import * as Errors from '../../core/Errors.js'; /** * Shared WASM instantiation and memory plumbing. * * @internal */ /** An instantiated WASM module, with helpers for moving bytes across. */ export type Module> = { /** The module's exported functions. */ exports: exports; /** Address of the first byte we may write to. */ heapBase: number; /** * Grows linear memory so `bytes` are available above `heapBase`. * * @throws {@link MemoryError} when the runtime refuses to grow. */ reserve(bytes: number): void; /** * A view over the module's current memory. * * Must be called after {@link Module.reserve} and again after anything that * could grow memory: `WebAssembly.Memory.grow` detaches the previous * `ArrayBuffer`, which silently turns any retained view into a zero-length one. */ view(): Uint8Array; }; /** * Compiles a base64-encoded WASM module without instantiating it. * * @internal */ export declare function compile(base64: string): Promise; /** * Instantiates a compiled WASM module. * * @internal */ export declare function instantiateModule>(compiled: WebAssembly.Module): Promise>; /** * Instantiates a base64-encoded WASM module. * * Always asynchronous: browsers refuse to compile modules larger than a few * kilobytes synchronously on the main thread, so there is no synchronous path to * fall back to. Callers await this once and then call the module synchronously. * * @internal */ export declare function instantiate>(base64: string): Promise>; /** * Memoizes a loader so concurrent callers compile the module once. * * The promise is memoized rather than its result, so a second call made while * the first is still compiling awaits the same compilation. A rejected attempt * is discarded, so a later call can try again. * * @internal */ export declare function memoize(load: () => Promise): () => Promise; /** Thrown when a WASM module cannot grow its memory to the required size. */ export declare class MemoryError extends Errors.BaseError { readonly name = "Wasm.MemoryError"; constructor({ bytes, cause }: { bytes: number; cause: Error; }); } //# sourceMappingURL=instantiate.d.ts.map