@loaders.gl/json 3.1.0-alpha.3 → 3.1.0-beta.2

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 (131) hide show
  1. package/dist/bundle.d.ts +2 -0
  2. package/dist/bundle.d.ts.map +1 -0
  3. package/dist/bundle.js +1838 -4
  4. package/dist/es5/bundle.js +7 -0
  5. package/dist/es5/bundle.js.map +1 -0
  6. package/dist/es5/geojson-loader.js +95 -0
  7. package/dist/es5/geojson-loader.js.map +1 -0
  8. package/dist/es5/index.js +54 -0
  9. package/dist/es5/index.js.map +1 -0
  10. package/dist/es5/json-loader.js +59 -0
  11. package/dist/es5/json-loader.js.map +1 -0
  12. package/dist/es5/jsonl-loader.js +2 -0
  13. package/dist/{jsonl-loader.js.map → es5/jsonl-loader.js.map} +0 -0
  14. package/dist/{lib → es5/lib}/clarinet/LICENSE +0 -0
  15. package/dist/es5/lib/clarinet/clarinet.js +511 -0
  16. package/dist/es5/lib/clarinet/clarinet.js.map +1 -0
  17. package/dist/es5/lib/jsonpath/jsonpath.js +97 -0
  18. package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -0
  19. package/dist/es5/lib/parse-json-in-batches.js +99 -0
  20. package/dist/es5/lib/parse-json-in-batches.js.map +1 -0
  21. package/dist/es5/lib/parse-json.js +41 -0
  22. package/dist/es5/lib/parse-json.js.map +1 -0
  23. package/dist/es5/lib/parse-ndjson-in-batches.js +46 -0
  24. package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -0
  25. package/dist/es5/lib/parse-ndjson.js +18 -0
  26. package/dist/es5/lib/parse-ndjson.js.map +1 -0
  27. package/dist/es5/lib/parser/json-parser.js +137 -0
  28. package/dist/es5/lib/parser/json-parser.js.map +1 -0
  29. package/dist/es5/lib/parser/streaming-json-parser.js +102 -0
  30. package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -0
  31. package/dist/es5/ndjson-loader.js +45 -0
  32. package/dist/es5/ndjson-loader.js.map +1 -0
  33. package/dist/es5/workers/geojson-worker.js +8 -0
  34. package/dist/es5/workers/geojson-worker.js.map +1 -0
  35. package/dist/esm/bundle.js +5 -0
  36. package/dist/esm/bundle.js.map +1 -0
  37. package/dist/esm/geojson-loader.js +81 -0
  38. package/dist/esm/geojson-loader.js.map +1 -0
  39. package/dist/esm/index.js +6 -0
  40. package/dist/esm/index.js.map +1 -0
  41. package/dist/esm/json-loader.js +47 -0
  42. package/dist/esm/json-loader.js.map +1 -0
  43. package/dist/esm/jsonl-loader.js +2 -0
  44. package/dist/esm/jsonl-loader.js.map +1 -0
  45. package/dist/esm/lib/clarinet/LICENSE +28 -0
  46. package/dist/esm/lib/clarinet/clarinet.js +518 -0
  47. package/dist/esm/lib/clarinet/clarinet.js.map +1 -0
  48. package/dist/esm/lib/jsonpath/jsonpath.js +86 -0
  49. package/dist/esm/lib/jsonpath/jsonpath.js.map +1 -0
  50. package/dist/esm/lib/parse-json-in-batches.js +87 -0
  51. package/dist/esm/lib/parse-json-in-batches.js.map +1 -0
  52. package/dist/esm/lib/parse-json.js +34 -0
  53. package/dist/esm/lib/parse-json.js.map +1 -0
  54. package/dist/esm/lib/parse-ndjson-in-batches.js +37 -0
  55. package/dist/esm/lib/parse-ndjson-in-batches.js.map +1 -0
  56. package/dist/esm/lib/parse-ndjson.js +11 -0
  57. package/dist/esm/lib/parse-ndjson.js.map +1 -0
  58. package/dist/esm/lib/parser/json-parser.js +128 -0
  59. package/dist/esm/lib/parser/json-parser.js.map +1 -0
  60. package/dist/esm/lib/parser/streaming-json-parser.js +93 -0
  61. package/dist/esm/lib/parser/streaming-json-parser.js.map +1 -0
  62. package/dist/esm/ndjson-loader.js +32 -0
  63. package/dist/esm/ndjson-loader.js.map +1 -0
  64. package/dist/esm/workers/geojson-worker.js +4 -0
  65. package/dist/esm/workers/geojson-worker.js.map +1 -0
  66. package/dist/geojson-loader.d.ts +16 -0
  67. package/dist/geojson-loader.d.ts.map +1 -0
  68. package/dist/geojson-loader.js +66 -69
  69. package/dist/geojson-worker.js +1702 -2
  70. package/dist/index.d.ts +8 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +17 -6
  73. package/dist/json-loader.d.ts +14 -0
  74. package/dist/json-loader.d.ts.map +1 -0
  75. package/dist/json-loader.js +48 -38
  76. package/dist/jsonl-loader.d.ts +1 -0
  77. package/dist/jsonl-loader.d.ts.map +1 -0
  78. package/dist/jsonl-loader.js +53 -1
  79. package/dist/lib/clarinet/clarinet.d.ts +74 -0
  80. package/dist/lib/clarinet/clarinet.d.ts.map +1 -0
  81. package/dist/lib/clarinet/clarinet.js +517 -538
  82. package/dist/lib/jsonpath/jsonpath.d.ts +32 -0
  83. package/dist/lib/jsonpath/jsonpath.d.ts.map +1 -0
  84. package/dist/lib/jsonpath/jsonpath.js +81 -78
  85. package/dist/lib/parse-json-in-batches.d.ts +4 -0
  86. package/dist/lib/parse-json-in-batches.d.ts.map +1 -0
  87. package/dist/lib/parse-json-in-batches.js +75 -82
  88. package/dist/lib/parse-json.d.ts +3 -0
  89. package/dist/lib/parse-json.d.ts.map +1 -0
  90. package/dist/lib/parse-json.js +24 -29
  91. package/dist/lib/parse-ndjson-in-batches.d.ts +4 -0
  92. package/dist/lib/parse-ndjson-in-batches.d.ts.map +1 -0
  93. package/dist/lib/parse-ndjson-in-batches.js +32 -34
  94. package/dist/lib/parse-ndjson.d.ts +2 -0
  95. package/dist/lib/parse-ndjson.d.ts.map +1 -0
  96. package/dist/lib/parse-ndjson.js +13 -10
  97. package/dist/lib/parser/json-parser.d.ts +22 -0
  98. package/dist/lib/parser/json-parser.d.ts.map +1 -0
  99. package/dist/lib/parser/json-parser.js +95 -124
  100. package/dist/lib/parser/streaming-json-parser.d.ts +37 -0
  101. package/dist/lib/parser/streaming-json-parser.d.ts.map +1 -0
  102. package/dist/lib/parser/streaming-json-parser.js +95 -93
  103. package/dist/ndjson-loader.d.ts +22 -0
  104. package/dist/ndjson-loader.d.ts.map +1 -0
  105. package/dist/ndjson-loader.js +28 -23
  106. package/dist/workers/geojson-worker.d.ts +2 -0
  107. package/dist/workers/geojson-worker.d.ts.map +1 -0
  108. package/dist/workers/geojson-worker.js +5 -4
  109. package/package.json +10 -10
  110. package/src/lib/clarinet/clarinet.ts +539 -0
  111. package/src/lib/parser/json-parser.ts +52 -55
  112. package/src/lib/parser/streaming-json-parser.ts +28 -32
  113. package/src/ndjson-loader.ts +3 -1
  114. package/dist/bundle.js.map +0 -1
  115. package/dist/dist.min.js +0 -2
  116. package/dist/dist.min.js.map +0 -1
  117. package/dist/geojson-loader.js.map +0 -1
  118. package/dist/geojson-worker.js.map +0 -1
  119. package/dist/index.js.map +0 -1
  120. package/dist/json-loader.js.map +0 -1
  121. package/dist/lib/clarinet/clarinet.js.map +0 -1
  122. package/dist/lib/jsonpath/jsonpath.js.map +0 -1
  123. package/dist/lib/parse-json-in-batches.js.map +0 -1
  124. package/dist/lib/parse-json.js.map +0 -1
  125. package/dist/lib/parse-ndjson-in-batches.js.map +0 -1
  126. package/dist/lib/parse-ndjson.js.map +0 -1
  127. package/dist/lib/parser/json-parser.js.map +0 -1
  128. package/dist/lib/parser/streaming-json-parser.js.map +0 -1
  129. package/dist/ndjson-loader.js.map +0 -1
  130. package/dist/workers/geojson-worker.js.map +0 -1
  131. package/src/lib/clarinet/clarinet.js +0 -578
