@loaders.gl/json 3.1.0-alpha.4 → 3.1.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.
Files changed (51) hide show
  1. package/dist/bundle.d.ts +1 -0
  2. package/dist/dist.min.js +1 -1
  3. package/dist/es5/bundle.js +1 -1
  4. package/dist/es5/bundle.js.map +1 -1
  5. package/dist/es5/geojson-loader.js +29 -143
  6. package/dist/es5/geojson-loader.js.map +1 -1
  7. package/dist/es5/index.js +6 -6
  8. package/dist/es5/json-loader.js +18 -44
  9. package/dist/es5/json-loader.js.map +1 -1
  10. package/dist/es5/lib/clarinet/clarinet.js +373 -393
  11. package/dist/es5/lib/clarinet/clarinet.js.map +1 -1
  12. package/dist/es5/lib/jsonpath/jsonpath.js +54 -101
  13. package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -1
  14. package/dist/es5/lib/parse-json-in-batches.js +78 -237
  15. package/dist/es5/lib/parse-json-in-batches.js.map +1 -1
  16. package/dist/es5/lib/parse-json.js +4 -9
  17. package/dist/es5/lib/parse-json.js.map +1 -1
  18. package/dist/es5/lib/parse-ndjson-in-batches.js +31 -143
  19. package/dist/es5/lib/parse-ndjson-in-batches.js.map +1 -1
  20. package/dist/es5/lib/parse-ndjson.js +2 -2
  21. package/dist/es5/lib/parse-ndjson.js.map +1 -1
  22. package/dist/es5/lib/parser/json-parser.js +112 -133
  23. package/dist/es5/lib/parser/json-parser.js.map +1 -1
  24. package/dist/es5/lib/parser/streaming-json-parser.js +65 -125
  25. package/dist/es5/lib/parser/streaming-json-parser.js.map +1 -1
  26. package/dist/es5/ndjson-loader.js +7 -29
  27. package/dist/es5/ndjson-loader.js.map +1 -1
  28. package/dist/esm/geojson-loader.js +1 -1
  29. package/dist/esm/json-loader.js +1 -1
  30. package/dist/esm/lib/parse-ndjson-in-batches.js +1 -1
  31. package/dist/esm/lib/parse-ndjson-in-batches.js.map +1 -1
  32. package/dist/esm/lib/parse-ndjson.js +1 -1
  33. package/dist/esm/lib/parse-ndjson.js.map +1 -1
  34. package/dist/esm/ndjson-loader.js +1 -1
  35. package/dist/geojson-loader.d.ts +15 -0
  36. package/dist/geojson-worker.js +1 -1
  37. package/dist/geojson-worker.js.map +1 -1
  38. package/dist/index.d.ts +7 -0
  39. package/dist/json-loader.d.ts +13 -0
  40. package/dist/jsonl-loader.d.ts +0 -0
  41. package/dist/lib/clarinet/clarinet.d.ts +40 -0
  42. package/dist/lib/jsonpath/jsonpath.d.ts +31 -0
  43. package/dist/lib/parse-json-in-batches.d.ts +3 -0
  44. package/dist/lib/parse-json.d.ts +2 -0
  45. package/dist/lib/parse-ndjson-in-batches.d.ts +3 -0
  46. package/dist/lib/parse-ndjson.d.ts +1 -0
  47. package/dist/lib/parser/json-parser.d.ts +17 -0
  48. package/dist/lib/parser/streaming-json-parser.d.ts +37 -0
  49. package/dist/ndjson-loader.d.ts +2 -0
  50. package/dist/workers/geojson-worker.d.ts +1 -0
  51. package/package.json +7 -6
