diff --git a/src/io.ts b/src/io.ts index 326aca35..7a7d81c7 100644 --- a/src/io.ts +++ b/src/io.ts @@ -18,6 +18,7 @@ import { loadMultiscales, MAGENTA_GREEN, MAX_CHANNELS, + nested, open, parseMatrix, range, @@ -115,6 +116,19 @@ function loadMultiChannel(config: MultichannelConfig, data: ZarrPixelSource { const node = await open(config.source); let data: ZarrArray[]; @@ -122,6 +136,10 @@ export async function createSourceData(config: ImageLayerConfig): Promise { + if (key === 'getItem' || key === 'containsItem') { + return (path: string, ...args: unknown[]) => { + if (path.endsWith('.zarray') || path.endsWith('.zattrs') || path.endsWith('.zgroup')) { + return target[key](path, ...args); + } + const prefix = path.split('/'); + const chunkKey = prefix.pop()!; + const newPath = [...prefix, chunkKey.replaceAll('.', '/')].join('/'); + return target[key](newPath, ...args); + }; + } + return Reflect.get(target, key); + }; + return new Proxy(store, { get }); +} + export function hexToRGB(hex: string): number[] { if (hex.startsWith('#')) hex = hex.slice(1); const r = parseInt(hex.slice(0, 2), 16);