@loaders.gl/las 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/las-worker.js +32 -24
- package/package.json +4 -4
package/dist/las-worker.js
CHANGED
|
@@ -53,61 +53,69 @@
|
|
|
53
53
|
}
|
|
54
54
|
|
|
55
55
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
56
|
-
function getParentPort() {
|
|
56
|
+
async function getParentPort() {
|
|
57
57
|
let parentPort;
|
|
58
58
|
try {
|
|
59
59
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
60
60
|
parentPort = globalThis.parentPort;
|
|
61
61
|
} catch {
|
|
62
|
+
try {
|
|
63
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
64
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
65
|
+
parentPort = workerThreads.parentPort;
|
|
66
|
+
} catch (error) {
|
|
67
|
+
console.error(error.message);
|
|
68
|
+
}
|
|
62
69
|
}
|
|
63
70
|
return parentPort;
|
|
64
71
|
}
|
|
65
72
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
66
73
|
var WorkerBody = class {
|
|
67
74
|
/** Check that we are actually in a worker thread */
|
|
68
|
-
static inWorkerThread() {
|
|
69
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
75
|
+
static async inWorkerThread() {
|
|
76
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
70
77
|
}
|
|
71
78
|
/*
|
|
72
79
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
73
80
|
*/
|
|
74
81
|
static set onmessage(onMessage) {
|
|
75
|
-
function handleMessage(message) {
|
|
76
|
-
const
|
|
77
|
-
const { type, payload } =
|
|
82
|
+
async function handleMessage(message) {
|
|
83
|
+
const parentPort2 = await getParentPort();
|
|
84
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
78
85
|
onMessage(type, payload);
|
|
79
86
|
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
+
getParentPort().then((parentPort2) => {
|
|
88
|
+
if (parentPort2) {
|
|
89
|
+
parentPort2.on("message", handleMessage);
|
|
90
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
91
|
+
} else {
|
|
92
|
+
globalThis.onmessage = handleMessage;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
87
95
|
}
|
|
88
|
-
static addEventListener(onMessage) {
|
|
96
|
+
static async addEventListener(onMessage) {
|
|
89
97
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
90
98
|
if (!onMessageWrapper) {
|
|
91
|
-
onMessageWrapper = (message) => {
|
|
99
|
+
onMessageWrapper = async (message) => {
|
|
92
100
|
if (!isKnownMessage(message)) {
|
|
93
101
|
return;
|
|
94
102
|
}
|
|
95
|
-
const parentPort3 = getParentPort();
|
|
103
|
+
const parentPort3 = await getParentPort();
|
|
96
104
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
97
105
|
onMessage(type, payload);
|
|
98
106
|
};
|
|
99
107
|
}
|
|
100
|
-
const parentPort2 = getParentPort();
|
|
108
|
+
const parentPort2 = await getParentPort();
|
|
101
109
|
if (parentPort2) {
|
|
102
110
|
console.error("not implemented");
|
|
103
111
|
} else {
|
|
104
112
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
|
-
static removeEventListener(onMessage) {
|
|
115
|
+
static async removeEventListener(onMessage) {
|
|
108
116
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
109
117
|
onMessageWrapperMap.delete(onMessage);
|
|
110
|
-
const parentPort2 = getParentPort();
|
|
118
|
+
const parentPort2 = await getParentPort();
|
|
111
119
|
if (parentPort2) {
|
|
112
120
|
console.error("not implemented");
|
|
113
121
|
} else {
|
|
@@ -119,10 +127,10 @@
|
|
|
119
127
|
* @param type
|
|
120
128
|
* @param payload
|
|
121
129
|
*/
|
|
122
|
-
static postMessage(type, payload) {
|
|
130
|
+
static async postMessage(type, payload) {
|
|
123
131
|
const data = { source: "loaders.gl", type, payload };
|
|
124
132
|
const transferList = getTransferList(payload);
|
|
125
|
-
const parentPort2 = getParentPort();
|
|
133
|
+
const parentPort2 = await getParentPort();
|
|
126
134
|
if (parentPort2) {
|
|
127
135
|
parentPort2.postMessage(data, transferList);
|
|
128
136
|
} else {
|
|
@@ -137,8 +145,8 @@
|
|
|
137
145
|
|
|
138
146
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
139
147
|
var requestId = 0;
|
|
140
|
-
function createLoaderWorker(loader) {
|
|
141
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
148
|
+
async function createLoaderWorker(loader) {
|
|
149
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
142
150
|
return;
|
|
143
151
|
}
|
|
144
152
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -217,7 +225,7 @@
|
|
|
217
225
|
}
|
|
218
226
|
|
|
219
227
|
// src/las-loader.ts
|
|
220
|
-
var VERSION = true ? "4.0.
|
|
228
|
+
var VERSION = true ? "4.0.3" : "latest";
|
|
221
229
|
var DEFAULT_LAS_OPTIONS = {
|
|
222
230
|
las: {
|
|
223
231
|
shape: "mesh",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/las",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.3",
|
|
4
4
|
"description": "Framework-independent loader for the LAS and LAZ formats",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -49,9 +49,9 @@
|
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"@babel/runtime": "^7.3.1",
|
|
52
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
53
|
-
"@loaders.gl/schema": "4.0.
|
|
52
|
+
"@loaders.gl/loader-utils": "4.0.3",
|
|
53
|
+
"@loaders.gl/schema": "4.0.3",
|
|
54
54
|
"laz-perf": "^0.0.6"
|
|
55
55
|
},
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "03c871839b36c997249dabae1844df53a35d3760"
|
|
57
57
|
}
|