@loaders.gl/json 4.3.0-alpha.7 → 4.3.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -831,52 +831,6 @@ var __exports__ = (() => {
831
831
  }
832
832
  }
833
833
 
834
- // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
835
- function _typeof(obj) {
836
- "@babel/helpers - typeof";
837
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
838
- return typeof obj2;
839
- } : function(obj2) {
840
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
841
- }, _typeof(obj);
842
- }
843
-
844
- // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
845
- function _toPrimitive(input, hint) {
846
- if (_typeof(input) !== "object" || input === null)
847
- return input;
848
- var prim = input[Symbol.toPrimitive];
849
- if (prim !== void 0) {
850
- var res = prim.call(input, hint || "default");
851
- if (_typeof(res) !== "object")
852
- return res;
853
- throw new TypeError("@@toPrimitive must return a primitive value.");
854
- }
855
- return (hint === "string" ? String : Number)(input);
856
- }
857
-
858
- // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
859
- function _toPropertyKey(arg) {
860
- var key = _toPrimitive(arg, "string");
861
- return _typeof(key) === "symbol" ? key : String(key);
862
- }
863
-
864
- // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
865
- function _defineProperty(obj, key, value) {
866
- key = _toPropertyKey(key);
867
- if (key in obj) {
868
- Object.defineProperty(obj, key, {
869
- value,
870
- enumerable: true,
871
- configurable: true,
872
- writable: true
873
- });
874
- } else {
875
- obj[key] = value;
876
- }
877
- return obj;
878
- }
879
-
880
834
  // ../loader-utils/src/lib/binary-utils/array-buffer-utils.ts
881
835
  function concatenateArrayBuffers(...sources) {
882
836
  return concatenateArrayBuffersFromArray(sources);
@@ -1897,11 +1851,7 @@ Char: ${this.c}`;
1897
1851
  z: 2
1898
1852
  };
1899
1853
  function getPolygonSignedArea(points, options = {}) {
1900
- const {
1901
- start = 0,
1902
- end = points.length,
1903
- plane = "xy"
1904
- } = options;
1854
+ const { start = 0, end = points.length, plane = "xy" } = options;
1905
1855
  const dim = options.size || 2;
1906
1856
  let area2 = 0;
1907
1857
  const i0 = DimIndex[plane[0]];
@@ -1955,12 +1905,7 @@ Char: ${this.c}`;
1955
1905
  let i;
1956
1906
  let last;
1957
1907
  if (area2 === void 0) {
1958
- area2 = getPolygonSignedArea(data, {
1959
- start,
1960
- end,
1961
- size: dim,
1962
- plane
1963
- });
1908
+ area2 = getPolygonSignedArea(data, { start, end, size: dim, plane });
1964
1909
  }
1965
1910
  let i0 = DimIndex[plane[0]];
1966
1911
  let i1 = DimIndex[plane[1]];
@@ -2295,7 +2240,10 @@ Char: ${this.c}`;
2295
2240
  return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
2296
2241
  }
2297
2242
  function isValidDiagonal(a, b) {
2298
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
2243
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
2244
+ (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
2245
+ (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
2246
+ equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
2299
2247
  }
2300
2248
  function area(p, q, r) {
2301
2249
  return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -2388,15 +2336,12 @@ Char: ${this.c}`;
2388
2336
  }
