gb-image-decoder 0.0.1 → 0.0.3

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/dist/index.cjs CHANGED
@@ -592,13 +592,19 @@ class RGBNDecoder {
592
592
  return canvas;
593
593
  }
594
594
  maxTiles() {
595
- return Math.max(...channels.map((key) => this.channels[key].tiles?.length || 0));
595
+ return channels.reduce((acc, key) => {
596
+ const channel = this.channels[key];
597
+ return Math.max(acc, channel.tiles?.length || 0);
598
+ }, 0);
596
599
  }
597
600
  getHeight() {
598
601
  return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() / TILES_PER_LINE);
599
602
  }
600
603
  }
601
604
 
605
+ const maxTiles = (rgbnTiles) => Math.max(...channels.map((key) => rgbnTiles[key]?.length || 0));
606
+
607
+ exports.BW_PALETTE = BW_PALETTE;
602
608
  exports.BlendMode = BlendMode;
603
609
  exports.Decoder = Decoder;
604
610
  exports.ExportFrameMode = ExportFrameMode;
@@ -606,4 +612,5 @@ exports.RGBNDecoder = RGBNDecoder;
606
612
  exports.blendModeNewName = blendModeNewName;
607
613
  exports.decodeTile = decodeTile;
608
614
  exports.getRGBValue = getRGBValue;
615
+ exports.maxTiles = maxTiles;
609
616
  exports.tileIndexIsPartOfFrame = tileIndexIsPartOfFrame;
package/dist/index.d.cts CHANGED
@@ -128,4 +128,8 @@ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockF
128
128
 
129
129
  declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
130
 
131
- export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
131
+ declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
132
+
133
+ declare const BW_PALETTE: number[];
134
+
135
+ export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
package/dist/index.d.mts CHANGED
@@ -128,4 +128,8 @@ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockF
128
128
 
129
129
  declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
130
 
131
- export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
131
+ declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
132
+
133
+ declare const BW_PALETTE: number[];
134
+
135
+ export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
package/dist/index.d.ts CHANGED
@@ -128,4 +128,8 @@ declare const getRGBValue: ({ pixels, index, tileIndex, handleExportFrame, lockF
128
128
 
129
129
  declare const tileIndexIsPartOfFrame: (tileIndex: number, handleExportFrame?: ExportFrameMode) => boolean;
130
130
 
131
- export { type BWPalette, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
131
+ declare const maxTiles: (rgbnTiles: RGBNTiles) => number;
132
+
133
+ declare const BW_PALETTE: number[];
134
+
135
+ export { type BWPalette, BW_PALETTE, BlendMode, type ChangedTile, type Channel, type Channels, Decoder, ExportFrameMode, type IndexedTilePixels, RGBNDecoder, type RGBNPalette, type RGBNTiles, type RGBValue, type ScaledCanvasSize, type SourceCanvases, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
package/dist/index.mjs CHANGED
@@ -590,11 +590,16 @@ class RGBNDecoder {
590
590
  return canvas;
591
591
  }
592
592
  maxTiles() {
593
- return Math.max(...channels.map((key) => this.channels[key].tiles?.length || 0));
593
+ return channels.reduce((acc, key) => {
594
+ const channel = this.channels[key];
595
+ return Math.max(acc, channel.tiles?.length || 0);
596
+ }, 0);
594
597
  }
595
598
  getHeight() {
596
599
  return TILE_PIXEL_HEIGHT * Math.ceil(this.maxTiles() / TILES_PER_LINE);
597
600
  }
598
601
  }
599
602
 
600
- export { BlendMode, Decoder, ExportFrameMode, RGBNDecoder, blendModeNewName, decodeTile, getRGBValue, tileIndexIsPartOfFrame };
603
+ const maxTiles = (rgbnTiles) => Math.max(...channels.map((key) => rgbnTiles[key]?.length || 0));
604
+
605
+ export { BW_PALETTE, BlendMode, Decoder, ExportFrameMode, RGBNDecoder, blendModeNewName, decodeTile, getRGBValue, maxTiles, tileIndexIsPartOfFrame };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gb-image-decoder",
3
- "version": "0.0.1",
3
+ "version": "0.0.3",
4
4
  "description": "Decoder classes for GameBoy images",
5
5
  "repository": "",
6
6
  "license": "MIT",