@earendil-works/pi-durable 1.4.0 → 1.5.0

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.
Files changed (221) hide show
  1. package/CHANGELOG.md +186 -0
  2. package/README.md +181 -84
  3. package/dist/codemode/codemode.d.ts +4 -4
  4. package/dist/codemode/codemode.d.ts.map +1 -1
  5. package/dist/codemode/codemode.js +9 -12
  6. package/dist/codemode/codemode.js.map +1 -1
  7. package/dist/codemode/models.js +4 -4
  8. package/dist/codemode/models.js.map +1 -1
  9. package/dist/env/index.d.ts +12 -10
  10. package/dist/env/index.d.ts.map +1 -1
  11. package/dist/env/index.js.map +1 -1
  12. package/dist/env/node-watch.d.ts +3 -3
  13. package/dist/env/node-watch.d.ts.map +1 -1
  14. package/dist/env/node-watch.js +18 -16
  15. package/dist/env/node-watch.js.map +1 -1
  16. package/dist/env/node.d.ts +2 -2
  17. package/dist/env/node.d.ts.map +1 -1
  18. package/dist/env/node.js +1 -1
  19. package/dist/env/node.js.map +1 -1
  20. package/dist/errors.d.ts +18 -2
  21. package/dist/errors.d.ts.map +1 -1
  22. package/dist/errors.js +26 -3
  23. package/dist/errors.js.map +1 -1
  24. package/dist/harness/agent.d.ts.map +1 -1
  25. package/dist/harness/agent.js +10 -2
  26. package/dist/harness/agent.js.map +1 -1
  27. package/dist/harness/compaction.d.ts.map +1 -1
  28. package/dist/harness/compaction.js +19 -2
  29. package/dist/harness/compaction.js.map +1 -1
  30. package/dist/harness/context.d.ts +23 -7
  31. package/dist/harness/context.d.ts.map +1 -1
  32. package/dist/harness/context.js +71 -25
  33. package/dist/harness/context.js.map +1 -1
  34. package/dist/harness/define.d.ts +7 -3
  35. package/dist/harness/define.d.ts.map +1 -1
  36. package/dist/harness/define.js +4 -0
  37. package/dist/harness/define.js.map +1 -1
  38. package/dist/harness/generation.d.ts +38 -5
  39. package/dist/harness/generation.d.ts.map +1 -1
  40. package/dist/harness/generation.js +445 -96
  41. package/dist/harness/generation.js.map +1 -1
  42. package/dist/harness/harness.d.ts +2 -0
  43. package/dist/harness/harness.d.ts.map +1 -1
  44. package/dist/harness/harness.js +87 -62
  45. package/dist/harness/harness.js.map +1 -1
  46. package/dist/harness/inbox.d.ts +5 -1
  47. package/dist/harness/inbox.d.ts.map +1 -1
  48. package/dist/harness/inbox.js +4 -1
  49. package/dist/harness/inbox.js.map +1 -1
  50. package/dist/harness/json.d.ts +20 -4
  51. package/dist/harness/json.d.ts.map +1 -1
  52. package/dist/harness/json.js +23 -5
  53. package/dist/harness/json.js.map +1 -1
  54. package/dist/harness/live.d.ts +122 -16
  55. package/dist/harness/live.d.ts.map +1 -1
  56. package/dist/harness/live.js +93 -12
  57. package/dist/harness/live.js.map +1 -1
  58. package/dist/harness/partial-changes.d.ts +54 -0
  59. package/dist/harness/partial-changes.d.ts.map +1 -0
  60. package/dist/harness/partial-changes.js +162 -0
  61. package/dist/harness/partial-changes.js.map +1 -0
  62. package/dist/harness/registry-reader.d.ts +11 -0
  63. package/dist/harness/registry-reader.d.ts.map +1 -0
  64. package/dist/harness/registry-reader.js +25 -0
  65. package/dist/harness/registry-reader.js.map +1 -0
  66. package/dist/harness/scheduler.d.ts +46 -19
  67. package/dist/harness/scheduler.d.ts.map +1 -1
  68. package/dist/harness/scheduler.js +973 -376
  69. package/dist/harness/scheduler.js.map +1 -1
  70. package/dist/harness/submissions.d.ts +17 -10
  71. package/dist/harness/submissions.d.ts.map +1 -1
  72. package/dist/harness/submissions.js +62 -25
  73. package/dist/harness/submissions.js.map +1 -1
  74. package/dist/harness/task-graph.d.ts +12 -9
  75. package/dist/harness/task-graph.d.ts.map +1 -1
  76. package/dist/harness/task-graph.js +38 -28
  77. package/dist/harness/task-graph.js.map +1 -1
  78. package/dist/harness/telemetry.d.ts +11 -11
  79. package/dist/harness/telemetry.d.ts.map +1 -1
  80. package/dist/harness/telemetry.js +7 -7
  81. package/dist/harness/telemetry.js.map +1 -1
  82. package/dist/harness/tool.d.ts +2 -0
  83. package/dist/harness/tool.d.ts.map +1 -1
  84. package/dist/harness/tool.js +171 -55
  85. package/dist/harness/tool.js.map +1 -1
  86. package/dist/harness/transcript.d.ts +72 -0
  87. package/dist/harness/transcript.d.ts.map +1 -0
  88. package/dist/harness/transcript.js +264 -0
  89. package/dist/harness/transcript.js.map +1 -0
  90. package/dist/harness/types.d.ts +218 -59
  91. package/dist/harness/types.d.ts.map +1 -1
  92. package/dist/harness/types.js.map +1 -1
  93. package/dist/harness/util.d.ts +3 -1
  94. package/dist/harness/util.d.ts.map +1 -1
  95. package/dist/harness/util.js +9 -0
  96. package/dist/harness/util.js.map +1 -1
  97. package/dist/harness/view.d.ts +43 -22
  98. package/dist/harness/view.d.ts.map +1 -1
  99. package/dist/harness/view.js +130 -71
  100. package/dist/harness/view.js.map +1 -1
  101. package/dist/index.d.ts +9 -7
  102. package/dist/index.d.ts.map +1 -1
  103. package/dist/index.js +4 -3
  104. package/dist/index.js.map +1 -1
  105. package/dist/search.d.ts +19 -3
  106. package/dist/search.d.ts.map +1 -1
  107. package/dist/search.js +107 -44
  108. package/dist/search.js.map +1 -1
  109. package/dist/session/cached-storage.d.ts +71 -0
  110. package/dist/session/cached-storage.d.ts.map +1 -0
  111. package/dist/session/cached-storage.js +269 -0
  112. package/dist/session/cached-storage.js.map +1 -0
  113. package/dist/session/conversation-tails.d.ts +33 -0
  114. package/dist/session/conversation-tails.d.ts.map +1 -0
  115. package/dist/session/conversation-tails.js +101 -0
  116. package/dist/session/conversation-tails.js.map +1 -0
  117. package/dist/session/keys.d.ts +68 -0
  118. package/dist/session/keys.d.ts.map +1 -0
  119. package/dist/session/keys.js +161 -0
  120. package/dist/session/keys.js.map +1 -0
  121. package/dist/session/session.d.ts +167 -26
  122. package/dist/session/session.d.ts.map +1 -1
  123. package/dist/session/session.js +1029 -171
  124. package/dist/session/session.js.map +1 -1
  125. package/dist/session/transaction.d.ts +81 -3
  126. package/dist/session/transaction.d.ts.map +1 -1
  127. package/dist/session/transaction.js +224 -37
  128. package/dist/session/transaction.js.map +1 -1
  129. package/dist/session/writer.d.ts +74 -0
  130. package/dist/session/writer.d.ts.map +1 -0
  131. package/dist/session/writer.js +294 -0
  132. package/dist/session/writer.js.map +1 -0
  133. package/dist/storage/indexeddb.d.ts +10 -2
  134. package/dist/storage/indexeddb.d.ts.map +1 -1
  135. package/dist/storage/indexeddb.js +91 -41
  136. package/dist/storage/indexeddb.js.map +1 -1
  137. package/dist/storage/jsonl/storage.d.ts +14 -2
  138. package/dist/storage/jsonl/storage.d.ts.map +1 -1
  139. package/dist/storage/jsonl/storage.js +88 -24
  140. package/dist/storage/jsonl/storage.js.map +1 -1
  141. package/dist/storage/memory.d.ts +7 -2
  142. package/dist/storage/memory.d.ts.map +1 -1
  143. package/dist/storage/memory.js +28 -2
  144. package/dist/storage/memory.js.map +1 -1
  145. package/dist/storage/sqlite/storage.d.ts +14 -2
  146. package/dist/storage/sqlite/storage.d.ts.map +1 -1
  147. package/dist/storage/sqlite/storage.js +110 -36
  148. package/dist/storage/sqlite/storage.js.map +1 -1
  149. package/dist/storage/store/commit.d.ts +33 -0
  150. package/dist/storage/store/commit.d.ts.map +1 -0
  151. package/dist/storage/store/commit.js +286 -0
  152. package/dist/storage/store/commit.js.map +1 -0
  153. package/dist/storage/store/documents.d.ts +43 -0
  154. package/dist/storage/store/documents.d.ts.map +1 -0
  155. package/dist/storage/store/documents.js +102 -0
  156. package/dist/storage/store/documents.js.map +1 -0
  157. package/dist/storage/store/index.d.ts +2 -0
  158. package/dist/storage/store/index.d.ts.map +1 -0
  159. package/dist/storage/store/index.js +2 -0
  160. package/dist/storage/store/index.js.map +1 -0
  161. package/dist/storage/store/queries.d.ts +49 -0
  162. package/dist/storage/store/queries.d.ts.map +1 -0
  163. package/dist/storage/store/queries.js +93 -0
  164. package/dist/storage/store/queries.js.map +1 -0
  165. package/dist/storage/store/storage.d.ts +59 -0
  166. package/dist/storage/store/storage.d.ts.map +1 -0
  167. package/dist/storage/store/storage.js +438 -0
  168. package/dist/storage/store/storage.js.map +1 -0
  169. package/dist/storage/store/tables.d.ts +54 -0
  170. package/dist/storage/store/tables.d.ts.map +1 -0
  171. package/dist/storage/store/tables.js +108 -0
  172. package/dist/storage/store/tables.js.map +1 -0
  173. package/dist/testing/commit-writes.d.ts +5 -0
  174. package/dist/testing/commit-writes.d.ts.map +1 -0
  175. package/dist/testing/commit-writes.js +12 -0
  176. package/dist/testing/commit-writes.js.map +1 -0
  177. package/dist/testing/env-conformance.js +7 -7
  178. package/dist/testing/env-conformance.js.map +1 -1
  179. package/dist/testing/index.d.ts +1 -0
  180. package/dist/testing/index.d.ts.map +1 -1
  181. package/dist/testing/index.js +1 -0
  182. package/dist/testing/index.js.map +1 -1
  183. package/dist/testing/storage-benchmark.d.ts.map +1 -1
  184. package/dist/testing/storage-benchmark.js +18 -17
  185. package/dist/testing/storage-benchmark.js.map +1 -1
  186. package/dist/testing/storage-conformance.d.ts.map +1 -1
  187. package/dist/testing/storage-conformance.js +354 -69
  188. package/dist/testing/storage-conformance.js.map +1 -1
  189. package/dist/tool-search/tool-search.d.ts +6 -12
  190. package/dist/tool-search/tool-search.d.ts.map +1 -1
  191. package/dist/tool-search/tool-search.js +7 -7
  192. package/dist/tool-search/tool-search.js.map +1 -1
  193. package/dist/tools/bash.d.ts +12 -12
  194. package/dist/tools/bash.d.ts.map +1 -1
  195. package/dist/tools/bash.js +16 -15
  196. package/dist/tools/bash.js.map +1 -1
  197. package/dist/tools/edit.d.ts +7 -7
  198. package/dist/tools/edit.d.ts.map +1 -1
  199. package/dist/tools/edit.js +9 -9
  200. package/dist/tools/edit.js.map +1 -1
  201. package/dist/tools/index.d.ts +32 -32
  202. package/dist/tools/read.d.ts +6 -6
  203. package/dist/tools/read.d.ts.map +1 -1
  204. package/dist/tools/read.js +19 -8
  205. package/dist/tools/read.js.map +1 -1
  206. package/dist/tools/write.d.ts +4 -4
  207. package/dist/tools/write.d.ts.map +1 -1
  208. package/dist/tools/write.js +5 -5
  209. package/dist/tools/write.js.map +1 -1
  210. package/dist/types.d.ts +223 -77
  211. package/dist/types.d.ts.map +1 -1
  212. package/dist/types.js.map +1 -1
  213. package/package.json +19 -12
  214. package/dist/harness/events.d.ts +0 -186
  215. package/dist/harness/events.d.ts.map +0 -1
  216. package/dist/harness/events.js +0 -373
  217. package/dist/harness/events.js.map +0 -1
  218. package/dist/session/observation.d.ts +0 -42
  219. package/dist/session/observation.d.ts.map +0 -1
  220. package/dist/session/observation.js +0 -281
  221. package/dist/session/observation.js.map +0 -1
