UNPKG

@minecraft/creator-tools

Version:

Minecraft Creator Tools command line and libraries.

64 lines (63 loc) 3.08 kB
import IFile from "./IFile"; import IStorage, { IFileUpdateEvent } from "./IStorage"; export declare enum StorageProxyCommands { fsExists = "fsExists", fsFolderExists = "fsFolderExists", fsMkdir = "fsMkdir", fsReadUtf8File = "fsReadUtf8File", fsReadFile = "fsReadFile", fsWriteUtf8File = "fsWriteUtf8File", fsWriteFile = "fsWriteFile", fsReaddir = "fsReaddir", fsStat = "fsStat", fsDeleteItem = "fsDeleteItem", getDirname = "getDirname", notifyFileAdded = "notifyFileAdded", notifyFileContentsUpdated = "notifyFileContentsUpdated", notifyFileRemoved = "notifyFileRemoved" } export interface ISubscribersRetriever { getSubscribers(id: string): any[] | undefined; } export default class StorageProxy { private _storage; private _id; isReadOnly: boolean; encodeBinary: boolean; private _subscribersRetriever; private _sendMessage; private _alternateContents; constructor(storage: IStorage, id: string, sendMessage: (sender: any, command: string, id: string, message: any) => void, subscribersRetriever: ISubscribersRetriever); /** * Converts an absolute path (which may include the storage root URI) to a relative path. * The MessageProxyStorage on the webview side sends full paths like "vscode-test-web://mount/subfolder/" * but getFolderFromRelativePath expects paths like "/subfolder/". */ private toRelativePath; registerAlternateContents(storageRelativePath: string, contents: string | Uint8Array): void; clearAlternateContents(storageRelativePath: string): void; onFileAdded(storage: IStorage, file: IFile): void; onFileRemoved(storage: IStorage, path: string): void; onFileContentsUpdated(storage: IStorage, fileEvent: IFileUpdateEvent): void; /** * Normalizes a path/ID by removing trailing slashes for comparison purposes. */ private normalizeId; /** * Checks if an incoming message ID matches this storage proxy. * Returns true if the ID matches exactly or if the ID is a child path of this storage's root. */ private matchesId; processMessage(sender: any, command: string, id: string, data: any): Promise<void>; readOnlyCheck(): void; fileIsContainer(): void; writeUtf8File(sender: any, command: string, requestId: string, data: any): Promise<void>; writeFile(sender: any, command: string, requestId: string, data: any): Promise<void>; readUtf8File(sender: any, command: string, requestId: string, data: any): Promise<void>; readFile(sender: any, command: string, requestId: string, data: any): Promise<void>; createDirectory(sender: any, command: string, requestId: string, data: any): Promise<void>; folderExists(sender: any, command: string, requestId: string, data: any): Promise<void>; readDir(sender: any, command: string, requestId: string, data: any): Promise<void>; stat(sender: any, command: string, requestId: string, data: any): Promise<void>; fileExists(sender: any, command: string, requestId: string, data: any): Promise<void>; }