import { type PanelPaletteKey } from './dither'; import type { FrameOSScene, PreviewAssetEntry, PreviewAssetsInfo, PreviewFrame, SceneInfo } from './types'; export interface FrameOSPreviewOptions { /** URL of the module worker script: `/preview-worker.js`. The * frameos.js/frameos.wasm files must live next to it (same directory) — * copy the package's `dist/assets/` folder somewhere same-origin. */ workerUrl: string | URL; /** Render width/height in pixels (the frame's dimensions). */ width: number; height: number; /** The scenes to load — the parsed contents of a scenes.json. */ scenes: FrameOSScene[]; /** Scene to select initially; defaults to the runtime's default scene. */ sceneId?: string; /** Frame name shown in logs. */ name?: string; /** IANA time zone for the simulated frame; defaults to the browser's. */ timeZone?: string; /** Frame settings (app API keys etc.); most previews run fine without. */ settings?: Record; /** Same-origin proxy endpoint for the runtime's HTTP requests. Without it, * scenes fetching external data hit browser CORS limits. */ proxyUrl?: string; /** Canvas to paint frames onto; can also be attached later. */ canvas?: HTMLCanvasElement | null; /** Renders are throttled to one per second unless this is true (see * `onFastRenderRequest` and `setFastMode`). */ fastMode?: boolean; /** Whether apps may save files into the browser asset folder — a frame's * `saveAssets` setting: a boolean, or `{nodeName: boolean}`. Defaults to * true (it is the visitor's own browser storage). */ saveAssets?: boolean | Record; /** Set to false to run with an empty in-memory /srv/assets instead of the * browser's persistent folder. */ browserAssets?: boolean; /** Show frames the way an e-ink panel would: dithered to that panel's * inks or greys (see ./dither). Display only — the scene renders in full * colour either way. Null (the default) paints the frame as rendered. */ panelPalette?: PanelPaletteKey | null; onReady?: (sceneInfo: SceneInfo, assets: PreviewAssetsInfo | null) => void; onFrame?: (frame: PreviewFrame) => void; onState?: (state: Record) => void; onLog?: (message: string) => void; onSceneEvent?: (name: string, payload: Record) => void; onError?: (message: string) => void; /** The scene asked to render every `intervalMs` — faster than the 1 fps * throttle. Fires once per runtime start; call `setFastMode(true)` to let * the scene run at its own pace. */ onFastRenderRequest?: (intervalMs: number) => void; /** Files in the browser asset folder changed: the scene saved something, * or an asset op completed. */ onAssetsChanged?: () => void; } export declare class FrameOSPreview { readonly options: FrameOSPreviewOptions; private worker; private canvas; private pendingFrame; private destroyed; private assetRequests; private nextAssetRequestId; /** Latest scene info from the runtime (set once `ready` fires). */ sceneInfo: SceneInfo | null; /** How the runtime's /srv/assets is backed (set once `ready` fires). */ assetsInfo: PreviewAssetsInfo | null; /** Latest public state of the current scene. */ state: Record; /** The scene currently selected in the runtime. */ currentSceneId: string | null; /** Whether renders may run faster than once per second. */ fastMode: boolean; /** The panel frames are shown through, or null for the true colours. */ panelPalette: PanelPaletteKey | null; constructor(options: FrameOSPreviewOptions); private handleMessage; /** Attach (or replace) the canvas frames are painted onto. */ attachCanvas(canvas: HTMLCanvasElement | null): void; /** Show frames through a panel's palette (or null for true colour), and * repaint the frame already on screen — no re-render needed, the picture * is the same one. */ setPanelPalette(palette: PanelPaletteKey | null): void; private paint; /** Force a render now. */ render(): void; /** Dispatch a scene event (a custom event node's keyword, "button", ...). */ sendEvent(name: string, payload?: Record): void; /** Update the current scene's state fields; renders by default. */ setSceneState(state: Record, render?: boolean): void; /** Switch the runtime to another loaded scene. */ selectScene(sceneId: string): void; /** Let the scene render as often as it asks (true), or throttle it back * to one render per second (false). */ setFastMode(enabled: boolean): void; private assetRequest; /** Every file and folder in the browser asset folder (/srv/assets). */ listAssets(): Promise; /** The bytes of one file in the browser asset folder. */ readAsset(path: string): Promise; /** Write (create or replace) a file; missing parent folders are created. */ writeAsset(path: string, data: ArrayBuffer | Uint8Array | Blob): Promise; /** Create a folder (and its parents). */ createAssetFolder(path: string): Promise; /** Delete a file, or a folder with everything in it. */ deleteAsset(path: string): Promise; /** Empty the folder and regenerate the sample images. */ resetAssets(): Promise; /** Terminate the worker; the instance cannot be reused afterwards. */ destroy(): void; } export declare function createFrameOSPreview(options: FrameOSPreviewOptions): FrameOSPreview;