@prose-reader/streamer 1.124.0 → 1.126.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/index.js CHANGED
@@ -1,6 +1,6 @@
1
- import F, { XmlDocument as le, XmlTextNode as pe, XmlElement as fe } from "xmldoc";
2
- import { urlJoin as N, isXmlBasedMimeType as ue, detectMimeTypeFromName as V } from "@prose-reader/shared";
3
- import { Subject as R, mergeMap as O, EMPTY as _, pairwise as me, filter as j, startWith as he, from as L, tap as D, catchError as P, switchMap as k, merge as q, takeUntil as ge, map as A, ignoreElements as ye, first as be, BehaviorSubject as we, distinctUntilChanged as ve, shareReplay as $e, NEVER as G, timer as xe, finalize as K, of as J, lastValueFrom as Y } from "rxjs";
1
+ import F, { XmlDocument as pe, XmlTextNode as fe, XmlElement as ue } from "xmldoc";
2
+ import { urlJoin as N, isXmlBasedMimeType as me, detectMimeTypeFromName as _ } from "@prose-reader/shared";
3
+ import { Subject as j, mergeMap as z, EMPTY as q, pairwise as he, filter as D, startWith as ge, from as L, tap as O, catchError as P, switchMap as k, merge as G, takeUntil as ye, map as A, ignoreElements as be, first as we, BehaviorSubject as ve, distinctUntilChanged as $e, shareReplay as xe, NEVER as K, timer as Fe, finalize as J, of as Y, lastValueFrom as Q } from "rxjs";
4
4
  let S = !1;
5
5
  const v = {
6
6
  enable: (e) => {
@@ -35,195 +35,195 @@ const v = {
35
35
  ));
36
36
  },
