-
Notifications
You must be signed in to change notification settings - Fork 567
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ZeroFrame Version Fix MTB - dependencies updated APIL - recursive parser bug fix
- Loading branch information
Showing
9 changed files
with
2,402 additions
and
32 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,234 @@ | ||
/* | ||
========================================================= | ||
Name : MetaScriptToolbox | ||
GitHub : | ||
Roll20 Contact : timmaugh | ||
Version : 0.0.2 | ||
Last Update : 6 SEP 2024 | ||
========================================================= | ||
*/ | ||
var API_Meta = API_Meta || {}; | ||
API_Meta.MetaScriptToolbox = { offset: Number.MAX_SAFE_INTEGER, lineCount: -1 }; | ||
{ try { throw new Error(''); } catch (e) { API_Meta.MetaScriptToolbox.offset = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - (12)); } } | ||
|
||
const MetaScriptToolbox = (() => { // eslint-disable-line no-unused-vars | ||
const apiproject = 'MetaScriptToolbox'; | ||
const version = '0.0.2'; | ||
const schemaVersion = 0.1; | ||
API_Meta[apiproject].version = version; | ||
const vd = new Date(1725630209434); | ||
const versionInfo = () => { | ||
log(`\u0166\u0166 ${apiproject} v${API_Meta[apiproject].version}, ${vd.getFullYear()}/${vd.getMonth() + 1}/${vd.getDate()} \u0166\u0166 -- offset ${API_Meta[apiproject].offset}`); | ||
}; | ||
const logsig = () => { | ||
// initialize shared namespace for all signed projects, if needed | ||
state.torii = state.torii || {}; | ||
// initialize siglogged check, if needed | ||
state.torii.siglogged = state.torii.siglogged || false; | ||
state.torii.sigtime = state.torii.sigtime || Date.now() - 3001; | ||
if (!state.torii.siglogged || Date.now() - state.torii.sigtime > 3000) { | ||
const logsig = '\n' + | ||
' _____________________________________________ ' + '\n' + | ||
' )_________________________________________( ' + '\n' + | ||
' )_____________________________________( ' + '\n' + | ||
' ___| |_______________| |___ ' + '\n' + | ||
' |___ _______________ ___| ' + '\n' + | ||
' | | | | ' + '\n' + | ||
' | | | | ' + '\n' + | ||
' | | | | ' + '\n' + | ||
' | | | | ' + '\n' + | ||
' | | | | ' + '\n' + | ||
'______________|_|_______________|_|_______________' + '\n' + | ||
' ' + '\n'; | ||
log(`${logsig}`); | ||
state.torii.siglogged = true; | ||
state.torii.sigtime = Date.now(); | ||
} | ||
return; | ||
}; | ||
const checkInstall = () => { | ||
if (!state.hasOwnProperty(apiproject) || state[apiproject].version !== schemaVersion) { | ||
log(` > Updating ${apiproject} Schema to v${schemaVersion} <`); | ||
switch (state[apiproject] && state[apiproject].version) { | ||
|
||
case 0.1: | ||
/* falls through */ | ||
|
||
case 'UpdateSchemaVersion': | ||
state[apiproject].version = schemaVersion; | ||
break; | ||
|
||
default: | ||
state[apiproject] = { | ||
settings: {}, | ||
defaults: {}, | ||
version: schemaVersion | ||
} | ||
break; | ||
} | ||
} | ||
}; | ||
let stateReady = false; | ||
const assureState = () => { | ||
if (!stateReady) { | ||
checkInstall(); | ||
stateReady = true; | ||
} | ||
}; | ||
|
||
const checkDependencies = (deps) => { | ||
/* pass array of objects like | ||
{ name: 'ModName', version: '#.#.#' || '', mod: ModName || undefined, checks: [ [ExposedItem, type], [ExposedItem, type] ] } | ||
*/ | ||
const dependencyEngine = (deps) => { | ||
const versionCheck = (mv, rv) => { | ||
let modv = [...mv.split('.'), ...Array(4).fill(0)].slice(0, 4); | ||
let reqv = [...rv.split('.'), ...Array(4).fill(0)].slice(0, 4); | ||
return reqv.reduce((m, v, i) => { | ||
if (m.pass || m.fail) return m; | ||
if (i < 3) { | ||
if (parseInt(modv[i]) > parseInt(reqv[i])) m.pass = true; | ||
else if (parseInt(modv[i]) < parseInt(reqv[i])) m.fail = true; | ||
} else { | ||
// all betas are considered below the release they are attached to | ||
if (reqv[i] === 0 && modv[i] === 0) m.pass = true; | ||
else if (modv[i] === 0) m.pass = true; | ||
else if (reqv[i] === 0) m.fail = true; | ||
else if (parseInt(modv[i].slice(1)) >= parseInt(reqv[i].slice(1))) m.pass = true; | ||
} | ||
return m; | ||
}, { pass: false, fail: false }).pass; | ||
}; | ||
|
||
let result = { passed: true, failures: {}, optfailures: {} }; | ||
deps.forEach(d => { | ||
let failObj = d.optional ? result.optfailures : result.failures; | ||
if (!d.mod) { | ||
if (!d.optional) result.passed = false; | ||
failObj[d.name] = 'Not found'; | ||
return; | ||
} | ||
if (d.version && d.version.length) { | ||
if (!(API_Meta[d.name].version && API_Meta[d.name].version.length && versionCheck(API_Meta[d.name].version, d.version))) { | ||
if (!d.optional) result.passed = false; | ||
failObj[d.name] = `Incorrect version. Required v${d.version}. ${API_Meta[d.name].version && API_Meta[d.name].version.length ? `Found v${API_Meta[d.name].version}` : 'Unable to tell version of current.'}`; | ||
return; | ||
} | ||
} | ||
d.checks.reduce((m, c) => { | ||
if (!m.passed) return m; | ||
let [pname, ptype] = c; | ||
if (!d.mod.hasOwnProperty(pname) || typeof d.mod[pname] !== ptype) { | ||
if (!d.optional) m.passed = false; | ||
failObj[d.name] = `Incorrect version.`; | ||
} | ||
return m; | ||
}, result); | ||
}); | ||
return result; | ||
}; | ||
let depCheck = dependencyEngine(deps); | ||
let failures = '', contents = '', msg = ''; | ||
if (Object.keys(depCheck.optfailures).length) { // optional components were missing | ||
failures = Object.keys(depCheck.optfailures).map(k => `• <code>${k}</code> : ${depCheck.optfailures[k]}`).join('<br>'); | ||
contents = `<span style="font-weight: bold">${apiproject}</span> utilizies one or more other scripts for optional features, and works best with those scripts installed. You can typically find these optional scripts in the 1-click Mod Library:<br>${failures}`; | ||
msg = `<div style="width: 100%;border: none;border-radius: 0px;min-height: 60px;display: block;text-align: left;white-space: pre-wrap;overflow: hidden"><div style="font-size: 14px;font-family: "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif"><div style="background-color: #000000;border-radius: 6px 6px 0px 0px;position: relative;border-width: 2px 2px 0px 2px;border-style: solid;border-color: black;"><div style="border-radius: 18px;width: 35px;height: 35px;position: absolute;left: 3px;top: 2px;"><img style="background-color: transparent ; float: left ; border: none ; max-height: 40px" src="${typeof apilogo !== 'undefined' ? apilogo : 'https://i.imgur.com/kxkuQFy.png'}"></div><div style="background-color: #c94d4d;font-weight: bold;font-size: 18px;line-height: 36px;border-radius: 6px 6px 0px 0px;padding: 4px 4px 0px 43px;color: #ffffff;min-height: 38px;">MISSING MOD DETECTED</div></div><div style="background-color: white;padding: 4px 8px;border: 2px solid #000000;border-bottom-style: none;color: #404040;">${contents}</div><div style="background-color: white;text-align: right;padding: 4px 8px;border: 2px solid #000000;border-top-style: none;border-radius: 0px 0px 6px 6px"></div></div></div>`; | ||
sendChat(apiproject, `/w gm ${msg}`); | ||
} | ||
if (!depCheck.passed) { | ||
failures = Object.keys(depCheck.failures).map(k => `• <code>${k}</code> : ${depCheck.failures[k]}`).join('<br>'); | ||
contents = `<span style="font-weight: bold">${apiproject}</span> requires other scripts to work. Please use the 1-click Mod Library to correct the listed problems:<br>${failures}`; | ||
msg = `<div style="width: 100%;border: none;border-radius: 0px;min-height: 60px;display: block;text-align: left;white-space: pre-wrap;overflow: hidden"><div style="font-size: 14px;font-family: "Segoe UI", Roboto, Ubuntu, Cantarell, "Helvetica Neue", sans-serif"><div style="background-color: #000000;border-radius: 6px 6px 0px 0px;position: relative;border-width: 2px 2px 0px 2px;border-style: solid;border-color: black;"><div style="border-radius: 18px;width: 35px;height: 35px;position: absolute;left: 3px;top: 2px;"><img style="background-color: transparent ; float: left ; border: none ; max-height: 40px" src="${typeof apilogo !== 'undefined' ? apilogo : 'https://i.imgur.com/kxkuQFy.png'}"></div><div style="background-color: #c94d4d;font-weight: bold;font-size: 18px;line-height: 36px;border-radius: 6px 6px 0px 0px;padding: 4px 4px 0px 43px;color: #ffffff;min-height: 38px;">MISSING MOD DETECTED</div></div><div style="background-color: white;padding: 4px 8px;border: 2px solid #000000;border-bottom-style: none;color: #404040;">${contents}</div><div style="background-color: white;text-align: right;padding: 4px 8px;border: 2px solid #000000;border-top-style: none;border-radius: 0px 0px 6px 6px"></div></div></div>`; | ||
sendChat(apiproject, `/w gm ${msg}`); | ||
return false; | ||
} | ||
return true; | ||
}; | ||
|
||
on('ready', () => { | ||
versionInfo(); | ||
assureState(); | ||
logsig(); | ||
let reqs = [ | ||
{ | ||
name: 'ZeroFrame', | ||
version: `1.2.2`, | ||
mod: typeof ZeroFrame !== 'undefined' ? ZeroFrame : undefined, | ||
checks: [['RegisterMetaOp', 'function']], | ||
}, | ||
{ | ||
name: 'APILogic', | ||
version: `2.0.9`, | ||
mod: typeof APILogic !== 'undefined' ? APILogic : undefined, | ||
checks: [], | ||
}, | ||
{ | ||
name: 'Fetch', | ||
version: `2.1.1`, | ||
mod: typeof Fetch !== 'undefined' ? Fetch : undefined, | ||
checks: [], | ||
}, | ||
{ | ||
name: 'SelectManager', | ||
version: `1.1.8`, | ||
mod: typeof SelectManager !== 'undefined' ? SelectManager : undefined, | ||
checks: [['GetPlayerID', 'function'], ['GetSelected', 'function'], ['GetWho', 'function']], | ||
}, | ||
{ | ||
name: 'Muler', | ||
version: `2.0.2`, | ||
mod: typeof Muler !== 'undefined' ? Muler : undefined, | ||
checks: [], | ||
}, | ||
{ | ||
name: 'Plugger', | ||
version: `1.0.9`, | ||
mod: typeof Plugger !== 'undefined' ? Plugger : undefined, | ||
checks: [], | ||
}, | ||
{ | ||
name: 'MathOps', | ||
version: `1.0.8`, | ||
mod: typeof MathOps !== 'undefined' ? MathOps : undefined, | ||
checks: [['MathProcessor', 'function']], | ||
}, | ||
{ | ||
name: 'libTokenMarkers', | ||
version: `0.1.2`, | ||
mod: typeof libTokenMarkers !== 'undefined' ? libTokenMarkers : undefined, | ||
checks: [['getStatus', 'function'], ['getStatuses', 'function'], ['getOrderedList', 'function']] | ||
}, | ||
{ | ||
name: 'libTable', | ||
version: `1.0.0`, | ||
mod: typeof libTable !== 'undefined' ? libTable : undefined, | ||
checks: [ | ||
['getTable', 'function'], | ||
['getTables', 'function'], | ||
['getItems', 'function'], | ||
['getItemsByIndex', 'function'], | ||
['getItemsByName', 'function'], | ||
['getItemsByWeight', 'function'], | ||
['getItemsByWeightedIndex', 'function'] | ||
] | ||
}, | ||
{ | ||
name: 'checkLightLevel', | ||
// version: `1.0.0.b3`, | ||
mod: typeof checkLightLevel !== 'undefined' ? checkLightLevel : undefined, | ||
checks: [['isLitBy', 'function']], | ||
optional: true | ||
}, | ||
{ | ||
name: 'Messenger', | ||
version: `1.0.1`, | ||
mod: typeof Messenger !== 'undefined' ? Messenger : undefined, | ||
checks: [['Button', 'function'], ['MsgBox', 'function'], ['HE', 'function'], ['Html', 'function'], ['Css', 'function']] | ||
} | ||
]; | ||
if (!checkDependencies(reqs)) return; | ||
}); | ||
return {}; | ||
})(); | ||
|
||
{ try { throw new Error(''); } catch (e) { API_Meta.MetaScriptToolbox.lineCount = (parseInt(e.stack.split(/\n/)[1].replace(/^.*:(\d+):.*$/, '$1'), 10) - API_Meta.MetaScriptToolbox.offset); } } |
Oops, something went wrong.