@vitessce/vit-s 4.0.7 → 4.0.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.
Files changed (42) hide show
  1. package/dist/index.js +560 -65
  2. package/dist-tsc/VitS.d.ts +3 -0
  3. package/dist-tsc/VitS.d.ts.map +1 -1
  4. package/dist-tsc/VitS.js +4 -2
  5. package/dist-tsc/VitS.js.map +1 -1
  6. package/dist-tsc/VitessceGrid.d.ts.map +1 -1
  7. package/dist-tsc/VitessceGrid.js +2 -2
  8. package/dist-tsc/VitessceGrid.js.map +1 -1
  9. package/dist-tsc/data-hooks.d.ts +13 -0
  10. package/dist-tsc/data-hooks.d.ts.map +1 -1
  11. package/dist-tsc/data-hooks.js +15 -0
  12. package/dist-tsc/data-hooks.js.map +1 -1
  13. package/dist-tsc/hooks.d.ts +6 -1
  14. package/dist-tsc/hooks.d.ts.map +1 -1
  15. package/dist-tsc/hooks.js +52 -22
  16. package/dist-tsc/hooks.js.map +1 -1
  17. package/dist-tsc/hooks.test.js +100 -3
  18. package/dist-tsc/hooks.test.js.map +1 -1
  19. package/dist-tsc/index.d.ts +2 -2
  20. package/dist-tsc/index.js +2 -2
  21. package/dist-tsc/index.js.map +1 -1
  22. package/dist-tsc/state/annotation-frames.test.d.ts +2 -0
  23. package/dist-tsc/state/annotation-frames.test.d.ts.map +1 -0
  24. package/dist-tsc/state/annotation-frames.test.js +171 -0
  25. package/dist-tsc/state/annotation-frames.test.js.map +1 -0
  26. package/dist-tsc/state/hooks.d.ts +101 -4
  27. package/dist-tsc/state/hooks.d.ts.map +1 -1
  28. package/dist-tsc/state/hooks.js +344 -13
  29. package/dist-tsc/state/hooks.js.map +1 -1
  30. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.d.ts.map +1 -1
  31. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.js +4 -4
  32. package/dist-tsc/vitessce-grid-layout/VitessceGridLayout.js.map +1 -1
  33. package/package.json +13 -13
  34. package/src/VitS.js +4 -0
  35. package/src/VitessceGrid.js +2 -0
  36. package/src/data-hooks.js +23 -0
  37. package/src/hooks.js +55 -23
  38. package/src/hooks.test.jsx +114 -3
  39. package/src/index.js +4 -0
  40. package/src/state/annotation-frames.test.js +185 -0
  41. package/src/state/hooks.js +395 -9
  42. package/src/vitessce-grid-layout/VitessceGridLayout.js +4 -2
package/dist/index.js CHANGED
@@ -3291,7 +3291,7 @@ function requireReactIs() {
3291
3291
  return reactIs.exports;
3292
3292
  }
3293
3293
  var reactIsExports = /* @__PURE__ */ requireReactIs();
