@aics/vole-core 4.4.1 → 4.5.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.
@@ -3,6 +3,7 @@ import { ThreadableVolumeLoader } from "./IVolumeLoader.js";
3
3
  import { computeAtlasSize } from "../ImageInfo.js";
4
4
  import { isChunk } from "../VolumeCache.js";
5
5
  import { getDataRange } from "../utils/num_utils.js";
6
+ import { remapUri } from "../utils/url_utils.js";
6
7
 
7
8
  /* eslint-disable @typescript-eslint/naming-convention */
8
9
 
@@ -70,7 +71,7 @@ class JsonImageInfoLoader extends ThreadableVolumeLoader {
70
71
  if (cachedInfo) {
71
72
  return cachedInfo;
72
73
  }
73
- const response = await fetch(this.urls[time]);
74
+ const response = await fetch(remapUri(this.urls[time]));
74
75
  const imageInfo = await response.json();
75
76
  imageInfo.pixel_size_unit = imageInfo.pixel_size_unit || "μm";
76
77
  imageInfo.times = imageInfo.times || this.urls.length;
@@ -194,7 +195,7 @@ class JsonImageInfoLoader extends ThreadableVolumeLoader {
194
195
  if (cacheHit) {
195
196
  return;
196
197
  }
197
- const response = await fetch(image.name, {
198
+ const response = await fetch(remapUri(image.name), {
198
199
  mode: "cors"
199
200
  });
200
201
  const blob = await response.blob();
@@ -12,6 +12,7 @@ import { getScale, getSourceChannelMeta, matchSourceScaleLevels, orderByDimensio
12
12
  import { VolumeLoadError, VolumeLoadErrorType, wrapVolumeLoadError } from "./VolumeLoadError.js";
13
13
  import wrapArray, { RelaxedFetchStore } from "./zarr_utils/wrappers.js";
14
14
  import { assertMetadataHasMultiscales, toOMEZarrMetaV4, validateOMEZarrMetadata } from "./zarr_utils/validation.js";
15
+ import { remapUri } from "../utils/url_utils.js";
15
16
  const CHUNK_REQUEST_CANCEL_REASON = "chunk request cancelled";
16
17
 
17
18
  // returns the converted data and the original min and max values
@@ -81,7 +82,7 @@ class OMEZarrLoader extends ThreadableVolumeLoader {
81
82
  if (!queue) {
82
83
  queue = new SubscribableRequestQueue(fetchOptions?.concurrencyLimit, fetchOptions?.prefetchConcurrencyLimit);
83
84
  }
84
- const urlsArr = Array.isArray(urls) ? urls : [urls];
85
+ const urlsArr = (Array.isArray(urls) ? urls : [urls]).map(remapUri);
85
86
  const scenesArr = Array.isArray(scenes) ? scenes : [scenes];
86
87
 
87
88
  // Create one `ZarrSource` per URL
@@ -4,6 +4,7 @@ import { ThreadableVolumeLoader, LoadSpec } from "./IVolumeLoader.js";
4
4
  import { computePackedAtlasDims, MAX_ATLAS_EDGE } from "./VolumeLoaderUtils.js";
5
5
  import { VolumeLoadError, VolumeLoadErrorType, wrapVolumeLoadError } from "./VolumeLoadError.js";
6
6
  import { CImageInfo } from "../ImageInfo.js";
7
+ import { remapUri } from "../utils/url_utils.js";
7
8
  function trimNull(xml) {
8
9
  // trim trailing unicode zeros?
9
10
  return xml && xml.trim().replace(/\0/g, "").trim();
@@ -92,7 +93,7 @@ const getPixelType = pxSize => pxSize === 1 ? "uint8" : pxSize === 2 ? "uint16"
92
93
  class TiffLoader extends ThreadableVolumeLoader {
93
94
  constructor(url) {
94
95
  super();
95
- this.url = url;
96
+ this.url = url.map(remapUri);
96
97
  }
97
98
  async loadOmeDims() {
98
99
  if (!this.dims) {
@@ -35,7 +35,7 @@ export type TiffLoadResult = {
35
35
  range: [number, number];
36
36
  };
37
37
  declare class TiffLoader extends ThreadableVolumeLoader {
38
- url: string[];
38
+ private url;
39
39
  dims?: OMEDims;
40
40
  constructor(url: string[]);
41
41
  private loadOmeDims;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Remaps non-standard URIs (e.g. S3 (`s3://`), Google Cloud Storage (`gs://`), or
3
+ * VAST files (`/allen/aics/`)) to a standard HTTPS URL.
4
+ */
5
+ export declare function remapUri(url: string): string;
@@ -0,0 +1,25 @@
1
+ const S3_URL_PREFIX = "s3://";
2
+ const GCS_URL_PREFIX = "gs://";
3
+ const VAST_FILES_PREFIX = "/allen/aics/";
4
+ const VAST_FILES_URL = "https://vast-files.int.allencell.org/";
5
+
6
+ /**
7
+ * Remaps non-standard URIs (e.g. S3 (`s3://`), Google Cloud Storage (`gs://`), or
8
+ * VAST files (`/allen/aics/`)) to a standard HTTPS URL.
9
+ */
10
+ export function remapUri(url) {
11
+ let newUrl = url.trim();
12
+ if (newUrl.startsWith(S3_URL_PREFIX)) {
13
+ // remap s3://bucket/key to https://bucket.s3.amazonaws.com/key
14
+ const s3Path = newUrl.slice(S3_URL_PREFIX.length);
15
+ const pathSegments = s3Path.split("/");
16
+ newUrl = `https://${pathSegments[0]}.s3.amazonaws.com/${pathSegments.slice(1).join("/")}`;
17
+ } else if (newUrl.startsWith(GCS_URL_PREFIX)) {
18
+ // remap gs://bucket/key to https://storage.googleapis.com/bucket/key
19
+ newUrl = newUrl.replace(GCS_URL_PREFIX, "https://storage.googleapis.com/");
20
+ } else if (newUrl.startsWith(VAST_FILES_PREFIX)) {
21
+ // remap /allen/aics/... to https://vast-files.int.allencell.org/...
22
+ newUrl = newUrl.replace(VAST_FILES_PREFIX, VAST_FILES_URL);
23
+ }
24
+ return newUrl;
25
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aics/vole-core",
3
- "version": "4.4.1",
3
+ "version": "4.5.0",
4
4
  "description": "volume renderer for 3d, 4d, or 5d imaging data with OME-Zarr support",
5
5
  "main": "es/index.js",
6
6
  "type": "module",