@prose-reader/streamer 1.301.0 → 1.303.0

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