@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
|
@@ -1,180 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* In-memory filesystem used by transient loose-file and DBK workspaces.
|
|
3
|
-
*
|
|
4
|
-
* MemoryFileSystemProviderV2 is authoritative. This class is the temporary
|
|
5
|
-
* text-oriented v1 facade retained while callers migrate to the byte contract.
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
import { FsError, type FsOperation } from './fs-error.js';
|
|
9
|
-
import {
|
|
10
|
-
MemoryFileSystemProviderV2,
|
|
11
|
-
type MemoryFileSystemV2ReplacementFile,
|
|
12
|
-
} from './memory-provider-v2.js';
|
|
13
|
-
import type { FileCommitResult, FileSystemEntry, FileSystemProvider, FileMeta } from './types.js';
|
|
14
|
-
import { parseWorkspacePath, type WorkspacePath } from './workspace-path.js';
|
|
15
|
-
|
|
16
|
-
export type MemoryFileSystemSnapshotFile =
|
|
17
|
-
| {
|
|
18
|
-
readonly kind: 'text';
|
|
19
|
-
readonly path: string;
|
|
20
|
-
readonly content: string;
|
|
21
|
-
}
|
|
22
|
-
| {
|
|
23
|
-
readonly kind: 'binary';
|
|
24
|
-
readonly path: string;
|
|
25
|
-
readonly data: ArrayBuffer | Uint8Array;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
/** Complete provider-relative state for a transient memory workspace. */
|
|
29
|
-
export interface MemoryFileSystemSnapshot {
|
|
30
|
-
readonly files: readonly MemoryFileSystemSnapshotFile[];
|
|
31
|
-
readonly directories?: readonly string[];
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
function canonicalPath(path: string): WorkspacePath {
|
|
35
|
-
return parseWorkspacePath(path);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function entryPath(path: string, operation: FsOperation): WorkspacePath {
|
|
39
|
-
const canonical = canonicalPath(path);
|
|
40
|
-
if (!canonical) {
|
|
41
|
-
throw new FsError('invalid-path', 'The workspace root is not a file entry.', {
|
|
42
|
-
operation,
|
|
43
|
-
path,
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
return canonical;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
function decode(data: ArrayBuffer): string {
|
|
50
|
-
return new TextDecoder().decode(data);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
/**
|
|
54
|
-
* Legacy facade over the correctness-first memory provider.
|
|
55
|
-
*
|
|
56
|
-
* Synchronous seed/snapshot replacement methods remain because DBK import
|
|
57
|
-
* fully stages external bytes before publishing one atomic in-memory swap.
|
|
58
|
-
*/
|
|
59
|
-
export class MemoryFileSystemProvider implements FileSystemProvider {
|
|
60
|
-
public readonly id: string;
|
|
61
|
-
public readonly label: string;
|
|
62
|
-
public readonly v2: MemoryFileSystemProviderV2;
|
|
63
|
-
|
|
64
|
-
public constructor(id: string, label: string) {
|
|
65
|
-
this.id = id;
|
|
66
|
-
this.label = label;
|
|
67
|
-
this.v2 = new MemoryFileSystemProviderV2(id, label);
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/** Monotonic version of the complete in-memory tree. */
|
|
71
|
-
public get treeVersion(): number {
|
|
72
|
-
return this.v2.mutationRevision;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/** Capture an owned deterministic copy of the complete transient tree. */
|
|
76
|
-
public captureContents(): MemoryFileSystemSnapshot {
|
|
77
|
-
const state = this.v2.captureState();
|
|
78
|
-
return {
|
|
79
|
-
files: state.files.map((file) =>
|
|
80
|
-
file.payloadKind === 'text'
|
|
81
|
-
? { kind: 'text' as const, path: file.path, content: decode(file.data) }
|
|
82
|
-
: { kind: 'binary' as const, path: file.path, data: file.data.slice(0) },
|
|
83
|
-
),
|
|
84
|
-
directories: [...state.directories],
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/** Atomically replace the complete tree after validating and owning all input. */
|
|
89
|
-
public replaceContents(snapshot: MemoryFileSystemSnapshot, expectedTreeVersion?: number): void {
|
|
90
|
-
const files: MemoryFileSystemV2ReplacementFile[] = snapshot.files.map((file) => ({
|
|
91
|
-
path: entryPath(file.path, 'write'),
|
|
92
|
-
payloadKind: file.kind,
|
|
93
|
-
data: file.kind === 'text' ? new TextEncoder().encode(file.content) : file.data,
|
|
94
|
-
}));
|
|
95
|
-
const directories = (snapshot.directories ?? []).map((path) =>
|
|
96
|
-
entryPath(path, 'create-directory'),
|
|
97
|
-
);
|
|
98
|
-
this.v2.replaceState({ files, directories }, expectedTreeVersion);
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
/** Seed synchronously before publishing a transient provider to consumers. */
|
|
102
|
-
public seedText(path: string, content: string): void {
|
|
103
|
-
this.v2.seedText(entryPath(path, 'write'), content);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
public async readFile(path: string): Promise<string | null> {
|
|
107
|
-
const file = await this.v2.readFile(entryPath(path, 'read'));
|
|
108
|
-
return file ? decode(file.data) : null;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
public async writeFile(path: string, content: string): Promise<void> {
|
|
112
|
-
await this.v2.writeText(entryPath(path, 'write'), content, { createParents: true });
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
public commitFile(
|
|
116
|
-
path: string,
|
|
117
|
-
content: string,
|
|
118
|
-
expectedContent: string | null,
|
|
119
|
-
): Promise<FileCommitResult> {
|
|
120
|
-
return this.v2.commitText(entryPath(path, 'write'), content, expectedContent);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
public async delete(path: string): Promise<void> {
|
|
124
|
-
await this.v2.remove(entryPath(path, 'remove'), { recursive: true, missing: 'ignore' });
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
public async rename(oldPath: string, newPath: string): Promise<void> {
|
|
128
|
-
await this.v2.move(entryPath(oldPath, 'move'), entryPath(newPath, 'move'), {
|
|
129
|
-
createParents: true,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
public async readDirectory(path: string): Promise<FileSystemEntry[]> {
|
|
134
|
-
const canonical = canonicalPath(path);
|
|
135
|
-
try {
|
|
136
|
-
const entries = await this.v2.readDirectory(canonical);
|
|
137
|
-
return entries.map((entry) => ({
|
|
138
|
-
kind: entry.kind,
|
|
139
|
-
name: entry.name,
|
|
140
|
-
path: entry.path,
|
|
141
|
-
}));
|
|
142
|
-
} catch (error: unknown) {
|
|
143
|
-
// Preserve the v1 missing-directory behavior only on the compatibility facade.
|
|
144
|
-
if (error instanceof FsError && error.code === 'not-found') return [];
|
|
145
|
-
throw error;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
public async exists(path: string): Promise<boolean> {
|
|
150
|
-
return (await this.v2.stat(canonicalPath(path))) !== null;
|
|
151
|
-
}
|
|
152
|
-
|
|
153
|
-
public async createDirectory(path: string): Promise<void> {
|
|
154
|
-
await this.v2.createDirectory(canonicalPath(path), { createParents: true });
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
public async stat(path: string): Promise<FileMeta | null> {
|
|
158
|
-
const canonical = canonicalPath(path);
|
|
159
|
-
if (!canonical) return null;
|
|
160
|
-
const entry = await this.v2.stat(canonical);
|
|
161
|
-
if (!entry || entry.kind !== 'file') return null;
|
|
162
|
-
return {
|
|
163
|
-
name: entry.name,
|
|
164
|
-
path: entry.path,
|
|
165
|
-
size: entry.size,
|
|
166
|
-
lastModified: entry.lastModified,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
public async readBinary(path: string): Promise<ArrayBuffer | null> {
|
|
171
|
-
const canonical = entryPath(path, 'read');
|
|
172
|
-
const file = this.v2.readCompatibilityFile(canonical);
|
|
173
|
-
if (!file || file.payloadKind !== 'binary') return null;
|
|
174
|
-
return file.data;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
public async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {
|
|
178
|
-
await this.v2.writeBinary(entryPath(path, 'write'), data, { createParents: true });
|
|
179
|
-
}
|
|
180
|
-
}
|
package/src/filesystem/memory.ts
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
/** Transient in-memory filesystem provider entry point. */
|
|
2
|
-
export {
|
|
3
|
-
MemoryFileSystemProvider,
|
|
4
|
-
type MemoryFileSystemSnapshot,
|
|
5
|
-
type MemoryFileSystemSnapshotFile,
|
|
6
|
-
} from './memory-provider.js';
|
|
7
|
-
export {
|
|
8
|
-
MemoryFileSystemProviderV2,
|
|
9
|
-
type MemoryFilePayloadKind,
|
|
10
|
-
type MemoryFileSystemV2CompatibilityFile,
|
|
11
|
-
type MemoryFileSystemV2Replacement,
|
|
12
|
-
type MemoryFileSystemV2ReplacementFile,
|
|
13
|
-
type MemoryFileSystemV2State,
|
|
14
|
-
type MemoryFileSystemV2StateFile,
|
|
15
|
-
} from './memory-provider-v2.js';
|
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';
|
|
2
|
-
import {
|
|
3
|
-
describeEntryMove,
|
|
4
|
-
describePartialMove,
|
|
5
|
-
FileSystemMoveRecoveryError,
|
|
6
|
-
FileSystemPartialMoveError,
|
|
7
|
-
} from './move-error.js';
|
|
8
|
-
import { parseWorkspacePath } from './workspace-path.js';
|
|
9
|
-
|
|
10
|
-
function normalisePath(path: string): string {
|
|
11
|
-
return parseWorkspacePath(path);
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
function dirname(path: string): string {
|
|
15
|
-
const slash = path.lastIndexOf('/');
|
|
16
|
-
return slash < 0 ? '' : path.slice(0, slash);
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
function basename(path: string): string {
|
|
20
|
-
const slash = path.lastIndexOf('/');
|
|
21
|
-
return slash < 0 ? path : path.slice(slash + 1);
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/** Return the hidden companion directory used for a document's media and versions. */
|
|
25
|
-
export function documentCompanionPath(documentPath: string): string {
|
|
26
|
-
const rooted = documentPath.replace(/\\/g, '/').startsWith('/');
|
|
27
|
-
const clean = parseWorkspacePath(documentPath);
|
|
28
|
-
if (!clean) throw new Error('The workspace root has no document companion path.');
|
|
29
|
-
const parent = dirname(clean);
|
|
30
|
-
const name = basename(clean).replace(/\.[^.]+$/, '');
|
|
31
|
-
if (parent) return `${parent}/${name}_files`;
|
|
32
|
-
return rooted ? `/${name}_files` : `${name}_files`;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
function isMarkdownPath(path: string): boolean {
|
|
36
|
-
return /\.md$/i.test(basename(path));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Move an explorer entry without overwriting an existing entry. Markdown files
|
|
41
|
-
* carry their hidden `<basename>_files` companion directory with them.
|
|
42
|
-
*/
|
|
43
|
-
export async function moveFileSystemEntry(
|
|
44
|
-
provider: FileSystemProvider,
|
|
45
|
-
oldPath: string,
|
|
46
|
-
newPath: string,
|
|
47
|
-
kind: 'file' | 'directory',
|
|
48
|
-
): Promise<void> {
|
|
49
|
-
const providerV2 = getFileSystemProviderV2(provider);
|
|
50
|
-
const exists = (candidate: string): Promise<boolean> =>
|
|
51
|
-
providerV2
|
|
52
|
-
? providerV2.stat(parseWorkspacePath(candidate)).then((entry) => entry !== null)
|
|
53
|
-
: provider.exists(candidate);
|
|
54
|
-
const move = (source: string, destination: string): Promise<void> =>
|
|
55
|
-
providerV2
|
|
56
|
-
? providerV2
|
|
57
|
-
.move(parseWorkspacePath(source), parseWorkspacePath(destination), {
|
|
58
|
-
createParents: true,
|
|
59
|
-
})
|
|
60
|
-
.then(() => undefined)
|
|
61
|
-
: provider.rename(source, destination);
|
|
62
|
-
|
|
63
|
-
const oldNormalised = normalisePath(oldPath);
|
|
64
|
-
const newNormalised = normalisePath(newPath);
|
|
65
|
-
if (oldNormalised === newNormalised) return;
|
|
66
|
-
|
|
67
|
-
if (kind === 'directory' && newNormalised.startsWith(`${oldNormalised}/`)) {
|
|
68
|
-
throw new Error('A folder cannot be moved into itself.');
|
|
69
|
-
}
|
|
70
|
-
if (await exists(newPath)) {
|
|
71
|
-
throw new Error(`An entry named "${basename(newPath)}" already exists there.`);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
let oldCompanion: string | null = null;
|
|
75
|
-
let newCompanion: string | null = null;
|
|
76
|
-
if (kind === 'file' && isMarkdownPath(oldPath)) {
|
|
77
|
-
const candidate = documentCompanionPath(oldPath);
|
|
78
|
-
if (await exists(candidate)) {
|
|
79
|
-
oldCompanion = candidate;
|
|
80
|
-
newCompanion = documentCompanionPath(newPath);
|
|
81
|
-
if (
|
|
82
|
-
normalisePath(oldCompanion) !== normalisePath(newCompanion) &&
|
|
83
|
-
(await exists(newCompanion))
|
|
84
|
-
) {
|
|
85
|
-
throw new Error(`The companion folder "${basename(newCompanion)}" already exists there.`);
|
|
86
|
-
}
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
try {
|
|
91
|
-
await move(oldPath, newPath);
|
|
92
|
-
} catch (error: unknown) {
|
|
93
|
-
const state = await describeEntryMove(provider, oldPath, newPath);
|
|
94
|
-
if (state.source === 'present' && state.destination === 'missing') throw error;
|
|
95
|
-
throw new FileSystemMoveRecoveryError(oldPath, newPath, state, error);
|
|
96
|
-
}
|
|
97
|
-
if (!oldCompanion || !newCompanion) return;
|
|
98
|
-
|
|
99
|
-
try {
|
|
100
|
-
await move(oldCompanion, newCompanion);
|
|
101
|
-
} catch (error: unknown) {
|
|
102
|
-
// Keep the document and its assets together when the second half fails.
|
|
103
|
-
try {
|
|
104
|
-
await move(newPath, oldPath);
|
|
105
|
-
} catch (rollbackError: unknown) {
|
|
106
|
-
const state = await describePartialMove(
|
|
107
|
-
provider,
|
|
108
|
-
oldPath,
|
|
109
|
-
newPath,
|
|
110
|
-
oldCompanion,
|
|
111
|
-
newCompanion,
|
|
112
|
-
);
|
|
113
|
-
throw new FileSystemPartialMoveError(
|
|
114
|
-
oldPath,
|
|
115
|
-
newPath,
|
|
116
|
-
oldCompanion,
|
|
117
|
-
newCompanion,
|
|
118
|
-
state,
|
|
119
|
-
error,
|
|
120
|
-
rollbackError,
|
|
121
|
-
);
|
|
122
|
-
}
|
|
123
|
-
const state = await describePartialMove(provider, oldPath, newPath, oldCompanion, newCompanion);
|
|
124
|
-
const restoredSourceOnly =
|
|
125
|
-
state.source === 'present' &&
|
|
126
|
-
state.destination === 'missing' &&
|
|
127
|
-
state.companionSource === 'present' &&
|
|
128
|
-
state.companionDestination === 'missing';
|
|
129
|
-
if (!restoredSourceOnly) {
|
|
130
|
-
throw new FileSystemPartialMoveError(
|
|
131
|
-
oldPath,
|
|
132
|
-
newPath,
|
|
133
|
-
oldCompanion,
|
|
134
|
-
newCompanion,
|
|
135
|
-
state,
|
|
136
|
-
error,
|
|
137
|
-
null,
|
|
138
|
-
);
|
|
139
|
-
}
|
|
140
|
-
throw error;
|
|
141
|
-
}
|
|
142
|
-
}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';
|
|
2
|
-
import { parseWorkspacePath } from './workspace-path.js';
|
|
3
|
-
|
|
4
|
-
export type FileSystemPathPresence = 'present' | 'missing' | 'unknown';
|
|
5
|
-
|
|
6
|
-
export interface FileSystemPartialMoveState {
|
|
7
|
-
readonly source: FileSystemPathPresence;
|
|
8
|
-
readonly destination: FileSystemPathPresence;
|
|
9
|
-
readonly companionSource: FileSystemPathPresence;
|
|
10
|
-
readonly companionDestination: FileSystemPathPresence;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export type FileSystemMoveLocation = 'source' | 'destination' | 'both' | 'neither' | 'unknown';
|
|
14
|
-
|
|
15
|
-
export interface FileSystemEntryMoveState {
|
|
16
|
-
readonly source: FileSystemPathPresence;
|
|
17
|
-
readonly destination: FileSystemPathPresence;
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
function locationFromPresence(
|
|
21
|
-
source: FileSystemPathPresence,
|
|
22
|
-
destination: FileSystemPathPresence,
|
|
23
|
-
): FileSystemMoveLocation {
|
|
24
|
-
if (source === 'unknown' || destination === 'unknown') return 'unknown';
|
|
25
|
-
if (source === 'present' && destination === 'present') return 'both';
|
|
26
|
-
if (source === 'present') return 'source';
|
|
27
|
-
if (destination === 'present') return 'destination';
|
|
28
|
-
return 'neither';
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* One provider move failed without restoring a provable source-only state.
|
|
33
|
-
* This is backend-neutral: callers must use `location`, never infer from the
|
|
34
|
-
* original exception or a provider's advertised move atomicity.
|
|
35
|
-
*/
|
|
36
|
-
export class FileSystemMoveRecoveryError extends Error {
|
|
37
|
-
public readonly code = 'partial-move' as const;
|
|
38
|
-
|
|
39
|
-
public constructor(
|
|
40
|
-
public readonly sourcePath: string,
|
|
41
|
-
public readonly destinationPath: string,
|
|
42
|
-
public readonly state: FileSystemEntryMoveState,
|
|
43
|
-
public readonly moveError: unknown,
|
|
44
|
-
) {
|
|
45
|
-
super(
|
|
46
|
-
`The move did not restore one authoritative path. Entry location: ${locationFromPresence(
|
|
47
|
-
state.source,
|
|
48
|
-
state.destination,
|
|
49
|
-
)}.`,
|
|
50
|
-
);
|
|
51
|
-
this.name = 'FileSystemMoveRecoveryError';
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
public get location(): FileSystemMoveLocation {
|
|
55
|
-
return locationFromPresence(this.state.source, this.state.destination);
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/** Alias used by DocumentSession's document-retarget recovery protocol. */
|
|
59
|
-
public get documentLocation(): FileSystemMoveLocation {
|
|
60
|
-
return this.location;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* A compound document/companion move failed and the document rollback also
|
|
66
|
-
* failed. Callers must use the recorded post-state instead of assuming the
|
|
67
|
-
* original path is still authoritative.
|
|
68
|
-
*/
|
|
69
|
-
export class FileSystemPartialMoveError extends Error {
|
|
70
|
-
readonly code = 'partial-move' as const;
|
|
71
|
-
|
|
72
|
-
constructor(
|
|
73
|
-
readonly sourcePath: string,
|
|
74
|
-
readonly destinationPath: string,
|
|
75
|
-
readonly companionSourcePath: string,
|
|
76
|
-
readonly companionDestinationPath: string,
|
|
77
|
-
readonly state: FileSystemPartialMoveState,
|
|
78
|
-
readonly moveError: unknown,
|
|
79
|
-
readonly rollbackError: unknown,
|
|
80
|
-
) {
|
|
81
|
-
super(
|
|
82
|
-
`The document move could not be rolled back. Document location: ${locationFromPresence(
|
|
83
|
-
state.source,
|
|
84
|
-
state.destination,
|
|
85
|
-
)}; companion location: ${locationFromPresence(
|
|
86
|
-
state.companionSource,
|
|
87
|
-
state.companionDestination,
|
|
88
|
-
)}.`,
|
|
89
|
-
);
|
|
90
|
-
this.name = 'FileSystemPartialMoveError';
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
get documentLocation(): FileSystemMoveLocation {
|
|
94
|
-
return locationFromPresence(this.state.source, this.state.destination);
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
get companionLocation(): FileSystemMoveLocation {
|
|
98
|
-
return locationFromPresence(this.state.companionSource, this.state.companionDestination);
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export function isFileSystemPartialMoveError(error: unknown): error is FileSystemPartialMoveError {
|
|
103
|
-
return error instanceof FileSystemPartialMoveError;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
export function isFileSystemMoveRecoveryError(
|
|
107
|
-
error: unknown,
|
|
108
|
-
): error is FileSystemMoveRecoveryError {
|
|
109
|
-
return error instanceof FileSystemMoveRecoveryError;
|
|
110
|
-
}
|
|
111
|
-
|
|
112
|
-
export function isFileSystemMoveStateError(
|
|
113
|
-
error: unknown,
|
|
114
|
-
): error is FileSystemMoveRecoveryError | FileSystemPartialMoveError {
|
|
115
|
-
return isFileSystemMoveRecoveryError(error) || isFileSystemPartialMoveError(error);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
async function probePath(
|
|
119
|
-
provider: FileSystemProvider,
|
|
120
|
-
path: string,
|
|
121
|
-
): Promise<FileSystemPathPresence> {
|
|
122
|
-
try {
|
|
123
|
-
const providerV2 = getFileSystemProviderV2(provider);
|
|
124
|
-
const present = providerV2
|
|
125
|
-
? (await providerV2.stat(parseWorkspacePath(path))) !== null
|
|
126
|
-
: await provider.exists(path);
|
|
127
|
-
return present ? 'present' : 'missing';
|
|
128
|
-
} catch {
|
|
129
|
-
return 'unknown';
|
|
130
|
-
}
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
export async function describePartialMove(
|
|
134
|
-
provider: FileSystemProvider,
|
|
135
|
-
sourcePath: string,
|
|
136
|
-
destinationPath: string,
|
|
137
|
-
companionSourcePath: string,
|
|
138
|
-
companionDestinationPath: string,
|
|
139
|
-
): Promise<FileSystemPartialMoveState> {
|
|
140
|
-
const [source, destination, companionSource, companionDestination] = await Promise.all([
|
|
141
|
-
probePath(provider, sourcePath),
|
|
142
|
-
probePath(provider, destinationPath),
|
|
143
|
-
probePath(provider, companionSourcePath),
|
|
144
|
-
probePath(provider, companionDestinationPath),
|
|
145
|
-
]);
|
|
146
|
-
return { source, destination, companionSource, companionDestination };
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
export async function describeEntryMove(
|
|
150
|
-
provider: FileSystemProvider,
|
|
151
|
-
sourcePath: string,
|
|
152
|
-
destinationPath: string,
|
|
153
|
-
): Promise<FileSystemEntryMoveState> {
|
|
154
|
-
const [source, destination] = await Promise.all([
|
|
155
|
-
probePath(provider, sourcePath),
|
|
156
|
-
probePath(provider, destinationPath),
|
|
157
|
-
]);
|
|
158
|
-
return { source, destination };
|
|
159
|
-
}
|