@loaders.gl/textures 4.0.0-alpha.17 → 4.0.0-alpha.19
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 +70 -71
- package/dist/basis-worker.js +46 -30
- package/dist/compressed-texture-worker.js +46 -30
- package/dist/crunch-worker.js +33 -17
- package/dist/dist.min.js +74 -37
- package/dist/es5/index.js +14 -0
- package/dist/es5/index.js.map +1 -1
- package/dist/es5/ktx2-basis-writer.js +4 -2
- package/dist/es5/ktx2-basis-writer.js.map +1 -1
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js +6 -5
- package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/es5/lib/parsers/basis-module-loader.js +26 -21
- package/dist/es5/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/es5/lib/parsers/crunch-module-loader.js +6 -1
- package/dist/es5/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/es5/lib/parsers/parse-basis.js +7 -7
- package/dist/es5/lib/parsers/parse-basis.js.map +1 -1
- package/dist/es5/lib/texture-api/deep-load.js.map +1 -1
- package/dist/es5/lib/utils/version.js +1 -1
- package/dist/es5/workers/ktx2-basis-writer-worker-node.js.map +1 -1
- package/dist/es5/workers/ktx2-basis-writer-worker.js.map +1 -1
- package/dist/esm/index.js +2 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/ktx2-basis-writer.js +6 -4
- package/dist/esm/ktx2-basis-writer.js.map +1 -1
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js +1 -1
- package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
- package/dist/esm/lib/parsers/basis-module-loader.js +13 -10
- package/dist/esm/lib/parsers/basis-module-loader.js.map +1 -1
- package/dist/esm/lib/parsers/crunch-module-loader.js +4 -1
- package/dist/esm/lib/parsers/crunch-module-loader.js.map +1 -1
- package/dist/esm/lib/parsers/parse-basis.js +3 -3
- package/dist/esm/lib/parsers/parse-basis.js.map +1 -1
- package/dist/esm/lib/texture-api/deep-load.js.map +1 -1
- package/dist/esm/lib/utils/version.js +1 -1
- package/dist/esm/workers/ktx2-basis-writer-worker-node.js.map +1 -1
- package/dist/esm/workers/ktx2-basis-writer-worker.js.map +1 -1
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +6 -1
- package/dist/ktx2-basis-writer-worker-node.js +73 -67
- package/dist/ktx2-basis-writer-worker.js +49 -26
- package/dist/ktx2-basis-writer.d.ts +8 -6
- package/dist/ktx2-basis-writer.d.ts.map +1 -1
- package/dist/ktx2-basis-writer.js +6 -4
- package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
- package/dist/lib/encoders/encode-ktx2-basis-texture.js +1 -1
- package/dist/lib/parsers/basis-module-loader.d.ts +11 -1
- package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/basis-module-loader.js +21 -17
- package/dist/lib/parsers/crunch-module-loader.d.ts +4 -0
- package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
- package/dist/lib/parsers/crunch-module-loader.js +6 -2
- package/dist/lib/parsers/parse-basis.js +2 -2
- package/dist/lib/texture-api/deep-load.d.ts.map +1 -1
- package/dist/lib/texture-api/deep-load.js +0 -1
- package/dist/npy-worker.js +1 -1
- package/package.json +7 -7
- package/src/index.ts +4 -0
- package/src/ktx2-basis-writer.ts +14 -10
- package/src/lib/encoders/encode-ktx2-basis-texture.ts +6 -1
- package/src/lib/parsers/basis-module-loader.ts +19 -16
- package/src/lib/parsers/crunch-module-loader.ts +6 -1
- package/src/lib/parsers/parse-basis.ts +3 -3
- package/src/lib/texture-api/deep-load.ts +0 -1
- package/src/workers/ktx2-basis-writer-worker-node.ts +2 -2
- package/src/workers/ktx2-basis-writer-worker.ts +2 -2
|
@@ -21408,7 +21408,7 @@ var require_cookie = __commonJS({
|
|
|
21408
21408
|
var Store = require_store().Store;
|
|
21409
21409
|
var MemoryCookieStore = require_memstore().MemoryCookieStore;
|
|
21410
21410
|
var pathMatch = require_pathMatch().pathMatch;
|
|
21411
|
-
var
|
|
21411
|
+
var VERSION4 = require_version();
|
|
21412
21412
|
var punycode;
|
|
21413
21413
|
try {
|
|
21414
21414
|
punycode = require("punycode");
|
|
@@ -22225,7 +22225,7 @@ var require_cookie = __commonJS({
|
|
|
22225
22225
|
type = null;
|
|
22226
22226
|
}
|
|
22227
22227
|
var serialized = {
|
|
22228
|
-
version: "tough-cookie@" +
|
|
22228
|
+
version: "tough-cookie@" + VERSION4,
|
|
22229
22229
|
storeType: type,
|
|
22230
22230
|
rejectPublicSuffixes: !!this.rejectPublicSuffixes,
|
|
22231
22231
|
cookies: []
|
|
@@ -22377,7 +22377,7 @@ var require_cookie = __commonJS({
|
|
|
22377
22377
|
CAN_BE_SYNC.forEach(function(method) {
|
|
22378
22378
|
CookieJar.prototype[method + "Sync"] = syncWrap(method);
|
|
22379
22379
|
});
|
|
22380
|
-
exports2.version =
|
|
22380
|
+
exports2.version = VERSION4;
|
|
22381
22381
|
exports2.CookieJar = CookieJar;
|
|
22382
22382
|
exports2.Cookie = Cookie;
|
|
22383
22383
|
exports2.Store = Store;
|
|
@@ -62939,48 +62939,12 @@ var Response = class {
|
|
|
62939
62939
|
// ../polyfills/src/node/fetch/fetch.node.ts
|
|
62940
62940
|
var import_http = __toModule(require("http"));
|
|
62941
62941
|
var import_https = __toModule(require("https"));
|
|
62942
|
-
|
|
62943
|
-
// ../polyfills/src/node/fetch/fetch-file.node.ts
|
|
62944
|
-
var import_fs = __toModule(require("fs"));
|
|
62945
|
-
async function fetchFileNode(url, options) {
|
|
62946
|
-
const noqueryUrl = url.split("?")[0];
|
|
62947
|
-
try {
|
|
62948
|
-
const body = await new Promise((resolve, reject) => {
|
|
62949
|
-
const stream = import_fs.default.createReadStream(noqueryUrl, { encoding: null });
|
|
62950
|
-
stream.once("readable", () => resolve(stream));
|
|
62951
|
-
stream.on("error", (error) => reject(error));
|
|
62952
|
-
});
|
|
62953
|
-
const status = 200;
|
|
62954
|
-
const statusText = "OK";
|
|
62955
|
-
const headers = getHeadersForFile(noqueryUrl);
|
|
62956
|
-
return new Response(body, { headers, status, statusText, url });
|
|
62957
|
-
} catch (error) {
|
|
62958
|
-
const status = 400;
|
|
62959
|
-
const statusText = error.message;
|
|
62960
|
-
const headers = {};
|
|
62961
|
-
return new Response(error.message, { headers, status, statusText, url });
|
|
62962
|
-
}
|
|
62963
|
-
}
|
|
62964
|
-
function getHeadersForFile(noqueryUrl) {
|
|
62965
|
-
const headers = {};
|
|
62966
|
-
if (!headers["content-length"]) {
|
|
62967
|
-
const stats = import_fs.default.statSync(noqueryUrl);
|
|
62968
|
-
headers["content-length"] = stats.size;
|
|
62969
|
-
}
|
|
62970
|
-
if (noqueryUrl.endsWith(".gz")) {
|
|
62971
|
-
noqueryUrl = noqueryUrl.slice(0, -3);
|
|
62972
|
-
headers["content-encoding"] = "gzip";
|
|
62973
|
-
}
|
|
62974
|
-
return new Headers(headers);
|
|
62975
|
-
}
|
|
62976
|
-
|
|
62977
|
-
// ../polyfills/src/node/fetch/fetch.node.ts
|
|
62978
62942
|
var isDataURL = (url) => url.startsWith("data:");
|
|
62979
62943
|
var isRequestURL = (url) => url.startsWith("http:") || url.startsWith("https:");
|
|
62980
62944
|
async function fetchNode(url, options) {
|
|
62981
62945
|
try {
|
|
62982
|
-
if (
|
|
62983
|
-
return await
|
|
62946
|
+
if (globalThis.fetch !== fetchNode && (isRequestURL(url) || isDataURL(url))) {
|
|
62947
|
+
return await fetch(url, options);
|
|
62984
62948
|
}
|
|
62985
62949
|
if (isDataURL(url)) {
|
|
62986
62950
|
const { arrayBuffer, mimeType } = decodeDataUri(url);
|
|
@@ -63338,7 +63302,7 @@ if (!("allSettled" in Promise)) {
|
|
|
63338
63302
|
}
|
|
63339
63303
|
|
|
63340
63304
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
63341
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
63305
|
+
var VERSION = true ? "4.0.0-alpha.19" : DEFAULT_VERSION;
|
|
63342
63306
|
if (false) {
|
|
63343
63307
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
63344
63308
|
}
|
|
@@ -63479,11 +63443,30 @@ function isKnownMessage(message) {
|
|
|
63479
63443
|
// ../worker-utils/src/lib/node/require-utils.node.ts
|
|
63480
63444
|
var require_utils_node_exports = {};
|
|
63481
63445
|
__export(require_utils_node_exports, {
|
|
63446
|
+
readFileAsArrayBuffer: () => readFileAsArrayBuffer,
|
|
63447
|
+
readFileAsText: () => readFileAsText,
|
|
63482
63448
|
requireFromFile: () => requireFromFile,
|
|
63483
63449
|
requireFromString: () => requireFromString
|
|
63484
63450
|
});
|
|
63485
63451
|
var import_module = __toModule(require("module"));
|
|
63486
63452
|
var import_path = __toModule(require("path"));
|
|
63453
|
+
var import_fs = __toModule(require("fs"));
|
|
63454
|
+
async function readFileAsArrayBuffer(filename) {
|
|
63455
|
+
if (filename.startsWith("http")) {
|
|
63456
|
+
const response = await fetch(filename);
|
|
63457
|
+
return await response.arrayBuffer();
|
|
63458
|
+
}
|
|
63459
|
+
const buffer = import_fs.default.readFileSync(filename);
|
|
63460
|
+
return buffer.buffer;
|
|
63461
|
+
}
|
|
63462
|
+
async function readFileAsText(filename) {
|
|
63463
|
+
if (filename.startsWith("http")) {
|
|
63464
|
+
const response = await fetch(filename);
|
|
63465
|
+
return await response.text();
|
|
63466
|
+
}
|
|
63467
|
+
const text = import_fs.default.readFileSync(filename, "utf8");
|
|
63468
|
+
return text;
|
|
63469
|
+
}
|
|
63487
63470
|
async function requireFromFile(filename) {
|
|
63488
63471
|
if (filename.startsWith("http")) {
|
|
63489
63472
|
const response = await fetch(filename);
|
|
@@ -63519,37 +63502,37 @@ function requireFromString(code, filename = "", options) {
|
|
|
63519
63502
|
var LATEST = "beta";
|
|
63520
63503
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
63521
63504
|
var loadLibraryPromises = {};
|
|
63522
|
-
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
63505
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
63523
63506
|
if (moduleName) {
|
|
63524
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
63507
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
63525
63508
|
}
|
|
63526
63509
|
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
63527
63510
|
return await loadLibraryPromises[libraryUrl];
|
|
63528
63511
|
}
|
|
63529
|
-
function getLibraryUrl(library, moduleName, options) {
|
|
63530
|
-
if (library.startsWith("http")) {
|
|
63512
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
63513
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
63531
63514
|
return library;
|
|
63532
63515
|
}
|
|
63516
|
+
libraryName = libraryName || library;
|
|
63533
63517
|
const modules = options.modules || {};
|
|
63534
|
-
if (modules[
|
|
63535
|
-
return modules[
|
|
63518
|
+
if (modules[libraryName]) {
|
|
63519
|
+
return modules[libraryName];
|
|
63536
63520
|
}
|
|
63537
63521
|
if (!isBrowser2) {
|
|
63538
|
-
return `modules/${moduleName}/dist/libs/${
|
|
63522
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
63539
63523
|
}
|
|
63540
63524
|
if (options.CDN) {
|
|
63541
63525
|
assert2(options.CDN.startsWith("http"));
|
|
63542
|
-
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${
|
|
63526
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
63543
63527
|
}
|
|
63544
63528
|
if (isWorker) {
|
|
63545
|
-
return `../src/libs/${
|
|
63529
|
+
return `../src/libs/${libraryName}`;
|
|
63546
63530
|
}
|
|
63547
|
-
return `modules/${moduleName}/src/libs/${
|
|
63531
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
63548
63532
|
}
|
|
63549
63533
|
async function loadLibraryFromFile(libraryUrl) {
|
|
63550
63534
|
if (libraryUrl.endsWith("wasm")) {
|
|
63551
|
-
|
|
63552
|
-
return await response2.arrayBuffer();
|
|
63535
|
+
return await loadAsArrayBuffer(libraryUrl);
|
|
63553
63536
|
}
|
|
63554
63537
|
if (!isBrowser2) {
|
|
63555
63538
|
try {
|
|
@@ -63561,8 +63544,7 @@ async function loadLibraryFromFile(libraryUrl) {
|
|
|
63561
63544
|
if (isWorker) {
|
|
63562
63545
|
return importScripts(libraryUrl);
|
|
63563
63546
|
}
|
|
63564
|
-
const
|
|
63565
|
-
const scriptSource = await response.text();
|
|
63547
|
+
const scriptSource = await loadAsText(libraryUrl);
|
|
63566
63548
|
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
63567
63549
|
}
|
|
63568
63550
|
function loadLibraryFromString(scriptSource, id) {
|
|
@@ -63583,6 +63565,20 @@ function loadLibraryFromString(scriptSource, id) {
|
|
|
63583
63565
|
document.body.appendChild(script);
|
|
63584
63566
|
return null;
|
|
63585
63567
|
}
|
|
63568
|
+
async function loadAsArrayBuffer(url) {
|
|
63569
|
+
if (!readFileAsArrayBuffer || url.startsWith("http")) {
|
|
63570
|
+
const response = await fetch(url);
|
|
63571
|
+
return await response.arrayBuffer();
|
|
63572
|
+
}
|
|
63573
|
+
return await readFileAsArrayBuffer(url);
|
|
63574
|
+
}
|
|
63575
|
+
async function loadAsText(url) {
|
|
63576
|
+
if (!readFileAsText || url.startsWith("http")) {
|
|
63577
|
+
const response = await fetch(url);
|
|
63578
|
+
return await response.text();
|
|
63579
|
+
}
|
|
63580
|
+
return await readFileAsText(url);
|
|
63581
|
+
}
|
|
63586
63582
|
|
|
63587
63583
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
63588
63584
|
var requestId = 0;
|
|
@@ -63658,32 +63654,35 @@ async function parseData({ loader, arrayBuffer, options, context }) {
|
|
|
63658
63654
|
}
|
|
63659
63655
|
|
|
63660
63656
|
// src/lib/utils/version.ts
|
|
63661
|
-
var VERSION3 = true ? "4.0.0-alpha.
|
|
63657
|
+
var VERSION3 = true ? "4.0.0-alpha.19" : "beta";
|
|
63662
63658
|
|
|
63663
63659
|
// src/lib/parsers/basis-module-loader.ts
|
|
63664
|
-
var
|
|
63665
|
-
|
|
63666
|
-
|
|
63660
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
63661
|
+
TRANSCODER: "basis_transcoder.js",
|
|
63662
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
63663
|
+
ENCODER: "basis_encoder.js",
|
|
63664
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
63665
|
+
};
|
|
63667
63666
|
var loadBasisTranscoderPromise;
|
|
63668
|
-
async function
|
|
63667
|
+
async function loadBasisTranscoderModule(options) {
|
|
63669
63668
|
const modules = options.modules || {};
|
|
63670
63669
|
if (modules.basis) {
|
|
63671
63670
|
return modules.basis;
|
|
63672
63671
|
}
|
|
63673
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise ||
|
|
63672
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
63674
63673
|
return await loadBasisTranscoderPromise;
|
|
63675
63674
|
}
|
|
63676
|
-
async function
|
|
63675
|
+
async function loadBasisTranscoder(options) {
|
|
63677
63676
|
let BASIS = null;
|
|
63678
63677
|
let wasmBinary = null;
|
|
63679
63678
|
[BASIS, wasmBinary] = await Promise.all([
|
|
63680
|
-
await loadLibrary(
|
|
63681
|
-
await loadLibrary(
|
|
63679
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
63680
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
63682
63681
|
]);
|
|
63683
63682
|
BASIS = BASIS || globalThis.BASIS;
|
|
63684
|
-
return await
|
|
63683
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
63685
63684
|
}
|
|
63686
|
-
function
|
|
63685
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
63687
63686
|
const options = {};
|
|
63688
63687
|
if (wasmBinary) {
|
|
63689
63688
|
options.wasmBinary = wasmBinary;
|
|
@@ -63709,8 +63708,8 @@ async function loadBasisEncoder(options) {
|
|
|
63709
63708
|
let BASIS_ENCODER = null;
|
|
63710
63709
|
let wasmBinary = null;
|
|
63711
63710
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
63712
|
-
await loadLibrary(
|
|
63713
|
-
await loadLibrary(
|
|
63711
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
63712
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
63714
63713
|
]);
|
|
63715
63714
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
63716
63715
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
@@ -63900,7 +63899,7 @@ async function parseBasis(data, options) {
|
|
|
63900
63899
|
const fileConstructors = await loadBasisEncoderModule(options);
|
|
63901
63900
|
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
63902
63901
|
}
|
|
63903
|
-
const { BasisFile } = await
|
|
63902
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
63904
63903
|
return parseBasisFile(BasisFile, data, options);
|
|
63905
63904
|
}
|
|
63906
63905
|
switch (options.basis.module) {
|
|
@@ -63915,7 +63914,7 @@ async function parseBasis(data, options) {
|
|
|
63915
63914
|
}
|
|
63916
63915
|
case "transcoder":
|
|
63917
63916
|
default:
|
|
63918
|
-
const { BasisFile } = await
|
|
63917
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
63919
63918
|
return parseBasisFile(BasisFile, data, options);
|
|
63920
63919
|
}
|
|
63921
63920
|
}
|
package/dist/basis-worker.js
CHANGED
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
});
|
|
29
29
|
|
|
30
30
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
31
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
31
|
+
var VERSION = true ? "4.0.0-alpha.19" : DEFAULT_VERSION;
|
|
32
32
|
if (false) {
|
|
33
33
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
34
34
|
}
|
|
@@ -171,37 +171,37 @@
|
|
|
171
171
|
var LATEST = "beta";
|
|
172
172
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
173
173
|
var loadLibraryPromises = {};
|
|
174
|
-
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
174
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
175
175
|
if (moduleName) {
|
|
176
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
176
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
177
177
|
}
|
|
178
178
|
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
179
179
|
return await loadLibraryPromises[libraryUrl];
|
|
180
180
|
}
|
|
181
|
-
function getLibraryUrl(library, moduleName, options) {
|
|
182
|
-
if (library.startsWith("http")) {
|
|
181
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
182
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
183
183
|
return library;
|
|
184
184
|
}
|
|
185
|
+
libraryName = libraryName || library;
|
|
185
186
|
const modules = options.modules || {};
|
|
186
|
-
if (modules[
|
|
187
|
-
return modules[
|
|
187
|
+
if (modules[libraryName]) {
|
|
188
|
+
return modules[libraryName];
|
|
188
189
|
}
|
|
189
190
|
if (!isBrowser) {
|
|
190
|
-
return `modules/${moduleName}/dist/libs/${
|
|
191
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
191
192
|
}
|
|
192
193
|
if (options.CDN) {
|
|
193
194
|
assert(options.CDN.startsWith("http"));
|
|
194
|
-
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${
|
|
195
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
195
196
|
}
|
|
196
197
|
if (isWorker) {
|
|
197
|
-
return `../src/libs/${
|
|
198
|
+
return `../src/libs/${libraryName}`;
|
|
198
199
|
}
|
|
199
|
-
return `modules/${moduleName}/src/libs/${
|
|
200
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
200
201
|
}
|
|
201
202
|
async function loadLibraryFromFile(libraryUrl) {
|
|
202
203
|
if (libraryUrl.endsWith("wasm")) {
|
|
203
|
-
|
|
204
|
-
return await response2.arrayBuffer();
|
|
204
|
+
return await loadAsArrayBuffer(libraryUrl);
|
|
205
205
|
}
|
|
206
206
|
if (!isBrowser) {
|
|
207
207
|
try {
|
|
@@ -213,8 +213,7 @@
|
|
|
213
213
|
if (isWorker) {
|
|
214
214
|
return importScripts(libraryUrl);
|
|
215
215
|
}
|
|
216
|
-
const
|
|
217
|
-
const scriptSource = await response.text();
|
|
216
|
+
const scriptSource = await loadAsText(libraryUrl);
|
|
218
217
|
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
219
218
|
}
|
|
220
219
|
function loadLibraryFromString(scriptSource, id) {
|
|
@@ -235,6 +234,20 @@
|
|
|
235
234
|
document.body.appendChild(script);
|
|
236
235
|
return null;
|
|
237
236
|
}
|
|
237
|
+
async function loadAsArrayBuffer(url) {
|
|
238
|
+
if (!node.readFileAsArrayBuffer || url.startsWith("http")) {
|
|
239
|
+
const response = await fetch(url);
|
|
240
|
+
return await response.arrayBuffer();
|
|
241
|
+
}
|
|
242
|
+
return await node.readFileAsArrayBuffer(url);
|
|
243
|
+
}
|
|
244
|
+
async function loadAsText(url) {
|
|
245
|
+
if (!node.readFileAsText || url.startsWith("http")) {
|
|
246
|
+
const response = await fetch(url);
|
|
247
|
+
return await response.text();
|
|
248
|
+
}
|
|
249
|
+
return await node.readFileAsText(url);
|
|
250
|
+
}
|
|
238
251
|
|
|
239
252
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
240
253
|
var requestId = 0;
|
|
@@ -312,32 +325,35 @@
|
|
|
312
325
|
}
|
|
313
326
|
|
|
314
327
|
// src/lib/utils/version.ts
|
|
315
|
-
var VERSION3 = true ? "4.0.0-alpha.
|
|
328
|
+
var VERSION3 = true ? "4.0.0-alpha.19" : "beta";
|
|
316
329
|
|
|
317
330
|
// src/lib/parsers/basis-module-loader.ts
|
|
318
|
-
var
|
|
319
|
-
|
|
320
|
-
|
|
331
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
332
|
+
TRANSCODER: "basis_transcoder.js",
|
|
333
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
334
|
+
ENCODER: "basis_encoder.js",
|
|
335
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
336
|
+
};
|
|
321
337
|
var loadBasisTranscoderPromise;
|
|
322
|
-
async function
|
|
338
|
+
async function loadBasisTranscoderModule(options) {
|
|
323
339
|
const modules = options.modules || {};
|
|
324
340
|
if (modules.basis) {
|
|
325
341
|
return modules.basis;
|
|
326
342
|
}
|
|
327
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise ||
|
|
343
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
328
344
|
return await loadBasisTranscoderPromise;
|
|
329
345
|
}
|
|
330
|
-
async function
|
|
346
|
+
async function loadBasisTranscoder(options) {
|
|
331
347
|
let BASIS = null;
|
|
332
348
|
let wasmBinary = null;
|
|
333
349
|
[BASIS, wasmBinary] = await Promise.all([
|
|
334
|
-
await loadLibrary(
|
|
335
|
-
await loadLibrary(
|
|
350
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
351
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
336
352
|
]);
|
|
337
353
|
BASIS = BASIS || globalThis.BASIS;
|
|
338
|
-
return await
|
|
354
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
339
355
|
}
|
|
340
|
-
function
|
|
356
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
341
357
|
const options = {};
|
|
342
358
|
if (wasmBinary) {
|
|
343
359
|
options.wasmBinary = wasmBinary;
|
|
@@ -363,8 +379,8 @@
|
|
|
363
379
|
let BASIS_ENCODER = null;
|
|
364
380
|
let wasmBinary = null;
|
|
365
381
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
366
|
-
await loadLibrary(
|
|
367
|
-
await loadLibrary(
|
|
382
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
383
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
368
384
|
]);
|
|
369
385
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
370
386
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
@@ -581,7 +597,7 @@
|
|
|
581
597
|
const fileConstructors = await loadBasisEncoderModule(options);
|
|
582
598
|
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
583
599
|
}
|
|
584
|
-
const { BasisFile } = await
|
|
600
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
585
601
|
return parseBasisFile(BasisFile, data, options);
|
|
586
602
|
}
|
|
587
603
|
switch (options.basis.module) {
|
|
@@ -596,7 +612,7 @@
|
|
|
596
612
|
}
|
|
597
613
|
case "transcoder":
|
|
598
614
|
default:
|
|
599
|
-
const { BasisFile } = await
|
|
615
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
600
616
|
return parseBasisFile(BasisFile, data, options);
|
|
601
617
|
}
|
|
602
618
|
}
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
// ../worker-utils/src/lib/env-utils/version.ts
|
|
38
|
-
var VERSION = true ? "4.0.0-alpha.
|
|
38
|
+
var VERSION = true ? "4.0.0-alpha.19" : DEFAULT_VERSION;
|
|
39
39
|
if (false) {
|
|
40
40
|
console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
|
|
41
41
|
}
|
|
@@ -178,37 +178,37 @@
|
|
|
178
178
|
var LATEST = "beta";
|
|
179
179
|
var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
|
|
180
180
|
var loadLibraryPromises = {};
|
|
181
|
-
async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
|
|
181
|
+
async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
|
|
182
182
|
if (moduleName) {
|
|
183
|
-
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
|
|
183
|
+
libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
|
|
184
184
|
}
|
|
185
185
|
loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
|
|
186
186
|
return await loadLibraryPromises[libraryUrl];
|
|
187
187
|
}
|
|
188
|
-
function getLibraryUrl(library, moduleName, options) {
|
|
189
|
-
if (library.startsWith("http")) {
|
|
188
|
+
function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
|
|
189
|
+
if (!options.useLocalLibraries && library.startsWith("http")) {
|
|
190
190
|
return library;
|
|
191
191
|
}
|
|
192
|
+
libraryName = libraryName || library;
|
|
192
193
|
const modules = options.modules || {};
|
|
193
|
-
if (modules[
|
|
194
|
-
return modules[
|
|
194
|
+
if (modules[libraryName]) {
|
|
195
|
+
return modules[libraryName];
|
|
195
196
|
}
|
|
196
197
|
if (!isBrowser) {
|
|
197
|
-
return `modules/${moduleName}/dist/libs/${
|
|
198
|
+
return `modules/${moduleName}/dist/libs/${libraryName}`;
|
|
198
199
|
}
|
|
199
200
|
if (options.CDN) {
|
|
200
201
|
assert2(options.CDN.startsWith("http"));
|
|
201
|
-
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${
|
|
202
|
+
return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${libraryName}`;
|
|
202
203
|
}
|
|
203
204
|
if (isWorker) {
|
|
204
|
-
return `../src/libs/${
|
|
205
|
+
return `../src/libs/${libraryName}`;
|
|
205
206
|
}
|
|
206
|
-
return `modules/${moduleName}/src/libs/${
|
|
207
|
+
return `modules/${moduleName}/src/libs/${libraryName}`;
|
|
207
208
|
}
|
|
208
209
|
async function loadLibraryFromFile(libraryUrl) {
|
|
209
210
|
if (libraryUrl.endsWith("wasm")) {
|
|
210
|
-
|
|
211
|
-
return await response2.arrayBuffer();
|
|
211
|
+
return await loadAsArrayBuffer(libraryUrl);
|
|
212
212
|
}
|
|
213
213
|
if (!isBrowser) {
|
|
214
214
|
try {
|
|
@@ -220,8 +220,7 @@
|
|
|
220
220
|
if (isWorker) {
|
|
221
221
|
return importScripts(libraryUrl);
|
|
222
222
|
}
|
|
223
|
-
const
|
|
224
|
-
const scriptSource = await response.text();
|
|
223
|
+
const scriptSource = await loadAsText(libraryUrl);
|
|
225
224
|
return loadLibraryFromString(scriptSource, libraryUrl);
|
|
226
225
|
}
|
|
227
226
|
function loadLibraryFromString(scriptSource, id) {
|
|
@@ -242,6 +241,20 @@
|
|
|
242
241
|
document.body.appendChild(script);
|
|
243
242
|
return null;
|
|
244
243
|
}
|
|
244
|
+
async function loadAsArrayBuffer(url) {
|
|
245
|
+
if (!node.readFileAsArrayBuffer || url.startsWith("http")) {
|
|
246
|
+
const response = await fetch(url);
|
|
247
|
+
return await response.arrayBuffer();
|
|
248
|
+
}
|
|
249
|
+
return await node.readFileAsArrayBuffer(url);
|
|
250
|
+
}
|
|
251
|
+
async function loadAsText(url) {
|
|
252
|
+
if (!node.readFileAsText || url.startsWith("http")) {
|
|
253
|
+
const response = await fetch(url);
|
|
254
|
+
return await response.text();
|
|
255
|
+
}
|
|
256
|
+
return await node.readFileAsText(url);
|
|
257
|
+
}
|
|
245
258
|
|
|
246
259
|
// ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
|
|
247
260
|
var requestId = 0;
|
|
@@ -319,7 +332,7 @@
|
|
|
319
332
|
}
|
|
320
333
|
|
|
321
334
|
// src/lib/utils/version.ts
|
|
322
|
-
var VERSION3 = true ? "4.0.0-alpha.
|
|
335
|
+
var VERSION3 = true ? "4.0.0-alpha.19" : "beta";
|
|
323
336
|
|
|
324
337
|
// ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
|
|
325
338
|
var t = new Uint8Array([0]);
|
|
@@ -907,29 +920,32 @@
|
|
|
907
920
|
}
|
|
908
921
|
|
|
909
922
|
// src/lib/parsers/basis-module-loader.ts
|
|
910
|
-
var
|
|
911
|
-
|
|
912
|
-
|
|
923
|
+
var BASIS_EXTERNAL_LIBRARIES = {
|
|
924
|
+
TRANSCODER: "basis_transcoder.js",
|
|
925
|
+
TRANSCODER_WASM: "basis_transcoder.wasm",
|
|
926
|
+
ENCODER: "basis_encoder.js",
|
|
927
|
+
ENCODER_WASM: "basis_encoder.wasm"
|
|
928
|
+
};
|
|
913
929
|
var loadBasisTranscoderPromise;
|
|
914
|
-
async function
|
|
930
|
+
async function loadBasisTranscoderModule(options) {
|
|
915
931
|
const modules = options.modules || {};
|
|
916
932
|
if (modules.basis) {
|
|
917
933
|
return modules.basis;
|
|
918
934
|
}
|
|
919
|
-
loadBasisTranscoderPromise = loadBasisTranscoderPromise ||
|
|
935
|
+
loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
|
|
920
936
|
return await loadBasisTranscoderPromise;
|
|
921
937
|
}
|
|
922
|
-
async function
|
|
938
|
+
async function loadBasisTranscoder(options) {
|
|
923
939
|
let BASIS = null;
|
|
924
940
|
let wasmBinary = null;
|
|
925
941
|
[BASIS, wasmBinary] = await Promise.all([
|
|
926
|
-
await loadLibrary(
|
|
927
|
-
await loadLibrary(
|
|
942
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
|
|
943
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
|
|
928
944
|
]);
|
|
929
945
|
BASIS = BASIS || globalThis.BASIS;
|
|
930
|
-
return await
|
|
946
|
+
return await initializeBasisTranscoderModule(BASIS, wasmBinary);
|
|
931
947
|
}
|
|
932
|
-
function
|
|
948
|
+
function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
|
|
933
949
|
const options = {};
|
|
934
950
|
if (wasmBinary) {
|
|
935
951
|
options.wasmBinary = wasmBinary;
|
|
@@ -955,8 +971,8 @@
|
|
|
955
971
|
let BASIS_ENCODER = null;
|
|
956
972
|
let wasmBinary = null;
|
|
957
973
|
[BASIS_ENCODER, wasmBinary] = await Promise.all([
|
|
958
|
-
await loadLibrary(
|
|
959
|
-
await loadLibrary(
|
|
974
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
|
|
975
|
+
await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
|
|
960
976
|
]);
|
|
961
977
|
BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
|
|
962
978
|
return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
|
|
@@ -1062,7 +1078,7 @@
|
|
|
1062
1078
|
const fileConstructors = await loadBasisEncoderModule(options);
|
|
1063
1079
|
return parseKTX2File(fileConstructors.KTX2File, data, options);
|
|
1064
1080
|
}
|
|
1065
|
-
const { BasisFile } = await
|
|
1081
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
1066
1082
|
return parseBasisFile(BasisFile, data, options);
|
|
1067
1083
|
}
|
|
1068
1084
|
switch (options.basis.module) {
|
|
@@ -1077,7 +1093,7 @@
|
|
|
1077
1093
|
}
|
|
1078
1094
|
case "transcoder":
|
|
1079
1095
|
default:
|
|
1080
|
-
const { BasisFile } = await
|
|
1096
|
+
const { BasisFile } = await loadBasisTranscoderModule(options);
|
|
1081
1097
|
return parseBasisFile(BasisFile, data, options);
|
|
1082
1098
|
}
|
|
1083
1099
|
}
|