react-iiif-vault 0.9.6 → 0.9.9

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/dist/index.d.ts CHANGED
@@ -1,80 +1,26 @@
1
- import React, { FC } from 'react';
1
+ import * as _atlas_viewer_atlas from '@atlas-viewer/atlas';
2
+ import * as React from 'react';
3
+ import React__default, { ReactNode, RefObject } from 'react';
4
+ import * as _iiif_presentation_3 from '@iiif/presentation-3';
5
+ import { InternationalString, ImageService, AnnotationPageNormalized, ContentResource, IIIFExternalWebResource, SpecificResource, AnnotationNormalized, CanvasNormalized, CollectionNormalized, Reference, ManifestNormalized, RangeNormalized, SearchService, Annotation, ExternalWebResource as ExternalWebResource$1, W3CAnnotationTarget, Selector } from '@iiif/presentation-3';
6
+ import { AtlasProps } from '@atlas-viewer/atlas/dist/types/modules/react-reconciler/Atlas';
2
7
  import { Vault, VaultOptions, ReduxStore, NormalizedEntity, IIIFStore } from '@iiif/vault';
8
+ import { ExternalWebResource } from '@iiif/presentation-3/resources/annotation';
9
+ import { ImageCandidate, ImageServiceLoader, ImageCandidateRequest } from '@atlas-viewer/iiif-image-api';
3
10
  import * as _iiif_vault__ from '@iiif/vault/*';
4
- import { CanvasNormalized, InternationalString, ImageService, AnnotationPageNormalized, ContentResource, IIIFExternalWebResource, SpecificResource, AnnotationNormalized, CollectionNormalized, Reference, ManifestNormalized, RangeNormalized, SearchService, Annotation, ExternalWebResource, W3CAnnotationTarget, Selector } from '@iiif/presentation-3';
5
- import { ImageServiceLoader, ImageCandidateRequest, ImageCandidate } from '@atlas-viewer/iiif-image-api';
6
11
  import * as _iiif_vault_helpers from '@iiif/vault-helpers';
7
12
 
8
- declare const AnnotationContext: React.FC<{
9
- annotation: string;
10
- }>;
11
-
12
- declare const CanvasContext: React.FC<{
13
- canvas: string;
14
- }>;
15
-
16
- declare const CollectionContext: React.FC<{
17
- collection: string;
18
- }>;
19
-
20
- declare const ManifestContext: React.FC<{
21
- manifest: string;
22
- }>;
23
-
24
- declare const RangeContext: React.FC<{
25
- range: string;
26
- }>;
27
-
28
- declare type ResourceContextType = {
29
- collection?: string;
30
- manifest?: string;
31
- range?: string;
32
- canvas?: string;
33
- annotation?: string;
34
- };
35
- declare const ResourceReactContext: React.Context<ResourceContextType>;
36
- declare const useResourceContext: () => ResourceContextType;
37
- declare const ResourceProvider: React.FC<{
38
- value: ResourceContextType;
39
- }>;
40
-
41
- declare const ReactVaultContext: React.Context<{
42
- vault: Vault | null;
43
- setVaultInstance: (vault: Vault) => void;
44
- }>;
45
- declare const VaultProvider: React.FC<{
46
- vault?: Vault;
47
- useGlobal?: boolean;
48
- vaultOptions?: VaultOptions;
49
- resources?: ResourceContextType;
50
- }>;
51
-
52
- declare function useContextBridge(): {
53
- VaultContext: {
54
- vault: _iiif_vault__.Vault | null;
55
- setVaultInstance: (vault: _iiif_vault__.Vault) => void;
56
- };
57
- ResourceContext: ResourceContextType;
58
- SimpleViewerReactContext: {
59
- setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
60
- setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
61
- currentCanvasIndex: number;
62
- pagingView: boolean;
63
- totalCanvases: number;
64
- nextCanvas: () => void;
65
- previousCanvas: () => void;
66
- };
67
- VisibleCanvasReactContext: string[];
68
- };
69
- declare const ContextBridge: React.FC<{
70
- bridge: ReturnType<typeof useContextBridge>;
71
- }>;
72
-
73
- declare const VisibleCanvasReactContext: React.Context<string[]>;
74
- declare function useVisibleCanvases(): CanvasNormalized[];
75
-
76
- declare const ImageServiceLoaderContext: React.Context<ImageServiceLoader>;
77
- declare function useImageServiceLoader(): ImageServiceLoader;
13
+ declare function Viewer({ children, errorFallback, outerContainerProps, ...props }: AtlasProps & {
14
+ height?: number | string;
15
+ width?: number | string;
16
+ resizeHash?: number;
17
+ containerProps?: any;
18
+ outerContainerProps?: any;
19
+ aspectRatio?: number;
20
+ errorFallback?: any;
21
+ } & {
22
+ children: ReactNode;
23
+ }): JSX.Element;
78
24
 
