react-native-readium 1.0.4 → 1.2.0

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 (42) hide show
  1. package/README.md +12 -2
  2. package/lib/commonjs/components/ReadiumView.js.map +1 -1
  3. package/lib/commonjs/index.web.js +54 -0
  4. package/lib/commonjs/index.web.js.map +1 -0
  5. package/lib/commonjs/web/ReadiumView.js +106 -0
  6. package/lib/commonjs/web/ReadiumView.js.map +1 -0
  7. package/lib/commonjs/web/hooks/index.js +45 -0
  8. package/lib/commonjs/web/hooks/index.js.map +1 -0
  9. package/lib/commonjs/web/hooks/useLocationObserver.js +21 -0
  10. package/lib/commonjs/web/hooks/useLocationObserver.js.map +1 -0
  11. package/lib/commonjs/web/hooks/useReaderRef.js +63 -0
  12. package/lib/commonjs/web/hooks/useReaderRef.js.map +1 -0
  13. package/lib/commonjs/web/hooks/useSettingsObserver.js +21 -0
  14. package/lib/commonjs/web/hooks/useSettingsObserver.js.map +1 -0
  15. package/lib/module/components/ReadiumView.js.map +1 -1
  16. package/lib/module/index.web.js +5 -0
  17. package/lib/module/index.web.js.map +1 -0
  18. package/lib/module/web/ReadiumView.js +89 -0
  19. package/lib/module/web/ReadiumView.js.map +1 -0
  20. package/lib/module/web/hooks/index.js +4 -0
  21. package/lib/module/web/hooks/index.js.map +1 -0
  22. package/lib/module/web/hooks/useLocationObserver.js +11 -0
  23. package/lib/module/web/hooks/useLocationObserver.js.map +1 -0
  24. package/lib/module/web/hooks/useReaderRef.js +50 -0
  25. package/lib/module/web/hooks/useReaderRef.js.map +1 -0
  26. package/lib/module/web/hooks/useSettingsObserver.js +11 -0
  27. package/lib/module/web/hooks/useSettingsObserver.js.map +1 -0
  28. package/lib/typescript/components/ReadiumView.d.ts +1 -2
  29. package/lib/typescript/index.web.d.ts +4 -0
  30. package/lib/typescript/web/ReadiumView.d.ts +5 -0
  31. package/lib/typescript/web/hooks/index.d.ts +3 -0
  32. package/lib/typescript/web/hooks/useLocationObserver.d.ts +3 -0
  33. package/lib/typescript/web/hooks/useReaderRef.d.ts +4 -0
  34. package/lib/typescript/web/hooks/useSettingsObserver.d.ts +3 -0
  35. package/package.json +9 -6
  36. package/src/components/ReadiumView.tsx +2 -2
  37. package/src/index.web.tsx +5 -0
  38. package/src/web/ReadiumView.tsx +97 -0
  39. package/src/web/hooks/index.ts +3 -0
  40. package/src/web/hooks/useLocationObserver.ts +21 -0
  41. package/src/web/hooks/useReaderRef.ts +57 -0
  42. package/src/web/hooks/useSettingsObserver.ts +21 -0
