@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.
- package/dist/{chunk-J32GU3F3.js → chunk-6IYMTYMQ.js} +249 -221
- package/dist/chunk-6IYMTYMQ.js.map +1 -0
- package/dist/{chunk-75UUF6C4.js → chunk-B56KWCSE.js} +2 -2
- package/dist/{chunk-RVQHY3XU.js → chunk-BNKV7MTO.js} +1 -1
- package/dist/{chunk-RVQHY3XU.js.map → chunk-BNKV7MTO.js.map} +1 -1
- package/dist/chunk-BXMF5YQJ.js +149 -0
- package/dist/chunk-BXMF5YQJ.js.map +1 -0
- package/dist/{chunk-PGR7LK6D.js → chunk-COYQXQK3.js} +14 -5
- package/dist/chunk-COYQXQK3.js.map +1 -0
- package/dist/{chunk-RQJRQF46.js → chunk-DN7A33LL.js} +42 -49
- package/dist/chunk-DN7A33LL.js.map +1 -0
- package/dist/chunk-FA7UNOXK.js +20 -0
- package/dist/chunk-FA7UNOXK.js.map +1 -0
- package/dist/chunk-GM5YXU4L.js +29 -0
- package/dist/chunk-GM5YXU4L.js.map +1 -0
- package/dist/{chunk-SI2LU2RP.js → chunk-JS6XFWQK.js} +2 -1
- package/dist/chunk-JS6XFWQK.js.map +1 -0
- package/dist/{chunk-EGNDADXB.js → chunk-MNSZ7EZN.js} +2 -2
- package/dist/chunk-P3DVZQ6S.js +228 -0
- package/dist/chunk-P3DVZQ6S.js.map +1 -0
- package/dist/chunk-P4WATND4.js +52 -0
- package/dist/chunk-P4WATND4.js.map +1 -0
- package/dist/chunk-RVPGQBWR.js +169 -0
- package/dist/chunk-RVPGQBWR.js.map +1 -0
- package/dist/chunk-U722UUFN.js +9 -0
- package/dist/chunk-U722UUFN.js.map +1 -0
- package/dist/{chunk-GCPBEMMH.js → chunk-VTCSF7VS.js} +11 -21
- package/dist/chunk-VTCSF7VS.js.map +1 -0
- package/dist/{chunk-2D7Y4IR3.js → chunk-WJKYY5QR.js} +123 -66
- package/dist/chunk-WJKYY5QR.js.map +1 -0
- package/dist/{chunk-5MYAICRE.js → chunk-XUML3MKV.js} +44 -56
- package/dist/chunk-XUML3MKV.js.map +1 -0
- package/dist/document/index.d.ts +358 -6
- package/dist/document/index.js +24 -3
- package/dist/document/index.js.map +1 -1
- package/dist/filesystem/electron.d.ts +73 -4
- package/dist/filesystem/electron.js +16 -3
- package/dist/filesystem/electron.js.map +1 -1
- package/dist/filesystem/index.d.ts +228 -22
- package/dist/filesystem/index.js +133 -19
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/indexeddb.d.ts +284 -5
- package/dist/filesystem/indexeddb.js +22 -4
- package/dist/filesystem/indexeddb.js.map +1 -1
- package/dist/filesystem/memory.d.ts +152 -4
- package/dist/filesystem/memory.js +12 -3
- package/dist/filesystem/memory.js.map +1 -1
- package/dist/filesystem/native.d.ts +136 -4
- package/dist/filesystem/native.js +27 -3
- package/dist/filesystem/native.js.map +1 -1
- package/dist/host/index.d.ts +32 -9
- package/dist/host/index.js +26 -29
- package/dist/host/index.js.map +1 -1
- package/dist/index.d.ts +14 -10
- package/dist/index.js +204 -9
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +33 -4
- package/dist/mcp/index.js +31 -3
- package/dist/mcp/index.js.map +1 -1
- package/dist/mcp/zod.d.ts +637 -635
- package/dist/mcp/zod.js +700 -884
- package/dist/mcp/zod.js.map +1 -1
- package/dist/share/index.d.ts +43 -0
- package/dist/share/index.js +13 -0
- package/dist/share/index.js.map +1 -0
- package/dist/{types-CsX6EN2t.d.ts → types-BEg5SQ1_.d.ts} +1 -1
- package/dist/{types-eOlt9J7n.d.ts → types-CueK0tvU.d.ts} +34 -11
- package/dist/vscode/index.d.ts +220 -3
- package/dist/vscode/index.js +382 -2
- package/dist/vscode/index.js.map +1 -1
- package/dist/workspace/index.d.ts +141 -4
- package/dist/workspace/index.js +28 -2
- package/dist/workspace/index.js.map +1 -1
- package/package.json +9 -5
- package/dist/chunk-2D7Y4IR3.js.map +0 -1
- package/dist/chunk-5MYAICRE.js.map +0 -1
- package/dist/chunk-AYZ4HN5M.js +0 -20
- package/dist/chunk-AYZ4HN5M.js.map +0 -1
- package/dist/chunk-GCPBEMMH.js.map +0 -1
- package/dist/chunk-J32GU3F3.js.map +0 -1
- package/dist/chunk-PGR7LK6D.js.map +0 -1
- package/dist/chunk-RQJRQF46.js.map +0 -1
- package/dist/chunk-SI2LU2RP.js.map +0 -1
- package/dist/chunk-W5UUUII5.js +0 -142
- package/dist/chunk-W5UUUII5.js.map +0 -1
- package/dist/document/document-session.d.ts +0 -127
- package/dist/document/document-session.d.ts.map +0 -1
- package/dist/document/document-session.js +0 -749
- package/dist/document/document-session.js.map +0 -1
- package/dist/document/filesystem-target.d.ts +0 -17
- package/dist/document/filesystem-target.d.ts.map +0 -1
- package/dist/document/filesystem-target.js +0 -70
- package/dist/document/filesystem-target.js.map +0 -1
- package/dist/document/index.d.ts.map +0 -1
- package/dist/document/recovery-journal.d.ts +0 -125
- package/dist/document/recovery-journal.d.ts.map +0 -1
- package/dist/document/recovery-journal.js +0 -385
- package/dist/document/recovery-journal.js.map +0 -1
- package/dist/document/types.d.ts +0 -89
- package/dist/document/types.d.ts.map +0 -1
- package/dist/document/types.js +0 -9
- package/dist/document/types.js.map +0 -1
- package/dist/filesystem/commit-lock.d.ts +0 -3
- package/dist/filesystem/commit-lock.d.ts.map +0 -1
- package/dist/filesystem/commit-lock.js +0 -20
- package/dist/filesystem/commit-lock.js.map +0 -1
- package/dist/filesystem/dbk-workspace.d.ts +0 -34
- package/dist/filesystem/dbk-workspace.d.ts.map +0 -1
- package/dist/filesystem/dbk-workspace.js +0 -85
- package/dist/filesystem/dbk-workspace.js.map +0 -1
- package/dist/filesystem/electron-provider-v2.d.ts +0 -36
- package/dist/filesystem/electron-provider-v2.d.ts.map +0 -1
- package/dist/filesystem/electron-provider-v2.js +0 -503
- package/dist/filesystem/electron-provider-v2.js.map +0 -1
- package/dist/filesystem/electron-provider.d.ts +0 -35
- package/dist/filesystem/electron-provider.d.ts.map +0 -1
- package/dist/filesystem/electron-provider.js +0 -69
- package/dist/filesystem/electron-provider.js.map +0 -1
- package/dist/filesystem/electron.d.ts.map +0 -1
- package/dist/filesystem/file-media-provider.d.ts +0 -23
- package/dist/filesystem/file-media-provider.d.ts.map +0 -1
- package/dist/filesystem/file-media-provider.js +0 -85
- package/dist/filesystem/file-media-provider.js.map +0 -1
- package/dist/filesystem/filesystem-content-container.d.ts +0 -24
- package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
- package/dist/filesystem/filesystem-content-container.js +0 -153
- package/dist/filesystem/filesystem-content-container.js.map +0 -1
- package/dist/filesystem/fs-error.d.ts +0 -46
- package/dist/filesystem/fs-error.d.ts.map +0 -1
- package/dist/filesystem/fs-error.js +0 -170
- package/dist/filesystem/fs-error.js.map +0 -1
- package/dist/filesystem/index.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-content-container.d.ts +0 -22
- package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-content-container.js +0 -100
- package/dist/filesystem/indexeddb-content-container.js.map +0 -1
- package/dist/filesystem/indexeddb-provider-v2.d.ts +0 -96
- package/dist/filesystem/indexeddb-provider-v2.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-provider-v2.js +0 -1241
- package/dist/filesystem/indexeddb-provider-v2.js.map +0 -1
- package/dist/filesystem/indexeddb-provider.d.ts +0 -39
- package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-provider.js +0 -145
- package/dist/filesystem/indexeddb-provider.js.map +0 -1
- package/dist/filesystem/indexeddb-store.d.ts +0 -34
- package/dist/filesystem/indexeddb-store.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-store.js +0 -165
- package/dist/filesystem/indexeddb-store.js.map +0 -1
- package/dist/filesystem/indexeddb.d.ts.map +0 -1
- package/dist/filesystem/legacy-v2-adapter.d.ts +0 -62
- package/dist/filesystem/legacy-v2-adapter.d.ts.map +0 -1
- package/dist/filesystem/legacy-v2-adapter.js +0 -499
- package/dist/filesystem/legacy-v2-adapter.js.map +0 -1
- package/dist/filesystem/memory-provider-v2.d.ts +0 -92
- package/dist/filesystem/memory-provider-v2.d.ts.map +0 -1
- package/dist/filesystem/memory-provider-v2.js +0 -615
- package/dist/filesystem/memory-provider-v2.js.map +0 -1
- package/dist/filesystem/memory-provider.d.ts +0 -54
- package/dist/filesystem/memory-provider.d.ts.map +0 -1
- package/dist/filesystem/memory-provider.js +0 -132
- package/dist/filesystem/memory-provider.js.map +0 -1
- package/dist/filesystem/memory.d.ts.map +0 -1
- package/dist/filesystem/move-entry.d.ts +0 -9
- package/dist/filesystem/move-entry.d.ts.map +0 -1
- package/dist/filesystem/move-entry.js +0 -103
- package/dist/filesystem/move-entry.js.map +0 -1
- package/dist/filesystem/move-error.d.ts +0 -53
- package/dist/filesystem/move-error.d.ts.map +0 -1
- package/dist/filesystem/move-error.js +0 -99
- package/dist/filesystem/move-error.js.map +0 -1
- package/dist/filesystem/native-provider-v2.d.ts +0 -75
- package/dist/filesystem/native-provider-v2.d.ts.map +0 -1
- package/dist/filesystem/native-provider-v2.js +0 -849
- package/dist/filesystem/native-provider-v2.js.map +0 -1
- package/dist/filesystem/native-provider.d.ts +0 -53
- package/dist/filesystem/native-provider.d.ts.map +0 -1
- package/dist/filesystem/native-provider.js +0 -471
- package/dist/filesystem/native-provider.js.map +0 -1
- package/dist/filesystem/native.d.ts.map +0 -1
- package/dist/filesystem/types.d.ts +0 -83
- package/dist/filesystem/types.d.ts.map +0 -1
- package/dist/filesystem/types.js +0 -16
- package/dist/filesystem/types.js.map +0 -1
- package/dist/filesystem/v2.d.ts +0 -172
- package/dist/filesystem/v2.d.ts.map +0 -1
- package/dist/filesystem/v2.js +0 -16
- package/dist/filesystem/v2.js.map +0 -1
- package/dist/filesystem/workspace-path.d.ts +0 -21
- package/dist/filesystem/workspace-path.d.ts.map +0 -1
- package/dist/filesystem/workspace-path.js +0 -80
- package/dist/filesystem/workspace-path.js.map +0 -1
- package/dist/host/filesystem-v2.d.ts +0 -45
- package/dist/host/filesystem-v2.d.ts.map +0 -1
- package/dist/host/filesystem-v2.js +0 -13
- package/dist/host/filesystem-v2.js.map +0 -1
- package/dist/host/git.d.ts +0 -200
- package/dist/host/git.d.ts.map +0 -1
- package/dist/host/git.js +0 -15
- package/dist/host/git.js.map +0 -1
- package/dist/host/index.d.ts.map +0 -1
- package/dist/host/types.d.ts +0 -232
- package/dist/host/types.d.ts.map +0 -1
- package/dist/host/types.js +0 -10
- package/dist/host/types.js.map +0 -1
- package/dist/host/wire-policy.d.ts +0 -22
- package/dist/host/wire-policy.d.ts.map +0 -1
- package/dist/host/wire-policy.js +0 -92
- package/dist/host/wire-policy.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/types.d.ts +0 -466
- package/dist/mcp/types.d.ts.map +0 -1
- package/dist/mcp/types.js +0 -25
- package/dist/mcp/types.js.map +0 -1
- package/dist/mcp/wire.d.ts +0 -29
- package/dist/mcp/wire.d.ts.map +0 -1
- package/dist/mcp/wire.js +0 -1046
- package/dist/mcp/wire.js.map +0 -1
- package/dist/mcp/zod.d.ts.map +0 -1
- package/dist/vscode/index.d.ts.map +0 -1
- package/dist/vscode/messages.d.ts +0 -204
- package/dist/vscode/messages.d.ts.map +0 -1
- package/dist/vscode/messages.js +0 -494
- package/dist/vscode/messages.js.map +0 -1
- package/dist/workspace/index.d.ts.map +0 -1
- package/dist/workspace/reconcile-electron.d.ts +0 -19
- package/dist/workspace/reconcile-electron.d.ts.map +0 -1
- package/dist/workspace/reconcile-electron.js +0 -42
- package/dist/workspace/reconcile-electron.js.map +0 -1
- package/dist/workspace/types.d.ts +0 -69
- package/dist/workspace/types.d.ts.map +0 -1
- package/dist/workspace/types.js +0 -2
- package/dist/workspace/types.js.map +0 -1
- package/dist/workspace/workspace-manager.d.ts +0 -47
- package/dist/workspace/workspace-manager.d.ts.map +0 -1
- package/dist/workspace/workspace-manager.js +0 -126
- package/dist/workspace/workspace-manager.js.map +0 -1
- package/src/document/document-session.ts +0 -834
- package/src/document/filesystem-target.ts +0 -109
- package/src/document/index.ts +0 -41
- package/src/document/recovery-journal.ts +0 -536
- package/src/document/types.ts +0 -116
- package/src/filesystem/commit-lock.ts +0 -29
- package/src/filesystem/dbk-workspace.ts +0 -135
- package/src/filesystem/electron-provider-v2.ts +0 -630
- package/src/filesystem/electron-provider.ts +0 -99
- package/src/filesystem/electron.ts +0 -3
- package/src/filesystem/file-media-provider.ts +0 -103
- package/src/filesystem/filesystem-content-container.ts +0 -164
- package/src/filesystem/fs-error.ts +0 -234
- package/src/filesystem/index.ts +0 -143
- package/src/filesystem/indexeddb-content-container.ts +0 -112
- package/src/filesystem/indexeddb-provider-v2.ts +0 -1740
- package/src/filesystem/indexeddb-provider.ts +0 -171
- package/src/filesystem/indexeddb-store.ts +0 -207
- package/src/filesystem/indexeddb.ts +0 -12
- package/src/filesystem/legacy-v2-adapter.ts +0 -779
- package/src/filesystem/memory-provider-v2.ts +0 -896
- package/src/filesystem/memory-provider.ts +0 -180
- package/src/filesystem/memory.ts +0 -15
- package/src/filesystem/move-entry.ts +0 -142
- package/src/filesystem/move-error.ts +0 -159
- package/src/filesystem/native-provider-v2.ts +0 -1165
- package/src/filesystem/native-provider.ts +0 -537
- package/src/filesystem/native.ts +0 -16
- package/src/filesystem/types.ts +0 -114
- package/src/filesystem/v2.ts +0 -231
- package/src/filesystem/workspace-path.ts +0 -92
- package/src/host/filesystem-v2.ts +0 -104
- package/src/host/git.ts +0 -246
- package/src/host/index.ts +0 -93
- package/src/host/types.ts +0 -274
- package/src/host/wire-policy.ts +0 -103
- package/src/index.ts +0 -10
- package/src/mcp/index.ts +0 -3
- package/src/mcp/types.ts +0 -594
- package/src/mcp/wire.ts +0 -1280
- package/src/mcp/zod.ts +0 -1000
- package/src/vscode/index.ts +0 -2
- package/src/vscode/messages.ts +0 -704
- package/src/workspace/index.ts +0 -17
- package/src/workspace/reconcile-electron.ts +0 -65
- package/src/workspace/types.ts +0 -67
- package/src/workspace/workspace-manager.ts +0 -151
- /package/dist/{chunk-75UUF6C4.js.map → chunk-B56KWCSE.js.map} +0 -0
- /package/dist/{chunk-EGNDADXB.js.map → chunk-MNSZ7EZN.js.map} +0 -0
package/src/workspace/index.ts
DELETED
|
@@ -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
|
-
}
|
package/src/workspace/types.ts
DELETED
|
@@ -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
|
-
}
|
|
File without changes
|
|
File without changes
|