@prose-reader/streamer 1.301.0 → 1.303.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/archives/createArchiveFromArrayBufferList.d.ts +2 -1
- package/dist/archives/createArchiveFromJszip.d.ts +2 -1
- package/dist/archives/createArchiveFromLibArchive.d.ts +2 -1
- package/dist/archives/getArchiveHasComicInfo.d.ts +2 -0
- package/dist/archives/types.d.ts +9 -3
- package/dist/epubs/getArchiveOpfInfo.d.ts +1 -10
- package/dist/epubs/getSpineItemFilesFromArchive.d.ts +1 -16
- package/dist/generators/manifest/hooks/finalDefaults.d.ts +2 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +259 -239
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +10 -10
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,50 +1,55 @@
|
|
|
1
|
-
import { detectMimeTypeFromName as b, Report as
|
|
2
|
-
import { parseOpf as
|
|
3
|
-
import { XmlDocument as R, XmlTextNode as
|
|
4
|
-
import { Subject as x, mergeMap as
|
|
5
|
-
const
|
|
1
|
+
import { detectMimeTypeFromName as b, Report as ie, escapeXmlAttributeValue as N, isXmlBasedMimeType as ae, parseContentType as J, isMediaContentMimeType as ce, urlJoin as T } from "@prose-reader/shared";
|
|
2
|
+
import { COMIC_INFO_FILENAME as W, parseOpf as de, APPLE_IBOOKS_DISPLAY_OPTIONS_FILENAME as Z, parseAppleDisplayOptionsXml as le, resolveArchiveMetadata as S, parseComicInfo as ue, KOBO_DISPLAY_OPTIONS_FILENAME as z, parseKoboXml as pe, tokenizeXmlSpaceSeparatedList as fe } from "@prose-reader/archive-parser";
|
|
3
|
+
import { XmlDocument as R, XmlTextNode as me, XmlElement as he } from "xmldoc";
|
|
4
|
+
import { Subject as x, mergeMap as Y, EMPTY as O, pairwise as ge, filter as E, startWith as ye, from as F, tap as k, catchError as C, switchMap as I, merge as M, first as D, takeUntil as be, map as $, ignoreElements as ve, BehaviorSubject as we, distinctUntilChanged as $e, shareReplay as Ae, NEVER as B, timer as Fe, finalize as Ie, of as Te, lastValueFrom as Se } from "rxjs";
|
|
5
|
+
const P = (e, t) => {
|
|
6
6
|
const o = e.split(/(\d+)/), r = t.split(/(\d+)/);
|
|
7
7
|
for (let n = 0, s = o.length; n < s; n++)
|
|
8
8
|
if (o[n] !== r[n])
|
|
9
9
|
return o[n]?.match(/\d/) ? +(o[n] || "") - +(r[n] || "") : (o[n] || "").localeCompare(r[n] || "");
|
|
10
10
|
return 1;
|
|
11
|
-
}, A = (e) => e.substring(e.lastIndexOf("/") + 1) || e, j = (e) => e.endsWith("/") ? e.slice(0, -1) : e,
|
|
11
|
+
}, A = (e) => e.substring(e.lastIndexOf("/") + 1) || e, j = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Re = (e) => {
|
|
12
12
|
const t = e.lastIndexOf("/");
|
|
13
13
|
return t >= 0 ? e.substring(0, t) : "";
|
|
14
|
-
},
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
}, Dt = async (e, {
|
|
15
|
+
orderByAlpha: t,
|
|
16
|
+
name: o,
|
|
17
|
+
encodingFormat: r
|
|
18
|
+
} = {}) => {
|
|
19
|
+
let n = e;
|
|
20
|
+
return t && (n = n.slice().sort((s, i) => P(s.name, i.name))), {
|
|
17
21
|
filename: o || "",
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
22
|
+
encodingFormat: r,
|
|
23
|
+
records: n.map((s) => {
|
|
24
|
+
const i = s.size, a = A(s.name);
|
|
25
|
+
return s.isDir ? {
|
|
21
26
|
dir: !0,
|
|
22
|
-
basename:
|
|
23
|
-
uri:
|
|
24
|
-
size:
|
|
27
|
+
basename: a,
|
|
28
|
+
uri: s.name,
|
|
29
|
+
size: i
|
|
25
30
|
} : {
|
|
26
|
-
dir:
|
|
27
|
-
basename:
|
|
28
|
-
encodingFormat: b(
|
|
29
|
-
uri:
|
|
30
|
-
blob: async () => new Blob([await
|
|
31
|
-
type: b(
|
|
31
|
+
dir: s.isDir,
|
|
32
|
+
basename: a,
|
|
33
|
+
encodingFormat: b(s.name),
|
|
34
|
+
uri: s.name,
|
|
35
|
+
blob: async () => new Blob([await s.data()], {
|
|
36
|
+
type: b(s.name) ?? ""
|
|
32
37
|
}),
|
|
33
38
|
string: async () => {
|
|
34
|
-
const
|
|
39
|
+
const c = await s.data();
|
|
35
40
|
return String.fromCharCode.apply(
|
|
36
41
|
null,
|
|
37
|
-
Array.from(new Uint16Array(
|
|
42
|
+
Array.from(new Uint16Array(c))
|
|
38
43
|
);
|
|
39
44
|
},
|
|
40
|
-
size:
|
|
45
|
+
size: i
|
|
41
46
|
};
|
|
42
47
|
}),
|
|
43
48
|
close: () => Promise.resolve()
|
|
44
49
|
};
|
|
45
|
-
},
|
|
50
|
+
}, Le = "@prose-reader/streamer", f = ie.namespace(Le, !1, {
|
|
46
51
|
color: "#ffae42"
|
|
47
|
-
}),
|
|
52
|
+
}), xe = (e) => {
|
|
48
53
|
const t = {};
|
|
49
54
|
for (const r of e) {
|
|
50
55
|
const n = r.split("/");
|
|
@@ -61,57 +66,66 @@ ${o(p, u)}` : `${d}${s}`;
|
|
|
61
66
|
}).join(`
|
|
62
67
|
`);
|
|
63
68
|
return o(t);
|
|
64
|
-
},
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
69
|
+
}, Bt = async (e, {
|
|
70
|
+
orderByAlpha: t,
|
|
71
|
+
name: o,
|
|
72
|
+
encodingFormat: r
|
|
73
|
+
} = {}) => {
|
|
74
|
+
let n = Object.values(e.files);
|
|
75
|
+
t && (n = n.slice().sort((i, a) => P(i.name, a.name)));
|
|
76
|
+
const s = {
|
|
68
77
|
filename: o || "",
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
78
|
+
encodingFormat: r,
|
|
79
|
+
records: n.map((i) => {
|
|
80
|
+
const a = i._data.uncompressedSize, c = A(i.name);
|
|
81
|
+
return i.dir ? {
|
|
72
82
|
dir: !0,
|
|
73
|
-
basename:
|
|
74
|
-
uri:
|
|
75
|
-
size:
|
|
83
|
+
basename: c,
|
|
84
|
+
uri: i.name,
|
|
85
|
+
size: a
|
|
76
86
|
} : {
|
|
77
87
|
dir: !1,
|
|
78
|
-
basename: A(
|
|
79
|
-
uri:
|
|
80
|
-
encodingFormat: b(
|
|
81
|
-
blob: () =>
|
|
82
|
-
string: () =>
|
|
83
|
-
...
|
|
84
|
-
stream:
|
|
88
|
+
basename: A(i.name),
|
|
89
|
+
uri: i.name,
|
|
90
|
+
encodingFormat: b(i.name),
|
|
91
|
+
blob: () => i.async("blob"),
|
|
92
|
+
string: () => i.async("string"),
|
|
93
|
+
...i.internalStream && {
|
|
94
|
+
stream: i.internalStream
|
|
85
95
|
},
|
|
86
96
|
// this is private API
|
|
87
97
|
// @ts-expect-error
|
|
88
|
-
size:
|
|
98
|
+
size: i._data.uncompressedSize
|
|
89
99
|
};
|
|
90
100
|
}),
|
|
91
101
|
close: () => Promise.resolve()
|
|
92
102
|
};
|
|
93
|
-
if (f.log("Generated archive",
|
|
94
|
-
const
|
|
103
|
+
if (f.log("Generated archive", s), process.env.NODE_ENV === "development" && f.isEnabled()) {
|
|
104
|
+
const i = xe(n.map((a) => a.name));
|
|
95
105
|
f.groupCollapsed(...f.getGroupArgs("Archive folder structure")), f.log(`
|
|
96
|
-
${
|
|
106
|
+
${i}`), f.groupEnd();
|
|
97
107
|
}
|
|
98
|
-
return
|
|
99
|
-
},
|
|
100
|
-
|
|
108
|
+
return s;
|
|
109
|
+
}, jt = async (e, {
|
|
110
|
+
name: t,
|
|
111
|
+
encodingFormat: o
|
|
112
|
+
} = {}) => {
|
|
113
|
+
const r = await e.getFilesArray(), n = {
|
|
101
114
|
close: () => e.close(),
|
|
102
115
|
filename: t ?? "",
|
|
103
|
-
|
|
116
|
+
encodingFormat: o,
|
|
117
|
+
records: r.map((s) => ({
|
|
104
118
|
dir: !1,
|
|
105
|
-
basename:
|
|
106
|
-
encodingFormat: b(
|
|
107
|
-
size:
|
|
108
|
-
uri: `${
|
|
109
|
-
blob: async () => await
|
|
110
|
-
string: async () => (await
|
|
119
|
+
basename: s.file.name,
|
|
120
|
+
encodingFormat: b(s.file.name),
|
|
121
|
+
size: s.file.size,
|
|
122
|
+
uri: `${s.path}${s.file.name}`,
|
|
123
|
+
blob: async () => await s.file.extract(),
|
|
124
|
+
string: async () => (await s.file.extract()).text()
|
|
111
125
|
}))
|
|
112
126
|
};
|
|
113
|
-
return f.log("Generated archive",
|
|
114
|
-
},
|
|
127
|
+
return f.log("Generated archive", n), n;
|
|
128
|
+
}, Ut = async (e, {
|
|
115
129
|
mimeType: t,
|
|
116
130
|
direction: o
|
|
117
131
|
} = { mimeType: "text/plain" }) => {
|
|
@@ -133,6 +147,7 @@ ${s}`), f.groupEnd();
|
|
|
133
147
|
`;
|
|
134
148
|
return {
|
|
135
149
|
filename: "content.txt",
|
|
150
|
+
encodingFormat: t,
|
|
136
151
|
records: [
|
|
137
152
|
{
|
|
138
153
|
dir: !1,
|
|
@@ -154,26 +169,26 @@ ${s}`), f.groupEnd();
|
|
|
154
169
|
],
|
|
155
170
|
close: () => Promise.resolve()
|
|
156
171
|
};
|
|
157
|
-
},
|
|
158
|
-
e.trim().replaceAll("/", "_").replace(
|
|
159
|
-
),
|
|
160
|
-
if (
|
|
172
|
+
}, Ee = /^[A-Za-z0-9_][A-Za-z0-9_.-]*$/, ke = /^[A-Za-z0-9_]/, U = /^xml/i, Ce = /[^A-Za-z0-9_.-]+/g, H = "_", We = (e) => e.replace(/^_+|_+$/g, ""), Pe = (e) => We(
|
|
173
|
+
e.trim().replaceAll("/", "_").replace(Ce, "_")
|
|
174
|
+
), _e = (e) => {
|
|
175
|
+
if (Ee.test(e) && !U.test(e))
|
|
161
176
|
return e;
|
|
162
|
-
const t =
|
|
163
|
-
return
|
|
164
|
-
},
|
|
165
|
-
const o =
|
|
177
|
+
const t = Pe(e), o = t && !U.test(t) ? t : `${H}${t}`;
|
|
178
|
+
return ke.test(o) ? o : `${H}${o}`;
|
|
179
|
+
}, Ne = (e, t) => {
|
|
180
|
+
const o = _e(e);
|
|
166
181
|
if (!t.has(o))
|
|
167
182
|
return t.add(o), o;
|
|
168
183
|
let r = 2, n = `${o}-${r}`;
|
|
169
184
|
for (; t.has(n); )
|
|
170
185
|
r += 1, n = `${o}-${r}`;
|
|
171
186
|
return t.add(n), n;
|
|
172
|
-
},
|
|
187
|
+
}, Q = () => {
|
|
173
188
|
const e = /* @__PURE__ */ new Set();
|
|
174
|
-
return (t) =>
|
|
175
|
-
},
|
|
176
|
-
const o =
|
|
189
|
+
return (t) => Ne(t, e);
|
|
190
|
+
}, Ht = async (e, t) => {
|
|
191
|
+
const o = Q(), r = e.map((a) => ({
|
|
177
192
|
id: o(a),
|
|
178
193
|
url: a
|
|
179
194
|
})), n = `
|
|
@@ -185,7 +200,7 @@ ${s}`), f.groupEnd();
|
|
|
185
200
|
<manifest>
|
|
186
201
|
${r.map(({ id: a, url: c }) => {
|
|
187
202
|
const d = b(c);
|
|
188
|
-
return `<item id="${a}" href="${
|
|
203
|
+
return `<item id="${a}" href="${N(c)}" media-type="${N(d ?? "")}"/>`;
|
|
189
204
|
}).join(`
|
|
190
205
|
`)}
|
|
191
206
|
</manifest>
|
|
@@ -215,11 +230,13 @@ ${s}`), f.groupEnd();
|
|
|
215
230
|
}, ...s],
|
|
216
231
|
close: () => Promise.resolve()
|
|
217
232
|
};
|
|
218
|
-
},
|
|
233
|
+
}, ze = (e) => !e.dir, Oe = W.toLowerCase(), Me = (e) => e.records.find(
|
|
234
|
+
(t) => ze(t) && t.basename.toLowerCase() === Oe
|
|
235
|
+
), Xt = ({
|
|
219
236
|
enableReport: e
|
|
220
237
|
} = {}) => {
|
|
221
238
|
f.enable(!!e);
|
|
222
|
-
},
|
|
239
|
+
}, _ = (e) => {
|
|
223
240
|
const o = Object.values(e.records).filter(
|
|
224
241
|
(r) => !r.dir
|
|
225
242
|
).find((r) => r.uri.endsWith(".opf"));
|
|
@@ -228,25 +245,25 @@ ${s}`), f.groupEnd();
|
|
|
228
245
|
basePath: o?.uri.substring(0, o.uri.lastIndexOf("/")) || ""
|
|
229
246
|
};
|
|
230
247
|
};
|
|
231
|
-
async function
|
|
232
|
-
const { data: t, basePath: o } =
|
|
248
|
+
async function ee(e) {
|
|
249
|
+
const { data: t, basePath: o } = _(e) || {};
|
|
233
250
|
if (!t || t.dir)
|
|
234
251
|
return;
|
|
235
252
|
const r = await t.string();
|
|
236
253
|
return {
|
|
237
|
-
opf:
|
|
254
|
+
opf: de(r),
|
|
238
255
|
basePath: o
|
|
239
256
|
};
|
|
240
257
|
}
|
|
241
|
-
const
|
|
258
|
+
const De = Z.toLowerCase(), Be = ({ archive: e }) => async (t) => {
|
|
242
259
|
const o = e.records.find(
|
|
243
|
-
(n) => !n.dir && n.basename.toLowerCase() ===
|
|
260
|
+
(n) => !n.dir && n.basename.toLowerCase() === De
|
|
244
261
|
);
|
|
245
262
|
if (!o || o.dir)
|
|
246
263
|
return t;
|
|
247
264
|
const r = await o.string();
|
|
248
265
|
try {
|
|
249
|
-
const n =
|
|
266
|
+
const n = le(r), { renditionLayout: s } = S(n);
|
|
250
267
|
return {
|
|
251
268
|
...t,
|
|
252
269
|
renditionLayout: t.renditionLayout ?? s
|
|
@@ -258,35 +275,33 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
258
275
|
r
|
|
259
276
|
), console.error(n), t;
|
|
260
277
|
}
|
|
261
|
-
},
|
|
262
|
-
const o = e
|
|
263
|
-
|
|
264
|
-
);
|
|
265
|
-
if (!o || o.dir)
|
|
278
|
+
}, je = W.toLowerCase(), Ue = ({ archive: e }) => async (t) => {
|
|
279
|
+
const o = Me(e);
|
|
280
|
+
if (!o)
|
|
266
281
|
return t;
|
|
267
282
|
const r = {
|
|
268
283
|
...t,
|
|
269
284
|
spineItems: t.spineItems.filter(
|
|
270
|
-
(s) => !s.id.toLowerCase().endsWith(
|
|
285
|
+
(s) => !s.id.toLowerCase().endsWith(je)
|
|
271
286
|
).map((s, i, a) => ({
|
|
272
287
|
...s,
|
|
273
288
|
progressionWeight: 1 / a.length
|
|
274
289
|
}))
|
|
275
290
|
}, n = await o.string();
|
|
276
291
|
try {
|
|
277
|
-
const s =
|
|
292
|
+
const s = ue(n), i = S(s);
|
|
278
293
|
return {
|
|
279
294
|
...r,
|
|
280
|
-
readingDirection: i.readingDirection ??
|
|
295
|
+
readingDirection: i.readingDirection ?? r.readingDirection
|
|
281
296
|
};
|
|
282
297
|
} catch (s) {
|
|
283
298
|
return console.error(
|
|
284
|
-
`Unable to parse ${
|
|
299
|
+
`Unable to parse ${W} for content
|
|
285
300
|
`,
|
|
286
301
|
n
|
|
287
302
|
), console.error(s), r;
|
|
288
303
|
}
|
|
289
|
-
},
|
|
304
|
+
}, He = ({
|
|
290
305
|
baseUrl: e = "",
|
|
291
306
|
resourcePath: t
|
|
292
307
|
}) => {
|
|
@@ -294,8 +309,8 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
294
309
|
return encodeURI(t);
|
|
295
310
|
const o = e ? `${e}${e.endsWith("/") ? "" : "/"}` : "file://";
|
|
296
311
|
return encodeURI(`${o}${t}`);
|
|
297
|
-
},
|
|
298
|
-
const o = Object.values(e.records).filter((s) => !s.dir), r =
|
|
312
|
+
}, Xe = ({ archive: e, baseUrl: t }) => async () => {
|
|
313
|
+
const o = Object.values(e.records).filter((s) => !s.dir), r = Q(), n = o.map((s) => ({
|
|
299
314
|
file: s,
|
|
300
315
|
id: r(s.uri)
|
|
301
316
|
}));
|
|
@@ -304,11 +319,11 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
304
319
|
title: e.records.find(({ dir: s }) => s)?.basename.replace(/\/$/, "") || e.filename,
|
|
305
320
|
renditionLayout: void 0,
|
|
306
321
|
renditionSpread: "auto",
|
|
307
|
-
readingDirection:
|
|
322
|
+
readingDirection: void 0,
|
|
308
323
|
spineItems: n.filter(({ file: s }) => !s.basename.endsWith(".db")).map(({ file: s, id: i }, a) => ({
|
|
309
324
|
id: i,
|
|
310
325
|
index: a,
|
|
311
|
-
href:
|
|
326
|
+
href: He({
|
|
312
327
|
baseUrl: t,
|
|
313
328
|
resourcePath: s.uri
|
|
314
329
|
}),
|
|
@@ -323,15 +338,15 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
323
338
|
href: encodeURI(`${t}${s.uri}`)
|
|
324
339
|
}))
|
|
325
340
|
};
|
|
326
|
-
},
|
|
341
|
+
}, te = async ({
|
|
327
342
|
archive: e,
|
|
328
343
|
archiveOpf: t
|
|
329
344
|
}) => {
|
|
330
345
|
if (!t) return [];
|
|
331
346
|
const { opf: o, basePath: r } = t, { spineRows: n } = o;
|
|
332
347
|
return e.records.filter((i) => n.find((a) => r ? `${r}/${a.href}` === i.uri : `${a.href}` === i.uri));
|
|
333
|
-
},
|
|
334
|
-
const { basePath: r } =
|
|
348
|
+
}, ne = (e, t, o) => {
|
|
349
|
+
const { basePath: r } = _(t) || {};
|
|
335
350
|
return e.map((n) => {
|
|
336
351
|
const s = n.href, i = o?.(s) ?? "";
|
|
337
352
|
return {
|
|
@@ -340,18 +355,18 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
340
355
|
mediaType: n.mediaType
|
|
341
356
|
};
|
|
342
357
|
});
|
|
343
|
-
},
|
|
358
|
+
}, Ve = (e) => {
|
|
344
359
|
const t = e?.trim();
|
|
345
360
|
return t === "scrolled-continuous" || t === "scrolled-doc" || t === "paginated" || t === "auto" ? t : "auto";
|
|
346
|
-
},
|
|
361
|
+
}, Ge = (e) => {
|
|
347
362
|
const t = e?.trim();
|
|
348
363
|
if (t === "none" || t === "landscape" || t === "portrait" || t === "both" || t === "auto")
|
|
349
364
|
return t;
|
|
350
|
-
},
|
|
365
|
+
}, Ke = (e) => {
|
|
351
366
|
const t = e?.trim();
|
|
352
367
|
if (t === "cover" || t === "title-page" || t === "copyright-page" || t === "text")
|
|
353
368
|
return t;
|
|
354
|
-
},
|
|
369
|
+
}, qe = ({
|
|
355
370
|
archive: e,
|
|
356
371
|
baseUrl: t,
|
|
357
372
|
archiveOpf: o
|
|
@@ -360,7 +375,7 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
360
375
|
return r;
|
|
361
376
|
const { opf: n, basePath: s } = o, i = S(n);
|
|
362
377
|
f.groupCollapsed(...f.getGroupArgs("OPF parsed")), f.log("opf", n), f.groupEnd();
|
|
363
|
-
const a = n.renditionLayoutMeta?.trim(), c = a === "reflowable" || a === "pre-paginated" ? a : i.renditionLayout, d = n.title?.trim() || e.records.find(({ dir: l }) => l)?.basename || "", u = i.readingDirection ??
|
|
378
|
+
const a = n.renditionLayoutMeta?.trim(), c = a === "reflowable" || a === "pre-paginated" ? a : i.renditionLayout, d = n.title?.trim() || e.records.find(({ dir: l }) => l)?.basename || "", u = i.readingDirection ?? r.readingDirection, m = (await te({
|
|
364
379
|
archive: e,
|
|
365
380
|
archiveOpf: o
|
|
366
381
|
})).reduce(
|
|
@@ -368,14 +383,14 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
368
383
|
0
|
|
369
384
|
), h = n.guide, y = [];
|
|
370
385
|
for (const l of h) {
|
|
371
|
-
const v =
|
|
386
|
+
const v = Ke(l.type);
|
|
372
387
|
v !== void 0 && y.push({ href: l.href, title: l.title, type: v });
|
|
373
388
|
}
|
|
374
389
|
return {
|
|
375
390
|
filename: e.filename,
|
|
376
391
|
renditionLayout: c,
|
|
377
|
-
renditionFlow:
|
|
378
|
-
renditionSpread:
|
|
392
|
+
renditionFlow: Ve(n.renditionFlowMeta),
|
|
393
|
+
renditionSpread: Ge(n.renditionSpreadMeta),
|
|
379
394
|
title: d,
|
|
380
395
|
readingDirection: u,
|
|
381
396
|
/**
|
|
@@ -395,30 +410,30 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
395
410
|
mediaType: l.mediaType
|
|
396
411
|
};
|
|
397
412
|
}),
|
|
398
|
-
items:
|
|
413
|
+
items: ne(n.manifestItems, e, (l) => /^https?:\/\//.test(l) ? "" : t || "file://"),
|
|
399
414
|
guide: y.length > 0 ? y : void 0
|
|
400
415
|
};
|
|
401
|
-
},
|
|
416
|
+
}, Je = (e) => {
|
|
402
417
|
const t = e.descendantWithPath("head")?.childrenNamed("meta").find((o) => o.attr.name === "viewport");
|
|
403
418
|
return !!(t && t.attr.name === "viewport");
|
|
404
|
-
},
|
|
405
|
-
if (!await t || !
|
|
419
|
+
}, Ze = (e) => e.reduce(async (t, o) => {
|
|
420
|
+
if (!await t || !ae({
|
|
406
421
|
mimeType: o.encodingFormat,
|
|
407
422
|
uri: o.uri
|
|
408
423
|
}))
|
|
409
424
|
return !1;
|
|
410
425
|
const n = o.dir ? null : await o.string();
|
|
411
|
-
return n ?
|
|
412
|
-
}, Promise.resolve(!0)),
|
|
426
|
+
return n ? Je(new R(n)) : !1;
|
|
427
|
+
}, Promise.resolve(!0)), Ye = ({
|
|
413
428
|
archive: e,
|
|
414
429
|
archiveOpf: t
|
|
415
430
|
}) => async (o) => {
|
|
416
431
|
if (o.renditionLayout === "reflowable" && o.spineItems.every((n) => n.renditionLayout === "reflowable")) {
|
|
417
|
-
const n = await
|
|
432
|
+
const n = await te({
|
|
418
433
|
archive: e,
|
|
419
434
|
archiveOpf: t
|
|
420
435
|
});
|
|
421
|
-
if (await
|
|
436
|
+
if (await Ze(n))
|
|
422
437
|
return {
|
|
423
438
|
...o,
|
|
424
439
|
spineItems: o.spineItems.map((i) => ({
|
|
@@ -429,18 +444,21 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
429
444
|
};
|
|
430
445
|
}
|
|
431
446
|
return o;
|
|
432
|
-
},
|
|
447
|
+
}, Qe = () => (e) => ({
|
|
448
|
+
...e,
|
|
449
|
+
readingDirection: e.readingDirection ?? "ltr"
|
|
450
|
+
}), et = async (e) => {
|
|
433
451
|
let t;
|
|
434
452
|
return await Promise.all(
|
|
435
453
|
e.records.map(async (o) => {
|
|
436
|
-
if (o.dir || !o.uri.endsWith(
|
|
454
|
+
if (o.dir || !o.uri.endsWith(z)) return;
|
|
437
455
|
const r = await o.string();
|
|
438
456
|
try {
|
|
439
|
-
const { renditionLayout: n } =
|
|
457
|
+
const { renditionLayout: n } = pe(r);
|
|
440
458
|
n && (t = n);
|
|
441
459
|
} catch (n) {
|
|
442
460
|
console.error(
|
|
443
|
-
`Unable to parse ${
|
|
461
|
+
`Unable to parse ${z} for content
|
|
444
462
|
`,
|
|
445
463
|
r
|
|
446
464
|
), console.error(n);
|
|
@@ -450,15 +468,15 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
450
468
|
kind: "kobo",
|
|
451
469
|
...t !== void 0 ? { renditionLayout: t } : {}
|
|
452
470
|
};
|
|
453
|
-
},
|
|
454
|
-
const o = await
|
|
471
|
+
}, tt = ({ archive: e }) => async (t) => {
|
|
472
|
+
const o = await et(e), { renditionLayout: r } = S(o);
|
|
455
473
|
return {
|
|
456
474
|
...t,
|
|
457
475
|
renditionLayout: t.renditionLayout ?? r
|
|
458
476
|
};
|
|
459
|
-
}, X = (e) => e.toLowerCase().endsWith(".opf"),
|
|
477
|
+
}, X = (e) => e.toLowerCase().endsWith(".opf"), nt = (e) => e.records.some(
|
|
460
478
|
(t) => !t.dir && (X(t.basename) || X(t.uri))
|
|
461
|
-
),
|
|
479
|
+
), rt = ({ archive: e }) => async (t) => nt(e) ? t : {
|
|
462
480
|
...t,
|
|
463
481
|
spineItems: t.spineItems.map((r) => {
|
|
464
482
|
const n = e.records.find(
|
|
@@ -466,10 +484,10 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
466
484
|
), s = J(n?.encodingFormat ?? "") || b(n?.basename ?? "");
|
|
467
485
|
return {
|
|
468
486
|
...r,
|
|
469
|
-
renditionLayout: s &&
|
|
487
|
+
renditionLayout: s && ce(s) ? "pre-paginated" : r.renditionLayout
|
|
470
488
|
};
|
|
471
489
|
})
|
|
472
|
-
},
|
|
490
|
+
}, re = (e) => e ? e.children.map((t) => t instanceof me ? t.text : t instanceof he ? re(t) : "").join("").trim() : "", st = (e) => fe(e.properties).includes("nav"), se = (e, { basePath: t, baseUrl: o }) => {
|
|
473
491
|
const r = {
|
|
474
492
|
contents: [],
|
|
475
493
|
path: "",
|
|
@@ -477,55 +495,55 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
477
495
|
title: ""
|
|
478
496
|
};
|
|
479
497
|
let n = e.childNamed("span") || e.childNamed("a");
|
|
480
|
-
r.title = (n?.attr.title || n?.val.trim() ||
|
|
498
|
+
r.title = (n?.attr.title || n?.val.trim() || re(n)) ?? "";
|
|
481
499
|
let s = n?.name;
|
|
482
|
-
s !== "a" && (n = e.descendantWithPath(`${s}.a`), n && (s = n.name.toLowerCase())), s === "a" && n?.attr.href && (r.path =
|
|
500
|
+
s !== "a" && (n = e.descendantWithPath(`${s}.a`), n && (s = n.name.toLowerCase())), s === "a" && n?.attr.href && (r.path = T(t, n.attr.href), r.href = T(o, t, n.attr.href));
|
|
483
501
|
const i = e.childNamed("ol");
|
|
484
502
|
if (i) {
|
|
485
503
|
const a = i.childrenNamed("li");
|
|
486
504
|
a && a.length > 0 && (r.contents = a.map(
|
|
487
|
-
(c) =>
|
|
505
|
+
(c) => se(c, { basePath: t, baseUrl: o })
|
|
488
506
|
));
|
|
489
507
|
}
|
|
490
508
|
return r;
|
|
491
|
-
},
|
|
509
|
+
}, ot = (e, { basePath: t, baseUrl: o }) => {
|
|
492
510
|
const r = [];
|
|
493
511
|
let n;
|
|
494
512
|
return e.descendantWithPath("body.nav.ol") ? n = e.descendantWithPath("body.nav.ol")?.children : e.descendantWithPath("body.section.nav.ol") && (n = e.descendantWithPath("body.section.nav.ol")?.children), n && n.length > 0 && n.filter((s) => s.name === "li").forEach((s) => {
|
|
495
|
-
r.push(
|
|
513
|
+
r.push(se(s, { basePath: t, baseUrl: o }));
|
|
496
514
|
}), r;
|
|
497
|
-
},
|
|
498
|
-
const r = e.manifestItems.find(
|
|
515
|
+
}, it = async (e, t, { baseUrl: o }) => {
|
|
516
|
+
const r = e.manifestItems.find(st);
|
|
499
517
|
if (r?.href) {
|
|
500
518
|
const n = Object.values(t.records).find(
|
|
501
519
|
(s) => s.uri.endsWith(r.href)
|
|
502
520
|
);
|
|
503
521
|
if (n && !n.dir) {
|
|
504
|
-
const s = new R(await n.string()), i =
|
|
505
|
-
return
|
|
522
|
+
const s = new R(await n.string()), i = Re(n.uri);
|
|
523
|
+
return ot(s, { basePath: i, baseUrl: o });
|
|
506
524
|
}
|
|
507
525
|
}
|
|
508
|
-
},
|
|
526
|
+
}, oe = (e, {
|
|
509
527
|
opfBasePath: t,
|
|
510
528
|
baseUrl: o,
|
|
511
529
|
prefix: r
|
|
512
530
|
}) => {
|
|
513
531
|
const n = e?.childNamed(`${r}content`)?.attr.src || "", s = {
|
|
514
532
|
title: e?.descendantWithPath(`${r}navLabel.${r}text`)?.val || "",
|
|
515
|
-
path:
|
|
516
|
-
href:
|
|
533
|
+
path: T(t, n),
|
|
534
|
+
href: T(o, t, n),
|
|
517
535
|
contents: []
|
|
518
536
|
}, i = e.childrenNamed(`${r}navPoint`);
|
|
519
537
|
return i && i.length > 0 && (s.contents = i.map(
|
|
520
|
-
(a) =>
|
|
538
|
+
(a) => oe(a, { opfBasePath: t, baseUrl: o, prefix: r })
|
|
521
539
|
)), s;
|
|
522
|
-
},
|
|
540
|
+
}, at = (e, { opfBasePath: t, baseUrl: o }) => {
|
|
523
541
|
const r = [], n = e.name;
|
|
524
542
|
let s = "";
|
|
525
543
|
return n.indexOf(":") !== -1 && (s = `${n.split(":")[0]}:`), e.childNamed(`${s}navMap`)?.childrenNamed(`${s}navPoint`).forEach((i) => {
|
|
526
|
-
r.push(
|
|
544
|
+
r.push(oe(i, { opfBasePath: t, baseUrl: o, prefix: s }));
|
|
527
545
|
}), r;
|
|
528
|
-
},
|
|
546
|
+
}, ct = async ({
|
|
529
547
|
opf: e,
|
|
530
548
|
opfBasePath: t,
|
|
531
549
|
baseUrl: o,
|
|
@@ -540,17 +558,17 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
540
558
|
);
|
|
541
559
|
if (a && !a.dir) {
|
|
542
560
|
const c = new R(await a.string());
|
|
543
|
-
return
|
|
561
|
+
return at(c, { opfBasePath: t, baseUrl: o });
|
|
544
562
|
}
|
|
545
563
|
}
|
|
546
564
|
}
|
|
547
|
-
},
|
|
548
|
-
const { basePath: r } =
|
|
565
|
+
}, dt = async (e, t, { baseUrl: o }) => {
|
|
566
|
+
const { basePath: r } = _(t) || {}, n = await it(e, t, {
|
|
549
567
|
baseUrl: o
|
|
550
568
|
});
|
|
551
569
|
if (n)
|
|
552
570
|
return n;
|
|
553
|
-
const s = await
|
|
571
|
+
const s = await ct({
|
|
554
572
|
opf: e,
|
|
555
573
|
opfBasePath: r ?? "",
|
|
556
574
|
archive: t,
|
|
@@ -558,22 +576,22 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
558
576
|
});
|
|
559
577
|
if (s)
|
|
560
578
|
return s;
|
|
561
|
-
},
|
|
579
|
+
}, lt = (e) => e.replace(/\.[^.]+$/, "").replace(/[_-]/g, " ").replace(/\s+/g, " ").trim(), ut = (e, t) => {
|
|
562
580
|
if (!(e.spineItems.length === 0 || !e.spineItems.every((r) => (J(r.mediaType ?? "") || b(r.href))?.startsWith("audio/"))))
|
|
563
581
|
return e.spineItems.map((r) => {
|
|
564
582
|
const n = t.records.find(
|
|
565
583
|
(s) => !s.dir && decodeURI(r.href).endsWith(s.uri)
|
|
566
584
|
);
|
|
567
585
|
return {
|
|
568
|
-
title:
|
|
586
|
+
title: lt(n?.basename ?? r.href),
|
|
569
587
|
href: r.href,
|
|
570
588
|
path: n?.uri ?? r.href,
|
|
571
589
|
contents: []
|
|
572
590
|
};
|
|
573
591
|
});
|
|
574
|
-
},
|
|
592
|
+
}, pt = (e, { baseUrl: t }) => {
|
|
575
593
|
const o = [...e.records].sort(
|
|
576
|
-
(n, s) =>
|
|
594
|
+
(n, s) => P(n.uri, s.uri)
|
|
577
595
|
), r = (n, s, i, a, c) => {
|
|
578
596
|
const d = n.find((m) => m.title === s), [u, ...p] = i;
|
|
579
597
|
return d ? u ? [
|
|
@@ -626,27 +644,27 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
626
644
|
if (s.dir) return n;
|
|
627
645
|
const i = s.uri.split("/").slice(0, -1), [a, ...c] = i;
|
|
628
646
|
if (!a) return n;
|
|
629
|
-
const d =
|
|
647
|
+
const d = T(t, encodeURI(s.uri)).replace(/\/$/, ""), u = s.uri.replace(/\/$/, "");
|
|
630
648
|
return r(n, a, c, d, u);
|
|
631
649
|
}, []);
|
|
632
|
-
},
|
|
650
|
+
}, ft = async (e, t, {
|
|
633
651
|
baseUrl: o,
|
|
634
652
|
archiveOpf: r
|
|
635
653
|
}) => {
|
|
636
654
|
if (r)
|
|
637
|
-
return await
|
|
638
|
-
const n =
|
|
655
|
+
return await dt(r.opf, e, { baseUrl: o }) || [];
|
|
656
|
+
const n = ut(t, e);
|
|
639
657
|
if (n) return n;
|
|
640
|
-
const s =
|
|
658
|
+
const s = pt(e, { baseUrl: o });
|
|
641
659
|
if (s.length !== 0)
|
|
642
660
|
return s;
|
|
643
|
-
},
|
|
661
|
+
}, mt = ({
|
|
644
662
|
archive: e,
|
|
645
663
|
baseUrl: t,
|
|
646
664
|
archiveOpf: o
|
|
647
665
|
}) => async (r) => {
|
|
648
666
|
if (r.nav) return r;
|
|
649
|
-
const n = await
|
|
667
|
+
const n = await ft(e, r, {
|
|
650
668
|
baseUrl: t,
|
|
651
669
|
archiveOpf: o
|
|
652
670
|
});
|
|
@@ -656,34 +674,35 @@ const Oe = Z.toLowerCase(), Me = ({ archive: e }) => async (t) => {
|
|
|
656
674
|
toc: n
|
|
657
675
|
}
|
|
658
676
|
} : r;
|
|
659
|
-
},
|
|
677
|
+
}, ht = (e) => e ? e.endsWith("/") ? e : `${e}/` : "", gt = async (e, {
|
|
660
678
|
baseUrl: t = "",
|
|
661
679
|
hooks: o = {}
|
|
662
680
|
} = {}) => {
|
|
663
681
|
f.log("Generating manifest from archive", e);
|
|
664
|
-
const r = await
|
|
682
|
+
const r = await ee(e), n = ht(t), s = (p) => (p ?? []).map(
|
|
665
683
|
(m) => m({ archive: e, baseUrl: n })
|
|
666
684
|
), i = [
|
|
667
|
-
|
|
685
|
+
qe({ archive: e, baseUrl: n, archiveOpf: r }),
|
|
686
|
+
Ue({ archive: e }),
|
|
668
687
|
Be({ archive: e }),
|
|
669
|
-
|
|
670
|
-
Qe({ archive: e }),
|
|
688
|
+
rt({ archive: e }),
|
|
671
689
|
...s(o.content)
|
|
672
690
|
], a = s(o.spine), c = [
|
|
673
|
-
|
|
674
|
-
|
|
691
|
+
Ye({ archive: e, archiveOpf: r }),
|
|
692
|
+
tt({ archive: e }),
|
|
675
693
|
...s(o.presentation)
|
|
676
694
|
], d = [
|
|
677
|
-
|
|
695
|
+
mt({ archive: e, baseUrl: n, archiveOpf: r }),
|
|
678
696
|
...s(o.navigation)
|
|
679
697
|
], u = [
|
|
680
698
|
...i,
|
|
681
699
|
...a,
|
|
682
700
|
...c,
|
|
683
|
-
...d
|
|
701
|
+
...d,
|
|
702
|
+
Qe()
|
|
684
703
|
];
|
|
685
704
|
try {
|
|
686
|
-
const p =
|
|
705
|
+
const p = Xe({
|
|
687
706
|
archive: e,
|
|
688
707
|
baseUrl: n
|
|
689
708
|
})(), m = await u.reduce(async (h, y) => await y(await h), p);
|
|
@@ -696,19 +715,19 @@ ${h}`), f.groupEnd();
|
|
|
696
715
|
} catch (p) {
|
|
697
716
|
throw f.error(p), p;
|
|
698
717
|
}
|
|
699
|
-
},
|
|
718
|
+
}, yt = (e) => {
|
|
700
719
|
const t = e.descendantWithPath("head")?.childrenNamed("meta").find((o) => o.attr.name === "calibre:cover");
|
|
701
720
|
return !!(t && t.attr.name === "calibre:cover");
|
|
702
|
-
},
|
|
721
|
+
}, bt = (e) => e.descendantWithPath("body")?.descendantWithPath("div")?.childrenNamed("svg")?.find(
|
|
703
722
|
(t) => t.attr.width === "100%" && t.attr.preserveAspectRatio === "none"
|
|
704
|
-
),
|
|
723
|
+
), vt = ({ archive: e, resourcePath: t }) => async (o) => {
|
|
705
724
|
const r = Object.values(e.records).find(
|
|
706
725
|
(n) => n.uri === t && !n.dir
|
|
707
726
|
);
|
|
708
727
|
if (r && !r.dir && r.basename.endsWith(".xhtml")) {
|
|
709
728
|
const n = typeof o.body == "string" ? o.body : await r.string(), s = new R(n);
|
|
710
|
-
if (
|
|
711
|
-
const i =
|
|
729
|
+
if (yt(s)) {
|
|
730
|
+
const i = bt(s);
|
|
712
731
|
return i && delete i.attr.preserveAspectRatio, {
|
|
713
732
|
...o,
|
|
714
733
|
body: s?.toString()
|
|
@@ -716,7 +735,7 @@ ${h}`), f.groupEnd();
|
|
|
716
735
|
}
|
|
717
736
|
}
|
|
718
737
|
return o;
|
|
719
|
-
},
|
|
738
|
+
}, wt = ({ archive: e, resourcePath: t }) => async (o) => vt({ archive: e, resourcePath: t })(o), $t = ({ archive: e, resourcePath: t }) => async (o) => {
|
|
720
739
|
const r = Object.values(e.records).find(
|
|
721
740
|
(n) => n.uri === t && !n.dir
|
|
722
741
|
);
|
|
@@ -731,10 +750,10 @@ ${h}`), f.groupEnd();
|
|
|
731
750
|
};
|
|
732
751
|
}
|
|
733
752
|
return o;
|
|
734
|
-
},
|
|
735
|
-
const o = await
|
|
753
|
+
}, At = async (e, t) => {
|
|
754
|
+
const o = await ee(e);
|
|
736
755
|
if (o) {
|
|
737
|
-
const { opf: r } = o, n =
|
|
756
|
+
const { opf: r } = o, n = ne(r.manifestItems, e, () => "");
|
|
738
757
|
if (n.find(
|
|
739
758
|
(i) => t.endsWith(i.href)
|
|
740
759
|
)?.mediaType)
|
|
@@ -743,9 +762,9 @@ ${h}`), f.groupEnd();
|
|
|
743
762
|
};
|
|
744
763
|
}
|
|
745
764
|
return {
|
|
746
|
-
mediaType:
|
|
765
|
+
mediaType: Ft(t)
|
|
747
766
|
};
|
|
748
|
-
},
|
|
767
|
+
}, Ft = (e) => {
|
|
749
768
|
if (e.endsWith(".css"))
|
|
750
769
|
return "text/css; charset=UTF-8";
|
|
751
770
|
if (e.endsWith(".jpg"))
|
|
@@ -756,12 +775,12 @@ ${h}`), f.groupEnd();
|
|
|
756
775
|
return "video/mp4";
|
|
757
776
|
if (e.endsWith(".svg"))
|
|
758
777
|
return "image/svg+xml";
|
|
759
|
-
},
|
|
778
|
+
}, It = ({ archive: e, resourcePath: t }) => async (o) => {
|
|
760
779
|
const r = Object.values(e.records).find(
|
|
761
780
|
(s) => s.uri === t && !s.dir
|
|
762
781
|
);
|
|
763
782
|
if (!r || r.dir) return o;
|
|
764
|
-
const n = await
|
|
783
|
+
const n = await At(e, t);
|
|
765
784
|
return {
|
|
766
785
|
...o,
|
|
767
786
|
params: {
|
|
@@ -825,7 +844,7 @@ ${h}`), f.groupEnd();
|
|
|
825
844
|
"canvas",
|
|
826
845
|
"script",
|
|
827
846
|
"style"
|
|
828
|
-
],
|
|
847
|
+
], Tt = ({ archive: e, resourcePath: t }) => async (o) => {
|
|
829
848
|
const r = Object.values(e.records).find(
|
|
830
849
|
(n) => n.uri === t && !n.dir
|
|
831
850
|
);
|
|
@@ -849,15 +868,15 @@ ${h}`), f.groupEnd();
|
|
|
849
868
|
};
|
|
850
869
|
}
|
|
851
870
|
return o;
|
|
852
|
-
},
|
|
871
|
+
}, St = async (e, t, { hooks: o = [] } = {}) => {
|
|
853
872
|
const r = {
|
|
854
873
|
params: {}
|
|
855
874
|
}, s = [
|
|
856
875
|
...o.map((i) => i({ archive: e, resourcePath: t })),
|
|
857
|
-
|
|
876
|
+
It({ archive: e, resourcePath: t }),
|
|
877
|
+
Tt({ archive: e, resourcePath: t }),
|
|
858
878
|
$t({ archive: e, resourcePath: t }),
|
|
859
|
-
|
|
860
|
-
gt({ archive: e, resourcePath: t })
|
|
879
|
+
wt({ archive: e, resourcePath: t })
|
|
861
880
|
];
|
|
862
881
|
try {
|
|
863
882
|
const i = await s.reduce(async (c, d) => await d(await c), Promise.resolve(r));
|
|
@@ -876,9 +895,9 @@ ${h}`), f.groupEnd();
|
|
|
876
895
|
throw f.error(i), i;
|
|
877
896
|
}
|
|
878
897
|
};
|
|
879
|
-
class
|
|
898
|
+
class Rt {
|
|
880
899
|
constructor(t) {
|
|
881
|
-
this.cleanArchiveAfter = t, this.state$ = new
|
|
900
|
+
this.cleanArchiveAfter = t, this.state$ = new we({
|
|
882
901
|
status: "idle",
|
|
883
902
|
locks: 0
|
|
884
903
|
});
|
|
@@ -895,27 +914,27 @@ class Ft {
|
|
|
895
914
|
get isUnlocked$() {
|
|
896
915
|
return this.locks$.pipe(
|
|
897
916
|
$((t) => t <= 0),
|
|
898
|
-
|
|
899
|
-
|
|
917
|
+
$e(),
|
|
918
|
+
Ae()
|
|
900
919
|
);
|
|
901
920
|
}
|
|
902
921
|
get overTTL$() {
|
|
903
922
|
return this.isUnlocked$.pipe(
|
|
904
|
-
|
|
905
|
-
(t) => t ? this.cleanArchiveAfter === 1 / 0 ? B :
|
|
923
|
+
I(
|
|
924
|
+
(t) => t ? this.cleanArchiveAfter === 1 / 0 ? B : Fe(this.cleanArchiveAfter) : B
|
|
906
925
|
)
|
|
907
926
|
);
|
|
908
927
|
}
|
|
909
928
|
}
|
|
910
|
-
const
|
|
929
|
+
const Lt = ({
|
|
911
930
|
getArchive: e,
|
|
912
931
|
cleanArchiveAfter: t = 300 * 1e3
|
|
913
932
|
// 5mn
|
|
914
933
|
}) => {
|
|
915
934
|
const o = new x(), r = new x(), n = new x(), s = {}, i = o.pipe(
|
|
916
|
-
|
|
935
|
+
Y((d) => {
|
|
917
936
|
const u = s[d];
|
|
918
|
-
if (!u || u.state.status !== "idle") return
|
|
937
|
+
if (!u || u.state.status !== "idle") return O;
|
|
919
938
|
let p = !1;
|
|
920
939
|
const m = (g) => {
|
|
921
940
|
f.debug(`Cleaning up archive with key: ${g}`);
|
|
@@ -926,9 +945,9 @@ const Tt = ({
|
|
|
926
945
|
status: "loading"
|
|
927
946
|
});
|
|
928
947
|
const h = u.locks$, y = u.isUnlocked$, l = h.pipe(
|
|
929
|
-
|
|
948
|
+
ge(),
|
|
930
949
|
E(([g, w]) => w > g),
|
|
931
|
-
|
|
950
|
+
ye(!0)
|
|
932
951
|
);
|
|
933
952
|
return F(e(d)).pipe(
|
|
934
953
|
k((g) => {
|
|
@@ -940,15 +959,15 @@ const Tt = ({
|
|
|
940
959
|
C((g) => (m(d), u.update({
|
|
941
960
|
status: "error",
|
|
942
961
|
error: g
|
|
943
|
-
}),
|
|
944
|
-
|
|
962
|
+
}), O)),
|
|
963
|
+
I(() => {
|
|
945
964
|
const g = l.pipe(
|
|
946
|
-
|
|
947
|
-
|
|
965
|
+
I(() => n),
|
|
966
|
+
I(() => y),
|
|
948
967
|
E((L) => L)
|
|
949
968
|
);
|
|
950
|
-
return
|
|
951
|
-
|
|
969
|
+
return M(g, u.overTTL$).pipe(
|
|
970
|
+
D(),
|
|
952
971
|
k(() => {
|
|
953
972
|
m(d);
|
|
954
973
|
})
|
|
@@ -956,10 +975,10 @@ const Tt = ({
|
|
|
956
975
|
})
|
|
957
976
|
);
|
|
958
977
|
}),
|
|
959
|
-
|
|
978
|
+
be(r)
|
|
960
979
|
), a = (d) => {
|
|
961
980
|
let u = !1;
|
|
962
|
-
const p = s[d] ?? new
|
|
981
|
+
const p = s[d] ?? new Rt(t);
|
|
963
982
|
s[d] = p, p.update({
|
|
964
983
|
locks: p.state.locks + 1
|
|
965
984
|
});
|
|
@@ -977,10 +996,10 @@ const Tt = ({
|
|
|
977
996
|
if (l)
|
|
978
997
|
throw l;
|
|
979
998
|
}),
|
|
980
|
-
|
|
999
|
+
ve()
|
|
981
1000
|
);
|
|
982
|
-
return
|
|
983
|
-
|
|
1001
|
+
return M(h, y).pipe(
|
|
1002
|
+
D(),
|
|
984
1003
|
$((l) => ({ archive: l, release: m })),
|
|
985
1004
|
C((l) => {
|
|
986
1005
|
throw m(), l;
|
|
@@ -1003,7 +1022,7 @@ const Tt = ({
|
|
|
1003
1022
|
} : {
|
|
1004
1023
|
valid: !0,
|
|
1005
1024
|
value: void 0
|
|
1006
|
-
},
|
|
1025
|
+
}, xt = (e) => {
|
|
1007
1026
|
if (!e.toLowerCase().startsWith("bytes="))
|
|
1008
1027
|
return {
|
|
1009
1028
|
kind: "missing"
|
|
@@ -1030,7 +1049,7 @@ const Tt = ({
|
|
|
1030
1049
|
start: s.value,
|
|
1031
1050
|
end: i.value
|
|
1032
1051
|
};
|
|
1033
|
-
},
|
|
1052
|
+
}, Et = (e) => {
|
|
1034
1053
|
if (e instanceof Blob)
|
|
1035
1054
|
return {
|
|
1036
1055
|
size: e.size,
|
|
@@ -1047,7 +1066,7 @@ const Tt = ({
|
|
|
1047
1066
|
return { content: n, length: n.byteLength };
|
|
1048
1067
|
}
|
|
1049
1068
|
};
|
|
1050
|
-
},
|
|
1069
|
+
}, kt = ({
|
|
1051
1070
|
body: e,
|
|
1052
1071
|
contentType: t,
|
|
1053
1072
|
rangeHeader: o
|
|
@@ -1058,13 +1077,13 @@ const Tt = ({
|
|
|
1058
1077
|
status: 200,
|
|
1059
1078
|
headers: r
|
|
1060
1079
|
});
|
|
1061
|
-
const n =
|
|
1080
|
+
const n = xt(o);
|
|
1062
1081
|
if (n.kind === "missing" || n.kind === "multi")
|
|
1063
1082
|
return e instanceof Blob && r.set("Content-Length", String(e.size)), new Response(e, {
|
|
1064
1083
|
status: 200,
|
|
1065
1084
|
headers: r
|
|
1066
1085
|
});
|
|
1067
|
-
const s =
|
|
1086
|
+
const s = Et(e), i = s.size;
|
|
1068
1087
|
if (n.kind === "invalid")
|
|
1069
1088
|
return new Response(null, {
|
|
1070
1089
|
status: 416,
|
|
@@ -1096,24 +1115,24 @@ const Tt = ({
|
|
|
1096
1115
|
status: 206,
|
|
1097
1116
|
headers: r
|
|
1098
1117
|
});
|
|
1099
|
-
}, K = "file://",
|
|
1118
|
+
}, K = "file://", Ct = /^https?:\/\//, Wt = (e) => {
|
|
1100
1119
|
try {
|
|
1101
1120
|
return decodeURIComponent(e);
|
|
1102
1121
|
} catch {
|
|
1103
1122
|
return e;
|
|
1104
1123
|
}
|
|
1105
|
-
}, q = (e) => e.startsWith(K) ? e.slice(K.length) : e,
|
|
1124
|
+
}, q = (e) => e.startsWith(K) ? e.slice(K.length) : e, Pt = (e) => {
|
|
1106
1125
|
const t = q(e);
|
|
1107
|
-
return
|
|
1126
|
+
return Ct.test(t) ? t : q(Wt(t));
|
|
1108
1127
|
};
|
|
1109
|
-
class
|
|
1128
|
+
class _t {
|
|
1110
1129
|
constructor({
|
|
1111
1130
|
hooks: t,
|
|
1112
1131
|
onError: o,
|
|
1113
1132
|
onManifestSuccess: r,
|
|
1114
1133
|
...n
|
|
1115
1134
|
}) {
|
|
1116
|
-
this.onError = (s) => (console.error(s), new Response(String(s), { status: 500 })), this.archiveLoader =
|
|
1135
|
+
this.onError = (s) => (console.error(s), new Response(String(s), { status: 500 })), this.archiveLoader = Lt(n), this.hooks = t ?? {}, this.onManifestSuccess = r ?? (({ manifest: s }) => Promise.resolve(s)), this.onError = o ?? this.onError;
|
|
1117
1136
|
}
|
|
1118
1137
|
prune() {
|
|
1119
1138
|
this.archiveLoader.purge();
|
|
@@ -1131,27 +1150,27 @@ class kt {
|
|
|
1131
1150
|
getResponse: o
|
|
1132
1151
|
}) {
|
|
1133
1152
|
const r = this.accessArchive(t).pipe(
|
|
1134
|
-
|
|
1153
|
+
Y(
|
|
1135
1154
|
({ archive: n, release: s }) => F(o(n)).pipe(
|
|
1136
1155
|
Ie(() => {
|
|
1137
1156
|
s();
|
|
1138
1157
|
})
|
|
1139
1158
|
)
|
|
1140
1159
|
),
|
|
1141
|
-
C((n) =>
|
|
1160
|
+
C((n) => Te(this.onError(n)))
|
|
1142
1161
|
);
|
|
1143
|
-
return
|
|
1162
|
+
return Se(r);
|
|
1144
1163
|
}
|
|
1145
1164
|
fetchManifest({ key: t, baseUrl: o }) {
|
|
1146
1165
|
return this.withArchiveResponse({
|
|
1147
1166
|
key: t,
|
|
1148
1167
|
getResponse: (r) => F(
|
|
1149
|
-
|
|
1168
|
+
gt(r, {
|
|
1150
1169
|
baseUrl: o,
|
|
1151
1170
|
hooks: this.hooks.manifest
|
|
1152
1171
|
})
|
|
1153
1172
|
).pipe(
|
|
1154
|
-
|
|
1173
|
+
I(
|
|
1155
1174
|
(s) => F(this.onManifestSuccess({ manifest: s, archive: r }))
|
|
1156
1175
|
),
|
|
1157
1176
|
$(
|
|
@@ -1170,14 +1189,14 @@ class kt {
|
|
|
1170
1189
|
return this.withArchiveResponse({
|
|
1171
1190
|
key: t,
|
|
1172
1191
|
getResponse: (n) => {
|
|
1173
|
-
const s =
|
|
1192
|
+
const s = Pt(o);
|
|
1174
1193
|
return F(
|
|
1175
|
-
|
|
1194
|
+
St(n, s, {
|
|
1176
1195
|
hooks: this.hooks.resource
|
|
1177
1196
|
})
|
|
1178
1197
|
).pipe(
|
|
1179
1198
|
$(
|
|
1180
|
-
(a) =>
|
|
1199
|
+
(a) => kt({
|
|
1181
1200
|
body: a.body ?? "",
|
|
1182
1201
|
contentType: a.params.contentType,
|
|
1183
1202
|
rangeHeader: r?.headers.get("range")
|
|
@@ -1188,7 +1207,7 @@ class kt {
|
|
|
1188
1207
|
});
|
|
1189
1208
|
}
|
|
1190
1209
|
}
|
|
1191
|
-
class
|
|
1210
|
+
class Vt extends _t {
|
|
1192
1211
|
constructor({
|
|
1193
1212
|
getUriInfo: t,
|
|
1194
1213
|
...o
|
|
@@ -1219,23 +1238,24 @@ class Dt extends kt {
|
|
|
1219
1238
|
}
|
|
1220
1239
|
}
|
|
1221
1240
|
export {
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1241
|
+
Vt as ServiceWorkerStreamer,
|
|
1242
|
+
_t as Streamer,
|
|
1243
|
+
Xt as configure,
|
|
1244
|
+
Dt as createArchiveFromArrayBufferList,
|
|
1245
|
+
Bt as createArchiveFromJszip,
|
|
1246
|
+
jt as createArchiveFromLibArchive,
|
|
1247
|
+
Ut as createArchiveFromText,
|
|
1248
|
+
Ht as createArchiveFromUrls,
|
|
1249
|
+
Ne as createUniqueXmlSafeId,
|
|
1250
|
+
_e as createXmlSafeId,
|
|
1251
|
+
Q as createXmlSafeIdFactory,
|
|
1252
|
+
gt as generateManifestFromArchive,
|
|
1253
|
+
St as generateResourceFromArchive,
|
|
1254
|
+
Me as getArchiveHasComicInfo,
|
|
1255
|
+
_ as getArchiveOpfInfo,
|
|
1256
|
+
Re as getUriBasePath,
|
|
1237
1257
|
A as getUriBasename,
|
|
1238
1258
|
j as removeTrailingSlash,
|
|
1239
|
-
|
|
1259
|
+
P as sortByTitleComparator
|
|
1240
1260
|
};
|
|
1241
1261
|
//# sourceMappingURL=index.js.map
|