import type { IBootResult } from "./structures/IBootResult"; import type { IBootTtscOptions } from "./structures/IBootTtscOptions"; /** * Boot a host-built wasm. Re-entrant only if you reuse the same `host`. * * Concurrent calls with the same `(apiName, wasmUrl)` pair share the same * in-flight boot. Calls with the same `apiName` but different `wasmUrl` are * serialized via `bootChainByApiName` so they don't race on the shared * `globalThis[apiName+"Ready"]` resolver slot. A rejection before `go.run` * clears the cache entries so the next call can retry from scratch. A rejection * after `go.run` terminally poisons that API name because JavaScript cannot * stop the old runtime; replace the Worker before retrying. * * **Single-Worker caveat.** Even with the chain, a second boot loaded into the * same Worker after a first boot completes will overlay its Go runtime on top * of the first. `importScripts(wasmExecUrl)` rebinds `globalThis.Go`, and the * first wasm's keepalive goroutine keeps running through the new runtime's * js-bridge tables. The serialization is sufficient for the typical use case * (one boot per Worker over the page's lifetime) but DOES NOT make a Worker * safe to host two wasm instances at once. Create a fresh Worker per concurrent * wasm. * * @evidence contracts/common.md#principled-implementation * The documented Go wasm_exec bridge is installed before streaming * instantiation, and Promise sharing coordinates calls that use its global * readiness slot. This follows the host.Expose integration rather than * inventing a second runtime protocol. * * @evidence contracts/common.md#clear-and-simple-design * The entry owns one attempt's host and cancellation, the per-API chain owns * readiness-slot serialization, and bootTtscOnce owns setup and cleanup. * These separate identities are needed because duplicate calls may join, * distinct binary URLs may queue, and a started runtime cannot be retried. * * @evidence contracts/common.md#prohibited-implementation-shortcuts * The ttsc default API name and Ready/Failed slots are the host protocol, * not consumer or fixture matches. The attempt installs missing Go host * shims and removes only its own failed installation; it does not replace an * existing foreign filesystem. The documented one-runtime-per-Worker * limitation is retained rather than hidden beneath retries after go.run. * * @evidence contracts/common.md#meaningful-documentation * JSDoc explains why same-URL calls share a boot, why API-slot serialization * is needed and why post-start failure requires Worker replacement. Separate * paragraphs state purpose and the shared-runtime caveat under the * documentation skill; option and result interfaces document cancellation * and host ownership. * * @evidence contracts/performance.md#efficient-algorithms * Cache lookup uses normalized URL length U and expected constant-time Map * access; fetch/streaming compilation process the B binary bytes without a * second JavaScript binary buffer. C joined callers add O(C) abort listeners, * and cancellation uses events rather than a polling scan. * * @evidence contracts/performance.md#reuse-equivalent-work * One API/normalized-URL pair shares fetch and instantiation only with the same * runtime-script URL and an identical supplied host. Omitted hosts reuse the * entry's actual host. Per-API Promise * chains serialize access to the global readiness slot; distinct URLs are * distinct boot identities. The URL must identify immutable binary content * for successful-result reuse to remain valid within the Worker lifetime. * * @evidence contracts/performance.md#bound-retention-and-release-resources * Each entry owns its controller, host and result; settlement removes joined * caller listeners and internal cancellation listeners. Successful boot keys, * API chain heads and terminal failures remain until Worker termination, with * no fixed key or retained-byte bound. Failed pre-start entries are removed; * started runtimes cannot be stopped here and require Worker replacement. */ export declare function bootTtsc(options: IBootTtscOptions): Promise;