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

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/dist.dev.js CHANGED
@@ -240,7 +240,6 @@ var __exports__ = (() => {
240
240
  };
241
241
  return batch;
242
242
  }
243
- // HELPERS
244
243
  _reallocateColumns() {
245
244
  if (this.length < this.allocated) {
246
245
  return;
@@ -304,7 +303,6 @@ var __exports__ = (() => {
304
303
  }
305
304
  return false;
306
305
  }
307
- /** @deprecated Use addArrayRow or addObjectRow */
308
306
  addRow(row) {
309
307
  if (this.limitReached()) {
310
308
  return;
@@ -318,7 +316,6 @@ var __exports__ = (() => {
318
316
  this.addObjectRow(row);
319
317
  }
320
318
  }
321
- /** Add one row to the batch */
322
319
  addArrayRow(row) {
323
320
  if (!this.aggregator) {
324
321
  const TableBatchType = this._getTableBatchType();
@@ -326,7 +323,6 @@ var __exports__ = (() => {
326
323
  }
327
324
  this.aggregator.addArrayRow(row);
328
325
  }
329
- /** Add one row to the batch */
330
326
  addObjectRow(row) {
331
327
  if (!this.aggregator) {
332
328
  const TableBatchType = this._getTableBatchType();
@@ -334,7 +330,6 @@ var __exports__ = (() => {
334
330
  }
335
331
  this.aggregator.addObjectRow(row);
336
332
  }
337
- /** Mark an incoming raw memory chunk has completed */
338
333
  chunkComplete(chunk) {
339
334
  if (chunk instanceof ArrayBuffer) {
340
335
  this.bytesUsed += chunk.byteLength;
@@ -350,7 +345,6 @@ var __exports__ = (() => {
350
345
  getFinalBatch(options) {
351
346
  return this._getBatch(options);
352
347
  }
353
- // INTERNAL
354
348
  _estimateRowMB(row) {
355
349
  return Array.isArray(row) ? row.length * 8 : Object.keys(row).length * 8;
356
350
  }
@@ -372,9 +366,6 @@ var __exports__ = (() => {
372
366
  this.lastBatchEmittedMs = Date.now();
373
367
  return true;
374
368
  }
375
- /**
376
- * bytesUsed can be set via chunkComplete or via getBatch*
377
- */
378
369
  _getBatch(options) {
379
370
  if (!this.aggregator) {
380
371
  return null;
@@ -683,7 +674,6 @@ var __exports__ = (() => {
683
674
  name,
684
675
  type: type.type || "null",
685
676
  nullable: type.nullable
686
- // metadata: {}
687
677
  };
688
678
  }
689
679
  if (Array.isArray(column) && column.length > 0) {
@@ -693,7 +683,6 @@ var __exports__ = (() => {
693
683
  name,
694
684
  type,
695
685
  nullable: true
696
- // metadata: {},
697
686
  };
698
687
  }
699
688
  throw new Error("empty table");
@@ -704,7 +693,6 @@ var __exports__ = (() => {
704
693
  name,
705
694
  type,
706
695
  nullable: true
707
- // metadata: {}
708
696
  };
709
697
  }
710
698
 
@@ -876,7 +864,7 @@ var __exports__ = (() => {
876
864
 
877
865
  // src/lib/clarinet/clarinet.ts
878
866
  var MAX_BUFFER_LENGTH = Number.MAX_SAFE_INTEGER;
879
- var STATE = /* @__PURE__ */ function(STATE2) {
867
+ var STATE = function(STATE2) {
880
868
  STATE2[STATE2["BEGIN"] = 0] = "BEGIN";
881
869
  STATE2[STATE2["VALUE"] = 1] = "VALUE";
882
870
  STATE2[STATE2["OPEN_OBJECT"] = 2] = "OPEN_OBJECT";
@@ -905,61 +893,33 @@ var __exports__ = (() => {
905
893
  }(STATE || {});
906
894
  var Char = {
907
895
  tab: 9,
908
- // \t
909
896
  lineFeed: 10,
910
- // \n
911
897
  carriageReturn: 13,
912
- // \r
913
898
  space: 32,
914
- // " "
915
899
  doubleQuote: 34,
916
- // "
917
900
  plus: 43,
918
- // +
919
901
  comma: 44,
920
- // ,
921
902
  minus: 45,
922
- // -
923
903
  period: 46,
924
- // .
925
904
  _0: 48,
926
- // 0
927
905
  _9: 57,
928
- // 9
929
906
  colon: 58,
930
- // :
931
907
  E: 69,
932
- // E
933
908
  openBracket: 91,
934
- // [
935
909
  backslash: 92,
936
- // \
937
910
  closeBracket: 93,
938
- // ]
939
911
  a: 97,
940
- // a
941
912
  b: 98,
942
- // b
943
913
  e: 101,
944
- // e
945
914
  f: 102,
946
- // f
947
915
  l: 108,
948
- // l
949
916
  n: 110,
950
- // n
951
917
  r: 114,
952
- // r
953
918
  s: 115,
954
- // s
955
919
  t: 116,
956
- // t
957
920
  u: 117,
958
- // u
959
921
  openBrace: 123,
960
- // {
961
922
  closeBrace: 125
962
- // }
963
923
  };
964
924
  var stringTokenPattern = /[\\"\n]/g;
965
925
  var DEFAULT_OPTIONS2 = {
@@ -993,11 +953,9 @@ var __exports__ = (() => {
993
953
  closed = false;
994
954
  closedRoot = false;
995
955
  sawRoot = false;
996
- // tag = null;
997
956
  error = null;
998
957
  state = STATE.BEGIN;
999
958
  stack = [];
1000
- // mostly just for error reporting
1001
959
  position = 0;
1002
960
  column = 0;
1003
961
  line = 1;
@@ -1030,7 +988,6 @@ var __exports__ = (() => {
1030
988
  close() {
1031
989
  return this.write(null);
1032
990
  }
1033
- // protected
1034
991
  emit(event, data) {
1035
992
  this.options[event]?.(data, this);
1036
993
  }
@@ -1038,8 +995,6 @@ var __exports__ = (() => {
1038
995
  this._closeValue();
1039
996
  this.emit(event, data);
1040
997
  }
1041
- /* eslint-disable no-continue */
1042
- // eslint-disable-next-line complexity, max-statements
1043
998
  write(chunk) {
1044
999
  if (this.error) {
1045
1000
  throw this.error;
@@ -1446,12 +1401,6 @@ Char: ${this.c}`;
1446
1401
  }
1447
1402
  return true;
1448
1403
  }
1449
- /**
1450
- * Sets the value pointed at by path
1451
- * TODO - handle root path
1452
- * @param object
1453
- * @param value
1454
- */
1455
1404
  setFieldAtPath(object, value) {
1456
1405
  const path = [...this.path];
1457
1406
  path.shift();
@@ -1461,11 +1410,6 @@ Char: ${this.c}`;
1461
1410
  }
1462
1411
  object[field] = value;
1463
1412
  }
1464
- /**
1465
- * Gets the value pointed at by path
1466
- * TODO - handle root path
1467
- * @param object
1468
- */
1469
1413
  getFieldAtPath(object) {
1470
1414
  const path = [...this.path];
1471
1415
  path.shift();
@@ -1540,7 +1484,6 @@ Char: ${this.c}`;
1540
1484
  close() {
1541
1485
  this.parser.close();
1542
1486
  }
1543
- // PRIVATE METHODS
1544
1487
  _pushOrSet(value) {
1545
1488
  const {
1546
1489
  container,
@@ -1601,7 +1544,6 @@ Char: ${this.c}`;
1601
1544
  }
1602
1545
  this._openArray();
1603
1546
  },
1604
- // Redefine onopenarray to inject value for top-level object
1605
1547
  onopenobject: (name) => {
1606
1548
  if (!this.topLevelObject) {
1607
1549
  this.topLevelObject = {};
@@ -1617,13 +1559,6 @@ Char: ${this.c}`;
1617
1559
  const jsonpaths = options.jsonpaths || [];
1618
1560
  this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));
1619
1561
  }
1620
- /**
1621
- * write REDEFINITION
1622
- * - super.write() chunk to parser
1623
- * - get the contents (so far) of "topmost-level" array as batch of rows
1624
- * - clear top-level array
1625
- * - return the batch of rows\
1626
- */
1627
1562
  write(chunk) {
1628
1563
  super.write(chunk);
1629
1564
  let array = [];
@@ -1633,11 +1568,6 @@ Char: ${this.c}`;
1633
1568
  }
1634
1569
  return array;
1635
1570
  }
1636
- /**
1637
- * Returns a partially formed result object
1638
- * Useful for returning the "wrapper" object when array is not top level
1639
- * e.g. GeoJSON
1640
- */
1641
1571
  getPartialResult() {
1642
1572
  return this.topLevelObject;
1643
1573
  }
@@ -1650,10 +1580,6 @@ Char: ${this.c}`;
1650
1580
  getJsonPath() {
1651
1581
  return this.jsonpath;
1652
1582
  }
1653
- // PRIVATE METHODS
1654
- /**
1655
- * Checks is this.getJsonPath matches the jsonpaths provided in options
1656
- */
1657
1583
  _matchJSONPath() {
1658
1584
  const currentPath = this.getJsonPath();
1659
1585
  if (this.jsonPaths.length === 0) {
@@ -1693,13 +1619,11 @@ Char: ${this.c}`;
1693
1619
  if (rows.length > 0 && isFirstChunk) {
1694
1620
  if (metadata) {
1695
1621
  const initialBatch = {
1696
- // Common fields
1697
1622
  shape,
1698
1623
  batchType: "partial-result",
1699
1624
  data: [],
1700
1625
  length: 0,
1701
1626
  bytesUsed: 0,
1702
- // JSON additions
1703
1627
  container: parser.getPartialResult(),
1704
1628
  jsonpath: jsonpath2
1705
1629
  };
@@ -1739,7 +1663,6 @@ Char: ${this.c}`;
1739
1663
  jsonpath: parser.getStreamingJsonPathAsString(),
1740
1664
  data: [],
1741
1665
  length: 0
1742
- // schema: null
1743
1666
  };
1744
1667
  yield finalBatch;
1745
1668
  }
@@ -1765,7 +1688,6 @@ Char: ${this.c}`;
1765
1688
  shape: "object-row-table",
1766
1689
  table: false,
1767
1690
  jsonpaths: []
1768
- // batchSize: 'auto'
1769
1691
  }
1770
1692
  };
1771
1693
  var JSONLoader = {
@@ -1860,12 +1782,7 @@ Char: ${this.c}`;
1860
1782
  module: "json",
1861
1783
  version: VERSION2,
1862
1784
  extensions: ["ndjson", "jsonl"],
1863
- mimeTypes: [
1864
- "application/x-ndjson",
1865
- "application/jsonlines",
1866
- // https://docs.aws.amazon.com/sagemaker/latest/dg/cdf-inference.html#cm-batch
1867
- "application/json-seq"
1868
- ],
1785
+ mimeTypes: ["application/x-ndjson", "application/jsonlines", "application/json-seq"],
1869
1786
  category: "table",
1870
1787
  text: true,
1871
1788
  parse: async (arrayBuffer) => parseNDJSONSync(new TextDecoder().decode(arrayBuffer)),
@@ -2588,10 +2505,7 @@ Char: ${this.c}`;
2588
2505
  const nextIndices = geometry.indices[l + 1];
2589
2506
  for (let i = 0, il = indices.length; i < il; ++i) {
2590
2507
  const start = indices[i];
2591
- const end = i === il - 1 ? (
2592
- // last line, so either read to:
2593
- nextIndices === void 0 ? geometry.data.length : nextIndices[0]
2594
- ) : indices[i + 1];
2508
+ const end = i === il - 1 ? nextIndices === void 0 ? geometry.data.length : nextIndices[0] : indices[i + 1];
2595
2509
  polygons.primitivePolygonIndices[indexMap.polygonRing++] = indexMap.polygonPosition;
2596
2510
  indexMap.polygonPosition += (end - start) / coordLength;
2597
2511
  }
@@ -2693,7 +2607,6 @@ Char: ${this.c}`;
2693
2607
  },
2694
2608
  numericProps: wrapProps(polygons.numericProps, 1)
2695
2609
  }
2696
- // triangles not expected
2697
2610
  };
2698
2611
  if (binaryFeatures.polygons && polygons.triangles) {
2699
2612
  binaryFeatures.polygons.triangles = {
@@ -2956,9 +2869,7 @@ Char: ${this.c}`;
2956
2869
  };
2957
2870
  var GeoJSONLoader = {
2958
2871
  ...GeoJSONWorkerLoader,
2959
- // @ts-expect-error
2960
2872
  parse: parse2,
2961
- // @ts-expect-error
2962
2873
  parseTextSync: parseTextSync2,
2963
2874
  parseInBatches: parseInBatches2
2964
2875
  };
@@ -2983,8 +2894,6 @@ Char: ${this.c}`;
2983
2894
  }
2984
2895
  const table = {
2985
2896
  shape: "geojson-table",
2986
- // TODO - deduce schema from geojson
2987
- // TODO check that parsed data is of type FeatureCollection
2988
2897
  type: "FeatureCollection",
2989
2898
  features: geojson?.features || []
2990
2899
  };
@@ -2416,7 +2416,7 @@ Char: ${this.c}`;
2416
2416
  }
2417
2417
 
2418
2418
  // src/geojson-loader.ts
2419
- var VERSION = true ? "4.0.0-beta.3" : "latest";
2419
+ var VERSION = true ? "4.0.0-beta.5" : "latest";
2420
2420
  var GeoJSONWorkerLoader = {
2421
2421
  name: "GeoJSON",
2422
2422
  id: "geojson",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/json",
3
- "version": "4.0.0-beta.3",
3
+ "version": "4.0.0-beta.5",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -43,9 +43,9 @@
43
43
  "build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
44
44
  },
45
45
  "dependencies": {
46
- "@loaders.gl/gis": "4.0.0-beta.3",
47
- "@loaders.gl/loader-utils": "4.0.0-beta.3",
48
- "@loaders.gl/schema": "4.0.0-beta.3"
46
+ "@loaders.gl/gis": "4.0.0-beta.5",
47
+ "@loaders.gl/loader-utils": "4.0.0-beta.5",
48
+ "@loaders.gl/schema": "4.0.0-beta.5"
49
49
  },
50
- "gitHead": "7ba9621cc51c7a26c407086ac86171f35b8712af"
50
+ "gitHead": "a6f5a0d1a316cc22396e5a4d480c14329d1ef146"
51
51
  }