@bendyline/docblocks 2.0.0 → 2.1.1

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 (278) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-2D7Y4IR3.js → chunk-4437YWLE.js} +123 -67
  3. package/dist/{chunk-5MYAICRE.js → chunk-45T5AFCN.js} +44 -57
  4. package/dist/{chunk-PGR7LK6D.js → chunk-6L3JRDE7.js} +14 -6
  5. package/dist/{chunk-RVQHY3XU.js → chunk-6XHOOBYF.js} +0 -1
  6. package/dist/chunk-73OOROXH.js +8 -0
  7. package/dist/{chunk-SI2LU2RP.js → chunk-AYWKIZLD.js} +1 -1
  8. package/dist/{chunk-GCPBEMMH.js → chunk-BVY7GGNV.js} +10 -21
  9. package/dist/{chunk-AEHCVWU5.js → chunk-DZB666V7.js} +0 -1
  10. package/dist/{chunk-75UUF6C4.js → chunk-HI7QEWL6.js} +18 -10
  11. package/dist/chunk-KQ6756AJ.js +28 -0
  12. package/dist/chunk-LMMOFRGQ.js +148 -0
  13. package/dist/{chunk-FNW556FN.js → chunk-M2PUNKHS.js} +0 -1
  14. package/dist/chunk-M5ZNQGR5.js +19 -0
  15. package/dist/chunk-M62ZGJ5I.js +51 -0
  16. package/dist/chunk-OQCPBOQA.js +168 -0
  17. package/dist/{chunk-EGNDADXB.js → chunk-QI6YKTQV.js} +2 -3
  18. package/dist/chunk-SJBB5OD7.js +227 -0
  19. package/dist/{chunk-EZKJZUNJ.js → chunk-XAMILHQP.js} +0 -1
  20. package/dist/{chunk-J32GU3F3.js → chunk-YM7O3PWO.js} +249 -222
  21. package/dist/{chunk-RQJRQF46.js → chunk-ZO7G53QP.js} +41 -49
  22. package/dist/document/index.d.ts +358 -6
  23. package/dist/document/index.js +24 -4
  24. package/dist/filesystem/electron.d.ts +73 -4
  25. package/dist/filesystem/electron.js +16 -4
  26. package/dist/filesystem/index.d.ts +228 -22
  27. package/dist/filesystem/index.js +133 -20
  28. package/dist/filesystem/indexeddb.d.ts +284 -5
  29. package/dist/filesystem/indexeddb.js +22 -5
  30. package/dist/filesystem/memory.d.ts +152 -4
  31. package/dist/filesystem/memory.js +12 -4
  32. package/dist/filesystem/native.d.ts +136 -4
  33. package/dist/filesystem/native.js +27 -4
  34. package/dist/host/index.d.ts +32 -9
  35. package/dist/host/index.js +26 -30
  36. package/dist/index.d.ts +14 -10
  37. package/dist/index.js +204 -10
  38. package/dist/mcp/index.d.ts +33 -4
  39. package/dist/mcp/index.js +31 -4
  40. package/dist/mcp/zod.d.ts +645 -643
  41. package/dist/mcp/zod.js +700 -885
  42. package/dist/share/index.d.ts +43 -0
  43. package/dist/share/index.js +12 -0
  44. package/dist/{types-CsX6EN2t.d.ts → types-BEg5SQ1_.d.ts} +1 -1
  45. package/dist/{types-eOlt9J7n.d.ts → types-CueK0tvU.d.ts} +34 -11
  46. package/dist/vscode/index.d.ts +225 -3
  47. package/dist/vscode/index.js +389 -3
  48. package/dist/workspace/index.d.ts +141 -4
  49. package/dist/workspace/index.js +28 -3
  50. package/package.json +10 -5
  51. package/dist/chunk-2D7Y4IR3.js.map +0 -1
  52. package/dist/chunk-5MYAICRE.js.map +0 -1
  53. package/dist/chunk-75UUF6C4.js.map +0 -1
  54. package/dist/chunk-AEHCVWU5.js.map +0 -1
  55. package/dist/chunk-AYZ4HN5M.js +0 -20
  56. package/dist/chunk-AYZ4HN5M.js.map +0 -1
  57. package/dist/chunk-EGNDADXB.js.map +0 -1
  58. package/dist/chunk-EZKJZUNJ.js.map +0 -1
  59. package/dist/chunk-FNW556FN.js.map +0 -1
  60. package/dist/chunk-GCPBEMMH.js.map +0 -1
  61. package/dist/chunk-J32GU3F3.js.map +0 -1
  62. package/dist/chunk-PGR7LK6D.js.map +0 -1
  63. package/dist/chunk-RQJRQF46.js.map +0 -1
  64. package/dist/chunk-RVQHY3XU.js.map +0 -1
  65. package/dist/chunk-SI2LU2RP.js.map +0 -1
  66. package/dist/chunk-W5UUUII5.js +0 -142
  67. package/dist/chunk-W5UUUII5.js.map +0 -1
  68. package/dist/document/document-session.d.ts +0 -127
  69. package/dist/document/document-session.d.ts.map +0 -1
  70. package/dist/document/document-session.js +0 -749
  71. package/dist/document/document-session.js.map +0 -1
  72. package/dist/document/filesystem-target.d.ts +0 -17
  73. package/dist/document/filesystem-target.d.ts.map +0 -1
  74. package/dist/document/filesystem-target.js +0 -70
  75. package/dist/document/filesystem-target.js.map +0 -1
  76. package/dist/document/index.d.ts.map +0 -1
  77. package/dist/document/index.js.map +0 -1
  78. package/dist/document/recovery-journal.d.ts +0 -125
  79. package/dist/document/recovery-journal.d.ts.map +0 -1
  80. package/dist/document/recovery-journal.js +0 -385
  81. package/dist/document/recovery-journal.js.map +0 -1
  82. package/dist/document/types.d.ts +0 -89
  83. package/dist/document/types.d.ts.map +0 -1
  84. package/dist/document/types.js +0 -9
  85. package/dist/document/types.js.map +0 -1
  86. package/dist/filesystem/commit-lock.d.ts +0 -3
  87. package/dist/filesystem/commit-lock.d.ts.map +0 -1
  88. package/dist/filesystem/commit-lock.js +0 -20
  89. package/dist/filesystem/commit-lock.js.map +0 -1
  90. package/dist/filesystem/dbk-workspace.d.ts +0 -34
  91. package/dist/filesystem/dbk-workspace.d.ts.map +0 -1
  92. package/dist/filesystem/dbk-workspace.js +0 -85
  93. package/dist/filesystem/dbk-workspace.js.map +0 -1
  94. package/dist/filesystem/electron-provider-v2.d.ts +0 -36
  95. package/dist/filesystem/electron-provider-v2.d.ts.map +0 -1
  96. package/dist/filesystem/electron-provider-v2.js +0 -503
  97. package/dist/filesystem/electron-provider-v2.js.map +0 -1
  98. package/dist/filesystem/electron-provider.d.ts +0 -35
  99. package/dist/filesystem/electron-provider.d.ts.map +0 -1
  100. package/dist/filesystem/electron-provider.js +0 -69
  101. package/dist/filesystem/electron-provider.js.map +0 -1
  102. package/dist/filesystem/electron.d.ts.map +0 -1
  103. package/dist/filesystem/electron.js.map +0 -1
  104. package/dist/filesystem/file-media-provider.d.ts +0 -23
  105. package/dist/filesystem/file-media-provider.d.ts.map +0 -1
  106. package/dist/filesystem/file-media-provider.js +0 -85
  107. package/dist/filesystem/file-media-provider.js.map +0 -1
  108. package/dist/filesystem/filesystem-content-container.d.ts +0 -24
  109. package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
  110. package/dist/filesystem/filesystem-content-container.js +0 -153
  111. package/dist/filesystem/filesystem-content-container.js.map +0 -1
  112. package/dist/filesystem/fs-error.d.ts +0 -46
  113. package/dist/filesystem/fs-error.d.ts.map +0 -1
  114. package/dist/filesystem/fs-error.js +0 -170
  115. package/dist/filesystem/fs-error.js.map +0 -1
  116. package/dist/filesystem/index.d.ts.map +0 -1
  117. package/dist/filesystem/index.js.map +0 -1
  118. package/dist/filesystem/indexeddb-content-container.d.ts +0 -22
  119. package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
  120. package/dist/filesystem/indexeddb-content-container.js +0 -100
  121. package/dist/filesystem/indexeddb-content-container.js.map +0 -1
  122. package/dist/filesystem/indexeddb-provider-v2.d.ts +0 -96
  123. package/dist/filesystem/indexeddb-provider-v2.d.ts.map +0 -1
  124. package/dist/filesystem/indexeddb-provider-v2.js +0 -1241
  125. package/dist/filesystem/indexeddb-provider-v2.js.map +0 -1
  126. package/dist/filesystem/indexeddb-provider.d.ts +0 -39
  127. package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
  128. package/dist/filesystem/indexeddb-provider.js +0 -145
  129. package/dist/filesystem/indexeddb-provider.js.map +0 -1
  130. package/dist/filesystem/indexeddb-store.d.ts +0 -34
  131. package/dist/filesystem/indexeddb-store.d.ts.map +0 -1
  132. package/dist/filesystem/indexeddb-store.js +0 -165
  133. package/dist/filesystem/indexeddb-store.js.map +0 -1
  134. package/dist/filesystem/indexeddb.d.ts.map +0 -1
  135. package/dist/filesystem/indexeddb.js.map +0 -1
  136. package/dist/filesystem/legacy-v2-adapter.d.ts +0 -62
  137. package/dist/filesystem/legacy-v2-adapter.d.ts.map +0 -1
  138. package/dist/filesystem/legacy-v2-adapter.js +0 -499
  139. package/dist/filesystem/legacy-v2-adapter.js.map +0 -1
  140. package/dist/filesystem/memory-provider-v2.d.ts +0 -92
  141. package/dist/filesystem/memory-provider-v2.d.ts.map +0 -1
  142. package/dist/filesystem/memory-provider-v2.js +0 -615
  143. package/dist/filesystem/memory-provider-v2.js.map +0 -1
  144. package/dist/filesystem/memory-provider.d.ts +0 -54
  145. package/dist/filesystem/memory-provider.d.ts.map +0 -1
  146. package/dist/filesystem/memory-provider.js +0 -132
  147. package/dist/filesystem/memory-provider.js.map +0 -1
  148. package/dist/filesystem/memory.d.ts.map +0 -1
  149. package/dist/filesystem/memory.js.map +0 -1
  150. package/dist/filesystem/move-entry.d.ts +0 -9
  151. package/dist/filesystem/move-entry.d.ts.map +0 -1
  152. package/dist/filesystem/move-entry.js +0 -103
  153. package/dist/filesystem/move-entry.js.map +0 -1
  154. package/dist/filesystem/move-error.d.ts +0 -53
  155. package/dist/filesystem/move-error.d.ts.map +0 -1
  156. package/dist/filesystem/move-error.js +0 -99
  157. package/dist/filesystem/move-error.js.map +0 -1
  158. package/dist/filesystem/native-provider-v2.d.ts +0 -75
  159. package/dist/filesystem/native-provider-v2.d.ts.map +0 -1
  160. package/dist/filesystem/native-provider-v2.js +0 -849
  161. package/dist/filesystem/native-provider-v2.js.map +0 -1
  162. package/dist/filesystem/native-provider.d.ts +0 -53
  163. package/dist/filesystem/native-provider.d.ts.map +0 -1
  164. package/dist/filesystem/native-provider.js +0 -471
  165. package/dist/filesystem/native-provider.js.map +0 -1
  166. package/dist/filesystem/native.d.ts.map +0 -1
  167. package/dist/filesystem/native.js.map +0 -1
  168. package/dist/filesystem/types.d.ts +0 -83
  169. package/dist/filesystem/types.d.ts.map +0 -1
  170. package/dist/filesystem/types.js +0 -16
  171. package/dist/filesystem/types.js.map +0 -1
  172. package/dist/filesystem/v2.d.ts +0 -172
  173. package/dist/filesystem/v2.d.ts.map +0 -1
  174. package/dist/filesystem/v2.js +0 -16
  175. package/dist/filesystem/v2.js.map +0 -1
  176. package/dist/filesystem/workspace-path.d.ts +0 -21
  177. package/dist/filesystem/workspace-path.d.ts.map +0 -1
  178. package/dist/filesystem/workspace-path.js +0 -80
  179. package/dist/filesystem/workspace-path.js.map +0 -1
  180. package/dist/host/filesystem-v2.d.ts +0 -45
  181. package/dist/host/filesystem-v2.d.ts.map +0 -1
  182. package/dist/host/filesystem-v2.js +0 -13
  183. package/dist/host/filesystem-v2.js.map +0 -1
  184. package/dist/host/git.d.ts +0 -200
  185. package/dist/host/git.d.ts.map +0 -1
  186. package/dist/host/git.js +0 -15
  187. package/dist/host/git.js.map +0 -1
  188. package/dist/host/index.d.ts.map +0 -1
  189. package/dist/host/index.js.map +0 -1
  190. package/dist/host/types.d.ts +0 -232
  191. package/dist/host/types.d.ts.map +0 -1
  192. package/dist/host/types.js +0 -10
  193. package/dist/host/types.js.map +0 -1
  194. package/dist/host/wire-policy.d.ts +0 -22
  195. package/dist/host/wire-policy.d.ts.map +0 -1
  196. package/dist/host/wire-policy.js +0 -92
  197. package/dist/host/wire-policy.js.map +0 -1
  198. package/dist/index.d.ts.map +0 -1
  199. package/dist/index.js.map +0 -1
  200. package/dist/mcp/index.d.ts.map +0 -1
  201. package/dist/mcp/index.js.map +0 -1
  202. package/dist/mcp/types.d.ts +0 -466
  203. package/dist/mcp/types.d.ts.map +0 -1
  204. package/dist/mcp/types.js +0 -25
  205. package/dist/mcp/types.js.map +0 -1
  206. package/dist/mcp/wire.d.ts +0 -29
  207. package/dist/mcp/wire.d.ts.map +0 -1
  208. package/dist/mcp/wire.js +0 -1046
  209. package/dist/mcp/wire.js.map +0 -1
  210. package/dist/mcp/zod.d.ts.map +0 -1
  211. package/dist/mcp/zod.js.map +0 -1
  212. package/dist/vscode/index.d.ts.map +0 -1
  213. package/dist/vscode/index.js.map +0 -1
  214. package/dist/vscode/messages.d.ts +0 -204
  215. package/dist/vscode/messages.d.ts.map +0 -1
  216. package/dist/vscode/messages.js +0 -494
  217. package/dist/vscode/messages.js.map +0 -1
  218. package/dist/workspace/index.d.ts.map +0 -1
  219. package/dist/workspace/index.js.map +0 -1
  220. package/dist/workspace/reconcile-electron.d.ts +0 -19
  221. package/dist/workspace/reconcile-electron.d.ts.map +0 -1
  222. package/dist/workspace/reconcile-electron.js +0 -42
  223. package/dist/workspace/reconcile-electron.js.map +0 -1
  224. package/dist/workspace/types.d.ts +0 -69
  225. package/dist/workspace/types.d.ts.map +0 -1
  226. package/dist/workspace/types.js +0 -2
  227. package/dist/workspace/types.js.map +0 -1
  228. package/dist/workspace/workspace-manager.d.ts +0 -47
  229. package/dist/workspace/workspace-manager.d.ts.map +0 -1
  230. package/dist/workspace/workspace-manager.js +0 -126
  231. package/dist/workspace/workspace-manager.js.map +0 -1
  232. package/src/document/document-session.ts +0 -834
  233. package/src/document/filesystem-target.ts +0 -109
  234. package/src/document/index.ts +0 -41
  235. package/src/document/recovery-journal.ts +0 -536
  236. package/src/document/types.ts +0 -116
  237. package/src/filesystem/commit-lock.ts +0 -29
  238. package/src/filesystem/dbk-workspace.ts +0 -135
  239. package/src/filesystem/electron-provider-v2.ts +0 -630
  240. package/src/filesystem/electron-provider.ts +0 -99
  241. package/src/filesystem/electron.ts +0 -3
  242. package/src/filesystem/file-media-provider.ts +0 -103
  243. package/src/filesystem/filesystem-content-container.ts +0 -164
  244. package/src/filesystem/fs-error.ts +0 -234
  245. package/src/filesystem/index.ts +0 -143
  246. package/src/filesystem/indexeddb-content-container.ts +0 -112
  247. package/src/filesystem/indexeddb-provider-v2.ts +0 -1740
  248. package/src/filesystem/indexeddb-provider.ts +0 -171
  249. package/src/filesystem/indexeddb-store.ts +0 -207
  250. package/src/filesystem/indexeddb.ts +0 -12
  251. package/src/filesystem/legacy-v2-adapter.ts +0 -779
  252. package/src/filesystem/memory-provider-v2.ts +0 -896
  253. package/src/filesystem/memory-provider.ts +0 -180
  254. package/src/filesystem/memory.ts +0 -15
  255. package/src/filesystem/move-entry.ts +0 -142
  256. package/src/filesystem/move-error.ts +0 -159
  257. package/src/filesystem/native-provider-v2.ts +0 -1165
  258. package/src/filesystem/native-provider.ts +0 -537
  259. package/src/filesystem/native.ts +0 -16
  260. package/src/filesystem/types.ts +0 -114
  261. package/src/filesystem/v2.ts +0 -231
  262. package/src/filesystem/workspace-path.ts +0 -92
  263. package/src/host/filesystem-v2.ts +0 -104
  264. package/src/host/git.ts +0 -246
  265. package/src/host/index.ts +0 -93
  266. package/src/host/types.ts +0 -274
  267. package/src/host/wire-policy.ts +0 -103
  268. package/src/index.ts +0 -10
  269. package/src/mcp/index.ts +0 -3
  270. package/src/mcp/types.ts +0 -594
  271. package/src/mcp/wire.ts +0 -1280
  272. package/src/mcp/zod.ts +0 -1000
  273. package/src/vscode/index.ts +0 -2
  274. package/src/vscode/messages.ts +0 -704
  275. package/src/workspace/index.ts +0 -17
  276. package/src/workspace/reconcile-electron.ts +0 -65
  277. package/src/workspace/types.ts +0 -67
  278. package/src/workspace/workspace-manager.ts +0 -151
