@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,17 +0,0 @@
1
- export type { WorkspaceDescriptor, TransientOrigin } from './types.js';
2
-
3
- export {
4
- listWorkspaces,
5
- getWorkspace,
6
- saveWorkspace,
7
- removeWorkspace,
8
- touchWorkspace,
9
- ensureDefaultWorkspace,
10
- registerTransientWorkspace,
11
- getTransientWorkspace,
12
- unregisterTransientWorkspace,
13
- } from './workspace-manager.js';
14
- export {
15
- reconcileElectronWorkspaceDescriptors,
16
- type ElectronWorkspaceReconciliation,
17
- } from './reconcile-electron.js';
@@ -1,65 +0,0 @@
1
- import type { ElectronWorkspaceInfo, HostEnvironment } from '../host/types.js';
2
- import type { WorkspaceDescriptor } from './types.js';
3
-
4
- export interface ElectronWorkspaceReconciliation {
5
- /** Obsolete renderer descriptors to remove before attempting restoration. */
6
- readonly removeIds: readonly string[];
7
- /** Canonical main-authorized descriptors to insert or replace. */
8
- readonly upsert: readonly WorkspaceDescriptor[];
9
- /** Safe navigation migration for a local descriptor matched by root. */
10
- readonly idRemap: Readonly<Record<string, string>>;
11
- }
12
-
13
- function comparableRoot(rootPath: string, platform: HostEnvironment['platform']): string {
14
- const normalized = rootPath.replace(/\\/gu, '/').replace(/\/+$/gu, '');
15
- return platform === 'win32' ? normalized.toLowerCase() : normalized;
16
- }
17
-
18
- /**
19
- * Reconcile renderer IndexedDB metadata with the main process authority list.
20
- * `hostWorkspaces` is authoritative: local Electron descriptors absent from
21
- * it cannot be opened safely and are removed. Root-path matching carries user
22
- * metadata across an id migration without treating that display path as
23
- * authority.
24
- */
25
- export function reconcileElectronWorkspaceDescriptors(
26
- local: readonly WorkspaceDescriptor[],
27
- hostWorkspaces: readonly ElectronWorkspaceInfo[],
28
- platform: HostEnvironment['platform'],
29
- now: string,
30
- ): ElectronWorkspaceReconciliation {
31
- const electron = local.filter((workspace) => workspace.type === 'electron-native');
32
- const matchedLocalIds = new Set<string>();
33
- const idRemap: Record<string, string> = {};
34
- const upsert = hostWorkspaces.map((hostWorkspace): WorkspaceDescriptor => {
35
- const root = comparableRoot(hostWorkspace.rootPath, platform);
36
- const candidates = electron.filter(
37
- (workspace) => workspace.rootPath && comparableRoot(workspace.rootPath, platform) === root,
38
- );
39
- const matching = candidates.sort((left, right) =>
40
- right.lastOpened.localeCompare(left.lastOpened),
41
- )[0];
42
- if (matching) {
43
- matchedLocalIds.add(matching.id);
44
- if (matching.id !== hostWorkspace.id) idRemap[matching.id] = hostWorkspace.id;
45
- }
46
- return {
47
- id: hostWorkspace.id,
48
- name: matching?.name ?? hostWorkspace.name,
49
- type: 'electron-native',
50
- rootPath: hostWorkspace.rootPath,
51
- lastOpened: matching?.lastOpened ?? now,
52
- ...(matching?.versioningOverride ? { versioningOverride: matching.versioningOverride } : {}),
53
- };
54
- });
55
- const canonicalIds = new Set(hostWorkspaces.map((workspace) => workspace.id));
56
- const removeIds = electron
57
- .filter(
58
- (workspace) =>
59
- !canonicalIds.has(workspace.id) ||
60
- (matchedLocalIds.has(workspace.id) &&
61
- !upsert.some((candidate) => candidate.id === workspace.id)),
62
- )
63
- .map((workspace) => workspace.id);
64
- return { removeIds, upsert, idRemap };
65
- }
@@ -1,67 +0,0 @@
1
- /**
2
- * Origin of a transient workspace — records where its contents came from and
3
- * how to save them back. Set only on `type: 'transient'` workspaces.
4
- * - 'loose-file' — a single markdown file opened from the OS (Electron);
5
- * edits write back through an owner-scoped `resourceId` grant.
6
- * - 'dbk' — a `.dbk`/zip bundle unpacked into memory (Electron); edits are
7
- * re-zipped and written back through an owner-scoped resource grant.
8
- * - 'web-file' — a single markdown file launched into the installed web app
9
- * (File Handling API); edits write back through `handle`.
10
- * - 'web-dbk' — a `.dbk`/zip bundle launched into the installed web app;
11
- * edits are re-zipped and written back through `handle`.
12
- *
13
- * The web variants hold a live `FileSystemFileHandle`. That is safe because
14
- * transient descriptors are never persisted — they live only in the
15
- * in-memory registry (see workspace-manager) for the current page session.
16
- */
17
- export type TransientOrigin =
18
- | { kind: 'loose-file'; resourceId: string }
19
- | {
20
- kind: 'dbk';
21
- resourceId: string;
22
- /** SHA-256 of the last bundle version acknowledged by the host. */
23
- version: string | null;
24
- }
25
- | { kind: 'web-file'; handle: FileSystemFileHandle; name: string }
26
- | {
27
- kind: 'web-dbk';
28
- handle: FileSystemFileHandle;
29
- name: string;
30
- /** SHA-256 of the last bundle version observed on disk. */
31
- version: string | null;
32
- };
33
-
34
- /**
35
- * Workspace — a named binding to a FileSystemProvider, representing
36
- * the user's current working context (a folder of markdown files).
37
- */
38
-
39
- export interface WorkspaceDescriptor {
40
- /** Unique stable identifier (persisted in IndexedDB). */
41
- id: string;
42
- /** User-visible label. */
43
- name: string;
44
- /**
45
- * Provider kind:
46
- * - 'indexeddb' — browser-local storage (web only)
47
- * - 'native' — File System Access API (web Chrome/Edge only)
48
- * - 'electron-native' — Electron main-process native filesystem
49
- * - 'transient' — session-only, in-memory (a loose file or `.dbk` opened
50
- * from the OS). Never persisted; its provider lives in an in-memory
51
- * registry (see workspace-manager) and it saves back to `origin`.
52
- */
53
- type: 'indexeddb' | 'native' | 'electron-native' | 'transient';
54
- /** ISO timestamp of last access. */
55
- lastOpened: string;
56
- /** Absolute filesystem path for 'electron-native' workspaces. */
57
- rootPath?: string;
58
- /** For 'transient' workspaces: where the contents came from / save back to. */
59
- origin?: TransientOrigin;
60
- /**
61
- * Per-workspace override for the global versioning preference. When
62
- * `'inherit'` (or absent), the global preference applies. `'on'` /
63
- * `'off'` force the corresponding behavior regardless of the global
64
- * setting. See `resolveVersioningEnabled` in the preferences module.
65
- */
66
- versioningOverride?: 'inherit' | 'on' | 'off';
67
- }
@@ -1,151 +0,0 @@
1
- /**
2
- * WorkspaceManager — manages the list of known workspaces in IndexedDB
3
- * and provides helpers for creating / switching / removing them.
4
- *
5
- * The actual FileSystemProvider instances are created by the caller
6
- * (since native providers need a DirectoryHandle from user interaction).
7
- */
8
-
9
- import { LocalForageAdapter } from '@bendyline/squisq/storage';
10
- import { getFileSystemProviderV2, type FileSystemProvider } from '../filesystem/types.js';
11
- import type { WorkspaceDescriptor } from './types.js';
12
-
13
- const DB_NAME = 'docblocks-workspaces';
14
- const STORE_NAME = 'workspaces';
15
- const LIST_KEY = 'workspace-list';
16
- const DEFAULT_WORKSPACE_ID = 'default';
17
-
18
- const store = new LocalForageAdapter({
19
- name: DB_NAME,
20
- storeName: STORE_NAME,
21
- });
22
-
23
- /**
24
- * Session-only transient workspaces (a loose file or `.dbk` opened from the
25
- * OS). Kept purely in memory — never written to the persisted list — with
26
- * their pre-built provider registered alongside the descriptor. Lost on
27
- * reload, which is the intended "transient for the app session" behaviour.
28
- */
29
- interface TransientEntry {
30
- descriptor: WorkspaceDescriptor;
31
- provider: FileSystemProvider;
32
- }
33
- const transientWorkspaces = new Map<string, TransientEntry>();
34
-
35
- /** Register a transient workspace and its (already-built) provider. */
36
- export function registerTransientWorkspace(
37
- descriptor: WorkspaceDescriptor,
38
- provider: FileSystemProvider,
39
- ): void {
40
- const previous = transientWorkspaces.get(descriptor.id);
41
- if (previous && previous.provider !== provider) {
42
- void getFileSystemProviderV2(previous.provider)?.dispose();
43
- }
44
- transientWorkspaces.set(descriptor.id, { descriptor, provider });
45
- }
46
-
47
- /** Look up a transient workspace (descriptor + provider) by id, if any. */
48
- export function getTransientWorkspace(
49
- id: string,
50
- ): { descriptor: WorkspaceDescriptor; provider: FileSystemProvider } | null {
51
- return transientWorkspaces.get(id) ?? null;
52
- }
53
-
54
- /** Forget a transient workspace (e.g. when it is closed). */
55
- export async function unregisterTransientWorkspace(id: string): Promise<void> {
56
- const entry = transientWorkspaces.get(id);
57
- if (!entry) return;
58
- transientWorkspaces.delete(id);
59
- await getFileSystemProviderV2(entry.provider)?.dispose();
60
- }
61
-
62
- /** The persisted (on-disk) workspace list only — excludes transient ones. */
63
- async function listPersisted(): Promise<WorkspaceDescriptor[]> {
64
- const list = await store.get<WorkspaceDescriptor[]>(LIST_KEY);
65
- return list ?? [];
66
- }
67
-
68
- /**
69
- * Get all known workspace descriptors — persisted plus any session-only
70
- * transient ones (so they show in the picker and resolve for the session).
71
- */
72
- export async function listWorkspaces(): Promise<WorkspaceDescriptor[]> {
73
- const persisted = await listPersisted();
74
- const transient = [...transientWorkspaces.values()].map((t) => t.descriptor);
75
- return [...persisted, ...transient];
76
- }
77
-
78
- /**
79
- * Get a specific workspace descriptor by id (transient or persisted).
80
- */
81
- export async function getWorkspace(id: string): Promise<WorkspaceDescriptor | null> {
82
- const transient = transientWorkspaces.get(id);
83
- if (transient) return transient.descriptor;
84
- const list = await listPersisted();
85
- return list.find((w) => w.id === id) ?? null;
86
- }
87
-
88
- /**
89
- * Add or update a workspace descriptor. If a workspace with the same id
90
- * already exists, it is replaced. Transient workspaces are never persisted.
91
- */
92
- export async function saveWorkspace(workspace: WorkspaceDescriptor): Promise<void> {
93
- if (workspace.type === 'transient') return;
94
- const list = await listPersisted();
95
- const idx = list.findIndex((w) => w.id === workspace.id);
96
- if (idx >= 0) {
97
- list[idx] = workspace;
98
- } else {
99
- list.push(workspace);
100
- }
101
- await store.set(LIST_KEY, list);
102
- }
103
-
104
- /**
105
- * Remove a workspace descriptor by id (transient or persisted).
106
- */
107
- export async function removeWorkspace(id: string): Promise<void> {
108
- if (transientWorkspaces.has(id)) {
109
- await unregisterTransientWorkspace(id);
110
- return;
111
- }
112
- const list = await listPersisted();
113
- const filtered = list.filter((w) => w.id !== id);
114
- await store.set(LIST_KEY, filtered);
115
- }
116
-
117
- /**
118
- * Touch the lastOpened timestamp on a workspace. For transient workspaces this
119
- * updates the in-memory descriptor only (nothing is persisted).
120
- */
121
- export async function touchWorkspace(id: string): Promise<void> {
122
- const transient = transientWorkspaces.get(id);
123
- if (transient) {
124
- transient.descriptor.lastOpened = new Date().toISOString();
125
- return;
126
- }
127
- const list = await listPersisted();
128
- const workspace = list.find((w) => w.id === id);
129
- if (workspace) {
130
- workspace.lastOpened = new Date().toISOString();
131
- await store.set(LIST_KEY, list);
132
- }
133
- }
134
-
135
- /**
136
- * Ensure a default IndexedDB workspace exists. Called on app startup.
137
- * Returns the descriptor.
138
- */
139
- export async function ensureDefaultWorkspace(): Promise<WorkspaceDescriptor> {
140
- const existing = await getWorkspace(DEFAULT_WORKSPACE_ID);
141
- if (existing) return existing;
142
-
143
- const descriptor: WorkspaceDescriptor = {
144
- id: DEFAULT_WORKSPACE_ID,
145
- name: 'My Documents',
146
- type: 'indexeddb',
147
- lastOpened: new Date().toISOString(),
148
- };
149
- await saveWorkspace(descriptor);
150
- return descriptor;
151
- }