@bendyline/docblocks 1.1.2 → 2.0.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 (270) hide show
  1. package/README.md +76 -11
  2. package/dist/chunk-2D7Y4IR3.js +1293 -0
  3. package/dist/chunk-2D7Y4IR3.js.map +1 -0
  4. package/dist/chunk-5MYAICRE.js +957 -0
  5. package/dist/chunk-5MYAICRE.js.map +1 -0
  6. package/dist/chunk-75UUF6C4.js +802 -0
  7. package/dist/chunk-75UUF6C4.js.map +1 -0
  8. package/dist/chunk-AEHCVWU5.js +25 -0
  9. package/dist/chunk-AEHCVWU5.js.map +1 -0
  10. package/dist/chunk-AYZ4HN5M.js +20 -0
  11. package/dist/chunk-AYZ4HN5M.js.map +1 -0
  12. package/dist/chunk-EGNDADXB.js +111 -0
  13. package/dist/chunk-EGNDADXB.js.map +1 -0
  14. package/dist/chunk-EZKJZUNJ.js +13 -0
  15. package/dist/chunk-EZKJZUNJ.js.map +1 -0
  16. package/dist/chunk-FNW556FN.js +75 -0
  17. package/dist/chunk-FNW556FN.js.map +1 -0
  18. package/dist/chunk-GCPBEMMH.js +563 -0
  19. package/dist/chunk-GCPBEMMH.js.map +1 -0
  20. package/dist/chunk-J32GU3F3.js +1664 -0
  21. package/dist/chunk-J32GU3F3.js.map +1 -0
  22. package/dist/chunk-PGR7LK6D.js +1062 -0
  23. package/dist/chunk-PGR7LK6D.js.map +1 -0
  24. package/dist/chunk-RQJRQF46.js +787 -0
  25. package/dist/chunk-RQJRQF46.js.map +1 -0
  26. package/dist/{chunk-ME76RUMR.js → chunk-RVQHY3XU.js} +15 -1
  27. package/dist/chunk-RVQHY3XU.js.map +1 -0
  28. package/dist/chunk-SI2LU2RP.js +224 -0
  29. package/dist/chunk-SI2LU2RP.js.map +1 -0
  30. package/dist/chunk-W5UUUII5.js +142 -0
  31. package/dist/chunk-W5UUUII5.js.map +1 -0
  32. package/dist/document/document-session.d.ts +127 -0
  33. package/dist/document/document-session.d.ts.map +1 -0
  34. package/dist/document/document-session.js +749 -0
  35. package/dist/document/document-session.js.map +1 -0
  36. package/dist/document/filesystem-target.d.ts +17 -0
  37. package/dist/document/filesystem-target.d.ts.map +1 -0
  38. package/dist/document/filesystem-target.js +70 -0
  39. package/dist/document/filesystem-target.js.map +1 -0
  40. package/dist/document/index.d.ts +6 -0
  41. package/dist/document/index.d.ts.map +1 -0
  42. package/dist/document/index.js +4 -0
  43. package/dist/document/index.js.map +1 -0
  44. package/dist/document/recovery-journal.d.ts +125 -0
  45. package/dist/document/recovery-journal.d.ts.map +1 -0
  46. package/dist/document/recovery-journal.js +385 -0
  47. package/dist/document/recovery-journal.js.map +1 -0
  48. package/dist/document/types.d.ts +89 -0
  49. package/dist/document/types.d.ts.map +1 -0
  50. package/dist/document/types.js +9 -0
  51. package/dist/document/types.js.map +1 -0
  52. package/dist/filesystem/commit-lock.d.ts +3 -0
  53. package/dist/filesystem/commit-lock.d.ts.map +1 -0
  54. package/dist/filesystem/commit-lock.js +20 -0
  55. package/dist/filesystem/commit-lock.js.map +1 -0
  56. package/dist/filesystem/dbk-workspace.d.ts +34 -0
  57. package/dist/filesystem/dbk-workspace.d.ts.map +1 -0
  58. package/dist/filesystem/dbk-workspace.js +85 -0
  59. package/dist/filesystem/dbk-workspace.js.map +1 -0
  60. package/dist/filesystem/electron-provider-v2.d.ts +36 -0
  61. package/dist/filesystem/electron-provider-v2.d.ts.map +1 -0
  62. package/dist/filesystem/electron-provider-v2.js +503 -0
  63. package/dist/filesystem/electron-provider-v2.js.map +1 -0
  64. package/dist/filesystem/electron-provider.d.ts +6 -3
  65. package/dist/filesystem/electron-provider.d.ts.map +1 -1
  66. package/dist/filesystem/electron-provider.js +18 -13
  67. package/dist/filesystem/electron-provider.js.map +1 -1
  68. package/dist/filesystem/electron.d.ts +4 -0
  69. package/dist/filesystem/electron.d.ts.map +1 -0
  70. package/dist/filesystem/electron.js +4 -0
  71. package/dist/filesystem/electron.js.map +1 -0
  72. package/dist/filesystem/filesystem-content-container.d.ts +1 -1
  73. package/dist/filesystem/filesystem-content-container.d.ts.map +1 -1
  74. package/dist/filesystem/filesystem-content-container.js +50 -13
  75. package/dist/filesystem/filesystem-content-container.js.map +1 -1
  76. package/dist/filesystem/fs-error.d.ts +46 -0
  77. package/dist/filesystem/fs-error.d.ts.map +1 -0
  78. package/dist/filesystem/fs-error.js +170 -0
  79. package/dist/filesystem/fs-error.js.map +1 -0
  80. package/dist/filesystem/index.d.ts +15 -1
  81. package/dist/filesystem/index.d.ts.map +1 -1
  82. package/dist/filesystem/index.js +13 -0
  83. package/dist/filesystem/index.js.map +1 -1
  84. package/dist/filesystem/indexeddb-content-container.d.ts +3 -1
  85. package/dist/filesystem/indexeddb-content-container.d.ts.map +1 -1
  86. package/dist/filesystem/indexeddb-content-container.js +18 -11
  87. package/dist/filesystem/indexeddb-content-container.js.map +1 -1
  88. package/dist/filesystem/indexeddb-provider-v2.d.ts +96 -0
  89. package/dist/filesystem/indexeddb-provider-v2.d.ts.map +1 -0
  90. package/dist/filesystem/indexeddb-provider-v2.js +1241 -0
  91. package/dist/filesystem/indexeddb-provider-v2.js.map +1 -0
  92. package/dist/filesystem/indexeddb-provider.d.ts +21 -14
  93. package/dist/filesystem/indexeddb-provider.d.ts.map +1 -1
  94. package/dist/filesystem/indexeddb-provider.js +111 -261
  95. package/dist/filesystem/indexeddb-provider.js.map +1 -1
  96. package/dist/filesystem/indexeddb-store.d.ts +34 -0
  97. package/dist/filesystem/indexeddb-store.d.ts.map +1 -0
  98. package/dist/filesystem/indexeddb-store.js +165 -0
  99. package/dist/filesystem/indexeddb-store.js.map +1 -0
  100. package/dist/filesystem/indexeddb.d.ts +5 -0
  101. package/dist/filesystem/indexeddb.d.ts.map +1 -0
  102. package/dist/filesystem/indexeddb.js +5 -0
  103. package/dist/filesystem/indexeddb.js.map +1 -0
  104. package/dist/filesystem/legacy-v2-adapter.d.ts +62 -0
  105. package/dist/filesystem/legacy-v2-adapter.d.ts.map +1 -0
  106. package/dist/filesystem/legacy-v2-adapter.js +499 -0
  107. package/dist/filesystem/legacy-v2-adapter.js.map +1 -0
  108. package/dist/filesystem/memory-provider-v2.d.ts +92 -0
  109. package/dist/filesystem/memory-provider-v2.d.ts.map +1 -0
  110. package/dist/filesystem/memory-provider-v2.js +615 -0
  111. package/dist/filesystem/memory-provider-v2.js.map +1 -0
  112. package/dist/filesystem/memory-provider.d.ts +54 -0
  113. package/dist/filesystem/memory-provider.d.ts.map +1 -0
  114. package/dist/filesystem/memory-provider.js +132 -0
  115. package/dist/filesystem/memory-provider.js.map +1 -0
  116. package/dist/filesystem/memory.d.ts +4 -0
  117. package/dist/filesystem/memory.d.ts.map +1 -0
  118. package/dist/filesystem/memory.js +4 -0
  119. package/dist/filesystem/memory.js.map +1 -0
  120. package/dist/filesystem/move-entry.d.ts +9 -0
  121. package/dist/filesystem/move-entry.d.ts.map +1 -0
  122. package/dist/filesystem/move-entry.js +103 -0
  123. package/dist/filesystem/move-entry.js.map +1 -0
  124. package/dist/filesystem/move-error.d.ts +53 -0
  125. package/dist/filesystem/move-error.d.ts.map +1 -0
  126. package/dist/filesystem/move-error.js +99 -0
  127. package/dist/filesystem/move-error.js.map +1 -0
  128. package/dist/filesystem/native-provider-v2.d.ts +75 -0
  129. package/dist/filesystem/native-provider-v2.d.ts.map +1 -0
  130. package/dist/filesystem/native-provider-v2.js +849 -0
  131. package/dist/filesystem/native-provider-v2.js.map +1 -0
  132. package/dist/filesystem/native-provider.d.ts +9 -1
  133. package/dist/filesystem/native-provider.d.ts.map +1 -1
  134. package/dist/filesystem/native-provider.js +172 -37
  135. package/dist/filesystem/native-provider.js.map +1 -1
  136. package/dist/filesystem/native.d.ts +4 -0
  137. package/dist/filesystem/native.d.ts.map +1 -0
  138. package/dist/filesystem/native.js +4 -0
  139. package/dist/filesystem/native.js.map +1 -0
  140. package/dist/filesystem/types.d.ts +37 -4
  141. package/dist/filesystem/types.d.ts.map +1 -1
  142. package/dist/filesystem/types.js +11 -3
  143. package/dist/filesystem/types.js.map +1 -1
  144. package/dist/filesystem/v2.d.ts +172 -0
  145. package/dist/filesystem/v2.d.ts.map +1 -0
  146. package/dist/filesystem/v2.js +16 -0
  147. package/dist/filesystem/v2.js.map +1 -0
  148. package/dist/filesystem/workspace-path.d.ts +21 -0
  149. package/dist/filesystem/workspace-path.d.ts.map +1 -0
  150. package/dist/filesystem/workspace-path.js +80 -0
  151. package/dist/filesystem/workspace-path.js.map +1 -0
  152. package/dist/host/filesystem-v2.d.ts +45 -0
  153. package/dist/host/filesystem-v2.d.ts.map +1 -0
  154. package/dist/host/filesystem-v2.js +13 -0
  155. package/dist/host/filesystem-v2.js.map +1 -0
  156. package/dist/host/git.d.ts +200 -0
  157. package/dist/host/git.d.ts.map +1 -0
  158. package/dist/host/git.js +15 -0
  159. package/dist/host/git.js.map +1 -0
  160. package/dist/host/index.d.ts +4 -1
  161. package/dist/host/index.d.ts.map +1 -1
  162. package/dist/host/index.js +2 -0
  163. package/dist/host/index.js.map +1 -1
  164. package/dist/host/types.d.ts +114 -31
  165. package/dist/host/types.d.ts.map +1 -1
  166. package/dist/host/wire-policy.d.ts +22 -0
  167. package/dist/host/wire-policy.d.ts.map +1 -0
  168. package/dist/host/wire-policy.js +92 -0
  169. package/dist/host/wire-policy.js.map +1 -0
  170. package/dist/index.d.ts +2 -1
  171. package/dist/index.d.ts.map +1 -1
  172. package/dist/index.js +2 -1
  173. package/dist/index.js.map +1 -1
  174. package/dist/mcp/index.d.ts +4 -0
  175. package/dist/mcp/index.d.ts.map +1 -0
  176. package/dist/mcp/index.js +4 -0
  177. package/dist/mcp/index.js.map +1 -0
  178. package/dist/mcp/types.d.ts +466 -0
  179. package/dist/mcp/types.d.ts.map +1 -0
  180. package/dist/mcp/types.js +25 -0
  181. package/dist/mcp/types.js.map +1 -0
  182. package/dist/mcp/wire.d.ts +29 -0
  183. package/dist/mcp/wire.d.ts.map +1 -0
  184. package/dist/mcp/wire.js +1046 -0
  185. package/dist/mcp/wire.js.map +1 -0
  186. package/dist/mcp/zod.d.ts +5763 -0
  187. package/dist/mcp/zod.d.ts.map +1 -0
  188. package/dist/mcp/zod.js +908 -0
  189. package/dist/mcp/zod.js.map +1 -0
  190. package/dist/types-CX893hgH.d.ts +468 -0
  191. package/dist/types-CsX6EN2t.d.ts +301 -0
  192. package/dist/types-eOlt9J7n.d.ts +478 -0
  193. package/dist/vscode/index.d.ts +3 -0
  194. package/dist/vscode/index.d.ts.map +1 -0
  195. package/dist/vscode/index.js +3 -0
  196. package/dist/vscode/index.js.map +1 -0
  197. package/dist/vscode/messages.d.ts +204 -0
  198. package/dist/vscode/messages.d.ts.map +1 -0
  199. package/dist/vscode/messages.js +494 -0
  200. package/dist/vscode/messages.js.map +1 -0
  201. package/dist/workspace/index.d.ts +3 -2
  202. package/dist/workspace/index.d.ts.map +1 -1
  203. package/dist/workspace/index.js +2 -1
  204. package/dist/workspace/index.js.map +1 -1
  205. package/dist/workspace/reconcile-electron.d.ts +19 -0
  206. package/dist/workspace/reconcile-electron.d.ts.map +1 -0
  207. package/dist/workspace/reconcile-electron.js +42 -0
  208. package/dist/workspace/reconcile-electron.js.map +1 -0
  209. package/dist/workspace/types.d.ts +41 -1
  210. package/dist/workspace/types.d.ts.map +1 -1
  211. package/dist/workspace/types.js +0 -4
  212. package/dist/workspace/types.js.map +1 -1
  213. package/dist/workspace/workspace-manager.d.ts +17 -5
  214. package/dist/workspace/workspace-manager.d.ts.map +1 -1
  215. package/dist/workspace/workspace-manager.js +55 -11
  216. package/dist/workspace/workspace-manager.js.map +1 -1
  217. package/dist/workspace-path-CWVrcuPL.d.ts +21 -0
  218. package/package.json +43 -2
  219. package/src/document/document-session.ts +834 -0
  220. package/src/document/filesystem-target.ts +109 -0
  221. package/src/document/index.ts +41 -0
  222. package/src/document/recovery-journal.ts +536 -0
  223. package/src/document/types.ts +116 -0
  224. package/src/filesystem/commit-lock.ts +29 -0
  225. package/src/filesystem/dbk-workspace.ts +135 -0
  226. package/src/filesystem/electron-provider-v2.ts +630 -0
  227. package/src/filesystem/electron-provider.ts +25 -14
  228. package/src/filesystem/electron.ts +3 -0
  229. package/src/filesystem/filesystem-content-container.ts +53 -15
  230. package/src/filesystem/fs-error.ts +234 -0
  231. package/src/filesystem/index.ts +119 -0
  232. package/src/filesystem/indexeddb-content-container.ts +20 -12
  233. package/src/filesystem/indexeddb-provider-v2.ts +1740 -0
  234. package/src/filesystem/indexeddb-provider.ts +126 -300
  235. package/src/filesystem/indexeddb-store.ts +207 -0
  236. package/src/filesystem/indexeddb.ts +12 -0
  237. package/src/filesystem/legacy-v2-adapter.ts +779 -0
  238. package/src/filesystem/memory-provider-v2.ts +896 -0
  239. package/src/filesystem/memory-provider.ts +180 -0
  240. package/src/filesystem/memory.ts +15 -0
  241. package/src/filesystem/move-entry.ts +142 -0
  242. package/src/filesystem/move-error.ts +159 -0
  243. package/src/filesystem/native-provider-v2.ts +1165 -0
  244. package/src/filesystem/native-provider.ts +194 -41
  245. package/src/filesystem/native.ts +16 -0
  246. package/src/filesystem/types.ts +49 -4
  247. package/src/filesystem/v2.ts +231 -0
  248. package/src/filesystem/workspace-path.ts +92 -0
  249. package/src/host/filesystem-v2.ts +104 -0
  250. package/src/host/git.ts +246 -0
  251. package/src/host/index.ts +46 -0
  252. package/src/host/types.ts +155 -34
  253. package/src/host/wire-policy.ts +103 -0
  254. package/src/index.ts +2 -1
  255. package/src/mcp/index.ts +3 -0
  256. package/src/mcp/types.ts +594 -0
  257. package/src/mcp/wire.ts +1280 -0
  258. package/src/mcp/zod.ts +1000 -0
  259. package/src/vscode/index.ts +2 -0
  260. package/src/vscode/messages.ts +704 -0
  261. package/src/workspace/index.ts +8 -1
  262. package/src/workspace/reconcile-electron.ts +65 -0
  263. package/src/workspace/types.ts +39 -1
  264. package/src/workspace/workspace-manager.ts +71 -10
  265. package/dist/chunk-GUNM43XZ.js +0 -63
  266. package/dist/chunk-GUNM43XZ.js.map +0 -1
  267. package/dist/chunk-IM7LCQJ6.js +0 -850
  268. package/dist/chunk-IM7LCQJ6.js.map +0 -1
  269. package/dist/chunk-ME76RUMR.js.map +0 -1
  270. package/dist/index-pgBHBQ9G.d.ts +0 -213
