@loaders.gl/textures 4.2.0-alpha.6 → 4.2.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 (49) hide show
  1. package/dist/basis-loader.d.ts +61 -3
  2. package/dist/basis-loader.d.ts.map +1 -1
  3. package/dist/basis-loader.js +5 -3
  4. package/dist/basis-worker-node.js +167 -210
  5. package/dist/basis-worker.js +29 -48
  6. package/dist/compressed-texture-loader.d.ts +43 -4
  7. package/dist/compressed-texture-loader.d.ts.map +1 -1
  8. package/dist/compressed-texture-loader.js +2 -0
  9. package/dist/compressed-texture-worker.js +30 -46
  10. package/dist/compressed-texture-writer.d.ts +24 -2
  11. package/dist/compressed-texture-writer.d.ts.map +1 -1
  12. package/dist/compressed-texture-writer.js +0 -8
  13. package/dist/crunch-loader.d.ts +23 -2
  14. package/dist/crunch-loader.d.ts.map +1 -1
  15. package/dist/crunch-loader.js +2 -0
  16. package/dist/crunch-worker.js +30 -46
  17. package/dist/dist.dev.js +96 -81
  18. package/dist/dist.min.js +2 -2
  19. package/dist/index.cjs +23 -15
  20. package/dist/index.cjs.map +3 -3
  21. package/dist/index.d.ts +5 -1
  22. package/dist/index.d.ts.map +1 -1
  23. package/dist/index.js +1 -1
  24. package/dist/ktx2-basis-writer-worker-node.js +148 -203
  25. package/dist/ktx2-basis-writer-worker.js +12 -42
  26. package/dist/ktx2-basis-writer.d.ts +18 -3
  27. package/dist/ktx2-basis-writer.d.ts.map +1 -1
  28. package/dist/lib/parsers/basis-module-loader.d.ts.map +1 -1
  29. package/dist/lib/parsers/basis-module-loader.js +6 -4
  30. package/dist/lib/parsers/crunch-module-loader.d.ts +2 -1
  31. package/dist/lib/parsers/crunch-module-loader.d.ts.map +1 -1
  32. package/dist/lib/parsers/crunch-module-loader.js +6 -4
  33. package/dist/lib/utils/version.js +1 -1
  34. package/dist/npy-loader.d.ts +40 -5
  35. package/dist/npy-loader.d.ts.map +1 -1
  36. package/dist/npy-loader.js +2 -0
  37. package/dist/npy-worker.js +3 -1
  38. package/dist/workers/crunch-worker.d.ts +15 -17
  39. package/dist/workers/crunch-worker.d.ts.map +1 -1
  40. package/package.json +6 -6
  41. package/src/basis-loader.ts +27 -7
  42. package/src/compressed-texture-loader.ts +14 -6
  43. package/src/compressed-texture-writer.ts +5 -15
  44. package/src/crunch-loader.ts +10 -2
  45. package/src/index.ts +10 -1
  46. package/src/ktx2-basis-writer.ts +2 -2
  47. package/src/lib/parsers/basis-module-loader.ts +6 -4
  48. package/src/lib/parsers/crunch-module-loader.ts +8 -6
  49. package/src/npy-loader.ts +13 -5
@@ -1,37 +1,15 @@
1
1
  "use strict";
2
2
  (() => {
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
-
29
- // (disabled):../worker-utils/src/lib/node/require-utils.node
30
- var require_require_utils = __commonJS({
31
- "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
32
- "use strict";
33
- }
34
- });
3
+ // ../loader-utils/src/lib/module-utils/js-module-utils.ts
4
+ function registerJSModules(modules) {
5
+ globalThis.loaders ||= {};
6
+ globalThis.loaders.modules ||= {};
7
+ Object.assign(globalThis.loaders.modules, modules);
8
+ }
9
+ function getJSModuleOrNull(name) {
10
+ const module = globalThis.loaders?.modules?.[name];
11
+ return module || null;
12
+ }
35
13
 
36
14
  // ../worker-utils/src/lib/env-utils/version.ts
37
15
  function getVersion() {
@@ -43,7 +21,7 @@
43
21
  );
44
22
  globalThis._loadersgl_.version = NPM_TAG;
45
23
  } else {
46
- globalThis._loadersgl_.version = "4.2.0-alpha.5";
24
+ globalThis._loadersgl_.version = "4.2.0-alpha.6";
47
25
  }
