@vitessce/neuroglancer 3.9.5 → 3.9.7

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.
Files changed (37) hide show
  1. package/dist/{ReactNeuroglancer-BCg93QGV.js → ReactNeuroglancer-pv4bM8Yp.js} +43 -26
  2. package/dist/index-BEPd2Tds.js +37856 -0
  3. package/dist/index.js +1 -1
  4. package/dist-tsc/Neuroglancer.d.ts +0 -2
  5. package/dist-tsc/Neuroglancer.d.ts.map +1 -1
  6. package/dist-tsc/Neuroglancer.js +26 -26
  7. package/dist-tsc/NeuroglancerSubscriber.d.ts.map +1 -1
  8. package/dist-tsc/NeuroglancerSubscriber.js +219 -53
  9. package/dist-tsc/ReactNeuroglancer.d.ts +2 -2
  10. package/dist-tsc/ReactNeuroglancer.d.ts.map +1 -1
  11. package/dist-tsc/ReactNeuroglancer.js +31 -28
  12. package/dist-tsc/data-hook-ng-utils.d.ts +18 -20
  13. package/dist-tsc/data-hook-ng-utils.d.ts.map +1 -1
  14. package/dist-tsc/data-hook-ng-utils.js +136 -68
  15. package/dist-tsc/shader-utils.d.ts +126 -0
  16. package/dist-tsc/shader-utils.d.ts.map +1 -0
  17. package/dist-tsc/shader-utils.js +547 -0
  18. package/dist-tsc/shader-utils.test.d.ts +2 -0
  19. package/dist-tsc/shader-utils.test.d.ts.map +1 -0
  20. package/dist-tsc/shader-utils.test.js +364 -0
  21. package/dist-tsc/use-memo-custom-comparison.d.ts +14 -0
  22. package/dist-tsc/use-memo-custom-comparison.d.ts.map +1 -0
  23. package/dist-tsc/use-memo-custom-comparison.js +150 -0
  24. package/package.json +9 -8
  25. package/src/Neuroglancer.js +31 -26
  26. package/src/NeuroglancerSubscriber.js +361 -81
  27. package/src/README.md +28 -0
  28. package/src/ReactNeuroglancer.js +34 -27
  29. package/src/data-hook-ng-utils.js +178 -78
  30. package/src/shader-utils.js +653 -0
  31. package/src/shader-utils.test.js +432 -0
  32. package/src/use-memo-custom-comparison.js +190 -0
  33. package/dist/index-Wdrc02VW.js +0 -32390
  34. package/dist-tsc/data-hook-ng-utils.test.d.ts +0 -2
  35. package/dist-tsc/data-hook-ng-utils.test.d.ts.map +0 -1
  36. package/dist-tsc/data-hook-ng-utils.test.js +0 -35
  37. package/src/data-hook-ng-utils.test.js +0 -52
@@ -2,7 +2,7 @@ var __defProp = Object.defineProperty;
2
2
  var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
3
3
  var __publicField = (obj, key, value) => __defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
4
4
  import React__default from "react";
5
- import { g as getDefaultExportFromCjs, c as commonjsGlobal, d as diffCameraState } from "./index-Wdrc02VW.js";
5
+ import { g as getDefaultExportFromCjs, c as commonjsGlobal, d as diffCameraState } from "./index-BEPd2Tds.js";
6
6
  var es6_object_assign = {};
7
7
  var _global = { exports: {} };
8
8
  var hasRequired_global;
@@ -31541,9 +31541,7 @@ const svg_bin = '<svg role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0
31541
31541
  function makeDeleteButton(options = {}) {
31542
31542
  const icon = makeIcon(_Object$assign({ svg: svg_bin }, options));
31543
31543
  const svg = icon.firstElementChild;
31544
- if (svg) {
31545
- svg.style.fill = "white";
31546
- }
31544
+ if (svg) svg.style.fill = "white";
31547
31545
  return icon;
31548
31546
  }
31549
31547
  var es6_string_raw = {};