@@ -1,85 +0,0 @@
1
- import { documentCompanionPath } from './move-entry.js';
2
- function normaliseRelativePath(path, label) {
3
- if (path.includes('\\') || path.includes('\0')) {
4
- throw new Error(`DBK ${label} must use a safe forward-slash path: ${path}`);
5
- }
6
- const normalized = path.replace(/^\/+|\/+$/g, '').replace(/\/+/g, '/');
7
- const segments = normalized ? normalized.split('/') : [];
8
- if (segments.length === 0 || segments.some((segment) => segment === '.' || segment === '..')) {
9
- throw new Error(`DBK ${label} must not be empty or traverse directories: ${path}`);
10
- }
11
- return segments.join('/');
12
- }
13
- function joinPath(parent, child) {
14
- return `${parent.replace(/\/+$/g, '')}/${child.replace(/^\/+/, '')}`;
15
- }
16
- /**
17
- * Fully materialize and validate a DBK container before touching its target
18
- * provider. A missing or unreadable entry fails the snapshot as a whole.
19
- */
20
- export async function createDbkWorkspaceSnapshot(source, options) {
21
- const targetDocumentPath = normaliseRelativePath(options.targetDocumentPath, 'target document path');
22
- const discoveredDocumentPath = await source.getDocumentPath();
23
- if (!discoveredDocumentPath)
24
- throw new Error('The external DBK has no primary markdown document.');
25
- const sourceDocumentPath = normaliseRelativePath(discoveredDocumentPath, 'primary document path');
26
- const requestedLayout = options.assetLayout ?? 'auto';
27
- const assetLayout = requestedLayout === 'auto'
28
- ? sourceDocumentPath === targetDocumentPath
29
- ? 'preserve'
30
- : 'companion'
31
- : requestedLayout;
32
- const companionPath = normaliseRelativePath(documentCompanionPath(targetDocumentPath), 'companion directory path');
33
- const listed = await source.listFiles();
34
- const entries = [...listed].sort((a, b) => a.path.localeCompare(b.path));
35
- const seenSourcePaths = new Set();
36
- const files = [];
37
- let documentContent = null;
38
- for (const entry of entries) {
39
- const sourcePath = normaliseRelativePath(entry.path, 'entry path');
40
- if (seenSourcePaths.has(sourcePath)) {
41
- throw new Error(`The external DBK contains duplicate paths: ${sourcePath}`);
42
- }
43
- seenSourcePaths.add(sourcePath);
44
- const data = await source.readFile(entry.path);
45
- if (data === null) {
46
- throw new Error(`The external DBK changed while reading: ${sourcePath}`);
47
- }
48
- if (sourcePath === sourceDocumentPath) {
49
- documentContent = new TextDecoder().decode(data);
50
- files.push({ kind: 'text', path: targetDocumentPath, content: documentContent });
51
- continue;
52
- }
53
- const targetPath = assetLayout === 'preserve' ? sourcePath : joinPath(companionPath, sourcePath);
54
- if (/\.(?:md|mdx|txt)$/i.test(sourcePath)) {
55
- files.push({ kind: 'text', path: targetPath, content: new TextDecoder().decode(data) });
56
- }
57
- else {
58
- files.push({ kind: 'binary', path: targetPath, data });
59
- }
60
- }
61
- if (documentContent === null) {
62
- throw new Error(`The external DBK did not include its primary document: ${sourceDocumentPath}`);
63
- }
64
- return {
65
- sourceDocumentPath,
66
- targetDocumentPath,
67
- documentContent,
68
- assetLayout,
69
- files,
70
- };
71
- }
72
- /**
73
- * Replace a transient DBK workspace as one logical operation.
74
- *
75
- * Container reads and validation happen before provider mutation. The memory
76
- * provider then stages and swaps the full tree synchronously, which removes
77
- * stale files and guarantees the old tree survives any failed replacement.
78
- */
79
- export async function replaceMemoryWorkspaceFromDbk(provider, source, options) {
80
- const expectedTreeVersion = provider.treeVersion;
81
- const snapshot = await createDbkWorkspaceSnapshot(source, options);
82
- provider.replaceContents(snapshot, expectedTreeVersion);
83
- return snapshot;
84
- }
85
- //# sourceMappingURL=dbk-workspace.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"dbk-workspace.js","sourceRoot":"","sources":["../../src/filesystem/dbk-workspace.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AA4BxD,SAAS,qBAAqB,CAAC,IAAY,EAAE,KAAa;IACxD,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,wCAAwC,IAAI,EAAE,CAAC,CAAC;IAC9E,CAAC;IACD,MAAM,UAAU,GAAG,IAAI,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACvE,MAAM,QAAQ,GAAG,UAAU,CAAC,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IACzD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,IAAI,QAAQ,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,KAAK,GAAG,IAAI,OAAO,KAAK,IAAI,CAAC,EAAE,CAAC;QAC7F,MAAM,IAAI,KAAK,CAAC,OAAO,KAAK,+CAA+C,IAAI,EAAE,CAAC,CAAC;IACrF,CAAC;IACD,OAAO,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAC5B,CAAC;AAED,SAAS,QAAQ,CAAC,MAAc,EAAE,KAAa;IAC7C,OAAO,GAAG,MA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;IACH,CAAC;IAED,IAAI,eAAe,KAAK,IAAI,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,0DAA0D,kBAAkB,EAAE,CAAC,CAAC;IAClG,CAAC;IAED,OAAO;QACL,kBAAkB;QAClB,kBAAkB;QAClB,eAAe;QACf,WAAW;QACX,KAAK;KACN,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,6BAA6B,CACjD,QAAkC,EAClC,MAAwB,EACxB,OAAoC;IAEpC,MAAM,mBAAmB,GAAG,QAAQ,CAAC,WAAW,CAAC;IACjD,MAAM,QAAQ,GAAG,MAAM,0BAA0B,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IACnE,QAAQ,CAAC,eAAe,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;IACxD,OAAO,QAAQ,CAAC;AAClB,CAAC"}
@@ -1,36 +0,0 @@
1
- import { type WorkspacePath } from './workspace-path.js';
2
- import { type FileSystemCreateDirectoryOptions, type FileSystemDirectorySnapshot, type FileSystemEntrySnapshot, type FileSystemFileRead, type FileSystemFileSnapshot, type FileSystemMoveOptions, type FileSystemProviderCapabilities, type FileSystemProviderV2, type FileSystemRemoveOptions, type FileSystemRemoveResult, type FileSystemSnapshot, type FileSystemWatchEvent, type FileSystemWatchOptions, type FileSystemWatchSubscription, type FileSystemWriteOptions } from './v2.js';
3
- /** Pure renderer-side client for the typed Electron filesystem v2 transport. */
4
- export declare class ElectronFileSystemProviderV2 implements FileSystemProviderV2 {
5
- readonly id: string;
6
- readonly label: string;
7
- readonly capabilities: FileSystemProviderCapabilities;
8
- private readonly rootPath;
9
- private readonly instanceId;
10
- private readonly watchers;
11
- private readonly subscriptions;
12
- private readonly inFlight;
13
- private openPromise;
14
- private removeWatchBridge;
15
- private disposePromise;
16
- private hostOpened;
17
- private disposed;
18
- constructor(id: string, label: string, rootPath: string);
19
- getRootPath(): string;
20
- stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null>;
21
- readFile(path: WorkspacePath): Promise<FileSystemFileRead | null>;
22
- readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]>;
23
- writeFile(path: WorkspacePath, data: ArrayBuffer | Uint8Array, options?: FileSystemWriteOptions): Promise<FileSystemFileSnapshot>;
24
- createDirectory(path: WorkspacePath, options?: FileSystemCreateDirectoryOptions): Promise<FileSystemDirectorySnapshot>;
25
- remove(path: WorkspacePath, options?: FileSystemRemoveOptions): Promise<FileSystemRemoveResult>;
26
- move(oldPath: WorkspacePath, newPath: WorkspacePath, options?: FileSystemMoveOptions): Promise<FileSystemEntrySnapshot>;
27
- snapshot(): Promise<FileSystemSnapshot>;
28
- watch(listener: (event: FileSystemWatchEvent) => void, options?: FileSystemWatchOptions): FileSystemWatchSubscription;
29
- dispose(): Promise<void>;
30
- private request;
31
- private ensureOpen;
32
- private ensureWatchBridge;
33
- private handleWatchMessage;
34
- private assertOpen;
35
- }
36
- //# sourceMappingURL=electron-provider-v2.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"electron-provider-v2.d.ts","sourceRoot":"","sources":["../../src/filesystem/electron-provider-v2.ts"],"names":[],"mappings":"AAcA,OAAO,EAKL,KAAK,aAAa,EACnB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,KAAK,gCAAgC,EACrC,KAAK,2BAA2B,EAChC,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,sBAAsB,EAC3B,KAAK,qBAAqB,EAC1B,KAAK,8BAA8B,EACnC,KAAK,oBAAoB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,sBAAsB,EAC3B,KAAK,kBAAkB,EAEvB,KAAK,oBAAoB,EACzB,KAAK,sBAAsB,EAC3B,KAAK,2BAA2B,EAChC,KAAK,sBAAsB,EAC5B,MAAM,SAAS,CAAC;AAmBjB,gFAAgF;AAChF,qBAAa,4BAA6B,YAAW,oBAAoB;IACvE,SAAgB,EAAE,EAAE,MAAM,CA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qBAAqB,GAC9B,OAAO,CAAC,uBAAuB,CAAC;IAUtB,QAAQ,IAAI,OAAO,CAAC,kBAAkB,CAAC;IAQ7C,KAAK,CACV,QAAQ,EAAE,CAAC,KAAK,EAAE,oBAAoB,KAAK,IAAI,EAC/C,OAAO,GAAE,sBAA2B,GACnC,2BAA2B;IAqDvB,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAiC/B,OAAO,CAAC,OAAO;IAqBf,OAAO,CAAC,UAAU;IAwBlB,OAAO,CAAC,iBAAiB;IAOzB,OAAO,CAAC,kBAAkB;IAkC1B,OAAO,CAAC,UAAU;CAInB"}
@@ -1,503 +0,0 @@
1
- import { ELECTRON_FILE_SYSTEM_V2_CAPABILITIES, maybeGetDocBlocksHost, } from '../host/index.js';
2
- import { FsError, deserializeFsError, fsErrorFromUnknown, isSerializedFsError, } from './fs-error.js';
3
- import { WORKSPACE_ROOT, parseWorkspacePath, workspacePathBasename, workspacePathDirname, } from './workspace-path.js';
4
- import { parseFileSystemVersion, } from './v2.js';
5
- let fallbackInstanceSequence = 0;
6
- function getHostFsV2(operation) {
7
- const host = maybeGetDocBlocksHost();
8
- if (!host?.fsV2) {
9
- throw new FsError('not-supported', 'Electron filesystem v2 host is unavailable.', {
10
- operation,
11
- });
12
- }
13
- return host.fsV2;
14
- }
15
- /** Pure renderer-side client for the typed Electron filesystem v2 transport. */
16
- export class ElectronFileSystemProviderV2 {
17
- constructor(id, label, rootPath) {
18
- this.capabilities = ELECTRON_FILE_SYSTEM_V2_CAPABILITIES;
19
- this.instanceId = createInstanceId();
20
- this.watchers = new Map();
21
- this.subscriptions = new Set();
22
- this.inFlight = new Set();
23
- this.openPromise = null;
24
- this.removeWatchBridge = null;
25
- this.disposePromise = null;
26
- this.hostOpened = false;
27
- this.disposed = false;
28
- this.id = id;
29
- this.label = label;
30
- this.rootPath = rootPath;
31
- }
32
- getRootPath() {
33
- return this.rootPath;
34
- }
35
- async stat(path) {
36
- const canonical = parseWorkspacePath(String(path));
37
- return this.request('stat', () => getHostFsV2('stat').stat(this.instanceId, canonical), (value) => (value ? normalizeEntry(value) : null));
38
- }
39
- async readFile(path) {
40
- const canonical = parseWorkspacePath(String(path));
41
- return this.request('read', () => getHostFsV2('read').readFile(this.instanceId, canonical), (value) => {
42
- if (!value)
43
- return null;
44
- const entry = normalizeFile(value.entry);
45
- const data = copyWireBuffer(value.data);
46
- if (data.byteLength !== entry.size) {
47
- throw new TypeError('Filesystem transport returned file bytes with the wrong size.');
48
- }
49
- return Object.freeze({ entry, data });
50
- });
51
- }
52
- async readDirectory(path) {
53
- const canonical = parseWorkspacePath(String(path));
54
- return this.request('list', () => getHostFsV2('list').readDirectory(this.instanceId, canonical), (value) => normalizeDirectoryListing(value, canonical));
55
- }
56
- async writeFile(path, data, options) {
57
- const canonical = parseWorkspacePath(String(path));
58
- const owned = copyBytes(data);
59
- return this.request('write', () => getHostFsV2('write').writeFile(this.instanceId, canonical, owned, options), normalizeFile);
60
- }
61
- async createDirectory(path, options) {
62
- const canonical = parseWorkspacePath(String(path));
63
- return this.request('create-directory', () => getHostFsV2('create-directory').createDirectory(this.instanceId, canonical, options), normalizeDirectory);
64
- }
65
- async remove(path, options) {
66
- const canonical = parseWorkspacePath(String(path));
67
- return this.request('remove', () => getHostFsV2('remove').remove(this.instanceId, canonical, options), normalizeRemoveResult);
68
- }
69
- async move(oldPath, newPath, options) {
70
- const source = parseWorkspacePath(String(oldPath));
71
- const destination = parseWorkspacePath(String(newPath));
72
- return this.request('move', () => getHostFsV2('move').move(this.instanceId, source, destination, options), normalizeEntry);
73
- }
74
- async snapshot() {
75
- return this.request('snapshot', () => getHostFsV2('snapshot').snapshot(this.instanceId), normalizeSnapshot);
76
- }
77
- watch(listener, options = {}) {
78
- this.assertOpen('watch');
79
- this.ensureWatchBridge();
80
- const subscriptionId = createInstanceId();
81
- const watcher = { listener, onError: options.onError };
82
- this.watchers.set(subscriptionId, watcher);
83
- let closed = false;
84
- let subscribed = false;
85
- let closePromise = null;
86
- const ready = this.ensureOpen('watch')
87
- .then(async () => {
88
- if (closed)
89
- return;
90
- unwrap(await getHostFsV2('watch').watchSubscribe(this.instanceId, subscriptionId), 'watch');
91
- subscribed = true;
92
- })
93
- .catch((error) => {
94
- closed = true;
95
- this.watchers.delete(subscriptionId);
96
- const typed = error instanceof FsError ? error : new FsError('io', String(error));
97
- try {
98
- watcher.onError?.(typed);
99
- }
100
- catch {
101
- // Isolate observers.
102
- }
103
- throw typed;
104
- });
105
- const subscription = {
106
- get closed() {
107
- return closed;
108
- },
109
- ready,
110
- dispose: () => {
111
- if (closePromise)
112
- return closePromise;
113
- closed = true;
114
- this.watchers.delete(subscriptionId);
115
- this.subscriptions.delete(subscription);
116
- closePromise = (async () => {
117
- await ready.catch(() => undefined);
118
- if (subscribed) {
119
- unwrap(await getHostFsV2('watch').watchUnsubscribe(this.instanceId, subscriptionId), 'watch');
120
- }
121
- })();
122
- return closePromise;
123
- },
124
- };
125
- this.subscriptions.add(subscription);
126
- return subscription;
127
- }
128
- dispose() {
129
- if (this.disposePromise)
130
- return this.disposePromise;
131
- this.disposed = true;
132
- this.disposePromise = (async () => {
133
- await Promise.allSettled([...this.inFlight]);
134
- await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));
135
- try {
136
- if (this.openPromise) {
137
- try {
138
- await this.openPromise;
139
- }
140
- catch {
141
- // A failed request normally creates no host record. `hostOpened`
142
- // separately tracks a successful open whose response validation
143
- // failed after the main-side record had already been published.
144
- }
145
- }
146
- if (this.hostOpened) {
147
- try {
148
- unwrap(await getHostFsV2('dispose').dispose(this.instanceId), 'dispose');
149
- }
150
- catch (error) {
151
- if (!(error instanceof FsError && error.code === 'closed'))
152
- throw error;
153
- }
154
- finally {
155
- this.hostOpened = false;
156
- }
157
- }
158
- }
159
- finally {
160
- this.removeWatchBridge?.();
161
- this.removeWatchBridge = null;
162
- }
163
- })();
164
- return this.disposePromise;
165
- }
166
- request(operation, send, normalize) {
167
- this.assertOpen(operation);
168
- const promise = this.ensureOpen(operation).then(async () => {
169
- try {
170
- return normalize(unwrap(await send(), operation));
171
- }
172
- catch (error) {
173
- throw transportErrorFromUnknown(error, operation);
174
- }
175
- });
176
- this.inFlight.add(promise);
177
- void promise.then(() => this.inFlight.delete(promise), () => this.inFlight.delete(promise));
178
- return promise;
179
- }
180
- ensureOpen(operation) {
181
- this.assertOpen(operation);
182
- if (!this.openPromise) {
183
- const attempt = getHostFsV2(operation)
184
- .open({
185
- instanceId: this.instanceId,
186
- providerId: this.id,
187
- label: this.label,
188
- })
189
- .then((result) => {
190
- if (isRecord(result) && result.ok === true)
191
- this.hostOpened = true;
192
- const capabilities = unwrap(result, operation);
193
- assertCapabilities(capabilities, operation);
194
- })
195
- .catch((error) => {
196
- const typed = withOperation(fsErrorFromUnknown(error, { operation }), operation);
197
- if (typed.retryable && this.openPromise === attempt)
198
- this.openPromise = null;
199
- throw typed;
200
- });
201
- this.openPromise = attempt;
202
- }
203
- return this.openPromise;
204
- }
205
- ensureWatchBridge() {
206
- if (this.removeWatchBridge)
207
- return;
208
- this.removeWatchBridge = getHostFsV2('watch').onWatchMessage((message) => this.handleWatchMessage(message));
209
- }
210
- handleWatchMessage(message) {
211
- if (message.instanceId !== this.instanceId)
212
- return;
213
- const watcher = this.watchers.get(message.subscriptionId);
214
- if (!watcher)
215
- return;
216
- if (message.kind === 'error') {
217
- const typed = isSerializedFsError(message.error)
218
- ? deserializeFsError(message.error)
219
- : invalidTransport('watch', 'Filesystem transport returned an invalid watch error.');
220
- try {
221
- watcher.onError?.(typed);
222
- }
223
- catch {
224
- // Isolate observers.
225
- }
226
- return;
227
- }
228
- let event;
229
- try {
230
- event = normalizeWatchEvent(message.event);
231
- }
232
- catch (error) {
233
- try {
234
- watcher.onError?.(transportErrorFromUnknown(error, 'watch'));
235
- }
236
- catch {
237
- // Isolate observers.
238
- }
239
- return;
240
- }
241
- try {
242
- watcher.listener(event);
243
- }
244
- catch {
245
- // Watch callbacks are observational.
246
- }
247
- }
248
- assertOpen(operation) {
249
- if (!this.disposed)
250
- return;
251
- throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });
252
- }
253
- }
254
- function unwrap(result, operation) {
255
- if (!isRecord(result) || typeof result.ok !== 'boolean') {
256
- throw invalidTransport(operation, 'Filesystem transport returned an invalid result envelope.');
257
- }
258
- if (result.ok) {
259
- if (!('value' in result)) {
260
- throw invalidTransport(operation, 'Filesystem transport omitted a result value.');
261
- }
262
- return result.value;
263
- }
264
- if (!isSerializedFsError(result.error)) {
265
- throw invalidTransport(operation, 'Filesystem transport returned an invalid error envelope.');
266
- }
267
- throw deserializeFsError(result.error);
268
- }
269
- function normalizeEntry(entry) {
270
- if (!isRecord(entry))
271
- throw new TypeError('Expected a filesystem entry object.');
272
- if (typeof entry.path !== 'string')
273
- throw new TypeError('Filesystem entry path must be a string.');
274
- if (typeof entry.name !== 'string')
275
- throw new TypeError('Filesystem entry name must be a string.');
276
- if (typeof entry.lastModified !== 'string') {
277
- throw new TypeError('Filesystem entry timestamp must be a string.');
278
- }
279
- const path = parseWorkspacePath(entry.path);
280
- if (entry.name !== workspacePathBasename(path)) {
281
- throw new TypeError('Filesystem entry name does not match its canonical path.');
282
- }
283
- const common = {
284
- path,
285
- name: entry.name,
286
- version: parseFileSystemVersion(entry.version),
287
- lastModified: new Date(entry.lastModified).toISOString(),
288
- };
289
- if (entry.kind === 'file') {
290
- if (!isNonNegativeSafeInteger(entry.size)) {
291
- throw new TypeError('Filesystem file size must be a non-negative safe integer.');
292
- }
293
- return Object.freeze({ ...common, kind: 'file', size: entry.size });
294
- }
295
- if (entry.kind === 'directory') {
296
- if (entry.size !== null)
297
- throw new TypeError('Filesystem directory size must be null.');
298
- return Object.freeze({ ...common, kind: 'directory', size: null });
299
- }
300
- throw new TypeError('Unknown filesystem entry kind.');
301
- }
302
- function normalizeDirectoryListing(value, parent) {
303
- if (!Array.isArray(value))
304
- throw new TypeError('Expected a filesystem directory listing.');
305
- const entries = value.map(normalizeEntry);
306
- const seen = new Set();
307
- for (const entry of entries) {
308
- if (entry.path === WORKSPACE_ROOT || workspacePathDirname(entry.path) !== parent) {
309
- throw new TypeError('Filesystem listing contained a non-child entry.');
310
- }
311
- if (seen.has(entry.path))
312
- throw new TypeError('Filesystem listing contained a duplicate path.');
313
- seen.add(entry.path);
314
- }
315
- const ordered = [...entries].sort(compareDirectoryEntries);
316
- if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {
317
- throw new TypeError('Filesystem listing was not in canonical deterministic order.');
318
- }
319
- return Object.freeze(entries);
320
- }
321
- function normalizeFile(entry) {
322
- const normalized = normalizeEntry(entry);
323
- if (normalized.kind !== 'file')
324
- throw new TypeError('Expected a file snapshot.');
325
- return normalized;
326
- }
327
- function normalizeDirectory(entry) {
328
- const normalized = normalizeEntry(entry);
329
- if (normalized.kind !== 'directory')
330
- throw new TypeError('Expected a directory snapshot.');
331
- return normalized;
332
- }
333
- function normalizeSnapshot(snapshot) {
334
- if (!isRecord(snapshot) || !Array.isArray(snapshot.entries)) {
335
- throw new TypeError('Expected a filesystem snapshot object.');
336
- }
337
- const version = parseFileSystemVersion(snapshot.version);
338
- const entries = snapshot.entries.map((entry) => {
339
- if (entry.kind === 'file') {
340
- const file = normalizeFile(entry);
341
- const data = copyWireBuffer(entry.data);
342
- if (data.byteLength !== file.size) {
343
- throw new TypeError('Filesystem snapshot file bytes have the wrong size.');
344
- }
345
- return Object.freeze({ ...file, data });
346
- }
347
- if (entry.kind === 'directory')
348
- return normalizeDirectory(entry);
349
- throw new TypeError('Unknown filesystem snapshot entry kind.');
350
- });
351
- const roots = entries.filter((entry) => entry.path === WORKSPACE_ROOT);
352
- if (roots.length !== 1 || roots[0]?.kind !== 'directory' || roots[0].version !== version) {
353
- throw new TypeError('Filesystem snapshot must contain one matching root directory.');
354
- }
355
- const seen = new Set();
356
- for (const entry of entries) {
357
- if (seen.has(entry.path))
358
- throw new TypeError('Filesystem snapshot contained a duplicate path.');
359
- seen.add(entry.path);
360
- }
361
- const ordered = [...entries].sort((left, right) => compareText(left.path, right.path));
362
- if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {
363
- throw new TypeError('Filesystem snapshot was not in canonical deterministic order.');
364
- }
365
- return Object.freeze({
366
- version,
367
- entries: Object.freeze(entries),
368
- });
369
- }
370
- function normalizeWatchEvent(event) {
371
- if (!isRecord(event))
372
- throw new TypeError('Expected a filesystem watch event object.');
373
- if (!isPositiveSafeInteger(event.sequence)) {
374
- throw new TypeError('Filesystem watch sequence must be a positive safe integer.');
375
- }
376
- if (!isWatchOrigin(event.origin))
377
- throw new TypeError('Unknown filesystem watch origin.');
378
- if (typeof event.path !== 'string')
379
- throw new TypeError('Watch event path must be a string.');
380
- const path = parseWorkspacePath(event.path);
381
- if (event.type === 'overflow') {
382
- if (event.kind !== null ||
383
- event.destinationPath !== null ||
384
- event.version !== null ||
385
- event.previousVersion !== null) {
386
- throw new TypeError('Filesystem overflow event has entry-specific fields.');
387
- }
388
- return Object.freeze({
389
- sequence: event.sequence,
390
- origin: event.origin,
391
- type: 'overflow',
392
- kind: null,
393
- path,
394
- destinationPath: null,
395
- version: null,
396
- previousVersion: null,
397
- });
398
- }
399
- if (!isEntryWatchType(event.type))
400
- throw new TypeError('Unknown filesystem watch event type.');
401
- if (event.kind !== 'file' && event.kind !== 'directory') {
402
- throw new TypeError('Unknown filesystem watch entry kind.');
403
- }
404
- const destinationPath = event.destinationPath === null
405
- ? null
406
- : typeof event.destinationPath === 'string'
407
- ? parseWorkspacePath(event.destinationPath)
408
- : (() => {
409
- throw new TypeError('Watch destination path must be a string or null.');
410
- })();
411
- if ((event.type === 'moved') !== (destinationPath !== null)) {
412
- throw new TypeError('Only moved watch events may have a destination path.');
413
- }
414
- return Object.freeze({
415
- sequence: event.sequence,
416
- origin: event.origin,
417
- type: event.type,
418
- kind: event.kind,
419
- path,
420
- destinationPath,
421
- version: event.version === null ? null : parseFileSystemVersion(event.version),
422
- previousVersion: event.previousVersion === null ? null : parseFileSystemVersion(event.previousVersion),
423
- });
424
- }
425
- function normalizeRemoveResult(value) {
426
- if (!isRecord(value) || typeof value.removed !== 'boolean') {
427
- throw new TypeError('Filesystem transport returned an invalid remove result.');
428
- }
429
- return Object.freeze({ removed: value.removed, version: parseFileSystemVersion(value.version) });
430
- }
431
- function assertCapabilities(value, operation) {
432
- if (!isRecord(value)) {
433
- throw invalidTransport(operation, 'Filesystem host returned invalid capabilities.');
434
- }
435
- for (const key of Object.keys(ELECTRON_FILE_SYSTEM_V2_CAPABILITIES)) {
436
- if (value[key] !== ELECTRON_FILE_SYSTEM_V2_CAPABILITIES[key]) {
437
- throw invalidTransport(operation, `Filesystem host capability mismatch: ${key}.`);
438
- }
439
- }
440
- }
441
- function compareDirectoryEntries(left, right) {
442
- if (left.kind !== right.kind)
443
- 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
- function isWatchOrigin(value) {
450
- return value === 'local' || value === 'external' || value === 'unknown';
451
- }
452
- function isEntryWatchType(value) {
453
- return value === 'created' || value === 'modified' || value === 'removed' || value === 'moved';
454
- }
455
- function isNonNegativeSafeInteger(value) {
456
- return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;
457
- }
458
- function isPositiveSafeInteger(value) {
459
- return isNonNegativeSafeInteger(value) && value > 0;
460
- }
461
- function isRecord(value) {
462
- return typeof value === 'object' && value !== null;
463
- }
464
- function invalidTransport(operation, message) {
465
- return new FsError('io', message, { operation, retryable: false });
466
- }
467
- function transportErrorFromUnknown(error, operation) {
468
- if (error instanceof TypeError)
469
- return invalidTransport(operation, error.message);
470
- return withOperation(fsErrorFromUnknown(error, { operation }), operation);
471
- }
472
- function withOperation(error, operation) {
473
- if (error.operation === operation)
474
- return error;
475
- return new FsError(error.code, error.message, {
476
- operation,
477
- path: error.path ?? undefined,
478
- destinationPath: error.destinationPath ?? undefined,
479
- retryable: error.retryable,
480
- });
481
- }
482
- function copyBytes(data) {
483
- const source = ArrayBuffer.isView(data)
484
- ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)
485
- : new Uint8Array(data);
486
- const copy = new Uint8Array(source.byteLength);
487
- copy.set(source);
488
- return copy.buffer;
489
- }
490
- function copyWireBuffer(data) {
491
- if (Object.prototype.toString.call(data) !== '[object ArrayBuffer]') {
492
- throw new TypeError('Expected an ArrayBuffer from the filesystem transport.');
493
- }
494
- return data.slice(0);
495
- }
496
- function createInstanceId() {
497
- const randomUUID = globalThis.crypto?.randomUUID;
498
- if (typeof randomUUID === 'function')
499
- return randomUUID.call(globalThis.crypto);
500
- fallbackInstanceSequence += 1;
501
- return `electron-fs-v2-${Date.now()}-${fallbackInstanceSequence}`;
502
- }
503
- //# sourceMappingURL=electron-provider-v2.js.map