@prose-reader/streamer 1.281.0 → 1.283.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.
- package/dist/Streamer.d.ts +7 -1
- package/dist/index.js +680 -563
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +11 -11
- package/dist/index.umd.cjs.map +1 -1
- package/dist/utils/createRangeResponse.d.ts +5 -0
- package/dist/utils/createRangeResponse.test.d.ts +1 -0
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,99 +1,120 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { XmlDocument as y, XmlTextNode as
|
|
3
|
-
import { Subject as
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
for (let
|
|
7
|
-
if (
|
|
8
|
-
return
|
|
1
|
+
import { detectMimeTypeFromName as x, Report as re, isXmlBasedMimeType as se, parseContentType as ie, urlJoin as S } from "@prose-reader/shared";
|
|
2
|
+
import { XmlDocument as y, XmlTextNode as oe, XmlElement as ae } from "xmldoc";
|
|
3
|
+
import { Subject as L, mergeMap as q, EMPTY as M, pairwise as ce, filter as C, startWith as de, from as A, tap as P, catchError as j, switchMap as I, merge as U, first as V, takeUntil as le, map as $, ignoreElements as pe, BehaviorSubject as me, distinctUntilChanged as ue, shareReplay as fe, NEVER as X, timer as he, finalize as ge, of as ye, lastValueFrom as be } from "rxjs";
|
|
4
|
+
const O = (t, e) => {
|
|
5
|
+
const i = t.split(/(\d+)/), s = e.split(/(\d+)/);
|
|
6
|
+
for (let n = 0, r = i.length; n < r; n++)
|
|
7
|
+
if (i[n] !== s[n])
|
|
8
|
+
return i[n]?.match(/\d/) ? +(i[n] || "") - +(s[n] || "") : (i[n] || "").localeCompare(s[n] || "");
|
|
9
9
|
return 1;
|
|
10
|
-
},
|
|
11
|
-
const e =
|
|
12
|
-
return e >= 0 ?
|
|
13
|
-
},
|
|
14
|
-
let
|
|
15
|
-
return e && (
|
|
16
|
-
filename:
|
|
17
|
-
records:
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
10
|
+
}, w = (t) => t.substring(t.lastIndexOf("/") + 1) || t, H = (t) => t.endsWith("/") ? t.slice(0, -1) : t, we = (t) => {
|
|
11
|
+
const e = t.lastIndexOf("/");
|
|
12
|
+
return e >= 0 ? t.substring(0, e) : "";
|
|
13
|
+
}, dt = async (t, { orderByAlpha: e, name: i } = {}) => {
|
|
14
|
+
let s = t;
|
|
15
|
+
return e && (s = s.slice().sort((n, r) => O(n.name, r.name))), {
|
|
16
|
+
filename: i || "",
|
|
17
|
+
records: s.map((n) => {
|
|
18
|
+
const r = n.size, o = w(n.name);
|
|
19
|
+
return n.isDir ? {
|
|
20
|
+
dir: !0,
|
|
21
|
+
basename: o,
|
|
22
|
+
uri: n.name,
|
|
23
|
+
size: r
|
|
24
|
+
} : {
|
|
25
|
+
dir: n.isDir,
|
|
26
|
+
basename: o,
|
|
27
|
+
encodingFormat: x(n.name),
|
|
28
|
+
uri: n.name,
|
|
29
|
+
blob: async () => new Blob([await n.data()], {
|
|
30
|
+
type: x(n.name) ?? ""
|
|
31
|
+
}),
|
|
32
|
+
string: async () => {
|
|
33
|
+
const a = await n.data();
|
|
34
|
+
return String.fromCharCode.apply(
|
|
35
|
+
null,
|
|
36
|
+
Array.from(new Uint16Array(a))
|
|
37
|
+
);
|
|
38
|
+
},
|
|
39
|
+
size: r
|
|
40
|
+
};
|
|
41
|
+
}),
|
|
31
42
|
close: () => Promise.resolve()
|
|
32
43
|
};
|
|
33
|
-
},
|
|
44
|
+
}, ve = "@prose-reader/streamer", m = re.namespace(ve, !1, {
|
|
34
45
|
color: "#ffae42"
|
|
35
|
-
}),
|
|
46
|
+
}), $e = (t) => {
|
|
36
47
|
const e = {};
|
|
37
|
-
for (const
|
|
38
|
-
const
|
|
39
|
-
let
|
|
40
|
-
for (let
|
|
41
|
-
const a =
|
|
42
|
-
a !== void 0 && (
|
|
48
|
+
for (const s of t) {
|
|
49
|
+
const n = s.split("/");
|
|
50
|
+
let r = e;
|
|
51
|
+
for (let o = 0; o < n.length; o++) {
|
|
52
|
+
const a = n[o];
|
|
53
|
+
a !== void 0 && (r[a] || (r[a] = {}), r = r[a]);
|
|
43
54
|
}
|
|
44
55
|
}
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
return p && Object.keys(p).length > 0 ? `${
|
|
48
|
-
${
|
|
56
|
+
const i = (s, n = "") => Object.keys(s).sort().map((r, o, a) => {
|
|
57
|
+
const c = o === a.length - 1, d = n + (c ? "└── " : "├── "), l = n + (c ? " " : "│ "), p = s[r];
|
|
58
|
+
return p && Object.keys(p).length > 0 ? `${d}${r}/
|
|
59
|
+
${i(p, l)}` : `${d}${r}`;
|
|
49
60
|
}).join(`
|
|
50
61
|
`);
|
|
51
|
-
return
|
|
52
|
-
},
|
|
53
|
-
let
|
|
54
|
-
e && (
|
|
55
|
-
const
|
|
56
|
-
filename:
|
|
57
|
-
records:
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
return i(e);
|
|
63
|
+
}, lt = async (t, { orderByAlpha: e, name: i } = {}) => {
|
|
64
|
+
let s = Object.values(t.files);
|
|
65
|
+
e && (s = s.slice().sort((r, o) => O(r.name, o.name)));
|
|
66
|
+
const n = {
|
|
67
|
+
filename: i || "",
|
|
68
|
+
records: s.map((r) => {
|
|
69
|
+
const o = r._data.uncompressedSize, a = w(r.name);
|
|
70
|
+
return r.dir ? {
|
|
71
|
+
dir: !0,
|
|
72
|
+
basename: a,
|
|
73
|
+
uri: r.name,
|
|
74
|
+
size: o
|
|
75
|
+
} : {
|
|
76
|
+
dir: !1,
|
|
77
|
+
basename: w(r.name),
|
|
78
|
+
uri: r.name,
|
|
79
|
+
encodingFormat: x(r.name),
|
|
80
|
+
blob: () => r.async("blob"),
|
|
81
|
+
string: () => r.async("string"),
|
|
82
|
+
...r.internalStream && {
|
|
83
|
+
stream: r.internalStream
|
|
84
|
+
},
|
|
85
|
+
// this is private API
|
|
86
|
+
// @ts-expect-error
|
|
87
|
+
size: r._data.uncompressedSize
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
70
90
|
close: () => Promise.resolve()
|
|
71
91
|
};
|
|
72
|
-
if (m.log("Generated archive",
|
|
73
|
-
const
|
|
92
|
+
if (m.log("Generated archive", n), process.env.NODE_ENV === "development" && m.isEnabled()) {
|
|
93
|
+
const r = $e(s.map((o) => o.name));
|
|
74
94
|
m.groupCollapsed(...m.getGroupArgs("Archive folder structure")), m.log(`
|
|
75
|
-
${
|
|
95
|
+
${r}`), m.groupEnd();
|
|
76
96
|
}
|
|
77
|
-
return
|
|
78
|
-
},
|
|
79
|
-
const
|
|
80
|
-
close: () =>
|
|
97
|
+
return n;
|
|
98
|
+
}, pt = async (t, { name: e } = {}) => {
|
|
99
|
+
const i = await t.getFilesArray(), s = {
|
|
100
|
+
close: () => t.close(),
|
|
81
101
|
filename: e ?? "",
|
|
82
|
-
records:
|
|
102
|
+
records: i.map((n) => ({
|
|
83
103
|
dir: !1,
|
|
84
|
-
basename:
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
104
|
+
basename: n.file.name,
|
|
105
|
+
encodingFormat: x(n.file.name),
|
|
106
|
+
size: n.file.size,
|
|
107
|
+
uri: `${n.path}${n.file.name}`,
|
|
108
|
+
blob: async () => await n.file.extract(),
|
|
109
|
+
string: async () => (await n.file.extract()).text()
|
|
89
110
|
}))
|
|
90
111
|
};
|
|
91
|
-
return m.log("Generated archive",
|
|
92
|
-
},
|
|
112
|
+
return m.log("Generated archive", s), s;
|
|
113
|
+
}, mt = async (t, {
|
|
93
114
|
mimeType: e,
|
|
94
|
-
direction:
|
|
115
|
+
direction: i
|
|
95
116
|
} = { mimeType: "text/plain" }) => {
|
|
96
|
-
const
|
|
117
|
+
const s = `
|
|
97
118
|
<?xml version="1.0" encoding="UTF-8"?>
|
|
98
119
|
<package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="ja" prefix="rendition: http://www.idpf.org/vocab/rendition/#"
|
|
99
120
|
unique-identifier="ootuya-id">
|
|
@@ -104,7 +125,7 @@ ${o}`), m.groupEnd();
|
|
|
104
125
|
<manifest>
|
|
105
126
|
<item id="p01" href="p01.txt" media-type="text/plain"/>
|
|
106
127
|
</manifest>
|
|
107
|
-
<spine page-progression-direction="${
|
|
128
|
+
<spine page-progression-direction="${i ?? "ltr"}">
|
|
108
129
|
<itemref idref="p01" />
|
|
109
130
|
</spine>
|
|
110
131
|
</package>
|
|
@@ -114,49 +135,49 @@ ${o}`), m.groupEnd();
|
|
|
114
135
|
records: [
|
|
115
136
|
{
|
|
116
137
|
dir: !1,
|
|
117
|
-
basename:
|
|
138
|
+
basename: w("generated.opf"),
|
|
118
139
|
uri: "generated.opf",
|
|
119
|
-
blob: async () => new Blob([
|
|
120
|
-
string: async () =>
|
|
140
|
+
blob: async () => new Blob([s]),
|
|
141
|
+
string: async () => s,
|
|
121
142
|
size: 0
|
|
122
143
|
},
|
|
123
144
|
{
|
|
124
145
|
dir: !1,
|
|
125
|
-
basename:
|
|
146
|
+
basename: w("p01.txt"),
|
|
126
147
|
uri: "p01.txt",
|
|
127
|
-
blob: async () => typeof
|
|
128
|
-
string: async () => typeof
|
|
129
|
-
size: typeof
|
|
148
|
+
blob: async () => typeof t == "string" ? new Blob([t]) : t,
|
|
149
|
+
string: async () => typeof t == "string" ? t : t.text(),
|
|
150
|
+
size: typeof t == "string" ? t.length : t.size,
|
|
130
151
|
encodingFormat: e
|
|
131
152
|
}
|
|
132
153
|
],
|
|
133
154
|
close: () => Promise.resolve()
|
|
134
155
|
};
|
|
135
|
-
},
|
|
136
|
-
const
|
|
156
|
+
}, ut = async (t, e) => {
|
|
157
|
+
const i = `
|
|
137
158
|
<?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
|
|
138
159
|
<metadata>
|
|
139
160
|
<meta property="rendition:layout">${e?.useRenditionFlow ? "reflowable" : "pre-paginated"}</meta>
|
|
140
161
|
${e?.useRenditionFlow ? '<meta property="rendition:flow">scrolled-continuous</meta>' : ""}
|
|
141
162
|
</metadata>
|
|
142
163
|
<manifest>
|
|
143
|
-
${
|
|
144
|
-
(
|
|
164
|
+
${t.map(
|
|
165
|
+
(r) => `<item id="${w(r)}" href="${r}" media-type="${x(r)}"/>`
|
|
145
166
|
).join(`
|
|
146
167
|
`)}
|
|
147
168
|
</manifest>
|
|
148
169
|
<spine>
|
|
149
|
-
${
|
|
170
|
+
${t.map((r) => `<itemref idref="${w(r)}" />`).join(`
|
|
150
171
|
`)}
|
|
151
172
|
</spine>
|
|
152
173
|
</package>
|
|
153
|
-
`,
|
|
174
|
+
`, s = t.map((r) => ({
|
|
154
175
|
dir: !1,
|
|
155
|
-
basename:
|
|
156
|
-
encodingFormat:
|
|
157
|
-
uri:
|
|
158
|
-
size: 100 /
|
|
159
|
-
blob: async () => (await fetch(
|
|
176
|
+
basename: w(r),
|
|
177
|
+
encodingFormat: x(r),
|
|
178
|
+
uri: r,
|
|
179
|
+
size: 100 / t.length,
|
|
180
|
+
blob: async () => (await fetch(r)).blob(),
|
|
160
181
|
string: async () => ""
|
|
161
182
|
}));
|
|
162
183
|
return {
|
|
@@ -167,487 +188,487 @@ ${o}`), m.groupEnd();
|
|
|
167
188
|
uri: "content.opf",
|
|
168
189
|
size: 0,
|
|
169
190
|
blob: async () => new Blob(),
|
|
170
|
-
string: async () =>
|
|
171
|
-
}, ...
|
|
191
|
+
string: async () => i
|
|
192
|
+
}, ...s],
|
|
172
193
|
close: () => Promise.resolve()
|
|
173
194
|
};
|
|
174
|
-
},
|
|
175
|
-
enableReport:
|
|
195
|
+
}, ft = ({
|
|
196
|
+
enableReport: t
|
|
176
197
|
} = {}) => {
|
|
177
|
-
m.enable(!!
|
|
178
|
-
},
|
|
179
|
-
const
|
|
180
|
-
(
|
|
181
|
-
).find((
|
|
198
|
+
m.enable(!!t);
|
|
199
|
+
}, E = (t) => {
|
|
200
|
+
const i = Object.values(t.records).filter(
|
|
201
|
+
(s) => !s.dir
|
|
202
|
+
).find((s) => s.uri.endsWith(".opf"));
|
|
182
203
|
return {
|
|
183
|
-
data:
|
|
184
|
-
basePath:
|
|
204
|
+
data: i,
|
|
205
|
+
basePath: i?.uri.substring(0, i.uri.lastIndexOf("/")) || ""
|
|
185
206
|
};
|
|
186
|
-
},
|
|
187
|
-
const
|
|
188
|
-
(
|
|
207
|
+
}, xe = ({ archive: t }) => async (e) => {
|
|
208
|
+
const i = t.records.find(
|
|
209
|
+
(n) => n.basename.toLowerCase() === "com.apple.ibooks.display-options.xml"
|
|
189
210
|
);
|
|
190
|
-
if (!
|
|
211
|
+
if (!i || i.dir)
|
|
191
212
|
return e;
|
|
192
|
-
const
|
|
213
|
+
const s = await (await i.blob()).text();
|
|
193
214
|
try {
|
|
194
|
-
const
|
|
215
|
+
const o = new y(s).childNamed("platform")?.childrenNamed("option")?.find((a) => a.attr.name === "fixed-layout")?.val || "false";
|
|
195
216
|
return {
|
|
196
217
|
...e,
|
|
197
|
-
renditionLayout:
|
|
218
|
+
renditionLayout: o === "true" ? "pre-paginated" : e.renditionLayout
|
|
198
219
|
};
|
|
199
|
-
} catch (
|
|
220
|
+
} catch (n) {
|
|
200
221
|
return console.error(
|
|
201
222
|
`Unable to parse com.apple.ibooks.display-options.xml for content
|
|
202
223
|
`,
|
|
203
|
-
|
|
204
|
-
), console.error(
|
|
224
|
+
s
|
|
225
|
+
), console.error(n), e;
|
|
205
226
|
}
|
|
206
|
-
},
|
|
227
|
+
}, Fe = async (t) => {
|
|
207
228
|
const e = {
|
|
208
229
|
renditionLayout: void 0
|
|
209
230
|
};
|
|
210
231
|
return await Promise.all(
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
const
|
|
214
|
-
|
|
232
|
+
t.records.map(async (i) => {
|
|
233
|
+
if (i.uri.endsWith("com.kobobooks.display-options.xml") && !i.dir) {
|
|
234
|
+
const n = new y(await i.string()).childNamed("platform")?.childNamed("option");
|
|
235
|
+
n?.attr?.name === "fixed-layout" && n.val === "true" && (e.renditionLayout = "pre-paginated");
|
|
215
236
|
}
|
|
216
237
|
})
|
|
217
238
|
), e;
|
|
218
|
-
},
|
|
219
|
-
const
|
|
239
|
+
}, Ee = ({ archive: t }) => async (e) => {
|
|
240
|
+
const i = await Fe(t);
|
|
220
241
|
return {
|
|
221
242
|
...e,
|
|
222
|
-
renditionLayout: e.renditionLayout ??
|
|
243
|
+
renditionLayout: e.renditionLayout ?? i.renditionLayout
|
|
223
244
|
};
|
|
224
|
-
},
|
|
225
|
-
const
|
|
245
|
+
}, Re = ({ archive: t, baseUrl: e }) => async () => {
|
|
246
|
+
const i = Object.values(t.records).filter((s) => !s.dir);
|
|
226
247
|
return {
|
|
227
|
-
filename:
|
|
228
|
-
title:
|
|
248
|
+
filename: t.filename,
|
|
249
|
+
title: t.records.find(({ dir: s }) => s)?.basename.replace(/\/$/, "") || t.filename,
|
|
229
250
|
renditionLayout: void 0,
|
|
230
251
|
renditionSpread: "auto",
|
|
231
252
|
readingDirection: "ltr",
|
|
232
|
-
spineItems:
|
|
233
|
-
const
|
|
253
|
+
spineItems: i.filter((s) => !s.basename.endsWith(".db")).map((s, n) => {
|
|
254
|
+
const r = e || (/^https?:\/\//.test(s.uri) ? "" : "file://");
|
|
234
255
|
return {
|
|
235
256
|
// some books such as cbz can have same basename inside different sub folder
|
|
236
257
|
// we need to make sure to have unique index
|
|
237
258
|
// /chap01/01.png, /chap02/01.png, etc
|
|
238
|
-
id: `${
|
|
239
|
-
index:
|
|
240
|
-
href: encodeURI(`${
|
|
259
|
+
id: `${n}.${s.basename}`,
|
|
260
|
+
index: n,
|
|
261
|
+
href: encodeURI(`${r}${s.uri}`),
|
|
241
262
|
renditionLayout: void 0,
|
|
242
|
-
progressionWeight: 1 /
|
|
263
|
+
progressionWeight: 1 / i.length,
|
|
243
264
|
pageSpreadLeft: void 0,
|
|
244
265
|
pageSpreadRight: void 0,
|
|
245
|
-
mediaType:
|
|
266
|
+
mediaType: s.encodingFormat
|
|
246
267
|
};
|
|
247
268
|
}),
|
|
248
|
-
items:
|
|
249
|
-
id: `${
|
|
250
|
-
href: encodeURI(`${e}${
|
|
269
|
+
items: i.map((s, n) => ({
|
|
270
|
+
id: `${n}.${s.basename}`,
|
|
271
|
+
href: encodeURI(`${e}${s.uri}`)
|
|
251
272
|
}))
|
|
252
273
|
};
|
|
253
|
-
},
|
|
254
|
-
archive:
|
|
274
|
+
}, J = async ({
|
|
275
|
+
archive: t
|
|
255
276
|
}) => {
|
|
256
|
-
const { data: e, basePath:
|
|
257
|
-
if (!
|
|
258
|
-
const
|
|
259
|
-
return
|
|
260
|
-
}, Ne = (
|
|
261
|
-
const e =
|
|
262
|
-
let
|
|
263
|
-
return e.find((
|
|
264
|
-
renditionLayout:
|
|
265
|
-
pageSpreadLeft: e.some((
|
|
266
|
-
pageSpreadRight: e.some((
|
|
277
|
+
const { data: e, basePath: i } = E(t) || {}, s = await e?.string();
|
|
278
|
+
if (!s) return [];
|
|
279
|
+
const n = new y(s), r = n.childNamed("manifest"), a = n.childNamed("spine")?.childrenNamed("itemref").map((l) => l.attr.idref), c = r?.childrenNamed("item").filter((l) => a.includes(l.attr.id || "")) || [];
|
|
280
|
+
return t.records.filter((l) => c.find((p) => i ? `${i}/${p.attr.href}` === l.uri : `${p.attr.href}` === l.uri));
|
|
281
|
+
}, Ne = (t) => {
|
|
282
|
+
const e = t.attr.properties?.split(" ") || [];
|
|
283
|
+
let i;
|
|
284
|
+
return e.find((s) => s === "rendition:layout-reflowable") && (i = "reflowable"), e.find((s) => s === "rendition:layout-pre-paginated") && (i = "pre-paginated"), {
|
|
285
|
+
renditionLayout: i,
|
|
286
|
+
pageSpreadLeft: e.some((s) => s === "page-spread-left") || void 0,
|
|
287
|
+
pageSpreadRight: e.some((s) => s === "page-spread-right") || void 0
|
|
267
288
|
};
|
|
268
|
-
}, Ae = (
|
|
269
|
-
const
|
|
289
|
+
}, Ae = (t, e, i) => {
|
|
290
|
+
const s = t.attr.href || "", n = i?.(t);
|
|
270
291
|
return {
|
|
271
|
-
href: e ? `${
|
|
272
|
-
id:
|
|
273
|
-
mediaType:
|
|
292
|
+
href: e ? `${n}${e}/${s}` : `${n}${s}`,
|
|
293
|
+
id: t.attr.id || "",
|
|
294
|
+
mediaType: t.attr["media-type"]
|
|
274
295
|
};
|
|
275
|
-
},
|
|
276
|
-
const
|
|
277
|
-
return
|
|
278
|
-
}, Ie = ({ archive:
|
|
279
|
-
const { data:
|
|
280
|
-
if (!
|
|
281
|
-
return
|
|
282
|
-
const
|
|
283
|
-
m.groupCollapsed(...m.getGroupArgs("OPF data")), m.log("data",
|
|
284
|
-
const
|
|
285
|
-
(
|
|
286
|
-
),
|
|
287
|
-
(
|
|
288
|
-
),
|
|
289
|
-
(
|
|
290
|
-
),
|
|
291
|
-
(
|
|
296
|
+
}, K = (t, e, i) => {
|
|
297
|
+
const s = t.childNamed("manifest"), { basePath: n } = E(e) || {};
|
|
298
|
+
return s?.childrenNamed("item")?.map((r) => Ae(r, n, i)) || [];
|
|
299
|
+
}, Ie = ({ archive: t, baseUrl: e }) => async (i) => {
|
|
300
|
+
const { data: s, basePath: n } = E(t) || {};
|
|
301
|
+
if (!s)
|
|
302
|
+
return i;
|
|
303
|
+
const r = await s.string();
|
|
304
|
+
m.groupCollapsed(...m.getGroupArgs("OPF data")), m.log("data", r), m.groupEnd();
|
|
305
|
+
const o = new y(r), a = o.childNamed("metadata"), c = o.childNamed("manifest"), d = o.childNamed("spine"), l = o.childNamed("guide"), p = a?.childNamed("dc:title"), g = a?.childrenNamed("meta") || [], b = g.find(
|
|
306
|
+
(u) => u.attr.property === "rendition:layout"
|
|
307
|
+
), R = g.find(
|
|
308
|
+
(u) => u.attr.property === "rendition:flow"
|
|
309
|
+
), f = g.find(
|
|
310
|
+
(u) => u.attr.property === "rendition:spread"
|
|
311
|
+
), T = b?.val, h = R?.val, F = f?.val, W = p?.val || t.records.find(({ dir: u }) => u)?.basename || "", ee = d?.attr["page-progression-direction"], te = (await J({ archive: t })).reduce(
|
|
312
|
+
(u, N) => N.size + u,
|
|
292
313
|
0
|
|
293
314
|
);
|
|
294
315
|
return {
|
|
295
|
-
filename:
|
|
296
|
-
renditionLayout:
|
|
316
|
+
filename: t.filename,
|
|
317
|
+
renditionLayout: T,
|
|
297
318
|
renditionFlow: h || "auto",
|
|
298
|
-
renditionSpread:
|
|
299
|
-
title:
|
|
300
|
-
readingDirection:
|
|
319
|
+
renditionSpread: F,
|
|
320
|
+
title: W,
|
|
321
|
+
readingDirection: ee || "ltr",
|
|
301
322
|
/**
|
|
302
323
|
* @see https://www.w3.org/TR/epub/#sec-itemref-elem
|
|
303
324
|
*/
|
|
304
|
-
spineItems:
|
|
305
|
-
const
|
|
325
|
+
spineItems: d?.childrenNamed("itemref").map((u, N) => {
|
|
326
|
+
const v = c?.childrenNamed("item").find((k) => k.attr.id === u?.attr.idref), z = v?.attr.href || "", ne = t.records.find((k) => k.uri.endsWith(z))?.size || 0, B = e || (/^https?:\/\//.test(z) ? "" : "file://"), D = Ne(u);
|
|
306
327
|
return {
|
|
307
|
-
...
|
|
308
|
-
id:
|
|
328
|
+
...D,
|
|
329
|
+
id: v?.attr.id || "",
|
|
309
330
|
index: N,
|
|
310
|
-
href:
|
|
311
|
-
renditionLayout:
|
|
312
|
-
progressionWeight:
|
|
331
|
+
href: v?.attr.href?.startsWith("https://") ? v?.attr.href : n ? `${B}${n}/${v?.attr.href}` : `${B}${v?.attr.href}`,
|
|
332
|
+
renditionLayout: D.renditionLayout ?? T,
|
|
333
|
+
progressionWeight: ne / te,
|
|
313
334
|
// size: itemSize
|
|
314
|
-
mediaType:
|
|
335
|
+
mediaType: v?.attr["media-type"]
|
|
315
336
|
};
|
|
316
337
|
}) || [],
|
|
317
|
-
items:
|
|
318
|
-
const N =
|
|
338
|
+
items: K(o, t, (u) => {
|
|
339
|
+
const N = u.attr.href || "";
|
|
319
340
|
return /^https?:\/\//.test(N) ? "" : e || "file://";
|
|
320
341
|
}),
|
|
321
|
-
guide:
|
|
322
|
-
href:
|
|
323
|
-
title:
|
|
324
|
-
type:
|
|
342
|
+
guide: l?.childrenNamed("reference").map((u) => ({
|
|
343
|
+
href: u.attr.href || "",
|
|
344
|
+
title: u.attr.title || "",
|
|
345
|
+
type: u.attr.type
|
|
325
346
|
}))
|
|
326
347
|
};
|
|
327
|
-
},
|
|
328
|
-
const e =
|
|
348
|
+
}, Se = (t) => {
|
|
349
|
+
const e = t.descendantWithPath("head")?.childrenNamed("meta").find((i) => i.attr.name === "viewport");
|
|
329
350
|
return !!(e && e.attr.name === "viewport");
|
|
330
|
-
},
|
|
331
|
-
if (!await e || !
|
|
332
|
-
mimeType:
|
|
333
|
-
uri:
|
|
351
|
+
}, Te = (t) => t.reduce(async (e, i) => {
|
|
352
|
+
if (!await e || !se({
|
|
353
|
+
mimeType: i.encodingFormat,
|
|
354
|
+
uri: i.uri
|
|
334
355
|
}))
|
|
335
356
|
return !1;
|
|
336
|
-
const
|
|
337
|
-
return
|
|
338
|
-
}, Promise.resolve(!0)),
|
|
339
|
-
if (e.renditionLayout === "reflowable" && e.spineItems.every((
|
|
340
|
-
const
|
|
341
|
-
if (await
|
|
357
|
+
const n = i.dir ? null : await i.string();
|
|
358
|
+
return n ? Se(new y(n)) : !1;
|
|
359
|
+
}, Promise.resolve(!0)), We = ({ archive: t }) => async (e) => {
|
|
360
|
+
if (e.renditionLayout === "reflowable" && e.spineItems.every((s) => s.renditionLayout === "reflowable")) {
|
|
361
|
+
const s = await J({ archive: t });
|
|
362
|
+
if (await Te(s))
|
|
342
363
|
return {
|
|
343
364
|
...e,
|
|
344
|
-
spineItems: e.spineItems.map((
|
|
345
|
-
...
|
|
365
|
+
spineItems: e.spineItems.map((r) => ({
|
|
366
|
+
...r,
|
|
346
367
|
renditionLayout: "pre-paginated"
|
|
347
368
|
})),
|
|
348
369
|
renditionLayout: "pre-paginated"
|
|
349
370
|
};
|
|
350
371
|
}
|
|
351
372
|
return e;
|
|
352
|
-
},
|
|
353
|
-
const
|
|
354
|
-
(
|
|
373
|
+
}, ke = ({ archive: t }) => async (e) => {
|
|
374
|
+
const i = t.records.find(
|
|
375
|
+
(r) => r.basename.toLowerCase() === "comicinfo.xml" && !r.dir
|
|
355
376
|
);
|
|
356
|
-
if (!
|
|
377
|
+
if (!i || i.dir)
|
|
357
378
|
return e;
|
|
358
|
-
const
|
|
379
|
+
const s = {
|
|
359
380
|
...e,
|
|
360
|
-
spineItems: e.spineItems.filter((
|
|
361
|
-
...
|
|
381
|
+
spineItems: e.spineItems.filter((r) => !r.id.toLowerCase().endsWith("comicinfo.xml")).map((r, o, a) => ({
|
|
382
|
+
...r,
|
|
362
383
|
progressionWeight: 1 / a.length
|
|
363
384
|
}))
|
|
364
|
-
},
|
|
385
|
+
}, n = await i.string();
|
|
365
386
|
try {
|
|
366
|
-
const
|
|
387
|
+
const o = new y(n).childNamed("Manga")?.val || "unknown";
|
|
367
388
|
return {
|
|
368
|
-
...
|
|
369
|
-
readingDirection:
|
|
389
|
+
...s,
|
|
390
|
+
readingDirection: o === "YesAndRightToLeft" ? "rtl" : "ltr"
|
|
370
391
|
};
|
|
371
|
-
} catch (
|
|
392
|
+
} catch (r) {
|
|
372
393
|
return console.error(`Unable to parse comicinfo.xml for content
|
|
373
|
-
`,
|
|
394
|
+
`, n), console.error(r), s;
|
|
374
395
|
}
|
|
375
|
-
},
|
|
396
|
+
}, Le = (t) => t.records.some((e) => e.basename.endsWith(".opf")), Ce = ({ archive: t }) => async (e) => Le(t) ? e : {
|
|
376
397
|
...e,
|
|
377
|
-
spineItems: e.spineItems.map((
|
|
378
|
-
const
|
|
379
|
-
(
|
|
380
|
-
),
|
|
398
|
+
spineItems: e.spineItems.map((s) => {
|
|
399
|
+
const n = t.records.find(
|
|
400
|
+
(o) => decodeURI(s.href).endsWith(o.uri)
|
|
401
|
+
), r = ie(n?.encodingFormat ?? "") || x(n?.basename ?? "");
|
|
381
402
|
return {
|
|
382
|
-
...
|
|
383
|
-
renditionLayout:
|
|
403
|
+
...s,
|
|
404
|
+
renditionLayout: r?.startsWith("image/") ? "pre-paginated" : s.renditionLayout
|
|
384
405
|
};
|
|
385
406
|
})
|
|
386
|
-
},
|
|
387
|
-
const
|
|
407
|
+
}, Y = (t) => t ? t.children.map((e) => e instanceof oe ? e.text : e instanceof ae ? Y(e) : "").join("").trim() : "", Q = (t, { basePath: e, baseUrl: i }) => {
|
|
408
|
+
const s = {
|
|
388
409
|
contents: [],
|
|
389
410
|
path: "",
|
|
390
411
|
href: "",
|
|
391
412
|
title: ""
|
|
392
413
|
};
|
|
393
|
-
let
|
|
394
|
-
|
|
395
|
-
let
|
|
396
|
-
|
|
397
|
-
const
|
|
398
|
-
if (
|
|
399
|
-
const a =
|
|
400
|
-
a && a.length > 0 && (
|
|
401
|
-
(
|
|
414
|
+
let n = t.childNamed("span") || t.childNamed("a");
|
|
415
|
+
s.title = (n?.attr.title || n?.val.trim() || Y(n)) ?? "";
|
|
416
|
+
let r = n?.name;
|
|
417
|
+
r !== "a" && (n = t.descendantWithPath(`${r}.a`), n && (r = n.name.toLowerCase())), r === "a" && n?.attr.href && (s.path = S(e, n.attr.href), s.href = S(i, e, n.attr.href));
|
|
418
|
+
const o = t.childNamed("ol");
|
|
419
|
+
if (o) {
|
|
420
|
+
const a = o.childrenNamed("li");
|
|
421
|
+
a && a.length > 0 && (s.contents = a.map(
|
|
422
|
+
(c) => Q(c, { basePath: e, baseUrl: i })
|
|
402
423
|
));
|
|
403
424
|
}
|
|
404
|
-
return
|
|
405
|
-
},
|
|
406
|
-
const
|
|
407
|
-
let
|
|
408
|
-
return
|
|
409
|
-
|
|
410
|
-
}),
|
|
411
|
-
},
|
|
412
|
-
const
|
|
413
|
-
if (
|
|
414
|
-
const
|
|
415
|
-
(
|
|
425
|
+
return s;
|
|
426
|
+
}, Pe = (t, { basePath: e, baseUrl: i }) => {
|
|
427
|
+
const s = [];
|
|
428
|
+
let n;
|
|
429
|
+
return t.descendantWithPath("body.nav.ol") ? n = t.descendantWithPath("body.nav.ol")?.children : t.descendantWithPath("body.section.nav.ol") && (n = t.descendantWithPath("body.section.nav.ol")?.children), n && n.length > 0 && n.filter((r) => r.name === "li").forEach((r) => {
|
|
430
|
+
s.push(Q(r, { basePath: e, baseUrl: i }));
|
|
431
|
+
}), s;
|
|
432
|
+
}, je = async (t, e, { baseUrl: i }) => {
|
|
433
|
+
const s = t.childNamed("manifest")?.childrenNamed("item").find((n) => n.attr.properties === "nav");
|
|
434
|
+
if (s) {
|
|
435
|
+
const n = Object.values(e.records).find(
|
|
436
|
+
(r) => r.uri.endsWith(s.attr.href || "")
|
|
416
437
|
);
|
|
417
|
-
if (
|
|
418
|
-
const
|
|
419
|
-
return
|
|
438
|
+
if (n && !n.dir) {
|
|
439
|
+
const r = new y(await n.string()), o = we(n.uri);
|
|
440
|
+
return Pe(r, { basePath: o, baseUrl: i });
|
|
420
441
|
}
|
|
421
442
|
}
|
|
422
|
-
},
|
|
443
|
+
}, Z = (t, {
|
|
423
444
|
opfBasePath: e,
|
|
424
|
-
baseUrl:
|
|
425
|
-
prefix:
|
|
445
|
+
baseUrl: i,
|
|
446
|
+
prefix: s
|
|
426
447
|
}) => {
|
|
427
|
-
const
|
|
428
|
-
title:
|
|
429
|
-
path:
|
|
430
|
-
href:
|
|
448
|
+
const n = t?.childNamed(`${s}content`)?.attr.src || "", r = {
|
|
449
|
+
title: t?.descendantWithPath(`${s}navLabel.${s}text`)?.val || "",
|
|
450
|
+
path: S(e, n),
|
|
451
|
+
href: S(i, e, n),
|
|
431
452
|
contents: []
|
|
432
|
-
},
|
|
433
|
-
return
|
|
434
|
-
(a) =>
|
|
435
|
-
)),
|
|
436
|
-
},
|
|
437
|
-
const
|
|
438
|
-
let
|
|
439
|
-
return
|
|
440
|
-
|
|
441
|
-
}),
|
|
442
|
-
},
|
|
443
|
-
opfData:
|
|
453
|
+
}, o = t.childrenNamed(`${s}navPoint`);
|
|
454
|
+
return o && o.length > 0 && (r.contents = o.map(
|
|
455
|
+
(a) => Z(a, { opfBasePath: e, baseUrl: i, prefix: s })
|
|
456
|
+
)), r;
|
|
457
|
+
}, Oe = (t, { opfBasePath: e, baseUrl: i }) => {
|
|
458
|
+
const s = [], n = t.name;
|
|
459
|
+
let r = "";
|
|
460
|
+
return n.indexOf(":") !== -1 && (r = `${n.split(":")[0]}:`), t.childNamed(`${r}navMap`)?.childrenNamed(`${r}navPoint`).forEach((o) => {
|
|
461
|
+
s.push(Z(o, { opfBasePath: e, baseUrl: i, prefix: r }));
|
|
462
|
+
}), s;
|
|
463
|
+
}, ze = async ({
|
|
464
|
+
opfData: t,
|
|
444
465
|
opfBasePath: e,
|
|
445
|
-
baseUrl:
|
|
446
|
-
archive:
|
|
466
|
+
baseUrl: i,
|
|
467
|
+
archive: s
|
|
447
468
|
}) => {
|
|
448
|
-
const
|
|
449
|
-
if (
|
|
450
|
-
const
|
|
451
|
-
if (
|
|
452
|
-
const a = `${e}${e === "" ? "" : "/"}${
|
|
453
|
-
(
|
|
469
|
+
const r = t.childNamed("spine")?.attr.toc;
|
|
470
|
+
if (r) {
|
|
471
|
+
const o = t.childNamed("manifest")?.childrenNamed("item").find((a) => a.attr.id === r);
|
|
472
|
+
if (o) {
|
|
473
|
+
const a = `${e}${e === "" ? "" : "/"}${o.attr.href}`, c = Object.values(s.records).find(
|
|
474
|
+
(d) => d.uri.endsWith(a)
|
|
454
475
|
);
|
|
455
|
-
if (
|
|
456
|
-
const
|
|
457
|
-
return
|
|
476
|
+
if (c && !c.dir) {
|
|
477
|
+
const d = new y(await c.string());
|
|
478
|
+
return Oe(d, { opfBasePath: e, baseUrl: i });
|
|
458
479
|
}
|
|
459
480
|
}
|
|
460
481
|
}
|
|
461
|
-
},
|
|
462
|
-
const { basePath:
|
|
463
|
-
baseUrl:
|
|
482
|
+
}, Be = async (t, e, { baseUrl: i }) => {
|
|
483
|
+
const { basePath: s } = E(e) || {}, n = await je(t, e, {
|
|
484
|
+
baseUrl: i
|
|
464
485
|
});
|
|
465
|
-
if (
|
|
466
|
-
return
|
|
467
|
-
const
|
|
468
|
-
opfData:
|
|
469
|
-
opfBasePath:
|
|
486
|
+
if (n)
|
|
487
|
+
return n;
|
|
488
|
+
const r = await ze({
|
|
489
|
+
opfData: t,
|
|
490
|
+
opfBasePath: s,
|
|
470
491
|
archive: e,
|
|
471
|
-
baseUrl:
|
|
492
|
+
baseUrl: i
|
|
472
493
|
});
|
|
473
|
-
if (
|
|
474
|
-
return
|
|
475
|
-
},
|
|
476
|
-
const
|
|
477
|
-
(
|
|
478
|
-
),
|
|
479
|
-
const
|
|
480
|
-
return
|
|
481
|
-
...
|
|
494
|
+
if (r)
|
|
495
|
+
return r;
|
|
496
|
+
}, De = (t, { baseUrl: e }) => {
|
|
497
|
+
const i = [...t.records].sort(
|
|
498
|
+
(n, r) => O(n.uri, r.uri)
|
|
499
|
+
), s = (n, r, o, a, c) => {
|
|
500
|
+
const d = n.find((g) => g.title === r), [l, ...p] = o;
|
|
501
|
+
return d ? l ? [
|
|
502
|
+
...n.filter((b) => b !== d),
|
|
482
503
|
{
|
|
483
|
-
...
|
|
504
|
+
...d,
|
|
484
505
|
contents: [
|
|
485
|
-
...
|
|
486
|
-
...
|
|
487
|
-
|
|
488
|
-
|
|
506
|
+
...d.contents,
|
|
507
|
+
...s(
|
|
508
|
+
d.contents,
|
|
509
|
+
l,
|
|
489
510
|
p,
|
|
490
511
|
a,
|
|
491
|
-
|
|
512
|
+
c
|
|
492
513
|
)
|
|
493
514
|
]
|
|
494
515
|
}
|
|
495
|
-
] :
|
|
496
|
-
...
|
|
516
|
+
] : d.path.split("/").length > c.split("/").length ? [
|
|
517
|
+
...n.filter((b) => b !== d),
|
|
497
518
|
{
|
|
498
|
-
...
|
|
499
|
-
path:
|
|
519
|
+
...d,
|
|
520
|
+
path: c,
|
|
500
521
|
href: a
|
|
501
522
|
}
|
|
502
|
-
] :
|
|
503
|
-
...
|
|
523
|
+
] : n : l ? [
|
|
524
|
+
...n,
|
|
504
525
|
{
|
|
505
|
-
contents:
|
|
526
|
+
contents: s(
|
|
506
527
|
[],
|
|
507
|
-
|
|
528
|
+
l,
|
|
508
529
|
p,
|
|
509
530
|
a,
|
|
510
|
-
|
|
531
|
+
c
|
|
511
532
|
),
|
|
512
533
|
href: a,
|
|
513
|
-
path:
|
|
514
|
-
title:
|
|
534
|
+
path: c,
|
|
535
|
+
title: r
|
|
515
536
|
}
|
|
516
537
|
] : [
|
|
517
|
-
...
|
|
538
|
+
...n,
|
|
518
539
|
{
|
|
519
540
|
contents: [],
|
|
520
541
|
href: a,
|
|
521
|
-
path:
|
|
522
|
-
title:
|
|
542
|
+
path: c,
|
|
543
|
+
title: r
|
|
523
544
|
}
|
|
524
545
|
];
|
|
525
546
|
};
|
|
526
|
-
return
|
|
527
|
-
if (
|
|
528
|
-
const
|
|
529
|
-
if (!a) return
|
|
530
|
-
const
|
|
531
|
-
return
|
|
547
|
+
return i.reduce((n, r) => {
|
|
548
|
+
if (r.dir) return n;
|
|
549
|
+
const o = r.uri.split("/").slice(0, -1), [a, ...c] = o;
|
|
550
|
+
if (!a) return n;
|
|
551
|
+
const d = S(e, encodeURI(r.uri)).replace(/\/$/, ""), l = r.uri.replace(/\/$/, "");
|
|
552
|
+
return s(n, a, c, d, l);
|
|
532
553
|
}, []);
|
|
533
|
-
},
|
|
534
|
-
const { data:
|
|
535
|
-
if (
|
|
536
|
-
const
|
|
537
|
-
return await
|
|
554
|
+
}, Me = async (t, { baseUrl: e }) => {
|
|
555
|
+
const { data: i } = E(t) || {};
|
|
556
|
+
if (i && !i.dir) {
|
|
557
|
+
const n = new y(await i.string());
|
|
558
|
+
return await Be(n, t, { baseUrl: e }) || [];
|
|
538
559
|
}
|
|
539
|
-
const
|
|
540
|
-
if (
|
|
541
|
-
return
|
|
542
|
-
},
|
|
543
|
-
if (
|
|
544
|
-
const
|
|
545
|
-
return
|
|
546
|
-
...
|
|
560
|
+
const s = De(t, { baseUrl: e });
|
|
561
|
+
if (s.length !== 0)
|
|
562
|
+
return s;
|
|
563
|
+
}, Ue = ({ archive: t, baseUrl: e }) => async (i) => {
|
|
564
|
+
if (i.nav) return i;
|
|
565
|
+
const s = await Me(t, { baseUrl: e });
|
|
566
|
+
return s ? {
|
|
567
|
+
...i,
|
|
547
568
|
nav: {
|
|
548
|
-
toc:
|
|
569
|
+
toc: s
|
|
549
570
|
}
|
|
550
|
-
} :
|
|
551
|
-
},
|
|
552
|
-
const
|
|
553
|
-
Ie({ archive:
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
Ce({ archive:
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
571
|
+
} : i;
|
|
572
|
+
}, Ve = async (t, { baseUrl: e = "" } = {}) => {
|
|
573
|
+
const i = [
|
|
574
|
+
Ie({ archive: t, baseUrl: e }),
|
|
575
|
+
ke({ archive: t }),
|
|
576
|
+
xe({ archive: t }),
|
|
577
|
+
Ce({ archive: t }),
|
|
578
|
+
We({ archive: t }),
|
|
579
|
+
Ee({ archive: t }),
|
|
580
|
+
Ue({ archive: t, baseUrl: e })
|
|
560
581
|
];
|
|
561
582
|
try {
|
|
562
|
-
const
|
|
563
|
-
if (m.log("Generated manifest",
|
|
564
|
-
const
|
|
583
|
+
const s = Re({ archive: t, baseUrl: e })(), n = await i.reduce(async (r, o) => await o(await r), s);
|
|
584
|
+
if (m.log("Generated manifest", n), process.env.NODE_ENV === "development" && m.isEnabled()) {
|
|
585
|
+
const r = JSON.stringify(n, null, 2);
|
|
565
586
|
m.groupCollapsed(...m.getGroupArgs("Generated manifest")), m.log(`
|
|
566
|
-
${
|
|
587
|
+
${r}`), m.groupEnd();
|
|
567
588
|
}
|
|
568
|
-
return
|
|
569
|
-
} catch (
|
|
570
|
-
throw m.error(
|
|
589
|
+
return n;
|
|
590
|
+
} catch (s) {
|
|
591
|
+
throw m.error(s), s;
|
|
571
592
|
}
|
|
572
|
-
}, Xe = (
|
|
573
|
-
const e =
|
|
593
|
+
}, Xe = (t) => {
|
|
594
|
+
const e = t.descendantWithPath("head")?.childrenNamed("meta").find((i) => i.attr.name === "calibre:cover");
|
|
574
595
|
return !!(e && e.attr.name === "calibre:cover");
|
|
575
|
-
},
|
|
596
|
+
}, He = (t) => t.descendantWithPath("body")?.descendantWithPath("div")?.childrenNamed("svg")?.find(
|
|
576
597
|
(e) => e.attr.width === "100%" && e.attr.preserveAspectRatio === "none"
|
|
577
|
-
),
|
|
578
|
-
const
|
|
579
|
-
(
|
|
598
|
+
), _e = ({ archive: t, resourcePath: e }) => async (i) => {
|
|
599
|
+
const s = Object.values(t.records).find(
|
|
600
|
+
(n) => n.uri === e && !n.dir
|
|
580
601
|
);
|
|
581
|
-
if (
|
|
582
|
-
const
|
|
583
|
-
if (Xe(
|
|
584
|
-
const
|
|
585
|
-
return
|
|
586
|
-
...
|
|
587
|
-
body:
|
|
602
|
+
if (s && !s.dir && s.basename.endsWith(".xhtml")) {
|
|
603
|
+
const n = i.body ?? await s.string(), r = new y(n);
|
|
604
|
+
if (Xe(r)) {
|
|
605
|
+
const o = He(r);
|
|
606
|
+
return o && delete o.attr.preserveAspectRatio, {
|
|
607
|
+
...i,
|
|
608
|
+
body: r?.toString()
|
|
588
609
|
};
|
|
589
610
|
}
|
|
590
611
|
}
|
|
591
|
-
return
|
|
592
|
-
},
|
|
593
|
-
const
|
|
594
|
-
(
|
|
612
|
+
return i;
|
|
613
|
+
}, Ge = ({ archive: t, resourcePath: e }) => async (i) => _e({ archive: t, resourcePath: e })(i), qe = ({ archive: t, resourcePath: e }) => async (i) => {
|
|
614
|
+
const s = Object.values(t.records).find(
|
|
615
|
+
(n) => n.uri === e && !n.dir
|
|
595
616
|
);
|
|
596
|
-
if (
|
|
597
|
-
const
|
|
617
|
+
if (s && !s.dir && s.basename.endsWith(".css")) {
|
|
618
|
+
const r = (i.body ?? await s.string()).replaceAll(
|
|
598
619
|
"-webkit-writing-mode",
|
|
599
620
|
"writing-mode"
|
|
600
621
|
);
|
|
601
622
|
return {
|
|
602
|
-
...
|
|
603
|
-
body:
|
|
623
|
+
...i,
|
|
624
|
+
body: r
|
|
604
625
|
};
|
|
605
626
|
}
|
|
606
|
-
return
|
|
607
|
-
},
|
|
608
|
-
const
|
|
609
|
-
if (
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
627
|
+
return i;
|
|
628
|
+
}, Je = async (t, e) => {
|
|
629
|
+
const s = await E(t).data?.string();
|
|
630
|
+
if (s) {
|
|
631
|
+
const n = new y(s), r = K(n, t, () => "");
|
|
632
|
+
if (r.find(
|
|
612
633
|
(a) => e.endsWith(a.href)
|
|
613
634
|
)?.mediaType)
|
|
614
635
|
return {
|
|
615
|
-
mediaType:
|
|
636
|
+
mediaType: r.find((a) => e.endsWith(a.href))?.mediaType
|
|
616
637
|
};
|
|
617
638
|
}
|
|
618
639
|
return {
|
|
619
|
-
mediaType:
|
|
640
|
+
mediaType: Ke(e)
|
|
620
641
|
};
|
|
621
|
-
},
|
|
622
|
-
if (
|
|
642
|
+
}, Ke = (t) => {
|
|
643
|
+
if (t.endsWith(".css"))
|
|
623
644
|
return "text/css; charset=UTF-8";
|
|
624
|
-
if (
|
|
645
|
+
if (t.endsWith(".jpg"))
|
|
625
646
|
return "image/jpg";
|
|
626
|
-
if (
|
|
647
|
+
if (t.endsWith(".xhtml"))
|
|
627
648
|
return "application/xhtml+xml";
|
|
628
|
-
if (
|
|
649
|
+
if (t.endsWith(".mp4"))
|
|
629
650
|
return "video/mp4";
|
|
630
|
-
if (
|
|
651
|
+
if (t.endsWith(".svg"))
|
|
631
652
|
return "image/svg+xml";
|
|
632
|
-
},
|
|
633
|
-
const
|
|
634
|
-
(
|
|
653
|
+
}, Ye = ({ archive: t, resourcePath: e }) => async (i) => {
|
|
654
|
+
const s = Object.values(t.records).find(
|
|
655
|
+
(r) => r.uri === e && !r.dir
|
|
635
656
|
);
|
|
636
|
-
if (!
|
|
637
|
-
const
|
|
657
|
+
if (!s || s.dir) return i;
|
|
658
|
+
const n = await Je(t, e);
|
|
638
659
|
return {
|
|
639
|
-
...
|
|
660
|
+
...i,
|
|
640
661
|
params: {
|
|
641
|
-
...
|
|
642
|
-
...
|
|
643
|
-
contentType:
|
|
662
|
+
...i.params,
|
|
663
|
+
...s?.encodingFormat && {
|
|
664
|
+
contentType: s.encodingFormat
|
|
644
665
|
},
|
|
645
|
-
...
|
|
646
|
-
contentType:
|
|
666
|
+
...n.mediaType && {
|
|
667
|
+
contentType: n.mediaType
|
|
647
668
|
}
|
|
648
669
|
}
|
|
649
670
|
};
|
|
650
|
-
},
|
|
671
|
+
}, _ = [
|
|
651
672
|
"div",
|
|
652
673
|
"span",
|
|
653
674
|
"p",
|
|
@@ -698,57 +719,57 @@ ${o}`), m.groupEnd();
|
|
|
698
719
|
"canvas",
|
|
699
720
|
"script",
|
|
700
721
|
"style"
|
|
701
|
-
],
|
|
702
|
-
const
|
|
703
|
-
(
|
|
722
|
+
], Qe = ({ archive: t, resourcePath: e }) => async (i) => {
|
|
723
|
+
const s = Object.values(t.records).find(
|
|
724
|
+
(n) => n.uri === e && !n.dir
|
|
704
725
|
);
|
|
705
|
-
if (
|
|
706
|
-
const
|
|
726
|
+
if (s && !s.dir && s.basename.endsWith(".xhtml")) {
|
|
727
|
+
const n = i.body ?? await s.string();
|
|
707
728
|
if (!new RegExp(
|
|
708
|
-
`<(${
|
|
729
|
+
`<(${_.join("|")})[\\s/>]`,
|
|
709
730
|
"i"
|
|
710
|
-
).test(
|
|
711
|
-
return
|
|
712
|
-
const
|
|
713
|
-
`<(${
|
|
731
|
+
).test(n))
|
|
732
|
+
return i;
|
|
733
|
+
const o = new RegExp(
|
|
734
|
+
`<(${_.join("|")})(\\s[^>]*)?\\s*/>`,
|
|
714
735
|
"gi"
|
|
715
|
-
), a =
|
|
716
|
-
|
|
717
|
-
(
|
|
736
|
+
), a = n.replace(
|
|
737
|
+
o,
|
|
738
|
+
(c, d, l = "") => `<${d} ${l.trim()}></${d}>`
|
|
718
739
|
);
|
|
719
740
|
return {
|
|
720
|
-
...
|
|
741
|
+
...i,
|
|
721
742
|
body: a
|
|
722
743
|
};
|
|
723
744
|
}
|
|
724
|
-
return
|
|
725
|
-
},
|
|
726
|
-
const
|
|
727
|
-
(
|
|
745
|
+
return i;
|
|
746
|
+
}, Ze = async (t, e) => {
|
|
747
|
+
const i = Object.values(t.records).find(
|
|
748
|
+
(r) => r.uri === e && !r.dir
|
|
728
749
|
);
|
|
729
|
-
if (!
|
|
750
|
+
if (!i || i.dir)
|
|
730
751
|
throw new Error(`no file found for resourcePath:${e}`);
|
|
731
|
-
const
|
|
752
|
+
const s = {
|
|
732
753
|
params: {}
|
|
733
|
-
},
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
754
|
+
}, n = [
|
|
755
|
+
Ye({ archive: t, resourcePath: e }),
|
|
756
|
+
Qe({ archive: t, resourcePath: e }),
|
|
757
|
+
qe({ archive: t, resourcePath: e }),
|
|
758
|
+
Ge({ archive: t, resourcePath: e })
|
|
738
759
|
];
|
|
739
760
|
try {
|
|
740
|
-
const
|
|
741
|
-
return m.log("Generated resource", e,
|
|
742
|
-
...
|
|
743
|
-
body:
|
|
761
|
+
const r = await n.reduce(async (o, a) => await a(await o), Promise.resolve(s));
|
|
762
|
+
return m.log("Generated resource", e, r), {
|
|
763
|
+
...r,
|
|
764
|
+
body: r.body ?? await i.blob()
|
|
744
765
|
};
|
|
745
|
-
} catch (
|
|
746
|
-
throw m.error(
|
|
766
|
+
} catch (r) {
|
|
767
|
+
throw m.error(r), r;
|
|
747
768
|
}
|
|
748
769
|
};
|
|
749
|
-
class
|
|
770
|
+
class et {
|
|
750
771
|
constructor(e) {
|
|
751
|
-
this.cleanArchiveAfter = e, this.state$ = new
|
|
772
|
+
this.cleanArchiveAfter = e, this.state$ = new me({
|
|
752
773
|
status: "idle",
|
|
753
774
|
locks: 0
|
|
754
775
|
});
|
|
@@ -757,121 +778,205 @@ class Ze {
|
|
|
757
778
|
this.state$.next({ ...this.state$.getValue(), ...e });
|
|
758
779
|
}
|
|
759
780
|
get locks$() {
|
|
760
|
-
return this.state$.pipe(
|
|
781
|
+
return this.state$.pipe($(({ locks: e }) => e));
|
|
761
782
|
}
|
|
762
783
|
get state() {
|
|
763
784
|
return this.state$.getValue();
|
|
764
785
|
}
|
|
765
786
|
get isUnlocked$() {
|
|
766
787
|
return this.locks$.pipe(
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
788
|
+
$((e) => e <= 0),
|
|
789
|
+
ue(),
|
|
790
|
+
fe()
|
|
770
791
|
);
|
|
771
792
|
}
|
|
772
793
|
get overTTL$() {
|
|
773
794
|
return this.isUnlocked$.pipe(
|
|
774
|
-
|
|
775
|
-
(e) => e ? this.cleanArchiveAfter === 1 / 0 ?
|
|
795
|
+
I(
|
|
796
|
+
(e) => e ? this.cleanArchiveAfter === 1 / 0 ? X : he(this.cleanArchiveAfter) : X
|
|
776
797
|
)
|
|
777
798
|
);
|
|
778
799
|
}
|
|
779
800
|
}
|
|
780
|
-
const
|
|
781
|
-
getArchive:
|
|
801
|
+
const tt = ({
|
|
802
|
+
getArchive: t,
|
|
782
803
|
cleanArchiveAfter: e = 300 * 1e3
|
|
783
804
|
// 5mn
|
|
784
805
|
}) => {
|
|
785
|
-
const
|
|
786
|
-
|
|
787
|
-
const
|
|
788
|
-
if (!
|
|
806
|
+
const i = new L(), s = new L(), n = new L(), r = {}, o = i.pipe(
|
|
807
|
+
q((d) => {
|
|
808
|
+
const l = r[d];
|
|
809
|
+
if (!l || l.state.status !== "idle") return M;
|
|
789
810
|
let p = !1;
|
|
790
811
|
const g = (h) => {
|
|
791
812
|
m.debug(`Cleaning up archive with key: ${h}`);
|
|
792
|
-
const
|
|
793
|
-
delete
|
|
813
|
+
const F = r[h];
|
|
814
|
+
delete r[h], p || (F?.state.archive?.close(), p = !0);
|
|
794
815
|
};
|
|
795
|
-
|
|
816
|
+
l.update({
|
|
796
817
|
status: "loading"
|
|
797
818
|
});
|
|
798
|
-
const b =
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
819
|
+
const b = l.locks$, R = l.isUnlocked$, f = b.pipe(
|
|
820
|
+
ce(),
|
|
821
|
+
C(([h, F]) => F > h),
|
|
822
|
+
de(!0)
|
|
802
823
|
);
|
|
803
|
-
return
|
|
824
|
+
return A(t(d)).pipe(
|
|
804
825
|
P((h) => {
|
|
805
|
-
|
|
826
|
+
l.update({
|
|
806
827
|
archive: h,
|
|
807
828
|
status: "success"
|
|
808
829
|
});
|
|
809
830
|
}),
|
|
810
|
-
|
|
831
|
+
j((h) => (g(d), l.update({
|
|
811
832
|
status: "error",
|
|
812
833
|
error: h
|
|
813
|
-
}),
|
|
814
|
-
|
|
815
|
-
const h =
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
834
|
+
}), M)),
|
|
835
|
+
I(() => {
|
|
836
|
+
const h = f.pipe(
|
|
837
|
+
I(() => n),
|
|
838
|
+
I(() => R),
|
|
839
|
+
C((W) => W)
|
|
819
840
|
);
|
|
820
|
-
return
|
|
841
|
+
return U(h, l.overTTL$).pipe(
|
|
821
842
|
V(),
|
|
822
843
|
P(() => {
|
|
823
|
-
g(
|
|
844
|
+
g(d);
|
|
824
845
|
})
|
|
825
846
|
);
|
|
826
847
|
})
|
|
827
848
|
);
|
|
828
849
|
}),
|
|
829
|
-
|
|
830
|
-
), a = (
|
|
831
|
-
let
|
|
832
|
-
const p =
|
|
833
|
-
|
|
850
|
+
le(s)
|
|
851
|
+
), a = (d) => {
|
|
852
|
+
let l = !1;
|
|
853
|
+
const p = r[d] ?? new et(e);
|
|
854
|
+
r[d] = p, p.update({
|
|
834
855
|
locks: p.state.locks + 1
|
|
835
856
|
});
|
|
836
857
|
const g = () => {
|
|
837
|
-
|
|
858
|
+
l || (l = !0, p.update({
|
|
838
859
|
locks: p.state.locks - 1
|
|
839
860
|
}));
|
|
840
861
|
};
|
|
841
|
-
|
|
862
|
+
i.next(d);
|
|
842
863
|
const b = p.state$.pipe(
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
),
|
|
846
|
-
P(({ error:
|
|
847
|
-
if (
|
|
848
|
-
throw
|
|
864
|
+
$(({ archive: f }) => f),
|
|
865
|
+
C((f) => !!f)
|
|
866
|
+
), R = p.state$.pipe(
|
|
867
|
+
P(({ error: f }) => {
|
|
868
|
+
if (f)
|
|
869
|
+
throw f;
|
|
849
870
|
}),
|
|
850
|
-
|
|
871
|
+
pe()
|
|
851
872
|
);
|
|
852
|
-
return
|
|
873
|
+
return U(b, R).pipe(
|
|
853
874
|
V(),
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
throw g(),
|
|
875
|
+
$((f) => ({ archive: f, release: g })),
|
|
876
|
+
j((f) => {
|
|
877
|
+
throw g(), f;
|
|
857
878
|
})
|
|
858
879
|
);
|
|
859
|
-
},
|
|
860
|
-
|
|
880
|
+
}, c = () => {
|
|
881
|
+
n.next();
|
|
861
882
|
};
|
|
862
|
-
return
|
|
883
|
+
return o.subscribe(), {
|
|
863
884
|
access: a,
|
|
864
|
-
purge:
|
|
865
|
-
_archives:
|
|
885
|
+
purge: c,
|
|
886
|
+
_archives: r
|
|
866
887
|
};
|
|
888
|
+
}, G = (t) => t ? /^\d+$/.test(t) ? {
|
|
889
|
+
valid: !0,
|
|
890
|
+
value: Number.parseInt(t, 10)
|
|
891
|
+
} : {
|
|
892
|
+
valid: !1,
|
|
893
|
+
value: void 0
|
|
894
|
+
} : {
|
|
895
|
+
valid: !0,
|
|
896
|
+
value: void 0
|
|
897
|
+
}, nt = (t) => {
|
|
898
|
+
if (!t.toLowerCase().startsWith("bytes="))
|
|
899
|
+
return {
|
|
900
|
+
kind: "missing"
|
|
901
|
+
};
|
|
902
|
+
const e = t.slice(6).trim();
|
|
903
|
+
if (!e)
|
|
904
|
+
return {
|
|
905
|
+
kind: "invalid"
|
|
906
|
+
};
|
|
907
|
+
if (e.includes(","))
|
|
908
|
+
return {
|
|
909
|
+
kind: "multi"
|
|
910
|
+
};
|
|
911
|
+
const i = /^(\d*)-(\d*)$/.exec(e);
|
|
912
|
+
if (!i)
|
|
913
|
+
return {
|
|
914
|
+
kind: "invalid"
|
|
915
|
+
};
|
|
916
|
+
const [, s = "", n = ""] = i, r = G(s.trim()), o = G(n.trim());
|
|
917
|
+
return !r.valid || !o.valid ? {
|
|
918
|
+
kind: "invalid"
|
|
919
|
+
} : {
|
|
920
|
+
kind: "single",
|
|
921
|
+
start: r.value,
|
|
922
|
+
end: o.value
|
|
923
|
+
};
|
|
924
|
+
}, rt = ({
|
|
925
|
+
body: t,
|
|
926
|
+
contentType: e,
|
|
927
|
+
rangeHeader: i
|
|
928
|
+
}) => {
|
|
929
|
+
const s = new Headers(), n = t instanceof Blob ? t : new Blob([t]), r = n.size;
|
|
930
|
+
if (e && s.set("Content-Type", e), s.set("Accept-Ranges", "bytes"), s.set("Content-Length", String(r)), !i)
|
|
931
|
+
return new Response(t, {
|
|
932
|
+
status: 200,
|
|
933
|
+
headers: s
|
|
934
|
+
});
|
|
935
|
+
const o = nt(i);
|
|
936
|
+
if (o.kind === "missing" || o.kind === "multi")
|
|
937
|
+
return new Response(t, {
|
|
938
|
+
status: 200,
|
|
939
|
+
headers: s
|
|
940
|
+
});
|
|
941
|
+
if (o.kind === "invalid")
|
|
942
|
+
return new Response(null, {
|
|
943
|
+
status: 416,
|
|
944
|
+
headers: {
|
|
945
|
+
"Content-Range": `bytes */${r}`
|
|
946
|
+
}
|
|
947
|
+
});
|
|
948
|
+
let a = o.start, c = o.end;
|
|
949
|
+
if (a === void 0 && c === void 0)
|
|
950
|
+
return new Response(null, {
|
|
951
|
+
status: 416,
|
|
952
|
+
headers: {
|
|
953
|
+
"Content-Range": `bytes */${r}`
|
|
954
|
+
}
|
|
955
|
+
});
|
|
956
|
+
if (a === void 0) {
|
|
957
|
+
const l = Math.min(c ?? 0, r);
|
|
958
|
+
a = Math.max(0, r - l), c = r - 1;
|
|
959
|
+
} else (c === void 0 || c >= r) && (c = r - 1);
|
|
960
|
+
if (a < 0 || c < 0 || a >= r || c >= r || a > c)
|
|
961
|
+
return new Response(null, {
|
|
962
|
+
status: 416,
|
|
963
|
+
headers: {
|
|
964
|
+
"Content-Range": `bytes */${r}`
|
|
965
|
+
}
|
|
966
|
+
});
|
|
967
|
+
const d = n.slice(a, c + 1);
|
|
968
|
+
return s.set("Content-Length", String(d.size)), s.set("Content-Range", `bytes ${a}-${c}/${r}`), new Response(d, {
|
|
969
|
+
status: 206,
|
|
970
|
+
headers: s
|
|
971
|
+
});
|
|
867
972
|
};
|
|
868
|
-
class
|
|
973
|
+
class st {
|
|
869
974
|
constructor({
|
|
870
975
|
onError: e,
|
|
871
|
-
onManifestSuccess:
|
|
872
|
-
...
|
|
976
|
+
onManifestSuccess: i,
|
|
977
|
+
...s
|
|
873
978
|
}) {
|
|
874
|
-
this.onError = (
|
|
979
|
+
this.onError = (n) => (console.error(n), new Response(String(n), { status: 500 })), this.epubLoader = tt(s), this.onManifestSuccess = i ?? (({ manifest: n }) => Promise.resolve(n)), this.onError = e ?? this.onError;
|
|
875
980
|
}
|
|
876
981
|
prune() {
|
|
877
982
|
this.epubLoader.purge();
|
|
@@ -881,99 +986,111 @@ class tt {
|
|
|
881
986
|
}
|
|
882
987
|
accessArchiveWithoutLock(e) {
|
|
883
988
|
return this.accessArchive(e).pipe(
|
|
884
|
-
|
|
989
|
+
$(({ archive: i, release: s }) => (s(), i))
|
|
885
990
|
);
|
|
886
991
|
}
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
992
|
+
withArchiveResponse({
|
|
993
|
+
key: e,
|
|
994
|
+
getResponse: i
|
|
995
|
+
}) {
|
|
996
|
+
const s = this.accessArchive(e).pipe(
|
|
997
|
+
q(
|
|
998
|
+
({ archive: n, release: r }) => A(i(n)).pipe(
|
|
999
|
+
ge(() => {
|
|
1000
|
+
r();
|
|
1001
|
+
})
|
|
1002
|
+
)
|
|
1003
|
+
),
|
|
1004
|
+
j((n) => ye(this.onError(n)))
|
|
1005
|
+
);
|
|
1006
|
+
return be(s);
|
|
1007
|
+
}
|
|
1008
|
+
fetchManifest({ key: e, baseUrl: i }) {
|
|
1009
|
+
return this.withArchiveResponse({
|
|
1010
|
+
key: e,
|
|
1011
|
+
getResponse: (s) => A(
|
|
1012
|
+
Ve(s, { baseUrl: i })
|
|
891
1013
|
).pipe(
|
|
892
|
-
|
|
893
|
-
(
|
|
1014
|
+
I(
|
|
1015
|
+
(r) => A(this.onManifestSuccess({ manifest: r, archive: s }))
|
|
894
1016
|
),
|
|
895
|
-
|
|
896
|
-
(
|
|
1017
|
+
$(
|
|
1018
|
+
(r) => new Response(JSON.stringify(r), {
|
|
897
1019
|
status: 200
|
|
898
1020
|
})
|
|
899
|
-
)
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
})
|
|
903
|
-
)),
|
|
904
|
-
W((t) => G(this.onError(t)))
|
|
905
|
-
);
|
|
906
|
-
return q(r);
|
|
1021
|
+
)
|
|
1022
|
+
)
|
|
1023
|
+
});
|
|
907
1024
|
}
|
|
908
1025
|
fetchResource({
|
|
909
1026
|
key: e,
|
|
910
|
-
resourcePath:
|
|
1027
|
+
resourcePath: i,
|
|
1028
|
+
request: s
|
|
911
1029
|
}) {
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
1030
|
+
return this.withArchiveResponse({
|
|
1031
|
+
key: e,
|
|
1032
|
+
getResponse: (n) => {
|
|
1033
|
+
const r = i.replaceAll("file://", "");
|
|
1034
|
+
return A(
|
|
1035
|
+
Ze(n, r)
|
|
917
1036
|
).pipe(
|
|
918
|
-
|
|
919
|
-
(
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
"Content-Type": l.params.contentType
|
|
924
|
-
}
|
|
925
|
-
}
|
|
1037
|
+
$(
|
|
1038
|
+
(a) => rt({
|
|
1039
|
+
body: a.body ?? "",
|
|
1040
|
+
contentType: a.params.contentType,
|
|
1041
|
+
rangeHeader: s?.headers.get("range")
|
|
926
1042
|
})
|
|
927
|
-
)
|
|
928
|
-
_(() => {
|
|
929
|
-
o();
|
|
930
|
-
})
|
|
1043
|
+
)
|
|
931
1044
|
);
|
|
932
|
-
}
|
|
933
|
-
|
|
934
|
-
);
|
|
935
|
-
return q(r);
|
|
1045
|
+
}
|
|
1046
|
+
});
|
|
936
1047
|
}
|
|
937
1048
|
}
|
|
938
|
-
class
|
|
1049
|
+
class ht extends st {
|
|
939
1050
|
constructor({
|
|
940
1051
|
getUriInfo: e,
|
|
941
|
-
...
|
|
1052
|
+
...i
|
|
942
1053
|
}) {
|
|
943
|
-
super(
|
|
1054
|
+
super(i), this.getUriInfo = e, this.fetchEventListener = this.fetchEventListener.bind(this);
|
|
944
1055
|
}
|
|
945
1056
|
fetchEventListener(e) {
|
|
946
1057
|
try {
|
|
947
|
-
const
|
|
948
|
-
if (!
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
), [
|
|
952
|
-
|
|
1058
|
+
const i = this.getUriInfo(e);
|
|
1059
|
+
if (!i) return;
|
|
1060
|
+
const s = H(i.baseUrl), n = e.request.url.substring(
|
|
1061
|
+
s.length + 1
|
|
1062
|
+
), [r = ""] = n.split("/"), o = decodeURIComponent(
|
|
1063
|
+
H(n.substring(r.length + 1))
|
|
1064
|
+
);
|
|
1065
|
+
n.endsWith("/manifest") ? e.respondWith(
|
|
1066
|
+
this.fetchManifest({ key: r, baseUrl: `${s}/${r}/` })
|
|
1067
|
+
) : e.respondWith(
|
|
1068
|
+
this.fetchResource({
|
|
1069
|
+
key: r,
|
|
1070
|
+
resourcePath: o,
|
|
1071
|
+
request: e.request
|
|
1072
|
+
})
|
|
953
1073
|
);
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
) : e.respondWith(this.fetchResource({ key: o, resourcePath: i }));
|
|
957
|
-
} catch (s) {
|
|
958
|
-
e.respondWith(new Response(String(s), { status: 500 }));
|
|
1074
|
+
} catch (i) {
|
|
1075
|
+
e.respondWith(new Response(String(i), { status: 500 }));
|
|
959
1076
|
}
|
|
960
1077
|
}
|
|
961
1078
|
}
|
|
962
1079
|
export {
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
1080
|
+
ht as ServiceWorkerStreamer,
|
|
1081
|
+
st as Streamer,
|
|
1082
|
+
ft as configure,
|
|
1083
|
+
dt as createArchiveFromArrayBufferList,
|
|
1084
|
+
lt as createArchiveFromJszip,
|
|
1085
|
+
pt as createArchiveFromLibArchive,
|
|
1086
|
+
mt as createArchiveFromText,
|
|
1087
|
+
ut as createArchiveFromUrls,
|
|
1088
|
+
Ve as generateManifestFromArchive,
|
|
1089
|
+
Ze as generateResourceFromArchive,
|
|
1090
|
+
E as getArchiveOpfInfo,
|
|
1091
|
+
we as getUriBasePath,
|
|
1092
|
+
w as getUriBasename,
|
|
1093
|
+
H as removeTrailingSlash,
|
|
1094
|
+
O as sortByTitleComparator
|
|
978
1095
|
};
|
|
979
1096
|
//# sourceMappingURL=index.js.map
|