@@ -1,4 +1,4 @@
1
- export type { WorkspaceDescriptor } from './types.js';
1
+ export type { WorkspaceDescriptor, TransientOrigin } from './types.js';
2
2
 
3
3
  export {
4
4
  listWorkspaces,
@@ -7,4 +7,11 @@ export {
7
7
  removeWorkspace,
8
8
  touchWorkspace,
9
9
  ensureDefaultWorkspace,
10
+ registerTransientWorkspace,
11
+ getTransientWorkspace,
12
+ unregisterTransientWorkspace,
10
13
  } from './workspace-manager.js';
14
+ export {
15
+ reconcileElectronWorkspaceDescriptors,
16
+ type ElectronWorkspaceReconciliation,
17
+ } from './reconcile-electron.js';
@@ -0,0 +1,65 @@
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,3 +1,36 @@
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
+
1
34
  /**
2
35
  * Workspace — a named binding to a FileSystemProvider, representing
3
36
  * the user's current working context (a folder of markdown files).
@@ -13,12 +46,17 @@ export interface WorkspaceDescriptor {
13
46
  * - 'indexeddb' — browser-local storage (web only)
14
47
  * - 'native' — File System Access API (web Chrome/Edge only)
15
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`.
16
52
  */
17
- type: 'indexeddb' | 'native' | 'electron-native';
53
+ type: 'indexeddb' | 'native' | 'electron-native' | 'transient';
18
54
  /** ISO timestamp of last access. */
19
55
  lastOpened: string;
20
56
  /** Absolute filesystem path for 'electron-native' workspaces. */
21
57
  rootPath?: string;
58
+ /** For 'transient' workspaces: where the contents came from / save back to. */
59
+ origin?: TransientOrigin;
22
60
  /**
23
61
  * Per-workspace override for the global versioning preference. When
24
62
  * `'inherit'` (or absent), the global preference applies. `'on'` /
@@ -7,6 +7,7 @@
7
7
  */
8
8
 
9
9
  import { LocalForageAdapter } from '@bendyline/squisq/storage';
10
+ import { getFileSystemProviderV2, type FileSystemProvider } from '../filesystem/types.js';
10
11
  import type { WorkspaceDescriptor } from './types.js';
11
12
 
12
13
  const DB_NAME = 'docblocks-workspaces';
@@ -20,27 +21,77 @@ const store = new LocalForageAdapter({
20
21
  });
21
22
 
22
23
  /**
23
- * Get the list of all known workspace descriptors.
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.
24
28
  */
25
- export async function listWorkspaces(): Promise<WorkspaceDescriptor[]> {
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[]> {
26
64
  const list = await store.get<WorkspaceDescriptor[]>(LIST_KEY);
27
65
  return list ?? [];
28
66
  }
29
67
 
30
68
  /**
31
- * Get a specific workspace descriptor by id.
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).
32
80
  */
33
81
  export async function getWorkspace(id: string): Promise<WorkspaceDescriptor | null> {
34
- const list = await listWorkspaces();
82
+ const transient = transientWorkspaces.get(id);
83
+ if (transient) return transient.descriptor;
84
+ const list = await listPersisted();
35
85
  return list.find((w) => w.id === id) ?? null;
36
86
  }
37
87
 
38
88
  /**
39
89
  * Add or update a workspace descriptor. If a workspace with the same id
40
- * already exists, it is replaced.
90
+ * already exists, it is replaced. Transient workspaces are never persisted.
41
91
  */
42
92
  export async function saveWorkspace(workspace: WorkspaceDescriptor): Promise<void> {
43
- const list = await listWorkspaces();
93
+ if (workspace.type === 'transient') return;
94
+ const list = await listPersisted();
44
95
  const idx = list.findIndex((w) => w.id === workspace.id);
45
96
  if (idx >= 0) {
46
97
  list[idx] = workspace;
@@ -51,19 +102,29 @@ export async function saveWorkspace(workspace: WorkspaceDescriptor): Promise<voi
51
102
  }
52
103
 
53
104
  /**
54
- * Remove a workspace descriptor by id.
105
+ * Remove a workspace descriptor by id (transient or persisted).
55
106
  */
56
107
  export async function removeWorkspace(id: string): Promise<void> {
57
- const list = await listWorkspaces();
108
+ if (transientWorkspaces.has(id)) {
109
+ await unregisterTransientWorkspace(id);
110
+ return;
111
+ }
112
+ const list = await listPersisted();
58
113
  const filtered = list.filter((w) => w.id !== id);
59
114
  await store.set(LIST_KEY, filtered);
60
115
  }
61
116
 
62
117
  /**
63
- * Touch the lastOpened timestamp on a workspace.
118
+ * Touch the lastOpened timestamp on a workspace. For transient workspaces this
119
+ * updates the in-memory descriptor only (nothing is persisted).
64
120
  */
65
121
  export async function touchWorkspace(id: string): Promise<void> {
66
- const list = await listWorkspaces();
122
+ const transient = transientWorkspaces.get(id);
123
+ if (transient) {
124
+ transient.descriptor.lastOpened = new Date().toISOString();
125
+ return;
126
+ }
127
+ const list = await listPersisted();
67
128
  const workspace = list.find((w) => w.id === id);
68
129
  if (workspace) {
69
130
  workspace.lastOpened = new Date().toISOString();
@@ -1,63 +0,0 @@
1
- // src/workspace/workspace-manager.ts
2
- import { LocalForageAdapter } from "@bendyline/squisq/storage";
3
- var DB_NAME = "docblocks-workspaces";
4
- var STORE_NAME = "workspaces";
5
- var LIST_KEY = "workspace-list";
6
- var DEFAULT_WORKSPACE_ID = "default";
7
- var store = new LocalForageAdapter({
8
- name: DB_NAME,
9
- storeName: STORE_NAME
10
- });
11
- async function listWorkspaces() {
12
- const list = await store.get(LIST_KEY);
13
- return list ?? [];
14
- }
15
- async function getWorkspace(id) {
16
- const list = await listWorkspaces();
17
- return list.find((w) => w.id === id) ?? null;
18
- }
19
- async function saveWorkspace(workspace) {
20
- const list = await listWorkspaces();
21
- const idx = list.findIndex((w) => w.id === workspace.id);
22
- if (idx >= 0) {
23
- list[idx] = workspace;
24
- } else {
25
- list.push(workspace);
26
- }
27
- await store.set(LIST_KEY, list);
28
- }
29
- async function removeWorkspace(id) {
30
- const list = await listWorkspaces();
31
- const filtered = list.filter((w) => w.id !== id);
32
- await store.set(LIST_KEY, filtered);
33
- }
34
- async function touchWorkspace(id) {
35
- const list = await listWorkspaces();
36
- const workspace = list.find((w) => w.id === id);
37
- if (workspace) {
38
- workspace.lastOpened = (/* @__PURE__ */ new Date()).toISOString();
39
- await store.set(LIST_KEY, list);
40
- }
41
- }
42
- async function ensureDefaultWorkspace() {
43
- const existing = await getWorkspace(DEFAULT_WORKSPACE_ID);
44
- if (existing) return existing;
45
- const descriptor = {
46
- id: DEFAULT_WORKSPACE_ID,
47
- name: "My Documents",
48
- type: "indexeddb",
49
- lastOpened: (/* @__PURE__ */ new Date()).toISOString()
50
- };
51
- await saveWorkspace(descriptor);
52
- return descriptor;
53
- }
54
-
55
- export {
56
- listWorkspaces,
57
- getWorkspace,
58
- saveWorkspace,
59
- removeWorkspace,
60
- touchWorkspace,
61
- ensureDefaultWorkspace
62
- };
63
- //# sourceMappingURL=chunk-GUNM43XZ.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/workspace/workspace-manager.ts"],"sourcesContent":["/**\n * WorkspaceManager — manages the list of known workspaces in IndexedDB\n * and provides helpers for creating / switching / removing them.\n *\n * The actual FileSystemProvider instances are created by the caller\n * (since native providers need a DirectoryHandle from user interaction).\n */\n\nimport { LocalForageAdapter } from '@bendyline/squisq/storage';\nimport type { WorkspaceDescriptor } from './types.js';\n\nconst DB_NAME = 'docblocks-workspaces';\nconst STORE_NAME = 'workspaces';\nconst LIST_KEY = 'workspace-list';\nconst DEFAULT_WORKSPACE_ID = 'default';\n\nconst store = new LocalForageAdapter({\n name: DB_NAME,\n storeName: STORE_NAME,\n});\n\n/**\n * Get the list of all known workspace descriptors.\n */\nexport async function listWorkspaces(): Promise<WorkspaceDescriptor[]> {\n const list = await store.get<WorkspaceDescriptor[]>(LIST_KEY);\n return list ?? [];\n}\n\n/**\n * Get a specific workspace descriptor by id.\n */\nexport async function getWorkspace(id: string): Promise<WorkspaceDescriptor | null> {\n const list = await listWorkspaces();\n return list.find((w) => w.id === id) ?? null;\n}\n\n/**\n * Add or update a workspace descriptor. If a workspace with the same id\n * already exists, it is replaced.\n */\nexport async function saveWorkspace(workspace: WorkspaceDescriptor): Promise<void> {\n const list = await listWorkspaces();\n const idx = list.findIndex((w) => w.id === workspace.id);\n if (idx >= 0) {\n list[idx] = workspace;\n } else {\n list.push(workspace);\n }\n await store.set(LIST_KEY, list);\n}\n\n/**\n * Remove a workspace descriptor by id.\n */\nexport async function removeWorkspace(id: string): Promise<void> {\n const list = await listWorkspaces();\n const filtered = list.filter((w) => w.id !== id);\n await store.set(LIST_KEY, filtered);\n}\n\n/**\n * Touch the lastOpened timestamp on a workspace.\n */\nexport async function touchWorkspace(id: string): Promise<void> {\n const list = await listWorkspaces();\n const workspace = list.find((w) => w.id === id);\n if (workspace) {\n workspace.lastOpened = new Date().toISOString();\n await store.set(LIST_KEY, list);\n }\n}\n\n/**\n * Ensure a default IndexedDB workspace exists. Called on app startup.\n * Returns the descriptor.\n */\nexport async function ensureDefaultWorkspace(): Promise<WorkspaceDescriptor> {\n const existing = await getWorkspace(DEFAULT_WORKSPACE_ID);\n if (existing) return existing;\n\n const descriptor: WorkspaceDescriptor = {\n id: DEFAULT_WORKSPACE_ID,\n name: 'My Documents',\n type: 'indexeddb',\n lastOpened: new Date().toISOString(),\n };\n await saveWorkspace(descriptor);\n return descriptor;\n}\n"],"mappings":";AAQA,SAAS,0BAA0B;AAGnC,IAAM,UAAU;AAChB,IAAM,aAAa;AACnB,IAAM,WAAW;AACjB,IAAM,uBAAuB;AAE7B,IAAM,QAAQ,IAAI,mBAAmB;AAAA,EACnC,MAAM;AAAA,EACN,WAAW;AACb,CAAC;AAKD,eAAsB,iBAAiD;AACrE,QAAM,OAAO,MAAM,MAAM,IAA2B,QAAQ;AAC5D,SAAO,QAAQ,CAAC;AAClB;AAKA,eAAsB,aAAa,IAAiD;AAClF,QAAM,OAAO,MAAM,eAAe;AAClC,SAAO,KAAK,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE,KAAK;AAC1C;AAMA,eAAsB,cAAc,WAA+C;AACjF,QAAM,OAAO,MAAM,eAAe;AAClC,QAAM,MAAM,KAAK,UAAU,CAAC,MAAM,EAAE,OAAO,UAAU,EAAE;AACvD,MAAI,OAAO,GAAG;AACZ,SAAK,GAAG,IAAI;AAAA,EACd,OAAO;AACL,SAAK,KAAK,SAAS;AAAA,EACrB;AACA,QAAM,MAAM,IAAI,UAAU,IAAI;AAChC;AAKA,eAAsB,gBAAgB,IAA2B;AAC/D,QAAM,OAAO,MAAM,eAAe;AAClC,QAAM,WAAW,KAAK,OAAO,CAAC,MAAM,EAAE,OAAO,EAAE;AAC/C,QAAM,MAAM,IAAI,UAAU,QAAQ;AACpC;AAKA,eAAsB,eAAe,IAA2B;AAC9D,QAAM,OAAO,MAAM,eAAe;AAClC,QAAM,YAAY,KAAK,KAAK,CAAC,MAAM,EAAE,OAAO,EAAE;AAC9C,MAAI,WAAW;AACb,cAAU,cAAa,oBAAI,KAAK,GAAE,YAAY;AAC9C,UAAM,MAAM,IAAI,UAAU,IAAI;AAAA,EAChC;AACF;AAMA,eAAsB,yBAAuD;AAC3E,QAAM,WAAW,MAAM,aAAa,oBAAoB;AACxD,MAAI,SAAU,QAAO;AAErB,QAAM,aAAkC;AAAA,IACtC,IAAI;AAAA,IACJ,MAAM;AAAA,IACN,MAAM;AAAA,IACN,aAAY,oBAAI,KAAK,GAAE,YAAY;AAAA,EACrC;AACA,QAAM,cAAc,UAAU;AAC9B,SAAO;AACT;","names":[]}