/** File/directory metadata returned by a provider's `stat` (null = does not exist). */ export interface FsStat { size: number; isDir: boolean; /** Modification time in ms since epoch (optional). */ mtime?: number; } /** * Async fallback storage for GRE files that are NOT baked into the shipped * gecko.data, mounted under GRE_DIR (/gre). When Gecko opens a /gre path that isn't * already present, the engine resolves it through this provider; paths passed here * are RELATIVE to the mount root (e.g. "modules/Foo.sys.mjs"). Back it with * IndexedDB, OPFS, fetch, … — all methods are genuinely async (the engine's * synchronous read blocks a Gecko worker thread, never the page main thread). */ export interface FsProvider { stat(path: string): Promise; readdir(path: string): Promise; readFile(path: string): Promise; } /** * Read-write async storage for the persistent profile, a separate mount (/profile). * The engine opens a profile file -> the whole file is fetched here on demand (async); * writes accumulate in memory and are flushed back here per-file on fsync/close * (`writeFile` with the full contents). Defaults to OPFS; override with your own * backend, or pass a string path to use OPFS rooted there. Paths are mount-relative. */ export interface ProfileProvider extends FsProvider { writeFile(path: string, data: Uint8Array): Promise; unlink(path: string): Promise; mkdir(path: string): Promise; /** Move from -> to (Gecko writes prefs/sessionstore as temp-then-rename). */ rename(from: string, to: string): Promise; } export interface GeckoOptions { /** * The page canvas the engine composites into. In software mode it receives * BGRA frames blitted via a 2D context. In GPU mode (env.GECKO_GPU set) the * engine instead creates a WebGL2 context on it directly — it must be free of * any other context and is forced to id="screen" (the engine's hardcoded GL * target selector); WebRender presents through an overlaid #glout canvas. */ canvas: HTMLCanvasElement; width?: number; height?: number; /** Extra engine env vars (e.g. MOZ_LOG, GECKO_WASMJIT, GECKO_STYLO_THREADS). */ env?: Record; /** WISP websocket endpoint; Necko fetches http(s):// over it. */ wispUrl?: string; /** * Async fallback for GRE files beyond the baked-in minimal set (mounted at /gre). * Either an FsProvider, or a string OPFS path (-> a built-in OPFS-backed provider * rooted there). Omit for baked-only. */ fs?: FsProvider | string; /** * Persistent profile storage (separate mount at /profile, read-write). Either a * ProfileProvider, or a string OPFS path. Omitted -> a default OPFS provider at * "gecko-profile". (Falls back to ephemeral in-memory if OPFS is unavailable.) */ profile?: ProfileProvider | string; /** Where gecko.wasm + gecko.data are served (URL prefix; default './', relative to the page). */ assetBase?: string; /** Full override of engine-asset location (file -> url); takes precedence over assetBase. */ locateFile?: (file: string) => string; print?: (s: string) => void; printErr?: (s: string) => void; /** Forward mouse/keyboard/wheel from the canvas to the engine (default true). */ forwardInput?: boolean; } export declare class Gecko { private opts; private canvas; private ctx; private gpu; private W; private H; private mod; private cmd; private queue; private running; private painting; private enc; private dec; private blitImg; private blitDst32; private popupCtx; private popupImg; private popupDst32; private popupShown; private detach; constructor(opts: GeckoOptions); /** Instantiate the engine, mount GRE files, and wait until it is ready. */ init(): Promise; /** Navigate the embedded engine to a URL (http(s):// fetched over WISP). */ load(url: string): Promise; /** * Resize the rendering surface. The engine reads the new dimensions from the * next command and reflows/recomposites to fit. Software mode resizes the 2D * canvas backing; GPU mode resizes the canvas box (the transferred #screen * drawing buffer is owned by the engine, so only its CSS size is set here) and * the #glout overlay follows. Safe to call repeatedly at runtime. */ resize(width: number, height: number): Promise; /** Evaluate JS in the chrome context; returns the stringified result. */ evalChrome(js: string): Promise; /** Stop loops, detach input handlers. (The wasm module is not torn down.) */ destroy(): void; private run; private pump; private runCmd; private blit; private drawPopupOverlay; private startPaintLoop; private setupGpuPresent; private syncGpuSize; private mods; private xy; private attachInput; private pasteThenKey; } export default Gecko;