omezarr-tilesource 0.7.1 → 0.8.0

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/README.md CHANGED
@@ -207,7 +207,20 @@ const tileSource2 = new OMEZarrTileSource(
207
207
 
208
208
  `loadOMEZarr(url, zip?, { signal })` loads the metadata with ome-zarr.js and
209
209
  opens the arrays of all resolution levels; `url` may also be a `Blob` holding a
210
- zipped OME-Zarr file. An `OMEZarr` can also be assembled
210
+ zipped OME-Zarr file, or a zarrita store (`Readable`, e.g. a custom
211
+ `AsyncReadable`; `zip: true` is rejected, wrap zipped files in a `ZipFileStore`
212
+ instead). Images loaded from a store can only be rendered by
213
+ passing the `OMEZarr` to a tile source, with a `url` that identifies the store:
214
+
215
+ ```javascript
216
+ const loaded = await OMEZarrTileSource.loadOMEZarr(myStore);
217
+ const tileSource = await OMEZarrTileSource.open(
218
+ { url: "custom://my-image" },
219
+ loaded,
220
+ );
221
+ ```
222
+
223
+ An `OMEZarr` can also be assembled
211
224
  from an `NgffImage` loaded by the app, as long as `arrays` lists the
212
225
  opened arrays of `image.paths` in order. It is not checked against the URL of
213
226
  the tile source it is passed to.
@@ -30,7 +30,7 @@ export declare function getDataTypeRange(chunk: zarr.Chunk<zarr.NumberDataType |
30
30
  * @param url - URL to check, as a string or a `URL`
31
31
  * @returns Whether the URL path ends in `.ozx`
32
32
  */
33
- export declare function isOZX(url: string | URL): boolean;
33
+ export declare function isOZXUrl(url: string | URL): boolean;
34
34
 
35
35
  /**
36
36
  * A color LUT (a color per scaled value, e.g. 256 entries) or a color map (a
@@ -149,19 +149,25 @@ export declare class OMEZarrTileSource extends default_2.TileSource {
149
149
  * Loads the OME-Zarr metadata and opens the arrays of all resolution levels.
150
150
  *
151
151
  * The result can be passed to the constructor or to {@link open} to share one
152
- * metadata load across several tile sources for the same URL.
153
- *
154
- * @param url - URL of the OME-Zarr image or zipped OME-Zarr file, as a string
155
- * or a `URL` (relative URLs are resolved against the document base URL),
156
- * or a `Blob` (e.g. a `File`) holding a zipped OME-Zarr file
152
+ * metadata load across several tile sources for the same URL. Images loaded
153
+ * from a zarrita store can only be rendered this way, with a `url` that
154
+ * identifies the store (e.g. `custom://my-image`).
155
+ *
156
+ * @param store - URL of the OME-Zarr image or zipped OME-Zarr file, as a
157
+ * string or a `URL` (relative URLs are resolved against the document base
158
+ * URL), a `Blob` (e.g. a `File`) holding a zipped OME-Zarr file, or a
159
+ * zarrita store (`Readable`, e.g. a custom `AsyncReadable`) holding the
160
+ * OME-Zarr image
157
161
  * @param zip - Whether the URL points to a zipped OME-Zarr file; defaults to
158
- * `true` for URLs whose path ends in `.ozx` and for `Blob`s
162
+ * `true` for URLs whose path ends in `.ozx` and for `Blob`s. Must not be
163
+ * `false` for a `Blob`, and must not be `true` for a zarrita store (wrap
164
+ * zipped files in a `ZipFileStore` instead)
159
165
  * @param options - `signal` aborts the load
160
166
  * @returns The loaded image and its arrays, highest resolution first
161
- * @throws If the URL is relative and there is no document base URL, or if
162
- * `zip` is `false` for a `Blob`
167
+ * @throws If the URL is relative and there is no document base URL, if `zip`
168
+ * is `false` for a `Blob`, or if `zip` is `true` for a zarrita store
163
169
  */
164
- static loadOMEZarr(url: string | URL | Blob, zip?: boolean, options?: {
170
+ static loadOMEZarr(store: string | URL | Blob | zarr.Readable, zip?: boolean, options?: {
165
171
  signal?: AbortSignal;
166
172
  }): Promise<OMEZarr>;
167
173
  /**
@@ -51,19 +51,17 @@ var d = class o extends i.TileSource {
51
51
  }
52
52
  static async loadOMEZarr(n, r, i) {
53
53
  let { signal: a } = i ?? {};
54
- a?.throwIfAborted();
55
- let o;
56
- if (n instanceof Blob) {
57
- if (r === !1) throw Error("only zipped OME-Zarr files can be loaded from a Blob");
58
- o = e.fromBlob(n);
59
- } else {
54
+ if (a?.throwIfAborted(), typeof n == "string" || n instanceof URL) {
60
55
  let t = s(n);
61
- o = r ?? c(t) ? e.fromUrl(t) : n.toString();
62
- }
63
- let l = await t.load(o, { signal: a });
56
+ n = r ?? c(t) ? e.fromUrl(t) : n.toString();
57
+ } else if (n instanceof Blob) {
58
+ if (r === !1) throw Error("only zipped OME-Zarr files can be loaded from a Blob");
59
+ n = e.fromBlob(n);
60
+ } else if (r === !0) throw Error("zip must not be true for a zarrita store (wrap zipped OME-Zarr files in a ZipFileStore instead)");
61
+ let o = await t.load(n, { signal: a });
64
62
  return {
65
- image: l,
66
- arrays: await Promise.all(l.paths.map((e) => l.openArray(e, { signal: a })))
63
+ image: o,
64
+ arrays: await Promise.all(o.paths.map((e) => o.openArray(e, { signal: a })))
67
65
  };
68
66
  }
69
67
  static async open(e, t, n) {
@@ -311,4 +309,4 @@ var d = class o extends i.TileSource {
311
309
  //#region src/main.ts
312
310
  globalThis.OpenSeadragon && d.enable(globalThis.OpenSeadragon);
313
311
  //#endregion
314
- export { d as OMEZarrTileSource, u as fnv1a, l as getDataTypeRange, c as isOZX, s as resolveUrl };
312
+ export { d as OMEZarrTileSource, u as fnv1a, l as getDataTypeRange, c as isOZXUrl, s as resolveUrl };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "omezarr-tilesource",
3
- "version": "0.7.1",
3
+ "version": "0.8.0",
4
4
  "description": "An OpenSeadragon tile source for the OME-Zarr bioimage file format",
5
5
  "homepage": "https://github.com/TissUUmaps/OMEZarrTileSource#readme",
6
6
  "bugs": "https://github.com/TissUUmaps/OMEZarrTileSource/issues",