@vitessce/image-utils 3.6.17 → 3.7.0

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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
2
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -119133,6 +119133,8 @@ const PIXELATED_TEXTURE_PARAMETERS = {
119133
119133
  [GL$1.TEXTURE_WRAP_T]: GL$1.CLAMP_TO_EDGE
119134
119134
  };
119135
119135
  const GLSL_COLORMAPS = [
119136
+ // NOTE: the ordering of these is important,
119137
+ // as the shader code in bitmask-layer-beta-shaders hardcodes their indices.
119136
119138
  "plasma",
119137
119139
  "viridis",
119138
119140
  "jet",
@@ -120225,22 +120227,22 @@ function addDecoder(cases, importFn) {
120225
120227
  }
120226
120228
  cases.forEach((c) => registry$1.set(c, importFn));
120227
120229
  }
120228
- addDecoder([void 0, 1], () => import("./raw-CU40fHlB.js").then((m) => m.default));
120229
- addDecoder(5, () => import("./lzw-Cx8CUZ3I.js").then((m) => m.default));
120230
+ addDecoder([void 0, 1], () => import("./raw-0Zj-wT7y.js").then((m) => m.default));
120231
+ addDecoder(5, () => import("./lzw-CKdFEosV.js").then((m) => m.default));
120230
120232
  addDecoder(6, () => {
120231
120233
  throw new Error("old style JPEG compression is not supported.");
120232
120234
  });
