@vitessce/json 3.2.0 → 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-8012d2e4.js";
2
+ import { B as BaseDecoder } from "./index-4161f4c6.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  class DeflateDecoder extends BaseDecoder {
@@ -134538,16 +134538,16 @@ async function getDecoder(fileDirectory) {
134538
134538
  const Decoder = await importFn();
134539
134539
  return new Decoder(fileDirectory);
134540
134540
  }
134541
- addDecoder([void 0, 1], () => import("./raw-52aeaa84.js").then((m) => m.default));
134542
- addDecoder(5, () => import("./lzw-e36a19d9.js").then((m) => m.default));
134541
+ addDecoder([void 0, 1], () => import("./raw-92d9d379.js").then((m) => m.default));
134542
+ addDecoder(5, () => import("./lzw-0d130ea8.js").then((m) => m.default));
134543
134543
  addDecoder(6, () => {
134544
134544
  throw new Error("old style JPEG compression is not supported.");
134545
134545
  });
134546
- addDecoder(7, () => import("./jpeg-4c99f279.js").then((m) => m.default));
134547
- addDecoder([8, 32946], () => import("./deflate-a6cb9579.js").then((m) => m.default));
134548
- addDecoder(32773, () => import("./packbits-07586fed.js").then((m) => m.default));
134549
- addDecoder(34887, () => import("./lerc-4666ac1a.js").then((m) => m.default));
134550
- addDecoder(50001, () => import("./webimage-eac23f35.js").then((m) => m.default));
134546
+ addDecoder(7, () => import("./jpeg-f095192f.js").then((m) => m.default));
134547
+ addDecoder([8, 32946], () => import("./deflate-bd18eba0.js").then((m) => m.default));
134548
+ addDecoder(32773, () => import("./packbits-50600755.js").then((m) => m.default));
134549
+ addDecoder(34887, () => import("./lerc-fa094a4e.js").then((m) => m.default));
134550
+ addDecoder(50001, () => import("./webimage-86533d62.js").then((m) => m.default));
134551
134551
  function copyNewSize(array2, width, height, samplesPerPixel = 1) {
134552
134552
  return new (Object.getPrototypeOf(array2)).constructor(width * height * samplesPerPixel);
134553
134553
  }
@@ -149079,6 +149079,67 @@ function makeBoundingBox(viewState) {
149079
149079
  viewport.unproject([0, viewport.height])
149080
149080
  ];
149081
149081
  }
