@nypl/web-reader 4.3.3 → 4.3.5

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
@@ -423,14 +423,14 @@ declare type HTMLActiveReader = CommonReader & {
423
423
  };
424
424
  declare type ActiveReader = PDFActiveReader | HTMLActiveReader;
425
425
  declare type ReaderReturn = InactiveReader | LoadingReader | ActiveReader;
426
- declare type GetContent = (href: string) => Promise<string>;
426
+ declare type GetContent<T extends string | Uint8Array> = (href: string, proxyUrl?: string) => Promise<T>;
427
427
  declare type ReaderManagerArguments = {
428
428
  headerLeft?: JSX.Element;
429
429
  };
430
- declare type UseWebReaderArguments = {
430
+ declare type UseWebReaderArguments<T extends string | Uint8Array> = {
431
431
  webpubManifestUrl: string;
432
432
  proxyUrl?: string;
433
- getContent?: GetContent;
433
+ getContent?: GetContent<T>;
434
434
  pdfWorkerSrc?: string;
435
435
  injectablesReflowable?: Injectable[];
436
436
  injectablesFixed?: Injectable[];
@@ -470,20 +470,23 @@ declare type UseWebReaderArguments = {
470
470
  */
471
471
  persistSettings?: boolean;
472
472
  };
473
- declare type ActiveReaderArguments = UseWebReaderArguments & {
473
+ declare type ActiveReaderArguments<T extends string | Uint8Array> = UseWebReaderArguments<T> & {
474
474
  manifest: WebpubManifest;
475
475
  };
476
476
  declare type InactiveReaderArguments = undefined;
477
- declare type ReaderArguments = ActiveReaderArguments | InactiveReaderArguments;
478
477
 
479
478
  /**
480
479
  * The React hook that exposes the main API into the reader. It
481
480
  * will determine the type of the webpub, and then use the correct reader
482
481
  * for that type.
483
482
  */
484
- declare function useWebReader(args: UseWebReaderArguments): HTMLActiveReader | PDFActiveReader | LoadingReader;
483
+ declare function useWebReader(args: UseWebReaderArguments<string | Uint8Array>): HTMLActiveReader | PDFActiveReader | LoadingReader;
485
484
 
486
- declare function useHtmlReader(args: ReaderArguments): ReaderReturn;
485
+ declare type HtmlReaderArguments = ActiveReaderArguments<string> | InactiveReaderArguments;
486
+
487
+ declare function useHtmlReader(args: HtmlReaderArguments): ReaderReturn;
488
+
489
+ declare type PdfReaderArguments = ActiveReaderArguments<Uint8Array> | InactiveReaderArguments;
487
490
 
488
491
  /**
489
492
  * The PDF reader
@@ -494,7 +497,7 @@ declare function useHtmlReader(args: ReaderArguments): ReaderReturn;
494
497
  * @param args T
495
498
  * @returns
496
499
  */
497
- declare function usePdfReader(args: ReaderArguments): ReaderReturn;
500
+ declare function usePdfReader(args: PdfReaderArguments): ReaderReturn;
498
501
 
499
502
  declare type Dict<T = any> = Record<string, T>;
500
503
 
@@ -526,8 +529,8 @@ declare function addTocToManifest(manifest: WebpubManifest, getResource: (url: s
526
529
  /**
527
530
  * The main React component export.
528
531
  */
529
- declare type WebReaderProps = UseWebReaderArguments & ReaderManagerArguments;
532
+ declare type WebReaderProps = UseWebReaderArguments<string | Uint8Array> & ReaderManagerArguments;
530
533
  declare const WebReaderWithoutBoundary: FC<WebReaderProps>;
531
534
  declare const WebReader: FC<WebReaderProps>;
532
535
 
533
- export { CHROME_HEIGHT, DEFAULT_HEIGHT, DEFAULT_SETTINGS, DEFAULT_SHOULD_GROW_WHEN_SCROLLING, FONT_DETAILS, FOOTER_HEIGHT, HEADER_HEIGHT, IS_DEV, LOCAL_STORAGE_LOCATIONS_KEY, LOCAL_STORAGE_SETTINGS_KEY, MAIN_CONTENT_ID, ReadiumWebpubContext, WebReaderProps, WebReaderWithoutBoundary, addTocToManifest, clearWebReaderLocalStorage, WebReader as default, getTheme, useColorModeValue, useHtmlReader, usePdfReader, useWebReader };
536
+ export { CHROME_HEIGHT, DEFAULT_HEIGHT, DEFAULT_SETTINGS, DEFAULT_SHOULD_GROW_WHEN_SCROLLING, FONT_DETAILS, FOOTER_HEIGHT, HEADER_HEIGHT, IS_DEV, LOCAL_STORAGE_LOCATIONS_KEY, LOCAL_STORAGE_SETTINGS_KEY, MAIN_CONTENT_ID, ReadiumLink, ReadiumWebpubContext, WebReaderProps, WebReaderWithoutBoundary, WebpubManifest, addTocToManifest, clearWebReaderLocalStorage, WebReader as default, getTheme, useColorModeValue, useHtmlReader, usePdfReader, useWebReader };