diff --git a/fizarrita/package.json b/fizarrita/package.json index a39bba6..ae2a597 100644 --- a/fizarrita/package.json +++ b/fizarrita/package.json @@ -1,6 +1,6 @@ { "name": "@fideus-labs/fizarrita", - "version": "1.2.0", + "version": "1.3.0", "description": "Worker-pool-accelerated get/set for zarrita.js — offloads codec encode/decode to Web Workers.", "type": "module", "main": "./dist/index.js", @@ -13,6 +13,18 @@ "./codec-worker": { "types": "./dist/codec-worker.d.ts", "import": "./dist/codec-worker.js" + }, + "./internals/codec-pipeline": { + "types": "./dist/internals/codec-pipeline.d.ts", + "import": "./dist/internals/codec-pipeline.js" + }, + "./internals/setter": { + "types": "./dist/internals/setter.d.ts", + "import": "./dist/internals/setter.js" + }, + "./internals/util": { + "types": "./dist/internals/util.d.ts", + "import": "./dist/internals/util.js" } }, "files": [ diff --git a/fizarrita/src/get-worker.ts b/fizarrita/src/get-worker.ts index 543c3a1..cd1684e 100644 --- a/fizarrita/src/get-worker.ts +++ b/fizarrita/src/get-worker.ts @@ -35,7 +35,7 @@ import { workerDecode, workerDecodeInto, getMetaId } from './worker-rpc.js' * Default URL for the codec worker. Uses `import.meta.url` to resolve * relative to this module. */ -const DEFAULT_WORKER_URL = new URL('./codec-worker.js', import.meta.url) +export const DEFAULT_WORKER_URL = new URL('./codec-worker.js', import.meta.url) /** Shared TextDecoder instance. */ const decoder = new TextDecoder() @@ -54,14 +54,14 @@ const NULL_CACHE: ChunkCache = { const storeIdMap = new WeakMap() let storeIdCounter = 0 -function getStoreId(store: Readable): string { +export function getStoreId(store: Readable): string { if (!storeIdMap.has(store)) { storeIdMap.set(store, storeIdCounter++) } return `store_${storeIdMap.get(store)}` } -function createCacheKey( +export function createCacheKey( arr: ZarrArray, encodeChunkKey: (chunk_coords: number[]) => string, chunk_coords: number[], @@ -75,13 +75,13 @@ function createCacheKey( // Unified metadata reader — reads zarr.json once, returns everything needed // --------------------------------------------------------------------------- -interface ArrayMetadata { +export interface ArrayMetadata { codecMeta: CodecChunkMeta encodeChunkKey: (chunk_coords: number[]) => string fillValue: Scalar | null } -async function readArrayMetadata( +export async function readArrayMetadata( arr: ZarrArray, ): Promise { const store = arr.store @@ -526,7 +526,7 @@ async function validateCandidateChunkShape( +export async function probeActualChunkShape( arr: ZarrArray, encodeChunkKey: (chunk_coords: number[]) => string, codecMeta: CodecChunkMeta, diff --git a/fizarrita/src/index.ts b/fizarrita/src/index.ts index a7c1dc4..e563acd 100644 --- a/fizarrita/src/index.ts +++ b/fizarrita/src/index.ts @@ -6,11 +6,46 @@ * WorkerPool with bounded concurrency. */ -export { getWorker, readZstdFrameContentSize, readBloscFrameContentSize, inferChunkShape } from './get-worker.js' +export { + getWorker, + readZstdFrameContentSize, + readBloscFrameContentSize, + inferChunkShape, + DEFAULT_WORKER_URL, + readArrayMetadata, + probeActualChunkShape, + createCacheKey, + getStoreId, +} from './get-worker.js' +export type { ArrayMetadata } from './get-worker.js' export { setWorker } from './set-worker.js' export type { GetWorkerOptions, SetWorkerOptions, CodecChunkMeta, ChunkCache, + Projection, + Indices, } from './types.js' + +// Internals — exported for building custom workers that extend the codec worker +export { create_codec_pipeline } from './internals/codec-pipeline.js' +export { + get_ctr, + get_strides, + create_chunk_key_encoder, + createBuffer, + assertSharedArrayBufferAvailable, +} from './internals/util.js' +export type { ChunkKeyEncoding } from './internals/util.js' +export { setter, compat_chunk, set_from_chunk_binary } from './internals/setter.js' +export { + BasicIndexer, + normalize_selection, + slice, + slice_indices, +} from './internals/indexer.js' +export type { ChunkProjection, IndexerProjection } from './internals/indexer.js' + +// Worker RPC helpers — for composing custom workers +export { workerDecode, workerDecodeInto, workerEncode, getMetaId } from './worker-rpc.js'