@vitessce/json 3.6.13 → 3.6.15

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.
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
2
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
3
3
  class DeflateDecoder extends BaseDecoder {
4
4
  decodeBlock(buffer) {
5
5
  return inflate_1(new Uint8Array(buffer)).buffer;
@@ -9,7 +9,7 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
9
9
  var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
10
10
  var __privateSet = (obj, member, value, setter2) => (__accessCheck(obj, member, "write to private field"), setter2 ? setter2.call(obj, value) : member.set(obj, value), value);
11
11
  var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
12
- var _a2, _b, _bytes, _encoder, _data, _stride, _TypedArray, _BYTES_PER_ELEMENT, _shape, _endian, _encoder_config, _decoder_config, _order, _inverseOrder, _shape2, _strides, _metadata, _metadata2, _c, _overrides, _use_suffix_request, _FetchStore_instances, merge_init_fn;
12
+ var _a2, _b, _overrides, _use_suffix_request, _FetchStore_instances, merge_init_fn, _bytes, _encoder, _data, _stride, _TypedArray, _BYTES_PER_ELEMENT, _shape, _endian, _encoder_config, _decoder_config, _order, _inverseOrder, _shape2, _strides, _metadata, _metadata2, _c;
13
13
  import "react";
14
14
  function _mergeNamespaces(n3, m) {
15
15
  for (var i2 = 0; i2 < m.length; i2++) {
@@ -210,6 +210,7 @@ const FileType$1 = {
210
210
  OBS_SPOTS_SPATIALDATA_ZARR: "obsSpots.spatialdata.zarr",
211
211
  FEATURE_LABELS_SPATIALDATA_ZARR: "featureLabels.spatialdata.zarr",
212
212
  OBS_POINTS_SPATIALDATA_ZARR: "obsPoints.spatialdata.zarr",
213
+ OBS_EMBEDDING_SPATIALDATA_ZARR: "obsEmbedding.spatialdata.zarr",
213
214
  // SpatialData - zipped
214
215
  IMAGE_SPATIALDATA_ZARR_ZIP: "image.spatialdata.zarr.zip",
215
216
  LABELS_SPATIALDATA_ZARR_ZIP: "labels.spatialdata.zarr.zip",
@@ -219,6 +220,7 @@ const FileType$1 = {
219
220
  OBS_SPOTS_SPATIALDATA_ZARR_ZIP: "obsSpots.spatialdata.zarr.zip",
220
221
  FEATURE_LABELS_SPATIALDATA_ZARR_ZIP: "featureLabels.spatialdata.zarr.zip",
221
222
  OBS_POINTS_SPATIALDATA_ZARR_ZIP: "obsPoints.spatialdata.zarr.zip",
223
+ OBS_EMBEDDING_SPATIALDATA_ZARR_ZIP: "obsEmbedding.spatialdata.zarr.zip",
222
224
  // MuData
223
225
  OBS_FEATURE_MATRIX_MUDATA_ZARR: "obsFeatureMatrix.mudata.zarr",
224
226
  OBS_SETS_MUDATA_ZARR: "obsSets.mudata.zarr",
@@ -466,6 +468,7 @@ const CoordinationType$1 = {
466
468
  [FileType$1.OBS_SETS_SPATIALDATA_ZARR]: DataType$2.OBS_SETS,
467
469
  [FileType$1.FEATURE_LABELS_SPATIALDATA_ZARR]: DataType$2.FEATURE_LABELS,
468
470
  [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: DataType$2.OBS_POINTS,
471
+ [FileType$1.OBS_EMBEDDING_SPATIALDATA_ZARR]: DataType$2.OBS_EMBEDDING,
469
472
  // For new file types to support old file types
470
473
  [FileType$1.OBS_EMBEDDING_CELLS_JSON]: DataType$2.OBS_EMBEDDING,
471
474
  [FileType$1.OBS_LOCATIONS_CELLS_JSON]: DataType$2.OBS_LOCATIONS,
@@ -642,6 +645,9 @@ const CoordinationType$1 = {
642
645
  },
643
646
  [FileType$1.OBS_POINTS_SPATIALDATA_ZARR]: {
644
647
  zip: FileType$1.OBS_POINTS_SPATIALDATA_ZARR_ZIP
648
+ },
649
+ [FileType$1.OBS_EMBEDDING_SPATIALDATA_ZARR]: {
650
+ zip: FileType$1.OBS_EMBEDDING_SPATIALDATA_ZARR_ZIP
645
651
  }
646
652
  });
647
653
  [
@@ -9956,6 +9962,16 @@ const obsSetsSpatialdataSchema = z.object({
9956
9962
  tablePath: z.string().optional().describe("The path to a table which contains the index for the set values."),
9957
9963
  obsSets: annDataObsSetsArr
9958
9964
  });
9965
+ annDataObsEmbedding.extend({
9966
+ // We extend anndataObsEmbedding which already has properties like `dims` and `path`.
9967
+ region: z.string().describe("The name of a region to use to filter instances (i.e., rows) in the table").optional(),
9968
+ tablePath: z.string().optional().describe("The path to a table which contains the index for the set values.")
9969
+ });
9970
+ const obsEmbeddingSpatialdataSchemaConvenience = z.union([
9971
+ annDataObsEmbedding,
9972
+ // For convenience, allow an array of items with `embeddingType` properties.
9973
+ z.array(annDataConvenienceObsEmbeddingItem)
9974
+ ]);
9959
9975
  z.object({
9960
9976
  targetX: z.number(),
9961
9977
  targetY: z.number(),
@@ -10064,9 +10080,10 @@ z.object({
10064
10080
  // TODO: obsPoints
10065
10081
  // TODO: obsLocations
10066
10082
  obsSets: obsSetsSpatialdataSchema,
10067
- // TODO: obsEmbedding
10083
+ obsEmbedding: obsEmbeddingSpatialdataSchemaConvenience,
10068
10084
  // TODO: obsLabels
10069
10085
  // TODO: featureLabels
10086
+ // TODO: allow specifying tablePath and region at the top-level here.
10070
10087
  coordinateSystem: z.string().optional().describe("The name of a coordinate transformation output used to transform all elements which lack a per-element coordinateSystem property.")
10071
10088
  }).partial();
10072
10089
  z.object({
@@ -137096,22 +137113,22 @@ async function getDecoder(fileDirectory) {
137096
137113
  const Decoder = await importFn();
137097
137114
  return new Decoder(fileDirectory);
137098
137115
  }
137099
- addDecoder([void 0, 1], () => import("./raw-BkEHccvG.js").then((m) => m.default));
137100
- addDecoder(5, () => import("./lzw-CT-xPuVt.js").then((m) => m.default));
137116
+ addDecoder([void 0, 1], () => import("./raw-DTPVJ1o9.js").then((m) => m.default));
137117
+ addDecoder(5, () => import("./lzw-CiXrXL8r.js").then((m) => m.default));
137101
137118
  addDecoder(6, () => {
137102
137119
  throw new Error("old style JPEG compression is not supported.");
137103
137120
  });
137104
- addDecoder(7, () => import("./jpeg-CgKC8pvg.js").then((m) => m.default));
137105
- addDecoder([8, 32946], () => import("./deflate-BB-_i4AV.js").then((m) => m.default));
137106
- addDecoder(32773, () => import("./packbits-CxU7_ENa.js").then((m) => m.default));
137121
+ addDecoder(7, () => import("./jpeg-uLYxf0zU.js").then((m) => m.default));
137122
+ addDecoder([8, 32946], () => import("./deflate-Dwj2TkFo.js").then((m) => m.default));
137123
+ addDecoder(32773, () => import("./packbits-jRtcxRzM.js").then((m) => m.default));
137107
137124
  addDecoder(
137108
137125
  34887,
137109
- () => import("./lerc-DHkuo7TO.js").then(async (m) => {
137126
+ () => import("./lerc-DgruiVGI.js").then(async (m) => {
137110
137127
  await m.zstd.init();
137111
137128
  return m;
137112
137129
  }).then((m) => m.default)
137113
137130
  );
137114
- addDecoder(50001, () => import("./webimage-BsYePjn2.js").then((m) => m.default));
137131
+ addDecoder(50001, () => import("./webimage-CXJ7hRD-.js").then((m) => m.default));
137115
137132
  function copyNewSize(array, width, height, samplesPerPixel = 1) {
137116
137133
  return new (Object.getPrototypeOf(array)).constructor(width * height * samplesPerPixel);
137117
137134
  }
@@ -150358,10 +150375,10 @@ function multiSetsToTextureData(multiFeatureValues, multiMatrixObsIndex, setColo
150358
150375
  channelIsSetColorMode.forEach((isSetColorMode, channelIndex) => {
150359
150376
  var _a3, _b2, _c2, _d;
150360
150377
  if (isSetColorMode) {
150361
- totalColorsLength += (((_b2 = (_a3 = setColorValues[channelIndex]) == null ? void 0 : _a3.setColors) == null ? void 0 : _b2.length) || 0) * 3;
150378
+ totalColorsLength += (((_b2 = (_a3 = setColorValues[channelIndex]) == null ? void 0 : _a3.setColors) == null ? void 0 : _b2.length) ?? 0) * 3;
150362
150379
  totalValuesLength += ((_c2 = setColorValues[channelIndex]) == null ? void 0 : _c2.obsIndex) ? max$1(setColorValues[channelIndex].obsIndex.map((d) => parseInt(d))) : 0;
150363
150380
  } else {
150364
- totalValuesLength += multiMatrixObsIndex[channelIndex] ? max$1(multiMatrixObsIndex[channelIndex].map((d) => parseInt(d))) : ((_d = multiFeatureValues[channelIndex]) == null ? void 0 : _d.length) || 0;
150381
+ totalValuesLength += multiMatrixObsIndex[channelIndex] ? max$1(multiMatrixObsIndex[channelIndex].map((d) => parseInt(d))) : ((_d = multiFeatureValues[channelIndex]) == null ? void 0 : _d.length) ?? 0;
150365
150382
  }
150366
150383
  });
150367
150384
  const valueTexHeight = Math.max(2, Math.ceil(totalValuesLength / texSize));
@@ -150382,7 +150399,7 @@ function multiSetsToTextureData(multiFeatureValues, multiMatrixObsIndex, setColo
150382
150399
  const matrixObsIndex = multiMatrixObsIndex[channelIndex];
150383
150400
  const bitmaskValueIsIndex = matrixObsIndex === null;
150384
150401
  if (isSetColorMode) {
150385
- const { setColorIndices, setColors, obsIndex } = setColorValues[channelIndex] || {};
150402
+ const { setColorIndices, setColors, obsIndex } = setColorValues[channelIndex] ?? {};
150386
150403
  if (setColorIndices && setColors && obsIndex) {
150387
150404
  for (let i2 = 0; i2 < obsIndex.length; i2++) {
150388
150405
  let obsId = String(i2 + 1);
@@ -150406,7 +150423,7 @@ function multiSetsToTextureData(multiFeatureValues, multiMatrixObsIndex, setColo
150406
150423
  indexOffset += (obsIndex == null ? void 0 : obsIndex.length) || 0;
150407
150424
  colorOffset += (setColors == null ? void 0 : setColors.length) || 0;
150408
150425
  } else {
150409
- const featureArr = multiFeatureValues[channelIndex];
150426
+ const featureArr = multiFeatureValues[channelIndex] ?? [];
150410
150427
  const normalizedFeatureArr = normalize(featureArr);
150411
150428
  if (!bitmaskValueIsIndex && matrixObsIndex) {
150412
150429
  for (let i2 = 0; i2 < matrixObsIndex.length; i2++) {
@@ -154184,18 +154201,93 @@ function coordinateTransformationsToMatrix(coordinateTransformations, axes) {
154184
154201
  }
154185
154202
  return mat;
154186
154203
  }
154187
- class NodeNotFoundError extends Error {
154188
- constructor(context, options = {}) {
154189
- super(`Node not found: ${context}`, options);
154190
- this.name = "NodeNotFoundError";
154204
+ function fetch_range(url, offset, length2, opts = {}) {
154205
+ if (offset !== void 0 && length2 !== void 0) {
154206
+ opts = {
154207
+ ...opts,
154208
+ headers: {
154209
+ ...opts.headers,
154210
+ Range: `bytes=${offset}-${offset + length2 - 1}`
154211
+ }
154212
+ };
154191
154213
  }
154214
+ return fetch(url, opts);
154192
154215
  }
154193
- class KeyError extends Error {
154194
- constructor(path) {
154195
- super(`Missing key: ${path}`);
154196
- this.name = "KeyError";
154216
+ function merge_init(storeOverrides, requestOverrides) {
154217
+ return {
154218
+ ...storeOverrides,
154219
+ ...requestOverrides,
154220
+ headers: {
154221
+ ...storeOverrides.headers,
154222
+ ...requestOverrides.headers
154223
+ }
154224
+ };
154225
+ }
154226
+ function resolve(root2, path) {
154227
+ const base = typeof root2 === "string" ? new URL(root2) : root2;
154228
+ if (!base.pathname.endsWith("/")) {
154229
+ base.pathname += "/";
154197
154230
  }
154231
+ const resolved = new URL(path.slice(1), base);
154232
+ resolved.search = base.search;
154233
+ return resolved;
154198
154234
  }
154235
+ async function handle_response(response) {
154236
+ if (response.status === 404) {
154237
+ return void 0;
154238
+ }
154239
+ if (response.status === 200 || response.status === 206) {
154240
+ return new Uint8Array(await response.arrayBuffer());
154241
+ }
154242
+ throw new Error(`Unexpected response status ${response.status} ${response.statusText}`);
154243
+ }
154244
+ async function fetch_suffix(url, suffix_length, init, use_suffix_request) {
154245
+ if (use_suffix_request) {
154246
+ return fetch(url, {
154247
+ ...init,
154248
+ headers: { ...init.headers, Range: `bytes=-${suffix_length}` }
154249
+ });
154250
+ }
154251
+ let response = await fetch(url, { ...init, method: "HEAD" });
154252
+ if (!response.ok) {
154253
+ return response;
154254
+ }
154255
+ let content_length = response.headers.get("Content-Length");
154256
+ let length2 = Number(content_length);
154257
+ return fetch_range(url, length2 - suffix_length, length2, init);
154258
+ }
154259
+ class FetchStore {
154260
+ constructor(url, options = {}) {
154261
+ __privateAdd(this, _FetchStore_instances);
154262
+ __privateAdd(this, _overrides);
154263
+ __privateAdd(this, _use_suffix_request);
154264
+ this.url = url;
154265
+ __privateSet(this, _overrides, options.overrides ?? {});
154266
+ __privateSet(this, _use_suffix_request, options.useSuffixRequest ?? false);
154267
+ }
154268
+ async get(key, options = {}) {
154269
+ let href = resolve(this.url, key).href;
154270
+ let response = await fetch(href, __privateMethod(this, _FetchStore_instances, merge_init_fn).call(this, options));
154271
+ return handle_response(response);
154272
+ }
154273
+ async getRange(key, range2, options = {}) {
154274
+ let url = resolve(this.url, key);
154275
+ let init = __privateMethod(this, _FetchStore_instances, merge_init_fn).call(this, options);
154276
+ let response;
154277
+ if ("suffixLength" in range2) {
154278
+ response = await fetch_suffix(url, range2.suffixLength, init, __privateGet(this, _use_suffix_request));
154279
+ } else {
154280
+ response = await fetch_range(url, range2.offset, range2.length, init);
154281
+ }
154282
+ return handle_response(response);
154283
+ }
154284
+ }
154285
+ _overrides = new WeakMap();
154286
+ _use_suffix_request = new WeakMap();
154287
+ _FetchStore_instances = new WeakSet();
154288
+ merge_init_fn = function(overrides) {
154289
+ return merge_init(__privateGet(this, _overrides), overrides);
154290
+ };
154199
154291
  class BoolArray {
154200
154292
  constructor(x, byteOffset, length2) {
154201
154293
  __privateAdd(this, _bytes);
@@ -154713,7 +154805,7 @@ const _JsonCodec = class _JsonCodec {
154713
154805
  const items = Array.from(buf.data);
154714
154806
  items.push("|O");
154715
154807
  items.push(buf.shape);
154716
- let replacer = void 0;
154808
+ let replacer;
154717
154809
  if (replacer_functions.length) {
154718
154810
  replacer = (key, value) => {
154719
154811
  let new_value = value;
@@ -154976,6 +155068,18 @@ async function load_codecs(chunk_meta) {
154976
155068
  function is_typed_array_like_meta(meta) {
154977
155069
  return meta.data_type !== "v2:object";
154978
155070
  }
155071
+ class NodeNotFoundError extends Error {
155072
+ constructor(context, options = {}) {
155073
+ super(`Node not found: ${context}`, options);
155074
+ this.name = "NodeNotFoundError";
155075
+ }
155076
+ }
155077
+ class KeyError extends Error {
155078
+ constructor(path) {
155079
+ super(`Missing key: ${path}`);
155080
+ this.name = "KeyError";
155081
+ }
155082
+ }
154979
155083
  const MAX_BIG_UINT = 18446744073709551615n;
154980
155084
  function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sharding_config) {
154981
155085
  assert$1(location.store.getRange, "Store does not support range requests");
@@ -155155,105 +155259,6 @@ let Array$1 = (_c = class extends (_a = Location, _a) {
155155
155259
  return is_dtype(this.dtype, query);
155156
155260
  }
155157
155261
  }, _metadata2 = new WeakMap(), _c);
155158
- let VERSION_COUNTER = create_version_counter();
155159
- function create_version_counter() {
155160
- let version_counts = /* @__PURE__ */ new WeakMap();
155161
- function get_counts(store) {
155162
- let counts = version_counts.get(store) ?? { v2: 0, v3: 0 };
155163
- version_counts.set(store, counts);
155164
- return counts;
155165
- }
155166
- return {
155167
- increment(store, version2) {
155168
- get_counts(store)[version2] += 1;
155169
- },
155170
- version_max(store) {
155171
- let counts = get_counts(store);
155172
- return counts.v3 > counts.v2 ? "v3" : "v2";
155173
- }
155174
- };
155175
- }
155176
- async function load_attrs(location) {
155177
- let meta_bytes = await location.store.get(location.resolve(".zattrs").path);
155178
- if (!meta_bytes)
155179
- return {};
155180
- return json_decode_object(meta_bytes);
155181
- }
155182
- async function open_v2(location, options = {}) {
155183
- let loc = "store" in location ? location : new Location(location);
155184
- let attrs = {};
155185
- if (options.attrs ?? true)
155186
- attrs = await load_attrs(loc);
155187
- if (options.kind === "array")
155188
- return open_array_v2(loc, attrs);
155189
- if (options.kind === "group")
155190
- return open_group_v2(loc, attrs);
155191
- return open_array_v2(loc, attrs).catch((err2) => {
155192
- rethrow_unless(err2, NodeNotFoundError);
155193
- return open_group_v2(loc, attrs);
155194
- });
155195
- }
155196
- async function open_array_v2(location, attrs) {
155197
- let { path } = location.resolve(".zarray");
155198
- let meta = await location.store.get(path);
155199
- if (!meta) {
155200
- throw new NodeNotFoundError("v2 array", {
155201
- cause: new KeyError(path)
155202
- });
155203
- }
155204
- VERSION_COUNTER.increment(location.store, "v2");
155205
- return new Array$1(location.store, location.path, v2_to_v3_array_metadata(json_decode_object(meta), attrs));
155206
- }
155207
- async function open_group_v2(location, attrs) {
155208
- let { path } = location.resolve(".zgroup");
155209
- let meta = await location.store.get(path);
155210
- if (!meta) {
155211
- throw new NodeNotFoundError("v2 group", {
155212
- cause: new KeyError(path)
155213
- });
155214
- }
155215
- VERSION_COUNTER.increment(location.store, "v2");
155216
- return new Group(location.store, location.path, v2_to_v3_group_metadata(json_decode_object(meta), attrs));
155217
- }
155218
- async function _open_v3(location) {
155219
- let { store, path } = location.resolve("zarr.json");
155220
- let meta = await location.store.get(path);
155221
- if (!meta) {
155222
- throw new NodeNotFoundError("v3 array or group", {
155223
- cause: new KeyError(path)
155224
- });
155225
- }
155226
- let meta_doc = json_decode_object(meta);
155227
- if (meta_doc.node_type === "array") {
155228
- meta_doc.fill_value = ensure_correct_scalar(meta_doc);
155229
- }
155230
- return meta_doc.node_type === "array" ? new Array$1(store, location.path, meta_doc) : new Group(store, location.path, meta_doc);
155231
- }
155232
- async function open_v3(location, options = {}) {
155233
- let loc = "store" in location ? location : new Location(location);
155234
- let node2 = await _open_v3(loc);
155235
- VERSION_COUNTER.increment(loc.store, "v3");
155236
- if (options.kind === void 0)
155237
- return node2;
155238
- if (options.kind === "array" && node2 instanceof Array$1)
155239
- return node2;
155240
- if (options.kind === "group" && node2 instanceof Group)
155241
- return node2;
155242
- let kind = node2 instanceof Array$1 ? "array" : "group";
155243
- throw new Error(`Expected node of kind ${options.kind}, found ${kind}.`);
155244
- }
155245
- async function open(location, options = {}) {
155246
- let store = "store" in location ? location.store : location;
155247
- let version_max = VERSION_COUNTER.version_max(store);
155248
- let open_primary = version_max === "v2" ? open.v2 : open.v3;
155249
- let open_secondary = version_max === "v2" ? open.v3 : open.v2;
155250
- return open_primary(location, options).catch((err2) => {
155251
- rethrow_unless(err2, NodeNotFoundError);
155252
- return open_secondary(location, options);
155253
- });
155254
- }
155255
- open.v2 = open_v2;
155256
- open.v3 = open_v3;
155257
155262
  function* range(start, stop, step = 1) {
155258
155263
  if (stop === void 0) {
155259
155264
  stop = start;
@@ -155634,93 +155639,105 @@ function set_from_chunk_binary(dest, src, bytes_per_element2, projections) {
155634
155639
  }, bytes_per_element2, projs);
155635
155640
  }
155636
155641
  }
155637
- function fetch_range(url, offset, length2, opts = {}) {
155638
- if (offset !== void 0 && length2 !== void 0) {
155639
- opts = {
155640
- ...opts,
155641
- headers: {
155642
- ...opts.headers,
155643
- Range: `bytes=${offset}-${offset + length2 - 1}`
155644
- }
155645
- };
155642
+ let VERSION_COUNTER = create_version_counter();
155643
+ function create_version_counter() {
155644
+ let version_counts = /* @__PURE__ */ new WeakMap();
155645
+ function get_counts(store) {
155646
+ let counts = version_counts.get(store) ?? { v2: 0, v3: 0 };
155647
+ version_counts.set(store, counts);
155648
+ return counts;
155646
155649
  }
155647
- return fetch(url, opts);
155648
- }
155649
- function merge_init(storeOverrides, requestOverrides) {
155650
155650
  return {
155651
- ...storeOverrides,
155652
- ...requestOverrides,
155653
- headers: {
155654
- ...storeOverrides.headers,
155655
- ...requestOverrides.headers
155651
+ increment(store, version2) {
155652
+ get_counts(store)[version2] += 1;
155653
+ },
155654
+ version_max(store) {
155655
+ let counts = get_counts(store);
155656
+ return counts.v3 > counts.v2 ? "v3" : "v2";
155656
155657
  }
155657
155658
  };
155658
155659
  }
155659
- function resolve(root2, path) {
155660
- const base = typeof root2 === "string" ? new URL(root2) : root2;
155661
- if (!base.pathname.endsWith("/")) {
155662
- base.pathname += "/";
155663
- }
155664
- const resolved = new URL(path.slice(1), base);
155665
- resolved.search = base.search;
155666
- return resolved;
155660
+ async function load_attrs(location) {
155661
+ let meta_bytes = await location.store.get(location.resolve(".zattrs").path);
155662
+ if (!meta_bytes)
155663
+ return {};
155664
+ return json_decode_object(meta_bytes);
155667
155665
  }
155668
- async function handle_response(response) {
155669
- if (response.status === 404) {
155670
- return void 0;
155671
- }
155672
- if (response.status === 200 || response.status === 206) {
155673
- return new Uint8Array(await response.arrayBuffer());
155674
- }
155675
- throw new Error(`Unexpected response status ${response.status} ${response.statusText}`);
155666
+ async function open_v2(location, options = {}) {
155667
+ let loc = "store" in location ? location : new Location(location);
155668
+ let attrs = {};
155669
+ if (options.attrs ?? true)
155670
+ attrs = await load_attrs(loc);
155671
+ if (options.kind === "array")
155672
+ return open_array_v2(loc, attrs);
155673
+ if (options.kind === "group")
155674
+ return open_group_v2(loc, attrs);
155675
+ return open_array_v2(loc, attrs).catch((err2) => {
155676
+ rethrow_unless(err2, NodeNotFoundError);
155677
+ return open_group_v2(loc, attrs);
155678
+ });
155676
155679
  }
155677
- async function fetch_suffix(url, suffix_length, init, use_suffix_request) {
155678
- if (use_suffix_request) {
155679
- return fetch(url, {
155680
- ...init,
155681
- headers: { ...init.headers, Range: `bytes=-${suffix_length}` }
155680
+ async function open_array_v2(location, attrs) {
155681
+ let { path } = location.resolve(".zarray");
155682
+ let meta = await location.store.get(path);
155683
+ if (!meta) {
155684
+ throw new NodeNotFoundError("v2 array", {
155685
+ cause: new KeyError(path)
155682
155686
  });
155683
155687
  }
155684
- let response = await fetch(url, { ...init, method: "HEAD" });
155685
- if (!response.ok) {
155686
- return response;
155687
- }
155688
- let content_length = response.headers.get("Content-Length");
155689
- let length2 = Number(content_length);
155690
- return fetch_range(url, length2 - suffix_length, length2, init);
155688
+ VERSION_COUNTER.increment(location.store, "v2");
155689
+ return new Array$1(location.store, location.path, v2_to_v3_array_metadata(json_decode_object(meta), attrs));
155691
155690
  }
155692
- class FetchStore {
155693
- constructor(url, options = {}) {
155694
- __privateAdd(this, _FetchStore_instances);
155695
- __privateAdd(this, _overrides);
155696
- __privateAdd(this, _use_suffix_request);
155697
- this.url = url;
155698
- __privateSet(this, _overrides, options.overrides ?? {});
155699
- __privateSet(this, _use_suffix_request, options.useSuffixRequest ?? false);
155691
+ async function open_group_v2(location, attrs) {
155692
+ let { path } = location.resolve(".zgroup");
155693
+ let meta = await location.store.get(path);
155694
+ if (!meta) {
155695
+ throw new NodeNotFoundError("v2 group", {
155696
+ cause: new KeyError(path)
155697
+ });
155700
155698
  }
155701
- async get(key, options = {}) {
155702
- let href = resolve(this.url, key).href;
155703
- let response = await fetch(href, __privateMethod(this, _FetchStore_instances, merge_init_fn).call(this, options));
155704
- return handle_response(response);
155699
+ VERSION_COUNTER.increment(location.store, "v2");
155700
+ return new Group(location.store, location.path, v2_to_v3_group_metadata(json_decode_object(meta), attrs));
155701
+ }
155702
+ async function _open_v3(location) {
155703
+ let { store, path } = location.resolve("zarr.json");
155704
+ let meta = await location.store.get(path);
155705
+ if (!meta) {
155706
+ throw new NodeNotFoundError("v3 array or group", {
155707
+ cause: new KeyError(path)
155708
+ });
155705
155709
  }
155706
- async getRange(key, range2, options = {}) {
155707
- let url = resolve(this.url, key);
155708
- let init = __privateMethod(this, _FetchStore_instances, merge_init_fn).call(this, options);
155709
- let response;
155710
- if ("suffixLength" in range2) {
155711
- response = await fetch_suffix(url, range2.suffixLength, init, __privateGet(this, _use_suffix_request));
155712
- } else {
155713
- response = await fetch_range(url, range2.offset, range2.length, init);
155714
- }
155715
- return handle_response(response);
155710
+ let meta_doc = json_decode_object(meta);
155711
+ if (meta_doc.node_type === "array") {
155712
+ meta_doc.fill_value = ensure_correct_scalar(meta_doc);
155716
155713
  }
155714
+ return meta_doc.node_type === "array" ? new Array$1(store, location.path, meta_doc) : new Group(store, location.path, meta_doc);
155717
155715
  }
155718
- _overrides = new WeakMap();
155719
- _use_suffix_request = new WeakMap();
155720
- _FetchStore_instances = new WeakSet();
155721
- merge_init_fn = function(overrides) {
155722
- return merge_init(__privateGet(this, _overrides), overrides);
155723
- };
155716
+ async function open_v3(location, options = {}) {
155717
+ let loc = "store" in location ? location : new Location(location);
155718
+ let node2 = await _open_v3(loc);
155719
+ VERSION_COUNTER.increment(loc.store, "v3");
155720
+ if (options.kind === void 0)
155721
+ return node2;
155722
+ if (options.kind === "array" && node2 instanceof Array$1)
155723
+ return node2;
155724
+ if (options.kind === "group" && node2 instanceof Group)
155725
+ return node2;
155726
+ let kind = node2 instanceof Array$1 ? "array" : "group";
155727
+ throw new Error(`Expected node of kind ${options.kind}, found ${kind}.`);
155728
+ }
155729
+ async function open(location, options = {}) {
155730
+ let store = "store" in location ? location.store : location;
155731
+ let version_max = VERSION_COUNTER.version_max(store);
155732
+ let open_primary = version_max === "v2" ? open.v2 : open.v3;
155733
+ let open_secondary = version_max === "v2" ? open.v3 : open.v2;
155734
+ return open_primary(location, options).catch((err2) => {
155735
+ rethrow_unless(err2, NodeNotFoundError);
155736
+ return open_secondary(location, options);
155737
+ });
155738
+ }
155739
+ open.v2 = open_v2;
155740
+ open.v3 = open_v3;
155724
155741
  function getV2DataType(dtype) {
155725
155742
  const mapping = {
155726
155743
  int8: "|i1",
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-Dk8azeqY.js";
1
+ import { C, d, e, f, h, G, b, J, M, i, O, c, R, j } from "./index-ClFtTupj.js";
2
2
  export {
3
3
  C as CellsJsonAsObsEmbeddingLoader,
4
4
  d as CellsJsonAsObsLabelsLoader,
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
1
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
2
2
  const dctZigZag = new Int32Array([
3
3
  0,
4
4
  1,
@@ -1,5 +1,5 @@
1
1
  import { i as inflate_1 } from "./pako.esm-SxljTded.js";
2
- import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-Dk8azeqY.js";
2
+ import { g as getDefaultExportFromCjs, B as BaseDecoder, L as LercParameters, a as LercAddCompression } from "./index-ClFtTupj.js";
3
3
  var LercDecode = { exports: {} };
4
4
  var hasRequiredLercDecode;
5
5
  function requireLercDecode() {
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
1
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
2
2
  const MIN_BITS = 9;
3
3
  const CLEAR_CODE = 256;
4
4
  const EOI_CODE = 257;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
1
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
2
2
  class PackbitsDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  const dataView = new DataView(buffer);
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
1
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
2
2
  class RawDecoder extends BaseDecoder {
3
3
  decodeBlock(buffer) {
4
4
  return buffer;
@@ -1,4 +1,4 @@
1
- import { B as BaseDecoder } from "./index-Dk8azeqY.js";
1
+ import { B as BaseDecoder } from "./index-ClFtTupj.js";
2
2
  class WebImageDecoder extends BaseDecoder {
3
3
  constructor() {
4
4
  super();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/json",
3
- "version": "3.6.13",
3
+ "version": "3.6.15",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -18,19 +18,19 @@
18
18
  "dependencies": {
19
19
  "d3-array": "^2.4.0",
20
20
  "lodash-es": "^4.17.21",
21
- "zarrita": "0.5.2",
21
+ "zarrita": "0.5.3",
22
22
  "zod": "^3.21.4",
23
- "@vitessce/constants-internal": "3.6.13",
24
- "@vitessce/gl": "3.6.13",
25
- "@vitessce/globals": "3.6.13",
26
- "@vitessce/schemas": "3.6.13",
27
- "@vitessce/sets-utils": "3.6.13",
28
- "@vitessce/spatial-utils": "3.6.13",
29
- "@vitessce/utils": "3.6.13",
30
- "@vitessce/abstract": "3.6.13",
31
- "@vitessce/error": "3.6.13",
32
- "@vitessce/zarr-utils": "3.6.13",
33
- "@vitessce/config": "3.6.13"
23
+ "@vitessce/constants-internal": "3.6.15",
24
+ "@vitessce/gl": "3.6.15",
25
+ "@vitessce/globals": "3.6.15",
26
+ "@vitessce/schemas": "3.6.15",
27
+ "@vitessce/sets-utils": "3.6.15",
28
+ "@vitessce/spatial-utils": "3.6.15",
29
+ "@vitessce/utils": "3.6.15",
30
+ "@vitessce/abstract": "3.6.15",
31
+ "@vitessce/error": "3.6.15",
32
+ "@vitessce/zarr-utils": "3.6.15",
33
+ "@vitessce/config": "3.6.15"
34
34
  },
35
35
  "scripts": {
36
36
  "bundle": "pnpm exec vite build -c ../../../scripts/vite.config.js",