@hatiolab/things-scene 9.0.0-beta.13 → 9.0.0-beta.14

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,21 @@
1
+ /**
2
+ * @licstart The following is the entire license notice for the
3
+ * JavaScript code in this page
4
+ *
5
+ * Copyright 2024 Mozilla Foundation
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ *
19
+ * @licend The above is the entire license notice for the
20
+ * JavaScript code in this page
21
+ */
package/582.js ADDED
@@ -0,0 +1,2 @@
1
+ /*! For license information please see 582.js.LICENSE.txt */
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.scene=e():t.scene=e()}(self,(()=>(()=>{"use strict";var t,e,r={89582:(t,e,r)=>{var n=r(91100);function o(t){return o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},o(t)}function a(){a=function(){return e};var t,e={},r=Object.prototype,n=r.hasOwnProperty,i=Object.defineProperty||function(t,e,r){t[e]=r.value},c="function"==typeof Symbol?Symbol:{},u=c.iterator||"@@iterator",s=c.asyncIterator||"@@asyncIterator",f=c.toStringTag||"@@toStringTag";function l(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{l({},"")}catch(t){l=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,a=Object.create(o.prototype),c=new T(n||[]);return i(a,"_invoke",{value:D(t,r,c)}),a}function h(t,e,r){try{return{type:"normal",arg:t.call(e,r)}}catch(t){return{type:"throw",arg:t}}}e.wrap=p;var y="suspendedStart",d="suspendedYield",v="executing",m="completed",g={};function b(){}function w(){}function x(){}var E={};l(E,u,(function(){return this}));var k=Object.getPrototypeOf,L=k&&k(k(A([])));L&&L!==r&&n.call(L,u)&&(E=L);var j=x.prototype=b.prototype=Object.create(E);function O(t){["next","throw","return"].forEach((function(e){l(t,e,(function(t){return this._invoke(e,t)}))}))}function S(t,e){function r(a,i,c,u){var s=h(t[a],t,i);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==o(l)&&n.call(l,"__await")?e.resolve(l.__await).then((function(t){r("next",t,c,u)}),(function(t){r("throw",t,c,u)})):e.resolve(l).then((function(t){f.value=t,c(f)}),(function(t){return r("throw",t,c,u)}))}u(s.arg)}var a;i(this,"_invoke",{value:function(t,n){function o(){return new e((function(e,o){r(t,n,e,o)}))}return a=a?a.then(o,o):o()}})}function D(e,r,n){var o=y;return function(a,i){if(o===v)throw Error("Generator is already running");if(o===m){if("throw"===a)throw i;return{value:t,done:!0}}for(n.method=a,n.arg=i;;){var c=n.delegate;if(c){var u=I(c,n);if(u){if(u===g)continue;return u}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if(o===y)throw o=m,n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);o=v;var s=h(e,r,n);if("normal"===s.type){if(o=n.done?m:d,s.arg===g)continue;return{value:s.arg,done:n.done}}"throw"===s.type&&(o=m,n.method="throw",n.arg=s.arg)}}}function I(e,r){var n=r.method,o=e.iterator[n];if(o===t)return r.delegate=null,"throw"===n&&e.iterator.return&&(r.method="return",r.arg=t,I(e,r),"throw"===r.method)||"return"!==n&&(r.method="throw",r.arg=new TypeError("The iterator does not provide a '"+n+"' method")),g;var a=h(o,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,g;var i=a.arg;return i?i.done?(r[e.resultName]=i.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=t),r.delegate=null,g):i:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,g)}function _(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function P(t){var e=t.completion||{};e.type="normal",delete e.arg,t.completion=e}function T(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(_,this),this.reset(!0)}function A(e){if(e||""===e){var r=e[u];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var a=-1,i=function r(){for(;++a<e.length;)if(n.call(e,a))return r.value=e[a],r.done=!1,r;return r.value=t,r.done=!0,r};return i.next=i}}throw new TypeError(o(e)+" is not iterable")}return w.prototype=x,i(j,"constructor",{value:x,configurable:!0}),i(x,"constructor",{value:w,configurable:!0}),w.displayName=l(x,f,"GeneratorFunction"),e.isGeneratorFunction=function(t){var e="function"==typeof t&&t.constructor;return!!e&&(e===w||"GeneratorFunction"===(e.displayName||e.name))},e.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,x):(t.__proto__=x,l(t,f,"GeneratorFunction")),t.prototype=Object.create(j),t},e.awrap=function(t){return{__await:t}},O(S.prototype),l(S.prototype,s,(function(){return this})),e.AsyncIterator=S,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new S(p(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},O(j),l(j,f,"Generator"),l(j,u,(function(){return this})),l(j,"toString",(function(){return"[object Generator]"})),e.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},e.values=A,T.prototype={constructor:T,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=t,this.done=!1,this.delegate=null,this.method="next",this.arg=t,this.tryEntries.forEach(P),!e)for(var r in this)"t"===r.charAt(0)&&n.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=t)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var r=this;function o(n,o){return c.type="throw",c.arg=e,r.next=n,o&&(r.method="next",r.arg=t),!!o}for(var a=this.tryEntries.length-1;a>=0;--a){var i=this.tryEntries[a],c=i.completion;if("root"===i.tryLoc)return o("end");if(i.tryLoc<=this.prev){var u=n.call(i,"catchLoc"),s=n.call(i,"finallyLoc");if(u&&s){if(this.prev<i.catchLoc)return o(i.catchLoc,!0);if(this.prev<i.finallyLoc)return o(i.finallyLoc)}else if(u){if(this.prev<i.catchLoc)return o(i.catchLoc,!0)}else{if(!s)throw Error("try statement without catch or finally");if(this.prev<i.finallyLoc)return o(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var o=this.tryEntries[r];if(o.tryLoc<=this.prev&&n.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=e&&e<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=e,a?(this.method="next",this.next=a.finallyLoc,g):this.complete(i)},complete:function(t,e){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&e&&(this.next=e),g},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),P(r),g}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if("throw"===n.type){var o=n.arg;P(r)}return o}}throw Error("illegal catch attempt")},delegateYield:function(e,r,n){return this.delegate={iterator:A(e),resultName:r,nextLoc:n},"next"===this.method&&(this.arg=t),g}},e}function i(t,e){if(t){if("string"==typeof t)return c(t,e);var r={}.toString.call(t).slice(8,-1);return"Object"===r&&t.constructor&&(r=t.constructor.name),"Map"===r||"Set"===r?Array.from(t):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?c(t,e):void 0}}function c(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}function u(t,e,r,n,o,a,i){try{var c=t[a](i),u=c.value}catch(t){return void r(t)}c.done?e(u):Promise.resolve(u).then(n,o)}function s(t){return function(){var e=this,r=arguments;return new Promise((function(n,o){var a=t.apply(e,r);function i(t){u(a,n,o,i,c,"next",t)}function c(t){u(a,n,o,i,c,"throw",t)}i(void 0)}))}}n.EA.workerSrc="/assets/javascript/pdf.worker.min.mjs";var f,l=new Map,p=new Map,h=new Map,y=512;function d(){return(d=s(a().mark((function t(){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,e){var r=indexedDB.open("PDFTileCache",1);r.onupgradeneeded=function(t){(f=t.target.result).objectStoreNames.contains("tiles")||f.createObjectStore("tiles",{keyPath:"tileKey"}),f.objectStoreNames.contains("pdf_cache_metadata")||f.createObjectStore("pdf_cache_metadata",{keyPath:"url"})},r.onsuccess=function(e){f=e.target.result,t()},r.onerror=function(t){console.error("IndexedDB Error:",t.target.error),e(t.target.error)}})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function v(t,e){return m.apply(this,arguments)}function m(){return(m=s(a().mark((function t(e,r){var n,o,i,c;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return(n=new OffscreenCanvas(y,y)).getContext("2d").drawImage(r,0,0),t.next=5,n.convertToBlob({type:"image/png"});case 5:return o=t.sent,i=f.transaction("tiles","readwrite"),c=i.objectStore("tiles"),t.next=10,c.put({tileKey:e,blob:o,timestamp:Date.now()});case 10:case"end":return t.stop()}}),t)})))).apply(this,arguments)}function g(t){return b.apply(this,arguments)}function b(){return(b=s(a().mark((function t(e){return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",new Promise((function(t,r){var n=f.transaction("tiles","readonly").objectStore("tiles").get(e);n.onsuccess=s(a().mark((function e(){var r,o;return a().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=n.result){e.next=3;break}return e.abrupt("return",t(null));case 3:if(!(Date.now()-r.timestamp>864e5)){e.next=7;break}t(null),e.next=11;break;case 7:return e.next=9,createImageBitmap(r.blob);case 9:o=e.sent,t(o);case 11:case"end":return e.stop()}}),e)}))),n.onerror=function(){return r("Failed to load tile from cache")}})));case 1:case"end":return t.stop()}}),t)})))).apply(this,arguments)}self.onmessage=function(){var t=s(a().mark((function t(e){var r,o,i,c,u,f,d,m,b,w,x,E,k,L,j,O,S;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:r=e.data,o=r.type,i=r.pdfUrl,c=r.pageNumber,u=r.zoom,f=r.row,d=r.col,t.prev=1,t.t0=o,t.next="LOAD_PDF"===t.t0?5:"REQUEST_TILE"===t.t0?9:47;break;case 5:return m="pdf-".concat(crypto.randomUUID()),postMessage({type:"PDF_ID_ASSIGNED",pdfId:m}),p.has(m)||p.set(m,new Promise(function(){var t=s(a().mark((function t(e,r){var o,c,u;return a().wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.prev=0,console.log("📌 Downloading PDF (ID: ".concat(m,") from URL: ").concat(i)),t.next=4,fetch(i);case 4:return o=t.sent,t.next=7,o.arrayBuffer();case 7:return c=t.sent,t.next=10,(0,n.YE)({data:c}).promise;case 10:u=t.sent,l.set(m,u),e(u),postMessage({type:"PDF_LOADED",pdfId:m}),t.next=22;break;case 16:t.prev=16,t.t0=t.catch(0),console.error("Failed to load PDF (ID: ".concat(m,"):"),t.t0),p.delete(m),r(t.t0),postMessage({type:"PDF_LOAD_FAILED",pdfId:m,error:t.t0.message});case 22:case"end":return t.stop()}}),t,null,[[0,16]])})));return function(e,r){return t.apply(this,arguments)}}())),t.abrupt("break",47);case 9:if(b=e.data.pdfId,l.has(b)){t.next=19;break}if(!p.has(b)){t.next=17;break}return console.log("⏳ Tile request waiting for PDF (ID: ".concat(b,") to load...")),t.next=15,p.get(b);case 15:t.next=19;break;case 17:return postMessage({type:"PDF_NOT_FOUND",pdfId:b}),t.abrupt("return");case 19:if(w="".concat(u,"_").concat(f,"_").concat(d),!h.has(w)){t.next=23;break}return postMessage({type:"TILE_CACHED",pdfId:b,tileKey:w,imageBitmap:h.get(w).imageBitmap}),t.abrupt("return");case 23:return t.next=25,g(w);case 25:if(!(x=t.sent)){t.next=30;break}return h.set(w,{imageBitmap:x,timestamp:Date.now()}),postMessage({type:"TILE_CACHED",pdfId:b,tileKey:w,imageBitmap:x}),t.abrupt("return");case 30:return E=l.get(b),t.next=33,E.getPage(c);case 33:return k=t.sent,L=k.getViewport({scale:u}),j=new OffscreenCanvas(y,y),O=j.getContext("2d"),t.next=39,k.render({canvasContext:O,viewport:L}).promise;case 39:return t.next=41,j.transferToImageBitmap();case 41:return S=t.sent,h.set(w,{imageBitmap:S,timestamp:Date.now()}),t.next=45,v(w,S);case 45:return postMessage({type:"TILE_RENDERED",pdfId:b,tileKey:w,imageBitmap:S},[S]),t.abrupt("break",47);case 47:t.next=52;break;case 49:t.prev=49,t.t1=t.catch(1),console.error("Worker error:",t.t1);case 52:case"end":return t.stop()}}),t,null,[[1,49]])})));return function(e){return t.apply(this,arguments)}}(),function(){d.apply(this,arguments)}(),setInterval((function(){var t,e,r,n=Date.now(),o=function(t){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(!e){if(Array.isArray(t)||(e=i(t))){e&&(t=e);var r=0,n=function(){};return{s:n,n:function(){return r>=t.length?{done:!0}:{done:!1,value:t[r++]}},e:function(t){throw t},f:n}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var o,a=!0,c=!1;return{s:function(){e=e.call(t)},n:function(){var t=e.next();return a=t.done,t},e:function(t){c=!0,o=t},f:function(){try{a||null==e.return||e.return()}finally{if(c)throw o}}}}(h.entries());try{for(o.s();!(t=o.n()).done;){var a=(e=t.value,r=2,function(t){if(Array.isArray(t))return t}(e)||function(t,e){var r=null==t?null:"undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(null!=r){var n,o,a,i,c=[],u=!0,s=!1;try{if(a=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;u=!1}else for(;!(u=(n=a.call(r)).done)&&(c.push(n.value),c.length!==e);u=!0);}catch(t){s=!0,o=t}finally{try{if(!u&&null!=r.return&&(i=r.return(),Object(i)!==i))return}finally{if(s)throw o}}return c}}(e,r)||i(e,r)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()),c=a[0];n-a[1].timestamp>6e5&&h.delete(c)}}catch(t){o.e(t)}finally{o.f()}}),6e4)}},n={};function o(t){var e=n[t];if(void 0!==e)return e.exports;var a=n[t]={exports:{}};return r[t](a,a.exports,o),a.exports}return o.m=r,o.x=()=>{var t=o.O(void 0,[100],(()=>o(89582)));return o.O(t)},t=[],o.O=(e,r,n,a)=>{if(!r){var i=1/0;for(f=0;f<t.length;f++){for(var[r,n,a]=t[f],c=!0,u=0;u<r.length;u++)(!1&a||i>=a)&&Object.keys(o.O).every((t=>o.O[t](r[u])))?r.splice(u--,1):(c=!1,a<i&&(i=a));if(c){t.splice(f--,1);var s=n();void 0!==s&&(e=s)}}return e}a=a||0;for(var f=t.length;f>0&&t[f-1][2]>a;f--)t[f]=t[f-1];t[f]=[r,n,a]},o.d=(t,e)=>{for(var r in e)o.o(e,r)&&!o.o(t,r)&&Object.defineProperty(t,r,{enumerable:!0,get:e[r]})},o.f={},o.e=t=>Promise.all(Object.keys(o.f).reduce(((e,r)=>(o.f[r](t,e),e)),[])),o.u=t=>t+".js",o.g=function(){if("object"==typeof globalThis)return globalThis;try{return this||new Function("return this")()}catch(t){if("object"==typeof window)return window}}(),o.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{var t;o.g.importScripts&&(t=o.g.location+"");var e=o.g.document;if(!t&&e&&(e.currentScript&&"SCRIPT"===e.currentScript.tagName.toUpperCase()&&(t=e.currentScript.src),!t)){var r=e.getElementsByTagName("script");if(r.length)for(var n=r.length-1;n>-1&&(!t||!/^http(s?):/.test(t));)t=r[n--].src}if(!t)throw new Error("Automatic publicPath is not supported in this browser");t=t.replace(/#.*$/,"").replace(/\?.*$/,"").replace(/\/[^\/]+$/,"/"),o.p=t})(),(()=>{var t={582:1};o.f.i=(e,r)=>{t[e]||importScripts(o.p+o.u(e))};var e=self.webpackChunkscene=self.webpackChunkscene||[],r=e.push.bind(e);e.push=e=>{var[n,a,i]=e;for(var c in a)o.o(a,c)&&(o.m[c]=a[c]);for(i&&i(o);n.length;)t[n.pop()]=1;r(e)}})(),e=o.x,o.x=()=>o.e(100).then(e),o.x()})()));
@@ -0,0 +1 @@
1
+ /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hatiolab/things-scene",
3
- "version": "9.0.0-beta.13",
3
+ "version": "9.0.0-beta.14",
4
4
  "description": "2D graphic library",
5
5
  "main": "src/index.js",
6
6
  "module": "things-scene.mjs",
@@ -28,6 +28,7 @@
28
28
  "serve:dev": "things-factory-dev",
29
29
  "serve:simple-http-server": "webpack-dev-server --config webpack.config.dev.js --hot --inline --host 0.0.0.0",
30
30
  "build": "webpack && rollup -c",
31
+ "build:clean": "rm yarn.lock || echo 'yarn.lock not found.' && yarn install && yarn build",
31
32
  "build:client": "npm run clean:client && webpack --config node_modules/@things-factory/shell/webpack.config.js",
32
33
  "clean:client": "rm -rf dist-client",
33
34
  "prepublish": "webpack && rollup -c",
@@ -85,7 +86,8 @@
85
86
  "canvas-roundrect-polyfill": "^0.0.1",
86
87
  "core-js": "^3.26.0",
87
88
  "jsonata": "^1.8.6",
88
- "lodash-es": "^4.17.20"
89
+ "lodash-es": "^4.17.20",
90
+ "pdfjs-dist": "^4.10.38"
89
91
  },
90
92
  "resolutions": {
91
93
  "@azure/storage-blob": "12.18.0",