@loaders.gl/json 3.1.0-alpha.2 → 4.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +2 -4
- package/dist/bundle.js.map +1 -1
- package/dist/geojson-loader.js +1 -1
- package/dist/geojson-worker.js +1702 -2
- package/dist/json-loader.js +1 -1
- package/dist/lib/clarinet/clarinet.js +222 -260
- package/dist/lib/clarinet/clarinet.js.map +1 -1
- package/dist/lib/parse-ndjson-in-batches.js +1 -1
- package/dist/lib/parse-ndjson-in-batches.js.map +1 -1
- package/dist/lib/parse-ndjson.js +1 -1
- package/dist/lib/parse-ndjson.js.map +1 -1
- package/dist/lib/parser/json-parser.js +48 -47
- package/dist/lib/parser/json-parser.js.map +1 -1
- package/dist/lib/parser/streaming-json-parser.js +29 -34
- package/dist/lib/parser/streaming-json-parser.js.map +1 -1
- package/dist/ndjson-loader.js +3 -1
- package/dist/ndjson-loader.js.map +1 -1
- package/package.json +7 -7
- package/src/bundle.ts +2 -3
- package/src/lib/clarinet/clarinet.ts +539 -0
- package/src/lib/parser/json-parser.ts +52 -55
- package/src/lib/parser/streaming-json-parser.ts +28 -32
- package/src/ndjson-loader.ts +3 -1
- package/dist/dist.min.js +0 -2
- package/dist/dist.min.js.map +0 -1
- package/dist/geojson-worker.js.map +0 -1
- package/src/lib/clarinet/clarinet.js +0 -578
|
@@ -12,10 +12,36 @@ export default class StreamingJSONParser extends JSONParser {
|
|
|
12
12
|
private topLevelObject: object | null = null;
|
|
13
13
|
|
|
14
14
|
constructor(options: {[key: string]: any} = {}) {
|
|
15
|
-
super(
|
|
15
|
+
super({
|
|
16
|
+
onopenarray: () => {
|
|
17
|
+
if (!this.streamingArray) {
|
|
18
|
+
if (this._matchJSONPath()) {
|
|
19
|
+
// @ts-ignore
|
|
20
|
+
this.streamingJsonPath = this.getJsonPath().clone();
|
|
21
|
+
this.streamingArray = [];
|
|
22
|
+
this._openArray(this.streamingArray as []);
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
this._openArray();
|
|
28
|
+
},
|
|
29
|
+
|
|
30
|
+
// Redefine onopenarray to inject value for top-level object
|
|
31
|
+
onopenobject: (name) => {
|
|
32
|
+
if (!this.topLevelObject) {
|
|
33
|
+
this.topLevelObject = {};
|
|
34
|
+
this._openObject(this.topLevelObject);
|
|
35
|
+
} else {
|
|
36
|
+
this._openObject({});
|
|
37
|
+
}
|
|
38
|
+
if (typeof name !== 'undefined') {
|
|
39
|
+
this.parser.emit('onkey', name);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
});
|
|
16
43
|
const jsonpaths = options.jsonpaths || [];
|
|
17
44
|
this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));
|
|
18
|
-
this._extendParser();
|
|
19
45
|
}
|
|
20
46
|
|
|
21
47
|
/**
|
|
@@ -79,34 +105,4 @@ export default class StreamingJSONParser extends JSONParser {
|
|
|
79
105
|
|
|
80
106
|
return false;
|
|
81
107
|
}
|
|
82
|
-
|
|
83
|
-
_extendParser() {
|
|
84
|
-
// Redefine onopenarray to locate and inject value for top-level array
|
|
85
|
-
this.parser.onopenarray = () => {
|
|
86
|
-
if (!this.streamingArray) {
|
|
87
|
-
if (this._matchJSONPath()) {
|
|
88
|
-
// @ts-ignore
|
|
89
|
-
this.streamingJsonPath = this.getJsonPath().clone();
|
|
90
|
-
this.streamingArray = [];
|
|
91
|
-
this._openArray(this.streamingArray as []);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
this._openArray();
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
// Redefine onopenarray to inject value for top-level object
|
|
100
|
-
this.parser.onopenobject = (name) => {
|
|
101
|
-
if (!this.topLevelObject) {
|
|
102
|
-
this.topLevelObject = {};
|
|
103
|
-
this._openObject(this.topLevelObject);
|
|
104
|
-
} else {
|
|
105
|
-
this._openObject({});
|
|
106
|
-
}
|
|
107
|
-
if (typeof name !== 'undefined') {
|
|
108
|
-
this.parser.onkey(name);
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
}
|
|
112
108
|
}
|
package/src/ndjson-loader.ts
CHANGED
|
@@ -7,7 +7,7 @@ import parseNDJSONInBatches from './lib/parse-ndjson-in-batches';
|
|
|
7
7
|
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
8
8
|
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
9
9
|
|
|
10
|
-
export const NDJSONLoader
|
|
10
|
+
export const NDJSONLoader = {
|
|
11
11
|
name: 'NDJSON',
|
|
12
12
|
id: 'ndjson',
|
|
13
13
|
module: 'json',
|
|
@@ -36,3 +36,5 @@ function parseInBatches(
|
|
|
36
36
|
): AsyncIterable<Batch> {
|
|
37
37
|
return parseNDJSONInBatches(asyncIterator, options);
|
|
38
38
|
}
|
|
39
|
+
|
|
40
|
+
export const _typecheckNDJSONLoader: LoaderWithParser = NDJSONLoader;
|
package/dist/dist.min.js
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
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 n in s)("object"==typeof exports?exports:t)[n]=s[n]}}(window,(function(){return function(t){var e={};function s(n){if(e[n])return e[n].exports;var o=e[n]={i:n,l:!1,exports:{}};return t[n].call(o.exports,o,o.exports,s),o.l=!0,o.exports}return s.m=t,s.c=e,s.d=function(t,e,n){s.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},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 n=Object.create(null);if(s.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var o in t)s.d(n,o,function(e){return t[e]}.bind(null,o));return n},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 n=s(4),o="undefined"==typeof window?e:window;o.loaders=o.loaders||{},t.exports=Object.assign(o.loaders,n)}).call(this,s(3))},,,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 n(t,e){try{var s;const n=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}(n)||n}catch(t){throw new Error("JSONLoader: failed to parse JSON")}}function o(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(o(this,"schema",void 0),o(this,"options",void 0),o(this,"length",0),o(this,"rows",null),o(this,"cursor",0),o(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 n=0;n<e.length;n++)s[e[n]]=t[n];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 n=0;n<e.length;n++)s[n]=t[e[n]];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,n=this.columns[e.index];if(n&&ArrayBuffer.isView(n)){const t=new s(this.allocated);t.set(n),this.columns[e.index]=t}else n?(n.length=this.allocated,this.columns[e.index]=n):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,x=92,k=93,U=97,F=98,T=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),n=this.p;for(g&&console.log("write -> ["+t+"]");s&&(n=s,this.c=s=t.charCodeAt(e++),n!==s?this.p=n:n=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===k){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===k)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 o=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,o=e-1):r++,!s)break t;if(s===E&&!i){this.state=this.stack.pop()||b.VALUE,this.textNode+=t.substring(o,e-1),this.position+=e-1-o;break}if(s===x&&!i&&(i=!0,this.textNode+=t.substring(o,e-1),this.position+=e-1-o,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===F?this.textNode+="\b":s===V?(r=1,this.unicodeS=""):this.textNode+=String.fromCharCode(s),s=t.charCodeAt(e++),this.position++,o=e-1,s)continue;break}q.lastIndex=e;var a=q.exec(t);if(null===a){e=t.length+1,this.textNode+=t.substring(o,e-1),this.position+=e-1-o;break}if(e=a.index+1,!(s=t.charCodeAt(a.index))){this.textNode+=t.substring(o,e-1),this.position+=e-1-o;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===T?(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===T?(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===T||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===_?(n!==T&&n!==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 n in y){var o=void 0===t[n]?0:t[n].length;if(o>e)switch(n){case"text":closeText(t);break;default:tt(t,"Max buffer length exceeded: "+n)}s=Math.max(s,o)}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,n;if(n=void 0,(s="path")in(e=this)?Object.defineProperty(e,s,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[s]=n,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 n=s.pop();for(const e of s)t=t[e];t[n]=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 nt(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(){nt(this,"jsonpath",void 0),nt(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(),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 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 n=d(t),{metadata:o}=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 n){const e=c.write(t),s=e.length>0&&c.getStreamingJsonPathAsString();if(e.length>0&&r){if(o){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 n=h.getFullBatch({jsonpath:s});n&&(yield n)}const l=c.getStreamingJsonPathAsString(),u=h.getFinalBatch({jsonpath:l});if(u&&(yield u),o){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.2",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 n(t,{...e,json:{...at.json,...null==e?void 0:e.json}})}const lt={name:"NDJSON",id:"ndjson",module:"json",version:"3.1.0-alpha.2",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))),n=new p(null,{...e,shape:"row-table"});for await(const{counter:t,line:e}of s)try{const t=JSON.parse(e);n.addRow(t),n.chunkComplete(e);const s=n.getFullBatch();s&&(yield s)}catch(e){throw new Error("NDJSONLoader: failed to parse JSON on line "+t)}const o=n.getFinalBatch();o&&(yield o)}(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,n=0,o=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++,n+=t.coordinates.length,o++;for(const e of t.coordinates)l.add(e.length);break;case"MultiLineString":i++;for(const e of t.coordinates){n+=e.length,o++;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:n,linePathsCount:o,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:n,pointFeaturesCount:o,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(n*p),globalFeatureIds:new g(n),featureIds:o>65535?new Uint32Array(n):new Uint16Array(n),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,n){const o={points:{...t,positions:{value:t.positions,size:n},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:n},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:n},globalFeatureIds:{value:s.globalFeatureIds,size:1},featureIds:{value:s.featureIds,size:1},type:"Polygon"}};for(const t in o)for(const e in o[t].numericProps)o[t].numericProps[e]={value:o[t].numericProps[e],size:1};return o}(y,b,w,p)}function gt(t,e,s,n,o){e.positions.set(t,s.pointPosition*n),e.globalFeatureIds[s.pointPosition]=s.feature,e.featureIds[s.pointPosition]=s.pointFeature,jt(e,o,s.pointPosition,1),s.pointPosition++}function yt(t,e,s,n,o){for(const i of t)gt(i,e,s,n,o)}function bt(t,e,s,n,o){e.pathIndices[s.linePath]=s.linePosition,s.linePath++,vt(e.positions,t,s.linePosition,n);const i=t.length;jt(e,o,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,n,o){for(const i of t)bt(i,e,s,n,o)}function mt(t,e,s,n,o){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,n);const t=i.length;jt(e,o,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,n,o){for(const i of t)mt(i,e,s,n,o)}function jt(t,e,s,n){for(const o in t.numericProps)o in e&&t.numericProps[o].set(new Array(n).fill(e[o]),s)}function Pt(t,e){const s={};for(const n in t)e.includes(n)||(s[n]=t[n]);return s}function vt(t,e,s,n){let o=s*n;for(const s of e)t.set(s,o),o+=n}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.2",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=n(t,e);switch(e.gis.format){case"binary":return pt(s);default:return s}}}])}));
|
|
2
|
-
//# sourceMappingURL=dist.min.js.map
|
package/dist/dist.min.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack:///webpack/universalModuleDefinition","webpack:///webpack/bootstrap","webpack:///./src/bundle.ts","webpack:///(webpack)/buildin/global.js","webpack:///./src/lib/parse-json.ts","webpack:///../schema/src/lib/batches/base-table-batch-aggregator.ts","webpack:///../schema/src/lib/batches/row-table-batch-aggregator.ts","webpack:///../schema/src/lib/utils/row-utils.ts","webpack:///../schema/src/lib/batches/columnar-table-batch-aggregator.ts","webpack:///../schema/src/lib/batches/table-batch-builder.ts","webpack:///../loader-utils/src/lib/iterators/text-iterators.ts","webpack:///./src/lib/clarinet/clarinet.js","webpack:///./src/lib/jsonpath/jsonpath.ts","webpack:///./src/lib/parser/streaming-json-parser.ts","webpack:///./src/lib/parser/json-parser.ts","webpack:///./src/lib/parse-json-in-batches.ts","webpack:///./src/json-loader.ts","webpack:///./src/ndjson-loader.ts","webpack:///./src/lib/parse-ndjson-in-batches.ts","webpack:///./src/lib/parse-ndjson.ts","webpack:///../gis/src/lib/geojson-to-binary.ts","webpack:///./src/geojson-loader.ts"],"names":["root","factory","exports","module","define","amd","a","i","window","installedModules","__webpack_require__","moduleId","l","modules","call","m","c","d","name","getter","o","Object","defineProperty","enumerable","get","r","Symbol","toStringTag","value","t","mode","__esModule","ns","create","key","bind","n","object","property","prototype","hasOwnProperty","p","s","moduleExports","require","_global","global","loaders","assign","g","this","Function","e","parseJSONSync","jsonText","options","json","JSON","parse","table","getFirstArray","Array","isArray","values","array","error","Error","RowTableBatchAggregator","constructor","schema","_headers","index","rowCount","length","addArrayRow","row","cursor","Number","isFinite","rows","addObjectRow","getBatch","slice","shape","batchType","data","rowObject","arrayRow","headers","objectRow","convertToObjectRow","arrayRows","rowArray","convertToArrayRow","objectRows","ColumnarTableBatchAggregator","_reallocateColumns","fieldName","columns","_pruneColumns","field","allocated","ArrayType","type","Float32Array","oldColumn","ArrayBuffer","isView","typedArray","set","columnName","column","entries","DEFAULT_OPTIONS","batchSize","batchDebounceMs","limit","_limitMB","TableBatchBuilder","Date","now","limitReached","Boolean","totalLength","totalBytes","addRow","rowBytes","_estimateRowMB","aggregator","TableBatchType","_getTableBatchType","chunkComplete","chunk","bytesUsed","byteLength","isChunkComplete","getFullBatch","_isFull","_getBatch","getFinalBatch","keys","lastBatchEmittedMs","normalizedBatch","count","batchCount","BaseTableBatchAggregator","ArrowBatch","async","makeTextDecoderIterator","arrayBufferIterator","textDecoder","TextDecoder","undefined","arrayBuffer","decode","stream","MAX_BUFFER_LENGTH","MAX_SAFE_INTEGER","DEBUG","CDEBUG","buffers","textNode","numberNode","S","STATE","BEGIN","VALUE","OPEN_OBJECT","CLOSE_OBJECT","OPEN_ARRAY","CLOSE_ARRAY","TEXT_ESCAPE","STRING","BACKSLASH","END","OPEN_KEY","CLOSE_KEY","TRUE","TRUE2","TRUE3","FALSE","FALSE2","FALSE3","FALSE4","NULL","NULL2","NULL3","NUMBER_DECIMAL_POINT","NUMBER_DIGIT","s_","Char","stringTokenPattern","ClarinetParser","_initialize","_clearBuffers","bufferCheckPosition","q","closed","closedRoot","sawRoot","tag","state","stack","position","line","slashed","unicodeI","unicodeS","depth","onready","onopenobject","onkey","oncloseobject","onopenarray","onclosearray","onvalue","onerror","onend","onchunkparsed","emit","buffer","end","closeValue","resume","close","write","charCodeAt","console","log","isWhitespace","push","pop","emitNode","String","fromCharCode","starti","STRING_BIGLOOP","parseInt","substring","lastIndex","reResult","exec","indexOf","closeNumber","parser","maxAllowed","Math","max","maxActual","len","closeText","checkBufferLength","event","opt","text","trim","normalize","replace","textopts","parseFloat","er","JSONPath","path","split","clone","toString","join","equals","other","setFieldAtPath","shift","component","getFieldAtPath","StreamingJSONParser","reset","_initializeParser","result","previousStates","currentState","freeze","container","jsonpath","_pushOrSet","_openArray","newContainer","_closeArray","_openObject","_closeObject","_parser","super","jsonpaths","jsonPaths","map","_extendParser","streamingArray","getPartialResult","topLevelObject","getStreamingJsonPath","streamingJsonPath","getStreamingJsonPathAsString","getJsonPath","_matchJSONPath","currentPath","jsonPath","parseJSONInBatches","binaryAsyncIterator","asyncIterator","metadata","isFirstChunk","tableBatchBuilder","initialBatch","batch","finalBatch","DEFAULT_JSON_LOADER_OPTIONS","JSONLoader","id","version","extensions","mimeTypes","category","parseTextSync","parseInBatches","jsonOptions","NDJSONLoader","numberedLineIterator","lineIterator","counter","makeNumberedLineIterator","textIterator","previous","textChunk","eolIndex","makeLineIterator","parseNDJSONInBatches","geojsonToBinary","features","firstPassData","firstPass","secondPass","coordLength","numericPropKeys","PositionDataType","pointPositionsCount","pointFeaturesCount","linePositionsCount","linePathsCount","lineFeaturesCount","polygonPositionsCount","polygonObjectsCount","polygonRingsCount","polygonFeaturesCount","coordLengths","Set","feature","geometry","add","coordinates","point","coord","flatten","polygon","properties","val","x","size","filter","k","GlobalFeatureIdsDataType","Uint32Array","Uint16Array","points","positions","globalFeatureIds","featureIds","numericProps","fields","lines","pathIndices","polygons","polygonIndices","primitivePolygonIndices","propName","indexMap","pointPosition","pointFeature","linePosition","linePath","lineFeature","polygonPosition","polygonObject","polygonRing","polygonFeature","handlePoint","keepStringProperties","handleMultiPoint","handleLineString","handleMultiLineString","handlePolygon","handleMultiPolygon","returnObj","geomType","numericProp","makeAccessorObjects","coords","fillNumericProperties","fillCoords","nPositions","fill","ring","numericPropName","numericKeys","props","includes","startVertex","arrays","concat","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","gis","format","GeoJSONWorkerLoader","worker","GeoJSONLoader","geojsonIterator","makeBinaryGeometryIterator"],"mappings":"CAAA,SAA2CA,EAAMC,GAChD,GAAsB,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,SACb,GAAqB,mBAAXG,QAAyBA,OAAOC,IAC9CD,OAAO,GAAIH,OACP,CACJ,IAAIK,EAAIL,IACR,IAAI,IAAIM,KAAKD,GAAuB,iBAAZJ,QAAuBA,QAAUF,GAAMO,GAAKD,EAAEC,IAPxE,CASGC,QAAQ,WACX,O,YCTE,IAAIC,EAAmB,GAGvB,SAASC,EAAoBC,GAG5B,GAAGF,EAAiBE,GACnB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,EAAQ0W,SAEtE,MAAMM,EAAkBvH,GAAmBE,EAAe3P,GAE1D,OAAQA,EAAQ2W,IAAIC,QAClB,IAAK,SACH,OAMNhR,gBAA2CoR,GACzC,UAAW,MAAMhH,KAASgH,EACxBhH,EAAMlO,KAAOyP,GAAgBvB,EAAMlO,YAC7BkO,EATGiH,CAA2BD,GACpC,QACE,OAAOA,KAzBb,SAASvG,GAAclE,EAAMvM,IAE3BA,EAAU,IAAIyW,MAAmCzW,IACzCC,KAAO,IAAIwW,GAA+BC,WAAY1W,EAAQ0W,SACtE1W,EAAQ2W,IAAM3W,EAAQ2W,KAAO,GAC7B,MAAM1W,EAAOH,EAAcyM,EAAMvM,GACjC,OAAQA,EAAQ2W,IAAIC,QAClB,IAAK,SACH,OAAOrF,GAAgBtR,GACzB,QACE,OAAOA","file":"dist.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine([], factory);\n\telse {\n\t\tvar a = factory();\n\t\tfor(var i in a) (typeof exports === 'object' ? exports : root)[i] = a[i];\n\t}\n})(window, function() {\nreturn "," \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId]) {\n \t\t\treturn installedModules[moduleId].exports;\n \t\t}\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\ti: moduleId,\n \t\t\tl: false,\n \t\t\texports: {}\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.l = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// define getter function for harmony exports\n \t__webpack_require__.d = function(exports, name, getter) {\n \t\tif(!__webpack_require__.o(exports, name)) {\n \t\t\tObject.defineProperty(exports, name, { enumerable: true, get: getter });\n \t\t}\n \t};\n\n \t// define __esModule on exports\n \t__webpack_require__.r = function(exports) {\n \t\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n \t\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n \t\t}\n \t\tObject.defineProperty(exports, '__esModule', { value: true });\n \t};\n\n \t// create a fake namespace object\n \t// mode & 1: value is a module id, require it\n \t// mode & 2: merge all properties of value into the ns\n \t// mode & 4: return value when already ns object\n \t// mode & 8|1: behave like require\n \t__webpack_require__.t = function(value, mode) {\n \t\tif(mode & 1) value = __webpack_require__(value);\n \t\tif(mode & 8) return value;\n \t\tif((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;\n \t\tvar ns = Object.create(null);\n \t\t__webpack_require__.r(ns);\n \t\tObject.defineProperty(ns, 'default', { enumerable: true, value: value });\n \t\tif(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));\n \t\treturn ns;\n \t};\n\n \t// getDefaultExport function for compatibility with non-harmony modules\n \t__webpack_require__.n = function(module) {\n \t\tvar getter = module && module.__esModule ?\n \t\t\tfunction getDefault() { return module['default']; } :\n \t\t\tfunction getModuleExports() { return module; };\n \t\t__webpack_require__.d(getter, 'a', getter);\n \t\treturn getter;\n \t};\n\n \t// Object.prototype.hasOwnProperty.call\n \t__webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"\";\n\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(__webpack_require__.s = 0);\n","// @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","var g;\n\n// This works in non-strict mode\ng = (function() {\n\treturn this;\n})();\n\ntry {\n\t// This works if eval is allowed (see CSP)\n\tg = g || new Function(\"return this\")();\n} catch (e) {\n\t// This works if the window reference is available\n\tif (typeof window === \"object\") g = window;\n}\n\n// g can still be undefined, but nothing to do about it...\n// We return undefined, instead of nothing here, so it's\n// easier to handle this case. if(!global) { ...}\n\nmodule.exports = g;\n","import type {JSONLoaderOptions} from '../json-loader';\n\nexport default function parseJSONSync(jsonText: string, options: JSONLoaderOptions) {\n try {\n const json = JSON.parse(jsonText);\n if (options.json?.table) {\n return getFirstArray(json) || json;\n }\n return json;\n } catch (error) {\n throw new Error('JSONLoader: failed to parse JSON');\n }\n}\n\nfunction getFirstArray(json) {\n if (Array.isArray(json)) {\n return json;\n }\n if (json && typeof json === 'object') {\n for (const value of Object.values(json)) {\n const array = getFirstArray(value);\n if (array) {\n return array;\n }\n }\n }\n return null;\n}\n","import type {Schema} from '../schema';\nimport type {TableBatch} from '../../category/table/table-types';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n rows: any[] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);\n this.rows[this.length] = row;\n this.length++;\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n this.rows = this.rows || new Array(DEFAULT_ROW_COUNT);\n this.rows[this.length] = row;\n this.length++;\n }\n\n getBatch(): TableBatch | null {\n let rows = this.rows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.rows = null;\n\n const batch: TableBatch = {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n\n return batch;\n }\n}\n","import type {Schema} from '../schema';\nimport type {TableBatch} from '../../category/table/table-types';\n// import type {ArrayRowTableBatch, ObjectRowTableBatch} from '../../category/table';\nimport {convertToArrayRow, convertToObjectRow} from '../utils/row-utils';\nimport {TableBatchAggregator, TableBatchOptions} from './table-batch-aggregator';\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class RowTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n options: TableBatchOptions;\n\n length: number = 0;\n objectRows: {[columnName: string]: any} | null = null;\n arrayRows: any[] | null = null;\n cursor: number = 0;\n private _headers: string[] = [];\n\n constructor(schema: Schema, options: TableBatchOptions) {\n this.options = options;\n this.schema = schema;\n\n // schema is an array if there're no headers\n // object if there are headers\n if (!Array.isArray(schema)) {\n this._headers = [];\n for (const key in schema) {\n this._headers[schema[key].index] = schema[key].name;\n }\n }\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[], cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'object-row-table':\n const rowObject = convertToObjectRow(row, this._headers);\n this.addObjectRow(rowObject, cursor);\n break;\n case 'array-row-table':\n this.arrayRows = this.arrayRows || new Array(DEFAULT_ROW_COUNT);\n this.arrayRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n addObjectRow(row: {[columnName: string]: any}, cursor?: number): void {\n if (Number.isFinite(cursor)) {\n this.cursor = cursor as number;\n }\n\n // eslint-disable-next-line default-case\n switch (this.options.shape) {\n case 'array-row-table':\n const rowArray = convertToArrayRow(row, this._headers);\n this.addArrayRow(rowArray, cursor);\n break;\n case 'object-row-table':\n this.objectRows = this.objectRows || new Array(DEFAULT_ROW_COUNT);\n this.objectRows[this.length] = row;\n this.length++;\n break;\n }\n }\n\n getBatch(): TableBatch | null {\n let rows = this.arrayRows || this.objectRows;\n if (!rows) {\n return null;\n }\n\n rows = rows.slice(0, this.length);\n this.arrayRows = null;\n this.objectRows = null;\n\n return {\n shape: this.options.shape,\n batchType: 'data',\n data: rows,\n length: this.length,\n schema: this.schema,\n cursor: this.cursor\n };\n }\n}\n","/** Convert an object row to an array row */\nexport function convertToObjectRow(\n arrayRow: any[],\n headers: string[]\n): {[columnName: string]: any} {\n if (!arrayRow) {\n throw new Error('null row');\n }\n if (!headers) {\n throw new Error('no headers');\n }\n const objectRow = {};\n for (let i = 0; i < headers.length; i++) {\n objectRow[headers[i]] = arrayRow[i];\n }\n return objectRow;\n}\n\n/** Convert an object row to an array row */\nexport function convertToArrayRow(\n objectRow: {[columnName: string]: any},\n headers: string[]\n): any[] {\n if (!objectRow) {\n throw new Error('null row');\n }\n if (!headers) {\n throw new Error('no headers');\n }\n const arrayRow = new Array(headers.length);\n for (let i = 0; i < headers.length; i++) {\n arrayRow[i] = objectRow[headers[i]];\n }\n return arrayRow;\n}\n","import type {Schema} from '../schema';\nimport type {ColumnarTableBatch, ArrowTableBatch} from '../../category/table/table-types';\nimport {TableBatchAggregator} from './table-batch-aggregator';\n\ntype ColumnarTableBatchOptions = {};\n\nconst DEFAULT_ROW_COUNT = 100;\n\nexport default class ColumnarTableBatchAggregator implements TableBatchAggregator {\n schema: Schema;\n length: number = 0;\n allocated: number = 0;\n columns: {[columnName: string]: any[]} = {};\n\n constructor(schema: Schema, options: ColumnarTableBatchOptions) {\n this.schema = schema;\n this._reallocateColumns();\n }\n\n rowCount(): number {\n return this.length;\n }\n\n addArrayRow(row: any[]) {\n // If user keeps pushing rows beyond batch size, reallocate\n this._reallocateColumns();\n let i = 0;\n // TODO what if no csv header, columns not populated?\n for (const fieldName in this.columns) {\n this.columns[fieldName][this.length] = row[i++];\n }\n this.length++;\n }\n\n addObjectRow(row: {[columnName: string]: any}): void {\n // If user keeps pushing rows beyond batch size, reallocate\n this._reallocateColumns();\n for (const fieldName in row) {\n this.columns[fieldName][this.length] = row[fieldName];\n }\n this.length++;\n }\n\n getBatch(): ColumnarTableBatch | ArrowTableBatch | null {\n this._pruneColumns();\n const columns = Array.isArray(this.schema) ? this.columns : {};\n\n // schema is an array if there're no headers\n // object if there are headers\n // columns should match schema format\n if (!Array.isArray(this.schema)) {\n for (const fieldName in this.schema) {\n const field = this.schema[fieldName];\n columns[field.name] = this.columns[field.index];\n }\n }\n\n this.columns = {};\n\n const batch: ColumnarTableBatch = {\n shape: 'columnar-table',\n batchType: 'data',\n data: columns,\n schema: this.schema,\n length: this.length\n };\n\n return batch;\n }\n\n // HELPERS\n\n _reallocateColumns() {\n if (this.length < this.allocated) {\n return;\n }\n\n // @ts-ignore TODO\n this.allocated = this.allocated > 0 ? (this.allocated *= 2) : DEFAULT_ROW_COUNT;\n this.columns = {};\n\n for (const fieldName in this.schema) {\n const field = this.schema[fieldName];\n const ArrayType = field.type || Float32Array;\n const oldColumn = this.columns[field.index];\n\n if (oldColumn && ArrayBuffer.isView(oldColumn)) {\n // Copy the old data to the new array\n const typedArray = new ArrayType(this.allocated);\n typedArray.set(oldColumn);\n this.columns[field.index] = typedArray;\n } else if (oldColumn) {\n // Plain array\n oldColumn.length = this.allocated;\n this.columns[field.index] = oldColumn;\n } else {\n // Create new\n this.columns[field.index] = new ArrayType(this.allocated);\n }\n }\n }\n\n _pruneColumns() {\n for (const [columnName, column] of Object.entries(this.columns)) {\n this.columns[columnName] = column.slice(0, this.length);\n }\n }\n}\n","import type {Schema} from '../schema';\nimport type {TableBatch} from '../../category/table/table-types';\nimport type {TableBatchAggregator, TableBatchConstructor} from './table-batch-aggregator';\nimport BaseTableBatchAggregator from './base-table-batch-aggregator';\nimport RowTableBatchAggregator from './row-table-batch-aggregator';\nimport ColumnarTableBatchAggregator from './columnar-table-batch-aggregator';\n\n// TODO define interface instead\ntype TableBatchBuilderOptions = {\n shape: 'row-table' | 'array-row-table' | 'object-row-table' | 'columnar-table' | 'arrow-table';\n batchSize?: number | 'auto';\n batchDebounceMs?: number;\n limit: number;\n _limitMB: number;\n};\n\ntype GetBatchOptions = {\n bytesUsed?: number;\n [key: string]: any;\n};\n\nconst DEFAULT_OPTIONS: Required<TableBatchBuilderOptions> = {\n shape: 'array-row-table',\n batchSize: 'auto',\n batchDebounceMs: 0,\n limit: 0,\n _limitMB: 0\n};\n\nconst ERR_MESSAGE = 'TableBatchBuilder';\n\n/** Incrementally builds batches from a stream of rows */\nexport default class TableBatchBuilder {\n schema: Schema;\n options: Required<TableBatchBuilderOptions>;\n\n private aggregator: TableBatchAggregator | null = null;\n private batchCount: number = 0;\n private bytesUsed: number = 0;\n private isChunkComplete: boolean = false;\n private lastBatchEmittedMs: number = Date.now();\n private totalLength: number = 0;\n private totalBytes: number = 0;\n private rowBytes: number = 0;\n\n static ArrowBatch?: TableBatchConstructor;\n\n constructor(schema: Schema, options?: TableBatchBuilderOptions) {\n this.schema = schema;\n this.options = {...DEFAULT_OPTIONS, ...options};\n }\n\n limitReached(): boolean {\n if (Boolean(this.options?.limit) && this.totalLength >= this.options.limit) {\n return true;\n }\n if (Boolean(this.options?._limitMB) && this.totalBytes / 1e6 >= this.options._limitMB) {\n return true;\n }\n return false;\n }\n\n /** @deprecated Use addArrayRow or addObjectRow */\n addRow(row: any[] | {[columnName: string]: any}): void {\n if (this.limitReached()) {\n return;\n }\n this.totalLength++;\n this.rowBytes = this.rowBytes || this._estimateRowMB(row);\n this.totalBytes += this.rowBytes;\n if (Array.isArray(row)) {\n this.addArrayRow(row);\n } else {\n this.addObjectRow(row);\n }\n }\n\n /** Add one row to the batch */\n protected addArrayRow(row: any[]) {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addArrayRow(row);\n }\n\n /** Add one row to the batch */\n protected addObjectRow(row: {[columnName: string]: any}): void {\n if (!this.aggregator) {\n const TableBatchType = this._getTableBatchType();\n this.aggregator = new TableBatchType(this.schema, this.options);\n }\n this.aggregator.addObjectRow(row);\n }\n\n /** Mark an incoming raw memory chunk has completed */\n chunkComplete(chunk: ArrayBuffer | string): void {\n if (chunk instanceof ArrayBuffer) {\n this.bytesUsed += chunk.byteLength;\n }\n if (typeof chunk === 'string') {\n this.bytesUsed += chunk.length;\n }\n this.isChunkComplete = true;\n }\n\n getFullBatch(options?: GetBatchOptions): TableBatch | null {\n return this._isFull() ? this._getBatch(options) : null;\n }\n\n getFinalBatch(options?: GetBatchOptions): TableBatch | null {\n return this._getBatch(options);\n }\n\n // INTERNAL\n\n _estimateRowMB(row) {\n return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;\n }\n\n private _isFull(): boolean {\n // No batch, not ready\n if (!this.aggregator || this.aggregator.rowCount() === 0) {\n return false;\n }\n\n // if batchSize === 'auto' we wait for chunk to complete\n // if batchSize === number, ensure we have enough rows\n if (this.options.batchSize === 'auto') {\n if (!this.isChunkComplete) {\n return false;\n }\n } else if (this.options.batchSize > this.aggregator.rowCount()) {\n return false;\n }\n\n // Debounce batches\n if (this.options.batchDebounceMs > Date.now() - this.lastBatchEmittedMs) {\n return false;\n }\n\n // Emit batch\n this.isChunkComplete = false;\n this.lastBatchEmittedMs = Date.now();\n return true;\n }\n\n /**\n * bytesUsed can be set via chunkComplete or via getBatch*\n */\n private _getBatch(options?: GetBatchOptions): TableBatch | null {\n if (!this.aggregator) {\n return null;\n }\n\n // TODO - this can overly increment bytes used?\n if (options?.bytesUsed) {\n this.bytesUsed = options.bytesUsed;\n }\n const normalizedBatch = this.aggregator.getBatch() as TableBatch;\n normalizedBatch.count = this.batchCount;\n normalizedBatch.bytesUsed = this.bytesUsed;\n Object.assign(normalizedBatch, options);\n\n this.batchCount++;\n this.aggregator = null;\n return normalizedBatch;\n }\n\n private _getTableBatchType(): TableBatchConstructor {\n switch (this.options.shape) {\n case 'row-table':\n return BaseTableBatchAggregator;\n case 'array-row-table':\n case 'object-row-table':\n return RowTableBatchAggregator;\n case 'columnar-table':\n return ColumnarTableBatchAggregator;\n case 'arrow-table':\n if (!TableBatchBuilder.ArrowBatch) {\n throw new Error(ERR_MESSAGE);\n }\n return TableBatchBuilder.ArrowBatch;\n default:\n throw new Error(ERR_MESSAGE);\n }\n }\n}\n","// TextDecoder iterators\n// TextDecoder will keep any partial undecoded bytes between calls to `decode`\n\nexport async function* makeTextDecoderIterator(\n arrayBufferIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options: TextDecoderOptions = {}\n): AsyncIterable<string> {\n const textDecoder = new TextDecoder(undefined, options);\n for await (const arrayBuffer of arrayBufferIterator) {\n yield typeof arrayBuffer === 'string'\n ? arrayBuffer\n : textDecoder.decode(arrayBuffer, {stream: true});\n }\n}\n\n// TextEncoder iterator\n// TODO - this is not useful unless min chunk size is given\n// TextEncoder will keep any partial undecoded bytes between calls to `encode`\n// If iterator does not yield strings, assume arrayBuffer and return unencoded\n\nexport async function* makeTextEncoderIterator(\n textIterator: AsyncIterable<string> | Iterable<ArrayBuffer>\n): AsyncIterable<ArrayBuffer> {\n const textEncoder = new TextEncoder();\n for await (const text of textIterator) {\n yield typeof text === 'string' ? textEncoder.encode(text) : text;\n }\n}\n\n/**\n * @param textIterator async iterable yielding strings\n * @returns an async iterable over lines\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\n\nexport async function* makeLineIterator(\n textIterator: AsyncIterable<string>\n): AsyncIterable<string> {\n let previous = '';\n for await (const textChunk of textIterator) {\n previous += textChunk;\n let eolIndex;\n while ((eolIndex = previous.indexOf('\\n')) >= 0) {\n // line includes the EOL\n const line = previous.slice(0, eolIndex + 1);\n previous = previous.slice(eolIndex + 1);\n yield line;\n }\n }\n\n if (previous.length > 0) {\n yield previous;\n }\n}\n\n/**\n * @param lineIterator async iterable yielding lines\n * @returns async iterable yielding numbered lines\n *\n * See http://2ality.com/2018/04/async-iter-nodejs.html\n */\nexport async function* makeNumberedLineIterator(\n lineIterator: AsyncIterable<string>\n): AsyncIterable<{counter: number; line: string}> {\n let counter = 1;\n for await (const line of lineIterator) {\n yield {counter, line};\n counter++;\n }\n}\n","/* eslint-disable */\n// @ts-nocheck\nconst env = {};\n\nexport const EVENTS = [\n 'value',\n 'string',\n 'key',\n 'openobject',\n 'closeobject',\n 'openarray',\n 'closearray',\n 'error',\n 'end',\n 'ready'\n];\n\n// Removes the MAX_BUFFER_LENGTH, originally set to 64 * 1024\nconst MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;\nconst DEBUG = env.CDEBUG === 'debug';\n\nconst buffers = {\n textNode: undefined,\n numberNode: ''\n};\n\nlet S = 0;\n\nconst STATE = {\n BEGIN: S++,\n VALUE: S++, // general stuff\n OPEN_OBJECT: S++, // {\n CLOSE_OBJECT: S++, // }\n OPEN_ARRAY: S++, // [\n CLOSE_ARRAY: S++, // ]\n TEXT_ESCAPE: S++, // \\ stuff\n STRING: S++, // \"\"\n BACKSLASH: S++,\n END: S++, // No more stack\n OPEN_KEY: S++, // , \"a\"\n CLOSE_KEY: S++, // :\n TRUE: S++, // r\n TRUE2: S++, // u\n TRUE3: S++, // e\n FALSE: S++, // a\n FALSE2: S++, // l\n FALSE3: S++, // s\n FALSE4: S++, // e\n NULL: S++, // u\n NULL2: S++, // l\n NULL3: S++, // l\n NUMBER_DECIMAL_POINT: S++, // .\n NUMBER_DIGIT: S++ // [0-9]\n};\n\nfor (var s_ in STATE) STATE[STATE[s_]] = s_;\n\n// switcharoo\nS = STATE;\n\nconst Char = {\n tab: 0x09, // \\t\n lineFeed: 0x0a, // \\n\n carriageReturn: 0x0d, // \\r\n space: 0x20, // \" \"\n\n doubleQuote: 0x22, // \"\n plus: 0x2b, // +\n comma: 0x2c, // ,\n minus: 0x2d, // -\n period: 0x2e, // .\n\n _0: 0x30, // 0\n _9: 0x39, // 9\n\n colon: 0x3a, // :\n\n E: 0x45, // E\n\n openBracket: 0x5b, // [\n backslash: 0x5c, // \\\n closeBracket: 0x5d, // ]\n\n a: 0x61, // a\n b: 0x62, // b\n e: 0x65, // e\n f: 0x66, // f\n l: 0x6c, // l\n n: 0x6e, // n\n r: 0x72, // r\n s: 0x73, // s\n t: 0x74, // t\n u: 0x75, // u\n\n openBrace: 0x7b, // {\n closeBrace: 0x7d // }\n};\n\nfunction checkBufferLength(parser) {\n const maxAllowed = Math.max(MAX_BUFFER_LENGTH, 10);\n let maxActual = 0;\n\n for (var buffer in buffers) {\n var len = parser[buffer] === undefined ? 0 : parser[buffer].length;\n if (len > maxAllowed) {\n switch (buffer) {\n case 'text':\n closeText(parser);\n break;\n\n default:\n error(parser, 'Max buffer length exceeded: ' + buffer);\n }\n }\n maxActual = Math.max(maxActual, len);\n }\n parser.bufferCheckPosition = MAX_BUFFER_LENGTH - maxActual + parser.position;\n}\n\nvar stringTokenPattern = /[\\\\\"\\n]/g;\n\nexport default class ClarinetParser {\n constructor(options = {}) {\n this._initialize(options);\n }\n\n _initialize(options) {\n this._clearBuffers(this);\n this.bufferCheckPosition = MAX_BUFFER_LENGTH;\n this.q = '';\n this.c = '';\n this.p = '';\n this.options = options || {};\n this.closed = false;\n this.closedRoot = false;\n this.sawRoot = false;\n this.tag = null;\n this.error = null;\n this.state = S.BEGIN;\n this.stack = new Array();\n // mostly just for error reporting\n this.position = this.column = 0;\n this.line = 1;\n this.slashed = false;\n this.unicodeI = 0;\n this.unicodeS = null;\n this.depth = 0;\n\n // install callbacks\n if ('onready' in options) {\n this.onready = options.onready;\n }\n\n if ('onopenobject' in options) {\n this.onopenobject = options.onopenobject;\n }\n\n if ('onkey' in options) {\n this.onkey = options.onkey;\n }\n\n if ('oncloseobject' in options) {\n this.oncloseobject = options.oncloseobject;\n }\n\n if ('onopenarray' in options) {\n this.onopenarray = options.onopenarray;\n }\n\n if ('onclosearray' in options) {\n this.onclosearray = options.onclosearray;\n }\n\n if ('onvalue' in options) {\n this.onvalue = options.onvalue;\n }\n\n if ('onerror' in options) {\n this.onerror = options.onerror;\n }\n\n if ('onend' in options) {\n this.onend = options.onend;\n }\n\n if ('onchunkparsed' in options) {\n this.onchunkparsed = options.onchunkparsed;\n }\n\n emit(this, 'onready');\n }\n\n _clearBuffers() {\n for (var buffer in buffers) {\n this[buffer] = buffers[buffer];\n }\n }\n\n end() {\n if (this.state !== S.VALUE || this.depth !== 0) error(this, 'Unexpected end');\n\n closeValue(this);\n this.c = '';\n this.closed = true;\n emit(this, 'onend');\n this._initialize(this.options);\n return this;\n }\n\n resume() {\n this.error = null;\n return this;\n }\n\n close() {\n return this.write(null);\n }\n\n write(chunk) {\n if (this.error) {\n throw this.error;\n }\n if (this.closed) {\n return error(this, 'Cannot write after close. Assign an onready handler.');\n }\n if (chunk === null) {\n return this.end();\n }\n var i = 0,\n c = chunk.charCodeAt(0),\n p = this.p;\n if (DEBUG) console.log('write -> [' + chunk + ']');\n while (c) {\n p = c;\n this.c = c = chunk.charCodeAt(i++);\n // if chunk doesnt have next, like streaming char by char\n // this way we need to check if previous is really previous\n // if not we need to reset to what the this says is the previous\n // from buffer\n if (p !== c) {\n this.p = p;\n } else {\n p = this.p;\n }\n\n if (!c) break;\n\n if (DEBUG) console.log(i, c, STATE[this.state]);\n this.position++;\n if (c === Char.lineFeed) {\n this.line++;\n this.column = 0;\n } else this.column++;\n\n switch (this.state) {\n case S.BEGIN:\n if (c === Char.openBrace) this.state = S.OPEN_OBJECT;\n else if (c === Char.openBracket) this.state = S.OPEN_ARRAY;\n else if (!isWhitespace(c)) {\n error(this, 'Non-whitespace before {[.');\n }\n continue;\n\n case S.OPEN_KEY:\n case S.OPEN_OBJECT:\n if (isWhitespace(c)) continue;\n if (this.state === S.OPEN_KEY) this.stack.push(S.CLOSE_KEY);\n else {\n if (c === Char.closeBrace) {\n emit(this, 'onopenobject');\n this.depth++;\n emit(this, 'oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || S.VALUE;\n continue;\n } else this.stack.push(S.CLOSE_OBJECT);\n }\n if (c === Char.doubleQuote) this.state = S.STRING;\n else error(this, 'Malformed object key should start with \"');\n continue;\n\n case S.CLOSE_KEY:\n case S.CLOSE_OBJECT:\n if (isWhitespace(c)) continue;\n var event = this.state === S.CLOSE_KEY ? 'key' : 'object';\n if (c === Char.colon) {\n if (this.state === S.CLOSE_OBJECT) {\n this.stack.push(S.CLOSE_OBJECT);\n closeValue(this, 'onopenobject');\n this.depth++;\n } else closeValue(this, 'onkey');\n this.state = S.VALUE;\n } else if (c === Char.closeBrace) {\n emitNode(this, 'oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || S.VALUE;\n } else if (c === Char.comma) {\n if (this.state === S.CLOSE_OBJECT) this.stack.push(S.CLOSE_OBJECT);\n closeValue(this);\n this.state = S.OPEN_KEY;\n } else error(this, 'Bad object');\n continue;\n\n case S.OPEN_ARRAY: // after an array there always a value\n case S.VALUE:\n if (isWhitespace(c)) continue;\n if (this.state === S.OPEN_ARRAY) {\n emit(this, 'onopenarray');\n this.depth++;\n this.state = S.VALUE;\n if (c === Char.closeBracket) {\n emit(this, 'onclosearray');\n this.depth--;\n this.state = this.stack.pop() || S.VALUE;\n continue;\n } else {\n this.stack.push(S.CLOSE_ARRAY);\n }\n }\n if (c === Char.doubleQuote) this.state = S.STRING;\n else if (c === Char.openBrace) this.state = S.OPEN_OBJECT;\n else if (c === Char.openBracket) this.state = S.OPEN_ARRAY;\n else if (c === Char.t) this.state = S.TRUE;\n else if (c === Char.f) this.state = S.FALSE;\n else if (c === Char.n) this.state = S.NULL;\n else if (c === Char.minus) {\n // keep and continue\n this.numberNode += '-';\n } else if (Char._0 <= c && c <= Char._9) {\n this.numberNode += String.fromCharCode(c);\n this.state = S.NUMBER_DIGIT;\n } else error(this, 'Bad value');\n continue;\n\n case S.CLOSE_ARRAY:\n if (c === Char.comma) {\n this.stack.push(S.CLOSE_ARRAY);\n closeValue(this, 'onvalue');\n this.state = S.VALUE;\n } else if (c === Char.closeBracket) {\n emitNode(this, 'onclosearray');\n this.depth--;\n this.state = this.stack.pop() || S.VALUE;\n } else if (isWhitespace(c)) continue;\n else error(this, 'Bad array');\n continue;\n\n case S.STRING:\n if (this.textNode === undefined) {\n this.textNode = '';\n }\n\n // thanks thejh, this is an about 50% performance improvement.\n var starti = i - 1,\n slashed = this.slashed,\n unicodeI = this.unicodeI;\n STRING_BIGLOOP: while (true) {\n if (DEBUG) console.log(i, c, STATE[this.state], slashed);\n // zero means \"no unicode active\". 1-4 mean \"parse some more\". end after 4.\n while (unicodeI > 0) {\n this.unicodeS += String.fromCharCode(c);\n c = chunk.charCodeAt(i++);\n this.position++;\n if (unicodeI === 4) {\n // TODO this might be slow? well, probably not used too often anyway\n this.textNode += String.fromCharCode(parseInt(this.unicodeS, 16));\n unicodeI = 0;\n starti = i - 1;\n } else {\n unicodeI++;\n }\n // we can just break here: no stuff we skipped that still has to be sliced out or so\n if (!c) break STRING_BIGLOOP;\n }\n if (c === Char.doubleQuote && !slashed) {\n this.state = this.stack.pop() || S.VALUE;\n this.textNode += chunk.substring(starti, i - 1);\n this.position += i - 1 - starti;\n break;\n }\n if (c === Char.backslash && !slashed) {\n slashed = true;\n this.textNode += chunk.substring(starti, i - 1);\n this.position += i - 1 - starti;\n c = chunk.charCodeAt(i++);\n this.position++;\n if (!c) break;\n }\n if (slashed) {\n slashed = false;\n if (c === Char.n) {\n this.textNode += '\\n';\n } else if (c === Char.r) {\n this.textNode += '\\r';\n } else if (c === Char.t) {\n this.textNode += '\\t';\n } else if (c === Char.f) {\n this.textNode += '\\f';\n } else if (c === Char.b) {\n this.textNode += '\\b';\n } else if (c === Char.u) {\n // \\uxxxx. meh!\n unicodeI = 1;\n this.unicodeS = '';\n } else {\n this.textNode += String.fromCharCode(c);\n }\n c = chunk.charCodeAt(i++);\n this.position++;\n starti = i - 1;\n if (!c) break;\n else continue;\n }\n\n stringTokenPattern.lastIndex = i;\n var reResult = stringTokenPattern.exec(chunk);\n if (reResult === null) {\n i = chunk.length + 1;\n this.textNode += chunk.substring(starti, i - 1);\n this.position += i - 1 - starti;\n break;\n }\n i = reResult.index + 1;\n c = chunk.charCodeAt(reResult.index);\n if (!c) {\n this.textNode += chunk.substring(starti, i - 1);\n this.position += i - 1 - starti;\n break;\n }\n }\n this.slashed = slashed;\n this.unicodeI = unicodeI;\n continue;\n\n case S.TRUE:\n if (c === Char.r) this.state = S.TRUE2;\n else error(this, 'Invalid true started with t' + c);\n continue;\n\n case S.TRUE2:\n if (c === Char.u) this.state = S.TRUE3;\n else error(this, 'Invalid true started with tr' + c);\n continue;\n\n case S.TRUE3:\n if (c === Char.e) {\n emit(this, 'onvalue', true);\n this.state = this.stack.pop() || S.VALUE;\n } else error(this, 'Invalid true started with tru' + c);\n continue;\n\n case S.FALSE:\n if (c === Char.a) this.state = S.FALSE2;\n else error(this, 'Invalid false started with f' + c);\n continue;\n\n case S.FALSE2:\n if (c === Char.l) this.state = S.FALSE3;\n else error(this, 'Invalid false started with fa' + c);\n continue;\n\n case S.FALSE3:\n if (c === Char.s) this.state = S.FALSE4;\n else error(this, 'Invalid false started with fal' + c);\n continue;\n\n case S.FALSE4:\n if (c === Char.e) {\n emit(this, 'onvalue', false);\n this.state = this.stack.pop() || S.VALUE;\n } else error(this, 'Invalid false started with fals' + c);\n continue;\n\n case S.NULL:\n if (c === Char.u) this.state = S.NULL2;\n else error(this, 'Invalid null started with n' + c);\n continue;\n\n case S.NULL2:\n if (c === Char.l) this.state = S.NULL3;\n else error(this, 'Invalid null started with nu' + c);\n continue;\n\n case S.NULL3:\n if (c === Char.l) {\n emit(this, 'onvalue', null);\n this.state = this.stack.pop() || S.VALUE;\n } else error(this, 'Invalid null started with nul' + c);\n continue;\n\n case S.NUMBER_DECIMAL_POINT:\n if (c === Char.period) {\n this.numberNode += '.';\n this.state = S.NUMBER_DIGIT;\n } else error(this, 'Leading zero not followed by .');\n continue;\n\n case S.NUMBER_DIGIT:\n if (Char._0 <= c && c <= Char._9) this.numberNode += String.fromCharCode(c);\n else if (c === Char.period) {\n if (this.numberNode.indexOf('.') !== -1) error(this, 'Invalid number has two dots');\n this.numberNode += '.';\n } else if (c === Char.e || c === Char.E) {\n if (this.numberNode.indexOf('e') !== -1 || this.numberNode.indexOf('E') !== -1)\n error(this, 'Invalid number has two exponential');\n this.numberNode += 'e';\n } else if (c === Char.plus || c === Char.minus) {\n if (!(p === Char.e || p === Char.E)) error(this, 'Invalid symbol in number');\n this.numberNode += String.fromCharCode(c);\n } else {\n closeNumber(this);\n i--; // go back one\n this.state = this.stack.pop() || S.VALUE;\n }\n continue;\n\n default:\n error(this, 'Unknown state: ' + this.state);\n }\n }\n if (this.position >= this.bufferCheckPosition) {\n checkBufferLength(this);\n }\n\n emit(this, 'onchunkparsed');\n\n return this;\n }\n}\n\nfunction emit(parser, event, data) {\n if (DEBUG) {\n console.log('-- emit', event, data);\n }\n if (parser[event]) {\n parser[event](data, parser);\n }\n}\n\nfunction emitNode(parser, event, data) {\n closeValue(parser);\n emit(parser, event, data);\n}\n\nfunction closeValue(parser, event) {\n parser.textNode = textopts(parser.options, parser.textNode);\n if (parser.textNode !== undefined) {\n emit(parser, event ? event : 'onvalue', parser.textNode);\n }\n parser.textNode = undefined;\n}\n\nfunction closeNumber(parser) {\n if (parser.numberNode) emit(parser, 'onvalue', parseFloat(parser.numberNode));\n parser.numberNode = '';\n}\n\nfunction textopts(opt, text) {\n if (text === undefined) {\n return text;\n }\n if (opt.trim) text = text.trim();\n if (opt.normalize) text = text.replace(/\\s+/g, ' ');\n return text;\n}\n\nfunction error(parser, er) {\n closeValue(parser);\n er += '\\nLine: ' + parser.line + '\\nColumn: ' + parser.column + '\\nChar: ' + parser.c;\n er = new Error(er);\n parser.error = er;\n emit(parser, 'onerror', er);\n return parser;\n}\n\nfunction isWhitespace(c) {\n return c === Char.carriageReturn || c === Char.lineFeed || c === Char.space || c === Char.tab;\n}\n","/**\n * A parser for a minimal subset of the jsonpath standard\n * Full JSON path parsers for JS exist but are quite large (bundle size)\n *\n * Supports\n *\n * `$.component.component.component`\n */\nexport default class JSONPath {\n path: string[];\n\n constructor(path: JSONPath | string[] | string | null = null) {\n this.path = ['$'];\n\n if (path instanceof JSONPath) {\n // @ts-ignore\n this.path = [...path.path];\n return;\n }\n\n if (Array.isArray(path)) {\n this.path.push(...path);\n return;\n }\n\n // Parse a string as a JSONPath\n if (typeof path === 'string') {\n this.path = path.split('.');\n if (this.path[0] !== '$') {\n throw new Error('JSONPaths must start with $');\n }\n }\n }\n\n clone(): JSONPath {\n return new JSONPath(this);\n }\n\n toString(): string {\n return this.path.join('.');\n }\n\n push(name: string): void {\n this.path.push(name);\n }\n\n pop() {\n return this.path.pop();\n }\n\n set(name: string): void {\n this.path[this.path.length - 1] = name;\n }\n\n equals(other: JSONPath): boolean {\n if (!this || !other || this.path.length !== other.path.length) {\n return false;\n }\n\n for (let i = 0; i < this.path.length; ++i) {\n if (this.path[i] !== other.path[i]) {\n return false;\n }\n }\n\n return true;\n }\n\n /**\n * Sets the value pointed at by path\n * TODO - handle root path\n * @param object\n * @param value\n */\n setFieldAtPath(object, value) {\n const path = [...this.path];\n path.shift();\n const field = path.pop();\n for (const component of path) {\n object = object[component];\n }\n // @ts-ignore\n object[field] = value;\n }\n\n /**\n * Gets the value pointed at by path\n * TODO - handle root path\n * @param object\n */\n getFieldAtPath(object) {\n const path = [...this.path];\n path.shift();\n const field = path.pop();\n for (const component of path) {\n object = object[component];\n }\n // @ts-ignore\n return object[field];\n }\n}\n","import {default as JSONParser} from './json-parser';\nimport JSONPath from '../jsonpath/jsonpath';\n\n/**\n * The `StreamingJSONParser` looks for the first array in the JSON structure.\n * and emits an array of chunks\n */\nexport default class StreamingJSONParser extends JSONParser {\n private jsonPaths: JSONPath[];\n private streamingJsonPath: JSONPath | null = null;\n private streamingArray: any[] | null = null;\n private topLevelObject: object | null = null;\n\n constructor(options: {[key: string]: any} = {}) {\n super();\n const jsonpaths = options.jsonpaths || [];\n this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));\n this._extendParser();\n }\n\n /**\n * write REDEFINITION\n * - super.write() chunk to parser\n * - get the contents (so far) of \"topmost-level\" array as batch of rows\n * - clear top-level array\n * - return the batch of rows\\\n */\n write(chunk) {\n super.write(chunk);\n let array: any[] = [];\n if (this.streamingArray) {\n array = [...this.streamingArray];\n this.streamingArray.length = 0;\n }\n return array;\n }\n\n /**\n * Returns a partially formed result object\n * Useful for returning the \"wrapper\" object when array is not top level\n * e.g. GeoJSON\n */\n getPartialResult() {\n return this.topLevelObject;\n }\n\n getStreamingJsonPath() {\n return this.streamingJsonPath;\n }\n\n getStreamingJsonPathAsString() {\n return this.streamingJsonPath && this.streamingJsonPath.toString();\n }\n\n getJsonPath() {\n return this.jsonpath;\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks is this.getJsonPath matches the jsonpaths provided in options\n */\n _matchJSONPath() {\n const currentPath = this.getJsonPath();\n // console.debug(`Testing JSONPath`, currentPath);\n\n // Backwards compatibility, match any array\n // TODO implement using wildcard once that is supported\n if (this.jsonPaths.length === 0) {\n return true;\n }\n\n for (const jsonPath of this.jsonPaths) {\n if (jsonPath.equals(currentPath)) {\n return true;\n }\n }\n\n return false;\n }\n\n _extendParser() {\n // Redefine onopenarray to locate and inject value for top-level array\n this.parser.onopenarray = () => {\n if (!this.streamingArray) {\n if (this._matchJSONPath()) {\n // @ts-ignore\n this.streamingJsonPath = this.getJsonPath().clone();\n this.streamingArray = [];\n this._openArray(this.streamingArray as []);\n return;\n }\n }\n\n this._openArray();\n };\n\n // Redefine onopenarray to inject value for top-level object\n this.parser.onopenobject = (name) => {\n if (!this.topLevelObject) {\n this.topLevelObject = {};\n this._openObject(this.topLevelObject);\n } else {\n this._openObject({});\n }\n if (typeof name !== 'undefined') {\n this.parser.onkey(name);\n }\n };\n }\n}\n","// @ts-nocheck\n\nimport ClarinetParser from '../clarinet/clarinet';\nimport JSONPath from '../jsonpath/jsonpath';\n\n// JSONParser builds a JSON object using the events emitted by the Clarinet parser\n\nexport default class JSONParser {\n jsonpath: JSONPath;\n _parser?: ClarinetParser;\n\n constructor() {\n this.reset();\n this._initializeParser();\n }\n\n reset(): void {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({container: [], key: null});\n this.jsonpath = new JSONPath();\n }\n\n write(chunk): void {\n this.parser.write(chunk);\n }\n\n close(): void {\n this.parser.close();\n }\n\n // PRIVATE METHODS\n\n _pushOrSet(value): void {\n const {container, key} = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n } else {\n container.push(value);\n }\n }\n\n _openArray(newContainer = []): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: true, key: null};\n }\n\n _closeArray(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _openObject(newContainer = {}): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: false, key: null};\n }\n\n _closeObject(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _initializeParser(): void {\n this._parser = new ClarinetParser({\n onready: () => {\n this.jsonpath = new JSONPath();\n this.previousStates.length = 0;\n this.currentState.container.length = 0;\n },\n\n onopenobject: (name) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.onkey(name);\n }\n },\n\n onkey: (name) => {\n this.jsonpath.set(name);\n this.currentState.key = name;\n },\n\n oncloseobject: () => {\n this._closeObject();\n },\n\n onopenarray: () => {\n this._openArray();\n },\n\n onclosearray: () => {\n this._closeArray();\n },\n\n onvalue: (value) => {\n this._pushOrSet(value);\n },\n\n onerror: (error) => {\n throw error;\n },\n\n onend: () => {\n this.result = this.currentState.container.pop();\n }\n });\n }\n\n protected get parser(): ClarinetParser {\n return this._parser as ClarinetParser;\n }\n}\n","import type {Batch} from '@loaders.gl/schema';\nimport type {JSONLoaderOptions} from '../json-loader';\nimport {TableBatchBuilder} from '@loaders.gl/schema';\nimport {makeTextDecoderIterator} from '@loaders.gl/loader-utils';\nimport StreamingJSONParser from './parser/streaming-json-parser';\n\n// TODO - support batch size 0 = no batching/single batch?\n// eslint-disable-next-line max-statements, complexity\nexport default async function* parseJSONInBatches(\n binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const asyncIterator = makeTextDecoderIterator(binaryAsyncIterator);\n\n const {metadata} = options;\n const {jsonpaths} = options.json || {};\n\n let isFirstChunk: boolean = true;\n\n // TODO fix Schema deduction\n const schema = null; // new Schema([]);\n const shape = options?.json?.shape || 'row-table';\n // @ts-ignore\n const tableBatchBuilder = new TableBatchBuilder(schema, {\n ...options,\n shape\n });\n\n const parser = new StreamingJSONParser({jsonpaths});\n\n for await (const chunk of asyncIterator) {\n const rows = parser.write(chunk);\n\n const jsonpath = rows.length > 0 && parser.getStreamingJsonPathAsString();\n\n if (rows.length > 0 && isFirstChunk) {\n if (metadata) {\n const initialBatch: Batch = {\n // Common fields\n shape,\n batchType: 'partial-result',\n data: [],\n length: 0,\n bytesUsed: 0,\n // JSON additions\n container: parser.getPartialResult(),\n jsonpath\n };\n yield initialBatch;\n }\n isFirstChunk = false;\n // schema = deduceSchema(rows);\n }\n\n // Add the row\n for (const row of rows) {\n tableBatchBuilder.addRow(row);\n // If a batch has been completed, emit it\n const batch = tableBatchBuilder.getFullBatch({jsonpath});\n if (batch) {\n yield batch;\n }\n }\n\n tableBatchBuilder.chunkComplete(chunk);\n const batch = tableBatchBuilder.getFullBatch({jsonpath});\n if (batch) {\n yield batch;\n }\n }\n\n // yield final batch\n const jsonpath = parser.getStreamingJsonPathAsString();\n const batch = tableBatchBuilder.getFinalBatch({jsonpath});\n if (batch) {\n yield batch;\n }\n\n if (metadata) {\n const finalBatch: Batch = {\n shape,\n batchType: 'final-result',\n container: parser.getPartialResult(),\n jsonpath: parser.getStreamingJsonPathAsString(),\n data: [],\n length: 0\n // schema: null\n };\n yield finalBatch;\n }\n}\n","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","import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseNDJSONSync from './lib/parse-ndjson';\nimport parseNDJSONInBatches from './lib/parse-ndjson-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 const NDJSONLoader: LoaderWithParser = {\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson'],\n mimeTypes: ['application/x-ndjson'],\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: {}\n};\n\nasync function parse(arrayBuffer: ArrayBuffer) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer));\n}\n\nfunction parseTextSync(text: string) {\n return parseNDJSONSync(text);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptions\n): AsyncIterable<Batch> {\n return parseNDJSONInBatches(asyncIterator, options);\n}\n","import type {Batch} from '@loaders.gl/schema';\nimport {TableBatchBuilder} from '@loaders.gl/schema';\nimport {\n LoaderOptions,\n makeLineIterator,\n makeNumberedLineIterator,\n makeTextDecoderIterator\n} from '@loaders.gl/loader-utils';\n\nexport default async function* parseNDJSONInBatches(\n binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptions\n): AsyncIterable<Batch> {\n const textIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const lineIterator = makeLineIterator(textIterator);\n const numberedLineIterator = makeNumberedLineIterator(lineIterator);\n\n const schema = null;\n const shape = 'row-table';\n // @ts-ignore\n const tableBatchBuilder = new TableBatchBuilder(schema, {\n ...options,\n shape\n });\n\n for await (const {counter, line} of numberedLineIterator) {\n try {\n const row = JSON.parse(line);\n tableBatchBuilder.addRow(row);\n tableBatchBuilder.chunkComplete(line);\n const batch = tableBatchBuilder.getFullBatch();\n if (batch) {\n yield batch;\n }\n } catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter}`);\n }\n }\n\n const batch = tableBatchBuilder.getFinalBatch();\n if (batch) {\n yield batch;\n }\n}\n","export default function parseNDJSONSync(ndjsonText: string) {\n const lines = ndjsonText.trim().split('\\n');\n return lines.map((line, counter) => {\n try {\n return JSON.parse(line);\n } catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);\n }\n });\n}\n","import {Feature, GeoJsonProperties} from '@loaders.gl/schema';\nimport type {BinaryFeatures} from '@loaders.gl/schema';\n\nexport type GeojsonToBinaryOptions = {\n coordLength?: number;\n numericPropKeys?: string[];\n PositionDataType?: Function;\n};\n\n/** Convert GeoJSON features to flat binary arrays */\nexport function geojsonToBinary(\n features: Feature[],\n options: GeojsonToBinaryOptions = {}\n): BinaryFeatures {\n const firstPassData = firstPass(features);\n return secondPass(features, firstPassData, {\n coordLength: options.coordLength || firstPassData.coordLength,\n numericPropKeys: options.numericPropKeys || firstPassData.numericPropKeys,\n PositionDataType: options.PositionDataType || Float32Array\n });\n}\n\nexport const TEST_EXPORTS = {\n firstPass,\n secondPass\n};\n\ntype FirstPassData = {\n coordLength: number;\n numericPropKeys: string[];\n\n pointPositionsCount: number;\n pointFeaturesCount: number;\n linePositionsCount: number;\n linePathsCount: number;\n lineFeaturesCount: number;\n polygonPositionsCount: number;\n polygonObjectsCount: number;\n polygonRingsCount: number;\n polygonFeaturesCount: number;\n};\n\n/**\n * Initial scan over GeoJSON features\n * Counts number of coordinates of each geometry type and\n * keeps track of the max coordinate dimensions\n */\n// eslint-disable-next-line complexity, max-statements\nfunction firstPass(features: Feature[]): FirstPassData {\n // Counts the number of _positions_, so [x, y, z] counts as one\n let pointPositionsCount = 0;\n let pointFeaturesCount = 0;\n let linePositionsCount = 0;\n let linePathsCount = 0;\n let lineFeaturesCount = 0;\n let polygonPositionsCount = 0;\n let polygonObjectsCount = 0;\n let polygonRingsCount = 0;\n let polygonFeaturesCount = 0;\n const coordLengths = new Set<number>();\n const numericPropKeys = {};\n\n for (const feature of features) {\n const geometry = feature.geometry;\n switch (geometry.type) {\n case 'Point':\n pointFeaturesCount++;\n pointPositionsCount++;\n coordLengths.add(geometry.coordinates.length);\n break;\n case 'MultiPoint':\n pointFeaturesCount++;\n pointPositionsCount += geometry.coordinates.length;\n for (const point of geometry.coordinates) {\n coordLengths.add(point.length);\n }\n break;\n case 'LineString':\n lineFeaturesCount++;\n linePositionsCount += geometry.coordinates.length;\n linePathsCount++;\n\n for (const coord of geometry.coordinates) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiLineString':\n lineFeaturesCount++;\n for (const line of geometry.coordinates) {\n linePositionsCount += line.length;\n linePathsCount++;\n\n // eslint-disable-next-line max-depth\n for (const coord of line) {\n coordLengths.add(coord.length);\n }\n }\n break;\n case 'Polygon':\n polygonFeaturesCount++;\n polygonObjectsCount++;\n polygonRingsCount += geometry.coordinates.length;\n polygonPositionsCount += flatten(geometry.coordinates).length;\n\n for (const coord of flatten(geometry.coordinates)) {\n coordLengths.add(coord.length);\n }\n break;\n case 'MultiPolygon':\n polygonFeaturesCount++;\n for (const polygon of geometry.coordinates) {\n polygonObjectsCount++;\n polygonRingsCount += polygon.length;\n polygonPositionsCount += flatten(polygon).length;\n\n // eslint-disable-next-line max-depth\n for (const coord of flatten(polygon)) {\n coordLengths.add(coord.length);\n }\n }\n break;\n default:\n throw new Error(`Unsupported geometry type: ${geometry.type}`);\n }\n\n if (feature.properties) {\n for (const key in feature.properties) {\n const val = feature.properties[key];\n\n // If property has not been seen before, or if property has been numeric\n // in all previous features, check if numeric in this feature\n // If not numeric, false is stored to prevent rechecking in the future\n numericPropKeys[key] =\n numericPropKeys[key] || numericPropKeys[key] === undefined\n ? isNumeric(val)\n : numericPropKeys[key];\n }\n }\n }\n\n return {\n coordLength: coordLengths.size > 0 ? Math.max(...coordLengths) : 2,\n\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount,\n\n // Array of keys whose values are always numeric\n numericPropKeys: Object.keys(numericPropKeys).filter((k) => numericPropKeys[k])\n };\n}\n\n/**\n * Second scan over GeoJSON features\n * Fills coordinates into pre-allocated typed arrays\n */\n// eslint-disable-next-line complexity\nfunction secondPass(\n features,\n firstPassData: FirstPassData,\n options: Required<GeojsonToBinaryOptions>\n) {\n const {\n pointPositionsCount,\n pointFeaturesCount,\n linePositionsCount,\n linePathsCount,\n lineFeaturesCount,\n polygonPositionsCount,\n polygonObjectsCount,\n polygonRingsCount,\n polygonFeaturesCount\n } = firstPassData;\n const {coordLength, numericPropKeys, PositionDataType = Float32Array} = options;\n const GlobalFeatureIdsDataType = features.length > 65535 ? Uint32Array : Uint16Array;\n const points = {\n // @ts-ignore Typescript doesn't like dynamic constructors\n positions: new PositionDataType(pointPositionsCount * coordLength),\n globalFeatureIds: new GlobalFeatureIdsDataType(pointPositionsCount),\n featureIds:\n pointFeaturesCount > 65535\n ? new Uint32Array(pointPositionsCount)\n : new Uint16Array(pointPositionsCount),\n numericProps: {},\n properties: Array<any>(),\n fields: Array<any>()\n };\n const lines = {\n // @ts-ignore Typescript doesn't like dynamic constructors\n positions: new PositionDataType(linePositionsCount * coordLength),\n pathIndices:\n linePositionsCount > 65535\n ? new Uint32Array(linePathsCount + 1)\n : new Uint16Array(linePathsCount + 1),\n globalFeatureIds: new GlobalFeatureIdsDataType(linePositionsCount),\n featureIds:\n lineFeaturesCount > 65535\n ? new Uint32Array(linePositionsCount)\n : new Uint16Array(linePositionsCount),\n numericProps: {},\n properties: Array<any>(),\n fields: Array<any>()\n };\n const polygons = {\n // @ts-ignore Typescript doesn't like dynamic constructors\n positions: new PositionDataType(polygonPositionsCount * coordLength),\n polygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonObjectsCount + 1)\n : new Uint16Array(polygonObjectsCount + 1),\n primitivePolygonIndices:\n polygonPositionsCount > 65535\n ? new Uint32Array(polygonRingsCount + 1)\n : new Uint16Array(polygonRingsCount + 1),\n globalFeatureIds: new GlobalFeatureIdsDataType(polygonPositionsCount),\n featureIds:\n polygonFeaturesCount > 65535\n ? new Uint32Array(polygonPositionsCount)\n : new Uint16Array(polygonPositionsCount),\n numericProps: {},\n properties: Array<any>(),\n fields: Array<any>()\n };\n\n // Instantiate numeric properties arrays; one value per vertex\n for (const object of [points, lines, polygons]) {\n for (const propName of numericPropKeys || []) {\n // If property has been numeric in all previous features in which the property existed, check\n // if numeric in this feature\n object.numericProps[propName] = new Float32Array(object.positions.length / coordLength);\n }\n }\n\n // Set last element of path/polygon indices as positions length\n lines.pathIndices[linePathsCount] = linePositionsCount;\n polygons.polygonIndices[polygonObjectsCount] = polygonPositionsCount;\n polygons.primitivePolygonIndices[polygonRingsCount] = polygonPositionsCount;\n\n const indexMap = {\n pointPosition: 0,\n pointFeature: 0,\n linePosition: 0,\n linePath: 0,\n lineFeature: 0,\n polygonPosition: 0,\n polygonObject: 0,\n polygonRing: 0,\n polygonFeature: 0,\n feature: 0\n };\n\n for (const feature of features) {\n const geometry = feature.geometry;\n const properties: GeoJsonProperties = feature.properties || {};\n\n switch (geometry.type) {\n case 'Point':\n handlePoint(geometry.coordinates, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.pointFeature++;\n break;\n case 'MultiPoint':\n handleMultiPoint(geometry.coordinates, points, indexMap, coordLength, properties);\n points.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.pointFeature++;\n break;\n case 'LineString':\n handleLineString(geometry.coordinates, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.lineFeature++;\n break;\n case 'MultiLineString':\n handleMultiLineString(geometry.coordinates, lines, indexMap, coordLength, properties);\n lines.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.lineFeature++;\n break;\n case 'Polygon':\n handlePolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.polygonFeature++;\n break;\n case 'MultiPolygon':\n handleMultiPolygon(geometry.coordinates, polygons, indexMap, coordLength, properties);\n polygons.properties.push(keepStringProperties(properties, numericPropKeys));\n indexMap.polygonFeature++;\n break;\n default:\n throw new Error('Invalid geometry type');\n }\n\n indexMap.feature++;\n }\n\n // Wrap each array in an accessor object with value and size keys\n return makeAccessorObjects(points, lines, polygons, coordLength);\n}\n\n/** Fills Point coordinates into points object of arrays */\nfunction handlePoint(coords, points, indexMap, coordLength, properties) {\n points.positions.set(coords, indexMap.pointPosition * coordLength);\n points.globalFeatureIds[indexMap.pointPosition] = indexMap.feature;\n points.featureIds[indexMap.pointPosition] = indexMap.pointFeature;\n\n fillNumericProperties(points, properties, indexMap.pointPosition, 1);\n indexMap.pointPosition++;\n}\n\n/** Fills MultiPoint coordinates into points object of arrays */\nfunction handleMultiPoint(coords, points, indexMap, coordLength, properties) {\n for (const point of coords) {\n handlePoint(point, points, indexMap, coordLength, properties);\n }\n}\n\n/** Fills LineString coordinates into lines object of arrays */\nfunction handleLineString(coords, lines, indexMap, coordLength, properties) {\n lines.pathIndices[indexMap.linePath] = indexMap.linePosition;\n indexMap.linePath++;\n\n fillCoords(lines.positions, coords, indexMap.linePosition, coordLength);\n\n const nPositions = coords.length;\n fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);\n\n lines.globalFeatureIds.set(\n new Uint32Array(nPositions).fill(indexMap.feature),\n indexMap.linePosition\n );\n lines.featureIds.set(\n new Uint32Array(nPositions).fill(indexMap.lineFeature),\n indexMap.linePosition\n );\n indexMap.linePosition += nPositions;\n}\n\n/** Fills MultiLineString coordinates into lines object of arrays */\nfunction handleMultiLineString(coords, lines, indexMap, coordLength, properties) {\n for (const line of coords) {\n handleLineString(line, lines, indexMap, coordLength, properties);\n }\n}\n\n/** Fills Polygon coordinates into polygons object of arrays */\nfunction handlePolygon(coords, polygons, indexMap, coordLength, properties) {\n polygons.polygonIndices[indexMap.polygonObject] = indexMap.polygonPosition;\n indexMap.polygonObject++;\n\n for (const ring of coords) {\n polygons.primitivePolygonIndices[indexMap.polygonRing] = indexMap.polygonPosition;\n indexMap.polygonRing++;\n\n fillCoords(polygons.positions, ring, indexMap.polygonPosition, coordLength);\n\n const nPositions = ring.length;\n fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);\n\n polygons.globalFeatureIds.set(\n new Uint32Array(nPositions).fill(indexMap.feature),\n indexMap.polygonPosition\n );\n polygons.featureIds.set(\n new Uint32Array(nPositions).fill(indexMap.polygonFeature),\n indexMap.polygonPosition\n );\n indexMap.polygonPosition += nPositions;\n }\n}\n\n/** Fills MultiPolygon coordinates into polygons object of arrays */\nfunction handleMultiPolygon(coords, polygons, indexMap, coordLength, properties) {\n for (const polygon of coords) {\n handlePolygon(polygon, polygons, indexMap, coordLength, properties);\n }\n}\n\n/** Wrap each array in an accessor object with value and size keys */\nfunction makeAccessorObjects(points, lines, polygons, coordLength): BinaryFeatures {\n const returnObj = {\n points: {\n ...points,\n positions: {value: points.positions, size: coordLength},\n globalFeatureIds: {value: points.globalFeatureIds, size: 1},\n featureIds: {value: points.featureIds, size: 1},\n type: 'Point'\n },\n lines: {\n ...lines,\n pathIndices: {value: lines.pathIndices, size: 1},\n positions: {value: lines.positions, size: coordLength},\n globalFeatureIds: {value: lines.globalFeatureIds, size: 1},\n featureIds: {value: lines.featureIds, size: 1},\n type: 'LineString'\n },\n polygons: {\n ...polygons,\n polygonIndices: {value: polygons.polygonIndices, size: 1},\n primitivePolygonIndices: {value: polygons.primitivePolygonIndices, size: 1},\n positions: {value: polygons.positions, size: coordLength},\n globalFeatureIds: {value: polygons.globalFeatureIds, size: 1},\n featureIds: {value: polygons.featureIds, size: 1},\n type: 'Polygon'\n }\n };\n\n for (const geomType in returnObj) {\n for (const numericProp in returnObj[geomType].numericProps) {\n returnObj[geomType].numericProps[numericProp] = {\n value: returnObj[geomType].numericProps[numericProp],\n size: 1\n };\n }\n }\n\n return returnObj as unknown as BinaryFeatures;\n}\n\n/** Add numeric properties to object */\nfunction fillNumericProperties(object, properties, index, length) {\n for (const numericPropName in object.numericProps) {\n if (numericPropName in properties) {\n object.numericProps[numericPropName].set(\n new Array(length).fill(properties[numericPropName]),\n index\n );\n }\n }\n}\n\n/** Keep string properties in object */\nfunction keepStringProperties(properties, numericKeys: string[]): GeoJsonProperties {\n const props = {};\n for (const key in properties) {\n if (!numericKeys.includes(key)) {\n props[key] = properties[key];\n }\n }\n return props;\n}\n\n/** @param coords is expected to be a list of arrays, each with length 2-3 */\nfunction fillCoords(array, coords, startVertex, coordLength): void {\n let index = startVertex * coordLength;\n for (const coord of coords) {\n array.set(coord, index);\n index += coordLength;\n }\n}\n\n// TODO - how does this work? Different `coordinates` have different nesting\nfunction flatten(arrays): number[][] {\n return [].concat(...arrays);\n}\n\nfunction isNumeric(x: any): boolean {\n return Number.isFinite(x);\n}\n","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"],"sourceRoot":""}
|