@loaders.gl/json 3.1.0-alpha.4 → 3.1.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.d.ts +1 -0
- package/dist/dist.min.js +1 -1
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/geojson-loader.js +29 -143
- package/dist/es5/geojson-loader.js.map +1 -1
- package/dist/es5/index.js +6 -6
- package/dist/es5/json-loader.js +18 -44
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/clarinet/clarinet.js +373 -393
- package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
- package/dist/es5/lib/jsonpath/jsonpath.js +54 -101
- package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -1
- package/dist/es5/lib/parse-json-in-batches.js +78 -237
- package/dist/es5/lib/parse-json-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-json.js +4 -9
- package/dist/es5/lib/parse-json.js.map +1 -1
- package/dist/es5/lib/parse-ndjson-in-batches.js +31 -143
- package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-ndjson.js +2 -2
- package/dist/es5/lib/parse-ndjson.js.map +1 -1
- package/dist/es5/lib/parser/json-parser.js +112 -133
- package/dist/es5/lib/parser/json-parser.js.map +1 -1
- package/dist/es5/lib/parser/streaming-json-parser.js +65 -125
- package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
- package/dist/es5/ndjson-loader.js +7 -29
- package/dist/es5/ndjson-loader.js.map +1 -1
- package/dist/esm/geojson-loader.js +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/lib/parse-ndjson-in-batches.js +1 -1
- package/dist/esm/lib/parse-ndjson-in-batches.js.map +1 -1
- package/dist/esm/lib/parse-ndjson.js +1 -1
- package/dist/esm/lib/parse-ndjson.js.map +1 -1
- package/dist/esm/ndjson-loader.js +1 -1
- package/dist/geojson-loader.d.ts +15 -0
- package/dist/geojson-worker.js +1 -1
- package/dist/geojson-worker.js.map +1 -1
- package/dist/index.d.ts +7 -0
- package/dist/json-loader.d.ts +13 -0
- package/dist/jsonl-loader.d.ts +0 -0
- package/dist/lib/clarinet/clarinet.d.ts +40 -0
- package/dist/lib/jsonpath/jsonpath.d.ts +31 -0
- package/dist/lib/parse-json-in-batches.d.ts +3 -0
- package/dist/lib/parse-json.d.ts +2 -0
- package/dist/lib/parse-ndjson-in-batches.d.ts +3 -0
- package/dist/lib/parse-ndjson.d.ts +1 -0
- package/dist/lib/parser/json-parser.d.ts +17 -0
- package/dist/lib/parser/streaming-json-parser.d.ts +37 -0
- package/dist/ndjson-loader.d.ts +2 -0
- package/dist/workers/geojson-worker.d.ts +1 -0
- package/package.json +7 -6
package/dist/bundle.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
declare const moduleExports: any;
|
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 n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,s),n.l=!0,n.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 n in t)s.d(o,n,function(e){return t[e]}.bind(null,n));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){const o=s(3);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,o)},,,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 n(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 ht})),s.d(e,"NDJSONLoader",(function(){return lt})),s.d(e,"_GeoJSONLoader",(function(){return _t})),s.d(e,"_GeoJSONWorkerLoader",(function(){return Ot})),s.d(e,"_JSONPath",(function(){return st})),s.d(e,"_ClarinetParser",(function(){return X}));class i{constructor(t,e){if(n(this,"schema",void 0),n(this,"options",void 0),n(this,"length",0),n(this,"rows",null),n(this,"cursor",0),n(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 i;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")}}}async function*d(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})}l(p,"ArrowBatch",void 0);const f=Number.MAX_SAFE_INTEGER,g="debug"==={}.CDEBUG,y={textNode:void 0,numberNode:""};let b=0;const w={BEGIN:b++,VALUE:b++,OPEN_OBJECT:b++,CLOSE_OBJECT:b++,OPEN_ARRAY:b++,CLOSE_ARRAY:b++,TEXT_ESCAPE:b++,STRING:b++,BACKSLASH:b++,END:b++,OPEN_KEY:b++,CLOSE_KEY:b++,TRUE:b++,TRUE2:b++,TRUE3:b++,FALSE:b++,FALSE2:b++,FALSE3:b++,FALSE4:b++,NULL:b++,NULL2:b++,NULL3:b++,NUMBER_DECIMAL_POINT:b++,NUMBER_DIGIT:b++};for(var m in w)w[w[m]]=m;b=w;const A=9,j=10,P=13,v=32,E=34,S=43,O=44,_=45,N=46,C=48,L=57,I=58,R=69,B=91,k=92,x=93,U=97,T=98,F=101,J=102,M=108,z=110,D=114,Y=115,G=116,V=117,K=123,$=125;var q=/[\\"\n]/g;class X{constructor(t={}){this._initialize(t)}_initialize(t){this._clearBuffers(this),this.bufferCheckPosition=f,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=b.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),H(this,"onready")}_clearBuffers(){for(var t in y)this[t]=y[t]}end(){return this.state===b.VALUE&&0===this.depth||tt(this,"Unexpected end"),Q(this),this.c="",this.closed=!0,H(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 tt(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(g&&console.log("write -> ["+t+"]");s&&(o=s,this.c=s=t.charCodeAt(e++),o!==s?this.p=o:o=this.p,s);)switch(g&&console.log(e,s,w[this.state]),this.position++,s===j?(this.line++,this.column=0):this.column++,this.state){case b.BEGIN:s===K?this.state=b.OPEN_OBJECT:s===B?this.state=b.OPEN_ARRAY:et(s)||tt(this,"Non-whitespace before {[.");continue;case b.OPEN_KEY:case b.OPEN_OBJECT:if(et(s))continue;if(this.state===b.OPEN_KEY)this.stack.push(b.CLOSE_KEY);else{if(s===$){H(this,"onopenobject"),this.depth++,H(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}this.stack.push(b.CLOSE_OBJECT)}s===E?this.state=b.STRING:tt(this,'Malformed object key should start with "');continue;case b.CLOSE_KEY:case b.CLOSE_OBJECT:if(et(s))continue;this.state,b.CLOSE_KEY;s===I?(this.state===b.CLOSE_OBJECT?(this.stack.push(b.CLOSE_OBJECT),Q(this,"onopenobject"),this.depth++):Q(this,"onkey"),this.state=b.VALUE):s===$?(W(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE):s===O?(this.state===b.CLOSE_OBJECT&&this.stack.push(b.CLOSE_OBJECT),Q(this),this.state=b.OPEN_KEY):tt(this,"Bad object");continue;case b.OPEN_ARRAY:case b.VALUE:if(et(s))continue;if(this.state===b.OPEN_ARRAY){if(H(this,"onopenarray"),this.depth++,this.state=b.VALUE,s===x){H(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}this.stack.push(b.CLOSE_ARRAY)}s===E?this.state=b.STRING:s===K?this.state=b.OPEN_OBJECT:s===B?this.state=b.OPEN_ARRAY:s===G?this.state=b.TRUE:s===J?this.state=b.FALSE:s===z?this.state=b.NULL:s===_?this.numberNode+="-":C<=s&&s<=L?(this.numberNode+=String.fromCharCode(s),this.state=b.NUMBER_DIGIT):tt(this,"Bad value");continue;case b.CLOSE_ARRAY:if(s===O)this.stack.push(b.CLOSE_ARRAY),Q(this,"onvalue"),this.state=b.VALUE;else if(s===x)W(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;else{if(et(s))continue;tt(this,"Bad array")}continue;case b.STRING:void 0===this.textNode&&(this.textNode="");var n=e-1,i=this.slashed,r=this.unicodeI;t:for(;;){for(g&&console.log(e,s,w[this.state],i);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,n=e-1):r++,!s)break t;if(s===E&&!i){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}if(s===k&&!i&&(i=!0,this.textNode+=t.substring(n,e-1),this.position+=e-1-n,s=t.charCodeAt(e++),this.position++,!s))break;if(i){if(i=!1,s===z?this.textNode+="\n":s===D?this.textNode+="\r":s===G?this.textNode+="\t":s===J?this.textNode+="\f":s===T?this.textNode+="\b":s===V?(r=1,this.unicodeS=""):this.textNode+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,n=e-1,s)continue;break}q.lastIndex=e;var a=q.exec(t);if(null===a){e=t.length+1,this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}if(e=a.index+1,!(s=t.charCodeAt(a.index))){this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}}this.slashed=i,this.unicodeI=r;continue;case b.TRUE:s===D?this.state=b.TRUE2:tt(this,"Invalid true started with t"+s);continue;case b.TRUE2:s===V?this.state=b.TRUE3:tt(this,"Invalid true started with tr"+s);continue;case b.TRUE3:s===F?(H(this,"onvalue",!0),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid true started with tru"+s);continue;case b.FALSE:s===U?this.state=b.FALSE2:tt(this,"Invalid false started with f"+s);continue;case b.FALSE2:s===M?this.state=b.FALSE3:tt(this,"Invalid false started with fa"+s);continue;case b.FALSE3:s===Y?this.state=b.FALSE4:tt(this,"Invalid false started with fal"+s);continue;case b.FALSE4:s===F?(H(this,"onvalue",!1),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid false started with fals"+s);continue;case b.NULL:s===V?this.state=b.NULL2:tt(this,"Invalid null started with n"+s);continue;case b.NULL2:s===M?this.state=b.NULL3:tt(this,"Invalid null started with nu"+s);continue;case b.NULL3:s===M?(H(this,"onvalue",null),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid null started with nul"+s);continue;case b.NUMBER_DECIMAL_POINT:s===N?(this.numberNode+=".",this.state=b.NUMBER_DIGIT):tt(this,"Leading zero not followed by .");continue;case b.NUMBER_DIGIT:C<=s&&s<=L?this.numberNode+=String.fromCharCode(s):s===N?(-1!==this.numberNode.indexOf(".")&&tt(this,"Invalid number has two dots"),this.numberNode+="."):s===F||s===R?(-1===this.numberNode.indexOf("e")&&-1===this.numberNode.indexOf("E")||tt(this,"Invalid number has two exponential"),this.numberNode+="e"):s===S||s===_?(o!==F&&o!==R&&tt(this,"Invalid symbol in number"),this.numberNode+=String.fromCharCode(s)):(Z(this),e--,this.state=this.stack.pop()||b.VALUE);continue;default:tt(this,"Unknown state: "+this.state)}return this.position>=this.bufferCheckPosition&&function(t){const e=Math.max(f,10);let s=0;for(var o in y){var n=void 0===t[o]?0:t[o].length;if(n>e)switch(o){case"text":closeText(t);break;default:tt(t,"Max buffer length exceeded: "+o)}s=Math.max(s,n)}t.bufferCheckPosition=f-s+t.position}(this),H(this,"onchunkparsed"),this}}function H(t,e,s){g&&console.log("-- emit",e,s),t[e]&&t[e](s,t)}function W(t,e,s){Q(t),H(t,e,s)}function Q(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&&H(t,e||"onvalue",t.textNode),t.textNode=void 0}function Z(t){t.numberNode&&H(t,"onvalue",parseFloat(t.numberNode)),t.numberNode=""}function tt(t,e){return Q(t),e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c,e=new Error(e),t.error=e,H(t,"onerror",e),t}function et(t){return t===P||t===j||t===v||t===A}class st{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 st)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 st(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 ot(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function nt(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(){ot(this,"jsonpath",void 0),ot(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 st}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 X({onready:()=>{this.jsonpath=new st,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(),nt(this,"jsonPaths",void 0),nt(this,"streamingJsonPath",null),nt(this,"streamingArray",null),nt(this,"topLevelObject",null);const e=t.jsonpaths||[];this.jsonPaths=e.map(t=>new st(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*rt(t,e){var s;const o=d(t),{metadata:n}=e,{jsonpaths:i}=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:i});for await(const t of o){const e=c.write(t),s=e.length>0&&c.getStreamingJsonPathAsString();if(e.length>0&&r){if(n){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),n){const t={shape:a,batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0};yield t}}const at={json:{shape:"row-table",table:!1,jsonpaths:[]}},ht={name:"JSON",id:"json",module:"json",version:"3.1.0-alpha.4",extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,parse:async function(t,e){return ct((new TextDecoder).decode(t),e)},parseTextSync:ct,parseInBatches:function(t,e){const s={...e,json:{...at.json,...null==e?void 0:e.json}};return rt(t,s)},options:at};function ct(t,e){return o(t,{...e,json:{...at.json,...null==e?void 0:e.json}})}const lt={name:"NDJSON",id:"ndjson",module:"json",version:"3.1.0-alpha.4",extensions:["ndjson"],mimeTypes:["application/x-ndjson"],category:"table",text:!0,parse:async function(t){return ut((new TextDecoder).decode(t))},parseTextSync:ut,parseInBatches:function(t,e){return async function*(t,e){const s=async function*(t){let e=1;for await(const s of t)yield{counter:e,line:s},e++}(async function*(t){let e="";for await(const s of t){let t;for(e+=s;(t=e.indexOf("\n"))>=0;){const s=e.slice(0,t+1);e=e.slice(t+1),yield s}}e.length>0&&(yield e)}(d(t))),o=new p(null,{...e,shape:"row-table"});for await(const{counter:t,line:e}of s)try{const t=JSON.parse(e);o.addRow(t),o.chunkComplete(e);const s=o.getFullBatch();s&&(yield s)}catch(e){throw new Error("NDJSONLoader: failed to parse JSON on line "+t)}const n=o.getFinalBatch();n&&(yield n)}(t,e)},options:{}};function ut(t){return t.trim().split("\n").map((t,e)=>{try{return JSON.parse(t)}catch(t){throw new Error("NDJSONLoader: failed to parse JSON on line "+(e+1))}})}function pt(t,e={}){const s=dt(t);return ft(t,s,{coordLength:e.coordLength||s.coordLength,numericPropKeys:e.numericPropKeys||s.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array})}function dt(t){let e=0,s=0,o=0,n=0,i=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":i++,o+=t.coordinates.length,n++;for(const e of t.coordinates)l.add(e.length);break;case"MultiLineString":i++;for(const e of t.coordinates){o+=e.length,n++;for(const t of e)l.add(t.length)}break;case"Polygon":c++,a++,h+=t.coordinates.length,r+=Et(t.coordinates).length;for(const e of Et(t.coordinates))l.add(e.length);break;case"MultiPolygon":c++;for(const e of t.coordinates){a++,h+=e.length,r+=Et(e).length;for(const t of Et(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:n,lineFeaturesCount:i,polygonPositionsCount:r,polygonObjectsCount:a,polygonRingsCount:h,polygonFeaturesCount:c,numericPropKeys:Object.keys(u).filter(t=>u[t])}}function ft(t,e,s){const{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:i,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:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:Array(),fields:Array()},b={positions:new f(i*p),pathIndices:i>65535?new Uint32Array(r+1):new Uint16Array(r+1),globalFeatureIds:new g(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),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]=i,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":gt(t.coordinates,y,m,p,s),y.properties.push(Pt(s,d)),m.pointFeature++;break;case"MultiPoint":yt(t.coordinates,y,m,p,s),y.properties.push(Pt(s,d)),m.pointFeature++;break;case"LineString":bt(t.coordinates,b,m,p,s),b.properties.push(Pt(s,d)),m.lineFeature++;break;case"MultiLineString":wt(t.coordinates,b,m,p,s),b.properties.push(Pt(s,d)),m.lineFeature++;break;case"Polygon":mt(t.coordinates,w,m,p,s),w.properties.push(Pt(s,d)),m.polygonFeature++;break;case"MultiPolygon":At(t.coordinates,w,m,p,s),w.properties.push(Pt(s,d)),m.polygonFeature++;break;default:throw new Error("Invalid geometry type")}m.feature++}return function(t,e,s,o){const n={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 n)for(const e in n[t].numericProps)n[t].numericProps[e]={value:n[t].numericProps[e],size:1};return n}(y,b,w,p)}function gt(t,e,s,o,n){e.positions.set(t,s.pointPosition*o),e.globalFeatureIds[s.pointPosition]=s.feature,e.featureIds[s.pointPosition]=s.pointFeature,jt(e,n,s.pointPosition,1),s.pointPosition++}function yt(t,e,s,o,n){for(const i of t)gt(i,e,s,o,n)}function bt(t,e,s,o,n){e.pathIndices[s.linePath]=s.linePosition,s.linePath++,vt(e.positions,t,s.linePosition,o);const i=t.length;jt(e,n,s.linePosition,i),e.globalFeatureIds.set(new Uint32Array(i).fill(s.feature),s.linePosition),e.featureIds.set(new Uint32Array(i).fill(s.lineFeature),s.linePosition),s.linePosition+=i}function wt(t,e,s,o,n){for(const i of t)bt(i,e,s,o,n)}function mt(t,e,s,o,n){e.polygonIndices[s.polygonObject]=s.polygonPosition,s.polygonObject++;for(const i of t){e.primitivePolygonIndices[s.polygonRing]=s.polygonPosition,s.polygonRing++,vt(e.positions,i,s.polygonPosition,o);const t=i.length;jt(e,n,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 At(t,e,s,o,n){for(const i of t)mt(i,e,s,o,n)}function jt(t,e,s,o){for(const n in t.numericProps)n in e&&t.numericProps[n].set(new Array(o).fill(e[n]),s)}function Pt(t,e){const s={};for(const o in t)e.includes(o)||(s[o]=t[o]);return s}function vt(t,e,s,o){let n=s*o;for(const s of e)t.set(s,n),n+=o}function Et(t){return[].concat(...t)}const St={geojson:{shape:"object-row-table"},json:{jsonpaths:["$","$.features"]},gis:{format:"geojson"}},Ot={name:"GeoJSON",id:"geojson",module:"geojson",version:"3.1.0-alpha.4",worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:St},_t={...Ot,parse:async function(t,e){return Nt((new TextDecoder).decode(t),e)},parseTextSync:Nt,parseInBatches:function(t,e){(e={...St,...e}).json={...St.geojson,...e.geojson};const s=rt(t,e);switch(e.gis.format){case"binary":return async function*(t){for await(const e of t)e.data=pt(e.data),yield e}(s);default:return s}}};function Nt(t,e){(e={...St,...e}).json={...St.geojson,...e.geojson},e.gis=e.gis||{};const s=o(t,e);switch(e.gis.format){case"binary":return pt(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 n=e[o]={i:o,l:!1,exports:{}};return t[o].call(n.exports,n,n.exports,s),n.l=!0,n.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 n in t)s.d(o,n,function(e){return t[e]}.bind(null,n));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){const o=s(3);globalThis.loaders=globalThis.loaders||{},t.exports=Object.assign(globalThis.loaders,o)},,,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 n(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 ht})),s.d(e,"NDJSONLoader",(function(){return lt})),s.d(e,"_GeoJSONLoader",(function(){return _t})),s.d(e,"_GeoJSONWorkerLoader",(function(){return Ot})),s.d(e,"_JSONPath",(function(){return st})),s.d(e,"_ClarinetParser",(function(){return X}));class i{constructor(t,e){if(n(this,"schema",void 0),n(this,"options",void 0),n(this,"length",0),n(this,"rows",null),n(this,"cursor",0),n(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 i;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")}}}async function*d(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})}l(p,"ArrowBatch",void 0);const f=Number.MAX_SAFE_INTEGER,g="debug"==={}.CDEBUG,y={textNode:void 0,numberNode:""};let b=0;const w={BEGIN:b++,VALUE:b++,OPEN_OBJECT:b++,CLOSE_OBJECT:b++,OPEN_ARRAY:b++,CLOSE_ARRAY:b++,TEXT_ESCAPE:b++,STRING:b++,BACKSLASH:b++,END:b++,OPEN_KEY:b++,CLOSE_KEY:b++,TRUE:b++,TRUE2:b++,TRUE3:b++,FALSE:b++,FALSE2:b++,FALSE3:b++,FALSE4:b++,NULL:b++,NULL2:b++,NULL3:b++,NUMBER_DECIMAL_POINT:b++,NUMBER_DIGIT:b++};for(var m in w)w[w[m]]=m;b=w;const A=9,j=10,P=13,v=32,E=34,S=43,O=44,_=45,N=46,C=48,L=57,I=58,R=69,B=91,k=92,x=93,U=97,T=98,F=101,J=102,M=108,z=110,D=114,Y=115,G=116,V=117,K=123,$=125;var q=/[\\"\n]/g;class X{constructor(t={}){this._initialize(t)}_initialize(t){this._clearBuffers(this),this.bufferCheckPosition=f,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=b.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),H(this,"onready")}_clearBuffers(){for(var t in y)this[t]=y[t]}end(){return this.state===b.VALUE&&0===this.depth||tt(this,"Unexpected end"),Q(this),this.c="",this.closed=!0,H(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 tt(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(g&&console.log("write -> ["+t+"]");s&&(o=s,this.c=s=t.charCodeAt(e++),o!==s?this.p=o:o=this.p,s);)switch(g&&console.log(e,s,w[this.state]),this.position++,s===j?(this.line++,this.column=0):this.column++,this.state){case b.BEGIN:s===K?this.state=b.OPEN_OBJECT:s===B?this.state=b.OPEN_ARRAY:et(s)||tt(this,"Non-whitespace before {[.");continue;case b.OPEN_KEY:case b.OPEN_OBJECT:if(et(s))continue;if(this.state===b.OPEN_KEY)this.stack.push(b.CLOSE_KEY);else{if(s===$){H(this,"onopenobject"),this.depth++,H(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}this.stack.push(b.CLOSE_OBJECT)}s===E?this.state=b.STRING:tt(this,'Malformed object key should start with "');continue;case b.CLOSE_KEY:case b.CLOSE_OBJECT:if(et(s))continue;this.state,b.CLOSE_KEY;s===I?(this.state===b.CLOSE_OBJECT?(this.stack.push(b.CLOSE_OBJECT),Q(this,"onopenobject"),this.depth++):Q(this,"onkey"),this.state=b.VALUE):s===$?(W(this,"oncloseobject"),this.depth--,this.state=this.stack.pop()||b.VALUE):s===O?(this.state===b.CLOSE_OBJECT&&this.stack.push(b.CLOSE_OBJECT),Q(this),this.state=b.OPEN_KEY):tt(this,"Bad object");continue;case b.OPEN_ARRAY:case b.VALUE:if(et(s))continue;if(this.state===b.OPEN_ARRAY){if(H(this,"onopenarray"),this.depth++,this.state=b.VALUE,s===x){H(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;continue}this.stack.push(b.CLOSE_ARRAY)}s===E?this.state=b.STRING:s===K?this.state=b.OPEN_OBJECT:s===B?this.state=b.OPEN_ARRAY:s===G?this.state=b.TRUE:s===J?this.state=b.FALSE:s===z?this.state=b.NULL:s===_?this.numberNode+="-":C<=s&&s<=L?(this.numberNode+=String.fromCharCode(s),this.state=b.NUMBER_DIGIT):tt(this,"Bad value");continue;case b.CLOSE_ARRAY:if(s===O)this.stack.push(b.CLOSE_ARRAY),Q(this,"onvalue"),this.state=b.VALUE;else if(s===x)W(this,"onclosearray"),this.depth--,this.state=this.stack.pop()||b.VALUE;else{if(et(s))continue;tt(this,"Bad array")}continue;case b.STRING:void 0===this.textNode&&(this.textNode="");var n=e-1,i=this.slashed,r=this.unicodeI;t:for(;;){for(g&&console.log(e,s,w[this.state],i);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,n=e-1):r++,!s)break t;if(s===E&&!i){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}if(s===k&&!i&&(i=!0,this.textNode+=t.substring(n,e-1),this.position+=e-1-n,s=t.charCodeAt(e++),this.position++,!s))break;if(i){if(i=!1,s===z?this.textNode+="\n":s===D?this.textNode+="\r":s===G?this.textNode+="\t":s===J?this.textNode+="\f":s===T?this.textNode+="\b":s===V?(r=1,this.unicodeS=""):this.textNode+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,n=e-1,s)continue;break}q.lastIndex=e;var a=q.exec(t);if(null===a){e=t.length+1,this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}if(e=a.index+1,!(s=t.charCodeAt(a.index))){this.textNode+=t.substring(n,e-1),this.position+=e-1-n;break}}this.slashed=i,this.unicodeI=r;continue;case b.TRUE:s===D?this.state=b.TRUE2:tt(this,"Invalid true started with t"+s);continue;case b.TRUE2:s===V?this.state=b.TRUE3:tt(this,"Invalid true started with tr"+s);continue;case b.TRUE3:s===F?(H(this,"onvalue",!0),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid true started with tru"+s);continue;case b.FALSE:s===U?this.state=b.FALSE2:tt(this,"Invalid false started with f"+s);continue;case b.FALSE2:s===M?this.state=b.FALSE3:tt(this,"Invalid false started with fa"+s);continue;case b.FALSE3:s===Y?this.state=b.FALSE4:tt(this,"Invalid false started with fal"+s);continue;case b.FALSE4:s===F?(H(this,"onvalue",!1),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid false started with fals"+s);continue;case b.NULL:s===V?this.state=b.NULL2:tt(this,"Invalid null started with n"+s);continue;case b.NULL2:s===M?this.state=b.NULL3:tt(this,"Invalid null started with nu"+s);continue;case b.NULL3:s===M?(H(this,"onvalue",null),this.state=this.stack.pop()||b.VALUE):tt(this,"Invalid null started with nul"+s);continue;case b.NUMBER_DECIMAL_POINT:s===N?(this.numberNode+=".",this.state=b.NUMBER_DIGIT):tt(this,"Leading zero not followed by .");continue;case b.NUMBER_DIGIT:C<=s&&s<=L?this.numberNode+=String.fromCharCode(s):s===N?(-1!==this.numberNode.indexOf(".")&&tt(this,"Invalid number has two dots"),this.numberNode+="."):s===F||s===R?(-1===this.numberNode.indexOf("e")&&-1===this.numberNode.indexOf("E")||tt(this,"Invalid number has two exponential"),this.numberNode+="e"):s===S||s===_?(o!==F&&o!==R&&tt(this,"Invalid symbol in number"),this.numberNode+=String.fromCharCode(s)):(Z(this),e--,this.state=this.stack.pop()||b.VALUE);continue;default:tt(this,"Unknown state: "+this.state)}return this.position>=this.bufferCheckPosition&&function(t){const e=Math.max(f,10);let s=0;for(var o in y){var n=void 0===t[o]?0:t[o].length;if(n>e)switch(o){case"text":closeText(t);break;default:tt(t,"Max buffer length exceeded: "+o)}s=Math.max(s,n)}t.bufferCheckPosition=f-s+t.position}(this),H(this,"onchunkparsed"),this}}function H(t,e,s){g&&console.log("-- emit",e,s),t[e]&&t[e](s,t)}function W(t,e,s){Q(t),H(t,e,s)}function Q(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&&H(t,e||"onvalue",t.textNode),t.textNode=void 0}function Z(t){t.numberNode&&H(t,"onvalue",parseFloat(t.numberNode)),t.numberNode=""}function tt(t,e){return Q(t),e+="\nLine: "+t.line+"\nColumn: "+t.column+"\nChar: "+t.c,e=new Error(e),t.error=e,H(t,"onerror",e),t}function et(t){return t===P||t===j||t===v||t===A}class st{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 st)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 st(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 ot(t,e,s){return e in t?Object.defineProperty(t,e,{value:s,enumerable:!0,configurable:!0,writable:!0}):t[e]=s,t}function nt(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(){ot(this,"jsonpath",void 0),ot(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 st}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 X({onready:()=>{this.jsonpath=new st,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(),nt(this,"jsonPaths",void 0),nt(this,"streamingJsonPath",null),nt(this,"streamingArray",null),nt(this,"topLevelObject",null);const e=t.jsonpaths||[];this.jsonPaths=e.map(t=>new st(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*rt(t,e){var s;const o=d(t),{metadata:n}=e,{jsonpaths:i}=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:i});for await(const t of o){const e=c.write(t),s=e.length>0&&c.getStreamingJsonPathAsString();if(e.length>0&&r){if(n){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),n){const t={shape:a,batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0};yield t}}const at={json:{shape:"row-table",table:!1,jsonpaths:[]}},ht={name:"JSON",id:"json",module:"json",version:"3.1.0-alpha.5",extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,parse:async function(t,e){return ct((new TextDecoder).decode(t),e)},parseTextSync:ct,parseInBatches:function(t,e){const s={...e,json:{...at.json,...null==e?void 0:e.json}};return rt(t,s)},options:at};function ct(t,e){return o(t,{...e,json:{...at.json,...null==e?void 0:e.json}})}const lt={name:"NDJSON",id:"ndjson",module:"json",version:"3.1.0-alpha.5",extensions:["ndjson"],mimeTypes:["application/x-ndjson"],category:"table",text:!0,parse:async function(t){return ut((new TextDecoder).decode(t))},parseTextSync:ut,parseInBatches:function(t,e){return async function*(t,e){const s=async function*(t){let e=1;for await(const s of t)yield{counter:e,line:s},e++}(async function*(t){let e="";for await(const s of t){let t;for(e+=s;(t=e.indexOf("\n"))>=0;){const s=e.slice(0,t+1);e=e.slice(t+1),yield s}}e.length>0&&(yield e)}(d(t))),o=new p(null,{...e,shape:"row-table"});for await(const{counter:t,line:e}of s)try{const t=JSON.parse(e);o.addRow(t),o.chunkComplete(e);const s=o.getFullBatch();s&&(yield s)}catch(e){throw new Error("NDJSONLoader: failed to parse JSON on line "+t)}const n=o.getFinalBatch();n&&(yield n)}(t,e)},options:{}};function ut(t){return t.trim().split("\n").map((t,e)=>{try{return JSON.parse(t)}catch(t){throw new Error("NDJSONLoader: failed to parse JSON on line "+(e+1))}})}function pt(t,e={}){const s=dt(t);return ft(t,s,{coordLength:e.coordLength||s.coordLength,numericPropKeys:e.numericPropKeys||s.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array})}function dt(t){let e=0,s=0,o=0,n=0,i=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":i++,o+=t.coordinates.length,n++;for(const e of t.coordinates)l.add(e.length);break;case"MultiLineString":i++;for(const e of t.coordinates){o+=e.length,n++;for(const t of e)l.add(t.length)}break;case"Polygon":c++,a++,h+=t.coordinates.length,r+=Et(t.coordinates).length;for(const e of Et(t.coordinates))l.add(e.length);break;case"MultiPolygon":c++;for(const e of t.coordinates){a++,h+=e.length,r+=Et(e).length;for(const t of Et(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:n,lineFeaturesCount:i,polygonPositionsCount:r,polygonObjectsCount:a,polygonRingsCount:h,polygonFeaturesCount:c,numericPropKeys:Object.keys(u).filter(t=>u[t])}}function ft(t,e,s){const{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:i,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:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:Array(),fields:Array()},b={positions:new f(i*p),pathIndices:i>65535?new Uint32Array(r+1):new Uint16Array(r+1),globalFeatureIds:new g(i),featureIds:a>65535?new Uint32Array(i):new Uint16Array(i),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]=i,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":gt(t.coordinates,y,m,p,s),y.properties.push(Pt(s,d)),m.pointFeature++;break;case"MultiPoint":yt(t.coordinates,y,m,p,s),y.properties.push(Pt(s,d)),m.pointFeature++;break;case"LineString":bt(t.coordinates,b,m,p,s),b.properties.push(Pt(s,d)),m.lineFeature++;break;case"MultiLineString":wt(t.coordinates,b,m,p,s),b.properties.push(Pt(s,d)),m.lineFeature++;break;case"Polygon":mt(t.coordinates,w,m,p,s),w.properties.push(Pt(s,d)),m.polygonFeature++;break;case"MultiPolygon":At(t.coordinates,w,m,p,s),w.properties.push(Pt(s,d)),m.polygonFeature++;break;default:throw new Error("Invalid geometry type")}m.feature++}return function(t,e,s,o){const n={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 n)for(const e in n[t].numericProps)n[t].numericProps[e]={value:n[t].numericProps[e],size:1};return n}(y,b,w,p)}function gt(t,e,s,o,n){e.positions.set(t,s.pointPosition*o),e.globalFeatureIds[s.pointPosition]=s.feature,e.featureIds[s.pointPosition]=s.pointFeature,jt(e,n,s.pointPosition,1),s.pointPosition++}function yt(t,e,s,o,n){for(const i of t)gt(i,e,s,o,n)}function bt(t,e,s,o,n){e.pathIndices[s.linePath]=s.linePosition,s.linePath++,vt(e.positions,t,s.linePosition,o);const i=t.length;jt(e,n,s.linePosition,i),e.globalFeatureIds.set(new Uint32Array(i).fill(s.feature),s.linePosition),e.featureIds.set(new Uint32Array(i).fill(s.lineFeature),s.linePosition),s.linePosition+=i}function wt(t,e,s,o,n){for(const i of t)bt(i,e,s,o,n)}function mt(t,e,s,o,n){e.polygonIndices[s.polygonObject]=s.polygonPosition,s.polygonObject++;for(const i of t){e.primitivePolygonIndices[s.polygonRing]=s.polygonPosition,s.polygonRing++,vt(e.positions,i,s.polygonPosition,o);const t=i.length;jt(e,n,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 At(t,e,s,o,n){for(const i of t)mt(i,e,s,o,n)}function jt(t,e,s,o){for(const n in t.numericProps)n in e&&t.numericProps[n].set(new Array(o).fill(e[n]),s)}function Pt(t,e){const s={};for(const o in t)e.includes(o)||(s[o]=t[o]);return s}function vt(t,e,s,o){let n=s*o;for(const s of e)t.set(s,n),n+=o}function Et(t){return[].concat(...t)}const St={geojson:{shape:"object-row-table"},json:{jsonpaths:["$","$.features"]},gis:{format:"geojson"}},Ot={name:"GeoJSON",id:"geojson",module:"geojson",version:"3.1.0-alpha.5",worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:St},_t={...Ot,parse:async function(t,e){return Nt((new TextDecoder).decode(t),e)},parseTextSync:Nt,parseInBatches:function(t,e){(e={...St,...e}).json={...St.geojson,...e.geojson};const s=rt(t,e);switch(e.gis.format){case"binary":return async function*(t){for await(const e of t)e.data=pt(e.data),yield e}(s);default:return s}}};function Nt(t,e){(e={...St,...e}).json={...St.geojson,...e.geojson},e.gis=e.gis||{};const s=o(t,e);switch(e.gis.format){case"binary":return pt(s);default:return s}}}])}));
|
|
2
2
|
//# sourceMappingURL=dist.min.js.map
|
package/dist/es5/bundle.js
CHANGED
package/dist/es5/bundle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,
|
|
1
|
+
{"version":3,"sources":["../../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":";;AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
|
@@ -7,30 +7,14 @@ 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
|
-
|
|
22
10
|
var _gis = require("@loaders.gl/gis");
|
|
23
11
|
|
|
24
12
|
var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
|
|
25
13
|
|
|
26
14
|
var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
|
|
27
15
|
|
|
28
|
-
|
|
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.1.0-alpha.4" !== 'undefined' ? "3.1.0-alpha.4" : 'latest';
|
|
33
|
-
var DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
16
|
+
const VERSION = typeof "3.1.0-alpha.5" !== 'undefined' ? "3.1.0-alpha.5" : 'latest';
|
|
17
|
+
const DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
34
18
|
geojson: {
|
|
35
19
|
shape: 'object-row-table'
|
|
36
20
|
},
|
|
@@ -41,7 +25,7 @@ var DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
|
41
25
|
format: 'geojson'
|
|
42
26
|
}
|
|
43
27
|
};
|
|
44
|
-
|
|
28
|
+
const GeoJSONWorkerLoader = {
|
|
45
29
|
name: 'GeoJSON',
|
|
46
30
|
id: 'geojson',
|
|
47
31
|
module: 'geojson',
|
|
@@ -54,42 +38,26 @@ var GeoJSONWorkerLoader = {
|
|
|
54
38
|
options: DEFAULT_GEOJSON_LOADER_OPTIONS
|
|
55
39
|
};
|
|
56
40
|
exports.GeoJSONWorkerLoader = GeoJSONWorkerLoader;
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
});
|
|
63
|
-
|
|
41
|
+
const GeoJSONLoader = { ...GeoJSONWorkerLoader,
|
|
42
|
+
parse,
|
|
43
|
+
parseTextSync,
|
|
44
|
+
parseInBatches
|
|
45
|
+
};
|
|
64
46
|
exports.GeoJSONLoader = GeoJSONLoader;
|
|
65
47
|
|
|
66
|
-
function parse(
|
|
67
|
-
return
|
|
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);
|
|
48
|
+
async function parse(arrayBuffer, options) {
|
|
49
|
+
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
86
50
|
}
|
|
87
51
|
|
|
88
52
|
function parseTextSync(text, options) {
|
|
89
|
-
options =
|
|
90
|
-
|
|
53
|
+
options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
|
|
54
|
+
...options
|
|
55
|
+
};
|
|
56
|
+
options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
|
|
57
|
+
...options.geojson
|
|
58
|
+
};
|
|
91
59
|
options.gis = options.gis || {};
|
|
92
|
-
|
|
60
|
+
const json = (0, _parseJson.default)(text, options);
|
|
93
61
|
|
|
94
62
|
switch (options.gis.format) {
|
|
95
63
|
case 'binary':
|
|
@@ -101,9 +69,13 @@ function parseTextSync(text, options) {
|
|
|
101
69
|
}
|
|
102
70
|
|
|
103
71
|
function parseInBatches(asyncIterator, options) {
|
|
104
|
-
options =
|
|
105
|
-
|
|
106
|
-
|
|
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);
|
|
107
79
|
|
|
108
80
|
switch (options.gis.format) {
|
|
109
81
|
case 'binary':
|
|
@@ -114,96 +86,10 @@ function parseInBatches(asyncIterator, options) {
|
|
|
114
86
|
}
|
|
115
87
|
}
|
|
116
88
|
|
|
117
|
-
function makeBinaryGeometryIterator(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
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);
|
|
89
|
+
async function* makeBinaryGeometryIterator(geojsonIterator) {
|
|
90
|
+
for await (const batch of geojsonIterator) {
|
|
91
|
+
batch.data = (0, _gis.geojsonToBinary)(batch.data);
|
|
92
|
+
yield batch;
|
|
93
|
+
}
|
|
208
94
|
}
|
|
209
95
|
//# 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":"
|
|
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,2BAAuB,WAAvB,qBAAmD,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"}
|
package/dist/es5/index.js
CHANGED
|
@@ -7,37 +7,37 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
});
|
|
8
8
|
Object.defineProperty(exports, "JSONLoader", {
|
|
9
9
|
enumerable: true,
|
|
10
|
-
get: function
|
|
10
|
+
get: function () {
|
|
11
11
|
return _jsonLoader.JSONLoader;
|
|
12
12
|
}
|
|
13
13
|
});
|
|
14
14
|
Object.defineProperty(exports, "NDJSONLoader", {
|
|
15
15
|
enumerable: true,
|
|
16
|
-
get: function
|
|
16
|
+
get: function () {
|
|
17
17
|
return _ndjsonLoader.NDJSONLoader;
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
20
|
Object.defineProperty(exports, "_GeoJSONLoader", {
|
|
21
21
|
enumerable: true,
|
|
22
|
-
get: function
|
|
22
|
+
get: function () {
|
|
23
23
|
return _geojsonLoader.GeoJSONLoader;
|
|
24
24
|
}
|
|
25
25
|
});
|
|
26
26
|
Object.defineProperty(exports, "_GeoJSONWorkerLoader", {
|
|
27
27
|
enumerable: true,
|
|
28
|
-
get: function
|
|
28
|
+
get: function () {
|
|
29
29
|
return _geojsonLoader.GeoJSONWorkerLoader;
|
|
30
30
|
}
|
|
31
31
|
});
|
|
32
32
|
Object.defineProperty(exports, "_JSONPath", {
|
|
33
33
|
enumerable: true,
|
|
34
|
-
get: function
|
|
34
|
+
get: function () {
|
|
35
35
|
return _jsonpath.default;
|
|
36
36
|
}
|
|
37
37
|
});
|
|
38
38
|
Object.defineProperty(exports, "_ClarinetParser", {
|
|
39
39
|
enumerable: true,
|
|
40
|
-
get: function
|
|
40
|
+
get: function () {
|
|
41
41
|
return _clarinet.default;
|
|
42
42
|
}
|
|
43
43
|
});
|
package/dist/es5/json-loader.js
CHANGED
|
@@ -7,29 +7,19 @@ 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
|
-
|
|
16
10
|
var _parseJson = _interopRequireDefault(require("./lib/parse-json"));
|
|
17
11
|
|
|
18
12
|
var _parseJsonInBatches = _interopRequireDefault(require("./lib/parse-json-in-batches"));
|
|
19
13
|
|
|
20
|
-
|
|
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.1.0-alpha.4" !== 'undefined' ? "3.1.0-alpha.4" : 'latest';
|
|
25
|
-
var DEFAULT_JSON_LOADER_OPTIONS = {
|
|
14
|
+
const VERSION = typeof "3.1.0-alpha.5" !== 'undefined' ? "3.1.0-alpha.5" : 'latest';
|
|
15
|
+
const DEFAULT_JSON_LOADER_OPTIONS = {
|
|
26
16
|
json: {
|
|
27
17
|
shape: 'row-table',
|
|
28
18
|
table: false,
|
|
29
19
|
jsonpaths: []
|
|
30
20
|
}
|
|
31
21
|
};
|
|
32
|
-
|
|
22
|
+
const JSONLoader = {
|
|
33
23
|
name: 'JSON',
|
|
34
24
|
id: 'json',
|
|
35
25
|
module: 'json',
|
|
@@ -38,48 +28,32 @@ var JSONLoader = {
|
|
|
38
28
|
mimeTypes: ['application/json'],
|
|
39
29
|
category: 'table',
|
|
40
30
|
text: true,
|
|
41
|
-
parse
|
|
42
|
-
parseTextSync
|
|
43
|
-
parseInBatches
|
|
31
|
+
parse,
|
|
32
|
+
parseTextSync,
|
|
33
|
+
parseInBatches,
|
|
44
34
|
options: DEFAULT_JSON_LOADER_OPTIONS
|
|
45
35
|
};
|
|
46
36
|
exports.JSONLoader = JSONLoader;
|
|
47
37
|
|
|
48
|
-
function parse(
|
|
49
|
-
return
|
|
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);
|
|
38
|
+
async function parse(arrayBuffer, options) {
|
|
39
|
+
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
68
40
|
}
|
|
69
41
|
|
|
70
42
|
function parseTextSync(text, options) {
|
|
71
|
-
|
|
72
|
-
json:
|
|
73
|
-
|
|
74
|
-
|
|
43
|
+
const jsonOptions = { ...options,
|
|
44
|
+
json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
|
|
45
|
+
...(options === null || options === void 0 ? void 0 : options.json)
|
|
46
|
+
}
|
|
47
|
+
};
|
|
75
48
|
return (0, _parseJson.default)(text, jsonOptions);
|
|
76
49
|
}
|
|
77
50
|
|
|
78
51
|
function parseInBatches(asyncIterator, options) {
|
|
79
|
-
|
|
80
|
-
json:
|
|
81
|
-
|
|
82
|
-
|
|
52
|
+
const jsonOptions = { ...options,
|
|
53
|
+
json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
|
|
54
|
+
...(options === null || options === void 0 ? void 0 : options.json)
|
|
55
|
+
}
|
|
56
|
+
};
|
|
83
57
|
return (0, _parseJsonInBatches.default)(asyncIterator, jsonOptions);
|
|
84
58
|
}
|
|
85
59
|
//# 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":"
|
|
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,2BAAuB,WAAvB,qBAAmD,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"}
|