@vitessce/all 4.1.1 → 4.1.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.
@@ -3,7 +3,7 @@ import { useRef, useEffect, useState } from "react";
3
3
  import { useThree, useFrame } from "@react-three/fiber";
4
4
  import { Bvh } from "@react-three/drei";
5
5
  import { Matrix4, Vector3, Box3, FrontSide } from "three";
6
- import { g as getXRModule, i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-Vg2it-xm.js";
6
+ import { g as getXRModule, i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-B_ToVxzC.js";
7
7
  function getHandJoint(hand, jointName) {
8
8
  return hand.get(jointName);
9
9
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
- import { g as getDefaultExportFromCjs, d as requireAssign, f as require_export, h as require_core, j as require_fails, k as require_toObject, m as require_objectKeys, n as require_cof, o as require_wks, p as require_iterators, q as requireWeb_dom_iterable, s as requireEs6_string_iterator, t as require_anObject, v as require_hide, w as require_ctx, x as require_toLength, y as require_global, z as require_objectDp, A as require_descriptors, D as require_isObject, E as require_objectCreate, F as require_iterDefine, G as require_iterStep, H as require_meta, I as require_isArray, J as require_iobject, K as require_setToStringTag, M as require_aFunction, N as requireIterator, O as require_propertyDesc, c as commonjsGlobal, P as requireEs6_symbol, Q as requireDefineProperty, R as require_toIobject, S as require_objectGopd, T as require_html, U as require_domCreate, V as require_library, W as requireSymbol, X as require_objectPie, Y as require_has, Z as require_redefine, _ as require_objectAssign, $ as GREY_HEX, a0 as diffCameraState } from "./index-uF7T9QQ9.js";
3
+ import { g as getDefaultExportFromCjs, d as requireAssign, f as require_export, h as require_core, j as require_fails, k as require_toObject, m as require_objectKeys, n as require_cof, o as require_wks, p as require_iterators, q as requireWeb_dom_iterable, s as requireEs6_string_iterator, t as require_anObject, v as require_hide, w as require_ctx, x as require_toLength, y as require_global, z as require_objectDp, A as require_descriptors, D as require_isObject, E as require_objectCreate, F as require_iterDefine, G as require_iterStep, H as require_meta, I as require_isArray, J as require_iobject, K as require_setToStringTag, M as require_aFunction, N as requireIterator, O as require_propertyDesc, c as commonjsGlobal, P as requireEs6_symbol, Q as requireDefineProperty, R as require_toIobject, S as require_objectGopd, T as require_html, U as require_domCreate, V as require_library, W as requireSymbol, X as require_objectPie, Y as require_has, Z as require_redefine, _ as require_objectAssign, $ as GREY_HEX, a0 as diffCameraState, a1 as applyQuat } from "./index-zwNOYbwy.js";
4
4
  var assignExports = requireAssign();
5
5
  const _Object$assign = /* @__PURE__ */ getDefaultExportFromCjs(assignExports);
6
6
  var es6_object_keys = {};
@@ -65185,6 +65185,9 @@ function setupDefaultViewer(options) {
65185
65185
  }
65186
65186
  const viewersKeyed = {};
65187
65187
  let viewerNoKey;
65188
+ const MIN_PROJECTION_SCALE_M = 1e-9;
65189
+ const FOV_F = 1 / Math.tan(Math.PI / 8);
65190
+ const MIN_RELATIVE_DEPTH = 50;
65188
65191
  function parseUrlHash(url) {
65189
65192
  let state = null;
65190
65193
  let s = url.replace(/^[^#]+/, "");
@@ -65626,10 +65629,63 @@ class Neuroglancer extends React__default.Component {
65626
65629
  this.disposers.push(this.viewer.projectionScale.changed.add(emit));
65627
65630
  this.disposers.push(this.viewer.projectionOrientation.changed.add(emit));
65628
65631
  this.disposers.push(this.viewer.position.changed.add(emit));
65632
+ let clampRaf = null;
65633
+ const clampZoom = () => {
65634
+ if (clampRaf !== null)
65635
+ return;
65636
+ clampRaf = requestAnimationFrame(() => {
65637
+ clampRaf = null;
65638
+ const ps = this.viewer?.projectionScale;
65639
+ if (!ps)
65640
+ return;
65641
+ const minScale = MIN_PROJECTION_SCALE_M / ps.canonicalVoxelPhysicalSize;
65642
+ if (Number.isFinite(minScale) && ps.value < minScale) {
65643
+ console.trace("[NG] clamp projectionScale", ps.value, "→", minScale);
65644
+ ps.value = minScale;
65645
+ }
65646
+ });
65647
+ };
65648
+ this.disposers.push(this.viewer.projectionScale.changed.add(clampZoom));
65649
+ this.disposers.push(() => {
65650
+ if (clampRaf !== null)
65651
+ cancelAnimationFrame(clampRaf);
65652
+ });
65629
65653
  if (viewerState) {
65630
65654
  this.withoutEmitting(() => {
65631
65655
  this.viewer.state.restoreState(viewerState);
65632
65656
  });
65657
+ let depthRaf = null;
65658
+ const fitDepthToData = () => {
65659
+ if (depthRaf !== null)
65660
+ return;
65661
+ depthRaf = requestAnimationFrame(() => {
65662
+ depthRaf = null;
65663
+ const v = this.viewer;
65664
+ const bounds = v?.coordinateSpace.value?.bounds;
65665
+ const pos = v?.position.value;
65666
+ const ps = v?.projectionScale.value;
65667
+ if (!bounds || !pos || pos.length < 3 || !(ps > 0))
65668
+ return;
65669
+ const { lowerBounds: lo, upperBounds: hi } = bounds;
65670
+ const axis = applyQuat(Array.from(v.projectionOrientation.orientation), [0, 0, 1]);
65671
+ let reach = 0;
65672
+ for (let i = 0; i < 3; i += 1) {
65673
+ reach += Math.abs(axis[i]) * Math.max(Math.abs(lo[i] - pos[i]), Math.abs(hi[i] - pos[i]));
65674
+ }
65675
+ const d = ps * FOV_F / 2;
65676
+ const r = Number.isFinite(reach) ? FOV_F * ((d + reach) * 1.05 / d - 1) : 0;
65677
+ v.projectionDepthRange.value = -Math.max(MIN_RELATIVE_DEPTH, r);
65678
+ });
65679
+ };
65680
+ this.disposers.push(this.viewer.position.changed.add(fitDepthToData));
65681
+ this.disposers.push(this.viewer.projectionScale.changed.add(fitDepthToData));
65682
+ this.disposers.push(this.viewer.projectionOrientation.changed.add(fitDepthToData));
65683
+ this.disposers.push(this.viewer.coordinateSpace.changed.add(fitDepthToData));
65684
+ this.disposers.push(() => {
65685
+ if (depthRaf !== null)
65686
+ cancelAnimationFrame(depthRaf);
65687
+ });
65688
+ fitDepthToData();
65633
65689
  }
65634
65690
  if (key) {
65635
65691
  viewersKeyed[key] = this.viewer;
@@ -65638,7 +65694,33 @@ class Neuroglancer extends React__default.Component {
65638
65694
  }
65639
65695
  const { visibleChunksChanged } = this.viewer.chunkQueueManager;
65640
65696
  let firstChunkLoaded = false;
65697
+ const reportedAnnotationLayers = /* @__PURE__ */ new Set();
65698
+ const reportAnnotationSources = () => {
65699
+ if (!this.viewer)
65700
+ return;
65701
+ for (const layer of this.viewer.layerManager.managedLayers) {
65702
+ if (layer.layer instanceof AnnotationUserLayer && !reportedAnnotationLayers.has(layer.name)) {
65703
+ const annotState = layer.layer.annotationStates?.states[0];
65704
+ const t = annotState?.chunkTransform?.value?.layerToChunkTransform;
65705
+ const serializers = annotState?.source?.annotationPropertySerializers;
65706
+ if (t && serializers) {
65707
+ reportedAnnotationLayers.add(layer.name);
65708
+ this.props.onAnnotationSourceReady?.({
65709
+ layerName: layer.name,
65710
+ x: t[0],
65711
+ y: t[5],
65712
+ z: t[10],
65713
+ serializers,
65714
+ // pass all serializers
65715
+ serializer: serializers[0]
65716
+ // keep default for backward compat
65717
+ });
65718
+ }
65719
+ }
65720
+ }
65721
+ };
65641
65722
  const checkAndMarkLoaded = () => {
65723
+ reportAnnotationSources();
65642
65724
  if (firstChunkLoaded || !this.viewer)
65643
65725
  return false;
65644
65726
  for (const layer of this.viewer.layerManager.managedLayers) {
@@ -65667,20 +65749,6 @@ class Neuroglancer extends React__default.Component {
65667
65749
  requestAnimationFrame(() => requestAnimationFrame(() => {
65668
65750
  this.props.onLayerLoadingChange?.(true);
65669
65751
  }));
65670
- const annotState = layer.layer.annotationStates?.states[0];
65671
- const t = annotState?.chunkTransform?.value?.layerToChunkTransform;
65672
- const serializers = annotState?.source?.annotationPropertySerializers;
65673
- if (t && serializers) {
65674
- this.props.onAnnotationSourceReady?.({
65675
- x: t[0],
65676
- y: t[5],
65677
- z: t[10],
65678
- serializers,
65679
- // pass all serializers
65680
- serializer: serializers[0]
65681
- // keep default for backward compat
65682
- });
65683
- }
65684
65752
  return true;
65685
65753
  }
65686
65754
  }
@@ -65688,14 +65756,8 @@ class Neuroglancer extends React__default.Component {
65688
65756
  return false;
65689
65757
  };
65690
65758
  this.disposers.push(visibleChunksChanged.add(checkAndMarkLoaded));
65691
- const timeoutId1 = setTimeout(() => {
65692
- if (!firstChunkLoaded)
65693
- checkAndMarkLoaded();
65694
- }, 100);
65695
- const timeoutId2 = setTimeout(() => {
65696
- if (!firstChunkLoaded)
65697
- checkAndMarkLoaded();
65698
- }, 1e3);
65759
+ const timeoutId1 = setTimeout(checkAndMarkLoaded, 100);
65760
+ const timeoutId2 = setTimeout(checkAndMarkLoaded, 1e3);
65699
65761
  this.disposers.push(() => clearTimeout(timeoutId1));
65700
65762
  this.disposers.push(() => clearTimeout(timeoutId2));
65701
65763
  document.addEventListener("wheel", (e) => {
@@ -65736,8 +65798,7 @@ class Neuroglancer extends React__default.Component {
65736
65798
  segmentSelectionState.set(selectedSegments[layer.name]);
65737
65799
  const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => layer.name?.includes(scope));
65738
65800
  if (layerScope) {
65739
- const opacity = this.props.meshOpacity !== void 0 ? this.props.meshOpacity : cellColorMappingByLayer[layerScope]?.opacity ?? 1;
65740
- layer.layer.displayState.objectAlpha.value = opacity;
65801
+ layer.layer.displayState.objectAlpha.value = cellColorMappingByLayer[layerScope]?.opacity ?? 1;
65741
65802
  }
65742
65803
  }
65743
65804
  if (layer.layer instanceof AnnotationUserLayer) {
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
2
  import { useState, useEffect } from "react";
3
- import { g as getXrStore } from "./xrStore-2FzrFs3o.js";
3
+ import { g as getXrStore } from "./xrStore-Cg8RL1U5.js";
4
4
  function XREnterButton() {
5
5
  const [supported, setSupported] = useState(false);
6
6
  const [entered, setEntered] = useState(false);
@@ -1,7 +1,7 @@
1
1
  import { jsxs, Fragment, jsx } from "react/jsx-runtime";
2
2
  import { useRef } from "react";
3
3
  import { useThree, useFrame } from "@react-three/fiber";
4
- import { g as getXRModule } from "./index-Vg2it-xm.js";
4
+ import { g as getXRModule } from "./index-B_ToVxzC.js";
5
5
  function getHandJoint(hand, jointName) {
6
6
  return hand.get(jointName);
7
7
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx } from "react/jsx-runtime";
2
- import { g as getXRModule } from "./index-Vg2it-xm.js";
3
- import { g as getXrStore } from "./xrStore-2FzrFs3o.js";
2
+ import { g as getXRModule } from "./index-B_ToVxzC.js";
3
+ import { g as getXrStore } from "./xrStore-Cg8RL1U5.js";
4
4
  function XRWrapper({ children }) {
5
5
  const { XR } = getXRModule();
6
6
  return jsx(XR, { store: getXrStore(), children });
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-uF7T9QQ9.js";
2
+ import { B as BaseDecoder } from "./index-zwNOYbwy.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -1,6 +1,6 @@
1
1
  import * as React from "react";
2
2
  import React__default, { createContext, isValidElement, PureComponent, Component, useMemo, useState, useRef, useEffect, useCallback, memo, useContext, useReducer, useLayoutEffect } from "react";
3
- import { r as requireObjectAssign, g as getDefaultExportFromCjs$1, c as commonjsGlobal, e as earcut } from "./index-uF7T9QQ9.js";
3
+ import { r as requireObjectAssign, g as getDefaultExportFromCjs$1, c as commonjsGlobal, e as earcut } from "./index-zwNOYbwy.js";
4
4
  import ReactDOM__default, { unstable_batchedUpdates, createPortal } from "react-dom";
5
5
  import { jsx, jsxs } from "react/jsx-runtime";
6
6
  function finallyConstructor(callback) {
@@ -3,7 +3,7 @@ import React__default, { useRef, useState, useEffect, Suspense, forwardRef } fro
3
3
  import { Canvas } from "@react-three/fiber";
4
4
  import { Center, Text, Line, Bvh, OrbitControls } from "@react-three/drei";
5
5
  import { Matrix3, Matrix4, Vector3, Vector2, UniformsUtils, Data3DTexture, RedFormat, FloatType, LinearFilter, FrontSide, Scene, Group, MeshPhysicalMaterial, MeshBasicMaterial, MeshStandardMaterial, BackSide } from "three";
6
- import { C as CoordinationType, b as getImageSize } from "./index-uF7T9QQ9.js";
6
+ import { C as CoordinationType, b as getImageSize } from "./index-zwNOYbwy.js";
7
7
  function MeasureLine({ currentLine, scale }) {
8
8
  const textRef = useRef(null);
9
9
  return jsxs("group", { children: [jsx(Center, { bottom: true, right: true, position: [currentLine.midPoint.x, currentLine.midPoint.y, currentLine.midPoint.z], rotation: [0, 0, 0], children: jsx(Text, { color: "gray", scale: 0.05, ref: textRef, children: `${(currentLine.startPoint.distanceTo(currentLine.endPoint) * scale).toFixed(2)} µm` }) }), jsx(Line, {
@@ -945,8 +945,8 @@ function GeometryAndMesh(props) {
945
945
  setObsHighlight(e.object.name);
946
946
  }, onPointerOut: () => setObsHighlight(null) }) })] }) : null, renderingSettings.uniforms && renderingSettings.shader && renderingSettings.meshScale && renderingSettings.geometrySize ? jsx("group", { children: jsxs("mesh", { scale: renderingSettings.meshScale, ref: materialRef, children: [jsx("boxGeometry", { args: renderingSettings.geometrySize }), jsx("shaderMaterial", { customProgramCacheKey: () => "1", side: FrontSide, uniforms: renderingSettings.uniforms, needsUpdate: true, transparent: true, vertexShader: renderingSettings.shader.vertexShader, fragmentShader: renderingSettings.shader.fragmentShader })] }) }) : null] }), jsx("group", { name: "lines", children: lines.map((object) => jsx(MeasureLine, { currentLine: object, scale: 1 }, stringifyLineData(object))) })] });
947
947
  }
948
- const LazyGeometryAndMeshXR = React__default.lazy(() => import("./GeometryAndMeshXR-BSJ2rBtK.js").catch(() => ({ default: GeometryAndMesh })));
949
- const LazyXRSceneComponents = React__default.lazy(() => import("./XRSceneComponents-KvBqtraG.js").catch(() => ({ default: () => null })));
948
+ const LazyGeometryAndMeshXR = React__default.lazy(() => import("./GeometryAndMeshXR-Bjs1Ruhx.js").catch(() => ({ default: GeometryAndMesh })));
949
+ const LazyXRSceneComponents = React__default.lazy(() => import("./XRSceneComponents-D8sYIzX0.js").catch(() => ({ default: () => null })));
950
950
  function SpatialThree(props) {
951
951
  const materialRef = useRef(null);
952
952
  const orbitRef = useRef(null);
@@ -1303,13 +1303,13 @@ function getXRModule() {
1303
1303
  }
1304
1304
  const LazyXRWrapper = React__default.lazy(
1305
1305
  // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
1306
- () => import("./XRWrapper-BNdj_qnt.js").catch(() => ({
1306
+ () => import("./XRWrapper-op8Avjd6.js").catch(() => ({
1307
1307
  default: ({ children }) => children
1308
1308
  }))
1309
1309
  );
1310
1310
  const LazyXREnterButton = React__default.lazy(
1311
1311
  // eslint-disable-next-line implicit-arrow-linebreak, function-paren-newline
1312
- () => import("./XREnterButton-D-MyjNiM.js").catch(() => ({
1312
+ () => import("./XREnterButton-CSkdz0V0.js").catch(() => ({
1313
1313
  default: () => null
1314
1314
  }))
1315
1315
  );
@@ -4,7 +4,7 @@ import { useThree, useFrame, Canvas } from "@react-three/fiber";
4
4
  import { OrbitControls } from "@react-three/drei";
5
5
  import * as THREE from "three";
6
6
  import { Data3DTexture, RedFormat, UnsignedByteType, LinearFilter, RedIntegerFormat, UnsignedIntType, NearestFilter, Vector3, Vector2, Vector4, UniformsUtils } from "three";
7
- import { l as log, i as isEqual, C as CoordinationType, u as useEventCallback } from "./index-uF7T9QQ9.js";
7
+ import { l as log, i as isEqual, C as CoordinationType, u as useEventCallback } from "./index-zwNOYbwy.js";
8
8
  const LogLevel = {
9
9
  INFO: "info",
10
10
  WARN: "warn",