@loaders.gl/json 3.1.0-alpha.5 → 3.1.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.
Files changed (79) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +1839 -0
  4. package/dist/es5/geojson-loader.js +1 -1
  5. package/dist/es5/geojson-loader.js.map +1 -1
  6. package/dist/es5/json-loader.js +1 -1
  7. package/dist/es5/json-loader.js.map +1 -1
  8. package/dist/es5/lib/clarinet/clarinet.js +226 -281
  9. package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
  10. package/dist/es5/lib/parser/json-parser.js +45 -47
  11. package/dist/es5/lib/parser/json-parser.js.map +1 -1
  12. package/dist/es5/lib/parser/streaming-json-parser.js +29 -34
  13. package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
  14. package/dist/es5/ndjson-loader.js +5 -2
  15. package/dist/es5/ndjson-loader.js.map +1 -1
  16. package/dist/esm/geojson-loader.js +1 -1
  17. package/dist/esm/geojson-loader.js.map +1 -1
  18. package/dist/esm/json-loader.js +1 -1
  19. package/dist/esm/json-loader.js.map +1 -1
  20. package/dist/esm/lib/clarinet/clarinet.js +222 -260
  21. package/dist/esm/lib/clarinet/clarinet.js.map +1 -1
  22. package/dist/esm/lib/parser/json-parser.js +48 -47
  23. package/dist/esm/lib/parser/json-parser.js.map +1 -1
  24. package/dist/esm/lib/parser/streaming-json-parser.js +29 -34
  25. package/dist/esm/lib/parser/streaming-json-parser.js.map +1 -1
  26. package/dist/esm/ndjson-loader.js +3 -1
  27. package/dist/esm/ndjson-loader.js.map +1 -1
  28. package/dist/geojson-loader.d.ts +1 -0
  29. package/dist/geojson-loader.d.ts.map +1 -0
  30. package/dist/geojson-loader.js +78 -0
  31. package/dist/geojson-worker.js +1702 -2
  32. package/dist/index.d.ts +1 -0
  33. package/dist/index.d.ts.map +1 -0
  34. package/dist/index.js +17 -0
  35. package/dist/json-loader.d.ts +1 -0
  36. package/dist/json-loader.d.ts.map +1 -0
  37. package/dist/json-loader.js +57 -0
  38. package/dist/jsonl-loader.d.ts +1 -0
  39. package/dist/jsonl-loader.d.ts.map +1 -0
  40. package/dist/jsonl-loader.js +54 -0
  41. package/dist/lib/clarinet/clarinet.d.ts +72 -38
  42. package/dist/lib/clarinet/clarinet.d.ts.map +1 -0
  43. package/dist/lib/clarinet/clarinet.js +535 -0
  44. package/dist/lib/jsonpath/jsonpath.d.ts +1 -0
  45. package/dist/lib/jsonpath/jsonpath.d.ts.map +1 -0
  46. package/dist/lib/jsonpath/jsonpath.js +89 -0
  47. package/dist/lib/parse-json-in-batches.d.ts +1 -0
  48. package/dist/lib/parse-json-in-batches.d.ts.map +1 -0
  49. package/dist/lib/parse-json-in-batches.js +80 -0
  50. package/dist/lib/parse-json.d.ts +1 -0
  51. package/dist/lib/parse-json.d.ts.map +1 -0
  52. package/dist/lib/parse-json.js +29 -0
  53. package/dist/lib/parse-ndjson-in-batches.d.ts +1 -0
  54. package/dist/lib/parse-ndjson-in-batches.d.ts.map +1 -0
  55. package/dist/lib/parse-ndjson-in-batches.js +35 -0
  56. package/dist/lib/parse-ndjson.d.ts +1 -0
  57. package/dist/lib/parse-ndjson.d.ts.map +1 -0
  58. package/dist/lib/parse-ndjson.js +14 -0
  59. package/dist/lib/parser/json-parser.d.ts +10 -5
  60. package/dist/lib/parser/json-parser.d.ts.map +1 -0
  61. package/dist/lib/parser/json-parser.js +98 -0
  62. package/dist/lib/parser/streaming-json-parser.d.ts +1 -1
  63. package/dist/lib/parser/streaming-json-parser.d.ts.map +1 -0
  64. package/dist/lib/parser/streaming-json-parser.js +100 -0
  65. package/dist/ndjson-loader.d.ts +22 -2
  66. package/dist/ndjson-loader.d.ts.map +1 -0
  67. package/dist/ndjson-loader.js +35 -0
  68. package/dist/workers/geojson-worker.d.ts +1 -0
  69. package/dist/workers/geojson-worker.d.ts.map +1 -0
  70. package/dist/workers/geojson-worker.js +5 -0
  71. package/package.json +7 -8
  72. package/src/lib/clarinet/clarinet.ts +539 -0
  73. package/src/lib/parser/json-parser.ts +52 -55
  74. package/src/lib/parser/streaming-json-parser.ts +28 -32
  75. package/src/ndjson-loader.ts +3 -1
  76. package/dist/dist.min.js +0 -2
  77. package/dist/dist.min.js.map +0 -1
  78. package/dist/geojson-worker.js.map +0 -1
  79. package/src/lib/clarinet/clarinet.js +0 -578
