@loaders.gl/core 3.1.0-alpha.2 → 4.0.0-alpha.3
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/bundle.js +2 -4
- package/dist/bundle.js.map +1 -1
- package/dist/lib/api/encode.js +1 -1
- package/dist/lib/api/encode.js.map +1 -1
- package/dist/lib/api/parse-sync.js +1 -1
- package/dist/lib/api/parse-sync.js.map +1 -1
- package/dist/lib/api/parse.js +1 -1
- package/dist/lib/api/parse.js.map +1 -1
- package/dist/lib/api/register-loaders.js.map +1 -1
- package/dist/lib/api/select-loader.js +8 -12
- package/dist/lib/api/select-loader.js.map +1 -1
- package/dist/lib/fetch/fetch-error-message.js +2 -2
- package/dist/lib/fetch/fetch-error-message.js.map +1 -1
- package/dist/lib/init.js +3 -4
- package/dist/lib/init.js.map +1 -1
- package/dist/lib/loader-utils/check-errors.js +4 -4
- package/dist/lib/loader-utils/check-errors.js.map +1 -1
- package/dist/lib/loader-utils/option-utils.js +7 -8
- package/dist/lib/loader-utils/option-utils.js.map +1 -1
- package/dist/lib/utils/response-utils.js +7 -7
- package/dist/lib/utils/response-utils.js.map +1 -1
- package/dist/null-loader.js +1 -1
- package/dist/null-worker.js +178 -2
- package/package.json +6 -6
- package/src/bundle.ts +2 -3
- package/src/lib/api/encode.ts +1 -0
- package/src/lib/api/register-loaders.ts +2 -1
- package/src/lib/api/select-loader.ts +10 -9
- package/src/lib/init.js +2 -3
- package/src/lib/loader-utils/option-utils.ts +3 -4
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/null-worker.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/utils/response-utils.ts"],"names":["isResponse","getResourceContentLength","getResourceUrlAndType","makeResponse","resource","headers","contentLength","String","url","type","initialDataUrl","getInitialDataUrl","TextEncoder","encode","response","Response","Object","defineProperty","value","checkResponse","ok","message","getResponseError","Error","checkResponseSync","status","statusText","length","slice","contentType","get","text","includes","error","INITIAL_DATA_LENGTH","Blob","blobSlice","Promise","resolve","reader","FileReader","onload","event","target","result","readAsDataURL","ArrayBuffer","base64","arrayBufferToBase64","buffer","binary","bytes","Uint8Array","i","byteLength","fromCharCode","btoa"],"mappings":"AAAA,SAAQA,UAAR,QAAyB,gCAAzB;AACA,SAAQC,wBAAR,EAAkCC,qBAAlC,QAA8D,kBAA9D;AAQA,OAAO,eAAeC,YAAf,CAA4BC,QAA5B,EAA8D;AACnE,MAAIJ,UAAU,CAACI,QAAD,CAAd,EAA0B;AACxB,WAAOA,QAAP;AACD;;AAGD,QAAMC,OAAmC,GAAG,EAA5C;AAEA,QAAMC,aAAa,GAAGL,wBAAwB,CAACG,QAAD,CAA9C;;AACA,MAAIE,aAAa,IAAI,CAArB,EAAwB;AACtBD,IAAAA,OAAO,CAAC,gBAAD,CAAP,GAA4BE,MAAM,CAACD,aAAD,CAAlC;AACD;;AAID,QAAM;AAACE,IAAAA,GAAD;AAAMC,IAAAA;AAAN,MAAcP,qBAAqB,CAACE,QAAD,CAAzC;;AACA,MAAIK,IAAJ,EAAU;AACRJ,IAAAA,OAAO,CAAC,cAAD,CAAP,GAA0BI,IAA1B;AACD;;AAGD,QAAMC,cAAc,GAAG,MAAMC,iBAAiB,CAACP,QAAD,CAA9C;;AACA,MAAIM,cAAJ,EAAoB;AAClBL,IAAAA,OAAO,CAAC,eAAD,CAAP,GAA2BK,cAA3B;AACD;;AAID,MAAI,OAAON,QAAP,KAAoB,QAAxB,EAAkC;AAEhCA,IAAAA,QAAQ,GAAG,IAAIQ,WAAJ,GAAkBC,MAAlB,CAAyBT,QAAzB,CAAX;AACD;;AAGD,QAAMU,QAAQ,GAAG,IAAIC,QAAJ,CAAaX,QAAb,EAAuB;AAACC,IAAAA;AAAD,GAAvB,CAAjB;AAEAW,EAAAA,MAAM,CAACC,cAAP,CAAsBH,QAAtB,EAAgC,KAAhC,EAAuC;AAACI,IAAAA,KAAK,EAAEV;AAAR,GAAvC;AACA,SAAOM,QAAP;AACD;AAMD,OAAO,eAAeK,aAAf,CAA6BL,QAA7B,EAAgE;AACrE,MAAI,CAACA,QAAQ,CAACM,EAAd,EAAkB;AAChB,UAAMC,OAAO,GAAG,MAAMC,gBAAgB,CAACR,QAAD,CAAtC;AACA,UAAM,IAAIS,KAAJ,CAAUF,OAAV,CAAN;AACD;AACF;AAMD,OAAO,SAASG,iBAAT,CAA2BV,QAA3B,EAAqD;AAC1D,MAAI,CAACA,QAAQ,CAACM,EAAd,EAAkB;AAChB,QAAIC,OAAO,
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/utils/response-utils.ts"],"names":["isResponse","getResourceContentLength","getResourceUrlAndType","makeResponse","resource","headers","contentLength","String","url","type","initialDataUrl","getInitialDataUrl","TextEncoder","encode","response","Response","Object","defineProperty","value","checkResponse","ok","message","getResponseError","Error","checkResponseSync","status","statusText","length","slice","contentType","get","text","includes","error","INITIAL_DATA_LENGTH","Blob","blobSlice","Promise","resolve","reader","FileReader","onload","event","target","result","readAsDataURL","ArrayBuffer","base64","arrayBufferToBase64","buffer","binary","bytes","Uint8Array","i","byteLength","fromCharCode","btoa"],"mappings":"AAAA,SAAQA,UAAR,QAAyB,gCAAzB;AACA,SAAQC,wBAAR,EAAkCC,qBAAlC,QAA8D,kBAA9D;AAQA,OAAO,eAAeC,YAAf,CAA4BC,QAA5B,EAA8D;AACnE,MAAIJ,UAAU,CAACI,QAAD,CAAd,EAA0B;AACxB,WAAOA,QAAP;AACD;;AAGD,QAAMC,OAAmC,GAAG,EAA5C;AAEA,QAAMC,aAAa,GAAGL,wBAAwB,CAACG,QAAD,CAA9C;;AACA,MAAIE,aAAa,IAAI,CAArB,EAAwB;AACtBD,IAAAA,OAAO,CAAC,gBAAD,CAAP,GAA4BE,MAAM,CAACD,aAAD,CAAlC;AACD;;AAID,QAAM;AAACE,IAAAA,GAAD;AAAMC,IAAAA;AAAN,MAAcP,qBAAqB,CAACE,QAAD,CAAzC;;AACA,MAAIK,IAAJ,EAAU;AACRJ,IAAAA,OAAO,CAAC,cAAD,CAAP,GAA0BI,IAA1B;AACD;;AAGD,QAAMC,cAAc,GAAG,MAAMC,iBAAiB,CAACP,QAAD,CAA9C;;AACA,MAAIM,cAAJ,EAAoB;AAClBL,IAAAA,OAAO,CAAC,eAAD,CAAP,GAA2BK,cAA3B;AACD;;AAID,MAAI,OAAON,QAAP,KAAoB,QAAxB,EAAkC;AAEhCA,IAAAA,QAAQ,GAAG,IAAIQ,WAAJ,GAAkBC,MAAlB,CAAyBT,QAAzB,CAAX;AACD;;AAGD,QAAMU,QAAQ,GAAG,IAAIC,QAAJ,CAAaX,QAAb,EAAuB;AAACC,IAAAA;AAAD,GAAvB,CAAjB;AAEAW,EAAAA,MAAM,CAACC,cAAP,CAAsBH,QAAtB,EAAgC,KAAhC,EAAuC;AAACI,IAAAA,KAAK,EAAEV;AAAR,GAAvC;AACA,SAAOM,QAAP;AACD;AAMD,OAAO,eAAeK,aAAf,CAA6BL,QAA7B,EAAgE;AACrE,MAAI,CAACA,QAAQ,CAACM,EAAd,EAAkB;AAChB,UAAMC,OAAO,GAAG,MAAMC,gBAAgB,CAACR,QAAD,CAAtC;AACA,UAAM,IAAIS,KAAJ,CAAUF,OAAV,CAAN;AACD;AACF;AAMD,OAAO,SAASG,iBAAT,CAA2BV,QAA3B,EAAqD;AAC1D,MAAI,CAACA,QAAQ,CAACM,EAAd,EAAkB;AAChB,QAAIC,OAAO,aAAMP,QAAQ,CAACW,MAAf,cAAyBX,QAAQ,CAACY,UAAlC,CAAX;AACAL,IAAAA,OAAO,GAAGA,OAAO,CAACM,MAAR,GAAiB,EAAjB,aAAyBN,OAAO,CAACO,KAAR,CAAc,EAAd,CAAzB,WAAkDP,OAA5D;AACA,UAAM,IAAIE,KAAJ,CAAUF,OAAV,CAAN;AACD;AACF;;AAID,eAAeC,gBAAf,CAAgCR,QAAhC,EAA2D;AACzD,MAAIO,OAAO,sCAA+BP,QAAQ,CAACN,GAAxC,eAAgDM,QAAQ,CAACW,MAAzD,QAAX;;AACA,MAAI;AACF,UAAMI,WAAW,GAAGf,QAAQ,CAACT,OAAT,CAAiByB,GAAjB,CAAqB,cAArB,CAApB;AACA,QAAIC,IAAI,GAAGjB,QAAQ,CAACY,UAApB;;AACA,QAAIG,WAAW,CAACG,QAAZ,CAAqB,kBAArB,CAAJ,EAA8C;AAC5CD,MAAAA,IAAI,eAAQ,MAAMjB,QAAQ,CAACiB,IAAT,EAAd,CAAJ;AACD;;AACDV,IAAAA,OAAO,IAAIU,IAAX;AACAV,IAAAA,OAAO,GAAGA,OAAO,CAACM,MAAR,GAAiB,EAAjB,aAAyBN,OAAO,CAACO,KAAR,CAAc,EAAd,CAAzB,WAAkDP,OAA5D;AACD,GARD,CAQE,OAAOY,KAAP,EAAc,CAEf;;AACD,SAAOZ,OAAP;AACD;;AAED,eAAeV,iBAAf,CAAiCP,QAAjC,EAAmE;AACjE,QAAM8B,mBAAmB,GAAG,CAA5B;;AACA,MAAI,OAAO9B,QAAP,KAAoB,QAAxB,EAAkC;AAChC,2BAAgBA,QAAQ,CAACwB,KAAT,CAAe,CAAf,EAAkBM,mBAAlB,CAAhB;AACD;;AACD,MAAI9B,QAAQ,YAAY+B,IAAxB,EAA8B;AAC5B,UAAMC,SAAS,GAAGhC,QAAQ,CAACwB,KAAT,CAAe,CAAf,EAAkB,CAAlB,CAAlB;AACA,WAAO,MAAM,IAAIS,OAAJ,CAAaC,OAAD,IAAa;AACpC,YAAMC,MAAM,GAAG,IAAIC,UAAJ,EAAf;;AACAD,MAAAA,MAAM,CAACE,MAAP,GAAiBC,KAAD;AAAA;;AAAA,eAAWJ,OAAO,CAACI,KAAD,aAACA,KAAD,wCAACA,KAAK,CAAEC,MAAR,kDAAC,cAAeC,MAAhB,CAAlB;AAAA,OAAhB;;AACAL,MAAAA,MAAM,CAACM,aAAP,CAAqBT,SAArB;AACD,KAJY,CAAb;AAKD;;AACD,MAAIhC,QAAQ,YAAY0C,WAAxB,EAAqC;AACnC,UAAMlB,KAAK,GAAGxB,QAAQ,CAACwB,KAAT,CAAe,CAAf,EAAkBM,mBAAlB,CAAd;AACA,UAAMa,MAAM,GAAGC,mBAAmB,CAACpB,KAAD,CAAlC;AACA,iCAAsBmB,MAAtB;AACD;;AACD,SAAO,IAAP;AACD;;AAGD,SAASC,mBAAT,CAA6BC,MAA7B,EAAqC;AACnC,MAAIC,MAAM,GAAG,EAAb;AACA,QAAMC,KAAK,GAAG,IAAIC,UAAJ,CAAeH,MAAf,CAAd;;AACA,OAAK,IAAII,CAAC,GAAG,CAAb,EAAgBA,CAAC,GAAGF,KAAK,CAACG,UAA1B,EAAsCD,CAAC,EAAvC,EAA2C;AACzCH,IAAAA,MAAM,IAAI3C,MAAM,CAACgD,YAAP,CAAoBJ,KAAK,CAACE,CAAD,CAAzB,CAAV;AACD;;AACD,SAAOG,IAAI,CAACN,MAAD,CAAX;AACD","sourcesContent":["import {isResponse} from '../../javascript-utils/is-type';\nimport {getResourceContentLength, getResourceUrlAndType} from './resource-utils';\n\n/**\n * Returns a Response object\n * Adds content-length header when possible\n *\n * @param resource\n */\nexport async function makeResponse(resource: any): Promise<Response> {\n if (isResponse(resource)) {\n return resource;\n }\n\n // Add content-length header if possible\n const headers: {[header: string]: string} = {};\n\n const contentLength = getResourceContentLength(resource);\n if (contentLength >= 0) {\n headers['content-length'] = String(contentLength);\n }\n\n // `new Response(File)` does not preserve content-type and URL\n // so we add them here\n const {url, type} = getResourceUrlAndType(resource);\n if (type) {\n headers['content-type'] = type;\n }\n\n // Add a custom header with initial bytes if available\n const initialDataUrl = await getInitialDataUrl(resource);\n if (initialDataUrl) {\n headers['x-first-bytes'] = initialDataUrl;\n }\n\n // TODO - is this the best way of handling strings?\n // Maybe package as data URL instead?\n if (typeof resource === 'string') {\n // Convert to ArrayBuffer to avoid Response treating it as a URL\n resource = new TextEncoder().encode(resource);\n }\n\n // Attempt to create a Response from the resource, adding headers and setting url\n const response = new Response(resource, {headers});\n // We can't control `Response.url` via constructor, use a property override to record URL.\n Object.defineProperty(response, 'url', {value: url});\n return response;\n}\n\n/**\n * Checks response status (async) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport async function checkResponse(response: Response): Promise<void> {\n if (!response.ok) {\n const message = await getResponseError(response);\n throw new Error(message);\n }\n}\n\n/**\n * Checks response status (sync) and throws a helpful error message if status is not OK.\n * @param response\n */\nexport function checkResponseSync(response: Response): void {\n if (!response.ok) {\n let message = `${response.status} ${response.statusText}`;\n message = message.length > 60 ? `${message.slice(60)}...` : message;\n throw new Error(message);\n }\n}\n\n// HELPERS\n\nasync function getResponseError(response): Promise<string> {\n let message = `Failed to fetch resource ${response.url} (${response.status}): `;\n try {\n const contentType = response.headers.get('Content-Type');\n let text = response.statusText;\n if (contentType.includes('application/json')) {\n text += ` ${await response.text()}`;\n }\n message += text;\n message = message.length > 60 ? `${message.slice(60)}...` : message;\n } catch (error) {\n // eslint forbids return in a finally statement, so we just catch here\n }\n return message;\n}\n\nasync function getInitialDataUrl(resource): Promise<string | null> {\n const INITIAL_DATA_LENGTH = 5;\n if (typeof resource === 'string') {\n return `data:,${resource.slice(0, INITIAL_DATA_LENGTH)}`;\n }\n if (resource instanceof Blob) {\n const blobSlice = resource.slice(0, 5);\n return await new Promise((resolve) => {\n const reader = new FileReader();\n reader.onload = (event) => resolve(event?.target?.result as string);\n reader.readAsDataURL(blobSlice);\n });\n }\n if (resource instanceof ArrayBuffer) {\n const slice = resource.slice(0, INITIAL_DATA_LENGTH);\n const base64 = arrayBufferToBase64(slice);\n return `data:base64,${base64}`;\n }\n return null;\n}\n\n// https://stackoverflow.com/questions/9267899/arraybuffer-to-base64-encoded-string\nfunction arrayBufferToBase64(buffer) {\n let binary = '';\n const bytes = new Uint8Array(buffer);\n for (let i = 0; i < bytes.byteLength; i++) {\n binary += String.fromCharCode(bytes[i]);\n }\n return btoa(binary);\n}\n"],"file":"response-utils.js"}
|
package/dist/null-loader.js
CHANGED
package/dist/null-worker.js
CHANGED
|
@@ -1,2 +1,178 @@
|
|
|
1
|
-
!function(e){var t={};function r(n){if(t[n])return t[n].exports;var o=t[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,r),o.l=!0,o.exports}r.m=e,r.c=t,r.d=function(e,t,n){r.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:n})},r.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},r.t=function(e,t){if(1&t&&(e=r(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)r.d(n,o,function(t){return e[t]}.bind(null,o));return n},r.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return r.d(t,"a",t),t},r.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},r.p="",r(r.s=12)}([function(e,t,r){e.exports=r(10)},function(e,t){function r(e,t,r,n,o,a,i){try{var u=e[a](i),s=u.value}catch(e){return void r(e)}u.done?t(s):Promise.resolve(s).then(n,o)}e.exports=function(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var i=e.apply(t,n);function u(e){r(i,o,a,u,s,"next",e)}function s(e){r(i,o,a,u,s,"throw",e)}u(void 0)}))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(3);e.exports=function(e){return new n(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){this.wrapped=e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}e.exports=function(e,t,n){return t&&r(e.prototype,t),n&&r(e,n),e},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){function r(t){return"function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?(e.exports=r=function(e){return typeof e},e.exports.default=e.exports,e.exports.__esModule=!0):(e.exports=r=function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},e.exports.default=e.exports,e.exports.__esModule=!0),r(t)}e.exports=r,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=r(11);e.exports=function(e){return function(){return new n(e.apply(this,arguments))}},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t){e.exports=function(e){var t;if("undefined"!=typeof Symbol&&(Symbol.asyncIterator&&(t=e[Symbol.asyncIterator]),null==t&&Symbol.iterator&&(t=e[Symbol.iterator])),null==t&&(t=e["@@asyncIterator"]),null==t&&(t=e["@@iterator"]),null==t)throw new TypeError("Object is not async iterable");return t.call(e)},e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){var n=function(e){"use strict";var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function s(e,t,r,n){var o=t&&t.prototype instanceof l?t:l,a=Object.create(o.prototype),i=new O(n||[]);return a._invoke=function(e,t,r){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return j()}for(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=b(i,r);if(u){if(u===f)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var s=c(e,t,r);if("normal"===s.type){if(n=r.done?"completed":"suspendedYield",s.arg===f)continue;return{value:s.arg,done:r.done}}"throw"===s.type&&(n="completed",r.method="throw",r.arg=s.arg)}}}(e,r,i),a}function c(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=s;var f={};function l(){}function p(){}function h(){}var d={};d[o]=function(){return this};var y=Object.getPrototypeOf,v=y&&y(y(k([])));v&&v!==t&&r.call(v,o)&&(d=v);var x=h.prototype=l.prototype=Object.create(d);function m(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function g(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,u){var s=c(e[o],e,a);if("throw"!==s.type){var f=s.arg,l=f.value;return l&&"object"==typeof l&&r.call(l,"__await")?t.resolve(l.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(l).then((function(e){f.value=e,i(f)}),(function(e){return n("throw",e,i,u)}))}u(s.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return f;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=c(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,f;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,f):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,f)}function w(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function _(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function O(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(w,this),this.reset(!0)}function k(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:j}}function j(){return{value:void 0,done:!0}}return p.prototype=x.constructor=h,h.constructor=p,p.displayName=u(h,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,h):(e.__proto__=h,u(e,i,"GeneratorFunction")),e.prototype=Object.create(x),e},e.awrap=function(e){return{__await:e}},m(g.prototype),g.prototype[a]=function(){return this},e.AsyncIterator=g,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new g(s(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},m(x),u(x,i,"Generator"),x[o]=function(){return this},x.toString=function(){return"[object Generator]"},e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=k,O.prototype={constructor:O,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(_),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=r.call(a,"catchLoc"),s=r.call(a,"finallyLoc");if(u&&s){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!s)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(e,t){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&t&&(this.next=t),f},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),_(r),f}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;_(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:k(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),f}},e}(e.exports);try{regeneratorRuntime=n}catch(e){Function("r","regeneratorRuntime = r")(n)}},function(e,t,r){var n=r(3);function o(e){var t,r;function o(t,r){try{var i=e[t](r),u=i.value,s=u instanceof n;Promise.resolve(s?u.wrapped:u).then((function(e){s?o("return"===t?"return":"next",e):a(i.done?"return":"normal",e)}),(function(e){o("throw",e)}))}catch(e){a("throw",e)}}function a(e,n){switch(e){case"return":t.resolve({value:n,done:!0});break;case"throw":t.reject(n);break;default:t.resolve({value:n,done:!1})}(t=t.next)?o(t.key,t.arg):r=null}this._invoke=function(e,n){return new Promise((function(a,i){var u={key:e,arg:n,resolve:a,reject:i,next:null};r?r=r.next=u:(t=r=u,o(e,n))}))},"function"!=typeof e.return&&(this.return=void 0)}o.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},o.prototype.next=function(e){return this._invoke("next",e)},o.prototype.throw=function(e){return this._invoke("throw",e)},o.prototype.return=function(e){return this._invoke("return",e)},e.exports=o,e.exports.default=e.exports,e.exports.__esModule=!0},function(e,t,r){"use strict";r.r(t);var n=r(4),o=r.n(n),a=r(1),i=r.n(a),u=r(0),s=r.n(u),c=r(5),f=r.n(c),l=r(6),p=r.n(l),h=r(7),d=r.n(h);function y(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}var v=new Map,x=function(){function e(){f()(this,e)}return p()(e,null,[{key:"onmessage",set:function(e){self.onmessage=function(t){if(m(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}}},{key:"addEventListener",value:function(e){var t=v.get(e);t||(t=function(t){if(m(t)){var r=t.data,n=r.type,o=r.payload;e(n,o)}}),self.addEventListener("message",t)}},{key:"removeEventListener",value:function(e){var t=v.get(e);v.delete(e),self.removeEventListener("message",t)}},{key:"postMessage",value:function(e,t){if(self){var r={source:"loaders.gl",type:e,payload:t},n=function e(t){var r=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=arguments.length>2?arguments[2]:void 0,o=n||new Set;if(t){if(y(t))o.add(t);else if(y(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(r&&"object"===d()(t))for(var a in t)e(t[a],r,o)}else;return void 0===n?Array.from(o):[]}(t);self.postMessage(r,n)}}}]),e}();function m(e){var t=e.type,r=e.data;return"message"===t&&r&&"string"==typeof r.source&&r.source.startsWith("loaders.gl")}function g(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function b(e){for(var t=1;t<arguments.length;t++){var r=null!=arguments[t]?arguments[t]:{};t%2?g(Object(r),!0).forEach((function(t){o()(e,t,r[t])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):g(Object(r)).forEach((function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}))}return e}var w=0;function _(e,t){return new Promise((function(r,n){var o=w++;x.addEventListener((function e(t,a){if(a.id===o)switch(t){case"done":x.removeEventListener(e),r(a.result);break;case"error":x.removeEventListener(e),n(a.error)}}));var a={id:o,input:e,options:t};x.postMessage("process",a)}))}function O(e){return k.apply(this,arguments)}function k(){return(k=i()(s.a.mark((function e(t){var r,n,o,a,i,u,c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(r=t.loader,n=t.arrayBuffer,o=t.options,a=t.context,!r.parseSync&&!r.parse){e.next=6;break}i=n,u=r.parseSync||r.parse,e.next=13;break;case 6:if(!r.parseTextSync){e.next=12;break}c=new TextDecoder,i=c.decode(n),u=r.parseTextSync,e.next=13;break;case 12:throw new Error("Could not load data with ".concat(r.name," loader"));case 13:return o=b(b({},o),{},{modules:r&&r.options&&r.options.modules||{},worker:!1}),e.next=16,u(i,b({},o),a,r);case 16:return e.abrupt("return",e.sent);case 17:case"end":return e.stop()}}),e)})))).apply(this,arguments)}var j,E,L,S=r(2),P=r.n(S),M=r(8),T=r.n(M),I=r(9),N=r.n(I),G={name:"Null loader",id:"null",module:"core",version:"3.1.0-alpha.2",mimeTypes:["application/x.empty"],extensions:["null"],parse:(E=i()(s.a.mark((function e(t){return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",t);case 1:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)}),parseSync:function(e){return e},parseInBatches:(j=T()(s.a.mark((function e(t){var r,n,o,a,i,u,c;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:r=!0,n=!1,e.prev=2,a=N()(t);case 4:return e.next=6,P()(a.next());case 6:return i=e.sent,r=i.done,e.next=10,P()(i.value);case 10:if(u=e.sent,r){e.next=18;break}return c=u,e.next=15,c;case 15:r=!0,e.next=4;break;case 18:e.next=24;break;case 20:e.prev=20,e.t0=e.catch(2),n=!0,o=e.t0;case 24:if(e.prev=24,e.prev=25,r||null==a.return){e.next=29;break}return e.next=29,P()(a.return());case 29:if(e.prev=29,!n){e.next=32;break}throw o;case 32:return e.finish(29);case 33:return e.finish(24);case 34:case"end":return e.stop()}}),e,null,[[2,20,24,34],[25,,29,33]])}))),function(e){return j.apply(this,arguments)}),tests:[function(){return!1}],options:{null:{}}};L=G,"undefined"!=typeof self&&(x.onmessage=function(){var e=i()(s.a.mark((function e(t,r){var n,o,a,i,u;return s.a.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:e.t0=t,e.next="process"===e.t0?3:16;break;case 3:return e.prev=3,n=r.input,o=r.options,a=void 0===o?{}:o,e.next=7,O({loader:L,arrayBuffer:n,options:a,context:{parse:_}});case 7:i=e.sent,x.postMessage("done",{result:i}),e.next=15;break;case 11:e.prev=11,e.t1=e.catch(3),u=e.t1 instanceof Error?e.t1.message:"",x.postMessage("error",{error:u});case 15:return e.abrupt("break",16);case 16:case"end":return e.stop()}}),e,null,[[3,11]])})));return function(t,r){return e.apply(this,arguments)}}())}]);
|
|
2
|
-
|
|
1
|
+
(() => {
|
|
2
|
+
// ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
|
|
3
|
+
function getTransferList(object, recursive = true, transfers) {
|
|
4
|
+
const transfersSet = transfers || new Set();
|
|
5
|
+
if (!object) {
|
|
6
|
+
} else if (isTransferable(object)) {
|
|
7
|
+
transfersSet.add(object);
|
|
8
|
+
} else if (isTransferable(object.buffer)) {
|
|
9
|
+
transfersSet.add(object.buffer);
|
|
10
|
+
} else if (ArrayBuffer.isView(object)) {
|
|
11
|
+
} else if (recursive && typeof object === "object") {
|
|
12
|
+
for (const key in object) {
|
|
13
|
+
getTransferList(object[key], recursive, transfersSet);
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
return transfers === void 0 ? Array.from(transfersSet) : [];
|
|
17
|
+
}
|
|
18
|
+
function isTransferable(object) {
|
|
19
|
+
if (!object) {
|
|
20
|
+
return false;
|
|
21
|
+
}
|
|
22
|
+
if (object instanceof ArrayBuffer) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
if (typeof MessagePort !== "undefined" && object instanceof MessagePort) {
|
|
26
|
+
return true;
|
|
27
|
+
}
|
|
28
|
+
if (typeof ImageBitmap !== "undefined" && object instanceof ImageBitmap) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
if (typeof OffscreenCanvas !== "undefined" && object instanceof OffscreenCanvas) {
|
|
32
|
+
return true;
|
|
33
|
+
}
|
|
34
|
+
return false;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
38
|
+
var onMessageWrapperMap = new Map();
|
|
39
|
+
var WorkerBody = class {
|
|
40
|
+
static set onmessage(onMessage) {
|
|
41
|
+
self.onmessage = (message) => {
|
|
42
|
+
if (!isKnownMessage(message)) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
const { type, payload } = message.data;
|
|
46
|
+
onMessage(type, payload);
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
static addEventListener(onMessage) {
|
|
50
|
+
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
51
|
+
if (!onMessageWrapper) {
|
|
52
|
+
onMessageWrapper = (message) => {
|
|
53
|
+
if (!isKnownMessage(message)) {
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
const { type, payload } = message.data;
|
|
57
|
+
onMessage(type, payload);
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
self.addEventListener("message", onMessageWrapper);
|
|
61
|
+
}
|
|
62
|
+
static removeEventListener(onMessage) {
|
|
63
|
+
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64
|
+
onMessageWrapperMap.delete(onMessage);
|
|
65
|
+
self.removeEventListener("message", onMessageWrapper);
|
|
66
|
+
}
|
|
67
|
+
static postMessage(type, payload) {
|
|
68
|
+
if (self) {
|
|
69
|
+
const data = { source: "loaders.gl", type, payload };
|
|
70
|
+
const transferList = getTransferList(payload);
|
|
71
|
+
self.postMessage(data, transferList);
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
};
|
|
75
|
+
function isKnownMessage(message) {
|
|
76
|
+
const { type, data } = message;
|
|
77
|
+
return type === "message" && data && typeof data.source === "string" && data.source.startsWith("loaders.gl");
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
81
|
+
var requestId = 0;
|
|
82
|
+
function createLoaderWorker(loader) {
|
|
83
|
+
if (typeof self === "undefined") {
|
|
84
|
+
return;
|
|
85
|
+
}
|
|
86
|
+
WorkerBody.onmessage = async (type, payload) => {
|
|
87
|
+
switch (type) {
|
|
88
|
+
case "process":
|
|
89
|
+
try {
|
|
90
|
+
const { input, options = {} } = payload;
|
|
91
|
+
const result = await parseData({
|
|
92
|
+
loader,
|
|
93
|
+
arrayBuffer: input,
|
|
94
|
+
options,
|
|
95
|
+
context: {
|
|
96
|
+
parse: parseOnMainThread
|
|
97
|
+
}
|
|
98
|
+
});
|
|
99
|
+
WorkerBody.postMessage("done", { result });
|
|
100
|
+
} catch (error) {
|
|
101
|
+
const message = error instanceof Error ? error.message : "";
|
|
102
|
+
WorkerBody.postMessage("error", { error: message });
|
|
103
|
+
}
|
|
104
|
+
break;
|
|
105
|
+
default:
|
|
106
|
+
}
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
function parseOnMainThread(arrayBuffer, options) {
|
|
110
|
+
return new Promise((resolve, reject) => {
|
|
111
|
+
const id = requestId++;
|
|
112
|
+
const onMessage = (type, payload2) => {
|
|
113
|
+
if (payload2.id !== id) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
switch (type) {
|
|
117
|
+
case "done":
|
|
118
|
+
WorkerBody.removeEventListener(onMessage);
|
|
119
|
+
resolve(payload2.result);
|
|
120
|
+
break;
|
|
121
|
+
case "error":
|
|
122
|
+
WorkerBody.removeEventListener(onMessage);
|
|
123
|
+
reject(payload2.error);
|
|
124
|
+
break;
|
|
125
|
+
default:
|
|
126
|
+
}
|
|
127
|
+
};
|
|
128
|
+
WorkerBody.addEventListener(onMessage);
|
|
129
|
+
const payload = { id, input: arrayBuffer, options };
|
|
130
|
+
WorkerBody.postMessage("process", payload);
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
async function parseData({ loader, arrayBuffer, options, context }) {
|
|
134
|
+
let data;
|
|
135
|
+
let parser;
|
|
136
|
+
if (loader.parseSync || loader.parse) {
|
|
137
|
+
data = arrayBuffer;
|
|
138
|
+
parser = loader.parseSync || loader.parse;
|
|
139
|
+
} else if (loader.parseTextSync) {
|
|
140
|
+
const textDecoder = new TextDecoder();
|
|
141
|
+
data = textDecoder.decode(arrayBuffer);
|
|
142
|
+
parser = loader.parseTextSync;
|
|
143
|
+
} else {
|
|
144
|
+
throw new Error(`Could not load data with ${loader.name} loader`);
|
|
145
|
+
}
|
|
146
|
+
options = {
|
|
147
|
+
...options,
|
|
148
|
+
modules: loader && loader.options && loader.options.modules || {},
|
|
149
|
+
worker: false
|
|
150
|
+
};
|
|
151
|
+
return await parser(data, { ...options }, context, loader);
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
// src/null-loader.ts
|
|
155
|
+
var VERSION = typeof __VERSION__ !== "undefined" ? __VERSION__ : "latest";
|
|
156
|
+
var NullLoader = {
|
|
157
|
+
name: "Null loader",
|
|
158
|
+
id: "null",
|
|
159
|
+
module: "core",
|
|
160
|
+
version: VERSION,
|
|
161
|
+
mimeTypes: ["application/x.empty"],
|
|
162
|
+
extensions: ["null"],
|
|
163
|
+
parse: async (arrayBuffer) => arrayBuffer,
|
|
164
|
+
parseSync: (arrayBuffer) => arrayBuffer,
|
|
165
|
+
parseInBatches: async function* generator(asyncIterator) {
|
|
166
|
+
for await (const batch of asyncIterator) {
|
|
167
|
+
yield batch;
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
tests: [() => false],
|
|
171
|
+
options: {
|
|
172
|
+
null: {}
|
|
173
|
+
}
|
|
174
|
+
};
|
|
175
|
+
|
|
176
|
+
// src/workers/null-worker.ts
|
|
177
|
+
createLoaderWorker(NullLoader);
|
|
178
|
+
})();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/core",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "4.0.0-alpha.3",
|
|
4
4
|
"description": "Framework-independent loaders for 3D graphics formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -36,14 +36,14 @@
|
|
|
36
36
|
],
|
|
37
37
|
"scripts": {
|
|
38
38
|
"pre-build": "npm run build-bundle && npm run build-worker",
|
|
39
|
-
"build-bundle": "
|
|
40
|
-
"build-worker": "
|
|
39
|
+
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js",
|
|
40
|
+
"build-worker": "esbuild src/workers/null-worker.ts --bundle --outfile=dist/null-worker.js"
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
43
|
"@babel/runtime": "^7.3.1",
|
|
44
|
-
"@loaders.gl/loader-utils": "
|
|
45
|
-
"@loaders.gl/worker-utils": "
|
|
44
|
+
"@loaders.gl/loader-utils": "4.0.0-alpha.3",
|
|
45
|
+
"@loaders.gl/worker-utils": "4.0.0-alpha.3",
|
|
46
46
|
"probe.gl": "^3.4.0"
|
|
47
47
|
},
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "ded84630d02ba4fc97277ebecea3e42ae1bc2616"
|
|
49
49
|
}
|
package/src/bundle.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
// @ts-nocheck
|
|
2
2
|
const moduleExports = require('./index');
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
module.exports = Object.assign(_global.loaders, moduleExports);
|
|
3
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
4
|
+
module.exports = Object.assign(globalThis.loaders, moduleExports);
|
package/src/lib/api/encode.ts
CHANGED
|
@@ -12,6 +12,7 @@ export async function encode(
|
|
|
12
12
|
writer: Writer,
|
|
13
13
|
options?: LoaderOptions
|
|
14
14
|
): Promise<ArrayBuffer> {
|
|
15
|
+
// TODO Merge default writer options with options argument like it is done in load module.
|
|
15
16
|
if (writer.encode) {
|
|
16
17
|
return await writer.encode(data, options);
|
|
17
18
|
}
|
|
@@ -10,6 +10,7 @@ const getGlobalLoaderRegistry = () => {
|
|
|
10
10
|
return state.loaderRegistry;
|
|
11
11
|
};
|
|
12
12
|
|
|
13
|
+
/** Register a list of global loaders */
|
|
13
14
|
export function registerLoaders(loaders: Loader[]) {
|
|
14
15
|
const loaderRegistry = getGlobalLoaderRegistry();
|
|
15
16
|
|
|
@@ -28,7 +29,7 @@ export function getRegisteredLoaders(): Loader[] {
|
|
|
28
29
|
return getGlobalLoaderRegistry();
|
|
29
30
|
}
|
|
30
31
|
|
|
31
|
-
|
|
32
|
+
/** @deprecated For testing only */
|
|
32
33
|
export function _unregisterLoaders() {
|
|
33
34
|
const state = getGlobalLoaderState();
|
|
34
35
|
state.loaderRegistry = [];
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type {LoaderContext, LoaderOptions, Loader} from '@loaders.gl/loader-utils';
|
|
2
|
-
import {compareArrayBuffers} from '@loaders.gl/loader-utils';
|
|
2
|
+
import {compareArrayBuffers, path} from '@loaders.gl/loader-utils';
|
|
3
3
|
import {normalizeLoader} from '../loader-utils/normalize-loader';
|
|
4
4
|
import {getResourceUrlAndType} from '../utils/resource-utils';
|
|
5
5
|
import {getRegisteredLoaders} from './register-loaders';
|
|
@@ -143,16 +143,17 @@ function validHTTPResponse(data: any): boolean {
|
|
|
143
143
|
return true;
|
|
144
144
|
}
|
|
145
145
|
|
|
146
|
+
/** Generate a helpful message to help explain why loader selection failed. */
|
|
146
147
|
function getNoValidLoaderMessage(data): string {
|
|
147
148
|
const {url, type} = getResourceUrlAndType(data);
|
|
148
149
|
|
|
149
|
-
let message = 'No valid loader found';
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
150
|
+
let message = 'No valid loader found (';
|
|
151
|
+
message += url ? `${path.filename(url)}, ` : 'no url provided, ';
|
|
152
|
+
message += `MIME type: ${type ? `"${type}"` : 'not provided'}, `;
|
|
153
|
+
// First characters are only accessible when called on data (string or arrayBuffer).
|
|
154
|
+
const firstCharacters: string = data ? getFirstCharacters(data) : '';
|
|
155
|
+
message += firstCharacters ? ` first bytes: "${firstCharacters}"` : 'first bytes: not available';
|
|
156
|
+
message += ')';
|
|
156
157
|
return message;
|
|
157
158
|
}
|
|
158
159
|
|
|
@@ -257,7 +258,7 @@ function testBinary(data, byteOffset, loader, test) {
|
|
|
257
258
|
}
|
|
258
259
|
}
|
|
259
260
|
|
|
260
|
-
function getFirstCharacters(data, length = 5) {
|
|
261
|
+
function getFirstCharacters(data, length: number = 5) {
|
|
261
262
|
if (typeof data === 'string') {
|
|
262
263
|
return data.slice(0, length);
|
|
263
264
|
} else if (ArrayBuffer.isView(data)) {
|
package/src/lib/init.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {global} from '@loaders.gl/loader-utils';
|
|
2
1
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
3
2
|
const version = typeof __VERSION__ !== 'undefined' ? __VERSION__ : '';
|
|
4
3
|
|
|
5
4
|
// @ts-ignore
|
|
6
|
-
|
|
5
|
+
globalThis.loaders = Object.assign(globalThis.loaders || {}, {
|
|
7
6
|
VERSION: version
|
|
8
7
|
});
|
|
9
8
|
|
|
10
9
|
// @ts-ignore
|
|
11
|
-
export default
|
|
10
|
+
export default globalThis.loaders;
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type {Loader, LoaderContext, LoaderOptions} from '@loaders.gl/loader-utils';
|
|
2
|
-
import {global} from '@loaders.gl/loader-utils';
|
|
3
2
|
import {isPureObject, isObject} from '../../javascript-utils/is-type';
|
|
4
3
|
import {fetchFile} from '../fetch/fetch-file';
|
|
5
4
|
import {probeLog, NullLog} from './loggers';
|
|
@@ -18,11 +17,11 @@ type GlobalLoaderState = {
|
|
|
18
17
|
*/
|
|
19
18
|
export function getGlobalLoaderState(): GlobalLoaderState {
|
|
20
19
|
// @ts-ignore
|
|
21
|
-
|
|
20
|
+
globalThis.loaders = globalThis.loaders || {};
|
|
22
21
|
// @ts-ignore
|
|
23
|
-
const {loaders} =
|
|
22
|
+
const {loaders} = globalThis;
|
|
24
23
|
|
|
25
|
-
// Add _state object to keep separate from modules added to
|
|
24
|
+
// Add _state object to keep separate from modules added to globalThis.loaders
|
|
26
25
|
loaders._state = loaders._state || {};
|
|
27
26
|
return loaders._state;
|
|
28
27
|
}
|
package/dist/dist.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
!function(e,t){if("object"==typeof exports&&"object"==typeof module)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();for(var r in n)("object"==typeof exports?exports:e)[r]=n[r]}}(window,(function(){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=16)}([function(e,t,n){"use strict";(function(e,r){n.d(t,"e",(function(){return s})),n.d(t,"f",(function(){return i})),n.d(t,"b",(function(){return a})),n.d(t,"a",(function(){return u})),n.d(t,"c",(function(){return c})),n.d(t,"d",(function(){return f}));const o={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},s=o.self||o.window||o.global||{},i=o.window||o.self||o.global||{},a=o.global||o.self||o.window||{},u=o.document||{},c="object"!=typeof r||"[object process]"!==String(r)||r.browser,f="function"==typeof importScripts,l=void 0!==r&&r.version&&/v([0-9]*)/.exec(r.version);l&&parseFloat(l[1])}).call(this,n(4),n(2))},function(e,t,n){"use strict";(function(e,r){n.d(t,"b",(function(){return s})),n.d(t,"a",(function(){return i}));const o={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document,process:"object"==typeof r&&r},s=o.window||o.self||o.global,i=o.process||{};console}).call(this,n(4),n(2))},function(e,t){var n,r,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function a(e){if(n===setTimeout)return setTimeout(e,0);if((n===s||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(t){try{return n.call(null,e,0)}catch(t){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:s}catch(e){n=s}try{r="function"==typeof clearTimeout?clearTimeout:i}catch(e){r=i}}();var u,c=[],f=!1,l=-1;function d(){f&&u&&(f=!1,u.length?c=u.concat(c):l=-1,c.length&&h())}function h(){if(!f){var e=a(d);f=!0;for(var t=c.length;t;){for(u=c,c=[];++l<t;)u&&u[l].run();l=-1,t=c.length}u=null,f=!1,function(e){if(r===clearTimeout)return clearTimeout(e);if((r===i||!r)&&clearTimeout)return r=clearTimeout,clearTimeout(e);try{r(e)}catch(t){try{return r.call(null,e)}catch(t){return r.call(this,e)}}}(e)}}function p(e,t){this.fun=e,this.array=t}function y(){}o.nextTick=function(e){var t=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)t[n-1]=arguments[n];c.push(new p(e,t)),1!==c.length||f||a(h)},p.prototype.run=function(){this.fun.apply(null,this.array)},o.title="browser",o.browser=!0,o.env={},o.argv=[],o.version="",o.versions={},o.on=y,o.addListener=y,o.once=y,o.off=y,o.removeListener=y,o.removeAllListeners=y,o.emit=y,o.prependListener=y,o.prependOnceListener=y,o.listeners=function(e){return[]},o.binding=function(e){throw new Error("process.binding is not supported")},o.cwd=function(){return"/"},o.chdir=function(e){throw new Error("process.chdir is not supported")},o.umask=function(){return 0}},function(e,t,n){"use strict";(function(e){function r(){let t;if("undefined"!=typeof window&&window.performance)t=window.performance.now();else if(void 0!==e&&e.hrtime){const n=e.hrtime();t=1e3*n[0]+n[1]/1e6}else t=Date.now();return t}n.d(t,"a",(function(){return r}))}).call(this,n(2))},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},,,function(e,t){},,,function(e,t){},function(e,t){},function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return o}));var r=n(13);function o(){return!("object"==typeof e&&"[object process]"===String(e)&&!e.browser)||Object(r.a)()}}).call(this,n(2))},function(e,t,n){"use strict";(function(e){function r(t){if("undefined"!=typeof window&&"object"==typeof window.process&&"renderer"===window.process.type)return!0;if(void 0!==e&&"object"==typeof e.versions&&Boolean(e.versions.electron))return!0;const n="object"==typeof navigator&&"string"==typeof navigator.userAgent&&navigator.userAgent,r=t||n;return!!(r&&r.indexOf("Electron")>=0)}n.d(t,"a",(function(){return r}))}).call(this,n(2))},function(e,t,n){"use strict";(function(e,r){n.d(t,"a",(function(){return o}));"undefined"!=typeof self&&self,"undefined"!=typeof window&&window,"undefined"!=typeof document&&document,"object"!=typeof r||"[object process]"!==String(r)||r.browser;const o="undefined"!=typeof window&&void 0!==window.orientation,s=void 0!==r&&r.version&&/v([0-9]*)/.exec(r.version);s&&parseFloat(s[1])}).call(this,n(4),n(2))},function(e,t){},function(e,t,n){(function(t){const r=n(22),o="undefined"==typeof window?t:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,r)}).call(this,n(4))},,,,,function(e,t){},function(e,t,n){"use strict";n.r(t),n.d(t,"fetchFile",(function(){return E})),n.d(t,"readArrayBuffer",(function(){return B})),n.d(t,"readFileSync",(function(){return U})),n.d(t,"writeFile",(function(){return q})),n.d(t,"writeFileSync",(function(){return N})),n.d(t,"setLoaderOptions",(function(){return we})),n.d(t,"registerLoaders",(function(){return Te})),n.d(t,"selectLoader",(function(){return Se})),n.d(t,"selectLoaderSync",(function(){return ke})),n.d(t,"parse",(function(){return at})),n.d(t,"parseSync",(function(){return ut})),n.d(t,"parseInBatches",(function(){return ct})),n.d(t,"load",(function(){return ft})),n.d(t,"loadInBatches",(function(){return lt})),n.d(t,"encode",(function(){return ht})),n.d(t,"encodeSync",(function(){return pt})),n.d(t,"encodeInBatches",(function(){return gt})),n.d(t,"encodeText",(function(){return yt})),n.d(t,"encodeURLtoURL",(function(){return mt})),n.d(t,"save",(function(){return bt})),n.d(t,"saveSync",(function(){return vt})),n.d(t,"setPathPrefix",(function(){return s})),n.d(t,"getPathPrefix",(function(){return i})),n.d(t,"resolvePath",(function(){return a})),n.d(t,"RequestScheduler",(function(){return kt})),n.d(t,"makeIterator",(function(){return tt})),n.d(t,"makeStream",(function(){return jt})),n.d(t,"makeDOMStream",(function(){return Lt})),n.d(t,"makeNodeStream",(function(){return Ct.a})),n.d(t,"NullWorkerLoader",(function(){return Ot})),n.d(t,"NullLoader",(function(){return Pt})),n.d(t,"JSONLoader",(function(){return Mt})),n.d(t,"_fetchProgress",(function(){return It})),n.d(t,"_BrowserFileSystem",(function(){return Ut})),n.d(t,"_unregisterLoaders",(function(){return xe})),n.d(t,"isBrowser",(function(){return C.c})),n.d(t,"isWorker",(function(){return C.d})),n.d(t,"self",(function(){return C.e})),n.d(t,"window",(function(){return C.f})),n.d(t,"global",(function(){return C.b})),n.d(t,"document",(function(){return C.a})),n.d(t,"assert",(function(){return W})),n.d(t,"forEach",(function(){return Ke})),n.d(t,"concatenateArrayBuffersAsync",(function(){return Xe})),n.d(t,"makeTextDecoderIterator",(function(){return qt})),n.d(t,"makeTextEncoderIterator",(function(){return Nt})),n.d(t,"makeLineIterator",(function(){return $t})),n.d(t,"makeNumberedLineIterator",(function(){return Dt})),n.d(t,"isPureObject",(function(){return l})),n.d(t,"isPromise",(function(){return d})),n.d(t,"isIterable",(function(){return h})),n.d(t,"isAsyncIterable",(function(){return p})),n.d(t,"isIterator",(function(){return y})),n.d(t,"isResponse",(function(){return g})),n.d(t,"isReadableStream",(function(){return w})),n.d(t,"isWritableStream",(function(){return b}));let r="";const o={};function s(e){r=e}function i(){return r}function a(e){for(const t in o)if(e.startsWith(t)){const n=o[t];e=e.replace(t,n)}return e.startsWith("http://")||e.startsWith("https://")||(e=`${r}${e}`),e}const u=e=>"boolean"==typeof e,c=e=>"function"==typeof e,f=e=>null!==e&&"object"==typeof e,l=e=>f(e)&&e.constructor==={}.constructor,d=e=>f(e)&&c(e.then),h=e=>e&&"function"==typeof e[Symbol.iterator],p=e=>e&&"function"==typeof e[Symbol.asyncIterator],y=e=>e&&c(e.next),g=e=>"undefined"!=typeof Response&&e instanceof Response||e&&e.arrayBuffer&&e.text&&e.json,m=e=>"undefined"!=typeof Blob&&e instanceof Blob,w=e=>(e=>"undefined"!=typeof ReadableStream&&e instanceof ReadableStream||f(e)&&c(e.tee)&&c(e.cancel)&&c(e.getReader))(e)||(e=>f(e)&&c(e.read)&&c(e.pipe)&&u(e.readable))(e),b=e=>(e=>f(e)&&c(e.abort)&&c(e.getWriter))(e)||(e=>f(e)&&c(e.end)&&c(e.write)&&u(e.writable))(e),v=/^data:([-\w.]+\/[-\w.+]+)(;|,)/,_=/^([-\w.]+\/[-\w.+]+)/;function T(e){const t=_.exec(e);return t?t[1]:e}function x(e){const t=v.exec(e);return t?t[1]:""}const A=/\?.*/;function S(e){if(g(e)){const t=k(e.url||"");return{url:t,type:T(e.headers.get("content-type")||"")||x(t)}}return m(e)?{url:k(e.name||""),type:e.type||""}:"string"==typeof e?{url:k(e),type:x(e)}:{url:"",type:""}}function k(e){return e.replace(A,"")}async function L(e){if(g(e))return e;const t={},n=function(e){return g(e)?e.headers["content-length"]||-1:m(e)?e.size:"string"==typeof e?e.length:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:-1}(e);n>=0&&(t["content-length"]=String(n));const{url:r,type:o}=S(e);o&&(t["content-type"]=o);const s=await async function(e){if("string"==typeof e)return"data:,"+e.slice(0,5);if(e instanceof Blob){const t=e.slice(0,5);return await new Promise(e=>{const n=new FileReader;n.onload=t=>{var n;return e(null==t||null===(n=t.target)||void 0===n?void 0:n.result)},n.readAsDataURL(t)})}if(e instanceof ArrayBuffer){const t=e.slice(0,5);return"data:base64,"+function(e){let t="";const n=new Uint8Array(e);for(let e=0;e<n.byteLength;e++)t+=String.fromCharCode(n[e]);return btoa(t)}(t)}return null}(e);s&&(t["x-first-bytes"]=s),"string"==typeof e&&(e=(new TextEncoder).encode(e));const i=new Response(e,{headers:t});return Object.defineProperty(i,"url",{value:r}),i}async function R(e){if(!e.ok){const t=await async function(e){let t=`Failed to fetch resource ${e.url} (${e.status}): `;try{const n=e.headers.get("Content-Type");let r=e.statusText;n.includes("application/json")&&(r+=" "+await e.text()),t+=r,t=t.length>60?t.slice(60)+"...":t}catch(e){}return t}(e);throw new Error(t)}}async function E(e,t){if("string"==typeof e){e=a(e);let n=t;return null!=t&&t.fetch&&"function"!=typeof(null==t?void 0:t.fetch)&&(n=t.fetch),await fetch(e,n)}return await L(e)}var j=n(10);async function B(e,t,n){if("number"==typeof e)return await j._readToArrayBuffer(e,t,n);e instanceof Blob||(e=new Blob([e]));const r=e.slice(t,t+n);return await async function(e){return await new Promise((t,n)=>{const r=new FileReader;r.onload=e=>{var n;return t(null==e||null===(n=e.target)||void 0===n?void 0:n.result)},r.onerror=e=>n(e),r.readAsArrayBuffer(e)})}(r)}var C=n(0),O=n(7);function P(e){return e&&"object"==typeof e&&e.isBuffer}function M(e){return O.toBuffer?O.toBuffer(e):e}function F(e){if(P(e))return function(e){if(P(e)){return new Uint8Array(e.buffer,e.byteOffset,e.length).slice().buffer}return e}(e);if(e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return 0===e.byteOffset&&e.byteLength===e.buffer.byteLength?e.buffer:e.buffer.slice(e.byteOffset,e.byteOffset+e.byteLength);if("string"==typeof e){const t=e;return(new TextEncoder).encode(t).buffer}if(e&&"object"==typeof e&&e._toArrayBuffer)return e._toArrayBuffer();throw new Error("toArrayBuffer")}function I(...e){const t=e.map(e=>e instanceof ArrayBuffer?new Uint8Array(e):e),n=t.reduce((e,t)=>e+t.byteLength,0),r=new Uint8Array(n);let o=0;for(const e of t)r.set(e,o),o+=e.byteLength;return r.buffer}function W(e,t){if(!e)throw new Error(t||"loader assertion failed.")}function U(e,t={}){if(e=a(e),!C.c){const n=j.readFileSync(e,t);return"string"!=typeof n?F(n):n}return t.nothrow||W(!1),null}async function q(e,t,n){e=a(e),C.c||await j.writeFile(e,M(t),{flag:"w"}),W(!1)}function N(e,t,n){e=a(e),C.c||j.writeFileSync(e,M(t),{flag:"w"}),W(!1)}var $=n(12);const D=Object($.a)();class z{constructor(e,t,n="sessionStorage"){this.storage=function(e){try{const t=window[e],n="__storage_test__";return t.setItem(n,n),t.removeItem(n),t}catch(e){return null}}(n),this.id=e,this.config={},Object.assign(this.config,t),this._loadConfiguration()}getConfiguration(){return this.config}setConfiguration(e){return this.config={},this.updateConfiguration(e)}updateConfiguration(e){if(Object.assign(this.config,e),this.storage){const e=JSON.stringify(this.config);this.storage.setItem(this.id,e)}return this}_loadConfiguration(){let e={};if(this.storage){const t=this.storage.getItem(this.id);e=t?JSON.parse(t):{}}return Object.assign(this.config,e),this}}function Q(e,t,n,r=600){const o=e.src.replace(/\(/g,"%28").replace(/\)/g,"%29");e.width>r&&(n=Math.min(n,r/e.width));const s=e.width*n,i=e.height*n,a=["font-size:1px;","padding:".concat(Math.floor(i/2),"px ").concat(Math.floor(s/2),"px;"),"line-height:".concat(i,"px;"),"background:url(".concat(o,");"),"background-size:".concat(s,"px ").concat(i,"px;"),"color:transparent;"].join("");return["".concat(t," %c+"),a]}const H={BLACK:30,RED:31,GREEN:32,YELLOW:33,BLUE:34,MAGENTA:35,CYAN:36,WHITE:37,BRIGHT_BLACK:90,BRIGHT_RED:91,BRIGHT_GREEN:92,BRIGHT_YELLOW:93,BRIGHT_BLUE:94,BRIGHT_MAGENTA:95,BRIGHT_CYAN:96,BRIGHT_WHITE:97};function G(e){return"string"==typeof e?H[e.toUpperCase()]||H.WHITE:e}function J(e,t){if(!e)throw new Error(t||"Assertion failed")}var V=n(1);function Y(){let e;if(D&&V.b.performance)e=V.b.performance.now();else if(V.a.hrtime){const t=V.a.hrtime();e=1e3*t[0]+t[1]/1e6}else e=Date.now();return e}const K={debug:D&&console.debug||console.log,log:console.log,info:console.info,warn:console.warn,error:console.error},X={enabled:!0,level:0};function Z(){}const ee={},te={once:!0};function ne(e){for(const t in e)for(const n in e[t])return n||"untitled";return"empty"}class re{constructor({id:e}={id:""}){this.id=e,this.VERSION="3.1.0-alpha.2",this._startTs=Y(),this._deltaTs=Y(),this.LOG_THROTTLE_TIMEOUT=0,this._storage=new z("__probe-".concat(this.id,"__"),X),this.userData={},this.timeStamp("".concat(this.id," started")),function(e,t=["constructor"]){const n=Object.getPrototypeOf(e),r=Object.getOwnPropertyNames(n);for(const n of r)"function"==typeof e[n]&&(t.find(e=>n===e)||(e[n]=e[n].bind(e)))}(this),Object.seal(this)}set level(e){this.setLevel(e)}get level(){return this.getLevel()}isEnabled(){return this._storage.config.enabled}getLevel(){return this._storage.config.level}getTotal(){return Number((Y()-this._startTs).toPrecision(10))}getDelta(){return Number((Y()-this._deltaTs).toPrecision(10))}set priority(e){this.level=e}get priority(){return this.level}getPriority(){return this.level}enable(e=!0){return this._storage.updateConfiguration({enabled:e}),this}setLevel(e){return this._storage.updateConfiguration({level:e}),this}assert(e,t){J(e,t)}warn(e){return this._getLogFunction(0,e,K.warn,arguments,te)}error(e){return this._getLogFunction(0,e,K.error,arguments)}deprecated(e,t){return this.warn("`".concat(e,"` is deprecated and will be removed in a later version. Use `").concat(t,"` instead"))}removed(e,t){return this.error("`".concat(e,"` has been removed. Use `").concat(t,"` instead"))}probe(e,t){return this._getLogFunction(e,t,K.log,arguments,{time:!0,once:!0})}log(e,t){return this._getLogFunction(e,t,K.debug,arguments)}info(e,t){return this._getLogFunction(e,t,console.info,arguments)}once(e,t){return this._getLogFunction(e,t,K.debug||K.info,arguments,te)}table(e,t,n){return t?this._getLogFunction(e,t,console.table||Z,n&&[n],{tag:ne(t)}):Z}image({logLevel:e,priority:t,image:r,message:o="",scale:s=1}){return this._shouldLog(e||t)?D?function({image:e,message:t="",scale:n=1}){if("string"==typeof e){const r=new Image;return r.onload=()=>{const e=Q(r,t,n);console.log(...e)},r.src=e,Z}const r=e.nodeName||"";if("img"===r.toLowerCase())return console.log(...Q(e,t,n)),Z;if("canvas"===r.toLowerCase()){const r=new Image;return r.onload=()=>console.log(...Q(r,t,n)),r.src=e.toDataURL(),Z}return Z}({image:r,message:o,scale:s}):function({image:e,message:t="",scale:r=1}){let o=null;try{o=n(21)}catch(e){}if(o)return()=>o(e,{fit:"box",width:"".concat(Math.round(80*r),"%")}).then(e=>console.log(e));return Z}({image:r,message:o,scale:s}):Z}settings(){console.table?console.table(this._storage.config):console.log(this._storage.config)}get(e){return this._storage.config[e]}set(e,t){this._storage.updateConfiguration({[e]:t})}time(e,t){return this._getLogFunction(e,t,console.time?console.time:console.info)}timeEnd(e,t){return this._getLogFunction(e,t,console.timeEnd?console.timeEnd:console.info)}timeStamp(e,t){return this._getLogFunction(e,t,console.timeStamp||Z)}group(e,t,n={collapsed:!1}){n=se({logLevel:e,message:t,opts:n});const{collapsed:r}=n;return n.method=(r?console.groupCollapsed:console.group)||console.info,this._getLogFunction(n)}groupCollapsed(e,t,n={}){return this.group(e,t,Object.assign({},n,{collapsed:!0}))}groupEnd(e){return this._getLogFunction(e,"",console.groupEnd||Z)}withGroup(e,t,n){this.group(e,t)();try{n()}finally{this.groupEnd(e)()}}trace(){console.trace&&console.trace()}_shouldLog(e){return this.isEnabled()&&this.getLevel()>=oe(e)}_getLogFunction(e,t,n,r=[],o){if(this._shouldLog(e)){o=se({logLevel:e,message:t,args:r,opts:o}),J(n=n||o.method),o.total=this.getTotal(),o.delta=this.getDelta(),this._deltaTs=Y();const s=o.tag||o.message;if(o.once){if(ee[s])return Z;ee[s]=Y()}return t=function(e,t,n){if("string"==typeof t){const i=n.time?function(e,t=8){const n=Math.max(t-e.length,0);return"".concat(" ".repeat(n)).concat(e)}(function(e){let t;return t=e<10?"".concat(e.toFixed(2),"ms"):e<100?"".concat(e.toFixed(1),"ms"):e<1e3?"".concat(e.toFixed(0),"ms"):"".concat((e/1e3).toFixed(2),"s"),t}(n.total)):"";t=n.time?"".concat(e,": ").concat(i," ").concat(t):"".concat(e,": ").concat(t),r=t,o=n.color,s=n.background,D||"string"!=typeof r||(o&&(o=G(o),r="[".concat(o,"m").concat(r,"[39m")),s&&(o=G(s),r="[".concat(s+10,"m").concat(r,"[49m"))),t=r}var r,o,s;return t}(this.id,o.message,o),n.bind(console,t,...o.args)}return Z}}function oe(e){if(!e)return 0;let t;switch(typeof e){case"number":t=e;break;case"object":t=e.logLevel||e.priority||0;break;default:return 0}return J(Number.isFinite(t)&&t>=0),t}function se(e){const{logLevel:t,message:n}=e;e.logLevel=oe(t);const r=e.args?Array.from(e.args):[];for(;r.length&&r.shift()!==n;);switch(e.args=r,typeof t){case"string":case"function":void 0!==n&&r.unshift(n),e.message=t;break;case"object":Object.assign(e,t)}"function"==typeof e.message&&(e.message=e.message());const o=typeof e.message;return J("string"===o||"object"===o),Object.assign(e,e.opts)}re.VERSION="3.1.0-alpha.2";const ie=new re({id:"loaders.gl"});class ae{log(){return()=>{}}info(){return()=>{}}warn(){return()=>{}}error(){return()=>{}}}const ue={fetch:null,mimeType:void 0,nothrow:!1,log:new class{constructor(){var e,t,n;n=void 0,(t="console")in(e=this)?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,this.console=console}log(...e){return this.console.log.bind(this.console,...e)}info(...e){return this.console.info.bind(this.console,...e)}warn(...e){return this.console.warn.bind(this.console,...e)}error(...e){return this.console.error.bind(this.console,...e)}},CDN:"https://unpkg.com/@loaders.gl",worker:!0,maxConcurrency:3,maxMobileConcurrency:1,reuseWorkers:!0,_workerType:"",limit:0,_limitMB:0,batchSize:"auto",batchDebounceMs:0,metadata:!1,transforms:[]},ce={throws:"nothrow",dataType:"(no longer used)",uri:"baseUri",method:"fetch.method",headers:"fetch.headers",body:"fetch.body",mode:"fetch.mode",credentials:"fetch.credentials",cache:"fetch.cache",redirect:"fetch.redirect",referrer:"fetch.referrer",referrerPolicy:"fetch.referrerPolicy",integrity:"fetch.integrity",keepalive:"fetch.keepalive",signal:"fetch.signal"};function fe(){C.b.loaders=C.b.loaders||{};const{loaders:e}=C.b;return e._state=e._state||{},e._state}const le=()=>{const e=fe();return e.globalOptions=e.globalOptions||{...ue},e.globalOptions};function de(e,t,n,r){return n=n||[],function(e,t){pe(e,null,ue,ce,t);for(const n of t){const r=e&&e[n.id]||{},o=n.options&&n.options[n.id]||{},s=n.deprecatedOptions&&n.deprecatedOptions[n.id]||{};pe(r,n.id,o,s,t)}}(e,n=Array.isArray(n)?n:[n]),ge(t,e,r)}function he(e,t){const n=le(),r=e||n;return"function"==typeof r.fetch?r.fetch:f(r.fetch)?e=>E(e,r):null!=t&&t.fetch?null==t?void 0:t.fetch:E}function pe(e,t,n,r,o){const s=t||"Top level",i=t?t+".":"";for(const a in e){const u=!t&&f(e[a]),c="baseUri"===a&&!t,l="workerUrl"===a&&t;if(!(a in n)&&!c&&!l)if(a in r)ie.warn(`${s} loader option '${i}${a}' no longer supported, use '${r[a]}'`)();else if(!u){const e=ye(a,o);ie.warn(`${s} loader option '${i}${a}' not recognized. ${e}`)()}}}function ye(e,t){const n=e.toLowerCase();let r="";for(const o of t)for(const t in o.options){if(e===t)return`Did you mean '${o.id}.${t}'?`;const s=t.toLowerCase();(n.startsWith(s)||s.startsWith(n))&&(r=r||`Did you mean '${o.id}.${t}'?`)}return r}function ge(e,t,n){const r={...e.options||{}};return function(e,t){t&&!("baseUri"in e)&&(e.baseUri=t)}(r,n),null===r.log&&(r.log=new ae),me(r,le()),me(r,t),r}function me(e,t){for(const n in t)if(n in t){const r=t[n];l(r)&&l(e[n])?e[n]={...e[n],...t[n]}:e[n]=t[n]}}function we(e){!function(e){const t=fe(),n=le();t.globalOptions=ge(n,e)}(e)}function be(e){var t;if(!e)return!1;Array.isArray(e)&&(e=e[0]);return Array.isArray(null===(t=e)||void 0===t?void 0:t.extensions)}function ve(e){var t,n;let r;return W(e,"null loader"),W(be(e),"invalid loader"),Array.isArray(e)&&(r=e[1],e=e[0],e={...e,options:{...e.options,...r}}),(null!==(t=e)&&void 0!==t&&t.parseTextSync||null!==(n=e)&&void 0!==n&&n.parseText)&&(e.text=!0),e.text||(e.binary=!0),e}const _e=()=>{const e=fe();return e.loaderRegistry=e.loaderRegistry||[],e.loaderRegistry};function Te(e){const t=_e();e=Array.isArray(e)?e:[e];for(const n of e){const e=ve(n);t.find(t=>e===t)||t.unshift(e)}}function xe(){fe().loaderRegistry=[]}const Ae=/\.([^.]+)$/;async function Se(e,t=[],n,r){if(!Le(e))return null;let o=ke(e,t,{...n,nothrow:!0},r);if(o)return o;if(m(e)&&(o=ke(e=await e.slice(0,10).arrayBuffer(),t,n,r)),!(o||null!=n&&n.nothrow))throw new Error(Re(e));return o}function ke(e,t=[],n,r){if(!Le(e))return null;if(t&&!Array.isArray(t))return ve(t);let o=[];t&&(o=o.concat(t)),null!=n&&n.ignoreRegisteredLoaders||o.push(..._e()),function(e){for(const t of e)ve(t)}(o);const s=function(e,t,n,r){const{url:o,type:s}=S(e),i=o||(null==r?void 0:r.url);let a=null;null!=n&&n.mimeType&&(a=Ee(t,null==n?void 0:n.mimeType));return a=a||function(e,t){const n=t&&Ae.exec(t),r=n&&n[1];return r?function(e,t){t=t.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===t)return n;return null}(e,r):null}(t,i),a=a||Ee(t,s),a=a||function(e,t){if(!t)return null;for(const n of e)if("string"==typeof t){if(je(t,n))return n}else if(ArrayBuffer.isView(t)){if(Be(t.buffer,t.byteOffset,n))return n}else if(t instanceof ArrayBuffer){if(Be(t,0,n))return n}return null}(t,e),a=a||Ee(t,null==n?void 0:n.fallbackMimeType),a}(e,o,n,r);if(!(s||null!=n&&n.nothrow))throw new Error(Re(e));return s}function Le(e){return!(e instanceof Response&&204===e.status)}function Re(e){const{url:t,type:n}=S(e);let r="No valid loader found";return e&&(r+=` data: "${function(e,t=5){if("string"==typeof e)return e.slice(0,t);if(ArrayBuffer.isView(e))return Ce(e.buffer,e.byteOffset,t);if(e instanceof ArrayBuffer){return Ce(e,0,t)}return""}(e)}", contentType: "${n}"`),t&&(r+=" url: "+t),r}function Ee(e,t){for(const n of e){if(n.mimeTypes&&n.mimeTypes.includes(t))return n;if(t==="application/x."+n.id)return n}return null}function je(e,t){if(t.testText)return t.testText(e);return(Array.isArray(t.tests)?t.tests:[t.tests]).some(t=>e.startsWith(t))}function Be(e,t,n){return(Array.isArray(n.tests)?n.tests:[n.tests]).some(r=>function(e,t,n,r){if(r instanceof ArrayBuffer)return function(e,t,n){if(n=n||e.byteLength,e.byteLength<n||t.byteLength<n)return!1;const r=new Uint8Array(e),o=new Uint8Array(t);for(let e=0;e<r.length;++e)if(r[e]!==o[e])return!1;return!0}(r,e,r.byteLength);switch(typeof r){case"function":return r(e,n);case"string":const o=Ce(e,t,r.length);return r===o;default:return!1}}(e,t,n,r))}function Ce(e,t,n){if(e.byteLength<t+n)return"";const r=new DataView(e);let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(r.getUint8(t+e));return o}function Oe(e,t){if(!e)throw new Error(t||"loaders.gl assertion failed.")}var Pe=n(14);const Me=new Map;function Fe(e){Oe(e.source&&!e.url||!e.source&&e.url);let t=Me.get(e.source||e.url);return t||(e.url&&(t=function(e){if(!e.startsWith("http"))return e;return Ie((t=e,`try {\n importScripts('${t}');\n} catch (error) {\n console.error(error);\n throw error;\n}`));var t}(e.url),Me.set(e.url,t)),e.source&&(t=Ie(e.source),Me.set(e.source,t))),Oe(t),t}function Ie(e){const t=new Blob([e],{type:"application/javascript"});return URL.createObjectURL(t)}function We(e){return!!e&&(e instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}function Ue(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const qe=()=>{};class Ne{static isSupported(){return"undefined"!=typeof Worker}constructor(e){Ue(this,"name",void 0),Ue(this,"source",void 0),Ue(this,"url",void 0),Ue(this,"terminated",!1),Ue(this,"worker",void 0),Ue(this,"onMessage",void 0),Ue(this,"onError",void 0),Ue(this,"_loadableURL","");const{name:t,source:n,url:r}=e;Oe(n||r),this.name=t,this.source=n,this.url=r,this.onMessage=qe,this.onError=e=>console.log(e),this.worker=this._createBrowserWorker()}destroy(){this.onMessage=qe,this.onError=qe,this.worker.terminate(),this.terminated=!0}get isRunning(){return Boolean(this.onMessage)}postMessage(e,t){t=t||function e(t,n=!0,r){const o=r||new Set;if(t){if(We(t))o.add(t);else if(We(t.buffer))o.add(t.buffer);else if(ArrayBuffer.isView(t));else if(n&&"object"==typeof t)for(const r in t)e(t[r],n,o)}else;return void 0===r?Array.from(o):[]}(e),this.worker.postMessage(e,t)}_getErrorFromErrorEvent(e){let t="Failed to load ";return t+=`worker ${this.name} from ${this.url}. `,e.message&&(t+=e.message+" in "),e.lineno&&(t+=`:${e.lineno}:${e.colno}`),new Error(t)}_createBrowserWorker(){this._loadableURL=Fe({source:this.source,url:this.url});const e=new Worker(this._loadableURL,{name:this.name});return e.onmessage=e=>{e.data?this.onMessage(e.data):this.onError(new Error("No data received"))},e.onerror=e=>{this.onError(this._getErrorFromErrorEvent(e)),this.terminated=!0},e.onmessageerror=e=>console.error(e),e}}function $e(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class De{constructor(e,t){$e(this,"name",void 0),$e(this,"workerThread",void 0),$e(this,"isRunning",void 0),$e(this,"result",void 0),$e(this,"_resolve",void 0),$e(this,"_reject",void 0),this.name=e,this.workerThread=t,this.isRunning=!0,this._resolve=()=>{},this._reject=()=>{},this.result=new Promise((e,t)=>{this._resolve=e,this._reject=t})}postMessage(e,t){this.workerThread.postMessage({source:"loaders.gl",type:e,payload:t})}done(e){Oe(this.isRunning),this.isRunning=!1,this._resolve(e)}error(e){Oe(this.isRunning),this.isRunning=!1,this._reject(e)}}function ze(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class Qe{constructor(e){ze(this,"name","unnamed"),ze(this,"source",void 0),ze(this,"url",void 0),ze(this,"maxConcurrency",1),ze(this,"maxMobileConcurrency",1),ze(this,"onDebug",()=>{}),ze(this,"reuseWorkers",!0),ze(this,"props",{}),ze(this,"jobQueue",[]),ze(this,"idleQueue",[]),ze(this,"count",0),ze(this,"isDestroyed",!1),this.source=e.source,this.url=e.url,this.setProps(e)}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}setProps(e){this.props={...this.props,...e},void 0!==e.name&&(this.name=e.name),void 0!==e.maxConcurrency&&(this.maxConcurrency=e.maxConcurrency),void 0!==e.maxMobileConcurrency&&(this.maxMobileConcurrency=e.maxMobileConcurrency),void 0!==e.reuseWorkers&&(this.reuseWorkers=e.reuseWorkers),void 0!==e.onDebug&&(this.onDebug=e.onDebug)}async startJob(e,t=((e,t,n)=>e.done(n)),n=((e,t)=>e.error(t))){const r=new Promise(r=>(this.jobQueue.push({name:e,onMessage:t,onError:n,onStart:r}),this));return this._startQueuedJob(),await r}async _startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const t=this.jobQueue.shift();if(t){this.onDebug({message:"Starting job",name:t.name,workerThread:e,backlog:this.jobQueue.length});const n=new De(t.name,e);e.onMessage=e=>t.onMessage(n,e.type,e.payload),e.onError=e=>t.onError(n,e),t.onStart(n);try{await n.result}finally{this.returnWorkerToQueue(e)}}}returnWorkerToQueue(e){this.isDestroyed||!this.reuseWorkers||this.count>this._getMaxConcurrency()?(e.destroy(),this.count--):this.idleQueue.push(e),this.isDestroyed||this._startQueuedJob()}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift()||null;if(this.count<this._getMaxConcurrency()){this.count++;const e=`${this.name.toLowerCase()} (#${this.count} of ${this.maxConcurrency})`;return new Ne({name:e,source:this.source,url:this.url})}return null}_getMaxConcurrency(){return Pe.a?this.maxMobileConcurrency:this.maxConcurrency}}function He(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const Ge={maxConcurrency:3,maxMobileConcurrency:1,onDebug:()=>{},reuseWorkers:!0};class Je{static isSupported(){return Ne.isSupported()}static getWorkerFarm(e={}){return Je._workerFarm=Je._workerFarm||new Je({}),Je._workerFarm.setProps(e),Je._workerFarm}constructor(e){He(this,"props",void 0),He(this,"workerPools",new Map),this.props={...Ge},this.setProps(e),this.workerPools=new Map}destroy(){for(const e of this.workerPools.values())e.destroy()}setProps(e){this.props={...this.props,...e};for(const e of this.workerPools.values())e.setProps(this._getWorkerPoolProps())}getWorkerPool(e){const{name:t,source:n,url:r}=e;let o=this.workerPools.get(t);return o||(o=new Qe({name:t,source:n,url:r}),o.setProps(this._getWorkerPoolProps()),this.workerPools.set(t,o)),o}_getWorkerPoolProps(){return{maxConcurrency:this.props.maxConcurrency,maxMobileConcurrency:this.props.maxMobileConcurrency,reuseWorkers:this.props.reuseWorkers,onDebug:this.props.onDebug}}}He(Je,"_workerFarm",void 0);async function Ve(e,t,n,r,o){const s=e.id,i=function(e,t={}){const n=t[e.id]||{},r=e.id+"-worker.js";let o=n.workerUrl;if("test"===t._workerType&&(o=`modules/${e.module}/dist/${r}`),!o){let t=e.version;"latest"===t&&(t="beta");const n=t?"@"+t:"";o=`https://unpkg.com/@loaders.gl/${e.module}${n}/dist/${r}`}return Oe(o),o}(e,n),a=Je.getWorkerFarm(n).getWorkerPool({name:s,url:i});n=JSON.parse(JSON.stringify(n));const u=await a.startJob("process-on-worker",Ye.bind(null,o));u.postMessage("process",{input:t,options:n});const c=await u.result;return await c.result}async function Ye(e,t,n,r){switch(n){case"done":t.done(r);break;case"error":t.error(r.error);break;case"process":const{id:o,input:s,options:i}=r;try{const n=await e(s,i);t.postMessage("done",{id:o,result:n})}catch(e){const n=e instanceof Error?e.message:"unknown error";t.postMessage("error",{id:o,error:n})}break;default:console.warn("parse-with-worker unknown message "+n)}}async function Ke(e,t){for(;;){const{done:n,value:r}=await e.next();if(n)return void e.return();if(t(r))return}}async function Xe(e){const t=[];for await(const n of e)t.push(n);return I(...t)}const Ze=262144;function et(e,t){return C.c?async function*(e,t){const n=e.getReader();let r;try{for(;;){const e=r||n.read();null!=t&&t._streamReadAhead&&(r=n.read());const{done:o,value:s}=await e;if(o)return;yield F(s)}}catch(e){n.releaseLock()}}(e,t):async function*(e,t){for await(const t of e)yield F(t)}(e)}function tt(e,t){if("string"==typeof e)return function*(e,t){const n=(null==t?void 0:t.chunkSize)||262144;let r=0;const o=new TextEncoder;for(;r<e.length;){const t=Math.min(e.length-r,n),s=e.slice(r,r+t);r+=t,yield o.encode(s)}}(e,t);if(e instanceof ArrayBuffer)return function*(e,t={}){const{chunkSize:n=Ze}=t;let r=0;for(;r<e.byteLength;){const t=Math.min(e.byteLength-r,n),o=new ArrayBuffer(t),s=new Uint8Array(e,r,t);new Uint8Array(o).set(s),r+=t,yield o}}(e,t);if(m(e))return async function*(e,t){const n=(null==t?void 0:t.chunkSize)||1048576;let r=0;for(;r<e.size;){const t=r+n,o=await e.slice(r,t).arrayBuffer();r=t,yield o}}(e,t);if(w(e))return et(e,t);if(g(e)){return et(e.body,t)}throw new Error("makeIterator")}const nt="Cannot convert supplied data type";function rt(e,t,n){if(t.text&&"string"==typeof e)return e;var r;if((r=e)&&"object"==typeof r&&r.isBuffer&&(e=e.buffer),e instanceof ArrayBuffer){const n=e;if(t.text&&!t.binary){return new TextDecoder("utf8").decode(n)}return n}if(ArrayBuffer.isView(e)){if(t.text&&!t.binary){return new TextDecoder("utf8").decode(e)}let n=e.buffer;const r=e.byteLength||e.length;return 0===e.byteOffset&&r===n.byteLength||(n=n.slice(e.byteOffset,e.byteOffset+r)),n}throw new Error(nt)}async function ot(e,t){if(y(e))return e;if(g(e)){const n=e;await R(n);return tt(await n.body,t)}return m(e)||w(e)?tt(e,t):p(e)?e[Symbol.asyncIterator]():function(e){if(ArrayBuffer.isView(e))return function*(){yield e.buffer}();if(e instanceof ArrayBuffer)return function*(){yield e}();if(y(e))return e;if(h(e))return e[Symbol.iterator]();throw new Error(nt)}(e)}function st(e,t,n=null){if(n)return n;const r={fetch:he(t,e),...e};return Array.isArray(r.loaders)||(r.loaders=null),r}function it(e,t){if(!t&&e&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),t&&t.loaders){const e=Array.isArray(t.loaders)?t.loaders:[t.loaders];n=n?[...n,...e]:e}return n&&n.length?n:null}async function at(e,t,n,r){Oe(!r||"object"==typeof r),!t||Array.isArray(t)||be(t)||(r=void 0,n=t,t=void 0),e=await e,n=n||{};const{url:o}=S(e),s=it(t,r),i=await Se(e,s,n);return i?(r=st({url:o,parse:at,loaders:s},n=de(n,i,s,o),r),await async function(e,t,n,r){if(function(e,t="3.1.0-alpha.2"){Oe(e,"no worker provided");const n=e.version}(e),t=await async function(e,t,n){const r=e instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||r)return rt(e,t);if(m(e)&&(e=await L(e)),g(e)){const n=e;return await R(n),t.binary?await n.arrayBuffer():await n.text()}if(w(e)&&(e=tt(e,n)),h(e)||p(e))return Xe(e);throw new Error(nt)}(t,e,n),e.parseTextSync&&"string"==typeof t)return n.dataType="text",e.parseTextSync(t,n,r,e);if(function(e,t){return!!Je.isSupported()&&(e.worker&&(null==t?void 0:t.worker))}(e,n))return await Ve(e,t,n,0,at);if(e.parseText&&"string"==typeof t)return await e.parseText(t,n,r,e);if(e.parse)return await e.parse(t,n,r,e);throw Oe(!e.parseSync),new Error(e.id+" loader - no parser found and worker is disabled")}(i,e,n,r)):null}function ut(e,t,n,r){W(!r||"object"==typeof r),Array.isArray(t)||be(t)||(r=void 0,n=t,t=void 0),n=n||{};const o=it(t,r),s=ke(e,o,n);if(!s)return null;n=de(n,s,o);const{url:i}=S(e);return function(e,t,n,r){if(t=rt(t,e),e.parseTextSync&&"string"==typeof t)return e.parseTextSync(t,n);if(e.parseSync&&t instanceof ArrayBuffer)return e.parseSync(t,n,r);throw new Error(`${e.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${r.url||""}`)}(s,e,n,r=st({url:i,parseSync:ut,parse:()=>{throw new Error("parseSync called parse")},loaders:t},n))}async function ct(e,t,n,r){W(!r||"object"==typeof r),Array.isArray(t)||be(t)||(r=void 0,n=t,t=void 0),e=await e,n=n||{};const{url:o}=S(e),s=await Se(e,t,n);return s?(r=st({url:o,parseInBatches:ct,parse:at,loaders:t},n=de(n,s,t,o),r),await async function(e,t,n,r){const o=await async function(e,t,n,r){const o=await ot(t,n),s=await async function(e,t=[]){let n=e;for await(const e of t)n=e(n);return n}(o,(null==n?void 0:n.transforms)||[]);if(e.parseInBatches)return e.parseInBatches(s,n,r);return async function*(){const t=await Xe(s),o=await at(t,e,{...n,mimeType:e.mimeTypes[0]},r),i={mimeType:e.mimeTypes[0],shape:Array.isArray(o)?"row-table":"unknown",batchType:"data",data:o,length:Array.isArray(o)?o.length:1};yield i}()}(e,t,n,r);if(!n.metadata)return o;const s={batchType:"metadata",metadata:{_loader:e,_context:r},data:[],bytesUsed:0};return async function*(e){yield s,yield*e}(o)}(s,e,n,r)):null}async function ft(e,t,n,r){Array.isArray(t)||be(t)||(void 0,n=t,t=void 0);const o=he(n);let s=e;return"string"==typeof e&&(s=await o(e)),m(e)&&(s=await o(e)),await at(s,t,n)}function lt(e,t,n,r){Array.isArray(t)||be(t)||(void 0,n=t,t=null);const o=he(n||{});if(!Array.isArray(e))return dt(e,t,n,o);return e.map(e=>dt(e,t,n,o))}async function dt(e,t,n,r){if("string"==typeof e){const o=e,s=await r(o);return await ct(s,t,n)}return await ct(e,t,n)}async function ht(e,t,n){if(t.encode)return await t.encode(e,n);if(t.encodeSync)return t.encodeSync(e,n);if(t.encodeText)return(new TextEncoder).encode(await t.encodeText(e,n));if(t.encodeInBatches){const r=gt(e,t,n),o=[];for await(const e of r)o.push(e);return I(...o)}if(!C.c&&t.encodeURLtoURL){const r=wt("input");await q(r,e);const o=wt("output"),s=await mt(r,o,t,n);return(await E(s)).arrayBuffer()}throw new Error("Writer could not encode data")}function pt(e,t,n){if(t.encodeSync)return t.encodeSync(e,n);throw new Error("Writer could not synchronously encode data")}async function yt(e,t,n){if(t.text&&t.encodeText)return await t.encodeText(e,n);if(t.text&&(t.encode||t.encodeInBatches)){const r=await ht(e,t,n);return(new TextDecoder).decode(r)}throw new Error("Writer could not encode data as text")}function gt(e,t,n){if(t.encodeInBatches){const r=function(e){return[{table:e,start:0,end:e.length}]}(e);return t.encodeInBatches(r,n)}throw new Error("Writer could not encode data in batches")}async function mt(e,t,n,r){if(e=a(e),t=a(t),C.c||!n.encodeURLtoURL)throw new Error;return await n.encodeURLtoURL(e,t,r)}function wt(e){return"/tmp/"+e}async function bt(e,t,n,r){const o=await ht(e,n,r);return await q(t,o)}function vt(e,t,n,r){return N(t,pt(e,n,r))}var _t=n(3);class Tt{constructor(e,t){this.name=e,this.type=t,this.sampleSize=1,this.reset()}setSampleSize(e){return this.sampleSize=e,this}incrementCount(){return this.addCount(1),this}decrementCount(){return this.subtractCount(1),this}addCount(e){return this._count+=e,this._samples++,this._checkSampling(),this}subtractCount(e){return this._count-=e,this._samples++,this._checkSampling(),this}addTime(e){return this._time+=e,this.lastTiming=e,this._samples++,this._checkSampling(),this}timeStart(){return this._startTime=Object(_t.a)(),this._timerPending=!0,this}timeEnd(){return this._timerPending?(this.addTime(Object(_t.a)()-this._startTime),this._timerPending=!1,this._checkSampling(),this):this}getSampleAverageCount(){return this.sampleSize>0?this.lastSampleCount/this.sampleSize:0}getSampleAverageTime(){return this.sampleSize>0?this.lastSampleTime/this.sampleSize:0}getSampleHz(){return this.lastSampleTime>0?this.sampleSize/(this.lastSampleTime/1e3):0}getAverageCount(){return this.samples>0?this.count/this.samples:0}getAverageTime(){return this.samples>0?this.time/this.samples:0}getHz(){return this.time>0?this.samples/(this.time/1e3):0}reset(){return this.time=0,this.count=0,this.samples=0,this.lastTiming=0,this.lastSampleTime=0,this.lastSampleCount=0,this._count=0,this._time=0,this._samples=0,this._startTime=0,this._timerPending=!1,this}_checkSampling(){this._samples===this.sampleSize&&(this.lastSampleTime=this._time,this.lastSampleCount=this._count,this.count+=this._count,this.time+=this._time,this.samples+=this._samples,this._time=0,this._count=0,this._samples=0)}}class xt{constructor({id:e,stats:t}){this.id=e,this.stats={},this._initializeStats(t),Object.seal(this)}get(e,t="count"){return this._getOrCreate({name:e,type:t})}get size(){return Object.keys(this.stats).length}reset(){for(const e in this.stats)this.stats[e].reset();return this}forEach(e){for(const t in this.stats)e(this.stats[t])}getTable(){const e={};return this.forEach(t=>{e[t.name]={time:t.time||0,count:t.count||0,average:t.getAverageTime()||0,hz:t.getHz()||0}}),e}_initializeStats(e=[]){e.forEach(e=>this._getOrCreate(e))}_getOrCreate(e){if(!e||!e.name)return null;const{name:t,type:n}=e;return this.stats[t]||(this.stats[t]=e instanceof Tt?e:new Tt(t,n)),this.stats[t]}}function At(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}const St={id:"request-scheduler",throttleRequests:!0,maxRequests:6};class kt{constructor(e={}){At(this,"props",void 0),At(this,"stats",void 0),At(this,"activeRequestCount",0),At(this,"requestQueue",[]),At(this,"requestMap",new Map),At(this,"deferredUpdate",null),this.props={...St,...e},this.stats=new xt({id:this.props.id}),this.stats.get("Queued Requests"),this.stats.get("Active Requests"),this.stats.get("Cancelled Requests"),this.stats.get("Queued Requests Ever"),this.stats.get("Active Requests Ever")}scheduleRequest(e,t=(()=>0)){if(!this.props.throttleRequests)return Promise.resolve({done:()=>{}});if(this.requestMap.has(e))return this.requestMap.get(e);const n={handle:e,priority:0,getPriority:t},r=new Promise(e=>(n.resolve=e,n));return this.requestQueue.push(n),this.requestMap.set(e,r),this._issueNewRequests(),r}_issueRequest(e){const{handle:t,resolve:n}=e;let r=!1;const o=()=>{r||(r=!0,this.requestMap.delete(t),this.activeRequestCount--,this._issueNewRequests())};return this.activeRequestCount++,n?n({done:o}):Promise.resolve({done:o})}_issueNewRequests(){this.deferredUpdate||(this.deferredUpdate=setTimeout(()=>this._issueNewRequestsAsync(),0))}_issueNewRequestsAsync(){this.deferredUpdate=null;const e=Math.max(this.props.maxRequests-this.activeRequestCount,0);if(0!==e){this._updateAllRequests();for(let t=0;t<e;++t){const e=this.requestQueue.shift();e&&this._issueRequest(e)}}}_updateAllRequests(){const e=this.requestQueue;for(let t=0;t<e.length;++t){const n=e[t];this._updateRequest(n)||(e.splice(t,1),this.requestMap.delete(n.handle),t--)}e.sort((e,t)=>e.priority-t.priority)}_updateRequest(e){return e.priority=e.getPriority(e.handle),!(e.priority<0)||(e.resolve(null),!1)}}function Lt(e,t){const n=e[Symbol.asyncIterator]?e[Symbol.asyncIterator]():e[Symbol.iterator]();return new ReadableStream({type:"bytes",async pull(e){try{const{done:t,value:r}=await n.next();t?e.close():e.enqueue(new Uint8Array(r))}catch(t){e.error(t)}},async cancel(){var e;await(null==n||null===(e=n.return)||void 0===e?void 0:e.call(n))}},{highWaterMark:2**24,...t})}var Rt=n(15),Et=n.n(Rt);function jt(e,t){return C.c?Lt(e,t):Et()(e,t)}var Bt=n(11),Ct=n.n(Bt);const Ot={name:"Null loader",id:"null",module:"core",version:"3.1.0-alpha.2",worker:!0,mimeTypes:["application/x.empty"],extensions:["null"],tests:[()=>!1],options:{null:{}}},Pt={name:"Null loader",id:"null",module:"core",version:"3.1.0-alpha.2",mimeTypes:["application/x.empty"],extensions:["null"],parse:async e=>e,parseSync:e=>e,parseInBatches:async function*(e){for await(const t of e)yield t},tests:[()=>!1],options:{null:{}}},Mt={name:"JSON",id:"json",module:"json",version:"3.1.0-alpha.2",extensions:["json","geojson"],mimeTypes:["application/json"],category:"json",text:!0,parseTextSync:Ft,parse:async e=>Ft((new TextDecoder).decode(e)),options:{}};function Ft(e){return JSON.parse(e)}async function It(e,t,n=(()=>{}),r=(()=>{})){if(!(e=await e).ok)return e;const o=e.body;if(!o)return e;const s=e.headers.get("content-length")||0,i=s&&parseInt(s);if(!(s>0))return e;if("undefined"==typeof ReadableStream||!o.getReader)return e;const a=new ReadableStream({async start(e){const s=o.getReader();await async function e(t,n,r,o,s,i,a){try{const{done:u,value:c}=await n.read();if(u)return i(),void t.close();r+=c.byteLength;const f=Math.round(r/o*100);s(f,{loadedBytes:r,totalBytes:o}),t.enqueue(c),await e(t,n,r,o,s,i,a)}catch(e){t.error(e),a(e)}}(e,s,0,i,t,n,r)}});return new Response(a)}function Wt(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}class Ut{constructor(e,t){Wt(this,"_fetch",void 0),Wt(this,"files",{}),Wt(this,"lowerCaseFiles",{}),Wt(this,"usedFiles",{}),this._fetch=(null==t?void 0:t.fetch)||fetch;for(let t=0;t<e.length;++t){const n=e[t];this.files[n.name]=n,this.lowerCaseFiles[n.name.toLowerCase()]=n,this.usedFiles[n.name]=!1}this.fetch=this.fetch.bind(this)}async fetch(e,t){if(e.includes("://"))return this._fetch(e,t);const n=this.files[e];if(!n)return new Response(e,{status:400,statusText:"NOT FOUND"});const r=new Headers(null==t?void 0:t.headers).get("Range"),o=r&&/bytes=($1)-($2)/.exec(r);if(o){const t=parseInt(o[1]),r=parseInt(o[2]),s=await n.slice(t,r).arrayBuffer(),i=new Response(s);return Object.defineProperty(i,"url",{value:e}),i}const s=new Response(n);return Object.defineProperty(s,"url",{value:e}),s}async readdir(e){const t=[];for(const e in this.files)t.push(e);return t}async stat(e,t){const n=this.files[e];if(!n)throw new Error(e);return{size:n.size}}async unlink(e){delete this.files[e],delete this.lowerCaseFiles[e],this.usedFiles[e]=!0}async open(e,t,n){return this.files[e]}async read(e,t,n=0,r=t.byteLength,o=null){const s=e;return{bytesRead:r,buffer:await s.slice(0,0+r).arrayBuffer()}}async close(e){}_getFile(e,t){const n=this.files[e]||this.lowerCaseFiles[e];return n&&t&&(this.usedFiles[e]=!0),n}}async function*qt(e,t={}){const n=new TextDecoder(void 0,t);for await(const t of e)yield"string"==typeof t?t:n.decode(t,{stream:!0})}async function*Nt(e){const t=new TextEncoder;for await(const n of e)yield"string"==typeof n?t.encode(n):n}async function*$t(e){let t="";for await(const n of e){let e;for(t+=n;(e=t.indexOf("\n"))>=0;){const n=t.slice(0,e+1);t=t.slice(e+1),yield n}}t.length>0&&(yield t)}async function*Dt(e){let t=1;for await(const n of e)yield{counter:t,line:n},t++}}])}));
|
|
2
|
-
//# sourceMappingURL=dist.min.js.map
|