@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,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';