@aics/vole-core 3.12.4
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/LICENSE.txt +26 -0
- package/README.md +119 -0
- package/es/Atlas2DSlice.js +224 -0
- package/es/Channel.js +264 -0
- package/es/FileSaver.js +31 -0
- package/es/FusedChannelData.js +192 -0
- package/es/Histogram.js +250 -0
- package/es/ImageInfo.js +127 -0
- package/es/Light.js +74 -0
- package/es/Lut.js +500 -0
- package/es/MarchingCubes.js +507 -0
- package/es/MeshVolume.js +334 -0
- package/es/NaiveSurfaceNets.js +251 -0
- package/es/PathTracedVolume.js +482 -0
- package/es/RayMarchedAtlasVolume.js +250 -0
- package/es/RenderToBuffer.js +31 -0
- package/es/ThreeJsPanel.js +633 -0
- package/es/Timing.js +28 -0
- package/es/TrackballControls.js +538 -0
- package/es/View3d.js +848 -0
- package/es/Volume.js +352 -0
- package/es/VolumeCache.js +161 -0
- package/es/VolumeDims.js +16 -0
- package/es/VolumeDrawable.js +702 -0
- package/es/VolumeMaker.js +101 -0
- package/es/VolumeRenderImpl.js +1 -0
- package/es/VolumeRenderSettings.js +203 -0
- package/es/constants/basicShaders.js +29 -0
- package/es/constants/colors.js +59 -0
- package/es/constants/denoiseShader.js +43 -0
- package/es/constants/lights.js +42 -0
- package/es/constants/materials.js +85 -0
- package/es/constants/pathtraceOutputShader.js +13 -0
- package/es/constants/scaleBarSVG.js +21 -0
- package/es/constants/time.js +34 -0
- package/es/constants/volumePTshader.js +153 -0
- package/es/constants/volumeRayMarchShader.js +123 -0
- package/es/constants/volumeSliceShader.js +115 -0
- package/es/index.js +21 -0
- package/es/loaders/IVolumeLoader.js +131 -0
- package/es/loaders/JsonImageInfoLoader.js +255 -0
- package/es/loaders/OmeZarrLoader.js +495 -0
- package/es/loaders/OpenCellLoader.js +65 -0
- package/es/loaders/RawArrayLoader.js +89 -0
- package/es/loaders/TiffLoader.js +219 -0
- package/es/loaders/VolumeLoadError.js +44 -0
- package/es/loaders/VolumeLoaderUtils.js +221 -0
- package/es/loaders/index.js +40 -0
- package/es/loaders/zarr_utils/ChunkPrefetchIterator.js +143 -0
- package/es/loaders/zarr_utils/WrappedStore.js +51 -0
- package/es/loaders/zarr_utils/types.js +24 -0
- package/es/loaders/zarr_utils/utils.js +225 -0
- package/es/loaders/zarr_utils/validation.js +49 -0
- package/es/test/ChunkPrefetchIterator.test.js +208 -0
- package/es/test/RequestQueue.test.js +442 -0
- package/es/test/SubscribableRequestQueue.test.js +244 -0
- package/es/test/VolumeCache.test.js +118 -0
- package/es/test/VolumeRenderSettings.test.js +71 -0
- package/es/test/lut.test.js +671 -0
- package/es/test/num_utils.test.js +140 -0
- package/es/test/volume.test.js +98 -0
- package/es/test/zarr_utils.test.js +358 -0
- package/es/types/Atlas2DSlice.d.ts +41 -0
- package/es/types/Channel.d.ts +44 -0
- package/es/types/FileSaver.d.ts +6 -0
- package/es/types/FusedChannelData.d.ts +26 -0
- package/es/types/Histogram.d.ts +57 -0
- package/es/types/ImageInfo.d.ts +87 -0
- package/es/types/Light.d.ts +27 -0
- package/es/types/Lut.d.ts +67 -0
- package/es/types/MarchingCubes.d.ts +53 -0
- package/es/types/MeshVolume.d.ts +40 -0
- package/es/types/NaiveSurfaceNets.d.ts +11 -0
- package/es/types/PathTracedVolume.d.ts +65 -0
- package/es/types/RayMarchedAtlasVolume.d.ts +41 -0
- package/es/types/RenderToBuffer.d.ts +17 -0
- package/es/types/ThreeJsPanel.d.ts +107 -0
- package/es/types/Timing.d.ts +11 -0
- package/es/types/TrackballControls.d.ts +51 -0
- package/es/types/View3d.d.ts +357 -0
- package/es/types/Volume.d.ts +152 -0
- package/es/types/VolumeCache.d.ts +43 -0
- package/es/types/VolumeDims.d.ts +28 -0
- package/es/types/VolumeDrawable.d.ts +108 -0
- package/es/types/VolumeMaker.d.ts +49 -0
- package/es/types/VolumeRenderImpl.d.ts +22 -0
- package/es/types/VolumeRenderSettings.d.ts +98 -0
- package/es/types/constants/basicShaders.d.ts +4 -0
- package/es/types/constants/colors.d.ts +2 -0
- package/es/types/constants/denoiseShader.d.ts +40 -0
- package/es/types/constants/lights.d.ts +38 -0
- package/es/types/constants/materials.d.ts +20 -0
- package/es/types/constants/pathtraceOutputShader.d.ts +11 -0
- package/es/types/constants/scaleBarSVG.d.ts +2 -0
- package/es/types/constants/time.d.ts +19 -0
- package/es/types/constants/volumePTshader.d.ts +137 -0
- package/es/types/constants/volumeRayMarchShader.d.ts +117 -0
- package/es/types/constants/volumeSliceShader.d.ts +109 -0
- package/es/types/glsl.d.js +0 -0
- package/es/types/index.d.ts +28 -0
- package/es/types/loaders/IVolumeLoader.d.ts +113 -0
- package/es/types/loaders/JsonImageInfoLoader.d.ts +80 -0
- package/es/types/loaders/OmeZarrLoader.d.ts +87 -0
- package/es/types/loaders/OpenCellLoader.d.ts +9 -0
- package/es/types/loaders/RawArrayLoader.d.ts +33 -0
- package/es/types/loaders/TiffLoader.d.ts +45 -0
- package/es/types/loaders/VolumeLoadError.d.ts +18 -0
- package/es/types/loaders/VolumeLoaderUtils.d.ts +38 -0
- package/es/types/loaders/index.d.ts +22 -0
- package/es/types/loaders/zarr_utils/ChunkPrefetchIterator.d.ts +22 -0
- package/es/types/loaders/zarr_utils/WrappedStore.d.ts +24 -0
- package/es/types/loaders/zarr_utils/types.d.ts +94 -0
- package/es/types/loaders/zarr_utils/utils.d.ts +23 -0
- package/es/types/loaders/zarr_utils/validation.d.ts +7 -0
- package/es/types/test/ChunkPrefetchIterator.test.d.ts +1 -0
- package/es/types/test/RequestQueue.test.d.ts +1 -0
- package/es/types/test/SubscribableRequestQueue.test.d.ts +1 -0
- package/es/types/test/VolumeCache.test.d.ts +1 -0
- package/es/types/test/VolumeRenderSettings.test.d.ts +1 -0
- package/es/types/test/lut.test.d.ts +1 -0
- package/es/types/test/num_utils.test.d.ts +1 -0
- package/es/types/test/volume.test.d.ts +1 -0
- package/es/types/test/zarr_utils.test.d.ts +1 -0
- package/es/types/types.d.ts +115 -0
- package/es/types/utils/RequestQueue.d.ts +112 -0
- package/es/types/utils/SubscribableRequestQueue.d.ts +52 -0
- package/es/types/utils/num_utils.d.ts +43 -0
- package/es/types/workers/VolumeLoaderContext.d.ts +106 -0
- package/es/types/workers/types.d.ts +101 -0
- package/es/types/workers/util.d.ts +3 -0
- package/es/types.js +75 -0
- package/es/typings.d.js +0 -0
- package/es/utils/RequestQueue.js +267 -0
- package/es/utils/SubscribableRequestQueue.js +187 -0
- package/es/utils/num_utils.js +231 -0
- package/es/workers/FetchTiffWorker.js +153 -0
- package/es/workers/VolumeLoadWorker.js +129 -0
- package/es/workers/VolumeLoaderContext.js +271 -0
- package/es/workers/types.js +41 -0
- package/es/workers/util.js +8 -0
- package/package.json +83 -0
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { Vector2, Vector3, Matrix4, Texture } from "three";
|
|
2
|
+
export declare const sliceVertexShaderSrc: string;
|
|
3
|
+
export declare const sliceFragmentShaderSrc: string;
|
|
4
|
+
export declare const sliceShaderUniforms: () => {
|
|
5
|
+
iResolution: {
|
|
6
|
+
type: string;
|
|
7
|
+
value: Vector2;
|
|
8
|
+
};
|
|
9
|
+
CLIP_NEAR: {
|
|
10
|
+
type: string;
|
|
11
|
+
value: number;
|
|
12
|
+
};
|
|
13
|
+
CLIP_FAR: {
|
|
14
|
+
type: string;
|
|
15
|
+
value: number;
|
|
16
|
+
};
|
|
17
|
+
maskAlpha: {
|
|
18
|
+
type: string;
|
|
19
|
+
value: number;
|
|
20
|
+
};
|
|
21
|
+
BRIGHTNESS: {
|
|
22
|
+
type: string;
|
|
23
|
+
value: number;
|
|
24
|
+
};
|
|
25
|
+
DENSITY: {
|
|
26
|
+
type: string;
|
|
27
|
+
value: number;
|
|
28
|
+
};
|
|
29
|
+
GAMMA_MIN: {
|
|
30
|
+
type: string;
|
|
31
|
+
value: number;
|
|
32
|
+
};
|
|
33
|
+
GAMMA_MAX: {
|
|
34
|
+
type: string;
|
|
35
|
+
value: number;
|
|
36
|
+
};
|
|
37
|
+
GAMMA_SCALE: {
|
|
38
|
+
type: string;
|
|
39
|
+
value: number;
|
|
40
|
+
};
|
|
41
|
+
BREAK_STEPS: {
|
|
42
|
+
type: string;
|
|
43
|
+
value: number;
|
|
44
|
+
};
|
|
45
|
+
ATLAS_DIMS: {
|
|
46
|
+
type: string;
|
|
47
|
+
value: Vector2;
|
|
48
|
+
};
|
|
49
|
+
Z_SLICE: {
|
|
50
|
+
type: string;
|
|
51
|
+
value: number;
|
|
52
|
+
};
|
|
53
|
+
SLICES: {
|
|
54
|
+
type: string;
|
|
55
|
+
value: number;
|
|
56
|
+
};
|
|
57
|
+
isOrtho: {
|
|
58
|
+
type: string;
|
|
59
|
+
value: number;
|
|
60
|
+
};
|
|
61
|
+
orthoThickness: {
|
|
62
|
+
type: string;
|
|
63
|
+
value: number;
|
|
64
|
+
};
|
|
65
|
+
orthoScale: {
|
|
66
|
+
type: string;
|
|
67
|
+
value: number;
|
|
68
|
+
};
|
|
69
|
+
AABB_CLIP_MIN: {
|
|
70
|
+
type: string;
|
|
71
|
+
value: Vector3;
|
|
72
|
+
};
|
|
73
|
+
AABB_CLIP_MAX: {
|
|
74
|
+
type: string;
|
|
75
|
+
value: Vector3;
|
|
76
|
+
};
|
|
77
|
+
inverseModelViewMatrix: {
|
|
78
|
+
type: string;
|
|
79
|
+
value: Matrix4;
|
|
80
|
+
};
|
|
81
|
+
textureAtlas: {
|
|
82
|
+
type: string;
|
|
83
|
+
value: Texture;
|
|
84
|
+
};
|
|
85
|
+
textureAtlasMask: {
|
|
86
|
+
type: string;
|
|
87
|
+
value: Texture;
|
|
88
|
+
};
|
|
89
|
+
maxProject: {
|
|
90
|
+
type: string;
|
|
91
|
+
value: number;
|
|
92
|
+
};
|
|
93
|
+
interpolationEnabled: {
|
|
94
|
+
type: string;
|
|
95
|
+
value: boolean;
|
|
96
|
+
};
|
|
97
|
+
flipVolume: {
|
|
98
|
+
type: string;
|
|
99
|
+
value: Vector3;
|
|
100
|
+
};
|
|
101
|
+
volumeScale: {
|
|
102
|
+
type: string;
|
|
103
|
+
value: Vector3;
|
|
104
|
+
};
|
|
105
|
+
textureRes: {
|
|
106
|
+
type: string;
|
|
107
|
+
value: Vector2;
|
|
108
|
+
};
|
|
109
|
+
};
|
|
File without changes
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import { RENDERMODE_PATHTRACE, RENDERMODE_RAYMARCH, View3d } from "./View3d.js";
|
|
2
|
+
import Volume from "./Volume.js";
|
|
3
|
+
import VolumeDrawable from "./VolumeDrawable.js";
|
|
4
|
+
import Channel from "./Channel.js";
|
|
5
|
+
import VolumeMaker from "./VolumeMaker.js";
|
|
6
|
+
import VolumeCache from "./VolumeCache.js";
|
|
7
|
+
import RequestQueue from "./utils/RequestQueue.js";
|
|
8
|
+
import SubscribableRequestQueue from "./utils/SubscribableRequestQueue.js";
|
|
9
|
+
import Histogram from "./Histogram.js";
|
|
10
|
+
import { Lut, remapControlPoints } from "./Lut.js";
|
|
11
|
+
import { ViewportCorner } from "./types.js";
|
|
12
|
+
import { VolumeFileFormat, createVolumeLoader, PrefetchDirection } from "./loaders/index.js";
|
|
13
|
+
import { LoadSpec } from "./loaders/IVolumeLoader.js";
|
|
14
|
+
import { OMEZarrLoader } from "./loaders/OmeZarrLoader.js";
|
|
15
|
+
import { JsonImageInfoLoader } from "./loaders/JsonImageInfoLoader.js";
|
|
16
|
+
import { RawArrayLoader, type RawArrayData, type RawArrayInfo, type RawArrayLoaderOptions } from "./loaders/RawArrayLoader.js";
|
|
17
|
+
import { TiffLoader } from "./loaders/TiffLoader.js";
|
|
18
|
+
import VolumeLoaderContext from "./workers/VolumeLoaderContext.js";
|
|
19
|
+
import { VolumeLoadError, VolumeLoadErrorType } from "./loaders/VolumeLoadError.js";
|
|
20
|
+
import { type CameraState } from "./ThreeJsPanel.js";
|
|
21
|
+
import { Light, AREA_LIGHT, SKY_LIGHT } from "./Light.js";
|
|
22
|
+
export type { ImageInfo } from "./ImageInfo.js";
|
|
23
|
+
export type { ControlPoint } from "./Lut.js";
|
|
24
|
+
export type { CreateLoaderOptions } from "./loaders/index.js";
|
|
25
|
+
export type { IVolumeLoader, PerChannelCallback } from "./loaders/IVolumeLoader.js";
|
|
26
|
+
export type { ZarrLoaderFetchOptions } from "./loaders/OmeZarrLoader.js";
|
|
27
|
+
export type { WorkerLoader } from "./workers/VolumeLoaderContext.js";
|
|
28
|
+
export { Histogram, Lut, remapControlPoints, View3d, Volume, VolumeDrawable, LoadSpec, VolumeMaker, VolumeCache, RequestQueue, SubscribableRequestQueue, PrefetchDirection, OMEZarrLoader, JsonImageInfoLoader, RawArrayLoader, type RawArrayData, type RawArrayInfo, type RawArrayLoaderOptions, TiffLoader, VolumeLoaderContext, VolumeLoadError, VolumeLoadErrorType, VolumeFileFormat, createVolumeLoader, Channel, Light, ViewportCorner, AREA_LIGHT, RENDERMODE_PATHTRACE, RENDERMODE_RAYMARCH, SKY_LIGHT, type CameraState, };
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { Box3 } from "three";
|
|
2
|
+
import Volume from "../Volume.js";
|
|
3
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
4
|
+
import { type ImageInfo } from "../ImageInfo.js";
|
|
5
|
+
import { TypedArray, NumberType } from "../types.js";
|
|
6
|
+
import { PrefetchDirection } from "./zarr_utils/types.js";
|
|
7
|
+
import { ZarrLoaderFetchOptions } from "./OmeZarrLoader.js";
|
|
8
|
+
export declare class LoadSpec {
|
|
9
|
+
time: number;
|
|
10
|
+
/** The max size of a volume atlas that may be produced by a load. Used to pick the appropriate multiscale level. */
|
|
11
|
+
maxAtlasEdge?: number;
|
|
12
|
+
/** An optional bias added to the scale level index after the optimal level is picked based on `maxAtlasEdge`. */
|
|
13
|
+
scaleLevelBias?: number;
|
|
14
|
+
/**
|
|
15
|
+
* The max scale level to load. Even when this is specified, the loader may pick a *lower* scale level based on
|
|
16
|
+
* limits imposed by `scaleLevelBias` and `maxAtlasEdge` (or their defaults if unspecified).
|
|
17
|
+
*/
|
|
18
|
+
multiscaleLevel?: number;
|
|
19
|
+
/** Subregion of volume to load. If not specified, the entire volume is loaded. Specify as floats between 0-1. */
|
|
20
|
+
subregion: Box3;
|
|
21
|
+
channels?: number[];
|
|
22
|
+
/** Treat multiscaleLevel literally and don't use other constraints to change it.
|
|
23
|
+
* By default we will try to load the best level based on the maxAtlasEdge and scaleLevelBias,
|
|
24
|
+
* so this is false.
|
|
25
|
+
*/
|
|
26
|
+
useExplicitLevel: boolean;
|
|
27
|
+
}
|
|
28
|
+
export declare function loadSpecToString(spec: LoadSpec): string;
|
|
29
|
+
export type LoadedVolumeInfo = {
|
|
30
|
+
imageInfo: ImageInfo;
|
|
31
|
+
loadSpec: LoadSpec;
|
|
32
|
+
};
|
|
33
|
+
/**
|
|
34
|
+
* @callback PerChannelCallback
|
|
35
|
+
* @param {string} imageurl
|
|
36
|
+
* @param {Volume} volume
|
|
37
|
+
* @param {number} channelindex
|
|
38
|
+
*/
|
|
39
|
+
export type PerChannelCallback = (volume: Volume, channelIndex: number) => void;
|
|
40
|
+
/**
|
|
41
|
+
* @callback RawChannelDataCallback - allow lists of channel indices and data arrays to be passed to the callback
|
|
42
|
+
* @param {number[]} channelIndex - The indices of the channels that were loaded
|
|
43
|
+
* @param {NumberType[]} dtype - The data type of the data arrays
|
|
44
|
+
* @param {TypedArray<NumberType>[]} data - The raw data for each channel
|
|
45
|
+
* @param {[number, number][]} ranges - The min and max values for each channel in their original range
|
|
46
|
+
* @param {[number, number]} atlasDims - The dimensions of the atlas, if the data is in an atlas format
|
|
47
|
+
*/
|
|
48
|
+
export type RawChannelDataCallback = (channelIndex: number[], dtype: NumberType[], data: TypedArray<NumberType>[], ranges: [number, number][], atlasDims?: [number, number]) => void;
|
|
49
|
+
/**
|
|
50
|
+
* Loads volume data from a source specified by a `LoadSpec`.
|
|
51
|
+
*
|
|
52
|
+
* Loaders may keep state for reuse between volume creation and volume loading, and should be kept alive until volume
|
|
53
|
+
* loading is complete. (See `createVolume`)
|
|
54
|
+
*/
|
|
55
|
+
export interface IVolumeLoader {
|
|
56
|
+
/** Use VolumeDims to further refine a `LoadSpec` for use in `createVolume` */
|
|
57
|
+
loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
58
|
+
/**
|
|
59
|
+
* Create an empty `Volume` from a `LoadSpec`, which must be passed to `loadVolumeData` to begin loading.
|
|
60
|
+
* Optionally pass a callback to respond whenever new channel data is loaded into the volume.
|
|
61
|
+
*/
|
|
62
|
+
createVolume(loadSpec: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<Volume>;
|
|
63
|
+
/**
|
|
64
|
+
* Begin loading a volume's data, as specified in its `LoadSpec`.
|
|
65
|
+
*
|
|
66
|
+
* Pass a callback to respond when this request loads a new channel. This callback will execute after the one
|
|
67
|
+
* assigned in `createVolume`, if any.
|
|
68
|
+
*
|
|
69
|
+
* The returned `Promise` resolves once all channels load, or rejects with any error that occurs during loading.
|
|
70
|
+
*/
|
|
71
|
+
loadVolumeData(volume: Volume, loadSpec?: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<void>;
|
|
72
|
+
/** Change which directions to prioritize when prefetching. Currently only implemented on `OMEZarrLoader`. */
|
|
73
|
+
setPrefetchPriority(directions: PrefetchDirection[]): void;
|
|
74
|
+
/**
|
|
75
|
+
* By default channel data can arrive out of order and at different times.
|
|
76
|
+
* This can cause the rendering to update in a way that is not visually appealing.
|
|
77
|
+
* In particular, during time series playback or Z slice playback, we would like
|
|
78
|
+
* to see all channels update at the same time.
|
|
79
|
+
* @param sync Set true to force all requested channels to load at the same time
|
|
80
|
+
*/
|
|
81
|
+
syncMultichannelLoading(sync: boolean): void;
|
|
82
|
+
}
|
|
83
|
+
/** Abstract class which allows loaders to accept and return types that are easier to transfer to/from a worker. */
|
|
84
|
+
export declare abstract class ThreadableVolumeLoader implements IVolumeLoader {
|
|
85
|
+
/** Unchanged from `IVolumeLoader`. See that interface for details. */
|
|
86
|
+
abstract loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
87
|
+
/**
|
|
88
|
+
* Creates an `ImageInfo` object from a `LoadSpec`, which may be passed to the `Volume` constructor to create an
|
|
89
|
+
* empty volume that can accept data loaded with the given `LoadSpec`.
|
|
90
|
+
*
|
|
91
|
+
* Also returns a new `LoadSpec` that may have been modified from the input `LoadSpec` to reflect the constraints or
|
|
92
|
+
* abilities of the loader. This new `LoadSpec` should be used when constructing the `Volume`, _not_ the original.
|
|
93
|
+
*/
|
|
94
|
+
abstract createImageInfo(loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
95
|
+
/**
|
|
96
|
+
* Begins loading per-channel data for the volume specified by `imageInfo` and `loadSpec`.
|
|
97
|
+
*
|
|
98
|
+
* This function accepts two required callbacks. The first, `onUpdateVolumeMetadata`, should be called at most once
|
|
99
|
+
* to modify the `Volume`'s `imageInfo` and/or `loadSpec` properties based on changes made by this load. Actual
|
|
100
|
+
* loaded channel data is passed to `onData` as it is loaded.
|
|
101
|
+
*
|
|
102
|
+
* Depending on the loader, the array passed to `onData` may be in simple 3d dimension order or reflect a 2d atlas.
|
|
103
|
+
* If the latter, the dimensions of the atlas are passed as the third argument to `onData`.
|
|
104
|
+
*
|
|
105
|
+
* The returned promise should resolve when all data has been loaded, or reject if any error occurs while loading.
|
|
106
|
+
*/
|
|
107
|
+
abstract loadRawChannelData(imageInfo: ImageInfo, loadSpec: LoadSpec, onUpdateVolumeMetadata: (imageInfo?: ImageInfo, loadSpec?: LoadSpec) => void, onData: RawChannelDataCallback): Promise<void>;
|
|
108
|
+
setPrefetchPriority(_directions: PrefetchDirection[]): void;
|
|
109
|
+
syncMultichannelLoading(_sync: boolean): void;
|
|
110
|
+
updateFetchOptions(_options: Partial<ZarrLoaderFetchOptions>): void;
|
|
111
|
+
createVolume(loadSpec: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<Volume>;
|
|
112
|
+
loadVolumeData(volume: Volume, loadSpecOverride?: LoadSpec, onChannelLoaded?: PerChannelCallback): Promise<void>;
|
|
113
|
+
}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import { ThreadableVolumeLoader, type LoadSpec, type RawChannelDataCallback, type LoadedVolumeInfo } from "./IVolumeLoader.js";
|
|
2
|
+
import { type ImageInfo } from "../ImageInfo.js";
|
|
3
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
4
|
+
import VolumeCache from "../VolumeCache.js";
|
|
5
|
+
interface PackedChannelsImage {
|
|
6
|
+
name: string;
|
|
7
|
+
channels: number[];
|
|
8
|
+
}
|
|
9
|
+
type JsonImageInfo = {
|
|
10
|
+
name: string;
|
|
11
|
+
version?: string;
|
|
12
|
+
images: PackedChannelsImage[];
|
|
13
|
+
/** X size of the *original* (not downsampled) volume, in pixels */
|
|
14
|
+
width: number;
|
|
15
|
+
/** Y size of the *original* (not downsampled) volume, in pixels */
|
|
16
|
+
height: number;
|
|
17
|
+
/** Number of rows of z-slice tiles (not pixels) in the texture atlas */
|
|
18
|
+
rows: number;
|
|
19
|
+
/** Number of columns of z-slice tiles (not pixels) in the texture atlas */
|
|
20
|
+
cols: number;
|
|
21
|
+
/** Width of a single atlas tile in pixels */
|
|
22
|
+
tile_width: number;
|
|
23
|
+
/** Height of a single atlas tile in pixels */
|
|
24
|
+
tile_height: number;
|
|
25
|
+
/** Width of the texture atlas in pixels; equivalent to `tile_width * cols` */
|
|
26
|
+
atlas_width: number;
|
|
27
|
+
/** Height of the texture atlas in pixels; equivalent to `tile_height * rows` */
|
|
28
|
+
atlas_height: number;
|
|
29
|
+
/** Number of tiles in the texture atlas (or number of z-slices in the volume segment) */
|
|
30
|
+
tiles: number;
|
|
31
|
+
/** Physical x size of a single *original* (not downsampled) pixel */
|
|
32
|
+
pixel_size_x: number;
|
|
33
|
+
/** Physical y size of a single *original* (not downsampled) pixel */
|
|
34
|
+
pixel_size_y: number;
|
|
35
|
+
/** Physical z size of a single pixel */
|
|
36
|
+
pixel_size_z: number;
|
|
37
|
+
/** Symbol of physical unit used by `pixel_size_(x|y|z)` fields */
|
|
38
|
+
pixel_size_unit?: string;
|
|
39
|
+
channels: number;
|
|
40
|
+
channel_names: string[];
|
|
41
|
+
channel_colors?: [number, number, number][];
|
|
42
|
+
times?: number;
|
|
43
|
+
time_scale?: number;
|
|
44
|
+
time_unit?: string;
|
|
45
|
+
transform: {
|
|
46
|
+
translation: [number, number, number];
|
|
47
|
+
rotation: [number, number, number];
|
|
48
|
+
};
|
|
49
|
+
userData?: Record<string, unknown>;
|
|
50
|
+
};
|
|
51
|
+
declare class JsonImageInfoLoader extends ThreadableVolumeLoader {
|
|
52
|
+
urls: string[];
|
|
53
|
+
jsonInfo: (JsonImageInfo | undefined)[];
|
|
54
|
+
syncChannels: boolean;
|
|
55
|
+
cache?: VolumeCache;
|
|
56
|
+
constructor(urls: string | string[], cache?: VolumeCache);
|
|
57
|
+
private getJsonImageInfo;
|
|
58
|
+
syncMultichannelLoading(sync: boolean): void;
|
|
59
|
+
loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
60
|
+
createImageInfo(loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
61
|
+
loadRawChannelData(imageInfo: ImageInfo, loadSpec: LoadSpec, onUpdateMetadata: (imageInfo: undefined, loadSpec?: LoadSpec) => void, onData: RawChannelDataCallback): Promise<void>;
|
|
62
|
+
/**
|
|
63
|
+
* load per-channel volume data from a batch of image files containing the volume slices tiled across the images
|
|
64
|
+
* @param {Array.<{name:string, channels:Array.<number>}>} imageArray
|
|
65
|
+
* @param {RawChannelDataCallback} onData Per-channel callback. Called when each channel's atlased volume data is loaded
|
|
66
|
+
* @param {VolumeCache} cache
|
|
67
|
+
* @example loadVolumeAtlasData([{
|
|
68
|
+
* "name": "AICS-10_5_5.ome.tif_atlas_0.png",
|
|
69
|
+
* "channels": [0, 1, 2]
|
|
70
|
+
* }, {
|
|
71
|
+
* "name": "AICS-10_5_5.ome.tif_atlas_1.png",
|
|
72
|
+
* "channels": [3, 4, 5]
|
|
73
|
+
* }, {
|
|
74
|
+
* "name": "AICS-10_5_5.ome.tif_atlas_2.png",
|
|
75
|
+
* "channels": [6, 7, 8]
|
|
76
|
+
* }], mycallback);
|
|
77
|
+
*/
|
|
78
|
+
static loadVolumeAtlasData(imageArray: PackedChannelsImage[], onData: RawChannelDataCallback, cache?: VolumeCache, syncChannels?: boolean): Promise<void>;
|
|
79
|
+
}
|
|
80
|
+
export { JsonImageInfoLoader };
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { ImageInfo } from "../ImageInfo.js";
|
|
2
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
3
|
+
import VolumeCache from "../VolumeCache.js";
|
|
4
|
+
import SubscribableRequestQueue from "../utils/SubscribableRequestQueue.js";
|
|
5
|
+
import { ThreadableVolumeLoader, LoadSpec, type RawChannelDataCallback, type LoadedVolumeInfo } from "./IVolumeLoader.js";
|
|
6
|
+
import type { PrefetchDirection } from "./zarr_utils/types.js";
|
|
7
|
+
export type ZarrLoaderFetchOptions = {
|
|
8
|
+
/** The max. number of requests the loader can issue at a time. Ignored if the constructor also receives a queue. */
|
|
9
|
+
concurrencyLimit?: number;
|
|
10
|
+
/**
|
|
11
|
+
* The max. number of *prefetch* requests the loader can issue at a time. Set lower than `concurrencyLimit` to ensure
|
|
12
|
+
* that prefetching leaves room in the queue for actual loads. Ignored if the constructor also receives a queue.
|
|
13
|
+
*/
|
|
14
|
+
prefetchConcurrencyLimit?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The max. number of chunks to prefetch outward in either direction. E.g. if a load requests chunks with z coords 3
|
|
17
|
+
* and 4 and `maxPrefetchDistance` in z is 2, the loader will prefetch similar chunks with z coords 1, 2, 5, and 6
|
|
18
|
+
* (or until it hits `maxPrefetchChunks`). Ordered TZYX.
|
|
19
|
+
*/
|
|
20
|
+
maxPrefetchDistance: [number, number, number, number];
|
|
21
|
+
/** The max. number of total chunks that can be prefetched after any load. */
|
|
22
|
+
maxPrefetchChunks: number;
|
|
23
|
+
/** The initial directions to prioritize when prefetching */
|
|
24
|
+
priorityDirections?: PrefetchDirection[];
|
|
25
|
+
/** only use priority directions */
|
|
26
|
+
onlyPriorityDirections?: boolean;
|
|
27
|
+
};
|
|
28
|
+
declare class OMEZarrLoader extends ThreadableVolumeLoader {
|
|
29
|
+
/**
|
|
30
|
+
* Array of records, each containing the objects and metadata we need to load from one source of multiscale zarr
|
|
31
|
+
* data. See documentation on `ZarrSource` for more.
|
|
32
|
+
*/
|
|
33
|
+
private sources;
|
|
34
|
+
/** Handle to a `SubscribableRequestQueue` for smart concurrency management and request cancelling/reissuing. */
|
|
35
|
+
private requestQueue;
|
|
36
|
+
/** Options to configure (pre)fetching behavior. */
|
|
37
|
+
private fetchOptions;
|
|
38
|
+
/** Direction(s) to prioritize when prefetching. Stored separate from `fetchOptions` since it may be mutated. */
|
|
39
|
+
private priorityDirections;
|
|
40
|
+
/** The ID of the subscriber responsible for "actual loads" (non-prefetch requests) */
|
|
41
|
+
private loadSubscriber;
|
|
42
|
+
/** The ID of the subscriber responsible for prefetches, so that requests can be cancelled and reissued */
|
|
43
|
+
private prefetchSubscriber;
|
|
44
|
+
private maxExtent?;
|
|
45
|
+
private syncChannels;
|
|
46
|
+
private constructor();
|
|
47
|
+
/**
|
|
48
|
+
* Creates a new `OMEZarrLoader`.
|
|
49
|
+
*
|
|
50
|
+
* @param urls The URL(s) of the OME-Zarr data to load. If `urls` is an array, the loader will attempt to find scale
|
|
51
|
+
* levels with exactly the same size in every source. If matching level(s) are available, the loader will produce a
|
|
52
|
+
* volume containing all channels from every provided zarr in the order they appear in `urls`. If no matching sets
|
|
53
|
+
* of scale levels are available, creation fails.
|
|
54
|
+
* @param scenes The scene(s) to load from each URL. If `urls` is an array, `scenes` may either be an array of values
|
|
55
|
+
* corresponding to each URL, or a single value to apply to all URLs. Default 0.
|
|
56
|
+
* @param cache A cache to use for storing fetched data. If not provided, a new cache will be created.
|
|
57
|
+
* @param queue A queue to use for managing requests. If not provided, a new queue will be created.
|
|
58
|
+
* @param fetchOptions Options to configure (pre)fetching behavior.
|
|
59
|
+
*/
|
|
60
|
+
static createLoader(urls: string | string[], scenes?: number | number[], cache?: VolumeCache, queue?: SubscribableRequestQueue, fetchOptions?: ZarrLoaderFetchOptions): Promise<OMEZarrLoader>;
|
|
61
|
+
private getUnitSymbols;
|
|
62
|
+
private getLevelShapesZYX;
|
|
63
|
+
private getScale;
|
|
64
|
+
private orderByDimension;
|
|
65
|
+
private orderByTCZYX;
|
|
66
|
+
/**
|
|
67
|
+
* Converts a volume channel index to the index of its zarr source and its channel index within that zarr.
|
|
68
|
+
* e.g., if the loader has 2 sources, the first with 3 channels and the second with 2, then `matchChannelToSource(4)`
|
|
69
|
+
* returns `[1, 1]` (the second channel of the second source).
|
|
70
|
+
*/
|
|
71
|
+
private matchChannelToSource;
|
|
72
|
+
/**
|
|
73
|
+
* Change which directions to prioritize when prefetching. All chunks will be prefetched in these directions before
|
|
74
|
+
* any chunks are prefetched in any other directions.
|
|
75
|
+
*/
|
|
76
|
+
setPrefetchPriority(directions: PrefetchDirection[]): void;
|
|
77
|
+
syncMultichannelLoading(sync: boolean): void;
|
|
78
|
+
updateFetchOptions(options: Partial<ZarrLoaderFetchOptions>): void;
|
|
79
|
+
loadDims(loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
80
|
+
createImageInfo(loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
81
|
+
private prefetchChunk;
|
|
82
|
+
/** Reads a list of chunk keys requested by a `loadVolumeData` call and sets up appropriate prefetch requests. */
|
|
83
|
+
private beginPrefetch;
|
|
84
|
+
private updateImageInfoForLoad;
|
|
85
|
+
loadRawChannelData(imageInfo: ImageInfo, loadSpec: LoadSpec, onUpdateMetadata: (imageInfo: ImageInfo) => void, onData: RawChannelDataCallback): Promise<void>;
|
|
86
|
+
}
|
|
87
|
+
export { OMEZarrLoader };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { ThreadableVolumeLoader, LoadSpec, RawChannelDataCallback, LoadedVolumeInfo } from "./IVolumeLoader.js";
|
|
2
|
+
import { type ImageInfo } from "../ImageInfo.js";
|
|
3
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
4
|
+
declare class OpenCellLoader extends ThreadableVolumeLoader {
|
|
5
|
+
loadDims(_: LoadSpec): Promise<VolumeDims[]>;
|
|
6
|
+
createImageInfo(_loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
7
|
+
loadRawChannelData(imageInfo: ImageInfo, _loadSpec: LoadSpec, _onUpdateMetadata: () => void, onData: RawChannelDataCallback): Promise<void>;
|
|
8
|
+
}
|
|
9
|
+
export { OpenCellLoader };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { ThreadableVolumeLoader, type LoadSpec, type RawChannelDataCallback, type LoadedVolumeInfo } from "./IVolumeLoader.js";
|
|
2
|
+
import type { ImageInfo } from "../ImageInfo.js";
|
|
3
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
4
|
+
import { Uint8 } from "../types.js";
|
|
5
|
+
export type RawArrayData = {
|
|
6
|
+
dtype: Uint8;
|
|
7
|
+
shape: [number, number, number, number];
|
|
8
|
+
buffer: DataView;
|
|
9
|
+
};
|
|
10
|
+
export type RawArrayInfo = {
|
|
11
|
+
name: string;
|
|
12
|
+
sizeX: number;
|
|
13
|
+
sizeY: number;
|
|
14
|
+
sizeZ: number;
|
|
15
|
+
sizeC: number;
|
|
16
|
+
physicalPixelSize: [number, number, number];
|
|
17
|
+
spatialUnit: string;
|
|
18
|
+
channelNames: string[];
|
|
19
|
+
userData?: Record<string, unknown>;
|
|
20
|
+
};
|
|
21
|
+
export interface RawArrayLoaderOptions {
|
|
22
|
+
data: RawArrayData;
|
|
23
|
+
metadata: RawArrayInfo;
|
|
24
|
+
}
|
|
25
|
+
declare class RawArrayLoader extends ThreadableVolumeLoader {
|
|
26
|
+
data: RawArrayData;
|
|
27
|
+
jsonInfo: RawArrayInfo;
|
|
28
|
+
constructor(rawData: RawArrayData, rawDataInfo: RawArrayInfo);
|
|
29
|
+
loadDims(_loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
30
|
+
createImageInfo(loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
31
|
+
loadRawChannelData(imageInfo: ImageInfo, loadSpec: LoadSpec, onUpdateMetadata: (imageInfo: undefined, loadSpec: LoadSpec) => void, onData: RawChannelDataCallback): Promise<void>;
|
|
32
|
+
}
|
|
33
|
+
export { RawArrayLoader };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { ThreadableVolumeLoader, LoadSpec, type RawChannelDataCallback, type LoadedVolumeInfo } from "./IVolumeLoader.js";
|
|
2
|
+
import { type ImageInfo } from "../ImageInfo.js";
|
|
3
|
+
import type { VolumeDims } from "../VolumeDims.js";
|
|
4
|
+
import { TypedArray, NumberType } from "../types.js";
|
|
5
|
+
declare class OMEDims {
|
|
6
|
+
sizex: number;
|
|
7
|
+
sizey: number;
|
|
8
|
+
sizez: number;
|
|
9
|
+
sizec: number;
|
|
10
|
+
sizet: number;
|
|
11
|
+
unit: string;
|
|
12
|
+
pixeltype: string;
|
|
13
|
+
dimensionorder: string;
|
|
14
|
+
pixelsizex: number;
|
|
15
|
+
pixelsizey: number;
|
|
16
|
+
pixelsizez: number;
|
|
17
|
+
channelnames: string[];
|
|
18
|
+
}
|
|
19
|
+
export type TiffWorkerParams = {
|
|
20
|
+
channel: number;
|
|
21
|
+
tilesizex: number;
|
|
22
|
+
tilesizey: number;
|
|
23
|
+
sizec: number;
|
|
24
|
+
sizez: number;
|
|
25
|
+
dimensionOrder: string;
|
|
26
|
+
bytesPerSample: number;
|
|
27
|
+
url: string;
|
|
28
|
+
};
|
|
29
|
+
export type TiffLoadResult = {
|
|
30
|
+
isError: false;
|
|
31
|
+
data: TypedArray<NumberType>;
|
|
32
|
+
dtype: NumberType;
|
|
33
|
+
channel: number;
|
|
34
|
+
range: [number, number];
|
|
35
|
+
};
|
|
36
|
+
declare class TiffLoader extends ThreadableVolumeLoader {
|
|
37
|
+
url: string;
|
|
38
|
+
dims?: OMEDims;
|
|
39
|
+
constructor(url: string);
|
|
40
|
+
private loadOmeDims;
|
|
41
|
+
loadDims(_loadSpec: LoadSpec): Promise<VolumeDims[]>;
|
|
42
|
+
createImageInfo(_loadSpec: LoadSpec): Promise<LoadedVolumeInfo>;
|
|
43
|
+
loadRawChannelData(imageInfo: ImageInfo, _loadSpec: LoadSpec, _onUpdateMetadata: () => void, onData: RawChannelDataCallback): Promise<void>;
|
|
44
|
+
}
|
|
45
|
+
export { TiffLoader };
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** Groups possible load errors into a few broad categories which we can give similar guidance to the user about. */
|
|
2
|
+
export declare const enum VolumeLoadErrorType {
|
|
3
|
+
UNKNOWN = "unknown",
|
|
4
|
+
NOT_FOUND = "not_found",
|
|
5
|
+
TOO_LARGE = "too_large",
|
|
6
|
+
LOAD_DATA_FAILED = "load_data_failed",
|
|
7
|
+
INVALID_METADATA = "invalid_metadata",
|
|
8
|
+
INVALID_MULTI_SOURCE_ZARR = "invalid_multi_source_zarr"
|
|
9
|
+
}
|
|
10
|
+
export declare class VolumeLoadError extends Error {
|
|
11
|
+
type: VolumeLoadErrorType;
|
|
12
|
+
constructor(message?: string, options?: {
|
|
13
|
+
cause?: unknown;
|
|
14
|
+
type?: VolumeLoadErrorType;
|
|
15
|
+
});
|
|
16
|
+
}
|
|
17
|
+
/** Curried function to re-throw an error wrapped in a `VolumeLoadError` with the given `message` and `type`. */
|
|
18
|
+
export declare function wrapVolumeLoadError<T>(message?: string, type?: VolumeLoadErrorType, ignore?: unknown): (e: T) => T;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Box3, Vector2, Vector3 } from "three";
|
|
2
|
+
import { type ImageInfo } from "../ImageInfo.js";
|
|
3
|
+
import { LoadSpec } from "./IVolumeLoader.js";
|
|
4
|
+
export declare const MAX_ATLAS_EDGE = 4096;
|
|
5
|
+
/** Converts a full spatial or temporal unit name supported by OME-Zarr to its unit symbol */
|
|
6
|
+
export declare function unitNameToSymbol(unitName?: string): string | null;
|
|
7
|
+
export declare function computePackedAtlasDims(z: number, tw: number, th: number): Vector2;
|
|
8
|
+
/** Picks the largest scale level that can fit into a texture atlas with edges no longer than `maxAtlasEdge`. */
|
|
9
|
+
export declare function estimateLevelForAtlas(spatialDimsZYX: [number, number, number][], maxAtlasEdge?: number): number | undefined;
|
|
10
|
+
type ZYX = [number, number, number];
|
|
11
|
+
export declare function scaleDimsToSubregion(subregion: Box3, dims: ZYX): ZYX;
|
|
12
|
+
export declare function scaleMultipleDimsToSubregion(subregion: Box3, dims: ZYX[]): ZYX[];
|
|
13
|
+
/**
|
|
14
|
+
* Picks the best scale level to load based on scale level dimensions and a `LoadSpec`. This calls
|
|
15
|
+
* `estimateLevelForAtlas`, then accounts for `LoadSpec`'s scale level picking properties:
|
|
16
|
+
* - `multiscaleLevel` imposes a minimum scale level (or *maximum* resolution level) to load
|
|
17
|
+
* - `maxAtlasEdge` sets the maximum size of the texture atlas that may be produced by a load
|
|
18
|
+
* - `scaleLevelBias` offsets the scale level index after the optimal level is picked based on `maxAtlasEdge`
|
|
19
|
+
*
|
|
20
|
+
* This function assumes that `spatialDimsZYX` has already been appropriately scaled to match `loadSpec`'s `subregion`.
|
|
21
|
+
*/
|
|
22
|
+
export declare function pickLevelToLoadUnscaled(loadSpec: LoadSpec, spatialDimsZYX: ZYX[]): number;
|
|
23
|
+
/**
|
|
24
|
+
* Picks the best scale level to load based on scale level dimensions and a `LoadSpec`. This calls
|
|
25
|
+
* `estimateLevelForAtlas` and accounts for all properties of `LoadSpec` considered by
|
|
26
|
+
* `pickLevelToLoadUnscaled`, and additionally scales the dimensions of the scale levels to account for the
|
|
27
|
+
* `LoadSpec`'s `subregion` property.
|
|
28
|
+
*/
|
|
29
|
+
export declare function pickLevelToLoad(loadSpec: LoadSpec, spatialDimsZYX: ZYX[]): number;
|
|
30
|
+
/** Given the size of a volume in pixels, convert a `Box3` in the 0-1 range to pixels */
|
|
31
|
+
export declare function convertSubregionToPixels(region: Box3, size: Vector3): Box3;
|
|
32
|
+
/**
|
|
33
|
+
* Return the subset of `container` specified by `region`, assuming that `region` contains fractional values (between 0
|
|
34
|
+
* and 1). i.e. if `container`'s range on the X axis is 0-4 and `region`'s is 0.25-0.5, the result will have range 1-2.
|
|
35
|
+
*/
|
|
36
|
+
export declare function composeSubregion(region: Box3, container: Box3): Box3;
|
|
37
|
+
export declare function buildDefaultMetadata(rawImageInfo: ImageInfo): Record<string, unknown>;
|
|
38
|
+
export {};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { ThreadableVolumeLoader } from "./IVolumeLoader.js";
|
|
2
|
+
import { type ZarrLoaderFetchOptions } from "./OmeZarrLoader.js";
|
|
3
|
+
import { RawArrayLoaderOptions } from "./RawArrayLoader.js";
|
|
4
|
+
import VolumeCache from "../VolumeCache.js";
|
|
5
|
+
import SubscribableRequestQueue from "../utils/SubscribableRequestQueue.js";
|
|
6
|
+
export { PrefetchDirection } from "./zarr_utils/types.js";
|
|
7
|
+
export declare const enum VolumeFileFormat {
|
|
8
|
+
ZARR = "zarr",
|
|
9
|
+
JSON = "json",
|
|
10
|
+
TIFF = "tiff",
|
|
11
|
+
DATA = "data"
|
|
12
|
+
}
|
|
13
|
+
export type CreateLoaderOptions = {
|
|
14
|
+
fileType?: VolumeFileFormat;
|
|
15
|
+
cache?: VolumeCache;
|
|
16
|
+
queue?: SubscribableRequestQueue;
|
|
17
|
+
scene?: number;
|
|
18
|
+
fetchOptions?: ZarrLoaderFetchOptions;
|
|
19
|
+
rawArrayOptions?: RawArrayLoaderOptions;
|
|
20
|
+
};
|
|
21
|
+
export declare function pathToFileType(path: string): VolumeFileFormat;
|
|
22
|
+
export declare function createVolumeLoader(path: string | string[], options?: CreateLoaderOptions): Promise<ThreadableVolumeLoader>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { PrefetchDirection, TCZYX } from "./types";
|
|
2
|
+
type TZYX = [number, number, number, number];
|
|
3
|
+
type PrefetchDirectionState = {
|
|
4
|
+
direction: PrefetchDirection;
|
|
5
|
+
chunks: TCZYX<number>[];
|
|
6
|
+
start: number;
|
|
7
|
+
/** May be either a number for all channels or an array of ends per-channels */
|
|
8
|
+
end: number | number[];
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Since the user is most likely to want nearby data (in space or time) first, we should prefetch those chunks first.
|
|
12
|
+
*
|
|
13
|
+
* Given a list of just-loaded chunks and some bounds, `ChunkPrefetchIterator` iterates evenly outwards in T/Z/Y/X.
|
|
14
|
+
*/
|
|
15
|
+
export default class ChunkPrefetchIterator {
|
|
16
|
+
directionStates: PrefetchDirectionState[];
|
|
17
|
+
priorityDirectionStates: PrefetchDirectionState[];
|
|
18
|
+
constructor(chunks: TCZYX<number>[], tzyxMaxPrefetchOffset: TZYX, tczyxChunksPerSource: TCZYX<number>[], priorityDirections?: PrefetchDirection[], onlyPriorityDirections?: boolean);
|
|
19
|
+
private static iterateDirections;
|
|
20
|
+
[Symbol.iterator](): Iterator<TCZYX<number>>;
|
|
21
|
+
}
|
|
22
|
+
export {};
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { AbsolutePath, AsyncMutable, Readable } from "@zarrita/storage";
|
|
2
|
+
import SubscribableRequestQueue from "../../utils/SubscribableRequestQueue";
|
|
3
|
+
import VolumeCache from "../../VolumeCache";
|
|
4
|
+
import { SubscriberId } from "./types";
|
|
5
|
+
type WrappedStoreOpts<Opts> = {
|
|
6
|
+
options?: Opts;
|
|
7
|
+
subscriber: SubscriberId;
|
|
8
|
+
reportKey?: (key: string, subscriber: SubscriberId) => void;
|
|
9
|
+
isPrefetch?: boolean;
|
|
10
|
+
};
|
|
11
|
+
/**
|
|
12
|
+
* `Readable` is zarrita's minimal abstraction for any source of data.
|
|
13
|
+
* `WrappedStore` wraps another `Readable` and adds (optional) connections to `VolumeCache` and `RequestQueue`.
|
|
14
|
+
*/
|
|
15
|
+
declare class WrappedStore<Opts, S extends Readable<Opts> = Readable<Opts>> implements AsyncMutable<WrappedStoreOpts<Opts>> {
|
|
16
|
+
private baseStore;
|
|
17
|
+
private cache?;
|
|
18
|
+
private queue?;
|
|
19
|
+
constructor(baseStore: S, cache?: VolumeCache | undefined, queue?: SubscribableRequestQueue | undefined);
|
|
20
|
+
set(_key: AbsolutePath, _value: Uint8Array): Promise<void>;
|
|
21
|
+
private getAndCache;
|
|
22
|
+
get(key: AbsolutePath, opts?: WrappedStoreOpts<Opts> | undefined): Promise<Uint8Array | undefined>;
|
|
23
|
+
}
|
|
24
|
+
export default WrappedStore;
|