2389
2337
  var Vertex = class {
2390
2338
  constructor(i, x, y) {
2391
- _defineProperty(this, "i", void 0);
2392
- _defineProperty(this, "x", void 0);
2393
- _defineProperty(this, "y", void 0);
2394
- _defineProperty(this, "prev", null);
2395
- _defineProperty(this, "next", null);
2396
- _defineProperty(this, "z", 0);
2397
- _defineProperty(this, "prevZ", null);
2398
- _defineProperty(this, "nextZ", null);
2399
- _defineProperty(this, "steiner", false);
2339
+ this.prev = null;
2340
+ this.next = null;
2341
+ this.z = 0;
2342
+ this.prevZ = null;
2343
+ this.nextZ = null;
2344
+ this.steiner = false;
2400
2345
  this.i = i;
2401
2346
  this.x = x;
2402
2347
  this.y = y;
package/dist/dist.min.js CHANGED
@@ -4,18 +4,18 @@
4
4
  else if (typeof define === 'function' && define.amd) define([], factory);
5
5
  else if (typeof exports === 'object') exports['loaders'] = factory();
6
6
  else root['loaders'] = factory();})(globalThis, function () {
7
- "use strict";var __exports__=(()=>{var gt=Object.create;var D=Object.defineProperty;var xt=Object.getOwnPropertyDescriptor;var wt=Object.getOwnPropertyNames;var bt=Object.getPrototypeOf,At=Object.prototype.hasOwnProperty;var Pt=(t,e,r)=>e in t?D(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var jt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),Nt=(t,e)=>{for(var r in e)D(t,r,{get:e[r],enumerable:!0})},Q=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of wt(e))!At.call(t,n)&&n!==r&&D(t,n,{get:()=>e[n],enumerable:!(o=xt(e,n))||o.enumerable});return t},X=(t,e,r)=>(Q(t,e,"default"),r&&Q(r,e,"default")),Ot=(t,e,r)=>(r=t!=null?gt(bt(t)):{},Q(e||!t||!t.__esModule?D(r,"default",{value:t,enumerable:!0}):r,t)),St=t=>Q(D({},"__esModule",{value:!0}),t);var Le=(t,e,r)=>(Pt(t,typeof e!="symbol"?e+"":e,r),r);var ve=jt((jr,Fe)=>{Fe.exports=globalThis.loaders});var H={};Nt(H,{JSONLoader:()=>ce,JSONWriter:()=>et,NDJSONLoader:()=>qe,_ClarinetParser:()=>L,_GeoJSONLoader:()=>U,_GeoJSONWorkerLoader:()=>Ce,_GeoJSONWriter:()=>yt,_JSONPath:()=>P,_rebuildJsonObject:()=>He});X(H,Ot(ve(),1));function q(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":(t===null||t==="undefined","null")}function Re(t){let e=It(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=q(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function It(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}var ee=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(e,r){if(this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function ke(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let o=0;o<e.length;o++)r[e[o]]=t[o];else for(let o=0;o<t.length;o++){let n=`column-${o}`;r[n]=t[o]}return r}function Te(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=t[e[o]];return r}return Object.values(t)}function Ue(t){let e=[];for(let r=0;r<t.length;r++){let o=`column-${r}`;e.push(o)}return e}function De(t){return Object.keys(t)}var Je=100,te=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(e,r){if(this.options=r,this.schema=e,e){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=Ue(e),this.options.shape){case"object-row-table":let o=ke(e,this._headers);this.addObjectRow(o,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Je),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=De(e),this.options.shape){case"array-row-table":let o=Te(e,this._headers);this.addArrayRow(o,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Je),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var re=class{schema;length=0;allocated=0;columns={};constructor(e,r){this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let o in this.columns)this.columns[o][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let o in this.schema){let n=this.schema[o];e[n.name]=this.columns[n.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],o=r.type||Float32Array,n=this.columns[r.index];if(n&&ArrayBuffer.isView(n)){let s=new o(this.allocated);s.set(n),this.columns[r.index]=s}else n?(n.length=this.allocated,this.columns[r.index]=n):this.columns[r.index]=new o(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var Bt={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},Et="TableBatchBuilder",oe=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(e,r){this.schema=e,this.options={...Bt,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return te;case"columnar-table":return re;case"arrow-table":if(!oe.ArrowBatch)throw new Error(Et);return oe.ArrowBatch;default:return ee}}},I=oe;Le(I,"ArrowBatch");function B(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function ne(t){if(t.schema)return t.schema.fields.length;if(B(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function se(t,e,r,o){switch(t.shape){case"object-row-table":return o?Object.fromEntries(Object.entries(t.data[e])):t.data[e];case"array-row-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[e][l];return c}throw new Error("no schema");case"geojson-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.features[e][l];return c}throw new Error("no schema");case"columnar-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||{};for(let[l,u]of Object.entries(t.data))c[l]=u[e];return c}case"arrow-table":let n=t.data,s=r||{},a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[i.fields[c].name]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function ie(t,e,r,o){switch(t.shape){case"array-row-table":return o?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[e][t.schema.fields[l].name];return c}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.features[e][t.schema.fields[l].name];return c}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||[],l=0;for(let u of Object.values(t.data))c[l]=u[e],l++;return c}case"arrow-table":let n=t.data,s=r||[],a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[c]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function*de(t,e){switch(e){case"array-row-table":yield*Ge(t);break;case"object-row-table":yield*Me(t);break;default:throw new Error(`Unknown row type ${e}`)}}function*Ge(t,e=[]){let r=B(t);for(let o=0;o<r;o++)yield ie(t,o,e)}function*Me(t,e={}){let r=B(t);for(let o=0;o<r;o++)yield se(t,o,e)}function ze(t){switch(t.shape){case"array-row-table":case"object-row-table":return _t(t.data);case"geojson-table":return Lt(t.features);case"columnar-table":return Ct(t.data);case"arrow-table":default:throw new Error("Deduce schema")}}function Ct(t){let e=[];for(let[r,o]of Object.entries(t)){let n=Ft(o,r);e.push(n)}return{fields:e,metadata:{}}}function _t(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0];for(let[o,n]of Object.entries(r))e.push(We(n,o));return{fields:e,metadata:{}}}function Lt(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0].properties||{};for(let[o,n]of Object.entries(r))e.push(We(n,o));return{fields:e,metadata:{}}}function Ft(t,e){if(ArrayBuffer.isView(t)){let r=Re(t);return{name:e,type:r.type||"null",nullable:r.nullable}}if(Array.isArray(t)&&t.length>0){let r=t[0],o=q(r);return{name:e,type:o,nullable:!0}}throw new Error("empty table")}function We(t,e){let r=q(t);return{name:e,type:r,nullable:!0}}function J(t){let e;switch(vt(t)){case"array-row-table":e={shape:"array-row-table",data:t};break;case"object-row-table":e={shape:"object-row-table",data:t};break;case"columnar-table":e={shape:"columnar-table",data:t};break;default:throw new Error("table")}let r=ze(e);return{...e,schema:r}}function vt(t){if(Array.isArray(t)){if(t.length===0)throw new Error("cannot deduce type of empty table");let e=t[0];if(Array.isArray(e))return"array-row-table";if(e&&typeof e=="object")return"object-row-table"}if(t&&typeof t=="object")return"columnar-table";throw new Error("invalid table")}function Ve(t,e){try{let r=JSON.parse(t);if(e.json?.table){let o=$e(r)||r;return J(o)}return r}catch{throw new Error("JSONLoader: failed to parse JSON")}}function $e(t){if(Array.isArray(t))return t;if(t&&typeof t=="object")for(let e of Object.values(t)){let r=$e(e);if(r)return r}return null}function me(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function E(t){return E=typeof Symbol=="function"&&typeof Symbol.iterator=="symbol"?function(e){return typeof e}:function(e){return e&&typeof Symbol=="function"&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},E(t)}function ye(t,e){if(E(t)!=="object"||t===null)return t;var r=t[Symbol.toPrimitive];if(r!==void 0){var o=r.call(t,e||"default");if(E(o)!=="object")return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return(e==="string"?String:Number)(t)}function ge(t){var e=ye(t,"string");return E(e)==="symbol"?e:String(e)}function j(t,e,r){return e=ge(e),e in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t}function Ze(...t){return Rt(t)}function Rt(t){let e=t.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),r=e.reduce((s,a)=>s+a.byteLength,0),o=new Uint8Array(r),n=0;for(let s of e)o.set(s,n),n+=s.byteLength;return o.buffer}async function*G(t,e={}){let r=new TextDecoder(void 0,e);for await(let o of t)yield typeof o=="string"?o:r.decode(o,{stream:!0})}async function*xe(t){let e="";for await(let r of t){e+=r;let o;for(;(o=e.indexOf(`
8
- `))>=0;){let n=e.slice(0,o+1);e=e.slice(o+1),yield n}}e.length>0&&(yield e)}async function*we(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function be(t){let e=[];for await(let r of t)e.push(r);return Ze(...e)}var Ae=Number.MAX_SAFE_INTEGER,h;(function(t){t[t.BEGIN=0]="BEGIN",t[t.VALUE=1]="VALUE",t[t.OPEN_OBJECT=2]="OPEN_OBJECT",t[t.CLOSE_OBJECT=3]="CLOSE_OBJECT",t[t.OPEN_ARRAY=4]="OPEN_ARRAY",t[t.CLOSE_ARRAY=5]="CLOSE_ARRAY",t[t.TEXT_ESCAPE=6]="TEXT_ESCAPE",t[t.STRING=7]="STRING",t[t.BACKSLASH=8]="BACKSLASH",t[t.END=9]="END",t[t.OPEN_KEY=10]="OPEN_KEY",t[t.CLOSE_KEY=11]="CLOSE_KEY",t[t.TRUE=12]="TRUE",t[t.TRUE2=13]="TRUE2",t[t.TRUE3=14]="TRUE3",t[t.FALSE=15]="FALSE",t[t.FALSE2=16]="FALSE2",t[t.FALSE3=17]="FALSE3",t[t.FALSE4=18]="FALSE4",t[t.NULL=19]="NULL",t[t.NULL2=20]="NULL2",t[t.NULL3=21]="NULL3",t[t.NUMBER_DECIMAL_POINT=22]="NUMBER_DECIMAL_POINT",t[t.NUMBER_DIGIT=23]="NUMBER_DIGIT"})(h||(h={}));var p={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125},Ke=/[\\"\n]/g,Ye={onready:()=>{},onopenobject:()=>{},onkey:()=>{},oncloseobject:()=>{},onopenarray:()=>{},onclosearray:()=>{},onvalue:()=>{},onerror:()=>{},onend:()=>{},onchunkparsed:()=>{}},L=class{options=Ye;bufferCheckPosition=Ae;q="";c="";p="";closed=!1;closedRoot=!1;sawRoot=!1;error=null;state=h.BEGIN;stack=[];position=0;column=0;line=1;slashed=!1;unicodeI=0;unicodeS=null;depth=0;textNode;numberNode;constructor(e={}){this.options={...Ye,...e},this.textNode=void 0,this.numberNode="",this.emit("onready")}end(){return(this.state!==h.VALUE||this.depth!==0)&&this._error("Unexpected end"),this._closeValue(),this.c="",this.closed=!0,this.emit("onend"),this}resume(){return this.error=null,this}close(){return this.write(null)}emit(e,r){this.options[e]?.(r,this)}emitNode(e,r){this._closeValue(),this.emit(e,r)}write(e){if(this.error)throw this.error;if(this.closed)return this._error("Cannot write after close. Assign an onready handler.");if(e===null)return this.end();let r=0,o=e.charCodeAt(0),n=this.p;for(;o&&(n=o,this.c=o=e.charCodeAt(r++),n!==o?this.p=n:n=this.p,!!o);)switch(this.position++,o===p.lineFeed?(this.line++,this.column=0):this.column++,this.state){case h.BEGIN:o===p.openBrace?this.state=h.OPEN_OBJECT:o===p.openBracket?this.state=h.OPEN_ARRAY:M(o)||this._error("Non-whitespace before {[.");continue;case h.OPEN_KEY:case h.OPEN_OBJECT:if(M(o))continue;if(this.state===h.OPEN_KEY)this.stack.push(h.CLOSE_KEY);else if(o===p.closeBrace){this.emit("onopenobject"),this.depth++,this.emit("oncloseobject"),this.depth--,this.state=this.stack.pop()||h.VALUE;continue}else this.stack.push(h.CLOSE_OBJECT);o===p.doubleQuote?this.state=h.STRING:this._error('Malformed object key should start with "');continue;case h.CLOSE_KEY:case h.CLOSE_OBJECT:if(M(o))continue;o===p.colon?(this.state===h.CLOSE_OBJECT?(this.stack.push(h.CLOSE_OBJECT),this._closeValue("onopenobject"),this.depth++):this._closeValue("onkey"),this.state=h.VALUE):o===p.closeBrace?(this.emitNode("oncloseobject"),this.depth--,this.state=this.stack.pop()||h.VALUE):o===p.comma?(this.state===h.CLOSE_OBJECT&&this.stack.push(h.CLOSE_OBJECT),this._closeValue(),this.state=h.OPEN_KEY):this._error("Bad object");continue;case h.OPEN_ARRAY:case h.VALUE:if(M(o))continue;if(this.state===h.OPEN_ARRAY)if(this.emit("onopenarray"),this.depth++,this.state=h.VALUE,o===p.closeBracket){this.emit("onclosearray"),this.depth--,this.state=this.stack.pop()||h.VALUE;continue}else this.stack.push(h.CLOSE_ARRAY);o===p.doubleQuote?this.state=h.STRING:o===p.openBrace?this.state=h.OPEN_OBJECT:o===p.openBracket?this.state=h.OPEN_ARRAY:o===p.t?this.state=h.TRUE:o===p.f?this.state=h.FALSE:o===p.n?this.state=h.NULL:o===p.minus?this.numberNode+="-":p._0<=o&&o<=p._9?(this.numberNode+=String.fromCharCode(o),this.state=h.NUMBER_DIGIT):this._error("Bad value");continue;case h.CLOSE_ARRAY:if(o===p.comma)this.stack.push(h.CLOSE_ARRAY),this._closeValue("onvalue"),this.state=h.VALUE;else if(o===p.closeBracket)this.emitNode("onclosearray"),this.depth--,this.state=this.stack.pop()||h.VALUE;else{if(M(o))continue;this._error("Bad array")}continue;case h.STRING:this.textNode===void 0&&(this.textNode="");let s=r-1,a=this.slashed,i=this.unicodeI;e:for(;;){for(;i>0;)if(this.unicodeS+=String.fromCharCode(o),o=e.charCodeAt(r++),this.position++,i===4?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),i=0,s=r-1):i++,!o)break e;if(o===p.doubleQuote&&!a){this.state=this.stack.pop()||h.VALUE,this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}if(o===p.backslash&&!a&&(a=!0,this.textNode+=e.substring(s,r-1),this.position+=r-1-s,o=e.charCodeAt(r++),this.position++,!o))break;if(a){if(a=!1,o===p.n?this.textNode+=`
9
- `:o===p.r?this.textNode+="\r":o===p.t?this.textNode+=" ":o===p.f?this.textNode+="\f":o===p.b?this.textNode+="\b":o===p.u?(i=1,this.unicodeS=""):this.textNode+=String.fromCharCode(o),o=e.charCodeAt(r++),this.position++,s=r-1,o)continue;break}Ke.lastIndex=r;let c=Ke.exec(e);if(c===null){r=e.length+1,this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}if(r=c.index+1,o=e.charCodeAt(c.index),!o){this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}}this.slashed=a,this.unicodeI=i;continue;case h.TRUE:o===p.r?this.state=h.TRUE2:this._error(`Invalid true started with t${o}`);continue;case h.TRUE2:o===p.u?this.state=h.TRUE3:this._error(`Invalid true started with tr${o}`);continue;case h.TRUE3:o===p.e?(this.emit("onvalue",!0),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid true started with tru${o}`);continue;case h.FALSE:o===p.a?this.state=h.FALSE2:this._error(`Invalid false started with f${o}`);continue;case h.FALSE2:o===p.l?this.state=h.FALSE3:this._error(`Invalid false started with fa${o}`);continue;case h.FALSE3:o===p.s?this.state=h.FALSE4:this._error(`Invalid false started with fal${o}`);continue;case h.FALSE4:o===p.e?(this.emit("onvalue",!1),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid false started with fals${o}`);continue;case h.NULL:o===p.u?this.state=h.NULL2:this._error(`Invalid null started with n${o}`);continue;case h.NULL2:o===p.l?this.state=h.NULL3:this._error(`Invalid null started with nu${o}`);continue;case h.NULL3:o===p.l?(this.emit("onvalue",null),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid null started with nul${o}`);continue;case h.NUMBER_DECIMAL_POINT:o===p.period?(this.numberNode+=".",this.state=h.NUMBER_DIGIT):this._error("Leading zero not followed by .");continue;case h.NUMBER_DIGIT:p._0<=o&&o<=p._9?this.numberNode+=String.fromCharCode(o):o===p.period?(this.numberNode.indexOf(".")!==-1&&this._error("Invalid number has two dots"),this.numberNode+="."):o===p.e||o===p.E?((this.numberNode.indexOf("e")!==-1||this.numberNode.indexOf("E")!==-1)&&this._error("Invalid number has two exponential"),this.numberNode+="e"):o===p.plus||o===p.minus?(n===p.e||n===p.E||this._error("Invalid symbol in number"),this.numberNode+=String.fromCharCode(o)):(this._closeNumber(),r--,this.state=this.stack.pop()||h.VALUE);continue;default:this._error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&kt(this),this.emit("onchunkparsed"),this}_closeValue(e="onvalue"){this.textNode!==void 0&&this.emit(e,this.textNode),this.textNode=void 0}_closeNumber(){this.numberNode&&this.emit("onvalue",parseFloat(this.numberNode)),this.numberNode=""}_error(e=""){this._closeValue(),e+=`
7
+ "use strict";var __exports__=(()=>{var pt=Object.create;var v=Object.defineProperty;var dt=Object.getOwnPropertyDescriptor;var mt=Object.getOwnPropertyNames;var yt=Object.getPrototypeOf,gt=Object.prototype.hasOwnProperty;var xt=(t,e,r)=>e in t?v(t,e,{enumerable:!0,configurable:!0,writable:!0,value:r}):t[e]=r;var wt=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),bt=(t,e)=>{for(var r in e)v(t,r,{get:e[r],enumerable:!0})},K=(t,e,r,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of mt(e))!gt.call(t,n)&&n!==r&&v(t,n,{get:()=>e[n],enumerable:!(o=dt(e,n))||o.enumerable});return t},H=(t,e,r)=>(K(t,e,"default"),r&&K(r,e,"default")),At=(t,e,r)=>(r=t!=null?pt(yt(t)):{},K(e||!t||!t.__esModule?v(r,"default",{value:t,enumerable:!0}):r,t)),Pt=t=>K(v({},"__esModule",{value:!0}),t);var Be=(t,e,r)=>(xt(t,typeof e!="symbol"?e+"":e,r),r);var Ce=wt((wr,Ee)=>{Ee.exports=globalThis.loaders});var Y={};bt(Y,{JSONLoader:()=>ie,JSONWriter:()=>He,NDJSONLoader:()=>Ke,_ClarinetParser:()=>C,_GeoJSONLoader:()=>T,_GeoJSONWorkerLoader:()=>Se,_GeoJSONWriter:()=>ft,_JSONPath:()=>P,_rebuildJsonObject:()=>$e});H(Y,At(Ce(),1));function Q(t,e="float32"){return t instanceof Date?"date-millisecond":t instanceof Number?e:typeof t=="string"?"utf8":(t===null||t==="undefined","null")}function Le(t){let e=jt(t);return e!=="null"?{type:e,nullable:!1}:t.length>0?(e=Q(t[0]),{type:e,nullable:!0}):{type:"null",nullable:!0}}function jt(t){switch(t.constructor){case Int8Array:return"int8";case Uint8Array:case Uint8ClampedArray:return"uint8";case Int16Array:return"int16";case Uint16Array:return"uint16";case Int32Array:return"int32";case Uint32Array:return"uint32";case Float32Array:return"float32";case Float64Array:return"float64";default:return"null"}}var X=class{schema;options;shape;length=0;rows=null;cursor=0;_headers=[];constructor(e,r){if(this.options=r,this.schema=e,!Array.isArray(e)){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="array-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}addObjectRow(e,r){Number.isFinite(r)&&(this.cursor=r),this.shape="object-row-table",this.rows=this.rows||new Array(100),this.rows[this.length]=e,this.length++}getBatch(){let e=this.rows;return e?(e=e.slice(0,this.length),this.rows=null,{shape:this.shape||"array-row-table",batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};function Fe(t,e){if(!t)throw new Error("null row");let r={};if(e)for(let o=0;o<e.length;o++)r[e[o]]=t[o];else for(let o=0;o<t.length;o++){let n=`column-${o}`;r[n]=t[o]}return r}function _e(t,e){if(!t)throw new Error("null row");if(e){let r=new Array(e.length);for(let o=0;o<e.length;o++)r[o]=t[e[o]];return r}return Object.values(t)}function ke(t){let e=[];for(let r=0;r<t.length;r++){let o=`column-${r}`;e.push(o)}return e}function Re(t){return Object.keys(t)}var Te=100,q=class{schema;options;length=0;objectRows=null;arrayRows=null;cursor=0;_headers=null;constructor(e,r){if(this.options=r,this.schema=e,e){this._headers=[];for(let o in e)this._headers[e[o].index]=e[o].name}}rowCount(){return this.length}addArrayRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=ke(e),this.options.shape){case"object-row-table":let o=Fe(e,this._headers);this.addObjectRow(o,r);break;case"array-row-table":this.arrayRows=this.arrayRows||new Array(Te),this.arrayRows[this.length]=e,this.length++;break}}addObjectRow(e,r){switch(Number.isFinite(r)&&(this.cursor=r),this._headers||=Re(e),this.options.shape){case"array-row-table":let o=_e(e,this._headers);this.addArrayRow(o,r);break;case"object-row-table":this.objectRows=this.objectRows||new Array(Te),this.objectRows[this.length]=e,this.length++;break}}getBatch(){let e=this.arrayRows||this.objectRows;return e?(e=e.slice(0,this.length),this.arrayRows=null,this.objectRows=null,{shape:this.options.shape,batchType:"data",data:e,length:this.length,schema:this.schema,cursor:this.cursor}):null}};var ee=class{schema;length=0;allocated=0;columns={};constructor(e,r){this.schema=e,this._reallocateColumns()}rowCount(){return this.length}addArrayRow(e){this._reallocateColumns();let r=0;for(let o in this.columns)this.columns[o][this.length]=e[r++];this.length++}addObjectRow(e){this._reallocateColumns();for(let r in e)this.columns[r][this.length]=e[r];this.length++}getBatch(){this._pruneColumns();let e=Array.isArray(this.schema)?this.columns:{};if(!Array.isArray(this.schema))for(let o in this.schema){let n=this.schema[o];e[n.name]=this.columns[n.index]}return this.columns={},{shape:"columnar-table",batchType:"data",data:e,schema:this.schema,length:this.length}}_reallocateColumns(){if(!(this.length<this.allocated)){this.allocated=this.allocated>0?this.allocated*=2:100,this.columns={};for(let e in this.schema){let r=this.schema[e],o=r.type||Float32Array,n=this.columns[r.index];if(n&&ArrayBuffer.isView(n)){let s=new o(this.allocated);s.set(n),this.columns[r.index]=s}else n?(n.length=this.allocated,this.columns[r.index]=n):this.columns[r.index]=new o(this.allocated)}}}_pruneColumns(){for(let[e,r]of Object.entries(this.columns))this.columns[e]=r.slice(0,this.length)}};var Nt={shape:void 0,batchSize:"auto",batchDebounceMs:0,limit:0,_limitMB:0},Ot="TableBatchBuilder",te=class{schema;options;aggregator=null;batchCount=0;bytesUsed=0;isChunkComplete=!1;lastBatchEmittedMs=Date.now();totalLength=0;totalBytes=0;rowBytes=0;constructor(e,r){this.schema=e,this.options={...Nt,...r}}limitReached(){return!!(Boolean(this.options?.limit)&&this.totalLength>=this.options.limit||Boolean(this.options?._limitMB)&&this.totalBytes/1e6>=this.options._limitMB)}addRow(e){this.limitReached()||(this.totalLength++,this.rowBytes=this.rowBytes||this._estimateRowMB(e),this.totalBytes+=this.rowBytes,Array.isArray(e)?this.addArrayRow(e):this.addObjectRow(e))}addArrayRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addArrayRow(e)}addObjectRow(e){if(!this.aggregator){let r=this._getTableBatchType();this.aggregator=new r(this.schema,this.options)}this.aggregator.addObjectRow(e)}chunkComplete(e){e instanceof ArrayBuffer&&(this.bytesUsed+=e.byteLength),typeof e=="string"&&(this.bytesUsed+=e.length),this.isChunkComplete=!0}getFullBatch(e){return this._isFull()?this._getBatch(e):null}getFinalBatch(e){return this._getBatch(e)}_estimateRowMB(e){return Array.isArray(e)?e.length*8:Object.keys(e).length*8}_isFull(){if(!this.aggregator||this.aggregator.rowCount()===0)return!1;if(this.options.batchSize==="auto"){if(!this.isChunkComplete)return!1}else if(this.options.batchSize>this.aggregator.rowCount())return!1;return this.options.batchDebounceMs>Date.now()-this.lastBatchEmittedMs?!1:(this.isChunkComplete=!1,this.lastBatchEmittedMs=Date.now(),!0)}_getBatch(e){if(!this.aggregator)return null;e?.bytesUsed&&(this.bytesUsed=e.bytesUsed);let r=this.aggregator.getBatch();return r.count=this.batchCount,r.bytesUsed=this.bytesUsed,Object.assign(r,e),this.batchCount++,this.aggregator=null,r}_getTableBatchType(){switch(this.options.shape){case"array-row-table":case"object-row-table":return q;case"columnar-table":return ee;case"arrow-table":if(!te.ArrowBatch)throw new Error(Ot);return te.ArrowBatch;default:return X}}},S=te;Be(S,"ArrowBatch");function I(t){switch(t.shape){case"array-row-table":case"object-row-table":return t.data.length;case"geojson-table":return t.features.length;case"arrow-table":return t.data.numRows;case"columnar-table":for(let r of Object.values(t.data))return r.length||0;return 0;default:throw new Error("table")}}function re(t){if(t.schema)return t.schema.fields.length;if(I(t)===0)throw new Error("empty table");switch(t.shape){case"array-row-table":return t.data[0].length;case"object-row-table":return Object.keys(t.data[0]).length;case"geojson-table":return Object.keys(t.features[0]).length;case"columnar-table":return Object.keys(t.data).length;case"arrow-table":return t.data.numCols;default:throw new Error("table")}}function oe(t,e,r,o){switch(t.shape){case"object-row-table":return o?Object.fromEntries(Object.entries(t.data[e])):t.data[e];case"array-row-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[e][l];return c}throw new Error("no schema");case"geojson-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.features[e][l];return c}throw new Error("no schema");case"columnar-table":if(t.schema){let c=r||{};for(let l=0;l<t.schema.fields.length;l++)c[t.schema.fields[l].name]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||{};for(let[l,u]of Object.entries(t.data))c[l]=u[e];return c}case"arrow-table":let n=t.data,s=r||{},a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[i.fields[c].name]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function ne(t,e,r,o){switch(t.shape){case"array-row-table":return o?Array.from(t.data[e]):t.data[e];case"object-row-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[e][t.schema.fields[l].name];return c}return Object.values(t.data[e]);case"geojson-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.features[e][t.schema.fields[l].name];return c}return Object.values(t.features[e]);case"columnar-table":if(t.schema){let c=r||[];for(let l=0;l<t.schema.fields.length;l++)c[l]=t.data[t.schema.fields[l].name][e];return c}else{let c=r||[],l=0;for(let u of Object.values(t.data))c[l]=u[e],l++;return c}case"arrow-table":let n=t.data,s=r||[],a=n.get(e),i=n.schema;for(let c=0;c<i.fields.length;c++)s[c]=a?.[i.fields[c].name];return s;default:throw new Error("shape")}}function*fe(t,e){switch(e){case"array-row-table":yield*ve(t);break;case"object-row-table":yield*Ue(t);break;default:throw new Error(`Unknown row type ${e}`)}}function*ve(t,e=[]){let r=I(t);for(let o=0;o<r;o++)yield ne(t,o,e)}function*Ue(t,e={}){let r=I(t);for(let o=0;o<r;o++)yield oe(t,o,e)}function De(t){switch(t.shape){case"array-row-table":case"object-row-table":return It(t.data);case"geojson-table":return Bt(t.features);case"columnar-table":return St(t.data);case"arrow-table":default:throw new Error("Deduce schema")}}function St(t){let e=[];for(let[r,o]of Object.entries(t)){let n=Et(o,r);e.push(n)}return{fields:e,metadata:{}}}function It(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0];for(let[o,n]of Object.entries(r))e.push(Je(n,o));return{fields:e,metadata:{}}}function Bt(t){if(!t.length)throw new Error("deduce from empty table");let e=[],r=t[0].properties||{};for(let[o,n]of Object.entries(r))e.push(Je(n,o));return{fields:e,metadata:{}}}function Et(t,e){if(ArrayBuffer.isView(t)){let r=Le(t);return{name:e,type:r.type||"null",nullable:r.nullable}}if(Array.isArray(t)&&t.length>0){let r=t[0],o=Q(r);return{name:e,type:o,nullable:!0}}throw new Error("empty table")}function Je(t,e){let r=Q(t);return{name:e,type:r,nullable:!0}}function U(t){let e;switch(Ct(t)){case"array-row-table":e={shape:"array-row-table",data:t};break;case"object-row-table":e={shape:"object-row-table",data:t};break;case"columnar-table":e={shape:"columnar-table",data:t};break;default:throw new Error("table")}let r=De(e);return{...e,schema:r}}function Ct(t){if(Array.isArray(t)){if(t.length===0)throw new Error("cannot deduce type of empty table");let e=t[0];if(Array.isArray(e))return"array-row-table";if(e&&typeof e=="object")return"object-row-table"}if(t&&typeof t=="object")return"columnar-table";throw new Error("invalid table")}function Ge(t,e){try{let r=JSON.parse(t);if(e.json?.table){let o=Me(r)||r;return U(o)}return r}catch{throw new Error("JSONLoader: failed to parse JSON")}}function Me(t){if(Array.isArray(t))return t;if(t&&typeof t=="object")for(let e of Object.values(t)){let r=Me(e);if(r)return r}return null}function pe(t,e){if(!t)throw new Error(e||"loader assertion failed.")}function ze(...t){return Lt(t)}function Lt(t){let e=t.map(s=>s instanceof ArrayBuffer?new Uint8Array(s):s),r=e.reduce((s,a)=>s+a.byteLength,0),o=new Uint8Array(r),n=0;for(let s of e)o.set(s,n),n+=s.byteLength;return o.buffer}async function*D(t,e={}){let r=new TextDecoder(void 0,e);for await(let o of t)yield typeof o=="string"?o:r.decode(o,{stream:!0})}async function*de(t){let e="";for await(let r of t){e+=r;let o;for(;(o=e.indexOf(`
8
+ `))>=0;){let n=e.slice(0,o+1);e=e.slice(o+1),yield n}}e.length>0&&(yield e)}async function*me(t){let e=1;for await(let r of t)yield{counter:e,line:r},e++}async function ye(t){let e=[];for await(let r of t)e.push(r);return ze(...e)}var ge=Number.MAX_SAFE_INTEGER,h;(function(t){t[t.BEGIN=0]="BEGIN",t[t.VALUE=1]="VALUE",t[t.OPEN_OBJECT=2]="OPEN_OBJECT",t[t.CLOSE_OBJECT=3]="CLOSE_OBJECT",t[t.OPEN_ARRAY=4]="OPEN_ARRAY",t[t.CLOSE_ARRAY=5]="CLOSE_ARRAY",t[t.TEXT_ESCAPE=6]="TEXT_ESCAPE",t[t.STRING=7]="STRING",t[t.BACKSLASH=8]="BACKSLASH",t[t.END=9]="END",t[t.OPEN_KEY=10]="OPEN_KEY",t[t.CLOSE_KEY=11]="CLOSE_KEY",t[t.TRUE=12]="TRUE",t[t.TRUE2=13]="TRUE2",t[t.TRUE3=14]="TRUE3",t[t.FALSE=15]="FALSE",t[t.FALSE2=16]="FALSE2",t[t.FALSE3=17]="FALSE3",t[t.FALSE4=18]="FALSE4",t[t.NULL=19]="NULL",t[t.NULL2=20]="NULL2",t[t.NULL3=21]="NULL3",t[t.NUMBER_DECIMAL_POINT=22]="NUMBER_DECIMAL_POINT",t[t.NUMBER_DIGIT=23]="NUMBER_DIGIT"})(h||(h={}));var p={tab:9,lineFeed:10,carriageReturn:13,space:32,doubleQuote:34,plus:43,comma:44,minus:45,period:46,_0:48,_9:57,colon:58,E:69,openBracket:91,backslash:92,closeBracket:93,a:97,b:98,e:101,f:102,l:108,n:110,r:114,s:115,t:116,u:117,openBrace:123,closeBrace:125},We=/[\\"\n]/g,Ve={onready:()=>{},onopenobject:()=>{},onkey:()=>{},oncloseobject:()=>{},onopenarray:()=>{},onclosearray:()=>{},onvalue:()=>{},onerror:()=>{},onend:()=>{},onchunkparsed:()=>{}},C=class{options=Ve;bufferCheckPosition=ge;q="";c="";p="";closed=!1;closedRoot=!1;sawRoot=!1;error=null;state=h.BEGIN;stack=[];position=0;column=0;line=1;slashed=!1;unicodeI=0;unicodeS=null;depth=0;textNode;numberNode;constructor(e={}){this.options={...Ve,...e},this.textNode=void 0,this.numberNode="",this.emit("onready")}end(){return(this.state!==h.VALUE||this.depth!==0)&&this._error("Unexpected end"),this._closeValue(),this.c="",this.closed=!0,this.emit("onend"),this}resume(){return this.error=null,this}close(){return this.write(null)}emit(e,r){this.options[e]?.(r,this)}emitNode(e,r){this._closeValue(),this.emit(e,r)}write(e){if(this.error)throw this.error;if(this.closed)return this._error("Cannot write after close. Assign an onready handler.");if(e===null)return this.end();let r=0,o=e.charCodeAt(0),n=this.p;for(;o&&(n=o,this.c=o=e.charCodeAt(r++),n!==o?this.p=n:n=this.p,!!o);)switch(this.position++,o===p.lineFeed?(this.line++,this.column=0):this.column++,this.state){case h.BEGIN:o===p.openBrace?this.state=h.OPEN_OBJECT:o===p.openBracket?this.state=h.OPEN_ARRAY:J(o)||this._error("Non-whitespace before {[.");continue;case h.OPEN_KEY:case h.OPEN_OBJECT:if(J(o))continue;if(this.state===h.OPEN_KEY)this.stack.push(h.CLOSE_KEY);else if(o===p.closeBrace){this.emit("onopenobject"),this.depth++,this.emit("oncloseobject"),this.depth--,this.state=this.stack.pop()||h.VALUE;continue}else this.stack.push(h.CLOSE_OBJECT);o===p.doubleQuote?this.state=h.STRING:this._error('Malformed object key should start with "');continue;case h.CLOSE_KEY:case h.CLOSE_OBJECT:if(J(o))continue;o===p.colon?(this.state===h.CLOSE_OBJECT?(this.stack.push(h.CLOSE_OBJECT),this._closeValue("onopenobject"),this.depth++):this._closeValue("onkey"),this.state=h.VALUE):o===p.closeBrace?(this.emitNode("oncloseobject"),this.depth--,this.state=this.stack.pop()||h.VALUE):o===p.comma?(this.state===h.CLOSE_OBJECT&&this.stack.push(h.CLOSE_OBJECT),this._closeValue(),this.state=h.OPEN_KEY):this._error("Bad object");continue;case h.OPEN_ARRAY:case h.VALUE:if(J(o))continue;if(this.state===h.OPEN_ARRAY)if(this.emit("onopenarray"),this.depth++,this.state=h.VALUE,o===p.closeBracket){this.emit("onclosearray"),this.depth--,this.state=this.stack.pop()||h.VALUE;continue}else this.stack.push(h.CLOSE_ARRAY);o===p.doubleQuote?this.state=h.STRING:o===p.openBrace?this.state=h.OPEN_OBJECT:o===p.openBracket?this.state=h.OPEN_ARRAY:o===p.t?this.state=h.TRUE:o===p.f?this.state=h.FALSE:o===p.n?this.state=h.NULL:o===p.minus?this.numberNode+="-":p._0<=o&&o<=p._9?(this.numberNode+=String.fromCharCode(o),this.state=h.NUMBER_DIGIT):this._error("Bad value");continue;case h.CLOSE_ARRAY:if(o===p.comma)this.stack.push(h.CLOSE_ARRAY),this._closeValue("onvalue"),this.state=h.VALUE;else if(o===p.closeBracket)this.emitNode("onclosearray"),this.depth--,this.state=this.stack.pop()||h.VALUE;else{if(J(o))continue;this._error("Bad array")}continue;case h.STRING:this.textNode===void 0&&(this.textNode="");let s=r-1,a=this.slashed,i=this.unicodeI;e:for(;;){for(;i>0;)if(this.unicodeS+=String.fromCharCode(o),o=e.charCodeAt(r++),this.position++,i===4?(this.textNode+=String.fromCharCode(parseInt(this.unicodeS,16)),i=0,s=r-1):i++,!o)break e;if(o===p.doubleQuote&&!a){this.state=this.stack.pop()||h.VALUE,this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}if(o===p.backslash&&!a&&(a=!0,this.textNode+=e.substring(s,r-1),this.position+=r-1-s,o=e.charCodeAt(r++),this.position++,!o))break;if(a){if(a=!1,o===p.n?this.textNode+=`
9
+ `:o===p.r?this.textNode+="\r":o===p.t?this.textNode+=" ":o===p.f?this.textNode+="\f":o===p.b?this.textNode+="\b":o===p.u?(i=1,this.unicodeS=""):this.textNode+=String.fromCharCode(o),o=e.charCodeAt(r++),this.position++,s=r-1,o)continue;break}We.lastIndex=r;let c=We.exec(e);if(c===null){r=e.length+1,this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}if(r=c.index+1,o=e.charCodeAt(c.index),!o){this.textNode+=e.substring(s,r-1),this.position+=r-1-s;break}}this.slashed=a,this.unicodeI=i;continue;case h.TRUE:o===p.r?this.state=h.TRUE2:this._error(`Invalid true started with t${o}`);continue;case h.TRUE2:o===p.u?this.state=h.TRUE3:this._error(`Invalid true started with tr${o}`);continue;case h.TRUE3:o===p.e?(this.emit("onvalue",!0),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid true started with tru${o}`);continue;case h.FALSE:o===p.a?this.state=h.FALSE2:this._error(`Invalid false started with f${o}`);continue;case h.FALSE2:o===p.l?this.state=h.FALSE3:this._error(`Invalid false started with fa${o}`);continue;case h.FALSE3:o===p.s?this.state=h.FALSE4:this._error(`Invalid false started with fal${o}`);continue;case h.FALSE4:o===p.e?(this.emit("onvalue",!1),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid false started with fals${o}`);continue;case h.NULL:o===p.u?this.state=h.NULL2:this._error(`Invalid null started with n${o}`);continue;case h.NULL2:o===p.l?this.state=h.NULL3:this._error(`Invalid null started with nu${o}`);continue;case h.NULL3:o===p.l?(this.emit("onvalue",null),this.state=this.stack.pop()||h.VALUE):this._error(`Invalid null started with nul${o}`);continue;case h.NUMBER_DECIMAL_POINT:o===p.period?(this.numberNode+=".",this.state=h.NUMBER_DIGIT):this._error("Leading zero not followed by .");continue;case h.NUMBER_DIGIT:p._0<=o&&o<=p._9?this.numberNode+=String.fromCharCode(o):o===p.period?(this.numberNode.indexOf(".")!==-1&&this._error("Invalid number has two dots"),this.numberNode+="."):o===p.e||o===p.E?((this.numberNode.indexOf("e")!==-1||this.numberNode.indexOf("E")!==-1)&&this._error("Invalid number has two exponential"),this.numberNode+="e"):o===p.plus||o===p.minus?(n===p.e||n===p.E||this._error("Invalid symbol in number"),this.numberNode+=String.fromCharCode(o)):(this._closeNumber(),r--,this.state=this.stack.pop()||h.VALUE);continue;default:this._error(`Unknown state: ${this.state}`)}return this.position>=this.bufferCheckPosition&&Ft(this),this.emit("onchunkparsed"),this}_closeValue(e="onvalue"){this.textNode!==void 0&&this.emit(e,this.textNode),this.textNode=void 0}_closeNumber(){this.numberNode&&this.emit("onvalue",parseFloat(this.numberNode)),this.numberNode=""}_error(e=""){this._closeValue(),e+=`
10
10
  Line: ${this.line}
11
11
  Column: ${this.column}
12
- Char: ${this.c}`;let r=new Error(e);this.error=r,this.emit("onerror",r)}};function M(t){return t===p.carriageReturn||t===p.lineFeed||t===p.space||t===p.tab}function kt(t){let e=Math.max(Ae,10),r=0;for(let o of["textNode","numberNode"]){let n=t[o]===void 0?0:t[o].length;if(n>e)switch(o){case"text":break;default:t._error(`Max buffer length exceeded: ${o}`)}r=Math.max(r,n)}t.bufferCheckPosition=Ae-r+t.position}var P=class{path;constructor(e=null){if(this.path=["$"],e instanceof P){this.path=[...e.path];return}if(Array.isArray(e)){this.path.push(...e);return}if(typeof e=="string"&&(this.path=e.split("."),this.path[0]!=="$"))throw new Error("JSONPaths must start with $")}clone(){return new P(this)}toString(){return this.path.join(".")}push(e){this.path.push(e)}pop(){return this.path.pop()}set(e){this.path[this.path.length-1]=e}equals(e){if(!this||!e||this.path.length!==e.path.length)return!1;for(let r=0;r<this.path.length;++r)if(this.path[r]!==e.path[r])return!1;return!0}setFieldAtPath(e,r){let o=[...this.path];o.shift();let n=o.pop();for(let s of o)e=e[s];e[n]=r}getFieldAtPath(e){let r=[...this.path];r.shift();let o=r.pop();for(let n of r)e=e[n];return e[o]}};var z=class{parser;result=void 0;previousStates=[];currentState=Object.freeze({container:[],key:null});jsonpath=new P;constructor(e){this.reset(),this.parser=new L({onready:()=>{this.jsonpath=new P,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:r=>{this._openObject({}),typeof r<"u"&&this.parser.emit("onkey",r)},onkey:r=>{this.jsonpath.set(r),this.currentState.key=r},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:r=>{this._pushOrSet(r)},onerror:r=>{throw r},onend:()=>{this.result=this.currentState.container.pop()},...e})}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new P}write(e){this.parser.write(e)}close(){this.parser.close()}_pushOrSet(e){let{container:r,key:o}=this.currentState;o!==null?(r[o]=e,this.currentState.key=null):r.push(e)}_openArray(e=[]){this.jsonpath.push(null),this._pushOrSet(e),this.previousStates.push(this.currentState),this.currentState={container:e,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(e={}){this.jsonpath.push(null),this._pushOrSet(e),this.previousStates.push(this.currentState),this.currentState={container:e,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}};var W=class extends z{jsonPaths;streamingJsonPath=null;streamingArray=null;topLevelObject=null;constructor(e={}){super({onopenarray:()=>{if(!this.streamingArray&&this._matchJSONPath()){this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],this._openArray(this.streamingArray);return}this._openArray()},onopenobject:o=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),typeof o<"u"&&this.parser.emit("onkey",o)}});let r=e.jsonpaths||[];this.jsonPaths=r.map(o=>new P(o))}write(e){super.write(e);let r=[];return this.streamingArray&&(r=[...this.streamingArray],this.streamingArray.length=0),r}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){let e=this.getJsonPath();if(this.jsonPaths.length===0)return!0;for(let r of this.jsonPaths)if(r.equals(e))return!0;return!1}};async function*ae(t,e){let r=G(t),{metadata:o}=e,{jsonpaths:n}=e.json||{},s=!0,a=null,i=new I(a,e),c=new W({jsonpaths:n});for await(let d of r){let f=c.write(d),y=f.length>0&&c.getStreamingJsonPathAsString();f.length>0&&s&&(o&&(yield{shape:e?.json?.shape||"array-row-table",batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:y}),s=!1);for(let w of f){i.addRow(w);let A=i.getFullBatch({jsonpath:y});A&&(yield A)}i.chunkComplete(d);let m=i.getFullBatch({jsonpath:y});m&&(yield m)}let l=c.getStreamingJsonPathAsString(),u=i.getFinalBatch({jsonpath:l});u&&(yield u),o&&(yield{shape:"json",batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0})}function He(t,e){if(me(t.batchType==="final-result"),t.jsonpath==="$")return e;if(t.jsonpath&&t.jsonpath.length>1){let r=t.container;return new P(t.jsonpath).setFieldAtPath(r,e),r}return t.container}var Tt="4.3.0-alpha.6",ce={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:Tt,extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,options:{json:{shape:void 0,table:!1,jsonpaths:[]}},parse:Ut,parseTextSync:Qe,parseInBatches:Dt};async function Ut(t,e){return Qe(new TextDecoder().decode(t),e)}function Qe(t,e){let r={...e,json:{...ce.options.json,...e?.json}};return Ve(t,r)}function Dt(t,e){let r={...e,json:{...ce.options.json,...e?.json}};return ae(t,r)}function Pe(t){let r=t.trim().split(`
13
- `).map((o,n)=>{try{return JSON.parse(o)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${n+1}`)}});return J(r)}async function*Xe(t,e){let r=G(t),o=xe(r),n=we(o),s=null,a="row-table",i=new I(s,{...e,shape:a});for await(let{counter:l,line:u}of n)try{let d=JSON.parse(u);i.addRow(d),i.chunkComplete(u);let f=i.getFullBatch();f&&(yield f)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=i.getFinalBatch();c&&(yield c)}var Jt="4.3.0-alpha.6",qe={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:Jt,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async t=>Pe(new TextDecoder().decode(t)),parseTextSync:Pe,parseInBatches:Xe,options:{}};function je(t,e){let r=e?.json?.shape||"object-row-table",o=[],n=de(t,r);for(let s of n)o.push(JSON.stringify(s));return`[${o.join(",")}]`}var et={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(t,e)=>new TextEncoder().encode(je(t,e)).buffer,encodeTextSync:(t,e)=>je(t,e)};var V={x:0,y:1,z:2};function k(t,e={}){let{start:r=0,end:o=t.length,plane:n="xy"}=e,s=e.size||2,a=0,i=V[n[0]],c=V[n[1]];for(let l=r,u=o-s;l<o;l+=s)a+=(t[l+i]-t[u+i])*(t[l+c]+t[u+c]),u=l;return a/2}function Oe(t,e,r=2,o,n="xy"){let s=e&&e.length,a=s?e[0]*r:t.length,i=rt(t,0,a,r,!0,o&&o[0],n),c=[];if(!i||i.next===i.prev)return c;let l,u,d,f,y,m,w;if(s&&(i=Zt(t,e,i,r,o,n)),t.length>80*r){f=u=t[0],y=d=t[1];for(let A=r;A<a;A+=r)m=t[A],w=t[A+1],m<f&&(f=m),w<y&&(y=w),m>u&&(u=m),w>d&&(d=w);l=Math.max(u-f,d-y),l=l!==0?32767/l:0}return $(i,c,r,f,y,l,0),c}function rt(t,e,r,o,n,s,a){let i,c;s===void 0&&(s=k(t,{start:e,end:r,size:o,plane:a}));let l=V[a[0]],u=V[a[1]];if(n===s<0)for(i=e;i<r;i+=o)c=tt(i,t[i+l],t[i+u],c);else for(i=r-o;i>=e;i-=o)c=tt(i,t[i+l],t[i+u],c);return c&&he(c,c.next)&&(K(c),c=c.next),c}function F(t,e){if(!t)return t;e||(e=t);let r=t,o;do if(o=!1,!r.steiner&&(he(r,r.next)||b(r.prev,r,r.next)===0)){if(K(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function $(t,e,r,o,n,s,a){if(!t)return;!a&&s&&Xt(t,o,n,s);let i=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?Wt(t,o,n,s):zt(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),K(t),t=l.next,i=l.next;continue}if(t=l,t===i){a?a===1?(t=Vt(F(t),e,r),$(t,e,r,o,n,s,2)):a===2&&$t(t,e,r,o,n,s):$(F(t),e,r,o,n,s,1);break}}}function zt(t){let e=t.prev,r=t,o=t.next;if(b(e,r,o)>=0)return!1;let n=e.x,s=r.x,a=o.x,i=e.y,c=r.y,l=o.y,u=n<s?n<a?n:a:s<a?s:a,d=i<c?i<l?i:l:c<l?c:l,f=n>s?n>a?n:a:s>a?s:a,y=i>c?i>l?i:l:c>l?c:l,m=o.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=y&&T(n,i,s,c,a,l,m.x,m.y)&&b(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Wt(t,e,r,o){let n=t.prev,s=t,a=t.next;if(b(n,s,a)>=0)return!1;let i=n.x,c=s.x,l=a.x,u=n.y,d=s.y,f=a.y,y=i<c?i<l?i:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,w=i>c?i>l?i:l:c>l?c:l,A=u>d?u>f?u:f:d>f?d:f,v=Ne(y,m,e,r,o),R=Ne(w,A,e,r,o),x=t.prevZ,g=t.nextZ;for(;x&&x.z>=v&&g&&g.z<=R;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&T(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0||(x=x.prevZ,g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&T(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;x&&x.z>=v;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&T(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;g&&g.z<=R;){if(g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&T(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Vt(t,e,r){let o=t;do{let n=o.prev,s=o.next.next;!he(n,s)&&ot(n,o,o.next,s)&&Z(n,s)&&Z(s,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(s.i/r|0),K(o),K(o.next),o=t=s),o=o.next}while(o!==t);return F(o)}function $t(t,e,r,o,n,s){let a=t;do{let i=a.next.next;for(;i!==a.prev;){if(a.i!==i.i&&tr(a,i)){let c=nt(a,i);a=F(a,a.next),c=F(c,c.next),$(a,e,r,o,n,s,0),$(c,e,r,o,n,s,0);return}i=i.next}a=a.next}while(a!==t)}function Zt(t,e,r,o,n,s){let a=[],i,c,l,u,d;for(i=0,c=e.length;i<c;i++)l=e[i]*o,u=i<c-1?e[i+1]*o:t.length,d=rt(t,l,u,o,!1,n&&n[i+1],s),d===d.next&&(d.steiner=!0),a.push(er(d));for(a.sort(Kt),i=0;i<a.length;i++)r=Yt(a[i],r);return r}function Kt(t,e){return t.x-e.x}function Yt(t,e){let r=Ht(t,e);if(!r)return e;let o=nt(r,t);return F(o,o.next),F(r,r.next)}function Ht(t,e){let r=e,o=t.x,n=t.y,s=-1/0,a;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let f=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=o&&f>s&&(s=f,a=r.x<r.next.x?r:r.next,f===o))return a}r=r.next}while(r!==e);if(!a)return null;let i=a,c=a.x,l=a.y,u=1/0,d;r=a;do o>=r.x&&r.x>=c&&o!==r.x&&T(n<l?o:s,n,c,l,n<l?s:o,n,r.x,r.y)&&(d=Math.abs(n-r.y)/(o-r.x),Z(r,t)&&(d<u||d===u&&(r.x>a.x||r.x===a.x&&Qt(a,r)))&&(a=r,u=d)),r=r.next;while(r!==i);return a}function Qt(t,e){return b(t.prev,t,e.prev)<0&&b(e.next,t,t.next)<0}function Xt(t,e,r,o){let n=t;do n.z===0&&(n.z=Ne(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,qt(n)}function qt(t){let e,r,o=1,n,s,a,i,c,l;do{for(s=t,t=null,l=null,n=0;s;){for(n++,i=s,a=0,r=0;r<o&&(a++,i=i.nextZ,!!i);r++);for(c=o;a>0||c>0&&i;)a!==0&&(c===0||!i||s.z<=i.z)?(e=s,s=s.nextZ,a--):(e=i,i=i.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=i}l.nextZ=null,o*=2}while(n>1);return t}function Ne(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function er(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function T(t,e,r,o,n,s,a,i){return(n-a)*(e-i)>=(t-a)*(s-i)&&(t-a)*(o-i)>=(r-a)*(e-i)&&(r-a)*(s-i)>=(n-a)*(o-i)}function tr(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!rr(t,e)&&(Z(t,e)&&Z(e,t)&&or(t,e)&&(b(t.prev,t,e.prev)||b(t,e.prev,e))||he(t,e)&&b(t.prev,t,t.next)>0&&b(e.prev,e,e.next)>0)}function b(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function he(t,e){return t.x===e.x&&t.y===e.y}function ot(t,e,r,o){let n=ue(b(t,e,r)),s=ue(b(t,e,o)),a=ue(b(r,o,t)),i=ue(b(r,o,e));return!!(n!==s&&a!==i||n===0&&le(t,r,e)||s===0&&le(t,o,e)||a===0&&le(r,t,o)||i===0&&le(r,e,o))}function le(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function ue(t){return t>0?1:t<0?-1:0}function rr(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&ot(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function Z(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function or(t,e){let r=t,o=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function nt(t,e){let r=new Y(t.i,t.x,t.y),o=new Y(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,s.next=o,o.prev=s,o}function tt(t,e,r,o){let n=new Y(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function K(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Y=class{constructor(e,r,o){j(this,"i",void 0),j(this,"x",void 0),j(this,"y",void 0),j(this,"prev",null),j(this,"next",null),j(this,"z",0),j(this,"prevZ",null),j(this,"nextZ",null),j(this,"steiner",!1),this.i=e,this.x=r,this.y=o}};function at(t,e,r){let o=cr(t),n=Object.keys(o).filter(s=>o[s]!==Array);return lr(t,{propArrayTypes:o,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function cr(t){let e={};for(let r of t)if(r.properties)for(let o in r.properties){let n=r.properties[o];e[o]=mr(n,e[o])}return e}function lr(t,e,r){let{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:s,linePathsCount:a,lineFeaturesCount:i,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:d,propArrayTypes:f,coordLength:y}=e,{numericPropKeys:m=[],PositionDataType:w=Float32Array,triangulate:A=!0}=r,v=t[0]&&"id"in t[0],R=t.length>65535?Uint32Array:Uint16Array,x={type:"Point",positions:new w(o*y),globalFeatureIds:new R(o),featureIds:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:s>65535?new Uint32Array(a+1):new Uint16Array(a+1),positions:new w(s*y),globalFeatureIds:new R(s),featureIds:i>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},N={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new w(c*y),globalFeatureIds:new R(c),featureIds:d>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};A&&(N.triangles=[]);for(let O of[x,g,N])for(let _ of m){let S=f[_];O.numericProps[_]=new S(O.positions.length/y)}g.pathIndices[a]=s,N.polygonIndices[l]=c,N.primitivePolygonIndices[u]=c;let C={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let O of t){let _=O.geometry,S=O.properties||{};switch(_.type){case"Point":ur(_,x,C,y,S),x.properties.push(Ie(S,m)),v&&x.fields.push({id:O.id}),C.pointFeature++;break;case"LineString":hr(_,g,C,y,S),g.properties.push(Ie(S,m)),v&&g.fields.push({id:O.id}),C.lineFeature++;break;case"Polygon":fr(_,N,C,y,S),N.properties.push(Ie(S,m)),v&&N.fields.push({id:O.id}),C.polygonFeature++;break;default:throw new Error("Invalid geometry type")}C.feature++}return dr(x,g,N,y)}function ur(t,e,r,o,n){e.positions.set(t.data,r.pointPosition*o);let s=t.data.length/o;Be(e,n,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function hr(t,e,r,o,n){e.positions.set(t.data,r.linePosition*o);let s=t.data.length/o;Be(e,n,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=t.indices[a],l=a===i-1?t.data.length:t.indices[a+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/o}}function fr(t,e,r,o,n){e.positions.set(t.data,r.polygonPosition*o);let s=t.data.length/o;Be(e,n,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[a],u=t.indices[a],d=t.indices[a+1];for(let y=0,m=u.length;y<m;++y){let w=u[y],A=y===m-1?d===void 0?t.data.length:d[0]:u[y+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(A-w)/o}let f=r.polygonPosition;pr(e,l,u,{startPosition:c,endPosition:f,coordLength:o})}}function pr(t,e,r,{startPosition:o,endPosition:n,coordLength:s}){if(!t.triangles)return;let a=o*s,i=n*s,c=t.positions.subarray(a,i),l=r[0],u=r.slice(1).map(f=>(f-l)/s),d=Oe(c,u,s,e);for(let f=0,y=d.length;f<y;++f)t.triangles.push(o+d[f])}function Se(t,e){let r={};for(let o in t)r[o]={value:t[o],size:e};return r}function dr(t,e,r,o){let n={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Se(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:o},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Se(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:o},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Se(r.numericProps,1)}};return n.polygons&&r.triangles&&(n.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),n}function Be(t,e,r,o){for(let n in t.numericProps)if(n in e){let s=e[n];t.numericProps[n].fill(s,r,r+o)}}function Ie(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}function mr(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function ct(t){let e=0,r=0,o=0,n=0,s=0,a=0,i=0,c=0,l=0,u=new Set;for(let d of t){let f=d.geometry;switch(f.type){case"Point":r++,e++,u.add(f.coordinates.length);break;case"MultiPoint":r++,e+=f.coordinates.length;for(let m of f.coordinates)u.add(m.length);break;case"LineString":s++,o+=f.coordinates.length,n++;for(let m of f.coordinates)u.add(m.length);break;case"MultiLineString":s++;for(let m of f.coordinates){o+=m.length,n++;for(let w of m)u.add(w.length)}break;case"Polygon":l++,i++,c+=f.coordinates.length;let y=f.coordinates.flat();a+=y.length;for(let m of y)u.add(m.length);break;case"MultiPolygon":l++;for(let m of f.coordinates){i++,c+=m.length;let w=m.flat();a+=w.length;for(let A of w)u.add(A.length)}break;default:throw new Error(`Unsupported geometry type: ${f.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:e,pointFeaturesCount:r,linePositionsCount:o,linePathsCount:n,lineFeaturesCount:s,polygonPositionsCount:a,polygonObjectsCount:i,polygonRingsCount:c,polygonFeaturesCount:l}}function ht(t,e={coordLength:2,fixRingWinding:!0}){return t.map(r=>yr(r,e))}function lt(t,e,r,o){r.push(e.length),e.push(...t);for(let n=t.length;n<o.coordLength;n++)e.push(0)}function Ee(t,e,r,o){r.push(e.length);for(let n of t){e.push(...n);for(let s=n.length;s<o.coordLength;s++)e.push(0)}}function ut(t,e,r,o,n){let s=0,a=[],i=[];for(let c of t){let l=c.map(f=>f.slice(0,2)),u=k(l.flat()),d=u<0;n.fixRingWinding&&(s===0&&!d||s>0&&d)&&(c.reverse(),u=-u),a.push(u),Ee(c,e,i,n),s++}s>0&&(o.push(a),r.push(i))}function yr(t,e){let{geometry:r}=t;if(r.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let o=[],n=[],s,a;switch(r.type){case"Point":a="Point",lt(r.coordinates,o,n,e);break;case"MultiPoint":a="Point",r.coordinates.map(i=>lt(i,o,n,e));break;case"LineString":a="LineString",Ee(r.coordinates,o,n,e);break;case"MultiLineString":a="LineString",r.coordinates.map(i=>Ee(i,o,n,e));break;case"Polygon":a="Polygon",s=[],ut(r.coordinates,o,n,s,e);break;case"MultiPolygon":a="Polygon",s=[],r.coordinates.map(i=>ut(i,o,n,s,e));break;default:throw new Error(`Unknown type: ${a}`)}return{...t,geometry:{type:a,indices:n,data:o,areas:s}}}function fe(t,e={fixRingWinding:!0,triangulate:!0}){let r=ct(t),o=r.coordLength,{fixRingWinding:n}=e,s=ht(t,{coordLength:o,fixRingWinding:n});return at(s,r,{numericPropKeys:e.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array,triangulate:e.triangulate})}var gr="4.3.0-alpha.6",Ce={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:gr,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},U={...Ce,parse:xr,parseTextSync:ft,parseInBatches:wr};async function xr(t,e){return ft(new TextDecoder().decode(t),e)}function ft(t,e){e={...U.options,...e},e.geojson={...U.options.geojson,...e.geojson},e.gis=e.gis||{};let r;try{r=JSON.parse(t)}catch{r={}}let o={shape:"geojson-table",type:"FeatureCollection",features:r?.features||[]};switch(e.gis.format){case"binary":return fe(o.features);default:return o}}function wr(t,e){e={...U.options,...e},e.json={...U.options.geojson,...e.geojson};let r=ae(t,e);switch(e.gis.format){case"binary":return br(r);default:return r}}async function*br(t){for await(let e of t)e.data=fe(e.data),yield e}function pt(t){let e=t.schema?.fields.findIndex(r=>r.name==="geometry")??-1;if(e>-1)return e;if(B(t)>0){let r=ie(t,0);for(let o=0;o<ne(t);o++){let n=r?.[o];if(n&&typeof n=="object")return o}}throw new Error("Failed to detect geometry column")}function dt(t,e,r=[]){let o={};for(let n=0;n<ne(t);++n){let s=t.schema?.fields[n].name;s&&!r.includes(n)&&(o[s]=e[s])}return o}function mt(t,e,r,o){let n=se(t,e);if(!n)return;let s=Ar(t,n,r),a=JSON.stringify(s);o.push(a)}function Ar(t,e,r){let o=dt(t,e,[r]),n=t.schema?.fields[r].name,s=n&&e[n];if(!s)return{type:"Feature",geometry:null,properties:o};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:o}:{type:"Feature",geometry:s,properties:o}}var pe=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(e){this.chunkSize=e}push(...e){for(let r of e)this.strings.push(r),this.totalLength+=r.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return this.textEncoder.encode(this.getStringBatch()).buffer}getStringBatch(){let e=this.strings.join("");return this.strings=[],this.totalLength=0,e}};async function*_e(t,e={}){let r={geojson:{},chunkSize:1e4,...e},o=new pe(r.chunkSize);r.geojson.featureArray||o.push(`{
12
+ Char: ${this.c}`;let r=new Error(e);this.error=r,this.emit("onerror",r)}};function J(t){return t===p.carriageReturn||t===p.lineFeed||t===p.space||t===p.tab}function Ft(t){let e=Math.max(ge,10),r=0;for(let o of["textNode","numberNode"]){let n=t[o]===void 0?0:t[o].length;if(n>e)switch(o){case"text":break;default:t._error(`Max buffer length exceeded: ${o}`)}r=Math.max(r,n)}t.bufferCheckPosition=ge-r+t.position}var P=class{path;constructor(e=null){if(this.path=["$"],e instanceof P){this.path=[...e.path];return}if(Array.isArray(e)){this.path.push(...e);return}if(typeof e=="string"&&(this.path=e.split("."),this.path[0]!=="$"))throw new Error("JSONPaths must start with $")}clone(){return new P(this)}toString(){return this.path.join(".")}push(e){this.path.push(e)}pop(){return this.path.pop()}set(e){this.path[this.path.length-1]=e}equals(e){if(!this||!e||this.path.length!==e.path.length)return!1;for(let r=0;r<this.path.length;++r)if(this.path[r]!==e.path[r])return!1;return!0}setFieldAtPath(e,r){let o=[...this.path];o.shift();let n=o.pop();for(let s of o)e=e[s];e[n]=r}getFieldAtPath(e){let r=[...this.path];r.shift();let o=r.pop();for(let n of r)e=e[n];return e[o]}};var G=class{parser;result=void 0;previousStates=[];currentState=Object.freeze({container:[],key:null});jsonpath=new P;constructor(e){this.reset(),this.parser=new C({onready:()=>{this.jsonpath=new P,this.previousStates.length=0,this.currentState.container.length=0},onopenobject:r=>{this._openObject({}),typeof r<"u"&&this.parser.emit("onkey",r)},onkey:r=>{this.jsonpath.set(r),this.currentState.key=r},oncloseobject:()=>{this._closeObject()},onopenarray:()=>{this._openArray()},onclosearray:()=>{this._closeArray()},onvalue:r=>{this._pushOrSet(r)},onerror:r=>{throw r},onend:()=>{this.result=this.currentState.container.pop()},...e})}reset(){this.result=void 0,this.previousStates=[],this.currentState=Object.freeze({container:[],key:null}),this.jsonpath=new P}write(e){this.parser.write(e)}close(){this.parser.close()}_pushOrSet(e){let{container:r,key:o}=this.currentState;o!==null?(r[o]=e,this.currentState.key=null):r.push(e)}_openArray(e=[]){this.jsonpath.push(null),this._pushOrSet(e),this.previousStates.push(this.currentState),this.currentState={container:e,isArray:!0,key:null}}_closeArray(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}_openObject(e={}){this.jsonpath.push(null),this._pushOrSet(e),this.previousStates.push(this.currentState),this.currentState={container:e,isArray:!1,key:null}}_closeObject(){this.jsonpath.pop(),this.currentState=this.previousStates.pop()}};var M=class extends G{jsonPaths;streamingJsonPath=null;streamingArray=null;topLevelObject=null;constructor(e={}){super({onopenarray:()=>{if(!this.streamingArray&&this._matchJSONPath()){this.streamingJsonPath=this.getJsonPath().clone(),this.streamingArray=[],this._openArray(this.streamingArray);return}this._openArray()},onopenobject:o=>{this.topLevelObject?this._openObject({}):(this.topLevelObject={},this._openObject(this.topLevelObject)),typeof o<"u"&&this.parser.emit("onkey",o)}});let r=e.jsonpaths||[];this.jsonPaths=r.map(o=>new P(o))}write(e){super.write(e);let r=[];return this.streamingArray&&(r=[...this.streamingArray],this.streamingArray.length=0),r}getPartialResult(){return this.topLevelObject}getStreamingJsonPath(){return this.streamingJsonPath}getStreamingJsonPathAsString(){return this.streamingJsonPath&&this.streamingJsonPath.toString()}getJsonPath(){return this.jsonpath}_matchJSONPath(){let e=this.getJsonPath();if(this.jsonPaths.length===0)return!0;for(let r of this.jsonPaths)if(r.equals(e))return!0;return!1}};async function*se(t,e){let r=D(t),{metadata:o}=e,{jsonpaths:n}=e.json||{},s=!0,a=null,i=new S(a,e),c=new M({jsonpaths:n});for await(let d of r){let f=c.write(d),y=f.length>0&&c.getStreamingJsonPathAsString();f.length>0&&s&&(o&&(yield{shape:e?.json?.shape||"array-row-table",batchType:"partial-result",data:[],length:0,bytesUsed:0,container:c.getPartialResult(),jsonpath:y}),s=!1);for(let w of f){i.addRow(w);let A=i.getFullBatch({jsonpath:y});A&&(yield A)}i.chunkComplete(d);let m=i.getFullBatch({jsonpath:y});m&&(yield m)}let l=c.getStreamingJsonPathAsString(),u=i.getFinalBatch({jsonpath:l});u&&(yield u),o&&(yield{shape:"json",batchType:"final-result",container:c.getPartialResult(),jsonpath:c.getStreamingJsonPathAsString(),data:[],length:0})}function $e(t,e){if(pe(t.batchType==="final-result"),t.jsonpath==="$")return e;if(t.jsonpath&&t.jsonpath.length>1){let r=t.container;return new P(t.jsonpath).setFieldAtPath(r,e),r}return t.container}var _t="4.3.0-alpha.8",ie={dataType:null,batchType:null,name:"JSON",id:"json",module:"json",version:_t,extensions:["json","geojson"],mimeTypes:["application/json"],category:"table",text:!0,options:{json:{shape:void 0,table:!1,jsonpaths:[]}},parse:kt,parseTextSync:Ze,parseInBatches:Rt};async function kt(t,e){return Ze(new TextDecoder().decode(t),e)}function Ze(t,e){let r={...e,json:{...ie.options.json,...e?.json}};return Ge(t,r)}function Rt(t,e){let r={...e,json:{...ie.options.json,...e?.json}};return se(t,r)}function xe(t){let r=t.trim().split(`
13
+ `).map((o,n)=>{try{return JSON.parse(o)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${n+1}`)}});return U(r)}async function*Ye(t,e){let r=D(t),o=de(r),n=me(o),s=null,a="row-table",i=new S(s,{...e,shape:a});for await(let{counter:l,line:u}of n)try{let d=JSON.parse(u);i.addRow(d),i.chunkComplete(u);let f=i.getFullBatch();f&&(yield f)}catch{throw new Error(`NDJSONLoader: failed to parse JSON on line ${l}`)}let c=i.getFinalBatch();c&&(yield c)}var Tt="4.3.0-alpha.8",Ke={dataType:null,batchType:null,name:"NDJSON",id:"ndjson",module:"json",version:Tt,extensions:["ndjson","jsonl"],mimeTypes:["application/x-ndjson","application/jsonlines","application/json-seq"],category:"table",text:!0,parse:async t=>xe(new TextDecoder().decode(t)),parseTextSync:xe,parseInBatches:Ye,options:{}};function we(t,e){let r=e?.json?.shape||"object-row-table",o=[],n=fe(t,r);for(let s of n)o.push(JSON.stringify(s));return`[${o.join(",")}]`}var He={id:"json",version:"latest",module:"json",name:"JSON",extensions:["json"],mimeTypes:["application/json"],options:{},text:!0,encode:async(t,e)=>new TextEncoder().encode(we(t,e)).buffer,encodeTextSync:(t,e)=>we(t,e)};var z={x:0,y:1,z:2};function k(t,e={}){let{start:r=0,end:o=t.length,plane:n="xy"}=e,s=e.size||2,a=0,i=z[n[0]],c=z[n[1]];for(let l=r,u=o-s;l<o;l+=s)a+=(t[l+i]-t[u+i])*(t[l+c]+t[u+c]),u=l;return a/2}function Ae(t,e,r=2,o,n="xy"){let s=e&&e.length,a=s?e[0]*r:t.length,i=Xe(t,0,a,r,!0,o&&o[0],n),c=[];if(!i||i.next===i.prev)return c;let l,u,d,f,y,m,w;if(s&&(i=zt(t,e,i,r,o,n)),t.length>80*r){f=u=t[0],y=d=t[1];for(let A=r;A<a;A+=r)m=t[A],w=t[A+1],m<f&&(f=m),w<y&&(y=w),m>u&&(u=m),w>d&&(d=w);l=Math.max(u-f,d-y),l=l!==0?32767/l:0}return W(i,c,r,f,y,l,0),c}function Xe(t,e,r,o,n,s,a){let i,c;s===void 0&&(s=k(t,{start:e,end:r,size:o,plane:a}));let l=z[a[0]],u=z[a[1]];if(n===s<0)for(i=e;i<r;i+=o)c=Qe(i,t[i+l],t[i+u],c);else for(i=r-o;i>=e;i-=o)c=Qe(i,t[i+l],t[i+u],c);return c&&le(c,c.next)&&($(c),c=c.next),c}function L(t,e){if(!t)return t;e||(e=t);let r=t,o;do if(o=!1,!r.steiner&&(le(r,r.next)||b(r.prev,r,r.next)===0)){if($(r),r=e=r.prev,r===r.next)break;o=!0}else r=r.next;while(o||r!==e);return e}function W(t,e,r,o,n,s,a){if(!t)return;!a&&s&&Yt(t,o,n,s);let i=t,c,l;for(;t.prev!==t.next;){if(c=t.prev,l=t.next,s?Jt(t,o,n,s):Dt(t)){e.push(c.i/r|0),e.push(t.i/r|0),e.push(l.i/r|0),$(t),t=l.next,i=l.next;continue}if(t=l,t===i){a?a===1?(t=Gt(L(t),e,r),W(t,e,r,o,n,s,2)):a===2&&Mt(t,e,r,o,n,s):W(L(t),e,r,o,n,s,1);break}}}function Dt(t){let e=t.prev,r=t,o=t.next;if(b(e,r,o)>=0)return!1;let n=e.x,s=r.x,a=o.x,i=e.y,c=r.y,l=o.y,u=n<s?n<a?n:a:s<a?s:a,d=i<c?i<l?i:l:c<l?c:l,f=n>s?n>a?n:a:s>a?s:a,y=i>c?i>l?i:l:c>l?c:l,m=o.next;for(;m!==e;){if(m.x>=u&&m.x<=f&&m.y>=d&&m.y<=y&&R(n,i,s,c,a,l,m.x,m.y)&&b(m.prev,m,m.next)>=0)return!1;m=m.next}return!0}function Jt(t,e,r,o){let n=t.prev,s=t,a=t.next;if(b(n,s,a)>=0)return!1;let i=n.x,c=s.x,l=a.x,u=n.y,d=s.y,f=a.y,y=i<c?i<l?i:l:c<l?c:l,m=u<d?u<f?u:f:d<f?d:f,w=i>c?i>l?i:l:c>l?c:l,A=u>d?u>f?u:f:d>f?d:f,F=be(y,m,e,r,o),_=be(w,A,e,r,o),x=t.prevZ,g=t.nextZ;for(;x&&x.z>=F&&g&&g.z<=_;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&R(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0||(x=x.prevZ,g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&R(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0))return!1;g=g.nextZ}for(;x&&x.z>=F;){if(x.x>=y&&x.x<=w&&x.y>=m&&x.y<=A&&x!==n&&x!==a&&R(i,u,c,d,l,f,x.x,x.y)&&b(x.prev,x,x.next)>=0)return!1;x=x.prevZ}for(;g&&g.z<=_;){if(g.x>=y&&g.x<=w&&g.y>=m&&g.y<=A&&g!==n&&g!==a&&R(i,u,c,d,l,f,g.x,g.y)&&b(g.prev,g,g.next)>=0)return!1;g=g.nextZ}return!0}function Gt(t,e,r){let o=t;do{let n=o.prev,s=o.next.next;!le(n,s)&&qe(n,o,o.next,s)&&V(n,s)&&V(s,n)&&(e.push(n.i/r|0),e.push(o.i/r|0),e.push(s.i/r|0),$(o),$(o.next),o=t=s),o=o.next}while(o!==t);return L(o)}function Mt(t,e,r,o,n,s){let a=t;do{let i=a.next.next;for(;i!==a.prev;){if(a.i!==i.i&&Qt(a,i)){let c=et(a,i);a=L(a,a.next),c=L(c,c.next),W(a,e,r,o,n,s,0),W(c,e,r,o,n,s,0);return}i=i.next}a=a.next}while(a!==t)}function zt(t,e,r,o,n,s){let a=[],i,c,l,u,d;for(i=0,c=e.length;i<c;i++)l=e[i]*o,u=i<c-1?e[i+1]*o:t.length,d=Xe(t,l,u,o,!1,n&&n[i+1],s),d===d.next&&(d.steiner=!0),a.push(Ht(d));for(a.sort(Wt),i=0;i<a.length;i++)r=Vt(a[i],r);return r}function Wt(t,e){return t.x-e.x}function Vt(t,e){let r=$t(t,e);if(!r)return e;let o=et(r,t);return L(o,o.next),L(r,r.next)}function $t(t,e){let r=e,o=t.x,n=t.y,s=-1/0,a;do{if(n<=r.y&&n>=r.next.y&&r.next.y!==r.y){let f=r.x+(n-r.y)*(r.next.x-r.x)/(r.next.y-r.y);if(f<=o&&f>s&&(s=f,a=r.x<r.next.x?r:r.next,f===o))return a}r=r.next}while(r!==e);if(!a)return null;let i=a,c=a.x,l=a.y,u=1/0,d;r=a;do o>=r.x&&r.x>=c&&o!==r.x&&R(n<l?o:s,n,c,l,n<l?s:o,n,r.x,r.y)&&(d=Math.abs(n-r.y)/(o-r.x),V(r,t)&&(d<u||d===u&&(r.x>a.x||r.x===a.x&&Zt(a,r)))&&(a=r,u=d)),r=r.next;while(r!==i);return a}function Zt(t,e){return b(t.prev,t,e.prev)<0&&b(e.next,t,t.next)<0}function Yt(t,e,r,o){let n=t;do n.z===0&&(n.z=be(n.x,n.y,e,r,o)),n.prevZ=n.prev,n.nextZ=n.next,n=n.next;while(n!==t);n.prevZ.nextZ=null,n.prevZ=null,Kt(n)}function Kt(t){let e,r,o=1,n,s,a,i,c,l;do{for(s=t,t=null,l=null,n=0;s;){for(n++,i=s,a=0,r=0;r<o&&(a++,i=i.nextZ,!!i);r++);for(c=o;a>0||c>0&&i;)a!==0&&(c===0||!i||s.z<=i.z)?(e=s,s=s.nextZ,a--):(e=i,i=i.nextZ,c--),l?l.nextZ=e:t=e,e.prevZ=l,l=e;s=i}l.nextZ=null,o*=2}while(n>1);return t}function be(t,e,r,o,n){return t=(t-r)*n|0,e=(e-o)*n|0,t=(t|t<<8)&16711935,t=(t|t<<4)&252645135,t=(t|t<<2)&858993459,t=(t|t<<1)&1431655765,e=(e|e<<8)&16711935,e=(e|e<<4)&252645135,e=(e|e<<2)&858993459,e=(e|e<<1)&1431655765,t|e<<1}function Ht(t){let e=t,r=t;do(e.x<r.x||e.x===r.x&&e.y<r.y)&&(r=e),e=e.next;while(e!==t);return r}function R(t,e,r,o,n,s,a,i){return(n-a)*(e-i)>=(t-a)*(s-i)&&(t-a)*(o-i)>=(r-a)*(e-i)&&(r-a)*(s-i)>=(n-a)*(o-i)}function Qt(t,e){return t.next.i!==e.i&&t.prev.i!==e.i&&!Xt(t,e)&&(V(t,e)&&V(e,t)&&qt(t,e)&&(b(t.prev,t,e.prev)||b(t,e.prev,e))||le(t,e)&&b(t.prev,t,t.next)>0&&b(e.prev,e,e.next)>0)}function b(t,e,r){return(e.y-t.y)*(r.x-e.x)-(e.x-t.x)*(r.y-e.y)}function le(t,e){return t.x===e.x&&t.y===e.y}function qe(t,e,r,o){let n=ce(b(t,e,r)),s=ce(b(t,e,o)),a=ce(b(r,o,t)),i=ce(b(r,o,e));return!!(n!==s&&a!==i||n===0&&ae(t,r,e)||s===0&&ae(t,o,e)||a===0&&ae(r,t,o)||i===0&&ae(r,e,o))}function ae(t,e,r){return e.x<=Math.max(t.x,r.x)&&e.x>=Math.min(t.x,r.x)&&e.y<=Math.max(t.y,r.y)&&e.y>=Math.min(t.y,r.y)}function ce(t){return t>0?1:t<0?-1:0}function Xt(t,e){let r=t;do{if(r.i!==t.i&&r.next.i!==t.i&&r.i!==e.i&&r.next.i!==e.i&&qe(r,r.next,t,e))return!0;r=r.next}while(r!==t);return!1}function V(t,e){return b(t.prev,t,t.next)<0?b(t,e,t.next)>=0&&b(t,t.prev,e)>=0:b(t,e,t.prev)<0||b(t,t.next,e)<0}function qt(t,e){let r=t,o=!1,n=(t.x+e.x)/2,s=(t.y+e.y)/2;do r.y>s!=r.next.y>s&&r.next.y!==r.y&&n<(r.next.x-r.x)*(s-r.y)/(r.next.y-r.y)+r.x&&(o=!o),r=r.next;while(r!==t);return o}function et(t,e){let r=new Z(t.i,t.x,t.y),o=new Z(e.i,e.x,e.y),n=t.next,s=e.prev;return t.next=e,e.prev=t,r.next=n,n.prev=r,o.next=r,r.prev=o,s.next=o,o.prev=s,o}function Qe(t,e,r,o){let n=new Z(t,e,r);return o?(n.next=o.next,n.prev=o,o.next.prev=n,o.next=n):(n.prev=n,n.next=n),n}function $(t){t.next.prev=t.prev,t.prev.next=t.next,t.prevZ&&(t.prevZ.nextZ=t.nextZ),t.nextZ&&(t.nextZ.prevZ=t.prevZ)}var Z=class{constructor(e,r,o){this.prev=null,this.next=null,this.z=0,this.prevZ=null,this.nextZ=null,this.steiner=!1,this.i=e,this.x=r,this.y=o}};function ot(t,e,r){let o=nr(t),n=Object.keys(o).filter(s=>o[s]!==Array);return sr(t,{propArrayTypes:o,...e},{numericPropKeys:r&&r.numericPropKeys||n,PositionDataType:r?r.PositionDataType:Float32Array,triangulate:r?r.triangulate:!0})}function nr(t){let e={};for(let r of t)if(r.properties)for(let o in r.properties){let n=r.properties[o];e[o]=hr(n,e[o])}return e}function sr(t,e,r){let{pointPositionsCount:o,pointFeaturesCount:n,linePositionsCount:s,linePathsCount:a,lineFeaturesCount:i,polygonPositionsCount:c,polygonObjectsCount:l,polygonRingsCount:u,polygonFeaturesCount:d,propArrayTypes:f,coordLength:y}=e,{numericPropKeys:m=[],PositionDataType:w=Float32Array,triangulate:A=!0}=r,F=t[0]&&"id"in t[0],_=t.length>65535?Uint32Array:Uint16Array,x={type:"Point",positions:new w(o*y),globalFeatureIds:new _(o),featureIds:n>65535?new Uint32Array(o):new Uint16Array(o),numericProps:{},properties:[],fields:[]},g={type:"LineString",pathIndices:s>65535?new Uint32Array(a+1):new Uint16Array(a+1),positions:new w(s*y),globalFeatureIds:new _(s),featureIds:i>65535?new Uint32Array(s):new Uint16Array(s),numericProps:{},properties:[],fields:[]},j={type:"Polygon",polygonIndices:c>65535?new Uint32Array(l+1):new Uint16Array(l+1),primitivePolygonIndices:c>65535?new Uint32Array(u+1):new Uint16Array(u+1),positions:new w(c*y),globalFeatureIds:new _(c),featureIds:d>65535?new Uint32Array(c):new Uint16Array(c),numericProps:{},properties:[],fields:[]};A&&(j.triangles=[]);for(let N of[x,g,j])for(let E of m){let O=f[E];N.numericProps[E]=new O(N.positions.length/y)}g.pathIndices[a]=s,j.polygonIndices[l]=c,j.primitivePolygonIndices[u]=c;let B={pointPosition:0,pointFeature:0,linePosition:0,linePath:0,lineFeature:0,polygonPosition:0,polygonObject:0,polygonRing:0,polygonFeature:0,feature:0};for(let N of t){let E=N.geometry,O=N.properties||{};switch(E.type){case"Point":ir(E,x,B,y,O),x.properties.push(je(O,m)),F&&x.fields.push({id:N.id}),B.pointFeature++;break;case"LineString":ar(E,g,B,y,O),g.properties.push(je(O,m)),F&&g.fields.push({id:N.id}),B.lineFeature++;break;case"Polygon":cr(E,j,B,y,O),j.properties.push(je(O,m)),F&&j.fields.push({id:N.id}),B.polygonFeature++;break;default:throw new Error("Invalid geometry type")}B.feature++}return ur(x,g,j,y)}function ir(t,e,r,o,n){e.positions.set(t.data,r.pointPosition*o);let s=t.data.length/o;Ne(e,n,r.pointPosition,s),e.globalFeatureIds.fill(r.feature,r.pointPosition,r.pointPosition+s),e.featureIds.fill(r.pointFeature,r.pointPosition,r.pointPosition+s),r.pointPosition+=s}function ar(t,e,r,o,n){e.positions.set(t.data,r.linePosition*o);let s=t.data.length/o;Ne(e,n,r.linePosition,s),e.globalFeatureIds.fill(r.feature,r.linePosition,r.linePosition+s),e.featureIds.fill(r.lineFeature,r.linePosition,r.linePosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=t.indices[a],l=a===i-1?t.data.length:t.indices[a+1];e.pathIndices[r.linePath++]=r.linePosition,r.linePosition+=(l-c)/o}}function cr(t,e,r,o,n){e.positions.set(t.data,r.polygonPosition*o);let s=t.data.length/o;Ne(e,n,r.polygonPosition,s),e.globalFeatureIds.fill(r.feature,r.polygonPosition,r.polygonPosition+s),e.featureIds.fill(r.polygonFeature,r.polygonPosition,r.polygonPosition+s);for(let a=0,i=t.indices.length;a<i;++a){let c=r.polygonPosition;e.polygonIndices[r.polygonObject++]=c;let l=t.areas[a],u=t.indices[a],d=t.indices[a+1];for(let y=0,m=u.length;y<m;++y){let w=u[y],A=y===m-1?d===void 0?t.data.length:d[0]:u[y+1];e.primitivePolygonIndices[r.polygonRing++]=r.polygonPosition,r.polygonPosition+=(A-w)/o}let f=r.polygonPosition;lr(e,l,u,{startPosition:c,endPosition:f,coordLength:o})}}function lr(t,e,r,{startPosition:o,endPosition:n,coordLength:s}){if(!t.triangles)return;let a=o*s,i=n*s,c=t.positions.subarray(a,i),l=r[0],u=r.slice(1).map(f=>(f-l)/s),d=Ae(c,u,s,e);for(let f=0,y=d.length;f<y;++f)t.triangles.push(o+d[f])}function Pe(t,e){let r={};for(let o in t)r[o]={value:t[o],size:e};return r}function ur(t,e,r,o){let n={shape:"binary-feature-collection",points:{...t,positions:{value:t.positions,size:o},globalFeatureIds:{value:t.globalFeatureIds,size:1},featureIds:{value:t.featureIds,size:1},numericProps:Pe(t.numericProps,1)},lines:{...e,positions:{value:e.positions,size:o},pathIndices:{value:e.pathIndices,size:1},globalFeatureIds:{value:e.globalFeatureIds,size:1},featureIds:{value:e.featureIds,size:1},numericProps:Pe(e.numericProps,1)},polygons:{...r,positions:{value:r.positions,size:o},polygonIndices:{value:r.polygonIndices,size:1},primitivePolygonIndices:{value:r.primitivePolygonIndices,size:1},globalFeatureIds:{value:r.globalFeatureIds,size:1},featureIds:{value:r.featureIds,size:1},numericProps:Pe(r.numericProps,1)}};return n.polygons&&r.triangles&&(n.polygons.triangles={value:new Uint32Array(r.triangles),size:1}),n}function Ne(t,e,r,o){for(let n in t.numericProps)if(n in e){let s=e[n];t.numericProps[n].fill(s,r,r+o)}}function je(t,e){let r={};for(let o in t)e.includes(o)||(r[o]=t[o]);return r}function hr(t,e){return e===Array||!Number.isFinite(t)?Array:e===Float64Array||Math.fround(t)!==t?Float64Array:Float32Array}function nt(t){let e=0,r=0,o=0,n=0,s=0,a=0,i=0,c=0,l=0,u=new Set;for(let d of t){let f=d.geometry;switch(f.type){case"Point":r++,e++,u.add(f.coordinates.length);break;case"MultiPoint":r++,e+=f.coordinates.length;for(let m of f.coordinates)u.add(m.length);break;case"LineString":s++,o+=f.coordinates.length,n++;for(let m of f.coordinates)u.add(m.length);break;case"MultiLineString":s++;for(let m of f.coordinates){o+=m.length,n++;for(let w of m)u.add(w.length)}break;case"Polygon":l++,i++,c+=f.coordinates.length;let y=f.coordinates.flat();a+=y.length;for(let m of y)u.add(m.length);break;case"MultiPolygon":l++;for(let m of f.coordinates){i++,c+=m.length;let w=m.flat();a+=w.length;for(let A of w)u.add(A.length)}break;default:throw new Error(`Unsupported geometry type: ${f.type}`)}}return{coordLength:u.size>0?Math.max(...u):2,pointPositionsCount:e,pointFeaturesCount:r,linePositionsCount:o,linePathsCount:n,lineFeaturesCount:s,polygonPositionsCount:a,polygonObjectsCount:i,polygonRingsCount:c,polygonFeaturesCount:l}}function at(t,e={coordLength:2,fixRingWinding:!0}){return t.map(r=>fr(r,e))}function st(t,e,r,o){r.push(e.length),e.push(...t);for(let n=t.length;n<o.coordLength;n++)e.push(0)}function Oe(t,e,r,o){r.push(e.length);for(let n of t){e.push(...n);for(let s=n.length;s<o.coordLength;s++)e.push(0)}}function it(t,e,r,o,n){let s=0,a=[],i=[];for(let c of t){let l=c.map(f=>f.slice(0,2)),u=k(l.flat()),d=u<0;n.fixRingWinding&&(s===0&&!d||s>0&&d)&&(c.reverse(),u=-u),a.push(u),Oe(c,e,i,n),s++}s>0&&(o.push(a),r.push(i))}function fr(t,e){let{geometry:r}=t;if(r.type==="GeometryCollection")throw new Error("GeometryCollection type not supported");let o=[],n=[],s,a;switch(r.type){case"Point":a="Point",st(r.coordinates,o,n,e);break;case"MultiPoint":a="Point",r.coordinates.map(i=>st(i,o,n,e));break;case"LineString":a="LineString",Oe(r.coordinates,o,n,e);break;case"MultiLineString":a="LineString",r.coordinates.map(i=>Oe(i,o,n,e));break;case"Polygon":a="Polygon",s=[],it(r.coordinates,o,n,s,e);break;case"MultiPolygon":a="Polygon",s=[],r.coordinates.map(i=>it(i,o,n,s,e));break;default:throw new Error(`Unknown type: ${a}`)}return{...t,geometry:{type:a,indices:n,data:o,areas:s}}}function ue(t,e={fixRingWinding:!0,triangulate:!0}){let r=nt(t),o=r.coordLength,{fixRingWinding:n}=e,s=at(t,{coordLength:o,fixRingWinding:n});return ot(s,r,{numericPropKeys:e.numericPropKeys,PositionDataType:e.PositionDataType||Float32Array,triangulate:e.triangulate})}var pr="4.3.0-alpha.8",Se={dataType:null,batchType:null,name:"GeoJSON",id:"geojson",module:"geojson",version:pr,worker:!0,extensions:["geojson"],mimeTypes:["application/geo+json"],category:"geometry",text:!0,options:{geojson:{shape:"geojson-table"},json:{shape:"object-row-table",jsonpaths:["$","$.features"]},gis:{format:"geojson"}}},T={...Se,parse:dr,parseTextSync:ct,parseInBatches:mr};async function dr(t,e){return ct(new TextDecoder().decode(t),e)}function ct(t,e){e={...T.options,...e},e.geojson={...T.options.geojson,...e.geojson},e.gis=e.gis||{};let r;try{r=JSON.parse(t)}catch{r={}}let o={shape:"geojson-table",type:"FeatureCollection",features:r?.features||[]};switch(e.gis.format){case"binary":return ue(o.features);default:return o}}function mr(t,e){e={...T.options,...e},e.json={...T.options.geojson,...e.geojson};let r=se(t,e);switch(e.gis.format){case"binary":return yr(r);default:return r}}async function*yr(t){for await(let e of t)e.data=ue(e.data),yield e}function lt(t){let e=t.schema?.fields.findIndex(r=>r.name==="geometry")??-1;if(e>-1)return e;if(I(t)>0){let r=ne(t,0);for(let o=0;o<re(t);o++){let n=r?.[o];if(n&&typeof n=="object")return o}}throw new Error("Failed to detect geometry column")}function ut(t,e,r=[]){let o={};for(let n=0;n<re(t);++n){let s=t.schema?.fields[n].name;s&&!r.includes(n)&&(o[s]=e[s])}return o}function ht(t,e,r,o){let n=oe(t,e);if(!n)return;let s=gr(t,n,r),a=JSON.stringify(s);o.push(a)}function gr(t,e,r){let o=ut(t,e,[r]),n=t.schema?.fields[r].name,s=n&&e[n];if(!s)return{type:"Feature",geometry:null,properties:o};if(typeof s=="string")try{s=JSON.parse(s)}catch{throw new Error("Invalid string geometry")}if(typeof s!="object"||typeof s?.type!="string")throw new Error("invalid geometry column value");return s?.type==="Feature"?{...s,properties:o}:{type:"Feature",geometry:s,properties:o}}var he=class{chunkSize;strings=[];totalLength=0;textEncoder=new TextEncoder;constructor(e){this.chunkSize=e}push(...e){for(let r of e)this.strings.push(r),this.totalLength+=r.length}isFull(){return this.totalLength>=this.chunkSize}getArrayBufferBatch(){return this.textEncoder.encode(this.getStringBatch()).buffer}getStringBatch(){let e=this.strings.join("");return this.strings=[],this.totalLength=0,e}};async function*Ie(t,e={}){let r={geojson:{},chunkSize:1e4,...e},o=new he(r.chunkSize);r.geojson.featureArray||o.push(`{
14
14
  `,`"type": "FeatureCollection",
15
15
  `,`"features":
16
- `),o.push("[");let n=r.geojson.geometryColumn,s=!0,a=0;for await(let i of t){let c=a+B(i);n||(n=n||pt(i));for(let u=a;u<c;++u)s||o.push(","),o.push(`
17
- `),s=!1,mt(i,u,n,o),o.isFull()&&(yield o.getArrayBufferBatch()),a=c;let l=o.getArrayBufferBatch();l.byteLength>0&&(yield l)}o.push(`
16
+ `),o.push("[");let n=r.geojson.geometryColumn,s=!0,a=0;for await(let i of t){let c=a+I(i);n||(n=n||lt(i));for(let u=a;u<c;++u)s||o.push(","),o.push(`
17
+ `),s=!1,ht(i,u,n,o),o.isFull()&&(yield o.getArrayBufferBatch()),a=c;let l=o.getArrayBufferBatch();l.byteLength>0&&(yield l)}o.push(`
18
18
  `),o.push(`]
19
- `),r.geojson.featureArray||o.push("}"),yield o.getArrayBufferBatch()}var yt={id:"geojson",version:"latest",module:"geojson",name:"GeoJSON",extensions:["geojson"],mimeTypes:["application/geo+json"],text:!0,options:{geojson:{featureArray:!1,geometryColumn:null}},async encode(t,e){let o=_e([t],e);return await be(o)},encodeInBatches:(t,e)=>_e(t,e)};return St(H);})();
19
+ `),r.geojson.featureArray||o.push("}"),yield o.getArrayBufferBatch()}var ft={id:"geojson",version:"latest",module:"geojson",name:"GeoJSON",extensions:["geojson"],mimeTypes:["application/geo+json"],text:!0,options:{geojson:{featureArray:!1,geometryColumn:null}},async encode(t,e){let o=Ie([t],e);return await ye(o)},encodeInBatches:(t,e)=>Ie(t,e)};return Pt(Y);})();
20
20
  return __exports__;
21
21
  });
@@ -1 +1 @@
1
- {"version":3,"file":"geojson-loader.d.ts","sourceRoot":"","sources":["../src/geojson-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAC,iBAAiB,EAAC,yBAAsB;AASrD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG;IACrD,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,eAAe,CAAC;KACzB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;KAC/B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;CAyB2C,CAAC;AAE5E,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;CAO2D,CAAC;AAEtF,iBAAe,KAAK,CAClB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,YAAY,GAAG,uBAAuB,CAAC,CAEjD;AAED,iBAAS,aAAa,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,oBAAoB,GAC7B,YAAY,GAAG,uBAAuB,CA2BxC;AAED,iBAAS,cAAc,CAAC,aAAa,KAAA,EAAE,OAAO,KAAA,GAAG,aAAa,CAAC,UAAU,CAAC,CAazE"}
1
+ {"version":3,"file":"geojson-loader.d.ts","sourceRoot":"","sources":["../src/geojson-loader.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,uBAAuB,EAAE,YAAY,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC1F,OAAO,KAAK,EAAC,iBAAiB,EAAC,yBAAsB;AASrD,MAAM,MAAM,oBAAoB,GAAG,iBAAiB,GAAG;IACrD,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,eAAe,CAAC;KACzB,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,MAAM,CAAC,EAAE,SAAS,GAAG,QAAQ,CAAC;KAC/B,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mBAAmB;uBACD,YAAY;wBACX,UAAU;;;;;;;;;;;;;;;;;;;;;;CAuBiC,CAAC;AAE5E,eAAO,MAAM,aAAa;;;;uBA1BK,YAAY;wBACX,UAAU;;;;;;;;;;;;;;;;;;;;;;CAgC2C,CAAC;AAEtF,iBAAe,KAAK,CAClB,WAAW,EAAE,WAAW,EACxB,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,YAAY,GAAG,uBAAuB,CAAC,CAEjD;AAED,iBAAS,aAAa,CACpB,IAAI,EAAE,MAAM,EACZ,OAAO,CAAC,EAAE,oBAAoB,GAC7B,YAAY,GAAG,uBAAuB,CA2BxC;AAED,iBAAS,cAAc,CAAC,aAAa,KAAA,EAAE,OAAO,KAAA,GAAG,aAAa,CAAC,UAAU,CAAC,CAazE"}
@@ -6,7 +6,7 @@ import { geojsonToBinary } from '@loaders.gl/gis';
6
6
  import { parseJSONInBatches } from "./lib/parsers/parse-json-in-batches.js";
7
7
  // __VERSION__ is injected by babel-plugin-version-inline
8
8
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
9
- const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
9
+ const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest';
10
10
  /**
11
11
  * GeoJSON loader
12
12
  */
@@ -7,52 +7,6 @@
7
7
  return value;
8
8
  };
9
9
 
10
- // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
11
- function _typeof(obj) {
12
- "@babel/helpers - typeof";
13
- return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
14
- return typeof obj2;
15
- } : function(obj2) {
16
- return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
17
- }, _typeof(obj);
18
- }
19
-
20
- // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
21
- function _toPrimitive(input, hint) {
22
- if (_typeof(input) !== "object" || input === null)
23
- return input;
24
- var prim = input[Symbol.toPrimitive];
25
- if (prim !== void 0) {
26
- var res = prim.call(input, hint || "default");
27
- if (_typeof(res) !== "object")
28
- return res;
29
- throw new TypeError("@@toPrimitive must return a primitive value.");
30
- }
31
- return (hint === "string" ? String : Number)(input);
32
- }
33
-
34
- // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
35
- function _toPropertyKey(arg) {
36
- var key = _toPrimitive(arg, "string");
37
- return _typeof(key) === "symbol" ? key : String(key);
38
- }
39
-
40
- // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
41
- function _defineProperty(obj, key, value) {
42
- key = _toPropertyKey(key);
43
- if (key in obj) {
44
- Object.defineProperty(obj, key, {
45
- value,
46
- enumerable: true,
47
- configurable: true,
48
- writable: true
49
- });
50
- } else {
51
- obj[key] = value;
52
- }
53
- return obj;
54
- }
55
-
56
10
  // ../worker-utils/src/lib/node/worker_threads-browser.ts
57
11
  var parentPort = null;
58
12
 
@@ -664,11 +618,7 @@
664
618
  z: 2
665
619
  };
666
620
  function getPolygonSignedArea(points, options = {}) {
667
- const {
668
- start = 0,
669
- end = points.length,
670
- plane = "xy"
671
- } = options;
621
+ const { start = 0, end = points.length, plane = "xy" } = options;
672
622
  const dim = options.size || 2;
673
623
  let area2 = 0;
674
624
  const i0 = DimIndex[plane[0]];
@@ -722,12 +672,7 @@
722
672
  let i;
723
673
  let last;
724
674
  if (area2 === void 0) {
725
- area2 = getPolygonSignedArea(data, {
726
- start,
727
- end,
728
- size: dim,
729
- plane
730
- });
675
+ area2 = getPolygonSignedArea(data, { start, end, size: dim, plane });
731
676
  }
732
677
  let i0 = DimIndex[plane[0]];
733
678
  let i1 = DimIndex[plane[1]];
@@ -1062,7 +1007,10 @@
1062
1007
  return (cx - px) * (ay - py) >= (ax - px) * (cy - py) && (ax - px) * (by - py) >= (bx - px) * (ay - py) && (bx - px) * (cy - py) >= (cx - px) * (by - py);
1063
1008
  }
1064
1009
  function isValidDiagonal(a, b) {
1065
- return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && (area(a.prev, a, b.prev) || area(a, b.prev, b)) || equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
1010
+ return a.next.i !== b.i && a.prev.i !== b.i && !intersectsPolygon(a, b) && // dones't intersect other edges
1011
+ (locallyInside(a, b) && locallyInside(b, a) && middleInside(a, b) && // locally visible
1012
+ (area(a.prev, a, b.prev) || area(a, b.prev, b)) || // does not create opposite-facing sectors
1013
+ equals(a, b) && area(a.prev, a, a.next) > 0 && area(b.prev, b, b.next) > 0);
1066
1014
  }
1067
1015
  function area(p, q, r) {
1068
1016
  return (q.y - p.y) * (r.x - q.x) - (q.x - p.x) * (r.y - q.y);
@@ -1155,15 +1103,12 @@
1155
1103
  }
1156
1104
  var Vertex = class {
1157
1105
  constructor(i, x, y) {
1158
- _defineProperty(this, "i", void 0);
1159
- _defineProperty(this, "x", void 0);
1160
- _defineProperty(this, "y", void 0);
1161
- _defineProperty(this, "prev", null);
1162
- _defineProperty(this, "next", null);
1163
- _defineProperty(this, "z", 0);
1164
- _defineProperty(this, "prevZ", null);
1165
- _defineProperty(this, "nextZ", null);
1166
- _defineProperty(this, "steiner", false);
1106
+ this.prev = null;
1107
+ this.next = null;
1108
+ this.z = 0;
1109
+ this.prevZ = null;
1110
+ this.nextZ = null;
1111
+ this.steiner = false;
1167
1112
  this.i = i;
1168
1113
  this.x = x;
1169
1114
  this.y = y;
@@ -2454,7 +2399,7 @@ Char: ${this.c}`;
2454
2399
  }
2455
2400
 
2456
2401
  // src/geojson-loader.ts
2457
- var VERSION = true ? "4.3.0-alpha.6" : "latest";
2402
+ var VERSION = true ? "4.3.0-alpha.8" : "latest";
2458
2403
  var GeoJSONWorkerLoader = {
2459
2404
  dataType: null,
2460
2405
  batchType: null,
@@ -1 +1 @@
1
- {"version":3,"file":"geojson-writer.d.ts","sourceRoot":"","sources":["../src/geojson-writer.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;6BAeJ,KAAK,WAAW,oBAAoB,KAAG,QAAQ,WAAW,CAAC;8CAM9C,cAAc,UAAU,CAAC,GAAG,SAAS,UAAU,CAAC;CAEJ,CAAC"}
1
+ {"version":3,"file":"geojson-writer.d.ts","sourceRoot":"","sources":["../src/geojson-writer.ts"],"names":[],"mappings":"AAKA,OAAO,EAEL,KAAK,aAAa,EAEnB,MAAM,0BAA0B,CAAC;AAClC,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,aAAa;;;;;;;;;;;;;;6BAeJ,KAAK,WAAW,oBAAoB,KAAG,OAAO,CAAC,WAAW,CAAC;8CAM9C,aAAa,CAAC,UAAU,CAAC,GAAG,QAAQ,CAAC,UAAU,CAAC;CAEJ,CAAC"}
package/dist/index.cjs CHANGED
@@ -923,7 +923,7 @@ function rebuildJsonObject(batch, data) {
923
923
  }
924
924
 
925
925
  // dist/json-loader.js
926
- var VERSION = true ? "4.3.0-alpha.6" : "latest";
926
+ var VERSION = true ? "4.3.0-alpha.8" : "latest";
927
927
  var JSONLoader = {
928
928
  dataType: null,
929
929
  batchType: null,
@@ -1006,7 +1006,7 @@ async function* parseNDJSONInBatches(binaryAsyncIterator, options) {
1006
1006
  }
1007
1007
 
1008
1008
  // dist/ndjson-loader.js
1009
- var VERSION2 = true ? "4.3.0-alpha.6" : "latest";
1009
+ var VERSION2 = true ? "4.3.0-alpha.8" : "latest";
1010
1010
  var NDJSONLoader = {
1011
1011
  dataType: null,
1012
1012
  batchType: null,
@@ -1058,7 +1058,7 @@ var JSONWriter = {
1058
1058
 
1059
1059
  // dist/geojson-loader.js
1060
1060
  var import_gis = require("@loaders.gl/gis");
1061
- var VERSION3 = true ? "4.3.0-alpha.6" : "latest";
1061
+ var VERSION3 = true ? "4.3.0-alpha.8" : "latest";
1062
1062
  var GeoJSONWorkerLoader = {
1063
1063
  dataType: null,
1064
1064
  batchType: null,
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["index.js", "lib/parsers/parse-json.js", "lib/parsers/parse-json-in-batches.js", "lib/clarinet/clarinet.js", "lib/jsonpath/jsonpath.js", "lib/json-parser/json-parser.js", "lib/json-parser/streaming-json-parser.js", "json-loader.js", "lib/parsers/parse-ndjson.js", "lib/parsers/parse-ndjson-in-batches.js", "ndjson-loader.js", "lib/encoders/json-encoder.js", "json-writer.js", "geojson-loader.js", "geojson-writer.js", "lib/encoders/geojson-encoder.js", "lib/encoder-utils/encode-utils.js", "lib/encoder-utils/encode-table-row.js", "lib/encoder-utils/utf8-encoder.js"],
4
- "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { JSONLoader } from \"./json-loader.js\";\nexport { NDJSONLoader } from \"./ndjson-loader.js\";\nexport { JSONWriter } from \"./json-writer.js\";\nexport { GeoJSONLoader as _GeoJSONLoader, GeoJSONWorkerLoader as _GeoJSONWorkerLoader } from \"./geojson-loader.js\";\nexport { GeoJSONWriter as _GeoJSONWriter } from \"./geojson-writer.js\";\nexport { default as _JSONPath } from \"./lib/jsonpath/jsonpath.js\";\nexport { default as _ClarinetParser } from \"./lib/clarinet/clarinet.js\";\nexport { rebuildJsonObject as _rebuildJsonObject } from \"./lib/parsers/parse-json-in-batches.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { makeTableFromData } from '@loaders.gl/schema';\nexport function parseJSONSync(jsonText, options) {\n try {\n const json = JSON.parse(jsonText);\n if (options.json?.table) {\n const data = getFirstArray(json) || json;\n return makeTableFromData(data);\n }\n return json;\n }\n catch (error) {\n throw new Error('JSONLoader: failed to parse JSON');\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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { assert, makeTextDecoderIterator } from '@loaders.gl/loader-utils';\nimport StreamingJSONParser from \"../json-parser/streaming-json-parser.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\n// TODO - support batch size 0 = no batching/single batch?\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseJSONInBatches(binaryAsyncIterator, options) {\n const asyncIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const { metadata } = options;\n const { jsonpaths } = options.json || {};\n let isFirstChunk = true;\n // @ts-expect-error TODO fix Schema deduction\n const schema = null;\n const tableBatchBuilder = new TableBatchBuilder(schema, options);\n const parser = new StreamingJSONParser({ jsonpaths });\n for await (const chunk of asyncIterator) {\n const rows = parser.write(chunk);\n const jsonpath = rows.length > 0 && parser.getStreamingJsonPathAsString();\n if (rows.length > 0 && isFirstChunk) {\n if (metadata) {\n const initialBatch = {\n // Common fields\n shape: options?.json?.shape || 'array-row-table',\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 // 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 tableBatchBuilder.chunkComplete(chunk);\n const batch = tableBatchBuilder.getFullBatch({ jsonpath });\n if (batch) {\n yield batch;\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 if (metadata) {\n const finalBatch = {\n shape: 'json',\n batchType: 'final-result',\n container: parser.getPartialResult(),\n jsonpath: parser.getStreamingJsonPathAsString(),\n /** Data Just to avoid crashing? */\n data: [],\n length: 0\n // schema: null\n };\n yield finalBatch;\n }\n}\nexport function rebuildJsonObject(batch, data) {\n // Last batch will have this special type and will provide all the root object of the parsed file\n assert(batch.batchType === 'final-result');\n // The streamed JSON data is a top level array (jsonpath = '$'), just return the array of row objects\n if (batch.jsonpath === '$') {\n return data;\n }\n // (jsonpath !== '$') The streamed data is not a top level array, so stitch it back in to the top-level object\n if (batch.jsonpath && batch.jsonpath.length > 1) {\n const topLevelObject = batch.container;\n const streamingPath = new JSONPath(batch.jsonpath);\n streamingPath.setFieldAtPath(topLevelObject, data);\n return topLevelObject;\n }\n // No jsonpath, in this case nothing was streamed.\n return batch.container;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT AND BSD\n// Copyright (c) vis.gl contributors\n// This is a fork of the clarinet library, originally BSD license (see LICENSE file)\n// loaders.gl changes:\n// - typescript port\n// Removes the MAX_BUFFER_LENGTH, originally set to 64 * 1024\nconst MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;\n// const DEBUG = false;\nvar STATE;\n(function (STATE) {\n STATE[STATE[\"BEGIN\"] = 0] = \"BEGIN\";\n STATE[STATE[\"VALUE\"] = 1] = \"VALUE\";\n STATE[STATE[\"OPEN_OBJECT\"] = 2] = \"OPEN_OBJECT\";\n STATE[STATE[\"CLOSE_OBJECT\"] = 3] = \"CLOSE_OBJECT\";\n STATE[STATE[\"OPEN_ARRAY\"] = 4] = \"OPEN_ARRAY\";\n STATE[STATE[\"CLOSE_ARRAY\"] = 5] = \"CLOSE_ARRAY\";\n STATE[STATE[\"TEXT_ESCAPE\"] = 6] = \"TEXT_ESCAPE\";\n STATE[STATE[\"STRING\"] = 7] = \"STRING\";\n STATE[STATE[\"BACKSLASH\"] = 8] = \"BACKSLASH\";\n STATE[STATE[\"END\"] = 9] = \"END\";\n STATE[STATE[\"OPEN_KEY\"] = 10] = \"OPEN_KEY\";\n STATE[STATE[\"CLOSE_KEY\"] = 11] = \"CLOSE_KEY\";\n STATE[STATE[\"TRUE\"] = 12] = \"TRUE\";\n STATE[STATE[\"TRUE2\"] = 13] = \"TRUE2\";\n STATE[STATE[\"TRUE3\"] = 14] = \"TRUE3\";\n STATE[STATE[\"FALSE\"] = 15] = \"FALSE\";\n STATE[STATE[\"FALSE2\"] = 16] = \"FALSE2\";\n STATE[STATE[\"FALSE3\"] = 17] = \"FALSE3\";\n STATE[STATE[\"FALSE4\"] = 18] = \"FALSE4\";\n STATE[STATE[\"NULL\"] = 19] = \"NULL\";\n STATE[STATE[\"NULL2\"] = 20] = \"NULL2\";\n STATE[STATE[\"NULL3\"] = 21] = \"NULL3\";\n STATE[STATE[\"NUMBER_DECIMAL_POINT\"] = 22] = \"NUMBER_DECIMAL_POINT\";\n STATE[STATE[\"NUMBER_DIGIT\"] = 23] = \"NUMBER_DIGIT\"; // [0-9]\n})(STATE || (STATE = {}));\nconst Char = {\n tab: 0x09, // \\t\n lineFeed: 0x0a, // \\n\n carriageReturn: 0x0d, // \\r\n space: 0x20, // \" \"\n doubleQuote: 0x22, // \"\n plus: 0x2b, // +\n comma: 0x2c, // ,\n minus: 0x2d, // -\n period: 0x2e, // .\n _0: 0x30, // 0\n _9: 0x39, // 9\n colon: 0x3a, // :\n E: 0x45, // E\n openBracket: 0x5b, // [\n backslash: 0x5c, // \\\n closeBracket: 0x5d, // ]\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 openBrace: 0x7b, // {\n closeBrace: 0x7d // }\n};\nconst stringTokenPattern = /[\\\\\"\\n]/g;\nconst DEFAULT_OPTIONS = {\n onready: () => { },\n onopenobject: () => { },\n onkey: () => { },\n oncloseobject: () => { },\n onopenarray: () => { },\n onclosearray: () => { },\n onvalue: () => { },\n onerror: () => { },\n onend: () => { },\n onchunkparsed: () => { }\n};\nexport default class ClarinetParser {\n options = DEFAULT_OPTIONS;\n bufferCheckPosition = MAX_BUFFER_LENGTH;\n q = '';\n c = '';\n p = '';\n closed = false;\n closedRoot = false;\n sawRoot = false;\n // tag = null;\n error = null;\n state = STATE.BEGIN;\n stack = [];\n // mostly just for error reporting\n position = 0;\n column = 0;\n line = 1;\n slashed = false;\n unicodeI = 0;\n unicodeS = null;\n depth = 0;\n textNode;\n numberNode;\n constructor(options = {}) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n this.textNode = undefined;\n this.numberNode = '';\n this.emit('onready');\n }\n end() {\n if (this.state !== STATE.VALUE || this.depth !== 0)\n this._error('Unexpected end');\n this._closeValue();\n this.c = '';\n this.closed = true;\n this.emit('onend');\n return this;\n }\n resume() {\n this.error = null;\n return this;\n }\n close() {\n return this.write(null);\n }\n // protected\n emit(event, data) {\n // if (DEBUG) console.log('-- emit', event, data);\n this.options[event]?.(data, this);\n }\n emitNode(event, data) {\n this._closeValue();\n this.emit(event, data);\n }\n /* eslint-disable no-continue */\n // eslint-disable-next-line complexity, max-statements\n write(chunk) {\n if (this.error) {\n throw this.error;\n }\n if (this.closed) {\n return this._error('Cannot write after close. Assign an onready handler.');\n }\n if (chunk === null) {\n return this.end();\n }\n let i = 0;\n let c = chunk.charCodeAt(0);\n let 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 }\n else {\n p = this.p;\n }\n if (!c)\n break;\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 }\n else\n this.column++;\n switch (this.state) {\n case STATE.BEGIN:\n if (c === Char.openBrace)\n this.state = STATE.OPEN_OBJECT;\n else if (c === Char.openBracket)\n this.state = STATE.OPEN_ARRAY;\n else if (!isWhitespace(c)) {\n this._error('Non-whitespace before {[.');\n }\n continue;\n case STATE.OPEN_KEY:\n case STATE.OPEN_OBJECT:\n if (isWhitespace(c))\n continue;\n if (this.state === STATE.OPEN_KEY)\n this.stack.push(STATE.CLOSE_KEY);\n else if (c === Char.closeBrace) {\n this.emit('onopenobject');\n this.depth++;\n this.emit('oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n continue;\n }\n else\n this.stack.push(STATE.CLOSE_OBJECT);\n if (c === Char.doubleQuote)\n this.state = STATE.STRING;\n else\n this._error('Malformed object key should start with \"');\n continue;\n case STATE.CLOSE_KEY:\n case STATE.CLOSE_OBJECT:\n if (isWhitespace(c))\n continue;\n // let event = this.state === STATE.CLOSE_KEY ? 'key' : 'object';\n if (c === Char.colon) {\n if (this.state === STATE.CLOSE_OBJECT) {\n this.stack.push(STATE.CLOSE_OBJECT);\n this._closeValue('onopenobject');\n this.depth++;\n }\n else\n this._closeValue('onkey');\n this.state = STATE.VALUE;\n }\n else if (c === Char.closeBrace) {\n this.emitNode('oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else if (c === Char.comma) {\n if (this.state === STATE.CLOSE_OBJECT)\n this.stack.push(STATE.CLOSE_OBJECT);\n this._closeValue();\n this.state = STATE.OPEN_KEY;\n }\n else\n this._error('Bad object');\n continue;\n case STATE.OPEN_ARRAY: // after an array there always a value\n case STATE.VALUE:\n if (isWhitespace(c))\n continue;\n if (this.state === STATE.OPEN_ARRAY) {\n this.emit('onopenarray');\n this.depth++;\n this.state = STATE.VALUE;\n if (c === Char.closeBracket) {\n this.emit('onclosearray');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n continue;\n }\n else {\n this.stack.push(STATE.CLOSE_ARRAY);\n }\n }\n if (c === Char.doubleQuote)\n this.state = STATE.STRING;\n else if (c === Char.openBrace)\n this.state = STATE.OPEN_OBJECT;\n else if (c === Char.openBracket)\n this.state = STATE.OPEN_ARRAY;\n else if (c === Char.t)\n this.state = STATE.TRUE;\n else if (c === Char.f)\n this.state = STATE.FALSE;\n else if (c === Char.n)\n this.state = STATE.NULL;\n else if (c === Char.minus) {\n // keep and continue\n this.numberNode += '-';\n }\n else if (Char._0 <= c && c <= Char._9) {\n this.numberNode += String.fromCharCode(c);\n this.state = STATE.NUMBER_DIGIT;\n }\n else\n this._error('Bad value');\n continue;\n case STATE.CLOSE_ARRAY:\n if (c === Char.comma) {\n this.stack.push(STATE.CLOSE_ARRAY);\n this._closeValue('onvalue');\n this.state = STATE.VALUE;\n }\n else if (c === Char.closeBracket) {\n this.emitNode('onclosearray');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else if (isWhitespace(c))\n continue;\n else\n this._error('Bad array');\n continue;\n case STATE.STRING:\n if (this.textNode === undefined) {\n this.textNode = '';\n }\n // thanks thejh, this is an about 50% performance improvement.\n let starti = i - 1;\n let slashed = this.slashed;\n let unicodeI = this.unicodeI;\n // eslint-disable-next-line no-constant-condition, no-labels\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 }\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 // eslint-disable-next-line no-labels\n if (!c)\n break STRING_BIGLOOP;\n }\n if (c === Char.doubleQuote && !slashed) {\n this.state = this.stack.pop() || STATE.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)\n break;\n }\n if (slashed) {\n slashed = false;\n if (c === Char.n) {\n this.textNode += '\\n';\n }\n else if (c === Char.r) {\n this.textNode += '\\r';\n }\n else if (c === Char.t) {\n this.textNode += '\\t';\n }\n else if (c === Char.f) {\n this.textNode += '\\f';\n }\n else if (c === Char.b) {\n this.textNode += '\\b';\n }\n else if (c === Char.u) {\n // \\uxxxx. meh!\n unicodeI = 1;\n this.unicodeS = '';\n }\n else {\n this.textNode += String.fromCharCode(c);\n }\n c = chunk.charCodeAt(i++);\n this.position++;\n starti = i - 1;\n if (!c)\n break;\n else\n continue;\n }\n stringTokenPattern.lastIndex = i;\n const 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 case STATE.TRUE:\n if (c === Char.r)\n this.state = STATE.TRUE2;\n else\n this._error(`Invalid true started with t${c}`);\n continue;\n case STATE.TRUE2:\n if (c === Char.u)\n this.state = STATE.TRUE3;\n else\n this._error(`Invalid true started with tr${c}`);\n continue;\n case STATE.TRUE3:\n if (c === Char.e) {\n this.emit('onvalue', true);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid true started with tru${c}`);\n continue;\n case STATE.FALSE:\n if (c === Char.a)\n this.state = STATE.FALSE2;\n else\n this._error(`Invalid false started with f${c}`);\n continue;\n case STATE.FALSE2:\n if (c === Char.l)\n this.state = STATE.FALSE3;\n else\n this._error(`Invalid false started with fa${c}`);\n continue;\n case STATE.FALSE3:\n if (c === Char.s)\n this.state = STATE.FALSE4;\n else\n this._error(`Invalid false started with fal${c}`);\n continue;\n case STATE.FALSE4:\n if (c === Char.e) {\n this.emit('onvalue', false);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid false started with fals${c}`);\n continue;\n case STATE.NULL:\n if (c === Char.u)\n this.state = STATE.NULL2;\n else\n this._error(`Invalid null started with n${c}`);\n continue;\n case STATE.NULL2:\n if (c === Char.l)\n this.state = STATE.NULL3;\n else\n this._error(`Invalid null started with nu${c}`);\n continue;\n case STATE.NULL3:\n if (c === Char.l) {\n this.emit('onvalue', null);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid null started with nul${c}`);\n continue;\n case STATE.NUMBER_DECIMAL_POINT:\n if (c === Char.period) {\n this.numberNode += '.';\n this.state = STATE.NUMBER_DIGIT;\n }\n else\n this._error('Leading zero not followed by .');\n continue;\n case STATE.NUMBER_DIGIT:\n if (Char._0 <= c && c <= Char._9)\n this.numberNode += String.fromCharCode(c);\n else if (c === Char.period) {\n if (this.numberNode.indexOf('.') !== -1)\n this._error('Invalid number has two dots');\n this.numberNode += '.';\n }\n else if (c === Char.e || c === Char.E) {\n if (this.numberNode.indexOf('e') !== -1 || this.numberNode.indexOf('E') !== -1)\n this._error('Invalid number has two exponential');\n this.numberNode += 'e';\n }\n else if (c === Char.plus || c === Char.minus) {\n // @ts-expect-error\n if (!(p === Char.e || p === Char.E))\n this._error('Invalid symbol in number');\n this.numberNode += String.fromCharCode(c);\n }\n else {\n this._closeNumber();\n i--; // go back one\n this.state = this.stack.pop() || STATE.VALUE;\n }\n continue;\n default:\n this._error(`Unknown state: ${this.state}`);\n }\n }\n if (this.position >= this.bufferCheckPosition) {\n checkBufferLength(this);\n }\n this.emit('onchunkparsed');\n return this;\n }\n _closeValue(event = 'onvalue') {\n if (this.textNode !== undefined) {\n this.emit(event, this.textNode);\n }\n this.textNode = undefined;\n }\n _closeNumber() {\n if (this.numberNode)\n this.emit('onvalue', parseFloat(this.numberNode));\n this.numberNode = '';\n }\n _error(message = '') {\n this._closeValue();\n message += `\\nLine: ${this.line}\\nColumn: ${this.column}\\nChar: ${this.c}`;\n const error = new Error(message);\n this.error = error;\n this.emit('onerror', error);\n }\n}\nfunction isWhitespace(c) {\n return c === Char.carriageReturn || c === Char.lineFeed || c === Char.space || c === Char.tab;\n}\nfunction checkBufferLength(parser) {\n const maxAllowed = Math.max(MAX_BUFFER_LENGTH, 10);\n let maxActual = 0;\n for (const buffer of ['textNode', 'numberNode']) {\n const len = parser[buffer] === undefined ? 0 : parser[buffer].length;\n if (len > maxAllowed) {\n switch (buffer) {\n case 'text':\n // TODO - should this be closeValue?\n // closeText(parser);\n break;\n default:\n parser._error(`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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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;\n constructor(path = null) {\n this.path = ['$'];\n if (path instanceof JSONPath) {\n // @ts-ignore\n this.path = [...path.path];\n return;\n }\n if (Array.isArray(path)) {\n this.path.push(...path);\n return;\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 clone() {\n return new JSONPath(this);\n }\n toString() {\n return this.path.join('.');\n }\n push(name) {\n this.path.push(name);\n }\n pop() {\n return this.path.pop();\n }\n set(name) {\n this.path[this.path.length - 1] = name;\n }\n equals(other) {\n if (!this || !other || this.path.length !== other.path.length) {\n return false;\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 return true;\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 * 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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck\nimport ClarinetParser from \"../clarinet/clarinet.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\n// JSONParser builds a JSON object using the events emitted by the Clarinet parser\nexport default class JSONParser {\n parser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({ container: [], key: null });\n jsonpath = new JSONPath();\n constructor(options) {\n this.reset();\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 onopenobject: (name) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n onkey: (name) => {\n this.jsonpath.set(name);\n this.currentState.key = name;\n },\n oncloseobject: () => {\n this._closeObject();\n },\n onopenarray: () => {\n this._openArray();\n },\n onclosearray: () => {\n this._closeArray();\n },\n onvalue: (value) => {\n this._pushOrSet(value);\n },\n onerror: (error) => {\n throw error;\n },\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n ...options\n });\n }\n reset() {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({ container: [], key: null });\n this.jsonpath = new JSONPath();\n }\n write(chunk) {\n this.parser.write(chunk);\n }\n close() {\n this.parser.close();\n }\n // PRIVATE METHODS\n _pushOrSet(value) {\n const { container, key } = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n }\n else {\n container.push(value);\n }\n }\n _openArray(newContainer = []) {\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 _closeArray() {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n _openObject(newContainer = {}) {\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 _closeObject() {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { default as JSONParser } from \"./json-parser.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\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 jsonPaths;\n streamingJsonPath = null;\n streamingArray = null;\n topLevelObject = null;\n constructor(options = {}) {\n super({\n 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);\n return;\n }\n }\n this._openArray();\n },\n // Redefine onopenarray to inject value for top-level object\n onopenobject: (name) => {\n if (!this.topLevelObject) {\n this.topLevelObject = {};\n this._openObject(this.topLevelObject);\n }\n else {\n this._openObject({});\n }\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n }\n });\n const jsonpaths = options.jsonpaths || [];\n this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));\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 = [];\n if (this.streamingArray) {\n array = [...this.streamingArray];\n this.streamingArray.length = 0;\n }\n return array;\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 getStreamingJsonPath() {\n return this.streamingJsonPath;\n }\n getStreamingJsonPathAsString() {\n return this.streamingJsonPath && this.streamingJsonPath.toString();\n }\n getJsonPath() {\n return this.jsonpath;\n }\n // PRIVATE METHODS\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 // 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 for (const jsonPath of this.jsonPaths) {\n if (jsonPath.equals(currentPath)) {\n return true;\n }\n }\n return false;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseJSONSync } from \"./lib/parsers/parse-json.js\";\nimport { parseJSONInBatches } from \"./lib/parsers/parse-json-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\nexport const JSONLoader = {\n dataType: null,\n batchType: null,\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'table',\n text: true,\n options: {\n json: {\n shape: undefined,\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n },\n parse,\n parseTextSync,\n parseInBatches\n};\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\nfunction parseTextSync(text, options) {\n const jsonOptions = { ...options, json: { ...JSONLoader.options.json, ...options?.json } };\n return parseJSONSync(text, jsonOptions);\n}\nfunction parseInBatches(asyncIterator, options) {\n const jsonOptions = { ...options, json: { ...JSONLoader.options.json, ...options?.json } };\n return parseJSONInBatches(asyncIterator, jsonOptions);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { makeTableFromData } from '@loaders.gl/schema';\nexport function parseNDJSONSync(ndjsonText) {\n const lines = ndjsonText.trim().split('\\n');\n const parsedLines = lines.map((line, counter) => {\n try {\n return JSON.parse(line);\n }\n catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);\n }\n });\n return makeTableFromData(parsedLines);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { makeLineIterator, makeNumberedLineIterator, makeTextDecoderIterator } from '@loaders.gl/loader-utils';\nexport async function* parseNDJSONInBatches(binaryAsyncIterator, options) {\n const textIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const lineIterator = makeLineIterator(textIterator);\n const numberedLineIterator = makeNumberedLineIterator(lineIterator);\n const schema = null;\n const shape = 'row-table';\n // @ts-ignore\n const tableBatchBuilder = new TableBatchBuilder(schema, {\n ...options,\n shape\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 }\n catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter}`);\n }\n }\n const batch = tableBatchBuilder.getFinalBatch();\n if (batch) {\n yield batch;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseNDJSONSync } from \"./lib/parsers/parse-ndjson.js\";\nimport { parseNDJSONInBatches } from \"./lib/parsers/parse-ndjson-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\nexport const NDJSONLoader = {\n dataType: null,\n batchType: null,\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson', 'jsonl'],\n mimeTypes: [\n 'application/x-ndjson',\n 'application/jsonlines', // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch\n 'application/json-seq'\n ],\n category: 'table',\n text: true,\n parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),\n parseTextSync: parseNDJSONSync,\n parseInBatches: parseNDJSONInBatches,\n options: {}\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { makeRowIterator } from '@loaders.gl/schema';\n/**\n * Encode a table as a JSON string\n */\nexport function encodeTableAsJSON(table, options) {\n const shape = options?.json?.shape || 'object-row-table';\n const strings = [];\n const rowIterator = makeRowIterator(table, shape);\n for (const row of rowIterator) {\n // Round elements etc\n // processRow(wrappedRow, table.schema);\n // const wrappedRow = options.wrapper ? options.wrapper(row) : row;\n strings.push(JSON.stringify(row));\n }\n return `[${strings.join(',')}]`;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { encodeTableAsJSON } from \"./lib/encoders/json-encoder.js\";\nexport const JSONWriter = {\n id: 'json',\n version: 'latest',\n module: 'json',\n name: 'JSON',\n extensions: ['json'],\n mimeTypes: ['application/json'],\n options: {},\n text: true,\n encode: async (table, options) => new TextEncoder().encode(encodeTableAsJSON(table, options)).buffer,\n encodeTextSync: (table, options) => encodeTableAsJSON(table, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { geojsonToBinary } from '@loaders.gl/gis';\n// import {parseJSONSync} from './lib/parsers/parse-json';\nimport { parseJSONInBatches } from \"./lib/parsers/parse-json-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.6\" !== 'undefined' ? \"4.3.0-alpha.6\" : 'latest';\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader = {\n dataType: null,\n batchType: null,\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: {\n geojson: {\n shape: 'geojson-table'\n },\n json: {\n shape: 'object-row-table',\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n }\n};\nexport const GeoJSONLoader = {\n ...GeoJSONWorkerLoader,\n // @ts-expect-error\n parse,\n // @ts-expect-error\n parseTextSync,\n parseInBatches\n};\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = { ...GeoJSONLoader.options, ...options };\n options.geojson = { ...GeoJSONLoader.options.geojson, ...options.geojson };\n options.gis = options.gis || {};\n let geojson;\n try {\n geojson = JSON.parse(text);\n }\n catch {\n geojson = {};\n }\n const table = {\n shape: 'geojson-table',\n // TODO - deduce schema from geojson\n // TODO check that parsed data is of type FeatureCollection\n type: 'FeatureCollection',\n features: geojson?.features || []\n };\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(table.features);\n default:\n return table;\n }\n}\nfunction parseInBatches(asyncIterator, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = { ...GeoJSONLoader.options, ...options };\n options.json = { ...GeoJSONLoader.options.geojson, ...options.geojson };\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright Foursquare, Inc 20222\nimport { concatenateArrayBuffersAsync } from '@loaders.gl/loader-utils';\nimport { encodeTableAsGeojsonInBatches } from \"./lib/encoders/geojson-encoder.js\";\nexport const GeoJSONWriter = {\n id: 'geojson',\n version: 'latest',\n module: 'geojson',\n name: 'GeoJSON',\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n text: true,\n options: {\n geojson: {\n featureArray: false,\n geometryColumn: null\n }\n },\n async encode(table, options) {\n const tableIterator = [table];\n const batches = encodeTableAsGeojsonInBatches(tableIterator, options);\n return await concatenateArrayBuffersAsync(batches);\n },\n encodeInBatches: (tableIterator, options) => encodeTableAsGeojsonInBatches(tableIterator, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableLength } from '@loaders.gl/schema';\nimport { detectGeometryColumnIndex } from \"../encoder-utils/encode-utils.js\";\nimport { encodeTableRow } from \"../encoder-utils/encode-table-row.js\";\nimport { Utf8ArrayBufferEncoder } from \"../encoder-utils/utf8-encoder.js\";\n/**\n * Encode a table as GeoJSON\n */\n// eslint-disable-next-line max-statements\nexport async function* encodeTableAsGeojsonInBatches(batchIterator, // | Iterable<TableBatch>,\ninputOpts = {}) {\n // @ts-expect-error\n const options = { geojson: {}, chunkSize: 10000, ...inputOpts };\n const utf8Encoder = new Utf8ArrayBufferEncoder(options.chunkSize);\n if (!options.geojson.featureArray) {\n utf8Encoder.push('{\\n', '\"type\": \"FeatureCollection\",\\n', '\"features\":\\n');\n }\n utf8Encoder.push('['); // Note no newline\n let geometryColumn = options.geojson.geometryColumn;\n let isFirstLine = true;\n let start = 0;\n for await (const tableBatch of batchIterator) {\n const end = start + getTableLength(tableBatch);\n // Deduce geometry column if not already done\n if (!geometryColumn) {\n geometryColumn = geometryColumn || detectGeometryColumnIndex(tableBatch);\n }\n for (let rowIndex = start; rowIndex < end; ++rowIndex) {\n // Add a comma except on final feature\n if (!isFirstLine) {\n utf8Encoder.push(',');\n }\n utf8Encoder.push('\\n');\n isFirstLine = false;\n encodeTableRow(tableBatch, rowIndex, geometryColumn, utf8Encoder);\n // eslint-disable-next-line max-depth\n if (utf8Encoder.isFull()) {\n yield utf8Encoder.getArrayBufferBatch();\n }\n start = end;\n }\n const arrayBufferBatch = utf8Encoder.getArrayBufferBatch();\n if (arrayBufferBatch.byteLength > 0) {\n yield arrayBufferBatch;\n }\n }\n utf8Encoder.push('\\n');\n // Add completing rows and emit final batch\n utf8Encoder.push(']\\n');\n if (!options.geojson.featureArray) {\n utf8Encoder.push('}');\n }\n // Note: Since we pushed a few final lines, the last batch will always exist, no need to check first\n yield utf8Encoder.getArrayBufferBatch();\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableLength, getTableNumCols, getTableRowAsArray } from '@loaders.gl/schema';\n/**\n * Attempts to identify which column contains geometry\n * Currently just returns name (key) of first object-valued column\n * @todo look for hints in schema metadata\n * @todo look for WKB\n */\nexport function detectGeometryColumnIndex(table) {\n // TODO - look for hints in schema metadata\n // look for a column named geometry\n const geometryIndex = table.schema?.fields.findIndex((field) => field.name === 'geometry') ?? -1;\n if (geometryIndex > -1) {\n return geometryIndex;\n }\n // look at the data\n // TODO - this drags in the indices\n if (getTableLength(table) > 0) {\n const row = getTableRowAsArray(table, 0);\n for (let columnIndex = 0; columnIndex < getTableNumCols(table); columnIndex++) {\n const value = row?.[columnIndex];\n if (value && typeof value === 'object') {\n return columnIndex;\n }\n }\n }\n throw new Error('Failed to detect geometry column');\n}\n/**\n * Return a row as a property (key/value) object, excluding selected columns\n */\nexport function getRowPropertyObject(table, row, excludeColumnIndices = []) {\n const properties = {};\n for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {\n const columnName = table.schema?.fields[columnIndex].name;\n if (columnName && !excludeColumnIndices.includes(columnIndex)) {\n properties[columnName] = row[columnName];\n }\n }\n return properties;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableRowAsObject } from '@loaders.gl/schema';\nimport { getRowPropertyObject } from \"./encode-utils.js\";\n// Helpers\n/**\n * Encode a row. Currently this ignores properties in the geometry column.\n */\nexport function encodeTableRow(table, rowIndex, geometryColumnIndex, utf8Encoder) {\n const row = getTableRowAsObject(table, rowIndex);\n if (!row)\n return;\n const featureWithProperties = getFeatureFromRow(table, row, geometryColumnIndex);\n const featureString = JSON.stringify(featureWithProperties);\n utf8Encoder.push(featureString);\n}\n/**\n * Encode a row as a Feature. Currently this ignores properties objects in the geometry column.\n */\nfunction getFeatureFromRow(table, row, geometryColumnIndex) {\n // Extract non-feature/geometry properties\n const properties = getRowPropertyObject(table, row, [geometryColumnIndex]);\n // Extract geometry feature\n const columnName = table.schema?.fields[geometryColumnIndex].name;\n let featureOrGeometry = columnName && row[columnName];\n // GeoJSON support null geometries\n if (!featureOrGeometry) {\n // @ts-ignore Feature type does not support null geometries\n return { type: 'Feature', geometry: null, properties };\n }\n // Support string geometries?\n // TODO: This assumes GeoJSON strings, which may not be the correct format\n // (could be WKT, encoded WKB...)\n if (typeof featureOrGeometry === 'string') {\n try {\n featureOrGeometry = JSON.parse(featureOrGeometry);\n }\n catch (err) {\n throw new Error('Invalid string geometry');\n }\n }\n if (typeof featureOrGeometry !== 'object' || typeof featureOrGeometry?.type !== 'string') {\n throw new Error('invalid geometry column value');\n }\n if (featureOrGeometry?.type === 'Feature') {\n // @ts-ignore Feature type does not support null geometries\n return { ...featureOrGeometry, properties };\n }\n // @ts-ignore Feature type does not support null geometries\n return { type: 'Feature', geometry: featureOrGeometry, properties };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n/* global TextEncoder */\nexport class Utf8ArrayBufferEncoder {\n chunkSize;\n strings = [];\n totalLength = 0;\n textEncoder = new TextEncoder();\n constructor(chunkSize) {\n this.chunkSize = chunkSize;\n }\n push(...strings) {\n for (const string of strings) {\n this.strings.push(string);\n this.totalLength += string.length;\n }\n }\n isFull() {\n return this.totalLength >= this.chunkSize;\n }\n getArrayBufferBatch() {\n return this.textEncoder.encode(this.getStringBatch()).buffer;\n }\n getStringBatch() {\n const stringChunk = this.strings.join('');\n this.strings = [];\n this.totalLength = 0;\n return stringChunk;\n }\n}\n"],
4
+ "sourcesContent": ["// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nexport { JSONLoader } from \"./json-loader.js\";\nexport { NDJSONLoader } from \"./ndjson-loader.js\";\nexport { JSONWriter } from \"./json-writer.js\";\nexport { GeoJSONLoader as _GeoJSONLoader, GeoJSONWorkerLoader as _GeoJSONWorkerLoader } from \"./geojson-loader.js\";\nexport { GeoJSONWriter as _GeoJSONWriter } from \"./geojson-writer.js\";\nexport { default as _JSONPath } from \"./lib/jsonpath/jsonpath.js\";\nexport { default as _ClarinetParser } from \"./lib/clarinet/clarinet.js\";\nexport { rebuildJsonObject as _rebuildJsonObject } from \"./lib/parsers/parse-json-in-batches.js\";\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { makeTableFromData } from '@loaders.gl/schema';\nexport function parseJSONSync(jsonText, options) {\n try {\n const json = JSON.parse(jsonText);\n if (options.json?.table) {\n const data = getFirstArray(json) || json;\n return makeTableFromData(data);\n }\n return json;\n }\n catch (error) {\n throw new Error('JSONLoader: failed to parse JSON');\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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { assert, makeTextDecoderIterator } from '@loaders.gl/loader-utils';\nimport StreamingJSONParser from \"../json-parser/streaming-json-parser.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\n// TODO - support batch size 0 = no batching/single batch?\n// eslint-disable-next-line max-statements, complexity\nexport async function* parseJSONInBatches(binaryAsyncIterator, options) {\n const asyncIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const { metadata } = options;\n const { jsonpaths } = options.json || {};\n let isFirstChunk = true;\n // @ts-expect-error TODO fix Schema deduction\n const schema = null;\n const tableBatchBuilder = new TableBatchBuilder(schema, options);\n const parser = new StreamingJSONParser({ jsonpaths });\n for await (const chunk of asyncIterator) {\n const rows = parser.write(chunk);\n const jsonpath = rows.length > 0 && parser.getStreamingJsonPathAsString();\n if (rows.length > 0 && isFirstChunk) {\n if (metadata) {\n const initialBatch = {\n // Common fields\n shape: options?.json?.shape || 'array-row-table',\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 // 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 tableBatchBuilder.chunkComplete(chunk);\n const batch = tableBatchBuilder.getFullBatch({ jsonpath });\n if (batch) {\n yield batch;\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 if (metadata) {\n const finalBatch = {\n shape: 'json',\n batchType: 'final-result',\n container: parser.getPartialResult(),\n jsonpath: parser.getStreamingJsonPathAsString(),\n /** Data Just to avoid crashing? */\n data: [],\n length: 0\n // schema: null\n };\n yield finalBatch;\n }\n}\nexport function rebuildJsonObject(batch, data) {\n // Last batch will have this special type and will provide all the root object of the parsed file\n assert(batch.batchType === 'final-result');\n // The streamed JSON data is a top level array (jsonpath = '$'), just return the array of row objects\n if (batch.jsonpath === '$') {\n return data;\n }\n // (jsonpath !== '$') The streamed data is not a top level array, so stitch it back in to the top-level object\n if (batch.jsonpath && batch.jsonpath.length > 1) {\n const topLevelObject = batch.container;\n const streamingPath = new JSONPath(batch.jsonpath);\n streamingPath.setFieldAtPath(topLevelObject, data);\n return topLevelObject;\n }\n // No jsonpath, in this case nothing was streamed.\n return batch.container;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT AND BSD\n// Copyright (c) vis.gl contributors\n// This is a fork of the clarinet library, originally BSD license (see LICENSE file)\n// loaders.gl changes:\n// - typescript port\n// Removes the MAX_BUFFER_LENGTH, originally set to 64 * 1024\nconst MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;\n// const DEBUG = false;\nvar STATE;\n(function (STATE) {\n STATE[STATE[\"BEGIN\"] = 0] = \"BEGIN\";\n STATE[STATE[\"VALUE\"] = 1] = \"VALUE\";\n STATE[STATE[\"OPEN_OBJECT\"] = 2] = \"OPEN_OBJECT\";\n STATE[STATE[\"CLOSE_OBJECT\"] = 3] = \"CLOSE_OBJECT\";\n STATE[STATE[\"OPEN_ARRAY\"] = 4] = \"OPEN_ARRAY\";\n STATE[STATE[\"CLOSE_ARRAY\"] = 5] = \"CLOSE_ARRAY\";\n STATE[STATE[\"TEXT_ESCAPE\"] = 6] = \"TEXT_ESCAPE\";\n STATE[STATE[\"STRING\"] = 7] = \"STRING\";\n STATE[STATE[\"BACKSLASH\"] = 8] = \"BACKSLASH\";\n STATE[STATE[\"END\"] = 9] = \"END\";\n STATE[STATE[\"OPEN_KEY\"] = 10] = \"OPEN_KEY\";\n STATE[STATE[\"CLOSE_KEY\"] = 11] = \"CLOSE_KEY\";\n STATE[STATE[\"TRUE\"] = 12] = \"TRUE\";\n STATE[STATE[\"TRUE2\"] = 13] = \"TRUE2\";\n STATE[STATE[\"TRUE3\"] = 14] = \"TRUE3\";\n STATE[STATE[\"FALSE\"] = 15] = \"FALSE\";\n STATE[STATE[\"FALSE2\"] = 16] = \"FALSE2\";\n STATE[STATE[\"FALSE3\"] = 17] = \"FALSE3\";\n STATE[STATE[\"FALSE4\"] = 18] = \"FALSE4\";\n STATE[STATE[\"NULL\"] = 19] = \"NULL\";\n STATE[STATE[\"NULL2\"] = 20] = \"NULL2\";\n STATE[STATE[\"NULL3\"] = 21] = \"NULL3\";\n STATE[STATE[\"NUMBER_DECIMAL_POINT\"] = 22] = \"NUMBER_DECIMAL_POINT\";\n STATE[STATE[\"NUMBER_DIGIT\"] = 23] = \"NUMBER_DIGIT\"; // [0-9]\n})(STATE || (STATE = {}));\nconst Char = {\n tab: 0x09, // \\t\n lineFeed: 0x0a, // \\n\n carriageReturn: 0x0d, // \\r\n space: 0x20, // \" \"\n doubleQuote: 0x22, // \"\n plus: 0x2b, // +\n comma: 0x2c, // ,\n minus: 0x2d, // -\n period: 0x2e, // .\n _0: 0x30, // 0\n _9: 0x39, // 9\n colon: 0x3a, // :\n E: 0x45, // E\n openBracket: 0x5b, // [\n backslash: 0x5c, // \\\n closeBracket: 0x5d, // ]\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 openBrace: 0x7b, // {\n closeBrace: 0x7d // }\n};\nconst stringTokenPattern = /[\\\\\"\\n]/g;\nconst DEFAULT_OPTIONS = {\n onready: () => { },\n onopenobject: () => { },\n onkey: () => { },\n oncloseobject: () => { },\n onopenarray: () => { },\n onclosearray: () => { },\n onvalue: () => { },\n onerror: () => { },\n onend: () => { },\n onchunkparsed: () => { }\n};\nexport default class ClarinetParser {\n options = DEFAULT_OPTIONS;\n bufferCheckPosition = MAX_BUFFER_LENGTH;\n q = '';\n c = '';\n p = '';\n closed = false;\n closedRoot = false;\n sawRoot = false;\n // tag = null;\n error = null;\n state = STATE.BEGIN;\n stack = [];\n // mostly just for error reporting\n position = 0;\n column = 0;\n line = 1;\n slashed = false;\n unicodeI = 0;\n unicodeS = null;\n depth = 0;\n textNode;\n numberNode;\n constructor(options = {}) {\n this.options = { ...DEFAULT_OPTIONS, ...options };\n this.textNode = undefined;\n this.numberNode = '';\n this.emit('onready');\n }\n end() {\n if (this.state !== STATE.VALUE || this.depth !== 0)\n this._error('Unexpected end');\n this._closeValue();\n this.c = '';\n this.closed = true;\n this.emit('onend');\n return this;\n }\n resume() {\n this.error = null;\n return this;\n }\n close() {\n return this.write(null);\n }\n // protected\n emit(event, data) {\n // if (DEBUG) console.log('-- emit', event, data);\n this.options[event]?.(data, this);\n }\n emitNode(event, data) {\n this._closeValue();\n this.emit(event, data);\n }\n /* eslint-disable no-continue */\n // eslint-disable-next-line complexity, max-statements\n write(chunk) {\n if (this.error) {\n throw this.error;\n }\n if (this.closed) {\n return this._error('Cannot write after close. Assign an onready handler.');\n }\n if (chunk === null) {\n return this.end();\n }\n let i = 0;\n let c = chunk.charCodeAt(0);\n let 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 }\n else {\n p = this.p;\n }\n if (!c)\n break;\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 }\n else\n this.column++;\n switch (this.state) {\n case STATE.BEGIN:\n if (c === Char.openBrace)\n this.state = STATE.OPEN_OBJECT;\n else if (c === Char.openBracket)\n this.state = STATE.OPEN_ARRAY;\n else if (!isWhitespace(c)) {\n this._error('Non-whitespace before {[.');\n }\n continue;\n case STATE.OPEN_KEY:\n case STATE.OPEN_OBJECT:\n if (isWhitespace(c))\n continue;\n if (this.state === STATE.OPEN_KEY)\n this.stack.push(STATE.CLOSE_KEY);\n else if (c === Char.closeBrace) {\n this.emit('onopenobject');\n this.depth++;\n this.emit('oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n continue;\n }\n else\n this.stack.push(STATE.CLOSE_OBJECT);\n if (c === Char.doubleQuote)\n this.state = STATE.STRING;\n else\n this._error('Malformed object key should start with \"');\n continue;\n case STATE.CLOSE_KEY:\n case STATE.CLOSE_OBJECT:\n if (isWhitespace(c))\n continue;\n // let event = this.state === STATE.CLOSE_KEY ? 'key' : 'object';\n if (c === Char.colon) {\n if (this.state === STATE.CLOSE_OBJECT) {\n this.stack.push(STATE.CLOSE_OBJECT);\n this._closeValue('onopenobject');\n this.depth++;\n }\n else\n this._closeValue('onkey');\n this.state = STATE.VALUE;\n }\n else if (c === Char.closeBrace) {\n this.emitNode('oncloseobject');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else if (c === Char.comma) {\n if (this.state === STATE.CLOSE_OBJECT)\n this.stack.push(STATE.CLOSE_OBJECT);\n this._closeValue();\n this.state = STATE.OPEN_KEY;\n }\n else\n this._error('Bad object');\n continue;\n case STATE.OPEN_ARRAY: // after an array there always a value\n case STATE.VALUE:\n if (isWhitespace(c))\n continue;\n if (this.state === STATE.OPEN_ARRAY) {\n this.emit('onopenarray');\n this.depth++;\n this.state = STATE.VALUE;\n if (c === Char.closeBracket) {\n this.emit('onclosearray');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n continue;\n }\n else {\n this.stack.push(STATE.CLOSE_ARRAY);\n }\n }\n if (c === Char.doubleQuote)\n this.state = STATE.STRING;\n else if (c === Char.openBrace)\n this.state = STATE.OPEN_OBJECT;\n else if (c === Char.openBracket)\n this.state = STATE.OPEN_ARRAY;\n else if (c === Char.t)\n this.state = STATE.TRUE;\n else if (c === Char.f)\n this.state = STATE.FALSE;\n else if (c === Char.n)\n this.state = STATE.NULL;\n else if (c === Char.minus) {\n // keep and continue\n this.numberNode += '-';\n }\n else if (Char._0 <= c && c <= Char._9) {\n this.numberNode += String.fromCharCode(c);\n this.state = STATE.NUMBER_DIGIT;\n }\n else\n this._error('Bad value');\n continue;\n case STATE.CLOSE_ARRAY:\n if (c === Char.comma) {\n this.stack.push(STATE.CLOSE_ARRAY);\n this._closeValue('onvalue');\n this.state = STATE.VALUE;\n }\n else if (c === Char.closeBracket) {\n this.emitNode('onclosearray');\n this.depth--;\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else if (isWhitespace(c))\n continue;\n else\n this._error('Bad array');\n continue;\n case STATE.STRING:\n if (this.textNode === undefined) {\n this.textNode = '';\n }\n // thanks thejh, this is an about 50% performance improvement.\n let starti = i - 1;\n let slashed = this.slashed;\n let unicodeI = this.unicodeI;\n // eslint-disable-next-line no-constant-condition, no-labels\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 }\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 // eslint-disable-next-line no-labels\n if (!c)\n break STRING_BIGLOOP;\n }\n if (c === Char.doubleQuote && !slashed) {\n this.state = this.stack.pop() || STATE.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)\n break;\n }\n if (slashed) {\n slashed = false;\n if (c === Char.n) {\n this.textNode += '\\n';\n }\n else if (c === Char.r) {\n this.textNode += '\\r';\n }\n else if (c === Char.t) {\n this.textNode += '\\t';\n }\n else if (c === Char.f) {\n this.textNode += '\\f';\n }\n else if (c === Char.b) {\n this.textNode += '\\b';\n }\n else if (c === Char.u) {\n // \\uxxxx. meh!\n unicodeI = 1;\n this.unicodeS = '';\n }\n else {\n this.textNode += String.fromCharCode(c);\n }\n c = chunk.charCodeAt(i++);\n this.position++;\n starti = i - 1;\n if (!c)\n break;\n else\n continue;\n }\n stringTokenPattern.lastIndex = i;\n const 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 case STATE.TRUE:\n if (c === Char.r)\n this.state = STATE.TRUE2;\n else\n this._error(`Invalid true started with t${c}`);\n continue;\n case STATE.TRUE2:\n if (c === Char.u)\n this.state = STATE.TRUE3;\n else\n this._error(`Invalid true started with tr${c}`);\n continue;\n case STATE.TRUE3:\n if (c === Char.e) {\n this.emit('onvalue', true);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid true started with tru${c}`);\n continue;\n case STATE.FALSE:\n if (c === Char.a)\n this.state = STATE.FALSE2;\n else\n this._error(`Invalid false started with f${c}`);\n continue;\n case STATE.FALSE2:\n if (c === Char.l)\n this.state = STATE.FALSE3;\n else\n this._error(`Invalid false started with fa${c}`);\n continue;\n case STATE.FALSE3:\n if (c === Char.s)\n this.state = STATE.FALSE4;\n else\n this._error(`Invalid false started with fal${c}`);\n continue;\n case STATE.FALSE4:\n if (c === Char.e) {\n this.emit('onvalue', false);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid false started with fals${c}`);\n continue;\n case STATE.NULL:\n if (c === Char.u)\n this.state = STATE.NULL2;\n else\n this._error(`Invalid null started with n${c}`);\n continue;\n case STATE.NULL2:\n if (c === Char.l)\n this.state = STATE.NULL3;\n else\n this._error(`Invalid null started with nu${c}`);\n continue;\n case STATE.NULL3:\n if (c === Char.l) {\n this.emit('onvalue', null);\n this.state = this.stack.pop() || STATE.VALUE;\n }\n else\n this._error(`Invalid null started with nul${c}`);\n continue;\n case STATE.NUMBER_DECIMAL_POINT:\n if (c === Char.period) {\n this.numberNode += '.';\n this.state = STATE.NUMBER_DIGIT;\n }\n else\n this._error('Leading zero not followed by .');\n continue;\n case STATE.NUMBER_DIGIT:\n if (Char._0 <= c && c <= Char._9)\n this.numberNode += String.fromCharCode(c);\n else if (c === Char.period) {\n if (this.numberNode.indexOf('.') !== -1)\n this._error('Invalid number has two dots');\n this.numberNode += '.';\n }\n else if (c === Char.e || c === Char.E) {\n if (this.numberNode.indexOf('e') !== -1 || this.numberNode.indexOf('E') !== -1)\n this._error('Invalid number has two exponential');\n this.numberNode += 'e';\n }\n else if (c === Char.plus || c === Char.minus) {\n // @ts-expect-error\n if (!(p === Char.e || p === Char.E))\n this._error('Invalid symbol in number');\n this.numberNode += String.fromCharCode(c);\n }\n else {\n this._closeNumber();\n i--; // go back one\n this.state = this.stack.pop() || STATE.VALUE;\n }\n continue;\n default:\n this._error(`Unknown state: ${this.state}`);\n }\n }\n if (this.position >= this.bufferCheckPosition) {\n checkBufferLength(this);\n }\n this.emit('onchunkparsed');\n return this;\n }\n _closeValue(event = 'onvalue') {\n if (this.textNode !== undefined) {\n this.emit(event, this.textNode);\n }\n this.textNode = undefined;\n }\n _closeNumber() {\n if (this.numberNode)\n this.emit('onvalue', parseFloat(this.numberNode));\n this.numberNode = '';\n }\n _error(message = '') {\n this._closeValue();\n message += `\\nLine: ${this.line}\\nColumn: ${this.column}\\nChar: ${this.c}`;\n const error = new Error(message);\n this.error = error;\n this.emit('onerror', error);\n }\n}\nfunction isWhitespace(c) {\n return c === Char.carriageReturn || c === Char.lineFeed || c === Char.space || c === Char.tab;\n}\nfunction checkBufferLength(parser) {\n const maxAllowed = Math.max(MAX_BUFFER_LENGTH, 10);\n let maxActual = 0;\n for (const buffer of ['textNode', 'numberNode']) {\n const len = parser[buffer] === undefined ? 0 : parser[buffer].length;\n if (len > maxAllowed) {\n switch (buffer) {\n case 'text':\n // TODO - should this be closeValue?\n // closeText(parser);\n break;\n default:\n parser._error(`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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\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;\n constructor(path = null) {\n this.path = ['$'];\n if (path instanceof JSONPath) {\n // @ts-ignore\n this.path = [...path.path];\n return;\n }\n if (Array.isArray(path)) {\n this.path.push(...path);\n return;\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 clone() {\n return new JSONPath(this);\n }\n toString() {\n return this.path.join('.');\n }\n push(name) {\n this.path.push(name);\n }\n pop() {\n return this.path.pop();\n }\n set(name) {\n this.path[this.path.length - 1] = name;\n }\n equals(other) {\n if (!this || !other || this.path.length !== other.path.length) {\n return false;\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 return true;\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 * 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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// @ts-nocheck\nimport ClarinetParser from \"../clarinet/clarinet.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\n// JSONParser builds a JSON object using the events emitted by the Clarinet parser\nexport default class JSONParser {\n parser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({ container: [], key: null });\n jsonpath = new JSONPath();\n constructor(options) {\n this.reset();\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 onopenobject: (name) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n onkey: (name) => {\n this.jsonpath.set(name);\n this.currentState.key = name;\n },\n oncloseobject: () => {\n this._closeObject();\n },\n onopenarray: () => {\n this._openArray();\n },\n onclosearray: () => {\n this._closeArray();\n },\n onvalue: (value) => {\n this._pushOrSet(value);\n },\n onerror: (error) => {\n throw error;\n },\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n ...options\n });\n }\n reset() {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({ container: [], key: null });\n this.jsonpath = new JSONPath();\n }\n write(chunk) {\n this.parser.write(chunk);\n }\n close() {\n this.parser.close();\n }\n // PRIVATE METHODS\n _pushOrSet(value) {\n const { container, key } = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n }\n else {\n container.push(value);\n }\n }\n _openArray(newContainer = []) {\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 _closeArray() {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n _openObject(newContainer = {}) {\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 _closeObject() {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { default as JSONParser } from \"./json-parser.js\";\nimport JSONPath from \"../jsonpath/jsonpath.js\";\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 jsonPaths;\n streamingJsonPath = null;\n streamingArray = null;\n topLevelObject = null;\n constructor(options = {}) {\n super({\n 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);\n return;\n }\n }\n this._openArray();\n },\n // Redefine onopenarray to inject value for top-level object\n onopenobject: (name) => {\n if (!this.topLevelObject) {\n this.topLevelObject = {};\n this._openObject(this.topLevelObject);\n }\n else {\n this._openObject({});\n }\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n }\n });\n const jsonpaths = options.jsonpaths || [];\n this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));\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 = [];\n if (this.streamingArray) {\n array = [...this.streamingArray];\n this.streamingArray.length = 0;\n }\n return array;\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 getStreamingJsonPath() {\n return this.streamingJsonPath;\n }\n getStreamingJsonPathAsString() {\n return this.streamingJsonPath && this.streamingJsonPath.toString();\n }\n getJsonPath() {\n return this.jsonpath;\n }\n // PRIVATE METHODS\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 // 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 for (const jsonPath of this.jsonPaths) {\n if (jsonPath.equals(currentPath)) {\n return true;\n }\n }\n return false;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseJSONSync } from \"./lib/parsers/parse-json.js\";\nimport { parseJSONInBatches } from \"./lib/parsers/parse-json-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.8\" !== 'undefined' ? \"4.3.0-alpha.8\" : 'latest';\nexport const JSONLoader = {\n dataType: null,\n batchType: null,\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n category: 'table',\n text: true,\n options: {\n json: {\n shape: undefined,\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n },\n parse,\n parseTextSync,\n parseInBatches\n};\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\nfunction parseTextSync(text, options) {\n const jsonOptions = { ...options, json: { ...JSONLoader.options.json, ...options?.json } };\n return parseJSONSync(text, jsonOptions);\n}\nfunction parseInBatches(asyncIterator, options) {\n const jsonOptions = { ...options, json: { ...JSONLoader.options.json, ...options?.json } };\n return parseJSONInBatches(asyncIterator, jsonOptions);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { makeTableFromData } from '@loaders.gl/schema';\nexport function parseNDJSONSync(ndjsonText) {\n const lines = ndjsonText.trim().split('\\n');\n const parsedLines = lines.map((line, counter) => {\n try {\n return JSON.parse(line);\n }\n catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);\n }\n });\n return makeTableFromData(parsedLines);\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { TableBatchBuilder } from '@loaders.gl/schema';\nimport { makeLineIterator, makeNumberedLineIterator, makeTextDecoderIterator } from '@loaders.gl/loader-utils';\nexport async function* parseNDJSONInBatches(binaryAsyncIterator, options) {\n const textIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const lineIterator = makeLineIterator(textIterator);\n const numberedLineIterator = makeNumberedLineIterator(lineIterator);\n const schema = null;\n const shape = 'row-table';\n // @ts-ignore\n const tableBatchBuilder = new TableBatchBuilder(schema, {\n ...options,\n shape\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 }\n catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter}`);\n }\n }\n const batch = tableBatchBuilder.getFinalBatch();\n if (batch) {\n yield batch;\n }\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { parseNDJSONSync } from \"./lib/parsers/parse-ndjson.js\";\nimport { parseNDJSONInBatches } from \"./lib/parsers/parse-ndjson-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.8\" !== 'undefined' ? \"4.3.0-alpha.8\" : 'latest';\nexport const NDJSONLoader = {\n dataType: null,\n batchType: null,\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson', 'jsonl'],\n mimeTypes: [\n 'application/x-ndjson',\n 'application/jsonlines', // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch\n 'application/json-seq'\n ],\n category: 'table',\n text: true,\n parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),\n parseTextSync: parseNDJSONSync,\n parseInBatches: parseNDJSONInBatches,\n options: {}\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { makeRowIterator } from '@loaders.gl/schema';\n/**\n * Encode a table as a JSON string\n */\nexport function encodeTableAsJSON(table, options) {\n const shape = options?.json?.shape || 'object-row-table';\n const strings = [];\n const rowIterator = makeRowIterator(table, shape);\n for (const row of rowIterator) {\n // Round elements etc\n // processRow(wrappedRow, table.schema);\n // const wrappedRow = options.wrapper ? options.wrapper(row) : row;\n strings.push(JSON.stringify(row));\n }\n return `[${strings.join(',')}]`;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { encodeTableAsJSON } from \"./lib/encoders/json-encoder.js\";\nexport const JSONWriter = {\n id: 'json',\n version: 'latest',\n module: 'json',\n name: 'JSON',\n extensions: ['json'],\n mimeTypes: ['application/json'],\n options: {},\n text: true,\n encode: async (table, options) => new TextEncoder().encode(encodeTableAsJSON(table, options)).buffer,\n encodeTextSync: (table, options) => encodeTableAsJSON(table, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\nimport { geojsonToBinary } from '@loaders.gl/gis';\n// import {parseJSONSync} from './lib/parsers/parse-json';\nimport { parseJSONInBatches } from \"./lib/parsers/parse-json-in-batches.js\";\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof \"4.3.0-alpha.8\" !== 'undefined' ? \"4.3.0-alpha.8\" : 'latest';\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader = {\n dataType: null,\n batchType: null,\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: {\n geojson: {\n shape: 'geojson-table'\n },\n json: {\n shape: 'object-row-table',\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n }\n};\nexport const GeoJSONLoader = {\n ...GeoJSONWorkerLoader,\n // @ts-expect-error\n parse,\n // @ts-expect-error\n parseTextSync,\n parseInBatches\n};\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = { ...GeoJSONLoader.options, ...options };\n options.geojson = { ...GeoJSONLoader.options.geojson, ...options.geojson };\n options.gis = options.gis || {};\n let geojson;\n try {\n geojson = JSON.parse(text);\n }\n catch {\n geojson = {};\n }\n const table = {\n shape: 'geojson-table',\n // TODO - deduce schema from geojson\n // TODO check that parsed data is of type FeatureCollection\n type: 'FeatureCollection',\n features: geojson?.features || []\n };\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(table.features);\n default:\n return table;\n }\n}\nfunction parseInBatches(asyncIterator, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = { ...GeoJSONLoader.options, ...options };\n options.json = { ...GeoJSONLoader.options.geojson, ...options.geojson };\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\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", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright Foursquare, Inc 20222\nimport { concatenateArrayBuffersAsync } from '@loaders.gl/loader-utils';\nimport { encodeTableAsGeojsonInBatches } from \"./lib/encoders/geojson-encoder.js\";\nexport const GeoJSONWriter = {\n id: 'geojson',\n version: 'latest',\n module: 'geojson',\n name: 'GeoJSON',\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n text: true,\n options: {\n geojson: {\n featureArray: false,\n geometryColumn: null\n }\n },\n async encode(table, options) {\n const tableIterator = [table];\n const batches = encodeTableAsGeojsonInBatches(tableIterator, options);\n return await concatenateArrayBuffersAsync(batches);\n },\n encodeInBatches: (tableIterator, options) => encodeTableAsGeojsonInBatches(tableIterator, options)\n};\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableLength } from '@loaders.gl/schema';\nimport { detectGeometryColumnIndex } from \"../encoder-utils/encode-utils.js\";\nimport { encodeTableRow } from \"../encoder-utils/encode-table-row.js\";\nimport { Utf8ArrayBufferEncoder } from \"../encoder-utils/utf8-encoder.js\";\n/**\n * Encode a table as GeoJSON\n */\n// eslint-disable-next-line max-statements\nexport async function* encodeTableAsGeojsonInBatches(batchIterator, // | Iterable<TableBatch>,\ninputOpts = {}) {\n // @ts-expect-error\n const options = { geojson: {}, chunkSize: 10000, ...inputOpts };\n const utf8Encoder = new Utf8ArrayBufferEncoder(options.chunkSize);\n if (!options.geojson.featureArray) {\n utf8Encoder.push('{\\n', '\"type\": \"FeatureCollection\",\\n', '\"features\":\\n');\n }\n utf8Encoder.push('['); // Note no newline\n let geometryColumn = options.geojson.geometryColumn;\n let isFirstLine = true;\n let start = 0;\n for await (const tableBatch of batchIterator) {\n const end = start + getTableLength(tableBatch);\n // Deduce geometry column if not already done\n if (!geometryColumn) {\n geometryColumn = geometryColumn || detectGeometryColumnIndex(tableBatch);\n }\n for (let rowIndex = start; rowIndex < end; ++rowIndex) {\n // Add a comma except on final feature\n if (!isFirstLine) {\n utf8Encoder.push(',');\n }\n utf8Encoder.push('\\n');\n isFirstLine = false;\n encodeTableRow(tableBatch, rowIndex, geometryColumn, utf8Encoder);\n // eslint-disable-next-line max-depth\n if (utf8Encoder.isFull()) {\n yield utf8Encoder.getArrayBufferBatch();\n }\n start = end;\n }\n const arrayBufferBatch = utf8Encoder.getArrayBufferBatch();\n if (arrayBufferBatch.byteLength > 0) {\n yield arrayBufferBatch;\n }\n }\n utf8Encoder.push('\\n');\n // Add completing rows and emit final batch\n utf8Encoder.push(']\\n');\n if (!options.geojson.featureArray) {\n utf8Encoder.push('}');\n }\n // Note: Since we pushed a few final lines, the last batch will always exist, no need to check first\n yield utf8Encoder.getArrayBufferBatch();\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableLength, getTableNumCols, getTableRowAsArray } from '@loaders.gl/schema';\n/**\n * Attempts to identify which column contains geometry\n * Currently just returns name (key) of first object-valued column\n * @todo look for hints in schema metadata\n * @todo look for WKB\n */\nexport function detectGeometryColumnIndex(table) {\n // TODO - look for hints in schema metadata\n // look for a column named geometry\n const geometryIndex = table.schema?.fields.findIndex((field) => field.name === 'geometry') ?? -1;\n if (geometryIndex > -1) {\n return geometryIndex;\n }\n // look at the data\n // TODO - this drags in the indices\n if (getTableLength(table) > 0) {\n const row = getTableRowAsArray(table, 0);\n for (let columnIndex = 0; columnIndex < getTableNumCols(table); columnIndex++) {\n const value = row?.[columnIndex];\n if (value && typeof value === 'object') {\n return columnIndex;\n }\n }\n }\n throw new Error('Failed to detect geometry column');\n}\n/**\n * Return a row as a property (key/value) object, excluding selected columns\n */\nexport function getRowPropertyObject(table, row, excludeColumnIndices = []) {\n const properties = {};\n for (let columnIndex = 0; columnIndex < getTableNumCols(table); ++columnIndex) {\n const columnName = table.schema?.fields[columnIndex].name;\n if (columnName && !excludeColumnIndices.includes(columnIndex)) {\n properties[columnName] = row[columnName];\n }\n }\n return properties;\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\nimport { getTableRowAsObject } from '@loaders.gl/schema';\nimport { getRowPropertyObject } from \"./encode-utils.js\";\n// Helpers\n/**\n * Encode a row. Currently this ignores properties in the geometry column.\n */\nexport function encodeTableRow(table, rowIndex, geometryColumnIndex, utf8Encoder) {\n const row = getTableRowAsObject(table, rowIndex);\n if (!row)\n return;\n const featureWithProperties = getFeatureFromRow(table, row, geometryColumnIndex);\n const featureString = JSON.stringify(featureWithProperties);\n utf8Encoder.push(featureString);\n}\n/**\n * Encode a row as a Feature. Currently this ignores properties objects in the geometry column.\n */\nfunction getFeatureFromRow(table, row, geometryColumnIndex) {\n // Extract non-feature/geometry properties\n const properties = getRowPropertyObject(table, row, [geometryColumnIndex]);\n // Extract geometry feature\n const columnName = table.schema?.fields[geometryColumnIndex].name;\n let featureOrGeometry = columnName && row[columnName];\n // GeoJSON support null geometries\n if (!featureOrGeometry) {\n // @ts-ignore Feature type does not support null geometries\n return { type: 'Feature', geometry: null, properties };\n }\n // Support string geometries?\n // TODO: This assumes GeoJSON strings, which may not be the correct format\n // (could be WKT, encoded WKB...)\n if (typeof featureOrGeometry === 'string') {\n try {\n featureOrGeometry = JSON.parse(featureOrGeometry);\n }\n catch (err) {\n throw new Error('Invalid string geometry');\n }\n }\n if (typeof featureOrGeometry !== 'object' || typeof featureOrGeometry?.type !== 'string') {\n throw new Error('invalid geometry column value');\n }\n if (featureOrGeometry?.type === 'Feature') {\n // @ts-ignore Feature type does not support null geometries\n return { ...featureOrGeometry, properties };\n }\n // @ts-ignore Feature type does not support null geometries\n return { type: 'Feature', geometry: featureOrGeometry, properties };\n}\n", "// loaders.gl\n// SPDX-License-Identifier: MIT\n/* global TextEncoder */\nexport class Utf8ArrayBufferEncoder {\n chunkSize;\n strings = [];\n totalLength = 0;\n textEncoder = new TextEncoder();\n constructor(chunkSize) {\n this.chunkSize = chunkSize;\n }\n push(...strings) {\n for (const string of strings) {\n this.strings.push(string);\n this.totalLength += string.length;\n }\n }\n isFull() {\n return this.totalLength >= this.chunkSize;\n }\n getArrayBufferBatch() {\n return this.textEncoder.encode(this.getStringBatch()).buffer;\n }\n getStringBatch() {\n const stringChunk = this.strings.join('');\n this.strings = [];\n this.totalLength = 0;\n return stringChunk;\n }\n}\n"],
5
5
  "mappings": ";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACGA,oBAAkC;AAC3B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IAAI;AACrB,oBAAc;AACd,qBAAe,YAAY,UAAU,gBAAgB,WAAW;AAEhE,UAAI,YAAY,OAAO,GAAG;AACtB,cAAM,YAAY,oBAAoB;AAAA,MAC1C;AACA,cAAQ;AAAA,IACZ;AACA,UAAM,mBAAmB,YAAY,oBAAoB;AACzD,QAAI,iBAAiB,aAAa,GAAG;AACjC,YAAM;AAAA,IACV;AAAA,EACJ;AACA,cAAY,KAAK,IAAI;AAErB,cAAY,KAAK,KAAK;AACtB,MAAI,CAAC,QAAQ,QAAQ,cAAc;AAC/B,gBAAY,KAAK,GAAG;AAAA,EACxB;AAEA,QAAM,YAAY,oBAAoB;AAC1C;;;ADnDO,IAAM,gBAAgB;AAAA,EACzB,IAAI;AAAA,EACJ,SAAS;AAAA,EACT,QAAQ;AAAA,EACR,MAAM;AAAA,EACN,YAAY,CAAC,SAAS;AAAA,EACtB,WAAW,CAAC,sBAAsB;AAAA,EAClC,MAAM;AAAA,EACN,SAAS;AAAA,IACL,SAAS;AAAA,MACL,cAAc;AAAA,MACd,gBAAgB;AAAA,IACpB;AAAA,EACJ;AAAA,EACA,MAAM,OAAO,OAAO,SAAS;AACzB,UAAM,gBAAgB,CAAC,KAAK;AAC5B,UAAM,UAAU,8BAA8B,eAAe,OAAO;AACpE,WAAO,UAAM,mDAA6B,OAAO;AAAA,EACrD;AAAA,EACA,iBAAiB,CAAC,eAAe,YAAY,8BAA8B,eAAe,OAAO;AACrG;",
6
6
  "names": ["import_schema", "STATE", "jsonpath", "batch", "import_schema", "import_schema", "import_loader_utils", "batch", "VERSION", "import_schema", "VERSION", "parse", "parseTextSync", "parseInBatches", "import_loader_utils", "import_schema", "import_schema", "import_schema"]
7
7
  }
@@ -5,7 +5,7 @@ import { parseJSONSync } from "./lib/parsers/parse-json.js";
5
5
  import { parseJSONInBatches } from "./lib/parsers/parse-json-in-batches.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
8
+ const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest';
9
9
  export const JSONLoader = {
10
10
  dataType: null,
11
11
  batchType: null,
@@ -1 +1 @@
1
- {"version":3,"file":"encode-table-row.d.ts","sourceRoot":"","sources":["../../../src/lib/encoder-utils/encode-table-row.ts"],"names":[],"mappings":"AAMA,OAAO,EAAC,KAAK,EAAsB,MAAM,oBAAoB,CAAC;AAE9D,OAAO,EAAC,sBAAsB,EAAC,0BAAuB;AAMtD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,sBAAsB,GAClC,IAAI,CAMN"}
1
+ {"version":3,"file":"encode-table-row.d.ts","sourceRoot":"","sources":["../../../src/lib/encoder-utils/encode-table-row.ts"],"names":[],"mappings":"AAKA,OAAO,EAAU,KAAK,EAAsB,MAAM,oBAAoB,CAAC;AAEvE,OAAO,EAAC,sBAAsB,EAAC,0BAAuB;AAMtD;;GAEG;AACH,wBAAgB,cAAc,CAC5B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,MAAM,EAChB,mBAAmB,EAAE,MAAM,EAC3B,WAAW,EAAE,sBAAsB,GAClC,IAAI,CAMN"}
@@ -1 +1 @@
1
- {"version":3,"file":"ndgeoson-loader.d.ts","sourceRoot":"","sources":["../src/ndgeoson-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAC,eAAe,EAAC,sCAAmC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,iDAA8C;AAC3E,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAMxE,kCAAkC;AAClC,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,kBAAkB,CAAC;KAC5B,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,sBAAsB;AACtB,eAAO,MAAM,YAAY;;;;;;;;;;;kCAkBI,WAAW;;;;;;;;;;;CAevC,CAAC"}
1
+ {"version":3,"file":"ndgeoson-loader.d.ts","sourceRoot":"","sources":["../src/ndgeoson-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAmB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC9E,OAAO,EAAC,eAAe,EAAC,sCAAmC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,iDAA8C;AAC3E,OAAO,EAAC,aAAa,EAAE,cAAc,EAAE,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAMxE,kCAAkC;AAClC,MAAM,MAAM,sBAAsB,GAAG,aAAa,GAAG;IACnD,OAAO,CAAC,EAAE;QACR,KAAK,CAAC,EAAE,kBAAkB,CAAC;KAC5B,CAAC;IACF,GAAG,CAAC,EAAE;QACJ,MAAM,EAAE,SAAS,CAAC;KACnB,CAAC;CACH,CAAC;AAEF,sBAAsB;AACtB,eAAO,MAAM,YAAY;uBACM,aAAa,GAAG,cAAc;wBAC7B,KAAK;;;;;;;;;kCAgBR,WAAW;;;;;;;;;;;CAevC,CAAC"}
@@ -5,7 +5,7 @@ import { parseNDJSONSync } from "./lib/parsers/parse-ndjson.js";
5
5
  import { parseNDJSONInBatches } from "./lib/parsers/parse-ndjson-in-batches.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
8
+ const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest';
9
9
  /** NDGeoJSONLoader */
10
10
  export const NDJSONLoader = {
11
11
  dataType: null,
@@ -1 +1 @@
1
- {"version":3,"file":"ndjson-loader.d.ts","sourceRoot":"","sources":["../src/ndjson-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAC,eAAe,EAAC,sCAAmC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,iDAA8C;AAM3E,eAAO,MAAM,YAAY;;;;;;;;;;;kCAgBI,WAAW;;;;CAIwD,CAAC"}
1
+ {"version":3,"file":"ndjson-loader.d.ts","sourceRoot":"","sources":["../src/ndjson-loader.ts"],"names":[],"mappings":"AAKA,OAAO,EAAC,cAAc,EAAE,aAAa,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAC7E,OAAO,EAAC,eAAe,EAAC,sCAAmC;AAC3D,OAAO,EAAC,oBAAoB,EAAC,iDAA8C;AAM3E,eAAO,MAAM,YAAY;uBACM,aAAa,GAAG,cAAc;wBAC7B,UAAU;;;;;;;;;kCAcb,WAAW;;;;CAIwD,CAAC"}
@@ -5,7 +5,7 @@ import { parseNDJSONSync } from "./lib/parsers/parse-ndjson.js";
5
5
  import { parseNDJSONInBatches } from "./lib/parsers/parse-ndjson-in-batches.js";
6
6
  // __VERSION__ is injected by babel-plugin-version-inline
7
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
8
- const VERSION = typeof "4.3.0-alpha.6" !== 'undefined' ? "4.3.0-alpha.6" : 'latest';
8
+ const VERSION = typeof "4.3.0-alpha.8" !== 'undefined' ? "4.3.0-alpha.8" : 'latest';
9
9
  export const NDJSONLoader = {
10
10
  dataType: null,
11
11
  batchType: null,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/json",
3
- "version": "4.3.0-alpha.7",
3
+ "version": "4.3.0-beta.1",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -44,12 +44,12 @@
44
44
  "build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
45
45
  },
46
46
  "dependencies": {
47
- "@loaders.gl/gis": "4.3.0-alpha.7",
48
- "@loaders.gl/loader-utils": "4.3.0-alpha.7",
49
- "@loaders.gl/schema": "4.3.0-alpha.7"
47
+ "@loaders.gl/gis": "4.3.0-beta.1",
48
+ "@loaders.gl/loader-utils": "4.3.0-beta.1",
49
+ "@loaders.gl/schema": "4.3.0-beta.1"
50
50
  },
51
51
  "peerDependencies": {
52
52
  "@loaders.gl/core": "^4.0.0"
53
53
  },
54
- "gitHead": "73fb27872d89f3804dca37ebd568c6ba9609a98f"
54
+ "gitHead": "992d24e7d4e3015a91fa1cbfe87ee7dc1b333322"
55
55
  }
@@ -3,8 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
  // Copyright 2022 Foursquare Labs, Inc.
5
5
 
6
- import {Feature} from '@loaders.gl/schema';
7
- import {Table, getTableRowAsObject} from '@loaders.gl/schema';
6
+ import {Feature, Table, getTableRowAsObject} from '@loaders.gl/schema';
8
7
  import {getRowPropertyObject} from './encode-utils';
9
8
  import {Utf8ArrayBufferEncoder} from './utf8-encoder';
10
9