@monogrid/gainmap-js 2.0.4 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,10 @@
1
+ ## [2.0.5](https://github.com/MONOGRID/gainmap-js/compare/v2.0.4...v2.0.5) (2023-11-16)
2
+
3
+
4
+ ### Bug Fixes
5
+
6
+ * **jpegrloader:** rename JPEGRLoader to HDRJPEGLoader, old name kept for compatibility ([ac6e386](https://github.com/MONOGRID/gainmap-js/commit/ac6e38610886b7adec5806a7ad301bff1ec00d62))
7
+
1
8
  ## [2.0.4](https://github.com/MONOGRID/gainmap-js/compare/v2.0.3...v2.0.4) (2023-11-15)
2
9
 
3
10
 
package/README.md CHANGED
@@ -37,7 +37,7 @@ $ npm install @monogrid/gainmap-js three
37
37
  > * The **gain map**. This is a secondary “image” embedded in the file. It is not a real image, but rather contains data to convert each pixel from the base image into the other (SDR or HDR) version of the image.
38
38
  >* Gain map **metadata**. This tells the browser how the gain map is encoded as well as critical information to optimize rendering on any display.
39
39
 
40
- Please note that Google [is adopting the gain map technology in Android 14](https://support.google.com/photos/answer/14159275) but its naming of the technology refers to it as **Ultra HDR Image Format** and a JPEG file with embedded gain map is called `JPEGR` in their terminology.
40
+ Please note that Google [is adopting the gain map technology in Android 14](https://support.google.com/photos/answer/14159275) but its naming of the technology refers to it as **Ultra HDR Image Format** and a JPEG file with embedded gain map is [apparently called JPEGR](https://github.com/google/libultrahdr/blob/3a3a752a5da0b2304b1b6de0ef383bbe41256a67/lib/jpegr.h#L28C16-L28C21) in their terminology, we call it `HDRJPEG` for the moment.
41
41
 
42
42
  ## API
43
43
 
@@ -63,7 +63,7 @@ The disadvantages are:
63
63
  * Photo sharing websites and/or services (i.e. sharing with Slack) will likely strip the Gain map metadata and the HDR information will be lost, leaving you with only the SDR Representation.
64
64
 
65
65
  ```ts
66
- import { JPEGRLoader } from '@monogrid/gainmap-js'
66
+ import { HDRJPGLoader } from '@monogrid/gainmap-js'
67
67
  import {
68
68
  EquirectangularReflectionMapping,
69
69
  LinearFilter,
@@ -77,7 +77,7 @@ import {
77
77
 
78
78
  const renderer = new WebGLRenderer()
79
79
 
80
- const loader = new JPEGRLoader(renderer)
80
+ const loader = new HDRJPGLoader(renderer)
81
81
 
82
82
  const result = loader.load('gainmap.jpeg')
83
83
  // `result` can be used to populate a Texture
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -74,10 +74,10 @@ const canReadPixels = (type, renderer, camera) => {
74
74
  return _canReadPixelsResult;
75
75
  };
76
76
  /**
77
- * Utility structure used for rendering a texture with a material
77
+ * Utility class used for rendering a texture with a material
78
78
  *
79
- * @category General
80
- * @group General
79
+ * @category Core
80
+ * @group Core
81
81
  */
82
82
  class QuadRenderer {
83
83
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -1,14 +1,16 @@
1
1
  import { ByteType, ColorSpace, DataTexture, FloatType, HalfFloatType, IntType, Material, ShortType, TextureDataType, UnsignedByteType, UnsignedIntType, WebGLRenderer, WebGLRenderTarget } from 'three';
2
2
  /**
3
- * @category General
4
- * @group General
3
+ * Utility Type that translates `three` texture types to their TypedArray counterparts.
4
+ *
5
+ * @category Utility
6
+ * @group Utility
5
7
  */
6
8
  export type TextureDataTypeToBufferType<TType extends TextureDataType> = TType extends typeof UnsignedByteType ? Uint8ClampedArray : TType extends typeof HalfFloatType ? Uint16Array : TType extends typeof UnsignedIntType ? Uint32Array : TType extends typeof ByteType ? Int8Array : TType extends typeof ShortType ? Int16Array : TType extends typeof IntType ? Int32Array : TType extends typeof FloatType ? Float32Array : never;
7
9
  /**
8
- * Utility structure used for rendering a texture with a material
10
+ * Utility class used for rendering a texture with a material
9
11
  *
10
- * @category General
11
- * @group General
12
+ * @category Core
13
+ * @group Core
12
14
  */
13
15
  export declare class QuadRenderer<TType extends TextureDataType, TMaterial extends Material> {
14
16
  private _renderer;
@@ -5,8 +5,8 @@ import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
5
5
  /**
6
6
  * Utility function to obtain a `DataTexture` from various input formats
7
7
  *
8
- * @category General
9
- * @group General
8
+ * @category Utility
9
+ * @group Utility
10
10
  *
11
11
  * @param image
12
12
  * @returns
@@ -0,0 +1,3 @@
1
+ export * from './get-data-texture';
2
+ export * from './QuadRenderer';
3
+ export * from './types';
@@ -2,8 +2,8 @@
2
2
  * This is the Metadata stored in an encoded Gainmap which is used
3
3
  * to decode it and return an HDR image
4
4
  *
5
- * @category Gainmap Specifications
6
- * @group Gainmap Specifications
5
+ * @category Specs
6
+ * @group Specs
7
7
  */
8
8
  export type GainMapMetadata = {
9
9
  /**
@@ -4,8 +4,8 @@ import { DecodeParameters } from './types';
4
4
  /**
5
5
  * Decodes a gain map using a WebGLRenderTarget
6
6
  *
7
- * @category Decoding
8
- * @group Decoding
7
+ * @category Decoding Functions
8
+ * @group Decoding Functions
9
9
  * @example
10
10
  * import { decode } from '@monogrid/gainmap-js'
11
11
  * import {
@@ -1,7 +1,22 @@
1
1
  /**
2
+ * Extracts XMP Metadata and the gain map recovery image
3
+ * from a single JPEG file.
2
4
  *
3
- * @param jpegFile
4
- * @returns
5
+ * @category Decoding Functions
6
+ * @group Decoding Functions
7
+ * @param jpegFile an `Uint8Array` containing and encoded JPEG file
8
+ * @returns an sdr `Uint8Array` compressed in JPEG, a gainMap `Uint8Array` compressed in JPEG and the XMP parsed XMP metadata
9
+ * @throws Error if XMP Metadata is not found
10
+ * @throws Error if Gain map image is not found
11
+ * @example
12
+ * import { FileLoader } from 'three'
13
+ * import { extractGainmapFromJPEG } from '@monogrid/gainmap-js'
14
+ *
15
+ * const jpegFile = await new FileLoader()
16
+ * .setResponseType('arraybuffer')
17
+ * .loadAsync('image.jpg')
18
+ *
19
+ * const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
5
20
  */
6
21
  export declare const extractGainmapFromJPEG: (jpegFile: Uint8Array) => Promise<{
7
22
  sdr: Uint8Array;
@@ -3,6 +3,7 @@ export * from '../core/types';
3
3
  export * from './decode';
4
4
  export * from './extract';
5
5
  export * from './loaders/GainMapLoader';
6
- export * from './loaders/JPEGRLoader';
6
+ export * from './loaders/HDRJPGLoader';
7
+ export { HDRJPGLoader as JPEGRLoader } from './loaders/HDRJPGLoader';
7
8
  export * from './materials/GainMapDecoderMaterial';
8
9
  export * from './types';
@@ -45,7 +45,6 @@ import { LoaderBase } from './LoaderBase';
45
45
  * scene.background.mapping = EquirectangularReflectionMapping
46
46
  * scene.background.minFilter = LinearFilter
47
47
  *
48
- *
49
48
  */
50
49
  export declare class GainMapLoader extends LoaderBase<[string, string, string]> {
51
50
  /**
@@ -56,12 +55,10 @@ export declare class GainMapLoader extends LoaderBase<[string, string, string]>
56
55
  *
57
56
  * useful for webp gain maps
58
57
  *
59
- * @param sdrUrl
60
- * @param gainMapUrl
61
- * @param metadataUrl
62
- * @param onLoad
63
- * @param onProgress
64
- * @param onError
58
+ * @param urls An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
59
+ * @param onLoad Load complete callback, will receive the result
60
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
61
+ * @param onError Error callback
65
62
  * @returns
66
63
  */
67
64
  load([sdrUrl, gainMapUrl, metadataUrl]: [string, string, string], onLoad?: (data: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>;
@@ -1,6 +1,6 @@
1
1
  import { HalfFloatType } from 'three';
2
2
  import { QuadRenderer } from '../../core/QuadRenderer';
3
- import { GainMapDecoderMaterial } from '../../decode/materials/GainMapDecoderMaterial';
3
+ import { GainMapDecoderMaterial } from '../materials/GainMapDecoderMaterial';
4
4
  import { LoaderBase } from './LoaderBase';
5
5
  /**
6
6
  * A Three.js Loader for a JPEG with embedded gainmap metadata.
@@ -47,13 +47,14 @@ import { LoaderBase } from './LoaderBase';
47
47
 
48
48
  *
49
49
  */
50
- export declare class JPEGRLoader extends LoaderBase<string> {
50
+ export declare class HDRJPGLoader extends LoaderBase<string> {
51
51
  /**
52
+ * Loads a JPEGR Image
52
53
  *
53
- * @param url
54
- * @param onLoad
55
- * @param onProgress
56
- * @param onError
54
+ * @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
55
+ * @param onLoad Load complete callback, will receive the result
56
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
57
+ * @param onError Error callback
57
58
  * @returns
58
59
  */
59
60
  load(url: string, onLoad?: (data: QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>) => void, onProgress?: (event: ProgressEvent) => void, onError?: (err: unknown) => void): QuadRenderer<typeof HalfFloatType, GainMapDecoderMaterial>;
@@ -1,10 +1,10 @@
1
1
  import { type Texture, type WebGLRenderer } from 'three';
2
2
  import { type GainMapMetadata } from '../core/types';
3
3
  /**
4
- * Parameters for decoding a Gainmap
4
+ * Necessary parameters for decoding a Gainmap
5
5
  *
6
- * @category Gainmap Specifications
7
- * @group Gainmap Specifications
6
+ * @category Specs
7
+ * @group Specs
8
8
  */
9
9
  export type GainmapDecodingParameters = {
10
10
  /**
@@ -19,8 +19,8 @@ export type GainmapDecodingParameters = {
19
19
  maxDisplayBoost: number;
20
20
  };
21
21
  /**
22
- * @category Decoding
23
- * @group Decoding
22
+ * @category Decoding Functions
23
+ * @group Decoding Functions
24
24
  */
25
25
  export type DecodeParameters = {
26
26
  /**
package/dist/decode.js CHANGED
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { Q as QuadRenderer } from './QuadRenderer-lU9EAEKl.js';
6
+ import { Q as QuadRenderer } from './QuadRenderer-bEJB0XFk.js';
7
7
  import { ShaderMaterial, Vector3, NoBlending, SRGBColorSpace, NoColorSpace, HalfFloatType, Loader, Texture, UVMapping, ClampToEdgeWrapping, LinearFilter, LinearMipMapLinearFilter, RGBAFormat, UnsignedByteType, FileLoader } from 'three';
8
8
 
9
9
  const vertexShader = /* glsl */ `
@@ -152,8 +152,8 @@ class GainMapDecoderMaterial extends ShaderMaterial {
152
152
  /**
153
153
  * Decodes a gain map using a WebGLRenderTarget
154
154
  *
155
- * @category Decoding
156
- * @group Decoding
155
+ * @category Decoding Functions
156
+ * @group Decoding Functions
157
157
  * @example
158
158
  * import { decode } from '@monogrid/gainmap-js'
159
159
  * import {
@@ -215,6 +215,8 @@ const decode = (params) => {
215
215
  gainMap.needsUpdate = true;
216
216
  const material = new GainMapDecoderMaterial(Object.assign(Object.assign({}, params), { sdr,
217
217
  gainMap }));
218
+ // TODO: three types are generic, eslint complains here, see how we can solve
219
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
218
220
  const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, HalfFloatType, NoColorSpace, material, renderer);
219
221
  try {
220
222
  quadRenderer.render();
@@ -466,9 +468,24 @@ class MPFExtractor {
466
468
  }
467
469
 
468
470
  /**
471
+ * Extracts XMP Metadata and the gain map recovery image
472
+ * from a single JPEG file.
473
+ *
474
+ * @category Decoding Functions
475
+ * @group Decoding Functions
476
+ * @param jpegFile an `Uint8Array` containing and encoded JPEG file
477
+ * @returns an sdr `Uint8Array` compressed in JPEG, a gainMap `Uint8Array` compressed in JPEG and the XMP parsed XMP metadata
478
+ * @throws Error if XMP Metadata is not found
479
+ * @throws Error if Gain map image is not found
480
+ * @example
481
+ * import { FileLoader } from 'three'
482
+ * import { extractGainmapFromJPEG } from '@monogrid/gainmap-js'
469
483
  *
470
- * @param jpegFile
471
- * @returns
484
+ * const jpegFile = await new FileLoader()
485
+ * .setResponseType('arraybuffer')
486
+ * .loadAsync('image.jpg')
487
+ *
488
+ * const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
472
489
  */
473
490
  const extractGainmapFromJPEG = async (jpegFile) => {
474
491
  const metadata = extractXMP(jpegFile);
@@ -626,7 +643,6 @@ class LoaderBase extends Loader {
626
643
  * scene.background.mapping = EquirectangularReflectionMapping
627
644
  * scene.background.minFilter = LinearFilter
628
645
  *
629
- *
630
646
  */
631
647
  class GainMapLoader extends LoaderBase {
632
648
  /**
@@ -637,12 +653,10 @@ class GainMapLoader extends LoaderBase {
637
653
  *
638
654
  * useful for webp gain maps
639
655
  *
640
- * @param sdrUrl
641
- * @param gainMapUrl
642
- * @param metadataUrl
643
- * @param onLoad
644
- * @param onProgress
645
- * @param onError
656
+ * @param urls An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
657
+ * @param onLoad Load complete callback, will receive the result
658
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
659
+ * @param onError Error callback
646
660
  * @returns
647
661
  */
648
662
  load([sdrUrl, gainMapUrl, metadataUrl], onLoad, onProgress, onError) {
@@ -684,7 +698,7 @@ class GainMapLoader extends LoaderBase {
684
698
  if (typeof buffer === 'string')
685
699
  throw new Error('Invalid sdr buffer');
686
700
  sdr = buffer;
687
- loadCheck();
701
+ await loadCheck();
688
702
  }, (e) => {
689
703
  sdrLengthComputable = e.lengthComputable;
690
704
  sdrLoaded = e.loaded;
@@ -700,7 +714,7 @@ class GainMapLoader extends LoaderBase {
700
714
  if (typeof buffer === 'string')
701
715
  throw new Error('Invalid gainmap buffer');
702
716
  gainMap = buffer;
703
- loadCheck();
717
+ await loadCheck();
704
718
  }, (e) => {
705
719
  gainMapLengthComputable = e.lengthComputable;
706
720
  gainMapLoaded = e.loaded;
@@ -715,8 +729,10 @@ class GainMapLoader extends LoaderBase {
715
729
  metadataLoader.load(metadataUrl, async (json) => {
716
730
  if (typeof json !== 'string')
717
731
  throw new Error('Invalid metadata string');
732
+ // TODO: implement check on JSON file and remove this eslint disable
733
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
718
734
  metadata = JSON.parse(json);
719
- loadCheck();
735
+ await loadCheck();
720
736
  }, (e) => {
721
737
  metadataLengthComputable = e.lengthComputable;
722
738
  metadataLoaded = e.loaded;
@@ -772,13 +788,14 @@ class GainMapLoader extends LoaderBase {
772
788
 
773
789
  *
774
790
  */
775
- class JPEGRLoader extends LoaderBase {
791
+ class HDRJPGLoader extends LoaderBase {
776
792
  /**
793
+ * Loads a JPEGR Image
777
794
  *
778
- * @param url
779
- * @param onLoad
780
- * @param onProgress
781
- * @param onError
795
+ * @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
796
+ * @param onLoad Load complete callback, will receive the result
797
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
798
+ * @param onError Error callback
782
799
  * @returns
783
800
  */
784
801
  load(url, onLoad, onProgress, onError) {
@@ -801,4 +818,4 @@ class JPEGRLoader extends LoaderBase {
801
818
  }
802
819
  }
803
820
 
804
- export { GainMapDecoderMaterial, GainMapLoader, JPEGRLoader, QuadRenderer, decode, extractGainmapFromJPEG };
821
+ export { GainMapDecoderMaterial, GainMapLoader, HDRJPGLoader, HDRJPGLoader as JPEGRLoader, QuadRenderer, decode, extractGainmapFromJPEG };
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -78,10 +78,10 @@
78
78
  return _canReadPixelsResult;
79
79
  };
80
80
  /**
81
- * Utility structure used for rendering a texture with a material
81
+ * Utility class used for rendering a texture with a material
82
82
  *
83
- * @category General
84
- * @group General
83
+ * @category Core
84
+ * @group Core
85
85
  */
86
86
  class QuadRenderer {
87
87
  /**
@@ -385,8 +385,8 @@ void main() {
385
385
  /**
386
386
  * Decodes a gain map using a WebGLRenderTarget
387
387
  *
388
- * @category Decoding
389
- * @group Decoding
388
+ * @category Decoding Functions
389
+ * @group Decoding Functions
390
390
  * @example
391
391
  * import { decode } from '@monogrid/gainmap-js'
392
392
  * import {
@@ -448,6 +448,8 @@ void main() {
448
448
  gainMap.needsUpdate = true;
449
449
  const material = new GainMapDecoderMaterial(Object.assign(Object.assign({}, params), { sdr,
450
450
  gainMap }));
451
+ // TODO: three types are generic, eslint complains here, see how we can solve
452
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-argument, @typescript-eslint/no-unsafe-member-access
451
453
  const quadRenderer = new QuadRenderer(sdr.image.width, sdr.image.height, three.HalfFloatType, three.NoColorSpace, material, renderer);
452
454
  try {
453
455
  quadRenderer.render();
@@ -699,9 +701,24 @@ void main() {
699
701
  }
700
702
 
701
703
  /**
704
+ * Extracts XMP Metadata and the gain map recovery image
705
+ * from a single JPEG file.
702
706
  *
703
- * @param jpegFile
704
- * @returns
707
+ * @category Decoding Functions
708
+ * @group Decoding Functions
709
+ * @param jpegFile an `Uint8Array` containing and encoded JPEG file
710
+ * @returns an sdr `Uint8Array` compressed in JPEG, a gainMap `Uint8Array` compressed in JPEG and the XMP parsed XMP metadata
711
+ * @throws Error if XMP Metadata is not found
712
+ * @throws Error if Gain map image is not found
713
+ * @example
714
+ * import { FileLoader } from 'three'
715
+ * import { extractGainmapFromJPEG } from '@monogrid/gainmap-js'
716
+ *
717
+ * const jpegFile = await new FileLoader()
718
+ * .setResponseType('arraybuffer')
719
+ * .loadAsync('image.jpg')
720
+ *
721
+ * const { sdr, gainMap, metadata } = extractGainmapFromJPEG(jpegFile)
705
722
  */
706
723
  const extractGainmapFromJPEG = async (jpegFile) => {
707
724
  const metadata = extractXMP(jpegFile);
@@ -859,7 +876,6 @@ void main() {
859
876
  * scene.background.mapping = EquirectangularReflectionMapping
860
877
  * scene.background.minFilter = LinearFilter
861
878
  *
862
- *
863
879
  */
864
880
  class GainMapLoader extends LoaderBase {
865
881
  /**
@@ -870,12 +886,10 @@ void main() {
870
886
  *
871
887
  * useful for webp gain maps
872
888
  *
873
- * @param sdrUrl
874
- * @param gainMapUrl
875
- * @param metadataUrl
876
- * @param onLoad
877
- * @param onProgress
878
- * @param onError
889
+ * @param urls An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
890
+ * @param onLoad Load complete callback, will receive the result
891
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
892
+ * @param onError Error callback
879
893
  * @returns
880
894
  */
881
895
  load([sdrUrl, gainMapUrl, metadataUrl], onLoad, onProgress, onError) {
@@ -917,7 +931,7 @@ void main() {
917
931
  if (typeof buffer === 'string')
918
932
  throw new Error('Invalid sdr buffer');
919
933
  sdr = buffer;
920
- loadCheck();
934
+ await loadCheck();
921
935
  }, (e) => {
922
936
  sdrLengthComputable = e.lengthComputable;
923
937
  sdrLoaded = e.loaded;
@@ -933,7 +947,7 @@ void main() {
933
947
  if (typeof buffer === 'string')
934
948
  throw new Error('Invalid gainmap buffer');
935
949
  gainMap = buffer;
936
- loadCheck();
950
+ await loadCheck();
937
951
  }, (e) => {
938
952
  gainMapLengthComputable = e.lengthComputable;
939
953
  gainMapLoaded = e.loaded;
@@ -948,8 +962,10 @@ void main() {
948
962
  metadataLoader.load(metadataUrl, async (json) => {
949
963
  if (typeof json !== 'string')
950
964
  throw new Error('Invalid metadata string');
965
+ // TODO: implement check on JSON file and remove this eslint disable
966
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
951
967
  metadata = JSON.parse(json);
952
- loadCheck();
968
+ await loadCheck();
953
969
  }, (e) => {
954
970
  metadataLengthComputable = e.lengthComputable;
955
971
  metadataLoaded = e.loaded;
@@ -1005,13 +1021,14 @@ void main() {
1005
1021
 
1006
1022
  *
1007
1023
  */
1008
- class JPEGRLoader extends LoaderBase {
1024
+ class HDRJPGLoader extends LoaderBase {
1009
1025
  /**
1026
+ * Loads a JPEGR Image
1010
1027
  *
1011
- * @param url
1012
- * @param onLoad
1013
- * @param onProgress
1014
- * @param onError
1028
+ * @param url An array in the form of [sdr.jpg, gainmap.jpg, metadata.json]
1029
+ * @param onLoad Load complete callback, will receive the result
1030
+ * @param onProgress Progress callback, will receive a {@link ProgressEvent}
1031
+ * @param onError Error callback
1015
1032
  * @returns
1016
1033
  */
1017
1034
  load(url, onLoad, onProgress, onError) {
@@ -1036,7 +1053,8 @@ void main() {
1036
1053
 
1037
1054
  exports.GainMapDecoderMaterial = GainMapDecoderMaterial;
1038
1055
  exports.GainMapLoader = GainMapLoader;
1039
- exports.JPEGRLoader = JPEGRLoader;
1056
+ exports.HDRJPGLoader = HDRJPGLoader;
1057
+ exports.JPEGRLoader = HDRJPGLoader;
1040
1058
  exports.QuadRenderer = QuadRenderer;
1041
1059
  exports.decode = decode;
1042
1060
  exports.extractGainmapFromJPEG = extractGainmapFromJPEG;
@@ -4,8 +4,8 @@ import { LogLuv } from 'three/examples/jsm/loaders/LogLuvLoader';
4
4
  import { RGBE } from 'three/examples/jsm/loaders/RGBELoader';
5
5
  /**
6
6
  *
7
- * @category Encoding Functions
8
- * @group Encoding Functions
7
+ * @category Utility
8
+ * @group Utility
9
9
  *
10
10
  * @param srcTex
11
11
  * @param mode
@@ -5,8 +5,8 @@ import { type RGBE } from 'three/examples/jsm/loaders/RGBELoader';
5
5
  import { WorkerInterfaceImplementation } from '../worker-types';
6
6
  /**
7
7
  * Parameters used by content Creators in order to create a GainMap
8
- * @category Gainmap Specifications
9
- * @group Gainmap Specifications
8
+ * @category Specs
9
+ * @group Specs
10
10
  */
11
11
  export type GainmapEncodingParameters = {
12
12
  /**
@@ -93,15 +93,15 @@ export type CompressionMimeType = 'image/png' | 'image/jpeg' | 'image/webp';
93
93
  /**
94
94
  * Accepted HDR image buffers, definitions coming from the THREE.js Library types
95
95
  *
96
- * @category General
97
- * @group General
96
+ * @category Utility
97
+ * @group Utility
98
98
  */
99
99
  export type HDRRawImageBuffer = EXR['data'] | RGBE['data'] | LogLuv['data'];
100
100
  /**
101
101
  * Raw HDR image data
102
102
  *
103
- * @category General
104
- * @group General
103
+ * @category Utility
104
+ * @group Utility
105
105
  */
106
106
  export type HDRRawImage = {
107
107
  data: HDRRawImageBuffer;
package/dist/encode.js CHANGED
@@ -1,17 +1,17 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { c as compress } from './compress-RL9UE9ww.js';
6
+ import { c as compress } from './compress-aBsBfoFB.js';
7
7
  import { DataTexture, RGBAFormat, UVMapping, RepeatWrapping, LinearFilter, NoColorSpace, ShaderMaterial, Vector3, NoBlending, UnsignedByteType, ACESFilmicToneMapping, LinearToneMapping, CineonToneMapping, ReinhardToneMapping, SRGBColorSpace, Vector2, WebGLRenderTarget, NearestFilter, ClampToEdgeWrapping, FloatType, DataUtils } from 'three';
8
- import { Q as QuadRenderer } from './QuadRenderer-lU9EAEKl.js';
8
+ import { Q as QuadRenderer } from './QuadRenderer-bEJB0XFk.js';
9
9
 
10
10
  /**
11
11
  * Utility function to obtain a `DataTexture` from various input formats
12
12
  *
13
- * @category General
14
- * @group General
13
+ * @category Utility
14
+ * @group Utility
15
15
  *
16
16
  * @param image
17
17
  * @returns
@@ -645,8 +645,8 @@ void main() {
645
645
  `;
646
646
  /**
647
647
  *
648
- * @category Encoding Functions
649
- * @group Encoding Functions
648
+ * @category Utility
649
+ * @group Utility
650
650
  *
651
651
  * @param srcTex
652
652
  * @param mode
@@ -699,7 +699,9 @@ const findTextureMinMax = (image, mode = 'max', renderer) => {
699
699
  quadRenderer.renderTarget = fbi;
700
700
  quadRenderer.render();
701
701
  mat.uniforms.map.value = fbi.texture;
702
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
702
703
  mat.uniforms.u_srcResolution.value.x = w;
704
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
703
705
  mat.uniforms.u_srcResolution.value.y = h;
704
706
  });
705
707
  const out = quadRenderer.toArray();
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -88,8 +88,8 @@
88
88
  /**
89
89
  * Utility function to obtain a `DataTexture` from various input formats
90
90
  *
91
- * @category General
92
- * @group General
91
+ * @category Utility
92
+ * @group Utility
93
93
  *
94
94
  * @param image
95
95
  * @returns
@@ -183,10 +183,10 @@
183
183
  return _canReadPixelsResult;
184
184
  };
185
185
  /**
186
- * Utility structure used for rendering a texture with a material
186
+ * Utility class used for rendering a texture with a material
187
187
  *
188
- * @category General
189
- * @group General
188
+ * @category Core
189
+ * @group Core
190
190
  */
191
191
  class QuadRenderer {
192
192
  /**
@@ -953,8 +953,8 @@ void main() {
953
953
  `;
954
954
  /**
955
955
  *
956
- * @category Encoding Functions
957
- * @group Encoding Functions
956
+ * @category Utility
957
+ * @group Utility
958
958
  *
959
959
  * @param srcTex
960
960
  * @param mode
@@ -1007,7 +1007,9 @@ void main() {
1007
1007
  quadRenderer.renderTarget = fbi;
1008
1008
  quadRenderer.render();
1009
1009
  mat.uniforms.map.value = fbi.texture;
1010
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1010
1011
  mat.uniforms.u_srcResolution.value.x = w;
1012
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
1011
1013
  mat.uniforms.u_srcResolution.value.y = h;
1012
1014
  });
1013
1015
  const out = quadRenderer.toArray();
@@ -1,8 +1,8 @@
1
1
  import { MainModule } from '../../libultrahdr-wasm/build/libultrahdr';
2
2
  /**
3
3
  * Instances the WASM module and returns it, only one module will be created upon multiple calls.
4
- * @category General
5
- * @group General
4
+ * @category WASM
5
+ * @group WASM
6
6
  *
7
7
  * @returns
8
8
  */
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -6533,8 +6533,8 @@ var libultrahdr = Module;
6533
6533
  let library;
6534
6534
  /**
6535
6535
  * Instances the WASM module and returns it, only one module will be created upon multiple calls.
6536
- * @category General
6537
- * @group General
6536
+ * @category WASM
6537
+ * @group WASM
6538
6538
  *
6539
6539
  * @returns
6540
6540
  */
@@ -6603,7 +6603,7 @@ const decodeJPEGMetadata = async (file) => {
6603
6603
  const lib = await getLibrary();
6604
6604
  const result = lib.extractJpegR(file, file.length);
6605
6605
  if (!result.success)
6606
- throw new Error(result.errorMessage);
6606
+ throw new Error(`${result.errorMessage}`);
6607
6607
  const parser = new DOMParser();
6608
6608
  const xmlDocument = parser.parseFromString(result.metadata, 'text/xml');
6609
6609
  const description = xmlDocument.getElementsByTagName('rdf:Description')[0];
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -6540,8 +6540,8 @@
6540
6540
  let library;
6541
6541
  /**
6542
6542
  * Instances the WASM module and returns it, only one module will be created upon multiple calls.
6543
- * @category General
6544
- * @group General
6543
+ * @category WASM
6544
+ * @group WASM
6545
6545
  *
6546
6546
  * @returns
6547
6547
  */
@@ -6610,7 +6610,7 @@
6610
6610
  const lib = await getLibrary();
6611
6611
  const result = lib.extractJpegR(file, file.length);
6612
6612
  if (!result.success)
6613
- throw new Error(result.errorMessage);
6613
+ throw new Error(`${result.errorMessage}`);
6614
6614
  const parser = new DOMParser();
6615
6615
  const xmlDocument = parser.parseFromString(result.metadata, 'text/xml');
6616
6616
  const description = xmlDocument.getElementsByTagName('rdf:Description')[0];
@@ -1,9 +1,9 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-n2Ng5lYw.js';
6
+ import { c as commonjsGlobal, g as getDefaultExportFromCjs } from './_commonjsHelpers-bdHH9bEd.js';
7
7
 
8
8
  var lib$1;
9
9
  var hasRequiredLib$1;
@@ -474,6 +474,7 @@ var PromiseWorker$1 = /*@__PURE__*/getDefaultExportFromCjs(promiseWorkerTransfer
474
474
  * @returns
475
475
  */
476
476
  const getPromiseWorker = (worker) => {
477
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
477
478
  return new PromiseWorker$1(worker);
478
479
  };
479
480
  /**
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -484,6 +484,7 @@
484
484
  * @returns
485
485
  */
486
486
  const getPromiseWorker = (worker) => {
487
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
487
488
  return new PromiseWorker$1(worker);
488
489
  };
489
490
  /**
package/dist/worker.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
6
- import { g as getDefaultExportFromCjs } from './_commonjsHelpers-n2Ng5lYw.js';
7
- import { c as compress } from './compress-RL9UE9ww.js';
6
+ import { g as getDefaultExportFromCjs } from './_commonjsHelpers-bdHH9bEd.js';
7
+ import { c as compress } from './compress-aBsBfoFB.js';
8
8
 
9
9
  var isPromise$2 = {exports: {}};
10
10
 
@@ -113,6 +113,7 @@ const _compress = async (message, withTransferList) => {
113
113
  const result = await compress(message.payload);
114
114
  return withTransferList(Object.assign(Object.assign({}, result), { source: message.payload.source instanceof ImageData ? message.payload.source.data : new Uint8ClampedArray(message.payload.source) }), [result.data.buffer, message.payload.source instanceof ImageData ? message.payload.source.data.buffer : message.payload.source.buffer]);
115
115
  };
116
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
116
117
  registerPromiseWorker$1(async (message, withTransferList) => {
117
118
  switch (message.type) {
118
119
  // case 'encode-gainmap-buffers':
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @monogrid/gainmap-js v2.0.3
2
+ * @monogrid/gainmap-js v2.0.4
3
3
  * With ❤️, by MONOGRID <hello@mono-grid.com>
4
4
  */
5
5
 
@@ -195,6 +195,7 @@
195
195
  const result = await compress(message.payload);
196
196
  return withTransferList(Object.assign(Object.assign({}, result), { source: message.payload.source instanceof ImageData ? message.payload.source.data : new Uint8ClampedArray(message.payload.source) }), [result.data.buffer, message.payload.source instanceof ImageData ? message.payload.source.data.buffer : message.payload.source.buffer]);
197
197
  };
198
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-call
198
199
  registerPromiseWorker$1(async (message, withTransferList) => {
199
200
  switch (message.type) {
200
201
  // case 'encode-gainmap-buffers':
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@monogrid/gainmap-js",
3
- "version": "2.0.4",
3
+ "version": "2.0.5",
4
4
  "description": "A Javascript (TypeScript) Port of Adobe Gainmap Technology for storing HDR Images using an SDR Image + a gain map",
5
5
  "homepage": "https://github.com/MONOGRID/gainmap-js#readme",
6
6
  "repository": {
@@ -124,6 +124,7 @@
124
124
  "cz-conventional-changelog": "^3.3.0",
125
125
  "eslint": "^8.53.0",
126
126
  "eslint-config-standard": "^17.0.0",
127
+ "eslint-plugin-html": "^7.1.0",
127
128
  "eslint-plugin-import": "^2.29.0",
128
129
  "eslint-plugin-jest-extended": "^2.0.0",
129
130
  "eslint-plugin-n": "^16.3.1",