hackmud-script-manager 0.21.0 → 0.21.1-24be49c
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/README.md +1 -1
- package/bin/hsm.js +2 -2
- package/package.json +1 -1
- package/processScript/preprocess.js +15 -3
package/README.md
CHANGED
@@ -12,7 +12,7 @@ You can read about how HSM works [in my blog post](https://samual.uk/blog/js-cod
|
|
12
12
|
## Usage
|
13
13
|
1. Run `#dir` in game, then `cd` to that folder
|
14
14
|
2. Name your source script file to `<name>.src.js`
|
15
|
-
3. Run `hsm
|
15
|
+
3. Run `hsm minify <name>.src.js` and it will create a minified script file called `<name>.js`
|
16
16
|
|
17
17
|
> **NOTE:** If you get an error message that looks like this:
|
18
18
|
> ```
|
package/bin/hsm.js
CHANGED
@@ -62,7 +62,7 @@ process.version.startsWith("v21.") &&
|
|
62
62
|
)
|
63
63
|
)
|
64
64
|
if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
|
65
|
-
console.log("0.21.
|
65
|
+
console.log("0.21.1-24be49c")
|
66
66
|
process.exit()
|
67
67
|
}
|
68
68
|
let warnedDeprecatedEmitDtsAlias = !1
|
@@ -403,7 +403,7 @@ function logHelp() {
|
|
403
403
|
default:
|
404
404
|
console.log(
|
405
405
|
colourS(
|
406
|
-
`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.
|
406
|
+
`${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-24be49c")}\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
407
|
)
|
408
408
|
)
|
409
409
|
}
|
package/package.json
CHANGED
@@ -4,11 +4,23 @@ import babelTraverse 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
|
+
import { tokenizer, tokTypes } from "acorn"
|
7
8
|
import { resolve } from "import-meta-resolve"
|
8
9
|
const { default: traverse } = babelTraverse,
|
9
|
-
{ default: generate } = babelGenerator
|
10
|
+
{ default: generate } = babelGenerator,
|
11
|
+
SUBSCRIPT_PREFIXES = ["s", "fs", "4s", "hs", "3s", "ms", "2s", "ls", "1s", "ns", "0s"]
|
10
12
|
async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
11
|
-
assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:
|
13
|
+
assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:26:36")
|
14
|
+
const tokensIterable = tokenizer(code, { ecmaVersion: "latest" })
|
15
|
+
for (const token of tokensIterable) {
|
16
|
+
assert("value" in token, "src/processScript/preprocess.ts:31:28")
|
17
|
+
if (token.type != tokTypes.privateId) continue
|
18
|
+
assert("string" == typeof token.value, "src/processScript/preprocess.ts:36:42")
|
19
|
+
if (!SUBSCRIPT_PREFIXES.includes(token.value)) continue
|
20
|
+
const nextToken = tokensIterable.getToken()
|
21
|
+
if (nextToken.type != tokTypes._in && nextToken.type != tokTypes.dot)
|
22
|
+
throw SyntaxError("Subscripts must be in the form of #fs.foo.bar")
|
23
|
+
}
|
12
24
|
const sourceCode = code
|
13
25
|
let lengthBefore, file, program
|
14
26
|
do {
|
@@ -47,7 +59,7 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
|
|
47
59
|
})
|
48
60
|
break
|
49
61
|
} catch (error_) {
|
50
|
-
assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:
|
62
|
+
assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:89:42")
|
51
63
|
error = error_
|
52
64
|
}
|
53
65
|
if ("BABEL_PARSER_SYNTAX_ERROR" != error.code || "PrivateInExpectedIn" != error.reasonCode) {
|