mirror of
https://github.com/tobspr/shapez.io.git
synced 2025-12-13 02:01:51 +00:00
fix option #2
This commit is contained in:
parent
966ab25dab
commit
56aea797bf
14
gulp/mod.js
14
gulp/mod.js
@ -1,3 +1,15 @@
|
||||
/**
|
||||
*
|
||||
* @param {string} source
|
||||
* @param {*} map
|
||||
* @returns
|
||||
*/
|
||||
module.exports = function (source, map) {
|
||||
return source + `\nexport let $s=(n,v)=>eval(n+"=v")`;
|
||||
const regex = /export (?:let|class) (?<name>\w+)/g;
|
||||
// @ts-ignore
|
||||
[...source.matchAll(regex)]
|
||||
.map(n => n.groups.name)
|
||||
.forEach(name => (source += `export const $S_${name}=(v)=>${name}=v;\n`));
|
||||
|
||||
return source;
|
||||
};
|
||||
|
||||
@ -79,7 +79,9 @@ export class ModLoader {
|
||||
return module[member];
|
||||
},
|
||||
set(v) {
|
||||
module["$s"](member, v);
|
||||
let fun = module["$S_" + member];
|
||||
if (!fun) throw new TypeError(`Assignment to constant shapez export "${member}"`);
|
||||
fun(v);
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user