@@ -1,127 +1,98 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import ClarinetParser from '../clarinet/clarinet';
3
- import JSONPath from '../jsonpath/jsonpath';
4
- export default class JSONParser {
5
- constructor() {
6
- _defineProperty(this, "jsonpath", void 0);
7
-
8
- _defineProperty(this, "_parser", void 0);
9
-
10
- this.reset();
11
-
12
- this._initializeParser();
13
- }
14
-
15
- reset() {
16
- this.result = undefined;
17
- this.previousStates = [];
18
- this.currentState = Object.freeze({
19
- container: [],
20
- key: null
21
- });
22
- this.jsonpath = new JSONPath();
23
- }
24
-
25
- write(chunk) {
26
- this.parser.write(chunk);
27
- }
28
-
29
- close() {
30
- this.parser.close();
31
- }
32
-
33
- _pushOrSet(value) {
34
- const {
35
- container,
36
- key
37
- } = this.currentState;
38
-
39
- if (key !== null) {
40
- container[key] = value;
41
- this.currentState.key = null;
42
- } else {
43
- container.push(value);
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
+ });
44
53
  }
45
- }
46
-
47
- _openArray(newContainer = []) {
48
- this.jsonpath.push(null);
49
-
50
- this._pushOrSet(newContainer);
51
-
52
- this.previousStates.push(this.currentState);
53
- this.currentState = {
54
- container: newContainer,
55
- isArray: true,
56
- key: null
57
- };
58
- }
59
-
60
- _closeArray() {
61
- this.jsonpath.pop();
62
- this.currentState = this.previousStates.pop();
63
- }
64
-
65
- _openObject(newContainer = {}) {
66
- this.jsonpath.push(null);
67
-
68
- this._pushOrSet(newContainer);
69
-
70
- this.previousStates.push(this.currentState);
71
- this.currentState = {
72
- container: newContainer,
73
- isArray: false,
74
- key: null
75
- };
76
- }
77
-
78
- _closeObject() {
79
- this.jsonpath.pop();
80
- this.currentState = this.previousStates.pop();
81
- }
82
-
83
- _initializeParser() {
84
- this._parser = new ClarinetParser({
85
- onready: () => {
86
- this.jsonpath = new JSONPath();
87
- this.previousStates.length = 0;
88
- this.currentState.container.length = 0;
89
- },
90
- onopenobject: name => {
91
- this._openObject({});
92
-
93
- if (typeof name !== 'undefined') {
94
- this.parser.onkey(name);
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;
95
72
  }
96
- },
97
- onkey: name => {
98
- this.jsonpath.set(name);
99
- this.currentState.key = name;
100
- },
101
- oncloseobject: () => {
102
- this._closeObject();
103
- },
104
- onopenarray: () => {
105
- this._openArray();
106
- },
107
- onclosearray: () => {
108
- this._closeArray();
109
- },
110
- onvalue: value => {
111
- this._pushOrSet(value);
112
- },
113
- onerror: error => {
114
- throw error;
115
- },
116
- onend: () => {
117
- this.result = this.currentState.container.pop();
118
- }
119
- });
120
- }
121
-
122
- get parser() {
123
- return this._parser;
124
- }
125
-
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
+ }
126
97
  }
