diff --git a/dist/src/environment-browser.js b/dist/src/environment-browser.js index 17f5447caf11b153cc117df8549140f05b1b2b84..71a0bc32c0d6eb69026328912248f7d52065770d 100644 --- a/dist/src/environment-browser.js +++ b/dist/src/environment-browser.js @@ -21,3 +21,26 @@ if (environment.resolveUrl === defaultEnvironment.resolveUrl) { }; } // wasm locator must be manually configured +// +// PATCH (banner-studio): install a wasm locator as a side effect of importing +// the browser environment. api.js imports this file (`#register-default- +// environment` under the browser condition) BEFORE wasm.js, which means by +// the time wasm.js runs `await environment.wasmLocator()`, the locator is in +// place. This is the dropflow-documented integration point — we just move it +// from "consumer must call before importing dropflow" to "happens at module +// init under the browser condition". +// +// Why patch rather than configure: Next.js 14.2.x has a regression where +// webpack `experiments.topLevelAwait: true` is ignored, so any locator setup +// that runs after the dropflow chunk loads is too late. Patching guarantees +// ordering at the module-graph level. +if (environment.wasmLocator === defaultEnvironment.wasmLocator) { + environment.wasmLocator = async function () { + const res = await fetch('/dropflow.wasm'); + if (!res.ok) { + throw new Error('dropflow wasm fetch failed: ' + res.status + ' ' + res.statusText); + } + const buf = await res.arrayBuffer(); + return new Uint8Array(buf); + }; +}