UNPKG

static-browser-server

Version:

A simple service worker used for the static template in sandpack, allowing users to develop websites like they would locally in the browser.

27 lines (26 loc) 948 B
export type FileContent = string | Uint8Array; export type GetFileContentFn = (filepath: string) => Promise<FileContent> | FileContent; export interface IPreviewControllerOptions { baseUrl: string; getFileContent: GetFileContentFn; indexFiles?: string[]; } export declare function normalizeFilepath(filepath: string): string; export declare function joinFilepath(filepath: string, addition: string): string; export declare function getExtension(filepath: string): string; export declare class PreviewController { private baseUrl; private indexFiles; private getFileContent; private initPromise; constructor(options: IPreviewControllerOptions); private getIndexAtPath; private handleWorkerRequest; private getRelayUrl; private _initPreview; /** * Initialize a preview and return the url at which the preview is being served **/ initPreview(): Promise<string>; destroy(): void; }