127
- //# sourceMappingURL=json-parser.js.map
98
+ exports.default = JSONParser;
@@ -0,0 +1,37 @@
1
+ import { default as JSONParser } from './json-parser';
2
+ import JSONPath from '../jsonpath/jsonpath';
3
+ /**
4
+ * The `StreamingJSONParser` looks for the first array in the JSON structure.
5
+ * and emits an array of chunks
6
+ */
7
+ export default class StreamingJSONParser extends JSONParser {
8
+ private jsonPaths;
9
+ private streamingJsonPath;
10
+ private streamingArray;
11
+ private topLevelObject;
12
+ constructor(options?: {
13
+ [key: string]: any;
14
+ });
15
+ /**
16
+ * write REDEFINITION
17
+ * - super.write() chunk to parser
18
+ * - get the contents (so far) of "topmost-level" array as batch of rows
19
+ * - clear top-level array
20
+ * - return the batch of rows\
21
+ */
22
+ write(chunk: any): any[];
23
+ /**
24
+ * Returns a partially formed result object
25
+ * Useful for returning the "wrapper" object when array is not top level
26
+ * e.g. GeoJSON
27
+ */
28
+ getPartialResult(): object | null;
29
+ getStreamingJsonPath(): JSONPath | null;
30
+ getStreamingJsonPathAsString(): string | null;
31
+ getJsonPath(): JSONPath;
32
+ /**
33
+ * Checks is this.getJsonPath matches the jsonpaths provided in options
34
+ */
35
+ _matchJSONPath(): boolean;
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"}
@@ -1,98 +1,100 @@
1
- import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { default as JSONParser } from './json-parser';
3
- import JSONPath from '../jsonpath/jsonpath';
4
- export default class StreamingJSONParser extends JSONParser {
5
- constructor(options = {}) {
6
- super();
7
-
8
- _defineProperty(this, "jsonPaths", void 0);
9
-
10
- _defineProperty(this, "streamingJsonPath", null);
11
-
12
- _defineProperty(this, "streamingArray", null);
13
-
14
- _defineProperty(this, "topLevelObject", null);
15
-
16
- const jsonpaths = options.jsonpaths || [];
17
- this.jsonPaths = jsonpaths.map(jsonpath => new JSONPath(jsonpath));
18
-
19
- this._extendParser();
20
- }
21
-
22
- write(chunk) {
23
- super.write(chunk);
24
- let array = [];
25
-
26
- if (this.streamingArray) {
27
- array = [...this.streamingArray];
28
- this.streamingArray.length = 0;
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));
29
46
  }
30
-
31
- return array;
32
- }
33
-
34
- getPartialResult() {
35
- return this.topLevelObject;
36
- }
37
-
38
- getStreamingJsonPath() {
39
- return this.streamingJsonPath;
40
- }
41
-
42
- getStreamingJsonPathAsString() {
43
- return this.streamingJsonPath && this.streamingJsonPath.toString();
44
- }
45
-
46
- getJsonPath() {
47
- return this.jsonpath;
48
- }
49
-
50
- _matchJSONPath() {
51
- const currentPath = this.getJsonPath();
52
-
53
- if (this.jsonPaths.length === 0) {
54
- return true;
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;
55
73
  }
56
-
57
- for (const jsonPath of this.jsonPaths) {
58
- if (jsonPath.equals(currentPath)) {
59
- return true;
60
- }
74
+ getStreamingJsonPathAsString() {
75
+ return this.streamingJsonPath && this.streamingJsonPath.toString();
61
76
  }
62
-
63
- return false;
64
- }
65
-
66
- _extendParser() {
67
- this.parser.onopenarray = () => {
68
- if (!this.streamingArray) {
69
- if (this._matchJSONPath()) {
70
- this.streamingJsonPath = this.getJsonPath().clone();
71
- this.streamingArray = [];
72
-
73
- this._openArray(this.streamingArray);
74
-
75
- return;
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
+ }
76
96
  }
77
- }
78
-
79
- this._openArray();
80
- };
81
-
82
- this.parser.onopenobject = name => {
83
- if (!this.topLevelObject) {
84
- this.topLevelObject = {};
85
-
86
- this._openObject(this.topLevelObject);
87
- } else {
88
- this._openObject({});
89
- }
90
-
91
- if (typeof name !== 'undefined') {
92
- this.parser.onkey(name);
93
- }
94
- };
95
- }
96
-
97
+ return false;
98
+ }
97
99
  }