@@ -1 +1 @@
1
- {"version":3,"file":"node-watch.js","sourceRoot":"","sources":["../../src/env/node-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAkB,KAAK,IAAI,OAAO,EAAc,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1E,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAEnD,OAAO,EAAE,SAAS,EAAwD,MAAM,YAAY,CAAC;AAwC7F,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB;;;;GAIG;AACH,MAAM,kBAAkB,GAAG,GAAG,CAAC;AAC/B,MAAM,eAAe,GAAG,IAAI,CAAC;AAC7B,MAAM,uBAAuB,GAAG,MAAM,CAAC;AACvC;gEACgE;AAChE,MAAM,cAAc,GAAG,GAAG,GAAG,IAAI,CAAC;AAClC,MAAM,cAAc,GAAG,IAAI,CAAC;AAE5B,iHAAiH;AACjH,MAAM,uBAAuB,GAAG,IAAI,GAAG,CAAC;IACvC,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,MAAM;IACd,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,OAAO;IACnB,UAAU,EAAE,uCAAuC;IACnD,UAAU,EAAE,2BAA2B;IACvC,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AI,IAAI,KAAK,MAAM,CAAC,IAAI;gBAAE,SAAS;YACnE,MAAM,UAAU,GAAG,QAAQ,CAAC,MAAM,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;YAC1D,IAAI,CAAC,MAAM,CAAC,SAAS,IAAI,UAAU,CAAC,MAAM,GAAG,CAAC;gBAAE,SAAS;YACzD,IAAI,UAAU,CAAC,IAAI,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM,EAAE,IAAI,CAAC,CAAC;gBAAE,SAAS;YAChE,OAAO,IAAI,CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAED,mHAAmH;AACnH,KAAK,UAAU,aAAa,CAAC,KAAwB;IACpD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACjF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjC,IAAI,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACxD,MAAM;QACP,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { type FSWatcher, watch as fsWatch, type Stats } from \"node:fs\";\nimport { lstat, readdir, readFile, stat, statfs } from \"node:fs/promises\";\nimport { dirname, relative, sep } from \"node:path\";\nimport type { Context } from \"@earendil-works/chord\";\nimport { FileError, type FileWatcher, type WatchChange, type WatchTarget } from \"./index.ts\";\n\n/** How `NodeExecutionEnv` watches. */\nexport interface NodeWatchOptions {\n\t/**\n\t * Force a mode. By default `polling` is chosen on Windows, where native watchers keep directories open and so block\n\t * renaming their parents, and for file systems that do not report remote changes.\n\t */\n\tmode?: \"native\" | \"polling\";\n\t/** Interval between snapshots in `polling` mode; default 2000 ms. */\n\tpollIntervalMs?: number;\n\t/** Most directories one watcher covers; default 10,000. */\n\tmaxDirectories?: number;\n}\n\ntype ResolvedTarget = {\n\treadonly path: string;\n\treadonly recursive: boolean;\n\treadonly hidden: boolean;\n\treadonly names: ReadonlySet<string>;\n};\n\n/** What a snapshot remembers of one path. Directories and ancestors are compared by identity only. */\ntype Entry = {\n\treadonly kind: \"file\" | \"directory\" | \"symlink\" | \"other\";\n\treadonly dev: number;\n\treadonly ino: number;\n\treadonly size: number;\n\treadonly mtimeMs: number;\n\treadonly hash?: string;\n};\n\ntype Snapshot = Map<string, Entry>;\n\n/** A native watcher and the identity of what it was installed on: a path replaced by another file needs a new one. */\ntype Installed = { readonly watcher: FSWatcher; readonly dev: number; readonly ino: number };\n\n/** A scan: the snapshot, and targets that are symbolic links to files, whose files need their own watchers. */\ntype Scan = { readonly snapshot: Snapshot; readonly linkedFiles: ReadonlySet<string> };\n\nconst DEBOUNCE_MS = 50;\n/**\n * On macOS, `fs.watch` returns before libuv's FSEvents stream is live, and changes in between are never reported\n * (about 2% of changes made right after the call, none after 100 ms). A rescan this long after installing watchers\n * catches them.\n */\nconst FSEVENTS_SETTLE_MS = 500;\nconst DEFAULT_POLL_MS = 2000;\nconst DEFAULT_MAX_DIRECTORIES = 10_000;\n/** In polling mode, recently modified small files are also compared by content: a second write within the file system's\n * timestamp granularity can keep size and modification time. */\nconst HASH_MAX_BYTES = 256 * 1024;\nconst HASH_RECENT_MS = 5000;\n\n/** Linux `statfs` magic numbers of file systems that accept watches but do not report changes made elsewhere. */\nconst UNRELIABLE_FILE_SYSTEMS = new Set([\n\t0x6969, // NFS\n\t0x517b, // SMB\n\t0xff534d42, // CIFS\n\t0xfe534d42, // SMB2\n\t0x65735546, // FUSE (sshfs, Android shared storage)\n\t0x01021997, // 9P (WSL2 Windows drives)\n\t0x0bd00bd0, // Lustre\n\t0x47504653, // GPFS\n\t0x00c36400, // Ceph\n\t0x5346414f, // OpenAFS\n\t0x6b414653, // kAFS\n\t0x5dca2df5, // sdcardfs\n]);\n\nclass BudgetExceeded extends Error {}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n\treturn error instanceof Error && \"code\" in error;\n}\n\nfunction isDenied(error: unknown): boolean {\n\treturn isNodeError(error) && (error.code === \"EACCES\" || error.code === \"EPERM\");\n}\n\nfunction entryOf(stats: Stats, hash?: string): Entry {\n\tconst kind = stats.isFile()\n\t\t? \"file\"\n\t\t: stats.isDirectory()\n\t\t\t? \"directory\"\n\t\t\t: stats.isSymbolicLink()\n\t\t\t\t? \"symlink\"\n\t\t\t\t: \"other\";\n\treturn {\n\t\tkind,\n\t\tdev: stats.dev,\n\t\tino: stats.ino,\n\t\tsize: kind === \"directory\" ? 0 : stats.size,\n\t\tmtimeMs: kind === \"directory\" ? 0 : stats.mtimeMs,\n\t\t...(hash === undefined ? {} : { hash }),\n\t};\n}\n\nfunction sameEntry(a: Entry, b: Entry): boolean {\n\treturn (\n\t\ta.kind === b.kind &&\n\t\ta.dev === b.dev &&\n\t\ta.ino === b.ino &&\n\t\ta.size === b.size &&\n\t\ta.mtimeMs === b.mtimeMs &&\n\t\ta.hash === b.hash\n\t);\n}\n\n/** Ancestors of `path`, nearest first, up to the root. */\nfunction ancestorsOf(path: string): string[] {\n\tconst result: string[] = [];\n\tfor (let current = dirname(path); ; current = dirname(current)) {\n\t\tresult.push(current);\n\t\tif (dirname(current) === current) return result;\n\t}\n}\n\n/** Whether `path` is `ancestor` or below it. */\nfunction isWithin(path: string, ancestor: string): boolean {\n\treturn path === ancestor || path.startsWith(ancestor.endsWith(sep) ? ancestor : ancestor + sep);\n}\n\nfunction excluded(target: ResolvedTarget, name: string): boolean {\n\treturn (target.hidden && name.startsWith(\".\")) || target.names.has(name);\n}\n\n/**\n * Watches by snapshots: native events only trigger a debounced rescan, and changes are the difference between\n * snapshots plus the event paths. A replaced file, a renamed or recreated ancestor, or a directory created with its\n * contents therefore never depends on which events an operating system sends. New directories get their watchers\n * before they are scanned again, so nothing written into them before the watcher existed is missed.\n */\nexport class NodeFileWatcher implements FileWatcher {\n\treadonly #targets: readonly ResolvedTarget[];\n\treadonly #onChange: (change: WatchChange) => void;\n\treadonly #pollIntervalMs: number;\n\treadonly #maxDirectories: number;\n\treadonly #watchers = new Map<string, Installed>();\n\treadonly #events = new Set<string>();\n\t#mode: \"native\" | \"polling\";\n\t#snapshot: Snapshot = new Map();\n\t#timer: ReturnType<typeof setTimeout> | undefined;\n\t#settleTimer: ReturnType<typeof setTimeout> | undefined;\n\t#running: Promise<void> | undefined;\n\t#dirty = false;\n\t#closed = false;\n\n\tprivate constructor(\n\t\ttargets: readonly ResolvedTarget[],\n\t\tonChange: (change: WatchChange) => void,\n\t\tmode: \"native\" | \"polling\",\n\t\toptions: NodeWatchOptions,\n\t) {\n\t\tthis.#targets = targets;\n\t\tthis.#onChange = onChange;\n\t\tthis.#mode = mode;\n\t\tthis.#pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_MS;\n\t\tthis.#maxDirectories = options.maxDirectories ?? DEFAULT_MAX_DIRECTORIES;\n\t}\n\n\t/** Establish coverage: watchers first, then the snapshot later changes are compared with. */\n\tstatic async open(\n\t\ttargets: readonly WatchTarget[],\n\t\tresolvePath: (path: string) => string,\n\t\tonChange: (change: WatchChange) => void,\n\t\toptions: NodeWatchOptions,\n\t): Promise<NodeFileWatcher> {\n\t\tconst resolved = targets.map((target) => ({\n\t\t\tpath: resolvePath(target.path),\n\t\t\trecursive: target.recursive === true,\n\t\t\thidden: target.exclude?.hidden === true,\n\t\t\tnames: new Set(target.exclude?.names ?? []),\n\t\t}));\n\t\t// Windows refuses to rename a directory while another directory below it is open, and a native watcher keeps\n\t\t// every watched directory open: watching would break renames of their parents, so Windows polls.\n\t\tconst mode =\n\t\t\toptions.mode ??\n\t\t\t(process.platform === \"win32\" || (await anyUnreliable(resolved.map((target) => target.path)))\n\t\t\t\t? \"polling\"\n\t\t\t\t: \"native\");\n\t\tconst watcher = new NodeFileWatcher(resolved, onChange, mode, options);\n\t\ttry {\n\t\t\tawait watcher.#sync(false);\n\t\t} catch (error) {\n\t\t\twatcher.#stop();\n\t\t\tif (error instanceof BudgetExceeded) throw new FileError(\"invalid\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\twatcher.#schedulePoll();\n\t\treturn watcher;\n\t}\n\n\tget mode(): \"native\" | \"polling\" {\n\t\treturn this.#mode;\n\t}\n\n\tasync close(_context: Context): Promise<void> {\n\t\tif (this.#closed) return;\n\t\tthis.#stop();\n\t\tawait this.#running;\n\t}\n\n\t#stop(): void {\n\t\tthis.#closed = true;\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tclearTimeout(this.#settleTimer);\n\t\tthis.#settleTimer = undefined;\n\t\tfor (const { watcher } of this.#watchers.values()) watcher.close();\n\t\tthis.#watchers.clear();\n\t}\n\n\t#deliver(change: WatchChange): void {\n\t\tif (this.#closed) return;\n\t\ttry {\n\t\t\tthis.#onChange(change);\n\t\t} catch {\n\t\t\t// A throwing callback must not stop watching.\n\t\t}\n\t}\n\n\t#schedulePoll(): void {\n\t\tif (this.#closed || this.#mode !== \"polling\") return;\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tvoid this.#flush().finally(() => this.#schedulePoll());\n\t\t}, this.#pollIntervalMs);\n\t}\n\n\t#scheduleFlush(): void {\n\t\tif (this.#closed || this.#timer !== undefined) return;\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tvoid this.#flush();\n\t\t}, DEBOUNCE_MS);\n\t}\n\n\t#scheduleSettle(): void {\n\t\tif (this.#closed) return;\n\t\tclearTimeout(this.#settleTimer);\n\t\tthis.#settleTimer = setTimeout(() => {\n\t\t\tthis.#settleTimer = undefined;\n\t\t\tvoid this.#flush();\n\t\t}, FSEVENTS_SETTLE_MS);\n\t}\n\n\t#flush(): Promise<void> {\n\t\tif (this.#running !== undefined) {\n\t\t\tthis.#dirty = true;\n\t\t\treturn this.#running;\n\t\t}\n\t\tthis.#running = (async () => {\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tthis.#dirty = false;\n\t\t\t\t\tconst events = [...this.#events];\n\t\t\t\t\tthis.#events.clear();\n\t\t\t\t\tconst changed = await this.#sync(true);\n\t\t\t\t\tfor (const path of events) changed.add(path);\n\t\t\t\t\tif (changed.size > 0) this.#deliver({ paths: [...changed].sort() });\n\t\t\t\t} while (this.#dirty && !this.#closed);\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst fileError =\n\t\t\t\t\terror instanceof FileError\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new FileError(isDenied(error) ? \"permission_denied\" : \"invalid\", message);\n\t\t\t\tthis.#deliver({ error: fileError });\n\t\t\t\tthis.#stop();\n\t\t\t} finally {\n\t\t\t\tthis.#running = undefined;\n\t\t\t}\n\t\t})();\n\t\treturn this.#running;\n\t}\n\n\t/** Rescan, report differences, and install watchers for new directories, rescanning until none are new. */\n\tasync #sync(report: boolean): Promise<Set<string>> {\n\t\tconst changed = new Set<string>();\n\t\tfor (let round = 0; round < 10 && !this.#closed; round++) {\n\t\t\tconst scan = await this.#scan();\n\t\t\t// Closed during the scan: installing watchers now would leak them.\n\t\t\tif (this.#closed) break;\n\t\t\tconst next = scan.snapshot;\n\t\t\tif (report) for (const path of this.#diff(this.#snapshot, next)) changed.add(path);\n\t\t\tthis.#snapshot = next;\n\t\t\tif (this.#mode === \"polling\" || !this.#reconcileWatchers(scan)) break;\n\t\t\tif (process.platform === \"darwin\") this.#scheduleSettle();\n\t\t\t// Something written into a new directory before its watcher existed shows up in the next round.\n\t\t\treport = true;\n\t\t}\n\t\treturn changed;\n\t}\n\n\t#diff(previous: Snapshot, next: Snapshot): string[] {\n\t\tconst changed: string[] = [];\n\t\tfor (const [path, entry] of next) {\n\t\t\tconst before = previous.get(path);\n\t\t\tif (before === undefined || !sameEntry(before, entry)) changed.push(this.#reported(path));\n\t\t}\n\t\tfor (const path of previous.keys()) if (!next.has(path)) changed.push(this.#reported(path));\n\t\treturn changed;\n\t}\n\n\t/** An ancestor that changed identity moved every target below it; report those targets. */\n\t#reported(path: string): string {\n\t\tif (this.#targets.some((target) => isWithin(path, target.path))) return path;\n\t\treturn this.#targets.find((target) => isWithin(target.path, path))?.path ?? path;\n\t}\n\n\tasync #scan(): Promise<Scan> {\n\t\tconst snapshot: Snapshot = new Map();\n\t\tconst linkedFiles = new Set<string>();\n\t\t// Directories are counted once, but traversed once per target: overlapping targets differ in recursion and\n\t\t// exclusions, and an entry recorded for one target must still be descended into for another.\n\t\tconst counted = new Set<string>();\n\t\tconst traversed = new Set<string>();\n\t\t/** Kinds of listed entries, not following links: a target that links to a directory is recorded by `stat`, but\n\t\t * symbolic links below a recursive target are not followed. */\n\t\tconst listed = new Map<string, Entry[\"kind\"]>();\n\t\tconst countDirectory = (path: string): void => {\n\t\t\tcounted.add(path);\n\t\t\tif (counted.size > this.#maxDirectories) {\n\t\t\t\tthrow new BudgetExceeded(`Watched paths exceed ${this.#maxDirectories} directories`);\n\t\t\t}\n\t\t};\n\t\tconst record = async (path: string, stats: Stats): Promise<void> => {\n\t\t\tlet hash: string | undefined;\n\t\t\tif (\n\t\t\t\tthis.#mode === \"polling\" &&\n\t\t\t\tstats.isFile() &&\n\t\t\t\tstats.size <= HASH_MAX_BYTES &&\n\t\t\t\tDate.now() - stats.mtimeMs < HASH_RECENT_MS\n\t\t\t) {\n\t\t\t\thash = await readFile(path).then(\n\t\t\t\t\t(content) => createHash(\"sha256\").update(content).digest(\"hex\"),\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tsnapshot.set(path, entryOf(stats, hash));\n\t\t};\n\t\tconst scanDirectory = async (index: number, target: ResolvedTarget, directory: string): Promise<void> => {\n\t\t\tconst key = `${index}\\0${directory}`;\n\t\t\tif (traversed.has(key)) return;\n\t\t\ttraversed.add(key);\n\t\t\tlet names: string[];\n\t\t\ttry {\n\t\t\t\tnames = await readdir(directory);\n\t\t\t} catch (error) {\n\t\t\t\t// The watched directory itself must be readable; below it, unreadable directories are skipped.\n\t\t\t\tif (directory === target.path && isDenied(error)) throw error;\n\t\t\t\tif (isNodeError(error) && [\"ENOENT\", \"EACCES\", \"EPERM\", \"ENOTDIR\"].includes(error.code ?? \"\")) return;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tfor (const name of names) {\n\t\t\t\tif (excluded(target, name)) continue;\n\t\t\t\tconst path = `${directory.endsWith(sep) ? directory : directory + sep}${name}`;\n\t\t\t\tlet kind = listed.get(path);\n\t\t\t\tif (kind === undefined) {\n\t\t\t\t\tconst stats = await lstat(path).catch(() => undefined);\n\t\t\t\t\tif (stats === undefined) continue;\n\t\t\t\t\tkind = entryOf(stats).kind;\n\t\t\t\t\tlisted.set(path, kind);\n\t\t\t\t\t// A target's own entry (following links) wins over its listing by another target.\n\t\t\t\t\tif (!snapshot.has(path)) await record(path, stats);\n\t\t\t\t}\n\t\t\t\tif (target.recursive && kind === \"directory\") {\n\t\t\t\t\tcountDirectory(path);\n\t\t\t\t\tawait scanDirectory(index, target, path);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (const [index, target] of this.#targets.entries()) {\n\t\t\tfor (const ancestor of ancestorsOf(target.path)) {\n\t\t\t\tif (snapshot.has(ancestor)) continue;\n\t\t\t\tconst stats = await lstat(ancestor).catch(() => undefined);\n\t\t\t\t// Identity only: an ancestor's own timestamps change with every unrelated sibling.\n\t\t\t\tif (stats !== undefined) snapshot.set(ancestor, { ...entryOf(stats), size: 0, mtimeMs: 0 });\n\t\t\t}\n\t\t\t// The target itself may be a symbolic link to what is watched; follow it. A missing target is watched for its\n\t\t\t// creation; one that cannot be reached for lack of permission fails.\n\t\t\tlet stats: Stats;\n\t\t\ttry {\n\t\t\t\tstats = await stat(target.path);\n\t\t\t} catch (error) {\n\t\t\t\tif (isDenied(error)) throw error;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait record(target.path, stats);\n\t\t\tif (stats.isFile() && (await lstat(target.path).catch(() => undefined))?.isSymbolicLink()) {\n\t\t\t\tlinkedFiles.add(target.path);\n\t\t\t}\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tcountDirectory(target.path);\n\t\t\t\tawait scanDirectory(index, target, target.path);\n\t\t\t}\n\t\t}\n\t\treturn { snapshot, linkedFiles };\n\t}\n\n\t/**\n\t * Watch every existing ancestor of each target, each target directory, each target that is a symbolic link to a file\n\t * (changes to that file are not events of the link's directory), and on Linux each directory below a recursive target\n\t * (elsewhere one recursive watcher per target). Returns whether a watcher was added.\n\t */\n\t#reconcileWatchers({ snapshot, linkedFiles }: Scan): boolean {\n\t\tconst wanted = new Map<string, boolean>();\n\t\tfor (const path of linkedFiles) wanted.set(path, false);\n\t\tconst perDirectory = process.platform === \"linux\" || process.platform === \"android\";\n\t\tfor (const target of this.#targets) {\n\t\t\tfor (const ancestor of ancestorsOf(target.path)) {\n\t\t\t\tif (snapshot.get(ancestor)?.kind === \"directory\" && !wanted.has(ancestor)) wanted.set(ancestor, false);\n\t\t\t}\n\t\t\tif (snapshot.get(target.path)?.kind !== \"directory\") continue;\n\t\t\tconst recursiveRoot = target.recursive && !perDirectory;\n\t\t\twanted.set(target.path, recursiveRoot);\n\t\t\tif (target.recursive && perDirectory) {\n\t\t\t\tfor (const [path, entry] of snapshot) {\n\t\t\t\t\tif (entry.kind === \"directory\" && path !== target.path && isWithin(path, target.path)) {\n\t\t\t\t\t\twanted.set(path, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const [path, installed] of this.#watchers) {\n\t\t\tconst entry = snapshot.get(path);\n\t\t\t// Gone, or replaced: a watcher follows the directory it was installed on, not the path.\n\t\t\tif (!wanted.has(path) || entry === undefined || entry.dev !== installed.dev || entry.ino !== installed.ino) {\n\t\t\t\tinstalled.watcher.close();\n\t\t\t\tthis.#watchers.delete(path);\n\t\t\t}\n\t\t}\n\t\tlet added = false;\n\t\tfor (const [path, recursive] of wanted) {\n\t\t\tconst entry = snapshot.get(path);\n\t\t\tif (this.#watchers.has(path) || entry === undefined) continue;\n\t\t\tconst linked = linkedFiles.has(path);\n\t\t\ttry {\n\t\t\t\tconst watcher = fsWatch(path, { recursive, persistent: false }, (_event, filename) =>\n\t\t\t\t\tlinked\n\t\t\t\t\t\t? this.#onLinkedFileEvent(path)\n\t\t\t\t\t\t: this.#onEvent(path, filename === null ? undefined : String(filename)),\n\t\t\t\t);\n\t\t\t\t// A watched directory that disappears or fails: rescan, which also replaces the watcher.\n\t\t\t\twatcher.on(\"error\", () => {\n\t\t\t\t\twatcher.close();\n\t\t\t\t\tif (this.#watchers.get(path)?.watcher === watcher) this.#watchers.delete(path);\n\t\t\t\t\tthis.#scheduleFlush();\n\t\t\t\t});\n\t\t\t\tthis.#watchers.set(path, { watcher, dev: entry.dev, ino: entry.ino });\n\t\t\t\tadded = true;\n\t\t\t} catch (error) {\n\t\t\t\t// Out of watches or unsupported: compare snapshots from now on, and say coverage was uncertain.\n\t\t\t\tif (isNodeError(error) && error.code !== \"ENOENT\" && error.code !== \"EACCES\" && error.code !== \"EPERM\") {\n\t\t\t\t\tthis.#switchToPolling();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn added;\n\t}\n\n\t#switchToPolling(): void {\n\t\tif (this.#mode === \"polling\") return;\n\t\tthis.#mode = \"polling\";\n\t\tfor (const { watcher } of this.#watchers.values()) watcher.close();\n\t\tthis.#watchers.clear();\n\t\tthis.#deliver({ overflow: true });\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tthis.#schedulePoll();\n\t}\n\n\t#onEvent(directory: string, filename: string | undefined): void {\n\t\tif (this.#closed) return;\n\t\tconst path =\n\t\t\tfilename === undefined ? directory : `${directory.endsWith(sep) ? directory : directory + sep}${filename}`;\n\t\t// Events about unrelated siblings of an ancestor, or about excluded entries, are ignored.\n\t\tconst relevant = this.#inScope(path);\n\t\tif (relevant) this.#events.add(this.#reported(path));\n\t\tif (relevant || filename === undefined) this.#scheduleFlush();\n\t}\n\n\t/** The file a target links to changed: report the target. */\n\t#onLinkedFileEvent(target: string): void {\n\t\tif (this.#closed) return;\n\t\tthis.#events.add(target);\n\t\tthis.#scheduleFlush();\n\t}\n\n\t#inScope(path: string): boolean {\n\t\tfor (const target of this.#targets) {\n\t\t\tif (isWithin(target.path, path)) return true;\n\t\t\tif (!isWithin(path, target.path) || path === target.path) continue;\n\t\t\tconst components = relative(target.path, path).split(sep);\n\t\t\tif (!target.recursive && components.length > 1) continue;\n\t\t\tif (components.some((name) => excluded(target, name))) continue;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/** Whether any path, or its nearest existing ancestor, is on a file system that does not report remote changes. */\nasync function anyUnreliable(paths: readonly string[]): Promise<boolean> {\n\tif (process.platform !== \"linux\" && process.platform !== \"android\") return false;\n\tfor (const path of paths) {\n\t\tfor (const candidate of [path, ...ancestorsOf(path)]) {\n\t\t\tconst info = await statfs(candidate).catch(() => undefined);\n\t\t\tif (info === undefined) continue;\n\t\t\tif (UNRELIABLE_FILE_SYSTEMS.has(info.type)) return true;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn false;\n}\n"]}
1
+ {"version":3,"file":"node-watch.js","sourceRoot":"","sources":["../../src/env/node-watch.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAkB,KAAK,IAAI,OAAO,EAA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CAAC;QACb,CAAC;QACD,OAAO,KAAK,CAAC;IACd,CAAC;CACD;AAED,mHAAmH;AACnH,KAAK,UAAU,aAAa,CAAC,KAAwB;IACpD,IAAI,OAAO,CAAC,QAAQ,KAAK,OAAO,IAAI,OAAO,CAAC,QAAQ,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IACjF,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QAC1B,KAAK,MAAM,SAAS,IAAI,CAAC,IAAI,EAAE,GAAG,WAAW,CAAC,IAAI,CAAC,CAAC,EAAE,CAAC;YACtD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,SAAS,CAAC,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,SAAS,CAAC,CAAC;YAC5D,IAAI,IAAI,KAAK,SAAS;gBAAE,SAAS;YACjC,IAAI,uBAAuB,CAAC,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;gBAAE,OAAO,IAAI,CAAC;YACxD,MAAM;QACP,CAAC;IACF,CAAC;IACD,OAAO,KAAK,CAAC;AACd,CAAC","sourcesContent":["import { createHash } from \"node:crypto\";\nimport { type FSWatcher, watch as fsWatch, type Stats } from \"node:fs\";\nimport { lstat, readdir, readFile, stat, statfs } from \"node:fs/promises\";\nimport { dirname, relative, sep } from \"node:path\";\nimport type { Context } from \"@earendil-works/chord\";\nimport { type FileChange, FileError, type FileWatcher, type WatchTarget } from \"./index.ts\";\n\n/** How `NodeExecutionEnv` watches. */\nexport interface NodeWatchOptions {\n\t/**\n\t * Force a mode. By default `polling` is chosen on Windows, where native watchers keep directories open and so block\n\t * renaming their parents, and for file systems that do not report remote changes.\n\t */\n\tmode?: \"native\" | \"polling\";\n\t/** Interval between snapshots in `polling` mode; default 2000 ms. */\n\tpollIntervalMs?: number;\n\t/** Most directories one watcher covers; default 10,000. */\n\tmaxDirectories?: number;\n}\n\ntype ResolvedTarget = {\n\treadonly path: string;\n\treadonly recursive: boolean;\n\treadonly hidden: boolean;\n\treadonly names: ReadonlySet<string>;\n};\n\n/** What a snapshot remembers of one path. Directories and ancestors are compared by identity only. */\ntype Entry = {\n\treadonly kind: \"file\" | \"directory\" | \"symlink\" | \"other\";\n\treadonly dev: number;\n\treadonly ino: number;\n\treadonly size: number;\n\treadonly mtimeMs: number;\n\treadonly hash?: string;\n};\n\ntype Snapshot = Map<string, Entry>;\n\n/** A native watcher and the identity of what it was installed on: a path replaced by another file needs a new one. */\ntype Installed = { readonly watcher: FSWatcher; readonly dev: number; readonly ino: number };\n\n/** A scan: the snapshot, and targets that are symbolic links to files, whose files need their own watchers. */\ntype Scan = { readonly snapshot: Snapshot; readonly linkedFiles: ReadonlySet<string> };\n\nconst DEBOUNCE_MS = 50;\n/**\n * On macOS, `fs.watch` returns before libuv's FSEvents stream is live, and changes in between are never reported\n * (about 2% of changes made right after the call, none after 100 ms). A rescan this long after installing watchers\n * catches them.\n */\nconst FSEVENTS_SETTLE_MS = 500;\nconst DEFAULT_POLL_MS = 2000;\nconst DEFAULT_MAX_DIRECTORIES = 10_000;\n/** The one `overflow` change; it carries nothing else. */\nconst OVERFLOW: FileChange = { kind: \"overflow\" };\n/** In polling mode, recently modified small files are also compared by content: a second write within the file system's\n * timestamp granularity can keep size and modification time. */\nconst HASH_MAX_BYTES = 256 * 1024;\nconst HASH_RECENT_MS = 5000;\n\n/** Linux `statfs` magic numbers of file systems that accept watches but do not report changes made elsewhere. */\nconst UNRELIABLE_FILE_SYSTEMS = new Set([\n\t0x6969, // NFS\n\t0x517b, // SMB\n\t0xff534d42, // CIFS\n\t0xfe534d42, // SMB2\n\t0x65735546, // FUSE (sshfs, Android shared storage)\n\t0x01021997, // 9P (WSL2 Windows drives)\n\t0x0bd00bd0, // Lustre\n\t0x47504653, // GPFS\n\t0x00c36400, // Ceph\n\t0x5346414f, // OpenAFS\n\t0x6b414653, // kAFS\n\t0x5dca2df5, // sdcardfs\n]);\n\nclass BudgetExceeded extends Error {}\n\nfunction isNodeError(error: unknown): error is NodeJS.ErrnoException {\n\treturn error instanceof Error && \"code\" in error;\n}\n\nfunction isDenied(error: unknown): boolean {\n\treturn isNodeError(error) && (error.code === \"EACCES\" || error.code === \"EPERM\");\n}\n\nfunction entryOf(stats: Stats, hash?: string): Entry {\n\tconst kind = stats.isFile()\n\t\t? \"file\"\n\t\t: stats.isDirectory()\n\t\t\t? \"directory\"\n\t\t\t: stats.isSymbolicLink()\n\t\t\t\t? \"symlink\"\n\t\t\t\t: \"other\";\n\treturn {\n\t\tkind,\n\t\tdev: stats.dev,\n\t\tino: stats.ino,\n\t\tsize: kind === \"directory\" ? 0 : stats.size,\n\t\tmtimeMs: kind === \"directory\" ? 0 : stats.mtimeMs,\n\t\t...(hash === undefined ? {} : { hash }),\n\t};\n}\n\nfunction sameEntry(a: Entry, b: Entry): boolean {\n\treturn (\n\t\ta.kind === b.kind &&\n\t\ta.dev === b.dev &&\n\t\ta.ino === b.ino &&\n\t\ta.size === b.size &&\n\t\ta.mtimeMs === b.mtimeMs &&\n\t\ta.hash === b.hash\n\t);\n}\n\n/** Ancestors of `path`, nearest first, up to the root. */\nfunction ancestorsOf(path: string): string[] {\n\tconst result: string[] = [];\n\tfor (let current = dirname(path); ; current = dirname(current)) {\n\t\tresult.push(current);\n\t\tif (dirname(current) === current) return result;\n\t}\n}\n\n/** Whether `path` is `ancestor` or below it. */\nfunction isWithin(path: string, ancestor: string): boolean {\n\treturn path === ancestor || path.startsWith(ancestor.endsWith(sep) ? ancestor : ancestor + sep);\n}\n\nfunction excluded(target: ResolvedTarget, name: string): boolean {\n\treturn (target.hidden && name.startsWith(\".\")) || target.names.has(name);\n}\n\n/**\n * Watches by snapshots: native events only trigger a debounced rescan, and changes are the difference between\n * snapshots plus the event paths. A replaced file, a renamed or recreated ancestor, or a directory created with its\n * contents therefore never depends on which events an operating system sends. New directories get their watchers\n * before they are scanned again, so nothing written into them before the watcher existed is missed.\n */\nexport class NodeFileWatcher implements FileWatcher {\n\treadonly #targets: readonly ResolvedTarget[];\n\treadonly #onChange: (change: FileChange) => void;\n\treadonly #pollIntervalMs: number;\n\treadonly #maxDirectories: number;\n\treadonly #watchers = new Map<string, Installed>();\n\treadonly #events = new Set<string>();\n\t#mode: \"native\" | \"polling\";\n\t#snapshot: Snapshot = new Map();\n\t#timer: ReturnType<typeof setTimeout> | undefined;\n\t#settleTimer: ReturnType<typeof setTimeout> | undefined;\n\t#running: Promise<void> | undefined;\n\t#dirty = false;\n\t#stopped = false;\n\n\tprivate constructor(\n\t\ttargets: readonly ResolvedTarget[],\n\t\tonChange: (change: FileChange) => void,\n\t\tmode: \"native\" | \"polling\",\n\t\toptions: NodeWatchOptions,\n\t) {\n\t\tthis.#targets = targets;\n\t\tthis.#onChange = onChange;\n\t\tthis.#mode = mode;\n\t\tthis.#pollIntervalMs = options.pollIntervalMs ?? DEFAULT_POLL_MS;\n\t\tthis.#maxDirectories = options.maxDirectories ?? DEFAULT_MAX_DIRECTORIES;\n\t}\n\n\t/** Establish coverage: watchers first, then the snapshot later changes are compared with. */\n\tstatic async open(\n\t\ttargets: readonly WatchTarget[],\n\t\tresolvePath: (path: string) => string,\n\t\tonChange: (change: FileChange) => void,\n\t\toptions: NodeWatchOptions,\n\t): Promise<NodeFileWatcher> {\n\t\tconst resolved = targets.map((target) => ({\n\t\t\tpath: resolvePath(target.path),\n\t\t\trecursive: target.recursive === true,\n\t\t\thidden: target.exclude?.hidden === true,\n\t\t\tnames: new Set(target.exclude?.names ?? []),\n\t\t}));\n\t\t// Windows refuses to rename a directory while another directory below it is open, and a native watcher keeps\n\t\t// every watched directory open: watching would break renames of their parents, so Windows polls.\n\t\tconst mode =\n\t\t\toptions.mode ??\n\t\t\t(process.platform === \"win32\" || (await anyUnreliable(resolved.map((target) => target.path)))\n\t\t\t\t? \"polling\"\n\t\t\t\t: \"native\");\n\t\tconst watcher = new NodeFileWatcher(resolved, onChange, mode, options);\n\t\ttry {\n\t\t\tawait watcher.#sync(false);\n\t\t} catch (error) {\n\t\t\twatcher.#stop();\n\t\t\tif (error instanceof BudgetExceeded) throw new FileError(\"invalid\", error.message);\n\t\t\tthrow error;\n\t\t}\n\t\twatcher.#schedulePoll();\n\t\treturn watcher;\n\t}\n\n\tget mode(): \"native\" | \"polling\" {\n\t\treturn this.#mode;\n\t}\n\n\tasync stop(_context: Context): Promise<void> {\n\t\tif (this.#stopped) return;\n\t\tthis.#stop();\n\t\tawait this.#running;\n\t}\n\n\t#stop(): void {\n\t\tthis.#stopped = true;\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tclearTimeout(this.#settleTimer);\n\t\tthis.#settleTimer = undefined;\n\t\tfor (const { watcher } of this.#watchers.values()) watcher.close();\n\t\tthis.#watchers.clear();\n\t}\n\n\t#deliver(change: FileChange): void {\n\t\tif (this.#stopped) return;\n\t\ttry {\n\t\t\tthis.#onChange(change);\n\t\t} catch {\n\t\t\t// A throwing callback must not stop watching.\n\t\t}\n\t}\n\n\t#schedulePoll(): void {\n\t\tif (this.#stopped || this.#mode !== \"polling\") return;\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tvoid this.#flush().finally(() => this.#schedulePoll());\n\t\t}, this.#pollIntervalMs);\n\t}\n\n\t#scheduleFlush(): void {\n\t\tif (this.#stopped || this.#timer !== undefined) return;\n\t\tthis.#timer = setTimeout(() => {\n\t\t\tthis.#timer = undefined;\n\t\t\tvoid this.#flush();\n\t\t}, DEBOUNCE_MS);\n\t}\n\n\t#scheduleSettle(): void {\n\t\tif (this.#stopped) return;\n\t\tclearTimeout(this.#settleTimer);\n\t\tthis.#settleTimer = setTimeout(() => {\n\t\t\tthis.#settleTimer = undefined;\n\t\t\tvoid this.#flush();\n\t\t}, FSEVENTS_SETTLE_MS);\n\t}\n\n\t#flush(): Promise<void> {\n\t\tif (this.#running !== undefined) {\n\t\t\tthis.#dirty = true;\n\t\t\treturn this.#running;\n\t\t}\n\t\tthis.#running = (async () => {\n\t\t\ttry {\n\t\t\t\tdo {\n\t\t\t\t\tthis.#dirty = false;\n\t\t\t\t\tconst events = [...this.#events];\n\t\t\t\t\tthis.#events.clear();\n\t\t\t\t\tconst changed = await this.#sync(true);\n\t\t\t\t\tfor (const path of events) changed.add(path);\n\t\t\t\t\tif (changed.size > 0) this.#deliver({ kind: \"paths\", paths: [...changed].sort() });\n\t\t\t\t} while (this.#dirty && !this.#stopped);\n\t\t\t} catch (error) {\n\t\t\t\tconst message = error instanceof Error ? error.message : String(error);\n\t\t\t\tconst fileError =\n\t\t\t\t\terror instanceof FileError\n\t\t\t\t\t\t? error\n\t\t\t\t\t\t: new FileError(isDenied(error) ? \"permission_denied\" : \"invalid\", message);\n\t\t\t\tthis.#deliver({ kind: \"failed\", error: fileError });\n\t\t\t\tthis.#stop();\n\t\t\t} finally {\n\t\t\t\tthis.#running = undefined;\n\t\t\t}\n\t\t})();\n\t\treturn this.#running;\n\t}\n\n\t/** Rescan, report differences, and install watchers for new directories, rescanning until none are new. */\n\tasync #sync(report: boolean): Promise<Set<string>> {\n\t\tconst changed = new Set<string>();\n\t\tfor (let round = 0; round < 10 && !this.#stopped; round++) {\n\t\t\tconst scan = await this.#scan();\n\t\t\t// Closed during the scan: installing watchers now would leak them.\n\t\t\tif (this.#stopped) break;\n\t\t\tconst next = scan.snapshot;\n\t\t\tif (report) for (const path of this.#diff(this.#snapshot, next)) changed.add(path);\n\t\t\tthis.#snapshot = next;\n\t\t\tif (this.#mode === \"polling\" || !this.#reconcileWatchers(scan)) break;\n\t\t\tif (process.platform === \"darwin\") this.#scheduleSettle();\n\t\t\t// Something written into a new directory before its watcher existed shows up in the next round.\n\t\t\treport = true;\n\t\t}\n\t\treturn changed;\n\t}\n\n\t#diff(previous: Snapshot, next: Snapshot): string[] {\n\t\tconst changed: string[] = [];\n\t\tfor (const [path, entry] of next) {\n\t\t\tconst before = previous.get(path);\n\t\t\tif (before === undefined || !sameEntry(before, entry)) changed.push(this.#reported(path));\n\t\t}\n\t\tfor (const path of previous.keys()) if (!next.has(path)) changed.push(this.#reported(path));\n\t\treturn changed;\n\t}\n\n\t/** An ancestor that changed identity moved every target below it; report those targets. */\n\t#reported(path: string): string {\n\t\tif (this.#targets.some((target) => isWithin(path, target.path))) return path;\n\t\treturn this.#targets.find((target) => isWithin(target.path, path))?.path ?? path;\n\t}\n\n\tasync #scan(): Promise<Scan> {\n\t\tconst snapshot: Snapshot = new Map();\n\t\tconst linkedFiles = new Set<string>();\n\t\t// Directories are counted once, but traversed once per target: overlapping targets differ in recursion and\n\t\t// exclusions, and an entry recorded for one target must still be descended into for another.\n\t\tconst counted = new Set<string>();\n\t\tconst traversed = new Set<string>();\n\t\t/** Kinds of listed entries, not following links: a target that links to a directory is recorded by `stat`, but\n\t\t * symbolic links below a recursive target are not followed. */\n\t\tconst listed = new Map<string, Entry[\"kind\"]>();\n\t\tconst countDirectory = (path: string): void => {\n\t\t\tcounted.add(path);\n\t\t\tif (counted.size > this.#maxDirectories) {\n\t\t\t\tthrow new BudgetExceeded(`Watched paths exceed ${this.#maxDirectories} directories`);\n\t\t\t}\n\t\t};\n\t\tconst record = async (path: string, stats: Stats): Promise<void> => {\n\t\t\tlet hash: string | undefined;\n\t\t\tif (\n\t\t\t\tthis.#mode === \"polling\" &&\n\t\t\t\tstats.isFile() &&\n\t\t\t\tstats.size <= HASH_MAX_BYTES &&\n\t\t\t\tDate.now() - stats.mtimeMs < HASH_RECENT_MS\n\t\t\t) {\n\t\t\t\thash = await readFile(path).then(\n\t\t\t\t\t(content) => createHash(\"sha256\").update(content).digest(\"hex\"),\n\t\t\t\t\t() => undefined,\n\t\t\t\t);\n\t\t\t}\n\t\t\tsnapshot.set(path, entryOf(stats, hash));\n\t\t};\n\t\tconst scanDirectory = async (index: number, target: ResolvedTarget, directory: string): Promise<void> => {\n\t\t\tconst key = `${index}\\0${directory}`;\n\t\t\tif (traversed.has(key)) return;\n\t\t\ttraversed.add(key);\n\t\t\tlet names: string[];\n\t\t\ttry {\n\t\t\t\tnames = await readdir(directory);\n\t\t\t} catch (error) {\n\t\t\t\t// The watched directory itself must be readable; below it, unreadable directories are skipped.\n\t\t\t\tif (directory === target.path && isDenied(error)) throw error;\n\t\t\t\tif (isNodeError(error) && [\"ENOENT\", \"EACCES\", \"EPERM\", \"ENOTDIR\"].includes(error.code ?? \"\")) return;\n\t\t\t\tthrow error;\n\t\t\t}\n\t\t\tfor (const name of names) {\n\t\t\t\tif (excluded(target, name)) continue;\n\t\t\t\tconst path = `${directory.endsWith(sep) ? directory : directory + sep}${name}`;\n\t\t\t\tlet kind = listed.get(path);\n\t\t\t\tif (kind === undefined) {\n\t\t\t\t\tconst stats = await lstat(path).catch(() => undefined);\n\t\t\t\t\tif (stats === undefined) continue;\n\t\t\t\t\tkind = entryOf(stats).kind;\n\t\t\t\t\tlisted.set(path, kind);\n\t\t\t\t\t// A target's own entry (following links) wins over its listing by another target.\n\t\t\t\t\tif (!snapshot.has(path)) await record(path, stats);\n\t\t\t\t}\n\t\t\t\tif (target.recursive && kind === \"directory\") {\n\t\t\t\t\tcountDirectory(path);\n\t\t\t\t\tawait scanDirectory(index, target, path);\n\t\t\t\t}\n\t\t\t}\n\t\t};\n\t\tfor (const [index, target] of this.#targets.entries()) {\n\t\t\tfor (const ancestor of ancestorsOf(target.path)) {\n\t\t\t\tif (snapshot.has(ancestor)) continue;\n\t\t\t\tconst stats = await lstat(ancestor).catch(() => undefined);\n\t\t\t\t// Identity only: an ancestor's own timestamps change with every unrelated sibling.\n\t\t\t\tif (stats !== undefined) snapshot.set(ancestor, { ...entryOf(stats), size: 0, mtimeMs: 0 });\n\t\t\t}\n\t\t\t// The target itself may be a symbolic link to what is watched; follow it. A missing target is watched for its\n\t\t\t// creation; one that cannot be reached for lack of permission fails.\n\t\t\tlet stats: Stats;\n\t\t\ttry {\n\t\t\t\tstats = await stat(target.path);\n\t\t\t} catch (error) {\n\t\t\t\tif (isDenied(error)) throw error;\n\t\t\t\tcontinue;\n\t\t\t}\n\t\t\tawait record(target.path, stats);\n\t\t\tif (stats.isFile() && (await lstat(target.path).catch(() => undefined))?.isSymbolicLink()) {\n\t\t\t\tlinkedFiles.add(target.path);\n\t\t\t}\n\t\t\tif (stats.isDirectory()) {\n\t\t\t\tcountDirectory(target.path);\n\t\t\t\tawait scanDirectory(index, target, target.path);\n\t\t\t}\n\t\t}\n\t\treturn { snapshot, linkedFiles };\n\t}\n\n\t/**\n\t * Watch every existing ancestor of each target, each target directory, each target that is a symbolic link to a file\n\t * (changes to that file are not events of the link's directory), and on Linux each directory below a recursive target\n\t * (elsewhere one recursive watcher per target). Returns whether a watcher was added.\n\t */\n\t#reconcileWatchers({ snapshot, linkedFiles }: Scan): boolean {\n\t\tconst wanted = new Map<string, boolean>();\n\t\tfor (const path of linkedFiles) wanted.set(path, false);\n\t\tconst perDirectory = process.platform === \"linux\" || process.platform === \"android\";\n\t\tfor (const target of this.#targets) {\n\t\t\tfor (const ancestor of ancestorsOf(target.path)) {\n\t\t\t\tif (snapshot.get(ancestor)?.kind === \"directory\" && !wanted.has(ancestor)) wanted.set(ancestor, false);\n\t\t\t}\n\t\t\tif (snapshot.get(target.path)?.kind !== \"directory\") continue;\n\t\t\tconst recursiveRoot = target.recursive && !perDirectory;\n\t\t\twanted.set(target.path, recursiveRoot);\n\t\t\tif (target.recursive && perDirectory) {\n\t\t\t\tfor (const [path, entry] of snapshot) {\n\t\t\t\t\tif (entry.kind === \"directory\" && path !== target.path && isWithin(path, target.path)) {\n\t\t\t\t\t\twanted.set(path, false);\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tfor (const [path, installed] of this.#watchers) {\n\t\t\tconst entry = snapshot.get(path);\n\t\t\t// Gone, or replaced: a watcher follows the directory it was installed on, not the path.\n\t\t\tif (!wanted.has(path) || entry === undefined || entry.dev !== installed.dev || entry.ino !== installed.ino) {\n\t\t\t\tinstalled.watcher.close();\n\t\t\t\tthis.#watchers.delete(path);\n\t\t\t}\n\t\t}\n\t\tlet added = false;\n\t\tfor (const [path, recursive] of wanted) {\n\t\t\tconst entry = snapshot.get(path);\n\t\t\tif (this.#watchers.has(path) || entry === undefined) continue;\n\t\t\tconst linked = linkedFiles.has(path);\n\t\t\ttry {\n\t\t\t\tconst watcher = fsWatch(path, { recursive, persistent: false }, (_event, filename) =>\n\t\t\t\t\tlinked\n\t\t\t\t\t\t? this.#onLinkedFileEvent(path)\n\t\t\t\t\t\t: this.#onEvent(path, filename === null ? undefined : String(filename)),\n\t\t\t\t);\n\t\t\t\t// A watched directory that disappears or fails: rescan, which also replaces the watcher.\n\t\t\t\twatcher.on(\"error\", () => {\n\t\t\t\t\twatcher.close();\n\t\t\t\t\tif (this.#watchers.get(path)?.watcher === watcher) this.#watchers.delete(path);\n\t\t\t\t\tthis.#scheduleFlush();\n\t\t\t\t});\n\t\t\t\tthis.#watchers.set(path, { watcher, dev: entry.dev, ino: entry.ino });\n\t\t\t\tadded = true;\n\t\t\t} catch (error) {\n\t\t\t\t// Out of watches or unsupported: compare snapshots from now on, and say coverage was uncertain.\n\t\t\t\tif (isNodeError(error) && error.code !== \"ENOENT\" && error.code !== \"EACCES\" && error.code !== \"EPERM\") {\n\t\t\t\t\tthis.#switchToPolling();\n\t\t\t\t\treturn false;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\treturn added;\n\t}\n\n\t#switchToPolling(): void {\n\t\tif (this.#mode === \"polling\") return;\n\t\tthis.#mode = \"polling\";\n\t\tfor (const { watcher } of this.#watchers.values()) watcher.close();\n\t\tthis.#watchers.clear();\n\t\tthis.#deliver(OVERFLOW);\n\t\tclearTimeout(this.#timer);\n\t\tthis.#timer = undefined;\n\t\tthis.#schedulePoll();\n\t}\n\n\t#onEvent(directory: string, filename: string | undefined): void {\n\t\tif (this.#stopped) return;\n\t\tconst path =\n\t\t\tfilename === undefined ? directory : `${directory.endsWith(sep) ? directory : directory + sep}${filename}`;\n\t\t// Events about unrelated siblings of an ancestor, or about excluded entries, are ignored.\n\t\tconst relevant = this.#inScope(path);\n\t\tif (relevant) this.#events.add(this.#reported(path));\n\t\tif (relevant || filename === undefined) this.#scheduleFlush();\n\t}\n\n\t/** The file a target links to changed: report the target. */\n\t#onLinkedFileEvent(target: string): void {\n\t\tif (this.#stopped) return;\n\t\tthis.#events.add(target);\n\t\tthis.#scheduleFlush();\n\t}\n\n\t#inScope(path: string): boolean {\n\t\tfor (const target of this.#targets) {\n\t\t\tif (isWithin(target.path, path)) return true;\n\t\t\tif (!isWithin(path, target.path) || path === target.path) continue;\n\t\t\tconst components = relative(target.path, path).split(sep);\n\t\t\tif (!target.recursive && components.length > 1) continue;\n\t\t\tif (components.some((name) => excluded(target, name))) continue;\n\t\t\treturn true;\n\t\t}\n\t\treturn false;\n\t}\n}\n\n/** Whether any path, or its nearest existing ancestor, is on a file system that does not report remote changes. */\nasync function anyUnreliable(paths: readonly string[]): Promise<boolean> {\n\tif (process.platform !== \"linux\" && process.platform !== \"android\") return false;\n\tfor (const path of paths) {\n\t\tfor (const candidate of [path, ...ancestorsOf(path)]) {\n\t\t\tconst info = await statfs(candidate).catch(() => undefined);\n\t\t\tif (info === undefined) continue;\n\t\t\tif (UNRELIABLE_FILE_SYSTEMS.has(info.type)) return true;\n\t\t\tbreak;\n\t\t}\n\t}\n\treturn false;\n}\n"]}
@@ -1,5 +1,5 @@
1
1
  import type { Context } from "@earendil-works/chord";
2
- import { type BinaryReader, type DirReader, type ExecutionEnv, ExecutionError, FileError, type FileInfo, type FileWatcher, type Result, type ShellExecOptions, type ShellExecResult, type TextLineReader, type WatchChange, type WatchTarget } from "./index.ts";
2
+ import { type BinaryReader, type DirReader, type ExecutionEnv, ExecutionError, type FileChange, FileError, type FileInfo, type FileWatcher, type Result, type ShellExecOptions, type ShellExecResult, type TextLineReader, type WatchTarget } from "./index.ts";
3
3
  import { type NodeWatchOptions } from "./node-watch.ts";
4
4
  export declare class NodeExecutionEnv implements ExecutionEnv {
5
5
  /** Every local environment sees the same files. */
@@ -15,7 +15,7 @@ export declare class NodeExecutionEnv implements ExecutionEnv {
15
15
  shellEnv?: NodeJS.ProcessEnv;
16
16
  watch?: NodeWatchOptions;
17
17
  });
18
- watch(targets: readonly WatchTarget[], onChange: (change: WatchChange) => void, context: Context): Promise<Result<FileWatcher, FileError>>;
18
+ watch(targets: readonly WatchTarget[], onChange: (change: FileChange) => void, context: Context): Promise<Result<FileWatcher, FileError>>;
19
19
  absolutePath(path: string, _context: Context): Promise<Result<string, FileError>>;
20
20
  joinPath(parts: string[], _context: Context): Promise<Result<string, FileError>>;
21
21
  exec(command: string | readonly string[], options: ShellExecOptions | undefined, context: Context): Promise<Result<ShellExecResult, ExecutionError>>;
@@ -1 +1 @@
1
- {"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/env/node.ts"],"names":[],"mappings":"AAsBA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAErD,OAAO,EACN,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,YAAY,EACjB,cAAc,EAEd,SAAS,EACT,KAAK,QAAQ,EAEb,KAAK,WAAW,EAGhB,KAAK,MAAM,EACX,KAAK,gBAAgB,EACrB,KAAK,eAAe,EAGpB,KAAK,cAAc,EAEnB,KAAK,WAAW,EAChB,KAAK,WAAW,EAChB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAmB,KAAK,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAojBzE,qBAAa,gBAAiB,YAAW,YAAY;IACpD,mDAAmD;IACnD,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAgB;IACnC,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,SAAS,CAAC,CAAS;IAC3B,OAAO,CAAC,QAAQ,CAAC,CAAoB;IACrC,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,eAAe,CAAqB;IAE5C,YAAY,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,SAAS,CAAC,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,EAAE,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,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAStF;IAEK,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC,CAKhF;IAEK,SAAS,CACd,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,EAC5C,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAUlC;IAEK,MAAM,CACX,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE;QAAE,SAAS,CAAC,EAAE,OAAO,CAAC;QAAC,KAAK,CAAC,EAAE,OAAO,CAAA;KAAE,GAAG,SAAS,EAC7D,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAUlC;IAEK,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,EAAE,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CASpG;IAEK,cAAc,CACnB,OAAO,EAAE;QAAE,MAAM,CAAC,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,EACzD,OAAO,EAAE,OAAO,GACd,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC,CAUpC;IAEK,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,CAG9C;CACD;AACD,YAAY,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC"}
package/dist/env/node.js CHANGED
@@ -570,7 +570,7 @@ export class NodeExecutionEnv {
570
570
  const watcher = await NodeFileWatcher.open(targets, (path) => resolvePath(this.cwd, path), onChange, this.watchOptions);
571
571
  const afterOpenAbort = abortResult(context.abortSignal);
572
572
  if (afterOpenAbort) {
573
- await watcher.close(context);
573
+ await watcher.stop(context);
574
574
  return afterOpenAbort;
575
575
  }
576
576
  return ok(watcher);