@bendyline/docblocks 2.1.0 → 2.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (72) hide show
  1. package/README.md +2 -2
  2. package/dist/{chunk-WJKYY5QR.js → chunk-4437YWLE.js} +5 -6
  3. package/dist/{chunk-XUML3MKV.js → chunk-45T5AFCN.js} +5 -6
  4. package/dist/{chunk-COYQXQK3.js → chunk-6L3JRDE7.js} +4 -5
  5. package/dist/{chunk-BNKV7MTO.js → chunk-6XHOOBYF.js} +0 -1
  6. package/dist/{chunk-U722UUFN.js → chunk-73OOROXH.js} +0 -1
  7. package/dist/{chunk-JS6XFWQK.js → chunk-AYWKIZLD.js} +0 -1
  8. package/dist/{chunk-VTCSF7VS.js → chunk-BVY7GGNV.js} +4 -5
  9. package/dist/{chunk-B56KWCSE.js → chunk-DOV5VRTD.js} +61 -10
  10. package/dist/{chunk-AEHCVWU5.js → chunk-DZB666V7.js} +0 -1
  11. package/dist/{chunk-GM5YXU4L.js → chunk-KQ6756AJ.js} +1 -2
  12. package/dist/{chunk-BXMF5YQJ.js → chunk-LMMOFRGQ.js} +0 -1
  13. package/dist/{chunk-FNW556FN.js → chunk-M2PUNKHS.js} +0 -1
  14. package/dist/{chunk-FA7UNOXK.js → chunk-M5ZNQGR5.js} +1 -2
  15. package/dist/{chunk-P4WATND4.js → chunk-M62ZGJ5I.js} +0 -1
  16. package/dist/{chunk-RVPGQBWR.js → chunk-OQCPBOQA.js} +0 -1
  17. package/dist/{chunk-MNSZ7EZN.js → chunk-QI6YKTQV.js} +2 -3
  18. package/dist/{chunk-P3DVZQ6S.js → chunk-SJBB5OD7.js} +2 -3
  19. package/dist/{chunk-EZKJZUNJ.js → chunk-XAMILHQP.js} +0 -1
  20. package/dist/{chunk-6IYMTYMQ.js → chunk-YM7O3PWO.js} +7 -8
  21. package/dist/{chunk-DN7A33LL.js → chunk-ZO7G53QP.js} +4 -5
  22. package/dist/document/index.js +5 -6
  23. package/dist/filesystem/electron.js +6 -7
  24. package/dist/filesystem/index.js +16 -17
  25. package/dist/filesystem/indexeddb.js +8 -9
  26. package/dist/filesystem/memory.js +5 -6
  27. package/dist/filesystem/native.js +6 -7
  28. package/dist/host/index.js +2 -3
  29. package/dist/index.js +19 -20
  30. package/dist/mcp/index.d.ts +6 -3
  31. package/dist/mcp/index.js +4 -3
  32. package/dist/mcp/zod.d.ts +1859 -648
  33. package/dist/mcp/zod.js +78 -7
  34. package/dist/share/index.js +1 -2
  35. package/dist/{types-CX893hgH.d.ts → types-B7BBB5az.d.ts} +63 -2
  36. package/dist/vscode/index.d.ts +5 -0
  37. package/dist/vscode/index.js +11 -5
  38. package/dist/workspace/index.js +3 -4
  39. package/package.json +3 -2
  40. package/dist/chunk-6IYMTYMQ.js.map +0 -1
  41. package/dist/chunk-AEHCVWU5.js.map +0 -1
  42. package/dist/chunk-B56KWCSE.js.map +0 -1
  43. package/dist/chunk-BNKV7MTO.js.map +0 -1
  44. package/dist/chunk-BXMF5YQJ.js.map +0 -1
  45. package/dist/chunk-COYQXQK3.js.map +0 -1
  46. package/dist/chunk-DN7A33LL.js.map +0 -1
  47. package/dist/chunk-EZKJZUNJ.js.map +0 -1
  48. package/dist/chunk-FA7UNOXK.js.map +0 -1
  49. package/dist/chunk-FNW556FN.js.map +0 -1
  50. package/dist/chunk-GM5YXU4L.js.map +0 -1
  51. package/dist/chunk-JS6XFWQK.js.map +0 -1
  52. package/dist/chunk-MNSZ7EZN.js.map +0 -1
  53. package/dist/chunk-P3DVZQ6S.js.map +0 -1
  54. package/dist/chunk-P4WATND4.js.map +0 -1
  55. package/dist/chunk-RVPGQBWR.js.map +0 -1
  56. package/dist/chunk-U722UUFN.js.map +0 -1
  57. package/dist/chunk-VTCSF7VS.js.map +0 -1
  58. package/dist/chunk-WJKYY5QR.js.map +0 -1
  59. package/dist/chunk-XUML3MKV.js.map +0 -1
  60. package/dist/document/index.js.map +0 -1
  61. package/dist/filesystem/electron.js.map +0 -1
  62. package/dist/filesystem/index.js.map +0 -1
  63. package/dist/filesystem/indexeddb.js.map +0 -1
  64. package/dist/filesystem/memory.js.map +0 -1
  65. package/dist/filesystem/native.js.map +0 -1
  66. package/dist/host/index.js.map +0 -1
  67. package/dist/index.js.map +0 -1
  68. package/dist/mcp/index.js.map +0 -1
  69. package/dist/mcp/zod.js.map +0 -1
  70. package/dist/share/index.js.map +0 -1
  71. package/dist/vscode/index.js.map +0 -1
  72. package/dist/workspace/index.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/electron-provider-v2.ts","../src/filesystem/electron-provider.ts"],"sourcesContent":["import {\n ELECTRON_FILE_SYSTEM_V2_CAPABILITIES,\n maybeGetDocBlocksHost,\n type DocBlocksHostFsV2API,\n type HostFileSystemV2Result,\n type HostFileSystemV2WatchMessage,\n} from '../host/index.js';\nimport {\n FsError,\n deserializeFsError,\n fsErrorFromUnknown,\n isSerializedFsError,\n type FsOperation,\n} from './fs-error.js';\nimport {\n WORKSPACE_ROOT,\n parseWorkspacePath,\n workspacePathBasename,\n workspacePathDirname,\n type WorkspacePath,\n} from './workspace-path.js';\nimport { copyBytes } from './internal/bytes.js';\nimport { compareSnapshotsByPath, compareText } from './internal/entry-order.js';\nimport { isRecord } from './internal/records.js';\nimport {\n parseFileSystemVersion,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\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 FileSystemWatchEvent,\n type FileSystemWatchOptions,\n type FileSystemWatchSubscription,\n type FileSystemWriteOptions,\n} from './v2.js';\n\ninterface ClientWatcher {\n readonly listener: (event: FileSystemWatchEvent) => void;\n readonly onError: FileSystemWatchOptions['onError'];\n}\n\nlet fallbackInstanceSequence = 0;\n\nfunction getHostFsV2(operation: FsOperation): DocBlocksHostFsV2API {\n const host = maybeGetDocBlocksHost();\n if (!host?.fsV2) {\n throw new FsError('not-supported', 'Electron filesystem v2 host is unavailable.', {\n operation,\n });\n }\n return host.fsV2;\n}\n\n/** Pure renderer-side client for the typed Electron filesystem v2 transport. */\nexport class ElectronFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = ELECTRON_FILE_SYSTEM_V2_CAPABILITIES;\n\n private readonly rootPath: string;\n private readonly instanceId = createInstanceId();\n private readonly watchers = new Map<string, ClientWatcher>();\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private openPromise: Promise<void> | null = null;\n private removeWatchBridge: (() => void) | null = null;\n private disposePromise: Promise<void> | null = null;\n private hostOpened = false;\n private disposed = false;\n\n public constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n }\n\n public getRootPath(): string {\n return this.rootPath;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'stat',\n () => getHostFsV2('stat').stat(this.instanceId, canonical),\n (value) => (value ? normalizeEntry(value) : null),\n );\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'read',\n () => getHostFsV2('read').readFile(this.instanceId, canonical),\n (value) => {\n if (!value) return null;\n const entry = normalizeFile(value.entry);\n const data = copyWireBuffer(value.data);\n if (data.byteLength !== entry.size) {\n throw new TypeError('Filesystem transport returned file bytes with the wrong size.');\n }\n return Object.freeze({ entry, data });\n },\n );\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'list',\n () => getHostFsV2('list').readDirectory(this.instanceId, canonical),\n (value) => normalizeDirectoryListing(value, canonical),\n );\n }\n\n public async writeFile(\n path: WorkspacePath,\n data: ArrayBuffer | Uint8Array,\n options?: FileSystemWriteOptions,\n ): Promise<FileSystemFileSnapshot> {\n const canonical = parseWorkspacePath(String(path));\n const owned = copyBytes(data);\n return this.request(\n 'write',\n () => getHostFsV2('write').writeFile(this.instanceId, canonical, owned, options),\n normalizeFile,\n );\n }\n\n public async createDirectory(\n path: WorkspacePath,\n options?: FileSystemCreateDirectoryOptions,\n ): Promise<FileSystemDirectorySnapshot> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'create-directory',\n () => getHostFsV2('create-directory').createDirectory(this.instanceId, canonical, options),\n normalizeDirectory,\n );\n }\n\n public async remove(\n path: WorkspacePath,\n options?: FileSystemRemoveOptions,\n ): Promise<FileSystemRemoveResult> {\n const canonical = parseWorkspacePath(String(path));\n return this.request(\n 'remove',\n () => getHostFsV2('remove').remove(this.instanceId, canonical, options),\n normalizeRemoveResult,\n );\n }\n\n public async move(\n oldPath: WorkspacePath,\n newPath: WorkspacePath,\n options?: FileSystemMoveOptions,\n ): Promise<FileSystemEntrySnapshot> {\n const source = parseWorkspacePath(String(oldPath));\n const destination = parseWorkspacePath(String(newPath));\n return this.request(\n 'move',\n () => getHostFsV2('move').move(this.instanceId, source, destination, options),\n normalizeEntry,\n );\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.request(\n 'snapshot',\n () => getHostFsV2('snapshot').snapshot(this.instanceId),\n normalizeSnapshot,\n );\n }\n\n public watch(\n listener: (event: FileSystemWatchEvent) => void,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n this.ensureWatchBridge();\n const subscriptionId = createInstanceId();\n const watcher: ClientWatcher = { listener, onError: options.onError };\n this.watchers.set(subscriptionId, watcher);\n let closed = false;\n let subscribed = false;\n let closePromise: Promise<void> | null = null;\n const ready = this.ensureOpen('watch')\n .then(async () => {\n if (closed) return;\n unwrap(await getHostFsV2('watch').watchSubscribe(this.instanceId, subscriptionId), 'watch');\n subscribed = true;\n })\n .catch((error: unknown) => {\n closed = true;\n this.watchers.delete(subscriptionId);\n const typed = error instanceof FsError ? error : new FsError('io', String(error));\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n throw typed;\n });\n\n const subscription: FileSystemWatchSubscription = {\n get closed() {\n return closed;\n },\n ready,\n dispose: () => {\n if (closePromise) return closePromise;\n closed = true;\n this.watchers.delete(subscriptionId);\n this.subscriptions.delete(subscription);\n closePromise = (async () => {\n await ready.catch(() => undefined);\n if (subscribed) {\n unwrap(\n await getHostFsV2('watch').watchUnsubscribe(this.instanceId, subscriptionId),\n 'watch',\n );\n }\n })();\n return closePromise;\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.disposed = true;\n this.disposePromise = (async () => {\n await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n try {\n if (this.openPromise) {\n try {\n await this.openPromise;\n } catch {\n // A failed request normally creates no host record. `hostOpened`\n // separately tracks a successful open whose response validation\n // failed after the main-side record had already been published.\n }\n }\n if (this.hostOpened) {\n try {\n unwrap(await getHostFsV2('dispose').dispose(this.instanceId), 'dispose');\n } catch (error: unknown) {\n if (!(error instanceof FsError && error.code === 'closed')) throw error;\n } finally {\n this.hostOpened = false;\n }\n }\n } finally {\n this.removeWatchBridge?.();\n this.removeWatchBridge = null;\n }\n })();\n return this.disposePromise;\n }\n\n private request<T, U>(\n operation: FsOperation,\n send: () => Promise<HostFileSystemV2Result<T>>,\n normalize: (value: T) => U,\n ): Promise<U> {\n this.assertOpen(operation);\n const promise = this.ensureOpen(operation).then(async () => {\n try {\n return normalize(unwrap(await send(), operation));\n } catch (error: unknown) {\n throw transportErrorFromUnknown(error, operation);\n }\n });\n this.inFlight.add(promise);\n void promise.then(\n () => this.inFlight.delete(promise),\n () => this.inFlight.delete(promise),\n );\n return promise;\n }\n\n private ensureOpen(operation: FsOperation): Promise<void> {\n this.assertOpen(operation);\n if (!this.openPromise) {\n const attempt = getHostFsV2(operation)\n .open({\n instanceId: this.instanceId,\n providerId: this.id,\n label: this.label,\n })\n .then((result) => {\n if (isRecord(result) && result.ok === true) this.hostOpened = true;\n const capabilities = unwrap(result, operation);\n assertCapabilities(capabilities, operation);\n })\n .catch((error: unknown) => {\n const typed = withOperation(fsErrorFromUnknown(error, { operation }), operation);\n if (typed.retryable && this.openPromise === attempt) this.openPromise = null;\n throw typed;\n });\n this.openPromise = attempt;\n }\n return this.openPromise;\n }\n\n private ensureWatchBridge(): void {\n if (this.removeWatchBridge) return;\n this.removeWatchBridge = getHostFsV2('watch').onWatchMessage((message) =>\n this.handleWatchMessage(message),\n );\n }\n\n private handleWatchMessage(message: HostFileSystemV2WatchMessage): void {\n if (message.instanceId !== this.instanceId) return;\n const watcher = this.watchers.get(message.subscriptionId);\n if (!watcher) return;\n if (message.kind === 'error') {\n const typed = isSerializedFsError(message.error)\n ? deserializeFsError(message.error)\n : invalidTransport('watch', 'Filesystem transport returned an invalid watch error.');\n try {\n watcher.onError?.(typed);\n } catch {\n // Isolate observers.\n }\n return;\n }\n\n let event: FileSystemWatchEvent;\n try {\n event = normalizeWatchEvent(message.event);\n } catch (error: unknown) {\n try {\n watcher.onError?.(transportErrorFromUnknown(error, 'watch'));\n } catch {\n // Isolate observers.\n }\n return;\n }\n try {\n watcher.listener(event);\n } catch {\n // Watch callbacks are observational.\n }\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n}\n\nfunction unwrap<T>(result: HostFileSystemV2Result<T>, operation: FsOperation): T {\n if (!isRecord(result) || typeof result.ok !== 'boolean') {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid result envelope.');\n }\n if (result.ok) {\n if (!('value' in result)) {\n throw invalidTransport(operation, 'Filesystem transport omitted a result value.');\n }\n return result.value;\n }\n if (!isSerializedFsError(result.error)) {\n throw invalidTransport(operation, 'Filesystem transport returned an invalid error envelope.');\n }\n throw deserializeFsError(result.error);\n}\n\nfunction normalizeEntry(entry: FileSystemEntrySnapshot): FileSystemEntrySnapshot {\n if (!isRecord(entry)) throw new TypeError('Expected a filesystem entry object.');\n if (typeof entry.path !== 'string')\n throw new TypeError('Filesystem entry path must be a string.');\n if (typeof entry.name !== 'string')\n throw new TypeError('Filesystem entry name must be a string.');\n if (typeof entry.lastModified !== 'string') {\n throw new TypeError('Filesystem entry timestamp must be a string.');\n }\n const path = parseWorkspacePath(entry.path);\n if (entry.name !== workspacePathBasename(path)) {\n throw new TypeError('Filesystem entry name does not match its canonical path.');\n }\n const common = {\n path,\n name: entry.name,\n version: parseFileSystemVersion(entry.version),\n lastModified: new Date(entry.lastModified).toISOString(),\n };\n if (entry.kind === 'file') {\n if (!isNonNegativeSafeInteger(entry.size)) {\n throw new TypeError('Filesystem file size must be a non-negative safe integer.');\n }\n return Object.freeze({ ...common, kind: 'file', size: entry.size });\n }\n if (entry.kind === 'directory') {\n if (entry.size !== null) throw new TypeError('Filesystem directory size must be null.');\n return Object.freeze({ ...common, kind: 'directory', size: null });\n }\n throw new TypeError('Unknown filesystem entry kind.');\n}\n\nfunction normalizeDirectoryListing(\n value: readonly FileSystemEntrySnapshot[],\n parent: WorkspacePath,\n): readonly FileSystemEntrySnapshot[] {\n if (!Array.isArray(value)) throw new TypeError('Expected a filesystem directory listing.');\n const entries = value.map(normalizeEntry);\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (entry.path === WORKSPACE_ROOT || workspacePathDirname(entry.path) !== parent) {\n throw new TypeError('Filesystem listing contained a non-child entry.');\n }\n if (seen.has(entry.path)) throw new TypeError('Filesystem listing contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort(compareSnapshotsByPath);\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem listing was not in canonical deterministic order.');\n }\n return Object.freeze(entries);\n}\n\nfunction normalizeFile(entry: FileSystemFileSnapshot): FileSystemFileSnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'file') throw new TypeError('Expected a file snapshot.');\n return normalized;\n}\n\nfunction normalizeDirectory(entry: FileSystemDirectorySnapshot): FileSystemDirectorySnapshot {\n const normalized = normalizeEntry(entry);\n if (normalized.kind !== 'directory') throw new TypeError('Expected a directory snapshot.');\n return normalized;\n}\n\nfunction normalizeSnapshot(snapshot: FileSystemSnapshot): FileSystemSnapshot {\n if (!isRecord(snapshot) || !Array.isArray(snapshot.entries)) {\n throw new TypeError('Expected a filesystem snapshot object.');\n }\n const version = parseFileSystemVersion(snapshot.version);\n const entries: FileSystemSnapshotEntry[] = snapshot.entries.map((entry) => {\n if (entry.kind === 'file') {\n const file = normalizeFile(entry);\n const data = copyWireBuffer(entry.data);\n if (data.byteLength !== file.size) {\n throw new TypeError('Filesystem snapshot file bytes have the wrong size.');\n }\n return Object.freeze({ ...file, data });\n }\n if (entry.kind === 'directory') return normalizeDirectory(entry);\n throw new TypeError('Unknown filesystem snapshot entry kind.');\n });\n const roots = entries.filter((entry) => entry.path === WORKSPACE_ROOT);\n if (roots.length !== 1 || roots[0]?.kind !== 'directory' || roots[0].version !== version) {\n throw new TypeError('Filesystem snapshot must contain one matching root directory.');\n }\n const seen = new Set<WorkspacePath>();\n for (const entry of entries) {\n if (seen.has(entry.path))\n throw new TypeError('Filesystem snapshot contained a duplicate path.');\n seen.add(entry.path);\n }\n const ordered = [...entries].sort((left, right) => compareText(left.path, right.path));\n if (ordered.some((entry, index) => entry.path !== entries[index]?.path)) {\n throw new TypeError('Filesystem snapshot was not in canonical deterministic order.');\n }\n return Object.freeze({\n version,\n entries: Object.freeze(entries),\n });\n}\n\nfunction normalizeWatchEvent(event: FileSystemWatchEvent): FileSystemWatchEvent {\n if (!isRecord(event)) throw new TypeError('Expected a filesystem watch event object.');\n if (!isPositiveSafeInteger(event.sequence)) {\n throw new TypeError('Filesystem watch sequence must be a positive safe integer.');\n }\n if (!isWatchOrigin(event.origin)) throw new TypeError('Unknown filesystem watch origin.');\n if (typeof event.path !== 'string') throw new TypeError('Watch event path must be a string.');\n const path = parseWorkspacePath(event.path);\n if (event.type === 'overflow') {\n if (\n event.kind !== null ||\n event.destinationPath !== null ||\n event.version !== null ||\n event.previousVersion !== null\n ) {\n throw new TypeError('Filesystem overflow event has entry-specific fields.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: 'overflow',\n kind: null,\n path,\n destinationPath: null,\n version: null,\n previousVersion: null,\n });\n }\n if (!isEntryWatchType(event.type)) throw new TypeError('Unknown filesystem watch event type.');\n if (event.kind !== 'file' && event.kind !== 'directory') {\n throw new TypeError('Unknown filesystem watch entry kind.');\n }\n const destinationPath =\n event.destinationPath === null\n ? null\n : typeof event.destinationPath === 'string'\n ? parseWorkspacePath(event.destinationPath)\n : (() => {\n throw new TypeError('Watch destination path must be a string or null.');\n })();\n if ((event.type === 'moved') !== (destinationPath !== null)) {\n throw new TypeError('Only moved watch events may have a destination path.');\n }\n return Object.freeze({\n sequence: event.sequence,\n origin: event.origin,\n type: event.type,\n kind: event.kind,\n path,\n destinationPath,\n version: event.version === null ? null : parseFileSystemVersion(event.version),\n previousVersion:\n event.previousVersion === null ? null : parseFileSystemVersion(event.previousVersion),\n });\n}\n\nfunction normalizeRemoveResult(value: FileSystemRemoveResult): FileSystemRemoveResult {\n if (!isRecord(value) || typeof value.removed !== 'boolean') {\n throw new TypeError('Filesystem transport returned an invalid remove result.');\n }\n return Object.freeze({ removed: value.removed, version: parseFileSystemVersion(value.version) });\n}\n\nfunction assertCapabilities(value: FileSystemProviderCapabilities, operation: FsOperation): void {\n if (!isRecord(value)) {\n throw invalidTransport(operation, 'Filesystem host returned invalid capabilities.');\n }\n for (const key of Object.keys(ELECTRON_FILE_SYSTEM_V2_CAPABILITIES) as Array<\n keyof FileSystemProviderCapabilities\n >) {\n if (value[key] !== ELECTRON_FILE_SYSTEM_V2_CAPABILITIES[key]) {\n throw invalidTransport(operation, `Filesystem host capability mismatch: ${key}.`);\n }\n }\n}\n\nfunction isWatchOrigin(value: unknown): value is FileSystemWatchEvent['origin'] {\n return value === 'local' || value === 'external' || value === 'unknown';\n}\n\nfunction isEntryWatchType(\n value: unknown,\n): value is Exclude<FileSystemWatchEvent['type'], 'overflow'> {\n return value === 'created' || value === 'modified' || value === 'removed' || value === 'moved';\n}\n\nfunction isNonNegativeSafeInteger(value: unknown): value is number {\n return typeof value === 'number' && Number.isSafeInteger(value) && value >= 0;\n}\n\nfunction isPositiveSafeInteger(value: unknown): value is number {\n return isNonNegativeSafeInteger(value) && value > 0;\n}\n\nfunction invalidTransport(operation: FsOperation, message: string): FsError {\n return new FsError('io', message, { operation, retryable: false });\n}\n\nfunction transportErrorFromUnknown(error: unknown, operation: FsOperation): FsError {\n if (error instanceof TypeError) return invalidTransport(operation, error.message);\n return withOperation(fsErrorFromUnknown(error, { operation }), operation);\n}\n\nfunction withOperation(error: FsError, operation: FsOperation): FsError {\n if (error.operation === operation) return error;\n return new FsError(error.code, error.message, {\n operation,\n path: error.path ?? undefined,\n destinationPath: error.destinationPath ?? undefined,\n retryable: error.retryable,\n });\n}\n\nfunction copyWireBuffer(data: ArrayBuffer): ArrayBuffer {\n if (Object.prototype.toString.call(data) !== '[object ArrayBuffer]') {\n throw new TypeError('Expected an ArrayBuffer from the filesystem transport.');\n }\n return data.slice(0);\n}\n\nfunction createInstanceId(): string {\n const randomUUID = globalThis.crypto?.randomUUID;\n if (typeof randomUUID === 'function') return randomUUID.call(globalThis.crypto);\n fallbackInstanceSequence += 1;\n return `electron-fs-v2-${Date.now()}-${fallbackInstanceSequence}`;\n}\n","/**\n * ElectronFileSystemProvider — implements FileSystemProvider by delegating\n * to the Electron desktop host's fs IPC bridge. Every operation is scoped\n * to an opaque workspace id that the main process resolves against its\n * registered workspace authority.\n *\n * This file has no Electron dependency — it is a pure IPC client that\n * relies on the `docBlocksHost` global installed by the preload script.\n */\n\nimport type { FileCommitResult, FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { maybeGetDocBlocksHost } from '../host/index.js';\nimport type { DocBlocksHostFsAPI } from '../host/types.js';\nimport { ElectronFileSystemProviderV2 } from './electron-provider-v2.js';\n\nexport { isElectronHost } from '../host/index.js';\n\nfunction getHostFs(): DocBlocksHostFsAPI {\n const host = maybeGetDocBlocksHost();\n if (!host) {\n throw new Error(\n 'ElectronFileSystemProvider: docBlocksHost is not available — not running under Electron?',\n );\n }\n return host.fs;\n}\n\nexport class ElectronFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n readonly v2: ElectronFileSystemProviderV2;\n\n private readonly rootPath: string;\n\n constructor(id: string, label: string, rootPath: string) {\n this.id = id;\n this.label = label;\n this.rootPath = rootPath;\n this.v2 = new ElectronFileSystemProviderV2(id, label, rootPath);\n }\n\n /** Absolute path this provider is rooted at. */\n getRootPath(): string {\n return this.rootPath;\n }\n\n readFile(path: string): Promise<string | null> {\n return getHostFs().readFile(this.id, path);\n }\n\n writeFile(path: string, content: string): Promise<void> {\n return getHostFs().writeFile(this.id, path, content);\n }\n\n commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n return getHostFs().commitFile(this.id, path, content, expectedContent);\n }\n\n delete(path: string): Promise<void> {\n return getHostFs().delete(this.id, path);\n }\n\n rename(oldPath: string, newPath: string): Promise<void> {\n return getHostFs().rename(this.id, oldPath, newPath);\n }\n\n readDirectory(path: string): Promise<FileSystemEntry[]> {\n return getHostFs().readDirectory(this.id, path);\n }\n\n exists(path: string): Promise<boolean> {\n return getHostFs().exists(this.id, path);\n }\n\n createDirectory(path: string): Promise<void> {\n return getHostFs().createDirectory(this.id, path);\n }\n\n stat(path: string): Promise<FileMeta | null> {\n return getHostFs().stat(this.id, path);\n }\n\n readBinary(path: string): Promise<ArrayBuffer | null> {\n return getHostFs().readBinary(this.id, path);\n }\n\n writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return getHostFs().writeBinary(this.id, path, data);\n }\n\n /** Subscribe to external change notifications under this root. */\n watch(onChange: (changedPath: string) => void): () => void {\n return getHostFs().watch(this.id, onChange);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAiDA,IAAI,2BAA2B;AAE/B,SAAS,YAAY,WAA8C;AACjE,QAAM,OAAO,sBAAsB;AACnC,MAAI,CAAC,MAAM,MAAM;AACf,UAAM,IAAI,QAAQ,iBAAiB,+CAA+C;AAAA,MAChF;AAAA,IACF,CAAC;AAAA,EACH;AACA,SAAO,KAAK;AACd;AAGO,IAAM,+BAAN,MAAmE;AAAA,EAgBjE,YAAY,IAAY,OAAe,UAAkB;AAbhE,SAAgB,eAAe;AAG/B,SAAiB,aAAa,iBAAiB;AAC/C,SAAiB,WAAW,oBAAI,IAA2B;AAC3D,SAAiB,gBAAgB,oBAAI,IAAiC;AACtE,SAAiB,WAAW,oBAAI,IAAsB;AACtD,SAAQ,cAAoC;AAC5C,SAAQ,oBAAyC;AACjD,SAAQ,iBAAuC;AAC/C,SAAQ,aAAa;AACrB,SAAQ,WAAW;AAGjB,SAAK,KAAK;AACV,SAAK,QAAQ;AACb,SAAK,WAAW;AAAA,EAClB;AAAA,EAEO,cAAsB;AAC3B,WAAO,KAAK;AAAA,EACd;AAAA,EAEA,MAAa,KAAK,MAA8D;AAC9E,UAAM,YAAY,mBAAmB,OAAO,IAAI,CAAC;AACjD,WAAO,KAAK;AAAA,MACV;AAAA,MACA,MAAM,YAAY,MAAM,EAAE,KAAK,KAAK,YAAY,SAAS;AAAA,MACzD,CAAC,UAAW,QAAQ,eAAe,KAAK,IAAI;AAAA,IAC9C;AAAA,EACF;AAAA,EAEA,MAAa,SAAS,MAAyD;AAC7E,UAAM,YAAY,mBAAmB,OAAO,IAAI,CAAC;AACjD,WAAO,KAAK;AAAA,MACV;AAAA,MAC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I,MAAM,IAAI;AAAA,EACpD;AAAA;AAAA,EAGA,MAAM,UAAqD;AACzD,WAAO,UAAU,EAAE,MAAM,KAAK,IAAI,QAAQ;AAAA,EAC5C;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/filesystem/native-provider-v2.ts","../src/filesystem/native-provider.ts"],"sourcesContent":["import { withFileCommitLock } from './commit-lock.js';\nimport { FsError, fsErrorFromUnknown, type FsOperation } from './fs-error.js';\nimport {\n parseFileSystemVersion,\n type FileSystemCreateDirectoryOptions,\n type FileSystemDirectorySnapshot,\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 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 workspacePathJoin,\n type WorkspacePath,\n} from './workspace-path.js';\nimport { bytesEqual, copyBytes } from './internal/bytes.js';\nimport { compareSnapshotsByName, compareText } from './internal/entry-order.js';\nimport { parentChain } from './internal/parent-chain.js';\n\ninterface ScannedEntry<TFile extends FileSystemFileSnapshot> {\n readonly root: FileSystemDirectorySnapshot | TFile;\n readonly entries: readonly (FileSystemDirectorySnapshot | TFile)[];\n}\n\ntype MetadataScan = ScannedEntry<FileSystemFileSnapshot>;\ntype SnapshotScan = ScannedEntry<FileSystemSnapshotFile>;\n\nexport type NativeFileSystemMovePathState = 'present' | 'missing' | 'unknown';\n\nexport interface NativeFileSystemMoveRecoveryState {\n readonly source: NativeFileSystemMovePathState;\n readonly destination: NativeFileSystemMovePathState;\n}\n\n/**\n * A copy/delete move failed and the provider could not prove that rollback\n * restored the source-only state. Callers must inspect `state` before retrying.\n */\nexport class NativeFileSystemMoveRecoveryError extends FsError {\n public readonly primaryError: FsError;\n public readonly recoveryErrors: readonly FsError[];\n public readonly state: NativeFileSystemMoveRecoveryState;\n\n public constructor(\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n primaryError: FsError,\n recoveryErrors: readonly FsError[],\n state: NativeFileSystemMoveRecoveryState,\n ) {\n super(\n 'io',\n `Native move recovery is incomplete (source: ${state.source}, destination: ${state.destination}).`,\n {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n retryable: false,\n },\n );\n this.name = 'NativeFileSystemMoveRecoveryError';\n this.primaryError = primaryError;\n this.recoveryErrors = Object.freeze([...recoveryErrors]);\n this.state = Object.freeze({ ...state });\n }\n}\n\nconst EPOCH = new Date(0).toISOString();\n\nconst NATIVE_V2_CAPABILITIES: FileSystemProviderCapabilities = Object.freeze({\n writeAtomicity: 'none',\n moveAtomicity: 'none',\n snapshotAtomicity: 'none',\n conditionalWrite: 'process',\n recursiveRemove: true,\n watch: false,\n caseSensitivity: 'platform',\n symlinkPolicy: 'unsupported',\n durability: 'best-effort',\n});\n\n/** Direct File System Access API implementation of FileSystemProviderV2. */\nexport class NativeFileSystemProviderV2 implements FileSystemProviderV2 {\n public readonly id: string;\n public readonly label: string;\n public readonly capabilities = NATIVE_V2_CAPABILITIES;\n\n private readonly root: FileSystemDirectoryHandle;\n private readonly lockKey: string;\n private readonly subscriptions = new Set<FileSystemWatchSubscription>();\n private readonly inFlight = new Set<Promise<unknown>>();\n private disposed = false;\n private disposePromise: Promise<void> | null = null;\n\n public constructor(id: string, root: FileSystemDirectoryHandle) {\n this.id = id;\n this.label = root.name;\n this.root = root;\n this.lockKey = `native:${id}:workspace`;\n }\n\n public async stat(path: WorkspacePath): Promise<FileSystemEntrySnapshot | null> {\n const canonical = this.canonical(path);\n return this.execute('stat', canonical, null, async () => {\n const scanned = await this.tryScanMetadata(canonical, 'stat');\n return scanned ? withoutData(scanned.root) : null;\n });\n }\n\n public async readFile(path: WorkspacePath): Promise<FileSystemFileRead | null> {\n const canonical = this.canonical(path);\n return this.execute('read', canonical, null, async () => {\n const handle = await this.getHandle(canonical);\n if (!handle) return null;\n if (handle.kind !== 'file') {\n throw this.error('type-mismatch', 'read', canonical, 'Expected a file, found a directory.');\n }\n const scanned = await this.scanSnapshotHandle(canonical, handle, 'read');\n if (scanned.root.kind !== 'file') {\n throw this.error('io', 'read', canonical, 'Native file handle changed kind during read.');\n }\n return Object.freeze({\n entry: withoutData(scanned.root) as FileSystemFileSnapshot,\n data: scanned.root.data.slice(0),\n });\n });\n }\n\n public async readDirectory(path: WorkspacePath): Promise<readonly FileSystemEntrySnapshot[]> {\n const canonical = this.canonical(path);\n return this.execute('list', canonical, null, async () => {\n const handle = await this.getHandle(canonical);\n if (!handle) throw this.error('not-found', 'list', canonical, 'Directory does not exist.');\n if (handle.kind !== 'directory') {\n throw this.error('type-mismatch', 'list', canonical, 'Expected a directory, found a file.');\n }\n\n const children: FileSystemEntrySnapshot[] = [];\n for (const [name, childHandle] of await listDirectory(\n handle as FileSystemDirectoryHandle,\n 'list',\n canonical,\n )) {\n const childPath = workspacePathJoin(canonical, name);\n children.push(\n withoutData((await this.scanMetadataHandle(childPath, childHandle, 'list')).root),\n );\n }\n children.sort(compareSnapshotsByName);\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.mutate('write', canonical, null, async () => {\n const mode = options.mode ?? 'upsert';\n if (mode !== 'upsert' && mode !== 'create' && mode !== 'replace') {\n throw this.error('invalid-path', 'write', canonical, 'Invalid write mode.');\n }\n\n const existing = await this.tryScanMetadata(canonical, 'write');\n if (existing?.root.kind === 'directory') {\n throw this.error(\n 'type-mismatch',\n 'write',\n canonical,\n 'Cannot replace a directory with a file.',\n );\n }\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?.root, options.expectedVersion, 'write', canonical);\n\n const missingParents = await this.planParents(\n canonical,\n options.createParents ?? false,\n 'write',\n );\n const createdParents = await this.createDirectories(missingParents);\n let writeCompleted = false;\n try {\n await this.writeBytes(canonical, ownedData);\n writeCompleted = true;\n const written = await this.requireSnapshot(canonical, 'write');\n if (written.root.kind !== 'file' || !bytesEqual(written.root.data, ownedData)) {\n throw this.error(\n 'conflict',\n 'write',\n canonical,\n 'Stored bytes changed before the write could be verified.',\n );\n }\n return withoutData(written.root) as FileSystemFileSnapshot;\n } catch (error: unknown) {\n if (!existing && !writeCompleted) {\n await this.removeEmptyFileIfPresent(canonical).catch(() => undefined);\n }\n await this.rollbackDirectories(createdParents);\n throw error;\n }\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.mutate('create-directory', canonical, null, async () => {\n const mode = options.mode ?? 'ensure';\n if (mode !== 'ensure' && mode !== 'create') {\n throw this.error('invalid-path', 'create-directory', canonical, 'Invalid directory mode.');\n }\n const existing = await this.tryScanMetadata(canonical, 'create-directory');\n if (existing) {\n if (existing.root.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 (mode === 'create') {\n throw this.error(\n 'already-exists',\n 'create-directory',\n canonical,\n 'Directory already exists.',\n );\n }\n return withoutData(existing.root) as FileSystemDirectorySnapshot;\n }\n\n const missingParents = await this.planParents(\n canonical,\n options.createParents ?? false,\n 'create-directory',\n );\n const planned = [...missingParents, canonical];\n const created = await this.createDirectories(planned);\n try {\n const scanned = await this.requireMetadata(canonical, 'create-directory');\n if (scanned.root.kind !== 'directory') {\n throw this.error(\n 'io',\n 'create-directory',\n canonical,\n 'The native backend did not create a directory.',\n );\n }\n return withoutData(scanned.root) as FileSystemDirectorySnapshot;\n } catch (error: unknown) {\n await this.rollbackDirectories(created);\n throw error;\n }\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.mutate('remove', canonical, null, async () => {\n const existing = await this.tryScanMetadata(canonical, 'remove');\n if (!existing) {\n if ((options.missing ?? 'error') === 'ignore') {\n return Object.freeze({\n removed: false,\n version: await this.currentTreeVersion('remove'),\n });\n }\n throw this.error('not-found', 'remove', canonical, 'Entry does not exist.');\n }\n this.assertExpectedVersion(existing.root, options.expectedVersion, 'remove', canonical);\n if (existing.root.kind === 'directory' && !options.recursive) {\n const handle = await this.getHandle(canonical);\n if (!handle || handle.kind !== 'directory') {\n throw this.error('conflict', 'remove', canonical, 'Directory changed before removal.');\n }\n if (\n (await listDirectory(handle as FileSystemDirectoryHandle, 'remove', canonical)).length > 0\n ) {\n throw this.error('not-empty', 'remove', canonical, 'Directory is not empty.');\n }\n }\n\n await this.removeEntry(canonical, existing.root.kind === 'directory' && !!options.recursive);\n if (await this.getHandle(canonical)) {\n throw this.error('conflict', 'remove', canonical, 'Entry was recreated during removal.');\n }\n return Object.freeze({\n removed: true,\n version: await this.currentTreeVersion('remove'),\n });\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.mutate('move', sourcePath, destinationPath, async () => {\n const sourceMetadata = await this.tryScanMetadata(sourcePath, 'move');\n if (!sourceMetadata) {\n throw this.error('not-found', 'move', sourcePath, 'Source does not exist.');\n }\n this.assertExpectedVersion(sourceMetadata.root, options.expectedVersion, 'move', sourcePath);\n if (sourcePath === destinationPath) return withoutData(sourceMetadata.root);\n if (\n sourceMetadata.root.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 if (await this.getHandle(destinationPath)) {\n throw new FsError('already-exists', 'Destination already exists.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n const missingParents = await this.planParents(\n destinationPath,\n options.createParents ?? false,\n 'move',\n );\n const source = await this.tryScanSnapshot(sourcePath, 'move');\n if (\n !source ||\n source.root.kind !== sourceMetadata.root.kind ||\n source.root.version !== sourceMetadata.root.version\n ) {\n throw new FsError('conflict', 'Source changed before the move could be copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n const createdParents = await this.createDirectories(missingParents);\n let destinationVersion: FileSystemVersion | null = null;\n let sourceDeleteAttempted = false;\n try {\n await this.writeTree(source, sourcePath, destinationPath);\n const copied = await this.requireSnapshot(destinationPath, 'move');\n destinationVersion = copied.root.version;\n if (!equalTreeContents(source, sourcePath, copied, destinationPath)) {\n throw new FsError('conflict', 'Destination changed while the move was copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n const sourceBeforeDelete = await this.tryScanMetadata(sourcePath, 'move');\n if (\n !sourceBeforeDelete ||\n sourceBeforeDelete.root.kind !== source.root.kind ||\n sourceBeforeDelete.root.version !== source.root.version\n ) {\n throw new FsError('conflict', 'Source changed while the move was copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n // The version check above is necessary but NOT sufficient to authorize\n // destroying the source. A native version token is\n // sha256(size + '\\0' + lastModified), which cannot see a same-size\n // rewrite landing inside one coarse mtime tick -- FAT/exFAT stamp mtime\n // at 2s granularity, network shares coarser. Deleting on the strength\n // of that token alone can throw away an external edit this move never\n // copied, and `conditionalWrite: 'process'` does not excuse it: that\n // capability describes the atomicity boundary of a caller's\n // `expectedVersion`, whereas this is the provider's own internal proof,\n // reached with no concurrent DocBlocks writer involved.\n //\n // So prove it by bytes before deleting. A move already reads the whole\n // subtree, so re-reading it here is proportionate -- which is exactly\n // why the token itself must NOT hash content: `stat`/`readDirectory`\n // depend on staying metadata-only.\n if (!(await this.matchesCapturedSource(sourcePath, source))) {\n throw new FsError('conflict', 'Source changed while the move was copied.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n\n // Recorded before the call, not after it: removing a directory is not\n // atomic, so a failure partway through still leaves the source damaged\n // and rollback must know the repair is ours to make.\n sourceDeleteAttempted = true;\n await this.removeEntry(sourcePath, source.root.kind === 'directory');\n const [sourceAfter, destinationAfter] = await Promise.all([\n this.tryScanMetadata(sourcePath, 'move'),\n this.tryScanMetadata(destinationPath, 'move'),\n ]);\n if (\n sourceAfter ||\n !destinationAfter ||\n destinationAfter.root.kind !== source.root.kind ||\n destinationAfter.root.version !== destinationVersion\n ) {\n throw new FsError('conflict', 'Move state changed before it could be verified.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n return withoutData(destinationAfter.root);\n } catch (error: unknown) {\n return await this.rollbackMoveAndThrow(\n sourcePath,\n destinationPath,\n source,\n createdParents,\n destinationVersion,\n sourceDeleteAttempted,\n error,\n );\n }\n });\n }\n\n public async snapshot(): Promise<FileSystemSnapshot> {\n return this.mutate('snapshot', WORKSPACE_ROOT, null, async () => {\n const scanned = await this.scanSnapshotHandle(WORKSPACE_ROOT, this.root, 'snapshot');\n const entries = [...scanned.entries]\n .sort((left, right) => compareText(left.path, right.path))\n .map(copySnapshotEntry);\n return Object.freeze({ version: scanned.root.version, entries: Object.freeze(entries) });\n });\n }\n\n public watch(\n _listener: FileSystemWatchListener,\n options: FileSystemWatchOptions = {},\n ): FileSystemWatchSubscription {\n this.assertOpen('watch');\n const error = new FsError('not-supported', 'Native filesystem watching is unavailable.', {\n operation: 'watch',\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 // Observers cannot change provider 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.disposed = true;\n this.disposePromise = (async () => {\n await Promise.allSettled([...this.inFlight]);\n await Promise.all([...this.subscriptions].map((subscription) => subscription.dispose()));\n })();\n return this.disposePromise;\n }\n\n private canonical(path: WorkspacePath): WorkspacePath {\n return parseWorkspacePath(String(path));\n }\n\n private canonicalNonRoot(path: WorkspacePath, operation: FsOperation): WorkspacePath {\n const canonical = this.canonical(path);\n if (!canonical) {\n throw this.error('invalid-path', operation, canonical, 'Workspace root cannot be mutated.');\n }\n return canonical;\n }\n\n private execute<T>(\n operation: FsOperation,\n path: WorkspacePath | null,\n destinationPath: WorkspacePath | null,\n work: () => Promise<T>,\n ): Promise<T> {\n this.assertOpen(operation);\n const promise = (async () => {\n try {\n return await work();\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, destinationPath);\n }\n })();\n this.inFlight.add(promise);\n void promise.then(\n () => this.inFlight.delete(promise),\n () => this.inFlight.delete(promise),\n );\n return promise;\n }\n\n private mutate<T>(\n operation: FsOperation,\n path: WorkspacePath,\n destinationPath: WorkspacePath | null,\n work: () => Promise<T>,\n ): Promise<T> {\n return this.execute(operation, path, destinationPath, () =>\n withFileCommitLock(this.lockKey, work),\n );\n }\n\n private assertOpen(operation: FsOperation): void {\n if (!this.disposed) return;\n throw new FsError('disposed', 'Filesystem provider is disposed.', { operation });\n }\n\n private translateError(\n error: unknown,\n operation: FsOperation,\n path: WorkspacePath | null,\n destinationPath: WorkspacePath | null,\n ): FsError {\n if (error instanceof FsError) return error;\n return fsErrorFromUnknown(error, {\n operation,\n path: path ?? undefined,\n destinationPath: destinationPath ?? undefined,\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 private assertExpectedVersion(\n entry: FileSystemEntrySnapshot | 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 async resolveDirectory(path: WorkspacePath): Promise<FileSystemDirectoryHandle | null> {\n if (!path) return this.root;\n let current = this.root;\n for (const segment of path.split('/')) {\n try {\n current = await current.getDirectoryHandle(segment);\n } catch (error: unknown) {\n if (errorName(error) === 'NotFoundError') return null;\n throw error;\n }\n }\n return current;\n }\n\n private async getHandle(path: WorkspacePath): Promise<FileSystemHandle | null> {\n if (!path) return this.root;\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) return null;\n const name = workspacePathBasename(path);\n try {\n return await parent.getFileHandle(name);\n } catch (error: unknown) {\n if (!isMissingOrKindError(error)) throw error;\n }\n try {\n return await parent.getDirectoryHandle(name);\n } catch (error: unknown) {\n if (!isMissingOrKindError(error)) throw error;\n return null;\n }\n }\n\n private async tryScanMetadata(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<MetadataScan | null> {\n const handle = await this.getHandle(path);\n return handle ? this.scanMetadataHandle(path, handle, operation) : null;\n }\n\n private async tryScanSnapshot(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<SnapshotScan | null> {\n const handle = await this.getHandle(path);\n return handle ? this.scanSnapshotHandle(path, handle, operation) : null;\n }\n\n private async requireMetadata(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<MetadataScan> {\n const scanned = await this.tryScanMetadata(path, operation);\n if (!scanned) throw this.error('not-found', operation, path, 'Entry does not exist.');\n return scanned;\n }\n\n private async requireSnapshot(\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<SnapshotScan> {\n const scanned = await this.tryScanSnapshot(path, operation);\n if (!scanned) throw this.error('not-found', operation, path, 'Entry does not exist.');\n return scanned;\n }\n\n private scanMetadataHandle(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n ): Promise<MetadataScan> {\n // File snapshots expose stable size/lastModified metadata without reading payload bytes.\n // Keep stat/list/version checks on this path so directory scans scale with entries, not bytes.\n return this.scanHandle(path, handle, operation, (filePath, fileHandle) =>\n this.scanFileMetadata(filePath, fileHandle, operation),\n );\n }\n\n private scanSnapshotHandle(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n ): Promise<SnapshotScan> {\n return this.scanHandle(path, handle, operation, (filePath, fileHandle) =>\n this.scanFileSnapshot(filePath, fileHandle, operation),\n );\n }\n\n private async scanHandle<TFile extends FileSystemFileSnapshot>(\n path: WorkspacePath,\n handle: FileSystemHandle,\n operation: FsOperation,\n scanFile: (path: WorkspacePath, handle: FileSystemFileHandle) => Promise<TFile>,\n ): Promise<ScannedEntry<TFile>> {\n if (handle.kind === 'file') {\n const entry = await scanFile(path, handle as FileSystemFileHandle);\n return { root: entry, entries: Object.freeze([entry]) };\n }\n\n const children: ScannedEntry<TFile>[] = [];\n for (const [name, childHandle] of await listDirectory(\n handle as FileSystemDirectoryHandle,\n operation,\n path,\n )) {\n children.push(\n await this.scanHandle(workspacePathJoin(path, name), childHandle, operation, scanFile),\n );\n }\n const childRoots = children.map((child) => child.root).sort(compareSnapshotsByName);\n const version = await metadataVersion(\n 'directory',\n new TextEncoder().encode(\n childRoots\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: FileSystemDirectorySnapshot = Object.freeze({\n kind: 'directory' as const,\n path,\n name: workspacePathBasename(path),\n size: null,\n version,\n lastModified: newestLastModified(childRoots),\n });\n return {\n root: directory,\n entries: Object.freeze([directory, ...children.flatMap((child) => child.entries)]),\n };\n }\n\n private async scanFileMetadata(\n path: WorkspacePath,\n handle: FileSystemFileHandle,\n operation: FsOperation,\n ): Promise<FileSystemFileSnapshot> {\n const file = await this.getFileSnapshot(handle, path, operation);\n return this.fileMetadata(file, path, operation);\n }\n\n private async scanFileSnapshot(\n path: WorkspacePath,\n handle: FileSystemFileHandle,\n operation: FsOperation,\n ): Promise<FileSystemSnapshotFile> {\n const file = await this.getFileSnapshot(handle, path, operation);\n const metadata = await this.fileMetadata(file, path, operation);\n let data: ArrayBuffer;\n try {\n data = copyBytes(await file.arrayBuffer());\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, null);\n }\n if (metadata.size !== data.byteLength) {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n return Object.freeze({ ...metadata, data });\n }\n\n private async getFileSnapshot(\n handle: FileSystemFileHandle,\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<File> {\n try {\n return await handle.getFile();\n } catch (error: unknown) {\n throw this.translateError(error, operation, path, null);\n }\n }\n\n private async fileMetadata(\n file: File,\n path: WorkspacePath,\n operation: FsOperation,\n ): Promise<FileSystemFileSnapshot> {\n if (!Number.isSafeInteger(file.size) || file.size < 0 || !Number.isFinite(file.lastModified)) {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n\n let lastModified: string;\n try {\n lastModified = new Date(file.lastModified).toISOString();\n } catch {\n throw this.error('io', operation, path, 'Native file metadata is inconsistent.');\n }\n\n return Object.freeze({\n kind: 'file',\n path,\n name: workspacePathBasename(path),\n // Derived from size + mtime, never from content. This keeps stat/list\n // proportional to entry count instead of bytes (see scanMetadataHandle),\n // which is what makes large workspaces listable in a browser tab at all.\n //\n // The cost is a real blind spot: an external same-size rewrite inside one\n // mtime tick is invisible here. FAT/exFAT stamp mtime at 2-second\n // granularity, and network shares can be coarser, so this is reachable on\n // removable and mounted volumes rather than merely theoretical. Two\n // consequences follow, and neither is hypothetical:\n // - a conditional write guarded on expectedVersion accepts, silently\n // overwriting the external edit;\n // - move() re-checks this version to prove the source is unchanged\n // before deleting it, so it can delete a source whose bytes it never\n // copied, losing the edit outright.\n // `conditionalWrite: 'process'` declares the first (expectedVersion binds\n // only against writers in this process). The second is a provider-internal\n // check that the token cannot actually support; closing it means\n // byte-comparing the captured source before the delete, not hashing\n // content here, which would undo the scan-by-metadata property above.\n size: file.size,\n version: await metadataVersion(\n 'file',\n new TextEncoder().encode(`${file.size}\\0${file.lastModified}`),\n operation,\n path,\n ),\n lastModified,\n });\n }\n\n private async planParents(\n path: WorkspacePath,\n createParents: boolean,\n operation: FsOperation,\n ): Promise<WorkspacePath[]> {\n const missing: WorkspacePath[] = [];\n for (const parent of parentChain(path)) {\n const handle = await this.getHandle(parent);\n if (handle?.kind === 'file') {\n throw this.error('type-mismatch', operation, parent, 'A parent path is a file.');\n }\n if (!handle) {\n if (!createParents) {\n throw this.error('not-found', operation, parent, 'Parent directory does not exist.');\n }\n missing.push(parent);\n }\n }\n return missing;\n }\n\n private async createDirectories(paths: readonly WorkspacePath[]): Promise<WorkspacePath[]> {\n const created: WorkspacePath[] = [];\n try {\n for (const path of paths) {\n if (!path) continue;\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) {\n throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n }\n await parent.getDirectoryHandle(workspacePathBasename(path), { create: true });\n created.push(path);\n }\n return created;\n } catch (error: unknown) {\n await this.rollbackDirectories(created);\n throw error;\n }\n }\n\n private async rollbackDirectories(paths: readonly WorkspacePath[]): Promise<void> {\n for (const path of [...paths].reverse()) {\n try {\n await this.removeEntry(path, false);\n } catch {\n // Best effort: a non-empty directory may now contain external data.\n }\n }\n }\n\n private async writeBytes(path: WorkspacePath, data: ArrayBuffer): Promise<void> {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n const fileHandle = await parent.getFileHandle(workspacePathBasename(path), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, data);\n }\n\n private async removeEntry(path: WorkspacePath, recursive: boolean): Promise<void> {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n await parent.removeEntry(workspacePathBasename(path), { recursive });\n }\n\n private async removeEmptyFileIfPresent(path: WorkspacePath): Promise<void> {\n const current = await this.tryScanMetadata(path, 'write');\n if (current?.root.kind !== 'file' || current.root.size !== 0) return;\n await this.removeEntry(path, false);\n }\n\n private async currentTreeVersion(operation: FsOperation): Promise<FileSystemVersion> {\n return (await this.scanMetadataHandle(WORKSPACE_ROOT, this.root, operation)).root.version;\n }\n\n private async writeTree(\n source: SnapshotScan,\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n ): Promise<void> {\n const remapped = source.entries.map((entry) => {\n const suffix = entry.path.slice(sourcePath.length);\n return [entry, parseWorkspacePath(`${destinationPath}${suffix}`)] as const;\n });\n const directories = remapped\n .filter(\n (item): item is readonly [FileSystemDirectorySnapshot, WorkspacePath] =>\n item[0].kind === 'directory',\n )\n .sort((left, right) => pathDepth(left[1]) - pathDepth(right[1]));\n for (const [, path] of directories) {\n const parent = await this.resolveDirectory(workspacePathDirname(path));\n if (!parent) throw new DOMException('Parent directory does not exist.', 'NotFoundError');\n await parent.getDirectoryHandle(workspacePathBasename(path), { create: true });\n }\n for (const [entry, path] of remapped) {\n if (entry.kind === 'file') await this.writeBytes(path, entry.data);\n }\n }\n\n private async rollbackMoveAndThrow(\n sourcePath: WorkspacePath,\n destinationPath: WorkspacePath,\n source: SnapshotScan,\n createdParents: readonly WorkspacePath[],\n destinationVersion: FileSystemVersion | null,\n sourceDeleteAttempted: boolean,\n primary: unknown,\n ): Promise<never> {\n const primaryError = this.translateError(primary, 'move', sourcePath, destinationPath);\n const recoveryErrors: FsError[] = [];\n\n // Whether the source still holds everything the move captured. If this move\n // never reached the delete, the source is untouched and is not ours to\n // rewrite — a source that changed underneath us is the caller's conflict,\n // and restoring the captured copy over it would destroy that change.\n let sourceWhole = true;\n if (sourceDeleteAttempted) {\n sourceWhole = await this.matchesCapturedSource(sourcePath, source);\n if (!sourceWhole) {\n try {\n await this.writeTree(source, sourcePath, sourcePath);\n const restored = await this.probeSnapshot(sourcePath);\n if (!restored || !equalTreeContents(source, sourcePath, restored, sourcePath)) {\n throw new FsError('conflict', 'Restored source does not match its captured state.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n });\n }\n sourceWhole = true;\n } catch (error: unknown) {\n recoveryErrors.push(this.translateError(error, 'move', sourcePath, destinationPath));\n }\n }\n }\n\n const destinationCurrent = await this.probeScan(destinationPath);\n if (destinationCurrent) {\n if (!sourceWhole) {\n // Removing a directory is not atomic, so the delete above can fail with\n // the source root still present but children already gone. The copy at\n // the destination is then the only complete one in existence: deleting\n // it to \"undo\" the move would destroy the user's data outright. Keep it\n // and report loudly instead.\n recoveryErrors.push(\n new FsError(\n 'conflict',\n 'Source is incomplete; rollback kept the copy at the destination.',\n {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n },\n ),\n );\n } else if (destinationVersion && destinationCurrent.root.version !== destinationVersion) {\n recoveryErrors.push(\n new FsError('conflict', 'Destination changed; rollback will not delete it.', {\n operation: 'move',\n path: sourcePath,\n destinationPath,\n }),\n );\n } else {\n try {\n await this.removeEntry(destinationPath, destinationCurrent.root.kind === 'directory');\n } catch (error: unknown) {\n recoveryErrors.push(this.translateError(error, 'move', sourcePath, destinationPath));\n }\n }\n }\n await this.rollbackDirectories(createdParents);\n\n const state: NativeFileSystemMoveRecoveryState = {\n source: await this.probePresence(sourcePath),\n destination: await this.probePresence(destinationPath),\n };\n if (\n recoveryErrors.length === 0 &&\n state.source === 'present' &&\n state.destination === 'missing'\n ) {\n throw primaryError;\n }\n throw new NativeFileSystemMoveRecoveryError(\n sourcePath,\n destinationPath,\n primaryError,\n recoveryErrors,\n state,\n );\n }\n\n /**\n * Whether the source still holds exactly the bytes the move captured.\n *\n * A probe that fails answers \"no\": rollback must never treat an unverifiable\n * source as whole, because that is precisely what licenses deleting the copy\n * at the destination.\n */\n private async matchesCapturedSource(\n sourcePath: WorkspacePath,\n source: SnapshotScan,\n ): Promise<boolean> {\n const current = await this.probeSnapshot(sourcePath);\n if (!current) return false;\n return equalTreeContents(source, sourcePath, current, sourcePath);\n }\n\n private async probeScan(path: WorkspacePath): Promise<MetadataScan | null | undefined> {\n try {\n return await this.tryScanMetadata(path, 'move');\n } catch {\n return undefined;\n }\n }\n\n private async probeSnapshot(path: WorkspacePath): Promise<SnapshotScan | null | undefined> {\n try {\n return await this.tryScanSnapshot(path, 'move');\n } catch {\n return undefined;\n }\n }\n\n private async probePresence(path: WorkspacePath): Promise<NativeFileSystemMovePathState> {\n try {\n return (await this.getHandle(path)) ? 'present' : 'missing';\n } catch {\n return 'unknown';\n }\n }\n}\n\nasync function listDirectory(\n directory: FileSystemDirectoryHandle,\n operation: FsOperation,\n path: WorkspacePath,\n): Promise<readonly (readonly [string, FileSystemHandle])[]> {\n const entries: Array<readonly [string, FileSystemHandle]> = [];\n try {\n for await (const entry of directory as unknown as AsyncIterable<\n readonly [string, FileSystemHandle]\n >) {\n const [name, handle] = entry;\n if (\n typeof name !== 'string' ||\n !handle ||\n (handle.kind !== 'file' && handle.kind !== 'directory')\n ) {\n throw new FsError('io', 'Native directory returned an invalid entry.', {\n operation,\n path,\n });\n }\n entries.push([name, handle]);\n }\n } catch (error: unknown) {\n throw fsErrorFromUnknown(error, { operation, path });\n }\n entries.sort(([left], [right]) => compareText(left, right));\n return entries;\n}\n\nasync function writeAndClose(\n writable: FileSystemWritableFileStream,\n data: ArrayBuffer,\n): Promise<void> {\n try {\n await writable.write(data);\n await writable.close();\n } catch (error: unknown) {\n await writable.abort(error).catch(() => undefined);\n throw error;\n }\n}\n\nasync function metadataVersion(\n kind: 'file' | 'directory',\n metadata: 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 + metadata.byteLength);\n input.set(prefix);\n input.set(metadata, 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, {\n operation,\n path,\n defaultCode: 'not-supported',\n });\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 pathDepth(path: WorkspacePath): number {\n return path ? path.split('/').length : 0;\n}\n\nfunction errorName(error: unknown): string | null {\n if (!error || typeof error !== 'object') return null;\n const name = (error as { name?: unknown }).name;\n return typeof name === 'string' ? name : null;\n}\n\nfunction isMissingOrKindError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotFoundError' || name === 'TypeMismatchError';\n}\n\nfunction equalTreeContents(\n left: SnapshotScan,\n leftRoot: WorkspacePath,\n right: SnapshotScan,\n rightRoot: WorkspacePath,\n): boolean {\n if (left.entries.length !== right.entries.length) return false;\n\n const rightByRelativePath = new Map<\n string,\n FileSystemDirectorySnapshot | FileSystemSnapshotFile\n >();\n for (const entry of right.entries) {\n const relativePath = treeRelativePath(rightRoot, entry.path);\n if (relativePath === null || rightByRelativePath.has(relativePath)) return false;\n rightByRelativePath.set(relativePath, entry);\n }\n\n for (const entry of left.entries) {\n const relativePath = treeRelativePath(leftRoot, entry.path);\n if (relativePath === null) return false;\n const counterpart = rightByRelativePath.get(relativePath);\n if (!counterpart || counterpart.kind !== entry.kind) return false;\n if (entry.kind === 'file') {\n if (counterpart.kind !== 'file' || !bytesEqual(entry.data, counterpart.data)) return false;\n }\n }\n return true;\n}\n\nfunction treeRelativePath(root: WorkspacePath, path: WorkspacePath): string | null {\n if (path === root) return '';\n const prefix = root ? `${root}/` : '';\n return path.startsWith(prefix) ? path.slice(prefix.length) : null;\n}\n\nfunction withoutData(entry: FileSystemEntrySnapshot): FileSystemEntrySnapshot {\n if (entry.kind === 'directory') return Object.freeze({ ...entry });\n return Object.freeze({\n kind: 'file',\n path: entry.path,\n name: entry.name,\n size: entry.size,\n version: entry.version,\n lastModified: entry.lastModified,\n });\n}\n\nfunction copySnapshotEntry(entry: FileSystemSnapshotEntry): FileSystemSnapshotEntry {\n if (entry.kind === 'directory') return Object.freeze({ ...entry });\n return Object.freeze({\n kind: 'file',\n path: entry.path,\n name: entry.name,\n size: entry.size,\n version: entry.version,\n lastModified: entry.lastModified,\n data: entry.data.slice(0),\n });\n}\n\nfunction newestLastModified(children: readonly FileSystemEntrySnapshot[]): 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","/**\n * NativeFileSystemProvider — wraps the File System Access API\n * (window.showDirectoryPicker / FileSystemDirectoryHandle).\n *\n * Progressive enhancement: only available in browsers that support\n * the API (Chrome, Edge). Feature-detect with `isNativeFileSystemSupported()`.\n */\n\nimport type { FileCommitResult, FileSystemProvider, FileSystemEntry, FileMeta } from './types.js';\nimport { withFileCommitLock } from './commit-lock.js';\nimport { NativeFileSystemProviderV2 } from './native-provider-v2.js';\nimport { parseWorkspacePath } from './workspace-path.js';\nimport { FsError, type FsOperation } from './fs-error.js';\nimport { decodeUtf8Text } from './utf8.js';\n\n// ── Feature detection ──────────────────────────────────────────────\n\nexport function isNativeFileSystemSupported(): boolean {\n return (\n typeof globalThis !== 'undefined' &&\n typeof (globalThis as { showDirectoryPicker?: unknown }).showDirectoryPicker === 'function'\n );\n}\n\n// ── Handle persistence (IndexedDB, structured clone) ───────────────\n\nconst HANDLE_DB_NAME = 'docblocks-handles';\nconst HANDLE_STORE_NAME = 'directory-handles';\n\nfunction openHandleDB(): Promise<IDBDatabase> {\n return new Promise((resolve, reject) => {\n const req = indexedDB.open(HANDLE_DB_NAME, 1);\n req.onupgradeneeded = () => {\n req.result.createObjectStore(HANDLE_STORE_NAME);\n };\n req.onsuccess = () => resolve(req.result);\n req.onerror = () => reject(req.error);\n });\n}\n\n/** Persist a FileSystemDirectoryHandle so it survives page reloads. */\nexport async function storeDirectoryHandle(\n workspaceId: string,\n handle: FileSystemDirectoryHandle,\n): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).put(handle, workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n/** Retrieve a previously stored handle. Returns null if not found. */\nexport async function loadDirectoryHandle(\n workspaceId: string,\n): Promise<FileSystemDirectoryHandle | null> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readonly');\n const req = tx.objectStore(HANDLE_STORE_NAME).get(workspaceId);\n req.onsuccess = () => {\n db.close();\n resolve(req.result ?? null);\n };\n req.onerror = () => {\n db.close();\n reject(req.error);\n };\n });\n}\n\n/** Remove a stored handle (e.g. when deleting a workspace). */\nexport async function removeDirectoryHandle(workspaceId: string): Promise<void> {\n const db = await openHandleDB();\n return new Promise((resolve, reject) => {\n const tx = db.transaction(HANDLE_STORE_NAME, 'readwrite');\n tx.objectStore(HANDLE_STORE_NAME).delete(workspaceId);\n tx.oncomplete = () => {\n db.close();\n resolve();\n };\n tx.onerror = () => {\n db.close();\n reject(tx.error);\n };\n });\n}\n\n// ── Helpers ────────────────────────────────────────────────────────\n\nfunction normalisePath(p: string): string {\n return parseWorkspacePath(p);\n}\n\nfunction errorName(error: unknown): string | undefined {\n return typeof error === 'object' && error !== null && 'name' in error\n ? String((error as { name?: unknown }).name)\n : undefined;\n}\n\nfunction isMissingEntryError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotFoundError' || name === 'TypeMismatchError';\n}\n\nfunction isKindMismatchError(error: unknown): boolean {\n return errorName(error) === 'TypeMismatchError';\n}\n\n/**\n * Root policy, mirrored from the v2 authority so all three v1 facades agree.\n *\n * The File System Access API has no handle for \"the empty name\", so the root\n * must be answered before reaching it — otherwise it raises a raw TypeError\n * where the other providers raise a typed FsError.\n *\n * v2 splits the root into two cases, and the split is meaningful: a mutation can\n * never legitimately target the root, so it is an invalid *path*; a read finds\n * something real that is simply the wrong *kind*.\n */\nfunction rootIsNotAMutationTarget(operation: FsOperation, path: string): FsError {\n return new FsError('invalid-path', 'The workspace root is not a file entry.', {\n operation,\n path,\n });\n}\n\nfunction notAFile(operation: FsOperation, path: string): FsError {\n return new FsError('type-mismatch', 'Expected a file but found a directory.', {\n operation,\n path,\n });\n}\n\nfunction isPermissionError(error: unknown): boolean {\n const name = errorName(error);\n return name === 'NotAllowedError' || name === 'SecurityError';\n}\n\nclass NativeMoveRecoveryError extends Error {\n readonly causes: readonly unknown[];\n\n constructor(message: string, causes: readonly unknown[]) {\n super(message);\n this.name = 'NativeMoveRecoveryError';\n this.causes = causes;\n }\n}\n\n/**\n * Walk a chain of path segments to reach a FileSystemDirectoryHandle.\n * Returns null if any segment is missing.\n */\nasync function resolveDir(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle | null> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n try {\n current = await current.getDirectoryHandle(part);\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n return current;\n}\n\n/**\n * Walk path segments, creating directories as needed.\n */\nasync function resolveDirCreate(\n root: FileSystemDirectoryHandle,\n dirPath: string,\n): Promise<FileSystemDirectoryHandle> {\n if (!dirPath) return root;\n const parts = dirPath.split('/');\n let current = root;\n for (const part of parts) {\n current = await current.getDirectoryHandle(part, { create: true });\n }\n return current;\n}\n\nfunction parentDir(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? '' : p.slice(0, idx);\n}\n\nfunction baseName(p: string): string {\n const idx = p.lastIndexOf('/');\n return idx === -1 ? p : p.slice(idx + 1);\n}\n\nfunction toWritableBinary(data: ArrayBuffer | Uint8Array): ArrayBuffer {\n if (data instanceof ArrayBuffer) return data;\n const copy = new Uint8Array(data.byteLength);\n copy.set(data);\n return copy.buffer;\n}\n\nasync function writeAndClose(\n writable: FileSystemWritableFileStream,\n data: string | ArrayBuffer,\n): Promise<void> {\n try {\n await writable.write(data);\n await writable.close();\n } catch (error: unknown) {\n await writable.abort(error).catch(() => undefined);\n throw error;\n }\n}\n\n// ── Implementation ─────────────────────────────────────────────────\n\nexport class NativeFileSystemProvider implements FileSystemProvider {\n readonly id: string;\n readonly label: string;\n readonly v2: NativeFileSystemProviderV2;\n\n private root: FileSystemDirectoryHandle;\n\n constructor(id: string, root: FileSystemDirectoryHandle) {\n this.id = id;\n this.label = root.name;\n this.root = root;\n this.v2 = new NativeFileSystemProviderV2(id, root);\n }\n\n private withMutationLock<T>(operation: () => Promise<T>): Promise<T> {\n return withFileCommitLock(`native:${this.id}:workspace`, operation);\n }\n\n private async copyDirectory(oldDirPath: string, newDirPath: string): Promise<void> {\n const source = await resolveDir(this.root, oldDirPath);\n if (!source)\n throw new DOMException(`Source directory does not exist: ${oldDirPath}`, 'NotFoundError');\n await resolveDirCreate(this.root, newDirPath);\n\n for await (const [name, handle] of source as unknown as AsyncIterable<\n [string, FileSystemHandle]\n >) {\n const oldChild = oldDirPath ? `${oldDirPath}/${name}` : name;\n const newChild = newDirPath ? `${newDirPath}/${name}` : name;\n if (handle.kind === 'directory') {\n await this.copyDirectory(oldChild, newChild);\n } else {\n const fileHandle = await source.getFileHandle(name);\n const file = await fileHandle.getFile();\n await this.writeBinaryUnlocked(newChild, await file.arrayBuffer());\n }\n }\n }\n\n async readFile(path: string): Promise<string | null> {\n const p = normalisePath(path);\n const data = await this.readBinary(p);\n if (data === null) return null;\n // `File.text()` decodes leniently: invalid bytes become U+FFFD, and a later\n // save would write those replacement characters back over the user's\n // original bytes. Fail the read instead, like every other provider.\n return decodeUtf8Text(data, { label: 'The file', operation: 'read', path: p });\n }\n\n async writeFile(path: string, content: string): Promise<void> {\n return this.withMutationLock(() => this.writeFileUnlocked(path, content));\n }\n\n private async writeFileUnlocked(path: string, content: string): Promise<void> {\n const p = normalisePath(path);\n // Without this the root's empty basename reaches getFileHandle('', {create:true}),\n // which creates a junk empty-named entry instead of rejecting the write.\n if (!p) throw rootIsNotAMutationTarget('write', path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, content);\n }\n\n async commitFile(\n path: string,\n content: string,\n expectedContent: string | null,\n ): Promise<FileCommitResult> {\n const p = normalisePath(path);\n return this.withMutationLock(async () => {\n const current = await this.readFile(p);\n if (current !== expectedContent && current !== content) {\n const meta = await this.stat(p);\n return {\n status: 'conflict',\n content: current,\n version: meta?.lastModified ?? null,\n };\n }\n await this.writeFileUnlocked(p, content);\n const meta = await this.stat(p);\n return { status: 'committed', version: meta?.lastModified ?? null };\n });\n }\n\n async delete(path: string): Promise<void> {\n return this.withMutationLock(() => this.deleteUnlocked(path));\n }\n\n private async deleteUnlocked(path: string): Promise<void> {\n const p = normalisePath(path);\n if (!p) throw rootIsNotAMutationTarget('remove', path);\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return;\n try {\n await dir.removeEntry(name, { recursive: true });\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return;\n throw error;\n }\n }\n\n async rename(oldPath: string, newPath: string): Promise<void> {\n return this.withMutationLock(() => this.renameUnlocked(oldPath, newPath));\n }\n\n private async renameUnlocked(oldPath: string, newPath: string): Promise<void> {\n const op = normalisePath(oldPath);\n const np = normalisePath(newPath);\n if (op === np) return;\n if (!op || !np) throw rootIsNotAMutationTarget('move', !op ? oldPath : newPath);\n if (np.startsWith(op + '/')) {\n throw new Error('Cannot move a directory into itself');\n }\n if (!(await this.exists(op))) {\n throw new Error(`Source does not exist: ${oldPath}`);\n }\n if (await this.exists(np)) {\n throw new Error(`Destination exists: ${newPath}`);\n }\n\n // The File System Access API doesn't have a native rename.\n // Copy → delete.\n const oldParent = await resolveDir(this.root, parentDir(op));\n if (!oldParent) {\n throw new DOMException(`Source does not exist: ${oldPath}`, 'NotFoundError');\n }\n\n let fileHandle: FileSystemFileHandle | null = null;\n try {\n fileHandle = await oldParent.getFileHandle(baseName(op));\n } catch (error: unknown) {\n if (!isMissingEntryError(error)) throw error;\n }\n\n if (fileHandle) {\n const file = await fileHandle.getFile();\n await this.writeBinaryUnlocked(np, await file.arrayBuffer());\n try {\n await this.deleteUnlocked(op);\n } catch (error: unknown) {\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move partially completed and rollback failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n return;\n }\n\n try {\n await this.copyDirectory(op, np);\n } catch (error: unknown) {\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move failed and destination cleanup failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n\n try {\n await this.deleteUnlocked(op);\n } catch (error: unknown) {\n // Deleting a directory is not atomic: this can fail after some children\n // are already gone, leaving the source gutted and the copy at the\n // destination the only complete one in existence. Rebuild the source from\n // that copy before removing it, and if the source cannot be made whole,\n // keep the copy — deleting it would destroy the user's only data.\n try {\n await this.copyDirectory(np, op);\n } catch (restoreError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move partially deleted the source and it could not be restored; the copy at ${newPath} was kept: ${oldPath} -> ${newPath}`,\n [error, restoreError],\n );\n }\n try {\n await this.deleteUnlocked(np);\n } catch (rollbackError: unknown) {\n throw new NativeMoveRecoveryError(\n `Move partially completed and rollback failed: ${oldPath} -> ${newPath}`,\n [error, rollbackError],\n );\n }\n throw error;\n }\n }\n\n async readDirectory(path: string): Promise<FileSystemEntry[]> {\n const p = normalisePath(path);\n const dir = await resolveDir(this.root, p);\n if (!dir) return [];\n\n const entries: FileSystemEntry[] = [];\n for await (const [name, handle] of dir as unknown as AsyncIterable<\n [string, FileSystemHandle]\n >) {\n const entryPath = p ? `${p}/${name}` : name;\n if (handle.kind === 'directory') {\n entries.push({ kind: 'directory', name, path: entryPath });\n } else {\n entries.push({ kind: 'file', name, path: entryPath });\n }\n }\n\n // Sort: directories first, then alphabetical\n entries.sort((a, b) => {\n if (a.kind !== b.kind) return a.kind === 'directory' ? -1 : 1;\n return a.name.localeCompare(b.name);\n });\n\n return entries;\n }\n\n async exists(path: string): Promise<boolean> {\n const p = normalisePath(path);\n // The granted root handle always exists; there is no entry to look up.\n if (!p) return true;\n const parent = parentDir(p);\n const name = baseName(p);\n const dir = await resolveDir(this.root, parent);\n if (!dir) return false;\n\n try {\n await dir.getFileHandle(name);\n return true;\n } catch (fileError: unknown) {\n if (!isMissingEntryError(fileError)) throw fileError;\n try {\n await dir.getDirectoryHandle(name);\n return true;\n } catch (directoryError: unknown) {\n if (!isMissingEntryError(directoryError)) throw directoryError;\n return false;\n }\n }\n }\n\n async createDirectory(path: string): Promise<void> {\n return this.withMutationLock(async () => {\n const p = normalisePath(path);\n await resolveDirCreate(this.root, p);\n });\n }\n\n async stat(path: string): Promise<FileMeta | null> {\n const p = normalisePath(path);\n // stat() reports files only; the root is a directory, so it has no FileMeta.\n // Every provider returns null rather than throwing for a non-file path.\n if (!p) return null;\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return {\n name: file.name,\n path: p,\n size: file.size,\n lastModified: new Date(file.lastModified).toISOString(),\n };\n } catch (error: unknown) {\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n\n async readBinary(path: string): Promise<ArrayBuffer | null> {\n const p = normalisePath(path);\n if (!p) throw notAFile('read', p);\n const dir = await resolveDir(this.root, parentDir(p));\n if (!dir) return null;\n try {\n const fileHandle = await dir.getFileHandle(baseName(p));\n const file = await fileHandle.getFile();\n return file.arrayBuffer();\n } catch (error: unknown) {\n // A directory is not an absent file: reporting null here made callers\n // conclude the path was free. IndexedDB and memory both raise\n // type-mismatch, so raise it here too.\n if (isKindMismatchError(error)) throw notAFile('read', p);\n if (isMissingEntryError(error)) return null;\n throw error;\n }\n }\n\n async writeBinary(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n return this.withMutationLock(() => this.writeBinaryUnlocked(path, data));\n }\n\n private async writeBinaryUnlocked(path: string, data: ArrayBuffer | Uint8Array): Promise<void> {\n const p = normalisePath(path);\n if (!p) throw rootIsNotAMutationTarget('write', path);\n const dir = await resolveDirCreate(this.root, parentDir(p));\n const fileHandle = await dir.getFileHandle(baseName(p), { create: true });\n const writable = await fileHandle.createWritable();\n await writeAndClose(writable, toWritableBinary(data));\n }\n}\n\n/**\n * Prompt the user to pick a local folder and return a NativeFileSystemProvider.\n * The directory handle is persisted in IndexedDB so it can be restored later.\n * Throws if the user cancels or the API is unsupported.\n */\nexport async function openNativeFolder(): Promise<NativeFileSystemProvider> {\n if (!isNativeFileSystemSupported()) {\n throw new Error('File System Access API is not supported in this browser');\n }\n\n const handle = await (\n globalThis as unknown as {\n showDirectoryPicker: (options: { mode: 'readwrite' }) => Promise<FileSystemDirectoryHandle>;\n }\n ).showDirectoryPicker({ mode: 'readwrite' });\n const id = `native-${handle.name}-${Date.now()}`;\n await storeDirectoryHandle(id, handle);\n return new NativeFileSystemProvider(id, handle);\n}\n\n/**\n * Restore a previously opened native folder from a persisted handle.\n * Re-requests read/write permission (browser will show a prompt).\n * Returns null if the handle is not found or permission is denied.\n */\nexport async function restoreNativeFolder(\n workspaceId: string,\n): Promise<NativeFileSystemProvider | null> {\n const handle = await loadDirectoryHandle(workspaceId);\n if (!handle) return null;\n\n // Verify/request permission\n const opts = { mode: 'readwrite' as const };\n const h = handle as FileSystemDirectoryHandle & {\n queryPermission(desc: { mode: string }): Promise<string>;\n requestPermission(desc: { mode: string }): Promise<string>;\n };\n try {\n if ((await h.queryPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n if ((await h.requestPermission(opts)) === 'granted') {\n return new NativeFileSystemProvider(workspaceId, handle);\n }\n } catch (error: unknown) {\n if (!isPermissionError(error)) throw error;\n }\n\n return null;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAuDO,IAAM,oCAAN,cAAgD,QAAQ;AAAA,EAKtD,YACL,YACA,iBACA,cACA,gBACA,OACA;AACA;AAAA,MACE;AAAA,MACA,+CAA+C,MAAM,MAAM,kBAAkB,MAAM,WAAW;AAAA,MAC9F;AAAA,QACE,WAAW;AAAA,QACX,MAAM;AAAA,QACN;AAAA,QACA,WAAW;AAAA,MACb;AAAA,IACF;AACA,SAAK,OAAO;AACZ,SAAK,eAAe;AACpB,SAAK,iBAAiB,OAAO,OAAO,CAAC,GAAG,cAAc,CAAC;AACvD,SAAK,QAAQ,OAAO,OAAO,EAAE,GAAG,MAAM,CAAC;AAAA,EACzC;AACF;AAEA,IAAM,SAAQ,oBAAI,KAAK,CAAC,GAAE,YAAY;AAEtC,IAAM,yBAAyD,OAAO,OAAO;AAAA,EAC3E,gBAAgB;AAAA,EAChB,eAAe;AAAA,EACf,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,iBAAiB;AAAA,EACjB,OAAO;AAAA,EACP,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,YAAY;AACd,CAAC;AAGM,IAAM,6BAAN,MAAiE;AAAA,EAY/D,YAAY,IAAY,MAAiC;AAThE,SAAgB,eAAe;AAI/B,SAAiB,gBAAgB,oBAAI,IAAiC;AACtE,SA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,CAAC;AAAA,EACtD;AACF;AAOA,eAAsB,mBAAsD;AAC1E,MAAI,CAAC,4BAA4B,GAAG;AAClC,UAAM,IAAI,MAAM,yDAAyD;AAAA,EAC3E;AAEA,QAAM,SAAS,MACb,WAGA,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAC3C,QAAM,KAAK,UAAU,OAAO,IAAI,IAAI,KAAK,IAAI,CAAC;AAC9C,QAAM,qBAAqB,IAAI,MAAM;AACrC,SAAO,IAAI,yBAAyB,IAAI,MAAM;AAChD;AAOA,eAAsB,oBACpB,aAC0C;AAC1C,QAAM,SAAS,MAAM,oBAAoB,WAAW;AACpD,MAAI,CAAC,OAAQ,QAAO;AAGpB,QAAM,OAAO,EAAE,MAAM,YAAqB;AAC1C,QAAM,IAAI;AAIV,MAAI;AACF,QAAK,MAAM,EAAE,gBAAgB,IAAI,MAAO,WAAW;AACjD,aAAO,IAAI,yBAAyB,aAAa,MAAM;AAAA,IACzD;AACA,QAAK,MAAM,EAAE,kBAAkB,IAAI,MAAO,WAAW;AACnD,aAAO,IAAI,yBAAyB,aAAa,MAAM;AAAA,IACzD;AAAA,EACF,SAAS,OAAgB;AACvB,QAAI,CAAC,kBAAkB,KAAK,EAAG,OAAM;AAAA,EACvC;AAEA,SAAO;AACT;","names":["errorName","writeAndClose","meta"]}
@@ -1 +0,0 @@
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';\nimport { bytesEqual, copyBytes } from './internal/bytes.js';\nimport { compareSnapshotsByName, compareText } from './internal/entry-order.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(compareSnapshotsByName);\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' || !bytesEqual(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(compareSnapshotsByName);\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 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","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 secondary Markdown files beneath `<document>_files/`. `auto`\n * preserves a DBK whose primary path already matches the target, otherwise\n * rebasing the secondary documents 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 (\n path.includes('\\\\') ||\n /^[a-zA-Z]:/u.test(path) ||\n [...path].some((character) => {\n const codePoint = character.codePointAt(0) ?? 0;\n return codePoint <= 0x1f || codePoint === 0x7f;\n })\n ) {\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 decodeMarkdownFile(data: ArrayBuffer, path: string): string {\n let content: string;\n try {\n content = new TextDecoder('utf-8', { fatal: true }).decode(data);\n } catch {\n throw new Error(`The external DBK contains invalid UTF-8 Markdown: ${path}`);\n }\n if (content.includes('\\0')) {\n throw new Error(`The external DBK contains a NUL character in Markdown: ${path}`);\n }\n return content;\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. Transient workspace DBKs are intentionally Markdown-only: every\n * member must be a valid UTF-8 `.md` file. A missing, unreadable, binary, or\n * differently typed 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 validatedEntries: Array<{ sourcePath: string; containerPath: 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 if (!/\\.md$/iu.test(sourcePath)) {\n throw new Error(\n `The external DBK is corrupt: only Markdown (.md) files are allowed (${sourcePath}).`,\n );\n }\n validatedEntries.push({ sourcePath, containerPath: entry.path });\n }\n\n for (const entry of validatedEntries) {\n const { sourcePath } = entry;\n const data = await source.readFile(entry.containerPath);\n if (data === null) {\n throw new Error(`The external DBK changed while reading: ${sourcePath}`);\n }\n const content = decodeMarkdownFile(data, sourcePath);\n if (sourcePath === sourceDocumentPath) {\n documentContent = content;\n files.push({ kind: 'text', path: targetDocumentPath, content: documentContent });\n continue;\n }\n\n const targetPath =\n assetLayout === 'preserve' ? sourcePath : joinPath(companionPath, sourcePath);\n files.push({ kind: 'text', path: targetPath, content });\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';\nimport { guessMimeType } from './internal/mime.js';\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":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAkEA,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,iBAAiB;AAAA,MACxC,YAAY,QAAQ,cAAc;AAAA,IACpC,CAAC;AAAA,EACH;AAAA,EAEA,MAAa,KAAK,MAA8D;AAC9E,UAAM,YAAY,KAAK,UAAU,IAAI;AACrC,WAAO,KAAK,QAAQ,QAAQ,YAAY;AACtC,YAAM,SAAS,MAAM,KAAK,YAAY,MAAM,GAAG,QAAQ,IAAI,SAAS;AACpE,aAAO,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A,UAAgB;AACd,iBAAW,OAAO,aAAa,OAAO,GAAG;AACvC,YAAI,gBAAgB,GAAG;AAAA,MACzB;AACA,mBAAa,MAAM;AAAA,IACrB;AAAA,EACF;AACF;","names":["state"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
package/dist/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}