79
25
  interface SingleChoice {
80
26
  type: 'single-choice';
@@ -171,8 +117,8 @@ declare type SingleVideo = {
171
117
  url: string;
172
118
  format: string;
173
119
  duration: number;
174
- target: TemporalBoxSelector;
175
- selector: TemporalBoxSelector;
120
+ target: TemporalSelector | TemporalBoxSelector;
121
+ selector: TemporalSelector | TemporalBoxSelector;
176
122
  };
177
123
  declare type AudioSequence = {
178
124
  type: 'SoundSequence';
@@ -186,6 +132,46 @@ declare type AnnotationPageDescription = {
186
132
  pages: AnnotationPageNormalized[];
187
133
  };
188
134
 
135
+ declare type ImageServiceLoaderType = (imageService: any | undefined, { height, width }: {
136
+ height: number;
137
+ width: number;
138
+ }) => ImageService | undefined;
139
+ declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, string>];
140
+
141
+ declare function parseSpecificResource(resource: ContentResource): any[];
142
+ interface Paintables {
143
+ choice: ChoiceDescription | null;
144
+ types: string[];
145
+ items: Array<{
146
+ type: string;
147
+ resource: IIIFExternalWebResource | SpecificResource;
148
+ target: any;
149
+ selector: any;
150
+ }>;
151
+ }
152
+ declare function getPaintables(vault: Vault, paintingAnnotations: AnnotationNormalized[], enabledChoices: string[]): Paintables;
153
+ declare const emptyActions: {
154
+ makeChoice: () => void;
155
+ };
156
+ declare const unknownResponse: UseRenderingStrategy[0];
157
+ declare const unsupportedStrategy: (reason: string) => UseRenderingStrategy[0];
158
+
159
+ declare type SingleImageStrategy = {
160
+ type: 'images';
161
+ image: ImageWithOptionalService;
162
+ images: Array<ImageWithOptionalService>;
163
+ choice?: ChoiceDescription;
164
+ annotations?: AnnotationPageDescription;
165
+ };
166
+ declare function getImageStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType): RenderingStrategy;
167
+
168
+ declare type Single3DModelStrategy = {
169
+ type: '3d-model';
170
+ model: ExternalWebResource;
171
+ choice?: ChoiceDescription;
172
+ annotations?: AnnotationPageDescription;
173
+ };
174
+
189
175
  declare type MediaStrategy = {
190
176
  type: 'media';
191
177
  media: SingleAudio | SingleVideo | AudioSequence | VideoSequence;
@@ -203,13 +189,7 @@ declare type UnknownStrategy = {
203
189
  reason?: string;
204
190
  annotations?: AnnotationPageDescription;
205
191
  };
206
- declare type RenderingStrategy = SingleImageStrategy | MediaStrategy | ComplexTimelineStrategy | UnknownStrategy;
207
-
208
- declare type ImageServiceLoaderType = (imageService: any | undefined, { height, width }: {
209
- height: number;
210
- width: number;
211
- }) => ImageService | undefined;
212
- declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, string>];
192
+ declare type RenderingStrategy = SingleImageStrategy | MediaStrategy | ComplexTimelineStrategy | Single3DModelStrategy | UnknownStrategy;
213
193
 
