@loaders.gl/textures 3.1.8 → 3.2.0-alpha.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 (86) hide show
  1. package/dist/basis-worker.js +57 -26
  2. package/dist/compressed-texture-loader.d.ts +1 -1
  3. package/dist/compressed-texture-loader.js +1 -1
  4. package/dist/compressed-texture-worker.js +58 -27
  5. package/dist/crunch-worker.js +61 -29
  6. package/dist/dist.min.js +13 -13
  7. package/dist/es5/compressed-texture-loader.js +1 -1
  8. package/dist/es5/compressed-texture-loader.js.map +1 -1
  9. package/dist/es5/index.js.map +1 -1
  10. package/dist/es5/lib/parsers/basis-module-loader.js +1 -1
  11. package/dist/es5/lib/parsers/basis-module-loader.js.map +1 -1
  12. package/dist/es5/lib/parsers/parse-basis.js +8 -8
  13. package/dist/es5/lib/parsers/parse-basis.js.map +1 -1
  14. package/dist/es5/lib/parsers/parse-compressed-texture.js.map +1 -1
  15. package/dist/es5/lib/parsers/parse-crunch.js +8 -7
  16. package/dist/es5/lib/parsers/parse-crunch.js.map +1 -1
  17. package/dist/es5/lib/parsers/parse-dds.js.map +1 -1
  18. package/dist/es5/lib/parsers/parse-ktx.js.map +1 -1
  19. package/dist/es5/lib/parsers/parse-npy.js.map +1 -1
  20. package/dist/es5/lib/parsers/parse-pvr.js.map +1 -1
  21. package/dist/es5/lib/utils/extract-mipmap-images.js.map +1 -1
  22. package/dist/es5/lib/utils/texture-formats.js.map +1 -1
  23. package/dist/es5/lib/utils/version.js +1 -1
  24. package/dist/es5/lib/utils/version.js.map +1 -1
  25. package/dist/esm/compressed-texture-loader.js +1 -1
  26. package/dist/esm/compressed-texture-loader.js.map +1 -1
  27. package/dist/esm/index.js.map +1 -1
  28. package/dist/esm/lib/parsers/basis-module-loader.js +1 -1
  29. package/dist/esm/lib/parsers/basis-module-loader.js.map +1 -1
  30. package/dist/esm/lib/parsers/parse-basis.js +8 -8
  31. package/dist/esm/lib/parsers/parse-basis.js.map +1 -1
  32. package/dist/esm/lib/parsers/parse-compressed-texture.js.map +1 -1
  33. package/dist/esm/lib/parsers/parse-crunch.js +13 -12
  34. package/dist/esm/lib/parsers/parse-crunch.js.map +1 -1
  35. package/dist/esm/lib/parsers/parse-dds.js.map +1 -1
  36. package/dist/esm/lib/parsers/parse-ktx.js.map +1 -1
  37. package/dist/esm/lib/parsers/parse-npy.js.map +1 -1
  38. package/dist/esm/lib/parsers/parse-pvr.js.map +1 -1
  39. package/dist/esm/lib/utils/extract-mipmap-images.js.map +1 -1
  40. package/dist/esm/lib/utils/texture-formats.js.map +1 -1
  41. package/dist/esm/lib/utils/version.js +1 -1
  42. package/dist/esm/lib/utils/version.js.map +1 -1
  43. package/dist/esm/types.js +1 -1
  44. package/dist/index.d.ts +1 -1
  45. package/dist/index.d.ts.map +1 -1
  46. package/dist/lib/parsers/basis-module-loader.js +1 -1
  47. package/dist/lib/parsers/parse-basis.d.ts +8 -6
  48. package/dist/lib/parsers/parse-basis.d.ts.map +1 -1
  49. package/dist/lib/parsers/parse-basis.js +25 -25
  50. package/dist/lib/parsers/parse-compressed-texture.d.ts +1 -1
  51. package/dist/lib/parsers/parse-compressed-texture.d.ts.map +1 -1
  52. package/dist/lib/parsers/parse-crunch.d.ts +1 -1
  53. package/dist/lib/parsers/parse-crunch.d.ts.map +1 -1
  54. package/dist/lib/parsers/parse-crunch.js +14 -13
  55. package/dist/lib/parsers/parse-dds.d.ts +1 -1
  56. package/dist/lib/parsers/parse-dds.d.ts.map +1 -1
  57. package/dist/lib/parsers/parse-ktx.d.ts +2 -1
  58. package/dist/lib/parsers/parse-ktx.d.ts.map +1 -1
  59. package/dist/lib/parsers/parse-npy.d.ts.map +1 -1
  60. package/dist/lib/parsers/parse-npy.js +1 -0
  61. package/dist/lib/parsers/parse-pvr.d.ts +1 -1
  62. package/dist/lib/parsers/parse-pvr.d.ts.map +1 -1
  63. package/dist/lib/parsers/parse-pvr.js +2 -2
  64. package/dist/lib/utils/extract-mipmap-images.d.ts +8 -1
  65. package/dist/lib/utils/extract-mipmap-images.d.ts.map +1 -1
  66. package/dist/lib/utils/version.d.ts.map +1 -1
  67. package/dist/lib/utils/version.js +2 -1
  68. package/dist/npy-worker.js +46 -15
  69. package/dist/types.d.ts +0 -20
  70. package/dist/types.d.ts.map +1 -1
  71. package/dist/types.js +0 -1
  72. package/package.json +6 -5
  73. package/src/compressed-texture-loader.ts +1 -1
  74. package/src/index.ts +1 -1
  75. package/src/lib/parsers/basis-module-loader.ts +1 -1
  76. package/src/lib/parsers/parse-basis.ts +68 -36
  77. package/src/lib/parsers/parse-compressed-texture.ts +1 -1
  78. package/src/lib/parsers/parse-crunch.ts +15 -14
  79. package/src/lib/parsers/parse-dds.ts +1 -1
  80. package/src/lib/parsers/parse-ktx.ts +2 -1
  81. package/src/lib/parsers/parse-npy.ts +2 -0
  82. package/src/lib/parsers/parse-pvr.ts +2 -1
  83. package/src/lib/utils/extract-mipmap-images.ts +9 -1
  84. package/src/lib/utils/texture-formats.ts +1 -1
  85. package/src/lib/utils/version.ts +2 -1
  86. package/src/types.ts +0 -30
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/texture-formats.ts"],"names":["BROWSER_PREFIXES","WEBGL_EXTENSIONS","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_atc","WEBGL_compressed_texture_astc","EXT_texture_compression_rgtc","formats","getSupportedGPUTextureFormats","gl","getWebGLContext","undefined","Set","prefix","extension","getExtension","gpuTextureFormat","add","canvas","document","createElement","getContext","error"],"mappings":"AAEA,MAAMA,gBAAgB,GAAG,CAAC,EAAD,EAAK,SAAL,EAAgB,MAAhB,CAAzB;AAEA,MAAMC,gBAAmD,GAAG;AAE1DC,EAAAA,6BAA6B,EAAE,KAF2B;AAG1DC,EAAAA,kCAAkC,EAAE,UAHsB;AAI1DC,EAAAA,6BAA6B,EAAE,MAJ2B;AAK1DC,EAAAA,4BAA4B,EAAE,MAL4B;AAM1DC,EAAAA,8BAA8B,EAAE,OAN0B;AAO1DC,EAAAA,4BAA4B,EAAE,KAP4B;AAQ1DC,EAAAA,6BAA6B,EAAE,MAR2B;AAS1DC,EAAAA,4BAA4B,EAAE;AAT4B,CAA5D;AAaA,IAAIC,OAAqC,GAAG,IAA5C;AAQA,OAAO,SAASC,6BAAT,CAAuCC,EAAvC,EAAgF;AACrF,MAAI,CAACF,OAAL,EAAc;AACZE,IAAAA,EAAE,GAAGA,EAAE,IAAIC,eAAe,EAArB,IAA2BC,SAAhC;AAEAJ,IAAAA,OAAO,GAAG,IAAIK,GAAJ,EAAV;;AAEA,SAAK,MAAMC,MAAX,IAAqBhB,gBAArB,EAAuC;AACrC,WAAK,MAAMiB,SAAX,IAAwBhB,gBAAxB,EAA0C;AACxC,YAAIW,EAAE,IAAIA,EAAE,CAACM,YAAH,WAAmBF,MAAnB,SAA4BC,SAA5B,EAAV,EAAoD;AAClD,gBAAME,gBAAgB,GAAGlB,gBAAgB,CAACgB,SAAD,CAAzC;AACAP,UAAAA,OAAO,CAACU,GAAR,CAAYD,gBAAZ;AACD;AACF;AACF;AACF;;AAED,SAAOT,OAAP;AACD;;AAKD,SAASG,eAAT,GAA2B;AACzB,MAAI;AACF,UAAMQ,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;AACA,WAAOF,MAAM,CAACG,UAAP,CAAkB,OAAlB,CAAP;AACD,GAHD,CAGE,OAAOC,KAAP,EAAc;AACd,WAAO,IAAP;AACD;AACF","sourcesContent":["import type {GPUTextureFormat} from '../../types';\n\nconst BROWSER_PREFIXES = ['', 'WEBKIT_', 'MOZ_'];\n\nconst WEBGL_EXTENSIONS: {[key: string]: GPUTextureFormat} = {\n /* eslint-disable camelcase */\n WEBGL_compressed_texture_s3tc: 'dxt',\n WEBGL_compressed_texture_s3tc_srgb: 'dxt-srgb',\n WEBGL_compressed_texture_etc1: 'etc1',\n WEBGL_compressed_texture_etc: 'etc2',\n WEBGL_compressed_texture_pvrtc: 'pvrtc',\n WEBGL_compressed_texture_atc: 'atc',\n WEBGL_compressed_texture_astc: 'astc',\n EXT_texture_compression_rgtc: 'rgtc'\n /* eslint-enable camelcase */\n};\n\nlet formats: Set<GPUTextureFormat> | null = null;\n\n/**\n * Returns a list of formats.\n * Creates a temporary WebGLRenderingContext if none is provided.\n *\n * @param gl - Optional context.\n */\nexport function getSupportedGPUTextureFormats(gl?: WebGLRenderingContext): Set<string> {\n if (!formats) {\n gl = gl || getWebGLContext() || undefined;\n\n formats = new Set<GPUTextureFormat>();\n\n for (const prefix of BROWSER_PREFIXES) {\n for (const extension in WEBGL_EXTENSIONS) {\n if (gl && gl.getExtension(`${prefix}${extension}`)) {\n const gpuTextureFormat = WEBGL_EXTENSIONS[extension];\n formats.add(gpuTextureFormat);\n }\n }\n }\n }\n\n return formats;\n}\n\n/**\n * @returns {WebGLRenderingContext?}\n */\nfunction getWebGLContext() {\n try {\n const canvas = document.createElement('canvas');\n return canvas.getContext('webgl');\n } catch (error) {\n return null;\n }\n}\n"],"file":"texture-formats.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/texture-formats.ts"],"names":["BROWSER_PREFIXES","WEBGL_EXTENSIONS","WEBGL_compressed_texture_s3tc","WEBGL_compressed_texture_s3tc_srgb","WEBGL_compressed_texture_etc1","WEBGL_compressed_texture_etc","WEBGL_compressed_texture_pvrtc","WEBGL_compressed_texture_atc","WEBGL_compressed_texture_astc","EXT_texture_compression_rgtc","formats","getSupportedGPUTextureFormats","gl","getWebGLContext","undefined","Set","prefix","extension","getExtension","gpuTextureFormat","add","canvas","document","createElement","getContext","error"],"mappings":"AAEA,MAAMA,gBAAgB,GAAG,CAAC,EAAD,EAAK,SAAL,EAAgB,MAAhB,CAAzB;AAEA,MAAMC,gBAAmD,GAAG;AAE1DC,EAAAA,6BAA6B,EAAE,KAF2B;AAG1DC,EAAAA,kCAAkC,EAAE,UAHsB;AAI1DC,EAAAA,6BAA6B,EAAE,MAJ2B;AAK1DC,EAAAA,4BAA4B,EAAE,MAL4B;AAM1DC,EAAAA,8BAA8B,EAAE,OAN0B;AAO1DC,EAAAA,4BAA4B,EAAE,KAP4B;AAQ1DC,EAAAA,6BAA6B,EAAE,MAR2B;AAS1DC,EAAAA,4BAA4B,EAAE;AAT4B,CAA5D;AAaA,IAAIC,OAAqC,GAAG,IAA5C;AAQA,OAAO,SAASC,6BAAT,CAAuCC,EAAvC,EAAgF;AACrF,MAAI,CAACF,OAAL,EAAc;AACZE,IAAAA,EAAE,GAAGA,EAAE,IAAIC,eAAe,EAArB,IAA2BC,SAAhC;AAEAJ,IAAAA,OAAO,GAAG,IAAIK,GAAJ,EAAV;;AAEA,SAAK,MAAMC,MAAX,IAAqBhB,gBAArB,EAAuC;AACrC,WAAK,MAAMiB,SAAX,IAAwBhB,gBAAxB,EAA0C;AACxC,YAAIW,EAAE,IAAIA,EAAE,CAACM,YAAH,WAAmBF,MAAnB,SAA4BC,SAA5B,EAAV,EAAoD;AAClD,gBAAME,gBAAgB,GAAGlB,gBAAgB,CAACgB,SAAD,CAAzC;AACAP,UAAAA,OAAO,CAACU,GAAR,CAAYD,gBAAZ;AACD;AACF;AACF;AACF;;AAED,SAAOT,OAAP;AACD;;AAKD,SAASG,eAAT,GAA2B;AACzB,MAAI;AACF,UAAMQ,MAAM,GAAGC,QAAQ,CAACC,aAAT,CAAuB,QAAvB,CAAf;AACA,WAAOF,MAAM,CAACG,UAAP,CAAkB,OAAlB,CAAP;AACD,GAHD,CAGE,OAAOC,KAAP,EAAc;AACd,WAAO,IAAP;AACD;AACF","sourcesContent":["import type {GPUTextureFormat} from '@loaders.gl/schema';\n\nconst BROWSER_PREFIXES = ['', 'WEBKIT_', 'MOZ_'];\n\nconst WEBGL_EXTENSIONS: {[key: string]: GPUTextureFormat} = {\n /* eslint-disable camelcase */\n WEBGL_compressed_texture_s3tc: 'dxt',\n WEBGL_compressed_texture_s3tc_srgb: 'dxt-srgb',\n WEBGL_compressed_texture_etc1: 'etc1',\n WEBGL_compressed_texture_etc: 'etc2',\n WEBGL_compressed_texture_pvrtc: 'pvrtc',\n WEBGL_compressed_texture_atc: 'atc',\n WEBGL_compressed_texture_astc: 'astc',\n EXT_texture_compression_rgtc: 'rgtc'\n /* eslint-enable camelcase */\n};\n\nlet formats: Set<GPUTextureFormat> | null = null;\n\n/**\n * Returns a list of formats.\n * Creates a temporary WebGLRenderingContext if none is provided.\n *\n * @param gl - Optional context.\n */\nexport function getSupportedGPUTextureFormats(gl?: WebGLRenderingContext): Set<string> {\n if (!formats) {\n gl = gl || getWebGLContext() || undefined;\n\n formats = new Set<GPUTextureFormat>();\n\n for (const prefix of BROWSER_PREFIXES) {\n for (const extension in WEBGL_EXTENSIONS) {\n if (gl && gl.getExtension(`${prefix}${extension}`)) {\n const gpuTextureFormat = WEBGL_EXTENSIONS[extension];\n formats.add(gpuTextureFormat);\n }\n }\n }\n }\n\n return formats;\n}\n\n/**\n * @returns {WebGLRenderingContext?}\n */\nfunction getWebGLContext() {\n try {\n const canvas = document.createElement('canvas');\n return canvas.getContext('webgl');\n } catch (error) {\n return null;\n }\n}\n"],"file":"texture-formats.js"}
@@ -1,2 +1,2 @@
1
- export const VERSION = typeof "3.1.8" !== 'undefined' ? "3.1.8" : 'latest';
1
+ export const VERSION = typeof "3.2.0-alpha.1" !== 'undefined' ? "3.2.0-alpha.1" : 'beta';
2
2
  //# sourceMappingURL=version.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAGA,OAAO,MAAMA,OAAO,GAAG,mBAAuB,WAAvB,aAAmD,QAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';\n"],"file":"version.js"}
