@vitessce/utils 3.3.1 → 3.3.3

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
@@ -441,6 +441,33 @@ function getNextScope$1(prevScopes) {
441
441
  } while (prevScopes.includes(nextScope));
442
442
  return nextScope;
443
443
  }
444
+ function getNextScopeNumeric(prevScopes) {
445
+ let nextScopeInt = 0;
446
+ let nextScopeStr;
447
+ do {
448
+ nextScopeStr = `${nextScopeInt}`;
449
+ nextScopeInt += 1;
450
+ } while (prevScopes.includes(nextScopeStr));
451
+ return nextScopeStr;
452
+ }
453
+ function createPrefixedGetNextScopeNumeric(prefix) {
454
+ return (prevScopes) => {
455
+ let nextScopeInt = 0;
456
+ let nextScopeStr;
457
+ do {
458
+ nextScopeStr = `${prefix}${nextScopeInt}`;
459
+ nextScopeInt += 1;
460
+ } while (prevScopes.includes(nextScopeStr));
461
+ return nextScopeStr;
462
+ };
463
+ }
464
+ function getInitialCoordinationScopePrefix(datasetUid, dataType) {
465
+ return `init_${datasetUid}_${dataType}_`;
466
+ }
467
+ function getInitialCoordinationScopeName(datasetUid, dataType, i = null) {
468
+ const prefix = getInitialCoordinationScopePrefix(datasetUid, dataType);
469
+ return `${prefix}${i === null ? 0 : i}`;
470
+ }
444
471
  const DEFAULT_DARK_COLOR$1 = [50, 50, 50];
445
472
  const DEFAULT_LIGHT_COLOR$1 = [200, 200, 200];
446
473
  function getDefaultColor$1(theme) {
@@ -9003,7 +9030,9 @@ const FileType$1 = {
9003
9030
  OBS_SEGMENTATIONS_JSON: "obsSegmentations.json",
9004
9031
  OBS_SETS_CSV: "obsSets.csv",
9005
9032
  OBS_SETS_JSON: "obsSets.json",
9033
+ // OME-Zarr
9006
9034
  IMAGE_OME_ZARR: "image.ome-zarr",
9035
+ OBS_SEGMENTATIONS_OME_ZARR: "obsSegmentations.ome-zarr",
9007
9036
  // AnnData
9008
9037
  OBS_FEATURE_MATRIX_ANNDATA_ZARR: "obsFeatureMatrix.anndata.zarr",
9009
9038
  OBS_SETS_ANNDATA_ZARR: "obsSets.anndata.zarr",
@@ -9456,30 +9485,39 @@ const omeCoordinateTransformations = z.array(z.union([
9456
9485
  scale: z.array(z.number())
9457
9486
  })
9458
9487
  ]));
