Skip to content

Commit 6c60067

Browse files
Merge pull request #1 from BioImageTools/amt
feat: convert to library
2 parents 0c328a9 + 79b421d commit 6c60067

14 files changed

Lines changed: 1782 additions & 162 deletions

‎.npmignore‎

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Source files (only ship compiled dist/)
2+
src/
3+
tsconfig.json
4+
tsconfig.lib.json
5+
vite.config.ts
6+
7+
# Development files
8+
.git/
9+
.github/
10+
node_modules/
11+
docs/
12+
public/
13+
14+
# Web app specific (PoC only)
15+
index.html
16+
src/style.css
17+
src/app.ts
18+
19+
# Build artifacts from web app
20+
*.map

‎README.md‎

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,78 @@ Current OME-NGFF (i.e. OME-Zarr) tools tend to support different aspects of the
88

99
Each tool could optionally publish a "capability manifest" which describes the tool's implementd capabilities with regards to the current and former NGFF Specifications. This manifest could simply live in the tool's Github repo, to be updated whenever relevant changes are made to the code. This manifest can then be interpreted computationally by any platform that wants to launch OME-NGFF tools (OMERO, BFF, Fileglancer, etc.)
1010

11+
## Library Usage
12+
13+
This package can be used as a library to determine which OME-Zarr viewers are compatible with a given dataset.
14+
15+
### Installation
16+
17+
```bash
18+
npm install @bioimagetools/capability-manifest
19+
```
20+
21+
### Usage
22+
23+
```typescript
24+
import {
25+
initialize,
26+
getCompatibleViewers,
27+
type OmeZarrMetadata
28+
} from '@bioimagetools/capability-manifest';
29+
30+
// Initialize once at application startup
31+
await initialize();
32+
33+
// For each dataset, pass pre-parsed metadata
34+
const metadata: OmeZarrMetadata = {
35+
version: '0.4',
36+
axes: [
37+
{ name: 'z', type: 'space' },
38+
{ name: 'y', type: 'space' },
39+
{ name: 'x', type: 'space' }
40+
],
41+
// ... other metadata
42+
};
43+
44+
// Get list of compatible viewer names
45+
const viewers = getCompatibleViewers(metadata);
46+
// Returns: ['Avivator', 'Neuroglancer']
47+
```
48+
49+
### API
50+
51+
#### `initialize(): Promise<void>`
52+
53+
Loads all viewer capability manifests. Must be called once at application startup before using other functions.
54+
55+
Throws an error if no manifests can be loaded.
56+
57+
#### `getCompatibleViewers(metadata: OmeZarrMetadata): string[]`
58+
59+
Returns array of viewer names that are compatible with the given dataset metadata.
60+
61+
- **Parameters:**
62+
- `metadata`: Pre-parsed OME-Zarr metadata object (use ome-zarr.js or similar to parse from Zarr stores)
63+
64+
- **Returns:** Array of viewer names (e.g., `['Avivator', 'Neuroglancer']`)
65+
66+
- **Throws:** Error if library not initialized
67+
68+
#### `getCompatibleViewersWithDetails(metadata: OmeZarrMetadata): Array<{name: string, validation: ValidationResult}>`
69+
70+
Returns detailed compatibility information including validation errors and warnings for each compatible viewer.
71+
72+
Useful for debugging or displaying why certain viewers work/don't work.
73+
74+
### Types
75+
76+
The library exports TypeScript types for all data structures:
77+
78+
- `OmeZarrMetadata` - Structure of OME-Zarr metadata
79+
- `ViewerManifest` - Structure of viewer capability manifests
80+
- `ValidationResult` - Validation outcome with errors/warnings
81+
- `ValidationError`, `ValidationWarning` - Detailed validation messages
82+
1183
## Manifest Specification (DRAFT)
1284

1385
| Attribute | Description |

‎index.html‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ <h1>OME-NGFF Tool Capabilities</h1>
2626
</div>
2727
</div>
2828

29-
<script type="module" src="/src/main.ts"></script>
29+
<script type="module" src="/src/app.ts"></script>
3030
</body>
3131
</html>

0 commit comments

Comments
 (0)