Skip to content

Commit 9e65138

Browse files
refactor: return viewer manifest info during initialization for consuming app to use
1 parent 6c60067 commit 9e65138

3 files changed

Lines changed: 13 additions & 8 deletions

File tree

‎README.md‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,14 @@ npm install @bioimagetools/capability-manifest
2222

2323
```typescript
2424
import {
25-
initialize,
25+
initializeViewerManifests,
2626
getCompatibleViewers,
27-
type OmeZarrMetadata
27+
type OmeZarrMetadata,
28+
type ViewerManifest
2829
} from '@bioimagetools/capability-manifest';
2930

30-
// Initialize once at application startup
31-
await initialize();
31+
// Initialize once at application startup - returns all viewer manifests
32+
const manifests = await initializeViewerManifests();
3233

3334
// For each dataset, pass pre-parsed metadata
3435
const metadata: OmeZarrMetadata = {
@@ -48,11 +49,12 @@ const viewers = getCompatibleViewers(metadata);
4849

4950
### API
5051

51-
#### `initialize(): Promise<void>`
52+
#### `initializeViewerManifests(): Promise<ViewerManifest[]>`
5253

5354
Loads all viewer capability manifests. Must be called once at application startup before using other functions.
5455

55-
Throws an error if no manifests can be loaded.
56+
- **Returns:** Array of all loaded viewer manifests, each containing viewer info (name, version, template_url) and capabilities
57+
- **Throws:** Error if no manifests can be loaded
5658

5759
#### `getCompatibleViewers(metadata: OmeZarrMetadata): string[]`
5860

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@bioimagetools/capability-manifest",
3-
"version": "0.1.0",
3+
"version": "0.2.0",
44
"description": "Library to determine OME-Zarr viewer compatibility based on capability manifests",
55
"type": "module",
66
"main": "./dist/index.js",

‎src/index.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,16 +24,19 @@ let cachedManifests: ViewerManifest[] | null = null;
2424
* Initialize the library by loading all viewer manifests.
2525
* Must be called once at application startup before using getCompatibleViewers.
2626
*
27+
* @returns Array of all loaded viewer manifests
2728
* @throws Error if manifest loading fails completely
2829
*/
29-
export async function initializeViewerManifests(): Promise<void> {
30+
export async function initializeViewerManifests(): Promise<ViewerManifest[]> {
3031
cachedManifests = await loadViewerManifests();
3132

3233
if (cachedManifests.length === 0) {
3334
throw new Error(
3435
'[capability-manifest] Failed to load any viewer manifests. Check network and manifest URLs.'
3536
);
3637
}
38+
39+
return cachedManifests;
3740
}
3841

3942
/**

0 commit comments

Comments
 (0)