@prose-reader/streamer 1.130.0 → 1.132.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/generators/manifest/hooks/epub/epub.d.ts +1 -1
- package/dist/index.js +171 -159
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +6 -6
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import F, { XmlDocument as pe, XmlTextNode as fe, XmlElement as ue } from "xmldoc";
|
|
2
|
-
import { urlJoin as N, isXmlBasedMimeType as me, detectMimeTypeFromName as
|
|
3
|
-
import { Subject as j, mergeMap as
|
|
2
|
+
import { urlJoin as N, isXmlBasedMimeType as me, detectMimeTypeFromName as q } from "@prose-reader/shared";
|
|
3
|
+
import { Subject as j, mergeMap as M, EMPTY as G, pairwise as he, filter as D, startWith as ge, from as I, tap as O, catchError as C, switchMap as k, merge as K, takeUntil as ye, map as A, ignoreElements as be, first as we, BehaviorSubject as ve, distinctUntilChanged as $e, shareReplay as xe, NEVER as J, timer as Fe, finalize as Y, of as E, lastValueFrom as Q } from "rxjs";
|
|
4
4
|
let S = !1;
|
|
5
5
|
const v = {
|
|
6
6
|
enable: (e) => {
|
|
@@ -69,7 +69,7 @@ const v = {
|
|
|
69
69
|
}
|
|
70
70
|
}
|
|
71
71
|
return i;
|
|
72
|
-
},
|
|
72
|
+
}, We = ({ archive: e, resourcePath: t }) => async (i) => Se({ archive: e, resourcePath: t })(i), ke = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
73
73
|
const s = Object.values(e.files).find(
|
|
74
74
|
(n) => n.uri === t
|
|
75
75
|
);
|
|
@@ -84,16 +84,16 @@ const v = {
|
|
|
84
84
|
};
|
|
85
85
|
}
|
|
86
86
|
return i;
|
|
87
|
-
},
|
|
87
|
+
}, L = (e) => {
|
|
88
88
|
const i = Object.values(e.files).filter((s) => !s.dir).find((s) => s.uri.endsWith(".opf"));
|
|
89
89
|
return {
|
|
90
90
|
data: i,
|
|
91
91
|
basePath: (i == null ? void 0 : i.uri.substring(0, i.uri.lastIndexOf("/"))) || ""
|
|
92
92
|
};
|
|
93
|
-
},
|
|
93
|
+
}, te = (e) => e ? e.children.map((t) => t instanceof fe ? t.text : t instanceof ue ? te(t) : "").join("").trim() : "", T = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Z = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Ne = (e) => {
|
|
94
94
|
const t = e.lastIndexOf("/");
|
|
95
95
|
return t >= 0 ? e.substring(0, t) : "";
|
|
96
|
-
},
|
|
96
|
+
}, ne = (e, { basePath: t, baseUrl: i }) => {
|
|
97
97
|
const s = {
|
|
98
98
|
contents: [],
|
|
99
99
|
path: "",
|
|
@@ -101,14 +101,14 @@ const v = {
|
|
|
101
101
|
title: ""
|
|
102
102
|
};
|
|
103
103
|
let n = e.childNamed("span") || e.childNamed("a");
|
|
104
|
-
s.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) ||
|
|
104
|
+
s.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || te(n)) ?? "";
|
|
105
105
|
let r = n == null ? void 0 : n.name;
|
|
106
106
|
r !== "a" && (n = e.descendantWithPath(`${r}.a`), n && (r = n.name.toLowerCase())), r === "a" && (n != null && n.attr.href) && (s.path = N(t, n.attr.href), s.href = N(i, t, n.attr.href));
|
|
107
107
|
const a = e.childNamed("ol");
|
|
108
108
|
if (a) {
|
|
109
109
|
const o = a.childrenNamed("li");
|
|
110
110
|
o && o.length > 0 && (s.contents = o.map(
|
|
111
|
-
(d) =>
|
|
111
|
+
(d) => ne(d, { basePath: t, baseUrl: i })
|
|
112
112
|
));
|
|
113
113
|
}
|
|
114
114
|
return s;
|
|
@@ -117,7 +117,7 @@ const v = {
|
|
|
117
117
|
const s = [];
|
|
118
118
|
let n;
|
|
119
119
|
return e.descendantWithPath("body.nav.ol") ? n = (r = e.descendantWithPath("body.nav.ol")) == null ? void 0 : r.children : e.descendantWithPath("body.section.nav.ol") && (n = (a = e.descendantWithPath("body.section.nav.ol")) == null ? void 0 : a.children), n && n.length > 0 && n.filter((o) => o.name === "li").forEach(
|
|
120
|
-
(o) => s.push(
|
|
120
|
+
(o) => s.push(ne(o, { basePath: t, baseUrl: i }))
|
|
121
121
|
), s;
|
|
122
122
|
}, Pe = async (e, t, { baseUrl: i }) => {
|
|
123
123
|
var n;
|
|
@@ -127,11 +127,11 @@ const v = {
|
|
|
127
127
|
(a) => a.uri.endsWith(s.attr.href || "")
|
|
128
128
|
);
|
|
129
129
|
if (r) {
|
|
130
|
-
const a = new F.XmlDocument(await r.string()), o =
|
|
130
|
+
const a = new F.XmlDocument(await r.string()), o = Ne(r.uri);
|
|
131
131
|
return Le(a, { basePath: o, baseUrl: i });
|
|
132
132
|
}
|
|
133
133
|
}
|
|
134
|
-
},
|
|
134
|
+
}, re = (e, {
|
|
135
135
|
opfBasePath: t,
|
|
136
136
|
baseUrl: i,
|
|
137
137
|
prefix: s
|
|
@@ -144,16 +144,16 @@ const v = {
|
|
|
144
144
|
contents: []
|
|
145
145
|
}, a = e.childrenNamed(`${s}navPoint`);
|
|
146
146
|
return a && a.length > 0 && (r.contents = a.map(
|
|
147
|
-
(p) =>
|
|
147
|
+
(p) => re(p, { opfBasePath: t, baseUrl: i, prefix: s })
|
|
148
148
|
)), r;
|
|
149
|
-
},
|
|
149
|
+
}, Ie = (e, { opfBasePath: t, baseUrl: i }) => {
|
|
150
150
|
var a;
|
|
151
151
|
const s = [], n = e.name;
|
|
152
152
|
let r = "";
|
|
153
153
|
return n.indexOf(":") !== -1 && (r = n.split(":")[0] + ":"), (a = e.childNamed(`${r}navMap`)) == null || a.childrenNamed(`${r}navPoint`).forEach(
|
|
154
|
-
(o) => s.push(
|
|
154
|
+
(o) => s.push(re(o, { opfBasePath: t, baseUrl: i, prefix: r }))
|
|
155
155
|
), s;
|
|
156
|
-
},
|
|
156
|
+
}, Ce = async ({
|
|
157
157
|
opfData: e,
|
|
158
158
|
opfBasePath: t,
|
|
159
159
|
baseUrl: i,
|
|
@@ -169,12 +169,12 @@ const v = {
|
|
|
169
169
|
);
|
|
170
170
|
if (p) {
|
|
171
171
|
const c = new F.XmlDocument(await p.string());
|
|
172
|
-
return
|
|
172
|
+
return Ie(c, { opfBasePath: t, baseUrl: i });
|
|
173
173
|
}
|
|
174
174
|
}
|
|
175
175
|
}
|
|
176
176
|
}, Re = async (e, t, { baseUrl: i }) => {
|
|
177
|
-
const { basePath: s } =
|
|
177
|
+
const { basePath: s } = L(t) || {}, n = await Ce({
|
|
178
178
|
opfData: e,
|
|
179
179
|
opfBasePath: s,
|
|
180
180
|
archive: t,
|
|
@@ -194,36 +194,39 @@ const v = {
|
|
|
194
194
|
}
|
|
195
195
|
})
|
|
196
196
|
), t;
|
|
197
|
-
},
|
|
197
|
+
}, se = async ({
|
|
198
198
|
archive: e
|
|
199
199
|
}) => {
|
|
200
|
-
const { data: t, basePath: i } =
|
|
200
|
+
const { data: t, basePath: i } = L(e) || {}, s = await (t == null ? void 0 : t.string());
|
|
201
201
|
if (!s) return [];
|
|
202
202
|
const n = new F.XmlDocument(s), r = n.childNamed("manifest"), a = n.childNamed("spine"), o = a == null ? void 0 : a.childrenNamed("itemref").map((c) => c.attr.idref), d = (r == null ? void 0 : r.childrenNamed("item").filter((c) => o.includes(c.attr.id || ""))) || [];
|
|
203
203
|
return e.files.filter((c) => d.find((l) => i ? `${i}/${l.attr.href}` === c.uri : `${l.attr.href}` === c.uri));
|
|
204
|
-
},
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
204
|
+
}, De = (e, t, i) => {
|
|
205
|
+
const s = e.attr.href || "", n = i == null ? void 0 : i(e);
|
|
206
|
+
return {
|
|
207
|
+
href: t ? `${n}${t}/${s}` : `${n}${s}`,
|
|
208
|
+
id: e.attr.id || "",
|
|
209
|
+
mediaType: e.attr["media-type"]
|
|
210
|
+
};
|
|
211
|
+
}, ie = (e, t, i) => {
|
|
212
|
+
var r;
|
|
213
|
+
const s = e.childNamed("manifest"), { basePath: n } = L(t) || {};
|
|
214
|
+
return ((r = s == null ? void 0 : s.childrenNamed("item")) == null ? void 0 : r.map((a) => De(a, n, i))) || [];
|
|
215
|
+
}, Oe = ({ archive: e, baseUrl: t }) => async (i) => {
|
|
213
216
|
var X;
|
|
214
|
-
const { data: s, basePath: n } =
|
|
217
|
+
const { data: s, basePath: n } = L(e) || {}, r = await je(e);
|
|
215
218
|
if (!s)
|
|
216
219
|
return i;
|
|
217
220
|
const a = await s.string();
|
|
218
221
|
v.log(a, r);
|
|
219
|
-
const o = new F.XmlDocument(a), d = await Re(o, e, { baseUrl: t }) || [], p = o.childNamed("metadata"), c = o.childNamed("manifest"), l = o.childNamed("spine"),
|
|
220
|
-
(
|
|
222
|
+
const o = new F.XmlDocument(a), d = await Re(o, e, { baseUrl: t }) || [], p = o.childNamed("metadata"), c = o.childNamed("manifest"), l = o.childNamed("spine"), m = o.childNamed("guide"), g = p == null ? void 0 : p.childNamed("dc:title"), b = (p == null ? void 0 : p.childrenNamed("meta")) || [], h = b.find(
|
|
223
|
+
(f) => f.attr.property === "rendition:layout"
|
|
221
224
|
), x = b.find(
|
|
222
|
-
(
|
|
225
|
+
(f) => f.attr.property === "rendition:flow"
|
|
223
226
|
), y = b.find(
|
|
224
|
-
(
|
|
225
|
-
), w = h == null ? void 0 : h.val,
|
|
226
|
-
(
|
|
227
|
+
(f) => f.attr.property === "rendition:spread"
|
|
228
|
+
), w = h == null ? void 0 : h.val, P = x == null ? void 0 : x.val, ae = y == null ? void 0 : y.val, oe = (g == null ? void 0 : g.val) || ((X = e.files.find(({ dir: f }) => f)) == null ? void 0 : X.basename) || "", ce = l == null ? void 0 : l.attr["page-progression-direction"], de = (await se({ archive: e })).reduce(
|
|
229
|
+
(f, W) => W.size + f,
|
|
227
230
|
0
|
|
228
231
|
);
|
|
229
232
|
return {
|
|
@@ -232,45 +235,51 @@ const v = {
|
|
|
232
235
|
toc: d
|
|
233
236
|
},
|
|
234
237
|
renditionLayout: w || r.renditionLayout || "reflowable",
|
|
235
|
-
renditionFlow:
|
|
236
|
-
renditionSpread:
|
|
237
|
-
title:
|
|
238
|
-
readingDirection:
|
|
239
|
-
spineItems: (l == null ? void 0 : l.childrenNamed("itemref").map((
|
|
240
|
-
var
|
|
241
|
-
const
|
|
238
|
+
renditionFlow: P || "auto",
|
|
239
|
+
renditionSpread: ae,
|
|
240
|
+
title: oe,
|
|
241
|
+
readingDirection: ce || "ltr",
|
|
242
|
+
spineItems: (l == null ? void 0 : l.childrenNamed("itemref").map((f, W) => {
|
|
243
|
+
var H, V, _;
|
|
244
|
+
const u = c == null ? void 0 : c.childrenNamed("item").find(($) => $.attr.id === (f == null ? void 0 : f.attr.idref)), B = (u == null ? void 0 : u.attr.href) || "", R = ((H = f == null ? void 0 : f.attr.properties) == null ? void 0 : H.split(" ")) || [], le = ((V = e.files.find(($) => $.uri.endsWith(B))) == null ? void 0 : V.size) || 0, U = t || (/^https?:\/\//.test(B) ? "" : "file://");
|
|
242
245
|
return {
|
|
243
|
-
id: (
|
|
244
|
-
index:
|
|
245
|
-
href: (
|
|
246
|
+
id: (u == null ? void 0 : u.attr.id) || "",
|
|
247
|
+
index: W,
|
|
248
|
+
href: (_ = u == null ? void 0 : u.attr.href) != null && _.startsWith("https://") ? u == null ? void 0 : u.attr.href : n ? `${U}${n}/${u == null ? void 0 : u.attr.href}` : `${U}${u == null ? void 0 : u.attr.href}`,
|
|
246
249
|
renditionLayout: w || "reflowable",
|
|
247
250
|
...R.find(
|
|
248
251
|
($) => $ === "rendition:layout-reflowable"
|
|
249
252
|
) && {
|
|
250
253
|
renditionLayout: "reflowable"
|
|
251
254
|
},
|
|
252
|
-
progressionWeight: le /
|
|
255
|
+
progressionWeight: le / de,
|
|
253
256
|
pageSpreadLeft: R.some(($) => $ === "page-spread-left") || void 0,
|
|
254
257
|
pageSpreadRight: R.some(($) => $ === "page-spread-right") || void 0,
|
|
255
258
|
// size: itemSize
|
|
256
|
-
mediaType:
|
|
259
|
+
mediaType: u == null ? void 0 : u.attr["media-type"]
|
|
257
260
|
};
|
|
258
261
|
})) || [],
|
|
259
|
-
items:
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
262
|
+
items: ie(o, e, (f) => {
|
|
263
|
+
const W = f.attr.href || "";
|
|
264
|
+
return /^https?:\/\//.test(W) ? "" : t || "file://";
|
|
265
|
+
}),
|
|
266
|
+
guide: m == null ? void 0 : m.childrenNamed("reference").map((f) => ({
|
|
267
|
+
href: f.attr.href || "",
|
|
268
|
+
title: f.attr.title || "",
|
|
269
|
+
type: f.attr.type
|
|
264
270
|
}))
|
|
265
271
|
};
|
|
266
|
-
},
|
|
267
|
-
var n, r;
|
|
268
|
-
const s = await ((n =
|
|
272
|
+
}, Me = async (e, t) => {
|
|
273
|
+
var n, r, a;
|
|
274
|
+
const s = await ((n = L(e).data) == null ? void 0 : n.string());
|
|
269
275
|
if (s) {
|
|
270
|
-
const
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
276
|
+
const o = new F.XmlDocument(s), d = ie(o, e, () => "");
|
|
277
|
+
if ((r = d.find(
|
|
278
|
+
(c) => t.endsWith(c.href)
|
|
279
|
+
)) == null ? void 0 : r.mediaType)
|
|
280
|
+
return {
|
|
281
|
+
mediaType: (a = d.find((c) => t.endsWith(c.href))) == null ? void 0 : a.mediaType
|
|
282
|
+
};
|
|
274
283
|
}
|
|
275
284
|
return {
|
|
276
285
|
mediaType: ze(t)
|
|
@@ -286,12 +295,12 @@ const v = {
|
|
|
286
295
|
return "video/mp4";
|
|
287
296
|
if (e.endsWith(".svg"))
|
|
288
297
|
return "image/svg+xml";
|
|
289
|
-
},
|
|
298
|
+
}, Xe = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
290
299
|
const s = Object.values(e.files).find(
|
|
291
300
|
(r) => r.uri === t
|
|
292
301
|
);
|
|
293
302
|
if (!s) return i;
|
|
294
|
-
const n = await
|
|
303
|
+
const n = await Me(e, t);
|
|
295
304
|
return {
|
|
296
305
|
...i,
|
|
297
306
|
params: {
|
|
@@ -304,7 +313,7 @@ const v = {
|
|
|
304
313
|
}
|
|
305
314
|
}
|
|
306
315
|
};
|
|
307
|
-
},
|
|
316
|
+
}, ee = [
|
|
308
317
|
"div",
|
|
309
318
|
"span",
|
|
310
319
|
"p",
|
|
@@ -355,19 +364,19 @@ const v = {
|
|
|
355
364
|
"canvas",
|
|
356
365
|
"script",
|
|
357
366
|
"style"
|
|
358
|
-
],
|
|
367
|
+
], Be = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
359
368
|
const s = Object.values(e.files).find(
|
|
360
369
|
(n) => n.uri === t
|
|
361
370
|
);
|
|
362
371
|
if (s != null && s.basename.endsWith(".xhtml")) {
|
|
363
372
|
const n = i.body ?? await s.string();
|
|
364
373
|
if (!new RegExp(
|
|
365
|
-
`<(${
|
|
374
|
+
`<(${ee.join("|")})[\\s/>]`,
|
|
366
375
|
"i"
|
|
367
376
|
).test(n))
|
|
368
377
|
return i;
|
|
369
378
|
const a = new RegExp(
|
|
370
|
-
`<(${
|
|
379
|
+
`<(${ee.join("|")})(\\s[^>]*)?\\s*/>`,
|
|
371
380
|
"gi"
|
|
372
381
|
), o = n.replace(
|
|
373
382
|
a,
|
|
@@ -379,7 +388,7 @@ const v = {
|
|
|
379
388
|
};
|
|
380
389
|
}
|
|
381
390
|
return i;
|
|
382
|
-
},
|
|
391
|
+
}, Ue = async (e, t) => {
|
|
383
392
|
const i = Object.values(e.files).find(
|
|
384
393
|
(r) => r.uri === t
|
|
385
394
|
);
|
|
@@ -388,10 +397,10 @@ const v = {
|
|
|
388
397
|
const s = {
|
|
389
398
|
params: {}
|
|
390
399
|
}, n = [
|
|
391
|
-
Me({ archive: e, resourcePath: t }),
|
|
392
400
|
Xe({ archive: e, resourcePath: t }),
|
|
393
|
-
|
|
394
|
-
ke({ archive: e, resourcePath: t })
|
|
401
|
+
Be({ archive: e, resourcePath: t }),
|
|
402
|
+
ke({ archive: e, resourcePath: t }),
|
|
403
|
+
We({ archive: e, resourcePath: t })
|
|
395
404
|
];
|
|
396
405
|
try {
|
|
397
406
|
const r = await n.reduce(async (a, o) => await o(await a), Promise.resolve(s));
|
|
@@ -402,7 +411,7 @@ const v = {
|
|
|
402
411
|
} catch (r) {
|
|
403
412
|
throw v.error(r), r;
|
|
404
413
|
}
|
|
405
|
-
},
|
|
414
|
+
}, He = ({ archive: e, baseUrl: t }) => async () => {
|
|
406
415
|
var s;
|
|
407
416
|
const i = Object.values(e.files).filter((n) => !n.dir);
|
|
408
417
|
return {
|
|
@@ -426,10 +435,10 @@ const v = {
|
|
|
426
435
|
})),
|
|
427
436
|
items: i.map((n, r) => ({
|
|
428
437
|
id: `${r}.${n.basename}`,
|
|
429
|
-
href: `${t}${n.uri}`
|
|
438
|
+
href: encodeURI(`${t}${n.uri}`)
|
|
430
439
|
}))
|
|
431
440
|
};
|
|
432
|
-
},
|
|
441
|
+
}, Ve = ({ archive: e }) => async (t) => {
|
|
433
442
|
var r;
|
|
434
443
|
const i = e.files.find(
|
|
435
444
|
(a) => a.basename.toLowerCase() === "comicinfo.xml"
|
|
@@ -453,22 +462,22 @@ const v = {
|
|
|
453
462
|
return console.error(`Unable to parse comicinfo.xml for content
|
|
454
463
|
`, n), console.error(a), s;
|
|
455
464
|
}
|
|
456
|
-
},
|
|
465
|
+
}, _e = (e) => {
|
|
457
466
|
var i;
|
|
458
467
|
const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((s) => s.attr.name === "viewport");
|
|
459
468
|
return !!(t && t.attr.name === "viewport");
|
|
460
|
-
},
|
|
469
|
+
}, qe = (e) => e.reduce(async (t, i) => {
|
|
461
470
|
if (!await t || !me({
|
|
462
471
|
mimeType: i.encodingFormat,
|
|
463
472
|
uri: i.uri
|
|
464
473
|
}))
|
|
465
474
|
return !1;
|
|
466
475
|
const n = await i.string();
|
|
467
|
-
return n ?
|
|
468
|
-
}, Promise.resolve(!0)),
|
|
476
|
+
return n ? _e(new F.XmlDocument(n)) : !1;
|
|
477
|
+
}, Promise.resolve(!0)), Ge = ({ archive: e }) => async (t) => {
|
|
469
478
|
if (t.renditionLayout === "reflowable" && t.spineItems.every((s) => s.renditionLayout === "reflowable")) {
|
|
470
|
-
const s = await
|
|
471
|
-
if (await
|
|
479
|
+
const s = await se({ archive: e });
|
|
480
|
+
if (await qe(s))
|
|
472
481
|
return {
|
|
473
482
|
...t,
|
|
474
483
|
spineItems: t.spineItems.map((r) => ({
|
|
@@ -479,27 +488,27 @@ const v = {
|
|
|
479
488
|
};
|
|
480
489
|
}
|
|
481
490
|
return t;
|
|
482
|
-
},
|
|
491
|
+
}, z = (e, t) => {
|
|
483
492
|
var n;
|
|
484
493
|
const i = e.split(/(\d+)/), s = t.split(/(\d+)/);
|
|
485
494
|
for (let r = 0, a = i.length; r < a; r++)
|
|
486
495
|
if (i[r] !== s[r])
|
|
487
496
|
return (n = i[r]) != null && n.match(/\d/) ? +(i[r] || "") - +(s[r] || "") : (i[r] || "").localeCompare(s[r] || "");
|
|
488
497
|
return 1;
|
|
489
|
-
},
|
|
498
|
+
}, Ke = ({ archive: e, baseUrl: t }) => async (i) => {
|
|
490
499
|
if (i.nav) return i;
|
|
491
500
|
const s = [...e.files].sort(
|
|
492
|
-
(o, d) =>
|
|
501
|
+
(o, d) => z(o.uri, d.uri)
|
|
493
502
|
), n = Object.values(s), r = (o, d, p, c, l) => {
|
|
494
|
-
const
|
|
495
|
-
return
|
|
496
|
-
...o.filter((x) => x !=
|
|
503
|
+
const m = o.find((h) => h.title === d), [g, ...b] = p;
|
|
504
|
+
return m ? g ? [
|
|
505
|
+
...o.filter((x) => x != m),
|
|
497
506
|
{
|
|
498
|
-
...
|
|
507
|
+
...m,
|
|
499
508
|
contents: [
|
|
500
|
-
...
|
|
509
|
+
...m.contents,
|
|
501
510
|
...r(
|
|
502
|
-
|
|
511
|
+
m.contents,
|
|
503
512
|
g,
|
|
504
513
|
b,
|
|
505
514
|
c,
|
|
@@ -507,10 +516,10 @@ const v = {
|
|
|
507
516
|
)
|
|
508
517
|
]
|
|
509
518
|
}
|
|
510
|
-
] :
|
|
511
|
-
...o.filter((x) => x !=
|
|
519
|
+
] : m.path.split("/").length > l.split("/").length ? [
|
|
520
|
+
...o.filter((x) => x != m),
|
|
512
521
|
{
|
|
513
|
-
...
|
|
522
|
+
...m,
|
|
514
523
|
path: l,
|
|
515
524
|
href: c
|
|
516
525
|
}
|
|
@@ -540,10 +549,10 @@ const v = {
|
|
|
540
549
|
}, a = n.reduce(
|
|
541
550
|
(o, d) => {
|
|
542
551
|
if (d.dir) return o;
|
|
543
|
-
const c = d.uri.split("/").slice(0, -1), [l, ...
|
|
552
|
+
const c = d.uri.split("/").slice(0, -1), [l, ...m] = c;
|
|
544
553
|
if (l) {
|
|
545
554
|
const g = N(t, encodeURI(d.uri)).replace(/\/$/, ""), b = d.uri.replace(/\/$/, "");
|
|
546
|
-
return r(o, l,
|
|
555
|
+
return r(o, l, m, g, b);
|
|
547
556
|
}
|
|
548
557
|
return o;
|
|
549
558
|
},
|
|
@@ -555,7 +564,7 @@ const v = {
|
|
|
555
564
|
toc: a
|
|
556
565
|
}
|
|
557
566
|
};
|
|
558
|
-
},
|
|
567
|
+
}, Je = {
|
|
559
568
|
filename: "",
|
|
560
569
|
items: [],
|
|
561
570
|
nav: {
|
|
@@ -566,21 +575,21 @@ const v = {
|
|
|
566
575
|
renditionSpread: "auto",
|
|
567
576
|
spineItems: [],
|
|
568
577
|
title: ""
|
|
569
|
-
},
|
|
578
|
+
}, Ye = async (e, { baseUrl: t = "" } = {}) => {
|
|
570
579
|
const i = [
|
|
571
|
-
Ue({ archive: e, baseUrl: t }),
|
|
572
|
-
De({ archive: e, baseUrl: t }),
|
|
573
|
-
qe({ archive: e, baseUrl: t }),
|
|
574
580
|
He({ archive: e, baseUrl: t }),
|
|
575
|
-
|
|
581
|
+
Oe({ archive: e, baseUrl: t }),
|
|
582
|
+
Ge({ archive: e, baseUrl: t }),
|
|
583
|
+
Ve({ archive: e, baseUrl: t }),
|
|
584
|
+
Ke({ archive: e, baseUrl: t })
|
|
576
585
|
];
|
|
577
586
|
try {
|
|
578
|
-
const s = await i.reduce(async (n, r) => await r(await n), Promise.resolve(
|
|
587
|
+
const s = await i.reduce(async (n, r) => await r(await n), Promise.resolve(Je));
|
|
579
588
|
return v.log("Generated manifest", s), s;
|
|
580
589
|
} catch (s) {
|
|
581
590
|
throw v.error(s), s;
|
|
582
591
|
}
|
|
583
|
-
},
|
|
592
|
+
}, st = async (e, t) => {
|
|
584
593
|
const i = `
|
|
585
594
|
<?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
|
|
586
595
|
<metadata>
|
|
@@ -589,7 +598,7 @@ const v = {
|
|
|
589
598
|
</metadata>
|
|
590
599
|
<manifest>
|
|
591
600
|
${e.map(
|
|
592
|
-
(r) => `<item id="${T(r)}" href="${r}" media-type="${
|
|
601
|
+
(r) => `<item id="${T(r)}" href="${r}" media-type="${q(r)}"/>`
|
|
593
602
|
).join(`
|
|
594
603
|
`)}
|
|
595
604
|
</manifest>
|
|
@@ -601,7 +610,7 @@ const v = {
|
|
|
601
610
|
`, s = e.map((r) => ({
|
|
602
611
|
dir: !1,
|
|
603
612
|
basename: T(r),
|
|
604
|
-
encodingFormat:
|
|
613
|
+
encodingFormat: q(r),
|
|
605
614
|
uri: r,
|
|
606
615
|
size: 100 / e.length,
|
|
607
616
|
blob: async () => (await fetch(r)).blob(),
|
|
@@ -619,7 +628,7 @@ const v = {
|
|
|
619
628
|
}, ...s],
|
|
620
629
|
close: () => Promise.resolve()
|
|
621
630
|
};
|
|
622
|
-
},
|
|
631
|
+
}, it = async (e, {
|
|
623
632
|
mimeType: t,
|
|
624
633
|
direction: i
|
|
625
634
|
} = { mimeType: "text/plain" }) => {
|
|
@@ -662,9 +671,9 @@ const v = {
|
|
|
662
671
|
],
|
|
663
672
|
close: () => Promise.resolve()
|
|
664
673
|
};
|
|
665
|
-
},
|
|
674
|
+
}, at = async (e, { orderByAlpha: t, name: i } = {}) => {
|
|
666
675
|
let s = Object.values(e.files);
|
|
667
|
-
t && (s = s.slice().sort((r, a) =>
|
|
676
|
+
t && (s = s.slice().sort((r, a) => z(r.name, a.name)));
|
|
668
677
|
const n = {
|
|
669
678
|
filename: i || "",
|
|
670
679
|
files: s.map((r) => ({
|
|
@@ -684,7 +693,7 @@ const v = {
|
|
|
684
693
|
close: () => Promise.resolve()
|
|
685
694
|
};
|
|
686
695
|
return v.log("Generated archive", n), n;
|
|
687
|
-
},
|
|
696
|
+
}, ot = async (e, { name: t } = {}) => {
|
|
688
697
|
const i = await e.getFilesArray(), s = {
|
|
689
698
|
close: () => e.close(),
|
|
690
699
|
filename: t ?? "",
|
|
@@ -698,9 +707,9 @@ const v = {
|
|
|
698
707
|
}))
|
|
699
708
|
};
|
|
700
709
|
return v.log("Generated archive", s), s;
|
|
701
|
-
},
|
|
710
|
+
}, ct = async (e, { orderByAlpha: t, name: i } = {}) => {
|
|
702
711
|
let s = e;
|
|
703
|
-
return t && (s = s.slice().sort((n, r) =>
|
|
712
|
+
return t && (s = s.slice().sort((n, r) => z(n.name, r.name))), {
|
|
704
713
|
filename: i || "",
|
|
705
714
|
files: s.map((n) => ({
|
|
706
715
|
dir: n.isDir,
|
|
@@ -718,12 +727,12 @@ const v = {
|
|
|
718
727
|
})),
|
|
719
728
|
close: () => Promise.resolve()
|
|
720
729
|
};
|
|
721
|
-
},
|
|
730
|
+
}, dt = ({
|
|
722
731
|
enableReport: e
|
|
723
732
|
} = {}) => {
|
|
724
733
|
v.enable(!!e);
|
|
725
734
|
};
|
|
726
|
-
class
|
|
735
|
+
class Ee {
|
|
727
736
|
constructor(t) {
|
|
728
737
|
this.cleanArchiveAfter = t, this.state$ = new ve({
|
|
729
738
|
status: "idle",
|
|
@@ -749,7 +758,7 @@ class Ye {
|
|
|
749
758
|
get overTTL$() {
|
|
750
759
|
return this.isUnlocked$.pipe(
|
|
751
760
|
k(
|
|
752
|
-
(t) => t ? this.cleanArchiveAfter === 1 / 0 ?
|
|
761
|
+
(t) => t ? this.cleanArchiveAfter === 1 / 0 ? J : Fe(this.cleanArchiveAfter) : J
|
|
753
762
|
)
|
|
754
763
|
);
|
|
755
764
|
}
|
|
@@ -760,14 +769,14 @@ const Qe = ({
|
|
|
760
769
|
// 5mn
|
|
761
770
|
}) => {
|
|
762
771
|
const i = new j(), s = new j(), n = new j(), r = {}, a = i.pipe(
|
|
763
|
-
|
|
772
|
+
M((p) => {
|
|
764
773
|
const c = r[p];
|
|
765
|
-
if (!c || c.state.status !== "idle") return
|
|
774
|
+
if (!c || c.state.status !== "idle") return G;
|
|
766
775
|
let l = !1;
|
|
767
|
-
const
|
|
768
|
-
var
|
|
776
|
+
const m = (y) => {
|
|
777
|
+
var P;
|
|
769
778
|
const w = r[y];
|
|
770
|
-
delete r[y], l || ((
|
|
779
|
+
delete r[y], l || ((P = w == null ? void 0 : w.state.archive) == null || P.close(), l = !0);
|
|
771
780
|
};
|
|
772
781
|
c.update({
|
|
773
782
|
status: "loading"
|
|
@@ -777,38 +786,38 @@ const Qe = ({
|
|
|
777
786
|
D(([y, w]) => w > y),
|
|
778
787
|
ge(!0)
|
|
779
788
|
);
|
|
780
|
-
return
|
|
789
|
+
return I(e(p)).pipe(
|
|
781
790
|
O((y) => {
|
|
782
791
|
c.update({
|
|
783
792
|
archive: y,
|
|
784
793
|
status: "success"
|
|
785
794
|
});
|
|
786
795
|
}),
|
|
787
|
-
|
|
796
|
+
C((y) => (m(p), c.update({
|
|
788
797
|
status: "error",
|
|
789
798
|
error: y
|
|
790
|
-
}),
|
|
799
|
+
}), G)),
|
|
791
800
|
k(() => {
|
|
792
801
|
const y = h.pipe(
|
|
793
802
|
k(() => n),
|
|
794
803
|
k(() => b),
|
|
795
804
|
D((w) => w)
|
|
796
805
|
);
|
|
797
|
-
return
|
|
806
|
+
return K(y, c.overTTL$);
|
|
798
807
|
}),
|
|
799
808
|
O(() => {
|
|
800
|
-
|
|
809
|
+
m(p);
|
|
801
810
|
})
|
|
802
811
|
);
|
|
803
812
|
}),
|
|
804
813
|
ye(s)
|
|
805
814
|
), o = (p) => {
|
|
806
815
|
let c = !1;
|
|
807
|
-
const l = r[p] ?? new
|
|
816
|
+
const l = r[p] ?? new Ee(t);
|
|
808
817
|
r[p] = l, l.update({
|
|
809
818
|
locks: l.state.locks + 1
|
|
810
819
|
});
|
|
811
|
-
const
|
|
820
|
+
const m = () => {
|
|
812
821
|
c || (c = !0, l.update({
|
|
813
822
|
locks: l.state.locks - 1
|
|
814
823
|
}));
|
|
@@ -824,11 +833,11 @@ const Qe = ({
|
|
|
824
833
|
}),
|
|
825
834
|
be()
|
|
826
835
|
);
|
|
827
|
-
return
|
|
836
|
+
return K(g, b).pipe(
|
|
828
837
|
we(),
|
|
829
|
-
A((h) => ({ archive: h, release:
|
|
830
|
-
|
|
831
|
-
throw
|
|
838
|
+
A((h) => ({ archive: h, release: m })),
|
|
839
|
+
C((h) => {
|
|
840
|
+
throw m(), h;
|
|
832
841
|
})
|
|
833
842
|
);
|
|
834
843
|
}, d = () => {
|
|
@@ -861,22 +870,22 @@ class Ze {
|
|
|
861
870
|
}
|
|
862
871
|
fetchManifest({ key: t, baseUrl: i }) {
|
|
863
872
|
const s = this.accessArchive(t).pipe(
|
|
864
|
-
|
|
865
|
-
|
|
873
|
+
M(({ archive: n, release: r }) => I(
|
|
874
|
+
Ye(n, { baseUrl: i })
|
|
866
875
|
).pipe(
|
|
867
876
|
k(
|
|
868
|
-
(o) =>
|
|
877
|
+
(o) => I(this.onManifestSuccess({ manifest: o, archive: n }))
|
|
869
878
|
),
|
|
870
879
|
A(
|
|
871
880
|
(o) => new Response(JSON.stringify(o), {
|
|
872
881
|
status: 200
|
|
873
882
|
})
|
|
874
883
|
),
|
|
875
|
-
|
|
884
|
+
Y(() => {
|
|
876
885
|
r();
|
|
877
886
|
})
|
|
878
887
|
)),
|
|
879
|
-
|
|
888
|
+
C((n) => E(this.onError(n)))
|
|
880
889
|
);
|
|
881
890
|
return Q(s);
|
|
882
891
|
}
|
|
@@ -885,29 +894,32 @@ class Ze {
|
|
|
885
894
|
resourcePath: i
|
|
886
895
|
}) {
|
|
887
896
|
const s = this.accessArchive(t).pipe(
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
+
M(({ archive: n, release: r }) => {
|
|
898
|
+
const a = i.replaceAll("file://", "");
|
|
899
|
+
return I(
|
|
900
|
+
Ue(n, a)
|
|
901
|
+
).pipe(
|
|
902
|
+
A(
|
|
903
|
+
(d) => new Response(d.body, {
|
|
904
|
+
status: 200,
|
|
905
|
+
headers: {
|
|
906
|
+
...d.params.contentType && {
|
|
907
|
+
"Content-Type": d.params.contentType
|
|
908
|
+
}
|
|
897
909
|
}
|
|
898
|
-
}
|
|
910
|
+
})
|
|
911
|
+
),
|
|
912
|
+
Y(() => {
|
|
913
|
+
r();
|
|
899
914
|
})
|
|
900
|
-
)
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
})
|
|
904
|
-
)),
|
|
905
|
-
P((n) => Y(this.onError(n)))
|
|
915
|
+
);
|
|
916
|
+
}),
|
|
917
|
+
C((n) => E(this.onError(n)))
|
|
906
918
|
);
|
|
907
919
|
return Q(s);
|
|
908
920
|
}
|
|
909
921
|
}
|
|
910
|
-
class
|
|
922
|
+
class lt extends Ze {
|
|
911
923
|
constructor({
|
|
912
924
|
getUriInfo: t,
|
|
913
925
|
...i
|
|
@@ -932,16 +944,16 @@ class dt extends Ze {
|
|
|
932
944
|
}
|
|
933
945
|
}
|
|
934
946
|
export {
|
|
935
|
-
|
|
947
|
+
lt as ServiceWorkerStreamer,
|
|
936
948
|
Ze as Streamer,
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
949
|
+
dt as configure,
|
|
950
|
+
ct as createArchiveFromArrayBufferList,
|
|
951
|
+
at as createArchiveFromJszip,
|
|
952
|
+
ot as createArchiveFromLibArchive,
|
|
953
|
+
it as createArchiveFromText,
|
|
954
|
+
st as createArchiveFromUrls,
|
|
955
|
+
Ye as generateManifestFromArchive,
|
|
956
|
+
Ue as generateResourceFromArchive,
|
|
957
|
+
L as getArchiveOpfInfo
|
|
946
958
|
};
|
|
947
959
|
//# sourceMappingURL=index.js.map
|