@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,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
- }