@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,10 +1,16 @@
1
1
  import {
2
2
  ELECTRON_FILE_SYSTEM_V2_CAPABILITIES,
3
3
  maybeGetDocBlocksHost
4
- } from "./chunk-RVQHY3XU.js";
4
+ } from "./chunk-BNKV7MTO.js";
5
5
  import {
6
+ isRecord
7
+ } from "./chunk-U722UUFN.js";
8
+ import {
9
+ compareSnapshotsByPath,
10
+ compareText,
11
+ copyBytes,
6
12
  parseFileSystemVersion
7
- } from "./chunk-AYZ4HN5M.js";
13
+ } from "./chunk-P4WATND4.js";
8
14
  import {
9
15
  FsError,
10
16
  WORKSPACE_ROOT,
@@ -14,7 +20,7 @@ import {
14
20
  parseWorkspacePath,
15
21
  workspacePathBasename,
16
22
  workspacePathDirname
17
- } from "./chunk-SI2LU2RP.js";
23
+ } from "./chunk-JS6XFWQK.js";
18
24
 
19
25
  // src/filesystem/electron-provider-v2.ts
20
26
  var fallbackInstanceSequence = 0;
@@ -327,7 +333,7 @@ function normalizeDirectoryListing(value, parent) {
327
333
  if (seen.has(entry.path)) throw new TypeError("Filesystem listing contained a duplicate path.");
328
334
  seen.add(entry.path);
329
335
  }
330
- const ordered = [...entries].sort(compareDirectoryEntries);
336
+ const ordered = [...entries].sort(compareSnapshotsByPath);
331
337
  if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {
332
338
  throw new TypeError("Filesystem listing was not in canonical deterministic order.");
333
339
  }
@@ -439,13 +445,6 @@ function assertCapabilities(value, operation) {
439
445
  }
440
446
  }
441
447
  }
442
- function compareDirectoryEntries(left, right) {
443
- if (left.kind !== right.kind) return left.kind === "directory" ? -1 : 1;
444
- return compareText(left.path, right.path);
445
- }
446
- function compareText(left, right) {
447
- return left < right ? -1 : left > right ? 1 : 0;
448
- }
449
448
  function isWatchOrigin(value) {
450
449
  return value === "local" || value === "external" || value === "unknown";
451
450
  }
@@ -458,9 +457,6 @@ function isNonNegativeSafeInteger(value) {
458
457
  function isPositiveSafeInteger(value) {
459
458
  return isNonNegativeSafeInteger(value) && value > 0;
460
459
  }
461
- function isRecord(value) {
462
- return typeof value === "object" && value !== null;
463
- }
464
460
  function invalidTransport(operation, message) {
465
461
  return new FsError("io", message, { operation, retryable: false });
466
462
  }
@@ -477,12 +473,6 @@ function withOperation(error, operation) {
477
473
  retryable: error.retryable
478
474
  });
479
475
  }
