@loaders.gl/json 4.0.1 → 4.0.3
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/geojson-worker.js +32 -24
- package/dist/geojson-writer.d.ts +2 -2
- package/dist/geojson-writer.d.ts.map +1 -1
- package/dist/geojson-writer.js.map +1 -1
- package/dist/json-writer.d.ts +2 -2
- package/dist/json-writer.d.ts.map +1 -1
- package/dist/json-writer.js.map +1 -1
- package/package.json +5 -5
- package/src/geojson-writer.ts +2 -2
- package/src/json-writer.ts +2 -2
package/dist/geojson-worker.js
CHANGED
|
@@ -36,61 +36,69 @@
|
|
|
36
36
|
}
|
|
37
37
|
|
|
38
38
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
39
|
-
function getParentPort() {
|
|
39
|
+
async function getParentPort() {
|
|
40
40
|
let parentPort;
|
|
41
41
|
try {
|
|
42
42
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
43
43
|
parentPort = globalThis.parentPort;
|
|
44
44
|
} catch {
|
|
45
|
+
try {
|
|
46
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
47
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
48
|
+
parentPort = workerThreads.parentPort;
|
|
49
|
+
} catch (error) {
|
|
50
|
+
console.error(error.message);
|
|
51
|
+
}
|
|
45
52
|
}
|
|
46
53
|
return parentPort;
|
|
47
54
|
}
|
|
48
55
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
49
56
|
var WorkerBody = class {
|
|
50
57
|
/** Check that we are actually in a worker thread */
|
|
51
|
-
static inWorkerThread() {
|
|
52
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
58
|
+
static async inWorkerThread() {
|
|
59
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
53
60
|
}
|
|
54
61
|
/*
|
|
55
62
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
56
63
|
*/
|
|
57
64
|
static set onmessage(onMessage) {
|
|
58
|
-
function handleMessage(message) {
|
|
59
|
-
const
|
|
60
|
-
const { type, payload } =
|
|
65
|
+
async function handleMessage(message) {
|
|
66
|
+
const parentPort2 = await getParentPort();
|
|
67
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
61
68
|
onMessage(type, payload);
|
|
62
69
|
}
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
+
getParentPort().then((parentPort2) => {
|
|
71
|
+
if (parentPort2) {
|
|
72
|
+
parentPort2.on("message", handleMessage);
|
|
73
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
74
|
+
} else {
|
|
75
|
+
globalThis.onmessage = handleMessage;
|
|
76
|
+
}
|
|
77
|
+
});
|
|
70
78
|
}
|
|
71
|
-
static addEventListener(onMessage) {
|
|
79
|
+
static async addEventListener(onMessage) {
|
|
72
80
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
73
81
|
if (!onMessageWrapper) {
|
|
74
|
-
onMessageWrapper = (message) => {
|
|
82
|
+
onMessageWrapper = async (message) => {
|
|
75
83
|
if (!isKnownMessage(message)) {
|
|
76
84
|
return;
|
|
77
85
|
}
|
|
78
|
-
const parentPort3 = getParentPort();
|
|
86
|
+
const parentPort3 = await getParentPort();
|
|
79
87
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
80
88
|
onMessage(type, payload);
|
|
81
89
|
};
|
|
82
90
|
}
|
|
83
|
-
const parentPort2 = getParentPort();
|
|
91
|
+
const parentPort2 = await getParentPort();
|
|
84
92
|
if (parentPort2) {
|
|
85
93
|
console.error("not implemented");
|
|
86
94
|
} else {
|
|
87
95
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
88
96
|
}
|
|
89
97
|
}
|
|
90
|
-
static removeEventListener(onMessage) {
|
|
98
|
+
static async removeEventListener(onMessage) {
|
|
91
99
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
92
100
|
onMessageWrapperMap.delete(onMessage);
|
|
93
|
-
const parentPort2 = getParentPort();
|
|
101
|
+
const parentPort2 = await getParentPort();
|
|
94
102
|
if (parentPort2) {
|
|
95
103
|
console.error("not implemented");
|
|
96
104
|
} else {
|
|
@@ -102,10 +110,10 @@
|
|
|
102
110
|
* @param type
|
|
103
111
|
* @param payload
|
|
104
112
|
*/
|
|
105
|
-
static postMessage(type, payload) {
|
|
113
|
+
static async postMessage(type, payload) {
|
|
106
114
|
const data = { source: "loaders.gl", type, payload };
|
|
107
115
|
const transferList = getTransferList(payload);
|
|
108
|
-
const parentPort2 = getParentPort();
|
|
116
|
+
const parentPort2 = await getParentPort();
|
|
109
117
|
if (parentPort2) {
|
|
110
118
|
parentPort2.postMessage(data, transferList);
|
|
111
119
|
} else {
|
|
@@ -120,8 +128,8 @@
|
|
|
120
128
|
|
|
121
129
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
122
130
|
var requestId = 0;
|
|
123
|
-
function createLoaderWorker(loader) {
|
|
124
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
131
|
+
async function createLoaderWorker(loader) {
|
|
132
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
125
133
|
return;
|
|
126
134
|
}
|
|
127
135
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -2417,7 +2425,7 @@ Char: ${this.c}`;
|
|
|
2417
2425
|
}
|
|
2418
2426
|
|
|
2419
2427
|
// src/geojson-loader.ts
|
|
2420
|
-
var VERSION = true ? "4.0.
|
|
2428
|
+
var VERSION = true ? "4.0.3" : "latest";
|
|
2421
2429
|
var GeoJSONWorkerLoader = {
|
|
2422
2430
|
name: "GeoJSON",
|
|
2423
2431
|
id: "geojson",
|
package/dist/geojson-writer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { Table, TableBatch } from '@loaders.gl/schema';
|
|
3
3
|
export type GeoJSONWriterOptions = WriterOptions & {
|
|
4
4
|
geojson?: {
|
|
@@ -7,5 +7,5 @@ export type GeoJSONWriterOptions = WriterOptions & {
|
|
|
7
7
|
};
|
|
8
8
|
chunkSize?: number;
|
|
9
9
|
};
|
|
10
|
-
export declare const GeoJSONWriter:
|
|
10
|
+
export declare const GeoJSONWriter: WriterWithEncoder<Table, TableBatch, GeoJSONWriterOptions>;
|
|
11
11
|
//# sourceMappingURL=geojson-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-writer.d.ts","sourceRoot":"","sources":["../src/geojson-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"geojson-writer.d.ts","sourceRoot":"","sources":["../src/geojson-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG1D,MAAM,MAAM,oBAAoB,GAAG,aAAa,GAAG;IACjD,OAAO,CAAC,EAAE;QACR,YAAY,CAAC,EAAE,OAAO,CAAC;QACvB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;KAChC,CAAC;IACF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,eAAO,MAAM,aAAa,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,oBAAoB,CAgBpF,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"geojson-writer.js","names":["encodeTableAsGeojsonInBatches","GeoJSONWriter","id","version","module","name","extensions","mimeTypes","options","geojson","featureArray","geometryColumn","text","encodeInBatches","tableIterator"],"sources":["../src/geojson-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n// Copyright Foursquare, Inc 20222\n\nimport type {
|
|
1
|
+
{"version":3,"file":"geojson-writer.js","names":["encodeTableAsGeojsonInBatches","GeoJSONWriter","id","version","module","name","extensions","mimeTypes","options","geojson","featureArray","geometryColumn","text","encodeInBatches","tableIterator"],"sources":["../src/geojson-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n// Copyright Foursquare, Inc 20222\n\nimport type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {Table, TableBatch} from '@loaders.gl/schema';\nimport {encodeTableAsGeojsonInBatches} from './lib/encoders/geojson-encoder';\n\nexport type GeoJSONWriterOptions = WriterOptions & {\n geojson?: {\n featureArray?: boolean;\n geometryColumn?: number | null;\n };\n chunkSize?: number;\n};\n\nexport const GeoJSONWriter: WriterWithEncoder<Table, TableBatch, GeoJSONWriterOptions> = {\n id: 'geojson',\n version: 'latest',\n module: 'geojson',\n name: 'GeoJSON',\n extensions: ['geojson'],\n mimeTypes: ['application/geo+json'],\n options: {\n geojson: {\n featureArray: false,\n geometryColumn: null\n }\n },\n text: true,\n encodeInBatches: (tableIterator: AsyncIterable<TableBatch>, options) =>\n encodeTableAsGeojsonInBatches(tableIterator, options)\n};\n"],"mappings":"SAMQA,6BAA6B;AAUrC,OAAO,MAAMC,aAAyE,GAAG;EACvFC,EAAE,EAAE,SAAS;EACbC,OAAO,EAAE,QAAQ;EACjBC,MAAM,EAAE,SAAS;EACjBC,IAAI,EAAE,SAAS;EACfC,UAAU,EAAE,CAAC,SAAS,CAAC;EACvBC,SAAS,EAAE,CAAC,sBAAsB,CAAC;EACnCC,OAAO,EAAE;IACPC,OAAO,EAAE;MACPC,YAAY,EAAE,KAAK;MACnBC,cAAc,EAAE;IAClB;EACF,CAAC;EACDC,IAAI,EAAE,IAAI;EACVC,eAAe,EAAEA,CAACC,aAAwC,EAAEN,OAAO,KACjER,6BAA6B,CAACc,aAAa,EAAEN,OAAO;AACxD,CAAC"}
|
package/dist/json-writer.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
|
|
2
2
|
import type { Table, TableBatch } from '@loaders.gl/schema';
|
|
3
3
|
export type JSONWriterOptions = WriterOptions & {
|
|
4
4
|
json?: {
|
|
@@ -11,6 +11,6 @@ type RowObject = {
|
|
|
11
11
|
[key: string]: unknown;
|
|
12
12
|
};
|
|
13
13
|
type TableJSON = RowArray[] | RowObject[];
|
|
14
|
-
export declare const JSONWriter:
|
|
14
|
+
export declare const JSONWriter: WriterWithEncoder<Table, TableBatch, JSONWriterOptions>;
|
|
15
15
|
export {};
|
|
16
16
|
//# sourceMappingURL=json-writer.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-writer.d.ts","sourceRoot":"","sources":["../src/json-writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,
|
|
1
|
+
{"version":3,"file":"json-writer.d.ts","sourceRoot":"","sources":["../src/json-writer.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAC/E,OAAO,KAAK,EAAC,KAAK,EAAE,UAAU,EAAC,MAAM,oBAAoB,CAAC;AAG1D,MAAM,MAAM,iBAAiB,GAAG,aAAa,GAAG;IAC9C,IAAI,CAAC,EAAE;QACL,KAAK,CAAC,EAAE,kBAAkB,GAAG,iBAAiB,CAAC;QAC/C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,SAAS,KAAK,OAAO,CAAC;KACzC,CAAC;CACH,CAAC;AAEF,KAAK,QAAQ,GAAG,OAAO,EAAE,CAAC;AAC1B,KAAK,SAAS,GAAG;IAAC,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAA;CAAC,CAAC;AAC1C,KAAK,SAAS,GAAG,QAAQ,EAAE,GAAG,SAAS,EAAE,CAAC;AAE1C,eAAO,MAAM,UAAU,EAAE,iBAAiB,CAAC,KAAK,EAAE,UAAU,EAAE,iBAAiB,CAY9E,CAAC"}
|
package/dist/json-writer.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"json-writer.js","names":["encodeTableAsJSON","JSONWriter","id","version","module","name","extensions","mimeTypes","options","text","encode","table","TextEncoder","buffer","encodeTextSync"],"sources":["../src/json-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\n\n/* global TextEncoder */\nimport type {
|
|
1
|
+
{"version":3,"file":"json-writer.js","names":["encodeTableAsJSON","JSONWriter","id","version","module","name","extensions","mimeTypes","options","text","encode","table","TextEncoder","buffer","encodeTextSync"],"sources":["../src/json-writer.ts"],"sourcesContent":["// loaders.gl, MIT license\n// Copyright (c) vis.gl contributors\n// Copyright 2022 Foursquare Labs, Inc.\n\n/* global TextEncoder */\nimport type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';\nimport type {Table, TableBatch} from '@loaders.gl/schema';\nimport {encodeTableAsJSON} from './lib/encoders/json-encoder';\n\nexport type JSONWriterOptions = WriterOptions & {\n json?: {\n shape?: 'object-row-table' | 'array-row-table';\n wrapper?: (table: TableJSON) => unknown;\n };\n};\n\ntype RowArray = unknown[];\ntype RowObject = {[key: string]: unknown};\ntype TableJSON = RowArray[] | RowObject[];\n\nexport const JSONWriter: WriterWithEncoder<Table, TableBatch, JSONWriterOptions> = {\n id: 'json',\n version: 'latest',\n module: 'json',\n name: 'JSON',\n extensions: ['json'],\n mimeTypes: ['application/json'],\n options: {},\n text: true,\n encode: async (table: Table, options: JSONWriterOptions) =>\n new TextEncoder().encode(encodeTableAsJSON(table, options)).buffer,\n encodeTextSync: (table: Table, options: JSONWriterOptions) => encodeTableAsJSON(table, options)\n};\n"],"mappings":"SAOQA,iBAAiB;AAazB,OAAO,MAAMC,UAAmE,GAAG;EACjFC,EAAE,EAAE,MAAM;EACVC,OAAO,EAAE,QAAQ;EACjBC,MAAM,EAAE,MAAM;EACdC,IAAI,EAAE,MAAM;EACZC,UAAU,EAAE,CAAC,MAAM,CAAC;EACpBC,SAAS,EAAE,CAAC,kBAAkB,CAAC;EAC/BC,OAAO,EAAE,CAAC,CAAC;EACXC,IAAI,EAAE,IAAI;EACVC,MAAM,EAAE,MAAAA,CAAOC,KAAY,EAAEH,OAA0B,KACrD,IAAII,WAAW,CAAC,CAAC,CAACF,MAAM,CAACV,iBAAiB,CAACW,KAAK,EAAEH,OAAO,CAAC,CAAC,CAACK,MAAM;EACpEC,cAAc,EAAEA,CAACH,KAAY,EAAEH,OAA0B,KAAKR,iBAAiB,CAACW,KAAK,EAAEH,OAAO;AAChG,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/json",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Framework-independent loader for JSON and streaming JSON formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -43,9 +43,9 @@
|
|
|
43
43
|
"build-worker": "esbuild src/workers/geojson-worker.ts --bundle --outfile=dist/geojson-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
44
44
|
},
|
|
45
45
|
"dependencies": {
|
|
46
|
-
"@loaders.gl/gis": "4.0.
|
|
47
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
48
|
-
"@loaders.gl/schema": "4.0.
|
|
46
|
+
"@loaders.gl/gis": "4.0.3",
|
|
47
|
+
"@loaders.gl/loader-utils": "4.0.3",
|
|
48
|
+
"@loaders.gl/schema": "4.0.3"
|
|
49
49
|
},
|
|
50
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "03c871839b36c997249dabae1844df53a35d3760"
|
|
51
51
|
}
|
package/src/geojson-writer.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
// Copyright (c) vis.gl contributors
|
|
3
3
|
// Copyright Foursquare, Inc 20222
|
|
4
4
|
|
|
5
|
-
import type {
|
|
5
|
+
import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
6
6
|
import type {Table, TableBatch} from '@loaders.gl/schema';
|
|
7
7
|
import {encodeTableAsGeojsonInBatches} from './lib/encoders/geojson-encoder';
|
|
8
8
|
|
|
@@ -14,7 +14,7 @@ export type GeoJSONWriterOptions = WriterOptions & {
|
|
|
14
14
|
chunkSize?: number;
|
|
15
15
|
};
|
|
16
16
|
|
|
17
|
-
export const GeoJSONWriter:
|
|
17
|
+
export const GeoJSONWriter: WriterWithEncoder<Table, TableBatch, GeoJSONWriterOptions> = {
|
|
18
18
|
id: 'geojson',
|
|
19
19
|
version: 'latest',
|
|
20
20
|
module: 'geojson',
|
package/src/json-writer.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// Copyright 2022 Foursquare Labs, Inc.
|
|
4
4
|
|
|
5
5
|
/* global TextEncoder */
|
|
6
|
-
import type {
|
|
6
|
+
import type {WriterWithEncoder, WriterOptions} from '@loaders.gl/loader-utils';
|
|
7
7
|
import type {Table, TableBatch} from '@loaders.gl/schema';
|
|
8
8
|
import {encodeTableAsJSON} from './lib/encoders/json-encoder';
|
|
9
9
|
|
|
@@ -18,7 +18,7 @@ type RowArray = unknown[];
|
|
|
18
18
|
type RowObject = {[key: string]: unknown};
|
|
19
19
|
type TableJSON = RowArray[] | RowObject[];
|
|
20
20
|
|
|
21
|
-
export const JSONWriter:
|
|
21
|
+
export const JSONWriter: WriterWithEncoder<Table, TableBatch, JSONWriterOptions> = {
|
|
22
22
|
id: 'json',
|
|
23
23
|
version: 'latest',
|
|
24
24
|
module: 'json',
|