@prose-reader/streamer 1.208.0 → 1.210.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/archiveLoader.d.ts +1 -1
- package/dist/generators/manifest/hooks/epub/epub.d.ts +2 -2
- package/dist/generators/manifest/hooks/epub/spineItems.d.ts +2 -2
- package/dist/index.js +246 -244
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +3 -3
- package/dist/index.umd.cjs.map +1 -1
- package/dist/parsers/nav.d.ts +2 -2
- package/package.json +6 -7
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { urlJoin as
|
|
3
|
-
import { Subject as R, mergeMap as
|
|
1
|
+
import { XmlDocument as w, XmlTextNode as le, XmlElement as pe } from "xmldoc";
|
|
2
|
+
import { urlJoin as N, isXmlBasedMimeType as fe, parseContentType as ue, detectMimeTypeFromName as M } from "@prose-reader/shared";
|
|
3
|
+
import { Subject as R, mergeMap as z, EMPTY as _, pairwise as he, filter as j, startWith as me, from as C, tap as O, catchError as P, switchMap as W, merge as q, first as G, takeUntil as ge, map as F, ignoreElements as ye, BehaviorSubject as be, distinctUntilChanged as we, shareReplay as ve, NEVER as K, timer as $e, finalize as J, of as Y, lastValueFrom as Q } from "rxjs";
|
|
4
4
|
let S = !1;
|
|
5
5
|
const v = {
|
|
6
6
|
enable: (e) => {
|
|
@@ -22,31 +22,31 @@ const v = {
|
|
|
22
22
|
error: (...e) => {
|
|
23
23
|
console.error(...e);
|
|
24
24
|
}
|
|
25
|
-
},
|
|
25
|
+
}, xe = (e) => {
|
|
26
26
|
var i;
|
|
27
27
|
const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((r) => r.attr.name === "calibre:cover");
|
|
28
28
|
return !!(t && t.attr.name === "calibre:cover");
|
|
29
|
-
},
|
|
29
|
+
}, Fe = (e) => {
|
|
30
30
|
var t, i, r;
|
|
31
31
|
return (r = (i = (t = e.descendantWithPath("body")) == null ? void 0 : t.descendantWithPath("div")) == null ? void 0 : i.childrenNamed("svg")) == null ? void 0 : r.find(
|
|
32
32
|
(n) => n.attr.width === "100%" && n.attr.preserveAspectRatio === "none"
|
|
33
33
|
);
|
|
34
|
-
},
|
|
34
|
+
}, Ae = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
35
35
|
const r = Object.values(e.files).find(
|
|
36
36
|
(n) => n.uri === t
|
|
37
37
|
);
|
|
38
38
|
if (r != null && r.basename.endsWith(".xhtml")) {
|
|
39
|
-
const n = i.body ?? await r.string(), s = new
|
|
40
|
-
if (
|
|
41
|
-
const
|
|
42
|
-
return
|
|
39
|
+
const n = i.body ?? await r.string(), s = new w(n);
|
|
40
|
+
if (xe(s)) {
|
|
41
|
+
const a = Fe(s);
|
|
42
|
+
return a && delete a.attr.preserveAspectRatio, {
|
|
43
43
|
...i,
|
|
44
44
|
body: s == null ? void 0 : s.toString()
|
|
45
45
|
};
|
|
46
46
|
}
|
|
47
47
|
}
|
|
48
48
|
return i;
|
|
49
|
-
},
|
|
49
|
+
}, Te = ({ archive: e, resourcePath: t }) => async (i) => Ae({ archive: e, resourcePath: t })(i), Le = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
50
50
|
const r = Object.values(e.files).find(
|
|
51
51
|
(n) => n.uri === t
|
|
52
52
|
);
|
|
@@ -61,10 +61,23 @@ const v = {
|
|
|
61
61
|
};
|
|
62
62
|
}
|
|
63
63
|
return i;
|
|
64
|
-
},
|
|
64
|
+
}, k = (e) => {
|
|
65
|
+
const i = Object.values(e.files).filter((r) => !r.dir).find((r) => r.uri.endsWith(".opf"));
|
|
66
|
+
return {
|
|
67
|
+
data: i,
|
|
68
|
+
basePath: (i == null ? void 0 : i.uri.substring(0, i.uri.lastIndexOf("/"))) || ""
|
|
69
|
+
};
|
|
70
|
+
}, te = async ({
|
|
71
|
+
archive: e
|
|
72
|
+
}) => {
|
|
73
|
+
const { data: t, basePath: i } = k(e) || {}, r = await (t == null ? void 0 : t.string());
|
|
74
|
+
if (!r) return [];
|
|
75
|
+
const n = new w(r), s = n.childNamed("manifest"), a = n.childNamed("spine"), o = a == null ? void 0 : a.childrenNamed("itemref").map((c) => c.attr.idref), d = (s == null ? void 0 : s.childrenNamed("item").filter((c) => o.includes(c.attr.id || ""))) || [];
|
|
76
|
+
return e.files.filter((c) => d.find((p) => i ? `${i}/${p.attr.href}` === c.uri : `${p.attr.href}` === c.uri));
|
|
77
|
+
}, A = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Z = (e) => e.endsWith("/") ? e.slice(0, -1) : e, We = (e) => {
|
|
65
78
|
const t = e.lastIndexOf("/");
|
|
66
79
|
return t >= 0 ? e.substring(0, t) : "";
|
|
67
|
-
},
|
|
80
|
+
}, ne = (e) => e ? e.children.map((t) => t instanceof le ? t.text : t instanceof pe ? ne(t) : "").join("").trim() : "", re = (e, { basePath: t, baseUrl: i }) => {
|
|
68
81
|
const r = {
|
|
69
82
|
contents: [],
|
|
70
83
|
path: "",
|
|
@@ -72,57 +85,57 @@ const v = {
|
|
|
72
85
|
title: ""
|
|
73
86
|
};
|
|
74
87
|
let n = e.childNamed("span") || e.childNamed("a");
|
|
75
|
-
r.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) ||
|
|
88
|
+
r.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || ne(n)) ?? "";
|
|
76
89
|
let s = n == null ? void 0 : n.name;
|
|
77
|
-
s !== "a" && (n = e.descendantWithPath(`${s}.a`), n && (s = n.name.toLowerCase())), s === "a" && (n != null && n.attr.href) && (r.path =
|
|
78
|
-
const
|
|
79
|
-
if (
|
|
80
|
-
const
|
|
81
|
-
|
|
82
|
-
(d) =>
|
|
90
|
+
s !== "a" && (n = e.descendantWithPath(`${s}.a`), n && (s = n.name.toLowerCase())), s === "a" && (n != null && n.attr.href) && (r.path = N(t, n.attr.href), r.href = N(i, t, n.attr.href));
|
|
91
|
+
const a = e.childNamed("ol");
|
|
92
|
+
if (a) {
|
|
93
|
+
const o = a.childrenNamed("li");
|
|
94
|
+
o && o.length > 0 && (r.contents = o.map(
|
|
95
|
+
(d) => re(d, { basePath: t, baseUrl: i })
|
|
83
96
|
));
|
|
84
97
|
}
|
|
85
98
|
return r;
|
|
86
|
-
},
|
|
87
|
-
var s,
|
|
99
|
+
}, Ne = (e, { basePath: t, baseUrl: i }) => {
|
|
100
|
+
var s, a;
|
|
88
101
|
const r = [];
|
|
89
102
|
let n;
|
|
90
|
-
return e.descendantWithPath("body.nav.ol") ? n = (s = e.descendantWithPath("body.nav.ol")) == null ? void 0 : s.children : e.descendantWithPath("body.section.nav.ol") && (n = (
|
|
91
|
-
(
|
|
103
|
+
return e.descendantWithPath("body.nav.ol") ? n = (s = e.descendantWithPath("body.nav.ol")) == null ? void 0 : s.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(
|
|
104
|
+
(o) => r.push(re(o, { basePath: t, baseUrl: i }))
|
|
92
105
|
), r;
|
|
93
|
-
},
|
|
106
|
+
}, ke = async (e, t, { baseUrl: i }) => {
|
|
94
107
|
var n;
|
|
95
108
|
const r = (n = e.childNamed("manifest")) == null ? void 0 : n.childrenNamed("item").find((s) => s.attr.properties === "nav");
|
|
96
109
|
if (r) {
|
|
97
110
|
const s = Object.values(t.files).find(
|
|
98
|
-
(
|
|
111
|
+
(a) => a.uri.endsWith(r.attr.href || "")
|
|
99
112
|
);
|
|
100
113
|
if (s) {
|
|
101
|
-
const
|
|
102
|
-
return
|
|
114
|
+
const a = new w(await s.string()), o = We(s.uri);
|
|
115
|
+
return Ne(a, { basePath: o, baseUrl: i });
|
|
103
116
|
}
|
|
104
117
|
}
|
|
105
|
-
},
|
|
118
|
+
}, se = (e, {
|
|
106
119
|
opfBasePath: t,
|
|
107
120
|
baseUrl: i,
|
|
108
121
|
prefix: r
|
|
109
122
|
}) => {
|
|
110
|
-
var
|
|
111
|
-
const n = ((
|
|
123
|
+
var o, d;
|
|
124
|
+
const n = ((o = e == null ? void 0 : e.childNamed(`${r}content`)) == null ? void 0 : o.attr.src) || "", s = {
|
|
112
125
|
title: ((d = e == null ? void 0 : e.descendantWithPath(`${r}navLabel.${r}text`)) == null ? void 0 : d.val) || "",
|
|
113
|
-
path:
|
|
114
|
-
href:
|
|
126
|
+
path: N(t, n),
|
|
127
|
+
href: N(i, t, n),
|
|
115
128
|
contents: []
|
|
116
|
-
},
|
|
117
|
-
return
|
|
118
|
-
(l) =>
|
|
129
|
+
}, a = e.childrenNamed(`${r}navPoint`);
|
|
130
|
+
return a && a.length > 0 && (s.contents = a.map(
|
|
131
|
+
(l) => se(l, { opfBasePath: t, baseUrl: i, prefix: r })
|
|
119
132
|
)), s;
|
|
120
|
-
},
|
|
121
|
-
var
|
|
133
|
+
}, Se = (e, { opfBasePath: t, baseUrl: i }) => {
|
|
134
|
+
var a;
|
|
122
135
|
const r = [], n = e.name;
|
|
123
136
|
let s = "";
|
|
124
|
-
return n.indexOf(":") !== -1 && (s = `${n.split(":")[0]}:`), (
|
|
125
|
-
(
|
|
137
|
+
return n.indexOf(":") !== -1 && (s = `${n.split(":")[0]}:`), (a = e.childNamed(`${s}navMap`)) == null || a.childrenNamed(`${s}navPoint`).forEach(
|
|
138
|
+
(o) => r.push(se(o, { opfBasePath: t, baseUrl: i, prefix: s }))
|
|
126
139
|
), r;
|
|
127
140
|
}, Ce = async ({
|
|
128
141
|
opfData: e,
|
|
@@ -130,31 +143,31 @@ const v = {
|
|
|
130
143
|
baseUrl: i,
|
|
131
144
|
archive: r
|
|
132
145
|
}) => {
|
|
133
|
-
var
|
|
146
|
+
var a;
|
|
134
147
|
const n = e.childNamed("spine"), s = n == null ? void 0 : n.attr.toc;
|
|
135
148
|
if (s) {
|
|
136
|
-
const
|
|
137
|
-
if (
|
|
138
|
-
const d = `${t}${t === "" ? "" : "/"}${
|
|
149
|
+
const o = (a = e.childNamed("manifest")) == null ? void 0 : a.childrenNamed("item").find((d) => d.attr.id === s);
|
|
150
|
+
if (o) {
|
|
151
|
+
const d = `${t}${t === "" ? "" : "/"}${o.attr.href}`, l = Object.values(r.files).find(
|
|
139
152
|
(c) => c.uri.endsWith(d)
|
|
140
153
|
);
|
|
141
154
|
if (l) {
|
|
142
|
-
const c = new
|
|
143
|
-
return
|
|
155
|
+
const c = new w(await l.string());
|
|
156
|
+
return Se(c, { opfBasePath: t, baseUrl: i });
|
|
144
157
|
}
|
|
145
158
|
}
|
|
146
159
|
}
|
|
147
|
-
},
|
|
148
|
-
const { basePath: r } =
|
|
160
|
+
}, Pe = async (e, t, { baseUrl: i }) => {
|
|
161
|
+
const { basePath: r } = k(t) || {}, n = await Ce({
|
|
149
162
|
opfData: e,
|
|
150
163
|
opfBasePath: r,
|
|
151
164
|
archive: t,
|
|
152
165
|
baseUrl: i
|
|
153
166
|
});
|
|
154
|
-
return n || await
|
|
167
|
+
return n || await ke(e, t, {
|
|
155
168
|
baseUrl: i
|
|
156
169
|
});
|
|
157
|
-
},
|
|
170
|
+
}, Ie = (e) => {
|
|
158
171
|
var r;
|
|
159
172
|
const t = ((r = e.attr.properties) == null ? void 0 : r.split(" ")) || [];
|
|
160
173
|
let i;
|
|
@@ -163,94 +176,81 @@ const v = {
|
|
|
163
176
|
pageSpreadLeft: t.some((n) => n === "page-spread-left") || void 0,
|
|
164
177
|
pageSpreadRight: t.some((n) => n === "page-spread-right") || void 0
|
|
165
178
|
};
|
|
166
|
-
},
|
|
167
|
-
const i = Object.values(e.files).filter((r) => !r.dir).find((r) => r.uri.endsWith(".opf"));
|
|
168
|
-
return {
|
|
169
|
-
data: i,
|
|
170
|
-
basePath: (i == null ? void 0 : i.uri.substring(0, i.uri.lastIndexOf("/"))) || ""
|
|
171
|
-
};
|
|
172
|
-
}, re = async ({
|
|
173
|
-
archive: e
|
|
174
|
-
}) => {
|
|
175
|
-
const { data: t, basePath: i } = N(e) || {}, r = await (t == null ? void 0 : t.string());
|
|
176
|
-
if (!r) return [];
|
|
177
|
-
const n = new $.XmlDocument(r), s = n.childNamed("manifest"), o = n.childNamed("spine"), a = o == null ? void 0 : o.childrenNamed("itemref").map((c) => c.attr.idref), d = (s == null ? void 0 : s.childrenNamed("item").filter((c) => a.includes(c.attr.id || ""))) || [];
|
|
178
|
-
return e.files.filter((c) => d.find((p) => i ? `${i}/${p.attr.href}` === c.uri : `${p.attr.href}` === c.uri));
|
|
179
|
-
}, De = (e, t, i) => {
|
|
179
|
+
}, Re = (e, t, i) => {
|
|
180
180
|
const r = e.attr.href || "", n = i == null ? void 0 : i(e);
|
|
181
181
|
return {
|
|
182
182
|
href: t ? `${n}${t}/${r}` : `${n}${r}`,
|
|
183
183
|
id: e.attr.id || "",
|
|
184
184
|
mediaType: e.attr["media-type"]
|
|
185
185
|
};
|
|
186
|
-
},
|
|
186
|
+
}, ie = (e, t, i) => {
|
|
187
187
|
var s;
|
|
188
|
-
const r = e.childNamed("manifest"), { basePath: n } =
|
|
189
|
-
return ((s = r == null ? void 0 : r.childrenNamed("item")) == null ? void 0 : s.map((
|
|
188
|
+
const r = e.childNamed("manifest"), { basePath: n } = k(t) || {};
|
|
189
|
+
return ((s = r == null ? void 0 : r.childrenNamed("item")) == null ? void 0 : s.map((a) => Re(a, n, i))) || [];
|
|
190
190
|
}, je = ({ archive: e, baseUrl: t }) => async (i) => {
|
|
191
|
-
var
|
|
192
|
-
const { data: r, basePath: n } =
|
|
191
|
+
var U;
|
|
192
|
+
const { data: r, basePath: n } = k(e) || {};
|
|
193
193
|
if (!r)
|
|
194
194
|
return i;
|
|
195
195
|
const s = await r.string();
|
|
196
196
|
v.log("data", s);
|
|
197
|
-
const
|
|
198
|
-
(
|
|
199
|
-
),
|
|
200
|
-
(
|
|
201
|
-
),
|
|
202
|
-
(
|
|
203
|
-
), y = b == null ? void 0 : b.val,
|
|
204
|
-
(
|
|
197
|
+
const a = new w(s), o = await Pe(a, e, { baseUrl: t }) || [], d = a.childNamed("metadata"), l = a.childNamed("manifest"), c = a.childNamed("spine"), p = a.childNamed("guide"), u = d == null ? void 0 : d.childNamed("dc:title"), g = (d == null ? void 0 : d.childrenNamed("meta")) || [], b = g.find(
|
|
198
|
+
(h) => h.attr.property === "rendition:layout"
|
|
199
|
+
), m = g.find(
|
|
200
|
+
(h) => h.attr.property === "rendition:flow"
|
|
201
|
+
), $ = g.find(
|
|
202
|
+
(h) => h.attr.property === "rendition:spread"
|
|
203
|
+
), y = b == null ? void 0 : b.val, x = m == null ? void 0 : m.val, T = $ == null ? void 0 : $.val, ae = (u == null ? void 0 : u.val) || ((U = e.files.find(({ dir: h }) => h)) == null ? void 0 : U.basename) || "", oe = c == null ? void 0 : c.attr["page-progression-direction"], ce = (await te({ archive: e })).reduce(
|
|
204
|
+
(h, L) => L.size + h,
|
|
205
205
|
0
|
|
206
206
|
);
|
|
207
207
|
return {
|
|
208
208
|
filename: e.filename,
|
|
209
209
|
nav: {
|
|
210
|
-
toc:
|
|
210
|
+
toc: o
|
|
211
211
|
},
|
|
212
212
|
renditionLayout: y,
|
|
213
|
-
renditionFlow:
|
|
214
|
-
renditionSpread:
|
|
215
|
-
title:
|
|
213
|
+
renditionFlow: x || "auto",
|
|
214
|
+
renditionSpread: T,
|
|
215
|
+
title: ae,
|
|
216
216
|
readingDirection: oe || "ltr",
|
|
217
217
|
/**
|
|
218
218
|
* @see https://www.w3.org/TR/epub/#sec-itemref-elem
|
|
219
219
|
*/
|
|
220
|
-
spineItems: (c == null ? void 0 : c.childrenNamed("itemref").map((
|
|
221
|
-
var
|
|
222
|
-
const f = l == null ? void 0 : l.childrenNamed("item").find((I) => I.attr.id === (
|
|
220
|
+
spineItems: (c == null ? void 0 : c.childrenNamed("itemref").map((h, L) => {
|
|
221
|
+
var V, X;
|
|
222
|
+
const f = l == null ? void 0 : l.childrenNamed("item").find((I) => I.attr.id === (h == null ? void 0 : h.attr.idref)), B = (f == null ? void 0 : f.attr.href) || "", de = ((V = e.files.find((I) => I.uri.endsWith(B))) == null ? void 0 : V.size) || 0, E = t || (/^https?:\/\//.test(B) ? "" : "file://"), H = Ie(h);
|
|
223
223
|
return {
|
|
224
|
-
...
|
|
224
|
+
...H,
|
|
225
225
|
id: (f == null ? void 0 : f.attr.id) || "",
|
|
226
|
-
index:
|
|
227
|
-
href: (
|
|
228
|
-
renditionLayout:
|
|
229
|
-
progressionWeight:
|
|
226
|
+
index: L,
|
|
227
|
+
href: (X = f == null ? void 0 : f.attr.href) != null && X.startsWith("https://") ? f == null ? void 0 : f.attr.href : n ? `${E}${n}/${f == null ? void 0 : f.attr.href}` : `${E}${f == null ? void 0 : f.attr.href}`,
|
|
228
|
+
renditionLayout: H.renditionLayout ?? y,
|
|
229
|
+
progressionWeight: de / ce,
|
|
230
230
|
// size: itemSize
|
|
231
231
|
mediaType: f == null ? void 0 : f.attr["media-type"]
|
|
232
232
|
};
|
|
233
233
|
})) || [],
|
|
234
|
-
items:
|
|
235
|
-
const
|
|
236
|
-
return /^https?:\/\//.test(
|
|
234
|
+
items: ie(a, e, (h) => {
|
|
235
|
+
const L = h.attr.href || "";
|
|
236
|
+
return /^https?:\/\//.test(L) ? "" : t || "file://";
|
|
237
237
|
}),
|
|
238
|
-
guide: p == null ? void 0 : p.childrenNamed("reference").map((
|
|
239
|
-
href:
|
|
240
|
-
title:
|
|
241
|
-
type:
|
|
238
|
+
guide: p == null ? void 0 : p.childrenNamed("reference").map((h) => ({
|
|
239
|
+
href: h.attr.href || "",
|
|
240
|
+
title: h.attr.title || "",
|
|
241
|
+
type: h.attr.type
|
|
242
242
|
}))
|
|
243
243
|
};
|
|
244
244
|
}, Oe = async (e, t) => {
|
|
245
|
-
var n, s,
|
|
246
|
-
const r = await ((n =
|
|
245
|
+
var n, s, a;
|
|
246
|
+
const r = await ((n = k(e).data) == null ? void 0 : n.string());
|
|
247
247
|
if (r) {
|
|
248
|
-
const
|
|
248
|
+
const o = new w(r), d = ie(o, e, () => "");
|
|
249
249
|
if ((s = d.find(
|
|
250
250
|
(c) => t.endsWith(c.href)
|
|
251
251
|
)) == null ? void 0 : s.mediaType)
|
|
252
252
|
return {
|
|
253
|
-
mediaType: (
|
|
253
|
+
mediaType: (a = d.find((c) => t.endsWith(c.href))) == null ? void 0 : a.mediaType
|
|
254
254
|
};
|
|
255
255
|
}
|
|
256
256
|
return {
|
|
@@ -285,7 +285,7 @@ const v = {
|
|
|
285
285
|
}
|
|
286
286
|
}
|
|
287
287
|
};
|
|
288
|
-
},
|
|
288
|
+
}, ee = [
|
|
289
289
|
"div",
|
|
290
290
|
"span",
|
|
291
291
|
"p",
|
|
@@ -336,27 +336,27 @@ const v = {
|
|
|
336
336
|
"canvas",
|
|
337
337
|
"script",
|
|
338
338
|
"style"
|
|
339
|
-
],
|
|
339
|
+
], De = ({ archive: e, resourcePath: t }) => async (i) => {
|
|
340
340
|
const r = Object.values(e.files).find(
|
|
341
341
|
(n) => n.uri === t
|
|
342
342
|
);
|
|
343
343
|
if (r != null && r.basename.endsWith(".xhtml")) {
|
|
344
344
|
const n = i.body ?? await r.string();
|
|
345
345
|
if (!new RegExp(
|
|
346
|
-
`<(${
|
|
346
|
+
`<(${ee.join("|")})[\\s/>]`,
|
|
347
347
|
"i"
|
|
348
348
|
).test(n))
|
|
349
349
|
return i;
|
|
350
|
-
const
|
|
351
|
-
`<(${
|
|
350
|
+
const a = new RegExp(
|
|
351
|
+
`<(${ee.join("|")})(\\s[^>]*)?\\s*/>`,
|
|
352
352
|
"gi"
|
|
353
|
-
),
|
|
354
|
-
|
|
353
|
+
), o = n.replace(
|
|
354
|
+
a,
|
|
355
355
|
(d, l, c = "") => `<${l} ${c.trim()}></${l}>`
|
|
356
356
|
);
|
|
357
357
|
return {
|
|
358
358
|
...i,
|
|
359
|
-
body:
|
|
359
|
+
body: o
|
|
360
360
|
};
|
|
361
361
|
}
|
|
362
362
|
return i;
|
|
@@ -370,12 +370,12 @@ const v = {
|
|
|
370
370
|
params: {}
|
|
371
371
|
}, n = [
|
|
372
372
|
ze({ archive: e, resourcePath: t }),
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
373
|
+
De({ archive: e, resourcePath: t }),
|
|
374
|
+
Le({ archive: e, resourcePath: t }),
|
|
375
|
+
Te({ archive: e, resourcePath: t })
|
|
376
376
|
];
|
|
377
377
|
try {
|
|
378
|
-
const s = await n.reduce(async (
|
|
378
|
+
const s = await n.reduce(async (a, o) => await o(await a), Promise.resolve(r));
|
|
379
379
|
return v.log("Generated resource", t, s), {
|
|
380
380
|
...s,
|
|
381
381
|
body: s.body ?? await i.blob()
|
|
@@ -393,14 +393,14 @@ const v = {
|
|
|
393
393
|
renditionSpread: "auto",
|
|
394
394
|
readingDirection: "ltr",
|
|
395
395
|
spineItems: i.filter((n) => !n.basename.endsWith(".db")).map((n, s) => {
|
|
396
|
-
const
|
|
396
|
+
const a = t || (/^https?:\/\//.test(n.uri) ? "" : "file://");
|
|
397
397
|
return {
|
|
398
398
|
// some books such as cbz can have same basename inside different sub folder
|
|
399
399
|
// we need to make sure to have unique index
|
|
400
400
|
// /chap01/01.png, /chap02/01.png, etc
|
|
401
401
|
id: `${s}.${n.basename}`,
|
|
402
402
|
index: s,
|
|
403
|
-
href: encodeURI(`${
|
|
403
|
+
href: encodeURI(`${a}${n.uri}`),
|
|
404
404
|
renditionLayout: void 0,
|
|
405
405
|
progressionWeight: 1 / i.length,
|
|
406
406
|
pageSpreadLeft: void 0,
|
|
@@ -421,8 +421,8 @@ const v = {
|
|
|
421
421
|
e.files.map(async (i) => {
|
|
422
422
|
var r, n;
|
|
423
423
|
if (i.uri.endsWith("com.kobobooks.display-options.xml")) {
|
|
424
|
-
const
|
|
425
|
-
((n =
|
|
424
|
+
const a = (r = new w(await i.string()).childNamed("platform")) == null ? void 0 : r.childNamed("option");
|
|
425
|
+
((n = a == null ? void 0 : a.attr) == null ? void 0 : n.name) === "fixed-layout" && a.val === "true" && (t.renditionLayout = "pre-paginated");
|
|
426
426
|
}
|
|
427
427
|
})
|
|
428
428
|
), t;
|
|
@@ -436,18 +436,18 @@ const v = {
|
|
|
436
436
|
var i;
|
|
437
437
|
const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((r) => r.attr.name === "viewport");
|
|
438
438
|
return !!(t && t.attr.name === "viewport");
|
|
439
|
-
},
|
|
439
|
+
}, Xe = (e) => e.reduce(async (t, i) => {
|
|
440
440
|
if (!await t || !fe({
|
|
441
441
|
mimeType: i.encodingFormat,
|
|
442
442
|
uri: i.uri
|
|
443
443
|
}))
|
|
444
444
|
return !1;
|
|
445
445
|
const n = await i.string();
|
|
446
|
-
return n ? Ve(new
|
|
447
|
-
}, Promise.resolve(!0)),
|
|
446
|
+
return n ? Ve(new w(n)) : !1;
|
|
447
|
+
}, Promise.resolve(!0)), _e = ({ archive: e }) => async (t) => {
|
|
448
448
|
if (t.renditionLayout === "reflowable" && t.spineItems.every((r) => r.renditionLayout === "reflowable")) {
|
|
449
|
-
const r = await
|
|
450
|
-
if (await
|
|
449
|
+
const r = await te({ archive: e });
|
|
450
|
+
if (await Xe(r))
|
|
451
451
|
return {
|
|
452
452
|
...t,
|
|
453
453
|
spineItems: t.spineItems.map((s) => ({
|
|
@@ -458,21 +458,21 @@ const v = {
|
|
|
458
458
|
};
|
|
459
459
|
}
|
|
460
460
|
return t;
|
|
461
|
-
},
|
|
461
|
+
}, D = (e, t) => {
|
|
462
462
|
var n;
|
|
463
463
|
const i = e.split(/(\d+)/), r = t.split(/(\d+)/);
|
|
464
|
-
for (let s = 0,
|
|
464
|
+
for (let s = 0, a = i.length; s < a; s++)
|
|
465
465
|
if (i[s] !== r[s])
|
|
466
466
|
return (n = i[s]) != null && n.match(/\d/) ? +(i[s] || "") - +(r[s] || "") : (i[s] || "").localeCompare(r[s] || "");
|
|
467
467
|
return 1;
|
|
468
|
-
},
|
|
468
|
+
}, qe = ({ archive: e, baseUrl: t }) => async (i) => {
|
|
469
469
|
if (i.nav) return i;
|
|
470
470
|
const r = [...e.files].sort(
|
|
471
|
-
(
|
|
472
|
-
), n = Object.values(r), s = (
|
|
473
|
-
const u =
|
|
471
|
+
(o, d) => D(o.uri, d.uri)
|
|
472
|
+
), n = Object.values(r), s = (o, d, l, c, p) => {
|
|
473
|
+
const u = o.find((m) => m.title === d), [g, ...b] = l;
|
|
474
474
|
return u ? g ? [
|
|
475
|
-
...
|
|
475
|
+
...o.filter(($) => $ !== u),
|
|
476
476
|
{
|
|
477
477
|
...u,
|
|
478
478
|
contents: [
|
|
@@ -487,14 +487,14 @@ const v = {
|
|
|
487
487
|
]
|
|
488
488
|
}
|
|
489
489
|
] : u.path.split("/").length > p.split("/").length ? [
|
|
490
|
-
...
|
|
490
|
+
...o.filter(($) => $ !== u),
|
|
491
491
|
{
|
|
492
492
|
...u,
|
|
493
493
|
path: p,
|
|
494
494
|
href: c
|
|
495
495
|
}
|
|
496
|
-
] :
|
|
497
|
-
...
|
|
496
|
+
] : o : g ? [
|
|
497
|
+
...o,
|
|
498
498
|
{
|
|
499
499
|
contents: s(
|
|
500
500
|
[],
|
|
@@ -508,7 +508,7 @@ const v = {
|
|
|
508
508
|
title: d
|
|
509
509
|
}
|
|
510
510
|
] : [
|
|
511
|
-
...
|
|
511
|
+
...o,
|
|
512
512
|
{
|
|
513
513
|
contents: [],
|
|
514
514
|
href: c,
|
|
@@ -516,92 +516,92 @@ const v = {
|
|
|
516
516
|
title: d
|
|
517
517
|
}
|
|
518
518
|
];
|
|
519
|
-
},
|
|
520
|
-
(
|
|
521
|
-
if (d.dir) return
|
|
519
|
+
}, a = n.reduce(
|
|
520
|
+
(o, d) => {
|
|
521
|
+
if (d.dir) return o;
|
|
522
522
|
const c = d.uri.split("/").slice(0, -1), [p, ...u] = c;
|
|
523
523
|
if (p) {
|
|
524
|
-
const g =
|
|
525
|
-
return s(
|
|
524
|
+
const g = N(t, encodeURI(d.uri)).replace(/\/$/, ""), b = d.uri.replace(/\/$/, "");
|
|
525
|
+
return s(o, p, u, g, b);
|
|
526
526
|
}
|
|
527
|
-
return
|
|
527
|
+
return o;
|
|
528
528
|
},
|
|
529
529
|
[]
|
|
530
530
|
);
|
|
531
|
-
return
|
|
531
|
+
return a.length === 0 ? i : {
|
|
532
532
|
...i,
|
|
533
533
|
nav: {
|
|
534
|
-
toc:
|
|
534
|
+
toc: a
|
|
535
535
|
}
|
|
536
536
|
};
|
|
537
|
-
},
|
|
537
|
+
}, Ge = ({ archive: e }) => async (t) => {
|
|
538
538
|
var s;
|
|
539
539
|
const i = e.files.find(
|
|
540
|
-
(
|
|
540
|
+
(a) => a.basename.toLowerCase() === "comicinfo.xml"
|
|
541
541
|
);
|
|
542
542
|
if (!i)
|
|
543
543
|
return t;
|
|
544
544
|
const r = {
|
|
545
545
|
...t,
|
|
546
|
-
spineItems: t.spineItems.filter((
|
|
547
|
-
...
|
|
546
|
+
spineItems: t.spineItems.filter((a) => !a.id.toLowerCase().endsWith("comicinfo.xml")).map((a, o, d) => ({
|
|
547
|
+
...a,
|
|
548
548
|
progressionWeight: 1 / d.length
|
|
549
549
|
}))
|
|
550
550
|
}, n = await i.string();
|
|
551
551
|
try {
|
|
552
|
-
const
|
|
552
|
+
const o = ((s = new w(n).childNamed("Manga")) == null ? void 0 : s.val) || "unknown";
|
|
553
553
|
return {
|
|
554
554
|
...r,
|
|
555
|
-
readingDirection:
|
|
555
|
+
readingDirection: o === "YesAndRightToLeft" ? "rtl" : "ltr"
|
|
556
556
|
};
|
|
557
|
-
} catch (
|
|
557
|
+
} catch (a) {
|
|
558
558
|
return console.error(`Unable to parse comicinfo.xml for content
|
|
559
|
-
`, n), console.error(
|
|
559
|
+
`, n), console.error(a), r;
|
|
560
560
|
}
|
|
561
|
-
},
|
|
561
|
+
}, Ke = (e) => e.files.some((t) => t.basename.endsWith(".opf")), Je = ({ archive: e }) => async (t) => Ke(e) ? t : {
|
|
562
562
|
...t,
|
|
563
563
|
spineItems: t.spineItems.map((r) => {
|
|
564
564
|
const n = e.files.find(
|
|
565
|
-
(
|
|
566
|
-
), s = ue((n == null ? void 0 : n.encodingFormat) ?? "") ??
|
|
565
|
+
(a) => decodeURI(r.href).endsWith(a.uri)
|
|
566
|
+
), s = ue((n == null ? void 0 : n.encodingFormat) ?? "") ?? M((n == null ? void 0 : n.basename) ?? "");
|
|
567
567
|
return {
|
|
568
568
|
...r,
|
|
569
569
|
renditionLayout: s != null && s.startsWith("image/") ? "pre-paginated" : r.renditionLayout
|
|
570
570
|
};
|
|
571
571
|
})
|
|
572
|
-
},
|
|
572
|
+
}, Ye = ({ archive: e }) => async (t) => {
|
|
573
573
|
var n, s;
|
|
574
574
|
const i = e.files.find(
|
|
575
|
-
(
|
|
575
|
+
(a) => a.basename.toLowerCase() === "com.apple.ibooks.display-options.xml"
|
|
576
576
|
);
|
|
577
577
|
if (!i)
|
|
578
578
|
return t;
|
|
579
579
|
const r = await (await i.blob()).text();
|
|
580
580
|
try {
|
|
581
|
-
const
|
|
581
|
+
const o = new w(r).childNamed("platform"), d = ((s = (n = o == null ? void 0 : o.childrenNamed("option")) == null ? void 0 : n.find((l) => l.attr.name === "fixed-layout")) == null ? void 0 : s.val) || "false";
|
|
582
582
|
return {
|
|
583
583
|
...t,
|
|
584
584
|
renditionLayout: d === "true" ? "pre-paginated" : t.renditionLayout
|
|
585
585
|
};
|
|
586
|
-
} catch (
|
|
586
|
+
} catch (a) {
|
|
587
587
|
return console.error(
|
|
588
588
|
`Unable to parse com.apple.ibooks.display-options.xml for content
|
|
589
589
|
`,
|
|
590
590
|
r
|
|
591
|
-
), console.error(
|
|
591
|
+
), console.error(a), t;
|
|
592
592
|
}
|
|
593
|
-
},
|
|
593
|
+
}, Qe = async (e, { baseUrl: t = "" } = {}) => {
|
|
594
594
|
const i = [
|
|
595
595
|
je({ archive: e, baseUrl: t }),
|
|
596
|
-
|
|
597
|
-
Qe({ archive: e }),
|
|
596
|
+
Ge({ archive: e }),
|
|
598
597
|
Ye({ archive: e }),
|
|
599
|
-
|
|
598
|
+
Je({ archive: e }),
|
|
599
|
+
_e({ archive: e }),
|
|
600
600
|
He({ archive: e }),
|
|
601
|
-
|
|
601
|
+
qe({ archive: e, baseUrl: t })
|
|
602
602
|
];
|
|
603
603
|
try {
|
|
604
|
-
const r = Be({ archive: e, baseUrl: t })(), n = await i.reduce(async (s,
|
|
604
|
+
const r = Be({ archive: e, baseUrl: t })(), n = await i.reduce(async (s, a) => await a(await s), r);
|
|
605
605
|
return v.log("Generated manifest", n), n;
|
|
606
606
|
} catch (r) {
|
|
607
607
|
throw v.error(r), r;
|
|
@@ -615,7 +615,7 @@ const v = {
|
|
|
615
615
|
</metadata>
|
|
616
616
|
<manifest>
|
|
617
617
|
${e.map(
|
|
618
|
-
(s) => `<item id="${A(s)}" href="${s}" media-type="${
|
|
618
|
+
(s) => `<item id="${A(s)}" href="${s}" media-type="${M(s)}"/>`
|
|
619
619
|
).join(`
|
|
620
620
|
`)}
|
|
621
621
|
</manifest>
|
|
@@ -627,7 +627,7 @@ const v = {
|
|
|
627
627
|
`, r = e.map((s) => ({
|
|
628
628
|
dir: !1,
|
|
629
629
|
basename: A(s),
|
|
630
|
-
encodingFormat:
|
|
630
|
+
encodingFormat: M(s),
|
|
631
631
|
uri: s,
|
|
632
632
|
size: 100 / e.length,
|
|
633
633
|
blob: async () => (await fetch(s)).blob(),
|
|
@@ -645,7 +645,7 @@ const v = {
|
|
|
645
645
|
}, ...r],
|
|
646
646
|
close: () => Promise.resolve()
|
|
647
647
|
};
|
|
648
|
-
},
|
|
648
|
+
}, ot = async (e, {
|
|
649
649
|
mimeType: t,
|
|
650
650
|
direction: i
|
|
651
651
|
} = { mimeType: "text/plain" }) => {
|
|
@@ -688,9 +688,9 @@ const v = {
|
|
|
688
688
|
],
|
|
689
689
|
close: () => Promise.resolve()
|
|
690
690
|
};
|
|
691
|
-
},
|
|
691
|
+
}, ct = async (e, { orderByAlpha: t, name: i } = {}) => {
|
|
692
692
|
let r = Object.values(e.files);
|
|
693
|
-
t && (r = r.slice().sort((s,
|
|
693
|
+
t && (r = r.slice().sort((s, a) => D(s.name, a.name)));
|
|
694
694
|
const n = {
|
|
695
695
|
filename: i || "",
|
|
696
696
|
files: r.map((s) => ({
|
|
@@ -709,7 +709,7 @@ const v = {
|
|
|
709
709
|
close: () => Promise.resolve()
|
|
710
710
|
};
|
|
711
711
|
return v.log("Generated archive", n), n;
|
|
712
|
-
},
|
|
712
|
+
}, dt = async (e, { name: t } = {}) => {
|
|
713
713
|
const i = await e.getFilesArray(), r = {
|
|
714
714
|
close: () => e.close(),
|
|
715
715
|
filename: t ?? "",
|
|
@@ -723,9 +723,9 @@ const v = {
|
|
|
723
723
|
}))
|
|
724
724
|
};
|
|
725
725
|
return v.log("Generated archive", r), r;
|
|
726
|
-
},
|
|
726
|
+
}, lt = async (e, { orderByAlpha: t, name: i } = {}) => {
|
|
727
727
|
let r = e;
|
|
728
|
-
return t && (r = r.slice().sort((n, s) =>
|
|
728
|
+
return t && (r = r.slice().sort((n, s) => D(n.name, s.name))), {
|
|
729
729
|
filename: i || "",
|
|
730
730
|
files: r.map((n) => ({
|
|
731
731
|
dir: n.isDir,
|
|
@@ -743,14 +743,14 @@ const v = {
|
|
|
743
743
|
})),
|
|
744
744
|
close: () => Promise.resolve()
|
|
745
745
|
};
|
|
746
|
-
},
|
|
746
|
+
}, pt = ({
|
|
747
747
|
enableReport: e
|
|
748
748
|
} = {}) => {
|
|
749
749
|
v.enable(!!e);
|
|
750
750
|
};
|
|
751
|
-
class
|
|
751
|
+
class Ze {
|
|
752
752
|
constructor(t) {
|
|
753
|
-
this.cleanArchiveAfter = t, this.state$ = new
|
|
753
|
+
this.cleanArchiveAfter = t, this.state$ = new be({
|
|
754
754
|
status: "idle",
|
|
755
755
|
locks: 0
|
|
756
756
|
});
|
|
@@ -767,70 +767,72 @@ class et {
|
|
|
767
767
|
get isUnlocked$() {
|
|
768
768
|
return this.locks$.pipe(
|
|
769
769
|
F((t) => t <= 0),
|
|
770
|
-
|
|
771
|
-
|
|
770
|
+
we(),
|
|
771
|
+
ve()
|
|
772
772
|
);
|
|
773
773
|
}
|
|
774
774
|
get overTTL$() {
|
|
775
775
|
return this.isUnlocked$.pipe(
|
|
776
|
-
|
|
777
|
-
(t) => t ? this.cleanArchiveAfter === 1 / 0 ?
|
|
776
|
+
W(
|
|
777
|
+
(t) => t ? this.cleanArchiveAfter === 1 / 0 ? K : $e(this.cleanArchiveAfter) : K
|
|
778
778
|
)
|
|
779
779
|
);
|
|
780
780
|
}
|
|
781
781
|
}
|
|
782
|
-
const
|
|
782
|
+
const et = ({
|
|
783
783
|
getArchive: e,
|
|
784
784
|
cleanArchiveAfter: t = 5 * 60 * 1e3
|
|
785
785
|
// 5mn
|
|
786
786
|
}) => {
|
|
787
|
-
const i = new R(), r = new R(), n = new R(), s = {},
|
|
788
|
-
|
|
787
|
+
const i = new R(), r = new R(), n = new R(), s = {}, a = i.pipe(
|
|
788
|
+
z((l) => {
|
|
789
789
|
const c = s[l];
|
|
790
790
|
if (!c || c.state.status !== "idle") return _;
|
|
791
791
|
let p = !1;
|
|
792
792
|
const u = (y) => {
|
|
793
|
-
var
|
|
793
|
+
var T;
|
|
794
794
|
v.debug(`Cleaning up archive with key: ${y}`);
|
|
795
|
-
const
|
|
796
|
-
delete s[y], p || ((
|
|
795
|
+
const x = s[y];
|
|
796
|
+
delete s[y], p || ((T = x == null ? void 0 : x.state.archive) == null || T.close(), p = !0);
|
|
797
797
|
};
|
|
798
798
|
c.update({
|
|
799
799
|
status: "loading"
|
|
800
800
|
});
|
|
801
|
-
const g = c.locks$, b = c.isUnlocked$,
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
801
|
+
const g = c.locks$, b = c.isUnlocked$, m = g.pipe(
|
|
802
|
+
he(),
|
|
803
|
+
j(([y, x]) => x > y),
|
|
804
|
+
me(!0)
|
|
805
805
|
);
|
|
806
|
-
return
|
|
807
|
-
|
|
806
|
+
return C(e(l)).pipe(
|
|
807
|
+
O((y) => {
|
|
808
808
|
c.update({
|
|
809
809
|
archive: y,
|
|
810
810
|
status: "success"
|
|
811
811
|
});
|
|
812
812
|
}),
|
|
813
|
-
|
|
813
|
+
P((y) => (u(l), c.update({
|
|
814
814
|
status: "error",
|
|
815
815
|
error: y
|
|
816
816
|
}), _)),
|
|
817
|
-
|
|
818
|
-
const y =
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
817
|
+
W(() => {
|
|
818
|
+
const y = m.pipe(
|
|
819
|
+
W(() => n),
|
|
820
|
+
W(() => b),
|
|
821
|
+
j((T) => T)
|
|
822
|
+
);
|
|
823
|
+
return q(y, c.overTTL$).pipe(
|
|
824
|
+
G(),
|
|
825
|
+
O(() => {
|
|
826
|
+
u(l);
|
|
827
|
+
})
|
|
822
828
|
);
|
|
823
|
-
return q(y, c.overTTL$);
|
|
824
|
-
}),
|
|
825
|
-
j(() => {
|
|
826
|
-
u(l);
|
|
827
829
|
})
|
|
828
830
|
);
|
|
829
831
|
}),
|
|
830
832
|
ge(r)
|
|
831
|
-
),
|
|
833
|
+
), o = (l) => {
|
|
832
834
|
let c = !1;
|
|
833
|
-
const p = s[l] ?? new
|
|
835
|
+
const p = s[l] ?? new Ze(t);
|
|
834
836
|
s[l] = p, p.update({
|
|
835
837
|
locks: p.state.locks + 1
|
|
836
838
|
});
|
|
@@ -841,38 +843,38 @@ const tt = ({
|
|
|
841
843
|
};
|
|
842
844
|
i.next(l);
|
|
843
845
|
const g = p.state$.pipe(
|
|
844
|
-
F(({ archive:
|
|
845
|
-
|
|
846
|
+
F(({ archive: m }) => m),
|
|
847
|
+
j((m) => !!m)
|
|
846
848
|
), b = p.state$.pipe(
|
|
847
|
-
|
|
848
|
-
if (
|
|
849
|
-
throw
|
|
849
|
+
O(({ error: m }) => {
|
|
850
|
+
if (m)
|
|
851
|
+
throw m;
|
|
850
852
|
}),
|
|
851
853
|
ye()
|
|
852
854
|
);
|
|
853
855
|
return q(g, b).pipe(
|
|
854
|
-
|
|
855
|
-
F((
|
|
856
|
-
|
|
857
|
-
throw u(),
|
|
856
|
+
G(),
|
|
857
|
+
F((m) => ({ archive: m, release: u })),
|
|
858
|
+
P((m) => {
|
|
859
|
+
throw u(), m;
|
|
858
860
|
})
|
|
859
861
|
);
|
|
860
862
|
}, d = () => {
|
|
861
863
|
n.next();
|
|
862
864
|
};
|
|
863
|
-
return
|
|
864
|
-
access:
|
|
865
|
+
return a.subscribe(), {
|
|
866
|
+
access: o,
|
|
865
867
|
purge: d,
|
|
866
|
-
|
|
868
|
+
_archives: s
|
|
867
869
|
};
|
|
868
870
|
};
|
|
869
|
-
class
|
|
871
|
+
class tt {
|
|
870
872
|
constructor({
|
|
871
873
|
onError: t,
|
|
872
874
|
onManifestSuccess: i,
|
|
873
875
|
...r
|
|
874
876
|
}) {
|
|
875
|
-
this.onError = (n) => (console.error(n), new Response(String(n), { status: 500 })), this.epubLoader =
|
|
877
|
+
this.onError = (n) => (console.error(n), new Response(String(n), { status: 500 })), this.epubLoader = et(r), this.onManifestSuccess = i ?? (({ manifest: n }) => Promise.resolve(n)), this.onError = t ?? this.onError;
|
|
876
878
|
}
|
|
877
879
|
prune() {
|
|
878
880
|
this.epubLoader.purge();
|
|
@@ -887,34 +889,34 @@ class nt {
|
|
|
887
889
|
}
|
|
888
890
|
fetchManifest({ key: t, baseUrl: i }) {
|
|
889
891
|
const r = this.accessArchive(t).pipe(
|
|
890
|
-
|
|
891
|
-
|
|
892
|
+
z(({ archive: n, release: s }) => C(
|
|
893
|
+
Qe(n, { baseUrl: i })
|
|
892
894
|
).pipe(
|
|
893
|
-
|
|
894
|
-
(
|
|
895
|
+
W(
|
|
896
|
+
(o) => C(this.onManifestSuccess({ manifest: o, archive: n }))
|
|
895
897
|
),
|
|
896
898
|
F(
|
|
897
|
-
(
|
|
899
|
+
(o) => new Response(JSON.stringify(o), {
|
|
898
900
|
status: 200
|
|
899
901
|
})
|
|
900
902
|
),
|
|
901
|
-
|
|
903
|
+
J(() => {
|
|
902
904
|
s();
|
|
903
905
|
})
|
|
904
906
|
)),
|
|
905
|
-
|
|
907
|
+
P((n) => Y(this.onError(n)))
|
|
906
908
|
);
|
|
907
|
-
return
|
|
909
|
+
return Q(r);
|
|
908
910
|
}
|
|
909
911
|
fetchResource({
|
|
910
912
|
key: t,
|
|
911
913
|
resourcePath: i
|
|
912
914
|
}) {
|
|
913
915
|
const r = this.accessArchive(t).pipe(
|
|
914
|
-
|
|
915
|
-
const
|
|
916
|
-
return
|
|
917
|
-
Ue(n,
|
|
916
|
+
z(({ archive: n, release: s }) => {
|
|
917
|
+
const a = i.replaceAll("file://", "");
|
|
918
|
+
return C(
|
|
919
|
+
Ue(n, a)
|
|
918
920
|
).pipe(
|
|
919
921
|
F(
|
|
920
922
|
(d) => new Response(d.body, {
|
|
@@ -926,17 +928,17 @@ class nt {
|
|
|
926
928
|
}
|
|
927
929
|
})
|
|
928
930
|
),
|
|
929
|
-
|
|
931
|
+
J(() => {
|
|
930
932
|
s();
|
|
931
933
|
})
|
|
932
934
|
);
|
|
933
935
|
}),
|
|
934
|
-
|
|
936
|
+
P((n) => Y(this.onError(n)))
|
|
935
937
|
);
|
|
936
|
-
return
|
|
938
|
+
return Q(r);
|
|
937
939
|
}
|
|
938
940
|
}
|
|
939
|
-
class
|
|
941
|
+
class ft extends tt {
|
|
940
942
|
constructor({
|
|
941
943
|
getUriInfo: t,
|
|
942
944
|
...i
|
|
@@ -947,30 +949,30 @@ class ut extends nt {
|
|
|
947
949
|
try {
|
|
948
950
|
const i = this.getUriInfo(t);
|
|
949
951
|
if (!i) return;
|
|
950
|
-
const r =
|
|
952
|
+
const r = Z(i.baseUrl), n = t.request.url.substring(
|
|
951
953
|
r.length + 1
|
|
952
|
-
), [s = ""] = n.split("/"),
|
|
953
|
-
|
|
954
|
+
), [s = ""] = n.split("/"), a = decodeURIComponent(
|
|
955
|
+
Z(n.substring(s.length + 1))
|
|
954
956
|
);
|
|
955
957
|
n.endsWith("/manifest") ? t.respondWith(
|
|
956
958
|
this.fetchManifest({ key: s, baseUrl: `${r}/${s}/` })
|
|
957
|
-
) : t.respondWith(this.fetchResource({ key: s, resourcePath:
|
|
959
|
+
) : t.respondWith(this.fetchResource({ key: s, resourcePath: a }));
|
|
958
960
|
} catch (i) {
|
|
959
961
|
t.respondWith(new Response(String(i), { status: 500 }));
|
|
960
962
|
}
|
|
961
963
|
}
|
|
962
964
|
}
|
|
963
965
|
export {
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
966
|
+
ft as ServiceWorkerStreamer,
|
|
967
|
+
tt as Streamer,
|
|
968
|
+
pt as configure,
|
|
969
|
+
lt as createArchiveFromArrayBufferList,
|
|
970
|
+
ct as createArchiveFromJszip,
|
|
971
|
+
dt as createArchiveFromLibArchive,
|
|
972
|
+
ot as createArchiveFromText,
|
|
971
973
|
at as createArchiveFromUrls,
|
|
972
|
-
|
|
974
|
+
Qe as generateManifestFromArchive,
|
|
973
975
|
Ue as generateResourceFromArchive,
|
|
974
|
-
|
|
976
|
+
k as getArchiveOpfInfo
|
|
975
977
|
};
|
|
976
978
|
//# sourceMappingURL=index.js.map
|