@loaders.gl/mvt 4.0.1 → 4.0.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.
- package/dist/mvt-worker.js +32 -24
- package/package.json +6 -6
package/dist/mvt-worker.js
CHANGED
|
@@ -2303,7 +2303,7 @@
|
|
|
2303
2303
|
}
|
|
2304
2304
|
|
|
2305
2305
|
// src/mvt-loader.ts
|
|
2306
|
-
var VERSION = true ? "4.0.
|
|
2306
|
+
var VERSION = true ? "4.0.2" : "latest";
|
|
2307
2307
|
var MVTWorkerLoader = {
|
|
2308
2308
|
name: "Mapbox Vector Tile",
|
|
2309
2309
|
id: "mvt",
|
|
@@ -2372,61 +2372,69 @@
|
|
|
2372
2372
|
}
|
|
2373
2373
|
|
|
2374
2374
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
2375
|
-
function getParentPort() {
|
|
2375
|
+
async function getParentPort() {
|
|
2376
2376
|
let parentPort;
|
|
2377
2377
|
try {
|
|
2378
2378
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
2379
2379
|
parentPort = globalThis.parentPort;
|
|
2380
2380
|
} catch {
|
|
2381
|
+
try {
|
|
2382
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
2383
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
2384
|
+
parentPort = workerThreads.parentPort;
|
|
2385
|
+
} catch (error) {
|
|
2386
|
+
console.error(error.message);
|
|
2387
|
+
}
|
|
2381
2388
|
}
|
|
2382
2389
|
return parentPort;
|
|
2383
2390
|
}
|
|
2384
2391
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
2385
2392
|
var WorkerBody = class {
|
|
2386
2393
|
/** Check that we are actually in a worker thread */
|
|
2387
|
-
static inWorkerThread() {
|
|
2388
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
2394
|
+
static async inWorkerThread() {
|
|
2395
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
2389
2396
|
}
|
|
2390
2397
|
/*
|
|
2391
2398
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
2392
2399
|
*/
|
|
2393
2400
|
static set onmessage(onMessage) {
|
|
2394
|
-
function handleMessage(message) {
|
|
2395
|
-
const
|
|
2396
|
-
const { type, payload } =
|
|
2401
|
+
async function handleMessage(message) {
|
|
2402
|
+
const parentPort2 = await getParentPort();
|
|
2403
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
2397
2404
|
onMessage(type, payload);
|
|
2398
2405
|
}
|
|
2399
|
-
|
|
2400
|
-
|
|
2401
|
-
|
|
2402
|
-
|
|
2403
|
-
|
|
2404
|
-
|
|
2405
|
-
|
|
2406
|
+
getParentPort().then((parentPort2) => {
|
|
2407
|
+
if (parentPort2) {
|
|
2408
|
+
parentPort2.on("message", handleMessage);
|
|
2409
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
2410
|
+
} else {
|
|
2411
|
+
globalThis.onmessage = handleMessage;
|
|
2412
|
+
}
|
|
2413
|
+
});
|
|
2406
2414
|
}
|
|
2407
|
-
static addEventListener(onMessage) {
|
|
2415
|
+
static async addEventListener(onMessage) {
|
|
2408
2416
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
2409
2417
|
if (!onMessageWrapper) {
|
|
2410
|
-
onMessageWrapper = (message) => {
|
|
2418
|
+
onMessageWrapper = async (message) => {
|
|
2411
2419
|
if (!isKnownMessage(message)) {
|
|
2412
2420
|
return;
|
|
2413
2421
|
}
|
|
2414
|
-
const parentPort3 = getParentPort();
|
|
2422
|
+
const parentPort3 = await getParentPort();
|
|
2415
2423
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
2416
2424
|
onMessage(type, payload);
|
|
2417
2425
|
};
|
|
2418
2426
|
}
|
|
2419
|
-
const parentPort2 = getParentPort();
|
|
2427
|
+
const parentPort2 = await getParentPort();
|
|
2420
2428
|
if (parentPort2) {
|
|
2421
2429
|
console.error("not implemented");
|
|
2422
2430
|
} else {
|
|
2423
2431
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
2424
2432
|
}
|
|
2425
2433
|
}
|
|
2426
|
-
static removeEventListener(onMessage) {
|
|
2434
|
+
static async removeEventListener(onMessage) {
|
|
2427
2435
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
2428
2436
|
onMessageWrapperMap.delete(onMessage);
|
|
2429
|
-
const parentPort2 = getParentPort();
|
|
2437
|
+
const parentPort2 = await getParentPort();
|
|
2430
2438
|
if (parentPort2) {
|
|
2431
2439
|
console.error("not implemented");
|
|
2432
2440
|
} else {
|
|
@@ -2438,10 +2446,10 @@
|
|
|
2438
2446
|
* @param type
|
|
2439
2447
|
* @param payload
|
|
2440
2448
|
*/
|
|
2441
|
-
static postMessage(type, payload) {
|
|
2449
|
+
static async postMessage(type, payload) {
|
|
2442
2450
|
const data = { source: "loaders.gl", type, payload };
|
|
2443
2451
|
const transferList = getTransferList(payload);
|
|
2444
|
-
const parentPort2 = getParentPort();
|
|
2452
|
+
const parentPort2 = await getParentPort();
|
|
2445
2453
|
if (parentPort2) {
|
|
2446
2454
|
parentPort2.postMessage(data, transferList);
|
|
2447
2455
|
} else {
|
|
@@ -2456,8 +2464,8 @@
|
|
|
2456
2464
|
|
|
2457
2465
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
2458
2466
|
var requestId = 0;
|
|
2459
|
-
function createLoaderWorker(loader) {
|
|
2460
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
2467
|
+
async function createLoaderWorker(loader) {
|
|
2468
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
2461
2469
|
return;
|
|
2462
2470
|
}
|
|
2463
2471
|
WorkerBody.onmessage = async (type, payload) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/mvt",
|
|
3
3
|
"description": "Loader for Mapbox Vector Tiles",
|
|
4
|
-
"version": "4.0.
|
|
4
|
+
"version": "4.0.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"publishConfig": {
|
|
@@ -40,15 +40,15 @@
|
|
|
40
40
|
"build-worker": "esbuild src/workers/mvt-worker.ts --bundle --outfile=dist/mvt-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
41
41
|
},
|
|
42
42
|
"dependencies": {
|
|
43
|
-
"@loaders.gl/gis": "4.0.
|
|
44
|
-
"@loaders.gl/images": "4.0.
|
|
45
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
46
|
-
"@loaders.gl/schema": "4.0.
|
|
43
|
+
"@loaders.gl/gis": "4.0.2",
|
|
44
|
+
"@loaders.gl/images": "4.0.2",
|
|
45
|
+
"@loaders.gl/loader-utils": "4.0.2",
|
|
46
|
+
"@loaders.gl/schema": "4.0.2",
|
|
47
47
|
"@math.gl/polygon": "^4.0.0",
|
|
48
48
|
"pbf": "^3.2.1"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/pbf": "^3.0.2"
|
|
52
52
|
},
|
|
53
|
-
"gitHead": "
|
|
53
|
+
"gitHead": "471058d109d5652f28c32c1f296fd632f9a5c806"
|
|
54
54
|
}
|