120233
- addDecoder(7, () => import("./jpeg-IHVyFDaf.js").then((m) => m.default));
120234
- addDecoder([8, 32946], () => import("./deflate-QFiR_eHt.js").then((m) => m.default));
120235
- addDecoder(32773, () => import("./packbits-DhtrR3HF.js").then((m) => m.default));
120235
+ addDecoder(7, () => import("./jpeg-Cr-xD78T.js").then((m) => m.default));
120236
+ addDecoder([8, 32946], () => import("./deflate-Dd1C9gct.js").then((m) => m.default));
120237
+ addDecoder(32773, () => import("./packbits-dEr5HOPP.js").then((m) => m.default));
120236
120238
  addDecoder(
120237
120239
  34887,
120238
- () => import("./lerc-CTnJE0lo.js").then(async (m) => {
120240
+ () => import("./lerc-CvrT17Yp.js").then(async (m) => {
120239
120241
  await m.zstd.init();
120240
120242
  return m;
120241
120243
  }).then((m) => m.default)
120242
120244
  );
120243
- addDecoder(50001, () => import("./webimage-CZCTvbYg.js").then((m) => m.default));
120245
+ addDecoder(50001, () => import("./webimage-Bmag3270.js").then((m) => m.default));
120244
120246
  function decodeRowAcc(row, stride) {
120245
120247
  let length2 = row.length - stride;
120246
120248
  let offset = 0;
@@ -133609,7 +133611,7 @@ uniform float channelOpacities[7];
133609
133611
  uniform bool channelIsStaticColorMode[7]; // TODO: should this be a single float?
133610
133612
  uniform bool channelIsSetColorMode[7]; // TODO: should this be a single float?
133611
133613
 
133612
- // TODO: can array of tuples/vec2 be used?
133614
+ uniform int channelColormapFuncIndices[7];
133613
133615
  uniform float channelColormapRangeStarts[7];
133614
133616
  uniform float channelColormapRangeEnds[7];
133615
133617
 
@@ -133675,7 +133677,30 @@ vec3 sampleAndGetData(sampler2D dataTex, vec2 coord, bool isFilled, float stroke
133675
133677
  return vec3(clampedSampledData * float(isOn), sampledData, float(isEdge));
133676
133678
  }
133677
133679
 
133678
- vec4 dataToColor(vec3 sampledDataAndIsEdge, bool isStaticColorMode, vec3 channelColor, float channelOpacity, float valueOffset, float rangeStart, float rangeEnd, bool isSetColorMode, float setColorOffset) {
133680
+ vec3 colormapFunc(float clampedScaledExpressionValue, int colormapIndex) {
133681
+ // Map indices of GLSL_COLORMAPS array to their function calls.
133682
+ // GLSL_COLORMAPS is defined in ./constants.js and needs to stay manually synced.
133683
+ // 0: 'plasma',
133684
+ // 1: 'viridis',
133685
+ // 2: 'jet',
133686
+ // 3: 'greys',
133687
+
133688
+ if (colormapIndex <= 0) {
133689
+ // This should also match -1, to account for a failed Array.indexOf lookup.
133690
+ return plasma(clampedScaledExpressionValue).rgb;
133691
+ }
133692
+ if (colormapIndex == 1) {
133693
+ return viridis(clampedScaledExpressionValue).rgb;
133694
+ }
133695
+ if (colormapIndex == 2) {
133696
+ return jet(clampedScaledExpressionValue).rgb;
133697
+ }
133698
+ if (colormapIndex == 3) {
133699
+ return greys(clampedScaledExpressionValue).rgb;
133700
+ }
133701
+ }
133702
+
133703
+ vec4 dataToColor(vec3 sampledDataAndIsEdge, bool isStaticColorMode, vec3 channelColor, float channelOpacity, float valueOffset, int colormapFuncIndex, float rangeStart, float rangeEnd, bool isSetColorMode, float setColorOffset) {
133679
133704
  float clampedSampledDataAndIsOn = sampledDataAndIsEdge.x;
133680
133705
  float sampledData = sampledDataAndIsEdge.y;
133681
133706
  float isEdge = sampledDataAndIsEdge.z;
@@ -133719,7 +133744,7 @@ vec4 dataToColor(vec3 sampledDataAndIsEdge, bool isStaticColorMode, vec3 channel
133719
133744
  }
133720
133745
 
133721
133746
 
133722
- vec4 sampledColor = (1. - (float(isStaticColorMode) + float(isSetColorMode))) * vec4(COLORMAP_FUNC(clamp(scaledExpressionValue, 0.0, 1.0)).rgb, channelOpacity) + float(isStaticColorMode) * vec4(channelColor.rgb, channelOpacity) + float(isSetColorMode) * vec4(setColor, channelOpacity);
133747
+ vec4 sampledColor = (1. - (float(isStaticColorMode) + float(isSetColorMode))) * vec4(colormapFunc(clamp(scaledExpressionValue, 0.0, 1.0), colormapFuncIndex).rgb, channelOpacity) + float(isStaticColorMode) * vec4(channelColor.rgb, channelOpacity) + float(isSetColorMode) * vec4(setColor, channelOpacity);
133723
133748
  // Only return a color if the data is non-zero.
133724
133749
 
133725
133750
  return clampedSampledDataAndIsOn * isEdge * sampledColor;
@@ -133735,15 +133760,15 @@ void main() {
133735
133760
  vec3 dat4 = sampleAndGetData(channel4, vTexCoord, channelsFilled[4], channelStrokeWidths[4], channelsVisible[4]);
133736
133761
  vec3 dat5 = sampleAndGetData(channel5, vTexCoord, channelsFilled[5], channelStrokeWidths[5], channelsVisible[5]);
133737
133762
  vec3 dat6 = sampleAndGetData(channel6, vTexCoord, channelsFilled[6], channelStrokeWidths[6], channelsVisible[6]);
133738
-
133739
- vec4 val0 = dataToColor(dat0, channelIsStaticColorMode[0], color0, channelOpacities[0], valueTexOffsets[0], channelColormapRangeStarts[0], channelColormapRangeEnds[0], channelIsSetColorMode[0], colorTexOffsets[0]);
133740
- vec4 val1 = dataToColor(dat1, channelIsStaticColorMode[1], color1, channelOpacities[1], valueTexOffsets[1], channelColormapRangeStarts[1], channelColormapRangeEnds[1], channelIsSetColorMode[1], colorTexOffsets[1]);
133741
- vec4 val2 = dataToColor(dat2, channelIsStaticColorMode[2], color2, channelOpacities[2], valueTexOffsets[2], channelColormapRangeStarts[2], channelColormapRangeEnds[2], channelIsSetColorMode[2], colorTexOffsets[2]);
133742
- vec4 val3 = dataToColor(dat3, channelIsStaticColorMode[3], color3, channelOpacities[3], valueTexOffsets[3], channelColormapRangeStarts[3], channelColormapRangeEnds[3], channelIsSetColorMode[3], colorTexOffsets[3]);
133743
- vec4 val4 = dataToColor(dat4, channelIsStaticColorMode[4], color4, channelOpacities[4], valueTexOffsets[4], channelColormapRangeStarts[4], channelColormapRangeEnds[4], channelIsSetColorMode[4], colorTexOffsets[4]);
133744
- vec4 val5 = dataToColor(dat5, channelIsStaticColorMode[5], color5, channelOpacities[5], valueTexOffsets[5], channelColormapRangeStarts[5], channelColormapRangeEnds[5], channelIsSetColorMode[5], colorTexOffsets[5]);
133745
- vec4 val6 = dataToColor(dat6, channelIsStaticColorMode[6], color6, channelOpacities[6], valueTexOffsets[6], channelColormapRangeStarts[6], channelColormapRangeEnds[6], channelIsSetColorMode[6], colorTexOffsets[6]);
133746
-
133763
+
133764
+ vec4 val0 = dataToColor(dat0, channelIsStaticColorMode[0], color0, channelOpacities[0], valueTexOffsets[0], channelColormapFuncIndices[0], channelColormapRangeStarts[0], channelColormapRangeEnds[0], channelIsSetColorMode[0], colorTexOffsets[0]);
133765
+ vec4 val1 = dataToColor(dat1, channelIsStaticColorMode[1], color1, channelOpacities[1], valueTexOffsets[1], channelColormapFuncIndices[1], channelColormapRangeStarts[1], channelColormapRangeEnds[1], channelIsSetColorMode[1], colorTexOffsets[1]);
133766
+ vec4 val2 = dataToColor(dat2, channelIsStaticColorMode[2], color2, channelOpacities[2], valueTexOffsets[2], channelColormapFuncIndices[2], channelColormapRangeStarts[2], channelColormapRangeEnds[2], channelIsSetColorMode[2], colorTexOffsets[2]);
133767
+ vec4 val3 = dataToColor(dat3, channelIsStaticColorMode[3], color3, channelOpacities[3], valueTexOffsets[3], channelColormapFuncIndices[3], channelColormapRangeStarts[3], channelColormapRangeEnds[3], channelIsSetColorMode[3], colorTexOffsets[3]);
133768
+ vec4 val4 = dataToColor(dat4, channelIsStaticColorMode[4], color4, channelOpacities[4], valueTexOffsets[4], channelColormapFuncIndices[4], channelColormapRangeStarts[4], channelColormapRangeEnds[4], channelIsSetColorMode[4], colorTexOffsets[4]);
133769
+ vec4 val5 = dataToColor(dat5, channelIsStaticColorMode[5], color5, channelOpacities[5], valueTexOffsets[5], channelColormapFuncIndices[5], channelColormapRangeStarts[5], channelColormapRangeEnds[5], channelIsSetColorMode[5], colorTexOffsets[5]);
133770
+ vec4 val6 = dataToColor(dat6, channelIsStaticColorMode[6], color6, channelOpacities[6], valueTexOffsets[6], channelColormapFuncIndices[6], channelColormapRangeStarts[6], channelColormapRangeEnds[6], channelIsSetColorMode[6], colorTexOffsets[6]);
133771
+
133747
133772
  // If all of the channels are "empty", then discard this pixel so that it is not considered during picking.
133748
133773
  float emptyDat = 0.;
133749
133774
  if(dat0.x == emptyDat && dat1.x == emptyDat && dat2.x == emptyDat && dat3.x == emptyDat && dat4.x == emptyDat && dat5.x == emptyDat && dat6.x == emptyDat) {
@@ -133927,14 +133952,10 @@ const defaultProps$1 = {
133927
133952
  class BitmaskLayer2 extends XRLayer {
133928
133953
  // eslint-disable-next-line class-methods-use-this
133929
133954
  getShaders() {
133930
- const { colormap } = this.props;
133931
133955
  return {
133932
133956
  fs,
133933
133957
  vs,
133934
- modules: [project32, picking],
133935
- defines: {
133936
- [COLORMAP_SHADER_PLACEHOLDER]: GLSL_COLORMAPS.includes(colormap) ? colormap : GLSL_COLORMAP_DEFAULT
133937
- }
133958
+ modules: [project32, picking]
133938
133959
  };
133939
133960
  }
133940
133961
  /**
@@ -133993,8 +134014,6 @@ class BitmaskLayer2 extends XRLayer {
133993
134014
  channelOpacities,
133994
134015
  channelColors,
133995
134016
  channelsVisible,
133996
- // TODO: use `channelFeatureValueColormaps` in shader,
133997
- // figure out how to call multiple GLSL colormap functions
133998
134017
  channelFeatureValueColormaps,
133999
134018
  channelFeatureValueColormapRanges,
134000
134019
  channelIsStaticColorMode,
@@ -134055,6 +134074,12 @@ class BitmaskLayer2 extends XRLayer {
134055
134074
  // There are six texture entries on the shaders
134056
134075
  MAX_CHANNELS - channelStrokeWidths.length
134057
134076
  ),
134077
+ channelColormapFuncIndices: padWithDefault(
134078
+ channelFeatureValueColormaps.map((d) => GLSL_COLORMAPS.indexOf(d)),
134079
+ 0,
134080
+ // There are six texture entries on the shaders
134081
+ MAX_CHANNELS - channelFeatureValueColormaps.length
134082
+ ),
134058
134083
  channelColormapRangeStarts: padWithDefault(
134059
134084
  channelFeatureValueColormapRanges.map((r2) => (r2 == null ? void 0 : r2[0]) || 0),
134060
134085
  0,
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { I } from "./index-CrnSIpc2.js";
1
+ import { I } from "./index-vVcGlwOW.js";
2
2
  export {
3
3
  I as ImageWrapper
4
4
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
1
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-CrnSIpc2.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-vVcGlwOW.js";
3
3
  const LercParameters = {
4
4
  AddCompression: 1
5
5
  };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
1
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
1
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
1
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-CrnSIpc2.js";
1
+ import { B as BaseDecoder } from "./index-vVcGlwOW.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/image-utils",
3
- "version": "3.6.17",
3
+ "version": "3.7.0",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -17,17 +17,17 @@
17
17
  ],
18
18
  "dependencies": {
19
19
  "@hms-dbmi/viv": "~0.16.0",
20
- "@vitessce/types": "3.6.17",
21
- "@vitessce/spatial-utils": "3.6.17",
22
- "@vitessce/utils": "3.6.17",
23
- "@vitessce/globals": "3.6.17"
20
+ "@vitessce/types": "3.7.0",
21
+ "@vitessce/spatial-utils": "3.7.0",
22
+ "@vitessce/utils": "3.7.0",
23
+ "@vitessce/globals": "3.7.0"
24
24
  },
25
25
  "devDependencies": {
26
- "vite": "^6.3.5",
26
+ "vite": "^7.0.0",
27
27
  "vitest": "^3.1.4"
28
28
  },
29
29
  "scripts": {
30
- "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
30
+ "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
31
31
  "test": "pnpm exec vitest --run"
32
32
  },
33
33
  "module": "dist/index.js",