98
- //# sourceMappingURL=streaming-json-parser.js.map
100
+ exports.default = StreamingJSONParser;
@@ -0,0 +1,22 @@
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"}
@@ -1,30 +1,35 @@
1
- import parseNDJSONSync from './lib/parse-ndjson';
2
- import parseNDJSONInBatches from './lib/parse-ndjson-in-batches';
3
- const VERSION = typeof "3.1.0-alpha.3" !== 'undefined' ? "3.1.0-alpha.3" : 'latest';
4
- export const NDJSONLoader = {
5
- name: 'NDJSON',
6
- id: 'ndjson',
7
- module: 'json',
8
- version: VERSION,
9
- extensions: ['ndjson'],
10
- mimeTypes: ['application/x-ndjson'],
11
- category: 'table',
12
- text: true,
13
- parse,
14
- parseTextSync,
15
- parseInBatches,
16
- options: {}
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: {}
17
25
  };
18
-
19
26
  async function parse(arrayBuffer) {
20
- return parseTextSync(new TextDecoder().decode(arrayBuffer));
27
+ return parseTextSync(new TextDecoder().decode(arrayBuffer));
21
28
  }
22
-
23
29
  function parseTextSync(text) {
24
- return parseNDJSONSync(text);
30
+ return (0, parse_ndjson_1.default)(text);
25
31
  }
