@bendyline/docblocks 1.1.2 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -11
- package/dist/chunk-2D7Y4IR3.js +1293 -0
- package/dist/chunk-2D7Y4IR3.js.map +1 -0
- package/dist/chunk-5MYAICRE.js +957 -0
- package/dist/chunk-5MYAICRE.js.map +1 -0
- package/dist/chunk-75UUF6C4.js +802 -0
- package/dist/chunk-75UUF6C4.js.map +1 -0
- package/dist/chunk-AEHCVWU5.js +25 -0
- package/dist/chunk-AEHCVWU5.js.map +1 -0
- package/dist/chunk-AYZ4HN5M.js +20 -0
- package/dist/chunk-AYZ4HN5M.js.map +1 -0
- package/dist/chunk-EGNDADXB.js +111 -0
- package/dist/chunk-EGNDADXB.js.map +1 -0
- package/dist/chunk-EZKJZUNJ.js +13 -0
- package/dist/chunk-EZKJZUNJ.js.map +1 -0
- package/dist/chunk-FNW556FN.js +75 -0
- package/dist/chunk-FNW556FN.js.map +1 -0
- package/dist/chunk-GCPBEMMH.js +563 -0
- package/dist/chunk-GCPBEMMH.js.map +1 -0
- package/dist/chunk-J32GU3F3.js +1664 -0
- package/dist/chunk-J32GU3F3.js.map +1 -0
- package/dist/chunk-PGR7LK6D.js +1062 -0
- package/dist/chunk-PGR7LK6D.js.map +1 -0
- package/dist/chunk-RQJRQF46.js +787 -0
- package/dist/chunk-RQJRQF46.js.map +1 -0
- package/dist/{chunk-ME76RUMR.js → chunk-RVQHY3XU.js} +15 -1
- package/dist/chunk-RVQHY3XU.js.map +1 -0
- package/dist/chunk-SI2LU2RP.js +224 -0
- package/dist/chunk-SI2LU2RP.js.map +1 -0
- package/dist/chunk-W5UUUII5.js +142 -0
- package/dist/chunk-W5UUUII5.js.map +1 -0
- package/dist/document/document-session.d.ts +127 -0
- package/dist/document/document-session.d.ts.map +1 -0
- package/dist/document/document-session.js +749 -0
- package/dist/document/document-session.js.map +1 -0
- package/dist/document/filesystem-target.d.ts +17 -0
- package/dist/document/filesystem-target.d.ts.map +1 -0
- package/dist/document/filesystem-target.js +70 -0
- package/dist/document/filesystem-target.js.map +1 -0
- package/dist/document/index.d.ts +6 -0
- package/dist/document/index.d.ts.map +1 -0
- package/dist/document/index.js +4 -0
- package/dist/document/index.js.map +1 -0
- package/dist/document/recovery-journal.d.ts +125 -0
- package/dist/document/recovery-journal.d.ts.map +1 -0
- package/dist/document/recovery-journal.js +385 -0
- package/dist/document/recovery-journal.js.map +1 -0
- package/dist/document/types.d.ts +89 -0
- package/dist/document/types.d.ts.map +1 -0
- package/dist/document/types.js +9 -0
- package/dist/document/types.js.map +1 -0
- package/dist/filesystem/commit-lock.d.ts +3 -0
- package/dist/filesystem/commit-lock.d.ts.map +1 -0
- package/dist/filesystem/commit-lock.js +20 -0
- package/dist/filesystem/commit-lock.js.map +1 -0
- package/dist/filesystem/dbk-workspace.d.ts +34 -0
- package/dist/filesystem/dbk-workspace.d.ts.map +1 -0
- package/dist/filesystem/dbk-workspace.js +85 -0
- package/dist/filesystem/dbk-workspace.js.map +1 -0
- package/dist/filesystem/electron-provider-v2.d.ts +36 -0
- package/dist/filesystem/electron-provider-v2.d.ts.map +1 -0
- package/dist/filesystem/electron-provider-v2.js +503 -0
- package/dist/filesystem/electron-provider-v2.js.map +1 -0
- package/dist/filesystem/electron-provider.d.ts +6 -3
- package/dist/filesystem/electron-provider.d.ts.map +1 -1
- package/dist/filesystem/electron-provider.js +18 -13
- package/dist/filesystem/electron-provider.js.map +1 -1
- package/dist/filesystem/electron.d.ts +4 -0
- package/dist/filesystem/electron.d.ts.map +1 -0
- package/dist/filesystem/electron.js +4 -0
- package/dist/filesystem/electron.js.map +1 -0
- package/dist/filesystem/filesystem-content-container.d.ts +1 -1
- package/dist/filesystem/filesystem-content-container.d.ts.map +1 -1
- package/dist/filesystem/filesystem-content-container.js +50 -13
- package/dist/filesystem/filesystem-content-container.js.map +1 -1
- package/dist/filesystem/fs-error.d.ts +46 -0
- package/dist/filesystem/fs-error.d.ts.map +1 -0
- package/dist/filesystem/fs-error.js +170 -0
- package/dist/filesystem/fs-error.js.map +1 -0
- package/dist/filesystem/index.d.ts +15 -1
- package/dist/filesystem/index.d.ts.map +1 -1
- package/dist/filesystem/index.js +13 -0
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/indexeddb-content-container.d.ts +3 -1
- package/dist/filesystem/indexeddb-content-container.d.ts.map +1 -1
- package/dist/filesystem/indexeddb-content-container.js +18 -11
- package/dist/filesystem/indexeddb-content-container.js.map +1 -1
- package/dist/filesystem/indexeddb-provider-v2.d.ts +96 -0
- package/dist/filesystem/indexeddb-provider-v2.d.ts.map +1 -0
- package/dist/filesystem/indexeddb-provider-v2.js +1241 -0
- package/dist/filesystem/indexeddb-provider-v2.js.map +1 -0
- package/dist/filesystem/indexeddb-provider.d.ts +21 -14
- package/dist/filesystem/indexeddb-provider.d.ts.map +1 -1
- package/dist/filesystem/indexeddb-provider.js +111 -261
- package/dist/filesystem/indexeddb-provider.js.map +1 -1
- package/dist/filesystem/indexeddb-store.d.ts +34 -0
- package/dist/filesystem/indexeddb-store.d.ts.map +1 -0
- package/dist/filesystem/indexeddb-store.js +165 -0
- package/dist/filesystem/indexeddb-store.js.map +1 -0
- package/dist/filesystem/indexeddb.d.ts +5 -0
- package/dist/filesystem/indexeddb.d.ts.map +1 -0
- package/dist/filesystem/indexeddb.js +5 -0
- package/dist/filesystem/indexeddb.js.map +1 -0
- package/dist/filesystem/legacy-v2-adapter.d.ts +62 -0
- package/dist/filesystem/legacy-v2-adapter.d.ts.map +1 -0
- package/dist/filesystem/legacy-v2-adapter.js +499 -0
- package/dist/filesystem/legacy-v2-adapter.js.map +1 -0
- package/dist/filesystem/memory-provider-v2.d.ts +92 -0
- package/dist/filesystem/memory-provider-v2.d.ts.map +1 -0
- package/dist/filesystem/memory-provider-v2.js +615 -0
- package/dist/filesystem/memory-provider-v2.js.map +1 -0
- package/dist/filesystem/memory-provider.d.ts +54 -0
- package/dist/filesystem/memory-provider.d.ts.map +1 -0
- package/dist/filesystem/memory-provider.js +132 -0
- package/dist/filesystem/memory-provider.js.map +1 -0
- package/dist/filesystem/memory.d.ts +4 -0
- package/dist/filesystem/memory.d.ts.map +1 -0
- package/dist/filesystem/memory.js +4 -0
- package/dist/filesystem/memory.js.map +1 -0
- package/dist/filesystem/move-entry.d.ts +9 -0
- package/dist/filesystem/move-entry.d.ts.map +1 -0
- package/dist/filesystem/move-entry.js +103 -0
- package/dist/filesystem/move-entry.js.map +1 -0
- package/dist/filesystem/move-error.d.ts +53 -0
- package/dist/filesystem/move-error.d.ts.map +1 -0
- package/dist/filesystem/move-error.js +99 -0
- package/dist/filesystem/move-error.js.map +1 -0
- package/dist/filesystem/native-provider-v2.d.ts +75 -0
- package/dist/filesystem/native-provider-v2.d.ts.map +1 -0
- package/dist/filesystem/native-provider-v2.js +849 -0
- package/dist/filesystem/native-provider-v2.js.map +1 -0
- package/dist/filesystem/native-provider.d.ts +9 -1
- package/dist/filesystem/native-provider.d.ts.map +1 -1
- package/dist/filesystem/native-provider.js +172 -37
- package/dist/filesystem/native-provider.js.map +1 -1
- package/dist/filesystem/native.d.ts +4 -0
- package/dist/filesystem/native.d.ts.map +1 -0
- package/dist/filesystem/native.js +4 -0
- package/dist/filesystem/native.js.map +1 -0
- package/dist/filesystem/types.d.ts +37 -4
- package/dist/filesystem/types.d.ts.map +1 -1
- package/dist/filesystem/types.js +11 -3
- package/dist/filesystem/types.js.map +1 -1
- package/dist/filesystem/v2.d.ts +172 -0
- package/dist/filesystem/v2.d.ts.map +1 -0
- package/dist/filesystem/v2.js +16 -0
- package/dist/filesystem/v2.js.map +1 -0
- package/dist/filesystem/workspace-path.d.ts +21 -0
- package/dist/filesystem/workspace-path.d.ts.map +1 -0
- package/dist/filesystem/workspace-path.js +80 -0
- package/dist/filesystem/workspace-path.js.map +1 -0
- package/dist/host/filesystem-v2.d.ts +45 -0
- package/dist/host/filesystem-v2.d.ts.map +1 -0
- package/dist/host/filesystem-v2.js +13 -0
- package/dist/host/filesystem-v2.js.map +1 -0
- package/dist/host/git.d.ts +200 -0
- package/dist/host/git.d.ts.map +1 -0
- package/dist/host/git.js +15 -0
- package/dist/host/git.js.map +1 -0
- package/dist/host/index.d.ts +4 -1
- package/dist/host/index.d.ts.map +1 -1
- package/dist/host/index.js +2 -0
- package/dist/host/index.js.map +1 -1
- package/dist/host/types.d.ts +114 -31
- package/dist/host/types.d.ts.map +1 -1
- package/dist/host/wire-policy.d.ts +22 -0
- package/dist/host/wire-policy.d.ts.map +1 -0
- package/dist/host/wire-policy.js +92 -0
- package/dist/host/wire-policy.js.map +1 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -1
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +4 -0
- package/dist/mcp/index.d.ts.map +1 -0
- package/dist/mcp/index.js +4 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/types.d.ts +466 -0
- package/dist/mcp/types.d.ts.map +1 -0
- package/dist/mcp/types.js +25 -0
- package/dist/mcp/types.js.map +1 -0
- package/dist/mcp/wire.d.ts +29 -0
- package/dist/mcp/wire.d.ts.map +1 -0
- package/dist/mcp/wire.js +1046 -0
- package/dist/mcp/wire.js.map +1 -0
- package/dist/mcp/zod.d.ts +5763 -0
- package/dist/mcp/zod.d.ts.map +1 -0
- package/dist/mcp/zod.js +908 -0
- package/dist/mcp/zod.js.map +1 -0
- package/dist/types-CX893hgH.d.ts +468 -0
- package/dist/types-CsX6EN2t.d.ts +301 -0
- package/dist/types-eOlt9J7n.d.ts +478 -0
- package/dist/vscode/index.d.ts +3 -0
- package/dist/vscode/index.d.ts.map +1 -0
- package/dist/vscode/index.js +3 -0
- package/dist/vscode/index.js.map +1 -0
- package/dist/vscode/messages.d.ts +204 -0
- package/dist/vscode/messages.d.ts.map +1 -0
- package/dist/vscode/messages.js +494 -0
- package/dist/vscode/messages.js.map +1 -0
- package/dist/workspace/index.d.ts +3 -2
- package/dist/workspace/index.d.ts.map +1 -1
- package/dist/workspace/index.js +2 -1
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace/reconcile-electron.d.ts +19 -0
- package/dist/workspace/reconcile-electron.d.ts.map +1 -0
- package/dist/workspace/reconcile-electron.js +42 -0
- package/dist/workspace/reconcile-electron.js.map +1 -0
- package/dist/workspace/types.d.ts +41 -1
- package/dist/workspace/types.d.ts.map +1 -1
- package/dist/workspace/types.js +0 -4
- package/dist/workspace/types.js.map +1 -1
- package/dist/workspace/workspace-manager.d.ts +17 -5
- package/dist/workspace/workspace-manager.d.ts.map +1 -1
- package/dist/workspace/workspace-manager.js +55 -11
- package/dist/workspace/workspace-manager.js.map +1 -1
- package/dist/workspace-path-CWVrcuPL.d.ts +21 -0
- package/package.json +43 -2
- package/src/document/document-session.ts +834 -0
- package/src/document/filesystem-target.ts +109 -0
- package/src/document/index.ts +41 -0
- package/src/document/recovery-journal.ts +536 -0
- package/src/document/types.ts +116 -0
- package/src/filesystem/commit-lock.ts +29 -0
- package/src/filesystem/dbk-workspace.ts +135 -0
- package/src/filesystem/electron-provider-v2.ts +630 -0
- package/src/filesystem/electron-provider.ts +25 -14
- package/src/filesystem/electron.ts +3 -0
- package/src/filesystem/filesystem-content-container.ts +53 -15
- package/src/filesystem/fs-error.ts +234 -0
- package/src/filesystem/index.ts +119 -0
- package/src/filesystem/indexeddb-content-container.ts +20 -12
- package/src/filesystem/indexeddb-provider-v2.ts +1740 -0
- package/src/filesystem/indexeddb-provider.ts +126 -300
- package/src/filesystem/indexeddb-store.ts +207 -0
- package/src/filesystem/indexeddb.ts +12 -0
- package/src/filesystem/legacy-v2-adapter.ts +779 -0
- package/src/filesystem/memory-provider-v2.ts +896 -0
- package/src/filesystem/memory-provider.ts +180 -0
- package/src/filesystem/memory.ts +15 -0
- package/src/filesystem/move-entry.ts +142 -0
- package/src/filesystem/move-error.ts +159 -0
- package/src/filesystem/native-provider-v2.ts +1165 -0
- package/src/filesystem/native-provider.ts +194 -41
- package/src/filesystem/native.ts +16 -0
- package/src/filesystem/types.ts +49 -4
- package/src/filesystem/v2.ts +231 -0
- package/src/filesystem/workspace-path.ts +92 -0
- package/src/host/filesystem-v2.ts +104 -0
- package/src/host/git.ts +246 -0
- package/src/host/index.ts +46 -0
- package/src/host/types.ts +155 -34
- package/src/host/wire-policy.ts +103 -0
- package/src/index.ts +2 -1
- package/src/mcp/index.ts +3 -0
- package/src/mcp/types.ts +594 -0
- package/src/mcp/wire.ts +1280 -0
- package/src/mcp/zod.ts +1000 -0
- package/src/vscode/index.ts +2 -0
- package/src/vscode/messages.ts +704 -0
- package/src/workspace/index.ts +8 -1
- package/src/workspace/reconcile-electron.ts +65 -0
- package/src/workspace/types.ts +39 -1
- package/src/workspace/workspace-manager.ts +71 -10
- package/dist/chunk-GUNM43XZ.js +0 -63
- package/dist/chunk-GUNM43XZ.js.map +0 -1
- package/dist/chunk-IM7LCQJ6.js +0 -850
- package/dist/chunk-IM7LCQJ6.js.map +0 -1
- package/dist/chunk-ME76RUMR.js.map +0 -1
- package/dist/index-pgBHBQ9G.d.ts +0 -213
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/filesystem/legacy-v2-adapter.ts","../src/filesystem/move-entry.ts","../src/filesystem/dbk-workspace.ts","../src/filesystem/filesystem-content-container.ts","../src/filesystem/file-media-provider.ts"],"sourcesContent":["import { FsError, fsErrorFromUnknown, type FsOperation } from './fs-error.js';\nimport type { FileSystemEntry, FileSystemProvider } from './types.js';\nimport {\n parseFileSystemVersion,\n type FileSystemAtomicity,\n type FileSystemCaseSensitivity,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\n type FileSystemDurability,\n type FileSystemEntrySnapshot,\n type FileSystemFileRead,\n type FileSystemFileSnapshot,\n type FileSystemMoveOptions,\n type FileSystemProviderCapabilities,\n type FileSystemProviderV2,\n type FileSystemRemoveOptions,\n type FileSystemRemoveResult,\n type FileSystemSnapshot,\n type FileSystemSnapshotEntry,\n type FileSystemSnapshotFile,\n type FileSystemSymlinkPolicy,\n type FileSystemVersion,\n type FileSystemWatchListener,\n type FileSystemWatchOptions,\n type FileSystemWatchSubscription,\n type FileSystemWriteOptions,\n} from './v2.js';\nimport {\n WORKSPACE_ROOT,\n parseWorkspacePath,\n workspacePathBasename,\n workspacePathContains,\n workspacePathDirname,\n workspacePathToLegacy,\n type WorkspacePath,\n} from './workspace-path.js';\n\nexport type LegacyFilePayloadModel =\n | 'split'\n | 'binary-first-text-fallback'\n | 'binary-authoritative';\n\nexport interface LegacyFileSystemProviderV2AdapterOptions {\n /**\n * Split stores expose independent raw text and binary channels and reject\n * dual payloads. Binary-first stores synthesize text for binary records, so\n * the adapter only asks for text after readBinary() returns null. Binary-\n * authoritative stores expose every file through readBinary().\n */\n readonly payloadModel: LegacyFilePayloadModel;\n readonly writeAtomicity?: FileSystemAtomicity;\n readonly moveAtomicity?: FileSystemAtomicity;\n readonly caseSensitivity?: FileSystemCaseSensitivity;\n readonly symlinkPolicy?: FileSystemSymlinkPolicy;\n readonly durability?: FileSystemDurability;\n /** Optional ownership hook; omitted when the adapter does not own the v1 provider. */\n readonly dispose?: () => void | Promise<void>;\n}\n\ninterface CapturedTree {\n readonly entries: ReadonlyMap<WorkspacePath, FileSystemSnapshotEntry>;\n readonly version: FileSystemVersion;\n}\n\nconst EPOCH = new Date(0).toISOString();\n\n/**\n * Correctness bridge for hardened v1 providers while storage backends migrate.\n *\n * The adapter deliberately serializes every observable operation. This makes a\n * version check and its mutation indivisible among v2 callers, but cannot make\n * calls that bypass the adapter participate in that boundary. Content-derived\n * versions make those external changes visible on the next adapter operation.\n */\nexport class LegacyFileSystemProviderV2Adapter implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities: FileSystemProviderCapabilities;\n\n private operationTail: Promise<void> = Promise.resolve();\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private closing = false;\n private disposed = false;\n private disposePromise: Promise<void> | null = null;\n\n public constructor(\n private readonly provider: FileSystemProvider,\n private readonly options: LegacyFileSystemProviderV2AdapterOptions,\n ) {\n this.id = provider.id;\n this.label = provider.label;\n this.capabilities = Object.freeze({\n writeAtomicity: options.writeAtomicity ?? 'none',\n moveAtomicity: options.moveAtomicity ?? 'none',\n // A tree snapshot spans multiple v1 calls; callers that bypass this\n // adapter can still interleave, even though adapter operations serialize.\n snapshotAtomicity: 'none',\n conditionalWrite: 'process',\n recursiveRemove: true,\n watch: false,\n caseSensitivity: options.caseSensitivity ?? 'platform',\n symlinkPolicy: options.symlinkPolicy ?? 'unsupported',\n durability: options.durability ?? 'best-effort',\n });\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = this.canonical(path);\n return this.enqueue('stat', async () => {\n const entry = (await this.captureTree('stat')).entries.get(canonical);\n return entry ? copyEntrySnapshot(entry) : null;\n });\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = this.canonical(path);\n return this.enqueue('read', async () => {\n const entry = (await this.captureTree('read')).entries.get(canonical);\n if (!entry) return null;\n if (entry.kind !== 'file') {\n throw this.error('type-mismatch', 'read', canonical, 'Expected a file, found a directory.');\n }\n return Object.freeze({ entry: fileMetadata(entry), data: entry.data.slice(0) });\n });\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = this.canonical(path);\n return this.enqueue('list', async () => {\n const tree = await this.captureTree('list');\n const entry = tree.entries.get(canonical);\n if (!entry) throw this.error('not-found', 'list', canonical, 'Directory does not exist.');\n if (entry.kind !== 'directory') {\n throw this.error('type-mismatch', 'list', canonical, 'Expected a directory, found a file.');\n }\n const children = [...tree.entries.entries()]\n .filter(([entryPath]) => entryPath && workspacePathDirname(entryPath) === canonical)\n .map(([, child]) => copyEntrySnapshot(child))\n .sort(compareSnapshots);\n return Object.freeze(children);\n });\n }\n\n public async writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options: FileSystemWriteOptions = {},\n ): Promise<FileSystemFileSnapshot> {\n const canonical = this.canonicalNonRoot(path, 'write');\n const ownedData = copyBytes(data);\n return this.enqueue('write', async () => {\n const tree = await this.captureTree('write');\n const existing = tree.entries.get(canonical);\n if (existing?.kind === 'directory') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Cannot replace a directory with a file.',\n );\n }\n\n const mode = options.mode ?? 'upsert';\n if (mode === 'create' && existing) {\n throw this.error('already-exists', 'write', canonical, 'File already exists.');\n }\n if (mode === 'replace' && !existing) {\n throw this.error('not-found', 'write', canonical, 'File does not exist.');\n }\n this.assertExpectedVersion(existing, options.expectedVersion, 'write', canonical);\n this.assertParents(tree, canonical, options.createParents ?? false, 'write');\n\n await this.invoke(\n () => this.provider.writeBinary(workspacePathToLegacy(canonical), ownedData),\n 'write',\n canonical,\n );\n const written = (await this.captureTree('write')).entries.get(canonical);\n if (written?.kind !== 'file' || !equalBytes(written.data, ownedData)) {\n throw this.error(\n 'io',\n 'write',\n canonical,\n 'The legacy provider did not persist the requested bytes.',\n );\n }\n return fileMetadata(written);\n });\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options: FileSystemCreateDirectoryOptions = {},\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = this.canonical(path);\n return this.enqueue('create-directory', async () => {\n const tree = await this.captureTree('create-directory');\n const existing = tree.entries.get(canonical);\n if (existing) {\n if (existing.kind !== 'directory') {\n throw this.error(\n 'type-mismatch',\n 'create-directory',\n canonical,\n 'Cannot replace a file with a directory.',\n );\n }\n if ((options.mode ?? 'ensure') === 'create') {\n throw this.error(\n 'already-exists',\n 'create-directory',\n canonical,\n 'Directory already exists.',\n );\n }\n return copyDirectorySnapshot(existing);\n }\n\n this.assertParents(tree, canonical, options.createParents ?? false, 'create-directory');\n await this.invoke(\n () => this.provider.createDirectory(workspacePathToLegacy(canonical)),\n 'create-directory',\n canonical,\n );\n const created = (await this.captureTree('create-directory')).entries.get(canonical);\n if (created?.kind !== 'directory') {\n throw this.error(\n 'io',\n 'create-directory',\n canonical,\n 'The legacy provider did not create the directory.',\n );\n }\n return copyDirectorySnapshot(created);\n });\n }\n\n public async remove(\n path: WorkspacePath,\n options: FileSystemRemoveOptions = {},\n ): Promise<FileSystemRemoveResult> {\n const canonical = this.canonicalNonRoot(path, 'remove');\n return this.enqueue('remove', async () => {\n const tree = await this.captureTree('remove');\n const existing = tree.entries.get(canonical);\n if (!existing) {\n if ((options.missing ?? 'error') === 'ignore') {\n return Object.freeze({ removed: false, version: tree.version });\n }\n throw this.error('not-found', 'remove', canonical, 'Entry does not exist.');\n }\n this.assertExpectedVersion(existing, options.expectedVersion, 'remove', canonical);\n if (\n existing.kind === 'directory' &&\n !options.recursive &&\n [...tree.entries.keys()].some((candidate) =>\n workspacePathContains(canonical, candidate, false),\n )\n ) {\n throw this.error('not-empty', 'remove', canonical, 'Directory is not empty.');\n }\n\n await this.invoke(\n () => this.provider.delete(workspacePathToLegacy(canonical)),\n 'remove',\n canonical,\n );\n const after = await this.captureTree('remove');\n if (\n [...after.entries.keys()].some((candidate) => workspacePathContains(canonical, candidate))\n ) {\n throw this.error(\n 'io',\n 'remove',\n canonical,\n 'The legacy provider did not remove the complete entry.',\n );\n }\n return Object.freeze({ removed: true, version: after.version });\n });\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options: FileSystemMoveOptions = {},\n ): Promise<FileSystemEntrySnapshot> {\n const sourcePath = this.canonicalNonRoot(oldPath, 'move');\n const destinationPath = this.canonicalNonRoot(newPath, 'move');\n return this.enqueue('move', async () => {\n const tree = await this.captureTree('move');\n const source = tree.entries.get(sourcePath);\n if (!source) throw this.error('not-found', 'move', sourcePath, 'Source does not exist.');\n this.assertExpectedVersion(source, options.expectedVersion, 'move', sourcePath);\n if (sourcePath === destinationPath) return copyEntrySnapshot(source);\n if (tree.entries.has(destinationPath)) {\n throw new FsError('already-exists', 'Destination already exists.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n if (\n source.kind === 'directory' &&\n workspacePathContains(sourcePath, destinationPath, false)\n ) {\n throw new FsError('invalid-path', 'Cannot move a directory into itself.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n this.assertParents(tree, destinationPath, options.createParents ?? false, 'move');\n\n const sourceEntries = [...tree.entries.entries()].filter(([candidate]) =>\n workspacePathContains(sourcePath, candidate),\n );\n await this.invoke(\n () =>\n this.provider.rename(\n workspacePathToLegacy(sourcePath),\n workspacePathToLegacy(destinationPath),\n ),\n 'move',\n sourcePath,\n destinationPath,\n );\n\n const after = await this.captureTree('move');\n if (\n [...after.entries.keys()].some((candidate) => workspacePathContains(sourcePath, candidate))\n ) {\n throw this.error(\n 'io',\n 'move',\n sourcePath,\n 'The legacy provider left source entries behind.',\n );\n }\n for (const [oldEntryPath, oldEntry] of sourceEntries) {\n const suffix = oldEntryPath.slice(sourcePath.length);\n const movedPath = parseWorkspacePath(`${destinationPath}${suffix}`);\n const moved = after.entries.get(movedPath);\n if (!moved || moved.kind !== oldEntry.kind || moved.version !== oldEntry.version) {\n throw new FsError(\n 'io',\n 'The legacy provider did not move the complete entry unchanged.',\n {\n operation: 'move',\n path: oldEntryPath,\n destinationPath: movedPath,\n },\n );\n }\n }\n return copyEntrySnapshot(after.entries.get(destinationPath)!);\n });\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.enqueue('snapshot', async () => {\n const tree = await this.captureTree('snapshot');\n const entries = [...tree.entries.values()]\n .sort((left, right) => compareText(left.path, right.path))\n .map((entry) => copySnapshotEntry(entry));\n return Object.freeze({ version: tree.version, entries: Object.freeze(entries) });\n });\n }\n\n public watch(\n _listener: FileSystemWatchListener,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertAccepting('watch');\n const error = new FsError(\n 'not-supported',\n 'The legacy adapter cannot observe external changes.',\n {\n operation: 'watch',\n },\n );\n let closed = false;\n let disposePromise: Promise<void> | null = null;\n const ready = Promise.reject(error);\n void ready.catch((caught: FsError) => {\n try {\n options.onError?.(caught);\n } catch {\n // An observational error callback cannot change subscription state.\n }\n });\n const subscription: FileSystemWatchSubscription = {\n get closed() {\n return closed;\n },\n ready,\n dispose: () => {\n if (disposePromise) return disposePromise;\n closed = true;\n this.subscriptions.delete(subscription);\n disposePromise = Promise.resolve();\n return disposePromise;\n },\n };\n this.subscriptions.add(subscription);\n return subscription;\n }\n\n public dispose(): Promise<void> {\n if (this.disposePromise) return this.disposePromise;\n this.closing = true;\n const run = this.operationTail.then(async () => {\n try {\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n await this.options.dispose?.();\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation: 'dispose' });\n } finally {\n this.disposed = true;\n }\n });\n this.operationTail = run.then(\n () => undefined,\n () => undefined,\n );\n this.disposePromise = run;\n return run;\n }\n\n private enqueue<T>(operation: FsOperation, task: () => Promise<T>): Promise<T> {\n this.assertAccepting(operation);\n const run = this.operationTail.then(task);\n this.operationTail = run.then(\n () => undefined,\n () => undefined,\n );\n return run;\n }\n\n private assertAccepting(operation: FsOperation): void {\n if (!this.closing && !this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n\n private canonical(path: WorkspacePath): WorkspacePath {\n return parseWorkspacePath(path);\n }\n\n private canonicalNonRoot(path: WorkspacePath, operation: FsOperation): WorkspacePath {\n const canonical = this.canonical(path);\n if (!canonical) {\n throw this.error(\n 'invalid-path',\n operation,\n canonical,\n 'The workspace root is not an entry target.',\n );\n }\n return canonical;\n }\n\n private assertExpectedVersion(\n entry: FileSystemSnapshotEntry | undefined,\n expected: FileSystemVersion | null | undefined,\n operation: FsOperation,\n path: WorkspacePath,\n ): void {\n if (expected === undefined) return;\n if (expected === null ? !entry : entry?.version === expected) return;\n throw this.error(\n 'conflict',\n operation,\n path,\n 'Entry version does not match the expected version.',\n );\n }\n\n private assertParents(\n tree: CapturedTree,\n path: WorkspacePath,\n createParents: boolean,\n operation: FsOperation,\n ): void {\n let parent = workspacePathDirname(path);\n const parents: WorkspacePath[] = [];\n while (parent) {\n parents.unshift(parent);\n parent = workspacePathDirname(parent);\n }\n for (const candidate of parents) {\n const entry = tree.entries.get(candidate);\n if (entry?.kind === 'file') {\n throw this.error('type-mismatch', operation, candidate, 'A parent path is a file.');\n }\n if (!entry && !createParents) {\n throw this.error('not-found', operation, candidate, 'Parent directory does not exist.');\n }\n }\n }\n\n private async captureTree(operation: FsOperation): Promise<CapturedTree> {\n const entries = new Map<WorkspacePath, FileSystemSnapshotEntry>();\n const visiting = new Set<WorkspacePath>();\n\n const visitDirectory = async (path: WorkspacePath): Promise<FileSystemDirectorySnapshot> => {\n if (visiting.has(path)) {\n throw this.error('io', operation, path, 'The legacy provider returned a directory cycle.');\n }\n visiting.add(path);\n const listed = await this.invoke(\n () => this.provider.readDirectory(workspacePathToLegacy(path)),\n operation,\n path,\n );\n if (!Array.isArray(listed)) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned an invalid directory listing.',\n );\n }\n const children: FileSystemSnapshotEntry[] = [];\n const seen = new Set<WorkspacePath>();\n for (const candidate of listed as readonly unknown[]) {\n if (!isLegacyEntry(candidate)) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned an invalid directory entry.',\n );\n }\n const legacyEntry = candidate;\n const childPath = parseWorkspacePath(legacyEntry.path);\n if (\n !childPath ||\n workspacePathDirname(childPath) !== path ||\n workspacePathBasename(childPath) !== legacyEntry.name\n ) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned a non-child entry.',\n );\n }\n if (seen.has(childPath) || entries.has(childPath)) {\n throw this.error(\n 'io',\n operation,\n childPath,\n 'The legacy provider returned duplicate entry paths.',\n );\n }\n seen.add(childPath);\n\n if (legacyEntry.kind === 'directory') {\n children.push(await visitDirectory(childPath));\n } else {\n const file = await this.captureFile(childPath, operation);\n entries.set(childPath, file);\n children.push(file);\n }\n }\n children.sort(compareSnapshots);\n const version = await contentVersion(\n 'directory',\n new TextEncoder().encode(\n children\n .map((child) => `${child.kind}\\0${child.name.length}:${child.name}\\0${child.version}`)\n .join('\\n'),\n ),\n operation,\n path,\n );\n const directory = Object.freeze({\n kind: 'directory' as const,\n path,\n name: workspacePathBasename(path),\n size: null,\n version,\n lastModified: newestLastModified(children),\n });\n entries.set(path, directory);\n visiting.delete(path);\n return directory;\n };\n\n const root = await visitDirectory(WORKSPACE_ROOT);\n return { entries, version: root.version };\n }\n\n private async captureFile(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<FileSystemSnapshotFile> {\n const legacyPath = workspacePathToLegacy(path);\n let data: ArrayBuffer | null;\n if (this.options.payloadModel === 'binary-authoritative') {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n data = binary ? binary.slice(0) : null;\n } else if (this.options.payloadModel === 'binary-first-text-fallback') {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n if (binary) {\n data = binary.slice(0);\n } else {\n const text = await this.invoke(() => this.provider.readFile(legacyPath), operation, path);\n data = text === null ? null : new TextEncoder().encode(text).buffer;\n }\n } else {\n const binary = await this.invoke(() => this.provider.readBinary(legacyPath), operation, path);\n const text = await this.invoke(() => this.provider.readFile(legacyPath), operation, path);\n if (binary !== null && text !== null) {\n throw this.error(\n 'conflict',\n operation,\n path,\n 'The split legacy store contains both text and binary payloads.',\n );\n }\n data = binary\n ? binary.slice(0)\n : text === null\n ? null\n : new TextEncoder().encode(text).buffer;\n }\n if (!data) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider listed a file without a payload.',\n );\n }\n\n const meta = await this.invoke(() => this.provider.stat(legacyPath), operation, path);\n if (\n !meta ||\n parseWorkspacePath(meta.path) !== path ||\n meta.name !== workspacePathBasename(path) ||\n meta.size !== data.byteLength ||\n !Number.isFinite(Date.parse(meta.lastModified))\n ) {\n throw this.error(\n 'io',\n operation,\n path,\n 'The legacy provider returned inconsistent file metadata.',\n );\n }\n return Object.freeze({\n kind: 'file' as const,\n path,\n name: workspacePathBasename(path),\n size: data.byteLength,\n version: await contentVersion('file', new Uint8Array(data), operation, path),\n lastModified: meta.lastModified,\n data,\n });\n }\n\n private async invoke<T>(\n task: () => Promise<T>,\n operation: FsOperation,\n path?: WorkspacePath,\n destinationPath?: WorkspacePath,\n ): Promise<T> {\n try {\n return await task();\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path, destinationPath });\n }\n }\n\n private error(\n code: ConstructorParameters<typeof FsError>[0],\n operation: FsOperation,\n path: WorkspacePath,\n message: string,\n ): FsError {\n return new FsError(code, message, { operation, path });\n }\n}\n\nasync function contentVersion(\n kind: 'file' | 'directory',\n data: Uint8Array,\n operation: FsOperation,\n path: WorkspacePath,\n): Promise<FileSystemVersion> {\n const prefix = new TextEncoder().encode(`${kind}\\0`);\n const input = new Uint8Array(prefix.byteLength + data.byteLength);\n input.set(prefix);\n input.set(data, prefix.byteLength);\n let digest: ArrayBuffer;\n try {\n digest = await globalThis.crypto.subtle.digest('SHA-256', input.buffer as ArrayBuffer);\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path, defaultCode: 'not-supported' });\n }\n const hex = [...new Uint8Array(digest)]\n .map((value) => value.toString(16).padStart(2, '0'))\n .join('');\n return parseFileSystemVersion(`sha256:${hex}`);\n}\n\nfunction isLegacyEntry(value: unknown): value is FileSystemEntry {\n if (!value || typeof value !== 'object') return false;\n const candidate = value as Partial<Record<keyof FileSystemEntry, unknown>>;\n return (\n (candidate.kind === 'file' || candidate.kind === 'directory') &&\n typeof candidate.name === 'string' &&\n typeof candidate.path === 'string'\n );\n}\n\nfunction copyBytes(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n const source = ArrayBuffer.isView(data)\n ? new Uint8Array(data.buffer, data.byteOffset, data.byteLength)\n : new Uint8Array(data);\n const copy = new Uint8Array(source.byteLength);\n copy.set(source);\n return copy.buffer as ArrayBuffer;\n}\n\nfunction equalBytes(left: ArrayBuffer, right: ArrayBuffer): boolean {\n const leftBytes = new Uint8Array(left);\n const rightBytes = new Uint8Array(right);\n return (\n leftBytes.byteLength === rightBytes.byteLength &&\n leftBytes.every((value, index) => value === rightBytes[index])\n );\n}\n\nfunction fileMetadata(file: FileSystemSnapshotFile): FileSystemFileSnapshot {\n return Object.freeze({\n kind: 'file',\n path: file.path,\n name: file.name,\n size: file.size,\n version: file.version,\n lastModified: file.lastModified,\n });\n}\n\nfunction copyDirectorySnapshot(\n directory: FileSystemDirectorySnapshot,\n): FileSystemDirectorySnapshot {\n return Object.freeze({ ...directory });\n}\n\nfunction copyEntrySnapshot(entry: FileSystemSnapshotEntry): FileSystemEntrySnapshot {\n return entry.kind === 'file' ? fileMetadata(entry) : copyDirectorySnapshot(entry);\n}\n\nfunction copySnapshotEntry(entry: FileSystemSnapshotEntry): FileSystemSnapshotEntry {\n return entry.kind === 'file'\n ? Object.freeze({ ...fileMetadata(entry), data: entry.data.slice(0) })\n : copyDirectorySnapshot(entry);\n}\n\nfunction newestLastModified(children: readonly FileSystemSnapshotEntry[]): string {\n let newest = 0;\n for (const child of children) {\n const timestamp = Date.parse(child.lastModified);\n if (Number.isFinite(timestamp)) newest = Math.max(newest, timestamp);\n }\n return newest ? new Date(newest).toISOString() : EPOCH;\n}\n\nfunction compareSnapshots(left: FileSystemEntrySnapshot, right: FileSystemEntrySnapshot): number {\n if (left.kind !== right.kind) return left.kind === 'directory' ? -1 : 1;\n return compareText(left.name, right.name);\n}\n\nfunction compareText(left: string, right: string): number {\n return left < right ? -1 : left > right ? 1 : 0;\n}\n","import { getFileSystemProviderV2, type FileSystemProvider } from './types.js';\nimport {\n describeEntryMove,\n describePartialMove,\n FileSystemMoveRecoveryError,\n FileSystemPartialMoveError,\n} from './move-error.js';\nimport { parseWorkspacePath } from './workspace-path.js';\n\nfunction normalisePath(path: string): string {\n return parseWorkspacePath(path);\n}\n\nfunction dirname(path: string): string {\n const slash = path.lastIndexOf('/');\n return slash < 0 ? '' : path.slice(0, slash);\n}\n\nfunction basename(path: string): string {\n const slash = path.lastIndexOf('/');\n return slash < 0 ? path : path.slice(slash + 1);\n}\n\n/** Return the hidden companion directory used for a document's media and versions. */\nexport function documentCompanionPath(documentPath: string): string {\n const rooted = documentPath.replace(/\\\\/g, '/').startsWith('/');\n const clean = parseWorkspacePath(documentPath);\n if (!clean) throw new Error('The workspace root has no document companion path.');\n const parent = dirname(clean);\n const name = basename(clean).replace(/\\.[^.]+$/, '');\n if (parent) return `${parent}/${name}_files`;\n return rooted ? `/${name}_files` : `${name}_files`;\n}\n\nfunction isMarkdownPath(path: string): boolean {\n return /\\.md$/i.test(basename(path));\n}\n\n/**\n * Move an explorer entry without overwriting an existing entry. Markdown files\n * carry their hidden `<basename>_files` companion directory with them.\n */\nexport async function moveFileSystemEntry(\n provider: FileSystemProvider,\n oldPath: string,\n newPath: string,\n kind: 'file' | 'directory',\n): Promise<void> {\n const providerV2 = getFileSystemProviderV2(provider);\n const exists = (candidate: string): Promise<boolean> =>\n providerV2\n ? providerV2.stat(parseWorkspacePath(candidate)).then((entry) => entry !== null)\n : provider.exists(candidate);\n const move = (source: string, destination: string): Promise<void> =>\n providerV2\n ? providerV2\n .move(parseWorkspacePath(source), parseWorkspacePath(destination), {\n createParents: true,\n })\n .then(() => undefined)\n : provider.rename(source, destination);\n\n const oldNormalised = normalisePath(oldPath);\n const newNormalised = normalisePath(newPath);\n if (oldNormalised === newNormalised) return;\n\n if (kind === 'directory' && newNormalised.startsWith(`${oldNormalised}/`)) {\n throw new Error('A folder cannot be moved into itself.');\n }\n if (await exists(newPath)) {\n throw new Error(`An entry named \"${basename(newPath)}\" already exists there.`);\n }\n\n let oldCompanion: string | null = null;\n let newCompanion: string | null = null;\n if (kind === 'file' && isMarkdownPath(oldPath)) {\n const candidate = documentCompanionPath(oldPath);\n if (await exists(candidate)) {\n oldCompanion = candidate;\n newCompanion = documentCompanionPath(newPath);\n if (\n normalisePath(oldCompanion) !== normalisePath(newCompanion) &&\n (await exists(newCompanion))\n ) {\n throw new Error(`The companion folder \"${basename(newCompanion)}\" already exists there.`);\n }\n }\n }\n\n try {\n await move(oldPath, newPath);\n } catch (error: unknown) {\n const state = await describeEntryMove(provider, oldPath, newPath);\n if (state.source === 'present' && state.destination === 'missing') throw error;\n throw new FileSystemMoveRecoveryError(oldPath, newPath, state, error);\n }\n if (!oldCompanion || !newCompanion) return;\n\n try {\n await move(oldCompanion, newCompanion);\n } catch (error: unknown) {\n // Keep the document and its assets together when the second half fails.\n try {\n await move(newPath, oldPath);\n } catch (rollbackError: unknown) {\n const state = await describePartialMove(\n provider,\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n );\n throw new FileSystemPartialMoveError(\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n state,\n error,\n rollbackError,\n );\n }\n const state = await describePartialMove(provider, oldPath, newPath, oldCompanion, newCompanion);\n const restoredSourceOnly =\n state.source === 'present' &&\n state.destination === 'missing' &&\n state.companionSource === 'present' &&\n state.companionDestination === 'missing';\n if (!restoredSourceOnly) {\n throw new FileSystemPartialMoveError(\n oldPath,\n newPath,\n oldCompanion,\n newCompanion,\n state,\n error,\n null,\n );\n }\n throw error;\n }\n}\n","import type { ContentContainer } from '@bendyline/squisq/storage';\nimport { documentCompanionPath } from './move-entry.js';\nimport type {\n MemoryFileSystemProvider,\n MemoryFileSystemSnapshot,\n MemoryFileSystemSnapshotFile,\n} from './memory-provider.js';\n\nexport type DbkWorkspaceAssetLayout = 'auto' | 'preserve' | 'companion';\n\nexport interface DbkWorkspaceSnapshotOptions {\n /** Provider-relative path of the transient workspace's active markdown file. */\n targetDocumentPath: string;\n /**\n * `preserve` treats the DBK as a serialized workspace tree. `companion`\n * rebases non-document files beneath `<document>_files/`. `auto` preserves\n * a DBK whose primary path already matches the target, otherwise rebasing\n * imported media into the companion directory.\n */\n assetLayout?: DbkWorkspaceAssetLayout;\n}\n\nexport interface DbkWorkspaceSnapshot extends MemoryFileSystemSnapshot {\n readonly sourceDocumentPath: string;\n readonly targetDocumentPath: string;\n readonly documentContent: string;\n readonly assetLayout: Exclude<DbkWorkspaceAssetLayout, 'auto'>;\n}\n\nfunction normaliseRelativePath(path: string, label: string): string {\n if (path.includes('\\\\') || path.includes('\\0')) {\n throw new Error(`DBK ${label} must use a safe forward-slash path: ${path}`);\n }\n const normalized = path.replace(/^\\/+|\\/+$/g, '').replace(/\\/+/g, '/');\n const segments = normalized ? normalized.split('/') : [];\n if (segments.length === 0 || segments.some((segment) => segment === '.' || segment === '..')) {\n throw new Error(`DBK ${label} must not be empty or traverse directories: ${path}`);\n }\n return segments.join('/');\n}\n\nfunction joinPath(parent: string, child: string): string {\n return `${parent.replace(/\\/+$/g, '')}/${child.replace(/^\\/+/, '')}`;\n}\n\n/**\n * Fully materialize and validate a DBK container before touching its target\n * provider. A missing or unreadable entry fails the snapshot as a whole.\n */\nexport async function createDbkWorkspaceSnapshot(\n source: ContentContainer,\n options: DbkWorkspaceSnapshotOptions,\n): Promise<DbkWorkspaceSnapshot> {\n const targetDocumentPath = normaliseRelativePath(\n options.targetDocumentPath,\n 'target document path',\n );\n const discoveredDocumentPath = await source.getDocumentPath();\n if (!discoveredDocumentPath)\n throw new Error('The external DBK has no primary markdown document.');\n const sourceDocumentPath = normaliseRelativePath(discoveredDocumentPath, 'primary document path');\n const requestedLayout = options.assetLayout ?? 'auto';\n const assetLayout: Exclude<DbkWorkspaceAssetLayout, 'auto'> =\n requestedLayout === 'auto'\n ? sourceDocumentPath === targetDocumentPath\n ? 'preserve'\n : 'companion'\n : requestedLayout;\n const companionPath = normaliseRelativePath(\n documentCompanionPath(targetDocumentPath),\n 'companion directory path',\n );\n\n const listed = await source.listFiles();\n const entries = [...listed].sort((a, b) => a.path.localeCompare(b.path));\n const seenSourcePaths = new Set<string>();\n const files: MemoryFileSystemSnapshotFile[] = [];\n let documentContent: string | null = null;\n\n for (const entry of entries) {\n const sourcePath = normaliseRelativePath(entry.path, 'entry path');\n if (seenSourcePaths.has(sourcePath)) {\n throw new Error(`The external DBK contains duplicate paths: ${sourcePath}`);\n }\n seenSourcePaths.add(sourcePath);\n\n const data = await source.readFile(entry.path);\n if (data === null) {\n throw new Error(`The external DBK changed while reading: ${sourcePath}`);\n }\n if (sourcePath === sourceDocumentPath) {\n documentContent = new TextDecoder().decode(data);\n files.push({ kind: 'text', path: targetDocumentPath, content: documentContent });\n continue;\n }\n\n const targetPath =\n assetLayout === 'preserve' ? sourcePath : joinPath(companionPath, sourcePath);\n if (/\\.(?:md|mdx|txt)$/i.test(sourcePath)) {\n files.push({ kind: 'text', path: targetPath, content: new TextDecoder().decode(data) });\n } else {\n files.push({ kind: 'binary', path: targetPath, data });\n }\n }\n\n if (documentContent === null) {\n throw new Error(`The external DBK did not include its primary document: ${sourceDocumentPath}`);\n }\n\n return {\n sourceDocumentPath,\n targetDocumentPath,\n documentContent,\n assetLayout,\n files,\n };\n}\n\n/**\n * Replace a transient DBK workspace as one logical operation.\n *\n * Container reads and validation happen before provider mutation. The memory\n * provider then stages and swaps the full tree synchronously, which removes\n * stale files and guarantees the old tree survives any failed replacement.\n */\nexport async function replaceMemoryWorkspaceFromDbk(\n provider: MemoryFileSystemProvider,\n source: ContentContainer,\n options: DbkWorkspaceSnapshotOptions,\n): Promise<DbkWorkspaceSnapshot> {\n const expectedTreeVersion = provider.treeVersion;\n const snapshot = await createDbkWorkspaceSnapshot(source, options);\n provider.replaceContents(snapshot, expectedTreeVersion);\n return snapshot;\n}\n","/**\n * FileSystemContentContainer — a ContentContainer backed by any\n * FileSystemProvider, scoped to a sub-path (e.g., \".docblocks/media/\").\n *\n * Used by the Electron desktop app so media lives inside the workspace\n * folder (visible as regular files) rather than in a separate IndexedDB\n * origin that only the app can see.\n */\n\nimport type { ContentContainer, ContentEntry } from '@bendyline/squisq/storage';\nimport { findDocumentPath } from '@bendyline/squisq/storage';\nimport { FsError } from './fs-error.js';\nimport { getFileSystemProviderV2, type FileSystemProvider } from './types.js';\nimport { parseWorkspacePath, workspacePathContains, workspacePathJoin } from './workspace-path.js';\n\nconst EXTENSION_MIME_MAP: Record<string, string> = {\n '.md': 'text/markdown',\n '.txt': 'text/plain',\n '.json': 'application/json',\n '.jpg': 'image/jpeg',\n '.jpeg': 'image/jpeg',\n '.png': 'image/png',\n '.gif': 'image/gif',\n '.svg': 'image/svg+xml',\n '.webp': 'image/webp',\n '.avif': 'image/avif',\n '.mp4': 'video/mp4',\n '.webm': 'video/webm',\n '.mp3': 'audio/mpeg',\n '.wav': 'audio/wav',\n '.ogg': 'audio/ogg',\n};\n\nfunction guessMimeType(path: string): string {\n const dot = path.lastIndexOf('.');\n if (dot === -1) return 'application/octet-stream';\n const ext = path.slice(dot).toLowerCase();\n return EXTENSION_MIME_MAP[ext] ?? 'application/octet-stream';\n}\n\nfunction joinPrefix(prefix: string, p: string): string {\n return workspacePathJoin(parseWorkspacePath(prefix), p);\n}\n\nexport class FileSystemContentContainer implements ContentContainer {\n private readonly prefix: string;\n\n constructor(\n private readonly provider: FileSystemProvider,\n prefix = '.docblocks/media',\n ) {\n this.prefix = parseWorkspacePath(prefix);\n }\n\n async readFile(path: string): Promise<ArrayBuffer | null> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) return (await providerV2.readFile(parseWorkspacePath(full)))?.data ?? null;\n const binary = await this.provider.readBinary(full);\n if (binary) return binary;\n // IndexedDB-backed workspaces store text via `writeFile(string)` and\n // binary via `writeBinary(ArrayBuffer)` under separate keys, so a\n // markdown file written through the text API is invisible to\n // `readBinary`. Fall back to text-then-UTF-8 so consumers like the\n // recursive HTML export can resolve sibling `.md` links uniformly\n // across browser and native workspaces.\n const text = await this.provider.readFile(full);\n if (text === null) return null;\n return new TextEncoder().encode(text).buffer as ArrayBuffer;\n }\n\n async writeFile(path: string, data: ArrayBuffer | Uint8Array, _mimeType?: string): Promise<void> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) {\n await providerV2.writeFile(parseWorkspacePath(full), data, {\n mode: 'upsert',\n createParents: true,\n });\n return;\n }\n await this.provider.writeBinary(full, data);\n }\n\n async removeFile(path: string): Promise<void> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n if (providerV2) {\n await providerV2.remove(parseWorkspacePath(full), { missing: 'ignore' });\n return;\n }\n await this.provider.delete(full);\n }\n\n async listFiles(prefix?: string): Promise<ContentEntry[]> {\n const entries: ContentEntry[] = [];\n const providerV2 = getFileSystemProviderV2(this.provider);\n const root = parseWorkspacePath(this.prefix);\n type ListedEntry = {\n readonly kind: 'file' | 'directory';\n readonly path: string;\n readonly size?: number | null;\n };\n const walk = async (dir: string) => {\n let children: readonly ListedEntry[];\n try {\n children = providerV2\n ? await providerV2.readDirectory(parseWorkspacePath(dir))\n : await this.provider.readDirectory(dir);\n } catch (error: unknown) {\n // An absent container root means an empty container. Every other\n // storage fault (including a subtree disappearing mid-snapshot)\n // remains observable to backup/export callers.\n if (dir === root && error instanceof FsError && error.code === 'not-found') return;\n throw error;\n }\n for (const child of children) {\n if (child.kind === 'directory') {\n await walk(child.path);\n } else {\n const childPath = parseWorkspacePath(child.path);\n const prefixPath = parseWorkspacePath(this.prefix);\n if (!workspacePathContains(prefixPath, childPath)) continue;\n const rel = childPath === prefixPath ? '' : childPath.slice(prefixPath.length + 1);\n if (prefix && !rel.startsWith(prefix)) continue;\n const size = child.size ?? (await this.provider.stat(child.path))?.size ?? 0;\n entries.push({\n path: rel,\n mimeType: guessMimeType(rel),\n size,\n });\n }\n }\n };\n await walk(root);\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const full = joinPrefix(this.prefix, path);\n const providerV2 = getFileSystemProviderV2(this.provider);\n return providerV2\n ? (await providerV2.stat(parseWorkspacePath(full))) !== null\n : this.provider.exists(full);\n }\n\n async getDocumentPath(): Promise<string | null> {\n return findDocumentPath(await this.listFiles());\n }\n\n async readDocument(): Promise<string | null> {\n const docPath = await this.getDocumentPath();\n if (!docPath) return null;\n const data = await this.readFile(docPath);\n if (!data) return null;\n return new TextDecoder().decode(data);\n }\n\n async writeDocument(markdown: string, filename?: string): Promise<void> {\n const name = filename ?? 'index.md';\n const data = new TextEncoder().encode(markdown);\n await this.writeFile(name, data, 'text/markdown');\n }\n}\n","/**\n * createFileMediaProvider — per-file media storage following the pandoc /\n * Word convention: a markdown file `notes.md` gets a sibling folder\n * `notes_files/` that holds its images, audio, and video.\n *\n * Given:\n * • `container` — a ContentContainer scoped to the markdown file's\n * parent directory (so `readFile('notes_files/image.png')` maps to the\n * parent-relative path)\n * • `markdownBasename` — e.g. `\"notes.md\"`\n *\n * Returns a MediaProvider that:\n * • Writes new media under `{basename}_files/{name}` in the parent dir\n * • Returns the folder-qualified path (`notes_files/image.png`) from\n * addMedia so the markdown stays portable outside DocBlocks\n * • Resolves both bare (`image.png`) and folder-qualified\n * (`notes_files/image.png`) references — so legacy markdown and\n * exports from other tools both work\n */\n\nimport type { MediaProvider, MediaEntry } from '@bendyline/squisq/schemas';\nimport type { ContentContainer } from '@bendyline/squisq/storage';\n\nfunction stripExt(name: string): string {\n return name.replace(/\\.[^.]+$/, '');\n}\n\nexport function createFileMediaProvider(\n container: ContentContainer,\n markdownBasename: string,\n): MediaProvider {\n const folder = stripExt(markdownBasename) + '_files';\n const prefix = folder + '/';\n const blobUrlCache = new Map<string, string>();\n\n function toKey(ref: string): string {\n const clean = ref.replace(/^\\/+/, '');\n return clean.startsWith(prefix) ? clean : prefix + clean;\n }\n\n return {\n async resolveUrl(ref: string): Promise<string> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) return cached;\n\n const data = await container.readFile(key);\n if (!data) return ref;\n\n const entries = await container.listFiles();\n const entry = entries.find((e) => e.path === key);\n const mimeType = entry?.mimeType ?? 'application/octet-stream';\n\n const url = URL.createObjectURL(new Blob([data], { type: mimeType }));\n blobUrlCache.set(key, url);\n return url;\n },\n\n async listMedia(): Promise<MediaEntry[]> {\n const entries = await container.listFiles(prefix);\n return entries\n .filter((e) => !e.path.toLowerCase().endsWith('.md'))\n .map((e) => ({\n name: e.path,\n mimeType: e.mimeType,\n size: e.size,\n }));\n },\n\n async addMedia(\n name: string,\n data: ArrayBuffer | Blob | Uint8Array,\n mimeType: string,\n ): Promise<string> {\n const key = toKey(name);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n const buffer = data instanceof Blob ? new Uint8Array(await data.arrayBuffer()) : data;\n await container.writeFile(key, buffer, mimeType);\n return key;\n },\n\n async removeMedia(ref: string): Promise<void> {\n const key = toKey(ref);\n const cached = blobUrlCache.get(key);\n if (cached) {\n URL.revokeObjectURL(cached);\n blobUrlCache.delete(key);\n }\n await container.removeFile(key);\n },\n\n dispose(): void {\n for (const url of blobUrlCache.values()) {\n URL.revokeObjectURL(url);\n }\n blobUrlCache.clear();\n },\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAgEA,IAAM,SAAQ,oBAAI,KAAK,CAAC,GAAE,YAAY;AAU/B,IAAM,oCAAN,MAAwE;AAAA,EAWtE,YACY,UACA,SACjB;AAFiB;AACA;AARnB,SAAQ,gBAA+B,QAAQ,QAAQ;AACvD,SAAiB,gBAAgB,oBAAI,IAAiC;AACtE,SAAQ,UAAU;AAClB,SAAQ,WAAW;AACnB,SAAQ,iBAAuC;AAM7C,SAAK,KAAK,SAAS;AACnB,SAAK,QAAQ,SAAS;AACtB,SAAK,eAAe,OAAO,OAAO;AAAA,MAChC,gBAAgB,QAAQ,kBAAkB;AAAA,MAC1C,eAAe,QAAQ,iBAAiB;AAAA;AAAA;AAAA,MAGxC,mBAAmB;AAAA,MACnB,kBAAkB;AAAA,MAClB,iBAAiB;AAAA,MACjB,OAAO;AAAA,MACP,iBAAiB,QAAQ,mBAAmB;AAAA,MAC5C,eAAe,QAAQ,iBAAi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