hackmud-script-manager 0.21.1-93e7bef → 0.21.1-ae53eb7

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-93e7bef")
66
+ console.log("0.21.1-ae53eb7")
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-93e7bef")}\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-ae53eb7")}\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
@@ -189,7 +189,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
189
189
 
190
190
  /** @returns A random element from `array`, selected with a random number generated using `rng`
191
191
  * (defaults to `Math.random`). */
192
- sample: (array: any[], rng?: ()=>number) => any
192
+ sample: <T>(array: T[], rng?: ()=>number) => T
193
193
 
194
194
  /** @returns Whether two MongoDB `ObjectId`s are equivalent. */ are_ids_eq: (id1: any, id2: any) => boolean
195
195
  /** Convert a MongoDB `ObjectId` to a string. */ id_to_str: (id: string | {$oid: string}) => any
@@ -270,7 +270,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
270
270
  map: <T, U>(array: T[], callback: (index: number, value: T) => U) => U[]
271
271
 
272
272
  /** @returns A new object derived from `obj` with only the keys specified in `keys`. */
273
- pick: (obj: object, keys: string[]) => any
273
+ pick: <TObj extends object, TKeys extends keyof TObj>(obj: TObj, keys: TKeys[]) => { [K in TKeys]: TObj[K] }
274
274
 
275
275
  /** @returns An array with the elements from `array` in a random order. */ shuffle: <T>(array: T[]) => T[]
276
276
 