@@ -0,0 +1,80 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const schema_1 = require("@loaders.gl/schema");
7
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
8
+ const streaming_json_parser_1 = __importDefault(require("./parser/streaming-json-parser"));
9
+ // TODO - support batch size 0 = no batching/single batch?
10
+ // eslint-disable-next-line max-statements, complexity
11
+ async function* parseJSONInBatches(binaryAsyncIterator, options) {
12
+ const asyncIterator = (0, loader_utils_1.makeTextDecoderIterator)(binaryAsyncIterator);
13
+ const { metadata } = options;
14
+ const { jsonpaths } = options.json || {};
15
+ let isFirstChunk = true;
16
+ // TODO fix Schema deduction
17
+ const schema = null; // new Schema([]);
18
+ const shape = options?.json?.shape || 'row-table';
19
+ // @ts-ignore
20
+ const tableBatchBuilder = new schema_1.TableBatchBuilder(schema, {
21
+ ...options,
22
+ shape
23
+ });
24
+ const parser = new streaming_json_parser_1.default({ jsonpaths });
25
+ for await (const chunk of asyncIterator) {
26
+ const rows = parser.write(chunk);
27
+ const jsonpath = rows.length > 0 && parser.getStreamingJsonPathAsString();
28
+ if (rows.length > 0 && isFirstChunk) {
29
+ if (metadata) {
30
+ const initialBatch = {
31
+ // Common fields
32
+ shape,
33
+ batchType: 'partial-result',
34
+ data: [],
35
+ length: 0,
36
+ bytesUsed: 0,
37
+ // JSON additions
38
+ container: parser.getPartialResult(),
39
+ jsonpath
40
+ };
41
+ yield initialBatch;
42
+ }
43
+ isFirstChunk = false;
44
+ // schema = deduceSchema(rows);
45
+ }
46
+ // Add the row
47
+ for (const row of rows) {
48
+ tableBatchBuilder.addRow(row);
49
+ // If a batch has been completed, emit it
50
+ const batch = tableBatchBuilder.getFullBatch({ jsonpath });
51
+ if (batch) {
52
+ yield batch;
53
+ }
54
+ }
55
+ tableBatchBuilder.chunkComplete(chunk);
56
+ const batch = tableBatchBuilder.getFullBatch({ jsonpath });
57
+ if (batch) {
58
+ yield batch;
59
+ }
60
+ }
61
+ // yield final batch
62
+ const jsonpath = parser.getStreamingJsonPathAsString();
63
+ const batch = tableBatchBuilder.getFinalBatch({ jsonpath });
64
+ if (batch) {
65
+ yield batch;
66
+ }
67
+ if (metadata) {
68
+ const finalBatch = {
69
+ shape,
70
+ batchType: 'final-result',
71
+ container: parser.getPartialResult(),
72
+ jsonpath: parser.getStreamingJsonPathAsString(),
73
+ data: [],
74
+ length: 0
75
+ // schema: null
76
+ };
77
+ yield finalBatch;
78
+ }
79
+ }
80
+ exports.default = parseJSONInBatches;
@@ -1,2 +1,3 @@
1
1
  import type { JSONLoaderOptions } from '../json-loader';