1
+ {"version":3,"sources":["../../../../src/lib/utils/version.ts"],"names":["VERSION"],"mappings":"AAIA,OAAO,MAAMA,OAAO,GAAG,2BAAuB,WAAvB,qBAAmD,MAAnE","sourcesContent":["// Version constant cannot be imported, it needs to correspond to the build version of **this** module.\n// __VERSION__ is injected by babel-plugin-version-inline\n// TODO: use 'latest' instead of 'beta' when 3.0.0 version is released as 'latest'\n// @ts-ignore TS2304: Cannot find name '__VERSION__'.\nexport const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';\n"],"file":"version.js"}
package/dist/esm/types.js CHANGED
@@ -1,2 +1,2 @@
1
- export {};
1
+
2
2
  //# sourceMappingURL=types.js.map
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export type { GPUTextureFormat } from './types';
1
+ export type { GPUTextureFormat } from '@loaders.gl/schema';
2
2
  export type { TextureLoaderOptions } from './compressed-texture-loader';
3
3
  export { BasisLoader, BasisWorkerLoader } from './basis-loader';
4
4
  export { CompressedTextureLoader, CompressedTextureWorkerLoader } from './compressed-texture-loader';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,gBAAgB,EAAC,MAAM,SAAS,CAAC;AAC9C,YAAY,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAE,6BAA6B,EAAC,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,+BAA+B,EAAC,MAAM,uCAAuC,CAAC;AAGtF,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AAGvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,0BAA0B,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,6BAA6B,EAAC,MAAM,6BAA6B,CAAC;AAG1E,OAAO,EAAC,YAAY,IAAI,kBAAkB,EAAC,MAAM,iBAAiB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EAAC,gBAAgB,EAAC,MAAM,oBAAoB,CAAC;AACzD,YAAY,EAAC,oBAAoB,EAAC,MAAM,6BAA6B,CAAC;AAGtE,OAAO,EAAC,WAAW,EAAE,iBAAiB,EAAC,MAAM,gBAAgB,CAAC;AAC9D,OAAO,EAAC,uBAAuB,EAAE,6BAA6B,EAAC,MAAM,6BAA6B,CAAC;AACnG,OAAO,EAAC,YAAY,EAAC,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAC,SAAS,EAAE,eAAe,EAAC,MAAM,cAAc,CAAC;AAGxD,OAAO,EAAC,uBAAuB,EAAC,MAAM,6BAA6B,CAAC;AACpE,OAAO,EAAC,+BAA+B,EAAC,MAAM,uCAAuC,CAAC;AAGtF,OAAO,EAAC,gBAAgB,EAAC,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAC,qBAAqB,EAAC,MAAM,oCAAoC,CAAC;AACzE,OAAO,EAAC,oBAAoB,EAAC,MAAM,mCAAmC,CAAC;AAGvE,OAAO,EAAC,uBAAuB,EAAC,MAAM,qBAAqB,CAAC;AAC5D,OAAO,EAAC,0BAA0B,EAAC,MAAM,2BAA2B,CAAC;AACrE,OAAO,EAAC,6BAA6B,EAAC,MAAM,6BAA6B,CAAC;AAG1E,OAAO,EAAC,YAAY,IAAI,kBAAkB,EAAC,MAAM,iBAAiB,CAAC"}
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.loadBasisEncoderModule = exports.loadBasisTrascoderModule = void 0;
4
4
  // __VERSION__ is injected by babel-plugin-version-inline
