@vitessce/neuroglancer 3.9.7 → 3.9.9
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-pv4bM8Yp.js → ReactNeuroglancer-Bxe4YcLF.js} +64 -9
- package/dist/{index-BEPd2Tds.js → index-anGvS-pL.js} +120 -46
- package/dist/index.js +1 -1
- package/dist-tsc/Neuroglancer.d.ts.map +1 -1
- package/dist-tsc/Neuroglancer.js +2 -2
- package/dist-tsc/NeuroglancerSubscriber.d.ts.map +1 -1
- package/dist-tsc/NeuroglancerSubscriber.js +22 -6
- package/dist-tsc/ReactNeuroglancer.d.ts +11 -0
- package/dist-tsc/ReactNeuroglancer.d.ts.map +1 -1
- package/dist-tsc/ReactNeuroglancer.js +60 -5
- 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 +5 -0
- package/package.json +9 -9
- package/src/Neuroglancer.js +2 -1
- package/src/NeuroglancerSubscriber.js +28 -4
- package/src/ReactNeuroglancer.js +67 -5
- 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 +6 -0
|
@@ -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;
|
|
@@ -66895,11 +66895,12 @@ class Neuroglancer extends React__default.Component {
|
|
|
66895
66895
|
if (!this.viewer) return;
|
|
66896
66896
|
const baseLayers = ((_a = this.props.viewerState) == null ? void 0 : _a.layers) ?? (this.viewer.state.toJSON().layers || []);
|
|
66897
66897
|
const newLayers = baseLayers.map((layer) => {
|
|
66898
|
+
var _a2;
|
|
66898
66899
|
const layerScope = Object.keys(cellColorMappingByLayer).find((scope) => {
|
|
66899
|
-
var
|
|
66900
|
-
return (
|
|
66900
|
+
var _a3;
|
|
66901
|
+
return (_a3 = layer.name) == null ? void 0 : _a3.includes(scope);
|
|
66901
66902
|
});
|
|
66902
|
-
const selected = { ...cellColorMappingByLayer[layerScope] || {} };
|
|
66903
|
+
const selected = { ...((_a2 = cellColorMappingByLayer[layerScope]) == null ? void 0 : _a2.colors) || {} };
|
|
66903
66904
|
if (!this.allKnownIdsByLayer) this.allKnownIdsByLayer = {};
|
|
66904
66905
|
if (!this.allKnownIdsByLayer[layerScope]) {
|
|
66905
66906
|
this.allKnownIdsByLayer[layerScope] = /* @__PURE__ */ new Set();
|
|
@@ -67064,9 +67065,41 @@ class Neuroglancer extends React__default.Component {
|
|
|
67064
67065
|
} else {
|
|
67065
67066
|
viewerNoKey = this.viewer;
|
|
67066
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
|
+
});
|
|
67067
67100
|
}
|
|
67068
67101
|
componentDidUpdate(prevProps, prevState) {
|
|
67069
|
-
var _a;
|
|
67102
|
+
var _a, _b;
|
|
67070
67103
|
const { viewerState, cellColorMapping: cellColorMappingByLayer } = this.props;
|
|
67071
67104
|
const selectedSegments = {};
|
|
67072
67105
|
for (const layer of this.viewer.layerManager.managedLayers) {
|
|
@@ -67079,6 +67112,27 @@ class Neuroglancer extends React__default.Component {
|
|
|
67079
67112
|
if (layer.layer instanceof SegmentationUserLayer) {
|
|
67080
67113
|
const { segmentSelectionState } = layer.layer.displayState;
|
|
67081
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
|
+
}
|
|
67082
67136
|
}
|
|
67083
67137
|
}
|
|
67084
67138
|
if (!viewerState) return;
|
|
@@ -67104,8 +67158,8 @@ class Neuroglancer extends React__default.Component {
|
|
|
67104
67158
|
}
|
|
67105
67159
|
});
|
|
67106
67160
|
}
|
|
67107
|
-
const prevSize = prevProps.cellColorMapping ? Object.
|
|
67108
|
-
const currSize = cellColorMappingByLayer ? Object.
|
|
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;
|
|
67109
67163
|
const mappingRefChanged = prevProps.cellColorMapping !== this.props.cellColorMapping;
|
|
67110
67164
|
if (!this.didLayersChange(prevVS, viewerState) && (mappingRefChanged || prevSize !== currSize)) {
|
|
67111
67165
|
this.withoutEmitting(() => {
|
|
@@ -67114,10 +67168,10 @@ class Neuroglancer extends React__default.Component {
|
|
|
67114
67168
|
}
|
|
67115
67169
|
const stripSegFields = (layers) => (layers || []).map((l) => {
|
|
67116
67170
|
if (!l) return l;
|
|
67117
|
-
const { segments, segmentColors, ...rest } = l;
|
|
67171
|
+
const { segments, segmentColors, objectAlpha, ...rest } = l;
|
|
67118
67172
|
return rest;
|
|
67119
67173
|
});
|
|
67120
|
-
const prevLayers = (
|
|
67174
|
+
const prevLayers = (_b = prevProps.viewerState) == null ? void 0 : _b.layers;
|
|
67121
67175
|
const nextLayers = viewerState == null ? void 0 : viewerState.layers;
|
|
67122
67176
|
const prevCore = JSON.stringify(stripSegFields(prevLayers));
|
|
67123
67177
|
const nextCore = JSON.stringify(stripSegFields(nextLayers));
|
|
@@ -67181,6 +67235,7 @@ __publicField(Neuroglancer, "defaultProps", {
|
|
|
67181
67235
|
onVisibleChanged: null,
|
|
67182
67236
|
onSelectionDetailsStateChanged: null,
|
|
67183
67237
|
onViewerStateChanged: null,
|
|
67238
|
+
onLayerLoadingChange: null,
|
|
67184
67239
|
key: null,
|
|
67185
67240
|
callbacks: [],
|
|
67186
67241
|
ngServer: "https://neuroglancer-demo.appspot.com/"
|