react-native-simple-epub-reader 0.1.2 → 0.1.4

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.
Files changed (36) hide show
  1. package/lib/module/components/GestureHandler/index.js +8 -2
  2. package/lib/module/components/GestureHandler/index.js.map +1 -1
  3. package/lib/module/components/Reader.js +125 -22
  4. package/lib/module/components/Reader.js.map +1 -1
  5. package/lib/module/constants/template.js +189 -226
  6. package/lib/module/constants/template.js.map +1 -1
  7. package/lib/module/constants/theme.js +28 -11
  8. package/lib/module/constants/theme.js.map +1 -1
  9. package/lib/module/helpers/downloadEpub.js +5 -1
  10. package/lib/module/helpers/downloadEpub.js.map +1 -1
  11. package/lib/module/helpers/saveTemplateToFile.js +4 -0
  12. package/lib/module/helpers/saveTemplateToFile.js.map +1 -1
  13. package/lib/module/hooks/useInjectWebviewVariables.js +4 -2
  14. package/lib/module/hooks/useInjectWebviewVariables.js.map +1 -1
  15. package/lib/typescript/src/components/GestureHandler/index.d.ts.map +1 -1
  16. package/lib/typescript/src/components/Reader.d.ts +1 -1
  17. package/lib/typescript/src/components/Reader.d.ts.map +1 -1
  18. package/lib/typescript/src/constants/template.d.ts +1 -1
  19. package/lib/typescript/src/constants/template.d.ts.map +1 -1
  20. package/lib/typescript/src/constants/theme.d.ts.map +1 -1
  21. package/lib/typescript/src/helpers/downloadEpub.d.ts.map +1 -1
  22. package/lib/typescript/src/helpers/saveTemplateToFile.d.ts +1 -0
  23. package/lib/typescript/src/helpers/saveTemplateToFile.d.ts.map +1 -1
  24. package/lib/typescript/src/hooks/useInjectWebviewVariables.d.ts +2 -1
  25. package/lib/typescript/src/hooks/useInjectWebviewVariables.d.ts.map +1 -1
  26. package/lib/typescript/src/types/index.d.ts +4 -0
  27. package/lib/typescript/src/types/index.d.ts.map +1 -1
  28. package/package.json +1 -1
  29. package/src/components/GestureHandler/index.tsx +8 -0
  30. package/src/components/Reader.tsx +161 -27
  31. package/src/constants/template.ts +189 -226
  32. package/src/constants/theme.ts +28 -11
  33. package/src/helpers/downloadEpub.ts +7 -1
  34. package/src/helpers/saveTemplateToFile.ts +5 -0
  35. package/src/hooks/useInjectWebviewVariables.ts +9 -0
  36. package/src/types/index.ts +4 -0
@@ -18,3 +18,8 @@ export const checkTemplateFileExists = (fileName: string) => {
18
18
  const htmlFile = new File(Paths.document, fileName);
19
19
  return htmlFile.exists;
20
20
  };
21
+
22
+ export const getTemplateFileUri = (fileName: string) => {
23
+ const htmlFile = new File(Paths.document, fileName);
24
+ return htmlFile.uri;
25
+ };
@@ -12,6 +12,7 @@ export function useInjectWebViewVariables() {
12
12
  book,
13
13
  allowScriptedContent,
14
14
  theme,
15
+ locations,
15
16
  }: {
16
17
  jszip: string;
17
18
  epubjs: string;
@@ -19,7 +20,11 @@ export function useInjectWebViewVariables() {
19
20
  book: string;
20
21
  allowScriptedContent?: boolean;
21
22
  theme: Theme;
23
+ locations?: string[];
22
24
  }) => {
25
+ const initialLocations =
26
+ locations && locations.length > 0 ? JSON.stringify(locations) : 'null';
27
+
23
28
  return template
24
29
  .replace(
25
30
  /<script id="jszip"><\/script>/,
@@ -43,6 +48,10 @@ export function useInjectWebViewVariables() {
43
48
  .replace(
44
49
  /const theme = window.theme;/,
45
50
  `const theme = ${JSON.stringify(theme)};`
51
+ )
52
+ .replace(
53
+ /const initialLocations = window.locations;/,
54
+ `const initialLocations = ${initialLocations};`
46
55
  );
47
56
  },
48
57
  []
@@ -67,13 +67,17 @@ export interface GestureHandlerProps {
67
67
  onSwipeLeft?: () => void;
68
68
  onSwipeRight?: () => void;
69
69
  onTap?: () => void;
70
+ onPinchStart?: () => void;
70
71
  onPinch?: (e: GestureUpdateEvent<PinchGestureHandlerEventPayload>) => void;
72
+ onPinchEnd?: () => void;
71
73
  onWebViewMessage?: (event: any) => void;
72
74
  }
73
75
 
74
76
  export type ReaderProps = {
75
77
  src: string;
76
78
  initialLocation?: string;
79
+ beginAt?: number;
80
+ waitForLocationsReady?: boolean;
77
81
  onLocationChange?: (data: LocationChangeData) => void;
78
82
  onLocationsReady?: (epubKey: string, locations: ePubCfi[]) => void;
79
83
  onFinish?: () => void;