hackmud-script-manager 0.21.1-ea9322a → 0.21.1-ef961a0

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.
@@ -1,10 +1,10 @@
1
- import babelTraverse from "@babel/traverse"
1
+ import lawenv4t0impljmx6dxyijy9 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 = lawenv4t0impljmx6dxyijy9.default,
8
8
  globalFunctionsUnder7Characters = [
9
9
  "Map",
10
10
  "Set",
@@ -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:198:69")
145
+ assert("Identifier" == referencePath.parentPath.node.property.type, "src/processScript/transform.ts:199: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:205: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:255: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:273: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:287: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:293: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:406: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:410: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:429: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:432: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:489: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:501: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:504: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
+ thisId = reuseDeclaredName ? parent.id.name : `_${evenMoreUniqueId}_THIS_`
593
+ let 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:709: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,12 +640,30 @@ 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:814:30")
586
651
  let thisIsReferenced = !1
587
652
  for (const classMethod of classBody.body) {
588
653
  if ("ClassMethod" != classMethod.type) continue
589
654
  let methodReferencesThis = !1
655
+ for (const param of classMethod.params)
656
+ traverse(
657
+ param,
658
+ {
659
+ ThisExpression(path) {
660
+ path.replaceWith(
661
+ t.callExpression(t.memberExpression(t.super(), t.identifier("valueOf")), [])
662
+ )
663
+ }
664
+ },
665
+ scope
666
+ )
590
667
  traverse(
591
668
  classMethod.body,
592
669
  {
@@ -595,7 +672,9 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
595
672
  thisIsReferenced = !0
596
673
  path.replaceWith(t.identifier(`_${uniqueId}_THIS_`))
597
674
  },
598
- Function: path => path.skip()
675
+ Function(path) {
676
+ "ArrowFunctionExpression" != path.node.type && path.skip()
677
+ }
599
678
  },
600
679
  scope
601
680
  )
@@ -682,23 +761,23 @@ function transform(file, sourceCode, { uniqueId = "00000000000", scriptUser, scr
682
761
  }
683
762
  function processFakeSubscriptObject(fakeSubscriptObjectName, seclevel) {
684
763
  for (const referencePath of getReferencePathsToGlobal(fakeSubscriptObjectName, program)) {
685
- assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:807:60")
764
+ assert("MemberExpression" == referencePath.parent.type, "src/processScript/transform.ts:937:60")
686
765
  assert("Identifier" == referencePath.parent.property.type)
687
766
  assert(
688
767
  "MemberExpression" == referencePath.parentPath.parentPath?.node.type,
689
- "src/processScript/transform.ts:809:81"
768
+ "src/processScript/transform.ts:939:81"
690
769
  )
691
770
  assert(
692
771
  "Identifier" == referencePath.parentPath.parentPath.node.property.type,
693
- "src/processScript/transform.ts:810:83"
772
+ "src/processScript/transform.ts:940:83"
694
773
  )
695
774
  assert(
696
775
  /^[_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`
776
+ `src/processScript/transform.ts:944:8 invalid user "${referencePath.parent.property.name}" in subscript`
698
777
  )
699
778
  assert(
700
779
  /^[_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`
780
+ `src/processScript/transform.ts:949:8 invalid script name "${referencePath.parentPath.parentPath.node.property.name}" in subscript`
702
781
  )
703
782
  if ("CallExpression" == referencePath.parentPath.parentPath.parentPath?.type)
704
783
  referencePath.parentPath.parentPath.replaceWith(
package/pull.d.ts CHANGED
@@ -1,5 +1,7 @@
1
- /** Copies script from hackmud to local source folder.
2
- * @param sourceFolderPath path to folder containing source files
3
- * @param hackmudPath path to hackmud directory
4
- * @param script to pull in `user.name` format */
1
+ /**
2
+ * Copies script from hackmud to local source folder.
3
+ * @param sourceFolderPath path to folder containing source files
4
+ * @param hackmudPath path to hackmud directory
5
+ * @param script to pull in `user.name` format
6
+ */
5
7
  export declare function pull(sourceFolderPath: string, hackmudPath: string, script: string): Promise<void>;
package/pull.js CHANGED
@@ -1,5 +1,5 @@
1
- import { copyFilePersistent } from "@samual/lib/copyFilePersistent"
2
1
  import { resolve } from "path"
2
+ import { copyFilePersistent } from "@samual/lib/copyFilePersistent"
3
3
  async function pull(sourceFolderPath, hackmudPath, script) {
4
4
  const [user, name] = script.split(".")
5
5
  if (!user || !name) throw Error('`script` argument must be in "user.name" format')
package/push.d.ts CHANGED
@@ -3,19 +3,22 @@ import type { Info } from ".";
3
3
  export type PushOptions = LaxPartial<{
4
4
  /** whether to do the minify step (defaults to `true`) */ minify: boolean;
5
5
  /** whether to mangle function and class names (defaults to `false`) */ mangleNames: boolean;
6
- /** array of scripts in the format `foo.bar`
7
- *
8
- * also accepts wild card (`*`) e.g. `*.bar` or `foo.*`
9
- *
10
- * pushes everything by default (`*.*`) */
6
+ /**
7
+ * array of scripts in the format `foo.bar`
8
+ *
9
+ * also accepts wild card (`*`) e.g. `*.bar` or `foo.*`
10
+ *
11
+ * pushes everything by default (`*.*`)
12
+ */
11
13
  scripts: string[];
12
14
  /** callback called on script push */ onPush: (info: Info) => void;
13
- /** when set to `true` forces use of quine cheats
14
- *
15
- * when set to `false` forces quine cheats not to be used
16
- *
17
- * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
18
- */
15
+ /**
16
+ * when set to `true` forces use of quine cheats
17
+ *
18
+ * when set to `false` forces quine cheats not to be used
19
+ *
20
+ * when left unset or set to `undefined`, automatically uses or doesn't use quine cheats based on character count
21
+ */
19
22
  forceQuineCheats: boolean;
20
23
  rootFolderPath: string;
21
24
  }>;
@@ -27,11 +30,13 @@ export declare class NoUsersError extends Error {
27
30
  }
28
31
  export declare class NoScriptsError extends Error {
29
32
  }
30
- /** Push scripts from a source directory to the hackmud directory.
31
- *
32
- * Pushes files directly in the source folder to all users
33
- * @param sourcePath directory containing source code
34
- * @param hackmudPath directory created by hackmud containing user data including scripts
35
- * @param options {@link PushOptions details}
36
- * @returns array of info on pushed scripts */
33
+ /**
34
+ * Push scripts from a source directory to the hackmud directory.
35
+ *
36
+ * Pushes files directly in the source folder to all users
37
+ * @param sourcePath directory containing source code
38
+ * @param hackmudPath directory created by hackmud containing user data including scripts
39
+ * @param options {@link PushOptions details}
40
+ * @returns array of info on pushed scripts
41
+ */
37
42
  export declare function push(sourcePath: string, hackmudPath: string, { scripts, onPush, minify, mangleNames, forceQuineCheats, rootFolderPath }?: PushOptions): Promise<MissingSourceFolderError | MissingHackmudFolderError | NoUsersError | NoScriptsError | Info[]>;
package/push.js CHANGED
@@ -1,10 +1,10 @@
1
- import { AutoMap } from "@samual/lib/AutoMap"
1
+ import { readFile } from "fs/promises"
2
+ import { basename, resolve } from "path"
2
3
  import { ensure, assert } from "@samual/lib/assert"
4
+ import { AutoMap } from "@samual/lib/AutoMap"
3
5
  import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
4
6
  import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
5
7
  import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
6
- import { readFile } from "fs/promises"
7
- import { basename, resolve } from "path"
8
8
  import { processScript } from "./processScript/index.js"
9
9
  import "@babel/generator"
10
10
  import "@babel/parser"
@@ -75,7 +75,7 @@ async function push(
75
75
  ),
76
76
  allUsers = new Set([
77
77
  ...scripts
78
- .map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:85:65"))
78
+ .map(scriptName => ensure(scriptName.split(".")[0], "src/push.ts:94:65"))
79
79
  .filter(name => "*" != name),
80
80
  ...sourceFolderFolders.map(({ name }) => name),
81
81
  ...hackmudFolder.filter(({ stats }) => stats.isDirectory()).map(({ name }) => name),
@@ -91,8 +91,8 @@ async function push(
91
91
  scriptNamesToUsers = new AutoMap(_scriptName => new Set())
92
92
  for (const script of scripts) {
93
93
  const [user, scriptName] = script.split(".")
94
- assert(user, "src/push.ts:108:16")
95
- assert(scriptName, "src/push.ts:109:22")
94
+ assert(user, "src/push.ts:117:16")
95
+ assert(scriptName, "src/push.ts:118:22")
96
96
  "*" == user ? scriptNamesToUsers.set(scriptName, allUsers) : scriptNamesToUsers.get(scriptName).add(user)
97
97
  }
98
98
  const sourceFolderFiles = sourceFolder.filter(({ stats }) => stats.isFile()),
package/syncMacros.js CHANGED
@@ -1,6 +1,6 @@
1
- import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
2
1
  import { readFile, stat, writeFile } from "fs/promises"
3
2
  import { extname, basename, resolve } from "path"
3
+ import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
4
4
  async function syncMacros(hackmudPath) {
5
5
  const files = await readDirectoryWithStats(hackmudPath),
6
6
  macros = new Map(),
@@ -9,22 +9,21 @@ async function syncMacros(hackmudPath) {
9
9
  files.map(async file => {
10
10
  if (file.stats.isFile())
11
11
  switch (extname(file.name)) {
12
- case ".macros":
13
- {
14
- const [lines, date] = await Promise.all([
15
- readFile(resolve(hackmudPath, file.name), { encoding: "utf8" }).then(file =>
16
- file.split("\n")
17
- ),
18
- stat(resolve(hackmudPath, file.name)).then(({ mtime }) => mtime)
19
- ])
20
- for (let index = 0; index < lines.length / 2 - 1; index++) {
21
- const macroName = lines[2 * index],
22
- currentMacro = macros.get(macroName)
23
- ;(!currentMacro || date > currentMacro.date) &&
24
- macros.set(macroName, { date, macro: lines[2 * index + 1] })
25
- }
12
+ case ".macros": {
13
+ const [lines, date] = await Promise.all([
14
+ readFile(resolve(hackmudPath, file.name), { encoding: "utf8" }).then(file =>
15
+ file.split("\n")
16
+ ),
17
+ stat(resolve(hackmudPath, file.name)).then(({ mtime }) => mtime)
18
+ ])
19
+ for (let index = 0; index < lines.length / 2 - 1; index++) {
20
+ const macroName = lines[2 * index],
21
+ currentMacro = macros.get(macroName)
22
+ ;(!currentMacro || date > currentMacro.date) &&
23
+ macros.set(macroName, { date, macro: lines[2 * index + 1] })
26
24
  }
27
25
  break
26
+ }
28
27
  case ".key":
29
28
  users.push(basename(file.name, ".key"))
30
29
  }
package/watch.d.ts CHANGED
@@ -1,15 +1,19 @@
1
1
  import type { LaxPartial } from "@samual/lib";
2
2
  import type { PushOptions } from "./push";
3
3
  export type WatchOptions = PushOptions & LaxPartial<{
4
- /** if provided, will write typescript type declarations for all the scripts on every change detected
5
- *
6
- * writing the type declarations enables interscript type checking and autocompletetes for the args */
4
+ /**
5
+ * if provided, will write typescript type declarations for all the scripts on every change detected
6
+ *
7
+ * writing the type declarations enables interscript type checking and autocompletetes for the args
8
+ */
7
9
  typeDeclarationPath: string;
8
10
  onReady: () => void;
9
11
  rootFolderPath: string;
10
12
  }>;
11
- /** Watches target file or folder for updates and builds and pushes updated file.
12
- * @param sourceDirectory path to folder containing source files
13
- * @param hackmudDirectory path to hackmud directory
14
- * @param options {@link WatchOptions details} and {@link PushOptions more details} */
13
+ /**
14
+ * Watches target file or folder for updates and builds and pushes updated file.
15
+ * @param sourceDirectory path to folder containing source files
16
+ * @param hackmudDirectory path to hackmud directory
17
+ * @param options {@link WatchOptions details} and {@link PushOptions more details}
18
+ */
15
19
  export declare function watch(sourceDirectory: string, hackmudDirectory: string, { scripts, onPush, minify, mangleNames, typeDeclarationPath: typeDeclarationPath_, onReady, forceQuineCheats, rootFolderPath }?: WatchOptions): Promise<void>;
package/watch.js CHANGED
@@ -1,15 +1,14 @@
1
- import { AutoMap } from "@samual/lib/AutoMap"
1
+ import { stat, readFile, writeFile } from "fs/promises"
2
+ import { extname, basename, resolve } from "path"
2
3
  import { assert } from "@samual/lib/assert"
4
+ import { AutoMap } from "@samual/lib/AutoMap"
3
5
  import { countHackmudCharacters } from "@samual/lib/countHackmudCharacters"
4
6
  import { readDirectoryWithStats } from "@samual/lib/readDirectoryWithStats"
5
7
  import { writeFilePersistent } from "@samual/lib/writeFilePersistent"
6
8
  import { watch as watch$1 } from "chokidar"
7
- import { stat, readFile, writeFile } from "fs/promises"
8
- 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"
@@ -145,7 +144,7 @@ async function watch(
145
144
  }
146
145
  ))
147
146
  } catch (error) {
148
- assert(error instanceof Error, "src/watch.ts:160:36")
147
+ assert(error instanceof Error, "src/watch.ts:165:36")
149
148
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
150
149
  return
151
150
  }
@@ -193,7 +192,7 @@ async function watch(
193
192
  rootFolderPath
194
193
  }))
195
194
  } catch (error) {
196
- assert(error instanceof Error, "src/watch.ts:207:35")
195
+ assert(error instanceof Error, "src/watch.ts:212:35")
197
196
  onPush?.({ path, users: [], characterCount: 0, error, warnings: [] })
198
197
  return
199
198
  }
@@ -208,7 +207,7 @@ async function watch(
208
207
  try {
209
208
  await writeFile(typeDeclarationPath, typeDeclaration)
210
209
  } catch (error) {
211
- assert(error instanceof Error, "src/watch.ts:240:35")
210
+ assert(error instanceof Error, "src/watch.ts:245:35")
212
211
  if ("EISDIR" != error.code) throw error
213
212
  typeDeclarationPath = resolve(typeDeclarationPath, "player.d.ts")
214
213
  await writeFile(typeDeclarationPath, typeDeclaration)