5
5
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
6
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
6
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
7
7
  // @ts-nocheck
8
8
  const worker_utils_1 = require("@loaders.gl/worker-utils");
9
9
  const BASIS_CDN_ENCODER_WASM = `https://unpkg.com/@loaders.gl/textures@${VERSION}/dist/libs/basis_encoder.wasm`;
@@ -1,16 +1,18 @@
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
+ export declare type BasisFormat = 'etc1' | 'etc2' | 'bc1' | 'bc3' | 'bc4' | 'bc5' | 'bc7-m6-opaque-only' | 'bc7-m5' | 'pvrtc1-4-rgb' | 'pvrtc1-4-rgba' | 'astc-4x4' | 'atc-rgb' | 'atc-rgba-interpolated-alpha' | 'rgba32' | 'rgb565' | 'bgr565' | 'rgba4444';
1
3
  /**
2
4
  * parse data with a Binomial Basis_Universal module
3
- * @param {ArrayBuffer} data
4
- * @param {*} options
5
+ * @param data
6
+ * @param options
5
7
  * @returns compressed texture data
6
8
  */
7
- export default function parseBasis(data: any, options: any): Promise<any[] | null>;
9
+ export default function parseBasis(data: ArrayBuffer, options: any): Promise<TextureLevel[][]>;
8
10
  /**
9
11
  * Select transcode format from the list of supported formats
10
12
  * @returns key for OutputFormat map
11
13
  */