37
37
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
- measurePerformance: (e, t = 10, i) => (...r) => {
39
- const n = performance.now(), s = i(...r);
40
- if (s && s.then)
41
- return s.then((o) => {
38
+ measurePerformance: (e, t = 10, i) => (...s) => {
39
+ const n = performance.now(), r = i(...s);
40
+ if (r && r.then)
41
+ return r.then((o) => {
42
42
  const d = performance.now();
43
43
  return v.metric({ name: e, duration: d - n }, t), o;
44
44
  });
45
45
  const a = performance.now();
46
- return v.metric({ name: e, duration: a - n }, t), s;
46
+ return v.metric({ name: e, duration: a - n }, t), r;
47
47
  }
48
- }, Fe = (e) => {
48
+ }, Ae = (e) => {
49
49
  var i;
50
- const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((r) => r.attr.name === "calibre:cover");
50
+ const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((s) => s.attr.name === "calibre:cover");
51
51
  return !!(t && t.attr.name === "calibre:cover");
52
- }, Ae = (e) => {
53
- var t, i, r;
54
- return (r = (i = (t = e.descendantWithPath("body")) == null ? void 0 : t.descendantWithPath("div")) == null ? void 0 : i.childrenNamed("svg")) == null ? void 0 : r.find(
52
+ }, Te = (e) => {
53
+ var t, i, s;
54
+ return (s = (i = (t = e.descendantWithPath("body")) == null ? void 0 : t.descendantWithPath("div")) == null ? void 0 : i.childrenNamed("svg")) == null ? void 0 : s.find(
55
55
  (n) => n.attr.width === "100%" && n.attr.preserveAspectRatio === "none"
56
56
  );
57
- }, Te = ({ archive: e, resourcePath: t }) => async (i) => {
58
- const r = Object.values(e.files).find(
57
+ }, Se = ({ archive: e, resourcePath: t }) => async (i) => {
58
+ const s = Object.values(e.files).find(
59
59
  (n) => n.uri === t
60
60
  );
61
- if (r != null && r.basename.endsWith(".xhtml")) {
62
- const n = i.body ?? await r.string(), s = new le(n);
63
- if (Fe(s)) {
64
- const a = Ae(s);
61
+ if (s != null && s.basename.endsWith(".xhtml")) {
62
+ const n = i.body ?? await s.string(), r = new pe(n);
63
+ if (Ae(r)) {
64
+ const a = Te(r);
65
65
  return a && delete a.attr.preserveAspectRatio, {
66
66
  ...i,
67
- body: s == null ? void 0 : s.toString()
67
+ body: r == null ? void 0 : r.toString()
68
68
  };
69
69
  }
70
70
  }
71
71
  return i;
72
- }, Se = ({ archive: e, resourcePath: t }) => async (i) => Te({ archive: e, resourcePath: t })(i), ke = ({ archive: e, resourcePath: t }) => async (i) => {
73
- const r = Object.values(e.files).find(
72
+ }, ke = ({ archive: e, resourcePath: t }) => async (i) => Se({ archive: e, resourcePath: t })(i), Ne = ({ archive: e, resourcePath: t }) => async (i) => {
73
+ const s = Object.values(e.files).find(
74
74
  (n) => n.uri === t
75
75
  );
76
- if (r != null && r.basename.endsWith(".css")) {
77
- const s = (i.body ?? await r.string()).replaceAll(
76
+ if (s != null && s.basename.endsWith(".css")) {
77
+ const r = (i.body ?? await s.string()).replaceAll(
78
78
  "-webkit-writing-mode",
79
79
  "writing-mode"
80
80
  );
81
81
  return {
82
82
  ...i,
83
- body: s
83
+ body: r
84
84
  };
85
85
  }
86
86
  return i;
87
87
  }, C = (e) => {
88
- const i = Object.values(e.files).filter((r) => !r.dir).find((r) => r.uri.endsWith(".opf"));
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
- }, E = (e) => e ? e.children.map((t) => t instanceof pe ? t.text : t instanceof fe ? E(t) : "").join("").trim() : "", T = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Q = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Ne = (e) => {
93
+ }, ee = (e) => e ? e.children.map((t) => t instanceof fe ? t.text : t instanceof ue ? ee(t) : "").join("").trim() : "", T = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Z = (e) => e.endsWith("/") ? e.slice(0, -1) : e, We = (e) => {
94
94
  const t = e.lastIndexOf("/");
95
95
  return t >= 0 ? e.substring(0, t) : "";
96
- }, ee = (e, { basePath: t, baseUrl: i }) => {
97
- const r = {
96
+ }, te = (e, { basePath: t, baseUrl: i }) => {
97
+ const s = {
98
98
  contents: [],
99
99
  path: "",
100
100
  href: "",
101
101
  title: ""
102
102
  };
103
103
  let n = e.childNamed("span") || e.childNamed("a");
104
- r.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || E(n)) ?? "";
105
- let s = n == null ? void 0 : n.name;
106
- 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));
104
+ s.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || ee(n)) ?? "";
105
+ let r = n == null ? void 0 : n.name;
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
- o && o.length > 0 && (r.contents = o.map(
111
- (d) => ee(d, { basePath: t, baseUrl: i })
110
+ o && o.length > 0 && (s.contents = o.map(
111
+ (d) => te(d, { basePath: t, baseUrl: i })
112
112
  ));
113
113
  }
114
- return r;
115
- }, We = (e, { basePath: t, baseUrl: i }) => {
116
- var s, a;
117
- const r = [];
114
+ return s;
115
+ }, Le = (e, { basePath: t, baseUrl: i }) => {
116
+ var r, a;
117
+ const s = [];
118
118
  let n;
119
- 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(
120
- (o) => r.push(ee(o, { basePath: t, baseUrl: i }))
121
- ), r;
122
- }, Le = async (e, t, { baseUrl: i }) => {
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(te(o, { basePath: t, baseUrl: i }))
121
+ ), s;
122
+ }, Pe = async (e, t, { baseUrl: i }) => {
123
123
  var n;
124
- const r = (n = e.childNamed("manifest")) == null ? void 0 : n.childrenNamed("item").find((s) => s.attr.properties === "nav");
125
- if (r) {
126
- const s = Object.values(t.files).find(
127
- (a) => a.uri.endsWith(r.attr.href || "")
124
+ const s = (n = e.childNamed("manifest")) == null ? void 0 : n.childrenNamed("item").find((r) => r.attr.properties === "nav");
125
+ if (s) {
126
+ const r = Object.values(t.files).find(
127
+ (a) => a.uri.endsWith(s.attr.href || "")
128
128
  );
129
- if (s) {
130
- const a = new F.XmlDocument(await s.string()), o = Ne(s.uri);
131
- return We(a, { basePath: o, baseUrl: i });
129
+ if (r) {
130
+ const a = new F.XmlDocument(await r.string()), o = We(r.uri);
131
+ return Le(a, { basePath: o, baseUrl: i });
132
132
  }
133
133
  }
134
- }, te = (e, {
134
+ }, ne = (e, {
135
135
  opfBasePath: t,
136
136
  baseUrl: i,
137
- prefix: r
137
+ prefix: s
138
138
  }) => {
139
139
  var o, d;
140
- const n = ((o = e == null ? void 0 : e.childNamed(`${r}content`)) == null ? void 0 : o.attr.src) || "", s = {
141
- title: ((d = e == null ? void 0 : e.descendantWithPath(`${r}navLabel.${r}text`)) == null ? void 0 : d.val) || "",
140
+ const n = ((o = e == null ? void 0 : e.childNamed(`${s}content`)) == null ? void 0 : o.attr.src) || "", r = {
141
+ title: ((d = e == null ? void 0 : e.descendantWithPath(`${s}navLabel.${s}text`)) == null ? void 0 : d.val) || "",
142
142
  path: N(t, n),
143
143
  href: N(i, t, n),
144
144
  contents: []
145
- }, a = e.childrenNamed(`${r}navPoint`);
146
- return a && a.length > 0 && (s.contents = a.map(
147
- (p) => te(p, { opfBasePath: t, baseUrl: i, prefix: r })
148
- )), s;
149
- }, Pe = (e, { opfBasePath: t, baseUrl: i }) => {
145
+ }, a = e.childrenNamed(`${s}navPoint`);
146
+ return a && a.length > 0 && (r.contents = a.map(
147
+ (p) => ne(p, { opfBasePath: t, baseUrl: i, prefix: s })
148
+ )), r;
149
+ }, Ce = (e, { opfBasePath: t, baseUrl: i }) => {
150
150
  var a;
151
- const r = [], n = e.name;
152
- let s = "";
153
- return n.indexOf(":") !== -1 && (s = n.split(":")[0] + ":"), (a = e.childNamed(`${s}navMap`)) == null || a.childrenNamed(`${s}navPoint`).forEach(
154
- (o) => r.push(te(o, { opfBasePath: t, baseUrl: i, prefix: s }))
155
- ), r;
156
- }, Ce = async ({
151
+ const s = [], n = e.name;
152
+ let r = "";
153
+ return n.indexOf(":") !== -1 && (r = n.split(":")[0] + ":"), (a = e.childNamed(`${r}navMap`)) == null || a.childrenNamed(`${r}navPoint`).forEach(
154
+ (o) => s.push(ne(o, { opfBasePath: t, baseUrl: i, prefix: r }))
155
+ ), s;
156
+ }, Ie = async ({
157
157
  opfData: e,
158
158
  opfBasePath: t,
159
159
  baseUrl: i,
160
- archive: r
160
+ archive: s
161
161
  }) => {
162
162
  var a;
163
- const n = e.childNamed("spine"), s = n && n.attr.toc;
164
- if (s) {
165
- const o = (a = e.childNamed("manifest")) == null ? void 0 : a.childrenNamed("item").find((d) => d.attr.id === s);
163
+ const n = e.childNamed("spine"), r = n && n.attr.toc;
164
+ if (r) {
165
+ const o = (a = e.childNamed("manifest")) == null ? void 0 : a.childrenNamed("item").find((d) => d.attr.id === r);
166
166
  if (o) {
167
- const d = `${t}${t === "" ? "" : "/"}${o.attr.href}`, p = Object.values(r.files).find(
167
+ const d = `${t}${t === "" ? "" : "/"}${o.attr.href}`, p = Object.values(s.files).find(
168
168
  (c) => c.uri.endsWith(d)
169
169
  );
170
170
  if (p) {
171
171
  const c = new F.XmlDocument(await p.string());
172
- return Pe(c, { opfBasePath: t, baseUrl: i });
172
+ return Ce(c, { opfBasePath: t, baseUrl: i });
173
173
  }
174
174
  }
175
175
  }
176
- }, Ie = async (e, t, { baseUrl: i }) => {
177
- const { basePath: r } = C(t) || {}, n = await Ce({
176
+ }, Re = async (e, t, { baseUrl: i }) => {
177
+ const { basePath: s } = C(t) || {}, n = await Ie({
178
178
  opfData: e,
179
- opfBasePath: r,
179
+ opfBasePath: s,
180
180
  archive: t,
181
181
  baseUrl: i
182
182
  });
183
- return n || await Le(e, t, { opfBasePath: r, baseUrl: i });
184
- }, Re = async (e) => {
183
+ return n || await Pe(e, t, { opfBasePath: s, baseUrl: i });
184
+ }, je = async (e) => {
185
185
  const t = {
186
186
  renditionLayout: void 0
187
187
  };
188
188
  return await Promise.all(
189
189
  e.files.map(async (i) => {
190
- var r, n;
190
+ var s, n;
191
191
  if (i.uri.endsWith("com.kobobooks.display-options.xml")) {
192
- const a = (r = new F.XmlDocument(await i.string()).childNamed("platform")) == null ? void 0 : r.childNamed("option");
192
+ const a = (s = new F.XmlDocument(await i.string()).childNamed("platform")) == null ? void 0 : s.childNamed("option");
193
193
  ((n = a == null ? void 0 : a.attr) == null ? void 0 : n.name) === "fixed-layout" && a.val === "true" && (t.renditionLayout = "pre-paginated");
194
194
  }
195
195
  })
196
196
  ), t;
197
- }, ne = async ({
197
+ }, re = async ({
198
198
  archive: e
199
199
  }) => {
200
- const { data: t, basePath: i } = C(e) || {}, r = await (t == null ? void 0 : t.string());
201
- if (!r) return [];
202
- const n = new F.XmlDocument(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 || ""))) || [];
200
+ const { data: t, basePath: i } = C(e) || {}, s = await (t == null ? void 0 : t.string());
201
+ if (!s) return [];
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
- }, re = (e) => {
204
+ }, se = (e) => {
205
205
  var i;
206
206
  const t = e.childNamed("manifest");
207
- return ((i = t == null ? void 0 : t.childrenNamed("item")) == null ? void 0 : i.map((r) => ({
208
- href: r.attr.href || "",
209
- id: r.attr.id || "",
210
- mediaType: r.attr["media-type"]
207
+ return ((i = t == null ? void 0 : t.childrenNamed("item")) == null ? void 0 : i.map((s) => ({
208
+ href: s.attr.href || "",
209
+ id: s.attr.id || "",
210
+ mediaType: s.attr["media-type"]
211
211
  }))) || [];
212
- }, je = ({ archive: e, baseUrl: t }) => async (i) => {
213
- var M;
214
- const { data: r, basePath: n } = C(e) || {}, s = await Re(e);
215
- if (!r)
212
+ }, De = ({ archive: e, baseUrl: t }) => async (i) => {
213
+ var X;
214
+ const { data: s, basePath: n } = C(e) || {}, r = await je(e);
215
+ if (!s)
216
216
  return i;
217
- const a = await r.string();
218
- v.log(a, s);
219
- const o = new F.XmlDocument(a), d = await Ie(o, e, { baseUrl: t }) || [], p = o.childNamed("metadata"), c = o.childNamed("manifest"), l = o.childNamed("spine"), u = o.childNamed("guide"), g = p == null ? void 0 : p.childNamed("dc:title"), b = (p == null ? void 0 : p.childrenNamed("meta")) || [], h = b.find(
217
+ const a = await s.string();
218
+ 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"), u = o.childNamed("guide"), g = p == null ? void 0 : p.childNamed("dc:title"), b = (p == null ? void 0 : p.childrenNamed("meta")) || [], h = b.find(
220
220
  (m) => m.attr.property === "rendition:layout"
221
221
  ), x = b.find(
222
222
  (m) => m.attr.property === "rendition:flow"
223
223
  ), y = b.find(
224
224
  (m) => m.attr.property === "rendition:spread"
225
- ), w = h == null ? void 0 : h.val, W = x == null ? void 0 : x.val, se = y == null ? void 0 : y.val, ie = (g == null ? void 0 : g.val) || ((M = e.files.find(({ dir: m }) => m)) == null ? void 0 : M.basename) || "", ae = l == null ? void 0 : l.attr["page-progression-direction"], oe = (await ne({ archive: e })).reduce(
226
- (m, f) => f.size + m,
225
+ ), w = h == null ? void 0 : h.val, W = x == null ? void 0 : x.val, ie = y == null ? void 0 : y.val, ae = (g == null ? void 0 : g.val) || ((X = e.files.find(({ dir: m }) => m)) == null ? void 0 : X.basename) || "", oe = l == null ? void 0 : l.attr["page-progression-direction"], ce = (await re({ archive: e })).reduce(
226
+ (m, I) => I.size + m,
227
227
  0
228
228
  );
229
229
  return {
@@ -231,50 +231,51 @@ const v = {
231
231
  nav: {
232
232
  toc: d
233
233
  },
234
- renditionLayout: w || s.renditionLayout || "reflowable",
234
+ renditionLayout: w || r.renditionLayout || "reflowable",
235
235
  renditionFlow: W || "auto",
236
- renditionSpread: se,
237
- title: ie,
238
- readingDirection: ae || "ltr",
239
- spineItems: (l == null ? void 0 : l.childrenNamed("itemref").map((m) => {
240
- var B, U, H;
241
- const f = c == null ? void 0 : c.childrenNamed("item").find(($) => $.attr.id === (m == null ? void 0 : m.attr.idref)), ce = (f == null ? void 0 : f.attr.href) || "", I = ((B = m == null ? void 0 : m.attr.properties) == null ? void 0 : B.split(" ")) || [], de = ((U = e.files.find(($) => $.uri.endsWith(ce))) == null ? void 0 : U.size) || 0, X = t ?? "";
236
+ renditionSpread: ie,
237
+ title: ae,
238
+ readingDirection: oe || "ltr",
239
+ spineItems: (l == null ? void 0 : l.childrenNamed("itemref").map((m, I) => {
240
+ var U, H, V;
241
+ const f = c == null ? void 0 : c.childrenNamed("item").find(($) => $.attr.id === (m == null ? void 0 : m.attr.idref)), de = (f == null ? void 0 : f.attr.href) || "", R = ((U = m == null ? void 0 : m.attr.properties) == null ? void 0 : U.split(" ")) || [], le = ((H = e.files.find(($) => $.uri.endsWith(de))) == null ? void 0 : H.size) || 0, B = t ?? "";
242
242
  return {
243
243
  id: (f == null ? void 0 : f.attr.id) || "",
244
- href: (H = f == null ? void 0 : f.attr.href) != null && H.startsWith("https://") ? f == null ? void 0 : f.attr.href : n ? `${X}${n}/${f == null ? void 0 : f.attr.href}` : `${X}${f == null ? void 0 : f.attr.href}`,
244
+ index: I,
245
+ href: (V = f == null ? void 0 : f.attr.href) != null && V.startsWith("https://") ? f == null ? void 0 : f.attr.href : n ? `${B}${n}/${f == null ? void 0 : f.attr.href}` : `${B}${f == null ? void 0 : f.attr.href}`,
245
246
  renditionLayout: w || "reflowable",
246
- ...I.find(
247
+ ...R.find(
247
248
  ($) => $ === "rendition:layout-reflowable"
248
249
  ) && {
249
250
  renditionLayout: "reflowable"
250
251
  },
251
- progressionWeight: de / oe,
252
- pageSpreadLeft: I.some(($) => $ === "page-spread-left") || void 0,
253
- pageSpreadRight: I.some(($) => $ === "page-spread-right") || void 0,
252
+ progressionWeight: le / ce,
253
+ pageSpreadLeft: R.some(($) => $ === "page-spread-left") || void 0,
254
+ pageSpreadRight: R.some(($) => $ === "page-spread-right") || void 0,
254
255
  // size: itemSize
255
256
  mediaType: f == null ? void 0 : f.attr["media-type"]
256
257
  };
257
258
  })) || [],
258
- items: re(o),
259
+ items: se(o),
259
260
  guide: u == null ? void 0 : u.childrenNamed("reference").map((m) => ({
260
261
  href: m.attr.href || "",
261
262
  title: m.attr.title || "",
262
263
  type: m.attr.type
263
264
  }))
264
265
  };
265
- }, De = async (e, t) => {
266
- var n, s;
267
- const r = await ((n = C(e).data) == null ? void 0 : n.string());
268
- if (r) {
269
- const a = new F.XmlDocument(r);
266
+ }, Oe = async (e, t) => {
267
+ var n, r;
268
+ const s = await ((n = C(e).data) == null ? void 0 : n.string());
269
+ if (s) {
270
+ const a = new F.XmlDocument(s);
270
271
  return {
271
- mediaType: (s = re(a).find((d) => t.endsWith(d.href))) == null ? void 0 : s.mediaType
272
+ mediaType: (r = se(a).find((d) => t.endsWith(d.href))) == null ? void 0 : r.mediaType
272
273
  };
273
274
  }
274
275
  return {
275
- mediaType: Oe(t)
276
+ mediaType: ze(t)
276
277
  };
277
- }, Oe = (e) => {
278
+ }, ze = (e) => {
278
279
  if (e.endsWith(".css"))
279
280
  return "text/css; charset=UTF-8";
280
281
  if (e.endsWith(".jpg"))
@@ -285,25 +286,25 @@ const v = {
285
286
  return "video/mp4";
286
287
  if (e.endsWith(".svg"))
287
288
  return "image/svg+xml";
288
- }, ze = ({ archive: e, resourcePath: t }) => async (i) => {
289
- const r = Object.values(e.files).find(
290
- (s) => s.uri === t
289
+ }, Me = ({ archive: e, resourcePath: t }) => async (i) => {
290
+ const s = Object.values(e.files).find(
291
+ (r) => r.uri === t
291
292
  );
292
- if (!r) return i;
293
- const n = await De(e, t);
293
+ if (!s) return i;
294
+ const n = await Oe(e, t);
294
295
  return {
295
296
  ...i,
296
297
  params: {
297
298
  ...i.params,
298
- ...(r == null ? void 0 : r.encodingFormat) && {
299
- contentType: r.encodingFormat
299
+ ...(s == null ? void 0 : s.encodingFormat) && {
300
+ contentType: s.encodingFormat
300
301
  },
301
302
  ...n.mediaType && {
302
303
  contentType: n.mediaType
303
304
  }
304
305
  }
305
306
  };
306
- }, Z = [
307
+ }, E = [
307
308
  "div",
308
309
  "span",
309
310
  "p",
@@ -354,19 +355,19 @@ const v = {
354
355
  "canvas",
355
356
  "script",
356
357
  "style"
357
- ], Me = ({ archive: e, resourcePath: t }) => async (i) => {
358
- const r = Object.values(e.files).find(
358
+ ], Xe = ({ archive: e, resourcePath: t }) => async (i) => {
359
+ const s = Object.values(e.files).find(
359
360
  (n) => n.uri === t
360
361
  );
361
- if (r != null && r.basename.endsWith(".xhtml")) {
362
- const n = i.body ?? await r.string();
362
+ if (s != null && s.basename.endsWith(".xhtml")) {
363
+ const n = i.body ?? await s.string();
363
364
  if (!new RegExp(
364
- `<(${Z.join("|")})[\\s/>]`,
365
+ `<(${E.join("|")})[\\s/>]`,
365
366
  "i"
366
367
  ).test(n))
367
368
  return i;
368
369
  const a = new RegExp(
369
- `<(${Z.join("|")})(\\s[^>]*)?\\s*/>`,
370
+ `<(${E.join("|")})(\\s[^>]*)?\\s*/>`,
370
371
  "gi"
371
372
  ), o = n.replace(
372
373
  a,
@@ -378,43 +379,44 @@ const v = {
378
379
  };
379
380
  }
380
381
  return i;
381
- }, Xe = async (e, t) => {
382
+ }, Be = async (e, t) => {
382
383
  const i = Object.values(e.files).find(
383
- (s) => s.uri === t
384
+ (r) => r.uri === t
384
385
  );
385
386
  if (!i)
386
387
  throw new Error("no file found");
387
- const r = {
388
+ const s = {
388
389
  params: {}
389
390
  }, n = [
390
- ze({ archive: e, resourcePath: t }),
391
391
  Me({ archive: e, resourcePath: t }),
392
- ke({ archive: e, resourcePath: t }),
393
- Se({ archive: e, resourcePath: t })
392
+ Xe({ archive: e, resourcePath: t }),
393
+ Ne({ archive: e, resourcePath: t }),
394
+ ke({ archive: e, resourcePath: t })
394
395
  ];
395
396
  try {
396
- const s = await n.reduce(async (a, o) => await o(await a), Promise.resolve(r));
397
- return v.log("Generated resource", t, s), {
398
- ...s,
399
- body: s.body ?? await i.blob()
397
+ const r = await n.reduce(async (a, o) => await o(await a), Promise.resolve(s));
398
+ return v.log("Generated resource", t, r), {
399
+ ...r,
400
+ body: r.body ?? await i.blob()
400
401
  };
401
- } catch (s) {
402
- throw v.error(s), s;
402
+ } catch (r) {
403
+ throw v.error(r), r;
403
404
  }
404
- }, Be = ({ archive: e, baseUrl: t }) => async () => {
405
- var r;
405
+ }, Ue = ({ archive: e, baseUrl: t }) => async () => {
406
+ var s;
406
407
  const i = Object.values(e.files).filter((n) => !n.dir);
407
408
  return {
408
409
  filename: e.filename,
409
- title: ((r = e.files.find(({ dir: n }) => n)) == null ? void 0 : r.basename.replace(/\/$/, "")) || "",
410
+ title: ((s = e.files.find(({ dir: n }) => n)) == null ? void 0 : s.basename.replace(/\/$/, "")) || "",
410
411
  renditionLayout: "pre-paginated",
411
412
  renditionSpread: "auto",
412
413
  readingDirection: "ltr",
413
- spineItems: i.filter((n) => !n.basename.endsWith(".db")).map((n, s) => ({
414
+ spineItems: i.filter((n) => !n.basename.endsWith(".db")).map((n, r) => ({
414
415
  // some books such as cbz can have same basename inside different sub folder
415
416
  // we need to make sure to have unique index
416
417
  // /chap01/01.png, /chap02/01.png, etc
417
- id: `${s}.${n.basename}`,
418
+ id: `${r}.${n.basename}`,
419
+ index: r,
418
420
  href: encodeURI(`${t}${n.uri}`),
419
421
  renditionLayout: "pre-paginated",
420
422
  progressionWeight: 1 / i.length,
@@ -422,19 +424,19 @@ const v = {
422
424
  pageSpreadRight: void 0,
423
425
  mediaType: n.encodingFormat
424
426
  })),
425
- items: i.map((n, s) => ({
426
- id: `${s}.${n.basename}`,
427
+ items: i.map((n, r) => ({
428
+ id: `${r}.${n.basename}`,
427
429
  href: `${t}${n.uri}`
428
430
  }))
429
431
  };
430
- }, Ue = ({ archive: e }) => async (t) => {
431
- var s;
432
+ }, He = ({ archive: e }) => async (t) => {
433
+ var r;
432
434
  const i = e.files.find(
433
435
  (a) => a.basename.toLowerCase() === "comicinfo.xml"
434
436
  );
435
437
  if (!i)
436
438
  return t;
437
- const r = {
439
+ const s = {
438
440
  ...t,
439
441
  spineItems: t.spineItems.filter((a) => !a.id.toLowerCase().endsWith("comicinfo.xml")).map((a, o, d) => ({
440
442
  ...a,
@@ -442,53 +444,53 @@ const v = {
442
444
  }))
443
445
  }, n = await i.string();
444
446
  try {
445
- const o = ((s = new F.XmlDocument(n).childNamed("Manga")) == null ? void 0 : s.val) || "unknown";
447
+ const o = ((r = new F.XmlDocument(n).childNamed("Manga")) == null ? void 0 : r.val) || "unknown";
446
448
  return {
447
- ...r,
449
+ ...s,
448
450
  readingDirection: o === "YesAndRightToLeft" ? "rtl" : "ltr"
449
451
  };
450
452
  } catch (a) {
451
453
  return console.error(`Unable to parse comicinfo.xml for content
452
- `, n), console.error(a), r;
454
+ `, n), console.error(a), s;
453
455
  }
454
- }, He = (e) => {
456
+ }, Ve = (e) => {
455
457
  var i;
456
- const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((r) => r.attr.name === "viewport");
458
+ const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((s) => s.attr.name === "viewport");
457
459
  return !!(t && t.attr.name === "viewport");
458
- }, Ve = (e) => e.reduce(async (t, i) => {
459
- if (!await t || !ue({
460
+ }, _e = (e) => e.reduce(async (t, i) => {
461
+ if (!await t || !me({
460
462
  mimeType: i.encodingFormat,
461
463
  uri: i.uri
462
464
  }))
463
465
  return !1;
464
466
  const n = await i.string();
465
- return n ? He(new F.XmlDocument(n)) : !1;
466
- }, Promise.resolve(!0)), _e = ({ archive: e }) => async (t) => {
467
- if (t.renditionLayout === "reflowable" && t.spineItems.every((r) => r.renditionLayout === "reflowable")) {
468
- const r = await ne({ archive: e });
469
- if (await Ve(r))
467
+ return n ? Ve(new F.XmlDocument(n)) : !1;
468
+ }, Promise.resolve(!0)), qe = ({ archive: e }) => async (t) => {
469
+ if (t.renditionLayout === "reflowable" && t.spineItems.every((s) => s.renditionLayout === "reflowable")) {
470
+ const s = await re({ archive: e });
471
+ if (await _e(s))
470
472
  return {
471
473
  ...t,
472
- spineItems: t.spineItems.map((s) => ({
473
- ...s,
474
+ spineItems: t.spineItems.map((r) => ({
475
+ ...r,
474
476
  renditionLayout: "pre-paginated"
475
477
  })),
476
478
  renditionLayout: "pre-paginated"
477
479
  };
478
480
  }
479
481
  return t;
480
- }, z = (e, t) => {
482
+ }, M = (e, t) => {
481
483
  var n;
482
- const i = e.split(/(\d+)/), r = t.split(/(\d+)/);
483
- for (let s = 0, a = i.length; s < a; s++)
484
- if (i[s] !== r[s])
485
- return (n = i[s]) != null && n.match(/\d/) ? +(i[s] || "") - +(r[s] || "") : (i[s] || "").localeCompare(r[s] || "");
484
+ const i = e.split(/(\d+)/), s = t.split(/(\d+)/);
485
+ for (let r = 0, a = i.length; r < a; r++)
486
+ if (i[r] !== s[r])
487
+ return (n = i[r]) != null && n.match(/\d/) ? +(i[r] || "") - +(s[r] || "") : (i[r] || "").localeCompare(s[r] || "");
486
488
  return 1;
487
- }, qe = ({ archive: e, baseUrl: t }) => async (i) => {
489
+ }, Ge = ({ archive: e, baseUrl: t }) => async (i) => {
488
490
  if (i.nav) return i;
489
- const r = [...e.files].sort(
490
- (o, d) => z(o.uri, d.uri)
491
- ), n = Object.values(r), s = (o, d, p, c, l) => {
491
+ const s = [...e.files].sort(
492
+ (o, d) => M(o.uri, d.uri)
493
+ ), n = Object.values(s), r = (o, d, p, c, l) => {
492
494
  const u = o.find((h) => h.title === d), [g, ...b] = p;
493
495
  return u ? g ? [
494
496
  ...o.filter((x) => x != u),
@@ -496,7 +498,7 @@ const v = {
496
498
  ...u,
497
499
  contents: [
498
500
  ...u.contents,
499
- ...s(
501
+ ...r(
500
502
  u.contents,
501
503
  g,
502
504
  b,
@@ -515,7 +517,7 @@ const v = {
515
517
  ] : o : g ? [
516
518
  ...o,
517
519
  {
518
- contents: s(
520
+ contents: r(
519
521
  [],
520
522
  g,
521
523
  b,
@@ -541,7 +543,7 @@ const v = {
541
543
  const c = d.uri.split("/").slice(0, -1), [l, ...u] = c;
542
544
  if (l) {
543
545
  const g = N(t, encodeURI(d.uri)).replace(/\/$/, ""), b = d.uri.replace(/\/$/, "");
544
- return s(o, l, u, g, b);
546
+ return r(o, l, u, g, b);
545
547
  }
546
548
  return o;
547
549
  },
@@ -553,7 +555,7 @@ const v = {
553
555
  toc: a
554
556
  }
555
557
  };
556
- }, Ge = {
558
+ }, Ke = {
557
559
  filename: "",
558
560
  items: [],
559
561
  nav: {
@@ -564,21 +566,21 @@ const v = {
564
566
  renditionSpread: "auto",
565
567
  spineItems: [],
566
568
  title: ""
567
- }, Ke = async (e, { baseUrl: t = "" } = {}) => {
569
+ }, Je = async (e, { baseUrl: t = "" } = {}) => {
568
570
  const i = [
569
- Be({ archive: e, baseUrl: t }),
570
- je({ archive: e, baseUrl: t }),
571
- _e({ archive: e, baseUrl: t }),
572
571
  Ue({ archive: e, baseUrl: t }),
573
- qe({ archive: e, baseUrl: t })
572
+ De({ archive: e, baseUrl: t }),
573
+ qe({ archive: e, baseUrl: t }),
574
+ He({ archive: e, baseUrl: t }),
575
+ Ge({ archive: e, baseUrl: t })
574
576
  ];
575
577
  try {
576
- const r = await i.reduce(async (n, s) => await s(await n), Promise.resolve(Ge));
577
- return v.log("Generated manifest", r), r;
578
- } catch (r) {
579
- throw v.error(r), r;
578
+ const s = await i.reduce(async (n, r) => await r(await n), Promise.resolve(Ke));
579
+ return v.log("Generated manifest", s), s;
580
+ } catch (s) {
581
+ throw v.error(s), s;
580
582
  }
581
- }, nt = async (e, t) => {
583
+ }, rt = async (e, t) => {
582
584
  const i = `
583
585
  <?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
584
586
  <metadata>
@@ -587,22 +589,22 @@ const v = {
587
589
  </metadata>
588
590
  <manifest>
589
591
  ${e.map(
590
- (s) => `<item id="${T(s)}" href="${s}" media-type="${V(s)}"/>`
592
+ (r) => `<item id="${T(r)}" href="${r}" media-type="${_(r)}"/>`
591
593
  ).join(`
592
594
  `)}
593
595
  </manifest>
594
596
  <spine>
595
- ${e.map((s) => `<itemref idref="${T(s)}" />`).join(`
597
+ ${e.map((r) => `<itemref idref="${T(r)}" />`).join(`
596
598
  `)}
597
599
  </spine>
598
600
  </package>
599
- `, r = e.map((s) => ({
601
+ `, s = e.map((r) => ({
600
602
  dir: !1,
601
- basename: T(s),
602
- encodingFormat: V(s),
603
- uri: s,
603
+ basename: T(r),
604
+ encodingFormat: _(r),
605
+ uri: r,
604
606
  size: 100 / e.length,
605
- blob: async () => (await fetch(s)).blob(),
607
+ blob: async () => (await fetch(r)).blob(),
606
608
  string: async () => ""
607
609
  }));
608
610
  return {
@@ -614,14 +616,14 @@ const v = {
614
616
  size: 0,
615
617
  blob: async () => new Blob(),
616
618
  string: async () => i
617
- }, ...r],
619
+ }, ...s],
618
620
  close: () => Promise.resolve()
619
621
  };
620
- }, rt = async (e, {
622
+ }, st = async (e, {
621
623
  mimeType: t,
622
624
  direction: i
623
625
  } = { mimeType: "text/plain" }) => {
624
- const r = `
626
+ const s = `
625
627
  <?xml version="1.0" encoding="UTF-8"?>
626
628
  <package xmlns="http://www.idpf.org/2007/opf" version="3.0" xml:lang="ja" prefix="rendition: http://www.idpf.org/vocab/rendition/#"
627
629
  unique-identifier="ootuya-id">
@@ -644,8 +646,8 @@ const v = {
644
646
  dir: !1,
645
647
  basename: T("generated.opf"),
646
648
  uri: "generated.opf",
647
- blob: async () => new Blob([r]),
648
- string: async () => r,
649
+ blob: async () => new Blob([s]),
650
+ string: async () => s,
649
651
  size: 0
650
652
  },
651
653
  {
@@ -660,30 +662,30 @@ const v = {
660
662
  ],
661
663
  close: () => Promise.resolve()
662
664
  };
663
- }, st = async (e, { orderByAlpha: t, name: i } = {}) => {
664
- let r = Object.values(e.files);
665
- t && (r = r.slice().sort((s, a) => z(s.name, a.name)));
665
+ }, it = async (e, { orderByAlpha: t, name: i } = {}) => {
666
+ let s = Object.values(e.files);
667
+ t && (s = s.slice().sort((r, a) => M(r.name, a.name)));
666
668
  const n = {
667
669
  filename: i || "",
668
- files: r.map((s) => ({
669
- dir: s.dir,
670
- basename: T(s.name),
671
- uri: s.name,
672
- blob: () => s.async("blob"),
673
- string: () => s.async("string"),
674
- ...s.internalStream && {
675
- stream: s.internalStream
670
+ files: s.map((r) => ({
671
+ dir: r.dir,
672
+ basename: T(r.name),
673
+ uri: r.name,
674
+ blob: () => r.async("blob"),
675
+ string: () => r.async("string"),
676
+ ...r.internalStream && {
677
+ stream: r.internalStream
676
678
  },
677
679
  // this is private API
678
680
  // eslint-disable-next-line @typescript-eslint/ban-ts-comment
679
681
  // @ts-ignore
680
- size: s._data.uncompressedSize
682
+ size: r._data.uncompressedSize
681
683
  })),
682
684
  close: () => Promise.resolve()
683
685
  };
684
686
  return v.log("Generated archive", n), n;
685
- }, it = async (e, { name: t } = {}) => {
686
- const i = await e.getFilesArray(), r = {
687
+ }, at = async (e, { name: t } = {}) => {
688
+ const i = await e.getFilesArray(), s = {
687
689
  close: () => e.close(),
688
690
  filename: t ?? "",
689
691
  files: i.map((n) => ({
@@ -695,35 +697,35 @@ const v = {
695
697
  string: async () => (await n.file.extract()).text()
696
698
  }))
697
699
  };
698
- return v.log("Generated archive", r), r;
699
- }, at = async (e, { orderByAlpha: t, name: i } = {}) => {
700
- let r = e;
701
- return t && (r = r.slice().sort((n, s) => z(n.name, s.name))), {
700
+ return v.log("Generated archive", s), s;
701
+ }, ot = async (e, { orderByAlpha: t, name: i } = {}) => {
702
+ let s = e;
703
+ return t && (s = s.slice().sort((n, r) => M(n.name, r.name))), {
702
704
  filename: i || "",
703
- files: r.map((n) => ({
705
+ files: s.map((n) => ({
704
706
  dir: n.isDir,
705
707
  basename: T(n.name),
706
708
  uri: n.name,
707
709
  blob: async () => new Blob([await n.data()]),
708
710
  string: async () => {
709
- const s = await n.data();
711
+ const r = await n.data();
710
712
  return String.fromCharCode.apply(
711
713
  null,
712
- Array.from(new Uint16Array(s))
714
+ Array.from(new Uint16Array(r))
713
715
  );
714
716
  },
715
717
  size: n.size
716
718
  })),
717
719
  close: () => Promise.resolve()
718
720
  };
719
- }, ot = ({
721
+ }, ct = ({
720
722
  enableReport: e
721
723
  } = {}) => {
722
724
  v.enable(!!e);
723
725
  };
724
- class Je {
726
+ class Ye {
725
727
  constructor(t) {
726
- this.cleanArchiveAfter = t, this.state$ = new we({
728
+ this.cleanArchiveAfter = t, this.state$ = new ve({
727
729
  status: "idle",
728
730
  locks: 0
729
731
  });
@@ -740,43 +742,43 @@ class Je {
740
742
  get isUnlocked$() {
741
743
  return this.locks$.pipe(
742
744
  A((t) => t <= 0),
743
- ve(),
744
- $e()
745
+ $e(),
746
+ xe()
745
747
  );
746
748
  }
747
749
  get overTTL$() {
748
750
  return this.isUnlocked$.pipe(
749
751
  k(
750
- (t) => t ? this.cleanArchiveAfter === 1 / 0 ? G : xe(this.cleanArchiveAfter) : G
752
+ (t) => t ? this.cleanArchiveAfter === 1 / 0 ? K : Fe(this.cleanArchiveAfter) : K
751
753
  )
752
754
  );
753
755
  }
754
756
  }
755
- const Ye = ({
757
+ const Qe = ({
756
758
  getArchive: e,
757
759
  cleanArchiveAfter: t = 5 * 60 * 1e3
758
760
  // 5mn
759
761
  }) => {
760
- const i = new R(), r = new R(), n = new R(), s = {}, a = i.pipe(
761
- O((p) => {
762
- const c = s[p];
763
- if (!c || c.state.status !== "idle") return _;
762
+ const i = new j(), s = new j(), n = new j(), r = {}, a = i.pipe(
763
+ z((p) => {
764
+ const c = r[p];
765
+ if (!c || c.state.status !== "idle") return q;
764
766
  let l = !1;
765
767
  const u = (y) => {
766
768
  var W;
767
- const w = s[y];
768
- delete s[y], l || ((W = w == null ? void 0 : w.state.archive) == null || W.close(), l = !0);
769
+ const w = r[y];
770
+ delete r[y], l || ((W = w == null ? void 0 : w.state.archive) == null || W.close(), l = !0);
769
771
  };
770
772
  c.update({
771
773
  status: "loading"
772
774
  });
773
775
  const g = c.locks$, b = c.isUnlocked$, h = g.pipe(
774
- me(),
775
- j(([y, w]) => w > y),
776
- he(!0)
776
+ he(),
777
+ D(([y, w]) => w > y),
778
+ ge(!0)
777
779
  );
778
780
  return L(e(p)).pipe(
779
- D((y) => {
781
+ O((y) => {
780
782
  c.update({
781
783
  archive: y,
782
784
  status: "success"
@@ -785,25 +787,25 @@ const Ye = ({
785
787
  P((y) => (u(p), c.update({
786
788
  status: "error",
787
789
  error: y
788
- }), _)),
790
+ }), q)),
789
791
  k(() => {
790
792
  const y = h.pipe(
791
793
  k(() => n),
792
794
  k(() => b),
793
- j((w) => w)
795
+ D((w) => w)
794
796
  );
795
- return q(y, c.overTTL$);
797
+ return G(y, c.overTTL$);
796
798
  }),
797
- D(() => {
799
+ O(() => {
798
800
  u(p);
799
801
  })
800
802
  );
801
803
  }),
802
- ge(r)
804
+ ye(s)
803
805
  ), o = (p) => {
804
806
  let c = !1;
805
- const l = s[p] ?? new Je(t);
806
- s[p] = l, l.update({
807
+ const l = r[p] ?? new Ye(t);
808
+ r[p] = l, l.update({
807
809
  locks: l.state.locks + 1
808
810
  });
809
811
  const u = () => {
@@ -814,16 +816,16 @@ const Ye = ({
814
816
  i.next(p);
815
817
  const g = l.state$.pipe(
816
818
  A(({ archive: h }) => h),
817
- j((h) => !!h)
819
+ D((h) => !!h)
818
820
  ), b = l.state$.pipe(
819
- D(({ error: h }) => {
821
+ O(({ error: h }) => {
820
822
  if (h)
821
823
  throw h;
822
824
  }),
823
- ye()
825
+ be()
824
826
  );
825
- return q(g, b).pipe(
826
- be(),
827
+ return G(g, b).pipe(
828
+ we(),
827
829
  A((h) => ({ archive: h, release: u })),
828
830
  P((h) => {
829
831
  throw u(), h;
@@ -835,16 +837,16 @@ const Ye = ({
835
837
  return a.subscribe(), {
836
838
  access: o,
837
839
  purge: d,
838
- archives: s
840
+ archives: r
839
841
  };
840
842
  };
841
- class Qe {
843
+ class Ze {
842
844
  constructor({
843
845
  onError: t,
844
846
  onManifestSuccess: i,
845
- ...r
847
+ ...s
846
848
  }) {
847
- this.onError = (n) => (console.error(n), new Response(String(n), { status: 500 })), this.epubLoader = Ye(r), this.onManifestSuccess = i ?? (({ manifest: n }) => Promise.resolve(n)), this.onError = t ?? this.onError;
849
+ this.onError = (n) => (console.error(n), new Response(String(n), { status: 500 })), this.epubLoader = Qe(s), this.onManifestSuccess = i ?? (({ manifest: n }) => Promise.resolve(n)), this.onError = t ?? this.onError;
848
850
  }
849
851
  prune() {
850
852
  this.epubLoader.purge();
@@ -854,13 +856,13 @@ class Qe {
854
856
  }
855
857
  accessArchiveWithoutLock(t) {
856
858
  return this.accessArchive(t).pipe(
857
- A(({ archive: i, release: r }) => (r(), i))
859
+ A(({ archive: i, release: s }) => (s(), i))
858
860
  );
859
861
  }
860
862
  fetchManifest({ key: t, baseUrl: i }) {
861
- const r = this.accessArchive(t).pipe(
862
- O(({ archive: n, release: s }) => L(
863
- Ke(n, { baseUrl: i })
863
+ const s = this.accessArchive(t).pipe(
864
+ z(({ archive: n, release: r }) => L(
865
+ Je(n, { baseUrl: i })
864
866
  ).pipe(
865
867
  k(
866
868
  (o) => L(this.onManifestSuccess({ manifest: o, archive: n }))
@@ -870,21 +872,21 @@ class Qe {
870
872
  status: 200
871
873
  })
872
874
  ),
873
- K(() => {
874
- s();
875
+ J(() => {
876
+ r();
875
877
  })
876
878
  )),
877
- P((n) => J(this.onError(n)))
879
+ P((n) => Y(this.onError(n)))
878
880
  );
879
- return Y(r);
881
+ return Q(s);
880
882
  }
881
883
  fetchResource({
882
884
  key: t,
883
885
  resourcePath: i
884
886
  }) {
885
- const r = this.accessArchive(t).pipe(
886
- O(({ archive: n, release: s }) => L(
887
- Xe(n, i)
887
+ const s = this.accessArchive(t).pipe(
888
+ z(({ archive: n, release: r }) => L(
889
+ Be(n, i)
888
890
  ).pipe(
889
891
  A(
890
892
  (o) => new Response(o.body, {
@@ -896,16 +898,16 @@ class Qe {
896
898
  }
897
899
  })
898
900
  ),
899
- K(() => {
900
- s();
901
+ J(() => {
902
+ r();
901
903
  })
902
904
  )),
903
- P((n) => J(this.onError(n)))
905
+ P((n) => Y(this.onError(n)))
904
906
  );
905
- return Y(r);
907
+ return Q(s);
906
908
  }
907
909
  }
908
- class ct extends Qe {
910
+ class dt extends Ze {
909
911
  constructor({
910
912
  getUriInfo: t,
911
913
  ...i
@@ -916,30 +918,30 @@ class ct extends Qe {
916
918
  try {
917
919
  const i = this.getUriInfo(t);
918
920
  if (!i) return;
919
- const r = Q(i.baseUrl), n = t.request.url.substring(
920
- r.length + 1
921
- ), [s = ""] = n.split("/"), a = decodeURIComponent(
922
- Q(n.substring(s.length + 1))
921
+ const s = Z(i.baseUrl), n = t.request.url.substring(
922
+ s.length + 1
923
+ ), [r = ""] = n.split("/"), a = decodeURIComponent(
924
+ Z(n.substring(r.length + 1))
923
925
  );
924
926
  n.endsWith("/manifest") ? t.respondWith(
925
- this.fetchManifest({ key: s, baseUrl: `${r}/${s}/` })
926
- ) : t.respondWith(this.fetchResource({ key: s, resourcePath: a }));
927
+ this.fetchManifest({ key: r, baseUrl: `${s}/${r}/` })
928
+ ) : t.respondWith(this.fetchResource({ key: r, resourcePath: a }));
927
929
  } catch (i) {
928
930
  t.respondWith(new Response(String(i), { status: 500 }));
929
931
  }
930
932
  }
931
933
  }
932
934
  export {
933
- ct as ServiceWorkerStreamer,
934
- Qe as Streamer,
935
- ot as configure,
936
- at as createArchiveFromArrayBufferList,
937
- st as createArchiveFromJszip,
938
- it as createArchiveFromLibArchive,
939
- rt as createArchiveFromText,
940
- nt as createArchiveFromUrls,
941
- Ke as generateManifestFromArchive,
942
- Xe as generateResourceFromArchive,
935
+ dt as ServiceWorkerStreamer,
936
+ Ze as Streamer,
937
+ ct as configure,
938
+ ot as createArchiveFromArrayBufferList,
939
+ it as createArchiveFromJszip,
940
+ at as createArchiveFromLibArchive,
941
+ st as createArchiveFromText,
942
+ rt as createArchiveFromUrls,
943
+ Je as generateManifestFromArchive,
944
+ Be as generateResourceFromArchive,
943
945
  C as getArchiveOpfInfo
944
946
  };
945
947
  //# sourceMappingURL=index.js.map