@vitessce/utils 4.0.8 → 4.0.10

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 CHANGED
@@ -1001,6 +1001,12 @@ function filterValidExpressionArrays(arrays) {
1001
1001
  }
1002
1002
  return arrays.filter((arr) => arr && (Array.isArray(arr) || ArrayBuffer.isView(arr)) && arr.length > 0);
1003
1003
  }
1004
+ function getAnnotationFrameCoordinationValues(annotationStory, annotationFrameIndex, viewUid) {
1005
+ if (typeof annotationFrameIndex !== "number") {
1006
+ return void 0;
1007
+ }
1008
+ return annotationStory?.frames?.[annotationFrameIndex]?.layout?.find((v) => v.uid === viewUid)?.coordinationValues;
1009
+ }
1004
1010
  export {
1005
1011
  COLORMAP_OPTIONS,
1006
1012
  DEFAULT_DARK_COLOR,
@@ -1032,6 +1038,7 @@ export {
1032
1038
  filterValidExpressionArrays,
1033
1039
  formatBytes,
1034
1040
  getAllocationBudgetBytes,
1041
+ getAnnotationFrameCoordinationValues,
1035
1042
  getDefaultColor,
1036
1043
  getDefaultForegroundColor,
1037
1044
  getInitialCoordinationScopeName,
@@ -0,0 +1,21 @@
1
+ type AnnotationFrameView = {
2
+ uid: string;
3
+ coordinationValues?: Record<string, unknown>;
4
+ };
5
+ type AnnotationStory = {
6
+ frames?: Array<{
7
+ layout?: AnnotationFrameView[];
8
+ }>;
9
+ };
10
+ /**
11
+ * Get the coordination values that the current annotation frame
12
+ * defines for a particular view.
13
+ * @param annotationStory The annotation story object.
14
+ * @param annotationFrameIndex The index of the current frame, or null if no frame is active.
15
+ * @param viewUid The uid of the view of interest.
16
+ * @returns The per-view coordination values for the frame,
17
+ * or undefined if no frame is active or the frame does not include the view.
18
+ */
19
+ export declare function getAnnotationFrameCoordinationValues(annotationStory: AnnotationStory | null | undefined, annotationFrameIndex: number | null | undefined, viewUid: string): Record<string, unknown> | undefined;
20
+ export {};
21
+ //# sourceMappingURL=annotation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.d.ts","sourceRoot":"","sources":["../src/annotation.ts"],"names":[],"mappings":"AAAA,KAAK,mBAAmB,GAAG;IACzB,GAAG,EAAE,MAAM,CAAC;IACZ,kBAAkB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9C,CAAC;AAEF,KAAK,eAAe,GAAG;IACrB,MAAM,CAAC,EAAE,KAAK,CAAC;QAAE,MAAM,CAAC,EAAE,mBAAmB,EAAE,CAAA;KAAE,CAAC,CAAC;CACpD,CAAC;AAEF;;;;;;;;GAQG;AACH,wBAAgB,oCAAoC,CAClD,eAAe,EAAE,eAAe,GAAG,IAAI,GAAG,SAAS,EACnD,oBAAoB,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAC/C,OAAO,EAAE,MAAM,GACd,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CAOrC"}
@@ -0,0 +1,18 @@
1
+ /**
2
+ * Get the coordination values that the current annotation frame
3
+ * defines for a particular view.
4
+ * @param annotationStory The annotation story object.
5
+ * @param annotationFrameIndex The index of the current frame, or null if no frame is active.
6
+ * @param viewUid The uid of the view of interest.
7
+ * @returns The per-view coordination values for the frame,
8
+ * or undefined if no frame is active or the frame does not include the view.
9
+ */
10
+ export function getAnnotationFrameCoordinationValues(annotationStory, annotationFrameIndex, viewUid) {
11
+ if (typeof annotationFrameIndex !== 'number') {
12
+ return undefined;
13
+ }
14
+ return annotationStory?.frames?.[annotationFrameIndex]?.layout
15
+ ?.find(v => v.uid === viewUid)
16
+ ?.coordinationValues;
17
+ }
18
+ //# sourceMappingURL=annotation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.js","sourceRoot":"","sources":["../src/annotation.ts"],"names":[],"mappings":"AASA;;;;;;;;GAQG;AACH,MAAM,UAAU,oCAAoC,CAClD,eAAmD,EACnD,oBAA+C,EAC/C,OAAe;IAEf,IAAI,OAAO,oBAAoB,KAAK,QAAQ,EAAE,CAAC;QAC7C,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,OAAO,eAAe,EAAE,MAAM,EAAE,CAAC,oBAAoB,CAAC,EAAE,MAAM;QAC5D,EAAE,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,KAAK,OAAO,CAAC;QAC9B,EAAE,kBAAkB,CAAC;AACzB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=annotation.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.test.d.ts","sourceRoot":"","sources":["../src/annotation.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { getAnnotationFrameCoordinationValues } from './annotation.js';
3
+ const story = {
4
+ uid: 'story',
5
+ frames: [
6
+ {
7
+ uid: 'frame-0',
8
+ layout: [
9
+ { uid: 'spatial', coordinationValues: { spatialZoom: -2 } },
10
+ ],
11
+ },
12
+ { uid: 'frame-1' },
13
+ ],
14
+ };
15
+ describe('getAnnotationFrameCoordinationValues', () => {
16
+ it('returns the coordination values for the view in the current frame', () => {
17
+ expect(getAnnotationFrameCoordinationValues(story, 0, 'spatial'))
18
+ .toEqual({ spatialZoom: -2 });
19
+ });
20
+ it('returns undefined when the frame does not include the view', () => {
21
+ expect(getAnnotationFrameCoordinationValues(story, 0, 'scatterplot')).toBeUndefined();
22
+ expect(getAnnotationFrameCoordinationValues(story, 1, 'spatial')).toBeUndefined();
23
+ });
24
+ it('returns undefined when no frame is active or no story is loaded', () => {
25
+ expect(getAnnotationFrameCoordinationValues(story, null, 'spatial')).toBeUndefined();
26
+ expect(getAnnotationFrameCoordinationValues(null, 0, 'spatial')).toBeUndefined();
27
+ });
28
+ });
29
+ //# sourceMappingURL=annotation.test.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"annotation.test.js","sourceRoot":"","sources":["../src/annotation.test.ts"],"names":[],"mappings":"AAAA,OAAO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ction, VALUE_TRANSFORM_OPTIONS, } from './gating.js
4
4
  export { default as Pool } from './Pool.js';
5
5
  export { DEFAULT_MAX_ALLOCATION_BYTES, getJsHeapSizeLimit, getAllocationBudgetBytes, exceedsAllocationBudget, } from './memory.js';
6
6
  export { aggregateFeatureArrays, normalizeAggregatedFeatureArray, filterValidExpressionArrays, } from './expr.js';
7
+ export { getAnnotationFrameCoordinationValues } from './annotation.js';
7
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,SAAS,EACT,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,SAAS,EACT,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC"}
package/dist-tsc/index.js CHANGED
@@ -6,4 +6,5 @@ export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js
6
6
  export { default as Pool } from './Pool.js';
7
7
  export { DEFAULT_MAX_ALLOCATION_BYTES, getJsHeapSizeLimit, getAllocationBudgetBytes, exceedsAllocationBudget, } from './memory.js';
8
8
  export { aggregateFeatureArrays, normalizeAggregatedFeatureArray, filterValidExpressionArrays, } from './expr.js';
9
+ export { getAnnotationFrameCoordinationValues } from './annotation.js';
9
10
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,SAAS,EACT,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,gEAAgE;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,gEAAgE;AAChE,OAAO,EACL,WAAW,EACX,UAAU,EACV,SAAS,EACT,cAAc,EACd,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,EAC/B,SAAS,EACT,yBAAyB,GAC1B,MAAM,WAAW,CAAC;AACnB,gEAAgE;AAChE,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,iBAAiB,EACjB,uBAAuB,EACvB,gBAAgB,EAChB,kBAAkB,EAClB,yBAAyB,EACzB,iCAAiC,EACjC,6BAA6B,EAC7B,6BAA6B,EAC7B,8BAA8B,EAC9B,2BAA2B,EAC3B,4BAA4B,EAC5B,cAAc,EACd,UAAU,EACV,WAAW,GACZ,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,yBAAyB,EACzB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC;AAC5C,OAAO,EACL,4BAA4B,EAC5B,kBAAkB,EAClB,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,sBAAsB,EACtB,+BAA+B,EAC/B,2BAA2B,GAC5B,MAAM,WAAW,CAAC;AACnB,OAAO,EAAE,oCAAoC,EAAE,MAAM,iBAAiB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/utils",
3
- "version": "4.0.8",
3
+ "version": "4.0.10",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -21,7 +21,7 @@
21
21
  "lz-string": "^1.4.4",
22
22
  "pluralize": "^8.0.0",
23
23
  "d3-array": "^2.4.0",
24
- "@vitessce/globals": "4.0.8"
24
+ "@vitessce/globals": "4.0.10"
25
25
  },
26
26
  "scripts": {
27
27
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.mjs",
@@ -0,0 +1,32 @@
1
+ import { describe, it, expect } from 'vitest';
2
+ import { getAnnotationFrameCoordinationValues } from './annotation.js';
3
+
4
+ const story = {
5
+ uid: 'story',
6
+ frames: [
7
+ {
8
+ uid: 'frame-0',
9
+ layout: [
10
+ { uid: 'spatial', coordinationValues: { spatialZoom: -2 } },
11
+ ],
12
+ },
13
+ { uid: 'frame-1' },
14
+ ],
15
+ };
16
+
17
+ describe('getAnnotationFrameCoordinationValues', () => {
18
+ it('returns the coordination values for the view in the current frame', () => {
19
+ expect(getAnnotationFrameCoordinationValues(story, 0, 'spatial'))
20
+ .toEqual({ spatialZoom: -2 });
21
+ });
22
+
23
+ it('returns undefined when the frame does not include the view', () => {
24
+ expect(getAnnotationFrameCoordinationValues(story, 0, 'scatterplot')).toBeUndefined();
25
+ expect(getAnnotationFrameCoordinationValues(story, 1, 'spatial')).toBeUndefined();
26
+ });
27
+
28
+ it('returns undefined when no frame is active or no story is loaded', () => {
29
+ expect(getAnnotationFrameCoordinationValues(story, null, 'spatial')).toBeUndefined();
30
+ expect(getAnnotationFrameCoordinationValues(null, 0, 'spatial')).toBeUndefined();
31
+ });
32
+ });
@@ -0,0 +1,30 @@
1
+ type AnnotationFrameView = {
2
+ uid: string;
3
+ coordinationValues?: Record<string, unknown>;
4
+ };
5
+
6
+ type AnnotationStory = {
7
+ frames?: Array<{ layout?: AnnotationFrameView[] }>;
8
+ };
9
+
10
+ /**
11
+ * Get the coordination values that the current annotation frame
12
+ * defines for a particular view.
13
+ * @param annotationStory The annotation story object.
14
+ * @param annotationFrameIndex The index of the current frame, or null if no frame is active.
15
+ * @param viewUid The uid of the view of interest.
16
+ * @returns The per-view coordination values for the frame,
17
+ * or undefined if no frame is active or the frame does not include the view.
18
+ */
19
+ export function getAnnotationFrameCoordinationValues(
20
+ annotationStory: AnnotationStory | null | undefined,
21
+ annotationFrameIndex: number | null | undefined,
22
+ viewUid: string,
23
+ ): Record<string, unknown> | undefined {
24
+ if (typeof annotationFrameIndex !== 'number') {
25
+ return undefined;
26
+ }
27
+ return annotationStory?.frames?.[annotationFrameIndex]?.layout
28
+ ?.find(v => v.uid === viewUid)
29
+ ?.coordinationValues;
30
+ }
package/src/index.ts CHANGED
@@ -52,3 +52,4 @@ export {
52
52
  normalizeAggregatedFeatureArray,
53
53
  filterValidExpressionArrays,
54
54
  } from './expr.js';
55
+ export { getAnnotationFrameCoordinationValues } from './annotation.js';