@loaders.gl/textures 4.0.0 → 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/basis-worker-node.js +36 -28
- package/dist/basis-worker.js +35 -27
- package/dist/compressed-texture-worker.js +35 -27
- package/dist/compressed-texture-writer.d.ts.map +1 -1
- package/dist/compressed-texture-writer.js +4 -1
- package/dist/compressed-texture-writer.js.map +1 -1
- package/dist/crunch-worker.js +35 -27
- package/dist/dist.dev.js +6 -3
- package/dist/index.cjs +4 -1
- package/dist/ktx2-basis-writer-worker-node.js +36 -28
- package/dist/ktx2-basis-writer-worker.js +35 -27
- package/dist/npy-worker.js +32 -24
- package/dist/workers/ktx2-basis-writer-worker-node.js +2 -2
- package/dist/workers/ktx2-basis-writer-worker-node.js.map +1 -1
- package/dist/workers/ktx2-basis-writer-worker.js +2 -2
- package/dist/workers/ktx2-basis-writer-worker.js.map +1 -1
- package/package.json +7 -7
- package/src/compressed-texture-writer.ts +4 -1
- package/src/workers/ktx2-basis-writer-worker-node.ts +2 -2
- package/src/workers/ktx2-basis-writer-worker.ts +2 -2
|
@@ -63885,7 +63885,7 @@ function getVersion() {
|
|
|
63885
63885
|
);
|
|
63886
63886
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
63887
63887
|
} else {
|
|
63888
|
-
globalThis._loadersgl_.version = "4.0.
|
|
63888
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
63889
63889
|
}
|
|
63890
63890
|
}
|
|
63891
63891
|
return globalThis._loadersgl_.version;
|
|
@@ -63955,61 +63955,69 @@ function isTransferable(object) {
|
|
|
63955
63955
|
}
|
|
63956
63956
|
|
|
63957
63957
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
63958
|
-
function getParentPort() {
|
|
63958
|
+
async function getParentPort() {
|
|
63959
63959
|
let parentPort;
|
|
63960
63960
|
try {
|
|
63961
63961
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
63962
63962
|
parentPort = globalThis.parentPort;
|
|
63963
63963
|
} catch {
|
|
63964
|
+
try {
|
|
63965
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
63966
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
63967
|
+
parentPort = workerThreads.parentPort;
|
|
63968
|
+
} catch (error) {
|
|
63969
|
+
console.error(error.message);
|
|
63970
|
+
}
|
|
63964
63971
|
}
|
|
63965
63972
|
return parentPort;
|
|
63966
63973
|
}
|
|
63967
63974
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
63968
63975
|
var WorkerBody = class {
|
|
63969
63976
|
/** Check that we are actually in a worker thread */
|
|
63970
|
-
static inWorkerThread() {
|
|
63971
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
63977
|
+
static async inWorkerThread() {
|
|
63978
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
63972
63979
|
}
|
|
63973
63980
|
/*
|
|
63974
63981
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
63975
63982
|
*/
|
|
63976
63983
|
static set onmessage(onMessage) {
|
|
63977
|
-
function handleMessage(message) {
|
|
63978
|
-
const
|
|
63979
|
-
const { type, payload } =
|
|
63984
|
+
async function handleMessage(message) {
|
|
63985
|
+
const parentPort2 = await getParentPort();
|
|
63986
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
63980
63987
|
onMessage(type, payload);
|
|
63981
63988
|
}
|
|
63982
|
-
|
|
63983
|
-
|
|
63984
|
-
|
|
63985
|
-
|
|
63986
|
-
|
|
63987
|
-
|
|
63988
|
-
|
|
63989
|
+
getParentPort().then((parentPort2) => {
|
|
63990
|
+
if (parentPort2) {
|
|
63991
|
+
parentPort2.on("message", handleMessage);
|
|
63992
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
63993
|
+
} else {
|
|
63994
|
+
globalThis.onmessage = handleMessage;
|
|
63995
|
+
}
|
|
63996
|
+
});
|
|
63989
63997
|
}
|
|
63990
|
-
static addEventListener(onMessage) {
|
|
63998
|
+
static async addEventListener(onMessage) {
|
|
63991
63999
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
63992
64000
|
if (!onMessageWrapper) {
|
|
63993
|
-
onMessageWrapper = (message) => {
|
|
64001
|
+
onMessageWrapper = async (message) => {
|
|
63994
64002
|
if (!isKnownMessage(message)) {
|
|
63995
64003
|
return;
|
|
63996
64004
|
}
|
|
63997
|
-
const parentPort3 = getParentPort();
|
|
64005
|
+
const parentPort3 = await getParentPort();
|
|
63998
64006
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
63999
64007
|
onMessage(type, payload);
|
|
64000
64008
|
};
|
|
64001
64009
|
}
|
|
64002
|
-
const parentPort2 = getParentPort();
|
|
64010
|
+
const parentPort2 = await getParentPort();
|
|
64003
64011
|
if (parentPort2) {
|
|
64004
64012
|
console.error("not implemented");
|
|
64005
64013
|
} else {
|
|
64006
64014
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
64007
64015
|
}
|
|
64008
64016
|
}
|
|
64009
|
-
static removeEventListener(onMessage) {
|
|
64017
|
+
static async removeEventListener(onMessage) {
|
|
64010
64018
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
64011
64019
|
onMessageWrapperMap.delete(onMessage);
|
|
64012
|
-
const parentPort2 = getParentPort();
|
|
64020
|
+
const parentPort2 = await getParentPort();
|
|
64013
64021
|
if (parentPort2) {
|
|
64014
64022
|
console.error("not implemented");
|
|
64015
64023
|
} else {
|
|
@@ -64021,10 +64029,10 @@ var WorkerBody = class {
|
|
|
64021
64029
|
* @param type
|
|
64022
64030
|
* @param payload
|
|
64023
64031
|
*/
|
|
64024
|
-
static postMessage(type, payload) {
|
|
64032
|
+
static async postMessage(type, payload) {
|
|
64025
64033
|
const data = { source: "loaders.gl", type, payload };
|
|
64026
64034
|
const transferList = getTransferList(payload);
|
|
64027
|
-
const parentPort2 = getParentPort();
|
|
64035
|
+
const parentPort2 = await getParentPort();
|
|
64028
64036
|
if (parentPort2) {
|
|
64029
64037
|
parentPort2.postMessage(data, transferList);
|
|
64030
64038
|
} else {
|
|
@@ -64073,7 +64081,7 @@ async function requireFromFile(filename) {
|
|
|
64073
64081
|
if (!filename.startsWith("/")) {
|
|
64074
64082
|
filename = `${process.cwd()}/${filename}`;
|
|
64075
64083
|
}
|
|
64076
|
-
const code = await fs.
|
|
64084
|
+
const code = await fs.promises.readFile(filename, "utf8");
|
|
64077
64085
|
return requireFromString(code);
|
|
64078
64086
|
}
|
|
64079
64087
|
function requireFromString(code, filename = "", options) {
|
|
@@ -64164,14 +64172,14 @@ function loadLibraryFromString(scriptSource, id) {
|
|
|
64164
64172
|
return null;
|
|
64165
64173
|
}
|
|
64166
64174
|
async function loadAsArrayBuffer(url) {
|
|
64167
|
-
if (!readFileAsArrayBuffer || url.startsWith("http")) {
|
|
64175
|
+
if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
64168
64176
|
const response = await fetch(url);
|
|
64169
64177
|
return await response.arrayBuffer();
|
|
64170
64178
|
}
|
|
64171
64179
|
return await readFileAsArrayBuffer(url);
|
|
64172
64180
|
}
|
|
64173
64181
|
async function loadAsText(url) {
|
|
64174
|
-
if (!readFileAsText || url.startsWith("http")) {
|
|
64182
|
+
if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
|
|
64175
64183
|
const response = await fetch(url);
|
|
64176
64184
|
return await response.text();
|
|
64177
64185
|
}
|
|
@@ -64180,8 +64188,8 @@ async function loadAsText(url) {
|
|
|
64180
64188
|
|
|
64181
64189
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
64182
64190
|
var requestId = 0;
|
|
64183
|
-
function createLoaderWorker(loader) {
|
|
64184
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
64191
|
+
async function createLoaderWorker(loader) {
|
|
64192
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
64185
64193
|
return;
|
|
64186
64194
|
}
|
|
64187
64195
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -65384,7 +65392,7 @@ if (nodeVersion2 < 18) {
|
|
|
65384
65392
|
}
|
|
65385
65393
|
|
|
65386
65394
|
// src/lib/utils/version.ts
|
|
65387
|
-
var VERSION2 = true ? "4.0.
|
|
65395
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
65388
65396
|
|
|
65389
65397
|
// src/lib/parsers/basis-module-loader.ts
|
|
65390
65398
|
var BASIS_EXTERNAL_LIBRARIES = {
|
package/dist/basis-worker.js
CHANGED
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
);
|
|
44
44
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
45
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.0.
|
|
46
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return globalThis._loadersgl_.version;
|
|
@@ -113,61 +113,69 @@
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
116
|
-
function getParentPort() {
|
|
116
|
+
async function getParentPort() {
|
|
117
117
|
let parentPort;
|
|
118
118
|
try {
|
|
119
119
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
120
120
|
parentPort = globalThis.parentPort;
|
|
121
121
|
} catch {
|
|
122
|
+
try {
|
|
123
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
124
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
125
|
+
parentPort = workerThreads.parentPort;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error(error.message);
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
return parentPort;
|
|
124
131
|
}
|
|
125
132
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
126
133
|
var WorkerBody = class {
|
|
127
134
|
/** Check that we are actually in a worker thread */
|
|
128
|
-
static inWorkerThread() {
|
|
129
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
135
|
+
static async inWorkerThread() {
|
|
136
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
130
137
|
}
|
|
131
138
|
/*
|
|
132
139
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
133
140
|
*/
|
|
134
141
|
static set onmessage(onMessage) {
|
|
135
|
-
function handleMessage(message) {
|
|
136
|
-
const
|
|
137
|
-
const { type, payload } =
|
|
142
|
+
async function handleMessage(message) {
|
|
143
|
+
const parentPort2 = await getParentPort();
|
|
144
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
138
145
|
onMessage(type, payload);
|
|
139
146
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
getParentPort().then((parentPort2) => {
|
|
148
|
+
if (parentPort2) {
|
|
149
|
+
parentPort2.on("message", handleMessage);
|
|
150
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
151
|
+
} else {
|
|
152
|
+
globalThis.onmessage = handleMessage;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
147
155
|
}
|
|
148
|
-
static addEventListener(onMessage) {
|
|
156
|
+
static async addEventListener(onMessage) {
|
|
149
157
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
150
158
|
if (!onMessageWrapper) {
|
|
151
|
-
onMessageWrapper = (message) => {
|
|
159
|
+
onMessageWrapper = async (message) => {
|
|
152
160
|
if (!isKnownMessage(message)) {
|
|
153
161
|
return;
|
|
154
162
|
}
|
|
155
|
-
const parentPort3 = getParentPort();
|
|
163
|
+
const parentPort3 = await getParentPort();
|
|
156
164
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
157
165
|
onMessage(type, payload);
|
|
158
166
|
};
|
|
159
167
|
}
|
|
160
|
-
const parentPort2 = getParentPort();
|
|
168
|
+
const parentPort2 = await getParentPort();
|
|
161
169
|
if (parentPort2) {
|
|
162
170
|
console.error("not implemented");
|
|
163
171
|
} else {
|
|
164
172
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
|
-
static removeEventListener(onMessage) {
|
|
175
|
+
static async removeEventListener(onMessage) {
|
|
168
176
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
169
177
|
onMessageWrapperMap.delete(onMessage);
|
|
170
|
-
const parentPort2 = getParentPort();
|
|
178
|
+
const parentPort2 = await getParentPort();
|
|
171
179
|
if (parentPort2) {
|
|
172
180
|
console.error("not implemented");
|
|
173
181
|
} else {
|
|
@@ -179,10 +187,10 @@
|
|
|
179
187
|
* @param type
|
|
180
188
|
* @param payload
|
|
181
189
|
*/
|
|
182
|
-
static postMessage(type, payload) {
|
|
190
|
+
static async postMessage(type, payload) {
|
|
183
191
|
const data = { source: "loaders.gl", type, payload };
|
|
184
192
|
const transferList = getTransferList(payload);
|
|
185
|
-
const parentPort2 = getParentPort();
|
|
193
|
+
const parentPort2 = await getParentPort();
|
|
186
194
|
if (parentPort2) {
|
|
187
195
|
parentPort2.postMessage(data, transferList);
|
|
188
196
|
} else {
|
|
@@ -264,14 +272,14 @@
|
|
|
264
272
|
return null;
|
|
265
273
|
}
|
|
266
274
|
async function loadAsArrayBuffer(url) {
|
|
267
|
-
if (!void 0 || url.startsWith("http")) {
|
|
275
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
268
276
|
const response = await fetch(url);
|
|
269
277
|
return await response.arrayBuffer();
|
|
270
278
|
}
|
|
271
279
|
return await (void 0)(url);
|
|
272
280
|
}
|
|
273
281
|
async function loadAsText(url) {
|
|
274
|
-
if (!void 0 || url.startsWith("http")) {
|
|
282
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
275
283
|
const response = await fetch(url);
|
|
276
284
|
return await response.text();
|
|
277
285
|
}
|
|
@@ -280,8 +288,8 @@
|
|
|
280
288
|
|
|
281
289
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
282
290
|
var requestId = 0;
|
|
283
|
-
function createLoaderWorker(loader) {
|
|
284
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
291
|
+
async function createLoaderWorker(loader) {
|
|
292
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
285
293
|
return;
|
|
286
294
|
}
|
|
287
295
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -360,7 +368,7 @@
|
|
|
360
368
|
}
|
|
361
369
|
|
|
362
370
|
// src/lib/utils/version.ts
|
|
363
|
-
var VERSION2 = true ? "4.0.
|
|
371
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
364
372
|
|
|
365
373
|
// src/lib/parsers/basis-module-loader.ts
|
|
366
374
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
);
|
|
51
51
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
52
52
|
} else {
|
|
53
|
-
globalThis._loadersgl_.version = "4.0.
|
|
53
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
return globalThis._loadersgl_.version;
|
|
@@ -120,61 +120,69 @@
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
123
|
-
function getParentPort() {
|
|
123
|
+
async function getParentPort() {
|
|
124
124
|
let parentPort;
|
|
125
125
|
try {
|
|
126
126
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
127
127
|
parentPort = globalThis.parentPort;
|
|
128
128
|
} catch {
|
|
129
|
+
try {
|
|
130
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
131
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
132
|
+
parentPort = workerThreads.parentPort;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(error.message);
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
return parentPort;
|
|
131
138
|
}
|
|
132
139
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
133
140
|
var WorkerBody = class {
|
|
134
141
|
/** Check that we are actually in a worker thread */
|
|
135
|
-
static inWorkerThread() {
|
|
136
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
142
|
+
static async inWorkerThread() {
|
|
143
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
137
144
|
}
|
|
138
145
|
/*
|
|
139
146
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
140
147
|
*/
|
|
141
148
|
static set onmessage(onMessage) {
|
|
142
|
-
function handleMessage(message) {
|
|
143
|
-
const
|
|
144
|
-
const { type, payload } =
|
|
149
|
+
async function handleMessage(message) {
|
|
150
|
+
const parentPort2 = await getParentPort();
|
|
151
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
145
152
|
onMessage(type, payload);
|
|
146
153
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
getParentPort().then((parentPort2) => {
|
|
155
|
+
if (parentPort2) {
|
|
156
|
+
parentPort2.on("message", handleMessage);
|
|
157
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
158
|
+
} else {
|
|
159
|
+
globalThis.onmessage = handleMessage;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
154
162
|
}
|
|
155
|
-
static addEventListener(onMessage) {
|
|
163
|
+
static async addEventListener(onMessage) {
|
|
156
164
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
157
165
|
if (!onMessageWrapper) {
|
|
158
|
-
onMessageWrapper = (message) => {
|
|
166
|
+
onMessageWrapper = async (message) => {
|
|
159
167
|
if (!isKnownMessage(message)) {
|
|
160
168
|
return;
|
|
161
169
|
}
|
|
162
|
-
const parentPort3 = getParentPort();
|
|
170
|
+
const parentPort3 = await getParentPort();
|
|
163
171
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
164
172
|
onMessage(type, payload);
|
|
165
173
|
};
|
|
166
174
|
}
|
|
167
|
-
const parentPort2 = getParentPort();
|
|
175
|
+
const parentPort2 = await getParentPort();
|
|
168
176
|
if (parentPort2) {
|
|
169
177
|
console.error("not implemented");
|
|
170
178
|
} else {
|
|
171
179
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
|
-
static removeEventListener(onMessage) {
|
|
182
|
+
static async removeEventListener(onMessage) {
|
|
175
183
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
176
184
|
onMessageWrapperMap.delete(onMessage);
|
|
177
|
-
const parentPort2 = getParentPort();
|
|
185
|
+
const parentPort2 = await getParentPort();
|
|
178
186
|
if (parentPort2) {
|
|
179
187
|
console.error("not implemented");
|
|
180
188
|
} else {
|
|
@@ -186,10 +194,10 @@
|
|
|
186
194
|
* @param type
|
|
187
195
|
* @param payload
|
|
188
196
|
*/
|
|
189
|
-
static postMessage(type, payload) {
|
|
197
|
+
static async postMessage(type, payload) {
|
|
190
198
|
const data = { source: "loaders.gl", type, payload };
|
|
191
199
|
const transferList = getTransferList(payload);
|
|
192
|
-
const parentPort2 = getParentPort();
|
|
200
|
+
const parentPort2 = await getParentPort();
|
|
193
201
|
if (parentPort2) {
|
|
194
202
|
parentPort2.postMessage(data, transferList);
|
|
195
203
|
} else {
|
|
@@ -271,14 +279,14 @@
|
|
|
271
279
|
return null;
|
|
272
280
|
}
|
|
273
281
|
async function loadAsArrayBuffer(url) {
|
|
274
|
-
if (!void 0 || url.startsWith("http")) {
|
|
282
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
275
283
|
const response = await fetch(url);
|
|
276
284
|
return await response.arrayBuffer();
|
|
277
285
|
}
|
|
278
286
|
return await (void 0)(url);
|
|
279
287
|
}
|
|
280
288
|
async function loadAsText(url) {
|
|
281
|
-
if (!void 0 || url.startsWith("http")) {
|
|
289
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
282
290
|
const response = await fetch(url);
|
|
283
291
|
return await response.text();
|
|
284
292
|
}
|
|
@@ -287,8 +295,8 @@
|
|
|
287
295
|
|
|
288
296
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
289
297
|
var requestId = 0;
|
|
290
|
-
function createLoaderWorker(loader) {
|
|
291
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
298
|
+
async function createLoaderWorker(loader) {
|
|
299
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
292
300
|
return;
|
|
293
301
|
}
|
|
294
302
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -367,7 +375,7 @@
|
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
// src/lib/utils/version.ts
|
|
370
|
-
var VERSION2 = true ? "4.0.
|
|
378
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
371
379
|
|
|
372
380
|
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
373
381
|
var t = new Uint8Array([0]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAIpE,MAAM,MAAM,8BAA8B,GAAG,aAAa,GAAG;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,8BAA8B,
|
|
1
|
+
{"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAIpE,MAAM,MAAM,8BAA8B,GAAG,aAAa,GAAG;IAC3D,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE;QACR,MAAM,EAAE,MAAM,CAAC;QACf,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC;QAChB,MAAM,EAAE,OAAO,CAAC;QAChB,KAAK,EAAE,OAAO,CAAC;QACf,SAAS,EAAE,MAAM,CAAC;KACnB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,MAAM,CAAC,OAAO,EAAE,OAAO,EAAE,8BAA8B,CAuB5F,CAAC"}
|
|
@@ -16,6 +16,9 @@ export const CompressedTextureWriter = {
|
|
|
16
16
|
toolFlags: ''
|
|
17
17
|
}
|
|
18
18
|
},
|
|
19
|
-
encodeURLtoURL: encodeImageURLToCompressedTextureURL
|
|
19
|
+
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
20
|
+
encode() {
|
|
21
|
+
throw new Error('Not implemented');
|
|
22
|
+
}
|
|
20
23
|
};
|
|
21
24
|
//# sourceMappingURL=compressed-texture-writer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compressed-texture-writer.js","names":["VERSION","encodeImageURLToCompressedTextureURL","CompressedTextureWriter","name","id","module","version","extensions","options","texture","format","compression","quality","mipmap","flipY","toolFlags","encodeURLtoURL"],"sources":["../src/compressed-texture-writer.ts"],"sourcesContent":["import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport {VERSION} from './lib/utils/version';\nimport {encodeImageURLToCompressedTextureURL} from './lib/encoders/encode-texture';\n\nexport type CompressedTextureWriterOptions = WriterOptions & {\n cwd?: string;\n texture?: {\n format: string;\n compression: string;\n quality: string;\n mipmap: boolean;\n flipY: boolean;\n toolFlags: string;\n };\n};\n\n/**\n * DDS Texture Container Exporter\n */\nexport const CompressedTextureWriter: Writer<unknown, unknown, CompressedTextureWriterOptions> = {\n name: 'DDS Texture Container',\n id: 'dds',\n module: 'textures',\n version: VERSION,\n\n extensions: ['dds'],\n\n options: {\n texture: {\n format: 'auto',\n compression: 'auto',\n quality: 'auto',\n mipmap: false,\n flipY: false,\n toolFlags: ''\n }\n },\n\n encodeURLtoURL: encodeImageURLToCompressedTextureURL\n};\n\n// TYPE TESTS - TODO find a better way than exporting junk\n// export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {\n// encodeURLtoURL: (\n// inputUrl: string,\n// outputUrl: string,\n// options?: CompressedTextureWriterOptions\n// ) => Promise<string>;\n// } = CompressedTextureWriter;\n"],"mappings":"SACQA,OAAO;AAAA,SACPC,oCAAoC;AAiB5C,OAAO,MAAMC,uBAAiF,GAAG;EAC/FC,IAAI,EAAE,uBAAuB;EAC7BC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,UAAU;EAClBC,OAAO,EAAEN,OAAO;EAEhBO,UAAU,EAAE,CAAC,KAAK,CAAC;EAEnBC,OAAO,EAAE;IACPC,OAAO,EAAE;MACPC,MAAM,EAAE,MAAM;MACdC,WAAW,EAAE,MAAM;MACnBC,OAAO,EAAE,MAAM;MACfC,MAAM,EAAE,KAAK;MACbC,KAAK,EAAE,KAAK;MACZC,SAAS,EAAE;IACb;EACF,CAAC;EAEDC,cAAc,EAAEf;
|
|
1
|
+
{"version":3,"file":"compressed-texture-writer.js","names":["VERSION","encodeImageURLToCompressedTextureURL","CompressedTextureWriter","name","id","module","version","extensions","options","texture","format","compression","quality","mipmap","flipY","toolFlags","encodeURLtoURL","encode","Error"],"sources":["../src/compressed-texture-writer.ts"],"sourcesContent":["import type {Writer, WriterOptions} from '@loaders.gl/loader-utils';\nimport {VERSION} from './lib/utils/version';\nimport {encodeImageURLToCompressedTextureURL} from './lib/encoders/encode-texture';\n\nexport type CompressedTextureWriterOptions = WriterOptions & {\n cwd?: string;\n texture?: {\n format: string;\n compression: string;\n quality: string;\n mipmap: boolean;\n flipY: boolean;\n toolFlags: string;\n };\n};\n\n/**\n * DDS Texture Container Exporter\n */\nexport const CompressedTextureWriter: Writer<unknown, unknown, CompressedTextureWriterOptions> = {\n name: 'DDS Texture Container',\n id: 'dds',\n module: 'textures',\n version: VERSION,\n\n extensions: ['dds'],\n\n options: {\n texture: {\n format: 'auto',\n compression: 'auto',\n quality: 'auto',\n mipmap: false,\n flipY: false,\n toolFlags: ''\n }\n },\n\n encodeURLtoURL: encodeImageURLToCompressedTextureURL,\n encode() {\n throw new Error('Not implemented');\n }\n};\n\n// TYPE TESTS - TODO find a better way than exporting junk\n// export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {\n// encodeURLtoURL: (\n// inputUrl: string,\n// outputUrl: string,\n// options?: CompressedTextureWriterOptions\n// ) => Promise<string>;\n// } = CompressedTextureWriter;\n"],"mappings":"SACQA,OAAO;AAAA,SACPC,oCAAoC;AAiB5C,OAAO,MAAMC,uBAAiF,GAAG;EAC/FC,IAAI,EAAE,uBAAuB;EAC7BC,EAAE,EAAE,KAAK;EACTC,MAAM,EAAE,UAAU;EAClBC,OAAO,EAAEN,OAAO;EAEhBO,UAAU,EAAE,CAAC,KAAK,CAAC;EAEnBC,OAAO,EAAE;IACPC,OAAO,EAAE;MACPC,MAAM,EAAE,MAAM;MACdC,WAAW,EAAE,MAAM;MACnBC,OAAO,EAAE,MAAM;MACfC,MAAM,EAAE,KAAK;MACbC,KAAK,EAAE,KAAK;MACZC,SAAS,EAAE;IACb;EACF,CAAC;EAEDC,cAAc,EAAEf,oCAAoC;EACpDgB,MAAMA,CAAA,EAAG;IACP,MAAM,IAAIC,KAAK,CAAC,iBAAiB,CAAC;EACpC;AACF,CAAC"}
|
package/dist/crunch-worker.js
CHANGED
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
);
|
|
51
51
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
52
52
|
} else {
|
|
53
|
-
globalThis._loadersgl_.version = "4.0.
|
|
53
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
return globalThis._loadersgl_.version;
|
|
@@ -120,61 +120,69 @@
|
|
|
120
120
|
}
|
|
121
121
|
|
|
122
122
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
123
|
-
function getParentPort() {
|
|
123
|
+
async function getParentPort() {
|
|
124
124
|
let parentPort;
|
|
125
125
|
try {
|
|
126
126
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
127
127
|
parentPort = globalThis.parentPort;
|
|
128
128
|
} catch {
|
|
129
|
+
try {
|
|
130
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
131
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
132
|
+
parentPort = workerThreads.parentPort;
|
|
133
|
+
} catch (error) {
|
|
134
|
+
console.error(error.message);
|
|
135
|
+
}
|
|
129
136
|
}
|
|
130
137
|
return parentPort;
|
|
131
138
|
}
|
|
132
139
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
133
140
|
var WorkerBody = class {
|
|
134
141
|
/** Check that we are actually in a worker thread */
|
|
135
|
-
static inWorkerThread() {
|
|
136
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
142
|
+
static async inWorkerThread() {
|
|
143
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
137
144
|
}
|
|
138
145
|
/*
|
|
139
146
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
140
147
|
*/
|
|
141
148
|
static set onmessage(onMessage) {
|
|
142
|
-
function handleMessage(message) {
|
|
143
|
-
const
|
|
144
|
-
const { type, payload } =
|
|
149
|
+
async function handleMessage(message) {
|
|
150
|
+
const parentPort2 = await getParentPort();
|
|
151
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
145
152
|
onMessage(type, payload);
|
|
146
153
|
}
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
+
getParentPort().then((parentPort2) => {
|
|
155
|
+
if (parentPort2) {
|
|
156
|
+
parentPort2.on("message", handleMessage);
|
|
157
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
158
|
+
} else {
|
|
159
|
+
globalThis.onmessage = handleMessage;
|
|
160
|
+
}
|
|
161
|
+
});
|
|
154
162
|
}
|
|
155
|
-
static addEventListener(onMessage) {
|
|
163
|
+
static async addEventListener(onMessage) {
|
|
156
164
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
157
165
|
if (!onMessageWrapper) {
|
|
158
|
-
onMessageWrapper = (message) => {
|
|
166
|
+
onMessageWrapper = async (message) => {
|
|
159
167
|
if (!isKnownMessage(message)) {
|
|
160
168
|
return;
|
|
161
169
|
}
|
|
162
|
-
const parentPort3 = getParentPort();
|
|
170
|
+
const parentPort3 = await getParentPort();
|
|
163
171
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
164
172
|
onMessage(type, payload);
|
|
165
173
|
};
|
|
166
174
|
}
|
|
167
|
-
const parentPort2 = getParentPort();
|
|
175
|
+
const parentPort2 = await getParentPort();
|
|
168
176
|
if (parentPort2) {
|
|
169
177
|
console.error("not implemented");
|
|
170
178
|
} else {
|
|
171
179
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
172
180
|
}
|
|
173
181
|
}
|
|
174
|
-
static removeEventListener(onMessage) {
|
|
182
|
+
static async removeEventListener(onMessage) {
|
|
175
183
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
176
184
|
onMessageWrapperMap.delete(onMessage);
|
|
177
|
-
const parentPort2 = getParentPort();
|
|
185
|
+
const parentPort2 = await getParentPort();
|
|
178
186
|
if (parentPort2) {
|
|
179
187
|
console.error("not implemented");
|
|
180
188
|
} else {
|
|
@@ -186,10 +194,10 @@
|
|
|
186
194
|
* @param type
|
|
187
195
|
* @param payload
|
|
188
196
|
*/
|
|
189
|
-
static postMessage(type, payload) {
|
|
197
|
+
static async postMessage(type, payload) {
|
|
190
198
|
const data = { source: "loaders.gl", type, payload };
|
|
191
199
|
const transferList = getTransferList(payload);
|
|
192
|
-
const parentPort2 = getParentPort();
|
|
200
|
+
const parentPort2 = await getParentPort();
|
|
193
201
|
if (parentPort2) {
|
|
194
202
|
parentPort2.postMessage(data, transferList);
|
|
195
203
|
} else {
|
|
@@ -271,14 +279,14 @@
|
|
|
271
279
|
return null;
|
|
272
280
|
}
|
|
273
281
|
async function loadAsArrayBuffer(url) {
|
|
274
|
-
if (!void 0 || url.startsWith("http")) {
|
|
282
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
275
283
|
const response = await fetch(url);
|
|
276
284
|
return await response.arrayBuffer();
|
|
277
285
|
}
|
|
278
286
|
return await (void 0)(url);
|
|
279
287
|
}
|
|
280
288
|
async function loadAsText(url) {
|
|
281
|
-
if (!void 0 || url.startsWith("http")) {
|
|
289
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
282
290
|
const response = await fetch(url);
|
|
283
291
|
return await response.text();
|
|
284
292
|
}
|
|
@@ -287,8 +295,8 @@
|
|
|
287
295
|
|
|
288
296
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
289
297
|
var requestId = 0;
|
|
290
|
-
function createLoaderWorker(loader) {
|
|
291
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
298
|
+
async function createLoaderWorker(loader) {
|
|
299
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
292
300
|
return;
|
|
293
301
|
}
|
|
294
302
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -367,7 +375,7 @@
|
|
|
367
375
|
}
|
|
368
376
|
|
|
369
377
|
// src/lib/utils/version.ts
|
|
370
|
-
var VERSION2 = true ? "4.0.
|
|
378
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
371
379
|
|
|
372
380
|
// src/crunch-loader.ts
|
|
373
381
|
var CrunchLoader = {
|
package/dist/dist.dev.js
CHANGED
|
@@ -186,14 +186,14 @@ var __exports__ = (() => {
|
|
|
186
186
|
return null;
|
|
187
187
|
}
|
|
188
188
|
async function loadAsArrayBuffer(url) {
|
|
189
|
-
if (!void 0 || url.startsWith("http")) {
|
|
189
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
190
190
|
const response = await fetch(url);
|
|
191
191
|
return await response.arrayBuffer();
|
|
192
192
|
}
|
|
193
193
|
return await (void 0)(url);
|
|
194
194
|
}
|
|
195
195
|
async function loadAsText(url) {
|
|
196
|
-
if (!void 0 || url.startsWith("http")) {
|
|
196
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
197
197
|
const response = await fetch(url);
|
|
198
198
|
return await response.text();
|
|
199
199
|
}
|
|
@@ -1313,7 +1313,10 @@ var __exports__ = (() => {
|
|
|
1313
1313
|
toolFlags: ""
|
|
1314
1314
|
}
|
|
1315
1315
|
},
|
|
1316
|
-
encodeURLtoURL: encodeImageURLToCompressedTextureURL
|
|
1316
|
+
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
1317
|
+
encode() {
|
|
1318
|
+
throw new Error("Not implemented");
|
|
1319
|
+
}
|
|
1317
1320
|
};
|
|
1318
1321
|
|
|
1319
1322
|
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
package/dist/index.cjs
CHANGED
|
@@ -1153,7 +1153,10 @@ var CompressedTextureWriter = {
|
|
|
1153
1153
|
toolFlags: ""
|
|
1154
1154
|
}
|
|
1155
1155
|
},
|
|
1156
|
-
encodeURLtoURL: encodeImageURLToCompressedTextureURL
|
|
1156
|
+
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
1157
|
+
encode() {
|
|
1158
|
+
throw new Error("Not implemented");
|
|
1159
|
+
}
|
|
1157
1160
|
};
|
|
1158
1161
|
|
|
1159
1162
|
// src/lib/encoders/encode-ktx2-basis-texture.ts
|
|
@@ -63710,7 +63710,7 @@ function getVersion() {
|
|
|
63710
63710
|
);
|
|
63711
63711
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
63712
63712
|
} else {
|
|
63713
|
-
globalThis._loadersgl_.version = "4.0.
|
|
63713
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
63714
63714
|
}
|
|
63715
63715
|
}
|
|
63716
63716
|
return globalThis._loadersgl_.version;
|
|
@@ -63780,61 +63780,69 @@ function isTransferable(object) {
|
|
|
63780
63780
|
}
|
|
63781
63781
|
|
|
63782
63782
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
63783
|
-
function getParentPort() {
|
|
63783
|
+
async function getParentPort() {
|
|
63784
63784
|
let parentPort;
|
|
63785
63785
|
try {
|
|
63786
63786
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
63787
63787
|
parentPort = globalThis.parentPort;
|
|
63788
63788
|
} catch {
|
|
63789
|
+
try {
|
|
63790
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
63791
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
63792
|
+
parentPort = workerThreads.parentPort;
|
|
63793
|
+
} catch (error) {
|
|
63794
|
+
console.error(error.message);
|
|
63795
|
+
}
|
|
63789
63796
|
}
|
|
63790
63797
|
return parentPort;
|
|
63791
63798
|
}
|
|
63792
63799
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
63793
63800
|
var WorkerBody = class {
|
|
63794
63801
|
/** Check that we are actually in a worker thread */
|
|
63795
|
-
static inWorkerThread() {
|
|
63796
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
63802
|
+
static async inWorkerThread() {
|
|
63803
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
63797
63804
|
}
|
|
63798
63805
|
/*
|
|
63799
63806
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
63800
63807
|
*/
|
|
63801
63808
|
static set onmessage(onMessage) {
|
|
63802
|
-
function handleMessage(message) {
|
|
63803
|
-
const
|
|
63804
|
-
const { type, payload } =
|
|
63809
|
+
async function handleMessage(message) {
|
|
63810
|
+
const parentPort2 = await getParentPort();
|
|
63811
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
63805
63812
|
onMessage(type, payload);
|
|
63806
63813
|
}
|
|
63807
|
-
|
|
63808
|
-
|
|
63809
|
-
|
|
63810
|
-
|
|
63811
|
-
|
|
63812
|
-
|
|
63813
|
-
|
|
63814
|
+
getParentPort().then((parentPort2) => {
|
|
63815
|
+
if (parentPort2) {
|
|
63816
|
+
parentPort2.on("message", handleMessage);
|
|
63817
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
63818
|
+
} else {
|
|
63819
|
+
globalThis.onmessage = handleMessage;
|
|
63820
|
+
}
|
|
63821
|
+
});
|
|
63814
63822
|
}
|
|
63815
|
-
static addEventListener(onMessage) {
|
|
63823
|
+
static async addEventListener(onMessage) {
|
|
63816
63824
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
63817
63825
|
if (!onMessageWrapper) {
|
|
63818
|
-
onMessageWrapper = (message) => {
|
|
63826
|
+
onMessageWrapper = async (message) => {
|
|
63819
63827
|
if (!isKnownMessage(message)) {
|
|
63820
63828
|
return;
|
|
63821
63829
|
}
|
|
63822
|
-
const parentPort3 = getParentPort();
|
|
63830
|
+
const parentPort3 = await getParentPort();
|
|
63823
63831
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
63824
63832
|
onMessage(type, payload);
|
|
63825
63833
|
};
|
|
63826
63834
|
}
|
|
63827
|
-
const parentPort2 = getParentPort();
|
|
63835
|
+
const parentPort2 = await getParentPort();
|
|
63828
63836
|
if (parentPort2) {
|
|
63829
63837
|
console.error("not implemented");
|
|
63830
63838
|
} else {
|
|
63831
63839
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
63832
63840
|
}
|
|
63833
63841
|
}
|
|
63834
|
-
static removeEventListener(onMessage) {
|
|
63842
|
+
static async removeEventListener(onMessage) {
|
|
63835
63843
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
63836
63844
|
onMessageWrapperMap.delete(onMessage);
|
|
63837
|
-
const parentPort2 = getParentPort();
|
|
63845
|
+
const parentPort2 = await getParentPort();
|
|
63838
63846
|
if (parentPort2) {
|
|
63839
63847
|
console.error("not implemented");
|
|
63840
63848
|
} else {
|
|
@@ -63846,10 +63854,10 @@ var WorkerBody = class {
|
|
|
63846
63854
|
* @param type
|
|
63847
63855
|
* @param payload
|
|
63848
63856
|
*/
|
|
63849
|
-
static postMessage(type, payload) {
|
|
63857
|
+
static async postMessage(type, payload) {
|
|
63850
63858
|
const data = { source: "loaders.gl", type, payload };
|
|
63851
63859
|
const transferList = getTransferList(payload);
|
|
63852
|
-
const parentPort2 = getParentPort();
|
|
63860
|
+
const parentPort2 = await getParentPort();
|
|
63853
63861
|
if (parentPort2) {
|
|
63854
63862
|
parentPort2.postMessage(data, transferList);
|
|
63855
63863
|
} else {
|
|
@@ -63898,7 +63906,7 @@ async function requireFromFile(filename) {
|
|
|
63898
63906
|
if (!filename.startsWith("/")) {
|
|
63899
63907
|
filename = `${process.cwd()}/${filename}`;
|
|
63900
63908
|
}
|
|
63901
|
-
const code = await fs.
|
|
63909
|
+
const code = await fs.promises.readFile(filename, "utf8");
|
|
63902
63910
|
return requireFromString(code);
|
|
63903
63911
|
}
|
|
63904
63912
|
function requireFromString(code, filename = "", options) {
|
|
@@ -63989,14 +63997,14 @@ function loadLibraryFromString(scriptSource, id) {
|
|
|
63989
63997
|
return null;
|
|
63990
63998
|
}
|
|
63991
63999
|
async function loadAsArrayBuffer(url) {
|
|
63992
|
-
if (!readFileAsArrayBuffer || url.startsWith("http")) {
|
|
64000
|
+
if (isBrowser2 || !readFileAsArrayBuffer || url.startsWith("http")) {
|
|
63993
64001
|
const response = await fetch(url);
|
|
63994
64002
|
return await response.arrayBuffer();
|
|
63995
64003
|
}
|
|
63996
64004
|
return await readFileAsArrayBuffer(url);
|
|
63997
64005
|
}
|
|
63998
64006
|
async function loadAsText(url) {
|
|
63999
|
-
if (!readFileAsText || url.startsWith("http")) {
|
|
64007
|
+
if (isBrowser2 || !readFileAsText || url.startsWith("http")) {
|
|
64000
64008
|
const response = await fetch(url);
|
|
64001
64009
|
return await response.text();
|
|
64002
64010
|
}
|
|
@@ -65128,7 +65136,7 @@ if (nodeVersion2 < 18) {
|
|
|
65128
65136
|
}
|
|
65129
65137
|
|
|
65130
65138
|
// src/lib/utils/version.ts
|
|
65131
|
-
var VERSION2 = true ? "4.0.
|
|
65139
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
65132
65140
|
|
|
65133
65141
|
// src/lib/parsers/basis-module-loader.ts
|
|
65134
65142
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -65225,8 +65233,8 @@ var KTX2BasisWriter = {
|
|
|
65225
65233
|
};
|
|
65226
65234
|
|
|
65227
65235
|
// src/workers/ktx2-basis-writer-worker-node.ts
|
|
65228
|
-
(() => {
|
|
65229
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
65236
|
+
(async () => {
|
|
65237
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
65230
65238
|
return;
|
|
65231
65239
|
}
|
|
65232
65240
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -43,7 +43,7 @@
|
|
|
43
43
|
);
|
|
44
44
|
globalThis._loadersgl_.version = NPM_TAG;
|
|
45
45
|
} else {
|
|
46
|
-
globalThis._loadersgl_.version = "4.0.
|
|
46
|
+
globalThis._loadersgl_.version = "4.0.2";
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
49
|
return globalThis._loadersgl_.version;
|
|
@@ -113,61 +113,69 @@
|
|
|
113
113
|
}
|
|
114
114
|
|
|
115
115
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
116
|
-
function getParentPort() {
|
|
116
|
+
async function getParentPort() {
|
|
117
117
|
let parentPort;
|
|
118
118
|
try {
|
|
119
119
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
120
120
|
parentPort = globalThis.parentPort;
|
|
121
121
|
} catch {
|
|
122
|
+
try {
|
|
123
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
124
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
125
|
+
parentPort = workerThreads.parentPort;
|
|
126
|
+
} catch (error) {
|
|
127
|
+
console.error(error.message);
|
|
128
|
+
}
|
|
122
129
|
}
|
|
123
130
|
return parentPort;
|
|
124
131
|
}
|
|
125
132
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
126
133
|
var WorkerBody = class {
|
|
127
134
|
/** Check that we are actually in a worker thread */
|
|
128
|
-
static inWorkerThread() {
|
|
129
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
135
|
+
static async inWorkerThread() {
|
|
136
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
130
137
|
}
|
|
131
138
|
/*
|
|
132
139
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
133
140
|
*/
|
|
134
141
|
static set onmessage(onMessage) {
|
|
135
|
-
function handleMessage(message) {
|
|
136
|
-
const
|
|
137
|
-
const { type, payload } =
|
|
142
|
+
async function handleMessage(message) {
|
|
143
|
+
const parentPort2 = await getParentPort();
|
|
144
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
138
145
|
onMessage(type, payload);
|
|
139
146
|
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
+
getParentPort().then((parentPort2) => {
|
|
148
|
+
if (parentPort2) {
|
|
149
|
+
parentPort2.on("message", handleMessage);
|
|
150
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
151
|
+
} else {
|
|
152
|
+
globalThis.onmessage = handleMessage;
|
|
153
|
+
}
|
|
154
|
+
});
|
|
147
155
|
}
|
|
148
|
-
static addEventListener(onMessage) {
|
|
156
|
+
static async addEventListener(onMessage) {
|
|
149
157
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
150
158
|
if (!onMessageWrapper) {
|
|
151
|
-
onMessageWrapper = (message) => {
|
|
159
|
+
onMessageWrapper = async (message) => {
|
|
152
160
|
if (!isKnownMessage(message)) {
|
|
153
161
|
return;
|
|
154
162
|
}
|
|
155
|
-
const parentPort3 = getParentPort();
|
|
163
|
+
const parentPort3 = await getParentPort();
|
|
156
164
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
157
165
|
onMessage(type, payload);
|
|
158
166
|
};
|
|
159
167
|
}
|
|
160
|
-
const parentPort2 = getParentPort();
|
|
168
|
+
const parentPort2 = await getParentPort();
|
|
161
169
|
if (parentPort2) {
|
|
162
170
|
console.error("not implemented");
|
|
163
171
|
} else {
|
|
164
172
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
165
173
|
}
|
|
166
174
|
}
|
|
167
|
-
static removeEventListener(onMessage) {
|
|
175
|
+
static async removeEventListener(onMessage) {
|
|
168
176
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
169
177
|
onMessageWrapperMap.delete(onMessage);
|
|
170
|
-
const parentPort2 = getParentPort();
|
|
178
|
+
const parentPort2 = await getParentPort();
|
|
171
179
|
if (parentPort2) {
|
|
172
180
|
console.error("not implemented");
|
|
173
181
|
} else {
|
|
@@ -179,10 +187,10 @@
|
|
|
179
187
|
* @param type
|
|
180
188
|
* @param payload
|
|
181
189
|
*/
|
|
182
|
-
static postMessage(type, payload) {
|
|
190
|
+
static async postMessage(type, payload) {
|
|
183
191
|
const data = { source: "loaders.gl", type, payload };
|
|
184
192
|
const transferList = getTransferList(payload);
|
|
185
|
-
const parentPort2 = getParentPort();
|
|
193
|
+
const parentPort2 = await getParentPort();
|
|
186
194
|
if (parentPort2) {
|
|
187
195
|
parentPort2.postMessage(data, transferList);
|
|
188
196
|
} else {
|
|
@@ -264,14 +272,14 @@
|
|
|
264
272
|
return null;
|
|
265
273
|
}
|
|
266
274
|
async function loadAsArrayBuffer(url) {
|
|
267
|
-
if (!void 0 || url.startsWith("http")) {
|
|
275
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
268
276
|
const response = await fetch(url);
|
|
269
277
|
return await response.arrayBuffer();
|
|
270
278
|
}
|
|
271
279
|
return await (void 0)(url);
|
|
272
280
|
}
|
|
273
281
|
async function loadAsText(url) {
|
|
274
|
-
if (!void 0 || url.startsWith("http")) {
|
|
282
|
+
if (isBrowser || !void 0 || url.startsWith("http")) {
|
|
275
283
|
const response = await fetch(url);
|
|
276
284
|
return await response.text();
|
|
277
285
|
}
|
|
@@ -279,7 +287,7 @@
|
|
|
279
287
|
}
|
|
280
288
|
|
|
281
289
|
// src/lib/utils/version.ts
|
|
282
|
-
var VERSION2 = true ? "4.0.
|
|
290
|
+
var VERSION2 = true ? "4.0.2" : "beta";
|
|
283
291
|
|
|
284
292
|
// src/lib/parsers/basis-module-loader.ts
|
|
285
293
|
var BASIS_EXTERNAL_LIBRARIES = {
|
|
@@ -376,8 +384,8 @@
|
|
|
376
384
|
};
|
|
377
385
|
|
|
378
386
|
// src/workers/ktx2-basis-writer-worker.ts
|
|
379
|
-
(() => {
|
|
380
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
387
|
+
(async () => {
|
|
388
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
381
389
|
return;
|
|
382
390
|
}
|
|
383
391
|
WorkerBody.onmessage = async (type, payload) => {
|
package/dist/npy-worker.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
(() => {
|
|
3
3
|
// src/lib/utils/version.ts
|
|
4
|
-
var VERSION = true ? "4.0.
|
|
4
|
+
var VERSION = true ? "4.0.2" : "beta";
|
|
5
5
|
|
|
6
6
|
// src/lib/parsers/parse-npy.ts
|
|
7
7
|
var a = new Uint32Array([305419896]);
|
|
@@ -119,61 +119,69 @@
|
|
|
119
119
|
}
|
|
120
120
|
|
|
121
121
|
// ../worker-utils/src/lib/worker-farm/worker-body.ts
|
|
122
|
-
function getParentPort() {
|
|
122
|
+
async function getParentPort() {
|
|
123
123
|
let parentPort;
|
|
124
124
|
try {
|
|
125
125
|
eval("globalThis.parentPort = require('worker_threads').parentPort");
|
|
126
126
|
parentPort = globalThis.parentPort;
|
|
127
127
|
} catch {
|
|
128
|
+
try {
|
|
129
|
+
eval("globalThis.workerThreadsPromise = import('worker_threads')");
|
|
130
|
+
const workerThreads = await globalThis.workerThreadsPromise;
|
|
131
|
+
parentPort = workerThreads.parentPort;
|
|
132
|
+
} catch (error) {
|
|
133
|
+
console.error(error.message);
|
|
134
|
+
}
|
|
128
135
|
}
|
|
129
136
|
return parentPort;
|
|
130
137
|
}
|
|
131
138
|
var onMessageWrapperMap = /* @__PURE__ */ new Map();
|
|
132
139
|
var WorkerBody = class {
|
|
133
140
|
/** Check that we are actually in a worker thread */
|
|
134
|
-
static inWorkerThread() {
|
|
135
|
-
return typeof self !== "undefined" || Boolean(getParentPort());
|
|
141
|
+
static async inWorkerThread() {
|
|
142
|
+
return typeof self !== "undefined" || Boolean(await getParentPort());
|
|
136
143
|
}
|
|
137
144
|
/*
|
|
138
145
|
* (type: WorkerMessageType, payload: WorkerMessagePayload) => any
|
|
139
146
|
*/
|
|
140
147
|
static set onmessage(onMessage) {
|
|
141
|
-
function handleMessage(message) {
|
|
142
|
-
const
|
|
143
|
-
const { type, payload } =
|
|
148
|
+
async function handleMessage(message) {
|
|
149
|
+
const parentPort2 = await getParentPort();
|
|
150
|
+
const { type, payload } = parentPort2 ? message : message.data;
|
|
144
151
|
onMessage(type, payload);
|
|
145
152
|
}
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
getParentPort().then((parentPort2) => {
|
|
154
|
+
if (parentPort2) {
|
|
155
|
+
parentPort2.on("message", handleMessage);
|
|
156
|
+
parentPort2.on("exit", () => console.debug("Node worker closing"));
|
|
157
|
+
} else {
|
|
158
|
+
globalThis.onmessage = handleMessage;
|
|
159
|
+
}
|
|
160
|
+
});
|
|
153
161
|
}
|
|
154
|
-
static addEventListener(onMessage) {
|
|
162
|
+
static async addEventListener(onMessage) {
|
|
155
163
|
let onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
156
164
|
if (!onMessageWrapper) {
|
|
157
|
-
onMessageWrapper = (message) => {
|
|
165
|
+
onMessageWrapper = async (message) => {
|
|
158
166
|
if (!isKnownMessage(message)) {
|
|
159
167
|
return;
|
|
160
168
|
}
|
|
161
|
-
const parentPort3 = getParentPort();
|
|
169
|
+
const parentPort3 = await getParentPort();
|
|
162
170
|
const { type, payload } = parentPort3 ? message : message.data;
|
|
163
171
|
onMessage(type, payload);
|
|
164
172
|
};
|
|
165
173
|
}
|
|
166
|
-
const parentPort2 = getParentPort();
|
|
174
|
+
const parentPort2 = await getParentPort();
|
|
167
175
|
if (parentPort2) {
|
|
168
176
|
console.error("not implemented");
|
|
169
177
|
} else {
|
|
170
178
|
globalThis.addEventListener("message", onMessageWrapper);
|
|
171
179
|
}
|
|
172
180
|
}
|
|
173
|
-
static removeEventListener(onMessage) {
|
|
181
|
+
static async removeEventListener(onMessage) {
|
|
174
182
|
const onMessageWrapper = onMessageWrapperMap.get(onMessage);
|
|
175
183
|
onMessageWrapperMap.delete(onMessage);
|
|
176
|
-
const parentPort2 = getParentPort();
|
|
184
|
+
const parentPort2 = await getParentPort();
|
|
177
185
|
if (parentPort2) {
|
|
178
186
|
console.error("not implemented");
|
|
179
187
|
} else {
|
|
@@ -185,10 +193,10 @@
|
|
|
185
193
|
* @param type
|
|
186
194
|
* @param payload
|
|
187
195
|
*/
|
|
188
|
-
static postMessage(type, payload) {
|
|
196
|
+
static async postMessage(type, payload) {
|
|
189
197
|
const data = { source: "loaders.gl", type, payload };
|
|
190
198
|
const transferList = getTransferList(payload);
|
|
191
|
-
const parentPort2 = getParentPort();
|
|
199
|
+
const parentPort2 = await getParentPort();
|
|
192
200
|
if (parentPort2) {
|
|
193
201
|
parentPort2.postMessage(data, transferList);
|
|
194
202
|
} else {
|
|
@@ -203,8 +211,8 @@
|
|
|
203
211
|
|
|
204
212
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
205
213
|
var requestId = 0;
|
|
206
|
-
function createLoaderWorker(loader) {
|
|
207
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
214
|
+
async function createLoaderWorker(loader) {
|
|
215
|
+
if (!await WorkerBody.inWorkerThread()) {
|
|
208
216
|
return;
|
|
209
217
|
}
|
|
210
218
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import '@loaders.gl/polyfills';
|
|
2
2
|
import { WorkerBody } from '@loaders.gl/worker-utils';
|
|
3
3
|
import { KTX2BasisWriter } from "../ktx2-basis-writer.js";
|
|
4
|
-
(() => {
|
|
5
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
4
|
+
(async () => {
|
|
5
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
6
6
|
return;
|
|
7
7
|
}
|
|
8
8
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktx2-basis-writer-worker-node.js","names":["WorkerBody","KTX2BasisWriter","inWorkerThread","onmessage","type","payload","_KTX2BasisWriter$enco","input","options","result","encode","call","postMessage","error","message","Error"],"sources":["../../src/workers/ktx2-basis-writer-worker-node.ts"],"sourcesContent":["// Polyfills increases the bundle size significantly. Use it for NodeJS worker only\nimport '@loaders.gl/polyfills';\nimport {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';\n\n(() => {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,UAAU,QAA6B,0BAA0B;AAAC,SAClEC,eAAe;AAEvB,CAAC,
|
|
1
|
+
{"version":3,"file":"ktx2-basis-writer-worker-node.js","names":["WorkerBody","KTX2BasisWriter","inWorkerThread","onmessage","type","payload","_KTX2BasisWriter$enco","input","options","result","encode","call","postMessage","error","message","Error"],"sources":["../../src/workers/ktx2-basis-writer-worker-node.ts"],"sourcesContent":["// Polyfills increases the bundle size significantly. Use it for NodeJS worker only\nimport '@loaders.gl/polyfills';\nimport {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';\n\n(async () => {\n // Check that we are actually in a worker thread\n if (!(await WorkerBody.inWorkerThread())) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],"mappings":"AACA,OAAO,uBAAuB;AAC9B,SAAQA,UAAU,QAA6B,0BAA0B;AAAC,SAClEC,eAAe;AAEvB,CAAC,YAAY;EAEX,IAAI,EAAE,MAAMD,UAAU,CAACE,cAAc,CAAC,CAAC,CAAC,EAAE;IACxC;EACF;EAEAF,UAAU,CAACG,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAA6B,KAAK;IACpE,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAAA,IAAAE,qBAAA;UACF,MAAM;YAACC,KAAK;YAAEC;UAAO,CAAC,GAAGH,OAAO;UAChC,MAAMI,MAAM,GAAG,QAAAH,qBAAA,GAAML,eAAe,CAACS,MAAM,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAAK,IAAA,CAAAV,eAAe,EAAUM,KAAK,EAAEC,OAAiC,CAAC;UACvFR,UAAU,CAACY,WAAW,CAAC,MAAM,EAAE;YAACH;UAAM,CAAC,CAAC;QAC1C,CAAC,CAAC,OAAOI,KAAK,EAAE;UACd,MAAMC,OAAO,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACC,OAAO,GAAG,EAAE;UAC3Dd,UAAU,CAACY,WAAW,CAAC,OAAO,EAAE;YAACC,KAAK,EAAEC;UAAO,CAAC,CAAC;QACnD;QACA;MACF;IACF;EACF,CAAC;AACH,CAAC,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { WorkerBody } from '@loaders.gl/worker-utils';
|
|
2
2
|
import { KTX2BasisWriter } from "../ktx2-basis-writer.js";
|
|
3
|
-
(() => {
|
|
4
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
3
|
+
(async () => {
|
|
4
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
5
5
|
return;
|
|
6
6
|
}
|
|
7
7
|
WorkerBody.onmessage = async (type, payload) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ktx2-basis-writer-worker.js","names":["WorkerBody","KTX2BasisWriter","inWorkerThread","onmessage","type","payload","_KTX2BasisWriter$enco","input","options","result","encode","call","postMessage","error","message","Error"],"sources":["../../src/workers/ktx2-basis-writer-worker.ts"],"sourcesContent":["import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';\n\n(() => {\n // Check that we are actually in a worker thread\n if (!WorkerBody.inWorkerThread()) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],"mappings":"AAAA,SAAQA,UAAU,QAA6B,0BAA0B;AAAC,SAClEC,eAAe;AAEvB,CAAC,
|
|
1
|
+
{"version":3,"file":"ktx2-basis-writer-worker.js","names":["WorkerBody","KTX2BasisWriter","inWorkerThread","onmessage","type","payload","_KTX2BasisWriter$enco","input","options","result","encode","call","postMessage","error","message","Error"],"sources":["../../src/workers/ktx2-basis-writer-worker.ts"],"sourcesContent":["import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';\nimport {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';\n\n(async () => {\n // Check that we are actually in a worker thread\n if (!(await WorkerBody.inWorkerThread())) {\n return;\n }\n\n WorkerBody.onmessage = async (type, payload: WorkerMessagePayload) => {\n switch (type) {\n case 'process':\n try {\n const {input, options} = payload;\n const result = await KTX2BasisWriter.encode?.(input, options as KTX2BasisWriterOptions);\n WorkerBody.postMessage('done', {result});\n } catch (error) {\n const message = error instanceof Error ? error.message : '';\n WorkerBody.postMessage('error', {error: message});\n }\n break;\n default:\n }\n };\n})();\n"],"mappings":"AAAA,SAAQA,UAAU,QAA6B,0BAA0B;AAAC,SAClEC,eAAe;AAEvB,CAAC,YAAY;EAEX,IAAI,EAAE,MAAMD,UAAU,CAACE,cAAc,CAAC,CAAC,CAAC,EAAE;IACxC;EACF;EAEAF,UAAU,CAACG,SAAS,GAAG,OAAOC,IAAI,EAAEC,OAA6B,KAAK;IACpE,QAAQD,IAAI;MACV,KAAK,SAAS;QACZ,IAAI;UAAA,IAAAE,qBAAA;UACF,MAAM;YAACC,KAAK;YAAEC;UAAO,CAAC,GAAGH,OAAO;UAChC,MAAMI,MAAM,GAAG,QAAAH,qBAAA,GAAML,eAAe,CAACS,MAAM,cAAAJ,qBAAA,uBAAtBA,qBAAA,CAAAK,IAAA,CAAAV,eAAe,EAAUM,KAAK,EAAEC,OAAiC,CAAC;UACvFR,UAAU,CAACY,WAAW,CAAC,MAAM,EAAE;YAACH;UAAM,CAAC,CAAC;QAC1C,CAAC,CAAC,OAAOI,KAAK,EAAE;UACd,MAAMC,OAAO,GAAGD,KAAK,YAAYE,KAAK,GAAGF,KAAK,CAACC,OAAO,GAAG,EAAE;UAC3Dd,UAAU,CAACY,WAAW,CAAC,OAAO,EAAE;YAACC,KAAK,EAAEC;UAAO,CAAC,CAAC;QACnD;QACA;MACF;IACF;EACF,CAAC;AACH,CAAC,EAAE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@loaders.gl/textures",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.2",
|
|
4
4
|
"description": "Framework-independent loaders for compressed and super compressed (basis) textures ",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
@@ -53,15 +53,15 @@
|
|
|
53
53
|
"build-crunch-worker": "esbuild src/workers/crunch-worker.ts --outfile=dist/crunch-worker.js --target=esnext --bundle --define:__VERSION__=\\\"$npm_package_version\\\""
|
|
54
54
|
},
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@loaders.gl/images": "4.0.
|
|
57
|
-
"@loaders.gl/loader-utils": "4.0.
|
|
58
|
-
"@loaders.gl/schema": "4.0.
|
|
59
|
-
"@loaders.gl/worker-utils": "4.0.
|
|
56
|
+
"@loaders.gl/images": "4.0.2",
|
|
57
|
+
"@loaders.gl/loader-utils": "4.0.2",
|
|
58
|
+
"@loaders.gl/schema": "4.0.2",
|
|
59
|
+
"@loaders.gl/worker-utils": "4.0.2",
|
|
60
60
|
"ktx-parse": "^0.0.4",
|
|
61
61
|
"texture-compressor": "^1.0.2"
|
|
62
62
|
},
|
|
63
63
|
"devDependencies": {
|
|
64
|
-
"@loaders.gl/polyfills": "4.0.
|
|
64
|
+
"@loaders.gl/polyfills": "4.0.2"
|
|
65
65
|
},
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "471058d109d5652f28c32c1f296fd632f9a5c806"
|
|
67
67
|
}
|
|
@@ -36,7 +36,10 @@ export const CompressedTextureWriter: Writer<unknown, unknown, CompressedTexture
|
|
|
36
36
|
}
|
|
37
37
|
},
|
|
38
38
|
|
|
39
|
-
encodeURLtoURL: encodeImageURLToCompressedTextureURL
|
|
39
|
+
encodeURLtoURL: encodeImageURLToCompressedTextureURL,
|
|
40
|
+
encode() {
|
|
41
|
+
throw new Error('Not implemented');
|
|
42
|
+
}
|
|
40
43
|
};
|
|
41
44
|
|
|
42
45
|
// TYPE TESTS - TODO find a better way than exporting junk
|
|
@@ -3,9 +3,9 @@ import '@loaders.gl/polyfills';
|
|
|
3
3
|
import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';
|
|
4
4
|
import {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';
|
|
5
5
|
|
|
6
|
-
(() => {
|
|
6
|
+
(async () => {
|
|
7
7
|
// Check that we are actually in a worker thread
|
|
8
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
8
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
9
9
|
return;
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {WorkerBody, WorkerMessagePayload} from '@loaders.gl/worker-utils';
|
|
2
2
|
import {KTX2BasisWriter, KTX2BasisWriterOptions} from '../ktx2-basis-writer';
|
|
3
3
|
|
|
4
|
-
(() => {
|
|
4
|
+
(async () => {
|
|
5
5
|
// Check that we are actually in a worker thread
|
|
6
|
-
if (!WorkerBody.inWorkerThread()) {
|
|
6
|
+
if (!(await WorkerBody.inWorkerThread())) {
|
|
7
7
|
return;
|
|
8
8
|
}
|
|
9
9
|
|