hackmud-script-manager 0.19.0-50a29ed → 0.19.0-7c69a3b
Sign up to get free protection for your applications and to get access to all the features.
- package/LICENSE +21 -674
- package/bin/hsm.d.ts +0 -0
- package/bin/hsm.js +682 -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 +50 -1
- package/package.json +45 -85
- package/processScript/index.d.ts +2 -2
- package/processScript/index.js +313 -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 +83 -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 +393 -1
- package/pull.js +17 -1
- package/push.d.ts +3 -3
- package/push.js +254 -1
- package/syncMacros.js +53 -1
- package/tsconfig.tsbuildinfo +1 -1
- package/watch.d.ts +3 -3
- package/watch.js +231 -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,50 @@
|
|
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-decorators';
|
13
|
+
import '@babel/plugin-proposal-destructuring-private';
|
14
|
+
import '@babel/plugin-proposal-explicit-resource-management';
|
15
|
+
import '@babel/plugin-transform-class-properties';
|
16
|
+
import '@babel/plugin-transform-class-static-block';
|
17
|
+
import '@babel/plugin-transform-exponentiation-operator';
|
18
|
+
import '@babel/plugin-transform-json-strings';
|
19
|
+
import '@babel/plugin-transform-logical-assignment-operators';
|
20
|
+
import '@babel/plugin-transform-nullish-coalescing-operator';
|
21
|
+
import '@babel/plugin-transform-numeric-separator';
|
22
|
+
import '@babel/plugin-transform-object-rest-spread';
|
23
|
+
import '@babel/plugin-transform-optional-catch-binding';
|
24
|
+
import '@babel/plugin-transform-optional-chaining';
|
25
|
+
import '@babel/plugin-transform-private-property-in-object';
|
26
|
+
import '@babel/plugin-transform-unicode-sets-regex';
|
27
|
+
import '@babel/traverse';
|
28
|
+
import '@babel/types';
|
29
|
+
import '@rollup/plugin-babel';
|
30
|
+
import '@rollup/plugin-commonjs';
|
31
|
+
import '@rollup/plugin-json';
|
32
|
+
import '@rollup/plugin-node-resolve';
|
33
|
+
import '@samual/lib/assert';
|
34
|
+
import 'prettier';
|
35
|
+
import 'rollup';
|
36
|
+
import './processScript/minify.js';
|
37
|
+
import '@samual/lib/countHackmudCharacters';
|
38
|
+
import '@samual/lib/spliceString';
|
39
|
+
import 'acorn';
|
40
|
+
import 'terser';
|
41
|
+
import './processScript/shared.js';
|
42
|
+
import './processScript/postprocess.js';
|
43
|
+
import './processScript/preprocess.js';
|
44
|
+
import 'import-meta-resolve';
|
45
|
+
import './processScript/transform.js';
|
46
|
+
import '@samual/lib/clearObject';
|
47
|
+
import '@samual/lib/copyFilePersistent';
|
48
|
+
import '@samual/lib/DynamicMap';
|
49
|
+
import '@samual/lib/writeFilePersistent';
|
50
|
+
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-7c69a3b",
|
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,58 @@
|
|
27
27
|
"url": "https://github.com/samualtnorman/hackmud-script-manager.git"
|
28
28
|
},
|
29
29
|
"dependencies": {
|
30
|
-
"@babel/
|
31
|
-
"@babel/
|
32
|
-
"@babel/
|
33
|
-
"@babel/plugin-proposal-
|
34
|
-
"@babel/plugin-proposal-
|
35
|
-
"@babel/plugin-proposal-
|
36
|
-
"@babel/plugin-proposal-
|
37
|
-
"@babel/plugin-proposal-function-
|
38
|
-
"@babel/plugin-proposal-
|
39
|
-
"@babel/plugin-proposal-
|
40
|
-
"@babel/plugin-proposal-
|
41
|
-
"@babel/plugin-proposal-
|
42
|
-
"@babel/plugin-
|
43
|
-
"@babel/plugin-
|
44
|
-
"@babel/plugin-
|
45
|
-
"@babel/plugin-
|
46
|
-
"@babel/plugin-
|
47
|
-
"@babel/plugin-
|
48
|
-
"@babel/plugin-
|
49
|
-
"@babel/plugin-
|
50
|
-
"@babel/plugin-
|
51
|
-
"@babel/plugin-transform-
|
52
|
-
"@babel/plugin-transform-
|
53
|
-
"@babel/
|
54
|
-
"@babel/
|
30
|
+
"@babel/generator": "^7.23.6",
|
31
|
+
"@babel/parser": "^7.23.6",
|
32
|
+
"@babel/plugin-proposal-decorators": "^7.23.7",
|
33
|
+
"@babel/plugin-proposal-destructuring-private": "^7.23.3",
|
34
|
+
"@babel/plugin-proposal-do-expressions": "^7.23.3",
|
35
|
+
"@babel/plugin-proposal-explicit-resource-management": "^7.23.3",
|
36
|
+
"@babel/plugin-proposal-function-bind": "^7.23.3",
|
37
|
+
"@babel/plugin-proposal-function-sent": "^7.23.3",
|
38
|
+
"@babel/plugin-proposal-partial-application": "^7.23.3",
|
39
|
+
"@babel/plugin-proposal-pipeline-operator": "^7.23.3",
|
40
|
+
"@babel/plugin-proposal-record-and-tuple": "^7.23.3",
|
41
|
+
"@babel/plugin-proposal-throw-expressions": "^7.23.3",
|
42
|
+
"@babel/plugin-transform-class-properties": "^7.23.3",
|
43
|
+
"@babel/plugin-transform-class-static-block": "^7.23.4",
|
44
|
+
"@babel/plugin-transform-exponentiation-operator": "^7.23.3",
|
45
|
+
"@babel/plugin-transform-json-strings": "^7.23.4",
|
46
|
+
"@babel/plugin-transform-logical-assignment-operators": "^7.23.4",
|
47
|
+
"@babel/plugin-transform-nullish-coalescing-operator": "^7.23.4",
|
48
|
+
"@babel/plugin-transform-numeric-separator": "^7.23.4",
|
49
|
+
"@babel/plugin-transform-object-rest-spread": "^7.23.4",
|
50
|
+
"@babel/plugin-transform-optional-catch-binding": "^7.23.4",
|
51
|
+
"@babel/plugin-transform-optional-chaining": "^7.23.4",
|
52
|
+
"@babel/plugin-transform-private-property-in-object": "^7.23.4",
|
53
|
+
"@babel/plugin-transform-typescript": "^7.23.6",
|
54
|
+
"@babel/plugin-transform-unicode-sets-regex": "^7.23.3",
|
55
|
+
"@babel/traverse": "^7.23.7",
|
56
|
+
"@babel/types": "^7.23.6",
|
55
57
|
"@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
|
-
"
|
58
|
+
"@rollup/plugin-babel": "^6.0.4",
|
59
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
60
|
+
"@rollup/plugin-json": "^6.1.0",
|
61
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
62
|
+
"@samual/lib": "^0.9.1",
|
63
|
+
"acorn": "^8.11.3",
|
64
|
+
"chalk": "^5.3.0",
|
62
65
|
"chokidar": "^3.5.3",
|
63
|
-
"import-meta-resolve": "^
|
64
|
-
"prettier": "^2.
|
66
|
+
"import-meta-resolve": "^4.0.0",
|
67
|
+
"prettier": "^3.2.2",
|
65
68
|
"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"
|
69
|
+
"rollup": "^4.9.5",
|
70
|
+
"terser": "^5.26.0"
|
94
71
|
},
|
95
72
|
"engines": {
|
96
|
-
"node": ">=
|
73
|
+
"node": ">=20"
|
97
74
|
},
|
98
|
-
"types": "index.d.ts",
|
99
75
|
"type": "module",
|
100
76
|
"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"
|
77
|
+
"./*": "./*.js",
|
78
|
+
"./*.js": "./*.js"
|
120
79
|
},
|
121
80
|
"bin": {
|
122
|
-
"hsm": "
|
81
|
+
"hsm.d": "bin/hsm.d.ts",
|
82
|
+
"hsm": "bin/hsm.js"
|
123
83
|
}
|
124
84
|
}
|
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 */
|