26
-
27
32
  function parseInBatches(asyncIterator, options) {
28
- return parseNDJSONInBatches(asyncIterator, options);
33
+ return (0, parse_ndjson_in_batches_1.default)(asyncIterator, options);
29
34
  }
30
- //# sourceMappingURL=ndjson-loader.js.map
35
+ exports._typecheckNDJSONLoader = exports.NDJSONLoader;
@@ -0,0 +1,2 @@
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":""}
@@ -1,4 +1,5 @@
1
- import { createLoaderWorker } from '@loaders.gl/loader-utils';
2
- import { GeoJSONLoader } from '../geojson-loader';
3
- createLoaderWorker(GeoJSONLoader);
4
- //# sourceMappingURL=geojson-worker.js.map
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.3",
3
+ "version": "3.1.0-beta.2",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -20,9 +20,9 @@
20
20
  "JSON stream",
21
21
  "JSON async iterator"
22
22
  ],
23
- "types": "src/index.ts",
24
- "main": "dist/index.js",
25
- "module": "dist/index.js",
23
+ "types": "dist/index.d.ts",
24
+ "main": "dist/es5/index.js",
25
+ "module": "dist/esm/index.js",
26
26
  "sideEffects": false,
27
27
  "files": [
28
28
  "src",
@@ -31,13 +31,13 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "pre-build": "npm run build-bundle && npm run build-worker",
34
- "build-bundle": "webpack --config ../../scripts/webpack/bundle.js",
35
- "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"
36
36
  },
37
37
  "dependencies": {
38
- "@loaders.gl/gis": "3.1.0-alpha.3",
39
- "@loaders.gl/loader-utils": "3.1.0-alpha.3",
40
- "@loaders.gl/schema": "3.1.0-alpha.3"
38
+ "@loaders.gl/gis": "3.1.0-beta.2",
39
+ "@loaders.gl/loader-utils": "3.1.0-beta.2",
40
+ "@loaders.gl/schema": "3.1.0-beta.2"
41
41
  },
42
- "gitHead": "68e1c443d1b63aa2515436a7411ed0a029b42c15"
42
+ "gitHead": "90f487e7b3f15c554d57c92497d3a12d71676818"
43
43
  }