Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@loaders.gl/core

Package Overview
Dependencies
Maintainers
9
Versions
337
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@loaders.gl/core - npm Package Compare versions

Comparing version 2.0.0-alpha.2 to 2.0.0-alpha.3

dist/es5/lib/constants.js

2

dist/dist.min.js

@@ -1,1 +0,1 @@

!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var t=r();for(var n in t)("object"==typeof exports?exports:e)[n]=t[n]}}(window,(function(){return function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=5)}([function(e,r,t){"use strict";(function(e,n){t.d(r,"c",(function(){return o})),t.d(r,"e",(function(){return i})),t.d(r,"f",(function(){return u})),t.d(r,"b",(function(){return a})),t.d(r,"a",(function(){return c})),t.d(r,"d",(function(){return l}));const o="object"!=typeof e||"[object process]"!==String(e)||e.browser,s={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==n&&n,document:"undefined"!=typeof document&&document},i=s.self||s.window||s.global,u=s.window||s.self||s.global,a=s.global||s.self||s.window,c=s.document||{},f=void 0!==e&&e.version&&e.version.match(/v([0-9]*)/),l=f&&parseFloat(f[1])||0}).call(this,t(6),t(4))},function(e,r){},function(e,r){},function(e,r){},function(e,r){var t;t=function(){return this}();try{t=t||new Function("return this")()}catch(e){"object"==typeof window&&(t=window)}e.exports=t},function(e,r,t){(function(r){const n=t(7),o="undefined"==typeof window?r:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,n)}).call(this,t(4))},function(e,r){var t,n,o=e.exports={};function s(){throw new Error("setTimeout has not been defined")}function i(){throw new Error("clearTimeout has not been defined")}function u(e){if(t===setTimeout)return setTimeout(e,0);if((t===s||!t)&&setTimeout)return t=setTimeout,setTimeout(e,0);try{return t(e,0)}catch(r){try{return t.call(null,e,0)}catch(r){return t.call(this,e,0)}}}!function(){try{t="function"==typeof setTimeout?setTimeout:s}catch(e){t=s}try{n="function"==typeof clearTimeout?clearTimeout:i}catch(e){n=i}}();var a,c=[],f=!1,l=-1;function d(){f&&a&&(f=!1,a.length?c=a.concat(c):l=-1,c.length&&y())}function y(){if(!f){var e=u(d);f=!0;for(var r=c.length;r;){for(a=c,c=[];++l<r;)a&&a[l].run();l=-1,r=c.length}a=null,f=!1,function(e){if(n===clearTimeout)return clearTimeout(e);if((n===i||!n)&&clearTimeout)return n=clearTimeout,clearTimeout(e);try{n(e)}catch(r){try{return n.call(null,e)}catch(r){return n.call(this,e)}}}(e)}}function h(e,r){this.fun=e,this.array=r}function p(){}o.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var t=1;t<arguments.length;t++)r[t-1]=arguments[t];c.push(new h(e,r)),1!==c.length||f||u(y)},h.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=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,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,r,t){"use strict";t.r(r);var n={};function o(e){const r=e&&e.lastIndexOf("/");return r>=0?e.substr(0,r):""}t.r(n),t.d(n,"dirname",(function(){return o}));let s="";const i={};function u(e){s=e}function a(){return s}function c(e){for(const r in i)if(e.startsWith(r)){const t=i[r];return e.replace(r,t)}return e+=s}const f=e=>"boolean"==typeof e,l=e=>"function"==typeof e,d=e=>null!==e&&"object"==typeof e,y=e=>d(e)&&l(e.then),h=e=>e&&"function"==typeof e[Symbol.iterator],p=e=>e&&"function"==typeof e[Symbol.asyncIterator],w=e=>e&&l(e.next),b=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,g=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e),m=e=>(e=>d(e)&&l(e.tee)&&l(e.cancel)&&l(e.pipeTo)&&l(e.getReader))(e)||(e=>d(e)&&l(e.read)&&l(e.pipe)&&f(e.readable))(e),x=e=>(e=>d(e)&&l(e.abort)&&l(e.getWriter))(e)||(e=>d(e)&&l(e.end)&&l(e.write)&&f(e.writable))(e);function A(e,r){if(!e)throw new Error(r||"loader assertion failed.")}class S{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}get url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:r}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),r}async text(){const{reader:e,promise:r}=this._getFileReader();return e.readAsText(this._fileOrBlob),r}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;A(!this.bodyUsed),this.bodyUsed=!0;const r=new Promise((r,t)=>{try{(e=new FileReader).onerror=e=>t(new Error(e)),e.onabort=()=>t(new Error("Read aborted.")),e.onload=()=>r(e.result)}catch(e){t(e)}});return{reader:e,promise:r}}}function v(e,r){return Promise.resolve(new S(e,r))}async function B(e,r){return g(e)?v(e,r):(e=c(e),fetch(e,r))}var T=t(0),k=t(2);const j={dataType:"arraybuffer",nothrow:!0},_=e=>e.startsWith("data:");function I(e,r){return r=function(e={}){return(e=Object.assign({},j,e)).responseType=e.responseType||e.dataType,e}(r),_(e),r.nothrow||A(!1),null}function O(e,r={}){return e=c(e),!T.c&&k.readFileSync?k.readFileSync(e,r):I(e,r)}var P=t(1);function E(e,r,t){return e=c(e),!T.c&&P.writeFile?P.writeFile(e,r,t):A(!1)}function F(e,r,t){return e=c(e),!T.c&&P.writeFileSync?P.writeFileSync(e,r,t):A(!1)}function L(e){return`Failed to fetch resource ${e.url}(${e.status}): ${e.statusText} `}async function M(e){let r=`Failed to fetch resource ${e.url} (${e.status}): `;try{e.headers.get("Content-Type").includes("application/json")?r+=await e.text():r+=e.statusText}catch(e){return r}return r}function C(e){if(!e)return!1;return Array.isArray(e)&&(e=e[0]),e.parseTextSync||e.parseSync||e.parse||e.parseStream||e.parseInBatches||e.worker}function D(e){let r;return A(e,"null loader"),A(C(e),"invalid loader"),Array.isArray(e)&&(r=e[1],e=e[0],e={...e,options:{...e.options,...r}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),A(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}let W=[];function $(e){e=Array.isArray(e)?e:[e];for(const r of e){const e=D(r);W.find(r=>e===r)||W.unshift(e)}}function R(){W=[]}class U{log(){return e=>{}}info(){return e=>{}}warn(){return e=>{}}error(){return e=>{}}}const Q={log:new class{constructor(){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)}}},N=e=>e&&"object"==typeof e&&e.constructor==={}.constructor;function V(e,r,t){const n=e&&(e.DEFAULT_OPTIONS||e.defaultOptions||e.options||{}),o={...Q,...n,dataType:"arraybuffer",...r};return!t||"baseUri"in o||(o.baseUri=t),null===o.log&&(o.log=new U),function(e,r,t){for(const n in r){const o=r[n];N(o)&&n in t&&(N(t[n])?e[n]={...t[n],...r[n]}:e.log.warn(`Nested option ${n} not recognized`)())}}(o,r,n),o}function J(e){if(T.c||T.d>=10){if("function"==typeof e[Symbol.asyncIterator])return e;if("function"==typeof e.getIterator)return e.getIterator()}return T.c?async function*(e){const r=e.getReader();try{for(;;){const{done:e,value:t}=await r.read();if(e)return;yield t}}catch(e){r.releaseLock()}}(e):async function*(e){e=await e;for(;;){const r=e.read();if(null===r){if(e._readableState.ended)return;await z(e)}else yield r}}(e)}async function z(e){return new Promise(r=>{e.once("readable",r)})}const q="Cannot convert supplied data type";function H(e,r){if(r.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const t=e.buffer||e;if(r.text&&!r.binary){return new TextDecoder("utf8").decode(t)}return t}throw new Error(q)}async function G(e,r){const t=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||t)return H(e,r);if(g(e)&&(e=await v(e)),b(e))return await async function(e){if(!e.ok){let r=`fetch failed ${e.status} `;try{r+=await e.text()}catch(e){}throw new Error(r)}}(e),r.binary?await e.arrayBuffer():await e.text();throw new Error(q)}function K(e){return w(e)?e:b(e)&&e.body?(function(e){if(!e.ok)throw new Error(`fetch failed ${e.status}`)}(e),J(e.body)):m(e)?J(e):p(e)?e[Symbol.asyncIterator]():X(e)}function X(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return function*(){yield e.buffer||e}();if(w(e))return e;if(h(e))return e[Symbol.iterator]();throw new Error(q)}function Y(e,r,t){return t||(e={fetch:e.fetch||B,...e},Array.isArray(e.loaders)||(e.loaders=null),e)}function Z(e,r){if(!r&&!Array.isArray(e))return e;let t;if(e&&(t=Array.isArray(e)?e:[e]),r&&r.loaders){const e=Array.isArray(r.loaders)?r.loaders:[r.loaders];t=t?[...t,...e]:e}return t&&t.length?t:null}var ee=t(3);function re(e){if(ee.toArrayBuffer&&(e=Object(ee.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const r=e;return(new TextEncoder).encode(r).buffer}return A(!1)}function te(e,r=!0,t=[]){if(e){if(e instanceof ArrayBuffer)t.push(e);else if(e.buffer&&e.buffer instanceof ArrayBuffer)t.push(e.buffer);else if(r&&"object"==typeof e)for(const n in e)te(e[n],r,t)}else;return t}const ne=new Map;let oe=0;function se({data:e,resolve:r}){r(e)}class ie{constructor({source:e,name:r=`web-worker-${oe++}`,onMessage:t}){const n=function(e){if(A("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")"))return e.match(/^url\((.*)\)$/)[1];let r=ne.get(e);if(!r){const t=new Blob([e],{type:"application/javascript"});r=URL.createObjectURL(t),ne.set(e,r)}return r}(e);this.worker=new Worker(n,{name:r}),this.name=r,this.onMessage=t||se}async process(e){return new Promise((r,t)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:r,reject:t}),this.worker.onerror=e=>t(e);const n=te(e);this.worker.postMessage(e,n)})}destroy(){this.worker.terminate(),this.worker=null}}class ue{constructor({source:e,name:r="unnamed",maxConcurrency:t=1,onMessage:n,onDebug:o=(()=>{})}){this.source=e,this.name=r,this.maxConcurrency=t,this.onMessage=n,this.onDebug=o,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,r){return new Promise((t,n)=>{this.jobQueue.push({data:e,jobName:r,resolve:t,reject:n}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const r=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:r.jobName,backlog:this.jobQueue.length}),e.process(r.data).then(e=>r.resolve(e)).catch(e=>r.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new ie({source:this.source,onMessage:this.onMessage,name:e})}return null}}const ae=5;class ce{constructor({maxConcurrency:e=ae,onMessage:r,onDebug:t=(()=>{})}){this.maxConcurrency=e,this.onMessage=r,this.onDebug=t,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,r,t){return this._getWorkerPool(e,r).process(t)}_getWorkerPool(e,r){let t=this.workerPools.get(r);return t||(t=new ue({source:e,name:r,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(r,t)),t}}let fe=null;async function le({worker:e,data:r,resolve:t,reject:n}){switch(r.type){case"done":t(r.result);break;case"process":try{const t=await ge(r.arraybuffer,r.options,r.url);e.postMessage({type:"process-done",id:r.id,result:t},te(t))}catch(t){e.postMessage({type:"process-error",id:r.id,message:t.message})}break;case"error":n(r.message)}}function de(e,r,t,n={},o={}){n.workerUrl&&(e=n.workerUrl.startsWith("http")?`\n try {\n importScripts('${n.workerUrl}')\n } catch (error) {\n console.error(error);\n }`:`url(${n.workerUrl})`);const s=function(e={}){const r={};return e.maxConcurrency&&(r.maxConcurrency=e.maxConcurrency),e.onDebug&&(r.onDebug=e.onDebug),fe||(fe=new ce({onMessage:le})),fe.setProps(r),fe}(n);return n=JSON.parse(JSON.stringify(n)),s.process(e,`loaders.gl-${r}`,{arraybuffer:re(t),options:n,source:"loaders.gl",type:"process"})}const ye=/[^.]+$/;function he(e,r="",t=null,{nothrow:n=!1}={}){if(r=r||"",e&&!Array.isArray(e)){const r=e;return D(r),r}(function(e){for(const r of e)D(r)})(e=[...e||[],...W]),r=r.replace(/\?.*/,"");let o=null;if(!(o=(o=o||function(e,r){const t=r.match(ye),n=t&&t[0];return n&&function(e,r){r=r.toLowerCase();for(const t of e)for(const e of t.extensions)if(e.toLowerCase()===r)return t;return null}(e,n)}(e,r))||function(e,r){if(!r)return null;for(const t of e)if("string"==typeof r){if(pe(r,t))return t}else if(ArrayBuffer.isView(r)){if(we(r.buffer,r.byteOffset,t))return t}else if(r instanceof ArrayBuffer){if(we(r,0,t))return t}return null}(e,t))){if(n)return null;let e="No valid loader found";throw t&&(e+=` for data starting with "${function(e,r=5){if("string"==typeof e)return e.slice(0,r);if(ArrayBuffer.isView(e))return be(e.buffer,e.byteOffset,r);if(e instanceof ArrayBuffer){return be(e,0,r)}return""}(t)}"`),r&&(e+=` for ${r}`),new Error(e)}return o}function pe(e,r){return r.testText&&r.testText(e)}function we(e,r,t){switch(Array.isArray(t.test)?"array":typeof t.test){case"function":return t.test(e,t);case"string":case"array":return(Array.isArray(t.test)?t.test:[t.test]).some(t=>{return t===be(e,r,t.length)});default:return!1}}function be(e,r,t){if(e.byteLength<=r+t)return"";const n=new DataView(e);let o="";for(let e=0;e<t;e++)o+=String.fromCharCode(n.getUint8(r+e));return o}async function ge(e,r,t,n){Array.isArray(r)||C(r)||(n=t,t=r,r=null);let o="";"string"==typeof n&&(o=n,n=null),t=t||{};const s=function(e,r){return b(e)?r=r||e.url:g(r)&&(r=r.name),"string"==typeof r?r.replace(/\?.*/,""):r}(e,o),i=Z(r,n),u=he(i,s,e);return u?(t=V(u,t,s),n=Y({url:s,parse:ge,loaders:i},0,n),await async function(e,r,t,n){if(r=await G(r,e),e.parseTextSync&&"string"==typeof r)return t.dataType="text",e.parseTextSync(r,t,n,e);if(e.parse)return await e.parse(r,t,n,e);if(e.parseSync)return e.parseSync(r,t,n,e);if(e.worker)return await de(e.worker,e.name,r,t,n);return A(!1)}(u,e,t,n)):null}function me(e,r,t,n){Array.isArray(r)||C(r)||(n=t,t=r,r=null);let o="";"string"==typeof n&&(o=n,n=null),t=t||{};const s=he(Z(r,n),o,e);return s?function(e,r,t,n){if(r=H(r,e),e.parseTextSync&&"string"==typeof r)return e.parseTextSync(r,t,n,e);if(e.parseSync)return e.parseSync(r,t,n,e);throw new Error(`${e.name}: Loader does not support 'parseSync' (${n.url||"data"})`)}(s,e,t=V(s,t,o),n=Y({url:o,parseSync:me,loaders:r})):null}async function xe(e,r,t,n){Array.isArray(r)||C(r)||(n=t,t=r,r=null);const o=he(r,n,null);return function(e,r,t,n){if(e.parseInBatches){const o=K(r);return e.parseInBatches(o,t,n,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,t=V(o,t,n),Y({url:n,loaders:r}))}async function Ae(e,r,t,n){Array.isArray(r)||C(r)||(n=t,t=r,r=null);const o=he(r,n,null);return function(e,r,t,n){if(e.parseInBatchesSync){const o=X(r);return e.parseInBatchesSync(o,t,n,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,t=V(o,t),Y({url:n,loaders:r}))}async function Se(e,r,t){Array.isArray(r)||C(r)||(t=r,r=null);let n=e;return"string"==typeof e&&(n=await B(e,t)),g(e)&&(n=await B(e,t),e=null),await ge(n,r,t,e)}async function ve(e,r,t){return xe(await B(e,t),r,t,e)}function Be(e,r,t,n){if(r.encode)return r.encode(e,t);if(r.encodeSync)return Promise.resolve(r.encodeSync(e,t));throw new Error("Writer could not encode data")}function Te(e,r,t,n){if(r.encodeSync)return r.encodeSync(e,t);throw new Error("Writer could not synchronously encode data")}function ke(e,r,t,n){if(r.encodeInBatches)return r.encodeInBatches(e,t);throw new Error("Writer could not encode data in batches")}function je(e,r,t,n){return E(r,Be(e,t,n))}function _e(e,r,t,n){return F(r,Te(e,t,n))}function Ie(e,r){const t=e instanceof ArrayBuffer?new Uint8Array(e):e,n=r instanceof ArrayBuffer?new Uint8Array(r):r,o=new Uint8Array(t.byteLength+n.byteLength);return o.set(t,0),o.set(n,t.byteLength),o}async function Oe(e,r){for(;;){const{done:t,value:n}=await e.next();if(t)return void e.return();if(r(n))return}}async function Pe(e){let r=new ArrayBuffer,t="";for await(const n of e)"string"==typeof n?t+=n:r=Ie(r,n);return t||r}async function*Ee(e,r){const t=new TextDecoder(r);for await(const r of e)yield"string"==typeof r?r:t.decode(r,{stream:!0})}async function*Fe(e){let r="";for await(const t of e){let e;for(r+=t;(e=r.indexOf("\n"))>=0;){const t=r.slice(0,e+1);r=r.slice(e+1),yield t}}r.length>0&&(yield r)}async function*Le(e){let r=1;for await(const t of e)yield{counter:r,line:t},r++}async function Me(e,r,t=(()=>{}),n=(()=>{})){if(!(e=await e).ok)return e;if(!e.body)return e;const o=e.headers.get("content-length"),s=o&&parseInt(o,10);if(!(o>0))return e;if("undefined"==typeof ReadableStream)return e;const i=new ReadableStream({start(o){!async function e(r,t,n,o,s,i,u){try{const{done:a,value:c}=await t.read();if(a)return i(),void r.close();n+=c.byteLength;const f=Math.round(n/o*100);s(f,{loadedBytes:n,totalBytes:o}),r.enqueue(c),await e(r,t,n,o,s,i,u)}catch(e){r.error(e),u(e)}}(o,e.body.getReader(),0,s,r,t,n)}});return new Response(i)}t.d(r,"path",(function(){return n})),t.d(r,"setPathPrefix",(function(){return u})),t.d(r,"getPathPrefix",(function(){return a})),t.d(r,"resolvePath",(function(){return c})),t.d(r,"fetchFile",(function(){return B})),t.d(r,"readFileSync",(function(){return O})),t.d(r,"writeFile",(function(){return E})),t.d(r,"writeFileSync",(function(){return F})),t.d(r,"_getErrorMessageFromResponseSync",(function(){return L})),t.d(r,"_getErrorMessageFromResponse",(function(){return M})),t.d(r,"registerLoaders",(function(){return $})),t.d(r,"parse",(function(){return ge})),t.d(r,"parseSync",(function(){return me})),t.d(r,"parseInBatches",(function(){return xe})),t.d(r,"parseInBatchesSync",(function(){return Ae})),t.d(r,"load",(function(){return Se})),t.d(r,"loadInBatches",(function(){return ve})),t.d(r,"encode",(function(){return Be})),t.d(r,"encodeSync",(function(){return Te})),t.d(r,"encodeInBatches",(function(){return ke})),t.d(r,"save",(function(){return je})),t.d(r,"saveSync",(function(){return _e})),t.d(r,"isPromise",(function(){return y})),t.d(r,"isIterable",(function(){return h})),t.d(r,"isAsyncIterable",(function(){return p})),t.d(r,"isIterator",(function(){return w})),t.d(r,"isFetchResponse",(function(){return b})),t.d(r,"isReadableStream",(function(){return m})),t.d(r,"isWritableStream",(function(){return x})),t.d(r,"toArrayBuffer",(function(){return re})),t.d(r,"getStreamIterator",(function(){return J})),t.d(r,"forEach",(function(){return Oe})),t.d(r,"concatenateAsyncIterator",(function(){return Pe})),t.d(r,"lineAsyncIterator",(function(){return Fe})),t.d(r,"textDecoderAsyncIterator",(function(){return Ee})),t.d(r,"numberedLineAsyncIterator",(function(){return Le})),t.d(r,"isBrowser",(function(){return T.c})),t.d(r,"self",(function(){return T.e})),t.d(r,"window",(function(){return T.f})),t.d(r,"global",(function(){return T.b})),t.d(r,"document",(function(){return T.a})),t.d(r,"assert",(function(){return A})),t.d(r,"_selectLoader",(function(){return he})),t.d(r,"_WorkerThread",(function(){return ie})),t.d(r,"_WorkerFarm",(function(){return ce})),t.d(r,"_WorkerPool",(function(){return ue})),t.d(r,"_fetchProgress",(function(){return Me})),t.d(r,"_unregisterLoaders",(function(){return R}))}])}));
!function(e,r){if("object"==typeof exports&&"object"==typeof module)module.exports=r();else if("function"==typeof define&&define.amd)define([],r);else{var n=r();for(var t in n)("object"==typeof exports?exports:e)[t]=n[t]}}(window,(function(){return function(e){var r={};function n(t){if(r[t])return r[t].exports;var o=r[t]={i:t,l:!1,exports:{}};return e[t].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=r,n.d=function(e,r,t){n.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},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,r){if(1&r&&(e=n(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(n.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)n.d(t,o,function(r){return e[r]}.bind(null,o));return t},n.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(r,"a",r),r},n.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},n.p="",n(n.s=5)}([,function(e,r){},function(e,r){},function(e,r){},function(e,r){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,r,n){(function(r){const t=n(7),o="undefined"==typeof window?r:window;o.loaders=o.loaders||{},e.exports=Object.assign(o.loaders,t)}).call(this,n(4))},function(e,r){var n,t,o=e.exports={};function i(){throw new Error("setTimeout has not been defined")}function s(){throw new Error("clearTimeout has not been defined")}function u(e){if(n===setTimeout)return setTimeout(e,0);if((n===i||!n)&&setTimeout)return n=setTimeout,setTimeout(e,0);try{return n(e,0)}catch(r){try{return n.call(null,e,0)}catch(r){return n.call(this,e,0)}}}!function(){try{n="function"==typeof setTimeout?setTimeout:i}catch(e){n=i}try{t="function"==typeof clearTimeout?clearTimeout:s}catch(e){t=s}}();var a,c=[],f=!1,l=-1;function d(){f&&a&&(f=!1,a.length?c=a.concat(c):l=-1,c.length&&y())}function y(){if(!f){var e=u(d);f=!0;for(var r=c.length;r;){for(a=c,c=[];++l<r;)a&&a[l].run();l=-1,r=c.length}a=null,f=!1,function(e){if(t===clearTimeout)return clearTimeout(e);if((t===s||!t)&&clearTimeout)return t=clearTimeout,clearTimeout(e);try{t(e)}catch(r){try{return t.call(null,e)}catch(r){return t.call(this,e)}}}(e)}}function h(e,r){this.fun=e,this.array=r}function p(){}o.nextTick=function(e){var r=new Array(arguments.length-1);if(arguments.length>1)for(var n=1;n<arguments.length;n++)r[n-1]=arguments[n];c.push(new h(e,r)),1!==c.length||f||u(y)},h.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=p,o.addListener=p,o.once=p,o.off=p,o.removeListener=p,o.removeAllListeners=p,o.emit=p,o.prependListener=p,o.prependOnceListener=p,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,r,n){"use strict";n.r(r);var t={};function o(e){const r=e&&e.lastIndexOf("/");return r>=0?e.substr(0,r):""}n.r(t),n.d(t,"dirname",(function(){return o}));let i="";const s={};function u(e){i=e}function a(){return i}function c(e){for(const r in s)if(e.startsWith(r)){const n=s[r];return e.replace(r,n)}return e+=i}const f=e=>"boolean"==typeof e,l=e=>"function"==typeof e,d=e=>null!==e&&"object"==typeof e,y=e=>d(e)&&l(e.then),h=e=>e&&"function"==typeof e[Symbol.iterator],p=e=>e&&"function"==typeof e[Symbol.asyncIterator],w=e=>e&&l(e.next),g=e=>"undefined"!=typeof Response&&e instanceof Response||e.arrayBuffer&&e.text&&e.json,b=e=>(e=>"undefined"!=typeof File&&e instanceof File)(e)||(e=>"undefined"!=typeof Blob&&e instanceof Blob)(e),m=e=>(e=>d(e)&&l(e.tee)&&l(e.cancel)&&l(e.pipeTo)&&l(e.getReader))(e)||(e=>d(e)&&l(e.read)&&l(e.pipe)&&f(e.readable))(e),x=e=>(e=>d(e)&&l(e.abort)&&l(e.getWriter))(e)||(e=>d(e)&&l(e.end)&&l(e.write)&&f(e.writable))(e);function A(e,r){if(!e)throw new Error(r||"loader assertion failed.")}class v{constructor(e){this._fileOrBlob=e,this.bodyUsed=!1}get headers(){return new Headers({"Content-Length":this._fileOrBlob.size,"Content-Type":this._fileOrBlob.type})}get ok(){return!0}get status(){return 200}get url(){return this._fileOrBlob.name||""}async arrayBuffer(){const{reader:e,promise:r}=this._getFileReader();return e.readAsArrayBuffer(this._fileOrBlob),r}async text(){const{reader:e,promise:r}=this._getFileReader();return e.readAsText(this._fileOrBlob),r}async json(){const e=await this.text();return JSON.parse(e)}_getFileReader(){let e;A(!this.bodyUsed),this.bodyUsed=!0;const r=new Promise((r,n)=>{try{(e=new FileReader).onerror=e=>n(new Error(e)),e.onabort=()=>n(new Error("Read aborted.")),e.onload=()=>r(e.result)}catch(e){n(e)}});return{reader:e,promise:r}}}function S(e,r){return Promise.resolve(new v(e,r))}async function B(e,r){return b(e)?S(e,r):(e=c(e),fetch(e,r))}var k=n(8),T=n(2);const j={dataType:"arraybuffer",nothrow:!0},_=e=>e.startsWith("data:");function O(e,r){return r=function(e={}){return(e=Object.assign({},j,e)).responseType=e.responseType||e.dataType,e}(r),_(e),r.nothrow||A(!1),null}function I(e,r={}){return e=c(e),!k.c&&T.readFileSync?T.readFileSync(e,r):O(e,r)}var P=n(1);function $(e,r,n){return e=c(e),!k.c&&P.writeFile?P.writeFile(e,r,n):A(!1)}function E(e,r,n){return e=c(e),!k.c&&P.writeFileSync?P.writeFileSync(e,r,n):A(!1)}function W(e){return`Failed to fetch resource ${e.url}(${e.status}): ${e.statusText} `}async function C(e){let r=`Failed to fetch resource ${e.url} (${e.status}): `;try{e.headers.get("Content-Type").includes("application/json")?r+=await e.text():r+=e.statusText}catch(e){return r}return r}class L{log(){return e=>{}}info(){return e=>{}}warn(){return e=>{}}error(){return e=>{}}}const M={CDN:"https://unpkg.com/@loaders.gl",worker:!0,log:new class{constructor(){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)}},dataType:"arraybuffer"},D=e=>e&&"object"==typeof e&&e.constructor==={}.constructor;let F={...M};function R(e,r,n){const t=e&&(e.DEFAULT_LOADER_OPTIONS||e.defaultOptions||e.options||{}),o={...t,...F,...r};return function(e,r){!r||"baseUri"in e||(e.baseUri=r)}(o,n),null===o.log&&(o.log=new L),U(o,t,F),U(o,t,r),o}function U(e,r,n){for(const t in n){const o=n[t];D(o)&&t in r&&(D(r[t])?e[t]={...r[t],...n[t]}:e.log.warn(`Nested option ${t} not recognized`)())}}function Q(e){!function(e){F=R(F,e)}(e)}function N(e){if(!e)return!1;Array.isArray(e)&&(e=e[0]);let r=e.parseTextSync||e.parseSync||e.parse||e.parseStream||e.parseInBatches;const n=e.options&&e.options[e.id];return r=r||n&&n.workerUrl}function V(e){let r;return A(e,"null loader"),A(N(e),"invalid loader"),Array.isArray(e)&&(r=e[1],e=e[0],e={...e,options:{...e.options,...r}}),e.extension&&(e.extensions=e.extensions||e.extension,delete e.extension),Array.isArray(e.extensions)||(e.extensions=[e.extensions]),A(e.extensions&&e.extensions.length>0&&e.extensions[0]),e.parseTextSync&&(e.text=!0),e.text||(e.binary=!0),e}let J=[];function q(e){e=Array.isArray(e)?e:[e];for(const r of e){const e=V(r);J.find(r=>e===r)||J.unshift(e)}}function z(){J=[]}const H="2.0.0-alpha.3";function G(e){const r=e.split(".").map(Number);return{major:r[0],minor:r[1]}}function K(e){if(k.c||k.e>=10){if("function"==typeof e[Symbol.asyncIterator])return e;if("function"==typeof e.getIterator)return e.getIterator()}return k.c?async function*(e){const r=e.getReader();try{for(;;){const{done:e,value:n}=await r.read();if(e)return;yield n}}catch(e){r.releaseLock()}}(e):async function*(e){e=await e;for(;;){const r=e.read();if(null===r){if(e._readableState.ended)return;await X(e)}else yield r}}(e)}async function X(e){return new Promise(r=>{e.once("readable",r)})}const Y="Cannot convert supplied data type";function Z(e,r){if(r.text&&"string"==typeof e)return e;if(e instanceof ArrayBuffer||ArrayBuffer.isView(e)){const n=e.buffer||e;if(r.text&&!r.binary){return new TextDecoder("utf8").decode(n)}return n}throw new Error(Y)}async function ee(e,r){const n=(e=await e)instanceof ArrayBuffer||ArrayBuffer.isView(e);if("string"==typeof e||n)return Z(e,r);if(b(e)&&(e=await S(e)),g(e))return await async function(e){if(!e.ok){let r=`fetch failed ${e.status} `;try{r+=await e.text()}catch(e){}throw new Error(r)}}(e),r.binary?await e.arrayBuffer():await e.text();throw new Error(Y)}function re(e){return w(e)?e:g(e)&&e.body?(function(e){if(!e.ok)throw new Error(`fetch failed ${e.status}`)}(e),K(e.body)):m(e)?K(e):p(e)?e[Symbol.asyncIterator]():ne(e)}function ne(e){if(e instanceof ArrayBuffer||ArrayBuffer.isView(e))return function*(){yield e.buffer||e}();if(w(e))return e;if(h(e))return e[Symbol.iterator]();throw new Error(Y)}function te(e,r,n){return n||(e={fetch:e.fetch||B,...e},Array.isArray(e.loaders)||(e.loaders=null),e)}function oe(e,r){if(!r&&!Array.isArray(e))return e;let n;if(e&&(n=Array.isArray(e)?e:[e]),r&&r.loaders){const e=Array.isArray(r.loaders)?r.loaders:[r.loaders];n=n?[...n,...e]:e}return n&&n.length?n:null}var ie=n(3);function se(e){if(ie.toArrayBuffer&&(e=Object(ie.toArrayBuffer)(e)),e instanceof ArrayBuffer)return e;if(ArrayBuffer.isView(e))return e.buffer;if("string"==typeof e){const r=e;return(new TextEncoder).encode(r).buffer}return A(!1)}const ue=new Map;function ae(e){return!!e&&(e instanceof ArrayBuffer||e.buffer instanceof ArrayBuffer||("undefined"!=typeof MessagePort&&e instanceof MessagePort||("undefined"!=typeof ImageBitmap&&e instanceof ImageBitmap||"undefined"!=typeof OffscreenCanvas&&e instanceof OffscreenCanvas)))}function ce(e,r=!0,n=[]){if(e){if(ae(e))n.push(e);else if(ae(e.buffer))n.push(e.buffer);else if(r&&"object"==typeof e)for(const t in e)ce(e[t],r,n)}else;return n}let fe=0;function le({data:e,resolve:r}){r(e)}class de{constructor({source:e,name:r=`web-worker-${fe++}`,onMessage:n}){const t=function(e,r="Worker"){if(A("string"==typeof e,"worker source"),e.startsWith("url(")&&e.endsWith(")")){const r=e.match(/^url\((.*)\)$/)[1];if(r&&!r.startsWith("http"))return r;e=function(e){return`try {\n importScripts('${e}');\n} catch (error) {\n console.error(error);\n}`}(r)}let n=ue.get(e);if(!n){const r=new Blob([e],{type:"application/javascript"});n=URL.createObjectURL(r),ue.set(e,n)}return n}(e,r);this.worker=new Worker(t,{name:r}),this.name=r,this.onMessage=n||le}async process(e){return new Promise((r,n)=>{this.worker.onmessage=e=>this.onMessage({worker:this.worker,data:e.data,resolve:r,reject:n}),this.worker.onerror=e=>{let r=`${this.name}: WorkerThread.process() failed`;e.message&&(r+=` ${e.message} ${e.filename}:${e.lineno}:${e.colno}`);const t=new Error(r);console.error(e),n(t)};const t=ce(e);this.worker.postMessage(e,t)})}destroy(){this.worker.terminate(),this.worker=null}}class ye{constructor({source:e,name:r="unnamed",maxConcurrency:n=1,onMessage:t,onDebug:o=(()=>{})}){this.source=e,this.name=r,this.maxConcurrency=n,this.onMessage=t,this.onDebug=o,this.jobQueue=[],this.idleQueue=[],this.count=0,this.isDestroyed=!1}destroy(){this.idleQueue.forEach(e=>e.destroy()),this.isDestroyed=!0}async process(e,r){return new Promise((n,t)=>{this.jobQueue.push({data:e,jobName:r,resolve:n,reject:t}),this._startQueuedJob()})}_startQueuedJob(){if(!this.jobQueue.length)return;const e=this._getAvailableWorker();if(!e)return;const r=this.jobQueue.shift();this.onDebug({message:"processing",worker:e.name,job:r.jobName,backlog:this.jobQueue.length}),e.process(r.data).then(e=>r.resolve(e)).catch(e=>r.reject(e)).then(()=>this._onWorkerDone(e))}_onWorkerDone(e){this.isDestroyed?e.destroy():(this.idleQueue.push(e),this._startQueuedJob())}_getAvailableWorker(){if(this.idleQueue.length>0)return this.idleQueue.shift();if(this.count<this.maxConcurrency){this.count++;const e=`${this.name.toLowerCase()}-worker-${this.count}-of-${this.maxConcurrency}`;return new de({source:this.source,onMessage:this.onMessage,name:e})}return null}}const he=5;class pe{constructor({maxConcurrency:e=he,onMessage:r,onDebug:n=(()=>{})}){this.maxConcurrency=e,this.onMessage=r,this.onDebug=n,this.workerPools=new Map}setProps(e){"maxConcurrency"in e&&(this.maxConcurrency=e.maxConcurrency),"onDebug"in e&&(this.onDebug=e.onDebug)}destroy(){this.workerPools.forEach(e=>e.destroy())}async process(e,r,n){return this._getWorkerPool(e,r).process(n)}_getWorkerPool(e,r){let n=this.workerPools.get(r);return n||(n=new ye({source:e,name:r,onMessage:this.onMessage,maxConcurrency:this.maxConcurrency,onDebug:this.onDebug}),this.workerPools.set(r,n)),n}}function we(e,r,n,t){const o=n&&n[e.id],{workerUrl:i}=o||{},s=`url(${i})`,u=e.name,a=function(e={}){const r={};e.maxConcurrency&&(r.maxConcurrency=e.maxConcurrency);e.onDebug&&(r.onDebug=e.onDebug);ge||(ge=new pe({onMessage:be}));return ge.setProps(r),ge}(n);return n=JSON.parse(JSON.stringify(n)),a.process(s,`loaders.gl-${u}`,{arraybuffer:se(r),options:n,source:"loaders.gl@2.0.0-alpha.3",type:"parse"})}let ge=null;async function be({worker:e,data:r,resolve:n,reject:t}){switch(r.type){case"done":n(r.result);break;case"parse":try{const n=await Be(r.arraybuffer,r.options,r.url);e.postMessage({type:"parse-done",id:r.id,result:n},ce(n))}catch(n){e.postMessage({type:"parse-error",id:r.id,message:n.message})}break;case"error":t(r.message)}}const me=/[^.]+$/;function xe(e,r="",n=null,{nothrow:t=!1}={}){if(r=r||"",e&&!Array.isArray(e)){const r=e;return V(r),r}(function(e){for(const r of e)V(r)})(e=[...e||[],...J]),r=r.replace(/\?.*/,"");let o=null;if(!(o=(o=o||function(e,r){const n=r.match(me),t=n&&n[0];return t&&function(e,r){r=r.toLowerCase();for(const n of e)for(const e of n.extensions)if(e.toLowerCase()===r)return n;return null}(e,t)}(e,r))||function(e,r){if(!r)return null;for(const n of e)if("string"==typeof r){if(Ae(r,n))return n}else if(ArrayBuffer.isView(r)){if(ve(r.buffer,r.byteOffset,n))return n}else if(r instanceof ArrayBuffer){if(ve(r,0,n))return n}return null}(e,n))){if(t)return null;let e="No valid loader found";throw n&&(e+=` for data starting with "${function(e,r=5){if("string"==typeof e)return e.slice(0,r);if(ArrayBuffer.isView(e))return Se(e.buffer,e.byteOffset,r);if(e instanceof ArrayBuffer){return Se(e,0,r)}return""}(n)}"`),r&&(e+=` for ${r}`),new Error(e)}return o}function Ae(e,r){return r.testText&&r.testText(e)}function ve(e,r,n){switch(Array.isArray(n.test)?"array":typeof n.test){case"function":return n.test(e,n);case"string":case"array":return(Array.isArray(n.test)?n.test:[n.test]).some(n=>{return n===Se(e,r,n.length)});default:return!1}}function Se(e,r,n){if(e.byteLength<=r+n)return"";const t=new DataView(e);let o="";for(let e=0;e<n;e++)o+=String.fromCharCode(t.getUint8(r+e));return o}async function Be(e,r,n,t){Array.isArray(r)||N(r)||(t=n,n=r,r=null);let o="";"string"==typeof t&&(o=t,t=null),n=n||{};const i=function(e,r){return g(e)?r=r||e.url:b(r)&&(r=r.name),"string"==typeof r?r.replace(/\?.*/,""):r}(e,o),s=oe(r,t),u=xe(s,i,e);return u?(n=R(u,n,i),t=te({url:i,parse:Be,loaders:s},0,t),await async function(e,r,n,t){if(function(e,r=H){A(e,"no loader provided");let n=e.version;r&&n&&(r=G(r),n=G(n),A(r.major===n.major&&r.minor<=n.minor,`loader: ${e.name} is not compatible. ${r.major}.${r.minor}+ is required.`))}(e),r=await ee(r,e),e.parseTextSync&&"string"==typeof r)return n.dataType="text",e.parseTextSync(r,n,t,e);if(function(e,r,n,t){const o=n&&n[e.id];return!!(n.worker&&o&&o.workerUrl)&&(!e.useWorker||e.useWorker(n))}(e,0,n))return await we(e,r,n);if(e.parse)return await e.parse(r,n,t,e);return A(!e.parseSync),A(!1)}(u,e,n,t)):null}function ke(e,r,n,t){Array.isArray(r)||N(r)||(t=n,n=r,r=null);let o="";"string"==typeof t&&(o=t,t=null),n=n||{};const i=xe(oe(r,t),o,e);return i?function(e,r,n,t){if(r=Z(r,e),e.parseTextSync&&"string"==typeof r)return e.parseTextSync(r,n,t,e);if(e.parseSync)return e.parseSync(r,n,t,e);throw new Error(`${e.name} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${t.url||""}`)}(i,e,n=R(i,n,o),t=te({url:o,parseSync:ke,loaders:r})):null}async function Te(e,r,n,t){Array.isArray(r)||N(r)||(t=n,n=r,r=null);const o=xe(r,t,null);return function(e,r,n,t){if(e.parseInBatches){const o=re(r);return e.parseInBatches(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=R(o,n,t),te({url:t,loaders:r}))}async function je(e,r,n,t){Array.isArray(r)||N(r)||(t=n,n=r,r=null);const o=xe(r,t,null);return function(e,r,n,t){if(e.parseInBatchesSync){const o=ne(r);return e.parseInBatchesSync(o,n,t,e)}throw new Error("parseWithLoaderInBatchesSync not available")}(o,e,n=R(o,n),te({url:t,loaders:r}))}async function _e(e,r,n){Array.isArray(r)||N(r)||(n=r,r=null);let t=e;return"string"==typeof e&&(t=await B(e,n)),b(e)&&(t=await B(e,n),e=null),await Be(t,r,n,e)}async function Oe(e,r,n){return Te(await B(e,n),r,n,e)}function Ie(e,r,n,t){if(r.encode)return r.encode(e,n);if(r.encodeSync)return Promise.resolve(r.encodeSync(e,n));throw new Error("Writer could not encode data")}function Pe(e,r,n,t){if(r.encodeSync)return r.encodeSync(e,n);throw new Error("Writer could not synchronously encode data")}function $e(e,r,n,t){if(r.encodeInBatches)return r.encodeInBatches(e,n);throw new Error("Writer could not encode data in batches")}function Ee(e,r,n,t){return $(r,Ie(e,n,t))}function We(e,r,n,t){return E(r,Pe(e,n,t))}function Ce(e,r){const n=e instanceof ArrayBuffer?new Uint8Array(e):e,t=r instanceof ArrayBuffer?new Uint8Array(r):r,o=new Uint8Array(n.byteLength+t.byteLength);return o.set(n,0),o.set(t,n.byteLength),o}async function Le(e,r){for(;;){const{done:n,value:t}=await e.next();if(n)return void e.return();if(r(t))return}}async function Me(e){let r=new ArrayBuffer,n="";for await(const t of e)"string"==typeof t?n+=t:r=Ce(r,t);return n||r}async function*De(e,r){const n=new TextDecoder(r);for await(const r of e)yield"string"==typeof r?r:n.decode(r,{stream:!0})}async function*Fe(e){let r="";for await(const n of e){let e;for(r+=n;(e=r.indexOf("\n"))>=0;){const n=r.slice(0,e+1);r=r.slice(e+1),yield n}}r.length>0&&(yield r)}async function*Re(e){let r=1;for await(const n of e)yield{counter:r,line:n},r++}async function Ue(e,r,n=(()=>{}),t=(()=>{})){if(!(e=await e).ok)return e;if(!e.body)return e;const o=e.headers.get("content-length"),i=o&&parseInt(o,10);if(!(o>0))return e;if("undefined"==typeof ReadableStream)return e;const s=new ReadableStream({start(o){!async function e(r,n,t,o,i,s,u){try{const{done:a,value:c}=await n.read();if(a)return s(),void r.close();t+=c.byteLength;const f=Math.round(t/o*100);i(f,{loadedBytes:t,totalBytes:o}),r.enqueue(c),await e(r,n,t,o,i,s,u)}catch(e){r.error(e),u(e)}}(o,e.body.getReader(),0,i,r,n,t)}});return new Response(s)}n.d(r,"path",(function(){return t})),n.d(r,"setPathPrefix",(function(){return u})),n.d(r,"getPathPrefix",(function(){return a})),n.d(r,"resolvePath",(function(){return c})),n.d(r,"fetchFile",(function(){return B})),n.d(r,"readFileSync",(function(){return I})),n.d(r,"writeFile",(function(){return $})),n.d(r,"writeFileSync",(function(){return E})),n.d(r,"_getErrorMessageFromResponseSync",(function(){return W})),n.d(r,"_getErrorMessageFromResponse",(function(){return C})),n.d(r,"setLoaderOptions",(function(){return Q})),n.d(r,"registerLoaders",(function(){return q})),n.d(r,"parse",(function(){return Be})),n.d(r,"parseSync",(function(){return ke})),n.d(r,"parseInBatches",(function(){return Te})),n.d(r,"parseInBatchesSync",(function(){return je})),n.d(r,"load",(function(){return _e})),n.d(r,"loadInBatches",(function(){return Oe})),n.d(r,"encode",(function(){return Ie})),n.d(r,"encodeSync",(function(){return Pe})),n.d(r,"encodeInBatches",(function(){return $e})),n.d(r,"save",(function(){return Ee})),n.d(r,"saveSync",(function(){return We})),n.d(r,"isPromise",(function(){return y})),n.d(r,"isIterable",(function(){return h})),n.d(r,"isAsyncIterable",(function(){return p})),n.d(r,"isIterator",(function(){return w})),n.d(r,"isFetchResponse",(function(){return g})),n.d(r,"isReadableStream",(function(){return m})),n.d(r,"isWritableStream",(function(){return x})),n.d(r,"toArrayBuffer",(function(){return se})),n.d(r,"getStreamIterator",(function(){return K})),n.d(r,"forEach",(function(){return Le})),n.d(r,"concatenateAsyncIterator",(function(){return Me})),n.d(r,"lineAsyncIterator",(function(){return Fe})),n.d(r,"textDecoderAsyncIterator",(function(){return De})),n.d(r,"numberedLineAsyncIterator",(function(){return Re})),n.d(r,"isBrowser",(function(){return k.c})),n.d(r,"isWorker",(function(){return k.d})),n.d(r,"self",(function(){return k.f})),n.d(r,"window",(function(){return k.g})),n.d(r,"global",(function(){return k.b})),n.d(r,"document",(function(){return k.a})),n.d(r,"assert",(function(){return A})),n.d(r,"_selectLoader",(function(){return xe})),n.d(r,"_WorkerThread",(function(){return de})),n.d(r,"_WorkerFarm",(function(){return pe})),n.d(r,"_WorkerPool",(function(){return ye})),n.d(r,"_fetchProgress",(function(){return Ue})),n.d(r,"_unregisterLoaders",(function(){return z}))},function(e,r,n){"use strict";(function(e,t){n.d(r,"f",(function(){return i})),n.d(r,"g",(function(){return s})),n.d(r,"b",(function(){return u})),n.d(r,"a",(function(){return a})),n.d(r,"c",(function(){return c})),n.d(r,"d",(function(){return f})),n.d(r,"e",(function(){return d}));const o={self:"undefined"!=typeof self&&self,window:"undefined"!=typeof window&&window,global:void 0!==e&&e,document:"undefined"!=typeof document&&document},i=o.self||o.window||o.global,s=o.window||o.self||o.global,u=o.global||o.self||o.window,a=o.document||{},c="object"!=typeof t||"[object process]"!==String(t)||t.browser,f="function"==typeof importScripts,l=void 0!==t&&t.version&&t.version.match(/v([0-9]*)/),d=l&&parseFloat(l[1])||0}).call(this,n(4),n(6))}])}));

@@ -64,2 +64,8 @@ "use strict";

});
Object.defineProperty(exports, "setLoaderOptions", {
enumerable: true,
get: function get() {
return _setLoaderOptions.setLoaderOptions;
}
});
Object.defineProperty(exports, "registerLoaders", {

@@ -230,9 +236,15 @@ enumerable: true,

get: function get() {
return _globals.isBrowser;
return _loaderUtils.isBrowser;
}
});
Object.defineProperty(exports, "isWorker", {
enumerable: true,
get: function get() {
return _loaderUtils.isWorker;
}
});
Object.defineProperty(exports, "self", {
enumerable: true,
get: function get() {
return _globals.self;
return _loaderUtils.self;
}

@@ -243,3 +255,3 @@ });

get: function get() {
return _globals.window;
return _loaderUtils.window;
}

@@ -250,3 +262,3 @@ });

get: function get() {
return _globals.global;
return _loaderUtils.global;
}

@@ -257,3 +269,3 @@ });

get: function get() {
return _globals.document;
return _loaderUtils.document;
}

@@ -264,3 +276,3 @@ });

