@loaders.gl/json 3.0.13 → 3.0.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.min.js CHANGED
@@ -1,2 +1,2 @@
1
- !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var o in s)("object"==typeof exports?exports:t)[o]=s[o]}}(window,(function(){return function(t){var e={};function s(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=t,s.c=e,s.d=function(t,e,o){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(o,i,function(e){return t[e]}.bind(null,i));return o},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){(function(e){const o=s(2),i="undefined"==typeof window?e:window;i.loaders=i.loaders||{},t.exports=Object.assign(i.loaders,o)}).call(this,s(1))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";function o(t,e){try{var s;const o=JSON.parse(t);return null!==(s=e.json)&&void 0!==s&&s.table&&function t(e){if(Array.isArray(e))return e;if(e&&"object"==typeof e)for(const s of Object.values(e)){const e=t(s);if(e)return e}return null}(o)||o}catch(t){throw new Error("JSONLoader: failed to parse JSON")}}function i(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}s.r(e),s.d(e,"JSONLoader",(function(){return at})),s.d(e,"_GeoJSONLoader",(function(){return Et})),s.d(e,"_GeoJSONWorkerLoader",(function(){return vt})),s.d(e,"_JSONPath",(function(){return et})),s.d(e,"_ClarinetParser",(function(){return q}));class n{constructor(t,e){if(i(this,"schema",void 0),i(this,"options",void 0),i(this,"length",0),i(this,"rows",null),i(this,"cursor",0),i(this,"_headers",[]),this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(const e in t)this._headers[t[e].index]=t[e].name}}rowCount(){return this.length}addArrayRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}addObjectRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}getBatch(){let t=this.rows;if(!t)return null;t=t.slice(0,this.length),this.rows=null;return{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}}}function r(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class a{constructor(t,e){if(r(this,"schema",void 0),r(this,"options",void 0),r(this,"length",0),r(this,"objectRows",null),r(this,"arrayRows",null),r(this,"cursor",0),r(this,"_headers",[]),this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(const e in t)this._headers[t[e].index]=t[e].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this.options.shape){case"object-row-table":const s=function(t,e){if(!t)throw new Error("null row");if(!e)throw new Error("no headers");const s={};for(let o=0;o<e.length;o++)s[e[o]]=t[o];return s}(t,this._headers);this.addObjectRow(s,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(100),this.arrayRows[this.length]=t,this.length++}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this.options.shape){case"array-row-table":const s=function(t,e){if(!t)throw new Error("null row");if(!e)throw new Error("no headers");const s=new Array(e.length);for(let o=0;o<e.length;o++)s[o]=t[e[o]];return s}(t,this._headers);this.addArrayRow(s,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(100),this.objectRows[this.length]=t,this.length++}}getBatch(){let t=this.arrayRows||this.objectRows;return t?(t=t.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}}function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class c{constructor(t,e){h(this,"schema",void 0),h(this,"length",0),h(this,"allocated",0),h(this,"columns",{}),this.schema=t,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(t){this._reallocateColumns();let e=0;for(const s in this.columns)this.columns[s][this.length]=t[e++];this.length++}addObjectRow(t){this._reallocateColumns();for(const e in t)this.columns[e][this.length]=t[e];this.length++}getBatch(){this._pruneColumns();const t=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(const e in this.schema){const s=this.schema[e];t[s.name]=this.columns[s.index]}this.columns={};return{shape:"columnar-table",batchType:"data",data:t,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(const t in this.schema){const e=this.schema[t],s=e.type||Float32Array,o=this.columns[e.index];if(o&&ArrayBuffer.isView(o)){const t=new s(this.allocated);t.set(o),this.columns[e.index]=t}else o?(o.length=this.allocated,this.columns[e.index]=o):this.columns[e.index]=new s(this.allocated)}}}_pruneColumns(){for(const[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}}function l(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}const u={shape:"array-row-table",batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0};class p{constructor(t,e){l(this,"schema",void 0),l(this,"options",void 0),l(this,"aggregator",null),l(this,"batchCount",0),l(this,"bytesUsed",0),l(this,"isChunkComplete",!1),l(this,"lastBatchEmittedMs",Date.now()),l(this,"totalLength",0),l(this,"totalBytes",0),l(this,"rowBytes",0),this.schema=t,this.options={...u,...e}}limitReached(){var t,e;return!!(Boolean(null===(t=this.options)||void 0===t?void 0:t.limit)&&this.totalLength>=this.options.limit)||!!(Boolean(null===(e=this.options)||void 0===e?void 0:e._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(t){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(t),this.totalBytes+=this.rowBytes,Array.isArray(t)?this.addArrayRow(t):this.addObjectRow(t))}addArrayRow(t){if(!this.aggregator){const t=this._getTableBatchType();this.aggregator=new t(this.schema,this.options)}this.aggregator.addArrayRow(t)}addObjectRow(t){if(!this.aggregator){const t=this._getTableBatchType();this.aggregator=new t(this.schema,this.options)}this.aggregator.addObjectRow(t)}chunkComplete(t){t instanceof ArrayBuffer&&(this.bytesUsed+=t.byteLength),"string"==typeof t&&(this.bytesUsed+=t.length),this.isChunkComplete=!0}getFullBatch(t){return this._isFull()?this._getBatch(t):null}getFinalBatch(t){return this._getBatch(t)}_estimateRowMB(t){return Array.isArray(t)?8*t.length:8*Object.keys(t).length}_isFull(){if(!this.aggregator||0===this.aggregator.rowCount())return!1;if("auto"===this.options.batchSize){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return!(this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs)&&(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(t){if(!this.aggregator)return null;null!=t&&t.bytesUsed&&(this.bytesUsed=t.bytesUsed);const e=this.aggregator.getBatch();return e.count=this.batchCount,e.bytesUsed=this.bytesUsed,Object.assign(e,t),this.batchCount++,this.aggregator=null,e}_getTableBatchType(){switch(this.options.shape){case"row-table":return n;case"array-row-table":case"object-row-table":return a;case"columnar-table":return c;case"arrow-table":if(!p.ArrowBatch)throw new Error("TableBatchBuilder");return p.ArrowBatch;default:throw new Error("TableBatchBuilder")}}}l(p,"ArrowBatch",void 0);const d=Number.MAX_SAFE_INTEGER,f="debug"==={}.CDEBUG,g={textNode:void 0,numberNode:""};let y=0;const b={BEGIN:y++,VALUE:y++,OPEN_OBJECT:y++,CLOSE_OBJECT:y++,OPEN_ARRAY:y++,CLOSE_ARRAY:y++,TEXT_ESCAPE:y++,STRING:y++,BACKSLASH:y++,END:y++,OPEN_KEY:y++,CLOSE_KEY:y++,TRUE:y++,TRUE2:y++,TRUE3:y++,FALSE:y++,FALSE2:y++,FALSE3:y++,FALSE4:y++,NULL:y++,NULL2:y++,NULL3:y++,NUMBER_DECIMAL_POINT:y++,NUMBER_DIGIT:y++};for(var w in b)b[b[w]]=w;y=b;const m=9,A=10,j=13,P=32,v=34,E=43,S=44,_=45,O=46,C=48,N=57,L=58,I=69,R=91,B=92,U=93,k=97,x=98,F=101,T=102,J=108,M=110,z=114,D=115,Y=116,G=117,V=123,K=125;var $=/[\\"\n]/g;class q{constructor(t={}){this._initialize(t)}_initialize(t){this._clearBuffers(this),this.bufferCheckPosition=d,this.q="",this.c="",this.p="",this.options=t||{},this.closed=!1,this.closedRoot=!1,this.sawRoot=!1,this.tag=null,this.error=null,this.state=y.BEGIN,this.stack=new Array,this.position=this.column=0,this.line=1,this.slashed=!1,this.unicodeI=0,this.unicodeS=null,this.depth=0,"onready"in t&&(this.onready=t.onready),"onopenobject"in t&&(this.onopenobject=t.onopenobject),"onkey"in t&&(this.onkey=t.onkey),"oncloseobject"in t&&(this.oncloseobject=t.oncloseobject),"onopenarray"in t&&(this.onopenarray=t.onopenarray),"onclosearray"in t&&(this.onclosearray=t.onclosearray),"onvalue"in t&&(this.onvalue=t.onvalue),"onerror"in t&&(this.onerror=t.onerror),"onend"in t&&(this.onend=t.onend),"onchunkparsed"in t&&(this.onchunkparsed=t.onchunkparsed),X(this,"onready")}_clearBuffers(){for(var t in g)this[t]=g[t]}end(){return this.state===y.VALUE&&0===this.depth||Z(this,"Unexpected end"),W(this),this.c="",this.closed=!0,X(this,"onend"),this._initialize(this.options),this}resume(){return this.error=null,this}close(){return this.write(null)}write(t){if(this.error)throw this.error;if(this.closed)return Z(this,"Cannot write after close. Assign an onready handler.");if(null===t)return this.end();var e=0,s=t.charCodeAt(0),o=this.p;for(f&&console.log("write -> ["+t+"]");s&&(o=s,this.c=s=t.charCodeAt(e++),o!==s?this.p=o:o=this.p,s);)switch(f&&console.log(e,s,b[this.state]),this.position++,s===A?(this.line++,this.column=0):this.column++,this.state){case y.BEGIN:s===V?this.state=y.OPEN_OBJECT:s===R?this.state=y.OPEN_ARRAY:tt(s)||Z(this,"Non-whitespace before {[.");continue;case y.OPEN_KEY:case y.OPEN_OBJECT:if(tt(s))continue;if(this.state===y.OPEN_KEY)this.stack.push(y.CLOSE_KEY);else{if(s===K){X(this,"onopenobject"),this.depth++,X(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||y.VALUE;continue}this.stack.push(y.CLOSE_OBJECT)}s===v?this.state=y.STRING:Z(this,'Malformed object key should start with "');continue;case y.CLOSE_KEY:case y.CLOSE_OBJECT:if(tt(s))continue;this.state,y.CLOSE_KEY;s===L?(this.state===y.CLOSE_OBJECT?(this.stack.push(y.CLOSE_OBJECT),W(this,"onopenobject"),this.depth++):W(this,"onkey"),this.state=y.VALUE):s===K?(H(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||y.VALUE):s===S?(this.state===y.CLOSE_OBJECT&&this.stack.push(y.CLOSE_OBJECT),W(this),this.state=y.OPEN_KEY):Z(this,"Bad object");continue;case y.OPEN_ARRAY:case y.VALUE:if(tt(s))continue;if(this.state===y.OPEN_ARRAY){if(X(this,"onopenarray"),this.depth++,this.state=y.VALUE,s===U){X(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||y.VALUE;continue}this.stack.push(y.CLOSE_ARRAY)}s===v?this.state=y.STRING:s===V?this.state=y.OPEN_OBJECT:s===R?this.state=y.OPEN_ARRAY:s===Y?this.state=y.TRUE:s===T?this.state=y.FALSE:s===M?this.state=y.NULL:s===_?this.numberNode+="-":C<=s&&s<=N?(this.numberNode+=String.fromCharCode(s),this.state=y.NUMBER_DIGIT):Z(this,"Bad value");continue;case y.CLOSE_ARRAY:if(s===S)this.stack.push(y.CLOSE_ARRAY),W(this,"onvalue"),this.state=y.VALUE;else if(s===U)H(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||y.VALUE;else{if(tt(s))continue;Z(this,"Bad array")}continue;case y.STRING:void 0===this.textNode&&(this.textNode="");var i=e-1,n=this.slashed,r=this.unicodeI;t:for(;;){for(f&&console.log(e,s,b[this.state],n);r>0;)if(this.unicodeS+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,4===r?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),r=0,i=e-1):r++,!s)break t;if(s===v&&!n){this.state=this.stack.pop()||y.VALUE,this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}if(s===B&&!n&&(n=!0,this.textNode+=t.substring(i,e-1),this.position+=e-1-i,s=t.charCodeAt(e++),this.position++,!s))break;if(n){if(n=!1,s===M?this.textNode+="\n":s===z?this.textNode+="\r":s===Y?this.textNode+="\t":s===T?this.textNode+="\f":s===x?this.textNode+="\b":s===G?(r=1,this.unicodeS=""):this.textNode+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,i=e-1,s)continue;break}$.lastIndex=e;var a=$.exec(t);if(null===a){e=t.length+1,this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}if(e=a.index+1,!(s=t.charCodeAt(a.index))){this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}}this.slashed=n,this.unicodeI=r;continue;case y.TRUE:s===z?this.state=y.TRUE2:Z(this,"Invalid true started with t"+s);continue;case y.TRUE2:s===G?this.state=y.TRUE3:Z(this,"Invalid true started with tr"+s);continue;case y.TRUE3:s===F?(X(this,"onvalue",!0),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid true started with tru"+s);continue;case y.FALSE:s===k?this.state=y.FALSE2:Z(this,"Invalid false started with f"+s);continue;case y.FALSE2:s===J?this.state=y.FALSE3:Z(this,"Invalid false started with fa"+s);continue;case y.FALSE3:s===D?this.state=y.FALSE4:Z(this,"Invalid false started with fal"+s);continue;case y.FALSE4:s===F?(X(this,"onvalue",!1),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid false started with fals"+s);continue;case y.NULL:s===G?this.state=y.NULL2:Z(this,"Invalid null started with n"+s);continue;case y.NULL2:s===J?this.state=y.NULL3:Z(this,"Invalid null started with nu"+s);continue;case y.NULL3:s===J?(X(this,"onvalue",null),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid null started with nul"+s);continue;case y.NUMBER_DECIMAL_POINT:s===O?(this.numberNode+=".",this.state=y.NUMBER_DIGIT):Z(this,"Leading zero not followed by .");continue;case y.NUMBER_DIGIT:C<=s&&s<=N?this.numberNode+=String.fromCharCode(s):s===O?(-1!==this.numberNode.indexOf(".")&&Z(this,"Invalid number has two dots"),this.numberNode+="."):s===F||s===I?(-1===this.numberNode.indexOf("e")&&-1===this.numberNode.indexOf("E")||Z(this,"Invalid number has two exponential"),this.numberNode+="e"):s===E||s===_?(o!==F&&o!==I&&Z(this,"Invalid symbol in number"),this.numberNode+=String.fromCharCode(s)):(Q(this),e--,this.state=this.stack.pop()||y.VALUE);continue;default:Z(this,"Unknown state: "+this.state)}return this.position>=this.bufferCheckPosition&&function(t){const e=Math.max(d,10);let s=0;for(var o in g){var i=void 0===t[o]?0:t[o].length;if(i>e)switch(o){case"text":closeText(t);break;default:Z(t,"Max buffer length exceeded: "+o)}s=Math.max(s,i)}t.bufferCheckPosition=d-s+t.position}(this),X(this,"onchunkparsed"),this}}function X(t,e,s){f&&console.log("-- emit",e,s),t[e]&&t[e](s,t)}function H(t,e,s){W(t),X(t,e,s)}function W(t,e){t.textNode=function(t,e){if(void 0===e)return e;t.trim&&(e=e.trim());t.normalize&&(e=e.replace(/\s+/g," "));return e}(t.options,t.textNode),void 0!==t.textNode&&X(t,e||"onvalue",t.textNode),t.textNode=void 0}function Q(t){t.numberNode&&X(t,"onvalue",parseFloat(t.numberNode)),t.numberNode=""}function Z(t,e){return W(t),e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c,e=new Error(e),t.error=e,X(t,"onerror",e),t}function tt(t){return t===j||t===A||t===P||t===m}class et{constructor(t=null){var e,s,o;if(o=void 0,(s="path")in(e=this)?Object.defineProperty(e,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[s]=o,this.path=["$"],t instanceof et)this.path=[...t.path];else if(Array.isArray(t))this.path.push(...t);else if("string"==typeof t&&(this.path=t.split("."),"$"!==this.path[0]))throw new Error("JSONPaths must start with $")}clone(){return new et(this)}toString(){return this.path.join(".")}push(t){this.path.push(t)}pop(){return this.path.pop()}set(t){this.path[this.path.length-1]=t}equals(t){if(!this||!t||this.path.length!==t.path.length)return!1;for(let e=0;e<this.path.length;++e)if(this.path[e]!==t.path[e])return!1;return!0}setFieldAtPath(t,e){const s=[...this.path];s.shift();const o=s.pop();for(const e of s)t=t[e];t[o]=e}getFieldAtPath(t){const e=[...this.path];e.shift();const s=e.pop();for(const s of e)t=t[s];return t[s]}}function st(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function ot(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class it extends class{constructor(){st(this,"jsonpath",void 0),st(this,"_parser",void 0),this.reset(),this._initializeParser()}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new et}write(t){this.parser.write(t)}close(){this.parser.close()}_pushOrSet(t){const{container:e,key:s}=this.currentState;null!==s?(e[s]=t,this.currentState.key=null):e.push(t)}_openArray(t=[]){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(t={}){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_initializeParser(){this._parser=new q({onready:()=>{this.jsonpath=new et,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:t=>{this._openObject({}),void 0!==t&&this.parser.onkey(t)},onkey:t=>{this.jsonpath.set(t),this.currentState.key=t},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:t=>{this._pushOrSet(t)},onerror:t=>{throw t},onend:()=>{this.result=this.currentState.container.pop()}})}get parser(){return this._parser}}{constructor(t={}){super(),ot(this,"jsonPaths",void 0),ot(this,"streamingJsonPath",null),ot(this,"streamingArray",null),ot(this,"topLevelObject",null);const e=t.jsonpaths||[];this.jsonPaths=e.map(t=>new et(t)),this._extendParser()}write(t){super.write(t);let e=[];return this.streamingArray&&(e=[...this.streamingArray],this.streamingArray.length=0),e}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){const t=this.getJsonPath();if(0===this.jsonPaths.length)return!0;for(const e of this.jsonPaths)if(e.equals(t))return!0;return!1}_extendParser(){this.parser.onopenarray=()=>{if(!this.streamingArray&&this._matchJSONPath())return this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],void this._openArray(this.streamingArray);this._openArray()},this.parser.onopenobject=t=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),void 0!==t&&this.parser.onkey(t)}}}async function*nt(t,e){var s;const o=async function*(t,e={}){const s=new TextDecoder(void 0,e);for await(const e of t)yield"string"==typeof e?e:s.decode(e,{stream:!0})}(t),{metadata:i}=e,{jsonpaths:n}=e.json||{};let r=!0;const a=(null==e||null===(s=e.json)||void 0===s?void 0:s.shape)||"row-table",h=new p(null,{...e,shape:a}),c=new it({jsonpaths:n});for await(const t of o){const e=c.write(t),s=e.length>0&&c.getStreamingJsonPathAsString();if(e.length>0&&r){if(i){const t={shape:a,batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:s};yield t}r=!1}for(const t of e){h.addRow(t);const e=h.getFullBatch({jsonpath:s});e&&(yield e)}h.chunkComplete(t);const o=h.getFullBatch({jsonpath:s});o&&(yield o)}const l=c.getStreamingJsonPathAsString(),u=h.getFinalBatch({jsonpath:l});if(u&&(yield u),i){const t={shape:a,batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0};yield t}}const rt={json:{shape:"row-table",table:!1,jsonpaths:[]}},at={name:"JSON",id:"json",module:"json",version:"3.0.13",extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,parse:async function(t,e){return ht((new TextDecoder).decode(t),e)},parseTextSync:ht,parseInBatches:function(t,e){const s={...e,json:{...rt.json,...null==e?void 0:e.json}};return nt(t,s)},options:rt};function ht(t,e){return o(t,{...e,json:{...rt.json,...null==e?void 0:e.json}})}function ct(t,e={}){const s=lt(t);return ut(t,s,{coordLength:e.coordLength||s.coordLength,numericPropKeys:e.numericPropKeys||s.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array})}function lt(t){let e=0,s=0,o=0,i=0,n=0,r=0,a=0,h=0,c=0;const l=new Set,u={};for(const d of t){const t=d.geometry;switch(t.type){case"Point":s++,e++,l.add(t.coordinates.length);break;case"MultiPoint":s++,e+=t.coordinates.length;for(const e of t.coordinates)l.add(e.length);break;case"LineString":n++,o+=t.coordinates.length,i++;for(const e of t.coordinates)l.add(e.length);break;case"MultiLineString":n++;for(const e of t.coordinates){o+=e.length,i++;for(const t of e)l.add(t.length)}break;case"Polygon":c++,a++,h+=t.coordinates.length,r+=jt(t.coordinates).length;for(const e of jt(t.coordinates))l.add(e.length);break;case"MultiPolygon":c++;for(const e of t.coordinates){a++,h+=e.length,r+=jt(e).length;for(const t of jt(e))l.add(t.length)}break;default:throw new Error("Unsupported geometry type: "+t.type)}if(d.properties)for(const t in d.properties){const e=d.properties[t];u[t]=u[t]||void 0===u[t]?(p=e,Number.isFinite(p)):u[t]}}var p;return{coordLength:l.size>0?Math.max(...l):2,pointPositionsCount:e,pointFeaturesCount:s,linePositionsCount:o,linePathsCount:i,lineFeaturesCount:n,polygonPositionsCount:r,polygonObjectsCount:a,polygonRingsCount:h,polygonFeaturesCount:c,numericPropKeys:Object.keys(u).filter(t=>u[t])}}function ut(t,e,s){const{pointPositionsCount:o,pointFeaturesCount:i,linePositionsCount:n,linePathsCount:r,lineFeaturesCount:a,polygonPositionsCount:h,polygonObjectsCount:c,polygonRingsCount:l,polygonFeaturesCount:u}=e,{coordLength:p,numericPropKeys:d,PositionDataType:f=Float32Array}=s,g=t.length>65535?Uint32Array:Uint16Array,y={positions:new f(o*p),globalFeatureIds:new g(o),featureIds:i>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:Array(),fields:Array()},b={positions:new f(n*p),pathIndices:n>65535?new Uint32Array(r+1):new Uint16Array(r+1),globalFeatureIds:new g(n),featureIds:a>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:Array(),fields:Array()},w={positions:new f(h*p),polygonIndices:h>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:h>65535?new Uint32Array(l+1):new Uint16Array(l+1),globalFeatureIds:new g(h),featureIds:u>65535?new Uint32Array(h):new Uint16Array(h),numericProps:{},properties:Array(),fields:Array()};for(const t of[y,b,w])for(const e of d||[])t.numericProps[e]=new Float32Array(t.positions.length/p);b.pathIndices[r]=n,w.polygonIndices[c]=h,w.primitivePolygonIndices[l]=h;const m={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const e of t){const t=e.geometry,s=e.properties||{};switch(t.type){case"Point":pt(t.coordinates,y,m,p,s),y.properties.push(mt(s,d)),m.pointFeature++;break;case"MultiPoint":dt(t.coordinates,y,m,p,s),y.properties.push(mt(s,d)),m.pointFeature++;break;case"LineString":ft(t.coordinates,b,m,p,s),b.properties.push(mt(s,d)),m.lineFeature++;break;case"MultiLineString":gt(t.coordinates,b,m,p,s),b.properties.push(mt(s,d)),m.lineFeature++;break;case"Polygon":yt(t.coordinates,w,m,p,s),w.properties.push(mt(s,d)),m.polygonFeature++;break;case"MultiPolygon":bt(t.coordinates,w,m,p,s),w.properties.push(mt(s,d)),m.polygonFeature++;break;default:throw new Error("Invalid geometry type")}m.feature++}return function(t,e,s,o){const i={points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},type:"Point"},lines:{...e,pathIndices:{value:e.pathIndices,size:1},positions:{value:e.positions,size:o},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},type:"LineString"},polygons:{...s,polygonIndices:{value:s.polygonIndices,size:1},primitivePolygonIndices:{value:s.primitivePolygonIndices,size:1},positions:{value:s.positions,size:o},globalFeatureIds:{value:s.globalFeatureIds,size:1},featureIds:{value:s.featureIds,size:1},type:"Polygon"}};for(const t in i)for(const e in i[t].numericProps)i[t].numericProps[e]={value:i[t].numericProps[e],size:1};return i}(y,b,w,p)}function pt(t,e,s,o,i){e.positions.set(t,s.pointPosition*o),e.globalFeatureIds[s.pointPosition]=s.feature,e.featureIds[s.pointPosition]=s.pointFeature,wt(e,i,s.pointPosition,1),s.pointPosition++}function dt(t,e,s,o,i){for(const n of t)pt(n,e,s,o,i)}function ft(t,e,s,o,i){e.pathIndices[s.linePath]=s.linePosition,s.linePath++,At(e.positions,t,s.linePosition,o);const n=t.length;wt(e,i,s.linePosition,n),e.globalFeatureIds.set(new Uint32Array(n).fill(s.feature),s.linePosition),e.featureIds.set(new Uint32Array(n).fill(s.lineFeature),s.linePosition),s.linePosition+=n}function gt(t,e,s,o,i){for(const n of t)ft(n,e,s,o,i)}function yt(t,e,s,o,i){e.polygonIndices[s.polygonObject]=s.polygonPosition,s.polygonObject++;for(const n of t){e.primitivePolygonIndices[s.polygonRing]=s.polygonPosition,s.polygonRing++,At(e.positions,n,s.polygonPosition,o);const t=n.length;wt(e,i,s.polygonPosition,t),e.globalFeatureIds.set(new Uint32Array(t).fill(s.feature),s.polygonPosition),e.featureIds.set(new Uint32Array(t).fill(s.polygonFeature),s.polygonPosition),s.polygonPosition+=t}}function bt(t,e,s,o,i){for(const n of t)yt(n,e,s,o,i)}function wt(t,e,s,o){for(const i in t.numericProps)i in e&&t.numericProps[i].set(new Array(o).fill(e[i]),s)}function mt(t,e){const s={};for(const o in t)e.includes(o)||(s[o]=t[o]);return s}function At(t,e,s,o){let i=s*o;for(const s of e)t.set(s,i),i+=o}function jt(t){return[].concat(...t)}const Pt={geojson:{shape:"object-row-table"},json:{jsonpaths:["$","$.features"]},gis:{format:"geojson"}},vt={name:"GeoJSON",id:"geojson",module:"geojson",version:"3.0.13",worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:Pt},Et={...vt,parse:async function(t,e){return St((new TextDecoder).decode(t),e)},parseTextSync:St,parseInBatches:function(t,e){(e={...Pt,...e}).json={...Pt.geojson,...e.geojson};const s=nt(t,e);switch(e.gis.format){case"binary":return async function*(t){for await(const e of t)e.data=ct(e.data),yield e}(s);default:return s}}};function St(t,e){(e={...Pt,...e}).json={...Pt.geojson,...e.geojson},e.gis=e.gis||{};const s=o(t,e);switch(e.gis.format){case"binary":return ct(s);default:return s}}}])}));
1
+ !function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var s=e();for(var o in s)("object"==typeof exports?exports:t)[o]=s[o]}}(window,(function(){return function(t){var e={};function s(o){if(e[o])return e[o].exports;var i=e[o]={i:o,l:!1,exports:{}};return t[o].call(i.exports,i,i.exports,s),i.l=!0,i.exports}return s.m=t,s.c=e,s.d=function(t,e,o){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:o})},s.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},s.t=function(t,e){if(1&e&&(t=s(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var o=Object.create(null);if(s.r(o),Object.defineProperty(o,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)s.d(o,i,function(e){return t[e]}.bind(null,i));return o},s.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return s.d(e,"a",e),e},s.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},s.p="",s(s.s=0)}([function(t,e,s){(function(e){const o=s(2),i="undefined"==typeof window?e:window;i.loaders=i.loaders||{},t.exports=Object.assign(i.loaders,o)}).call(this,s(1))},function(t,e){var s;s=function(){return this}();try{s=s||new Function("return this")()}catch(t){"object"==typeof window&&(s=window)}t.exports=s},function(t,e,s){"use strict";function o(t,e){try{var s;const o=JSON.parse(t);return null!==(s=e.json)&&void 0!==s&&s.table&&function t(e){if(Array.isArray(e))return e;if(e&&"object"==typeof e)for(const s of Object.values(e)){const e=t(s);if(e)return e}return null}(o)||o}catch(t){throw new Error("JSONLoader: failed to parse JSON")}}function i(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}s.r(e),s.d(e,"JSONLoader",(function(){return at})),s.d(e,"_GeoJSONLoader",(function(){return Et})),s.d(e,"_GeoJSONWorkerLoader",(function(){return vt})),s.d(e,"_JSONPath",(function(){return et})),s.d(e,"_ClarinetParser",(function(){return q}));class n{constructor(t,e){if(i(this,"schema",void 0),i(this,"options",void 0),i(this,"length",0),i(this,"rows",null),i(this,"cursor",0),i(this,"_headers",[]),this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(const e in t)this._headers[t[e].index]=t[e].name}}rowCount(){return this.length}addArrayRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}addObjectRow(t,e){Number.isFinite(e)&&(this.cursor=e),this.rows=this.rows||new Array(100),this.rows[this.length]=t,this.length++}getBatch(){let t=this.rows;if(!t)return null;t=t.slice(0,this.length),this.rows=null;return{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}}}function r(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class a{constructor(t,e){if(r(this,"schema",void 0),r(this,"options",void 0),r(this,"length",0),r(this,"objectRows",null),r(this,"arrayRows",null),r(this,"cursor",0),r(this,"_headers",[]),this.options=e,this.schema=t,!Array.isArray(t)){this._headers=[];for(const e in t)this._headers[t[e].index]=t[e].name}}rowCount(){return this.length}addArrayRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this.options.shape){case"object-row-table":const s=function(t,e){if(!t)throw new Error("null row");if(!e)throw new Error("no headers");const s={};for(let o=0;o<e.length;o++)s[e[o]]=t[o];return s}(t,this._headers);this.addObjectRow(s,e);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(100),this.arrayRows[this.length]=t,this.length++}}addObjectRow(t,e){switch(Number.isFinite(e)&&(this.cursor=e),this.options.shape){case"array-row-table":const s=function(t,e){if(!t)throw new Error("null row");if(!e)throw new Error("no headers");const s=new Array(e.length);for(let o=0;o<e.length;o++)s[o]=t[e[o]];return s}(t,this._headers);this.addArrayRow(s,e);break;case"object-row-table":this.objectRows=this.objectRows||new Array(100),this.objectRows[this.length]=t,this.length++}}getBatch(){let t=this.arrayRows||this.objectRows;return t?(t=t.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:t,length:this.length,schema:this.schema,cursor:this.cursor}):null}}function h(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class c{constructor(t,e){h(this,"schema",void 0),h(this,"length",0),h(this,"allocated",0),h(this,"columns",{}),this.schema=t,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(t){this._reallocateColumns();let e=0;for(const s in this.columns)this.columns[s][this.length]=t[e++];this.length++}addObjectRow(t){this._reallocateColumns();for(const e in t)this.columns[e][this.length]=t[e];this.length++}getBatch(){this._pruneColumns();const t=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(const e in this.schema){const s=this.schema[e];t[s.name]=this.columns[s.index]}this.columns={};return{shape:"columnar-table",batchType:"data",data:t,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(const t in this.schema){const e=this.schema[t],s=e.type||Float32Array,o=this.columns[e.index];if(o&&ArrayBuffer.isView(o)){const t=new s(this.allocated);t.set(o),this.columns[e.index]=t}else o?(o.length=this.allocated,this.columns[e.index]=o):this.columns[e.index]=new s(this.allocated)}}}_pruneColumns(){for(const[t,e]of Object.entries(this.columns))this.columns[t]=e.slice(0,this.length)}}function l(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}const u={shape:"array-row-table",batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0};class p{constructor(t,e){l(this,"schema",void 0),l(this,"options",void 0),l(this,"aggregator",null),l(this,"batchCount",0),l(this,"bytesUsed",0),l(this,"isChunkComplete",!1),l(this,"lastBatchEmittedMs",Date.now()),l(this,"totalLength",0),l(this,"totalBytes",0),l(this,"rowBytes",0),this.schema=t,this.options={...u,...e}}limitReached(){var t,e;return!!(Boolean(null===(t=this.options)||void 0===t?void 0:t.limit)&&this.totalLength>=this.options.limit)||!!(Boolean(null===(e=this.options)||void 0===e?void 0:e._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(t){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(t),this.totalBytes+=this.rowBytes,Array.isArray(t)?this.addArrayRow(t):this.addObjectRow(t))}addArrayRow(t){if(!this.aggregator){const t=this._getTableBatchType();this.aggregator=new t(this.schema,this.options)}this.aggregator.addArrayRow(t)}addObjectRow(t){if(!this.aggregator){const t=this._getTableBatchType();this.aggregator=new t(this.schema,this.options)}this.aggregator.addObjectRow(t)}chunkComplete(t){t instanceof ArrayBuffer&&(this.bytesUsed+=t.byteLength),"string"==typeof t&&(this.bytesUsed+=t.length),this.isChunkComplete=!0}getFullBatch(t){return this._isFull()?this._getBatch(t):null}getFinalBatch(t){return this._getBatch(t)}_estimateRowMB(t){return Array.isArray(t)?8*t.length:8*Object.keys(t).length}_isFull(){if(!this.aggregator||0===this.aggregator.rowCount())return!1;if("auto"===this.options.batchSize){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return!(this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs)&&(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(t){if(!this.aggregator)return null;null!=t&&t.bytesUsed&&(this.bytesUsed=t.bytesUsed);const e=this.aggregator.getBatch();return e.count=this.batchCount,e.bytesUsed=this.bytesUsed,Object.assign(e,t),this.batchCount++,this.aggregator=null,e}_getTableBatchType(){switch(this.options.shape){case"row-table":return n;case"array-row-table":case"object-row-table":return a;case"columnar-table":return c;case"arrow-table":if(!p.ArrowBatch)throw new Error("TableBatchBuilder");return p.ArrowBatch;default:throw new Error("TableBatchBuilder")}}}l(p,"ArrowBatch",void 0);const d=Number.MAX_SAFE_INTEGER,f="debug"==={}.CDEBUG,g={textNode:void 0,numberNode:""};let y=0;const b={BEGIN:y++,VALUE:y++,OPEN_OBJECT:y++,CLOSE_OBJECT:y++,OPEN_ARRAY:y++,CLOSE_ARRAY:y++,TEXT_ESCAPE:y++,STRING:y++,BACKSLASH:y++,END:y++,OPEN_KEY:y++,CLOSE_KEY:y++,TRUE:y++,TRUE2:y++,TRUE3:y++,FALSE:y++,FALSE2:y++,FALSE3:y++,FALSE4:y++,NULL:y++,NULL2:y++,NULL3:y++,NUMBER_DECIMAL_POINT:y++,NUMBER_DIGIT:y++};for(var w in b)b[b[w]]=w;y=b;const m=9,A=10,j=13,P=32,v=34,E=43,S=44,_=45,O=46,C=48,N=57,L=58,I=69,R=91,B=92,U=93,k=97,x=98,F=101,T=102,J=108,M=110,z=114,D=115,Y=116,G=117,V=123,K=125;var $=/[\\"\n]/g;class q{constructor(t={}){this._initialize(t)}_initialize(t){this._clearBuffers(this),this.bufferCheckPosition=d,this.q="",this.c="",this.p="",this.options=t||{},this.closed=!1,this.closedRoot=!1,this.sawRoot=!1,this.tag=null,this.error=null,this.state=y.BEGIN,this.stack=new Array,this.position=this.column=0,this.line=1,this.slashed=!1,this.unicodeI=0,this.unicodeS=null,this.depth=0,"onready"in t&&(this.onready=t.onready),"onopenobject"in t&&(this.onopenobject=t.onopenobject),"onkey"in t&&(this.onkey=t.onkey),"oncloseobject"in t&&(this.oncloseobject=t.oncloseobject),"onopenarray"in t&&(this.onopenarray=t.onopenarray),"onclosearray"in t&&(this.onclosearray=t.onclosearray),"onvalue"in t&&(this.onvalue=t.onvalue),"onerror"in t&&(this.onerror=t.onerror),"onend"in t&&(this.onend=t.onend),"onchunkparsed"in t&&(this.onchunkparsed=t.onchunkparsed),X(this,"onready")}_clearBuffers(){for(var t in g)this[t]=g[t]}end(){return this.state===y.VALUE&&0===this.depth||Z(this,"Unexpected end"),W(this),this.c="",this.closed=!0,X(this,"onend"),this._initialize(this.options),this}resume(){return this.error=null,this}close(){return this.write(null)}write(t){if(this.error)throw this.error;if(this.closed)return Z(this,"Cannot write after close. Assign an onready handler.");if(null===t)return this.end();var e=0,s=t.charCodeAt(0),o=this.p;for(f&&console.log("write -> ["+t+"]");s&&(o=s,this.c=s=t.charCodeAt(e++),o!==s?this.p=o:o=this.p,s);)switch(f&&console.log(e,s,b[this.state]),this.position++,s===A?(this.line++,this.column=0):this.column++,this.state){case y.BEGIN:s===V?this.state=y.OPEN_OBJECT:s===R?this.state=y.OPEN_ARRAY:tt(s)||Z(this,"Non-whitespace before {[.");continue;case y.OPEN_KEY:case y.OPEN_OBJECT:if(tt(s))continue;if(this.state===y.OPEN_KEY)this.stack.push(y.CLOSE_KEY);else{if(s===K){X(this,"onopenobject"),this.depth++,X(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||y.VALUE;continue}this.stack.push(y.CLOSE_OBJECT)}s===v?this.state=y.STRING:Z(this,'Malformed object key should start with "');continue;case y.CLOSE_KEY:case y.CLOSE_OBJECT:if(tt(s))continue;this.state,y.CLOSE_KEY;s===L?(this.state===y.CLOSE_OBJECT?(this.stack.push(y.CLOSE_OBJECT),W(this,"onopenobject"),this.depth++):W(this,"onkey"),this.state=y.VALUE):s===K?(H(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||y.VALUE):s===S?(this.state===y.CLOSE_OBJECT&&this.stack.push(y.CLOSE_OBJECT),W(this),this.state=y.OPEN_KEY):Z(this,"Bad object");continue;case y.OPEN_ARRAY:case y.VALUE:if(tt(s))continue;if(this.state===y.OPEN_ARRAY){if(X(this,"onopenarray"),this.depth++,this.state=y.VALUE,s===U){X(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||y.VALUE;continue}this.stack.push(y.CLOSE_ARRAY)}s===v?this.state=y.STRING:s===V?this.state=y.OPEN_OBJECT:s===R?this.state=y.OPEN_ARRAY:s===Y?this.state=y.TRUE:s===T?this.state=y.FALSE:s===M?this.state=y.NULL:s===_?this.numberNode+="-":C<=s&&s<=N?(this.numberNode+=String.fromCharCode(s),this.state=y.NUMBER_DIGIT):Z(this,"Bad value");continue;case y.CLOSE_ARRAY:if(s===S)this.stack.push(y.CLOSE_ARRAY),W(this,"onvalue"),this.state=y.VALUE;else if(s===U)H(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||y.VALUE;else{if(tt(s))continue;Z(this,"Bad array")}continue;case y.STRING:void 0===this.textNode&&(this.textNode="");var i=e-1,n=this.slashed,r=this.unicodeI;t:for(;;){for(f&&console.log(e,s,b[this.state],n);r>0;)if(this.unicodeS+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,4===r?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),r=0,i=e-1):r++,!s)break t;if(s===v&&!n){this.state=this.stack.pop()||y.VALUE,this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}if(s===B&&!n&&(n=!0,this.textNode+=t.substring(i,e-1),this.position+=e-1-i,s=t.charCodeAt(e++),this.position++,!s))break;if(n){if(n=!1,s===M?this.textNode+="\n":s===z?this.textNode+="\r":s===Y?this.textNode+="\t":s===T?this.textNode+="\f":s===x?this.textNode+="\b":s===G?(r=1,this.unicodeS=""):this.textNode+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,i=e-1,s)continue;break}$.lastIndex=e;var a=$.exec(t);if(null===a){e=t.length+1,this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}if(e=a.index+1,!(s=t.charCodeAt(a.index))){this.textNode+=t.substring(i,e-1),this.position+=e-1-i;break}}this.slashed=n,this.unicodeI=r;continue;case y.TRUE:s===z?this.state=y.TRUE2:Z(this,"Invalid true started with t"+s);continue;case y.TRUE2:s===G?this.state=y.TRUE3:Z(this,"Invalid true started with tr"+s);continue;case y.TRUE3:s===F?(X(this,"onvalue",!0),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid true started with tru"+s);continue;case y.FALSE:s===k?this.state=y.FALSE2:Z(this,"Invalid false started with f"+s);continue;case y.FALSE2:s===J?this.state=y.FALSE3:Z(this,"Invalid false started with fa"+s);continue;case y.FALSE3:s===D?this.state=y.FALSE4:Z(this,"Invalid false started with fal"+s);continue;case y.FALSE4:s===F?(X(this,"onvalue",!1),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid false started with fals"+s);continue;case y.NULL:s===G?this.state=y.NULL2:Z(this,"Invalid null started with n"+s);continue;case y.NULL2:s===J?this.state=y.NULL3:Z(this,"Invalid null started with nu"+s);continue;case y.NULL3:s===J?(X(this,"onvalue",null),this.state=this.stack.pop()||y.VALUE):Z(this,"Invalid null started with nul"+s);continue;case y.NUMBER_DECIMAL_POINT:s===O?(this.numberNode+=".",this.state=y.NUMBER_DIGIT):Z(this,"Leading zero not followed by .");continue;case y.NUMBER_DIGIT:C<=s&&s<=N?this.numberNode+=String.fromCharCode(s):s===O?(-1!==this.numberNode.indexOf(".")&&Z(this,"Invalid number has two dots"),this.numberNode+="."):s===F||s===I?(-1===this.numberNode.indexOf("e")&&-1===this.numberNode.indexOf("E")||Z(this,"Invalid number has two exponential"),this.numberNode+="e"):s===E||s===_?(o!==F&&o!==I&&Z(this,"Invalid symbol in number"),this.numberNode+=String.fromCharCode(s)):(Q(this),e--,this.state=this.stack.pop()||y.VALUE);continue;default:Z(this,"Unknown state: "+this.state)}return this.position>=this.bufferCheckPosition&&function(t){const e=Math.max(d,10);let s=0;for(var o in g){var i=void 0===t[o]?0:t[o].length;if(i>e)switch(o){case"text":closeText(t);break;default:Z(t,"Max buffer length exceeded: "+o)}s=Math.max(s,i)}t.bufferCheckPosition=d-s+t.position}(this),X(this,"onchunkparsed"),this}}function X(t,e,s){f&&console.log("-- emit",e,s),t[e]&&t[e](s,t)}function H(t,e,s){W(t),X(t,e,s)}function W(t,e){t.textNode=function(t,e){if(void 0===e)return e;t.trim&&(e=e.trim());t.normalize&&(e=e.replace(/\s+/g," "));return e}(t.options,t.textNode),void 0!==t.textNode&&X(t,e||"onvalue",t.textNode),t.textNode=void 0}function Q(t){t.numberNode&&X(t,"onvalue",parseFloat(t.numberNode)),t.numberNode=""}function Z(t,e){return W(t),e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c,e=new Error(e),t.error=e,X(t,"onerror",e),t}function tt(t){return t===j||t===A||t===P||t===m}class et{constructor(t=null){var e,s,o;if(o=void 0,(s="path")in(e=this)?Object.defineProperty(e,s,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[s]=o,this.path=["$"],t instanceof et)this.path=[...t.path];else if(Array.isArray(t))this.path.push(...t);else if("string"==typeof t&&(this.path=t.split("."),"$"!==this.path[0]))throw new Error("JSONPaths must start with $")}clone(){return new et(this)}toString(){return this.path.join(".")}push(t){this.path.push(t)}pop(){return this.path.pop()}set(t){this.path[this.path.length-1]=t}equals(t){if(!this||!t||this.path.length!==t.path.length)return!1;for(let e=0;e<this.path.length;++e)if(this.path[e]!==t.path[e])return!1;return!0}setFieldAtPath(t,e){const s=[...this.path];s.shift();const o=s.pop();for(const e of s)t=t[e];t[o]=e}getFieldAtPath(t){const e=[...this.path];e.shift();const s=e.pop();for(const s of e)t=t[s];return t[s]}}function st(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function ot(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}class it extends class{constructor(){st(this,"jsonpath",void 0),st(this,"_parser",void 0),this.reset(),this._initializeParser()}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new et}write(t){this.parser.write(t)}close(){this.parser.close()}_pushOrSet(t){const{container:e,key:s}=this.currentState;null!==s?(e[s]=t,this.currentState.key=null):e.push(t)}_openArray(t=[]){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(t={}){this.jsonpath.push(null),this._pushOrSet(t),this.previousStates.push(this.currentState),this.currentState={container:t,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_initializeParser(){this._parser=new q({onready:()=>{this.jsonpath=new et,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:t=>{this._openObject({}),void 0!==t&&this.parser.onkey(t)},onkey:t=>{this.jsonpath.set(t),this.currentState.key=t},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:t=>{this._pushOrSet(t)},onerror:t=>{throw t},onend:()=>{this.result=this.currentState.container.pop()}})}get parser(){return this._parser}}{constructor(t={}){super(),ot(this,"jsonPaths",void 0),ot(this,"streamingJsonPath",null),ot(this,"streamingArray",null),ot(this,"topLevelObject",null);const e=t.jsonpaths||[];this.jsonPaths=e.map(t=>new et(t)),this._extendParser()}write(t){super.write(t);let e=[];return this.streamingArray&&(e=[...this.streamingArray],this.streamingArray.length=0),e}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){const t=this.getJsonPath();if(0===this.jsonPaths.length)return!0;for(const e of this.jsonPaths)if(e.equals(t))return!0;return!1}_extendParser(){this.parser.onopenarray=()=>{if(!this.streamingArray&&this._matchJSONPath())return this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],void this._openArray(this.streamingArray);this._openArray()},this.parser.onopenobject=t=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),void 0!==t&&this.parser.onkey(t)}}}async function*nt(t,e){var s;const o=async function*(t,e={}){const s=new TextDecoder(void 0,e);for await(const e of t)yield"string"==typeof e?e:s.decode(e,{stream:!0})}(t),{metadata:i}=e,{jsonpaths:n}=e.json||{};let r=!0;const a=(null==e||null===(s=e.json)||void 0===s?void 0:s.shape)||"row-table",h=new p(null,{...e,shape:a}),c=new it({jsonpaths:n});for await(const t of o){const e=c.write(t),s=e.length>0&&c.getStreamingJsonPathAsString();if(e.length>0&&r){if(i){const t={shape:a,batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:s};yield t}r=!1}for(const t of e){h.addRow(t);const e=h.getFullBatch({jsonpath:s});e&&(yield e)}h.chunkComplete(t);const o=h.getFullBatch({jsonpath:s});o&&(yield o)}const l=c.getStreamingJsonPathAsString(),u=h.getFinalBatch({jsonpath:l});if(u&&(yield u),i){const t={shape:a,batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0};yield t}}const rt={json:{shape:"row-table",table:!1,jsonpaths:[]}},at={name:"JSON",id:"json",module:"json",version:"3.0.14",extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,parse:async function(t,e){return ht((new TextDecoder).decode(t),e)},parseTextSync:ht,parseInBatches:function(t,e){const s={...e,json:{...rt.json,...null==e?void 0:e.json}};return nt(t,s)},options:rt};function ht(t,e){return o(t,{...e,json:{...rt.json,...null==e?void 0:e.json}})}function ct(t,e={}){const s=lt(t);return ut(t,s,{coordLength:e.coordLength||s.coordLength,numericPropKeys:e.numericPropKeys||s.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array})}function lt(t){let e=0,s=0,o=0,i=0,n=0,r=0,a=0,h=0,c=0;const l=new Set,u={};for(const d of t){const t=d.geometry;switch(t.type){case"Point":s++,e++,l.add(t.coordinates.length);break;case"MultiPoint":s++,e+=t.coordinates.length;for(const e of t.coordinates)l.add(e.length);break;case"LineString":n++,o+=t.coordinates.length,i++;for(const e of t.coordinates)l.add(e.length);break;case"MultiLineString":n++;for(const e of t.coordinates){o+=e.length,i++;for(const t of e)l.add(t.length)}break;case"Polygon":c++,a++,h+=t.coordinates.length,r+=jt(t.coordinates).length;for(const e of jt(t.coordinates))l.add(e.length);break;case"MultiPolygon":c++;for(const e of t.coordinates){a++,h+=e.length,r+=jt(e).length;for(const t of jt(e))l.add(t.length)}break;default:throw new Error("Unsupported geometry type: "+t.type)}if(d.properties)for(const t in d.properties){const e=d.properties[t];u[t]=u[t]||void 0===u[t]?(p=e,Number.isFinite(p)):u[t]}}var p;return{coordLength:l.size>0?Math.max(...l):2,pointPositionsCount:e,pointFeaturesCount:s,linePositionsCount:o,linePathsCount:i,lineFeaturesCount:n,polygonPositionsCount:r,polygonObjectsCount:a,polygonRingsCount:h,polygonFeaturesCount:c,numericPropKeys:Object.keys(u).filter(t=>u[t])}}function ut(t,e,s){const{pointPositionsCount:o,pointFeaturesCount:i,linePositionsCount:n,linePathsCount:r,lineFeaturesCount:a,polygonPositionsCount:h,polygonObjectsCount:c,polygonRingsCount:l,polygonFeaturesCount:u}=e,{coordLength:p,numericPropKeys:d,PositionDataType:f=Float32Array}=s,g=t.length>65535?Uint32Array:Uint16Array,y={positions:new f(o*p),globalFeatureIds:new g(o),featureIds:i>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:Array(),fields:Array()},b={positions:new f(n*p),pathIndices:n>65535?new Uint32Array(r+1):new Uint16Array(r+1),globalFeatureIds:new g(n),featureIds:a>65535?new Uint32Array(n):new Uint16Array(n),numericProps:{},properties:Array(),fields:Array()},w={positions:new f(h*p),polygonIndices:h>65535?new Uint32Array(c+1):new Uint16Array(c+1),primitivePolygonIndices:h>65535?new Uint32Array(l+1):new Uint16Array(l+1),globalFeatureIds:new g(h),featureIds:u>65535?new Uint32Array(h):new Uint16Array(h),numericProps:{},properties:Array(),fields:Array()};for(const t of[y,b,w])for(const e of d||[])t.numericProps[e]=new Float32Array(t.positions.length/p);b.pathIndices[r]=n,w.polygonIndices[c]=h,w.primitivePolygonIndices[l]=h;const m={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(const e of t){const t=e.geometry,s=e.properties||{};switch(t.type){case"Point":pt(t.coordinates,y,m,p,s),y.properties.push(mt(s,d)),m.pointFeature++;break;case"MultiPoint":dt(t.coordinates,y,m,p,s),y.properties.push(mt(s,d)),m.pointFeature++;break;case"LineString":ft(t.coordinates,b,m,p,s),b.properties.push(mt(s,d)),m.lineFeature++;break;case"MultiLineString":gt(t.coordinates,b,m,p,s),b.properties.push(mt(s,d)),m.lineFeature++;break;case"Polygon":yt(t.coordinates,w,m,p,s),w.properties.push(mt(s,d)),m.polygonFeature++;break;case"MultiPolygon":bt(t.coordinates,w,m,p,s),w.properties.push(mt(s,d)),m.polygonFeature++;break;default:throw new Error("Invalid geometry type")}m.feature++}return function(t,e,s,o){const i={points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},type:"Point"},lines:{...e,pathIndices:{value:e.pathIndices,size:1},positions:{value:e.positions,size:o},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},type:"LineString"},polygons:{...s,polygonIndices:{value:s.polygonIndices,size:1},primitivePolygonIndices:{value:s.primitivePolygonIndices,size:1},positions:{value:s.positions,size:o},globalFeatureIds:{value:s.globalFeatureIds,size:1},featureIds:{value:s.featureIds,size:1},type:"Polygon"}};for(const t in i)for(const e in i[t].numericProps)i[t].numericProps[e]={value:i[t].numericProps[e],size:1};return i}(y,b,w,p)}function pt(t,e,s,o,i){e.positions.set(t,s.pointPosition*o),e.globalFeatureIds[s.pointPosition]=s.feature,e.featureIds[s.pointPosition]=s.pointFeature,wt(e,i,s.pointPosition,1),s.pointPosition++}function dt(t,e,s,o,i){for(const n of t)pt(n,e,s,o,i)}function ft(t,e,s,o,i){e.pathIndices[s.linePath]=s.linePosition,s.linePath++,At(e.positions,t,s.linePosition,o);const n=t.length;wt(e,i,s.linePosition,n),e.globalFeatureIds.set(new Uint32Array(n).fill(s.feature),s.linePosition),e.featureIds.set(new Uint32Array(n).fill(s.lineFeature),s.linePosition),s.linePosition+=n}function gt(t,e,s,o,i){for(const n of t)ft(n,e,s,o,i)}function yt(t,e,s,o,i){e.polygonIndices[s.polygonObject]=s.polygonPosition,s.polygonObject++;for(const n of t){e.primitivePolygonIndices[s.polygonRing]=s.polygonPosition,s.polygonRing++,At(e.positions,n,s.polygonPosition,o);const t=n.length;wt(e,i,s.polygonPosition,t),e.globalFeatureIds.set(new Uint32Array(t).fill(s.feature),s.polygonPosition),e.featureIds.set(new Uint32Array(t).fill(s.polygonFeature),s.polygonPosition),s.polygonPosition+=t}}function bt(t,e,s,o,i){for(const n of t)yt(n,e,s,o,i)}function wt(t,e,s,o){for(const i in t.numericProps)i in e&&t.numericProps[i].set(new Array(o).fill(e[i]),s)}function mt(t,e){const s={};for(const o in t)e.includes(o)||(s[o]=t[o]);return s}function At(t,e,s,o){let i=s*o;for(const s of e)t.set(s,i),i+=o}function jt(t){return[].concat(...t)}const Pt={geojson:{shape:"object-row-table"},json:{jsonpaths:["$","$.features"]},gis:{format:"geojson"}},vt={name:"GeoJSON",id:"geojson",module:"geojson",version:"3.0.14",worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:Pt},Et={...vt,parse:async function(t,e){return St((new TextDecoder).decode(t),e)},parseTextSync:St,parseInBatches:function(t,e){(e={...Pt,...e}).json={...Pt.geojson,...e.geojson};const s=nt(t,e);switch(e.gis.format){case"binary":return async function*(t){for await(const e of t)e.data=ct(e.data),yield e}(s);default:return s}}};function St(t,e){(e={...Pt,...e}).json={...Pt.geojson,...e.geojson},e.gis=e.gis||{};const s=o(t,e);switch(e.gis.format){case"binary":return ct(s);default:return s}}}])}));
2
2
  //# sourceMappingURL=dist.min.js.map
@@ -1,8 +1,8 @@
1
1
  "use strict";
2
2
 
3
- const moduleExports = require('./index');
3
+ var moduleExports = require('./index');
4
4
 
5
- const _global = typeof window === 'undefined' ? global : window;
5
+ var _global = typeof window === 'undefined' ? global : window;
6
6
 
7
7
  _global.loaders = _global.loaders || {};
8
8
  module.exports = Object.assign(_global.loaders, moduleExports);
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,MAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
1
+ {"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","_global","window","global","loaders","module","exports","Object","assign"],"mappings":";;AACA,IAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACA,IAAMC,OAAO,GAAG,OAAOC,MAAP,KAAkB,WAAlB,GAAgCC,MAAhC,GAAyCD,MAAzD;;AACAD,OAAO,CAACG,OAAR,GAAkBH,OAAO,CAACG,OAAR,IAAmB,EAArC;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcP,OAAO,CAACG,OAAtB,EAA+BL,aAA/B,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nconst _global = typeof window === 'undefined' ? global : window;\n_global.loaders = _global.loaders || {};\nmodule.exports = Object.assign(_global.loaders, moduleExports);\n"],"file":"bundle.js"}
@@ -7,14 +7,30 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.GeoJSONLoader = exports.GeoJSONWorkerLoader = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
13
+
14
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
15
+
16
+ var _awaitAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/awaitAsyncGenerator"));
17
+
18
+ var _wrapAsyncGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/wrapAsyncGenerator"));
19
+
20
+ var _asyncIterator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncIterator"));
21
+
10
22
  var _gis = require("@loaders.gl/gis");
11
23
 
12
24
  var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
13
25
 
14
26
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
15
27
 
16
- const VERSION = typeof "3.0.13" !== 'undefined' ? "3.0.13" : 'latest';
17
- const DEFAULT_GEOJSON_LOADER_OPTIONS = {
28
+ 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; }
29
+
30
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
31
+
32
+ var VERSION = typeof "3.0.14" !== 'undefined' ? "3.0.14" : 'latest';
33
+ var DEFAULT_GEOJSON_LOADER_OPTIONS = {
18
34
  geojson: {
19
35
  shape: 'object-row-table'
20
36
  },
@@ -25,7 +41,7 @@ const DEFAULT_GEOJSON_LOADER_OPTIONS = {
25
41
  format: 'geojson'
26
42
  }
27
43
  };
28
- const GeoJSONWorkerLoader = {
44
+ var GeoJSONWorkerLoader = {
29
45
  name: 'GeoJSON',
30
46
  id: 'geojson',
31
47
  module: 'geojson',
@@ -38,26 +54,42 @@ const GeoJSONWorkerLoader = {
38
54
  options: DEFAULT_GEOJSON_LOADER_OPTIONS
39
55
  };
40
56
  exports.GeoJSONWorkerLoader = GeoJSONWorkerLoader;
41
- const GeoJSONLoader = { ...GeoJSONWorkerLoader,
42
- parse,
43
- parseTextSync,
44
- parseInBatches
45
- };
57
+
58
+ var GeoJSONLoader = _objectSpread(_objectSpread({}, GeoJSONWorkerLoader), {}, {
59
+ parse: parse,
60
+ parseTextSync: parseTextSync,
61
+ parseInBatches: parseInBatches
62
+ });
63
+
46
64
  exports.GeoJSONLoader = GeoJSONLoader;
47
65
 
48
- async function parse(arrayBuffer, options) {
49
- return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
66
+ function parse(_x2, _x3) {
67
+ return _parse.apply(this, arguments);
68
+ }
69
+
70
+ function _parse() {
71
+ _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee2(arrayBuffer, options) {
72
+ return _regenerator.default.wrap(function _callee2$(_context2) {
73
+ while (1) {
74
+ switch (_context2.prev = _context2.next) {
75
+ case 0:
76
+ return _context2.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer), options));
77
+
78
+ case 1:
79
+ case "end":
80
+ return _context2.stop();
81
+ }
82
+ }
83
+ }, _callee2);
84
+ }));
85
+ return _parse.apply(this, arguments);
50
86
  }
51
87
 
52
88
  function parseTextSync(text, options) {
53
- options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
54
- ...options
55
- };
56
- options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
57
- ...options.geojson
58
- };
89
+ options = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS), options);
90
+ options.json = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS.geojson), options.geojson);
59
91
  options.gis = options.gis || {};
60
- const json = (0, _parseJson.default)(text, options);
92
+ var json = (0, _parseJson.default)(text, options);
61
93
 
62
94
  switch (options.gis.format) {
63
95
  case 'binary':
@@ -69,13 +101,9 @@ function parseTextSync(text, options) {
69
101
  }
70
102
 
71
103
  function parseInBatches(asyncIterator, options) {
72
- options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
73
- ...options
74
- };
75
- options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
76
- ...options.geojson
77
- };
78
- const geojsonIterator = (0, _parseJsonInBatches.default)(asyncIterator, options);
104
+ options = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS), options);
105
+ options.json = _objectSpread(_objectSpread({}, DEFAULT_GEOJSON_LOADER_OPTIONS.geojson), options.geojson);
106
+ var geojsonIterator = (0, _parseJsonInBatches.default)(asyncIterator, options);
79
107
 
80
108
  switch (options.gis.format) {
81
109
  case 'binary':
@@ -86,10 +114,96 @@ function parseInBatches(asyncIterator, options) {
86
114
  }
87
115
  }
88
116
 
89
- async function* makeBinaryGeometryIterator(geojsonIterator) {
90
- for await (const batch of geojsonIterator) {
91
- batch.data = (0, _gis.geojsonToBinary)(batch.data);
92
- yield batch;
93
- }
117
+ function makeBinaryGeometryIterator(_x) {
118
+ return _makeBinaryGeometryIterator.apply(this, arguments);
119
+ }
120
+
121
+ function _makeBinaryGeometryIterator() {
122
+ _makeBinaryGeometryIterator = (0, _wrapAsyncGenerator2.default)(_regenerator.default.mark(function _callee(geojsonIterator) {
123
+ var _iteratorNormalCompletion, _didIteratorError, _iteratorError, _iterator, _step, _value, batch;
124
+
125
+ return _regenerator.default.wrap(function _callee$(_context) {
126
+ while (1) {
127
+ switch (_context.prev = _context.next) {
128
+ case 0:
129
+ _iteratorNormalCompletion = true;
130
+ _didIteratorError = false;
131
+ _context.prev = 2;
132
+ _iterator = (0, _asyncIterator2.default)(geojsonIterator);
133
+
134
+ case 4:
135
+ _context.next = 6;
136
+ return (0, _awaitAsyncGenerator2.default)(_iterator.next());
137
+
138
+ case 6:
139
+ _step = _context.sent;
140
+ _iteratorNormalCompletion = _step.done;
141
+ _context.next = 10;
142
+ return (0, _awaitAsyncGenerator2.default)(_step.value);
143
+
144
+ case 10:
145
+ _value = _context.sent;
146
+
147
+ if (_iteratorNormalCompletion) {
148
+ _context.next = 19;
149
+ break;
150
+ }
151
+
152
+ batch = _value;
153
+ batch.data = (0, _gis.geojsonToBinary)(batch.data);
154
+ _context.next = 16;
155
+ return batch;
156
+
157
+ case 16:
158
+ _iteratorNormalCompletion = true;
159
+ _context.next = 4;
160
+ break;
161
+
162
+ case 19:
163
+ _context.next = 25;
164
+ break;
165
+
166
+ case 21:
167
+ _context.prev = 21;
168
+ _context.t0 = _context["catch"](2);
169
+ _didIteratorError = true;
170
+ _iteratorError = _context.t0;
171
+
172
+ case 25:
173
+ _context.prev = 25;
174
+ _context.prev = 26;
175
+
176
+ if (!(!_iteratorNormalCompletion && _iterator.return != null)) {
177
+ _context.next = 30;
178
+ break;
179
+ }
180
+
181
+ _context.next = 30;
182
+ return (0, _awaitAsyncGenerator2.default)(_iterator.return());
183
+
184
+ case 30:
185
+ _context.prev = 30;
186
+
187
+ if (!_didIteratorError) {
188
+ _context.next = 33;
189
+ break;
190
+ }
191
+
192
+ throw _iteratorError;
193
+
194
+ case 33:
195
+ return _context.finish(30);
196
+
197
+ case 34:
198
+ return _context.finish(25);
199
+
200
+ case 35:
201
+ case "end":
202
+ return _context.stop();
203
+ }
204
+ }
205
+ }, _callee, null, [[2, 21, 25, 35], [26,, 30, 34]]);
206
+ }));
207
+ return _makeBinaryGeometryIterator.apply(this, arguments);
94
208
  }
95
209
  //# sourceMappingURL=geojson-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/geojson-loader.ts"],"names":["VERSION","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","shape","json","jsonpaths","gis","format","GeoJSONWorkerLoader","name","id","module","version","worker","extensions","mimeTypes","category","text","options","GeoJSONLoader","parse","parseTextSync","parseInBatches","arrayBuffer","TextDecoder","decode","asyncIterator","geojsonIterator","makeBinaryGeometryIterator","batch","data"],"mappings":";;;;;;;;;AAEA;;AACA;;AACA;;AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAWA,MAAMC,8BAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE;AADA,GAD4B;AAIrCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,SAAS,EAAE,CAAC,GAAD,EAAM,YAAN;AADP,GAJ+B;AAOrCC,EAAAA,GAAG,EAAE;AACHC,IAAAA,MAAM,EAAE;AADL;AAPgC,CAAvC;AAeO,MAAMC,mBAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,SADmC;AAEzCC,EAAAA,EAAE,EAAE,SAFqC;AAGzCC,EAAAA,MAAM,EAAE,SAHiC;AAIzCC,EAAAA,OAAO,EAAEZ,OAJgC;AAKzCa,EAAAA,MAAM,EAAE,IALiC;AAMzCC,EAAAA,UAAU,EAAE,CAAC,SAAD,CAN6B;AAOzCC,EAAAA,SAAS,EAAE,CAAC,sBAAD,CAP8B;AAQzCC,EAAAA,QAAQ,EAAE,UAR+B;AASzCC,EAAAA,IAAI,EAAE,IATmC;AAUzCC,EAAAA,OAAO,EAAEjB;AAVgC,CAApC;;AAaA,MAAMkB,aAA+B,GAAG,EAC7C,GAAGX,mBAD0C;AAE7CY,EAAAA,KAF6C;AAG7CC,EAAAA,aAH6C;AAI7CC,EAAAA;AAJ6C,CAAxC;;;AAOP,eAAeF,KAAf,CAAqBG,WAArB,EAAkCL,OAAlC,EAA2C;AACzC,SAAOG,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCL,OAAxC,CAApB;AACD;;AAED,SAASG,aAAT,CAAuBJ,IAAvB,EAA6BC,OAA7B,EAAsC;AAEpCA,EAAAA,OAAO,GAAG,EAAC,GAAGjB,8BAAJ;AAAoC,OAAGiB;AAAvC,GAAV;AACAA,EAAAA,OAAO,CAACd,IAAR,GAAe,EAAC,GAAGH,8BAA8B,CAACC,OAAnC;AAA4C,OAAGgB,OAAO,CAAChB;AAAvD,GAAf;AACAgB,EAAAA,OAAO,CAACZ,GAAR,GAAcY,OAAO,CAACZ,GAAR,IAAe,EAA7B;AACA,QAAMF,IAAI,GAAG,wBAAca,IAAd,EAAoBC,OAApB,CAAb;;AACA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAO,0BAAgBH,IAAhB,CAAP;;AACF;AACE,aAAOA,IAAP;AAJJ;AAMD;;AAED,SAASkB,cAAT,CAAwBI,aAAxB,EAAuCR,OAAvC,EAAoE;AAElEA,EAAAA,OAAO,GAAG,EAAC,GAAGjB,8BAAJ;AAAoC,OAAGiB;AAAvC,GAAV;AACAA,EAAAA,OAAO,CAACd,IAAR,GAAe,EAAC,GAAGH,8BAA8B,CAACC,OAAnC;AAA4C,OAAGgB,OAAO,CAAChB;AAAvD,GAAf;AAEA,QAAMyB,eAAe,GAAG,iCAAmBD,aAAnB,EAAkCR,OAAlC,CAAxB;;AAEA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAOqB,0BAA0B,CAACD,eAAD,CAAjC;;AACF;AACE,aAAOA,eAAP;AAJJ;AAMD;;AAED,gBAAgBC,0BAAhB,CAA2CD,eAA3C,EAA4D;AAC1D,aAAW,MAAME,KAAjB,IAA0BF,eAA1B,EAA2C;AACzCE,IAAAA,KAAK,CAACC,IAAN,GAAa,0BAAgBD,KAAK,CAACC,IAAtB,CAAb;AACA,UAAMD,KAAN;AACD;AACF","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {JSONLoaderOptions} from './json-loader';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type GeoJSONLoaderOptions = JSONLoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_GEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n json: {\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n};\n\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader: Loader = {\n name: 'GeoJSON',\n id: 'geojson',\n module: 'geojson',\n version: VERSION,\n worker: true,\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n category: 'geometry',\n text: true,\n options: DEFAULT_GEOJSON_LOADER_OPTIONS\n};\n\nexport const GeoJSONLoader: LoaderWithParser = {\n ...GeoJSONWorkerLoader,\n parse,\n parseTextSync,\n parseInBatches\n};\n\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n options.gis = options.gis || {};\n const json = parseJSONSync(text, options);\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(json);\n default:\n return json;\n }\n}\n\nfunction parseInBatches(asyncIterator, options): AsyncIterable<any> {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\n }\n}\n\nasync function* makeBinaryGeometryIterator(geojsonIterator) {\n for await (const batch of geojsonIterator) {\n batch.data = geojsonToBinary(batch.data);\n yield batch;\n }\n}\n"],"file":"geojson-loader.js"}
1
+ {"version":3,"sources":["../../src/geojson-loader.ts"],"names":["VERSION","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","shape","json","jsonpaths","gis","format","GeoJSONWorkerLoader","name","id","module","version","worker","extensions","mimeTypes","category","text","options","GeoJSONLoader","parse","parseTextSync","parseInBatches","arrayBuffer","TextDecoder","decode","asyncIterator","geojsonIterator","makeBinaryGeometryIterator","batch","data"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAEA;;AACA;;AACA;;;;;;AAIA,IAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAWA,IAAMC,8BAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE;AADA,GAD4B;AAIrCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,SAAS,EAAE,CAAC,GAAD,EAAM,YAAN;AADP,GAJ+B;AAOrCC,EAAAA,GAAG,EAAE;AACHC,IAAAA,MAAM,EAAE;AADL;AAPgC,CAAvC;AAeO,IAAMC,mBAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,SADmC;AAEzCC,EAAAA,EAAE,EAAE,SAFqC;AAGzCC,EAAAA,MAAM,EAAE,SAHiC;AAIzCC,EAAAA,OAAO,EAAEZ,OAJgC;AAKzCa,EAAAA,MAAM,EAAE,IALiC;AAMzCC,EAAAA,UAAU,EAAE,CAAC,SAAD,CAN6B;AAOzCC,EAAAA,SAAS,EAAE,CAAC,sBAAD,CAP8B;AAQzCC,EAAAA,QAAQ,EAAE,UAR+B;AASzCC,EAAAA,IAAI,EAAE,IATmC;AAUzCC,EAAAA,OAAO,EAAEjB;AAVgC,CAApC;;;AAaA,IAAMkB,aAA+B,mCACvCX,mBADuC;AAE1CY,EAAAA,KAAK,EAALA,KAF0C;AAG1CC,EAAAA,aAAa,EAAbA,aAH0C;AAI1CC,EAAAA,cAAc,EAAdA;AAJ0C,EAArC;;;;SAOQF,K;;;;;qEAAf,kBAAqBG,WAArB,EAAkCL,OAAlC;AAAA;AAAA;AAAA;AAAA;AAAA,8CACSG,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCL,OAAxC,CADtB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAIA,SAASG,aAAT,CAAuBJ,IAAvB,EAA6BC,OAA7B,EAAsC;AAEpCA,EAAAA,OAAO,mCAAOjB,8BAAP,GAA0CiB,OAA1C,CAAP;AACAA,EAAAA,OAAO,CAACd,IAAR,mCAAmBH,8BAA8B,CAACC,OAAlD,GAA8DgB,OAAO,CAAChB,OAAtE;AACAgB,EAAAA,OAAO,CAACZ,GAAR,GAAcY,OAAO,CAACZ,GAAR,IAAe,EAA7B;AACA,MAAMF,IAAI,GAAG,wBAAca,IAAd,EAAoBC,OAApB,CAAb;;AACA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAO,0BAAgBH,IAAhB,CAAP;;AACF;AACE,aAAOA,IAAP;AAJJ;AAMD;;AAED,SAASkB,cAAT,CAAwBI,aAAxB,EAAuCR,OAAvC,EAAoE;AAElEA,EAAAA,OAAO,mCAAOjB,8BAAP,GAA0CiB,OAA1C,CAAP;AACAA,EAAAA,OAAO,CAACd,IAAR,mCAAmBH,8BAA8B,CAACC,OAAlD,GAA8DgB,OAAO,CAAChB,OAAtE;AAEA,MAAMyB,eAAe,GAAG,iCAAmBD,aAAnB,EAAkCR,OAAlC,CAAxB;;AAEA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAOqB,0BAA0B,CAACD,eAAD,CAAjC;;AACF;AACE,aAAOA,eAAP;AAJJ;AAMD;;SAEeC,0B;;;;;4FAAhB,iBAA2CD,eAA3C;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qDAC4BA,eAD5B;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AACmBE,YAAAA,KADnB;AAEIA,YAAAA,KAAK,CAACC,IAAN,GAAa,0BAAgBD,KAAK,CAACC,IAAtB,CAAb;AAFJ;AAGI,mBAAMD,KAAN;;AAHJ;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;;AAAA;;AAAA;AAAA;;AAAA;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {JSONLoaderOptions} from './json-loader';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type GeoJSONLoaderOptions = JSONLoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_GEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n json: {\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n};\n\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader: Loader = {\n name: 'GeoJSON',\n id: 'geojson',\n module: 'geojson',\n version: VERSION,\n worker: true,\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n category: 'geometry',\n text: true,\n options: DEFAULT_GEOJSON_LOADER_OPTIONS\n};\n\nexport const GeoJSONLoader: LoaderWithParser = {\n ...GeoJSONWorkerLoader,\n parse,\n parseTextSync,\n parseInBatches\n};\n\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n options.gis = options.gis || {};\n const json = parseJSONSync(text, options);\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(json);\n default:\n return json;\n }\n}\n\nfunction parseInBatches(asyncIterator, options): AsyncIterable<any> {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\n }\n}\n\nasync function* makeBinaryGeometryIterator(geojsonIterator) {\n for await (const batch of geojsonIterator) {\n batch.data = geojsonToBinary(batch.data);\n yield batch;\n }\n}\n"],"file":"geojson-loader.js"}
package/dist/es5/index.js CHANGED
@@ -7,31 +7,31 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  Object.defineProperty(exports, "JSONLoader", {
9
9
  enumerable: true,
10
- get: function () {
10
+ get: function get() {
11
11
  return _jsonLoader.JSONLoader;
12
12
  }
13
13
  });
14
14
  Object.defineProperty(exports, "_GeoJSONLoader", {
15
15
  enumerable: true,
16
- get: function () {
16
+ get: function get() {
17
17
  return _geojsonLoader.GeoJSONLoader;
18
18
  }
19
19
  });
20
20
  Object.defineProperty(exports, "_GeoJSONWorkerLoader", {
21
21
  enumerable: true,
22
- get: function () {
22
+ get: function get() {
23
23
  return _geojsonLoader.GeoJSONWorkerLoader;
24
24
  }
25
25
  });
26
26
  Object.defineProperty(exports, "_JSONPath", {
27
27
  enumerable: true,
28
- get: function () {
28
+ get: function get() {
29
29
  return _jsonpath.default;
30
30
  }
31
31
  });
32
32
  Object.defineProperty(exports, "_ClarinetParser", {
33
33
  enumerable: true,
34
- get: function () {
34
+ get: function get() {
35
35
  return _clarinet.default;
36
36
  }
37
37
  });
@@ -7,19 +7,29 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports.JSONLoader = void 0;
9
9
 
10
+ var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
11
+
12
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
+
14
+ var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
15
+
10
16
  var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
11
17
 
12
18
  var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
13
19
 
14
- const VERSION = typeof "3.0.13" !== 'undefined' ? "3.0.13" : 'latest';
15
- const DEFAULT_JSON_LOADER_OPTIONS = {
20
+ 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; }
21
+
22
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
23
+
24
+ var VERSION = typeof "3.0.14" !== 'undefined' ? "3.0.14" : 'latest';
25
+ var DEFAULT_JSON_LOADER_OPTIONS = {
16
26
  json: {
17
27
  shape: 'row-table',
18
28
  table: false,
19
29
  jsonpaths: []
20
30
  }
21
31
  };
22
- const JSONLoader = {
32
+ var JSONLoader = {
23
33
  name: 'JSON',
24
34
  id: 'json',
25
35
  module: 'json',
@@ -28,32 +38,48 @@ const JSONLoader = {
28
38
  mimeTypes: ['application/json'],
29
39
  category: 'table',
30
40
  text: true,
31
- parse,
32
- parseTextSync,
33
- parseInBatches,
41
+ parse: parse,
42
+ parseTextSync: parseTextSync,
43
+ parseInBatches: parseInBatches,
34
44
  options: DEFAULT_JSON_LOADER_OPTIONS
35
45
  };
36
46
  exports.JSONLoader = JSONLoader;
37
47
 
38
- async function parse(arrayBuffer, options) {
39
- return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
48
+ function parse(_x, _x2) {
49
+ return _parse.apply(this, arguments);
50
+ }
51
+
52
+ function _parse() {
53
+ _parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer, options) {
54
+ return _regenerator.default.wrap(function _callee$(_context) {
55
+ while (1) {
56
+ switch (_context.prev = _context.next) {
57
+ case 0:
58
+ return _context.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer), options));
59
+
60
+ case 1:
61
+ case "end":
62
+ return _context.stop();
63
+ }
64
+ }
65
+ }, _callee);
66
+ }));
67
+ return _parse.apply(this, arguments);
40
68
  }
41
69
 
42
70
  function parseTextSync(text, options) {
43
- const jsonOptions = { ...options,
44
- json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
45
- ...(options === null || options === void 0 ? void 0 : options.json)
46
- }
47
- };
71
+ var jsonOptions = _objectSpread(_objectSpread({}, options), {}, {
72
+ json: _objectSpread(_objectSpread({}, DEFAULT_JSON_LOADER_OPTIONS.json), options === null || options === void 0 ? void 0 : options.json)
73
+ });
74
+
48
75
  return (0, _parseJson.default)(text, jsonOptions);
49
76
  }
50
77
 
51
78
  function parseInBatches(asyncIterator, options) {
52
- const jsonOptions = { ...options,
53
- json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
54
- ...(options === null || options === void 0 ? void 0 : options.json)
55
- }
56
- };
79
+ var jsonOptions = _objectSpread(_objectSpread({}, options), {}, {
80
+ json: _objectSpread(_objectSpread({}, DEFAULT_JSON_LOADER_OPTIONS.json), options === null || options === void 0 ? void 0 : options.json)
81
+ });
82
+
57
83
  return (0, _parseJsonInBatches.default)(asyncIterator, jsonOptions);
58
84
  }
59
85
  //# sourceMappingURL=json-loader.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","DEFAULT_JSON_LOADER_OPTIONS","json","shape","table","jsonpaths","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","jsonOptions","asyncIterator"],"mappings":";;;;;;;;;AAEA;;AACA;;AAIA,MAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAcA,MAAMC,2BAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,WADH;AAEJC,IAAAA,KAAK,EAAE,KAFH;AAGJC,IAAAA,SAAS,EAAE;AAHP;AAD4B,CAApC;AASO,MAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEV,OAJiC;AAK1CW,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CAN+B;AAoB1CC,EAAAA,QAAQ,EAAE,OApBgC;AAqB1CC,EAAAA,IAAI,EAAE,IArBoC;AAsB1CC,EAAAA,KAtB0C;AAuB1CC,EAAAA,aAvB0C;AAwB1CC,EAAAA,cAxB0C;AAyB1CC,EAAAA,OAAO,EAAEjB;AAzBiC,CAArC;;;AA4BP,eAAec,KAAf,CAAqBI,WAArB,EAA+CD,OAA/C,EAA4E;AAC1E,SAAOF,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCD,OAAxC,CAApB;AACD;;AAED,SAASF,aAAT,CAAuBF,IAAvB,EAAqCI,OAArC,EAAkE;AAChE,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAO,wBAAcY,IAAd,EAAoBQ,WAApB,CAAP;AACD;;AAED,SAASL,cAAT,CACEM,aADF,EAEEL,OAFF,EAGwB;AACtB,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAO,iCAAmBqB,aAAnB,EAAkCD,WAAlC,CAAP;AACD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * @param table -\n * @param jsonpaths -\n */\nexport type JSONLoaderOptions = LoaderOptions & {\n json?: {\n shape?: 'row-table';\n table?: false;\n jsonpaths?: string[];\n };\n};\n\nconst DEFAULT_JSON_LOADER_OPTIONS = {\n json: {\n shape: 'row-table',\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n};\n\nexport const JSONLoader: LoaderWithParser = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n // TODO - support various line based JSON formats\n /*\n extensions: {\n json: null,\n jsonl: {stream: true},\n ndjson: {stream: true}\n },\n mimeTypes: {\n 'application/json': null,\n 'application/json-seq': {stream: true},\n 'application/x-ndjson': {stream: true}\n },\n */\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: DEFAULT_JSON_LOADER_OPTIONS\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: JSONLoaderOptions) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text: string, options?: JSONLoaderOptions) {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONSync(text, jsonOptions as JSONLoaderOptions);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONInBatches(asyncIterator, jsonOptions as JSONLoaderOptions);\n}\n"],"file":"json-loader.js"}
1
+ {"version":3,"sources":["../../src/json-loader.ts"],"names":["VERSION","DEFAULT_JSON_LOADER_OPTIONS","json","shape","table","jsonpaths","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","jsonOptions","asyncIterator"],"mappings":";;;;;;;;;;;;;;;AAEA;;AACA;;;;;;AAIA,IAAMA,OAAO,GAAG,oBAAuB,WAAvB,cAAmD,QAAnE;AAcA,IAAMC,2BAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,WADH;AAEJC,IAAAA,KAAK,EAAE,KAFH;AAGJC,IAAAA,SAAS,EAAE;AAHP;AAD4B,CAApC;AASO,IAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEV,OAJiC;AAK1CW,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CAN+B;AAoB1CC,EAAAA,QAAQ,EAAE,OApBgC;AAqB1CC,EAAAA,IAAI,EAAE,IArBoC;AAsB1CC,EAAAA,KAAK,EAALA,KAtB0C;AAuB1CC,EAAAA,aAAa,EAAbA,aAvB0C;AAwB1CC,EAAAA,cAAc,EAAdA,cAxB0C;AAyB1CC,EAAAA,OAAO,EAAEjB;AAzBiC,CAArC;;;SA4BQc,K;;;;;qEAAf,iBAAqBI,WAArB,EAA+CD,OAA/C;AAAA;AAAA;AAAA;AAAA;AAAA,6CACSF,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCD,OAAxC,CADtB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAIA,SAASF,aAAT,CAAuBF,IAAvB,EAAqCI,OAArC,EAAkE;AAChE,MAAMI,WAAW,mCAAOJ,OAAP;AAAgBhB,IAAAA,IAAI,kCAAMD,2BAA2B,CAACC,IAAlC,GAA2CgB,OAA3C,aAA2CA,OAA3C,uBAA2CA,OAAO,CAAEhB,IAApD;AAApB,IAAjB;;AACA,SAAO,wBAAcY,IAAd,EAAoBQ,WAApB,CAAP;AACD;;AAED,SAASL,cAAT,CACEM,aADF,EAEEL,OAFF,EAGwB;AACtB,MAAMI,WAAW,mCAAOJ,OAAP;AAAgBhB,IAAAA,IAAI,kCAAMD,2BAA2B,CAACC,IAAlC,GAA2CgB,OAA3C,aAA2CA,OAA3C,uBAA2CA,OAAO,CAAEhB,IAApD;AAApB,IAAjB;;AACA,SAAO,iCAAmBqB,aAAnB,EAAkCD,WAAlC,CAAP;AACD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * @param table -\n * @param jsonpaths -\n */\nexport type JSONLoaderOptions = LoaderOptions & {\n json?: {\n shape?: 'row-table';\n table?: false;\n jsonpaths?: string[];\n };\n};\n\nconst DEFAULT_JSON_LOADER_OPTIONS = {\n json: {\n shape: 'row-table',\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n};\n\nexport const JSONLoader: LoaderWithParser = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n // TODO - support various line based JSON formats\n /*\n extensions: {\n json: null,\n jsonl: {stream: true},\n ndjson: {stream: true}\n },\n mimeTypes: {\n 'application/json': null,\n 'application/json-seq': {stream: true},\n 'application/x-ndjson': {stream: true}\n },\n */\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: DEFAULT_JSON_LOADER_OPTIONS\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: JSONLoaderOptions) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text: string, options?: JSONLoaderOptions) {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONSync(text, jsonOptions as JSONLoaderOptions);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONInBatches(asyncIterator, jsonOptions as JSONLoaderOptions);\n}\n"],"file":"json-loader.js"}