export function SAB({ initByteLength, maxByteLength }: { initByteLength?: number; maxByteLength?: number; }): SharedArrayBuffer; export function bootstrap(Worker: T): (scriptURL: string, options: Options) => Promise; export function handler(sab: any, options: any, useAtomics: any): ({ data }: { data: any; }) => Promise; export function post(sab: any, options: any): any[]; export function url(scriptURL: any, reflected: any, options: any): any[]; /** * see https://developer.mozilla.org/en-US/docs/Web/API/ServiceWorkerContainer/register#options */ export type ServiceWorkerOptions = { /** * will use the `serviceWorker` value if that is a `string`, otherwise it refers to where the service worker file is located. */ url?: string; type?: "classic" | "module"; updateViaCache?: "all" | "imports" | "none"; }; export type Options = { /** * invoked when the worker expect a response as `Int32Array` to populate the SharedArrayBuffer with. */ onsync?: (payload: unknown) => Int32Array | Promise; /** * invoked when the worker replies to a `worker.send(data)` call. */ onsend?: (payload: unknown) => unknown | Promise; /** * the WebSocket URL to use for worker <-> server communication. */ ws?: string; /** * defines the initial byte length of the SharedArrayBuffer. */ initByteLength?: number; /** * defines the maximum byte length (growth) of the SharedArrayBuffer. */ maxByteLength?: number; /** * defines the service worker to use as fallback if SharedArrayBuffer is not supported. If not defined, the `async` fallback will be used so that no `sync` operations from the worker will be possible. */ serviceWorker?: string | ServiceWorkerOptions; /** * defines the encoder function to use to encode the result into the SharedArrayBuffer. */ encoder?: typeof encoder; }; import { encoder } from 'reflected-ffi/encoder';