import type { Id, Disposable } from "@codesandbox/pitcher-common"; import { SerialQueue } from "@codesandbox/pitcher-common"; import { fs as fsProtocol } from "@codesandbox/pitcher-protocol"; import { MemoryFS } from "../../../common/MemoryFS"; import type { FSErrorEvent, FSSyncEvent, IFSClient, PickRawFsResult } from "../../../interface/clients/IFSClient"; import type { RelativeWorkspacePath, AbsoluteWorkspacePath } from "../../../types"; import type { PitcherMessageHandler } from "../../PitcherMessageHandler"; export * from "../../../common/MemoryFS"; export declare const USER_WORKSPACE_PATH_REGEXP: RegExp; export declare const DOCKER_WORKSPACE_PATH_REGEXP: RegExp; export declare const PITCHER_HOST_WORKSPACE_PATH_REGEXP: RegExp; export declare const DEVCONTAINER_WORKSPACE_PATH_REGEXP: RegExp; export declare class FSClient implements IFSClient { private workspacePath; private userWorkspacePath; private messageHandler; memoryFS: MemoryFS; operationQueue: SerialQueue; private onFSErrorEmitter; onFSError: import("@codesandbox/pitcher-common").Event; private onFSSyncEmitter; onFSSync: import("@codesandbox/pitcher-common").Event; private onPendingOperationsChangeEmitter; onPendingOperationsChange: import("@codesandbox/pitcher-common").Event; readyPromise: Promise; constructor(workspacePath: string, userWorkspacePath: string, messageHandler: PitcherMessageHandler); /** * When you have a path you know is relative, but you want to to ensure the correct format with * prefixed "/" and type safety */ asRelativeWorkspacePath(path: string): `$RELATIVE/${string}`; /** * When you know you have an absolute path, but want to ensure it to be this users workspace and have type safety */ asAbsoluteWorkspacePath(path: string): `$ABSOLUTE/${string}`; /** * When you have a type safe absolute path and want to make it relative */ absoluteToRelativeWorkspacePath(path: AbsoluteWorkspacePath): `$RELATIVE/${string}`; /** * When you have a tpe safe relative path and want to make it absolute to this users workspace path */ relativeToAbsoluteWorkspacePath(path: RelativeWorkspacePath): `$ABSOLUTE/${string}`; resolveRelativeWorkspacePath(path: string): `$RELATIVE/${string}`; resolveAbsoluteWorkspacePath(path: string): `$ABSOLUTE/${string}`; private getPendingOperations; private readFs; resync(): Promise; private applyFSOperation; private createParentDirs; /** * Create a file with the provided name within the directory of the given * parent id. * */ createFile(name: string, parentId: Id): Promise<{ id: Id; filepath: string; }>; isFile(id: Id): boolean; private createNewDirectory; /** * Create a directory with the provided name within the directory of the * given parent id. * */ createDirectory(name: string, parentId: Id): Id; /** * delete a node from the FS * */ deleteNode(id: Id): void; /** * rename a node from the FS * */ move(id: Id, opts: { newName?: string; newParentId?: Id; }): void; /** * Searches for a string literal within the files of a workspace. * Doesn't search the contents of gitignored files. */ search(params: fsProtocol.FSSearchParams): Promise; /** * Searches for a string literal within the files of a workspace. * Doesn't search the contents of gitignored files. */ streamingSearch(params: fsProtocol.FSSearchParams, onMatches: (matches: fsProtocol.StreamingSearchResult[]) => void, abort: Disposable): Promise<{ hitLimit: boolean; }>; /** * Searches for a filepath within the project * Query can be a literal string or a unix-like pattern e.g. *.test.ts */ pathSearch(params: fsProtocol.PathSearchParams): Promise; uploadFile(name: string, content: Uint8Array, parentId: Id): Promise<{ id: Id; filepath: `$RELATIVE/${string}`; }>; download(path?: string): Promise<{ downloadUrl: string; }>; getPathFromId: (id: Id) => `$RELATIVE/${string}` | undefined; getIdFromPath: (path: string) => Id | undefined; private isInWorkspacePath; readFile(path: string): Promise>; readdir(path: string): Promise>; writeFile(path: string, content: Uint8Array, create?: boolean, overwrite?: boolean): Promise>; stat(path: string): Promise>; copy(from: string, to: string, recursive?: boolean, overwrite?: boolean): Promise>; rename(from: string, to: string, overwrite?: boolean): Promise>; remove(path: string, recursive?: boolean): Promise>; mkdir(path: string, recursive?: boolean): Promise>; watch(path: string, options: { readonly recursive?: boolean; readonly excludes?: readonly string[]; }, onEvent: (watchEvent: fsProtocol.FSWatchEvent) => void): Promise<(PickRawFsResult<"fs/watch"> & { type: "error"; }) | { type: "success"; dispose(): void; }>; private handleRawFsResponse; } //# sourceMappingURL=index.d.ts.map