2
2
  export default function parseJSONSync(jsonText: string, options: JSONLoaderOptions): any;
3
+ //# sourceMappingURL=parse-json.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["../../src/lib/parse-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,OAUjF"}
@@ -0,0 +1,29 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function parseJSONSync(jsonText, options) {
4
+ try {
5
+ const json = JSON.parse(jsonText);
6
+ if (options.json?.table) {
7
+ return getFirstArray(json) || json;
8
+ }
9
+ return json;
10
+ }
11
+ catch (error) {
12
+ throw new Error('JSONLoader: failed to parse JSON');
13
+ }
14
+ }
15
+ exports.default = parseJSONSync;
16
+ function getFirstArray(json) {
17
+ if (Array.isArray(json)) {
18
+ return json;
19
+ }
20
+ if (json && typeof json === 'object') {
21
+ for (const value of Object.values(json)) {
22
+ const array = getFirstArray(value);
23
+ if (array) {
24
+ return array;
25
+ }
26
+ }
27
+ }
28
+ return null;
29
+ }
@@ -1,3 +1,4 @@
1
1
  import type { Batch } from '@loaders.gl/schema';
2
2
  import { LoaderOptions } from '@loaders.gl/loader-utils';
3
3
  export default function parseNDJSONInBatches(binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: LoaderOptions): AsyncIterable<Batch>;
