zarrextra 0.2.2 → 0.2.3

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.
@@ -1,15 +1,6 @@
1
- import { WorkerPool } from '@fideus-labs/worker-pool';
2
- import { ChunkCache, GetWorkerOptions } from '@fideus-labs/fizarrita';
3
- export type { ChunkCache } from '@fideus-labs/fizarrita';
4
- export type EnableWorkerChunkDecodeOptions = {
5
- workers?: number;
6
- workerUrl?: string | URL;
7
- useSharedArrayBuffer?: boolean;
8
- cache?: ChunkCache;
9
- };
10
- /** Enable fizarrita worker-pool chunk decode for all subsequent getZarrChunk reads. */
11
- export declare function enableWorkerChunkDecode(options?: EnableWorkerChunkDecodeOptions): WorkerPool;
12
- /** Terminate worker pool and restore main-thread zarr.get chunk decode. */
13
- export declare function disableWorkerChunkDecode(): void;
14
- export type { GetWorkerOptions };
1
+ import { EnableWorkerChunkDecodeOptions } from './workerControls';
2
+ export type { ChunkCache, GetWorkerOptions } from '@fideus-labs/fizarrita';
3
+ export type { EnableWorkerChunkDecodeOptions };
4
+ export declare const enableWorkerChunkDecode: (options?: EnableWorkerChunkDecodeOptions) => import('@fideus-labs/worker-pool').WorkerPool;
5
+ export declare const disableWorkerChunkDecode: () => void;
15
6
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAkBF,uFAAuF;AACvF,wBAAgB,uBAAuB,CAAC,OAAO,GAAE,8BAAmC,cAoBnF;AAED,2EAA2E;AAC3E,wBAAgB,wBAAwB,SAMvC;AAED,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/workers/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,8BAA8B,EAAE,CAAC;AAI/C,eAAO,MAAM,uBAAuB,6FAAmC,CAAC;AACxE,eAAO,MAAM,wBAAwB,YAAoC,CAAC"}
@@ -0,0 +1,6 @@
1
+ import { EnableWorkerChunkDecodeOptions } from './workerControls';
2
+ export type { ChunkCache, GetWorkerOptions } from '@fideus-labs/fizarrita';
3
+ export type { EnableWorkerChunkDecodeOptions };
4
+ export declare const enableWorkerChunkDecode: (options?: EnableWorkerChunkDecodeOptions) => import('@fideus-labs/worker-pool').WorkerPool;
5
+ export declare const disableWorkerChunkDecode: () => void;
6
+ //# sourceMappingURL=index.package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.package.d.ts","sourceRoot":"","sources":["../../src/workers/index.package.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,8BAA8B,EACpC,MAAM,kBAAkB,CAAC;AAG1B,YAAY,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAC3E,YAAY,EAAE,8BAA8B,EAAE,CAAC;AAI/C,eAAO,MAAM,uBAAuB,6FAAmC,CAAC;AACxE,eAAO,MAAM,wBAAwB,YAAoC,CAAC"}
@@ -0,0 +1,16 @@
1
+ import { WorkerPool } from '@fideus-labs/worker-pool';
2
+ import { ChunkCache, GetWorkerOptions } from '@fideus-labs/fizarrita';
3
+ export type { ChunkCache } from '@fideus-labs/fizarrita';
4
+ export type EnableWorkerChunkDecodeOptions = {
5
+ workers?: number;
6
+ workerUrl?: string | URL;
7
+ useSharedArrayBuffer?: boolean;
8
+ cache?: ChunkCache;
9
+ };
10
+ export type WorkerUrlFactory = () => string | URL;
11
+ export declare function createWorkerChunkDecodeControls(defaultWorkerUrl: WorkerUrlFactory): {
12
+ enableWorkerChunkDecode: (options?: EnableWorkerChunkDecodeOptions) => WorkerPool;
13
+ disableWorkerChunkDecode: () => void;
14
+ };
15
+ export type { GetWorkerOptions };
16
+ //# sourceMappingURL=workerControls.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerControls.d.ts","sourceRoot":"","sources":["../../src/workers/workerControls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAa,KAAK,UAAU,EAAE,KAAK,gBAAgB,EAAE,MAAM,wBAAwB,CAAC;AAG3F,YAAY,EAAE,UAAU,EAAE,MAAM,wBAAwB,CAAC;AAEzD,MAAM,MAAM,8BAA8B,GAAG;IAC3C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACzB,oBAAoB,CAAC,EAAE,OAAO,CAAC;IAC/B,KAAK,CAAC,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG,MAAM,MAAM,GAAG,GAAG,CAAC;AAWlD,wBAAgB,+BAA+B,CAAC,gBAAgB,EAAE,gBAAgB;wCAItC,8BAA8B;;EAmCzE;AAED,YAAY,EAAE,gBAAgB,EAAE,CAAC"}
@@ -0,0 +1,2 @@
1
+ export declare function defaultWorkerUrl(): URL;
2
+ //# sourceMappingURL=workerUrl.package.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerUrl.package.d.ts","sourceRoot":"","sources":["../../src/workers/workerUrl.package.ts"],"names":[],"mappings":"AAAA,wBAAgB,gBAAgB,IAAI,GAAG,CAGtC"}
@@ -0,0 +1,2 @@
1
+ export declare function defaultWorkerUrl(): string;
2
+ //# sourceMappingURL=workerUrl.source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerUrl.source.d.ts","sourceRoot":"","sources":["../../src/workers/workerUrl.source.ts"],"names":[],"mappings":"AAIA,wBAAgB,gBAAgB,IAAI,MAAM,CAEzC"}
package/dist/workers.js CHANGED
@@ -1,32 +1,43 @@
1
1
  import { n as e, r as t } from "./chunkDecode-CvE5qLLQ.js";
