hackmud-script-manager 0.21.1-979c2a3 → 0.21.1-c61c24e
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/bin/hsm.js +2 -2
 - package/env.d.ts +9 -9
 - package/package.json +3 -2
 - package/processScript/index.js +2 -1
 - package/push.js +3 -1
 
    
        package/bin/hsm.js
    CHANGED
    
    | 
         @@ -64,7 +64,7 @@ if (process.version.startsWith("v21.")) { 
     | 
|
| 
       64 
64 
     | 
    
         
             
            	)
         
     | 
| 
       65 
65 
     | 
    
         
             
            }
         
     | 
| 
       66 
66 
     | 
    
         
             
            if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
         
     | 
| 
       67 
     | 
    
         
            -
            	console.log("0.21.1- 
     | 
| 
      
 67 
     | 
    
         
            +
            	console.log("0.21.1-c61c24e")
         
     | 
| 
       68 
68 
     | 
    
         
             
            	process.exit()
         
     | 
| 
       69 
69 
     | 
    
         
             
            }
         
     | 
| 
       70 
70 
     | 
    
         
             
            let warnedDeprecatedEmitDtsAlias = !1
         
     | 
| 
         @@ -412,7 +412,7 @@ function logHelp() { 
     | 
|
| 
       412 
412 
     | 
    
         
             
            		default:
         
     | 
| 
       413 
413 
     | 
    
         
             
            			console.log(
         
     | 
| 
       414 
414 
     | 
    
         
             
            				colourS(
         
     | 
| 
       415 
     | 
    
         
            -
            					`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1- 
     | 
| 
      
 415 
     | 
    
         
            +
            					`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-c61c24e")}\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 
416 
     | 
    
         
             
            				)
         
     | 
| 
       417 
417 
     | 
    
         
             
            			)
         
     | 
| 
       418 
418 
     | 
    
         
             
            	}
         
     | 
    
        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`.
         
     | 
| 
         @@ -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> = {
         
     | 
| 
         @@ -886,9 +886,9 @@ declare global { 
     | 
|
| 
       886 
886 
     | 
    
         
             
            	type ScriptSuccess<T = unknown> = { ok: true } & T
         
     | 
| 
       887 
887 
     | 
    
         
             
            	type ScriptFailure = { ok: false, msg?: string }
         
     | 
| 
       888 
888 
     | 
    
         
             
            	type ScriptResponse<T = unknown> = ScriptSuccess<T> | ScriptFailure
         
     | 
| 
       889 
     | 
    
         
            -
            	type Scriptor<TArgs  
     | 
| 
      
 889 
     | 
    
         
            +
            	type Scriptor<TArgs = any> = { name: string, call: (args: TArgs) => unknown }
         
     | 
| 
       890 
890 
     | 
    
         
             
            	type Context = CliContext | SubscriptContext | ScriptorContext | BrainContext
         
     | 
| 
       891 
     | 
    
         
            -
            	type  
     | 
| 
      
 891 
     | 
    
         
            +
            	type MongoObjectId = { $oid: string }
         
     | 
| 
       892 
892 
     | 
    
         | 
| 
       893 
893 
     | 
    
         
             
            	interface PlayerFullsec {}
         
     | 
| 
       894 
894 
     | 
    
         
             
            	interface PlayerHighsec {}
         
     | 
| 
         @@ -979,7 +979,7 @@ declare global { 
     | 
|
| 
       979 
979 
     | 
    
         
             
            		us: <T extends MongoDocument>(query: MongoQuery<T> | MongoQuery<T>[], command: MongoUpdateCommand<T>) =>
         
     | 
| 
       980 
980 
     | 
    
         
             
            			{ n: number, ok: 0 | 1, opTime: { t: number }, nModified: number }[]
         
     | 
| 
       981 
981 
     | 
    
         | 
| 
       982 
     | 
    
         
            -
            		ObjectId: () =>  
     | 
| 
      
 982 
     | 
    
         
            +
            		ObjectId: () => MongoObjectId
         
     | 
| 
       983 
983 
     | 
    
         
             
            	}
         
     | 
| 
       984 
984 
     | 
    
         | 
| 
       985 
985 
     | 
    
         
             
            	/** Debug Log.
         
     | 
    
        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-c61c24e",
         
     | 
| 
       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,8 @@ 
     | 
|
| 
       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"
         
     | 
| 
       27 
28 
     | 
    
         
             
              ],
         
     | 
| 
       28 
29 
     | 
    
         
             
              "main": "index.js",
         
     | 
| 
       29 
30 
     | 
    
         
             
              "repository": {
         
     | 
    
        package/processScript/index.js
    CHANGED
    
    | 
         @@ -210,7 +210,8 @@ async function processScript( 
     | 
|
| 
       210 
210 
     | 
    
         
             
            				{
         
     | 
| 
       211 
211 
     | 
    
         
             
            					name: "hackmud-script-manager",
         
     | 
| 
       212 
212 
     | 
    
         
             
            					async transform(code, id) {
         
     | 
| 
       213 
     | 
    
         
            -
            						if (!id.includes("/node_modules/")) 
     | 
| 
      
 213 
     | 
    
         
            +
            						if (id.startsWith("/") && !id.includes("/node_modules/"))
         
     | 
| 
      
 214 
     | 
    
         
            +
            							return (await preprocess(code, { uniqueId })).code
         
     | 
| 
       214 
215 
     | 
    
         
             
            						let program
         
     | 
| 
       215 
216 
     | 
    
         
             
            						traverse(parse(code, { sourceType: "module" }), {
         
     | 
| 
       216 
217 
     | 
    
         
             
            							Program(path) {
         
     | 
    
        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"))
         
     |