hackmud-script-manager 0.18.0-7338c14 → 0.18.0-7556335
Sign up to get free protection for your applications and to get access to all the features.
- package/bin/hsm.js +2 -1
- package/constants-9bb78688.js +1 -0
- package/countHackmudCharacters-a08a265f.js +1 -0
- package/generateTypeDeclaration.d.ts +1 -1
- package/generateTypeDeclaration.js +1 -1
- package/index.js +1 -1
- package/package.json +52 -53
- 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/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-0476afeb.js → writeFilePersistent-ee9c9bfd.js} +0 -0
- package/generateTypeDeclaration-8dd67882.js +0 -1
- package/index-73f8f8aa.js +0 -1
- package/minify-fba250e4.js +0 -1
- package/postprocess-164b44d3.js +0 -1
- package/preprocess-67d17495.js +0 -1
- package/pull-9b44f235.js +0 -1
- package/push-3c3e0dfc.js +0 -1
- package/shared-eace5bd5.js +0 -1
- package/syncMacros-0bf3ed91.js +0 -1
- package/transform-eee68ce3.js +0 -1
- package/watch-e580a6f9.js +0 -1
package/bin/hsm.js
CHANGED
@@ -1 +1,2 @@
|
|
1
|
-
|
1
|
+
#!/usr/bin/env node
|
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.18.0-7556335")),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.18.0-7556335"),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()}
|
@@ -0,0 +1 @@
|
|
1
|
+
const s=[".js",".ts"],t=["i","r","f","u","u1","us","ObjectId"];export{s,t as v};
|
@@ -0,0 +1 @@
|
|
1
|
+
function countHackmudCharacters(u){return u.replace(/\/\/.*/g,"").replace(/[ \t\n\r\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000]/g,"").length}export{countHackmudCharacters as c};
|
@@ -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
|
-
|
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"./
|
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,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.18.0-
|
3
|
+
"version": "0.18.0-7556335",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -27,71 +27,70 @@
|
|
27
27
|
"url": "https://github.com/samualtnorman/hackmud-script-manager.git"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@babel/core": "^7.
|
31
|
-
"@babel/generator": "^7.
|
32
|
-
"@babel/parser": "^7.
|
33
|
-
"@babel/plugin-proposal-class-properties": "^7.
|
34
|
-
"@babel/plugin-proposal-class-static-block": "^7.
|
35
|
-
"@babel/plugin-proposal-decorators": "^7.
|
36
|
-
"@babel/plugin-proposal-do-expressions": "^7.
|
37
|
-
"@babel/plugin-proposal-function-bind": "^7.
|
38
|
-
"@babel/plugin-proposal-function-sent": "^7.
|
39
|
-
"@babel/plugin-proposal-json-strings": "^7.
|
40
|
-
"@babel/plugin-proposal-logical-assignment-operators": "^7.
|
41
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.
|
42
|
-
"@babel/plugin-proposal-numeric-separator": "^7.
|
43
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
44
|
-
"@babel/plugin-proposal-optional-catch-binding": "^7.
|
45
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
46
|
-
"@babel/plugin-proposal-partial-application": "^7.
|
47
|
-
"@babel/plugin-proposal-pipeline-operator": "^7.
|
48
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.
|
49
|
-
"@babel/plugin-proposal-record-and-tuple": "^7.
|
50
|
-
"@babel/plugin-proposal-throw-expressions": "^7.
|
51
|
-
"@babel/plugin-transform-exponentiation-operator": "^7.
|
52
|
-
"@babel/plugin-transform-typescript": "^7.
|
53
|
-
"@babel/traverse": "^7.
|
54
|
-
"@babel/types": "^7.
|
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
55
|
"@bloomberg/record-tuple-polyfill": "^0.0.4",
|
56
|
-
"@rollup/plugin-babel": "^5.3.
|
57
|
-
"@rollup/plugin-commonjs": "^22.0.
|
56
|
+
"@rollup/plugin-babel": "^5.3.1",
|
57
|
+
"@rollup/plugin-commonjs": "^22.0.1",
|
58
58
|
"@rollup/plugin-json": "^4.1.0",
|
59
|
-
"@rollup/plugin-node-resolve": "^13.0
|
60
|
-
"acorn": "^8.
|
61
|
-
"chalk": "^5.0.
|
62
|
-
"chokidar": "^3.5.
|
63
|
-
"import-meta-resolve": "^
|
64
|
-
"prettier": "^2.
|
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
65
|
"proxy-polyfill": "^0.3.2",
|
66
|
-
"rollup": "^2.
|
67
|
-
"terser": "^5.
|
66
|
+
"rollup": "^2.77.0",
|
67
|
+
"terser": "^5.14.2"
|
68
68
|
},
|
69
69
|
"devDependencies": {
|
70
|
-
"@babel/preset-env": "^7.
|
71
|
-
"@babel/preset-typescript": "^7.
|
72
|
-
"@samual/lib": "^0.3.
|
73
|
-
"@types/babel__core": "^7.1.
|
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
74
|
"@types/babel__generator": "^7.6.4",
|
75
75
|
"@types/babel__traverse": "^7.17.1",
|
76
|
-
"@types/node": "14",
|
77
|
-
"@types/prettier": "^2.
|
78
|
-
"@types/semver": "^7.3.
|
79
|
-
"@typescript-eslint/eslint-plugin": "^5.
|
80
|
-
"@typescript-eslint/parser": "^5.
|
81
|
-
"eslint": "^8.
|
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
82
|
"eslint-plugin-array-func": "^3.1.7",
|
83
83
|
"eslint-plugin-eslint-comments": "^3.2.0",
|
84
|
-
"eslint-plugin-
|
85
|
-
"eslint-plugin-
|
86
|
-
"
|
87
|
-
"latest-version": "^6.0.0",
|
84
|
+
"eslint-plugin-regexp": "^1.7.0",
|
85
|
+
"eslint-plugin-unicorn": "^43.0.2",
|
86
|
+
"latest-version": "^7.0.0",
|
88
87
|
"rollup-plugin-preserve-shebang": "^1.0.1",
|
89
88
|
"rollup-plugin-terser": "^7.0.2",
|
90
|
-
"semver": "^7.3.
|
91
|
-
"typescript": "^4.
|
89
|
+
"semver": "^7.3.7",
|
90
|
+
"typescript": "^4.7.4"
|
92
91
|
},
|
93
92
|
"optionalDependencies": {
|
94
|
-
"deasync": "^0.1.
|
93
|
+
"deasync": "^0.1.27"
|
95
94
|
},
|
96
95
|
"engines": {
|
97
96
|
"node": ">=14"
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
export{t as default,t as transform}from"../transform-eee68ce3.js";import"@babel/traverse";import"@babel/types";import"../shared-eace5bd5.js";import"../assert-22a7ef8a.js";
|
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
|
-
|
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
|
-
|
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};
|
package/syncMacros.d.ts
CHANGED
package/syncMacros.js
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
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","8c40baf2d3ba5168e65ea85a22e1fc3164898761a42e7a544501f4ff7605ff94","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
|
-
|
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
|
@@ -1 +0,0 @@
|
|
1
|
-
import e from"fs";import{basename as t,resolve as n}from"path";const{readdir:s}=e.promises;async function generateTypeDeclaration(e,a){const i=new Set;if(a)for(const e of await s(a,{withFileTypes:!0}))e.isFile()&&e.name.endsWith(".key")&&i.add(t(e.name,".key"));const r=[],o=[],f={},c={};await Promise.all((await s(e,{withFileTypes:!0})).map((async a=>{if(a.isFile())a.name.endsWith(".ts")?a.name.endsWith(".d.ts")||r.push(t(a.name,".ts")):a.name.endsWith(".js")&&o.push(t(a.name,".js"));else if(a.isDirectory()){const r=[],o=[];f[a.name]=r,c[a.name]=o,i.add(a.name);for(const i of await s(n(e,a.name),{withFileTypes:!0}))i.isFile()&&(i.name.endsWith(".ts")?a.name.endsWith(".d.ts")||r.push(t(i.name,".ts")):i.name.endsWith(".js")&&o.push(t(i.name,".js")))}}))),e=n(e);let l="";for(const t of r)l+=`type $${t}$ = typeof import("${e}/${t}").default\n`;l+="\n";for(const t in f){const n=f[t];for(const s of n)l+=`type $${t}$${s}$ = typeof import("${e}/${t}/${s}").default\n`}l+="\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)l+=`\t${e}: Subscript<$${e}$>\n`;for(const e of o)l+=`\t${e}: (...args: any) => any\n`;l+="}\n\ninterface PlayerFullsec {";let p=!0;for(const e of i){const t=f[e],n=c[e];if(t&&t.length||n&&n.length){if(p=!0,l+=`\n\t${e}: WildFullsec & {\n`,t)for(const n of t)l+=`\t\t${n}: Subscript<$${e}$${n}$>\n`;if(n)for(const e of n)l+=`\t\t${e}: (...args: any) => any\n`;l+="\t}"}else p&&(l+="\n",p=!1),l+=`\t${e}: WildFullsec`;l+="\n"}return l+="}\n",l}export{generateTypeDeclaration as g};
|
package/index-73f8f8aa.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import e from"@babel/generator";import{parse as o}from"@babel/parser";import r from"@babel/plugin-proposal-class-properties";import a from"@babel/plugin-proposal-class-static-block";import s from"@babel/plugin-proposal-decorators";import l from"@babel/plugin-proposal-json-strings";import i from"@babel/plugin-proposal-logical-assignment-operators";import n from"@babel/plugin-proposal-nullish-coalescing-operator";import c from"@babel/plugin-proposal-numeric-separator";import u from"@babel/plugin-proposal-object-rest-spread";import f from"@babel/plugin-proposal-optional-catch-binding";import d from"@babel/plugin-proposal-optional-chaining";import b from"@babel/plugin-proposal-private-property-in-object";import g from"@babel/plugin-transform-exponentiation-operator";import h from"@babel/traverse";import y from"@babel/types";import w from"@rollup/plugin-babel";import k from"@rollup/plugin-commonjs";import x from"@rollup/plugin-json";import v from"@rollup/plugin-node-resolve";import{resolve as j}from"path";import S from"prettier";import{rollup as E}from"rollup";import{s as C,t as L}from"./transform-eee68ce3.js";export{t as transform}from"./transform-eee68ce3.js";import{m as $}from"./minify-fba250e4.js";export{m as minify}from"./minify-fba250e4.js";import{p as N}from"./postprocess-164b44d3.js";export{p as postprocess}from"./postprocess-164b44d3.js";import{p as I}from"./preprocess-67d17495.js";export{p as preprocess}from"./preprocess-67d17495.js";import{i as P,r as D}from"./shared-eace5bd5.js";import{a as _}from"./assert-22a7ef8a.js";import"acorn";import"terser";import"./spliceString-0e6b5d6d.js";import"import-meta-resolve";const{default:M}=w,{format:O}=S,{default:T}=e,{default:U}=h;async function processScript(e,{minify:t=!0,uniqueID:p=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),scriptUser:m="UNKNOWN",scriptName:h="UNKNOWN",filePath:w,mangleNames:S=!1,forceQuineCheats:W}={}){_(/^\w{11}$/.exec(p));const q=e;let V,F;const H=/^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(e);if(H)e=`export default ${e}`,({autocomplete:V}=H.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 "))V=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":F=4;break;case"highsec":case"high":case"hs":case"3s":case"h":case"3":F=3;break;case"midsec":case"mid":case"ms":case"2s":case"m":case"2":F=2;break;case"lowsec":case"low":case"ls":case"1s":case"l":case"1":F=1;break;case"nullsec":case"null":case"ns":case"0s":case"n":case"0":F=0;break;default:throw new Error(`unrecognised seclevel "${e}"`)}}}_(/^\w{11}$/.exec(p));const z=[[s.default,{decoratorsBeforeExport:!0}],[r.default],[a.default],[b.default],[i.default],[c.default],[n.default],[d.default],[f.default],[l.default],[u.default],[g.default]];let K;if(w)if(K=j(w),w.endsWith(".ts"))z.push([(await import("@babel/plugin-transform-typescript")).default,{allowDeclareFields:!0,optimizeConstEnums:!0}]);else{const[e,o,r,a,t,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")]);z.push([e.default],[o.default],[r.default],[a.default],[t.default,{proposal:"hack",topicToken:"%"}],[p.default],[s.default,{syntaxType:"hash",importPolyfill:!0}])}else{K=`${p}.ts`;const[e,o,r,a,t,s,l,i]=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")]);z.push([e.default,{allowDeclareFields:!0,optimizeConstEnums:!0}],[o.default],[r.default],[a.default],[t.default],[s.default,{proposal:"hack",topicToken:"%"}],[l.default],[i.default,{syntaxType:"hash",importPolyfill:!0}])}const Q=await E({input:K,plugins:[{name:"hackmud-script-manager",transform:async e=>(await I(e,{uniqueID:p})).code},M({babelHelpers:"bundled",plugins:z,configFile:!1,extensions:C}),k(),v({extensions:C}),x()],treeshake:{moduleSideEffects:!1}}),A=["NULLSEC","LOWSEC","MIDSEC","HIGHSEC","FULLSEC"];e=(await Q.generate({})).output[0].code;const{file:B,seclevel:G}=L(o(e,{sourceType:"module"}),q,{uniqueID:p,scriptUser:m,scriptName:h});if(null!=F&&G<F)throw new Error(`detected seclevel ${A[G]} is lower than stated seclevel ${A[F]}`);if(e=T(B).code,t?e=await $(B,{uniqueID:p,mangleNames:S,forceQuineCheats:W,autocomplete:V}):(U(B,{MemberExpression({node:e}){e.computed||(_("Identifier"==e.property.type),"prototype"==e.property.name?(e.computed=!0,e.property=y.stringLiteral("prototype")):"__proto__"==e.property.name?(e.computed=!0,e.property=y.stringLiteral("__proto__")):P(e.property.name)&&(e.computed=!0,e.property=y.stringLiteral(D(p,e.property.name))))},VariableDeclarator(e){!function renameVariables(o){switch(o.type){case"Identifier":P(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)_("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}"`)}}(e.node.id)},ObjectProperty({node:e}){"Identifier"==e.key.type&&P(e.key.name)&&(e.key=y.stringLiteral(D(p,e.key.name)),e.shorthand=!1)},StringLiteral({node:e}){e.value=D(p,e.value)},TemplateLiteral({node:e}){for(const o of e.quasis)o.value.cooked?(o.value.cooked=D(p,o.value.cooked),o.value.raw=o.value.cooked.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"$\\{")):o.value.raw=D(p,o.value.raw)},RegExpLiteral(e){e.node.pattern=D(p,e.node.pattern),delete e.node.extra}}),e=O(T(B,{comments:!1}).code,{parser:"babel",arrowParens:"avoid",semi:!1,trailingComma:"none"})),e=N(e,G,p),P(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};
|
package/minify-fba250e4.js
DELETED
@@ -1 +0,0 @@
|
|
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{g as o,i as s,r as p}from"./shared-eace5bd5.js";import{a as l}from"./assert-22a7ef8a.js";import{s as u}from"./spliceString-0e6b5d6d.js";function countHackmudCharacters(e){return e.replace(/\/\/.*/g,"").replace(/[ \t\n\r\u00A0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000]/g,"").length}const{default:c}=e,{default:f}=t;async function minify(e,{uniqueID:t="00000000000",mangleNames:i=!1,forceQuineCheats:n,autocomplete:d}={}){let m;if(l(/^\w{11}$/.exec(t)),f(e,{Program(e){m=e,e.skip()}}),m.scope.hasGlobal("_START"))for(const e of o("_START",m))e.replaceWith(r.identifier("_ST"));if(m.scope.hasGlobal("_TIMEOUT"))for(const e of o("_TIMEOUT",m))e.replaceWith(r.identifier("_TO"));const y=m.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 m.scope.globals){if("arguments"==e||e.startsWith(`$${t}$`))continue;const i=o(e,m);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$`,m);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 $=[];let g,E,b=!1;if(1!=n){const o=r.cloneNode(e);if(f(o,{MemberExpression({node:e}){e.computed||(l("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(p(t,e.property.name))))},ObjectProperty({node:e}){"Identifier"==e.key.type&&s(e.key.name)&&(e.key=r.stringLiteral(p(t,e.key.name)),e.shorthand=!1)},StringLiteral({node:e}){e.value=p(t,e.value)},TemplateLiteral({node:e}){for(const r of e.quasis)r.value.cooked?(r.value.cooked=p(t,r.value.cooked),r.value.raw=r.value.cooked.replace(/\\/g,"\\\\").replace(/`/g,"\\`").replace(/\$\{/g,"$\\{")):r.value.raw=p(t,r.value.raw)},RegExpLiteral(e){e.node.pattern=p(t,e.node.pattern),delete e.node.extra}}),g=(await a.minify(c(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__"'),d&&(g=u(g,`//${d}\n`,getFunctionBodyStart(g)+1)),0==n)return g}let h,v=!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_${$.push(i)-1}_`))},ArrayExpression(e){const i=[];parseArrayExpression(e.node,i)&&e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${$.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||(l("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_`)),b=!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=$.indexOf(n);-1==i&&(i+=$.push(n)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))})()),e.skip()}},NullLiteral(e){let i=$.indexOf(null);-1==i&&(i+=$.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=$.indexOf(e.node.value);-1==i&&(i+=$.push(e.node.value)),e.replaceWith(r.identifier(`_${t}_JSON_VALUE_${i}_`))})())},StringLiteral(e){if(e.node.value=p(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=$.indexOf(e.node.value);-1==i&&(i+=$.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=$.indexOf(e.key.name);-1==i&&(i+=$.push(e.key.name)),e.computed=!0,e.key=r.identifier(`_${t}_JSON_VALUE_${i}_`)},RegExpLiteral(e){e.node.pattern=p(t,e.node.pattern),delete e.node.extra}}),e.skip()}}),await Promise.all(i);const n=e.program.body[0];if(l("FunctionDeclaration"==n.type),$.length)if(v=!0,1==$.length)if("string"!=typeof $[0]||$[0].includes("\n")||$[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)]))]);b&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),E=JSON.stringify($[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))]);b&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),E=$[0]}else{const e=r.variableDeclaration("let",[r.variableDeclarator(r.arrayPattern($.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)]))]);b&&e.declarations.push(r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))),n.body.body.unshift(e),E=JSON.stringify($)}else b&&n.body.body.unshift(r.variableDeclaration("let",[r.variableDeclarator(r.identifier(`_${t}_UNDEFINED_`))]));h=c(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!=E&&(h=u(h,`${d?`//${d}\n`:""}\n//\t${E}\t\n`,getFunctionBodyStart(h)+1),h=h.replace(`$${t}$SPLIT_INDEX$`,await minifyNumber(h.split("\t").findIndex((e=>e==E))))),1==n?h:(l(g),countHackmudCharacters(g)<=countHackmudCharacters(h)+Number(v)?g:h)}function parseObjectExpression(e,t){if(!e.properties.length)return!1;for(const r of e.properties){if("ObjectProperty"!=r.type||r.computed)return!1;if(l("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}function 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}async function minifyNumber(e){return/\$\((?<number>.+)\)/.exec((await a.minify(`$(${e})`,{ecma:2015})).code).groups.number}function 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{countHackmudCharacters as c,minify as m};
|
package/postprocess-164b44d3.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
function postprocess($,e,p){return $.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 p};
|
package/preprocess-67d17495.js
DELETED
@@ -1 +0,0 @@
|
|
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:n}=e;async function preprocess(e,{uniqueID:r="00000000000"}={}){s(/^\w{11}$/.test(r));const a=e;let c,f,d;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{f=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(a),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(f,{Program(e){d=e,e.skip()}});const u=d.scope.hasGlobal("Record"),h=d.scope.hasGlobal("Tuple");return(u||h)&&f.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"))),d.scope.hasGlobal("Proxy")&&f.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==d.node.body.length&&"FunctionDeclaration"==d.node.body[0].type?{code:`export default ${n(f).code}`}:{code:n(f).code}}export{preprocess as p};
|
package/pull-9b44f235.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{dirname as t,resolve as r}from"path";import i from"fs";const{mkdir:s,copyFile:o}=i.promises;async function pull(i,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,i,e){return o(r,i,e).catch((async a=>{if("ENOENT"!=a.code)throw a;await s(t(i),{recursive:!0}),await o(r,i,e)}))}(r(e,c,"scripts",`${n}.js`),r(i,c,`${n}.js`))}export{pull as p};
|
package/push-3c3e0dfc.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import e from"fs";import{resolve as i,extname as t,basename as a}from"path";import{s as r}from"./transform-eee68ce3.js";import{processScript as s}from"./index-73f8f8aa.js";import{D as o,w as p}from"./writeFilePersistent-0476afeb.js";import{c as n}from"./minify-fba250e4.js";import"@babel/traverse";import"@babel/types";import"./shared-eace5bd5.js";import"./assert-22a7ef8a.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"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./postprocess-164b44d3.js";import"./preprocess-67d17495.js";import"import-meta-resolve";import"./spliceString-0e6b5d6d.js";import"acorn";import"terser";const{readFile:l,readdir:m}=e.promises;async function push(e,c,{scripts:f=["*.*"],onPush:u=(()=>{}),minify:g=!0,mangleNames:d=!1,forceQuineCheats:b}={}){const h=new o((e=>new Set)),w=new Set,$=new Set;let y=!1;for(const e of f){const[i,t]=e.split(".");i&&"*"!=i?t&&"*"!=t?h.get(i).add(t):w.add(i):t&&"*"!=t?$.add(t):y=!0}const j=new o((e=>new Set)),P=[],S=new o((e=>new Set));let N;if($.size||y){const t=await m(i(c),{withFileTypes:!0}),a=new Set([...(N=await m(i(e),{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 a)w.add(e);else for(const e of a){const i=h.get(e);for(const e of $)i.add(e)}}return await Promise.all([...w].map((async o=>{await m(i(e,o),{withFileTypes:!0}).then((async m=>{await Promise.all(m.map((async m=>{if(m.name.endsWith(".d.ts"))return;const f=t(m.name);if(m.isFile()&&r.includes(f)){const t=a(m.name,f),r=i(e,o,m.name),{script:h}=await s(await l(r,{encoding:"utf-8"}),{minify:g,scriptUser:o,scriptName:t,filePath:r,mangleNames:d,forceQuineCheats:b}),w={file:`${o}/${m.name}`,users:[o],minLength:n(h),error:void 0};S.get(o).add(t),P.push(w),await p(i(c,o,`scripts/${t}.js`),h),u(w)}})))}),(e=>{if("ENOENT"!=e.code)throw e}))}))),await Promise.all([...h].map((async([t,a])=>{w.has(t)||await Promise.all([...a].map((async a=>{let o,m,f;for(const s of r)try{m=`${a}${s}`,o=await l(f=i(e,t,m),{encoding:"utf-8"});break}catch{}if(o){const{script:e}=await s(o,{minify:g,scriptUser:t,scriptName:a,filePath:f,mangleNames:d,forceQuineCheats:b}),r={file:`${t}/${m}`,users:[t],minLength:n(e),error:void 0};P.push(r),await p(i(c,t,"scripts",`${a}.js`),e),u(r)}else j.get(a).add(t)})))}))),await(w.size?Promise.all((N||await m(i(e),{withFileTypes:!0})).map((async o=>{if(o.name.endsWith(".d.ts"))return;const m=t(o.name);if(!o.isFile()||!r.includes(m))return;const f=a(o.name,m),h=[...w,...j.get(f)].filter((e=>!S.get(e).has(f)));if(!h.length)return;const $=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),y=i(e,o.name),{script:N}=await s(await l(y,{encoding:"utf-8"}),{minify:g,scriptUser:!0,scriptName:f,uniqueID:$,filePath:y,mangleNames:d,forceQuineCheats:b}),F={file:o.name,users:h,minLength:n(N),error:void 0};await Promise.all(h.map((e=>p(i(c,e,`scripts/${f}.js`),N.replace(new RegExp(`\\$${$}\\$SCRIPT_USER\\$`,"g"),e).replace(new RegExp(`\\$${$}\\$FULL_SCRIPT_NAME\\$`,"g"),`${e}.${f}`))))),P.push(F),u(F)}))):Promise.all([...j].map((async([t,a])=>{let o,m,f;for(const a of r)try{m=`${t}${a}`,o=await l(f=i(e,m),{encoding:"utf-8"});break}catch{}if(o){const e=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),{script:r}=await s(o,{minify:g,scriptUser:!0,scriptName:t,uniqueID:e,filePath:f,mangleNames:d,forceQuineCheats:b}),l={file:m,users:[...a],minLength:n(r),error:void 0};await Promise.all([...a].map((a=>p(i(c,a,`scripts/${t}.js`),r.replace(new RegExp(`\\$${e}\\$SCRIPT_USER\\$`,"g"),a).replace(new RegExp(`\\$${e}\\$FULL_SCRIPT_NAME\\$`,"g"),`${a}.${t}`))))),P.push(l),u(l)}})))),P}export{push as default,push};
|
package/shared-eace5bd5.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import e from"@babel/types";import{e as $}from"./assert-22a7ef8a.js";function getReferencePathsToGlobal(r,a){const[l]=a.unshiftContainer("body",e.variableDeclaration("let",[e.variableDeclarator(e.identifier(r))]));a.scope.crawl();const n=$(a.scope.getBinding(r));return l.remove(),n.referencePaths}function includesIllegalString(e){return e.includes("SC$")||e.includes("DB$")||e.includes("__D_S")||e.includes("__FMCL_")||e.includes("__G_")}function replaceUnsafeStrings(e,$){return $.replace(/SC\$/g,`$${e}$\\$SC_DOLLAR$`).replace(/DB\$/g,`$${e}$\\$DB_DOLLAR$`).replace(/__D_S/g,`$${e}$\\$D$`).replace(/__FMCL_/g,`$${e}$\\$FMCL$`).replace(/__G_/g,`$${e}$\\$G$`).replace(/\/\//g,`$${e}$SLASH_SLASH$`).replace(/#[0-4fhmln]?s(?:\.[_a-z][\d_a-z]{0,24}){2}\(/g,`$${e}$NOT_A_SUBSCRIPT$$$&$`).replace(/#db\.(?<methodName>[irfu]|u1|us|ObjectId)\(/g,`$${e}$NOT_A_DB_CALL$$$1$`).replace(/#D\(/g,`$${e}$NOT_A_DEBUG_CALL$`).replace(/#FMCL/g,`$${e}$NOT_FMCL$`).replace(/#G/g,`$${e}$NOT_G$`)}export{getReferencePathsToGlobal as g,includesIllegalString as i,replaceUnsafeStrings as r};
|
package/syncMacros-0bf3ed91.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import e from"fs";import{extname as s,basename as t,resolve as a}from"path";const{readFile:o,readdir:n,stat:r,writeFile:c}=e.promises;async function syncMacros(e){const i=await n(e,{withFileTypes:!0}),m=new Map,l=[];await Promise.all(i.map((async n=>{if(n.isFile())switch(s(n.name)){case".macros":{const[s,t]=await Promise.all([o(a(e,n.name),{encoding:"utf-8"}).then((e=>e.split("\n"))),r(a(e,n.name)).then((({mtime:e})=>e))]);for(let e=0;e<s.length/2-1;e++){const a=s[2*e],o=m.get(a);(!o||t>o.date)&&m.set(a,{date:t,macro:s[2*e+1]})}}break;case".key":l.push(t(n.name,".key"))}})));let f="",p=0;for(const[e,{macro:s}]of[...m].sort((([e],[s])=>(e>s)-(e<s))))s[0]==s[0].toLowerCase()&&(f+=`${e}\n${s}\n`,p++);for(const s of l)c(a(e,`${s}.macros`),f);return{macrosSynced:p,usersSynced:l.length}}export{syncMacros as s};
|
package/transform-eee68ce3.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import e from"@babel/traverse";import t from"@babel/types";import{g as i}from"./shared-eace5bd5.js";import{a as r}from"./assert-22a7ef8a.js";const n=[".js",".ts"],o=["i","r","f","u","u1","us","ObjectId"];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:a}=e,s=["Map","Set","Date","JSON","Math","Array","Error","isNaN","Number","Object","RegExp","String","Symbol","BigInt"];function transform(e,n,{uniqueID:p="00000000000",scriptUser:c="UNKNOWN",scriptName:l="UNKNOWN",seclevel:d=4}={}){const f=`_${p}_SCRIPT_`,b=new Map,y=new Map;let $;if(a(e,{Program(e){$=e,e.skip()}}),$.scope.hasGlobal("_SOURCE"))for(const e of i("_SOURCE",$))e.replaceWith(t.stringLiteral(n));if($.scope.hasGlobal("_BUILD_DATE"))for(const e of i("_BUILD_DATE",$))e.replaceWith(t.numericLiteral(Date.now()));if($.scope.hasGlobal("_SCRIPT_USER"))for(const e of i("_SCRIPT_USER",$))1==c?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_USER$`)):e.replaceWith(t.stringLiteral(c));if($.scope.hasGlobal("_SCRIPT_NAME"))for(const e of i("_SCRIPT_NAME",$))1==l?e.replaceWith(t.stringLiteral(`$${p}$SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(l));if($.scope.hasGlobal("_FULL_SCRIPT_NAME"))for(const e of i("_FULL_SCRIPT_NAME",$))1==c||1==l?e.replaceWith(t.stringLiteral(`$${p}$FULL_SCRIPT_NAME$`)):e.replaceWith(t.stringLiteral(`${c}.${l}`));let m=!1;if($.scope.hasGlobal("Function")){const e=i("Function",$);if(1==e.length){const t=e[0];r("MemberExpression"==t.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),r("Identifier"==t.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),r("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)r("MemberExpression"==i.parent.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),r("Identifier"==i.parent.property.type,"`Function` isn't available in hackmud, only `Function.prototype` is accessible"),r("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;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 i("$db",$)){var E;r("MemberExpression"==e.parentPath.node.type),r("Identifier"==e.parentPath.node.property.type);const i=e.parentPath.node.property.name;r(o.includes(i),`invalid db method "${i}", valid db methods are "${o.join('", "')}"`),"CallExpression"==(null===(E=e.parentPath.parentPath)||void 0===E?void 0:E.type)?e.parentPath.replaceWith(t.identifier(`$${p}$DB$${i}$`)):"ObjectId"==i?e.parentPath.replaceWith(t.arrowFunctionExpression([],t.callExpression(t.identifier(`$${p}$DB$${i}$`),[]))):"i"==i||"r"==i?e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a")],t.callExpression(t.identifier(`$${p}$DB$${i}$`),[t.identifier("a")]))):e.parentPath.replaceWith(t.arrowFunctionExpression([t.identifier("a"),t.identifier("b")],t.callExpression(t.identifier(`$${p}$DB$${i}$`),[t.identifier("a"),t.identifier("b")])))}if($.scope.hasGlobal("$D"))for(const e of i("$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 i("$FMCL",$))e.replaceWith(t.identifier(`$${p}$FMCL$`));if($.scope.hasGlobal("$G"))for(const e of i("$G",$))e.replaceWith(t.identifier(`$${p}$GLOBAL$`));if($.scope.hasGlobal("_SECLEVEL"))for(const e of i("_SECLEVEL",$))e.replaceWith(t.numericLiteral(d));let _=!1,u=!1;if($.scope.hasGlobal("Object"))for(const e of i("Object",$))"MemberExpression"!=e.parent.type||e.parent.computed||(r("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 O;if(r(P,"program is empty"),"ExportNamedDeclaration"==P.type){$.node.body.pop();for(const e of P.specifiers){r("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 $.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([]))),$.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))]))))]))),$.scope.crawl();const e=new Set;let n=0;for(const[i,o]of[...x.body.entries()].reverse())if("VariableDeclaration"==o.type){r(1==o.declarations.length);const a=o.declarations[0];if(r("Identifier"==a.id.type,`declarator.id.type was "${a.id.type}"`),$.scope.crawl(),$.scope.hasGlobal(a.id.name)){x.body.splice(i,1);const[s]=$.unshiftContainer("body",x),[c]=$.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);r(e);for(const i of e.referencePaths)r("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(i,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),n++}else e.add(a.id.name)}else if("ClassDeclaration"==o.type&&($.scope.crawl(),$.scope.hasGlobal(o.id.name))){x.body.splice(i,1);const[e]=$.unshiftContainer("body",x),[n]=$.unshiftContainer("body",o);$.scope.crawl();const a=$.scope.getBinding(o.id.name);r(a);for(const e of a.referencePaths)r("Identifier"==e.node.type),e.replaceWith(t.memberExpression(t.identifier(`$${p}$GLOBAL$`),t.identifier(e.node.name)));e.remove(),n.remove(),x.body.splice(i,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 i("_EXPORTS",$))e.replaceWith(t.arrayExpression([...b.keys(),...y.keys()].map((e=>t.stringLiteral(e)))));x.body.length&&S.body.body.splice(n,0,t.ifStatement(t.unaryExpression("!",t.identifier(`$${p}$FMCL$`)),x))}return m&&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__")]))])),a(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:n}){r(t.isClass(n));let o=!1;for(const r of e.body){if("ClassMethod"!=r.type)continue;let e=!1;if(a(r.body,{ThisExpression(i){e=!0,o=!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(a(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(),[]))]))}}!n.superClass&&o&&(n.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 i(e,$)){var n,o;r("MemberExpression"==a.parent.type),r("Identifier"==a.parent.property.type),r("MemberExpression"==(null===(n=a.parentPath.parentPath)||void 0===n?void 0:n.node.type)),r("Identifier"==a.parentPath.parentPath.node.property.type),r(/^[_a-z][\d_a-z]{0,24}$/.test(a.parent.property.name),`invalid user "${a.parent.property.name}" in subscript`),r(/^[_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 s)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"))}}export{n as s,transform as t};
|
package/watch-e580a6f9.js
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
import{watch as e}from"chokidar";import r from"fs";import{extname as t,basename as i,resolve as o}from"path";import{s as a}from"./transform-eee68ce3.js";import{g as s}from"./generateTypeDeclaration-8dd67882.js";import{processScript as n}from"./index-73f8f8aa.js";import{D as p,w as l}from"./writeFilePersistent-0476afeb.js";import{a as c}from"./assert-22a7ef8a.js";import{c as m}from"./minify-fba250e4.js";import"@babel/traverse";import"@babel/types";import"./shared-eace5bd5.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"@rollup/plugin-babel";import"@rollup/plugin-commonjs";import"@rollup/plugin-json";import"@rollup/plugin-node-resolve";import"prettier";import"rollup";import"./postprocess-164b44d3.js";import"./preprocess-67d17495.js";import"import-meta-resolve";import"./spliceString-0e6b5d6d.js";import"acorn";import"terser";const{readFile:f,readdir:d,writeFile:u}=r.promises;async function watch(r,h,{scripts:g=["*.*"],onPush:w,minify:b=!0,mangleNames:y=!1,typeDeclarationPath:j,onReady:D,forceQuineCheats:T}={}){if(!g.length)throw new Error("scripts option was an empty array");const $=new p((e=>new Set)),v=new Set,F=new Set;let S=!1;for(const e of g){const[r,t]=e.split(".");r&&"*"!=r?t&&"*"!=t?$.get(t).add(r):v.add(r):t&&"*"!=t?F.add(t):S=!0}const E=e(["*.ts","*.js"],{depth:1,cwd:r,awaitWriteFinish:{stabilityThreshold:100},ignored:"*.d.ts"}).on("change",(async e=>{if(e.endsWith(".d.ts"))return;const s=t(e);if(!a.includes(s))return;const u=i(e,s);if(e==i(e)){if(!(S||v.size||F.has(u)||$.has(u)))return;const s=new p((e=>[]));await Promise.all((await d(r,{withFileTypes:!0})).map((async e=>{if(e.isDirectory())for(const n of await d(o(r,e.name),{withFileTypes:!0})){if(!n.isFile())continue;const r=t(n.name);a.includes(r)&&s.get(i(n.name,r)).push(e.name)}})));const g=new Set;if(S||F.has(u)){for(const e of await d(o(r),{withFileTypes:!0}))e.isDirectory()&&g.add(e.name);for(const e of await d(o(h),{withFileTypes:!0}))e.isDirectory()?g.add(e.name):e.isFile()&&e.name.endsWith(".key")&&g.add(e.name.slice(0,-4));for(const e of $.values())for(const r of e)g.add(r)}for(const e of v)g.add(e);for(const e of $.get(u))g.add(e);const j=[...g].filter((e=>!s.has(e)));if(!j.length)return void(null==w||w({file:e,users:[],minLength:0,error:new Error("no users to push to")}));const D=Math.floor(Math.random()*2**52).toString(36).padStart(11,"0"),E=o(r,e);let P;try{({script:P}=await n(await f(E,{encoding:"utf-8"}),{minify:b,scriptUser:!0,scriptName:u,uniqueID:D,filePath:E,mangleNames:y,forceQuineCheats:T}))}catch(r){return c(r instanceof Error),void(null==w||w({file:e,users:[],minLength:0,error:r}))}return await Promise.all(j.map((e=>l(o(h,e,`scripts/${u}.js`),P.replace(new RegExp(`\\$${D}\\$SCRIPT_USER\\$`,"g"),e).replace(new RegExp(`\\$${D}\\$FULL_SCRIPT_NAME\\$`,"g"),`${e}.${u}`))))),void(null==w||w({file:e,users:j,minLength:m(P),error:void 0}))}const g=i(o(e,".."));if(!(S||v.size||F.has(u)||$.get(u).has(g)))return;const j=o(r,e),D=await f(j,{encoding:"utf-8"});let E;try{({script:E}=await n(D,{minify:b,scriptUser:g,scriptName:u,filePath:j,mangleNames:y,forceQuineCheats:T}))}catch(r){return c(r instanceof Error),void(null==w||w({file:e,users:[],minLength:0,error:r}))}await l(o(h,g,"scripts",`${u}.js`),E),null==w||w({file:e,users:[g],minLength:m(E),error:void 0})}));if(D&&E.on("ready",D),!j)return;let P=j;async function writeTypeDeclaration(){const e=await s(r,h);try{await u(P,e)}catch(r){if(c(r instanceof Error),"EISDIR"!=r.code)throw r;P=o(P,"player.d.ts"),await u(P,e)}}await writeTypeDeclaration(),E.on("add",writeTypeDeclaration),E.on("unlink",writeTypeDeclaration)}export{watch as default,watch};
|