@knaw-huc/osd-iiif-viewer 0.1.5 → 0.1.7

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.
package/README.md CHANGED
@@ -1,14 +1,15 @@
1
1
  # @knaw-huc/osd-iiif-viewer
2
2
 
3
- React wrapper around OpenSeadragon to display and browse image sources from iiif manifests.
3
+ Lightweight React wrapper around OpenSeadragon to display and browse image sources from IIIF manifests.
4
4
 
5
- Current features (WIP):
5
+ Features:
6
6
  - Canvas navigation
7
7
  - Highlight overlay
8
8
  - Zoom and fullscreen controls
9
- - Manifest parsing (iiif manifests v3, ImageService2)
9
+ - IIIF manifest loading
10
+
11
+ ## Example
10
12
 
11
- ## Minimal example
12
13
  ```tsx
13
14
  import {useEffect} from 'react';
14
15
  import {
@@ -20,27 +21,28 @@ import {
20
21
 
21
22
  export function Example() {
22
23
  return <ViewerProvider>
23
- <View/>
24
+ <MyOsdIiifView/>
24
25
  </ViewerProvider>
25
26
  }
26
27
 
27
- function View() {
28
+ function MyOsdIiifView() {
28
29
  const loadManifest = useLoadManifest();
29
- const manifest = useManifest();
30
+ const {isReady} = useManifest();
30
31
 
31
32
  useEffect(() => {
32
33
  loadManifest('/manifest.json');
33
34
  }, [loadManifest]);
34
35
 
35
- if (!manifest.data) {
36
+ if (!isReady) {
36
37
  return null;
37
38
  }
38
39
 
39
40
  return (
40
41
  <div style={{width: '100%', height: '100vh'}}>
41
- <Viewerer/>
42
+ <Viewer/>
42
43
  </div>
43
44
  );
44
45
  }
45
46
  ```
46
47
 
48
+ For more examples, run `npm i && npm start` and open http://localhost:5173
@@ -1,11 +1,14 @@
1
1
  import { StateCreator } from 'zustand/vanilla';
2
2
  import { ViewerStore } from './ViewerStore.ts';
3
- export type ControlSlice = {
3
+ import { Resettable } from './Resettable.ts';
4
+ export type ControlState = {
4
5
  zoomLevel: number | null;
5
6
  zoomMin: number | null;
6
7
  zoomMax: number | null;
7
8
  isFullPage: boolean;
8
9
  rotation: number;
10
+ };
11
+ export type ControlSlice = Resettable & ControlState & {
9
12
  setZoomLevel: (zoomLevel: number | null) => void;
10
13
  setZoomMin: (zoomMin: number | null) => void;
11
14
  setZoomMax: (zoomMax: number | null) => void;
@@ -1,9 +1,12 @@
1
1
  import { StateCreator } from 'zustand/vanilla';
2
2
  import { default as OpenSeadragon } from 'openseadragon';
3
3
  import { ViewerStore } from './ViewerStore.ts';
4
- export type InstanceSlice = {
4
+ import { Resettable } from './Resettable.ts';
5
+ export type InstanceState = {
5
6
  viewer: OpenSeadragon.Viewer | null;
6
7
  viewerReady: boolean;
8
+ };
9
+ export type InstanceSlice = Resettable & InstanceState & {
7
10
  setViewer: (viewer: OpenSeadragon.Viewer | null) => void;
8
11
  setViewerReady: (viewerReady: boolean) => void;
9
12
  };
@@ -0,0 +1,3 @@
1
+ export type Resettable = {
2
+ reset: () => void;
3
+ };
@@ -2,5 +2,6 @@ import { InstanceSlice } from './InstanceSlice.ts';
2
2
  import { ControlSlice } from './ControlSlice.ts';
3
3
  import { ManifestSlice } from './manifest/ManifestSlice.ts';
4
4
  import { CanvasSlice } from './manifest/CanvasSlice.ts';
5
- export type ViewerStore = InstanceSlice & ControlSlice & ManifestSlice & CanvasSlice;
5
+ import { Resettable } from './Resettable.ts';
6
+ export type ViewerStore = InstanceSlice & ControlSlice & ManifestSlice & CanvasSlice & Resettable;
6
7
  export declare const createViewerStore: () => import('zustand').StoreApi<ViewerStore>;
package/dist/index.d.ts CHANGED
@@ -8,4 +8,7 @@ export { useViewerReady } from './useViewerReady';
8
8
  export { useViewerStore } from './useViewerStore';
9
9
  export { useManifest, useLoadManifest } from './manifest/useManifest';
10
10
  export { useCanvas } from './manifest/useCanvas';
11
- export type { ViewerManifest, ViewerCanvas, ViewerRange, ViewerMetadata } from './manifest/model';
11
+ export { useVault } from './manifest/useVault';
12
+ export { findTileSource } from './manifest/findTileSource';
13
+ export { findThumbnail } from './manifest/findThumbnail';
14
+ export { getImageServiceId } from './manifest/getImageServiceId';