@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
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.default = parseNDJSONSync;
|
|
7
|
-
|
|
8
|
-
function parseNDJSONSync(ndjsonText) {
|
|
9
|
-
var lines = ndjsonText.trim().split('\n');
|
|
10
|
-
return lines.map(function (line, counter) {
|
|
11
|
-
try {
|
|
12
|
-
return JSON.parse(line);
|
|
13
|
-
} catch (error) {
|
|
14
|
-
throw new Error("NDJSONLoader: failed to parse JSON on line ".concat(counter + 1));
|
|
15
|
-
}
|
|
16
|
-
});
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=parse-ndjson.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/parse-ndjson.ts"],"names":["parseNDJSONSync","ndjsonText","lines","trim","split","map","line","counter","JSON","parse","error","Error"],"mappings":";;;;;;;AAAe,SAASA,eAAT,CAAyBC,UAAzB,EAA6C;AAC1D,MAAMC,KAAK,GAAGD,UAAU,CAACE,IAAX,GAAkBC,KAAlB,CAAwB,IAAxB,CAAd;AACA,SAAOF,KAAK,CAACG,GAAN,CAAU,UAACC,IAAD,EAAOC,OAAP,EAAmB;AAClC,QAAI;AACF,aAAOC,IAAI,CAACC,KAAL,CAAWH,IAAX,CAAP;AACD,KAFD,CAEE,OAAOI,KAAP,EAAc;AACd,YAAM,IAAIC,KAAJ,sDAAwDJ,OAAO,GAAG,CAAlE,EAAN;AACD;AACF,GANM,CAAP;AAOD","sourcesContent":["export default function parseNDJSONSync(ndjsonText: string) {\n const lines = ndjsonText.trim().split('\\n');\n return lines.map((line, counter) => {\n try {\n return JSON.parse(line);\n } catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);\n }\n });\n}\n"],"file":"parse-ndjson.js"}
|
|
@@ -1,159 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
15
|
-
|
|
16
|
-
var _clarinet = _interopRequireDefault(require("../clarinet/clarinet"));
|
|
17
|
-
|
|
18
|
-
var _jsonpath = _interopRequireDefault(require("../jsonpath/jsonpath"));
|
|
19
|
-
|
|
20
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
21
|
-
|
|
22
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
23
|
-
|
|
24
|
-
var JSONParser = function () {
|
|
25
|
-
function JSONParser(options) {
|
|
26
|
-
var _this = this;
|
|
27
|
-
|
|
28
|
-
(0, _classCallCheck2.default)(this, JSONParser);
|
|
29
|
-
(0, _defineProperty2.default)(this, "parser", void 0);
|
|
30
|
-
(0, _defineProperty2.default)(this, "result", undefined);
|
|
31
|
-
(0, _defineProperty2.default)(this, "previousStates", []);
|
|
32
|
-
(0, _defineProperty2.default)(this, "currentState", Object.freeze({
|
|
33
|
-
container: [],
|
|
34
|
-
key: null
|
|
35
|
-
}));
|
|
36
|
-
(0, _defineProperty2.default)(this, "jsonpath", new _jsonpath.default());
|
|
37
|
-
this.reset();
|
|
38
|
-
this.parser = new _clarinet.default(_objectSpread({
|
|
39
|
-
onready: function onready() {
|
|
40
|
-
_this.jsonpath = new _jsonpath.default();
|
|
41
|
-
_this.previousStates.length = 0;
|
|
42
|
-
_this.currentState.container.length = 0;
|
|
43
|
-
},
|
|
44
|
-
onopenobject: function onopenobject(name) {
|
|
45
|
-
_this._openObject({});
|
|
46
|
-
|
|
47
|
-
if (typeof name !== 'undefined') {
|
|
48
|
-
_this.parser.emit('onkey', name);
|
|
49
|
-
}
|
|
50
|
-
},
|
|
51
|
-
onkey: function onkey(name) {
|
|
52
|
-
_this.jsonpath.set(name);
|
|
53
|
-
|
|
54
|
-
_this.currentState.key = name;
|
|
55
|
-
},
|
|
56
|
-
oncloseobject: function oncloseobject() {
|
|
57
|
-
_this._closeObject();
|
|
58
|
-
},
|
|
59
|
-
onopenarray: function onopenarray() {
|
|
60
|
-
_this._openArray();
|
|
61
|
-
},
|
|
62
|
-
onclosearray: function onclosearray() {
|
|
63
|
-
_this._closeArray();
|
|
64
|
-
},
|
|
65
|
-
onvalue: function onvalue(value) {
|
|
66
|
-
_this._pushOrSet(value);
|
|
67
|
-
},
|
|
68
|
-
onerror: function onerror(error) {
|
|
69
|
-
throw error;
|
|
70
|
-
},
|
|
71
|
-
onend: function onend() {
|
|
72
|
-
_this.result = _this.currentState.container.pop();
|
|
73
|
-
}
|
|
74
|
-
}, options));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
(0, _createClass2.default)(JSONParser, [{
|
|
78
|
-
key: "reset",
|
|
79
|
-
value: function reset() {
|
|
80
|
-
this.result = undefined;
|
|
81
|
-
this.previousStates = [];
|
|
82
|
-
this.currentState = Object.freeze({
|
|
83
|
-
container: [],
|
|
84
|
-
key: null
|
|
85
|
-
});
|
|
86
|
-
this.jsonpath = new _jsonpath.default();
|
|
87
|
-
}
|
|
88
|
-
}, {
|
|
89
|
-
key: "write",
|
|
90
|
-
value: function write(chunk) {
|
|
91
|
-
this.parser.write(chunk);
|
|
92
|
-
}
|
|
93
|
-
}, {
|
|
94
|
-
key: "close",
|
|
95
|
-
value: function close() {
|
|
96
|
-
this.parser.close();
|
|
97
|
-
}
|
|
98
|
-
}, {
|
|
99
|
-
key: "_pushOrSet",
|
|
100
|
-
value: function _pushOrSet(value) {
|
|
101
|
-
var _this$currentState = this.currentState,
|
|
102
|
-
container = _this$currentState.container,
|
|
103
|
-
key = _this$currentState.key;
|
|
104
|
-
|
|
105
|
-
if (key !== null) {
|
|
106
|
-
container[key] = value;
|
|
107
|
-
this.currentState.key = null;
|
|
108
|
-
} else {
|
|
109
|
-
container.push(value);
|
|
110
|
-
}
|
|
111
|
-
}
|
|
112
|
-
}, {
|
|
113
|
-
key: "_openArray",
|
|
114
|
-
value: function _openArray() {
|
|
115
|
-
var newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
116
|
-
this.jsonpath.push(null);
|
|
117
|
-
|
|
118
|
-
this._pushOrSet(newContainer);
|
|
119
|
-
|
|
120
|
-
this.previousStates.push(this.currentState);
|
|
121
|
-
this.currentState = {
|
|
122
|
-
container: newContainer,
|
|
123
|
-
isArray: true,
|
|
124
|
-
key: null
|
|
125
|
-
};
|
|
126
|
-
}
|
|
127
|
-
}, {
|
|
128
|
-
key: "_closeArray",
|
|
129
|
-
value: function _closeArray() {
|
|
130
|
-
this.jsonpath.pop();
|
|
131
|
-
this.currentState = this.previousStates.pop();
|
|
132
|
-
}
|
|
133
|
-
}, {
|
|
134
|
-
key: "_openObject",
|
|
135
|
-
value: function _openObject() {
|
|
136
|
-
var newContainer = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
137
|
-
this.jsonpath.push(null);
|
|
138
|
-
|
|
139
|
-
this._pushOrSet(newContainer);
|
|
140
|
-
|
|
141
|
-
this.previousStates.push(this.currentState);
|
|
142
|
-
this.currentState = {
|
|
143
|
-
container: newContainer,
|
|
144
|
-
isArray: false,
|
|
145
|
-
key: null
|
|
146
|
-
};
|
|
147
|
-
}
|
|
148
|
-
}, {
|
|
149
|
-
key: "_closeObject",
|
|
150
|
-
value: function _closeObject() {
|
|
151
|
-
this.jsonpath.pop();
|
|
152
|
-
this.currentState = this.previousStates.pop();
|
|
153
|
-
}
|
|
154
|
-
}]);
|
|
155
|
-
return JSONParser;
|
|
156
|
-
}();
|
|
157
|
-
|
|
158
|
-
exports.default = JSONParser;
|
|
159
|
-
//# sourceMappingURL=json-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parser/json-parser.ts"],"names":["JSONParser","options","undefined","Object","freeze","container","key","JSONPath","reset","parser","ClarinetParser","onready","jsonpath","previousStates","length","currentState","onopenobject","name","_openObject","emit","onkey","set","oncloseobject","_closeObject","onopenarray","_openArray","onclosearray","_closeArray","onvalue","value","_pushOrSet","onerror","error","onend","result","pop","chunk","write","close","push","newContainer","isArray"],"mappings":"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","sourcesContent":["// @ts-nocheck\n\nimport ClarinetParser, {ClarinetParserOptions} from '../clarinet/clarinet';\nimport JSONPath from '../jsonpath/jsonpath';\n\n// JSONParser builds a JSON object using the events emitted by the Clarinet parser\n\nexport default class JSONParser {\n readonly parser: ClarinetParser;\n result = undefined;\n previousStates = [];\n currentState = Object.freeze({container: [], key: null});\n jsonpath: JSONPath = new JSONPath();\n\n constructor(options: ClarinetParserOptions) {\n this.reset();\n this.parser = new ClarinetParser({\n onready: () => {\n this.jsonpath = new JSONPath();\n this.previousStates.length = 0;\n this.currentState.container.length = 0;\n },\n\n onopenobject: (name) => {\n this._openObject({});\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n },\n\n onkey: (name) => {\n this.jsonpath.set(name);\n this.currentState.key = name;\n },\n\n oncloseobject: () => {\n this._closeObject();\n },\n\n onopenarray: () => {\n this._openArray();\n },\n\n onclosearray: () => {\n this._closeArray();\n },\n\n onvalue: (value) => {\n this._pushOrSet(value);\n },\n\n onerror: (error) => {\n throw error;\n },\n\n onend: () => {\n this.result = this.currentState.container.pop();\n },\n\n ...options\n });\n }\n\n reset(): void {\n this.result = undefined;\n this.previousStates = [];\n this.currentState = Object.freeze({container: [], key: null});\n this.jsonpath = new JSONPath();\n }\n\n write(chunk): void {\n this.parser.write(chunk);\n }\n\n close(): void {\n this.parser.close();\n }\n\n // PRIVATE METHODS\n\n _pushOrSet(value): void {\n const {container, key} = this.currentState;\n if (key !== null) {\n container[key] = value;\n this.currentState.key = null;\n } else {\n container.push(value);\n }\n }\n\n _openArray(newContainer = []): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: true, key: null};\n }\n\n _closeArray(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n\n _openObject(newContainer = {}): void {\n this.jsonpath.push(null);\n this._pushOrSet(newContainer);\n this.previousStates.push(this.currentState);\n this.currentState = {container: newContainer, isArray: false, key: null};\n }\n\n _closeObject(): void {\n this.jsonpath.pop();\n this.currentState = this.previousStates.pop();\n }\n}\n"],"file":"json-parser.js"}
|
|
@@ -1,158 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports.default = void 0;
|
|
9
|
-
|
|
10
|
-
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
11
|
-
|
|
12
|
-
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
-
|
|
14
|
-
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
-
|
|
16
|
-
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
-
|
|
18
|
-
var _get2 = _interopRequireDefault(require("@babel/runtime/helpers/get"));
|
|
19
|
-
|
|
20
|
-
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
21
|
-
|
|
22
|
-
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
23
|
-
|
|
24
|
-
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
25
|
-
|
|
26
|
-
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
27
|
-
|
|
28
|
-
var _jsonParser = _interopRequireDefault(require("./json-parser"));
|
|
29
|
-
|
|
30
|
-
var _jsonpath = _interopRequireDefault(require("../jsonpath/jsonpath"));
|
|
31
|
-
|
|
32
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
33
|
-
|
|
34
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
35
|
-
|
|
36
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
|
|
37
|
-
|
|
38
|
-
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
39
|
-
|
|
40
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
41
|
-
|
|
42
|
-
var StreamingJSONParser = function (_JSONParser) {
|
|
43
|
-
(0, _inherits2.default)(StreamingJSONParser, _JSONParser);
|
|
44
|
-
|
|
45
|
-
var _super = _createSuper(StreamingJSONParser);
|
|
46
|
-
|
|
47
|
-
function StreamingJSONParser() {
|
|
48
|
-
var _this;
|
|
49
|
-
|
|
50
|
-
var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
51
|
-
(0, _classCallCheck2.default)(this, StreamingJSONParser);
|
|
52
|
-
_this = _super.call(this, {
|
|
53
|
-
onopenarray: function onopenarray() {
|
|
54
|
-
if (!_this.streamingArray) {
|
|
55
|
-
if (_this._matchJSONPath()) {
|
|
56
|
-
_this.streamingJsonPath = _this.getJsonPath().clone();
|
|
57
|
-
_this.streamingArray = [];
|
|
58
|
-
|
|
59
|
-
_this._openArray(_this.streamingArray);
|
|
60
|
-
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
_this._openArray();
|
|
66
|
-
},
|
|
67
|
-
onopenobject: function onopenobject(name) {
|
|
68
|
-
if (!_this.topLevelObject) {
|
|
69
|
-
_this.topLevelObject = {};
|
|
70
|
-
|
|
71
|
-
_this._openObject(_this.topLevelObject);
|
|
72
|
-
} else {
|
|
73
|
-
_this._openObject({});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
if (typeof name !== 'undefined') {
|
|
77
|
-
_this.parser.emit('onkey', name);
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "jsonPaths", void 0);
|
|
82
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "streamingJsonPath", null);
|
|
83
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "streamingArray", null);
|
|
84
|
-
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "topLevelObject", null);
|
|
85
|
-
var jsonpaths = options.jsonpaths || [];
|
|
86
|
-
_this.jsonPaths = jsonpaths.map(function (jsonpath) {
|
|
87
|
-
return new _jsonpath.default(jsonpath);
|
|
88
|
-
});
|
|
89
|
-
return _this;
|
|
90
|
-
}
|
|
91
|
-
|
|
92
|
-
(0, _createClass2.default)(StreamingJSONParser, [{
|
|
93
|
-
key: "write",
|
|
94
|
-
value: function write(chunk) {
|
|
95
|
-
(0, _get2.default)((0, _getPrototypeOf2.default)(StreamingJSONParser.prototype), "write", this).call(this, chunk);
|
|
96
|
-
var array = [];
|
|
97
|
-
|
|
98
|
-
if (this.streamingArray) {
|
|
99
|
-
array = (0, _toConsumableArray2.default)(this.streamingArray);
|
|
100
|
-
this.streamingArray.length = 0;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
return array;
|
|
104
|
-
}
|
|
105
|
-
}, {
|
|
106
|
-
key: "getPartialResult",
|
|
107
|
-
value: function getPartialResult() {
|
|
108
|
-
return this.topLevelObject;
|
|
109
|
-
}
|
|
110
|
-
}, {
|
|
111
|
-
key: "getStreamingJsonPath",
|
|
112
|
-
value: function getStreamingJsonPath() {
|
|
113
|
-
return this.streamingJsonPath;
|
|
114
|
-
}
|
|
115
|
-
}, {
|
|
116
|
-
key: "getStreamingJsonPathAsString",
|
|
117
|
-
value: function getStreamingJsonPathAsString() {
|
|
118
|
-
return this.streamingJsonPath && this.streamingJsonPath.toString();
|
|
119
|
-
}
|
|
120
|
-
}, {
|
|
121
|
-
key: "getJsonPath",
|
|
122
|
-
value: function getJsonPath() {
|
|
123
|
-
return this.jsonpath;
|
|
124
|
-
}
|
|
125
|
-
}, {
|
|
126
|
-
key: "_matchJSONPath",
|
|
127
|
-
value: function _matchJSONPath() {
|
|
128
|
-
var currentPath = this.getJsonPath();
|
|
129
|
-
|
|
130
|
-
if (this.jsonPaths.length === 0) {
|
|
131
|
-
return true;
|
|
132
|
-
}
|
|
133
|
-
|
|
134
|
-
var _iterator = _createForOfIteratorHelper(this.jsonPaths),
|
|
135
|
-
_step;
|
|
136
|
-
|
|
137
|
-
try {
|
|
138
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
139
|
-
var jsonPath = _step.value;
|
|
140
|
-
|
|
141
|
-
if (jsonPath.equals(currentPath)) {
|
|
142
|
-
return true;
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
} catch (err) {
|
|
146
|
-
_iterator.e(err);
|
|
147
|
-
} finally {
|
|
148
|
-
_iterator.f();
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
return false;
|
|
152
|
-
}
|
|
153
|
-
}]);
|
|
154
|
-
return StreamingJSONParser;
|
|
155
|
-
}(_jsonParser.default);
|
|
156
|
-
|
|
157
|
-
exports.default = StreamingJSONParser;
|
|
158
|
-
//# sourceMappingURL=streaming-json-parser.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/lib/parser/streaming-json-parser.ts"],"names":["StreamingJSONParser","options","onopenarray","streamingArray","_matchJSONPath","streamingJsonPath","getJsonPath","clone","_openArray","onopenobject","name","topLevelObject","_openObject","parser","emit","jsonpaths","jsonPaths","map","jsonpath","JSONPath","chunk","array","length","toString","currentPath","jsonPath","equals","JSONParser"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;AACA;;;;;;;;;;;;IAMqBA,mB;;;;;AAMnB,iCAAgD;AAAA;;AAAA,QAApCC,OAAoC,uEAAJ,EAAI;AAAA;AAC9C,8BAAM;AACJC,MAAAA,WAAW,EAAE,uBAAM;AACjB,YAAI,CAAC,MAAKC,cAAV,EAA0B;AACxB,cAAI,MAAKC,cAAL,EAAJ,EAA2B;AAEzB,kBAAKC,iBAAL,GAAyB,MAAKC,WAAL,GAAmBC,KAAnB,EAAzB;AACA,kBAAKJ,cAAL,GAAsB,EAAtB;;AACA,kBAAKK,UAAL,CAAgB,MAAKL,cAArB;;AACA;AACD;AACF;;AAED,cAAKK,UAAL;AACD,OAbG;AAgBJC,MAAAA,YAAY,EAAE,sBAACC,IAAD,EAAU;AACtB,YAAI,CAAC,MAAKC,cAAV,EAA0B;AACxB,gBAAKA,cAAL,GAAsB,EAAtB;;AACA,gBAAKC,WAAL,CAAiB,MAAKD,cAAtB;AACD,SAHD,MAGO;AACL,gBAAKC,WAAL,CAAiB,EAAjB;AACD;;AACD,YAAI,OAAOF,IAAP,KAAgB,WAApB,EAAiC;AAC/B,gBAAKG,MAAL,CAAYC,IAAZ,CAAiB,OAAjB,EAA0BJ,IAA1B;AACD;AACF;AA1BG,KAAN;AAD8C;AAAA,oGAJH,IAIG;AAAA,iGAHT,IAGS;AAAA,iGAFR,IAEQ;AA6B9C,QAAMK,SAAS,GAAGd,OAAO,CAACc,SAAR,IAAqB,EAAvC;AACA,UAAKC,SAAL,GAAiBD,SAAS,CAACE,GAAV,CAAc,UAACC,QAAD;AAAA,aAAc,IAAIC,iBAAJ,CAAaD,QAAb,CAAd;AAAA,KAAd,CAAjB;AA9B8C;AA+B/C;;;;WASD,eAAME,KAAN,EAAa;AACX,iHAAYA,KAAZ;AACA,UAAIC,KAAY,GAAG,EAAnB;;AACA,UAAI,KAAKlB,cAAT,EAAyB;AACvBkB,QAAAA,KAAK,oCAAO,KAAKlB,cAAZ,CAAL;AACA,aAAKA,cAAL,CAAoBmB,MAApB,GAA6B,CAA7B;AACD;;AACD,aAAOD,KAAP;AACD;;;WAOD,4BAAmB;AACjB,aAAO,KAAKV,cAAZ;AACD;;;WAED,gCAAuB;AACrB,aAAO,KAAKN,iBAAZ;AACD;;;WAED,wCAA+B;AAC7B,aAAO,KAAKA,iBAAL,IAA0B,KAAKA,iBAAL,CAAuBkB,QAAvB,EAAjC;AACD;;;WAED,uBAAc;AACZ,aAAO,KAAKL,QAAZ;AACD;;;WAOD,0BAAiB;AACf,UAAMM,WAAW,GAAG,KAAKlB,WAAL,EAApB;;AAKA,UAAI,KAAKU,SAAL,CAAeM,MAAf,KAA0B,CAA9B,EAAiC;AAC/B,eAAO,IAAP;AACD;;AARc,iDAUQ,KAAKN,SAVb;AAAA;;AAAA;AAUf,4DAAuC;AAAA,cAA5BS,QAA4B;;AACrC,cAAIA,QAAQ,CAACC,MAAT,CAAgBF,WAAhB,CAAJ,EAAkC;AAChC,mBAAO,IAAP;AACD;AACF;AAdc;AAAA;AAAA;AAAA;AAAA;;AAgBf,aAAO,KAAP;AACD;;;EAnG8CG,mB","sourcesContent":["import {default as JSONParser} from './json-parser';\nimport JSONPath from '../jsonpath/jsonpath';\n\n/**\n * The `StreamingJSONParser` looks for the first array in the JSON structure.\n * and emits an array of chunks\n */\nexport default class StreamingJSONParser extends JSONParser {\n private jsonPaths: JSONPath[];\n private streamingJsonPath: JSONPath | null = null;\n private streamingArray: any[] | null = null;\n private topLevelObject: object | null = null;\n\n constructor(options: {[key: string]: any} = {}) {\n super({\n onopenarray: () => {\n if (!this.streamingArray) {\n if (this._matchJSONPath()) {\n // @ts-ignore\n this.streamingJsonPath = this.getJsonPath().clone();\n this.streamingArray = [];\n this._openArray(this.streamingArray as []);\n return;\n }\n }\n\n this._openArray();\n },\n\n // Redefine onopenarray to inject value for top-level object\n onopenobject: (name) => {\n if (!this.topLevelObject) {\n this.topLevelObject = {};\n this._openObject(this.topLevelObject);\n } else {\n this._openObject({});\n }\n if (typeof name !== 'undefined') {\n this.parser.emit('onkey', name);\n }\n }\n });\n const jsonpaths = options.jsonpaths || [];\n this.jsonPaths = jsonpaths.map((jsonpath) => new JSONPath(jsonpath));\n }\n\n /**\n * write REDEFINITION\n * - super.write() chunk to parser\n * - get the contents (so far) of \"topmost-level\" array as batch of rows\n * - clear top-level array\n * - return the batch of rows\\\n */\n write(chunk) {\n super.write(chunk);\n let array: any[] = [];\n if (this.streamingArray) {\n array = [...this.streamingArray];\n this.streamingArray.length = 0;\n }\n return array;\n }\n\n /**\n * Returns a partially formed result object\n * Useful for returning the \"wrapper\" object when array is not top level\n * e.g. GeoJSON\n */\n getPartialResult() {\n return this.topLevelObject;\n }\n\n getStreamingJsonPath() {\n return this.streamingJsonPath;\n }\n\n getStreamingJsonPathAsString() {\n return this.streamingJsonPath && this.streamingJsonPath.toString();\n }\n\n getJsonPath() {\n return this.jsonpath;\n }\n\n // PRIVATE METHODS\n\n /**\n * Checks is this.getJsonPath matches the jsonpaths provided in options\n */\n _matchJSONPath() {\n const currentPath = this.getJsonPath();\n // console.debug(`Testing JSONPath`, currentPath);\n\n // Backwards compatibility, match any array\n // TODO implement using wildcard once that is supported\n if (this.jsonPaths.length === 0) {\n return true;\n }\n\n for (const jsonPath of this.jsonPaths) {\n if (jsonPath.equals(currentPath)) {\n return true;\n }\n }\n\n return false;\n }\n}\n"],"file":"streaming-json-parser.js"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
|
-
Object.defineProperty(exports, "__esModule", {
|
|
6
|
-
value: true
|
|
7
|
-
});
|
|
8
|
-
exports._typecheckNDJSONLoader = exports.NDJSONLoader = void 0;
|
|
9
|
-
|
|
10
|
-
var _regenerator = _interopRequireDefault(require("@babel/runtime/regenerator"));
|
|
11
|
-
|
|
12
|
-
var _asyncToGenerator2 = _interopRequireDefault(require("@babel/runtime/helpers/asyncToGenerator"));
|
|
13
|
-
|
|
14
|
-
var _parseNdjson = _interopRequireDefault(require("./lib/parse-ndjson"));
|
|
15
|
-
|
|
16
|
-
var _parseNdjsonInBatches = _interopRequireDefault(require("./lib/parse-ndjson-in-batches"));
|
|
17
|
-
|
|
18
|
-
var VERSION = typeof "3.1.3" !== 'undefined' ? "3.1.3" : 'latest';
|
|
19
|
-
var NDJSONLoader = {
|
|
20
|
-
name: 'NDJSON',
|
|
21
|
-
id: 'ndjson',
|
|
22
|
-
module: 'json',
|
|
23
|
-
version: VERSION,
|
|
24
|
-
extensions: ['ndjson'],
|
|
25
|
-
mimeTypes: ['application/x-ndjson'],
|
|
26
|
-
category: 'table',
|
|
27
|
-
text: true,
|
|
28
|
-
parse: parse,
|
|
29
|
-
parseTextSync: parseTextSync,
|
|
30
|
-
parseInBatches: parseInBatches,
|
|
31
|
-
options: {}
|
|
32
|
-
};
|
|
33
|
-
exports.NDJSONLoader = NDJSONLoader;
|
|
34
|
-
|
|
35
|
-
function parse(_x) {
|
|
36
|
-
return _parse.apply(this, arguments);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function _parse() {
|
|
40
|
-
_parse = (0, _asyncToGenerator2.default)(_regenerator.default.mark(function _callee(arrayBuffer) {
|
|
41
|
-
return _regenerator.default.wrap(function _callee$(_context) {
|
|
42
|
-
while (1) {
|
|
43
|
-
switch (_context.prev = _context.next) {
|
|
44
|
-
case 0:
|
|
45
|
-
return _context.abrupt("return", parseTextSync(new TextDecoder().decode(arrayBuffer)));
|
|
46
|
-
|
|
47
|
-
case 1:
|
|
48
|
-
case "end":
|
|
49
|
-
return _context.stop();
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
}, _callee);
|
|
53
|
-
}));
|
|
54
|
-
return _parse.apply(this, arguments);
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function parseTextSync(text) {
|
|
58
|
-
return (0, _parseNdjson.default)(text);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
function parseInBatches(asyncIterator, options) {
|
|
62
|
-
return (0, _parseNdjsonInBatches.default)(asyncIterator, options);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
var _typecheckNDJSONLoader = NDJSONLoader;
|
|
66
|
-
exports._typecheckNDJSONLoader = _typecheckNDJSONLoader;
|
|
67
|
-
//# sourceMappingURL=ndjson-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/ndjson-loader.ts"],"names":["VERSION","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","asyncIterator","_typecheckNDJSONLoader"],"mappings":";;;;;;;;;;;;;AAEA;;AACA;;AAIA,IAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE;AAEO,IAAMC,YAAY,GAAG;AAC1BC,EAAAA,IAAI,EAAE,QADoB;AAE1BC,EAAAA,EAAE,EAAE,QAFsB;AAG1BC,EAAAA,MAAM,EAAE,MAHkB;AAI1BC,EAAAA,OAAO,EAAEL,OAJiB;AAK1BM,EAAAA,UAAU,EAAE,CAAC,QAAD,CALc;AAM1BC,EAAAA,SAAS,EAAE,CAAC,sBAAD,CANe;AAO1BC,EAAAA,QAAQ,EAAE,OAPgB;AAQ1BC,EAAAA,IAAI,EAAE,IARoB;AAS1BC,EAAAA,KAAK,EAALA,KAT0B;AAU1BC,EAAAA,aAAa,EAAbA,aAV0B;AAW1BC,EAAAA,cAAc,EAAdA,cAX0B;AAY1BC,EAAAA,OAAO,EAAE;AAZiB,CAArB;;;SAeQH,K;;;;;qEAAf,iBAAqBI,WAArB;AAAA;AAAA;AAAA;AAAA;AAAA,6CACSH,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CADtB;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,G;;;;AAIA,SAASH,aAAT,CAAuBF,IAAvB,EAAqC;AACnC,SAAO,0BAAgBA,IAAhB,CAAP;AACD;;AAED,SAASG,cAAT,CACEK,aADF,EAEEJ,OAFF,EAGwB;AACtB,SAAO,mCAAqBI,aAArB,EAAoCJ,OAApC,CAAP;AACD;;AAEM,IAAMK,sBAAwC,GAAGjB,YAAjD","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport type {LoaderWithParser, LoaderOptions} from '@loaders.gl/loader-utils';\nimport parseNDJSONSync from './lib/parse-ndjson';\nimport parseNDJSONInBatches from './lib/parse-ndjson-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 const NDJSONLoader = {\n name: 'NDJSON',\n id: 'ndjson',\n module: 'json',\n version: VERSION,\n extensions: ['ndjson'],\n mimeTypes: ['application/x-ndjson'],\n category: 'table',\n text: true,\n parse,\n parseTextSync,\n parseInBatches,\n options: {}\n};\n\nasync function parse(arrayBuffer: ArrayBuffer) {\n return parseTextSync(new TextDecoder().decode(arrayBuffer));\n}\n\nfunction parseTextSync(text: string) {\n return parseNDJSONSync(text);\n}\n\nfunction parseInBatches(\n asyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptions\n): AsyncIterable<Batch> {\n return parseNDJSONInBatches(asyncIterator, options);\n}\n\nexport const _typecheckNDJSONLoader: LoaderWithParser = NDJSONLoader;\n"],"file":"ndjson-loader.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/workers/geojson-worker.ts"],"names":["GeoJSONLoader"],"mappings":";;AAAA;;AACA;;AAEA,qCAAmBA,4BAAnB","sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {GeoJSONLoader} from '../geojson-loader';\n\ncreateLoaderWorker(GeoJSONLoader);\n"],"file":"geojson-worker.js"}
|
package/dist/esm/bundle.js
DELETED
package/dist/esm/bundle.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,81 +0,0 @@
|
|
|
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 "3.1.3" !== 'undefined' ? "3.1.3" : 'latest';
|
|
5
|
-
const DEFAULT_GEOJSON_LOADER_OPTIONS = {
|
|
6
|
-
geojson: {
|
|
7
|
-
shape: 'object-row-table'
|
|
8
|
-
},
|
|
9
|
-
json: {
|
|
10
|
-
jsonpaths: ['$', '$.features']
|
|
11
|
-
},
|
|
12
|
-
gis: {
|
|
13
|
-
format: 'geojson'
|
|
14
|
-
}
|
|
15
|
-
};
|
|
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
|
|
27
|
-
};
|
|
28
|
-
export const GeoJSONLoader = { ...GeoJSONWorkerLoader,
|
|
29
|
-
parse,
|
|
30
|
-
parseTextSync,
|
|
31
|
-
parseInBatches
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
async function parse(arrayBuffer, options) {
|
|
35
|
-
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function parseTextSync(text, options) {
|
|
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
|
-
}
|
|
55
|
-
}
|
|
56
|
-
|
|
57
|
-
function parseInBatches(asyncIterator, options) {
|
|
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
|
-
}
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
async function* makeBinaryGeometryIterator(geojsonIterator) {
|
|
76
|
-
for await (const batch of geojsonIterator) {
|
|
77
|
-
batch.data = geojsonToBinary(batch.data);
|
|
78
|
-
yield batch;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=geojson-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAuB,WAAvB,aAAmD,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;AAOrCC,EAAAA,GAAG,EAAE;AACHC,IAAAA,MAAM,EAAE;AADL;AAPgC,CAAvC;AAeA,OAAO,MAAMC,mBAA2B,GAAG;AACzCC,EAAAA,IAAI,EAAE,SADmC;AAEzCC,EAAAA,EAAE,EAAE,SAFqC;AAGzCC,EAAAA,MAAM,EAAE,SAHiC;AAIzCC,EAAAA,OAAO,EAAEZ,OAJgC;AAKzCa,EAAAA,MAAM,EAAE,IALiC;AAMzCC,EAAAA,UAAU,EAAE,CAAC,SAAD,CAN6B;AAOzCC,EAAAA,SAAS,EAAE,CAAC,sBAAD,CAP8B;AAQzCC,EAAAA,QAAQ,EAAE,UAR+B;AASzCC,EAAAA,IAAI,EAAE,IATmC;AAUzCC,EAAAA,OAAO,EAAEjB;AAVgC,CAApC;AAaP,OAAO,MAAMkB,aAA+B,GAAG,EAC7C,GAAGX,mBAD0C;AAE7CY,EAAAA,KAF6C;AAG7CC,EAAAA,aAH6C;AAI7CC,EAAAA;AAJ6C,CAAxC;;AAOP,eAAeF,KAAf,CAAqBG,WAArB,EAAkCL,OAAlC,EAA2C;AACzC,SAAOG,aAAa,CAAC,IAAIG,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCL,OAAxC,CAApB;AACD;;AAED,SAASG,aAAT,CAAuBJ,IAAvB,EAA6BC,OAA7B,EAAsC;AAEpCA,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;AACAgB,EAAAA,OAAO,CAACZ,GAAR,GAAcY,OAAO,CAACZ,GAAR,IAAe,EAA7B;AACA,QAAMF,IAAI,GAAGN,aAAa,CAACmB,IAAD,EAAOC,OAAP,CAA1B;;AACA,UAAQA,OAAO,CAACZ,GAAR,CAAYC,MAApB;AACE,SAAK,QAAL;AACE,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/esm/index.js
DELETED
|
@@ -1,7 +0,0 @@
|
|
|
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
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
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/esm/json-loader.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import parseJSONSync from './lib/parse-json';
|
|
2
|
-
import parseJSONInBatches from './lib/parse-json-in-batches';
|
|
3
|
-
const VERSION = typeof "3.1.3" !== 'undefined' ? "3.1.3" : 'latest';
|
|
4
|
-
const DEFAULT_JSON_LOADER_OPTIONS = {
|
|
5
|
-
json: {
|
|
6
|
-
shape: 'row-table',
|
|
7
|
-
table: false,
|
|
8
|
-
jsonpaths: []
|
|
9
|
-
}
|
|
10
|
-
};
|
|
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
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
async function parse(arrayBuffer, options) {
|
|
27
|
-
return parseTextSync(new TextDecoder().decode(arrayBuffer), options);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
function parseTextSync(text, options) {
|
|
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);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function parseInBatches(asyncIterator, options) {
|
|
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);
|
|
46
|
-
}
|
|
47
|
-
//# sourceMappingURL=json-loader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
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,mBAAuB,WAAvB,aAAmD,QAAnE;AAcA,MAAMC,2BAA2B,GAAG;AAClCC,EAAAA,IAAI,EAAE;AACJC,IAAAA,KAAK,EAAE,WADH;AAEJC,IAAAA,KAAK,EAAE,KAFH;AAGJC,IAAAA,SAAS,EAAE;AAHP;AAD4B,CAApC;AASA,OAAO,MAAMC,UAA4B,GAAG;AAC1CC,EAAAA,IAAI,EAAE,MADoC;AAE1CC,EAAAA,EAAE,EAAE,MAFsC;AAG1CC,EAAAA,MAAM,EAAE,MAHkC;AAI1CC,EAAAA,OAAO,EAAEV,OAJiC;AAK1CW,EAAAA,UAAU,EAAE,CAAC,MAAD,EAAS,SAAT,CAL8B;AAM1CC,EAAAA,SAAS,EAAE,CAAC,kBAAD,CAN+B;AAoB1CC,EAAAA,QAAQ,EAAE,OApBgC;AAqB1CC,EAAAA,IAAI,EAAE,IArBoC;AAsB1CC,EAAAA,KAtB0C;AAuB1CC,EAAAA,aAvB0C;AAwB1CC,EAAAA,cAxB0C;AAyB1CC,EAAAA,OAAO,EAAEjB;AAzBiC,CAArC;;AA4BP,eAAec,KAAf,CAAqBI,WAArB,EAA+CD,OAA/C,EAA4E;AAC1E,SAAOF,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,EAAwCD,OAAxC,CAApB;AACD;;AAED,SAASF,aAAT,CAAuBF,IAAvB,EAAqCI,OAArC,EAAkE;AAChE,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,IAAI,EAAE,EAAC,GAAGD,2BAA2B,CAACC,IAAhC;AAAsC,UAAGgB,OAAH,aAAGA,OAAH,uBAAGA,OAAO,CAAEhB,IAAZ;AAAtC;AAAnB,GAApB;AACA,SAAOJ,aAAa,CAACgB,IAAD,EAAOQ,WAAP,CAApB;AACD;;AAED,SAASL,cAAT,CACEM,aADF,EAEEL,OAFF,EAGwB;AACtB,QAAMI,WAAW,GAAG,EAAC,GAAGJ,OAAJ;AAAahB,IAAAA,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/esm/jsonl-loader.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":[],"names":[],"mappings":"","sourcesContent":[],"file":"jsonl-loader.js"}
|