/** * ClientModuleLoaderImpl — the implementation behind the {@link ClientModuleLoader} * seam. The conceptual contract (lazy CJS model, resolution branch order) is * documented on the package module and the public interfaces in `./index.ts`; * this file owns the state tables and the fetch/execute/materialize machinery. */ import type { ClientModuleLoader, ClientModuleLoaderOptions, ClientModuleRecord, ClientPluginHandoff, DshWindow, WebBootEntry, } from './index.ts' /** A registered-but-unmaterialized bundle: the factory plus its source URL (diagnostics). */ interface RegisteredFactory { factory: ClientPluginHandoff['factory'] url: string } /** Default bundle fetch seam: same-origin fetch().text(). */ const defaultFetchBundle = async (url: string): Promise => { const res = await fetch(url) if (!res.ok) throw new Error(`client-modules: bundle fetch ${url} answered ${String(res.status)}`) return res.text() } /** Default bundle execution seam: a