149082
+ const TARGETS = [1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 200, 250, 500, 1e3];
149083
+ const MIN_TARGET = TARGETS[0];
149084
+ const MAX_TARGET = TARGETS[TARGETS.length - 1];
149085
+ const SI_PREFIXES = [
149086
+ { symbol: "Y", exponent: 24 },
149087
+ { symbol: "Z", exponent: 21 },
149088
+ { symbol: "E", exponent: 18 },
149089
+ { symbol: "P", exponent: 15 },
149090
+ { symbol: "T", exponent: 12 },
149091
+ { symbol: "G", exponent: 9 },
149092
+ { symbol: "M", exponent: 6 },
149093
+ { symbol: "k", exponent: 3 },
149094
+ { symbol: "h", exponent: 2 },
149095
+ { symbol: "da", exponent: 1 },
149096
+ { symbol: "", exponent: 0 },
149097
+ { symbol: "d", exponent: -1 },
149098
+ { symbol: "c", exponent: -2 },
149099
+ { symbol: "m", exponent: -3 },
149100
+ { symbol: "µ", exponent: -6 },
149101
+ { symbol: "n", exponent: -9 },
149102
+ { symbol: "p", exponent: -12 },
149103
+ { symbol: "f", exponent: -15 },
149104
+ { symbol: "a", exponent: -18 },
149105
+ { symbol: "z", exponent: -21 },
149106
+ { symbol: "y", exponent: -24 }
149107
+ ];
149108
+ function sizeToMeters(size2, unit2) {
149109
+ if (!unit2 || unit2 === "m") {
149110
+ return size2;
149111
+ }
149112
+ if (unit2.length > 1) {
149113
+ let unitPrefix = unit2.substring(0, unit2.length - 1);
149114
+ if (unitPrefix === "u") {
149115
+ unitPrefix = "µ";
149116
+ }
149117
+ const unitObj = SI_PREFIXES.find((p) => p.symbol === unitPrefix);
149118
+ if (unitObj) {
149119
+ return size2 * 10 ** unitObj.exponent;
149120
+ }
149121
+ }
149122
+ throw new Error("Received unknown unit");
149123
+ }
149124
+ function snapValue(value) {
149125
+ let magnitude = 0;
149126
+ if (value < MIN_TARGET || value > MAX_TARGET) {
149127
+ magnitude = Math.floor(Math.log10(value));
149128
+ }
149129
+ let snappedUnit = SI_PREFIXES.find(
149130
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude
149131
+ );
149132
+ let adjustedValue = value / 10 ** snappedUnit.exponent;
149133
+ if (adjustedValue > 500 && adjustedValue <= 1e3) {
149134
+ snappedUnit = SI_PREFIXES.find(
149135
+ (p) => p.exponent % 3 === 0 && p.exponent <= magnitude + 3
149136
+ );
149137
+ adjustedValue = value / 10 ** snappedUnit.exponent;
149138
+ }
149139
+ const targetNewUnits = TARGETS.find((t2) => t2 > adjustedValue);
149140
+ const targetOrigUnits = targetNewUnits * 10 ** snappedUnit.exponent;
149141
+ return [targetOrigUnits, targetNewUnits, snappedUnit.symbol];
149142
+ }
149082
149143
  const fs$1$1 = `#define SHADER_NAME xr-layer-fragment-shader
149083
149144
 
149084
149145
  precision highp float;
@@ -149846,26 +149907,27 @@ const OverviewLayer = class extends CompositeLayer {
149846
149907
  OverviewLayer.layerName = "OverviewLayer";
149847
149908
  OverviewLayer.defaultProps = defaultProps$3;
149848
149909
  function getPosition(boundingBox, position, length2) {
149849
- const viewLength = boundingBox[2][0] - boundingBox[0][0];
149910
+ const viewWidth = boundingBox[2][0] - boundingBox[0][0];
149911
+ const viewHeight = boundingBox[2][1] - boundingBox[0][1];
149850
149912
  switch (position) {
149851
149913
  case "bottom-right": {
149852
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
149853
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
149914
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
149915
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
149854
149916
  return [yCoord, xLeftCoord];
149855
149917
  }
149856
149918
  case "top-right": {
149857
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
149858
- const xLeftCoord = boundingBox[2][0] - viewLength * length2;
149919
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
149920
+ const xLeftCoord = boundingBox[2][0] - viewWidth * length2;
149859
149921
  return [yCoord, xLeftCoord];
149860
149922
  }
149861
149923
  case "top-left": {
149862
- const yCoord = (boundingBox[2][1] - boundingBox[0][1]) * length2;
149863
- const xLeftCoord = viewLength * length2;
149924
+ const yCoord = boundingBox[0][1] + viewHeight * length2;
149925
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
149864
149926
  return [yCoord, xLeftCoord];
149865
149927
  }
149866
149928
  case "bottom-left": {
149867
- const yCoord = boundingBox[2][1] - (boundingBox[2][1] - boundingBox[0][1]) * length2;
149868
- const xLeftCoord = viewLength * length2;
149929
+ const yCoord = boundingBox[2][1] - viewHeight * length2;
149930
+ const xLeftCoord = boundingBox[0][0] + viewWidth * length2;
149869
149931
  return [yCoord, xLeftCoord];
149870
149932
  }
149871
149933
  default: {
@@ -149883,11 +149945,12 @@ const defaultProps$2 = {
149883
149945
  unit: { type: "string", value: "", compare: true },
149884
149946
  size: { type: "number", value: 1, compare: true },
149885
149947
  position: { type: "string", value: "bottom-right", compare: true },
149886
- length: { type: "number", value: 0.085, compare: true }
149948
+ length: { type: "number", value: 0.085, compare: true },
149949
+ snap: { type: "boolean", value: false, compare: true }
149887
149950
  };
149888
149951
  const ScaleBarLayer = class extends CompositeLayer {
149889
149952
  renderLayers() {
149890
- const { id, unit: unit2, size: size2, position, viewState, length: length2 } = this.props;
149953
+ const { id, unit: unit2, size: size2, position, viewState, length: length2, snap } = this.props;
149891
149954
  const boundingBox = makeBoundingBox(viewState);
149892
149955
  const { zoom } = viewState;
149893
149956
  const viewLength = boundingBox[2][0] - boundingBox[0][0];
@@ -149896,15 +149959,27 @@ const ScaleBarLayer = class extends CompositeLayer {
149896
149959
  2 ** (-zoom + 1.5),
149897
149960
  (boundingBox[2][1] - boundingBox[0][1]) * 7e-3
149898
149961
  );
149899
- const numUnits = barLength * size2;
149962
+ let adjustedBarLength = barLength;
149963
+ let displayNumber = (barLength * size2).toPrecision(5);
149964
+ let displayUnit = unit2;
149965
+ if (snap) {
149966
+ const meterSize = sizeToMeters(size2, unit2);
149967
+ const numUnits = barLength * meterSize;
149968
+ const [snappedOrigUnits, snappedNewUnits, snappedUnitPrefix] = snapValue(numUnits);
149969
+ adjustedBarLength = snappedOrigUnits / meterSize;
149970
+ displayNumber = snappedNewUnits;
149971
+ displayUnit = `${snappedUnitPrefix}m`;
149972
+ }
149900
149973
  const [yCoord, xLeftCoord] = getPosition(boundingBox, position, length2);
149974
+ const xRightCoord = xLeftCoord + barLength;
149975
+ const isLeft = position.endsWith("-left");
149901
149976
  const lengthBar = new LineLayer({
149902
149977
  id: `scale-bar-length-${id}`,
149903
149978
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
149904
149979
  data: [
149905
149980
  [
149906
- [xLeftCoord, yCoord],
149907
- [xLeftCoord + barLength, yCoord]
149981
+ [isLeft ? xLeftCoord : xRightCoord - adjustedBarLength, yCoord],
149982
+ [isLeft ? xLeftCoord + adjustedBarLength : xRightCoord, yCoord]
149908
149983
  ]
149909
149984
  ],
149910
149985
  getSourcePosition: (d) => d[0],
@@ -149917,8 +149992,14 @@ const ScaleBarLayer = class extends CompositeLayer {
149917
149992
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
149918
149993
  data: [
149919
149994
  [
149920
- [xLeftCoord, yCoord - barHeight],
149921
- [xLeftCoord, yCoord + barHeight]
149995
+ [
149996
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
149997
+ yCoord - barHeight
149998
+ ],
149999
+ [
150000
+ isLeft ? xLeftCoord : xRightCoord - adjustedBarLength,
150001
+ yCoord + barHeight
150002
+ ]
149922
150003
  ]
149923
150004
  ],
149924
150005
  getSourcePosition: (d) => d[0],
@@ -149931,8 +150012,14 @@ const ScaleBarLayer = class extends CompositeLayer {
149931
150012
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
149932
150013
  data: [
149933
150014
  [
149934
- [xLeftCoord + barLength, yCoord - barHeight],
149935
- [xLeftCoord + barLength, yCoord + barHeight]
150015
+ [
150016
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
150017
+ yCoord - barHeight
150018
+ ],
150019
+ [
150020
+ isLeft ? xLeftCoord + adjustedBarLength : xRightCoord,
150021
+ yCoord + barHeight
150022
+ ]
149936
150023
  ]
149937
150024
  ],
149938
150025
  getSourcePosition: (d) => d[0],
@@ -149945,8 +150032,11 @@ const ScaleBarLayer = class extends CompositeLayer {
149945
150032
  coordinateSystem: COORDINATE_SYSTEM.CARTESIAN,
149946
150033
  data: [
149947
150034
  {
149948
- text: numUnits.toPrecision(5) + unit2,
149949
- position: [xLeftCoord + barLength * 0.5, yCoord + barHeight * 4]
150035
+ text: `${displayNumber}${displayUnit}`,
150036
+ position: [
150037
+ isLeft ? xLeftCoord + barLength * 0.5 : xRightCoord - barLength * 0.5,
150038
+ yCoord + barHeight * 4
150039
+ ]
149950
150040
  }
149951
150041
  ],
149952
150042
  getColor: [220, 220, 220, 255],
@@ -149955,7 +150045,7 @@ const ScaleBarLayer = class extends CompositeLayer {
149955
150045
  sizeUnits: "meters",
149956
150046
  sizeScale: 2 ** -zoom,
149957
150047
  characterSet: [
149958
- ...unit2.split(""),
150048
+ ...displayUnit.split(""),
149959
150049
  ...range(10).map((i2) => String(i2)),
149960
150050
  ".",
149961
150051
  "e",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-8012d2e4.js";
1
+ import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-4161f4c6.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-8012d2e4.js";
1
+ import { B as BaseDecoder } from "./index-4161f4c6.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, L as LercParameters, a as LercAddCompression } from "./index-8012d2e4.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-4161f4c6.js";
3
3
  import "@vitessce/vit-s";
4
4
  import "react";
5
5
  var LercDecode = { exports: {} };
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-8012d2e4.js";
1
+ import { B as BaseDecoder } from "./index-4161f4c6.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-8012d2e4.js";
1
+ import { B as BaseDecoder } from "./index-4161f4c6.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-8012d2e4.js";
1
+ import { B as BaseDecoder } from "./index-4161f4c6.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-8012d2e4.js";
1
+ import { B as BaseDecoder } from "./index-4161f4c6.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/json",
3
- "version": "3.2.0",
3
+ "version": "3.2.2",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,13 +20,13 @@
20
20
  "lodash-es": "^4.17.21",
21
21
  "zarr": "0.5.1",
22
22
  "zod": "^3.21.4",
23
- "@vitessce/constants-internal": "3.2.0",
24
- "@vitessce/gl": "3.2.0",
25
- "@vitessce/schemas": "3.2.0",
26
- "@vitessce/sets-utils": "3.2.0",
27
- "@vitessce/spatial-utils": "3.2.0",
28
- "@vitessce/utils": "3.2.0",
29
- "@vitessce/vit-s": "3.2.0"
23
+ "@vitessce/constants-internal": "3.2.2",
24
+ "@vitessce/gl": "3.2.2",
25
+ "@vitessce/schemas": "3.2.2",
26
+ "@vitessce/sets-utils": "3.2.2",
27
+ "@vitessce/spatial-utils": "3.2.2",
28
+ "@vitessce/utils": "3.2.2",
29
+ "@vitessce/vit-s": "3.2.2"
30
30
  },
31
31
  "scripts": {
32
32
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",