@vitessce/json 3.6.7 → 3.6.8

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 (58) hide show
  1. package/dist/{deflate-BYKpSTT6.js → deflate-DstPPSeQ.js} +1 -1
  2. package/dist/{index-B7T2DtqE.js → index-D2yFM0Ax.js} +552 -471
  3. package/dist/index.js +1 -1
  4. package/dist/{jpeg-HiHjx4CG.js → jpeg-DLyTBIoB.js} +1 -1
  5. package/dist/{lerc-BMjU_3GZ.js → lerc-C3NYZ4w9.js} +1 -1
  6. package/dist/{lzw-U6CSxLDR.js → lzw-CscKL06f.js} +1 -1
  7. package/dist/{packbits-DoX7PkwR.js → packbits-D3LeL8FE.js} +1 -1
  8. package/dist/{raw-Cy08b44Z.js → raw-uN_cumDY.js} +1 -1
  9. package/dist/{webimage-Pvwg1VPe.js → webimage-CsEP6b6I.js} +1 -1
  10. package/dist-tsc/JsonSource.d.ts +2 -2
  11. package/dist-tsc/JsonSource.d.ts.map +1 -1
  12. package/dist-tsc/JsonSource.js +7 -9
  13. package/dist-tsc/json-loaders/JsonLoader.d.ts +1 -1
  14. package/dist-tsc/json-loaders/JsonLoader.d.ts.map +1 -1
  15. package/dist-tsc/json-loaders/JsonLoader.js +10 -15
  16. package/dist-tsc/json-loaders/ObsSegmentationsJson.d.ts.map +1 -1
  17. package/dist-tsc/json-loaders/ObsSegmentationsJson.js +3 -6
  18. package/dist-tsc/json-loaders/ObsSetsJson.d.ts.map +1 -1
  19. package/dist-tsc/json-loaders/ObsSetsJson.js +2 -5
  20. package/dist-tsc/legacy-loaders/CellsJsonAsObsEmbedding.d.ts.map +1 -1
  21. package/dist-tsc/legacy-loaders/CellsJsonAsObsEmbedding.js +3 -6
  22. package/dist-tsc/legacy-loaders/CellsJsonAsObsLabels.d.ts.map +1 -1
  23. package/dist-tsc/legacy-loaders/CellsJsonAsObsLabels.js +3 -6
  24. package/dist-tsc/legacy-loaders/CellsJsonAsObsLocations.d.ts.map +1 -1
  25. package/dist-tsc/legacy-loaders/CellsJsonAsObsLocations.js +3 -6
  26. package/dist-tsc/legacy-loaders/CellsJsonAsObsSegmentations.d.ts.map +1 -1
  27. package/dist-tsc/legacy-loaders/CellsJsonAsObsSegmentations.js +4 -7
  28. package/dist-tsc/legacy-loaders/ClustersJsonAsObsFeatureMatrix.d.ts.map +1 -1
  29. package/dist-tsc/legacy-loaders/ClustersJsonAsObsFeatureMatrix.js +3 -6
  30. package/dist-tsc/legacy-loaders/GenesJsonAsObsFeatureMatrix.d.ts.map +1 -1
  31. package/dist-tsc/legacy-loaders/GenesJsonAsObsFeatureMatrix.js +3 -6
  32. package/dist-tsc/legacy-loaders/MoleculesJsonAsObsLabels.d.ts.map +1 -1
  33. package/dist-tsc/legacy-loaders/MoleculesJsonAsObsLabels.js +3 -6
  34. package/dist-tsc/legacy-loaders/MoleculesJsonAsObsLocations.d.ts.map +1 -1
  35. package/dist-tsc/legacy-loaders/MoleculesJsonAsObsLocations.js +3 -6
  36. package/dist-tsc/raster-json-loaders/RasterJsonAsImageLoader.d.ts.map +1 -1
  37. package/dist-tsc/raster-json-loaders/RasterJsonAsImageLoader.js +2 -5
  38. package/dist-tsc/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.d.ts.map +1 -1
  39. package/dist-tsc/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.js +2 -5
  40. package/dist-tsc/raster-json-loaders/RasterJsonLoader.d.ts +0 -1
  41. package/dist-tsc/raster-json-loaders/RasterJsonLoader.d.ts.map +1 -1
  42. package/dist-tsc/raster-json-loaders/RasterJsonLoader.js +6 -6
  43. package/package.json +12 -11
  44. package/src/JsonSource.js +7 -9
  45. package/src/json-loaders/JsonLoader.js +11 -18
  46. package/src/json-loaders/ObsSegmentationsJson.js +4 -7
  47. package/src/json-loaders/ObsSetsJson.js +2 -5
  48. package/src/legacy-loaders/CellsJsonAsObsEmbedding.js +4 -7
  49. package/src/legacy-loaders/CellsJsonAsObsLabels.js +3 -6
  50. package/src/legacy-loaders/CellsJsonAsObsLocations.js +4 -7
  51. package/src/legacy-loaders/CellsJsonAsObsSegmentations.js +4 -7
  52. package/src/legacy-loaders/ClustersJsonAsObsFeatureMatrix.js +4 -7
  53. package/src/legacy-loaders/GenesJsonAsObsFeatureMatrix.js +4 -7
  54. package/src/legacy-loaders/MoleculesJsonAsObsLabels.js +3 -6
  55. package/src/legacy-loaders/MoleculesJsonAsObsLocations.js +3 -6
  56. package/src/raster-json-loaders/RasterJsonAsImageLoader.js +2 -5
  57. package/src/raster-json-loaders/RasterJsonAsObsSegmentationsLoader.js +2 -5
  58. package/src/raster-json-loaders/RasterJsonLoader.js +6 -6
@@ -30,371 +30,34 @@ function _mergeNamespaces(n3, m) {
30
30
  }
31
31
  return Object.freeze(Object.defineProperty(n3, Symbol.toStringTag, { value: "Module" }));
32
32
  }
