react-iiif-vault 0.9.4 → 0.9.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/dist/index.d.ts CHANGED
@@ -1,81 +1,23 @@
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, FC } 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, 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 { ImageCandidate, ImageServiceLoader, ImageCandidateRequest } from '@atlas-viewer/iiif-image-api';
3
9
  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
- import { QueryOptions } from 'react-query';
7
10
  import * as _iiif_vault_helpers from '@iiif/vault-helpers';
8
11
 
9
- declare const AnnotationContext: React.FC<{
10
- annotation: string;
11
- }>;
12
-
13
- declare const CanvasContext: React.FC<{
14
- canvas: string;
15
- }>;
16
-
17
- declare const CollectionContext: React.FC<{
18
- collection: string;
19
- }>;
20
-
21
- declare const ManifestContext: React.FC<{
22
- manifest: string;
23
- }>;
24
-
25
- declare const RangeContext: React.FC<{
26
- range: string;
27
- }>;
28
-
29
- declare type ResourceContextType = {
30
- collection?: string;
31
- manifest?: string;
32
- range?: string;
33
- canvas?: string;
34
- annotation?: string;
35
- };
36
- declare const ResourceReactContext: React.Context<ResourceContextType>;
37
- declare const useResourceContext: () => ResourceContextType;
38
- declare const ResourceProvider: React.FC<{
39
- value: ResourceContextType;
40
- }>;
41
-
42
- declare const ReactVaultContext: React.Context<{
43
- vault: Vault | null;
44
- setVaultInstance: (vault: Vault) => void;
45
- }>;
46
- declare const VaultProvider: React.FC<{
47
- vault?: Vault;
48
- useGlobal?: boolean;
49
- vaultOptions?: VaultOptions;
50
- resources?: ResourceContextType;
51
- }>;
52
-
53
- declare function useContextBridge(): {
54
- VaultContext: {
55
- vault: _iiif_vault__.Vault | null;
56
- setVaultInstance: (vault: _iiif_vault__.Vault) => void;
57
- };
58
- ResourceContext: ResourceContextType;
59
- SimpleViewerReactContext: {
60
- setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
61
- setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
62
- currentCanvasIndex: number;
63
- pagingView: boolean;
64
- totalCanvases: number;
65
- nextCanvas: () => void;
66
- previousCanvas: () => void;
67
- };
68
- VisibleCanvasReactContext: string[];
69
- };
70
- declare const ContextBridge: React.FC<{
71
- bridge: ReturnType<typeof useContextBridge>;
72
- }>;
73
-
74
- declare const VisibleCanvasReactContext: React.Context<string[]>;
75
- declare function useVisibleCanvases(): CanvasNormalized[];
76
-
77
- declare const ImageServiceLoaderContext: React.Context<ImageServiceLoader>;
78
- declare function useImageServiceLoader(): ImageServiceLoader;
12
+ declare function Viewer({ children, ...props }: AtlasProps & {
13
+ height?: number | string;
14
+ width?: number | string;
15
+ resizeHash?: number;
16
+ containerProps?: any;
17
+ aspectRatio?: number;
18
+ } & {
19
+ children: ReactNode;
20
+ }): JSX.Element;
79
21
 