get: function get() {
return _assert["default"];
return _loaderUtils.assert;
}

@@ -314,2 +326,4 @@ });

var _setLoaderOptions = require("./lib/set-loader-options");
var _registerLoaders = require("./lib/register-loaders");

@@ -341,6 +355,4 @@

var _globals = require("./utils/globals");
var _loaderUtils = require("@loaders.gl/loader-utils");
var _assert = _interopRequireDefault(require("./utils/assert"));
var _selectLoader = require("./lib/select-loader");

@@ -347,0 +359,0 @@

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,3 +8,3 @@ value: true

var _assert = _interopRequireDefault(require("../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -34,4 +32,4 @@ var _toArrayBuffer = require("../node/utils/to-array-buffer.node");

return (0, _assert["default"])(false);
return (0, _loaderUtils.assert)(false);
}
//# sourceMappingURL=binary-utils.js.map

@@ -18,6 +18,6 @@ "use strict";

var _globals = require("../utils/globals");
var _loaderUtils = require("@loaders.gl/loader-utils");
function getStreamIterator(stream) {
if (_globals.isBrowser || _globals.nodeVersion >= 10) {
if (_loaderUtils.isBrowser || _loaderUtils.nodeVersion >= 10) {
if (typeof stream[Symbol.asyncIterator] === 'function') {

@@ -32,3 +32,3 @@ return stream;

return _globals.isBrowser ? makeBrowserStreamIterator(stream) : makeNodeStreamIterator(stream);
return _loaderUtils.isBrowser ? makeBrowserStreamIterator(stream) : makeNodeStreamIterator(stream);
}

@@ -35,0 +35,0 @@

@@ -18,3 +18,3 @@ "use strict";

var _assert = _interopRequireDefault(require("../../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -117,3 +117,3 @@ var FileReadableResponse = function () {

value: function _getFileReader() {
(0, _assert["default"])(!this.bodyUsed);
(0, _loaderUtils.assert)(!this.bodyUsed);
this.bodyUsed = true;

@@ -120,0 +120,0 @@ var reader;

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,3 +8,3 @@ value: true

var _assert = _interopRequireDefault(require("../../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -28,3 +26,3 @@ var DEFAULT_OPTIONS = {

if (!options.nothrow) {
(0, _assert["default"])(false);
(0, _loaderUtils.assert)(false);
}

@@ -31,0 +29,0 @@

@@ -10,3 +10,3 @@ "use strict";

var _globals = require("../../utils/globals");
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -23,3 +23,3 @@ var node = _interopRequireWildcard(require("../../node/read-file-sync.node"));

if (!_globals.isBrowser && node.readFileSync) {
if (!_loaderUtils.isBrowser && node.readFileSync) {
return node.readFileSync(url, options);

@@ -26,0 +26,0 @@ }

@@ -5,4 +5,2 @@ "use strict";

var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -14,6 +12,4 @@ value: true

var _globals = require("../../utils/globals");
var _loaderUtils = require("@loaders.gl/loader-utils");
var _assert = _interopRequireDefault(require("../../utils/assert"));
var node = _interopRequireWildcard(require("../../node/write-file.node"));

@@ -26,7 +22,7 @@

if (!_globals.isBrowser && node.writeFile) {
if (!_loaderUtils.isBrowser && node.writeFile) {
return node.writeFile(filePath, arrayBufferOrString, options);
}
return (0, _assert["default"])(false);
return (0, _loaderUtils.assert)(false);
}

@@ -37,8 +33,8 @@

if (!_globals.isBrowser && node.writeFileSync) {
if (!_loaderUtils.isBrowser && node.writeFileSync) {
return node.writeFileSync(filePath, arrayBufferOrString, options);
}
return (0, _assert["default"])(false);
return (0, _loaderUtils.assert)(false);
}
//# sourceMappingURL=write-file.js.map

@@ -8,2 +8,3 @@ "use strict";

});
exports.setGlobalOptions = setGlobalOptions;
exports.mergeOptions = mergeOptions;

@@ -15,2 +16,4 @@

var _constants = require("../constants");
var _loggers = require("./loggers");

@@ -22,6 +25,2 @@

var COMMON_DEFAULT_OPTIONS = {
log: new _loggers.ConsoleLog()
};
var isPureObject = function isPureObject(value) {

@@ -31,12 +30,14 @@ return value && (0, _typeof2["default"])(value) === 'object' && value.constructor === {}.constructor;

var globalOptions = _objectSpread({}, _constants.DEFAULT_LOADER_OPTIONS);
function setGlobalOptions(options) {
globalOptions = mergeOptions(globalOptions, options);
}
function mergeOptions(loader, options, url) {
var loaderDefaultOptions = loader && (loader.DEFAULT_OPTIONS || loader.defaultOptions || loader.options || {});
var loaderDefaultOptions = loader && (loader.DEFAULT_LOADER_OPTIONS || loader.defaultOptions || loader.options || {});
var mergedOptions = _objectSpread({}, COMMON_DEFAULT_OPTIONS, {}, loaderDefaultOptions, {
dataType: 'arraybuffer'
}, options);
var mergedOptions = _objectSpread({}, loaderDefaultOptions, {}, globalOptions, {}, options);
if (url && !('baseUri' in mergedOptions)) {
mergedOptions.baseUri = url;
}
addUrlOptions(mergedOptions, url);

@@ -47,7 +48,8 @@ if (mergedOptions.log === null) {

mergeNesteFields(mergedOptions, options, loaderDefaultOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, globalOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, options);
return mergedOptions;
}
function mergeNesteFields(mergedOptions, options, loaderDefaultOptions) {
function mergeNestedFields(mergedOptions, loaderDefaultOptions, options) {
for (var key in options) {

@@ -65,2 +67,8 @@ var value = options[key];

}
function addUrlOptions(options, url) {
if (url && !('baseUri' in options)) {
options.baseUri = url;
}
}
//# sourceMappingURL=merge-options.js.map

@@ -13,3 +13,3 @@ "use strict";

var _assert = _interopRequireDefault(require("../../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -29,3 +29,5 @@ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; }

var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches;
var loaderOptions = loader.options && loader.options[loader.id];
hasParser = hasParser || loaderOptions && loaderOptions.workerUrl;
return hasParser;

@@ -35,4 +37,4 @@ }

function normalizeLoader(loader) {
(0, _assert["default"])(loader, 'null loader');
(0, _assert["default"])(isLoaderObject(loader), 'invalid loader');
(0, _loaderUtils.assert)(loader, 'null loader');
(0, _loaderUtils.assert)(isLoaderObject(loader), 'invalid loader');
var options;

@@ -57,3 +59,3 @@

(0, _assert["default"])(loader.extensions && loader.extensions.length > 0 && loader.extensions[0]);
(0, _loaderUtils.assert)(loader.extensions && loader.extensions.length > 0 && loader.extensions[0]);

@@ -60,0 +62,0 @@ if (loader.parseTextSync) {

@@ -8,2 +8,3 @@ "use strict";

});
exports.canParseWithWorker = canParseWithWorker;
exports["default"] = parseWithWorker;

@@ -19,6 +20,34 @@

var _getTransferList = require("../../worker-utils/get-transfer-list");
var _parse = require("../parse");
var _workerUtils = require("../../worker-utils/worker-utils");
function canParseWithWorker(loader, data, options, context) {
var loaderOptions = options && options[loader.id];
if (options.worker && loaderOptions && loaderOptions.workerUrl) {
return loader.useWorker ? loader.useWorker(options) : true;
}
return false;
}
function parseWithWorker(loader, data, options, context) {
var loaderOptions = options && options[loader.id];
var _ref = loaderOptions || {},
workerUrl = _ref.workerUrl;
var workerSource = "url(".concat(workerUrl, ")");
var workerName = loader.name;
var workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: (0, _binaryUtils.toArrayBuffer)(data),
options: options,
source: "loaders.gl@".concat("2.0.0-alpha.3"),
type: 'parse'
});
}
var _workerFarm = null;

@@ -54,3 +83,3 @@

function _onWorkerMessage() {
_onWorkerMessage = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref) {
_onWorkerMessage = (0, _asyncToGenerator2["default"])(_regenerator["default"].mark(function _callee(_ref2) {
var worker, data, resolve, reject, result;

@@ -61,5 +90,5 @@ return _regenerator["default"].wrap(function _callee$(_context) {

case 0:
worker = _ref.worker, data = _ref.data, resolve = _ref.resolve, reject = _ref.reject;
worker = _ref2.worker, data = _ref2.data, resolve = _ref2.resolve, reject = _ref2.reject;
_context.t0 = data.type;
_context.next = _context.t0 === 'done' ? 4 : _context.t0 === 'process' ? 6 : _context.t0 === 'error' ? 17 : 19;
_context.next = _context.t0 === 'done' ? 4 : _context.t0 === 'parse' ? 6 : _context.t0 === 'error' ? 17 : 19;
break;

@@ -79,6 +108,6 @@

worker.postMessage({
type: 'process-done',
type: 'parse-done',
id: data.id,
result: result
}, (0, _workerUtils.getTransferList)(result));
}, (0, _getTransferList.getTransferList)(result));
_context.next = 16;

@@ -91,3 +120,3 @@ break;

worker.postMessage({
type: 'process-error',
type: 'parse-error',
id: data.id,

@@ -113,24 +142,2 @@ message: _context.t1.message

}
function parseWithWorker(workerSource, workerName, data) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var context = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
if (options.workerUrl) {
if (options.workerUrl.startsWith('http')) {
workerSource = "\n try {\n importScripts('".concat(options.workerUrl, "')\n } catch (error) {\n console.error(error);\n }");
} else {
workerSource = "url(".concat(options.workerUrl, ")");
}
}
var workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: (0, _binaryUtils.toArrayBuffer)(data),
options: options,
source: 'loaders.gl',
type: 'process'
});
}
//# sourceMappingURL=parse-with-worker.js.map

@@ -60,4 +60,4 @@ "use strict";

throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
throw new Error("".concat(loader.name, " loader: 'parseSync' not supported by this loader, use 'parse' instead. ").concat(context.url || ''));
}
//# sourceMappingURL=parse-sync.js.map
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");

@@ -14,3 +16,3 @@

var _assert = _interopRequireDefault(require("../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -25,3 +27,3 @@ var _normalizeLoader = require("./loader-utils/normalize-loader");

var _parseWithWorker = _interopRequireDefault(require("./loader-utils/parse-with-worker"));
var _parseWithWorker = _interopRequireWildcard(require("./loader-utils/parse-with-worker"));

@@ -99,10 +101,11 @@ var _selectLoader = require("./select-loader");

case 0:
_context2.next = 2;
(0, _loaderUtils.validateLoaderVersion)(loader);
_context2.next = 3;
return (0, _getData.getArrayBufferOrStringFromData)(data, loader);
case 2:
case 3:
data = _context2.sent;
if (!(loader.parseTextSync && typeof data === 'string')) {
_context2.next = 6;
_context2.next = 7;
break;

@@ -114,37 +117,30 @@ }

case 6:
if (!loader.parse) {
_context2.next = 10;
case 7:
if (!(0, _parseWithWorker.canParseWithWorker)(loader, data, options, context)) {
_context2.next = 11;
break;
}
_context2.next = 9;
return loader.parse(data, options, context, loader);
_context2.next = 10;
return (0, _parseWithWorker["default"])(loader, data, options, context);
case 9:
case 10:
return _context2.abrupt("return", _context2.sent);
case 10:
if (!loader.parseSync) {
_context2.next = 12;
case 11:
if (!loader.parse) {
_context2.next = 15;
break;
}
return _context2.abrupt("return", loader.parseSync(data, options, context, loader));
_context2.next = 14;
return loader.parse(data, options, context, loader);
case 12:
if (!loader.worker) {
_context2.next = 16;
break;
}
case 14:
return _context2.abrupt("return", _context2.sent);
_context2.next = 15;
return (0, _parseWithWorker["default"])(loader.worker, loader.name, data, options, context, loader);
case 15:
return _context2.abrupt("return", _context2.sent);
(0, _loaderUtils.assert)(!loader.parseSync);
return _context2.abrupt("return", (0, _loaderUtils.assert)(false));
case 16:
return _context2.abrupt("return", (0, _assert["default"])(false));
case 17:

@@ -151,0 +147,0 @@ case "end":

"use strict";
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {

@@ -10,3 +8,3 @@ value: true

var _assert = _interopRequireDefault(require("../../utils/assert"));
var _loaderUtils = require("@loaders.gl/loader-utils");

@@ -29,4 +27,4 @@ function toBuffer(binaryData) {

return (0, _assert["default"])(false);
return (0, _loaderUtils.assert)(false);
}
//# sourceMappingURL=to-buffer.node.js.map

@@ -18,4 +18,6 @@ "use strict";

var _workerUtils = require("./worker-utils");
var _getWorkerUrl = require("./get-worker-url");
var _getTransferList = require("./get-transfer-list");
var count = 0;

@@ -36,3 +38,3 @@

(0, _classCallCheck2["default"])(this, WorkerThread);
var url = (0, _workerUtils.getWorkerURL)(source);
var url = (0, _getWorkerUrl.getWorkerURL)(source, name);
this.worker = new Worker(url, {

@@ -66,6 +68,14 @@ name: name

_this.worker.onerror = function (error) {
return reject(error);
var message = "".concat(_this.name, ": WorkerThread.process() failed");
if (error.message) {
message += " ".concat(error.message, " ").concat(error.filename, ":").concat(error.lineno, ":").concat(error.colno);
}
var betterError = new Error(message);
console.error(error);
reject(betterError);
};
var transferList = (0, _workerUtils.getTransferList)(data);
var transferList = (0, _getTransferList.getTransferList)(data);

@@ -72,0 +82,0 @@ _this.worker.postMessage(data, transferList);

@@ -8,2 +8,3 @@ import * as path from './lib/path/path';

export { getErrorMessageFromResponseSync as _getErrorMessageFromResponseSync, getErrorMessageFromResponse as _getErrorMessageFromResponse } from './lib/fetch/fetch-error-message';
export { setLoaderOptions } from './lib/set-loader-options';
export { registerLoaders } from './lib/register-loaders';

@@ -22,4 +23,4 @@ export { parse } from './lib/parse';

export { forEach, concatenateAsyncIterator, lineAsyncIterator, textDecoderAsyncIterator, numberedLineAsyncIterator } from './javascript-utils/async-iterator-utils';
export { isBrowser, self, window, global, document } from './utils/globals';
export { default as assert } from './utils/assert';
export { isBrowser, isWorker, self, window, global, document } from '@loaders.gl/loader-utils';
export { assert } from '@loaders.gl/loader-utils';
export { selectLoader as _selectLoader } from './lib/select-loader';

@@ -26,0 +27,0 @@ export { default as _WorkerThread } from './worker-utils/worker-thread';

@@ -1,2 +0,2 @@

import assert from '../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
import { toArrayBuffer as bufferToArrayBuffer } from '../node/utils/to-array-buffer.node';

@@ -3,0 +3,0 @@ export function toArrayBuffer(data) {

import _awaitAsyncGenerator from "@babel/runtime/helpers/esm/awaitAsyncGenerator";
import _wrapAsyncGenerator from "@babel/runtime/helpers/esm/wrapAsyncGenerator";
import { isBrowser, nodeVersion } from '../utils/globals';
import { isBrowser, nodeVersion } from '@loaders.gl/loader-utils';
export function getStreamIterator(stream) {

@@ -5,0 +5,0 @@ if (isBrowser || nodeVersion >= 10) {

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';

@@ -3,0 +3,0 @@ class FileReadableResponse {

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
const DEFAULT_OPTIONS = {

@@ -3,0 +3,0 @@ dataType: 'arraybuffer',

@@ -1,2 +0,2 @@

import { isBrowser } from '../../utils/globals';
import { isBrowser } from '@loaders.gl/loader-utils';
import * as node from '../../node/read-file-sync.node';

@@ -3,0 +3,0 @@ import { resolvePath } from './file-aliases';

@@ -1,3 +0,2 @@

import { isBrowser } from '../../utils/globals';
import assert from '../../utils/assert';
import { isBrowser, assert } from '@loaders.gl/loader-utils';
import * as node from '../../node/write-file.node';

@@ -4,0 +3,0 @@ import { resolvePath } from './file-aliases';

@@ -7,19 +7,18 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import { NullLog, ConsoleLog } from './loggers';
const COMMON_DEFAULT_OPTIONS = {
log: new ConsoleLog()
};
import { DEFAULT_LOADER_OPTIONS } from '../constants';
import { NullLog } from './loggers';
const isPureObject = value => value && typeof value === 'object' && value.constructor === {}.constructor;
let globalOptions = _objectSpread({}, DEFAULT_LOADER_OPTIONS);
export function setGlobalOptions(options) {
globalOptions = mergeOptions(globalOptions, options);
}
export function mergeOptions(loader, options, url) {
const loaderDefaultOptions = loader && (loader.DEFAULT_OPTIONS || loader.defaultOptions || loader.options || {});
const loaderDefaultOptions = loader && (loader.DEFAULT_LOADER_OPTIONS || loader.defaultOptions || loader.options || {});
const mergedOptions = _objectSpread({}, COMMON_DEFAULT_OPTIONS, {}, loaderDefaultOptions, {
dataType: 'arraybuffer'
}, options);
const mergedOptions = _objectSpread({}, loaderDefaultOptions, {}, globalOptions, {}, options);
if (url && !('baseUri' in mergedOptions)) {
mergedOptions.baseUri = url;
}
addUrlOptions(mergedOptions, url);

@@ -30,7 +29,8 @@ if (mergedOptions.log === null) {

mergeNesteFields(mergedOptions, options, loaderDefaultOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, globalOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, options);
return mergedOptions;
}
function mergeNesteFields(mergedOptions, options, loaderDefaultOptions) {
function mergeNestedFields(mergedOptions, loaderDefaultOptions, options) {
for (const key in options) {

@@ -48,2 +48,8 @@ const value = options[key];

}
function addUrlOptions(options, url) {
if (url && !('baseUri' in options)) {
options.baseUri = url;
}
}
//# sourceMappingURL=merge-options.js.map

@@ -7,3 +7,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
export function isLoaderObject(loader) {

@@ -18,3 +18,5 @@ if (!loader) {

const hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
let hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches;
const loaderOptions = loader.options && loader.options[loader.id];
hasParser = hasParser || loaderOptions && loaderOptions.workerUrl;
return hasParser;

@@ -21,0 +23,0 @@ }

import { toArrayBuffer } from '../../javascript-utils/binary-utils';
import WorkerFarm from '../../worker-utils/worker-farm';
import { getTransferList } from '../../worker-utils/get-transfer-list';
import { parse } from '../parse';
import { getTransferList } from '../../worker-utils/worker-utils';
export function canParseWithWorker(loader, data, options, context) {
const loaderOptions = options && options[loader.id];
if (options.worker && loaderOptions && loaderOptions.workerUrl) {
return loader.useWorker ? loader.useWorker(options) : true;
}
return false;
}
export default function parseWithWorker(loader, data, options, context) {
const loaderOptions = options && options[loader.id];
const {
workerUrl
} = loaderOptions || {};
const workerSource = "url(".concat(workerUrl, ")");
const workerName = loader.name;
const workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: toArrayBuffer(data),
options,
source: "loaders.gl@".concat("2.0.0-alpha.3"),
type: 'parse'
});
}
let _workerFarm = null;

@@ -40,7 +65,7 @@

case 'process':
case 'parse':
try {
const result = await parse(data.arraybuffer, data.options, data.url);
worker.postMessage({
type: 'process-done',
type: 'parse-done',
id: data.id,

@@ -51,3 +76,3 @@ result

worker.postMessage({
type: 'process-error',
type: 'parse-error',
id: data.id,

@@ -67,21 +92,2 @@ message: error.message

}
export default function parseWithWorker(workerSource, workerName, data, options = {}, context = {}) {
if (options.workerUrl) {
if (options.workerUrl.startsWith('http')) {
workerSource = "\n try {\n importScripts('".concat(options.workerUrl, "')\n } catch (error) {\n console.error(error);\n }");
} else {
workerSource = "url(".concat(options.workerUrl, ")");
}
}
const workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: toArrayBuffer(data),
options,
source: 'loaders.gl',
type: 'process'
});
}
//# sourceMappingURL=parse-with-worker.js.map

@@ -48,4 +48,4 @@ import { selectLoader } from './select-loader';

throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
throw new Error("".concat(loader.name, " loader: 'parseSync' not supported by this loader, use 'parse' instead. ").concat(context.url || ''));
}
//# sourceMappingURL=parse-sync.js.map

@@ -1,2 +0,2 @@

import assert from '../utils/assert';
import { assert, validateLoaderVersion } from '@loaders.gl/loader-utils';
import { isLoaderObject } from './loader-utils/normalize-loader';

@@ -7,3 +7,3 @@ import { mergeOptions } from './loader-utils/merge-options';

import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';
import parseWithWorker, { canParseWithWorker } from './loader-utils/parse-with-worker';
import { selectLoader } from './select-loader';

@@ -43,2 +43,3 @@ export async function parse(data, loaders, options, context) {

async function parseWithLoader(loader, data, options, context) {
validateLoaderVersion(loader);
data = await getArrayBufferOrStringFromData(data, loader);

@@ -51,2 +52,6 @@

if (canParseWithWorker(loader, data, options, context)) {
return await parseWithWorker(loader, data, options, context);
}
if (loader.parse) {

@@ -56,12 +61,5 @@ return await loader.parse(data, options, context, loader);

if (loader.parseSync) {
return loader.parseSync(data, options, context, loader);
}
if (loader.worker) {
return await parseWithWorker(loader.worker, loader.name, data, options, context, loader);
}
assert(!loader.parseSync);
return assert(false);
}
//# sourceMappingURL=parse.js.map

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
export default function toBuffer(binaryData) {

@@ -3,0 +3,0 @@ if (ArrayBuffer.isView(binaryData)) {

@@ -1,2 +0,3 @@

import { getWorkerURL, getTransferList } from './worker-utils';
import { getWorkerURL } from './get-worker-url';
import { getTransferList } from './get-transfer-list';
let count = 0;

@@ -17,3 +18,3 @@

}) {
const url = getWorkerURL(source);
const url = getWorkerURL(source, name);
this.worker = new Worker(url, {

@@ -35,4 +36,14 @@ name

this.worker.onerror = error => reject(error);
this.worker.onerror = error => {
let message = "".concat(this.name, ": WorkerThread.process() failed");
if (error.message) {
message += " ".concat(error.message, " ").concat(error.filename, ":").concat(error.lineno, ":").concat(error.colno);
}
const betterError = new Error(message);
console.error(error);
reject(betterError);
};
const transferList = getTransferList(data);

@@ -39,0 +50,0 @@ this.worker.postMessage(data, transferList);

@@ -8,2 +8,3 @@ import * as path from './lib/path/path';

export { getErrorMessageFromResponseSync as _getErrorMessageFromResponseSync, getErrorMessageFromResponse as _getErrorMessageFromResponse } from './lib/fetch/fetch-error-message';
export { setLoaderOptions } from './lib/set-loader-options';
export { registerLoaders } from './lib/register-loaders';

@@ -22,4 +23,4 @@ export { parse } from './lib/parse';

export { forEach, concatenateAsyncIterator, lineAsyncIterator, textDecoderAsyncIterator, numberedLineAsyncIterator } from './javascript-utils/async-iterator-utils';
export { isBrowser, self, window, global, document } from './utils/globals';
export { default as assert } from './utils/assert';
export { isBrowser, isWorker, self, window, global, document } from '@loaders.gl/loader-utils';
export { assert } from '@loaders.gl/loader-utils';
export { selectLoader as _selectLoader } from './lib/select-loader';

@@ -26,0 +27,0 @@ export { default as _WorkerThread } from './worker-utils/worker-thread';

@@ -1,2 +0,2 @@

import assert from '../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
import { toArrayBuffer as bufferToArrayBuffer } from '../node/utils/to-array-buffer.node';

@@ -3,0 +3,0 @@ export function toArrayBuffer(data) {

@@ -5,3 +5,3 @@ import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";

import _wrapAsyncGenerator from "@babel/runtime/helpers/esm/wrapAsyncGenerator";
import { isBrowser, nodeVersion } from '../utils/globals';
import { isBrowser, nodeVersion } from '@loaders.gl/loader-utils';
export function getStreamIterator(stream) {

@@ -8,0 +8,0 @@ if (isBrowser || nodeVersion >= 10) {

@@ -5,3 +5,3 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import _createClass from "@babel/runtime/helpers/esm/createClass";
import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';

@@ -8,0 +8,0 @@ var FileReadableResponse = function () {

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
var DEFAULT_OPTIONS = {

@@ -3,0 +3,0 @@ dataType: 'arraybuffer',

@@ -1,2 +0,2 @@

import { isBrowser } from '../../utils/globals';
import { isBrowser } from '@loaders.gl/loader-utils';
import * as node from '../../node/read-file-sync.node';

@@ -3,0 +3,0 @@ import { resolvePath } from './file-aliases';

@@ -1,3 +0,2 @@

import { isBrowser } from '../../utils/globals';
import assert from '../../utils/assert';
import { isBrowser, assert } from '@loaders.gl/loader-utils';
import * as node from '../../node/write-file.node';

@@ -4,0 +3,0 @@ import { resolvePath } from './file-aliases';

@@ -8,6 +8,4 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import { NullLog, ConsoleLog } from './loggers';
var COMMON_DEFAULT_OPTIONS = {
log: new ConsoleLog()
};
import { DEFAULT_LOADER_OPTIONS } from '../constants';
import { NullLog } from './loggers';

@@ -18,12 +16,13 @@ var isPureObject = function isPureObject(value) {

var globalOptions = _objectSpread({}, DEFAULT_LOADER_OPTIONS);
export function setGlobalOptions(options) {
globalOptions = mergeOptions(globalOptions, options);
}
export function mergeOptions(loader, options, url) {
var loaderDefaultOptions = loader && (loader.DEFAULT_OPTIONS || loader.defaultOptions || loader.options || {});
var loaderDefaultOptions = loader && (loader.DEFAULT_LOADER_OPTIONS || loader.defaultOptions || loader.options || {});
var mergedOptions = _objectSpread({}, COMMON_DEFAULT_OPTIONS, {}, loaderDefaultOptions, {
dataType: 'arraybuffer'
}, options);
var mergedOptions = _objectSpread({}, loaderDefaultOptions, {}, globalOptions, {}, options);
if (url && !('baseUri' in mergedOptions)) {
mergedOptions.baseUri = url;
}
addUrlOptions(mergedOptions, url);

@@ -34,7 +33,8 @@ if (mergedOptions.log === null) {

mergeNesteFields(mergedOptions, options, loaderDefaultOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, globalOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, options);
return mergedOptions;
}
function mergeNesteFields(mergedOptions, options, loaderDefaultOptions) {
function mergeNestedFields(mergedOptions, loaderDefaultOptions, options) {
for (var key in options) {

@@ -52,2 +52,8 @@ var value = options[key];

}
function addUrlOptions(options, url) {
if (url && !('baseUri' in options)) {
options.baseUri = url;
}
}
//# sourceMappingURL=merge-options.js.map

@@ -7,3 +7,3 @@ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
export function isLoaderObject(loader) {

@@ -18,3 +18,5 @@ if (!loader) {

var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches || loader.worker;
var hasParser = loader.parseTextSync || loader.parseSync || loader.parse || loader.parseStream || loader.parseInBatches;
var loaderOptions = loader.options && loader.options[loader.id];
hasParser = hasParser || loaderOptions && loaderOptions.workerUrl;
return hasParser;

@@ -21,0 +23,0 @@ }

@@ -5,4 +5,30 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import WorkerFarm from '../../worker-utils/worker-farm';
import { getTransferList } from '../../worker-utils/get-transfer-list';
import { parse } from '../parse';
import { getTransferList } from '../../worker-utils/worker-utils';
export function canParseWithWorker(loader, data, options, context) {
var loaderOptions = options && options[loader.id];
if (options.worker && loaderOptions && loaderOptions.workerUrl) {
return loader.useWorker ? loader.useWorker(options) : true;
}
return false;
}
export default function parseWithWorker(loader, data, options, context) {
var loaderOptions = options && options[loader.id];
var _ref = loaderOptions || {},
workerUrl = _ref.workerUrl;
var workerSource = "url(".concat(workerUrl, ")");
var workerName = loader.name;
var workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: toArrayBuffer(data),
options: options,
source: "loaders.gl@".concat("2.0.0-alpha.3"),
type: 'parse'
});
}
var _workerFarm = null;

@@ -38,3 +64,3 @@

function _onWorkerMessage() {
_onWorkerMessage = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(_ref) {
_onWorkerMessage = _asyncToGenerator(_regeneratorRuntime.mark(function _callee(_ref2) {
var worker, data, resolve, reject, result;

@@ -45,5 +71,5 @@ return _regeneratorRuntime.wrap(function _callee$(_context) {

case 0:
worker = _ref.worker, data = _ref.data, resolve = _ref.resolve, reject = _ref.reject;
worker = _ref2.worker, data = _ref2.data, resolve = _ref2.resolve, reject = _ref2.reject;
_context.t0 = data.type;
_context.next = _context.t0 === 'done' ? 4 : _context.t0 === 'process' ? 6 : _context.t0 === 'error' ? 17 : 19;
_context.next = _context.t0 === 'done' ? 4 : _context.t0 === 'parse' ? 6 : _context.t0 === 'error' ? 17 : 19;
break;

@@ -63,3 +89,3 @@

worker.postMessage({
type: 'process-done',
type: 'parse-done',
id: data.id,

@@ -75,3 +101,3 @@ result: result

worker.postMessage({
type: 'process-error',
type: 'parse-error',
id: data.id,

@@ -97,24 +123,2 @@ message: _context.t1.message

}
export default function parseWithWorker(workerSource, workerName, data) {
var options = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : {};
var context = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : {};
if (options.workerUrl) {
if (options.workerUrl.startsWith('http')) {
workerSource = "\n try {\n importScripts('".concat(options.workerUrl, "')\n } catch (error) {\n console.error(error);\n }");
} else {
workerSource = "url(".concat(options.workerUrl, ")");
}
}
var workerFarm = getWorkerFarm(options);
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, "loaders.gl-".concat(workerName), {
arraybuffer: toArrayBuffer(data),
options: options,
source: 'loaders.gl',
type: 'process'
});
}
//# sourceMappingURL=parse-with-worker.js.map

@@ -48,4 +48,4 @@ import { selectLoader } from './select-loader';

throw new Error("".concat(loader.name, ": Loader does not support 'parseSync' (").concat(context.url || 'data', ")"));
throw new Error("".concat(loader.name, " loader: 'parseSync' not supported by this loader, use 'parse' instead. ").concat(context.url || ''));
}
//# sourceMappingURL=parse-sync.js.map
import _regeneratorRuntime from "@babel/runtime/regenerator";
import _asyncToGenerator from "@babel/runtime/helpers/esm/asyncToGenerator";
import assert from '../utils/assert';
import { assert, validateLoaderVersion } from '@loaders.gl/loader-utils';
import { isLoaderObject } from './loader-utils/normalize-loader';

@@ -9,3 +9,3 @@ import { mergeOptions } from './loader-utils/merge-options';

import { getLoaders, getLoaderContext } from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';
import parseWithWorker, { canParseWithWorker } from './loader-utils/parse-with-worker';
import { selectLoader } from './select-loader';

@@ -81,10 +81,11 @@ export function parse(_x, _x2, _x3, _x4) {

case 0:
_context2.next = 2;
validateLoaderVersion(loader);
_context2.next = 3;
return getArrayBufferOrStringFromData(data, loader);
case 2:
case 3:
data = _context2.sent;
if (!(loader.parseTextSync && typeof data === 'string')) {
_context2.next = 6;
_context2.next = 7;
break;

@@ -96,35 +97,28 @@ }

case 6:
if (!loader.parse) {
_context2.next = 10;
case 7:
if (!canParseWithWorker(loader, data, options, context)) {
_context2.next = 11;
break;
}
_context2.next = 9;
return loader.parse(data, options, context, loader);
_context2.next = 10;
return parseWithWorker(loader, data, options, context);
case 9:
case 10:
return _context2.abrupt("return", _context2.sent);
case 10:
if (!loader.parseSync) {
_context2.next = 12;
case 11:
if (!loader.parse) {
_context2.next = 15;
break;
}
return _context2.abrupt("return", loader.parseSync(data, options, context, loader));
_context2.next = 14;
return loader.parse(data, options, context, loader);
case 12:
if (!loader.worker) {
_context2.next = 16;
break;
}
case 14:
return _context2.abrupt("return", _context2.sent);
_context2.next = 15;
return parseWithWorker(loader.worker, loader.name, data, options, context, loader);
case 15:
return _context2.abrupt("return", _context2.sent);
case 16:
assert(!loader.parseSync);
return _context2.abrupt("return", assert(false));

@@ -131,0 +125,0 @@

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import { assert } from '@loaders.gl/loader-utils';
export default function toBuffer(binaryData) {

@@ -3,0 +3,0 @@ if (ArrayBuffer.isView(binaryData)) {

@@ -5,3 +5,4 @@ import _regeneratorRuntime from "@babel/runtime/regenerator";

import _createClass from "@babel/runtime/helpers/esm/createClass";
import { getWorkerURL, getTransferList } from './worker-utils';
import { getWorkerURL } from './get-worker-url';
import { getTransferList } from './get-transfer-list';
var count = 0;

@@ -24,3 +25,3 @@

var url = getWorkerURL(source);
var url = getWorkerURL(source, name);
this.worker = new Worker(url, {

@@ -54,3 +55,11 @@ name: name

_this.worker.onerror = function (error) {
return reject(error);
var message = "".concat(_this.name, ": WorkerThread.process() failed");
if (error.message) {
message += " ".concat(error.message, " ").concat(error.filename, ":").concat(error.lineno, ":").concat(error.colno);
}
var betterError = new Error(message);
console.error(error);
reject(betterError);
};

@@ -57,0 +66,0 @@

{
"name": "@loaders.gl/core",
"version": "2.0.0-alpha.2",
"version": "2.0.0-alpha.3",
"description": "Framework-independent loaders for 3D graphics formats",

@@ -30,12 +30,12 @@ "license": "MIT",

"./dist/es5/node/utils/to-array-buffer.node.js": false,
"./dist/esm/node/utils/to-array-buffer.node.js": false,
"./dist/es6/node/utils/to-array-buffer.node.js": false,
"./dist/es5/node/utils/to-buffer.node.js": false,
"./dist/esm/node/utils/to-buffer.node.js": false,
"./dist/es6/node/utils/to-buffer.node.js": false,
"./dist/es5/node/write-file.node.js": false,
"./dist/esm/node/write-file.node.js": false,
"./dist/es6/node/write-file.node.js": false,
"./dist/es5/node/read-file-sync.node.js": false,
"./dist/esm/node/utils/to-array-buffer.node.js": false,
"./dist/esm/node/utils/to-buffer.node.js": false,
"./dist/esm/node/write-file.node.js": false,
"./dist/esm/node/read-file-sync.node.js": false,
"./dist/es6/node/utils/to-array-buffer.node.js": false,
"./dist/es6/node/utils/to-buffer.node.js": false,
"./dist/es6/node/write-file.node.js": false,
"./dist/es6/node/read-file-sync.node.js": false,

@@ -54,5 +54,6 @@ "fs": false

"dependencies": {
"@babel/runtime": "^7.3.1"
"@babel/runtime": "^7.3.1",
"@loaders.gl/loader-utils": "2.0.0-alpha.3"
},
"gitHead": "1bc3e4e6522a2a337f972799f63682464500a313"
"gitHead": "fc28707733ea13de169330a6acd003956e9dbcfa"
}

@@ -16,3 +16,4 @@ import * as path from './lib/path/path';

// FILE PARSING AND ENCODING
// CONFIGURATION
export {setLoaderOptions} from './lib/set-loader-options';
export {registerLoaders} from './lib/register-loaders';

@@ -29,3 +30,3 @@

// ENCODING AND SAVING
// ENCODING (ENCODING AND WRITING)
export {encode, encodeSync, encodeInBatches} from './lib/encode';

@@ -59,4 +60,4 @@ export {save, saveSync} from './lib/save';

// CORE UTILS
export {isBrowser, self, window, global, document} from './utils/globals';
export {default as assert} from './utils/assert';
export {isBrowser, isWorker, self, window, global, document} from '@loaders.gl/loader-utils';
export {assert} from '@loaders.gl/loader-utils';

@@ -63,0 +64,0 @@ // EXPERIMENTAL

/* global ArrayBuffer, TextEncoder */
import assert from '../utils/assert';
import {assert} from '@loaders.gl/loader-utils';
import {toArrayBuffer as bufferToArrayBuffer} from '../node/utils/to-array-buffer.node';

@@ -4,0 +4,0 @@

@@ -1,2 +0,2 @@

import {isBrowser, nodeVersion} from '../utils/globals';
import {isBrowser, nodeVersion} from '@loaders.gl/loader-utils';

@@ -3,0 +3,0 @@ export function getStreamIterator(stream) {

/* global FileReader, Headers */
import assert from '../../utils/assert';
import {assert} from '@loaders.gl/loader-utils';

@@ -4,0 +4,0 @@ // File reader fetch "polyfill" for the browser

// TODO - this file is not tested
import assert from '../../utils/assert';
import {assert} from '@loaders.gl/loader-utils';

@@ -4,0 +4,0 @@ const DEFAULT_OPTIONS = {

@@ -1,2 +0,2 @@

import {isBrowser} from '../../utils/globals';
import {isBrowser} from '@loaders.gl/loader-utils';
import * as node from '../../node/read-file-sync.node';

@@ -3,0 +3,0 @@ import {resolvePath} from './file-aliases';

@@ -1,3 +0,2 @@

import {isBrowser} from '../../utils/globals';
import assert from '../../utils/assert';
import {isBrowser, assert} from '@loaders.gl/loader-utils';
import * as node from '../../node/write-file.node';

@@ -4,0 +3,0 @@ import {resolvePath} from './file-aliases';

@@ -1,25 +0,26 @@

import {NullLog, ConsoleLog} from './loggers';
import {DEFAULT_LOADER_OPTIONS} from '../constants';
import {NullLog} from './loggers';
const COMMON_DEFAULT_OPTIONS = {
log: new ConsoleLog()
};
const isPureObject = value =>
value && typeof value === 'object' && value.constructor === {}.constructor;
// Merges
let globalOptions = {...DEFAULT_LOADER_OPTIONS};
// Set global loader options
export function setGlobalOptions(options) {
globalOptions = mergeOptions(globalOptions, options);
}
// Merges options with global opts and loader defaults, also injects baseUri
export function mergeOptions(loader, options, url) {
const loaderDefaultOptions =
loader && (loader.DEFAULT_OPTIONS || loader.defaultOptions || loader.options || {});
loader && (loader.DEFAULT_LOADER_OPTIONS || loader.defaultOptions || loader.options || {});
const mergedOptions = {
...COMMON_DEFAULT_OPTIONS,
...loaderDefaultOptions,
dataType: 'arraybuffer', // TODO - explain why this option is needed for parsing
...globalOptions,
...options // Merges any non-nested fields, but clobbers nested fields
};
// TODO - remove file component from baseUri
if (url && !('baseUri' in mergedOptions)) {
mergedOptions.baseUri = url;
}
addUrlOptions(mergedOptions, url);

@@ -31,3 +32,4 @@ // LOGGING: options.log can be set to `null` to defeat logging

mergeNesteFields(mergedOptions, options, loaderDefaultOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, globalOptions);
mergeNestedFields(mergedOptions, loaderDefaultOptions, options);

@@ -38,3 +40,3 @@ return mergedOptions;

// Merge nested options objects
function mergeNesteFields(mergedOptions, options, loaderDefaultOptions) {
function mergeNestedFields(mergedOptions, loaderDefaultOptions, options) {
for (const key in options) {

@@ -57,1 +59,12 @@ const value = options[key];

}
// Harvest information from the url
// TODO - baseUri should be a directory, i.e. remove file component from baseUri
// TODO - extract extension?
// TODO - extract query parameters?
// TODO - should these be injected on context instead of options?
function addUrlOptions(options, url) {
if (url && !('baseUri' in options)) {
options.baseUri = url;
}
}

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import {assert} from '@loaders.gl/loader-utils';

@@ -12,11 +12,12 @@ export function isLoaderObject(loader) {

const hasParser =
let hasParser =
loader.parseTextSync ||
loader.parseSync ||
loader.parse ||
loader.parseStream || // TODO Replace with parseInBatches
loader.parseInBatches ||
// loader.parseInBatchesSync || // Optimization only, parseInBatches needed
loader.worker;
loader.parseStream || // TODO Remove, Replace with parseInBatches
loader.parseInBatches;
const loaderOptions = loader.options && loader.options[loader.id];
hasParser = hasParser || (loaderOptions && loaderOptions.workerUrl);
return hasParser;

@@ -23,0 +24,0 @@ }

import {toArrayBuffer} from '../../javascript-utils/binary-utils';
import WorkerFarm from '../../worker-utils/worker-farm';
import {getTransferList} from '../../worker-utils/get-transfer-list';
import {parse} from '../parse';
import {getTransferList} from '../../worker-utils/worker-utils';
export function canParseWithWorker(loader, data, options, context) {
const loaderOptions = options && options[loader.id];
if (options.worker && loaderOptions && loaderOptions.workerUrl) {
return loader.useWorker ? loader.useWorker(options) : true;
}
return false;
}
/**
* this function expects that the worker function sends certain messages,
* this can be automated if the worker is wrapper by a call to createWorker in @loaders.gl/loader-utils.
*/
export default function parseWithWorker(loader, data, options, context) {
const loaderOptions = options && options[loader.id];
const {workerUrl} = loaderOptions || {};
// Mark as URL
const workerSource = `url(${workerUrl})`;
const workerName = loader.name;
const workerFarm = getWorkerFarm(options);
// options.log object contains functions which cannot be transferred
// TODO - decide how to handle logging on workers
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, `loaders.gl-${workerName}`, {
arraybuffer: toArrayBuffer(data),
options, // __VERSION__ is injected by babel-plugin-version-inline
/* global __VERSION__ */ source: `loaders.gl@${__VERSION__}`, // Lets worker ignore unrelated messages
type: 'parse' // For future extension
});
}
let _workerFarm = null;
// Create a single instance of a worker farm
function getWorkerFarm(options = {}) {

@@ -32,8 +66,8 @@ const props = {};

case 'process':
case 'parse':
try {
const result = await parse(data.arraybuffer, data.options, data.url);
worker.postMessage({type: 'process-done', id: data.id, result}, getTransferList(result));
worker.postMessage({type: 'parse-done', id: data.id, result}, getTransferList(result));
} catch (error) {
worker.postMessage({type: 'process-error', id: data.id, message: error.message});
worker.postMessage({type: 'parse-error', id: data.id, message: error.message});
}

@@ -50,41 +84,1 @@ break;

}
/**
* this function expects that the worker function sends certain messages,
* this can be automated if the worker is wrapper by a call to createWorker in @loaders.gl/loader-utils.
*/
export default function parseWithWorker(
workerSource,
workerName,
data,
options = {},
context = {}
) {
if (options.workerUrl) {
if (options.workerUrl.startsWith('http')) {
// Per spec worker cannot be constructed from a different origin
// Only use trusted sources!
workerSource = `
try {
importScripts('${options.workerUrl}')
} catch (error) {
console.error(error);
}`;
} else {
workerSource = `url(${options.workerUrl})`;
}
}
const workerFarm = getWorkerFarm(options);
// options.log object contains functions which cannot be transferred
// TODO - decide how to handle logging on workers
options = JSON.parse(JSON.stringify(options));
return workerFarm.process(workerSource, `loaders.gl-${workerName}`, {
arraybuffer: toArrayBuffer(data),
options,
source: 'loaders.gl', // Lets worker ignore unrelated messages
type: 'process' // For future extension
});
}

@@ -55,3 +55,7 @@ import {selectLoader} from './select-loader';

// TBD - If synchronous parser not available, return null
throw new Error(`${loader.name}: Loader does not support 'parseSync' (${context.url || 'data'})`);
throw new Error(
`${
loader.name
} loader: 'parseSync' not supported by this loader, use 'parse' instead. ${context.url || ''}`
);
}

@@ -1,2 +0,2 @@

import assert from '../utils/assert';
import {assert, validateLoaderVersion} from '@loaders.gl/loader-utils';
import {isLoaderObject} from './loader-utils/normalize-loader';

@@ -7,3 +7,3 @@ import {mergeOptions} from './loader-utils/merge-options';

import {getLoaders, getLoaderContext} from './loader-utils/get-loader-context';
import parseWithWorker from './loader-utils/parse-with-worker';
import parseWithWorker, {canParseWithWorker} from './loader-utils/parse-with-worker';
import {selectLoader} from './select-loader';

@@ -51,5 +51,6 @@

// TODO: support progress and abort
// TODO: support moving loading to worker
// TODO - should accept loader.parseAsyncIterator and concatenate.
async function parseWithLoader(loader, data, options, context) {
validateLoaderVersion(loader);
data = await getArrayBufferOrStringFromData(data, loader);

@@ -63,2 +64,7 @@

// If we have a workerUrl and the loader can parse the given options efficiently in a worker
if (canParseWithWorker(loader, data, options, context)) {
return await parseWithWorker(loader, data, options, context);
}
// Check for asynchronous parser

@@ -69,13 +75,7 @@ if (loader.parse) {

// Now check for synchronous binary data parser, wrap results in promises
if (loader.parseSync) {
return loader.parseSync(data, options, context, loader);
}
// This should not happen, all sync loaders should also offer `parse` function
assert(!loader.parseSync);
if (loader.worker) {
return await parseWithWorker(loader.worker, loader.name, data, options, context, loader);
}
// TBD - If asynchronous parser not available, return null
return assert(false);
}

@@ -1,2 +0,2 @@

import assert from '../../utils/assert';
import {assert} from '@loaders.gl/loader-utils';

@@ -3,0 +3,0 @@ // Convert (copy) ArrayBuffer to Buffer

/* global Worker */
import {getWorkerURL, getTransferList} from './worker-utils';
import {getWorkerURL} from './get-worker-url';
import {getTransferList} from './get-transfer-list';

@@ -13,3 +14,3 @@ let count = 0;

constructor({source, name = `web-worker-${count++}`, onMessage}) {
const url = getWorkerURL(source);
const url = getWorkerURL(source, name);
this.worker = new Worker(url, {name});

@@ -29,3 +30,14 @@ this.name = name;

this.onMessage({worker: this.worker, data: event.data, resolve, reject});
this.worker.onerror = error => reject(error);
this.worker.onerror = error => {
// Note Error object does not have the expected fields if loading failed completely
// https://developer.mozilla.org/en-US/docs/Web/API/Worker#Event_handlers
// https://developer.mozilla.org/en-US/docs/Web/API/ErrorEvent
let message = `${this.name}: WorkerThread.process() failed`;
if (error.message) {
message += ` ${error.message} ${error.filename}:${error.lineno}:${error.colno}`;
}
const betterError = new Error(message);
console.error(error); // eslint-disable-line
reject(betterError);
};
const transferList = getTransferList(data);

@@ -32,0 +44,0 @@ this.worker.postMessage(data, transferList);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc