hackmud-script-manager 0.19.0-50a29ed → 0.19.0-cd5548c
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/LICENSE +21 -674
- package/bin/hsm.d.ts +0 -1
- package/bin/hsm.js +687 -1
- package/constants.d.ts +2 -0
- package/constants.js +4 -0
- package/generateTypeDeclaration.js +94 -1
- package/index.d.ts +2 -2
- package/index.js +47 -1
- package/package.json +37 -79
- package/processScript/index.d.ts +2 -2
- package/processScript/index.js +310 -1
- package/processScript/minify.d.ts +3 -3
- package/processScript/minify.js +376 -1
- package/processScript/postprocess.js +5 -1
- package/processScript/preprocess.d.ts +1 -1
- package/processScript/preprocess.js +84 -1
- package/processScript/shared.d.ts +3 -3
- package/processScript/shared.js +18 -1
- package/processScript/transform.d.ts +3 -3
- package/processScript/transform.js +394 -1
- package/pull.js +17 -1
- package/push.d.ts +3 -3
- package/push.js +251 -1
- package/syncMacros.js +53 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/watch.d.ts +3 -3
- package/watch.js +228 -1
- package/assert-22a7ef8a.js +0 -1
- package/constants-9bb78688.js +0 -1
- package/countHackmudCharacters-a08a265f.js +0 -1
- package/spliceString-0e6b5d6d.js +0 -1
- package/writeFilePersistent-ee9c9bfd.js +0 -1
package/constants.d.ts
ADDED
package/constants.js
ADDED
@@ -1 +1,94 @@
|
|
1
|
-
import{readdir
|
1
|
+
import { readdir } from 'fs/promises';
|
2
|
+
import { basename, resolve } from 'path';
|
3
|
+
|
4
|
+
const generateTypeDeclaration = async (sourceDirectory, hackmudPath) => {
|
5
|
+
const users = new Set();
|
6
|
+
if (hackmudPath) {
|
7
|
+
for (const dirent of await readdir(hackmudPath, {
|
8
|
+
withFileTypes: true
|
9
|
+
})) {
|
10
|
+
if (dirent.isFile() && dirent.name.endsWith(`.key`)) users.add(basename(dirent.name, `.key`));
|
11
|
+
}
|
12
|
+
}
|
13
|
+
const wildScripts = [];
|
14
|
+
const wildAnyScripts = [];
|
15
|
+
const allScripts = {};
|
16
|
+
const allAnyScripts = {};
|
17
|
+
await Promise.all((await readdir(sourceDirectory, {
|
18
|
+
withFileTypes: true
|
19
|
+
})).map(async dirent => {
|
20
|
+
if (dirent.isFile()) {
|
21
|
+
if (dirent.name.endsWith(`.ts`)) {
|
22
|
+
if (!dirent.name.endsWith(`.d.ts`)) wildScripts.push(basename(dirent.name, `.ts`));
|
23
|
+
} else if (dirent.name.endsWith(`.js`)) wildAnyScripts.push(basename(dirent.name, `.js`));
|
24
|
+
} else if (dirent.isDirectory()) {
|
25
|
+
const scripts = [];
|
26
|
+
const anyScripts = [];
|
27
|
+
allScripts[dirent.name] = scripts;
|
28
|
+
allAnyScripts[dirent.name] = anyScripts;
|
29
|
+
users.add(dirent.name);
|
30
|
+
for (const file of await readdir(resolve(sourceDirectory, dirent.name), {
|
31
|
+
withFileTypes: true
|
32
|
+
})) {
|
33
|
+
if (file.isFile()) {
|
34
|
+
if (file.name.endsWith(`.ts`)) {
|
35
|
+
if (!dirent.name.endsWith(`.d.ts`)) scripts.push(basename(file.name, `.ts`));
|
36
|
+
} else if (file.name.endsWith(`.js`)) anyScripts.push(basename(file.name, `.js`));
|
37
|
+
}
|
38
|
+
}
|
39
|
+
}
|
40
|
+
}));
|
41
|
+
sourceDirectory = resolve(sourceDirectory);
|
42
|
+
let o = ``;
|
43
|
+
for (const script of wildScripts) o += `type $${script}$ = typeof import("${sourceDirectory}/${script}").default\n`;
|
44
|
+
o += `\n`;
|
45
|
+
for (const user in allScripts) {
|
46
|
+
const scripts = allScripts[user];
|
47
|
+
for (const script of scripts) o += `type $${user}$${script}$ = typeof import("${sourceDirectory}/${user}/${script}").default\n`;
|
48
|
+
}
|
49
|
+
|
50
|
+
// TODO detect security level and generate apropriate code
|
51
|
+
|
52
|
+
// TODO accurate function signatures
|
53
|
+
// I lose the generic-ness of my functions when I wrap them
|
54
|
+
// regexing isn't enough and it looks like I'm going to need to parse the files in TypeScript to extract the signature
|
55
|
+
|
56
|
+
o += `
|
57
|
+
type ArrayRemoveFirst<A> = A extends [ infer FirstItem, ...infer Rest ] ? Rest : never
|
58
|
+
|
59
|
+
type Subscript<T extends (...args: any) => any> =
|
60
|
+
(...args: ArrayRemoveFirst<Parameters<T>>) => ReturnType<T> | ScriptFailure
|
61
|
+
|
62
|
+
type WildFullsec = Record<string, () => ScriptFailure> & {
|
63
|
+
`;
|
64
|
+
for (const script of wildScripts) o += `\t${script}: Subscript<$${script}$>\n`;
|
65
|
+
for (const script of wildAnyScripts) o += `\t${script}: (...args: any) => any\n`;
|
66
|
+
o += `}\n\ninterface PlayerFullsec {`;
|
67
|
+
let lastWasMultiLine = true;
|
68
|
+
for (const user of users) {
|
69
|
+
const scripts = allScripts[user];
|
70
|
+
const anyScripts = allAnyScripts[user];
|
71
|
+
if (scripts && scripts.length || anyScripts && anyScripts.length) {
|
72
|
+
lastWasMultiLine = true;
|
73
|
+
o += `\n\t${user}: WildFullsec & {\n`;
|
74
|
+
if (scripts) {
|
75
|
+
for (const script of scripts) o += `\t\t${script}: Subscript<$${user}$${script}$>\n`;
|
76
|
+
}
|
77
|
+
if (anyScripts) {
|
78
|
+
for (const script of anyScripts) o += `\t\t${script}: (...args: any) => any\n`;
|
79
|
+
}
|
80
|
+
o += `\t}`;
|
81
|
+
} else {
|
82
|
+
if (lastWasMultiLine) {
|
83
|
+
o += `\n`;
|
84
|
+
lastWasMultiLine = false;
|
85
|
+
}
|
86
|
+
o += `\t${user}: WildFullsec`;
|
87
|
+
}
|
88
|
+
o += `\n`;
|
89
|
+
}
|
90
|
+
o += `}\n`;
|
91
|
+
return o;
|
92
|
+
};
|
93
|
+
|
94
|
+
export { generateTypeDeclaration as default, generateTypeDeclaration };
|
package/index.d.ts
CHANGED
@@ -1,11 +1,11 @@
|
|
1
|
-
export { supportedExtensions } from "./constants
|
1
|
+
export { supportedExtensions } from "./constants";
|
2
2
|
export { generateTypeDeclaration } from "./generateTypeDeclaration";
|
3
3
|
export { processScript } from "./processScript";
|
4
4
|
export { pull } from "./pull";
|
5
5
|
export { push } from "./push";
|
6
6
|
export { syncMacros } from "./syncMacros";
|
7
7
|
export { watch } from "./watch";
|
8
|
-
export
|
8
|
+
export type Info = {
|
9
9
|
file: string;
|
10
10
|
users: string[];
|
11
11
|
minLength: number;
|
package/index.js
CHANGED
@@ -1 +1,47 @@
|
|
1
|
-
export{
|
1
|
+
export { supportedExtensions } from './constants.js';
|
2
|
+
export { generateTypeDeclaration } from './generateTypeDeclaration.js';
|
3
|
+
export { processScript } from './processScript/index.js';
|
4
|
+
export { pull } from './pull.js';
|
5
|
+
export { push } from './push.js';
|
6
|
+
export { syncMacros } from './syncMacros.js';
|
7
|
+
export { watch } from './watch.js';
|
8
|
+
import 'fs/promises';
|
9
|
+
import 'path';
|
10
|
+
import '@babel/generator';
|
11
|
+
import '@babel/parser';
|
12
|
+
import '@babel/plugin-proposal-class-properties';
|
13
|
+
import '@babel/plugin-proposal-class-static-block';
|
14
|
+
import '@babel/plugin-proposal-decorators';
|
15
|
+
import '@babel/plugin-proposal-json-strings';
|
16
|
+
import '@babel/plugin-proposal-logical-assignment-operators';
|
17
|
+
import '@babel/plugin-proposal-nullish-coalescing-operator';
|
18
|
+
import '@babel/plugin-proposal-numeric-separator';
|
19
|
+
import '@babel/plugin-proposal-object-rest-spread';
|
20
|
+
import '@babel/plugin-proposal-optional-catch-binding';
|
21
|
+
import '@babel/plugin-proposal-optional-chaining';
|
22
|
+
import '@babel/plugin-proposal-private-property-in-object';
|
23
|
+
import '@babel/plugin-transform-exponentiation-operator';
|
24
|
+
import '@babel/traverse';
|
25
|
+
import '@babel/types';
|
26
|
+
import '@rollup/plugin-babel';
|
27
|
+
import '@rollup/plugin-commonjs';
|
28
|
+
import '@rollup/plugin-json';
|
29
|
+
import '@rollup/plugin-node-resolve';
|
30
|
+
import '@samual/lib/assert';
|
31
|
+
import 'prettier';
|
32
|
+
import 'rollup';
|
33
|
+
import './processScript/minify.js';
|
34
|
+
import '@samual/lib/countHackmudCharacters';
|
35
|
+
import '@samual/lib/spliceString';
|
36
|
+
import 'acorn';
|
37
|
+
import 'terser';
|
38
|
+
import './processScript/shared.js';
|
39
|
+
import './processScript/postprocess.js';
|
40
|
+
import './processScript/preprocess.js';
|
41
|
+
import 'import-meta-resolve';
|
42
|
+
import './processScript/transform.js';
|
43
|
+
import '@samual/lib/clearObject';
|
44
|
+
import '@samual/lib/copyFilePersistent';
|
45
|
+
import '@samual/lib/DynamicMap';
|
46
|
+
import '@samual/lib/writeFilePersistent';
|
47
|
+
import 'chokidar';
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
|
-
"version": "0.19.0-
|
3
|
+
"version": "0.19.0-cd5548c",
|
4
4
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
5
5
|
"keywords": [
|
6
6
|
"api",
|
@@ -19,7 +19,7 @@
|
|
19
19
|
],
|
20
20
|
"homepage": "https://github.com/samualtnorman/hackmud-script-manager#readme",
|
21
21
|
"bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
|
22
|
-
"license": "
|
22
|
+
"license": "MIT",
|
23
23
|
"author": "Samual Norman",
|
24
24
|
"main": "index.js",
|
25
25
|
"repository": {
|
@@ -27,98 +27,56 @@
|
|
27
27
|
"url": "https://github.com/samualtnorman/hackmud-script-manager.git"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@babel/
|
31
|
-
"@babel/
|
32
|
-
"@babel/parser": "^7.18.9",
|
30
|
+
"@babel/generator": "^7.22.9",
|
31
|
+
"@babel/parser": "^7.22.7",
|
33
32
|
"@babel/plugin-proposal-class-properties": "^7.18.6",
|
34
|
-
"@babel/plugin-proposal-class-static-block": "^7.
|
35
|
-
"@babel/plugin-proposal-decorators": "^7.
|
36
|
-
"@babel/plugin-proposal-do-expressions": "^7.
|
37
|
-
"@babel/plugin-proposal-function-bind": "^7.
|
38
|
-
"@babel/plugin-proposal-function-sent": "^7.
|
33
|
+
"@babel/plugin-proposal-class-static-block": "^7.21.0",
|
34
|
+
"@babel/plugin-proposal-decorators": "^7.22.7",
|
35
|
+
"@babel/plugin-proposal-do-expressions": "^7.22.5",
|
36
|
+
"@babel/plugin-proposal-function-bind": "^7.22.5",
|
37
|
+
"@babel/plugin-proposal-function-sent": "^7.22.5",
|
39
38
|
"@babel/plugin-proposal-json-strings": "^7.18.6",
|
40
|
-
"@babel/plugin-proposal-logical-assignment-operators": "^7.
|
39
|
+
"@babel/plugin-proposal-logical-assignment-operators": "^7.20.7",
|
41
40
|
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.18.6",
|
42
41
|
"@babel/plugin-proposal-numeric-separator": "^7.18.6",
|
43
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.
|
42
|
+
"@babel/plugin-proposal-object-rest-spread": "^7.20.7",
|
44
43
|
"@babel/plugin-proposal-optional-catch-binding": "^7.18.6",
|
45
|
-
"@babel/plugin-proposal-optional-chaining": "^7.
|
46
|
-
"@babel/plugin-proposal-partial-application": "^7.
|
47
|
-
"@babel/plugin-proposal-pipeline-operator": "^7.
|
48
|
-
"@babel/plugin-proposal-private-property-in-object": "^7.
|
49
|
-
"@babel/plugin-proposal-record-and-tuple": "^7.
|
50
|
-
"@babel/plugin-proposal-throw-expressions": "^7.
|
51
|
-
"@babel/plugin-transform-exponentiation-operator": "^7.
|
52
|
-
"@babel/plugin-transform-typescript": "^7.
|
53
|
-
"@babel/traverse": "^7.
|
54
|
-
"@babel/types": "^7.
|
44
|
+
"@babel/plugin-proposal-optional-chaining": "^7.21.0",
|
45
|
+
"@babel/plugin-proposal-partial-application": "^7.22.5",
|
46
|
+
"@babel/plugin-proposal-pipeline-operator": "^7.22.5",
|
47
|
+
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
|
48
|
+
"@babel/plugin-proposal-record-and-tuple": "^7.22.5",
|
49
|
+
"@babel/plugin-proposal-throw-expressions": "^7.22.5",
|
50
|
+
"@babel/plugin-transform-exponentiation-operator": "^7.22.5",
|
51
|
+
"@babel/plugin-transform-typescript": "^7.22.9",
|
52
|
+
"@babel/traverse": "^7.22.8",
|
53
|
+
"@babel/types": "^7.22.5",
|
55
54
|
"@bloomberg/record-tuple-polyfill": "^0.0.4",
|
56
|
-
"@rollup/plugin-babel": "^
|
57
|
-
"@rollup/plugin-commonjs": "^
|
58
|
-
"@rollup/plugin-json": "^
|
59
|
-
"@rollup/plugin-node-resolve": "^
|
60
|
-
"
|
61
|
-
"
|
55
|
+
"@rollup/plugin-babel": "^6.0.3",
|
56
|
+
"@rollup/plugin-commonjs": "^25.0.2",
|
57
|
+
"@rollup/plugin-json": "^6.0.0",
|
58
|
+
"@rollup/plugin-node-resolve": "^15.1.0",
|
59
|
+
"@samual/lib": "^0.8.1",
|
60
|
+
"acorn": "^8.10.0",
|
61
|
+
"chalk": "^5.3.0",
|
62
62
|
"chokidar": "^3.5.3",
|
63
|
-
"import-meta-resolve": "^
|
64
|
-
"prettier": "^
|
63
|
+
"import-meta-resolve": "^3.0.0",
|
64
|
+
"prettier": "^3.0.0",
|
65
65
|
"proxy-polyfill": "^0.3.2",
|
66
|
-
"rollup": "^
|
67
|
-
"terser": "^5.
|
68
|
-
},
|
69
|
-
"devDependencies": {
|
70
|
-
"@babel/preset-env": "^7.18.9",
|
71
|
-
"@babel/preset-typescript": "^7.18.6",
|
72
|
-
"@samual/lib": "^0.3.4",
|
73
|
-
"@types/babel__core": "^7.1.19",
|
74
|
-
"@types/babel__generator": "^7.6.4",
|
75
|
-
"@types/babel__traverse": "^7.17.1",
|
76
|
-
"@types/node": "^14.18.22",
|
77
|
-
"@types/prettier": "^2.6.3",
|
78
|
-
"@types/semver": "^7.3.10",
|
79
|
-
"@typescript-eslint/eslint-plugin": "^5.30.7",
|
80
|
-
"@typescript-eslint/parser": "^5.30.7",
|
81
|
-
"eslint": "^8.20.0",
|
82
|
-
"eslint-plugin-array-func": "^3.1.7",
|
83
|
-
"eslint-plugin-eslint-comments": "^3.2.0",
|
84
|
-
"eslint-plugin-regexp": "^1.7.0",
|
85
|
-
"eslint-plugin-unicorn": "^43.0.2",
|
86
|
-
"latest-version": "^7.0.0",
|
87
|
-
"rollup-plugin-preserve-shebang": "^1.0.1",
|
88
|
-
"rollup-plugin-terser": "^7.0.2",
|
89
|
-
"semver": "^7.3.7",
|
90
|
-
"typescript": "^4.7.4"
|
91
|
-
},
|
92
|
-
"optionalDependencies": {
|
93
|
-
"deasync": "^0.1.27"
|
66
|
+
"rollup": "^3.26.2",
|
67
|
+
"terser": "^5.19.0"
|
94
68
|
},
|
95
69
|
"engines": {
|
96
|
-
"node": ">=
|
70
|
+
"node": ">=16"
|
97
71
|
},
|
98
72
|
"types": "index.d.ts",
|
99
73
|
"type": "module",
|
100
74
|
"exports": {
|
101
|
-
"
|
102
|
-
|
103
|
-
"require": "./index.cjs"
|
104
|
-
},
|
105
|
-
"./*": "./*",
|
106
|
-
"./generateTypeDeclaration": "./generateTypeDeclaration.js",
|
107
|
-
"./index": "./index.js",
|
108
|
-
"./pull": "./pull.js",
|
109
|
-
"./push": "./push.js",
|
110
|
-
"./syncMacros": "./syncMacros.js",
|
111
|
-
"./watch": "./watch.js",
|
112
|
-
"./bin/hsm": "./bin/hsm.js",
|
113
|
-
"./processScript/index": "./processScript/index.js",
|
114
|
-
"./processScript": "./processScript/index.js",
|
115
|
-
"./processScript/minify": "./processScript/minify.js",
|
116
|
-
"./processScript/postprocess": "./processScript/postprocess.js",
|
117
|
-
"./processScript/preprocess": "./processScript/preprocess.js",
|
118
|
-
"./processScript/shared": "./processScript/shared.js",
|
119
|
-
"./processScript/transform": "./processScript/transform.js"
|
75
|
+
"./*": "./*.js",
|
76
|
+
"./*.js": "./*.js"
|
120
77
|
},
|
121
78
|
"bin": {
|
122
|
-
"hsm": "
|
79
|
+
"hsm.d": "bin/hsm.d.ts",
|
80
|
+
"hsm": "bin/hsm.js"
|
123
81
|
}
|
124
82
|
}
|
package/processScript/index.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
|
-
import { LaxPartial } from "@samual/lib";
|
1
|
+
import type { LaxPartial } from "@samual/lib";
|
2
2
|
export { minify } from "./minify";
|
3
3
|
export { postprocess } from "./postprocess";
|
4
4
|
export { preprocess } from "./preprocess";
|
5
5
|
export { transform } from "./transform";
|
6
|
-
export
|
6
|
+
export type ProcessOptions = {
|
7
7
|
/** whether to minify the given code */
|
8
8
|
minify: boolean;
|
9
9
|
/** 11 a-z 0-9 characters */
|