@vitessce/vit-s 4.0.2 → 4.0.4
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/index.js +38 -1
- package/dist-tsc/index.d.ts +1 -0
- package/dist-tsc/index.js +1 -0
- package/dist-tsc/index.js.map +1 -1
- package/dist-tsc/use-memo-custom-comparison.d.ts +21 -0
- package/dist-tsc/use-memo-custom-comparison.d.ts.map +1 -0
- package/dist-tsc/use-memo-custom-comparison.js +39 -0
- package/dist-tsc/use-memo-custom-comparison.js.map +1 -0
- package/package.json +13 -13
- package/src/index.js +12 -0
- package/src/use-memo-custom-comparison.js +61 -0
package/dist/index.js
CHANGED
|
@@ -34108,7 +34108,7 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
|
|
|
34108
34108
|
CoordinationType$1.HIERARCHY_LEVELS
|
|
34109
34109
|
]
|
|
34110
34110
|
});
|
|
34111
|
-
const version = "4.0.
|
|
34111
|
+
const version = "4.0.4";
|
|
34112
34112
|
const META_VERSION = {
|
|
34113
34113
|
version
|
|
34114
34114
|
};
|
|
@@ -47151,6 +47151,33 @@ function createOnDrop(setters, isFileInput = false, isConfigInput = false) {
|
|
|
47151
47151
|
setStores(storesForConfig);
|
|
47152
47152
|
};
|
|
47153
47153
|
}
|
|
47154
|
+
function useMemoCustomComparison(factory, dependencies, customIsEqual) {
|
|
47155
|
+
const ref = useRef(
|
|
47156
|
+
/** @type {{ deps: any; value: T } | undefined} */
|
|
47157
|
+
void 0
|
|
47158
|
+
);
|
|
47159
|
+
if (ref.current === void 0 || !customIsEqual(ref.current.deps, dependencies)) {
|
|
47160
|
+
ref.current = { deps: dependencies, value: factory() };
|
|
47161
|
+
}
|
|
47162
|
+
return ref.current.value;
|
|
47163
|
+
}
|
|
47164
|
+
const shallowDiff = (prevDeps, nextDeps, depName) => prevDeps[depName] !== nextDeps[depName];
|
|
47165
|
+
const shallowDiffByLayer = (prevDeps, nextDeps, depName, scopeName) => prevDeps?.[depName]?.[scopeName] !== nextDeps?.[depName]?.[scopeName];
|
|
47166
|
+
const shallowDiffByLayerWithKeys = (prevDeps, nextDeps, depName, scopeName, keys2) => keys2.some(
|
|
47167
|
+
(k) => prevDeps?.[depName]?.[scopeName]?.[k] !== nextDeps?.[depName]?.[scopeName]?.[k]
|
|
47168
|
+
);
|
|
47169
|
+
const shallowDiffByChannel = (prevDeps, nextDeps, depName, firstName, secondName) => prevDeps?.[depName]?.[firstName]?.[secondName] !== nextDeps?.[depName]?.[firstName]?.[secondName];
|
|
47170
|
+
const shallowDiffByChannelWithKeys = (prevDeps, nextDeps, depName, firstName, secondName, keys2) => keys2.some(
|
|
47171
|
+
(k) => prevDeps?.[depName]?.[firstName]?.[secondName]?.[k] !== nextDeps?.[depName]?.[firstName]?.[secondName]?.[k]
|
|
47172
|
+
);
|
|
47173
|
+
const shallowDiffByLayerCoordination = (prevDeps, nextDeps, depName, layerScope) => prevDeps?.[depName]?.[0]?.[layerScope] !== nextDeps?.[depName]?.[0]?.[layerScope];
|
|
47174
|
+
const shallowDiffByLayerCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, keys2) => keys2.some(
|
|
47175
|
+
(k) => prevDeps?.[depName]?.[0]?.[layerScope]?.[k] !== nextDeps?.[depName]?.[0]?.[layerScope]?.[k]
|
|
47176
|
+
);
|
|
47177
|
+
const shallowDiffByChannelCoordination = (prevDeps, nextDeps, depName, layerScope, channelScope) => prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope] !== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope];
|
|
47178
|
+
const shallowDiffByChannelCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, channelScope, keys2) => keys2.some(
|
|
47179
|
+
(k) => prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k] !== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k]
|
|
47180
|
+
);
|
|
47154
47181
|
export {
|
|
47155
47182
|
CellColorEncodingOption,
|
|
47156
47183
|
OptionSelect,
|
|
@@ -47162,6 +47189,15 @@ export {
|
|
|
47162
47189
|
createLoaders,
|
|
47163
47190
|
createOnDrop,
|
|
47164
47191
|
logConfig,
|
|
47192
|
+
shallowDiff,
|
|
47193
|
+
shallowDiffByChannel,
|
|
47194
|
+
shallowDiffByChannelCoordination,
|
|
47195
|
+
shallowDiffByChannelCoordinationWithKeys,
|
|
47196
|
+
shallowDiffByChannelWithKeys,
|
|
47197
|
+
shallowDiffByLayer,
|
|
47198
|
+
shallowDiffByLayerCoordination,
|
|
47199
|
+
shallowDiffByLayerCoordinationWithKeys,
|
|
47200
|
+
shallowDiffByLayerWithKeys,
|
|
47165
47201
|
useAddImageChannelInMetaCoordinationScopes,
|
|
47166
47202
|
useAsyncFunction,
|
|
47167
47203
|
useAuxiliaryCoordination,
|
|
@@ -47194,6 +47230,7 @@ export {
|
|
|
47194
47230
|
useInitialCoordination,
|
|
47195
47231
|
useLoaders,
|
|
47196
47232
|
useMatchingLoader,
|
|
47233
|
+
useMemoCustomComparison,
|
|
47197
47234
|
useMergeCoordination,
|
|
47198
47235
|
useMultiCoordinationScopes,
|
|
47199
47236
|
useMultiCoordinationScopesNonNull,
|
package/dist-tsc/index.d.ts
CHANGED
|
@@ -12,4 +12,5 @@ export { useDescription, useImageData, useObsSetsData, useObsEmbeddingData, useF
|
|
|
12
12
|
export { usePointMultiObsLabels, usePointMultiObsFeatureMatrixIndices, useSpotMultiFeatureSelection, useSpotMultiObsFeatureMatrixIndices, useSegmentationMultiFeatureSelection, useSegmentationMultiObsFeatureMatrixIndices, useSegmentationMultiObsLocations, useSegmentationMultiObsSets } from "./data-hooks-multilevel.js";
|
|
13
13
|
export { CellColorEncodingOption, OptionsContainer, OptionSelect, usePlotOptionsStyles } from "./shared-plot-options/index.js";
|
|
14
14
|
export { useAsyncFunction, usePageModeView } from "./contexts.js";
|
|
15
|
+
export { useMemoCustomComparison, shallowDiff, shallowDiffByLayer, shallowDiffByLayerWithKeys, shallowDiffByChannel, shallowDiffByChannelWithKeys, shallowDiffByLayerCoordination, shallowDiffByLayerCoordinationWithKeys, shallowDiffByChannelCoordination, shallowDiffByChannelCoordinationWithKeys } from "./use-memo-custom-comparison.js";
|
|
15
16
|
//# sourceMappingURL=index.d.ts.map
|
package/dist-tsc/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export { logConfig } from './view-config-utils.js';
|
|
|
13
13
|
export { useAsyncFunction, usePageModeView } from './contexts.js';
|
|
14
14
|
export { createLoaders } from './vitessce-grid-utils.js';
|
|
15
15
|
export { createOnDrop } from './on-drop.js';
|
|
16
|
+
export { useMemoCustomComparison, shallowDiff, shallowDiffByLayer, shallowDiffByLayerWithKeys, shallowDiffByChannel, shallowDiffByChannelWithKeys, shallowDiffByLayerCoordination, shallowDiffByLayerCoordinationWithKeys, shallowDiffByChannelCoordination, shallowDiffByChannelCoordinationWithKeys, } from './use-memo-custom-comparison.js';
|
|
16
17
|
//# sourceMappingURL=index.js.map
|
package/dist-tsc/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,yBAAyB;AACzB,OAAO,EACL,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,+BAA+B,EAC/B,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,eA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AAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.js"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,yBAAyB;AACzB,OAAO,EACL,QAAQ,EACR,OAAO,EACP,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,wBAAwB,EACxB,wBAAwB,EACxB,mBAAmB,EACnB,aAAa,EACb,+BAA+B,EAC/B,mBAAmB,EACnB,eAAe,EACf,2BAA2B,EAC3B,oBAAoB,GACrB,MAAM,YAAY,CAAC;AACpB,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,sBAAsB,EACtB,eAAe,EACf,sBAAsB,EACtB,+BAA+B,EAC/B,0BAA0B,EAC1B,iCAAiC,EACjC,mCAAmC,EACnC,0CAA0C,EAC1C,0BAA0B,EAC1B,2BAA2B,EAC3B,cAAc,EACd,UAAU,EACV,oBAAoB,EACpB,iBAAiB,EACjB,kBAAkB,EAClB,qBAAqB,EACrB,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,uBAAuB,EACvB,UAAU,EACV,aAAa,EACb,wBAAwB,EACxB,kBAAkB,EAClB,6CAA6C,EAC7C,0CAA0C,GAC3C,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,mBAAmB,EACnB,mBAAmB,EACnB,0BAA0B,EAC1B,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,gBAAgB,EAChB,iBAAiB,EACjB,mBAAmB,EACnB,yBAAyB,EACzB,wBAAwB,EACxB,cAAc,EAEd,eAAe,EACf,gBAAgB,EAChB,mBAAmB,EACnB,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAEhB,uBAAuB,EACvB,oBAAoB,EACpB,sBAAsB,EAEtB,qBAAqB,EACrB,mBAAmB,EACnB,sBAAsB,EACtB,kBAAkB,GACnB,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,sBAAsB,EACtB,oCAAoC,EACpC,4BAA4B,EAC5B,mCAAmC,EACnC,oCAAoC,EACpC,2CAA2C,EAC3C,gCAAgC,EAChC,2BAA2B,GAC5B,MAAM,4BAA4B,CAAC;AACpC,OAAO,EACL,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,uBAAuB,EACvB,gBAAgB,EAChB,YAAY,EACZ,oBAAoB,GACrB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACnD,OAAO,EAAE,gBAAgB,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAClE,OAAO,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzD,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,EACL,uBAAuB,EACvB,WAAW,EACX,kBAAkB,EAClB,0BAA0B,EAC1B,oBAAoB,EACpB,4BAA4B,EAC5B,8BAA8B,EAC9B,sCAAsC,EACtC,gCAAgC,EAChC,wCAAwC,GACzC,MAAM,iCAAiC,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A variant of useMemo that accepts a custom equality function
|
|
3
|
+
* to determine whether the dependencies have changed.
|
|
4
|
+
* @template T
|
|
5
|
+
* @param {() => T} factory - Function that computes the memoized value.
|
|
6
|
+
* @param {any} dependencies - The useMemo dependencies.
|
|
7
|
+
* @param {(prevDeps: any, nextDeps: any) => boolean} customIsEqual - Custom equality function,
|
|
8
|
+
* which receives the previous and next dependencies and returns true if they are considered equal.
|
|
9
|
+
* @returns {T} The memoized value.
|
|
10
|
+
*/
|
|
11
|
+
export function useMemoCustomComparison<T>(factory: () => T, dependencies: any, customIsEqual: (prevDeps: any, nextDeps: any) => boolean): T;
|
|
12
|
+
export function shallowDiff(prevDeps: any, nextDeps: any, depName: any): boolean;
|
|
13
|
+
export function shallowDiffByLayer(prevDeps: any, nextDeps: any, depName: any, scopeName: any): boolean;
|
|
14
|
+
export function shallowDiffByLayerWithKeys(prevDeps: any, nextDeps: any, depName: any, scopeName: any, keys: any): any;
|
|
15
|
+
export function shallowDiffByChannel(prevDeps: any, nextDeps: any, depName: any, firstName: any, secondName: any): boolean;
|
|
16
|
+
export function shallowDiffByChannelWithKeys(prevDeps: any, nextDeps: any, depName: any, firstName: any, secondName: any, keys: any): any;
|
|
17
|
+
export function shallowDiffByLayerCoordination(prevDeps: any, nextDeps: any, depName: any, layerScope: any): boolean;
|
|
18
|
+
export function shallowDiffByLayerCoordinationWithKeys(prevDeps: any, nextDeps: any, depName: any, layerScope: any, keys: any): any;
|
|
19
|
+
export function shallowDiffByChannelCoordination(prevDeps: any, nextDeps: any, depName: any, layerScope: any, channelScope: any): boolean;
|
|
20
|
+
export function shallowDiffByChannelCoordinationWithKeys(prevDeps: any, nextDeps: any, depName: any, layerScope: any, channelScope: any, keys: any): any;
|
|
21
|
+
//# sourceMappingURL=use-memo-custom-comparison.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-memo-custom-comparison.d.ts","sourceRoot":"","sources":["../src/use-memo-custom-comparison.js"],"names":[],"mappings":"AAIA;;;;;;;;;GASG;AACH,wCAPa,CAAC,WACH,MAAM,CAAC,gBACP,GAAG,iBACH,CAAC,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG,KAAK,OAAO,GAEvC,CAAC,CAUb;AAIM,iFAA4F;AAC5F,wGAEN;AAGM,uHAEN;AACM,2HAGN;AACM,0IAKN;AACM,qHAGN;AACM,oIAGN;AACM,0IAGN;AACM,yJAGN"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
/**
|
|
5
|
+
* A variant of useMemo that accepts a custom equality function
|
|
6
|
+
* to determine whether the dependencies have changed.
|
|
7
|
+
* @template T
|
|
8
|
+
* @param {() => T} factory - Function that computes the memoized value.
|
|
9
|
+
* @param {any} dependencies - The useMemo dependencies.
|
|
10
|
+
* @param {(prevDeps: any, nextDeps: any) => boolean} customIsEqual - Custom equality function,
|
|
11
|
+
* which receives the previous and next dependencies and returns true if they are considered equal.
|
|
12
|
+
* @returns {T} The memoized value.
|
|
13
|
+
*/
|
|
14
|
+
export function useMemoCustomComparison(factory, dependencies, customIsEqual) {
|
|
15
|
+
const ref = useRef(/** @type {{ deps: any; value: T } | undefined} */ (undefined));
|
|
16
|
+
if (ref.current === undefined || !customIsEqual(ref.current.deps, dependencies)) {
|
|
17
|
+
ref.current = { deps: dependencies, value: factory() };
|
|
18
|
+
}
|
|
19
|
+
return ref.current.value;
|
|
20
|
+
}
|
|
21
|
+
// Comparison utilties inspired by componentDidUpdate in spatial-beta/Spatial.js:
|
|
22
|
+
export const shallowDiff = (prevDeps, nextDeps, depName) => prevDeps[depName] !== nextDeps[depName];
|
|
23
|
+
export const shallowDiffByLayer = (prevDeps, nextDeps, depName, scopeName) => (prevDeps?.[depName]?.[scopeName] !== nextDeps?.[depName]?.[scopeName]);
|
|
24
|
+
// Rather than checking equality of the entire object,
|
|
25
|
+
// here, we only shallowly compare the specific properties that are relevant.
|
|
26
|
+
export const shallowDiffByLayerWithKeys = (prevDeps, nextDeps, depName, scopeName, keys) => keys.some(k => (prevDeps?.[depName]?.[scopeName]?.[k] !== nextDeps?.[depName]?.[scopeName]?.[k]));
|
|
27
|
+
export const shallowDiffByChannel = (prevDeps, nextDeps, depName, firstName, secondName) => (prevDeps?.[depName]?.[firstName]?.[secondName]
|
|
28
|
+
!== nextDeps?.[depName]?.[firstName]?.[secondName]);
|
|
29
|
+
export const shallowDiffByChannelWithKeys = (prevDeps, nextDeps, depName, firstName, secondName, keys) => keys.some(k => (prevDeps?.[depName]?.[firstName]?.[secondName]?.[k]
|
|
30
|
+
!== nextDeps?.[depName]?.[firstName]?.[secondName]?.[k]));
|
|
31
|
+
export const shallowDiffByLayerCoordination = (prevDeps, nextDeps, depName, layerScope) => (prevDeps?.[depName]?.[0]?.[layerScope]
|
|
32
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]);
|
|
33
|
+
export const shallowDiffByLayerCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, keys) => keys.some(k => prevDeps?.[depName]?.[0]?.[layerScope]?.[k]
|
|
34
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[k]);
|
|
35
|
+
export const shallowDiffByChannelCoordination = (prevDeps, nextDeps, depName, layerScope, channelScope) => (prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]
|
|
36
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]);
|
|
37
|
+
export const shallowDiffByChannelCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, channelScope, keys) => keys.some(k => prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k]
|
|
38
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k]);
|
|
39
|
+
//# sourceMappingURL=use-memo-custom-comparison.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"use-memo-custom-comparison.js","sourceRoot":"","sources":["../src/use-memo-custom-comparison.js"],"names":[],"mappings":"AAAA,mCAAmC;AACnC,4BAA4B;AAC5B,OAAO,EAAE,MAAM,EAAE,MAAM,OAAO,CAAC;AAE/B;;;;;;;;;GASG;AACH,MAAM,UAAU,uBAAuB,CAAC,OAAO,EAAE,YAAY,EAAE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,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,CAAC,CAAC,CACtD,CAAC;AACF,MAAM,CAAC,MAAM,gCAAgC,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,EAAE,CAAC,CACzG,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC;QAChD,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,CAC7D,CAAC;AACF,MAAM,CAAC,MAAM,wCAAwC,GAAG,CAAC,QAAQ,EAAE,QAAQ,EAAE,OAAO,EAAE,UAAU,EAAE,YAAY,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAChI,CAAC,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC;QACtD,QAAQ,EAAE,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,UAAU,CAAC,EAAE,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CACtE,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@vitessce/vit-s",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"author": "HIDIVE Lab at HMS",
|
|
5
5
|
"homepage": "http://vitessce.io",
|
|
6
6
|
"repository": {
|
|
@@ -31,17 +31,17 @@
|
|
|
31
31
|
"react-error-boundary": "^5.0.0",
|
|
32
32
|
"@placemarkio/flat-drop-files": "^1.0.2",
|
|
33
33
|
"zarrita": "0.6.1",
|
|
34
|
-
"@vitessce/
|
|
35
|
-
"@vitessce/
|
|
36
|
-
"@vitessce/
|
|
37
|
-
"@vitessce/
|
|
38
|
-
"@vitessce/
|
|
39
|
-
"@vitessce/
|
|
40
|
-
"@vitessce/zarr-utils": "4.0.
|
|
41
|
-
"@vitessce/utils": "4.0.
|
|
42
|
-
"@vitessce/
|
|
43
|
-
"@vitessce/
|
|
44
|
-
"@vitessce/
|
|
34
|
+
"@vitessce/styles": "4.0.4",
|
|
35
|
+
"@vitessce/abstract": "4.0.4",
|
|
36
|
+
"@vitessce/error": "4.0.4",
|
|
37
|
+
"@vitessce/schemas": "4.0.4",
|
|
38
|
+
"@vitessce/constants-internal": "4.0.4",
|
|
39
|
+
"@vitessce/utils": "4.0.4",
|
|
40
|
+
"@vitessce/zarr-utils": "4.0.4",
|
|
41
|
+
"@vitessce/sets-utils": "4.0.4",
|
|
42
|
+
"@vitessce/plugins": "4.0.4",
|
|
43
|
+
"@vitessce/config": "4.0.4",
|
|
44
|
+
"@vitessce/globals": "4.0.4"
|
|
45
45
|
},
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"@testing-library/jest-dom": "^6.6.3",
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
"react-dom": "19.2.6",
|
|
51
51
|
"vite": "^7.0.0",
|
|
52
52
|
"vitest": "^3.1.4",
|
|
53
|
-
"@vitessce/types": "4.0.
|
|
53
|
+
"@vitessce/types": "4.0.4"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0"
|
package/src/index.js
CHANGED
|
@@ -107,3 +107,15 @@ export { logConfig } from './view-config-utils.js';
|
|
|
107
107
|
export { useAsyncFunction, usePageModeView } from './contexts.js';
|
|
108
108
|
export { createLoaders } from './vitessce-grid-utils.js';
|
|
109
109
|
export { createOnDrop } from './on-drop.js';
|
|
110
|
+
export {
|
|
111
|
+
useMemoCustomComparison,
|
|
112
|
+
shallowDiff,
|
|
113
|
+
shallowDiffByLayer,
|
|
114
|
+
shallowDiffByLayerWithKeys,
|
|
115
|
+
shallowDiffByChannel,
|
|
116
|
+
shallowDiffByChannelWithKeys,
|
|
117
|
+
shallowDiffByLayerCoordination,
|
|
118
|
+
shallowDiffByLayerCoordinationWithKeys,
|
|
119
|
+
shallowDiffByChannelCoordination,
|
|
120
|
+
shallowDiffByChannelCoordinationWithKeys,
|
|
121
|
+
} from './use-memo-custom-comparison.js';
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/* eslint-disable no-unused-vars */
|
|
2
|
+
/* eslint-disable max-len */
|
|
3
|
+
import { useRef } from 'react';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* A variant of useMemo that accepts a custom equality function
|
|
7
|
+
* to determine whether the dependencies have changed.
|
|
8
|
+
* @template T
|
|
9
|
+
* @param {() => T} factory - Function that computes the memoized value.
|
|
10
|
+
* @param {any} dependencies - The useMemo dependencies.
|
|
11
|
+
* @param {(prevDeps: any, nextDeps: any) => boolean} customIsEqual - Custom equality function,
|
|
12
|
+
* which receives the previous and next dependencies and returns true if they are considered equal.
|
|
13
|
+
* @returns {T} The memoized value.
|
|
14
|
+
*/
|
|
15
|
+
export function useMemoCustomComparison(factory, dependencies, customIsEqual) {
|
|
16
|
+
const ref = useRef(/** @type {{ deps: any; value: T } | undefined} */ (undefined));
|
|
17
|
+
|
|
18
|
+
if (ref.current === undefined || !customIsEqual(ref.current.deps, dependencies)) {
|
|
19
|
+
ref.current = { deps: dependencies, value: factory() };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return ref.current.value;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
// Comparison utilties inspired by componentDidUpdate in spatial-beta/Spatial.js:
|
|
27
|
+
export const shallowDiff = (prevDeps, nextDeps, depName) => prevDeps[depName] !== nextDeps[depName];
|
|
28
|
+
export const shallowDiffByLayer = (prevDeps, nextDeps, depName, scopeName) => (
|
|
29
|
+
prevDeps?.[depName]?.[scopeName] !== nextDeps?.[depName]?.[scopeName]
|
|
30
|
+
);
|
|
31
|
+
// Rather than checking equality of the entire object,
|
|
32
|
+
// here, we only shallowly compare the specific properties that are relevant.
|
|
33
|
+
export const shallowDiffByLayerWithKeys = (prevDeps, nextDeps, depName, scopeName, keys) => keys.some(
|
|
34
|
+
k => (prevDeps?.[depName]?.[scopeName]?.[k] !== nextDeps?.[depName]?.[scopeName]?.[k]),
|
|
35
|
+
);
|
|
36
|
+
export const shallowDiffByChannel = (prevDeps, nextDeps, depName, firstName, secondName) => (
|
|
37
|
+
prevDeps?.[depName]?.[firstName]?.[secondName]
|
|
38
|
+
!== nextDeps?.[depName]?.[firstName]?.[secondName]
|
|
39
|
+
);
|
|
40
|
+
export const shallowDiffByChannelWithKeys = (prevDeps, nextDeps, depName, firstName, secondName, keys) => keys.some(
|
|
41
|
+
k => (
|
|
42
|
+
prevDeps?.[depName]?.[firstName]?.[secondName]?.[k]
|
|
43
|
+
!== nextDeps?.[depName]?.[firstName]?.[secondName]?.[k]
|
|
44
|
+
),
|
|
45
|
+
);
|
|
46
|
+
export const shallowDiffByLayerCoordination = (prevDeps, nextDeps, depName, layerScope) => (
|
|
47
|
+
prevDeps?.[depName]?.[0]?.[layerScope]
|
|
48
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]
|
|
49
|
+
);
|
|
50
|
+
export const shallowDiffByLayerCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, keys) => keys.some(
|
|
51
|
+
k => prevDeps?.[depName]?.[0]?.[layerScope]?.[k]
|
|
52
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[k],
|
|
53
|
+
);
|
|
54
|
+
export const shallowDiffByChannelCoordination = (prevDeps, nextDeps, depName, layerScope, channelScope) => (
|
|
55
|
+
prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]
|
|
56
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]
|
|
57
|
+
);
|
|
58
|
+
export const shallowDiffByChannelCoordinationWithKeys = (prevDeps, nextDeps, depName, layerScope, channelScope, keys) => keys.some(
|
|
59
|
+
k => prevDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k]
|
|
60
|
+
!== nextDeps?.[depName]?.[0]?.[layerScope]?.[channelScope]?.[k],
|
|
61
|
+
);
|