@vitessce/zarr 3.2.1 → 3.2.2

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-68f84e2a.js";
2
- import { B as BaseDecoder } from "./index-9ae02eab.js";
2
+ import { B as BaseDecoder } from "./index-11e344fb.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  class DeflateDecoder extends BaseDecoder {
@@ -142296,16 +142296,16 @@ function addDecoder(cases, importFn) {
142296
142296
  }
142297
142297
  cases.forEach((c) => registry.set(c, importFn));
142298
142298
  }
142299
- addDecoder([void 0, 1], () => import("./raw-4015af9c.js").then((m) => m.default));
142300
- addDecoder(5, () => import("./lzw-b264d65a.js").then((m) => m.default));
142299
+ addDecoder([void 0, 1], () => import("./raw-53282bb2.js").then((m) => m.default));
142300
+ addDecoder(5, () => import("./lzw-88a53998.js").then((m) => m.default));
142301
142301
  addDecoder(6, () => {
142302
142302
  throw new Error("old style JPEG compression is not supported.");
142303
142303
  });
142304
- addDecoder(7, () => import("./jpeg-af2abb26.js").then((m) => m.default));
142305
- addDecoder([8, 32946], () => import("./deflate-2b2b285b.js").then((m) => m.default));
142306
- addDecoder(32773, () => import("./packbits-58bf813f.js").then((m) => m.default));
142307
- addDecoder(34887, () => import("./lerc-ac5abe1c.js").then((m) => m.default));
142308
- addDecoder(50001, () => import("./webimage-d31de7e9.js").then((m) => m.default));
142304
+ addDecoder(7, () => import("./jpeg-f5f84485.js").then((m) => m.default));
142305
+ addDecoder([8, 32946], () => import("./deflate-f2b94bed.js").then((m) => m.default));
142306
+ addDecoder(32773, () => import("./packbits-93df2294.js").then((m) => m.default));
142307
+ addDecoder(34887, () => import("./lerc-2dbc6d98.js").then((m) => m.default));
142308
+ addDecoder(50001, () => import("./webimage-9f58dd5d.js").then((m) => m.default));
142309
142309
  function decodeRowAcc(row, stride) {
142310
142310
  let length2 = row.length - stride;
142311
142311
  let offset = 0;
@@ -146128,6 +146128,67 @@ function makeBoundingBox(viewState) {
146128
146128
  viewport.unproject([0, viewport.height])
146129
146129
  ];
146130
146130
  }
146131
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
146132
+ const MIN_TARGET = TARGETS[0];
146133
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
146134
+ const SI_PREFIXES = [
146135
+ { symbol: "Y", exponent: 24 },
146136
+ { symbol: "Z", exponent: 21 },
146137
+ { symbol: "E", exponent: 18 },
146138
+ { symbol: "P", exponent: 15 },
146139
+ { symbol: "T", exponent: 12 },
146140
+ { symbol: "G", exponent: 9 },
146141
+ { symbol: "M", exponent: 6 },
146142
+ { symbol: "k", exponent: 3 },
146143
+ { symbol: "h", exponent: 2 },
146144
+ { symbol: "da", exponent: 1 },
146145
+ { symbol: "", exponent: 0 },
146146
+ { symbol: "d", exponent: -1 },
146147
+ { symbol: "c", exponent: -2 },
146148
+ { symbol: "m", exponent: -3 },
146149
+ { symbol: "µ", exponent: -6 },
146150
+ { symbol: "n", exponent: -9 },
146151
+ { symbol: "p", exponent: -12 },
146152
+ { symbol: "f", exponent: -15 },
146153
+ { symbol: "a", exponent: -18 },
146154
+ { symbol: "z", exponent: -21 },
146155
+ { symbol: "y", exponent: -24 }
146156
+ ];
146157
+ function sizeToMeters(size2, unit2) {
146158
+ if (!unit2 || unit2 === "m") {
146159
+ return size2;
146160
+ }
146161
+ if (unit2.length > 1) {
146162
+ let unitPrefix = unit2.substring(0, unit2.length - 1);
146163
+ if (unitPrefix === "u") {
146164
+ unitPrefix = "µ";
146165
+ }
146166
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
146167
+ if (unitObj) {
146168
+ return size2 * 10 ** unitObj.exponent;
146169
+ }
146170
+ }
146171
+ throw new Error("Received unknown unit");
146172
+ }
146173
+ function snapValue(value) {
146174
+ let magnitude = 0;
146175
+ if (value < MIN_TARGET || value > MAX_TARGET) {
146176
+ magnitude = Math.floor(Math.log10(value));
146177
+ }
146178
+ let snappedUnit = SI_PREFIXES.find(
146179
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
146180
+ );
146181
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
146182
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
146183
+ snappedUnit = SI_PREFIXES.find(
146184
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
146185
+ );
146186
+ adjustedValue = value / 10 ** snappedUnit.exponent;
146187
+ }
146188
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
146189
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
146190
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
146191
+ }
146131
146192
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
146132
146193
 
