@sanox/sangine-core 0.3.0 → 0.3.1
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.
- package/dist/index.cjs.js +1 -1
- package/dist/index.es.js +1 -1
- package/dist/wasm/sangine/sangine.d.ts +1 -1
- package/dist/wasm/sangine/{sangine.4ff87b52.js → sangine.da2149d8.js} +11 -11
- package/dist/wasm/sangine/{sangine_bg.4ff87b52.wasm → sangine_bg.da2149d8.wasm} +0 -0
- package/dist/wasm/sangine/sangine_bg.wasm.d.ts +1 -1
- package/dist/wasm-hashes/sangine.d.ts +1 -1
- package/package.json +1 -1
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var f=Object.defineProperty;var y=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var r=(o,e,t)=>y(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g="/static/sangine/wasm",_="
|
|
1
|
+
"use strict";var f=Object.defineProperty;var y=(o,e,t)=>e in o?f(o,e,{enumerable:!0,configurable:!0,writable:!0,value:t}):o[e]=t;var r=(o,e,t)=>y(o,typeof e!="symbol"?e+"":e,t);Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const g="/static/sangine/wasm",_="da2149d8";class R{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 n=this.idle.pop();n?this.dispatch(n,e,t,s):this.queue.push({request:e,resolve:t,reject:s})})}dispatch(e,t,s,n){const w=i=>{s(i.data),a(),this.release(e)},d=i=>{n(i),a(),this.release(e)},a=()=>{e.removeEventListener("message",w),e.removeEventListener("error",d)};e.addEventListener("message",w,{once:!0}),e.addEventListener("error",d,{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)}terminate(){for(const e of this.workers)e.terminate()}}class p{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(`${g}/sangine/sangine.${_}.js`,window.location.origin).toString());await t.default(),this.wasm=t,this._inited=!0;const s=this.config.numWorkers??(navigator.hardwareConcurrency||2)-1;this.decodePool=new R(()=>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)}handleSangineEvent(e,t){t==="ready"?this.windowCreatedPromiseResolveRegistry[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 n;const w=new Promise(a=>{n=a}),d=this.wasm.create_window(e,t,s);return this.windowCreatedPromiseResolveRegistry[d]=n,this.callbackRegistry[d]={actionChanged:[],routeUpdated:[],measurementCreated:[],assetsDownloading:[]},this.userActionRegistry[d]="watching",this.windowCreatedPromiseRegistry[d]=w,d}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 b="fa5ceba1";function A(o,e){let t=!1,s=null,n=null;async function w(d,a){if(n){const i=`https://sangine-asset-cache/${d}`,c=await n.match(i);if(c)return c;const l=await a(),h=await fetch(l);return h.ok&&await n.put(i,h.clone()),h}return fetch(await a())}o.onmessage=async d=>{if(!t){const c=await import(new URL(`${g}/sbo-decode/wasm_sbo_decode.${b}.js`,o.location.origin).href);await c.default(),s=c,t=!0}!n&&typeof caches<"u"&&(n=await caches.open("sangine-assets-v1"));const{data:a}=d;if("texture-file"in a)try{const i=await w(a["texture-file"].pk,()=>e(a));if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const c=await i.blob(),l=await createImageBitmap(c),h=new OffscreenCanvas(l.width,l.height),m=h.getContext("2d");if(m===null)throw new Error("Couldnt create canvas");m.drawImage(l,0,0);const u=m.getImageData(0,0,h.width,h.height);o.postMessage({success:!0,width:h.width,height:h.height,data:u.data.buffer},[u.data.buffer])}catch(i){o.postMessage({success:!1,error:i.message})}else if("model-part-mesh"in a){const i=await w(a["model-part-mesh"].pk,()=>e(a));if(!i.ok)throw new Error(`HTTP error! status: ${i.status}`);const c=await i.arrayBuffer(),l=new Uint8Array(c),h=s.decode_sbo(l);o.postMessage({success:!0,data:h.buffer},[h.buffer])}}}exports.RendererService=p;exports.registerDecodeWorker=A;
|
package/dist/index.es.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var f = Object.defineProperty;
|
|
2
2
|
var y = (o, e, t) => e in o ? f(o, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : o[e] = t;
|
|
3
3
|
var r = (o, e, t) => y(o, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
-
const g = "/static/sangine/wasm", _ = "
|
|
4
|
+
const g = "/static/sangine/wasm", _ = "da2149d8";
|
|
5
5
|
class R {
|
|
6
6
|
constructor(e, t) {
|
|
7
7
|
r(this, "workers");
|
|
@@ -66,6 +66,7 @@ export type InitInput = RequestInfo | URL | Response | BufferSource | WebAssembl
|
|
|
66
66
|
|
|
67
67
|
export interface InitOutput {
|
|
68
68
|
readonly memory: WebAssembly.Memory;
|
|
69
|
+
readonly run: () => void;
|
|
69
70
|
readonly register_event_listener: (a: any) => void;
|
|
70
71
|
readonly register_asset_decoder: (a: any) => void;
|
|
71
72
|
readonly set_lighting_mode: (a: number, b: any) => [number, number];
|
|
@@ -83,7 +84,6 @@ export interface InitOutput {
|
|
|
83
84
|
readonly destroy_window: (a: number) => [number, number];
|
|
84
85
|
readonly set_window_action: (a: number, b: any) => [number, number];
|
|
85
86
|
readonly create_window: (a: number, b: number, c: any, d: number) => [number, number, number];
|
|
86
|
-
readonly run: () => void;
|
|
87
87
|
readonly wasm_bindgen__closure__destroy__h17333457aae2b090: (a: number, b: number) => void;
|
|
88
88
|
readonly wasm_bindgen__closure__destroy__hf05ec8f078dda008: (a: number, b: number) => void;
|
|
89
89
|
readonly wasm_bindgen__convert__closures_____invoke__h2a85c969f4c20848: (a: number, b: number, c: any, d: any) => void;
|
|
@@ -2647,52 +2647,52 @@ function __wbg_get_imports() {
|
|
|
2647
2647
|
arg0.writeTexture(arg1, arg2, arg3, arg4);
|
|
2648
2648
|
}, arguments); },
|
|
2649
2649
|
__wbindgen_cast_0000000000000001: function(arg0, arg1) {
|
|
2650
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2650
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("Array<any>"), NamedExternref("ResizeObserver")], shim_idx: 3804, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2651
2651
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h2a85c969f4c20848);
|
|
2652
2652
|
return ret;
|
|
2653
2653
|
},
|
|
2654
2654
|
__wbindgen_cast_0000000000000002: function(arg0, arg1) {
|
|
2655
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2655
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("Array<any>")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2656
2656
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2657
2657
|
return ret;
|
|
2658
2658
|
},
|
|
2659
2659
|
__wbindgen_cast_0000000000000003: function(arg0, arg1) {
|
|
2660
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2660
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("Event")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2661
2661
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2662
2662
|
return ret;
|
|
2663
2663
|
},
|
|
2664
2664
|
__wbindgen_cast_0000000000000004: function(arg0, arg1) {
|
|
2665
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2665
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("FocusEvent")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2666
2666
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2667
2667
|
return ret;
|
|
2668
2668
|
},
|
|
2669
2669
|
__wbindgen_cast_0000000000000005: function(arg0, arg1) {
|
|
2670
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2670
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("KeyboardEvent")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2671
2671
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2672
2672
|
return ret;
|
|
2673
2673
|
},
|
|
2674
2674
|
__wbindgen_cast_0000000000000006: function(arg0, arg1) {
|
|
2675
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2675
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("PageTransitionEvent")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2676
2676
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2677
2677
|
return ret;
|
|
2678
2678
|
},
|
|
2679
2679
|
__wbindgen_cast_0000000000000007: function(arg0, arg1) {
|
|
2680
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2680
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("PointerEvent")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2681
2681
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2682
2682
|
return ret;
|
|
2683
2683
|
},
|
|
2684
2684
|
__wbindgen_cast_0000000000000008: function(arg0, arg1) {
|
|
2685
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2685
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [NamedExternref("WheelEvent")], shim_idx: 3799, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2686
2686
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__h091d820f15c8c0c2);
|
|
2687
2687
|
return ret;
|
|
2688
2688
|
},
|
|
2689
2689
|
__wbindgen_cast_0000000000000009: function(arg0, arg1) {
|
|
2690
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2690
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3798, function: Function { arguments: [], shim_idx: 3802, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2691
2691
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__h17333457aae2b090, wasm_bindgen__convert__closures_____invoke__he5f4030ca973712a);
|
|
2692
2692
|
return ret;
|
|
2693
2693
|
},
|
|
2694
2694
|
__wbindgen_cast_000000000000000a: function(arg0, arg1) {
|
|
2695
|
-
// Cast intrinsic for `Closure(Closure { dtor_idx:
|
|
2695
|
+
// Cast intrinsic for `Closure(Closure { dtor_idx: 3855, function: Function { arguments: [Externref], shim_idx: 3856, ret: Unit, inner_ret: Some(Unit) }, mutable: true }) -> Externref`.
|
|
2696
2696
|
const ret = makeMutClosure(arg0, arg1, wasm.wasm_bindgen__closure__destroy__hf05ec8f078dda008, wasm_bindgen__convert__closures_____invoke__h07eaa4ea93496cfb);
|
|
2697
2697
|
return ret;
|
|
2698
2698
|
},
|
|
@@ -3234,7 +3234,7 @@ async function __wbg_init(module_or_path) {
|
|
|
3234
3234
|
}
|
|
3235
3235
|
|
|
3236
3236
|
if (module_or_path === undefined) {
|
|
3237
|
-
module_or_path = new URL('sangine_bg.
|
|
3237
|
+
module_or_path = new URL('sangine_bg.da2149d8.wasm', import.meta.url);
|
|
3238
3238
|
}
|
|
3239
3239
|
const imports = __wbg_get_imports();
|
|
3240
3240
|
|
|
Binary file
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const run: () => void;
|
|
4
5
|
export const register_event_listener: (a: any) => void;
|
|
5
6
|
export const register_asset_decoder: (a: any) => void;
|
|
6
7
|
export const set_lighting_mode: (a: number, b: any) => [number, number];
|
|
@@ -18,7 +19,6 @@ export const set_route_highlight: (a: number, b: number, c: number, d: number) =
|
|
|
18
19
|
export const destroy_window: (a: number) => [number, number];
|
|
19
20
|
export const set_window_action: (a: number, b: any) => [number, number];
|
|
20
21
|
export const create_window: (a: number, b: number, c: any, d: number) => [number, number, number];
|
|
21
|
-
export const run: () => void;
|
|
22
22
|
export const wasm_bindgen__closure__destroy__h17333457aae2b090: (a: number, b: number) => void;
|
|
23
23
|
export const wasm_bindgen__closure__destroy__hf05ec8f078dda008: (a: number, b: number) => void;
|
|
24
24
|
export const wasm_bindgen__convert__closures_____invoke__h2a85c969f4c20848: (a: number, b: number, c: any, d: any) => void;
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export declare const SANGINE_HASH = "
|
|
1
|
+
export declare const SANGINE_HASH = "da2149d8";
|
|
2
2
|
//# sourceMappingURL=sangine.d.ts.map
|