214
194
  declare type StrategyActions = {
215
195
  makeChoice: (id: string, options?: {
@@ -225,32 +205,184 @@ declare type UseRenderingStrategyOptions = {
225
205
  };
226
206
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
227
207
 
228
- declare function parseSpecificResource(resource: ContentResource): any[];
229
- interface Paintables {
230
- choice: ChoiceDescription | null;
231
- types: string[];
232
- items: Array<{
233
- type: string;
234
- resource: IIIFExternalWebResource | SpecificResource;
235
- target: any;
236
- selector: any;
208
+ declare type CanvasProps = {
209
+ x?: number;
210
+ y?: number;
211
+ onCreated?: any;
212
+ onChoiceChange?: (choice?: ChoiceDescription) => void;
213
+ registerActions?: (actions: StrategyActions) => void;
214
+ defaultChoices?: Array<{
215
+ id: string;
216
+ opacity?: number;
237
217
  }>;
238
- }
239
- declare function getPaintables(vault: Vault, paintingAnnotations: AnnotationNormalized[], enabledChoices: string[]): Paintables;
240
- declare const emptyActions: {
241
- makeChoice: () => void;
218
+ isStatic?: boolean;
219
+ children?: ReactNode;
220
+ renderViewerControls?: (strategy: SingleImageStrategy) => ReactNode;
221
+ renderMediaControls?: (strategy: MediaStrategy) => ReactNode;
222
+ strategies?: Array<RenderingStrategy['type']>;
242
223
  };
243
- declare const unknownResponse: UseRenderingStrategy[0];
244
- declare const unsupportedStrategy: (reason: string) => UseRenderingStrategy[0];
224
+ declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic, renderViewerControls, renderMediaControls, strategies, children, }: CanvasProps): JSX.Element | null;
245
225
 
246
- declare type SingleImageStrategy = {
247
- type: 'images';
226
+ declare function RenderImage({ id, image, thumbnail, isStatic, x, y, annotations, children, }: {
227
+ id: string;
248
228
  image: ImageWithOptionalService;
249
- images: Array<ImageWithOptionalService>;
250
- choice?: ChoiceDescription;
251
- annotations?: AnnotationPageDescription;
229
+ thumbnail?: ImageCandidate;
230
+ isStatic?: boolean;
231
+ x?: number;
232
+ y?: number;
233
+ annotations?: ReactNode;
234
+ children?: ReactNode;
235
+ }): JSX.Element;
236
+
237
+ declare const CanvasPanel: {
238
+ RenderImage: typeof RenderImage;
239
+ RenderCanvas: typeof RenderCanvas;
240
+ RenderAnnotationPage: React.FC<{
241
+ page: _iiif_presentation_3.AnnotationPageNormalized | _iiif_presentation_3.AnnotationPage;
242
+ className?: string | undefined;
243
+ }>;
244
+ RenderAnnotation: React.FC<{
245
+ id: string;
246
+ className?: string | undefined;
247
+ style?: _atlas_viewer_atlas.BoxStyle | undefined;
248
+ interactive?: boolean | undefined;
249
+ }>;
250
+ Viewer: typeof Viewer;
252
251
  };
253
- declare function getImageStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType): RenderingStrategy;
252
+
253
+ declare function AnnotationContext({ annotation, children }: {
254
+ annotation: string;
255
+ children: ReactNode;
256
+ }): JSX.Element;
257
+
258
+ declare function CanvasContext({ canvas, children }: {
259
+ canvas: string;
260
+ children: ReactNode;
261
+ }): JSX.Element;
262
+
263
+ declare function CollectionContext({ collection, children }: {
264
+ collection: string;
265
+ children: ReactNode;
266
+ }): JSX.Element;
267
+
268
+ declare function ManifestContext({ manifest, children }: {
269
+ manifest: string;
270
+ children: ReactNode;
271
+ }): JSX.Element;
272
+
273
+ declare type MediaPlayerState = {
274
+ isPlaying: boolean;
275
+ isMuted: boolean;
276
+ playRequested: boolean;
277
+ volume: number;
278
+ isFinished: boolean;
279
+ duration: number;
280
+ };
281
+ declare type MediaPlayerActions = {
282
+ play(): void;
283
+ pause(): void;
284
+ playPause(): void;
285
+ mute(): void;
286
+ unmute(): void;
287
+ toggleMute(): void;
288
+ setVolume(volume: number): void;
289
+ setDurationPercent(percent: number): void;
290
+ setTime(time: number): void;
291
+ };
292
+ declare function formatTime(time: number): string;
293
+ declare function useSimpleMediaPlayer(props: {
294
+ duration: number;
295
+ }): readonly [
296
+ {
297
+ element: RefObject<HTMLAudioElement | HTMLVideoElement>;
298
+ currentTime: RefObject<HTMLDivElement>;
299
+ progress: RefObject<HTMLDivElement>;
300
+ },
301
+ MediaPlayerState,
302
+ MediaPlayerActions
303
+ ];
304
+
305
+ declare function useMediaState(): MediaPlayerState;
306
+ declare function useMediaActions(): MediaPlayerActions;
307
+ declare function useMediaElements(): {
308
+ element: RefObject<HTMLAudioElement | HTMLVideoElement>;
309
+ currentTime: RefObject<HTMLDivElement>;
310
+ progress: RefObject<HTMLDivElement>;
311
+ };
312
+ declare function MediaPlayerProvider({ actions, state, children, currentTime, progress, element, }: {
313
+ actions: MediaPlayerActions;
314
+ state: MediaPlayerState;
315
+ children: ReactNode;
316
+ currentTime: RefObject<HTMLDivElement>;
317
+ progress: RefObject<HTMLDivElement>;
318
+ element: RefObject<HTMLAudioElement | HTMLVideoElement>;
319
+ }): JSX.Element;
320
+
321
+ declare const PortalContext: React__default.Context<HTMLDivElement | null>;
322
+ declare const OverlayPortalContext: React__default.Context<HTMLDivElement | null>;
323
+ declare function CanvasPortal({ children, overlay }: {
324
+ children: ReactNode;
325
+ overlay?: boolean;
326
+ }): null;
327
+
328
+ declare function RangeContext({ range, children }: {
329
+ range: string;
330
+ children: ReactNode;
331
+ }): JSX.Element;
332
+
333
+ declare type ResourceContextType = {
334
+ collection?: string;
335
+ manifest?: string;
336
+ range?: string;
337
+ canvas?: string;
338
+ annotation?: string;
339
+ };
340
+ declare const ResourceReactContext: React__default.Context<ResourceContextType>;
341
+ declare const useResourceContext: () => ResourceContextType;
342
+ declare function ResourceProvider({ value, children }: {
343
+ value: ResourceContextType;
344
+ children: ReactNode;
345
+ }): JSX.Element;
346
+
347
+ declare const ReactVaultContext: React__default.Context<{
348
+ vault: Vault | null;
349
+ setVaultInstance: (vault: Vault) => void;
350
+ }>;
351
+ declare function VaultProvider({ vault, vaultOptions, useGlobal, resources, children, }: {
352
+ vault?: Vault;
353
+ useGlobal?: boolean;
354
+ vaultOptions?: VaultOptions;
355
+ resources?: ResourceContextType;
356
+ children: ReactNode;
357
+ }): JSX.Element;
358
+
359
+ declare function useContextBridge(): {
360
+ VaultContext: {
361
+ vault: _iiif_vault__.Vault | null;
362
+ setVaultInstance: (vault: _iiif_vault__.Vault) => void;
363
+ };
364
+ ResourceContext: ResourceContextType;
365
+ SimpleViewerReactContext: {
366
+ setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
367
+ setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
368
+ currentCanvasIndex: number;
369
+ pagingView: boolean;
370
+ totalCanvases: number;
371
+ nextCanvas: () => void;
372
+ previousCanvas: () => void;
373
+ };
374
+ VisibleCanvasReactContext: string[];
375
+ };
376
+ declare function ContextBridge(props: {
377
+ bridge: ReturnType<typeof useContextBridge>;
378
+ children: ReactNode;
379
+ }): JSX.Element;
380
+
381
+ declare const VisibleCanvasReactContext: React__default.Context<string[]>;
382
+ declare function useVisibleCanvases(): CanvasNormalized[];
383
+
384
+ declare const ImageServiceLoaderContext: React__default.Context<ImageServiceLoader>;
385
+ declare function useImageServiceLoader(): ImageServiceLoader;
254
386
 
255
387
  declare function useAnnotation(options?: {
256
388
  id: string;
@@ -424,9 +556,17 @@ declare function useVirtualAnnotationPage(): readonly [AnnotationPageNormalized
424
556
  readonly removeAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => void;
425
557
  }];
426
558
 
559
+ declare function useVirtualAnnotationPageContext(): readonly [AnnotationPageNormalized | null, {
560
+ readonly addAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation, atIndex?: number | undefined) => void;
561
+ readonly removeAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation) => void;
562
+ }];
563
+ declare function VirtualAnnotationProvider({ children }: {
564
+ children: any;
565
+ }): JSX.Element;
566
+
427
567
  declare type SupportedTarget = {
428
568
  type: 'SpecificResource';
429
- source: ExternalWebResource | {
569
+ source: ExternalWebResource$1 | {
430
570
  id: string;
431
571
  type: 'Unknown' | 'Canvas' | 'Range' | 'Manifest';
432
572
  partOf?: Array<{
@@ -464,11 +604,12 @@ declare type SimpleViewerContext = {
464
604
  nextCanvas: () => void;
465
605
  previousCanvas: () => void;
466
606
  };
467
- declare const SimpleViewerReactContext: React.Context<SimpleViewerContext>;
468
- declare const SimpleViewerProvider: FC<{
607
+ declare const SimpleViewerReactContext: React__default.Context<SimpleViewerContext>;
608
+ declare function SimpleViewerProvider(props: {
469
609
  manifest: string;
470
610
  pagingEnabled?: boolean;
471
- }>;
611
+ children: ReactNode;
612
+ }): JSX.Element;
472
613
  declare function useSimpleViewer(): SimpleViewerContext;
473
614
 
474
- export { AnnotationContext, AnnotationPageDescription, AudioSequence, BoxSelector, CanvasContext, ChoiceDescription, CollectionContext, ComplexChoice, ComplexTimelineStrategy, ContextBridge, ImageServiceLoaderContext, ImageServiceLoaderType, ImageServiceRequestOptions, ImageWithOptionalService, ManifestContext, MediaStrategy, Paintables, ParsedSelector, PointSelector, RangeContext, ReactVaultContext, RenderingStrategy, ResourceContextType, ResourceProvider, ResourceReactContext, ResourceRequestOptions, SimpleViewerProvider, SimpleViewerReactContext, SingleAudio, SingleChoice, SingleImageStrategy, SingleVideo, StrategyActions, SupportedSelector, SupportedSelectors, SupportedTarget, TemporalBoxSelector, TemporalSelector, UnknownStrategy, UseRenderingStrategy, UseRenderingStrategyOptions, VaultActivatedAnnotation, VaultProvider, VideoSequence, VisibleCanvasReactContext, emptyActions, expandTarget, flattenAnnotationPageIds, getImageStrategy, getPaintables, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useVirtualAnnotationPage, useVisibleCanvases };
615
+ export { AnnotationContext, AnnotationPageDescription, AudioSequence, BoxSelector, CanvasContext, CanvasPanel, CanvasPortal, ChoiceDescription, CollectionContext, ComplexChoice, ComplexTimelineStrategy, ContextBridge, ImageServiceLoaderContext, ImageServiceLoaderType, ImageServiceRequestOptions, ImageWithOptionalService, ManifestContext, MediaPlayerActions, MediaPlayerProvider, MediaPlayerState, MediaStrategy, OverlayPortalContext, Paintables, ParsedSelector, PointSelector, PortalContext, RangeContext, ReactVaultContext, RenderingStrategy, ResourceContextType, ResourceProvider, ResourceReactContext, ResourceRequestOptions, SimpleViewerProvider, SimpleViewerReactContext, SingleAudio, SingleChoice, SingleImageStrategy, SingleVideo, StrategyActions, SupportedSelector, SupportedSelectors, SupportedTarget, TemporalBoxSelector, TemporalSelector, UnknownStrategy, UseRenderingStrategy, UseRenderingStrategyOptions, VaultActivatedAnnotation, VaultProvider, VideoSequence, VirtualAnnotationProvider, VisibleCanvasReactContext, emptyActions, expandTarget, flattenAnnotationPageIds, formatTime, getImageStrategy, getPaintables, parseSelector, parseSpecificResource, unknownResponse, unsupportedStrategy, useAnnotation, useAnnotationPageManager, useAnnotationsAtTime, useCanvas, useCanvasClock, useCollection, useContextBridge, useDispatch, useEventListener, useExistingVault, useExternalCollection, useExternalManifest, useExternalResource, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, useMediaActions, useMediaElements, useMediaState, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleMediaPlayer, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useVirtualAnnotationPage, useVirtualAnnotationPageContext, useVisibleCanvases };