48
26
  }
49
27
  return globalThis._loadersgl_.version;
@@ -196,7 +174,6 @@
196
174
  }
197
175
 
198
176
  // ../worker-utils/src/lib/library-utils/library-utils.ts
199
- var node = __toESM(require_require_utils(), 1);
200
177
  var loadLibraryPromises = {};
201
178
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
202
179
  if (moduleName) {
@@ -233,7 +210,8 @@
233
210
  }
234
211
  if (!isBrowser) {
235
212
  try {
236
- return node && void 0 && await (void 0)(libraryUrl);
213
+ const { requireFromFile } = globalThis.loaders || {};
214
+ return await requireFromFile?.(libraryUrl);
237
215
  } catch (error) {
238
216
  console.error(error);
239
217
  return null;
@@ -247,7 +225,8 @@
247
225
  }
248
226
  function loadLibraryFromString(scriptSource, id) {
249
227
  if (!isBrowser) {
250
- return void 0 && (void 0)(scriptSource, id);
228
+ const { requireFromString } = globalThis.loaders || {};
229
+ return requireFromString?.(scriptSource, id);
251
230
  }
252
231
  if (isWorker) {
253
232
  eval.call(globalThis, scriptSource);
@@ -264,18 +243,20 @@
264
243
  return null;
265
244
  }
266
245
  async function loadAsArrayBuffer(url) {
267
- if (isBrowser || !void 0 || url.startsWith("http")) {
246
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
247
+ if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
268
248
  const response = await fetch(url);
269
249
  return await response.arrayBuffer();
270
250
  }
271
- return await (void 0)(url);
251
+ return await readFileAsArrayBuffer(url);
272
252
  }
273
253
  async function loadAsText(url) {
274
- if (isBrowser || !void 0 || url.startsWith("http")) {
254
+ const { readFileAsText } = globalThis.loaders || {};
255
+ if (isBrowser || !readFileAsText || url.startsWith("http")) {
275
256
  const response = await fetch(url);
276
257
  return await response.text();
277
258
  }
278
- return await (void 0)(url);
259
+ return await readFileAsText(url);
279
260
  }
280
261
 
281
262
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
@@ -360,7 +341,7 @@
360
341
  }
361
342
 
362
343
  // src/lib/utils/version.ts
363
- var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
344
+ var VERSION2 = true ? "4.2.0-alpha.6" : "latest";
364
345
 
365
346
  // src/lib/parsers/basis-module-loader.ts
366
347
  var BASIS_EXTERNAL_LIBRARIES = {
@@ -375,11 +356,12 @@
375
356
  };
376
357
  var loadBasisTranscoderPromise;
377
358
  async function loadBasisTranscoderModule(options) {
378
- const modules = options.modules || {};
379
- if (modules.basis) {
380
- return modules.basis;
359
+ registerJSModules(options.modules);
360
+ const basis = getJSModuleOrNull("basis");
361
+ if (basis) {
362
+ return basis;
381
363
  }
382
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
364
+ loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
383
365
  return await loadBasisTranscoderPromise;
384
366
  }
385
367
  async function loadBasisTranscoder(options) {
@@ -811,6 +793,8 @@
811
793
 
812
794
  // src/basis-loader.ts
813
795
  var BasisWorkerLoader = {
796
+ dataType: null,
797
+ batchType: null,
814
798
  name: "Basis",
815
799
  id: "basis",
816
800
  module: "textures",
@@ -823,12 +807,9 @@
823
807
  options: {
824
808
  basis: {
825
809
  format: "auto",
826
- // gl context doesn't exist on a worker thread
827
810
  libraryPath: "libs/",
828
811
  containerFormat: "auto",
829
- // 'basis' || 'ktx2' || 'auto'
830
812
  module: "transcoder"
831
- // 'transcoder' || 'encoder'
832
813
  }
833
814
  }
834
815
  };
@@ -1,16 +1,55 @@
1
- import type { Loader, LoaderWithParser } from '@loaders.gl/loader-utils';
2
- export type TextureLoaderOptions = {
1
+ /** Options for the CompressedTextureLoader */
2
+ export type CompressedTextureLoaderOptions = {
3
3
  'compressed-texture'?: {
4
+ /** @deprecated Specify path to libraries */
4
5
  libraryPath?: string;
6
+ /** Whether to use Basis decoding */
5
7
  useBasis?: boolean;
8
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
9
+ workerUrl?: string;
6
10
  };
7
11
  };
8
12
  /**
9
13
  * Worker Loader for KTX, DDS, and PVR texture container formats
10
14
  */
11
- export declare const CompressedTextureWorkerLoader: Loader<any, never, TextureLoaderOptions>;
15
+ export declare const CompressedTextureWorkerLoader: {
16
+ readonly dataType: any;
17
+ readonly batchType: never;
18
+ readonly name: "Texture Containers";
19
+ readonly id: "compressed-texture";
20
+ readonly module: "textures";
21
+ readonly version: any;
22
+ readonly worker: true;
23
+ readonly extensions: ["ktx", "ktx2", "dds", "pvr"];
24
+ readonly mimeTypes: ["image/ktx2", "image/ktx", "image/vnd-ms.dds", "image/x-dds", "application/octet-stream"];
25
+ readonly binary: true;
26
+ readonly options: {
27
+ readonly 'compressed-texture': {
28
+ readonly libraryPath: "libs/";
29
+ readonly useBasis: false;
30
+ };
31
+ };
32
+ };
12
33
  /**
13
34
  * Loader for KTX, DDS, and PVR texture container formats
14
35
  */
15
- export declare const CompressedTextureLoader: LoaderWithParser<any, never, TextureLoaderOptions>;
36
+ export declare const CompressedTextureLoader: {
37
+ readonly parse: (arrayBuffer: ArrayBuffer, options?: CompressedTextureLoaderOptions) => Promise<import("@loaders.gl/schema").TextureLevel[]>;
38
+ readonly dataType: any;
39
+ readonly batchType: never;
40
+ readonly name: "Texture Containers";
41
+ readonly id: "compressed-texture";
42
+ readonly module: "textures";
43
+ readonly version: any;
44
+ readonly worker: true;
45
+ readonly extensions: ["ktx", "ktx2", "dds", "pvr"];
46
+ readonly mimeTypes: ["image/ktx2", "image/ktx", "image/vnd-ms.dds", "image/x-dds", "application/octet-stream"];
47
+ readonly binary: true;
48
+ readonly options: {
49
+ readonly 'compressed-texture': {
50
+ readonly libraryPath: "libs/";
51
+ readonly useBasis: false;
52
+ };
53
+ };
54
+ };
16
55
  //# 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":"AAIA,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"}
1
+ {"version":3,"file":"compressed-texture-loader.d.ts","sourceRoot":"","sources":["../src/compressed-texture-loader.ts"],"names":[],"mappings":"AASA,8CAA8C;AAC9C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,oBAAoB,CAAC,EAAE;QACrB,4CAA4C;QAC5C,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,oCAAoC;QACpC,QAAQ,CAAC,EAAE,OAAO,CAAC;QACnB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,6BAA6B;;;;;;;;;;;;;;;;;CA6B6B,CAAC;AAExE;;GAEG;AACH,eAAO,MAAM,uBAAuB;kCAEP,WAAW,YAAY,8BAA8B;;;;;;;;;;;;;;;;;CAkBD,CAAC"}
@@ -8,6 +8,8 @@ import parseBasis from "./lib/parsers/parse-basis.js";
8
8
  * Worker Loader for KTX, DDS, and PVR texture container formats
9
9
  */
10
10
  export const CompressedTextureWorkerLoader = {
11
+ dataType: null,
12
+ batchType: null,
11
13
  name: 'Texture Containers',
12
14
  id: 'compressed-texture',
13
15
  module: 'textures',
@@ -1,38 +1,5 @@
1
1
  "use strict";
2
2
  (() => {
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
-
29
- // (disabled):../worker-utils/src/lib/node/require-utils.node
30
- var require_require_utils = __commonJS({
31
- "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
32
- "use strict";
33
- }
34
- });
35
-
36
3
  // ../loader-utils/src/lib/env-utils/assert.ts
37
4
  function assert(condition, message) {
38
5
  if (!condition) {
@@ -40,6 +7,17 @@
40
7
  }
41
8
  }
42
9
 
10
+ // ../loader-utils/src/lib/module-utils/js-module-utils.ts
11
+ function registerJSModules(modules) {
12
+ globalThis.loaders ||= {};
13
+ globalThis.loaders.modules ||= {};
14
+ Object.assign(globalThis.loaders.modules, modules);
15
+ }
16
+ function getJSModuleOrNull(name) {
17
+ const module = globalThis.loaders?.modules?.[name];
18
+ return module || null;
19
+ }
20
+
43
21
  // ../worker-utils/src/lib/env-utils/version.ts
44
22
  function getVersion() {
45
23
  if (!globalThis._loadersgl_?.version) {
@@ -50,7 +28,7 @@
50
28
  );
51
29
  globalThis._loadersgl_.version = NPM_TAG;
52
30
  } else {
53
- globalThis._loadersgl_.version = "4.2.0-alpha.5";
31
+ globalThis._loadersgl_.version = "4.2.0-alpha.6";
54
32
  }
55
33
  }
56
34
  return globalThis._loadersgl_.version;
@@ -203,7 +181,6 @@
203
181
  }
204
182
 
205
183
  // ../worker-utils/src/lib/library-utils/library-utils.ts
206
- var node = __toESM(require_require_utils(), 1);
207
184
  var loadLibraryPromises = {};
208
185
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
209
186
  if (moduleName) {
@@ -240,7 +217,8 @@
240
217
  }
241
218
  if (!isBrowser) {
242
219
  try {
243
- return node && void 0 && await (void 0)(libraryUrl);
220
+ const { requireFromFile } = globalThis.loaders || {};
221
+ return await requireFromFile?.(libraryUrl);
244
222
  } catch (error) {
245
223
  console.error(error);
246
224
  return null;
@@ -254,7 +232,8 @@
254
232
  }
255
233
  function loadLibraryFromString(scriptSource, id) {
256
234
  if (!isBrowser) {
257
- return void 0 && (void 0)(scriptSource, id);
235
+ const { requireFromString } = globalThis.loaders || {};
236
+ return requireFromString?.(scriptSource, id);
258
237
  }
259
238
  if (isWorker) {
260
239
  eval.call(globalThis, scriptSource);
@@ -271,18 +250,20 @@
271
250
  return null;
272
251
  }
273
252
  async function loadAsArrayBuffer(url) {
274
- if (isBrowser || !void 0 || url.startsWith("http")) {
253
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
254
+ if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
275
255
  const response = await fetch(url);
276
256
  return await response.arrayBuffer();
277
257
  }
278
- return await (void 0)(url);
258
+ return await readFileAsArrayBuffer(url);
279
259
  }
280
260
  async function loadAsText(url) {
281
- if (isBrowser || !void 0 || url.startsWith("http")) {
261
+ const { readFileAsText } = globalThis.loaders || {};
262
+ if (isBrowser || !readFileAsText || url.startsWith("http")) {
282
263
  const response = await fetch(url);
283
264
  return await response.text();
284
265
  }
285
- return await (void 0)(url);
266
+ return await readFileAsText(url);
286
267
  }
287
268
 
288
269
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
@@ -367,7 +348,7 @@
367
348
  }
368
349
 
369
350
  // src/lib/utils/version.ts
370
- var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
351
+ var VERSION2 = true ? "4.2.0-alpha.6" : "latest";
371
352
 
372
353
  // ../../node_modules/ktx-parse/dist/ktx-parse.modern.js
373
354
  var t = new Uint8Array([0]);
@@ -1037,11 +1018,12 @@
1037
1018
  };
1038
1019
  var loadBasisTranscoderPromise;
1039
1020
  async function loadBasisTranscoderModule(options) {
1040
- const modules = options.modules || {};
1041
- if (modules.basis) {
1042
- return modules.basis;
1021
+ registerJSModules(options.modules);
1022
+ const basis = getJSModuleOrNull("basis");
1023
+ if (basis) {
1024
+ return basis;
1043
1025
  }
1044
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
1026
+ loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
1045
1027
  return await loadBasisTranscoderPromise;
1046
1028
  }
1047
1029
  async function loadBasisTranscoder(options) {
@@ -1342,6 +1324,8 @@
1342
1324
 
1343
1325
  // src/compressed-texture-loader.ts
1344
1326
  var CompressedTextureWorkerLoader = {
1327
+ dataType: null,
1328
+ batchType: null,
1345
1329
  name: "Texture Containers",
1346
1330
  id: "compressed-texture",
1347
1331
  module: "textures",
@@ -1,6 +1,10 @@
1
- import type { WriterWithEncoder, WriterOptions } from '@loaders.gl/loader-utils';
1
+ import type { WriterOptions } from '@loaders.gl/loader-utils';
2
+ import { encodeImageURLToCompressedTextureURL } from "./lib/encoders/encode-texture.js";
3
+ /** Compressed Texture writer options */
2
4
  export type CompressedTextureWriterOptions = WriterOptions & {
5
+ /** @deprecated current working directory */
3
6
  cwd?: string;
7
+ /** Compressed Texture writer options */
4
8
  texture?: {
5
9
  format: string;
6
10
  compression: string;
@@ -13,5 +17,23 @@ export type CompressedTextureWriterOptions = WriterOptions & {
13
17
  /**
14
18
  * DDS Texture Container Exporter
15
19
  */
16
- export declare const CompressedTextureWriter: WriterWithEncoder<unknown, unknown, CompressedTextureWriterOptions>;
20
+ export declare const CompressedTextureWriter: {
21
+ readonly name: "DDS Texture Container";
22
+ readonly id: "dds";
23
+ readonly module: "textures";
24
+ readonly version: any;
25
+ readonly extensions: ["dds"];
26
+ readonly options: {
27
+ readonly texture: {
28
+ readonly format: "auto";
29
+ readonly compression: "auto";
30
+ readonly quality: "auto";
31
+ readonly mipmap: false;
32
+ readonly flipY: false;
33
+ readonly toolFlags: "";
34
+ };
35
+ };
36
+ readonly encodeURLtoURL: typeof encodeImageURLToCompressedTextureURL;
37
+ readonly encode: () => never;
38
+ };
17
39
  //# sourceMappingURL=compressed-texture-writer.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,iBAAiB,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAI/E,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,iBAAiB,CACrD,OAAO,EACP,OAAO,EACP,8BAA8B,CAwB/B,CAAC"}
1
+ {"version":3,"file":"compressed-texture-writer.d.ts","sourceRoot":"","sources":["../src/compressed-texture-writer.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAoB,aAAa,EAAC,MAAM,0BAA0B,CAAC;AAE/E,OAAO,EAAC,oCAAoC,EAAC,yCAAsC;AAEnF,wCAAwC;AACxC,MAAM,MAAM,8BAA8B,GAAG,aAAa,GAAG;IAC3D,4CAA4C;IAC5C,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,wCAAwC;IACxC,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;;;;;;;;;;;;;;;;;;CAuBoD,CAAC"}
@@ -27,11 +27,3 @@ export const CompressedTextureWriter = {
27
27
  throw new Error('Not implemented');
28
28
  }
29
29
  };
30
- // TYPE TESTS - TODO find a better way than exporting junk
31
- // export const _TypecheckCompressedTextureWriter: typeof CompressedTextureWriter & {
32
- // encodeURLtoURL: (
33
- // inputUrl: string,
34
- // outputUrl: string,
35
- // options?: CompressedTextureWriterOptions
36
- // ) => Promise<string>;
37
- // } = CompressedTextureWriter;
@@ -1,13 +1,34 @@
1
- import type { Loader, LoaderOptions } from '@loaders.gl/loader-utils';
1
+ import type { LoaderOptions } from '@loaders.gl/loader-utils';
2
2
  import type { TextureLevel } from '@loaders.gl/schema';
3
+ /** CrunchLoader options */
3
4
  export type CrunchLoaderOptions = LoaderOptions & {
5
+ /** CrunchLoader options */
4
6
  crunch?: {
7
+ /** @deprecated Specify where to load the Crunch decoder library */
5
8
  libraryPath?: string;
9
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
10
+ workerUrl?: string;
6
11
  };
7
12
  };
8
13
  /**
9
14
  * Worker loader for the Crunch compressed texture container format
10
15
  * @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
11
16
  */
12
- export declare const CrunchLoader: Loader<TextureLevel[], never, CrunchLoaderOptions>;
17
+ export declare const CrunchLoader: {
18
+ readonly dataType: TextureLevel[];
19
+ readonly batchType: never;
20
+ readonly id: "crunch";
21
+ readonly name: "Crunch";
22
+ readonly module: "textures";
23
+ readonly version: any;
24
+ readonly worker: true;
25
+ readonly extensions: ["crn"];
26
+ readonly mimeTypes: ["image/crn", "image/x-crn", "application/octet-stream"];
27
+ readonly binary: true;
28
+ readonly options: {
29
+ readonly crunch: {
30
+ readonly libraryPath: "libs/";
31
+ };
32
+ };
33
+ };
13
34
  //# sourceMappingURL=crunch-loader.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"crunch-loader.d.ts","sourceRoot":"","sources":["../src/crunch-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,MAAM,EAAE,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGrD,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,MAAM,CAAC,EAAE;QACP,WAAW,CAAC,EAAE,MAAM,CAAC;KACtB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY,EAAE,MAAM,CAAC,YAAY,EAAE,EAAE,KAAK,EAAE,mBAAmB,CAc3E,CAAC"}
1
+ {"version":3,"file":"crunch-loader.d.ts","sourceRoot":"","sources":["../src/crunch-loader.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAS,aAAa,EAAC,MAAM,0BAA0B,CAAC;AACpE,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAGrD,2BAA2B;AAC3B,MAAM,MAAM,mBAAmB,GAAG,aAAa,GAAG;IAChD,2BAA2B;IAC3B,MAAM,CAAC,EAAE;QACP,mEAAmE;QACnE,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,8EAA8E;QAC9E,SAAS,CAAC,EAAE,MAAM,CAAC;KACpB,CAAC;CACH,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;CAiB8C,CAAC"}
@@ -7,6 +7,8 @@ import { VERSION } from "./lib/utils/version.js";
7
7
  * @note We avoid bundling crunch - it is a rare format and large lib, so we only offer worker loader
8
8
  */
9
9
  export const CrunchLoader = {
10
+ dataType: null,
11
+ batchType: null,
10
12
  id: 'crunch',
11
13
  name: 'Crunch',
12
14
  module: 'textures',
@@ -1,38 +1,5 @@
1
1
  "use strict";
2
2
  (() => {
3
- var __create = Object.create;
4
- var __defProp = Object.defineProperty;
5
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
- var __getOwnPropNames = Object.getOwnPropertyNames;
7
- var __getProtoOf = Object.getPrototypeOf;
8
- var __hasOwnProp = Object.prototype.hasOwnProperty;
9
- var __commonJS = (cb, mod) => function __require() {
10
- return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
-
29
- // (disabled):../worker-utils/src/lib/node/require-utils.node
30
- var require_require_utils = __commonJS({
31
- "(disabled):../worker-utils/src/lib/node/require-utils.node"() {
32
- "use strict";
33
- }
34
- });
35
-
36
3
  // ../loader-utils/src/lib/env-utils/assert.ts
37
4
  function assert(condition, message) {
38
5
  if (!condition) {
@@ -40,6 +7,17 @@
40
7
  }
41
8
  }
42
9
 
10
+ // ../loader-utils/src/lib/module-utils/js-module-utils.ts
11
+ function registerJSModules(modules) {
12
+ globalThis.loaders ||= {};
13
+ globalThis.loaders.modules ||= {};
14
+ Object.assign(globalThis.loaders.modules, modules);
15
+ }
16
+ function getJSModuleOrNull(name) {
17
+ const module = globalThis.loaders?.modules?.[name];
18
+ return module || null;
19
+ }
20
+
43
21
  // ../worker-utils/src/lib/env-utils/version.ts
44
22
  function getVersion() {
45
23
  if (!globalThis._loadersgl_?.version) {
@@ -50,7 +28,7 @@
50
28
  );
51
29
  globalThis._loadersgl_.version = NPM_TAG;
52
30
  } else {
53
- globalThis._loadersgl_.version = "4.2.0-alpha.5";
31
+ globalThis._loadersgl_.version = "4.2.0-alpha.6";
54
32
  }
55
33
  }
56
34
  return globalThis._loadersgl_.version;
@@ -203,7 +181,6 @@
203
181
  }
204
182
 
205
183
  // ../worker-utils/src/lib/library-utils/library-utils.ts
206
- var node = __toESM(require_require_utils(), 1);
207
184
  var loadLibraryPromises = {};
208
185
  async function loadLibrary(libraryUrl, moduleName = null, options = {}, libraryName = null) {
209
186
  if (moduleName) {
@@ -240,7 +217,8 @@
240
217
  }
241
218
  if (!isBrowser) {
242
219
  try {
243
- return node && void 0 && await (void 0)(libraryUrl);
220
+ const { requireFromFile } = globalThis.loaders || {};
221
+ return await requireFromFile?.(libraryUrl);
244
222
  } catch (error) {
245
223
  console.error(error);
246
224
  return null;
@@ -254,7 +232,8 @@
254
232
  }
255
233
  function loadLibraryFromString(scriptSource, id) {
256
234
  if (!isBrowser) {
257
- return void 0 && (void 0)(scriptSource, id);
235
+ const { requireFromString } = globalThis.loaders || {};
236
+ return requireFromString?.(scriptSource, id);
258
237
  }
259
238
  if (isWorker) {
260
239
  eval.call(globalThis, scriptSource);
@@ -271,18 +250,20 @@
271
250
  return null;
272
251
  }
273
252
  async function loadAsArrayBuffer(url) {
274
- if (isBrowser || !void 0 || url.startsWith("http")) {
253
+ const { readFileAsArrayBuffer } = globalThis.loaders || {};
254
+ if (isBrowser || !readFileAsArrayBuffer || url.startsWith("http")) {
275
255
  const response = await fetch(url);
276
256
  return await response.arrayBuffer();
277
257
  }
278
- return await (void 0)(url);
258
+ return await readFileAsArrayBuffer(url);
279
259
  }
280
260
  async function loadAsText(url) {
281
- if (isBrowser || !void 0 || url.startsWith("http")) {
261
+ const { readFileAsText } = globalThis.loaders || {};
262
+ if (isBrowser || !readFileAsText || url.startsWith("http")) {
282
263
  const response = await fetch(url);
283
264
  return await response.text();
284
265
  }
285
- return await (void 0)(url);
266
+ return await readFileAsText(url);
286
267
  }
287
268
 
288
269
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
@@ -367,10 +348,12 @@
367
348
  }
368
349
 
369
350
  // src/lib/utils/version.ts
370
- var VERSION2 = true ? "4.2.0-alpha.5" : "latest";
351
+ var VERSION2 = true ? "4.2.0-alpha.6" : "latest";
371
352
 
372
353
  // src/crunch-loader.ts
373
354
  var CrunchLoader = {
355
+ dataType: null,
356
+ batchType: null,
374
357
  id: "crunch",
375
358
  name: "Crunch",
376
359
  module: "textures",
@@ -392,9 +375,10 @@
392
375
  DECODER: "crunch.js"
393
376
  };
394
377
  async function loadCrunchModule(options) {
395
- const modules = options.modules || {};
396
- if (modules.crunch) {
397
- return modules.crunch;
378
+ registerJSModules(options.modules);
379
+ const crunch = getJSModuleOrNull("crunch");
380
+ if (crunch) {
381
+ return crunch;
398
382
  }
399
383
  return loadCrunch(options);
400
384
  }
@@ -404,7 +388,7 @@
404
388
  return crunchModule;
405
389
  }
406
390
  let loadCrunchDecoder = await loadLibrary(CRUNCH_EXTERNAL_LIBRARIES.DECODER, "textures", options);
407
- loadCrunchDecoder = loadCrunchDecoder || globalThis.LoadCrunchDecoder;
391
+ loadCrunchDecoder ||= globalThis.LoadCrunchDecoder;
408
392
  crunchModule = loadCrunchDecoder();
409
393
  return crunchModule;
410
394
  }