@loaders.gl/json 4.0.0-beta.2 → 4.0.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (119) hide show
  1. package/dist/{dist.min.js → dist.dev.js} +1603 -1561
  2. package/dist/{esm/geojson-loader.js → geojson-loader.js} +2 -2
  3. package/dist/geojson-loader.js.map +1 -0
  4. package/dist/geojson-worker.js +345 -179
  5. package/dist/{esm/geojson-writer.js → geojson-writer.js} +1 -1
  6. package/dist/geojson-writer.js.map +1 -0
  7. package/dist/index.cjs +1259 -0
  8. package/dist/index.js +9 -0
  9. package/dist/index.js.map +1 -0
  10. package/dist/{esm/json-loader.js → json-loader.js} +3 -3
  11. package/dist/json-loader.js.map +1 -0
  12. package/dist/{esm/json-writer.js → json-writer.js} +1 -1
  13. package/dist/json-writer.js.map +1 -0
  14. package/dist/{esm/lib → lib}/clarinet/clarinet.js +33 -34
  15. package/dist/lib/clarinet/clarinet.js.map +1 -0
  16. package/dist/{esm/lib → lib}/encoder-utils/encode-table-row.js +1 -1
  17. package/dist/lib/encoder-utils/encode-table-row.js.map +1 -0
  18. package/dist/lib/encoder-utils/encode-utils.js.map +1 -0
  19. package/dist/{esm/lib → lib}/encoder-utils/utf8-encoder.js +4 -5
  20. package/dist/lib/encoder-utils/utf8-encoder.js.map +1 -0
  21. package/dist/{esm/lib → lib}/encoders/geojson-encoder.js +3 -3
  22. package/dist/lib/encoders/geojson-encoder.js.map +1 -0
  23. package/dist/{esm/lib → lib}/encoders/json-encoder.js +1 -1
  24. package/dist/lib/encoders/json-encoder.js.map +1 -0
  25. package/dist/{esm/lib → lib}/json-parser/json-parser.js +8 -9
  26. package/dist/lib/json-parser/json-parser.js.map +1 -0
  27. package/dist/{esm/lib → lib}/json-parser/streaming-json-parser.js +6 -7
  28. package/dist/lib/json-parser/streaming-json-parser.js.map +1 -0
  29. package/dist/{esm/lib → lib}/jsonpath/jsonpath.js +1 -2
  30. package/dist/lib/jsonpath/jsonpath.js.map +1 -0
  31. package/dist/{esm/lib → lib}/parsers/parse-json-in-batches.js +2 -2
  32. package/dist/lib/parsers/parse-json-in-batches.js.map +1 -0
  33. package/dist/lib/parsers/parse-json.js.map +1 -0
  34. package/dist/{esm/lib → lib}/parsers/parse-ndjson-in-batches.js +1 -1
  35. package/dist/lib/parsers/parse-ndjson-in-batches.js.map +1 -0
  36. package/dist/{esm/lib → lib}/parsers/parse-ndjson.js +1 -1
  37. package/dist/lib/parsers/parse-ndjson.js.map +1 -0
  38. package/dist/{esm/ndgeoson-loader.js → ndgeoson-loader.js} +3 -3
  39. package/dist/ndgeoson-loader.js.map +1 -0
  40. package/dist/{esm/ndjson-loader.js → ndjson-loader.js} +3 -3
  41. package/dist/ndjson-loader.js.map +1 -0
  42. package/dist/{esm/workers → workers}/geojson-worker.js +1 -1
  43. package/dist/workers/geojson-worker.js.map +1 -0
  44. package/package.json +17 -9
  45. package/dist/bundle.d.ts +0 -2
  46. package/dist/bundle.d.ts.map +0 -1
  47. package/dist/es5/bundle.js +0 -6
  48. package/dist/es5/bundle.js.map +0 -1
  49. package/dist/es5/geojson-loader.js +0 -166
  50. package/dist/es5/geojson-loader.js.map +0 -1
  51. package/dist/es5/geojson-writer.js +0 -27
  52. package/dist/es5/geojson-writer.js.map +0 -1
  53. package/dist/es5/index.js +0 -69
  54. package/dist/es5/index.js.map +0 -1
  55. package/dist/es5/json-loader.js +0 -67
  56. package/dist/es5/json-loader.js.map +0 -1
  57. package/dist/es5/json-writer.js +0 -42
  58. package/dist/es5/json-writer.js.map +0 -1
  59. package/dist/es5/lib/clarinet/clarinet.js +0 -446
  60. package/dist/es5/lib/clarinet/clarinet.js.map +0 -1
  61. package/dist/es5/lib/encoder-utils/encode-table-row.js +0 -54
  62. package/dist/es5/lib/encoder-utils/encode-table-row.js.map +0 -1
  63. package/dist/es5/lib/encoder-utils/encode-utils.js +0 -42
  64. package/dist/es5/lib/encoder-utils/encode-utils.js.map +0 -1
  65. package/dist/es5/lib/encoder-utils/utf8-encoder.js +0 -54
  66. package/dist/es5/lib/encoder-utils/utf8-encoder.js.map +0 -1
  67. package/dist/es5/lib/encoders/geojson-encoder.js +0 -141
  68. package/dist/es5/lib/encoders/geojson-encoder.js.map +0 -1
  69. package/dist/es5/lib/encoders/json-encoder.js +0 -30
  70. package/dist/es5/lib/encoders/json-encoder.js.map +0 -1
  71. package/dist/es5/lib/json-parser/json-parser.js +0 -140
  72. package/dist/es5/lib/json-parser/json-parser.js.map +0 -1
  73. package/dist/es5/lib/json-parser/streaming-json-parser.js +0 -123
  74. package/dist/es5/lib/json-parser/streaming-json-parser.js.map +0 -1
  75. package/dist/es5/lib/jsonpath/jsonpath.js +0 -119
  76. package/dist/es5/lib/jsonpath/jsonpath.js.map +0 -1
  77. package/dist/es5/lib/parsers/parse-json-in-batches.js +0 -206
  78. package/dist/es5/lib/parsers/parse-json-in-batches.js.map +0 -1
  79. package/dist/es5/lib/parsers/parse-json.js +0 -38
  80. package/dist/es5/lib/parsers/parse-json.js.map +0 -1
  81. package/dist/es5/lib/parsers/parse-ndjson-in-batches.js +0 -114
  82. package/dist/es5/lib/parsers/parse-ndjson-in-batches.js.map +0 -1
  83. package/dist/es5/lib/parsers/parse-ndjson.js +0 -19
  84. package/dist/es5/lib/parsers/parse-ndjson.js.map +0 -1
  85. package/dist/es5/ndgeoson-loader.js +0 -51
  86. package/dist/es5/ndgeoson-loader.js.map +0 -1
  87. package/dist/es5/ndjson-loader.js +0 -44
  88. package/dist/es5/ndjson-loader.js.map +0 -1
  89. package/dist/es5/workers/geojson-worker.js +0 -6
  90. package/dist/es5/workers/geojson-worker.js.map +0 -1
  91. package/dist/esm/bundle.js +0 -4
  92. package/dist/esm/bundle.js.map +0 -1
  93. package/dist/esm/geojson-loader.js.map +0 -1
  94. package/dist/esm/geojson-writer.js.map +0 -1
  95. package/dist/esm/index.js +0 -9
  96. package/dist/esm/index.js.map +0 -1
  97. package/dist/esm/json-loader.js.map +0 -1
  98. package/dist/esm/json-writer.js.map +0 -1
  99. package/dist/esm/lib/clarinet/LICENSE +0 -28
  100. package/dist/esm/lib/clarinet/clarinet.js.map +0 -1
  101. package/dist/esm/lib/encoder-utils/encode-table-row.js.map +0 -1
  102. package/dist/esm/lib/encoder-utils/encode-utils.js.map +0 -1
  103. package/dist/esm/lib/encoder-utils/utf8-encoder.js.map +0 -1
  104. package/dist/esm/lib/encoders/geojson-encoder.js.map +0 -1
  105. package/dist/esm/lib/encoders/json-encoder.js.map +0 -1
  106. package/dist/esm/lib/json-parser/json-parser.js.map +0 -1
  107. package/dist/esm/lib/json-parser/streaming-json-parser.js.map +0 -1
  108. package/dist/esm/lib/jsonpath/jsonpath.js.map +0 -1
  109. package/dist/esm/lib/parsers/parse-json-in-batches.js.map +0 -1
  110. package/dist/esm/lib/parsers/parse-json.js.map +0 -1
  111. package/dist/esm/lib/parsers/parse-ndjson-in-batches.js.map +0 -1
  112. package/dist/esm/lib/parsers/parse-ndjson.js.map +0 -1
  113. package/dist/esm/ndgeoson-loader.js.map +0 -1
  114. package/dist/esm/ndjson-loader.js.map +0 -1
  115. package/dist/esm/workers/geojson-worker.js.map +0 -1
  116. package/src/bundle.ts +0 -4
  117. /package/dist/{es5/lib → lib}/clarinet/LICENSE +0 -0
  118. /package/dist/{esm/lib → lib}/encoder-utils/encode-utils.js +0 -0
  119. /package/dist/{esm/lib → lib}/parsers/parse-json.js +0 -0