@@ -47188,6 +47186,19 @@ class DataManagementContext extends RefCounted {
47188
47186
  this.frameNumberCounter = frameNumberCounter;
47189
47187
  const chunk_worker_url = bundleRoot + "chunk_worker.bundle.js";
47190
47188
  this.worker = typeof bundleRoot === "string" ? new Worker(chunk_worker_url) : bundleRoot;
47189
+ if (typeof bundleRoot !== "string") {
47190
+ this.worker.addEventListener("message", (msg) => {
47191
+ var _a, _b;
47192
+ if (((_a = msg.data) == null ? void 0 : _a.functionName) === "Worker" && ((_b = msg.data) == null ? void 0 : _b.path) === "async_computation.bundle.js") {
47193
+ msg.stopImmediatePropagation();
47194
+ const AsyncWorker = bundleRoot.AsyncComputationWorker;
47195
+ if (AsyncWorker) {
47196
+ const asyncWorker = new AsyncWorker();
47197
+ asyncWorker.postMessage({ port: msg.data.port }, [msg.data.port]);
47198
+ }
47199
+ }
47200
+ }, true);
47201
+ }
47191
47202
  this.chunkQueueManager = this.registerDisposer(new ChunkQueueManager(new RPC(this.worker), this.gl, this.frameNumberCounter, {
47192
47203
  gpuMemory: new CapacitySpecification({ defaultItemLimit: 1e6, defaultSizeLimit: 1e9 }),
47193
47204
  systemMemory: new CapacitySpecification({ defaultItemLimit: 1e7, defaultSizeLimit: 2e9 }),
@@ -66879,22 +66890,28 @@ class Neuroglancer extends React__default.Component {
66879
66890
  return JSON.stringify(prevLayers) !== JSON.stringify(nextLayers);
66880
66891
  });
66881
66892
  /* To add colors to the segments, turning unselected to grey */
66882
- __publicField(this, "applyColorsAndVisibility", (cellColorMapping) => {
66883
- var _a, _b, _c, _d;
66893
+ __publicField(this, "applyColorsAndVisibility", (cellColorMappingByLayer) => {
66894
+ var _a;
66884
66895
  if (!this.viewer) return;
66885
- const selected = { ...cellColorMapping || {} };
66886
- for (const id of Object.keys(selected)) this.allKnownIds.add(id);
66887
- if (this.allKnownIds.size === 0) {
66888
- const init = ((_c = (_b = (_a = this.props.viewerState) == null ? void 0 : _a.layers) == null ? void 0 : _b[0]) == null ? void 0 : _c.segmentColors) || {};
66889
- for (const id of Object.keys(init)) this.allKnownIds.add(id);
66890
- }
66891
- const fullSegmentColors = {};
66892
- for (const id of this.allKnownIds) {
66893
- fullSegmentColors[id] = selected[id] || GREY_HEX;
66894
- }
66895
- const baseLayers = ((_d = this.props.viewerState) == null ? void 0 : _d.layers) ?? (this.viewer.state.toJSON().layers || []);
66896
- const newLayers = baseLayers.map((layer, idx) => {
66897
- if (idx === 0 || (layer == null ? void 0 : layer.type) === "segmentation") {
66896
+ const baseLayers = ((_a = this.props.viewerState) == null ? void 0 : _a.layers) ?? (this.viewer.state.toJSON().layers || []);
66897
+ const newLayers = baseLayers.map((layer) => {
66898
+ const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => {
66899
+ var _a2;
66900
+ return (_a2 = layer.name) == null ? void 0 : _a2.includes(scope);
66901
+ });
66902
+ const selected = { ...cellColorMappingByLayer[layerScope] || {} };
66903
+ if (!this.allKnownIdsByLayer) this.allKnownIdsByLayer = {};
66904
+ if (!this.allKnownIdsByLayer[layerScope]) {
66905
+ this.allKnownIdsByLayer[layerScope] = /* @__PURE__ */ new Set();
66906
+ }
66907
+ for (const id of Object.keys(selected)) {
66908
+ this.allKnownIdsByLayer[layerScope].add(id);
66909
+ }
66910
+ const fullSegmentColors = {};
66911
+ for (const id of this.allKnownIdsByLayer[layerScope] || []) {
66912
+ fullSegmentColors[id] = selected[id] || GREY_HEX;
66913
+ }
66914
+ if (layer.type === "segmentation") {
66898
66915
  return { ...layer, segmentColors: fullSegmentColors };
66899
66916
  }
66900
66917
  return layer;
@@ -67005,7 +67022,7 @@ class Neuroglancer extends React__default.Component {
67005
67022
  this.disposers = [];
67006
67023
  this.prevColorOverrides = /* @__PURE__ */ new Set();
67007
67024
  this.overrideColorsById = /* @__PURE__ */ Object.create(null);
67008
- this.allKnownIds = /* @__PURE__ */ new Set();
67025
+ this.allKnownIdsByLayer = {};
67009
67026
  }
67010
67027
  componentDidMount() {
67011
67028
  const {
@@ -67050,7 +67067,7 @@ class Neuroglancer extends React__default.Component {
67050
67067
  }
67051
67068
  componentDidUpdate(prevProps, prevState) {
67052
67069
  var _a;
67053
- const { viewerState, cellColorMapping } = this.props;
67070
+ const { viewerState, cellColorMapping: cellColorMappingByLayer } = this.props;
67054
67071
  const selectedSegments = {};
67055
67072
  for (const layer of this.viewer.layerManager.managedLayers) {
67056
67073
  if (layer.layer instanceof SegmentationUserLayer) {
@@ -67082,17 +67099,17 @@ class Neuroglancer extends React__default.Component {
67082
67099
  this.withoutEmitting(() => {
67083
67100
  const layers = Array.isArray(viewerState.layers) ? viewerState.layers : [];
67084
67101
  this.viewer.state.restoreState({ layers });
67085
- if (cellColorMapping && Object.keys(cellColorMapping).length) {
67086
- this.applyColorsAndVisibility(cellColorMapping);
67102
+ if (cellColorMappingByLayer && Object.keys(cellColorMappingByLayer).length) {
67103
+ this.applyColorsAndVisibility(cellColorMappingByLayer);
67087
67104
  }
67088
67105
  });
67089
67106
  }
67090
67107
  const prevSize = prevProps.cellColorMapping ? Object.keys(prevProps.cellColorMapping).length : 0;
67091
- const currSize = cellColorMapping ? Object.keys(cellColorMapping).length : 0;
67092
- const mappingRefChanged = prevProps.cellColorMapping !== cellColorMapping;
67108
+ const currSize = cellColorMappingByLayer ? Object.keys(cellColorMappingByLayer).length : 0;
67109
+ const mappingRefChanged = prevProps.cellColorMapping !== this.props.cellColorMapping;
67093
67110
  if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
67094
67111
  this.withoutEmitting(() => {
67095
- this.applyColorsAndVisibility(cellColorMapping);
67112
+ this.applyColorsAndVisibility(cellColorMappingByLayer);
67096
67113
  });
67097
67114
  }
67098
67115
  const stripSegFields = (layers) => (layers || []).map((l) => {