@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,3 +1,29 @@
1
- export { listWorkspaces, getWorkspace, saveWorkspace, removeWorkspace, touchWorkspace, ensureDefaultWorkspace, registerTransientWorkspace, getTransientWorkspace, unregisterTransientWorkspace, } from './workspace-manager.js';
2
- export { reconcileElectronWorkspaceDescriptors, } from './reconcile-electron.js';
1
+ import {
2
+ ensureDefaultWorkspace,
3
+ getTransientWorkspace,
4
+ getWorkspace,
5
+ listWorkspaces,
6
+ parsePersistedWorkspaceList,
7
+ reconcileElectronWorkspaceDescriptors,
8
+ registerTransientWorkspace,
9
+ removeWorkspace,
10
+ saveWorkspace,
11
+ touchWorkspace,
12
+ unregisterTransientWorkspace
13
+ } from "../chunk-P3DVZQ6S.js";
14
+ import "../chunk-RVPGQBWR.js";
15
+ import "../chunk-EZKJZUNJ.js";
16
+ export {
17
+ ensureDefaultWorkspace,
18
+ getTransientWorkspace,
19
+ getWorkspace,
20
+ listWorkspaces,
21
+ parsePersistedWorkspaceList,
22
+ reconcileElectronWorkspaceDescriptors,
23
+ registerTransientWorkspace,
24
+ removeWorkspace,
25
+ saveWorkspace,
26
+ touchWorkspace,
27
+ unregisterTransientWorkspace
28
+ };
3
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/workspace/index.ts"],"names":[],"mappings":"AAEA,OAAO,EACL,cAAc,EACd,YAAY,EACZ,aAAa,EACb,eAAe,EACf,cAAc,EACd,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,4BAA4B,GAC7B,MAAM,wBAAwB,CAAC;AAChC,OAAO,EACL,qCAAqC,GAEtC,MAAM,yBAAyB,CAAC"}
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bendyline/docblocks",
3
- "version": "2.0.0",
3
+ "version": "2.1.0",
4
4
  "description": "Core data structures and filesystem abstractions for DocBlocks",
5
5
  "license": "MIT",
6
6
  "author": "Bendyline",
@@ -9,7 +9,7 @@
9
9
  "url": "https://github.com/bendyline/docblocks.git",
10
10
  "directory": "packages/core"
11
11
  },
