@loaders.gl/json 4.0.0-alpha.5 → 4.0.0-alpha.6
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/dist.min.js +643 -92
- package/dist/es5/bundle.js +6 -0
- package/dist/es5/bundle.js.map +1 -0
- package/dist/es5/geojson-loader.js +157 -0
- package/dist/es5/geojson-loader.js.map +1 -0
- package/dist/es5/geojson-writer.js +27 -0
- package/dist/es5/geojson-writer.js.map +1 -0
- package/dist/es5/index.js +69 -0
- package/dist/es5/index.js.map +1 -0
- package/dist/es5/json-loader.js +67 -0
- package/dist/es5/json-loader.js.map +1 -0
- package/dist/es5/json-writer.js +42 -0
- package/dist/es5/json-writer.js.map +1 -0
- package/dist/es5/lib/clarinet/clarinet.js +446 -0
- package/dist/es5/lib/clarinet/clarinet.js.map +1 -0
- package/dist/es5/lib/encoders/encode-utils.js +42 -0
- package/dist/es5/lib/encoders/encode-utils.js.map +1 -0
- package/dist/es5/lib/encoders/geojson-encoder.js +178 -0
- package/dist/es5/lib/encoders/geojson-encoder.js.map +1 -0
- package/dist/es5/lib/encoders/json-encoder.js +30 -0
- package/dist/es5/lib/encoders/json-encoder.js.map +1 -0
- package/dist/es5/lib/encoders/utf8-encoder.js +54 -0
- package/dist/es5/lib/encoders/utf8-encoder.js.map +1 -0
- package/dist/es5/lib/json-parser/json-parser.js +140 -0
- package/dist/es5/lib/json-parser/json-parser.js.map +1 -0
- package/dist/es5/lib/json-parser/streaming-json-parser.js +123 -0
- package/dist/es5/lib/json-parser/streaming-json-parser.js.map +1 -0
- package/dist/es5/lib/jsonpath/jsonpath.js +119 -0
- package/dist/es5/lib/jsonpath/jsonpath.js.map +1 -0
- package/dist/es5/lib/parsers/parse-json-in-batches.js +206 -0
- package/dist/es5/lib/parsers/parse-json-in-batches.js.map +1 -0
- package/dist/es5/lib/parsers/parse-json.js +38 -0
- package/dist/es5/lib/parsers/parse-json.js.map +1 -0
- package/dist/es5/lib/parsers/parse-ndjson-in-batches.js +114 -0
- package/dist/es5/lib/parsers/parse-ndjson-in-batches.js.map +1 -0
- package/dist/es5/lib/parsers/parse-ndjson.js +19 -0
- package/dist/es5/lib/parsers/parse-ndjson.js.map +1 -0
- package/dist/es5/ndgeoson-loader.js +54 -0
- package/dist/es5/ndgeoson-loader.js.map +1 -0
- package/dist/es5/ndjson-loader.js +44 -0
- package/dist/es5/ndjson-loader.js.map +1 -0
- package/dist/es5/workers/geojson-worker.js +6 -0
- package/dist/es5/workers/geojson-worker.js.map +1 -0
- package/dist/esm/bundle.js +4 -0
- package/dist/esm/bundle.js.map +1 -0
- package/dist/esm/geojson-loader.js +79 -0
- package/dist/esm/geojson-loader.js.map +1 -0
- package/dist/esm/geojson-writer.js +18 -0
- package/dist/esm/geojson-writer.js.map +1 -0
- package/dist/esm/index.js +9 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/json-loader.js +48 -0
- package/dist/esm/json-loader.js.map +1 -0
- package/dist/esm/json-writer.js +14 -0
- package/dist/esm/json-writer.js.map +1 -0
- package/dist/esm/lib/clarinet/LICENSE +28 -0
- package/dist/esm/lib/clarinet/clarinet.js +415 -0
- package/dist/esm/lib/clarinet/clarinet.js.map +1 -0
- package/dist/esm/lib/encoders/encode-utils.js +31 -0
- package/dist/esm/lib/encoders/encode-utils.js.map +1 -0
- package/dist/esm/lib/encoders/geojson-encoder.js +98 -0
- package/dist/esm/lib/encoders/geojson-encoder.js.map +1 -0
- package/dist/esm/lib/encoders/json-encoder.js +12 -0
- package/dist/esm/lib/encoders/json-encoder.js.map +1 -0
- package/dist/esm/lib/encoders/utf8-encoder.js +32 -0
- package/dist/esm/lib/encoders/utf8-encoder.js.map +1 -0
- package/dist/{lib/parser → esm/lib/json-parser}/json-parser.js +4 -22
- package/dist/esm/lib/json-parser/json-parser.js.map +1 -0
- package/dist/{lib/parser → esm/lib/json-parser}/streaming-json-parser.js +2 -23
- package/dist/esm/lib/json-parser/streaming-json-parser.js.map +1 -0
- package/dist/esm/lib/jsonpath/jsonpath.js +67 -0
- package/dist/esm/lib/jsonpath/jsonpath.js.map +1 -0
- package/dist/{lib → esm/lib/parsers}/parse-json-in-batches.js +5 -18
- package/dist/esm/lib/parsers/parse-json-in-batches.js.map +1 -0
- package/dist/{lib → esm/lib/parsers}/parse-json.js +4 -9
- package/dist/esm/lib/parsers/parse-json.js.map +1 -0
- package/dist/{lib → esm/lib/parsers}/parse-ndjson-in-batches.js +3 -6
- package/dist/esm/lib/parsers/parse-ndjson-in-batches.js.map +1 -0
- package/dist/esm/lib/parsers/parse-ndjson.js +13 -0
- package/dist/esm/lib/parsers/parse-ndjson.js.map +1 -0
- package/dist/esm/ndgeoson-loader.js +27 -0
- package/dist/esm/ndgeoson-loader.js.map +1 -0
- package/dist/esm/ndjson-loader.js +18 -0
- package/dist/esm/ndjson-loader.js.map +1 -0
- package/dist/esm/workers/geojson-worker.js +4 -0
- package/dist/esm/workers/geojson-worker.js.map +1 -0
- package/dist/geojson-loader.d.ts +2 -2
- package/dist/geojson-loader.d.ts.map +1 -1
- package/dist/geojson-loader.js +65 -69
- package/dist/geojson-worker.js +251 -68
- package/dist/geojson-writer.d.ts +6 -0
- package/dist/geojson-writer.d.ts.map +1 -0
- package/dist/geojson-writer.js +22 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +24 -7
- package/dist/json-loader.d.ts +10 -7
- package/dist/json-loader.d.ts.map +1 -1
- package/dist/json-loader.js +33 -38
- package/dist/json-writer.d.ts +6 -0
- package/dist/json-writer.d.ts.map +1 -0
- package/dist/json-writer.js +18 -0
- package/dist/lib/clarinet/clarinet.d.ts +3 -3
- package/dist/lib/clarinet/clarinet.d.ts.map +1 -1
- package/dist/lib/clarinet/clarinet.js +510 -493
- package/dist/lib/encoders/encode-utils.d.ts +19 -0
- package/dist/lib/encoders/encode-utils.d.ts.map +1 -0
- package/dist/lib/encoders/encode-utils.js +47 -0
- package/dist/lib/encoders/geojson-encoder.d.ts +14 -0
- package/dist/lib/encoders/geojson-encoder.d.ts.map +1 -0
- package/dist/lib/encoders/geojson-encoder.js +104 -0
- package/dist/lib/encoders/json-encoder.d.ts +16 -0
- package/dist/lib/encoders/json-encoder.d.ts.map +1 -0
- package/dist/lib/encoders/json-encoder.js +22 -0
- package/dist/lib/encoders/utf8-encoder.d.ts +12 -0
- package/dist/lib/encoders/utf8-encoder.d.ts.map +1 -0
- package/dist/lib/encoders/utf8-encoder.js +32 -0
- package/dist/lib/json-parser/json-parser.d.ts.map +1 -0
- package/dist/lib/json-parser/json-parser.js +98 -0
- package/dist/lib/json-parser/streaming-json-parser.d.ts.map +1 -0
- package/dist/lib/json-parser/streaming-json-parser.js +100 -0
- package/dist/lib/jsonpath/jsonpath.js +81 -78
- package/dist/lib/parsers/parse-json-in-batches.d.ts +5 -0
- package/dist/lib/parsers/parse-json-in-batches.d.ts.map +1 -0
- package/dist/lib/parsers/parse-json-in-batches.js +100 -0
- package/dist/lib/parsers/parse-json.d.ts +4 -0
- package/dist/lib/parsers/parse-json.d.ts.map +1 -0
- package/dist/lib/parsers/parse-json.js +32 -0
- package/dist/lib/{parse-ndjson-in-batches.d.ts → parsers/parse-ndjson-in-batches.d.ts} +1 -1
- package/dist/lib/parsers/parse-ndjson-in-batches.d.ts.map +1 -0
- package/dist/lib/parsers/parse-ndjson-in-batches.js +36 -0
- package/dist/lib/parsers/parse-ndjson.d.ts +3 -0
- package/dist/lib/parsers/parse-ndjson.d.ts.map +1 -0
- package/dist/lib/parsers/parse-ndjson.js +17 -0
- package/dist/ndgeoson-loader.d.ts +34 -0
- package/dist/ndgeoson-loader.d.ts.map +1 -0
- package/dist/ndgeoson-loader.js +37 -0
- package/dist/ndjson-loader.d.ts +3 -21
- package/dist/ndjson-loader.d.ts.map +1 -1
- package/dist/ndjson-loader.js +26 -31
- package/dist/workers/geojson-worker.js +5 -4
- package/package.json +7 -7
- package/src/geojson-loader.ts +10 -6
- package/src/geojson-writer.ts +27 -0
- package/src/index.ts +9 -1
- package/src/json-loader.ts +15 -24
- package/src/json-writer.ts +24 -0
- package/src/lib/encoders/encode-utils.ts +54 -0
- package/src/lib/encoders/geojson-encoder.ts +139 -0
- package/src/lib/encoders/json-encoder.ts +30 -0
- package/src/lib/encoders/utf8-encoder.ts +35 -0
- package/src/lib/{parse-json-in-batches.ts → parsers/parse-json-in-batches.ts} +8 -8
- package/src/lib/{parse-json.ts → parsers/parse-json.ts} +7 -3
- package/src/lib/{parse-ndjson-in-batches.ts → parsers/parse-ndjson-in-batches.ts} +1 -1
- package/src/lib/parsers/parse-ndjson.ts +15 -0
- package/src/ndgeoson-loader.ts +48 -0
- package/src/ndjson-loader.ts +20 -27
- package/dist/bundle.js.map +0 -1
- package/dist/geojson-loader.js.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/json-loader.js.map +0 -1
- package/dist/jsonl-loader.d.ts +0 -1
- package/dist/jsonl-loader.d.ts.map +0 -1
- package/dist/jsonl-loader.js +0 -2
- package/dist/jsonl-loader.js.map +0 -1
- package/dist/lib/clarinet/clarinet.js.map +0 -1
- package/dist/lib/jsonpath/jsonpath.js.map +0 -1
- package/dist/lib/parse-json-in-batches.d.ts +0 -5
- package/dist/lib/parse-json-in-batches.d.ts.map +0 -1
- package/dist/lib/parse-json-in-batches.js.map +0 -1
- package/dist/lib/parse-json.d.ts +0 -3
- package/dist/lib/parse-json.d.ts.map +0 -1
- package/dist/lib/parse-json.js.map +0 -1
- package/dist/lib/parse-ndjson-in-batches.d.ts.map +0 -1
- package/dist/lib/parse-ndjson-in-batches.js.map +0 -1
- package/dist/lib/parse-ndjson.d.ts +0 -2
- package/dist/lib/parse-ndjson.d.ts.map +0 -1
- package/dist/lib/parse-ndjson.js +0 -11
- package/dist/lib/parse-ndjson.js.map +0 -1
- package/dist/lib/parser/json-parser.d.ts.map +0 -1
- package/dist/lib/parser/json-parser.js.map +0 -1
- package/dist/lib/parser/streaming-json-parser.d.ts.map +0 -1
- package/dist/lib/parser/streaming-json-parser.js.map +0 -1
- package/dist/ndjson-loader.js.map +0 -1
- package/dist/workers/geojson-worker.js.map +0 -1
- package/src/jsonl-loader.ts +0 -53
- package/src/lib/parse-ndjson.ts +0 -10
- /package/dist/{lib → es5/lib}/clarinet/LICENSE +0 -0
- /package/dist/lib/{parser → json-parser}/json-parser.d.ts +0 -0
- /package/dist/lib/{parser → json-parser}/streaming-json-parser.d.ts +0 -0
- /package/src/lib/{parser → json-parser}/json-parser.ts +0 -0
- /package/src/lib/{parser → json-parser}/streaming-json-parser.ts +0 -0
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-json.d.ts","sourceRoot":"","sources":["../../src/lib/parse-json.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAEtD,MAAM,CAAC,OAAO,UAAU,aAAa,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,iBAAiB,OAUjF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/parse-json.ts"],"names":["parseJSONSync","jsonText","options","json","JSON","parse","table","getFirstArray","error","Error","Array","isArray","value","Object","values","array"],"mappings":"AAEA,eAAe,SAASA,aAAT,CAAuBC,QAAvB,EAAyCC,OAAzC,EAAqE;AAClF,MAAI;AAAA;;AACF,UAAMC,IAAI,GAAGC,IAAI,CAACC,KAAL,CAAWJ,QAAX,CAAb;;AACA,yBAAIC,OAAO,CAACC,IAAZ,0CAAI,cAAcG,KAAlB,EAAyB;AACvB,aAAOC,aAAa,CAACJ,IAAD,CAAb,IAAuBA,IAA9B;AACD;;AACD,WAAOA,IAAP;AACD,GAND,CAME,OAAOK,KAAP,EAAc;AACd,UAAM,IAAIC,KAAJ,CAAU,kCAAV,CAAN;AACD;AACF;;AAED,SAASF,aAAT,CAAuBJ,IAAvB,EAA6B;AAC3B,MAAIO,KAAK,CAACC,OAAN,CAAcR,IAAd,CAAJ,EAAyB;AACvB,WAAOA,IAAP;AACD;;AACD,MAAIA,IAAI,IAAI,OAAOA,IAAP,KAAgB,QAA5B,EAAsC;AACpC,SAAK,MAAMS,KAAX,IAAoBC,MAAM,CAACC,MAAP,CAAcX,IAAd,CAApB,EAAyC;AACvC,YAAMY,KAAK,GAAGR,aAAa,CAACK,KAAD,CAA3B;;AACA,UAAIG,KAAJ,EAAW;AACT,eAAOA,KAAP;AACD;AACF;AACF;;AACD,SAAO,IAAP;AACD","sourcesContent":["import type {JSONLoaderOptions} from '../json-loader';\n\nexport default function parseJSONSync(jsonText: string, options: JSONLoaderOptions) {\n try {\n const json = JSON.parse(jsonText);\n if (options.json?.table) {\n return getFirstArray(json) || json;\n }\n return json;\n } catch (error) {\n throw new Error('JSONLoader: failed to parse JSON');\n }\n}\n\nfunction getFirstArray(json) {\n if (Array.isArray(json)) {\n return json;\n }\n if (json && typeof json === 'object') {\n for (const value of Object.values(json)) {\n const array = getFirstArray(value);\n if (array) {\n return array;\n }\n }\n }\n return null;\n}\n"],"file":"parse-json.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-ndjson-in-batches.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ndjson-in-batches.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,KAAK,EAAC,MAAM,oBAAoB,CAAC;AAE9C,OAAO,EACL,aAAa,EAId,MAAM,0BAA0B,CAAC;AAElC,wBAA+B,oBAAoB,CACjD,mBAAmB,EAAE,aAAa,CAAC,WAAW,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,EACvE,OAAO,CAAC,EAAE,aAAa,GACtB,aAAa,CAAC,KAAK,CAAC,CA+BtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../src/lib/parse-ndjson-in-batches.ts"],"names":["TableBatchBuilder","makeLineIterator","makeNumberedLineIterator","makeTextDecoderIterator","parseNDJSONInBatches","binaryAsyncIterator","options","textIterator","lineIterator","numberedLineIterator","schema","shape","tableBatchBuilder","counter","line","row","JSON","parse","addRow","chunkComplete","batch","getFullBatch","error","Error","getFinalBatch"],"mappings":"AACA,SAAQA,iBAAR,QAAgC,oBAAhC;AACA,SAEEC,gBAFF,EAGEC,wBAHF,EAIEC,uBAJF,QAKO,0BALP;AAOA,eAAe,gBAAgBC,oBAAhB,CACbC,mBADa,EAEbC,OAFa,EAGS;AACtB,QAAMC,YAAY,GAAGJ,uBAAuB,CAACE,mBAAD,CAA5C;AACA,QAAMG,YAAY,GAAGP,gBAAgB,CAACM,YAAD,CAArC;AACA,QAAME,oBAAoB,GAAGP,wBAAwB,CAACM,YAAD,CAArD;AAEA,QAAME,MAAM,GAAG,IAAf;AACA,QAAMC,KAAK,GAAG,WAAd;AAEA,QAAMC,iBAAiB,GAAG,IAAIZ,iBAAJ,CAAsBU,MAAtB,EAA8B,EACtD,GAAGJ,OADmD;AAEtDK,IAAAA;AAFsD,GAA9B,CAA1B;;AAKA,aAAW,MAAM;AAACE,IAAAA,OAAD;AAAUC,IAAAA;AAAV,GAAjB,IAAoCL,oBAApC,EAA0D;AACxD,QAAI;AACF,YAAMM,GAAG,GAAGC,IAAI,CAACC,KAAL,CAAWH,IAAX,CAAZ;AACAF,MAAAA,iBAAiB,CAACM,MAAlB,CAAyBH,GAAzB;AACAH,MAAAA,iBAAiB,CAACO,aAAlB,CAAgCL,IAAhC;AACA,YAAMM,KAAK,GAAGR,iBAAiB,CAACS,YAAlB,EAAd;;AACA,UAAID,KAAJ,EAAW;AACT,cAAMA,KAAN;AACD;AACF,KARD,CAQE,OAAOE,KAAP,EAAc;AACd,YAAM,IAAIC,KAAJ,sDAAwDV,OAAxD,EAAN;AACD;AACF;;AAED,QAAMO,KAAK,GAAGR,iBAAiB,CAACY,aAAlB,EAAd;;AACA,MAAIJ,KAAJ,EAAW;AACT,UAAMA,KAAN;AACD;AACF","sourcesContent":["import type {Batch} from '@loaders.gl/schema';\nimport {TableBatchBuilder} from '@loaders.gl/schema';\nimport {\n LoaderOptions,\n makeLineIterator,\n makeNumberedLineIterator,\n makeTextDecoderIterator\n} from '@loaders.gl/loader-utils';\n\nexport default async function* parseNDJSONInBatches(\n binaryAsyncIterator: AsyncIterable<ArrayBuffer> | Iterable<ArrayBuffer>,\n options?: LoaderOptions\n): AsyncIterable<Batch> {\n const textIterator = makeTextDecoderIterator(binaryAsyncIterator);\n const lineIterator = makeLineIterator(textIterator);\n const numberedLineIterator = makeNumberedLineIterator(lineIterator);\n\n const schema = null;\n const shape = 'row-table';\n // @ts-ignore\n const tableBatchBuilder = new TableBatchBuilder(schema, {\n ...options,\n shape\n });\n\n for await (const {counter, line} of numberedLineIterator) {\n try {\n const row = JSON.parse(line);\n tableBatchBuilder.addRow(row);\n tableBatchBuilder.chunkComplete(line);\n const batch = tableBatchBuilder.getFullBatch();\n if (batch) {\n yield batch;\n }\n } catch (error) {\n throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter}`);\n }\n }\n\n const batch = tableBatchBuilder.getFinalBatch();\n if (batch) {\n yield batch;\n }\n}\n"],"file":"parse-ndjson-in-batches.js"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"parse-ndjson.d.ts","sourceRoot":"","sources":["../../src/lib/parse-ndjson.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,OAAO,UAAU,eAAe,CAAC,UAAU,EAAE,MAAM,SASzD"}
|
package/dist/lib/parse-ndjson.js
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export default function parseNDJSONSync(ndjsonText) {
|
|
2
|
-
const lines = ndjsonText.trim().split('\n');
|
|
3
|
-
return lines.map((line, counter) => {
|
|
4
|
-
try {
|
|
5
|
-
return JSON.parse(line);
|
|
6
|
-
} catch (error) {
|
|
7
|
-
throw new Error("NDJSONLoader: failed to parse JSON on line ".concat(counter + 1));
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
//# 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":"AAAA,eAAe,SAASA,eAAT,CAAyBC,UAAzB,EAA6C;AAC1D,QAAMC,KAAK,GAAGD,UAAU,CAACE,IAAX,GAAkBC,KAAlB,CAAwB,IAAxB,CAAd;AACA,SAAOF,KAAK,CAACG,GAAN,CAAU,CAACC,IAAD,EAAOC,OAAP,KAAmB;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 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json-parser.d.ts","sourceRoot":"","sources":["../../../src/lib/parser/json-parser.ts"],"names":[],"mappings":"AAEA,OAAO,cAAc,EAAE,EAAC,qBAAqB,EAAC,MAAM,sBAAsB,CAAC;AAC3E,OAAO,QAAQ,MAAM,sBAAsB,CAAC;AAI5C,MAAM,CAAC,OAAO,OAAO,UAAU;IAC7B,QAAQ,CAAC,MAAM,EAAE,cAAc,CAAC;IAChC,MAAM,YAAa;IACnB,cAAc,UAAM;IACpB,YAAY;;;OAA6C;IACzD,QAAQ,EAAE,QAAQ,CAAkB;gBAExB,OAAO,EAAE,qBAAqB;IAiD1C,KAAK,IAAI,IAAI;IAOb,KAAK,CAAC,KAAK,KAAA,GAAG,IAAI;IAIlB,KAAK,IAAI,IAAI;IAMb,UAAU,CAAC,KAAK,KAAA,GAAG,IAAI;IAUvB,UAAU,CAAC,YAAY,UAAK,GAAG,IAAI;IAOnC,WAAW,IAAI,IAAI;IAKnB,WAAW,CAAC,YAAY,KAAK,GAAG,IAAI;IAOpC,YAAY,IAAI,IAAI;CAIrB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/parser/json-parser.ts"],"names":["ClarinetParser","JSONPath","JSONParser","constructor","options","undefined","Object","freeze","container","key","reset","parser","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","write","chunk","close","push","newContainer","isArray"],"mappings":";AAEA,OAAOA,cAAP,MAAoD,sBAApD;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAIA,eAAe,MAAMC,UAAN,CAAiB;AAO9BC,EAAAA,WAAW,CAACC,OAAD,EAAiC;AAAA;;AAAA,oCALnCC,SAKmC;;AAAA,4CAJ3B,EAI2B;;AAAA,0CAH7BC,MAAM,CAACC,MAAP,CAAc;AAACC,MAAAA,SAAS,EAAE,EAAZ;AAAgBC,MAAAA,GAAG,EAAE;AAArB,KAAd,CAG6B;;AAAA,sCAFvB,IAAIR,QAAJ,EAEuB;;AAC1C,SAAKS,KAAL;AACA,SAAKC,MAAL,GAAc,IAAIX,cAAJ,CAAmB;AAC/BY,MAAAA,OAAO,EAAE,MAAM;AACb,aAAKC,QAAL,GAAgB,IAAIZ,QAAJ,EAAhB;AACA,aAAKa,cAAL,CAAoBC,MAApB,GAA6B,CAA7B;AACA,aAAKC,YAAL,CAAkBR,SAAlB,CAA4BO,MAA5B,GAAqC,CAArC;AACD,OAL8B;AAO/BE,MAAAA,YAAY,EAAGC,IAAD,IAAU;AACtB,aAAKC,WAAL,CAAiB,EAAjB;;AACA,YAAI,OAAOD,IAAP,KAAgB,W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AL,CAAoBsB,GAApB,EAApB;AACD;;AAzG6B","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 +0,0 @@
|
|
|
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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/parser/streaming-json-parser.ts"],"names":["default","JSONParser","JSONPath","StreamingJSONParser","constructor","options","onopenarray","streamingArray","_matchJSONPath","streamingJsonPath","getJsonPath","clone","_openArray","onopenobject","name","topLevelObject","_openObject","parser","emit","jsonpaths","jsonPaths","map","jsonpath","write","chunk","array","length","getPartialResult","getStreamingJsonPath","getStreamingJsonPathAsString","toString","currentPath","jsonPath","equals"],"mappings":";AAAA,SAAQA,OAAO,IAAIC,UAAnB,QAAoC,eAApC;AACA,OAAOC,QAAP,MAAqB,sBAArB;AAMA,eAAe,MAAMC,mBAAN,SAAkCF,UAAlC,CAA6C;AAM1DG,EAAA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BAAgB,GAAG;AACjB,WAAO,KAAKZ,cAAZ;AACD;;AAEDa,EAAAA,oBAAoB,GAAG;AACrB,WAAO,KAAKnB,iBAAZ;AACD;;AAEDoB,EAAAA,4BAA4B,GAAG;AAC7B,WAAO,KAAKpB,iBAAL,IAA0B,KAAKA,iBAAL,CAAuBqB,QAAvB,EAAjC;AACD;;AAEDpB,EAAAA,WAAW,GAAG;AACZ,WAAO,KAAKY,QAAZ;AACD;;AAODd,EAAAA,cAAc,GAAG;AACf,UAAMuB,WAAW,GAAG,KAAKrB,WAAL,EAApB;;AAKA,QAAI,KAAKU,SAAL,CAAeM,MAAf,KAA0B,CAA9B,EAAiC;AAC/B,aAAO,IAAP;AACD;;AAED,SAAK,MAAMM,QAAX,IAAuB,KAAKZ,SAA5B,EAAuC;AACrC,UAAIY,QAAQ,CAACC,MAAT,CAAgBF,WAAhB,CAAJ,EAAkC;AAChC,eAAO,IAAP;AACD;AACF;;AAED,WAAO,KAAP;AACD;;AAnGyD","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 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/ndjson-loader.ts"],"names":["parseNDJSONSync","parseNDJSONInBatches","VERSION","NDJSONLoader","name","id","module","version","extensions","mimeTypes","category","text","parse","parseTextSync","parseInBatches","options","arrayBuffer","TextDecoder","decode","asyncIterator","_typecheckNDJSONLoader"],"mappings":"AAEA,OAAOA,eAAP,MAA4B,oBAA5B;AACA,OAAOC,oBAAP,MAAiC,+BAAjC;AAIA,MAAMC,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,QAAnE;AAEA,OAAO,MAAMC,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,KAT0B;AAU1BC,EAAAA,aAV0B;AAW1BC,EAAAA,cAX0B;AAY1BC,EAAAA,OAAO,EAAE;AAZiB,CAArB;;AAeP,eAAeH,KAAf,CAAqBI,WAArB,EAA+C;AAC7C,SAAOH,aAAa,CAAC,IAAII,WAAJ,GAAkBC,MAAlB,CAAyBF,WAAzB,CAAD,CAApB;AACD;;AAED,SAASH,aAAT,CAAuBF,IAAvB,EAAqC;AACnC,SAAOX,eAAe,CAACW,IAAD,CAAtB;AACD;;AAED,SAASG,cAAT,CACEK,aADF,EAEEJ,OAFF,EAGwB;AACtB,SAAOd,oBAAoB,CAACkB,aAAD,EAAgBJ,OAAhB,CAA3B;AACD;;AAED,OAAO,MAAMK,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":["createLoaderWorker","GeoJSONLoader"],"mappings":"AAAA,SAAQA,kBAAR,QAAiC,0BAAjC;AACA,SAAQC,aAAR,QAA4B,mBAA5B;AAEAD,kBAAkB,CAACC,aAAD,CAAlB","sourcesContent":["import {createLoaderWorker} from '@loaders.gl/loader-utils';\nimport {GeoJSONLoader} from '../geojson-loader';\n\ncreateLoaderWorker(GeoJSONLoader);\n"],"file":"geojson-worker.js"}
|
package/src/jsonl-loader.ts
DELETED
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
/* TODO JSONL loader
|
|
2
|
-
export const JSONLoader: LoaderWithParser = {
|
|
3
|
-
name: 'JSON',
|
|
4
|
-
id: 'json',
|
|
5
|
-
module: 'json',
|
|
6
|
-
version: VERSION,
|
|
7
|
-
extensions: ['json', 'geojson'],
|
|
8
|
-
mimeTypes: ['application/json'],
|
|
9
|
-
// TODO - support various line based JSON formats
|
|
10
|
-
/*
|
|
11
|
-
extensions: {
|
|
12
|
-
json: null,
|
|
13
|
-
jsonl: {stream: true},
|
|
14
|
-
ndjson: {stream: true}
|
|
15
|
-
},
|
|
16
|
-
mimeTypes: {
|
|
17
|
-
'application/json': null,
|
|
18
|
-
'application/json-seq': {stream: true},
|
|
19
|
-
'application/x-ndjson': {stream: true}
|
|
20
|
-
},
|
|
21
|
-
*
|
|
22
|
-
category: 'table',
|
|
23
|
-
text: true,
|
|
24
|
-
parse,
|
|
25
|
-
parseTextSync,
|
|
26
|
-
parseInBatches,
|
|
27
|
-
options: DEFAULT_JSON_LOADER_OPTIONS
|
|
28
|
-
};
|
|
29
|
-
{
|
|
30
|
-
name: 'TEST-JSONL_LOADER',
|
|
31
|
-
extensions: ['jsonl'],
|
|
32
|
-
parse: async (arrayBuffer, options, context) => {
|
|
33
|
-
const characters = new Uint8Array(arrayBuffer);
|
|
34
|
-
const result = [];
|
|
35
|
-
|
|
36
|
-
const len = characters.length;
|
|
37
|
-
let startIndex = 0;
|
|
38
|
-
for (let i = 0; i <= len; i++) {
|
|
39
|
-
if (characters[i] === 10 || i === len) {
|
|
40
|
-
// Note: we need to make a copy of the buffer here because we cannot
|
|
41
|
-
// handover the ownership of arrayBuffer to the child process
|
|
42
|
-
const json = characters.slice(startIndex, i);
|
|
43
|
-
if (json.length > 1) {
|
|
44
|
-
result.push(await context.parse(json.buffer, {}, 'line.json'));
|
|
45
|
-
}
|
|
46
|
-
startIndex = i + 1;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
return result;
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
*/
|
package/src/lib/parse-ndjson.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export default function parseNDJSONSync(ndjsonText: string) {
|
|
2
|
-
const lines = ndjsonText.trim().split('\n');
|
|
3
|
-
return lines.map((line, counter) => {
|
|
4
|
-
try {
|
|
5
|
-
return JSON.parse(line);
|
|
6
|
-
} catch (error) {
|
|
7
|
-
throw new Error(`NDJSONLoader: failed to parse JSON on line ${counter + 1}`);
|
|
8
|
-
}
|
|
9
|
-
});
|
|
10
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|