@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.
- package/README.md +2 -2
- package/dist/{chunk-2D7Y4IR3.js → chunk-4437YWLE.js} +123 -67
- package/dist/{chunk-5MYAICRE.js → chunk-45T5AFCN.js} +44 -57
- package/dist/{chunk-PGR7LK6D.js → chunk-6L3JRDE7.js} +14 -6
- package/dist/{chunk-RVQHY3XU.js → chunk-6XHOOBYF.js} +0 -1
- package/dist/chunk-73OOROXH.js +8 -0
- package/dist/{chunk-SI2LU2RP.js → chunk-AYWKIZLD.js} +1 -1
- package/dist/{chunk-GCPBEMMH.js → chunk-BVY7GGNV.js} +10 -21
- package/dist/{chunk-AEHCVWU5.js → chunk-DZB666V7.js} +0 -1
- package/dist/{chunk-75UUF6C4.js → chunk-HI7QEWL6.js} +18 -10
- package/dist/chunk-KQ6756AJ.js +28 -0
- package/dist/chunk-LMMOFRGQ.js +148 -0
- package/dist/{chunk-FNW556FN.js → chunk-M2PUNKHS.js} +0 -1
- package/dist/chunk-M5ZNQGR5.js +19 -0
- package/dist/chunk-M62ZGJ5I.js +51 -0
- package/dist/chunk-OQCPBOQA.js +168 -0
- package/dist/{chunk-EGNDADXB.js → chunk-QI6YKTQV.js} +2 -3
- package/dist/chunk-SJBB5OD7.js +227 -0
- package/dist/{chunk-EZKJZUNJ.js → chunk-XAMILHQP.js} +0 -1
- package/dist/{chunk-J32GU3F3.js → chunk-YM7O3PWO.js} +249 -222
- package/dist/{chunk-RQJRQF46.js → chunk-ZO7G53QP.js} +41 -49
- package/dist/document/index.d.ts +358 -6
- package/dist/document/index.js +24 -4
- package/dist/filesystem/electron.d.ts +73 -4
- package/dist/filesystem/electron.js +16 -4
- package/dist/filesystem/index.d.ts +228 -22
- package/dist/filesystem/index.js +133 -20
- package/dist/filesystem/indexeddb.d.ts +284 -5
- package/dist/filesystem/indexeddb.js +22 -5
- package/dist/filesystem/memory.d.ts +152 -4
- package/dist/filesystem/memory.js +12 -4
- package/dist/filesystem/native.d.ts +136 -4
- package/dist/filesystem/native.js +27 -4
- package/dist/host/index.d.ts +32 -9
- package/dist/host/index.js +26 -30
- package/dist/index.d.ts +14 -10
- package/dist/index.js +204 -10
- package/dist/mcp/index.d.ts +33 -4
- package/dist/mcp/index.js +31 -4
- package/dist/mcp/zod.d.ts +645 -643
- package/dist/mcp/zod.js +700 -885
- package/dist/share/index.d.ts +43 -0
- package/dist/share/index.js +12 -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 +225 -3
- package/dist/vscode/index.js +389 -3
- package/dist/workspace/index.d.ts +141 -4
- package/dist/workspace/index.js +28 -3
- package/package.json +10 -5
- package/dist/chunk-2D7Y4IR3.js.map +0 -1
- package/dist/chunk-5MYAICRE.js.map +0 -1
- package/dist/chunk-75UUF6C4.js.map +0 -1
- package/dist/chunk-AEHCVWU5.js.map +0 -1
- package/dist/chunk-AYZ4HN5M.js +0 -20
- package/dist/chunk-AYZ4HN5M.js.map +0 -1
- package/dist/chunk-EGNDADXB.js.map +0 -1
- package/dist/chunk-EZKJZUNJ.js.map +0 -1
- package/dist/chunk-FNW556FN.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-RVQHY3XU.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/index.js.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/electron.js.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/index.js.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/indexeddb.js.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/memory.js.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/native.js.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/index.js.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/index.js.map +0 -1
- package/dist/mcp/index.d.ts.map +0 -1
- package/dist/mcp/index.js.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/mcp/zod.js.map +0 -1
- package/dist/vscode/index.d.ts.map +0 -1
- package/dist/vscode/index.js.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/index.js.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/README.md
CHANGED
|
@@ -55,8 +55,8 @@ compatibility `filesystem` barrel still re-exports every provider, but eagerly
|
|
|
55
55
|
constructing from that barrel puts mutually exclusive backends in one startup
|
|
56
56
|
bundle.
|
|
57
57
|
|
|
58
|
-
Mutation behavior is explicit: `writeFile`
|
|
59
|
-
`upsert` mode; `remove` distinguishes an empty-directory removal from a
|
|
58
|
+
Mutation behavior is explicit: `writeFile` accepts a `create`, `replace`, or
|
|
59
|
+
`upsert` mode and defaults to `upsert` when omitted; `remove` distinguishes an empty-directory removal from a
|
|
60
60
|
recursive tree removal; and `move` never overwrites its destination. Missing
|
|
61
61
|
entries are returned as `null` only by `stat` and `readFile`. Permission,
|
|
62
62
|
wrong-kind, conflict, quota, and I/O failures remain typed `FsError`s.
|
|
@@ -1,9 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
2
|
withFileCommitLock
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-DZB666V7.js";
|
|
4
4
|
import {
|
|
5
|
+
parentChain
|
|
6
|
+
} from "./chunk-KQ6756AJ.js";
|
|
7
|
+
import {
|
|
8
|
+
bytesEqual,
|
|
9
|
+
compareSnapshotsByName,
|
|
10
|
+
compareText,
|
|
11
|
+
copyBytes,
|
|
5
12
|
parseFileSystemVersion
|
|
6
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-M62ZGJ5I.js";
|
|
14
|
+
import {
|
|
15
|
+
decodeUtf8Text
|
|
16
|
+
} from "./chunk-M5ZNQGR5.js";
|
|
7
17
|
import {
|
|
8
18
|
FsError,
|
|
9
19
|
WORKSPACE_ROOT,
|
|
@@ -13,7 +23,7 @@ import {
|
|
|
13
23
|
workspacePathContains,
|
|
14
24
|
workspacePathDirname,
|
|
15
25
|
workspacePathJoin
|
|
16
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-AYWKIZLD.js";
|
|
17
27
|
|
|
18
28
|
// src/filesystem/native-provider-v2.ts
|
|
19
29
|
var NativeFileSystemMoveRecoveryError = class extends FsError {
|
|
@@ -102,7 +112,7 @@ var NativeFileSystemProviderV2 = class {
|
|
|
102
112
|
withoutData((await this.scanMetadataHandle(childPath, childHandle, "list")).root)
|
|
103
113
|
);
|
|
104
114
|
}
|
|
105
|
-
children.sort(
|
|
115
|
+
children.sort(compareSnapshotsByName);
|
|
106
116
|
return Object.freeze(children);
|
|
107
117
|
});
|
|
108
118
|
}
|
|
@@ -141,7 +151,7 @@ var NativeFileSystemProviderV2 = class {
|
|
|
141
151
|
await this.writeBytes(canonical, ownedData);
|
|
142
152
|
writeCompleted = true;
|
|
143
153
|
const written = await this.requireSnapshot(canonical, "write");
|
|
144
|
-
if (written.root.kind !== "file" || !
|
|
154
|
+
if (written.root.kind !== "file" || !bytesEqual(written.root.data, ownedData)) {
|
|
145
155
|
throw this.error(
|
|
146
156
|
"conflict",
|
|
147
157
|
"write",
|
|
@@ -282,7 +292,7 @@ var NativeFileSystemProviderV2 = class {
|
|
|
282
292
|
}
|
|
283
293
|
const createdParents = await this.createDirectories(missingParents);
|
|
284
294
|
let destinationVersion = null;
|
|
285
|
-
let
|
|
295
|
+
let sourceDeleteAttempted = false;
|
|
286
296
|
try {
|
|
287
297
|
await this.writeTree(source, sourcePath, destinationPath);
|
|
288
298
|
const copied = await this.requireSnapshot(destinationPath, "move");
|
|
@@ -302,8 +312,15 @@ var NativeFileSystemProviderV2 = class {
|
|
|
302
312
|
destinationPath
|
|
303
313
|
});
|
|
304
314
|
}
|
|
315
|
+
if (!await this.matchesCapturedSource(sourcePath, source)) {
|
|
316
|
+
throw new FsError("conflict", "Source changed while the move was copied.", {
|
|
317
|
+
operation: "move",
|
|
318
|
+
path: sourcePath,
|
|
319
|
+
destinationPath
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
sourceDeleteAttempted = true;
|
|
305
323
|
await this.removeEntry(sourcePath, source.root.kind === "directory");
|
|
306
|
-
sourceDeleted = true;
|
|
307
324
|
const [sourceAfter, destinationAfter] = await Promise.all([
|
|
308
325
|
this.tryScanMetadata(sourcePath, "move"),
|
|
309
326
|
this.tryScanMetadata(destinationPath, "move")
|
|
@@ -323,7 +340,7 @@ var NativeFileSystemProviderV2 = class {
|
|
|
323
340
|
source,
|
|
324
341
|
createdParents,
|
|
325
342
|
destinationVersion,
|
|
326
|
-
|
|
343
|
+
sourceDeleteAttempted,
|
|
327
344
|
error
|
|
328
345
|
);
|
|
329
346
|
}
|
|
@@ -513,7 +530,7 @@ var NativeFileSystemProviderV2 = class {
|
|
|
513
530
|
await this.scanHandle(workspacePathJoin(path, name), childHandle, operation, scanFile)
|
|
514
531
|
);
|
|
515
532
|
}
|
|
516
|
-
const childRoots = children.map((child) => child.root).sort(
|
|
533
|
+
const childRoots = children.map((child) => child.root).sort(compareSnapshotsByName);
|
|
517
534
|
const version = await metadataVersion(
|
|
518
535
|
"directory",
|
|
519
536
|
new TextEncoder().encode(
|
|
@@ -574,6 +591,25 @@ var NativeFileSystemProviderV2 = class {
|
|
|
574
591
|
kind: "file",
|
|
575
592
|
path,
|
|
576
593
|
name: workspacePathBasename(path),
|
|
594
|
+
// Derived from size + mtime, never from content. This keeps stat/list
|
|
595
|
+
// proportional to entry count instead of bytes (see scanMetadataHandle),
|
|
596
|
+
// which is what makes large workspaces listable in a browser tab at all.
|
|
597
|
+
//
|
|
598
|
+
// The cost is a real blind spot: an external same-size rewrite inside one
|
|
599
|
+
// mtime tick is invisible here. FAT/exFAT stamp mtime at 2-second
|
|
600
|
+
// granularity, and network shares can be coarser, so this is reachable on
|
|
601
|
+
// removable and mounted volumes rather than merely theoretical. Two
|
|
602
|
+
// consequences follow, and neither is hypothetical:
|
|
603
|
+
// - a conditional write guarded on expectedVersion accepts, silently
|
|
604
|
+
// overwriting the external edit;
|
|
605
|
+
// - move() re-checks this version to prove the source is unchanged
|
|
606
|
+
// before deleting it, so it can delete a source whose bytes it never
|
|
607
|
+
// copied, losing the edit outright.
|
|
608
|
+
// `conditionalWrite: 'process'` declares the first (expectedVersion binds
|
|
609
|
+
// only against writers in this process). The second is a provider-internal
|
|
610
|
+
// check that the token cannot actually support; closing it means
|
|
611
|
+
// byte-comparing the captured source before the delete, not hashing
|
|
612
|
+
// content here, which would undo the scan-by-metadata property above.
|
|
577
613
|
size: file.size,
|
|
578
614
|
version: await metadataVersion(
|
|
579
615
|
"file",
|
|
@@ -663,28 +699,44 @@ var NativeFileSystemProviderV2 = class {
|
|
|
663
699
|
if (entry.kind === "file") await this.writeBytes(path, entry.data);
|
|
664
700
|
}
|
|
665
701
|
}
|
|
666
|
-
async rollbackMoveAndThrow(sourcePath, destinationPath, source, createdParents, destinationVersion,
|
|
702
|
+
async rollbackMoveAndThrow(sourcePath, destinationPath, source, createdParents, destinationVersion, sourceDeleteAttempted, primary) {
|
|
667
703
|
const primaryError = this.translateError(primary, "move", sourcePath, destinationPath);
|
|
668
704
|
const recoveryErrors = [];
|
|
669
|
-
|
|
670
|
-
if (
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
705
|
+
let sourceWhole = true;
|
|
706
|
+
if (sourceDeleteAttempted) {
|
|
707
|
+
sourceWhole = await this.matchesCapturedSource(sourcePath, source);
|
|
708
|
+
if (!sourceWhole) {
|
|
709
|
+
try {
|
|
710
|
+
await this.writeTree(source, sourcePath, sourcePath);
|
|
711
|
+
const restored = await this.probeSnapshot(sourcePath);
|
|
712
|
+
if (!restored || !equalTreeContents(source, sourcePath, restored, sourcePath)) {
|
|
713
|
+
throw new FsError("conflict", "Restored source does not match its captured state.", {
|
|
714
|
+
operation: "move",
|
|
715
|
+
path: sourcePath,
|
|
716
|
+
destinationPath
|
|
717
|
+
});
|
|
718
|
+
}
|
|
719
|
+
sourceWhole = true;
|
|
720
|
+
} catch (error) {
|
|
721
|
+
recoveryErrors.push(this.translateError(error, "move", sourcePath, destinationPath));
|
|
680
722
|
}
|
|
681
|
-
} catch (error) {
|
|
682
|
-
recoveryErrors.push(this.translateError(error, "move", sourcePath, destinationPath));
|
|
683
723
|
}
|
|
684
724
|
}
|
|
685
725
|
const destinationCurrent = await this.probeScan(destinationPath);
|
|
686
726
|
if (destinationCurrent) {
|
|
687
|
-
if (
|
|
727
|
+
if (!sourceWhole) {
|
|
728
|
+
recoveryErrors.push(
|
|
729
|
+
new FsError(
|
|
730
|
+
"conflict",
|
|
731
|
+
"Source is incomplete; rollback kept the copy at the destination.",
|
|
732
|
+
{
|
|
733
|
+
operation: "move",
|
|
734
|
+
path: sourcePath,
|
|
735
|
+
destinationPath
|
|
736
|
+
}
|
|
737
|
+
)
|
|
738
|
+
);
|
|
739
|
+
} else if (destinationVersion && destinationCurrent.root.version !== destinationVersion) {
|
|
688
740
|
recoveryErrors.push(
|
|
689
741
|
new FsError("conflict", "Destination changed; rollback will not delete it.", {
|
|
690
742
|
operation: "move",
|
|
@@ -716,6 +768,18 @@ var NativeFileSystemProviderV2 = class {
|
|
|
716
768
|
state
|
|
717
769
|
);
|
|
718
770
|
}
|
|
771
|
+
/**
|
|
772
|
+
* Whether the source still holds exactly the bytes the move captured.
|
|
773
|
+
*
|
|
774
|
+
* A probe that fails answers "no": rollback must never treat an unverifiable
|
|
775
|
+
* source as whole, because that is precisely what licenses deleting the copy
|
|
776
|
+
* at the destination.
|
|
777
|
+
*/
|
|
778
|
+
async matchesCapturedSource(sourcePath, source) {
|
|
779
|
+
const current = await this.probeSnapshot(sourcePath);
|
|
780
|
+
if (!current) return false;
|
|
781
|
+
return equalTreeContents(source, sourcePath, current, sourcePath);
|
|
782
|
+
}
|
|
719
783
|
async probeScan(path) {
|
|
720
784
|
try {
|
|
721
785
|
return await this.tryScanMetadata(path, "move");
|
|
@@ -784,15 +848,6 @@ async function metadataVersion(kind, metadata, operation, path) {
|
|
|
784
848
|
const hex = [...new Uint8Array(digest)].map((value) => value.toString(16).padStart(2, "0")).join("");
|
|
785
849
|
return parseFileSystemVersion(`sha256:${hex}`);
|
|
786
850
|
}
|
|
787
|
-
function parentChain(path) {
|
|
788
|
-
const parents = [];
|
|
789
|
-
let current = workspacePathDirname(path);
|
|
790
|
-
while (current) {
|
|
791
|
-
parents.unshift(current);
|
|
792
|
-
current = workspacePathDirname(current);
|
|
793
|
-
}
|
|
794
|
-
return parents;
|
|
795
|
-
}
|
|
796
851
|
function pathDepth(path) {
|
|
797
852
|
return path ? path.split("/").length : 0;
|
|
798
853
|
}
|
|
@@ -805,17 +860,6 @@ function isMissingOrKindError(error) {
|
|
|
805
860
|
const name = errorName(error);
|
|
806
861
|
return name === "NotFoundError" || name === "TypeMismatchError";
|
|
807
862
|
}
|
|
808
|
-
function copyBytes(data) {
|
|
809
|
-
const source = ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
|
|
810
|
-
const copy = new Uint8Array(source.byteLength);
|
|
811
|
-
copy.set(source);
|
|
812
|
-
return copy.buffer;
|
|
813
|
-
}
|
|
814
|
-
function equalBytes(left, right) {
|
|
815
|
-
const leftBytes = new Uint8Array(left);
|
|
816
|
-
const rightBytes = new Uint8Array(right);
|
|
817
|
-
return leftBytes.byteLength === rightBytes.byteLength && leftBytes.every((value, index) => value === rightBytes[index]);
|
|
818
|
-
}
|
|
819
863
|
function equalTreeContents(left, leftRoot, right, rightRoot) {
|
|
820
864
|
if (left.entries.length !== right.entries.length) return false;
|
|
821
865
|
const rightByRelativePath = /* @__PURE__ */ new Map();
|
|
@@ -830,7 +874,7 @@ function equalTreeContents(left, leftRoot, right, rightRoot) {
|
|
|
830
874
|
const counterpart = rightByRelativePath.get(relativePath);
|
|
831
875
|
if (!counterpart || counterpart.kind !== entry.kind) return false;
|
|
832
876
|
if (entry.kind === "file") {
|
|
833
|
-
if (counterpart.kind !== "file" || !
|
|
877
|
+
if (counterpart.kind !== "file" || !bytesEqual(entry.data, counterpart.data)) return false;
|
|
834
878
|
}
|
|
835
879
|
}
|
|
836
880
|
return true;
|
|
@@ -871,13 +915,6 @@ function newestLastModified(children) {
|
|
|
871
915
|
}
|
|
872
916
|
return newest ? new Date(newest).toISOString() : EPOCH;
|
|
873
917
|
}
|
|
874
|
-
function compareSnapshots(left, right) {
|
|
875
|
-
if (left.kind !== right.kind) return left.kind === "directory" ? -1 : 1;
|
|
876
|
-
return compareText(left.name, right.name);
|
|
877
|
-
}
|
|
878
|
-
function compareText(left, right) {
|
|
879
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
880
|
-
}
|
|
881
918
|
|
|
882
919
|
// src/filesystem/native-provider.ts
|
|
883
920
|
function isNativeFileSystemSupported() {
|
|
@@ -950,6 +987,21 @@ function isMissingEntryError(error) {
|
|
|
950
987
|
const name = errorName2(error);
|
|
951
988
|
return name === "NotFoundError" || name === "TypeMismatchError";
|
|
952
989
|
}
|
|
990
|
+
function isKindMismatchError(error) {
|
|
991
|
+
return errorName2(error) === "TypeMismatchError";
|
|
992
|
+
}
|
|
993
|
+
function rootIsNotAMutationTarget(operation, path) {
|
|
994
|
+
return new FsError("invalid-path", "The workspace root is not a file entry.", {
|
|
995
|
+
operation,
|
|
996
|
+
path
|
|
997
|
+
});
|
|
998
|
+
}
|
|
999
|
+
function notAFile(operation, path) {
|
|
1000
|
+
return new FsError("type-mismatch", "Expected a file but found a directory.", {
|
|
1001
|
+
operation,
|
|
1002
|
+
path
|
|
1003
|
+
});
|
|
1004
|
+
}
|
|
953
1005
|
function isPermissionError(error) {
|
|
954
1006
|
const name = errorName2(error);
|
|
955
1007
|
return name === "NotAllowedError" || name === "SecurityError";
|
|
@@ -1036,22 +1088,16 @@ var NativeFileSystemProvider = class {
|
|
|
1036
1088
|
}
|
|
1037
1089
|
async readFile(path) {
|
|
1038
1090
|
const p = normalisePath(path);
|
|
1039
|
-
const
|
|
1040
|
-
if (
|
|
1041
|
-
|
|
1042
|
-
const fileHandle = await dir.getFileHandle(baseName(p));
|
|
1043
|
-
const file = await fileHandle.getFile();
|
|
1044
|
-
return file.text();
|
|
1045
|
-
} catch (error) {
|
|
1046
|
-
if (isMissingEntryError(error)) return null;
|
|
1047
|
-
throw error;
|
|
1048
|
-
}
|
|
1091
|
+
const data = await this.readBinary(p);
|
|
1092
|
+
if (data === null) return null;
|
|
1093
|
+
return decodeUtf8Text(data, { label: "The file", operation: "read", path: p });
|
|
1049
1094
|
}
|
|
1050
1095
|
async writeFile(path, content) {
|
|
1051
1096
|
return this.withMutationLock(() => this.writeFileUnlocked(path, content));
|
|
1052
1097
|
}
|
|
1053
1098
|
async writeFileUnlocked(path, content) {
|
|
1054
1099
|
const p = normalisePath(path);
|
|
1100
|
+
if (!p) throw rootIsNotAMutationTarget("write", path);
|
|
1055
1101
|
const dir = await resolveDirCreate(this.root, parentDir(p));
|
|
1056
1102
|
const fileHandle = await dir.getFileHandle(baseName(p), { create: true });
|
|
1057
1103
|
const writable = await fileHandle.createWritable();
|
|
@@ -1079,7 +1125,7 @@ var NativeFileSystemProvider = class {
|
|
|
1079
1125
|
}
|
|
1080
1126
|
async deleteUnlocked(path) {
|
|
1081
1127
|
const p = normalisePath(path);
|
|
1082
|
-
if (!p) throw
|
|
1128
|
+
if (!p) throw rootIsNotAMutationTarget("remove", path);
|
|
1083
1129
|
const parent = parentDir(p);
|
|
1084
1130
|
const name = baseName(p);
|
|
1085
1131
|
const dir = await resolveDir(this.root, parent);
|
|
@@ -1098,9 +1144,7 @@ var NativeFileSystemProvider = class {
|
|
|
1098
1144
|
const op = normalisePath(oldPath);
|
|
1099
1145
|
const np = normalisePath(newPath);
|
|
1100
1146
|
if (op === np) return;
|
|
1101
|
-
if (!op || !np)
|
|
1102
|
-
throw new Error("Cannot rename the filesystem root");
|
|
1103
|
-
}
|
|
1147
|
+
if (!op || !np) throw rootIsNotAMutationTarget("move", !op ? oldPath : newPath);
|
|
1104
1148
|
if (np.startsWith(op + "/")) {
|
|
1105
1149
|
throw new Error("Cannot move a directory into itself");
|
|
1106
1150
|
}
|
|
@@ -1154,6 +1198,14 @@ var NativeFileSystemProvider = class {
|
|
|
1154
1198
|
try {
|
|
1155
1199
|
await this.deleteUnlocked(op);
|
|
1156
1200
|
} catch (error) {
|
|
1201
|
+
try {
|
|
1202
|
+
await this.copyDirectory(np, op);
|
|
1203
|
+
} catch (restoreError) {
|
|
1204
|
+
throw new NativeMoveRecoveryError(
|
|
1205
|
+
`Move partially deleted the source and it could not be restored; the copy at ${newPath} was kept: ${oldPath} -> ${newPath}`,
|
|
1206
|
+
[error, restoreError]
|
|
1207
|
+
);
|
|
1208
|
+
}
|
|
1157
1209
|
try {
|
|
1158
1210
|
await this.deleteUnlocked(np);
|
|
1159
1211
|
} catch (rollbackError) {
|
|
@@ -1186,6 +1238,7 @@ var NativeFileSystemProvider = class {
|
|
|
1186
1238
|
}
|
|
1187
1239
|
async exists(path) {
|
|
1188
1240
|
const p = normalisePath(path);
|
|
1241
|
+
if (!p) return true;
|
|
1189
1242
|
const parent = parentDir(p);
|
|
1190
1243
|
const name = baseName(p);
|
|
1191
1244
|
const dir = await resolveDir(this.root, parent);
|
|
@@ -1212,6 +1265,7 @@ var NativeFileSystemProvider = class {
|
|
|
1212
1265
|
}
|
|
1213
1266
|
async stat(path) {
|
|
1214
1267
|
const p = normalisePath(path);
|
|
1268
|
+
if (!p) return null;
|
|
1215
1269
|
const dir = await resolveDir(this.root, parentDir(p));
|
|
1216
1270
|
if (!dir) return null;
|
|
1217
1271
|
try {
|
|
@@ -1230,6 +1284,7 @@ var NativeFileSystemProvider = class {
|
|
|
1230
1284
|
}
|
|
1231
1285
|
async readBinary(path) {
|
|
1232
1286
|
const p = normalisePath(path);
|
|
1287
|
+
if (!p) throw notAFile("read", p);
|
|
1233
1288
|
const dir = await resolveDir(this.root, parentDir(p));
|
|
1234
1289
|
if (!dir) return null;
|
|
1235
1290
|
try {
|
|
@@ -1237,6 +1292,7 @@ var NativeFileSystemProvider = class {
|
|
|
1237
1292
|
const file = await fileHandle.getFile();
|
|
1238
1293
|
return file.arrayBuffer();
|
|
1239
1294
|
} catch (error) {
|
|
1295
|
+
if (isKindMismatchError(error)) throw notAFile("read", p);
|
|
1240
1296
|
if (isMissingEntryError(error)) return null;
|
|
1241
1297
|
throw error;
|
|
1242
1298
|
}
|
|
@@ -1246,6 +1302,7 @@ var NativeFileSystemProvider = class {
|
|
|
1246
1302
|
}
|
|
1247
1303
|
async writeBinaryUnlocked(path, data) {
|
|
1248
1304
|
const p = normalisePath(path);
|
|
1305
|
+
if (!p) throw rootIsNotAMutationTarget("write", path);
|
|
1249
1306
|
const dir = await resolveDirCreate(this.root, parentDir(p));
|
|
1250
1307
|
const fileHandle = await dir.getFileHandle(baseName(p), { create: true });
|
|
1251
1308
|
const writable = await fileHandle.createWritable();
|
|
@@ -1290,4 +1347,3 @@ export {
|
|
|
1290
1347
|
openNativeFolder,
|
|
1291
1348
|
restoreNativeFolder
|
|
1292
1349
|
};
|
|
1293
|
-
//# sourceMappingURL=chunk-2D7Y4IR3.js.map
|
|
@@ -1,12 +1,19 @@
|
|
|
1
1
|
import {
|
|
2
|
+
guessMimeType
|
|
3
|
+
} from "./chunk-YM7O3PWO.js";
|
|
4
|
+
import {
|
|
5
|
+
bytesEqual,
|
|
6
|
+
compareSnapshotsByName,
|
|
7
|
+
compareText,
|
|
8
|
+
copyBytes,
|
|
2
9
|
parseFileSystemVersion
|
|
3
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-M62ZGJ5I.js";
|
|
4
11
|
import {
|
|
5
12
|
FileSystemMoveRecoveryError,
|
|
6
13
|
FileSystemPartialMoveError,
|
|
7
14
|
describeEntryMove,
|
|
8
15
|
describePartialMove
|
|
9
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-QI6YKTQV.js";
|
|
10
17
|
import {
|
|
11
18
|
FsError,
|
|
12
19
|
WORKSPACE_ROOT,
|
|
@@ -17,10 +24,10 @@ import {
|
|
|
17
24
|
workspacePathDirname,
|
|
18
25
|
workspacePathJoin,
|
|
19
26
|
workspacePathToLegacy
|
|
20
|
-
} from "./chunk-
|
|
27
|
+
} from "./chunk-AYWKIZLD.js";
|
|
21
28
|
import {
|
|
22
29
|
getFileSystemProviderV2
|
|
23
|
-
} from "./chunk-
|
|
30
|
+
} from "./chunk-XAMILHQP.js";
|
|
24
31
|
|
|
25
32
|
// src/filesystem/legacy-v2-adapter.ts
|
|
26
33
|
var EPOCH = (/* @__PURE__ */ new Date(0)).toISOString();
|
|
@@ -76,7 +83,7 @@ var LegacyFileSystemProviderV2Adapter = class {
|
|
|
76
83
|
if (entry.kind !== "directory") {
|
|
77
84
|
throw this.error("type-mismatch", "list", canonical, "Expected a directory, found a file.");
|
|
78
85
|
}
|
|
79
|
-
const children = [...tree.entries.entries()].filter(([entryPath]) => entryPath && workspacePathDirname(entryPath) === canonical).map(([, child]) => copyEntrySnapshot(child)).sort(
|
|
86
|
+
const children = [...tree.entries.entries()].filter(([entryPath]) => entryPath && workspacePathDirname(entryPath) === canonical).map(([, child]) => copyEntrySnapshot(child)).sort(compareSnapshotsByName);
|
|
80
87
|
return Object.freeze(children);
|
|
81
88
|
});
|
|
82
89
|
}
|
|
@@ -109,7 +116,7 @@ var LegacyFileSystemProviderV2Adapter = class {
|
|
|
109
116
|
canonical
|
|
110
117
|
);
|
|
111
118
|
const written = (await this.captureTree("write")).entries.get(canonical);
|
|
112
|
-
if (written?.kind !== "file" || !
|
|
119
|
+
if (written?.kind !== "file" || !bytesEqual(written.data, ownedData)) {
|
|
113
120
|
throw this.error(
|
|
114
121
|
"io",
|
|
115
122
|
"write",
|
|
@@ -435,7 +442,7 @@ var LegacyFileSystemProviderV2Adapter = class {
|
|
|
435
442
|
children.push(file);
|
|
436
443
|
}
|
|
437
444
|
}
|
|
438
|
-
children.sort(
|
|
445
|
+
children.sort(compareSnapshotsByName);
|
|
439
446
|
const version = await contentVersion(
|
|
440
447
|
"directory",
|
|
441
448
|
new TextEncoder().encode(
|
|
@@ -543,17 +550,6 @@ function isLegacyEntry(value) {
|
|
|
543
550
|
const candidate = value;
|
|
544
551
|
return (candidate.kind === "file" || candidate.kind === "directory") && typeof candidate.name === "string" && typeof candidate.path === "string";
|
|
545
552
|
}
|
|
546
|
-
function copyBytes(data) {
|
|
547
|
-
const source = ArrayBuffer.isView(data) ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength) : new Uint8Array(data);
|
|
548
|
-
const copy = new Uint8Array(source.byteLength);
|
|
549
|
-
copy.set(source);
|
|
550
|
-
return copy.buffer;
|
|
551
|
-
}
|
|
552
|
-
function equalBytes(left, right) {
|
|
553
|
-
const leftBytes = new Uint8Array(left);
|
|
554
|
-
const rightBytes = new Uint8Array(right);
|
|
555
|
-
return leftBytes.byteLength === rightBytes.byteLength && leftBytes.every((value, index) => value === rightBytes[index]);
|
|
556
|
-
}
|
|
557
553
|
function fileMetadata(file) {
|
|
558
554
|
return Object.freeze({
|
|
559
555
|
kind: "file",
|
|
@@ -581,13 +577,6 @@ function newestLastModified(children) {
|
|
|
581
577
|
}
|
|
582
578
|
return newest ? new Date(newest).toISOString() : EPOCH;
|
|
583
579
|
}
|
|
584
|
-
function compareSnapshots(left, right) {
|
|
585
|
-
if (left.kind !== right.kind) return left.kind === "directory" ? -1 : 1;
|
|
586
|
-
return compareText(left.name, right.name);
|
|
587
|
-
}
|
|
588
|
-
function compareText(left, right) {
|
|
589
|
-
return left < right ? -1 : left > right ? 1 : 0;
|
|
590
|
-
}
|
|
591
580
|
|
|
592
581
|
// src/filesystem/move-entry.ts
|
|
593
582
|
function normalisePath(path) {
|
|
@@ -690,7 +679,10 @@ async function moveFileSystemEntry(provider, oldPath, newPath, kind) {
|
|
|
690
679
|
|
|
691
680
|
// src/filesystem/dbk-workspace.ts
|
|
692
681
|
function normaliseRelativePath(path, label) {
|
|
693
|
-
if (path.includes("\\") || path.
|
|
682
|
+
if (path.includes("\\") || /^[a-zA-Z]:/u.test(path) || [...path].some((character) => {
|
|
683
|
+
const codePoint = character.codePointAt(0) ?? 0;
|
|
684
|
+
return codePoint <= 31 || codePoint === 127;
|
|
685
|
+
})) {
|
|
694
686
|
throw new Error(`DBK ${label} must use a safe forward-slash path: ${path}`);
|
|
695
687
|
}
|
|
696
688
|
const normalized = path.replace(/^\/+|\/+$/g, "").replace(/\/+/g, "/");
|
|
@@ -700,6 +692,18 @@ function normaliseRelativePath(path, label) {
|
|
|
700
692
|
}
|
|
701
693
|
return segments.join("/");
|
|
702
694
|
}
|
|
695
|
+
function decodeMarkdownFile(data, path) {
|
|
696
|
+
let content;
|
|
697
|
+
try {
|
|
698
|
+
content = new TextDecoder("utf-8", { fatal: true }).decode(data);
|
|
699
|
+
} catch {
|
|
700
|
+
throw new Error(`The external DBK contains invalid UTF-8 Markdown: ${path}`);
|
|
701
|
+
}
|
|
702
|
+
if (content.includes("\0")) {
|
|
703
|
+
throw new Error(`The external DBK contains a NUL character in Markdown: ${path}`);
|
|
704
|
+
}
|
|
705
|
+
return content;
|
|
706
|
+
}
|
|
703
707
|
function joinPath(parent, child) {
|
|
704
708
|
return `${parent.replace(/\/+$/g, "")}/${child.replace(/^\/+/, "")}`;
|
|
705
709
|
}
|
|
@@ -721,6 +725,7 @@ async function createDbkWorkspaceSnapshot(source, options) {
|
|
|
721
725
|
const listed = await source.listFiles();
|
|
722
726
|
const entries = [...listed].sort((a, b) => a.path.localeCompare(b.path));
|
|
723
727
|
const seenSourcePaths = /* @__PURE__ */ new Set();
|
|
728
|
+
const validatedEntries = [];
|
|
724
729
|
const files = [];
|
|
725
730
|
let documentContent = null;
|
|
726
731
|
for (const entry of entries) {
|
|
@@ -729,21 +734,27 @@ async function createDbkWorkspaceSnapshot(source, options) {
|
|
|
729
734
|
throw new Error(`The external DBK contains duplicate paths: ${sourcePath}`);
|
|
730
735
|
}
|
|
731
736
|
seenSourcePaths.add(sourcePath);
|
|
732
|
-
|
|
737
|
+
if (!/\.md$/iu.test(sourcePath)) {
|
|
738
|
+
throw new Error(
|
|
739
|
+
`The external DBK is corrupt: only Markdown (.md) files are allowed (${sourcePath}).`
|
|
740
|
+
);
|
|
741
|
+
}
|
|
742
|
+
validatedEntries.push({ sourcePath, containerPath: entry.path });
|
|
743
|
+
}
|
|
744
|
+
for (const entry of validatedEntries) {
|
|
745
|
+
const { sourcePath } = entry;
|
|
746
|
+
const data = await source.readFile(entry.containerPath);
|
|
733
747
|
if (data === null) {
|
|
734
748
|
throw new Error(`The external DBK changed while reading: ${sourcePath}`);
|
|
735
749
|
}
|
|
750
|
+
const content = decodeMarkdownFile(data, sourcePath);
|
|
736
751
|
if (sourcePath === sourceDocumentPath) {
|
|
737
|
-
documentContent =
|
|
752
|
+
documentContent = content;
|
|
738
753
|
files.push({ kind: "text", path: targetDocumentPath, content: documentContent });
|
|
739
754
|
continue;
|
|
740
755
|
}
|
|
741
756
|
const targetPath = assetLayout === "preserve" ? sourcePath : joinPath(companionPath, sourcePath);
|
|
742
|
-
|
|
743
|
-
files.push({ kind: "text", path: targetPath, content: new TextDecoder().decode(data) });
|
|
744
|
-
} else {
|
|
745
|
-
files.push({ kind: "binary", path: targetPath, data });
|
|
746
|
-
}
|
|
757
|
+
files.push({ kind: "text", path: targetPath, content });
|
|
747
758
|
}
|
|
748
759
|
if (documentContent === null) {
|
|
749
760
|
throw new Error(`The external DBK did not include its primary document: ${sourceDocumentPath}`);
|
|
@@ -765,29 +776,6 @@ async function replaceMemoryWorkspaceFromDbk(provider, source, options) {
|
|
|
765
776
|
|
|
766
777
|
// src/filesystem/filesystem-content-container.ts
|
|
767
778
|
import { findDocumentPath } from "@bendyline/squisq/storage";
|
|
768
|
-
var EXTENSION_MIME_MAP = {
|
|
769
|
-
".md": "text/markdown",
|
|
770
|
-
".txt": "text/plain",
|
|
771
|
-
".json": "application/json",
|
|
772
|
-
".jpg": "image/jpeg",
|
|
773
|
-
".jpeg": "image/jpeg",
|
|
774
|
-
".png": "image/png",
|
|
775
|
-
".gif": "image/gif",
|
|
776
|
-
".svg": "image/svg+xml",
|
|
777
|
-
".webp": "image/webp",
|
|
778
|
-
".avif": "image/avif",
|
|
779
|
-
".mp4": "video/mp4",
|
|
780
|
-
".webm": "video/webm",
|
|
781
|
-
".mp3": "audio/mpeg",
|
|
782
|
-
".wav": "audio/wav",
|
|
783
|
-
".ogg": "audio/ogg"
|
|
784
|
-
};
|
|
785
|
-
function guessMimeType(path) {
|
|
786
|
-
const dot = path.lastIndexOf(".");
|
|
787
|
-
if (dot === -1) return "application/octet-stream";
|
|
788
|
-
const ext = path.slice(dot).toLowerCase();
|
|
789
|
-
return EXTENSION_MIME_MAP[ext] ?? "application/octet-stream";
|
|
790
|
-
}
|
|
791
779
|
function joinPrefix(prefix, p) {
|
|
792
780
|
return workspacePathJoin(parseWorkspacePath(prefix), p);
|
|
793
781
|
}
|
|
@@ -954,4 +942,3 @@ export {
|
|
|
954
942
|
FileSystemContentContainer,
|
|
955
943
|
createFileMediaProvider
|
|
956
944
|
};
|
|
957
|
-
//# sourceMappingURL=chunk-5MYAICRE.js.map
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isFileSystemMoveStateError
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-QI6YKTQV.js";
|
|
4
|
+
import {
|
|
5
|
+
decodeUtf8Text
|
|
6
|
+
} from "./chunk-M5ZNQGR5.js";
|
|
4
7
|
import {
|
|
5
8
|
FsError,
|
|
6
9
|
parseWorkspacePath
|
|
7
|
-
} from "./chunk-
|
|
10
|
+
} from "./chunk-AYWKIZLD.js";
|
|
8
11
|
import {
|
|
9
12
|
getFileSystemProviderV2
|
|
10
|
-
} from "./chunk-
|
|
13
|
+
} from "./chunk-XAMILHQP.js";
|
|
11
14
|
|
|
12
15
|
// src/document/document-session.ts
|
|
13
16
|
var DEFAULT_AUTO_SAVE_RETRY_DELAYS_MS = [1e3, 3e3, 1e4];
|
|
@@ -668,7 +671,10 @@ function createFileSystemDocumentTarget(provider, path, options = {}) {
|
|
|
668
671
|
async commit(request) {
|
|
669
672
|
if (providerV2 && providerV2.capabilities.conditionalWrite !== "none") {
|
|
670
673
|
const current = await providerV2.readFile(canonicalPath);
|
|
671
|
-
const currentContent = current ?
|
|
674
|
+
const currentContent = current ? decodeUtf8Text(current.data, {
|
|
675
|
+
label: "The external document",
|
|
676
|
+
path: canonicalPath
|
|
677
|
+
}) : null;
|
|
672
678
|
if (currentContent !== request.persistedContent && currentContent !== request.content) {
|
|
673
679
|
throw new DocumentCommitConflictError(
|
|
674
680
|
"The document changed outside DocBlocks: " + path,
|
|
@@ -697,7 +703,10 @@ function createFileSystemDocumentTarget(provider, path, options = {}) {
|
|
|
697
703
|
const external = await providerV2.readFile(canonicalPath);
|
|
698
704
|
throw new DocumentCommitConflictError(
|
|
699
705
|
"The document changed outside DocBlocks: " + path,
|
|
700
|
-
external ?
|
|
706
|
+
external ? decodeUtf8Text(external.data, {
|
|
707
|
+
label: "The external document",
|
|
708
|
+
path: canonicalPath
|
|
709
|
+
}) : null,
|
|
701
710
|
external?.entry.version ?? null
|
|
702
711
|
);
|
|
703
712
|
}
|
|
@@ -1059,4 +1068,3 @@ export {
|
|
|
1059
1068
|
DocumentRecoveryJournal,
|
|
1060
1069
|
getDefaultDocumentRecoveryStorage
|
|
1061
1070
|
};
|
|
1062
|
-
//# sourceMappingURL=chunk-PGR7LK6D.js.map
|
|
@@ -8,6 +8,7 @@ var FS_ERROR_CODES = /* @__PURE__ */ new Set([
|
|
|
8
8
|
"not-empty",
|
|
9
9
|
"permission-denied",
|
|
10
10
|
"conflict",
|
|
11
|
+
"corrupt",
|
|
11
12
|
"quota-exceeded",
|
|
12
13
|
"not-supported",
|
|
13
14
|
"busy",
|
|
@@ -221,4 +222,3 @@ export {
|
|
|
221
222
|
workspacePathBasename,
|
|
222
223
|
workspacePathContains
|
|
223
224
|
};
|
|
224
|
-
//# sourceMappingURL=chunk-SI2LU2RP.js.map
|