@sanox/sangine-core 0.4.3 → 0.4.5

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.
@@ -0,0 +1,3 @@
1
+ export type AssetKind = 'texture' | 'mesh';
2
+ export declare function fetchAndCache(kind: AssetKind, pk: string, url: string): Promise<ArrayBuffer>;
3
+ //# sourceMappingURL=assetFetcher.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assetFetcher.d.ts","sourceRoot":"","sources":["../src/assetFetcher.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,SAAS,GAAG,SAAS,GAAG,MAAM,CAAA;AAE1C,wBAAsB,aAAa,CACjC,IAAI,EAAE,SAAS,EACf,EAAE,EAAE,MAAM,EACV,GAAG,EAAE,MAAM,GACV,OAAO,CAAC,WAAW,CAAC,CAiBtB"}
package/dist/index.cjs.js CHANGED
@@ -1 +1 @@
1
- "use strict";var b=Object.defineProperty;var A=(a,e,t)=>e in a?b(a,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):a[e]=t;var r=(a,e,t)=>A(a,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const p="/static/sangine/wasm",M="10c8ee57";class S{constructor(e,t){r(this,"workers");r(this,"idle");r(this,"queue",[]);this.workers=Array.from({length:t},e),this.idle=[...this.workers]}run(e){return new Promise((t,s)=>{const d=this.idle.pop();d?this.dispatch(d,e,t,s):this.queue.push({request:e,resolve:t,reject:s})})}dispatch(e,t,s,d){const l=n=>{s(n.data),i(),this.release(e)},o=n=>{d(n),i(),this.release(e)},i=()=>{e.removeEventListener("message",l),e.removeEventListener("error",o)};e.addEventListener("message",l,{once:!0}),e.addEventListener("error",o,{once:!0}),e.postMessage(t)}release(e){const t=this.queue.shift();t?this.dispatch(e,t.request,t.resolve,t.reject):this.idle.push(e)}broadcast(e){for(const t of this.workers)t.postMessage(e)}terminate(){for(const e of this.workers)e.terminate()}}class E{constructor(e){r(this,"wasm",null);r(this,"callbackRegistry",{});r(this,"userActionRegistry",{});r(this,"assetsDownloadingRegistry",{});r(this,"windowCreatedPromiseRegistry",{});r(this,"windowCreatedPromiseResolveRegistry",{});r(this,"_inited",!1);r(this,"decodePool");r(this,"_readyPromise");r(this,"_resolveReady");r(this,"_rejectReady");this.config=e,this._readyPromise=new Promise((t,s)=>{this._resolveReady=t,this._rejectReady=s}),this.config=e}async init(){if(!(typeof window>"u")){if(this._inited)return this._readyPromise;try{const t=await import(new URL(`${p}/sangine/sangine.${M}.js`,window.location.origin).toString());await t.default(),this.wasm=t,this._inited=!0;const s=Math.min(this.config.numWorkers??(navigator.hardwareConcurrency||2)-1,4);this.decodePool=new S(()=>this.config.createDecodeWorker(),Math.max(s,1)),this.wasm.register_asset_decoder(this.decodeAsset.bind(this)),this.wasm.register_event_listener(this.handleSangineEvent.bind(this)),this._resolveReady()}catch(e){throw this._rejectReady(e),e}return this._readyPromise}}ready(){return this._readyPromise}get inited(){return this._inited}getWasm(){if(!this.wasm)throw new Error("RendererService not initialized");return this.wasm}handleActionChanged(e,t){this.userActionRegistry[e]=t;for(const s of this.callbackRegistry[e].actionChanged)s(t)}handleMeasurementCreated(e,t){for(const s of this.callbackRegistry[e].measurementCreated)s(t)}handleRouteUpdated(e,t){for(const s of this.callbackRegistry[e].routeUpdated)s(t)}handleAssetsDownloading(e,t){this.assetsDownloadingRegistry[e]=t;for(const s of this.callbackRegistry[e].assetsDownloading)s(t)}handleUserInteractionStarted(e){for(const t of this.callbackRegistry[e].userInteractionStarted)t()}handleSangineEvent(e,t){t==="ready"?this.windowCreatedPromiseResolveRegistry[e]():t==="userInteractionStarted"?this.handleUserInteractionStarted(e):"actionChanged"in t?this.handleActionChanged(e,t.actionChanged.action):"measurementCreated"in t?this.handleMeasurementCreated(e,t.measurementCreated.measurement):"routeUnderConstructionUpdated"in t?this.handleRouteUpdated(e,t.routeUnderConstructionUpdated.route):"assetsDownloading"in t&&this.handleAssetsDownloading(e,t.assetsDownloading.downloading)}createWindow(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");let d;const l=new Promise(i=>{d=i}),o=this.wasm.create_window(e,t,s);return this.windowCreatedPromiseResolveRegistry[o]=d,this.callbackRegistry[o]={actionChanged:[],routeUpdated:[],measurementCreated:[],assetsDownloading:[],userInteractionStarted:[]},this.userActionRegistry[o]="watching",this.windowCreatedPromiseRegistry[o]=l,o}getAssetsDownloading(e){return this.assetsDownloadingRegistry[e]||!1}readUserAction(e){return this.userActionRegistry[e]}windowReady(e){return this.windowCreatedPromiseRegistry[e]}registerCallback(e,t,s){this.callbackRegistry[e][t].push(s)}setWindowAction(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_action(e,t)}destroyWindow(e){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.destroy_window(e),delete this.callbackRegistry[e],delete this.userActionRegistry[e]}setRouteHighlight(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_highlight(e,t,s)}setRouteVisible(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_visible(e,t,s)}animateToRoute(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to_route(e,t)}setSunProperties(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_sun_properties(e,t)}setAmbientLighting(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_ambient_lighting(e,t)}setLightingMode(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_lighting_mode(e,t)}setNorthCorrection(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_north_correction(e,t)}setGpuMemoryBudgetMb(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_gpu_memory_budget_mb(e,t)}setRenderQuality(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_render_quality(e,t)}readCameraPos(e){if(!this.wasm)throw new Error("WASM not initialized");return this.wasm.read_camera_pos(e)}animateTo(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to(e,t)}setScale(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_scale(e,t)}async decodeAsset(e){if(!this.decodePool)throw new Error("Renderer not initialized");return this.decodePool.run(e)}destroy(){var e;(e=this.decodePool)==null||e.terminate()}}const C="bf116aa6",W=0;function P(a){let e=!1,t=null,s=null;async function d(o,i){if(s){const n=`https://sangine-asset-cache/${o}`,u=await s.match(n);if(u)return u;const w=await fetch(i);return w.ok&&await s.put(n,w.clone()),w}return fetch(i)}async function l(){if(e)return;const i=await import(new URL(`${p}/decode/wasm_decode.${C}.js`,a.location.origin).href);await i.default(),await i.init_basis(),t=i,e=!0}a.onmessage=async o=>{const{data:i}=o;if(!s&&typeof caches<"u"&&(s=await caches.open("sangine-assets-v1")),"texture-file"in i)try{const{pk:n,url:u,format:w,encoding:g}=i["texture-file"];if(g==="ktx2"){await l();const c=await d(n,u);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const f=await c.arrayBuffer(),m=new Uint8Array(f),h=t.transcode_basis(m,w);a.postMessage({success:!0,width:h.width,height:h.height,data:h.data.buffer,format:h.format},[h.data.buffer])}else{const c=await d(n,u);if(!c.ok)throw new Error(`HTTP error! status: ${c.status}`);const f=await c.blob(),m=await createImageBitmap(f),h=new OffscreenCanvas(m.width,m.height),y=h.getContext("2d");if(y===null)throw new Error("Couldnt create canvas");y.drawImage(m,0,0);const R=y.getImageData(0,0,h.width,h.height);a.postMessage({success:!0,width:h.width,height:h.height,data:R.data.buffer,format:W},[R.data.buffer])}}catch(n){a.postMessage({success:!1,error:n.message})}else if("model-part-mesh"in i){await l();const{pk:n,url:u}=i["model-part-mesh"],w=await d(n,u);if(!w.ok)throw new Error(`HTTP error! status: ${w.status}`);const g=await w.arrayBuffer(),_=new Uint8Array(g),c=t.decode_sbo(_);a.postMessage({success:!0,data:c.buffer},[c.buffer])}}}exports.RendererService=E;exports.registerDecodeWorker=P;
1
+ "use strict";var g=Object.defineProperty;var f=(n,e,t)=>e in n?g(n,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):n[e]=t;var d=(n,e,t)=>f(n,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const y="sangine-assets-v2";let l=null;async function u(n,e,t){if(typeof caches>"u"){const a=await fetch(t);if(!a.ok)throw new Error(`fetch ${t} failed: ${a.status}`);return a.arrayBuffer()}l??(l=caches.open(y));const s=await l,o=`https://sangine-asset-cache/${n}/${e}`,r=await s.match(o);if(r)return r.arrayBuffer();const i=await fetch(t);if(!i.ok)throw new Error(`fetch ${t} failed: ${i.status}`);return s.put(o,i.clone()).catch(()=>{}),i.arrayBuffer()}const m="/static/sangine/wasm",_="ecedf539";class b{constructor(e,t){d(this,"workers");d(this,"idle");d(this,"queue",[]);this.workers=Array.from({length:t},e),this.idle=[...this.workers]}run(e,t){return new Promise((s,o)=>{const r=this.idle.pop();r?this.dispatch(r,e,t,s,o):this.queue.push({request:e,transfer:t,resolve:s,reject:o})})}dispatch(e,t,s,o,r){const i=h=>{o(h.data),c(),this.release(e)},a=h=>{r(h),c(),this.release(e)},c=()=>{e.removeEventListener("message",i),e.removeEventListener("error",a)};e.addEventListener("message",i,{once:!0}),e.addEventListener("error",a,{once:!0}),e.postMessage(t,s??[])}release(e){const t=this.queue.shift();t?this.dispatch(e,t.request,t.transfer,t.resolve,t.reject):this.idle.push(e)}broadcast(e){for(const t of this.workers)t.postMessage(e)}terminate(){for(const e of this.workers)e.terminate()}}class R{constructor(e){d(this,"wasm",null);d(this,"callbackRegistry",{});d(this,"userActionRegistry",{});d(this,"assetsDownloadingRegistry",{});d(this,"windowCreatedPromiseRegistry",{});d(this,"windowCreatedPromiseResolveRegistry",{});d(this,"_inited",!1);d(this,"decodePool");d(this,"_readyPromise");d(this,"_resolveReady");d(this,"_rejectReady");this.config=e,this._readyPromise=new Promise((t,s)=>{this._resolveReady=t,this._rejectReady=s}),this.config=e}async init(){if(!(typeof window>"u")){if(this._inited)return this._readyPromise;try{const t=await import(new URL(`${m}/sangine/sangine.${_}.js`,window.location.origin).toString());await t.default(),this.wasm=t,this._inited=!0;const s=Math.min(this.config.numWorkers??(navigator.hardwareConcurrency||2)-1,2);this.decodePool=new b(()=>this.config.createDecodeWorker(),Math.max(s,1)),this.wasm.register_asset_decoder(this.decodeAsset.bind(this)),this.wasm.register_event_listener(this.handleSangineEvent.bind(this)),this._resolveReady()}catch(e){throw this._rejectReady(e),e}return this._readyPromise}}ready(){return this._readyPromise}get inited(){return this._inited}getWasm(){if(!this.wasm)throw new Error("RendererService not initialized");return this.wasm}handleActionChanged(e,t){this.userActionRegistry[e]=t;for(const s of this.callbackRegistry[e].actionChanged)s(t)}handleMeasurementCreated(e,t){for(const s of this.callbackRegistry[e].measurementCreated)s(t)}handleRouteUpdated(e,t){for(const s of this.callbackRegistry[e].routeUpdated)s(t)}handleAssetsDownloading(e,t){this.assetsDownloadingRegistry[e]=t;for(const s of this.callbackRegistry[e].assetsDownloading)s(t)}handleUserInteractionStarted(e){for(const t of this.callbackRegistry[e].userInteractionStarted)t()}handleSangineEvent(e,t){t==="ready"?this.windowCreatedPromiseResolveRegistry[e]():t==="userInteractionStarted"?this.handleUserInteractionStarted(e):"actionChanged"in t?this.handleActionChanged(e,t.actionChanged.action):"measurementCreated"in t?this.handleMeasurementCreated(e,t.measurementCreated.measurement):"routeUnderConstructionUpdated"in t?this.handleRouteUpdated(e,t.routeUnderConstructionUpdated.route):"assetsDownloading"in t&&this.handleAssetsDownloading(e,t.assetsDownloading.downloading)}createWindow(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");let o;const r=new Promise(a=>{o=a}),i=this.wasm.create_window(e,t,s);return this.windowCreatedPromiseResolveRegistry[i]=o,this.callbackRegistry[i]={actionChanged:[],routeUpdated:[],measurementCreated:[],assetsDownloading:[],userInteractionStarted:[]},this.userActionRegistry[i]="watching",this.windowCreatedPromiseRegistry[i]=r,i}getAssetsDownloading(e){return this.assetsDownloadingRegistry[e]||!1}readUserAction(e){return this.userActionRegistry[e]}windowReady(e){return this.windowCreatedPromiseRegistry[e]}registerCallback(e,t,s){this.callbackRegistry[e][t].push(s)}setWindowAction(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_action(e,t)}destroyWindow(e){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.destroy_window(e),delete this.callbackRegistry[e],delete this.userActionRegistry[e]}setRouteHighlight(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_highlight(e,t,s)}setRouteVisible(e,t,s){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_route_visible(e,t,s)}animateToRoute(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to_route(e,t)}setSunProperties(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_sun_properties(e,t)}setAmbientLighting(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_ambient_lighting(e,t)}setLightingMode(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_lighting_mode(e,t)}setNorthCorrection(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_north_correction(e,t)}setGpuMemoryBudgetMb(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_gpu_memory_budget_mb(e,t)}setRenderQuality(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_render_quality(e,t)}readCameraPos(e){if(!this.wasm)throw new Error("WASM not initialized");return this.wasm.read_camera_pos(e)}animateTo(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.animate_to(e,t)}setScale(e,t){if(!this.wasm)throw new Error("WASM not initialized");this.wasm.set_window_scale(e,t)}async decodeAsset(e){if(!this.decodePool)throw new Error("Renderer not initialized");if("texture-file"in e){const{pk:r,url:i,encoding:a,format:c}=e["texture-file"],h=await u("texture",r,i);return a==="ktx2"?this.decodePool.run({kind:"texture-basis",bytes:h,format:c},[h]):this.decodePool.run({kind:"texture-image",bytes:h},[h])}const{pk:t,url:s}=e["model-part-mesh"],o=await u("mesh",t,s);return this.decodePool.run({kind:"model-sbo",bytes:o},[o])}destroy(){var e;(e=this.decodePool)==null||e.terminate()}}const p="bf116aa6",A=0;function M(n){let e=!1,t=null;async function s(){if(e)return;const r=await import(new URL(`${m}/decode/wasm_decode.${p}.js`,n.location.origin).href);await r.default(),await r.init_basis(),t=r,e=!0}n.onmessage=async o=>{const r=o.data;try{if(r.kind==="texture-basis"){await s();const i=new Uint8Array(r.bytes),a=t.transcode_basis(i,r.format);n.postMessage({success:!0,width:a.width,height:a.height,data:a.data.buffer,format:a.format},[a.data.buffer])}else if(r.kind==="texture-image"){const i=new Blob([r.bytes]),a=await createImageBitmap(i),c=new OffscreenCanvas(a.width,a.height),h=c.getContext("2d");if(h===null)throw new Error("Couldnt create canvas");h.drawImage(a,0,0);const w=h.getImageData(0,0,c.width,c.height);n.postMessage({success:!0,width:c.width,height:c.height,data:w.data.buffer,format:A},[w.data.buffer])}else if(r.kind==="model-sbo"){await s();const i=new Uint8Array(r.bytes),a=t.decode_sbo(i);n.postMessage({success:!0,data:a.buffer},[a.buffer])}else{const i=r;throw new Error(`unknown task kind: ${i.kind}`)}}catch(i){n.postMessage({success:!1,error:i.message})}}}exports.RendererService=R;exports.registerDecodeWorker=M;
package/dist/index.es.js CHANGED
@@ -1,33 +1,49 @@
1
- var b = Object.defineProperty;
2
- var A = (a, e, t) => e in a ? b(a, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : a[e] = t;
3
- var r = (a, e, t) => A(a, typeof e != "symbol" ? e + "" : e, t);
4
- const p = "/static/sangine/wasm", M = "10c8ee57";
5
- class E {
1
+ var g = Object.defineProperty;
2
+ var f = (n, e, t) => e in n ? g(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
3
+ var d = (n, e, t) => f(n, typeof e != "symbol" ? e + "" : e, t);
4
+ const y = "sangine-assets-v2";
5
+ let l = null;
6
+ async function m(n, e, t) {
7
+ if (typeof caches > "u") {
8
+ const a = await fetch(t);
9
+ if (!a.ok) throw new Error(`fetch ${t} failed: ${a.status}`);
10
+ return a.arrayBuffer();
11
+ }
12
+ l ?? (l = caches.open(y));
13
+ const s = await l, o = `https://sangine-asset-cache/${n}/${e}`, r = await s.match(o);
14
+ if (r) return r.arrayBuffer();
15
+ const i = await fetch(t);
16
+ if (!i.ok) throw new Error(`fetch ${t} failed: ${i.status}`);
17
+ return s.put(o, i.clone()).catch(() => {
18
+ }), i.arrayBuffer();
19
+ }
20
+ const u = "/static/sangine/wasm", _ = "ecedf539";
21
+ class b {
6
22
  constructor(e, t) {
7
- r(this, "workers");
8
- r(this, "idle");
9
- r(this, "queue", []);
23
+ d(this, "workers");
24
+ d(this, "idle");
25
+ d(this, "queue", []);
10
26
  this.workers = Array.from({ length: t }, e), this.idle = [...this.workers];
11
27
  }
12
- run(e) {
13
- return new Promise((t, s) => {
14
- const h = this.idle.pop();
15
- h ? this.dispatch(h, e, t, s) : this.queue.push({ request: e, resolve: t, reject: s });
28
+ run(e, t) {
29
+ return new Promise((s, o) => {
30
+ const r = this.idle.pop();
31
+ r ? this.dispatch(r, e, t, s, o) : this.queue.push({ request: e, transfer: t, resolve: s, reject: o });
16
32
  });
17
33
  }
18
- dispatch(e, t, s, h) {
19
- const l = (n) => {
20
- s(n.data), i(), this.release(e);
21
- }, o = (n) => {
22
- h(n), i(), this.release(e);
23
- }, i = () => {
24
- e.removeEventListener("message", l), e.removeEventListener("error", o);
34
+ dispatch(e, t, s, o, r) {
35
+ const i = (h) => {
36
+ o(h.data), c(), this.release(e);
37
+ }, a = (h) => {
38
+ r(h), c(), this.release(e);
39
+ }, c = () => {
40
+ e.removeEventListener("message", i), e.removeEventListener("error", a);
25
41
  };
26
- e.addEventListener("message", l, { once: !0 }), e.addEventListener("error", o, { once: !0 }), e.postMessage(t);
42
+ e.addEventListener("message", i, { once: !0 }), e.addEventListener("error", a, { once: !0 }), e.postMessage(t, s ?? []);
27
43
  }
28
44
  release(e) {
29
45
  const t = this.queue.shift();
30
- t ? this.dispatch(e, t.request, t.resolve, t.reject) : this.idle.push(e);
46
+ t ? this.dispatch(e, t.request, t.transfer, t.resolve, t.reject) : this.idle.push(e);
31
47
  }
32
48
  broadcast(e) {
33
49
  for (const t of this.workers)
@@ -38,19 +54,19 @@ class E {
38
54
  e.terminate();
39
55
  }
40
56
  }
41
- class P {
57
+ class M {
42
58
  constructor(e) {
43
- r(this, "wasm", null);
44
- r(this, "callbackRegistry", {});
45
- r(this, "userActionRegistry", {});
46
- r(this, "assetsDownloadingRegistry", {});
47
- r(this, "windowCreatedPromiseRegistry", {});
48
- r(this, "windowCreatedPromiseResolveRegistry", {});
49
- r(this, "_inited", !1);
50
- r(this, "decodePool");
51
- r(this, "_readyPromise");
52
- r(this, "_resolveReady");
53
- r(this, "_rejectReady");
59
+ d(this, "wasm", null);
60
+ d(this, "callbackRegistry", {});
61
+ d(this, "userActionRegistry", {});
62
+ d(this, "assetsDownloadingRegistry", {});
63
+ d(this, "windowCreatedPromiseRegistry", {});
64
+ d(this, "windowCreatedPromiseResolveRegistry", {});
65
+ d(this, "_inited", !1);
66
+ d(this, "decodePool");
67
+ d(this, "_readyPromise");
68
+ d(this, "_resolveReady");
69
+ d(this, "_rejectReady");
54
70
  this.config = e, this._readyPromise = new Promise((t, s) => {
55
71
  this._resolveReady = t, this._rejectReady = s;
56
72
  }), this.config = e;
@@ -60,15 +76,15 @@ class P {
60
76
  if (this._inited) return this._readyPromise;
61
77
  try {
62
78
  const t = await import(new URL(
63
- `${p}/sangine/sangine.${M}.js`,
79
+ `${u}/sangine/sangine.${_}.js`,
64
80
  window.location.origin
65
81
  ).toString());
66
82
  await t.default(), this.wasm = t, this._inited = !0;
67
83
  const s = Math.min(
68
84
  this.config.numWorkers ?? (navigator.hardwareConcurrency || 2) - 1,
69
- 4
85
+ 2
70
86
  );
71
- this.decodePool = new E(
87
+ this.decodePool = new b(
72
88
  () => this.config.createDecodeWorker(),
73
89
  Math.max(s, 1)
74
90
  ), this.wasm.register_asset_decoder(this.decodeAsset.bind(this)), this.wasm.register_event_listener(this.handleSangineEvent.bind(this)), this._resolveReady();
@@ -116,17 +132,17 @@ class P {
116
132
  }
117
133
  createWindow(e, t, s) {
118
134
  if (!this.wasm) throw new Error("WASM not initialized");
119
- let h;
120
- const l = new Promise((i) => {
121
- h = i;
122
- }), o = this.wasm.create_window(e, t, s);
123
- return this.windowCreatedPromiseResolveRegistry[o] = h, this.callbackRegistry[o] = {
135
+ let o;
136
+ const r = new Promise((a) => {
137
+ o = a;
138
+ }), i = this.wasm.create_window(e, t, s);
139
+ return this.windowCreatedPromiseResolveRegistry[i] = o, this.callbackRegistry[i] = {
124
140
  actionChanged: [],
125
141
  routeUpdated: [],
126
142
  measurementCreated: [],
127
143
  assetsDownloading: [],
128
144
  userInteractionStarted: []
129
- }, this.userActionRegistry[o] = "watching", this.windowCreatedPromiseRegistry[o] = l, o;
145
+ }, this.userActionRegistry[i] = "watching", this.windowCreatedPromiseRegistry[i] = r, i;
130
146
  }
131
147
  getAssetsDownloading(e) {
132
148
  return this.assetsDownloadingRegistry[e] || !1;
@@ -198,84 +214,74 @@ class P {
198
214
  }
199
215
  async decodeAsset(e) {
200
216
  if (!this.decodePool) throw new Error("Renderer not initialized");
201
- return this.decodePool.run(e);
217
+ if ("texture-file" in e) {
218
+ const { pk: r, url: i, encoding: a, format: c } = e["texture-file"], h = await m("texture", r, i);
219
+ return a === "ktx2" ? this.decodePool.run({ kind: "texture-basis", bytes: h, format: c }, [h]) : this.decodePool.run({ kind: "texture-image", bytes: h }, [h]);
220
+ }
221
+ const { pk: t, url: s } = e["model-part-mesh"], o = await m("mesh", t, s);
222
+ return this.decodePool.run({ kind: "model-sbo", bytes: o }, [o]);
202
223
  }
203
224
  destroy() {
204
225
  var e;
205
226
  (e = this.decodePool) == null || e.terminate();
206
227
  }
207
228
  }
208
- const S = "bf116aa6", C = 0;
209
- function k(a) {
210
- let e = !1, t = null, s = null;
211
- async function h(o, i) {
212
- if (s) {
213
- const n = `https://sangine-asset-cache/${o}`, m = await s.match(n);
214
- if (m) return m;
215
- const w = await fetch(i);
216
- return w.ok && await s.put(n, w.clone()), w;
217
- }
218
- return fetch(i);
219
- }
220
- async function l() {
229
+ const R = "bf116aa6", p = 0;
230
+ function E(n) {
231
+ let e = !1, t = null;
232
+ async function s() {
221
233
  if (e) return;
222
- const i = await import(new URL(
223
- `${p}/decode/wasm_decode.${S}.js`,
224
- a.location.origin
234
+ const r = await import(new URL(
235
+ `${u}/decode/wasm_decode.${R}.js`,
236
+ n.location.origin
225
237
  ).href);
226
- await i.default(), await i.init_basis(), t = i, e = !0;
227
- }
228
- a.onmessage = async (o) => {
229
- const { data: i } = o;
230
- if (!s && typeof caches < "u" && (s = await caches.open("sangine-assets-v1")), "texture-file" in i)
231
- try {
232
- const { pk: n, url: m, format: w, encoding: g } = i["texture-file"];
233
- if (g === "ktx2") {
234
- await l();
235
- const c = await h(n, m);
236
- if (!c.ok) throw new Error(`HTTP error! status: ${c.status}`);
237
- const f = await c.arrayBuffer(), u = new Uint8Array(f), d = t.transcode_basis(u, w);
238
- a.postMessage(
239
- {
240
- success: !0,
241
- width: d.width,
242
- height: d.height,
243
- data: d.data.buffer,
244
- format: d.format
245
- },
246
- [d.data.buffer]
247
- );
248
- } else {
249
- const c = await h(n, m);
250
- if (!c.ok) throw new Error(`HTTP error! status: ${c.status}`);
251
- const f = await c.blob(), u = await createImageBitmap(f), d = new OffscreenCanvas(u.width, u.height), y = d.getContext("2d");
252
- if (y === null) throw new Error("Couldnt create canvas");
253
- y.drawImage(u, 0, 0);
254
- const R = y.getImageData(0, 0, d.width, d.height);
255
- a.postMessage(
256
- {
257
- success: !0,
258
- width: d.width,
259
- height: d.height,
260
- data: R.data.buffer,
261
- format: C
262
- },
263
- [R.data.buffer]
264
- );
265
- }
266
- } catch (n) {
267
- a.postMessage({ success: !1, error: n.message });
238
+ await r.default(), await r.init_basis(), t = r, e = !0;
239
+ }
240
+ n.onmessage = async (o) => {
241
+ const r = o.data;
242
+ try {
243
+ if (r.kind === "texture-basis") {
244
+ await s();
245
+ const i = new Uint8Array(r.bytes), a = t.transcode_basis(i, r.format);
246
+ n.postMessage(
247
+ {
248
+ success: !0,
249
+ width: a.width,
250
+ height: a.height,
251
+ data: a.data.buffer,
252
+ format: a.format
253
+ },
254
+ [a.data.buffer]
255
+ );
256
+ } else if (r.kind === "texture-image") {
257
+ const i = new Blob([r.bytes]), a = await createImageBitmap(i), c = new OffscreenCanvas(a.width, a.height), h = c.getContext("2d");
258
+ if (h === null) throw new Error("Couldnt create canvas");
259
+ h.drawImage(a, 0, 0);
260
+ const w = h.getImageData(0, 0, c.width, c.height);
261
+ n.postMessage(
262
+ {
263
+ success: !0,
264
+ width: c.width,
265
+ height: c.height,
266
+ data: w.data.buffer,
267
+ format: p
268
+ },
269
+ [w.data.buffer]
270
+ );
271
+ } else if (r.kind === "model-sbo") {
272
+ await s();
273
+ const i = new Uint8Array(r.bytes), a = t.decode_sbo(i);
274
+ n.postMessage({ success: !0, data: a.buffer }, [a.buffer]);
275
+ } else {
276
+ const i = r;
277
+ throw new Error(`unknown task kind: ${i.kind}`);
268
278
  }
269
- else if ("model-part-mesh" in i) {
270
- await l();
271
- const { pk: n, url: m } = i["model-part-mesh"], w = await h(n, m);
272
- if (!w.ok) throw new Error(`HTTP error! status: ${w.status}`);
273
- const g = await w.arrayBuffer(), _ = new Uint8Array(g), c = t.decode_sbo(_);
274
- a.postMessage({ success: !0, data: c.buffer }, [c.buffer]);
279
+ } catch (i) {
280
+ n.postMessage({ success: !1, error: i.message });
275
281
  }
276
282
  };
277
283
  }
278
284
  export {
279
- P as RendererService,
280
- k as registerDecodeWorker
285
+ M as RendererService,
286
+ E as registerDecodeWorker
281
287
  };
@@ -1 +1 @@
1
- {"version":3,"file":"rendererService.d.ts","sourceRoot":"","sources":["../src/rendererService.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EACV,SAAS,EACT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,GAAG,OAAO,CAAC,WAAW,CAAC;IAezD,OAAO;CAGR"}
@@ -44,7 +44,6 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
44
44
 
45
45
  export interface InitOutput {
46
46
  readonly memory: WebAssembly.Memory;
47
- readonly run: () => void;
48
47
  readonly animate_to: (a: number, b: any) => [number, number];
49
48
  readonly animate_to_route: (a: number, b: number, c: number) => [number, number];
50
49
  readonly create_window: (a: number, b: number, c: any, d: number) => [number, number, number];
@@ -62,6 +61,7 @@ export interface InitOutput {
62
61
  readonly set_sun_properties: (a: number, b: any) => [number, number];
63
62
  readonly set_window_action: (a: number, b: any) => [number, number];
64
63
  readonly set_window_scale: (a: number, b: number) => [number, number];
64
+ readonly run: () => void;
65
65
  readonly wasm_bindgen__convert__closures_____invoke__hd8590da73942d3e0: (a: number, b: number, c: any) => [number, number];
66
66
  readonly wasm_bindgen__convert__closures_____invoke__h6ff3e7511bd758a3: (a: number, b: number, c: any, d: any) => void;
67
67
  readonly wasm_bindgen__convert__closures_____invoke__h00cde4323839146b: (a: number, b: number, c: any) => void;
@@ -2705,57 +2705,57 @@ function __wbg_get_imports() {
2705
2705
  arg0.writeTexture(arg1, arg2, arg3, arg4);
2706
2706
  }, arguments); },
2707
2707
  __wbindgen_cast_0000000000000001: function(arg0, arg1) {
2708
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2708
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2709
2709
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b);
2710
2710
  return ret;
2711
2711
  },
2712
2712
  __wbindgen_cast_0000000000000002: function(arg0, arg1) {
2713
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3911, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2713
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [Externref], shim_idx: 3910, ret: Result(Unit), inner_ret: Some(Result(Unit)) }, mutable: true }) -> Externref`.
2714
2714
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hd8590da73942d3e0);
2715
2715
  return ret;
2716
2716
  },
2717
2717
  __wbindgen_cast_0000000000000003: function(arg0, arg1) {
2718
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 3834, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2718
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 3833, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2719
2719
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h6ff3e7511bd758a3);
2720
2720
  return ret;
2721
2721
  },
2722
2722
  __wbindgen_cast_0000000000000004: function(arg0, arg1) {
2723
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2723
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2724
2724
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_3);
2725
2725
  return ret;
2726
2726
  },
2727
2727
  __wbindgen_cast_0000000000000005: function(arg0, arg1) {
2728
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2728
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("Event")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2729
2729
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_4);
2730
2730
  return ret;
2731
2731
  },
2732
2732
  __wbindgen_cast_0000000000000006: function(arg0, arg1) {
2733
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("FocusEvent")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2733
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("FocusEvent")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2734
2734
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_5);
2735
2735
  return ret;
2736
2736
  },
2737
2737
  __wbindgen_cast_0000000000000007: function(arg0, arg1) {
2738
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2738
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2739
2739
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_6);
2740
2740
  return ret;
2741
2741
  },
2742
2742
  __wbindgen_cast_0000000000000008: function(arg0, arg1) {
2743
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("PageTransitionEvent")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2743
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("PageTransitionEvent")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2744
2744
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_7);
2745
2745
  return ret;
2746
2746
  },
2747
2747
  __wbindgen_cast_0000000000000009: function(arg0, arg1) {
2748
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("PointerEvent")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2748
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("PointerEvent")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2749
2749
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_8);
2750
2750
  return ret;
2751
2751
  },
2752
2752
  __wbindgen_cast_000000000000000a: function(arg0, arg1) {
2753
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WheelEvent")], shim_idx: 3827, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2753
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [NamedExternref("WheelEvent")], shim_idx: 3826, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2754
2754
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__h00cde4323839146b_9);
2755
2755
  return ret;
2756
2756
  },
2757
2757
  __wbindgen_cast_000000000000000b: function(arg0, arg1) {
2758
- // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 3832, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2758
+ // Cast intrinsic for `Closure(Closure { owned: true, function: Function { arguments: [], shim_idx: 3831, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
2759
2759
  const ret = makeMutClosure(arg0, arg1, wasm_bindgen__convert__closures_____invoke__hdb7f99c0126c5c28);
2760
2760
  return ret;
2761
2761
  },
@@ -3324,7 +3324,7 @@ async function __wbg_init(module_or_path) {
3324
3324
  }
3325
3325
 
3326
3326
  if (module_or_path === undefined) {
3327
- module_or_path = new URL('sangine_bg.10c8ee57.wasm', import.meta.url);
3327
+ module_or_path = new URL('sangine_bg.ecedf539.wasm', import.meta.url);
3328
3328
  }
3329
3329
  const imports = __wbg_get_imports();
3330
3330
 
@@ -1,7 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
- export const run: () => void;
5
4
  export const animate_to: (a: number, b: any) => [number, number];
6
5
  export const animate_to_route: (a: number, b: number, c: number) => [number, number];
7
6
  export const create_window: (a: number, b: number, c: any, d: number) => [number, number, number];
@@ -19,6 +18,7 @@ export const set_route_visible: (a: number, b: number, c: number, d: number) =>
19
18
  export const set_sun_properties: (a: number, b: any) => [number, number];
20
19
  export const set_window_action: (a: number, b: any) => [number, number];
21
20
  export const set_window_scale: (a: number, b: number) => [number, number];
21
+ export const run: () => void;
22
22
  export const wasm_bindgen__convert__closures_____invoke__hd8590da73942d3e0: (a: number, b: number, c: any) => [number, number];
23
23
  export const wasm_bindgen__convert__closures_____invoke__h6ff3e7511bd758a3: (a: number, b: number, c: any, d: any) => void;
24
24
  export const wasm_bindgen__convert__closures_____invoke__h00cde4323839146b: (a: number, b: number, c: any) => void;
@@ -1,2 +1,2 @@
1
- export declare const SANGINE_HASH = "10c8ee57";
1
+ export declare const SANGINE_HASH = "ecedf539";
2
2
  //# sourceMappingURL=sangine.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"decodeWorkerImpl.d.ts","sourceRoot":"","sources":["../../src/worker/decodeWorkerImpl.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,aAAa,IAAI,CAAA;AACvB,QAAA,MAAM,iBAAiB,IAAI,CAAA;AAC3B,QAAA,MAAM,eAAe,IAAI,CAAA;AACzB,QAAA,MAAM,UAAU,IAAI,CAAA;AACpB,QAAA,MAAM,UAAU,IAAI,CAAA;AACpB,QAAA,MAAM,aAAa,IAAI,CAAA;AACvB,QAAA,MAAM,gBAAgB,IAAI,CAAA;AAE1B,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,0BAA0B,QAyGpE;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,aAAa,GACd,CAAA"}
1
+ {"version":3,"file":"decodeWorkerImpl.d.ts","sourceRoot":"","sources":["../../src/worker/decodeWorkerImpl.ts"],"names":[],"mappings":"AAeA,QAAA,MAAM,aAAa,IAAI,CAAA;AACvB,QAAA,MAAM,iBAAiB,IAAI,CAAA;AAC3B,QAAA,MAAM,eAAe,IAAI,CAAA;AACzB,QAAA,MAAM,UAAU,IAAI,CAAA;AACpB,QAAA,MAAM,UAAU,IAAI,CAAA;AACpB,QAAA,MAAM,aAAa,IAAI,CAAA;AACvB,QAAA,MAAM,gBAAgB,IAAI,CAAA;AAE1B,wBAAgB,oBAAoB,CAAC,IAAI,EAAE,0BAA0B,QAkEpE;AAED,OAAO,EACL,eAAe,EACf,aAAa,EACb,UAAU,EACV,gBAAgB,EAChB,iBAAiB,EACjB,UAAU,EACV,aAAa,GACd,CAAA"}
@@ -3,7 +3,7 @@ export declare class WorkerPool<Request, Response> {
3
3
  private idle;
4
4
  private queue;
5
5
  constructor(workerFactory: () => Worker, num: number);
6
- run(request: Request): Promise<Response>;
6
+ run(request: Request, transfer?: Transferable[]): Promise<Response>;
7
7
  private dispatch;
8
8
  private release;
9
9
  broadcast(message: unknown): void;
@@ -1 +1 @@
1
- {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/worker/pool.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU,CAAC,OAAO,EAAE,QAAQ;IACvC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,KAAK,CAIL;gBAEI,aAAa,EAAE,MAAM,MAAM,EAAE,GAAG,EAAE,MAAM;IAKpD,GAAG,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWxC,OAAO,CAAC,QAAQ;IA4BhB,OAAO,CAAC,OAAO;IASR,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMjC,SAAS;CAKjB"}
1
+ {"version":3,"file":"pool.d.ts","sourceRoot":"","sources":["../../src/worker/pool.ts"],"names":[],"mappings":"AAAA,qBAAa,UAAU,CAAC,OAAO,EAAE,QAAQ;IACvC,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,IAAI,CAAU;IACtB,OAAO,CAAC,KAAK,CAKL;gBAEI,aAAa,EAAE,MAAM,MAAM,EAAE,GAAG,EAAE,MAAM;IAKpD,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,QAAQ,CAAC,EAAE,YAAY,EAAE,GAAG,OAAO,CAAC,QAAQ,CAAC;IAWnE,OAAO,CAAC,QAAQ;IA6BhB,OAAO,CAAC,OAAO;IASR,SAAS,CAAC,OAAO,EAAE,OAAO,GAAG,IAAI;IAMjC,SAAS;CAKjB"}
@@ -0,0 +1,12 @@
1
+ export type WorkerDecodeTask = {
2
+ kind: 'texture-basis';
3
+ bytes: ArrayBuffer;
4
+ format: number;
5
+ } | {
6
+ kind: 'texture-image';
7
+ bytes: ArrayBuffer;
8
+ } | {
9
+ kind: 'model-sbo';
10
+ bytes: ArrayBuffer;
11
+ };
12
+ //# sourceMappingURL=workerTask.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerTask.d.ts","sourceRoot":"","sources":["../../src/worker/workerTask.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,gBAAgB,GACxB;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,WAAW,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAC7D;IAAE,IAAI,EAAE,eAAe,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,GAC7C;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,KAAK,EAAE,WAAW,CAAA;CAAE,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sanox/sangine-core",
3
- "version": "0.4.3",
3
+ "version": "0.4.5",
4
4
  "description": "Sangine core renderer runtime (WASM + workers)",
5
5
  "type": "module",
6
6
  "private": false,