480
- function copyBytes(data) {
481
- const source = ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
482
- const copy = new Uint8Array(source.byteLength);
483
- copy.set(source);
484
- return copy.buffer;
485
- }
486
476
  function copyWireBuffer(data) {
487
477
  if (Object.prototype.toString.call(data) !== "[object ArrayBuffer]") {
488
478
  throw new TypeError("Expected an ArrayBuffer from the filesystem transport.");
@@ -560,4 +550,4 @@ export {
560
550
  ElectronFileSystemProviderV2,
561
551
  ElectronFileSystemProvider
562
552
  };
563
- //# sourceMappingURL=chunk-GCPBEMMH.js.map
553
+ //# sourceMappingURL=chunk-VTCSF7VS.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/filesystem/electron-provider-v2.ts","../src/filesystem/electron-provider.ts"],"sourcesContent":["import {\n ELECTRON_FILE_SYSTEM_V2_CAPABILITIES,\n maybeGetDocBlocksHost,\n type DocBlocksHostFsV2API,\n type HostFileSystemV2Result,\n type HostFileSystemV2WatchMessage,\n} from '../host/index.js';\nimport {\n FsError,\n deserializeFsError,\n fsErrorFromUnknown,\n isSerializedFsError,\n type FsOperation,\n} from './fs-error.js';\nimport {\n WORKSPACE_ROOT,\n parseWorkspacePath,\n workspacePathBasename,\n workspacePathDirname,\n type WorkspacePath,\n} from './workspace-path.js';\nimport { copyBytes } from './internal/bytes.js';\nimport { compareSnapshotsByPath, compareText } from './internal/entry-order.js';\nimport { isRecord } from './internal/records.js';\nimport {\n parseFileSystemVersion,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\n type FileSystemEntrySnapshot,\n type FileSystemFileRead,\n type FileSystemFileSnapshot,\n type FileSystemMoveOptions,\n type FileSystemProviderCapabilities,\n type FileSystemProviderV2,\n type FileSystemRemoveOptions,\n type FileSystemRemoveResult,\n type FileSystemSnapshot,\n type FileSystemSnapshotEntry,\n type FileSystemWatchEvent,\n type FileSystemWatchOptions,\n type FileSystemWatchSubscription,\n type FileSystemWriteOptions,\n} from './v2.js';\n\ninterface ClientWatcher {\n readonly listener: (event: FileSystemWatchEvent) => void;\n readonly onError: FileSystemWatchOptions['onError'];\n}\n\nlet fallbackInstanceSequence = 0;\n\nfunction getHostFsV2(operation: FsOperation): DocBlocksHostFsV2API {\n const host = maybeGetDocBlocksHost();\n if (!host?.fsV2) {\n throw new FsError('not-supported', 'Electron filesystem v2 host is unavailable.', {\n operation,\n });\n }\n return host.fsV2;\n}\n\n/** Pure renderer-side client for the typed Electron filesystem v2 transport. */\nexport class ElectronFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = ELECTRON_FILE_SYSTEM_V2_CAPABILITIES;\n\n private readonly rootPath: string;\n private readonly instanceId = createInstanceId();\n private readonly watchers = new Map<string, ClientWatcher>();\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private openPromise: Promise<void> | null = null;\n private removeWatchBridge: (() => void) | null = null;\n private disposePromise: Promise<void> | null = null;\n private hostOpened = false;\n private disposed = false;\n\n public constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n }\n\n public getRootPath(): string {\n return this.rootPath;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'stat',\n () => getHostFsV2('stat').stat(this.instanceId, canonical),\n (value) => (value ? normalizeEntry(value) : null),\n );\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'read',\n () => getHostFsV2('read').readFile(this.instanceId, canonical),\n (value) => {\n if (!value) return null;\n const entry = normalizeFile(value.entry);\n const data = copyWireBuffer(value.data);\n if (data.byteLength !== entry.size) {\n throw new TypeError('Filesystem transport returned file bytes with the wrong size.');\n }\n return Object.freeze({ entry, data });\n },\n );\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'list',\n () => getHostFsV2('list').readDirectory(this.instanceId, canonical),\n (value) => normalizeDirectoryListing(value, canonical),\n );\n }\n\n public async writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options?: FileSystemWriteOptions,\n ): Promise<FileSystemFileSnapshot> {\n const canonical = parseWorkspacePath(String(path));\n const owned = copyBytes(data);\n return this.request(\n 'write',\n () => getHostFsV2('write').writeFile(this.instanceId, canonical, owned, options),\n normalizeFile,\n );\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options?: FileSystemCreateDirectoryOptions,\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'create-directory',\n () => getHostFsV2('create-directory').createDirectory(this.instanceId, canonical, options),\n normalizeDirectory,\n );\n }\n\n public async remove(\n path: WorkspacePath,\n options?: FileSystemRemoveOptions,\n ): Promise<FileSystemRemoveResult> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'remove',\n () => getHostFsV2('remove').remove(this.instanceId, canonical, options),\n normalizeRemoveResult,\n );\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options?: FileSystemMoveOptions,\n ): Promise<FileSystemEntrySnapshot> {\n const source = parseWorkspacePath(String(oldPath));\n const destination = parseWorkspacePath(String(newPath));\n return this.request(\n 'move',\n () => getHostFsV2('move').move(this.instanceId, source, destination, options),\n normalizeEntry,\n );\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.request(\n 'snapshot',\n () => getHostFsV2('snapshot').snapshot(this.instanceId),\n normalizeSnapshot,\n );\n }\n\n public watch(\n listener: (event: FileSystemWatchEvent) => void,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n this.ensureWatchBridge();\n const subscriptionId = createInstanceId();\n const watcher: ClientWatcher = { listener, onError: options.onError };\n this.watchers.set(subscriptionId, watcher);\n let closed = false;\n let subscribed = false;\n let closePromise: Promise<void> | null = null;\n const ready = this.ensureOpen('watch')\n .then(async () => {\n if (closed) return;\n unwrap(await getHostFsV2('watch').watchSubscribe(this.instanceId, subscriptionId), 'watch');\n subscribed = true;\n })\n .catch((error: unknown) => {\n closed = true;\n this.watchers.delete(subscriptionId);\n const typed = error instanceof FsError ? error : new FsError('io', String(error));\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n throw typed;\n });\n\n const subscription: FileSystemWatchSubscription = {\n get closed() {\n return closed;\n },\n ready,\n dispose: () => {\n if (closePromise) return closePromise;\n closed = true;\n this.watchers.delete(subscriptionId);\n this.subscriptions.delete(subscription);\n closePromise = (async () => {\n await ready.catch(() => undefined);\n if (subscribed) {\n unwrap(\n await getHostFsV2('watch').watchUnsubscribe(this.instanceId, subscriptionId),\n 'watch',\n );\n }\n })();\n return closePromise;\n },\n };\n this.subscriptions.add(subscription);\n return subscription;\n }\n\n public dispose(): Promise<void> {\n if (this.disposePromise) return this.disposePromise;\n this.disposed = true;\n this.disposePromise = (async () => {\n await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n try {\n if (this.openPromise) {\n try {\n await this.openPromise;\n } catch {\n // A failed request normally creates no host record. `hostOpened`\n // separately tracks a successful open whose response validation\n // failed after the main-side record had already been published.\n }\n }\n if (this.hostOpened) {\n try {\n unwrap(await getHostFsV2('dispose').dispose(this.instanceId), 'dispose');\n } catch (error: unknown) {\n if (!(error instanceof FsError && error.code === 'closed')) throw error;\n } finally {\n this.hostOpened = false;\n }\n }\n } finally {\n this.removeWatchBridge?.();\n this.removeWatchBridge = null;\n }\n })();\n return this.disposePromise;\n }\n\n private request<T, U>(\n operation: FsOperation,\n send: () => Promise<HostFileSystemV2Result<T>>,\n normalize: (value: T) => U,\n ): Promise<U> {\n this.assertOpen(operation);\n const promise = this.ensureOpen(operation).then(async () => {\n try {\n return normalize(unwrap(await send(), operation));\n } catch (error: unknown) {\n throw transportErrorFromUnknown(error, operation);\n }\n });\n this.inFlight.add(promise);\n void promise.then(\n () => this.inFlight.delete(promise),\n () => this.inFlight.delete(promise),\n );\n return promise;\n }\n\n private ensureOpen(operation: FsOperation): Promise<void> {\n this.assertOpen(operation);\n if (!this.openPromise) {\n const attempt = getHostFsV2(operation)\n .open({\n instanceId: this.instanceId,\n providerId: this.id,\n label: this.label,\n })\n .then((result) => {\n if (isRecord(result) && result.ok === true) this.hostOpened = true;\n const capabilities = unwrap(result, operation);\n assertCapabilities(capabilities, operation);\n })\n .catch((error: unknown) => {\n const typed = withOperation(fsErrorFromUnknown(error, { operation }), operation);\n if (typed.retryable && this.openPromise === attempt) this.openPromise = null;\n throw typed;\n });\n this.openPromise = attempt;\n }\n return this.openPromise;\n }\n\n private ensureWatchBridge(): void {\n if (this.removeWatchBridge) return;\n this.removeWatchBridge = getHostFsV2('watch').onWatchMessage((message) =>\n this.handleWatchMessage(message),\n );\n }\n\n private handleWatchMessage(message: HostFileSystemV2WatchMessage): void {\n if (message.instanceId !== this.instanceId) return;\n const watcher = this.watchers.get(message.subscriptionId);\n if (!watcher) return;\n if (message.kind === 'error') {\n const typed = isSerializedFsError(message.error)\n ? deserializeFsError(message.error)\n : invalidTransport('watch', 'Filesystem transport returned an invalid watch error.');\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n return;\n }\n\n let event: FileSystemWatchEvent;\n try {\n event = normalizeWatchEvent(message.event);\n } catch (error: unknown) {\n try {\n watcher.onError?.(transportErrorFromUnknown(error, 'watch'));\n } catch {\n // Isolate observers.\n }\n return;\n }\n try {\n watcher.listener(event);\n } catch {\n // Watch callbacks are observational.\n }\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n}\n\nfunction unwrap<T>(result: HostFileSystemV2Result<T>, operation: FsOperation): T {\n if (!isRecord(result) || typeof result.ok !== 'boolean') {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid result envelope.');\n }\n if (result.ok) {\n if (!('value' in result)) {\n throw invalidTransport(operation, 'Filesystem transport omitted a result value.');\n }\n return result.value;\n }\n if (!isSerializedFsError(result.error)) {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid error envelope.');\n }\n throw deserializeFsError(result.error);\n}\n\nfunction normalizeEntry(entry: FileSystemEntrySnapshot): FileSystemEntrySnapshot {\n if (!isRecord(entry)) throw new TypeError('Expected a filesystem entry object.');\n if (typeof entry.path !== 'string')\n throw new TypeError('Filesystem entry path must be a string.');\n if (typeof entry.name !== 'string')\n throw new TypeError('Filesystem entry name must be a string.');\n if (typeof entry.lastModified !== 'string') {\n throw new TypeError('Filesystem entry timestamp must be a string.');\n }\n const path = parseWorkspacePath(entry.path);\n if (entry.name !== workspacePathBasename(path)) {\n throw new TypeError('Filesystem entry name does not match its canonical path.');\n }\n const common = {\n path,\n name: entry.name,\n version: parseFileSystemVersion(entry.version),\n lastModified: new Date(entry.lastModified).toISOString(),\n };\n if (entry.kind === 'file') {\n if (!isNonNegativeSafeInteger(entry.size)) {\n throw new TypeError('Filesystem file size must be a non-negative safe integer.');\n }\n return Object.freeze({ ...common, kind: 'file', size: entry.size });\n }\n if (entry.kind === 'directory') {\n if (entry.size !== null) throw new TypeError('Filesystem directory size must be null.');\n return Object.freeze({ ...common, kind: 'directory', size: null });\n }\n throw new TypeError('Unknown filesystem entry kind.');\n}\n\nfunction normalizeDirectoryListing(\n value: readonly FileSystemEntrySnapshot[],\n parent: WorkspacePath,\n): readonly FileSystemEntrySnapshot[] {\n if (!Array.isArray(value)) throw new TypeError('Expected a filesystem directory listing.');\n const entries = value.map(normalizeEntry);\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (entry.path === WORKSPACE_ROOT || workspacePathDirname(entry.path) !== parent) {\n throw new TypeError('Filesystem listing contained a non-child entry.');\n }\n if (seen.has(entry.path)) throw new TypeError('Filesystem listing contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort(compareSnapshotsByPath);\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem listing was not in canonical deterministic order.');\n }\n return Object.freeze(entries);\n}\n\nfunction normalizeFile(entry: FileSystemFileSnapshot): FileSystemFileSnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'file') throw new TypeError('Expected a file snapshot.');\n return normalized;\n}\n\nfunction normalizeDirectory(entry: FileSystemDirectorySnapshot): FileSystemDirectorySnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'directory') throw new TypeError('Expected a directory snapshot.');\n return normalized;\n}\n\nfunction normalizeSnapshot(snapshot: FileSystemSnapshot): FileSystemSnapshot {\n if (!isRecord(snapshot) || !Array.isArray(snapshot.entries)) {\n throw new TypeError('Expected a filesystem snapshot object.');\n }\n const version = parseFileSystemVersion(snapshot.version);\n const entries: FileSystemSnapshotEntry[] = snapshot.entries.map((entry) => {\n if (entry.kind === 'file') {\n const file = normalizeFile(entry);\n const data = copyWireBuffer(entry.data);\n if (data.byteLength !== file.size) {\n throw new TypeError('Filesystem snapshot file bytes have the wrong size.');\n }\n return Object.freeze({ ...file, data });\n }\n if (entry.kind === 'directory') return normalizeDirectory(entry);\n throw new TypeError('Unknown filesystem snapshot entry kind.');\n });\n const roots = entries.filter((entry) => entry.path === WORKSPACE_ROOT);\n if (roots.length !== 1 || roots[0]?.kind !== 'directory' || roots[0].version !== version) {\n throw new TypeError('Filesystem snapshot must contain one matching root directory.');\n }\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (seen.has(entry.path))\n throw new TypeError('Filesystem snapshot contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort((left, right) => compareText(left.path, right.path));\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem snapshot was not in canonical deterministic order.');\n }\n return Object.freeze({\n version,\n entries: Object.freeze(entries),\n });\n}\n\nfunction normalizeWatchEvent(event: FileSystemWatchEvent): FileSystemWatchEvent {\n if (!isRecord(event)) throw new TypeError('Expected a filesystem watch event object.');\n if (!isPositiveSafeInteger(event.sequence)) {\n throw new TypeError('Filesystem watch sequence must be a positive safe integer.');\n }\n if (!isWatchOrigin(event.origin)) throw new TypeError('Unknown filesystem watch origin.');\n if (typeof event.path !== 'string') throw new TypeError('Watch event path must be a string.');\n const path = parseWorkspacePath(event.path);\n if (event.type === 'overflow') {\n if (\n event.kind !== null ||\n event.destinationPath !== null ||\n event.version !== null ||\n event.previousVersion !== null\n ) {\n throw new TypeError('Filesystem overflow event has entry-specific fields.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: 'overflow',\n kind: null,\n path,\n destinationPath: null,\n version: null,\n previousVersion: null,\n });\n }\n if (!isEntryWatchType(event.type)) throw new TypeError('Unknown filesystem watch event type.');\n if (event.kind !== 'file' && event.kind !== 'directory') {\n throw new TypeError('Unknown filesystem watch entry kind.');\n }\n const destinationPath =\n event.destinationPath === null\n ? null\n : typeof event.destinationPath === 'string'\n ? parseWorkspacePath(event.destinationPath)\n : (() => {\n throw new TypeError('Watch destination path must be a string or null.');\n })();\n if ((event.type === 'moved') !== (destinationPath !== null)) {\n throw new TypeError('Only moved watch events may have a destination path.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: event.type,\n kind: event.kind,\n path,\n destinationPath,\n version: event.version === null ? null : parseFileSystemVersion(event.version),\n previousVersion:\n event.previousVersion === null ? null : parseFileSystemVersion(event.previousVersion),\n });\n}\n\nfunction normalizeRemoveResult(value: FileSystemRemoveResult): FileSystemRemoveResult {\n if (!isRecord(value) || typeof value.removed !== 'boolean') {\n throw new TypeError('Filesystem transport returned an invalid remove result.');\n }\n return Object.freeze({ removed: value.removed, version: parseFileSystemVersion(value.version) });\n}\n\nfunction assertCapabilities(value: FileSystemProviderCapabilities, operation: FsOperation): void {\n if (!isRecord(value)) {\n throw invalidTransport(operation, 'Filesystem host returned invalid capabilities.');\n }\n for (const key of Object.keys(ELECTRON_FILE_SYSTEM_V2_CAPABILITIES) as Array<\n keyof FileSystemProviderCapabilities\n >) {\n if (value[key] !== ELECTRON_FILE_SYSTEM_V2_CAPABILITIES[key]) {\n throw invalidTransport(operation, `Filesystem host capability mismatch: ${key}.`);\n }\n }\n}\n\nfunction isWatchOrigin(value: unknown): value is FileSystemWatchEvent['origin'] {\n return value === 'local' || value === 'external' || value === 'unknown';\n}\n\nfunction isEntryWatchType(\n value: unknown,\n): value is Exclude<FileSystemWatchEvent['type'], 'overflow'> {\n return value === 'created' || value === 'modified' || value === 'removed' || value === 'moved';\n}\n\nfunction isNonNegativeSafeInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction isPositiveSafeInteger(value: unknown): value is number {\n return isNonNegativeSafeInteger(value) && value > 0;\n}\n\nfunction invalidTransport(operation: FsOperation, message: string): FsError {\n return new FsError('io', message, { operation, retryable: false });\n}\n\nfunction transportErrorFromUnknown(error: unknown, operation: FsOperation): FsError {\n if (error instanceof TypeError) return invalidTransport(operation, error.message);\n return withOperation(fsErrorFromUnknown(error, { operation }), operation);\n}\n\nfunction withOperation(error: FsError, operation: FsOperation): FsError {\n if (error.operation === operation) return error;\n return new FsError(error.code, error.message, {\n operation,\n path: error.path ?? undefined,\n destinationPath: error.destinationPath ?? undefined,\n retryable: error.retryable,\n });\n}\n\nfunction copyWireBuffer(data: ArrayBuffer): ArrayBuffer {\n if (Object.prototype.toString.call(data) !== '[object ArrayBuffer]') {\n throw new TypeError('Expected an ArrayBuffer from the filesystem transport.');\n }\n return data.slice(0);\n}\n\nfunction createInstanceId(): string {\n const randomUUID = globalThis.crypto?.randomUUID;\n if (typeof randomUUID === 'function') return randomUUID.call(globalThis.crypto);\n fallbackInstanceSequence += 1;\n return `electron-fs-v2-${Date.now()}-${fallbackInstanceSequence}`;\n}\n","/**\n * ElectronFileSystemProvider — implements FileSystemProvider by delegating\n * to the Electron desktop host's fs IPC bridge. Every operation is scoped\n * to an opaque workspace id that the main process resolves against its\n * registered workspace authority.\n *\n * This file has no Electron dependency — it is a pure IPC client that\n * relies on the `docBlocksHost` global installed by the preload script.\n */\n\nimport type { FileCommitResult, FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { maybeGetDocBlocksHost } from '../host/index.js';\nimport type { DocBlocksHostFsAPI } from '../host/types.js';\nimport { ElectronFileSystemProviderV2 } from './electron-provider-v2.js';\n\nexport { isElectronHost } from '../host/index.js';\n\nfunction getHostFs(): DocBlocksHostFsAPI {\n const host = maybeGetDocBlocksHost();\n if (!host) {\n throw new Error(\n 'ElectronFileSystemProvider: docBlocksHost is not available — not running under Electron?',\n );\n }\n return host.fs;\n}\n\nexport class ElectronFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n readonly v2: ElectronFileSystemProviderV2;\n\n private readonly rootPath: string;\n\n constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n this.v2 = new ElectronFileSystemProviderV2(id, label, rootPath);\n }\n\n /** Absolute path this provider is rooted at. */\n getRootPath(): string {\n return this.rootPath;\n }\n\n readFile(path: string): Promise<string | null> {\n return getHostFs().readFile(this.id, path);\n }\n\n writeFile(path: string, content: string): Promise<void> {\n return getHostFs().writeFile(this.id, path, content);\n }\n\n commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n return getHostFs().commitFile(this.id, path, content, expectedContent);\n }\n\n delete(path: string): Promise<void> {\n return getHostFs().delete(this.id, path);\n }\n\n rename(oldPath: string, newPath: string): Promise<void> {\n return getHostFs().rename(this.id, oldPath, newPath);\n }\n\n readDirectory(path: string): Promise<FileSystemEntry[]> {\n return getHostFs().readDirectory(this.id, path);\n }\n\n exists(path: string): Promise<boolean> {\n return getHostFs().exists(this.id, path);\n }\n\n createDirectory(path: string): Promise<void> {\n return getHostFs().createDirectory(this.id, path);\n }\n\n stat(path: string): Promise<FileMeta | null> {\n return getHostFs().stat(this.id, path);\n }\n\n readBinary(path: string): Promise<ArrayBuffer | null> {\n return getHostFs().readBinary(this.id, path);\n }\n\n writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return getHostFs().writeBinary(this.id, path, data);\n }\n\n /** Subscribe to external change notifications under this root. */\n watch(onChange: (changedPath: string) => void): () => void {\n return getHostFs().watch(this.id, onChange);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAI,2BAA2B;AAE/B,SAAS,YAAY,WAA8C;AACjE,QAAM,OAAO,sBAAsB;AACnC,MAAI,CAAC,MAAM,MAAM;AACf,UAAM,IAAI,QAAQ,iBAAiB,+CAA+C;AAAA,MAChF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,KAAK;AACd;AAGO,IAAM,+BAAN,MAAmE;AAAA,EAgBjE,YAAY,IAAY,OAAe,UAAkB;AAbhE,SAAgB,eAAe;AAG/B,SAAiB,aAAa,iBAAiB;AAC/C,SAAiB,WAAW,oBAAI,IAA2B;AAC3D,SAAiB,gBAAgB,oBAAI,IAAiC;AACtE,SAAiB,WAAW,oBAAI,IAAsB;AACtD,SAAQ,cAAoC;AAC5C,SAAQ,oBAAyC;AACjD,SAAQ,iBAAuC;AAC/C,SAAQ,aAAa;AACrB,SAAQ,WAAW;AAGjB,SAAK,KAAK;AACV,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,cAAsB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,KAAK,MAA8D;AAC9E,UAAM,YAAY,mBAAmB,OAAO,IAAI,CAAC;AACjD,WAAO,KAAK;AAAA,MACV;AAAA,MACA,MAAM,YAAY,MAAM,EAAE,KAAK,KAAK,YAAY,SAAS;AAAA,MACzD,CAAC,UAAW,QAAQ,eAAe,KAAK,IAAI;AAAA,IAC9C;AAAA,EACF;AAAA,EAEA,MAAa,SAAS,MAAyD;AAC7E,UAAM,YAAY,mBAAmB,OAAO,IAAI,CAAC;AACjD,WAAO,KAAK;AAAA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AAY,KAAK,IAAI,MAAM,IAAI;AAAA,EACpD;AAAA;AAAA,EAGA,MAAM,UAAqD;AACzD,WAAO,UAAU,EAAE,MAAM,KAAK,IAAI,QAAQ;AAAA,EAC5C;AACF;","names":[]}
@@ -2,8 +2,18 @@ import {
2
2
  withFileCommitLock
3
3
  } from "./chunk-AEHCVWU5.js";
4
4
  import {
5
+ parentChain
6
+ } from "./chunk-GM5YXU4L.js";
7
+ import {
8
+ bytesEqual,
9
+ compareSnapshotsByName,
10
+ compareText,
11
+ copyBytes,
5
12
  parseFileSystemVersion
6
- } from "./chunk-AYZ4HN5M.js";
13
+ } from "./chunk-P4WATND4.js";
14
+ import {
15
+ decodeUtf8Text
16
+ } from "./chunk-FA7UNOXK.js";
7
17
  import {
8
18
  FsError,
9
19
  WORKSPACE_ROOT,
@@ -13,7 +23,7 @@ import {
13
23
  workspacePathContains,
14
24
  workspacePathDirname,
15
25
  workspacePathJoin
16
- } from "./chunk-SI2LU2RP.js";
26
+ } from "./chunk-JS6XFWQK.js";
17
27
 
18
28
  // src/filesystem/native-provider-v2.ts
19
29
  var NativeFileSystemMoveRecoveryError = class extends FsError {
@@ -102,7 +112,7 @@ var NativeFileSystemProviderV2 = class {
102
112
  withoutData((await this.scanMetadataHandle(childPath, childHandle, "list")).root)
103
113
  );
104
114
  }
105
- children.sort(compareSnapshots);
115
+ children.sort(compareSnapshotsByName);
106
116
  return Object.freeze(children);
107
117
  });