33
- class LoaderResult {
34
- /**
35
- * @param {LoaderDataType} data
36
- * @param {object[]|string|null} url Single URL or array of { url, name } objects.
37
- * @param {object|null} coordinationValues
38
- * @param {RequestInit|null} requestInit
39
- */
40
- constructor(data, url, coordinationValues = null, requestInit2 = null) {
41
- this.data = data;
42
- this.url = url;
43
- this.coordinationValues = coordinationValues;
44
- this.requestInit = requestInit2;
33
+ class VitessceError extends Error {
34
+ constructor(message) {
35
+ super(message);
36
+ this.name = "VitessceError";
45
37
  }
46
38
  }
47
- class AbstractLoader {
48
- /**
49
- *
50
- * @param {LoaderParams} params
51
- */
52
- constructor({ type, fileType, url, requestInit: requestInit2, options, coordinationValues }) {
53
- this.fileType = fileType;
54
- this.type = type;
55
- this.url = url;
56
- this.requestInit = requestInit2;
57
- this.options = options;
58
- this.coordinationValues = coordinationValues;
59
- }
60
- /**
61
- *
62
- * @returns {Promise<LoaderResult<any>>}
63
- */
64
- // eslint-disable-next-line class-methods-use-this
65
- async load() {
66
- return Promise.resolve(new LoaderResult(true, null));
39
+ class DataLoaderError extends VitessceError {
40
+ constructor(message) {
41
+ super(message);
42
+ this.name = "DataLoaderError";
67
43
  }
68
44
  }
69
- class AbstractTwoStepLoader extends AbstractLoader {
70
- /**
71
- *
72
- * @param {DataSourceType} dataSource
73
- * @param {LoaderParams} params
74
- */
75
- constructor(dataSource, params) {
76
- super(params);
77
- this.dataSource = dataSource;
45
+ class JsonLoaderValidationError extends DataLoaderError {
46
+ constructor(message) {
47
+ super(message);
48
+ this.name = "JsonLoaderValidationError";
78
49
  }
79
50
  }
80
- class AbstractLoaderError {
51
+ class DataFetchError extends DataLoaderError {
81
52
  constructor(message) {
82
- this.message = message;
83
- }
84
- // eslint-disable-next-line class-methods-use-this
85
- warnInConsole() {
86
- throw new Error("The warnInConsole() method has not been implemented.");
53
+ super(message);
54
+ this.name = "DataFetchError";
87
55
  }
88
56
  }
89
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
90
- function getDefaultExportFromCjs(x) {
91
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
92
- }
93
- function getAugmentedNamespace(n3) {
94
- if (Object.prototype.hasOwnProperty.call(n3, "__esModule")) return n3;
95
- var f2 = n3.default;
96
- if (typeof f2 == "function") {
97
- var a2 = function a3() {
98
- if (this instanceof a3) {
99
- return Reflect.construct(f2, arguments, this.constructor);
100
- }
101
- return f2.apply(this, arguments);
102
- };
103
- a2.prototype = f2.prototype;
104
- } else a2 = {};
105
- Object.defineProperty(a2, "__esModule", { value: true });
106
- Object.keys(n3).forEach(function(k) {
107
- var d = Object.getOwnPropertyDescriptor(n3, k);
108
- Object.defineProperty(a2, k, d.get ? d : {
109
- enumerable: true,
110
- get: function() {
111
- return n3[k];
112
- }
113
- });
114
- });
115
- return a2;
116
- }
117
- var loglevel$1 = { exports: {} };
118
- var loglevel = loglevel$1.exports;
119
- var hasRequiredLoglevel;
120
- function requireLoglevel() {
121
- if (hasRequiredLoglevel) return loglevel$1.exports;
122
- hasRequiredLoglevel = 1;
123
- (function(module2) {
124
- (function(root2, definition) {
125
- if (module2.exports) {
126
- module2.exports = definition();
127
- } else {
128
- root2.log = definition();
129
- }
130
- })(loglevel, function() {
131
- var noop2 = function() {
132
- };
133
- var undefinedType2 = "undefined";
134
- var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
135
- var logMethods = [
136
- "trace",
137
- "debug",
138
- "info",
139
- "warn",
140
- "error"
141
- ];
142
- var _loggersByName = {};
143
- var defaultLogger = null;
144
- function bindMethod(obj, methodName) {
145
- var method = obj[methodName];
146
- if (typeof method.bind === "function") {
147
- return method.bind(obj);
148
- } else {
149
- try {
150
- return Function.prototype.bind.call(method, obj);
151
- } catch (e2) {
152
- return function() {
153
- return Function.prototype.apply.apply(method, [obj, arguments]);
154
- };
155
- }
156
- }
157
- }
158
- function traceForIE() {
159
- if (console.log) {
160
- if (console.log.apply) {
161
- console.log.apply(console, arguments);
162
- } else {
163
- Function.prototype.apply.apply(console.log, [console, arguments]);
164
- }
165
- }
166
- if (console.trace) console.trace();
167
- }
168
- function realMethod(methodName) {
169
- if (methodName === "debug") {
170
- methodName = "log";
171
- }
172
- if (typeof console === undefinedType2) {
173
- return false;
174
- } else if (methodName === "trace" && isIE) {
175
- return traceForIE;
176
- } else if (console[methodName] !== void 0) {
177
- return bindMethod(console, methodName);
178
- } else if (console.log !== void 0) {
179
- return bindMethod(console, "log");
180
- } else {
181
- return noop2;
182
- }
183
- }
184
- function replaceLoggingMethods() {
185
- var level = this.getLevel();
186
- for (var i2 = 0; i2 < logMethods.length; i2++) {
187
- var methodName = logMethods[i2];
188
- this[methodName] = i2 < level ? noop2 : this.methodFactory(methodName, level, this.name);
189
- }
190
- this.log = this.debug;
191
- if (typeof console === undefinedType2 && level < this.levels.SILENT) {
192
- return "No console available for logging";
193
- }
194
- }
195
- function enableLoggingWhenConsoleArrives(methodName) {
196
- return function() {
197
- if (typeof console !== undefinedType2) {
198
- replaceLoggingMethods.call(this);
199
- this[methodName].apply(this, arguments);
200
- }
201
- };
202
- }
203
- function defaultMethodFactory(methodName, _level, _loggerName) {
204
- return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
205
- }
206
- function Logger(name2, factory2) {
207
- var self2 = this;
208
- var inheritedLevel;
209
- var defaultLevel;
210
- var userLevel;
211
- var storageKey = "loglevel";
212
- if (typeof name2 === "string") {
213
- storageKey += ":" + name2;
214
- } else if (typeof name2 === "symbol") {
215
- storageKey = void 0;
216
- }
217
- function persistLevelIfPossible(levelNum) {
218
- var levelName = (logMethods[levelNum] || "silent").toUpperCase();
219
- if (typeof window === undefinedType2 || !storageKey) return;
220
- try {
221
- window.localStorage[storageKey] = levelName;
222
- return;
223
- } catch (ignore) {
224
- }
225
- try {
226
- window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
227
- } catch (ignore) {
228
- }
229
- }
230
- function getPersistedLevel() {
231
- var storedLevel;
232
- if (typeof window === undefinedType2 || !storageKey) return;
233
- try {
234
- storedLevel = window.localStorage[storageKey];
235
- } catch (ignore) {
236
- }
237
- if (typeof storedLevel === undefinedType2) {
238
- try {
239
- var cookie = window.document.cookie;
240
- var cookieName = encodeURIComponent(storageKey);
241
- var location = cookie.indexOf(cookieName + "=");
242
- if (location !== -1) {
243
- storedLevel = /^([^;]+)/.exec(
244
- cookie.slice(location + cookieName.length + 1)
245
- )[1];
246
- }
247
- } catch (ignore) {
248
- }
249
- }
250
- if (self2.levels[storedLevel] === void 0) {
251
- storedLevel = void 0;
252
- }
253
- return storedLevel;
254
- }
255
- function clearPersistedLevel() {
256
- if (typeof window === undefinedType2 || !storageKey) return;
257
- try {
258
- window.localStorage.removeItem(storageKey);
259
- } catch (ignore) {
260
- }
261
- try {
262
- window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
263
- } catch (ignore) {
264
- }
265
- }
266
- function normalizeLevel(input) {
267
- var level = input;
268
- if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
269
- level = self2.levels[level.toUpperCase()];
270
- }
271
- if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
272
- return level;
273
- } else {
274
- throw new TypeError("log.setLevel() called with invalid level: " + input);
275
- }
276
- }
277
- self2.name = name2;
278
- self2.levels = {
279
- "TRACE": 0,
280
- "DEBUG": 1,
281
- "INFO": 2,
282
- "WARN": 3,
283
- "ERROR": 4,
284
- "SILENT": 5
285
- };
286
- self2.methodFactory = factory2 || defaultMethodFactory;
287
- self2.getLevel = function() {
288
- if (userLevel != null) {
289
- return userLevel;
290
- } else if (defaultLevel != null) {
291
- return defaultLevel;
292
- } else {
293
- return inheritedLevel;
294
- }
295
- };
296
- self2.setLevel = function(level, persist) {
297
- userLevel = normalizeLevel(level);
298
- if (persist !== false) {
299
- persistLevelIfPossible(userLevel);
300
- }
301
- return replaceLoggingMethods.call(self2);
302
- };
303
- self2.setDefaultLevel = function(level) {
304
- defaultLevel = normalizeLevel(level);
305
- if (!getPersistedLevel()) {
306
- self2.setLevel(level, false);
307
- }
308
- };
309
- self2.resetLevel = function() {
310
- userLevel = null;
311
- clearPersistedLevel();
312
- replaceLoggingMethods.call(self2);
313
- };
314
- self2.enableAll = function(persist) {
315
- self2.setLevel(self2.levels.TRACE, persist);
316
- };
317
- self2.disableAll = function(persist) {
318
- self2.setLevel(self2.levels.SILENT, persist);
319
- };
320
- self2.rebuild = function() {
321
- if (defaultLogger !== self2) {
322
- inheritedLevel = normalizeLevel(defaultLogger.getLevel());
323
- }
324
- replaceLoggingMethods.call(self2);
325
- if (defaultLogger === self2) {
326
- for (var childName in _loggersByName) {
327
- _loggersByName[childName].rebuild();
328
- }
329
- }
330
- };
331
- inheritedLevel = normalizeLevel(
332
- defaultLogger ? defaultLogger.getLevel() : "WARN"
333
- );
334
- var initialLevel = getPersistedLevel();
335
- if (initialLevel != null) {
336
- userLevel = normalizeLevel(initialLevel);
337
- }
338
- replaceLoggingMethods.call(self2);
339
- }
340
- defaultLogger = new Logger();
341
- defaultLogger.getLogger = function getLogger(name2) {
342
- if (typeof name2 !== "symbol" && typeof name2 !== "string" || name2 === "") {
343
- throw new TypeError("You must supply a name when creating a logger.");
344
- }
345
- var logger = _loggersByName[name2];
346
- if (!logger) {
347
- logger = _loggersByName[name2] = new Logger(
348
- name2,
349
- defaultLogger.methodFactory
350
- );
351
- }
352
- return logger;
353
- };
354
- var _log = typeof window !== undefinedType2 ? window.log : void 0;
355
- defaultLogger.noConflict = function() {
356
- if (typeof window !== undefinedType2 && window.log === defaultLogger) {
357
- window.log = _log;
358
- }
359
- return defaultLogger;
360
- };
361
- defaultLogger.getLoggers = function getLoggers2() {
362
- return _loggersByName;
363
- };
364
- defaultLogger["default"] = defaultLogger;
365
- return defaultLogger;
366
- });
367
- })(loglevel$1);
368
- return loglevel$1.exports;
369
- }
370
- var loglevelExports = requireLoglevel();
371
- const log$6 = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
372
- class LoaderValidationError extends AbstractLoaderError {
373
- constructor(datasetType, datasetFileType, datasetUrl, reason) {
374
- super(`Error while validating ${datasetType}.`);
375
- this.name = "LoaderValidationError";
376
- this.datasetType = datasetType;
377
- this.datasetFileType = datasetFileType;
378
- this.datasetUrl = datasetUrl;
379
- this.reason = reason;
380
- this.message = `${datasetType} from ${datasetUrl}: validation failed`;
381
- }
382
- warnInConsole() {
383
- const { reason, message } = this;
384
- log$6.warn(message, JSON.stringify(reason, null, 2));
385
- }
386
- }
387
- class DataSourceFetchError extends AbstractLoaderError {
388
- constructor(source, url, headers) {
389
- super(`${source} Error HTTP Status fetching from ${url}`);
390
- this.source = source;
391
- this.url = url;
392
- this.headers = headers;
393
- this.message = `${source} failed to fetch from ${url} with headers ${JSON.stringify(headers)}`;
394
- }
395
- warnInConsole() {
396
- const { message } = this;
397
- log$6.warn(message);
57
+ class ZarrNodeNotFoundError extends DataLoaderError {
58
+ constructor(message) {
59
+ super(message);
60
+ this.name = "ZarrNodeNotFoundError";
398
61
  }
399
62
  }
400
63
  class JsonSource {
@@ -402,14 +65,13 @@ class JsonSource {
402
65
  this.url = url;
403
66
  this.requestInit = requestInit2;
404
67
  }
405
- get data() {
68
+ async loadJson() {
406
69
  if (this._data) return this._data;
407
- this._data = fetch(this.url, this.requestInit).then((response) => {
408
- if (!response.ok) {
409
- return Promise.reject(new DataSourceFetchError("JsonSource", this.url, response.headers));
410
- }
411
- return response.json();
412
- }).catch(() => Promise.reject(new DataSourceFetchError("JsonSource", this.url, {})));
70
+ const response = await fetch(this.url, this.requestInit);
71
+ if (!response.ok) {
72
+ throw new DataFetchError(`loadJson failed for ${this.url}`);
73
+ }
74
+ this._data = await response.json();
413
75
  return this._data;
414
76
  }
415
77
  }
@@ -547,9 +209,7 @@ const FileType$1 = {
547
209
  OBS_SETS_SPATIALDATA_ZARR: "obsSets.spatialdata.zarr",
548
210
  OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
549
211
  FEATURE_LABELS_SPATIALDATA_ZARR: "featureLabels.spatialdata.zarr",
550
- // TODO:
551
- // OBS_POINTS_SPATIALDATA_ZARR: 'obsPoints.spatialdata.zarr',
552
- // OBS_LOCATIONS_SPATIALDATA_ZARR: 'obsLocations.spatialdata.zarr',
212
+ OBS_POINTS_SPATIALDATA_ZARR: "obsPoints.spatialdata.zarr",
553
213
  // SpatialData - zipped
554
214
  IMAGE_SPATIALDATA_ZARR_ZIP: "image.spatialdata.zarr.zip",
555
215
  LABELS_SPATIALDATA_ZARR_ZIP: "labels.spatialdata.zarr.zip",
@@ -558,6 +218,7 @@ const FileType$1 = {
558
218
  OBS_SETS_SPATIALDATA_ZARR_ZIP: "obsSets.spatialdata.zarr.zip",
559
219
  OBS_SPOTS_SPATIALDATA_ZARR_ZIP: "obsSpots.spatialdata.zarr.zip",
560
220
  FEATURE_LABELS_SPATIALDATA_ZARR_ZIP: "featureLabels.spatialdata.zarr.zip",
221
+ OBS_POINTS_SPATIALDATA_ZARR_ZIP: "obsPoints.spatialdata.zarr.zip",
561
222
  // MuData
562
223
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
563
224
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -804,6 +465,7 @@ const CoordinationType$1 = {
804
465
  [FileType$1.OBS_FEATURE_MATRIX_SPATIALDATA_ZARR]: DataType$2.OBS_FEATURE_MATRIX,
805
466
  [FileType$1.OBS_SETS_SPATIALDATA_ZARR]: DataType$2.OBS_SETS,
806
467
  [FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR]: DataType$2.FEATURE_LABELS,
468
+ [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: DataType$2.OBS_POINTS,
807
469
  // For new file types to support old file types
808
470
  [FileType$1.OBS_EMBEDDING_CELLS_JSON]: DataType$2.OBS_EMBEDDING,
809
471
  [FileType$1.OBS_LOCATIONS_CELLS_JSON]: DataType$2.OBS_LOCATIONS,
@@ -977,6 +639,9 @@ const CoordinationType$1 = {
977
639
  },
978
640
  [FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR]: {
979
641
  zip: FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR_ZIP
642
+ },
643
+ [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: {
644
+ zip: FileType$1.OBS_POINTS_SPATIALDATA_ZARR_ZIP
980
645
  }
981
646
  });
982
647
  [
@@ -1675,6 +1340,53 @@ const DEFAULT_RASTER_LAYER_PROPS = {
1675
1340
  // viv.RENDERING_MODES.ADDITIVE,
1676
1341
  use3d: false
1677
1342
  };
1343
+ class LoaderResult {
1344
+ /**
1345
+ * @param {LoaderDataType} data
1346
+ * @param {object[]|string|null} url Single URL or array of { url, name } objects.
1347
+ * @param {object|null} coordinationValues
1348
+ * @param {RequestInit|null} requestInit
1349
+ */
1350
+ constructor(data, url, coordinationValues = null, requestInit2 = null) {
1351
+ this.data = data;
1352
+ this.url = url;
1353
+ this.coordinationValues = coordinationValues;
1354
+ this.requestInit = requestInit2;
1355
+ }
1356
+ }
1357
+ class AbstractLoader {
1358
+ /**
1359
+ *
1360
+ * @param {LoaderParams} params
1361
+ */
1362
+ constructor({ type, fileType, url, requestInit: requestInit2, options, coordinationValues }) {
1363
+ this.fileType = fileType;
1364
+ this.type = type;
1365
+ this.url = url;
1366
+ this.requestInit = requestInit2;
1367
+ this.options = options;
1368
+ this.coordinationValues = coordinationValues;
1369
+ }
1370
+ /**
1371
+ *
1372
+ * @returns {Promise<LoaderResult<any>>}
1373
+ */
1374
+ // eslint-disable-next-line class-methods-use-this
1375
+ async load() {
1376
+ return Promise.resolve(new LoaderResult(true, null));
1377
+ }
1378
+ }
1379
+ class AbstractTwoStepLoader extends AbstractLoader {
1380
+ /**
1381
+ *
1382
+ * @param {DataSourceType} dataSource
1383
+ * @param {LoaderParams} params
1384
+ */
1385
+ constructor(dataSource, params) {
1386
+ super(params);
1387
+ this.dataSource = dataSource;
1388
+ }
1389
+ }
1678
1390
  var util;
1679
1391
  (function(util2) {
1680
1392
  util2.assertEqual = (val) => val;
@@ -5654,6 +5366,9 @@ const configSchema1_0_16 = configSchema1_0_13.extend({
5654
5366
  const configSchema1_0_17 = configSchema1_0_16.extend({
5655
5367
  version: z.literal("1.0.17")
5656
5368
  });
5369
+ const configSchema1_0_18 = configSchema1_0_17.extend({
5370
+ version: z.literal("1.0.18")
5371
+ });
5657
5372
  let getRandomValues$1;
5658
5373
  const rnds8$1 = new Uint8Array(16);
5659
5374
  function rng$1() {
@@ -6702,6 +6417,34 @@ var range$5 = createRange();
6702
6417
  function sum$4(array) {
6703
6418
  return array && array.length ? baseSum(array, identity$6) : 0;
6704
6419
  }
6420
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
6421
+ function getDefaultExportFromCjs(x) {
6422
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
6423
+ }
6424
+ function getAugmentedNamespace(n3) {
6425
+ if (Object.prototype.hasOwnProperty.call(n3, "__esModule")) return n3;
6426
+ var f2 = n3.default;
6427
+ if (typeof f2 == "function") {
6428
+ var a2 = function a3() {
6429
+ if (this instanceof a3) {
6430
+ return Reflect.construct(f2, arguments, this.constructor);
6431
+ }
6432
+ return f2.apply(this, arguments);
6433
+ };
6434
+ a2.prototype = f2.prototype;
6435
+ } else a2 = {};
6436
+ Object.defineProperty(a2, "__esModule", { value: true });
6437
+ Object.keys(n3).forEach(function(k) {
6438
+ var d = Object.getOwnPropertyDescriptor(n3, k);
6439
+ Object.defineProperty(a2, k, d.get ? d : {
6440
+ enumerable: true,
6441
+ get: function() {
6442
+ return n3[k];
6443
+ }
6444
+ });
6445
+ });
6446
+ return a2;
6447
+ }
6705
6448
  function commonjsRequire(path) {
6706
6449
  throw new Error('Could not dynamically require "' + path + '". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.');
6707
6450
  }
@@ -7092,6 +6835,261 @@ function getNextScope(prevScopes) {
7092
6835
  } while (prevScopes.includes(nextScope));
7093
6836
  return nextScope;
7094
6837
  }
6838
+ var loglevel$1 = { exports: {} };
6839
+ var loglevel = loglevel$1.exports;
6840
+ var hasRequiredLoglevel;
6841
+ function requireLoglevel() {
6842
+ if (hasRequiredLoglevel) return loglevel$1.exports;
6843
+ hasRequiredLoglevel = 1;
6844
+ (function(module2) {
6845
+ (function(root2, definition) {
6846
+ if (module2.exports) {
6847
+ module2.exports = definition();
6848
+ } else {
6849
+ root2.log = definition();
6850
+ }
6851
+ })(loglevel, function() {
6852
+ var noop2 = function() {
6853
+ };
6854
+ var undefinedType2 = "undefined";
6855
+ var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
6856
+ var logMethods = [
6857
+ "trace",
6858
+ "debug",
6859
+ "info",
6860
+ "warn",
6861
+ "error"
6862
+ ];
6863
+ var _loggersByName = {};
6864
+ var defaultLogger = null;
6865
+ function bindMethod(obj, methodName) {
6866
+ var method = obj[methodName];
6867
+ if (typeof method.bind === "function") {
6868
+ return method.bind(obj);
6869
+ } else {
6870
+ try {
6871
+ return Function.prototype.bind.call(method, obj);
6872
+ } catch (e2) {
6873
+ return function() {
6874
+ return Function.prototype.apply.apply(method, [obj, arguments]);
6875
+ };
6876
+ }
6877
+ }
6878
+ }
6879
+ function traceForIE() {
6880
+ if (console.log) {
6881
+ if (console.log.apply) {
6882
+ console.log.apply(console, arguments);
6883
+ } else {
6884
+ Function.prototype.apply.apply(console.log, [console, arguments]);
6885
+ }
6886
+ }
6887
+ if (console.trace) console.trace();
6888
+ }
6889
+ function realMethod(methodName) {
6890
+ if (methodName === "debug") {
6891
+ methodName = "log";
6892
+ }
6893
+ if (typeof console === undefinedType2) {
6894
+ return false;
6895
+ } else if (methodName === "trace" && isIE) {
6896
+ return traceForIE;
6897
+ } else if (console[methodName] !== void 0) {
6898
+ return bindMethod(console, methodName);
6899
+ } else if (console.log !== void 0) {
6900
+ return bindMethod(console, "log");
6901
+ } else {
6902
+ return noop2;
6903
+ }
6904
+ }
6905
+ function replaceLoggingMethods() {
6906
+ var level = this.getLevel();
6907
+ for (var i2 = 0; i2 < logMethods.length; i2++) {
6908
+ var methodName = logMethods[i2];
6909
+ this[methodName] = i2 < level ? noop2 : this.methodFactory(methodName, level, this.name);
6910
+ }
6911
+ this.log = this.debug;
6912
+ if (typeof console === undefinedType2 && level < this.levels.SILENT) {
6913
+ return "No console available for logging";
6914
+ }
6915
+ }
6916
+ function enableLoggingWhenConsoleArrives(methodName) {
6917
+ return function() {
6918
+ if (typeof console !== undefinedType2) {
6919
+ replaceLoggingMethods.call(this);
6920
+ this[methodName].apply(this, arguments);
6921
+ }
6922
+ };
6923
+ }
6924
+ function defaultMethodFactory(methodName, _level, _loggerName) {
6925
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
6926
+ }
6927
+ function Logger(name2, factory2) {
6928
+ var self2 = this;
6929
+ var inheritedLevel;
6930
+ var defaultLevel;
6931
+ var userLevel;
6932
+ var storageKey = "loglevel";
6933
+ if (typeof name2 === "string") {
6934
+ storageKey += ":" + name2;
6935
+ } else if (typeof name2 === "symbol") {
6936
+ storageKey = void 0;
6937
+ }
6938
+ function persistLevelIfPossible(levelNum) {
6939
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
6940
+ if (typeof window === undefinedType2 || !storageKey) return;
6941
+ try {
6942
+ window.localStorage[storageKey] = levelName;
6943
+ return;
6944
+ } catch (ignore) {
6945
+ }
6946
+ try {
6947
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
6948
+ } catch (ignore) {
6949
+ }
6950
+ }
6951
+ function getPersistedLevel() {
6952
+ var storedLevel;
6953
+ if (typeof window === undefinedType2 || !storageKey) return;
6954
+ try {
6955
+ storedLevel = window.localStorage[storageKey];
6956
+ } catch (ignore) {
6957
+ }
6958
+ if (typeof storedLevel === undefinedType2) {
6959
+ try {
6960
+ var cookie = window.document.cookie;
6961
+ var cookieName = encodeURIComponent(storageKey);
6962
+ var location = cookie.indexOf(cookieName + "=");
6963
+ if (location !== -1) {
6964
+ storedLevel = /^([^;]+)/.exec(
6965
+ cookie.slice(location + cookieName.length + 1)
6966
+ )[1];
6967
+ }
6968
+ } catch (ignore) {
6969
+ }
6970
+ }
6971
+ if (self2.levels[storedLevel] === void 0) {
6972
+ storedLevel = void 0;
6973
+ }
6974
+ return storedLevel;
6975
+ }
6976
+ function clearPersistedLevel() {
6977
+ if (typeof window === undefinedType2 || !storageKey) return;
6978
+ try {
6979
+ window.localStorage.removeItem(storageKey);
6980
+ } catch (ignore) {
6981
+ }
6982
+ try {
6983
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
6984
+ } catch (ignore) {
6985
+ }
6986
+ }
6987
+ function normalizeLevel(input) {
6988
+ var level = input;
6989
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
6990
+ level = self2.levels[level.toUpperCase()];
6991
+ }
6992
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
6993
+ return level;
6994
+ } else {
6995
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
6996
+ }
6997
+ }
6998
+ self2.name = name2;
6999
+ self2.levels = {
7000
+ "TRACE": 0,
7001
+ "DEBUG": 1,
7002
+ "INFO": 2,
7003
+ "WARN": 3,
7004
+ "ERROR": 4,
7005
+ "SILENT": 5
7006
+ };
7007
+ self2.methodFactory = factory2 || defaultMethodFactory;
7008
+ self2.getLevel = function() {
7009
+ if (userLevel != null) {
7010
+ return userLevel;
7011
+ } else if (defaultLevel != null) {
7012
+ return defaultLevel;
7013
+ } else {
7014
+ return inheritedLevel;
7015
+ }
7016
+ };
7017
+ self2.setLevel = function(level, persist) {
7018
+ userLevel = normalizeLevel(level);
7019
+ if (persist !== false) {
7020
+ persistLevelIfPossible(userLevel);
7021
+ }
7022
+ return replaceLoggingMethods.call(self2);
7023
+ };
7024
+ self2.setDefaultLevel = function(level) {
7025
+ defaultLevel = normalizeLevel(level);
7026
+ if (!getPersistedLevel()) {
7027
+ self2.setLevel(level, false);
7028
+ }
7029
+ };
7030
+ self2.resetLevel = function() {
7031
+ userLevel = null;
7032
+ clearPersistedLevel();
7033
+ replaceLoggingMethods.call(self2);
7034
+ };
7035
+ self2.enableAll = function(persist) {
7036
+ self2.setLevel(self2.levels.TRACE, persist);
7037
+ };
7038
+ self2.disableAll = function(persist) {
7039
+ self2.setLevel(self2.levels.SILENT, persist);
7040
+ };
7041
+ self2.rebuild = function() {
7042
+ if (defaultLogger !== self2) {
7043
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
7044
+ }
7045
+ replaceLoggingMethods.call(self2);
7046
+ if (defaultLogger === self2) {
7047
+ for (var childName in _loggersByName) {
7048
+ _loggersByName[childName].rebuild();
7049
+ }
7050
+ }
7051
+ };
7052
+ inheritedLevel = normalizeLevel(
7053
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
7054
+ );
7055
+ var initialLevel = getPersistedLevel();
7056
+ if (initialLevel != null) {
7057
+ userLevel = normalizeLevel(initialLevel);
7058
+ }
7059
+ replaceLoggingMethods.call(self2);
7060
+ }
7061
+ defaultLogger = new Logger();
7062
+ defaultLogger.getLogger = function getLogger(name2) {
7063
+ if (typeof name2 !== "symbol" && typeof name2 !== "string" || name2 === "") {
7064
+ throw new TypeError("You must supply a name when creating a logger.");
7065
+ }
7066
+ var logger = _loggersByName[name2];
7067
+ if (!logger) {
7068
+ logger = _loggersByName[name2] = new Logger(
7069
+ name2,
7070
+ defaultLogger.methodFactory
7071
+ );
7072
+ }
7073
+ return logger;
7074
+ };
7075
+ var _log = typeof window !== undefinedType2 ? window.log : void 0;
7076
+ defaultLogger.noConflict = function() {
7077
+ if (typeof window !== undefinedType2 && window.log === defaultLogger) {
7078
+ window.log = _log;
7079
+ }
7080
+ return defaultLogger;
7081
+ };
7082
+ defaultLogger.getLoggers = function getLoggers2() {
7083
+ return _loggersByName;
7084
+ };
7085
+ defaultLogger["default"] = defaultLogger;
7086
+ return defaultLogger;
7087
+ });
7088
+ })(loglevel$1);
7089
+ return loglevel$1.exports;
7090
+ }
7091
+ var loglevelExports = requireLoglevel();
7092
+ const log$6 = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
7095
7093
  const PALETTE = [
7096
7094
  [68, 119, 170],
7097
7095
  [136, 204, 238],
@@ -7620,7 +7618,54 @@ function upgradeFrom1_0_16(config3) {
7620
7618
  version: "1.0.17"
7621
7619
  };
7622
7620
  }
7623
- const latestConfigSchema = configSchema1_0_17;
7621
+ function upgradeFrom1_0_17(config3) {
7622
+ const newConfig = cloneDeep(config3);
7623
+ const { datasets } = newConfig;
7624
+ const newDatasets = datasets.map((datasetDef) => {
7625
+ const { files } = datasetDef;
7626
+ const newFiles = files.map((fileDef) => {
7627
+ const { fileType, options } = fileDef;
7628
+ if (fileType === "spatialdata.zarr" || fileType === "spatialdata.zarr.zip") {
7629
+ if (options.labels && options.shapes) {
7630
+ throw new Error("Cannot upgrade both labels and shapes at the same time. For now, a workaround is to include two separate spatialdata.zarr file definitions, one for labels and one for shapes.");
7631
+ }
7632
+ if (options.labels) {
7633
+ const newOptions = {
7634
+ ...options,
7635
+ obsSegmentations: options.labels
7636
+ };
7637
+ delete newOptions.labels;
7638
+ return {
7639
+ ...fileDef,
7640
+ options: newOptions
7641
+ };
7642
+ }
7643
+ if (options.shapes) {
7644
+ const newOptions = {
7645
+ ...options,
7646
+ obsSegmentations: options.shapes
7647
+ };
7648
+ delete newOptions.shapes;
7649
+ return {
7650
+ ...fileDef,
7651
+ options: newOptions
7652
+ };
7653
+ }
7654
+ }
7655
+ return fileDef;
7656
+ });
7657
+ return {
7658
+ ...datasetDef,
7659
+ files: newFiles
7660
+ };
7661
+ });
7662
+ return {
7663
+ ...newConfig,
7664
+ datasets: newDatasets,
7665
+ version: "1.0.18"
7666
+ };
7667
+ }
7668
+ const latestConfigSchema = configSchema1_0_18;
7624
7669
  const SCHEMA_HANDLERS = [
7625
7670
  [configSchema0_1_0, upgradeFrom0_1_0],
7626
7671
  [configSchema1_0_0, upgradeFrom1_0_0],
@@ -7639,7 +7684,8 @@ const SCHEMA_HANDLERS = [
7639
7684
  [configSchema1_0_13, upgradeFrom1_0_13],
7640
7685
  [configSchema1_0_14, upgradeFrom1_0_14],
7641
7686
  [configSchema1_0_15, upgradeFrom1_0_15],
7642
- [configSchema1_0_16, upgradeFrom1_0_16]
7687
+ [configSchema1_0_16, upgradeFrom1_0_16],
7688
+ [configSchema1_0_17, upgradeFrom1_0_17]
7643
7689
  ];
7644
7690
  var re = { exports: {} };
7645
7691
  var constants$1;
@@ -9882,10 +9928,14 @@ const imageSpatialdataSchema = z.object({
9882
9928
  coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.')
9883
9929
  });
9884
9930
  const obsSegmentationsSpatialdataSchema = z.object({
9885
- // TODO: should this be renamed labelsSpatialdataSchema?
9886
- // TODO: support obsTypesFromChannelNames?
9887
- path: z.string(),
9888
- tablePath: z.string().optional().describe("The path to a table which annotates the labels. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected."),
9931
+ // TODO: support obsTypesFromElementNames?
9932
+ path: z.string().describe("The path to the segmentation data, stored in either shapes/ or labels/."),
9933
+ tablePath: z.string().optional().describe("The path to a table which annotates the labels or shapes. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected."),
9934
+ coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.')
9935
+ });
9936
+ const obsPointsSpatialdataSchema = z.object({
9937
+ path: z.string().describe("The path to the point data."),
9938
+ tablePath: z.string().optional().describe("The path to a table which annotates the points. If available but not specified, the spot identifiers may not be aligned with associated tabular data as expected."),
9889
9939
  coordinateSystem: z.string().optional().describe('The name of a coordinate transformation output used to transform the image. If not provided, the "global" coordinate system is assumed.')
9890
9940
  });
9891
9941
  z.object({
@@ -10005,13 +10055,10 @@ z.object({
10005
10055
  image: imageSpatialdataSchema,
10006
10056
  // TODO: should this be a special schema
10007
10057
  // to allow specifying fileUid (like for embeddingType)?
10008
- // TODO: allow multiple labels?
10009
- labels: obsSegmentationsSpatialdataSchema,
10058
+ // TODO: allow multiple labels/shapes?
10059
+ obsSegmentations: obsSegmentationsSpatialdataSchema,
10060
+ obsPoints: obsPointsSpatialdataSchema,
10010
10061
  // TODO: allow multiple shapes?
10011
- // TODO: unify labels and shapes to obsSegmentations,
10012
- // then distinguish in expand function based on
10013
- // "labels/*" vs. "shapes/*" in path?
10014
- shapes: obsSegmentationsSpatialdataSchema,
10015
10062
  obsFeatureMatrix: obsFeatureMatrixSpatialdataSchema,
10016
10063
  obsSpots: obsSpotsSpatialdataSchema,
10017
10064
  // TODO: obsPoints
@@ -10122,26 +10169,17 @@ class JsonLoader extends AbstractTwoStepLoader {
10122
10169
  const { fileType } = params;
10123
10170
  this.schema = fileTypeToSchema[fileType];
10124
10171
  }
10125
- load() {
10126
- const {
10127
- url,
10128
- type,
10129
- fileType
10130
- } = this;
10172
+ async load() {
10173
+ const { url } = this;
10131
10174
  if (this.data) {
10132
10175
  return this.data;
10133
10176
  }
10134
- this.data = this.dataSource.data.then((data) => {
10135
- if (data instanceof AbstractLoaderError) {
10136
- return Promise.reject(data);
10137
- }
10138
- const [valid2, reason] = this.validate(data);
10139
- if (valid2) {
10140
- return Promise.resolve(new LoaderResult(data, url));
10141
- }
10142
- return Promise.reject(new LoaderValidationError(type, fileType, url, reason));
10143
- });
10144
- return this.data;
10177
+ this.data = await this.dataSource.loadJson();
10178
+ const [valid2, reason] = this.validate(this.data);
10179
+ if (valid2) {
10180
+ return new LoaderResult(this.data, url);
10181
+ }
10182
+ throw new JsonLoaderValidationError(reason);
10145
10183
  }
10146
10184
  validate(data) {
10147
10185
  const { schema } = this;
@@ -10191,10 +10229,7 @@ class ObsSegmentationsJsonLoader extends JsonLoader {
10191
10229
  }
10192
10230
  async load() {
10193
10231
  var _a3;
10194
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
10195
- if (payload instanceof AbstractLoaderError) {
10196
- return Promise.reject(payload);
10197
- }
10232
+ const payload = await super.load();
10198
10233
  const channelCoordination = [{
10199
10234
  // obsType: null,
10200
10235
  spatialChannelColor: [255, 255, 255],
@@ -10222,11 +10257,11 @@ class ObsSegmentationsJsonLoader extends JsonLoader {
10222
10257
  };
10223
10258
  const { data, url } = payload;
10224
10259
  const result = this.loadFromCache(data);
10225
- return Promise.resolve(new LoaderResult(
10260
+ return new LoaderResult(
10226
10261
  result,
10227
10262
  url,
10228
10263
  coordinationValues
10229
- ));
10264
+ );
10230
10265
  }
10231
10266
  }
10232
10267
  var earthRadius = 63710088e-1;
@@ -17627,10 +17662,7 @@ class ObsSetsJsonLoader extends JsonLoader {
17627
17662
  this.schema = obsSetsSchema;
17628
17663
  }
17629
17664
  async load() {
17630
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17631
- if (payload instanceof AbstractLoaderError) {
17632
- return Promise.reject(payload);
17633
- }
17665
+ const payload = await super.load();
17634
17666
  const { data: rawData, url } = payload;
17635
17667
  this.fileType.endsWith("cell-sets.json") ? "cell" : "obs";
17636
17668
  const [upgradedData] = tryUpgradeTreeToLatestSchema(rawData);
@@ -17687,16 +17719,13 @@ class CellsJsonAsObsEmbeddingLoader extends JsonLoader {
17687
17719
  return this.cachedResult;
17688
17720
  }
17689
17721
  async load() {
17690
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17691
- if (payload instanceof AbstractLoaderError) {
17692
- return Promise.reject(payload);
17693
- }
17722
+ const payload = await super.load();
17694
17723
  const { data, url } = payload;
17695
17724
  const result = this.loadFromCache(data);
17696
- return Promise.resolve(new LoaderResult(
17725
+ return new LoaderResult(
17697
17726
  result,
17698
17727
  url
17699
- ));
17728
+ );
17700
17729
  }
17701
17730
  }
17702
17731
  class CellsJsonAsObsLabelsLoader extends JsonLoader {
@@ -17715,13 +17744,10 @@ class CellsJsonAsObsLabelsLoader extends JsonLoader {
17715
17744
  return this.cachedResult;
17716
17745
  }
17717
17746
  async load() {
17718
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17719
- if (payload instanceof AbstractLoaderError) {
17720
- return Promise.reject(payload);
17721
- }
17747
+ const payload = await super.load();
17722
17748
  const { data, url } = payload;
17723
17749
  const result = this.loadFromCache(data);
17724
- return Promise.resolve(new LoaderResult(result, url));
17750
+ return new LoaderResult(result, url);
17725
17751
  }
17726
17752
  }
17727
17753
  class CellsJsonAsObsLocationsLoader extends JsonLoader {
@@ -17749,16 +17775,13 @@ class CellsJsonAsObsLocationsLoader extends JsonLoader {
17749
17775
  return this.cachedResult;
17750
17776
  }
17751
17777
  async load() {
17752
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17753
- if (payload instanceof AbstractLoaderError) {
17754
- return Promise.reject(payload);
17755
- }
17778
+ const payload = await super.load();
17756
17779
  const { data, url } = payload;
17757
17780
  const result = this.loadFromCache(data);
17758
- return Promise.resolve(new LoaderResult(
17781
+ return new LoaderResult(
17759
17782
  result,
17760
17783
  url
17761
- ));
17784
+ );
17762
17785
  }
17763
17786
  }
17764
17787
  function square(x, y, r2) {
@@ -17795,19 +17818,16 @@ class CellsJsonAsObsSegmentationsLoader extends JsonLoader {
17795
17818
  return this.cachedResult;
17796
17819
  }
17797
17820
  async load() {
17798
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17799
- if (payload instanceof AbstractLoaderError) {
17800
- return Promise.reject(payload);
17801
- }
17821
+ const payload = await super.load();
17802
17822
  const { data, url } = payload;
17803
17823
  const result = this.loadFromCache(data);
17804
17824
  const coordinationValues = {
17805
17825
  spatialSegmentationLayer: DEFAULT_CELLS_LAYER
17806
17826
  };
17807
- return Promise.resolve(new LoaderResult({
17827
+ return new LoaderResult({
17808
17828
  ...result,
17809
17829
  obsSegmentationsType: "polygon"
17810
- }, url, coordinationValues));
17830
+ }, url, coordinationValues);
17811
17831
  }
17812
17832
  }
17813
17833
  function extent$1(values2, valueof) {
@@ -17870,16 +17890,13 @@ class ClustersJsonAsObsFeatureMatrixLoader extends JsonLoader {
17870
17890
  return this.cachedResult;
17871
17891
  }
17872
17892
  async load() {
17873
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17874
- if (payload instanceof AbstractLoaderError) {
17875
- return Promise.reject(payload);
17876
- }
17893
+ const payload = await super.load();
17877
17894
  const { data, url } = payload;
17878
17895
  const result = this.loadFromCache(data);
17879
- return Promise.resolve(new LoaderResult(
17896
+ return new LoaderResult(
17880
17897
  result,
17881
17898
  url
17882
- ));
17899
+ );
17883
17900
  }
17884
17901
  }
17885
17902
  const genesSchema = z.record(z.object({
@@ -17907,16 +17924,13 @@ class GenesJsonAsObsFeatureMatrixLoader extends JsonLoader {
17907
17924
  return this.cachedResult;
17908
17925
  }
17909
17926
  async load() {
17910
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17911
- if (payload instanceof AbstractLoaderError) {
17912
- return Promise.reject(payload);
17913
- }
17927
+ const payload = await super.load();
17914
17928
  const { data, url } = payload;
17915
17929
  const result = this.loadFromCache(data);
17916
- return Promise.resolve(new LoaderResult(
17930
+ return new LoaderResult(
17917
17931
  result,
17918
17932
  url
17919
- ));
17933
+ );
17920
17934
  }
17921
17935
  }
17922
17936
  class MoleculesJsonAsObsLabelsLoader extends JsonLoader {
@@ -17940,13 +17954,10 @@ class MoleculesJsonAsObsLabelsLoader extends JsonLoader {
17940
17954
  return this.cachedResult;
17941
17955
  }
17942
17956
  async load() {
17943
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
17944
- if (payload instanceof AbstractLoaderError) {
17945
- return Promise.reject(payload);
17946
- }
17957
+ const payload = await super.load();
17947
17958
  const { data, url } = payload;
17948
17959
  const result = this.loadFromCache(data);
17949
- return Promise.resolve(new LoaderResult(result, url));
17960
+ return new LoaderResult(result, url);
17950
17961
  }
17951
17962
  }
17952
17963
  function assert$e(condition, message) {
@@ -137084,22 +137095,22 @@ async function getDecoder(fileDirectory) {
137084
137095
  const Decoder = await importFn();
137085
137096
  return new Decoder(fileDirectory);
137086
137097
  }
137087
- addDecoder([void 0, 1], () => import("./raw-Cy08b44Z.js").then((m) => m.default));
137088
- addDecoder(5, () => import("./lzw-U6CSxLDR.js").then((m) => m.default));
137098
+ addDecoder([void 0, 1], () => import("./raw-uN_cumDY.js").then((m) => m.default));
137099
+ addDecoder(5, () => import("./lzw-CscKL06f.js").then((m) => m.default));
137089
137100
  addDecoder(6, () => {
137090
137101
  throw new Error("old style JPEG compression is not supported.");
137091
137102
  });
137092
- addDecoder(7, () => import("./jpeg-HiHjx4CG.js").then((m) => m.default));
137093
- addDecoder([8, 32946], () => import("./deflate-BYKpSTT6.js").then((m) => m.default));
137094
- addDecoder(32773, () => import("./packbits-DoX7PkwR.js").then((m) => m.default));
137103
+ addDecoder(7, () => import("./jpeg-DLyTBIoB.js").then((m) => m.default));
137104
+ addDecoder([8, 32946], () => import("./deflate-DstPPSeQ.js").then((m) => m.default));
137105
+ addDecoder(32773, () => import("./packbits-D3LeL8FE.js").then((m) => m.default));
137095
137106
  addDecoder(
137096
137107
  34887,
137097
- () => import("./lerc-BMjU_3GZ.js").then(async (m) => {
137108
+ () => import("./lerc-C3NYZ4w9.js").then(async (m) => {
137098
137109
  await m.zstd.init();
137099
137110
  return m;
137100
137111
  }).then((m) => m.default)
137101
137112
  );
137102
- addDecoder(50001, () => import("./webimage-Pvwg1VPe.js").then((m) => m.default));
137113
+ addDecoder(50001, () => import("./webimage-CsEP6b6I.js").then((m) => m.default));
137103
137114
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
137104
137115
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
137105
137116
  }
@@ -154064,11 +154075,80 @@ function getNgffAxes(firstMultiscalesAxes) {
154064
154075
  }
154065
154076
  return axes;
154066
154077
  }
154078
+ function getSwapAxesMatrix(inputAxes, outputAxes) {
154079
+ const size2 = inputAxes.length;
154080
+ if (!(size2 === 2 || size2 === 3)) {
154081
+ throw new Error(`Expected input and output axes to have 2 or 3 elements, got ${size2}.`);
154082
+ }
154083
+ const matrix2 = [
154084
+ [0, 0, 0, 0],
154085
+ [0, 0, 0, 0],
154086
+ [0, 0, size2 === 2 ? 1 : 0, 0],
154087
+ // In 2D, leave Z unchanged.
154088
+ [0, 0, 0, 1]
154089
+ ];
154090
+ for (let outRow = 0; outRow < size2; outRow++) {
154091
+ const axis = outputAxes[outRow];
154092
+ const inCol = inputAxes.indexOf(axis);
154093
+ if (inCol === -1) {
154094
+ throw new Error(`Axis "${axis}" not found in inputAxes`);
154095
+ }
154096
+ matrix2[outRow][inCol] = 1;
154097
+ }
154098
+ return matrix2;
154099
+ }
154067
154100
  function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
154068
154101
  let mat = new Matrix4().identity();
154069
154102
  if (coordinateTransformations && axes) {
154070
154103
  const xyzIndices = ["x", "y", "z"].map((name2) => axes.findIndex((axisObj) => axisObj.type === "space" && axisObj.name === name2));
154071
154104
  coordinateTransformations.forEach((transform2) => {
154105
+ if (transform2.type === "affine") {
154106
+ const { affine, input, output } = transform2;
154107
+ const excludeEntries = input.axes.map((axis, i2) => [axis, i2]).filter(([axis, i2]) => axis.type !== "space").map(([axis, i2]) => i2);
154108
+ const filteredAffine = affine.filter((_, i2) => !excludeEntries.includes(i2)).map((row) => row.filter((_, i2) => !excludeEntries.includes(i2)));
154109
+ const spatialInputAxes = input.axes.filter((axis) => axis.type === "space");
154110
+ const spatialOutputAxes = output.axes.filter((axis) => axis.type === "space");
154111
+ const inputAxisNames = spatialInputAxes.map((axis) => axis.name);
154112
+ const outputAxisNames = spatialOutputAxes.map((axis) => axis.name);
154113
+ if (spatialInputAxes.length === 3) {
154114
+ const nextMat = new Matrix4().fromArray([
154115
+ ...filteredAffine[0],
154116
+ ...filteredAffine[1],
154117
+ ...filteredAffine[2],
154118
+ 0,
154119
+ 0,
154120
+ 0,
154121
+ 1
154122
+ ]);
154123
+ mat = mat.multiplyLeft(nextMat);
154124
+ if (!isEqual$1(inputAxisNames, outputAxisNames)) {
154125
+ const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
154126
+ const swapMat = new Matrix4().fromArray(swapMatNested.flat());
154127
+ mat = mat.multiplyLeft(swapMat);
154128
+ }
154129
+ } else if (spatialOutputAxes.length === 2) {
154130
+ const nextMat = new Matrix4().fromArray([
154131
+ ...filteredAffine[0],
154132
+ ...filteredAffine[1],
154133
+ 0,
154134
+ 0,
154135
+ 1,
154136
+ 0,
154137
+ 0,
154138
+ 0,
154139
+ 0,
154140
+ 1
154141
+ ]);
154142
+ mat = mat.multiplyLeft(nextMat);
154143
+ if (!isEqual$1(inputAxisNames, outputAxisNames)) {
154144
+ const swapMatNested = getSwapAxesMatrix(inputAxisNames, outputAxisNames);
154145
+ const swapMat = new Matrix4().fromArray(swapMatNested.flat());
154146
+ mat = mat.multiplyLeft(swapMat);
154147
+ }
154148
+ } else {
154149
+ throw new Error("Affine transformation must have 2 or 3 rows.");
154150
+ }
154151
+ }
154072
154152
  if (transform2.type === "translation") {
154073
154153
  const { translation: axisOrderedTranslation } = transform2;
154074
154154
  if (axisOrderedTranslation.length !== axes.length) {
@@ -155712,7 +155792,15 @@ function isAxis(axisOrLabel) {
155712
155792
  return typeof axisOrLabel[0] !== "string";
155713
155793
  }
155714
155794
  async function loadMultiscales(root2) {
155715
- const rootAttrs = (await open(root2)).attrs;
155795
+ let rootAttrs;
155796
+ try {
155797
+ rootAttrs = (await open(root2)).attrs;
155798
+ } catch (e2) {
155799
+ if (e2.name === "NodeNotFoundError") {
155800
+ throw new ZarrNodeNotFoundError(root2.path);
155801
+ }
155802
+ throw e2;
155803
+ }
155716
155804
  let paths = ["0"];
155717
155805
  let labels = ["t", "c", "z", "y", "x"];
155718
155806
  if ("multiscales" in rootAttrs) {
@@ -155725,6 +155813,8 @@ async function loadMultiscales(root2) {
155725
155813
  labels = axes;
155726
155814
  }
155727
155815
  }
155816
+ } else {
155817
+ throw new Error("Expected the Zarr store to contain OME-NGFF multiscales metadata.");
155728
155818
  }
155729
155819
  const data = paths.map((path) => open(root2.resolve(path), { kind: "array" }));
155730
155820
  return {
@@ -155786,17 +155876,14 @@ class MoleculesJsonAsObsLocationsLoader extends JsonLoader {
155786
155876
  return this.cachedResult;
155787
155877
  }
155788
155878
  async load() {
155789
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
155790
- if (payload instanceof AbstractLoaderError) {
155791
- return Promise.reject(payload);
155792
- }
155879
+ const payload = await super.load();
155793
155880
  const { data, url } = payload;
155794
155881
  const result = this.loadFromCache(data);
155795
155882
  const coordinationValues = {
155796
155883
  // TODO: do this for anndata segmentation loader
155797
155884
  spatialPointLayer: DEFAULT_MOLECULES_LAYER
155798
155885
  };
155799
- return Promise.resolve(new LoaderResult(result, url, coordinationValues));
155886
+ return new LoaderResult(result, url, coordinationValues);
155800
155887
  }
155801
155888
  }
155802
155889
  async function initLoader(imageData) {
@@ -155909,10 +155996,7 @@ class RasterLoader extends JsonLoader {
155909
155996
  this.schema = rasterJsonSchema;
155910
155997
  }
155911
155998
  async load() {
155912
- const payload = await super.load().catch((reason) => Promise.resolve(reason));
155913
- if (payload instanceof AbstractLoaderError) {
155914
- return Promise.reject(payload);
155915
- }
155999
+ const payload = await super.load();
155916
156000
  const { data: raster } = payload;
155917
156001
  const { images, renderLayers, usePhysicalSizeScaling = false } = raster;
155918
156002
  const urls = images.filter((image2) => !image2.url.includes("zarr")).map((image2) => ({ url: image2.url, name: image2.name }));
@@ -155933,7 +156017,10 @@ class RasterLoader extends JsonLoader {
155933
156017
  spatialImageLayer: autoImageLayers
155934
156018
  };
155935
156019
  return new LoaderResult(
155936
- { loaders: imageLayerLoaders, meta: imageLayerMeta },
156020
+ {
156021
+ loaders: imageLayerLoaders,
156022
+ meta: imageLayerMeta
156023
+ },
155937
156024
  urls,
155938
156025
  coordinationValues
155939
156026
  );
@@ -155943,10 +156030,7 @@ class RasterLoader extends JsonLoader {
155943
156030
  class RasterJsonAsImageLoader extends RasterLoader {
155944
156031
  async load() {
155945
156032
  var _a3;
155946
- const loaderResult = await super.load().catch((reason) => Promise.resolve(reason));
155947
- if (loaderResult instanceof AbstractLoaderError) {
155948
- return Promise.reject(loaderResult);
155949
- }
156033
+ const loaderResult = await super.load();
155950
156034
  const { data = {}, url: urls, coordinationValues } = loaderResult;
155951
156035
  const { loaders: allLoaders = [], meta: allMeta = [] } = data;
155952
156036
  const loaders = [];
@@ -155979,10 +156063,7 @@ class RasterJsonAsImageLoader extends RasterLoader {
155979
156063
  class RasterJsonAsObsSegmentationsLoader extends RasterLoader {
155980
156064
  async load() {
155981
156065
  var _a3;
155982
- const loaderResult = await super.load().catch((reason) => Promise.resolve(reason));
155983
- if (loaderResult instanceof AbstractLoaderError) {
155984
- return Promise.reject(loaderResult);
155985
- }
156066
+ const loaderResult = await super.load();
155986
156067
  const { data = {}, url: urls, coordinationValues } = loaderResult;
155987
156068
  const { loaders: allLoaders = [], meta: allMeta = [] } = data;
155988
156069
  const loaders = [];