@loaders.gl/json 3.1.3 → 4.0.0-alpha.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/bundle.js +2 -2
- package/dist/bundle.js.map +1 -0
- package/dist/geojson-loader.js +69 -66
- package/dist/geojson-loader.js.map +1 -0
- package/dist/geojson-worker.js +1 -1
- package/dist/index.js +7 -19
- package/dist/index.js.map +1 -0
- package/dist/json-loader.js +38 -48
- package/dist/json-loader.js.map +1 -0
- package/dist/jsonl-loader.js +1 -53
- package/dist/{es5/jsonl-loader.js.map → jsonl-loader.js.map} +0 -0
- package/dist/{es5/lib → lib}/clarinet/LICENSE +0 -0
- package/dist/lib/clarinet/clarinet.js +493 -510
- package/dist/lib/clarinet/clarinet.js.map +1 -0
- package/dist/lib/jsonpath/jsonpath.js +78 -81
- package/dist/lib/jsonpath/jsonpath.js.map +1 -0
- package/dist/lib/parse-json-in-batches.js +98 -94
- package/dist/lib/parse-json-in-batches.js.map +1 -0
- package/dist/lib/parse-json.js +29 -24
- package/dist/lib/parse-json.js.map +1 -0
- package/dist/lib/parse-ndjson-in-batches.js +34 -32
- package/dist/lib/parse-ndjson-in-batches.js.map +1 -0
- package/dist/lib/parse-ndjson.js +10 -13
- package/dist/lib/parse-ndjson.js.map +1 -0
- package/dist/lib/parser/json-parser.js +125 -95
- package/dist/lib/parser/json-parser.js.map +1 -0
- package/dist/lib/parser/streaming-json-parser.js +88 -95
- package/dist/lib/parser/streaming-json-parser.js.map +1 -0
- package/dist/ndjson-loader.js +25 -28
- package/dist/ndjson-loader.js.map +1 -0
- package/dist/workers/geojson-worker.js +4 -5
- package/dist/workers/geojson-worker.js.map +1 -0
- package/package.json +8 -8
- package/dist/es5/bundle.js +0 -7
- package/dist/es5/bundle.js.map +0 -1
- package/dist/es5/geojson-loader.js +0 -209
- package/dist/es5/geojson-loader.js.map +0 -1
- package/dist/es5/index.js +0 -62
- package/dist/es5/index.js.map +0 -1
- package/dist/es5/json-loader.js +0 -85
- package/dist/es5/json-loader.js.map +0 -1
- package/dist/es5/jsonl-loader.js +0 -2
- package/dist/es5/lib/clarinet/clarinet.js +0 -535
- package/dist/es5/lib/clarinet/clarinet.js.map +0 -1
- package/dist/es5/lib/jsonpath/jsonpath.js +0 -144
- package/dist/es5/lib/jsonpath/jsonpath.js.map +0 -1
- package/dist/es5/lib/parse-json-in-batches.js +0 -278
- package/dist/es5/lib/parse-json-in-batches.js.map +0 -1
- package/dist/es5/lib/parse-json.js +0 -46
- package/dist/es5/lib/parse-json.js.map +0 -1
- package/dist/es5/lib/parse-ndjson-in-batches.js +0 -158
- package/dist/es5/lib/parse-ndjson-in-batches.js.map +0 -1
- package/dist/es5/lib/parse-ndjson.js +0 -18
- package/dist/es5/lib/parse-ndjson.js.map +0 -1
- package/dist/es5/lib/parser/json-parser.js +0 -159
- package/dist/es5/lib/parser/json-parser.js.map +0 -1
- package/dist/es5/lib/parser/streaming-json-parser.js +0 -158
- package/dist/es5/lib/parser/streaming-json-parser.js.map +0 -1
- package/dist/es5/ndjson-loader.js +0 -67
- package/dist/es5/ndjson-loader.js.map +0 -1
- package/dist/es5/workers/geojson-worker.js +0 -8
- package/dist/es5/workers/geojson-worker.js.map +0 -1
- package/dist/esm/bundle.js +0 -5
- package/dist/esm/bundle.js.map +0 -1
- package/dist/esm/geojson-loader.js +0 -81
- package/dist/esm/geojson-loader.js.map +0 -1
- package/dist/esm/index.js +0 -7
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/json-loader.js +0 -47
- package/dist/esm/json-loader.js.map +0 -1
- package/dist/esm/jsonl-loader.js +0 -2
- package/dist/esm/jsonl-loader.js.map +0 -1
- package/dist/esm/lib/clarinet/LICENSE +0 -28
- package/dist/esm/lib/clarinet/clarinet.js +0 -518
- package/dist/esm/lib/clarinet/clarinet.js.map +0 -1
- package/dist/esm/lib/jsonpath/jsonpath.js +0 -86
- package/dist/esm/lib/jsonpath/jsonpath.js.map +0 -1
- package/dist/esm/lib/parse-json-in-batches.js +0 -104
- package/dist/esm/lib/parse-json-in-batches.js.map +0 -1
- package/dist/esm/lib/parse-json.js +0 -34
- package/dist/esm/lib/parse-json.js.map +0 -1
- package/dist/esm/lib/parse-ndjson-in-batches.js +0 -37
- package/dist/esm/lib/parse-ndjson-in-batches.js.map +0 -1
- package/dist/esm/lib/parse-ndjson.js +0 -11
- package/dist/esm/lib/parse-ndjson.js.map +0 -1
- package/dist/esm/lib/parser/json-parser.js +0 -128
- package/dist/esm/lib/parser/json-parser.js.map +0 -1
- package/dist/esm/lib/parser/streaming-json-parser.js +0 -93
- package/dist/esm/lib/parser/streaming-json-parser.js.map +0 -1
- package/dist/esm/ndjson-loader.js +0 -32
- package/dist/esm/ndjson-loader.js.map +0 -1
- package/dist/esm/workers/geojson-worker.js +0 -4
- package/dist/esm/workers/geojson-worker.js.map +0 -1
package/dist/bundle.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/bundle.ts"],"names":["moduleExports","require","globalThis","loaders","module","exports","Object","assign"],"mappings":"AACA,MAAMA,aAAa,GAAGC,OAAO,CAAC,SAAD,CAA7B;;AACAC,UAAU,CAACC,OAAX,GAAqBD,UAAU,CAACC,OAAX,IAAsB,EAA3C;AACAC,MAAM,CAACC,OAAP,GAAiBC,MAAM,CAACC,MAAP,CAAcL,UAAU,CAACC,OAAzB,EAAkCH,aAAlC,CAAjB","sourcesContent":["// @ts-nocheck\nconst moduleExports = require('./index');\nglobalThis.loaders = globalThis.loaders || {};\nmodule.exports = Object.assign(globalThis.loaders, moduleExports);\n"],"file":"bundle.js"}
|
package/dist/geojson-loader.js
CHANGED
|
@@ -1,78 +1,81 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.GeoJSONLoader = exports.GeoJSONWorkerLoader = void 0;
|
|
7
|
-
const gis_1 = require("@loaders.gl/gis");
|
|
8
|
-
const parse_json_1 = __importDefault(require("./lib/parse-json"));
|
|
9
|
-
const parse_json_in_batches_1 = __importDefault(require("./lib/parse-json-in-batches"));
|
|
10
|
-
// __VERSION__ is injected by babel-plugin-version-inline
|
|
11
|
-
// @ts-ignore TS2304: Cannot find name '__VERSION__'.
|
|
12
|
-
const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
|
|
1
|
+
import { geojsonToBinary } from '@loaders.gl/gis';
|
|
2
|
+
import parseJSONSync from './lib/parse-json';
|
|
3
|
+
import parseJSONInBatches from './lib/parse-json-in-batches';
|
|
4
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
13
5
|
const DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
6
|
+
geojson: {
|
|
7
|
+
shape: 'object-row-table'
|
|
8
|
+
},
|
|
9
|
+
json: {
|
|
10
|
+
jsonpaths: ['$', '$.features']
|
|
11
|
+
},
|
|
12
|
+
gis: {
|
|
13
|
+
format: 'geojson'
|
|
14
|
+
}
|
|
23
15
|
};
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
category: 'geometry',
|
|
36
|
-
text: true,
|
|
37
|
-
options: DEFAULT_GEOJSON_LOADER_OPTIONS
|
|
16
|
+
export const GeoJSONWorkerLoader = {
|
|
17
|
+
name: 'GeoJSON',
|
|
18
|
+
id: 'geojson',
|
|
19
|
+
module: 'geojson',
|
|
20
|
+
version: VERSION,
|
|
21
|
+
worker: true,
|
|
22
|
+
extensions: ['geojson'],
|
|
23
|
+
mimeTypes: ['application/geo+json'],
|
|
24
|
+
category: 'geometry',
|
|
25
|
+
text: true,
|
|
26
|
+
options: DEFAULT_GEOJSON_LOADER_OPTIONS
|
|
38
27
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
parseInBatches
|
|
28
|
+
export const GeoJSONLoader = { ...GeoJSONWorkerLoader,
|
|
29
|
+
parse,
|
|
30
|
+
parseTextSync,
|
|
31
|
+
parseInBatches
|
|
44
32
|
};
|
|
33
|
+
|
|
45
34
|
async function parse(arrayBuffer, options) {
|
|
46
|
-
|
|
35
|
+
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
47
36
|
}
|
|
37
|
+
|
|
48
38
|
function parseTextSync(text, options) {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
39
|
+
options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
|
|
40
|
+
...options
|
|
41
|
+
};
|
|
42
|
+
options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
|
|
43
|
+
...options.geojson
|
|
44
|
+
};
|
|
45
|
+
options.gis = options.gis || {};
|
|
46
|
+
const json = parseJSONSync(text, options);
|
|
47
|
+
|
|
48
|
+
switch (options.gis.format) {
|
|
49
|
+
case 'binary':
|
|
50
|
+
return geojsonToBinary(json);
|
|
51
|
+
|
|
52
|
+
default:
|
|
53
|
+
return json;
|
|
54
|
+
}
|
|
60
55
|
}
|
|
56
|
+
|
|
61
57
|
function parseInBatches(asyncIterator, options) {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
58
|
+
options = { ...DEFAULT_GEOJSON_LOADER_OPTIONS,
|
|
59
|
+
...options
|
|
60
|
+
};
|
|
61
|
+
options.json = { ...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson,
|
|
62
|
+
...options.geojson
|
|
63
|
+
};
|
|
64
|
+
const geojsonIterator = parseJSONInBatches(asyncIterator, options);
|
|
65
|
+
|
|
66
|
+
switch (options.gis.format) {
|
|
67
|
+
case 'binary':
|
|
68
|
+
return makeBinaryGeometryIterator(geojsonIterator);
|
|
69
|
+
|
|
70
|
+
default:
|
|
71
|
+
return geojsonIterator;
|
|
72
|
+
}
|
|
72
73
|
}
|
|
74
|
+
|
|
73
75
|
async function* makeBinaryGeometryIterator(geojsonIterator) {
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
for await (const batch of geojsonIterator) {
|
|
77
|
+
batch.data = geojsonToBinary(batch.data);
|
|
78
|
+
yield batch;
|
|
79
|
+
}
|
|
78
80
|
}
|
|
81
|
+
//# sourceMappingURL=geojson-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/geojson-loader.ts"],"names":["geojsonToBinary","parseJSONSync","parseJSONInBatches","VERSION","DEFAULT_GEOJSON_LOADER_OPTIONS","geojson","shape","json","jsonpaths","gis","format","GeoJSONWorkerLoader","name","id","module","version","worker","extensions","mimeTypes","category","text","options","GeoJSONLoader","parse","parseTextSync","parseInBatches","arrayBuffer","TextDecoder","decode","asyncIterator","geojsonIterator","makeBinaryGeometryIterator","batch","data"],"mappings":"AAEA,SAAQA,eAAR,QAA8B,iBAA9B;AACA,OAAOC,aAAP,MAA0B,kBAA1B;AACA,OAAOC,kBAAP,MAA+B,6BAA/B;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAWA,MAAMC,8BAA8B,GAAG;AACrCC,EAAAA,OAAO,EAAE;AACPC,IAAAA,KAAK,EAAE;AADA,GAD4B;AAIrCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,SAAS,EAAE,CAAC,GAAD,EAAM,YAAN;AADP,GAJ+B;AA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ACE,aAAOV,eAAe,CAACO,IAAD,CAAtB;;AACF;AACE,aAAOA,IAAP;AAJJ;AAMD;;AAED,SAASkB,cAAT,CAAwBI,aAAxB,EAAuCR,OAAvC,EAAoE;AAElEA,EAAAA,OAAO,GAAG,EAAC,GAAGjB,8BAAJ;AAAoC,OAAGiB;AAAvC,GAAV;AACAA,EAAAA,OAAO,CAACd,IAAR,GAAe,EAAC,GAAGH,8BAA8B,CAACC,OAAnC;AAA4C,OAAGgB,OAAO,CAAChB;AAAvD,GAAf;AAEA,QAAMyB,eAAe,GAAG5B,kBAAkB,CAAC2B,aAAD,EAAgBR,OAAhB,CAA1C;;AAEA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,aAAOqB,0BAA0B,CAACD,eAAD,CAAjC;;AACF;AACE,aAAOA,eAAP;AAJJ;AAMD;;AAED,gBAAgBC,0BAAhB,CAA2CD,eAA3C,EAA4D;AAC1D,aAAW,MAAME,KAAjB,IAA0BF,eAA1B,EAA2C;AACzCE,IAAAA,KAAK,CAACC,IAAN,GAAajC,eAAe,CAACgC,KAAK,CAACC,IAAP,CAA5B;AACA,UAAMD,KAAN;AACD;AACF","sourcesContent":["import type {Loader, LoaderWithParser} from '@loaders.gl/loader-utils';\nimport type {JSONLoaderOptions} from './json-loader';\nimport {geojsonToBinary} from '@loaders.gl/gis';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\nexport type GeoJSONLoaderOptions = JSONLoaderOptions & {\n geojson?: {\n shape?: 'object-row-table';\n };\n gis?: {\n format: 'geojson';\n };\n};\n\nconst DEFAULT_GEOJSON_LOADER_OPTIONS = {\n geojson: {\n shape: 'object-row-table'\n },\n json: {\n jsonpaths: ['$', '$.features']\n },\n gis: {\n format: 'geojson'\n }\n};\n\n/**\n * GeoJSON loader\n */\nexport const GeoJSONWorkerLoader: Loader = {\n name: 'GeoJSON',\n id: 'geojson',\n module: 'geojson',\n version: VERSION,\n worker: true,\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n category: 'geometry',\n text: true,\n options: DEFAULT_GEOJSON_LOADER_OPTIONS\n};\n\nexport const GeoJSONLoader: LoaderWithParser = {\n ...GeoJSONWorkerLoader,\n parse,\n parseTextSync,\n parseInBatches\n};\n\nasync function parse(arrayBuffer, options) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text, options) {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n options.gis = options.gis || {};\n const json = parseJSONSync(text, options);\n switch (options.gis.format) {\n case 'binary':\n return geojsonToBinary(json);\n default:\n return json;\n }\n}\n\nfunction parseInBatches(asyncIterator, options): AsyncIterable<any> {\n // Apps can call the parse method directly, we so apply default options here\n options = {...DEFAULT_GEOJSON_LOADER_OPTIONS, ...options};\n options.json = {...DEFAULT_GEOJSON_LOADER_OPTIONS.geojson, ...options.geojson};\n\n const geojsonIterator = parseJSONInBatches(asyncIterator, options);\n\n switch (options.gis.format) {\n case 'binary':\n return makeBinaryGeometryIterator(geojsonIterator);\n default:\n return geojsonIterator;\n }\n}\n\nasync function* makeBinaryGeometryIterator(geojsonIterator) {\n for await (const batch of geojsonIterator) {\n batch.data = geojsonToBinary(batch.data);\n yield batch;\n }\n}\n"],"file":"geojson-loader.js"}
|
package/dist/geojson-worker.js
CHANGED
|
@@ -2235,7 +2235,7 @@ Char: ${this.c}`;
|
|
|
2235
2235
|
}
|
|
2236
2236
|
|
|
2237
2237
|
// src/geojson-loader.ts
|
|
2238
|
-
var VERSION =
|
|
2238
|
+
var VERSION = true ? "4.0.0-alpha.5" : "latest";
|
|
2239
2239
|
var DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
2240
2240
|
geojson: {
|
|
2241
2241
|
shape: "object-row-table"
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
Object.defineProperty(exports, "JSONLoader", { enumerable: true, get: function () { return json_loader_1.JSONLoader; } });
|
|
9
|
-
var ndjson_loader_1 = require("./ndjson-loader");
|
|
10
|
-
Object.defineProperty(exports, "NDJSONLoader", { enumerable: true, get: function () { return ndjson_loader_1.NDJSONLoader; } });
|
|
11
|
-
var geojson_loader_1 = require("./geojson-loader");
|
|
12
|
-
Object.defineProperty(exports, "_GeoJSONLoader", { enumerable: true, get: function () { return geojson_loader_1.GeoJSONLoader; } });
|
|
13
|
-
Object.defineProperty(exports, "_GeoJSONWorkerLoader", { enumerable: true, get: function () { return geojson_loader_1.GeoJSONWorkerLoader; } });
|
|
14
|
-
var jsonpath_1 = require("./lib/jsonpath/jsonpath");
|
|
15
|
-
Object.defineProperty(exports, "_JSONPath", { enumerable: true, get: function () { return __importDefault(jsonpath_1).default; } });
|
|
16
|
-
var clarinet_1 = require("./lib/clarinet/clarinet");
|
|
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
|
+
export { JSONLoader } from './json-loader';
|
|
2
|
+
export { NDJSONLoader } from './ndjson-loader';
|
|
3
|
+
export { GeoJSONLoader as _GeoJSONLoader, GeoJSONWorkerLoader as _GeoJSONWorkerLoader } from './geojson-loader';
|
|
4
|
+
export { default as _JSONPath } from './lib/jsonpath/jsonpath';
|
|
5
|
+
export { default as _ClarinetParser } from './lib/clarinet/clarinet';
|
|
6
|
+
export { rebuildJsonObject as _rebuildJsonObject } from './lib/parse-json-in-batches';
|
|
7
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts"],"names":["JSONLoader","NDJSONLoader","GeoJSONLoader","_GeoJSONLoader","GeoJSONWorkerLoader","_GeoJSONWorkerLoader","default","_JSONPath","_ClarinetParser","rebuildJsonObject","_rebuildJsonObject"],"mappings":"AACA,SAAQA,UAAR,QAAyB,eAAzB;AACA,SAAQC,YAAR,QAA2B,iBAA3B;AAIA,SACEC,aAAa,IAAIC,cADnB,EAEEC,mBAAmB,IAAIC,oBAFzB,QAGO,kBAHP;AAKA,SAAQC,OAAO,IAAIC,SAAnB,QAAmC,yBAAnC;AACA,SAAQD,OAAO,IAAIE,eAAnB,QAAyC,yBAAzC;AAEA,SAAQC,iBAAiB,IAAIC,kBAA7B,QAAsD,6BAAtD","sourcesContent":["export type {JSONLoaderOptions} from './json-loader';\nexport {JSONLoader} from './json-loader';\nexport {NDJSONLoader} from './ndjson-loader';\n\n// EXPERIMENTAL EXPORTS - WARNING: MAY BE REMOVED WIHTOUT NOTICE IN FUTURE RELEASES\nexport type {GeoJSONLoaderOptions as _GeoJSONLoaderOptions} from './geojson-loader';\nexport {\n GeoJSONLoader as _GeoJSONLoader,\n GeoJSONWorkerLoader as _GeoJSONWorkerLoader\n} from './geojson-loader';\n\nexport {default as _JSONPath} from './lib/jsonpath/jsonpath';\nexport {default as _ClarinetParser} from './lib/clarinet/clarinet';\n\nexport {rebuildJsonObject as _rebuildJsonObject} from './lib/parse-json-in-batches';\n"],"file":"index.js"}
|
package/dist/json-loader.js
CHANGED
|
@@ -1,57 +1,47 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.JSONLoader = void 0;
|
|
7
|
-
const parse_json_1 = __importDefault(require("./lib/parse-json"));
|
|
8
|
-
const parse_json_in_batches_1 = __importDefault(require("./lib/parse-json-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';
|
|
1
|
+
import parseJSONSync from './lib/parse-json';
|
|
2
|
+
import parseJSONInBatches from './lib/parse-json-in-batches';
|
|
3
|
+
const VERSION = typeof "4.0.0-alpha.5" !== 'undefined' ? "4.0.0-alpha.5" : 'latest';
|
|
12
4
|
const DEFAULT_JSON_LOADER_OPTIONS = {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
}
|
|
5
|
+
json: {
|
|
6
|
+
shape: 'row-table',
|
|
7
|
+
table: false,
|
|
8
|
+
jsonpaths: []
|
|
9
|
+
}
|
|
19
10
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
},
|
|
34
|
-
mimeTypes: {
|
|
35
|
-
'application/json': null,
|
|
36
|
-
'application/json-seq': {stream: true},
|
|
37
|
-
'application/x-ndjson': {stream: true}
|
|
38
|
-
},
|
|
39
|
-
*/
|
|
40
|
-
category: 'table',
|
|
41
|
-
text: true,
|
|
42
|
-
parse,
|
|
43
|
-
parseTextSync,
|
|
44
|
-
parseInBatches,
|
|
45
|
-
options: DEFAULT_JSON_LOADER_OPTIONS
|
|
11
|
+
export const JSONLoader = {
|
|
12
|
+
name: 'JSON',
|
|
13
|
+
id: 'json',
|
|
14
|
+
module: 'json',
|
|
15
|
+
version: VERSION,
|
|
16
|
+
extensions: ['json', 'geojson'],
|
|
17
|
+
mimeTypes: ['application/json'],
|
|
18
|
+
category: 'table',
|
|
19
|
+
text: true,
|
|
20
|
+
parse,
|
|
21
|
+
parseTextSync,
|
|
22
|
+
parseInBatches,
|
|
23
|
+
options: DEFAULT_JSON_LOADER_OPTIONS
|
|
46
24
|
};
|
|
25
|
+
|
|
47
26
|
async function parse(arrayBuffer, options) {
|
|
48
|
-
|
|
27
|
+
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
49
28
|
}
|
|
29
|
+
|
|
50
30
|
function parseTextSync(text, options) {
|
|
51
|
-
|
|
52
|
-
|
|
31
|
+
const jsonOptions = { ...options,
|
|
32
|
+
json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
|
|
33
|
+
...(options === null || options === void 0 ? void 0 : options.json)
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
return parseJSONSync(text, jsonOptions);
|
|
53
37
|
}
|
|
38
|
+
|
|
54
39
|
function parseInBatches(asyncIterator, options) {
|
|
55
|
-
|
|
56
|
-
|
|
40
|
+
const jsonOptions = { ...options,
|
|
41
|
+
json: { ...DEFAULT_JSON_LOADER_OPTIONS.json,
|
|
42
|
+
...(options === null || options === void 0 ? void 0 : options.json)
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
return parseJSONInBatches(asyncIterator, jsonOptions);
|
|
57
46
|
}
|
|
47
|
+
//# sourceMappingURL=json-loader.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/json-loader.ts"],"names":["parseJSONSync","parseJSONInBatches","VERSION","DEFAULT_JSON_LOADER_OPTIONS","json","shape","table","jsonpaths","JSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","jsonOptions","asyncIterator"],"mappings":"AAEA,OAAOA,aAAP,MAA0B,kBAA1B;AACA,OAAOC,kBAAP,MAA+B,6BAA/B;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAv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IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAOH,kBAAkB,CAACwB,aAAD,EAAgBD,WAAhB,CAAzB;AACD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseJSONSync from './lib/parse-json';\nimport parseJSONInBatches from './lib/parse-json-in-batches';\n\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nconst VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n\n/**\n * @param table -\n * @param jsonpaths -\n */\nexport type JSONLoaderOptions = LoaderOptions & {\n json?: {\n shape?: 'row-table';\n table?: false;\n jsonpaths?: string[];\n };\n};\n\nconst DEFAULT_JSON_LOADER_OPTIONS = {\n json: {\n shape: 'row-table',\n table: false,\n jsonpaths: []\n // batchSize: 'auto'\n }\n};\n\nexport const JSONLoader: LoaderWithParser = {\n name: 'JSON',\n id: 'json',\n module: 'json',\n version: VERSION,\n extensions: ['json', 'geojson'],\n mimeTypes: ['application/json'],\n // TODO - support various line based JSON formats\n /*\n extensions: {\n json: null,\n jsonl: {stream: true},\n ndjson: {stream: true}\n },\n mimeTypes: {\n 'application/json': null,\n 'application/json-seq': {stream: true},\n 'application/x-ndjson': {stream: true}\n },\n */\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: DEFAULT_JSON_LOADER_OPTIONS\n};\n\nasync function parse(arrayBuffer: ArrayBuffer, options?: JSONLoaderOptions) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer), options);\n}\n\nfunction parseTextSync(text: string, options?: JSONLoaderOptions) {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONSync(text, jsonOptions as JSONLoaderOptions);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: JSONLoaderOptions\n): AsyncIterable<Batch> {\n const jsonOptions = {...options, json: {...DEFAULT_JSON_LOADER_OPTIONS.json, ...options?.json}};\n return parseJSONInBatches(asyncIterator, jsonOptions as JSONLoaderOptions);\n}\n"],"file":"json-loader.js"}
|
package/dist/jsonl-loader.js
CHANGED
|
@@ -1,54 +1,2 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/* TODO JSONL loader
|
|
3
|
-
export const JSONLoader: LoaderWithParser = {
|
|
4
|
-
name: 'JSON',
|
|
5
|
-
id: 'json',
|
|
6
|
-
module: 'json',
|
|
7
|
-
version: VERSION,
|
|
8
|
-
extensions: ['json', 'geojson'],
|
|
9
|
-
mimeTypes: ['application/json'],
|
|
10
|
-
// TODO - support various line based JSON formats
|
|
11
|
-
/*
|
|
12
|
-
extensions: {
|
|
13
|
-
json: null,
|
|
14
|
-
jsonl: {stream: true},
|
|
15
|
-
ndjson: {stream: true}
|
|
16
|
-
},
|
|
17
|
-
mimeTypes: {
|
|
18
|
-
'application/json': null,
|
|
19
|
-
'application/json-seq': {stream: true},
|
|
20
|
-
'application/x-ndjson': {stream: true}
|
|
21
|
-
},
|
|
22
|
-
*
|
|
23
|
-
category: 'table',
|
|
24
|
-
text: true,
|
|
25
|
-
parse,
|
|
26
|
-
parseTextSync,
|
|
27
|
-
parseInBatches,
|
|
28
|
-
options: DEFAULT_JSON_LOADER_OPTIONS
|
|
29
|
-
};
|
|
30
|
-
{
|
|
31
|
-
name: 'TEST-JSONL_LOADER',
|
|
32
|
-
extensions: ['jsonl'],
|
|
33
|
-
parse: async (arrayBuffer, options, context) => {
|
|
34
|
-
const characters = new Uint8Array(arrayBuffer);
|
|
35
|
-
const result = [];
|
|
36
1
|
|
|
37
|
-
|
|
38
|
-
let startIndex = 0;
|
|
39
|
-
for (let i = 0; i <= len; i++) {
|
|
40
|
-
if (characters[i] === 10 || i === len) {
|
|
41
|
-
// Note: we need to make a copy of the buffer here because we cannot
|
|
42
|
-
// handover the ownership of arrayBuffer to the child process
|
|
43
|
-
const json = characters.slice(startIndex, i);
|
|
44
|
-
if (json.length > 1) {
|
|
45
|
-
result.push(await context.parse(json.buffer, {}, 'line.json'));
|
|
46
|
-
}
|
|
47
|
-
startIndex = i + 1;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return result;
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
*/
|
|
2
|
+
//# sourceMappingURL=jsonl-loader.js.map
|
|
File without changes
|
|
File without changes
|