hackmud-script-manager 0.21.1-628a731 → 0.21.1-698970b

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 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
- } else commands.push(argument)
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-628a731")
81
+ console.log("0.21.1-698970b")
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:300:38")
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:444:35")
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-628a731")}\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`
421
+ `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-698970b")}\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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
3
  "type": "module",
4
- "version": "0.21.1-628a731",
4
+ "version": "0.21.1-698970b",
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": [
@@ -12,10 +12,7 @@
12
12
  ],
13
13
  "license": "MIT",
14
14
  "homepage": "https://github.com/samualtnorman/hackmud-script-manager#readme",
15
- "repository": {
16
- "type": "git",
17
- "url": "https://github.com/samualtnorman/hackmud-script-manager.git"
18
- },
15
+ "repository": "github:samualtnorman/hackmud-script-manager",
19
16
  "bugs": "https://github.com/samualtnorman/hackmud-script-manager/issues",
20
17
  "keywords": [
21
18
  "api",
@@ -1,22 +1,22 @@
1
1
  import { relative, isAbsolute, sep } from "path"
2
- import aebzhxabshj61x7158qbcn2x from "@babel/generator"
2
+ import o8o18ueduqgposmxo6khc98u from "@babel/generator"
3
3
  import { parse } from "@babel/parser"
4
- import s2ijmvl7wzm8x394g1t9hy8q from "@babel/plugin-proposal-decorators"
5
- import ol4uaa84wjloic2wsoi6umo8 from "@babel/plugin-proposal-destructuring-private"
6
- import cbsvdf0g10wznhaefq3xse17 from "@babel/plugin-proposal-explicit-resource-management"
7
- import j07gcj286yuti7d039w8qp0u from "@babel/plugin-transform-class-properties"
8
- import upwk5e6zb7t9muf3l9ti8udk from "@babel/plugin-transform-class-static-block"
9
- import fpgic0shirjc7nvp6qxdbs8u from "@babel/plugin-transform-exponentiation-operator"
10
- import f5ic1rjer9khd55x2hcf00m1 from "@babel/plugin-transform-json-strings"
11
- import k1omyve9bniu90tg7tbjt9vk from "@babel/plugin-transform-logical-assignment-operators"
12
- import yhl3lcharmsmfpq182cxrptq from "@babel/plugin-transform-nullish-coalescing-operator"
13
- import mlyvai1hug0j9bjtom8lyrkp from "@babel/plugin-transform-numeric-separator"
14
- import y62i7opsnlr2x3j4qu1ufsvv from "@babel/plugin-transform-object-rest-spread"
15
- import n5vivjwibw69juzwbc941n4e from "@babel/plugin-transform-optional-catch-binding"
16
- import tw1r15cx7xxc8faz7rt7jva9 from "@babel/plugin-transform-optional-chaining"
17
- import ik82kk7qeg2vi4ycdwkqr0ws from "@babel/plugin-transform-private-property-in-object"
18
- import ea48loi9ddodrbpp8w2ei0uh from "@babel/plugin-transform-unicode-sets-regex"
19
- import lc792rc2i7ecp4gwhh6mo7ge from "@babel/traverse"
4
+ import yerg92h3xef0pxntmentis4x from "@babel/plugin-proposal-decorators"
5
+ import bte791wmvheh6c8duknw52o8 from "@babel/plugin-proposal-destructuring-private"
6
+ import hh8bh9as603wznftfw598ev4 from "@babel/plugin-proposal-explicit-resource-management"
7
+ import mw6tmscbfy336xel0wwko3m5 from "@babel/plugin-transform-class-properties"
8
+ import hqa52cv6hq1ln2kxplifj0vt from "@babel/plugin-transform-class-static-block"
9
+ import kue2jd7y9faemw8fy3f873jc from "@babel/plugin-transform-exponentiation-operator"
10
+ import rla2xnm97c6qkc9c3lugzrsn from "@babel/plugin-transform-json-strings"
11
+ import yrmvvy1iqsvv49eiqoaiagw1 from "@babel/plugin-transform-logical-assignment-operators"
12
+ import u3y6roa2q93oh9vgn7fh5bp8 from "@babel/plugin-transform-nullish-coalescing-operator"
13
+ import q5clnfu3mx2a2utmxqlodg7x from "@babel/plugin-transform-numeric-separator"
14
+ import w96tm2oib174p8k4grehe3y1 from "@babel/plugin-transform-object-rest-spread"
15
+ import zk6pwiooyiv76c30twyn2zhq from "@babel/plugin-transform-optional-catch-binding"
16
+ import l8e6321b0ayw5a4k0tzzxigq from "@babel/plugin-transform-optional-chaining"
17
+ import nmo6kym6bvsq78mjyglii3dt from "@babel/plugin-transform-private-property-in-object"
18
+ import b87sx47xj4o4ode3kr2ona7l from "@babel/plugin-transform-unicode-sets-regex"
19
+ import gpiwud5ibbmji5fxkev1yx1i 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 = aebzhxabshj61x7158qbcn2x.default,
42
- babelPluginProposalDecorators = s2ijmvl7wzm8x394g1t9hy8q.default,
43
- babelPluginProposalDestructuringPrivate = ol4uaa84wjloic2wsoi6umo8.default,
44
- babelPluginProposalExplicitResourceManagement = cbsvdf0g10wznhaefq3xse17.default,
45
- babelPluginTransformClassProperties = j07gcj286yuti7d039w8qp0u.default,
46
- babelPluginTransformClassStaticBlock = upwk5e6zb7t9muf3l9ti8udk.default,
47
- babelPluginTransformExponentiationOperator = fpgic0shirjc7nvp6qxdbs8u.default,
48
- babelPluginTransformJsonStrings = f5ic1rjer9khd55x2hcf00m1.default,
49
- babelPluginTransformLogicalAssignmentOperators = k1omyve9bniu90tg7tbjt9vk.default,
50
- babelPluginTransformNullishCoalescingOperator = yhl3lcharmsmfpq182cxrptq.default,
51
- babelPluginTransformNumericSeparator = mlyvai1hug0j9bjtom8lyrkp.default,
52
- babelPluginTransformObjectRestSpread = y62i7opsnlr2x3j4qu1ufsvv.default,
53
- babelPluginTransformOptionalCatchBinding = n5vivjwibw69juzwbc941n4e.default,
54
- babelPluginTransformOptionalChaining = tw1r15cx7xxc8faz7rt7jva9.default,
55
- babelPluginTransformPrivatePropertyInObject = ik82kk7qeg2vi4ycdwkqr0ws.default,
56
- babelPluginTransformUnicodeSetsRegex = ea48loi9ddodrbpp8w2ei0uh.default,
57
- traverse = lc792rc2i7ecp4gwhh6mo7ge.default,
41
+ const generate = o8o18ueduqgposmxo6khc98u.default,
42
+ babelPluginProposalDecorators = yerg92h3xef0pxntmentis4x.default,
43
+ babelPluginProposalDestructuringPrivate = bte791wmvheh6c8duknw52o8.default,
44
+ babelPluginProposalExplicitResourceManagement = hh8bh9as603wznftfw598ev4.default,
45
+ babelPluginTransformClassProperties = mw6tmscbfy336xel0wwko3m5.default,
46
+ babelPluginTransformClassStaticBlock = hqa52cv6hq1ln2kxplifj0vt.default,
47
+ babelPluginTransformExponentiationOperator = kue2jd7y9faemw8fy3f873jc.default,
48
+ babelPluginTransformJsonStrings = rla2xnm97c6qkc9c3lugzrsn.default,
49
+ babelPluginTransformLogicalAssignmentOperators = yrmvvy1iqsvv49eiqoaiagw1.default,
50
+ babelPluginTransformNullishCoalescingOperator = u3y6roa2q93oh9vgn7fh5bp8.default,
51
+ babelPluginTransformNumericSeparator = q5clnfu3mx2a2utmxqlodg7x.default,
52
+ babelPluginTransformObjectRestSpread = w96tm2oib174p8k4grehe3y1.default,
53
+ babelPluginTransformOptionalCatchBinding = zk6pwiooyiv76c30twyn2zhq.default,
54
+ babelPluginTransformOptionalChaining = l8e6321b0ayw5a4k0tzzxigq.default,
55
+ babelPluginTransformPrivatePropertyInObject = nmo6kym6bvsq78mjyglii3dt.default,
56
+ babelPluginTransformUnicodeSetsRegex = b87sx47xj4o4ode3kr2ona7l.default,
57
+ traverse = gpiwud5ibbmji5fxkev1yx1i.default,
58
58
  { format } = prettier
59
59
  async function processScript(
60
60
  code,
@@ -154,7 +154,7 @@ async function processScript(
154
154
  if (filePath) {
155
155
  filePathResolved = relative(".", filePath)
156
156
  if (filePath.endsWith(".ts"))
157
- plugins.push([
157
+ plugins.unshift([
158
158
  await import("@babel/plugin-transform-typescript").then(module => module.default),
159
159
  { allowDeclareFields: !0, optimizeConstEnums: !0 }
160
160
  ])
@@ -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:325:60")
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:356:51")
308
+ assert("ObjectProperty" == property.type, "src/processScript/index.ts:367:51")
302
309
  renameVariables(property.value)
303
310
  }
304
311
  break
@@ -1,5 +1,5 @@
1
- import aebzhxabshj61x7158qbcn2x from "@babel/generator"
2
- import lc792rc2i7ecp4gwhh6mo7ge from "@babel/traverse"
1
+ import o8o18ueduqgposmxo6khc98u from "@babel/generator"
2
+ import gpiwud5ibbmji5fxkev1yx1i 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 = aebzhxabshj61x7158qbcn2x.default,
11
- traverse = lc792rc2i7ecp4gwhh6mo7ge.default,
10
+ const generate = o8o18ueduqgposmxo6khc98u.default,
11
+ traverse = gpiwud5ibbmji5fxkev1yx1i.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 aebzhxabshj61x7158qbcn2x from "@babel/generator"
1
+ import o8o18ueduqgposmxo6khc98u from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
- import lc792rc2i7ecp4gwhh6mo7ge from "@babel/traverse"
3
+ import gpiwud5ibbmji5fxkev1yx1i 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 = aebzhxabshj61x7158qbcn2x.default,
9
- traverse = lc792rc2i7ecp4gwhh6mo7ge.default
8
+ const generate = o8o18ueduqgposmxo6khc98u.default,
9
+ traverse = gpiwud5ibbmji5fxkev1yx1i.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 lc792rc2i7ecp4gwhh6mo7ge from "@babel/traverse"
1
+ import gpiwud5ibbmji5fxkev1yx1i 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 = lc792rc2i7ecp4gwhh6mo7ge.default,
7
+ const traverse = gpiwud5ibbmji5fxkev1yx1i.default,
8
8
  globalFunctionsUnder7Characters = [
9
9
  "Map",
10
10
  "Set",
@@ -652,6 +652,18 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
652
652
  for (const classMethod of classBody.body) {
653
653
  if ("ClassMethod" != classMethod.type) continue
654
654
  let methodReferencesThis = !1
655
+ for (const param of classMethod.params)
656
+ traverse(
657
+ param,
658
+ {
659
+ ThisExpression(path) {
660
+ path.replaceWith(
661
+ t.callExpression(t.memberExpression(t.super(), t.identifier("valueOf")), [])
662
+ )
663
+ }
664
+ },
665
+ scope
666
+ )
655
667
  traverse(
656
668
  classMethod.body,
657
669
  {
@@ -723,17 +735,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
723
735
  !parent.superClass && thisIsReferenced && (parent.superClass = t.identifier("Object"))
724
736
  },
725
737
  VariableDeclaration({ node: variableDeclaration }) {
726
- if ("const" == variableDeclaration.kind) {
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!`)
738
+ "const" == variableDeclaration.kind && (variableDeclaration.kind = "let")
737
739
  },
738
740
  ThisExpression: path => {
739
741
  path.replaceWith(t.identifier("undefined"))