@vitessce/csv 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.
package/dist/index.js CHANGED
@@ -114,6 +114,40 @@ function dsvFormat(delimiter) {
114
114
  }
115
115
  var csv = dsvFormat(",");
116
116
  var csvParse = csv.parse;
117
+ class VitessceError extends Error {
118
+ constructor(message) {
119
+ super(message);
120
+ this.name = "VitessceError";
121
+ }
122
+ }
123
+ class DataLoaderError extends VitessceError {
124
+ constructor(message) {
125
+ super(message);
126
+ this.name = "DataLoaderError";
127
+ }
128
+ }
129
+ class DataFetchError extends DataLoaderError {
130
+ constructor(message) {
131
+ super(message);
132
+ this.name = "DataFetchError";
133
+ }
134
+ }
135
+ class CsvSource {
136
+ constructor({ url, requestInit: requestInit2 }) {
137
+ this.url = url;
138
+ this.requestInit = requestInit2;
139
+ }
140
+ async loadCsv() {
141
+ if (this._data) return this._data;
142
+ const response = await fetch(this.url, this.requestInit);
143
+ if (!response.ok) {
144
+ throw new DataFetchError(`loadCsv failed for ${this.url}`);
145
+ }
146
+ const responseText = await response.text();
147
+ this._data = csvParse(responseText);
148
+ return this._data;
149
+ }
150
+ }
117
151
  class LoaderResult {
118
152
  /**
119
153
  * @param {LoaderDataType} data
@@ -161,359 +195,17 @@ class AbstractTwoStepLoader extends AbstractLoader {
161
195
  this.dataSource = dataSource;
162
196
  }
163
197
  }
164
- class AbstractLoaderError {
165
- constructor(message) {
166
- this.message = message;
167
- }
168
- // eslint-disable-next-line class-methods-use-this
169
- warnInConsole() {
170
- throw new Error("The warnInConsole() method has not been implemented.");
171
- }
172
- }
173
- var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
174
- function getDefaultExportFromCjs(x) {
175
- return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
176
- }
177
- function getAugmentedNamespace(n) {
178
- if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
179
- var f = n.default;
180
- if (typeof f == "function") {
181
- var a = function a2() {
182
- if (this instanceof a2) {
183
- return Reflect.construct(f, arguments, this.constructor);
184
- }
185
- return f.apply(this, arguments);
186
- };
187
- a.prototype = f.prototype;
188
- } else a = {};
189
- Object.defineProperty(a, "__esModule", { value: true });
190
- Object.keys(n).forEach(function(k) {
191
- var d = Object.getOwnPropertyDescriptor(n, k);
192
- Object.defineProperty(a, k, d.get ? d : {
193
- enumerable: true,
194
- get: function() {
195
- return n[k];
196
- }
197
- });
198
- });
199
- return a;
200
- }
201
- var loglevel$1 = { exports: {} };
202
- var loglevel = loglevel$1.exports;
203
- var hasRequiredLoglevel;
204
- function requireLoglevel() {
205
- if (hasRequiredLoglevel) return loglevel$1.exports;
206
- hasRequiredLoglevel = 1;
207
- (function(module2) {
208
- (function(root2, definition) {
209
- if (module2.exports) {
210
- module2.exports = definition();
211
- } else {
212
- root2.log = definition();
213
- }
214
- })(loglevel, function() {
215
- var noop = function() {
216
- };
217
- var undefinedType2 = "undefined";
218
- var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
219
- var logMethods = [
220
- "trace",
221
- "debug",
222
- "info",
223
- "warn",
224
- "error"
225
- ];
226
- var _loggersByName = {};
227
- var defaultLogger = null;
228
- function bindMethod(obj, methodName) {
229
- var method = obj[methodName];
230
- if (typeof method.bind === "function") {
231
- return method.bind(obj);
232
- } else {
233
- try {
234
- return Function.prototype.bind.call(method, obj);
235
- } catch (e) {
236
- return function() {
237
- return Function.prototype.apply.apply(method, [obj, arguments]);
238
- };
239
- }
240
- }
241
- }
242
- function traceForIE() {
243
- if (console.log) {
244
- if (console.log.apply) {
245
- console.log.apply(console, arguments);
246
- } else {
247
- Function.prototype.apply.apply(console.log, [console, arguments]);
248
- }
249
- }
250
- if (console.trace) console.trace();
251
- }
252
- function realMethod(methodName) {
253
- if (methodName === "debug") {
254
- methodName = "log";
255
- }
256
- if (typeof console === undefinedType2) {
257
- return false;
258
- } else if (methodName === "trace" && isIE) {
259
- return traceForIE;
260
- } else if (console[methodName] !== void 0) {
261
- return bindMethod(console, methodName);
262
- } else if (console.log !== void 0) {
263
- return bindMethod(console, "log");
264
- } else {
265
- return noop;
266
- }
267
- }
268
- function replaceLoggingMethods() {
269
- var level = this.getLevel();
270
- for (var i = 0; i < logMethods.length; i++) {
271
- var methodName = logMethods[i];
272
- this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
273
- }
274
- this.log = this.debug;
275
- if (typeof console === undefinedType2 && level < this.levels.SILENT) {
276
- return "No console available for logging";
277
- }
278
- }
279
- function enableLoggingWhenConsoleArrives(methodName) {
280
- return function() {
281
- if (typeof console !== undefinedType2) {
282
- replaceLoggingMethods.call(this);
283
- this[methodName].apply(this, arguments);
284
- }
285
- };
286
- }
287
- function defaultMethodFactory(methodName, _level, _loggerName) {
288
- return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
289
- }
290
- function Logger(name, factory) {
291
- var self2 = this;
292
- var inheritedLevel;
293
- var defaultLevel;
294
- var userLevel;
295
- var storageKey = "loglevel";
296
- if (typeof name === "string") {
297
- storageKey += ":" + name;
298
- } else if (typeof name === "symbol") {
299
- storageKey = void 0;
300
- }
301
- function persistLevelIfPossible(levelNum) {
302
- var levelName = (logMethods[levelNum] || "silent").toUpperCase();
303
- if (typeof window === undefinedType2 || !storageKey) return;
304
- try {
305
- window.localStorage[storageKey] = levelName;
306
- return;
307
- } catch (ignore) {
308
- }
309
- try {
310
- window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
311
- } catch (ignore) {
312
- }
313
- }
314
- function getPersistedLevel() {
315
- var storedLevel;
316
- if (typeof window === undefinedType2 || !storageKey) return;
317
- try {
318
- storedLevel = window.localStorage[storageKey];
319
- } catch (ignore) {
320
- }
321
- if (typeof storedLevel === undefinedType2) {
322
- try {
323
- var cookie = window.document.cookie;
324
- var cookieName = encodeURIComponent(storageKey);
325
- var location = cookie.indexOf(cookieName + "=");
326
- if (location !== -1) {
327
- storedLevel = /^([^;]+)/.exec(
328
- cookie.slice(location + cookieName.length + 1)
329
- )[1];
330
- }
331
- } catch (ignore) {
332
- }
333
- }
334
- if (self2.levels[storedLevel] === void 0) {
335
- storedLevel = void 0;
336
- }
337
- return storedLevel;
338
- }
339
- function clearPersistedLevel() {
340
- if (typeof window === undefinedType2 || !storageKey) return;
341
- try {
342
- window.localStorage.removeItem(storageKey);
343
- } catch (ignore) {
344
- }
345
- try {
346
- window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
347
- } catch (ignore) {
348
- }
349
- }
350
- function normalizeLevel(input) {
351
- var level = input;
352
- if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
353
- level = self2.levels[level.toUpperCase()];
354
- }
355
- if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
356
- return level;
357
- } else {
358
- throw new TypeError("log.setLevel() called with invalid level: " + input);
359
- }
360
- }
361
- self2.name = name;
362
- self2.levels = {
363
- "TRACE": 0,
364
- "DEBUG": 1,
365
- "INFO": 2,
366
- "WARN": 3,
367
- "ERROR": 4,
368
- "SILENT": 5
369
- };
370
- self2.methodFactory = factory || defaultMethodFactory;
371
- self2.getLevel = function() {
372
- if (userLevel != null) {
373
- return userLevel;
374
- } else if (defaultLevel != null) {
375
- return defaultLevel;
376
- } else {
377
- return inheritedLevel;
378
- }
379
- };
380
- self2.setLevel = function(level, persist) {
381
- userLevel = normalizeLevel(level);
382
- if (persist !== false) {
383
- persistLevelIfPossible(userLevel);
384
- }
385
- return replaceLoggingMethods.call(self2);
386
- };
387
- self2.setDefaultLevel = function(level) {
388
- defaultLevel = normalizeLevel(level);
389
- if (!getPersistedLevel()) {
390
- self2.setLevel(level, false);
391
- }
392
- };
393
- self2.resetLevel = function() {
394
- userLevel = null;
395
- clearPersistedLevel();
396
- replaceLoggingMethods.call(self2);
397
- };
398
- self2.enableAll = function(persist) {
399
- self2.setLevel(self2.levels.TRACE, persist);
400
- };
401
- self2.disableAll = function(persist) {
402
- self2.setLevel(self2.levels.SILENT, persist);
403
- };
404
- self2.rebuild = function() {
405
- if (defaultLogger !== self2) {
406
- inheritedLevel = normalizeLevel(defaultLogger.getLevel());
407
- }
408
- replaceLoggingMethods.call(self2);
409
- if (defaultLogger === self2) {
410
- for (var childName in _loggersByName) {
411
- _loggersByName[childName].rebuild();
412
- }
413
- }
414
- };
415
- inheritedLevel = normalizeLevel(
416
- defaultLogger ? defaultLogger.getLevel() : "WARN"
417
- );
418
- var initialLevel = getPersistedLevel();
419
- if (initialLevel != null) {
420
- userLevel = normalizeLevel(initialLevel);
421
- }
422
- replaceLoggingMethods.call(self2);
423
- }
424
- defaultLogger = new Logger();
425
- defaultLogger.getLogger = function getLogger(name) {
426
- if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
427
- throw new TypeError("You must supply a name when creating a logger.");
428
- }
429
- var logger = _loggersByName[name];
430
- if (!logger) {
431
- logger = _loggersByName[name] = new Logger(
432
- name,
433
- defaultLogger.methodFactory
434
- );
435
- }
436
- return logger;
437
- };
438
- var _log = typeof window !== undefinedType2 ? window.log : void 0;
439
- defaultLogger.noConflict = function() {
440
- if (typeof window !== undefinedType2 && window.log === defaultLogger) {
441
- window.log = _log;
442
- }
443
- return defaultLogger;
444
- };
445
- defaultLogger.getLoggers = function getLoggers() {
446
- return _loggersByName;
447
- };
448
- defaultLogger["default"] = defaultLogger;
449
- return defaultLogger;
450
- });
451
- })(loglevel$1);
452
- return loglevel$1.exports;
453
- }
454
- var loglevelExports = requireLoglevel();
455
- const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
456
- class DataSourceFetchError extends AbstractLoaderError {
457
- constructor(source, url, headers) {
458
- super(`${source} Error HTTP Status fetching from ${url}`);
459
- this.source = source;
460
- this.url = url;
461
- this.headers = headers;
462
- this.message = `${source} failed to fetch from ${url} with headers ${JSON.stringify(headers)}`;
463
- }
464
- warnInConsole() {
465
- const { message } = this;
466
- log.warn(message);
467
- }
468
- }
469
- class CsvSource {
470
- constructor({ url, requestInit: requestInit2 }) {
471
- this.url = url;
472
- this.requestInit = requestInit2;
473
- }
474
- get data() {
475
- if (this._data) return this._data;
476
- this._data = fetch(this.url, this.requestInit).then((response) => {
477
- if (!response.ok) {
478
- return Promise.reject(new DataSourceFetchError("CsvSource", this.url, response.headers));
479
- }
480
- return response.text();
481
- }).catch(() => Promise.reject(new DataSourceFetchError("CsvSource", this.url, {}))).then((data) => {
482
- if (data instanceof AbstractLoaderError) {
483
- return Promise.reject(data);
484
- }
485
- return csvParse(data);
486
- });
487
- return this._data;
488
- }
489
- }
490
198
  class CsvLoader extends AbstractTwoStepLoader {
491
- getSourceData() {
492
- const {
493
- url
494
- } = this;
495
- if (this.data) {
496
- return this.data;
497
- }
498
- this.data = this.dataSource.data.then((data) => {
499
- if (data instanceof AbstractLoaderError) {
500
- return Promise.reject(data);
501
- }
502
- return Promise.resolve(new LoaderResult(data, url));
503
- });
504
- return this.data;
199
+ async getSourceData() {
200
+ return new LoaderResult(await this.dataSource.loadCsv(), this.url);
505
201
  }
506
202
  async load() {
507
- const payload = await this.getSourceData().catch((reason) => Promise.resolve(reason));
508
- if (payload instanceof AbstractLoaderError) {
509
- return Promise.reject(payload);
510
- }
511
- const { data, url } = payload;
203
+ const { data, url } = await this.getSourceData();
512
204
  const result = this.loadFromCache(data);
513
- return Promise.resolve(new LoaderResult(
205
+ return new LoaderResult(
514
206
  result,
515
207
  url
516
- ));
208
+ );
517
209
  }
518
210
  }
519
211
  class FeatureLabelsCsvLoader extends CsvLoader {
@@ -715,9 +407,7 @@ const FileType$1 = {
715
407
  OBS_SETS_SPATIALDATA_ZARR: "obsSets.spatialdata.zarr",
716
408
  OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
717
409
  FEATURE_LABELS_SPATIALDATA_ZARR: "featureLabels.spatialdata.zarr",
718
- // TODO:
719
- // OBS_POINTS_SPATIALDATA_ZARR: 'obsPoints.spatialdata.zarr',
720
- // OBS_LOCATIONS_SPATIALDATA_ZARR: 'obsLocations.spatialdata.zarr',
410
+ OBS_POINTS_SPATIALDATA_ZARR: "obsPoints.spatialdata.zarr",
721
411
  // SpatialData - zipped
722
412
  IMAGE_SPATIALDATA_ZARR_ZIP: "image.spatialdata.zarr.zip",
723
413
  LABELS_SPATIALDATA_ZARR_ZIP: "labels.spatialdata.zarr.zip",
@@ -726,6 +416,7 @@ const FileType$1 = {
726
416
  OBS_SETS_SPATIALDATA_ZARR_ZIP: "obsSets.spatialdata.zarr.zip",
727
417
  OBS_SPOTS_SPATIALDATA_ZARR_ZIP: "obsSpots.spatialdata.zarr.zip",
728
418
  FEATURE_LABELS_SPATIALDATA_ZARR_ZIP: "featureLabels.spatialdata.zarr.zip",
419
+ OBS_POINTS_SPATIALDATA_ZARR_ZIP: "obsPoints.spatialdata.zarr.zip",
729
420
  // MuData
730
421
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
731
422
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -972,6 +663,7 @@ const CoordinationType$1 = {
972
663
  [FileType$1.OBS_FEATURE_MATRIX_SPATIALDATA_ZARR]: DataType$1.OBS_FEATURE_MATRIX,
973
664
  [FileType$1.OBS_SETS_SPATIALDATA_ZARR]: DataType$1.OBS_SETS,
974
665
  [FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR]: DataType$1.FEATURE_LABELS,
666
+ [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: DataType$1.OBS_POINTS,
975
667
  // For new file types to support old file types
976
668
  [FileType$1.OBS_EMBEDDING_CELLS_JSON]: DataType$1.OBS_EMBEDDING,
977
669
  [FileType$1.OBS_LOCATIONS_CELLS_JSON]: DataType$1.OBS_LOCATIONS,
@@ -1145,6 +837,9 @@ const CoordinationType$1 = {
1145
837
  },
1146
838
  [FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR]: {
1147
839
  zip: FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR_ZIP
840
+ },
841
+ [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: {
842
+ zip: FileType$1.OBS_POINTS_SPATIALDATA_ZARR_ZIP
1148
843
  }
1149
844
  });
1150
845
  [
@@ -1819,6 +1514,34 @@ const CoordinationType$1 = {
1819
1514
  CoordinationType$1.HIERARCHY_LEVELS
1820
1515
  ]
1821
1516
  });
1517
+ var commonjsGlobal = typeof globalThis !== "undefined" ? globalThis : typeof window !== "undefined" ? window : typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : {};
1518
+ function getDefaultExportFromCjs(x) {
1519
+ return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
1520
+ }
1521
+ function getAugmentedNamespace(n) {
1522
+ if (Object.prototype.hasOwnProperty.call(n, "__esModule")) return n;
1523
+ var f = n.default;
1524
+ if (typeof f == "function") {
1525
+ var a = function a2() {
1526
+ if (this instanceof a2) {
1527
+ return Reflect.construct(f, arguments, this.constructor);
1528
+ }
1529
+ return f.apply(this, arguments);
1530
+ };
1531
+ a.prototype = f.prototype;
1532
+ } else a = {};
1533
+ Object.defineProperty(a, "__esModule", { value: true });
1534
+ Object.keys(n).forEach(function(k) {
1535
+ var d = Object.getOwnPropertyDescriptor(n, k);
1536
+ Object.defineProperty(a, k, d.get ? d : {
1537
+ enumerable: true,
1538
+ get: function() {
1539
+ return n[k];
1540
+ }
1541
+ });
1542
+ });
1543
+ return a;
1544
+ }
1822
1545
  function commonjsRequire(path) {
1823
1546
  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.');
1824
1547
  }
@@ -2197,18 +1920,273 @@ function getNextScope(prevScopes) {
2197
1920
  increment = false;
2198
1921
  break;
2199
1922
  }
2200
- }
2201
- if (increment) {
2202
- nextCharIndices.push(0);
2203
- }
2204
- return r.join("");
2205
- }
2206
- let nextScope;
2207
- do {
2208
- nextScope = next();
2209
- } while (prevScopes.includes(nextScope));
2210
- return nextScope;
1923
+ }
1924
+ if (increment) {
1925
+ nextCharIndices.push(0);
1926
+ }
1927
+ return r.join("");
1928
+ }
1929
+ let nextScope;
1930
+ do {
1931
+ nextScope = next();
1932
+ } while (prevScopes.includes(nextScope));
1933
+ return nextScope;
1934
+ }
1935
+ var loglevel$1 = { exports: {} };
1936
+ var loglevel = loglevel$1.exports;
1937
+ var hasRequiredLoglevel;
1938
+ function requireLoglevel() {
1939
+ if (hasRequiredLoglevel) return loglevel$1.exports;
1940
+ hasRequiredLoglevel = 1;
1941
+ (function(module2) {
1942
+ (function(root2, definition) {
1943
+ if (module2.exports) {
1944
+ module2.exports = definition();
1945
+ } else {
1946
+ root2.log = definition();
1947
+ }
1948
+ })(loglevel, function() {
1949
+ var noop = function() {
1950
+ };
1951
+ var undefinedType2 = "undefined";
1952
+ var isIE = typeof window !== undefinedType2 && typeof window.navigator !== undefinedType2 && /Trident\/|MSIE /.test(window.navigator.userAgent);
1953
+ var logMethods = [
1954
+ "trace",
1955
+ "debug",
1956
+ "info",
1957
+ "warn",
1958
+ "error"
1959
+ ];
1960
+ var _loggersByName = {};
1961
+ var defaultLogger = null;
1962
+ function bindMethod(obj, methodName) {
1963
+ var method = obj[methodName];
1964
+ if (typeof method.bind === "function") {
1965
+ return method.bind(obj);
1966
+ } else {
1967
+ try {
1968
+ return Function.prototype.bind.call(method, obj);
1969
+ } catch (e) {
1970
+ return function() {
1971
+ return Function.prototype.apply.apply(method, [obj, arguments]);
1972
+ };
1973
+ }
1974
+ }
1975
+ }
1976
+ function traceForIE() {
1977
+ if (console.log) {
1978
+ if (console.log.apply) {
1979
+ console.log.apply(console, arguments);
1980
+ } else {
1981
+ Function.prototype.apply.apply(console.log, [console, arguments]);
1982
+ }
1983
+ }
1984
+ if (console.trace) console.trace();
1985
+ }
1986
+ function realMethod(methodName) {
1987
+ if (methodName === "debug") {
1988
+ methodName = "log";
1989
+ }
1990
+ if (typeof console === undefinedType2) {
1991
+ return false;
1992
+ } else if (methodName === "trace" && isIE) {
1993
+ return traceForIE;
1994
+ } else if (console[methodName] !== void 0) {
1995
+ return bindMethod(console, methodName);
1996
+ } else if (console.log !== void 0) {
1997
+ return bindMethod(console, "log");
1998
+ } else {
1999
+ return noop;
2000
+ }
2001
+ }
2002
+ function replaceLoggingMethods() {
2003
+ var level = this.getLevel();
2004
+ for (var i = 0; i < logMethods.length; i++) {
2005
+ var methodName = logMethods[i];
2006
+ this[methodName] = i < level ? noop : this.methodFactory(methodName, level, this.name);
2007
+ }
2008
+ this.log = this.debug;
2009
+ if (typeof console === undefinedType2 && level < this.levels.SILENT) {
2010
+ return "No console available for logging";
2011
+ }
2012
+ }
2013
+ function enableLoggingWhenConsoleArrives(methodName) {
2014
+ return function() {
2015
+ if (typeof console !== undefinedType2) {
2016
+ replaceLoggingMethods.call(this);
2017
+ this[methodName].apply(this, arguments);
2018
+ }
2019
+ };
2020
+ }
2021
+ function defaultMethodFactory(methodName, _level, _loggerName) {
2022
+ return realMethod(methodName) || enableLoggingWhenConsoleArrives.apply(this, arguments);
2023
+ }
2024
+ function Logger(name, factory) {
2025
+ var self2 = this;
2026
+ var inheritedLevel;
2027
+ var defaultLevel;
2028
+ var userLevel;
2029
+ var storageKey = "loglevel";
2030
+ if (typeof name === "string") {
2031
+ storageKey += ":" + name;
2032
+ } else if (typeof name === "symbol") {
2033
+ storageKey = void 0;
2034
+ }
2035
+ function persistLevelIfPossible(levelNum) {
2036
+ var levelName = (logMethods[levelNum] || "silent").toUpperCase();
2037
+ if (typeof window === undefinedType2 || !storageKey) return;
2038
+ try {
2039
+ window.localStorage[storageKey] = levelName;
2040
+ return;
2041
+ } catch (ignore) {
2042
+ }
2043
+ try {
2044
+ window.document.cookie = encodeURIComponent(storageKey) + "=" + levelName + ";";
2045
+ } catch (ignore) {
2046
+ }
2047
+ }
2048
+ function getPersistedLevel() {
2049
+ var storedLevel;
2050
+ if (typeof window === undefinedType2 || !storageKey) return;
2051
+ try {
2052
+ storedLevel = window.localStorage[storageKey];
2053
+ } catch (ignore) {
2054
+ }
2055
+ if (typeof storedLevel === undefinedType2) {
2056
+ try {
2057
+ var cookie = window.document.cookie;
2058
+ var cookieName = encodeURIComponent(storageKey);
2059
+ var location = cookie.indexOf(cookieName + "=");
2060
+ if (location !== -1) {
2061
+ storedLevel = /^([^;]+)/.exec(
2062
+ cookie.slice(location + cookieName.length + 1)
2063
+ )[1];
2064
+ }
2065
+ } catch (ignore) {
2066
+ }
2067
+ }
2068
+ if (self2.levels[storedLevel] === void 0) {
2069
+ storedLevel = void 0;
2070
+ }
2071
+ return storedLevel;
2072
+ }
2073
+ function clearPersistedLevel() {
2074
+ if (typeof window === undefinedType2 || !storageKey) return;
2075
+ try {
2076
+ window.localStorage.removeItem(storageKey);
2077
+ } catch (ignore) {
2078
+ }
2079
+ try {
2080
+ window.document.cookie = encodeURIComponent(storageKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC";
2081
+ } catch (ignore) {
2082
+ }
2083
+ }
2084
+ function normalizeLevel(input) {
2085
+ var level = input;
2086
+ if (typeof level === "string" && self2.levels[level.toUpperCase()] !== void 0) {
2087
+ level = self2.levels[level.toUpperCase()];
2088
+ }
2089
+ if (typeof level === "number" && level >= 0 && level <= self2.levels.SILENT) {
2090
+ return level;
2091
+ } else {
2092
+ throw new TypeError("log.setLevel() called with invalid level: " + input);
2093
+ }
2094
+ }
2095
+ self2.name = name;
2096
+ self2.levels = {
2097
+ "TRACE": 0,
2098
+ "DEBUG": 1,
2099
+ "INFO": 2,
2100
+ "WARN": 3,
2101
+ "ERROR": 4,
2102
+ "SILENT": 5
2103
+ };
2104
+ self2.methodFactory = factory || defaultMethodFactory;
2105
+ self2.getLevel = function() {
2106
+ if (userLevel != null) {
2107
+ return userLevel;
2108
+ } else if (defaultLevel != null) {
2109
+ return defaultLevel;
2110
+ } else {
2111
+ return inheritedLevel;
2112
+ }
2113
+ };
2114
+ self2.setLevel = function(level, persist) {
2115
+ userLevel = normalizeLevel(level);
2116
+ if (persist !== false) {
2117
+ persistLevelIfPossible(userLevel);
2118
+ }
2119
+ return replaceLoggingMethods.call(self2);
2120
+ };
2121
+ self2.setDefaultLevel = function(level) {
2122
+ defaultLevel = normalizeLevel(level);
2123
+ if (!getPersistedLevel()) {
2124
+ self2.setLevel(level, false);
2125
+ }
2126
+ };
2127
+ self2.resetLevel = function() {
2128
+ userLevel = null;
2129
+ clearPersistedLevel();
2130
+ replaceLoggingMethods.call(self2);
2131
+ };
2132
+ self2.enableAll = function(persist) {
2133
+ self2.setLevel(self2.levels.TRACE, persist);
2134
+ };
2135
+ self2.disableAll = function(persist) {
2136
+ self2.setLevel(self2.levels.SILENT, persist);
2137
+ };
2138
+ self2.rebuild = function() {
2139
+ if (defaultLogger !== self2) {
2140
+ inheritedLevel = normalizeLevel(defaultLogger.getLevel());
2141
+ }
2142
+ replaceLoggingMethods.call(self2);
2143
+ if (defaultLogger === self2) {
2144
+ for (var childName in _loggersByName) {
2145
+ _loggersByName[childName].rebuild();
2146
+ }
2147
+ }
2148
+ };
2149
+ inheritedLevel = normalizeLevel(
2150
+ defaultLogger ? defaultLogger.getLevel() : "WARN"
2151
+ );
2152
+ var initialLevel = getPersistedLevel();
2153
+ if (initialLevel != null) {
2154
+ userLevel = normalizeLevel(initialLevel);
2155
+ }
2156
+ replaceLoggingMethods.call(self2);
2157
+ }
2158
+ defaultLogger = new Logger();
2159
+ defaultLogger.getLogger = function getLogger(name) {
2160
+ if (typeof name !== "symbol" && typeof name !== "string" || name === "") {
2161
+ throw new TypeError("You must supply a name when creating a logger.");
2162
+ }
2163
+ var logger = _loggersByName[name];
2164
+ if (!logger) {
2165
+ logger = _loggersByName[name] = new Logger(
2166
+ name,
2167
+ defaultLogger.methodFactory
2168
+ );
2169
+ }
2170
+ return logger;
2171
+ };
2172
+ var _log = typeof window !== undefinedType2 ? window.log : void 0;
2173
+ defaultLogger.noConflict = function() {
2174
+ if (typeof window !== undefinedType2 && window.log === defaultLogger) {
2175
+ window.log = _log;
2176
+ }
2177
+ return defaultLogger;
2178
+ };
2179
+ defaultLogger.getLoggers = function getLoggers() {
2180
+ return _loggersByName;
2181
+ };
2182
+ defaultLogger["default"] = defaultLogger;
2183
+ return defaultLogger;
2184
+ });
2185
+ })(loglevel$1);
2186
+ return loglevel$1.exports;
2211
2187
  }
2188
+ var loglevelExports = requireLoglevel();
2189
+ const log = /* @__PURE__ */ getDefaultExportFromCjs(loglevelExports);
2212
2190
  const PALETTE = [
2213
2191
  [68, 119, 170],
2214
2192
  [136, 204, 238],
@@ -2255,10 +2233,7 @@ class ObsSpotsCsvLoader extends CsvLoader {
2255
2233
  return this.cachedResult;
2256
2234
  }
2257
2235
  async load() {
2258
- const payload = await this.getSourceData().catch((reason) => Promise.resolve(reason));
2259
- if (payload instanceof AbstractLoaderError) {
2260
- return Promise.reject(payload);
2261
- }
2236
+ const payload = await this.getSourceData();
2262
2237
  const coordinationValues = {
2263
2238
  spotLayer: CL({
2264
2239
  obsType: "spot",
@@ -2278,11 +2253,11 @@ class ObsSpotsCsvLoader extends CsvLoader {
2278
2253
  };
2279
2254
  const { data, url } = payload;
2280
2255
  const result = this.loadFromCache(data);
2281
- return Promise.resolve(new LoaderResult(
2256
+ return new LoaderResult(
2282
2257
  result,
2283
2258
  url,
2284
2259
  coordinationValues
2285
- ));
2260
+ );
2286
2261
  }
2287
2262
  }
2288
2263
  class ObsPointsCsvLoader extends CsvLoader {
@@ -2302,10 +2277,7 @@ class ObsPointsCsvLoader extends CsvLoader {
2302
2277
  return this.cachedResult;
2303
2278
  }
2304
2279
  async load() {
2305
- const payload = await this.getSourceData().catch((reason) => Promise.resolve(reason));
2306
- if (payload instanceof AbstractLoaderError) {
2307
- return Promise.reject(payload);
2308
- }
2280
+ const payload = await this.getSourceData();
2309
2281
  const coordinationValues = {
2310
2282
  pointLayer: CL({
2311
2283
  obsType: "point",
@@ -8046,6 +8018,9 @@ const configSchema1_0_16 = configSchema1_0_13.extend({
8046
8018
  const configSchema1_0_17 = configSchema1_0_16.extend({
8047
8019
  version: z.literal("1.0.17")
8048
8020
  });
8021
+ const configSchema1_0_18 = configSchema1_0_17.extend({
8022
+ version: z.literal("1.0.18")
8023
+ });
8049
8024
  configSchema1_0_0.shape.coordinationSpace.unwrap();
8050
8025
  configSchema1_0_0.shape.layout.element.shape.coordinationScopes.unwrap();
8051
8026
  function upgradeReplaceViewProp(prefix, view, coordinationSpace) {
@@ -8553,7 +8528,54 @@ function upgradeFrom1_0_16(config) {
8553
8528
  version: "1.0.17"
8554
8529
  };
8555
8530
  }
8556
- const latestConfigSchema = configSchema1_0_17;
8531
+ function upgradeFrom1_0_17(config) {
8532
+ const newConfig = cloneDeep(config);
8533
+ const { datasets } = newConfig;
8534
+ const newDatasets = datasets.map((datasetDef) => {
8535
+ const { files } = datasetDef;
8536
+ const newFiles = files.map((fileDef) => {
8537
+ const { fileType, options } = fileDef;
8538
+ if (fileType === "spatialdata.zarr" || fileType === "spatialdata.zarr.zip") {
8539
+ if (options.labels && options.shapes) {
8540
+ 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.");
8541
+ }
8542
+ if (options.labels) {
8543
+ const newOptions = {
8544
+ ...options,
8545
+ obsSegmentations: options.labels
8546
+ };
8547
+ delete newOptions.labels;
8548
+ return {
8549
+ ...fileDef,
8550
+ options: newOptions
8551
+ };
8552
+ }
8553
+ if (options.shapes) {
8554
+ const newOptions = {
8555
+ ...options,
8556
+ obsSegmentations: options.shapes
8557
+ };
8558
+ delete newOptions.shapes;
8559
+ return {
8560
+ ...fileDef,
8561
+ options: newOptions
8562
+ };
8563
+ }
8564
+ }
8565
+ return fileDef;
8566
+ });
8567
+ return {
8568
+ ...datasetDef,
8569
+ files: newFiles
8570
+ };
8571
+ });
8572
+ return {
8573
+ ...newConfig,
8574
+ datasets: newDatasets,
8575
+ version: "1.0.18"
8576
+ };
8577
+ }
8578
+ const latestConfigSchema = configSchema1_0_18;
8557
8579
  const SCHEMA_HANDLERS = [
8558
8580
  [configSchema0_1_0, upgradeFrom0_1_0],
8559
8581
  [configSchema1_0_0, upgradeFrom1_0_0],
@@ -8572,7 +8594,8 @@ const SCHEMA_HANDLERS = [
8572
8594
  [configSchema1_0_13, upgradeFrom1_0_13],
8573
8595
  [configSchema1_0_14, upgradeFrom1_0_14],
8574
8596
  [configSchema1_0_15, upgradeFrom1_0_15],
8575
- [configSchema1_0_16, upgradeFrom1_0_16]
8597
+ [configSchema1_0_16, upgradeFrom1_0_16],
8598
+ [configSchema1_0_17, upgradeFrom1_0_17]
8576
8599
  ];
8577
8600
  var re = { exports: {} };
8578
8601
  var constants;
@@ -10815,10 +10838,14 @@ const imageSpatialdataSchema = z.object({
10815
10838
  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.')
10816
10839
  });
10817
10840
  const obsSegmentationsSpatialdataSchema = z.object({
10818
- // TODO: should this be renamed labelsSpatialdataSchema?
10819
- // TODO: support obsTypesFromChannelNames?
10820
- path: z.string(),
10821
- 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."),
10841
+ // TODO: support obsTypesFromElementNames?
10842
+ path: z.string().describe("The path to the segmentation data, stored in either shapes/ or labels/."),
10843
+ 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."),
10844
+ 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.')
10845
+ });
10846
+ const obsPointsSpatialdataSchema = z.object({
10847
+ path: z.string().describe("The path to the point data."),
10848
+ 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."),
10822
10849
  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.')
10823
10850
  });
10824
10851
  z.object({
@@ -10938,13 +10965,10 @@ z.object({
10938
10965
  image: imageSpatialdataSchema,
10939
10966
  // TODO: should this be a special schema
10940
10967
  // to allow specifying fileUid (like for embeddingType)?
10941
- // TODO: allow multiple labels?
10942
- labels: obsSegmentationsSpatialdataSchema,
10968
+ // TODO: allow multiple labels/shapes?
10969
+ obsSegmentations: obsSegmentationsSpatialdataSchema,
10970
+ obsPoints: obsPointsSpatialdataSchema,
10943
10971
  // TODO: allow multiple shapes?
10944
- // TODO: unify labels and shapes to obsSegmentations,
10945
- // then distinguish in expand function based on
10946
- // "labels/*" vs. "shapes/*" in path?
10947
- shapes: obsSegmentationsSpatialdataSchema,
10948
10972
  obsFeatureMatrix: obsFeatureMatrixSpatialdataSchema,
10949
10973
  obsSpots: obsSpotsSpatialdataSchema,
10950
10974
  // TODO: obsPoints
@@ -17451,10 +17475,7 @@ class ObsSetsCsvLoader extends CsvLoader {
17451
17475
  return [obsIndex, cellSetsTree, obsSetsMembership, coordinationValues];
17452
17476
  }
17453
17477
  async load() {
17454
- const payload = await this.getSourceData().catch((reason) => Promise.resolve(reason));
17455
- if (payload instanceof AbstractLoaderError) {
17456
- return Promise.reject(payload);
17457
- }
17478
+ const payload = await this.getSourceData();
17458
17479
  const { data, url } = payload;
17459
17480
  const [
17460
17481
  obsIndex,
@@ -17462,13 +17483,11 @@ class ObsSetsCsvLoader extends CsvLoader {
17462
17483
  obsSetsMembership,
17463
17484
  coordinationValues
17464
17485
  ] = this.loadFromCache(data);
17465
- return Promise.resolve(
17466
- new LoaderResult({
17467
- obsIndex,
17468
- obsSets: cellSetsTree,
17469
- obsSetsMembership
17470
- }, url, coordinationValues)
17471
- );
17486
+ return new LoaderResult({
17487
+ obsIndex,
17488
+ obsSets: cellSetsTree,
17489
+ obsSetsMembership
17490
+ }, url, coordinationValues);
17472
17491
  }
17473
17492
  }
17474
17493
  class SampleSetsCsvLoader extends CsvLoader {
@@ -17495,10 +17514,7 @@ class SampleSetsCsvLoader extends CsvLoader {
17495
17514
  return [obsIndex, cellSetsTree, obsSetsMembership, coordinationValues];
17496
17515
  }
17497
17516
  async load() {
17498
- const payload = await this.getSourceData().catch((reason) => Promise.resolve(reason));
17499
- if (payload instanceof AbstractLoaderError) {
17500
- return Promise.reject(payload);
17501
- }
17517
+ const payload = await this.getSourceData();
17502
17518
  const { data, url } = payload;
17503
17519
  const [
17504
17520
  obsIndex,
@@ -17506,13 +17522,11 @@ class SampleSetsCsvLoader extends CsvLoader {
17506
17522
  obsSetsMembership,
17507
17523
  coordinationValues
17508
17524
  ] = this.loadFromCache(data);
17509
- return Promise.resolve(
17510
- new LoaderResult({
17511
- sampleIndex: obsIndex,
17512
- sampleSets: cellSetsTree,
17513
- sampleSetsMembership: obsSetsMembership
17514
- }, url, coordinationValues)
17515
- );
17525
+ return new LoaderResult({
17526
+ sampleIndex: obsIndex,
17527
+ sampleSets: cellSetsTree,
17528
+ sampleSetsMembership: obsSetsMembership
17529
+ }, url, coordinationValues);
17516
17530
  }
17517
17531
  }
17518
17532
  export {