@@ -0,0 +1,7 @@
1
+ export type { JSONLoaderOptions } from './json-loader';
2
+ export { JSONLoader } from './json-loader';
3
+ export { NDJSONLoader } from './ndjson-loader';
4
+ export type { GeoJSONLoaderOptions as _GeoJSONLoaderOptions } from './geojson-loader';
5
+ export { GeoJSONLoader as _GeoJSONLoader, GeoJSONWorkerLoader as _GeoJSONWorkerLoader } from './geojson-loader';
6
+ export { default as _JSONPath } from './lib/jsonpath/jsonpath';
7
+ export { default as _ClarinetParser } from './lib/clarinet/clarinet';
@@ -0,0 +1,13 @@
1
+ import type { LoaderWithParser, LoaderOptions } from '@loaders.gl/loader-utils';
2
+ /**
3
+ * @param table -
4
+ * @param jsonpaths -
5
+ */
6
+ export declare type JSONLoaderOptions = LoaderOptions & {
7
+ json?: {
8
+ shape?: 'row-table';
9
+ table?: false;
10
+ jsonpaths?: string[];
11
+ };
12
+ };
13
+ export declare const JSONLoader: LoaderWithParser;
File without changes
@@ -0,0 +1,40 @@
1
+ export const EVENTS: string[];
2
+ export default class ClarinetParser {
3
+ constructor(options?: {});
4
+ _initialize(options: any): void;
5
+ bufferCheckPosition: number | undefined;
6
+ q: string | undefined;
7
+ c: any;
8
+ p: any;
9
+ options: any;
10
+ closed: boolean | undefined;
11
+ closedRoot: boolean | undefined;
12
+ sawRoot: boolean | undefined;
13
+ tag: any;
14
+ error: any;
15
+ state: any;
16
+ stack: any[] | undefined;
17
+ position: number | undefined;
18
+ column: number | undefined;
19
+ line: number | undefined;
20
+ slashed: any;
21
+ unicodeI: any;
22
+ unicodeS: string | null | undefined;
23
+ depth: number | undefined;
24
+ onready: any;
25
+ onopenobject: any;
26
+ onkey: any;
27
+ oncloseobject: any;
28
+ onopenarray: any;
29
+ onclosearray: any;
30
+ onvalue: any;
31
+ onerror: any;
32
+ onend: any;
33
+ onchunkparsed: any;
34
+ _clearBuffers(): void;
35
+ end(): ClarinetParser;
36
+ resume(): ClarinetParser;
37
+ close(): any;
38
+ write(chunk: any): any;
39
+ textNode: string | undefined;
40
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * A parser for a minimal subset of the jsonpath standard
3
+ * Full JSON path parsers for JS exist but are quite large (bundle size)
4
+ *
5
+ * Supports
6
+ *
7
+ * `$.component.component.component`
8
+ */
9
+ export default class JSONPath {
10
+ path: string[];
11
+ constructor(path?: JSONPath | string[] | string | null);
12
+ clone(): JSONPath;
13
+ toString(): string;
14
+ push(name: string): void;
15
+ pop(): string | undefined;
16
+ set(name: string): void;
17
+ equals(other: JSONPath): boolean;
18
+ /**
19
+ * Sets the value pointed at by path
20
+ * TODO - handle root path
21
+ * @param object
22
+ * @param value
23
+ */
24
+ setFieldAtPath(object: any, value: any): void;
25
+ /**
26
+ * Gets the value pointed at by path
27
+ * TODO - handle root path
28
+ * @param object
29
+ */
30
+ getFieldAtPath(object: any): any;
31
+ }
@@ -0,0 +1,3 @@
1
+ import type { Batch } from '@loaders.gl/schema';
2
+ import type { JSONLoaderOptions } from '../json-loader';
3
+ export default function parseJSONInBatches(binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options: JSONLoaderOptions): AsyncIterable<Batch>;
@@ -0,0 +1,2 @@
1
+ import type { JSONLoaderOptions } from '../json-loader';
2
+ export default function parseJSONSync(jsonText: string, options: JSONLoaderOptions): any;
@@ -0,0 +1,3 @@
1
+ import type { Batch } from '@loaders.gl/schema';
2
+ import { LoaderOptions } from '@loaders.gl/loader-utils';
3
+ export default function parseNDJSONInBatches(binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>, options?: LoaderOptions): AsyncIterable<Batch>;
@@ -0,0 +1 @@
1
+ export default function parseNDJSONSync(ndjsonText: string): any[];
@@ -0,0 +1,17 @@
1
+ import ClarinetParser from '../clarinet/clarinet';
2
+ import JSONPath from '../jsonpath/jsonpath';
3
+ export default class JSONParser {
4
+ jsonpath: JSONPath;
5
+ _parser?: ClarinetParser;
6
+ constructor();
7
+ reset(): void;
8
+ write(chunk: any): void;
9
+ close(): void;
10
+ _pushOrSet(value: any): void;
11
+ _openArray(newContainer?: never[]): void;
12
+ _closeArray(): void;
13
+ _openObject(newContainer?: {}): void;
14
+ _closeObject(): void;
15
+ _initializeParser(): void;
16
+ protected get parser(): ClarinetParser;
17
+ }
@@ -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
+ _extendParser(): void;
37
+ }
@@ -0,0 +1,2 @@
1
+ import type { LoaderWithParser } from '@loaders.gl/loader-utils';
2
+ export declare const NDJSONLoader: LoaderWithParser;
@@ -0,0 +1 @@
1
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/json",
3
- "version": "3.1.0-alpha.4",
3
+ "version": "3.1.0-alpha.5",
4
4
  "description": "Framework-independent loader for JSON and streaming JSON formats",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -20,7 +20,7 @@
20
20
  "JSON stream",
21
21
  "JSON async iterator"
22
22
  ],
23
- "types": "src/index.ts",
23
+ "types": "dist/index.d.ts",
24
24
  "main": "dist/es5/index.js",
25
25
  "module": "dist/esm/index.js",
26
26
  "sideEffects": false,
@@ -31,13 +31,14 @@
31
31
  ],
32
32
  "scripts": {
33
33
  "pre-build": "npm run build-bundle && npm run build-worker",
34
+ "post-build": "tsc",
34
35
  "build-bundle": "webpack --config ../../scripts/webpack/bundle.js",
35
36
  "build-worker": "webpack --entry ./src/workers/geojson-worker.ts --output ./dist/geojson-worker.js --config ../../scripts/webpack/worker.js"
36
37
  },
37
38
  "dependencies": {
38
- "@loaders.gl/gis": "3.1.0-alpha.4",
39
- "@loaders.gl/loader-utils": "3.1.0-alpha.4",
40
- "@loaders.gl/schema": "3.1.0-alpha.4"
39
+ "@loaders.gl/gis": "3.1.0-alpha.5",
40
+ "@loaders.gl/loader-utils": "3.1.0-alpha.5",
41
+ "@loaders.gl/schema": "3.1.0-alpha.5"
41
42
  },
42
- "gitHead": "e309784af37ef9f3640c7733c7851124c72e1fa3"
43
+ "gitHead": "352241dd910a8c6307a235dadbe154ca915b885b"
43
44
  }