@onirix/ar-engine-sdk 1.6.1 → 1.6.2

Sign up to get free protection for your applications and to get access to all the features.
package/dist/worker-b.js CHANGED
@@ -1,3 +1,3 @@
1
1
  class IndexedDBManager{constructor(e,r){this.dbName=e,this.storeName=r;}async getFromCacheOrFetch(e,r){let t=null;try{t=await this.getFileFromIndexedDB(e);}catch(e){console.log("An error occurred while trying to get element from indexedDB.");}return t||(t=await this.fetchAndCacheFile(r,e)),new Uint8Array(t)}async getFileFromIndexedDB(e){return new Promise(((r,t)=>{const o=indexedDB.open(this.dbName);o.onerror=()=>t(o.error),o.onsuccess=()=>{const s=o.result.transaction(this.storeName,"readonly").objectStore(this.storeName).get(e);s.onsuccess=()=>r(s.result),s.onerror=()=>t(s.error);},o.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName);};}))}async saveFileToIndexedDB(e,r){return new Promise(((t,o)=>{const s=indexedDB.open(this.dbName);s.onerror=()=>o(s.error),s.onupgradeneeded=e=>{e.target.result.createObjectStore(this.storeName);},s.onsuccess=()=>{try{const n=s.result.transaction(this.storeName,"readwrite"),a=n.objectStore(this.storeName).put(r,e);a.onsuccess=()=>t(a.result),a.onerror=()=>o(a.error);}catch(e){o(e);}};}))}async fetchAndCacheFile(e,r){const t=await fetch(e),o=await t.arrayBuffer();return await this.saveFileToIndexedDB(r,o),o}}
2
2
 
3
- class WorkerNative{constructor(){this.ready=!1;this.indexedDBManager=new IndexedDBManager("onirix-sdk","files"),this.indexedDBManager.getFileFromIndexedDB("SDK_1.6.1").then((async e=>{let t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));const{default:a}=await import(/* webpackIgnore: true, webpackMode: "lazy" */t),r=await a();this.nativeSDK=r,this.fromBuffer=this.nativeSDK._malloc(22e5),this.toBuffer=this.nativeSDK._malloc(22e5),this.ready=!0,postMessage("ready");}));}start(){addEventListener("message",(async e=>{if(!this.ready)return;const t=e.data,a=t.from,r=t.to;this.nativeSDK.HEAPF32.set(a,this.fromBuffer/4),this.nativeSDK.HEAPF32.set(r,this.toBuffer/4);let s=this.nativeSDK._OX_Match(this.fromBuffer,this.toBuffer,t.dtype);postMessage(new Float32Array(this.readMatchingData(this.nativeSDK.HEAPF32,s/4)));}));}readMatchingData(e,t){let a=t,r=[],s=e[a];r.push(s),a++;for(let t=0;t<s;t++)r.push(e[a]),r.push(e[a+1]),a+=2;return r}}const worker=new WorkerNative;worker.start();
3
+ class WorkerNative{constructor(){this.ready=!1;this.indexedDBManager=new IndexedDBManager("onirix-sdk","files"),this.indexedDBManager.getFileFromIndexedDB("SDK_1.6.2").then((async e=>{let t=URL.createObjectURL(new Blob([e],{type:"text/javascript"}));const{default:a}=await import(/* webpackIgnore: true, webpackMode: "lazy" */t),r=await a();this.nativeSDK=r,this.fromBuffer=this.nativeSDK._malloc(22e5),this.toBuffer=this.nativeSDK._malloc(22e5),this.ready=!0,postMessage("ready");}));}start(){addEventListener("message",(async e=>{if(!this.ready)return;const t=e.data,a=t.from,r=t.to;this.nativeSDK.HEAPF32.set(a,this.fromBuffer/4),this.nativeSDK.HEAPF32.set(r,this.toBuffer/4);let s=this.nativeSDK._OX_Match(this.fromBuffer,this.toBuffer,t.dtype);postMessage(new Float32Array(this.readMatchingData(this.nativeSDK.HEAPF32,s/4)));}));}readMatchingData(e,t){let a=t,r=[],s=e[a];r.push(s),a++;for(let t=0;t<s;t++)r.push(e[a]),r.push(e[a+1]),a+=2;return r}}const worker=new WorkerNative;worker.start();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onirix/ar-engine-sdk",
3
- "version": "1.6.1",
3
+ "version": "1.6.2",
4
4
  "description": "Onirix AR Engine SDK allows to create Augmented Reality experiences that run in a web browser.",
5
5
  "main": "./dist/ox-sdk.js",
6
6
  "module": "./dist/ox-sdk.esm.js",