12
- export declare function selectSupportedBasisFormat(): "etc1" | "etc2" | "astc-4x4" | "rgb565" | {
13
- alpha: string;
14
- noAlpha: string;
14
+ export declare function selectSupportedBasisFormat(): BasisFormat | {
15
+ alpha: BasisFormat;
16
+ noAlpha: BasisFormat;
15
17
  };
16
18
  //# sourceMappingURL=parse-basis.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-basis.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-basis.ts"],"names":[],"mappings":"AAiDA;;;;;GAKG;AACH,wBAA8B,UAAU,CAAC,IAAI,KAAA,EAAE,OAAO,KAAA,yBAwBrD;AA8KD;;;GAGG;AACH,wBAAgB,0BAA0B;;;EAoBzC"}
1
+ {"version":3,"file":"parse-basis.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-basis.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAMrD,oBAAY,WAAW,GACnB,MAAM,GACN,MAAM,GACN,KAAK,GACL,KAAK,GACL,KAAK,GACL,KAAK,GACL,oBAAoB,GACpB,QAAQ,GACR,cAAc,GACd,eAAe,GACf,UAAU,GACV,SAAS,GACT,6BAA6B,GAC7B,QAAQ,GACR,QAAQ,GACR,QAAQ,GACR,UAAU,CAAC;AAoDf;;;;;GAKG;AACH,wBAA8B,UAAU,CAAC,IAAI,EAAE,WAAW,EAAE,OAAO,KAAA,GAAG,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAwB9F;AA8KD;;;GAGG;AACH,wBAAgB,0BAA0B,IACtC,WAAW,GACX;IACE,KAAK,EAAE,WAAW,CAAC;IACnB,OAAO,EAAE,WAAW,CAAC;CACtB,CAoBJ"}
@@ -50,8 +50,8 @@ const OutputFormat = {
50
50
  };
51
51
  /**
52
52
  * parse data with a Binomial Basis_Universal module
53
- * @param {ArrayBuffer} data
54
- * @param {*} options
53
+ * @param data
54
+ * @param options
55
55
  * @returns compressed texture data
56
56
  */
57
57
  async function parseBasis(data, options) {
@@ -82,16 +82,16 @@ async function parseBasis(data, options) {
82
82
  exports.default = parseBasis;
83
83
  /**
84
84
  * Parse *.basis file data
85
- * @param {*} BasisFile - initialized transcoder module
86
- * @param {*} data
87
- * @param {*} options
85
+ * @param BasisFile - initialized transcoder module
86
+ * @param data
87
+ * @param options
88
88
  * @returns compressed texture data
89
89
  */
90
90
  function parseBasisFile(BasisFile, data, options) {
91
91
  const basisFile = new BasisFile(new Uint8Array(data));
92
92
  try {
93
93
  if (!basisFile.startTranscoding()) {
94
- return null;
94
+ throw new Error('Failed to start basis transcoding');
95
95
  }
96
96
  const imageCount = basisFile.getNumImages();
97
97
  const images = [];
@@ -112,10 +112,10 @@ function parseBasisFile(BasisFile, data, options) {
112
112
  }
113
113
  /**
114
114
  * Parse the particular level image of a basis file
115
- * @param {*} basisFile
116
- * @param {*} imageIndex
117
- * @param {*} levelIndex
118
- * @param {*} options
115
+ * @param basisFile
116
+ * @param imageIndex
117
+ * @param levelIndex
118
+ * @param options
119
119
  * @returns compressed texture data
120
120
  */
121
121
  function transcodeImage(basisFile, imageIndex, levelIndex, options) {
@@ -128,7 +128,7 @@ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
128
128
  const decodedSize = basisFile.getImageTranscodedSizeInBytes(imageIndex, levelIndex, basisFormat);
129
129
  const decodedData = new Uint8Array(decodedSize);
130
130
  if (!basisFile.transcodeImage(decodedData, imageIndex, levelIndex, basisFormat, 0, 0)) {
131
- return null;
131
+ throw new Error('failed to start Basis transcoding');
132
132
  }
133
133
  return {
134
134
  // standard loaders.gl image category payload
@@ -136,24 +136,24 @@ function transcodeImage(basisFile, imageIndex, levelIndex, options) {
136
136
  height,
137
137
  data: decodedData,
138
138
  compressed,
139
+ format,
139
140
  // Additional fields
140
141
  // Add levelSize field.
141
- hasAlpha,
142
- format
142
+ hasAlpha
143
143
  };
144
144
  }
145
145
  /**
146
146
  * Parse *.ktx2 file data
147
- * @param {*} KTX2File
148
- * @param {*} data
149
- * @param {*} options
147
+ * @param KTX2File
148
+ * @param data
149
+ * @param options
150
150
  * @returns compressed texture data
151
151
  */
152
152
  function parseKTX2File(KTX2File, data, options) {
153
153
  const ktx2File = new KTX2File(new Uint8Array(data));
154
154
  try {
155
155
  if (!ktx2File.startTranscoding()) {
156
- return null;
156
+ throw new Error('failed to start KTX2 transcoding');
157
157
  }
158
158
  const levelsCount = ktx2File.getLevels();
159
159
  const levels = [];
@@ -161,7 +161,7 @@ function parseKTX2File(KTX2File, data, options) {
161
161
  levels.push(transcodeKTX2Image(ktx2File, levelIndex, options));
162
162
  break; // texture app can only show one level for some reason
163
163
  }
164
- return levels;
164
+ return [levels];
165
165
  }
166
166
  finally {
167
167
  ktx2File.close();
@@ -170,9 +170,9 @@ function parseKTX2File(KTX2File, data, options) {
170
170
  }
171
171
  /**
172
172
  * Parse the particular level image of a ktx2 file
173
- * @param {*} ktx2File
174
- * @param {*} levelIndex
175
- * @param {*} options
173
+ * @param ktx2File
174
+ * @param levelIndex
175
+ * @param options
176
176
  * @returns
177
177
  */
178
178
  function transcodeKTX2Image(ktx2File, levelIndex, options) {
@@ -182,7 +182,7 @@ function transcodeKTX2Image(ktx2File, levelIndex, options) {
182
182
  const decodedSize = ktx2File.getImageTranscodedSizeInBytes(levelIndex, 0 /* layerIndex */, 0 /* faceIndex */, basisFormat);
183
183
  const decodedData = new Uint8Array(decodedSize);
184
184
  if (!ktx2File.transcodeImage(decodedData, levelIndex, 0 /* layerIndex */, 0 /* faceIndex */, basisFormat, 0, -1 /* channel0 */, -1 /* channel1 */)) {
185
- return null;
185
+ throw new Error('Failed to transcode KTX2 image');
186
186
  }
187
187
  return {
188
188
  // standard loaders.gl image category payload
@@ -192,14 +192,14 @@ function transcodeKTX2Image(ktx2File, levelIndex, options) {
192
192
  compressed,
193
193
  // Additional fields
194
194
  // Add levelSize field.
195
- alphaFlag,
195
+ hasAlpha: alphaFlag,
196
196
  format
197
197
  };
198
198
  }
199
199
  /**
200
200
  * Get BasisFormat by loader format option
201
- * @param {*} options
202
- * @param {*} hasAlpha
201
+ * @param options
202
+ * @param hasAlpha
203
203
  * @returns BasisFormat data
204
204
  */
205
205
  function getBasisOptions(options, hasAlpha) {
@@ -1,4 +1,4 @@
1
- import type { TextureLevel } from '../../types';
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
2
  /**
3
3
  * Deduces format and parses compressed texture loaded in ArrayBuffer
4
4
  * @param data - binary data of compressed texture
@@ -1 +1 @@
1
- {"version":3,"file":"parse-compressed-texture.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-compressed-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAK9C;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CAaxE"}
1
+ {"version":3,"file":"parse-compressed-texture.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-compressed-texture.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAKrD;;;;GAIG;AACH,wBAAgB,sBAAsB,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CAaxE"}
@@ -1,4 +1,4 @@
1
- import type { TextureLevel } from '../../types';
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
2
  /**
3
3
  * Parse texture data as "CRN" format.
4
4
  * Function is "async" as emscriptified decoder module is loaded asyncronously
@@ -1 +1 @@
1
- {"version":3,"file":"parse-crunch.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-crunch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AAqC9C;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,KAAA,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAmD7E"}
1
+ {"version":3,"file":"parse-crunch.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-crunch.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAsCrD;;;;;GAKG;AACH,wBAAsB,WAAW,CAAC,IAAI,KAAA,EAAE,OAAO,EAAE,GAAG,GAAG,OAAO,CAAC,YAAY,EAAE,CAAC,CAmD7E"}
@@ -15,19 +15,20 @@ const CRN_FORMAT = {
15
15
  cCRNFmtDXT5: 2
16
16
  // Crunch supports more formats than this.
17
17
  };
18
- // Mapping of Crunch formats to DXT formats.
19
- const DXT_FORMAT_MAP = {};
20
- DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT1] = {
21
- pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
22
- sizeFunction: parse_dds_1.getDxt1LevelSize
23
- };
24
- DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT3] = {
25
- pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
26
- sizeFunction: parse_dds_1.getDxtXLevelSize
27
- };
28
- DXT_FORMAT_MAP[CRN_FORMAT.cCRNFmtDXT5] = {
29
- pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
30
- sizeFunction: parse_dds_1.getDxtXLevelSize
18
+ /** Mapping of Crunch formats to DXT formats. */
19
+ const DXT_FORMAT_MAP = {
20
+ [CRN_FORMAT.cCRNFmtDXT1]: {
21
+ pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGB_S3TC_DXT1_EXT,
22
+ sizeFunction: parse_dds_1.getDxt1LevelSize
23
+ },
24
+ [CRN_FORMAT.cCRNFmtDXT3]: {
25
+ pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT3_EXT,
26
+ sizeFunction: parse_dds_1.getDxtXLevelSize
27
+ },
28
+ [CRN_FORMAT.cCRNFmtDXT5]: {
29
+ pixelFormat: gl_extensions_1.GL_EXTENSIONS_CONSTANTS.COMPRESSED_RGBA_S3TC_DXT5_EXT,
30
+ sizeFunction: parse_dds_1.getDxtXLevelSize
31
+ }
31
32
  };
32
33
  let cachedDstSize = 0;
33
34
  let dst;
@@ -1,4 +1,4 @@
1
- import type { TextureLevel } from '../../types';
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
2
  /**
3
3
  * Check if data is in "DDS" format by its magic number
4
4
  * @param data - binary data of compressed texture
@@ -1 +1 @@
1
- {"version":3,"file":"parse-dds.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-dds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AA0C9C;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAIhD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CA4B1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE"}
1
+ {"version":3,"file":"parse-dds.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-dds.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AA0CrD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAIhD;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CA4B1D;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAEtE"}
@@ -1,3 +1,4 @@
1
+ import type { TextureLevel } from '@loaders.gl/schema';
1
2
  export declare function isKTX(data: ArrayBuffer): boolean;
2
- export declare function parseKTX(arrayBuffer: ArrayBuffer): import("../../types").TextureLevel[];
3
+ export declare function parseKTX(arrayBuffer: ArrayBuffer): TextureLevel[];
3
4
  //# sourceMappingURL=parse-ktx.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"parse-ktx.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-ktx.ts"],"names":[],"mappings":"AAUA,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,WAmBtC;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,wCAehD"}
1
+ {"version":3,"file":"parse-ktx.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-ktx.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAWrD,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,WAmBtC;AAED,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,GAAG,YAAY,EAAE,CAejE"}
@@ -1 +1 @@
1
- {"version":3,"file":"parse-npy.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-npy.ts"],"names":[],"mappings":"AAAA,aAAK,WAAW,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC;AA6BpD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO;;;SA+BnE"}
1
+ {"version":3,"file":"parse-npy.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-npy.ts"],"names":[],"mappings":"AAEA,aAAK,WAAW,GAAG;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAA;CAAC,CAAC;AA6BpD,wBAAgB,QAAQ,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO;;;SA+BnE"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ // import type {TextureLevel} from '@loaders.gl/schema';
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.parseNPY = void 0;
4
5
  function systemIsLittleEndian() {
@@ -1,4 +1,4 @@
1
- import { TextureLevel } from '../../types';
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
2
  /**
3
3
  * Check if data is in "PVR" format by its magic number
4
4
  * @param data - binary data of compressed texture
@@ -1 +1 @@
1
- {"version":3,"file":"parse-pvr.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-pvr.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,YAAY,EAAC,MAAM,aAAa,CAAC;AA2HzC;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAKhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CA0B1D"}
1
+ {"version":3,"file":"parse-pvr.d.ts","sourceRoot":"","sources":["../../../src/lib/parsers/parse-pvr.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAwHrD;;;;GAIG;AACH,wBAAgB,KAAK,CAAC,IAAI,EAAE,WAAW,GAAG,OAAO,CAKhD;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,WAAW,GAAG,YAAY,EAAE,CA0B1D"}
@@ -1,9 +1,9 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parsePVR = exports.isPVR = void 0;
4
2
  /* eslint-disable camelcase */
5
3
  // Forked from PicoGL: https://github.com/tsherif/picogl.js/blob/master/examples/utils/utils.js
6
4
  // Copyright (c) 2017 Tarek Sherif, The MIT License (MIT)
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.parsePVR = exports.isPVR = void 0;
7
7
  const gl_extensions_1 = require("../gl-extensions");
8
8
  const extract_mipmap_images_1 = require("../utils/extract-mipmap-images");
9
9
  const PVR_CONSTANTS = {
@@ -1,4 +1,11 @@
1
- import { CompressedTextureExtractOptions, TextureLevel } from '../../types';
1
+ import type { TextureLevel } from '@loaders.gl/schema';
2
+ export declare type CompressedTextureExtractOptions = {
3
+ mipMapLevels: number;
4
+ width: number;
5
+ height: number;
6
+ sizeFunction: Function;
7
+ internalFormat: number;
8
+ };
2
9
  /**
3
10
  * Extract mipmap images from compressed texture buffer
4
11
  * @param data - binary data of compressed texture or Array of level objects
@@ -1 +1 @@
1
- {"version":3,"file":"extract-mipmap-images.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/extract-mipmap-images.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,+BAA+B,EAAE,YAAY,EAAC,MAAM,aAAa,CAAC;AAE1E;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,EAC3B,OAAO,EAAE,+BAA+B,GACvC,YAAY,EAAE,CA4BhB"}
1
+ {"version":3,"file":"extract-mipmap-images.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/extract-mipmap-images.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAC,YAAY,EAAC,MAAM,oBAAoB,CAAC;AAErD,oBAAY,+BAA+B,GAAG;IAC5C,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,QAAQ,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF;;;;;;;;;GASG;AACH,wBAAgB,mBAAmB,CACjC,IAAI,EAAE,UAAU,GAAG,MAAM,EAAE,EAC3B,OAAO,EAAE,+BAA+B,GACvC,YAAY,EAAE,CA4BhB"}
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/version.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,OAAO,KAA8D,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../../src/lib/utils/version.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,OAAO,KAA4D,CAAC"}
@@ -3,5 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
4
  // Version constant cannot be imported, it needs to correspond to the build version of **this** module.
5
5
  // __VERSION__ is injected by babel-plugin-version-inline
6
+ // TODO: use 'latest' instead of 'beta' when 3.0.0 version is released as 'latest'
6
7
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
7
- exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
8
+ exports.VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
@@ -1,6 +1,6 @@
1
1
  (() => {
2
2
  // src/lib/utils/version.ts
3
- var VERSION = true ? "3.1.8" : "latest";
3
+ var VERSION = true ? "3.2.0-alpha.1" : "beta";
4
4
 
5
5
  // src/lib/parsers/parse-npy.ts
6
6
  function systemIsLittleEndian() {
@@ -119,16 +119,33 @@
119
119
  }
120
120
 
121
121
  // ../worker-utils/src/lib/worker-farm/worker-body.ts
122
+ function getParentPort() {
123
+ let parentPort;
124
+ try {
125
+ eval("globalThis.parentPort = require('worker_threads').parentPort");
126
+ parentPort = globalThis.parentPort;
127
+ } catch {
128
+ }
129
+ return parentPort;
130
+ }
122
131
  var onMessageWrapperMap = new Map();
123
132
  var WorkerBody = class {
133
+ static inWorkerThread() {
134
+ return typeof self !== "undefined" || Boolean(getParentPort());
135
+ }
124
136
  static set onmessage(onMessage) {
125
- self.onmessage = (message) => {
126
- if (!isKnownMessage(message)) {
127
- return;
128
- }
129
- const { type, payload } = message.data;
137
+ function handleMessage(message) {
138
+ const parentPort3 = getParentPort();
139
+ const { type, payload } = parentPort3 ? message : message.data;
130
140
  onMessage(type, payload);
131
- };
141
+ }
142
+ const parentPort2 = getParentPort();
143
+ if (parentPort2) {
144
+ parentPort2.on("message", handleMessage);
145
+ parentPort2.on("exit", () => console.debug("Node worker closing"));
146
+ } else {
147
+ globalThis.onmessage = handleMessage;
148
+ }
132
149
  }
133
150
  static addEventListener(onMessage) {
134
151
  let onMessageWrapper = onMessageWrapperMap.get(onMessage);
@@ -137,22 +154,36 @@
137
154
  if (!isKnownMessage(message)) {
138
155
  return;
139
156
  }
140
- const { type, payload } = message.data;
157
+ const parentPort3 = getParentPort();
158
+ const { type, payload } = parentPort3 ? message : message.data;
141
159
  onMessage(type, payload);
142
160
  };
143
161
  }
144
- self.addEventListener("message", onMessageWrapper);
162
+ const parentPort2 = getParentPort();
163
+ if (parentPort2) {
164
+ console.error("not implemented");
165
+ } else {
166
+ globalThis.addEventListener("message", onMessageWrapper);
167
+ }
145
168
  }
146
169
  static removeEventListener(onMessage) {
147
170
  const onMessageWrapper = onMessageWrapperMap.get(onMessage);
148
171
  onMessageWrapperMap.delete(onMessage);
149
- self.removeEventListener("message", onMessageWrapper);
172
+ const parentPort2 = getParentPort();
173
+ if (parentPort2) {
174
+ console.error("not implemented");
175
+ } else {
176
+ globalThis.removeEventListener("message", onMessageWrapper);
177
+ }
150
178
  }
151
179
  static postMessage(type, payload) {
152
- if (self) {
153
- const data = { source: "loaders.gl", type, payload };
154
- const transferList = getTransferList(payload);
155
- self.postMessage(data, transferList);
180
+ const data = { source: "loaders.gl", type, payload };
181
+ const transferList = getTransferList(payload);
182
+ const parentPort2 = getParentPort();
183
+ if (parentPort2) {
184
+ parentPort2.postMessage(data, transferList);
185
+ } else {
186
+ globalThis.postMessage(data, transferList);
156
187
  }
157
188
  }
158
189
  };
@@ -164,7 +195,7 @@
164
195
  // ../loader-utils/src/lib/worker-loader-utils/create-loader-worker.ts
165
196
  var requestId = 0;
166
197
  function createLoaderWorker(loader) {
167
- if (typeof self === "undefined") {
198
+ if (!WorkerBody.inWorkerThread()) {
168
199
  return;
169
200
  }
170
201
  WorkerBody.onmessage = async (type, payload) => {
package/dist/types.d.ts CHANGED
@@ -1,21 +1 @@
1
- /**
2
- * These represent the main compressed texture formats
3
- * Each format typically has a number of more specific subformats
4
- */
5
- export declare type GPUTextureFormat = 'dxt' | 'dxt-srgb' | 'etc1' | 'etc2' | 'pvrtc' | 'atc' | 'astc' | 'rgtc';
6
- export interface TextureLevel {
7
- compressed: boolean;
8
- format: number;
9
- data: Uint8Array;
10
- witdh: number;
11
- height: number;
12
- levelSize?: number;
13
- }
14
- export interface CompressedTextureExtractOptions {
15
- mipMapLevels: number;
16
- width: number;
17
- height: number;
18
- sizeFunction: Function;
19
- internalFormat: number;
20
- }
21
1
  //# sourceMappingURL=types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,oBAAY,gBAAgB,GACxB,KAAK,GACL,UAAU,GACV,MAAM,GACN,MAAM,GACN,OAAO,GACP,KAAK,GACL,MAAM,GACN,MAAM,CAAC;AAEX,MAAM,WAAW,YAAY;IAC3B,UAAU,EAAE,OAAO,CAAC;IACpB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,UAAU,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,+BAA+B;IAC9C,YAAY,EAAE,MAAM,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,YAAY,EAAE,QAAQ,CAAC;IACvB,cAAc,EAAE,MAAM,CAAC;CACxB"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
package/dist/types.js CHANGED
@@ -1,2 +1 @@
1
1
  "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@loaders.gl/textures",
3
- "version": "3.1.8",
3
+ "version": "3.2.0-alpha.1",
4
4
  "description": "Framework-independent loaders for compressed and super compressed (basis) textures ",
5
5
  "license": "MIT",
6
6
  "publishConfig": {
@@ -42,11 +42,12 @@
42
42
  "build-crunch-worker": "esbuild src/workers/crunch-worker.ts --bundle --outfile=dist/crunch-worker.js --define:__VERSION__=\\\"$npm_package_version\\\""
43
43
  },
44
44
  "dependencies": {
45
- "@loaders.gl/images": "3.1.8",
46
- "@loaders.gl/loader-utils": "3.1.8",
47
- "@loaders.gl/worker-utils": "3.1.8",
45
+ "@loaders.gl/images": "3.2.0-alpha.1",
46
+ "@loaders.gl/loader-utils": "3.2.0-alpha.1",
47
+ "@loaders.gl/schema": "3.2.0-alpha.1",
48
+ "@loaders.gl/worker-utils": "3.2.0-alpha.1",
48
49
  "ktx-parse": "^0.0.4",
49
50
  "texture-compressor": "^1.0.2"
50
51
  },
51
- "gitHead": "0ef07b4e9fc20f5a882224cf241c6fd1bad898d8"
52
+ "gitHead": "423a2815092b08dcf93ad5b7dc2940b167305afe"
52
53
  }
@@ -59,7 +59,7 @@ export const CompressedTextureLoader = {
59
59
  containerFormat: 'ktx2',
60
60
  module: 'encoder'
61
61
  };
62
- return await parseBasis(arrayBuffer, options);
62
+ return (await parseBasis(arrayBuffer, options))[0];
63
63
  }
64
64
  return parseCompressedTexture(arrayBuffer);
65
65
  }
package/src/index.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  // Types
2
- export type {GPUTextureFormat} from './types';
2
+ export type {GPUTextureFormat} from '@loaders.gl/schema';
3
3
  export type {TextureLoaderOptions} from './compressed-texture-loader';
4
4
 
5
5
  // Loaders
@@ -1,6 +1,6 @@
1
1
  // __VERSION__ is injected by babel-plugin-version-inline
2
2
  // @ts-ignore TS2304: Cannot find name '__VERSION__'.
3
- const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'latest';
3
+ const VERSION = typeof __VERSION__ !== 'undefined' ? __VERSION__ : 'beta';
4
4
 
5
5
  // @ts-nocheck
6
6
  import {loadLibrary} from '@loaders.gl/worker-utils';