@@ -1,7 +1,8 @@
1
+ "use strict";
1
2
  (() => {
2
3
  // ../worker-utils/src/lib/worker-utils/get-transfer-list.ts
3
4
  function getTransferList(object, recursive = true, transfers) {
4
- const transfersSet = transfers || new Set();
5
+ const transfersSet = transfers || /* @__PURE__ */ new Set();
5
6
  if (!object) {
6
7
  } else if (isTransferable(object)) {
7
8
  transfersSet.add(object);
@@ -44,11 +45,15 @@
44
45
  }
45
46
  return parentPort;
46
47
  }
47
- var onMessageWrapperMap = new Map();
48
+ var onMessageWrapperMap = /* @__PURE__ */ new Map();
48
49
  var WorkerBody = class {
50
+ /** Check that we are actually in a worker thread */
49
51
  static inWorkerThread() {
50
52
  return typeof self !== "undefined" || Boolean(getParentPort());
51
53
  }
54
+ /*
55
+ * (type: WorkerMessageType, payload: WorkerMessagePayload) => any
56
+ */
52
57
  static set onmessage(onMessage) {
53
58
  function handleMessage(message) {
54
59
  const parentPort3 = getParentPort();
@@ -92,6 +97,11 @@
92
97
  globalThis.removeEventListener("message", onMessageWrapper);
93
98
  }
94
99
  }
100
+ /**
101
+ * Send a message from a worker to creating thread (main thread)
102
+ * @param type
103
+ * @param payload
104
+ */
95
105
  static postMessage(type, payload) {
96
106
  const data = { source: "loaders.gl", type, payload };
97
107
  const transferList = getTransferList(payload);
@@ -123,6 +133,7 @@
123
133
  loader,
124
134
  arrayBuffer: input,
125
135
  options,
136
+ // @ts-expect-error fetch missing
126
137
  context: {
127
138
  ...context,
128
139
  _parse: parseOnMainThread
@@ -196,26 +207,80 @@
196
207
  }
197
208
  }
198
209
 
199
- // ../../node_modules/@math.gl/polygon/dist/esm/polygon-utils.js
210
+ // ../../node_modules/@babel/runtime/helpers/esm/typeof.js
211
+ function _typeof(obj) {
212
+ "@babel/helpers - typeof";
213
+ return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(obj2) {
214
+ return typeof obj2;
215
+ } : function(obj2) {
216
+ return obj2 && "function" == typeof Symbol && obj2.constructor === Symbol && obj2 !== Symbol.prototype ? "symbol" : typeof obj2;
217
+ }, _typeof(obj);
218
+ }
219
+
220
+ // ../../node_modules/@babel/runtime/helpers/esm/toPrimitive.js
221
+ function _toPrimitive(input, hint) {
222
+ if (_typeof(input) !== "object" || input === null)
223
+ return input;
224
+ var prim = input[Symbol.toPrimitive];
225
+ if (prim !== void 0) {
226
+ var res = prim.call(input, hint || "default");
227
+ if (_typeof(res) !== "object")
228
+ return res;
229
+ throw new TypeError("@@toPrimitive must return a primitive value.");
230
+ }
231
+ return (hint === "string" ? String : Number)(input);
232
+ }
233
+
234
+ // ../../node_modules/@babel/runtime/helpers/esm/toPropertyKey.js
235
+ function _toPropertyKey(arg) {
236
+ var key = _toPrimitive(arg, "string");
237
+ return _typeof(key) === "symbol" ? key : String(key);
238
+ }
239
+
240
+ // ../../node_modules/@babel/runtime/helpers/esm/defineProperty.js
241
+ function _defineProperty(obj, key, value) {
242
+ key = _toPropertyKey(key);
243
+ if (key in obj) {
244
+ Object.defineProperty(obj, key, {
245
+ value,
246
+ enumerable: true,
247
+ configurable: true,
248
+ writable: true
249
+ });
250
+ } else {
251
+ obj[key] = value;
252
+ }
253
+ return obj;
254
+ }
255
+
256
+ // ../../node_modules/@math.gl/polygon/dist/polygon-utils.js
257
+ var DimIndex = {
258
+ x: 0,
259
+ y: 1,
260
+ z: 2
261
+ };
200
262
  function getPolygonSignedArea(points, options = {}) {
201
263
  const {
202
264
  start = 0,
203
- end = points.length
265
+ end = points.length,
266
+ plane = "xy"
204
267
  } = options;
205
268
  const dim = options.size || 2;
206
269
  let area2 = 0;
270
+ const i0 = DimIndex[plane[0]];
271
+ const i1 = DimIndex[plane[1]];
207
272
  for (let i = start, j = end - dim; i < end; i += dim) {
208
- area2 += (points[i] - points[j]) * (points[i + 1] + points[j + 1]);
273
+ area2 += (points[i + i0] - points[j + i0]) * (points[i + i1] + points[j + i1]);
209
274
  j = i;
210
275
  }
211
276
  return area2 / 2;
212
277
  }
213
278
 
214
- // ../../node_modules/@math.gl/polygon/dist/esm/earcut.js
215
- function earcut(positions, holeIndices, dim = 2, areas) {
279
+ // ../../node_modules/@math.gl/polygon/dist/earcut.js
280
+ function earcut(positions, holeIndices, dim = 2, areas, plane = "xy") {
216
281
  const hasHoles = holeIndices && holeIndices.length;
217
282
  const outerLen = hasHoles ? holeIndices[0] * dim : positions.length;
218
- let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0]);
283
+ let outerNode = linkedList(positions, 0, outerLen, dim, true, areas && areas[0], plane);
219
284
  const triangles = [];
220
285
  if (!outerNode || outerNode.next === outerNode.prev)
221
286
  return triangles;
@@ -227,7 +292,7 @@
227
292
  let x;
228
293
  let y;
229
294
  if (hasHoles)
230
- outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas);
295
+ outerNode = eliminateHoles(positions, holeIndices, outerNode, dim, areas, plane);
231
296
  if (positions.length > 80 * dim) {
232
297
  minX = maxX = positions[0];
233
298
  minY = maxY = positions[1];
@@ -244,27 +309,30 @@
244
309
  maxY = y;
245
310
  }
246
311
  invSize = Math.max(maxX - minX, maxY - minY);
247
- invSize = invSize !== 0 ? 1 / invSize : 0;
312
+ invSize = invSize !== 0 ? 32767 / invSize : 0;
248
313
  }
249
- earcutLinked(outerNode, triangles, dim, minX, minY, invSize);
314
+ earcutLinked(outerNode, triangles, dim, minX, minY, invSize, 0);
250
315
  return triangles;
251
316
  }
