@vitessce/config 3.9.2 → 3.9.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/dist/index.js +50 -5
  2. package/package.json +7 -7
package/dist/index.js CHANGED
@@ -2374,6 +2374,9 @@ function get_ctr(data_type) {
2374
2374
  let [, kind, chars] = match;
2375
2375
  return (kind === "U" ? UnicodeStringArray : ByteStringArray).bind(null, Number(chars));
2376
2376
  }
2377
+ if (data_type === "string") {
2378
+ return globalThis.Array;
2379
+ }
2377
2380
  let ctr = {
2378
2381
  int8: Int8Array,
2379
2382
  int16: Int16Array,
@@ -2495,7 +2498,7 @@ function is_dtype(dtype, query) {
2495
2498
  let is_boolean = dtype === "bool";
2496
2499
  if (query === "boolean")
2497
2500
  return is_boolean;
2498
- let is_string = dtype.startsWith("v2:U") || dtype.startsWith("v2:S");
2501
+ let is_string = dtype.startsWith("v2:U") || dtype.startsWith("v2:S") || dtype === "string";
2499
2502
  if (query === "string")
2500
2503
  return is_string;
2501
2504
  let is_bigint = dtype === "int64" || dtype === "uint64";
@@ -2945,7 +2948,7 @@ async function load_codecs(chunk_meta) {
2945
2948
  return { array_to_array, array_to_bytes, bytes_to_bytes };
2946
2949
  }
2947
2950
  function is_typed_array_like_meta(meta) {
2948
- return meta.data_type !== "v2:object";
2951
+ return meta.data_type !== "v2:object" && meta.data_type !== "string";
2949
2952
  }
2950
2953
  class NodeNotFoundError extends Error {
2951
2954
  constructor(context, options = {}) {
@@ -3029,7 +3032,7 @@ function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sh
3029
3032
  codecs: sharding_config.index_codecs
3030
3033
  });
3031
3034
  let cache = {};
3032
- return async (chunk_coord) => {
3035
+ return async (chunk_coord, options) => {
3033
3036
  let shard_coord = chunk_coord.map((d, i) => Math.floor(d / index_shape[i]));
3034
3037
  let shard_path = location.resolve(encode_shard_key(shard_coord)).path;
3035
3038
  let index;
@@ -3040,7 +3043,7 @@ function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sh
3040
3043
  let index_size = 16 * index_shape.reduce((a, b) => a * b, 1);
3041
3044
  let bytes = await get_range(shard_path, {
3042
3045
  suffixLength: index_size + checksum_size
3043
- });
3046
+ }, options);
3044
3047
  index = cache[shard_path] = bytes ? await index_codec.decode(bytes) : null;
3045
3048
  }
3046
3049
  if (index === null) {
@@ -3056,7 +3059,7 @@ function create_sharded_chunk_getter(location, shard_shape, encode_shard_key, sh
3056
3059
  return get_range(shard_path, {
3057
3060
  offset: Number(offset),
3058
3061
  length: Number(length)
3059
- });
3062
+ }, options);
3060
3063
  };
3061
3064
  }
3062
3065
  var _a;
@@ -4077,6 +4080,13 @@ async function unzip(source) {
4077
4080
  entries: Object.fromEntries(entries.map((v) => [v.name, v]))
4078
4081
  };
4079
4082
  }
