react-book-reader 1.1.7 → 1.1.9

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.
@@ -1,109 +0,0 @@
1
- const h = async (e, i, t) => {
2
- const o = t * devicePixelRatio;
3
- i.documentElement.style.transform = `scale(${1 / devicePixelRatio})`, i.documentElement.style.transformOrigin = "top left", i.documentElement.style.setProperty("--scale-factor", o);
4
- const n = e.getViewport({ scale: o }), s = document.createElement("canvas");
5
- s.height = n.height, s.width = n.width;
6
- const g = s.getContext("2d");
7
- await e.render({ canvasContext: g, viewport: n }).promise, i.querySelector("#canvas").replaceChildren(i.adoptNode(s));
8
- const c = i.querySelector(".textLayer");
9
- await new pdfjsLib.TextLayer({
10
- textContentSource: await e.streamTextContent(),
11
- container: c,
12
- viewport: n
13
- }).render();
14
- for (const l of document.querySelectorAll(".hiddenCanvasElement"))
15
- Object.assign(l.style, {
16
- position: "absolute",
17
- top: "0",
18
- left: "0",
19
- width: "0",
20
- height: "0",
21
- display: "none"
22
- });
23
- const a = document.createElement("div");
24
- a.className = "endOfContent", c.append(a), c.onpointerdown = () => c.classList.add("selecting"), c.onpointerup = () => c.classList.remove("selecting");
25
- const d = i.querySelector(".annotationLayer");
26
- await new pdfjsLib.AnnotationLayer({ page: e, viewport: n, div: d }).render({
27
- annotations: await e.getAnnotations(),
28
- linkService: {
29
- goToDestination: () => {
30
- },
31
- getDestinationHash: (l) => JSON.stringify(l),
32
- addLinkAttributes: (l, p) => l.href = p
33
- }
34
- });
35
- }, u = async (e, i) => {
36
- const t = e.getViewport({ scale: 1 });
37
- if (i) {
38
- const s = document.createElement("canvas");
39
- s.height = t.height, s.width = t.width;
40
- const g = s.getContext("2d");
41
- return await e.render({ canvasContext: g, viewport: t }).promise, new Promise((c) => s.toBlob(c));
42
- }
43
- return { src: URL.createObjectURL(new Blob([`
44
- <!DOCTYPE html>
45
- <html lang="en">
46
- <meta charset="utf-8">
47
- <meta name="viewport" content="width=${t.width}, height=${t.height}">
48
- <style>
49
- html, body {
50
- margin: 0;
51
- padding: 0;
52
- }
53
- </style>
54
- <div id="canvas"></div>
55
- <div class="textLayer"></div>
56
- <div class="annotationLayer"></div>
57
- `], { type: "text/html" })), onZoom: ({ doc: s, scale: g }) => h(e, s, g) };
58
- }, m = (e) => ({
59
- label: e.title,
60
- href: JSON.stringify(e.dest),
61
- subitems: e.items.length ? e.items.map(m) : null
62
- }), y = async (e) => {
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
- });
68
- };
69
- const t = await pdfjsLib.getDocument({
70
- range: i,
71
- // cMapUrl: pdfjsPath('cmaps/'),
72
- // standardFontDataUrl: pdfjsPath('standard_fonts/'),
73
- isEvalSupported: !1
74
- }).promise, o = { rendition: { layout: "pre-paginated" } }, { metadata: n, info: s } = await t.getMetadata() ?? {};
75
- o.metadata = {
76
- title: n?.get("dc:title") ?? s?.Title,
77
- author: n?.get("dc:creator") ?? s?.Author,
78
- contributor: n?.get("dc:contributor"),
79
- description: n?.get("dc:description") ?? s?.Subject,
80
- language: n?.get("dc:language"),
81
- publisher: n?.get("dc:publisher"),
82
- subject: n?.get("dc:subject"),
83
- identifier: n?.get("dc:identifier"),
84
- source: n?.get("dc:source"),
85
- rights: n?.get("dc:rights")
86
- };
87
- const g = await t.getOutline();
88
- o.toc = g?.map(m);
89
- const c = /* @__PURE__ */ new Map();
90
- return o.sections = Array.from({ length: t.numPages }).map((r, a) => ({
91
- id: a,
92
- load: async () => {
93
- const d = c.get(a);
94
- if (d) return d;
95
- const l = await u(await t.getPage(a + 1));
96
- return c.set(a, l), l;
97
- },
98
- size: 1e3
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
- return { index: await t.getPageIndex(d[0]) };
102
- }, o.splitTOCHref = async (r) => {
103
- const a = JSON.parse(r), d = typeof a == "string" ? await t.getDestination(a) : a;
104
- return [await t.getPageIndex(d[0]), null];
105
- }, o.getTOCFragment = (r) => r.documentElement, o.getCover = async () => u(await t.getPage(1), !0), o.destroy = () => t.destroy(), o;
106
- };
107
- export {
108
- y as makePDF
109
- };