@vitessce/neuroglancer 3.9.6 → 3.9.8
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.
- package/dist/{ReactNeuroglancer-BSLfuCt9.js → ReactNeuroglancer-Bxe4YcLF.js} +102 -30
- package/dist/index-anGvS-pL.js +37930 -0
- package/dist/index.js +1 -1
- package/dist-tsc/Neuroglancer.d.ts +0 -2
- package/dist-tsc/Neuroglancer.d.ts.map +1 -1
- package/dist-tsc/Neuroglancer.js +28 -28
- package/dist-tsc/NeuroglancerSubscriber.d.ts.map +1 -1
- package/dist-tsc/NeuroglancerSubscriber.js +70 -27
- package/dist-tsc/ReactNeuroglancer.d.ts +13 -2
- package/dist-tsc/ReactNeuroglancer.d.ts.map +1 -1
- package/dist-tsc/ReactNeuroglancer.js +89 -31
- package/dist-tsc/data-hook-ng-utils.d.ts +1 -1
- package/dist-tsc/data-hook-ng-utils.d.ts.map +1 -1
- package/dist-tsc/data-hook-ng-utils.js +18 -4
- package/dist-tsc/shader-utils.d.ts +12 -12
- package/dist-tsc/shader-utils.d.ts.map +1 -1
- package/dist-tsc/shader-utils.js +51 -26
- package/dist-tsc/shader-utils.test.js +20 -0
- package/dist-tsc/use-memo-custom-comparison.d.ts.map +1 -1
- package/dist-tsc/use-memo-custom-comparison.js +6 -0
- package/package.json +9 -9
- package/src/Neuroglancer.js +33 -27
- package/src/NeuroglancerSubscriber.js +102 -49
- package/src/ReactNeuroglancer.js +99 -30
- package/src/data-hook-ng-utils.js +21 -2
- package/src/shader-utils.js +79 -26
- package/src/shader-utils.test.js +20 -0
- package/src/use-memo-custom-comparison.js +7 -0
- package/dist/index-DvhFVdN_.js +0 -37826
|
@@ -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-
|
|
5
|
+
import { g as getDefaultExportFromCjs, c as commonjsGlobal, d as diffCameraState } from "./index-anGvS-pL.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,29 @@ 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", (
|
|
66883
|
-
var _a
|
|
66893
|
+
__publicField(this, "applyColorsAndVisibility", (cellColorMappingByLayer) => {
|
|
66894
|
+
var _a;
|
|
66884
66895
|
if (!this.viewer) return;
|
|
66885
|
-
const
|
|
66886
|
-
|
|
66887
|
-
|
|
66888
|
-
const
|
|
66889
|
-
|
|
66890
|
-
|
|
66891
|
-
|
|
66892
|
-
|
|
66893
|
-
|
|
66894
|
-
|
|
66895
|
-
|
|
66896
|
-
|
|
66897
|
-
|
|
66896
|
+
const baseLayers = ((_a = this.props.viewerState) == null ? void 0 : _a.layers) ?? (this.viewer.state.toJSON().layers || []);
|
|
66897
|
+
const newLayers = baseLayers.map((layer) => {
|
|
66898
|
+
var _a2;
|
|
66899
|
+
const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => {
|
|
66900
|
+
var _a3;
|
|
66901
|
+
return (_a3 = layer.name) == null ? void 0 : _a3.includes(scope);
|
|
66902
|
+
});
|
|
66903
|
+
const selected = { ...((_a2 = cellColorMappingByLayer[layerScope]) == null ? void 0 : _a2.colors) || {} };
|
|
66904
|
+
if (!this.allKnownIdsByLayer) this.allKnownIdsByLayer = {};
|
|
66905
|
+
if (!this.allKnownIdsByLayer[layerScope]) {
|
|
66906
|
+
this.allKnownIdsByLayer[layerScope] = /* @__PURE__ */ new Set();
|
|
66907
|
+
}
|
|
66908
|
+
for (const id of Object.keys(selected)) {
|
|
66909
|
+
this.allKnownIdsByLayer[layerScope].add(id);
|
|
66910
|
+
}
|
|
66911
|
+
const fullSegmentColors = {};
|
|
66912
|
+
for (const id of this.allKnownIdsByLayer[layerScope] || []) {
|
|
66913
|
+
fullSegmentColors[id] = selected[id] || GREY_HEX;
|
|
66914
|
+
}
|
|
66915
|
+
if (layer.type === "segmentation") {
|
|
66898
66916
|
return { ...layer, segmentColors: fullSegmentColors };
|
|
66899
66917
|
}
|
|
66900
66918
|
return layer;
|
|
@@ -67005,7 +67023,7 @@ class Neuroglancer extends React__default.Component {
|
|
|
67005
67023
|
this.disposers = [];
|
|
67006
67024
|
this.prevColorOverrides = /* @__PURE__ */ new Set();
|
|
67007
67025
|
this.overrideColorsById = /* @__PURE__ */ Object.create(null);
|
|
67008
|
-
this.
|
|
67026
|
+
this.allKnownIdsByLayer = {};
|
|
67009
67027
|
}
|
|
67010
67028
|
componentDidMount() {
|
|
67011
67029
|
const {
|
|
@@ -67047,10 +67065,42 @@ class Neuroglancer extends React__default.Component {
|
|
|
67047
67065
|
} else {
|
|
67048
67066
|
viewerNoKey = this.viewer;
|
|
67049
67067
|
}
|
|
67068
|
+
const { visibleChunksChanged } = this.viewer.chunkQueueManager;
|
|
67069
|
+
let firstChunkLoaded = false;
|
|
67070
|
+
this.disposers.push(visibleChunksChanged.add(() => {
|
|
67071
|
+
var _a;
|
|
67072
|
+
if (!firstChunkLoaded) {
|
|
67073
|
+
for (const layer of this.viewer.layerManager.managedLayers) {
|
|
67074
|
+
if (layer.layer instanceof SegmentationUserLayer) {
|
|
67075
|
+
const hasVisibleChunk = (_a = layer.layer.renderLayers) == null ? void 0 : _a.some((rl) => {
|
|
67076
|
+
const {
|
|
67077
|
+
numVisibleChunksAvailable,
|
|
67078
|
+
numVisibleChunksNeeded
|
|
67079
|
+
} = rl.layerChunkProgressInfo || {};
|
|
67080
|
+
if (!numVisibleChunksNeeded || !numVisibleChunksAvailable) return false;
|
|
67081
|
+
return numVisibleChunksAvailable / numVisibleChunksNeeded > 0.25;
|
|
67082
|
+
});
|
|
67083
|
+
if (hasVisibleChunk) {
|
|
67084
|
+
firstChunkLoaded = true;
|
|
67085
|
+
requestAnimationFrame(() => {
|
|
67086
|
+
requestAnimationFrame(() => {
|
|
67087
|
+
var _a2, _b;
|
|
67088
|
+
(_b = (_a2 = this.props).onLayerLoadingChange) == null ? void 0 : _b.call(_a2, true);
|
|
67089
|
+
});
|
|
67090
|
+
});
|
|
67091
|
+
return;
|
|
67092
|
+
}
|
|
67093
|
+
}
|
|
67094
|
+
}
|
|
67095
|
+
}
|
|
67096
|
+
}));
|
|
67097
|
+
this.disposers.push(() => {
|
|
67098
|
+
firstChunkLoaded = false;
|
|
67099
|
+
});
|
|
67050
67100
|
}
|
|
67051
67101
|
componentDidUpdate(prevProps, prevState) {
|
|
67052
|
-
var _a;
|
|
67053
|
-
const { viewerState, cellColorMapping } = this.props;
|
|
67102
|
+
var _a, _b;
|
|
67103
|
+
const { viewerState, cellColorMapping: cellColorMappingByLayer } = this.props;
|
|
67054
67104
|
const selectedSegments = {};
|
|
67055
67105
|
for (const layer of this.viewer.layerManager.managedLayers) {
|
|
67056
67106
|
if (layer.layer instanceof SegmentationUserLayer) {
|
|
@@ -67062,6 +67112,27 @@ class Neuroglancer extends React__default.Component {
|
|
|
67062
67112
|
if (layer.layer instanceof SegmentationUserLayer) {
|
|
67063
67113
|
const { segmentSelectionState } = layer.layer.displayState;
|
|
67064
67114
|
segmentSelectionState.set(selectedSegments[layer.name]);
|
|
67115
|
+
const layerScope = Object.keys(cellColorMappingByLayer).find(
|
|
67116
|
+
(scope) => {
|
|
67117
|
+
var _a2;
|
|
67118
|
+
return (_a2 = layer.name) == null ? void 0 : _a2.includes(scope);
|
|
67119
|
+
}
|
|
67120
|
+
);
|
|
67121
|
+
if (layerScope) {
|
|
67122
|
+
const opacity = ((_a = cellColorMappingByLayer[layerScope]) == null ? void 0 : _a.opacity) ?? 1;
|
|
67123
|
+
layer.layer.displayState.objectAlpha.value = opacity;
|
|
67124
|
+
}
|
|
67125
|
+
}
|
|
67126
|
+
if (layer.layer instanceof AnnotationUserLayer) {
|
|
67127
|
+
const matchingLayer = ((viewerState == null ? void 0 : viewerState.layers) || []).find(
|
|
67128
|
+
(l) => l.name === layer.name
|
|
67129
|
+
);
|
|
67130
|
+
if (matchingLayer == null ? void 0 : matchingLayer.shader) {
|
|
67131
|
+
const currentShader = layer.layer.annotationDisplayState.shader.value_;
|
|
67132
|
+
if (currentShader !== matchingLayer.shader) {
|
|
67133
|
+
layer.layer.annotationDisplayState.shader.value = matchingLayer.shader;
|
|
67134
|
+
}
|
|
67135
|
+
}
|
|
67065
67136
|
}
|
|
67066
67137
|
}
|
|
67067
67138
|
if (!viewerState) return;
|
|
@@ -67082,25 +67153,25 @@ class Neuroglancer extends React__default.Component {
|
|
|
67082
67153
|
this.withoutEmitting(() => {
|
|
67083
67154
|
const layers = Array.isArray(viewerState.layers) ? viewerState.layers : [];
|
|
67084
67155
|
this.viewer.state.restoreState({ layers });
|
|
67085
|
-
if (
|
|
67086
|
-
this.applyColorsAndVisibility(
|
|
67156
|
+
if (cellColorMappingByLayer && Object.keys(cellColorMappingByLayer).length) {
|
|
67157
|
+
this.applyColorsAndVisibility(cellColorMappingByLayer);
|
|
67087
67158
|
}
|
|
67088
67159
|
});
|
|
67089
67160
|
}
|
|
67090
|
-
const prevSize = prevProps.cellColorMapping ? Object.
|
|
67091
|
-
const currSize =
|
|
67092
|
-
const mappingRefChanged = prevProps.cellColorMapping !== cellColorMapping;
|
|
67161
|
+
const prevSize = prevProps.cellColorMapping ? Object.values(prevProps.cellColorMapping).reduce((acc, v) => acc + Object.keys((v == null ? void 0 : v.colors) || {}).length, 0) : 0;
|
|
67162
|
+
const currSize = cellColorMappingByLayer ? Object.values(cellColorMappingByLayer).reduce((acc, v) => acc + Object.keys((v == null ? void 0 : v.colors) || {}).length, 0) : 0;
|
|
67163
|
+
const mappingRefChanged = prevProps.cellColorMapping !== this.props.cellColorMapping;
|
|
67093
67164
|
if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
|
|
67094
67165
|
this.withoutEmitting(() => {
|
|
67095
|
-
this.applyColorsAndVisibility(
|
|
67166
|
+
this.applyColorsAndVisibility(cellColorMappingByLayer);
|
|
67096
67167
|
});
|
|
67097
67168
|
}
|
|
67098
67169
|
const stripSegFields = (layers) => (layers || []).map((l) => {
|
|
67099
67170
|
if (!l) return l;
|
|
67100
|
-
const { segments, segmentColors, ...rest } = l;
|
|
67171
|
+
const { segments, segmentColors, objectAlpha, ...rest } = l;
|
|
67101
67172
|
return rest;
|
|
67102
67173
|
});
|
|
67103
|
-
const prevLayers = (
|
|
67174
|
+
const prevLayers = (_b = prevProps.viewerState) == null ? void 0 : _b.layers;
|
|
67104
67175
|
const nextLayers = viewerState == null ? void 0 : viewerState.layers;
|
|
67105
67176
|
const prevCore = JSON.stringify(stripSegFields(prevLayers));
|
|
67106
67177
|
const nextCore = JSON.stringify(stripSegFields(nextLayers));
|
|
@@ -67164,6 +67235,7 @@ __publicField(Neuroglancer, "defaultProps", {
|
|
|
67164
67235
|
onVisibleChanged: null,
|
|
67165
67236
|
onSelectionDetailsStateChanged: null,
|
|
67166
67237
|
onViewerStateChanged: null,
|
|
67238
|
+
onLayerLoadingChange: null,
|
|
67167
67239
|
key: null,
|
|
67168
67240
|
callbacks: [],
|
|
67169
67241
|
ngServer: "https://neuroglancer-demo.appspot.com/"
|