12
- "homepage": "https://github.com/bendyline/docblocks",
12
+ "homepage": "https://docblocks.com/",
13
13
  "keywords": [
14
14
  "docblocks",
15
15
  "markdown",
@@ -24,8 +24,7 @@
24
24
  "module": "./dist/index.js",
25
25
  "types": "./dist/index.d.ts",
26
26
  "files": [
27
- "dist",
28
- "src"
27
+ "dist"
29
28
  ],
30
29
  "exports": {
31
30
  ".": {
@@ -73,6 +72,11 @@
73
72
  "import": "./dist/host/index.js",
74
73
  "default": "./dist/host/index.js"
75
74
  },
75
+ "./share": {
76
+ "types": "./dist/share/index.d.ts",
77
+ "import": "./dist/share/index.js",
78
+ "default": "./dist/share/index.js"
79
+ },
76
80
  "./vscode": {
77
81
  "types": "./dist/vscode/index.d.ts",
78
82
  "import": "./dist/vscode/index.js",
@@ -94,7 +98,7 @@
94
98
  "typecheck": "tsc --noEmit"
95
99
  },
96
100
  "dependencies": {
97
- "@bendyline/squisq": "2.0.1",
101
+ "@bendyline/squisq": "2.3.0",
98
102
  "zod": "3.25.76"
99
103
  }
100
104
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/native-provider-v2.ts","../src/filesystem/native-provider.ts"],"sourcesContent":["import { withFileCommitLock } from './commit-lock.js';\nimport { FsError, fsErrorFromUnknown, type FsOperation } from './fs-error.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 FileSystemSnapshotFile,\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 workspacePathJoin,\n type WorkspacePath,\n} from './workspace-path.js';\n\ninterface ScannedEntry<TFile extends FileSystemFileSnapshot> {\n readonly root: FileSystemDirectorySnapshot | TFile;\n readonly entries: readonly (FileSystemDirectorySnapshot | TFile)[];\n}\n\ntype MetadataScan = ScannedEntry<FileSystemFileSnapshot>;\ntype SnapshotScan = ScannedEntry<FileSystemSnapshotFile>;\n\nexport type NativeFileSystemMovePathState = 'present' | 'missing' | 'unknown';\n\nexport interface NativeFileSystemMoveRecoveryState {\n readonly source: NativeFileSystemMovePathState;\n readonly destination: NativeFileSystemMovePathState;\n}\n\n/**\n * A copy/delete move failed and the provider could not prove that rollback\n * restored the source-only state. Callers must inspect `state` before retrying.\n */\nexport class NativeFileSystemMoveRecoveryError extends FsError {\n public readonly primaryError: FsError;\n public readonly recoveryErrors: readonly FsError[];\n public readonly state: NativeFileSystemMoveRecoveryState;\n\n public constructor(\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n primaryError: FsError,\n recoveryErrors: readonly FsError[],\n state: NativeFileSystemMoveRecoveryState,\n ) {\n super(\n 'io',\n `Native move recovery is incomplete (source: ${state.source}, destination: ${state.destination}).`,\n {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n retryable: false,\n },\n );\n this.name = 'NativeFileSystemMoveRecoveryError';\n this.primaryError = primaryError;\n this.recoveryErrors = Object.freeze([...recoveryErrors]);\n this.state = Object.freeze({ ...state });\n }\n}\n\nconst EPOCH = new Date(0).toISOString();\n\nconst NATIVE_V2_CAPABILITIES: FileSystemProviderCapabilities = Object.freeze({\n writeAtomicity: 'none',\n moveAtomicity: 'none',\n snapshotAtomicity: 'none',\n conditionalWrite: 'process',\n recursiveRemove: true,\n watch: false,\n caseSensitivity: 'platform',\n symlinkPolicy: 'unsupported',\n durability: 'best-effort',\n});\n\n/** Direct File System Access API implementation of FileSystemProviderV2. */\nexport class NativeFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = NATIVE_V2_CAPABILITIES;\n\n private readonly root: FileSystemDirectoryHandle;\n private readonly lockKey: string;\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private disposed = false;\n private disposePromise: Promise<void> | null = null;\n\n public constructor(id: string, root: FileSystemDirectoryHandle) {\n this.id = id;\n this.label = root.name;\n this.root = root;\n this.lockKey = `native:${id}:workspace`;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = this.canonical(path);\n return this.execute('stat', canonical, null, async () => {\n const scanned = await this.tryScanMetadata(canonical, 'stat');\n return scanned ? withoutData(scanned.root) : null;\n });\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = this.canonical(path);\n return this.execute('read', canonical, null, async () => {\n const handle = await this.getHandle(canonical);\n if (!handle) return null;\n if (handle.kind !== 'file') {\n throw this.error('type-mismatch', 'read', canonical, 'Expected a file, found a directory.');\n }\n const scanned = await this.scanSnapshotHandle(canonical, handle, 'read');\n if (scanned.root.kind !== 'file') {\n throw this.error('io', 'read', canonical, 'Native file handle changed kind during read.');\n }\n return Object.freeze({\n entry: withoutData(scanned.root) as FileSystemFileSnapshot,\n data: scanned.root.data.slice(0),\n });\n });\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = this.canonical(path);\n return this.execute('list', canonical, null, async () => {\n const handle = await this.getHandle(canonical);\n if (!handle) throw this.error('not-found', 'list', canonical, 'Directory does not exist.');\n if (handle.kind !== 'directory') {\n throw this.error('type-mismatch', 'list', canonical, 'Expected a directory, found a file.');\n }\n\n const children: FileSystemEntrySnapshot[] = [];\n for (const [name, childHandle] of await listDirectory(\n handle as FileSystemDirectoryHandle,\n 'list',\n canonical,\n )) {\n const childPath = workspacePathJoin(canonical, name);\n children.push(\n withoutData((await this.scanMetadataHandle(childPath, childHandle, 'list')).root),\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 const canonical = this.canonicalNonRoot(path, 'write');\n const ownedData = copyBytes(data);\n return this.mutate('write', canonical, null, async () => {\n const mode = options.mode ?? 'upsert';\n if (mode !== 'upsert' && mode !== 'create' && mode !== 'replace') {\n throw this.error('invalid-path', 'write', canonical, 'Invalid write mode.');\n }\n\n const existing = await this.tryScanMetadata(canonical, 'write');\n if (existing?.root.kind === 'directory') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Cannot replace a directory with a file.',\n );\n }\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?.root, options.expectedVersion, 'write', canonical);\n\n const missingParents = await this.planParents(\n canonical,\n options.createParents ?? false,\n 'write',\n );\n const createdParents = await this.createDirectories(missingParents);\n let writeCompleted = false;\n try {\n await this.writeBytes(canonical, ownedData);\n writeCompleted = true;\n const written = await this.requireSnapshot(canonical, 'write');\n if (written.root.kind !== 'file' || !equalBytes(written.root.data, ownedData)) {\n throw this.error(\n 'conflict',\n 'write',\n canonical,\n 'Stored bytes changed before the write could be verified.',\n );\n }\n return withoutData(written.root) as FileSystemFileSnapshot;\n } catch (error: unknown) {\n if (!existing && !writeCompleted) {\n await this.removeEmptyFileIfPresent(canonical).catch(() => undefined);\n }\n await this.rollbackDirectories(createdParents);\n throw error;\n }\n });\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options: FileSystemCreateDirectoryOptions = {},\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = this.canonical(path);\n return this.mutate('create-directory', canonical, null, async () => {\n const mode = options.mode ?? 'ensure';\n if (mode !== 'ensure' && mode !== 'create') {\n throw this.error('invalid-path', 'create-directory', canonical, 'Invalid directory mode.');\n }\n const existing = await this.tryScanMetadata(canonical, 'create-directory');\n if (existing) {\n if (existing.root.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 (mode === 'create') {\n throw this.error(\n 'already-exists',\n 'create-directory',\n canonical,\n 'Directory already exists.',\n );\n }\n return withoutData(existing.root) as FileSystemDirectorySnapshot;\n }\n\n const missingParents = await this.planParents(\n canonical,\n options.createParents ?? false,\n 'create-directory',\n );\n const planned = [...missingParents, canonical];\n const created = await this.createDirectories(planned);\n try {\n const scanned = await this.requireMetadata(canonical, 'create-directory');\n if (scanned.root.kind !== 'directory') {\n throw this.error(\n 'io',\n 'create-directory',\n canonical,\n 'The native backend did not create a directory.',\n );\n }\n return withoutData(scanned.root) as FileSystemDirectorySnapshot;\n } catch (error: unknown) {\n await this.rollbackDirectories(created);\n throw error;\n }\n });\n }\n\n public async remove(\n path: WorkspacePath,\n options: FileSystemRemoveOptions = {},\n ): Promise<FileSystemRemoveResult> {\n const canonical = this.canonicalNonRoot(path, 'remove');\n return this.mutate('remove', canonical, null, async () => {\n const existing = await this.tryScanMetadata(canonical, 'remove');\n if (!existing) {\n if ((options.missing ?? 'error') === 'ignore') {\n return Object.freeze({\n removed: false,\n version: await this.currentTreeVersion('remove'),\n });\n }\n throw this.error('not-found', 'remove', canonical, 'Entry does not exist.');\n }\n this.assertExpectedVersion(existing.root, options.expectedVersion, 'remove', canonical);\n if (existing.root.kind === 'directory' && !options.recursive) {\n const handle = await this.getHandle(canonical);\n if (!handle || handle.kind !== 'directory') {\n throw this.error('conflict', 'remove', canonical, 'Directory changed before removal.');\n }\n if (\n (await listDirectory(handle as FileSystemDirectoryHandle, 'remove', canonical)).length > 0\n ) {\n throw this.error('not-empty', 'remove', canonical, 'Directory is not empty.');\n }\n }\n\n await this.removeEntry(canonical, existing.root.kind === 'directory' && !!options.recursive);\n if (await this.getHandle(canonical)) {\n throw this.error('conflict', 'remove', canonical, 'Entry was recreated during removal.');\n }\n return Object.freeze({\n removed: true,\n version: await this.currentTreeVersion('remove'),\n });\n });\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options: FileSystemMoveOptions = {},\n ): Promise<FileSystemEntrySnapshot> {\n const sourcePath = this.canonicalNonRoot(oldPath, 'move');\n const destinationPath = this.canonicalNonRoot(newPath, 'move');\n return this.mutate('move', sourcePath, destinationPath, async () => {\n const sourceMetadata = await this.tryScanMetadata(sourcePath, 'move');\n if (!sourceMetadata) {\n throw this.error('not-found', 'move', sourcePath, 'Source does not exist.');\n }\n this.assertExpectedVersion(sourceMetadata.root, options.expectedVersion, 'move', sourcePath);\n if (sourcePath === destinationPath) return withoutData(sourceMetadata.root);\n if (\n sourceMetadata.root.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 if (await this.getHandle(destinationPath)) {\n throw new FsError('already-exists', 'Destination already exists.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n const missingParents = await this.planParents(\n destinationPath,\n options.createParents ?? false,\n 'move',\n );\n const source = await this.tryScanSnapshot(sourcePath, 'move');\n if (\n !source ||\n source.root.kind !== sourceMetadata.root.kind ||\n source.root.version !== sourceMetadata.root.version\n ) {\n throw new FsError('conflict', 'Source changed before the move could be copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n const createdParents = await this.createDirectories(missingParents);\n let destinationVersion: FileSystemVersion | null = null;\n let sourceDeleted = false;\n try {\n await this.writeTree(source, sourcePath, destinationPath);\n const copied = await this.requireSnapshot(destinationPath, 'move');\n destinationVersion = copied.root.version;\n if (!equalTreeContents(source, sourcePath, copied, destinationPath)) {\n throw new FsError('conflict', 'Destination changed while the move was copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n const sourceBeforeDelete = await this.tryScanMetadata(sourcePath, 'move');\n if (\n !sourceBeforeDelete ||\n sourceBeforeDelete.root.kind !== source.root.kind ||\n sourceBeforeDelete.root.version !== source.root.version\n ) {\n throw new FsError('conflict', 'Source changed while the move was copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n await this.removeEntry(sourcePath, source.root.kind === 'directory');\n sourceDeleted = true;\n const [sourceAfter, destinationAfter] = await Promise.all([\n this.tryScanMetadata(sourcePath, 'move'),\n this.tryScanMetadata(destinationPath, 'move'),\n ]);\n if (\n sourceAfter ||\n !destinationAfter ||\n destinationAfter.root.kind !== source.root.kind ||\n destinationAfter.root.version !== destinationVersion\n ) {\n throw new FsError('conflict', 'Move state changed before it could be verified.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n return withoutData(destinationAfter.root);\n } catch (error: unknown) {\n return await this.rollbackMoveAndThrow(\n sourcePath,\n destinationPath,\n source,\n createdParents,\n destinationVersion,\n sourceDeleted,\n error,\n );\n }\n });\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.mutate('snapshot', WORKSPACE_ROOT, null, async () => {\n const scanned = await this.scanSnapshotHandle(WORKSPACE_ROOT, this.root, 'snapshot');\n const entries = [...scanned.entries]\n .sort((left, right) => compareText(left.path, right.path))\n .map(copySnapshotEntry);\n return Object.freeze({ version: scanned.root.version, entries: Object.freeze(entries) });\n });\n }\n\n public watch(\n _listener: FileSystemWatchListener,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n const error = new FsError('not-supported', 'Native 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 // Observers cannot change provider 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 await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n })();\n return this.disposePromise;\n }\n\n private canonical(path: WorkspacePath): WorkspacePath {\n return parseWorkspacePath(String(path));\n }\n\n private canonicalNonRoot(path: WorkspacePath, operation: FsOperation): WorkspacePath {\n const canonical = this.canonical(path);\n if (!canonical) {\n throw this.error('invalid-path', operation, canonical, 'Workspace root cannot be mutated.');\n }\n return canonical;\n }\n\n private execute<T>(\n operation: FsOperation,\n path: WorkspacePath | null,\n destinationPath: WorkspacePath | null,\n work: () => Promise<T>,\n ): Promise<T> {\n this.assertOpen(operation);\n const promise = (async () => {\n try {\n return await work();\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, destinationPath);\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 mutate<T>(\n operation: FsOperation,\n path: WorkspacePath,\n destinationPath: WorkspacePath | null,\n work: () => Promise<T>,\n ): Promise<T> {\n return this.execute(operation, path, destinationPath, () =>\n withFileCommitLock(this.lockKey, work),\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 translateError(\n error: unknown,\n operation: FsOperation,\n path: WorkspacePath | null,\n destinationPath: WorkspacePath | null,\n ): FsError {\n if (error instanceof FsError) return error;\n return fsErrorFromUnknown(error, {\n operation,\n path: path ?? undefined,\n destinationPath: destinationPath ?? undefined,\n });\n }\n\n private error(\n code: ConstructorParameters<typeof FsError>[0],\n operation: FsOperation,\n path: WorkspacePath,\n message: string,\n ): FsError {\n return new FsError(code, message, { operation, path });\n }\n\n private assertExpectedVersion(\n entry: FileSystemEntrySnapshot | undefined,\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 async resolveDirectory(path: WorkspacePath): Promise<FileSystemDirectoryHandle | null> {\n if (!path) return this.root;\n let current = this.root;\n for (const segment of path.split('/')) {\n try {\n current = await current.getDirectoryHandle(segment);\n } catch (error: unknown) {\n if (errorName(error) === 'NotFoundError') return null;\n throw error;\n }\n }\n return current;\n }\n\n private async getHandle(path: WorkspacePath): Promise<FileSystemHandle | null> {\n if (!path) return this.root;\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) return null;\n const name = workspacePathBasename(path);\n try {\n return await parent.getFileHandle(name);\n } catch (error: unknown) {\n if (!isMissingOrKindError(error)) throw error;\n }\n try {\n return await parent.getDirectoryHandle(name);\n } catch (error: unknown) {\n if (!isMissingOrKindError(error)) throw error;\n return null;\n }\n }\n\n private async tryScanMetadata(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<MetadataScan | null> {\n const handle = await this.getHandle(path);\n return handle ? this.scanMetadataHandle(path, handle, operation) : null;\n }\n\n private async tryScanSnapshot(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<SnapshotScan | null> {\n const handle = await this.getHandle(path);\n return handle ? this.scanSnapshotHandle(path, handle, operation) : null;\n }\n\n private async requireMetadata(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<MetadataScan> {\n const scanned = await this.tryScanMetadata(path, operation);\n if (!scanned) throw this.error('not-found', operation, path, 'Entry does not exist.');\n return scanned;\n }\n\n private async requireSnapshot(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<SnapshotScan> {\n const scanned = await this.tryScanSnapshot(path, operation);\n if (!scanned) throw this.error('not-found', operation, path, 'Entry does not exist.');\n return scanned;\n }\n\n private scanMetadataHandle(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n ): Promise<MetadataScan> {\n // File snapshots expose stable size/lastModified metadata without reading payload bytes.\n // Keep stat/list/version checks on this path so directory scans scale with entries, not bytes.\n return this.scanHandle(path, handle, operation, (filePath, fileHandle) =>\n this.scanFileMetadata(filePath, fileHandle, operation),\n );\n }\n\n private scanSnapshotHandle(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n ): Promise<SnapshotScan> {\n return this.scanHandle(path, handle, operation, (filePath, fileHandle) =>\n this.scanFileSnapshot(filePath, fileHandle, operation),\n );\n }\n\n private async scanHandle<TFile extends FileSystemFileSnapshot>(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n scanFile: (path: WorkspacePath, handle: FileSystemFileHandle) => Promise<TFile>,\n ): Promise<ScannedEntry<TFile>> {\n if (handle.kind === 'file') {\n const entry = await scanFile(path, handle as FileSystemFileHandle);\n return { root: entry, entries: Object.freeze([entry]) };\n }\n\n const children: ScannedEntry<TFile>[] = [];\n for (const [name, childHandle] of await listDirectory(\n handle as FileSystemDirectoryHandle,\n operation,\n path,\n )) {\n children.push(\n await this.scanHandle(workspacePathJoin(path, name), childHandle, operation, scanFile),\n );\n }\n const childRoots = children.map((child) => child.root).sort(compareSnapshots);\n const version = await metadataVersion(\n 'directory',\n new TextEncoder().encode(\n childRoots\n .map((child) => `${child.kind}\\0${child.name.length}:${child.name}\\0${child.version}`)\n .join('\\n'),\n ),\n operation,\n path,\n );\n const directory: FileSystemDirectorySnapshot = Object.freeze({\n kind: 'directory' as const,\n path,\n name: workspacePathBasename(path),\n size: null,\n version,\n lastModified: newestLastModified(childRoots),\n });\n return {\n root: directory,\n entries: Object.freeze([directory, ...children.flatMap((child) => child.entries)]),\n };\n }\n\n private async scanFileMetadata(\n path: WorkspacePath,\n handle: FileSystemFileHandle,\n operation: FsOperation,\n ): Promise<FileSystemFileSnapshot> {\n const file = await this.getFileSnapshot(handle, path, operation);\n return this.fileMetadata(file, path, operation);\n }\n\n private async scanFileSnapshot(\n path: WorkspacePath,\n handle: FileSystemFileHandle,\n operation: FsOperation,\n ): Promise<FileSystemSnapshotFile> {\n const file = await this.getFileSnapshot(handle, path, operation);\n const metadata = await this.fileMetadata(file, path, operation);\n let data: ArrayBuffer;\n try {\n data = copyBytes(await file.arrayBuffer());\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, null);\n }\n if (metadata.size !== data.byteLength) {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n return Object.freeze({ ...metadata, data });\n }\n\n private async getFileSnapshot(\n handle: FileSystemFileHandle,\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<File> {\n try {\n return await handle.getFile();\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, null);\n }\n }\n\n private async fileMetadata(\n file: File,\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<FileSystemFileSnapshot> {\n if (!Number.isSafeInteger(file.size) || file.size < 0 || !Number.isFinite(file.lastModified)) {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n\n let lastModified: string;\n try {\n lastModified = new Date(file.lastModified).toISOString();\n } catch {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n\n return Object.freeze({\n kind: 'file',\n path,\n name: workspacePathBasename(path),\n size: file.size,\n version: await metadataVersion(\n 'file',\n new TextEncoder().encode(`${file.size}\\0${file.lastModified}`),\n operation,\n path,\n ),\n lastModified,\n });\n }\n\n private async planParents(\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 handle = await this.getHandle(parent);\n if (handle?.kind === 'file') {\n throw this.error('type-mismatch', operation, parent, 'A parent path is a file.');\n }\n if (!handle) {\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 async createDirectories(paths: readonly WorkspacePath[]): Promise<WorkspacePath[]> {\n const created: WorkspacePath[] = [];\n try {\n for (const path of paths) {\n if (!path) continue;\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) {\n throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n }\n await parent.getDirectoryHandle(workspacePathBasename(path), { create: true });\n created.push(path);\n }\n return created;\n } catch (error: unknown) {\n await this.rollbackDirectories(created);\n throw error;\n }\n }\n\n private async rollbackDirectories(paths: readonly WorkspacePath[]): Promise<void> {\n for (const path of [...paths].reverse()) {\n try {\n await this.removeEntry(path, false);\n } catch {\n // Best effort: a non-empty directory may now contain external data.\n }\n }\n }\n\n private async writeBytes(path: WorkspacePath, data: ArrayBuffer): Promise<void> {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n const fileHandle = await parent.getFileHandle(workspacePathBasename(path), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, data);\n }\n\n private async removeEntry(path: WorkspacePath, recursive: boolean): Promise<void> {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n await parent.removeEntry(workspacePathBasename(path), { recursive });\n }\n\n private async removeEmptyFileIfPresent(path: WorkspacePath): Promise<void> {\n const current = await this.tryScanMetadata(path, 'write');\n if (current?.root.kind !== 'file' || current.root.size !== 0) return;\n await this.removeEntry(path, false);\n }\n\n private async currentTreeVersion(operation: FsOperation): Promise<FileSystemVersion> {\n return (await this.scanMetadataHandle(WORKSPACE_ROOT, this.root, operation)).root.version;\n }\n\n private async writeTree(\n source: SnapshotScan,\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n ): Promise<void> {\n const remapped = source.entries.map((entry) => {\n const suffix = entry.path.slice(sourcePath.length);\n return [entry, parseWorkspacePath(`${destinationPath}${suffix}`)] as const;\n });\n const directories = remapped\n .filter(\n (item): item is readonly [FileSystemDirectorySnapshot, WorkspacePath] =>\n item[0].kind === 'directory',\n )\n .sort((left, right) => pathDepth(left[1]) - pathDepth(right[1]));\n for (const [, path] of directories) {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n await parent.getDirectoryHandle(workspacePathBasename(path), { create: true });\n }\n for (const [entry, path] of remapped) {\n if (entry.kind === 'file') await this.writeBytes(path, entry.data);\n }\n }\n\n private async rollbackMoveAndThrow(\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n source: SnapshotScan,\n createdParents: readonly WorkspacePath[],\n destinationVersion: FileSystemVersion | null,\n sourceDeleted: boolean,\n primary: unknown,\n ): Promise<never> {\n const primaryError = this.translateError(primary, 'move', sourcePath, destinationPath);\n const recoveryErrors: FsError[] = [];\n\n const sourceCurrent = await this.probeScan(sourcePath);\n if (sourceCurrent === null && sourceDeleted) {\n try {\n await this.writeTree(source, sourcePath, sourcePath);\n const restored = await this.probeSnapshot(sourcePath);\n if (!restored || !equalTreeContents(source, sourcePath, restored, sourcePath)) {\n throw new FsError('conflict', 'Restored source does not match its captured state.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n } catch (error: unknown) {\n recoveryErrors.push(this.translateError(error, 'move', sourcePath, destinationPath));\n }\n }\n\n const destinationCurrent = await this.probeScan(destinationPath);\n if (destinationCurrent) {\n if (destinationVersion && destinationCurrent.root.version !== destinationVersion) {\n recoveryErrors.push(\n new FsError('conflict', 'Destination changed; rollback will not delete it.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n }),\n );\n } else {\n try {\n await this.removeEntry(destinationPath, destinationCurrent.root.kind === 'directory');\n } catch (error: unknown) {\n recoveryErrors.push(this.translateError(error, 'move', sourcePath, destinationPath));\n }\n }\n }\n await this.rollbackDirectories(createdParents);\n\n const state: NativeFileSystemMoveRecoveryState = {\n source: await this.probePresence(sourcePath),\n destination: await this.probePresence(destinationPath),\n };\n if (\n recoveryErrors.length === 0 &&\n state.source === 'present' &&\n state.destination === 'missing'\n ) {\n throw primaryError;\n }\n throw new NativeFileSystemMoveRecoveryError(\n sourcePath,\n destinationPath,\n primaryError,\n recoveryErrors,\n state,\n );\n }\n\n private async probeScan(path: WorkspacePath): Promise<MetadataScan | null | undefined> {\n try {\n return await this.tryScanMetadata(path, 'move');\n } catch {\n return undefined;\n }\n }\n\n private async probeSnapshot(path: WorkspacePath): Promise<SnapshotScan | null | undefined> {\n try {\n return await this.tryScanSnapshot(path, 'move');\n } catch {\n return undefined;\n }\n }\n\n private async probePresence(path: WorkspacePath): Promise<NativeFileSystemMovePathState> {\n try {\n return (await this.getHandle(path)) ? 'present' : 'missing';\n } catch {\n return 'unknown';\n }\n }\n}\n\nasync function listDirectory(\n directory: FileSystemDirectoryHandle,\n operation: FsOperation,\n path: WorkspacePath,\n): Promise<readonly (readonly [string, FileSystemHandle])[]> {\n const entries: Array<readonly [string, FileSystemHandle]> = [];\n try {\n for await (const entry of directory as unknown as AsyncIterable<\n readonly [string, FileSystemHandle]\n >) {\n const [name, handle] = entry;\n if (\n typeof name !== 'string' ||\n !handle ||\n (handle.kind !== 'file' && handle.kind !== 'directory')\n ) {\n throw new FsError('io', 'Native directory returned an invalid entry.', {\n operation,\n path,\n });\n }\n entries.push([name, handle]);\n }\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path });\n }\n entries.sort(([left], [right]) => compareText(left, right));\n return entries;\n}\n\nasync function writeAndClose(\n writable: FileSystemWritableFileStream,\n data: ArrayBuffer,\n): Promise<void> {\n try {\n await writable.write(data);\n await writable.close();\n } catch (error: unknown) {\n await writable.abort(error).catch(() => undefined);\n throw error;\n }\n}\n\nasync function metadataVersion(\n kind: 'file' | 'directory',\n metadata: Uint8Array,\n operation: FsOperation,\n path: WorkspacePath,\n): Promise<FileSystemVersion> {\n const prefix = new TextEncoder().encode(`${kind}\\0`);\n const input = new Uint8Array(prefix.byteLength + metadata.byteLength);\n input.set(prefix);\n input.set(metadata, prefix.byteLength);\n let digest: ArrayBuffer;\n try {\n digest = await globalThis.crypto.subtle.digest('SHA-256', input.buffer as ArrayBuffer);\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, {\n operation,\n path,\n defaultCode: 'not-supported',\n });\n }\n const hex = [...new Uint8Array(digest)]\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('');\n return parseFileSystemVersion(`sha256:${hex}`);\n}\n\nfunction parentChain(path: WorkspacePath): WorkspacePath[] {\n const parents: WorkspacePath[] = [];\n let current = workspacePathDirname(path);\n while (current) {\n parents.unshift(current);\n current = workspacePathDirname(current);\n }\n return parents;\n}\n\nfunction pathDepth(path: WorkspacePath): number {\n return path ? path.split('/').length : 0;\n}\n\nfunction errorName(error: unknown): string | null {\n if (!error || typeof error !== 'object') return null;\n const name = (error as { name?: unknown }).name;\n return typeof name === 'string' ? name : null;\n}\n\nfunction isMissingOrKindError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotFoundError' || name === 'TypeMismatchError';\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 equalBytes(left: ArrayBuffer, right: ArrayBuffer): boolean {\n const leftBytes = new Uint8Array(left);\n const rightBytes = new Uint8Array(right);\n return (\n leftBytes.byteLength === rightBytes.byteLength &&\n leftBytes.every((value, index) => value === rightBytes[index])\n );\n}\n\nfunction equalTreeContents(\n left: SnapshotScan,\n leftRoot: WorkspacePath,\n right: SnapshotScan,\n rightRoot: WorkspacePath,\n): boolean {\n if (left.entries.length !== right.entries.length) return false;\n\n const rightByRelativePath = new Map<\n string,\n FileSystemDirectorySnapshot | FileSystemSnapshotFile\n >();\n for (const entry of right.entries) {\n const relativePath = treeRelativePath(rightRoot, entry.path);\n if (relativePath === null || rightByRelativePath.has(relativePath)) return false;\n rightByRelativePath.set(relativePath, entry);\n }\n\n for (const entry of left.entries) {\n const relativePath = treeRelativePath(leftRoot, entry.path);\n if (relativePath === null) return false;\n const counterpart = rightByRelativePath.get(relativePath);\n if (!counterpart || counterpart.kind !== entry.kind) return false;\n if (entry.kind === 'file') {\n if (counterpart.kind !== 'file' || !equalBytes(entry.data, counterpart.data)) return false;\n }\n }\n return true;\n}\n\nfunction treeRelativePath(root: WorkspacePath, path: WorkspacePath): string | null {\n if (path === root) return '';\n const prefix = root ? `${root}/` : '';\n return path.startsWith(prefix) ? path.slice(prefix.length) : null;\n}\n\nfunction withoutData(entry: FileSystemEntrySnapshot): FileSystemEntrySnapshot {\n if (entry.kind === 'directory') return Object.freeze({ ...entry });\n return Object.freeze({\n kind: 'file',\n path: entry.path,\n name: entry.name,\n size: entry.size,\n version: entry.version,\n lastModified: entry.lastModified,\n });\n}\n\nfunction copySnapshotEntry(entry: FileSystemSnapshotEntry): FileSystemSnapshotEntry {\n if (entry.kind === 'directory') return Object.freeze({ ...entry });\n return Object.freeze({\n kind: 'file',\n path: entry.path,\n name: entry.name,\n size: entry.size,\n version: entry.version,\n lastModified: entry.lastModified,\n data: entry.data.slice(0),\n });\n}\n\nfunction newestLastModified(children: readonly FileSystemEntrySnapshot[]): string {\n let newest = 0;\n for (const child of children) {\n const timestamp = Date.parse(child.lastModified);\n if (Number.isFinite(timestamp)) newest = Math.max(newest, timestamp);\n }\n return newest ? new Date(newest).toISOString() : EPOCH;\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","/**\n * NativeFileSystemProvider — wraps the File System Access API\n * (window.showDirectoryPicker / FileSystemDirectoryHandle).\n *\n * Progressive enhancement: only available in browsers that support\n * the API (Chrome, Edge). Feature-detect with `isNativeFileSystemSupported()`.\n */\n\nimport type { FileCommitResult, FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { withFileCommitLock } from './commit-lock.js';\nimport { NativeFileSystemProviderV2 } from './native-provider-v2.js';\nimport { parseWorkspacePath } from './workspace-path.js';\n\n// ── Feature detection ──────────────────────────────────────────────\n\nexport function isNativeFileSystemSupported(): boolean {\n return (\n typeof globalThis !== 'undefined' &&\n typeof (globalThis as { showDirectoryPicker?: unknown }).showDirectoryPicker === 'function'\n );\n}\n\n// ── Handle persistence (IndexedDB, structured clone) ───────────────\n\nconst HANDLE_DB_NAME = 'docblocks-handles';\nconst HANDLE_STORE_NAME = 'directory-handles';\n\nfunction openHandleDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(HANDLE_DB_NAME, 1);\n req.onupgradeneeded = () => {\n req.result.createObjectStore(HANDLE_STORE_NAME);\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\n\n/** Persist a FileSystemDirectoryHandle so it survives page reloads. */\nexport async function storeDirectoryHandle(\n workspaceId: string,\n handle: FileSystemDirectoryHandle,\n): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).put(handle, workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n/** Retrieve a previously stored handle. Returns null if not found. */\nexport async function loadDirectoryHandle(\n workspaceId: string,\n): Promise<FileSystemDirectoryHandle | null> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readonly');\n const req = tx.objectStore(HANDLE_STORE_NAME).get(workspaceId);\n req.onsuccess = () => {\n db.close();\n resolve(req.result ?? null);\n };\n req.onerror = () => {\n db.close();\n reject(req.error);\n };\n });\n}\n\n/** Remove a stored handle (e.g. when deleting a workspace). */\nexport async function removeDirectoryHandle(workspaceId: string): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).delete(workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n// ── Helpers ────────────────────────────────────────────────────────\n\nfunction normalisePath(p: string): string {\n return parseWorkspacePath(p);\n}\n\nfunction errorName(error: unknown): string | undefined {\n return typeof error === 'object' && error !== null && 'name' in error\n ? String((error as { name?: unknown }).name)\n : undefined;\n}\n\nfunction isMissingEntryError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotFoundError' || name === 'TypeMismatchError';\n}\n\nfunction isPermissionError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotAllowedError' || name === 'SecurityError';\n}\n\nclass NativeMoveRecoveryError extends Error {\n readonly causes: readonly unknown[];\n\n constructor(message: string, causes: readonly unknown[]) {\n super(message);\n this.name = 'NativeMoveRecoveryError';\n this.causes = causes;\n }\n}\n\n/**\n * Walk a chain of path segments to reach a FileSystemDirectoryHandle.\n * Returns null if any segment is missing.\n */\nasync function resolveDir(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle | null> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n try {\n current = await current.getDirectoryHandle(part);\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n return current;\n}\n\n/**\n * Walk path segments, creating directories as needed.\n */\nasync function resolveDirCreate(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n current = await current.getDirectoryHandle(part, { create: true });\n }\n return current;\n}\n\nfunction parentDir(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? '' : p.slice(0, idx);\n}\n\nfunction baseName(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? p : p.slice(idx + 1);\n}\n\nfunction toWritableBinary(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n if (data instanceof ArrayBuffer) return data;\n const copy = new Uint8Array(data.byteLength);\n copy.set(data);\n return copy.buffer;\n}\n\nasync function writeAndClose(\n writable: FileSystemWritableFileStream,\n data: string | ArrayBuffer,\n): Promise<void> {\n try {\n await writable.write(data);\n await writable.close();\n } catch (error: unknown) {\n await writable.abort(error).catch(() => undefined);\n throw error;\n }\n}\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class NativeFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n readonly v2: NativeFileSystemProviderV2;\n\n private root: FileSystemDirectoryHandle;\n\n constructor(id: string, root: FileSystemDirectoryHandle) {\n this.id = id;\n this.label = root.name;\n this.root = root;\n this.v2 = new NativeFileSystemProviderV2(id, root);\n }\n\n private withMutationLock<T>(operation: () => Promise<T>): Promise<T> {\n return withFileCommitLock(`native:${this.id}:workspace`, operation);\n }\n\n private async copyDirectory(oldDirPath: string, newDirPath: string): Promise<void> {\n const source = await resolveDir(this.root, oldDirPath);\n if (!source)\n throw new DOMException(`Source directory does not exist: ${oldDirPath}`, 'NotFoundError');\n await resolveDirCreate(this.root, newDirPath);\n\n for await (const [name, handle] of source as unknown as AsyncIterable<\n [string, FileSystemHandle]\n >) {\n const oldChild = oldDirPath ? `${oldDirPath}/${name}` : name;\n const newChild = newDirPath ? `${newDirPath}/${name}` : name;\n if (handle.kind === 'directory') {\n await this.copyDirectory(oldChild, newChild);\n } else {\n const fileHandle = await source.getFileHandle(name);\n const file = await fileHandle.getFile();\n await this.writeBinaryUnlocked(newChild, await file.arrayBuffer());\n }\n }\n }\n\n async readFile(path: string): Promise<string | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return file.text();\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.withMutationLock(() => this.writeFileUnlocked(path, content));\n }\n\n private async writeFileUnlocked(path: string, content: string): Promise<void> {\n const p = normalisePath(path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, content);\n }\n\n async commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n const p = normalisePath(path);\n return this.withMutationLock(async () => {\n const current = await this.readFile(p);\n if (current !== expectedContent && current !== content) {\n const meta = await this.stat(p);\n return {\n status: 'conflict',\n content: current,\n version: meta?.lastModified ?? null,\n };\n }\n await this.writeFileUnlocked(p, content);\n const meta = await this.stat(p);\n return { status: 'committed', version: meta?.lastModified ?? null };\n });\n }\n\n async delete(path: string): Promise<void> {\n return this.withMutationLock(() => this.deleteUnlocked(path));\n }\n\n private async deleteUnlocked(path: string): Promise<void> {\n const p = normalisePath(path);\n if (!p) throw new Error('Cannot delete the filesystem root');\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return;\n try {\n await dir.removeEntry(name, { recursive: true });\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return;\n throw error;\n }\n }\n\n async rename(oldPath: string, newPath: string): Promise<void> {\n return this.withMutationLock(() => this.renameUnlocked(oldPath, newPath));\n }\n\n private async renameUnlocked(oldPath: string, newPath: string): Promise<void> {\n const op = normalisePath(oldPath);\n const np = normalisePath(newPath);\n if (op === np) return;\n if (!op || !np) {\n throw new Error('Cannot rename the filesystem root');\n }\n if (np.startsWith(op + '/')) {\n throw new Error('Cannot move a directory into itself');\n }\n if (!(await this.exists(op))) {\n throw new Error(`Source does not exist: ${oldPath}`);\n }\n if (await this.exists(np)) {\n throw new Error(`Destination exists: ${newPath}`);\n }\n\n // The File System Access API doesn't have a native rename.\n // Copy → delete.\n const oldParent = await resolveDir(this.root, parentDir(op));\n if (!oldParent) {\n throw new DOMException(`Source does not exist: ${oldPath}`, 'NotFoundError');\n }\n\n let fileHandle: FileSystemFileHandle | null = null;\n try {\n fileHandle = await oldParent.getFileHandle(baseName(op));\n } catch (error: unknown) {\n if (!isMissingEntryError(error)) throw error;\n }\n\n if (fileHandle) {\n const file = await fileHandle.getFile();\n await this.writeBinaryUnlocked(np, await file.arrayBuffer());\n try {\n await this.deleteUnlocked(op);\n } catch (error: unknown) {\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move partially completed and rollback failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n return;\n }\n\n try {\n await this.copyDirectory(op, np);\n } catch (error: unknown) {\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move failed and destination cleanup failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n\n try {\n await this.deleteUnlocked(op);\n } catch (error: unknown) {\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move partially completed and rollback failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n }\n\n async readDirectory(path: string): Promise<FileSystemEntry[]> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, p);\n if (!dir) return [];\n\n const entries: FileSystemEntry[] = [];\n for await (const [name, handle] of dir as unknown as AsyncIterable<\n [string, FileSystemHandle]\n >) {\n const entryPath = p ? `${p}/${name}` : name;\n if (handle.kind === 'directory') {\n entries.push({ kind: 'directory', name, path: entryPath });\n } else {\n entries.push({ kind: 'file', name, path: entryPath });\n }\n }\n\n // Sort: directories first, then alphabetical\n entries.sort((a, b) => {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1;\n return a.name.localeCompare(b.name);\n });\n\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const p = normalisePath(path);\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return false;\n\n try {\n await dir.getFileHandle(name);\n return true;\n } catch (fileError: unknown) {\n if (!isMissingEntryError(fileError)) throw fileError;\n try {\n await dir.getDirectoryHandle(name);\n return true;\n } catch (directoryError: unknown) {\n if (!isMissingEntryError(directoryError)) throw directoryError;\n return false;\n }\n }\n }\n\n async createDirectory(path: string): Promise<void> {\n return this.withMutationLock(async () => {\n const p = normalisePath(path);\n await resolveDirCreate(this.root, p);\n });\n }\n\n async stat(path: string): Promise<FileMeta | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return {\n name: file.name,\n path: p,\n size: file.size,\n lastModified: new Date(file.lastModified).toISOString(),\n };\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n\n async readBinary(path: string): Promise<ArrayBuffer | null> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return file.arrayBuffer();\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n\n async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return this.withMutationLock(() => this.writeBinaryUnlocked(path, data));\n }\n\n private async writeBinaryUnlocked(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n const p = normalisePath(path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, toWritableBinary(data));\n }\n}\n\n/**\n * Prompt the user to pick a local folder and return a NativeFileSystemProvider.\n * The directory handle is persisted in IndexedDB so it can be restored later.\n * Throws if the user cancels or the API is unsupported.\n */\nexport async function openNativeFolder(): Promise<NativeFileSystemProvider> {\n if (!isNativeFileSystemSupported()) {\n throw new Error('File System Access API is not supported in this browser');\n }\n\n const handle = await (\n globalThis as unknown as {\n showDirectoryPicker: (options: { mode: 'readwrite' }) => Promise<FileSystemDirectoryHandle>;\n }\n ).showDirectoryPicker({ mode: 'readwrite' });\n const id = `native-${handle.name}-${Date.now()}`;\n await storeDirectoryHandle(id, handle);\n return new NativeFileSystemProvider(id, handle);\n}\n\n/**\n * Restore a previously opened native folder from a persisted handle.\n * Re-requests read/write permission (browser will show a prompt).\n * Returns null if the handle is not found or permission is denied.\n */\nexport async function restoreNativeFolder(\n workspaceId: string,\n): Promise<NativeFileSystemProvider | null> {\n const handle = await loadDirectoryHandle(workspaceId);\n if (!handle) return null;\n\n // Verify/request permission\n const opts = { mode: 'readwrite' as const };\n const h = handle as FileSystemDirectoryHandle & {\n queryPermission(desc: { mode: string }): Promise<string>;\n requestPermission(desc: { mode: string }): Promise<string>;\n };\n try {\n if ((await h.queryPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n if ((await h.requestPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n } catch (error: unknown) {\n if (!isPermissionError(error)) throw error;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAoDO,IAAM,oCAAN,cAAgD,QAAQ;AAAA,EAKtD,YACL,YACA,iBACA,cACA,gBACA,OACA;AACA;AAAA,MACE;AAAA,MACA,+CAA+C,MAAM,MAAM,kBAAkB,MAAM,WAAW;AAAA,MAC9F;AAAA,QACE,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,QACA,WAAW;AAAA,MACb;AAAA,IACF;AACA,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB,OAAO,OAAO,CAAC,GAAG,cAAc,CAAC;AACvD,SAAK,QAAQ,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC;AAAA,EACzC;AACF;AAEA,IAAM,SAAQ,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AC3E;AAEA,QAAM,SAAS,MACb,WAGA,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC3C,QAAM,KAAK,UAAU,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;AAC9C,QAAM,qBAAqB,IAAI,MAAM;AACrC,SAAO,IAAI,yBAAyB,IAAI,MAAM;AAChD;AAOA,eAAsB,oBACpB,aAC0C;AAC1C,QAAM,SAAS,MAAM,oBAAoB,WAAW;AACpD,MAAI,CAAC,OAAQ,QAAO;AAGpB,QAAM,OAAO,EAAE,MAAM,YAAqB;AAC1C,QAAM,IAAI;AAIV,MAAI;AACF,QAAK,MAAM,EAAE,gBAAgB,IAAI,MAAO,WAAW;AACjD,aAAO,IAAI,yBAAyB,aAAa,MAAM;AAAA,IACzD;AACA,QAAK,MAAM,EAAE,kBAAkB,IAAI,MAAO,WAAW;AACnD,aAAO,IAAI,yBAAyB,aAAa,MAAM;AAAA,IACzD;AAAA,EACF,SAAS,OAAgB;AACvB,QAAI,CAAC,kBAAkB,KAAK,EAAG,OAAM;AAAA,EACvC;AAEA,SAAO;AACT;","names":["errorName","writeAndClose","meta"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/legacy-v2-adapter.ts","../src/filesystem/move-entry.ts","../src/filesystem/dbk-workspace.ts","../src/filesystem/filesystem-content-container.ts","../src/filesystem/file-media-provider.ts"],"sourcesContent":["import { FsError, fsErrorFromUnknown, type FsOperation } from './fs-error.js';\nimport type { FileSystemEntry, FileSystemProvider } from './types.js';\nimport {\n parseFileSystemVersion,\n type FileSystemAtomicity,\n type FileSystemCaseSensitivity,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\n type FileSystemDurability,\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 FileSystemSnapshotFile,\n type FileSystemSymlinkPolicy,\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 workspacePathToLegacy,\n type WorkspacePath,\n} from './workspace-path.js';\n\nexport type LegacyFilePayloadModel =\n | 'split'\n | 'binary-first-text-fallback'\n | 'binary-authoritative';\n\nexport interface LegacyFileSystemProviderV2AdapterOptions {\n /**\n * Split stores expose independent raw text and binary channels and reject\n * dual payloads. Binary-first stores synthesize text for binary records, so\n * the adapter only asks for text after readBinary() returns null. Binary-\n * authoritative stores expose every file through readBinary().\n */\n readonly payloadModel: LegacyFilePayloadModel;\n readonly writeAtomicity?: FileSystemAtomicity;\n readonly moveAtomicity?: FileSystemAtomicity;\n readonly caseSensitivity?: FileSystemCaseSensitivity;\n readonly symlinkPolicy?: FileSystemSymlinkPolicy;\n readonly durability?: FileSystemDurability;\n /** Optional ownership hook; omitted when the adapter does not own the v1 provider. */\n readonly dispose?: () => void | Promise<void>;\n}\n\ninterface CapturedTree {\n readonly entries: ReadonlyMap<WorkspacePath, FileSystemSnapshotEntry>;\n readonly version: FileSystemVersion;\n}\n\nconst EPOCH = new Date(0).toISOString();\n\n/**\n * Correctness bridge for hardened v1 providers while storage backends migrate.\n *\n * The adapter deliberately serializes every observable operation. This makes a\n * version check and its mutation indivisible among v2 callers, but cannot make\n * calls that bypass the adapter participate in that boundary. Content-derived\n * versions make those external changes visible on the next adapter operation.\n */\nexport class LegacyFileSystemProviderV2Adapter implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities: FileSystemProviderCapabilities;\n\n private operationTail: Promise<void> = Promise.resolve();\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private closing = false;\n private disposed = false;\n private disposePromise: Promise<void> | null = null;\n\n public constructor(\n private readonly provider: FileSystemProvider,\n private readonly options: LegacyFileSystemProviderV2AdapterOptions,\n ) {\n this.id = provider.id;\n this.label = provider.label;\n this.capabilities = Object.freeze({\n writeAtomicity: options.writeAtomicity ?? 'none',\n moveAtomicity: options.moveAtomicity ?? 'none',\n // A tree snapshot spans multiple v1 calls; callers that bypass this\n // adapter can still interleave, even though adapter operations serialize.\n snapshotAtomicity: 'none',\n conditionalWrite: 'process',\n recursiveRemove: true,\n watch: false,\n caseSensitivity: options.caseSensitivity ?? 'platform',\n symlinkPolicy: options.symlinkPolicy ?? 'unsupported',\n durability: options.durability ?? 'best-effort',\n });\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = this.canonical(path);\n return this.enqueue('stat', async () => {\n const entry = (await this.captureTree('stat')).entries.get(canonical);\n return entry ? copyEntrySnapshot(entry) : null;\n });\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = this.canonical(path);\n return this.enqueue('read', async () => {\n const entry = (await this.captureTree('read')).entries.get(canonical);\n if (!entry) return null;\n if (entry.kind !== 'file') {\n throw this.error('type-mismatch', 'read', canonical, 'Expected a file, found a directory.');\n }\n return Object.freeze({ entry: fileMetadata(entry), data: entry.data.slice(0) });\n });\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = this.canonical(path);\n return this.enqueue('list', async () => {\n const tree = await this.captureTree('list');\n const entry = tree.entries.get(canonical);\n if (!entry) throw this.error('not-found', 'list', canonical, 'Directory does not exist.');\n if (entry.kind !== 'directory') {\n throw this.error('type-mismatch', 'list', canonical, 'Expected a directory, found a file.');\n }\n const children = [...tree.entries.entries()]\n .filter(([entryPath]) => entryPath && workspacePathDirname(entryPath) === canonical)\n .map(([, child]) => copyEntrySnapshot(child))\n .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 const canonical = this.canonicalNonRoot(path, 'write');\n const ownedData = copyBytes(data);\n return this.enqueue('write', async () => {\n const tree = await this.captureTree('write');\n const existing = tree.entries.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\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 this.assertParents(tree, canonical, options.createParents ?? false, 'write');\n\n await this.invoke(\n () => this.provider.writeBinary(workspacePathToLegacy(canonical), ownedData),\n 'write',\n canonical,\n );\n const written = (await this.captureTree('write')).entries.get(canonical);\n if (written?.kind !== 'file' || !equalBytes(written.data, ownedData)) {\n throw this.error(\n 'io',\n 'write',\n canonical,\n 'The legacy provider did not persist the requested bytes.',\n );\n }\n return fileMetadata(written);\n });\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options: FileSystemCreateDirectoryOptions = {},\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = this.canonical(path);\n return this.enqueue('create-directory', async () => {\n const tree = await this.captureTree('create-directory');\n const existing = tree.entries.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 copyDirectorySnapshot(existing);\n }\n\n this.assertParents(tree, canonical, options.createParents ?? false, 'create-directory');\n await this.invoke(\n () => this.provider.createDirectory(workspacePathToLegacy(canonical)),\n 'create-directory',\n canonical,\n );\n const created = (await this.captureTree('create-directory')).entries.get(canonical);\n if (created?.kind !== 'directory') {\n throw this.error(\n 'io',\n 'create-directory',\n canonical,\n 'The legacy provider did not create the directory.',\n );\n }\n return copyDirectorySnapshot(created);\n });\n }\n\n public async remove(\n path: WorkspacePath,\n options: FileSystemRemoveOptions = {},\n ): Promise<FileSystemRemoveResult> {\n const canonical = this.canonicalNonRoot(path, 'remove');\n return this.enqueue('remove', async () => {\n const tree = await this.captureTree('remove');\n const existing = tree.entries.get(canonical);\n if (!existing) {\n if ((options.missing ?? 'error') === 'ignore') {\n return Object.freeze({ removed: false, version: tree.version });\n }\n throw this.error('not-found', 'remove', canonical, 'Entry does not exist.');\n }\n this.assertExpectedVersion(existing, options.expectedVersion, 'remove', canonical);\n if (\n existing.kind === 'directory' &&\n !options.recursive &&\n [...tree.entries.keys()].some((candidate) =>\n workspacePathContains(canonical, candidate, false),\n )\n ) {\n throw this.error('not-empty', 'remove', canonical, 'Directory is not empty.');\n }\n\n await this.invoke(\n () => this.provider.delete(workspacePathToLegacy(canonical)),\n 'remove',\n canonical,\n );\n const after = await this.captureTree('remove');\n if (\n [...after.entries.keys()].some((candidate) => workspacePathContains(canonical, candidate))\n ) {\n throw this.error(\n 'io',\n 'remove',\n canonical,\n 'The legacy provider did not remove the complete entry.',\n );\n }\n return Object.freeze({ removed: true, version: after.version });\n });\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options: FileSystemMoveOptions = {},\n ): Promise<FileSystemEntrySnapshot> {\n const sourcePath = this.canonicalNonRoot(oldPath, 'move');\n const destinationPath = this.canonicalNonRoot(newPath, 'move');\n return this.enqueue('move', async () => {\n const tree = await this.captureTree('move');\n const source = tree.entries.get(sourcePath);\n if (!source) throw this.error('not-found', 'move', sourcePath, 'Source does not exist.');\n this.assertExpectedVersion(source, options.expectedVersion, 'move', sourcePath);\n if (sourcePath === destinationPath) return copyEntrySnapshot(source);\n if (tree.entries.has(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 this.assertParents(tree, destinationPath, options.createParents ?? false, 'move');\n\n const sourceEntries = [...tree.entries.entries()].filter(([candidate]) =>\n workspacePathContains(sourcePath, candidate),\n );\n await this.invoke(\n () =>\n this.provider.rename(\n workspacePathToLegacy(sourcePath),\n workspacePathToLegacy(destinationPath),\n ),\n 'move',\n sourcePath,\n destinationPath,\n );\n\n const after = await this.captureTree('move');\n if (\n [...after.entries.keys()].some((candidate) => workspacePathContains(sourcePath, candidate))\n ) {\n throw this.error(\n 'io',\n 'move',\n sourcePath,\n 'The legacy provider left source entries behind.',\n );\n }\n for (const [oldEntryPath, oldEntry] of sourceEntries) {\n const suffix = oldEntryPath.slice(sourcePath.length);\n const movedPath = parseWorkspacePath(`${destinationPath}${suffix}`);\n const moved = after.entries.get(movedPath);\n if (!moved || moved.kind !== oldEntry.kind || moved.version !== oldEntry.version) {\n throw new FsError(\n 'io',\n 'The legacy provider did not move the complete entry unchanged.',\n {\n operation: 'move',\n path: oldEntryPath,\n destinationPath: movedPath,\n },\n );\n }\n }\n return copyEntrySnapshot(after.entries.get(destinationPath)!);\n });\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.enqueue('snapshot', async () => {\n const tree = await this.captureTree('snapshot');\n const entries = [...tree.entries.values()]\n .sort((left, right) => compareText(left.path, right.path))\n .map((entry) => copySnapshotEntry(entry));\n return Object.freeze({ version: tree.version, entries: Object.freeze(entries) });\n });\n }\n\n public watch(\n _listener: FileSystemWatchListener,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertAccepting('watch');\n const error = new FsError(\n 'not-supported',\n 'The legacy adapter cannot observe external changes.',\n {\n operation: 'watch',\n },\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.closing = true;\n const run = this.operationTail.then(async () => {\n try {\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n await this.options.dispose?.();\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation: 'dispose' });\n } finally {\n this.disposed = true;\n }\n });\n this.operationTail = run.then(\n () => undefined,\n () => undefined,\n );\n this.disposePromise = run;\n return run;\n }\n\n private enqueue<T>(operation: FsOperation, task: () => Promise<T>): Promise<T> {\n this.assertAccepting(operation);\n const run = this.operationTail.then(task);\n this.operationTail = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n private assertAccepting(operation: FsOperation): void {\n if (!this.closing && !this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n\n private canonical(path: WorkspacePath): WorkspacePath {\n return parseWorkspacePath(path);\n }\n\n private canonicalNonRoot(path: WorkspacePath, operation: FsOperation): WorkspacePath {\n const canonical = this.canonical(path);\n if (!canonical) {\n throw this.error(\n 'invalid-path',\n operation,\n canonical,\n 'The workspace root is not an entry target.',\n );\n }\n return canonical;\n }\n\n private assertExpectedVersion(\n entry: FileSystemSnapshotEntry | undefined,\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 assertParents(\n tree: CapturedTree,\n path: WorkspacePath,\n createParents: boolean,\n operation: FsOperation,\n ): void {\n let parent = workspacePathDirname(path);\n const parents: WorkspacePath[] = [];\n while (parent) {\n parents.unshift(parent);\n parent = workspacePathDirname(parent);\n }\n for (const candidate of parents) {\n const entry = tree.entries.get(candidate);\n if (entry?.kind === 'file') {\n throw this.error('type-mismatch', operation, candidate, 'A parent path is a file.');\n }\n if (!entry && !createParents) {\n throw this.error('not-found', operation, candidate, 'Parent directory does not exist.');\n }\n }\n }\n\n private async captureTree(operation: FsOperation): Promise<CapturedTree> {\n const entries = new Map<WorkspacePath, FileSystemSnapshotEntry>();\n const visiting = new Set<WorkspacePath>();\n\n const visitDirectory = async (path: WorkspacePath): Promise<FileSystemDirectorySnapshot> => {\n if (visiting.has(path)) {\n throw this.error('io', operation, path, 'The legacy provider returned a directory cycle.');\n }\n visiting.add(path);\n const listed = await this.invoke(\n () => this.provider.readDirectory(workspacePathToLegacy(path)),\n operation,\n path,\n );\n if (!Array.isArray(listed)) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned an invalid directory listing.',\n );\n }\n const children: FileSystemSnapshotEntry[] = [];\n const seen = new Set<WorkspacePath>();\n for (const candidate of listed as readonly unknown[]) {\n if (!isLegacyEntry(candidate)) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned an invalid directory entry.',\n );\n }\n const legacyEntry = candidate;\n const childPath = parseWorkspacePath(legacyEntry.path);\n if (\n !childPath ||\n workspacePathDirname(childPath) !== path ||\n workspacePathBasename(childPath) !== legacyEntry.name\n ) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned a non-child entry.',\n );\n }\n if (seen.has(childPath) || entries.has(childPath)) {\n throw this.error(\n 'io',\n operation,\n childPath,\n 'The legacy provider returned duplicate entry paths.',\n );\n }\n seen.add(childPath);\n\n if (legacyEntry.kind === 'directory') {\n children.push(await visitDirectory(childPath));\n } else {\n const file = await this.captureFile(childPath, operation);\n entries.set(childPath, file);\n children.push(file);\n }\n }\n children.sort(compareSnapshots);\n const version = await contentVersion(\n 'directory',\n new TextEncoder().encode(\n children\n .map((child) => `${child.kind}\\0${child.name.length}:${child.name}\\0${child.version}`)\n .join('\\n'),\n ),\n operation,\n path,\n );\n const directory = Object.freeze({\n kind: 'directory' as const,\n path,\n name: workspacePathBasename(path),\n size: null,\n version,\n lastModified: newestLastModified(children),\n });\n entries.set(path, directory);\n visiting.delete(path);\n return directory;\n };\n\n const root = await visitDirectory(WORKSPACE_ROOT);\n return { entries, version: root.version };\n }\n\n private async captureFile(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<FileSystemSnapshotFile> {\n const legacyPath = workspacePathToLegacy(path);\n let data: ArrayBuffer | null;\n if (this.options.payloadModel === 'binary-authoritative') {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n data = binary ? binary.slice(0) : null;\n } else if (this.options.payloadModel === 'binary-first-text-fallback') {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n if (binary) {\n data = binary.slice(0);\n } else {\n const text = await this.invoke(() => this.provider.readFile(legacyPath), operation, path);\n data = text === null ? null : new TextEncoder().encode(text).buffer;\n }\n } else {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n const text = await this.invoke(() => this.provider.readFile(legacyPath), operation, path);\n if (binary !== null && text !== null) {\n throw this.error(\n 'conflict',\n operation,\n path,\n 'The split legacy store contains both text and binary payloads.',\n );\n }\n data = binary\n ? binary.slice(0)\n : text === null\n ? null\n : new TextEncoder().encode(text).buffer;\n }\n if (!data) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider listed a file without a payload.',\n );\n }\n\n const meta = await this.invoke(() => this.provider.stat(legacyPath), operation, path);\n if (\n !meta ||\n parseWorkspacePath(meta.path) !== path ||\n meta.name !== workspacePathBasename(path) ||\n meta.size !== data.byteLength ||\n !Number.isFinite(Date.parse(meta.lastModified))\n ) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned inconsistent file metadata.',\n );\n }\n return Object.freeze({\n kind: 'file' as const,\n path,\n name: workspacePathBasename(path),\n size: data.byteLength,\n version: await contentVersion('file', new Uint8Array(data), operation, path),\n lastModified: meta.lastModified,\n data,\n });\n }\n\n private async invoke<T>(\n task: () => Promise<T>,\n operation: FsOperation,\n path?: WorkspacePath,\n destinationPath?: WorkspacePath,\n ): Promise<T> {\n try {\n return await task();\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path, destinationPath });\n }\n }\n\n private error(\n code: ConstructorParameters<typeof FsError>[0],\n operation: FsOperation,\n path: WorkspacePath,\n message: string,\n ): FsError {\n return new FsError(code, message, { operation, path });\n }\n}\n\nasync function contentVersion(\n kind: 'file' | 'directory',\n data: Uint8Array,\n operation: FsOperation,\n path: WorkspacePath,\n): Promise<FileSystemVersion> {\n const prefix = new TextEncoder().encode(`${kind}\\0`);\n const input = new Uint8Array(prefix.byteLength + data.byteLength);\n input.set(prefix);\n input.set(data, prefix.byteLength);\n let digest: ArrayBuffer;\n try {\n digest = await globalThis.crypto.subtle.digest('SHA-256', input.buffer as ArrayBuffer);\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path, defaultCode: 'not-supported' });\n }\n const hex = [...new Uint8Array(digest)]\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('');\n return parseFileSystemVersion(`sha256:${hex}`);\n}\n\nfunction isLegacyEntry(value: unknown): value is FileSystemEntry {\n if (!value || typeof value !== 'object') return false;\n const candidate = value as Partial<Record<keyof FileSystemEntry, unknown>>;\n return (\n (candidate.kind === 'file' || candidate.kind === 'directory') &&\n typeof candidate.name === 'string' &&\n typeof candidate.path === 'string'\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 equalBytes(left: ArrayBuffer, right: ArrayBuffer): boolean {\n const leftBytes = new Uint8Array(left);\n const rightBytes = new Uint8Array(right);\n return (\n leftBytes.byteLength === rightBytes.byteLength &&\n leftBytes.every((value, index) => value === rightBytes[index])\n );\n}\n\nfunction fileMetadata(file: FileSystemSnapshotFile): FileSystemFileSnapshot {\n return Object.freeze({\n kind: 'file',\n path: file.path,\n name: file.name,\n size: file.size,\n version: file.version,\n lastModified: file.lastModified,\n });\n}\n\nfunction copyDirectorySnapshot(\n directory: FileSystemDirectorySnapshot,\n): FileSystemDirectorySnapshot {\n return Object.freeze({ ...directory });\n}\n\nfunction copyEntrySnapshot(entry: FileSystemSnapshotEntry): FileSystemEntrySnapshot {\n return entry.kind === 'file' ? fileMetadata(entry) : copyDirectorySnapshot(entry);\n}\n\nfunction copySnapshotEntry(entry: FileSystemSnapshotEntry): FileSystemSnapshotEntry {\n return entry.kind === 'file'\n ? Object.freeze({ ...fileMetadata(entry), data: entry.data.slice(0) })\n : copyDirectorySnapshot(entry);\n}\n\nfunction newestLastModified(children: readonly FileSystemSnapshotEntry[]): string {\n let newest = 0;\n for (const child of children) {\n const timestamp = Date.parse(child.lastModified);\n if (Number.isFinite(timestamp)) newest = Math.max(newest, timestamp);\n }\n return newest ? new Date(newest).toISOString() : EPOCH;\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","import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';\nimport {\n describeEntryMove,\n describePartialMove,\n FileSystemMoveRecoveryError,\n FileSystemPartialMoveError,\n} from './move-error.js';\nimport { parseWorkspacePath } from './workspace-path.js';\n\nfunction normalisePath(path: string): string {\n return parseWorkspacePath(path);\n}\n\nfunction dirname(path: string): string {\n const slash = path.lastIndexOf('/');\n return slash < 0 ? '' : path.slice(0, slash);\n}\n\nfunction basename(path: string): string {\n const slash = path.lastIndexOf('/');\n return slash < 0 ? path : path.slice(slash + 1);\n}\n\n/** Return the hidden companion directory used for a document's media and versions. */\nexport function documentCompanionPath(documentPath: string): string {\n const rooted = documentPath.replace(/\\\\/g, '/').startsWith('/');\n const clean = parseWorkspacePath(documentPath);\n if (!clean) throw new Error('The workspace root has no document companion path.');\n const parent = dirname(clean);\n const name = basename(clean).replace(/\\.[^.]+$/, '');\n if (parent) return `${parent}/${name}_files`;\n return rooted ? `/${name}_files` : `${name}_files`;\n}\n\nfunction isMarkdownPath(path: string): boolean {\n return /\\.md$/i.test(basename(path));\n}\n\n/**\n * Move an explorer entry without overwriting an existing entry. Markdown files\n * carry their hidden `<basename>_files` companion directory with them.\n */\nexport async function moveFileSystemEntry(\n provider: FileSystemProvider,\n oldPath: string,\n newPath: string,\n kind: 'file' | 'directory',\n): Promise<void> {\n const providerV2 = getFileSystemProviderV2(provider);\n const exists = (candidate: string): Promise<boolean> =>\n providerV2\n ? providerV2.stat(parseWorkspacePath(candidate)).then((entry) => entry !== null)\n : provider.exists(candidate);\n const move = (source: string, destination: string): Promise<void> =>\n providerV2\n ? providerV2\n .move(parseWorkspacePath(source), parseWorkspacePath(destination), {\n createParents: true,\n })\n .then(() => undefined)\n : provider.rename(source, destination);\n\n const oldNormalised = normalisePath(oldPath);\n const newNormalised = normalisePath(newPath);\n if (oldNormalised === newNormalised) return;\n\n if (kind === 'directory' && newNormalised.startsWith(`${oldNormalised}/`)) {\n throw new Error('A folder cannot be moved into itself.');\n }\n if (await exists(newPath)) {\n throw new Error(`An entry named \"${basename(newPath)}\" already exists there.`);\n }\n\n let oldCompanion: string | null = null;\n let newCompanion: string | null = null;\n if (kind === 'file' && isMarkdownPath(oldPath)) {\n const candidate = documentCompanionPath(oldPath);\n if (await exists(candidate)) {\n oldCompanion = candidate;\n newCompanion = documentCompanionPath(newPath);\n if (\n normalisePath(oldCompanion) !== normalisePath(newCompanion) &&\n (await exists(newCompanion))\n ) {\n throw new Error(`The companion folder \"${basename(newCompanion)}\" already exists there.`);\n }\n }\n }\n\n try {\n await move(oldPath, newPath);\n } catch (error: unknown) {\n const state = await describeEntryMove(provider, oldPath, newPath);\n if (state.source === 'present' && state.destination === 'missing') throw error;\n throw new FileSystemMoveRecoveryError(oldPath, newPath, state, error);\n }\n if (!oldCompanion || !newCompanion) return;\n\n try {\n await move(oldCompanion, newCompanion);\n } catch (error: unknown) {\n // Keep the document and its assets together when the second half fails.\n try {\n await move(newPath, oldPath);\n } catch (rollbackError: unknown) {\n const state = await describePartialMove(\n provider,\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n );\n throw new FileSystemPartialMoveError(\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n state,\n error,\n rollbackError,\n );\n }\n const state = await describePartialMove(provider, oldPath, newPath, oldCompanion, newCompanion);\n const restoredSourceOnly =\n state.source === 'present' &&\n state.destination === 'missing' &&\n state.companionSource === 'present' &&\n state.companionDestination === 'missing';\n if (!restoredSourceOnly) {\n throw new FileSystemPartialMoveError(\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n state,\n error,\n null,\n );\n }\n throw error;\n }\n}\n","import type { ContentContainer } from '@bendyline/squisq/storage';\nimport { documentCompanionPath } from './move-entry.js';\nimport type {\n MemoryFileSystemProvider,\n MemoryFileSystemSnapshot,\n MemoryFileSystemSnapshotFile,\n} from './memory-provider.js';\n\nexport type DbkWorkspaceAssetLayout = 'auto' | 'preserve' | 'companion';\n\nexport interface DbkWorkspaceSnapshotOptions {\n /** Provider-relative path of the transient workspace's active markdown file. */\n targetDocumentPath: string;\n /**\n * `preserve` treats the DBK as a serialized workspace tree. `companion`\n * rebases non-document files beneath `<document>_files/`. `auto` preserves\n * a DBK whose primary path already matches the target, otherwise rebasing\n * imported media into the companion directory.\n */\n assetLayout?: DbkWorkspaceAssetLayout;\n}\n\nexport interface DbkWorkspaceSnapshot extends MemoryFileSystemSnapshot {\n readonly sourceDocumentPath: string;\n readonly targetDocumentPath: string;\n readonly documentContent: string;\n readonly assetLayout: Exclude<DbkWorkspaceAssetLayout, 'auto'>;\n}\n\nfunction normaliseRelativePath(path: string, label: string): string {\n if (path.includes('\\\\') || path.includes('\\0')) {\n throw new Error(`DBK ${label} must use a safe forward-slash path: ${path}`);\n }\n const normalized = path.replace(/^\\/+|\\/+$/g, '').replace(/\\/+/g, '/');\n const segments = normalized ? normalized.split('/') : [];\n if (segments.length === 0 || segments.some((segment) => segment === '.' || segment === '..')) {\n throw new Error(`DBK ${label} must not be empty or traverse directories: ${path}`);\n }\n return segments.join('/');\n}\n\nfunction joinPath(parent: string, child: string): string {\n return `${parent.replace(/\\/+$/g, '')}/${child.replace(/^\\/+/, '')}`;\n}\n\n/**\n * Fully materialize and validate a DBK container before touching its target\n * provider. A missing or unreadable entry fails the snapshot as a whole.\n */\nexport async function createDbkWorkspaceSnapshot(\n source: ContentContainer,\n options: DbkWorkspaceSnapshotOptions,\n): Promise<DbkWorkspaceSnapshot> {\n const targetDocumentPath = normaliseRelativePath(\n options.targetDocumentPath,\n 'target document path',\n );\n const discoveredDocumentPath = await source.getDocumentPath();\n if (!discoveredDocumentPath)\n throw new Error('The external DBK has no primary markdown document.');\n const sourceDocumentPath = normaliseRelativePath(discoveredDocumentPath, 'primary document path');\n const requestedLayout = options.assetLayout ?? 'auto';\n const assetLayout: Exclude<DbkWorkspaceAssetLayout, 'auto'> =\n requestedLayout === 'auto'\n ? sourceDocumentPath === targetDocumentPath\n ? 'preserve'\n : 'companion'\n : requestedLayout;\n const companionPath = normaliseRelativePath(\n documentCompanionPath(targetDocumentPath),\n 'companion directory path',\n );\n\n const listed = await source.listFiles();\n const entries = [...listed].sort((a, b) => a.path.localeCompare(b.path));\n const seenSourcePaths = new Set<string>();\n const files: MemoryFileSystemSnapshotFile[] = [];\n let documentContent: string | null = null;\n\n for (const entry of entries) {\n const sourcePath = normaliseRelativePath(entry.path, 'entry path');\n if (seenSourcePaths.has(sourcePath)) {\n throw new Error(`The external DBK contains duplicate paths: ${sourcePath}`);\n }\n seenSourcePaths.add(sourcePath);\n\n const data = await source.readFile(entry.path);\n if (data === null) {\n throw new Error(`The external DBK changed while reading: ${sourcePath}`);\n }\n if (sourcePath === sourceDocumentPath) {\n documentContent = new TextDecoder().decode(data);\n files.push({ kind: 'text', path: targetDocumentPath, content: documentContent });\n continue;\n }\n\n const targetPath =\n assetLayout === 'preserve' ? sourcePath : joinPath(companionPath, sourcePath);\n if (/\\.(?:md|mdx|txt)$/i.test(sourcePath)) {\n files.push({ kind: 'text', path: targetPath, content: new TextDecoder().decode(data) });\n } else {\n files.push({ kind: 'binary', path: targetPath, data });\n }\n }\n\n if (documentContent === null) {\n throw new Error(`The external DBK did not include its primary document: ${sourceDocumentPath}`);\n }\n\n return {\n sourceDocumentPath,\n targetDocumentPath,\n documentContent,\n assetLayout,\n files,\n };\n}\n\n/**\n * Replace a transient DBK workspace as one logical operation.\n *\n * Container reads and validation happen before provider mutation. The memory\n * provider then stages and swaps the full tree synchronously, which removes\n * stale files and guarantees the old tree survives any failed replacement.\n */\nexport async function replaceMemoryWorkspaceFromDbk(\n provider: MemoryFileSystemProvider,\n source: ContentContainer,\n options: DbkWorkspaceSnapshotOptions,\n): Promise<DbkWorkspaceSnapshot> {\n const expectedTreeVersion = provider.treeVersion;\n const snapshot = await createDbkWorkspaceSnapshot(source, options);\n provider.replaceContents(snapshot, expectedTreeVersion);\n return snapshot;\n}\n","/**\n * FileSystemContentContainer — a ContentContainer backed by any\n * FileSystemProvider, scoped to a sub-path (e.g., \".docblocks/media/\").\n *\n * Used by the Electron desktop app so media lives inside the workspace\n * folder (visible as regular files) rather than in a separate IndexedDB\n * origin that only the app can see.\n */\n\nimport type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';\nimport { findDocumentPath } from '@bendyline/squisq/storage';\nimport { FsError } from './fs-error.js';\nimport { getFileSystemProviderV2, type FileSystemProvider } from './types.js';\nimport { parseWorkspacePath, workspacePathContains, workspacePathJoin } from './workspace-path.js';\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\nfunction joinPrefix(prefix: string, p: string): string {\n return workspacePathJoin(parseWorkspacePath(prefix), p);\n}\n\nexport class FileSystemContentContainer implements ContentContainer {\n private readonly prefix: string;\n\n constructor(\n private readonly provider: FileSystemProvider,\n prefix = '.docblocks/media',\n ) {\n this.prefix = parseWorkspacePath(prefix);\n }\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) return (await providerV2.readFile(parseWorkspacePath(full)))?.data ?? null;\n const binary = await this.provider.readBinary(full);\n if (binary) return binary;\n // IndexedDB-backed workspaces store text via `writeFile(string)` and\n // binary via `writeBinary(ArrayBuffer)` under separate keys, so a\n // markdown file written through the text API is invisible to\n // `readBinary`. Fall back to text-then-UTF-8 so consumers like the\n // recursive HTML export can resolve sibling `.md` links uniformly\n // across browser and native workspaces.\n const text = await this.provider.readFile(full);\n if (text === null) return null;\n return new TextEncoder().encode(text).buffer as ArrayBuffer;\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) {\n await providerV2.writeFile(parseWorkspacePath(full), data, {\n mode: 'upsert',\n createParents: true,\n });\n return;\n }\n await this.provider.writeBinary(full, data);\n }\n\n async removeFile(path: string): Promise<void> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) {\n await providerV2.remove(parseWorkspacePath(full), { missing: 'ignore' });\n return;\n }\n await this.provider.delete(full);\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n const providerV2 = getFileSystemProviderV2(this.provider);\n const root = parseWorkspacePath(this.prefix);\n type ListedEntry = {\n readonly kind: 'file' | 'directory';\n readonly path: string;\n readonly size?: number | null;\n };\n const walk = async (dir: string) => {\n let children: readonly ListedEntry[];\n try {\n children = providerV2\n ? await providerV2.readDirectory(parseWorkspacePath(dir))\n : await this.provider.readDirectory(dir);\n } catch (error: unknown) {\n // An absent container root means an empty container. Every other\n // storage fault (including a subtree disappearing mid-snapshot)\n // remains observable to backup/export callers.\n if (dir === root && error instanceof FsError && error.code === 'not-found') return;\n throw error;\n }\n for (const child of children) {\n if (child.kind === 'directory') {\n await walk(child.path);\n } else {\n const childPath = parseWorkspacePath(child.path);\n const prefixPath = parseWorkspacePath(this.prefix);\n if (!workspacePathContains(prefixPath, childPath)) continue;\n const rel = childPath === prefixPath ? '' : childPath.slice(prefixPath.length + 1);\n if (prefix && !rel.startsWith(prefix)) continue;\n const size = child.size ?? (await this.provider.stat(child.path))?.size ?? 0;\n entries.push({\n path: rel,\n mimeType: guessMimeType(rel),\n size,\n });\n }\n }\n };\n await walk(root);\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n return providerV2\n ? (await providerV2.stat(parseWorkspacePath(full))) !== null\n : this.provider.exists(full);\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","/**\n * createFileMediaProvider — per-file media storage following the pandoc /\n * Word convention: a markdown file `notes.md` gets a sibling folder\n * `notes_files/` that holds its images, audio, and video.\n *\n * Given:\n * • `container` — a ContentContainer scoped to the markdown file's\n * parent directory (so `readFile('notes_files/image.png')` maps to the\n * parent-relative path)\n * • `markdownBasename` — e.g. `\"notes.md\"`\n *\n * Returns a MediaProvider that:\n * • Writes new media under `{basename}_files/{name}` in the parent dir\n * • Returns the folder-qualified path (`notes_files/image.png`) from\n * addMedia so the markdown stays portable outside DocBlocks\n * • Resolves both bare (`image.png`) and folder-qualified\n * (`notes_files/image.png`) references — so legacy markdown and\n * exports from other tools both work\n */\n\nimport type { MediaProvider, MediaEntry } from '@bendyline/squisq/schemas';\nimport type { ContentContainer } from '@bendyline/squisq/storage';\n\nfunction stripExt(name: string): string {\n return name.replace(/\\.[^.]+$/, '');\n}\n\nexport function createFileMediaProvider(\n container: ContentContainer,\n markdownBasename: string,\n): MediaProvider {\n const folder = stripExt(markdownBasename) + '_files';\n const prefix = folder + '/';\n const blobUrlCache = new Map<string, string>();\n\n function toKey(ref: string): string {\n const clean = ref.replace(/^\\/+/, '');\n return clean.startsWith(prefix) ? clean : prefix + clean;\n }\n\n return {\n async resolveUrl(ref: string): Promise<string> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) return cached;\n\n const data = await container.readFile(key);\n if (!data) return ref;\n\n const entries = await container.listFiles();\n const entry = entries.find((e) => e.path === key);\n const mimeType = entry?.mimeType ?? 'application/octet-stream';\n\n const url = URL.createObjectURL(new Blob([data], { type: mimeType }));\n blobUrlCache.set(key, url);\n return url;\n },\n\n async listMedia(): Promise<MediaEntry[]> {\n const entries = await container.listFiles(prefix);\n return entries\n .filter((e) => !e.path.toLowerCase().endsWith('.md'))\n .map((e) => ({\n name: e.path,\n mimeType: e.mimeType,\n size: e.size,\n }));\n },\n\n async addMedia(\n name: string,\n data: ArrayBuffer | Blob | Uint8Array,\n mimeType: string,\n ): Promise<string> {\n const key = toKey(name);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n const buffer = data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data;\n await container.writeFile(key, buffer, mimeType);\n return key;\n },\n\n async removeMedia(ref: string): Promise<void> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n await container.removeFile(key);\n },\n\n dispose(): void {\n for (const url of blobUrlCache.values()) {\n URL.revokeObjectURL(url);\n }\n blobUrlCache.clear();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAM,SAAQ,oBAAI,KAAK,CAAC,GAAE,YAAY;AAU/B,IAAM,oCAAN,MAAwE;AAAA,EAWtE,YACY,UACA,SACjB;AAFiB;AACA;AARnB,SAAQ,gBAA+B,QAAQ,QAAQ;AACvD,SAAiB,gBAAgB,oBAAI,IAAiC;AACtE,SAAQ,UAAU;AAClB,SAAQ,WAAW;AACnB,SAAQ,iBAAuC;AAM7C,SAAK,KAAK,SAAS;AACnB,SAAK,QAAQ,SAAS;AACtB,SAAK,eAAe,OAAO,OAAO;AAAA,MAChC,gBAAgB,QAAQ,kBAAkB;AAAA,MAC1C,eAAe,QAAQ,iBAAiB;AAAA;AAAA;AAAA,MAGxC,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,iBAAiB,QAAQ,mBAAmB;AAAA,MAC5C,eAAe,QAAQ,iBAAiB;AAAA,MACxC,YAAY,QAA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ACvC,YAAM,UAAU,MAAM,UAAU,UAAU,MAAM;AAChD,aAAO,QACJ,OAAO,CAAC,MAAM,CAAC,EAAE,KAAK,YAAY,EAAE,SAAS,KAAK,CAAC,EACnD,IAAI,CAAC,OAAO;AAAA,QACX,MAAM,EAAE;AAAA,QACR,UAAU,EAAE;AAAA,QACZ,MAAM,EAAE;AAAA,MACV,EAAE;AAAA,IACN;AAAA,IAEA,MAAM,SACJ,MACA,MACA,UACiB;AACjB,YAAM,MAAM,MAAM,IAAI;AACtB,YAAM,SAAS,aAAa,IAAI,GAAG;AACnC,UAAI,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,qBAAa,OAAO,GAAG;AAAA,MACzB;AACA,YAAM,SAAS,gBAAgB,OAAO,IAAI,WAAW,MAAM,KAAK,YAAY,CAAC,IAAI;AACjF,YAAM,UAAU,UAAU,KAAK,QAAQ,QAAQ;AAC/C,aAAO;AAAA,IACT;AAAA,IAEA,MAAM,YAAY,KAA4B;AAC5C,YAAM,MAAM,MAAM,GAAG;AACrB,YAAM,SAAS,aAAa,IAAI,GAAG;AACnC,UAAI,QAAQ;AACV,YAAI,gBAAgB,MAAM;AAC1B,qBAAa,OAAO,GAAG;AAAA,MACzB;AACA,YAAM,UAAU,WAAW,GAAG;AAAA,IAChC;AAAA,IAEA,UAAgB;AACd,iBAAW,OAAO,aAAa,OAAO,GAAG;AACvC,YAAI,gBAAgB,GAAG;AAAA,MACzB;AACA,mBAAa,MAAM;AAAA,IACrB;AAAA,EACF;AACF;","names":["state"]}
@@ -1,20 +0,0 @@
1
- // src/filesystem/v2.ts
2
- function parseFileSystemVersion(value) {
3
- if (typeof value !== "string" || !value || value.length > 1024 || value.includes("\0")) {
4
- throw new TypeError("Filesystem version tokens must be non-empty bounded strings.");
5
- }
6
- return value;
7
- }
8
- function tryParseFileSystemVersion(value) {
9
- try {
10
- return parseFileSystemVersion(value);
11
- } catch {
12
- return null;
13
- }
14
- }
15
-
16
- export {
17
- parseFileSystemVersion,
18
- tryParseFileSystemVersion
19
- };
20
- //# sourceMappingURL=chunk-AYZ4HN5M.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/v2.ts"],"sourcesContent":["import type { FsError } from './fs-error.js';\nimport type { WorkspacePath } from './workspace-path.js';\n\n/**\n * Opaque provider-issued token representing one observed entry/tree state.\n * Tokens support equality only within the issuing provider; callers must not\n * parse them or assume a move or byte-identical rewrite changes the token.\n * A token need not be a content hash, but it must change whenever the issuing\n * provider observes a potentially different kind, payload, or descendant\n * state. Detection of non-cooperating external changes is bounded by the\n * backend's declared capabilities and metadata precision.\n */\ndeclare const fileSystemVersionBrand: unique symbol;\nexport type FileSystemVersion = string & {\n readonly [fileSystemVersionBrand]: 'FileSystemVersion';\n};\n\n/** Validate/rebrand a version received from a provider transport. */\nexport function parseFileSystemVersion(value: unknown): FileSystemVersion {\n if (typeof value !== 'string' || !value || value.length > 1024 || value.includes('\\0')) {\n throw new TypeError('Filesystem version tokens must be non-empty bounded strings.');\n }\n return value as FileSystemVersion;\n}\n\nexport function tryParseFileSystemVersion(value: unknown): FileSystemVersion | null {\n try {\n return parseFileSystemVersion(value);\n } catch {\n return null;\n }\n}\n\n/** `process` excludes this provider's local peers; `cross-context` also excludes cooperating tabs/processes. */\nexport type FileSystemAtomicity = 'none' | 'process' | 'cross-context';\nexport type FileSystemCaseSensitivity = 'sensitive' | 'insensitive' | 'platform';\nexport type FileSystemDurability = 'volatile' | 'best-effort' | 'durable';\nexport type FileSystemConditionalWriteStrength =\n | 'none'\n | 'process'\n | 'cross-context'\n | 'storage-atomic';\nexport type FileSystemSymlinkPolicy = 'unsupported' | 'reject' | 'follow-contained' | 'preserve';\n\n/** Serializable feature declaration; consumers never need provider instanceof checks. */\nexport interface FileSystemProviderCapabilities {\n /** Isolation of one successful file replacement from cooperating writers. */\n readonly writeAtomicity: FileSystemAtomicity;\n /** Isolation of one successful source-to-destination move. */\n readonly moveAtomicity: FileSystemAtomicity;\n /** Writers excluded while one complete snapshot is captured. */\n readonly snapshotAtomicity: FileSystemAtomicity;\n /** Strongest boundary at which expectedVersion is checked with mutation. */\n readonly conditionalWrite: FileSystemConditionalWriteStrength;\n readonly recursiveRemove: boolean;\n /** True only when watch has a real ready barrier and sequenced events. */\n readonly watch: boolean;\n readonly caseSensitivity: FileSystemCaseSensitivity;\n readonly symlinkPolicy: FileSystemSymlinkPolicy;\n readonly durability: FileSystemDurability;\n}\n\ninterface FileSystemEntrySnapshotBase {\n readonly path: WorkspacePath;\n readonly name: string;\n readonly version: FileSystemVersion;\n /** ISO-8601 timestamp supplied by the backend; versions remain authoritative. */\n readonly lastModified: string;\n}\n\nexport interface FileSystemFileSnapshot extends FileSystemEntrySnapshotBase {\n readonly kind: 'file';\n readonly size: number;\n}\n\nexport interface FileSystemDirectorySnapshot extends FileSystemEntrySnapshotBase {\n readonly kind: 'directory';\n readonly size: null;\n}\n\nexport type FileSystemEntrySnapshot = FileSystemFileSnapshot | FileSystemDirectorySnapshot;\n\n/** A read always couples owned bytes to the exact metadata version they represent. */\nexport interface FileSystemFileRead {\n readonly entry: FileSystemFileSnapshot;\n readonly data: ArrayBuffer;\n}\n\nexport interface FileSystemSnapshotFile extends FileSystemFileSnapshot {\n readonly data: ArrayBuffer;\n}\n\nexport type FileSystemSnapshotEntry = FileSystemSnapshotFile | FileSystemDirectorySnapshot;\n\n/**\n * Complete best-available tree traversal. `snapshotAtomicity` declares\n * whether concurrent local/cross-context mutations are excluded while it is\n * captured. Implementations must never expose aliased buffers.\n */\nexport interface FileSystemSnapshot {\n readonly version: FileSystemVersion;\n readonly entries: readonly FileSystemSnapshotEntry[];\n}\n\nexport type FileSystemWriteMode = 'upsert' | 'create' | 'replace';\n\nexport interface FileSystemWriteOptions {\n /** Defaults to upsert. */\n readonly mode?: FileSystemWriteMode;\n /** Defaults to false so structure creation is never implicit. */\n readonly createParents?: boolean;\n /** null means the entry must not exist; a token requires an exact match. */\n readonly expectedVersion?: FileSystemVersion | null;\n}\n\nexport type FileSystemCreateDirectoryMode = 'ensure' | 'create';\n\nexport interface FileSystemCreateDirectoryOptions {\n /** Defaults to ensure (idempotently return an existing directory). */\n readonly mode?: FileSystemCreateDirectoryMode;\n /** Defaults to false. */\n readonly createParents?: boolean;\n}\n\nexport interface FileSystemRemoveOptions {\n /** Defaults to false; non-empty directories otherwise fail with not-empty. */\n readonly recursive?: boolean;\n /** Defaults to error. */\n readonly missing?: 'ignore' | 'error';\n readonly expectedVersion?: FileSystemVersion;\n}\n\nexport interface FileSystemRemoveResult {\n readonly removed: boolean;\n /** Version of the complete tree after the removal attempt. */\n readonly version: FileSystemVersion;\n}\n\nexport interface FileSystemMoveOptions {\n /** Defaults to false. Destinations are never overwritten. */\n readonly createParents?: boolean;\n readonly expectedVersion?: FileSystemVersion;\n}\n\nexport type FileSystemWatchEventType = 'created' | 'modified' | 'removed' | 'moved' | 'overflow';\nexport type FileSystemWatchEventOrigin = 'local' | 'external' | 'unknown';\n\ninterface FileSystemWatchEventBase {\n readonly sequence: number;\n readonly origin: FileSystemWatchEventOrigin;\n readonly path: WorkspacePath;\n}\n\nexport interface FileSystemEntryWatchEvent extends FileSystemWatchEventBase {\n readonly type: Exclude<FileSystemWatchEventType, 'overflow'>;\n readonly kind: 'file' | 'directory';\n readonly destinationPath: WorkspacePath | null;\n readonly version: FileSystemVersion | null;\n readonly previousVersion: FileSystemVersion | null;\n}\n\nexport interface FileSystemOverflowWatchEvent extends FileSystemWatchEventBase {\n readonly type: 'overflow';\n readonly kind: null;\n readonly destinationPath: null;\n readonly version: null;\n readonly previousVersion: null;\n}\n\nexport type FileSystemWatchEvent = FileSystemEntryWatchEvent | FileSystemOverflowWatchEvent;\n\nexport type FileSystemWatchListener = (event: FileSystemWatchEvent) => void;\nexport type FileSystemWatchErrorListener = (error: FsError) => void;\n\nexport interface FileSystemWatchOptions {\n readonly onError?: FileSystemWatchErrorListener;\n}\n\nexport interface FileSystemWatchSubscription {\n readonly closed: boolean;\n /** Resolves after the backend watch is installed and no initial event can be missed. */\n readonly ready: Promise<void>;\n /** Idempotent and awaitable so resource release can join provider shutdown. */\n dispose(): Promise<void>;\n}\n\n/**\n * Correctness-first filesystem contract. Every logical path has exactly one\n * kind and one byte payload; conditional writes and lifecycle disposal are\n * mandatory rather than optional provider extensions.\n */\nexport interface FileSystemProviderV2 {\n readonly id: string;\n readonly label: string;\n readonly capabilities: FileSystemProviderCapabilities;\n\n /** Absence is represented only by null; permission/I/O/wrong-kind errors throw FsError. */\n stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null>;\n /** Absence is represented only by null; a directory at path is type-mismatch. */\n readFile(path: WorkspacePath): Promise<FileSystemFileRead | null>;\n /** Missing paths and file paths throw; results are canonical and deterministic. */\n readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]>;\n\n writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options?: FileSystemWriteOptions,\n ): Promise<FileSystemFileSnapshot>;\n createDirectory(\n path: WorkspacePath,\n options?: FileSystemCreateDirectoryOptions,\n ): Promise<FileSystemDirectorySnapshot>;\n remove(path: WorkspacePath, options?: FileSystemRemoveOptions): Promise<FileSystemRemoveResult>;\n move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options?: FileSystemMoveOptions,\n ): Promise<FileSystemEntrySnapshot>;\n\n snapshot(): Promise<FileSystemSnapshot>;\n /**\n * Always returns a disposable subscription. When `capabilities.watch` is\n * false, `ready` rejects with `FsError('not-supported')` and `onError`\n * observes the same failure; callers can therefore use one cleanup path.\n */\n watch(\n listener: FileSystemWatchListener,\n options?: FileSystemWatchOptions,\n ): FileSystemWatchSubscription;\n dispose(): Promise<void>;\n}\n"],"mappings":";AAkBO,SAAS,uBAAuB,OAAmC;AACxE,MAAI,OAAO,UAAU,YAAY,CAAC,SAAS,MAAM,SAAS,QAAQ,MAAM,SAAS,IAAI,GAAG;AACtF,UAAM,IAAI,UAAU,8DAA8D;AAAA,EACpF;AACA,SAAO;AACT;AAEO,SAAS,0BAA0B,OAA0C;AAClF,MAAI;AACF,WAAO,uBAAuB,KAAK;AAAA,EACrC,QAAQ;AACN,WAAO;AAAA,EACT;AACF;","names":[]}