4083
+ function isZipEntryInternal(entry) {
4084
+ if (!("compressionMethod" in entry) || !("_rawEntry" in entry)) {
4085
+ return false;
4086
+ }
4087
+ const rawEntry = entry._rawEntry;
4088
+ return typeof entry.compressionMethod === "number" && typeof rawEntry === "object" && rawEntry !== null && "relativeOffsetOfLocalHeader" in rawEntry && typeof rawEntry.relativeOffsetOfLocalHeader === "number";
4089
+ }
4080
4090
  class BlobReader2 {
4081
4091
  constructor(blob) {
4082
4092
  this.blob = blob;
@@ -4120,6 +4130,7 @@ class HTTPRangeReader {
4120
4130
  }
4121
4131
  class ZipFileStore {
4122
4132
  constructor(reader, opts = {}) {
4133
+ this.reader = reader;
4123
4134
  this.info = unzip(reader).then((info) => {
4124
4135
  if (opts.transformEntries) {
4125
4136
  info.entries = opts.transformEntries(info.entries);
@@ -4127,12 +4138,46 @@ class ZipFileStore {
4127
4138
  return info;
4128
4139
  });
4129
4140
  }
4141
+ /**
4142
+ * Compute the byte offset where entry data begins in the zip file.
4143
+ * This requires reading the local file header to get filename and extra field lengths.
4144
+ */
4145
+ async getEntryDataOffset(entry) {
4146
+ const localHeaderOffset = entry._rawEntry.relativeOffsetOfLocalHeader;
4147
+ const header = await this.reader.read(localHeaderOffset, 30);
4148
+ const fileNameLength = header[26] + header[27] * 256;
4149
+ const extraFieldLength = header[28] + header[29] * 256;
4150
+ return localHeaderOffset + 30 + fileNameLength + extraFieldLength;
4151
+ }
4130
4152
  async get(key) {
4131
4153
  let entry = (await this.info).entries[strip_prefix(key)];
4132
4154
  if (!entry)
4133
4155
  return;
4134
4156
  return new Uint8Array(await entry.arrayBuffer());
4135
4157
  }
4158
+ async getRange(key, range) {
4159
+ const entry = (await this.info).entries[strip_prefix(key)];
4160
+ if (!entry)
4161
+ return void 0;
4162
+ if (!isZipEntryInternal(entry)) {
4163
+ throw new Error("ZipFileStore.getRange requires internal unzipit properties that are not available. This may indicate an incompatible version of unzipit.");
4164
+ }
4165
+ if (entry.compressionMethod !== 0) {
4166
+ const bytes = await this.get(key);
4167
+ if (!bytes)
4168
+ return void 0;
4169
+ if ("suffixLength" in range) {
4170
+ return bytes.slice(-range.suffixLength);
4171
+ }
4172
+ return bytes.slice(range.offset, range.offset + range.length);
4173
+ }
4174
+ const dataOffset = await this.getEntryDataOffset(entry);
4175
+ if ("suffixLength" in range) {
4176
+ const start = dataOffset + entry.size - range.suffixLength;
4177
+ return this.reader.read(start, range.suffixLength);
4178
+ }
4179
+ return this.reader.read(dataOffset + range.offset, range.length);
4180
+ }
4136
4181
  async has(key) {
4137
4182
  return strip_prefix(key) in (await this.info).entries;
4138
4183
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vitessce/config",
3
- "version": "3.9.2",
3
+ "version": "3.9.3",
4
4
  "author": "HIDIVE Lab at HMS",
5
5
  "homepage": "http://vitessce.io",
6
6
  "repository": {
@@ -16,12 +16,12 @@
16
16
  "dist-tsc"
17
17
  ],
18
18
  "dependencies": {
19
- "zarrita": "0.5.4",
20
- "@zarrita/storage": "0.1.3",
21
- "@vitessce/constants-internal": "3.9.2",
22
- "@vitessce/utils": "3.9.2",
23
- "@vitessce/globals": "3.9.2",
24
- "@vitessce/zarr-utils": "3.9.2"
19
+ "zarrita": "0.6.1",
20
+ "@zarrita/storage": "0.1.4",
21
+ "@vitessce/constants-internal": "3.9.3",
22
+ "@vitessce/globals": "3.9.3",
23
+ "@vitessce/zarr-utils": "3.9.3",
24
+ "@vitessce/utils": "3.9.3"
25
25
  },
26
26
  "scripts": {
27
27
  "bundle": "pnpm exec vite build -c ../../scripts/vite.config.mjs",