108
118
  }
@@ -141,7 +151,7 @@ var NativeFileSystemProviderV2 = class {
141
151
  await this.writeBytes(canonical, ownedData);
142
152
  writeCompleted = true;
143
153
  const written = await this.requireSnapshot(canonical, "write");
144
- if (written.root.kind !== "file" || !equalBytes(written.root.data, ownedData)) {
154
+ if (written.root.kind !== "file" || !bytesEqual(written.root.data, ownedData)) {
145
155
  throw this.error(
146
156
  "conflict",
147
157
  "write",
@@ -282,7 +292,7 @@ var NativeFileSystemProviderV2 = class {
282
292
  }
283
293
  const createdParents = await this.createDirectories(missingParents);
284
294
  let destinationVersion = null;
285
- let sourceDeleted = false;
295
+ let sourceDeleteAttempted = false;
286
296
  try {
287
297
  await this.writeTree(source, sourcePath, destinationPath);
288
298
  const copied = await this.requireSnapshot(destinationPath, "move");
@@ -302,8 +312,15 @@ var NativeFileSystemProviderV2 = class {
302
312
  destinationPath
303
313
  });
304
314
  }
315
+ if (!await this.matchesCapturedSource(sourcePath, source)) {
316
+ throw new FsError("conflict", "Source changed while the move was copied.", {
317
+ operation: "move",
318
+ path: sourcePath,
319
+ destinationPath
320
+ });
321
+ }
322
+ sourceDeleteAttempted = true;
305
323
  await this.removeEntry(sourcePath, source.root.kind === "directory");
306
- sourceDeleted = true;
307
324
  const [sourceAfter, destinationAfter] = await Promise.all([
308
325
  this.tryScanMetadata(sourcePath, "move"),
309
326
  this.tryScanMetadata(destinationPath, "move")
@@ -323,7 +340,7 @@ var NativeFileSystemProviderV2 = class {
323
340
  source,
324
341
  createdParents,
325
342
  destinationVersion,
326
- sourceDeleted,
343
+ sourceDeleteAttempted,
327
344
  error
328
345
  );
329
346
  }
@@ -513,7 +530,7 @@ var NativeFileSystemProviderV2 = class {
513
530
  await this.scanHandle(workspacePathJoin(path, name), childHandle, operation, scanFile)
514
531
  );
515
532
  }
516
- const childRoots = children.map((child) => child.root).sort(compareSnapshots);
533
+ const childRoots = children.map((child) => child.root).sort(compareSnapshotsByName);
517
534
  const version = await metadataVersion(
518
535
  "directory",
519
536
  new TextEncoder().encode(
@@ -574,6 +591,25 @@ var NativeFileSystemProviderV2 = class {
574
591
  kind: "file",
575
592
  path,
576
593
  name: workspacePathBasename(path),
594
+ // Derived from size + mtime, never from content. This keeps stat/list
595
+ // proportional to entry count instead of bytes (see scanMetadataHandle),
596
+ // which is what makes large workspaces listable in a browser tab at all.
597
+ //
598
+ // The cost is a real blind spot: an external same-size rewrite inside one
599
+ // mtime tick is invisible here. FAT/exFAT stamp mtime at 2-second
600
+ // granularity, and network shares can be coarser, so this is reachable on
601
+ // removable and mounted volumes rather than merely theoretical. Two
602
+ // consequences follow, and neither is hypothetical:
603
+ // - a conditional write guarded on expectedVersion accepts, silently
604
+ // overwriting the external edit;
605
+ // - move() re-checks this version to prove the source is unchanged
606
+ // before deleting it, so it can delete a source whose bytes it never
607
+ // copied, losing the edit outright.
608
+ // `conditionalWrite: 'process'` declares the first (expectedVersion binds
609
+ // only against writers in this process). The second is a provider-internal
610
+ // check that the token cannot actually support; closing it means
611
+ // byte-comparing the captured source before the delete, not hashing
612
+ // content here, which would undo the scan-by-metadata property above.
577
613
  size: file.size,
578
614
  version: await metadataVersion(
579
615
  "file",
@@ -663,28 +699,44 @@ var NativeFileSystemProviderV2 = class {
663
699
  if (entry.kind === "file") await this.writeBytes(path, entry.data);
664
700
  }
665
701
  }
666
- async rollbackMoveAndThrow(sourcePath, destinationPath, source, createdParents, destinationVersion, sourceDeleted, primary) {
702
+ async rollbackMoveAndThrow(sourcePath, destinationPath, source, createdParents, destinationVersion, sourceDeleteAttempted, primary) {
667
703
  const primaryError = this.translateError(primary, "move", sourcePath, destinationPath);
668
704
  const recoveryErrors = [];
669
- const sourceCurrent = await this.probeScan(sourcePath);
670
- if (sourceCurrent === null && sourceDeleted) {
671
- try {
672
- await this.writeTree(source, sourcePath, sourcePath);
673
- const restored = await this.probeSnapshot(sourcePath);
674
- if (!restored || !equalTreeContents(source, sourcePath, restored, sourcePath)) {
675
- throw new FsError("conflict", "Restored source does not match its captured state.", {
676
- operation: "move",
677
- path: sourcePath,
678
- destinationPath
679
- });
705
+ let sourceWhole = true;
706
+ if (sourceDeleteAttempted) {
707
+ sourceWhole = await this.matchesCapturedSource(sourcePath, source);
708
+ if (!sourceWhole) {
709
+ try {
710
+ await this.writeTree(source, sourcePath, sourcePath);
711
+ const restored = await this.probeSnapshot(sourcePath);
712
+ if (!restored || !equalTreeContents(source, sourcePath, restored, sourcePath)) {
713
+ throw new FsError("conflict", "Restored source does not match its captured state.", {
714
+ operation: "move",
715
+ path: sourcePath,
716
+ destinationPath
717
+ });
718
+ }
719
+ sourceWhole = true;
720
+ } catch (error) {
721
+ recoveryErrors.push(this.translateError(error, "move", sourcePath, destinationPath));
680
722
  }
681
- } catch (error) {
682
- recoveryErrors.push(this.translateError(error, "move", sourcePath, destinationPath));
683
723
  }
684
724
  }
685
725
  const destinationCurrent = await this.probeScan(destinationPath);
686
726
  if (destinationCurrent) {
687
- if (destinationVersion && destinationCurrent.root.version !== destinationVersion) {
727
+ if (!sourceWhole) {
728
+ recoveryErrors.push(
729
+ new FsError(
730
+ "conflict",
731
+ "Source is incomplete; rollback kept the copy at the destination.",
732
+ {
733
+ operation: "move",
734
+ path: sourcePath,
735
+ destinationPath
736
+ }
737
+ )
738
+ );
739
+ } else if (destinationVersion && destinationCurrent.root.version !== destinationVersion) {
688
740
  recoveryErrors.push(
689
741
  new FsError("conflict", "Destination changed; rollback will not delete it.", {
690
742
  operation: "move",
@@ -716,6 +768,18 @@ var NativeFileSystemProviderV2 = class {
716
768
  state
717
769
  );
718
770
  }
771
+ /**
772
+ * Whether the source still holds exactly the bytes the move captured.
773
+ *
774
+ * A probe that fails answers "no": rollback must never treat an unverifiable
775
+ * source as whole, because that is precisely what licenses deleting the copy
776
+ * at the destination.
777
+ */
778
+ async matchesCapturedSource(sourcePath, source) {
779
+ const current = await this.probeSnapshot(sourcePath);
780
+ if (!current) return false;
781
+ return equalTreeContents(source, sourcePath, current, sourcePath);
782
+ }
719
783
  async probeScan(path) {
720
784
  try {
721
785
  return await this.tryScanMetadata(path, "move");
@@ -784,15 +848,6 @@ async function metadataVersion(kind, metadata, operation, path) {
784
848
  const hex = [...new Uint8Array(digest)].map((value) => value.toString(16).padStart(2, "0")).join("");
785
849
  return parseFileSystemVersion(`sha256:${hex}`);
786
850
  }
787
- function parentChain(path) {
788
- const parents = [];
789
- let current = workspacePathDirname(path);
790
- while (current) {
791
- parents.unshift(current);
792
- current = workspacePathDirname(current);
793
- }
794
- return parents;
795
- }
796
851
  function pathDepth(path) {
797
852
  return path ? path.split("/").length : 0;
798
853
  }
@@ -805,17 +860,6 @@ function isMissingOrKindError(error) {
805
860
  const name = errorName(error);
806
861
  return name === "NotFoundError" || name === "TypeMismatchError";
807
862
  }
808
- function copyBytes(data) {
809
- const source = ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
810
- const copy = new Uint8Array(source.byteLength);
811
- copy.set(source);
812
- return copy.buffer;
813
- }
814
- function equalBytes(left, right) {
815
- const leftBytes = new Uint8Array(left);
816
- const rightBytes = new Uint8Array(right);
817
- return leftBytes.byteLength === rightBytes.byteLength && leftBytes.every((value, index) => value === rightBytes[index]);
818
- }
819
863
  function equalTreeContents(left, leftRoot, right, rightRoot) {
820
864
  if (left.entries.length !== right.entries.length) return false;
821
865
  const rightByRelativePath = /* @__PURE__ */ new Map();
@@ -830,7 +874,7 @@ function equalTreeContents(left, leftRoot, right, rightRoot) {
830
874
  const counterpart = rightByRelativePath.get(relativePath);
831
875
  if (!counterpart || counterpart.kind !== entry.kind) return false;
832
876
  if (entry.kind === "file") {
833
- if (counterpart.kind !== "file" || !equalBytes(entry.data, counterpart.data)) return false;
877
+ if (counterpart.kind !== "file" || !bytesEqual(entry.data, counterpart.data)) return false;
834
878
  }
835
879
  }
836
880
  return true;
@@ -871,13 +915,6 @@ function newestLastModified(children) {
871
915
  }
872
916
  return newest ? new Date(newest).toISOString() : EPOCH;
873
917
  }
874
- function compareSnapshots(left, right) {
875
- if (left.kind !== right.kind) return left.kind === "directory" ? -1 : 1;
876
- return compareText(left.name, right.name);
877
- }
878
- function compareText(left, right) {
879
- return left < right ? -1 : left > right ? 1 : 0;
880
- }
881
918
 
882
919
  // src/filesystem/native-provider.ts
883
920
  function isNativeFileSystemSupported() {
@@ -950,6 +987,21 @@ function isMissingEntryError(error) {
950
987
  const name = errorName2(error);
951
988
  return name === "NotFoundError" || name === "TypeMismatchError";
952
989
  }
990
+ function isKindMismatchError(error) {
991
+ return errorName2(error) === "TypeMismatchError";
992
+ }
993
+ function rootIsNotAMutationTarget(operation, path) {
994
+ return new FsError("invalid-path", "The workspace root is not a file entry.", {
995
+ operation,
996
+ path
997
+ });
998
+ }
999
+ function notAFile(operation, path) {
1000
+ return new FsError("type-mismatch", "Expected a file but found a directory.", {
1001
+ operation,
1002
+ path
1003
+ });
1004
+ }
953
1005
  function isPermissionError(error) {
954
1006
  const name = errorName2(error);
955
1007
  return name === "NotAllowedError" || name === "SecurityError";
@@ -1036,22 +1088,16 @@ var NativeFileSystemProvider = class {
1036
1088
  }
1037
1089
  async readFile(path) {
1038
1090
  const p = normalisePath(path);
1039
- const dir = await resolveDir(this.root, parentDir(p));
1040
- if (!dir) return null;
1041
- try {
1042
- const fileHandle = await dir.getFileHandle(baseName(p));
1043
- const file = await fileHandle.getFile();
1044
- return file.text();
1045
- } catch (error) {
1046
- if (isMissingEntryError(error)) return null;
1047
- throw error;
1048
- }
1091
+ const data = await this.readBinary(p);
1092
+ if (data === null) return null;
1093
+ return decodeUtf8Text(data, { label: "The file", operation: "read", path: p });
1049
1094
  }
1050
1095
  async writeFile(path, content) {
1051
1096
  return this.withMutationLock(() => this.writeFileUnlocked(path, content));
1052
1097
  }
1053
1098
  async writeFileUnlocked(path, content) {
1054
1099
  const p = normalisePath(path);
1100
+ if (!p) throw rootIsNotAMutationTarget("write", path);
1055
1101
  const dir = await resolveDirCreate(this.root, parentDir(p));
1056
1102
  const fileHandle = await dir.getFileHandle(baseName(p), { create: true });
1057
1103
  const writable = await fileHandle.createWritable();
@@ -1079,7 +1125,7 @@ var NativeFileSystemProvider = class {
1079
1125
  }
1080
1126
  async deleteUnlocked(path) {
1081
1127
  const p = normalisePath(path);
1082
- if (!p) throw new Error("Cannot delete the filesystem root");
1128
+ if (!p) throw rootIsNotAMutationTarget("remove", path);
1083
1129
  const parent = parentDir(p);
1084
1130
  const name = baseName(p);
1085
1131
  const dir = await resolveDir(this.root, parent);
@@ -1098,9 +1144,7 @@ var NativeFileSystemProvider = class {
1098
1144
  const op = normalisePath(oldPath);
1099
1145
  const np = normalisePath(newPath);
1100
1146
  if (op === np) return;
1101
- if (!op || !np) {
1102
- throw new Error("Cannot rename the filesystem root");
1103
- }
1147
+ if (!op || !np) throw rootIsNotAMutationTarget("move", !op ? oldPath : newPath);
1104
1148
  if (np.startsWith(op + "/")) {
1105
1149
  throw new Error("Cannot move a directory into itself");
1106
1150
  }
@@ -1154,6 +1198,14 @@ var NativeFileSystemProvider = class {
1154
1198
  try {
1155
1199
  await this.deleteUnlocked(op);
1156
1200
  } catch (error) {
1201
+ try {
1202
+ await this.copyDirectory(np, op);
1203
+ } catch (restoreError) {
1204
+ throw new NativeMoveRecoveryError(
1205
+ `Move partially deleted the source and it could not be restored; the copy at ${newPath} was kept: ${oldPath} -> ${newPath}`,
1206
+ [error, restoreError]
1207
+ );
1208
+ }
1157
1209
  try {
1158
1210
  await this.deleteUnlocked(np);
1159
1211
  } catch (rollbackError) {
@@ -1186,6 +1238,7 @@ var NativeFileSystemProvider = class {
1186
1238
  }
1187
1239
  async exists(path) {
1188
1240
  const p = normalisePath(path);
1241
+ if (!p) return true;
1189
1242
  const parent = parentDir(p);
1190
1243
  const name = baseName(p);
1191
1244
  const dir = await resolveDir(this.root, parent);
@@ -1212,6 +1265,7 @@ var NativeFileSystemProvider = class {
1212
1265
  }
1213
1266
  async stat(path) {
1214
1267
  const p = normalisePath(path);
1268
+ if (!p) return null;
1215
1269
  const dir = await resolveDir(this.root, parentDir(p));
1216
1270
  if (!dir) return null;
1217
1271
  try {
@@ -1230,6 +1284,7 @@ var NativeFileSystemProvider = class {
1230
1284
  }
1231
1285
  async readBinary(path) {
1232
1286
  const p = normalisePath(path);
1287
+ if (!p) throw notAFile("read", p);
1233
1288
  const dir = await resolveDir(this.root, parentDir(p));
1234
1289
  if (!dir) return null;
1235
1290
  try {
@@ -1237,6 +1292,7 @@ var NativeFileSystemProvider = class {
1237
1292
  const file = await fileHandle.getFile();
1238
1293
  return file.arrayBuffer();
1239
1294
  } catch (error) {
1295
+ if (isKindMismatchError(error)) throw notAFile("read", p);
1240
1296
  if (isMissingEntryError(error)) return null;
1241
1297
  throw error;
1242
1298
  }
@@ -1246,6 +1302,7 @@ var NativeFileSystemProvider = class {
1246
1302
  }
1247
1303
  async writeBinaryUnlocked(path, data) {
1248
1304
  const p = normalisePath(path);
1305
+ if (!p) throw rootIsNotAMutationTarget("write", path);
1249
1306
  const dir = await resolveDirCreate(this.root, parentDir(p));
1250
1307
  const fileHandle = await dir.getFileHandle(baseName(p), { create: true });
1251
1308
  const writable = await fileHandle.createWritable();
@@ -1290,4 +1347,4 @@ export {
1290
1347
  openNativeFolder,
1291
1348
  restoreNativeFolder
1292
1349
  };
1293
- //# sourceMappingURL=chunk-2D7Y4IR3.js.map
1350
+ //# sourceMappingURL=chunk-WJKYY5QR.js.map