@loaders.gl/textures 4.0.0-alpha.8 → 4.0.0-beta.1

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.
Files changed (121) hide show
  1. package/dist/basis-worker-node.js +91 -79
  2. package/dist/basis-worker.js +66 -38
  3. package/dist/compressed-texture-loader.d.ts +2 -35
  4. package/dist/compressed-texture-loader.d.ts.map +1 -1
  5. package/dist/compressed-texture-worker.js +75 -47
  6. package/dist/crunch-loader.d.ts +9 -17
  7. package/dist/crunch-loader.d.ts.map +1 -1
  8. package/dist/crunch-worker.js +53 -25
  9. package/dist/dist.min.js +99 -55
  10. package/dist/es5/compressed-texture-loader.js +15 -17
  11. package/dist/es5/compressed-texture-loader.js.map +1 -1
  12. package/dist/es5/crunch-loader.js +1 -3
  13. package/dist/es5/crunch-loader.js.map +1 -1
  14. package/dist/es5/index.js +14 -0
  15. package/dist/es5/index.js.map +1 -1
  16. package/dist/es5/ktx2-basis-writer.js +5 -5
  17. package/dist/es5/ktx2-basis-writer.js.map +1 -1
  18. package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js +6 -5
  19. package/dist/es5/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
  20. package/dist/es5/lib/parsers/basis-module-loader.js +26 -21
  21. package/dist/es5/lib/parsers/basis-module-loader.js.map +1 -1
  22. package/dist/es5/lib/parsers/crunch-module-loader.js +6 -1
  23. package/dist/es5/lib/parsers/crunch-module-loader.js.map +1 -1
  24. package/dist/es5/lib/parsers/parse-basis.js +7 -7
  25. package/dist/es5/lib/parsers/parse-basis.js.map +1 -1
  26. package/dist/es5/lib/texture-api/deep-load.js.map +1 -1
  27. package/dist/es5/lib/utils/version.js +1 -1
  28. package/dist/es5/lib/utils/version.js.map +1 -1
  29. package/dist/es5/workers/compressed-texture-worker.js.map +1 -1
  30. package/dist/es5/workers/ktx2-basis-writer-worker-node.js.map +1 -1
  31. package/dist/es5/workers/ktx2-basis-writer-worker.js.map +1 -1
  32. package/dist/esm/compressed-texture-loader.js +10 -11
  33. package/dist/esm/compressed-texture-loader.js.map +1 -1
  34. package/dist/esm/crunch-loader.js +0 -1
  35. package/dist/esm/crunch-loader.js.map +1 -1
  36. package/dist/esm/index.js +2 -0
  37. package/dist/esm/index.js.map +1 -1
  38. package/dist/esm/ktx2-basis-writer.js +6 -5
  39. package/dist/esm/ktx2-basis-writer.js.map +1 -1
  40. package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js +1 -1
  41. package/dist/esm/lib/encoders/encode-ktx2-basis-texture.js.map +1 -1
  42. package/dist/esm/lib/parsers/basis-module-loader.js +13 -10
  43. package/dist/esm/lib/parsers/basis-module-loader.js.map +1 -1
  44. package/dist/esm/lib/parsers/crunch-module-loader.js +4 -1
  45. package/dist/esm/lib/parsers/crunch-module-loader.js.map +1 -1
  46. package/dist/esm/lib/parsers/parse-basis.js +3 -3
  47. package/dist/esm/lib/parsers/parse-basis.js.map +1 -1
  48. package/dist/esm/lib/texture-api/deep-load.js.map +1 -1
  49. package/dist/esm/lib/utils/version.js +1 -1
  50. package/dist/esm/lib/utils/version.js.map +1 -1
  51. package/dist/esm/workers/compressed-texture-worker.js.map +1 -1
  52. package/dist/esm/workers/ktx2-basis-writer-worker-node.js.map +1 -1
  53. package/dist/esm/workers/ktx2-basis-writer-worker.js.map +1 -1
  54. package/dist/index.d.ts +2 -0
  55. package/dist/index.d.ts.map +1 -1
  56. package/dist/ktx2-basis-writer-worker-node.js +86 -72
  57. package/dist/ktx2-basis-writer-worker.js +61 -31
  58. package/dist/ktx2-basis-writer.d.ts +8 -7
  59. package/dist/ktx2-basis-writer.d.ts.map +1 -1
  60. package/dist/lib/encoders/encode-ktx2-basis-texture.d.ts.map +1 -1
  61. package/dist/lib/parsers/basis-module-loader.d.ts +11 -1
  62. package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
  63. package/dist/lib/parsers/crunch-module-loader.d.ts +4 -0
  64. package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
  65. package/dist/lib/texture-api/deep-load.d.ts.map +1 -1
  66. package/dist/npy-worker.js +9 -4
  67. package/dist/workers/crunch-worker.d.ts +13 -9
  68. package/dist/workers/crunch-worker.d.ts.map +1 -1
  69. package/package.json +7 -7
  70. package/src/compressed-texture-loader.ts +14 -17
  71. package/src/crunch-loader.ts +10 -7
  72. package/src/index.ts +4 -0
  73. package/src/ktx2-basis-writer.ts +14 -13
  74. package/src/lib/encoders/encode-ktx2-basis-texture.ts +6 -1
  75. package/src/lib/parsers/basis-module-loader.ts +19 -16
  76. package/src/lib/parsers/crunch-module-loader.ts +6 -1
  77. package/src/lib/parsers/parse-basis.ts +3 -3
  78. package/src/lib/texture-api/deep-load.ts +0 -1
  79. package/src/workers/compressed-texture-worker.ts +1 -0
  80. package/src/workers/ktx2-basis-writer-worker-node.ts +2 -2
  81. package/src/workers/ktx2-basis-writer-worker.ts +2 -2
  82. package/dist/basis-loader.js +0 -37
  83. package/dist/bundle.js +0 -5
  84. package/dist/compressed-texture-loader.js +0 -64
  85. package/dist/compressed-texture-writer.js +0 -34
  86. package/dist/crunch-loader.js +0 -25
  87. package/dist/index.js +0 -52
  88. package/dist/ktx2-basis-writer.js +0 -26
  89. package/dist/lib/encoders/encode-ktx.js +0 -10
  90. package/dist/lib/encoders/encode-ktx2-basis-texture.js +0 -41
  91. package/dist/lib/encoders/encode-texture.js +0 -27
  92. package/dist/lib/gl-extensions.js +0 -72
  93. package/dist/lib/parsers/basis-module-loader.js +0 -114
  94. package/dist/lib/parsers/crunch-module-loader.js +0 -35
  95. package/dist/lib/parsers/parse-basis.js +0 -245
  96. package/dist/lib/parsers/parse-compressed-texture.js +0 -26
  97. package/dist/lib/parsers/parse-crunch.js +0 -106
  98. package/dist/lib/parsers/parse-dds.js +0 -108
  99. package/dist/lib/parsers/parse-ktx.js +0 -46
  100. package/dist/lib/parsers/parse-npy.js +0 -81
  101. package/dist/lib/parsers/parse-pvr.js +0 -250
  102. package/dist/lib/texture-api/async-deep-map.js +0 -41
  103. package/dist/lib/texture-api/deep-load.js +0 -16
  104. package/dist/lib/texture-api/generate-url.js +0 -17
  105. package/dist/lib/texture-api/load-image-array.js +0 -21
  106. package/dist/lib/texture-api/load-image-cube.js +0 -47
  107. package/dist/lib/texture-api/load-image.js +0 -43
  108. package/dist/lib/texture-api/texture-api-types.js +0 -3
  109. package/dist/lib/utils/extract-mipmap-images.js +0 -50
  110. package/dist/lib/utils/ktx-format-helper.js +0 -125
  111. package/dist/lib/utils/texture-formats.js +0 -51
  112. package/dist/lib/utils/version.js +0 -8
  113. package/dist/npy-loader.js +0 -31
  114. package/dist/types.js +0 -1
  115. package/dist/workers/basis-worker-node.js +0 -7
  116. package/dist/workers/basis-worker.js +0 -5
  117. package/dist/workers/compressed-texture-worker.js +0 -5
  118. package/dist/workers/crunch-worker.js +0 -14
  119. package/dist/workers/ktx2-basis-writer-worker-node.js +0 -28
  120. package/dist/workers/ktx2-basis-writer-worker.js +0 -26
  121. package/dist/workers/npy-worker.js +0 -5
