hackmud-script-manager 0.19.1-98e81f8 → 0.19.1-b040eb5
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/bin/hsm.d.ts +0 -0
- package/bin/hsm.js +147 -300
- package/env.d.ts +1357 -0
- package/generateTypeDeclaration.d.ts +1 -2
- package/generateTypeDeclaration.js +19 -19
- package/index.d.ts +2 -2
- package/index.js +2 -1
- package/package.json +8 -6
- package/processScript/index.d.ts +17 -26
- package/processScript/index.js +258 -241
- package/processScript/minify.d.ts +15 -21
- package/processScript/minify.js +381 -395
- package/processScript/postprocess.d.ts +0 -1
- package/processScript/postprocess.js +1 -1
- package/processScript/preprocess.d.ts +6 -9
- package/processScript/preprocess.js +94 -94
- package/processScript/shared.d.ts +1 -1
- package/processScript/shared.js +11 -11
- package/processScript/transform.d.ts +13 -18
- package/processScript/transform.js +597 -550
- package/pull.d.ts +5 -9
- package/pull.js +2 -2
- package/push.d.ts +24 -33
- package/push.js +88 -213
- package/syncMacros.d.ts +1 -2
- package/syncMacros.js +7 -6
- package/watch.d.ts +10 -16
- package/watch.js +30 -31
- package/tsconfig.tsbuildinfo +0 -1
@@ -1,2 +1 @@
|
|
1
|
-
export declare
|
2
|
-
export default generateTypeDeclaration;
|
1
|
+
export declare function generateTypeDeclaration(sourceDirectory: string, hackmudPath?: string): Promise<string>;
|
@@ -1,31 +1,31 @@
|
|
1
|
-
import {
|
1
|
+
import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
|
2
2
|
import { basename, resolve } from "path"
|
3
|
-
|
3
|
+
async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
|
4
4
|
const users = new Set()
|
5
5
|
if (hackmudPath)
|
6
|
-
for (const
|
7
|
-
|
6
|
+
for (const { stats, name } of await readDirectoryWithStats(hackmudPath))
|
7
|
+
stats.isFile() && name.endsWith(".key") && users.add(basename(name, ".key"))
|
8
8
|
const wildScripts = [],
|
9
9
|
wildAnyScripts = [],
|
10
10
|
allScripts = {},
|
11
11
|
allAnyScripts = {}
|
12
12
|
await Promise.all(
|
13
|
-
(await
|
14
|
-
if (
|
15
|
-
|
16
|
-
|
17
|
-
:
|
18
|
-
else if (
|
13
|
+
(await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name }) => {
|
14
|
+
if (stats.isFile())
|
15
|
+
name.endsWith(".ts") ?
|
16
|
+
name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
|
17
|
+
: name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
|
18
|
+
else if (stats.isDirectory()) {
|
19
19
|
const scripts = [],
|
20
20
|
anyScripts = []
|
21
|
-
allScripts[
|
22
|
-
allAnyScripts[
|
23
|
-
users.add(
|
24
|
-
for (const
|
25
|
-
|
26
|
-
(
|
27
|
-
|
28
|
-
:
|
21
|
+
allScripts[name] = scripts
|
22
|
+
allAnyScripts[name] = anyScripts
|
23
|
+
users.add(name)
|
24
|
+
for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
|
25
|
+
child.stats.isFile() &&
|
26
|
+
(child.name.endsWith(".ts") ?
|
27
|
+
name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
|
28
|
+
: child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
|
29
29
|
}
|
30
30
|
})
|
31
31
|
)
|
@@ -65,4 +65,4 @@ const generateTypeDeclaration = async (sourceDirectory, hackmudPath) => {
|
|
65
65
|
o += "}\n"
|
66
66
|
return o
|
67
67
|
}
|
68
|
-
export { generateTypeDeclaration
|
68
|
+
export { generateTypeDeclaration }
|
package/index.d.ts
CHANGED
@@ -6,8 +6,8 @@ export { push } from "./push";
|
|
6
6
|
export { syncMacros } from "./syncMacros";
|
7
7
|
export { watch } from "./watch";
|
8
8
|
export type Info = {
|
9
|
-
|
9
|
+
path: string;
|
10
10
|
users: string[];
|
11
|
-
|
11
|
+
characterCount: number;
|
12
12
|
error: Error | undefined;
|
13
13
|
};
|
package/index.js
CHANGED
@@ -5,7 +5,7 @@ export { pull } from "./pull.js"
|
|
5
5
|
export { push } from "./push.js"
|
6
6
|
export { syncMacros } from "./syncMacros.js"
|
7
7
|
export { watch } from "./watch.js"
|
8
|
-
import "
|
8
|
+
import "@samual/lib/readDirectoryWithStats"
|
9
9
|
import "path"
|
10
10
|
import "@babel/generator"
|
11
11
|
import "@babel/parser"
|
@@ -47,4 +47,5 @@ import "@samual/lib/clearObject"
|
|
47
47
|
import "@samual/lib/copyFilePersistent"
|
48
48
|
import "@samual/lib/Cache"
|
49
49
|
import "@samual/lib/writeFilePersistent"
|
50
|
+
import "fs/promises"
|
50
51
|
import "chokidar"
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.19.1-
|
3
|
+
"version": "0.19.1-b040eb5",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -59,7 +59,7 @@
|
|
59
59
|
"@rollup/plugin-commonjs": "^25.0.7",
|
60
60
|
"@rollup/plugin-json": "^6.1.0",
|
61
61
|
"@rollup/plugin-node-resolve": "^15.2.3",
|
62
|
-
"@samual/lib": "
|
62
|
+
"@samual/lib": "0.10.2-e64c5bc",
|
63
63
|
"acorn": "^8.11.3",
|
64
64
|
"chalk": "^5.3.0",
|
65
65
|
"chokidar": "^3.6.0",
|
@@ -69,17 +69,19 @@
|
|
69
69
|
"rollup": "^4.14.2",
|
70
70
|
"terser": "^5.30.3"
|
71
71
|
},
|
72
|
-
"
|
73
|
-
"
|
74
|
-
"pnpm": "^8.15.7"
|
72
|
+
"peerDependencies": {
|
73
|
+
"typescript": "5.4.5"
|
75
74
|
},
|
76
75
|
"type": "module",
|
77
76
|
"exports": {
|
77
|
+
".": "./index.js",
|
78
78
|
"./*": "./*.js",
|
79
79
|
"./*.js": "./*.js"
|
80
80
|
},
|
81
81
|
"bin": {
|
82
|
-
"hsm.d": "bin/hsm.d.ts",
|
83
82
|
"hsm": "bin/hsm.js"
|
83
|
+
},
|
84
|
+
"engines": {
|
85
|
+
"node": "^18 || >=20"
|
84
86
|
}
|
85
87
|
}
|
package/processScript/index.d.ts
CHANGED
@@ -3,38 +3,29 @@ export { minify } from "./minify";
|
|
3
3
|
export { postprocess } from "./postprocess";
|
4
4
|
export { preprocess } from "./preprocess";
|
5
5
|
export { transform } from "./transform";
|
6
|
-
export type ProcessOptions = {
|
7
|
-
/** whether to minify the given code */
|
8
|
-
|
9
|
-
/**
|
10
|
-
uniqueID: string;
|
11
|
-
/** the user going to be hosting this script (or set to `true` if not yet known) */
|
12
|
-
scriptUser: string | true;
|
13
|
-
/** the name of this script (or set to `true` if not yet known) */
|
14
|
-
scriptName: string | true;
|
6
|
+
export type ProcessOptions = LaxPartial<{
|
7
|
+
/** whether to minify the given code */ minify: boolean;
|
8
|
+
/** 11 a-z 0-9 characters */ uniqueID: string;
|
9
|
+
/** the user going to be hosting this script (or set to `true` if not yet known) */ scriptUser: string | true;
|
15
10
|
filePath: string;
|
16
|
-
/** whether to mangle function and class names (defaults to `false`) */
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
* when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
|
24
|
-
*/
|
11
|
+
/** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
|
12
|
+
/** when set to `true` forces use of quine cheats
|
13
|
+
*
|
14
|
+
* when set to `false` forces quine cheats not to be used
|
15
|
+
*
|
16
|
+
* when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
|
17
|
+
*/
|
25
18
|
forceQuineCheats: boolean;
|
19
|
+
}> & {
|
20
|
+
scriptName: string | true;
|
26
21
|
};
|
27
|
-
/**
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
* @param options {@link ProcessOptions details}
|
32
|
-
*/
|
33
|
-
export declare const processScript: (code: string, { minify: shouldMinify, uniqueID, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats }?: LaxPartial<ProcessOptions>) => Promise<{
|
22
|
+
/** Minifies a given script
|
23
|
+
* @param code JavaScript or TypeScript code
|
24
|
+
* @param options {@link ProcessOptions details} */
|
25
|
+
export declare function processScript(code: string, { minify: shouldMinify, uniqueID, scriptUser, scriptName, filePath, mangleNames, forceQuineCheats }: ProcessOptions): Promise<{
|
34
26
|
script: string;
|
35
27
|
warnings: {
|
36
28
|
message: string;
|
37
29
|
line: number;
|
38
30
|
}[];
|
39
31
|
}>;
|
40
|
-
export default processScript;
|