hackmud-script-manager 0.21.1-7b1c428 → 0.21.1-8072045
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 +20 -5
- package/env.d.ts +1 -1
- package/package.json +1 -1
- package/processScript/index.js +43 -36
- package/processScript/minify.js +4 -4
- package/processScript/preprocess.js +4 -4
- package/processScript/transform.js +8 -18
package/bin/hsm.js
CHANGED
@@ -14,6 +14,8 @@ import "@samual/lib/readDirectoryWithStats"
|
|
14
14
|
import "@samual/lib/copyFilePersistent"
|
15
15
|
const options = new Map(),
|
16
16
|
commands = []
|
17
|
+
let didParseOption = !1,
|
18
|
+
didParseOptionAfterCommand = !1
|
17
19
|
for (const argument of process.argv.slice(2))
|
18
20
|
if ("-" == argument[0]) {
|
19
21
|
const argumentEqualsIndex = argument.indexOf("=")
|
@@ -28,7 +30,11 @@ for (const argument of process.argv.slice(2))
|
|
28
30
|
}
|
29
31
|
if ("-" == argument[1]) options.set(key.slice(2), value)
|
30
32
|
else for (const option of key.slice(1)) options.set(option, value)
|
31
|
-
|
33
|
+
didParseOption = !0
|
34
|
+
} else {
|
35
|
+
didParseOption && (didParseOptionAfterCommand = !0)
|
36
|
+
commands.push(argument)
|
37
|
+
}
|
32
38
|
const pushModule = import("../push.js"),
|
33
39
|
processScriptModule = import("../processScript/index.js"),
|
34
40
|
watchModule = import("../watch.js"),
|
@@ -54,6 +60,15 @@ const pushModule = import("../push.js"),
|
|
54
60
|
return [colourJ, colourK, colourM, colourW, colourL, colourB][hash % 6](user)
|
55
61
|
}),
|
56
62
|
log = message => console.log(colourS(message))
|
63
|
+
if (didParseOptionAfterCommand) {
|
64
|
+
process.exitCode = 1
|
65
|
+
console.warn(
|
66
|
+
colourF(
|
67
|
+
chalk.bold("Warning:") +
|
68
|
+
" Options should come after commands when calling the script.\n This warning will become an error in the next minor version of HSM."
|
69
|
+
)
|
70
|
+
)
|
71
|
+
}
|
57
72
|
if (process.version.startsWith("v21.")) {
|
58
73
|
process.exitCode = 1
|
59
74
|
console.warn(
|
@@ -63,7 +78,7 @@ if (process.version.startsWith("v21.")) {
|
|
63
78
|
)
|
64
79
|
}
|
65
80
|
if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
|
66
|
-
console.log("0.21.1-
|
81
|
+
console.log("0.21.1-8072045")
|
67
82
|
process.exit()
|
68
83
|
}
|
69
84
|
let warnedDeprecatedEmitDtsAlias = !1
|
@@ -248,7 +263,7 @@ switch (commands[0]) {
|
|
248
263
|
const typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
|
249
264
|
declarationPathPromise = writeFile(typeDeclarationPath, typeDeclaration)
|
250
265
|
.catch(error => {
|
251
|
-
assert(error instanceof Error, "src/bin/hsm.ts:
|
266
|
+
assert(error instanceof Error, "src/bin/hsm.ts:318:38")
|
252
267
|
if ("EISDIR" != error.code) throw error
|
253
268
|
typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
|
254
269
|
return writeFile(typeDeclarationPath, typeDeclaration)
|
@@ -330,7 +345,7 @@ switch (commands[0]) {
|
|
330
345
|
typeDeclaration = await generateTypeDeclaration(sourcePath, hackmudPath)
|
331
346
|
let typeDeclarationPath = resolve(outputPath)
|
332
347
|
await writeFile(typeDeclarationPath, typeDeclaration).catch(error => {
|
333
|
-
assert(error instanceof Error, "src/bin/hsm.ts:
|
348
|
+
assert(error instanceof Error, "src/bin/hsm.ts:462:35")
|
334
349
|
if ("EISDIR" != error.code) throw error
|
335
350
|
typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
|
336
351
|
return writeFile(typeDeclarationPath, typeDeclaration)
|
@@ -403,7 +418,7 @@ function logHelp() {
|
|
403
418
|
default:
|
404
419
|
console.log(
|
405
420
|
colourS(
|
406
|
-
`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-
|
421
|
+
`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-8072045")}\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`
|
407
422
|
)
|
408
423
|
)
|
409
424
|
}
|
package/env.d.ts
CHANGED
package/package.json
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
{
|
2
2
|
"name": "hackmud-script-manager",
|
3
3
|
"type": "module",
|
4
|
-
"version": "0.21.1-
|
4
|
+
"version": "0.21.1-8072045",
|
5
5
|
"description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
|
6
6
|
"author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
|
7
7
|
"contributors": [
|
package/processScript/index.js
CHANGED
@@ -1,22 +1,22 @@
|
|
1
1
|
import { relative, isAbsolute, sep } from "path"
|
2
|
-
import
|
2
|
+
import f32fhtc0ktfq84afkvak6xwp from "@babel/generator"
|
3
3
|
import { parse } from "@babel/parser"
|
4
|
-
import
|
5
|
-
import
|
6
|
-
import
|
7
|
-
import
|
8
|
-
import
|
9
|
-
import
|
10
|
-
import
|
11
|
-
import
|
12
|
-
import
|
13
|
-
import
|
14
|
-
import
|
15
|
-
import
|
16
|
-
import
|
17
|
-
import
|
18
|
-
import
|
19
|
-
import
|
4
|
+
import jt6w4z2lvmfkblngexw9l9wg from "@babel/plugin-proposal-decorators"
|
5
|
+
import zcaqhzusgvsoi2gishyb72to from "@babel/plugin-proposal-destructuring-private"
|
6
|
+
import xes6d3s5rum7xj224qugy7on from "@babel/plugin-proposal-explicit-resource-management"
|
7
|
+
import dd0rqe9346tamfbxyvddl4yj from "@babel/plugin-transform-class-properties"
|
8
|
+
import wx29ry6muzcjh9n9g62r95gu from "@babel/plugin-transform-class-static-block"
|
9
|
+
import qcwwih7yuelcgp2zsloqnjr4 from "@babel/plugin-transform-exponentiation-operator"
|
10
|
+
import ez19e21mz73mll9wxfykyw07 from "@babel/plugin-transform-json-strings"
|
11
|
+
import vd7myomkrcmcfpm93nrx9kkc from "@babel/plugin-transform-logical-assignment-operators"
|
12
|
+
import mw53z57ogk4k0qxaulqs7hur from "@babel/plugin-transform-nullish-coalescing-operator"
|
13
|
+
import oox83tsy1y6a31sqju1hrmsx from "@babel/plugin-transform-numeric-separator"
|
14
|
+
import b8fc1ommbmr91idzubf822m5 from "@babel/plugin-transform-object-rest-spread"
|
15
|
+
import txofwbtd4i8fitzwb4zvrj3e from "@babel/plugin-transform-optional-catch-binding"
|
16
|
+
import q40h63iq1x13ej9z1p5o7nz7 from "@babel/plugin-transform-optional-chaining"
|
17
|
+
import pztmuxbkqlwf2wb0pt40zy6w from "@babel/plugin-transform-private-property-in-object"
|
18
|
+
import aic8ut1pgdh3ic5p295ge7y4 from "@babel/plugin-transform-unicode-sets-regex"
|
19
|
+
import bllgrfz6aotgd3ezg3mw89jw from "@babel/traverse"
|
20
20
|
import t from "@babel/types"
|
21
21
|
import rollupPluginAlias from "@rollup/plugin-alias"
|
22
22
|
import { babel } from "@rollup/plugin-babel"
|
@@ -38,23 +38,23 @@ import "acorn"
|
|
38
38
|
import "terser"
|
39
39
|
import "import-meta-resolve"
|
40
40
|
import "@samual/lib/clearObject"
|
41
|
-
const generate =
|
42
|
-
babelPluginProposalDecorators =
|
43
|
-
babelPluginProposalDestructuringPrivate =
|
44
|
-
babelPluginProposalExplicitResourceManagement =
|
45
|
-
babelPluginTransformClassProperties =
|
46
|
-
babelPluginTransformClassStaticBlock =
|
47
|
-
babelPluginTransformExponentiationOperator =
|
48
|
-
babelPluginTransformJsonStrings =
|
49
|
-
babelPluginTransformLogicalAssignmentOperators =
|
50
|
-
babelPluginTransformNullishCoalescingOperator =
|
51
|
-
babelPluginTransformNumericSeparator =
|
52
|
-
babelPluginTransformObjectRestSpread =
|
53
|
-
babelPluginTransformOptionalCatchBinding =
|
54
|
-
babelPluginTransformOptionalChaining =
|
55
|
-
babelPluginTransformPrivatePropertyInObject =
|
56
|
-
babelPluginTransformUnicodeSetsRegex =
|
57
|
-
traverse =
|
41
|
+
const generate = f32fhtc0ktfq84afkvak6xwp.default,
|
42
|
+
babelPluginProposalDecorators = jt6w4z2lvmfkblngexw9l9wg.default,
|
43
|
+
babelPluginProposalDestructuringPrivate = zcaqhzusgvsoi2gishyb72to.default,
|
44
|
+
babelPluginProposalExplicitResourceManagement = xes6d3s5rum7xj224qugy7on.default,
|
45
|
+
babelPluginTransformClassProperties = dd0rqe9346tamfbxyvddl4yj.default,
|
46
|
+
babelPluginTransformClassStaticBlock = wx29ry6muzcjh9n9g62r95gu.default,
|
47
|
+
babelPluginTransformExponentiationOperator = qcwwih7yuelcgp2zsloqnjr4.default,
|
48
|
+
babelPluginTransformJsonStrings = ez19e21mz73mll9wxfykyw07.default,
|
49
|
+
babelPluginTransformLogicalAssignmentOperators = vd7myomkrcmcfpm93nrx9kkc.default,
|
50
|
+
babelPluginTransformNullishCoalescingOperator = mw53z57ogk4k0qxaulqs7hur.default,
|
51
|
+
babelPluginTransformNumericSeparator = oox83tsy1y6a31sqju1hrmsx.default,
|
52
|
+
babelPluginTransformObjectRestSpread = b8fc1ommbmr91idzubf822m5.default,
|
53
|
+
babelPluginTransformOptionalCatchBinding = txofwbtd4i8fitzwb4zvrj3e.default,
|
54
|
+
babelPluginTransformOptionalChaining = q40h63iq1x13ej9z1p5o7nz7.default,
|
55
|
+
babelPluginTransformPrivatePropertyInObject = pztmuxbkqlwf2wb0pt40zy6w.default,
|
56
|
+
babelPluginTransformUnicodeSetsRegex = aic8ut1pgdh3ic5p295ge7y4.default,
|
57
|
+
traverse = bllgrfz6aotgd3ezg3mw89jw.default,
|
58
58
|
{ format } = prettier
|
59
59
|
async function processScript(
|
60
60
|
code,
|
@@ -224,7 +224,14 @@ async function processScript(
|
|
224
224
|
rollupPluginJSON({ preferConst: !0 }),
|
225
225
|
{
|
226
226
|
name: "hackmud-script-manager",
|
227
|
+
resolveId(source) {
|
228
|
+
if (source == filePathResolved) return filePathResolved
|
229
|
+
},
|
230
|
+
async load(id) {
|
231
|
+
if (id == filePathResolved) return (await preprocess(code, { uniqueId })).code
|
232
|
+
},
|
227
233
|
async transform(code, id) {
|
234
|
+
if (id == filePathResolved) return
|
228
235
|
if (isAbsolute(id) && !id.includes(`${sep}node_modules${sep}`))
|
229
236
|
return (await preprocess(code, { uniqueId })).code
|
230
237
|
let program
|
@@ -268,7 +275,7 @@ async function processScript(
|
|
268
275
|
traverse(file, {
|
269
276
|
MemberExpression({ node: memberExpression }) {
|
270
277
|
if (!memberExpression.computed) {
|
271
|
-
assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:
|
278
|
+
assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:336:60")
|
272
279
|
if ("prototype" == memberExpression.property.name) {
|
273
280
|
memberExpression.computed = !0
|
274
281
|
memberExpression.property = t.stringLiteral("prototype")
|
@@ -298,7 +305,7 @@ async function processScript(
|
|
298
305
|
break
|
299
306
|
case "ObjectPattern":
|
300
307
|
for (const property of lValue.properties) {
|
301
|
-
assert("ObjectProperty" == property.type, "src/processScript/index.ts:
|
308
|
+
assert("ObjectProperty" == property.type, "src/processScript/index.ts:367:51")
|
302
309
|
renameVariables(property.value)
|
303
310
|
}
|
304
311
|
break
|
package/processScript/minify.js
CHANGED
@@ -1,5 +1,5 @@
|
|
1
|
-
import
|
2
|
-
import
|
1
|
+
import f32fhtc0ktfq84afkvak6xwp from "@babel/generator"
|
2
|
+
import bllgrfz6aotgd3ezg3mw89jw 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,8 +7,8 @@ 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 generate =
|
11
|
-
traverse =
|
10
|
+
const generate = f32fhtc0ktfq84afkvak6xwp.default,
|
11
|
+
traverse = bllgrfz6aotgd3ezg3mw89jw.default,
|
12
12
|
minifyNumber = async number =>
|
13
13
|
/\$\((?<number>.+)\)/.exec((await terser.minify(`$(${number})`, { ecma: 2015 })).code).groups.number
|
14
14
|
async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQuineCheats, autocomplete } = {}) {
|
@@ -1,12 +1,12 @@
|
|
1
|
-
import
|
1
|
+
import f32fhtc0ktfq84afkvak6xwp from "@babel/generator"
|
2
2
|
import { parse } from "@babel/parser"
|
3
|
-
import
|
3
|
+
import bllgrfz6aotgd3ezg3mw89jw 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 generate =
|
9
|
-
traverse =
|
8
|
+
const generate = f32fhtc0ktfq84afkvak6xwp.default,
|
9
|
+
traverse = bllgrfz6aotgd3ezg3mw89jw.default
|
10
10
|
async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
11
11
|
assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:20:36")
|
12
12
|
const sourceCode = code
|
@@ -1,10 +1,10 @@
|
|
1
|
-
import
|
1
|
+
import bllgrfz6aotgd3ezg3mw89jw 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 traverse =
|
7
|
+
const traverse = bllgrfz6aotgd3ezg3mw89jw.default,
|
8
8
|
globalFunctionsUnder7Characters = [
|
9
9
|
"Map",
|
10
10
|
"Set",
|
@@ -723,17 +723,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
|
|
723
723
|
!parent.superClass && thisIsReferenced && (parent.superClass = t.identifier("Object"))
|
724
724
|
},
|
725
725
|
VariableDeclaration({ node: variableDeclaration }) {
|
726
|
-
|
727
|
-
variableDeclaration.kind = "let"
|
728
|
-
variableDeclaration.extra = { ...variableDeclaration.extra, usedToBeConst: !0 }
|
729
|
-
}
|
730
|
-
},
|
731
|
-
AssignmentExpression({ node: assignment, scope }) {
|
732
|
-
const lhs = assignment.left
|
733
|
-
if ("Identifier" != lhs.type) return
|
734
|
-
const binding = scope.getBinding(lhs.name)
|
735
|
-
if (binding?.path?.parentPath?.node?.extra?.usedToBeConst)
|
736
|
-
throw Error(`Reassignment to const variable ${lhs.name} is not allowed!`)
|
726
|
+
"const" == variableDeclaration.kind && (variableDeclaration.kind = "let")
|
737
727
|
},
|
738
728
|
ThisExpression: path => {
|
739
729
|
path.replaceWith(t.identifier("undefined"))
|
@@ -759,23 +749,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
|
|
759
749
|
}
|
760
750
|
function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
|
761
751
|
for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
|
762
|
-
assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:
|
752
|
+
assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:924:60")
|
763
753
|
assert("Identifier" == referencePath.parent.property.type)
|
764
754
|
assert(
|
765
755
|
"MemberExpression" == referencePath.parentPath.parentPath?.node.type,
|
766
|
-
"src/processScript/transform.ts:
|
756
|
+
"src/processScript/transform.ts:926:81"
|
767
757
|
)
|
768
758
|
assert(
|
769
759
|
"Identifier" == referencePath.parentPath.parentPath.node.property.type,
|
770
|
-
"src/processScript/transform.ts:
|
760
|
+
"src/processScript/transform.ts:927:83"
|
771
761
|
)
|
772
762
|
assert(
|
773
763
|
/^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
|
774
|
-
`src/processScript/transform.ts:
|
764
|
+
`src/processScript/transform.ts:931:8 invalid user "${referencePath.parent.property.name}" in subscript`
|
775
765
|
)
|
776
766
|
assert(
|
777
767
|
/^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
|
778
|
-
`src/processScript/transform.ts:
|
768
|
+
`src/processScript/transform.ts:936:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
|
779
769
|
)
|
780
770
|
if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
|
781
771
|
referencePath.parentPath.parentPath.replaceWith(
|