252
- function linkedList(data, start, end, dim, clockwise, area2) {
317
+ function linkedList(data, start, end, dim, clockwise, area2, plane) {
253
318
  let i;
254
319
  let last;
255
320
  if (area2 === void 0) {
256
321
  area2 = getPolygonSignedArea(data, {
257
322
  start,
258
323
  end,
259
- size: dim
324
+ size: dim,
325
+ plane
260
326
  });
261
327
  }
328
+ let i0 = DimIndex[plane[0]];
329
+ let i1 = DimIndex[plane[1]];
262
330
  if (clockwise === area2 < 0) {
263
331
  for (i = start; i < end; i += dim)
264
- last = insertNode(i, data[i], data[i + 1], last);
332
+ last = insertNode(i, data[i + i0], data[i + i1], last);
265
333
  } else {
266
334
  for (i = end - dim; i >= start; i -= dim)
267
- last = insertNode(i, data[i], data[i + 1], last);
335
+ last = insertNode(i, data[i + i0], data[i + i1], last);
268
336
  }
269
337
  if (last && equals(last, last.next)) {
270
338
  removeNode(last);
@@ -305,9 +373,9 @@
305
373
  prev = ear.prev;
306
374
  next = ear.next;
307
375
  if (invSize ? isEarHashed(ear, minX, minY, invSize) : isEar(ear)) {
308
- triangles.push(prev.i / dim);
309
- triangles.push(ear.i / dim);
310
- triangles.push(next.i / dim);
376
+ triangles.push(prev.i / dim | 0);
377
+ triangles.push(ear.i / dim | 0);
378
+ triangles.push(next.i / dim | 0);
311
379
  removeNode(ear);
312
380
  ear = next.next;
313
381
  stop = next.next;
@@ -333,9 +401,19 @@
333
401
  const c = ear.next;
334
402
  if (area(a, b, c) >= 0)
335
403
  return false;
336
- let p = ear.next.next;
337
- while (p !== ear.prev) {
338
- if (pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
404
+ const ax = a.x;
405
+ const bx = b.x;
406
+ const cx = c.x;
407
+ const ay = a.y;
408
+ const by = b.y;
409
+ const cy = c.y;
410
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
411
+ const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
412
+ const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
413
+ const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
414
+ let p = c.next;
415
+ while (p !== a) {
416
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
339
417
  return false;
340
418
  p = p.next;
341
419
  }
@@ -347,29 +425,35 @@
347
425
  const c = ear.next;
348
426
  if (area(a, b, c) >= 0)
349
427
  return false;
350
- const minTX = a.x < b.x ? a.x < c.x ? a.x : c.x : b.x < c.x ? b.x : c.x;
351
- const minTY = a.y < b.y ? a.y < c.y ? a.y : c.y : b.y < c.y ? b.y : c.y;
352
- const maxTX = a.x > b.x ? a.x > c.x ? a.x : c.x : b.x > c.x ? b.x : c.x;
353
- const maxTY = a.y > b.y ? a.y > c.y ? a.y : c.y : b.y > c.y ? b.y : c.y;
354
- const minZ = zOrder(minTX, minTY, minX, minY, invSize);
355
- const maxZ = zOrder(maxTX, maxTY, minX, minY, invSize);
428
+ const ax = a.x;
429
+ const bx = b.x;
430
+ const cx = c.x;
431
+ const ay = a.y;
432
+ const by = b.y;
433
+ const cy = c.y;
434
+ const x0 = ax < bx ? ax < cx ? ax : cx : bx < cx ? bx : cx;
435
+ const y0 = ay < by ? ay < cy ? ay : cy : by < cy ? by : cy;
436
+ const x1 = ax > bx ? ax > cx ? ax : cx : bx > cx ? bx : cx;
437
+ const y1 = ay > by ? ay > cy ? ay : cy : by > cy ? by : cy;
438
+ const minZ = zOrder(x0, y0, minX, minY, invSize);
439
+ const maxZ = zOrder(x1, y1, minX, minY, invSize);
356
440
  let p = ear.prevZ;
357
441
  let n = ear.nextZ;
358
442
  while (p && p.z >= minZ && n && n.z <= maxZ) {
359
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
443
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
360
444
  return false;
361
445
  p = p.prevZ;
362
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
446
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
363
447
  return false;
364
448
  n = n.nextZ;
365
449
  }
366
450
  while (p && p.z >= minZ) {
367
- if (p !== ear.prev && p !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, p.x, p.y) && area(p.prev, p, p.next) >= 0)
451
+ if (p.x >= x0 && p.x <= x1 && p.y >= y0 && p.y <= y1 && p !== a && p !== c && pointInTriangle(ax, ay, bx, by, cx, cy, p.x, p.y) && area(p.prev, p, p.next) >= 0)
368
452
  return false;
369
453
  p = p.prevZ;
370
454
  }
371
455
  while (n && n.z <= maxZ) {
372
- if (n !== ear.prev && n !== ear.next && pointInTriangle(a.x, a.y, b.x, b.y, c.x, c.y, n.x, n.y) && area(n.prev, n, n.next) >= 0)
456
+ if (n.x >= x0 && n.x <= x1 && n.y >= y0 && n.y <= y1 && n !== a && n !== c && pointInTriangle(ax, ay, bx, by, cx, cy, n.x, n.y) && area(n.prev, n, n.next) >= 0)
373
457
  return false;
374
458
  n = n.nextZ;
375
459
  }
@@ -381,9 +465,9 @@
381
465
  const a = p.prev;
382
466
  const b = p.next.next;
383
467
  if (!equals(a, b) && intersects(a, p, p.next, b) && locallyInside(a, b) && locallyInside(b, a)) {
384
- triangles.push(a.i / dim);
385
- triangles.push(p.i / dim);
386
- triangles.push(b.i / dim);
468
+ triangles.push(a.i / dim | 0);
469
+ triangles.push(p.i / dim | 0);
470
+ triangles.push(b.i / dim | 0);
387
471
  removeNode(p);
388
472
  removeNode(p.next);
389
473
  p = start = b;
@@ -401,8 +485,8 @@
401
485
  let c = splitPolygon(a, b);
402
486
  a = filterPoints(a, a.next);
403
487
  c = filterPoints(c, c.next);
404
- earcutLinked(a, triangles, dim, minX, minY, invSize);
405
- earcutLinked(c, triangles, dim, minX, minY, invSize);
488
+ earcutLinked(a, triangles, dim, minX, minY, invSize, 0);
489
+ earcutLinked(c, triangles, dim, minX, minY, invSize, 0);
406
490
  return;
407
491
  }
408
492
  b = b.next;
@@ -410,7 +494,7 @@
410
494
  a = a.next;
411
495
  } while (a !== start);
412
496
  }
413
- function eliminateHoles(data, holeIndices, outerNode, dim, areas) {
497
+ function eliminateHoles(data, holeIndices, outerNode, dim, areas, plane) {
414
498
  const queue = [];
415
499
  let i;
416
500
  let len;
@@ -420,15 +504,14 @@
420
504
  for (i = 0, len = holeIndices.length; i < len; i++) {
421
505
  start = holeIndices[i] * dim;
422
506
  end = i < len - 1 ? holeIndices[i + 1] * dim : data.length;
423
- list = linkedList(data, start, end, dim, false, areas && areas[i + 1]);
507
+ list = linkedList(data, start, end, dim, false, areas && areas[i + 1], plane);
424
508
  if (list === list.next)
425
509
  list.steiner = true;
426
510
  queue.push(getLeftmost(list));
427
511
  }
428
512
  queue.sort(compareX);
429
513
  for (i = 0; i < queue.length; i++) {
430
- eliminateHole(queue[i], outerNode);
431
- outerNode = filterPoints(outerNode, outerNode.next);
514
+ outerNode = eliminateHole(queue[i], outerNode);
432
515
  }
433
516
  return outerNode;
434
517
  }
@@ -436,12 +519,13 @@
436
519
  return a.x - b.x;
437
520
  }
438
521
  function eliminateHole(hole, outerNode) {
439
- outerNode = findHoleBridge(hole, outerNode);
440
- if (outerNode) {
441
- const b = splitPolygon(outerNode, hole);
442
- filterPoints(outerNode, outerNode.next);
443
- filterPoints(b, b.next);
522
+ const bridge = findHoleBridge(hole, outerNode);
523
+ if (!bridge) {
524
+ return outerNode;
444
525
  }
526
+ const bridgeReverse = splitPolygon(bridge, hole);
527
+ filterPoints(bridgeReverse, bridgeReverse.next);
528
+ return filterPoints(bridge, bridge.next);
445
529
  }
446
530
  function findHoleBridge(hole, outerNode) {
447
531
  let p = outerNode;
@@ -454,21 +538,15 @@
454
538
  const x = p.x + (hy - p.y) * (p.next.x - p.x) / (p.next.y - p.y);
455
539
  if (x <= hx && x > qx) {
456
540
  qx = x;
457
- if (x === hx) {
458
- if (hy === p.y)
459
- return p;
460
- if (hy === p.next.y)
461
- return p.next;
462
- }
463
541
  m = p.x < p.next.x ? p : p.next;
542
+ if (x === hx)
543
+ return m;
464
544
  }
465
545
  }
466
546
  p = p.next;
467
547
  } while (p !== outerNode);
468
548
  if (!m)
469
549
  return null;
470
- if (hx === qx)
471
- return m;
472
550
  const stop = m;
473
551
  const mx = m.x;
474
552
  const my = m.y;
@@ -493,7 +571,7 @@
493
571
  function indexCurve(start, minX, minY, invSize) {
494
572
  let p = start;
495
573
  do {
496
- if (p.z === null)
574
+ if (p.z === 0)
497
575
  p.z = zOrder(p.x, p.y, minX, minY, invSize);
498
576
  p.prevZ = p.prev;
499
577
  p.nextZ = p.next;
@@ -554,8 +632,8 @@
554
632
  return list;
555
633
  }
556
634
  function zOrder(x, y, minX, minY, invSize) {
557
- x = 32767 * (x - minX) * invSize;
558
- y = 32767 * (y - minY) * invSize;
635
+ x = (x - minX) * invSize | 0;
636
+ y = (y - minY) * invSize | 0;
559
637
  x = (x | x << 8) & 16711935;
560
638
  x = (x | x << 4) & 252645135;
561
639
  x = (x | x << 2) & 858993459;
@@ -577,7 +655,7 @@
577
655
  return leftmost;
578
656
  }
579
657
  function pointInTriangle(ax, ay, bx, by, cx, cy, px, py) {
580
- return (cx - px) * (ay - py) - (ax - px) * (cy - py) >= 0 && (ax - px) * (by - py) - (bx - px) * (ay - py) >= 0 && (bx - px) * (cy - py) - (cx - px) * (by - py) >= 0;
658
+ 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);
581
659
  }
582
660
  function isValidDiagonal(a, b) {
583
661
  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);
@@ -636,8 +714,8 @@
636
714
  return inside;
637
715
  }
638
716
  function splitPolygon(a, b) {
639
- const a2 = new Node(a.i, a.x, a.y);
640
- const b2 = new Node(b.i, b.x, b.y);
717
+ const a2 = new Vertex(a.i, a.x, a.y);
718
+ const b2 = new Vertex(b.i, b.x, b.y);
641
719
  const an = a.next;
642
720
  const bp = b.prev;
643
721
  a.next = b;
@@ -651,7 +729,7 @@
651
729
  return b2;
652
730
  }
653
731
  function insertNode(i, x, y, last) {
654
- const p = new Node(i, x, y);
732
+ const p = new Vertex(i, x, y);
655
733
  if (!last) {
656
734
  p.prev = p;
657
735
  p.next = p;
@@ -671,30 +749,39 @@
671
749
  if (p.nextZ)
672
750
  p.nextZ.prevZ = p.prevZ;
673
751
  }
674
- function Node(i, x, y) {
675
- this.i = i;
676
- this.x = x;
677
- this.y = y;
678
- this.prev = null;
679
- this.next = null;
680
- this.z = null;
681
- this.prevZ = null;
682
- this.nextZ = null;
683
- this.steiner = false;
684
- }
752
+ var Vertex = class {
753
+ constructor(i, x, y) {
754
+ _defineProperty(this, "i", void 0);
755
+ _defineProperty(this, "x", void 0);
756
+ _defineProperty(this, "y", void 0);
757
+ _defineProperty(this, "prev", null);
758
+ _defineProperty(this, "next", null);
759
+ _defineProperty(this, "z", 0);
760
+ _defineProperty(this, "prevZ", null);
761
+ _defineProperty(this, "nextZ", null);
762
+ _defineProperty(this, "steiner", false);
763
+ this.i = i;
764
+ this.x = x;
765
+ this.y = y;
766
+ }
767
+ };
685
768
 
686
769
  // ../gis/src/lib/flat-geojson-to-binary.ts
687
770
  function flatGeojsonToBinary(features, geometryInfo, options) {
688
771
  const propArrayTypes = extractNumericPropTypes(features);
689
772
  const numericPropKeys = Object.keys(propArrayTypes).filter((k) => propArrayTypes[k] !== Array);
690
- return fillArrays(features, {
691
- propArrayTypes,
692
- ...geometryInfo
693
- }, {
694
- numericPropKeys: options && options.numericPropKeys || numericPropKeys,
695
- PositionDataType: options ? options.PositionDataType : Float32Array,
696
- triangulate: options ? options.triangulate : true
697
- });
773
+ return fillArrays(
774
+ features,
775
+ {
776
+ propArrayTypes,
777
+ ...geometryInfo
778
+ },
779
+ {
780
+ numericPropKeys: options && options.numericPropKeys || numericPropKeys,
781
+ PositionDataType: options ? options.PositionDataType : Float32Array,
782
+ triangulate: options ? options.triangulate : true
783
+ }
784
+ );
698
785
  }
699
786
  function extractNumericPropTypes(features) {
700
787
  const propArrayTypes = {};
@@ -818,16 +905,32 @@
818
905
  points.positions.set(geometry.data, indexMap.pointPosition * coordLength);
819
906
  const nPositions = geometry.data.length / coordLength;
820
907
  fillNumericProperties(points, properties, indexMap.pointPosition, nPositions);
821
- points.globalFeatureIds.fill(indexMap.feature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
822
- points.featureIds.fill(indexMap.pointFeature, indexMap.pointPosition, indexMap.pointPosition + nPositions);
908
+ points.globalFeatureIds.fill(
909
+ indexMap.feature,
910
+ indexMap.pointPosition,
911
+ indexMap.pointPosition + nPositions
912
+ );
913
+ points.featureIds.fill(
914
+ indexMap.pointFeature,
915
+ indexMap.pointPosition,
916
+ indexMap.pointPosition + nPositions
917
+ );
823
918
  indexMap.pointPosition += nPositions;
824
919
  }
825
920
  function handleLineString(geometry, lines, indexMap, coordLength, properties) {
826
921
  lines.positions.set(geometry.data, indexMap.linePosition * coordLength);
827
922
  const nPositions = geometry.data.length / coordLength;
828
923
  fillNumericProperties(lines, properties, indexMap.linePosition, nPositions);
829
- lines.globalFeatureIds.fill(indexMap.feature, indexMap.linePosition, indexMap.linePosition + nPositions);
830
- lines.featureIds.fill(indexMap.lineFeature, indexMap.linePosition, indexMap.linePosition + nPositions);
924
+ lines.globalFeatureIds.fill(
925
+ indexMap.feature,
926
+ indexMap.linePosition,
927
+ indexMap.linePosition + nPositions
928
+ );
929
+ lines.featureIds.fill(
930
+ indexMap.lineFeature,
931
+ indexMap.linePosition,
932
+ indexMap.linePosition + nPositions
933
+ );
831
934
  for (let i = 0, il = geometry.indices.length; i < il; ++i) {
832
935
  const start = geometry.indices[i];
833
936
  const end = i === il - 1 ? geometry.data.length : geometry.indices[i + 1];
@@ -839,8 +942,16 @@
839
942
  polygons.positions.set(geometry.data, indexMap.polygonPosition * coordLength);
840
943
  const nPositions = geometry.data.length / coordLength;
841
944
  fillNumericProperties(polygons, properties, indexMap.polygonPosition, nPositions);
842
- polygons.globalFeatureIds.fill(indexMap.feature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
843
- polygons.featureIds.fill(indexMap.polygonFeature, indexMap.polygonPosition, indexMap.polygonPosition + nPositions);
945
+ polygons.globalFeatureIds.fill(
946
+ indexMap.feature,
947
+ indexMap.polygonPosition,
948
+ indexMap.polygonPosition + nPositions
949
+ );
950
+ polygons.featureIds.fill(
951
+ indexMap.polygonFeature,
952
+ indexMap.polygonPosition,
953
+ indexMap.polygonPosition + nPositions
954
+ );
844
955
  for (let l = 0, ll = geometry.indices.length; l < ll; ++l) {
845
956
  const startPosition = indexMap.polygonPosition;
846
957
  polygons.polygonIndices[indexMap.polygonObject++] = startPosition;
@@ -849,7 +960,10 @@
849
960
  const nextIndices = geometry.indices[l + 1];
850
961
  for (let i = 0, il = indices.length; i < il; ++i) {
851
962
  const start = indices[i];
852
- const end = i === il - 1 ? nextIndices === void 0 ? geometry.data.length : nextIndices[0] : indices[i + 1];
963
+ const end = i === il - 1 ? (
964
+ // last line, so either read to:
965
+ nextIndices === void 0 ? geometry.data.length : nextIndices[0]
966
+ ) : indices[i + 1];
853
967
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
854
968
  indexMap.polygonPosition += (end - start) / coordLength;
855
969
  }
@@ -908,6 +1022,7 @@
908
1022
  featureIds: { value: polygons.featureIds, size: 1 },
909
1023
  numericProps: wrapProps(polygons.numericProps, 1)
910
1024
  }
1025
+ // triangles not expected
911
1026
  };
912
1027
  if (binaryFeatures.polygons && polygons.triangles) {
913
1028
  binaryFeatures.polygons.triangles = { value: new Uint32Array(polygons.triangles), size: 1 };
@@ -949,7 +1064,7 @@
949
1064
  let polygonObjectsCount = 0;
950
1065
  let polygonRingsCount = 0;
951
1066
  let polygonFeaturesCount = 0;
952
- const coordLengths = new Set();
1067
+ const coordLengths = /* @__PURE__ */ new Set();
953
1068
  for (const feature of features) {
954
1069
  const geometry = feature.geometry;
955
1070
  switch (geometry.type) {
@@ -1321,6 +1436,7 @@
1321
1436
  };
1322
1437
  return batch;
1323
1438
  }
1439
+ // HELPERS
1324
1440
  _reallocateColumns() {
1325
1441
  if (this.length < this.allocated) {
1326
1442
  return;
@@ -1381,6 +1497,7 @@
1381
1497
  }
1382
1498
  return false;
1383
1499
  }
1500
+ /** @deprecated Use addArrayRow or addObjectRow */
1384
1501
  addRow(row) {
1385
1502
  if (this.limitReached()) {
1386
1503
  return;
@@ -1394,6 +1511,7 @@
1394
1511
  this.addObjectRow(row);
1395
1512
  }
1396
1513
  }
1514
+ /** Add one row to the batch */
1397
1515
  addArrayRow(row) {
1398
1516
  if (!this.aggregator) {
1399
1517
  const TableBatchType = this._getTableBatchType();
@@ -1401,6 +1519,7 @@
1401
1519
  }
1402
1520
  this.aggregator.addArrayRow(row);
1403
1521
  }
1522
+ /** Add one row to the batch */
1404
1523
  addObjectRow(row) {
1405
1524
  if (!this.aggregator) {
1406
1525
  const TableBatchType = this._getTableBatchType();
@@ -1408,6 +1527,7 @@
1408
1527
  }
1409
1528
  this.aggregator.addObjectRow(row);
1410
1529
  }
1530
+ /** Mark an incoming raw memory chunk has completed */
1411
1531
  chunkComplete(chunk) {
1412
1532
  if (chunk instanceof ArrayBuffer) {
1413
1533
  this.bytesUsed += chunk.byteLength;
@@ -1423,6 +1543,7 @@
1423
1543
  getFinalBatch(options) {
1424
1544
  return this._getBatch(options);
1425
1545
  }
1546
+ // INTERNAL
1426
1547
  _estimateRowMB(row) {
1427
1548
  return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
1428
1549
  }
@@ -1444,6 +1565,9 @@
1444
1565
  this.lastBatchEmittedMs = Date.now();
1445
1566
  return true;
1446
1567
  }
1568
+ /**
1569
+ * bytesUsed can be set via chunkComplete or via getBatch*
1570
+ */
1447
1571
  _getBatch(options) {
1448
1572
  if (!this.aggregator) {
1449
1573
  return null;
@@ -1481,62 +1605,63 @@
1481
1605
 
1482
1606
  // src/lib/clarinet/clarinet.ts
1483
1607
  var MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;
1484
- var STATE;
1485
- (function(STATE2) {
1486
- STATE2[STATE2["BEGIN"] = 0] = "BEGIN";
1487
- STATE2[STATE2["VALUE"] = 1] = "VALUE";
1488
- STATE2[STATE2["OPEN_OBJECT"] = 2] = "OPEN_OBJECT";
1489
- STATE2[STATE2["CLOSE_OBJECT"] = 3] = "CLOSE_OBJECT";
1490
- STATE2[STATE2["OPEN_ARRAY"] = 4] = "OPEN_ARRAY";
1491
- STATE2[STATE2["CLOSE_ARRAY"] = 5] = "CLOSE_ARRAY";
1492
- STATE2[STATE2["TEXT_ESCAPE"] = 6] = "TEXT_ESCAPE";
1493
- STATE2[STATE2["STRING"] = 7] = "STRING";
1494
- STATE2[STATE2["BACKSLASH"] = 8] = "BACKSLASH";
1495
- STATE2[STATE2["END"] = 9] = "END";
1496
- STATE2[STATE2["OPEN_KEY"] = 10] = "OPEN_KEY";
1497
- STATE2[STATE2["CLOSE_KEY"] = 11] = "CLOSE_KEY";
1498
- STATE2[STATE2["TRUE"] = 12] = "TRUE";
1499
- STATE2[STATE2["TRUE2"] = 13] = "TRUE2";
1500
- STATE2[STATE2["TRUE3"] = 14] = "TRUE3";
1501
- STATE2[STATE2["FALSE"] = 15] = "FALSE";
1502
- STATE2[STATE2["FALSE2"] = 16] = "FALSE2";
1503
- STATE2[STATE2["FALSE3"] = 17] = "FALSE3";
1504
- STATE2[STATE2["FALSE4"] = 18] = "FALSE4";
1505
- STATE2[STATE2["NULL"] = 19] = "NULL";
1506
- STATE2[STATE2["NULL2"] = 20] = "NULL2";
1507
- STATE2[STATE2["NULL3"] = 21] = "NULL3";
1508
- STATE2[STATE2["NUMBER_DECIMAL_POINT"] = 22] = "NUMBER_DECIMAL_POINT";
1509
- STATE2[STATE2["NUMBER_DIGIT"] = 23] = "NUMBER_DIGIT";
1510
- })(STATE || (STATE = {}));
1511
1608
  var Char = {
1512
1609
  tab: 9,
1610
+ // \t
1513
1611
  lineFeed: 10,
1612
+ // \n
1514
1613
  carriageReturn: 13,
1614
+ // \r
1515
1615
  space: 32,
1616
+ // " "
1516
1617
  doubleQuote: 34,
1618
+ // "
1517
1619
  plus: 43,
1620
+ // +
1518
1621
  comma: 44,
1622
+ // ,
1519
1623
  minus: 45,
1624
+ // -
1520
1625
  period: 46,
1626
+ // .
1521
1627
  _0: 48,
1628
+ // 0
1522
1629
  _9: 57,
1630
+ // 9
1523
1631
  colon: 58,
1632
+ // :
1524
1633
  E: 69,
1634
+ // E
1525
1635
  openBracket: 91,
1636
+ // [
1526
1637
  backslash: 92,
1638
+ // \
1527
1639
  closeBracket: 93,
1640
+ // ]
1528
1641
  a: 97,
1642
+ // a
1529
1643
  b: 98,
1644
+ // b
1530
1645
  e: 101,
1646
+ // e
1531
1647
  f: 102,
1648
+ // f
1532
1649
  l: 108,
1650
+ // l
1533
1651
  n: 110,
1652
+ // n
1534
1653
  r: 114,
1654
+ // r
1535
1655
  s: 115,
1656
+ // s
1536
1657
  t: 116,
1658
+ // t
1537
1659
  u: 117,
1660
+ // u
1538
1661
  openBrace: 123,
1662
+ // {
1539
1663
  closeBrace: 125
1664
+ // }
1540
1665
  };
1541
1666
  var stringTokenPattern = /[\\"\n]/g;
1542
1667
  var DEFAULT_OPTIONS2 = {
@@ -1571,9 +1696,11 @@
1571
1696
  this.closed = false;
1572
1697
  this.closedRoot = false;
1573
1698
  this.sawRoot = false;
1699
+ // tag = null;
1574
1700
  this.error = null;
1575
- this.state = 0;
1701
+ this.state = 0 /* BEGIN */;
1576
1702
  this.stack = [];
1703
+ // mostly just for error reporting
1577
1704
  this.position = 0;
1578
1705
  this.column = 0;
1579
1706
  this.line = 1;
@@ -1587,7 +1714,7 @@
1587
1714
  this.emit("onready");
1588
1715
  }
1589
1716
  end() {
1590
- if (this.state !== 1 || this.depth !== 0)
1717
+ if (this.state !== 1 /* VALUE */ || this.depth !== 0)
1591
1718
  this._error("Unexpected end");
1592
1719
  this._closeValue();
1593
1720
  this.c = "";
@@ -1602,6 +1729,7 @@
1602
1729
  close() {
1603
1730
  return this.write(null);
1604
1731
  }
1732
+ // protected
1605
1733
  emit(event, data) {
1606
1734
  this.options[event]?.(data, this);
1607
1735
  }
@@ -1609,6 +1737,8 @@
1609
1737
  this._closeValue();
1610
1738
  this.emit(event, data);
1611
1739
  }
1740
+ /* eslint-disable no-continue */
1741
+ // eslint-disable-next-line complexity, max-statements
1612
1742
  write(chunk) {
1613
1743
  if (this.error) {
1614
1744
  throw this.error;
@@ -1639,111 +1769,111 @@
1639
1769
  } else
1640
1770
  this.column++;
1641
1771
  switch (this.state) {
1642
- case 0:
1772
+ case 0 /* BEGIN */:
1643
1773
  if (c === Char.openBrace)
1644
- this.state = 2;
1774
+ this.state = 2 /* OPEN_OBJECT */;
1645
1775
  else if (c === Char.openBracket)
1646
- this.state = 4;
1776
+ this.state = 4 /* OPEN_ARRAY */;
1647
1777
  else if (!isWhitespace(c)) {
1648
1778
  this._error("Non-whitespace before {[.");
1649
1779
  }
1650
1780
  continue;
1651
- case 10:
1652
- case 2:
1781
+ case 10 /* OPEN_KEY */:
1782
+ case 2 /* OPEN_OBJECT */:
1653
1783
  if (isWhitespace(c))
1654
1784
  continue;
1655
- if (this.state === 10)
1656
- this.stack.push(11);
1785
+ if (this.state === 10 /* OPEN_KEY */)
1786
+ this.stack.push(11 /* CLOSE_KEY */);
1657
1787
  else if (c === Char.closeBrace) {
1658
1788
  this.emit("onopenobject");
1659
1789
  this.depth++;
1660
1790
  this.emit("oncloseobject");
1661
1791
  this.depth--;
1662
- this.state = this.stack.pop() || 1;
1792
+ this.state = this.stack.pop() || 1 /* VALUE */;
1663
1793
  continue;
1664
1794
  } else
1665
- this.stack.push(3);
1795
+ this.stack.push(3 /* CLOSE_OBJECT */);
1666
1796
  if (c === Char.doubleQuote)
1667
- this.state = 7;
1797
+ this.state = 7 /* STRING */;
1668
1798
  else
1669
1799
  this._error('Malformed object key should start with "');
1670
1800
  continue;
1671
- case 11:
1672
- case 3:
1801
+ case 11 /* CLOSE_KEY */:
1802
+ case 3 /* CLOSE_OBJECT */:
1673
1803
  if (isWhitespace(c))
1674
1804
  continue;
1675
1805
  if (c === Char.colon) {
1676
- if (this.state === 3) {
1677
- this.stack.push(3);
1806
+ if (this.state === 3 /* CLOSE_OBJECT */) {
1807
+ this.stack.push(3 /* CLOSE_OBJECT */);
1678
1808
  this._closeValue("onopenobject");
1679
1809
  this.depth++;
1680
1810
  } else
1681
1811
  this._closeValue("onkey");
1682
- this.state = 1;
1812
+ this.state = 1 /* VALUE */;
1683
1813
  } else if (c === Char.closeBrace) {
1684
1814
  this.emitNode("oncloseobject");
1685
1815
  this.depth--;
1686
- this.state = this.stack.pop() || 1;
1816
+ this.state = this.stack.pop() || 1 /* VALUE */;
1687
1817
  } else if (c === Char.comma) {
1688
- if (this.state === 3)
1689
- this.stack.push(3);
1818
+ if (this.state === 3 /* CLOSE_OBJECT */)
1819
+ this.stack.push(3 /* CLOSE_OBJECT */);
1690
1820
  this._closeValue();
1691
- this.state = 10;
1821
+ this.state = 10 /* OPEN_KEY */;
1692
1822
  } else
1693
1823
  this._error("Bad object");
1694
1824
  continue;
1695
- case 4:
1696
- case 1:
1825
+ case 4 /* OPEN_ARRAY */:
1826
+ case 1 /* VALUE */:
1697
1827
  if (isWhitespace(c))
1698
1828
  continue;
1699
- if (this.state === 4) {
1829
+ if (this.state === 4 /* OPEN_ARRAY */) {
1700
1830
  this.emit("onopenarray");
1701
1831
  this.depth++;
1702
- this.state = 1;
1832
+ this.state = 1 /* VALUE */;
1703
1833
  if (c === Char.closeBracket) {
1704
1834
  this.emit("onclosearray");
1705
1835
  this.depth--;
1706
- this.state = this.stack.pop() || 1;
1836
+ this.state = this.stack.pop() || 1 /* VALUE */;
1707
1837
  continue;
1708
1838
  } else {
1709
- this.stack.push(5);
1839
+ this.stack.push(5 /* CLOSE_ARRAY */);
1710
1840
  }
1711
1841
  }
1712
1842
  if (c === Char.doubleQuote)
1713
- this.state = 7;
1843
+ this.state = 7 /* STRING */;
1714
1844
  else if (c === Char.openBrace)
1715
- this.state = 2;
1845
+ this.state = 2 /* OPEN_OBJECT */;
1716
1846
  else if (c === Char.openBracket)
1717
- this.state = 4;
1847
+ this.state = 4 /* OPEN_ARRAY */;
1718
1848
  else if (c === Char.t)
1719
- this.state = 12;
1849
+ this.state = 12 /* TRUE */;
1720
1850
  else if (c === Char.f)
1721
- this.state = 15;
1851
+ this.state = 15 /* FALSE */;
1722
1852
  else if (c === Char.n)
1723
- this.state = 19;
1853
+ this.state = 19 /* NULL */;
1724
1854
  else if (c === Char.minus) {
1725
1855
  this.numberNode += "-";
1726
1856
  } else if (Char._0 <= c && c <= Char._9) {
1727
1857
  this.numberNode += String.fromCharCode(c);
1728
- this.state = 23;
1858
+ this.state = 23 /* NUMBER_DIGIT */;
1729
1859
  } else
1730
1860
  this._error("Bad value");
1731
1861
  continue;
1732
- case 5:
1862
+ case 5 /* CLOSE_ARRAY */:
1733
1863
  if (c === Char.comma) {
1734
- this.stack.push(5);
1864
+ this.stack.push(5 /* CLOSE_ARRAY */);
1735
1865
  this._closeValue("onvalue");
1736
- this.state = 1;
1866
+ this.state = 1 /* VALUE */;
1737
1867
  } else if (c === Char.closeBracket) {
1738
1868
  this.emitNode("onclosearray");
1739
1869
  this.depth--;
1740
- this.state = this.stack.pop() || 1;
1870
+ this.state = this.stack.pop() || 1 /* VALUE */;
1741
1871
  } else if (isWhitespace(c))
1742
1872
  continue;
1743
1873
  else
1744
1874
  this._error("Bad array");
1745
1875
  continue;
1746
- case 7:
1876
+ case 7 /* STRING */:
1747
1877
  if (this.textNode === void 0) {
1748
1878
  this.textNode = "";
1749
1879
  }
@@ -1767,7 +1897,7 @@
1767
1897
  break STRING_BIGLOOP;
1768
1898
  }
1769
1899
  if (c === Char.doubleQuote && !slashed) {
1770
- this.state = this.stack.pop() || 1;
1900
+ this.state = this.stack.pop() || 1 /* VALUE */;
1771
1901
  this.textNode += chunk.substring(starti, i - 1);
1772
1902
  this.position += i - 1 - starti;
1773
1903
  break;
@@ -1826,77 +1956,77 @@
1826
1956
  this.slashed = slashed;
1827
1957
  this.unicodeI = unicodeI;
1828
1958
  continue;
1829
- case 12:
1959
+ case 12 /* TRUE */:
1830
1960
  if (c === Char.r)
1831
- this.state = 13;
1961
+ this.state = 13 /* TRUE2 */;
1832
1962
  else
1833
1963
  this._error(`Invalid true started with t${c}`);
1834
1964
  continue;
1835
- case 13:
1965
+ case 13 /* TRUE2 */:
1836
1966
  if (c === Char.u)
1837
- this.state = 14;
1967
+ this.state = 14 /* TRUE3 */;
1838
1968
  else
1839
1969
  this._error(`Invalid true started with tr${c}`);
1840
1970
  continue;
1841
- case 14:
1971
+ case 14 /* TRUE3 */:
1842
1972
  if (c === Char.e) {
1843
1973
  this.emit("onvalue", true);
1844
- this.state = this.stack.pop() || 1;
1974
+ this.state = this.stack.pop() || 1 /* VALUE */;
1845
1975
  } else
1846
1976
  this._error(`Invalid true started with tru${c}`);
1847
1977
  continue;
1848
- case 15:
1978
+ case 15 /* FALSE */:
1849
1979
  if (c === Char.a)
1850
- this.state = 16;
1980
+ this.state = 16 /* FALSE2 */;
1851
1981
  else
1852
1982
  this._error(`Invalid false started with f${c}`);
1853
1983
  continue;
1854
- case 16:
1984
+ case 16 /* FALSE2 */:
1855
1985
  if (c === Char.l)
1856
- this.state = 17;
1986
+ this.state = 17 /* FALSE3 */;
1857
1987
  else
1858
1988
  this._error(`Invalid false started with fa${c}`);
1859
1989
  continue;
1860
- case 17:
1990
+ case 17 /* FALSE3 */:
1861
1991
  if (c === Char.s)
1862
- this.state = 18;
1992
+ this.state = 18 /* FALSE4 */;
1863
1993
  else
1864
1994
  this._error(`Invalid false started with fal${c}`);
1865
1995
  continue;
1866
- case 18:
1996
+ case 18 /* FALSE4 */:
1867
1997
  if (c === Char.e) {
1868
1998
  this.emit("onvalue", false);
1869
- this.state = this.stack.pop() || 1;
1999
+ this.state = this.stack.pop() || 1 /* VALUE */;
1870
2000
  } else
1871
2001
  this._error(`Invalid false started with fals${c}`);
1872
2002
  continue;
1873
- case 19:
2003
+ case 19 /* NULL */:
1874
2004
  if (c === Char.u)
1875
- this.state = 20;
2005
+ this.state = 20 /* NULL2 */;
1876
2006
  else
1877
2007
  this._error(`Invalid null started with n${c}`);
1878
2008
  continue;
1879
- case 20:
2009
+ case 20 /* NULL2 */:
1880
2010
  if (c === Char.l)
1881
- this.state = 21;
2011
+ this.state = 21 /* NULL3 */;
1882
2012
  else
1883
2013
  this._error(`Invalid null started with nu${c}`);
1884
2014
  continue;
1885
- case 21:
2015
+ case 21 /* NULL3 */:
1886
2016
  if (c === Char.l) {
1887
2017
  this.emit("onvalue", null);
1888
- this.state = this.stack.pop() || 1;
2018
+ this.state = this.stack.pop() || 1 /* VALUE */;
1889
2019
  } else
1890
2020
  this._error(`Invalid null started with nul${c}`);
1891
2021
  continue;
1892
- case 22:
2022
+ case 22 /* NUMBER_DECIMAL_POINT */:
1893
2023
  if (c === Char.period) {
1894
2024
  this.numberNode += ".";
1895
- this.state = 23;
2025
+ this.state = 23 /* NUMBER_DIGIT */;
1896
2026
  } else
1897
2027
  this._error("Leading zero not followed by .");
1898
2028
  continue;
1899
- case 23:
2029
+ case 23 /* NUMBER_DIGIT */:
1900
2030
  if (Char._0 <= c && c <= Char._9)
1901
2031
  this.numberNode += String.fromCharCode(c);
1902
2032
  else if (c === Char.period) {
@@ -1914,7 +2044,7 @@
1914
2044
  } else {
1915
2045
  this._closeNumber();
1916
2046
  i--;
1917
- this.state = this.stack.pop() || 1;
2047
+ this.state = this.stack.pop() || 1 /* VALUE */;
1918
2048
  }
1919
2049
  continue;
1920
2050
  default:
@@ -2015,6 +2145,12 @@ Char: ${this.c}`;
2015
2145
  }
2016
2146
  return true;
2017
2147
  }
2148
+ /**
2149
+ * Sets the value pointed at by path
2150
+ * TODO - handle root path
2151
+ * @param object
2152
+ * @param value
2153
+ */
2018
2154
  setFieldAtPath(object, value) {
2019
2155
  const path = [...this.path];
2020
2156
  path.shift();
@@ -2024,6 +2160,11 @@ Char: ${this.c}`;
2024
2160
  }
2025
2161
  object[field] = value;
2026
2162
  }
2163
+ /**
2164
+ * Gets the value pointed at by path
2165
+ * TODO - handle root path
2166
+ * @param object
2167
+ */
2027
2168
  getFieldAtPath(object) {
2028
2169
  const path = [...this.path];
2029
2170
  path.shift();
@@ -2092,6 +2233,7 @@ Char: ${this.c}`;
2092
2233
  close() {
2093
2234
  this.parser.close();
2094
2235
  }
2236
+ // PRIVATE METHODS
2095
2237
  _pushOrSet(value) {
2096
2238
  const { container, key } = this.currentState;
2097
2239
  if (key !== null) {
@@ -2138,6 +2280,7 @@ Char: ${this.c}`;
2138
2280
  }
2139
2281
  this._openArray();
2140
2282
  },
2283
+ // Redefine onopenarray to inject value for top-level object
2141
2284
  onopenobject: (name) => {
2142
2285
  if (!this.topLevelObject) {
2143
2286
  this.topLevelObject = {};
@@ -2156,6 +2299,13 @@ Char: ${this.c}`;
2156
2299
  const jsonpaths = options.jsonpaths || [];
2157
2300
  this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));
2158
2301
  }
2302
+ /**
2303
+ * write REDEFINITION
2304
+ * - super.write() chunk to parser
2305
+ * - get the contents (so far) of "topmost-level" array as batch of rows
2306
+ * - clear top-level array
2307
+ * - return the batch of rows\
2308
+ */
2159
2309
  write(chunk) {
2160
2310
  super.write(chunk);
2161
2311
  let array = [];
@@ -2165,6 +2315,11 @@ Char: ${this.c}`;
2165
2315
  }
2166
2316
  return array;
2167
2317
  }
2318
+ /**
2319
+ * Returns a partially formed result object
2320
+ * Useful for returning the "wrapper" object when array is not top level
2321
+ * e.g. GeoJSON
2322
+ */
2168
2323
  getPartialResult() {
2169
2324
  return this.topLevelObject;
2170
2325
  }
@@ -2177,6 +2332,10 @@ Char: ${this.c}`;
2177
2332
  getJsonPath() {
2178
2333
  return this.jsonpath;
2179
2334
  }
2335
+ // PRIVATE METHODS
2336
+ /**
2337
+ * Checks is this.getJsonPath matches the jsonpaths provided in options
2338
+ */
2180
2339
  _matchJSONPath() {
2181
2340
  const currentPath = this.getJsonPath();
2182
2341
  if (this.jsonPaths.length === 0) {
@@ -2210,11 +2369,13 @@ Char: ${this.c}`;
2210
2369
  if (rows.length > 0 && isFirstChunk) {
2211
2370
  if (metadata) {
2212
2371
  const initialBatch = {
2372
+ // Common fields
2213
2373
  shape,
2214
2374
  batchType: "partial-result",
2215
2375
  data: [],
2216
2376
  length: 0,
2217
2377
  bytesUsed: 0,
2378
+ // JSON additions
2218
2379
  container: parser.getPartialResult(),
2219
2380
  jsonpath: jsonpath2
2220
2381
  };
@@ -2248,13 +2409,14 @@ Char: ${this.c}`;
2248
2409
  jsonpath: parser.getStreamingJsonPathAsString(),
2249
2410
  data: [],
2250
2411
  length: 0
2412
+ // schema: null
2251
2413
  };
2252
2414
  yield finalBatch;
2253
2415
  }
2254
2416
  }
2255
2417
 
2256
2418
  // src/geojson-loader.ts
2257
- var VERSION = true ? "4.0.0-beta.2" : "latest";
2419
+ var VERSION = true ? "4.0.0-beta.3" : "latest";
2258
2420
  var GeoJSONWorkerLoader = {
2259
2421
  name: "GeoJSON",
2260
2422
  id: "geojson",
@@ -2280,7 +2442,9 @@ Char: ${this.c}`;
2280
2442
  };
2281
2443
  var GeoJSONLoader = {
2282
2444
  ...GeoJSONWorkerLoader,
2445
+ // @ts-expect-error
2283
2446
  parse,
2447
+ // @ts-expect-error
2284
2448
  parseTextSync,
2285
2449
  parseInBatches
2286
2450
  };
@@ -2299,6 +2463,8 @@ Char: ${this.c}`;
2299
2463
  }
2300
2464
  const table = {
2301
2465
  shape: "geojson-table",
2466
+ // TODO - deduce schema from geojson
2467
+ // TODO check that parsed data is of type FeatureCollection
2302
2468
  type: "FeatureCollection",
2303
2469
  features: geojson?.features || []
2304
2470
  };