146133
146194
  precision highp float;
@@ -146895,26 +146956,27 @@ const OverviewLayer = class extends CompositeLayer {
146895
146956
  OverviewLayer.layerName = "OverviewLayer";
146896
146957
  OverviewLayer.defaultProps = defaultProps$3;
146897
146958
  function getPosition(boundingBox, position, length2) {
146898
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
146959
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
146960
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
146899
146961
  switch (position) {
146900
146962
  case "bottom-right": {
146901
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
146902
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
146963
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
146964
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
146903
146965
  return [yCoord, xLeftCoord];
146904
146966
  }
146905
146967
  case "top-right": {
146906
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
146907
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
146968
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
146969
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
146908
146970
  return [yCoord, xLeftCoord];
146909
146971
  }
146910
146972
  case "top-left": {
146911
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
146912
- const xLeftCoord = viewLength * length2;
146973
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
146974
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
146913
146975
  return [yCoord, xLeftCoord];
146914
146976
  }
146915
146977
  case "bottom-left": {
146916
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
146917
- const xLeftCoord = viewLength * length2;
146978
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
146979
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
146918
146980
  return [yCoord, xLeftCoord];
146919
146981
  }
146920
146982
  default: {
@@ -146932,11 +146994,12 @@ const defaultProps$2 = {
146932
146994
  unit: { type: "string", value: "", compare: true },
146933
146995
  size: { type: "number", value: 1, compare: true },
146934
146996
  position: { type: "string", value: "bottom-right", compare: true },
146935
- length: { type: "number", value: 0.085, compare: true }
146997
+ length: { type: "number", value: 0.085, compare: true },
146998
+ snap: { type: "boolean", value: false, compare: true }
146936
146999
  };
146937
147000
  const ScaleBarLayer = class extends CompositeLayer {
146938
147001
  renderLayers() {
146939
- const { id, unit: unit2, size: size2, position, viewState, length: length2 } = this.props;
147002
+ const { id, unit: unit2, size: size2, position, viewState, length: length2, snap } = this.props;
146940
147003
  const boundingBox = makeBoundingBox(viewState);
146941
147004
  const { zoom } = viewState;
146942
147005
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -146945,15 +147008,27 @@ const ScaleBarLayer = class extends CompositeLayer {
146945
147008
  2 ** (-zoom + 1.5),
146946
147009
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
146947
147010
  );
146948
- const numUnits = barLength * size2;
147011
+ let adjustedBarLength = barLength;
147012
+ let displayNumber = (barLength * size2).toPrecision(5);
147013
+ let displayUnit = unit2;
147014
+ if (snap) {
147015
+ const meterSize = sizeToMeters(size2, unit2);
147016
+ const numUnits = barLength * meterSize;
147017
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
147018
+ adjustedBarLength = snappedOrigUnits / meterSize;
147019
+ displayNumber = snappedNewUnits;
147020
+ displayUnit = `${snappedUnitPrefix}m`;
147021
+ }
146949
147022
  const [yCoord, xLeftCoord] = getPosition(boundingBox, position, length2);
147023
+ const xRightCoord = xLeftCoord + barLength;
147024
+ const isLeft = position.endsWith("-left");
146950
147025
  const lengthBar = new LineLayer({
146951
147026
  id: `scale-bar-length-${id}`,
146952
147027
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146953
147028
  data: [
146954
147029
  [
146955
- [xLeftCoord, yCoord],
146956
- [xLeftCoord + barLength, yCoord]
147030
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
147031
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
146957
147032
  ]
146958
147033
  ],
146959
147034
  getSourcePosition: (d) => d[0],
@@ -146966,8 +147041,14 @@ const ScaleBarLayer = class extends CompositeLayer {
146966
147041
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146967
147042
  data: [
146968
147043
  [
146969
- [xLeftCoord, yCoord - barHeight],
146970
- [xLeftCoord, yCoord + barHeight]
147044
+ [
147045
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
147046
+ yCoord - barHeight
147047
+ ],
147048
+ [
147049
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
147050
+ yCoord + barHeight
147051
+ ]
146971
147052
  ]
146972
147053
  ],
146973
147054
  getSourcePosition: (d) => d[0],
@@ -146980,8 +147061,14 @@ const ScaleBarLayer = class extends CompositeLayer {
146980
147061
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146981
147062
  data: [
146982
147063
  [
146983
- [xLeftCoord + barLength, yCoord - barHeight],
146984
- [xLeftCoord + barLength, yCoord + barHeight]
147064
+ [
147065
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
147066
+ yCoord - barHeight
147067
+ ],
147068
+ [
147069
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
147070
+ yCoord + barHeight
147071
+ ]
146985
147072
  ]
146986
147073
  ],
146987
147074
  getSourcePosition: (d) => d[0],
@@ -146994,8 +147081,11 @@ const ScaleBarLayer = class extends CompositeLayer {
146994
147081
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
146995
147082
  data: [
146996
147083
  {
146997
- text: numUnits.toPrecision(5) + unit2,
146998
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
147084
+ text: `${displayNumber}${displayUnit}`,
147085
+ position: [
147086
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
147087
+ yCoord + barHeight * 4
147088
+ ]
146999
147089
  }
147000
147090
  ],
147001
147091
  getColor: [220, 220, 220, 255],
@@ -147004,7 +147094,7 @@ const ScaleBarLayer = class extends CompositeLayer {
147004
147094
  sizeUnits: "meters",
147005
147095
  sizeScale: 2 ** -zoom,
147006
147096
  characterSet: [
147007
- ...unit2.split(""),
147097
+ ...displayUnit.split(""),
147008
147098
  ...range(10).map((i2) => String(i2)),
147009
147099
  ".",
147010
147100
  "e",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A, F, G, a, M, b, O, i, e, d, f, h, c, j, Z } from "./index-9ae02eab.js";
1
+ import { A, F, G, a, M, b, O, i, e, d, f, h, c, j, Z } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  export {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-9ae02eab.js";
1
+ import { B as BaseDecoder } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const dctZigZag = new Int32Array([
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-68f84e2a.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-9ae02eab.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder } from "./index-11e344fb.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  const LercParameters = {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-9ae02eab.js";
1
+ import { B as BaseDecoder } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  const MIN_BITS = 9;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-9ae02eab.js";
1
+ import { B as BaseDecoder } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class PackbitsDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-9ae02eab.js";
1
+ import { B as BaseDecoder } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class RawDecoder extends BaseDecoder {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-9ae02eab.js";
1
+ import { B as BaseDecoder } from "./index-11e344fb.js";
2
2
  import "@vitessce/vit-s";
3
3
  import "react";
4
4
  class WebImageDecoder extends BaseDecoder {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/zarr",
3
- "version": "3.2.1",
3
+ "version": "3.2.2",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -19,13 +19,13 @@
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarr": "0.5.1",
22
- "@vitessce/constants-internal": "3.2.1",
23
- "@vitessce/gl": "3.2.1",
24
- "@vitessce/sets-utils": "3.2.1",
25
- "@vitessce/spatial-utils": "3.2.1",
26
- "@vitessce/image-utils": "3.2.1",
27
- "@vitessce/utils": "3.2.1",
28
- "@vitessce/vit-s": "3.2.1"
22
+ "@vitessce/constants-internal": "3.2.2",
23
+ "@vitessce/gl": "3.2.2",
24
+ "@vitessce/sets-utils": "3.2.2",
25
+ "@vitessce/spatial-utils": "3.2.2",
26
+ "@vitessce/image-utils": "3.2.2",
27
+ "@vitessce/utils": "3.2.2",
28
+ "@vitessce/vit-s": "3.2.2"
29
29
  },
30
30
  "scripts": {
31
31
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",