hackmud-script-manager 0.21.1-c61c24e → 0.21.1-d4bf990

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 CHANGED
@@ -1,6 +1,8 @@
1
1
  # Hackmud Script Manager
2
2
  Command made for [Hackmud Scripting Environment](https://github.com/samualtnorman/hackmud-environment), which is a scripting environment for hackmud with minification, autocompletes / intellisense, and TypeScript support.
3
3
 
4
+ Join [our Discord server](https://discord.gg/RSa4Sc6pNA)!
5
+
4
6
  [![ko-fi](https://ko-fi.com/img/githubbutton_sm.svg)](https://ko-fi.com/R6R0XN5CX)
5
7
 
6
8
  You can read about how HSM works [in my blog post](https://samual.uk/blog/js-code-transformation-niche-environment/).
package/bin/hsm.js CHANGED
@@ -11,7 +11,6 @@ import { generateTypeDeclaration } from "../generateTypeDeclaration.js"
11
11
  import { pull } from "../pull.js"
12
12
  import { syncMacros } from "../syncMacros.js"
13
13
  import "@samual/lib/readDirectoryWithStats"
14
- import "path/posix"
15
14
  import "@samual/lib/copyFilePersistent"
16
15
  const formatOption = name => colourN(`-${1 == name.length ? "" : "-"}${name}`),
17
16
  options = new Map(),
@@ -64,7 +63,7 @@ if (process.version.startsWith("v21.")) {
64
63
  )
65
64
  }
66
65
  if ("v" == commands[0] || "version" == commands[0] || popOption("version", "v")?.value) {
67
- console.log("0.21.1-c61c24e")
66
+ console.log("0.21.1-d4bf990")
68
67
  process.exit()
69
68
  }
70
69
  let warnedDeprecatedEmitDtsAlias = !1
@@ -412,7 +411,7 @@ function logHelp() {
412
411
  default:
413
412
  console.log(
414
413
  colourS(
415
- `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-c61c24e")}\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`
414
+ `${colourJ("Hackmud Script Manager")}\n${colourN("Version") + colourS(": ") + colourV("0.21.1-d4bf990")}\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`
416
415
  )
417
416
  )
418
417
  }
package/env.d.ts CHANGED
@@ -699,7 +699,7 @@ type Nullsec = Lowsec & PlayerNullsec & {
699
699
  // database
700
700
  type MongoPrimitive = null | boolean | number | Date | string
701
701
  type MongoValue = MongoPrimitive | MongoValue[] | MongoObject
702
- type MongoObject = { [k: string]: MongoValue, [k: `$${string}`]: never }
702
+ type MongoObject = { [k: string]: MongoValue }
703
703
  type MongoQueryValue = MongoPrimitive | MongoQueryValue[] | MongoQueryObject
704
704
 
705
705
  type MongoQueryObject =
@@ -755,11 +755,16 @@ type MongoQuerySelector<T extends MongoValue> = Partial<
755
755
 
756
756
  type MongoQuery<T extends MongoObject> = { [K in keyof T]?: T[K] | MongoQuerySelector<T[K]> } & { _id?: MongoId }
757
757
 
758
- type MongoUpdateOperators<T extends MongoObject> = Partial<{
758
+ type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
759
+
760
+ type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
761
+ { $position?: number, $slice?: number, $sort?: 1 | -1 }
762
+
763
+ type MongoUpdateCommand<T extends MongoObject> = Partial<{
759
764
  /* Universal operators */
760
- $set: Partial<Record<string, MongoCommandValue> & T>
761
- $setOnInsert: Partial<Record<string, MongoCommandValue> & T>
762
- $unset: Partial<Record<string, ""> & T>
765
+ $set: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
766
+ $setOnInsert: Partial<Record<(string & {}) | keyof T, MongoCommandValue>>
767
+ $unset: Partial<Record<(string & {}) | keyof T, "">>
763
768
 
764
769
  $rename: Partial<Record<string, string> & { [key in keyof T]: string }>
765
770
 
@@ -792,13 +797,6 @@ type MongoUpdateOperators<T extends MongoObject> = Partial<{
792
797
  $pullAll: Record<string, MongoCommandValue> & { [K in keyof T as T[K] extends [] ? K : never]?: T[K] }
793
798
  }>
794
799
 
795
- type MongoUpdateArrayOperatorUniversalModifiers<T> = { $each?: T extends [] ? T : T[] }
796
-
797
- type MongoUpdateArrayOperatorModifiers<T> = MongoUpdateArrayOperatorUniversalModifiers<T> &
798
- { $position?: number, $slice?: number, $sort?: 1 | -1 }
799
-
800
- type MongoUpdateCommand<Schema extends MongoObject> = MongoUpdateOperators<Schema>
801
-
802
800
  type SortOrder = { [key: string]: 1 | -1 | SortOrder }
803
801
 
804
802
  type Cursor<T> = {
@@ -1,6 +1,5 @@
1
1
  import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
2
2
  import { basename, resolve } from "path"
3
- import * as PathPosix from "path/posix"
4
3
  async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
5
4
  const users = new Set()
6
5
  if (hackmudPath)
@@ -11,33 +10,35 @@ async function generateTypeDeclaration(sourceDirectory, hackmudPath) {
11
10
  allScripts = {},
12
11
  allAnyScripts = {}
13
12
  await Promise.all(
14
- (await readDirectoryWithStats(sourceDirectory)).map(async ({ stats, name }) => {
15
- if (stats.isFile())
16
- name.endsWith(".ts")
17
- ? name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
18
- : name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
19
- else if (stats.isDirectory()) {
20
- const scripts = [],
21
- anyScripts = []
22
- allScripts[name] = scripts
23
- allAnyScripts[name] = anyScripts
24
- users.add(name)
25
- for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
26
- child.stats.isFile() &&
27
- (child.name.endsWith(".ts")
28
- ? name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
29
- : child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
30
- }
31
- })
13
+ (await readDirectoryWithStats(sourceDirectory))
14
+ .filter(({ stats, name }) => !stats.isDirectory() || /^[a-z_][a-z\d_]{0,24}$/.test(name))
15
+ .map(async ({ stats, name }) => {
16
+ if (stats.isFile())
17
+ name.endsWith(".ts")
18
+ ? name.endsWith(".d.ts") || wildScripts.push(basename(name, ".ts"))
19
+ : name.endsWith(".js") && wildAnyScripts.push(basename(name, ".js"))
20
+ else if (stats.isDirectory()) {
21
+ const scripts = [],
22
+ anyScripts = []
23
+ allScripts[name] = scripts
24
+ allAnyScripts[name] = anyScripts
25
+ users.add(name)
26
+ for (const child of await readDirectoryWithStats(resolve(sourceDirectory, name)))
27
+ child.stats.isFile() &&
28
+ (child.name.endsWith(".ts")
29
+ ? name.endsWith(".d.ts") || scripts.push(basename(child.name, ".ts"))
30
+ : child.name.endsWith(".js") && anyScripts.push(basename(child.name, ".js")))
31
+ }
32
+ })
32
33
  )
33
- sourceDirectory = PathPosix.resolve(sourceDirectory)
34
34
  let o = ""
35
- for (const script of wildScripts) o += `type $${script}$ = typeof import("${sourceDirectory}/${script}").default\n`
35
+ for (const script of wildScripts)
36
+ o += `type $${script}$ = typeof import(${JSON.stringify(resolve(sourceDirectory, script))}).default\n`
36
37
  o += "\n"
37
38
  for (const user in allScripts) {
38
39
  const scripts = allScripts[user]
39
40
  for (const script of scripts)
40
- o += `type $${user}$${script}$ = typeof import("${sourceDirectory}/${user}/${script}").default\n`
41
+ o += `type $${user}$${script}$ = typeof import(${JSON.stringify(resolve(sourceDirectory, user, script))}).default\n`
41
42
  }
42
43
  o +=
43
44
  "\ntype ArrayRemoveFirst<A> = A extends [ infer FirstItem, ...infer Rest ] ? Rest : never\n\ntype Subscript<T extends (...args: any) => any> =\n\t(...args: ArrayRemoveFirst<Parameters<T>>) => ReturnType<T> | ScriptFailure\n\ntype WildFullsec = Record<string, () => ScriptFailure> & {\n"
package/index.js CHANGED
@@ -7,7 +7,6 @@ export { syncMacros } from "./syncMacros.js"
7
7
  export { watch } from "./watch.js"
8
8
  import "@samual/lib/readDirectoryWithStats"
9
9
  import "path"
10
- import "path/posix"
11
10
  import "@babel/generator"
12
11
  import "@babel/parser"
13
12
  import "@babel/plugin-proposal-decorators"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hackmud-script-manager",
3
- "version": "0.21.1-c61c24e",
3
+ "version": "0.21.1-d4bf990",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -24,7 +24,8 @@
24
24
  "contributors": [
25
25
  "Daniel Swann (https://github.com/danswann)",
26
26
  "Longboyy",
27
- "Helloman892"
27
+ "Helloman892",
28
+ "Sarah Klocke (https://sarahisweird.dev/)"
28
29
  ],
29
30
  "main": "index.js",
30
31
  "repository": {
@@ -1,21 +1,21 @@
1
- import babelGenerator from "@babel/generator"
1
+ import awpz3osbzbgie0diqla53jdp from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
- import babelPluginProposalDecorators from "@babel/plugin-proposal-decorators"
4
- import babelPluginProposalDestructuringPrivate from "@babel/plugin-proposal-destructuring-private"
5
- import babelPluginProposalExplicitResourceManagement from "@babel/plugin-proposal-explicit-resource-management"
6
- import babelPluginTransformClassProperties from "@babel/plugin-transform-class-properties"
7
- import babelPluginTransformClassStaticBlock from "@babel/plugin-transform-class-static-block"
8
- import babelPluginTransformExponentiationOperator from "@babel/plugin-transform-exponentiation-operator"
9
- import babelPluginTransformJsonStrings from "@babel/plugin-transform-json-strings"
10
- import babelPluginTransformLogicalAssignmentOperators from "@babel/plugin-transform-logical-assignment-operators"
11
- import babelPluginTransformNullishCoalescingOperator from "@babel/plugin-transform-nullish-coalescing-operator"
12
- import babelPluginTransformNumericSeparator from "@babel/plugin-transform-numeric-separator"
13
- import babelPluginTransformObjectRestSpread from "@babel/plugin-transform-object-rest-spread"
14
- import babelPluginTransformOptionalCatchBinding from "@babel/plugin-transform-optional-catch-binding"
15
- import babelPluginTransformOptionalChaining from "@babel/plugin-transform-optional-chaining"
16
- import babelPluginTransformPrivatePropertyInObject from "@babel/plugin-transform-private-property-in-object"
17
- import babelPluginTransformUnicodeSetsRegex from "@babel/plugin-transform-unicode-sets-regex"
18
- import babelTraverse from "@babel/traverse"
3
+ import n7j5rk65x3x68f0977sx3p32 from "@babel/plugin-proposal-decorators"
4
+ import ta0frirmi3s2jq08l6cht3uk from "@babel/plugin-proposal-destructuring-private"
5
+ import k3l88m4rzomnxi1nyaws0uf4 from "@babel/plugin-proposal-explicit-resource-management"
6
+ import d8vrbov1hvzild8irq5ej6a5 from "@babel/plugin-transform-class-properties"
7
+ import yluenyq31jclk2gspvfqqhdw from "@babel/plugin-transform-class-static-block"
8
+ import s83tktwy1wj5yii2modwcpsu from "@babel/plugin-transform-exponentiation-operator"
9
+ import gjxa6uc9geesg3fse9p6nz2t from "@babel/plugin-transform-json-strings"
10
+ import hpo770a0fczabe5gqnfx5zuh from "@babel/plugin-transform-logical-assignment-operators"
11
+ import kzbxvgtuqrrh91fwlvcsrheu from "@babel/plugin-transform-nullish-coalescing-operator"
12
+ import meo269rn6bx4ct4wluvbjqan from "@babel/plugin-transform-numeric-separator"
13
+ import o997fnadhqb0j0fcvivsfr58 from "@babel/plugin-transform-object-rest-spread"
14
+ import sy7mwdqgoccmlrptsvyavb2g from "@babel/plugin-transform-optional-catch-binding"
15
+ import ylulmkigu6sywpswowfw2ont from "@babel/plugin-transform-optional-chaining"
16
+ import apo7v29f7l9cy104xqjwyavh from "@babel/plugin-transform-private-property-in-object"
17
+ import e4n14nj86a5rtu8hkil6ioxe from "@babel/plugin-transform-unicode-sets-regex"
18
+ import ons4yi64j2vp9u6vpqkt1emx from "@babel/traverse"
19
19
  import t from "@babel/types"
20
20
  import rollupPluginAlias from "@rollup/plugin-alias"
21
21
  import { babel } from "@rollup/plugin-babel"
@@ -23,7 +23,7 @@ import rollupPluginCommonJS from "@rollup/plugin-commonjs"
23
23
  import rollupPluginJSON from "@rollup/plugin-json"
24
24
  import rollupPluginNodeResolve from "@rollup/plugin-node-resolve"
25
25
  import { assert } from "@samual/lib/assert"
26
- import { relative } from "path"
26
+ import { relative, isAbsolute, sep } from "path"
27
27
  import prettier from "prettier"
28
28
  import { rollup } from "rollup"
29
29
  import { supportedExtensions } from "../constants.js"
@@ -38,9 +38,24 @@ import "acorn"
38
38
  import "terser"
39
39
  import "import-meta-resolve"
40
40
  import "@samual/lib/clearObject"
41
- const { format } = prettier,
42
- { default: generate } = babelGenerator,
43
- { default: traverse } = babelTraverse
41
+ const generate = awpz3osbzbgie0diqla53jdp.default,
42
+ babelPluginProposalDecorators = n7j5rk65x3x68f0977sx3p32.default,
43
+ babelPluginProposalDestructuringPrivate = ta0frirmi3s2jq08l6cht3uk.default,
44
+ babelPluginProposalExplicitResourceManagement = k3l88m4rzomnxi1nyaws0uf4.default,
45
+ babelPluginTransformClassProperties = d8vrbov1hvzild8irq5ej6a5.default,
46
+ babelPluginTransformClassStaticBlock = yluenyq31jclk2gspvfqqhdw.default,
47
+ babelPluginTransformExponentiationOperator = s83tktwy1wj5yii2modwcpsu.default,
48
+ babelPluginTransformJsonStrings = gjxa6uc9geesg3fse9p6nz2t.default,
49
+ babelPluginTransformLogicalAssignmentOperators = hpo770a0fczabe5gqnfx5zuh.default,
50
+ babelPluginTransformNullishCoalescingOperator = kzbxvgtuqrrh91fwlvcsrheu.default,
51
+ babelPluginTransformNumericSeparator = meo269rn6bx4ct4wluvbjqan.default,
52
+ babelPluginTransformObjectRestSpread = o997fnadhqb0j0fcvivsfr58.default,
53
+ babelPluginTransformOptionalCatchBinding = sy7mwdqgoccmlrptsvyavb2g.default,
54
+ babelPluginTransformOptionalChaining = ylulmkigu6sywpswowfw2ont.default,
55
+ babelPluginTransformPrivatePropertyInObject = apo7v29f7l9cy104xqjwyavh.default,
56
+ babelPluginTransformUnicodeSetsRegex = e4n14nj86a5rtu8hkil6ioxe.default,
57
+ traverse = ons4yi64j2vp9u6vpqkt1emx.default,
58
+ { format } = prettier
44
59
  async function processScript(
45
60
  code,
46
61
  {
@@ -56,7 +71,7 @@ async function processScript(
56
71
  rootFolderPath
57
72
  }
58
73
  ) {
59
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:81:36")
74
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:78:36")
60
75
  const sourceCode = code
61
76
  let autocomplete, statedSeclevel
62
77
  const autocompleteMatch = /^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(code)
@@ -117,30 +132,30 @@ async function processScript(
117
132
  }
118
133
  }
119
134
  }
120
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:162:36")
135
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:159:36")
121
136
  const plugins = [
122
- [babelPluginProposalDecorators.default, { decoratorsBeforeExport: !0 }],
123
- [babelPluginTransformClassProperties.default],
124
- [babelPluginTransformClassStaticBlock.default],
125
- [babelPluginTransformPrivatePropertyInObject.default],
126
- [babelPluginTransformLogicalAssignmentOperators.default],
127
- [babelPluginTransformNumericSeparator.default],
128
- [babelPluginTransformNullishCoalescingOperator.default],
129
- [babelPluginTransformOptionalChaining.default],
130
- [babelPluginTransformOptionalCatchBinding.default],
131
- [babelPluginTransformJsonStrings.default],
132
- [babelPluginTransformObjectRestSpread.default],
133
- [babelPluginTransformExponentiationOperator.default],
134
- [babelPluginTransformUnicodeSetsRegex.default],
135
- [babelPluginProposalDestructuringPrivate.default],
136
- [babelPluginProposalExplicitResourceManagement.default]
137
+ [babelPluginProposalDecorators, { decoratorsBeforeExport: !0 }],
138
+ [babelPluginTransformClassProperties],
139
+ [babelPluginTransformClassStaticBlock],
140
+ [babelPluginTransformPrivatePropertyInObject],
141
+ [babelPluginTransformLogicalAssignmentOperators],
142
+ [babelPluginTransformNumericSeparator],
143
+ [babelPluginTransformNullishCoalescingOperator],
144
+ [babelPluginTransformOptionalChaining],
145
+ [babelPluginTransformOptionalCatchBinding],
146
+ [babelPluginTransformJsonStrings],
147
+ [babelPluginTransformObjectRestSpread],
148
+ [babelPluginTransformExponentiationOperator],
149
+ [babelPluginTransformUnicodeSetsRegex],
150
+ [babelPluginProposalDestructuringPrivate],
151
+ [babelPluginProposalExplicitResourceManagement]
137
152
  ]
138
153
  let filePathResolved
139
154
  if (filePath) {
140
155
  filePathResolved = relative(".", filePath)
141
156
  if (filePath.endsWith(".ts"))
142
157
  plugins.push([
143
- (await import("@babel/plugin-transform-typescript")).default,
158
+ await import("@babel/plugin-transform-typescript").then(module => module.default),
144
159
  { allowDeclareFields: !0, optimizeConstEnums: !0 }
145
160
  ])
146
161
  else {
@@ -153,22 +168,22 @@ async function processScript(
153
168
  babelPluginProposalThrowExpressions,
154
169
  babelPluginProposalRecordAndTuple
155
170
  ] = await Promise.all([
156
- import("@babel/plugin-proposal-do-expressions"),
157
- import("@babel/plugin-proposal-function-bind"),
158
- import("@babel/plugin-proposal-function-sent"),
159
- import("@babel/plugin-proposal-partial-application"),
160
- import("@babel/plugin-proposal-pipeline-operator"),
161
- import("@babel/plugin-proposal-throw-expressions"),
162
- import("@babel/plugin-proposal-record-and-tuple")
171
+ import("@babel/plugin-proposal-do-expressions").then(module => module.default),
172
+ import("@babel/plugin-proposal-function-bind").then(module => module.default),
173
+ import("@babel/plugin-proposal-function-sent").then(module => module.default),
174
+ import("@babel/plugin-proposal-partial-application").then(module => module.default),
175
+ import("@babel/plugin-proposal-pipeline-operator").then(module => module.default),
176
+ import("@babel/plugin-proposal-throw-expressions").then(module => module.default),
177
+ import("@babel/plugin-proposal-record-and-tuple").then(module => module.default)
163
178
  ])
164
179
  plugins.push(
165
- [babelPluginProposalDoExpressions.default],
166
- [babelPluginProposalFunctionBind.default],
167
- [babelPluginProposalFunctionSent.default],
168
- [babelPluginProposalPartialApplication.default],
169
- [babelPluginProposalPipelineOperator.default, { proposal: "hack", topicToken: "%" }],
170
- [babelPluginProposalThrowExpressions.default],
171
- [babelPluginProposalRecordAndTuple.default, { syntaxType: "hash", importPolyfill: !0 }]
180
+ [babelPluginProposalDoExpressions],
181
+ [babelPluginProposalFunctionBind],
182
+ [babelPluginProposalFunctionSent],
183
+ [babelPluginProposalPartialApplication],
184
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
185
+ [babelPluginProposalThrowExpressions],
186
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
172
187
  )
173
188
  }
174
189
  } else {
@@ -183,24 +198,24 @@ async function processScript(
183
198
  babelPluginProposalThrowExpressions,
184
199
  babelPluginProposalRecordAndTuple
185
200
  ] = await Promise.all([
186
- import("@babel/plugin-transform-typescript"),
187
- import("@babel/plugin-proposal-do-expressions"),
188
- import("@babel/plugin-proposal-function-bind"),
189
- import("@babel/plugin-proposal-function-sent"),
190
- import("@babel/plugin-proposal-partial-application"),
191
- import("@babel/plugin-proposal-pipeline-operator"),
192
- import("@babel/plugin-proposal-throw-expressions"),
193
- import("@babel/plugin-proposal-record-and-tuple")
201
+ import("@babel/plugin-transform-typescript").then(module => module.default),
202
+ import("@babel/plugin-proposal-do-expressions").then(module => module.default),
203
+ import("@babel/plugin-proposal-function-bind").then(module => module.default),
204
+ import("@babel/plugin-proposal-function-sent").then(module => module.default),
205
+ import("@babel/plugin-proposal-partial-application").then(module => module.default),
206
+ import("@babel/plugin-proposal-pipeline-operator").then(module => module.default),
207
+ import("@babel/plugin-proposal-throw-expressions").then(module => module.default),
208
+ import("@babel/plugin-proposal-record-and-tuple").then(module => module.default)
194
209
  ])
195
210
  plugins.push(
196
- [babelPluginTransformTypescript.default, { allowDeclareFields: !0, optimizeConstEnums: !0 }],
197
- [babelPluginProposalDoExpressions.default],
198
- [babelPluginProposalFunctionBind.default],
199
- [babelPluginProposalFunctionSent.default],
200
- [babelPluginProposalPartialApplication.default],
201
- [babelPluginProposalPipelineOperator.default, { proposal: "hack", topicToken: "%" }],
202
- [babelPluginProposalThrowExpressions.default],
203
- [babelPluginProposalRecordAndTuple.default, { syntaxType: "hash", importPolyfill: !0 }]
211
+ [babelPluginTransformTypescript, { allowDeclareFields: !0, optimizeConstEnums: !0 }],
212
+ [babelPluginProposalDoExpressions],
213
+ [babelPluginProposalFunctionBind],
214
+ [babelPluginProposalFunctionSent],
215
+ [babelPluginProposalPartialApplication],
216
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
217
+ [babelPluginProposalThrowExpressions],
218
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
204
219
  )
205
220
  }
206
221
  const bundle = await rollup({
@@ -210,7 +225,7 @@ async function processScript(
210
225
  {
211
226
  name: "hackmud-script-manager",
212
227
  async transform(code, id) {
213
- if (id.startsWith("/") && !id.includes("/node_modules/"))
228
+ if (isAbsolute(id) && !id.includes(`${sep}node_modules${sep}`))
214
229
  return (await preprocess(code, { uniqueId })).code
215
230
  let program
216
231
  traverse(parse(code, { sourceType: "module" }), {
@@ -253,7 +268,7 @@ async function processScript(
253
268
  traverse(file, {
254
269
  MemberExpression({ node: memberExpression }) {
255
270
  if (!memberExpression.computed) {
256
- assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:326:60")
271
+ assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:323:60")
257
272
  if ("prototype" == memberExpression.property.name) {
258
273
  memberExpression.computed = !0
259
274
  memberExpression.property = t.stringLiteral("prototype")
@@ -283,7 +298,7 @@ async function processScript(
283
298
  break
284
299
  case "ObjectPattern":
285
300
  for (const property of lValue.properties) {
286
- assert("ObjectProperty" == property.type, "src/processScript/index.ts:356:51")
301
+ assert("ObjectProperty" == property.type, "src/processScript/index.ts:353:51")
287
302
  renameVariables(property.value)
288
303
  }
289
304
  break
@@ -1,5 +1,5 @@
1
- import babelGenerator from "@babel/generator"
2
- import babelTraverse from "@babel/traverse"
1
+ import awpz3osbzbgie0diqla53jdp from "@babel/generator"
2
+ import ons4yi64j2vp9u6vpqkt1emx 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,12 +7,12 @@ 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 { default: generate } = babelGenerator,
11
- { default: traverse } = babelTraverse,
10
+ const generate = awpz3osbzbgie0diqla53jdp.default,
11
+ traverse = ons4yi64j2vp9u6vpqkt1emx.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 } = {}) {
15
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts:46:36")
15
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts:41:36")
16
16
  let program
17
17
  traverse(file, {
18
18
  Program(path) {
@@ -52,7 +52,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
52
52
  traverse(fileBeforeJSONValueReplacement, {
53
53
  MemberExpression({ node: memberExpression }) {
54
54
  if (!memberExpression.computed) {
55
- assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:115:60")
55
+ assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:110:60")
56
56
  if ("prototype" == memberExpression.property.name) {
57
57
  memberExpression.computed = !0
58
58
  memberExpression.property = t.identifier(`_${uniqueId}_PROTOTYPE_PROPERTY_`)
@@ -164,7 +164,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
164
164
  },
165
165
  MemberExpression({ node: memberExpression }) {
166
166
  if (!memberExpression.computed) {
167
- assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:249:62")
167
+ assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:244:62")
168
168
  if (!(memberExpression.property.name.length < 3)) {
169
169
  memberExpression.computed = !0
170
170
  memberExpression.property = t.stringLiteral(memberExpression.property.name)
@@ -238,7 +238,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
238
238
  })
239
239
  await Promise.all(promises)
240
240
  const functionDeclaration = file.program.body[0]
241
- assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:354:61")
241
+ assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:349:61")
242
242
  if (jsonValues.length) {
243
243
  hasComment = !0
244
244
  if (1 == jsonValues.length)
@@ -358,7 +358,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
358
358
  )
359
359
  }
360
360
  if (1 == forceQuineCheats) return code
361
- assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:485:43")
361
+ assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:480:43")
362
362
  return countHackmudCharacters(scriptBeforeJSONValueReplacement) <= countHackmudCharacters(code) + Number(hasComment)
363
363
  ? scriptBeforeJSONValueReplacement
364
364
  : code
@@ -371,7 +371,7 @@ function parseObjectExpression(node, o) {
371
371
  "Identifier" == property.key.type ||
372
372
  "NumericLiteral" == property.key.type ||
373
373
  "StringLiteral" == property.key.type,
374
- "src/processScript/minify.ts:507:4"
374
+ "src/processScript/minify.ts:502:4"
375
375
  )
376
376
  if ("ArrayExpression" == property.value.type) {
377
377
  const childArray = []
@@ -1,14 +1,14 @@
1
- import babelGenerator from "@babel/generator"
1
+ import awpz3osbzbgie0diqla53jdp from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
- import babelTraverse from "@babel/traverse"
3
+ import ons4yi64j2vp9u6vpqkt1emx 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 { default: traverse } = babelTraverse,
9
- { default: generate } = babelGenerator
8
+ const generate = awpz3osbzbgie0diqla53jdp.default,
9
+ traverse = ons4yi64j2vp9u6vpqkt1emx.default
10
10
  async function preprocess(code, { uniqueId = "00000000000" } = {}) {
11
- assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:23:36")
11
+ assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:18:36")
12
12
  const sourceCode = code
13
13
  let lengthBefore, file, program
14
14
  do {
@@ -47,7 +47,7 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
47
47
  })
48
48
  break
49
49
  } catch (error_) {
50
- assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:67:42")
50
+ assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:62:42")
51
51
  error = error_
52
52
  }
53
53
  if ("BABEL_PARSER_SYNTAX_ERROR" != error.code || "PrivateInExpectedIn" != error.reasonCode) {
@@ -1,10 +1,10 @@
1
- import babelTraverse from "@babel/traverse"
1
+ import ons4yi64j2vp9u6vpqkt1emx 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 { default: traverse } = babelTraverse,
7
+ const traverse = ons4yi64j2vp9u6vpqkt1emx.default,
8
8
  globalFunctionsUnder7Characters = [
9
9
  "Map",
10
10
  "Set",
@@ -77,30 +77,30 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
77
77
  const referencePath = FunctionReferencePaths[0]
78
78
  assert(
79
79
  "MemberExpression" == referencePath.parent.type,
80
- "src/processScript/transform.ts:111:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
80
+ "src/processScript/transform.ts:108:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
81
81
  )
82
82
  assert(
83
83
  "Identifier" == referencePath.parent.property.type,
84
- "src/processScript/transform.ts:116:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
84
+ "src/processScript/transform.ts:113:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
85
85
  )
86
86
  assert(
87
87
  "prototype" == referencePath.parent.property.name,
88
- "src/processScript/transform.ts:121:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
88
+ "src/processScript/transform.ts:118:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
89
89
  )
90
90
  referencePath.parentPath.replaceWith(createGetFunctionPrototypeNode())
91
91
  } else {
92
92
  for (const referencePath of FunctionReferencePaths) {
93
93
  assert(
94
94
  "MemberExpression" == referencePath.parent.type,
95
- "src/processScript/transform.ts:129:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
95
+ "src/processScript/transform.ts:126:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
96
96
  )
97
97
  assert(
98
98
  "Identifier" == referencePath.parent.property.type,
99
- "src/processScript/transform.ts:134:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
99
+ "src/processScript/transform.ts:131:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
100
100
  )
101
101
  assert(
102
102
  "prototype" == referencePath.parent.property.name,
103
- "src/processScript/transform.ts:139:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
103
+ "src/processScript/transform.ts:136:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
104
104
  )
105
105
  functionDotPrototypeIsReferencedMultipleTimes = !0
106
106
  referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_FUNCTION_DOT_PROTOTYPE_`))
@@ -141,12 +141,12 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
141
141
  const neededDbMethodLets = new Set()
142
142
  if (program.scope.hasGlobal("$db"))
143
143
  for (const referencePath of getReferencePathsToGlobal("$db", program)) {
144
- assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts:199:69")
145
- assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:200:72")
144
+ assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts:196:69")
145
+ assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:197:72")
146
146
  const databaseOpMethodName = referencePath.parentPath.node.property.name
147
147
  assert(
148
148
  validDBMethods.includes(databaseOpMethodName),
149
- `src/processScript/transform.ts:206:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
149
+ `src/processScript/transform.ts:203:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
150
150
  )
151
151
  if ("CallExpression" == referencePath.parentPath.parentPath?.type)
152
152
  referencePath.parentPath.replaceWith(t.identifier(`$${uniqueId}$DB$${databaseOpMethodName}$`))
@@ -181,7 +181,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
181
181
  if (program.scope.hasGlobal("Object"))
182
182
  for (const referencePath of getReferencePathsToGlobal("Object", program))
183
183
  if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
184
- assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:256:64")
184
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:253:64")
185
185
  if ("getPrototypeOf" == referencePath.parent.property.name) {
186
186
  referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_GET_PROTOTYPE_OF_`))
187
187
  needGetPrototypeOf = !0
@@ -194,7 +194,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
194
194
  if (program.scope.hasGlobal("console"))
195
195
  for (const referencePath of getReferencePathsToGlobal("console", program))
196
196
  if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
197
- assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:274:64")
197
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:271:64")
198
198
  referencePath.parentPath.replaceWith(
199
199
  t.identifier(`_${uniqueId}_CONSOLE_METHOD_${referencePath.parent.property.name}_`)
200
200
  )
@@ -202,13 +202,13 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
202
202
  }
203
203
  const lastStatement = program.node.body.at(-1)
204
204
  let exportDefaultName
205
- assert(lastStatement, "src/processScript/transform.ts:288:27 program is empty")
205
+ assert(lastStatement, "src/processScript/transform.ts:285:27 program is empty")
206
206
  if ("ExportNamedDeclaration" == lastStatement.type) {
207
207
  program.node.body.pop()
208
208
  for (const specifier of lastStatement.specifiers) {
209
209
  assert(
210
210
  "ExportSpecifier" == specifier.type,
211
- `src/processScript/transform.ts:294:51 ${specifier.type} is currently unsupported`
211
+ `src/processScript/transform.ts:291:51 ${specifier.type} is currently unsupported`
212
212
  )
213
213
  if (
214
214
  "default" !=
@@ -310,11 +310,11 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
310
310
  let hoistedGlobalBlockFunctions = 0
311
311
  for (const [globalBlockIndex, globalBlockStatement] of [...globalBlock.body.entries()].reverse())
312
312
  if ("VariableDeclaration" == globalBlockStatement.type) {
313
- assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:408:59")
313
+ assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:405:59")
314
314
  const declarator = globalBlockStatement.declarations[0]
315
315
  assert(
316
316
  "Identifier" == declarator.id.type,
317
- `src/processScript/transform.ts:412:51 declarator.id.type was "${declarator.id.type}"`
317
+ `src/processScript/transform.ts:409:51 declarator.id.type was "${declarator.id.type}"`
318
318
  )
319
319
  program.scope.crawl()
320
320
  if (program.scope.hasGlobal(declarator.id.name)) {
@@ -329,9 +329,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
329
329
  Object.keys(program.scope.globals).some(global => globalBlockVariables.has(global))
330
330
  ) {
331
331
  const binding = program.scope.getBinding(declarator.id.name)
332
- assert(binding, "src/processScript/transform.ts:431:23")
332
+ assert(binding, "src/processScript/transform.ts:428:23")
333
333
  for (const referencePath of binding.referencePaths) {
334
- assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:434:56")
334
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:431:56")
335
335
  referencePath.replaceWith(
336
336
  t.memberExpression(
337
337
  t.identifier(`_${uniqueId}_G_`),
@@ -379,16 +379,16 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
379
379
  } else globalBlockVariables.add(declarator.id.name)
380
380
  } else if ("ClassDeclaration" == globalBlockStatement.type) {
381
381
  program.scope.crawl()
382
- assert(globalBlockStatement.id, "src/processScript/transform.ts:491:37")
382
+ assert(globalBlockStatement.id, "src/processScript/transform.ts:488:37")
383
383
  if (program.scope.hasGlobal(globalBlockStatement.id.name)) {
384
384
  globalBlock.body.splice(globalBlockIndex, 1)
385
385
  const [globalBlockPath] = program.unshiftContainer("body", globalBlock),
386
386
  [globalBlockStatementPath] = program.unshiftContainer("body", globalBlockStatement)
387
387
  program.scope.crawl()
388
388
  const binding = program.scope.getBinding(globalBlockStatement.id.name)
389
- assert(binding, "src/processScript/transform.ts:503:22")
389
+ assert(binding, "src/processScript/transform.ts:500:22")
390
390
  for (const referencePath of binding.referencePaths) {
391
- assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:506:55")
391
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:503:55")
392
392
  referencePath.replaceWith(
393
393
  t.memberExpression(t.identifier(`_${uniqueId}_G_`), t.identifier(referencePath.node.name))
394
394
  )
@@ -562,6 +562,65 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
562
562
  t.variableDeclarator(t.identifier(`_${uniqueId}_G_`), t.identifier(`$${uniqueId}$GLOBAL$`))
563
563
  ])
564
564
  )
565
+ const replaceAllThisWith = (node, scope, thisId) => {
566
+ let thisIsReferenced = !1
567
+ traverse(
568
+ node,
569
+ {
570
+ ThisExpression(path) {
571
+ thisIsReferenced = !0
572
+ path.replaceWith(t.identifier(thisId))
573
+ },
574
+ Function(path) {
575
+ "ArrowFunctionExpression" != path.node.type && path.skip()
576
+ }
577
+ },
578
+ scope
579
+ )
580
+ return thisIsReferenced
581
+ },
582
+ replaceThisInObjectLikeDefinition = path => {
583
+ const { node: object, scope, parent } = path,
584
+ evenMoreUniqueId = Math.floor(Math.random() * 2 ** 52)
585
+ .toString(36)
586
+ .padStart(11, "0"),
587
+ reuseDeclaredName =
588
+ "VariableDeclarator" == parent.type &&
589
+ "VariableDeclaration" == path.parentPath?.parentPath?.node?.type &&
590
+ "const" == path.parentPath?.parentPath?.node?.kind &&
591
+ "Identifier" == parent.id.type
592
+ let thisId = reuseDeclaredName ? parent.id.name : `_${evenMoreUniqueId}_THIS_`,
593
+ thisIsReferenced = !1
594
+ if ("ObjectExpression" == object.type)
595
+ for (const property of object.properties)
596
+ "ObjectMethod" == property.type &&
597
+ (thisIsReferenced ||= replaceAllThisWith(property, scope, thisId))
598
+ else
599
+ for (const element of object.elements)
600
+ null != element && (thisIsReferenced ||= replaceAllThisWith(element, scope, thisId))
601
+ if (!thisIsReferenced) return
602
+ if (reuseDeclaredName) return
603
+ path.replaceWith(t.assignmentExpression("=", t.identifier(thisId), object))
604
+ const parentBlock = (path => {
605
+ let someBlock = null,
606
+ currentParent = path
607
+ for (; currentParent && currentParent && currentParent.node; ) {
608
+ if (t.isBlock(currentParent.node)) {
609
+ someBlock = currentParent.node
610
+ break
611
+ }
612
+ if (t.isArrowFunctionExpression(currentParent.parentPath?.node)) {
613
+ currentParent.replaceWith(t.blockStatement([t.returnStatement(currentParent.node)]))
614
+ someBlock = currentParent.node
615
+ break
616
+ }
617
+ currentParent = currentParent.parentPath
618
+ }
619
+ assert(null != someBlock, "src/processScript/transform.ts:705:29")
620
+ return someBlock
621
+ })(path)
622
+ parentBlock.body.unshift(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(thisId), null)]))
623
+ }
565
624
  traverse(file, {
566
625
  BlockStatement({ node: blockStatement }) {
567
626
  for (const [index, functionDeclaration] of blockStatement.body.entries())
@@ -581,8 +640,14 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
581
640
  )
582
641
  }
583
642
  },
643
+ ObjectExpression(path) {
644
+ replaceThisInObjectLikeDefinition(path)
645
+ },
646
+ ArrayExpression(path) {
647
+ replaceThisInObjectLikeDefinition(path)
648
+ },
584
649
  ClassBody({ node: classBody, scope, parent }) {
585
- assert(t.isClass(parent), "src/processScript/transform.ts:701:30")
650
+ assert(t.isClass(parent), "src/processScript/transform.ts:804:30")
586
651
  let thisIsReferenced = !1
587
652
  for (const classMethod of classBody.body) {
588
653
  if ("ClassMethod" != classMethod.type) continue
@@ -595,7 +660,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
595
660
  thisIsReferenced = !0
596
661
  path.replaceWith(t.identifier(`_${uniqueId}_THIS_`))
597
662
  },
598
- Function: path => path.skip()
663
+ Function(path) {
664
+ "ArrowFunctionExpression" != path.node.type && path.skip()
665
+ }
599
666
  },
600
667
  scope
601
668
  )
@@ -656,7 +723,17 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
656
723
  !parent.superClass && thisIsReferenced && (parent.superClass = t.identifier("Object"))
657
724
  },
658
725
  VariableDeclaration({ node: variableDeclaration }) {
659
- "const" == variableDeclaration.kind && (variableDeclaration.kind = "let")
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!`)
660
737
  },
661
738
  ThisExpression: path => {
662
739
  path.replaceWith(t.identifier("undefined"))
@@ -682,23 +759,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
682
759
  }
683
760
  function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
684
761
  for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
685
- assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:807:60")
762
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:928:60")
686
763
  assert("Identifier" == referencePath.parent.property.type)
687
764
  assert(
688
765
  "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
689
- "src/processScript/transform.ts:809:81"
766
+ "src/processScript/transform.ts:930:81"
690
767
  )
691
768
  assert(
692
769
  "Identifier" == referencePath.parentPath.parentPath.node.property.type,
693
- "src/processScript/transform.ts:810:83"
770
+ "src/processScript/transform.ts:931:83"
694
771
  )
695
772
  assert(
696
773
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parent.property.name),
697
- `src/processScript/transform.ts:814:8 invalid user "${referencePath.parent.property.name}" in subscript`
774
+ `src/processScript/transform.ts:935:8 invalid user "${referencePath.parent.property.name}" in subscript`
698
775
  )
699
776
  assert(
700
777
  /^[_a-z][\d_a-z]{0,24}$/.test(referencePath.parentPath.parentPath.node.property.name),
701
- `src/processScript/transform.ts:819:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
778
+ `src/processScript/transform.ts:940:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
702
779
  )
703
780
  if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
704
781
  referencePath.parentPath.parentPath.replaceWith(
package/watch.js CHANGED
@@ -9,7 +9,6 @@ import { extname, basename, resolve } from "path"
9
9
  import { supportedExtensions } from "./constants.js"
10
10
  import { generateTypeDeclaration } from "./generateTypeDeclaration.js"
11
11
  import { processScript } from "./processScript/index.js"
12
- import "path/posix"
13
12
  import "@babel/generator"
14
13
  import "@babel/parser"
15
14
  import "@babel/plugin-proposal-decorators"