import { ConnectionConfig, Connection } from './bindings-smoldot-light.js'; import { SmoldotWasmInstance } from './bindings.js'; export { ConnectionConfig, ConnectionError, Connection } from './bindings-smoldot-light.js'; export interface Config { /** * Closure to call when the Wasm instance panics. * * This callback will always be invoked from within a binding called the Wasm instance. * * After this callback has been called, it is forbidden to invoke any function from the Wasm * VM. * * If this callback is called while invoking a function from the Wasm VM, this function will * throw a dummy exception. */ onWasmPanic: (message: string) => void; logCallback: (level: number, target: string, message: string) => void; jsonRpcResponsesNonEmptyCallback: (chainId: number) => void; currentTaskCallback?: (taskName: string | null) => void; cpuRateLimit: number; } /** * Contains functions that the client will use when it needs to leverage the platform. */ export interface PlatformBindings { /** * Base64-decode the given buffer then decompress its content using the inflate algorithm * with zlib header. * * The input is considered trusted. In other words, the implementation doesn't have to * resist malicious input. * * This function is asynchronous because implementations might use the compression streams * Web API, which for whatever reason is asynchronous. */ trustedBase64DecodeAndZlibInflate: (input: string) => Promise; /** * Returns the number of milliseconds since an arbitrary epoch. */ performanceNow: () => number; /** * Fills the given buffer with randomly-generated bytes. */ getRandomValues: (buffer: Uint8Array) => void; /** * The "should periodically yield" setting indicates whether the execution should periodically * yield back control by using `setTimeout(..., 0)`. * * On platforms such as browsers where `setTimeout(..., 0)` takes way more than 0 milliseconds, * this setting should be set to `false`. * * This function registers a callback that is called when the setting should be updated with * a new value. It returns the initial value of the setting and a function used to unregister * the callback. */ registerShouldPeriodicallyYield: (callback: (newValue: boolean) => void) => [boolean, () => void]; /** * Tries to open a new connection using the given configuration. * * @see Connection * @throws {@link ConnectionError} If the multiaddress couldn't be parsed or contains an invalid protocol. */ connect(config: ConnectionConfig): Connection; } export declare function startInstance(config: Config, platformBindings: PlatformBindings): Promise;