import { WireReader, WireWriter, BoltFFIModule, instantiateBoltFFI, wireStringSize } from "@boltffi/runtime";
import type { Duration, WireCodec, BoltFFIImports, BoltFFIExports } from "@boltffi/runtime";

const EXPECTED_ABI_VERSION = {{ abi_version }};
const _callback_handle_js_namespace_start = 0x80000000;
const _callback_handle_key = (handle: number): number => handle >>> 0;

let _module: BoltFFIModule;
let _exports: BoltFFIExports;
const _callbackImports: Record<string, WebAssembly.ImportValue> = {};

export default async function init(source: BufferSource | Response): Promise<void> {
  _module = await instantiateBoltFFI(source, EXPECTED_ABI_VERSION, { env: _callbackImports });
  _exports = _module.exports;
}
