@preference-sl/pref-configurator-sdk 0.1.2-beta.2 → 0.2.0-beta.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/README.md +15 -5
  2. package/_framework/{PrefConfigurator.Abstractions.m5p9u43rne.wasm → PrefConfigurator.Abstractions.vfbb9c67va.wasm} +0 -0
  3. package/_framework/PrefConfigurator.Abstractions.vfbb9c67va.wasm.br +0 -0
  4. package/_framework/{PrefConfigurator.Abstractions.m5p9u43rne.wasm.gz → PrefConfigurator.Abstractions.vfbb9c67va.wasm.gz} +0 -0
  5. package/_framework/{PrefConfigurator.Application.bb2ale30gh.wasm → PrefConfigurator.Application.9zmjeiiblq.wasm} +0 -0
  6. package/_framework/PrefConfigurator.Application.9zmjeiiblq.wasm.br +0 -0
  7. package/_framework/PrefConfigurator.Application.9zmjeiiblq.wasm.gz +0 -0
  8. package/_framework/{PrefConfigurator.Domain.lz24uq9hxw.wasm → PrefConfigurator.Domain.1q5yhykmld.wasm} +0 -0
  9. package/_framework/PrefConfigurator.Domain.1q5yhykmld.wasm.br +0 -0
  10. package/_framework/PrefConfigurator.Domain.1q5yhykmld.wasm.gz +0 -0
  11. package/_framework/{PrefConfigurator.Infrastructure.p8wrxjw2mh.wasm → PrefConfigurator.Infrastructure.5wgcu6lgap.wasm} +0 -0
  12. package/_framework/PrefConfigurator.Infrastructure.5wgcu6lgap.wasm.br +0 -0
  13. package/_framework/{PrefConfigurator.Infrastructure.p8wrxjw2mh.wasm.gz → PrefConfigurator.Infrastructure.5wgcu6lgap.wasm.gz} +0 -0
  14. package/_framework/PrefConfigurator.Wasm.s037if6n1x.wasm +0 -0
  15. package/_framework/PrefConfigurator.Wasm.s037if6n1x.wasm.br +0 -0
  16. package/_framework/PrefConfigurator.Wasm.s037if6n1x.wasm.gz +0 -0
  17. package/_framework/{System.Private.CoreLib.77dyhxu8ng.wasm → System.Private.CoreLib.3it7p8nh6k.wasm} +0 -0
  18. package/_framework/System.Private.CoreLib.3it7p8nh6k.wasm.br +0 -0
  19. package/_framework/System.Private.CoreLib.3it7p8nh6k.wasm.gz +0 -0
  20. package/_framework/System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm +0 -0
  21. package/_framework/System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm.br +0 -0
  22. package/_framework/System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm.gz +0 -0
  23. package/_framework/dotnet.js +17 -17
  24. package/_framework/dotnet.js.br +0 -0
  25. package/_framework/dotnet.js.gz +0 -0
  26. package/_framework/{dotnet.native.3hup5hq7f6.wasm → dotnet.native.0iyv779ixl.wasm} +0 -0
  27. package/_framework/dotnet.native.0iyv779ixl.wasm.br +0 -0
  28. package/_framework/{dotnet.native.3hup5hq7f6.wasm.gz → dotnet.native.0iyv779ixl.wasm.gz} +0 -0
  29. package/index.d.ts +42 -0
  30. package/index.js +8 -0
  31. package/js/gltf-merger.d.ts +25 -0
  32. package/js/gltf-merger.js +18 -3
  33. package/js/gltf-storage.d.ts +23 -0
  34. package/js/sdk-framework-assets.d.ts +3 -0
  35. package/js/sdk-framework-assets.js +85 -0
  36. package/js/sdk-init.d.ts +39 -0
  37. package/js/sdk-init.js +227 -0
  38. package/js/sdk-worker.d.ts +3 -0
  39. package/js/sdk-worker.js +138 -0
  40. package/package.json +31 -21
  41. package/_framework/PrefConfigurator.Abstractions.m5p9u43rne.wasm.br +0 -0
  42. package/_framework/PrefConfigurator.Application.bb2ale30gh.wasm.br +0 -0
  43. package/_framework/PrefConfigurator.Application.bb2ale30gh.wasm.gz +0 -0
  44. package/_framework/PrefConfigurator.Domain.lz24uq9hxw.wasm.br +0 -0
  45. package/_framework/PrefConfigurator.Domain.lz24uq9hxw.wasm.gz +0 -0
  46. package/_framework/PrefConfigurator.Infrastructure.p8wrxjw2mh.wasm.br +0 -0
  47. package/_framework/PrefConfigurator.Wasm.fm0zddqw93.wasm +0 -0
  48. package/_framework/PrefConfigurator.Wasm.fm0zddqw93.wasm.br +0 -0
  49. package/_framework/PrefConfigurator.Wasm.fm0zddqw93.wasm.gz +0 -0
  50. package/_framework/System.Private.CoreLib.77dyhxu8ng.wasm.br +0 -0
  51. package/_framework/System.Private.CoreLib.77dyhxu8ng.wasm.gz +0 -0
  52. package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm +0 -0
  53. package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm.br +0 -0
  54. package/_framework/System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm.gz +0 -0
  55. package/_framework/dotnet.native.3hup5hq7f6.wasm.br +0 -0
  56. package/main.d.ts +0 -4
  57. package/main.js +0 -2
  58. package/scripts/postinstall.js +0 -128
package/README.md CHANGED
@@ -1,8 +1,18 @@
1
1
  # pref-configurator-sdk
2
2
 
3
- Upon install, \postinstall\ copies into the consumer project:
3
+ Drop-in WebAssembly SDK that runs Preference's product-configurator engine inside the consumer's
4
+ bundler. Requires a browser/worker environment with module Worker support and a bundler that
5
+ respects \
6
+ ew URL(asset, import.meta.url)\ (webpack 5+, Turbopack, Vite, esbuild, Rollup).
4
7
 