@@ -298,7 +298,7 @@ type Fullsec = Subscripts & PlayerFullsec & {
298
298
  security_level_names: [ "NULLSEC", "LOWSEC", "MIDSEC", "HIGHSEC", "FULLSEC" ]
299
299
 
300
300
  /** @returns The string name of a numeric security level. */
301
- get_security_level_name: (security_level: number) => any
301
+ get_security_level_name: (security_level: number) => string
302
302
 
303
303
  /** @param result The return value of a call to `$db.i()` or `$db.r()`.
304
304
  * @param nModified The expected value of `result.nModified`.
@@ -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-93e7bef",
3
+ "version": "0.21.1-ae53eb7",
4
4
  "description": "Script manager for game hackmud, with minification, TypeScript support, and player script type definition generation.",
5
5
  "keywords": [
6
6
  "api",
@@ -23,7 +23,9 @@
23
23
  "author": "Samual Norman <me@samual.uk> (https://samual.uk/)",
24
24
  "contributors": [
25
25
  "Daniel Swann (https://github.com/danswann)",
26
- "Longboyy"
26
+ "Longboyy",
27
+ "Helloman892",
28
+ "Sarah Klocke (https://sarahisweird.dev/)"
27
29
  ],
28
30
  "main": "index.js",
29
31
  "repository": {
@@ -1,4 +1,4 @@
1
- import babelGenerator from "@babel/generator"
1
+ import generate from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
3
  import babelPluginProposalDecorators from "@babel/plugin-proposal-decorators"
4
4
  import babelPluginProposalDestructuringPrivate from "@babel/plugin-proposal-destructuring-private"
@@ -15,7 +15,7 @@ import babelPluginTransformOptionalCatchBinding from "@babel/plugin-transform-op
15
15
  import babelPluginTransformOptionalChaining from "@babel/plugin-transform-optional-chaining"
16
16
  import babelPluginTransformPrivatePropertyInObject from "@babel/plugin-transform-private-property-in-object"
17
17
  import babelPluginTransformUnicodeSetsRegex from "@babel/plugin-transform-unicode-sets-regex"
18
- import babelTraverse from "@babel/traverse"
18
+ import traverse 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,7 @@ 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 { format } = prettier
44
42
  async function processScript(
45
43
  code,
46
44
  {
@@ -56,7 +54,7 @@ async function processScript(
56
54
  rootFolderPath
57
55
  }
58
56
  ) {
59
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:81:36")
57
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:78:36")
60
58
  const sourceCode = code
61
59
  let autocomplete, statedSeclevel
62
60
  const autocompleteMatch = /^function\s*\(.+\/\/(?<autocomplete>.+)/.exec(code)
@@ -117,30 +115,30 @@ async function processScript(
117
115
  }
118
116
  }
119
117
  }
120
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:162:36")
118
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/index.ts:159:36")
121
119
  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]
120
+ [babelPluginProposalDecorators, { decoratorsBeforeExport: !0 }],
121
+ [babelPluginTransformClassProperties],
122
+ [babelPluginTransformClassStaticBlock],
123
+ [babelPluginTransformPrivatePropertyInObject],
124
+ [babelPluginTransformLogicalAssignmentOperators],
125
+ [babelPluginTransformNumericSeparator],
126
+ [babelPluginTransformNullishCoalescingOperator],
127
+ [babelPluginTransformOptionalChaining],
128
+ [babelPluginTransformOptionalCatchBinding],
129
+ [babelPluginTransformJsonStrings],
130
+ [babelPluginTransformObjectRestSpread],
131
+ [babelPluginTransformExponentiationOperator],
132
+ [babelPluginTransformUnicodeSetsRegex],
133
+ [babelPluginProposalDestructuringPrivate],
134
+ [babelPluginProposalExplicitResourceManagement]
137
135
  ]
138
136
  let filePathResolved
139
137
  if (filePath) {
140
138
  filePathResolved = relative(".", filePath)
141
139
  if (filePath.endsWith(".ts"))
142
140
  plugins.push([
143
- (await import("@babel/plugin-transform-typescript")).default,
141
+ await import("@babel/plugin-transform-typescript"),
144
142
  { allowDeclareFields: !0, optimizeConstEnums: !0 }
145
143
  ])
146
144
  else {
@@ -162,13 +160,13 @@ async function processScript(
162
160
  import("@babel/plugin-proposal-record-and-tuple")
163
161
  ])
164
162
  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 }]
163
+ [babelPluginProposalDoExpressions],
164
+ [babelPluginProposalFunctionBind],
165
+ [babelPluginProposalFunctionSent],
166
+ [babelPluginProposalPartialApplication],
167
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
168
+ [babelPluginProposalThrowExpressions],
169
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
172
170
  )
173
171
  }
174
172
  } else {
@@ -193,14 +191,14 @@ async function processScript(
193
191
  import("@babel/plugin-proposal-record-and-tuple")
194
192
  ])
195
193
  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 }]
194
+ [babelPluginTransformTypescript, { allowDeclareFields: !0, optimizeConstEnums: !0 }],
195
+ [babelPluginProposalDoExpressions],
196
+ [babelPluginProposalFunctionBind],
197
+ [babelPluginProposalFunctionSent],
198
+ [babelPluginProposalPartialApplication],
199
+ [babelPluginProposalPipelineOperator, { proposal: "hack", topicToken: "%" }],
200
+ [babelPluginProposalThrowExpressions],
201
+ [babelPluginProposalRecordAndTuple, { syntaxType: "hash", importPolyfill: !0 }]
204
202
  )
205
203
  }
206
204
  const bundle = await rollup({
@@ -210,7 +208,8 @@ async function processScript(
210
208
  {
211
209
  name: "hackmud-script-manager",
212
210
  async transform(code, id) {
213
- if (!id.includes("/node_modules/")) return (await preprocess(code, { uniqueId })).code
211
+ if (isAbsolute(id) && !id.includes(`${sep}node_modules${sep}`))
212
+ return (await preprocess(code, { uniqueId })).code
214
213
  let program
215
214
  traverse(parse(code, { sourceType: "module" }), {
216
215
  Program(path) {
@@ -252,7 +251,7 @@ async function processScript(
252
251
  traverse(file, {
253
252
  MemberExpression({ node: memberExpression }) {
254
253
  if (!memberExpression.computed) {
255
- assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:326:60")
254
+ assert("Identifier" == memberExpression.property.type, "src/processScript/index.ts:323:60")
256
255
  if ("prototype" == memberExpression.property.name) {
257
256
  memberExpression.computed = !0
258
257
  memberExpression.property = t.stringLiteral("prototype")
@@ -282,7 +281,7 @@ async function processScript(
282
281
  break
283
282
  case "ObjectPattern":
284
283
  for (const property of lValue.properties) {
285
- assert("ObjectProperty" == property.type, "src/processScript/index.ts:356:51")
284
+ assert("ObjectProperty" == property.type, "src/processScript/index.ts:353:51")
286
285
  renameVariables(property.value)
287
286
  }
288
287
  break
@@ -1,5 +1,5 @@
1
- import babelGenerator from "@babel/generator"
2
- import babelTraverse from "@babel/traverse"
1
+ import generate from "@babel/generator"
2
+ import traverse 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,10 @@ 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,
12
- minifyNumber = async number =>
13
- /\$\((?<number>.+)\)/.exec((await terser.minify(`$(${number})`, { ecma: 2015 })).code).groups.number
10
+ const minifyNumber = async number =>
11
+ /\$\((?<number>.+)\)/.exec((await terser.minify(`$(${number})`, { ecma: 2015 })).code).groups.number
14
12
  async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQuineCheats, autocomplete } = {}) {
15
- assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts:46:36")
13
+ assert(/^\w{11}$/.exec(uniqueId), "src/processScript/minify.ts:41:36")
16
14
  let program
17
15
  traverse(file, {
18
16
  Program(path) {
@@ -52,7 +50,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
52
50
  traverse(fileBeforeJSONValueReplacement, {
53
51
  MemberExpression({ node: memberExpression }) {
54
52
  if (!memberExpression.computed) {
55
- assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:115:60")
53
+ assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:110:60")
56
54
  if ("prototype" == memberExpression.property.name) {
57
55
  memberExpression.computed = !0
58
56
  memberExpression.property = t.identifier(`_${uniqueId}_PROTOTYPE_PROPERTY_`)
@@ -164,7 +162,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
164
162
  },
165
163
  MemberExpression({ node: memberExpression }) {
166
164
  if (!memberExpression.computed) {
167
- assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:249:62")
165
+ assert("Identifier" == memberExpression.property.type, "src/processScript/minify.ts:244:62")
168
166
  if (!(memberExpression.property.name.length < 3)) {
169
167
  memberExpression.computed = !0
170
168
  memberExpression.property = t.stringLiteral(memberExpression.property.name)
@@ -238,7 +236,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
238
236
  })
239
237
  await Promise.all(promises)
240
238
  const functionDeclaration = file.program.body[0]
241
- assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:354:61")
239
+ assert("FunctionDeclaration" == functionDeclaration.type, "src/processScript/minify.ts:349:61")
242
240
  if (jsonValues.length) {
243
241
  hasComment = !0
244
242
  if (1 == jsonValues.length)
@@ -358,7 +356,7 @@ async function minify(file, { uniqueId = "00000000000", mangleNames = !1, forceQ
358
356
  )
359
357
  }
360
358
  if (1 == forceQuineCheats) return code
361
- assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:485:43")
359
+ assert(scriptBeforeJSONValueReplacement, "src/processScript/minify.ts:480:43")
362
360
  return countHackmudCharacters(scriptBeforeJSONValueReplacement) <= countHackmudCharacters(code) + Number(hasComment)
363
361
  ? scriptBeforeJSONValueReplacement
364
362
  : code
@@ -371,7 +369,7 @@ function parseObjectExpression(node, o) {
371
369
  "Identifier" == property.key.type ||
372
370
  "NumericLiteral" == property.key.type ||
373
371
  "StringLiteral" == property.key.type,
374
- "src/processScript/minify.ts:507:4"
372
+ "src/processScript/minify.ts:502:4"
375
373
  )
376
374
  if ("ArrayExpression" == property.value.type) {
377
375
  const childArray = []
@@ -1,26 +1,12 @@
1
- import babelGenerator from "@babel/generator"
1
+ import generate from "@babel/generator"
2
2
  import { parse } from "@babel/parser"
3
- import babelTraverse from "@babel/traverse"
3
+ import traverse 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"
8
7
  import { resolve } from "import-meta-resolve"
9
- const { default: traverse } = babelTraverse,
10
- { default: generate } = babelGenerator,
11
- SUBSCRIPT_PREFIXES = ["s", "fs", "4s", "hs", "3s", "ms", "2s", "ls", "1s", "ns", "0s"]
12
8
  async function preprocess(code, { uniqueId = "00000000000" } = {}) {
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
- }
9
+ assert(/^\w{11}$/.test(uniqueId), "src/processScript/preprocess.ts:18:36")
24
10
  const sourceCode = code
25
11
  let lengthBefore, file, program
26
12
  do {
@@ -59,7 +45,7 @@ async function preprocess(code, { uniqueId = "00000000000" } = {}) {
59
45
  })
60
46
  break
61
47
  } catch (error_) {
62
- assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:89:42")
48
+ assert(error_ instanceof SyntaxError, "src/processScript/preprocess.ts:62:42")
63
49
  error = error_
64
50
  }
65
51
  if ("BABEL_PARSER_SYNTAX_ERROR" != error.code || "PrivateInExpectedIn" != error.reasonCode) {
@@ -1,26 +1,25 @@
1
- import babelTraverse from "@babel/traverse"
1
+ import traverse 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,
8
- globalFunctionsUnder7Characters = [
9
- "Map",
10
- "Set",
11
- "Date",
12
- "JSON",
13
- "Math",
14
- "Array",
15
- "Error",
16
- "isNaN",
17
- "Number",
18
- "Object",
19
- "RegExp",
20
- "String",
21
- "Symbol",
22
- "BigInt"
23
- ]
7
+ const globalFunctionsUnder7Characters = [
8
+ "Map",
9
+ "Set",
10
+ "Date",
11
+ "JSON",
12
+ "Math",
13
+ "Array",
14
+ "Error",
15
+ "isNaN",
16
+ "Number",
17
+ "Object",
18
+ "RegExp",
19
+ "String",
20
+ "Symbol",
21
+ "BigInt"
22
+ ]
24
23
  function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scriptName, seclevel = 4 }) {
25
24
  const warnings = [],
26
25
  topFunctionName = `_${uniqueId}_SCRIPT_`
@@ -77,30 +76,30 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
77
76
  const referencePath = FunctionReferencePaths[0]
78
77
  assert(
79
78
  "MemberExpression" == referencePath.parent.type,
80
- "src/processScript/transform.ts:111:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
79
+ "src/processScript/transform.ts:108:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
81
80
  )
82
81
  assert(
83
82
  "Identifier" == referencePath.parent.property.type,
84
- "src/processScript/transform.ts:116:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
83
+ "src/processScript/transform.ts:113:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
85
84
  )
86
85
  assert(
87
86
  "prototype" == referencePath.parent.property.name,
88
- "src/processScript/transform.ts:121:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
87
+ "src/processScript/transform.ts:118:8 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
89
88
  )
90
89
  referencePath.parentPath.replaceWith(createGetFunctionPrototypeNode())
91
90
  } else {
92
91
  for (const referencePath of FunctionReferencePaths) {
93
92
  assert(
94
93
  "MemberExpression" == referencePath.parent.type,
95
- "src/processScript/transform.ts:129:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
94
+ "src/processScript/transform.ts:126:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
96
95
  )
97
96
  assert(
98
97
  "Identifier" == referencePath.parent.property.type,
99
- "src/processScript/transform.ts:134:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
98
+ "src/processScript/transform.ts:131:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
100
99
  )
101
100
  assert(
102
101
  "prototype" == referencePath.parent.property.name,
103
- "src/processScript/transform.ts:139:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
102
+ "src/processScript/transform.ts:136:9 `Function` isn't available in hackmud, only `Function.prototype` is accessible"
104
103
  )
105
104
  functionDotPrototypeIsReferencedMultipleTimes = !0
106
105
  referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_FUNCTION_DOT_PROTOTYPE_`))
@@ -141,12 +140,12 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
141
140
  const neededDbMethodLets = new Set()
142
141
  if (program.scope.hasGlobal("$db"))
143
142
  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")
143
+ assert("MemberExpression" == referencePath.parentPath.node.type, "src/processScript/transform.ts:196:69")
144
+ assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:197:72")
146
145
  const databaseOpMethodName = referencePath.parentPath.node.property.name
147
146
  assert(
148
147
  validDBMethods.includes(databaseOpMethodName),
149
- `src/processScript/transform.ts:206:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
148
+ `src/processScript/transform.ts:203:8 invalid db method "${databaseOpMethodName}", valid db methods are "${validDBMethods.join('", "')}"`
150
149
  )
151
150
  if ("CallExpression" == referencePath.parentPath.parentPath?.type)
152
151
  referencePath.parentPath.replaceWith(t.identifier(`$${uniqueId}$DB$${databaseOpMethodName}$`))
@@ -181,7 +180,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
181
180
  if (program.scope.hasGlobal("Object"))
182
181
  for (const referencePath of getReferencePathsToGlobal("Object", program))
183
182
  if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
184
- assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:256:64")
183
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:253:64")
185
184
  if ("getPrototypeOf" == referencePath.parent.property.name) {
186
185
  referencePath.parentPath.replaceWith(t.identifier(`_${uniqueId}_GET_PROTOTYPE_OF_`))
187
186
  needGetPrototypeOf = !0
@@ -194,7 +193,7 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
194
193
  if (program.scope.hasGlobal("console"))
195
194
  for (const referencePath of getReferencePathsToGlobal("console", program))
196
195
  if ("MemberExpression" == referencePath.parent.type && !referencePath.parent.computed) {
197
- assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:274:64")
196
+ assert("Identifier" == referencePath.parent.property.type, "src/processScript/transform.ts:271:64")
198
197
  referencePath.parentPath.replaceWith(
199
198
  t.identifier(`_${uniqueId}_CONSOLE_METHOD_${referencePath.parent.property.name}_`)
200
199
  )
@@ -202,13 +201,13 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
202
201
  }
203
202
  const lastStatement = program.node.body.at(-1)
204
203
  let exportDefaultName
205
- assert(lastStatement, "src/processScript/transform.ts:288:27 program is empty")
204
+ assert(lastStatement, "src/processScript/transform.ts:285:27 program is empty")
206
205
  if ("ExportNamedDeclaration" == lastStatement.type) {
207
206
  program.node.body.pop()
208
207
  for (const specifier of lastStatement.specifiers) {
209
208
  assert(
210
209
  "ExportSpecifier" == specifier.type,
211
- `src/processScript/transform.ts:294:51 ${specifier.type} is currently unsupported`
210
+ `src/processScript/transform.ts:291:51 ${specifier.type} is currently unsupported`
212
211
  )
213
212
  if (
214
213
  "default" !=
@@ -310,11 +309,11 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
310
309
  let hoistedGlobalBlockFunctions = 0
311
310
  for (const [globalBlockIndex, globalBlockStatement] of [...globalBlock.body.entries()].reverse())
312
311
  if ("VariableDeclaration" == globalBlockStatement.type) {
313
- assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:408:59")
312
+ assert(1 == globalBlockStatement.declarations.length, "src/processScript/transform.ts:405:59")
314
313
  const declarator = globalBlockStatement.declarations[0]
315
314
  assert(
316
315
  "Identifier" == declarator.id.type,
317
- `src/processScript/transform.ts:412:51 declarator.id.type was "${declarator.id.type}"`
316
+ `src/processScript/transform.ts:409:51 declarator.id.type was "${declarator.id.type}"`
318
317
  )
319
318
  program.scope.crawl()
320
319
  if (program.scope.hasGlobal(declarator.id.name)) {
@@ -329,9 +328,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
329
328
  Object.keys(program.scope.globals).some(global => globalBlockVariables.has(global))
330
329
  ) {
331
330
  const binding = program.scope.getBinding(declarator.id.name)
332
- assert(binding, "src/processScript/transform.ts:431:23")
331
+ assert(binding, "src/processScript/transform.ts:428:23")
333
332
  for (const referencePath of binding.referencePaths) {
334
- assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:434:56")
333
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:431:56")
335
334
  referencePath.replaceWith(
336
335
  t.memberExpression(
337
336
  t.identifier(`_${uniqueId}_G_`),
@@ -379,16 +378,16 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
379
378
  } else globalBlockVariables.add(declarator.id.name)
380
379
  } else if ("ClassDeclaration" == globalBlockStatement.type) {
381
380
  program.scope.crawl()
382
- assert(globalBlockStatement.id, "src/processScript/transform.ts:491:37")
381
+ assert(globalBlockStatement.id, "src/processScript/transform.ts:488:37")
383
382
  if (program.scope.hasGlobal(globalBlockStatement.id.name)) {
384
383
  globalBlock.body.splice(globalBlockIndex, 1)
385
384
  const [globalBlockPath] = program.unshiftContainer("body", globalBlock),
386
385
  [globalBlockStatementPath] = program.unshiftContainer("body", globalBlockStatement)
387
386
  program.scope.crawl()
388
387
  const binding = program.scope.getBinding(globalBlockStatement.id.name)
389
- assert(binding, "src/processScript/transform.ts:503:22")
388
+ assert(binding, "src/processScript/transform.ts:500:22")
390
389
  for (const referencePath of binding.referencePaths) {
391
- assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:506:55")
390
+ assert("Identifier" == referencePath.node.type, "src/processScript/transform.ts:503:55")
392
391
  referencePath.replaceWith(
393
392
  t.memberExpression(t.identifier(`_${uniqueId}_G_`), t.identifier(referencePath.node.name))
394
393
  )
@@ -562,6 +561,65 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
562
561
  t.variableDeclarator(t.identifier(`_${uniqueId}_G_`), t.identifier(`$${uniqueId}$GLOBAL$`))
563
562
  ])
564
563
  )
564
+ const replaceAllThisWith = (node, scope, thisId) => {
565
+ let thisIsReferenced = !1
566
+ traverse(
567
+ node,
568
+ {
569
+ ThisExpression(path) {
570
+ thisIsReferenced = !0
571
+ path.replaceWith(t.identifier(thisId))
572
+ },
573
+ Function(path) {
574
+ "ArrowFunctionExpression" != path.node.type && path.skip()
575
+ }
576
+ },
577
+ scope
578
+ )
579
+ return thisIsReferenced
580
+ },
581
+ replaceThisInObjectLikeDefinition = path => {
582
+ const { node: object, scope, parent } = path,
583
+ evenMoreUniqueId = Math.floor(Math.random() * 2 ** 52)
584
+ .toString(36)
585
+ .padStart(11, "0"),
586
+ reuseDeclaredName =
587
+ "VariableDeclarator" == parent.type &&
588
+ "VariableDeclaration" == path.parentPath?.parentPath?.node?.type &&
589
+ "const" == path.parentPath?.parentPath?.node?.kind &&
590
+ "Identifier" == parent.id.type
591
+ let thisId = reuseDeclaredName ? parent.id.name : `_${evenMoreUniqueId}_THIS_`,
592
+ thisIsReferenced = !1
593
+ if ("ObjectExpression" == object.type)
594
+ for (const property of object.properties)
595
+ "ObjectMethod" == property.type &&
596
+ (thisIsReferenced ||= replaceAllThisWith(property, scope, thisId))
597
+ else
598
+ for (const element of object.elements)
599
+ null != element && (thisIsReferenced ||= replaceAllThisWith(element, scope, thisId))
600
+ if (!thisIsReferenced) return
601
+ if (reuseDeclaredName) return
602
+ path.replaceWith(t.assignmentExpression("=", t.identifier(thisId), object))
603
+ const parentBlock = (path => {
604
+ let someBlock = null,
605
+ currentParent = path
606
+ for (; currentParent && currentParent && currentParent.node; ) {
607
+ if (t.isBlock(currentParent.node)) {
608
+ someBlock = currentParent.node
609
+ break
610
+ }
611
+ if (t.isArrowFunctionExpression(currentParent.parentPath?.node)) {
612
+ currentParent.replaceWith(t.blockStatement([t.returnStatement(currentParent.node)]))
613
+ someBlock = currentParent.node
614
+ break
615
+ }
616
+ currentParent = currentParent.parentPath
617
+ }
618
+ assert(null != someBlock, "src/processScript/transform.ts:705:29")
619
+ return someBlock
620
+ })(path)
621
+ parentBlock.body.unshift(t.variableDeclaration("let", [t.variableDeclarator(t.identifier(thisId), null)]))
622
+ }
565
623
  traverse(file, {
566
624
  BlockStatement({ node: blockStatement }) {
567
625
  for (const [index, functionDeclaration] of blockStatement.body.entries())
@@ -581,8 +639,14 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
581
639
  )
582
640
  }
583
641
  },
642
+ ObjectExpression(path) {
643
+ replaceThisInObjectLikeDefinition(path)
644
+ },
645
+ ArrayExpression(path) {
646
+ replaceThisInObjectLikeDefinition(path)
647
+ },
584
648
  ClassBody({ node: classBody, scope, parent }) {
585
- assert(t.isClass(parent), "src/processScript/transform.ts:701:30")
649
+ assert(t.isClass(parent), "src/processScript/transform.ts:804:30")
586
650
  let thisIsReferenced = !1
587
651
  for (const classMethod of classBody.body) {
588
652
  if ("ClassMethod" != classMethod.type) continue
@@ -595,7 +659,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
595
659
  thisIsReferenced = !0
596
660
  path.replaceWith(t.identifier(`_${uniqueId}_THIS_`))
597
661
  },
598
- Function: path => path.skip()
662
+ Function(path) {
663
+ "ArrowFunctionExpression" != path.node.type && path.skip()
664
+ }
599
665
  },
600
666
  scope
601
667
  )
@@ -682,23 +748,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
682
748
  }
683
749
  function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
684
750
  for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
685
- assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:807:60")
751
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:914:60")
686
752
  assert("Identifier" == referencePath.parent.property.type)
687
753
  assert(
688
754
  "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
689
- "src/processScript/transform.ts:809:81"
755
+ "src/processScript/transform.ts:916:81"
690
756
  )
691
757
  assert(
692
758
  "Identifier" == referencePath.parentPath.parentPath.node.property.type,
693
- "src/processScript/transform.ts:810:83"
759
+ "src/processScript/transform.ts:917:83"
694
760
  )
695
761
  assert(
696
762
  /^[_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`
763
+ `src/processScript/transform.ts:921:8 invalid user "${referencePath.parent.property.name}" in subscript`
698
764
  )
699
765
  assert(
700
766
  /^[_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`
767
+ `src/processScript/transform.ts:926:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
702
768
  )
703
769
  if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
704
770
  referencePath.parentPath.parentPath.replaceWith(
package/push.js CHANGED
@@ -70,7 +70,9 @@ async function push(
70
70
  ])
71
71
  if (sourceFolder instanceof Error) return sourceFolder
72
72
  if (hackmudFolder instanceof Error) return hackmudFolder
73
- const sourceFolderFolders = sourceFolder.filter(({ stats }) => stats.isDirectory()),
73
+ const sourceFolderFolders = sourceFolder.filter(
74
+ ({ name, stats }) => stats.isDirectory() && /^[a-z_][a-z\d_]{0,24}$/.test(name)
75
+ ),
74
76
  allUsers = new Set([
75
77
  ...scripts
76
78
  .map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:85:65"))
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"
@@ -133,10 +132,19 @@ async function watch(
133
132
  try {
134
133
  ;({ script: minifiedCode, warnings } = await processScript(
135
134
  await readFile(filePath, { encoding: "utf8" }),
136
- { minify, scriptUser: !0, scriptName, uniqueId, filePath, mangleNames, forceQuineCheats }
135
+ {
136
+ minify,
137
+ scriptUser: !0,
138
+ scriptName,
139
+ uniqueId,
140
+ filePath,
141
+ mangleNames,
142
+ forceQuineCheats,
143
+ rootFolderPath
144
+ }
137
145
  ))
138
146
  } catch (error) {
139
- assert(error instanceof Error, "src/watch.ts:151:36")
147
+ assert(error instanceof Error, "src/watch.ts:160:36")
140
148
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
141
149
  return
142
150
  }
@@ -184,7 +192,7 @@ async function watch(
184
192
  rootFolderPath
185
193
  }))
186
194
  } catch (error) {
187
- assert(error instanceof Error, "src/watch.ts:198:35")
195
+ assert(error instanceof Error, "src/watch.ts:207:35")
188
196
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
189
197
  return
190
198
  }
@@ -199,7 +207,7 @@ async function watch(
199
207
  try {
200
208
  await writeFile(typeDeclarationPath, typeDeclaration)
201
209
  } catch (error) {
202
- assert(error instanceof Error, "src/watch.ts:231:35")
210
+ assert(error instanceof Error, "src/watch.ts:240:35")
203
211
  if ("EISDIR" != error.code) throw error
204
212
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
205
213
  await writeFile(typeDeclarationPath, typeDeclaration)