@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,171 +0,0 @@
1
- /**
2
- * Legacy FileSystemProvider facade over the revisioned IndexedDB authority.
3
- *
4
- * The old `fs:*` namespace is migration input only. Keeping this facade as an
5
- * adapter prevents current callers from recreating a second persistent source
6
- * of truth while the workspace moves to FileSystemProviderV2.
7
- */
8
-
9
- import type { FileCommitResult, FileMeta, FileSystemEntry, FileSystemProvider } from './types.js';
10
- import { FsError, type FsOperation } from './fs-error.js';
11
- import { parseWorkspacePath, type WorkspacePath } from './workspace-path.js';
12
- import { RawIndexedDBFileSystemStore, type IndexedDBFileSystemStore } from './indexeddb-store.js';
13
- import { IndexedDBFileSystemProviderV2 } from './indexeddb-provider-v2.js';
14
-
15
- export interface IndexedDBFileSystemProviderOptions {
16
- /** Injectable transaction store for deterministic fault/concurrency tests. */
17
- store?: IndexedDBFileSystemStore;
18
- /** Injectable metadata clock. */
19
- now?: () => Date;
20
- }
21
-
22
- export class IndexedDBFileSystemProvider implements FileSystemProvider {
23
- public readonly id: string;
24
- public readonly label: string;
25
- public readonly v2: IndexedDBFileSystemProviderV2;
26
-
27
- private disposed = false;
28
-
29
- public constructor(id: string, label: string, options: IndexedDBFileSystemProviderOptions = {}) {
30
- this.id = id;
31
- this.label = label;
32
- const store = options.store ?? new RawIndexedDBFileSystemStore(`docblocks-fs-${id}`, 'files');
33
- this.v2 = new IndexedDBFileSystemProviderV2(id, label, {
34
- store,
35
- now: options.now,
36
- closeStoreOnDispose: true,
37
- });
38
- }
39
-
40
- /** Release the underlying database connection after accepted work settles. */
41
- public dispose(): Promise<void> {
42
- this.disposed = true;
43
- return this.v2.dispose();
44
- }
45
-
46
- public async readFile(path: string): Promise<string | null> {
47
- this.assertOpen('read');
48
- const read = await this.v2.readFile(this.path(path, false, 'read'));
49
- return read ? new TextDecoder().decode(read.data) : null;
50
- }
51
-
52
- public async writeFile(path: string, content: string): Promise<void> {
53
- this.assertOpen('write');
54
- await this.v2.writeFile(this.path(path, false, 'write'), new TextEncoder().encode(content), {
55
- createParents: true,
56
- });
57
- }
58
-
59
- public async commitFile(
60
- path: string,
61
- content: string,
62
- expectedContent: string | null,
63
- ): Promise<FileCommitResult> {
64
- this.assertOpen('write');
65
- const canonical = this.path(path, false, 'write');
66
- const current = await this.v2.readFile(canonical);
67
- const currentContent = current ? new TextDecoder().decode(current.data) : null;
68
- if (currentContent !== expectedContent && currentContent !== content) {
69
- return {
70
- status: 'conflict',
71
- content: currentContent,
72
- version: current?.entry.version ?? null,
73
- };
74
- }
75
-
76
- try {
77
- const committed = await this.v2.writeFile(canonical, new TextEncoder().encode(content), {
78
- createParents: true,
79
- expectedVersion: current?.entry.version ?? null,
80
- });
81
- return { status: 'committed', version: committed.version };
82
- } catch (error: unknown) {
83
- if (!(error instanceof FsError) || error.code !== 'conflict') throw error;
84
- const latest = await this.v2.readFile(canonical);
85
- return {
86
- status: 'conflict',
87
- content: latest ? new TextDecoder().decode(latest.data) : null,
88
- version: latest?.entry.version ?? null,
89
- };
90
- }
91
- }
92
-
93
- public async delete(path: string): Promise<void> {
94
- this.assertOpen('remove');
95
- await this.v2.remove(this.path(path, false, 'remove'), {
96
- recursive: true,
97
- missing: 'ignore',
98
- });
99
- }
100
-
101
- public async rename(oldPath: string, newPath: string): Promise<void> {
102
- this.assertOpen('move');
103
- await this.v2.move(this.path(oldPath, false, 'move'), this.path(newPath, false, 'move'), {
104
- createParents: true,
105
- });
106
- }
107
-
108
- public async readDirectory(path: string): Promise<FileSystemEntry[]> {
109
- this.assertOpen('list');
110
- try {
111
- const entries = await this.v2.readDirectory(this.path(path, true, 'list'));
112
- return entries.map((entry) => ({
113
- kind: entry.kind,
114
- name: entry.name,
115
- path: entry.path,
116
- }));
117
- } catch (error: unknown) {
118
- if (error instanceof FsError && error.code === 'not-found') return [];
119
- throw error;
120
- }
121
- }
122
-
123
- public async exists(path: string): Promise<boolean> {
124
- this.assertOpen('stat');
125
- return (await this.v2.stat(this.path(path, true, 'stat'))) !== null;
126
- }
127
-
128
- public async createDirectory(path: string): Promise<void> {
129
- this.assertOpen('create-directory');
130
- await this.v2.createDirectory(this.path(path, false, 'create-directory'), {
131
- createParents: true,
132
- mode: 'ensure',
133
- });
134
- }
135
-
136
- public async stat(path: string): Promise<FileMeta | null> {
137
- this.assertOpen('stat');
138
- const entry = await this.v2.stat(this.path(path, false, 'stat'));
139
- if (!entry || entry.kind !== 'file') return null;
140
- return {
141
- name: entry.name,
142
- path: entry.path,
143
- size: entry.size,
144
- lastModified: entry.lastModified,
145
- };
146
- }
147
-
148
- public async readBinary(path: string): Promise<ArrayBuffer | null> {
149
- this.assertOpen('read');
150
- return (await this.v2.readFile(this.path(path, false, 'read')))?.data ?? null;
151
- }
152
-
153
- public async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {
154
- this.assertOpen('write');
155
- await this.v2.writeFile(this.path(path, false, 'write'), data, { createParents: true });
156
- }
157
-
158
- private path(path: string, allowRoot: boolean, operation: FsOperation): WorkspacePath {
159
- const canonical = parseWorkspacePath(path);
160
- if (canonical || allowRoot) return canonical;
161
- throw new FsError('invalid-path', 'The filesystem root cannot be used as a mutation target.', {
162
- operation,
163
- path,
164
- });
165
- }
166
-
167
- private assertOpen(operation: FsOperation): void {
168
- if (!this.disposed) return;
169
- throw new FsError('closed', 'The IndexedDB filesystem provider is disposed.', { operation });
170
- }
171
- }
@@ -1,207 +0,0 @@
1
- /**
2
- * Minimal, error-propagating IndexedDB store used by the virtual filesystem.
3
- *
4
- * The previous Squisq LocalForage adapter intentionally converted failed
5
- * reads/enumerations/removals into null/empty/success. Those semantics are
6
- * unsuitable for filesystem mutations: an unavailable database must never be
7
- * interpreted as an absent file. This layer opens the old database and object
8
- * store directly so existing data can be migrated in one transaction.
9
- */
10
-
11
- export type IndexedDBFileSystemTransactionMode = 'readonly' | 'readwrite';
12
-
13
- export interface IndexedDBFileSystemTransaction {
14
- get<T>(key: string): Promise<T | null>;
15
- put<T>(key: string, value: T): Promise<void>;
16
- delete(key: string): Promise<void>;
17
- keys(): Promise<string[]>;
18
- /** O(log n) namespace probe in the concrete IndexedDB implementation. */
19
- hasKeyWithPrefix(prefix: string): Promise<boolean>;
20
- }
21
-
22
- export interface IndexedDBFileSystemStore {
23
- transaction<T>(
24
- mode: IndexedDBFileSystemTransactionMode,
25
- operation: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,
26
- ): Promise<T>;
27
- close?(): void;
28
- }
29
-
30
- export class RawIndexedDBFileSystemStore implements IndexedDBFileSystemStore {
31
- private database: IDBDatabase | null = null;
32
- private opening: Promise<IDBDatabase> | null = null;
33
- private closed = false;
34
-
35
- public constructor(
36
- private readonly databaseName: string,
37
- private readonly storeName: string,
38
- ) {}
39
-
40
- public async transaction<T>(
41
- mode: IndexedDBFileSystemTransactionMode,
42
- operation: (transaction: IndexedDBFileSystemTransaction) => Promise<T>,
43
- ): Promise<T> {
44
- const database = await this.getDatabase();
45
- const nativeTransaction = database.transaction(this.storeName, mode);
46
- const completion = waitForTransaction(nativeTransaction);
47
- const transaction = new RawIndexedDBFileSystemTransaction(
48
- nativeTransaction.objectStore(this.storeName),
49
- );
50
-
51
- let result: T;
52
- try {
53
- result = await operation(transaction);
54
- } catch (error: unknown) {
55
- try {
56
- nativeTransaction.abort();
57
- } catch {
58
- // The request failure may already have aborted the transaction.
59
- }
60
- await completion.catch(() => undefined);
61
- throw error;
62
- }
63
-
64
- await completion;
65
- return result;
66
- }
67
-
68
- public close(): void {
69
- if (this.closed) return;
70
- this.closed = true;
71
- this.database?.close();
72
- this.database = null;
73
- this.opening = null;
74
- }
75
-
76
- private getDatabase(): Promise<IDBDatabase> {
77
- if (this.closed) {
78
- return Promise.reject(new Error('The IndexedDB filesystem store is closed.'));
79
- }
80
- if (this.database) return Promise.resolve(this.database);
81
- if (this.opening) return this.opening;
82
- if (typeof indexedDB === 'undefined') {
83
- return Promise.reject(new Error('IndexedDB is not available in this environment.'));
84
- }
85
-
86
- this.opening = openDatabaseWithStore(this.databaseName, this.storeName)
87
- .then((database) => {
88
- if (this.closed) {
89
- database.close();
90
- throw new Error('The IndexedDB filesystem store is closed.');
91
- }
92
- this.database = database;
93
- this.opening = null;
94
- database.onversionchange = () => {
95
- database.close();
96
- if (this.database === database) this.database = null;
97
- };
98
- return database;
99
- })
100
- .catch((error: unknown) => {
101
- this.opening = null;
102
- throw error;
103
- });
104
- return this.opening;
105
- }
106
- }
107
-
108
- class RawIndexedDBFileSystemTransaction implements IndexedDBFileSystemTransaction {
109
- public constructor(private readonly store: IDBObjectStore) {}
110
-
111
- public async get<T>(key: string): Promise<T | null> {
112
- const value = await requestResult(this.store.get(key));
113
- return value === undefined ? null : (value as T);
114
- }
115
-
116
- public async put<T>(key: string, value: T): Promise<void> {
117
- await requestResult(this.store.put(value, key));
118
- }
119
-
120
- public async delete(key: string): Promise<void> {
121
- await requestResult(this.store.delete(key));
122
- }
123
-
124
- public async keys(): Promise<string[]> {
125
- const keys = await requestResult(this.store.getAllKeys());
126
- return keys.map((key) => {
127
- if (typeof key !== 'string') {
128
- throw new Error('The DocBlocks filesystem store contains a non-string key.');
129
- }
130
- return key;
131
- });
132
- }
133
-
134
- public async hasKeyWithPrefix(prefix: string): Promise<boolean> {
135
- const cursor = await requestResult(this.store.openKeyCursor(IDBKeyRange.lowerBound(prefix)));
136
- return cursor !== null && typeof cursor.key === 'string' && cursor.key.startsWith(prefix);
137
- }
138
- }
139
-
140
- async function openDatabaseWithStore(
141
- databaseName: string,
142
- storeName: string,
143
- ): Promise<IDBDatabase> {
144
- const database = await openDatabase(databaseName, undefined, (upgradeDatabase) => {
145
- if (!upgradeDatabase.objectStoreNames.contains(storeName)) {
146
- upgradeDatabase.createObjectStore(storeName);
147
- }
148
- });
149
- if (database.objectStoreNames.contains(storeName)) return database;
150
-
151
- const nextVersion = database.version + 1;
152
- database.close();
153
- return openDatabase(databaseName, nextVersion, (upgradeDatabase) => {
154
- if (!upgradeDatabase.objectStoreNames.contains(storeName)) {
155
- upgradeDatabase.createObjectStore(storeName);
156
- }
157
- });
158
- }
159
-
160
- function openDatabase(
161
- databaseName: string,
162
- version: number | undefined,
163
- upgrade: (database: IDBDatabase) => void,
164
- ): Promise<IDBDatabase> {
165
- return new Promise((resolve, reject) => {
166
- const request =
167
- version === undefined ? indexedDB.open(databaseName) : indexedDB.open(databaseName, version);
168
- let settled = false;
169
-
170
- request.onupgradeneeded = () => upgrade(request.result);
171
- request.onsuccess = () => {
172
- if (settled) {
173
- request.result.close();
174
- return;
175
- }
176
- settled = true;
177
- resolve(request.result);
178
- };
179
- request.onerror = () => {
180
- if (settled) return;
181
- settled = true;
182
- reject(request.error ?? new Error(`Could not open IndexedDB database ${databaseName}.`));
183
- };
184
- request.onblocked = () => {
185
- if (settled) return;
186
- settled = true;
187
- reject(new Error(`IndexedDB database ${databaseName} is blocked by another open page.`));
188
- };
189
- });
190
- }
191
-
192
- function requestResult<T>(request: IDBRequest<T>): Promise<T> {
193
- return new Promise((resolve, reject) => {
194
- request.onsuccess = () => resolve(request.result);
195
- request.onerror = () => reject(request.error ?? new Error('IndexedDB request failed.'));
196
- });
197
- }
198
-
199
- function waitForTransaction(transaction: IDBTransaction): Promise<void> {
200
- return new Promise((resolve, reject) => {
201
- transaction.oncomplete = () => resolve();
202
- transaction.onabort = () =>
203
- reject(transaction.error ?? new Error('IndexedDB transaction was aborted.'));
204
- transaction.onerror = () =>
205
- reject(transaction.error ?? new Error('IndexedDB transaction failed.'));
206
- });
207
- }
@@ -1,12 +0,0 @@
1
- /** Browser-local persistent filesystem provider entry point. */
2
- export { IndexedDBFileSystemProvider } from './indexeddb-provider.js';
3
- export {
4
- IndexedDBFileSystemProviderV2,
5
- type IndexedDBFileSystemProviderV2Options,
6
- type IndexedDBLegacyConflictReason,
7
- type IndexedDBLegacyConflictResolution,
8
- type IndexedDBLegacyMigrationConflict,
9
- type IndexedDBLegacyRecoveryCandidate,
10
- type IndexedDBLegacyRecoveryKind,
11
- } from './indexeddb-provider-v2.js';
12
- export { IndexedDBContentContainer } from './indexeddb-content-container.js';