hackmud-script-manager 0.21.1-979c2a3 → 0.21.1-ae53eb7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -0
 - package/bin/hsm.js +2 -3
 - package/env.d.ts +19 -21
 - package/generateTypeDeclaration.js +23 -22
 - package/index.js +0 -1
 - package/package.json +4 -2
 - package/processScript/index.js +41 -42
 - package/processScript/minify.js +10 -12
 - package/processScript/preprocess.js +4 -6
 - package/processScript/transform.js +111 -45
 - package/push.js +3 -1
 - package/watch.js +0 -1
 
    
        package/README.md
    CHANGED
    
    | 
         @@ -1,6 +1,8 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            # Hackmud Script Manager
         
     | 
| 
       2 
2 
     | 
    
         
             
            Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
         
     | 
| 
       3 
3 
     | 
    
         | 
| 
      
 4 
     | 
    
         
            +
            Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
         
     | 
| 
      
 5 
     | 
    
         
            +
             
     | 
| 
       4 
6 
     | 
    
         
             
            [](https://ko-fi.com/R6R0XN5CX)
         
     | 
| 
       5 
7 
     | 
    
         | 
| 
       6 
8 
     | 
    
         
             
            You can read about how HSM works [in my blog post](https://samual.uk/blog/js-code-transformation-niche-environment/).
         
     | 
    
        package/bin/hsm.js
    CHANGED
    
    | 
         @@ -11,7 +11,6 @@ import { generateTypeDeclaration } from "../generateTypeDeclaration.js" 
     | 
|
| 
       11 
11 
     | 
    
         
             
            import { pull } from "../pull.js"
         
     | 
| 
       12 
12 
     | 
    
         
             
            import { syncMacros } from "../syncMacros.js"
         
     | 
| 
       13 
13 
     | 
    
         
             
            import "@samual/lib/readDirectoryWithStats"
         
     | 
| 
       14 
     | 
    
         
            -
            import "path/posix"
         
     | 
| 
       15 
14 
     | 
    
         
             
            import "@samual/lib/copyFilePersistent"
         
     | 
| 
       16 
15 
     | 
    
         
             
            const formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
         
     | 
| 
       17 
16 
     | 
    
         
             
            	options = new Map(),
         
     | 
| 
         @@ -64,7 +63,7 @@ if (process.version.startsWith("v21.")) { 
     | 
|
| 
       64 
63 
     | 
    
         
             
            	)
         
     | 
| 
       65 
64 
     | 
    
         
             
            }
         
     | 
| 
       66 
65 
     | 
    
         
             
            if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
         
     | 
| 
       67 
     | 
    
         
            -
            	console.log("0.21.1- 
     | 
| 
      
 66 
     | 
    
         
            +
            	console.log("0.21.1-ae53eb7")
         
     | 
| 
       68 
67 
     | 
    
         
             
            	process.exit()
         
     | 
| 
       69 
68 
     | 
    
         
             
            }
         
     | 
| 
       70 
69 
     | 
    
         
             
            let warnedDeprecatedEmitDtsAlias = !1
         
     | 
| 
         @@ -412,7 +411,7 @@ function logHelp() { 
     | 
|
| 
       412 
411 
     | 
    
         
             
            		default:
         
     | 
| 
       413 
412 
     | 
    
         
             
            			console.log(
         
     | 
| 
       414 
413 
     | 
    
         
             
            				colourS(
         
     | 
| 
       415 
     | 
    
         
            -
            					`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1- 
     | 
| 
      
 414 
     | 
    
         
            +
            					`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-ae53eb7")}\n\n${colourA("Commands:")}\n${colourL("push")}\n    ${pushCommandDescription}\n${colourL("minify")}\n    Minify a script file on the spot\n${colourL("emit-dts")}\n    Generate a type declaration file for a directory of scripts\n${colourL("sync-macros")}\n    Sync macros across all hackmud users\n${colourL("pull")}\n    Pull a script a from a hackmud user's script directory\n\n${colourA("Options:")}\n${colourN("--help")}\n    Can be used on any command e.g. ${colourC("hsm")} ${colourL("push")} ${colourN("--help")} to show helpful information`
         
     | 
| 
       416 
415 
     | 
    
         
             
            				)
         
     | 
| 
       417 
416 
     | 
    
         
             
            			)
         
     | 
| 
       418 
417 
     | 
    
         
             
            	}
         
     | 
    
        package/env.d.ts
    CHANGED
    
    | 
         @@ -189,7 +189,7 @@ type Fullsec = Subscripts & PlayerFullsec & { 
     | 
|
| 
       189 
189 
     | 
    
         | 
| 
       190 
190 
     | 
    
         
             
            			/** @returns A random element from `array`, selected with a random number generated using `rng`
         
     | 
| 
       191 
191 
     | 
    
         
             
            			  * (defaults to `Math.random`). */
         
     | 
| 
       192 
     | 
    
         
            -
            			sample: (array:  
     | 
| 
      
 192 
     | 
    
         
            +
            			sample: <T>(array: T[], rng?: ()=>number) => T
         
     | 
| 
       193 
193 
     | 
    
         | 
| 
       194 
194 
     | 
    
         
             
            			/** @returns Whether two MongoDB `ObjectId`s are equivalent. */ are_ids_eq: (id1: any, id2: any) => boolean
         
     | 
| 
       195 
195 
     | 
    
         
             
            			/** Convert a MongoDB `ObjectId` to a string. */ id_to_str: (id: string | {$oid: string}) => any
         
     | 
| 
         @@ -270,7 +270,7 @@ type Fullsec = Subscripts & PlayerFullsec & { 
     | 
|
| 
       270 
270 
     | 
    
         
             
            			map: <T, U>(array: T[], callback: (index: number, value: T) => U) => U[]
         
     | 
| 
       271 
271 
     | 
    
         | 
| 
       272 
272 
     | 
    
         
             
            			/** @returns A new object derived from `obj` with only the keys specified in `keys`. */
         
     | 
| 
       273 
     | 
    
         
            -
            			pick: (obj:  
     | 
| 
      
 273 
     | 
    
         
            +
            			pick: <TObj extends object, TKeys extends keyof TObj>(obj: TObj, keys: TKeys[]) => { [K in TKeys]: TObj[K] }
         
     | 
| 
       274 
274 
     | 
    
         | 
| 
       275 
275 
     | 
    
         
             
            			/** @returns An array with the elements from `array` in a random order. */ shuffle: <T>(array: T[]) => T[]
         
     | 
| 
       276 
276 
     | 
    
         | 
| 
         @@ -298,7 +298,7 @@ type Fullsec = Subscripts & PlayerFullsec & { 
     | 
|
| 
       298 
298 
     | 
    
         
             
            			security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
         
     | 
| 
       299 
299 
     | 
    
         | 
| 
       300 
300 
     | 
    
         
             
            			/** @returns The string name of a numeric security level. */
         
     | 
| 
       301 
     | 
    
         
            -
            			get_security_level_name: (security_level: number) =>  
     | 
| 
      
 301 
     | 
    
         
            +
            			get_security_level_name: (security_level: number) => string
         
     | 
| 
       302 
302 
     | 
    
         | 
| 
       303 
303 
     | 
    
         
             
            			/** @param result The return value of a call to `$db.i()` or `$db.r()`.
         
     | 
| 
       304 
304 
     | 
    
         
             
            			  * @param nModified The expected value of `result.nModified`.
         
     | 
| 
         @@ -699,7 +699,7 @@ type Nullsec = Lowsec & PlayerNullsec & { 
     | 
|
| 
       699 
699 
     | 
    
         
             
            // database
         
     | 
| 
       700 
700 
     | 
    
         
             
            type MongoPrimitive = null | boolean | number | Date | string
         
     | 
| 
       701 
701 
     | 
    
         
             
            type MongoValue = MongoPrimitive | MongoValue[] | MongoObject
         
     | 
| 
       702 
     | 
    
         
            -
            type MongoObject = { [k: string]: MongoValue 
     | 
| 
      
 702 
     | 
    
         
            +
            type MongoObject = { [k: string]: MongoValue }
         
     | 
| 
       703 
703 
     | 
    
         
             
            type MongoQueryValue = MongoPrimitive | MongoQueryValue[] | MongoQueryObject
         
     | 
| 
       704 
704 
     | 
    
         | 
| 
       705 
705 
     | 
    
         
             
            type MongoQueryObject =
         
     | 
| 
         @@ -710,7 +710,7 @@ type MongoTypeStringsToTypes = { 
     | 
|
| 
       710 
710 
     | 
    
         
             
            	string: string
         
     | 
| 
       711 
711 
     | 
    
         
             
            	object: MongoObject
         
     | 
| 
       712 
712 
     | 
    
         
             
            	array: MongoValue[]
         
     | 
| 
       713 
     | 
    
         
            -
            	objectId:  
     | 
| 
      
 713 
     | 
    
         
            +
            	objectId: MongoObjectId
         
     | 
| 
       714 
714 
     | 
    
         
             
            	bool: boolean
         
     | 
| 
       715 
715 
     | 
    
         
             
            	date: Date
         
     | 
| 
       716 
716 
     | 
    
         
             
            	null: null
         
     | 
| 
         @@ -720,8 +720,8 @@ type MongoTypeStringsToTypes = { 
     | 
|
| 
       720 
720 
     | 
    
         | 
| 
       721 
721 
     | 
    
         
             
            type MongoTypeString = keyof MongoTypeStringsToTypes
         
     | 
| 
       722 
722 
     | 
    
         
             
            type MongoTypeNumber = -1 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 16 | 17 | 18 | 19 | 127
         
     | 
| 
       723 
     | 
    
         
            -
            type MongoId = Exclude<MongoPrimitive, null | false> |  
     | 
| 
       724 
     | 
    
         
            -
            type MongoQueryId = Exclude<MongoPrimitive, null | false> |  
     | 
| 
      
 723 
     | 
    
         
            +
            type MongoId = Exclude<MongoPrimitive, null | false> | MongoObjectId | MongoObject
         
     | 
| 
      
 724 
     | 
    
         
            +
            type MongoQueryId = Exclude<MongoPrimitive, null | false> | MongoObjectId | MongoQueryObject
         
     | 
| 
       725 
725 
     | 
    
         
             
            type MongoDocument = MongoObject & { _id?: MongoId }
         
     | 
| 
       726 
726 
     | 
    
         | 
| 
       727 
727 
     | 
    
         
             
            type MongoQueryType<TQuery extends MongoQueryObject> = {
         
     | 
| 
         @@ -755,11 +755,16 @@ type MongoQuerySelector<T extends MongoValue> = Partial< 
     | 
|
| 
       755 
755 
     | 
    
         | 
| 
       756 
756 
     | 
    
         
             
            type MongoQuery<T extends MongoObject> = { [K in keyof T]?: T[K] | MongoQuerySelector<T[K]> } & { _id?: MongoId }
         
     | 
| 
       757 
757 
     | 
    
         | 
| 
       758 
     | 
    
         
            -
            type  
     | 
| 
      
 758 
     | 
    
         
            +
            type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
         
     | 
| 
      
 759 
     | 
    
         
            +
             
     | 
| 
      
 760 
     | 
    
         
            +
            type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
         
     | 
| 
      
 761 
     | 
    
         
            +
            	{ $position?: number, $slice?: number, $sort?: 1 | -1 }
         
     | 
| 
      
 762 
     | 
    
         
            +
             
     | 
| 
      
 763 
     | 
    
         
            +
            type MongoUpdateCommand<T extends MongoObject> = Partial<{
         
     | 
| 
       759 
764 
     | 
    
         
             
            	/* Universal operators */
         
     | 
| 
       760 
     | 
    
         
            -
            	$set: Partial<Record<string 
     | 
| 
       761 
     | 
    
         
            -
            	$setOnInsert: Partial<Record<string 
     | 
| 
       762 
     | 
    
         
            -
            	$unset: Partial<Record<string, "" 
     | 
| 
      
 765 
     | 
    
         
            +
            	$set: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
         
     | 
| 
      
 766 
     | 
    
         
            +
            	$setOnInsert: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
         
     | 
| 
      
 767 
     | 
    
         
            +
            	$unset: Partial<Record<(string & {}) | keyof T, "">>
         
     | 
| 
       763 
768 
     | 
    
         | 
| 
       764 
769 
     | 
    
         
             
            	$rename: Partial<Record<string, string> & { [key in keyof T]: string }>
         
     | 
| 
       765 
770 
     | 
    
         | 
| 
         @@ -792,13 +797,6 @@ type MongoUpdateOperators<T extends MongoObject> = Partial<{ 
     | 
|
| 
       792 
797 
     | 
    
         
             
            	$pullAll: Record<string, MongoCommandValue> & { [K in keyof T as T[K] extends [] ? K : never]?: T[K] }
         
     | 
| 
       793 
798 
     | 
    
         
             
            }>
         
     | 
| 
       794 
799 
     | 
    
         | 
| 
       795 
     | 
    
         
            -
            type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
         
     | 
| 
       796 
     | 
    
         
            -
             
     | 
| 
       797 
     | 
    
         
            -
            type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
         
     | 
| 
       798 
     | 
    
         
            -
            	{ $position?: number, $slice?: number, $sort?: 1 | -1 }
         
     | 
| 
       799 
     | 
    
         
            -
             
     | 
| 
       800 
     | 
    
         
            -
            type MongoUpdateCommand<Schema extends MongoObject> = MongoUpdateOperators<Schema>
         
     | 
| 
       801 
     | 
    
         
            -
             
     | 
| 
       802 
800 
     | 
    
         
             
            type SortOrder = { [key: string]: 1 | -1 | SortOrder }
         
     | 
| 
       803 
801 
     | 
    
         | 
| 
       804 
802 
     | 
    
         
             
            type Cursor<T> = {
         
     | 
| 
         @@ -886,9 +884,9 @@ declare global { 
     | 
|
| 
       886 
884 
     | 
    
         
             
            	type ScriptSuccess<T = unknown> = { ok: true } & T
         
     | 
| 
       887 
885 
     | 
    
         
             
            	type ScriptFailure = { ok: false, msg?: string }
         
     | 
| 
       888 
886 
     | 
    
         
             
            	type ScriptResponse<T = unknown> = ScriptSuccess<T> | ScriptFailure
         
     | 
| 
       889 
     | 
    
         
            -
            	type Scriptor<TArgs  
     | 
| 
      
 887 
     | 
    
         
            +
            	type Scriptor<TArgs = any> = { name: string, call: (args: TArgs) => unknown }
         
     | 
| 
       890 
888 
     | 
    
         
             
            	type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
         
     | 
| 
       891 
     | 
    
         
            -
            	type  
     | 
| 
      
 889 
     | 
    
         
            +
            	type MongoObjectId = { $oid: string }
         
     | 
| 
       892 
890 
     | 
    
         | 
| 
       893 
891 
     | 
    
         
             
            	interface PlayerFullsec {}
         
     | 
| 
       894 
892 
     | 
    
         
             
            	interface PlayerHighsec {}
         
     | 
| 
         @@ -979,7 +977,7 @@ declare global { 
     | 
|
| 
       979 
977 
     | 
    
         
             
            		us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
         
     | 
| 
       980 
978 
     | 
    
         
             
            			{ n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
         
     | 
| 
       981 
979 
     | 
    
         | 
| 
       982 
     | 
    
         
            -
            		ObjectId: () =>  
     | 
| 
      
 980 
     | 
    
         
            +
            		ObjectId: () => MongoObjectId
         
     | 
| 
       983 
981 
     | 
    
         
             
            	}
         
     | 
| 
       984 
982 
     | 
    
         | 
| 
       985 
983 
     | 
    
         
             
            	/** Debug Log.
         
     | 
| 
         @@ -1,6 +1,5 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { basename, resolve } from "path"
         
     | 
| 
       3 
     | 
    
         
            -
            import * as PathPosix from "path/posix"
         
     | 
| 
       4 
3 
     | 
    
         
             
            async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
         
     | 
| 
       5 
4 
     | 
    
         
             
            	const users = new Set()
         
     | 
| 
       6 
5 
     | 
    
         
             
            	if (hackmudPath)
         
     | 
| 
         @@ -11,33 +10,35 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) { 
     | 
|
| 
       11 
10 
     | 
    
         
             
            		allScripts = {},
         
     | 
| 
       12 
11 
     | 
    
         
             
            		allAnyScripts = {}
         
     | 
| 
       13 
12 
     | 
    
         
             
            	await Promise.all(
         
     | 
| 
       14 
     | 
    
         
            -
            		(await readDirectoryWithStats(sourceDirectory)) 
     | 
| 
       15 
     | 
    
         
            -
            			 
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
            					 
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
             
     | 
| 
       24 
     | 
    
         
            -
             
     | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
            					 
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
            							 
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
      
 13 
     | 
    
         
            +
            		(await readDirectoryWithStats(sourceDirectory))
         
     | 
| 
      
 14 
     | 
    
         
            +
            			.filter(({ stats, name }) => !stats.isDirectory() || /^[a-z_][a-z\d_]{0,24}$/.test(name))
         
     | 
| 
      
 15 
     | 
    
         
            +
            			.map(async ({ stats, name }) => {
         
     | 
| 
      
 16 
     | 
    
         
            +
            				if (stats.isFile())
         
     | 
| 
      
 17 
     | 
    
         
            +
            					name.endsWith(".ts")
         
     | 
| 
      
 18 
     | 
    
         
            +
            						? name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
         
     | 
| 
      
 19 
     | 
    
         
            +
            						: name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
         
     | 
| 
      
 20 
     | 
    
         
            +
            				else if (stats.isDirectory()) {
         
     | 
| 
      
 21 
     | 
    
         
            +
            					const scripts = [],
         
     | 
| 
      
 22 
     | 
    
         
            +
            						anyScripts = []
         
     | 
| 
      
 23 
     | 
    
         
            +
            					allScripts[name] = scripts
         
     | 
| 
      
 24 
     | 
    
         
            +
            					allAnyScripts[name] = anyScripts
         
     | 
| 
      
 25 
     | 
    
         
            +
            					users.add(name)
         
     | 
| 
      
 26 
     | 
    
         
            +
            					for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
         
     | 
| 
      
 27 
     | 
    
         
            +
            						child.stats.isFile() &&
         
     | 
| 
      
 28 
     | 
    
         
            +
            							(child.name.endsWith(".ts")
         
     | 
| 
      
 29 
     | 
    
         
            +
            								? name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
         
     | 
| 
      
 30 
     | 
    
         
            +
            								: child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
         
     | 
| 
      
 31 
     | 
    
         
            +
            				}
         
     | 
| 
      
 32 
     | 
    
         
            +
            			})
         
     | 
| 
       32 
33 
     | 
    
         
             
            	)
         
     | 
| 
       33 
     | 
    
         
            -
            	sourceDirectory = PathPosix.resolve(sourceDirectory)
         
     | 
| 
       34 
34 
     | 
    
         
             
            	let o = ""
         
     | 
| 
       35 
     | 
    
         
            -
            	for (const script of wildScripts) 
     | 
| 
      
 35 
     | 
    
         
            +
            	for (const script of wildScripts)
         
     | 
| 
      
 36 
     | 
    
         
            +
            		o += `type $${script}$ = typeof import(${JSON.stringify(resolve(sourceDirectory, script))}).default\n`
         
     | 
| 
       36 
37 
     | 
    
         
             
            	o += "\n"
         
     | 
| 
       37 
38 
     | 
    
         
             
            	for (const user in allScripts) {
         
     | 
| 
       38 
39 
     | 
    
         
             
            		const scripts = allScripts[user]
         
     | 
| 
       39 
40 
     | 
    
         
             
            		for (const script of scripts)
         
     | 
| 
       40 
     | 
    
         
            -
            			o += `type $${user}$${script}$ = typeof import( 
     | 
| 
      
 41 
     | 
    
         
            +
            			o += `type $${user}$${script}$ = typeof import(${JSON.stringify(resolve(sourceDirectory, user, script))}).default\n`
         
     | 
| 
       41 
42 
     | 
    
         
             
            	}
         
     | 
| 
       42 
43 
     | 
    
         
             
            	o +=
         
     | 
| 
       43 
44 
     | 
    
         
             
            		"\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"
         
     | 
    
        package/index.js
    CHANGED
    
    | 
         @@ -7,7 +7,6 @@ export { syncMacros } from "./syncMacros.js" 
     | 
|
| 
       7 
7 
     | 
    
         
             
            export { watch } from "./watch.js"
         
     | 
| 
       8 
8 
     | 
    
         
             
            import "@samual/lib/readDirectoryWithStats"
         
     | 
| 
       9 
9 
     | 
    
         
             
            import "path"
         
     | 
| 
       10 
     | 
    
         
            -
            import "path/posix"
         
     | 
| 
       11 
10 
     | 
    
         
             
            import "@babel/generator"
         
     | 
| 
       12 
11 
     | 
    
         
             
            import "@babel/parser"
         
     | 
| 
       13 
12 
     | 
    
         
             
            import "@babel/plugin-proposal-decorators"
         
     | 
    
        package/package.json
    CHANGED
    
    | 
         @@ -1,6 +1,6 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            {
         
     | 
| 
       2 
2 
     | 
    
         
             
              "name": "hackmud-script-manager",
         
     | 
| 
       3 
     | 
    
         
            -
              "version": "0.21.1- 
     | 
| 
      
 3 
     | 
    
         
            +
              "version": "0.21.1-ae53eb7",
         
     | 
| 
       4 
4 
     | 
    
         
             
              "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
         
     | 
| 
       5 
5 
     | 
    
         
             
              "keywords": [
         
     | 
| 
       6 
6 
     | 
    
         
             
                "api",
         
     | 
| 
         @@ -23,7 +23,9 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
              "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
         
     | 
| 
       24 
24 
     | 
    
         
             
              "contributors": [
         
     | 
| 
       25 
25 
     | 
    
         
             
                "Daniel Swann (https://github.com/danswann)",
         
     | 
| 
       26 
     | 
    
         
            -
                "Longboyy"
         
     | 
| 
      
 26 
     | 
    
         
            +
                "Longboyy",
         
     | 
| 
      
 27 
     | 
    
         
            +
                "Helloman892",
         
     | 
| 
      
 28 
     | 
    
         
            +
                "Sarah Klocke (https://sarahisweird.dev/)"
         
     | 
| 
       27 
29 
     | 
    
         
             
              ],
         
     | 
| 
       28 
30 
     | 
    
         
             
              "main": "index.js",
         
     | 
| 
       29 
31 
     | 
    
         
             
              "repository": {
         
     | 
    
        package/processScript/index.js
    CHANGED
    
    | 
         @@ -1,4 +1,4 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import  
     | 
| 
      
 1 
     | 
    
         
            +
            import generate from "@babel/generator"
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { parse } from "@babel/parser"
         
     | 
| 
       3 
3 
     | 
    
         
             
            import babelPluginProposalDecorators from "@babel/plugin-proposal-decorators"
         
     | 
| 
       4 
4 
     | 
    
         
             
            import babelPluginProposalDestructuringPrivate from "@babel/plugin-proposal-destructuring-private"
         
     | 
| 
         @@ -15,7 +15,7 @@ import babelPluginTransformOptionalCatchBinding from "@babel/plugin-transform-op 
     | 
|
| 
       15 
15 
     | 
    
         
             
            import babelPluginTransformOptionalChaining from "@babel/plugin-transform-optional-chaining"
         
     | 
| 
       16 
16 
     | 
    
         
             
            import babelPluginTransformPrivatePropertyInObject from "@babel/plugin-transform-private-property-in-object"
         
     | 
| 
       17 
17 
     | 
    
         
             
            import babelPluginTransformUnicodeSetsRegex from "@babel/plugin-transform-unicode-sets-regex"
         
     | 
| 
       18 
     | 
    
         
            -
            import  
     | 
| 
      
 18 
     | 
    
         
            +
            import traverse from "@babel/traverse"
         
     | 
| 
       19 
19 
     | 
    
         
             
            import t from "@babel/types"
         
     | 
| 
       20 
20 
     | 
    
         
             
            import rollupPluginAlias from "@rollup/plugin-alias"
         
     | 
| 
       21 
21 
     | 
    
         
             
            import { babel } from "@rollup/plugin-babel"
         
     | 
| 
         @@ -23,7 +23,7 @@ import rollupPluginCommonJS from "@rollup/plugin-commonjs" 
     | 
|
| 
       23 
23 
     | 
    
         
             
            import rollupPluginJSON from "@rollup/plugin-json"
         
     | 
| 
       24 
24 
     | 
    
         
             
            import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
         
     | 
| 
       25 
25 
     | 
    
         
             
            import { assert } from "@samual/lib/assert"
         
     | 
| 
       26 
     | 
    
         
            -
            import { relative } from "path"
         
     | 
| 
      
 26 
     | 
    
         
            +
            import { relative, isAbsolute, sep } from "path"
         
     | 
| 
       27 
27 
     | 
    
         
             
            import prettier from "prettier"
         
     | 
| 
       28 
28 
     | 
    
         
             
            import { rollup } from "rollup"
         
     | 
| 
       29 
29 
     | 
    
         
             
            import { supportedExtensions } from "../constants.js"
         
     | 
| 
         @@ -38,9 +38,7 @@ import "acorn" 
     | 
|
| 
       38 
38 
     | 
    
         
             
            import "terser"
         
     | 
| 
       39 
39 
     | 
    
         
             
            import "import-meta-resolve"
         
     | 
| 
       40 
40 
     | 
    
         
             
            import "@samual/lib/clearObject"
         
     | 
| 
       41 
     | 
    
         
            -
            const { format } = prettier 
     | 
| 
       42 
     | 
    
         
            -
            	{ default: generate } = babelGenerator,
         
     | 
| 
       43 
     | 
    
         
            -
            	{ default: traverse } = babelTraverse
         
     | 
| 
      
 41 
     | 
    
         
            +
            const { format } = prettier
         
     | 
| 
       44 
42 
     | 
    
         
             
            async function processScript(
         
     | 
| 
       45 
43 
     | 
    
         
             
            	code,
         
     | 
| 
       46 
44 
     | 
    
         
             
            	{
         
     | 
| 
         @@ -56,7 +54,7 @@ async function processScript( 
     | 
|
| 
       56 
54 
     | 
    
         
             
            		rootFolderPath
         
     | 
| 
       57 
55 
     | 
    
         
             
            	}
         
     | 
| 
       58 
56 
     | 
    
         
             
            ) {
         
     | 
| 
       59 
     | 
    
         
            -
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts: 
     | 
| 
      
 57 
     | 
    
         
            +
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:78:36")
         
     | 
| 
       60 
58 
     | 
    
         
             
            	const sourceCode = code
         
     | 
| 
       61 
59 
     | 
    
         
             
            	let autocomplete, statedSeclevel
         
     | 
| 
       62 
60 
     | 
    
         
             
            	const autocompleteMatch = /^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(code)
         
     | 
| 
         @@ -117,30 +115,30 @@ async function processScript( 
     | 
|
| 
       117 
115 
     | 
    
         
             
            				}
         
     | 
| 
       118 
116 
     | 
    
         
             
            			}
         
     | 
| 
       119 
117 
     | 
    
         
             
            		}
         
     | 
| 
       120 
     | 
    
         
            -
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts: 
     | 
| 
      
 118 
     | 
    
         
            +
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:159:36")
         
     | 
| 
       121 
119 
     | 
    
         
             
            	const plugins = [
         
     | 
| 
       122 
     | 
    
         
            -
            		[babelPluginProposalDecorators 
     | 
| 
       123 
     | 
    
         
            -
            		[babelPluginTransformClassProperties 
     | 
| 
       124 
     | 
    
         
            -
            		[babelPluginTransformClassStaticBlock 
     | 
| 
       125 
     | 
    
         
            -
            		[babelPluginTransformPrivatePropertyInObject 
     | 
| 
       126 
     | 
    
         
            -
            		[babelPluginTransformLogicalAssignmentOperators 
     | 
| 
       127 
     | 
    
         
            -
            		[babelPluginTransformNumericSeparator 
     | 
| 
       128 
     | 
    
         
            -
            		[babelPluginTransformNullishCoalescingOperator 
     | 
| 
       129 
     | 
    
         
            -
            		[babelPluginTransformOptionalChaining 
     | 
| 
       130 
     | 
    
         
            -
            		[babelPluginTransformOptionalCatchBinding 
     | 
| 
       131 
     | 
    
         
            -
            		[babelPluginTransformJsonStrings 
     | 
| 
       132 
     | 
    
         
            -
            		[babelPluginTransformObjectRestSpread 
     | 
| 
       133 
     | 
    
         
            -
            		[babelPluginTransformExponentiationOperator 
     | 
| 
       134 
     | 
    
         
            -
            		[babelPluginTransformUnicodeSetsRegex 
     | 
| 
       135 
     | 
    
         
            -
            		[babelPluginProposalDestructuringPrivate 
     | 
| 
       136 
     | 
    
         
            -
            		[babelPluginProposalExplicitResourceManagement 
     | 
| 
      
 120 
     | 
    
         
            +
            		[babelPluginProposalDecorators, { decoratorsBeforeExport: !0 }],
         
     | 
| 
      
 121 
     | 
    
         
            +
            		[babelPluginTransformClassProperties],
         
     | 
| 
      
 122 
     | 
    
         
            +
            		[babelPluginTransformClassStaticBlock],
         
     | 
| 
      
 123 
     | 
    
         
            +
            		[babelPluginTransformPrivatePropertyInObject],
         
     | 
| 
      
 124 
     | 
    
         
            +
            		[babelPluginTransformLogicalAssignmentOperators],
         
     | 
| 
      
 125 
     | 
    
         
            +
            		[babelPluginTransformNumericSeparator],
         
     | 
| 
      
 126 
     | 
    
         
            +
            		[babelPluginTransformNullishCoalescingOperator],
         
     | 
| 
      
 127 
     | 
    
         
            +
            		[babelPluginTransformOptionalChaining],
         
     | 
| 
      
 128 
     | 
    
         
            +
            		[babelPluginTransformOptionalCatchBinding],
         
     | 
| 
      
 129 
     | 
    
         
            +
            		[babelPluginTransformJsonStrings],
         
     | 
| 
      
 130 
     | 
    
         
            +
            		[babelPluginTransformObjectRestSpread],
         
     | 
| 
      
 131 
     | 
    
         
            +
            		[babelPluginTransformExponentiationOperator],
         
     | 
| 
      
 132 
     | 
    
         
            +
            		[babelPluginTransformUnicodeSetsRegex],
         
     | 
| 
      
 133 
     | 
    
         
            +
            		[babelPluginProposalDestructuringPrivate],
         
     | 
| 
      
 134 
     | 
    
         
            +
            		[babelPluginProposalExplicitResourceManagement]
         
     | 
| 
       137 
135 
     | 
    
         
             
            	]
         
     | 
| 
       138 
136 
     | 
    
         
             
            	let filePathResolved
         
     | 
| 
       139 
137 
     | 
    
         
             
            	if (filePath) {
         
     | 
| 
       140 
138 
     | 
    
         
             
            		filePathResolved = relative(".", filePath)
         
     | 
| 
       141 
139 
     | 
    
         
             
            		if (filePath.endsWith(".ts"))
         
     | 
| 
       142 
140 
     | 
    
         
             
            			plugins.push([
         
     | 
| 
       143 
     | 
    
         
            -
            				 
     | 
| 
      
 141 
     | 
    
         
            +
            				await import("@babel/plugin-transform-typescript"),
         
     | 
| 
       144 
142 
     | 
    
         
             
            				{ allowDeclareFields: !0, optimizeConstEnums: !0 }
         
     | 
| 
       145 
143 
     | 
    
         
             
            			])
         
     | 
| 
       146 
144 
     | 
    
         
             
            		else {
         
     | 
| 
         @@ -162,13 +160,13 @@ async function processScript( 
     | 
|
| 
       162 
160 
     | 
    
         
             
            				import("@babel/plugin-proposal-record-and-tuple")
         
     | 
| 
       163 
161 
     | 
    
         
             
            			])
         
     | 
| 
       164 
162 
     | 
    
         
             
            			plugins.push(
         
     | 
| 
       165 
     | 
    
         
            -
            				[babelPluginProposalDoExpressions 
     | 
| 
       166 
     | 
    
         
            -
            				[babelPluginProposalFunctionBind 
     | 
| 
       167 
     | 
    
         
            -
            				[babelPluginProposalFunctionSent 
     | 
| 
       168 
     | 
    
         
            -
            				[babelPluginProposalPartialApplication 
     | 
| 
       169 
     | 
    
         
            -
            				[babelPluginProposalPipelineOperator 
     | 
| 
       170 
     | 
    
         
            -
            				[babelPluginProposalThrowExpressions 
     | 
| 
       171 
     | 
    
         
            -
            				[babelPluginProposalRecordAndTuple 
     | 
| 
      
 163 
     | 
    
         
            +
            				[babelPluginProposalDoExpressions],
         
     | 
| 
      
 164 
     | 
    
         
            +
            				[babelPluginProposalFunctionBind],
         
     | 
| 
      
 165 
     | 
    
         
            +
            				[babelPluginProposalFunctionSent],
         
     | 
| 
      
 166 
     | 
    
         
            +
            				[babelPluginProposalPartialApplication],
         
     | 
| 
      
 167 
     | 
    
         
            +
            				[babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
         
     | 
| 
      
 168 
     | 
    
         
            +
            				[babelPluginProposalThrowExpressions],
         
     | 
| 
      
 169 
     | 
    
         
            +
            				[babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
         
     | 
| 
       172 
170 
     | 
    
         
             
            			)
         
     | 
| 
       173 
171 
     | 
    
         
             
            		}
         
     | 
| 
       174 
172 
     | 
    
         
             
            	} else {
         
     | 
| 
         @@ -193,14 +191,14 @@ async function processScript( 
     | 
|
| 
       193 
191 
     | 
    
         
             
            			import("@babel/plugin-proposal-record-and-tuple")
         
     | 
| 
       194 
192 
     | 
    
         
             
            		])
         
     | 
| 
       195 
193 
     | 
    
         
             
            		plugins.push(
         
     | 
| 
       196 
     | 
    
         
            -
            			[babelPluginTransformTypescript 
     | 
| 
       197 
     | 
    
         
            -
            			[babelPluginProposalDoExpressions 
     | 
| 
       198 
     | 
    
         
            -
            			[babelPluginProposalFunctionBind 
     | 
| 
       199 
     | 
    
         
            -
            			[babelPluginProposalFunctionSent 
     | 
| 
       200 
     | 
    
         
            -
            			[babelPluginProposalPartialApplication 
     | 
| 
       201 
     | 
    
         
            -
            			[babelPluginProposalPipelineOperator 
     | 
| 
       202 
     | 
    
         
            -
            			[babelPluginProposalThrowExpressions 
     | 
| 
       203 
     | 
    
         
            -
            			[babelPluginProposalRecordAndTuple 
     | 
| 
      
 194 
     | 
    
         
            +
            			[babelPluginTransformTypescript, { allowDeclareFields: !0, optimizeConstEnums: !0 }],
         
     | 
| 
      
 195 
     | 
    
         
            +
            			[babelPluginProposalDoExpressions],
         
     | 
| 
      
 196 
     | 
    
         
            +
            			[babelPluginProposalFunctionBind],
         
     | 
| 
      
 197 
     | 
    
         
            +
            			[babelPluginProposalFunctionSent],
         
     | 
| 
      
 198 
     | 
    
         
            +
            			[babelPluginProposalPartialApplication],
         
     | 
| 
      
 199 
     | 
    
         
            +
            			[babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
         
     | 
| 
      
 200 
     | 
    
         
            +
            			[babelPluginProposalThrowExpressions],
         
     | 
| 
      
 201 
     | 
    
         
            +
            			[babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
         
     | 
| 
       204 
202 
     | 
    
         
             
            		)
         
     | 
| 
       205 
203 
     | 
    
         
             
            	}
         
     | 
| 
       206 
204 
     | 
    
         
             
            	const bundle = await rollup({
         
     | 
| 
         @@ -210,7 +208,8 @@ async function processScript( 
     | 
|
| 
       210 
208 
     | 
    
         
             
            				{
         
     | 
| 
       211 
209 
     | 
    
         
             
            					name: "hackmud-script-manager",
         
     | 
| 
       212 
210 
     | 
    
         
             
            					async transform(code, id) {
         
     | 
| 
       213 
     | 
    
         
            -
            						if (!id.includes( 
     | 
| 
      
 211 
     | 
    
         
            +
            						if (isAbsolute(id) && !id.includes(`${sep}node_modules${sep}`))
         
     | 
| 
      
 212 
     | 
    
         
            +
            							return (await preprocess(code, { uniqueId })).code
         
     | 
| 
       214 
213 
     | 
    
         
             
            						let program
         
     | 
| 
       215 
214 
     | 
    
         
             
            						traverse(parse(code, { sourceType: "module" }), {
         
     | 
| 
       216 
215 
     | 
    
         
             
            							Program(path) {
         
     | 
| 
         @@ -252,7 +251,7 @@ async function processScript( 
     | 
|
| 
       252 
251 
     | 
    
         
             
            		traverse(file, {
         
     | 
| 
       253 
252 
     | 
    
         
             
            			MemberExpression({ node: memberExpression }) {
         
     | 
| 
       254 
253 
     | 
    
         
             
            				if (!memberExpression.computed) {
         
     | 
| 
       255 
     | 
    
         
            -
            					assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts: 
     | 
| 
      
 254 
     | 
    
         
            +
            					assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:323:60")
         
     | 
| 
       256 
255 
     | 
    
         
             
            					if ("prototype" == memberExpression.property.name) {
         
     | 
| 
       257 
256 
     | 
    
         
             
            						memberExpression.computed = !0
         
     | 
| 
       258 
257 
     | 
    
         
             
            						memberExpression.property = t.stringLiteral("prototype")
         
     | 
| 
         @@ -282,7 +281,7 @@ async function processScript( 
     | 
|
| 
       282 
281 
     | 
    
         
             
            							break
         
     | 
| 
       283 
282 
     | 
    
         
             
            						case "ObjectPattern":
         
     | 
| 
       284 
283 
     | 
    
         
             
            							for (const property of lValue.properties) {
         
     | 
| 
       285 
     | 
    
         
            -
            								assert("ObjectProperty" == property.type, "src/processScript/index.ts: 
     | 
| 
      
 284 
     | 
    
         
            +
            								assert("ObjectProperty" == property.type, "src/processScript/index.ts:353:51")
         
     | 
| 
       286 
285 
     | 
    
         
             
            								renameVariables(property.value)
         
     | 
| 
       287 
286 
     | 
    
         
             
            							}
         
     | 
| 
       288 
287 
     | 
    
         
             
            							break
         
     | 
    
        package/processScript/minify.js
    CHANGED
    
    | 
         @@ -1,5 +1,5 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import  
     | 
| 
       2 
     | 
    
         
            -
            import  
     | 
| 
      
 1 
     | 
    
         
            +
            import generate from "@babel/generator"
         
     | 
| 
      
 2 
     | 
    
         
            +
            import traverse from "@babel/traverse"
         
     | 
| 
       3 
3 
     | 
    
         
             
            import t from "@babel/types"
         
     | 
| 
       4 
4 
     | 
    
         
             
            import { assert } from "@samual/lib/assert"
         
     | 
| 
       5 
5 
     | 
    
         
             
            import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
         
     | 
| 
         @@ -7,12 +7,10 @@ import { spliceString } from "@samual/lib/spliceString" 
     | 
|
| 
       7 
7 
     | 
    
         
             
            import { tokenizer, tokTypes } from "acorn"
         
     | 
| 
       8 
8 
     | 
    
         
             
            import * as terser from "terser"
         
     | 
| 
       9 
9 
     | 
    
         
             
            import { getReferencePathsToGlobal, includesIllegalString, replaceUnsafeStrings } from "./shared.js"
         
     | 
| 
       10 
     | 
    
         
            -
            const  
     | 
| 
       11 
     | 
    
         
            -
            	{  
     | 
| 
       12 
     | 
    
         
            -
            	minifyNumber = async number =>
         
     | 
| 
       13 
     | 
    
         
            -
            		/\$\((?<number>.+)\)/.exec((await terser.minify(`$(${number})`, { ecma: 2015 })).code).groups.number
         
     | 
| 
      
 10 
     | 
    
         
            +
            const minifyNumber = async number =>
         
     | 
| 
      
 11 
     | 
    
         
            +
            	/\$\((?<number>.+)\)/.exec((await terser.minify(`$(${number})`, { ecma: 2015 })).code).groups.number
         
     | 
| 
       14 
12 
     | 
    
         
             
            async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQuineCheats, autocomplete } = {}) {
         
     | 
| 
       15 
     | 
    
         
            -
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts: 
     | 
| 
      
 13 
     | 
    
         
            +
            	assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts:41:36")
         
     | 
| 
       16 
14 
     | 
    
         
             
            	let program
         
     | 
| 
       17 
15 
     | 
    
         
             
            	traverse(file, {
         
     | 
| 
       18 
16 
     | 
    
         
             
            		Program(path) {
         
     | 
| 
         @@ -52,7 +50,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ 
     | 
|
| 
       52 
50 
     | 
    
         
             
            		traverse(fileBeforeJSONValueReplacement, {
         
     | 
| 
       53 
51 
     | 
    
         
             
            			MemberExpression({ node: memberExpression }) {
         
     | 
| 
       54 
52 
     | 
    
         
             
            				if (!memberExpression.computed) {
         
     | 
| 
       55 
     | 
    
         
            -
            					assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts: 
     | 
| 
      
 53 
     | 
    
         
            +
            					assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:110:60")
         
     | 
| 
       56 
54 
     | 
    
         
             
            					if ("prototype" == memberExpression.property.name) {
         
     | 
| 
       57 
55 
     | 
    
         
             
            						memberExpression.computed = !0
         
     | 
| 
       58 
56 
     | 
    
         
             
            						memberExpression.property = t.identifier(`_${uniqueId}_PROTOTYPE_PROPERTY_`)
         
     | 
| 
         @@ -164,7 +162,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ 
     | 
|
| 
       164 
162 
     | 
    
         
             
            					},
         
     | 
| 
       165 
163 
     | 
    
         
             
            					MemberExpression({ node: memberExpression }) {
         
     | 
| 
       166 
164 
     | 
    
         
             
            						if (!memberExpression.computed) {
         
     | 
| 
       167 
     | 
    
         
            -
            							assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts: 
     | 
| 
      
 165 
     | 
    
         
            +
            							assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:244:62")
         
     | 
| 
       168 
166 
     | 
    
         
             
            							if (!(memberExpression.property.name.length < 3)) {
         
     | 
| 
       169 
167 
     | 
    
         
             
            								memberExpression.computed = !0
         
     | 
| 
       170 
168 
     | 
    
         
             
            								memberExpression.property = t.stringLiteral(memberExpression.property.name)
         
     | 
| 
         @@ -238,7 +236,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ 
     | 
|
| 
       238 
236 
     | 
    
         
             
            		})
         
     | 
| 
       239 
237 
     | 
    
         
             
            		await Promise.all(promises)
         
     | 
| 
       240 
238 
     | 
    
         
             
            		const functionDeclaration = file.program.body[0]
         
     | 
| 
       241 
     | 
    
         
            -
            		assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts: 
     | 
| 
      
 239 
     | 
    
         
            +
            		assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:349:61")
         
     | 
| 
       242 
240 
     | 
    
         
             
            		if (jsonValues.length) {
         
     | 
| 
       243 
241 
     | 
    
         
             
            			hasComment = !0
         
     | 
| 
       244 
242 
     | 
    
         
             
            			if (1 == jsonValues.length)
         
     | 
| 
         @@ -358,7 +356,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ 
     | 
|
| 
       358 
356 
     | 
    
         
             
            		)
         
     | 
| 
       359 
357 
     | 
    
         
             
            	}
         
     | 
| 
       360 
358 
     | 
    
         
             
            	if (1 == forceQuineCheats) return code
         
     | 
| 
       361 
     | 
    
         
            -
            	assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts: 
     | 
| 
      
 359 
     | 
    
         
            +
            	assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:480:43")
         
     | 
| 
       362 
360 
     | 
    
         
             
            	return countHackmudCharacters(scriptBeforeJSONValueReplacement) <= countHackmudCharacters(code) + Number(hasComment)
         
     | 
| 
       363 
361 
     | 
    
         
             
            		? scriptBeforeJSONValueReplacement
         
     | 
| 
       364 
362 
     | 
    
         
             
            		: code
         
     | 
| 
         @@ -371,7 +369,7 @@ function parseObjectExpression(node, o) { 
     | 
|
| 
       371 
369 
     | 
    
         
             
            			"Identifier" == property.key.type ||
         
     | 
| 
       372 
370 
     | 
    
         
             
            				"NumericLiteral" == property.key.type ||
         
     | 
| 
       373 
371 
     | 
    
         
             
            				"StringLiteral" == property.key.type,
         
     | 
| 
       374 
     | 
    
         
            -
            			"src/processScript/minify.ts: 
     | 
| 
      
 372 
     | 
    
         
            +
            			"src/processScript/minify.ts:502:4"
         
     | 
| 
       375 
373 
     | 
    
         
             
            		)
         
     | 
| 
       376 
374 
     | 
    
         
             
            		if ("ArrayExpression" == property.value.type) {
         
     | 
| 
       377 
375 
     | 
    
         
             
            			const childArray = []
         
     | 
| 
         @@ -1,14 +1,12 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import  
     | 
| 
      
 1 
     | 
    
         
            +
            import generate from "@babel/generator"
         
     | 
| 
       2 
2 
     | 
    
         
             
            import { parse } from "@babel/parser"
         
     | 
| 
       3 
     | 
    
         
            -
            import  
     | 
| 
      
 3 
     | 
    
         
            +
            import traverse from "@babel/traverse"
         
     | 
| 
       4 
4 
     | 
    
         
             
            import t from "@babel/types"
         
     | 
| 
       5 
5 
     | 
    
         
             
            import { assert } from "@samual/lib/assert"
         
     | 
| 
       6 
6 
     | 
    
         
             
            import { spliceString } from "@samual/lib/spliceString"
         
     | 
| 
       7 
7 
     | 
    
         
             
            import { resolve } from "import-meta-resolve"
         
     | 
| 
       8 
     | 
    
         
            -
            const { default: traverse } = babelTraverse,
         
     | 
| 
       9 
     | 
    
         
            -
            	{ default: generate } = babelGenerator
         
     | 
| 
       10 
8 
     | 
    
         
             
            async function preprocess(code, { uniqueId = "00000000000" } = {}) {
         
     | 
| 
       11 
     | 
    
         
            -
            	assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts: 
     | 
| 
      
 9 
     | 
    
         
            +
            	assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:18:36")
         
     | 
| 
       12 
10 
     | 
    
         
             
            	const sourceCode = code
         
     | 
| 
       13 
11 
     | 
    
         
             
            	let lengthBefore, file, program
         
     | 
| 
       14 
12 
     | 
    
         
             
            	do {
         
     | 
| 
         @@ -47,7 +45,7 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) { 
     | 
|
| 
       47 
45 
     | 
    
         
             
            			})
         
     | 
| 
       48 
46 
     | 
    
         
             
            			break
         
     | 
| 
       49 
47 
     | 
    
         
             
            		} catch (error_) {
         
     | 
| 
       50 
     | 
    
         
            -
            			assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts: 
     | 
| 
      
 48 
     | 
    
         
            +
            			assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:62:42")
         
     | 
| 
       51 
49 
     | 
    
         
             
            			error = error_
         
     | 
| 
       52 
50 
     | 
    
         
             
            		}
         
     | 
| 
       53 
51 
     | 
    
         
             
            		if ("BABEL_PARSER_SYNTAX_ERROR" != error.code || "PrivateInExpectedIn" != error.reasonCode) {
         
     | 
| 
         @@ -1,26 +1,25 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            import  
     | 
| 
      
 1 
     | 
    
         
            +
            import traverse from "@babel/traverse"
         
     | 
| 
       2 
2 
     | 
    
         
             
            import t from "@babel/types"
         
     | 
| 
       3 
3 
     | 
    
         
             
            import { assert } from "@samual/lib/assert"
         
     | 
| 
       4 
4 
     | 
    
         
             
            import { clearObject } from "@samual/lib/clearObject"
         
     | 
| 
       5 
5 
     | 
    
         
             
            import { validDBMethods } from "../constants.js"
         
     | 
| 
       6 
6 
     | 
    
         
             
            import { getReferencePathsToGlobal } from "./shared.js"
         
     | 
| 
       7 
     | 
    
         
            -
            const  
     | 
| 
       8 
     | 
    
         
            -
            	 
     | 
| 
       9 
     | 
    
         
            -
             
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
             
     | 
| 
       12 
     | 
    
         
            -
             
     | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
       14 
     | 
    
         
            -
             
     | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
       16 
     | 
    
         
            -
             
     | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
       18 
     | 
    
         
            -
             
     | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
       20 
     | 
    
         
            -
             
     | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
       22 
     | 
    
         
            -
             
     | 
| 
       23 
     | 
    
         
            -
            	]
         
     | 
| 
      
 7 
     | 
    
         
            +
            const globalFunctionsUnder7Characters = [
         
     | 
| 
      
 8 
     | 
    
         
            +
            	"Map",
         
     | 
| 
      
 9 
     | 
    
         
            +
            	"Set",
         
     | 
| 
      
 10 
     | 
    
         
            +
            	"Date",
         
     | 
| 
      
 11 
     | 
    
         
            +
            	"JSON",
         
     | 
| 
      
 12 
     | 
    
         
            +
            	"Math",
         
     | 
| 
      
 13 
     | 
    
         
            +
            	"Array",
         
     | 
| 
      
 14 
     | 
    
         
            +
            	"Error",
         
     | 
| 
      
 15 
     | 
    
         
            +
            	"isNaN",
         
     | 
| 
      
 16 
     | 
    
         
            +
            	"Number",
         
     | 
| 
      
 17 
     | 
    
         
            +
            	"Object",
         
     | 
| 
      
 18 
     | 
    
         
            +
            	"RegExp",
         
     | 
| 
      
 19 
     | 
    
         
            +
            	"String",
         
     | 
| 
      
 20 
     | 
    
         
            +
            	"Symbol",
         
     | 
| 
      
 21 
     | 
    
         
            +
            	"BigInt"
         
     | 
| 
      
 22 
     | 
    
         
            +
            ]
         
     | 
| 
       24 
23 
     | 
    
         
             
            function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scriptName, seclevel = 4 }) {
         
     | 
| 
       25 
24 
     | 
    
         
             
            	const warnings = [],
         
     | 
| 
       26 
25 
     | 
    
         
             
            		topFunctionName = `_${uniqueId}_SCRIPT_`
         
     | 
| 
         @@ -77,30 +76,30 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       77 
76 
     | 
    
         
             
            			const referencePath = FunctionReferencePaths[0]
         
     | 
| 
       78 
77 
     | 
    
         
             
            			assert(
         
     | 
| 
       79 
78 
     | 
    
         
             
            				"MemberExpression" == referencePath.parent.type,
         
     | 
| 
       80 
     | 
    
         
            -
            				"src/processScript/transform.ts: 
     | 
| 
      
 79 
     | 
    
         
            +
            				"src/processScript/transform.ts:108:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       81 
80 
     | 
    
         
             
            			)
         
     | 
| 
       82 
81 
     | 
    
         
             
            			assert(
         
     | 
| 
       83 
82 
     | 
    
         
             
            				"Identifier" == referencePath.parent.property.type,
         
     | 
| 
       84 
     | 
    
         
            -
            				"src/processScript/transform.ts: 
     | 
| 
      
 83 
     | 
    
         
            +
            				"src/processScript/transform.ts:113:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       85 
84 
     | 
    
         
             
            			)
         
     | 
| 
       86 
85 
     | 
    
         
             
            			assert(
         
     | 
| 
       87 
86 
     | 
    
         
             
            				"prototype" == referencePath.parent.property.name,
         
     | 
| 
       88 
     | 
    
         
            -
            				"src/processScript/transform.ts: 
     | 
| 
      
 87 
     | 
    
         
            +
            				"src/processScript/transform.ts:118:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       89 
88 
     | 
    
         
             
            			)
         
     | 
| 
       90 
89 
     | 
    
         
             
            			referencePath.parentPath.replaceWith(createGetFunctionPrototypeNode())
         
     | 
| 
       91 
90 
     | 
    
         
             
            		} else {
         
     | 
| 
       92 
91 
     | 
    
         
             
            			for (const referencePath of FunctionReferencePaths) {
         
     | 
| 
       93 
92 
     | 
    
         
             
            				assert(
         
     | 
| 
       94 
93 
     | 
    
         
             
            					"MemberExpression" == referencePath.parent.type,
         
     | 
| 
       95 
     | 
    
         
            -
            					"src/processScript/transform.ts: 
     | 
| 
      
 94 
     | 
    
         
            +
            					"src/processScript/transform.ts:126:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       96 
95 
     | 
    
         
             
            				)
         
     | 
| 
       97 
96 
     | 
    
         
             
            				assert(
         
     | 
| 
       98 
97 
     | 
    
         
             
            					"Identifier" == referencePath.parent.property.type,
         
     | 
| 
       99 
     | 
    
         
            -
            					"src/processScript/transform.ts: 
     | 
| 
      
 98 
     | 
    
         
            +
            					"src/processScript/transform.ts:131:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       100 
99 
     | 
    
         
             
            				)
         
     | 
| 
       101 
100 
     | 
    
         
             
            				assert(
         
     | 
| 
       102 
101 
     | 
    
         
             
            					"prototype" == referencePath.parent.property.name,
         
     | 
| 
       103 
     | 
    
         
            -
            					"src/processScript/transform.ts: 
     | 
| 
      
 102 
     | 
    
         
            +
            					"src/processScript/transform.ts:136:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
         
     | 
| 
       104 
103 
     | 
    
         
             
            				)
         
     | 
| 
       105 
104 
     | 
    
         
             
            				functionDotPrototypeIsReferencedMultipleTimes = !0
         
     | 
| 
       106 
105 
     | 
    
         
             
            				referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_FUNCTION_DOT_PROTOTYPE_`))
         
     | 
| 
         @@ -141,12 +140,12 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       141 
140 
     | 
    
         
             
            	const neededDbMethodLets = new Set()
         
     | 
| 
       142 
141 
     | 
    
         
             
            	if (program.scope.hasGlobal("$db"))
         
     | 
| 
       143 
142 
     | 
    
         
             
            		for (const referencePath of getReferencePathsToGlobal("$db", program)) {
         
     | 
| 
       144 
     | 
    
         
            -
            			assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts: 
     | 
| 
       145 
     | 
    
         
            -
            			assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts: 
     | 
| 
      
 143 
     | 
    
         
            +
            			assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts:196:69")
         
     | 
| 
      
 144 
     | 
    
         
            +
            			assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:197:72")
         
     | 
| 
       146 
145 
     | 
    
         
             
            			const databaseOpMethodName = referencePath.parentPath.node.property.name
         
     | 
| 
       147 
146 
     | 
    
         
             
            			assert(
         
     | 
| 
       148 
147 
     | 
    
         
             
            				validDBMethods.includes(databaseOpMethodName),
         
     | 
| 
       149 
     | 
    
         
            -
            				`src/processScript/transform.ts: 
     | 
| 
      
 148 
     | 
    
         
            +
            				`src/processScript/transform.ts:203:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
         
     | 
| 
       150 
149 
     | 
    
         
             
            			)
         
     | 
| 
       151 
150 
     | 
    
         
             
            			if ("CallExpression" == referencePath.parentPath.parentPath?.type)
         
     | 
| 
       152 
151 
     | 
    
         
             
            				referencePath.parentPath.replaceWith(t.identifier(`$${uniqueId}$DB$${databaseOpMethodName}$`))
         
     | 
| 
         @@ -181,7 +180,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       181 
180 
     | 
    
         
             
            	if (program.scope.hasGlobal("Object"))
         
     | 
| 
       182 
181 
     | 
    
         
             
            		for (const referencePath of getReferencePathsToGlobal("Object", program))
         
     | 
| 
       183 
182 
     | 
    
         
             
            			if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
         
     | 
| 
       184 
     | 
    
         
            -
            				assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts: 
     | 
| 
      
 183 
     | 
    
         
            +
            				assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:253:64")
         
     | 
| 
       185 
184 
     | 
    
         
             
            				if ("getPrototypeOf" == referencePath.parent.property.name) {
         
     | 
| 
       186 
185 
     | 
    
         
             
            					referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_GET_PROTOTYPE_OF_`))
         
     | 
| 
       187 
186 
     | 
    
         
             
            					needGetPrototypeOf = !0
         
     | 
| 
         @@ -194,7 +193,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       194 
193 
     | 
    
         
             
            	if (program.scope.hasGlobal("console"))
         
     | 
| 
       195 
194 
     | 
    
         
             
            		for (const referencePath of getReferencePathsToGlobal("console", program))
         
     | 
| 
       196 
195 
     | 
    
         
             
            			if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
         
     | 
| 
       197 
     | 
    
         
            -
            				assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts: 
     | 
| 
      
 196 
     | 
    
         
            +
            				assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:271:64")
         
     | 
| 
       198 
197 
     | 
    
         
             
            				referencePath.parentPath.replaceWith(
         
     | 
| 
       199 
198 
     | 
    
         
             
            					t.identifier(`_${uniqueId}_CONSOLE_METHOD_${referencePath.parent.property.name}_`)
         
     | 
| 
       200 
199 
     | 
    
         
             
            				)
         
     | 
| 
         @@ -202,13 +201,13 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       202 
201 
     | 
    
         
             
            			}
         
     | 
| 
       203 
202 
     | 
    
         
             
            	const lastStatement = program.node.body.at(-1)
         
     | 
| 
       204 
203 
     | 
    
         
             
            	let exportDefaultName
         
     | 
| 
       205 
     | 
    
         
            -
            	assert(lastStatement, "src/processScript/transform.ts: 
     | 
| 
      
 204 
     | 
    
         
            +
            	assert(lastStatement, "src/processScript/transform.ts:285:27 program is empty")
         
     | 
| 
       206 
205 
     | 
    
         
             
            	if ("ExportNamedDeclaration" == lastStatement.type) {
         
     | 
| 
       207 
206 
     | 
    
         
             
            		program.node.body.pop()
         
     | 
| 
       208 
207 
     | 
    
         
             
            		for (const specifier of lastStatement.specifiers) {
         
     | 
| 
       209 
208 
     | 
    
         
             
            			assert(
         
     | 
| 
       210 
209 
     | 
    
         
             
            				"ExportSpecifier" == specifier.type,
         
     | 
| 
       211 
     | 
    
         
            -
            				`src/processScript/transform.ts: 
     | 
| 
      
 210 
     | 
    
         
            +
            				`src/processScript/transform.ts:291:51 ${specifier.type} is currently unsupported`
         
     | 
| 
       212 
211 
     | 
    
         
             
            			)
         
     | 
| 
       213 
212 
     | 
    
         
             
            			if (
         
     | 
| 
       214 
213 
     | 
    
         
             
            				"default" !=
         
     | 
| 
         @@ -310,11 +309,11 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       310 
309 
     | 
    
         
             
            		let hoistedGlobalBlockFunctions = 0
         
     | 
| 
       311 
310 
     | 
    
         
             
            		for (const [globalBlockIndex, globalBlockStatement] of [...globalBlock.body.entries()].reverse())
         
     | 
| 
       312 
311 
     | 
    
         
             
            			if ("VariableDeclaration" == globalBlockStatement.type) {
         
     | 
| 
       313 
     | 
    
         
            -
            				assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts: 
     | 
| 
      
 312 
     | 
    
         
            +
            				assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:405:59")
         
     | 
| 
       314 
313 
     | 
    
         
             
            				const declarator = globalBlockStatement.declarations[0]
         
     | 
| 
       315 
314 
     | 
    
         
             
            				assert(
         
     | 
| 
       316 
315 
     | 
    
         
             
            					"Identifier" == declarator.id.type,
         
     | 
| 
       317 
     | 
    
         
            -
            					`src/processScript/transform.ts: 
     | 
| 
      
 316 
     | 
    
         
            +
            					`src/processScript/transform.ts:409:51 declarator.id.type was "${declarator.id.type}"`
         
     | 
| 
       318 
317 
     | 
    
         
             
            				)
         
     | 
| 
       319 
318 
     | 
    
         
             
            				program.scope.crawl()
         
     | 
| 
       320 
319 
     | 
    
         
             
            				if (program.scope.hasGlobal(declarator.id.name)) {
         
     | 
| 
         @@ -329,9 +328,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       329 
328 
     | 
    
         
             
            						Object.keys(program.scope.globals).some(global => globalBlockVariables.has(global))
         
     | 
| 
       330 
329 
     | 
    
         
             
            					) {
         
     | 
| 
       331 
330 
     | 
    
         
             
            						const binding = program.scope.getBinding(declarator.id.name)
         
     | 
| 
       332 
     | 
    
         
            -
            						assert(binding, "src/processScript/transform.ts: 
     | 
| 
      
 331 
     | 
    
         
            +
            						assert(binding, "src/processScript/transform.ts:428:23")
         
     | 
| 
       333 
332 
     | 
    
         
             
            						for (const referencePath of binding.referencePaths) {
         
     | 
| 
       334 
     | 
    
         
            -
            							assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts: 
     | 
| 
      
 333 
     | 
    
         
            +
            							assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:431:56")
         
     | 
| 
       335 
334 
     | 
    
         
             
            							referencePath.replaceWith(
         
     | 
| 
       336 
335 
     | 
    
         
             
            								t.memberExpression(
         
     | 
| 
       337 
336 
     | 
    
         
             
            									t.identifier(`_${uniqueId}_G_`),
         
     | 
| 
         @@ -379,16 +378,16 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       379 
378 
     | 
    
         
             
            				} else globalBlockVariables.add(declarator.id.name)
         
     | 
| 
       380 
379 
     | 
    
         
             
            			} else if ("ClassDeclaration" == globalBlockStatement.type) {
         
     | 
| 
       381 
380 
     | 
    
         
             
            				program.scope.crawl()
         
     | 
| 
       382 
     | 
    
         
            -
            				assert(globalBlockStatement.id, "src/processScript/transform.ts: 
     | 
| 
      
 381 
     | 
    
         
            +
            				assert(globalBlockStatement.id, "src/processScript/transform.ts:488:37")
         
     | 
| 
       383 
382 
     | 
    
         
             
            				if (program.scope.hasGlobal(globalBlockStatement.id.name)) {
         
     | 
| 
       384 
383 
     | 
    
         
             
            					globalBlock.body.splice(globalBlockIndex, 1)
         
     | 
| 
       385 
384 
     | 
    
         
             
            					const [globalBlockPath] = program.unshiftContainer("body", globalBlock),
         
     | 
| 
       386 
385 
     | 
    
         
             
            						[globalBlockStatementPath] = program.unshiftContainer("body", globalBlockStatement)
         
     | 
| 
       387 
386 
     | 
    
         
             
            					program.scope.crawl()
         
     | 
| 
       388 
387 
     | 
    
         
             
            					const binding = program.scope.getBinding(globalBlockStatement.id.name)
         
     | 
| 
       389 
     | 
    
         
            -
            					assert(binding, "src/processScript/transform.ts: 
     | 
| 
      
 388 
     | 
    
         
            +
            					assert(binding, "src/processScript/transform.ts:500:22")
         
     | 
| 
       390 
389 
     | 
    
         
             
            					for (const referencePath of binding.referencePaths) {
         
     | 
| 
       391 
     | 
    
         
            -
            						assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts: 
     | 
| 
      
 390 
     | 
    
         
            +
            						assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:503:55")
         
     | 
| 
       392 
391 
     | 
    
         
             
            						referencePath.replaceWith(
         
     | 
| 
       393 
392 
     | 
    
         
             
            							t.memberExpression(t.identifier(`_${uniqueId}_G_`), t.identifier(referencePath.node.name))
         
     | 
| 
       394 
393 
     | 
    
         
             
            						)
         
     | 
| 
         @@ -562,6 +561,65 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       562 
561 
     | 
    
         
             
            				t.variableDeclarator(t.identifier(`_${uniqueId}_G_`), t.identifier(`$${uniqueId}$GLOBAL$`))
         
     | 
| 
       563 
562 
     | 
    
         
             
            			])
         
     | 
| 
       564 
563 
     | 
    
         
             
            		)
         
     | 
| 
      
 564 
     | 
    
         
            +
            	const replaceAllThisWith = (node, scope, thisId) => {
         
     | 
| 
      
 565 
     | 
    
         
            +
            			let thisIsReferenced = !1
         
     | 
| 
      
 566 
     | 
    
         
            +
            			traverse(
         
     | 
| 
      
 567 
     | 
    
         
            +
            				node,
         
     | 
| 
      
 568 
     | 
    
         
            +
            				{
         
     | 
| 
      
 569 
     | 
    
         
            +
            					ThisExpression(path) {
         
     | 
| 
      
 570 
     | 
    
         
            +
            						thisIsReferenced = !0
         
     | 
| 
      
 571 
     | 
    
         
            +
            						path.replaceWith(t.identifier(thisId))
         
     | 
| 
      
 572 
     | 
    
         
            +
            					},
         
     | 
| 
      
 573 
     | 
    
         
            +
            					Function(path) {
         
     | 
| 
      
 574 
     | 
    
         
            +
            						"ArrowFunctionExpression" != path.node.type && path.skip()
         
     | 
| 
      
 575 
     | 
    
         
            +
            					}
         
     | 
| 
      
 576 
     | 
    
         
            +
            				},
         
     | 
| 
      
 577 
     | 
    
         
            +
            				scope
         
     | 
| 
      
 578 
     | 
    
         
            +
            			)
         
     | 
| 
      
 579 
     | 
    
         
            +
            			return thisIsReferenced
         
     | 
| 
      
 580 
     | 
    
         
            +
            		},
         
     | 
| 
      
 581 
     | 
    
         
            +
            		replaceThisInObjectLikeDefinition = path => {
         
     | 
| 
      
 582 
     | 
    
         
            +
            			const { node: object, scope, parent } = path,
         
     | 
| 
      
 583 
     | 
    
         
            +
            				evenMoreUniqueId = Math.floor(Math.random() * 2 ** 52)
         
     | 
| 
      
 584 
     | 
    
         
            +
            					.toString(36)
         
     | 
| 
      
 585 
     | 
    
         
            +
            					.padStart(11, "0"),
         
     | 
| 
      
 586 
     | 
    
         
            +
            				reuseDeclaredName =
         
     | 
| 
      
 587 
     | 
    
         
            +
            					"VariableDeclarator" == parent.type &&
         
     | 
| 
      
 588 
     | 
    
         
            +
            					"VariableDeclaration" == path.parentPath?.parentPath?.node?.type &&
         
     | 
| 
      
 589 
     | 
    
         
            +
            					"const" == path.parentPath?.parentPath?.node?.kind &&
         
     | 
| 
      
 590 
     | 
    
         
            +
            					"Identifier" == parent.id.type
         
     | 
| 
      
 591 
     | 
    
         
            +
            			let thisId = reuseDeclaredName ? parent.id.name : `_${evenMoreUniqueId}_THIS_`,
         
     | 
| 
      
 592 
     | 
    
         
            +
            				thisIsReferenced = !1
         
     | 
| 
      
 593 
     | 
    
         
            +
            			if ("ObjectExpression" == object.type)
         
     | 
| 
      
 594 
     | 
    
         
            +
            				for (const property of object.properties)
         
     | 
| 
      
 595 
     | 
    
         
            +
            					"ObjectMethod" == property.type &&
         
     | 
| 
      
 596 
     | 
    
         
            +
            						(thisIsReferenced ||= replaceAllThisWith(property, scope, thisId))
         
     | 
| 
      
 597 
     | 
    
         
            +
            			else
         
     | 
| 
      
 598 
     | 
    
         
            +
            				for (const element of object.elements)
         
     | 
| 
      
 599 
     | 
    
         
            +
            					null != element && (thisIsReferenced ||= replaceAllThisWith(element, scope, thisId))
         
     | 
| 
      
 600 
     | 
    
         
            +
            			if (!thisIsReferenced) return
         
     | 
| 
      
 601 
     | 
    
         
            +
            			if (reuseDeclaredName) return
         
     | 
| 
      
 602 
     | 
    
         
            +
            			path.replaceWith(t.assignmentExpression("=", t.identifier(thisId), object))
         
     | 
| 
      
 603 
     | 
    
         
            +
            			const parentBlock = (path => {
         
     | 
| 
      
 604 
     | 
    
         
            +
            				let someBlock = null,
         
     | 
| 
      
 605 
     | 
    
         
            +
            					currentParent = path
         
     | 
| 
      
 606 
     | 
    
         
            +
            				for (; currentParent && currentParent && currentParent.node; ) {
         
     | 
| 
      
 607 
     | 
    
         
            +
            					if (t.isBlock(currentParent.node)) {
         
     | 
| 
      
 608 
     | 
    
         
            +
            						someBlock = currentParent.node
         
     | 
| 
      
 609 
     | 
    
         
            +
            						break
         
     | 
| 
      
 610 
     | 
    
         
            +
            					}
         
     | 
| 
      
 611 
     | 
    
         
            +
            					if (t.isArrowFunctionExpression(currentParent.parentPath?.node)) {
         
     | 
| 
      
 612 
     | 
    
         
            +
            						currentParent.replaceWith(t.blockStatement([t.returnStatement(currentParent.node)]))
         
     | 
| 
      
 613 
     | 
    
         
            +
            						someBlock = currentParent.node
         
     | 
| 
      
 614 
     | 
    
         
            +
            						break
         
     | 
| 
      
 615 
     | 
    
         
            +
            					}
         
     | 
| 
      
 616 
     | 
    
         
            +
            					currentParent = currentParent.parentPath
         
     | 
| 
      
 617 
     | 
    
         
            +
            				}
         
     | 
| 
      
 618 
     | 
    
         
            +
            				assert(null != someBlock, "src/processScript/transform.ts:705:29")
         
     | 
| 
      
 619 
     | 
    
         
            +
            				return someBlock
         
     | 
| 
      
 620 
     | 
    
         
            +
            			})(path)
         
     | 
| 
      
 621 
     | 
    
         
            +
            			parentBlock.body.unshift(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(thisId), null)]))
         
     | 
| 
      
 622 
     | 
    
         
            +
            		}
         
     | 
| 
       565 
623 
     | 
    
         
             
            	traverse(file, {
         
     | 
| 
       566 
624 
     | 
    
         
             
            		BlockStatement({ node: blockStatement }) {
         
     | 
| 
       567 
625 
     | 
    
         
             
            			for (const [index, functionDeclaration] of blockStatement.body.entries())
         
     | 
| 
         @@ -581,8 +639,14 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       581 
639 
     | 
    
         
             
            					)
         
     | 
| 
       582 
640 
     | 
    
         
             
            				}
         
     | 
| 
       583 
641 
     | 
    
         
             
            		},
         
     | 
| 
      
 642 
     | 
    
         
            +
            		ObjectExpression(path) {
         
     | 
| 
      
 643 
     | 
    
         
            +
            			replaceThisInObjectLikeDefinition(path)
         
     | 
| 
      
 644 
     | 
    
         
            +
            		},
         
     | 
| 
      
 645 
     | 
    
         
            +
            		ArrayExpression(path) {
         
     | 
| 
      
 646 
     | 
    
         
            +
            			replaceThisInObjectLikeDefinition(path)
         
     | 
| 
      
 647 
     | 
    
         
            +
            		},
         
     | 
| 
       584 
648 
     | 
    
         
             
            		ClassBody({ node: classBody, scope, parent }) {
         
     | 
| 
       585 
     | 
    
         
            -
            			assert(t.isClass(parent), "src/processScript/transform.ts: 
     | 
| 
      
 649 
     | 
    
         
            +
            			assert(t.isClass(parent), "src/processScript/transform.ts:804:30")
         
     | 
| 
       586 
650 
     | 
    
         
             
            			let thisIsReferenced = !1
         
     | 
| 
       587 
651 
     | 
    
         
             
            			for (const classMethod of classBody.body) {
         
     | 
| 
       588 
652 
     | 
    
         
             
            				if ("ClassMethod" != classMethod.type) continue
         
     | 
| 
         @@ -595,7 +659,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       595 
659 
     | 
    
         
             
            							thisIsReferenced = !0
         
     | 
| 
       596 
660 
     | 
    
         
             
            							path.replaceWith(t.identifier(`_${uniqueId}_THIS_`))
         
     | 
| 
       597 
661 
     | 
    
         
             
            						},
         
     | 
| 
       598 
     | 
    
         
            -
            						Function 
     | 
| 
      
 662 
     | 
    
         
            +
            						Function(path) {
         
     | 
| 
      
 663 
     | 
    
         
            +
            							"ArrowFunctionExpression" != path.node.type && path.skip()
         
     | 
| 
      
 664 
     | 
    
         
            +
            						}
         
     | 
| 
       599 
665 
     | 
    
         
             
            					},
         
     | 
| 
       600 
666 
     | 
    
         
             
            					scope
         
     | 
| 
       601 
667 
     | 
    
         
             
            				)
         
     | 
| 
         @@ -682,23 +748,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr 
     | 
|
| 
       682 
748 
     | 
    
         
             
            	}
         
     | 
| 
       683 
749 
     | 
    
         
             
            	function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
         
     | 
| 
       684 
750 
     | 
    
         
             
            		for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
         
     | 
| 
       685 
     | 
    
         
            -
            			assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts: 
     | 
| 
      
 751 
     | 
    
         
            +
            			assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:914:60")
         
     | 
| 
       686 
752 
     | 
    
         
             
            			assert("Identifier" == referencePath.parent.property.type)
         
     | 
| 
       687 
753 
     | 
    
         
             
            			assert(
         
     | 
| 
       688 
754 
     | 
    
         
             
            				"MemberExpression" == referencePath.parentPath.parentPath?.node.type,
         
     | 
| 
       689 
     | 
    
         
            -
            				"src/processScript/transform.ts: 
     | 
| 
      
 755 
     | 
    
         
            +
            				"src/processScript/transform.ts:916:81"
         
     | 
| 
       690 
756 
     | 
    
         
             
            			)
         
     | 
| 
       691 
757 
     | 
    
         
             
            			assert(
         
     | 
| 
       692 
758 
     | 
    
         
             
            				"Identifier" == referencePath.parentPath.parentPath.node.property.type,
         
     | 
| 
       693 
     | 
    
         
            -
            				"src/processScript/transform.ts: 
     | 
| 
      
 759 
     | 
    
         
            +
            				"src/processScript/transform.ts:917:83"
         
     | 
| 
       694 
760 
     | 
    
         
             
            			)
         
     | 
| 
       695 
761 
     | 
    
         
             
            			assert(
         
     | 
| 
       696 
762 
     | 
    
         
             
            				/^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
         
     | 
| 
       697 
     | 
    
         
            -
            				`src/processScript/transform.ts: 
     | 
| 
      
 763 
     | 
    
         
            +
            				`src/processScript/transform.ts:921:8 invalid user "${referencePath.parent.property.name}" in subscript`
         
     | 
| 
       698 
764 
     | 
    
         
             
            			)
         
     | 
| 
       699 
765 
     | 
    
         
             
            			assert(
         
     | 
| 
       700 
766 
     | 
    
         
             
            				/^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
         
     | 
| 
       701 
     | 
    
         
            -
            				`src/processScript/transform.ts: 
     | 
| 
      
 767 
     | 
    
         
            +
            				`src/processScript/transform.ts:926:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
         
     | 
| 
       702 
768 
     | 
    
         
             
            			)
         
     | 
| 
       703 
769 
     | 
    
         
             
            			if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
         
     | 
| 
       704 
770 
     | 
    
         
             
            				referencePath.parentPath.parentPath.replaceWith(
         
     | 
    
        package/push.js
    CHANGED
    
    | 
         @@ -70,7 +70,9 @@ async function push( 
     | 
|
| 
       70 
70 
     | 
    
         
             
            	])
         
     | 
| 
       71 
71 
     | 
    
         
             
            	if (sourceFolder instanceof Error) return sourceFolder
         
     | 
| 
       72 
72 
     | 
    
         
             
            	if (hackmudFolder instanceof Error) return hackmudFolder
         
     | 
| 
       73 
     | 
    
         
            -
            	const sourceFolderFolders = sourceFolder.filter( 
     | 
| 
      
 73 
     | 
    
         
            +
            	const sourceFolderFolders = sourceFolder.filter(
         
     | 
| 
      
 74 
     | 
    
         
            +
            			({ name, stats }) => stats.isDirectory() && /^[a-z_][a-z\d_]{0,24}$/.test(name)
         
     | 
| 
      
 75 
     | 
    
         
            +
            		),
         
     | 
| 
       74 
76 
     | 
    
         
             
            		allUsers = new Set([
         
     | 
| 
       75 
77 
     | 
    
         
             
            			...scripts
         
     | 
| 
       76 
78 
     | 
    
         
             
            				.map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:85:65"))
         
     | 
    
        package/watch.js
    CHANGED
    
    | 
         @@ -9,7 +9,6 @@ import { extname, basename, resolve } from "path" 
     | 
|
| 
       9 
9 
     | 
    
         
             
            import { supportedExtensions } from "./constants.js"
         
     | 
| 
       10 
10 
     | 
    
         
             
            import { generateTypeDeclaration } from "./generateTypeDeclaration.js"
         
     | 
| 
       11 
11 
     | 
    
         
             
            import { processScript } from "./processScript/index.js"
         
     | 
| 
       12 
     | 
    
         
            -
            import "path/posix"
         
     | 
| 
       13 
12 
     | 
    
         
             
            import "@babel/generator"
         
     | 
| 
       14 
13 
     | 
    
         
             
            import "@babel/parser"
         
     | 
| 
       15 
14 
     | 
    
         
             
            import "@babel/plugin-proposal-decorators"
         
     |