omezarr-tilesource 0.7.1 → 0.8.1
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 +15 -3
- package/dist/omezarr-tilesource.d.ts +16 -10
- package/dist/omezarr-tilesource.js +10 -12
- package/package.json +7 -6
package/README.md
CHANGED
|
@@ -23,8 +23,7 @@ pnpm add omezarr-tilesource
|
|
|
23
23
|
```
|
|
24
24
|
|
|
25
25
|
The package is distributed as an ES module for use with a bundler (e.g. Vite).
|
|
26
|
-
[zarrita](https://github.com/manzt/zarrita.js)
|
|
27
|
-
[@zarrita/storage](https://github.com/manzt/zarrita.js) and
|
|
26
|
+
[zarrita](https://github.com/manzt/zarrita.js) and
|
|
28
27
|
[ome-zarr.js](https://github.com/BioNGFF/ome-zarr.js) are peer dependencies
|
|
29
28
|
(installed automatically by pnpm and npm 7 or newer) and are not bundled, so
|
|
30
29
|
the app and the tile source share a single copy, e.g. for passing `NgffImage`
|
|
@@ -207,7 +206,20 @@ const tileSource2 = new OMEZarrTileSource(
|
|
|
207
206
|
|
|
208
207
|
`loadOMEZarr(url, zip?, { signal })` loads the metadata with ome-zarr.js and
|
|
209
208
|
opens the arrays of all resolution levels; `url` may also be a `Blob` holding a
|
|
210
|
-
zipped OME-Zarr file
|
|
209
|
+
zipped OME-Zarr file, or a zarrita store (`Readable`, e.g. a custom
|
|
210
|
+
`AsyncReadable`; `zip: true` is rejected, wrap zipped files in a `ZipFileStore`
|
|
211
|
+
instead). Images loaded from a store can only be rendered by
|
|
212
|
+
passing the `OMEZarr` to a tile source, with a `url` that identifies the store:
|
|
213
|
+
|
|
214
|
+
```javascript
|
|
215
|
+
const loaded = await OMEZarrTileSource.loadOMEZarr(myStore);
|
|
216
|
+
const tileSource = await OMEZarrTileSource.open(
|
|
217
|
+
{ url: "custom://my-image" },
|
|
218
|
+
loaded,
|
|
219
|
+
);
|
|
220
|
+
```
|
|
221
|
+
|
|
222
|
+
An `OMEZarr` can also be assembled
|
|
211
223
|
from an `NgffImage` loaded by the app, as long as `arrays` lists the
|
|
212
224
|
opened arrays of `image.paths` in order. It is not checked against the URL of
|
|
213
225
|
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
|
|
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
|
-
*
|
|
155
|
-
*
|
|
156
|
-
*
|
|
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,
|
|
162
|
-
* `zip` is `
|
|
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(
|
|
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
|
-
|
|
62
|
-
}
|
|
63
|
-
|
|
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:
|
|
66
|
-
arrays: await Promise.all(
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.8.1",
|
|
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",
|
|
@@ -22,10 +22,12 @@
|
|
|
22
22
|
"import": "./dist/omezarr-tilesource.js"
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"@zarrita/storage": "^0.2.0"
|
|
27
|
+
},
|
|
25
28
|
"peerDependencies": {
|
|
26
|
-
"
|
|
27
|
-
"
|
|
28
|
-
"openseadragon": ">=6.0.0 <7.0.0",
|
|
29
|
+
"ome-zarr.js": "^0.0.20",
|
|
30
|
+
"openseadragon": "^6.0.0",
|
|
29
31
|
"zarrita": "^0.7.5"
|
|
30
32
|
},
|
|
31
33
|
"devDependencies": {
|
|
@@ -33,13 +35,12 @@
|
|
|
33
35
|
"@microsoft/api-extractor": "^7.58.7",
|
|
34
36
|
"@trivago/prettier-plugin-sort-imports": "^6.0.2",
|
|
35
37
|
"@vitest/coverage-v8": "^4.1.7",
|
|
36
|
-
"@zarrita/storage": "0.2.0",
|
|
37
38
|
"eslint": "^10.4.0",
|
|
38
39
|
"eslint-config-prettier": "^10.1.8",
|
|
39
40
|
"husky": "^9.1.7",
|
|
40
41
|
"lint-staged": "^17.0.5",
|
|
41
42
|
"ome-zarr.js": "0.0.20",
|
|
42
|
-
"openseadragon": "^6.
|
|
43
|
+
"openseadragon": "^6.0.0",
|
|
43
44
|
"prettier": "^3.8.3",
|
|
44
45
|
"typescript": "^6.0.3",
|
|
45
46
|
"typescript-eslint": "^8.59.4",
|