{"version":3,"file":"assets.cjs","names":[],"sources":["../../src/tabular/assets.ts"],"sourcesContent":["/**\n * The runtime's own assets, which are the other half of working offline.\n *\n * ONNX Runtime Web does **not** embed its WebAssembly binary, not even in\n * the `.bundle` builds. Measured in Chromium: the default entry fetches\n * `ort-wasm-simd-threaded.jsep.wasm` at session creation, and serving the\n * app without that file fails with `Aborted(both async and sync fetching of\n * the wasm failed)` — an error that says nothing about the missing file.\n *\n * So an offline app has to ship those binaries and precache them. This\n * module names them and points the runtime at a local directory.\n *\n * It does **not** import `onnxruntime-web`. An app on the compact route\n * (`CompactPredictor`) has no runtime at all, and a module that imported\n * one at load time would force every consumer of this subpath to install\n * the peer — which is exactly the cost that route exists to avoid. The\n * configured path is remembered here and applied by the ONNX predictor,\n * which imports the runtime only when it actually loads a model.\n */\n\n/**\n * The WebAssembly binaries ONNX Runtime Web may request.\n *\n * Which one is fetched depends on the browser's threading and SIMD support,\n * so an app that must work everywhere ships all of them. Chromium with the\n * default entry point fetched the `jsep` build.\n */\nexport const ORT_WASM_ASSETS: readonly string[] = [\n    \"ort-wasm-simd-threaded.wasm\",\n    \"ort-wasm-simd-threaded.mjs\",\n    \"ort-wasm-simd-threaded.jsep.wasm\",\n    \"ort-wasm-simd-threaded.jsep.mjs\",\n];\n\nlet configuredPath: string | undefined;\n\n/**\n * Point ONNX Runtime Web at locally served WebAssembly binaries.\n *\n * Call once, before creating any predictor.\n *\n * @example\n * ```ts\n * configureOrtAssets(\"/ort/\");\n * const predictor = await TabularPredictor.create(\"/models/classifier.onnx\");\n * ```\n *\n * @param basePath Directory the binaries are served from, with a trailing\n *   slash. Copy them there at build time — for Vite, from\n *   `node_modules/onnxruntime-web/dist/`.\n */\nexport function configureOrtAssets(basePath: string): void {\n    configuredPath = basePath.endsWith(\"/\") ? basePath : `${basePath}/`;\n}\n\n/**\n * Where the runtime's binaries were said to live.\n *\n * Read by the ONNX predictor just before it creates a session, which is\n * the first moment the runtime exists to be configured.\n *\n * @returns The configured directory, or `undefined` when none was set.\n */\nexport function configuredOrtAssetPath(): string | undefined {\n    return configuredPath;\n}\n\n/**\n * The URLs a service worker should precache for offline inference.\n *\n * The model file is not included: it is cached by\n * {@link fetchModelBytes} on first use, under its own bucket.\n *\n * @example\n * ```ts\n * installPrecache([...ortAssetUrls(\"/ort/\"), \"/index.html\"]);\n * ```\n *\n * @param basePath Directory the binaries are served from.\n * @returns Absolute-from-root URLs for every runtime asset.\n */\nexport function ortAssetUrls(basePath: string): string[] {\n    const prefix = basePath.endsWith(\"/\") ? basePath : `${basePath}/`;\n    return ORT_WASM_ASSETS.map((asset) => `${prefix}${asset}`);\n}\n"],"mappings":"AA2BA,IAAa,EAAqC,CAC9C,8BACA,6BACA,mCACA,iCACJ,EAEI,EAiBJ,SAAgB,EAAmB,EAAwB,CACvD,EAAiB,EAAS,SAAS,GAAG,EAAI,EAAW,GAAG,EAAS,EACrE,CAUA,SAAgB,GAA6C,CACzD,OAAO,CACX,CAgBA,SAAgB,EAAa,EAA4B,CACrD,IAAM,EAAS,EAAS,SAAS,GAAG,EAAI,EAAW,GAAG,EAAS,GAC/D,OAAO,EAAgB,IAAK,GAAU,GAAG,IAAS,GAAO,CAC7D"}