hackmud-script-manager 0.18.0-b0e9141 → 0.19.0-f59b4c9
Sign up to get free protection for your applications and to get access to all the features.
- package/{assert-1556d989.js → assert-22a7ef8a.js} +0 -0
- package/bin/hsm.js +1 -1
- package/{countHackmudCharacters-1e122984.js → countHackmudCharacters-a08a265f.js} +0 -0
- package/generateTypeDeclaration.d.ts +1 -1
- package/generateTypeDeclaration.js +1 -1
- package/index.js +1 -1
- package/package.json +122 -122
- package/processScript/index.d.ts +1 -1
- package/processScript/index.js +1 -1
- package/processScript/minify.d.ts +1 -1
- package/processScript/minify.js +1 -1
- package/processScript/postprocess.d.ts +1 -1
- package/processScript/postprocess.js +1 -1
- package/processScript/preprocess.d.ts +1 -1
- package/processScript/preprocess.js +1 -1
- package/processScript/shared.d.ts +3 -3
- package/processScript/shared.js +1 -1
- package/processScript/transform.d.ts +1 -1
- package/processScript/transform.js +1 -1
- package/pull.d.ts +1 -1
- package/pull.js +1 -1
- package/push.d.ts +1 -1
- package/push.js +1 -1
- package/{spliceString-2c6f214f.js → spliceString-0e6b5d6d.js} +0 -0
- package/syncMacros.d.ts +1 -1
- package/syncMacros.js +1 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/watch.d.ts +1 -1
- package/watch.js +1 -1
- /package/{writeFilePersistent-72dc81a3.js → writeFilePersistent-ee9c9bfd.js} +0 -0
File without changes
|
package/bin/hsm.js
CHANGED
@@ -1,2 +1,2 @@
|
|
1
1
|
#!/usr/bin/env node
|
2
|
-
import e from"chalk";import{watch as o}from"chokidar";import s from"fs";import{homedir as t}from"os";import{resolve as n,basename as a,extname as c,dirname as i,relative as l}from"path";import{s as r}from"../constants-9bb78688.js";import{D as g,w as f}from"../writeFilePersistent-72dc81a3.js";import{generateTypeDeclaration as h}from"../generateTypeDeclaration.js";import{a as m}from"../assert-1556d989.js";import{syncMacros as p}from"../syncMacros.js";import{pull as u}from"../pull.js";import{c as d}from"../countHackmudCharacters-1e122984.js";const{readFile:b,rmdir:w,writeFile:k,mkdir:y}=s.promises,$=n(t(),".config"),j=n($,"hsm.json"),v=new Map,P=[];let C;const S=e.rgb(255,244,4),N=e.rgb(243,249,152),q=e.rgb(179,255,155),x=e.rgb(255,150,224),F=e.rgb(30,255,0),O=e.rgb(202,202,202),B=new g((e=>{let o=0;for(const s of e)o+=(o>>1)+o+"xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(s)+1;return[S,N,q,x,F,O][o%6](e)}));for(const e of process.argv.slice(2))if("-"==e[0]){const[o,s]=e.split("=");let t=s;if(t)if("true"==t)t=!0;else if("false"==t)t=!1;else{const e=Number(t);isFinite(e)&&(t=e)}else t=!0;if("-"==e[1])v.set(o.slice(2),t);else for(const e of o.slice(1))v.set(e,t)}else P.push(e);function help(){switch(P[0]){case"config":switch(P[1]){case"get":console.log("hsm config get <key>");break;case"set":console.log("hsm config set <key> <value>");break;case"delete":console.log("hsm config delete <key>");break;default:console.log("hsm config <get, delete, set>")}break;case"push":console.log('hsm push <dir> [..."<script user>.<script name>"] [--skip-minify] [--mangle-names]');break;case"dev":case"watch":console.log(`hsm ${P[0]} <dir> [..."<script user>.<script name>"] [--skip-minify] [--mangle-names]`);break;case"pull":console.log("hsm pull <script user>.<script name>");break;case"minify":case"golf":console.log(`${a(process.argv[1])} ${P[0]} <target> [output]`);break;default:console.log("hsm <push, watch, pull, config, golf>")}}function version(){console.log("0.18.0-b0e9141")}async function getConfig(){return C||(C=await b(j,{encoding:"utf-8"}).then((e=>{let o;try{o=JSON.parse(e)}catch{return console.log("config file was corrupted, resetting"),{}}return o&&"object"==typeof o?o:(console.log("config file was corrupted, resetting"),{})}),(()=>(console.log(`creating config file at ${j}`),{}))))}function exploreObject(e,o,s=!1){for(const n of o){var t;e=s?"object"==typeof e[n]?e[n]:e[n]={}:null===(t=e)||void 0===t?void 0:t[n]}return e}function updateConfig(){if(C){const e=JSON.stringify(C,void 0,"\t");k(j,e).catch((async o=>{switch(o.code){case"EISDIR":await w(j);break;case"ENOENT":await y($);break;default:throw o}k(j,e)}))}}function onPushLogger({file:o,users:s,minLength:t,error:i}){i?console.log(`error "${e.bold(i.message)}" in ${e.bold(o)}`):console.log(`pushed ${e.bold(o)} to ${s.map((o=>e.bold(B.get(o)))).join(", ")} | ${e.bold(String(t))} chars | ${e.bold(`${n(C.hackmudPath,s[0],"scripts",a(o,c(o)))}.js`)}`)}(async()=>{if(v.get("version")||v.get("v"))version();else if(v.get("help")||v.get("h"))help();else{switch(P[0]){case"push":{const e=await getConfig();if(!e.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const o=P[1];if(!o){console.error("specify the directory to watch"),help();break}const{push:s}=await import("../push.js"),t=e.hackmudPath,n=P.slice(2);n.length||n.push("*.*"),v.has("skip-minify")&&v.has("mangle-names")&&console.warn("pointless specifying both --skip-minify and --mangle-names");let a=v.get("force-quine-cheats");null!=a&&"boolean"!=typeof a&&(console.warn("warning: `--force-quine-cheats` should be `true` or `false`"),a=Boolean(a));(await s(o,t,{scripts:n,onPush:onPushLogger,minify:!v.get("skip-minify"),mangleNames:Boolean(v.get("mangle-names")),forceQuineCheats:a})).length||console.warn("couldn't find any scripts to push"),updateConfig()}break;case"dev":case"watch":{var s;if(!P[1]){console.error("specify the directory to watch"),help();break}const e=await getConfig();if(!e.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const{watch:o}=await import("../watch.js"),t=P.slice(2);t.length||t.push("*.*"),v.has("skip-minify")&&v.has("mangle-names")&&console.warn("pointless specifying both --skip-minify and --mangle-names");let n=v.get("force-quine-cheats");null!=n&&"boolean"!=typeof n&&(console.warn("warning: `--force-quine-cheats` should be `true` or `false`"),n=Boolean(n)),o(P[1],e.hackmudPath,{scripts:t,onPush:onPushLogger,typeDeclarationPath:null===(s=v.get("type-declaration-path")||v.get("type-declaration")||v.get("dts")||v.get("gen-types"))||void 0===s?void 0:s.toString(),minify:!v.get("skip-minify"),mangleNames:Boolean(v.get("mangle-names")),onReady:()=>console.log("watching"),forceQuineCheats:n})}break;case"pull":{const e=await getConfig();if(!e.hackmudPath){console.log("you need to set hackmudPath in config before you can use this command");break}const o=P[1];if(!o){help();break}const s=P[2]||".",t=e.hackmudPath;try{await u(s,t,o)}catch{console.log("something went wrong, did you forget to #down the script?")}}break;case"sync-macros":{const{hackmudPath:e}=await getConfig();if(!e){console.log("you need to set hackmudPath in config before you can use this command");break}const{macrosSynced:o,usersSynced:s}=await p(e);console.log(`synced ${o} macros to ${s} users`)}break;case"generate-type-declaration":case"gen-type-declaration":case"gen-dts":case"gen-types":{const o=n(P[1]||"."),s=h(o,(await getConfig()).hackmudPath);let t=n(P[2]||"./player.d.ts");try{await k(t,s)}catch(e){if(m(e instanceof Error),"EISDIR"!=e.code)throw e;t=n(t,"player.d.ts"),await k(t,s)}console.log(`wrote type declaration to ${e.bold(t)}`)}break;case"config":switch(P[1]){case"get":P[2]?console.log(exploreObject(await getConfig(),P[2].split("."))):console.log(await getConfig());break;case"delete":if(P[2]){var t;const e=P[2].split("."),o=e.pop();if(!e.length){help();break}const s=await getConfig();null===(t=exploreObject(s,e))||void 0===t||delete t[o],console.log(s)}else console.log("Usage:\nhsm config delete <key>");break;case"set":if(P[2]&&P[3]){const e=P[2].split(".");if(!e.length){help();break}const o=e.pop(),s=await getConfig();if(e.length||"hackmudPath"!=o){let t=s;for(const o of e)"object"==typeof t[o]||(t[o]={}),t=t[o];t[o]=P[3]}else s.hackmudPath=n(P[3]);console.log(s)}else console.log("Usage:\nhsm config set <key> <value>");break;default:P[1]&&console.log("unknown command"),help()}break;case"help":case"h":help();break;case"version":case"v":version();break;case"golf":case"minify":{const s=P[1];if(!s){console.log(`Target required\nUsage: ${a(process.argv[1])} ${P[0]} <target> [output]`);break}const t=c(s);if(!r.includes(t)){console.log(`Unsupported file extension "${e.bold(t)}"\nSupported extensions are "${r.map((o=>e.bold(o))).join('", "')}"`);break}v.get("watch")?o(s,{awaitWriteFinish:{stabilityThreshold:100}}).on("ready",(()=>console.log(`watching ${s}`))).on("change",(()=>golfFile(s,t))):await golfFile(s,t)}break;default:P[0]&&console.log("unknown command"),help()}updateConfig()}async function golfFile(o,s){const{processScript:t}=await import("../processScript/index.js");await b(o,{encoding:"utf-8"}).then((async c=>{const r=a(o,s),g=r.endsWith(".src"),h=g?r.slice(0,-4):r;let m="UNKNOWN";"scripts"==a(n(o,".."))&&"hackmud"==a(n(o,"../../.."))&&(m=a(n(o,"../..")));const p=!v.get("skip-minify"),u=Boolean(v.get("mangle-names"));!p&&u&&console.warn("warning: `--mangle-names` has no effect while `--skip-minify` is active");let b=v.get("force-quine-cheats");null!=b&&"boolean"!=typeof b&&(console.warn("warning: `--force-quine-cheats` should be `true` or `false`"),b=Boolean(b));const w=performance.now(),{script:k,warnings:y}=await t(c,{minify:p,scriptUser:m,scriptName:h,filePath:o,mangleNames:u,forceQuineCheats:b}),$=performance.now()-w;for(const{message:o,line:s}of y)console.log(`warning "${e.bold(o)}" on line ${e.bold(String(s))}`);let j;j=P[2]?P[2]:n(i(o),g?`${h}.js`:".js"==s?`${r}.min.js`:`${r}.js`);const C=d(k);await f(j,k).catch((async e=>{if(!P[2]||"EISDIR"!=e.code)throw e;j=n(j,`${a(o,s)}.js`),await f(j,k)})).then((()=>console.log(`wrote ${e.bold(C)} chars to ${e.bold(l(".",j))} | took ${Math.round(100*$)/100}ms`)),(e=>console.log(e.message)))}),(e=>console.log(e.message)))}})();
|
2
|
+
import{readFile as e,writeFile as t,mkdir as n,rmdir as a}from"fs/promises";import{homedir as s}from"os";import{s as o}from"../constants-9bb78688.js";import{generateTypeDeclaration as i}from"../generateTypeDeclaration.js";import{pull as r}from"../pull.js";import{syncMacros as c}from"../syncMacros.js";import{resolve as l,extname as f,basename as $,dirname as p,relative as h}from"path";import{D as m,w as d}from"../writeFilePersistent-ee9c9bfd.js";import{a as g}from"../assert-22a7ef8a.js";import{c as u}from"../countHackmudCharacters-a08a265f.js";import"fs";const y=l(s(),".config"),b=l(y,"hsm.json"),k=new Map,w=[],v=new m((e=>{let t=0;for(const n of e)t+=(t>>1)+t+"xi1_8ratvsw9hlbgm02y5zpdcn7uekof463qj".indexOf(n)+1;return[W,_,I,D,x,q][t%6](e)})),logNeedHackmudPathMessage=()=>console.error(R(`${C("You need to set hackmudPath in config before you can use this command")}\n\n${T("To fix this:")}\nOpen hackmud and run "${z("#dir")}"\nThis will open a file browser and print your hackmud user's script directory\nGo up 2 directories and then copy the path\nThen in a terminal run "${z("hsm")} ${x("config set")} ${A("hackmudPath")} ${q("<the path you copied>")}"`)),logHelp=()=>{const e="Push scripts from a directory to hackmud user's scripts directories",t="Watch a directory and push a script when modified",n="Minify a script file on the spot",a="Generate a type declaration file for a directory of scripts",s="Sync macros across all hackmud users",o="Retrieve a value from the config file",i="Assign a value to the config file",r="Remove a key and value from the config file",c="Pull a script a from a hackmud user's script directory",l="Skip minification to produce a readable script",f="Reduce character count further but lose function names in error call stacks",$="Force quine cheats even if the character count is higher";switch(console.log(J("Version")+R(": ")+A("0.19.0-f59b4c9")),w[0]){case"config":switch(w[1]){case"get":console.log(`\n${W(o)}\n\n${T("Usage:")}\n${z("hsm")} ${x(`${w[0]} ${w[1]}`)} ${q("<key>")}`);break;case"set":console.log(`\n${W(i)}\n\n${T("Usage:")}\n${z("hsm")} ${x(`${w[0]} ${w[1]}`)} ${q("<key> <value>")}`);break;case"delete":console.log(`\n${W(r)}\n\n${T("Usage:")}\n${z("hsm")} ${x(`${w[0]} ${w[1]}`)} ${q("<key>")}`);break;default:console.log(R(`${J("Config path")}: ${A(b)}\n\n${W("Modify the config file")}\n\n${T("Usage:")}\n${z("hsm")} ${x(`${w[0]} get`)} ${q("<key>")}\n ${o}\n${z("hsm")} ${x(`${w[0]} set`)} ${q("<key> <value>")}\n ${i}\n${z("hsm")} ${x(`${w[0]} delete`)} ${q("<key>")}\n ${r}`))}break;case"push":console.log(R(`\n${W(e)}\n\n${T("Usage:")}\n${z("hsm")} ${x(w[0])} ${q("<directory> [<script user>.<script name>...]")}\n\n${T("Options:")}\n${J("--skip-minify")}\n ${l}\n${J("--mangle-names")}\n ${f}\n${J("--force-quine-cheats")}\n ${$}`));break;case"dev":case"watch":console.log(R(`${J("Aliases")}: ${A("watch, dev")}\n\n${W(t)}\n\n${T("Usage:")}\n${z("hsm")} ${x(w[0])} ${q("<directory> [<script user>.<script name>...]")}\n\n${T("Options:")}\n${J("--skip-minify")}\n ${l}\n${J("--mangle-names")}\n ${f}\n${J("--type-declaration-path")}=${q("<path>")}\n Path to generate a type declaration file for the scripts\n${J("--force-quine-cheats")}\n ${$}`));break;case"pull":console.log(R(`\n${W(c)}\n\n${T("Usage:")}\n${z("hsm")} ${x(w[0])} ${q("<script user>")}${A(".")}${q("<script name>")}`));break;case"minify":case"golf":console.log(R(`${J("Aliases")}: ${A("minify, golf")}\n\n${W(n)}\n\n${T("Usage:")}\n${z("hsm")} ${x(w[0])} ${q("<target> [output path]")}\n\n${T("Options:")}\n${J("--skip-minify")}\n ${l}\n${J("--mangle-names")}\n ${f}\n${J("--force-quine-cheats")}\n ${$}\n${J("--watch")}\n Watch for changes`));break;case"generate-type-declaration":case"gen-type-declaration":case"gen-dts":case"gen-types":console.log(R(`${J("Aliases")}: ${A("generate-type-declaration, gen-type-declaration, gen-types, gen-dts")}\n\n${W(a)}\n\n${T("Usage:")}\n${z("hsm")} ${x(w[0])} ${q("<directory> [output path]")}`));break;case"sync-macros":console.log(`\n${W(s)}`);break;default:console.log(R(`\n${W("Hackmud Script Manager")}\n\n${T("Commands:")}\n${x("push")}\n ${e}\n${x("watch")}, ${x("dev")}\n ${t}\n${x("minify")}, ${x("golf")}\n ${n}\n${x("generate-type-declaration")}, ${x("gen-type-declaration")}, ${x("gen-types")}, ${x("gen-dts")}\n ${a}\n${x("sync-macros")}\n ${s}\n${x("config")}\n Modify and view the config file\n${x("pull")}\n ${c}`))}},exploreObject=(e,t,n=!1)=>{for(const s of t){var a;e=n?"object"==typeof e[s]?e[s]:e[s]={}:null===(a=e)||void 0===a?void 0:a[s]}return e},logInfo=({file:e,users:t,minLength:n,error:a},s)=>{a?logError(`error "${U.bold(a.message)}" in ${U.bold(e)}`):console.log(`pushed ${U.bold(e)} to ${t.map((e=>U.bold(v.get(e)))).join(", ")} | ${U.bold(String(n))} chars | ${U.bold(`${l(s,t[0],"scripts",$(e,f(e)))}.js`)}`)},log=e=>{console.log(R(e))},logError=e=>{console.error(C(e)),process.exitCode=1};for(const e of process.argv.slice(2))if("-"==e[0]){const[t,n]=e.split("=");let a=n;if(a)if("true"==a)a=!0;else if("false"==a)a=!1;else{const e=Number(a);isFinite(e)&&(a=e)}else a=!0;if("-"==e[1])k.set(t.slice(2),a);else for(const e of t.slice(1))k.set(e,a)}else w.push(e);("v"==w[0]||"version"==w[0]||k.get("version")||k.get("v"))&&(console.log("0.19.0-f59b4c9"),process.exit());let j=!1;const S=e(b,{encoding:"utf-8"}).then((e=>{let t;try{t=JSON.parse(e)}catch{return log("Config file was corrupted, resetting"),{}}return t&&"object"==typeof t?("hackmudPath"in t&&"string"!=typeof t.hackmudPath&&(log('Property "hackmudPath" of config file was corrupted, removing'),delete t.hackmudPath),t):(log("Config file was corrupted, resetting"),{})}),(()=>(j=!0,{}))),P=import("../push.js"),N=import("../processScript/index.js"),O=import("../watch.js"),M=import("chokidar"),{default:U}=await import("chalk"),T=U.rgb(255,255,255),q=U.rgb(202,202,202),z=U.rgb(155,155,155),C=U.rgb(255,0,0),W=U.rgb(255,244,4),_=U.rgb(243,249,152),x=U.rgb(30,255,0),I=U.rgb(179,255,155),J=U.rgb(0,255,255),R=U.rgb(122,178,244),A=U.rgb(255,0,236),D=U.rgb(255,150,224);switch((k.get("help")||k.get("h"))&&(logHelp(),process.exit()),w[0]){case"push":{const{hackmudPath:e}=await S;if(!e){logNeedHackmudPathMessage();break}const t=w[1];if(!t){logError("Must provide the directory to push from\n"),logHelp();break}const n=w.slice(2);if(n.length){const e=n.find((e=>!/^(?:[a-z_][a-z\d_]{0,24}|\*)\.(?:[a-z_][a-z\d_]{0,24}|\*)$/.test(e)));if(e){logError(`Invalid script name: ${JSON.stringify(e)}\n`),logHelp();break}}else n.push("*.*");if(k.has("skip-minify")&&k.has("mangle-names")){logError(`Option ${J("--mangle-names")} is not compatible with ${J("--skip-minify")}\n`),logHelp();break}const a=k.get("skip-minify");let s;if(null!=a){if("boolean"!=typeof a){logError(`The value for ${J("--skip-minify")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}s=!a}const o=k.get("mangle-names");if(null!=o&&"boolean"!=typeof o){logError(`The value for ${J("--mangle-names")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const i=k.get("force-quine-cheats");if(null!=i&&"boolean"!=typeof i){logError(`The value for ${J("--force-quine-cheats")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const{push:r}=await P;(await r(t,e,{scripts:n,onPush:t=>logInfo(t,e),minify:s,mangleNames:o,forceQuineCheats:i})).length||logError("Could not find any scripts to push")}break;case"dev":case"watch":{var E;const{hackmudPath:e}=await S;if(!e){logNeedHackmudPathMessage();break}const t=w[1];if(!t){logError("Must provide the directory to watch\n"),logHelp();break}const n=w.slice(2);if(n.length){const e=n.find((e=>!/^(?:[a-z_][a-z\d_]{0,24}|\*)\.(?:[a-z_][a-z\d_]{0,24}|\*)$/.test(e)));if(e){logError(`Invalid script name: ${JSON.stringify(e)}\n`),logHelp();break}}else n.push("*.*");if(k.has("skip-minify")&&k.has("mangle-names")){logError(`Option ${J("--mangle-names")} is not compatible with ${J("--skip-minify")}\n`),logHelp();break}const a=k.get("skip-minify");let s;if(null!=a){if("boolean"!=typeof a){logError(`The value for ${J("--skip-minify")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}s=!a}const o=k.get("mangle-names");if(null!=o&&"boolean"!=typeof o){logError(`The value for ${J("--mangle-names")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const i=k.get("force-quine-cheats");if(null!=i&&"boolean"!=typeof i){logError(`The value for ${J("--force-quine-cheats")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const{watch:r}=await O;r(t,e,{scripts:n,onPush:t=>logInfo(t,e),typeDeclarationPath:null===(E=k.get("type-declaration-path")||k.get("type-declaration")||k.get("dts")||k.get("gen-types"))||void 0===E?void 0:E.toString(),minify:s,mangleNames:o,onReady:()=>log("Watching"),forceQuineCheats:i})}break;case"pull":{const{hackmudPath:e}=await S;if(!e){logNeedHackmudPathMessage();break}const t=w[1];if(!t){logError("Must provide the script to pull\n"),logHelp();break}const n=w[2]||".";try{await r(n,e,t)}catch(e){console.error(e),logError(`Something went wrong, did you forget to ${z("#down")} the script?`)}}break;case"sync-macros":{const{hackmudPath:e}=await S;if(!e){logNeedHackmudPathMessage();break}const{macrosSynced:t,usersSynced:n}=await c(e);log(`Synced ${t} macros to ${n} users`)}break;case"generate-type-declaration":case"gen-type-declaration":case"gen-dts":case"gen-types":{const e=w[1];if(!e){logError("Must provide target directory\n"),logHelp();break}const n=l(e),a=w[2]||"./player.d.ts",s=await i(n,(await S).hackmudPath);let o=l(a);try{await t(o,s)}catch(e){if(g(e instanceof Error),"EISDIR"!=e.code)throw e;o=l(o,"player.d.ts"),await t(o,s)}log(`Wrote type declaration to ${U.bold(o)}`)}break;case"config":switch(w[1]){case"get":{const e=w[2];e?log(exploreObject(await S,e.split("."))):console.log(await S)}break;case"delete":{var F;const e=w[2];if(!e){logError("Must provide a key to delete\n"),logHelp();break}const t=e.split("."),n=t.map((e=>/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e))).join("."),a=t.pop();null===(F=exploreObject(await S,t))||void 0===F||delete F[a],log(`Removed ${A(n)} from config file`)}break;case"set":{const e=w[2],o=w[3];if(!e){logError("Must provide a key and value\n"),logHelp();break}const i=e.split("."),r=i.map((e=>/^[A-Za-z_$][\w$]*$/.test(e)?e:JSON.stringify(e))).join(".");if(!o){logError(`Must provide a value for the key ${r}\n`),logHelp();break}const c=i.pop(),f=await S;if(i.length||"hackmudPath"!=c){let e=f;for(const t of i)"object"==typeof e[t]||(e[t]={}),e=e[t];e[c]=o}else f.hackmudPath=l(o.startsWith("~/")?s()+o.slice(1):o);console.log(f),(async e=>{const s=JSON.stringify(e,void 0,"\t");j&&log(`Creating config file at ${b}`),await t(b,s).catch((async e=>{switch(e.code){case"EISDIR":await a(b);break;case"ENOENT":await n(y);break;default:throw e}await t(b,s)}))})(f)}break;default:w[1]&&logError(`Unknown command: ${JSON.stringify(w[1])}\n`),logHelp()}break;case"help":case"h":logHelp();break;case"golf":case"minify":{const t=w[1];if(!t){logError("Must provide target\n"),logHelp();break}const n=f(t);if(!o.includes(n)){logError(`Unsupported file extension "${U.bold(n)}"\nSupported extensions are "${o.map((e=>U.bold(e))).join('", "')}"`);break}const{processScript:a}=await N,s=$(t,n),i=s.endsWith(".src"),r=i?s.slice(0,-4):s,c="scripts"==$(l(t,".."))&&"hackmud"==$(l(t,"../../.."))?$(l(t,"../..")):"UNKNOWN",m=!k.get("skip-minify");if(k.has("skip-minify")&&k.has("mangle-names")){logError(`Option ${J("--mangle-names")} would have no effect if minification is skipped\n`),logHelp();break}const g=k.get("mangle-names");if(null!=g&&"boolean"!=typeof g){logError(`The value for ${J("--mangle-names")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const y=g,b=k.get("force-quine-cheats");if(null!=b&&"boolean"!=typeof b){logError(`the value for ${J("--force-quine-cheats")} must be ${A("true")} or ${A("false")}\n`),logHelp();break}const v=b;let j=w[2]||l(p(t),i?`${r}.js`:".js"==n?`${s}.min.js`:`${s}.js`);const golfFile=()=>e(t,{encoding:"utf-8"}).then((async e=>{const s=performance.now(),{script:o,warnings:i}=await a(e,{minify:m,scriptUser:c,scriptName:r,filePath:t,mangleNames:y,forceQuineCheats:v}),f=performance.now()-s;for(const{message:e,line:t}of i)log(`Warning "${U.bold(e)}" on line ${U.bold(String(t))}`);await d(j,o).catch((async e=>{if(!w[2]||"EISDIR"!=e.code)throw e;j=l(j,`${$(t,n)}.js`),await d(j,o)})).then((()=>log(`Wrote ${U.bold(u(o))} chars to ${U.bold(h(".",j))} | took ${Math.round(100*f)/100}ms`)),(e=>logError(e.message)))}),(e=>logError(e.message)));if(k.get("watch")){const{watch:e}=await M;e(t,{awaitWriteFinish:{stabilityThreshold:100}}).on("ready",(()=>log(`Watching ${t}`))).on("change",golfFile)}else golfFile()}break;default:w[0]&&logError(`Unknown command: ${JSON.stringify(w[0])}\n`),logHelp()}
|
File without changes
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare
|
1
|
+
export declare const generateTypeDeclaration: (sourceDirectory: string, hackmudPath?: string) => Promise<string>;
|
2
2
|
export default generateTypeDeclaration;
|
@@ -1 +1 @@
|
|
1
|
-
import e
|
1
|
+
import{readdir as e}from"fs/promises";import{basename as t,resolve as n}from"path";const generateTypeDeclaration=async(s,i)=>{const a=new Set;if(i)for(const n of await e(i,{withFileTypes:!0}))n.isFile()&&n.name.endsWith(".key")&&a.add(t(n.name,".key"));const r=[],o=[],f={},l={};await Promise.all((await e(s,{withFileTypes:!0})).map((async i=>{if(i.isFile())i.name.endsWith(".ts")?i.name.endsWith(".d.ts")||r.push(t(i.name,".ts")):i.name.endsWith(".js")&&o.push(t(i.name,".js"));else if(i.isDirectory()){const r=[],o=[];f[i.name]=r,l[i.name]=o,a.add(i.name);for(const a of await e(n(s,i.name),{withFileTypes:!0}))a.isFile()&&(a.name.endsWith(".ts")?i.name.endsWith(".d.ts")||r.push(t(a.name,".ts")):a.name.endsWith(".js")&&o.push(t(a.name,".js")))}}))),s=n(s);let c="";for(const e of r)c+=`type $${e}$ = typeof import("${s}/${e}").default\n`;c+="\n";for(const e in f){const t=f[e];for(const n of t)c+=`type $${e}$${n}$ = typeof import("${s}/${e}/${n}").default\n`}c+="\ntype ArrayRemoveFirst<A> = A extends [ infer FirstItem, ...infer Rest ] ? Rest : never\n\ntype Subscript<T extends (...args: any) => any> =\n\t(...args: ArrayRemoveFirst<Parameters<T>>) => ReturnType<T> | ScriptFailure\n\ntype WildFullsec = Record<string, () => ScriptFailure> & {\n";for(const e of r)c+=`\t${e}: Subscript<$${e}$>\n`;for(const e of o)c+=`\t${e}: (...args: any) => any\n`;c+="}\n\ninterface PlayerFullsec {";let m=!0;for(const e of a){const t=f[e],n=l[e];if(t&&t.length||n&&n.length){if(m=!0,c+=`\n\t${e}: WildFullsec & {\n`,t)for(const n of t)c+=`\t\t${n}: Subscript<$${e}$${n}$>\n`;if(n)for(const e of n)c+=`\t\t${e}: (...args: any) => any\n`;c+="\t}"}else m&&(c+="\n",m=!1),c+=`\t${e}: WildFullsec`;c+="\n"}return c+="}\n",c};export{generateTypeDeclaration as default,generateTypeDeclaration};
|
package/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
export{s as supportedExtensions}from"./constants-9bb78688.js";export{generateTypeDeclaration}from"./generateTypeDeclaration.js";export{processScript}from"./processScript/index.js";export{pull}from"./pull.js";export{push}from"./push.js";export{syncMacros}from"./syncMacros.js";export{watch}from"./watch.js";import"fs";import"path";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-transform-exponentiation-operator";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./processScript/minify.js";import"acorn";import"terser";import"./processScript/shared.js";import"./assert-
|
1
|
+
export{s as supportedExtensions}from"./constants-9bb78688.js";export{generateTypeDeclaration}from"./generateTypeDeclaration.js";export{processScript}from"./processScript/index.js";export{pull}from"./pull.js";export{push}from"./push.js";export{syncMacros}from"./syncMacros.js";export{watch}from"./watch.js";import"fs/promises";import"path";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-transform-exponentiation-operator";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./processScript/minify.js";import"acorn";import"terser";import"./processScript/shared.js";import"./assert-22a7ef8a.js";import"./spliceString-0e6b5d6d.js";import"./countHackmudCharacters-a08a265f.js";import"./processScript/postprocess.js";import"./processScript/preprocess.js";import"import-meta-resolve";import"./processScript/transform.js";import"fs";import"./writeFilePersistent-ee9c9bfd.js";import"chokidar";
|
package/package.json
CHANGED
@@ -1,124 +1,124 @@
|
|
1
1
|
{
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
2
|
+
"name": "hackmud-script-manager",
|
3
|
+
"version": "0.19.0-f59b4c9",
|
4
|
+
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
|
+
"keywords": [
|
6
|
+
"api",
|
7
|
+
"command-line",
|
8
|
+
"script",
|
9
|
+
"manager",
|
10
|
+
"minification",
|
11
|
+
"minifier",
|
12
|
+
"hackmd",
|
13
|
+
"hackmud",
|
14
|
+
"javascipt",
|
15
|
+
"typescipt",
|
16
|
+
"typescript-support",
|
17
|
+
"golf",
|
18
|
+
"golfer"
|
19
|
+
],
|
20
|
+
"homepage": "https://github.com/samualtnorman/hackmud-script-manager#readme",
|
21
|
+
"bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
|
22
|
+
"license": "GPL-3.0-or-later",
|
23
|
+
"author": "Samual Norman",
|
24
|
+
"main": "index.js",
|
25
|
+
"repository": {
|
26
|
+
"type": "git",
|
27
|
+
"url": "https://github.com/samualtnorman/hackmud-script-manager.git"
|
28
|
+
},
|
29
|
+
"dependencies": {
|
30
|
+
"@babel/core": "^7.18.9",
|
31
|
+
"@babel/generator": "^7.18.9",
|
32
|
+
"@babel/parser": "^7.18.9",
|
33
|
+
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
34
|
+
"@babel/plugin-proposal-class-static-block": "^7.18.6",
|
35
|
+
"@babel/plugin-proposal-decorators": "^7.18.9",
|
36
|
+
"@babel/plugin-proposal-do-expressions": "^7.18.6",
|
37
|
+
"@babel/plugin-proposal-function-bind": "^7.18.9",
|
38
|
+
"@babel/plugin-proposal-function-sent": "^7.18.6",
|
39
|
+
"@babel/plugin-proposal-json-strings": "^7.18.6",
|
40
|
+
"@babel/plugin-proposal-logical-assignment-operators": "^7.18.9",
|
41
|
+
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
42
|
+
"@babel/plugin-proposal-numeric-separator": "^7.18.6",
|
43
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.18.9",
|
44
|
+
"@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
|
45
|
+
"@babel/plugin-proposal-optional-chaining": "^7.18.9",
|
46
|
+
"@babel/plugin-proposal-partial-application": "^7.18.9",
|
47
|
+
"@babel/plugin-proposal-pipeline-operator": "^7.18.9",
|
48
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.18.6",
|
49
|
+
"@babel/plugin-proposal-record-and-tuple": "^7.18.6",
|
50
|
+
"@babel/plugin-proposal-throw-expressions": "^7.18.6",
|
51
|
+
"@babel/plugin-transform-exponentiation-operator": "^7.18.6",
|
52
|
+
"@babel/plugin-transform-typescript": "^7.18.8",
|
53
|
+
"@babel/traverse": "^7.18.9",
|
54
|
+
"@babel/types": "^7.18.9",
|
55
|
+
"@bloomberg/record-tuple-polyfill": "^0.0.4",
|
56
|
+
"@rollup/plugin-babel": "^5.3.1",
|
57
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
58
|
+
"@rollup/plugin-json": "^4.1.0",
|
59
|
+
"@rollup/plugin-node-resolve": "^13.3.0",
|
60
|
+
"acorn": "^8.7.1",
|
61
|
+
"chalk": "^5.0.1",
|
62
|
+
"chokidar": "^3.5.3",
|
63
|
+
"import-meta-resolve": "^2.0.3",
|
64
|
+
"prettier": "^2.7.1",
|
65
|
+
"proxy-polyfill": "^0.3.2",
|
66
|
+
"rollup": "^2.77.0",
|
67
|
+
"terser": "^5.14.2"
|
68
|
+
},
|
69
|
+
"devDependencies": {
|
70
|
+
"@babel/preset-env": "^7.18.9",
|
71
|
+
"@babel/preset-typescript": "^7.18.6",
|
72
|
+
"@samual/lib": "^0.3.4",
|
73
|
+
"@types/babel__core": "^7.1.19",
|
74
|
+
"@types/babel__generator": "^7.6.4",
|
75
|
+
"@types/babel__traverse": "^7.17.1",
|
76
|
+
"@types/node": "^14.18.22",
|
77
|
+
"@types/prettier": "^2.6.3",
|
78
|
+
"@types/semver": "^7.3.10",
|
79
|
+
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
80
|
+
"@typescript-eslint/parser": "^5.30.7",
|
81
|
+
"eslint": "^8.20.0",
|
82
|
+
"eslint-plugin-array-func": "^3.1.7",
|
83
|
+
"eslint-plugin-eslint-comments": "^3.2.0",
|
84
|
+
"eslint-plugin-regexp": "^1.7.0",
|
85
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
86
|
+
"latest-version": "^7.0.0",
|
87
|
+
"rollup-plugin-preserve-shebang": "^1.0.1",
|
88
|
+
"rollup-plugin-terser": "^7.0.2",
|
89
|
+
"semver": "^7.3.7",
|
90
|
+
"typescript": "^4.7.4"
|
91
|
+
},
|
92
|
+
"optionalDependencies": {
|
93
|
+
"deasync": "^0.1.27"
|
94
|
+
},
|
95
|
+
"engines": {
|
96
|
+
"node": ">=14"
|
97
|
+
},
|
98
|
+
"types": "index.d.ts",
|
99
|
+
"type": "module",
|
100
|
+
"exports": {
|
101
|
+
".": {
|
102
|
+
"import": "./index.js",
|
103
|
+
"require": "./index.cjs"
|
104
|
+
},
|
105
|
+
"./*": "./*",
|
106
|
+
"./generateTypeDeclaration": "./generateTypeDeclaration.js",
|
107
|
+
"./index": "./index.js",
|
108
|
+
"./pull": "./pull.js",
|
109
|
+
"./push": "./push.js",
|
110
|
+
"./syncMacros": "./syncMacros.js",
|
111
|
+
"./watch": "./watch.js",
|
112
|
+
"./bin/hsm": "./bin/hsm.js",
|
113
|
+
"./processScript/index": "./processScript/index.js",
|
114
|
+
"./processScript": "./processScript/index.js",
|
115
|
+
"./processScript/minify": "./processScript/minify.js",
|
116
|
+
"./processScript/postprocess": "./processScript/postprocess.js",
|
117
|
+
"./processScript/preprocess": "./processScript/preprocess.js",
|
118
|
+
"./processScript/shared": "./processScript/shared.js",
|
119
|
+
"./processScript/transform": "./processScript/transform.js"
|
120
|
+
},
|
121
|
+
"bin": {
|
122
|
+
"hsm": "./bin/hsm.js"
|
123
|
+
}
|
124
124
|
}
|
package/processScript/index.d.ts
CHANGED
@@ -30,7 +30,7 @@ export declare type ProcessOptions = {
|
|
30
30
|
* @param code JavaScript or TypeScript code
|
31
31
|
* @param options {@link ProcessOptions details}
|
32
32
|
*/
|
33
|
-
export declare
|
33
|
+
export declare const processScript: (code: string, { minify: shouldMinify, uniqueID, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats }?: LaxPartial<ProcessOptions>) => Promise<{
|
34
34
|
script: string;
|
35
35
|
warnings: {
|
36
36
|
message: string;
|
package/processScript/index.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import e from"@babel/generator";import{parse as o}from"@babel/parser";import r from"@babel/plugin-proposal-class-properties";import t from"@babel/plugin-proposal-class-static-block";import a from"@babel/plugin-proposal-decorators";import p from"@babel/plugin-proposal-json-strings";import s from"@babel/plugin-proposal-logical-assignment-operators";import l from"@babel/plugin-proposal-nullish-coalescing-operator";import i from"@babel/plugin-proposal-numeric-separator";import n from"@babel/plugin-proposal-object-rest-spread";import
|
1
|
+
import e from"@babel/generator";import{parse as o}from"@babel/parser";import r from"@babel/plugin-proposal-class-properties";import t from"@babel/plugin-proposal-class-static-block";import a from"@babel/plugin-proposal-decorators";import p from"@babel/plugin-proposal-json-strings";import s from"@babel/plugin-proposal-logical-assignment-operators";import l from"@babel/plugin-proposal-nullish-coalescing-operator";import i from"@babel/plugin-proposal-numeric-separator";import n from"@babel/plugin-proposal-object-rest-spread";import m from"@babel/plugin-proposal-optional-catch-binding";import c from"@babel/plugin-proposal-optional-chaining";import u from"@babel/plugin-proposal-private-property-in-object";import f from"@babel/plugin-transform-exponentiation-operator";import d from"@babel/traverse";import b from"@babel/types";import g from"@rollup/plugin-babel";import h from"@rollup/plugin-commonjs";import y from"@rollup/plugin-json";import w from"@rollup/plugin-node-resolve";import{resolve as k}from"path";import x from"prettier";import{rollup as j}from"rollup";import{s as v}from"../constants-9bb78688.js";import{minify as C}from"./minify.js";export{minify}from"./minify.js";import{postprocess as E}from"./postprocess.js";export{postprocess}from"./postprocess.js";import{preprocess as S}from"./preprocess.js";export{preprocess}from"./preprocess.js";import{includesIllegalString as L,replaceUnsafeStrings as $}from"./shared.js";import{transform as N}from"./transform.js";export{transform}from"./transform.js";import{a as I}from"../assert-22a7ef8a.js";import"acorn";import"terser";import"../spliceString-0e6b5d6d.js";import"../countHackmudCharacters-a08a265f.js";import"import-meta-resolve";const{default:P}=g,{format:D}=x,{default:_}=e,{default:M}=d,processScript=async(e,{minify:d=!0,uniqueID:g=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),scriptUser:x="UNKNOWN",scriptName:O="UNKNOWN",filePath:T,mangleNames:U=!1,forceQuineCheats:W}={})=>{I(/^\w{11}$/.exec(g));const q=e;let F,H;const z=/^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(e);if(z)e=`export default ${e}`,({autocomplete:F}=z.groups);else for(const o of e.split("\n")){const e=/^\s*\/\/(?<commentContent>.+)/.exec(o);if(!e)break;const r=e.groups.commentContent.trim();if(r.startsWith("@autocomplete "))F=r.slice(14).trimStart();else if(r.startsWith("@seclevel ")){const e=r.slice(10).trimStart().toLowerCase();switch(e){case"fullsec":case"full":case"fs":case"4s":case"f":case"4":H=4;break;case"highsec":case"high":case"hs":case"3s":case"h":case"3":H=3;break;case"midsec":case"mid":case"ms":case"2s":case"m":case"2":H=2;break;case"lowsec":case"low":case"ls":case"1s":case"l":case"1":H=1;break;case"nullsec":case"null":case"ns":case"0s":case"n":case"0":H=0;break;default:throw new Error(`unrecognised seclevel "${e}"`)}}}I(/^\w{11}$/.exec(g));const K=[[a.default,{decoratorsBeforeExport:!0}],[r.default],[t.default],[u.default],[s.default],[i.default],[l.default],[c.default],[m.default],[p.default],[n.default],[f.default]];let Q;if(T)if(Q=k(T),T.endsWith(".ts"))K.push([(await import("@babel/plugin-transform-typescript")).default,{allowDeclareFields:!0,optimizeConstEnums:!0}]);else{const[e,o,r,t,a,p,s]=await Promise.all([import("@babel/plugin-proposal-do-expressions"),import("@babel/plugin-proposal-function-bind"),import("@babel/plugin-proposal-function-sent"),import("@babel/plugin-proposal-partial-application"),import("@babel/plugin-proposal-pipeline-operator"),import("@babel/plugin-proposal-throw-expressions"),import("@babel/plugin-proposal-record-and-tuple")]);K.push([e.default],[o.default],[r.default],[t.default],[a.default,{proposal:"hack",topicToken:"%"}],[p.default],[s.default,{syntaxType:"hash",importPolyfill:!0}])}else{Q=`${g}.ts`;const[e,o,r,t,a,p,s,l]=await Promise.all([import("@babel/plugin-transform-typescript"),import("@babel/plugin-proposal-do-expressions"),import("@babel/plugin-proposal-function-bind"),import("@babel/plugin-proposal-function-sent"),import("@babel/plugin-proposal-partial-application"),import("@babel/plugin-proposal-pipeline-operator"),import("@babel/plugin-proposal-throw-expressions"),import("@babel/plugin-proposal-record-and-tuple")]);K.push([e.default,{allowDeclareFields:!0,optimizeConstEnums:!0}],[o.default],[r.default],[t.default],[a.default],[p.default,{proposal:"hack",topicToken:"%"}],[s.default],[l.default,{syntaxType:"hash",importPolyfill:!0}])}const V=await j({input:Q,plugins:[{name:"hackmud-script-manager",transform:async e=>(await S(e,{uniqueID:g})).code},P({babelHelpers:"bundled",plugins:K,configFile:!1,extensions:v}),h(),w({extensions:v}),y()],treeshake:{moduleSideEffects:!1}}),A=["NULLSEC","LOWSEC","MIDSEC","HIGHSEC","FULLSEC"];e=(await V.generate({})).output[0].code;const{file:B,seclevel:G}=N(o(e,{sourceType:"module"}),q,{uniqueID:g,scriptUser:x,scriptName:O});if(null!=H&&G<H)throw new Error(`detected seclevel ${A[G]} is lower than stated seclevel ${A[H]}`);if(e=_(B).code,d?e=await C(B,{uniqueID:g,mangleNames:U,forceQuineCheats:W,autocomplete:F}):(M(B,{MemberExpression({node:e}){e.computed||(I("Identifier"==e.property.type),"prototype"==e.property.name?(e.computed=!0,e.property=b.stringLiteral("prototype")):"__proto__"==e.property.name?(e.computed=!0,e.property=b.stringLiteral("__proto__")):L(e.property.name)&&(e.computed=!0,e.property=b.stringLiteral($(g,e.property.name))))},VariableDeclarator(e){const renameVariables=o=>{switch(o.type){case"Identifier":L(o.name)&&e.scope.rename(o.name,`$${Math.floor(Math.random()*2**52).toString(36).padStart(11,"0")}`);break;case"ObjectPattern":for(const e of o.properties)I("ObjectProperty"==e.type),renameVariables(e.value);break;case"ArrayPattern":for(const e of o.elements)e&&renameVariables(e);break;default:throw new Error(`unknown lValue type "${o.type}"`)}};renameVariables(e.node.id)},ObjectProperty({node:e}){"Identifier"==e.key.type&&L(e.key.name)&&(e.key=b.stringLiteral($(g,e.key.name)),e.shorthand=!1)},StringLiteral({node:e}){e.value=$(g,e.value)},TemplateLiteral({node:e}){for(const o of e.quasis)o.value.cooked?(o.value.cooked=$(g,o.value.cooked),o.value.raw=o.value.cooked.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"$\\{")):o.value.raw=$(g,o.value.raw)},RegExpLiteral(e){e.node.pattern=$(g,e.node.pattern),delete e.node.extra}}),e=D(_(B,{comments:!1}).code,{parser:"babel",arrowParens:"avoid",semi:!1,trailingComma:"none"})),e=E(e,G,g),L(e))throw new Error('you found a weird edge case where I wasn\'t able to replace illegal strings like "SC$", please report thx');return{script:e,warnings:[]}};export{processScript as default,processScript};
|
@@ -20,5 +20,5 @@ declare type MinifyOptions = {
|
|
20
20
|
* @param file babel ast node representing a file containing transformed code
|
21
21
|
* @param options {@link MinifyOptions details}
|
22
22
|
*/
|
23
|
-
export declare
|
23
|
+
export declare const minify: (file: File, { uniqueID, mangleNames, forceQuineCheats, autocomplete }?: LaxPartial<MinifyOptions>) => Promise<string>;
|
24
24
|
export default minify;
|
package/processScript/minify.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import e from"@babel/generator";import t from"@babel/traverse";import r from"@babel/types";import{tokenizer as i,tokTypes as n}from"acorn";import*as a from"terser";import{getReferencePathsToGlobal as o,includesIllegalString as s,replaceUnsafeStrings as
|
1
|
+
import e from"@babel/generator";import t from"@babel/traverse";import r from"@babel/types";import{tokenizer as i,tokTypes as n}from"acorn";import*as a from"terser";import{getReferencePathsToGlobal as o,includesIllegalString as s,replaceUnsafeStrings as l}from"./shared.js";import{a as p}from"../assert-22a7ef8a.js";import{s as u}from"../spliceString-0e6b5d6d.js";import{c}from"../countHackmudCharacters-a08a265f.js";const{default:d}=e,{default:f}=t,minify=async(e,{uniqueID:t="00000000000",mangleNames:i=!1,forceQuineCheats:n,autocomplete:m}={})=>{let _;if(p(/^\w{11}$/.exec(t)),f(e,{Program(e){_=e,e.skip()}}),_.scope.hasGlobal("_START"))for(const e of o("_START",_))e.replaceWith(r.identifier("_ST"));if(_.scope.hasGlobal("_TIMEOUT"))for(const e of o("_TIMEOUT",_))e.replaceWith(r.identifier("_TO"));const y=_.get("body.0");for(const e of[...y.node.params].reverse()){if("Identifier"==e.type){if(!y.scope.getBinding(e.name).referenced){y.node.params.pop();continue}}break}for(const e in _.scope.globals){if("arguments"==e||e.startsWith(`$${t}$`))continue;const i=o(e,_);if(!(5+e.length+i.length>=e.length*i.length)){for(const n of i)n.replaceWith(r.identifier(`_${t}_GLOBAL_${e}_`));y.node.body.body.unshift(r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_GLOBAL_${e}_`),r.identifier(e))]))}}const $=o(`$${t}$GLOBAL$`,_);if($.length>3){for(const e of $)e.replaceWith(r.identifier(`_${t}_G_`));y.node.body.body.unshift(r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_G_`),r.identifier(`$${t}$GLOBAL$`))]))}const g=[];let E,b,v=!1;if(1!=n){const o=r.cloneNode(e);if(f(o,{MemberExpression({node:e}){e.computed||(p("Identifier"==e.property.type),"prototype"==e.property.name?(e.computed=!0,e.property=r.identifier(`_${t}_PROTOTYPE_PROPERTY_`)):"__proto__"==e.property.name?(e.computed=!0,e.property=r.identifier(`_${t}_PROTO_PROPERTY_`)):s(e.property.name)&&(e.computed=!0,e.property=r.stringLiteral(l(t,e.property.name))))},ObjectProperty({node:e}){"Identifier"==e.key.type&&s(e.key.name)&&(e.key=r.stringLiteral(l(t,e.key.name)),e.shorthand=!1)},StringLiteral({node:e}){e.value=l(t,e.value)},TemplateLiteral({node:e}){for(const r of e.quasis)r.value.cooked?(r.value.cooked=l(t,r.value.cooked),r.value.raw=r.value.cooked.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"$\\{")):r.value.raw=l(t,r.value.raw)},RegExpLiteral(e){e.node.pattern=l(t,e.node.pattern),delete e.node.extra}}),E=(await a.minify(d(o).code,{ecma:2015,compress:{passes:1/0,unsafe:!0,unsafe_arrows:!0,unsafe_comps:!0,unsafe_symbols:!0,unsafe_methods:!0,unsafe_proto:!0,unsafe_regexp:!0,unsafe_undefined:!0,sequences:!1},format:{semicolons:!1},keep_classnames:!i,keep_fnames:!i})).code.replace(new RegExp(`_${t}_PROTOTYPE_PROPERTY_`,"g"),'"prototype"').replace(new RegExp(`_${t}_PROTO_PROPERTY_`,"g"),'"__proto__"'),m&&(E=u(E,`//${m}\n`,getFunctionBodyStart(E)+1)),0==n)return E}let h,k=!1;{const i=[];f(e,{FunctionDeclaration(e){e.traverse({Function(e){"CallExpression"!=e.parent.type&&"callee"!=e.parentKey&&e.skip()},Loop(e){e.skip()},ObjectExpression(e){const i={};parseObjectExpression(e.node,i)&&e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${g.push(i)-1}_`))},ArrayExpression(e){const i=[];parseArrayExpression(e.node,i)&&e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${g.push(i)-1}_`))}}),e.traverse({TemplateLiteral(e){if("TaggedTemplateExpression"==e.parent.type)return;const t=e.node;let i=r.stringLiteral(t.quasis[0].value.cooked);for(let e=0;e<t.expressions.length;e++){const n=t.expressions[e],a=t.quasis[e+1];i=r.binaryExpression("+",i,n),a.value.cooked&&(i=r.binaryExpression("+",i,r.stringLiteral(a.value.cooked)))}e.replaceWith(i)},MemberExpression({node:e}){e.computed||(p("Identifier"==e.property.type),e.property.name.length<3||(e.computed=!0,e.property=r.stringLiteral(e.property.name)))},UnaryExpression(e){if("void"==e.node.operator)"NumericLiteral"!=e.node.argument.type||e.node.argument.value||(e.replaceWith(r.identifier(`_${t}_UNDEFINED_`)),v=!0);else if("-"==e.node.operator&&"NumericLiteral"==e.node.argument.type){const n=-e.node.argument.value;i.push((async()=>{if((await minifyNumber(n)).length<=3)return;"key"==e.parentKey&&"ObjectProperty"==e.parent.type&&(e.parent.computed=!0);let i=g.indexOf(n);-1==i&&(i+=g.push(n)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))})()),e.skip()}},NullLiteral(e){let i=g.indexOf(null);-1==i&&(i+=g.push(null)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))},NumericLiteral(e){i.push((async()=>{if((await minifyNumber(e.node.value)).length<=3)return;"key"==e.parentKey&&"ObjectProperty"==e.parent.type&&(e.parent.computed=!0);let i=g.indexOf(e.node.value);-1==i&&(i+=g.push(e.node.value)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))})())},StringLiteral(e){if(e.node.value=l(t,e.node.value),JSON.stringify(e.node.value).includes("\\u00")||e.toString().length<4)return;"key"==e.parentKey&&"ObjectProperty"==e.parent.type&&(e.parent.computed=!0);let i=g.indexOf(e.node.value);-1==i&&(i+=g.push(e.node.value)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))},ObjectProperty({node:e}){if(e.computed||"Identifier"!=e.key.type||e.key.name.length<4)return;let i=g.indexOf(e.key.name);-1==i&&(i+=g.push(e.key.name)),e.computed=!0,e.key=r.identifier(`_${t}_JSON_VALUE_${i}_`)},RegExpLiteral(e){e.node.pattern=l(t,e.node.pattern),delete e.node.extra}}),e.skip()}}),await Promise.all(i);const n=e.program.body[0];if(p("FunctionDeclaration"==n.type),g.length)if(k=!0,1==g.length)if("string"!=typeof g[0]||g[0].includes("\n")||g[0].includes("\t")){const e=r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_JSON_VALUE_0_`),r.callExpression(r.memberExpression(r.identifier("JSON"),r.identifier("parse")),[r.memberExpression(r.taggedTemplateExpression(r.memberExpression(r.callExpression(r.identifier(`$${t}$SUBSCRIPT$scripts$quine$`),[]),r.identifier("split")),r.templateLiteral([r.templateElement({raw:"\t",cooked:"\t"},!0)],[])),r.identifier(`$${t}$SPLIT_INDEX$`),!0)]))]);v&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),b=JSON.stringify(g[0])}else{const e=r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_JSON_VALUE_0_`),r.memberExpression(r.taggedTemplateExpression(r.memberExpression(r.callExpression(r.identifier(`$${t}$SUBSCRIPT$scripts$quine$`),[]),r.identifier("split")),r.templateLiteral([r.templateElement({raw:"\t",cooked:"\t"},!0)],[])),r.identifier(`$${t}$SPLIT_INDEX$`),!0))]);v&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),b=g[0]}else{const e=r.variableDeclaration("let",[r.variableDeclarator(r.arrayPattern(g.map(((e,i)=>r.identifier(`_${t}_JSON_VALUE_${i}_`)))),r.callExpression(r.memberExpression(r.identifier("JSON"),r.identifier("parse")),[r.memberExpression(r.taggedTemplateExpression(r.memberExpression(r.callExpression(r.identifier(`$${t}$SUBSCRIPT$scripts$quine$`),[]),r.identifier("split")),r.templateLiteral([r.templateElement({raw:"\t",cooked:"\t"},!0)],[])),r.identifier(`$${t}$SPLIT_INDEX$`),!0)]))]);v&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),b=JSON.stringify(g)}else v&&n.body.body.unshift(r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))]));h=d(e).code}return h=(await a.minify(h,{ecma:2015,compress:{passes:1/0,unsafe:!0,unsafe_arrows:!0,unsafe_comps:!0,unsafe_symbols:!0,unsafe_methods:!0,unsafe_proto:!0,unsafe_regexp:!0,unsafe_undefined:!0,sequences:!1},format:{semicolons:!1},keep_classnames:!i,keep_fnames:!i})).code||"",null!=b&&(h=u(h,`${m?`//${m}\n`:""}\n//\t${b}\t\n`,getFunctionBodyStart(h)+1),h=h.replace(`$${t}$SPLIT_INDEX$`,await minifyNumber(h.split("\t").findIndex((e=>e==b))))),1==n?h:(p(E),c(E)<=c(h)+Number(k)?E:h)},parseObjectExpression=(e,t)=>{if(!e.properties.length)return!1;for(const r of e.properties){if("ObjectProperty"!=r.type||r.computed)return!1;if(p("Identifier"==r.key.type||"NumericLiteral"==r.key.type||"StringLiteral"==r.key.type),"ArrayExpression"==r.value.type){const e=[];if(!parseArrayExpression(r.value,e))return!1;t["Identifier"==r.key.type?r.key.name:r.key.value]=e}else if("ObjectExpression"==r.value.type){const e={};if(!parseObjectExpression(r.value,e))return!1;t["Identifier"==r.key.type?r.key.name:r.key.value]=e}else if("NullLiteral"==r.value.type)t["Identifier"==r.key.type?r.key.name:r.key.value]=null;else if("BooleanLiteral"==r.value.type||"NumericLiteral"==r.value.type||"StringLiteral"==r.value.type)t["Identifier"==r.key.type?r.key.name:r.key.value]=r.value.value;else{if("TemplateLiteral"!=r.value.type||r.value.expressions.length)return!1;t["Identifier"==r.key.type?r.key.name:r.key.value]=r.value.quasis[0].value.cooked}}return!0},parseArrayExpression=(e,t)=>{if(!e.elements.length)return!1;for(const r of e.elements){if(!r)return!1;if("ArrayExpression"==r.type){const e=[];if(!parseArrayExpression(r,e))return!1;e.push(e)}else if("ObjectExpression"==r.type){const e={};if(!parseObjectExpression(r,e))return!1;t.push(e)}else if("NullLiteral"==r.type)t.push(null);else if("BooleanLiteral"==r.type||"NumericLiteral"==r.type||"StringLiteral"==r.type)t.push(r.value);else{if("TemplateLiteral"!=r.type||r.expressions.length)return!1;t.push(r.quasis[0].value.cooked)}}return!0},minifyNumber=async e=>/\$\((?<number>.+)\)/.exec((await a.minify(`$(${e})`,{ecma:2015})).code).groups.number,getFunctionBodyStart=e=>{const t=i(e,{ecmaVersion:2015});t.getToken(),t.getToken(),t.getToken();let r=1;for(;r;){const e=t.getToken();e.type==n.parenL?r++:e.type==n.parenR&&r--}return t.getToken().start};export{minify as default,minify};
|
@@ -1,2 +1,2 @@
|
|
1
|
-
export declare
|
1
|
+
export declare const postprocess: (code: string, seclevel: number, uniqueID: string) => string;
|
2
2
|
export default postprocess;
|
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
const postprocess=($,e,p)=>$.replace(/^function\s*\w+\(/,"function(").replace(new RegExp(`\\$${p}\\$\\\\(?:\\\\)?\\$SC_DOLLAR\\$`,"g"),"S\\C$").replace(new RegExp(`\\$${p}\\$\\\\(?:\\\\)?\\$DB_DOLLAR\\$`,"g"),"D\\B$").replace(new RegExp(`\\$${p}\\$\\\\(?:\\\\)?\\$D\\$`,"g"),"_\\_D_S").replace(new RegExp(`\\$${p}\\$\\\\(?:\\\\)?\\$FMCL\\$`,"g"),"_\\_FMCL_").replace(new RegExp(`\\$${p}\\$\\\\(?:\\\\)?\\$G\\$`,"g"),"_\\_G_").replace(new RegExp(`\\$${p}\\$SUBSCRIPT\\$(\\w+)\\$(\\w+)\\$`,"g"),`#${"nlmhf"[e]}s.$1.$2`).replace(new RegExp(`\\$${p}\\$DEBUG\\$`,"g"),"#D").replace(new RegExp(`\\$${p}\\$FMCL\\$`,"g"),"#FMCL").replace(new RegExp(`\\$${p}\\$GLOBAL\\$`,"g"),"#G").replace(new RegExp(`\\$${p}\\$DB\\$(\\w+)\\$`,"g"),"#db.$1").replace(new RegExp(`\\$${p}\\$SLASH_SLASH\\$`,"g"),"/\\/").replace(new RegExp(`\\$${p}\\$NOT_A_SUBSCRIPT\\$(#[\\w\\.]+)\\(\\$`,"g"),"$1\\(").replace(new RegExp(`\\$${p}\\$NOT_A_DB_CALL\\$(\\w+)\\$`,"g"),"#db.$1\\(").replace(new RegExp(`\\$${p}\\$NOT_A_DEBUG_CALL\\$`,"g"),"#D\\(").replace(new RegExp(`\\$${p}\\$NOT_FMCL\\$`,"g"),"#\\FMCL").replace(new RegExp(`\\$${p}\\$NOT_G\\$`,"g"),"#\\G");export{postprocess as default,postprocess};
|
@@ -6,7 +6,7 @@ export declare type PreprocessOptions = {
|
|
6
6
|
* @param code source code for preprocessing
|
7
7
|
* @param options {@link PreprocessOptions details}
|
8
8
|
*/
|
9
|
-
export declare
|
9
|
+
export declare const preprocess: (code: string, { uniqueID }?: Partial<PreprocessOptions>) => Promise<{
|
10
10
|
code: string;
|
11
11
|
}>;
|
12
12
|
export default preprocess;
|
@@ -1 +1 @@
|
|
1
|
-
import e from"@babel/generator";import{parse as o}from"@babel/parser";import r from"@babel/traverse";import i from"@babel/types";import{resolve as t}from"import-meta-resolve";import{a as s}from"../assert-
|
1
|
+
import e from"@babel/generator";import{parse as o}from"@babel/parser";import r from"@babel/traverse";import i from"@babel/types";import{resolve as t}from"import-meta-resolve";import{a as s}from"../assert-22a7ef8a.js";import{s as p}from"../spliceString-0e6b5d6d.js";const{default:l}=r,{default:a}=e,preprocess=async(e,{uniqueID:r="00000000000"}={})=>{s(/^\w{11}$/.test(r));const n=e;let c,d,f;do{c=e.length,e=e.replace(/^\s+/,"").replace(/^\/\/.*/,"").replace(/^\/\*[\s\S]*?\*\//,"")}while(e.length!=c);for(e=e.replace(/^function\s*\(/,"export default function (");;){let i;try{d=o(e,{plugins:["typescript",["decorators",{decoratorsBeforeExport:!0}],"doExpressions","functionBind","functionSent","partialApplication",["pipelineOperator",{proposal:"hack",topicToken:"%"}],"throwExpressions",["recordAndTuple",{syntaxType:"hash"}],"classProperties","classPrivateProperties","classPrivateMethods","logicalAssignment","numericSeparator","nullishCoalescingOperator","optionalChaining","optionalCatchBinding","objectRestSpread"],sourceType:"module"});break}catch(e){s(e instanceof SyntaxError),i=e}var m;if("BABEL_PARSER_SYNTAX_ERROR"!=i.code||"PrivateInExpectedIn"!=i.reasonCode)throw console.log(null===(m=/.+/.exec(e.slice(i.pos)))||void 0===m?void 0:m[0]),i;const t=e.slice(i.pos);let l;if(l=/^#[0-4fhmln]s\.scripts\.quine\(\)/.exec(t))e=p(e,JSON.stringify(n),i.pos,l[0].length);else if(l=/^#[0-4fhmln]?s\./.exec(t))e=p(e,"$",i.pos,1);else if(l=/^#D[^\w$]/.exec(t))e=p(e,"$",i.pos,1);else if(l=/^#FMCL/.exec(t))e=p(e,`$${r}$FMCL$`,i.pos,l[0].length);else if(l=/^#G/.exec(t))e=p(e,`$${r}$GLOBAL$`,i.pos,l[0].length);else{if(!(l=/^#db\./.exec(t)))throw i;e=p(e,"$",i.pos,1)}}l(d,{Program(e){f=e,e.skip()}});const u=f.scope.hasGlobal("Record"),h=f.scope.hasGlobal("Tuple");return(u||h)&&d.program.body.unshift(i.importDeclaration(u?h?[i.importSpecifier(i.identifier("Record"),i.identifier("Record")),i.importSpecifier(i.identifier("Tuple"),i.identifier("Tuple"))]:[i.importSpecifier(i.identifier("Record"),i.identifier("Record"))]:[i.importSpecifier(i.identifier("Tuple"),i.identifier("Tuple"))],i.stringLiteral("@bloomberg/record-tuple-polyfill"))),f.scope.hasGlobal("Proxy")&&d.program.body.unshift(i.importDeclaration([i.importDefaultSpecifier(i.identifier("Proxy"))],i.stringLiteral((await t("proxy-polyfill/src/proxy.js",import.meta.url)).slice(7)))),1==f.node.body.length&&"FunctionDeclaration"==f.node.body[0].type?{code:`export default ${a(d).code}`}:{code:a(d).code}};export{preprocess as default,preprocess};
|
@@ -1,5 +1,5 @@
|
|
1
1
|
import { NodePath } from "@babel/traverse";
|
2
2
|
import t, { Program } from "@babel/types";
|
3
|
-
export declare
|
4
|
-
export declare
|
5
|
-
export declare
|
3
|
+
export declare const getReferencePathsToGlobal: (name: string, program: NodePath<Program>) => NodePath<t.Identifier>[];
|
4
|
+
export declare const includesIllegalString: (toCheck: string) => boolean;
|
5
|
+
export declare const replaceUnsafeStrings: (uniqueID: string, toReplace: string) => string;
|
package/processScript/shared.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import
|
1
|
+
import $ from"@babel/types";import{e}from"../assert-22a7ef8a.js";const getReferencePathsToGlobal=(_,r)=>{const[a]=r.unshiftContainer("body",$.variableDeclaration("let",[$.variableDeclarator($.identifier(_))]));r.scope.crawl();const c=e(r.scope.getBinding(_));return a.remove(),c.referencePaths},includesIllegalString=$=>$.includes("SC$")||$.includes("DB$")||$.includes("__D_S")||$.includes("__FMCL_")||$.includes("__G_"),replaceUnsafeStrings=($,e)=>e.replace(/SC\$/g,`$${$}$\\$SC_DOLLAR$`).replace(/DB\$/g,`$${$}$\\$DB_DOLLAR$`).replace(/__D_S/g,`$${$}$\\$D$`).replace(/__FMCL_/g,`$${$}$\\$FMCL$`).replace(/__G_/g,`$${$}$\\$G$`).replace(/\/\//g,`$${$}$SLASH_SLASH$`).replace(/#[0-4fhmln]?s(?:\.[_a-z][\d_a-z]{0,24}){2}\(/g,`$${$}$NOT_A_SUBSCRIPT$$$&$`).replace(/#db\.(?<methodName>[irfu]|u1|us|ObjectId)\(/g,`$${$}$NOT_A_DB_CALL$$$1$`).replace(/#D\(/g,`$${$}$NOT_A_DEBUG_CALL$`).replace(/#FMCL/g,`$${$}$NOT_FMCL$`).replace(/#G/g,`$${$}$NOT_G$`);export{getReferencePathsToGlobal,includesIllegalString,replaceUnsafeStrings};
|
@@ -17,7 +17,7 @@ export declare type TransformOptions = {
|
|
17
17
|
* @param sourceCode the original untouched source code
|
18
18
|
* @param options {@link TransformOptions details}
|
19
19
|
*/
|
20
|
-
export declare
|
20
|
+
export declare const transform: (file: File, sourceCode: string, { uniqueID, scriptUser, scriptName, seclevel }?: Partial<TransformOptions>) => {
|
21
21
|
file: t.File;
|
22
22
|
seclevel: number;
|
23
23
|
};
|
@@ -1 +1 @@
|
|
1
|
-
import e from"@babel/traverse";import t from"@babel/types";import{v as i}from"../constants-9bb78688.js";import{getReferencePathsToGlobal as r}from"./shared.js";import{a as n}from"../assert-1556d989.js";function clearObject(e,t){for(const t of Object.getOwnPropertyNames(e))delete e[t];for(const t of Object.getOwnPropertySymbols(e))delete e[t];void 0!==t&&Object.setPrototypeOf(e,t)}const{default:o}=e,a=["Map","Set","Date","JSON","Math","Array","Error","isNaN","Number","Object","RegExp","String","Symbol","BigInt"];function transform(e,s,{uniqueID:p="00000000000",scriptUser:c="UNKNOWN",scriptName:l="UNKNOWN",seclevel:d=4}={}){const f=`_${p}_SCRIPT_`,b=new Map,y=new Map;let m;if(o(e,{Program(e){m=e,e.skip()}}),m.scope.hasGlobal("_SOURCE"))for(const e of r("_SOURCE",m))e.replaceWith(t.stringLiteral(s));if(m.scope.hasGlobal("_BUILD_DATE"))for(const e of r("_BUILD_DATE",m))e.replaceWith(t.numericLiteral(Date.now()));if(m.scope.hasGlobal("_SCRIPT_USER"))for(const e of r("_SCRIPT_USER",m))1==c?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_USER$`)):e.replaceWith(t.stringLiteral(c));if(m.scope.hasGlobal("_SCRIPT_NAME"))for(const e of r("_SCRIPT_NAME",m))1==l?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(l));if(m.scope.hasGlobal("_FULL_SCRIPT_NAME"))for(const e of r("_FULL_SCRIPT_NAME",m))1==c||1==l?e.replaceWith(t.stringLiteral(`$${p}$FULL_SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(`${c}.${l}`));let $=!1;if(m.scope.hasGlobal("Function")){const e=r("Function",m);if(1==e.length){const t=e[0];n("MemberExpression"==t.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("Identifier"==t.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("prototype"==t.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t.parentPath.replaceWith(createGetFunctionPrototypeNode())}else{for(const i of e)n("MemberExpression"==i.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("Identifier"==i.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("prototype"==i.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),$=!0,i.parentPath.replaceWith(t.identifier(`_${p}_FUNCTION_DOT_PROTOTYPE_`));$=!0}}let h=4;for(const e of["$fs","$4s","$s"])m.scope.hasGlobal(e)&&processFakeSubscriptObject(e);for(const e of["$hs","$3s"])m.scope.hasGlobal(e)&&(h=3,processFakeSubscriptObject(e));for(const e of["$ms","$2s"])m.scope.hasGlobal(e)&&(h=2,processFakeSubscriptObject(e));for(const e of["$ls","$1s"])m.scope.hasGlobal(e)&&(h=1,processFakeSubscriptObject(e));for(const e of["$ns","$0s"])m.scope.hasGlobal(e)&&(h=0,processFakeSubscriptObject(e));if(d=Math.min(d,h),m.scope.hasGlobal("$db"))for(const e of r("$db",m)){var E;n("MemberExpression"==e.parentPath.node.type),n("Identifier"==e.parentPath.node.property.type);const r=e.parentPath.node.property.name;n(i.includes(r),`invalid db method "${r}", valid db methods are "${i.join('", "')}"`),"CallExpression"==(null===(E=e.parentPath.parentPath)||void 0===E?void 0:E.type)?e.parentPath.replaceWith(t.identifier(`$${p}$DB$${r}$`)):"ObjectId"==r?e.parentPath.replaceWith(t.arrowFunctionExpression([],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[]))):"i"==r||"r"==r?e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a")],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[t.identifier("a")]))):e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a"),t.identifier("b")],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[t.identifier("a"),t.identifier("b")])))}if(m.scope.hasGlobal("$D"))for(const e of r("$D",m))"CallExpression"==e.parentPath.type?e.replaceWith(t.identifier(`$${p}$DEBUG$`)):e.replaceWith(t.arrowFunctionExpression([t.identifier("a")],t.callExpression(t.identifier(`$${p}$DEBUG$`),[t.identifier("a")])));if(m.scope.hasGlobal("$FMCL"))for(const e of r("$FMCL",m))e.replaceWith(t.identifier(`$${p}$FMCL$`));if(m.scope.hasGlobal("$G"))for(const e of r("$G",m))e.replaceWith(t.identifier(`$${p}$GLOBAL$`));if(m.scope.hasGlobal("_SECLEVEL"))for(const e of r("_SECLEVEL",m))e.replaceWith(t.numericLiteral(d));let _=!1,u=!1;if(m.scope.hasGlobal("Object"))for(const e of r("Object",m))"MemberExpression"!=e.parent.type||e.parent.computed||(n("Identifier"==e.parent.property.type),"getPrototypeOf"==e.parent.property.name?(e.parentPath.replaceWith(t.identifier(`_${p}_GET_PROTOTYPE_OF_`)),_=!0):"setPrototypeOf"==e.parent.property.name&&(e.parentPath.replaceWith(t.identifier(`_${p}_SET_PROTOTYPE_OF_`)),u=!0));const P=m.node.body[m.node.body.length-1];let O;if(n(P,"program is empty"),"ExportNamedDeclaration"==P.type){m.node.body.pop();for(const e of P.specifiers){n("ExportSpecifier"==e.type,`${e.type} is currently unsupported`);const t="Identifier"==e.exported.type?e.exported.name:e.exported.value;"default"==t?O=e.local.name:b.set(e.local.name,t)}}const x=t.blockStatement([]);let S;for(const e of m.node.body)if("VariableDeclaration"==e.type)for(const i of e.declarations)if("Identifier"!=i.id.type||i.id.name!=O||!i.init||"FunctionExpression"!=i.init.type&&"ArrowFunctionExpression"!=i.init.type||i.init.async||i.init.generator){for(const r in t.getBindingIdentifiers(i.id))r==O&&(S=t.functionDeclaration(t.identifier(f),[t.identifier("context"),t.identifier("args")],t.blockStatement([t.returnStatement(t.callExpression(t.identifier(O),[]))]))),"const"!=e.kind&&b.has(r)&&(y.set(r,b.get(r)),b.delete(r)),x.body.push(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(r))]));i.init&&x.body.push(t.expressionStatement(t.assignmentExpression("=",i.id,i.init)))}else S=t.functionDeclaration(t.identifier(f),i.init.params,"BlockStatement"==i.init.body.type?i.init.body:t.blockStatement([t.returnStatement(i.init.body)]));else"FunctionDeclaration"==e.type?e.id.name==O?S=e:x.body.push(t.variableDeclaration("let",[t.variableDeclarator(e.id,t.functionExpression(void 0,e.params,e.body,e.generator,e.async))])):x.body.push(e);if(S||(S=t.functionDeclaration(t.identifier(f),[t.identifier("context"),t.identifier("args")],t.blockStatement([]))),m.node.body=[S],x.body.length){(b.size||y.size)&&S.body.body.push(t.returnStatement(t.objectExpression([...[...b].map((([e,i])=>t.objectProperty(t.identifier(i),t.identifier(e)))),...[...y].map((([e,i])=>t.objectMethod("get",t.identifier(i),[],t.blockStatement([t.returnStatement(t.identifier(e))]))))]))),m.scope.crawl();const e=new Set;let i=0;for(const[r,o]of[...x.body.entries()].reverse())if("VariableDeclaration"==o.type){n(1==o.declarations.length);const a=o.declarations[0];if(n("Identifier"==a.id.type,`declarator.id.type was "${a.id.type}"`),m.scope.crawl(),m.scope.hasGlobal(a.id.name)){x.body.splice(r,1);const[s]=m.unshiftContainer("body",x),[c]=m.unshiftContainer("body",o);if(m.scope.crawl(),!a.init||"FunctionExpression"!=a.init.type&&"ArrowFunctionExpression"!=a.init.type||Object.keys(m.scope.globals).some((t=>e.has(t)))){const e=m.scope.getBinding(a.id.name);n(e);for(const i of e.referencePaths)n("Identifier"==i.node.type),i.replaceWith(t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(i.node.name)));for(const i of e.constantViolations)if("AssignmentExpression"==i.node.type)for(const[e,r]of Object.entries(t.getBindingIdentifiers(i.node)))e==a.id.name&&(clearObject(r),Object.assign(r,t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(e))));s.remove(),c.remove(),a.init&&x.body.splice(r,0,t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(a.id.name)),a.init)))}else s.remove(),c.remove(),S.body.body.unshift(o),i++}else e.add(a.id.name)}else if("ClassDeclaration"==o.type&&(m.scope.crawl(),m.scope.hasGlobal(o.id.name))){x.body.splice(r,1);const[e]=m.unshiftContainer("body",x),[i]=m.unshiftContainer("body",o);m.scope.crawl();const a=m.scope.getBinding(o.id.name);n(a);for(const e of a.referencePaths)n("Identifier"==e.node.type),e.replaceWith(t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(e.node.name)));e.remove(),i.remove(),x.body.splice(r,0,t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(o.id.name)),t.classExpression(void 0,o.superClass,o.body,o.decorators))))}if(m.scope.hasGlobal("_EXPORTS"))for(const e of r("_EXPORTS",m))e.replaceWith(t.arrayExpression([...b.keys(),...y.keys()].map((e=>t.stringLiteral(e)))));x.body.length&&S.body.body.splice(i,0,t.ifStatement(t.unaryExpression("!",t.identifier(`$${p}$FMCL$`)),x))}return $&&S.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_FUNCTION_DOT_PROTOTYPE_`),createGetFunctionPrototypeNode())])),u&&S.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_SET_PROTOTYPE_OF_`),t.callExpression(t.memberExpression(t.memberExpression(t.identifier("Object"),t.identifier("call")),t.identifier("bind")),[t.identifier(`_${p}_DUNDER_PROTO_SETTER_`)]))])),_&&S.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_GET_PROTOTYPE_OF_`),t.callExpression(t.memberExpression(t.memberExpression(t.identifier("Object"),t.identifier("call")),t.identifier("bind")),[t.identifier(`_${p}_DUNDER_PROTO_GETTER_`)]))])),(_||u)&&S.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.objectPattern(_?u?[t.objectProperty(t.identifier("get"),t.identifier(`_${p}_DUNDER_PROTO_GETTER_`)),t.objectProperty(t.identifier("set"),t.identifier(`_${p}_DUNDER_PROTO_SETTER_`))]:[t.objectProperty(t.identifier("get"),t.identifier(`_${p}_DUNDER_PROTO_GETTER_`))]:[t.objectProperty(t.identifier("set"),t.identifier(`_${p}_DUNDER_PROTO_SETTER_`))]),t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getOwnPropertyDescriptor")),[t.memberExpression(t.identifier("Object"),t.identifier("prototype")),t.stringLiteral("__proto__")]))])),o(e,{BlockStatement({node:e}){for(const[i,r]of e.body.entries())"FunctionDeclaration"!=r.type||r.generator||(e.body.splice(i,1),e.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(r.id,t.arrowFunctionExpression(r.params,r.body,r.async))])))},ClassBody({node:e,scope:i,parent:r}){n(t.isClass(r));let a=!1;for(const r of e.body){if("ClassMethod"!=r.type)continue;let e=!1;if(o(r.body,{ThisExpression(i){e=!0,a=!0,i.replaceWith(t.identifier(`_${p}_THIS_`))},Function(e){e.skip()}},i),e)if("constructor"!=r.kind)r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),t.callExpression(t.memberExpression(t.super(),t.identifier("valueOf")),[]))]));else{const e=[];if(o(r.body,{CallExpression(t){"Super"==t.node.callee.type&&e.push(t)}},i),e.length)if(1==e.length&&"ExpressionStatement"==e[0].parent.type&&e[0].parentPath.parentPath.parent==r)e[0].parentPath.replaceWith(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),e[0].node)]));else{for(const i of e)i.replaceWith(t.assignmentExpression("=",t.identifier(`_${p}_THIS_`),i.node));r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`))]))}else r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),t.callExpression(t.super(),[]))]))}}!r.superClass&&a&&(r.superClass=t.identifier("Object"))},VariableDeclaration({node:e}){"const"==e.kind&&(e.kind="let")},ThisExpression(e){e.replaceWith(t.identifier("undefined"))},BigIntLiteral(e){const i=Number(e.node.value);BigInt(i)==BigInt(e.node.value)?e.replaceWith(t.callExpression(t.identifier("BigInt"),[t.numericLiteral(i)])):e.replaceWith(t.callExpression(t.identifier("BigInt"),[t.stringLiteral(e.node.value)]))}}),{file:e,seclevel:d};function processFakeSubscriptObject(e){for(const a of r(e,m)){var i,o;n("MemberExpression"==a.parent.type),n("Identifier"==a.parent.property.type),n("MemberExpression"==(null===(i=a.parentPath.parentPath)||void 0===i?void 0:i.node.type)),n("Identifier"==a.parentPath.parentPath.node.property.type),n(/^[_a-z][\d_a-z]{0,24}$/.test(a.parent.property.name),`invalid user "${a.parent.property.name}" in subscript`),n(/^[_a-z][\d_a-z]{0,24}$/.test(a.parentPath.parentPath.node.property.name),`invalid script name "${a.parentPath.parentPath.node.property.name}" in subscript`),"CallExpression"==(null===(o=a.parentPath.parentPath.parentPath)||void 0===o?void 0:o.type)?a.parentPath.parentPath.replaceWith(t.identifier(`$${p}$SUBSCRIPT$${a.parent.property.name}$${a.parentPath.parentPath.node.property.name}$`)):a.parentPath.parentPath.replaceWith(t.arrowFunctionExpression([t.restElement(t.identifier("args"))],t.callExpression(t.identifier(`$${p}$SUBSCRIPT$${a.parent.property.name}$${a.parentPath.parentPath.node.property.name}$`),[t.spreadElement(t.identifier("args"))])))}}function createGetFunctionPrototypeNode(){for(const e of a)if(!m.scope.hasOwnBinding(e))return t.memberExpression(t.memberExpression(t.identifier(e),t.identifier("constructor")),t.identifier("prototype"));return t.memberExpression(t.memberExpression(t.arrowFunctionExpression([t.identifier("_")],t.identifier("_")),t.identifier("constructor")),t.identifier("prototype"))}}export{transform as default,transform};
|
1
|
+
import e from"@babel/traverse";import t from"@babel/types";import{v as i}from"../constants-9bb78688.js";import{getReferencePathsToGlobal as r}from"./shared.js";import{a as n}from"../assert-22a7ef8a.js";function clearObject(e,t){for(const t of Object.getOwnPropertyNames(e))delete e[t];for(const t of Object.getOwnPropertySymbols(e))delete e[t];void 0!==t&&Object.setPrototypeOf(e,t)}const{default:o}=e,a=["Map","Set","Date","JSON","Math","Array","Error","isNaN","Number","Object","RegExp","String","Symbol","BigInt"],transform=(e,s,{uniqueID:p="00000000000",scriptUser:l="UNKNOWN",scriptName:c="UNKNOWN",seclevel:d=4}={})=>{const f=`_${p}_SCRIPT_`,b=new Map,y=new Map;let $;if(o(e,{Program(e){$=e,e.skip()}}),$.scope.hasGlobal("_SOURCE"))for(const e of r("_SOURCE",$))e.replaceWith(t.stringLiteral(s));if($.scope.hasGlobal("_BUILD_DATE"))for(const e of r("_BUILD_DATE",$))e.replaceWith(t.numericLiteral(Date.now()));if($.scope.hasGlobal("_SCRIPT_USER"))for(const e of r("_SCRIPT_USER",$))1==l?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_USER$`)):e.replaceWith(t.stringLiteral(l));if($.scope.hasGlobal("_SCRIPT_NAME"))for(const e of r("_SCRIPT_NAME",$))1==c?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(c));if($.scope.hasGlobal("_FULL_SCRIPT_NAME"))for(const e of r("_FULL_SCRIPT_NAME",$))1==l||1==c?e.replaceWith(t.stringLiteral(`$${p}$FULL_SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(`${l}.${c}`));let m=!1;const createGetFunctionPrototypeNode=()=>{for(const e of a)if(!$.scope.hasOwnBinding(e))return t.memberExpression(t.memberExpression(t.identifier(e),t.identifier("constructor")),t.identifier("prototype"));return t.memberExpression(t.memberExpression(t.arrowFunctionExpression([t.identifier("_")],t.identifier("_")),t.identifier("constructor")),t.identifier("prototype"))};if($.scope.hasGlobal("Function")){const e=r("Function",$);if(1==e.length){const t=e[0];n("MemberExpression"==t.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("Identifier"==t.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("prototype"==t.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),t.parentPath.replaceWith(createGetFunctionPrototypeNode())}else{for(const i of e)n("MemberExpression"==i.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("Identifier"==i.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),n("prototype"==i.parent.property.name,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),m=!0,i.parentPath.replaceWith(t.identifier(`_${p}_FUNCTION_DOT_PROTOTYPE_`));m=!0}}let h=4;const processFakeSubscriptObject=e=>{for(const a of r(e,$)){var i,o;n("MemberExpression"==a.parent.type),n("Identifier"==a.parent.property.type),n("MemberExpression"==(null===(i=a.parentPath.parentPath)||void 0===i?void 0:i.node.type)),n("Identifier"==a.parentPath.parentPath.node.property.type),n(/^[_a-z][\d_a-z]{0,24}$/.test(a.parent.property.name),`invalid user "${a.parent.property.name}" in subscript`),n(/^[_a-z][\d_a-z]{0,24}$/.test(a.parentPath.parentPath.node.property.name),`invalid script name "${a.parentPath.parentPath.node.property.name}" in subscript`),"CallExpression"==(null===(o=a.parentPath.parentPath.parentPath)||void 0===o?void 0:o.type)?a.parentPath.parentPath.replaceWith(t.identifier(`$${p}$SUBSCRIPT$${a.parent.property.name}$${a.parentPath.parentPath.node.property.name}$`)):a.parentPath.parentPath.replaceWith(t.arrowFunctionExpression([t.restElement(t.identifier("args"))],t.callExpression(t.identifier(`$${p}$SUBSCRIPT$${a.parent.property.name}$${a.parentPath.parentPath.node.property.name}$`),[t.spreadElement(t.identifier("args"))])))}};for(const e of["$fs","$4s","$s"])$.scope.hasGlobal(e)&&processFakeSubscriptObject(e);for(const e of["$hs","$3s"])$.scope.hasGlobal(e)&&(h=3,processFakeSubscriptObject(e));for(const e of["$ms","$2s"])$.scope.hasGlobal(e)&&(h=2,processFakeSubscriptObject(e));for(const e of["$ls","$1s"])$.scope.hasGlobal(e)&&(h=1,processFakeSubscriptObject(e));for(const e of["$ns","$0s"])$.scope.hasGlobal(e)&&(h=0,processFakeSubscriptObject(e));if(d=Math.min(d,h),$.scope.hasGlobal("$db"))for(const e of r("$db",$)){var E;n("MemberExpression"==e.parentPath.node.type),n("Identifier"==e.parentPath.node.property.type);const r=e.parentPath.node.property.name;n(i.includes(r),`invalid db method "${r}", valid db methods are "${i.join('", "')}"`),"CallExpression"==(null===(E=e.parentPath.parentPath)||void 0===E?void 0:E.type)?e.parentPath.replaceWith(t.identifier(`$${p}$DB$${r}$`)):"ObjectId"==r?e.parentPath.replaceWith(t.arrowFunctionExpression([],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[]))):"i"==r||"r"==r?e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a")],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[t.identifier("a")]))):e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a"),t.identifier("b")],t.callExpression(t.identifier(`$${p}$DB$${r}$`),[t.identifier("a"),t.identifier("b")])))}if($.scope.hasGlobal("$D"))for(const e of r("$D",$))"CallExpression"==e.parentPath.type?e.replaceWith(t.identifier(`$${p}$DEBUG$`)):e.replaceWith(t.arrowFunctionExpression([t.identifier("a")],t.callExpression(t.identifier(`$${p}$DEBUG$`),[t.identifier("a")])));if($.scope.hasGlobal("$FMCL"))for(const e of r("$FMCL",$))e.replaceWith(t.identifier(`$${p}$FMCL$`));if($.scope.hasGlobal("$G"))for(const e of r("$G",$))e.replaceWith(t.identifier(`$${p}$GLOBAL$`));if($.scope.hasGlobal("_SECLEVEL"))for(const e of r("_SECLEVEL",$))e.replaceWith(t.numericLiteral(d));let _=!1,u=!1;if($.scope.hasGlobal("Object"))for(const e of r("Object",$))"MemberExpression"!=e.parent.type||e.parent.computed||(n("Identifier"==e.parent.property.type),"getPrototypeOf"==e.parent.property.name?(e.parentPath.replaceWith(t.identifier(`_${p}_GET_PROTOTYPE_OF_`)),_=!0):"setPrototypeOf"==e.parent.property.name&&(e.parentPath.replaceWith(t.identifier(`_${p}_SET_PROTOTYPE_OF_`)),u=!0));const P=$.node.body[$.node.body.length-1];let x;if(n(P,"program is empty"),"ExportNamedDeclaration"==P.type){$.node.body.pop();for(const e of P.specifiers){n("ExportSpecifier"==e.type,`${e.type} is currently unsupported`);const t="Identifier"==e.exported.type?e.exported.name:e.exported.value;"default"==t?x=e.local.name:b.set(e.local.name,t)}}const O=t.blockStatement([]);let D;for(const e of $.node.body)if("VariableDeclaration"==e.type)for(const i of e.declarations)if("Identifier"!=i.id.type||i.id.name!=x||!i.init||"FunctionExpression"!=i.init.type&&"ArrowFunctionExpression"!=i.init.type||i.init.async||i.init.generator){for(const r in t.getBindingIdentifiers(i.id))r==x&&(D=t.functionDeclaration(t.identifier(f),[t.identifier("context"),t.identifier("args")],t.blockStatement([t.returnStatement(t.callExpression(t.identifier(x),[]))]))),"const"!=e.kind&&b.has(r)&&(y.set(r,b.get(r)),b.delete(r)),O.body.push(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(r))]));i.init&&O.body.push(t.expressionStatement(t.assignmentExpression("=",i.id,i.init)))}else D=t.functionDeclaration(t.identifier(f),i.init.params,"BlockStatement"==i.init.body.type?i.init.body:t.blockStatement([t.returnStatement(i.init.body)]));else"FunctionDeclaration"==e.type?e.id.name==x?D=e:O.body.push(t.variableDeclaration("let",[t.variableDeclarator(e.id,t.functionExpression(void 0,e.params,e.body,e.generator,e.async))])):O.body.push(e);if(D||(D=t.functionDeclaration(t.identifier(f),[t.identifier("context"),t.identifier("args")],t.blockStatement([]))),$.node.body=[D],O.body.length){(b.size||y.size)&&D.body.body.push(t.returnStatement(t.objectExpression([...[...b].map((([e,i])=>t.objectProperty(t.identifier(i),t.identifier(e)))),...[...y].map((([e,i])=>t.objectMethod("get",t.identifier(i),[],t.blockStatement([t.returnStatement(t.identifier(e))]))))]))),$.scope.crawl();const e=new Set;let i=0;for(const[r,o]of[...O.body.entries()].reverse())if("VariableDeclaration"==o.type){n(1==o.declarations.length);const a=o.declarations[0];if(n("Identifier"==a.id.type,`declarator.id.type was "${a.id.type}"`),$.scope.crawl(),$.scope.hasGlobal(a.id.name)){O.body.splice(r,1);const[s]=$.unshiftContainer("body",O),[l]=$.unshiftContainer("body",o);if($.scope.crawl(),!a.init||"FunctionExpression"!=a.init.type&&"ArrowFunctionExpression"!=a.init.type||Object.keys($.scope.globals).some((t=>e.has(t)))){const e=$.scope.getBinding(a.id.name);n(e);for(const i of e.referencePaths)n("Identifier"==i.node.type),i.replaceWith(t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(i.node.name)));for(const i of e.constantViolations)if("AssignmentExpression"==i.node.type)for(const[e,r]of Object.entries(t.getBindingIdentifiers(i.node)))e==a.id.name&&(clearObject(r),Object.assign(r,t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(e))));s.remove(),l.remove(),a.init&&O.body.splice(r,0,t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(a.id.name)),a.init)))}else s.remove(),l.remove(),D.body.body.unshift(o),i++}else e.add(a.id.name)}else if("ClassDeclaration"==o.type&&($.scope.crawl(),$.scope.hasGlobal(o.id.name))){O.body.splice(r,1);const[e]=$.unshiftContainer("body",O),[i]=$.unshiftContainer("body",o);$.scope.crawl();const a=$.scope.getBinding(o.id.name);n(a);for(const e of a.referencePaths)n("Identifier"==e.node.type),e.replaceWith(t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(e.node.name)));e.remove(),i.remove(),O.body.splice(r,0,t.expressionStatement(t.assignmentExpression("=",t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(o.id.name)),t.classExpression(void 0,o.superClass,o.body,o.decorators))))}if($.scope.hasGlobal("_EXPORTS"))for(const e of r("_EXPORTS",$))e.replaceWith(t.arrayExpression([...b.keys(),...y.keys()].map((e=>t.stringLiteral(e)))));O.body.length&&D.body.body.splice(i,0,t.ifStatement(t.unaryExpression("!",t.identifier(`$${p}$FMCL$`)),O))}return m&&D.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_FUNCTION_DOT_PROTOTYPE_`),createGetFunctionPrototypeNode())])),u&&D.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_SET_PROTOTYPE_OF_`),t.callExpression(t.memberExpression(t.memberExpression(t.identifier("Object"),t.identifier("call")),t.identifier("bind")),[t.identifier(`_${p}_DUNDER_PROTO_SETTER_`)]))])),_&&D.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_GET_PROTOTYPE_OF_`),t.callExpression(t.memberExpression(t.memberExpression(t.identifier("Object"),t.identifier("call")),t.identifier("bind")),[t.identifier(`_${p}_DUNDER_PROTO_GETTER_`)]))])),(_||u)&&D.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.objectPattern(_?u?[t.objectProperty(t.identifier("get"),t.identifier(`_${p}_DUNDER_PROTO_GETTER_`)),t.objectProperty(t.identifier("set"),t.identifier(`_${p}_DUNDER_PROTO_SETTER_`))]:[t.objectProperty(t.identifier("get"),t.identifier(`_${p}_DUNDER_PROTO_GETTER_`))]:[t.objectProperty(t.identifier("set"),t.identifier(`_${p}_DUNDER_PROTO_SETTER_`))]),t.callExpression(t.memberExpression(t.identifier("Object"),t.identifier("getOwnPropertyDescriptor")),[t.memberExpression(t.identifier("Object"),t.identifier("prototype")),t.stringLiteral("__proto__")]))])),o(e,{BlockStatement({node:e}){for(const[i,r]of e.body.entries())"FunctionDeclaration"!=r.type||r.generator||(e.body.splice(i,1),e.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(r.id,t.arrowFunctionExpression(r.params,r.body,r.async))])))},ClassBody({node:e,scope:i,parent:r}){n(t.isClass(r));let a=!1;for(const r of e.body){if("ClassMethod"!=r.type)continue;let e=!1;if(o(r.body,{ThisExpression(i){e=!0,a=!0,i.replaceWith(t.identifier(`_${p}_THIS_`))},Function(e){e.skip()}},i),e)if("constructor"!=r.kind)r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),t.callExpression(t.memberExpression(t.super(),t.identifier("valueOf")),[]))]));else{const e=[];if(o(r.body,{CallExpression(t){"Super"==t.node.callee.type&&e.push(t)}},i),e.length)if(1==e.length&&"ExpressionStatement"==e[0].parent.type&&e[0].parentPath.parentPath.parent==r)e[0].parentPath.replaceWith(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),e[0].node)]));else{for(const i of e)i.replaceWith(t.assignmentExpression("=",t.identifier(`_${p}_THIS_`),i.node));r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`))]))}else r.body.body.unshift(t.variableDeclaration("let",[t.variableDeclarator(t.identifier(`_${p}_THIS_`),t.callExpression(t.super(),[]))]))}}!r.superClass&&a&&(r.superClass=t.identifier("Object"))},VariableDeclaration({node:e}){"const"==e.kind&&(e.kind="let")},ThisExpression(e){e.replaceWith(t.identifier("undefined"))},BigIntLiteral(e){const i=Number(e.node.value);BigInt(i)==BigInt(e.node.value)?e.replaceWith(t.callExpression(t.identifier("BigInt"),[t.numericLiteral(i)])):e.replaceWith(t.callExpression(t.identifier("BigInt"),[t.stringLiteral(e.node.value)]))}}),{file:e,seclevel:d}};export{transform as default,transform};
|
package/pull.d.ts
CHANGED
@@ -5,5 +5,5 @@
|
|
5
5
|
* @param hackmudPath path to hackmud directory
|
6
6
|
* @param script to pull in `user.name` format
|
7
7
|
*/
|
8
|
-
export declare
|
8
|
+
export declare const pull: (sourceFolderPath: string, hackmudPath: string, script: string) => Promise<void>;
|
9
9
|
export default pull;
|
package/pull.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{dirname as t,resolve as r}from"path";import
|
1
|
+
import{dirname as t,resolve as r}from"path";import s from"fs";const{mkdir:i,copyFile:o}=s.promises;const pull=async(s,e,a)=>{const[c,n]=a.split(".");if(!c||!n)throw new Error('`script` argument must be in "user.name" format');await function copyFilePersistent(r,s,e){return o(r,s,e).catch((async a=>{if("ENOENT"!=a.code)throw a;await i(t(s),{recursive:!0}),await o(r,s,e)}))}(r(e,c,"scripts",`${n}.js`),r(s,c,`${n}.js`))};export{pull as default,pull};
|
package/push.d.ts
CHANGED
@@ -33,5 +33,5 @@ export declare type PushOptions = {
|
|
33
33
|
* @param options {@link PushOptions details}
|
34
34
|
* @returns array of info on pushed scripts
|
35
35
|
*/
|
36
|
-
export declare
|
36
|
+
export declare const push: (sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, forceQuineCheats }?: LaxPartial<PushOptions>) => Promise<Info[]>;
|
37
37
|
export default push;
|
package/push.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import e from"fs";import{resolve as i,extname as
|
1
|
+
import{readdir as e,readFile as t}from"fs/promises";import{resolve as i,extname as r,basename as a}from"path";import{s}from"./constants-9bb78688.js";import{processScript as o}from"./processScript/index.js";import{D as p,w as n}from"./writeFilePersistent-ee9c9bfd.js";import{c as l}from"./countHackmudCharacters-a08a265f.js";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-transform-exponentiation-operator";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./processScript/minify.js";import"acorn";import"terser";import"./processScript/shared.js";import"./assert-22a7ef8a.js";import"./spliceString-0e6b5d6d.js";import"./processScript/postprocess.js";import"./processScript/preprocess.js";import"import-meta-resolve";import"./processScript/transform.js";import"fs";const push=async(m,c,{scripts:f=["*.*"],onPush:u=(()=>{}),minify:g=!0,mangleNames:d=!1,forceQuineCheats:b}={})=>{const h=new p((e=>new Set)),w=new Set,$=new Set;let y=!1;for(const e of f){const[t,i]=e.split(".");t&&"*"!=t?i&&"*"!=i?h.get(t).add(i):w.add(t):i&&"*"!=i?$.add(i):y=!0}const S=new p((e=>new Set)),j=[],P=new p((e=>new Set));let N;if($.size||y){const t=await e(i(c),{withFileTypes:!0}),r=new Set([...(N=await e(i(m),{withFileTypes:!0})).filter((e=>e.isDirectory())).map((e=>e.name)),...t.filter((e=>e.isDirectory())).map((e=>e.name)),...t.filter((e=>e.isFile()&&e.name.endsWith(".key"))).map((e=>e.name.slice(0,-4))),...h.keys(),...w]);if(y)for(const e of r)w.add(e);else for(const e of r){const t=h.get(e);for(const e of $)t.add(e)}}return await Promise.all([...w].map((async p=>{await e(i(m,p),{withFileTypes:!0}).then((async e=>{await Promise.all(e.map((async e=>{if(e.name.endsWith(".d.ts"))return;const f=r(e.name);if(e.isFile()&&s.includes(f)){const r=a(e.name,f),s=i(m,p,e.name),{script:h}=await o(await t(s,{encoding:"utf-8"}),{minify:g,scriptUser:p,scriptName:r,filePath:s,mangleNames:d,forceQuineCheats:b}),w={file:`${p}/${e.name}`,users:[p],minLength:l(h),error:void 0};P.get(p).add(r),j.push(w),await n(i(c,p,`scripts/${r}.js`),h),u(w)}})))}),(e=>{if("ENOENT"!=e.code)throw e}))}))),await Promise.all([...h].map((async([e,r])=>{w.has(e)||await Promise.all([...r].map((async r=>{let a,p,f;for(const o of s)try{p=`${r}${o}`,a=await t(f=i(m,e,p),{encoding:"utf-8"});break}catch{}if(a){const{script:t}=await o(a,{minify:g,scriptUser:e,scriptName:r,filePath:f,mangleNames:d,forceQuineCheats:b}),s={file:`${e}/${p}`,users:[e],minLength:l(t),error:void 0};j.push(s),await n(i(c,e,"scripts",`${r}.js`),t),u(s)}else S.get(r).add(e)})))}))),await(w.size?Promise.all((N||await e(i(m),{withFileTypes:!0})).map((async e=>{if(e.name.endsWith(".d.ts"))return;const p=r(e.name);if(!e.isFile()||!s.includes(p))return;const f=a(e.name,p),h=[...w,...S.get(f)].filter((e=>!P.get(e).has(f)));if(!h.length)return;const $=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),y=i(m,e.name),{script:N}=await o(await t(y,{encoding:"utf-8"}),{minify:g,scriptUser:!0,scriptName:f,uniqueID:$,filePath:y,mangleNames:d,forceQuineCheats:b}),C={file:e.name,users:h,minLength:l(N),error:void 0};await Promise.all(h.map((e=>n(i(c,e,`scripts/${f}.js`),N.replace(new RegExp(`\\$${$}\\$SCRIPT_USER\\$`,"g"),e).replace(new RegExp(`\\$${$}\\$FULL_SCRIPT_NAME\\$`,"g"),`${e}.${f}`))))),j.push(C),u(C)}))):Promise.all([...S].map((async([e,r])=>{let a,p,f;for(const r of s)try{p=`${e}${r}`,a=await t(f=i(m,p),{encoding:"utf-8"});break}catch{}if(a){const t=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),{script:s}=await o(a,{minify:g,scriptUser:!0,scriptName:e,uniqueID:t,filePath:f,mangleNames:d,forceQuineCheats:b}),m={file:p,users:[...r],minLength:l(s),error:void 0};await Promise.all([...r].map((r=>n(i(c,r,`scripts/${e}.js`),s.replace(new RegExp(`\\$${t}\\$SCRIPT_USER\\$`,"g"),r).replace(new RegExp(`\\$${t}\\$FULL_SCRIPT_NAME\\$`,"g"),`${r}.${e}`))))),j.push(m),u(m)}})))),j};export{push as default,push};
|
File without changes
|
package/syncMacros.d.ts
CHANGED
package/syncMacros.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import e from"fs";import{extname as
|
1
|
+
import{readdir as e,readFile as t,stat as a,writeFile as s}from"fs/promises";import{extname as o,basename as n,resolve as r}from"path";const syncMacros=async c=>{const m=await e(c,{withFileTypes:!0}),i=new Map,l=[];await Promise.all(m.map((async e=>{if(e.isFile())switch(o(e.name)){case".macros":{const[s,o]=await Promise.all([t(r(c,e.name),{encoding:"utf-8"}).then((e=>e.split("\n"))),a(r(c,e.name)).then((({mtime:e})=>e))]);for(let e=0;e<s.length/2-1;e++){const t=s[2*e],a=i.get(t);(!a||o>a.date)&&i.set(t,{date:o,macro:s[2*e+1]})}}break;case".key":l.push(n(e.name,".key"))}})));let f="",p=0;for(const[e,{macro:t}]of[...i].sort((([e],[t])=>(e>t)-(e<t))))t[0]==t[0].toLowerCase()&&(f+=`${e}\n${t}\n`,p++);for(const e of l)s(r(c,`${e}.macros`),f);return{macrosSynced:p,usersSynced:l.length}};export{syncMacros as default,syncMacros};
|
@@ -0,0 +1 @@
|
|
1
|
+
{"program":{"fileNames":["../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es5.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2016.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.dom.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.dom.iterable.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.webworker.importscripts.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.scripthost.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.core.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.collection.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.generator.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.iterable.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.promise.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.proxy.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.reflect.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.symbol.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2015.symbol.wellknown.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2016.array.include.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.object.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.sharedmemory.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.string.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.intl.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2017.typedarrays.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.asyncgenerator.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.asynciterable.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.intl.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.promise.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2018.regexp.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.array.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.object.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.string.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.symbol.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2020.bigint.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2020.intl.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.esnext.intl.d.ts","../node_modules/.pnpm/typescript@4.7.4/node_modules/typescript/lib/lib.es2019.full.d.ts","../src/generateTypeDeclaration.ts","../src/constants.json","../node_modules/.pnpm/@babel+types@7.18.9/node_modules/@babel/types/lib/index.d.ts","../node_modules/.pnpm/@types+babel__generator@7.6.4/node_modules/@types/babel__generator/index.d.ts","../node_modules/.pnpm/@babel+parser@7.18.9/node_modules/@babel/parser/typings/babel-parser.d.ts","../node_modules/.pnpm/@types+babel__template@7.4.1/node_modules/@types/babel__template/index.d.ts","../node_modules/.pnpm/@types+babel__traverse@7.17.1/node_modules/@types/babel__traverse/index.d.ts","../node_modules/.pnpm/@types+babel__core@7.1.19/node_modules/@types/babel__core/index.d.ts","../node_modules/.pnpm/rollup@2.77.0/node_modules/rollup/dist/rollup.d.ts","../node_modules/.pnpm/@types+estree@0.0.39/node_modules/@types/estree/index.d.ts","../node_modules/.pnpm/@rollup+pluginutils@3.1.0_rollup@2.77.0/node_modules/@rollup/pluginutils/types/index.d.ts","../node_modules/.pnpm/@rollup+plugin-babel@5.3.1_jpkmfzy5naca2yz5hbsitzgfaa/node_modules/@rollup/plugin-babel/types/index.d.ts","../node_modules/.pnpm/@rollup+plugin-commonjs@22.0.1_rollup@2.77.0/node_modules/@rollup/plugin-commonjs/types/index.d.ts","../node_modules/.pnpm/@rollup+plugin-json@4.1.0_rollup@2.77.0/node_modules/@rollup/plugin-json/types/index.d.ts","../node_modules/.pnpm/@rollup+plugin-node-resolve@13.3.0_rollup@2.77.0/node_modules/@rollup/plugin-node-resolve/types/index.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/assert.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/globals.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/async_hooks.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/buffer.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/child_process.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/cluster.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/console.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/constants.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/crypto.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/dgram.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/dns.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/domain.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/events.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/fs.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/fs/promises.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/http.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/http2.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/https.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/inspector.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/module.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/net.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/os.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/path.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/perf_hooks.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/process.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/punycode.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/querystring.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/readline.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/repl.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/stream.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/string_decoder.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/timers.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/tls.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/trace_events.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/tty.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/url.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/util.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/v8.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/vm.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/wasi.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/worker_threads.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/zlib.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/globals.global.d.ts","../node_modules/.pnpm/@types+node@14.18.22/node_modules/@types/node/index.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/assert.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/BitStream.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/bufferToString.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/clamp.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/clearObject.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/combineAsyncGeneratorsParallel.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/copyFilePersistent.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/countHackmudCharacters.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/createErrorClass.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/deeplyEquals.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/DynamicMap.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/findFiles.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/findMatches.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/is.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/isGenerator.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/isRecord.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/iterateXY.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/lerp.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/objectHasOwn.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/positionToLine.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/raceAllPromises.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/shuffle.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/sigmoid.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/spliceString.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/tryCatch.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/wait.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/writeFilePersistent.d.ts","../node_modules/.pnpm/@samual+lib@0.3.4/node_modules/@samual/lib/index.d.ts","../node_modules/.pnpm/@types+prettier@2.6.3/node_modules/@types/prettier/index.d.ts","../node_modules/.pnpm/acorn@8.7.1/node_modules/acorn/dist/acorn.d.ts","../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.14/node_modules/@jridgewell/trace-mapping/dist/types/sourcemap-segment.d.ts","../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.14/node_modules/@jridgewell/trace-mapping/dist/types/types.d.ts","../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.14/node_modules/@jridgewell/trace-mapping/dist/types/any-map.d.ts","../node_modules/.pnpm/@jridgewell+trace-mapping@0.3.14/node_modules/@jridgewell/trace-mapping/dist/types/trace-mapping.d.ts","../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.2/node_modules/@jridgewell/gen-mapping/dist/types/sourcemap-segment.d.ts","../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.2/node_modules/@jridgewell/gen-mapping/dist/types/types.d.ts","../node_modules/.pnpm/@jridgewell+gen-mapping@0.3.2/node_modules/@jridgewell/gen-mapping/dist/types/gen-mapping.d.ts","../node_modules/.pnpm/@jridgewell+source-map@0.3.2/node_modules/@jridgewell/source-map/dist/types/source-map.d.ts","../node_modules/.pnpm/terser@5.14.2/node_modules/terser/tools/terser.d.ts","../src/processScript/shared.ts","../src/processScript/minify.ts","../src/processScript/postprocess.ts","../node_modules/.pnpm/import-meta-resolve@2.0.3/node_modules/import-meta-resolve/lib/errors.d.ts","../node_modules/.pnpm/import-meta-resolve@2.0.3/node_modules/import-meta-resolve/lib/resolve.d.ts","../node_modules/.pnpm/import-meta-resolve@2.0.3/node_modules/import-meta-resolve/index.d.ts","../src/processScript/preprocess.ts","../src/processScript/transform.ts","../src/processScript/index.ts","../src/pull.ts","../src/push.ts","../src/syncMacros.ts","../node_modules/.pnpm/anymatch@3.1.2/node_modules/anymatch/index.d.ts","../node_modules/.pnpm/chokidar@3.5.3/node_modules/chokidar/types/index.d.ts","../src/watch.ts","../src/index.ts","../src/modules.d.ts","../package.json","../node_modules/.pnpm/chalk@5.0.1/node_modules/chalk/source/vendor/supports-color/index.d.ts","../node_modules/.pnpm/chalk@5.0.1/node_modules/chalk/source/index.d.ts","../src/bin/hsm.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/classes/semver.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/parse.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/valid.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/clean.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/inc.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/diff.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/major.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/minor.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/patch.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/prerelease.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/compare.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/rcompare.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/compare-loose.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/compare-build.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/sort.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/rsort.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/gt.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/lt.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/eq.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/neq.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/gte.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/lte.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/cmp.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/coerce.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/classes/comparator.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/classes/range.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/functions/satisfies.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/max-satisfying.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/min-satisfying.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/to-comparators.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/min-version.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/valid.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/outside.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/gtr.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/ltr.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/intersects.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/simplify.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/ranges/subset.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/internals/identifiers.d.ts","../node_modules/.pnpm/@types+semver@7.3.10/node_modules/@types/semver/index.d.ts"],"fileInfos":[{"version":"f5c28122bee592cfaf5c72ed7bcc47f453b79778ffa6e301f45d21a0970719d4","affectsGlobalScope":true},"dc47c4fa66b9b9890cf076304de2a9c5201e94b740cffdf09f87296d877d71f6","7a387c58583dfca701b6c85e0adaf43fb17d590fb16d5b2dc0a2fbd89f35c467","8a12173c586e95f4433e0c6dc446bc88346be73ffe9ca6eec7aa63c8f3dca7f9","5f4e733ced4e129482ae2186aae29fde948ab7182844c3a5a51dd346182c7b06","e6b724280c694a9f588847f754198fb96c43d805f065c3a5b28bbc9594541c84",{"version":"3f149f903dd20dfeb7c80e228b659f0e436532de772469980dbd00702cc05cc1","affectsGlobalScope":true},{"version":"1272277fe7daa738e555eb6cc45ded42cc2d0f76c07294142283145d49e96186","affectsGlobalScope":true},{"version":"7fac8cb5fc820bc2a59ae11ef1c5b38d3832c6d0dfaec5acdb5569137d09a481","affectsGlobalScope":true},{"version":"097a57355ded99c68e6df1b738990448e0bf170e606707df5a7c0481ff2427cd","affectsGlobalScope":true},{"version":"adb996790133eb33b33aadb9c09f15c2c575e71fb57a62de8bf74dbf59ec7dfb","affectsGlobalScope":true},{"version":"43fb1d932e4966a39a41b464a12a81899d9ae5f2c829063f5571b6b87e6d2f9c","affectsGlobalScope":true},{"version":"cdccba9a388c2ee3fd6ad4018c640a471a6c060e96f1232062223063b0a5ac6a","affectsGlobalScope":true},{"version":"c5c05907c02476e4bde6b7e76a79ffcd948aedd14b6a8f56e4674221b0417398","affectsGlobalScope":true},{"version":"0d5f52b3174bee6edb81260ebcd792692c32c81fd55499d69531496f3f2b25e7","affectsGlobalScope":true},{"version":"810627a82ac06fb5166da5ada4159c4ec11978dfbb0805fe804c86406dab8357","affectsGlobalScope":true},{"version":"181f1784c6c10b751631b24ce60c7f78b20665db4550b335be179217bacc0d5f","affectsGlobalScope":true},{"version":"3013574108c36fd3aaca79764002b3717da09725a36a6fc02eac386593110f93","affectsGlobalScope":true},{"version":"75ec0bdd727d887f1b79ed6619412ea72ba3c81d92d0787ccb64bab18d261f14","affectsGlobalScope":true},{"version":"3be5a1453daa63e031d266bf342f3943603873d890ab8b9ada95e22389389006","affectsGlobalScope":true},{"version":"17bb1fc99591b00515502d264fa55dc8370c45c5298f4a5c2083557dccba5a2a","affectsGlobalScope":true},{"version":"7ce9f0bde3307ca1f944119f6365f2d776d281a393b576a18a2f2893a2d75c98","affectsGlobalScope":true},{"version":"6a6b173e739a6a99629a8594bfb294cc7329bfb7b227f12e1f7c11bc163b8577","affectsGlobalScope":true},{"version":"12a310447c5d23c7d0d5ca2af606e3bd08afda69100166730ab92c62999ebb9d","affectsGlobalScope":true},{"version":"b0124885ef82641903d232172577f2ceb5d3e60aed4da1153bab4221e1f6dd4e","affectsGlobalScope":true},{"version":"0eb85d6c590b0d577919a79e0084fa1744c1beba6fd0d4e951432fa1ede5510a","affectsGlobalScope":true},{"version":"da233fc1c8a377ba9e0bed690a73c290d843c2c3d23a7bd7ec5cd3d7d73ba1e0","affectsGlobalScope":true},{"version":"d154ea5bb7f7f9001ed9153e876b2d5b8f5c2bb9ec02b3ae0d239ec769f1f2ae","affectsGlobalScope":true},{"version":"bb2d3fb05a1d2ffbca947cc7cbc95d23e1d053d6595391bd325deb265a18d36c","affectsGlobalScope":true},{"version":"c80df75850fea5caa2afe43b9949338ce4e2de086f91713e9af1a06f973872b8","affectsGlobalScope":true},{"version":"9d57b2b5d15838ed094aa9ff1299eecef40b190722eb619bac4616657a05f951","affectsGlobalScope":true},{"version":"6c51b5dd26a2c31dbf37f00cfc32b2aa6a92e19c995aefb5b97a3a64f1ac99de","affectsGlobalScope":true},{"version":"6e7997ef61de3132e4d4b2250e75343f487903ddf5370e7ce33cf1b9db9a63ed","affectsGlobalScope":true},{"version":"2ad234885a4240522efccd77de6c7d99eecf9b4de0914adb9a35c0c22433f993","affectsGlobalScope":true},{"version":"09aa50414b80c023553090e2f53827f007a301bc34b0495bfb2c3c08ab9ad1eb","affectsGlobalScope":true},{"version":"cd483c056da900716879771893a3c9772b66c3c88f8943b4205aec738a94b1d0","affectsGlobalScope":true},{"version":"c37f8a49593a0030eecb51bbfa270e709bec9d79a6cc3bb851ef348d4e6b26f8","affectsGlobalScope":true},"1f03b495671c3a1bd24510f38b8947f0991dfd6bf0278c68eca14af15b306e1f",{"version":"48da7777fb5b3d49f8bca6e373eeff5230f3df6434fbb16721352e214b5c337a","signature":"a2dc116b16fae95e29d3c0c34ccdce1d0c5222110739a088eb15bfd3d6243859"},"0308641bf2889c79cc9d6815e4ed9876e2e627991ca4fea1d8986be96e004605","67633388f50fe010a7b4d892721437d0fac88a282ef46217137d263a8a6651ed","cc957354aa3c94c9961ebf46282cfde1e81d107fc5785a61f62c67f1dd3ac2eb","a46a2e69d12afe63876ec1e58d70e5dbee6d3e74132f4468f570c3d69f809f1c","93de1c6dab503f053efe8d304cb522bb3a89feab8c98f307a674a4fae04773e9","fc72135da24040641388fb5f2c2a7a99aa5b962c0fa125bd96fabeec63dd2e63","5426e62886b7be7806312d31a00e8f7dccd6fe63ba9bbefe99ee2eab29cc48a3","9f47d99ed5c23a78163db6ac3adee21d0398b2c53f264ceac0d77ce5ee4dabd5","89ccbe04e737ce613f5f04990271cfa84901446350b8551b0555ddf19319723b","9927b3566cfea0bf8ef5f341de65b8adb5be20f27320ec0319f85f8804e12f4e","aa4b85c0dbb237cb3594f2cfebcc9209ba65b635b739fc71da8b5e86952f4324","3695ed125dfdf6f9bb93de03c94a5a2579fa2b79e89f8f25bb02ab33207653e5","a26a99e1763be300fb411976bc8e276ddfaeb5f251ea9cb2d701ae2556dbd9a4","982576b3afed465780b0485d6dc977fd52506a6a8383156eb1e7ac54f8c7db49","4c2c4f53e8eedd970f8afa369d7371544fb6231bf95e659f8602e09abe74d5a5",{"version":"32ddf2b046fa7269050f64a87f1f3d2db10b92ad6302460681915af1207b1222","affectsGlobalScope":true},"c2b5085f47e41d6940bbc5b0d3bd7cc0037c752efb18aecd243c9cf83ad0c0b7","3143a5add0467b83150961ecd33773b561a1207aec727002aa1d70333068eb1b","9b2a8f604e7c0482a9061755f00b287cc99bd8718dc82d8207dd74c599b6dc43","d0fc76a91c828fbe3f0be5d683273634b7b101068333ceed975a8a9ac464137b",{"version":"1a048ff164b8d9609f5de3139d4e37f6e8a82af82087ac414b9208f52ef8aac7","affectsGlobalScope":true},"3111079f3cb5f2b9c812ca3f46161562bce5bfb355e915f46ed46c41714dc1c3","db86f82fac051ae344b47e8fe7ac7990174b41db79b2b220a49dc5a47c71a9b5","b32b6b16cb0bda68199582ad6f22242d07ee75fac9b1f28a98cd838afc5eea45","4441ee4119824bfaebc49308559edd7545978f9cb41a40f115074e1031dde75f",{"version":"60693a88462d0e97900123b5bf7c73e146ce0cc94da46a61fe6775b430d2ff05","affectsGlobalScope":true},{"version":"588c69eda58b9202676ec7ca11a72c3762819b46a0ed72462c769846153c447c","affectsGlobalScope":true},"ae064ed4f855716b7ff348639ddcd6a6d354a72fae82f506608a7dc9266aa24c","8e63e656267f767e6c15b47776f641d30ef29690581ab9bdddff5b83885d1a43","53d2c24a3cbc00a88ebaf8ab8e1b6e206bc3a6647d544f877241684ea3d484e3","ecee890ff04b70d8e8815fb753c20f24f95203426267a577823d375009c1ace7","0ce99c641ea20b0c0c09d093fc28f18f5ab31dc80033707a1ac3154399de2559","7dc9ed91e245cf0c4f8add7f6845d0cb08cceec4408ce3398c51e1f6dd7679ec","44e42ed6ec9c4451ebe89524e80ac8564e9dd0988c56e6c58f393c810730595d","d79fda68cbfb361c4ee9cd9ea169babb65887534d64017726cd01f54783d20a5","1606ea615c0a5ea9f5c1376a33e34c0e1112e8dee31a5b3b8a74ce781893aa6f","9fef9de633d01cb7f01f68195626a890ededd25cf96a1e785617d08c8668230d","4455c78d226d061b1203c7614c6c6eb5f4f9db5f00d44ff47d0112de8766fbc4",{"version":"ec369bb9d97c4dc09dd2a4093b7ca3ba69ad284831fccac8a1977785e9e38ce5","affectsGlobalScope":true},"4465a636f5f6e9665a90e30691862c9e0a3ac2edc0e66296704f10865e924f2a","9af781f03d44f5635ed7844be0ce370d9d595d4b4ec67cad88f0fac03255257e","f9fd4c3ef6de27fa0e256f4e75b61711c4be05a3399f7714621d3edc832e36b0","e49290b7a927995c0d7e6b2b9c8296284b68a9036d9966531de65185269258d7","c3689f70ce7563c2299f2dcb3c72efdf6f87ae510e7456fa6223c767d0ca99fc","874ca809b79276460011480a2829f4c8d4db29416dd411f71efbf8f497f0ac09","6c903bceaf3f3bc04f2d4c7dcd89ce9fb148b3ba0a5f5408d8f6de2b7eecc7ea","c65a0eeb867ff5c41debade8e2e8e63ec5367172d121afa726a598111d348816","23a28f834a078986bbf58f4e3705956983ff81c3c2493f3db3e5f0e8a9507779","4febdf7f3ec92706c58e0b4e8159cd6de718284ef384260b07c9641c13fc70ce",{"version":"eabefc2999c1489cf870e0c85af908900462fa245822d9a4616780a1a129945d","affectsGlobalScope":true},"7335933d9f30dcfd2c4b6080a8b78e81912a7fcefb1dafccb67ca4cb4b3ac23d","a6bfe9de9adef749010c118104b071d14943802ff0614732b47ce4f1c3e383cd","4c3d0e10396646db4a1e917fb852077ee77ae62e512913bef9cccc2bb0f8bd0e","3b220849d58140dcc6718f5b52dcd29fdb79c45bc28f561cbd29eb1cac6cce13","0ee22fce41f7417a24c808d266e91b850629113c104713a35854393d55994beb","22d1b1d965baba05766613e2e6c753bb005d4386c448cafd72c309ba689e8c24",{"version":"2708349d5a11a5c2e5f3a0765259ebe7ee00cdcc8161cb9990cb4910328442a1","affectsGlobalScope":true},"79d679a1d56574cc5cef92be1f0e5e8fb4af62fb55933b236670a0e0a23c83f6","b2decb030e5d69991bea6246b9edce80f4ae698fd8d9252a750e14520e9a8c32","d6d975cd7bcca88e9edc20abd89b2e912a857e12bbf8c23861d2ac10cd649957","32cd775882775e01f75b52964fb84a99efb148a624b49dd25951a8c2b62144cc","ce5abe9b2aba653d0177c62109353610e16ffabe1f50b40e9f9e0d439db276db","214abfe9a790d3c88f1c40610d44110bb597d58a739aa60ce0ed637169d7de28","35b81484eafd19cad851d0326cc6072e06f1ecf391e4c4af5befa885d47e602e","5f9849e06d49185eeeb08920ba8a520332a7d1cb5ef67b5c2a7b079847e47fdd","6b7966bd64726714468b3edb3a45ebf3339e20b1112678e88378d7a6bfcc66a3","35649e4414179e3b0ae7b9b7f8a36eeee6add7ab47624d6eec047cc3d8d63c20","6f3ea5aa736fcb300c5f5d774344268e8004a6135231c09d2c879d54616178c5","03cc3c32ce5c2b6a3b53f93c9ba0c7244f133f219c6ba0601da25505458f50ce","a0fbda8ee8f837e47fecee732a66a6bbc3a7ca8f1593130217d690f13e574928","cc1ddf76269450069af5553be7332283693b5b76c570f35d3ac9996bf48e1b69","279518f7c887f4c0dc84e87875862dfd46da50e002ce50bb01b5ca3178c737cf","b23b9b6d2671ee1a4a79eee871ebea9bdc3ec38f33c451d88b7e4ebd009bf44c","96f311b0e72c8f852138cbccc80db8229c0fc657969bbb440f9ab691d53f1724","66cafb3247b4c055d1be9d6b505c6facff7587fb8345812d2abde0481da3e7fb","ba814b6f042594187563cdf62733f0a574e3bf402158ab9e7efa62756a58f1a6","54231eacd60cafc4fbd0400dfea9300d0907ca07d627e8d701bf9abf20d3dff3","5527170665d77cca78934866c509a1cf08acfdc770d796d21117ed21c3be6a20","4a10b8a7e451a59526b9f74e8672350b1b3875aa679cf8961daa63f871200e7b","1aa8a5285da11ff60ae4095a3d0150fac84640102b00bd30cf7b2e2296c8d304","6dd48c58608596d91ed896bf718f91e2c7aa6b13c8fd602efd81ce3fa4499c94","4f4bb0534370e6151a87b2e695e602b741367c8fc9935eb08c96295d1f2d7c67","f17e611274a7bf90dc4d9f5343d757fa0b54bb5a6b387ce91ddb45ae58bb3470","fe9ac5d1514c170d53791bf35c6cf848f59cb662b5b8a432cb4111b37891324c","d9aa927ff9ae627ba6a93c45ac6cfa1be749bb7451ab675c9c44c806614e3413","9d002baaf366f0326459fb008ee2b9785b8af59225d6b9f941417244a330006b","f1d8b21cdf08726021c8cce0cd6159486236cf1d633eeabbc435b5b2e5869c2e","7c987ce34525ee919325847c465b3a27578e5472166c2162b871d24152d3569c","d66d26abde4bfe9049630ba8ce3912396d6654eb68869090e1207476ac5752c4","b5c9cc23d2bb049a9a9fb89f4c60a8c0d9b33aecfa4429e814e9292d237c51a9","aac4aabadfa2965ca91db1e2cda0ea570ec4682a1129af4defac2507e9568d6d","34dfd74a231a6ca2b4b04ee0f180dc92dc4ddc3b32435b3cbaf48e920572dee8","cadb68b67b80b14a9a5bb64cce3093168fb2bfe2c7b10096d230df5203218de1","8fdf499a5ff78160bf99bc2f276e6025c785f095d0e7a6c6ec3c752cafcbc0b9","d527195559dd49fefc932ee71ebc7ed34a64f5611cbe45557ba7f27d74dc7bee","693015483017a74f286180d19da286d238a328b98595e6e3d37d556538b03bd4","5141c2c2459a3b853bcbd518bd35ec6d633f714b83c4f87b38195159653c1214",{"version":"55d8ffdc2a0bd32a16af86d56b37a9fe025df0b71428c4f094da0aaa4d8d4c1c","signature":"678eaf263d75ca0ab40063fbe6b3e7675665eef57ef30dcefd051ff933c752d3"},{"version":"98d23953c4c413d7e8ff2e925e237e9e08060fcf6dde54e3ec13cff0af86f6a6","signature":"c737c7a5defeab585a270e0eff8e2d29f307bd34c582abd0b0e02203e674f56f"},{"version":"81219c1dacc7c3684e450781d4fabef365fd7cbb7c59ea7b0f1e3bd363e9b61f","signature":"910d2fac24fd87cec6419572d00528987cebb27ad85e573dbcadc85fb8b8c905"},"ee7a6ffbd440b02ac8834902712ae734b37d4a9bd3426e02cb26befc74e0f220","6727961fa9be73fbe6db7223c958375c2eef14f666a42cfd75465e5d081b90bf","790e0846105c38cc12c047515bb80be85d592cd650564768bcb505590a88b3c5",{"version":"3273f0a2ee10a041721cfce0f3432ee4d89f84caa17b104b4292be4cec448102","signature":"57c4b401bc40a98b2a4db1082ab79526f698ccee9bf6ab82297bca3dd671eff5"},{"version":"ee570f1a17758b1b2f1f846c5a7c478bb3abcdfc89d7907e933cea7d06b1d76b","signature":"17897c987c7f8b33ce22c071c8998854b4977398be8275ddfe42d77fb6db6a6a"},{"version":"3a009c32097e61cb0dc58b6348fb1127cb799f173289c29c9ddc5e5ba82d2013","signature":"c1967fc6f69b71b384f9f824c6163b3a8b6936709bd274cefa59b3bc6946a6ca"},{"version":"545c064f87407f06f3157c071460a7585c3796e6ab794a68de8e7cdd1ddcf754","signature":"b54e6fba7b99116a7817e98eccb5ea6e7919eb6f6aa668909b418cd208fd4040"},{"version":"7da00c80efe413416372d36646a4793284ad6fa19eff3280cb700280f1860734","signature":"cffaefad898fff3de5131b53d3c43ea19d8dd08e302482511d285e78c4eec48b"},{"version":"b2828fa6f99e5dff31bf79f441ab0ad57d59c5e632c4ae880ee537b3208eeaca","signature":"0545a204da459bca62369c9187bb92da117c080d630b7178e0dc5658eb5ccd27"},"4fb0b7d532aa6fb850b6cd2f1ee4f00802d877b5c66a51903bc1fb0624126349","a7e430e32eaefba6b1ebf23a94a4562bfe7051cc83558d33ddc8ff342f3c18e9",{"version":"540f2fec4ffc2c4e2a995b716ff471685bfe1839241856c7ffa622a572ccd611","signature":"4ff53ccd133b14f42649207234c37211eddf8b89e9a4942480bc3c4bfbef1a84"},{"version":"d6ddfcda8d4f37413c6a90a4da02ee1554ce402801d07aafb91b432cc42949b8","signature":"0649f5868c173ae9f4dbc7716387d3cd71505203a2951129720836a8421bba84"},"9c0d5409f7791e8028d96674f83594c06db94a2e749099ad0a7be908cf5b38c9","d2683cd06bb4cdd7a987797474bad20cebe5c367ebb4bb4b2cbba7a952d29290","46d2f1f89f283e9dcba0526080efb84c1cfb4aac779e41cdef07ced9d75a2e39","c1fffa8e392fc4e56ac745b741f22c048037cc14e7be64339539a10ce9a0c12f",{"version":"811563c52b6ed2eea57aa69e350b8587de0d13dd3a24f61f794806fefc97e4b7","signature":"43e818adf60173644896298637f47b01d5819b17eda46eaa32d0c7d64724d012"},"d9e55d93aa33fad61bd5c63800972d00ba8879ec5d29f6f3bce67d16d86abc33","2ac9c8332c5f8510b8bdd571f8271e0f39b0577714d5e95c1e79a12b2616f069","42c21aa963e7b86fa00801d96e88b36803188018d5ad91db2a9101bccd40b3ff","d31eb848cdebb4c55b4893b335a7c0cca95ad66dee13cbb7d0893810c0a9c301","77c1d91a129ba60b8c405f9f539e42df834afb174fe0785f89d92a2c7c16b77a","c544d81603149987796b24cca297c965db427b84b2580fb27e52fb37ddc1f470","906c751ef5822ec0dadcea2f0e9db64a33fb4ee926cc9f7efa38afe5d5371b2a","5387c049e9702f2d2d7ece1a74836a14b47fbebe9bbeb19f94c580a37c855351","c68391fb9efad5d99ff332c65b1606248c4e4a9f1dd9a087204242b56c7126d6","e9cf02252d3a0ced987d24845dcb1f11c1be5541f17e5daa44c6de2d18138d0c","e8b02b879754d85f48489294f99147aeccc352c760d95a6fe2b6e49cd400b2fe","9f6908ab3d8a86c68b86e38578afc7095114e66b2fc36a2a96e9252aac3998e0","0eedb2344442b143ddcd788f87096961cd8572b64f10b4afc3356aa0460171c6","71405cc70f183d029cc5018375f6c35117ffdaf11846c35ebf85ee3956b1b2a6","c68baff4d8ba346130e9753cefe2e487a16731bf17e05fdacc81e8c9a26aae9d","2cd15528d8bb5d0453aa339b4b52e0696e8b07e790c153831c642c3dea5ac8af","479d622e66283ffa9883fbc33e441f7fc928b2277ff30aacbec7b7761b4e9579","ade307876dc5ca267ca308d09e737b611505e015c535863f22420a11fffc1c54","f8cdefa3e0dee639eccbe9794b46f90291e5fd3989fcba60d2f08fde56179fb9","86c5a62f99aac7053976e317dbe9acb2eaf903aaf3d2e5bb1cafe5c2df7b37a8","2b300954ce01a8343866f737656e13243e86e5baef51bd0631b21dcef1f6e954","a2d409a9ffd872d6b9d78ead00baa116bbc73cfa959fce9a2f29d3227876b2a1","b288936f560cd71f4a6002953290de9ff8dfbfbf37f5a9391be5c83322324898","61178a781ef82e0ff54f9430397e71e8f365fc1e3725e0e5346f2de7b0d50dfa","6a6ccb37feb3aad32d9be026a3337db195979cd5727a616fc0f557e974101a54","6eef5113135a0f2bbac8259909a5bbb7666bcde022c28f4ab95145623cbe1f72","058b8dd97b7c67b6bf33e7bda7b1e247b019b675d4b6449d14ac002091a8b4f8","89c8a7b88c378663a8124664f2d9b8c2887e186b55aa066edf6d67177ca1aa04","5a30ba65ad753eb2ef65355dbb3011b28b192cb9df2ef0b5f595b51ca7faf353","b15e55c5fa977c2f25ca0b1db52cfa2d1fd4bf0baf90a8b90d4a7678ca462ff1","f41d30972724714763a2698ae949fbc463afb203b5fa7c4ad7e4de0871129a17","86d425f7fcd8d100dafa6286cc289af88cbb639ecbdbd25c3018a8f0f7b09fe5","9795e0a3a45d5b6f1a791ee54b7c8b58bc931e8900966cea2dff9c5bae56073b","5890be29879d02424b7654f40592915189034948f7a18c5ad121c006d4e92811","0ab49086f10c75a1cb3b18bffe799dae021774146d8a2d5a4bb42dda67b64f9b","81c77839e152b8f715ec67b0a8b910bcc2d6cf916794c3519f8798c40efd12ac","a868a534ba1c2ca9060b8a13b0ffbbbf78b4be7b0ff80d8c75b02773f7192c29","464843c00fb3dd4735b28255c5c9fe713f16b8e47a3db09ba1647687440f7aef","34baf65cfee92f110d6653322e2120c2d368ee64b3c7981dff08ed105c4f19b0","d0f6d36b2d86f934560c48d8bfdc7ab60c67cfb2ab6dc1916706aa68e83d6dc2"],"options":{"allowUnreachableCode":false,"allowUnusedLabels":false,"composite":true,"declaration":true,"emitDeclarationOnly":true,"esModuleInterop":true,"exactOptionalPropertyTypes":true,"module":7,"noFallthroughCasesInSwitch":true,"noImplicitOverride":true,"noImplicitReturns":true,"noUncheckedIndexedAccess":true,"noUnusedLocals":true,"noUnusedParameters":true,"outDir":"./","rootDir":"../src","skipLibCheck":true,"strict":true,"strictNullChecks":true,"target":6,"useUnknownInCatchVariables":true},"fileIdsList":[[41],[131,133],[132],[131,134],[129,131],[128,129,130],[128,131],[46,47,49],[47,49],[47],[48],[97],[67,97],[98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124],[41,42,43,44,45],[41,43],[54],[56],[57,62],[58,66,67,74,83],[58,59,66,74],[60,90],[61,62,67,75],[62,83],[63,64,66,74],[64],[65,66],[66],[66,67,68,83,89],[67,68],[69,74,83,89],[66,67,69,70,74,83,86,89],[69,71,83,86,89],[54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96],[66,72],[73,89],[64,66,74,83],[75],[76],[56,77],[78,88],[79],[80],[66,81],[81,82,90,92],[66,83],[84],[85],[74,83,86],[87],[74,88],[80,89],[90],[83,91],[92],[93],[66,68,83,89,92,94],[83,95],[158,197],[158,182,197],[197],[158],[158,183,197],[158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196],[183,197],[155],[88],[66,67,97,149],[140,141],[89,97,140],[135],[39,40,68,75,76,125,145,146,147,148,150,151,152,154,156],[68,76],[39,40,145,146,147,148,151],[40,41,42,43,45,46,47,50,51,52,53,76,125,126,137,138,139,143,144,153],[41,42,45,125,127,136,137],[41,42,43,45,125,142],[41,45,98],[40,41,45,125,137],[76,125],[40,68,76,125,145,152],[39,40,68,76,125,145,147,150],[125,138,139,143,144],[41,125],[41,45],[125,152],[125,147]],"referencedMap":[[43,1],[134,2],[133,3],[135,4],[130,5],[131,6],[129,7],[50,8],[51,9],[52,9],[53,10],[49,11],[98,12],[104,13],[106,12],[125,14],[46,15],[42,1],[44,16],[45,1],[54,17],[56,18],[57,19],[58,20],[59,21],[60,22],[61,23],[62,24],[63,25],[64,26],[65,27],[66,28],[67,29],[68,30],[69,31],[70,32],[71,33],[97,34],[72,35],[73,36],[74,37],[75,38],[76,39],[77,40],[78,41],[79,42],[80,43],[81,44],[82,45],[83,46],[84,47],[85,48],[86,49],[87,50],[88,51],[89,52],[90,53],[91,54],[92,55],[93,56],[94,57],[95,58],[182,59],[183,60],[158,61],[161,61],[180,59],[181,59],[171,59],[170,62],[168,59],[163,59],[176,59],[174,59],[178,59],[162,59],[175,59],[179,59],[164,59],[165,59],[177,59],[159,59],[166,59],[167,59],[169,59],[173,59],[184,63],[172,59],[160,59],[197,64],[191,63],[193,65],[192,63],[185,63],[186,63],[188,63],[190,63],[194,65],[195,65],[187,65],[189,65],[156,66],[155,67],[150,68],[142,69],[141,70],[136,71],[157,72],[39,73],[152,74],[145,75],[138,76],[143,77],[137,78],[144,79],[146,80],[147,81],[148,73],[151,82]],"exportedModulesMap":[[43,1],[134,2],[133,3],[135,4],[130,5],[131,6],[129,7],[50,8],[51,9],[52,9],[53,10],[49,11],[98,12],[104,13],[106,12],[125,14],[46,15],[42,1],[44,16],[45,1],[54,17],[56,18],[57,19],[58,20],[59,21],[60,22],[61,23],[62,24],[63,25],[64,26],[65,27],[66,28],[67,29],[68,30],[69,31],[70,32],[71,33],[97,34],[72,35],[73,36],[74,37],[75,38],[76,39],[77,40],[78,41],[79,42],[80,43],[81,44],[82,45],[83,46],[84,47],[85,48],[86,49],[87,50],[88,51],[89,52],[90,53],[91,54],[92,55],[93,56],[94,57],[95,58],[182,59],[183,60],[158,61],[161,61],[180,59],[181,59],[171,59],[170,62],[168,59],[163,59],[176,59],[174,59],[178,59],[162,59],[175,59],[179,59],[164,59],[165,59],[177,59],[159,59],[166,59],[167,59],[169,59],[173,59],[184,63],[172,59],[160,59],[197,64],[191,63],[193,65],[192,63],[185,63],[186,63],[188,63],[190,63],[194,65],[195,65],[187,65],[189,65],[156,66],[155,67],[150,68],[142,69],[141,70],[136,71],[152,74],[145,83],[138,84],[137,85],[144,1],[147,86],[151,87]],"semanticDiagnosticsPerFile":[43,41,134,132,133,135,130,128,131,129,50,51,52,53,49,99,108,98,100,101,102,103,104,105,106,107,109,110,125,111,112,113,114,115,116,117,118,119,120,121,122,123,124,46,42,44,45,48,54,56,57,58,59,60,61,62,63,64,65,66,67,68,55,96,69,70,71,97,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,126,182,183,158,161,180,181,171,170,168,163,176,174,178,162,175,179,164,165,177,159,166,167,169,173,184,172,160,197,196,191,193,192,185,186,188,190,194,195,187,189,127,149,156,155,150,142,140,141,47,136,7,8,12,11,2,13,14,15,16,17,18,19,20,3,4,24,21,22,23,25,26,27,5,28,29,30,31,6,38,32,33,34,35,36,1,37,10,9,154,157,40,39,152,153,145,138,139,143,137,144,146,147,148,151]},"version":"4.7.4"}
|
package/watch.d.ts
CHANGED
@@ -16,5 +16,5 @@ export declare type WatchOptions = PushOptions & {
|
|
16
16
|
* @param hackmudDirectory path to hackmud directory
|
17
17
|
* @param options {@link WatchOptions details} and {@link PushOptions more details}
|
18
18
|
*/
|
19
|
-
export declare
|
19
|
+
export declare const watch: (sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats }?: LaxPartial<WatchOptions>) => Promise<void>;
|
20
20
|
export default watch;
|
package/watch.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
import{watch as r}from"chokidar";import t from"fs";import{extname as
|
1
|
+
import{watch as r}from"chokidar";import{readdir as t,readFile as o,writeFile as e}from"fs/promises";import{extname as i,basename as s,resolve as a}from"path";import{s as n}from"./constants-9bb78688.js";import{generateTypeDeclaration as p}from"./generateTypeDeclaration.js";import{processScript as l}from"./processScript/index.js";import{D as c,w as m}from"./writeFilePersistent-ee9c9bfd.js";import{a as f}from"./assert-22a7ef8a.js";import{c as u}from"./countHackmudCharacters-a08a265f.js";import"@babel/generator";import"@babel/parser";import"@babel/plugin-proposal-class-properties";import"@babel/plugin-proposal-class-static-block";import"@babel/plugin-proposal-decorators";import"@babel/plugin-proposal-json-strings";import"@babel/plugin-proposal-logical-assignment-operators";import"@babel/plugin-proposal-nullish-coalescing-operator";import"@babel/plugin-proposal-numeric-separator";import"@babel/plugin-proposal-object-rest-spread";import"@babel/plugin-proposal-optional-catch-binding";import"@babel/plugin-proposal-optional-chaining";import"@babel/plugin-proposal-private-property-in-object";import"@babel/plugin-transform-exponentiation-operator";import"@babel/traverse";import"@babel/types";import"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./processScript/minify.js";import"acorn";import"terser";import"./processScript/shared.js";import"./spliceString-0e6b5d6d.js";import"./processScript/postprocess.js";import"./processScript/preprocess.js";import"import-meta-resolve";import"./processScript/transform.js";import"fs";const watch=async(d,g,{scripts:h=["*.*"],onPush:b,minify:w=!0,mangleNames:y=!1,typeDeclarationPath:j,onReady:S,forceQuineCheats:$}={})=>{if(!h.length)throw new Error("scripts option was an empty array");const v=new c((r=>new Set)),E=new Set,F=new Set;let P=!1;for(const r of h){const[t,o]=r.split(".");t&&"*"!=t?o&&"*"!=o?v.get(o).add(t):E.add(t):o&&"*"!=o?F.add(o):P=!0}const D=r(["*.ts","*.js"],{depth:1,cwd:d,awaitWriteFinish:{stabilityThreshold:100},ignored:"*.d.ts"}).on("change",(async r=>{if(r.endsWith(".d.ts"))return;const e=i(r);if(!n.includes(e))return;const p=s(r,e);if(r==s(r)){if(!(P||E.size||F.has(p)||v.has(p)))return;const e=new c((r=>[]));await Promise.all((await t(d,{withFileTypes:!0})).map((async r=>{if(r.isDirectory())for(const o of await t(a(d,r.name),{withFileTypes:!0})){if(!o.isFile())continue;const t=i(o.name);n.includes(t)&&e.get(s(o.name,t)).push(r.name)}})));const h=new Set;if(P||F.has(p)){for(const r of await t(a(d),{withFileTypes:!0}))r.isDirectory()&&h.add(r.name);for(const r of await t(a(g),{withFileTypes:!0}))r.isDirectory()?h.add(r.name):r.isFile()&&r.name.endsWith(".key")&&h.add(r.name.slice(0,-4));for(const r of v.values())for(const t of r)h.add(t)}for(const r of E)h.add(r);for(const r of v.get(p))h.add(r);const j=[...h].filter((r=>!e.has(r)));if(!j.length)return void(null==b||b({file:r,users:[],minLength:0,error:new Error("no users to push to")}));const S=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),D=a(d,r);let T;try{({script:T}=await l(await o(D,{encoding:"utf-8"}),{minify:w,scriptUser:!0,scriptName:p,uniqueID:S,filePath:D,mangleNames:y,forceQuineCheats:$}))}catch(t){return f(t instanceof Error),void(null==b||b({file:r,users:[],minLength:0,error:t}))}return await Promise.all(j.map((r=>m(a(g,r,`scripts/${p}.js`),T.replace(new RegExp(`\\$${S}\\$SCRIPT_USER\\$`,"g"),r).replace(new RegExp(`\\$${S}\\$FULL_SCRIPT_NAME\\$`,"g"),`${r}.${p}`))))),void(null==b||b({file:r,users:j,minLength:u(T),error:void 0}))}const h=s(a(r,".."));if(!(P||E.size||F.has(p)||v.get(p).has(h)))return;const j=a(d,r),S=await o(j,{encoding:"utf-8"});let D;try{({script:D}=await l(S,{minify:w,scriptUser:h,scriptName:p,filePath:j,mangleNames:y,forceQuineCheats:$}))}catch(t){return f(t instanceof Error),void(null==b||b({file:r,users:[],minLength:0,error:t}))}await m(a(g,h,"scripts",`${p}.js`),D),null==b||b({file:r,users:[h],minLength:u(D),error:void 0})}));if(S&&D.on("ready",S),!j)return;let T=j;const writeTypeDeclaration=async()=>{const r=await p(d,g);try{await e(T,r)}catch(t){if(f(t instanceof Error),"EISDIR"!=t.code)throw t;T=a(T,"player.d.ts"),await e(T,r)}};await writeTypeDeclaration(),D.on("add",writeTypeDeclaration),D.on("unlink",writeTypeDeclaration)};export{watch as default,watch};
|
File without changes
|