react-book-reader 1.1.5 → 1.1.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/README.md CHANGED
@@ -45,17 +45,17 @@ export default () => (
45
45
 
46
46
  ## ReactReader Attributes
47
47
 
48
- | **Name** | **Description** | **Type** | **Default** |
49
- | -------- | --------------------------------- | ---------------------- | ----------- |
50
- | url | book url or File | `string`/`File` | — |
51
- | location | set / update location of the book | `string`/`number` | — |
52
- | title | the title of the book | `string` | — |
53
- | showToc | whether to show the toc | `boolean` | true |
48
+ | **Name** | **Description** | **Type** | **Default** |
49
+ | -------- | --------------------------------- | ----------------------- | ----------- |
50
+ | url | book url or File | `string`/`File` | — |
51
+ | location | set / update location of the book | `string`/`number` | — |
52
+ | title | the title of the book | `string`/`ReactElement` | — |
53
+ | showToc | whether to show the toc | `boolean` | true |
54
54
 
55
55
 
56
56
  ## ReactReader props passed to inner BookView
57
57
 
58
- | **Name** | **Description** | **Type** | |
58
+ | **Name** | **Description** | **Type** | **Default** |
59
59
  | ----------- | ----------------------------------------- | --------------------------------- | ---------------- |
60
60
  | url | book url or File | `string`/`File` | |
61
61
  | tocChanged | when the reader has parsed the book you will receive an array of the chapters | `function(toc)` |
@@ -1,4 +1,4 @@
1
- import { f as z, p as V, t as X, a as W } from "./view-C6hqGjnD.js";
1
+ import { f as z, p as V, t as X, a as W } from "./view-Ht0IwIBs.js";
2
2
  const b = {
3
3
  CONTAINER: "urn:oasis:names:tc:opendocument:xmlns:container",
4
4
  XHTML: "http://www.w3.org/1999/xhtml",
@@ -1,11 +1,11 @@
1
- const h = async (e, r, t) => {
1
+ const h = async (e, i, t) => {
2
2
  const o = t * devicePixelRatio;
3
- r.documentElement.style.transform = `scale(${1 / devicePixelRatio})`, r.documentElement.style.transformOrigin = "top left", r.documentElement.style.setProperty("--scale-factor", o);
3
+ i.documentElement.style.transform = `scale(${1 / devicePixelRatio})`, i.documentElement.style.transformOrigin = "top left", i.documentElement.style.setProperty("--scale-factor", o);
4
4
  const n = e.getViewport({ scale: o }), s = document.createElement("canvas");
5
5
  s.height = n.height, s.width = n.width;
6
6
  const g = s.getContext("2d");
7
- await e.render({ canvasContext: g, viewport: n }).promise, r.querySelector("#canvas").replaceChildren(r.adoptNode(s));
8
- const c = r.querySelector(".textLayer");
7
+ await e.render({ canvasContext: g, viewport: n }).promise, i.querySelector("#canvas").replaceChildren(i.adoptNode(s));
8
+ const c = i.querySelector(".textLayer");
9
9
  await new pdfjsLib.TextLayer({
10
10
  textContentSource: await e.streamTextContent(),
11
11
  container: c,
@@ -22,7 +22,7 @@ const h = async (e, r, t) => {
22
22
  });
23
23
  const a = document.createElement("div");
24
24
  a.className = "endOfContent", c.append(a), c.onpointerdown = () => c.classList.add("selecting"), c.onpointerup = () => c.classList.remove("selecting");
25
- const d = r.querySelector(".annotationLayer");
25
+ const d = i.querySelector(".annotationLayer");
26
26
  await new pdfjsLib.AnnotationLayer({ page: e, viewport: n, div: d }).render({
27
27
  annotations: await e.getAnnotations(),
28
28
  linkService: {
@@ -32,9 +32,9 @@ const h = async (e, r, t) => {
32
32
  addLinkAttributes: (l, p) => l.href = p
33
33
  }
34
34
  });
35
- }, u = async (e, r) => {
35
+ }, u = async (e, i) => {
36
36
  const t = e.getViewport({ scale: 1 });
37
- if (r) {
37
+ if (i) {
38
38
  const s = document.createElement("canvas");
39
39
  s.height = t.height, s.width = t.width;
40
40
  const g = s.getContext("2d");
@@ -60,16 +60,16 @@ const h = async (e, r, t) => {
60
60
  href: JSON.stringify(e.dest),
61
61
  subitems: e.items.length ? e.items.map(m) : null
62
62
  }), y = async (e) => {
63
- const r = new pdfjsLib.PDFDataRangeTransport(e.size, []);
64
- r.requestDataRange = (i, a) => {
65
- e.slice(i, a).arrayBuffer().then((d) => {
66
- r.onDataRange(i, d);
63
+ const i = new pdfjsLib.PDFDataRangeTransport(e.size, []);
64
+ i.requestDataRange = (r, a) => {
65
+ e.slice(r, a).arrayBuffer().then((d) => {
66
+ i.onDataRange(r, d);
67
67
  });
68
68
  };
69
69
  const t = await pdfjsLib.getDocument({
70
- range: r,
71
- cMapUrl: pdfjsPath("cmaps/"),
72
- standardFontDataUrl: pdfjsPath("standard_fonts/"),
70
+ range: i,
71
+ // cMapUrl: pdfjsPath('cmaps/'),
72
+ // standardFontDataUrl: pdfjsPath('standard_fonts/'),
73
73
  isEvalSupported: !1
74
74
  }).promise, o = { rendition: { layout: "pre-paginated" } }, { metadata: n, info: s } = await t.getMetadata() ?? {};
75
75
  o.metadata = {
@@ -87,7 +87,7 @@ const h = async (e, r, t) => {
87
87
  const g = await t.getOutline();
88
88
  o.toc = g?.map(m);
89
89
  const c = /* @__PURE__ */ new Map();
90
- return o.sections = Array.from({ length: t.numPages }).map((i, a) => ({
90
+ return o.sections = Array.from({ length: t.numPages }).map((r, a) => ({
91
91
  id: a,
92
92
  load: async () => {
93
93
  const d = c.get(a);
@@ -96,13 +96,13 @@ const h = async (e, r, t) => {
96
96
  return c.set(a, l), l;
97
97
  },
98
98
  size: 1e3
99
- })), o.isExternal = (i) => /^\w+:/i.test(i), o.resolveHref = async (i) => {
100
- const a = JSON.parse(i), d = typeof a == "string" ? await t.getDestination(a) : a;
99
+ })), o.isExternal = (r) => /^\w+:/i.test(r), o.resolveHref = async (r) => {
100
+ const a = JSON.parse(r), d = typeof a == "string" ? await t.getDestination(a) : a;
101
101
  return { index: await t.getPageIndex(d[0]) };
102
- }, o.splitTOCHref = async (i) => {
103
- const a = JSON.parse(i), d = typeof a == "string" ? await t.getDestination(a) : a;
102
+ }, o.splitTOCHref = async (r) => {
103
+ const a = JSON.parse(r), d = typeof a == "string" ? await t.getDestination(a) : a;
104
104
  return [await t.getPageIndex(d[0]), null];
105
- }, o.getTOCFragment = (i) => i.documentElement, o.getCover = async () => u(await t.getPage(1), !0), o.destroy = () => t.destroy(), o;
105
+ }, o.getTOCFragment = (r) => r.documentElement, o.getCover = async () => u(await t.getPage(1), !0), o.destroy = () => t.destroy(), o;
106
106
  };
107
107
  export {
108
108
  y as makePDF