80
22
  interface SingleChoice {
81
23
  type: 'single-choice';
@@ -187,6 +129,39 @@ declare type AnnotationPageDescription = {
187
129
  pages: AnnotationPageNormalized[];
188
130
  };
189
131
 
132
+ declare type ImageServiceLoaderType = (imageService: any | undefined, { height, width }: {
133
+ height: number;
134
+ width: number;
135
+ }) => ImageService | undefined;
136
+ declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, string>];
137
+
138
+ declare function parseSpecificResource(resource: ContentResource): any[];
139
+ interface Paintables {
140
+ choice: ChoiceDescription | null;
141
+ types: string[];
142
+ items: Array<{
143
+ type: string;
144
+ resource: IIIFExternalWebResource | SpecificResource;
145
+ target: any;
146
+ selector: any;
147
+ }>;
148
+ }
149
+ declare function getPaintables(vault: Vault, paintingAnnotations: AnnotationNormalized[], enabledChoices: string[]): Paintables;
150
+ declare const emptyActions: {
151
+ makeChoice: () => void;
152
+ };
153
+ declare const unknownResponse: UseRenderingStrategy[0];
154
+ declare const unsupportedStrategy: (reason: string) => UseRenderingStrategy[0];
155
+
156
+ declare type SingleImageStrategy = {
157
+ type: 'images';
158
+ image: ImageWithOptionalService;
159
+ images: Array<ImageWithOptionalService>;
160
+ choice?: ChoiceDescription;
161
+ annotations?: AnnotationPageDescription;
162
+ };
163
+ declare function getImageStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType): RenderingStrategy;
164
+
190
165
  declare type MediaStrategy = {
191
166
  type: 'media';
192
167
  media: SingleAudio | SingleVideo | AudioSequence | VideoSequence;
@@ -206,12 +181,6 @@ declare type UnknownStrategy = {
206
181
  };
207
182
  declare type RenderingStrategy = SingleImageStrategy | MediaStrategy | ComplexTimelineStrategy | UnknownStrategy;
208
183
 
209
- declare type ImageServiceLoaderType = (imageService: any | undefined, { height, width }: {
210
- height: number;
211
- width: number;
212
- }) => ImageService | undefined;
213
- declare function useLoadImageService(): readonly [ImageServiceLoaderType, Record<string, string>];
214
-
215
184
  declare type StrategyActions = {
216
185
  makeChoice: (id: string, options?: {
217
186
  deselectOthers?: boolean;
@@ -226,32 +195,116 @@ declare type UseRenderingStrategyOptions = {
226
195
  };
227
196
  declare function useRenderingStrategy(options?: UseRenderingStrategyOptions): UseRenderingStrategy;
228
197
 
229
- declare function parseSpecificResource(resource: ContentResource): any[];
230
- interface Paintables {
231
- choice: ChoiceDescription | null;
232
- types: string[];
233
- items: Array<{
234
- type: string;
235
- resource: IIIFExternalWebResource | SpecificResource;
236
- target: any;
237
- selector: any;
198
+ declare type CanvasProps = {
199
+ x?: number;
200
+ y?: number;
201
+ onCreated?: any;
202
+ onChoiceChange?: (choice?: ChoiceDescription) => void;
203
+ registerActions?: (actions: StrategyActions) => void;
204
+ defaultChoices?: Array<{
205
+ id: string;
206
+ opacity?: number;
238
207
  }>;
239
- }
240
- declare function getPaintables(vault: Vault, paintingAnnotations: AnnotationNormalized[], enabledChoices: string[]): Paintables;
241
- declare const emptyActions: {
242
- makeChoice: () => void;
208
+ isStatic?: boolean;
243
209
  };
244
- declare const unknownResponse: UseRenderingStrategy[0];
245
- declare const unsupportedStrategy: (reason: string) => UseRenderingStrategy[0];
210
+ declare function RenderCanvas({ x, y, onChoiceChange, registerActions, defaultChoices, isStatic }: CanvasProps): JSX.Element | null;
246
211
 
247
- declare type SingleImageStrategy = {
248
- type: 'images';
212
+ declare function RenderImage({ id, image, thumbnail, isStatic, x, y, annotations, }: {
213
+ id: string;
249
214
  image: ImageWithOptionalService;
250
- images: Array<ImageWithOptionalService>;
251
- choice?: ChoiceDescription;
252
- annotations?: AnnotationPageDescription;
215
+ thumbnail?: ImageCandidate;
216
+ isStatic?: boolean;
217
+ x?: number;
218
+ y?: number;
219
+ annotations?: JSX.Element;
220
+ }): JSX.Element;
221
+
222
+ declare const CanvasPanel: {
223
+ RenderImage: typeof RenderImage;
224
+ RenderCanvas: typeof RenderCanvas;
225
+ RenderAnnotationPage: React.FC<{
226
+ page: _iiif_presentation_3.AnnotationPageNormalized | _iiif_presentation_3.AnnotationPage;
227
+ className?: string | undefined;
228
+ }>;
229
+ RenderAnnotation: React.FC<{
230
+ id: string;
231
+ className?: string | undefined;
232
+ style?: _atlas_viewer_atlas.BoxStyle | undefined;
233
+ interactive?: boolean | undefined;
234
+ }>;
235
+ Viewer: typeof Viewer;
253
236
  };
254
- declare function getImageStrategy(canvas: CanvasNormalized, paintables: Paintables, loadImageService: ImageServiceLoaderType): RenderingStrategy;
237
+
238
+ declare const AnnotationContext: React__default.FC<{
239
+ annotation: string;
240
+ }>;
241
+
242
+ declare const CanvasContext: React__default.FC<{
243
+ canvas: string;
244
+ }>;
245
+
246
+ declare const CollectionContext: React__default.FC<{
247
+ collection: string;
248
+ }>;
249
+
250
+ declare const ManifestContext: React__default.FC<{
251
+ manifest: string;
252
+ }>;
253
+
254
+ declare const RangeContext: React__default.FC<{
255
+ range: string;
256
+ }>;
257
+
258
+ declare type ResourceContextType = {
259
+ collection?: string;
260
+ manifest?: string;
261
+ range?: string;
262
+ canvas?: string;
263
+ annotation?: string;
264
+ };
265
+ declare const ResourceReactContext: React__default.Context<ResourceContextType>;
266
+ declare const useResourceContext: () => ResourceContextType;
267
+ declare const ResourceProvider: React__default.FC<{
268
+ value: ResourceContextType;
269
+ }>;
270
+
271
+ declare const ReactVaultContext: React__default.Context<{
272
+ vault: Vault | null;
273
+ setVaultInstance: (vault: Vault) => void;
274
+ }>;
275
+ declare const VaultProvider: React__default.FC<{
276
+ vault?: Vault;
277
+ useGlobal?: boolean;
278
+ vaultOptions?: VaultOptions;
279
+ resources?: ResourceContextType;
280
+ }>;
281
+
282
+ declare function useContextBridge(): {
283
+ VaultContext: {
284
+ vault: _iiif_vault__.Vault | null;
285
+ setVaultInstance: (vault: _iiif_vault__.Vault) => void;
286
+ };
287
+ ResourceContext: ResourceContextType;
288
+ SimpleViewerReactContext: {
289
+ setCurrentCanvasId: (newId: string | ((prev: string) => string)) => void;
290
+ setCurrentCanvasIndex: (newId: number | ((prev: number) => number)) => void;
291
+ currentCanvasIndex: number;
292
+ pagingView: boolean;
293
+ totalCanvases: number;
294
+ nextCanvas: () => void;
295
+ previousCanvas: () => void;
296
+ };
297
+ VisibleCanvasReactContext: string[];
298
+ };
299
+ declare const ContextBridge: React__default.FC<{
300
+ bridge: ReturnType<typeof useContextBridge>;
301
+ }>;
302
+
303
+ declare const VisibleCanvasReactContext: React__default.Context<string[]>;
304
+ declare function useVisibleCanvases(): CanvasNormalized[];
305
+
306
+ declare const ImageServiceLoaderContext: React__default.Context<ImageServiceLoader>;
307
+ declare function useImageServiceLoader(): ImageServiceLoader;
255
308
 
256
309
  declare function useAnnotation(options?: {
257
310
  id: string;
@@ -301,23 +354,54 @@ declare function useEventListener<T>(resource: Reference, name: SupportedEvents,
301
354
 
302
355
  declare function useExistingVault(): any;
303
356
 
304
- declare const useExternalCollection: (id: string, config?: QueryOptions<CollectionNormalized>) => {
357
+ declare type ResourceRequestOptions = {
358
+ noCache?: boolean;
359
+ };
360
+ declare function useExternalResource<T extends {
361
+ id: string;
362
+ }>(idOrRef: string | {
363
+ id: string;
364
+ type: string;
365
+ }, { noCache }?: ResourceRequestOptions): {
305
366
  id: string;
367
+ requestId: string;
306
368
  isLoaded: boolean;
307
- collection?: CollectionNormalized | undefined;
369
+ error: any;
370
+ cached: boolean;
371
+ resource?: T;
308
372
  };
309
373
 
310
- declare const useExternalManifest: (id: string, config?: QueryOptions<ManifestNormalized>) => {
374
+ declare function useExternalCollection(idOrRef: string | {
311
375
  id: string;
376
+ type: string;
377
+ }, options?: ResourceRequestOptions): {
378
+ id: string;
379
+ requestId: string;
380
+ isLoaded: boolean;
381
+ cached?: boolean;
382
+ error: any;
383
+ manifest?: CollectionNormalized;
384
+ };
385
+
386
+ declare function useExternalManifest(idOrRef: string | {
387
+ id: string;
388
+ type: string;
389
+ }, options?: ResourceRequestOptions): {
390
+ id: string;
391
+ requestId: string;
312
392
  isLoaded: boolean;
393
+ cached?: boolean;
313
394
  error: any;
314
- manifest?: ManifestNormalized | undefined;
395
+ manifest?: ManifestNormalized;
315
396
  };
316
397
 
317
- declare function useImageService(): {
398
+ interface ImageServiceRequestOptions {
399
+ cacheKey?: string;
400
+ }
401
+ declare function useImageService({ cacheKey }?: ImageServiceRequestOptions): {
318
402
  data: ImageService | undefined;
319
403
  isFetching: boolean;
320
- status: 'error' | 'success' | 'loading';
404
+ status: 'error' | 'success' | 'loading' | 'idle';
321
405
  };
322
406
 
323
407
  declare function useImageTile(): {
@@ -394,6 +478,14 @@ declare function useVirtualAnnotationPage(): readonly [AnnotationPageNormalized
394
478
  readonly removeAnnotation: (id: string | Annotation | VaultActivatedAnnotation | AnnotationNormalized) => void;
395
479
  }];
396
480
 
481
+ declare function useVirtualAnnotationPageContext(): readonly [AnnotationPageNormalized | null, {
482
+ readonly addAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation, atIndex?: number | undefined) => void;
483
+ readonly removeAnnotation: (id: string | AnnotationNormalized | VaultActivatedAnnotation | Annotation) => void;
484
+ }];
485
+ declare function VirtualAnnotationProvider({ children }: {
486
+ children: any;
487
+ }): JSX.Element;
488
+
397
489
  declare type SupportedTarget = {
398
490
  type: 'SpecificResource';
399
491
  source: ExternalWebResource | {
@@ -434,11 +526,11 @@ declare type SimpleViewerContext = {
434
526
  nextCanvas: () => void;
435
527
  previousCanvas: () => void;
436
528
  };
437
- declare const SimpleViewerReactContext: React.Context<SimpleViewerContext>;
529
+ declare const SimpleViewerReactContext: React__default.Context<SimpleViewerContext>;
438
530
  declare const SimpleViewerProvider: FC<{
439
531
  manifest: string;
440
532
  pagingEnabled?: boolean;
441
533
  }>;
442
534
  declare function useSimpleViewer(): SimpleViewerContext;
443
535
 
444
- export { AnnotationContext, AnnotationPageDescription, AudioSequence, BoxSelector, CanvasContext, ChoiceDescription, CollectionContext, ComplexChoice, ComplexTimelineStrategy, ContextBridge, ImageServiceLoaderContext, ImageServiceLoaderType, ImageWithOptionalService, ManifestContext, MediaStrategy, Paintables, ParsedSelector, PointSelector, RangeContext, ReactVaultContext, RenderingStrategy, ResourceContextType, ResourceProvider, ResourceReactContext, 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, useImageService, useImageServiceLoader, useImageTile, useLoadImageService, useManifest, usePaintables, usePaintingAnnotations, useRange, useRenderingStrategy, useResourceContext, useResourceEvents, useResources, useSearchService, useSimpleViewer, useStyleHelper, useStyles, useThumbnail, useVault, useVaultEffect, useVaultSelector, useVirtualAnnotationPage, useVisibleCanvases };
536
+ export { AnnotationContext, AnnotationPageDescription, AudioSequence, BoxSelector, CanvasContext, CanvasPanel, 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, VirtualAnnotationProvider, 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, useVirtualAnnotationPageContext, useVisibleCanvases };