import { type MaybePromise } from "maypromise"; /** * WebAssembly インスタンスを初期化するための関数型定義です。 */ export interface IWebAssemblyInstanceInitializer { /** * @param options インポートオブジェクト、または未定義です。 * @returns WebAssembly インスタンスの Promise、またはインスタンスそのものです。 */ (options: WebAssembly.Imports | undefined): MaybePromise; } /** * WebAssembly のソースとして許容される型をまとめた定義です。 */ export type WasmSource = string | ArrayBuffer | ArrayBufferView | MaybePromise | WebAssembly.Module | WebAssembly.Exports | WebAssembly.Instance | WebAssembly.WebAssemblyInstantiatedSource | IWebAssemblyInstanceInitializer; /** * WebAssembly の読み込み時に指定するオプションの型定義です。 */ export type LoadWasmOptions = { /** * インスタンスに渡すインポートオブジェクトです。 */ readonly imports?: WebAssembly.Imports | undefined; /** * 非同期処理を中断するためのシグナルです。 */ readonly signal?: AbortSignal | undefined; }; /** * さまざまなソースから WebAssembly を読み込み、エクスポートを返します。 * * @template TExports エクスポートオブジェクトの型定義です。デフォルトは WebAssembly.Exports です。 * @param source WebAssembly のソース(URL 文字列、バイナリー、Response 等)です。 * @param options インポートやシグナルを制御するオプションです。 * @returns 型定義された WebAssembly のエクスポートを含む Promise です。 * * @example * ``` * import { loadWasm } from "@z-rack/core"; * * // URL から読み込む場合 * const exports = await loadWasm("https://example.com/module.wasm"); * * // バイト配列から読み込む場合 * const bytes = new Uint8Array([0x00, 0x61, 0x73, 0x6d, ...]); * const exports2 = await loadWasm(bytes); * ``` */ export default function loadWasm(source: WasmSource, options?: LoadWasmOptions | undefined): Promise; //# sourceMappingURL=load-wasm.d.ts.map