@bendyline/docblocks 1.1.2 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +76 -11
- package/dist/chunk-6IYMTYMQ.js +1692 -0
- package/dist/chunk-6IYMTYMQ.js.map +1 -0
- package/dist/chunk-AEHCVWU5.js +25 -0
- package/dist/chunk-AEHCVWU5.js.map +1 -0
- package/dist/chunk-B56KWCSE.js +802 -0
- package/dist/chunk-B56KWCSE.js.map +1 -0
- package/dist/{chunk-ME76RUMR.js → chunk-BNKV7MTO.js} +15 -1
- package/dist/chunk-BNKV7MTO.js.map +1 -0
- package/dist/chunk-BXMF5YQJ.js +149 -0
- package/dist/chunk-BXMF5YQJ.js.map +1 -0
- package/dist/chunk-COYQXQK3.js +1071 -0
- package/dist/chunk-COYQXQK3.js.map +1 -0
- package/dist/chunk-DN7A33LL.js +780 -0
- package/dist/chunk-DN7A33LL.js.map +1 -0
- package/dist/chunk-EZKJZUNJ.js +13 -0
- package/dist/chunk-EZKJZUNJ.js.map +1 -0
- package/dist/chunk-FA7UNOXK.js +20 -0
- package/dist/chunk-FA7UNOXK.js.map +1 -0
- package/dist/chunk-FNW556FN.js +75 -0
- package/dist/chunk-FNW556FN.js.map +1 -0
- package/dist/chunk-GM5YXU4L.js +29 -0
- package/dist/chunk-GM5YXU4L.js.map +1 -0
- package/dist/chunk-JS6XFWQK.js +225 -0
- package/dist/chunk-JS6XFWQK.js.map +1 -0
- package/dist/chunk-MNSZ7EZN.js +111 -0
- package/dist/chunk-MNSZ7EZN.js.map +1 -0
- package/dist/chunk-P3DVZQ6S.js +228 -0
- package/dist/chunk-P3DVZQ6S.js.map +1 -0
- package/dist/chunk-P4WATND4.js +52 -0
- package/dist/chunk-P4WATND4.js.map +1 -0
- package/dist/chunk-RVPGQBWR.js +169 -0
- package/dist/chunk-RVPGQBWR.js.map +1 -0
- package/dist/chunk-U722UUFN.js +9 -0
- package/dist/chunk-U722UUFN.js.map +1 -0
- package/dist/chunk-VTCSF7VS.js +553 -0
- package/dist/chunk-VTCSF7VS.js.map +1 -0
- package/dist/chunk-WJKYY5QR.js +1350 -0
- package/dist/chunk-WJKYY5QR.js.map +1 -0
- package/dist/chunk-XUML3MKV.js +945 -0
- package/dist/chunk-XUML3MKV.js.map +1 -0
- package/dist/document/index.d.ts +358 -0
- package/dist/document/index.js +25 -0
- package/dist/document/index.js.map +1 -0
- package/dist/filesystem/electron.d.ts +73 -0
- package/dist/filesystem/electron.js +17 -0
- package/dist/filesystem/electron.js.map +1 -0
- package/dist/filesystem/index.d.ts +228 -8
- package/dist/filesystem/index.js +133 -6
- package/dist/filesystem/index.js.map +1 -1
- package/dist/filesystem/indexeddb.d.ts +284 -0
- package/dist/filesystem/indexeddb.js +23 -0
- package/dist/filesystem/indexeddb.js.map +1 -0
- package/dist/filesystem/memory.d.ts +152 -0
- package/dist/filesystem/memory.js +13 -0
- package/dist/filesystem/memory.js.map +1 -0
- package/dist/filesystem/native.d.ts +136 -0
- package/dist/filesystem/native.js +28 -0
- package/dist/filesystem/native.js.map +1 -0
- package/dist/host/index.d.ts +32 -6
- package/dist/host/index.js +26 -27
- package/dist/host/index.js.map +1 -1
- package/dist/index.d.ts +14 -9
- package/dist/index.js +204 -8
- package/dist/index.js.map +1 -1
- package/dist/mcp/index.d.ts +33 -0
- package/dist/mcp/index.js +32 -0
- package/dist/mcp/index.js.map +1 -0
- package/dist/mcp/zod.d.ts +5765 -0
- package/dist/mcp/zod.js +724 -0
- package/dist/mcp/zod.js.map +1 -0
- package/dist/share/index.d.ts +43 -0
- package/dist/share/index.js +13 -0
- package/dist/share/index.js.map +1 -0
- package/dist/types-BEg5SQ1_.d.ts +301 -0
- package/dist/types-CX893hgH.d.ts +468 -0
- package/dist/types-CueK0tvU.d.ts +501 -0
- package/dist/vscode/index.d.ts +220 -0
- package/dist/vscode/index.js +383 -0
- package/dist/vscode/index.js.map +1 -0
- package/dist/workspace/index.d.ts +141 -3
- package/dist/workspace/index.js +28 -1
- package/dist/workspace/index.js.map +1 -1
- package/dist/workspace-path-CWVrcuPL.d.ts +21 -0
- package/package.json +50 -5
- package/dist/chunk-GUNM43XZ.js +0 -63
- package/dist/chunk-GUNM43XZ.js.map +0 -1
- package/dist/chunk-IM7LCQJ6.js +0 -850
- package/dist/chunk-IM7LCQJ6.js.map +0 -1
- package/dist/chunk-ME76RUMR.js.map +0 -1
- package/dist/filesystem/electron-provider.d.ts +0 -32
- package/dist/filesystem/electron-provider.d.ts.map +0 -1
- package/dist/filesystem/electron-provider.js +0 -64
- package/dist/filesystem/electron-provider.js.map +0 -1
- package/dist/filesystem/file-media-provider.d.ts +0 -23
- package/dist/filesystem/file-media-provider.d.ts.map +0 -1
- package/dist/filesystem/file-media-provider.js +0 -85
- package/dist/filesystem/file-media-provider.js.map +0 -1
- package/dist/filesystem/filesystem-content-container.d.ts +0 -24
- package/dist/filesystem/filesystem-content-container.d.ts.map +0 -1
- package/dist/filesystem/filesystem-content-container.js +0 -116
- package/dist/filesystem/filesystem-content-container.js.map +0 -1
- package/dist/filesystem/index.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-content-container.d.ts +0 -20
- package/dist/filesystem/indexeddb-content-container.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-content-container.js +0 -93
- package/dist/filesystem/indexeddb-content-container.js.map +0 -1
- package/dist/filesystem/indexeddb-provider.d.ts +0 -32
- package/dist/filesystem/indexeddb-provider.d.ts.map +0 -1
- package/dist/filesystem/indexeddb-provider.js +0 -295
- package/dist/filesystem/indexeddb-provider.js.map +0 -1
- package/dist/filesystem/native-provider.d.ts +0 -45
- package/dist/filesystem/native-provider.d.ts.map +0 -1
- package/dist/filesystem/native-provider.js +0 -336
- package/dist/filesystem/native-provider.js.map +0 -1
- package/dist/filesystem/types.d.ts +0 -50
- package/dist/filesystem/types.d.ts.map +0 -1
- package/dist/filesystem/types.js +0 -8
- package/dist/filesystem/types.js.map +0 -1
- package/dist/host/index.d.ts.map +0 -1
- package/dist/host/types.d.ts +0 -149
- package/dist/host/types.d.ts.map +0 -1
- package/dist/host/types.js +0 -10
- package/dist/host/types.js.map +0 -1
- package/dist/index-pgBHBQ9G.d.ts +0 -213
- package/dist/index.d.ts.map +0 -1
- package/dist/workspace/index.d.ts.map +0 -1
- package/dist/workspace/types.d.ts +0 -29
- package/dist/workspace/types.d.ts.map +0 -1
- package/dist/workspace/types.js +0 -6
- package/dist/workspace/types.js.map +0 -1
- package/dist/workspace/workspace-manager.d.ts +0 -35
- package/dist/workspace/workspace-manager.d.ts.map +0 -1
- package/dist/workspace/workspace-manager.js +0 -82
- package/dist/workspace/workspace-manager.js.map +0 -1
- package/src/filesystem/electron-provider.ts +0 -88
- package/src/filesystem/file-media-provider.ts +0 -103
- package/src/filesystem/filesystem-content-container.ts +0 -126
- package/src/filesystem/index.ts +0 -24
- package/src/filesystem/indexeddb-content-container.ts +0 -104
- package/src/filesystem/indexeddb-provider.ts +0 -345
- package/src/filesystem/native-provider.ts +0 -384
- package/src/filesystem/types.ts +0 -69
- package/src/host/index.ts +0 -47
- package/src/host/types.ts +0 -153
- package/src/index.ts +0 -9
- package/src/workspace/index.ts +0 -10
- package/src/workspace/types.ts +0 -29
- package/src/workspace/workspace-manager.ts +0 -90
|
@@ -0,0 +1 @@
|
|
|
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,kBA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