@@ -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 VERSION5 = require_version();
21411
+ var VERSION3 = 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@" + VERSION5,
22228
+ version: "tough-cookie@" + VERSION3,
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 = VERSION5;
22380
+ exports2.version = VERSION3;
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 (!isRequestURL(url) && !isDataURL(url)) {
62983
- return await fetchFileNode(url, options);
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,10 +63302,20 @@ 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.8" : DEFAULT_VERSION;
63342
- if (false) {
63343
- console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
63305
+ function getVersion() {
63306
+ var _a;
63307
+ if (!((_a = globalThis._loadersgl_) == null ? void 0 : _a.version)) {
63308
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
63309
+ if (false) {
63310
+ console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
63311
+ globalThis._loadersgl_.version = NPM_TAG;
63312
+ } else {
63313
+ globalThis._loadersgl_.version = "4.0.0-beta.1";
63314
+ }
63315
+ }
63316
+ return globalThis._loadersgl_.version;
63344
63317
  }
63318
+ var VERSION = getVersion();
63345
63319
 
63346
63320
  // ../worker-utils/src/lib/env-utils/assert.ts
63347
63321
  function assert2(condition, message) {
@@ -63479,11 +63453,30 @@ function isKnownMessage(message) {
63479
63453
  // ../worker-utils/src/lib/node/require-utils.node.ts
63480
63454
  var require_utils_node_exports = {};
63481
63455
  __export(require_utils_node_exports, {
63456
+ readFileAsArrayBuffer: () => readFileAsArrayBuffer,
63457
+ readFileAsText: () => readFileAsText,
63482
63458
  requireFromFile: () => requireFromFile,
63483
63459
  requireFromString: () => requireFromString
63484
63460
  });
63485
63461
  var import_module = __toModule(require("module"));
63486
63462
  var import_path = __toModule(require("path"));
63463
+ var import_fs = __toModule(require("fs"));
63464
+ async function readFileAsArrayBuffer(filename) {
63465
+ if (filename.startsWith("http")) {
63466
+ const response = await fetch(filename);
63467
+ return await response.arrayBuffer();
63468
+ }
63469
+ const buffer = import_fs.default.readFileSync(filename);
63470
+ return buffer.buffer;
63471
+ }
63472
+ async function readFileAsText(filename) {
63473
+ if (filename.startsWith("http")) {
63474
+ const response = await fetch(filename);
63475
+ return await response.text();
63476
+ }
63477
+ const text = import_fs.default.readFileSync(filename, "utf8");
63478
+ return text;
63479
+ }
63487
63480
  async function requireFromFile(filename) {
63488
63481
  if (filename.startsWith("http")) {
63489
63482
  const response = await fetch(filename);
@@ -63516,40 +63509,38 @@ function requireFromString(code, filename = "", options) {
63516
63509
  }
63517
63510
 
63518
63511
  // ../worker-utils/src/lib/library-utils/library-utils.ts
63519
- var LATEST = "beta";
63520
- var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
63521
63512
  var loadLibraryPromises = {};
63522
- async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
63513
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
63523
63514
  if (moduleName) {
63524
- libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
63515
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
63525
63516
  }
63526
63517
  loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
63527
63518
  return await loadLibraryPromises[libraryUrl];
63528
63519
  }
63529
- function getLibraryUrl(library, moduleName, options) {
63530
- if (library.startsWith("http")) {
63520
+ function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
63521
+ if (!options.useLocalLibraries && library.startsWith("http")) {
63531
63522
  return library;
63532
63523
  }
63524
+ libraryName = libraryName || library;
63533
63525
  const modules = options.modules || {};
63534
- if (modules[library]) {
63535
- return modules[library];
63526
+ if (modules[libraryName]) {
63527
+ return modules[libraryName];
63536
63528
  }
63537
63529
  if (!isBrowser2) {
63538
- return `modules/${moduleName}/dist/libs/${library}`;
63530
+ return `modules/${moduleName}/dist/libs/${libraryName}`;
63539
63531
  }
63540
63532
  if (options.CDN) {
63541
63533
  assert2(options.CDN.startsWith("http"));
63542
- return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${library}`;
63534
+ return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
63543
63535
  }
63544
63536
  if (isWorker) {
63545
- return `../src/libs/${library}`;
63537
+ return `../src/libs/${libraryName}`;
63546
63538
  }
63547
- return `modules/${moduleName}/src/libs/${library}`;
63539
+ return `modules/${moduleName}/src/libs/${libraryName}`;
63548
63540
  }
63549
63541
  async function loadLibraryFromFile(libraryUrl) {
63550
63542
  if (libraryUrl.endsWith("wasm")) {
63551
- const response2 = await fetch(libraryUrl);
63552
- return await response2.arrayBuffer();
63543
+ return await loadAsArrayBuffer(libraryUrl);
63553
63544
  }
63554
63545
  if (!isBrowser2) {
63555
63546
  try {
@@ -63561,8 +63552,7 @@ async function loadLibraryFromFile(libraryUrl) {
63561
63552
  if (isWorker) {
63562
63553
  return importScripts(libraryUrl);
63563
63554
  }
63564
- const response = await fetch(libraryUrl);
63565
- const scriptSource = await response.text();
63555
+ const scriptSource = await loadAsText(libraryUrl);
63566
63556
  return loadLibraryFromString(scriptSource, libraryUrl);
63567
63557
  }
63568
63558
  function loadLibraryFromString(scriptSource, id) {
@@ -63583,6 +63573,20 @@ function loadLibraryFromString(scriptSource, id) {
63583
63573
  document.body.appendChild(script);
63584
63574
  return null;
63585
63575
  }
63576
+ async function loadAsArrayBuffer(url) {
63577
+ if (!readFileAsArrayBuffer || url.startsWith("http")) {
63578
+ const response = await fetch(url);
63579
+ return await response.arrayBuffer();
63580
+ }
63581
+ return await readFileAsArrayBuffer(url);
63582
+ }
63583
+ async function loadAsText(url) {
63584
+ if (!readFileAsText || url.startsWith("http")) {
63585
+ const response = await fetch(url);
63586
+ return await response.text();
63587
+ }
63588
+ return await readFileAsText(url);
63589
+ }
63586
63590
 
63587
63591
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
63588
63592
  var requestId = 0;
@@ -63600,7 +63604,7 @@ function createLoaderWorker(loader) {
63600
63604
  arrayBuffer: input,
63601
63605
  options,
63602
63606
  context: __spreadProps(__spreadValues({}, context), {
63603
- parse: parseOnMainThread
63607
+ _parse: parseOnMainThread
63604
63608
  })
63605
63609
  });
63606
63610
  WorkerBody.postMessage("done", { result });
@@ -63613,7 +63617,7 @@ function createLoaderWorker(loader) {
63613
63617
  }
63614
63618
  };
63615
63619
  }
63616
- function parseOnMainThread(arrayBuffer, options) {
63620
+ function parseOnMainThread(arrayBuffer, loader, options, context) {
63617
63621
  return new Promise((resolve, reject) => {
63618
63622
  const id = requestId++;
63619
63623
  const onMessage = (type, payload2) => {
@@ -63637,7 +63641,12 @@ function parseOnMainThread(arrayBuffer, options) {
63637
63641
  WorkerBody.postMessage("process", payload);
63638
63642
  });
63639
63643
  }
63640
- async function parseData({ loader, arrayBuffer, options, context }) {
63644
+ async function parseData({
63645
+ loader,
63646
+ arrayBuffer,
63647
+ options,
63648
+ context
63649
+ }) {
63641
63650
  let data;
63642
63651
  let parser;
63643
63652
  if (loader.parseSync || loader.parse) {
@@ -63658,32 +63667,35 @@ async function parseData({ loader, arrayBuffer, options, context }) {
63658
63667
  }
63659
63668
 
63660
63669
  // src/lib/utils/version.ts
63661
- var VERSION3 = true ? "4.0.0-alpha.8" : "beta";
63670
+ var VERSION2 = true ? "4.0.0-beta.1" : "beta";
63662
63671
 
63663
63672
  // src/lib/parsers/basis-module-loader.ts
63664
- var VERSION4 = true ? "4.0.0-alpha.8" : "beta";
63665
- var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.wasm`;
63666
- var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.js`;
63673
+ var BASIS_EXTERNAL_LIBRARIES = {
63674
+ TRANSCODER: "basis_transcoder.js",
63675
+ TRANSCODER_WASM: "basis_transcoder.wasm",
63676
+ ENCODER: "basis_encoder.js",
63677
+ ENCODER_WASM: "basis_encoder.wasm"
63678
+ };
63667
63679
  var loadBasisTranscoderPromise;
63668
- async function loadBasisTrascoderModule(options) {
63680
+ async function loadBasisTranscoderModule(options) {
63669
63681
  const modules = options.modules || {};
63670
63682
  if (modules.basis) {
63671
63683
  return modules.basis;
63672
63684
  }
63673
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
63685
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
63674
63686
  return await loadBasisTranscoderPromise;
63675
63687
  }
63676
- async function loadBasisTrascoder(options) {
63688
+ async function loadBasisTranscoder(options) {
63677
63689
  let BASIS = null;
63678
63690
  let wasmBinary = null;
63679
63691
  [BASIS, wasmBinary] = await Promise.all([
63680
- await loadLibrary("basis_transcoder.js", "textures", options),
63681
- await loadLibrary("basis_transcoder.wasm", "textures", options)
63692
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
63693
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
63682
63694
  ]);
63683
63695
  BASIS = BASIS || globalThis.BASIS;
63684
- return await initializeBasisTrascoderModule(BASIS, wasmBinary);
63696
+ return await initializeBasisTranscoderModule(BASIS, wasmBinary);
63685
63697
  }
63686
- function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
63698
+ function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
63687
63699
  const options = {};
63688
63700
  if (wasmBinary) {
63689
63701
  options.wasmBinary = wasmBinary;
@@ -63709,8 +63721,8 @@ async function loadBasisEncoder(options) {
63709
63721
  let BASIS_ENCODER = null;
63710
63722
  let wasmBinary = null;
63711
63723
  [BASIS_ENCODER, wasmBinary] = await Promise.all([
63712
- await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
63713
- await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
63724
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
63725
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
63714
63726
  ]);
63715
63727
  BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
63716
63728
  return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
@@ -63900,7 +63912,7 @@ async function parseBasis(data, options) {
63900
63912
  const fileConstructors = await loadBasisEncoderModule(options);
63901
63913
  return parseKTX2File(fileConstructors.KTX2File, data, options);
63902
63914
  }
63903
- const { BasisFile } = await loadBasisTrascoderModule(options);
63915
+ const { BasisFile } = await loadBasisTranscoderModule(options);
63904
63916
  return parseBasisFile(BasisFile, data, options);
63905
63917
  }
63906
63918
  switch (options.basis.module) {
@@ -63915,7 +63927,7 @@ async function parseBasis(data, options) {
63915
63927
  }
63916
63928
  case "transcoder":
63917
63929
  default:
63918
- const { BasisFile } = await loadBasisTrascoderModule(options);
63930
+ const { BasisFile } = await loadBasisTranscoderModule(options);
63919
63931
  return parseBasisFile(BasisFile, data, options);
63920
63932
  }
63921
63933
  }
@@ -64034,7 +64046,7 @@ var BasisWorkerLoader = {
64034
64046
  name: "Basis",
64035
64047
  id: "basis",
64036
64048
  module: "textures",
64037
- version: VERSION3,
64049
+ version: VERSION2,
64038
64050
  worker: true,
64039
64051
  extensions: ["basis", "ktx2"],
64040
64052
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -28,10 +28,19 @@
28
28
  });
29
29
 
30
30
  // ../worker-utils/src/lib/env-utils/version.ts
31
- var VERSION = true ? "4.0.0-alpha.8" : DEFAULT_VERSION;
32
- if (false) {
33
- console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
31
+ function getVersion() {
32
+ if (!globalThis._loadersgl_?.version) {
33
+ globalThis._loadersgl_ = globalThis._loadersgl_ || {};
34
+ if (false) {
35
+ console.error("loaders.gl: The __VERSION__ variable is not injected using babel plugin. Latest unstable workers would be fetched from the CDN.");
36
+ globalThis._loadersgl_.version = NPM_TAG;
37
+ } else {
38
+ globalThis._loadersgl_.version = "4.0.0-beta.1";
39
+ }
40
+ }
41
+ return globalThis._loadersgl_.version;
34
42
  }
43
+ var VERSION = getVersion();
35
44
 
36
45
  // ../worker-utils/src/lib/env-utils/assert.ts
37
46
  function assert(condition, message) {
@@ -168,40 +177,38 @@
168
177
 
169
178
  // ../worker-utils/src/lib/library-utils/library-utils.ts
170
179
  var node = __toModule(require_require_utils());
171
- var LATEST = "beta";
172
- var VERSION2 = typeof VERSION !== "undefined" ? VERSION : LATEST;
173
180
  var loadLibraryPromises = {};
174
- async function loadLibrary(libraryUrl, moduleName = null, options = {}) {
181
+ async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
175
182
  if (moduleName) {
176
- libraryUrl = getLibraryUrl(libraryUrl, moduleName, options);
183
+ libraryUrl = getLibraryUrl(libraryUrl, moduleName, options, libraryName);
177
184
  }
178
185
  loadLibraryPromises[libraryUrl] = loadLibraryPromises[libraryUrl] || loadLibraryFromFile(libraryUrl);
179
186
  return await loadLibraryPromises[libraryUrl];
180
187
  }
181
- function getLibraryUrl(library, moduleName, options) {
182
- if (library.startsWith("http")) {
188
+ function getLibraryUrl(library, moduleName, options = {}, libraryName = null) {
189
+ if (!options.useLocalLibraries && library.startsWith("http")) {
183
190
  return library;
184
191
  }
192
+ libraryName = libraryName || library;
185
193
  const modules = options.modules || {};
186
- if (modules[library]) {
187
- return modules[library];
194
+ if (modules[libraryName]) {
195
+ return modules[libraryName];
188
196
  }
189
197
  if (!isBrowser) {
190
- return `modules/${moduleName}/dist/libs/${library}`;
198
+ return `modules/${moduleName}/dist/libs/${libraryName}`;
191
199
  }
192
200
  if (options.CDN) {
193
201
  assert(options.CDN.startsWith("http"));
194
- return `${options.CDN}/${moduleName}@${VERSION2}/dist/libs/${library}`;
202
+ return `${options.CDN}/${moduleName}@${VERSION}/dist/libs/${libraryName}`;
195
203
  }
196
204
  if (isWorker) {
197
- return `../src/libs/${library}`;
205
+ return `../src/libs/${libraryName}`;
198
206
  }
199
- return `modules/${moduleName}/src/libs/${library}`;
207
+ return `modules/${moduleName}/src/libs/${libraryName}`;
200
208
  }
201
209
  async function loadLibraryFromFile(libraryUrl) {
202
210
  if (libraryUrl.endsWith("wasm")) {
203
- const response2 = await fetch(libraryUrl);
204
- return await response2.arrayBuffer();
211
+ return await loadAsArrayBuffer(libraryUrl);
205
212
  }
206
213
  if (!isBrowser) {
207
214
  try {
@@ -213,8 +220,7 @@
213
220
  if (isWorker) {
214
221
  return importScripts(libraryUrl);
215
222
  }
216
- const response = await fetch(libraryUrl);
217
- const scriptSource = await response.text();
223
+ const scriptSource = await loadAsText(libraryUrl);
218
224
  return loadLibraryFromString(scriptSource, libraryUrl);
219
225
  }
220
226
  function loadLibraryFromString(scriptSource, id) {
@@ -235,6 +241,20 @@
235
241
  document.body.appendChild(script);
236
242
  return null;
237
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
+ }
238
258
 
239
259
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
240
260
  var requestId = 0;
@@ -253,7 +273,7 @@
253
273
  options,
254
274
  context: {
255
275
  ...context,
256
- parse: parseOnMainThread
276
+ _parse: parseOnMainThread
257
277
  }
258
278
  });
259
279
  WorkerBody.postMessage("done", { result });
@@ -266,7 +286,7 @@
266
286
  }
267
287
  };
268
288
  }
269
- function parseOnMainThread(arrayBuffer, options) {
289
+ function parseOnMainThread(arrayBuffer, loader, options, context) {
270
290
  return new Promise((resolve, reject) => {
271
291
  const id = requestId++;
272
292
  const onMessage = (type, payload2) => {
@@ -290,7 +310,12 @@
290
310
  WorkerBody.postMessage("process", payload);
291
311
  });
292
312
  }
293
- async function parseData({ loader, arrayBuffer, options, context }) {
313
+ async function parseData({
314
+ loader,
315
+ arrayBuffer,
316
+ options,
317
+ context
318
+ }) {
294
319
  let data;
295
320
  let parser;
296
321
  if (loader.parseSync || loader.parse) {
@@ -312,32 +337,35 @@
312
337
  }
313
338
 
314
339
  // src/lib/utils/version.ts
315
- var VERSION3 = true ? "4.0.0-alpha.8" : "beta";
340
+ var VERSION2 = true ? "4.0.0-beta.1" : "beta";
316
341
 
317
342
  // src/lib/parsers/basis-module-loader.ts
318
- var VERSION4 = true ? "4.0.0-alpha.8" : "beta";
319
- var BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.wasm`;
320
- var BASIS_CDN_ENCODER_JS = `https://unpkg.com/@loaders.gl/textures@${VERSION4}/dist/libs/basis_encoder.js`;
343
+ var BASIS_EXTERNAL_LIBRARIES = {
344
+ TRANSCODER: "basis_transcoder.js",
345
+ TRANSCODER_WASM: "basis_transcoder.wasm",
346
+ ENCODER: "basis_encoder.js",
347
+ ENCODER_WASM: "basis_encoder.wasm"
348
+ };
321
349
  var loadBasisTranscoderPromise;
322
- async function loadBasisTrascoderModule(options) {
350
+ async function loadBasisTranscoderModule(options) {
323
351
  const modules = options.modules || {};
324
352
  if (modules.basis) {
325
353
  return modules.basis;
326
354
  }
327
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTrascoder(options);
355
+ loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
328
356
  return await loadBasisTranscoderPromise;
329
357
  }
330
- async function loadBasisTrascoder(options) {
358
+ async function loadBasisTranscoder(options) {
331
359
  let BASIS = null;
332
360
  let wasmBinary = null;
333
361
  [BASIS, wasmBinary] = await Promise.all([
334
- await loadLibrary("basis_transcoder.js", "textures", options),
335
- await loadLibrary("basis_transcoder.wasm", "textures", options)
362
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER, "textures", options),
363
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.TRANSCODER_WASM, "textures", options)
336
364
  ]);
337
365
  BASIS = BASIS || globalThis.BASIS;
338
- return await initializeBasisTrascoderModule(BASIS, wasmBinary);
366
+ return await initializeBasisTranscoderModule(BASIS, wasmBinary);
339
367
  }
340
- function initializeBasisTrascoderModule(BasisModule, wasmBinary) {
368
+ function initializeBasisTranscoderModule(BasisModule, wasmBinary) {
341
369
  const options = {};
342
370
  if (wasmBinary) {
343
371
  options.wasmBinary = wasmBinary;
@@ -363,8 +391,8 @@
363
391
  let BASIS_ENCODER = null;
364
392
  let wasmBinary = null;
365
393
  [BASIS_ENCODER, wasmBinary] = await Promise.all([
366
- await loadLibrary(BASIS_CDN_ENCODER_JS, "textures", options),
367
- await loadLibrary(BASIS_CDN_ENCODER_WASM, "textures", options)
394
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER, "textures", options),
395
+ await loadLibrary(BASIS_EXTERNAL_LIBRARIES.ENCODER_WASM, "textures", options)
368
396
  ]);
369
397
  BASIS_ENCODER = BASIS_ENCODER || globalThis.BASIS;
370
398
  return await initializeBasisEncoderModule(BASIS_ENCODER, wasmBinary);
@@ -581,7 +609,7 @@
581
609
  const fileConstructors = await loadBasisEncoderModule(options);
582
610
  return parseKTX2File(fileConstructors.KTX2File, data, options);
583
611
  }
584
- const { BasisFile } = await loadBasisTrascoderModule(options);
612
+ const { BasisFile } = await loadBasisTranscoderModule(options);
585
613
  return parseBasisFile(BasisFile, data, options);
586
614
  }
587
615
  switch (options.basis.module) {
@@ -596,7 +624,7 @@
596
624
  }
597
625
  case "transcoder":
598
626
  default:
599
- const { BasisFile } = await loadBasisTrascoderModule(options);
627
+ const { BasisFile } = await loadBasisTranscoderModule(options);
600
628
  return parseBasisFile(BasisFile, data, options);
601
629
  }
602
630
  }
@@ -715,7 +743,7 @@
715
743
  name: "Basis",
716
744
  id: "basis",
717
745
  module: "textures",
718
- version: VERSION3,
746
+ version: VERSION2,
719
747
  worker: true,
720
748
  extensions: ["basis", "ktx2"],
721
749
  mimeTypes: ["application/octet-stream", "image/ktx2"],
@@ -8,42 +8,9 @@ export type TextureLoaderOptions = {
8
8
  /**
9
9
  * Worker Loader for KTX, DDS, and PVR texture container formats
10
10
  */
11
- export declare const CompressedTextureWorkerLoader: {
12
- name: string;
13
- id: string;
14
- module: string;
15
- version: any;
16
- worker: boolean;
17
- extensions: string[];
18
- mimeTypes: string[];
19
- binary: boolean;
20
- options: {
21
- 'compressed-texture': {
22
- libraryPath: string;
23
- useBasis: boolean;
24
- };
25
- };
26
- };
11
+ export declare const CompressedTextureWorkerLoader: Loader<any, never, TextureLoaderOptions>;
27
12
  /**
28
13
  * Loader for KTX, DDS, and PVR texture container formats
29
14
  */
30
- export declare const CompressedTextureLoader: {
31
- parse: (arrayBuffer: any, options: any) => Promise<import("@loaders.gl/schema").TextureLevel[]>;
32
- name: string;
33
- id: string;
34
- module: string;
35
- version: any;
36
- worker: boolean;
37
- extensions: string[];
38
- mimeTypes: string[];
39
- binary: boolean;
40
- options: {
41
- 'compressed-texture': {
42
- libraryPath: string;
43
- useBasis: boolean;
44
- };
45
- };
46
- };
47
- export declare const _TypecheckCompressedTextureWorkerLoader: Loader;
48
- export declare const _TypecheckCompressedTextureLoader: LoaderWithParser;
15
+ export declare const CompressedTextureLoader: LoaderWithParser<any, never, TextureLoaderOptions>;
49
16
  //# sourceMappingURL=compressed-texture-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compressed-texture-loader.d.ts","sourceRoot":"","sources":["../src/compressed-texture-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAKvE,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB,CAAC,EAAE;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH,CAAC;AASF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;CAqBzC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;;CAiBnC,CAAC;AAGF,eAAO,MAAM,uCAAuC,EAAE,MAAsC,CAAC;AAC7F,eAAO,MAAM,iCAAiC,EAAE,gBAA0C,CAAC"}
1
+ {"version":3,"file":"compressed-texture-loader.d.ts","sourceRoot":"","sources":["../src/compressed-texture-loader.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,MAAM,EAAE,gBAAgB,EAAC,MAAM,0BAA0B,CAAC;AAKvE,MAAM,MAAM,oBAAoB,GAAG;IACjC,oBAAoB,CAAC,EAAE;QACrB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,QAAQ,CAAC,EAAE,OAAO,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B,EAAE,MAAM,CAAC,GAAG,EAAE,KAAK,EAAE,oBAAoB,CA0BlF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,uBAAuB,EAAE,gBAAgB,CAAC,GAAG,EAAE,KAAK,EAAE,oBAAoB,CAoBtF,CAAC"}