@loaders.gl/textures 4.2.0-alpha.5 → 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 +348 -335
  5. package/dist/basis-worker.js +32 -49
  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 +33 -47
  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 +33 -47
  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 +329 -328
  25. package/dist/ktx2-basis-writer-worker.js +15 -43
  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 +6 -2
  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 +7 -9
  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
@@ -2,6 +2,7 @@
2
2
  // SPDX-License-Identifier: MIT
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
+ import {registerJSModules, getJSModuleOrNull} from '@loaders.gl/loader-utils';
5
6
  import {loadLibrary} from '@loaders.gl/worker-utils';
6
7
 
7
8
  export const BASIS_EXTERNAL_LIBRARIES = {
@@ -23,12 +24,13 @@ let loadBasisTranscoderPromise;
23
24
  * @returns {BasisFile} promise
24
25
  */
25
26
  export async function loadBasisTranscoderModule(options) {
26
- const modules = options.modules || {};
27
- if (modules.basis) {
28
- return modules.basis;
27
+ registerJSModules(options.modules);
28
+ const basis = getJSModuleOrNull('basis');
29
+ if (basis) {
30
+ return basis;
29
31
  }
30
32
 
31
- loadBasisTranscoderPromise = loadBasisTranscoderPromise || loadBasisTranscoder(options);
33
+ loadBasisTranscoderPromise ||= loadBasisTranscoder(options);
32
34
  return await loadBasisTranscoderPromise;
33
35
  }
34
36
 
@@ -3,6 +3,7 @@
3
3
  // Copyright (c) vis.gl contributors
4
4
 
5
5
  // @ts-nocheck
6
+ import {getJSModuleOrNull, LoaderOptions, registerJSModules} from '@loaders.gl/loader-utils';
6
7
  import {loadLibrary} from '@loaders.gl/worker-utils';
7
8
 
8
9
  export const CRUNCH_EXTERNAL_LIBRARIES = {
@@ -15,10 +16,11 @@ export const CRUNCH_EXTERNAL_LIBRARIES = {
15
16
  * @param options - loader options
16
17
  * @returns Promise of module object
17
18
  */
18
- export async function loadCrunchModule(options): Promise<any> {
19
- const modules = options.modules || {};
20
- if (modules.crunch) {
21
- return modules.crunch;
19
+ export async function loadCrunchModule(options: LoaderOptions): Promise<any> {
20
+ registerJSModules(options.modules);
21
+ const crunch = getJSModuleOrNull('crunch');
22
+ if (crunch) {
23
+ return crunch;
22
24
  }
23
25
 
24
26
  return loadCrunch(options);
@@ -31,7 +33,7 @@ let crunchModule;
31
33
  * @param {any} options - Loader options
32
34
  * @returns {Promise<any>} Promise of Module object
33
35
  */
34
- async function loadCrunch(options) {
36
+ async function loadCrunch(options: LoaderOptions): Promise<any> {
35
37
  if (crunchModule) {
36
38
  return crunchModule;
37
39
  }
@@ -40,7 +42,7 @@ async function loadCrunch(options) {
40
42
 
41
43
  // Depends on how import happened...
42
44
  // @ts-ignore TS2339: Property does not exist on type
43
- loadCrunchDecoder = loadCrunchDecoder || globalThis.LoadCrunchDecoder;
45
+ loadCrunchDecoder ||= globalThis.LoadCrunchDecoder;
44
46
  crunchModule = loadCrunchDecoder();
45
47
  return crunchModule;
46
48
  }
package/src/npy-loader.ts CHANGED
@@ -9,14 +9,22 @@ import {parseNPY, NPYTile} from './lib/parsers/parse-npy';
9
9
  // \x93NUMPY
10
10
  const NPY_MAGIC_NUMBER = new Uint8Array([147, 78, 85, 77, 80, 89]);
11
11
 
12
+ /** NPYLoader for numpy tiles */
12
13
  export type NPYLoaderOptions = LoaderOptions & {
13
- npy?: {};
14
+ /** NPYLoader for numpy tiles */
15
+ npy?: {
16
+ /** Override the URL to the worker bundle (by default loads from unpkg.com) */
17
+ workerUrl?: string;
18
+ };
14
19
  };
15
20
 
16
21
  /**
17
22
  * Worker loader for numpy "tiles"
18
23
  */
19
- export const NPYWorkerLoader: Loader<NPYTile, never, NPYLoaderOptions> = {
24
+ export const NPYWorkerLoader = {
25
+ dataType: null as any as NPYTile,
26
+ batchType: null as never,
27
+
20
28
  name: 'NPY',
21
29
  id: 'npy',
22
30
  module: 'textures',
@@ -28,13 +36,13 @@ export const NPYWorkerLoader: Loader<NPYTile, never, NPYLoaderOptions> = {
28
36
  options: {
29
37
  npy: {}
30
38
  }
31
- };
39
+ } as const satisfies Loader<NPYTile, never, NPYLoaderOptions>;
32
40
 
33
41
  /**
34
42
  * Loader for numpy "tiles"
35
43
  */
36
- export const NPYLoader: LoaderWithParser<any, any, NPYLoaderOptions> = {
44
+ export const NPYLoader = {
37
45
  ...NPYWorkerLoader,
38
46
  parseSync: parseNPY,
39
47
  parse: async (arrayBuffer: ArrayBuffer, options?: LoaderOptions) => parseNPY(arrayBuffer, options)
40
- };
48
+ } as const satisfies LoaderWithParser<any, any, NPYLoaderOptions>;