2
2
  import { WorkerPool as n } from "@fideus-labs/worker-pool";
3
3
  import { getWorker as r } from "@fideus-labs/fizarrita";
4
- //#region src/workers/index.ts
5
- var i;
6
- function a() {
4
+ //#region src/workers/workerControls.ts
5
+ function i() {
7
6
  return typeof navigator < "u" && navigator.hardwareConcurrency ? Math.min(navigator.hardwareConcurrency, 4) : 4;
8
7
  }
9
- function o() {
10
- return new URL("./codec-worker.js", import.meta.url);
11
- }
12
8
  t(r);
13
- function s(t = {}) {
14
- i && c();
15
- let r = new n(t.workers ?? a());
16
- return i = r, e({
17
- kind: "fizarrita",
18
- pool: r,
19
- options: {
20
- workerUrl: t.workerUrl ?? o(),
21
- useSharedArrayBuffer: t.useSharedArrayBuffer,
22
- cache: t.cache
23
- }
24
- }), r;
9
+ function a(t) {
10
+ let r;
11
+ function a(a = {}) {
12
+ r && o();
13
+ let s = new n(a.workers ?? i());
14
+ return r = s, e({
15
+ kind: "fizarrita",
16
+ pool: s,
17
+ options: {
18
+ workerUrl: a.workerUrl ?? t(),
19
+ useSharedArrayBuffer: a.useSharedArrayBuffer,
20
+ cache: a.cache
21
+ }
22
+ }), s;
23
+ }
24
+ function o() {
25
+ r &&= (r.terminateWorkers(), void 0), e({ kind: "main" });
26
+ }
27
+ return {
28
+ enableWorkerChunkDecode: a,
29
+ disableWorkerChunkDecode: o
30
+ };
25
31
  }
26
- function c() {
27
- i &&= (i.terminateWorkers(), void 0), e({ kind: "main" });
32
+ //#endregion
33
+ //#region src/workers/workerUrl.package.ts
34
+ function o() {
35
+ return new URL("./codec-worker.js", import.meta.url);
28
36
  }
29
37
  //#endregion
30
- export { c as disableWorkerChunkDecode, s as enableWorkerChunkDecode };
38
+ //#region src/workers/index.package.ts
39
+ var s = a(o), c = s.enableWorkerChunkDecode, l = s.disableWorkerChunkDecode;
40
+ //#endregion
41
+ export { l as disableWorkerChunkDecode, c as enableWorkerChunkDecode };
31
42
 
32
43
  //# sourceMappingURL=workers.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"workers.js","names":[],"sources":["../src/workers/index.ts"],"sourcesContent":["import { WorkerPool } from '@fideus-labs/worker-pool';\nimport { getWorker, type ChunkCache, type GetWorkerOptions } from '@fideus-labs/fizarrita';\nimport { setChunkDecodeBackend, setFizarritaGetWorker } from '../chunkDecode';\n\nexport type { ChunkCache } from '@fideus-labs/fizarrita';\n\nexport type EnableWorkerChunkDecodeOptions = {\n workers?: number;\n workerUrl?: string | URL;\n useSharedArrayBuffer?: boolean;\n cache?: ChunkCache;\n};\n\nlet activePool: WorkerPool | undefined;\n\nfunction defaultWorkerCount() {\n if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {\n return Math.min(navigator.hardwareConcurrency, 4);\n }\n return 4;\n}\n\nfunction defaultWorkerUrl() {\n const workerFile = './codec-worker.js';\n return new URL(workerFile, import.meta.url);\n}\n\nsetFizarritaGetWorker(getWorker);\n\n/** Enable fizarrita worker-pool chunk decode for all subsequent getZarrChunk reads. */\nexport function enableWorkerChunkDecode(options: EnableWorkerChunkDecodeOptions = {}) {\n if (activePool) {\n disableWorkerChunkDecode();\n }\n\n const pool = new WorkerPool(options.workers ?? defaultWorkerCount());\n activePool = pool;\n\n const workerUrl = options.workerUrl ?? defaultWorkerUrl();\n setChunkDecodeBackend({\n kind: 'fizarrita',\n pool,\n options: {\n workerUrl,\n useSharedArrayBuffer: options.useSharedArrayBuffer,\n cache: options.cache,\n },\n });\n\n return pool;\n}\n\n/** Terminate worker pool and restore main-thread zarr.get chunk decode. */\nexport function disableWorkerChunkDecode() {\n if (activePool) {\n activePool.terminateWorkers();\n activePool = undefined;\n }\n setChunkDecodeBackend({ kind: 'main' });\n}\n\nexport type { GetWorkerOptions };\n"],"mappings":";;;;AAaA,IAAI;AAEJ,SAAS,IAAqB;AAI5B,QAHI,OAAO,YAAc,OAAe,UAAU,sBACzC,KAAK,IAAI,UAAU,qBAAqB,EAAE,GAE5C;;AAGT,SAAS,IAAmB;AAE1B,QAAO,IAAI,IADQ,qBACQ,OAAO,KAAK,IAAI;;AAG7C,EAAsB,EAAU;AAGhC,SAAgB,EAAwB,IAA0C,EAAE,EAAE;AACpF,CAAI,KACF,GAA0B;CAG5B,IAAM,IAAO,IAAI,EAAW,EAAQ,WAAW,GAAoB,CAAC;AAcpE,QAbA,IAAa,GAGb,EAAsB;EACpB,MAAM;EACN;EACA,SAAS;GACP,WALc,EAAQ,aAAa,GAAkB;GAMrD,sBAAsB,EAAQ;GAC9B,OAAO,EAAQ;GAChB;EACF,CAAC,EAEK;;AAIT,SAAgB,IAA2B;AAKzC,CAJA,AAEE,OADA,EAAW,kBAAkB,EAChB,KAAA,IAEf,EAAsB,EAAE,MAAM,QAAQ,CAAC"}
1
+ {"version":3,"file":"workers.js","names":[],"sources":["../src/workers/workerControls.ts","../src/workers/workerUrl.package.ts","../src/workers/index.package.ts"],"sourcesContent":["import { WorkerPool } from '@fideus-labs/worker-pool';\nimport { getWorker, type ChunkCache, type GetWorkerOptions } from '@fideus-labs/fizarrita';\nimport { setChunkDecodeBackend, setFizarritaGetWorker } from '../chunkDecode';\n\nexport type { ChunkCache } from '@fideus-labs/fizarrita';\n\nexport type EnableWorkerChunkDecodeOptions = {\n workers?: number;\n workerUrl?: string | URL;\n useSharedArrayBuffer?: boolean;\n cache?: ChunkCache;\n};\n\nexport type WorkerUrlFactory = () => string | URL;\n\nfunction defaultWorkerCount() {\n if (typeof navigator !== 'undefined' && navigator.hardwareConcurrency) {\n return Math.min(navigator.hardwareConcurrency, 4);\n }\n return 4;\n}\n\nsetFizarritaGetWorker(getWorker);\n\nexport function createWorkerChunkDecodeControls(defaultWorkerUrl: WorkerUrlFactory) {\n let activePool: WorkerPool | undefined;\n\n /** Enable fizarrita worker-pool chunk decode for all subsequent getZarrChunk reads. */\n function enableWorkerChunkDecode(options: EnableWorkerChunkDecodeOptions = {}) {\n if (activePool) {\n disableWorkerChunkDecode();\n }\n\n const pool = new WorkerPool(options.workers ?? defaultWorkerCount());\n activePool = pool;\n\n const workerUrl = options.workerUrl ?? defaultWorkerUrl();\n setChunkDecodeBackend({\n kind: 'fizarrita',\n pool,\n options: {\n workerUrl,\n useSharedArrayBuffer: options.useSharedArrayBuffer,\n cache: options.cache,\n },\n });\n\n return pool;\n }\n\n /** Terminate worker pool and restore main-thread zarr.get chunk decode. */\n function disableWorkerChunkDecode() {\n if (activePool) {\n activePool.terminateWorkers();\n activePool = undefined;\n }\n setChunkDecodeBackend({ kind: 'main' });\n }\n\n return {\n enableWorkerChunkDecode,\n disableWorkerChunkDecode,\n };\n}\n\nexport type { GetWorkerOptions };\n","export function defaultWorkerUrl(): URL {\n const workerFile = './codec-worker.js';\n return new URL(workerFile, import.meta.url);\n}\n","import {\n createWorkerChunkDecodeControls,\n type EnableWorkerChunkDecodeOptions,\n} from './workerControls';\nimport { defaultWorkerUrl } from './workerUrl.package';\n\nexport type { ChunkCache, GetWorkerOptions } from '@fideus-labs/fizarrita';\nexport type { EnableWorkerChunkDecodeOptions };\n\nconst controls = createWorkerChunkDecodeControls(defaultWorkerUrl);\n\nexport const enableWorkerChunkDecode = controls.enableWorkerChunkDecode;\nexport const disableWorkerChunkDecode = controls.disableWorkerChunkDecode;\n"],"mappings":";;;;AAeA,SAAS,IAAqB;AAI5B,QAHI,OAAO,YAAc,OAAe,UAAU,sBACzC,KAAK,IAAI,UAAU,qBAAqB,EAAE,GAE5C;;AAGT,EAAsB,EAAU;AAEhC,SAAgB,EAAgC,GAAoC;CAClF,IAAI;CAGJ,SAAS,EAAwB,IAA0C,EAAE,EAAE;AAC7E,EAAI,KACF,GAA0B;EAG5B,IAAM,IAAO,IAAI,EAAW,EAAQ,WAAW,GAAoB,CAAC;AAcpE,SAbA,IAAa,GAGb,EAAsB;GACpB,MAAM;GACN;GACA,SAAS;IACP,WALc,EAAQ,aAAa,GAAkB;IAMrD,sBAAsB,EAAQ;IAC9B,OAAO,EAAQ;IAChB;GACF,CAAC,EAEK;;CAIT,SAAS,IAA2B;AAKlC,EAJA,AAEE,OADA,EAAW,kBAAkB,EAChB,KAAA,IAEf,EAAsB,EAAE,MAAM,QAAQ,CAAC;;AAGzC,QAAO;EACL;EACA;EACD;;;;AC9DH,SAAgB,IAAwB;AAEtC,QAAO,IAAI,IADQ,qBACQ,OAAO,KAAK,IAAI;;;;ACO7C,IAAM,IAAW,EAAgC,EAAiB,EAErD,IAA0B,EAAS,yBACnC,IAA2B,EAAS"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zarrextra",
3
- "version": "0.2.2",
3
+ "version": "0.2.3",
4
4
  "description": "Extra utilities for working with zarr stores using zarrita",
5
5
  "type": "module",
6
6
  "module": "./dist/index.js",