@loaders.gl/json 3.1.0-beta.7 → 3.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.js +5 -1845
- package/dist/dist.min.js +2543 -0
- package/dist/es5/bundle.js +1 -1
- package/dist/es5/bundle.js.map +1 -1
- package/dist/es5/geojson-loader.js +143 -29
- package/dist/es5/geojson-loader.js.map +1 -1
- package/dist/es5/index.js +14 -6
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/json-loader.js +44 -18
- package/dist/es5/json-loader.js.map +1 -1
- package/dist/es5/lib/clarinet/clarinet.js +359 -335
- package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
- package/dist/es5/lib/jsonpath/jsonpath.js +101 -54
- package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -1
- package/dist/es5/lib/parse-json-in-batches.js +251 -72
- package/dist/es5/lib/parse-json-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-json.js +9 -4
- package/dist/es5/lib/parse-json.js.map +1 -1
- package/dist/es5/lib/parse-ndjson-in-batches.js +143 -31
- package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -1
- package/dist/es5/lib/parse-ndjson.js +2 -2
- package/dist/es5/lib/parse-ndjson.js.map +1 -1
- package/dist/es5/lib/parser/json-parser.js +117 -95
- package/dist/es5/lib/parser/json-parser.js.map +1 -1
- package/dist/es5/lib/parser/streaming-json-parser.js +115 -59
- package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
- package/dist/es5/ndjson-loader.js +30 -8
- package/dist/es5/ndjson-loader.js.map +1 -1
- package/dist/esm/geojson-loader.js +1 -1
- package/dist/esm/geojson-loader.js.map +1 -1
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/json-loader.js +1 -1
- package/dist/esm/json-loader.js.map +1 -1
- package/dist/esm/lib/parse-json-in-batches.js +18 -1
- package/dist/esm/lib/parse-json-in-batches.js.map +1 -1
- package/dist/esm/ndjson-loader.js +1 -1
- package/dist/esm/ndjson-loader.js.map +1 -1
- package/dist/geojson-worker.js +777 -182
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -1
- package/dist/lib/parse-json-in-batches.d.ts +1 -0
- package/dist/lib/parse-json-in-batches.d.ts.map +1 -1
- package/dist/lib/parse-json-in-batches.js +20 -0
- package/package.json +6 -6
- package/src/index.ts +2 -0
- package/src/lib/parse-json-in-batches.ts +23 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,4 +5,5 @@ export type { GeoJSONLoaderOptions as _GeoJSONLoaderOptions } from './geojson-lo
|
|
|
5
5
|
export { GeoJSONLoader as _GeoJSONLoader, GeoJSONWorkerLoader as _GeoJSONWorkerLoader } from './geojson-loader';
|
|
6
6
|
export { default as _JSONPath } from './lib/jsonpath/jsonpath';
|
|
7
7
|
export { default as _ClarinetParser } from './lib/clarinet/clarinet';
|
|
8
|
+
export { rebuildJsonObject as _rebuildJsonObject } from './lib/parse-json-in-batches';
|
|
8
9
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C,YAAY,EAAC,oBAAoB,IAAI,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,yBAAyB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EAAC,iBAAiB,EAAC,MAAM,eAAe,CAAC;AACrD,OAAO,EAAC,UAAU,EAAC,MAAM,eAAe,CAAC;AACzC,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAG7C,YAAY,EAAC,oBAAoB,IAAI,qBAAqB,EAAC,MAAM,kBAAkB,CAAC;AACpF,OAAO,EACL,aAAa,IAAI,cAAc,EAC/B,mBAAmB,IAAI,oBAAoB,EAC5C,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAC,OAAO,IAAI,SAAS,EAAC,MAAM,yBAAyB,CAAC;AAC7D,OAAO,EAAC,OAAO,IAAI,eAAe,EAAC,MAAM,yBAAyB,CAAC;AAEnE,OAAO,EAAC,iBAAiB,IAAI,kBAAkB,EAAC,MAAM,6BAA6B,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,7 +3,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports._ClarinetParser = exports._JSONPath = exports._GeoJSONWorkerLoader = exports._GeoJSONLoader = exports.NDJSONLoader = exports.JSONLoader = void 0;
|
|
6
|
+
exports._rebuildJsonObject = exports._ClarinetParser = exports._JSONPath = exports._GeoJSONWorkerLoader = exports._GeoJSONLoader = exports.NDJSONLoader = exports.JSONLoader = void 0;
|
|
7
7
|
var json_loader_1 = require("./json-loader");
|
|
8
8
|
Object.defineProperty(exports, "JSONLoader", { enumerable: true, get: function () { return json_loader_1.JSONLoader; } });
|
|
9
9
|
var ndjson_loader_1 = require("./ndjson-loader");
|
|
@@ -15,3 +15,5 @@ var jsonpath_1 = require("./lib/jsonpath/jsonpath");
|
|
|
15
15
|
Object.defineProperty(exports, "_JSONPath", { enumerable: true, get: function () { return __importDefault(jsonpath_1).default; } });
|
|
16
16
|
var clarinet_1 = require("./lib/clarinet/clarinet");
|
|
17
17
|
Object.defineProperty(exports, "_ClarinetParser", { enumerable: true, get: function () { return __importDefault(clarinet_1).default; } });
|
|
18
|
+
var parse_json_in_batches_1 = require("./lib/parse-json-in-batches");
|
|
19
|
+
Object.defineProperty(exports, "_rebuildJsonObject", { enumerable: true, get: function () { return parse_json_in_batches_1.rebuildJsonObject; } });
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { Batch } from '@loaders.gl/schema';
|
|
2
2
|
import type { JSONLoaderOptions } from '../json-loader';
|
|
3
3
|
export default function parseJSONInBatches(binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options: JSONLoaderOptions): AsyncIterable<Batch>;
|
|
4
|
+
export declare function rebuildJsonObject(batch: any, data: any): any;
|
|
4
5
|
//# sourceMappingURL=parse-json-in-batches.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"parse-json-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-json-in-batches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"parse-json-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-json-in-batches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAC9C,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAQtD,wBAA+B,kBAAkB,CAC/C,mBAAmB,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACvE,OAAO,EAAE,iBAAiB,GACzB,aAAa,CAAC,KAAK,CAAC,CA+EtB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,KAAA,EAAE,IAAI,KAAA,OAmB5C"}
|
|
@@ -3,9 +3,11 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
3
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.rebuildJsonObject = void 0;
|
|
6
7
|
const schema_1 = require("@loaders.gl/schema");
|
|
7
8
|
const loader_utils_1 = require("@loaders.gl/loader-utils");
|
|
8
9
|
const streaming_json_parser_1 = __importDefault(require("./parser/streaming-json-parser"));
|
|
10
|
+
const jsonpath_1 = __importDefault(require("./jsonpath/jsonpath"));
|
|
9
11
|
// TODO - support batch size 0 = no batching/single batch?
|
|
10
12
|
// eslint-disable-next-line max-statements, complexity
|
|
11
13
|
async function* parseJSONInBatches(binaryAsyncIterator, options) {
|
|
@@ -78,3 +80,21 @@ async function* parseJSONInBatches(binaryAsyncIterator, options) {
|
|
|
78
80
|
}
|
|
79
81
|
}
|
|
80
82
|
exports.default = parseJSONInBatches;
|
|
83
|
+
function rebuildJsonObject(batch, data) {
|
|
84
|
+
// Last batch will have this special type and will provide all the root object of the parsed file
|
|
85
|
+
(0, loader_utils_1.assert)(batch.batchType === 'final-result');
|
|
86
|
+
// The streamed JSON data is a top level array (jsonpath = '$'), just return the array of row objects
|
|
87
|
+
if (batch.jsonpath === '$') {
|
|
88
|
+
return data;
|
|
89
|
+
}
|
|
90
|
+
// (jsonpath !== '$') The streamed data is not a top level array, so stitch it back in to the top-level object
|
|
91
|
+
if (batch.jsonpath && batch.jsonpath.length > 1) {
|
|
92
|
+
const topLevelObject = batch.container;
|
|
93
|
+
const streamingPath = new jsonpath_1.default(batch.jsonpath);
|
|
94
|
+
streamingPath.setFieldAtPath(topLevelObject, data);
|
|
95
|
+
return topLevelObject;
|
|
96
|
+
}
|
|
97
|
+
// No jsonpath, in this case nothing was streamed.
|
|
98
|
+
return batch.container;
|
|
99
|
+
}
|
|
100
|
+
exports.rebuildJsonObject = rebuildJsonObject;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/json",
|
|
3
|
-
"version": "3.1.
|
|
3
|
+
"version": "3.1.3",
|
|
4
4
|
"description": "Framework-independent loader for JSON and streaming JSON formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"publishConfig": {
|
|
@@ -31,13 +31,13 @@
|
|
|
31
31
|
],
|
|
32
32
|
"scripts": {
|
|
33
33
|
"pre-build": "npm run build-bundle && npm run build-worker",
|
|
34
|
-
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/
|
|
34
|
+
"build-bundle": "esbuild src/bundle.ts --bundle --outfile=dist/dist.min.js",
|
|
35
35
|
"build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js"
|
|
36
36
|
},
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@loaders.gl/gis": "3.1.
|
|
39
|
-
"@loaders.gl/loader-utils": "3.1.
|
|
40
|
-
"@loaders.gl/schema": "3.1.
|
|
38
|
+
"@loaders.gl/gis": "3.1.3",
|
|
39
|
+
"@loaders.gl/loader-utils": "3.1.3",
|
|
40
|
+
"@loaders.gl/schema": "3.1.3"
|
|
41
41
|
},
|
|
42
|
-
"gitHead": "
|
|
42
|
+
"gitHead": "4a690c369779346d73c9a27395d1c08d77d279a4"
|
|
43
43
|
}
|
package/src/index.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type {Batch} from '@loaders.gl/schema';
|
|
2
2
|
import type {JSONLoaderOptions} from '../json-loader';
|
|
3
3
|
import {TableBatchBuilder} from '@loaders.gl/schema';
|
|
4
|
-
import {makeTextDecoderIterator} from '@loaders.gl/loader-utils';
|
|
4
|
+
import {assert, makeTextDecoderIterator} from '@loaders.gl/loader-utils';
|
|
5
5
|
import StreamingJSONParser from './parser/streaming-json-parser';
|
|
6
|
+
import JSONPath from './jsonpath/jsonpath';
|
|
6
7
|
|
|
7
8
|
// TODO - support batch size 0 = no batching/single batch?
|
|
8
9
|
// eslint-disable-next-line max-statements, complexity
|
|
@@ -89,3 +90,24 @@ export default async function* parseJSONInBatches(
|
|
|
89
90
|
yield finalBatch;
|
|
90
91
|
}
|
|
91
92
|
}
|
|
93
|
+
|
|
94
|
+
export function rebuildJsonObject(batch, data) {
|
|
95
|
+
// Last batch will have this special type and will provide all the root object of the parsed file
|
|
96
|
+
assert(batch.batchType === 'final-result');
|
|
97
|
+
|
|
98
|
+
// The streamed JSON data is a top level array (jsonpath = '$'), just return the array of row objects
|
|
99
|
+
if (batch.jsonpath === '$') {
|
|
100
|
+
return data;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
// (jsonpath !== '$') The streamed data is not a top level array, so stitch it back in to the top-level object
|
|
104
|
+
if (batch.jsonpath && batch.jsonpath.length > 1) {
|
|
105
|
+
const topLevelObject = batch.container;
|
|
106
|
+
const streamingPath = new JSONPath(batch.jsonpath);
|
|
107
|
+
streamingPath.setFieldAtPath(topLevelObject, data);
|
|
108
|
+
return topLevelObject;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// No jsonpath, in this case nothing was streamed.
|
|
112
|
+
return batch.container;
|
|
113
|
+
}
|