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 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-7b1c428")
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: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-7b1c428")}\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-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
@@ -175,7 +175,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
175
175
  /** **FULLSEC** */ trust: () => string[]
176
176
 
177
177
  /**
178
- * FULLSEC
178
+ * **FULLSEC*
179
179
  * @returns A code library containing useful helper functions you can use in your scripts.
180
180
  */
181
181
  lib: () => {
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-7b1c428",
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": [
@@ -1,22 +1,22 @@
1
1
  import { relative, isAbsolute, sep } from "path"
2
- import ujn0486i81rdajkphgiudnap from "@babel/generator"
2
+ import f32fhtc0ktfq84afkvak6xwp from "@babel/generator"
3
3
  import { parse } from "@babel/parser"
4
- import k7psang1tpz6eabjq703p3fk from "@babel/plugin-proposal-decorators"
5
- import zzu2uq45qpzok1b0f8718uhx from "@babel/plugin-proposal-destructuring-private"
6
- import zxpe7ef02ayjtbwsjvszb4mz from "@babel/plugin-proposal-explicit-resource-management"
7
- import xdorc4ryiyx33mosyoa35iic from "@babel/plugin-transform-class-properties"
8
- import qx70bas1wirb7m11mfdaogbc from "@babel/plugin-transform-class-static-block"
9
- import rndfrm5y6pet5wd1uwhn6h54 from "@babel/plugin-transform-exponentiation-operator"
10
- import jxueey10fuzmzucqrpmmjklg from "@babel/plugin-transform-json-strings"
11
- import rdg7sp217wwj9qugx0scn1rl from "@babel/plugin-transform-logical-assignment-operators"
12
- import afxcwva4rno5psdkcom9d2nc from "@babel/plugin-transform-nullish-coalescing-operator"
13
- import zqpmfoxz86cwrp3gooc0ji7a from "@babel/plugin-transform-numeric-separator"
14
- import ubzsbocw1kcavjhbi7fzbcxh from "@babel/plugin-transform-object-rest-spread"
15
- import ih33abnhwii5jbm2j43p0cg9 from "@babel/plugin-transform-optional-catch-binding"
16
- import nbp9xeigug4d5vshp4xt9de2 from "@babel/plugin-transform-optional-chaining"
17
- import jb9rvv8koat2j4wm3jejkbi8 from "@babel/plugin-transform-private-property-in-object"
18
- import hc3x7aq9lzptn9r7h4wo3vdg from "@babel/plugin-transform-unicode-sets-regex"
19
- import gxvr3xnjdibxqznvmlpo69ws from "@babel/traverse"
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 = ujn0486i81rdajkphgiudnap.default,
42
- babelPluginProposalDecorators = k7psang1tpz6eabjq703p3fk.default,
43
- babelPluginProposalDestructuringPrivate = zzu2uq45qpzok1b0f8718uhx.default,
44
- babelPluginProposalExplicitResourceManagement = zxpe7ef02ayjtbwsjvszb4mz.default,
45
- babelPluginTransformClassProperties = xdorc4ryiyx33mosyoa35iic.default,
46
- babelPluginTransformClassStaticBlock = qx70bas1wirb7m11mfdaogbc.default,
47
- babelPluginTransformExponentiationOperator = rndfrm5y6pet5wd1uwhn6h54.default,
48
- babelPluginTransformJsonStrings = jxueey10fuzmzucqrpmmjklg.default,
49
- babelPluginTransformLogicalAssignmentOperators = rdg7sp217wwj9qugx0scn1rl.default,
50
- babelPluginTransformNullishCoalescingOperator = afxcwva4rno5psdkcom9d2nc.default,
51
- babelPluginTransformNumericSeparator = zqpmfoxz86cwrp3gooc0ji7a.default,
52
- babelPluginTransformObjectRestSpread = ubzsbocw1kcavjhbi7fzbcxh.default,
53
- babelPluginTransformOptionalCatchBinding = ih33abnhwii5jbm2j43p0cg9.default,
54
- babelPluginTransformOptionalChaining = nbp9xeigug4d5vshp4xt9de2.default,
55
- babelPluginTransformPrivatePropertyInObject = jb9rvv8koat2j4wm3jejkbi8.default,
56
- babelPluginTransformUnicodeSetsRegex = hc3x7aq9lzptn9r7h4wo3vdg.default,
57
- traverse = gxvr3xnjdibxqznvmlpo69ws.default,
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: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 ujn0486i81rdajkphgiudnap from "@babel/generator"
2
- import gxvr3xnjdibxqznvmlpo69ws from "@babel/traverse"
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 = ujn0486i81rdajkphgiudnap.default,
11
- traverse = gxvr3xnjdibxqznvmlpo69ws.default,
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 ujn0486i81rdajkphgiudnap from "@babel/generator"
1
+ import f32fhtc0ktfq84afkvak6xwp from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
- import gxvr3xnjdibxqznvmlpo69ws from "@babel/traverse"
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 = ujn0486i81rdajkphgiudnap.default,
9
- traverse = gxvr3xnjdibxqznvmlpo69ws.default
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 gxvr3xnjdibxqznvmlpo69ws from "@babel/traverse"
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 = gxvr3xnjdibxqznvmlpo69ws.default,
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
- 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!`)
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:937:60")
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:939:81"
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:940:83"
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:944:8 invalid user "${referencePath.parent.property.name}" in subscript`
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:949:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
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(