4
+ //# sourceMappingURL=parse-ndjson-in-batches.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-ndjson-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ndjson-in-batches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EACL,aAAa,EAId,MAAM,0BAA0B,CAAC;AAElC,wBAA+B,oBAAoB,CACjD,mBAAmB,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa,CAAC,KAAK,CAAC,CA+BtB"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const schema_1 = require("@loaders.gl/schema");
4
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
5
+ async function* parseNDJSONInBatches(binaryAsyncIterator, options) {
6
+ const textIterator = (0, loader_utils_1.makeTextDecoderIterator)(binaryAsyncIterator);
7
+ const lineIterator = (0, loader_utils_1.makeLineIterator)(textIterator);
8
+ const numberedLineIterator = (0, loader_utils_1.makeNumberedLineIterator)(lineIterator);
9
+ const schema = null;
10
+ const shape = 'row-table';
11
+ // @ts-ignore
12
+ const tableBatchBuilder = new schema_1.TableBatchBuilder(schema, {
13
+ ...options,
14
+ shape
15
+ });
16
+ for await (const { counter, line } of numberedLineIterator) {
17
+ try {
18
+ const row = JSON.parse(line);
19
+ tableBatchBuilder.addRow(row);
20
+ tableBatchBuilder.chunkComplete(line);
21
+ const batch = tableBatchBuilder.getFullBatch();
22
+ if (batch) {
23
+ yield batch;
24
+ }
25
+ }
26
+ catch (error) {
27
+ throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter}`);
28
+ }
29
+ }
30
+ const batch = tableBatchBuilder.getFinalBatch();
31
+ if (batch) {
32
+ yield batch;
33
+ }
34
+ }
35
+ exports.default = parseNDJSONInBatches;
@@ -1 +1,2 @@
1
1
  export default function parseNDJSONSync(ndjsonText: string): any[];
2
+ //# sourceMappingURL=parse-ndjson.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse-ndjson.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ndjson.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,UAAU,EAAE,MAAM,SASzD"}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ function parseNDJSONSync(ndjsonText) {
4
+ const lines = ndjsonText.trim().split('\n');
5
+ return lines.map((line, counter) => {
6
+ try {
7
+ return JSON.parse(line);
8
+ }
9
+ catch (error) {
10
+ throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);
11
+ }
12
+ });
13
+ }
14
+ exports.default = parseNDJSONSync;
@@ -1,9 +1,15 @@
1
- import ClarinetParser from '../clarinet/clarinet';
1
+ import ClarinetParser, { ClarinetParserOptions } from '../clarinet/clarinet';
2
2
  import JSONPath from '../jsonpath/jsonpath';
3
3
  export default class JSONParser {
4
+ readonly parser: ClarinetParser;
5
+ result: undefined;
6
+ previousStates: never[];
7
+ currentState: Readonly<{
8
+ container: never[];
9
+ key: null;
10
+ }>;
4
11
  jsonpath: JSONPath;
5
- _parser?: ClarinetParser;
6
- constructor();
12
+ constructor(options: ClarinetParserOptions);
7
13
  reset(): void;
8
14
  write(chunk: any): void;
9
15
  close(): void;
@@ -12,6 +18,5 @@ export default class JSONParser {
12
18
  _closeArray(): void;
13
19
  _openObject(newContainer?: {}): void;
14
20
  _closeObject(): void;
15
- _initializeParser(): void;
16
- protected get parser(): ClarinetParser;
17
21
  }
22
+ //# sourceMappingURL=json-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-parser.d.ts","sourceRoot":"","sources":["../../../src/lib/parser/json-parser.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,EAAE,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAC3E,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,MAAM,YAAa;IACnB,cAAc,UAAM;IACpB,YAAY;;;OAA6C;IACzD,QAAQ,EAAE,QAAQ,CAAkB;gBAExB,OAAO,EAAE,qBAAqB;IAiD1C,KAAK,IAAI,IAAI;IAOb,KAAK,CAAC,KAAK,KAAA,GAAG,IAAI;IAIlB,KAAK,IAAI,IAAI;IAMb,UAAU,CAAC,KAAK,KAAA,GAAG,IAAI;IAUvB,UAAU,CAAC,YAAY,UAAK,GAAG,IAAI;IAOnC,WAAW,IAAI,IAAI;IAKnB,WAAW,CAAC,YAAY,KAAK,GAAG,IAAI;IAOpC,YAAY,IAAI,IAAI;CAIrB"}
@@ -0,0 +1,98 @@
1
+ "use strict";
2
+ // @ts-nocheck
3
+ var __importDefault = (this && this.__importDefault) || function (mod) {
4
+ return (mod && mod.__esModule) ? mod : { "default": mod };
5
+ };
6
+ Object.defineProperty(exports, "__esModule", { value: true });
7
+ const clarinet_1 = __importDefault(require("../clarinet/clarinet"));
8
+ const jsonpath_1 = __importDefault(require("../jsonpath/jsonpath"));
9
+ // JSONParser builds a JSON object using the events emitted by the Clarinet parser
10
+ class JSONParser {
11
+ constructor(options) {
12
+ this.result = undefined;
13
+ this.previousStates = [];
14
+ this.currentState = Object.freeze({ container: [], key: null });
15
+ this.jsonpath = new jsonpath_1.default();
16
+ this.reset();
17
+ this.parser = new clarinet_1.default({
18
+ onready: () => {
19
+ this.jsonpath = new jsonpath_1.default();
20
+ this.previousStates.length = 0;
21
+ this.currentState.container.length = 0;
22
+ },
23
+ onopenobject: (name) => {
24
+ this._openObject({});
25
+ if (typeof name !== 'undefined') {
26
+ this.parser.emit('onkey', name);
27
+ }
28
+ },
29
+ onkey: (name) => {
30
+ this.jsonpath.set(name);
31
+ this.currentState.key = name;
32
+ },
33
+ oncloseobject: () => {
34
+ this._closeObject();
35
+ },
36
+ onopenarray: () => {
37
+ this._openArray();
38
+ },
39
+ onclosearray: () => {
40
+ this._closeArray();
41
+ },
42
+ onvalue: (value) => {
43
+ this._pushOrSet(value);
44
+ },
45
+ onerror: (error) => {
46
+ throw error;
47
+ },
48
+ onend: () => {
49
+ this.result = this.currentState.container.pop();
50
+ },
51
+ ...options
52
+ });
53
+ }
54
+ reset() {
55
+ this.result = undefined;
56
+ this.previousStates = [];
57
+ this.currentState = Object.freeze({ container: [], key: null });
58
+ this.jsonpath = new jsonpath_1.default();
59
+ }
60
+ write(chunk) {
61
+ this.parser.write(chunk);
62
+ }
63
+ close() {
64
+ this.parser.close();
65
+ }
66
+ // PRIVATE METHODS
67
+ _pushOrSet(value) {
68
+ const { container, key } = this.currentState;
69
+ if (key !== null) {
70
+ container[key] = value;
71
+ this.currentState.key = null;
72
+ }
73
+ else {
74
+ container.push(value);
75
+ }
76
+ }
77
+ _openArray(newContainer = []) {
78
+ this.jsonpath.push(null);
79
+ this._pushOrSet(newContainer);
80
+ this.previousStates.push(this.currentState);
81
+ this.currentState = { container: newContainer, isArray: true, key: null };
82
+ }
83
+ _closeArray() {
84
+ this.jsonpath.pop();
85
+ this.currentState = this.previousStates.pop();
86
+ }
87
+ _openObject(newContainer = {}) {
88
+ this.jsonpath.push(null);
89
+ this._pushOrSet(newContainer);
90
+ this.previousStates.push(this.currentState);
91
+ this.currentState = { container: newContainer, isArray: false, key: null };
92
+ }
93
+ _closeObject() {
94
+ this.jsonpath.pop();
95
+ this.currentState = this.previousStates.pop();
96
+ }
97
+ }
98
+ exports.default = JSONParser;
@@ -33,5 +33,5 @@ export default class StreamingJSONParser extends JSONParser {
33
33
  * Checks is this.getJsonPath matches the jsonpaths provided in options
34
34
  */
35
35
  _matchJSONPath(): boolean;
36
- _extendParser(): void;
37
36
  }
37
+ //# sourceMappingURL=streaming-json-parser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"streaming-json-parser.d.ts","sourceRoot":"","sources":["../../../src/lib/parser/streaming-json-parser.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,IAAI,UAAU,EAAC,MAAM,eAAe,CAAC;AACpD,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAE5C;;;GAGG;AACH,MAAM,CAAC,OAAO,OAAO,mBAAoB,SAAQ,UAAU;IACzD,OAAO,CAAC,SAAS,CAAa;IAC9B,OAAO,CAAC,iBAAiB,CAAyB;IAClD,OAAO,CAAC,cAAc,CAAsB;IAC5C,OAAO,CAAC,cAAc,CAAuB;gBAEjC,OAAO,GAAE;QAAC,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;KAAM;IAiC9C;;;;;;OAMG;IACH,KAAK,CAAC,KAAK,KAAA;IAUX;;;;OAIG;IACH,gBAAgB;IAIhB,oBAAoB;IAIpB,4BAA4B;IAI5B,WAAW;IAMX;;OAEG;IACH,cAAc;CAkBf"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ const json_parser_1 = __importDefault(require("./json-parser"));
7
+ const jsonpath_1 = __importDefault(require("../jsonpath/jsonpath"));
8
+ /**
9
+ * The `StreamingJSONParser` looks for the first array in the JSON structure.
10
+ * and emits an array of chunks
11
+ */
12
+ class StreamingJSONParser extends json_parser_1.default {
13
+ constructor(options = {}) {
14
+ super({
15
+ onopenarray: () => {
16
+ if (!this.streamingArray) {
17
+ if (this._matchJSONPath()) {
18
+ // @ts-ignore
19
+ this.streamingJsonPath = this.getJsonPath().clone();
20
+ this.streamingArray = [];
21
+ this._openArray(this.streamingArray);
22
+ return;
23
+ }
24
+ }
25
+ this._openArray();
26
+ },
27
+ // Redefine onopenarray to inject value for top-level object
28
+ onopenobject: (name) => {
29
+ if (!this.topLevelObject) {
30
+ this.topLevelObject = {};
31
+ this._openObject(this.topLevelObject);
32
+ }
33
+ else {
34
+ this._openObject({});
35
+ }
36
+ if (typeof name !== 'undefined') {
37
+ this.parser.emit('onkey', name);
38
+ }
39
+ }
40
+ });
41
+ this.streamingJsonPath = null;
42
+ this.streamingArray = null;
43
+ this.topLevelObject = null;
44
+ const jsonpaths = options.jsonpaths || [];
45
+ this.jsonPaths = jsonpaths.map((jsonpath) => new jsonpath_1.default(jsonpath));
46
+ }
47
+ /**
48
+ * write REDEFINITION
49
+ * - super.write() chunk to parser
50
+ * - get the contents (so far) of "topmost-level" array as batch of rows
51
+ * - clear top-level array
52
+ * - return the batch of rows\
53
+ */
54
+ write(chunk) {
55
+ super.write(chunk);
56
+ let array = [];
57
+ if (this.streamingArray) {
58
+ array = [...this.streamingArray];
59
+ this.streamingArray.length = 0;
60
+ }
61
+ return array;
62
+ }
63
+ /**
64
+ * Returns a partially formed result object
65
+ * Useful for returning the "wrapper" object when array is not top level
66
+ * e.g. GeoJSON
67
+ */
68
+ getPartialResult() {
69
+ return this.topLevelObject;
70
+ }
71
+ getStreamingJsonPath() {
72
+ return this.streamingJsonPath;
73
+ }
74
+ getStreamingJsonPathAsString() {
75
+ return this.streamingJsonPath && this.streamingJsonPath.toString();
76
+ }
77
+ getJsonPath() {
78
+ return this.jsonpath;
79
+ }
80
+ // PRIVATE METHODS
81
+ /**
82
+ * Checks is this.getJsonPath matches the jsonpaths provided in options
83
+ */
84
+ _matchJSONPath() {
85
+ const currentPath = this.getJsonPath();
86
+ // console.debug(`Testing JSONPath`, currentPath);
87
+ // Backwards compatibility, match any array
88
+ // TODO implement using wildcard once that is supported
89
+ if (this.jsonPaths.length === 0) {
90
+ return true;
91
+ }
92
+ for (const jsonPath of this.jsonPaths) {
93
+ if (jsonPath.equals(currentPath)) {
94
+ return true;
95
+ }
96
+ }
97
+ return false;
98
+ }
99
+ }
100
+ exports.default = StreamingJSONParser;
@@ -1,2 +1,22 @@
1
- import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
- export declare const NDJSONLoader: LoaderWithParser;
1
+ import type { Batch } from '@loaders.gl/schema';
2
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
3
+ export declare const NDJSONLoader: {
4
+ name: string;
5
+ id: string;
6
+ module: string;
7
+ version: any;
8
+ extensions: string[];
9
+ mimeTypes: string[];
10
+ category: string;
11
+ text: boolean;
12
+ parse: typeof parse;
13
+ parseTextSync: typeof parseTextSync;
14
+ parseInBatches: typeof parseInBatches;
15
+ options: {};
16
+ };
17
+ declare function parse(arrayBuffer: ArrayBuffer): Promise<any[]>;
18
+ declare function parseTextSync(text: string): any[];
19
+ declare function parseInBatches(asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: LoaderOptions): AsyncIterable<Batch>;
20
+ export declare const _typecheckNDJSONLoader: LoaderWithParser;
21
+ export {};
22
+ //# sourceMappingURL=ndjson-loader.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ndjson-loader.d.ts","sourceRoot":"","sources":["../src/ndjson-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAC,gBAAgB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAQ9E,eAAO,MAAM,YAAY;;;;;;;;;;;;;CAaxB,CAAC;AAEF,iBAAe,KAAK,CAAC,WAAW,EAAE,WAAW,kBAE5C;AAED,iBAAS,aAAa,CAAC,IAAI,EAAE,MAAM,SAElC;AAED,iBAAS,cAAc,CACrB,aAAa,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACjE,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa,CAAC,KAAK,CAAC,CAEtB;AAED,eAAO,MAAM,sBAAsB,EAAE,gBAA+B,CAAC"}
@@ -0,0 +1,35 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports._typecheckNDJSONLoader = exports.NDJSONLoader = void 0;
7
+ const parse_ndjson_1 = __importDefault(require("./lib/parse-ndjson"));
8
+ const parse_ndjson_in_batches_1 = __importDefault(require("./lib/parse-ndjson-in-batches"));
9
+ // __VERSION__ is injected by babel-plugin-version-inline
10
+ // @ts-ignore TS2304: Cannot find name '__VERSION__'.
11
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
12
+ exports.NDJSONLoader = {
13
+ name: 'NDJSON',
14
+ id: 'ndjson',
15
+ module: 'json',
16
+ version: VERSION,
17
+ extensions: ['ndjson'],
18
+ mimeTypes: ['application/x-ndjson'],
19
+ category: 'table',
20
+ text: true,
21
+ parse,
22
+ parseTextSync,
23
+ parseInBatches,
24
+ options: {}
25
+ };
26
+ async function parse(arrayBuffer) {
27
+ return parseTextSync(new TextDecoder().decode(arrayBuffer));
28
+ }
29
+ function parseTextSync(text) {
30
+ return (0, parse_ndjson_1.default)(text);
31
+ }
32
+ function parseInBatches(asyncIterator, options) {
33
+ return (0, parse_ndjson_in_batches_1.default)(asyncIterator, options);
34
+ }
35
+ exports._typecheckNDJSONLoader = exports.NDJSONLoader;
@@ -1 +1,2 @@
1
1
  export {};
2
+ //# sourceMappingURL=geojson-worker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"geojson-worker.d.ts","sourceRoot":"","sources":["../../src/workers/geojson-worker.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const loader_utils_1 = require("@loaders.gl/loader-utils");
4
+ const geojson_loader_1 = require("../geojson-loader");
5
+ (0, loader_utils_1.createLoaderWorker)(geojson_loader_1.GeoJSONLoader);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/json",
3
- "version": "3.1.0-alpha.5",
3
+ "version": "3.1.0-beta.5",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -31,14 +31,13 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "pre-build": "npm run build-bundle && npm run build-worker",
34
- "post-build": "tsc",
35
- "build-bundle": "webpack --config ../../scripts/webpack/bundle.js",
36
- "build-worker": "webpack --entry ./src/workers/geojson-worker.ts --output ./dist/geojson-worker.js --config ../../scripts/webpack/worker.js"
34
+ "build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/bundle.js",
35
+ "build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js"
37
36
  },
38
37
  "dependencies": {
39
- "@loaders.gl/gis": "3.1.0-alpha.5",
40
- "@loaders.gl/loader-utils": "3.1.0-alpha.5",
41
- "@loaders.gl/schema": "3.1.0-alpha.5"
38
+ "@loaders.gl/gis": "3.1.0-beta.5",
39
+ "@loaders.gl/loader-utils": "3.1.0-beta.5",
40
+ "@loaders.gl/schema": "3.1.0-beta.5"
42
41
  },
43
- "gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
42
+ "gitHead": "5d66468457cc878d2dbff3d7807d737ceb181c9a"
44
43
  }