9459
- z.object({
9488
+ const imageOmeTiffSchema = z.object({
9460
9489
  offsetsUrl: z.string().optional(),
9461
9490
  coordinateTransformations: omeCoordinateTransformations.optional()
9462
9491
  });
9492
+ imageOmeTiffSchema.extend({
9493
+ obsTypesFromChannelNames: z.boolean().optional()
9494
+ });
9463
9495
  const imageOmeZarrSchema = z.object({
9464
9496
  coordinateTransformations: omeCoordinateTransformations.optional()
9465
9497
  });
9466
9498
  imageOmeZarrSchema.extend({
9499
+ obsTypesFromChannelNames: z.boolean().optional()
9500
+ });
9501
+ const imageSpatialdataSchema = imageOmeZarrSchema.extend({
9467
9502
  path: z.string()
9468
9503
  });
9469
- z.object({
9504
+ const obsSegmentationsSpatialdataSchema = z.object({
9505
+ // TODO: should this also extend the imageOmeZarrSchema?
9506
+ // TODO: should this be renamed labelsSpatialdataSchema?
9507
+ // TODO: support obsTypesFromChannelNames?
9470
9508
  path: z.string()
9471
9509
  });
9472
9510
  z.object({
9473
9511
  path: z.string()
9474
9512
  });
9475
- z.object({
9513
+ const obsSpotsSpatialdataSchema = z.object({
9476
9514
  path: z.string(),
9477
9515
  tablePath: z.string().optional().describe("The path to a table which annotates the spots. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected.")
9478
9516
  });
9479
- annDataObsFeatureMatrix.extend({
9517
+ const obsFeatureMatrixSpatialdataSchema = annDataObsFeatureMatrix.extend({
9480
9518
  region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional()
9481
9519
  });
9482
- z.object({
9520
+ const obsSetsSpatialdataSchema = z.object({
9483
9521
  region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional(),
9484
9522
  tablePath: z.string().optional().describe("The path to a table which contains the index for the set values."),
9485
9523
  obsSets: annDataObsSets
@@ -9542,6 +9580,19 @@ z.object({
9542
9580
  z.array(annDataConvenienceObsEmbeddingItem)
9543
9581
  ])
9544
9582
  }).partial();
9583
+ z.object({
9584
+ // TODO: should `image` be a special schema
9585
+ // to allow specifying fileUid (like for embeddingType)?
9586
+ image: imageSpatialdataSchema,
9587
+ // TODO: should this be a special schema
9588
+ // to allow specifying fileUid (like for embeddingType)?
9589
+ labels: obsSegmentationsSpatialdataSchema,
9590
+ obsFeatureMatrix: obsFeatureMatrixSpatialdataSchema,
9591
+ obsSpots: obsSpotsSpatialdataSchema,
9592
+ // TODO: obsPoints
9593
+ // TODO: obsLocations
9594
+ obsSets: obsSetsSpatialdataSchema
9595
+ }).partial();
9545
9596
  z.object({
9546
9597
  obsLabelsTypes: z.array(z.string()).optional(),
9547
9598
  embeddingTypes: z.array(z.string()).optional()
@@ -16230,12 +16281,16 @@ export {
16230
16281
  createDefaultUpdateStatus,
16231
16282
  createDefaultUpdateTracksHover,
16232
16283
  createDefaultUpdateViewInfo,
16284
+ createPrefixedGetNextScopeNumeric,
16233
16285
  formatBytes,
16234
16286
  fromEntries$1 as fromEntries,
16235
16287
  getCellColors,
16236
16288
  getDefaultColor$1 as getDefaultColor,
16289
+ getInitialCoordinationScopeName,
16290
+ getInitialCoordinationScopePrefix,
16237
16291
  getLongestString,
16238
16292
  getNextScope$1 as getNextScope,
16293
+ getNextScopeNumeric,
16239
16294
  getValueTransformFunction,
16240
16295
  pluralize
16241
16296
  };
@@ -1,4 +1,4 @@
1
- export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, } from './root.js';
1
+ export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
2
2
  export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
3
3
  export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
4
4
  export { getCellColors, } from './interpolate-colors.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,GACb,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,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,EACL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EACL,WAAW,EACX,WAAW,EACX,UAAU,EACV,SAAS,EACT,gBAAgB,EAChB,YAAY,EACZ,mBAAmB,EACnB,iCAAiC,EACjC,iCAAiC,EACjC,+BAA+B,GAChC,MAAM,WAAW,CAAC;AAEnB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,eAAe,EACf,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,EACL,aAAa,GACd,MAAM,yBAAyB,CAAC;AACjC,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,WAAW,CAAC"}
package/dist-tsc/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  // eslint-disable-next-line react-refresh/only-export-components
2
- export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, } from './root.js';
2
+ export { fromEntries, commaNumber, capitalize, pluralize, getLongestString, getNextScope, getNextScopeNumeric, createPrefixedGetNextScopeNumeric, getInitialCoordinationScopePrefix, getInitialCoordinationScopeName, } from './root.js';
3
3
  // eslint-disable-next-line react-refresh/only-export-components
4
4
  export { DEFAULT_DARK_COLOR, DEFAULT_LIGHT_COLOR, getDefaultColor, PALETTE, VIEWER_PALETTE, PATHOLOGY_PALETTE, LARGE_PATHOLOGY_PALETTE, COLORMAP_OPTIONS, DEFAULT_GL_OPTIONS, createDefaultUpdateStatus, createDefaultUpdateCellsSelection, createDefaultUpdateCellsHover, createDefaultUpdateGenesHover, createDefaultUpdateTracksHover, createDefaultUpdateViewInfo, createDefaultClearPleaseWait, copyUint8Array, asEsModule, formatBytes, } from './components.js';
5
5
  export { getValueTransformFunction, VALUE_TRANSFORM_OPTIONS, } from './gating.js';
@@ -31,4 +31,40 @@ export declare function getLongestString(strings: string[]): string;
31
31
  * @returns {string} The new scope name.
32
32
  */
33
33
  export declare function getNextScope(prevScopes: string[]): string;
34
+ /**
35
+ * Generate a new scope name which does not
36
+ * conflict / overlap with a previous scope name.
37
+ * Really these just need to be unique within the coordination object.
38
+ * So in theory they could be String(Math.random()) or uuidv4() or something.
39
+ * In this version we use an incrementing integer starting from 0.
40
+ * @param {string[]} prevScopes Previous scope names.
41
+ * @returns {string} The new scope name.
42
+ */
43
+ export declare function getNextScopeNumeric(prevScopes: string[]): string;
44
+ /**
45
+ * Generate a getNextScopeNumeric function which includes a prefix.
46
+ * @param {string} prefix The prefix to use.
47
+ * @returns {Function} The getNextScope function.
48
+ */
49
+ export declare function createPrefixedGetNextScopeNumeric(prefix: string): (prevScopes: string[]) => string;
50
+ /**
51
+ * Get the prefix for an automatically-initialized coordination scope.
52
+ * @param datasetUid The dataset UID.
53
+ * @param dataType The dataType corresponding to the fileType
54
+ * whose loader defines the initial coordination values.
55
+ * @returns The prefix for the initial coordination scope
56
+ * like "init_<datasetUid>_<dataType>_".
57
+ */
58
+ export declare function getInitialCoordinationScopePrefix(datasetUid: string, dataType: string): string;
59
+ /**
60
+ * Get the name for an automatically-initialized coordination scope.
61
+ * @param datasetUid The dataset UID.
62
+ * @param dataType The dataType corresponding to the fileType
63
+ * whose loader defines the initial coordination values.
64
+ * @param i Optional. If null, the initial coordination scope
65
+ * name will be "init_<datasetUid>_<dataType>_0".
66
+ * @returns The name for the initial coordination scope
67
+ * like "init_<datasetUid>_<dataType>_<i>".
68
+ */
69
+ export declare function getInitialCoordinationScopeName(datasetUid: string, dataType: string, i?: number | null): string;
34
70
  //# sourceMappingURL=root.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"root.d.ts","sourceRoot":"","sources":["../src/root.ts"],"names":[],"mappings":"AAQA,wBAAgB,WAAW,CAAC,QAAQ,EAAE,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,GAAG;IAAE,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,CAG7E;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,UAGpC;AAED;;;;GAIG;AACH,w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Q,EAAE,MAAM,EAAE,CAAC,GAAE,MAAM,GAAG,IAAW,UAI9D"}
package/dist-tsc/root.js CHANGED
@@ -83,3 +83,62 @@ export function getNextScope(prevScopes) {
83
83
  } while (prevScopes.includes(nextScope));
84
84
  return nextScope;
85
85
  }
86
+ /**
87
+ * Generate a new scope name which does not
88
+ * conflict / overlap with a previous scope name.
89
+ * Really these just need to be unique within the coordination object.
90
+ * So in theory they could be String(Math.random()) or uuidv4() or something.
91
+ * In this version we use an incrementing integer starting from 0.
92
+ * @param {string[]} prevScopes Previous scope names.
93
+ * @returns {string} The new scope name.
94
+ */
95
+ export function getNextScopeNumeric(prevScopes) {
96
+ let nextScopeInt = 0;
97
+ let nextScopeStr;
98
+ do {
99
+ nextScopeStr = `${nextScopeInt}`;
100
+ nextScopeInt += 1;
101
+ } while (prevScopes.includes(nextScopeStr));
102
+ return nextScopeStr;
103
+ }
104
+ /**
105
+ * Generate a getNextScopeNumeric function which includes a prefix.
106
+ * @param {string} prefix The prefix to use.
107
+ * @returns {Function} The getNextScope function.
108
+ */
109
+ export function createPrefixedGetNextScopeNumeric(prefix) {
110
+ return (prevScopes) => {
111
+ let nextScopeInt = 0;
112
+ let nextScopeStr;
113
+ do {
114
+ nextScopeStr = `${prefix}${nextScopeInt}`;
115
+ nextScopeInt += 1;
116
+ } while (prevScopes.includes(nextScopeStr));
117
+ return nextScopeStr;
118
+ };
119
+ }
120
+ /**
121
+ * Get the prefix for an automatically-initialized coordination scope.
122
+ * @param datasetUid The dataset UID.
123
+ * @param dataType The dataType corresponding to the fileType
124
+ * whose loader defines the initial coordination values.
125
+ * @returns The prefix for the initial coordination scope
126
+ * like "init_<datasetUid>_<dataType>_".
127
+ */
128
+ export function getInitialCoordinationScopePrefix(datasetUid, dataType) {
129
+ return `init_${datasetUid}_${dataType}_`;
130
+ }
131
+ /**
132
+ * Get the name for an automatically-initialized coordination scope.
133
+ * @param datasetUid The dataset UID.
134
+ * @param dataType The dataType corresponding to the fileType
135
+ * whose loader defines the initial coordination values.
136
+ * @param i Optional. If null, the initial coordination scope
137
+ * name will be "init_<datasetUid>_<dataType>_0".
138
+ * @returns The name for the initial coordination scope
139
+ * like "init_<datasetUid>_<dataType>_<i>".
140
+ */
141
+ export function getInitialCoordinationScopeName(datasetUid, dataType, i = null) {
142
+ const prefix = getInitialCoordinationScopePrefix(datasetUid, dataType);
143
+ return `${prefix}${i === null ? 0 : i}`;
144
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/utils",
3
- "version": "3.3.1",
3
+ "version": "3.3.3",
4
4
  "author": "Gehlenborg Lab",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -20,7 +20,7 @@
20
20
  "lodash-es": "^4.17.21",
21
21
  "lz-string": "^1.4.4",
22
22
  "pluralize": "^8.0.0",
23
- "@vitessce/sets-utils": "3.3.1"
23
+ "@vitessce/sets-utils": "3.3.3"
24
24
  },
25
25
  "scripts": {
26
26
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",
package/src/index.ts CHANGED
@@ -6,6 +6,10 @@ export {
6
6
  pluralize,
7
7
  getLongestString,
8
8
  getNextScope,
9
+ getNextScopeNumeric,
10
+ createPrefixedGetNextScopeNumeric,
11
+ getInitialCoordinationScopePrefix,
12
+ getInitialCoordinationScopeName,
9
13
  } from './root.js';
10
14
  // eslint-disable-next-line react-refresh/only-export-components
11
15
  export {
package/src/root.ts CHANGED
@@ -95,3 +95,70 @@ export function getNextScope(prevScopes: string[]) {
95
95
  } while (prevScopes.includes(nextScope));
96
96
  return nextScope;
97
97
  }
98
+
99
+ /**
100
+ * Generate a new scope name which does not
101
+ * conflict / overlap with a previous scope name.
102
+ * Really these just need to be unique within the coordination object.
103
+ * So in theory they could be String(Math.random()) or uuidv4() or something.
104
+ * In this version we use an incrementing integer starting from 0.
105
+ * @param {string[]} prevScopes Previous scope names.
106
+ * @returns {string} The new scope name.
107
+ */
108
+ export function getNextScopeNumeric(prevScopes: string[]) {
109
+ let nextScopeInt = 0;
110
+ let nextScopeStr: string;
111
+ do {
112
+ nextScopeStr = `${nextScopeInt}`;
113
+ nextScopeInt += 1;
114
+ } while (prevScopes.includes(nextScopeStr));
115
+ return nextScopeStr;
116
+ }
117
+
118
+ /**
119
+ * Generate a getNextScopeNumeric function which includes a prefix.
120
+ * @param {string} prefix The prefix to use.
121
+ * @returns {Function} The getNextScope function.
122
+ */
123
+ export function createPrefixedGetNextScopeNumeric(prefix: string) {
124
+ return (prevScopes: string[]) => {
125
+ let nextScopeInt = 0;
126
+ let nextScopeStr: string;
127
+ do {
128
+ nextScopeStr = `${prefix}${nextScopeInt}`;
129
+ nextScopeInt += 1;
130
+ } while (prevScopes.includes(nextScopeStr));
131
+ return nextScopeStr;
132
+ };
133
+ }
134
+
135
+ /**
136
+ * Get the prefix for an automatically-initialized coordination scope.
137
+ * @param datasetUid The dataset UID.
138
+ * @param dataType The dataType corresponding to the fileType
139
+ * whose loader defines the initial coordination values.
140
+ * @returns The prefix for the initial coordination scope
141
+ * like "init_<datasetUid>_<dataType>_".
142
+ */
143
+ export function getInitialCoordinationScopePrefix(
144
+ datasetUid: string, dataType: string,
145
+ ) {
146
+ return `init_${datasetUid}_${dataType}_`;
147
+ }
148
+
149
+ /**
150
+ * Get the name for an automatically-initialized coordination scope.
151
+ * @param datasetUid The dataset UID.
152
+ * @param dataType The dataType corresponding to the fileType
153
+ * whose loader defines the initial coordination values.
154
+ * @param i Optional. If null, the initial coordination scope
155
+ * name will be "init_<datasetUid>_<dataType>_0".
156
+ * @returns The name for the initial coordination scope
157
+ * like "init_<datasetUid>_<dataType>_<i>".
158
+ */
159
+ export function getInitialCoordinationScopeName(
160
+ datasetUid: string, dataType: string, i: number | null = null,
161
+ ) {
162
+ const prefix = getInitialCoordinationScopePrefix(datasetUid, dataType);
163
+ return `${prefix}${i === null ? 0 : i}`;
164
+ }