Represents a theme on the file system.

interface VirtualFileSystem {
    addEventListener: <T extends ThemeFSEventName>(
        eventName: T,
        cb: (params: ThemeFSEventPayload<T>) => void,
    ) => void;
    delete: (fileKey: string) => Promise<void>;
    files: Map<string, ThemeAsset>;
    read: (fileKey: string) => Promise<undefined | string | Buffer>;
    ready: () => Promise<void>;
    root: string;
    unsyncedFileKeys: Set<string>;
    write: (asset: ThemeAsset) => Promise<void>;
}

Hierarchy (View Summary)

Properties

addEventListener: <T extends ThemeFSEventName>(
    eventName: T,
    cb: (params: ThemeFSEventPayload<T>) => void,
) => void

Add callbacks to run after certain events are fired.

delete: (fileKey: string) => Promise<void>

Removes a file from the local disk and updates the file system

Type declaration

    • (fileKey: string): Promise<void>
    • Parameters

      • fileKey: string

        The key of the file to remove

      Returns Promise<void>

files: Map<string, ThemeAsset>

Local files.

read: (fileKey: string) => Promise<undefined | string | Buffer>

Reads a file from the local disk and updates the file system Returns a ThemeAsset representing the file that was read Returns undefined if the file does not exist

Type declaration

    • (fileKey: string): Promise<undefined | string | Buffer>
    • Parameters

      • fileKey: string

        The key of the file to read

      Returns Promise<undefined | string | Buffer>

ready: () => Promise<void>

Promise that resolves when all the initial files are found.

root: string

The root path of the theme.

unsyncedFileKeys: Set<string>

File keys that have been modified in memory and are not uploaded yet.

write: (asset: ThemeAsset) => Promise<void>

Writes a file to the local disk and updates the file system

Type declaration

    • (asset: ThemeAsset): Promise<void>
    • Parameters

      • asset: ThemeAsset

        The ThemeAsset representing the file to write

      Returns Promise<void>