@bendyline/docblocks 2.0.0 → 2.1.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 (286) hide show
  1. package/dist/{chunk-J32GU3F3.js → chunk-6IYMTYMQ.js} +249 -221
  2. package/dist/chunk-6IYMTYMQ.js.map +1 -0
  3. package/dist/{chunk-75UUF6C4.js → chunk-B56KWCSE.js} +2 -2
  4. package/dist/{chunk-RVQHY3XU.js → chunk-BNKV7MTO.js} +1 -1
  5. package/dist/{chunk-RVQHY3XU.js.map → chunk-BNKV7MTO.js.map} +1 -1
  6. package/dist/chunk-BXMF5YQJ.js +149 -0
  7. package/dist/chunk-BXMF5YQJ.js.map +1 -0
  8. package/dist/{chunk-PGR7LK6D.js → chunk-COYQXQK3.js} +14 -5
  9. package/dist/chunk-COYQXQK3.js.map +1 -0
  10. package/dist/{chunk-RQJRQF46.js → chunk-DN7A33LL.js} +42 -49
  11. package/dist/chunk-DN7A33LL.js.map +1 -0
  12. package/dist/chunk-FA7UNOXK.js +20 -0
  13. package/dist/chunk-FA7UNOXK.js.map +1 -0
  14. package/dist/chunk-GM5YXU4L.js +29 -0
  15. package/dist/chunk-GM5YXU4L.js.map +1 -0
  16. package/dist/{chunk-SI2LU2RP.js → chunk-JS6XFWQK.js} +2 -1
  17. package/dist/chunk-JS6XFWQK.js.map +1 -0
  18. package/dist/{chunk-EGNDADXB.js → chunk-MNSZ7EZN.js} +2 -2
  19. package/dist/chunk-P3DVZQ6S.js +228 -0
  20. package/dist/chunk-P3DVZQ6S.js.map +1 -0
  21. package/dist/chunk-P4WATND4.js +52 -0
  22. package/dist/chunk-P4WATND4.js.map +1 -0
  23. package/dist/chunk-RVPGQBWR.js +169 -0
  24. package/dist/chunk-RVPGQBWR.js.map +1 -0
  25. package/dist/chunk-U722UUFN.js +9 -0
  26. package/dist/chunk-U722UUFN.js.map +1 -0
  27. package/dist/{chunk-GCPBEMMH.js → chunk-VTCSF7VS.js} +11 -21
  28. package/dist/chunk-VTCSF7VS.js.map +1 -0
  29. package/dist/{chunk-2D7Y4IR3.js → chunk-WJKYY5QR.js} +123 -66
  30. package/dist/chunk-WJKYY5QR.js.map +1 -0
  31. package/dist/{chunk-5MYAICRE.js → chunk-XUML3MKV.js} +44 -56
  32. package/dist/chunk-XUML3MKV.js.map +1 -0
  33. package/dist/document/index.d.ts +358 -6
  34. package/dist/document/index.js +24 -3
  35. package/dist/document/index.js.map +1 -1
  36. package/dist/filesystem/electron.d.ts +73 -4
  37. package/dist/filesystem/electron.js +16 -3
  38. package/dist/filesystem/electron.js.map +1 -1
  39. package/dist/filesystem/index.d.ts +228 -22
  40. package/dist/filesystem/index.js +133 -19
  41. package/dist/filesystem/index.js.map +1 -1
  42. package/dist/filesystem/indexeddb.d.ts +284 -5
  43. package/dist/filesystem/indexeddb.js +22 -4
  44. package/dist/filesystem/indexeddb.js.map +1 -1
  45. package/dist/filesystem/memory.d.ts +152 -4
  46. package/dist/filesystem/memory.js +12 -3
  47. package/dist/filesystem/memory.js.map +1 -1
  48. package/dist/filesystem/native.d.ts +136 -4
  49. package/dist/filesystem/native.js +27 -3
  50. package/dist/filesystem/native.js.map +1 -1
  51. package/dist/host/index.d.ts +32 -9
  52. package/dist/host/index.js +26 -29
  53. package/dist/host/index.js.map +1 -1
  54. package/dist/index.d.ts +14 -10
  55. package/dist/index.js +204 -9
  56. package/dist/index.js.map +1 -1
  57. package/dist/mcp/index.d.ts +33 -4
  58. package/dist/mcp/index.js +31 -3
  59. package/dist/mcp/index.js.map +1 -1
  60. package/dist/mcp/zod.d.ts +637 -635
  61. package/dist/mcp/zod.js +700 -884
  62. package/dist/mcp/zod.js.map +1 -1
  63. package/dist/share/index.d.ts +43 -0
  64. package/dist/share/index.js +13 -0
  65. package/dist/share/index.js.map +1 -0
  66. package/dist/{types-CsX6EN2t.d.ts → types-BEg5SQ1_.d.ts} +1 -1
  67. package/dist/{types-eOlt9J7n.d.ts → types-CueK0tvU.d.ts} +34 -11
  68. package/dist/vscode/index.d.ts +220 -3
  69. package/dist/vscode/index.js +382 -2
  70. package/dist/vscode/index.js.map +1 -1
  71. package/dist/workspace/index.d.ts +141 -4
  72. package/dist/workspace/index.js +28 -2
  73. package/dist/workspace/index.js.map +1 -1
  74. package/package.json +9 -5
  75. package/dist/chunk-2D7Y4IR3.js.map +0 -1
  76. package/dist/chunk-5MYAICRE.js.map +0 -1
  77. package/dist/chunk-AYZ4HN5M.js +0 -20
  78. package/dist/chunk-AYZ4HN5M.js.map +0 -1
  79. package/dist/chunk-GCPBEMMH.js.map +0 -1
  80. package/dist/chunk-J32GU3F3.js.map +0 -1
  81. package/dist/chunk-PGR7LK6D.js.map +0 -1
  82. package/dist/chunk-RQJRQF46.js.map +0 -1
  83. package/dist/chunk-SI2LU2RP.js.map +0 -1
  84. package/dist/chunk-W5UUUII5.js +0 -142
  85. package/dist/chunk-W5UUUII5.js.map +0 -1
  86. package/dist/document/document-session.d.ts +0 -127
  87. package/dist/document/document-session.d.ts.map +0 -1
  88. package/dist/document/document-session.js +0 -749
  89. package/dist/document/document-session.js.map +0 -1
  90. package/dist/document/filesystem-target.d.ts +0 -17
  91. package/dist/document/filesystem-target.d.ts.map +0 -1
  92. package/dist/document/filesystem-target.js +0 -70
  93. package/dist/document/filesystem-target.js.map +0 -1
  94. package/dist/document/index.d.ts.map +0 -1
  95. package/dist/document/recovery-journal.d.ts +0 -125
  96. package/dist/document/recovery-journal.d.ts.map +0 -1
  97. package/dist/document/recovery-journal.js +0 -385
  98. package/dist/document/recovery-journal.js.map +0 -1
  99. package/dist/document/types.d.ts +0 -89
  100. package/dist/document/types.d.ts.map +0 -1
  101. package/dist/document/types.js +0 -9
  102. package/dist/document/types.js.map +0 -1
  103. package/dist/filesystem/commit-lock.d.ts +0 -3
  104. package/dist/filesystem/commit-lock.d.ts.map +0 -1
  105. package/dist/filesystem/commit-lock.js +0 -20
  106. package/dist/filesystem/commit-lock.js.map +0 -1
  107. package/dist/filesystem/dbk-workspace.d.ts +0 -34
  108. package/dist/filesystem/dbk-workspace.d.ts.map +0 -1
  109. package/dist/filesystem/dbk-workspace.js +0 -85
  110. package/dist/filesystem/dbk-workspace.js.map +0 -1
  111. package/dist/filesystem/electron-provider-v2.d.ts +0 -36
  112. package/dist/filesystem/electron-provider-v2.d.ts.map +0 -1
  113. package/dist/filesystem/electron-provider-v2.js +0 -503
  114. package/dist/filesystem/electron-provider-v2.js.map +0 -1
  115. package/dist/filesystem/electron-provider.d.ts +0 -35
  116. package/dist/filesystem/electron-provider.d.ts.map +0 -1
  117. package/dist/filesystem/electron-provider.js +0 -69
  118. package/dist/filesystem/electron-provider.js.map +0 -1
  119. package/dist/filesystem/electron.d.ts.map +0 -1
  120. package/dist/filesystem/file-media-provider.d.ts +0 -23
  121. package/dist/filesystem/file-media-provider.d.ts.map +0 -1
  122. package/dist/filesystem/file-media-provider.js +0 -85
  123. package/dist/filesystem/file-media-provider.js.map +0 -1
  124. package/dist/filesystem/filesystem-content-container.d.ts +0 -24
  125. package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
  126. package/dist/filesystem/filesystem-content-container.js +0 -153
  127. package/dist/filesystem/filesystem-content-container.js.map +0 -1
  128. package/dist/filesystem/fs-error.d.ts +0 -46
  129. package/dist/filesystem/fs-error.d.ts.map +0 -1
  130. package/dist/filesystem/fs-error.js +0 -170
  131. package/dist/filesystem/fs-error.js.map +0 -1
  132. package/dist/filesystem/index.d.ts.map +0 -1
  133. package/dist/filesystem/indexeddb-content-container.d.ts +0 -22
  134. package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
  135. package/dist/filesystem/indexeddb-content-container.js +0 -100
  136. package/dist/filesystem/indexeddb-content-container.js.map +0 -1
  137. package/dist/filesystem/indexeddb-provider-v2.d.ts +0 -96
  138. package/dist/filesystem/indexeddb-provider-v2.d.ts.map +0 -1
  139. package/dist/filesystem/indexeddb-provider-v2.js +0 -1241
  140. package/dist/filesystem/indexeddb-provider-v2.js.map +0 -1
  141. package/dist/filesystem/indexeddb-provider.d.ts +0 -39
  142. package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
  143. package/dist/filesystem/indexeddb-provider.js +0 -145
  144. package/dist/filesystem/indexeddb-provider.js.map +0 -1
  145. package/dist/filesystem/indexeddb-store.d.ts +0 -34
  146. package/dist/filesystem/indexeddb-store.d.ts.map +0 -1
  147. package/dist/filesystem/indexeddb-store.js +0 -165
  148. package/dist/filesystem/indexeddb-store.js.map +0 -1
  149. package/dist/filesystem/indexeddb.d.ts.map +0 -1
  150. package/dist/filesystem/legacy-v2-adapter.d.ts +0 -62
  151. package/dist/filesystem/legacy-v2-adapter.d.ts.map +0 -1
  152. package/dist/filesystem/legacy-v2-adapter.js +0 -499
  153. package/dist/filesystem/legacy-v2-adapter.js.map +0 -1
  154. package/dist/filesystem/memory-provider-v2.d.ts +0 -92
  155. package/dist/filesystem/memory-provider-v2.d.ts.map +0 -1
  156. package/dist/filesystem/memory-provider-v2.js +0 -615
  157. package/dist/filesystem/memory-provider-v2.js.map +0 -1
  158. package/dist/filesystem/memory-provider.d.ts +0 -54
  159. package/dist/filesystem/memory-provider.d.ts.map +0 -1
  160. package/dist/filesystem/memory-provider.js +0 -132
  161. package/dist/filesystem/memory-provider.js.map +0 -1
  162. package/dist/filesystem/memory.d.ts.map +0 -1
  163. package/dist/filesystem/move-entry.d.ts +0 -9
  164. package/dist/filesystem/move-entry.d.ts.map +0 -1
  165. package/dist/filesystem/move-entry.js +0 -103
  166. package/dist/filesystem/move-entry.js.map +0 -1
  167. package/dist/filesystem/move-error.d.ts +0 -53
  168. package/dist/filesystem/move-error.d.ts.map +0 -1
  169. package/dist/filesystem/move-error.js +0 -99
  170. package/dist/filesystem/move-error.js.map +0 -1
  171. package/dist/filesystem/native-provider-v2.d.ts +0 -75
  172. package/dist/filesystem/native-provider-v2.d.ts.map +0 -1
  173. package/dist/filesystem/native-provider-v2.js +0 -849
  174. package/dist/filesystem/native-provider-v2.js.map +0 -1
  175. package/dist/filesystem/native-provider.d.ts +0 -53
  176. package/dist/filesystem/native-provider.d.ts.map +0 -1
  177. package/dist/filesystem/native-provider.js +0 -471
  178. package/dist/filesystem/native-provider.js.map +0 -1
  179. package/dist/filesystem/native.d.ts.map +0 -1
  180. package/dist/filesystem/types.d.ts +0 -83
  181. package/dist/filesystem/types.d.ts.map +0 -1
  182. package/dist/filesystem/types.js +0 -16
  183. package/dist/filesystem/types.js.map +0 -1
  184. package/dist/filesystem/v2.d.ts +0 -172
  185. package/dist/filesystem/v2.d.ts.map +0 -1
  186. package/dist/filesystem/v2.js +0 -16
  187. package/dist/filesystem/v2.js.map +0 -1
  188. package/dist/filesystem/workspace-path.d.ts +0 -21
  189. package/dist/filesystem/workspace-path.d.ts.map +0 -1
  190. package/dist/filesystem/workspace-path.js +0 -80
  191. package/dist/filesystem/workspace-path.js.map +0 -1
  192. package/dist/host/filesystem-v2.d.ts +0 -45
  193. package/dist/host/filesystem-v2.d.ts.map +0 -1
  194. package/dist/host/filesystem-v2.js +0 -13
  195. package/dist/host/filesystem-v2.js.map +0 -1
  196. package/dist/host/git.d.ts +0 -200
  197. package/dist/host/git.d.ts.map +0 -1
  198. package/dist/host/git.js +0 -15
  199. package/dist/host/git.js.map +0 -1
  200. package/dist/host/index.d.ts.map +0 -1
  201. package/dist/host/types.d.ts +0 -232
  202. package/dist/host/types.d.ts.map +0 -1
  203. package/dist/host/types.js +0 -10
  204. package/dist/host/types.js.map +0 -1
  205. package/dist/host/wire-policy.d.ts +0 -22
  206. package/dist/host/wire-policy.d.ts.map +0 -1
  207. package/dist/host/wire-policy.js +0 -92
  208. package/dist/host/wire-policy.js.map +0 -1
  209. package/dist/index.d.ts.map +0 -1
  210. package/dist/mcp/index.d.ts.map +0 -1
  211. package/dist/mcp/types.d.ts +0 -466
  212. package/dist/mcp/types.d.ts.map +0 -1
  213. package/dist/mcp/types.js +0 -25
  214. package/dist/mcp/types.js.map +0 -1
  215. package/dist/mcp/wire.d.ts +0 -29
  216. package/dist/mcp/wire.d.ts.map +0 -1
  217. package/dist/mcp/wire.js +0 -1046
  218. package/dist/mcp/wire.js.map +0 -1
  219. package/dist/mcp/zod.d.ts.map +0 -1
  220. package/dist/vscode/index.d.ts.map +0 -1
  221. package/dist/vscode/messages.d.ts +0 -204
  222. package/dist/vscode/messages.d.ts.map +0 -1
  223. package/dist/vscode/messages.js +0 -494
  224. package/dist/vscode/messages.js.map +0 -1
  225. package/dist/workspace/index.d.ts.map +0 -1
  226. package/dist/workspace/reconcile-electron.d.ts +0 -19
  227. package/dist/workspace/reconcile-electron.d.ts.map +0 -1
  228. package/dist/workspace/reconcile-electron.js +0 -42
  229. package/dist/workspace/reconcile-electron.js.map +0 -1
  230. package/dist/workspace/types.d.ts +0 -69
  231. package/dist/workspace/types.d.ts.map +0 -1
  232. package/dist/workspace/types.js +0 -2
  233. package/dist/workspace/types.js.map +0 -1
  234. package/dist/workspace/workspace-manager.d.ts +0 -47
  235. package/dist/workspace/workspace-manager.d.ts.map +0 -1
  236. package/dist/workspace/workspace-manager.js +0 -126
  237. package/dist/workspace/workspace-manager.js.map +0 -1
  238. package/src/document/document-session.ts +0 -834
  239. package/src/document/filesystem-target.ts +0 -109
  240. package/src/document/index.ts +0 -41
  241. package/src/document/recovery-journal.ts +0 -536
  242. package/src/document/types.ts +0 -116
  243. package/src/filesystem/commit-lock.ts +0 -29
  244. package/src/filesystem/dbk-workspace.ts +0 -135
  245. package/src/filesystem/electron-provider-v2.ts +0 -630
  246. package/src/filesystem/electron-provider.ts +0 -99
  247. package/src/filesystem/electron.ts +0 -3
  248. package/src/filesystem/file-media-provider.ts +0 -103
  249. package/src/filesystem/filesystem-content-container.ts +0 -164
  250. package/src/filesystem/fs-error.ts +0 -234
  251. package/src/filesystem/index.ts +0 -143
  252. package/src/filesystem/indexeddb-content-container.ts +0 -112
  253. package/src/filesystem/indexeddb-provider-v2.ts +0 -1740
  254. package/src/filesystem/indexeddb-provider.ts +0 -171
  255. package/src/filesystem/indexeddb-store.ts +0 -207
  256. package/src/filesystem/indexeddb.ts +0 -12
  257. package/src/filesystem/legacy-v2-adapter.ts +0 -779
  258. package/src/filesystem/memory-provider-v2.ts +0 -896
  259. package/src/filesystem/memory-provider.ts +0 -180
  260. package/src/filesystem/memory.ts +0 -15
  261. package/src/filesystem/move-entry.ts +0 -142
  262. package/src/filesystem/move-error.ts +0 -159
  263. package/src/filesystem/native-provider-v2.ts +0 -1165
  264. package/src/filesystem/native-provider.ts +0 -537
  265. package/src/filesystem/native.ts +0 -16
  266. package/src/filesystem/types.ts +0 -114
  267. package/src/filesystem/v2.ts +0 -231
  268. package/src/filesystem/workspace-path.ts +0 -92
  269. package/src/host/filesystem-v2.ts +0 -104
  270. package/src/host/git.ts +0 -246
  271. package/src/host/index.ts +0 -93
  272. package/src/host/types.ts +0 -274
  273. package/src/host/wire-policy.ts +0 -103
  274. package/src/index.ts +0 -10
  275. package/src/mcp/index.ts +0 -3
  276. package/src/mcp/types.ts +0 -594
  277. package/src/mcp/wire.ts +0 -1280
  278. package/src/mcp/zod.ts +0 -1000
  279. package/src/vscode/index.ts +0 -2
  280. package/src/vscode/messages.ts +0 -704
  281. package/src/workspace/index.ts +0 -17
  282. package/src/workspace/reconcile-electron.ts +0 -65
  283. package/src/workspace/types.ts +0 -67
  284. package/src/workspace/workspace-manager.ts +0 -151
  285. /package/dist/{chunk-75UUF6C4.js.map → chunk-B56KWCSE.js.map} +0 -0
  286. /package/dist/{chunk-EGNDADXB.js.map → chunk-MNSZ7EZN.js.map} +0 -0
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/electron-provider-v2.ts","../src/filesystem/electron-provider.ts"],"sourcesContent":["import {\n ELECTRON_FILE_SYSTEM_V2_CAPABILITIES,\n maybeGetDocBlocksHost,\n type DocBlocksHostFsV2API,\n type HostFileSystemV2Result,\n type HostFileSystemV2WatchMessage,\n} from '../host/index.js';\nimport {\n FsError,\n deserializeFsError,\n fsErrorFromUnknown,\n isSerializedFsError,\n type FsOperation,\n} from './fs-error.js';\nimport {\n WORKSPACE_ROOT,\n parseWorkspacePath,\n workspacePathBasename,\n workspacePathDirname,\n type WorkspacePath,\n} from './workspace-path.js';\nimport {\n parseFileSystemVersion,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\n type FileSystemEntrySnapshot,\n type FileSystemFileRead,\n type FileSystemFileSnapshot,\n type FileSystemMoveOptions,\n type FileSystemProviderCapabilities,\n type FileSystemProviderV2,\n type FileSystemRemoveOptions,\n type FileSystemRemoveResult,\n type FileSystemSnapshot,\n type FileSystemSnapshotEntry,\n type FileSystemWatchEvent,\n type FileSystemWatchOptions,\n type FileSystemWatchSubscription,\n type FileSystemWriteOptions,\n} from './v2.js';\n\ninterface ClientWatcher {\n readonly listener: (event: FileSystemWatchEvent) => void;\n readonly onError: FileSystemWatchOptions['onError'];\n}\n\nlet fallbackInstanceSequence = 0;\n\nfunction getHostFsV2(operation: FsOperation): DocBlocksHostFsV2API {\n const host = maybeGetDocBlocksHost();\n if (!host?.fsV2) {\n throw new FsError('not-supported', 'Electron filesystem v2 host is unavailable.', {\n operation,\n });\n }\n return host.fsV2;\n}\n\n/** Pure renderer-side client for the typed Electron filesystem v2 transport. */\nexport class ElectronFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = ELECTRON_FILE_SYSTEM_V2_CAPABILITIES;\n\n private readonly rootPath: string;\n private readonly instanceId = createInstanceId();\n private readonly watchers = new Map<string, ClientWatcher>();\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private openPromise: Promise<void> | null = null;\n private removeWatchBridge: (() => void) | null = null;\n private disposePromise: Promise<void> | null = null;\n private hostOpened = false;\n private disposed = false;\n\n public constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n }\n\n public getRootPath(): string {\n return this.rootPath;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'stat',\n () => getHostFsV2('stat').stat(this.instanceId, canonical),\n (value) => (value ? normalizeEntry(value) : null),\n );\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'read',\n () => getHostFsV2('read').readFile(this.instanceId, canonical),\n (value) => {\n if (!value) return null;\n const entry = normalizeFile(value.entry);\n const data = copyWireBuffer(value.data);\n if (data.byteLength !== entry.size) {\n throw new TypeError('Filesystem transport returned file bytes with the wrong size.');\n }\n return Object.freeze({ entry, data });\n },\n );\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'list',\n () => getHostFsV2('list').readDirectory(this.instanceId, canonical),\n (value) => normalizeDirectoryListing(value, canonical),\n );\n }\n\n public async writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options?: FileSystemWriteOptions,\n ): Promise<FileSystemFileSnapshot> {\n const canonical = parseWorkspacePath(String(path));\n const owned = copyBytes(data);\n return this.request(\n 'write',\n () => getHostFsV2('write').writeFile(this.instanceId, canonical, owned, options),\n normalizeFile,\n );\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options?: FileSystemCreateDirectoryOptions,\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'create-directory',\n () => getHostFsV2('create-directory').createDirectory(this.instanceId, canonical, options),\n normalizeDirectory,\n );\n }\n\n public async remove(\n path: WorkspacePath,\n options?: FileSystemRemoveOptions,\n ): Promise<FileSystemRemoveResult> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'remove',\n () => getHostFsV2('remove').remove(this.instanceId, canonical, options),\n normalizeRemoveResult,\n );\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options?: FileSystemMoveOptions,\n ): Promise<FileSystemEntrySnapshot> {\n const source = parseWorkspacePath(String(oldPath));\n const destination = parseWorkspacePath(String(newPath));\n return this.request(\n 'move',\n () => getHostFsV2('move').move(this.instanceId, source, destination, options),\n normalizeEntry,\n );\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.request(\n 'snapshot',\n () => getHostFsV2('snapshot').snapshot(this.instanceId),\n normalizeSnapshot,\n );\n }\n\n public watch(\n listener: (event: FileSystemWatchEvent) => void,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n this.ensureWatchBridge();\n const subscriptionId = createInstanceId();\n const watcher: ClientWatcher = { listener, onError: options.onError };\n this.watchers.set(subscriptionId, watcher);\n let closed = false;\n let subscribed = false;\n let closePromise: Promise<void> | null = null;\n const ready = this.ensureOpen('watch')\n .then(async () => {\n if (closed) return;\n unwrap(await getHostFsV2('watch').watchSubscribe(this.instanceId, subscriptionId), 'watch');\n subscribed = true;\n })\n .catch((error: unknown) => {\n closed = true;\n this.watchers.delete(subscriptionId);\n const typed = error instanceof FsError ? error : new FsError('io', String(error));\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n throw typed;\n });\n\n const subscription: FileSystemWatchSubscription = {\n get closed() {\n return closed;\n },\n ready,\n dispose: () => {\n if (closePromise) return closePromise;\n closed = true;\n this.watchers.delete(subscriptionId);\n this.subscriptions.delete(subscription);\n closePromise = (async () => {\n await ready.catch(() => undefined);\n if (subscribed) {\n unwrap(\n await getHostFsV2('watch').watchUnsubscribe(this.instanceId, subscriptionId),\n 'watch',\n );\n }\n })();\n return closePromise;\n },\n };\n this.subscriptions.add(subscription);\n return subscription;\n }\n\n public dispose(): Promise<void> {\n if (this.disposePromise) return this.disposePromise;\n this.disposed = true;\n this.disposePromise = (async () => {\n await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n try {\n if (this.openPromise) {\n try {\n await this.openPromise;\n } catch {\n // A failed request normally creates no host record. `hostOpened`\n // separately tracks a successful open whose response validation\n // failed after the main-side record had already been published.\n }\n }\n if (this.hostOpened) {\n try {\n unwrap(await getHostFsV2('dispose').dispose(this.instanceId), 'dispose');\n } catch (error: unknown) {\n if (!(error instanceof FsError && error.code === 'closed')) throw error;\n } finally {\n this.hostOpened = false;\n }\n }\n } finally {\n this.removeWatchBridge?.();\n this.removeWatchBridge = null;\n }\n })();\n return this.disposePromise;\n }\n\n private request<T, U>(\n operation: FsOperation,\n send: () => Promise<HostFileSystemV2Result<T>>,\n normalize: (value: T) => U,\n ): Promise<U> {\n this.assertOpen(operation);\n const promise = this.ensureOpen(operation).then(async () => {\n try {\n return normalize(unwrap(await send(), operation));\n } catch (error: unknown) {\n throw transportErrorFromUnknown(error, operation);\n }\n });\n this.inFlight.add(promise);\n void promise.then(\n () => this.inFlight.delete(promise),\n () => this.inFlight.delete(promise),\n );\n return promise;\n }\n\n private ensureOpen(operation: FsOperation): Promise<void> {\n this.assertOpen(operation);\n if (!this.openPromise) {\n const attempt = getHostFsV2(operation)\n .open({\n instanceId: this.instanceId,\n providerId: this.id,\n label: this.label,\n })\n .then((result) => {\n if (isRecord(result) && result.ok === true) this.hostOpened = true;\n const capabilities = unwrap(result, operation);\n assertCapabilities(capabilities, operation);\n })\n .catch((error: unknown) => {\n const typed = withOperation(fsErrorFromUnknown(error, { operation }), operation);\n if (typed.retryable && this.openPromise === attempt) this.openPromise = null;\n throw typed;\n });\n this.openPromise = attempt;\n }\n return this.openPromise;\n }\n\n private ensureWatchBridge(): void {\n if (this.removeWatchBridge) return;\n this.removeWatchBridge = getHostFsV2('watch').onWatchMessage((message) =>\n this.handleWatchMessage(message),\n );\n }\n\n private handleWatchMessage(message: HostFileSystemV2WatchMessage): void {\n if (message.instanceId !== this.instanceId) return;\n const watcher = this.watchers.get(message.subscriptionId);\n if (!watcher) return;\n if (message.kind === 'error') {\n const typed = isSerializedFsError(message.error)\n ? deserializeFsError(message.error)\n : invalidTransport('watch', 'Filesystem transport returned an invalid watch error.');\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n return;\n }\n\n let event: FileSystemWatchEvent;\n try {\n event = normalizeWatchEvent(message.event);\n } catch (error: unknown) {\n try {\n watcher.onError?.(transportErrorFromUnknown(error, 'watch'));\n } catch {\n // Isolate observers.\n }\n return;\n }\n try {\n watcher.listener(event);\n } catch {\n // Watch callbacks are observational.\n }\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n}\n\nfunction unwrap<T>(result: HostFileSystemV2Result<T>, operation: FsOperation): T {\n if (!isRecord(result) || typeof result.ok !== 'boolean') {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid result envelope.');\n }\n if (result.ok) {\n if (!('value' in result)) {\n throw invalidTransport(operation, 'Filesystem transport omitted a result value.');\n }\n return result.value;\n }\n if (!isSerializedFsError(result.error)) {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid error envelope.');\n }\n throw deserializeFsError(result.error);\n}\n\nfunction normalizeEntry(entry: FileSystemEntrySnapshot): FileSystemEntrySnapshot {\n if (!isRecord(entry)) throw new TypeError('Expected a filesystem entry object.');\n if (typeof entry.path !== 'string')\n throw new TypeError('Filesystem entry path must be a string.');\n if (typeof entry.name !== 'string')\n throw new TypeError('Filesystem entry name must be a string.');\n if (typeof entry.lastModified !== 'string') {\n throw new TypeError('Filesystem entry timestamp must be a string.');\n }\n const path = parseWorkspacePath(entry.path);\n if (entry.name !== workspacePathBasename(path)) {\n throw new TypeError('Filesystem entry name does not match its canonical path.');\n }\n const common = {\n path,\n name: entry.name,\n version: parseFileSystemVersion(entry.version),\n lastModified: new Date(entry.lastModified).toISOString(),\n };\n if (entry.kind === 'file') {\n if (!isNonNegativeSafeInteger(entry.size)) {\n throw new TypeError('Filesystem file size must be a non-negative safe integer.');\n }\n return Object.freeze({ ...common, kind: 'file', size: entry.size });\n }\n if (entry.kind === 'directory') {\n if (entry.size !== null) throw new TypeError('Filesystem directory size must be null.');\n return Object.freeze({ ...common, kind: 'directory', size: null });\n }\n throw new TypeError('Unknown filesystem entry kind.');\n}\n\nfunction normalizeDirectoryListing(\n value: readonly FileSystemEntrySnapshot[],\n parent: WorkspacePath,\n): readonly FileSystemEntrySnapshot[] {\n if (!Array.isArray(value)) throw new TypeError('Expected a filesystem directory listing.');\n const entries = value.map(normalizeEntry);\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (entry.path === WORKSPACE_ROOT || workspacePathDirname(entry.path) !== parent) {\n throw new TypeError('Filesystem listing contained a non-child entry.');\n }\n if (seen.has(entry.path)) throw new TypeError('Filesystem listing contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort(compareDirectoryEntries);\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem listing was not in canonical deterministic order.');\n }\n return Object.freeze(entries);\n}\n\nfunction normalizeFile(entry: FileSystemFileSnapshot): FileSystemFileSnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'file') throw new TypeError('Expected a file snapshot.');\n return normalized;\n}\n\nfunction normalizeDirectory(entry: FileSystemDirectorySnapshot): FileSystemDirectorySnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'directory') throw new TypeError('Expected a directory snapshot.');\n return normalized;\n}\n\nfunction normalizeSnapshot(snapshot: FileSystemSnapshot): FileSystemSnapshot {\n if (!isRecord(snapshot) || !Array.isArray(snapshot.entries)) {\n throw new TypeError('Expected a filesystem snapshot object.');\n }\n const version = parseFileSystemVersion(snapshot.version);\n const entries: FileSystemSnapshotEntry[] = snapshot.entries.map((entry) => {\n if (entry.kind === 'file') {\n const file = normalizeFile(entry);\n const data = copyWireBuffer(entry.data);\n if (data.byteLength !== file.size) {\n throw new TypeError('Filesystem snapshot file bytes have the wrong size.');\n }\n return Object.freeze({ ...file, data });\n }\n if (entry.kind === 'directory') return normalizeDirectory(entry);\n throw new TypeError('Unknown filesystem snapshot entry kind.');\n });\n const roots = entries.filter((entry) => entry.path === WORKSPACE_ROOT);\n if (roots.length !== 1 || roots[0]?.kind !== 'directory' || roots[0].version !== version) {\n throw new TypeError('Filesystem snapshot must contain one matching root directory.');\n }\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (seen.has(entry.path))\n throw new TypeError('Filesystem snapshot contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort((left, right) => compareText(left.path, right.path));\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem snapshot was not in canonical deterministic order.');\n }\n return Object.freeze({\n version,\n entries: Object.freeze(entries),\n });\n}\n\nfunction normalizeWatchEvent(event: FileSystemWatchEvent): FileSystemWatchEvent {\n if (!isRecord(event)) throw new TypeError('Expected a filesystem watch event object.');\n if (!isPositiveSafeInteger(event.sequence)) {\n throw new TypeError('Filesystem watch sequence must be a positive safe integer.');\n }\n if (!isWatchOrigin(event.origin)) throw new TypeError('Unknown filesystem watch origin.');\n if (typeof event.path !== 'string') throw new TypeError('Watch event path must be a string.');\n const path = parseWorkspacePath(event.path);\n if (event.type === 'overflow') {\n if (\n event.kind !== null ||\n event.destinationPath !== null ||\n event.version !== null ||\n event.previousVersion !== null\n ) {\n throw new TypeError('Filesystem overflow event has entry-specific fields.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: 'overflow',\n kind: null,\n path,\n destinationPath: null,\n version: null,\n previousVersion: null,\n });\n }\n if (!isEntryWatchType(event.type)) throw new TypeError('Unknown filesystem watch event type.');\n if (event.kind !== 'file' && event.kind !== 'directory') {\n throw new TypeError('Unknown filesystem watch entry kind.');\n }\n const destinationPath =\n event.destinationPath === null\n ? null\n : typeof event.destinationPath === 'string'\n ? parseWorkspacePath(event.destinationPath)\n : (() => {\n throw new TypeError('Watch destination path must be a string or null.');\n })();\n if ((event.type === 'moved') !== (destinationPath !== null)) {\n throw new TypeError('Only moved watch events may have a destination path.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: event.type,\n kind: event.kind,\n path,\n destinationPath,\n version: event.version === null ? null : parseFileSystemVersion(event.version),\n previousVersion:\n event.previousVersion === null ? null : parseFileSystemVersion(event.previousVersion),\n });\n}\n\nfunction normalizeRemoveResult(value: FileSystemRemoveResult): FileSystemRemoveResult {\n if (!isRecord(value) || typeof value.removed !== 'boolean') {\n throw new TypeError('Filesystem transport returned an invalid remove result.');\n }\n return Object.freeze({ removed: value.removed, version: parseFileSystemVersion(value.version) });\n}\n\nfunction assertCapabilities(value: FileSystemProviderCapabilities, operation: FsOperation): void {\n if (!isRecord(value)) {\n throw invalidTransport(operation, 'Filesystem host returned invalid capabilities.');\n }\n for (const key of Object.keys(ELECTRON_FILE_SYSTEM_V2_CAPABILITIES) as Array<\n keyof FileSystemProviderCapabilities\n >) {\n if (value[key] !== ELECTRON_FILE_SYSTEM_V2_CAPABILITIES[key]) {\n throw invalidTransport(operation, `Filesystem host capability mismatch: ${key}.`);\n }\n }\n}\n\nfunction compareDirectoryEntries(\n left: FileSystemEntrySnapshot,\n right: FileSystemEntrySnapshot,\n): number {\n if (left.kind !== right.kind) return left.kind === 'directory' ? -1 : 1;\n return compareText(left.path, right.path);\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction isWatchOrigin(value: unknown): value is FileSystemWatchEvent['origin'] {\n return value === 'local' || value === 'external' || value === 'unknown';\n}\n\nfunction isEntryWatchType(\n value: unknown,\n): value is Exclude<FileSystemWatchEvent['type'], 'overflow'> {\n return value === 'created' || value === 'modified' || value === 'removed' || value === 'moved';\n}\n\nfunction isNonNegativeSafeInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction isPositiveSafeInteger(value: unknown): value is number {\n return isNonNegativeSafeInteger(value) && value > 0;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction invalidTransport(operation: FsOperation, message: string): FsError {\n return new FsError('io', message, { operation, retryable: false });\n}\n\nfunction transportErrorFromUnknown(error: unknown, operation: FsOperation): FsError {\n if (error instanceof TypeError) return invalidTransport(operation, error.message);\n return withOperation(fsErrorFromUnknown(error, { operation }), operation);\n}\n\nfunction withOperation(error: FsError, operation: FsOperation): FsError {\n if (error.operation === operation) return error;\n return new FsError(error.code, error.message, {\n operation,\n path: error.path ?? undefined,\n destinationPath: error.destinationPath ?? undefined,\n retryable: error.retryable,\n });\n}\n\nfunction copyBytes(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n const source = ArrayBuffer.isView(data)\n ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)\n : new Uint8Array(data);\n const copy = new Uint8Array(source.byteLength);\n copy.set(source);\n return copy.buffer as ArrayBuffer;\n}\n\nfunction copyWireBuffer(data: ArrayBuffer): ArrayBuffer {\n if (Object.prototype.toString.call(data) !== '[object ArrayBuffer]') {\n throw new TypeError('Expected an ArrayBuffer from the filesystem transport.');\n }\n return data.slice(0);\n}\n\nfunction createInstanceId(): string {\n const randomUUID = globalThis.crypto?.randomUUID;\n if (typeof randomUUID === 'function') return randomUUID.call(globalThis.crypto);\n fallbackInstanceSequence += 1;\n return `electron-fs-v2-${Date.now()}-${fallbackInstanceSequence}`;\n}\n","/**\n * ElectronFileSystemProvider — implements FileSystemProvider by delegating\n * to the Electron desktop host's fs IPC bridge. Every operation is scoped\n * to an opaque workspace id that the main process resolves against its\n * registered workspace authority.\n *\n * This file has no Electron dependency — it is a pure IPC client that\n * relies on the `docBlocksHost` global installed by the preload script.\n */\n\nimport type { FileCommitResult, FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { maybeGetDocBlocksHost } from '../host/index.js';\nimport type { DocBlocksHostFsAPI } from '../host/types.js';\nimport { ElectronFileSystemProviderV2 } from './electron-provider-v2.js';\n\nexport { isElectronHost } from '../host/index.js';\n\nfunction getHostFs(): DocBlocksHostFsAPI {\n const host = maybeGetDocBlocksHost();\n if (!host) {\n throw new Error(\n 'ElectronFileSystemProvider: docBlocksHost is not available — not running under Electron?',\n );\n }\n return host.fs;\n}\n\nexport class ElectronFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n readonly v2: ElectronFileSystemProviderV2;\n\n private readonly rootPath: string;\n\n constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n this.v2 = new ElectronFileSystemProviderV2(id, label, rootPath);\n }\n\n /** Absolute path this provider is rooted at. */\n getRootPath(): string {\n return this.rootPath;\n }\n\n readFile(path: string): Promise<string | null> {\n return getHostFs().readFile(this.id, path);\n }\n\n writeFile(path: string, content: string): Promise<void> {\n return getHostFs().writeFile(this.id, path, content);\n }\n\n commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n return getHostFs().commitFile(this.id, path, content, expectedContent);\n }\n\n delete(path: string): Promise<void> {\n return getHostFs().delete(this.id, path);\n }\n\n rename(oldPath: string, newPath: string): Promise<void> {\n return getHostFs().rename(this.id, oldPath, newPath);\n }\n\n readDirectory(path: string): Promise<FileSystemEntry[]> {\n return getHostFs().readDirectory(this.id, path);\n }\n\n exists(path: string): Promise<boolean> {\n return getHostFs().exists(this.id, path);\n }\n\n createDirectory(path: string): Promise<void> {\n return getHostFs().createDirectory(this.id, path);\n }\n\n stat(path: string): Promise<FileMeta | null> {\n return getHostFs().stat(this.id, path);\n }\n\n readBinary(path: string): Promise<ArrayBuffer | null> {\n return getHostFs().readBinary(this.id, path);\n }\n\n writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return getHostFs().writeBinary(this.id, path, data);\n }\n\n /** Subscribe to external change notifications under this root. */\n watch(onChange: (changedPath: string) => void): () => void {\n return getHostFs().watch(this.id, onChange);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;AA8CA,IAAI,2BAA2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AAgB,KAAK,IAAI,IAAI;AAAA,EAClD;AAAA,EAEA,KAAK,MAAwC;AAC3C,WAAO,UAAU,EAAE,KAAK,KAAK,IAAI,IAAI;AAAA,EACvC;AAAA,EAEA,WAAW,MAA2C;AACpD,WAAO,UAAU,EAAE,WAAW,KAAK,IAAI,IAAI;AAAA,EAC7C;AAAA,EAEA,YAAY,MAAc,MAA+C;AACvE,WAAO,UAAU,EAAE,YAAY,KAAK,IAAI,MAAM,IAAI;AAAA,EACpD;AAAA;AAAA,EAGA,MAAM,UAAqD;AACzD,WAAO,UAAU,EAAE,MAAM,KAAK,IAAI,QAAQ;AAAA,EAC5C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/indexeddb-store.ts","../src/filesystem/indexeddb-provider-v2.ts","../src/filesystem/indexeddb-provider.ts","../src/filesystem/indexeddb-content-container.ts"],"sourcesContent":["/**\n * Minimal, error-propagating IndexedDB store used by the virtual filesystem.\n *\n * The previous Squisq LocalForage adapter intentionally converted failed\n * reads/enumerations/removals into null/empty/success. Those semantics are\n * unsuitable for filesystem mutations: an unavailable database must never be\n * interpreted as an absent file. This layer opens the old database and object\n * store directly so existing data can be migrated in one transaction.\n */\n\nexport type IndexedDBFileSystemTransactionMode = 'readonly' | 'readwrite';\n\nexport interface IndexedDBFileSystemTransaction {\n get<T>(key: string): Promise<T | null>;\n put<T>(key: string, value: T): Promise<void>;\n delete(key: string): Promise<void>;\n keys(): Promise<string[]>;\n /** O(log n) namespace probe in the concrete IndexedDB implementation. */\n hasKeyWithPrefix(prefix: string): Promise<boolean>;\n}\n\nexport interface IndexedDBFileSystemStore {\n transaction<T>(\n mode: IndexedDBFileSystemTransactionMode,\n operation: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,\n ): Promise<T>;\n close?(): void;\n}\n\nexport class RawIndexedDBFileSystemStore implements IndexedDBFileSystemStore {\n private database: IDBDatabase | null = null;\n private opening: Promise<IDBDatabase> | null = null;\n private closed = false;\n\n public constructor(\n private readonly databaseName: string,\n private readonly storeName: string,\n ) {}\n\n public async transaction<T>(\n mode: IndexedDBFileSystemTransactionMode,\n operation: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,\n ): Promise<T> {\n const database = await this.getDatabase();\n const nativeTransaction = database.transaction(this.storeName, mode);\n const completion = waitForTransaction(nativeTransaction);\n const transaction = new RawIndexedDBFileSystemTransaction(\n nativeTransaction.objectStore(this.storeName),\n );\n\n let result: T;\n try {\n result = await operation(transaction);\n } catch (error: unknown) {\n try {\n nativeTransaction.abort();\n } catch {\n // The request failure may already have aborted the transaction.\n }\n await completion.catch(() => undefined);\n throw error;\n }\n\n await completion;\n return result;\n }\n\n public close(): void {\n if (this.closed) return;\n this.closed = true;\n this.database?.close();\n this.database = null;\n this.opening = null;\n }\n\n private getDatabase(): Promise<IDBDatabase> {\n if (this.closed) {\n return Promise.reject(new Error('The IndexedDB filesystem store is closed.'));\n }\n if (this.database) return Promise.resolve(this.database);\n if (this.opening) return this.opening;\n if (typeof indexedDB === 'undefined') {\n return Promise.reject(new Error('IndexedDB is not available in this environment.'));\n }\n\n this.opening = openDatabaseWithStore(this.databaseName, this.storeName)\n .then((database) => {\n if (this.closed) {\n database.close();\n throw new Error('The IndexedDB filesystem store is closed.');\n }\n this.database = database;\n this.opening = null;\n database.onversionchange = () => {\n database.close();\n if (this.database === database) this.database = null;\n };\n return database;\n })\n .catch((error: unknown) => {\n this.opening = null;\n throw error;\n });\n return this.opening;\n }\n}\n\nclass RawIndexedDBFileSystemTransaction implements IndexedDBFileSystemTransaction {\n public constructor(private readonly store: IDBObjectStore) {}\n\n public async get<T>(key: string): Promise<T | null> {\n const value = await requestResult(this.store.get(key));\n return value === undefined ? null : (value as T);\n }\n\n public async put<T>(key: string, value: T): Promise<void> {\n await requestResult(this.store.put(value, key));\n }\n\n public async delete(key: string): Promise<void> {\n await requestResult(this.store.delete(key));\n }\n\n public async keys(): Promise<string[]> {\n const keys = await requestResult(this.store.getAllKeys());\n return keys.map((key) => {\n if (typeof key !== 'string') {\n throw new Error('The DocBlocks filesystem store contains a non-string key.');\n }\n return key;\n });\n }\n\n public async hasKeyWithPrefix(prefix: string): Promise<boolean> {\n const cursor = await requestResult(this.store.openKeyCursor(IDBKeyRange.lowerBound(prefix)));\n return cursor !== null && typeof cursor.key === 'string' && cursor.key.startsWith(prefix);\n }\n}\n\nasync function openDatabaseWithStore(\n databaseName: string,\n storeName: string,\n): Promise<IDBDatabase> {\n const database = await openDatabase(databaseName, undefined, (upgradeDatabase) => {\n if (!upgradeDatabase.objectStoreNames.contains(storeName)) {\n upgradeDatabase.createObjectStore(storeName);\n }\n });\n if (database.objectStoreNames.contains(storeName)) return database;\n\n const nextVersion = database.version + 1;\n database.close();\n return openDatabase(databaseName, nextVersion, (upgradeDatabase) => {\n if (!upgradeDatabase.objectStoreNames.contains(storeName)) {\n upgradeDatabase.createObjectStore(storeName);\n }\n });\n}\n\nfunction openDatabase(\n databaseName: string,\n version: number | undefined,\n upgrade: (database: IDBDatabase) => void,\n): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const request =\n version === undefined ? indexedDB.open(databaseName) : indexedDB.open(databaseName, version);\n let settled = false;\n\n request.onupgradeneeded = () => upgrade(request.result);\n request.onsuccess = () => {\n if (settled) {\n request.result.close();\n return;\n }\n settled = true;\n resolve(request.result);\n };\n request.onerror = () => {\n if (settled) return;\n settled = true;\n reject(request.error ?? new Error(`Could not open IndexedDB database ${databaseName}.`));\n };\n request.onblocked = () => {\n if (settled) return;\n settled = true;\n reject(new Error(`IndexedDB database ${databaseName} is blocked by another open page.`));\n };\n });\n}\n\nfunction requestResult<T>(request: IDBRequest<T>): Promise<T> {\n return new Promise((resolve, reject) => {\n request.onsuccess = () => resolve(request.result);\n request.onerror = () => reject(request.error ?? new Error('IndexedDB request failed.'));\n });\n}\n\nfunction waitForTransaction(transaction: IDBTransaction): Promise<void> {\n return new Promise((resolve, reject) => {\n transaction.oncomplete = () => resolve();\n transaction.onabort = () =>\n reject(transaction.error ?? new Error('IndexedDB transaction was aborted.'));\n transaction.onerror = () =>\n reject(transaction.error ?? new Error('IndexedDB transaction failed.'));\n });\n}\n","import {\n FsError,\n fsErrorFromUnknown,\n type FsErrorCode,\n type FsErrorContext,\n type FsOperation,\n} from './fs-error.js';\nimport { withFileCommitLock } from './commit-lock.js';\nimport {\n RawIndexedDBFileSystemStore,\n type IndexedDBFileSystemStore,\n type IndexedDBFileSystemTransaction,\n type IndexedDBFileSystemTransactionMode,\n} from './indexeddb-store.js';\nimport {\n parseFileSystemVersion,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\n type FileSystemEntrySnapshot,\n type FileSystemFileRead,\n type FileSystemFileSnapshot,\n type FileSystemMoveOptions,\n type FileSystemProviderCapabilities,\n type FileSystemProviderV2,\n type FileSystemRemoveOptions,\n type FileSystemRemoveResult,\n type FileSystemSnapshot,\n type FileSystemSnapshotEntry,\n type FileSystemVersion,\n type FileSystemWatchListener,\n type FileSystemWatchOptions,\n type FileSystemWatchSubscription,\n type FileSystemWriteOptions,\n} from './v2.js';\nimport {\n WORKSPACE_ROOT,\n parseWorkspacePath,\n workspacePathBasename,\n workspacePathContains,\n workspacePathDirname,\n type WorkspacePath,\n} from './workspace-path.js';\nimport type { FileMeta } from './types.js';\n\nconst ENTRY_SCHEMA_VERSION = 1;\nconst STATE_SCHEMA_VERSION = 1;\nconst LEGACY_CONFLICT_SCHEMA_VERSION = 2;\nconst LEGACY_CONFLICT_SCHEMA_VERSION_V1 = 1;\nconst ENTRY_PREFIX = 'v2:entry:';\nconst STATE_KEY = 'v2:state';\nconst LEGACY_CONFLICT_PREFIX = 'v2:legacy-conflict:';\nconst LEGACY_IGNORED_PREFIX = 'v2:legacy-ignored:';\nconst LEGACY_OPAQUE_PREFIX = 'v2:legacy-opaque:';\nconst LEGACY_DIRS_KEY = 'fs:dirs';\nconst LEGACY_PREFIX = 'fs:';\nconst LEGACY_CONTENT_SUFFIX = ':content';\nconst LEGACY_BINARY_SUFFIX = ':binary';\nconst LEGACY_META_SUFFIX = ':meta';\n\nclass LegacyNamespaceDetectedError extends Error {}\n\nconst INDEXEDDB_V2_CAPABILITIES: FileSystemProviderCapabilities = Object.freeze({\n writeAtomicity: 'cross-context',\n moveAtomicity: 'cross-context',\n snapshotAtomicity: 'cross-context',\n conditionalWrite: 'storage-atomic',\n recursiveRemove: true,\n watch: false,\n caseSensitivity: 'sensitive',\n symlinkPolicy: 'unsupported',\n durability: 'best-effort',\n});\n\ninterface PersistedEntryBase {\n readonly schemaVersion: typeof ENTRY_SCHEMA_VERSION;\n readonly path: WorkspacePath;\n readonly version: string;\n readonly lastModified: string;\n}\n\ninterface PersistedFileEntry extends PersistedEntryBase {\n readonly kind: 'file';\n readonly data: ArrayBuffer;\n}\n\ninterface PersistedDirectoryEntry extends PersistedEntryBase {\n readonly kind: 'directory';\n}\n\ntype PersistedEntry = PersistedFileEntry | PersistedDirectoryEntry;\n\ninterface PersistedState {\n readonly schemaVersion: typeof STATE_SCHEMA_VERSION;\n readonly migrationVersion: 1 | 2;\n readonly mutationCounter: number;\n readonly treeVersion: string;\n}\n\nexport type IndexedDBLegacyConflictReason =\n | 'dual-payload'\n | 'kind-collision'\n | 'authority-collision'\n | 'stale-client-write';\n\nexport type IndexedDBLegacyRecoveryKind = 'file' | 'directory';\n\ninterface PersistedLegacyRecoveryCandidate {\n readonly kind: IndexedDBLegacyRecoveryKind;\n readonly reason: IndexedDBLegacyConflictReason;\n readonly text: string | null;\n readonly binary: ArrayBuffer | null;\n readonly metadata: FileMeta | null;\n readonly detectedAt: string;\n}\n\ninterface PersistedLegacyConflict {\n readonly schemaVersion: typeof LEGACY_CONFLICT_SCHEMA_VERSION;\n readonly path: WorkspacePath;\n readonly candidates: readonly PersistedLegacyRecoveryCandidate[];\n}\n\nexport interface IndexedDBLegacyRecoveryCandidate {\n readonly kind: IndexedDBLegacyRecoveryKind;\n readonly reason: IndexedDBLegacyConflictReason;\n readonly text: string | null;\n readonly binary: ArrayBuffer | null;\n readonly metadata: FileMeta | null;\n readonly detectedAt: string;\n}\n\nexport interface IndexedDBLegacyMigrationConflict {\n readonly path: WorkspacePath;\n /** Backward-compatible projection of the newest quarantined candidate. */\n readonly reason: IndexedDBLegacyConflictReason;\n readonly kind: IndexedDBLegacyRecoveryKind;\n readonly text: string | null;\n readonly binary: ArrayBuffer | null;\n readonly metadata: FileMeta | null;\n readonly detectedAt: string;\n readonly candidates: readonly IndexedDBLegacyRecoveryCandidate[];\n}\n\nexport type IndexedDBLegacyConflictResolution =\n | 'v2'\n | 'text'\n | 'binary'\n | {\n readonly candidate: number;\n readonly payload: 'text' | 'binary' | 'directory';\n };\n\nexport interface IndexedDBFileSystemProviderV2Options {\n /** Injectable store for fault, migration, and concurrency tests. */\n readonly store?: IndexedDBFileSystemStore;\n readonly now?: () => Date;\n /** Shared-store owners can retain the connection when this facade is disposed. */\n readonly closeStoreOnDispose?: boolean;\n}\n\ninterface MutationVersion {\n readonly state: PersistedState;\n readonly version: FileSystemVersion;\n readonly lastModified: string;\n}\n\n/**\n * IndexedDB implementation of the correctness-first filesystem contract.\n *\n * Each canonical path has one authoritative structured-clone record containing\n * its kind, owned bytes (for files), version, and metadata. Every mutation and\n * snapshot is one IndexedDB transaction. Legacy v1 keys are imported once;\n * ambiguous or stale branches move into durable recovery records before the\n * legacy namespace is deleted, leaving one live authority.\n */\nexport class IndexedDBFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = INDEXEDDB_V2_CAPABILITIES;\n\n private readonly store: IndexedDBFileSystemStore;\n private readonly now: () => Date;\n private readonly closeStoreOnDispose: boolean;\n private readonly versionPrefix: string;\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private initialization: Promise<void> | null = null;\n private disposePromise: Promise<void> | null = null;\n private storeClosed = false;\n private disposed = false;\n\n public constructor(\n id: string,\n label: string,\n options: IndexedDBFileSystemProviderV2Options = {},\n ) {\n this.id = id;\n this.label = label;\n this.store = options.store ?? new RawIndexedDBFileSystemStore(`docblocks-fs-${id}`, 'files');\n this.now = options.now ?? (() => new Date());\n this.closeStoreOnDispose = options.closeStoreOnDispose ?? true;\n this.versionPrefix = `idb-${encodeURIComponent(id).slice(0, 900) || 'workspace'}`;\n }\n\n /** Track accepted storage work so disposal can join it before closing. */\n private runSharedTransaction<T>(\n mode: IndexedDBFileSystemTransactionMode,\n operation: FsOperation,\n work: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,\n ): Promise<T> {\n this.assertOpen(operation);\n const transaction = this.store.transaction(mode, work);\n this.inFlight.add(transaction);\n void transaction.then(\n () => this.inFlight.delete(transaction),\n () => this.inFlight.delete(transaction),\n );\n return transaction;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n this.assertOpen('stat');\n const canonical = parseWorkspacePath(path);\n await this.ensureInitialized('stat');\n return this.transaction('readonly', { operation: 'stat', path: canonical }, async (tx) => {\n const entry = await readEntry(tx, canonical);\n return entry ? toEntrySnapshot(entry) : null;\n });\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n this.assertOpen('read');\n const canonical = parseWorkspacePath(path);\n await this.ensureInitialized('read');\n return this.transaction('readonly', { operation: 'read', path: canonical }, async (tx) => {\n const entry = await readEntry(tx, canonical);\n if (!entry) return null;\n if (entry.kind !== 'file') {\n throw this.error(\n 'type-mismatch',\n 'read',\n canonical,\n 'Expected a file but found a directory.',\n );\n }\n return Object.freeze({ entry: toFileSnapshot(entry), data: copyBytes(entry.data) });\n });\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n this.assertOpen('list');\n const canonical = parseWorkspacePath(path);\n await this.ensureInitialized('list');\n return this.transaction('readonly', { operation: 'list', path: canonical }, async (tx) => {\n const directory = await readEntry(tx, canonical);\n if (!directory) {\n throw this.error('not-found', 'list', canonical, 'Directory does not exist.');\n }\n if (directory.kind !== 'directory') {\n throw this.error(\n 'type-mismatch',\n 'list',\n canonical,\n 'Expected a directory but found a file.',\n );\n }\n const paths = await listEntryPaths(tx);\n const children: FileSystemEntrySnapshot[] = [];\n for (const candidate of paths) {\n if (candidate && workspacePathDirname(candidate) === canonical) {\n const entry = await readRequiredEntry(tx, candidate);\n children.push(toEntrySnapshot(entry));\n }\n }\n children.sort(compareSnapshots);\n return Object.freeze(children);\n });\n }\n\n public async writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options: FileSystemWriteOptions = {},\n ): Promise<FileSystemFileSnapshot> {\n this.assertOpen('write');\n const canonical = this.canonicalNonRoot(path, 'write');\n const ownedData = copyBytes(data);\n await this.ensureInitialized('write');\n return this.withMutationLock(() =>\n this.transaction('readwrite', { operation: 'write', path: canonical }, async (tx) => {\n await assertNoLegacyConflict(tx, canonical, 'write');\n const mutation = new EntryMutation(tx);\n const existing = await mutation.get(canonical);\n if (existing?.kind === 'directory') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Cannot replace a directory with a file.',\n );\n }\n const mode = options.mode ?? 'upsert';\n if (mode === 'create' && existing) {\n throw this.error('already-exists', 'write', canonical, 'File already exists.');\n }\n if (mode === 'replace' && !existing) {\n throw this.error('not-found', 'write', canonical, 'File does not exist.');\n }\n this.assertExpectedVersion(existing, options.expectedVersion, 'write', canonical);\n const missingParents = await this.planParents(\n mutation,\n canonical,\n options.createParents ?? false,\n 'write',\n );\n const next = await this.nextMutationVersion(tx);\n this.addDirectories(mutation, missingParents, next);\n const file: PersistedFileEntry = {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'file',\n path: canonical,\n data: ownedData,\n version: next.version,\n lastModified: next.lastModified,\n };\n mutation.set(canonical, file);\n await this.touchParents(mutation, canonical, next);\n await mutation.commit(next.state);\n return toFileSnapshot(file);\n }),\n );\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options: FileSystemCreateDirectoryOptions = {},\n ): Promise<FileSystemDirectorySnapshot> {\n this.assertOpen('create-directory');\n const canonical = parseWorkspacePath(path);\n await this.ensureInitialized('create-directory');\n return this.withMutationLock(() =>\n this.transaction(\n 'readwrite',\n { operation: 'create-directory', path: canonical },\n async (tx) => {\n await assertNoLegacyConflict(tx, canonical, 'create-directory');\n const mutation = new EntryMutation(tx);\n const existing = await mutation.get(canonical);\n if (existing) {\n if (existing.kind !== 'directory') {\n throw this.error(\n 'type-mismatch',\n 'create-directory',\n canonical,\n 'Cannot replace a file with a directory.',\n );\n }\n if ((options.mode ?? 'ensure') === 'create') {\n throw this.error(\n 'already-exists',\n 'create-directory',\n canonical,\n 'Directory already exists.',\n );\n }\n return toDirectorySnapshot(existing);\n }\n const missingParents = await this.planParents(\n mutation,\n canonical,\n options.createParents ?? false,\n 'create-directory',\n );\n const next = await this.nextMutationVersion(tx);\n this.addDirectories(mutation, [...missingParents, canonical], next);\n await this.touchParents(mutation, canonical, next);\n await mutation.commit(next.state);\n const created = await mutation.get(canonical);\n if (!created || created.kind !== 'directory') {\n throw corrupt('Created directory was not staged.', canonical);\n }\n return toDirectorySnapshot(created);\n },\n ),\n );\n }\n\n public async remove(\n path: WorkspacePath,\n options: FileSystemRemoveOptions = {},\n ): Promise<FileSystemRemoveResult> {\n this.assertOpen('remove');\n const canonical = this.canonicalNonRoot(path, 'remove');\n await this.ensureInitialized('remove');\n return this.withMutationLock(() =>\n this.transaction('readwrite', { operation: 'remove', path: canonical }, async (tx) => {\n const mutation = new EntryMutation(tx);\n const existing = await mutation.get(canonical);\n const state = await readRequiredState(tx);\n if (!existing) {\n if ((options.missing ?? 'error') === 'ignore') {\n return Object.freeze({\n removed: false,\n version: parseFileSystemVersion(state.treeVersion),\n });\n }\n throw this.error('not-found', 'remove', canonical, 'Entry does not exist.');\n }\n this.assertExpectedVersion(existing, options.expectedVersion, 'remove', canonical);\n const paths = await mutation.paths();\n const descendants = paths.filter((candidate) =>\n workspacePathContains(canonical, candidate, false),\n );\n if (existing.kind === 'directory' && descendants.length > 0 && !options.recursive) {\n throw this.error('not-empty', 'remove', canonical, 'Directory is not empty.');\n }\n const next = this.advanceState(state);\n mutation.delete(canonical);\n if (existing.kind === 'directory') {\n for (const descendant of descendants) mutation.delete(descendant);\n }\n await this.touchParents(mutation, canonical, next);\n await mutation.commit(next.state);\n return Object.freeze({ removed: true, version: next.version });\n }),\n );\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options: FileSystemMoveOptions = {},\n ): Promise<FileSystemEntrySnapshot> {\n this.assertOpen('move');\n const sourcePath = this.canonicalNonRoot(oldPath, 'move');\n const destinationPath = this.canonicalNonRoot(newPath, 'move');\n await this.ensureInitialized('move');\n return this.withMutationLock(() =>\n this.transaction(\n 'readwrite',\n { operation: 'move', path: sourcePath, destinationPath },\n async (tx) => {\n await assertNoLegacyConflict(tx, sourcePath, 'move');\n await assertNoLegacyConflict(tx, destinationPath, 'move');\n const mutation = new EntryMutation(tx);\n const source = await mutation.get(sourcePath);\n if (!source) {\n throw this.error('not-found', 'move', sourcePath, 'Source does not exist.');\n }\n this.assertExpectedVersion(source, options.expectedVersion, 'move', sourcePath);\n if (sourcePath === destinationPath) return toEntrySnapshot(source);\n if (await mutation.get(destinationPath)) {\n throw new FsError('already-exists', 'Destination already exists.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n if (\n source.kind === 'directory' &&\n workspacePathContains(sourcePath, destinationPath, false)\n ) {\n throw new FsError('invalid-path', 'Cannot move a directory into itself.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n const missingParents = await this.planParents(\n mutation,\n destinationPath,\n options.createParents ?? false,\n 'move',\n );\n const paths = await mutation.paths();\n const sourcePaths = paths.filter((candidate) =>\n workspacePathContains(sourcePath, candidate),\n );\n const sourceSet = new Set(sourcePaths);\n const remapped: Array<readonly [WorkspacePath, WorkspacePath, PersistedEntry]> = [];\n for (const currentPath of sourcePaths) {\n const suffix = currentPath.slice(sourcePath.length);\n const targetPath = parseWorkspacePath(`${destinationPath}${suffix}`);\n const collision = await mutation.get(targetPath);\n if (collision && !sourceSet.has(targetPath)) {\n throw new FsError('already-exists', 'A destination descendant already exists.', {\n operation: 'move',\n path: currentPath,\n destinationPath: targetPath,\n });\n }\n remapped.push([currentPath, targetPath, await mutation.require(currentPath)]);\n }\n const state = await readRequiredState(tx);\n const next = this.advanceState(state);\n for (const currentPath of sourcePaths) mutation.delete(currentPath);\n this.addDirectories(mutation, missingParents, next);\n for (const [, targetPath, current] of remapped) {\n mutation.set(targetPath, withPathAndVersion(current, targetPath, next));\n }\n await this.touchParents(mutation, sourcePath, next);\n await this.touchParents(mutation, destinationPath, next);\n await mutation.commit(next.state);\n return toEntrySnapshot(await mutation.require(destinationPath));\n },\n ),\n );\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n this.assertOpen('snapshot');\n await this.ensureInitialized('snapshot');\n return this.transaction('readonly', { operation: 'snapshot' }, async (tx) => {\n const [state, paths] = await Promise.all([readRequiredState(tx), listEntryPaths(tx)]);\n const entries: FileSystemSnapshotEntry[] = [];\n for (const path of paths.sort(compareText)) {\n const entry = await readRequiredEntry(tx, path);\n entries.push(\n entry.kind === 'file'\n ? Object.freeze({ ...toFileSnapshot(entry), data: copyBytes(entry.data) })\n : toDirectorySnapshot(entry),\n );\n }\n return Object.freeze({\n version: parseFileSystemVersion(state.treeVersion),\n entries: Object.freeze(entries),\n });\n });\n }\n\n /** IndexedDB has no reliable cross-browser external-change observer. */\n public watch(\n _listener: FileSystemWatchListener,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n const error = new FsError('not-supported', 'IndexedDB filesystem watching is unavailable.', {\n operation: 'watch',\n });\n let closed = false;\n let disposePromise: Promise<void> | null = null;\n const ready = Promise.reject(error);\n void ready.catch((caught: FsError) => {\n try {\n options.onError?.(caught);\n } catch {\n // An observational error callback cannot change subscription state.\n }\n });\n const subscription: FileSystemWatchSubscription = {\n get closed() {\n return closed;\n },\n ready,\n dispose: () => {\n if (disposePromise) return disposePromise;\n closed = true;\n this.subscriptions.delete(subscription);\n disposePromise = Promise.resolve();\n return disposePromise;\n },\n };\n this.subscriptions.add(subscription);\n return subscription;\n }\n\n public dispose(): Promise<void> {\n if (this.disposePromise) return this.disposePromise;\n this.disposed = true;\n this.disposePromise = (async () => {\n try {\n await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n } finally {\n if (this.closeStoreOnDispose && !this.storeClosed) {\n this.storeClosed = true;\n this.store.close?.();\n }\n }\n })();\n return this.disposePromise;\n }\n\n /** List unresolved, byte-preserving conflicts found during v1 migration. */\n public async listLegacyMigrationConflicts(): Promise<\n readonly IndexedDBLegacyMigrationConflict[]\n > {\n this.assertOpen('read');\n await this.ensureInitialized('read');\n return this.transaction('readonly', { operation: 'read' }, async (tx) => {\n const keys = (await tx.keys()).filter((key) => key.startsWith(LEGACY_CONFLICT_PREFIX));\n const conflicts: IndexedDBLegacyMigrationConflict[] = [];\n for (const key of keys) {\n const raw = await tx.get<unknown>(key);\n conflicts.push(toPublicLegacyConflict(validateLegacyConflict(raw)));\n }\n conflicts.sort((left, right) => compareText(left.path, right.path));\n return Object.freeze(conflicts);\n });\n }\n\n /** Resolve quarantined legacy data by choosing v2 or one legacy byte payload. */\n public async resolveLegacyMigrationConflict(\n path: WorkspacePath,\n resolution: IndexedDBLegacyConflictResolution,\n ): Promise<FileSystemEntrySnapshot> {\n this.assertOpen('write');\n const canonical = this.canonicalNonRoot(path, 'write');\n await this.ensureInitialized('write');\n return this.withMutationLock(() =>\n this.transaction('readwrite', { operation: 'write', path: canonical }, async (tx) => {\n const key = legacyConflictKey(canonical);\n const conflict = validateLegacyConflict(await tx.get<unknown>(key));\n if (conflict.path !== canonical) throw corrupt('Legacy conflict key mismatch.', canonical);\n const mutation = new EntryMutation(tx);\n const existing = await mutation.get(canonical);\n if (resolution === 'v2') {\n if (!existing) {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'There is no v2 authority to keep at this path.',\n );\n }\n await tx.delete(key);\n return toEntrySnapshot(existing);\n }\n\n const selected = selectLegacyPayload(conflict, resolution, canonical);\n if (selected.kind === 'directory') {\n if (existing?.kind === 'file') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Move or remove the v2 file before restoring a legacy directory at this path.',\n );\n }\n if (existing) {\n await tx.delete(key);\n return toDirectorySnapshot(existing);\n }\n const missingParents = await this.planParents(mutation, canonical, true, 'write');\n const next = await this.nextMutationVersion(tx);\n this.addDirectories(mutation, [...missingParents, canonical], next);\n await this.touchParents(mutation, canonical, next);\n await mutation.commit(next.state);\n await tx.delete(key);\n const restored = await mutation.require(canonical);\n if (restored.kind !== 'directory') {\n throw corrupt('Restored legacy directory was not staged as a directory.', canonical);\n }\n return toDirectorySnapshot(restored);\n }\n if (existing?.kind === 'directory') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Move or remove the v2 directory before restoring a legacy file at this path.',\n );\n }\n const missingParents = await this.planParents(mutation, canonical, true, 'write');\n const next = await this.nextMutationVersion(tx);\n this.addDirectories(mutation, missingParents, next);\n const file: PersistedFileEntry = {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'file',\n path: canonical,\n data: copyBytes(selected.data),\n version: next.version,\n lastModified: next.lastModified,\n };\n mutation.set(canonical, file);\n await this.touchParents(mutation, canonical, next);\n await mutation.commit(next.state);\n await tx.delete(key);\n return toFileSnapshot(file);\n }),\n );\n }\n\n /** Explicitly discard every quarantined legacy candidate at a path. */\n public async discardLegacyMigrationConflict(path: WorkspacePath): Promise<boolean> {\n this.assertOpen('remove');\n const canonical = this.canonicalNonRoot(path, 'remove');\n await this.ensureInitialized('remove');\n return this.withMutationLock(() =>\n this.transaction('readwrite', { operation: 'remove', path: canonical }, async (tx) => {\n const key = legacyConflictKey(canonical);\n if ((await tx.get<unknown>(key)) === null) return false;\n await tx.delete(key);\n return true;\n }),\n );\n }\n\n private async ensureInitialized(operation: FsOperation): Promise<void> {\n this.assertOpen(operation);\n if (this.initialization) return this.initialization;\n const attempt = this.withMutationLock(() =>\n this.runSharedTransaction('readwrite', operation, (tx) => this.migrateLegacy(tx)),\n );\n this.initialization = attempt.catch((error: unknown) => {\n this.initialization = null;\n throw fsErrorFromUnknown(error, { operation });\n });\n return this.initialization;\n }\n\n private async migrateLegacy(tx: IndexedDBFileSystemTransaction): Promise<void> {\n const existingState = await readState(tx);\n const keys = await tx.keys();\n if (existingState) {\n const root = await readEntry(tx, WORKSPACE_ROOT);\n if (!root || root.kind !== 'directory') {\n throw corrupt('Initialized v2 filesystem has no root directory.', WORKSPACE_ROOT);\n }\n if (\n existingState.migrationVersion === 1 ||\n keys.some((key) => key.startsWith(LEGACY_PREFIX))\n ) {\n await this.quarantineExistingLegacy(\n tx,\n keys,\n existingState,\n existingState.migrationVersion === 1 ? 'authority-collision' : 'stale-client-write',\n );\n }\n return;\n }\n\n const now = this.now().toISOString();\n const version = this.makeVersion(1);\n const entries = new Map<WorkspacePath, PersistedEntry>();\n\n // Preserve any authoritative v2 records left by a pre-release build.\n for (const path of entryPathsFromKeys(keys)) {\n entries.set(path, await readRequiredEntry(tx, path));\n }\n if (entries.get(WORKSPACE_ROOT)?.kind === 'file') {\n throw corrupt(\n 'Pre-release v2 authority stored a file at the workspace root.',\n WORKSPACE_ROOT,\n );\n }\n entries.set(\n WORKSPACE_ROOT,\n entries.get(WORKSPACE_ROOT) ?? directoryRecord(WORKSPACE_ROOT, version, now),\n );\n\n const legacyDirectories = await readLegacyDirectories(tx);\n const legacyFilePaths = legacyPathsFromKeys(keys);\n for (const directory of legacyDirectories) {\n const existing = entries.get(directory);\n if (existing?.kind === 'file' || hasFileAncestor(entries, directory)) {\n await appendLegacyConflict(\n tx,\n directory,\n directoryRecoveryCandidate('authority-collision', now),\n );\n continue;\n }\n addParentDirectories(entries, directory, version, now);\n if (!existing) entries.set(directory, directoryRecord(directory, version, now));\n }\n\n for (const path of legacyFilePaths) {\n const legacy = await readLegacyFile(tx, path);\n const existing = entries.get(path);\n if (existing?.kind === 'file') {\n if (!legacyPayloadsMatchEntry(legacy, existing)) {\n await appendLegacyConflict(\n tx,\n path,\n fileRecoveryCandidate(legacy, 'authority-collision', now),\n );\n }\n continue;\n }\n const kindCollision = existing?.kind === 'directory' || hasFileAncestor(entries, path);\n const payloadsDisagree =\n legacy.content !== null &&\n legacy.binary !== null &&\n !bytesEqual(new TextEncoder().encode(legacy.content), legacy.binary);\n if (\n payloadsDisagree ||\n kindCollision ||\n (legacy.content === null && legacy.binary === null)\n ) {\n await appendLegacyConflict(\n tx,\n path,\n fileRecoveryCandidate(\n legacy,\n kindCollision\n ? 'kind-collision'\n : payloadsDisagree\n ? 'dual-payload'\n : 'authority-collision',\n now,\n ),\n );\n continue;\n }\n addParentDirectories(entries, path, version, now);\n const data =\n legacy.content !== null\n ? new TextEncoder().encode(legacy.content).buffer\n : copyBytes(legacy.binary!);\n entries.set(path, {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'file',\n path,\n data: copyBytes(data),\n version,\n lastModified: legacy.metadata?.lastModified ?? now,\n });\n }\n\n for (const entry of entries.values()) {\n await tx.put(entryKey(entry.path), entry);\n }\n await deleteLegacyNamespace(tx, keys);\n const state: PersistedState = {\n schemaVersion: STATE_SCHEMA_VERSION,\n migrationVersion: 2,\n mutationCounter: 1,\n treeVersion: version,\n };\n await tx.put(STATE_KEY, state);\n }\n\n private async quarantineExistingLegacy(\n tx: IndexedDBFileSystemTransaction,\n keys: readonly string[],\n state: PersistedState,\n reason: 'authority-collision' | 'stale-client-write',\n ): Promise<void> {\n const now = this.now().toISOString();\n const ignored = await readMarkerPaths(\n tx,\n keys,\n LEGACY_IGNORED_PREFIX,\n validateIgnoredLegacyPath,\n );\n const legacyDirectories = await readLegacyDirectories(tx);\n for (const path of legacyDirectories) {\n if (ignored.has(path)) continue;\n const entry = await readEntry(tx, path);\n if (entry?.kind === 'directory') continue;\n await appendLegacyConflict(\n tx,\n path,\n directoryRecoveryCandidate(entry ? 'kind-collision' : reason, now),\n );\n }\n\n for (const path of legacyPathsFromKeys(keys)) {\n if (ignored.has(path)) continue;\n const legacy = await readLegacyFile(tx, path);\n const entry = await readEntry(tx, path);\n if (entry?.kind === 'file' && legacyPayloadsMatchEntry(legacy, entry)) continue;\n await appendLegacyConflict(\n tx,\n path,\n fileRecoveryCandidate(legacy, entry?.kind === 'directory' ? 'kind-collision' : reason, now),\n );\n }\n\n await deleteLegacyNamespace(tx, keys);\n for (const key of keys) {\n if (key.startsWith(LEGACY_IGNORED_PREFIX)) await tx.delete(key);\n }\n if (state.migrationVersion === 1) {\n await tx.put(STATE_KEY, { ...state, migrationVersion: 2 } satisfies PersistedState);\n }\n }\n\n private async transaction<T>(\n mode: IndexedDBFileSystemTransactionMode,\n context: FsErrorContext,\n operation: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,\n ): Promise<T> {\n this.assertOpen(context.operation ?? 'read');\n for (let attempt = 0; attempt < 3; attempt += 1) {\n try {\n const outcome = await this.runSharedTransaction(\n mode,\n context.operation ?? 'read',\n async (transaction) => {\n if (await transaction.hasKeyWithPrefix(LEGACY_PREFIX)) {\n if (mode === 'readonly') throw new LegacyNamespaceDetectedError();\n const state = await readRequiredState(transaction);\n await this.quarantineExistingLegacy(\n transaction,\n await transaction.keys(),\n state,\n 'stale-client-write',\n );\n return { retry: true as const };\n }\n return { retry: false as const, value: await operation(transaction) };\n },\n );\n if (outcome.retry) continue;\n return outcome.value;\n } catch (error: unknown) {\n if (!(error instanceof LegacyNamespaceDetectedError)) {\n throw fsErrorFromUnknown(error, context);\n }\n try {\n await this.withMutationLock(() =>\n this.runSharedTransaction(\n 'readwrite',\n context.operation ?? 'read',\n async (transaction) => {\n if (!(await transaction.hasKeyWithPrefix(LEGACY_PREFIX))) return;\n const state = await readRequiredState(transaction);\n await this.quarantineExistingLegacy(\n transaction,\n await transaction.keys(),\n state,\n 'stale-client-write',\n );\n },\n ),\n );\n } catch (quarantineError: unknown) {\n throw fsErrorFromUnknown(quarantineError, context);\n }\n }\n }\n throw new FsError('busy', 'A stale IndexedDB client is continuously writing legacy records.', {\n ...context,\n retryable: true,\n });\n }\n\n private withMutationLock<T>(operation: () => Promise<T>): Promise<T> {\n return withFileCommitLock(`indexeddb:${this.id}:workspace`, operation);\n }\n\n private async nextMutationVersion(tx: IndexedDBFileSystemTransaction): Promise<MutationVersion> {\n return this.advanceState(await readRequiredState(tx));\n }\n\n private advanceState(state: PersistedState): MutationVersion {\n if (state.mutationCounter >= Number.MAX_SAFE_INTEGER) {\n throw corrupt('IndexedDB filesystem mutation counter overflowed.');\n }\n const mutationCounter = state.mutationCounter + 1;\n const version = this.makeVersion(mutationCounter);\n const nextState: PersistedState = {\n ...state,\n mutationCounter,\n treeVersion: version,\n };\n return { state: nextState, version, lastModified: this.now().toISOString() };\n }\n\n private makeVersion(counter: number): FileSystemVersion {\n return parseFileSystemVersion(`${this.versionPrefix}:${counter}`);\n }\n\n private async planParents(\n mutation: EntryMutation,\n path: WorkspacePath,\n createParents: boolean,\n operation: FsOperation,\n ): Promise<WorkspacePath[]> {\n const missing: WorkspacePath[] = [];\n for (const parent of parentChain(path)) {\n const entry = await mutation.get(parent);\n if (entry?.kind === 'file') {\n throw this.error(\n 'type-mismatch',\n operation,\n parent,\n 'A parent path is a file, not a directory.',\n );\n }\n if (!entry) {\n if (!createParents) {\n throw this.error('not-found', operation, parent, 'Parent directory does not exist.');\n }\n missing.push(parent);\n }\n }\n return missing;\n }\n\n private addDirectories(\n mutation: EntryMutation,\n paths: readonly WorkspacePath[],\n next: MutationVersion,\n ): void {\n for (const path of paths) {\n mutation.set(path, directoryRecord(path, next.version, next.lastModified));\n }\n }\n\n private async touchParents(\n mutation: EntryMutation,\n path: WorkspacePath,\n next: MutationVersion,\n ): Promise<void> {\n for (const parent of parentChain(path)) {\n const entry = await mutation.get(parent);\n if (entry?.kind === 'directory') {\n mutation.set(parent, directoryRecord(parent, next.version, next.lastModified));\n }\n }\n }\n\n private canonicalNonRoot(path: WorkspacePath, operation: FsOperation): WorkspacePath {\n const canonical = parseWorkspacePath(path);\n if (!canonical) {\n throw this.error(\n 'invalid-path',\n operation,\n canonical,\n 'The workspace root is not a file entry.',\n );\n }\n return canonical;\n }\n\n private assertExpectedVersion(\n entry: PersistedEntry | null,\n expected: FileSystemVersion | null | undefined,\n operation: FsOperation,\n path: WorkspacePath,\n ): void {\n if (expected === undefined) return;\n if (expected === null ? !entry : entry?.version === expected) return;\n throw this.error(\n 'conflict',\n operation,\n path,\n 'Entry version does not match the expected version.',\n );\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n\n private error(\n code: FsErrorCode,\n operation: FsOperation,\n path: WorkspacePath,\n message: string,\n ): FsError {\n return new FsError(code, message, { operation, path });\n }\n}\n\nclass EntryMutation {\n private readonly cache = new Map<WorkspacePath, PersistedEntry | null>();\n private readonly changed = new Map<WorkspacePath, PersistedEntry>();\n private readonly deleted = new Set<WorkspacePath>();\n\n public constructor(private readonly transaction: IndexedDBFileSystemTransaction) {}\n\n public async get(path: WorkspacePath): Promise<PersistedEntry | null> {\n if (this.deleted.has(path)) return null;\n const cached = this.cache.get(path);\n if (cached !== undefined) return cached;\n const entry = await readEntry(this.transaction, path);\n this.cache.set(path, entry);\n return entry;\n }\n\n public async require(path: WorkspacePath): Promise<PersistedEntry> {\n const entry = await this.get(path);\n if (!entry) throw corrupt(`Missing staged entry: ${path}.`, path);\n return entry;\n }\n\n public set(path: WorkspacePath, entry: PersistedEntry): void {\n const owned = copyEntry(entry);\n this.cache.set(path, owned);\n this.changed.set(path, owned);\n this.deleted.delete(path);\n }\n\n public delete(path: WorkspacePath): void {\n this.cache.set(path, null);\n this.changed.delete(path);\n this.deleted.add(path);\n }\n\n public async paths(): Promise<WorkspacePath[]> {\n const paths = new Set(await listEntryPaths(this.transaction));\n for (const path of this.deleted) paths.delete(path);\n for (const path of this.changed.keys()) paths.add(path);\n return [...paths];\n }\n\n public async commit(state: PersistedState): Promise<void> {\n for (const path of this.deleted) await this.transaction.delete(entryKey(path));\n for (const [path, entry] of this.changed) await this.transaction.put(entryKey(path), entry);\n await this.transaction.put(STATE_KEY, state);\n }\n}\n\nfunction entryKey(path: WorkspacePath): string {\n return `${ENTRY_PREFIX}${path}`;\n}\n\nfunction legacyConflictKey(path: WorkspacePath): string {\n return `${LEGACY_CONFLICT_PREFIX}${path}`;\n}\n\nfunction entryPathsFromKeys(keys: readonly string[]): WorkspacePath[] {\n return keys\n .filter((key) => key.startsWith(ENTRY_PREFIX))\n .map((key) => {\n const rawPath = key.slice(ENTRY_PREFIX.length);\n const path = parseWorkspacePath(rawPath);\n if (path !== rawPath) throw corrupt(`Non-canonical v2 entry key: ${key}.`);\n return path;\n });\n}\n\nasync function listEntryPaths(tx: IndexedDBFileSystemTransaction): Promise<WorkspacePath[]> {\n return entryPathsFromKeys(await tx.keys());\n}\n\nasync function readEntry(\n tx: IndexedDBFileSystemTransaction,\n path: WorkspacePath,\n): Promise<PersistedEntry | null> {\n const raw = await tx.get<unknown>(entryKey(path));\n return raw === null ? null : validateEntry(raw, path);\n}\n\nasync function readRequiredEntry(\n tx: IndexedDBFileSystemTransaction,\n path: WorkspacePath,\n): Promise<PersistedEntry> {\n const entry = await readEntry(tx, path);\n if (!entry) throw corrupt(`Missing v2 entry record: ${path}.`, path);\n return entry;\n}\n\nfunction validateEntry(value: unknown, expectedPath: WorkspacePath): PersistedEntry {\n if (!isRecord(value)) throw corrupt(`Corrupt v2 entry record: ${expectedPath}.`, expectedPath);\n const path = parseWorkspacePath(readString(value.path, 'entry path'));\n if (path !== expectedPath) throw corrupt(`V2 entry path does not match key: ${expectedPath}.`);\n if (value.schemaVersion !== ENTRY_SCHEMA_VERSION) {\n throw corrupt(`Unsupported v2 entry schema at ${expectedPath}.`, expectedPath);\n }\n const version = parseFileSystemVersion(value.version);\n const lastModified = readString(value.lastModified, 'lastModified');\n if (value.kind === 'directory') {\n return { schemaVersion: ENTRY_SCHEMA_VERSION, kind: 'directory', path, version, lastModified };\n }\n if (value.kind !== 'file') throw corrupt(`Unknown entry kind at ${expectedPath}.`, expectedPath);\n return {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'file',\n path,\n version,\n lastModified,\n data: validateBytes(value.data, expectedPath),\n };\n}\n\nasync function readState(tx: IndexedDBFileSystemTransaction): Promise<PersistedState | null> {\n const raw = await tx.get<unknown>(STATE_KEY);\n return raw === null ? null : validateState(raw);\n}\n\nasync function readRequiredState(tx: IndexedDBFileSystemTransaction): Promise<PersistedState> {\n const state = await readState(tx);\n if (!state) throw corrupt('IndexedDB v2 state record is missing.');\n return state;\n}\n\nfunction validateState(value: unknown): PersistedState {\n if (\n !isRecord(value) ||\n value.schemaVersion !== STATE_SCHEMA_VERSION ||\n (value.migrationVersion !== 1 && value.migrationVersion !== 2) ||\n typeof value.mutationCounter !== 'number' ||\n !Number.isSafeInteger(value.mutationCounter) ||\n value.mutationCounter < 0\n ) {\n throw corrupt('IndexedDB v2 state record is corrupt.');\n }\n return {\n schemaVersion: STATE_SCHEMA_VERSION,\n migrationVersion: value.migrationVersion,\n mutationCounter: value.mutationCounter,\n treeVersion: parseFileSystemVersion(value.treeVersion),\n };\n}\n\nasync function readLegacyDirectories(tx: IndexedDBFileSystemTransaction): Promise<WorkspacePath[]> {\n const raw = await tx.get<unknown>(LEGACY_DIRS_KEY);\n if (raw === null) return [];\n if (!Array.isArray(raw)) throw corrupt('Legacy directory index is corrupt.');\n const directories: WorkspacePath[] = [];\n for (const value of raw) {\n if (typeof value !== 'string') throw corrupt('Legacy directory index is corrupt.');\n const path = parseWorkspacePath(value);\n if (path) directories.push(path);\n }\n return directories;\n}\n\nfunction legacyPathsFromKeys(keys: readonly string[]): WorkspacePath[] {\n const paths = new Set<WorkspacePath>();\n for (const key of keys) {\n if (!key.startsWith(LEGACY_PREFIX) || key === LEGACY_DIRS_KEY) continue;\n const suffix = [LEGACY_CONTENT_SUFFIX, LEGACY_BINARY_SUFFIX, LEGACY_META_SUFFIX].find(\n (candidate) => key.endsWith(candidate),\n );\n if (!suffix) continue;\n const rawPath = key.slice(LEGACY_PREFIX.length, -suffix.length);\n try {\n const path = parseWorkspacePath(rawPath);\n if (path) paths.add(path);\n } catch {\n // Invalid legacy keys remain untouched. They are not valid v2 paths.\n }\n }\n return [...paths];\n}\n\nasync function readLegacyFile(\n tx: IndexedDBFileSystemTransaction,\n path: WorkspacePath,\n): Promise<{ content: string | null; binary: ArrayBuffer | null; metadata: FileMeta | null }> {\n const [rawContent, rawBinary, rawMetadata] = await Promise.all([\n tx.get<unknown>(`${LEGACY_PREFIX}${path}${LEGACY_CONTENT_SUFFIX}`),\n tx.get<unknown>(`${LEGACY_PREFIX}${path}${LEGACY_BINARY_SUFFIX}`),\n tx.get<unknown>(`${LEGACY_PREFIX}${path}${LEGACY_META_SUFFIX}`),\n ]);\n if (rawContent !== null && typeof rawContent !== 'string') {\n throw corrupt(`Legacy text payload is corrupt: ${path}.`, path);\n }\n return {\n content: rawContent,\n binary: rawBinary === null ? null : validateBytes(rawBinary, path),\n metadata: validateLegacyMetadata(rawMetadata, path),\n };\n}\n\nasync function readMarkerPaths(\n transaction: IndexedDBFileSystemTransaction,\n keys: readonly string[],\n prefix: string,\n validate: (value: unknown) => WorkspacePath,\n): Promise<Set<WorkspacePath>> {\n const paths = new Set<WorkspacePath>();\n for (const key of keys) {\n if (!key.startsWith(prefix)) continue;\n const expectedPath = parseWorkspacePath(key.slice(prefix.length));\n if (!expectedPath) throw corrupt(`Recovery marker cannot target the workspace root: ${key}.`);\n const value = await transaction.get<unknown>(key);\n const path = validate(value);\n if (path !== expectedPath)\n throw corrupt(`Recovery marker path does not match its key: ${key}.`);\n paths.add(path);\n }\n return paths;\n}\n\nfunction validateIgnoredLegacyPath(value: unknown): WorkspacePath {\n if (!isRecord(value) || value.schemaVersion !== 1 || typeof value.ignoredAt !== 'string') {\n throw corrupt('Ignored legacy recovery marker is corrupt.');\n }\n const path = parseWorkspacePath(readString(value.path, 'ignored legacy path'));\n if (!path) throw corrupt('Ignored legacy recovery marker cannot target the workspace root.');\n return path;\n}\n\nfunction bytesEqual(left: ArrayBuffer | Uint8Array, right: ArrayBuffer | Uint8Array): boolean {\n const leftBytes = ArrayBuffer.isView(left)\n ? new Uint8Array(left.buffer, left.byteOffset, left.byteLength)\n : new Uint8Array(left);\n const rightBytes = ArrayBuffer.isView(right)\n ? new Uint8Array(right.buffer, right.byteOffset, right.byteLength)\n : new Uint8Array(right);\n if (leftBytes.byteLength !== rightBytes.byteLength) return false;\n return leftBytes.every((byte, index) => byte === rightBytes[index]);\n}\n\nasync function assertNoLegacyConflict(\n transaction: IndexedDBFileSystemTransaction,\n path: WorkspacePath,\n operation: FsOperation,\n): Promise<void> {\n if ((await transaction.get<unknown>(legacyConflictKey(path))) === null) return;\n throw new FsError(\n 'conflict',\n 'Resolve the legacy migration conflict before mutating this path.',\n {\n operation,\n path,\n retryable: false,\n },\n );\n}\n\nfunction validateLegacyMetadata(value: unknown, path: WorkspacePath): FileMeta | null {\n if (value === null) return null;\n if (\n !isRecord(value) ||\n typeof value.name !== 'string' ||\n typeof value.path !== 'string' ||\n typeof value.size !== 'number' ||\n !Number.isFinite(value.size) ||\n typeof value.lastModified !== 'string'\n ) {\n throw corrupt(`Legacy metadata is corrupt: ${path}.`, path);\n }\n return {\n name: value.name,\n path: value.path,\n size: value.size,\n lastModified: value.lastModified,\n };\n}\n\nfunction validateLegacyConflict(value: unknown): PersistedLegacyConflict {\n if (!isRecord(value)) {\n throw corrupt('Legacy migration conflict record is corrupt.');\n }\n const path = parseWorkspacePath(readString(value.path, 'legacy conflict path'));\n if (!path) throw corrupt('Legacy migration conflict cannot target the workspace root.');\n\n if (value.schemaVersion === LEGACY_CONFLICT_SCHEMA_VERSION_V1) {\n const reason = validateLegacyConflictReason(value.reason);\n const candidate: PersistedLegacyRecoveryCandidate = {\n kind: 'file',\n reason,\n text: value.text === null ? null : readString(value.text, 'legacy conflict text'),\n binary: value.binary === null ? null : validateBytes(value.binary, path),\n metadata: validateLegacyMetadata(value.metadata, path),\n detectedAt: readString(value.detectedAt, 'legacy conflict detectedAt'),\n };\n return {\n schemaVersion: LEGACY_CONFLICT_SCHEMA_VERSION,\n path,\n candidates: Object.freeze([candidate]),\n };\n }\n if (value.schemaVersion !== LEGACY_CONFLICT_SCHEMA_VERSION || !Array.isArray(value.candidates)) {\n throw corrupt('Legacy migration conflict record is corrupt.');\n }\n const candidates = value.candidates.map((candidate) =>\n validateLegacyRecoveryCandidate(candidate, path),\n );\n if (candidates.length === 0) throw corrupt('Legacy migration conflict has no candidates.', path);\n return {\n schemaVersion: LEGACY_CONFLICT_SCHEMA_VERSION,\n path,\n candidates: Object.freeze(candidates),\n };\n}\n\nfunction toPublicLegacyConflict(\n conflict: PersistedLegacyConflict,\n): IndexedDBLegacyMigrationConflict {\n const candidates = conflict.candidates.map(toPublicLegacyCandidate);\n const latest = candidates[candidates.length - 1]!;\n return Object.freeze({\n path: parseWorkspacePath(conflict.path),\n reason: latest.reason,\n kind: latest.kind,\n text: latest.text,\n binary: latest.binary,\n metadata: latest.metadata,\n detectedAt: latest.detectedAt,\n candidates: Object.freeze(candidates),\n });\n}\n\nfunction validateLegacyRecoveryCandidate(\n value: unknown,\n path: WorkspacePath,\n): PersistedLegacyRecoveryCandidate {\n if (!isRecord(value) || (value.kind !== 'file' && value.kind !== 'directory')) {\n throw corrupt('Legacy recovery candidate is corrupt.', path);\n }\n const kind = value.kind;\n const text = value.text === null ? null : readString(value.text, 'legacy recovery text');\n const binary = value.binary === null ? null : validateBytes(value.binary, path);\n const metadata = validateLegacyMetadata(value.metadata, path);\n if (kind === 'directory' && (text !== null || binary !== null || metadata !== null)) {\n throw corrupt('A legacy directory recovery candidate contains file data.', path);\n }\n return {\n kind,\n reason: validateLegacyConflictReason(value.reason),\n text,\n binary,\n metadata,\n detectedAt: readString(value.detectedAt, 'legacy recovery detectedAt'),\n };\n}\n\nfunction validateLegacyConflictReason(value: unknown): IndexedDBLegacyConflictReason {\n if (\n value === 'dual-payload' ||\n value === 'kind-collision' ||\n value === 'authority-collision' ||\n value === 'stale-client-write'\n ) {\n return value;\n }\n throw corrupt('Legacy recovery reason is invalid.');\n}\n\nfunction toPublicLegacyCandidate(\n candidate: PersistedLegacyRecoveryCandidate,\n): IndexedDBLegacyRecoveryCandidate {\n return Object.freeze({\n kind: candidate.kind,\n reason: candidate.reason,\n text: candidate.text,\n binary: candidate.binary ? copyBytes(candidate.binary) : null,\n metadata: candidate.metadata ? Object.freeze({ ...candidate.metadata }) : null,\n detectedAt: candidate.detectedAt,\n });\n}\n\nasync function appendLegacyConflict(\n transaction: IndexedDBFileSystemTransaction,\n path: WorkspacePath,\n candidate: PersistedLegacyRecoveryCandidate,\n): Promise<void> {\n const key = legacyConflictKey(path);\n const raw = await transaction.get<unknown>(key);\n const existing = raw === null ? null : validateLegacyConflict(raw);\n if (existing?.candidates.some((item) => recoveryCandidatesEqual(item, candidate))) return;\n const candidates = [...(existing?.candidates ?? []), copyRecoveryCandidate(candidate)];\n await transaction.put(key, {\n schemaVersion: LEGACY_CONFLICT_SCHEMA_VERSION,\n path,\n candidates,\n } satisfies PersistedLegacyConflict);\n}\n\nfunction fileRecoveryCandidate(\n legacy: { content: string | null; binary: ArrayBuffer | null; metadata: FileMeta | null },\n reason: IndexedDBLegacyConflictReason,\n detectedAt: string,\n): PersistedLegacyRecoveryCandidate {\n return {\n kind: 'file',\n reason,\n text: legacy.content,\n binary: legacy.binary ? copyBytes(legacy.binary) : null,\n metadata: legacy.metadata ? { ...legacy.metadata } : null,\n detectedAt,\n };\n}\n\nfunction directoryRecoveryCandidate(\n reason: IndexedDBLegacyConflictReason,\n detectedAt: string,\n): PersistedLegacyRecoveryCandidate {\n return { kind: 'directory', reason, text: null, binary: null, metadata: null, detectedAt };\n}\n\nfunction copyRecoveryCandidate(\n candidate: PersistedLegacyRecoveryCandidate,\n): PersistedLegacyRecoveryCandidate {\n return {\n ...candidate,\n binary: candidate.binary ? copyBytes(candidate.binary) : null,\n metadata: candidate.metadata ? { ...candidate.metadata } : null,\n };\n}\n\nfunction recoveryCandidatesEqual(\n left: PersistedLegacyRecoveryCandidate,\n right: PersistedLegacyRecoveryCandidate,\n): boolean {\n return (\n left.kind === right.kind &&\n left.text === right.text &&\n nullableBytesEqual(left.binary, right.binary) &&\n nullableMetadataEqual(left.metadata, right.metadata)\n );\n}\n\nfunction nullableBytesEqual(left: ArrayBuffer | null, right: ArrayBuffer | null): boolean {\n if (left === null || right === null) return left === right;\n return bytesEqual(left, right);\n}\n\nfunction nullableMetadataEqual(left: FileMeta | null, right: FileMeta | null): boolean {\n if (left === null || right === null) return left === right;\n return (\n left.name === right.name &&\n left.path === right.path &&\n left.size === right.size &&\n left.lastModified === right.lastModified\n );\n}\n\nfunction legacyPayloadsMatchEntry(\n legacy: { content: string | null; binary: ArrayBuffer | null; metadata: FileMeta | null },\n entry: PersistedFileEntry,\n): boolean {\n if (legacy.content === null && legacy.binary === null) return false;\n return (\n (legacy.content === null || bytesEqual(new TextEncoder().encode(legacy.content), entry.data)) &&\n (legacy.binary === null || bytesEqual(legacy.binary, entry.data))\n );\n}\n\nfunction hasFileAncestor(\n entries: ReadonlyMap<WorkspacePath, PersistedEntry>,\n path: WorkspacePath,\n): boolean {\n return parentChain(path).some((parent) => entries.get(parent)?.kind === 'file');\n}\n\nasync function deleteLegacyNamespace(\n transaction: IndexedDBFileSystemTransaction,\n keys: readonly string[],\n): Promise<void> {\n for (const key of keys) {\n if (key.startsWith(LEGACY_PREFIX) && !isRecognizedLegacyKey(key)) {\n const archiveKey = `${LEGACY_OPAQUE_PREFIX}${encodeURIComponent(key)}`;\n const existing = await transaction.get<unknown>(archiveKey);\n const values =\n isRecord(existing) &&\n existing.schemaVersion === 1 &&\n existing.key === key &&\n Array.isArray(existing.values)\n ? existing.values\n : [];\n await transaction.put(archiveKey, {\n schemaVersion: 1,\n key,\n values: [...values, await transaction.get<unknown>(key)],\n });\n }\n if (key.startsWith(LEGACY_PREFIX) || key.startsWith(LEGACY_IGNORED_PREFIX))\n await transaction.delete(key);\n }\n}\n\nfunction isRecognizedLegacyKey(key: string): boolean {\n if (key === LEGACY_DIRS_KEY) return true;\n const suffix = [LEGACY_CONTENT_SUFFIX, LEGACY_BINARY_SUFFIX, LEGACY_META_SUFFIX].find((item) =>\n key.endsWith(item),\n );\n if (!suffix) return false;\n const rawPath = key.slice(LEGACY_PREFIX.length, -suffix.length);\n try {\n const path = parseWorkspacePath(rawPath);\n return path !== WORKSPACE_ROOT && path === rawPath;\n } catch {\n return false;\n }\n}\n\nfunction selectLegacyPayload(\n conflict: PersistedLegacyConflict,\n resolution: Exclude<IndexedDBLegacyConflictResolution, 'v2'>,\n path: WorkspacePath,\n): { readonly kind: 'file'; readonly data: ArrayBuffer } | { readonly kind: 'directory' } {\n const payload = typeof resolution === 'string' ? resolution : resolution.payload;\n const eligible =\n typeof resolution === 'string'\n ? conflict.candidates.filter(\n (candidate) =>\n candidate.kind === 'file' &&\n (payload === 'text' ? candidate.text !== null : candidate.binary !== null),\n )\n : [conflict.candidates[resolution.candidate]].filter(\n (candidate): candidate is PersistedLegacyRecoveryCandidate => candidate !== undefined,\n );\n if (eligible.length !== 1) {\n throw new FsError(\n 'conflict',\n 'Choose an explicit recovery candidate because multiple legacy versions are quarantined.',\n { operation: 'write', path, retryable: false },\n );\n }\n const candidate = eligible[0]!;\n if (payload === 'directory') {\n if (candidate.kind !== 'directory') {\n throw new FsError('type-mismatch', 'The selected recovery candidate is not a directory.', {\n operation: 'write',\n path,\n });\n }\n return { kind: 'directory' };\n }\n if (candidate.kind !== 'file') {\n throw new FsError('type-mismatch', 'The selected recovery candidate is a directory.', {\n operation: 'write',\n path,\n });\n }\n const data =\n payload === 'text'\n ? candidate.text === null\n ? null\n : new TextEncoder().encode(candidate.text).buffer\n : candidate.binary;\n if (data === null) {\n throw new FsError('type-mismatch', `The selected candidate has no ${payload} payload.`, {\n operation: 'write',\n path,\n });\n }\n return { kind: 'file', data: copyBytes(data) };\n}\n\nfunction addParentDirectories(\n entries: Map<WorkspacePath, PersistedEntry>,\n path: WorkspacePath,\n version: FileSystemVersion,\n lastModified: string,\n): void {\n for (const parent of parentChain(path)) {\n if (!entries.has(parent)) entries.set(parent, directoryRecord(parent, version, lastModified));\n }\n}\n\nfunction parentChain(path: WorkspacePath): WorkspacePath[] {\n const parents: WorkspacePath[] = [];\n let current = workspacePathDirname(path);\n while (true) {\n parents.unshift(current);\n if (!current) return parents;\n current = workspacePathDirname(current);\n }\n}\n\nfunction directoryRecord(\n path: WorkspacePath,\n version: FileSystemVersion,\n lastModified: string,\n): PersistedDirectoryEntry {\n return {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'directory',\n path,\n version,\n lastModified,\n };\n}\n\nfunction withPathAndVersion(\n entry: PersistedEntry,\n path: WorkspacePath,\n next: MutationVersion,\n): PersistedEntry {\n return entry.kind === 'file'\n ? {\n schemaVersion: ENTRY_SCHEMA_VERSION,\n kind: 'file',\n path,\n data: copyBytes(entry.data),\n version: next.version,\n lastModified: next.lastModified,\n }\n : directoryRecord(path, next.version, next.lastModified);\n}\n\nfunction copyEntry(entry: PersistedEntry): PersistedEntry {\n return entry.kind === 'file' ? { ...entry, data: copyBytes(entry.data) } : { ...entry };\n}\n\nfunction toEntrySnapshot(entry: PersistedEntry): FileSystemEntrySnapshot {\n return entry.kind === 'file' ? toFileSnapshot(entry) : toDirectorySnapshot(entry);\n}\n\nfunction toFileSnapshot(entry: PersistedFileEntry): FileSystemFileSnapshot {\n return Object.freeze({\n kind: 'file',\n path: parseWorkspacePath(entry.path),\n name: workspacePathBasename(parseWorkspacePath(entry.path)),\n size: entry.data.byteLength,\n version: parseFileSystemVersion(entry.version),\n lastModified: entry.lastModified,\n });\n}\n\nfunction toDirectorySnapshot(entry: PersistedDirectoryEntry): FileSystemDirectorySnapshot {\n const path = parseWorkspacePath(entry.path);\n return Object.freeze({\n kind: 'directory',\n path,\n name: workspacePathBasename(path),\n size: null,\n version: parseFileSystemVersion(entry.version),\n lastModified: entry.lastModified,\n });\n}\n\nfunction compareSnapshots(left: FileSystemEntrySnapshot, right: FileSystemEntrySnapshot): number {\n if (left.kind !== right.kind) return left.kind === 'directory' ? -1 : 1;\n return compareText(left.name, right.name);\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n\nfunction copyBytes(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n const source = ArrayBuffer.isView(data)\n ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)\n : new Uint8Array(data);\n const copy = new Uint8Array(source.byteLength);\n copy.set(source);\n return copy.buffer as ArrayBuffer;\n}\n\nfunction validateBytes(value: unknown, path: WorkspacePath): ArrayBuffer {\n if (value instanceof ArrayBuffer) return copyBytes(value);\n if (value instanceof Uint8Array) return copyBytes(value);\n throw corrupt(`Stored file bytes are corrupt: ${path}.`, path);\n}\n\nfunction readString(value: unknown, label: string): string {\n if (typeof value !== 'string') throw corrupt(`Invalid ${label}.`);\n return value;\n}\n\nfunction isRecord(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction corrupt(message: string, path?: WorkspacePath): FsError {\n return new FsError('io', message, { operation: 'read', path, retryable: false });\n}\n","/**\n * Legacy FileSystemProvider facade over the revisioned IndexedDB authority.\n *\n * The old `fs:*` namespace is migration input only. Keeping this facade as an\n * adapter prevents current callers from recreating a second persistent source\n * of truth while the workspace moves to FileSystemProviderV2.\n */\n\nimport type { FileCommitResult, FileMeta, FileSystemEntry, FileSystemProvider } from './types.js';\nimport { FsError, type FsOperation } from './fs-error.js';\nimport { parseWorkspacePath, type WorkspacePath } from './workspace-path.js';\nimport { RawIndexedDBFileSystemStore, type IndexedDBFileSystemStore } from './indexeddb-store.js';\nimport { IndexedDBFileSystemProviderV2 } from './indexeddb-provider-v2.js';\n\nexport interface IndexedDBFileSystemProviderOptions {\n /** Injectable transaction store for deterministic fault/concurrency tests. */\n store?: IndexedDBFileSystemStore;\n /** Injectable metadata clock. */\n now?: () => Date;\n}\n\nexport class IndexedDBFileSystemProvider implements FileSystemProvider {\n public readonly id: string;\n public readonly label: string;\n public readonly v2: IndexedDBFileSystemProviderV2;\n\n private disposed = false;\n\n public constructor(id: string, label: string, options: IndexedDBFileSystemProviderOptions = {}) {\n this.id = id;\n this.label = label;\n const store = options.store ?? new RawIndexedDBFileSystemStore(`docblocks-fs-${id}`, 'files');\n this.v2 = new IndexedDBFileSystemProviderV2(id, label, {\n store,\n now: options.now,\n closeStoreOnDispose: true,\n });\n }\n\n /** Release the underlying database connection after accepted work settles. */\n public dispose(): Promise<void> {\n this.disposed = true;\n return this.v2.dispose();\n }\n\n public async readFile(path: string): Promise<string | null> {\n this.assertOpen('read');\n const read = await this.v2.readFile(this.path(path, false, 'read'));\n return read ? new TextDecoder().decode(read.data) : null;\n }\n\n public async writeFile(path: string, content: string): Promise<void> {\n this.assertOpen('write');\n await this.v2.writeFile(this.path(path, false, 'write'), new TextEncoder().encode(content), {\n createParents: true,\n });\n }\n\n public async commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n this.assertOpen('write');\n const canonical = this.path(path, false, 'write');\n const current = await this.v2.readFile(canonical);\n const currentContent = current ? new TextDecoder().decode(current.data) : null;\n if (currentContent !== expectedContent && currentContent !== content) {\n return {\n status: 'conflict',\n content: currentContent,\n version: current?.entry.version ?? null,\n };\n }\n\n try {\n const committed = await this.v2.writeFile(canonical, new TextEncoder().encode(content), {\n createParents: true,\n expectedVersion: current?.entry.version ?? null,\n });\n return { status: 'committed', version: committed.version };\n } catch (error: unknown) {\n if (!(error instanceof FsError) || error.code !== 'conflict') throw error;\n const latest = await this.v2.readFile(canonical);\n return {\n status: 'conflict',\n content: latest ? new TextDecoder().decode(latest.data) : null,\n version: latest?.entry.version ?? null,\n };\n }\n }\n\n public async delete(path: string): Promise<void> {\n this.assertOpen('remove');\n await this.v2.remove(this.path(path, false, 'remove'), {\n recursive: true,\n missing: 'ignore',\n });\n }\n\n public async rename(oldPath: string, newPath: string): Promise<void> {\n this.assertOpen('move');\n await this.v2.move(this.path(oldPath, false, 'move'), this.path(newPath, false, 'move'), {\n createParents: true,\n });\n }\n\n public async readDirectory(path: string): Promise<FileSystemEntry[]> {\n this.assertOpen('list');\n try {\n const entries = await this.v2.readDirectory(this.path(path, true, 'list'));\n return entries.map((entry) => ({\n kind: entry.kind,\n name: entry.name,\n path: entry.path,\n }));\n } catch (error: unknown) {\n if (error instanceof FsError && error.code === 'not-found') return [];\n throw error;\n }\n }\n\n public async exists(path: string): Promise<boolean> {\n this.assertOpen('stat');\n return (await this.v2.stat(this.path(path, true, 'stat'))) !== null;\n }\n\n public async createDirectory(path: string): Promise<void> {\n this.assertOpen('create-directory');\n await this.v2.createDirectory(this.path(path, false, 'create-directory'), {\n createParents: true,\n mode: 'ensure',\n });\n }\n\n public async stat(path: string): Promise<FileMeta | null> {\n this.assertOpen('stat');\n const entry = await this.v2.stat(this.path(path, false, 'stat'));\n if (!entry || entry.kind !== 'file') return null;\n return {\n name: entry.name,\n path: entry.path,\n size: entry.size,\n lastModified: entry.lastModified,\n };\n }\n\n public async readBinary(path: string): Promise<ArrayBuffer | null> {\n this.assertOpen('read');\n return (await this.v2.readFile(this.path(path, false, 'read')))?.data ?? null;\n }\n\n public async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n this.assertOpen('write');\n await this.v2.writeFile(this.path(path, false, 'write'), data, { createParents: true });\n }\n\n private path(path: string, allowRoot: boolean, operation: FsOperation): WorkspacePath {\n const canonical = parseWorkspacePath(path);\n if (canonical || allowRoot) return canonical;\n throw new FsError('invalid-path', 'The filesystem root cannot be used as a mutation target.', {\n operation,\n path,\n });\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('closed', 'The IndexedDB filesystem provider is disposed.', { operation });\n }\n}\n","/**\n * IndexedDBContentContainer — a ContentContainer backed by IndexedDB.\n *\n * Uses a dedicated IndexedDBFileSystemProvider instance (separate store)\n * to persist media files across page refreshes.\n */\n\nimport type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';\nimport { findDocumentPath } from '@bendyline/squisq/storage';\nimport { IndexedDBFileSystemProviderV2 } from './indexeddb-provider-v2.js';\nimport { parseWorkspacePath, WORKSPACE_ROOT } from './workspace-path.js';\n\n// ── MIME type guessing ─────────────────────────────────────────────\n\nconst EXTENSION_MIME_MAP: Record<string, string> = {\n '.md': 'text/markdown',\n '.txt': 'text/plain',\n '.json': 'application/json',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.png': 'image/png',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.webp': 'image/webp',\n '.avif': 'image/avif',\n '.mp4': 'video/mp4',\n '.webm': 'video/webm',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.ogg': 'audio/ogg',\n};\n\nfunction guessMimeType(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return 'application/octet-stream';\n const ext = path.slice(dot).toLowerCase();\n return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';\n}\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class IndexedDBContentContainer implements ContentContainer {\n private readonly provider: IndexedDBFileSystemProviderV2;\n\n constructor(workspaceId: string) {\n this.provider = new IndexedDBFileSystemProviderV2(`${workspaceId}-media`, 'Media Storage');\n }\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n return (await this.provider.readFile(parseWorkspacePath(path)))?.data ?? null;\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void> {\n await this.provider.writeFile(parseWorkspacePath(path), data, {\n mode: 'upsert',\n createParents: true,\n });\n }\n\n async removeFile(path: string): Promise<void> {\n await this.provider.remove(parseWorkspacePath(path), { missing: 'ignore' });\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n const walk = async (dir: string) => {\n const children = await this.provider.readDirectory(parseWorkspacePath(dir));\n for (const child of children) {\n if (child.kind === 'directory') {\n await walk(child.path);\n } else {\n const filePath = child.path;\n if (prefix && !filePath.startsWith(prefix)) continue;\n entries.push({\n path: filePath,\n mimeType: guessMimeType(filePath),\n size: child.size,\n });\n }\n }\n };\n await walk(WORKSPACE_ROOT);\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n return (await this.provider.stat(parseWorkspacePath(path))) !== null;\n }\n\n async getDocumentPath(): Promise<string | null> {\n return findDocumentPath(await this.listFiles());\n }\n\n async readDocument(): Promise<string | null> {\n const docPath = await this.getDocumentPath();\n if (!docPath) return null;\n const data = await this.readFile(docPath);\n if (!data) return null;\n return new TextDecoder().decode(data);\n }\n\n async writeDocument(markdown: string, filename?: string): Promise<void> {\n const name = filename ?? 'index.md';\n const data = new TextEncoder().encode(markdown);\n await this.writeFile(name, data, 'text/markdown');\n }\n\n /** Release the IndexedDB connection when a long-lived container is retired. */\n async dispose(): Promise<void> {\n await this.provider.dispose();\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;AA6BO,IAAM,8BAAN,MAAsE;AAAA,EAKpE,YACY,cACA,WACjB;AAFiB;AACA;AANnB,SAAQ,WAA+B;AACvC,SAAQ,UAAuC;AAC/C,SAAQ,SAAS;AAAA,EAKd;AAAA,EAEH,MAAa,YACX,MACA,WACY;AACZ,UAAM,WAAW,MAAM,KAAK,YAAY;AACxC,UAAM,oBAAoB,SAAS,YAAY,KAAK,WAAW,IAAI;AACnE,UAAM,aAAa,mBAAmB,iBAAiB;AACvD,UAAM,cAAc,IAAI;AAAA,MACtB,kBAAkB,YAAY,KAAK,SAAS;AAAA,IAC9C;AAEA,QAAI;AACJ,QAAI;AACF,eAAS,MAAM,UAAU,WAAW;AAAA,IACtC,SAAS,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AO;AAAA,EAClE;AAAA,EAEA,MAAM,kBAA0C;AAC9C,WAAO,iBAAiB,MAAM,KAAK,UAAU,CAAC;AAAA,EAChD;AAAA,EAEA,MAAM,eAAuC;AAC3C,UAAM,UAAU,MAAM,KAAK,gBAAgB;AAC3C,QAAI,CAAC,QAAS,QAAO;AACrB,UAAM,OAAO,MAAM,KAAK,SAAS,OAAO;AACxC,QAAI,CAAC,KAAM,QAAO;AAClB,WAAO,IAAI,YAAY,EAAE,OAAO,IAAI;AAAA,EACtC;AAAA,EAEA,MAAM,cAAc,UAAkB,UAAkC;AACtE,UAAM,OAAO,YAAY;AACzB,UAAM,OAAO,IAAI,YAAY,EAAE,OAAO,QAAQ;AAC9C,UAAM,KAAK,UAAU,MAAM,MAAM,eAAe;AAAA,EAClD;AAAA;AAAA,EAGA,MAAM,UAAyB;AAC7B,UAAM,KAAK,SAAS,QAAQ;AAAA,EAC9B;AACF;","names":["missingParents","next","candidate"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/document/document-session.ts","../src/document/filesystem-target.ts","../src/document/recovery-journal.ts"],"sourcesContent":["import type {\n DocumentCommitTarget,\n DocumentConflictStrategy,\n DocumentExternalChangeResult,\n DocumentExternalSnapshot,\n DocumentSaveReason,\n DocumentSessionConflict,\n DocumentSessionEditScope,\n DocumentSessionLifecycle,\n DocumentSessionOptions,\n DocumentSessionSnapshot,\n DocumentSessionStatus,\n DocumentSessionTransition,\n} from './types.js';\nimport { isFileSystemMoveStateError } from '../filesystem/move-error.js';\nimport type { DocumentRecoveryJournal } from './recovery-journal.js';\n\ntype SessionListener = () => void;\n\nconst DEFAULT_AUTO_SAVE_RETRY_DELAYS_MS = [1_000, 3_000, 10_000] as const;\n\n/**\n * Raised by a commit target when optimistic external-change verification\n * fails. The session converts it into durable conflict state.\n */\nexport class DocumentCommitConflictError extends Error {\n public readonly externalContent: string | null;\n public readonly externalVersion: string | number | null;\n\n public constructor(\n message: string,\n externalContent: string | null,\n externalVersion: string | number | null = null,\n ) {\n super(message);\n this.name = 'DocumentCommitConflictError';\n this.externalContent = externalContent;\n this.externalVersion = externalVersion;\n }\n}\n\nexport class DocumentSessionConflictError extends Error {\n public readonly conflict: DocumentSessionConflict;\n\n public constructor(conflict: DocumentSessionConflict) {\n super('The document changed outside DocBlocks while local edits were pending.');\n this.name = 'DocumentSessionConflictError';\n this.conflict = conflict;\n }\n}\n\n/**\n * A revisioned, serialized persistence boundary for one active document.\n *\n * Invariants:\n * - only drain() calls target.commit();\n * - at most one commit is in flight;\n * - revisions never decrease, including across target transitions;\n * - destructive operations wait for an in-flight commit and run last;\n * - a target is never changed by a React effect cleanup.\n */\nexport class DocumentSession {\n private readonly autoSaveDelayMs: number;\n private readonly autoSaveRetryDelaysMs: readonly number[];\n private readonly recoveryJournal: DocumentRecoveryJournal | null;\n private readonly listeners = new Set<SessionListener>();\n private autoSaveEnabled: boolean;\n\n private target: DocumentCommitTarget | null = null;\n private content = '';\n private persistedContent: string | null = null;\n private revision = 0;\n private persistedRevision = 0;\n private savingRevision: number | null = null;\n private savingContent: string | null = null;\n private generation = 0;\n private externalSequence = -1;\n private lifecycle: DocumentSessionLifecycle = 'open';\n private frozen = false;\n private error: Error | null = null;\n private conflict: DocumentSessionConflict | null = null;\n\n private autoSaveTimer: ReturnType<typeof setTimeout> | null = null;\n private autoSaveRetryAttempt = 0;\n private drainPromise: Promise<void> | null = null;\n private haltDrain = false;\n private operationTail: Promise<void> = Promise.resolve();\n private snapshot: DocumentSessionSnapshot;\n\n public constructor(options: DocumentSessionOptions = {}) {\n this.autoSaveDelayMs = Math.max(0, options.autoSaveDelayMs ?? 500);\n this.autoSaveEnabled = options.autoSaveEnabled ?? true;\n this.autoSaveRetryDelaysMs = normalizeRetryDelays(\n options.autoSaveRetryDelaysMs ?? DEFAULT_AUTO_SAVE_RETRY_DELAYS_MS,\n );\n this.recoveryJournal = options.recoveryJournal ?? null;\n this.snapshot = this.createSnapshot();\n }\n\n public readonly subscribe = (listener: SessionListener): (() => void) => {\n this.listeners.add(listener);\n return () => this.listeners.delete(listener);\n };\n\n public readonly getSnapshot = (): DocumentSessionSnapshot => this.snapshot;\n\n /** Enable or disable automatic persistence without weakening explicit or lifecycle flushes. */\n public setAutoSaveEnabled(enabled: boolean): void {\n if (this.autoSaveEnabled === enabled) return;\n this.autoSaveEnabled = enabled;\n if (!enabled) {\n this.clearAutoSaveTimer();\n return;\n }\n if (\n this.target &&\n this.lifecycle === 'open' &&\n !this.frozen &&\n !this.conflict &&\n this.persistedRevision < this.revision\n ) {\n this.scheduleAutoSave();\n }\n }\n\n /**\n * Record a complete local snapshot and schedule its persistence.\n * Returns the assigned monotonic revision.\n */\n public edit(content: string, scope: DocumentSessionEditScope): number {\n if (!this.target || this.lifecycle !== 'open' || this.frozen) {\n throw new Error('Cannot edit a document session that is not open.');\n }\n if (scope.targetKey !== this.target.key || scope.generation !== this.generation) {\n throw new Error('Cannot apply an edit from an obsolete document instance.');\n }\n if (content === this.content) return this.revision;\n\n this.content = content;\n this.revision += 1;\n this.error = null;\n this.autoSaveRetryAttempt = 0;\n if (this.conflict) {\n this.conflict = {\n ...this.conflict,\n localContent: content,\n localRevision: this.revision,\n };\n }\n this.writeRecoverySnapshot();\n if (!this.conflict) this.scheduleAutoSave();\n this.emit();\n return this.revision;\n }\n\n /**\n * Persist the revision current when flush() is called. A later edit may\n * advance the session again, but commits remain strictly serialized.\n */\n public async flush(reason: DocumentSaveReason = 'manual'): Promise<DocumentSessionSnapshot> {\n this.clearAutoSaveTimer();\n if (!this.target) return this.snapshot;\n if (this.conflict) throw new DocumentSessionConflictError(this.conflict);\n\n const requiredRevision = this.revision;\n while (this.target && this.persistedRevision < requiredRevision) {\n if (this.conflict) throw new DocumentSessionConflictError(this.conflict);\n if (this.haltDrain) {\n throw new Error('Document persistence was cancelled before the requested revision saved.');\n }\n try {\n await this.ensureDrain(reason);\n } catch (error: unknown) {\n if (this.conflict) throw new DocumentSessionConflictError(this.conflict);\n throw error;\n }\n }\n\n if (this.conflict) throw new DocumentSessionConflictError(this.conflict);\n if (this.persistedRevision < requiredRevision) {\n throw new Error('The document target closed before the requested revision saved.');\n }\n return this.snapshot;\n }\n\n /**\n * Flush the old document, then replace it with a new clean baseline.\n * UI state should change only after this promise resolves.\n */\n public transitionTo(\n target: DocumentCommitTarget | null,\n content: string,\n ): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(() =>\n this.performTransition(async () => ({ target, content })).then((snapshot) => {\n if (!snapshot) throw new Error('A fixed document transition cannot be cancelled.');\n return snapshot;\n }),\n );\n }\n\n /**\n * Freeze and flush the current document before reading the next one. The\n * loader may return null when a navigation request was superseded, leaving\n * the current target active and clean.\n */\n public transitionWithLoad(\n load: () => Promise<DocumentSessionTransition | null>,\n ): Promise<DocumentSessionSnapshot | null> {\n return this.enqueueOperation(() => this.performTransition(load));\n }\n\n /**\n * Flush the current path, run the storage move, and only then swap the\n * commit target. No edit can enter between those steps.\n */\n public retarget(\n nextTarget: DocumentCommitTarget,\n moveStorage: () => Promise<void>,\n ): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(async () => {\n this.assertNotPreparingClose();\n if (!this.target) throw new Error('Cannot retarget a session without a document.');\n\n this.lifecycle = 'transitioning';\n this.frozen = true;\n this.emit();\n try {\n this.haltDrain = false;\n await this.flush('transition');\n await moveStorage();\n this.generation += 1;\n this.externalSequence = -1;\n this.target = nextTarget;\n this.error = null;\n this.conflict = null;\n this.lifecycle = 'open';\n this.frozen = false;\n this.emit();\n return this.snapshot;\n } catch (error: unknown) {\n if (isFileSystemMoveStateError(error)) {\n if (error.documentLocation === 'destination') {\n this.generation += 1;\n this.externalSequence = -1;\n this.target = nextTarget;\n }\n this.haltDrain = true;\n this.error = error;\n this.lifecycle = 'open';\n // The provider could not establish one authoritative compound move.\n // Keep editing frozen until navigation/recovery chooses a real path.\n this.frozen = true;\n this.emit();\n throw error;\n }\n this.lifecycle = 'open';\n this.frozen = false;\n this.emit();\n throw error;\n }\n });\n }\n\n /**\n * Cancel queued writes, wait for an already-running write, then delete.\n * The deletion is therefore the final storage operation for this target.\n */\n public delete(deleteStorage: () => Promise<void>): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(async () => {\n this.assertNotPreparingClose();\n this.lifecycle = 'transitioning';\n this.frozen = true;\n this.haltDrain = true;\n this.clearAutoSaveTimer();\n this.emit();\n\n await this.awaitActiveDrain();\n try {\n await deleteStorage();\n } catch (error: unknown) {\n this.haltDrain = false;\n this.lifecycle = 'open';\n this.frozen = false;\n if (this.target && this.persistedRevision < this.revision && !this.conflict) {\n this.scheduleAutoSave();\n }\n this.emit();\n throw error;\n }\n\n this.discardRecoverySnapshot();\n this.detach();\n return this.snapshot;\n });\n }\n\n /**\n * Discard queued changes and detach without mutating storage. This is used\n * for explicitly abandoned sessions, never as an implicit effect cleanup.\n */\n public cancel(): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(async () => {\n this.lifecycle = 'transitioning';\n this.frozen = true;\n this.haltDrain = true;\n this.clearAutoSaveTimer();\n this.emit();\n await this.awaitActiveDrain();\n this.discardRecoverySnapshot();\n this.detach();\n return this.snapshot;\n });\n }\n\n /**\n * Observe a filesystem/host change captured for targetKey. Clean sessions\n * adopt it. Dirty or saving sessions preserve local text and enter conflict.\n */\n public observeExternal(change: DocumentExternalSnapshot): DocumentExternalChangeResult {\n if (!this.target || change.targetKey !== this.target.key || this.lifecycle === 'closed') {\n return 'ignored';\n }\n if (change.sequence !== undefined) {\n if (!Number.isSafeInteger(change.sequence) || change.sequence <= this.externalSequence) {\n return 'ignored';\n }\n this.externalSequence = change.sequence;\n }\n\n // While conflicted, a current observation equal to the latest local\n // snapshot proves that revision durable without requiring another write.\n // Never acknowledge while a commit is still running; its eventual result\n // remains authoritative for the serialized drain.\n if (\n this.conflict &&\n change.content === this.content &&\n this.savingRevision === null &&\n this.lifecycle === 'open'\n ) {\n this.clearAutoSaveTimer();\n this.autoSaveRetryAttempt = 0;\n this.persistedRevision = this.revision;\n this.persistedContent = this.content;\n this.haltDrain = false;\n this.error = null;\n this.conflict = null;\n this.discardRecoverySnapshot();\n this.emit();\n return 'applied';\n }\n\n // Once a conflict exists, every later accepted observation refreshes its\n // external branch before ordinary duplicate suppression. In particular,\n // A -> local C -> external B -> external A must offer A, not stale B, when\n // the user chooses Reload external.\n if (this.conflict) {\n const externalVersion = change.version ?? null;\n if (\n this.conflict.localContent === this.content &&\n this.conflict.localRevision === this.revision &&\n this.conflict.externalContent === change.content &&\n this.conflict.externalVersion === externalVersion\n ) {\n return 'ignored';\n }\n\n this.clearAutoSaveTimer();\n this.haltDrain = true;\n this.conflict = {\n targetKey: change.targetKey,\n localContent: this.content,\n localRevision: this.revision,\n externalContent: change.content,\n externalVersion,\n };\n this.error = null;\n this.writeRecoverySnapshot();\n this.emit();\n return 'conflict';\n }\n\n if (\n change.content === this.content ||\n change.content === this.persistedContent ||\n (this.savingRevision !== null && change.content === this.savingContent)\n ) {\n return 'ignored';\n }\n\n const isClean =\n this.persistedRevision === this.revision &&\n this.savingRevision === null &&\n this.error === null &&\n this.conflict === null;\n\n if (isClean && change.content !== null) {\n this.content = change.content;\n this.revision += 1;\n this.persistedRevision = this.revision;\n this.persistedContent = change.content;\n this.generation += 1;\n this.discardRecoverySnapshot();\n this.emit();\n return 'applied';\n }\n\n this.clearAutoSaveTimer();\n this.haltDrain = true;\n this.conflict = {\n targetKey: change.targetKey,\n localContent: this.content,\n localRevision: this.revision,\n externalContent: change.content,\n externalVersion: change.version ?? null,\n };\n this.error = null;\n this.writeRecoverySnapshot();\n this.emit();\n return 'conflict';\n }\n\n public resolveConflict(strategy: DocumentConflictStrategy): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(async () => {\n if (!this.conflict) return this.snapshot;\n\n this.clearAutoSaveTimer();\n this.haltDrain = true;\n await this.awaitActiveDrain();\n // A watcher may refresh or converge the conflict while an in-flight\n // commit settles. Resolve the branch that is current now, never the\n // snapshot captured before the await.\n const currentConflict = this.conflict;\n if (!currentConflict) return this.snapshot;\n\n if (strategy === 'use-external') {\n this.discardRecoverySnapshot();\n this.generation += 1;\n this.revision += 1;\n this.conflict = null;\n this.error = null;\n this.haltDrain = false;\n\n if (currentConflict.externalContent === null) {\n this.target = null;\n this.content = '';\n this.persistedContent = null;\n this.persistedRevision = this.revision;\n this.lifecycle = 'closed';\n this.frozen = true;\n } else {\n this.content = currentConflict.externalContent;\n this.persistedContent = currentConflict.externalContent;\n this.persistedRevision = this.revision;\n this.lifecycle = 'open';\n this.frozen = false;\n }\n this.emit();\n return this.snapshot;\n }\n\n // Keep the local branch, but make the observed external snapshot the\n // optimistic baseline for the next conditional commit.\n this.persistedContent = currentConflict.externalContent;\n // A clean external deletion/conflict has no unsaved local revision.\n // Keeping local still requires a fresh commit that recreates/overwrites\n // the target, so make that intent explicit with a new revision.\n this.revision += 1;\n this.conflict = null;\n this.error = null;\n this.haltDrain = false;\n this.lifecycle = 'open';\n this.frozen = false;\n this.writeRecoverySnapshot();\n this.emit();\n return this.flush('conflict');\n });\n }\n\n /**\n * Freeze edits and flush through the latest revision. A successful call\n * remains frozen until cancelClose(); the owning host may now destroy it.\n */\n public prepareClose(): Promise<DocumentSessionSnapshot> {\n return this.enqueueOperation(async () => {\n if (this.lifecycle === 'closing') return this.snapshot;\n this.lifecycle = 'closing';\n this.frozen = true;\n this.haltDrain = false;\n this.emit();\n try {\n await this.flush('close');\n return this.snapshot;\n } catch (error: unknown) {\n this.lifecycle = 'open';\n this.frozen = false;\n this.emit();\n throw error;\n }\n });\n }\n\n /** Resume editing when a host cancels a prepared close. */\n public cancelClose(): void {\n if (this.lifecycle !== 'closing') return;\n this.lifecycle = 'open';\n this.frozen = false;\n this.haltDrain = false;\n if (this.target && this.persistedRevision < this.revision && !this.conflict) {\n this.scheduleAutoSave();\n }\n this.emit();\n }\n\n private async performTransition(\n load: () => Promise<DocumentSessionTransition | null>,\n ): Promise<DocumentSessionSnapshot | null> {\n this.assertNotPreparingClose();\n this.lifecycle = 'transitioning';\n this.frozen = true;\n this.emit();\n\n try {\n this.haltDrain = false;\n await this.flush('transition');\n this.clearAutoSaveTimer();\n const next = await load();\n if (!next) {\n this.lifecycle = 'open';\n this.frozen = false;\n this.emit();\n return null;\n }\n\n this.generation += 1;\n this.externalSequence = -1;\n this.target = next.target;\n this.content = next.content;\n this.revision += 1;\n this.persistedRevision = this.revision;\n this.persistedContent = next.target ? next.content : null;\n this.savingRevision = null;\n this.savingContent = null;\n this.error = null;\n this.conflict = null;\n this.haltDrain = false;\n this.lifecycle = 'open';\n this.frozen = false;\n const recoveryState = this.restoreRecoverySnapshot();\n if (recoveryState === 'dirty') this.scheduleAutoSave();\n this.emit();\n return this.snapshot;\n } catch (error: unknown) {\n this.lifecycle = 'open';\n this.frozen = false;\n this.emit();\n throw error;\n }\n }\n\n private scheduleAutoSave(delayMs = this.autoSaveDelayMs): void {\n this.clearAutoSaveTimer();\n if (!this.autoSaveEnabled) return;\n this.autoSaveTimer = setTimeout(() => {\n this.autoSaveTimer = null;\n const target = this.target;\n const generation = this.generation;\n void this.flush('autosave').then(\n () => {\n this.autoSaveRetryAttempt = 0;\n },\n () => {\n // Preserve honest error/conflict state while making ordinary I/O\n // failures recoverable. A newer edit already owns a fresh debounce\n // timer, and lifecycle operations cancel this retry path.\n if (\n this.autoSaveTimer !== null ||\n !target ||\n target !== this.target ||\n generation !== this.generation ||\n this.lifecycle !== 'open' ||\n this.frozen ||\n this.haltDrain ||\n this.conflict ||\n this.persistedRevision >= this.revision\n ) {\n return;\n }\n const retryDelay = this.autoSaveRetryDelaysMs[this.autoSaveRetryAttempt];\n if (retryDelay === undefined) return;\n this.autoSaveRetryAttempt += 1;\n this.scheduleAutoSave(retryDelay);\n },\n );\n }, delayMs);\n }\n\n private clearAutoSaveTimer(): void {\n if (this.autoSaveTimer === null) return;\n clearTimeout(this.autoSaveTimer);\n this.autoSaveTimer = null;\n }\n\n private ensureDrain(reason: DocumentSaveReason): Promise<void> {\n if (this.drainPromise) return this.drainPromise;\n const running = this.drain(reason);\n this.drainPromise = running;\n const clear = () => {\n if (this.drainPromise === running) this.drainPromise = null;\n };\n void running.then(clear, clear);\n return running;\n }\n\n private async drain(reason: DocumentSaveReason): Promise<void> {\n while (\n this.target &&\n !this.haltDrain &&\n !this.conflict &&\n this.persistedRevision < this.revision\n ) {\n const target = this.target;\n const generation = this.generation;\n const saveRevision = this.revision;\n const saveContent = this.content;\n const previousPersistedRevision = this.persistedRevision;\n const previousPersistedContent = this.persistedContent;\n\n this.savingRevision = saveRevision;\n this.savingContent = saveContent;\n this.error = null;\n this.emit();\n\n try {\n await target.commit({\n targetKey: target.key,\n content: saveContent,\n revision: saveRevision,\n persistedRevision: previousPersistedRevision,\n persistedContent: previousPersistedContent,\n reason,\n });\n } catch (error: unknown) {\n this.savingRevision = null;\n this.savingContent = null;\n if (error instanceof DocumentCommitConflictError) {\n this.haltDrain = true;\n this.conflict = {\n targetKey: target.key,\n localContent: this.content,\n localRevision: this.revision,\n externalContent: error.externalContent,\n externalVersion: error.externalVersion,\n };\n this.error = null;\n } else {\n this.error = toError(error);\n }\n this.emit();\n throw error;\n }\n\n if (generation !== this.generation || target !== this.target) return;\n this.persistedRevision = Math.max(this.persistedRevision, saveRevision);\n this.persistedContent = saveContent;\n this.autoSaveRetryAttempt = 0;\n this.savingRevision = null;\n this.savingContent = null;\n this.error = null;\n const activeConflict = this.getSnapshot().conflict;\n if (activeConflict?.externalContent === saveContent && this.content === saveContent) {\n // An observation that matched the in-flight local snapshot could not\n // be acknowledged until the commit settled. Its successful return now\n // proves both branches converged on the same durable revision.\n this.conflict = null;\n this.haltDrain = false;\n }\n this.recoveryJournal?.acknowledge({\n targetKey: target.key,\n generation,\n persistedRevision: this.persistedRevision,\n });\n this.emit();\n }\n }\n\n private async awaitActiveDrain(): Promise<void> {\n const active = this.drainPromise;\n if (!active) return;\n try {\n await active;\n } catch {\n // A destructive cancellation still waits for the operation to settle,\n // but a failed obsolete write must not prevent the requested deletion.\n }\n }\n\n /**\n * Rehydrate a synchronous crash snapshot after the durable baseline has\n * been read. A matching baseline is safe to resume as dirty; a changed\n * baseline becomes an explicit conflict and is never auto-overwritten.\n */\n private restoreRecoverySnapshot(): 'none' | 'dirty' | 'conflict' {\n if (!this.target || !this.recoveryJournal) return 'none';\n const recovered = this.recoveryJournal.lookup(this.target.key);\n if (!recovered) return 'none';\n\n if (recovered.content === this.content) {\n this.recoveryJournal.acknowledge({\n targetKey: recovered.targetKey,\n generation: recovered.generation,\n persistedRevision: recovered.revision,\n });\n return 'none';\n }\n\n const externalContent = this.content;\n this.generation = Math.max(this.generation, recovered.generation) + 1;\n this.revision = Math.max(this.revision, recovered.revision) + 1;\n this.content = recovered.content;\n\n if (recovered.persistedContent === externalContent) {\n this.writeRecoverySnapshot();\n return 'dirty';\n }\n\n // Preserve the journal's prior baseline so a second crash continues to\n // reopen as a conflict until the user explicitly chooses a branch.\n this.persistedContent = recovered.persistedContent;\n this.haltDrain = true;\n this.conflict = {\n targetKey: this.target.key,\n localContent: recovered.content,\n localRevision: this.revision,\n externalContent,\n externalVersion: null,\n };\n this.writeRecoverySnapshot();\n return 'conflict';\n }\n\n private writeRecoverySnapshot(): void {\n if (!this.target || !this.recoveryJournal) return;\n if (this.persistedRevision >= this.revision && !this.conflict) return;\n this.recoveryJournal.write({\n targetKey: this.target.key,\n generation: this.generation,\n revision: this.revision,\n content: this.content,\n persistedContent: this.persistedContent,\n });\n }\n\n private discardRecoverySnapshot(): void {\n if (!this.target) return;\n this.recoveryJournal?.discard(this.target.key);\n }\n\n private detach(): void {\n this.clearAutoSaveTimer();\n this.autoSaveRetryAttempt = 0;\n this.generation += 1;\n this.externalSequence = -1;\n this.target = null;\n this.persistedContent = null;\n this.savingRevision = null;\n this.savingContent = null;\n this.error = null;\n this.conflict = null;\n this.haltDrain = false;\n this.lifecycle = 'closed';\n this.frozen = true;\n this.emit();\n }\n\n private assertNotPreparingClose(): void {\n if (this.lifecycle === 'closing') {\n throw new Error('The document is already prepared for close.');\n }\n }\n\n private enqueueOperation<T>(operation: () => Promise<T>): Promise<T> {\n const run = this.operationTail.then(operation, operation);\n this.operationTail = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n private createSnapshot(): DocumentSessionSnapshot {\n return Object.freeze({\n targetKey: this.target?.key ?? null,\n content: this.content,\n revision: this.revision,\n persistedRevision: this.persistedRevision,\n persistedContent: this.persistedContent,\n savingRevision: this.savingRevision,\n generation: this.generation,\n status: this.computeStatus(),\n lifecycle: this.lifecycle,\n frozen: this.frozen,\n error: this.error,\n conflict: this.conflict,\n });\n }\n\n private computeStatus(): DocumentSessionStatus {\n if (this.lifecycle === 'closed') return 'closed';\n if (!this.target) return 'idle';\n if (this.conflict) return 'conflict';\n if (this.error) return 'error';\n if (this.savingRevision !== null) return 'saving';\n return this.persistedRevision < this.revision ? 'dirty' : 'saved';\n }\n\n private emit(): void {\n this.snapshot = this.createSnapshot();\n for (const listener of [...this.listeners]) listener();\n }\n}\n\nfunction toError(error: unknown): Error {\n return error instanceof Error ? error : new Error(String(error));\n}\n\nfunction normalizeRetryDelays(delays: readonly number[]): readonly number[] {\n return delays.map((delay) => {\n if (!Number.isFinite(delay) || delay < 0) {\n throw new TypeError('Autosave retry delays must be finite, non-negative numbers.');\n }\n return Math.floor(delay);\n });\n}\n","import { getFileSystemProviderV2, type FileSystemProvider } from '../filesystem/types.js';\nimport { FsError } from '../filesystem/fs-error.js';\nimport { parseWorkspacePath } from '../filesystem/workspace-path.js';\nimport { DocumentCommitConflictError } from './document-session.js';\nimport type { DocumentCommitTarget, DocumentExternalVersion } from './types.js';\n\nexport interface FileSystemDocumentTargetOptions {\n /**\n * Compare the current file with the session's persisted baseline before\n * replacing it. Enabled by default.\n */\n verifyExternalChanges?: boolean;\n onCommitted?: (content: string, revision: number) => void;\n}\n\n/**\n * Adapt a FileSystemProvider path to the commit protocol used by\n * DocumentSession. The optimistic read catches external edits/deletions\n * before a local write recreates or silently replaces them.\n */\nexport function createFileSystemDocumentTarget(\n provider: FileSystemProvider,\n path: string,\n options: FileSystemDocumentTargetOptions = {},\n): DocumentCommitTarget {\n const verifyExternalChanges = options.verifyExternalChanges ?? true;\n const canonicalPath = parseWorkspacePath(path);\n const providerV2 = getFileSystemProviderV2(provider);\n return {\n key: provider.id + ':' + canonicalPath,\n async commit(request) {\n if (providerV2 && providerV2.capabilities.conditionalWrite !== 'none') {\n const current = await providerV2.readFile(canonicalPath);\n const currentContent = current ? new TextDecoder().decode(current.data) : null;\n if (currentContent !== request.persistedContent && currentContent !== request.content) {\n throw new DocumentCommitConflictError(\n 'The document changed outside DocBlocks: ' + path,\n currentContent,\n current?.entry.version ?? null,\n );\n }\n if (currentContent === request.content) {\n options.onCommitted?.(request.content, request.revision);\n return { version: current?.entry.version ?? null };\n }\n\n try {\n const committed = await providerV2.writeFile(\n canonicalPath,\n new TextEncoder().encode(request.content),\n {\n mode: current ? 'replace' : 'create',\n createParents: true,\n expectedVersion: current?.entry.version ?? null,\n },\n );\n options.onCommitted?.(request.content, request.revision);\n return { version: committed.version };\n } catch (error: unknown) {\n if (\n error instanceof FsError &&\n (error.code === 'conflict' ||\n error.code === 'already-exists' ||\n error.code === 'not-found')\n ) {\n const external = await providerV2.readFile(canonicalPath);\n throw new DocumentCommitConflictError(\n 'The document changed outside DocBlocks: ' + path,\n external ? new TextDecoder().decode(external.data) : null,\n external?.entry.version ?? null,\n );\n }\n throw error;\n }\n }\n\n if (provider.commitFile) {\n const result = await provider.commitFile(path, request.content, request.persistedContent);\n if (result.status === 'conflict') {\n throw new DocumentCommitConflictError(\n 'The document changed outside DocBlocks: ' + path,\n result.content,\n result.version,\n );\n }\n options.onCommitted?.(request.content, request.revision);\n return { version: result.version };\n }\n\n if (verifyExternalChanges) {\n const current = await provider.readFile(path);\n if (current !== request.persistedContent && current !== request.content) {\n const meta = await provider.stat(path).catch(() => null);\n const version: DocumentExternalVersion = meta?.lastModified ?? null;\n throw new DocumentCommitConflictError(\n 'The document changed outside DocBlocks: ' + path,\n current,\n version,\n );\n }\n }\n\n await provider.writeFile(path, request.content);\n options.onCommitted?.(request.content, request.revision);\n const meta = await provider.stat(path).catch(() => null);\n return { version: meta?.lastModified ?? null };\n },\n };\n}\n","/**\n * Synchronous crash-recovery journal for dirty document snapshots.\n *\n * The journal deliberately depends on a tiny injected Storage-like contract\n * instead of reading `window.localStorage` at module load time. This keeps the\n * document package usable in Node, Electron main, VS Code extension hosts, and\n * tests while allowing browser renderers to use localStorage for a best-effort\n * write that completes before the current JavaScript turn ends.\n */\n\nexport const DOCUMENT_RECOVERY_JOURNAL_STORAGE_KEY = 'docblocks:document-recovery:v1';\nexport const DOCUMENT_RECOVERY_JOURNAL_SCHEMA_VERSION = 1;\n\nexport interface DocumentRecoveryStorage {\n getItem(key: string): string | null;\n setItem(key: string, value: string): void;\n removeItem(key: string): void;\n}\n\nexport interface DocumentRecoveryRecord {\n /** Stable commit-target key, including the workspace/provider scope. */\n targetKey: string;\n /** DocumentSession generation that produced this snapshot. */\n generation: number;\n /** Monotonic DocumentSession revision represented by `content`. */\n revision: number;\n /** Complete markdown snapshot. */\n content: string;\n /**\n * Content last acknowledged by the commit target when this draft was made.\n * Recovery may be applied automatically only when storage still matches this\n * baseline; otherwise the caller must surface an external-change conflict.\n */\n persistedContent: string | null;\n /** Time the dirty record for this target was first created. */\n createdAt: number;\n /** Time the record was most recently replaced. */\n updatedAt: number;\n}\n\nexport interface DocumentRecoveryWrite {\n targetKey: string;\n generation: number;\n revision: number;\n content: string;\n persistedContent: string | null;\n}\n\nexport interface DocumentRecoveryAcknowledgement {\n targetKey: string;\n generation: number;\n /** Highest revision durably acknowledged by the commit target. */\n persistedRevision: number;\n}\n\nexport type DocumentRecoveryWriteFailure =\n | 'invalid-record'\n | 'record-too-large'\n | 'storage-unavailable'\n | 'quota-exceeded';\n\nexport type DocumentRecoveryWriteResult =\n | { status: 'stored'; evicted: number }\n | { status: 'unchanged'; evicted: 0 }\n | { status: 'ignored-stale'; evicted: 0 }\n | { status: 'rejected'; reason: DocumentRecoveryWriteFailure; evicted: number };\n\nexport interface DocumentRecoveryJournalOptions {\n storageKey?: string;\n /** Maximum number of document records retained. Defaults to 20. */\n maxEntries?: number;\n /** Conservative UTF-16 estimate for the whole serialized journal. */\n maxStorageBytes?: number;\n /** Conservative UTF-16 estimate for one serialized record. */\n maxRecordBytes?: number;\n /** Records older than this are discarded while reading. Defaults to 7 days. */\n maxAgeMs?: number;\n /** Tolerated clock skew for records dated in the future. Defaults to 5 minutes. */\n maxFutureSkewMs?: number;\n /** Injected for deterministic tests. */\n now?: () => number;\n}\n\ninterface DocumentRecoveryEnvelope {\n schemaVersion: typeof DOCUMENT_RECOVERY_JOURNAL_SCHEMA_VERSION;\n records: DocumentRecoveryRecord[];\n}\n\ninterface LoadedRecords {\n records: DocumentRecoveryRecord[];\n needsRepair: boolean;\n}\n\ninterface PersistResult {\n stored: boolean;\n evicted: number;\n reason?: 'storage-unavailable' | 'quota-exceeded';\n}\n\nconst DEFAULT_MAX_ENTRIES = 20;\nconst DEFAULT_MAX_STORAGE_BYTES = 2_000_000;\nconst DEFAULT_MAX_RECORD_BYTES = 1_000_000;\nconst DEFAULT_MAX_AGE_MS = 7 * 24 * 60 * 60 * 1000;\nconst DEFAULT_MAX_FUTURE_SKEW_MS = 5 * 60 * 1000;\nconst MAX_TARGET_KEY_LENGTH = 4096;\n\n/**\n * Best-effort, synchronous recovery storage.\n *\n * Normal save acknowledgement is the only automatic path that removes the\n * current record. Explicit discard, age expiry, corruption repair, and bounded\n * eviction are intentional exceptions: callers can discard after the user\n * rejects recovery, and the journal must never grow without limit.\n */\nexport class DocumentRecoveryJournal {\n private readonly storage: DocumentRecoveryStorage | null;\n private readonly storageKey: string;\n private readonly maxEntries: number;\n private readonly maxStorageBytes: number;\n private readonly maxRecordBytes: number;\n private readonly maxAgeMs: number;\n private readonly maxFutureSkewMs: number;\n private readonly now: () => number;\n\n public constructor(\n storage: DocumentRecoveryStorage | null,\n options: DocumentRecoveryJournalOptions = {},\n ) {\n this.storage = storage;\n this.storageKey = options.storageKey?.trim() || DOCUMENT_RECOVERY_JOURNAL_STORAGE_KEY;\n this.maxEntries = positiveInteger(options.maxEntries, DEFAULT_MAX_ENTRIES);\n this.maxStorageBytes = positiveInteger(options.maxStorageBytes, DEFAULT_MAX_STORAGE_BYTES);\n this.maxRecordBytes = Math.min(\n positiveInteger(options.maxRecordBytes, DEFAULT_MAX_RECORD_BYTES),\n this.maxStorageBytes,\n );\n this.maxAgeMs = nonNegativeFinite(options.maxAgeMs, DEFAULT_MAX_AGE_MS);\n this.maxFutureSkewMs = nonNegativeFinite(options.maxFutureSkewMs, DEFAULT_MAX_FUTURE_SKEW_MS);\n this.now = options.now ?? Date.now;\n }\n\n /**\n * Synchronously persist the latest dirty snapshot for a target.\n * Storage/quota failures are returned, never thrown into an editor onChange.\n */\n public write(input: DocumentRecoveryWrite): DocumentRecoveryWriteResult {\n const timestamp = this.now();\n if (!isValidWrite(input) || !Number.isFinite(timestamp) || timestamp < 0) {\n return { status: 'rejected', reason: 'invalid-record', evicted: 0 };\n }\n if (!this.storage) {\n return { status: 'rejected', reason: 'storage-unavailable', evicted: 0 };\n }\n if (\n estimatedBytes(input.content) > this.maxRecordBytes ||\n (input.persistedContent !== null &&\n estimatedBytes(input.persistedContent) > this.maxRecordBytes)\n ) {\n return { status: 'rejected', reason: 'record-too-large', evicted: 0 };\n }\n\n const loaded = this.load(timestamp);\n const existing = loaded.records.find((record) => record.targetKey === input.targetKey);\n if (existing) {\n const ordering = compareGenerationRevision(input, existing);\n if (ordering < 0) return { status: 'ignored-stale', evicted: 0 };\n if (ordering === 0) {\n if (\n existing.content === input.content &&\n existing.persistedContent === input.persistedContent\n ) {\n return { status: 'unchanged', evicted: 0 };\n }\n // A revision is an immutable content snapshot. Reusing it for different\n // content would make acknowledgement and recovery ambiguous.\n return { status: 'rejected', reason: 'invalid-record', evicted: 0 };\n }\n }\n\n const candidate: DocumentRecoveryRecord = {\n targetKey: input.targetKey,\n generation: input.generation,\n revision: input.revision,\n content: input.content,\n persistedContent: input.persistedContent,\n createdAt: existing?.createdAt ?? timestamp,\n updatedAt: timestamp,\n };\n if (estimatedBytes(JSON.stringify(candidate)) > this.maxRecordBytes) {\n return { status: 'rejected', reason: 'record-too-large', evicted: 0 };\n }\n if (estimatedBytes(serializeEnvelope([candidate])) > this.maxStorageBytes) {\n return { status: 'rejected', reason: 'record-too-large', evicted: 0 };\n }\n\n const next = loaded.records.filter((record) => record.targetKey !== input.targetKey);\n next.push(candidate);\n const persisted = this.persistBounded(next, input.targetKey);\n if (!persisted.stored) {\n return {\n status: 'rejected',\n reason: persisted.reason ?? 'quota-exceeded',\n evicted: persisted.evicted,\n };\n }\n return { status: 'stored', evicted: persisted.evicted };\n }\n\n /** Return the recoverable snapshot for one target, if present and valid. */\n public lookup(targetKey: string, generation?: number): DocumentRecoveryRecord | null {\n if (!isValidTargetKey(targetKey) || !isOptionalGeneration(generation)) return null;\n const record = this.load(this.now()).records.find(\n (candidate) =>\n candidate.targetKey === targetKey &&\n (generation === undefined || candidate.generation === generation),\n );\n return record ? cloneRecord(record) : null;\n }\n\n /** List valid records, newest first. Optionally restrict to one target. */\n public list(targetKey?: string): DocumentRecoveryRecord[] {\n if (targetKey !== undefined && !isValidTargetKey(targetKey)) return [];\n return this.load(this.now())\n .records.filter((record) => targetKey === undefined || record.targetKey === targetKey)\n .sort(compareNewestFirst)\n .map(cloneRecord);\n }\n\n /**\n * Clear a record only when the same generation has durably acknowledged at\n * least the journaled revision. A stale acknowledgement cannot erase a newer\n * crash-recovery snapshot.\n */\n public acknowledge(input: DocumentRecoveryAcknowledgement): boolean {\n if (!isValidAcknowledgement(input) || !this.storage) return false;\n const records = this.load(this.now()).records;\n const record = records.find((candidate) => candidate.targetKey === input.targetKey);\n if (\n !record ||\n record.generation !== input.generation ||\n record.revision > input.persistedRevision\n ) {\n return false;\n }\n\n return this.persistExact(records.filter((candidate) => candidate !== record));\n }\n\n /** Explicitly discard recovery data after a user or lifecycle decision. */\n public discard(targetKey: string, generation?: number): boolean {\n if (!isValidTargetKey(targetKey) || !isOptionalGeneration(generation) || !this.storage) {\n return false;\n }\n const records = this.load(this.now()).records;\n const next = records.filter(\n (record) =>\n record.targetKey !== targetKey ||\n (generation !== undefined && record.generation !== generation),\n );\n if (next.length === records.length) return false;\n return this.persistExact(next);\n }\n\n private load(timestamp: number): LoadedRecords {\n if (!this.storage) return { records: [], needsRepair: false };\n\n let raw: string | null;\n try {\n raw = this.storage.getItem(this.storageKey);\n } catch {\n return { records: [], needsRepair: false };\n }\n if (raw === null) return { records: [], needsRepair: false };\n\n let parsed: unknown;\n try {\n parsed = JSON.parse(raw) as unknown;\n } catch {\n this.tryRemove();\n return { records: [], needsRepair: true };\n }\n if (!isEnvelope(parsed)) {\n this.tryRemove();\n return { records: [], needsRepair: true };\n }\n\n const byTarget = new Map<string, DocumentRecoveryRecord>();\n let needsRepair = estimatedBytes(raw) > this.maxStorageBytes;\n for (const candidate of parsed.records) {\n if (!isValidStoredRecord(candidate, timestamp, this.maxAgeMs, this.maxFutureSkewMs)) {\n needsRepair = true;\n continue;\n }\n if (estimatedBytes(JSON.stringify(candidate)) > this.maxRecordBytes) {\n needsRepair = true;\n continue;\n }\n const current = byTarget.get(candidate.targetKey);\n if (!current || compareStoredRecords(candidate, current) > 0) {\n if (current) needsRepair = true;\n byTarget.set(candidate.targetKey, cloneRecord(candidate));\n } else {\n needsRepair = true;\n }\n }\n\n const records = [...byTarget.values()].sort(compareNewestFirst);\n while (records.length > this.maxEntries) {\n records.pop();\n needsRepair = true;\n }\n while (\n records.length > 0 &&\n estimatedBytes(serializeEnvelope(records)) > this.maxStorageBytes\n ) {\n records.pop();\n needsRepair = true;\n }\n if (needsRepair) {\n // Best effort only. Read APIs must still return the validated in-memory\n // records even when storage is temporarily unavailable.\n this.persistBounded(records);\n }\n return { records, needsRepair };\n }\n\n private persistBounded(\n records: DocumentRecoveryRecord[],\n protectedTarget?: string,\n ): PersistResult {\n if (!this.storage) {\n return { stored: false, evicted: 0, reason: 'storage-unavailable' };\n }\n\n const next = [...records].sort(compareNewestFirst);\n let evicted = 0;\n while (next.length > this.maxEntries) {\n if (!evictOldest(next, protectedTarget)) break;\n evicted += 1;\n }\n\n let serialized = serializeEnvelope(next);\n while (estimatedBytes(serialized) > this.maxStorageBytes) {\n if (!evictOldest(next, protectedTarget)) {\n return { stored: false, evicted, reason: 'quota-exceeded' };\n }\n evicted += 1;\n serialized = serializeEnvelope(next);\n }\n\n for (;;) {\n try {\n this.storage.setItem(this.storageKey, serialized);\n return { stored: true, evicted };\n } catch {\n if (!evictOldest(next, protectedTarget)) {\n return { stored: false, evicted, reason: 'quota-exceeded' };\n }\n evicted += 1;\n serialized = serializeEnvelope(next);\n }\n }\n }\n\n private persistExact(records: DocumentRecoveryRecord[]): boolean {\n if (!this.storage) return false;\n if (records.length === 0) {\n try {\n this.storage.removeItem(this.storageKey);\n return true;\n } catch {\n return false;\n }\n }\n try {\n this.storage.setItem(this.storageKey, serializeEnvelope(records));\n return true;\n } catch {\n return false;\n }\n }\n\n private tryRemove(): void {\n try {\n this.storage?.removeItem(this.storageKey);\n } catch {\n // Recovery is best effort; a denied cleanup must not fail application startup.\n }\n }\n}\n\n/**\n * Resolve browser localStorage on demand. Importing this module never touches\n * browser globals, and access errors (sandboxing/security settings) yield null.\n */\nexport function getDefaultDocumentRecoveryStorage(): DocumentRecoveryStorage | null {\n try {\n const candidate = Reflect.get(globalThis, 'localStorage') as unknown;\n if (!isStorage(candidate)) return null;\n return candidate;\n } catch {\n return null;\n }\n}\n\nfunction serializeEnvelope(records: DocumentRecoveryRecord[]): string {\n const envelope: DocumentRecoveryEnvelope = {\n schemaVersion: DOCUMENT_RECOVERY_JOURNAL_SCHEMA_VERSION,\n records,\n };\n return JSON.stringify(envelope);\n}\n\n/** localStorage quotas are commonly measured from UTF-16 storage usage. */\nfunction estimatedBytes(value: string): number {\n return value.length * 2;\n}\n\nfunction positiveInteger(value: number | undefined, fallback: number): number {\n return Number.isSafeInteger(value) && (value ?? 0) > 0 ? (value as number) : fallback;\n}\n\nfunction nonNegativeFinite(value: number | undefined, fallback: number): number {\n return Number.isFinite(value) && (value ?? -1) >= 0 ? (value as number) : fallback;\n}\n\nfunction isEnvelope(value: unknown): value is DocumentRecoveryEnvelope {\n if (!isObject(value)) return false;\n return (\n value.schemaVersion === DOCUMENT_RECOVERY_JOURNAL_SCHEMA_VERSION && Array.isArray(value.records)\n );\n}\n\nfunction isValidStoredRecord(\n value: unknown,\n timestamp: number,\n maxAgeMs: number,\n maxFutureSkewMs: number,\n): value is DocumentRecoveryRecord {\n if (!isObject(value)) return false;\n if (\n !isValidTargetKey(value.targetKey) ||\n !isNonNegativeSafeInteger(value.generation) ||\n !isNonNegativeSafeInteger(value.revision) ||\n typeof value.content !== 'string' ||\n (value.persistedContent !== null && typeof value.persistedContent !== 'string') ||\n !isNonNegativeFiniteNumber(value.createdAt) ||\n !isNonNegativeFiniteNumber(value.updatedAt) ||\n value.createdAt > value.updatedAt\n ) {\n return false;\n }\n if (!Number.isFinite(timestamp) || timestamp < 0) return false;\n if (value.updatedAt > timestamp + maxFutureSkewMs) return false;\n return timestamp - value.updatedAt <= maxAgeMs;\n}\n\nfunction isValidWrite(value: DocumentRecoveryWrite): boolean {\n return (\n isValidTargetKey(value.targetKey) &&\n isNonNegativeSafeInteger(value.generation) &&\n isNonNegativeSafeInteger(value.revision) &&\n typeof value.content === 'string' &&\n (value.persistedContent === null || typeof value.persistedContent === 'string')\n );\n}\n\nfunction isValidAcknowledgement(value: DocumentRecoveryAcknowledgement): boolean {\n return (\n isValidTargetKey(value.targetKey) &&\n isNonNegativeSafeInteger(value.generation) &&\n isNonNegativeSafeInteger(value.persistedRevision)\n );\n}\n\nfunction isValidTargetKey(value: unknown): value is string {\n return typeof value === 'string' && value.length > 0 && value.length <= MAX_TARGET_KEY_LENGTH;\n}\n\nfunction isOptionalGeneration(value: number | undefined): boolean {\n return value === undefined || isNonNegativeSafeInteger(value);\n}\n\nfunction isNonNegativeSafeInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction isNonNegativeFiniteNumber(value: unknown): value is number {\n return typeof value === 'number' && Number.isFinite(value) && value >= 0;\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null;\n}\n\nfunction isStorage(value: unknown): value is DocumentRecoveryStorage {\n if (!isObject(value)) return false;\n return (\n typeof value.getItem === 'function' &&\n typeof value.setItem === 'function' &&\n typeof value.removeItem === 'function'\n );\n}\n\nfunction compareGenerationRevision(\n left: Pick<DocumentRecoveryRecord, 'generation' | 'revision'>,\n right: Pick<DocumentRecoveryRecord, 'generation' | 'revision'>,\n): number {\n if (left.generation !== right.generation) return left.generation - right.generation;\n return left.revision - right.revision;\n}\n\nfunction compareStoredRecords(left: DocumentRecoveryRecord, right: DocumentRecoveryRecord): number {\n return compareGenerationRevision(left, right) || left.updatedAt - right.updatedAt;\n}\n\nfunction compareNewestFirst(left: DocumentRecoveryRecord, right: DocumentRecoveryRecord): number {\n return right.updatedAt - left.updatedAt || right.revision - left.revision;\n}\n\nfunction cloneRecord(record: DocumentRecoveryRecord): DocumentRecoveryRecord {\n return { ...record };\n}\n\nfunction evictOldest(records: DocumentRecoveryRecord[], protectedTarget?: string): boolean {\n let oldestIndex = -1;\n for (let index = 0; index < records.length; index += 1) {\n if (records[index].targetKey === protectedTarget) continue;\n if (oldestIndex < 0 || compareNewestFirst(records[index], records[oldestIndex]) > 0) {\n oldestIndex = index;\n }\n }\n if (oldestIndex < 0) return false;\n records.splice(oldestIndex, 1);\n return true;\n}\n"],"mappings":";;;;;;;;;;;;AAmBA,IAAM,oCAAoC,CAAC,KAAO,KAAO,GAAM;AAMxD,IAAM,8BAAN,cAA0C,MAAM;AAAA,EAI9C,YACL,SACA,iBACA,kBAA0C,MAC1C;AACA,UAAM,OAAO;AACb,SAAK,OAAO;AACZ,SAA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