package/README.md CHANGED
@@ -154,15 +154,25 @@ DRM is not supported at this time. However, there is a clear path to [support it
154
154
  | Name | Type | Optional | Description |
155
155
  |------|------|----------|-------------|
156
156
  | `file` | [`File`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/File.ts) | :x: | A file object containing the path to the eBook file on disk. |
157
- | `location` | [`Locator`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Locator.ts) | [`Link`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Link.ts) | :white_check_mark: | A locator prop that allows you to externally control the location of the reader (e.g. Chapters or Bookmarks)|
157
+ | `location` | [`Locator`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Locator.ts) \| [`Link`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Link.ts) | :white_check_mark: | A locator prop that allows you to externally control the location of the reader (e.g. Chapters or Bookmarks). <br/><br/>:warning: If you want to set the `location` of an ebook on initial load, you should use the `File.initialLocation` property (look at the `file` prop). See more [here](https://github.com/5-stones/react-native-readium/issues/16#issuecomment-1344128937) |
158
158
  | `settings` | [`Partial<Settings>`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Settings.ts) | :white_check_mark: | An object that allows you to control various aspects of the reader's UI (epub only) |
159
159
  | `style` | `ViewStyle` | :white_check_mark: | A traditional style object. |
160
160
  | `onLocationChange` | `(locator: Locator) => void` | :white_check_mark: | A callback that fires whenever the location is changed (e.g. the user transitions to a new page)|
161
161
  | `onTableOfContents` | `(toc: Link[] \| null) => void` | :white_check_mark: | A callback that fires once the file is parsed and emits the table of contents embedded in the file. Returns `null` or an empty `[]` if no TOC exists. See the [`Link`](https://github.com/5-stones/react-native-readium/blob/main/src/interfaces/Link.ts) interface for more info. |
162
162
 
163
+ #### :warning: Web vs Native File URLs
164
+
165
+ Please note that on `web` the `File.url` should be a web accessible URL path to
166
+ the `manifest.json` of the unpacked epub. In native contexts it needs to be a
167
+ local filepath to the epub file itself on disk. If you're not sure how to
168
+ serve epub books [take a look at this example](https://github.com/d-i-t-a/R2D2BC/blob/production/examples/server.ts)
169
+ which is based on the `dita-streamer-js` project (which is built on all the
170
+ readium [r2-*-js](https://github.com/readium?q=js) libraries)
171
+
163
172
  ## Contributing
164
173
 
165
- See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the repository and the development workflow.
174
+ See the [contributing guide](CONTRIBUTING.md) to learn how to contribute to the
175
+ repository and the development workflow.
166
176
 
167
177
  ## Release
168
178
 
@@ -1 +1 @@
1
- {"version":3,"sources":["ReadiumView.tsx"],"names":["ReadiumView","onLocationChange","wrappedOnLocationChange","onTableOfContents","wrappedOnTableOfContents","settings","unmappedSettings","props","ref","height","width","setDimensions","onLayout","nativeEvent","layout","event","toc","Platform","OS","viewId","current","styles","container","Settings","map","undefined","StyleSheet","create"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AACA;;AAEA;;;;;;;;AAIO,MAAMA,WAAmC,GAAG,QAK7C;AAAA,MAL8C;AAClDC,IAAAA,gBAAgB,EAAEC,uBADgC;AAElDC,IAAAA,iBAAiB,EAAEC,wBAF+B;AAGlDC,IAAAA,QAAQ,EAAEC,gBAHwC;AAIlD,OAAGC;AAJ+C,GAK9C;AACJ,QAAMC,GAAG,GAAG,mBAAO,IAAP,CAAZ;AACA,QAAM,CAAC;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAD,EAAoBC,aAApB,IAAqC,qBAAqB;AAC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,IAAA,gBAAgB,EAAEN,gBAJpB;AAKE,IAAA,iBAAiB,EAAEE,iBALrB;AAME,IAAA,QAAQ,EAAEG,gBAAgB,GAAGiB,qBAASC,GAAT,CAAalB,gBAAb,CAAH,GAAoCmB,SANhE;AAOE,IAAA,GAAG,EAAEjB;AAPP,KAJF,CADF;AAgBD,CAvDM;;;;AAyDP,MAAMa,MAAM,GAAGK,wBAAWC,MAAX,CAAkB;AAC/BL,EAAAA,SAAS,EAAE;AAAEZ,IAAAA,KAAK,EAAE,MAAT;AAAiBD,IAAAA,MAAM,EAAE;AAAzB;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useCallback, useState, useRef, useEffect } from 'react';\nimport { View, Platform, findNodeHandle, StyleSheet } from 'react-native';\n\nimport type { Dimensions } from '../interfaces';\nimport { Settings } from '../interfaces';\nimport { createFragment, getWidthOrHeightValue as dimension } from '../utils';\nimport type { BaseReadiumViewProps } from './BaseReadiumView';\nimport { BaseReadiumView } from './BaseReadiumView';\n\ntype ReadiumProps = BaseReadiumViewProps;\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n onTableOfContents: wrappedOnTableOfContents,\n settings: unmappedSettings,\n ...props\n}) => {\n const ref = useRef(null);\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n // set the view dimensions on layout\n const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}) => {\n setDimensions({\n width: dimension(width),\n height: dimension(height),\n });\n }, []);\n // wrap the native onLocationChange and extract the raw event value\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n const onTableOfContents = useCallback((event: any) => {\n if (wrappedOnTableOfContents) {\n const toc = event.nativeEvent.toc || null;\n wrappedOnTableOfContents(toc);\n }\n }, [wrappedOnTableOfContents]);\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }\n }, [])\n\n return (\n <View\n style={styles.container}\n onLayout={onLayout}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n onTableOfContents={onTableOfContents}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n ref={ref}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { width: '100%', height: '100%' },\n});\n"]}
1
+ {"version":3,"sources":["ReadiumView.tsx"],"names":["ReadiumView","onLocationChange","wrappedOnLocationChange","onTableOfContents","wrappedOnTableOfContents","settings","unmappedSettings","props","ref","height","width","setDimensions","onLayout","nativeEvent","layout","event","toc","Platform","OS","viewId","current","styles","container","Settings","map","undefined","StyleSheet","create"],"mappings":";;;;;;;AAAA;;AACA;;AAGA;;AACA;;AAEA;;;;;;;;AAIO,MAAMA,WAAmC,GAAG,QAK7C;AAAA,MAL8C;AAClDC,IAAAA,gBAAgB,EAAEC,uBADgC;AAElDC,IAAAA,iBAAiB,EAAEC,wBAF+B;AAGlDC,IAAAA,QAAQ,EAAEC,gBAHwC;AAIlD,OAAGC;AAJ+C,GAK9C;AACJ,QAAMC,GAAG,GAAG,mBAAO,IAAP,CAAZ;AACA,QAAM,CAAC;AAAEC,IAAAA,MAAF;AAAUC,IAAAA;AAAV,GAAD,EAAoBC,aAApB,IAAqC,qBAAqB;AAC9DD,IAAAA,KAAK,EAAE,CADuD;AAE9DD,IAAAA,MAAM,EAAE;AAFsD,GAArB,CAA3C,CAFI,CAMJ;;AACA,QAAMG,QAAQ,GAAG,wBAAY,SAAwD;AAAA,QAAvD;AAAEC,MAAAA,WAAW,EAAE;AAAEC,QAAAA,MAAM,EAAE;AAAEJ,UAAAA,KAAF;AAASD,UAAAA;AAAT;AAAV;AAAf,KAAuD;AACnFE,IAAAA,aAAa,CAAC;AACZD,MAAAA,KAAK,EAAE,kCAAUA,KAAV,CADK;AAEZD,MAAAA,MAAM,EAAE,kCAAUA,MAAV;AAFI,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CAAf","sourcesContent":["import React, { useCallback, useState, useRef, useEffect } from 'react';\nimport { View, Platform, findNodeHandle, StyleSheet } from 'react-native';\n\nimport type { Dimensions } from '../interfaces';\nimport { Settings } from '../interfaces';\nimport { createFragment, getWidthOrHeightValue as dimension } from '../utils';\nimport type { BaseReadiumViewProps } from './BaseReadiumView';\nimport { BaseReadiumView } from './BaseReadiumView';\n\nexport type ReadiumProps = BaseReadiumViewProps;\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n onTableOfContents: wrappedOnTableOfContents,\n settings: unmappedSettings,\n ...props\n}) => {\n const ref = useRef(null);\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n // set the view dimensions on layout\n const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}: any) => {\n setDimensions({\n width: dimension(width),\n height: dimension(height),\n });\n }, []);\n // wrap the native onLocationChange and extract the raw event value\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n const onTableOfContents = useCallback((event: any) => {\n if (wrappedOnTableOfContents) {\n const toc = event.nativeEvent.toc || null;\n wrappedOnTableOfContents(toc);\n }\n }, [wrappedOnTableOfContents]);\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }\n }, [])\n\n return (\n <View\n style={styles.container}\n onLayout={onLayout}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n onTableOfContents={onTableOfContents}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n ref={ref}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { width: '100%', height: '100%' },\n});\n"]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ var _exportNames = {
7
+ RANGES: true,
8
+ ReadiumView: true
9
+ };
10
+ Object.defineProperty(exports, "RANGES", {
11
+ enumerable: true,
12
+ get: function () {
13
+ return _utils.RANGES;
14
+ }
15
+ });
16
+ Object.defineProperty(exports, "ReadiumView", {
17
+ enumerable: true,
18
+ get: function () {
19
+ return _ReadiumView.ReadiumView;
20
+ }
21
+ });
22
+
23
+ var _enums = require("./enums");
24
+
25
+ Object.keys(_enums).forEach(function (key) {
26
+ if (key === "default" || key === "__esModule") return;
27
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
28
+ if (key in exports && exports[key] === _enums[key]) return;
29
+ Object.defineProperty(exports, key, {
30
+ enumerable: true,
31
+ get: function () {
32
+ return _enums[key];
33
+ }
34
+ });
35
+ });
36
+
37
+ var _interfaces = require("./interfaces");
38
+
39
+ Object.keys(_interfaces).forEach(function (key) {
40
+ if (key === "default" || key === "__esModule") return;
41
+ if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
42
+ if (key in exports && exports[key] === _interfaces[key]) return;
43
+ Object.defineProperty(exports, key, {
44
+ enumerable: true,
45
+ get: function () {
46
+ return _interfaces[key];
47
+ }
48
+ });
49
+ });
50
+
51
+ var _utils = require("./utils");
52
+
53
+ var _ReadiumView = require("./web/ReadiumView");
54
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.web.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAEA","sourcesContent":["export * from './enums';\nexport * from './interfaces';\nexport { RANGES } from './utils';\n\nexport { ReadiumView } from './web/ReadiumView';\n"]}
@@ -0,0 +1,106 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.ReadiumView = void 0;
7
+
8
+ var _react = _interopRequireWildcard(require("react"));
9
+
10
+ var _reactNative = require("react-native");
11
+
12
+ var _hooks = require("./hooks");
13
+
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
+
18
+ const ReadiumView = /*#__PURE__*/_react.default.forwardRef((_ref, ref) => {
19
+ let {
20
+ file,
21
+ settings,
22
+ location,
23
+ onLocationChange,
24
+ onTableOfContents,
25
+ style = {},
26
+ height,
27
+ width
28
+ } = _ref;
29
+ const readerRef = (0, _hooks.useReaderRef)({
30
+ file,
31
+ onLocationChange,
32
+ onTableOfContents
33
+ });
34
+ const reader = readerRef.current;
35
+ (0, _react.useImperativeHandle)(ref, () => ({
36
+ nextPage: () => {
37
+ var _readerRef$current;
38
+
39
+ (_readerRef$current = readerRef.current) === null || _readerRef$current === void 0 ? void 0 : _readerRef$current.nextPage();
40
+ },
41
+ prevPage: () => {
42
+ var _readerRef$current2;
43
+
44
+ (_readerRef$current2 = readerRef.current) === null || _readerRef$current2 === void 0 ? void 0 : _readerRef$current2.previousPage();
45
+ }
46
+ }));
47
+ (0, _hooks.useSettingsObserver)(reader, settings);
48
+ (0, _hooks.useLocationObserver)(reader, location);
49
+ const mainStyle = { ...styles.maximize,
50
+ ...style
51
+ };
52
+ if (height) mainStyle.height = height;
53
+ if (width) mainStyle.width = width;
54
+ return /*#__PURE__*/_react.default.createElement(_reactNative.View, {
55
+ style: styles.container
56
+ }, !reader && /*#__PURE__*/_react.default.createElement("div", {
57
+ style: styles.loader
58
+ }, "Loading reader..."), /*#__PURE__*/_react.default.createElement("div", {
59
+ id: "D2Reader-Container",
60
+ style: styles.d2Container
61
+ }, /*#__PURE__*/_react.default.createElement("main", {
62
+ style: mainStyle,
63
+ tabIndex: -1,
64
+ id: "iframe-wrapper"
65
+ }, /*#__PURE__*/_react.default.createElement("div", {
66
+ id: "reader-loading",
67
+ className: "loading",
68
+ style: styles.loader
69
+ }), /*#__PURE__*/_react.default.createElement("div", {
70
+ id: "reader-error",
71
+ className: "error"
72
+ }))));
73
+ });
74
+
75
+ exports.ReadiumView = ReadiumView;
76
+
77
+ const styles = _reactNative.StyleSheet.create({
78
+ container: {
79
+ width: '100%',
80
+ height: '100%'
81
+ },
82
+ d2Container: {
83
+ width: '100%',
84
+ height: '100%',
85
+ display: 'flex'
86
+ },
87
+ maximize: {
88
+ width: '100%',
89
+ height: '100%',
90
+ display: 'flex'
91
+ },
92
+ button: {
93
+ width: 50,
94
+ fontSize: 100,
95
+ backgroundColor: 'transparent',
96
+ border: 'none'
97
+ },
98
+ loader: {
99
+ width: '100%',
100
+ height: '100%',
101
+ textAlign: 'center',
102
+ position: 'relative',
103
+ top: 'calc(50% - 10px)'
104
+ }
105
+ });
106
+ //# sourceMappingURL=ReadiumView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ReadiumView.tsx"],"names":["ReadiumView","React","forwardRef","ref","file","settings","location","onLocationChange","onTableOfContents","style","height","width","readerRef","reader","current","nextPage","prevPage","previousPage","mainStyle","styles","maximize","container","loader","d2Container","StyleSheet","create","display","button","fontSize","backgroundColor","border","textAlign","position","top"],"mappings":";;;;;;;AAAA;;AAEA;;AAGA;;;;;;AAMO,MAAMA,WAAW,gBAAGC,eAAMC,UAAN,CAGV,OASdC,GATc,KASN;AAAA,MATO;AAChBC,IAAAA,IADgB;AAEhBC,IAAAA,QAFgB;AAGhBC,IAAAA,QAHgB;AAIhBC,IAAAA,gBAJgB;AAKhBC,IAAAA,iBALgB;AAMhBC,IAAAA,KAAK,GAAG,EANQ;AAOhBC,IAAAA,MAPgB;AAQhBC,IAAAA;AARgB,GASP;AACT,QAAMC,SAAS,GAAG,yBAAa;AAC7BR,IAAAA,IAD6B;AAE7BG,IAAAA,gBAF6B;AAG7BC,IAAAA;AAH6B,GAAb,CAAlB;AAKA,QAAMK,MAAM,GAAGD,SAAS,CAACE,OAAzB;AAEA,kCAAoBX,GAApB,EAAyB,OAAO;AAC9BY,IAAAA,QAAQ,EAAE,MAAM;AAAA;;AACd,4BAAAH,SAAS,CAACE,OAAV,0EAAmBC,QAAnB;AACD,KAH6B;AAI9BC,IAAAA,QAAQ,EAAE,MAAM;AAAA;;AACd,6BAAAJ,SAAS,CAACE,OAAV,4EAAmBG,YAAnB;AACD;AAN6B,GAAP,CAAzB;AASA,kCAAoBJ,MAApB,EAA4BR,QAA5B;AACA,kCAAoBQ,MAApB,EAA4BP,QAA5B;AAEA,QAAMY,SAAS,GAAG,EAChB,GAAGC,MAAM,CAACC,QADM;AAEhB,OAAIX;AAFY,GAAlB;AAKA,MAAIC,MAAJ,EAAYQ,SAAS,CAACR,MAAV,GAAmBA,MAAnB;AACZ,MAAIC,KAAJ,EAAWO,SAAS,CAACP,KAAV,GAAkBA,KAAlB;AAEX,sBACE,6BAAC,iBAAD;AAAM,IAAA,KAAK,EAAEQ,MAAM,CAACE;AAApB,KACG,CAACR,MAAD,iBAAW;AAAK,IAAA,KAAK,EAAEM,MAAM,CAACG;AAAnB,yBADd,eAEE;AAAK,IAAA,EAAE,EAAC,oBAAR;AAA6B,IAAA,KAAK,EAAEH,MAAM,CAACI;AAA3C,kBACE;AACE,IAAA,KAAK,EAAEL,SADT;AAEE,IAAA,QAAQ,EAAE,CAAC,CAFb;AAGE,IAAA,EAAE,EAAC;AAHL,kBAKE;AAAK,IAAA,EAAE,EAAC,gBAAR;AAAyB,IAAA,SAAS,EAAC,SAAnC;AAA6C,IAAA,KAAK,EAAEC,MAAM,CAACG;AAA3D,IALF,eAME;AAAK,IAAA,EAAE,EAAC,cAAR;AAAuB,IAAA,SAAS,EAAC;AAAjC,IANF,CADF,CAFF,CADF;AAeD,CAvD0B,CAApB;;;;AAyDP,MAAMH,MAAM,GAAGK,wBAAWC,MAAX,CAAkB;AAC/BJ,EAAAA,SAAS,EAAE;AACTV,IAAAA,KAAK,EAAE,MADE;AAETD,IAAAA,MAAM,EAAE;AAFC,GADoB;AAK/Ba,EAAAA,WAAW,EAAE;AACXZ,IAAAA,KAAK,EAAE,MADI;AAEXD,IAAAA,MAAM,EAAE,MAFG;AAGXgB,IAAAA,OAAO,EAAE;AAHE,GALkB;AAU/BN,EAAAA,QAAQ,EAAE;AACRT,IAAAA,KAAK,EAAE,MADC;AAERD,IAAAA,MAAM,EAAE,MAFA;AAGRgB,IAAAA,OAAO,EAAE;AAHD,GAVqB;AAe/BC,EAAAA,MAAM,EAAE;AACNhB,IAAAA,KAAK,EAAE,EADD;AAENiB,IAAAA,QAAQ,EAAE,GAFJ;AAGNC,IAAAA,eAAe,EAAE,aAHX;AAINC,IAAAA,MAAM,EAAE;AAJF,GAfuB;AAqB/BR,EAAAA,MAAM,EAAE;AACNX,IAAAA,KAAK,EAAE,MADD;AAEND,IAAAA,MAAM,EAAE,MAFF;AAGNqB,IAAAA,SAAS,EAAE,QAHL;AAINC,IAAAA,QAAQ,EAAE,UAJJ;AAKNC,IAAAA,GAAG,EAAE;AALC;AArBuB,CAAlB,CAAf","sourcesContent":["import React, { useImperativeHandle } from 'react';\nimport type { CSSProperties } from 'react';\nimport { View, StyleSheet } from 'react-native';\n\nimport type { ReadiumProps } from '../components/ReadiumView';\nimport {\n useReaderRef,\n useSettingsObserver,\n useLocationObserver,\n} from './hooks';\n\nexport const ReadiumView = React.forwardRef<{\n nextPage: () => void;\n prevPage: () => void;\n}, ReadiumProps>(({\n file,\n settings,\n location,\n onLocationChange,\n onTableOfContents,\n style = {},\n height,\n width,\n}, ref) => {\n const readerRef = useReaderRef({\n file,\n onLocationChange,\n onTableOfContents,\n });\n const reader = readerRef.current;\n\n useImperativeHandle(ref, () => ({\n nextPage: () => {\n readerRef.current?.nextPage();\n },\n prevPage: () => {\n readerRef.current?.previousPage();\n },\n }));\n\n useSettingsObserver(reader, settings);\n useLocationObserver(reader, location);\n\n const mainStyle = {\n ...styles.maximize,\n ...(style as CSSProperties),\n };\n\n if (height) mainStyle.height = height;\n if (width) mainStyle.width = width;\n\n return (\n <View style={styles.container}>\n {!reader && <div style={styles.loader}>Loading reader...</div>}\n <div id=\"D2Reader-Container\" style={styles.d2Container}>\n <main\n style={mainStyle}\n tabIndex={-1}\n id=\"iframe-wrapper\"\n >\n <div id=\"reader-loading\" className=\"loading\" style={styles.loader}></div>\n <div id=\"reader-error\" className=\"error\"></div>\n </main>\n </div>\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n height: '100%',\n },\n d2Container: {\n width: '100%',\n height: '100%',\n display: 'flex',\n },\n maximize: {\n width: '100%',\n height: '100%',\n display: 'flex',\n },\n button: {\n width: 50,\n fontSize: 100,\n backgroundColor: 'transparent',\n border: 'none',\n },\n loader: {\n width: '100%',\n height: '100%',\n textAlign: 'center',\n position: 'relative',\n top: 'calc(50% - 10px)',\n },\n});\n"]}
@@ -0,0 +1,45 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+
7
+ var _useReaderRef = require("./useReaderRef");
8
+
9
+ Object.keys(_useReaderRef).forEach(function (key) {
10
+ if (key === "default" || key === "__esModule") return;
11
+ if (key in exports && exports[key] === _useReaderRef[key]) return;
12
+ Object.defineProperty(exports, key, {
13
+ enumerable: true,
14
+ get: function () {
15
+ return _useReaderRef[key];
16
+ }
17
+ });
18
+ });
19
+
20
+ var _useSettingsObserver = require("./useSettingsObserver");
21
+
22
+ Object.keys(_useSettingsObserver).forEach(function (key) {
23
+ if (key === "default" || key === "__esModule") return;
24
+ if (key in exports && exports[key] === _useSettingsObserver[key]) return;
25
+ Object.defineProperty(exports, key, {
26
+ enumerable: true,
27
+ get: function () {
28
+ return _useSettingsObserver[key];
29
+ }
30
+ });
31
+ });
32
+
33
+ var _useLocationObserver = require("./useLocationObserver");
34
+
35
+ Object.keys(_useLocationObserver).forEach(function (key) {
36
+ if (key === "default" || key === "__esModule") return;
37
+ if (key in exports && exports[key] === _useLocationObserver[key]) return;
38
+ Object.defineProperty(exports, key, {
39
+ enumerable: true,
40
+ get: function () {
41
+ return _useLocationObserver[key];
42
+ }
43
+ });
44
+ });
45
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;AAAA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;AACA;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA","sourcesContent":["export * from './useReaderRef';\nexport * from './useSettingsObserver';\nexport * from './useLocationObserver';\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useLocationObserver = void 0;
7
+
8
+ var _useDeepCompare = require("use-deep-compare");
9
+
10
+ const useLocationObserver = (reader, location) => {
11
+ (0, _useDeepCompare.useDeepCompareEffect)(() => {
12
+ if (reader && location) {
13
+ // NOTE: technically this is a Link | Locator. However, under the hood the
14
+ // R2D2BC is converting Links to locators, so just force the type here.
15
+ reader.goTo(location);
16
+ }
17
+ }, [location, !!reader]);
18
+ };
19
+
20
+ exports.useLocationObserver = useLocationObserver;
21
+ //# sourceMappingURL=useLocationObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useLocationObserver.ts"],"names":["useLocationObserver","reader","location","goTo"],"mappings":";;;;;;;AAAA;;AAMO,MAAMA,mBAAmB,GAAG,CACjCC,MADiC,EAEjCC,QAFiC,KAG9B;AACH,4CAAqB,MAAM;AACzB,QAAID,MAAM,IAAIC,QAAd,EAAwB;AACtB;AACA;AACAD,MAAAA,MAAM,CAACE,IAAP,CAAYD,QAAZ;AACD;AACF,GAND,EAMG,CACDA,QADC,EAED,CAAC,CAACD,MAFD,CANH;AAUD,CAdM","sourcesContent":["import { useDeepCompareEffect } from 'use-deep-compare';\nimport type D2Reader from '@d-i-t-a/reader';\nimport type { Locator as R2Locator } from '@d-i-t-a/reader';\n\nimport type { Link, Locator } from '../../interfaces';\n\nexport const useLocationObserver = (\n reader?: D2Reader | null,\n location?: Link | Locator | null,\n) => {\n useDeepCompareEffect(() => {\n if (reader && location) {\n // NOTE: technically this is a Link | Locator. However, under the hood the\n // R2D2BC is converting Links to locators, so just force the type here.\n reader.goTo(location as R2Locator);\n }\n }, [\n location,\n !!reader,\n ]);\n};\n"]}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useReaderRef = void 0;
7
+
8
+ var _react = require("react");
9
+
10
+ var _reader = _interopRequireDefault(require("@d-i-t-a/reader"));
11
+
12
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
13
+
14
+ const useReaderRef = _ref => {
15
+ let {
16
+ file,
17
+ onLocationChange,
18
+ onTableOfContents
19
+ } = _ref;
20
+ const readerRef = (0, _react.useRef)(null);
21
+ (0, _react.useEffect)(() => {
22
+ _reader.default.load({
23
+ url: new URL(file.url),
24
+ lastReadingPosition: file.initialLocation,
25
+ userSettings: {
26
+ verticalScroll: false
27
+ },
28
+ api: {
29
+ updateCurrentLocation: async location => {
30
+ if (onLocationChange) onLocationChange(location);
31
+ return location;
32
+ }
33
+ },
34
+ injectables: injectables
35
+ }).then(r => {
36
+ if (onTableOfContents) {
37
+ onTableOfContents(r.tableOfContents);
38
+ }
39
+
40
+ readerRef.current = r;
41
+ });
42
+ }, []);
43
+ return readerRef;
44
+ }; // NOTE: right now we're serving these through statically.io, which is just
45
+ // pulling them from Github... Might not be the best way and maybe we should
46
+ // consider bundling them with the library.
47
+
48
+
49
+ exports.useReaderRef = useReaderRef;
50
+ const injectables = [{
51
+ type: "style",
52
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-before.css",
53
+ r2before: true
54
+ }, {
55
+ type: "style",
56
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-default.css",
57
+ r2default: true
58
+ }, {
59
+ type: "style",
60
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-after.css",
61
+ r2after: true
62
+ }];
63
+ //# sourceMappingURL=useReaderRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useReaderRef.ts"],"names":["useReaderRef","file","onLocationChange","onTableOfContents","readerRef","D2Reader","load","url","URL","lastReadingPosition","initialLocation","userSettings","verticalScroll","api","updateCurrentLocation","location","injectables","then","r","tableOfContents","current","type","r2before","r2default","r2after"],"mappings":";;;;;;;AAAA;;AACA;;;;AAKO,MAAMA,YAAY,GAAG,QAIkD;AAAA,MAJjD;AAC3BC,IAAAA,IAD2B;AAE3BC,IAAAA,gBAF2B;AAG3BC,IAAAA;AAH2B,GAIiD;AAC5E,QAAMC,SAAS,GAAG,mBAAwB,IAAxB,CAAlB;AAEA,wBAAU,MAAM;AACdC,oBAASC,IAAT,CAAc;AACZC,MAAAA,GAAG,EAAE,IAAIC,GAAJ,CAAQP,IAAI,CAACM,GAAb,CADO;AAEZE,MAAAA,mBAAmB,EAAER,IAAI,CAACS,eAFd;AAGZC,MAAAA,YAAY,EAAE;AAAEC,QAAAA,cAAc,EAAE;AAAlB,OAHF;AAIZC,MAAAA,GAAG,EAAE;AACHC,QAAAA,qBAAqB,EAAE,MAAOC,QAAP,IAA6B;AAClD,cAAIb,gBAAJ,EAAsBA,gBAAgB,CAACa,QAAD,CAAhB;AACtB,iBAAOA,QAAP;AACD;AAJE,OAJO;AAUZC,MAAAA,WAAW,EAAEA;AAVD,KAAd,EAWGC,IAXH,CAWSC,CAAD,IAAO;AACb,UAAIf,iBAAJ,EAAuB;AACrBA,QAAAA,iBAAiB,CAACe,CAAC,CAACC,eAAH,CAAjB;AACD;;AACDf,MAAAA,SAAS,CAACgB,OAAV,GAAoBF,CAApB;AACD,KAhBD;AAiBD,GAlBD,EAkBG,EAlBH;AAoBA,SAAOd,SAAP;AACD,CA5BM,C,CA8BP;AACA;AACA;;;;AACA,MAAMY,WAAkB,GAAG,CACzB;AACEK,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,iGAFP;AAGEe,EAAAA,QAAQ,EAAE;AAHZ,CADyB,EAMzB;AACED,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,kGAFP;AAGEgB,EAAAA,SAAS,EAAE;AAHb,CANyB,EAWzB;AACEF,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,gGAFP;AAGEiB,EAAAA,OAAO,EAAE;AAHX,CAXyB,CAA3B","sourcesContent":["import { useEffect, useRef } from 'react';\nimport D2Reader from '@d-i-t-a/reader';\n\nimport type { ReadiumProps } from '../../components/ReadiumView';\nimport type { Locator } from '../../interfaces';\n\nexport const useReaderRef = ({\n file,\n onLocationChange,\n onTableOfContents,\n}: Pick<ReadiumProps, 'file' | 'onLocationChange' | 'onTableOfContents' >) => {\n const readerRef = useRef<D2Reader | null>(null);\n\n useEffect(() => {\n D2Reader.load({\n url: new URL(file.url),\n lastReadingPosition: file.initialLocation,\n userSettings: { verticalScroll: false },\n api: {\n updateCurrentLocation: async (location: Locator) => {\n if (onLocationChange) onLocationChange(location);\n return location;\n },\n },\n injectables: injectables,\n }).then((r) => {\n if (onTableOfContents) {\n onTableOfContents(r.tableOfContents);\n }\n readerRef.current = r;\n });\n }, []);\n\n return readerRef\n};\n\n// NOTE: right now we're serving these through statically.io, which is just\n// pulling them from Github... Might not be the best way and maybe we should\n// consider bundling them with the library.\nconst injectables: any[] = [\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-before.css\",\n r2before: true,\n },\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-default.css\",\n r2default: true,\n },\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-after.css\",\n r2after: true,\n },\n];\n\n"]}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useSettingsObserver = void 0;
7
+
8
+ var _useDeepCompare = require("use-deep-compare");
9
+
10
+ const useSettingsObserver = (reader, settings) => {
11
+ (0, _useDeepCompare.useDeepCompareEffect)(() => {
12
+ if (reader && settings) {
13
+ // @ts-ignore - FIXME need to do some deeper investigation if these
14
+ // are equivalent or not
15
+ reader === null || reader === void 0 ? void 0 : reader.applyUserSettings(settings);
16
+ }
17
+ }, [settings, !!reader]);
18
+ };
19
+
20
+ exports.useSettingsObserver = useSettingsObserver;
21
+ //# sourceMappingURL=useSettingsObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSettingsObserver.ts"],"names":["useSettingsObserver","reader","settings","applyUserSettings"],"mappings":";;;;;;;AAAA;;AAMO,MAAMA,mBAAmB,GAAG,CACjCC,MADiC,EAEjCC,QAFiC,KAG9B;AACH,4CAAqB,MAAM;AACzB,QAAID,MAAM,IAAIC,QAAd,EAAwB;AACtB;AACA;AACAD,MAAAA,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,iBAAR,CAA0BD,QAA1B;AACD;AACF,GAND,EAMG,CACDA,QADC,EAED,CAAC,CAACD,MAFD,CANH;AAUD,CAdM","sourcesContent":["import { useDeepCompareEffect } from 'use-deep-compare';\nimport type D2Reader from '@d-i-t-a/reader';\nimport type { UserSettings } from '@d-i-t-a/reader/dist/types/model/user-settings/UserSettings';\n\nimport type { Settings } from '../../interfaces';\n\nexport const useSettingsObserver = (\n reader?: D2Reader | null,\n settings?: Partial<Settings> | null,\n) => {\n useDeepCompareEffect(() => {\n if (reader && settings) {\n // @ts-ignore - FIXME need to do some deeper investigation if these\n // are equivalent or not\n reader?.applyUserSettings(settings as Partial<UserSettings>);\n }\n }, [\n settings,\n !!reader,\n ]);\n};\n"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["ReadiumView.tsx"],"names":["React","useCallback","useState","useRef","useEffect","View","Platform","findNodeHandle","StyleSheet","Settings","createFragment","getWidthOrHeightValue","dimension","BaseReadiumView","ReadiumView","onLocationChange","wrappedOnLocationChange","onTableOfContents","wrappedOnTableOfContents","settings","unmappedSettings","props","ref","height","width","setDimensions","onLayout","nativeEvent","layout","event","toc","OS","viewId","current","styles","container","map","undefined","create"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,QAA7B,EAAuCC,MAAvC,EAA+CC,SAA/C,QAAgE,OAAhE;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,cAAzB,EAAyCC,UAAzC,QAA2D,cAA3D;AAGA,SAASC,QAAT,QAAyB,eAAzB;AACA,SAASC,cAAT,EAAyBC,qBAAqB,IAAIC,SAAlD,QAAmE,UAAnE;AAEA,SAASC,eAAT,QAAgC,mBAAhC;AAIA,OAAO,MAAMC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,CAArC;AAOAd,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIE,QAAQ,CAACyB,EAAT,KAAgB,SAApB,EAA+B;AAC7B,YAAMC,MAAM,GAAGzB,cAAc,CAACe,GAAG,CAACW,OAAL,CAA7B;AACAvB,MAAAA,cAAc,CAACsB,MAAD,CAAd;AACD;AACF,GALQ,EAKN,EALM,CAAT;AAOA,sBACE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAEE,MAAM,CAACC,SADhB;AAEE,IAAA,QAAQ,EAAET;AAFZ,kBAIE,oBAAC,eAAD;AACE,IAAA,MAAM,EAAEH,MADV;AAEE,IAAA,KAAK,EAAEC;AAFT,KAGMH,KAHN;AAIE,IAAA,gBAAgB,EAAEN,gBAJpB;AAKE,IAAA,iBAAiB,EAAEE,iBALrB;AAME,IAAA,QAAQ,EAAEG,gBAAgB,GAAGX,QAAQ,CAAC2B,GAAT,CAAahB,gBAAb,CAAH,GAAoCiB,SANhE;AAOE,IAAA,GAAG,EAAEf;AAPP,KAJF,CADF;AAgBD,CAvDM;AAyDP,MAAMY,MAAM,GAAG1B,UAAU,CAAC8B,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AAAEX,IAAAA,KAAK,EAAE,MAAT;AAAiBD,IAAAA,MAAM,EAAE;AAAzB;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useCallback, useState, useRef, useEffect } from 'react';\nimport { View, Platform, findNodeHandle, StyleSheet } from 'react-native';\n\nimport type { Dimensions } from '../interfaces';\nimport { Settings } from '../interfaces';\nimport { createFragment, getWidthOrHeightValue as dimension } from '../utils';\nimport type { BaseReadiumViewProps } from './BaseReadiumView';\nimport { BaseReadiumView } from './BaseReadiumView';\n\ntype ReadiumProps = BaseReadiumViewProps;\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n onTableOfContents: wrappedOnTableOfContents,\n settings: unmappedSettings,\n ...props\n}) => {\n const ref = useRef(null);\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n // set the view dimensions on layout\n const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}) => {\n setDimensions({\n width: dimension(width),\n height: dimension(height),\n });\n }, []);\n // wrap the native onLocationChange and extract the raw event value\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n const onTableOfContents = useCallback((event: any) => {\n if (wrappedOnTableOfContents) {\n const toc = event.nativeEvent.toc || null;\n wrappedOnTableOfContents(toc);\n }\n }, [wrappedOnTableOfContents]);\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }\n }, [])\n\n return (\n <View\n style={styles.container}\n onLayout={onLayout}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n onTableOfContents={onTableOfContents}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n ref={ref}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { width: '100%', height: '100%' },\n});\n"]}
1
+ {"version":3,"sources":["ReadiumView.tsx"],"names":["React","useCallback","useState","useRef","useEffect","View","Platform","findNodeHandle","StyleSheet","Settings","createFragment","getWidthOrHeightValue","dimension","BaseReadiumView","ReadiumView","onLocationChange","wrappedOnLocationChange","onTableOfContents","wrappedOnTableOfContents","settings","unmappedSettings","props","ref","height","width","setDimensions","onLayout","nativeEvent","layout","event","toc","OS","viewId","current","styles","container","map","undefined","create"],"mappings":";;AAAA,OAAOA,KAAP,IAAgBC,WAAhB,EAA6BC,QAA7B,EAAuCC,MAAvC,EAA+CC,SAA/C,QAAgE,OAAhE;AACA,SAASC,IAAT,EAAeC,QAAf,EAAyBC,cAAzB,EAAyCC,UAAzC,QAA2D,cAA3D;AAGA,SAASC,QAAT,QAAyB,eAAzB;AACA,SAASC,cAAT,EAAyBC,qBAAqB,IAAIC,SAA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BAAwB,CAACY,GAAD,CAAxB;AACD;AACF,GALoC,EAKlC,CAACZ,wBAAD,CALkC,CAArC;AAOAd,EAAAA,SAAS,CAAC,MAAM;AACd,QAAIE,QAAQ,CAACyB,EAAT,KAAgB,SAApB,EAA+B;AAC7B,YAAMC,MAAM,GAAGzB,cAAc,CAACe,GAAG,CAACW,OAAL,CAA7B;AACAvB,MAAAA,cAAc,CAACsB,MAAD,CAAd;AACD;AACF,GALQ,EAKN,EALM,CAAT;AAOA,sBACE,oBAAC,IAAD;AACE,IAAA,KAAK,EAAEE,MAAM,CAACC,SADhB;AAEE,IAAA,QAAQ,EAAET;AAFZ,kBAIE,oBAAC,eAAD;AACE,IAAA,MAAM,EAAEH,MADV;AAEE,IAAA,KAAK,EAAEC;AAFT,KAGMH,KAHN;AAIE,IAAA,gBAAgB,EAAEN,gBAJpB;AAKE,IAAA,iBAAiB,EAAEE,iBALrB;AAME,IAAA,QAAQ,EAAEG,gBAAgB,GAAGX,QAAQ,CAAC2B,GAAT,CAAahB,gBAAb,CAAH,GAAoCiB,SANhE;AAOE,IAAA,GAAG,EAAEf;AAPP,KAJF,CADF;AAgBD,CAvDM;AAyDP,MAAMY,MAAM,GAAG1B,UAAU,CAAC8B,MAAX,CAAkB;AAC/BH,EAAAA,SAAS,EAAE;AAAEX,IAAAA,KAAK,EAAE,MAAT;AAAiBD,IAAAA,MAAM,EAAE;AAAzB;AADoB,CAAlB,CAAf","sourcesContent":["import React, { useCallback, useState, useRef, useEffect } from 'react';\nimport { View, Platform, findNodeHandle, StyleSheet } from 'react-native';\n\nimport type { Dimensions } from '../interfaces';\nimport { Settings } from '../interfaces';\nimport { createFragment, getWidthOrHeightValue as dimension } from '../utils';\nimport type { BaseReadiumViewProps } from './BaseReadiumView';\nimport { BaseReadiumView } from './BaseReadiumView';\n\nexport type ReadiumProps = BaseReadiumViewProps;\n\nexport const ReadiumView: React.FC<ReadiumProps> = ({\n onLocationChange: wrappedOnLocationChange,\n onTableOfContents: wrappedOnTableOfContents,\n settings: unmappedSettings,\n ...props\n}) => {\n const ref = useRef(null);\n const [{ height, width }, setDimensions] = useState<Dimensions>({\n width: 0,\n height: 0,\n });\n // set the view dimensions on layout\n const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}: any) => {\n setDimensions({\n width: dimension(width),\n height: dimension(height),\n });\n }, []);\n // wrap the native onLocationChange and extract the raw event value\n const onLocationChange = useCallback((event: any) => {\n if (wrappedOnLocationChange) {\n wrappedOnLocationChange(event.nativeEvent);\n }\n }, [wrappedOnLocationChange]);\n\n const onTableOfContents = useCallback((event: any) => {\n if (wrappedOnTableOfContents) {\n const toc = event.nativeEvent.toc || null;\n wrappedOnTableOfContents(toc);\n }\n }, [wrappedOnTableOfContents]);\n\n useEffect(() => {\n if (Platform.OS === 'android') {\n const viewId = findNodeHandle(ref.current);\n createFragment(viewId);\n }\n }, [])\n\n return (\n <View\n style={styles.container}\n onLayout={onLayout}\n >\n <BaseReadiumView\n height={height}\n width={width}\n {...props}\n onLocationChange={onLocationChange}\n onTableOfContents={onTableOfContents}\n settings={unmappedSettings ? Settings.map(unmappedSettings) : undefined}\n ref={ref}\n />\n </View>\n );\n};\n\nconst styles = StyleSheet.create({\n container: { width: '100%', height: '100%' },\n});\n"]}
@@ -0,0 +1,5 @@
1
+ export * from './enums';
2
+ export * from './interfaces';
3
+ export { RANGES } from './utils';
4
+ export { ReadiumView } from './web/ReadiumView';
5
+ //# sourceMappingURL=index.web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.web.tsx"],"names":["RANGES","ReadiumView"],"mappings":"AAAA,cAAc,SAAd;AACA,cAAc,cAAd;AACA,SAASA,MAAT,QAAuB,SAAvB;AAEA,SAASC,WAAT,QAA4B,mBAA5B","sourcesContent":["export * from './enums';\nexport * from './interfaces';\nexport { RANGES } from './utils';\n\nexport { ReadiumView } from './web/ReadiumView';\n"]}
@@ -0,0 +1,89 @@
1
+ import React, { useImperativeHandle } from 'react';
2
+ import { View, StyleSheet } from 'react-native';
3
+ import { useReaderRef, useSettingsObserver, useLocationObserver } from './hooks';
4
+ export const ReadiumView = /*#__PURE__*/React.forwardRef((_ref, ref) => {
5
+ let {
6
+ file,
7
+ settings,
8
+ location,
9
+ onLocationChange,
10
+ onTableOfContents,
11
+ style = {},
12
+ height,
13
+ width
14
+ } = _ref;
15
+ const readerRef = useReaderRef({
16
+ file,
17
+ onLocationChange,
18
+ onTableOfContents
19
+ });
20
+ const reader = readerRef.current;
21
+ useImperativeHandle(ref, () => ({
22
+ nextPage: () => {
23
+ var _readerRef$current;
24
+
25
+ (_readerRef$current = readerRef.current) === null || _readerRef$current === void 0 ? void 0 : _readerRef$current.nextPage();
26
+ },
27
+ prevPage: () => {
28
+ var _readerRef$current2;
29
+
30
+ (_readerRef$current2 = readerRef.current) === null || _readerRef$current2 === void 0 ? void 0 : _readerRef$current2.previousPage();
31
+ }
32
+ }));
33
+ useSettingsObserver(reader, settings);
34
+ useLocationObserver(reader, location);
35
+ const mainStyle = { ...styles.maximize,
36
+ ...style
37
+ };
38
+ if (height) mainStyle.height = height;
39
+ if (width) mainStyle.width = width;
40
+ return /*#__PURE__*/React.createElement(View, {
41
+ style: styles.container
42
+ }, !reader && /*#__PURE__*/React.createElement("div", {
43
+ style: styles.loader
44
+ }, "Loading reader..."), /*#__PURE__*/React.createElement("div", {
45
+ id: "D2Reader-Container",
46
+ style: styles.d2Container
47
+ }, /*#__PURE__*/React.createElement("main", {
48
+ style: mainStyle,
49
+ tabIndex: -1,
50
+ id: "iframe-wrapper"
51
+ }, /*#__PURE__*/React.createElement("div", {
52
+ id: "reader-loading",
53
+ className: "loading",
54
+ style: styles.loader
55
+ }), /*#__PURE__*/React.createElement("div", {
56
+ id: "reader-error",
57
+ className: "error"
58
+ }))));
59
+ });
60
+ const styles = StyleSheet.create({
61
+ container: {
62
+ width: '100%',
63
+ height: '100%'
64
+ },
65
+ d2Container: {
66
+ width: '100%',
67
+ height: '100%',
68
+ display: 'flex'
69
+ },
70
+ maximize: {
71
+ width: '100%',
72
+ height: '100%',
73
+ display: 'flex'
74
+ },
75
+ button: {
76
+ width: 50,
77
+ fontSize: 100,
78
+ backgroundColor: 'transparent',
79
+ border: 'none'
80
+ },
81
+ loader: {
82
+ width: '100%',
83
+ height: '100%',
84
+ textAlign: 'center',
85
+ position: 'relative',
86
+ top: 'calc(50% - 10px)'
87
+ }
88
+ });
89
+ //# sourceMappingURL=ReadiumView.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["ReadiumView.tsx"],"names":["React","useImperativeHandle","View","StyleSheet","useReaderRef","useSettingsObserver","useLocationObserver","ReadiumView","forwardRef","ref","file","settings","location","onLocationChange","onTableOfContents","style","height","width","readerRef","reader","current","nextPage","prevPage","previousPage","mainStyle","styles","maximize","container","loader","d2Container","create","display","button","fontSize","backgroundColor","border","textAlign","position","top"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,mBAAhB,QAA2C,OAA3C;AAEA,SAASC,IAAT,EAAeC,UAAf,QAAiC,cAAjC;AAGA,SACEC,YADF,EAEEC,mBAFF,EAGEC,mBAHF,QAIO,SAJP;AAMA,OAAO,MAAMC,WAAW,gBAAGP,KAAK,CAACQ,UAAN,CAGV,OASdC,GATc,KASN;AAAA,MATO;AAChBC,IAAAA,IADgB;AAEhBC,IAAAA,QAFgB;AAGhBC,IAAAA,QAHgB;AAIhBC,IAAAA,gBAJgB;AAKhBC,IAAAA,iBALgB;AAMhBC,IAAAA,KAAK,GAAG,EANQ;AAOhBC,IAAAA,MAPgB;AAQhBC,IAAAA;AARgB,GASP;AACT,QAAMC,SAAS,GAAGd,YAAY,CAAC;AAC7BM,IAAAA,IAD6B;AAE7BG,IAAAA,gBAF6B;AAG7BC,IAAAA;AAH6B,GAAD,CAA9B;AAKA,QAAMK,MAAM,GAAGD,SAAS,CAACE,OAAzB;AAEAnB,EAAAA,mBAAmB,CAACQ,GAAD,EAAM,OAAO;AAC9BY,IAAAA,QAAQ,EAAE,MAAM;AAAA;;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AAE;AACXZ,IAAAA,KAAK,EAAE,MADI;AAEXD,IAAAA,MAAM,EAAE,MAFG;AAGXe,IAAAA,OAAO,EAAE;AAHE,GALkB;AAU/BL,EAAAA,QAAQ,EAAE;AACRT,IAAAA,KAAK,EAAE,MADC;AAERD,IAAAA,MAAM,EAAE,MAFA;AAGRe,IAAAA,OAAO,EAAE;AAHD,GAVqB;AAe/BC,EAAAA,MAAM,EAAE;AACNf,IAAAA,KAAK,EAAE,EADD;AAENgB,IAAAA,QAAQ,EAAE,GAFJ;AAGNC,IAAAA,eAAe,EAAE,aAHX;AAINC,IAAAA,MAAM,EAAE;AAJF,GAfuB;AAqB/BP,EAAAA,MAAM,EAAE;AACNX,IAAAA,KAAK,EAAE,MADD;AAEND,IAAAA,MAAM,EAAE,MAFF;AAGNoB,IAAAA,SAAS,EAAE,QAHL;AAINC,IAAAA,QAAQ,EAAE,UAJJ;AAKNC,IAAAA,GAAG,EAAE;AALC;AArBuB,CAAlB,CAAf","sourcesContent":["import React, { useImperativeHandle } from 'react';\nimport type { CSSProperties } from 'react';\nimport { View, StyleSheet } from 'react-native';\n\nimport type { ReadiumProps } from '../components/ReadiumView';\nimport {\n useReaderRef,\n useSettingsObserver,\n useLocationObserver,\n} from './hooks';\n\nexport const ReadiumView = React.forwardRef<{\n nextPage: () => void;\n prevPage: () => void;\n}, ReadiumProps>(({\n file,\n settings,\n location,\n onLocationChange,\n onTableOfContents,\n style = {},\n height,\n width,\n}, ref) => {\n const readerRef = useReaderRef({\n file,\n onLocationChange,\n onTableOfContents,\n });\n const reader = readerRef.current;\n\n useImperativeHandle(ref, () => ({\n nextPage: () => {\n readerRef.current?.nextPage();\n },\n prevPage: () => {\n readerRef.current?.previousPage();\n },\n }));\n\n useSettingsObserver(reader, settings);\n useLocationObserver(reader, location);\n\n const mainStyle = {\n ...styles.maximize,\n ...(style as CSSProperties),\n };\n\n if (height) mainStyle.height = height;\n if (width) mainStyle.width = width;\n\n return (\n <View style={styles.container}>\n {!reader && <div style={styles.loader}>Loading reader...</div>}\n <div id=\"D2Reader-Container\" style={styles.d2Container}>\n <main\n style={mainStyle}\n tabIndex={-1}\n id=\"iframe-wrapper\"\n >\n <div id=\"reader-loading\" className=\"loading\" style={styles.loader}></div>\n <div id=\"reader-error\" className=\"error\"></div>\n </main>\n </div>\n </View>\n );\n});\n\nconst styles = StyleSheet.create({\n container: {\n width: '100%',\n height: '100%',\n },\n d2Container: {\n width: '100%',\n height: '100%',\n display: 'flex',\n },\n maximize: {\n width: '100%',\n height: '100%',\n display: 'flex',\n },\n button: {\n width: 50,\n fontSize: 100,\n backgroundColor: 'transparent',\n border: 'none',\n },\n loader: {\n width: '100%',\n height: '100%',\n textAlign: 'center',\n position: 'relative',\n top: 'calc(50% - 10px)',\n },\n});\n"]}
@@ -0,0 +1,4 @@
1
+ export * from './useReaderRef';
2
+ export * from './useSettingsObserver';
3
+ export * from './useLocationObserver';
4
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAd;AACA,cAAc,uBAAd;AACA,cAAc,uBAAd","sourcesContent":["export * from './useReaderRef';\nexport * from './useSettingsObserver';\nexport * from './useLocationObserver';\n"]}
@@ -0,0 +1,11 @@
1
+ import { useDeepCompareEffect } from 'use-deep-compare';
2
+ export const useLocationObserver = (reader, location) => {
3
+ useDeepCompareEffect(() => {
4
+ if (reader && location) {
5
+ // NOTE: technically this is a Link | Locator. However, under the hood the
6
+ // R2D2BC is converting Links to locators, so just force the type here.
7
+ reader.goTo(location);
8
+ }
9
+ }, [location, !!reader]);
10
+ };
11
+ //# sourceMappingURL=useLocationObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useLocationObserver.ts"],"names":["useDeepCompareEffect","useLocationObserver","reader","location","goTo"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,kBAArC;AAMA,OAAO,MAAMC,mBAAmB,GAAG,CACjCC,MADiC,EAEjCC,QAFiC,KAG9B;AACHH,EAAAA,oBAAoB,CAAC,MAAM;AACzB,QAAIE,MAAM,IAAIC,QAAd,EAAwB;AACtB;AACA;AACAD,MAAAA,MAAM,CAACE,IAAP,CAAYD,QAAZ;AACD;AACF,GANmB,EAMjB,CACDA,QADC,EAED,CAAC,CAACD,MAFD,CANiB,CAApB;AAUD,CAdM","sourcesContent":["import { useDeepCompareEffect } from 'use-deep-compare';\nimport type D2Reader from '@d-i-t-a/reader';\nimport type { Locator as R2Locator } from '@d-i-t-a/reader';\n\nimport type { Link, Locator } from '../../interfaces';\n\nexport const useLocationObserver = (\n reader?: D2Reader | null,\n location?: Link | Locator | null,\n) => {\n useDeepCompareEffect(() => {\n if (reader && location) {\n // NOTE: technically this is a Link | Locator. However, under the hood the\n // R2D2BC is converting Links to locators, so just force the type here.\n reader.goTo(location as R2Locator);\n }\n }, [\n location,\n !!reader,\n ]);\n};\n"]}
@@ -0,0 +1,50 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import D2Reader from '@d-i-t-a/reader';
3
+ export const useReaderRef = _ref => {
4
+ let {
5
+ file,
6
+ onLocationChange,
7
+ onTableOfContents
8
+ } = _ref;
9
+ const readerRef = useRef(null);
10
+ useEffect(() => {
11
+ D2Reader.load({
12
+ url: new URL(file.url),
13
+ lastReadingPosition: file.initialLocation,
14
+ userSettings: {
15
+ verticalScroll: false
16
+ },
17
+ api: {
18
+ updateCurrentLocation: async location => {
19
+ if (onLocationChange) onLocationChange(location);
20
+ return location;
21
+ }
22
+ },
23
+ injectables: injectables
24
+ }).then(r => {
25
+ if (onTableOfContents) {
26
+ onTableOfContents(r.tableOfContents);
27
+ }
28
+
29
+ readerRef.current = r;
30
+ });
31
+ }, []);
32
+ return readerRef;
33
+ }; // NOTE: right now we're serving these through statically.io, which is just
34
+ // pulling them from Github... Might not be the best way and maybe we should
35
+ // consider bundling them with the library.
36
+
37
+ const injectables = [{
38
+ type: "style",
39
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-before.css",
40
+ r2before: true
41
+ }, {
42
+ type: "style",
43
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-default.css",
44
+ r2default: true
45
+ }, {
46
+ type: "style",
47
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-after.css",
48
+ r2after: true
49
+ }];
50
+ //# sourceMappingURL=useReaderRef.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useReaderRef.ts"],"names":["useEffect","useRef","D2Reader","useReaderRef","file","onLocationChange","onTableOfContents","readerRef","load","url","URL","lastReadingPosition","initialLocation","userSettings","verticalScroll","api","updateCurrentLocation","location","injectables","then","r","tableOfContents","current","type","r2before","r2default","r2after"],"mappings":"AAAA,SAASA,SAAT,EAAoBC,MAApB,QAAkC,OAAlC;AACA,OAAOC,QAAP,MAAqB,iBAArB;AAKA,OAAO,MAAMC,YAAY,GAAG,QAIkD;AAAA,MAJjD;AAC3BC,IAAAA,IAD2B;AAE3BC,IAAAA,gBAF2B;AAG3BC,IAAAA;AAH2B,GAIiD;AAC5E,QAAMC,SAAS,GAAGN,MAAM,CAAkB,IAAlB,CAAxB;AAEAD,EAAAA,SAAS,CAAC,MAAM;AACdE,IAAAA,QAAQ,CAACM,IAAT,CAAc;AACZC,MAAAA,GAAG,EAAE,IAAIC,GAAJ,CAAQN,IAAI,CAACK,GAAb,CADO;AAEZE,MAAAA,mBAAmB,EAAEP,IAAI,CAACQ,eAFd;AAGZC,MAAAA,YAAY,EAAE;AAAEC,QAAAA,cAAc,EAAE;AAAlB,OAHF;AAIZC,MAAAA,GAAG,EAAE;AACHC,QAAAA,qBAAqB,EAAE,MAAOC,QAAP,IAA6B;AAClD,cAAIZ,gBAAJ,EAAsBA,gBAAgB,CAACY,QAAD,CAAhB;AACtB,iBAAOA,QAAP;AACD;AAJE,OAJO;AAUZC,MAAAA,WAAW,EAAEA;AAVD,KAAd,EAWGC,IAXH,CAWSC,CAAD,IAAO;AACb,UAAId,iBAAJ,EAAuB;AACrBA,QAAAA,iBAAiB,CAACc,CAAC,CAACC,eAAH,CAAjB;AACD;;AACDd,MAAAA,SAAS,CAACe,OAAV,GAAoBF,CAApB;AACD,KAhBD;AAiBD,GAlBQ,EAkBN,EAlBM,CAAT;AAoBA,SAAOb,SAAP;AACD,CA5BM,C,CA8BP;AACA;AACA;;AACA,MAAMW,WAAkB,GAAG,CACzB;AACEK,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,iGAFP;AAGEe,EAAAA,QAAQ,EAAE;AAHZ,CADyB,EAMzB;AACED,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,kGAFP;AAGEgB,EAAAA,SAAS,EAAE;AAHb,CANyB,EAWzB;AACEF,EAAAA,IAAI,EAAE,OADR;AAEEd,EAAAA,GAAG,EAAE,gGAFP;AAGEiB,EAAAA,OAAO,EAAE;AAHX,CAXyB,CAA3B","sourcesContent":["import { useEffect, useRef } from 'react';\nimport D2Reader from '@d-i-t-a/reader';\n\nimport type { ReadiumProps } from '../../components/ReadiumView';\nimport type { Locator } from '../../interfaces';\n\nexport const useReaderRef = ({\n file,\n onLocationChange,\n onTableOfContents,\n}: Pick<ReadiumProps, 'file' | 'onLocationChange' | 'onTableOfContents' >) => {\n const readerRef = useRef<D2Reader | null>(null);\n\n useEffect(() => {\n D2Reader.load({\n url: new URL(file.url),\n lastReadingPosition: file.initialLocation,\n userSettings: { verticalScroll: false },\n api: {\n updateCurrentLocation: async (location: Locator) => {\n if (onLocationChange) onLocationChange(location);\n return location;\n },\n },\n injectables: injectables,\n }).then((r) => {\n if (onTableOfContents) {\n onTableOfContents(r.tableOfContents);\n }\n readerRef.current = r;\n });\n }, []);\n\n return readerRef\n};\n\n// NOTE: right now we're serving these through statically.io, which is just\n// pulling them from Github... Might not be the best way and maybe we should\n// consider bundling them with the library.\nconst injectables: any[] = [\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-before.css\",\n r2before: true,\n },\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-default.css\",\n r2default: true,\n },\n {\n type: \"style\",\n url: \"https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-after.css\",\n r2after: true,\n },\n];\n\n"]}
@@ -0,0 +1,11 @@
1
+ import { useDeepCompareEffect } from 'use-deep-compare';
2
+ export const useSettingsObserver = (reader, settings) => {
3
+ useDeepCompareEffect(() => {
4
+ if (reader && settings) {
5
+ // @ts-ignore - FIXME need to do some deeper investigation if these
6
+ // are equivalent or not
7
+ reader === null || reader === void 0 ? void 0 : reader.applyUserSettings(settings);
8
+ }
9
+ }, [settings, !!reader]);
10
+ };
11
+ //# sourceMappingURL=useSettingsObserver.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["useSettingsObserver.ts"],"names":["useDeepCompareEffect","useSettingsObserver","reader","settings","applyUserSettings"],"mappings":"AAAA,SAASA,oBAAT,QAAqC,kBAArC;AAMA,OAAO,MAAMC,mBAAmB,GAAG,CACjCC,MADiC,EAEjCC,QAFiC,KAG9B;AACHH,EAAAA,oBAAoB,CAAC,MAAM;AACzB,QAAIE,MAAM,IAAIC,QAAd,EAAwB;AACtB;AACA;AACAD,MAAAA,MAAM,SAAN,IAAAA,MAAM,WAAN,YAAAA,MAAM,CAAEE,iBAAR,CAA0BD,QAA1B;AACD;AACF,GANmB,EAMjB,CACDA,QADC,EAED,CAAC,CAACD,MAFD,CANiB,CAApB;AAUD,CAdM","sourcesContent":["import { useDeepCompareEffect } from 'use-deep-compare';\nimport type D2Reader from '@d-i-t-a/reader';\nimport type { UserSettings } from '@d-i-t-a/reader/dist/types/model/user-settings/UserSettings';\n\nimport type { Settings } from '../../interfaces';\n\nexport const useSettingsObserver = (\n reader?: D2Reader | null,\n settings?: Partial<Settings> | null,\n) => {\n useDeepCompareEffect(() => {\n if (reader && settings) {\n // @ts-ignore - FIXME need to do some deeper investigation if these\n // are equivalent or not\n reader?.applyUserSettings(settings as Partial<UserSettings>);\n }\n }, [\n settings,\n !!reader,\n ]);\n};\n"]}
@@ -1,5 +1,4 @@
1
1
  import React from 'react';
2
2
  import type { BaseReadiumViewProps } from './BaseReadiumView';
3
- declare type ReadiumProps = BaseReadiumViewProps;
3
+ export declare type ReadiumProps = BaseReadiumViewProps;
4
4
  export declare const ReadiumView: React.FC<ReadiumProps>;
5
- export {};
@@ -0,0 +1,4 @@
1
+ export * from './enums';
2
+ export * from './interfaces';
3
+ export { RANGES } from './utils';
4
+ export { ReadiumView } from './web/ReadiumView';
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export declare const ReadiumView: React.ForwardRefExoticComponent<Pick<import("../components/BaseReadiumView").BaseReadiumViewProps, "onLocationChange" | "onTableOfContents" | "settings" | "file" | "location" | "style" | "height" | "width"> & React.RefAttributes<{
3
+ nextPage: () => void;
4
+ prevPage: () => void;
5
+ }>>;
@@ -0,0 +1,3 @@
1
+ export * from './useReaderRef';
2
+ export * from './useSettingsObserver';
3
+ export * from './useLocationObserver';
@@ -0,0 +1,3 @@
1
+ import type D2Reader from '@d-i-t-a/reader';
2
+ import type { Link, Locator } from '../../interfaces';
3
+ export declare const useLocationObserver: (reader?: D2Reader | null | undefined, location?: Link | Locator | null | undefined) => void;
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import D2Reader from '@d-i-t-a/reader';
3
+ import type { ReadiumProps } from '../../components/ReadiumView';
4
+ export declare const useReaderRef: ({ file, onLocationChange, onTableOfContents, }: Pick<ReadiumProps, 'file' | 'onLocationChange' | 'onTableOfContents'>) => import("react").MutableRefObject<D2Reader | null>;
@@ -0,0 +1,3 @@
1
+ import type D2Reader from '@d-i-t-a/reader';
2
+ import type { Settings } from '../../interfaces';
3
+ export declare const useSettingsObserver: (reader?: D2Reader | null | undefined, settings?: Partial<Settings> | null | undefined) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-readium",
3
- "version": "1.0.4",
3
+ "version": "1.2.0",
4
4
  "description": "A react-native wrapper for https://readium.org/",
5
5
  "main": "lib/commonjs/index",
6
6
  "module": "lib/module/index",
@@ -62,8 +62,8 @@
62
62
  "@react-native-community/eslint-config": "^2.0.0",
63
63
  "@release-it/conventional-changelog": "^2.0.0",
64
64
  "@types/jest": "^26.0.0",
65
- "@types/react": "^16.9.19",
66
- "@types/react-native": "0.62.13",
65
+ "@types/react": "^18.0.26",
66
+ "@types/react-native": "^0.70.8",
67
67
  "commitlint": "^11.0.0",
68
68
  "conventional-changelog-cli": "^2.2.2",
69
69
  "eslint": "^7.2.0",
@@ -73,8 +73,8 @@
73
73
  "jest": "^26.0.1",
74
74
  "pod-install": "^0.1.0",
75
75
  "prettier": "^2.0.5",
76
- "react": "16.13.1",
77
- "react-native": "0.63.4",
76
+ "react": "^18.2.0",
77
+ "react-native": "^0.70.6",
78
78
  "react-native-builder-bob": "^0.18.2",
79
79
  "release-it": "^14.2.2",
80
80
  "typescript": "^4.1.3"
@@ -156,5 +156,8 @@
156
156
  ]
157
157
  ]
158
158
  },
159
- "dependencies": {}
159
+ "dependencies": {
160
+ "@d-i-t-a/reader": "^2.1.4",
161
+ "use-deep-compare": "^1.1.0"
162
+ }
160
163
  }
@@ -7,7 +7,7 @@ import { createFragment, getWidthOrHeightValue as dimension } from '../utils';
7
7
  import type { BaseReadiumViewProps } from './BaseReadiumView';
8
8
  import { BaseReadiumView } from './BaseReadiumView';
9
9
 
10
- type ReadiumProps = BaseReadiumViewProps;
10
+ export type ReadiumProps = BaseReadiumViewProps;
11
11
 
12
12
  export const ReadiumView: React.FC<ReadiumProps> = ({
13
13
  onLocationChange: wrappedOnLocationChange,
@@ -21,7 +21,7 @@ export const ReadiumView: React.FC<ReadiumProps> = ({
21
21
  height: 0,
22
22
  });
23
23
  // set the view dimensions on layout
24
- const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}) => {
24
+ const onLayout = useCallback(({ nativeEvent: { layout: { width, height } }}: any) => {
25
25
  setDimensions({
26
26
  width: dimension(width),
27
27
  height: dimension(height),
@@ -0,0 +1,5 @@
1
+ export * from './enums';
2
+ export * from './interfaces';
3
+ export { RANGES } from './utils';
4
+
5
+ export { ReadiumView } from './web/ReadiumView';
@@ -0,0 +1,97 @@
1
+ import React, { useImperativeHandle } from 'react';
2
+ import type { CSSProperties } from 'react';
3
+ import { View, StyleSheet } from 'react-native';
4
+
5
+ import type { ReadiumProps } from '../components/ReadiumView';
6
+ import {
7
+ useReaderRef,
8
+ useSettingsObserver,
9
+ useLocationObserver,
10
+ } from './hooks';
11
+
12
+ export const ReadiumView = React.forwardRef<{
13
+ nextPage: () => void;
14
+ prevPage: () => void;
15
+ }, ReadiumProps>(({
16
+ file,
17
+ settings,
18
+ location,
19
+ onLocationChange,
20
+ onTableOfContents,
21
+ style = {},
22
+ height,
23
+ width,
24
+ }, ref) => {
25
+ const readerRef = useReaderRef({
26
+ file,
27
+ onLocationChange,
28
+ onTableOfContents,
29
+ });
30
+ const reader = readerRef.current;
31
+
32
+ useImperativeHandle(ref, () => ({
33
+ nextPage: () => {
34
+ readerRef.current?.nextPage();
35
+ },
36
+ prevPage: () => {
37
+ readerRef.current?.previousPage();
38
+ },
39
+ }));
40
+
41
+ useSettingsObserver(reader, settings);
42
+ useLocationObserver(reader, location);
43
+
44
+ const mainStyle = {
45
+ ...styles.maximize,
46
+ ...(style as CSSProperties),
47
+ };
48
+
49
+ if (height) mainStyle.height = height;
50
+ if (width) mainStyle.width = width;
51
+
52
+ return (
53
+ <View style={styles.container}>
54
+ {!reader && <div style={styles.loader}>Loading reader...</div>}
55
+ <div id="D2Reader-Container" style={styles.d2Container}>
56
+ <main
57
+ style={mainStyle}
58
+ tabIndex={-1}
59
+ id="iframe-wrapper"
60
+ >
61
+ <div id="reader-loading" className="loading" style={styles.loader}></div>
62
+ <div id="reader-error" className="error"></div>
63
+ </main>
64
+ </div>
65
+ </View>
66
+ );
67
+ });
68
+
69
+ const styles = StyleSheet.create({
70
+ container: {
71
+ width: '100%',
72
+ height: '100%',
73
+ },
74
+ d2Container: {
75
+ width: '100%',
76
+ height: '100%',
77
+ display: 'flex',
78
+ },
79
+ maximize: {
80
+ width: '100%',
81
+ height: '100%',
82
+ display: 'flex',
83
+ },
84
+ button: {
85
+ width: 50,
86
+ fontSize: 100,
87
+ backgroundColor: 'transparent',
88
+ border: 'none',
89
+ },
90
+ loader: {
91
+ width: '100%',
92
+ height: '100%',
93
+ textAlign: 'center',
94
+ position: 'relative',
95
+ top: 'calc(50% - 10px)',
96
+ },
97
+ });
@@ -0,0 +1,3 @@
1
+ export * from './useReaderRef';
2
+ export * from './useSettingsObserver';
3
+ export * from './useLocationObserver';
@@ -0,0 +1,21 @@
1
+ import { useDeepCompareEffect } from 'use-deep-compare';
2
+ import type D2Reader from '@d-i-t-a/reader';
3
+ import type { Locator as R2Locator } from '@d-i-t-a/reader';
4
+
5
+ import type { Link, Locator } from '../../interfaces';
6
+
7
+ export const useLocationObserver = (
8
+ reader?: D2Reader | null,
9
+ location?: Link | Locator | null,
10
+ ) => {
11
+ useDeepCompareEffect(() => {
12
+ if (reader && location) {
13
+ // NOTE: technically this is a Link | Locator. However, under the hood the
14
+ // R2D2BC is converting Links to locators, so just force the type here.
15
+ reader.goTo(location as R2Locator);
16
+ }
17
+ }, [
18
+ location,
19
+ !!reader,
20
+ ]);
21
+ };
@@ -0,0 +1,57 @@
1
+ import { useEffect, useRef } from 'react';
2
+ import D2Reader from '@d-i-t-a/reader';
3
+
4
+ import type { ReadiumProps } from '../../components/ReadiumView';
5
+ import type { Locator } from '../../interfaces';
6
+
7
+ export const useReaderRef = ({
8
+ file,
9
+ onLocationChange,
10
+ onTableOfContents,
11
+ }: Pick<ReadiumProps, 'file' | 'onLocationChange' | 'onTableOfContents' >) => {
12
+ const readerRef = useRef<D2Reader | null>(null);
13
+
14
+ useEffect(() => {
15
+ D2Reader.load({
16
+ url: new URL(file.url),
17
+ lastReadingPosition: file.initialLocation,
18
+ userSettings: { verticalScroll: false },
19
+ api: {
20
+ updateCurrentLocation: async (location: Locator) => {
21
+ if (onLocationChange) onLocationChange(location);
22
+ return location;
23
+ },
24
+ },
25
+ injectables: injectables,
26
+ }).then((r) => {
27
+ if (onTableOfContents) {
28
+ onTableOfContents(r.tableOfContents);
29
+ }
30
+ readerRef.current = r;
31
+ });
32
+ }, []);
33
+
34
+ return readerRef
35
+ };
36
+
37
+ // NOTE: right now we're serving these through statically.io, which is just
38
+ // pulling them from Github... Might not be the best way and maybe we should
39
+ // consider bundling them with the library.
40
+ const injectables: any[] = [
41
+ {
42
+ type: "style",
43
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-before.css",
44
+ r2before: true,
45
+ },
46
+ {
47
+ type: "style",
48
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-default.css",
49
+ r2default: true,
50
+ },
51
+ {
52
+ type: "style",
53
+ url: "https://cdn.statically.io/gh/d-i-t-a/R2D2BC/production/viewer/readium-css/ReadiumCSS-after.css",
54
+ r2after: true,
55
+ },
56
+ ];
57
+
@@ -0,0 +1,21 @@
1
+ import { useDeepCompareEffect } from 'use-deep-compare';
2
+ import type D2Reader from '@d-i-t-a/reader';
3
+ import type { UserSettings } from '@d-i-t-a/reader/dist/types/model/user-settings/UserSettings';
4
+
5
+ import type { Settings } from '../../interfaces';
6
+
7
+ export const useSettingsObserver = (
8
+ reader?: D2Reader | null,
9
+ settings?: Partial<Settings> | null,
10
+ ) => {
11
+ useDeepCompareEffect(() => {
12
+ if (reader && settings) {
13
+ // @ts-ignore - FIXME need to do some deeper investigation if these
14
+ // are equivalent or not
15
+ reader?.applyUserSettings(settings as Partial<UserSettings>);
16
+ }
17
+ }, [
18
+ settings,
19
+ !!reader,
20
+ ]);
21
+ };