3294
- function isPlainObject$1(item) {
3294
+ function isPlainObject$2(item) {
3295
3295
  if (typeof item !== "object" || item === null) {
3296
3296
  return false;
3297
3297
  }
@@ -3299,7 +3299,7 @@ function isPlainObject$1(item) {
3299
3299
  return (prototype === null || prototype === Object.prototype || Object.getPrototypeOf(prototype) === null) && !(Symbol.toStringTag in item) && !(Symbol.iterator in item);
3300
3300
  }
3301
3301
  function deepClone(source) {
3302
- if (/* @__PURE__ */ React$1.isValidElement(source) || reactIsExports.isValidElementType(source) || !isPlainObject$1(source)) {
3302
+ if (/* @__PURE__ */ React$1.isValidElement(source) || reactIsExports.isValidElementType(source) || !isPlainObject$2(source)) {
3303
3303
  return source;
3304
3304
  }
3305
3305
  const output = {};
@@ -3314,15 +3314,15 @@ function deepmerge(target, source, options = {
3314
3314
  const output = options.clone ? {
3315
3315
  ...target
3316
3316
  } : target;
3317
- if (isPlainObject$1(target) && isPlainObject$1(source)) {
3317
+ if (isPlainObject$2(target) && isPlainObject$2(source)) {
3318
3318
  Object.keys(source).forEach((key) => {
3319
3319
  if (/* @__PURE__ */ React$1.isValidElement(source[key]) || reactIsExports.isValidElementType(source[key])) {
3320
3320
  output[key] = source[key];
3321
- } else if (isPlainObject$1(source[key]) && // Avoid prototype pollution
3322
- Object.prototype.hasOwnProperty.call(target, key) && isPlainObject$1(target[key])) {
3321
+ } else if (isPlainObject$2(source[key]) && // Avoid prototype pollution
3322
+ Object.prototype.hasOwnProperty.call(target, key) && isPlainObject$2(target[key])) {
3323
3323
  output[key] = deepmerge(target[key], source[key], options);
3324
3324
  } else if (options.clone) {
3325
- output[key] = isPlainObject$1(source[key]) ? deepClone(source[key]) : source[key];
3325
+ output[key] = isPlainObject$2(source[key]) ? deepClone(source[key]) : source[key];
3326
3326
  } else {
3327
3327
  output[key] = source[key];
3328
3328
  }
@@ -4537,7 +4537,7 @@ function extendSxProp$1(props) {
4537
4537
  } else if (typeof inSx === "function") {
4538
4538
  finalSx = (...args) => {
4539
4539
  const result = inSx(...args);
4540
- if (!isPlainObject$1(result)) {
4540
+ if (!isPlainObject$2(result)) {
4541
4541
  return systemProps;
4542
4542
  }
4543
4543
  return {
@@ -4804,7 +4804,7 @@ function createStyled2(input = {}) {
4804
4804
  return processStyle(props, style2);
4805
4805
  };
4806
4806
  }
4807
- if (isPlainObject$1(style2)) {
4807
+ if (isPlainObject$2(style2)) {
4808
4808
  const serialized = preprocessStyles(style2);
4809
4809
  if (!serialized.variants) {
4810
4810
  return serialized.style;
@@ -6900,7 +6900,7 @@ const zIndex = {
6900
6900
  tooltip: 1500
6901
6901
  };
6902
6902
  function isSerializable(val) {
6903
- return isPlainObject$1(val) || typeof val === "undefined" || typeof val === "string" || typeof val === "boolean" || typeof val === "number" || Array.isArray(val);
6903
+ return isPlainObject$2(val) || typeof val === "undefined" || typeof val === "string" || typeof val === "boolean" || typeof val === "number" || Array.isArray(val);
6904
6904
  }
6905
6905
  function stringifyTheme(baseTheme = {}) {
6906
6906
  const serializableTheme = {
@@ -6912,7 +6912,7 @@ function stringifyTheme(baseTheme = {}) {
6912
6912
  const [key, value] = array[index];
6913
6913
  if (!isSerializable(value) || key.startsWith("unstable_")) {
6914
6914
  delete object[key];
6915
- } else if (isPlainObject$1(value)) {
6915
+ } else if (isPlainObject$2(value)) {
6916
6916
  object[key] = {
6917
6917
  ...value
6918
6918
  };
@@ -21821,6 +21821,13 @@ const withConsolidatedMetadata = defineStoreExtension(async (store, opts = {}) =
21821
21821
  function extendStore(store, ...extensions) {
21822
21822
  return applyExtensions(store, extensions);
21823
21823
  }
21824
+ async function relaxedFetch(...args) {
21825
+ const response = await fetch(...args);
21826
+ if (response.status === 403) {
21827
+ return new Response(null, { status: 404 });
21828
+ }
21829
+ return response;
21830
+ }
21824
21831
  function transformEntriesForZipFileStore(entries) {
21825
21832
  const topLevelZarrDirectories = new Set(Object.keys(entries).map((k) => k.split("/")[0]).filter((firstPathItem) => firstPathItem?.endsWith(".zarr")));
21826
21833
  if (topLevelZarrDirectories.size === 0) {
@@ -21951,7 +21958,7 @@ function hashQueryKeyByOptions(queryKey, options) {
21951
21958
  function hashKey(queryKey) {
21952
21959
  return JSON.stringify(
21953
21960
  queryKey,
21954
- (_, val) => isPlainObject(val) ? Object.keys(val).sort().reduce((result, key) => {
21961
+ (_, val) => isPlainObject$1(val) ? Object.keys(val).sort().reduce((result, key) => {
21955
21962
  result[key] = val[key];
21956
21963
  return result;
21957
21964
  }, {}) : val
@@ -21974,7 +21981,7 @@ function replaceEqualDeep(a2, b) {
21974
21981
  return a2;
21975
21982
  }
21976
21983
  const array = isPlainArray(a2) && isPlainArray(b);
21977
- if (array || isPlainObject(a2) && isPlainObject(b)) {
21984
+ if (array || isPlainObject$1(a2) && isPlainObject$1(b)) {
21978
21985
  const aItems = array ? a2 : Object.keys(a2);
21979
21986
  const aSize = aItems.length;
21980
21987
  const bItems = array ? b : Object.keys(b);
@@ -22012,7 +22019,7 @@ function shallowEqualObjects(a2, b) {
22012
22019
  function isPlainArray(value) {
22013
22020
  return Array.isArray(value) && value.length === Object.keys(value).length;
22014
22021
  }
22015
- function isPlainObject(o2) {
22022
+ function isPlainObject$1(o2) {
22016
22023
  if (!hasObjectPrototype(o2)) {
22017
22024
  return false;
22018
22025
  }
@@ -29975,7 +29982,7 @@ const latestFileDefSchema = z.object({
29975
29982
  options: fileOptionsSchema.optional(),
29976
29983
  requestInit: requestInit.optional(),
29977
29984
  // New: file def can have coordinationValues.
29978
- coordinationValues: z.record(z.string()).optional()
29985
+ coordinationValues: z.record(z.any()).optional()
29979
29986
  });
29980
29987
  const datasetsSchema1_0_13 = z.array(z.object({
29981
29988
  uid: z.string(),
@@ -30006,7 +30013,8 @@ const configSchema1_0_16 = configSchema1_0_13.extend({
30006
30013
  h: z.number().int().optional(),
30007
30014
  // Updates coordinationScopes and coordinationScopesBy
30008
30015
  coordinationScopes: componentCoordinationScopes.optional(),
30009
- coordinationScopesBy: componentCoordinationScopesBy.optional()
30016
+ coordinationScopesBy: componentCoordinationScopesBy.optional(),
30017
+ coordinationValues: z.record(z.any()).optional()
30010
30018
  }))
30011
30019
  });
30012
30020
  const configSchema1_0_17 = configSchema1_0_16.extend({
@@ -30763,6 +30771,12 @@ function extent(values2, valueof) {
30763
30771
  }
30764
30772
  return [min2, max2];
30765
30773
  }
30774
+ function getAnnotationFrameCoordinationValues(annotationStory, annotationFrameIndex, viewUid) {
30775
+ if (typeof annotationFrameIndex !== "number") {
30776
+ return void 0;
30777
+ }
30778
+ return annotationStory?.frames?.[annotationFrameIndex]?.layout?.find((v) => v.uid === viewUid)?.coordinationValues;
30779
+ }
30766
30780
  configSchema1_0_0.shape.coordinationSpace.unwrap();
30767
30781
  configSchema1_0_0.shape.layout.element.shape.coordinationScopes.unwrap();
30768
30782
  function upgradeReplaceViewProp(prefix2, view, coordinationSpace) {
@@ -33260,7 +33274,9 @@ const ViewType$1 = {
33260
33274
  DUAL_SCATTERPLOT: "dualScatterplot",
33261
33275
  TREEMAP: "treemap",
33262
33276
  SAMPLE_SET_PAIR_MANAGER: "sampleSetPairManager",
33263
- FEATURE_STATS_TABLE: "featureStatsTable"
33277
+ FEATURE_STATS_TABLE: "featureStatsTable",
33278
+ SINGLE_OBS_SET_SELECTOR: "singleObsSetSelector",
33279
+ ANNOTATION_CONTROLLER: "annotationController"
33264
33280
  };
33265
33281
  const DataType$1 = {
33266
33282
  OBS_LABELS: "obsLabels",
@@ -33281,7 +33297,8 @@ const DataType$1 = {
33281
33297
  COMPARISON_METADATA: "comparisonMetadata",
33282
33298
  FEATURE_STATS: "featureStats",
33283
33299
  FEATURE_SET_STATS: "featureSetStats",
33284
- OBS_SET_STATS: "obsSetStats"
33300
+ OBS_SET_STATS: "obsSetStats",
33301
+ ANNOTATION_STORY: "annotationStory"
33285
33302
  };
33286
33303
  const AsyncFunctionType = {
33287
33304
  GET_TERM_MAPPING: "getTermMapping"
@@ -33306,6 +33323,7 @@ const FileType$1 = {
33306
33323
  OBS_SETS_CSV: "obsSets.csv",
33307
33324
  OBS_SETS_JSON: "obsSets.json",
33308
33325
  SAMPLE_SETS_CSV: "sampleSets.csv",
33326
+ ANNOTATION_STORY_JSON: "annotationStory.json",
33309
33327
  // OME-Zarr
33310
33328
  IMAGE_OME_ZARR: "image.ome-zarr",
33311
33329
  OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
@@ -33590,7 +33608,15 @@ const CoordinationType$1 = {
33590
33608
  FEATURE_POINT_FOLD_CHANGE_THRESHOLD: "featurePointFoldChangeThreshold",
33591
33609
  FEATURE_LABEL_FOLD_CHANGE_THRESHOLD: "featureLabelFoldChangeThreshold",
33592
33610
  // Treemap
33593
- HIERARCHY_LEVELS: "hierarchyLevels"
33611
+ HIERARCHY_LEVELS: "hierarchyLevels",
33612
+ // Annotation frames
33613
+ ANNOTATION_STORY: "annotationStory",
33614
+ ANNOTATION_FRAME_INDEX: "annotationFrameIndex",
33615
+ ANNOTATION_SHAPES: "annotationShapes",
33616
+ ANNOTATION_OVERLAY_VISIBLE: "annotationOverlayVisible",
33617
+ ANNOTATION_TRANSITION_DURATION: "annotationTransitionDuration",
33618
+ ANNOTATION_SEMANTIC_ZOOM: "annotationSemanticZoom",
33619
+ ANNOTATION_EDITABLE: "annotationEditable"
33594
33620
  };
33595
33621
  const STATUS = {
33596
33622
  LOADING: "loading",
@@ -33611,6 +33637,7 @@ const STATUS = {
33611
33637
  [FileType$1.OBS_SEGMENTATIONS_JSON]: DataType$1.OBS_SEGMENTATIONS,
33612
33638
  [FileType$1.OBS_SETS_CSV]: DataType$1.OBS_SETS,
33613
33639
  [FileType$1.OBS_SETS_JSON]: DataType$1.OBS_SETS,
33640
+ [FileType$1.ANNOTATION_STORY_JSON]: DataType$1.ANNOTATION_STORY,
33614
33641
  [FileType$1.IMAGE_OME_ZARR]: DataType$1.IMAGE,
33615
33642
  [FileType$1.OBS_SEGMENTATIONS_OME_ZARR]: DataType$1.OBS_SEGMENTATIONS,
33616
33643
  [FileType$1.OBS_FEATURE_MATRIX_ANNDATA_ZARR]: DataType$1.OBS_FEATURE_MATRIX,
@@ -33733,7 +33760,8 @@ const DATA_TYPE_COORDINATION_VALUE_USAGE = {
33733
33760
  [DataType$1.OBS_SET_STATS]: [
33734
33761
  CoordinationType$1.OBS_TYPE
33735
33762
  // TODO: should sampleType, obsSetSelection, and/or sampleSetSelection be used here?
33736
- ]
33763
+ ],
33764
+ [DataType$1.ANNOTATION_STORY]: []
33737
33765
  };
33738
33766
  ({
33739
33767
  // For AnnData:
@@ -33866,7 +33894,9 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
33866
33894
  CoordinationType$1.SPATIAL_TARGET_Z,
33867
33895
  CoordinationType$1.SPATIAL_AXIS_FIXED,
33868
33896
  CoordinationType$1.SPATIAL_ORBIT_AXIS,
33869
- CoordinationType$1.FEATURE_AGGREGATION_STRATEGY
33897
+ CoordinationType$1.FEATURE_AGGREGATION_STRATEGY,
33898
+ // Annotation shapes are specific to a view's coordinate system.
33899
+ CoordinationType$1.ANNOTATION_SHAPES
33870
33900
  ];
33871
33901
  ({
33872
33902
  [ViewType$1.NEUROGLANCER]: [
@@ -33958,7 +33988,14 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
33958
33988
  CoordinationType$1.EMBEDDING_CONTOURS_FILLED,
33959
33989
  CoordinationType$1.EMBEDDING_CONTOUR_PERCENTILES,
33960
33990
  CoordinationType$1.CONTOUR_COLOR_ENCODING,
33961
- CoordinationType$1.CONTOUR_COLOR
33991
+ CoordinationType$1.CONTOUR_COLOR,
33992
+ CoordinationType$1.ANNOTATION_STORY,
33993
+ CoordinationType$1.ANNOTATION_SHAPES,
33994
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
33995
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
33996
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
33997
+ CoordinationType$1.ANNOTATION_EDITABLE,
33998
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
33962
33999
  ],
33963
34000
  [ViewType$1.DUAL_SCATTERPLOT]: [
33964
34001
  CoordinationType$1.DATASET,
@@ -34074,7 +34111,14 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
34074
34111
  CoordinationType$1.ADDITIONAL_OBS_SETS,
34075
34112
  CoordinationType$1.MOLECULE_HIGHLIGHT,
34076
34113
  CoordinationType$1.TOOLTIPS_VISIBLE,
34077
- CoordinationType$1.PHOTOMETRIC_INTERPRETATION
34114
+ CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
34115
+ CoordinationType$1.ANNOTATION_STORY,
34116
+ CoordinationType$1.ANNOTATION_SHAPES,
34117
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
34118
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
34119
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
34120
+ CoordinationType$1.ANNOTATION_EDITABLE,
34121
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
34078
34122
  ],
34079
34123
  [ViewType$1.SPATIAL_BETA]: [
34080
34124
  CoordinationType$1.META_COORDINATION_SCOPES,
@@ -34152,7 +34196,27 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
34152
34196
  CoordinationType$1.SPATIAL_CHANNEL_LABELS_ORIENTATION,
34153
34197
  CoordinationType$1.SPATIAL_CHANNEL_LABEL_SIZE,
34154
34198
  CoordinationType$1.SPATIAL_CHANNELS_SORT_ORDER,
34155
- CoordinationType$1.PHOTOMETRIC_INTERPRETATION
34199
+ CoordinationType$1.PHOTOMETRIC_INTERPRETATION,
34200
+ CoordinationType$1.ANNOTATION_STORY,
34201
+ CoordinationType$1.ANNOTATION_SHAPES,
34202
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
34203
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
34204
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
34205
+ CoordinationType$1.ANNOTATION_EDITABLE,
34206
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
34207
+ ],
34208
+ [ViewType$1.ANNOTATION_CONTROLLER]: [
34209
+ CoordinationType$1.DATASET,
34210
+ CoordinationType$1.ANNOTATION_STORY,
34211
+ CoordinationType$1.ANNOTATION_FRAME_INDEX,
34212
+ CoordinationType$1.ANNOTATION_OVERLAY_VISIBLE,
34213
+ CoordinationType$1.ANNOTATION_TRANSITION_DURATION,
34214
+ CoordinationType$1.ANNOTATION_EDITABLE,
34215
+ CoordinationType$1.ANNOTATION_SEMANTIC_ZOOM
34216
+ // Note: the annotation controller also needs to read the coordination state
34217
+ // of all other views/coordination types via the full config.
34218
+ // Note: we get/set the CoordinationType.ANNOTATION_SHAPES from the full config,
34219
+ // as this info is view-specific rather than global to the story.
34156
34220
  ],
34157
34221
  [ViewType$1.HEATMAP]: [
34158
34222
  CoordinationType$1.DATASET,
@@ -34462,6 +34526,11 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
34462
34526
  CoordinationType$1.FEATURE_POINT_FOLD_CHANGE_THRESHOLD,
34463
34527
  CoordinationType$1.FEATURE_LABEL_FOLD_CHANGE_THRESHOLD
34464
34528
  ],
34529
+ [ViewType$1.SINGLE_OBS_SET_SELECTOR]: [
34530
+ CoordinationType$1.OBS_TYPE,
34531
+ CoordinationType$1.OBS_SET_COLOR,
34532
+ CoordinationType$1.OBS_SET_SELECTION
34533
+ ],
34465
34534
  [ViewType$1.OBS_SET_COMPOSITION_BAR_PLOT]: [
34466
34535
  CoordinationType$1.DATASET,
34467
34536
  CoordinationType$1.OBS_TYPE,
@@ -34556,7 +34625,7 @@ const AUTO_INDEPENDENT_COORDINATION_TYPES = [
34556
34625
  CoordinationType$1.HIERARCHY_LEVELS
34557
34626
  ]
34558
34627
  });
34559
- const version = "4.0.7";
34628
+ const version = "4.0.9";
34560
34629
  const META_VERSION = {
34561
34630
  version
34562
34631
  };
@@ -34817,7 +34886,15 @@ function buildConfigSchema(pluginFileTypes, pluginJointFileTypes, pluginCoordina
34817
34886
  w: z.number().int().optional(),
34818
34887
  h: z.number().int().optional(),
34819
34888
  coordinationScopes: componentCoordinationScopes.optional(),
34820
- coordinationScopesBy: componentCoordinationScopesBy.optional()
34889
+ coordinationScopesBy: componentCoordinationScopesBy.optional(),
34890
+ coordinationValues: z.object(
34891
+ // For view-level coordinationValues, the value schemas are used directly
34892
+ // (there is no coordination scope name as an intermediary).
34893
+ Object.fromEntries(pluginCoordinationTypes.map((ct) => [
34894
+ ct.name,
34895
+ ct.valueSchema.optional()
34896
+ ]))
34897
+ ).describe("Mapping from coordination types to values, for values which do not need to be coordinated with other views. These take precedence over coordinationScopes.").optional()
34821
34898
  })).describe("The layout array defines the views, or components, rendered in the grid."),
34822
34899
  initStrategy: z.enum(["none", "auto"]).describe("The initialization strategy determines how missing coordination objects and coordination scope mappings are initially filled in.")
34823
34900
  });
@@ -35240,6 +35317,124 @@ z.object({
35240
35317
  radius: z.number(),
35241
35318
  opacity: z.number()
35242
35319
  });
35320
+ const shapeBaseObj = z.object({
35321
+ uid: z.string(),
35322
+ text: z.string().optional(),
35323
+ strokeColor: z.array(z.number()).length(3).optional(),
35324
+ strokeWidth: z.number().optional(),
35325
+ // SVG-style dash pattern, e.g. "10 5" or "10 20 30 10". "none" or omitted = solid.
35326
+ strokeDashArray: z.string().optional(),
35327
+ visible: z.boolean().optional()
35328
+ // TODO: define unit modes for x and y axes
35329
+ // ("pixels" vs "normalized" vs "physical" etc.)
35330
+ // TODO: a coordinate system identifier (e.g., "DeckGL" for now,
35331
+ // but a coordinate system from OME-NGFF/SpatialData eventually?)
35332
+ });
35333
+ const rectangleShapeObj = shapeBaseObj.extend({
35334
+ type: z.literal("rectangle"),
35335
+ // OME-XML field names verbatim (upper-left origin)
35336
+ x: z.number(),
35337
+ y: z.number(),
35338
+ width: z.number(),
35339
+ height: z.number(),
35340
+ fillColor: z.array(z.number()).length(3).optional(),
35341
+ fillOpacity: z.number().optional()
35342
+ });
35343
+ const lineShapeObj = shapeBaseObj.extend({
35344
+ type: z.literal("line"),
35345
+ // OME-XML field names verbatim
35346
+ x1: z.number(),
35347
+ y1: z.number(),
35348
+ x2: z.number(),
35349
+ y2: z.number(),
35350
+ markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
35351
+ markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional(),
35352
+ textPosition: z.enum(["start", "middle", "end"]).optional(),
35353
+ textBufferPx: z.number().optional()
35354
+ });
35355
+ const ellipseShapeObj = shapeBaseObj.extend({
35356
+ type: z.literal("ellipse"),
35357
+ // OME-XML field names verbatim (centre point + radii)
35358
+ x1: z.number(),
35359
+ y1: z.number(),
35360
+ radiusX: z.number(),
35361
+ radiusY: z.number(),
35362
+ fillColor: z.array(z.number()).length(3).optional(),
35363
+ fillOpacity: z.number().optional()
35364
+ });
35365
+ const polygonShapeObj = shapeBaseObj.extend({
35366
+ type: z.literal("polygon"),
35367
+ // OME-XML: array of [x, y] coordinate pairs, closed automatically
35368
+ points: z.array(z.tuple([z.number(), z.number()])),
35369
+ fillColor: z.array(z.number()).length(3).optional(),
35370
+ fillOpacity: z.number().optional()
35371
+ });
35372
+ const polylineShapeObj = shapeBaseObj.extend({
35373
+ type: z.literal("polyline"),
35374
+ // OME-XML: array of [x, y] coordinate pairs, open (not closed)
35375
+ points: z.array(z.tuple([z.number(), z.number()])),
35376
+ markerStart: z.enum(["Arrow", "Tick"]).nullable().optional(),
35377
+ markerEnd: z.enum(["Arrow", "Tick"]).nullable().optional()
35378
+ });
35379
+ const annotationShapeObj = z.discriminatedUnion("type", [
35380
+ rectangleShapeObj,
35381
+ lineShapeObj,
35382
+ ellipseShapeObj,
35383
+ polygonShapeObj,
35384
+ polylineShapeObj
35385
+ ]);
35386
+ z.array(annotationShapeObj);
35387
+ const annotationFrameObj = z.object({
35388
+ uid: z.string(),
35389
+ title: z.string().optional(),
35390
+ description: z.string().optional(),
35391
+ descriptionType: z.enum(["text", "markdown"]).optional(),
35392
+ // A frame can define per-view: coordinationValues
35393
+ // (if the view's state should not be coordinated with other views)
35394
+ // or per-view coordinationScopes/coordinationScopesBy
35395
+ // (if at this frame, the view should be coordinated with other views).
35396
+ // We can also define a frame-level coordination space,
35397
+ // which will be merged with the global coordination space.
35398
+ // TODO: datasets
35399
+ // TODO: coordinationSpace
35400
+ layout: z.array(
35401
+ // Note: for now, we will infer view objects which have a uid
35402
+ // that is present in the global layout, and do NOT have x/y/w/h defined,
35403
+ // to mean that in this frame, the layout and set of views is unchanged
35404
+ // from the global layout.
35405
+ // This will allow each frame to omit the full list of views from the layout,
35406
+ // and only specify the views whose coordination state is changing in this frame.
35407
+ // If a frame includes a view with a uid that is not present
35408
+ // in the global layout, then that view will be added to the layout at this frame.
35409
+ // This frame should also define x/y/w/h for all views,
35410
+ // since it will otherwise be ambiguous how to layout the updated set of views
35411
+ // for this frame.
35412
+ z.object({
35413
+ // The view UID. If this view uid is not present in the global layout,
35414
+ // it will be added to the layout at this frame,
35415
+ // and will need to have its coordination values initialized to their defaults
35416
+ // for any that were not fully specified.
35417
+ uid: z.string(),
35418
+ coordinationValues: z.record(
35419
+ z.string(),
35420
+ // The coordination type name, e.g. "embeddingType"
35421
+ z.any()
35422
+ ).optional()
35423
+ // TODO: support coordinationScopes/coordinationScopesBy for per-view coordination
35424
+ // at this frame.
35425
+ // TODO: view x/y/w/h once we support view layout changes per-frame.
35426
+ })
35427
+ ).optional()
35428
+ });
35429
+ z.object({
35430
+ // TODO: schema version for the story schema?
35431
+ // Same as current Vitessce schema version?
35432
+ uid: z.string(),
35433
+ title: z.string().optional(),
35434
+ description: z.string().optional(),
35435
+ descriptionType: z.enum(["text", "markdown"]).optional(),
35436
+ frames: z.array(annotationFrameObj)
35437
+ });
35243
35438
  class VitessceError extends Error {
35244
35439
  constructor(message) {
35245
35440
  super(message);
@@ -35672,8 +35867,10 @@ class VitessceConfigView {
35672
35867
  * @param {number} y The y-coordinate of the view in the layout.
35673
35868
  * @param {number} w The width of the view in the layout.
35674
35869
  * @param {number} h The height of the view in the layout.
35870
+ * @param {object} coordinationValues A mapping from coordination type names
35871
+ * to coordination values which this view defines directly.
35675
35872
  */
35676
- constructor(component, coordinationScopes, x, y, w, h, uid) {
35873
+ constructor(component, coordinationScopes, x, y, w, h, uid, coordinationValues) {
35677
35874
  this.view = {
35678
35875
  component,
35679
35876
  coordinationScopes,
@@ -35683,7 +35880,8 @@ class VitessceConfigView {
35683
35880
  y,
35684
35881
  w,
35685
35882
  h,
35686
- uid
35883
+ uid,
35884
+ coordinationValues
35687
35885
  };
35688
35886
  }
35689
35887
  /**
@@ -35717,6 +35915,21 @@ class VitessceConfigView {
35717
35915
  this.view.coordinationScopesBy = nextCoordinationScopesBy;
35718
35916
  return this;
35719
35917
  }
35918
+ /**
35919
+ * Set coordination values on this view directly, without a coordination
35920
+ * scope in the coordination space as an intermediary.
35921
+ * These values take precedence over any coordination scope
35922
+ * (from coordinationScopes or metaCoordinationScopes) for the same type.
35923
+ * @param {object} cValues A mapping from coordination type names to values.
35924
+ * @returns {VitessceConfigView} This, to allow chaining.
35925
+ */
35926
+ setCoordinationValues(cValues) {
35927
+ this.view.coordinationValues = {
35928
+ ...this.view.coordinationValues || {},
35929
+ ...cValues
35930
+ };
35931
+ return this;
35932
+ }
35720
35933
  /**
35721
35934
  * Attach meta coordination scopes to this view.
35722
35935
  * @param {VitessceConfigMetaCoordinationScope} metaScope A meta coordination scope instance.
@@ -35802,6 +36015,9 @@ class CoordinationLevel {
35802
36015
  return this.cachedValue !== null;
35803
36016
  }
35804
36017
  }
36018
+ function CL(value) {
36019
+ return new CoordinationLevel(value);
36020
+ }
35805
36021
  class VitessceConfigCoordinationScope {
35806
36022
  /**
35807
36023
  * Construct a new coordination scope instance.
@@ -36224,7 +36440,8 @@ class VitessceConfig {
36224
36440
  url: f2.url,
36225
36441
  fileType: f2.fileType,
36226
36442
  coordinationValues: f2.coordinationValues,
36227
- options: f2.options
36443
+ options: f2.options,
36444
+ requestInit: f2.requestInit
36228
36445
  });
36229
36446
  });
36230
36447
  });
@@ -36240,7 +36457,7 @@ class VitessceConfig {
36240
36457
  }
36241
36458
  });
36242
36459
  config2.layout.forEach((c) => {
36243
- const newView = new VitessceConfigView(c.component, c.coordinationScopes, c.x, c.y, c.w, c.h, c.uid);
36460
+ const newView = new VitessceConfigView(c.component, c.coordinationScopes, c.x, c.y, c.w, c.h, c.uid, c.coordinationValues);
36244
36461
  vc.config.layout.push(newView);
36245
36462
  });
36246
36463
  return vc;
@@ -36493,7 +36710,7 @@ function getStore(parsedUrl) {
36493
36710
  }
36494
36711
  return fileType.endsWith(".zip") ? ZipFileStore.fromUrl(url, {
36495
36712
  transformEntries: transformEntriesForZipFileStore
36496
- }) : new FetchStore(url);
36713
+ }) : new FetchStore(url, { fetch: relaxedFetch });
36497
36714
  }
36498
36715
  function ensureStores(parsedUrls) {
36499
36716
  return parsedUrls.map((parsedUrl) => {
@@ -37076,6 +37293,122 @@ function getParameterScopeBy(parameter, byType, typeScope, coordinationScopes, c
37076
37293
  }
37077
37294
  return parameterScopeGlobal;
37078
37295
  }
37296
+ function hasCoordinationValue(coordinationValues, parameter) {
37297
+ return coordinationValues !== void 0 && parameter in coordinationValues;
37298
+ }
37299
+ const COORDINATION_LEVEL_SENTINEL = "$CL";
37300
+ function isPlainObject(value) {
37301
+ return value !== null && typeof value === "object" && !Array.isArray(value);
37302
+ }
37303
+ function isMultiLevelValue(value) {
37304
+ return isPlainObject(value) && Object.hasOwn(value, COORDINATION_LEVEL_SENTINEL);
37305
+ }
37306
+ function toArray(value) {
37307
+ if (value === void 0 || value === null) return [];
37308
+ return Array.isArray(value) ? value : [value];
37309
+ }
37310
+ function reviveCoordinationLevels(value) {
37311
+ if (Array.isArray(value)) {
37312
+ return value.map(reviveCoordinationLevels);
37313
+ }
37314
+ if (isMultiLevelValue(value)) {
37315
+ return CL(reviveCoordinationLevels(value[COORDINATION_LEVEL_SENTINEL]));
37316
+ }
37317
+ if (isPlainObject(value)) {
37318
+ return Object.fromEntries(
37319
+ Object.entries(value).map(([k, v]) => [k, reviveCoordinationLevels(v)])
37320
+ );
37321
+ }
37322
+ return value;
37323
+ }
37324
+ function applyAnnotationFrameToViewConfig(viewConfig, viewUid, frameCoordinationValues, scopePrefix) {
37325
+ const { coordinationSpace = {}, layout } = viewConfig;
37326
+ const viewObj = layout.find((l) => l.uid === viewUid);
37327
+ if (!viewObj || !frameCoordinationValues) {
37328
+ return viewConfig;
37329
+ }
37330
+ const META = CoordinationType$1.META_COORDINATION_SCOPES;
37331
+ const META_BY = CoordinationType$1.META_COORDINATION_SCOPES_BY;
37332
+ const newSpace = { ...coordinationSpace };
37333
+ const newViewObj = { ...viewObj };
37334
+ const setViewValue = (coordinationType, value) => {
37335
+ newViewObj.coordinationValues = {
37336
+ ...newViewObj.coordinationValues,
37337
+ [coordinationType]: value
37338
+ };
37339
+ };
37340
+ const entries = Object.entries(frameCoordinationValues);
37341
+ const singleLevelEntries = entries.filter(([, value]) => !isMultiLevelValue(value));
37342
+ const multiLevelEntries = entries.filter(([, value]) => isMultiLevelValue(value));
37343
+ const resolvedScopes = getScopes(viewObj.coordinationScopes || {}, coordinationSpace[META]);
37344
+ singleLevelEntries.forEach(([coordinationType, value]) => {
37345
+ const scopes = toArray(resolvedScopes[coordinationType]);
37346
+ if (hasCoordinationValue(viewObj.coordinationValues, coordinationType) || scopes.length === 0) {
37347
+ setViewValue(coordinationType, value);
37348
+ return;
37349
+ }
37350
+ newSpace[coordinationType] = {
37351
+ ...newSpace[coordinationType],
37352
+ ...Object.fromEntries(scopes.map((scope) => [scope, value]))
37353
+ };
37354
+ });
37355
+ if (multiLevelEntries.length > 0) {
37356
+ const {
37357
+ coordinationSpace: generatedSpace,
37358
+ coordinationScopes: generatedScopes
37359
+ } = getCoordinationSpaceAndScopes(
37360
+ Object.fromEntries(multiLevelEntries.map(([coordinationType, value]) => [
37361
+ coordinationType,
37362
+ reviveCoordinationLevels(value)
37363
+ ])),
37364
+ scopePrefix
37365
+ );
37366
+ Object.entries(generatedSpace).forEach(([coordinationType, scopeValues]) => {
37367
+ if ([META, META_BY, CoordinationType$1.DATASET].includes(coordinationType)) return;
37368
+ newSpace[coordinationType] = {
37369
+ ...newSpace[coordinationType],
37370
+ ...scopeValues
37371
+ };
37372
+ });
37373
+ const newTypeScopes = generatedSpace[META]?.[generatedScopes[META]?.[0]] || {};
37374
+ const newTypeScopesBy = generatedSpace[META_BY]?.[generatedScopes[META_BY]?.[0]] || {};
37375
+ const viewMetaScopes = toArray(viewObj.coordinationScopes?.[META]);
37376
+ Object.entries(newTypeScopes).forEach(([coordinationType, scopes]) => {
37377
+ const owner = [...viewMetaScopes].reverse().find((m) => Object.hasOwn(newSpace[META]?.[m] || {}, coordinationType));
37378
+ if (owner) {
37379
+ newSpace[META] = {
37380
+ ...newSpace[META],
37381
+ [owner]: { ...newSpace[META][owner], [coordinationType]: scopes }
37382
+ };
37383
+ } else {
37384
+ newViewObj.coordinationScopes = {
37385
+ ...newViewObj.coordinationScopes,
37386
+ [coordinationType]: scopes
37387
+ };
37388
+ }
37389
+ });
37390
+ const viewMetaScopesBy = toArray(viewObj.coordinationScopes?.[META_BY]);
37391
+ Object.entries(newTypeScopesBy).forEach(([primaryType, primaryObj]) => {
37392
+ const owner = [...viewMetaScopesBy].reverse().find((m) => Object.hasOwn(newSpace[META_BY]?.[m] || {}, primaryType)) ?? viewMetaScopesBy.at(-1);
37393
+ if (owner) {
37394
+ newSpace[META_BY] = {
37395
+ ...newSpace[META_BY],
37396
+ [owner]: { ...newSpace[META_BY][owner], [primaryType]: primaryObj }
37397
+ };
37398
+ } else {
37399
+ newViewObj.coordinationScopesBy = {
37400
+ ...newViewObj.coordinationScopesBy,
37401
+ [primaryType]: primaryObj
37402
+ };
37403
+ }
37404
+ });
37405
+ }
37406
+ return {
37407
+ ...viewConfig,
37408
+ coordinationSpace: newSpace,
37409
+ layout: layout.map((l) => l.uid === viewUid ? newViewObj : l)
37410
+ };
37411
+ }
37079
37412
  const createViewConfigStore = (initialLoaders, initialConfig) => create()(subscribeWithSelector((set) => ({
37080
37413
  // State:
37081
37414
  // The viewConfig is an object which must conform to the schema
@@ -37103,9 +37436,29 @@ const createViewConfigStore = (initialLoaders, initialConfig) => create()(subscr
37103
37436
  coordinationScopes,
37104
37437
  byType,
37105
37438
  typeScope,
37106
- coordinationScopesBy
37439
+ coordinationScopesBy,
37440
+ // The viewUid is only required to write back to view-level coordinationValues.
37441
+ viewUid
37107
37442
  }) => set((state) => {
37108
- const { coordinationSpace } = state.viewConfig;
37443
+ const { coordinationSpace, layout } = state.viewConfig;
37444
+ const viewObj = viewUid === void 0 ? void 0 : layout.find((l) => l.uid === viewUid);
37445
+ const coordinationValues = viewObj?.coordinationValues;
37446
+ const byTypeScope = byType ? coordinationScopesBy?.[byType]?.[parameter]?.[typeScope] : void 0;
37447
+ if (viewUid !== void 0 && hasCoordinationValue(coordinationValues, parameter) && !byTypeScope) {
37448
+ return {
37449
+ viewConfig: {
37450
+ ...state.viewConfig,
37451
+ layout: layout.map((l) => l.uid === viewUid ? {
37452
+ ...l,
37453
+ coordinationValues: {
37454
+ ...coordinationValues,
37455
+ [parameter]: value
37456
+ }
37457
+ } : l)
37458
+ },
37459
+ mostRecentConfigSource: "internal"
37460
+ };
37461
+ }
37109
37462
  let scope;
37110
37463
  if (!byType) {
37111
37464
  scope = getParameterScope(parameter, coordinationScopes);
@@ -37211,6 +37564,19 @@ const createViewConfigStore = (initialLoaders, initialConfig) => create()(subscr
37211
37564
  mostRecentConfigSource: "internal"
37212
37565
  };
37213
37566
  }),
37567
+ applyAnnotationFrameCoordination: ({
37568
+ viewUid,
37569
+ frameCoordinationValues,
37570
+ scopePrefix
37571
+ }) => set((state) => ({
37572
+ viewConfig: applyAnnotationFrameToViewConfig(
37573
+ state.viewConfig,
37574
+ viewUid,
37575
+ frameCoordinationValues,
37576
+ scopePrefix
37577
+ ),
37578
+ mostRecentConfigSource: "internal"
37579
+ })),
37214
37580
  removeImageChannelInMetaCoordinationScopes: (coordinationScopesRaw, layerScope, channelScope) => set((state) => {
37215
37581
  const { coordinationSpace } = state.viewConfig;
37216
37582
  return {
@@ -37311,10 +37677,13 @@ const useGridSizeStore = create((set) => ({
37311
37677
  resizeCount: state.resizeCount + 1
37312
37678
  }))
37313
37679
  }));
37314
- function useInitialCoordination(parameters, coordinationScopes) {
37680
+ function useInitialCoordination(parameters, coordinationScopes, coordinationValues) {
37315
37681
  const values2 = useViewConfigStoreShallow((state) => {
37316
37682
  const { coordinationSpace } = state.initialViewConfig;
37317
37683
  return Object.fromEntries(parameters.map((parameter) => {
37684
+ if (coordinationValues && hasCoordinationValue(coordinationValues, parameter)) {
37685
+ return [parameter, coordinationValues[parameter]];
37686
+ }
37318
37687
  if (coordinationSpace && coordinationSpace[parameter]) {
37319
37688
  const value = coordinationSpace[parameter][coordinationScopes[parameter]];
37320
37689
  return [parameter, value];
@@ -37324,11 +37693,14 @@ function useInitialCoordination(parameters, coordinationScopes) {
37324
37693
  });
37325
37694
  return values2;
37326
37695
  }
37327
- function useCoordination(parameters, coordinationScopes) {
37696
+ function useCoordination(parameters, coordinationScopes, coordinationValues, viewUid) {
37328
37697
  const setCoordinationValue = useViewConfigStore((state) => state.setCoordinationValue);
37329
37698
  const values2 = useViewConfigStoreShallow((state) => {
37330
37699
  const { coordinationSpace } = state.viewConfig;
37331
37700
  return Object.fromEntries(parameters.map((parameter) => {
37701
+ if (coordinationValues && hasCoordinationValue(coordinationValues, parameter)) {
37702
+ return [parameter, coordinationValues[parameter]];
37703
+ }
37332
37704
  if (coordinationSpace) {
37333
37705
  const parameterScope = getParameterScope(parameter, coordinationScopes);
37334
37706
  if (coordinationSpace && coordinationSpace[parameter]) {
@@ -37344,10 +37716,11 @@ function useCoordination(parameters, coordinationScopes) {
37344
37716
  const setterFunc = (value) => setCoordinationValue({
37345
37717
  parameter,
37346
37718
  coordinationScopes,
37719
+ viewUid,
37347
37720
  value
37348
37721
  });
37349
37722
  return [setterName, setterFunc];
37350
- })), [parameters, coordinationScopes]);
37723
+ })), [parameters, coordinationScopes, viewUid]);
37351
37724
  return [values2, setters];
37352
37725
  }
37353
37726
  function useMultiCoordinationScopes(parameter, coordinationScopes) {
@@ -37472,7 +37845,7 @@ function useMultiCoordinationValues(parameter, coordinationScopes) {
37472
37845
  function useDatasetUids(coordinationScopes) {
37473
37846
  return useMultiCoordinationValues(CoordinationType$1.DATASET, coordinationScopes);
37474
37847
  }
37475
- function useComplexCoordination(parameters, coordinationScopes, coordinationScopesBy, byType) {
37848
+ function useComplexCoordination(parameters, coordinationScopes, coordinationScopesBy, byType, coordinationValues, viewUid) {
37476
37849
  const setCoordinationValue = useViewConfigStore((state) => state.setCoordinationValue);
37477
37850
  const parameterSpaces = useViewConfigStoreShallow((state) => {
37478
37851
  const { coordinationSpace } = state.viewConfig;
@@ -37484,6 +37857,9 @@ function useComplexCoordination(parameters, coordinationScopes, coordinationScop
37484
37857
  const typeScopesArr = Array.isArray(typeScopes) ? typeScopes : [typeScopes];
37485
37858
  return Object.fromEntries(typeScopesArr.map((datasetScope) => {
37486
37859
  const datasetValues = Object.fromEntries(parameters.map((parameter, i2) => {
37860
+ if (coordinationValues && hasCoordinationValue(coordinationValues, parameter) && !coordinationScopesBy?.[byType]?.[parameter]?.[datasetScope]) {
37861
+ return [parameter, coordinationValues[parameter]];
37862
+ }
37487
37863
  if (parameterSpaces[i2]) {
37488
37864
  const parameterSpace = parameterSpaces[i2];
37489
37865
  const parameterScope = getParameterScopeBy(
@@ -37507,7 +37883,7 @@ function useComplexCoordination(parameters, coordinationScopes, coordinationScop
37507
37883
  }));
37508
37884
  }
37509
37885
  return {};
37510
- }, [byType, coordinationScopes, coordinationScopesBy, parameterSpaces]);
37886
+ }, [byType, coordinationScopes, coordinationScopesBy, parameterSpaces, coordinationValues]);
37511
37887
  const setters = useMemo(() => {
37512
37888
  const typeScopes = getParameterScope(byType, coordinationScopes);
37513
37889
  if (typeScopes) {
@@ -37521,6 +37897,7 @@ function useComplexCoordination(parameters, coordinationScopes, coordinationScop
37521
37897
  typeScope: datasetScope,
37522
37898
  coordinationScopes,
37523
37899
  coordinationScopesBy,
37900
+ viewUid,
37524
37901
  value
37525
37902
  });
37526
37903
  return [setterName, setterFunc];
@@ -37529,7 +37906,7 @@ function useComplexCoordination(parameters, coordinationScopes, coordinationScop
37529
37906
  }));
37530
37907
  }
37531
37908
  return {};
37532
- }, [coordinationScopes]);
37909
+ }, [coordinationScopes, viewUid]);
37533
37910
  return [values2, setters];
37534
37911
  }
37535
37912
  function useCoordinationScopes(coordinationScopes) {
@@ -37562,7 +37939,31 @@ function useCoordinationScopesBy(coordinationScopes, coordinationScopesBy) {
37562
37939
  }, [coordinationScopes, coordinationScopesBy, metaSpaceBy]);
37563
37940
  return vals;
37564
37941
  }
37565
- function useComplexCoordinationSecondary(parameters, coordinationScopes, coordinationScopesBy, primaryType, secondaryType) {
37942
+ function useRawViewMapping(viewUid) {
37943
+ const viewObj = useViewConfigStoreShallow((state) => {
37944
+ const { layout } = state.viewConfig;
37945
+ return layout.find((l) => l.uid === viewUid);
37946
+ });
37947
+ return useMemo(() => [
37948
+ viewObj?.coordinationScopes,
37949
+ viewObj?.coordinationScopesBy,
37950
+ viewObj?.coordinationValues
37951
+ ], [viewObj]);
37952
+ }
37953
+ function useViewMapping(viewUid) {
37954
+ const [
37955
+ coordinationScopesRaw,
37956
+ coordinationScopesByRaw,
37957
+ coordinationValues
37958
+ ] = useRawViewMapping(viewUid);
37959
+ const coordinationScopes = useCoordinationScopes(coordinationScopesRaw || {});
37960
+ const coordinationScopesBy = useCoordinationScopesBy(
37961
+ coordinationScopesRaw || {},
37962
+ coordinationScopesByRaw || {}
37963
+ );
37964
+ return [coordinationScopes, coordinationScopesBy, coordinationValues];
37965
+ }
37966
+ function useComplexCoordinationSecondary(parameters, coordinationScopes, coordinationScopesBy, primaryType, secondaryType, coordinationValues, viewUid) {
37566
37967
  const coordinationScopesFake = useMemo(() => {
37567
37968
  if (coordinationScopesBy?.[primaryType]?.[secondaryType]) {
37568
37969
  return {
@@ -37584,7 +37985,9 @@ function useComplexCoordinationSecondary(parameters, coordinationScopes, coordin
37584
37985
  parameters,
37585
37986
  coordinationScopesFake,
37586
37987
  coordinationScopesBy,
37587
- secondaryType
37988
+ secondaryType,
37989
+ coordinationValues,
37990
+ viewUid
37588
37991
  );
37589
37992
  const nestedValues = useMemo(() => {
37590
37993
  const result = {};
@@ -37719,6 +38122,63 @@ function useSetLoaders() {
37719
38122
  function useMergeCoordination() {
37720
38123
  return useViewConfigStore((state) => state.mergeCoordination);
37721
38124
  }
38125
+ const ANNOTATION_FRAME_COORDINATION_TYPES = [
38126
+ CoordinationType$1.ANNOTATION_STORY,
38127
+ CoordinationType$1.ANNOTATION_FRAME_INDEX
38128
+ ];
38129
+ function getAnnotationFrameUpdate(annotationStory, prevFrameIndex, annotationFrameIndex, viewUid) {
38130
+ if (typeof annotationFrameIndex !== "number") {
38131
+ if (typeof prevFrameIndex === "number") {
38132
+ return {
38133
+ frameCoordinationValues: { [CoordinationType$1.ANNOTATION_SHAPES]: null },
38134
+ scopePrefix: ""
38135
+ };
38136
+ }
38137
+ return null;
38138
+ }
38139
+ const frame = annotationStory?.frames?.[annotationFrameIndex];
38140
+ if (!frame) {
38141
+ return null;
38142
+ }
38143
+ const frameCoordinationValues = getAnnotationFrameCoordinationValues(
38144
+ annotationStory,
38145
+ annotationFrameIndex,
38146
+ viewUid
38147
+ );
38148
+ return {
38149
+ frameCoordinationValues: {
38150
+ [CoordinationType$1.ANNOTATION_SHAPES]: null,
38151
+ ...frameCoordinationValues
38152
+ },
38153
+ scopePrefix: `annotation_${annotationStory.uid}_${frame.uid}_${viewUid}_`
38154
+ };
38155
+ }
38156
+ function useAnnotationFrameCoordination(viewUid, coordinationScopes, coordinationValues) {
38157
+ const [{
38158
+ annotationStory,
38159
+ annotationFrameIndex
38160
+ }] = useCoordination(
38161
+ ANNOTATION_FRAME_COORDINATION_TYPES,
38162
+ coordinationScopes,
38163
+ coordinationValues
38164
+ );
38165
+ const applyAnnotationFrameCoordination = useViewConfigStore(
38166
+ (state) => state.applyAnnotationFrameCoordination
38167
+ );
38168
+ const prevFrameIndexRef = useRef(void 0);
38169
+ useEffect(() => {
38170
+ const update2 = getAnnotationFrameUpdate(
38171
+ annotationStory,
38172
+ prevFrameIndexRef.current,
38173
+ annotationFrameIndex,
38174
+ viewUid
38175
+ );
38176
+ prevFrameIndexRef.current = annotationFrameIndex;
38177
+ if (update2) {
38178
+ applyAnnotationFrameCoordination({ viewUid, ...update2 });
38179
+ }
38180
+ }, [annotationStory, annotationFrameIndex, viewUid]);
38181
+ }
37722
38182
  function useViewConfig() {
37723
38183
  return useViewConfigStore((state) => state.viewConfig);
37724
38184
  }
@@ -43973,6 +44433,7 @@ function VitessceGridLayout(props) {
43973
44433
  onRemoveComponent,
43974
44434
  onLayoutChange: onLayoutChangeProp,
43975
44435
  isBounded,
44436
+ areAnnotationsEditable,
43976
44437
  pageMode,
43977
44438
  children
43978
44439
  } = props;
@@ -44065,7 +44526,8 @@ function VitessceGridLayout(props) {
44065
44526
  viewTypes,
44066
44527
  fileTypes,
44067
44528
  coordinationTypes,
44068
- stores
44529
+ stores,
44530
+ areAnnotationsEditable
44069
44531
  }
44070
44532
  )))];
44071
44533
  }));
@@ -44086,11 +44548,12 @@ function VitessceGridLayout(props) {
44086
44548
  viewTypes,
44087
44549
  fileTypes,
44088
44550
  coordinationTypes,
44089
- stores
44551
+ stores,
44552
+ areAnnotationsEditable
44090
44553
  }
44091
44554
  )));
44092
44555
  }), contextValue];
44093
- }, [gridComponents, getComponent, onRemoveComponent, theme]);
44556
+ }, [gridComponents, getComponent, onRemoveComponent, theme, areAnnotationsEditable]);
44094
44557
  return pageMode ? /* @__PURE__ */ React__default.createElement(PageModeViewContext.Provider, { value: pageModeViews }, children) : gridLayouts && gridComponents && gridBreakpoints && gridCols && /* @__PURE__ */ React__default.createElement(React__default.Fragment, null, style2, /* @__PURE__ */ React__default.createElement(
44095
44558
  ResponsiveHeightGridLayout,
44096
44559
  {
@@ -46009,31 +46472,44 @@ function useWindowDimensions() {
46009
46472
  }, []);
46010
46473
  return windowDimensions;
46011
46474
  }
46475
+ const EMPTY_SIZE = { width: void 0, height: void 0 };
46012
46476
  function useGridItemSize() {
46013
46477
  const containerRef = useRef();
46014
- const [height2, setHeight] = useState();
46015
- const [width2, setWidth] = useState();
46016
- const resizeCount = useGridResize();
46017
- const incrementResizeCount = useEmitGridResize();
46478
+ const observerRef = useRef(null);
46479
+ const observedRef = useRef(null);
46480
+ const [size2, setSize] = useState(EMPTY_SIZE);
46018
46481
  useEffect(() => {
46019
- function onWindowResize() {
46020
- incrementResizeCount();
46482
+ if (typeof ResizeObserver === "undefined") {
46483
+ return () => {
46484
+ };
46021
46485
  }
46022
- const onResizeDebounced = debounce(onWindowResize, 100, { trailing: true });
46023
- window.addEventListener("resize", onResizeDebounced);
46024
- onWindowResize();
46486
+ const observer = new ResizeObserver(([entry]) => {
46487
+ if (!entry) return;
46488
+ const { width: width2, height: height2 } = entry.target.getBoundingClientRect();
46489
+ setSize((prevSize) => prevSize.width === width2 && prevSize.height === height2 ? prevSize : { width: width2, height: height2 });
46490
+ });
46491
+ observerRef.current = observer;
46025
46492
  return () => {
46026
- window.removeEventListener("resize", onResizeDebounced);
46493
+ observer.disconnect();
46494
+ observerRef.current = null;
46495
+ observedRef.current = null;
46027
46496
  };
46028
- }, [incrementResizeCount]);
46497
+ }, []);
46029
46498
  useEffect(() => {
46030
- if (!containerRef.current) return;
46031
- const container = containerRef.current;
46032
- const containerRect = container.getBoundingClientRect();
46033
- setHeight(containerRect.height);
46034
- setWidth(containerRect.width);
46035
- }, [resizeCount]);
46036
- return [width2, height2, containerRef];
46499
+ const observer = observerRef.current;
46500
+ const element = containerRef.current ?? null;
46501
+ if (!observer || element === observedRef.current) {
46502
+ return;
46503
+ }
46504
+ if (observedRef.current) {
46505
+ observer.unobserve(observedRef.current);
46506
+ }
46507
+ observedRef.current = element;
46508
+ if (element) {
46509
+ observer.observe(element);
46510
+ }
46511
+ });
46512
+ return [size2.width, size2.height, containerRef];
46037
46513
  }
46038
46514
  function useDeckCanvasSize() {
46039
46515
  const deckRef = useRef();
@@ -46603,7 +47079,8 @@ function VitessceGrid(props) {
46603
47079
  stores,
46604
47080
  pageMode,
46605
47081
  children,
46606
- queryClient
47082
+ queryClient,
47083
+ areAnnotationsEditable
46607
47084
  } = props;
46608
47085
  const [rowHeight, containerRef] = useRowHeight(config2, initialRowHeight, height2, margin, padding);
46609
47086
  const onResize = useEmitGridResize();
@@ -46671,7 +47148,8 @@ function VitessceGrid(props) {
46671
47148
  onLayoutChange: changeLayoutPostMount,
46672
47149
  isBounded,
46673
47150
  onResize,
46674
- onResizeStop: onResize
47151
+ onResizeStop: onResize,
47152
+ areAnnotationsEditable
46675
47153
  },
46676
47154
  children
46677
47155
  ) : null
@@ -46964,7 +47442,8 @@ function VitS(props) {
46964
47442
  pageMode = false,
46965
47443
  children,
46966
47444
  debugMode = DEFAULT_DEBUG_MODE,
46967
- logLevel = DEFAULT_LOG_LEVEL
47445
+ logLevel = DEFAULT_LOG_LEVEL,
47446
+ areAnnotationsEditable = true
46968
47447
  } = props;
46969
47448
  const [debugErrors, setDebugErrors] = useState([]);
46970
47449
  const viewTypes = useMemo(() => viewTypesProp || [], [viewTypesProp]);
@@ -47149,7 +47628,8 @@ function VitS(props) {
47149
47628
  theme,
47150
47629
  isBounded,
47151
47630
  stores: mergedStores,
47152
- queryClient
47631
+ queryClient,
47632
+ areAnnotationsEditable
47153
47633
  },
47154
47634
  children
47155
47635
  ), /* @__PURE__ */ React__default.createElement(
@@ -47941,6 +48421,17 @@ function useFeatureSetStatsData(loaders, dataset, isRequired, matchOn, volcanoOp
47941
48421
  DataType$1.FEATURE_SET_STATS
47942
48422
  );
47943
48423
  }
48424
+ function useAnnotationStoryData(loaders, dataset, isRequired, coordinationSetters, initialCoordinationValues, matchOn) {
48425
+ return useDataType(
48426
+ DataType$1.ANNOTATION_STORY,
48427
+ loaders,
48428
+ dataset,
48429
+ isRequired,
48430
+ coordinationSetters,
48431
+ initialCoordinationValues,
48432
+ matchOn
48433
+ );
48434
+ }
47944
48435
  function useObsSetStatsData(loaders, dataset, isRequired, matchOn, volcanoOptions) {
47945
48436
  return useComparativeDataType(
47946
48437
  loaders,
@@ -49410,6 +49901,8 @@ export {
49410
49901
  shallowDiffByLayerCoordinationWithKeys,
49411
49902
  shallowDiffByLayerWithKeys,
49412
49903
  useAddImageChannelInMetaCoordinationScopes,
49904
+ useAnnotationFrameCoordination,
49905
+ useAnnotationStoryData,
49413
49906
  useAsyncFunction,
49414
49907
  useAuxiliaryCoordination,
49415
49908
  useClosestVitessceContainerSize,
@@ -49469,6 +49962,7 @@ export {
49469
49962
  useStyles as usePlotOptionsStyles,
49470
49963
  usePointMultiObsFeatureMatrixIndices,
49471
49964
  usePointMultiObsLabels,
49965
+ useRawViewMapping,
49472
49966
  useReady,
49473
49967
  useRemoveImageChannelInMetaCoordinationScopes,
49474
49968
  useSampleEdgesData,
@@ -49492,6 +49986,7 @@ export {
49492
49986
  useViewConfig,
49493
49987
  useViewConfigStore,
49494
49988
  useViewConfigStoreApi,
49989
+ useViewMapping,
49495
49990
  useVitessceContainer,
49496
49991
  useWarning,
49497
49992
  useWindowDimensions