@vitessce/all 4.0.0-test.0 → 4.0.0-test.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.
@@ -4,7 +4,7 @@ import { useThree, useFrame } from "@react-three/fiber";
4
4
  import { Bvh } from "@react-three/drei";
5
5
  import { useXR, useXRInputSourceState } from "@react-three/xr";
6
6
  import { Matrix4, Vector3, Box3, FrontSide } from "three";
7
- import { i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-DxpZAn2M.js";
7
+ import { i as isValidGeometrySize, M as MeasureLine, s as stringifyLineData } from "./index-CNZN2FGp.js";
8
8
  function getHandJoint(hand, jointName) {
9
9
  return hand.get(jointName);
10
10
  }
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import React__default from "react";
3
- import { a 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 diffCameraState } from "./index-5W6nu-ix.js";
3
+ import { a 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 diffCameraState } from "./index-BYPSbKAg.js";
4
4
  var assignExports = requireAssign();
5
5
  const _Object$assign = /* @__PURE__ */ getDefaultExportFromCjs(assignExports);
6
6
  var es6_object_keys = {};
@@ -30148,9 +30148,7 @@ const svg_bin = '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0
30148
30148
  function makeDeleteButton(options = {}) {
30149
30149
  const icon = makeIcon(_Object$assign({ svg: svg_bin }, options));
30150
30150
  const svg = icon.firstElementChild;
30151
- if (svg) {
30152
- svg.style.fill = "white";
30153
- }
30151
+ if (svg) svg.style.fill = "white";
30154
30152
  return icon;
30155
30153
  }
30156
30154
  var es6_string_raw = {};
@@ -45795,6 +45793,18 @@ class DataManagementContext extends RefCounted {
45795
45793
  this.frameNumberCounter = frameNumberCounter;
45796
45794
  const chunk_worker_url = bundleRoot + "chunk_worker.bundle.js";
45797
45795
  this.worker = typeof bundleRoot === "string" ? new Worker(chunk_worker_url) : bundleRoot;
45796
+ if (typeof bundleRoot !== "string") {
45797
+ this.worker.addEventListener("message", (msg) => {
45798
+ if (msg.data?.functionName === "Worker" && msg.data?.path === "async_computation.bundle.js") {
45799
+ msg.stopImmediatePropagation();
45800
+ const AsyncWorker = bundleRoot.AsyncComputationWorker;
45801
+ if (AsyncWorker) {
45802
+ const asyncWorker = new AsyncWorker();
45803
+ asyncWorker.postMessage({ port: msg.data.port }, [msg.data.port]);
45804
+ }
45805
+ }
45806
+ }, true);
45807
+ }
45798
45808
  this.chunkQueueManager = this.registerDisposer(new ChunkQueueManager(new RPC(this.worker), this.gl, this.frameNumberCounter, {
45799
45809
  gpuMemory: new CapacitySpecification({ defaultItemLimit: 1e6, defaultSizeLimit: 1e9 }),
45800
45810
  systemMemory: new CapacitySpecification({ defaultItemLimit: 1e7, defaultSizeLimit: 2e9 }),
@@ -65432,6 +65442,7 @@ class Neuroglancer extends React__default.Component {
65432
65442
  onVisibleChanged: null,
65433
65443
  onSelectionDetailsStateChanged: null,
65434
65444
  onViewerStateChanged: null,
65445
+ onLayerLoadingChange: null,
65435
65446
  key: null,
65436
65447
  callbacks: [],
65437
65448
  ngServer: "https://neuroglancer-demo.appspot.com/"
@@ -65446,7 +65457,7 @@ class Neuroglancer extends React__default.Component {
65446
65457
  this.disposers = [];
65447
65458
  this.prevColorOverrides = /* @__PURE__ */ new Set();
65448
65459
  this.overrideColorsById = /* @__PURE__ */ Object.create(null);
65449
- this.allKnownIds = /* @__PURE__ */ new Set();
65460
+ this.allKnownIdsByLayer = {};
65450
65461
  }
65451
65462
  minimalPoseSnapshot = () => {
65452
65463
  const v = this.viewer;
@@ -65496,24 +65507,26 @@ class Neuroglancer extends React__default.Component {
65496
65507
  return JSON.stringify(prevLayers) !== JSON.stringify(nextLayers);
65497
65508
  };
65498
65509
  /* To add colors to the segments, turning unselected to grey */
65499
- applyColorsAndVisibility = (cellColorMapping) => {
65510
+ applyColorsAndVisibility = (cellColorMappingByLayer) => {
65500
65511
  if (!this.viewer)
65501
65512
  return;
65502
- const selected = { ...cellColorMapping || {} };
65503
- for (const id of Object.keys(selected))
65504
- this.allKnownIds.add(id);
65505
- if (this.allKnownIds.size === 0) {
65506
- const init = this.props.viewerState?.layers?.[0]?.segmentColors || {};
65507
- for (const id of Object.keys(init))
65508
- this.allKnownIds.add(id);
65509
- }
65510
- const fullSegmentColors = {};
65511
- for (const id of this.allKnownIds) {
65512
- fullSegmentColors[id] = selected[id] || GREY_HEX;
65513
- }
65514
65513
  const baseLayers = this.props.viewerState?.layers ?? (this.viewer.state.toJSON().layers || []);
65515
- const newLayers = baseLayers.map((layer, idx) => {
65516
- if (idx === 0 || layer?.type === "segmentation") {
65514
+ const newLayers = baseLayers.map((layer) => {
65515
+ const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => layer.name?.includes(scope));
65516
+ const selected = { ...cellColorMappingByLayer[layerScope]?.colors || {} };
65517
+ if (!this.allKnownIdsByLayer)
65518
+ this.allKnownIdsByLayer = {};
65519
+ if (!this.allKnownIdsByLayer[layerScope]) {
65520
+ this.allKnownIdsByLayer[layerScope] = /* @__PURE__ */ new Set();
65521
+ }
65522
+ for (const id of Object.keys(selected)) {
65523
+ this.allKnownIdsByLayer[layerScope].add(id);
65524
+ }
65525
+ const fullSegmentColors = {};
65526
+ for (const id of this.allKnownIdsByLayer[layerScope] || []) {
65527
+ fullSegmentColors[id] = selected[id] || GREY_HEX;
65528
+ }
65529
+ if (layer.type === "segmentation") {
65517
65530
  return { ...layer, segmentColors: fullSegmentColors };
65518
65531
  }
65519
65532
  return layer;
@@ -65560,9 +65573,37 @@ class Neuroglancer extends React__default.Component {
65560
65573
  } else {
65561
65574
  viewerNoKey = this.viewer;
65562
65575
  }
65576
+ const { visibleChunksChanged } = this.viewer.chunkQueueManager;
65577
+ let firstChunkLoaded = false;
65578
+ this.disposers.push(visibleChunksChanged.add(() => {
65579
+ if (!firstChunkLoaded) {
65580
+ for (const layer of this.viewer.layerManager.managedLayers) {
65581
+ if (layer.layer instanceof SegmentationUserLayer) {
65582
+ const hasVisibleChunk = layer.layer.renderLayers?.some((rl) => {
65583
+ const { numVisibleChunksAvailable, numVisibleChunksNeeded } = rl.layerChunkProgressInfo || {};
65584
+ if (!numVisibleChunksNeeded || !numVisibleChunksAvailable)
65585
+ return false;
65586
+ return numVisibleChunksAvailable / numVisibleChunksNeeded > 0.25;
65587
+ });
65588
+ if (hasVisibleChunk) {
65589
+ firstChunkLoaded = true;
65590
+ requestAnimationFrame(() => {
65591
+ requestAnimationFrame(() => {
65592
+ this.props.onLayerLoadingChange?.(true);
65593
+ });
65594
+ });
65595
+ return;
65596
+ }
65597
+ }
65598
+ }
65599
+ }
65600
+ }));
65601
+ this.disposers.push(() => {
65602
+ firstChunkLoaded = false;
65603
+ });
65563
65604
  }
65564
65605
  componentDidUpdate(prevProps, prevState) {
65565
- const { viewerState, cellColorMapping } = this.props;
65606
+ const { viewerState, cellColorMapping: cellColorMappingByLayer } = this.props;
65566
65607
  const selectedSegments = {};
65567
65608
  for (const layer of this.viewer.layerManager.managedLayers) {
65568
65609
  if (layer.layer instanceof SegmentationUserLayer) {
@@ -65574,6 +65615,20 @@ class Neuroglancer extends React__default.Component {
65574
65615
  if (layer.layer instanceof SegmentationUserLayer) {
65575
65616
  const { segmentSelectionState } = layer.layer.displayState;
65576
65617
  segmentSelectionState.set(selectedSegments[layer.name]);
65618
+ const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => layer.name?.includes(scope));
65619
+ if (layerScope) {
65620
+ const opacity = cellColorMappingByLayer[layerScope]?.opacity ?? 1;
65621
+ layer.layer.displayState.objectAlpha.value = opacity;
65622
+ }
65623
+ }
65624
+ if (layer.layer instanceof AnnotationUserLayer) {
65625
+ const matchingLayer = (viewerState?.layers || []).find((l) => l.name === layer.name);
65626
+ if (matchingLayer?.shader) {
65627
+ const currentShader = layer.layer.annotationDisplayState.shader.value_;
65628
+ if (currentShader !== matchingLayer.shader) {
65629
+ layer.layer.annotationDisplayState.shader.value = matchingLayer.shader;
65630
+ }
65631
+ }
65577
65632
  }
65578
65633
  }
65579
65634
  if (!viewerState)
@@ -65597,23 +65652,23 @@ class Neuroglancer extends React__default.Component {
65597
65652
  this.withoutEmitting(() => {
65598
65653
  const layers = Array.isArray(viewerState.layers) ? viewerState.layers : [];
65599
65654
  this.viewer.state.restoreState({ layers });
65600
- if (cellColorMapping && Object.keys(cellColorMapping).length) {
65601
- this.applyColorsAndVisibility(cellColorMapping);
65655
+ if (cellColorMappingByLayer && Object.keys(cellColorMappingByLayer).length) {
65656
+ this.applyColorsAndVisibility(cellColorMappingByLayer);
65602
65657
  }
65603
65658
  });
65604
65659
  }
65605
- const prevSize = prevProps.cellColorMapping ? Object.keys(prevProps.cellColorMapping).length : 0;
65606
- const currSize = cellColorMapping ? Object.keys(cellColorMapping).length : 0;
65607
- const mappingRefChanged = prevProps.cellColorMapping !== cellColorMapping;
65660
+ const prevSize = prevProps.cellColorMapping ? Object.values(prevProps.cellColorMapping).reduce((acc, v) => acc + Object.keys(v?.colors || {}).length, 0) : 0;
65661
+ const currSize = cellColorMappingByLayer ? Object.values(cellColorMappingByLayer).reduce((acc, v) => acc + Object.keys(v?.colors || {}).length, 0) : 0;
65662
+ const mappingRefChanged = prevProps.cellColorMapping !== this.props.cellColorMapping;
65608
65663
  if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
65609
65664
  this.withoutEmitting(() => {
65610
- this.applyColorsAndVisibility(cellColorMapping);
65665
+ this.applyColorsAndVisibility(cellColorMappingByLayer);
65611
65666
  });
65612
65667
  }
65613
65668
  const stripSegFields = (layers) => (layers || []).map((l) => {
65614
65669
  if (!l)
65615
65670
  return l;
65616
- const { segments, segmentColors, ...rest } = l;
65671
+ const { segments, segmentColors, objectAlpha, ...rest } = l;
65617
65672
  return rest;
65618
65673
  });
65619
65674
  const prevLayers = prevProps.viewerState?.layers;
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-5W6nu-ix.js";
2
+ import { B as BaseDecoder } from "./index-BYPSbKAg.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;