5
- - \public/preference-sl/pref-configurator-sdk/_framework\
6
- - \public/preference-sl/pref-configurator-sdk/main.js\ (if not present)
7
- - \public/preference-sl/pref-configurator-sdk/index.demo.html\ (if not present)
8
- - Extra JS under \public/preference-sl/pref-configurator-sdk/\ (without overwriting)
8
+ \\\ s
9
+ import { init } from '@preference-sl/pref-configurator-sdk';
10
+
11
+ const api = await init(envJson);
12
+ const options = await api.GetOptions();
13
+ \\\
14
+
15
+ \init\ boots the runtime in a Web Worker; \_framework/*\ assets are emitted by your bundler
16
+ automatically — no \public/\ copy step or postinstall hook is required. See
17
+ [\docs/wasm-worker-init.md\](https://bitbucket.org/preferencesl/pref-configurator-sdk/src/develop/PrefConfigurator/docs/wasm-worker-init.md)
18
+ for the architecture and migration notes.
@@ -4,7 +4,7 @@
4
4
  var e=!1;const t=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,4,1,96,0,0,3,2,1,0,10,8,1,6,0,6,64,25,11,11])),o=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,15,1,13,0,65,1,253,15,65,2,253,15,253,128,2,11])),n=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,0,0,1,5,1,96,0,1,123,3,2,1,0,10,10,1,8,0,65,0,253,15,253,98,11])),r=Symbol.for("wasm promise_control");function i(e,t){let o=null;const n=new Promise((function(n,r){o={isDone:!1,promise:null,resolve:t=>{o.isDone||(o.isDone=!0,n(t),e&&e())},reject:e=>{o.isDone||(o.isDone=!0,r(e),t&&t())}}}));o.promise=n;const i=n;return i[r]=o,{promise:i,promise_control:o}}function s(e){return e[r]}function a(e){e&&function(e){return void 0!==e[r]}(e)||Be(!1,"Promise is not controllable")}const l="__mono_message__",c=["debug","log","trace","warn","info","error"],d="MONO_WASM: ";let u,f,m,g,p,h;function w(e){g=e}function b(e){if(Pe.diagnosticTracing){const t="function"==typeof e?e():e;console.debug(d+t)}}function y(e,...t){console.info(d+e,...t)}function v(e,...t){console.info(e,...t)}function E(e,...t){console.warn(d+e,...t)}function _(e,...t){if(t&&t.length>0&&t[0]&&"object"==typeof t[0]){if(t[0].silent)return;if(t[0].toString)return void console.error(d+e,t[0].toString())}console.error(d+e,...t)}function x(e,t,o){return function(...n){try{let r=n[0];if(void 0===r)r="undefined";else if(null===r)r="null";else if("function"==typeof r)r=r.toString();else if("string"!=typeof r)try{r=JSON.stringify(r)}catch(e){r=r.toString()}t(o?JSON.stringify({method:e,payload:r,arguments:n.slice(1)}):[e+r,...n.slice(1)])}catch(e){m.error(`proxyConsole failed: ${e}`)}}}function j(e,t,o){f=t,g=e,m={...t};const n=`${o}/console`.replace("https://","wss://").replace("http://","ws://");u=new WebSocket(n),u.addEventListener("error",A),u.addEventListener("close",S),function(){for(const e of c)f[e]=x(`console.${e}`,T,!0)}()}function R(e){let t=30;const o=()=>{u?0==u.bufferedAmount||0==t?(e&&v(e),function(){for(const e of c)f[e]=x(`console.${e}`,m.log,!1)}(),u.removeEventListener("error",A),u.removeEventListener("close",S),u.close(1e3,e),u=void 0):(t--,globalThis.setTimeout(o,100)):e&&m&&m.log(e)};o()}function T(e){u&&u.readyState===WebSocket.OPEN?u.send(e):m.log(e)}function A(e){m.error(`[${g}] proxy console websocket error: ${e}`,e)}function S(e){m.debug(`[${g}] proxy console websocket closed: ${e}`,e)}function D(){Pe.preferredIcuAsset=O(Pe.config);let e="invariant"==Pe.config.globalizationMode;if(!e)if(Pe.preferredIcuAsset)Pe.diagnosticTracing&&b("ICU data archive(s) available, disabling invariant mode");else{if("custom"===Pe.config.globalizationMode||"all"===Pe.config.globalizationMode||"sharded"===Pe.config.globalizationMode){const e="invariant globalization mode is inactive and no ICU data archives are available";throw _(`ERROR: ${e}`),new Error(e)}Pe.diagnosticTracing&&b("ICU data archive(s) not available, using invariant globalization mode"),e=!0,Pe.preferredIcuAsset=null}const t="DOTNET_SYSTEM_GLOBALIZATION_INVARIANT",o=Pe.config.environmentVariables;if(void 0===o[t]&&e&&(o[t]="1"),void 0===o.TZ)try{const e=Intl.DateTimeFormat().resolvedOptions().timeZone||null;e&&(o.TZ=e)}catch(e){y("failed to detect timezone, will fallback to UTC")}}function O(e){var t;if((null===(t=e.resources)||void 0===t?void 0:t.icu)&&"invariant"!=e.globalizationMode){const t=e.applicationCulture||(ke?globalThis.navigator&&globalThis.navigator.languages&&globalThis.navigator.languages[0]:Intl.DateTimeFormat().resolvedOptions().locale),o=e.resources.icu;let n=null;if("custom"===e.globalizationMode){if(o.length>=1)return o[0].name}else t&&"all"!==e.globalizationMode?"sharded"===e.globalizationMode&&(n=function(e){const t=e.split("-")[0];return"en"===t||["fr","fr-FR","it","it-IT","de","de-DE","es","es-ES"].includes(e)?"icudt_EFIGS.dat":["zh","ko","ja"].includes(t)?"icudt_CJK.dat":"icudt_no_CJK.dat"}(t)):n="icudt.dat";if(n)for(let e=0;e<o.length;e++){const t=o[e];if(t.virtualPath===n)return t.name}}return e.globalizationMode="invariant",null}(new Date).valueOf();const C=class{constructor(e){this.url=e}toString(){return this.url}};async function k(e,t){try{const o="function"==typeof globalThis.fetch;if(Se){const n=e.startsWith("file://");if(!n&&o)return globalThis.fetch(e,t||{credentials:"same-origin"});p||(h=Ne.require("url"),p=Ne.require("fs")),n&&(e=h.fileURLToPath(e));const r=await p.promises.readFile(e);return{ok:!0,headers:{length:0,get:()=>null},url:e,arrayBuffer:()=>r,json:()=>JSON.parse(r),text:()=>{throw new Error("NotImplementedException")}}}if(o)return globalThis.fetch(e,t||{credentials:"same-origin"});if("function"==typeof read)return{ok:!0,url:e,headers:{length:0,get:()=>null},arrayBuffer:()=>new Uint8Array(read(e,"binary")),json:()=>JSON.parse(read(e,"utf8")),text:()=>read(e,"utf8")}}catch(t){return{ok:!1,url:e,status:500,headers:{length:0,get:()=>null},statusText:"ERR28: "+t,arrayBuffer:()=>{throw t},json:()=>{throw t},text:()=>{throw t}}}throw new Error("No fetch implementation available")}function I(e){return"string"!=typeof e&&Be(!1,"url must be a string"),!M(e)&&0!==e.indexOf("./")&&0!==e.indexOf("../")&&globalThis.URL&&globalThis.document&&globalThis.document.baseURI&&(e=new URL(e,globalThis.document.baseURI).toString()),e}const U=/^[a-zA-Z][a-zA-Z\d+\-.]*?:\/\//,P=/[a-zA-Z]:[\\/]/;function M(e){return Se||Ie?e.startsWith("/")||e.startsWith("\\")||-1!==e.indexOf("///")||P.test(e):U.test(e)}let L,N=0;const $=[],z=[],W=new Map,F={"js-module-threads":!0,"js-module-runtime":!0,"js-module-dotnet":!0,"js-module-native":!0,"js-module-diagnostics":!0},B={...F,"js-module-library-initializer":!0},V={...F,dotnetwasm:!0,heap:!0,manifest:!0},q={...B,manifest:!0},H={...B,dotnetwasm:!0},J={dotnetwasm:!0,symbols:!0},Z={...B,dotnetwasm:!0,symbols:!0},Q={symbols:!0};function G(e){return!("icu"==e.behavior&&e.name!=Pe.preferredIcuAsset)}function K(e,t,o){null!=t||(t=[]),Be(1==t.length,`Expect to have one ${o} asset in resources`);const n=t[0];return n.behavior=o,X(n),e.push(n),n}function X(e){V[e.behavior]&&W.set(e.behavior,e)}function Y(e){Be(V[e],`Unknown single asset behavior ${e}`);const t=W.get(e);if(t&&!t.resolvedUrl)if(t.resolvedUrl=Pe.locateFile(t.name),F[t.behavior]){const e=ge(t);e?("string"!=typeof e&&Be(!1,"loadBootResource response for 'dotnetjs' type should be a URL string"),t.resolvedUrl=e):t.resolvedUrl=ce(t.resolvedUrl,t.behavior)}else if("dotnetwasm"!==t.behavior)throw new Error(`Unknown single asset behavior ${e}`);return t}function ee(e){const t=Y(e);return Be(t,`Single asset for ${e} not found`),t}let te=!1;async function oe(){if(!te){te=!0,Pe.diagnosticTracing&&b("mono_download_assets");try{const e=[],t=[],o=(e,t)=>{!Z[e.behavior]&&G(e)&&Pe.expected_instantiated_assets_count++,!H[e.behavior]&&G(e)&&(Pe.expected_downloaded_assets_count++,t.push(se(e)))};for(const t of $)o(t,e);for(const e of z)o(e,t);Pe.allDownloadsQueued.promise_control.resolve(),Promise.all([...e,...t]).then((()=>{Pe.allDownloadsFinished.promise_control.resolve()})).catch((e=>{throw Pe.err("Error in mono_download_assets: "+e),Xe(1,e),e})),await Pe.runtimeModuleLoaded.promise;const n=async e=>{const t=await e;if(t.buffer){if(!Z[t.behavior]){t.buffer&&"object"==typeof t.buffer||Be(!1,"asset buffer must be array-like or buffer-like or promise of these"),"string"!=typeof t.resolvedUrl&&Be(!1,"resolvedUrl must be string");const e=t.resolvedUrl,o=await t.buffer,n=new Uint8Array(o);pe(t),await Ue.beforeOnRuntimeInitialized.promise,Ue.instantiate_asset(t,e,n)}}else J[t.behavior]?("symbols"===t.behavior&&(await Ue.instantiate_symbols_asset(t),pe(t)),J[t.behavior]&&++Pe.actual_downloaded_assets_count):(t.isOptional||Be(!1,"Expected asset to have the downloaded buffer"),!H[t.behavior]&&G(t)&&Pe.expected_downloaded_assets_count--,!Z[t.behavior]&&G(t)&&Pe.expected_instantiated_assets_count--)},r=[],i=[];for(const t of e)r.push(n(t));for(const e of t)i.push(n(e));Promise.all(r).then((()=>{Ce||Ue.coreAssetsInMemory.promise_control.resolve()})).catch((e=>{throw Pe.err("Error in mono_download_assets: "+e),Xe(1,e),e})),Promise.all(i).then((async()=>{Ce||(await Ue.coreAssetsInMemory.promise,Ue.allAssetsInMemory.promise_control.resolve())})).catch((e=>{throw Pe.err("Error in mono_download_assets: "+e),Xe(1,e),e}))}catch(e){throw Pe.err("Error in mono_download_assets: "+e),e}}}let ne=!1;function re(){if(ne)return;ne=!0;const e=Pe.config,t=[];if(e.assets)for(const t of e.assets)"object"!=typeof t&&Be(!1,`asset must be object, it was ${typeof t} : ${t}`),"string"!=typeof t.behavior&&Be(!1,"asset behavior must be known string"),"string"!=typeof t.name&&Be(!1,"asset name must be string"),t.resolvedUrl&&"string"!=typeof t.resolvedUrl&&Be(!1,"asset resolvedUrl could be string"),t.hash&&"string"!=typeof t.hash&&Be(!1,"asset resolvedUrl could be string"),t.pendingDownload&&"object"!=typeof t.pendingDownload&&Be(!1,"asset pendingDownload could be object"),t.isCore?$.push(t):z.push(t),X(t);else if(e.resources){const o=e.resources;o.wasmNative||Be(!1,"resources.wasmNative must be defined"),o.jsModuleNative||Be(!1,"resources.jsModuleNative must be defined"),o.jsModuleRuntime||Be(!1,"resources.jsModuleRuntime must be defined"),K(z,o.wasmNative,"dotnetwasm"),K(t,o.jsModuleNative,"js-module-native"),K(t,o.jsModuleRuntime,"js-module-runtime"),o.jsModuleDiagnostics&&K(t,o.jsModuleDiagnostics,"js-module-diagnostics");const n=(e,t,o)=>{const n=e;n.behavior=t,o?(n.isCore=!0,$.push(n)):z.push(n)};if(o.coreAssembly)for(let e=0;e<o.coreAssembly.length;e++)n(o.coreAssembly[e],"assembly",!0);if(o.assembly)for(let e=0;e<o.assembly.length;e++)n(o.assembly[e],"assembly",!o.coreAssembly);if(0!=e.debugLevel&&Pe.isDebuggingSupported()){if(o.corePdb)for(let e=0;e<o.corePdb.length;e++)n(o.corePdb[e],"pdb",!0);if(o.pdb)for(let e=0;e<o.pdb.length;e++)n(o.pdb[e],"pdb",!o.corePdb)}if(e.loadAllSatelliteResources&&o.satelliteResources)for(const e in o.satelliteResources)for(let t=0;t<o.satelliteResources[e].length;t++){const r=o.satelliteResources[e][t];r.culture=e,n(r,"resource",!o.coreAssembly)}if(o.coreVfs)for(let e=0;e<o.coreVfs.length;e++)n(o.coreVfs[e],"vfs",!0);if(o.vfs)for(let e=0;e<o.vfs.length;e++)n(o.vfs[e],"vfs",!o.coreVfs);const r=O(e);if(r&&o.icu)for(let e=0;e<o.icu.length;e++){const t=o.icu[e];t.name===r&&n(t,"icu",!1)}if(o.wasmSymbols)for(let e=0;e<o.wasmSymbols.length;e++)n(o.wasmSymbols[e],"symbols",!1)}if(e.appsettings)for(let t=0;t<e.appsettings.length;t++){const o=e.appsettings[t],n=he(o);"appsettings.json"!==n&&n!==`appsettings.${e.applicationEnvironment}.json`||z.push({name:o,behavior:"vfs",cache:"no-cache",useCredentials:!0})}e.assets=[...$,...z,...t]}async function ie(e){const t=await se(e);return await t.pendingDownloadInternal.response,t.buffer}async function se(e){try{return await ae(e)}catch(t){if(!Pe.enableDownloadRetry)throw t;if(Ie||Se)throw t;if(e.pendingDownload&&e.pendingDownloadInternal==e.pendingDownload)throw t;if(e.resolvedUrl&&-1!=e.resolvedUrl.indexOf("file://"))throw t;if(t&&404==t.status)throw t;e.pendingDownloadInternal=void 0,await Pe.allDownloadsQueued.promise;try{return Pe.diagnosticTracing&&b(`Retrying download '${e.name}'`),await ae(e)}catch(t){return e.pendingDownloadInternal=void 0,await new Promise((e=>globalThis.setTimeout(e,100))),Pe.diagnosticTracing&&b(`Retrying download (2) '${e.name}' after delay`),await ae(e)}}}async function ae(e){for(;L;)await L.promise;try{++N,N==Pe.maxParallelDownloads&&(Pe.diagnosticTracing&&b("Throttling further parallel downloads"),L=i());const t=await async function(e){if(e.pendingDownload&&(e.pendingDownloadInternal=e.pendingDownload),e.pendingDownloadInternal&&e.pendingDownloadInternal.response)return e.pendingDownloadInternal.response;if(e.buffer){const t=await e.buffer;return e.resolvedUrl||(e.resolvedUrl="undefined://"+e.name),e.pendingDownloadInternal={url:e.resolvedUrl,name:e.name,response:Promise.resolve({ok:!0,arrayBuffer:()=>t,json:()=>JSON.parse(new TextDecoder("utf-8").decode(t)),text:()=>{throw new Error("NotImplementedException")},headers:{get:()=>{}}})},e.pendingDownloadInternal.response}const t=e.loadRemote&&Pe.config.remoteSources?Pe.config.remoteSources:[""];let o;for(let n of t){n=n.trim(),"./"===n&&(n="");const t=le(e,n);e.name===t?Pe.diagnosticTracing&&b(`Attempting to download '${t}'`):Pe.diagnosticTracing&&b(`Attempting to download '${t}' for ${e.name}`);try{e.resolvedUrl=t;const n=fe(e);if(e.pendingDownloadInternal=n,o=await n.response,!o||!o.ok)continue;return o}catch(e){o||(o={ok:!1,url:t,status:0,statusText:""+e});continue}}const n=e.isOptional||e.name.match(/\.pdb$/)&&Pe.config.ignorePdbLoadErrors;if(o||Be(!1,`Response undefined ${e.name}`),!n){const t=new Error(`download '${o.url}' for ${e.name} failed ${o.status} ${o.statusText}`);throw t.status=o.status,t}y(`optional download '${o.url}' for ${e.name} failed ${o.status} ${o.statusText}`)}(e);return t?(J[e.behavior]||(e.buffer=await t.arrayBuffer(),++Pe.actual_downloaded_assets_count),e):e}finally{if(--N,L&&N==Pe.maxParallelDownloads-1){Pe.diagnosticTracing&&b("Resuming more parallel downloads");const e=L;L=void 0,e.promise_control.resolve()}}}function le(e,t){let o;return null==t&&Be(!1,`sourcePrefix must be provided for ${e.name}`),e.resolvedUrl?o=e.resolvedUrl:(o=""===t?"assembly"===e.behavior||"pdb"===e.behavior?e.name:"resource"===e.behavior&&e.culture&&""!==e.culture?`${e.culture}/${e.name}`:e.name:t+e.name,o=ce(Pe.locateFile(o),e.behavior)),o&&"string"==typeof o||Be(!1,"attemptUrl need to be path or url string"),o}function ce(e,t){return Pe.modulesUniqueQuery&&q[t]&&(e+=Pe.modulesUniqueQuery),e}let de=0;const ue=new Set;function fe(e){try{e.resolvedUrl||Be(!1,"Request's resolvedUrl must be set");const t=function(e){let t=e.resolvedUrl;if(Pe.loadBootResource){const o=ge(e);if(o instanceof Promise)return o;"string"==typeof o&&(t=o)}const o={};return e.cache?o.cache=e.cache:Pe.config.disableNoCacheFetch||(o.cache="no-cache"),e.useCredentials?o.credentials="include":!Pe.config.disableIntegrityCheck&&e.hash&&(o.integrity=e.hash),Pe.fetch_like(t,o)}(e),o={name:e.name,url:e.resolvedUrl,response:t};return ue.add(e.name),o.response.then((()=>{"assembly"==e.behavior&&Pe.loadedAssemblies.push(e.name),de++,Pe.onDownloadResourceProgress&&Pe.onDownloadResourceProgress(de,ue.size)})),o}catch(t){const o={ok:!1,url:e.resolvedUrl,status:500,statusText:"ERR29: "+t,arrayBuffer:()=>{throw t},json:()=>{throw t}};return{name:e.name,url:e.resolvedUrl,response:Promise.resolve(o)}}}const me={resource:"assembly",assembly:"assembly",pdb:"pdb",icu:"globalization",vfs:"configuration",manifest:"manifest",dotnetwasm:"dotnetwasm","js-module-dotnet":"dotnetjs","js-module-native":"dotnetjs","js-module-runtime":"dotnetjs","js-module-threads":"dotnetjs"};function ge(e){var t;if(Pe.loadBootResource){const o=null!==(t=e.hash)&&void 0!==t?t:"",n=e.resolvedUrl,r=me[e.behavior];if(r){const t=Pe.loadBootResource(r,e.name,n,o,e.behavior);return"string"==typeof t?I(t):t}}}function pe(e){e.pendingDownloadInternal=null,e.pendingDownload=null,e.buffer=null,e.moduleExports=null}function he(e){let t=e.lastIndexOf("/");return t>=0&&t++,e.substring(t)}async function we(e){e&&await Promise.all((null!=e?e:[]).map((e=>async function(e){try{const t=e.name;if(!e.moduleExports){const o=ce(Pe.locateFile(t),"js-module-library-initializer");Pe.diagnosticTracing&&b(`Attempting to import '${o}' for ${e}`),e.moduleExports=await import(/*! webpackIgnore: true */o)}Pe.libraryInitializers.push({scriptName:t,exports:e.moduleExports})}catch(t){E(`Failed to import library initializer '${e}': ${t}`)}}(e))))}async function be(e,t){if(!Pe.libraryInitializers)return;const o=[];for(let n=0;n<Pe.libraryInitializers.length;n++){const r=Pe.libraryInitializers[n];r.exports[e]&&o.push(ye(r.scriptName,e,(()=>r.exports[e](...t))))}await Promise.all(o)}async function ye(e,t,o){try{await o()}catch(o){throw E(`Failed to invoke '${t}' on library initializer '${e}': ${o}`),Xe(1,o),o}}function ve(e,t){if(e===t)return e;const o={...t};return void 0!==o.assets&&o.assets!==e.assets&&(o.assets=[...e.assets||[],...o.assets||[]]),void 0!==o.resources&&(o.resources=_e(e.resources||{assembly:[],jsModuleNative:[],jsModuleRuntime:[],wasmNative:[]},o.resources)),void 0!==o.environmentVariables&&(o.environmentVariables={...e.environmentVariables||{},...o.environmentVariables||{}}),void 0!==o.runtimeOptions&&o.runtimeOptions!==e.runtimeOptions&&(o.runtimeOptions=[...e.runtimeOptions||[],...o.runtimeOptions||[]]),Object.assign(e,o)}function Ee(e,t){if(e===t)return e;const o={...t};return o.config&&(e.config||(e.config={}),o.config=ve(e.config,o.config)),Object.assign(e,o)}function _e(e,t){if(e===t)return e;const o={...t};return void 0!==o.coreAssembly&&(o.coreAssembly=[...e.coreAssembly||[],...o.coreAssembly||[]]),void 0!==o.assembly&&(o.assembly=[...e.assembly||[],...o.assembly||[]]),void 0!==o.lazyAssembly&&(o.lazyAssembly=[...e.lazyAssembly||[],...o.lazyAssembly||[]]),void 0!==o.corePdb&&(o.corePdb=[...e.corePdb||[],...o.corePdb||[]]),void 0!==o.pdb&&(o.pdb=[...e.pdb||[],...o.pdb||[]]),void 0!==o.jsModuleWorker&&(o.jsModuleWorker=[...e.jsModuleWorker||[],...o.jsModuleWorker||[]]),void 0!==o.jsModuleNative&&(o.jsModuleNative=[...e.jsModuleNative||[],...o.jsModuleNative||[]]),void 0!==o.jsModuleDiagnostics&&(o.jsModuleDiagnostics=[...e.jsModuleDiagnostics||[],...o.jsModuleDiagnostics||[]]),void 0!==o.jsModuleRuntime&&(o.jsModuleRuntime=[...e.jsModuleRuntime||[],...o.jsModuleRuntime||[]]),void 0!==o.wasmSymbols&&(o.wasmSymbols=[...e.wasmSymbols||[],...o.wasmSymbols||[]]),void 0!==o.wasmNative&&(o.wasmNative=[...e.wasmNative||[],...o.wasmNative||[]]),void 0!==o.icu&&(o.icu=[...e.icu||[],...o.icu||[]]),void 0!==o.satelliteResources&&(o.satelliteResources=function(e,t){if(e===t)return e;for(const o in t)e[o]=[...e[o]||[],...t[o]||[]];return e}(e.satelliteResources||{},o.satelliteResources||{})),void 0!==o.modulesAfterConfigLoaded&&(o.modulesAfterConfigLoaded=[...e.modulesAfterConfigLoaded||[],...o.modulesAfterConfigLoaded||[]]),void 0!==o.modulesAfterRuntimeReady&&(o.modulesAfterRuntimeReady=[...e.modulesAfterRuntimeReady||[],...o.modulesAfterRuntimeReady||[]]),void 0!==o.extensions&&(o.extensions={...e.extensions||{},...o.extensions||{}}),void 0!==o.vfs&&(o.vfs=[...e.vfs||[],...o.vfs||[]]),Object.assign(e,o)}function xe(){const e=Pe.config;if(e.environmentVariables=e.environmentVariables||{},e.runtimeOptions=e.runtimeOptions||[],e.resources=e.resources||{assembly:[],jsModuleNative:[],jsModuleWorker:[],jsModuleRuntime:[],wasmNative:[],vfs:[],satelliteResources:{}},e.assets){Pe.diagnosticTracing&&b("config.assets is deprecated, use config.resources instead");for(const t of e.assets){const o={};switch(t.behavior){case"assembly":o.assembly=[t];break;case"pdb":o.pdb=[t];break;case"resource":o.satelliteResources={},o.satelliteResources[t.culture]=[t];break;case"icu":o.icu=[t];break;case"symbols":o.wasmSymbols=[t];break;case"vfs":o.vfs=[t];break;case"dotnetwasm":o.wasmNative=[t];break;case"js-module-threads":o.jsModuleWorker=[t];break;case"js-module-runtime":o.jsModuleRuntime=[t];break;case"js-module-native":o.jsModuleNative=[t];break;case"js-module-diagnostics":o.jsModuleDiagnostics=[t];break;case"js-module-dotnet":break;default:throw new Error(`Unexpected behavior ${t.behavior} of asset ${t.name}`)}_e(e.resources,o)}}e.debugLevel,e.applicationEnvironment||(e.applicationEnvironment="Production"),e.applicationCulture&&(e.environmentVariables.LANG=`${e.applicationCulture}.UTF-8`),Ue.diagnosticTracing=Pe.diagnosticTracing=!!e.diagnosticTracing,Ue.waitForDebugger=e.waitForDebugger,Pe.maxParallelDownloads=e.maxParallelDownloads||Pe.maxParallelDownloads,Pe.enableDownloadRetry=void 0!==e.enableDownloadRetry?e.enableDownloadRetry:Pe.enableDownloadRetry}let je=!1;async function Re(e){var t;if(je)return void await Pe.afterConfigLoaded.promise;let o;try{if(e.configSrc||Pe.config&&0!==Object.keys(Pe.config).length&&(Pe.config.assets||Pe.config.resources)||(e.configSrc="dotnet.boot.js"),o=e.configSrc,je=!0,o&&(Pe.diagnosticTracing&&b("mono_wasm_load_config"),await async function(e){const t=e.configSrc,o=Pe.locateFile(t);let n=null;void 0!==Pe.loadBootResource&&(n=Pe.loadBootResource("manifest",t,o,"","manifest"));let r,i=null;if(n)if("string"==typeof n)n.includes(".json")?(i=await s(I(n)),r=await Ae(i)):r=(await import(I(n))).config;else{const e=await n;"function"==typeof e.json?(i=e,r=await Ae(i)):r=e.config}else o.includes(".json")?(i=await s(ce(o,"manifest")),r=await Ae(i)):r=(await import(ce(o,"manifest"))).config;function s(e){return Pe.fetch_like(e,{method:"GET",credentials:"include",cache:"no-cache"})}Pe.config.applicationEnvironment&&(r.applicationEnvironment=Pe.config.applicationEnvironment),ve(Pe.config,r)}(e)),xe(),await we(null===(t=Pe.config.resources)||void 0===t?void 0:t.modulesAfterConfigLoaded),await be("onRuntimeConfigLoaded",[Pe.config]),e.onConfigLoaded)try{await e.onConfigLoaded(Pe.config,Le),xe()}catch(e){throw _("onConfigLoaded() failed",e),e}xe(),Pe.afterConfigLoaded.promise_control.resolve(Pe.config)}catch(t){const n=`Failed to load config file ${o} ${t} ${null==t?void 0:t.stack}`;throw Pe.config=e.config=Object.assign(Pe.config,{message:n,error:t,isError:!0}),Xe(1,new Error(n)),t}}function Te(){return!!globalThis.navigator&&(Pe.isChromium||Pe.isFirefox)}async function Ae(e){const t=Pe.config,o=await e.json();t.applicationEnvironment||o.applicationEnvironment||(o.applicationEnvironment=e.headers.get("Blazor-Environment")||e.headers.get("DotNet-Environment")||void 0),o.environmentVariables||(o.environmentVariables={});const n=e.headers.get("DOTNET-MODIFIABLE-ASSEMBLIES");n&&(o.environmentVariables.DOTNET_MODIFIABLE_ASSEMBLIES=n);const r=e.headers.get("ASPNETCORE-BROWSER-TOOLS");return r&&(o.environmentVariables.__ASPNETCORE_BROWSER_TOOLS=r),o}"function"!=typeof importScripts||globalThis.onmessage||(globalThis.dotnetSidecar=!0);const Se="object"==typeof process&&"object"==typeof process.versions&&"string"==typeof process.versions.node,De="function"==typeof importScripts,Oe=De&&"undefined"!=typeof dotnetSidecar,Ce=De&&!Oe,ke="object"==typeof window||De&&!Se,Ie=!ke&&!Se;let Ue={},Pe={},Me={},Le={},Ne={},$e=!1;const ze={},We={config:ze},Fe={mono:{},binding:{},internal:Ne,module:We,loaderHelpers:Pe,runtimeHelpers:Ue,diagnosticHelpers:Me,api:Le};function Be(e,t){if(e)return;const o="Assert failed: "+("function"==typeof t?t():t),n=new Error(o);_(o,n),Ue.nativeAbort(n)}function Ve(){return void 0!==Pe.exitCode}function qe(){return Ue.runtimeReady&&!Ve()}function He(){Ve()&&Be(!1,`.NET runtime already exited with ${Pe.exitCode} ${Pe.exitReason}. You can use runtime.runMain() which doesn't exit the runtime.`),Ue.runtimeReady||Be(!1,".NET runtime didn't start yet. Please call dotnet.create() first.")}function Je(){ke&&(globalThis.addEventListener("unhandledrejection",et),globalThis.addEventListener("error",tt))}let Ze,Qe;function Ge(e){Qe&&Qe(e),Xe(e,Pe.exitReason)}function Ke(e){Ze&&Ze(e||Pe.exitReason),Xe(1,e||Pe.exitReason)}function Xe(t,o){var n,r;const i=o&&"object"==typeof o;t=i&&"number"==typeof o.status?o.status:void 0===t?-1:t;const s=i&&"string"==typeof o.message?o.message:""+o;(o=i?o:Ue.ExitStatus?function(e,t){const o=new Ue.ExitStatus(e);return o.message=t,o.toString=()=>t,o}(t,s):new Error("Exit with code "+t+" "+s)).status=t,o.message||(o.message=s);const a=""+(o.stack||(new Error).stack);try{Object.defineProperty(o,"stack",{get:()=>a})}catch(e){}const l=!!o.silent;if(o.silent=!0,Ve())Pe.diagnosticTracing&&b("mono_exit called after exit");else{try{We.onAbort==Ke&&(We.onAbort=Ze),We.onExit==Ge&&(We.onExit=Qe),ke&&(globalThis.removeEventListener("unhandledrejection",et),globalThis.removeEventListener("error",tt)),Ue.runtimeReady?(Ue.jiterpreter_dump_stats&&Ue.jiterpreter_dump_stats(!1),0===t&&(null===(n=Pe.config)||void 0===n?void 0:n.interopCleanupOnExit)&&Ue.forceDisposeProxies(!0,!0),e&&0!==t&&(null===(r=Pe.config)||void 0===r||r.dumpThreadsOnNonZeroExit)):(Pe.diagnosticTracing&&b(`abort_startup, reason: ${o}`),function(e){Pe.allDownloadsQueued.promise_control.reject(e),Pe.allDownloadsFinished.promise_control.reject(e),Pe.afterConfigLoaded.promise_control.reject(e),Pe.wasmCompilePromise.promise_control.reject(e),Pe.runtimeModuleLoaded.promise_control.reject(e),Ue.dotnetReady&&(Ue.dotnetReady.promise_control.reject(e),Ue.afterInstantiateWasm.promise_control.reject(e),Ue.beforePreInit.promise_control.reject(e),Ue.afterPreInit.promise_control.reject(e),Ue.afterPreRun.promise_control.reject(e),Ue.beforeOnRuntimeInitialized.promise_control.reject(e),Ue.afterOnRuntimeInitialized.promise_control.reject(e),Ue.afterPostRun.promise_control.reject(e))}(o))}catch(e){E("mono_exit A failed",e)}try{l||(function(e,t){if(0!==e&&t){const e=Ue.ExitStatus&&t instanceof Ue.ExitStatus?b:_;"string"==typeof t?e(t):(void 0===t.stack&&(t.stack=(new Error).stack+""),t.message?e(Ue.stringify_as_error_with_stack?Ue.stringify_as_error_with_stack(t.message+"\n"+t.stack):t.message+"\n"+t.stack):e(JSON.stringify(t)))}!Ce&&Pe.config&&(Pe.config.logExitCode?Pe.config.forwardConsoleLogsToWS?R("WASM EXIT "+e):v("WASM EXIT "+e):Pe.config.forwardConsoleLogsToWS&&R())}(t,o),function(e){if(ke&&!Ce&&Pe.config&&Pe.config.appendElementOnExit&&document){const t=document.createElement("label");t.id="tests_done",0!==e&&(t.style.background="red"),t.innerHTML=""+e,document.body.appendChild(t)}}(t))}catch(e){E("mono_exit B failed",e)}Pe.exitCode=t,Pe.exitReason||(Pe.exitReason=o),!Ce&&Ue.runtimeReady&&We.runtimeKeepalivePop()}if(Pe.config&&Pe.config.asyncFlushOnExit&&0===t)throw(async()=>{try{await async function(){try{const e=await import(/*! webpackIgnore: true */"process"),t=e=>new Promise(((t,o)=>{e.on("error",o),e.end("","utf8",t)})),o=t(e.stderr),n=t(e.stdout);let r;const i=new Promise((e=>{r=setTimeout((()=>e("timeout")),1e3)}));await Promise.race([Promise.all([n,o]),i]),clearTimeout(r)}catch(e){_(`flushing std* streams failed: ${e}`)}}()}finally{Ye(t,o)}})(),o;Ye(t,o)}function Ye(e,t){if(Ue.runtimeReady&&Ue.nativeExit)try{Ue.nativeExit(e)}catch(e){!Ue.ExitStatus||e instanceof Ue.ExitStatus||E("set_exit_code_and_quit_now failed: "+e.toString())}if(0!==e||!ke)throw Se&&Ne.process?Ne.process.exit(e):Ue.quit&&Ue.quit(e,t),t}function et(e){ot(e,e.reason,"rejection")}function tt(e){ot(e,e.error,"error")}function ot(e,t,o){e.preventDefault();try{t||(t=new Error("Unhandled "+o)),void 0===t.stack&&(t.stack=(new Error).stack),t.stack=t.stack+"",t.silent||(_("Unhandled error:",t),Xe(1,t))}catch(e){}}!function(e){if($e)throw new Error("Loader module already loaded");$e=!0,Ue=e.runtimeHelpers,Pe=e.loaderHelpers,Me=e.diagnosticHelpers,Le=e.api,Ne=e.internal,Object.assign(Le,{INTERNAL:Ne,invokeLibraryInitializers:be}),Object.assign(e.module,{config:ve(ze,{environmentVariables:{}})});const r={mono_wasm_bindings_is_ready:!1,config:e.module.config,diagnosticTracing:!1,nativeAbort:e=>{throw e||new Error("abort")},nativeExit:e=>{throw new Error("exit:"+e)}},l={gitHash:"b16286c2284fecf303dbc12a0bb152476d662e44",config:e.module.config,diagnosticTracing:!1,maxParallelDownloads:16,enableDownloadRetry:!0,_loaded_files:[],loadedFiles:[],loadedAssemblies:[],libraryInitializers:[],workerNextNumber:1,actual_downloaded_assets_count:0,actual_instantiated_assets_count:0,expected_downloaded_assets_count:0,expected_instantiated_assets_count:0,afterConfigLoaded:i(),allDownloadsQueued:i(),allDownloadsFinished:i(),wasmCompilePromise:i(),runtimeModuleLoaded:i(),loadingWorkers:i(),is_exited:Ve,is_runtime_running:qe,assert_runtime_running:He,mono_exit:Xe,createPromiseController:i,getPromiseController:s,assertIsControllablePromise:a,mono_download_assets:oe,resolve_single_asset_path:ee,setup_proxy_console:j,set_thread_prefix:w,installUnhandledErrorHandler:Je,retrieve_asset_download:ie,invokeLibraryInitializers:be,isDebuggingSupported:Te,exceptions:t,simd:n,relaxedSimd:o};Object.assign(Ue,r),Object.assign(Pe,l)}(Fe);let nt,rt,it,st=!1,at=!1;async function lt(e){if(!at){if(at=!0,ke&&Pe.config.forwardConsoleLogsToWS&&void 0!==globalThis.WebSocket&&j("main",globalThis.console,globalThis.location.origin),We||Be(!1,"Null moduleConfig"),Pe.config||Be(!1,"Null moduleConfig.config"),"function"==typeof e){const t=e(Fe.api);if(t.ready)throw new Error("Module.ready couldn't be redefined.");Object.assign(We,t),Ee(We,t)}else{if("object"!=typeof e)throw new Error("Can't use moduleFactory callback of createDotnetRuntime function.");Ee(We,e)}await async function(e){if(Se){const e=await import(/*! webpackIgnore: true */"process"),t=14;if(e.versions.node.split(".")[0]<t)throw new Error(`NodeJS at '${e.execPath}' has too low version '${e.versions.node}', please use at least ${t}. See also https://aka.ms/dotnet-wasm-features`)}const t=/*! webpackIgnore: true */import.meta.url,o=t.indexOf("?");var n;if(o>0&&(Pe.modulesUniqueQuery=t.substring(o)),Pe.scriptUrl=t.replace(/\\/g,"/").replace(/[?#].*/,""),Pe.scriptDirectory=(n=Pe.scriptUrl).slice(0,n.lastIndexOf("/"))+"/",Pe.locateFile=e=>"URL"in globalThis&&globalThis.URL!==C?new URL(e,Pe.scriptDirectory).toString():M(e)?e:Pe.scriptDirectory+e,Pe.fetch_like=k,Pe.out=console.log,Pe.err=console.error,Pe.onDownloadResourceProgress=e.onDownloadResourceProgress,ke&&globalThis.navigator){const e=globalThis.navigator,t=e.userAgentData&&e.userAgentData.brands;t&&t.length>0?Pe.isChromium=t.some((e=>"Google Chrome"===e.brand||"Microsoft Edge"===e.brand||"Chromium"===e.brand)):e.userAgent&&(Pe.isChromium=e.userAgent.includes("Chrome"),Pe.isFirefox=e.userAgent.includes("Firefox"))}Ne.require=Se?await import(/*! webpackIgnore: true */"module").then((e=>e.createRequire(/*! webpackIgnore: true */import.meta.url))):Promise.resolve((()=>{throw new Error("require not supported")})),void 0===globalThis.URL&&(globalThis.URL=C)}(We)}}async function ct(e){return await lt(e),Ze=We.onAbort,Qe=We.onExit,We.onAbort=Ke,We.onExit=Ge,We.ENVIRONMENT_IS_PTHREAD?async function(){(function(){const e=new MessageChannel,t=e.port1,o=e.port2;t.addEventListener("message",(e=>{var n,r;n=JSON.parse(e.data.config),r=JSON.parse(e.data.monoThreadInfo),st?Pe.diagnosticTracing&&b("mono config already received"):(ve(Pe.config,n),Ue.monoThreadInfo=r,xe(),Pe.diagnosticTracing&&b("mono config received"),st=!0,Pe.afterConfigLoaded.promise_control.resolve(Pe.config),ke&&n.forwardConsoleLogsToWS&&void 0!==globalThis.WebSocket&&Pe.setup_proxy_console("worker-idle",console,globalThis.location.origin)),t.close(),o.close()}),{once:!0}),t.start(),self.postMessage({[l]:{monoCmd:"preload",port:o}},[o])})(),await Pe.afterConfigLoaded.promise,function(){const e=Pe.config;e.assets||Be(!1,"config.assets must be defined");for(const t of e.assets)X(t),Q[t.behavior]&&z.push(t)}(),setTimeout((async()=>{try{await oe()}catch(e){Xe(1,e)}}),0);const e=dt(),t=await Promise.all(e);return await ut(t),We}():async function(){var e;await Re(We),re();const t=dt();(async function(){try{const e=ee("dotnetwasm");await se(e),e&&e.pendingDownloadInternal&&e.pendingDownloadInternal.response||Be(!1,"Can't load dotnet.native.wasm");const t=await e.pendingDownloadInternal.response,o=t.headers&&t.headers.get?t.headers.get("Content-Type"):void 0;let n;if("function"==typeof WebAssembly.compileStreaming&&"application/wasm"===o)n=await WebAssembly.compileStreaming(t);else{ke&&"application/wasm"!==o&&E('WebAssembly resource does not have the expected content type "application/wasm", so falling back to slower ArrayBuffer instantiation.');const e=await t.arrayBuffer();Pe.diagnosticTracing&&b("instantiate_wasm_module buffered"),n=Ie?await Promise.resolve(new WebAssembly.Module(e)):await WebAssembly.compile(e)}e.pendingDownloadInternal=null,e.pendingDownload=null,e.buffer=null,e.moduleExports=null,Pe.wasmCompilePromise.promise_control.resolve(n)}catch(e){Pe.wasmCompilePromise.promise_control.reject(e)}})(),setTimeout((async()=>{try{D(),await oe()}catch(e){Xe(1,e)}}),0);const o=await Promise.all(t);return await ut(o),await Ue.dotnetReady.promise,await we(null===(e=Pe.config.resources)||void 0===e?void 0:e.modulesAfterRuntimeReady),await be("onRuntimeReady",[Fe.api]),Le}()}function dt(){const e=ee("js-module-runtime"),t=ee("js-module-native");if(nt&&rt)return[nt,rt,it];"object"==typeof e.moduleExports?nt=e.moduleExports:(Pe.diagnosticTracing&&b(`Attempting to import '${e.resolvedUrl}' for ${e.name}`),nt=import(/*! webpackIgnore: true */e.resolvedUrl)),"object"==typeof t.moduleExports?rt=t.moduleExports:(Pe.diagnosticTracing&&b(`Attempting to import '${t.resolvedUrl}' for ${t.name}`),rt=import(/*! webpackIgnore: true */t.resolvedUrl));const o=Y("js-module-diagnostics");return o&&("object"==typeof o.moduleExports?it=o.moduleExports:(Pe.diagnosticTracing&&b(`Attempting to import '${o.resolvedUrl}' for ${o.name}`),it=import(/*! webpackIgnore: true */o.resolvedUrl))),[nt,rt,it]}async function ut(e){const{initializeExports:t,initializeReplacements:o,configureRuntimeStartup:n,configureEmscriptenStartup:r,configureWorkerStartup:i,setRuntimeGlobals:s,passEmscriptenInternals:a}=e[0],{default:l}=e[1],c=e[2];s(Fe),t(Fe),c&&c.setRuntimeGlobals(Fe),await n(We),Pe.runtimeModuleLoaded.promise_control.resolve(),l((e=>(Object.assign(We,{ready:e.ready,__dotnet_runtime:{initializeReplacements:o,configureEmscriptenStartup:r,configureWorkerStartup:i,passEmscriptenInternals:a}}),We))).catch((e=>{if(e.message&&e.message.toLowerCase().includes("out of memory"))throw new Error(".NET runtime has failed to start, because too much memory was requested. Please decrease the memory by adjusting EmccMaximumHeapSize. See also https://aka.ms/dotnet-wasm-features");throw e}))}const ft=new class{withModuleConfig(e){try{return Ee(We,e),this}catch(e){throw Xe(1,e),e}}withOnConfigLoaded(e){try{return Ee(We,{onConfigLoaded:e}),this}catch(e){throw Xe(1,e),e}}withConsoleForwarding(){try{return ve(ze,{forwardConsoleLogsToWS:!0}),this}catch(e){throw Xe(1,e),e}}withExitOnUnhandledError(){try{return ve(ze,{exitOnUnhandledError:!0}),Je(),this}catch(e){throw Xe(1,e),e}}withAsyncFlushOnExit(){try{return ve(ze,{asyncFlushOnExit:!0}),this}catch(e){throw Xe(1,e),e}}withExitCodeLogging(){try{return ve(ze,{logExitCode:!0}),this}catch(e){throw Xe(1,e),e}}withElementOnExit(){try{return ve(ze,{appendElementOnExit:!0}),this}catch(e){throw Xe(1,e),e}}withInteropCleanupOnExit(){try{return ve(ze,{interopCleanupOnExit:!0}),this}catch(e){throw Xe(1,e),e}}withDumpThreadsOnNonZeroExit(){try{return ve(ze,{dumpThreadsOnNonZeroExit:!0}),this}catch(e){throw Xe(1,e),e}}withWaitingForDebugger(e){try{return ve(ze,{waitForDebugger:e}),this}catch(e){throw Xe(1,e),e}}withInterpreterPgo(e,t){try{return ve(ze,{interpreterPgo:e,interpreterPgoSaveDelay:t}),ze.runtimeOptions?ze.runtimeOptions.push("--interp-pgo-recording"):ze.runtimeOptions=["--interp-pgo-recording"],this}catch(e){throw Xe(1,e),e}}withConfig(e){try{return ve(ze,e),this}catch(e){throw Xe(1,e),e}}withConfigSrc(e){try{return e&&"string"==typeof e||Be(!1,"must be file path or URL"),Ee(We,{configSrc:e}),this}catch(e){throw Xe(1,e),e}}withVirtualWorkingDirectory(e){try{return e&&"string"==typeof e||Be(!1,"must be directory path"),ve(ze,{virtualWorkingDirectory:e}),this}catch(e){throw Xe(1,e),e}}withEnvironmentVariable(e,t){try{const o={};return o[e]=t,ve(ze,{environmentVariables:o}),this}catch(e){throw Xe(1,e),e}}withEnvironmentVariables(e){try{return e&&"object"==typeof e||Be(!1,"must be dictionary object"),ve(ze,{environmentVariables:e}),this}catch(e){throw Xe(1,e),e}}withDiagnosticTracing(e){try{return"boolean"!=typeof e&&Be(!1,"must be boolean"),ve(ze,{diagnosticTracing:e}),this}catch(e){throw Xe(1,e),e}}withDebugging(e){try{return null!=e&&"number"==typeof e||Be(!1,"must be number"),ve(ze,{debugLevel:e}),this}catch(e){throw Xe(1,e),e}}withApplicationArguments(...e){try{return e&&Array.isArray(e)||Be(!1,"must be array of strings"),ve(ze,{applicationArguments:e}),this}catch(e){throw Xe(1,e),e}}withRuntimeOptions(e){try{return e&&Array.isArray(e)||Be(!1,"must be array of strings"),ze.runtimeOptions?ze.runtimeOptions.push(...e):ze.runtimeOptions=e,this}catch(e){throw Xe(1,e),e}}withMainAssembly(e){try{return ve(ze,{mainAssemblyName:e}),this}catch(e){throw Xe(1,e),e}}withApplicationArgumentsFromQuery(){try{if(!globalThis.window)throw new Error("Missing window to the query parameters from");if(void 0===globalThis.URLSearchParams)throw new Error("URLSearchParams is supported");const e=new URLSearchParams(globalThis.window.location.search).getAll("arg");return this.withApplicationArguments(...e)}catch(e){throw Xe(1,e),e}}withApplicationEnvironment(e){try{return ve(ze,{applicationEnvironment:e}),this}catch(e){throw Xe(1,e),e}}withApplicationCulture(e){try{return ve(ze,{applicationCulture:e}),this}catch(e){throw Xe(1,e),e}}withResourceLoader(e){try{return Pe.loadBootResource=e,this}catch(e){throw Xe(1,e),e}}async download(){try{await async function(){lt(We),await Re(We),re(),D(),oe(),await Pe.allDownloadsFinished.promise}()}catch(e){throw Xe(1,e),e}}async create(){try{return this.instance||(this.instance=await async function(){return await ct(We),Fe.api}()),this.instance}catch(e){throw Xe(1,e),e}}async run(){try{return We.config||Be(!1,"Null moduleConfig.config"),this.instance||await this.create(),this.instance.runMainAndExit()}catch(e){throw Xe(1,e),e}}},mt=Xe,gt=ct;Ie||"function"==typeof globalThis.URL||Be(!1,"This browser/engine doesn't support URL API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"),"function"!=typeof globalThis.BigInt64Array&&Be(!1,"This browser/engine doesn't support BigInt64Array API. Please use a modern version. See also https://aka.ms/dotnet-wasm-features"),ft.withConfig(/*json-start*/{
5
5
  "mainAssemblyName": "PrefConfigurator.Wasm",
6
6
  "resources": {
7
- "hash": "sha256-X3F0fzQQ3A0zLxLAk+FVNJSo7TiDDRyc5dfHJBP/Apk=",
7
+ "hash": "sha256-46kwE7wdDdsd6k1wdaIXipgpc78pQgSVu5tJfiuXdr0=",
8
8
  "jsModuleNative": [
9
9
  {
10
10
  "name": "dotnet.native.5hvkdrpygk.js"
@@ -17,8 +17,8 @@ var e=!1;const t=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,
17
17
  ],
18
18
  "wasmNative": [
19
19
  {
20
- "name": "dotnet.native.3hup5hq7f6.wasm",
21
- "integrity": "sha256-h8+JKvc1j5VjNaZJLLDVMU7OmviKqCrxSx53uslezeE=",
20
+ "name": "dotnet.native.0iyv779ixl.wasm",
21
+ "integrity": "sha256-mEwuLQW/KRuuE6MNjlruifGSdI3GHhibcAUB8zEFV1w=",
22
22
  "cache": "force-cache"
23
23
  }
24
24
  ],
@@ -45,14 +45,14 @@ var e=!1;const t=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,
45
45
  "coreAssembly": [
46
46
  {
47
47
  "virtualPath": "System.Private.CoreLib.wasm",
48
- "name": "System.Private.CoreLib.77dyhxu8ng.wasm",
49
- "integrity": "sha256-rdOXc+RwjcnD1PYWzVIB6XHgk4L7KhHPqKoqpe+hm6w=",
48
+ "name": "System.Private.CoreLib.3it7p8nh6k.wasm",
49
+ "integrity": "sha256-Gxr+++ToWVs+h3Pl7CzB2ove+Fkx6RcpnJkcKfQwVSY=",
50
50
  "cache": "force-cache"
51
51
  },
52
52
  {
53
53
  "virtualPath": "System.Runtime.InteropServices.JavaScript.wasm",
54
- "name": "System.Runtime.InteropServices.JavaScript.hz5gi57d06.wasm",
55
- "integrity": "sha256-TbhoRbWuiNlFx+JYBrWtRMviHxqVWPlB0/FfOOGDpuo=",
54
+ "name": "System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm",
55
+ "integrity": "sha256-Y56bTziS4Ca0cuHsDzlnY6yScxov1z048h11vB1MNQw=",
56
56
  "cache": "force-cache"
57
57
  }
58
58
  ],
@@ -233,32 +233,32 @@ var e=!1;const t=async()=>WebAssembly.validate(new Uint8Array([0,97,115,109,1,0,
233
233
  },
234
234
  {
235
235
  "virtualPath": "PrefConfigurator.Abstractions.wasm",
236
- "name": "PrefConfigurator.Abstractions.m5p9u43rne.wasm",
237
- "integrity": "sha256-mkW/hoKEUagxFUdi+PFnERMBZ50Tz53irRqVhjglE/8=",
236
+ "name": "PrefConfigurator.Abstractions.vfbb9c67va.wasm",
237
+ "integrity": "sha256-q4ezuL7sLHx2hILXOfWaeVfS/NTpzKnVh8qa/IwTcxI=",
238
238
  "cache": "force-cache"
239
239
  },
240
240
  {
241
241
  "virtualPath": "PrefConfigurator.Application.wasm",
242
- "name": "PrefConfigurator.Application.bb2ale30gh.wasm",
243
- "integrity": "sha256-N4cH+ci4u3UaBn4SAE3sQz+prllVs7/7JNZDUHcBF6I=",
242
+ "name": "PrefConfigurator.Application.9zmjeiiblq.wasm",
243
+ "integrity": "sha256-FTHdaatuGaMLbzNmGsvmKn140ZT22xfIn72TQqRK8qU=",
244
244
  "cache": "force-cache"
245
245
  },
246
246
  {
247
247
  "virtualPath": "PrefConfigurator.Domain.wasm",
248
- "name": "PrefConfigurator.Domain.lz24uq9hxw.wasm",
249
- "integrity": "sha256-38Gc6GoHD2ngrUvCoP8guNsuLK51jctH0dDoVcrerbo=",
248
+ "name": "PrefConfigurator.Domain.1q5yhykmld.wasm",
249
+ "integrity": "sha256-h3UKFjOCY47LQ4sNDkzgSbmhWBKdhQM49VaC/ItMIHY=",
250
250
  "cache": "force-cache"
251
251
  },
252
252
  {
253
253
  "virtualPath": "PrefConfigurator.Infrastructure.wasm",
254
- "name": "PrefConfigurator.Infrastructure.p8wrxjw2mh.wasm",
255
- "integrity": "sha256-+Ui0z6Zph4dg+E5Zb0JSC85TjiNWf0aYDaZi39o2yQ0=",
254
+ "name": "PrefConfigurator.Infrastructure.5wgcu6lgap.wasm",
255
+ "integrity": "sha256-exmob8tcuw36ALetOGusxL9OhXhcyQPGmLS6AdodJ14=",
256
256
  "cache": "force-cache"
257
257
  },
258
258
  {
259
259
  "virtualPath": "PrefConfigurator.Wasm.wasm",
260
- "name": "PrefConfigurator.Wasm.fm0zddqw93.wasm",
261
- "integrity": "sha256-5w41tg22OuwYDQ3YNkAhDm4JpHCt0vx4LyNd77Ze1VA=",
260
+ "name": "PrefConfigurator.Wasm.s037if6n1x.wasm",
261
+ "integrity": "sha256-DBn5D7ffna5tj3MPt9IaAENucSqtamP7uNQas5MsHS8=",
262
262
  "cache": "force-cache"
263
263
  },
264
264
  {
Binary file
Binary file
package/index.d.ts ADDED
@@ -0,0 +1,42 @@
1
+ // PrefConfigurator WASM SDK — package entry point types.
2
+
3
+ export { init, type InitOptions, type SdkApi, type SdkLifecycle } from "./js/sdk-init";
4
+ export {
5
+ bindApi,
6
+ ensureOk,
7
+ parse,
8
+ type BoundApi,
9
+ type EnvJson,
10
+ type ErrorInfo,
11
+ type JsInteropApiRaw,
12
+ type OperationResult,
13
+ type RawOperation,
14
+ // Domain DTO re-exports — keep this surface in sync with prefconfigurator-api.d.ts.
15
+ type CadRendererData,
16
+ type CreateItemResponse,
17
+ type DimensionsResponse,
18
+ type EnhancedOptionInfo,
19
+ type EnhancedOptionList,
20
+ type HcProductStatusResult,
21
+ type ImageType,
22
+ type ModelImageConfig,
23
+ type OptionInfo,
24
+ type OptionList,
25
+ type OptionValueInfo,
26
+ type Scene,
27
+ type SceneFloor,
28
+ type SceneMaterial,
29
+ type ScenePlane,
30
+ type SceneTexCoord,
31
+ type SceneWallData,
32
+ type SetDimensionValueRequest,
33
+ type SetDimensionsResponse,
34
+ type SetOptionValueBatchResult,
35
+ type SetOptionValueRequest,
36
+ type SetOptionValueResponse,
37
+ type SetOptionsResponse,
38
+ type UsdImagesModel,
39
+ type UsdImagesRequest,
40
+ type UsdVariantSet,
41
+ type ViewMode,
42
+ } from "./js/prefconfigurator-api";
package/index.js ADDED
@@ -0,0 +1,8 @@
1
+ // PrefConfigurator WASM SDK — package entry point.
2
+ //
3
+ // `init(env)` is the recommended entry: it boots the runtime in a Web Worker and
4
+ // returns a typed proxy. `bindApi` / `ensureOk` / `parse` are kept for callers that
5
+ // drive dotnet.js directly.
6
+
7
+ export { init } from "./js/sdk-init.js";
8
+ export { bindApi, ensureOk, parse } from "./js/prefconfigurator-api.js";
@@ -0,0 +1,25 @@
1
+ // Type declarations for the gltf-merger bridge.
2
+ // Used by C# via [JSImport] (GltfMergerRepository); rarely needed by JS consumers directly.
3
+
4
+ export interface GltfMergeResult {
5
+ success: boolean;
6
+ error?: string | null;
7
+ [extra: string]: unknown;
8
+ }
9
+
10
+ export declare function mergeModels(
11
+ modelA: ArrayBuffer | Uint8Array,
12
+ modelB: ArrayBuffer | Uint8Array,
13
+ sceneWallDataStr: string,
14
+ buildWallDataStr: string,
15
+ materials: string,
16
+ materialAssignment: string,
17
+ textureRootPath: string,
18
+ binary: boolean,
19
+ ): Promise<GltfMergeResult>;
20
+
21
+ export declare function applyWallMaterials(
22
+ modelBuffer: ArrayBuffer | Uint8Array,
23
+ wallMaterialDataJson: string,
24
+ textureRootPath: string,
25
+ ): Promise<GltfMergeResult>;
package/js/gltf-merger.js CHANGED
@@ -26,7 +26,11 @@ async function loadCreateModuleFactory() {
26
26
 
27
27
  for (const candidatePath of candidatePaths) {
28
28
  try {
29
- const module = await import(candidatePath);
29
+ // webpackIgnore / @vite-ignore: this dynamic import is resolved at runtime
30
+ // by the candidate path (or by the __PREF_GLTF_MERGER_WASM_PATH override),
31
+ // not by the bundler. Without these comments webpack 5 would emit a warning
32
+ // and Vite would fail to find the module at build time.
33
+ const module = await import(/* webpackIgnore: true */ /* @vite-ignore */ candidatePath);
30
34
  if (typeof module.default === "function") {
31
35
  createModuleFactory = module.default;
32
36
  return createModuleFactory;
@@ -42,14 +46,25 @@ async function loadCreateModuleFactory() {
42
46
  async function getModule() {
43
47
  if (!moduleInstance) {
44
48
  const createModule = await loadCreateModuleFactory();
45
- moduleInstance = await createModule({
49
+ // Resolve the .wasm sibling. By default Emscripten asks for "PrefGltfMergerWasm.wasm"
50
+ // relative to its own .js URL — that breaks under bundlers (webpack/Vite/Rspack) that
51
+ // hash both files independently. When the SDK runs through sdk-worker.js, the host
52
+ // sets `globalThis.__PREF_GLTF_MERGER_WASM_BIN_PATH` to the bundler-emitted .wasm URL
53
+ // and we wire it through Module.locateFile here.
54
+ const wasmBinPath = globalThis.__PREF_GLTF_MERGER_WASM_BIN_PATH;
55
+ const moduleConfig = {
46
56
  onAbort: (what) => {
47
57
  console.error("[gltf-merger] WASM abort:", what);
48
58
  },
49
59
  printErr: (...args) => {
50
60
  console.error("[gltf-merger][wasm]", ...args);
51
61
  }
52
- }); // esto inicializa el WASM
62
+ };
63
+ if (typeof wasmBinPath === "string" && wasmBinPath) {
64
+ moduleConfig.locateFile = (path) =>
65
+ path && path.endsWith(".wasm") ? wasmBinPath : path;
66
+ }
67
+ moduleInstance = await createModule(moduleConfig); // esto inicializa el WASM
53
68
  }
54
69
  return moduleInstance;
55
70
  }
@@ -0,0 +1,23 @@
1
+ // Type declarations for the gltf-storage IndexedDB helper.
2
+ //
3
+ // Exposed both from C# via [JSImport] (used by IndexedDBRepository) and as an ESM module
4
+ // for consumers that want to read cached glTF blobs from the main thread without going
5
+ // through the WASM engine. Both contexts share the same IndexedDB by name.
6
+
7
+ export interface GltfRecord {
8
+ id: string;
9
+ data: string;
10
+ expirationTimeStamp?: number;
11
+ [extra: string]: unknown;
12
+ }
13
+
14
+ export declare function initDb(dbName: string, storeName: string): Promise<void>;
15
+ export declare function saveModel(modelData: string, storeName: string): Promise<void>;
16
+ export declare function loadModel(modelId: string, storeName: string | undefined): Promise<GltfRecord | null>;
17
+ export declare function getAllModels(storeName: string): Promise<string>;
18
+ export declare function deleteModel(modelId: string, storeName: string): Promise<void>;
19
+ export declare function clearAll(storeName: string): Promise<void>;
20
+ export declare function cleanExpiredModels(storeName: string): Promise<void>;
21
+ export declare function downloadFileFromBytes(bytes: ArrayBuffer | Uint8Array, filename: string, mimeType?: string): void;
22
+ export declare function closeDb(): void;
23
+ export declare function deleteDatabase(dbName: string): Promise<void>;
@@ -0,0 +1,3 @@
1
+ // Generated at SDK pack time — see scripts/Pack-Wasm.ps1.
2
+ // Maps each _framework/* asset name to the bundler-emitted URL string.
3
+ export declare const FRAMEWORK_ASSETS: Readonly<Record<string, string>>;
@@ -0,0 +1,85 @@
1
+ // AUTO-GENERATED by scripts/Pack-Wasm.ps1 — do not edit by hand.
2
+ // Maps each _framework/* asset name to the URL produced by the consumer's bundler.
3
+ //
4
+ // IMPORTANT — bundler invariant:
5
+ // The expression `new URL(string_literal, import.meta.url)` MUST appear unchained.
6
+ // webpack 5's URLPlugin pattern-matches the AST node and emits the asset target;
7
+ // chaining `.href` (or any property access) makes the matcher reject the node and
8
+ // webpack silently does not emit the file. Vite and esbuild behave the same way.
9
+ // We store URL instances here and coerce them to strings via String(url) at
10
+ // the postMessage boundary in sdk-init.js — that path is bulletproof against
11
+ // webpack's URL wrapper objects whose enumerable own .href getter would
12
+ // otherwise leak a non-cloneable native function into structuredClone.
13
+
14
+ export const FRAMEWORK_ASSETS = Object.freeze({
15
+ "dotnet.js": new URL("../_framework/dotnet.js", import.meta.url),
16
+ "dotnet.native.0iyv779ixl.wasm": new URL("../_framework/dotnet.native.0iyv779ixl.wasm", import.meta.url),
17
+ "dotnet.native.5hvkdrpygk.js": new URL("../_framework/dotnet.native.5hvkdrpygk.js", import.meta.url),
18
+ "dotnet.runtime.2zl32tp6ah.js": new URL("../_framework/dotnet.runtime.2zl32tp6ah.js", import.meta.url),
19
+ "icudt_CJK.tjcz0u77k5.dat": new URL("../_framework/icudt_CJK.tjcz0u77k5.dat", import.meta.url),
20
+ "icudt_EFIGS.tptq2av103.dat": new URL("../_framework/icudt_EFIGS.tptq2av103.dat", import.meta.url),
21
+ "icudt_no_CJK.lfu7j35m59.dat": new URL("../_framework/icudt_no_CJK.lfu7j35m59.dat", import.meta.url),
22
+ "Microsoft.Extensions.Caching.Abstractions.xqpx5xxjzl.wasm": new URL("../_framework/Microsoft.Extensions.Caching.Abstractions.xqpx5xxjzl.wasm", import.meta.url),
23
+ "Microsoft.Extensions.Caching.Memory.q78n7r2wee.wasm": new URL("../_framework/Microsoft.Extensions.Caching.Memory.q78n7r2wee.wasm", import.meta.url),
24
+ "Microsoft.Extensions.Configuration.Abstractions.ugxmsyl8r9.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.Abstractions.ugxmsyl8r9.wasm", import.meta.url),
25
+ "Microsoft.Extensions.Configuration.Binder.u7uig3v6zu.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.Binder.u7uig3v6zu.wasm", import.meta.url),
26
+ "Microsoft.Extensions.Configuration.bx39a9eeta.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.bx39a9eeta.wasm", import.meta.url),
27
+ "Microsoft.Extensions.Configuration.CommandLine.rwfx1dpj0f.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.CommandLine.rwfx1dpj0f.wasm", import.meta.url),
28
+ "Microsoft.Extensions.Configuration.EnvironmentVariables.4iqygerjsu.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.EnvironmentVariables.4iqygerjsu.wasm", import.meta.url),
29
+ "Microsoft.Extensions.Configuration.FileExtensions.gkccepp1zw.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.FileExtensions.gkccepp1zw.wasm", import.meta.url),
30
+ "Microsoft.Extensions.Configuration.Json.wulbkczaua.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.Json.wulbkczaua.wasm", import.meta.url),
31
+ "Microsoft.Extensions.Configuration.UserSecrets.3hquxzl9oa.wasm": new URL("../_framework/Microsoft.Extensions.Configuration.UserSecrets.3hquxzl9oa.wasm", import.meta.url),
32
+ "Microsoft.Extensions.DependencyInjection.Abstractions.tnr9bu0qg4.wasm": new URL("../_framework/Microsoft.Extensions.DependencyInjection.Abstractions.tnr9bu0qg4.wasm", import.meta.url),
33
+ "Microsoft.Extensions.DependencyInjection.npo4ctt27h.wasm": new URL("../_framework/Microsoft.Extensions.DependencyInjection.npo4ctt27h.wasm", import.meta.url),
34
+ "Microsoft.Extensions.Diagnostics.Abstractions.o01zsa67a9.wasm": new URL("../_framework/Microsoft.Extensions.Diagnostics.Abstractions.o01zsa67a9.wasm", import.meta.url),
35
+ "Microsoft.Extensions.Diagnostics.bwnulo9rzd.wasm": new URL("../_framework/Microsoft.Extensions.Diagnostics.bwnulo9rzd.wasm", import.meta.url),
36
+ "Microsoft.Extensions.FileProviders.Abstractions.73fjqjp4yj.wasm": new URL("../_framework/Microsoft.Extensions.FileProviders.Abstractions.73fjqjp4yj.wasm", import.meta.url),
37
+ "Microsoft.Extensions.FileProviders.Physical.xb79vbn663.wasm": new URL("../_framework/Microsoft.Extensions.FileProviders.Physical.xb79vbn663.wasm", import.meta.url),
38
+ "Microsoft.Extensions.FileSystemGlobbing.vnq2oqa19f.wasm": new URL("../_framework/Microsoft.Extensions.FileSystemGlobbing.vnq2oqa19f.wasm", import.meta.url),
39
+ "Microsoft.Extensions.Hosting.Abstractions.wdrg1gt8sg.wasm": new URL("../_framework/Microsoft.Extensions.Hosting.Abstractions.wdrg1gt8sg.wasm", import.meta.url),
40
+ "Microsoft.Extensions.Hosting.qbcheecaev.wasm": new URL("../_framework/Microsoft.Extensions.Hosting.qbcheecaev.wasm", import.meta.url),
41
+ "Microsoft.Extensions.Http.efsqq4vcly.wasm": new URL("../_framework/Microsoft.Extensions.Http.efsqq4vcly.wasm", import.meta.url),
42
+ "Microsoft.Extensions.Logging.Abstractions.hvjrczjl5y.wasm": new URL("../_framework/Microsoft.Extensions.Logging.Abstractions.hvjrczjl5y.wasm", import.meta.url),
43
+ "Microsoft.Extensions.Logging.ai6yh3gwys.wasm": new URL("../_framework/Microsoft.Extensions.Logging.ai6yh3gwys.wasm", import.meta.url),
44
+ "Microsoft.Extensions.Logging.Configuration.o5xjnd00ty.wasm": new URL("../_framework/Microsoft.Extensions.Logging.Configuration.o5xjnd00ty.wasm", import.meta.url),
45
+ "Microsoft.Extensions.Logging.Debug.wt9hqm6pwc.wasm": new URL("../_framework/Microsoft.Extensions.Logging.Debug.wt9hqm6pwc.wasm", import.meta.url),
46
+ "Microsoft.Extensions.Logging.EventLog.n0xbuqnamh.wasm": new URL("../_framework/Microsoft.Extensions.Logging.EventLog.n0xbuqnamh.wasm", import.meta.url),
47
+ "Microsoft.Extensions.Logging.EventSource.79232rb50z.wasm": new URL("../_framework/Microsoft.Extensions.Logging.EventSource.79232rb50z.wasm", import.meta.url),
48
+ "Microsoft.Extensions.Options.0xyfq7w7oa.wasm": new URL("../_framework/Microsoft.Extensions.Options.0xyfq7w7oa.wasm", import.meta.url),
49
+ "Microsoft.Extensions.Options.ConfigurationExtensions.i146gqqpbz.wasm": new URL("../_framework/Microsoft.Extensions.Options.ConfigurationExtensions.i146gqqpbz.wasm", import.meta.url),
50
+ "Microsoft.Extensions.Primitives.l6yivxpywg.wasm": new URL("../_framework/Microsoft.Extensions.Primitives.l6yivxpywg.wasm", import.meta.url),
51
+ "PrefConfigurator.Abstractions.vfbb9c67va.wasm": new URL("../_framework/PrefConfigurator.Abstractions.vfbb9c67va.wasm", import.meta.url),
52
+ "PrefConfigurator.Application.9zmjeiiblq.wasm": new URL("../_framework/PrefConfigurator.Application.9zmjeiiblq.wasm", import.meta.url),
53
+ "PrefConfigurator.Domain.1q5yhykmld.wasm": new URL("../_framework/PrefConfigurator.Domain.1q5yhykmld.wasm", import.meta.url),
54
+ "PrefConfigurator.Infrastructure.5wgcu6lgap.wasm": new URL("../_framework/PrefConfigurator.Infrastructure.5wgcu6lgap.wasm", import.meta.url),
55
+ "PrefConfigurator.Wasm.s037if6n1x.wasm": new URL("../_framework/PrefConfigurator.Wasm.s037if6n1x.wasm", import.meta.url),
56
+ "System.0x1wb7tfot.wasm": new URL("../_framework/System.0x1wb7tfot.wasm", import.meta.url),
57
+ "System.Collections.Concurrent.j3bbs5wmlv.wasm": new URL("../_framework/System.Collections.Concurrent.j3bbs5wmlv.wasm", import.meta.url),
58
+ "System.Collections.NonGeneric.yqu01kezsn.wasm": new URL("../_framework/System.Collections.NonGeneric.yqu01kezsn.wasm", import.meta.url),
59
+ "System.Collections.q5k866g8l0.wasm": new URL("../_framework/System.Collections.q5k866g8l0.wasm", import.meta.url),
60
+ "System.Collections.Specialized.bpdebmac44.wasm": new URL("../_framework/System.Collections.Specialized.bpdebmac44.wasm", import.meta.url),
61
+ "System.ComponentModel.Primitives.03lga6t30g.wasm": new URL("../_framework/System.ComponentModel.Primitives.03lga6t30g.wasm", import.meta.url),
62
+ "System.ComponentModel.TypeConverter.evmd54h9ff.wasm": new URL("../_framework/System.ComponentModel.TypeConverter.evmd54h9ff.wasm", import.meta.url),
63
+ "System.ComponentModel.xmxjt0ntly.wasm": new URL("../_framework/System.ComponentModel.xmxjt0ntly.wasm", import.meta.url),
64
+ "System.Console.n25kw3pp6f.wasm": new URL("../_framework/System.Console.n25kw3pp6f.wasm", import.meta.url),
65
+ "System.Diagnostics.DiagnosticSource.w6foamen3a.wasm": new URL("../_framework/System.Diagnostics.DiagnosticSource.w6foamen3a.wasm", import.meta.url),
66
+ "System.Diagnostics.EventLog.r3m23h8juo.wasm": new URL("../_framework/System.Diagnostics.EventLog.r3m23h8juo.wasm", import.meta.url),
67
+ "System.IO.FileSystem.Watcher.eb5dfvbj5s.wasm": new URL("../_framework/System.IO.FileSystem.Watcher.eb5dfvbj5s.wasm", import.meta.url),
68
+ "System.IO.Pipelines.pwfw0zwx98.wasm": new URL("../_framework/System.IO.Pipelines.pwfw0zwx98.wasm", import.meta.url),
69
+ "System.Linq.l0hidjun71.wasm": new URL("../_framework/System.Linq.l0hidjun71.wasm", import.meta.url),
70
+ "System.Memory.60lsd7b7gy.wasm": new URL("../_framework/System.Memory.60lsd7b7gy.wasm", import.meta.url),
71
+ "System.Net.Http.1erjtemsp4.wasm": new URL("../_framework/System.Net.Http.1erjtemsp4.wasm", import.meta.url),
72
+ "System.Net.Http.Json.5ycgf70349.wasm": new URL("../_framework/System.Net.Http.Json.5ycgf70349.wasm", import.meta.url),
73
+ "System.Net.Primitives.yl1uus6nzv.wasm": new URL("../_framework/System.Net.Primitives.yl1uus6nzv.wasm", import.meta.url),
74
+ "System.ObjectModel.lpjdvx9u1s.wasm": new URL("../_framework/System.ObjectModel.lpjdvx9u1s.wasm", import.meta.url),
75
+ "System.Private.CoreLib.3it7p8nh6k.wasm": new URL("../_framework/System.Private.CoreLib.3it7p8nh6k.wasm", import.meta.url),
76
+ "System.Private.Uri.i08y2naikb.wasm": new URL("../_framework/System.Private.Uri.i08y2naikb.wasm", import.meta.url),
77
+ "System.Private.Xml.Linq.aggbm4zmvg.wasm": new URL("../_framework/System.Private.Xml.Linq.aggbm4zmvg.wasm", import.meta.url),
78
+ "System.Private.Xml.xynykvwzmm.wasm": new URL("../_framework/System.Private.Xml.xynykvwzmm.wasm", import.meta.url),
79
+ "System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm": new URL("../_framework/System.Runtime.InteropServices.JavaScript.luprqfrwge.wasm", import.meta.url),
80
+ "System.Security.Cryptography.ar0yl9tyah.wasm": new URL("../_framework/System.Security.Cryptography.ar0yl9tyah.wasm", import.meta.url),
81
+ "System.Text.Encodings.Web.wom12sblxz.wasm": new URL("../_framework/System.Text.Encodings.Web.wom12sblxz.wasm", import.meta.url),
82
+ "System.Text.Json.p6fo7wpau6.wasm": new URL("../_framework/System.Text.Json.p6fo7wpau6.wasm", import.meta.url),
83
+ "System.Text.RegularExpressions.91s5c47mla.wasm": new URL("../_framework/System.Text.RegularExpressions.91s5c47mla.wasm", import.meta.url),
84
+ "System.Xml.Linq.1t1f7abjkk.wasm": new URL("../_framework/System.Xml.Linq.1t1f7abjkk.wasm", import.meta.url),
85
+ });
@@ -0,0 +1,39 @@
1
+ // PrefConfigurator WASM SDK — main-thread entry types.
2
+
3
+ import type { BoundApi, EnvJson, JsInteropApiRaw } from "./prefconfigurator-api";
4
+
5
+ export interface InitOptions {
6
+ /** Override the worker URL. Useful for tests or for serving the worker from a CDN. */
7
+ workerUrl?: URL | string;
8
+ /** Forwarded to `dotnet.withDiagnosticTracing(true)` when enabled. */
9
+ diagnosticTracing?: boolean;
10
+ }
11
+
12
+ /**
13
+ * Disposable surface added to the BoundApi proxy returned by init().
14
+ * Calling either dispose() or terminate() shuts the worker down and rejects all pending calls.
15
+ */
16
+ export interface SdkLifecycle {
17
+ dispose(): void;
18
+ terminate(): void;
19
+ }
20
+
21
+ /**
22
+ * The proxy returned by init(). Exposes every typed method of BoundApi<JsInteropApiRaw>
23
+ * plus a disposable lifecycle. InitializeFromEnvJson is on the type for declaration
24
+ * compatibility, but it is invoked implicitly by init() and the runtime proxy throws
25
+ * if a consumer calls it directly.
26
+ *
27
+ * NOTE: avoid `Omit<BoundApi<JsInteropApiRaw>, "InitializeFromEnvJson">`. Because
28
+ * JsInteropApiRaw declares a `[key: string]: unknown` index signature, Omit collapses
29
+ * the mapped half of BoundApi to the bare index signature, erasing every typed method.
30
+ * See https://github.com/microsoft/TypeScript/issues/31501.
31
+ */
32
+ export type SdkApi = BoundApi<JsInteropApiRaw> & SdkLifecycle;
33
+
34
+ /**
35
+ * Boots the SDK runtime inside a Web Worker and resolves to a proxy that mirrors
36
+ * the BoundApi shape: object args are JSON-stringified for the engine, and
37
+ * OperationResult<T> envelopes are unwrapped via ensureOk before resolving.
38
+ */
39
+ export declare function init(env: EnvJson | string, opts?: InitOptions): Promise<SdkApi>;
package/js/sdk-init.js ADDED
@@ -0,0 +1,227 @@
1
+ // PrefConfigurator WASM SDK — main-thread entry.
2
+ //
3
+ // init(env, opts?) spawns sdk-worker.js as a module Worker and returns a Proxy that
4
+ // forwards every method call to the worker over postMessage. The Proxy mirrors
5
+ // BoundApi<JsInteropApiRaw> from prefconfigurator-api.d.ts: it stringifies object
6
+ // args for the methods that need it and unwraps OperationResult<T> via ensureOk.
7
+ //
8
+ // All bundler-aware URL resolution lives here in the main thread, never in the
9
+ // worker — Next.js + webpack 5 does not reliably bundle a worker chunk's transitive
10
+ // imports, so the worker is kept leaf and we hand it pre-resolved URLs over the init
11
+ // message. See docs/wasm-worker-init.md.
12
+
13
+ import { ensureOk } from "./prefconfigurator-api.js";
14
+ import { FRAMEWORK_ASSETS } from "./sdk-framework-assets.js";
15
+
16
+ // new URL(literal, import.meta.url) is the bundler-recognized pattern; webpack 5 / Vite /
17
+ // esbuild rewrite each of these into asset emits and substitute the runtime URL. Any
18
+ // expression chained off the URL (e.g. .href) defeats the AST matcher in webpack 5,
19
+ // so we keep these expressions unchained and call String(...) at the use site below.
20
+ //
21
+ // We coerce with String(...) (not .href) because webpack 5 may produce URL-like wrappers
22
+ // whose .href is a getter that returns the URL instance itself or otherwise carries
23
+ // non-cloneable own properties. String(...) goes through .toString() which is guaranteed
24
+ // to return a primitive string and survives postMessage's structured clone.
25
+ const GLTF_STORAGE_URL = new URL("./gltf-storage.js", import.meta.url);
26
+ const GLTF_MERGER_URL = new URL("./gltf-merger.js", import.meta.url);
27
+ const PREF_GLTF_MERGER_WASM_URL = new URL("./PrefGltfMergerWasm.js", import.meta.url);
28
+ // PrefGltfMergerWasm.js is an Emscripten module that loads its companion .wasm
29
+ // at runtime via Module.locateFile. We MUST also resolve the .wasm here so the
30
+ // bundler emits both files; without this declaration webpack/Vite/etc. ignore
31
+ // the .wasm and Emscripten's default sibling-by-name lookup gets a 404 because
32
+ // the consumer's bundler hashed the .js to a different filename. The worker then
33
+ // passes both URLs to gltf-merger.js so locateFile can return the right one.
34
+ const PREF_GLTF_MERGER_WASM_BIN_URL = new URL("./PrefGltfMergerWasm.wasm", import.meta.url);
35
+
36
+ // Per-method arg adapters: equivalent to the typed shims in prefconfigurator-api.ts
37
+ // that today only exist in the .ts and not in the runtime .js, forcing consumers to
38
+ // reimplement them. Centralizing them here means npm consumers get the typed DX
39
+ // without a custom Proxy on their side.
40
+ const ARG_ADAPTERS = {
41
+ UpdateOptions: ([optionList, changedOptionNames]) => [
42
+ JSON.stringify(optionList),
43
+ JSON.stringify(changedOptionNames ?? []),
44
+ ],
45
+ SetDimensions: ([modelId, updates]) => [modelId, JSON.stringify(updates)],
46
+ SetOptions: ([modelId, updates]) => [modelId, JSON.stringify(updates)],
47
+ GetModelImage: ([modelId, config, sceneName, optionList]) => [
48
+ modelId,
49
+ JSON.stringify(config),
50
+ sceneName ?? null,
51
+ optionList != null ? JSON.stringify(optionList) : null,
52
+ ],
53
+ GetUsdImages: ([request, optionList]) => [
54
+ JSON.stringify(request),
55
+ optionList != null ? JSON.stringify(optionList) : null,
56
+ ],
57
+ GetUsdImagesHcStatus: ([request, optionList]) => [
58
+ JSON.stringify(request),
59
+ JSON.stringify(optionList ?? null),
60
+ ],
61
+ GetModelImageHcStatus: ([modelId, config]) => [modelId, JSON.stringify(config)],
62
+ };
63
+
64
+ // InitializeFromEnvJson is implicit — init() runs it during boot and the Proxy hides it.
65
+ const HIDDEN_METHODS = new Set(["InitializeFromEnvJson"]);
66
+
67
+ // String properties that must NOT be intercepted as remote method calls.
68
+ //
69
+ // The Promise resolution algorithm probes any returned value for `then` to
70
+ // decide whether it is a thenable; if our Proxy returns a function for `then`,
71
+ // JavaScript will call it with native (resolve, reject) callbacks, which are
72
+ // not structured-cloneable and crash postMessage with DataCloneError. Returning
73
+ // undefined makes the Proxy look like a plain object to the Promise machinery.
74
+ //
75
+ // `catch` / `finally` are kept here for the same reason in long Promise chains.
76
+ // `__esModule` is webpack's interop marker — if our Proxy returned an async
77
+ // function for it, dynamic imports could mis-classify the module.
78
+ //
79
+ // All Symbol-keyed probes (Symbol.toPrimitive / Symbol.iterator / Symbol.asyncIterator
80
+ // / Symbol.toStringTag / Symbol.dispose / etc.) are filtered earlier by the
81
+ // `typeof prop === "symbol"` check in the get trap, so they don't appear here.
82
+ const NON_REMOTE_KEYS = new Set([
83
+ "then",
84
+ "catch",
85
+ "finally",
86
+ "constructor",
87
+ "toJSON",
88
+ "toString",
89
+ "valueOf",
90
+ "__esModule",
91
+ ]);
92
+
93
+ function rebuildError(serialized) {
94
+ const message = serialized?.message ?? "Unknown SDK error";
95
+ const err = new Error(message);
96
+ if (serialized?.name) err.name = serialized.name;
97
+ if (serialized?.stack) err.stack = serialized.stack;
98
+ if (serialized?.code !== undefined) err.code = serialized.code;
99
+ if (serialized?.source !== undefined) err.source = serialized.source;
100
+ if (serialized?.httpStatus !== undefined) err.httpStatus = serialized.httpStatus;
101
+ if (serialized?.requestId !== undefined) err.requestId = serialized.requestId;
102
+ if (serialized?.correlationId !== undefined) err.correlationId = serialized.correlationId;
103
+ if (serialized?.traceParent !== undefined) err.traceParent = serialized.traceParent;
104
+ if (serialized?.detail !== undefined) err.detail = serialized.detail;
105
+ if (serialized?.callId !== undefined) err.callId = serialized.callId;
106
+ if (serialized?.result !== undefined) err.result = serialized.result;
107
+ return err;
108
+ }
109
+
110
+ function makeRpc(worker) {
111
+ let nextId = 1;
112
+ const pending = new Map();
113
+ let terminated = false;
114
+
115
+ worker.addEventListener("message", (ev) => {
116
+ const msg = ev?.data;
117
+ if (!msg || typeof msg !== "object" || msg.id === undefined) return;
118
+ const ctl = pending.get(msg.id);
119
+ if (!ctl) return;
120
+ pending.delete(msg.id);
121
+ if (msg.type === "result" || msg.type === "init-result") ctl.resolve(msg);
122
+ else if (msg.type === "error" || msg.type === "init-error") ctl.reject(rebuildError(msg.error));
123
+ });
124
+
125
+ worker.addEventListener("error", (ev) => {
126
+ const err = new Error(ev?.message ?? "PrefConfigurator worker crashed");
127
+ for (const ctl of pending.values()) ctl.reject(err);
128
+ pending.clear();
129
+ });
130
+
131
+ function send(message) {
132
+ if (terminated) return Promise.reject(new Error("PrefConfigurator SDK has been disposed."));
133
+ const id = nextId++;
134
+ return new Promise((resolve, reject) => {
135
+ pending.set(id, { resolve, reject });
136
+ worker.postMessage({ ...message, id });
137
+ });
138
+ }
139
+
140
+ function dispose() {
141
+ terminated = true;
142
+ const err = new Error("PrefConfigurator SDK has been disposed.");
143
+ for (const ctl of pending.values()) ctl.reject(err);
144
+ pending.clear();
145
+ worker.terminate();
146
+ }
147
+
148
+ return { send, dispose };
149
+ }
150
+
151
+ /**
152
+ * Boots the SDK runtime in a Web Worker and returns a proxy that mirrors the
153
+ * BoundApi shape exported by the SDK's TypeScript declarations.
154
+ *
155
+ * @param {object|string} env EnvJson object (or pre-serialized JSON string).
156
+ * @param {object} [opts]
157
+ * @param {URL|string} [opts.workerUrl] Override the worker URL (tests, custom hosting).
158
+ * @param {boolean} [opts.diagnosticTracing] Forwarded to dotnet.withDiagnosticTracing.
159
+ * @returns {Promise<object>} a proxy whose methods unwrap OperationResult<T> via ensureOk.
160
+ */
161
+ export async function init(env, opts) {
162
+ if (typeof Worker === "undefined") {
163
+ throw new Error("PrefConfigurator SDK requires a browser/worker environment with Worker support.");
164
+ }
165
+ const options = opts ?? {};
166
+ const workerUrl = options.workerUrl ?? new URL("./sdk-worker.js", import.meta.url);
167
+ const worker = new Worker(workerUrl, { type: "module" });
168
+ const rpc = makeRpc(worker);
169
+
170
+ const envJson = typeof env === "string" ? env : JSON.stringify(env);
171
+
172
+ // Build a plain { name: string } map. We force each value through String(...) and
173
+ // copy with Object.assign-style key iteration so the postMessage clone never sees a
174
+ // URL instance, a webpack wrapper, a getter, or any non-cloneable native function.
175
+ const frameworkAssets = {};
176
+ for (const name of Object.keys(FRAMEWORK_ASSETS)) {
177
+ frameworkAssets[name] = String(FRAMEWORK_ASSETS[name]);
178
+ }
179
+
180
+ try {
181
+ await rpc.send({
182
+ type: "init",
183
+ envJson,
184
+ diagnosticTracing: !!options.diagnosticTracing,
185
+ frameworkAssets,
186
+ gltfStorageUrl: String(GLTF_STORAGE_URL),
187
+ gltfMergerUrl: String(GLTF_MERGER_URL),
188
+ prefGltfMergerWasmUrl: String(PREF_GLTF_MERGER_WASM_URL),
189
+ prefGltfMergerWasmBinUrl: String(PREF_GLTF_MERGER_WASM_BIN_URL),
190
+ });
191
+ } catch (err) {
192
+ rpc.dispose();
193
+ throw err;
194
+ }
195
+
196
+ const proxy = new Proxy(
197
+ {},
198
+ {
199
+ get(_target, prop) {
200
+ if (prop === "dispose" || prop === "terminate" || prop === Symbol.dispose) {
201
+ return () => rpc.dispose();
202
+ }
203
+ // Hide thenable / iterator / serialization probes from the Promise and
204
+ // host runtimes — see NON_REMOTE_KEYS for the rationale.
205
+ if (typeof prop === "symbol") return undefined;
206
+ if (NON_REMOTE_KEYS.has(prop)) return undefined;
207
+ if (typeof prop !== "string") return undefined;
208
+ if (HIDDEN_METHODS.has(prop)) {
209
+ return () => {
210
+ throw new Error(
211
+ `${prop} is invoked implicitly by init() and is not callable on the SDK proxy.`,
212
+ );
213
+ };
214
+ }
215
+
216
+ return async (...args) => {
217
+ const adapter = ARG_ADAPTERS[prop];
218
+ const finalArgs = adapter ? adapter(args) : args;
219
+ const res = await rpc.send({ type: "call", method: prop, args: finalArgs });
220
+ return ensureOk(res.value);
221
+ };
222
+ },
223
+ },
224
+ );
225
+
226
+ return proxy;
227
+ }
@@ -0,0 +1,3 @@
1
+ // Worker entry has no public exports — it communicates exclusively via postMessage.
2
+ // This stub keeps TypeScript consumers happy when the file ships next to typed modules.
3
+ export {};
@@ -0,0 +1,138 @@
1
+ // PrefConfigurator WASM SDK — Web Worker entry.
2
+ //
3
+ // This module is intentionally LEAF: it has no static imports of SDK assets. The main
4
+ // thread (sdk-init.js) resolves every bundler-emitted URL with new URL(literal,
5
+ // import.meta.url), pushes the resulting map down via the init message, and the worker
6
+ // dynamic-imports each one at runtime. Keeping the worker leaf lets bundlers (webpack 5,
7
+ // Vite, esbuild, Rollup) treat sdk-worker.js as a self-contained file: they don't have
8
+ // to follow imports across the worker boundary, which Next.js + webpack 5 in particular
9
+ // does not do reliably as of 16.x.
10
+
11
+ let api = null;
12
+ let bootPromise = null;
13
+
14
+ async function bootDotnet({ envJson, diagnosticTracing, frameworkAssets, gltfStorageUrl, gltfMergerUrl, prefGltfMergerWasmUrl, prefGltfMergerWasmBinUrl }) {
15
+ const dotnetUrl = frameworkAssets["dotnet.js"];
16
+ if (!dotnetUrl) throw new Error("Framework asset manifest missing 'dotnet.js'.");
17
+
18
+ // gltf-merger.js consults these globals to locate its Emscripten module at runtime:
19
+ // __PREF_GLTF_MERGER_WASM_PATH → URL of PrefGltfMergerWasm.js (the loader)
20
+ // __PREF_GLTF_MERGER_WASM_BIN_PATH → URL of PrefGltfMergerWasm.wasm (the binary)
21
+ // Both are needed because the consumer's bundler hashes them independently and
22
+ // Emscripten's default sibling-by-filename lookup fails when the hashes differ.
23
+ self.__PREF_GLTF_MERGER_WASM_PATH = prefGltfMergerWasmUrl;
24
+ self.__PREF_GLTF_MERGER_WASM_BIN_PATH = prefGltfMergerWasmBinUrl;
25
+
26
+ // All three URLs (dotnet, gltf-storage, gltf-merger) are already resolved by the
27
+ // consumer's bundler at build time. webpackIgnore / @vite-ignore keep both bundlers
28
+ // from re-analyzing these dynamic imports.
29
+ const dotnetMod = await import(/* @vite-ignore */ /* webpackIgnore: true */ dotnetUrl);
30
+ const dotnet = dotnetMod.dotnet ?? dotnetMod.default?.dotnet ?? dotnetMod.default;
31
+ if (!dotnet) throw new Error("dotnet.js loaded but its 'dotnet' export is missing.");
32
+
33
+ const builder = dotnet
34
+ .withResourceLoader((_type, name, defaultUri /*, _hash, _behavior */) => {
35
+ const url = frameworkAssets[name];
36
+ return url ?? defaultUri;
37
+ })
38
+ .withApplicationArguments("start");
39
+
40
+ if (diagnosticTracing) builder.withDiagnosticTracing(true);
41
+
42
+ const runtime = await builder.create();
43
+ const { getConfig, getAssemblyExports, setModuleImports, runMain } = runtime;
44
+ if (typeof setModuleImports !== "function") {
45
+ throw new Error("dotnet runtime does not expose setModuleImports — required by the SDK.");
46
+ }
47
+
48
+ // Register [JSImport] target modules. Replaces JSHost.ImportAsync from the C# side.
49
+ const [gltfStorage, gltfMerger] = await Promise.all([
50
+ import(/* @vite-ignore */ /* webpackIgnore: true */ gltfStorageUrl),
51
+ import(/* @vite-ignore */ /* webpackIgnore: true */ gltfMergerUrl),
52
+ ]);
53
+ setModuleImports("gltf-storage", gltfStorage);
54
+ setModuleImports("gltf-merger", gltfMerger);
55
+
56
+ const cfg = getConfig();
57
+ const mainAssembly = cfg.mainAssemblyName;
58
+ if (!mainAssembly) throw new Error("dotnet.js config missing mainAssemblyName.");
59
+
60
+ const exportsAsm = await getAssemblyExports(mainAssembly);
61
+ const ns = exportsAsm?.PrefConfigurator?.Wasm?.JsInteropApi;
62
+ if (!ns) throw new Error("PrefConfigurator.Wasm.JsInteropApi is not exported by the assembly.");
63
+ api = ns;
64
+
65
+ await api.InitializeFromEnvJson(envJson);
66
+
67
+ // Fire Program.Main() so JsInteropApi.Initialize(host.Services) sets _services and
68
+ // the long-running host.RunAsync stays alive. Yield once so its synchronous prologue
69
+ // completes before the main thread starts dispatching calls.
70
+ void runMain();
71
+ await new Promise((resolve) => setTimeout(resolve, 0));
72
+ }
73
+
74
+ function serializeError(err) {
75
+ if (err && typeof err === "object") {
76
+ return {
77
+ name: err.name ?? "Error",
78
+ message: err.message ?? String(err),
79
+ stack: err.stack,
80
+ // Custom fields populated by ensureOk on the main side; pass them through so
81
+ // the rebuilt Error keeps its diagnostic shape.
82
+ code: err.code,
83
+ source: err.source,
84
+ httpStatus: err.httpStatus,
85
+ requestId: err.requestId,
86
+ correlationId: err.correlationId,
87
+ traceParent: err.traceParent,
88
+ detail: err.detail,
89
+ callId: err.callId,
90
+ result: err.result,
91
+ };
92
+ }
93
+ return { name: "Error", message: String(err) };
94
+ }
95
+
96
+ self.addEventListener("message", async (ev) => {
97
+ const msg = ev?.data;
98
+ if (!msg || typeof msg !== "object") return;
99
+
100
+ if (msg.type === "init") {
101
+ try {
102
+ if (!bootPromise) bootPromise = bootDotnet(msg);
103
+ await bootPromise;
104
+ const methods = Object.keys(api).filter((k) => typeof api[k] === "function");
105
+ self.postMessage({ id: msg.id, type: "init-result", methods });
106
+ } catch (err) {
107
+ bootPromise = null;
108
+ self.postMessage({ id: msg.id, type: "init-error", error: serializeError(err) });
109
+ }
110
+ return;
111
+ }
112
+
113
+ if (msg.type === "call") {
114
+ if (!api) {
115
+ self.postMessage({
116
+ id: msg.id,
117
+ type: "error",
118
+ error: serializeError(new Error("PrefConfigurator SDK is not initialized.")),
119
+ });
120
+ return;
121
+ }
122
+ const fn = api[msg.method];
123
+ if (typeof fn !== "function") {
124
+ self.postMessage({
125
+ id: msg.id,
126
+ type: "error",
127
+ error: serializeError(new Error(`Unknown SDK method: ${msg.method}`)),
128
+ });
129
+ return;
130
+ }
131
+ try {
132
+ const value = await fn(...(msg.args ?? []));
133
+ self.postMessage({ id: msg.id, type: "result", value });
134
+ } catch (err) {
135
+ self.postMessage({ id: msg.id, type: "error", error: serializeError(err) });
136
+ }
137
+ }
138
+ });
package/package.json CHANGED
@@ -1,7 +1,34 @@
1
1
  {
2
+ "sideEffects": false,
3
+ "version": "0.2.0-beta.0",
4
+ "type": "module",
5
+ "exports": {
6
+ "./_framework/*": "./_framework/*",
7
+ ".": {
8
+ "types": "./index.d.ts",
9
+ "default": "./index.js"
10
+ },
11
+ "./package.json": "./package.json",
12
+ "./js/prefconfigurator-api": {
13
+ "types": "./js/prefconfigurator-api.d.ts",
14
+ "default": "./js/prefconfigurator-api.js"
15
+ },
16
+ "./js/sdk-worker": "./js/sdk-worker.js",
17
+ "./js/*": {
18
+ "types": "./js/*.d.ts",
19
+ "default": "./js/*.js"
20
+ },
21
+ "./index.html": "./index.html",
22
+ "./js/sdk-init": {
23
+ "types": "./js/sdk-init.d.ts",
24
+ "default": "./js/sdk-init.js"
25
+ }
26
+ },
27
+ "name": "@preference-sl/pref-configurator-sdk",
28
+ "private": false,
29
+ "types": "index.d.ts",
2
30
  "description": ".NET WebAssembly SDK that embeds Preference's business logic for building product configurators (windows, doors, joinery) in browser-based ecommerce platforms.",
3
- "main": "main.js",
4
- "version": "0.1.2-beta.2",
31
+ "main": "index.js",
5
32
  "files": [
6
33
  "_framework/**",
7
34
  "**/*.js",
@@ -10,24 +37,7 @@
10
37
  "index.html",
11
38
  "README.md"
12
39
  ],
13
- "license": "MIT",
14
- "private": false,
15
- "name": "@preference-sl/pref-configurator-sdk",
16
- "scripts": {
17
- "postinstall": "node scripts/postinstall.js"
18
- },
40
+ "module": "index.js",
19
41
  "author": "Alex Moreno Palacio <amoreno@preference.es>",
20
- "exports": {
21
- ".": {
22
- "types": "./main.d.ts",
23
- "default": "./main.js"
24
- },
25
- "./package.json": "./package.json",
26
- "./index.html": "./index.html",
27
- "./js/prefconfigurator-api": {
28
- "types": "./js/prefconfigurator-api.d.ts",
29
- "default": "./js/prefconfigurator-api.js"
30
- }
31
- },
32
- "types": "main.d.ts"
42
+ "license": "MIT"
33
43
  }
package/main.d.ts DELETED
@@ -1,4 +0,0 @@
1
- declare const runtimeInfo: {
2
- frameworkPath: string;
3
- };
4
- export = runtimeInfo;
package/main.js DELETED
@@ -1,2 +0,0 @@
1
- const path = require("path");
2
- module.exports = { frameworkPath: path.join(__dirname, "_framework") };
@@ -1,128 +0,0 @@
1
- "use strict";
2
- /* eslint-disable no-console */
3
- const fs = require("fs");
4
- const path = require("path");
5
-
6
- /* ---------- utils ---------- */
7
- function walk(root, cb) {
8
- const st = [root];
9
- while (st.length) {
10
- const d = st.pop();
11
- let entries;
12
- try { entries = fs.readdirSync(d, { withFileTypes: true }); }
13
- catch { continue; }
14
- for (const e of entries) {
15
- const abs = path.join(d, e.name);
16
- if (e.isDirectory()) st.push(abs);
17
- else if (e.isFile()) cb(abs);
18
- }
19
- }
20
- }
21
-
22
- function ensureDir(p) { fs.mkdirSync(p, { recursive: true }); }
23
- function ensureDirForFile(filePath) { ensureDir(path.dirname(filePath)); }
24
-
25
- function rmrf(p) {
26
- try { fs.rmSync(p, { recursive: true, force: true }); } catch { }
27
- }
28
-
29
- function copyDirRecursive(src, dst) {
30
- if (!fs.existsSync(src)) return;
31
- ensureDir(dst);
32
- for (const e of fs.readdirSync(src, { withFileTypes: true })) {
33
- const s = path.join(src, e.name);
34
- const d = path.join(dst, e.name);
35
- if (e.isDirectory()) copyDirRecursive(s, d);
36
- else if (e.isFile()) fs.copyFileSync(s, d);
37
- }
38
- }
39
-
40
- function resolvePackageName(pkgRoot) {
41
- if (process.env.npm_package_name) {
42
- return String(process.env.npm_package_name).replace(/^@[^/]+\//, "").toLowerCase();
43
- }
44
- try {
45
- const pkg = JSON.parse(fs.readFileSync(path.join(pkgRoot, "package.json"), "utf8"));
46
- if (pkg && pkg.name) return String(pkg.name).replace(/^@[^/]+\//, "").toLowerCase();
47
- } catch { }
48
- try { return path.basename(pkgRoot).toLowerCase(); } catch { }
49
- return "package";
50
- }
51
-
52
- /* ---------- main ---------- */
53
- try {
54
- // package root (we are in .../scripts)
55
- const pkgRoot = path.resolve(__dirname, "..");
56
- const pkgName = resolvePackageName(pkgRoot);
57
-
58
- const srcFramework = path.join(pkgRoot, "_framework");
59
- const srcMain = path.join(pkgRoot, "main.js");
60
- const srcIndex = path.join(pkgRoot, "index.html");
61
-
62
- // consumer public dir
63
- const consumerRoot = process.env.INIT_CWD || process.env.npm_config_local_prefix || process.cwd();
64
- const candidates = [process.env.PUBLIC_DIR, "public", "wwwroot", path.join("src", "assets")].filter(Boolean);
65
-
66
- let targetPublic = null;
67
- for (const c of candidates) {
68
- const abs = path.isAbsolute(c) ? c : path.resolve(consumerRoot, c);
69
- if (fs.existsSync(abs)) { targetPublic = abs; break; }
70
- }
71
- if (!targetPublic) targetPublic = path.resolve(consumerRoot, "public");
72
-
73
- const ns = "preference-sl";
74
- const destRoot = path.join(targetPublic, ns, pkgName);
75
-
76
- // ALWAYS start fresh: remove destination completely
77
- rmrf(destRoot);
78
- ensureDir(destRoot);
79
-
80
- // 1) Copy runtime (_framework) — overwrite
81
- const wasmSubdir = process.env.WASM_SUBDIR || "_framework";
82
- const destFramework = path.join(destRoot, wasmSubdir);
83
- copyDirRecursive(srcFramework, destFramework);
84
- console.log(`[${pkgName}] Copied WASM → ${destFramework}`);
85
-
86
- // 2) main.js — overwrite
87
- if (fs.existsSync(srcMain)) {
88
- const destMain = path.join(destRoot, "main.js");
89
- ensureDirForFile(destMain);
90
- fs.copyFileSync(srcMain, destMain);
91
- console.log(`[${pkgName}] Installed main.js at ${destMain}`);
92
- }
93
-
94
- // 3) index.html → index.demo.html — overwrite
95
- if (fs.existsSync(srcIndex)) {
96
- const destDemo = path.join(destRoot, "index.demo.html");
97
- ensureDirForFile(destDemo);
98
- fs.copyFileSync(srcIndex, destDemo);
99
- console.log(`[${pkgName}] Installed index.demo.html at ${destDemo}`);
100
- }
101
-
102
- // 4) Extra JS / WASM / source maps outside _framework — overwrite
103
- // Includes PrefGltfMergerWasm.js and .wasm so the consumer doesn't need
104
- // a separate npm package for the GLTF merger.
105
- console.log(`[${pkgName}] Copying extra JS/WASM → ${destRoot}`);
106
- const frameworkRoot = path.resolve(path.join(pkgRoot, "_framework"));
107
- const exclude = new Set([
108
- path.resolve(path.join(pkgRoot, "scripts", "postinstall.js")),
109
- ]);
110
- // Source maps and symbols are intentionally not shipped (see Pack-Wasm.ps1).
111
- const copyableExtensions = [".js", ".d.ts", ".wasm"];
112
-
113
- walk(pkgRoot, (abs0) => {
114
- const abs = path.resolve(abs0);
115
- const lower = abs.toLowerCase();
116
- if (!copyableExtensions.some((ext) => lower.endsWith(ext))) return;
117
- if (abs.startsWith(frameworkRoot)) return; // skip _framework
118
- if (exclude.has(abs)) return; // skip postinstall itself
119
-
120
- const rel = path.relative(pkgRoot, abs); // e.g., "js/foo.js" or "js/PrefGltfMergerWasm.wasm"
121
- const dest = path.join(destRoot, rel);
122
- ensureDirForFile(dest);
123
- fs.copyFileSync(abs, dest); // OVERWRITE
124
- });
125
-
126
- } catch (err) {
127
- console.warn(`[postinstall] Warning: copy failed: ${err && (err.message || err)}`);
128
- }