@prose-reader/streamer 1.85.0 → 1.87.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.
@@ -0,0 +1 @@
1
+ export {};
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { urlJoin as N, PROSE_READER_RESOURCE_ERROR_INJECTED_META_NAME as ie, isXmlBasedMimeType as oe, detectMimeTypeFromName as M } from "@prose-reader/shared";
2
2
  import y, { XmlDocument as ce } from "xmldoc";
3
- import { Subject as U, mergeMap as I, EMPTY as de, from as L, map as v, catchError as F, NEVER as V, shareReplay as le, switchMap as X, timer as me, tap as B, merge as _, takeUntil as pe, BehaviorSubject as fe, filter as ue, ignoreElements as he, first as ge, finalize as H, of as E, lastValueFrom as G } from "rxjs";
3
+ import { Subject as U, mergeMap as I, EMPTY as de, from as L, map as v, catchError as F, NEVER as V, shareReplay as le, switchMap as X, distinctUntilChanged as me, timer as pe, tap as B, merge as _, takeUntil as fe, BehaviorSubject as ue, filter as he, ignoreElements as ge, first as be, finalize as H, of as E, lastValueFrom as G } from "rxjs";
4
4
  let x = !1;
5
5
  const g = {
6
6
  enable: (e) => {
@@ -39,29 +39,29 @@ const g = {
39
39
  const t = performance.now(), a = s(...r);
40
40
  if (a && a.then)
41
41
  return a.then((o) => {
42
- const c = performance.now();
43
- return g.metric({ name: e, duration: c - t }, n), o;
42
+ const d = performance.now();
43
+ return g.metric({ name: e, duration: d - t }, n), o;
44
44
  });
45
45
  const i = performance.now();
46
46
  return g.metric({ name: e, duration: i - t }, n), a;
47
47
  }
48
- }, be = (e) => {
48
+ }, ye = (e) => {
49
49
  var s;
50
50
  const n = (s = e.descendantWithPath("head")) == null ? void 0 : s.childrenNamed("meta").find((r) => r.attr.name === "calibre:cover");
51
51
  return !!(n && n.attr.name === "calibre:cover");
52
- }, ye = (e) => {
52
+ }, we = (e) => {
53
53
  var n, s, r;
54
54
  return (r = (s = (n = e.descendantWithPath("body")) == null ? void 0 : n.descendantWithPath("div")) == null ? void 0 : s.childrenNamed("svg")) == null ? void 0 : r.find(
55
55
  (t) => t.attr.width === "100%" && t.attr.preserveAspectRatio === "none"
56
56
  );
57
- }, we = ({ archive: e, resourcePath: n }) => async (s) => {
57
+ }, ve = ({ archive: e, resourcePath: n }) => async (s) => {
58
58
  const r = Object.values(e.files).find(
59
59
  (t) => t.uri === n
60
60
  );
61
61
  if (r != null && r.basename.endsWith(".xhtml")) {
62
62
  const t = s.body ?? await r.string(), a = new ce(t);
63
- if (be(a)) {
64
- const i = ye(a);
63
+ if (ye(a)) {
64
+ const i = we(a);
65
65
  return i && delete i.attr.preserveAspectRatio, {
66
66
  ...s,
67
67
  body: a == null ? void 0 : a.toString()
@@ -69,7 +69,7 @@ const g = {
69
69
  }
70
70
  }
71
71
  return s;
72
- }, ve = ({ archive: e, resourcePath: n }) => async (s) => we({ archive: e, resourcePath: n })(s), $e = ({ archive: e, resourcePath: n }) => async (s) => {
72
+ }, $e = ({ archive: e, resourcePath: n }) => async (s) => ve({ archive: e, resourcePath: n })(s), xe = ({ archive: e, resourcePath: n }) => async (s) => {
73
73
  const r = Object.values(e.files).find(
74
74
  (t) => t.uri === n
75
75
  );
@@ -105,18 +105,18 @@ const g = {
105
105
  if (i) {
106
106
  const o = i.childrenNamed("li");
107
107
  o && o.length > 0 && (r.contents = o.map(
108
- (c) => q(c, { opfBasePath: n, baseUrl: s })
108
+ (d) => q(d, { opfBasePath: n, baseUrl: s })
109
109
  ));
110
110
  }
111
111
  return r;
112
- }, xe = (e, { opfBasePath: n, baseUrl: s }) => {
112
+ }, Fe = (e, { opfBasePath: n, baseUrl: s }) => {
113
113
  var a, i;
114
114
  const r = [];
115
115
  let t;
116
116
  return e.descendantWithPath("body.nav.ol") ? t = (a = e.descendantWithPath("body.nav.ol")) == null ? void 0 : a.children : e.descendantWithPath("body.section.nav.ol") && (t = (i = e.descendantWithPath("body.section.nav.ol")) == null ? void 0 : i.children), t && t.length > 0 && t.filter((o) => o.name === "li").forEach(
117
117
  (o) => r.push(q(o, { opfBasePath: n, baseUrl: s }))
118
118
  ), r;
119
- }, Fe = async (e, n, { opfBasePath: s, baseUrl: r }) => {
119
+ }, Ne = async (e, n, { opfBasePath: s, baseUrl: r }) => {
120
120
  var a;
121
121
  const t = (a = e.childNamed("manifest")) == null ? void 0 : a.childrenNamed("item").find((i) => i.attr.properties === "nav");
122
122
  if (t) {
@@ -125,7 +125,7 @@ const g = {
125
125
  );
126
126
  if (i) {
127
127
  const o = new y.XmlDocument(await i.string());
128
- return xe(o, { opfBasePath: s, baseUrl: r });
128
+ return Fe(o, { opfBasePath: s, baseUrl: r });
129
129
  }
130
130
  }
131
131
  }, Y = (e, {
@@ -133,9 +133,9 @@ const g = {
133
133
  baseUrl: s,
134
134
  prefix: r
135
135
  }) => {
136
- var o, c;
136
+ var o, d;
137
137
  const t = ((o = e == null ? void 0 : e.childNamed(`${r}content`)) == null ? void 0 : o.attr.src) || "", a = {
138
- title: ((c = e == null ? void 0 : e.descendantWithPath(`${r}navLabel.${r}text`)) == null ? void 0 : c.val) || "",
138
+ title: ((d = e == null ? void 0 : e.descendantWithPath(`${r}navLabel.${r}text`)) == null ? void 0 : d.val) || "",
139
139
  path: N(n, t),
140
140
  href: N(s, n, t),
141
141
  contents: []
@@ -143,14 +143,14 @@ const g = {
143
143
  return i && i.length > 0 && (a.contents = i.map(
144
144
  (l) => Y(l, { opfBasePath: n, baseUrl: s, prefix: r })
145
145
  )), a;
146
- }, Ne = (e, { opfBasePath: n, baseUrl: s }) => {
146
+ }, Te = (e, { opfBasePath: n, baseUrl: s }) => {
147
147
  var i;
148
148
  const r = [], t = e.name;
149
149
  let a = "";
150
150
  return t.indexOf(":") !== -1 && (a = t.split(":")[0] + ":"), (i = e.childNamed(`${a}navMap`)) == null || i.childrenNamed(`${a}navPoint`).forEach(
151
151
  (o) => r.push(Y(o, { opfBasePath: n, baseUrl: s, prefix: a }))
152
152
  ), r;
153
- }, Te = async ({
153
+ }, Se = async ({
154
154
  opfData: e,
155
155
  opfBasePath: n,
156
156
  baseUrl: s,
@@ -159,26 +159,26 @@ const g = {
159
159
  var i;
160
160
  const t = e.childNamed("spine"), a = t && t.attr.toc;
161
161
  if (a) {
162
- const o = (i = e.childNamed("manifest")) == null ? void 0 : i.childrenNamed("item").find((c) => c.attr.id === a);
162
+ const o = (i = e.childNamed("manifest")) == null ? void 0 : i.childrenNamed("item").find((d) => d.attr.id === a);
163
163
  if (o) {
164
- const c = `${n}${n === "" ? "" : "/"}${o.attr.href}`, l = Object.values(r.files).find(
165
- (d) => d.uri.endsWith(c)
164
+ const d = `${n}${n === "" ? "" : "/"}${o.attr.href}`, l = Object.values(r.files).find(
165
+ (c) => c.uri.endsWith(d)
166
166
  );
167
167
  if (l) {
168
- const d = new y.XmlDocument(await l.string());
169
- return Ne(d, { opfBasePath: n, baseUrl: s });
168
+ const c = new y.XmlDocument(await l.string());
169
+ return Te(c, { opfBasePath: n, baseUrl: s });
170
170
  }
171
171
  }
172
172
  }
173
- }, Se = async (e, n, { baseUrl: s }) => {
174
- const { basePath: r } = T(n) || {}, t = await Te({
173
+ }, ke = async (e, n, { baseUrl: s }) => {
174
+ const { basePath: r } = T(n) || {}, t = await Se({
175
175
  opfData: e,
176
176
  opfBasePath: r,
177
177
  archive: n,
178
178
  baseUrl: s
179
179
  });
180
- return t || await Fe(e, n, { opfBasePath: r, baseUrl: s });
181
- }, ke = async (e) => {
180
+ return t || await Ne(e, n, { opfBasePath: r, baseUrl: s });
181
+ }, Re = async (e) => {
182
182
  const n = {
183
183
  renditionLayout: void 0
184
184
  };
@@ -196,8 +196,8 @@ const g = {
196
196
  }) => {
197
197
  const { data: n, basePath: s } = T(e) || {}, r = await (n == null ? void 0 : n.string());
198
198
  if (!r) return [];
199
- const t = new y.XmlDocument(r), a = t.childNamed("manifest"), i = t.childNamed("spine"), o = i == null ? void 0 : i.childrenNamed("itemref").map((d) => d.attr.idref), c = (a == null ? void 0 : a.childrenNamed("item").filter((d) => o.includes(d.attr.id || ""))) || [];
200
- return e.files.filter((d) => c.find((u) => s ? `${s}/${u.attr.href}` === d.uri : `${u.attr.href}` === d.uri));
199
+ const t = new y.XmlDocument(r), a = t.childNamed("manifest"), i = t.childNamed("spine"), o = i == null ? void 0 : i.childrenNamed("itemref").map((c) => c.attr.idref), d = (a == null ? void 0 : a.childrenNamed("item").filter((c) => o.includes(c.attr.id || ""))) || [];
200
+ return e.files.filter((c) => d.find((u) => s ? `${s}/${u.attr.href}` === c.uri : `${u.attr.href}` === c.uri));
201
201
  }, Q = (e) => {
202
202
  var s;
203
203
  const n = e.childNamed("manifest");
@@ -206,14 +206,14 @@ const g = {
206
206
  id: r.attr.id || "",
207
207
  mediaType: r.attr["media-type"]
208
208
  }))) || [];
209
- }, Re = ({ archive: e, baseUrl: n }) => async (s) => {
209
+ }, We = ({ archive: e, baseUrl: n }) => async (s) => {
210
210
  var P;
211
- const { data: r, basePath: t } = T(e) || {}, a = await ke(e);
211
+ const { data: r, basePath: t } = T(e) || {}, a = await Re(e);
212
212
  if (!r)
213
213
  return s;
214
214
  const i = await r.string();
215
215
  g.log(i, a);
216
- const o = new y.XmlDocument(i), c = await Se(o, e, { baseUrl: n }) || [], l = o.childNamed("metadata"), d = o.childNamed("manifest"), u = o.childNamed("spine"), f = o.childNamed("guide"), w = l == null ? void 0 : l.childNamed("dc:title"), h = (l == null ? void 0 : l.childrenNamed("meta")) || [], S = h.find(
216
+ const o = new y.XmlDocument(i), d = await ke(o, e, { baseUrl: n }) || [], l = o.childNamed("metadata"), c = o.childNamed("manifest"), u = o.childNamed("spine"), f = o.childNamed("guide"), w = l == null ? void 0 : l.childNamed("dc:title"), h = (l == null ? void 0 : l.childrenNamed("meta")) || [], S = h.find(
217
217
  (p) => p.attr.property === "rendition:layout"
218
218
  ), k = h.find(
219
219
  (p) => p.attr.property === "rendition:flow"
@@ -226,7 +226,7 @@ const g = {
226
226
  return {
227
227
  filename: e.filename,
228
228
  nav: {
229
- toc: c
229
+ toc: d
230
230
  },
231
231
  renditionLayout: C || a.renditionLayout || "reflowable",
232
232
  renditionFlow: Z || "auto",
@@ -235,7 +235,7 @@ const g = {
235
235
  readingDirection: ne || "ltr",
236
236
  spineItems: (u == null ? void 0 : u.childrenNamed("itemref").map((p) => {
237
237
  var O, j, z;
238
- const m = d == null ? void 0 : d.childrenNamed("item").find((b) => b.attr.id === (p == null ? void 0 : p.attr.idref)), ae = (m == null ? void 0 : m.attr.href) || "", W = ((O = p == null ? void 0 : p.attr.properties) == null ? void 0 : O.split(" ")) || [], se = ((j = e.files.find((b) => b.uri.endsWith(ae))) == null ? void 0 : j.size) || 0, D = n ?? "";
238
+ const m = c == null ? void 0 : c.childrenNamed("item").find((b) => b.attr.id === (p == null ? void 0 : p.attr.idref)), ae = (m == null ? void 0 : m.attr.href) || "", W = ((O = p == null ? void 0 : p.attr.properties) == null ? void 0 : O.split(" ")) || [], se = ((j = e.files.find((b) => b.uri.endsWith(ae))) == null ? void 0 : j.size) || 0, D = n ?? "";
239
239
  return {
240
240
  id: (m == null ? void 0 : m.attr.id) || "",
241
241
  href: (z = m == null ? void 0 : m.attr.href) != null && z.startsWith("https://") ? m == null ? void 0 : m.attr.href : t ? `${D}${t}/${m == null ? void 0 : m.attr.href}` : `${D}${m == null ? void 0 : m.attr.href}`,
@@ -259,19 +259,19 @@ const g = {
259
259
  type: p.attr.type
260
260
  }))
261
261
  };
262
- }, We = async (e, n) => {
262
+ }, Ie = async (e, n) => {
263
263
  var t, a;
264
264
  const r = await ((t = T(e).data) == null ? void 0 : t.string());
265
265
  if (r) {
266
266
  const i = new y.XmlDocument(r);
267
267
  return {
268
- mediaType: (a = Q(i).find((c) => n.endsWith(c.href))) == null ? void 0 : a.mediaType
268
+ mediaType: (a = Q(i).find((d) => n.endsWith(d.href))) == null ? void 0 : a.mediaType
269
269
  };
270
270
  }
271
271
  return {
272
- mediaType: Ie(n)
272
+ mediaType: Le(n)
273
273
  };
274
- }, Ie = (e) => {
274
+ }, Le = (e) => {
275
275
  if (e.endsWith(".css"))
276
276
  return "text/css; charset=UTF-8";
277
277
  if (e.endsWith(".jpg"))
@@ -282,12 +282,12 @@ const g = {
282
282
  return "video/mp4";
283
283
  if (e.endsWith(".svg"))
284
284
  return "image/svg+xml";
285
- }, Le = ({ archive: e, resourcePath: n }) => async (s) => {
285
+ }, Ae = ({ archive: e, resourcePath: n }) => async (s) => {
286
286
  const r = Object.values(e.files).find(
287
287
  (a) => a.uri === n
288
288
  );
289
289
  if (!r) return s;
290
- const t = await We(e, n);
290
+ const t = await Ie(e, n);
291
291
  return {
292
292
  ...s,
293
293
  params: {
@@ -303,7 +303,7 @@ const g = {
303
303
  }
304
304
  }
305
305
  };
306
- }, Ae = async (e, n) => {
306
+ }, Ce = async (e, n) => {
307
307
  const s = Object.values(e.files).find(
308
308
  (a) => a.uri === n
309
309
  );
@@ -314,9 +314,9 @@ const g = {
314
314
  status: 200
315
315
  }
316
316
  }, t = [
317
- Le({ archive: e, resourcePath: n }),
318
- $e({ archive: e, resourcePath: n }),
319
- ve({ archive: e, resourcePath: n })
317
+ Ae({ archive: e, resourcePath: n }),
318
+ xe({ archive: e, resourcePath: n }),
319
+ $e({ archive: e, resourcePath: n })
320
320
  ];
321
321
  try {
322
322
  const a = await t.reduce(async (i, o) => await o(await i), Promise.resolve(r));
@@ -327,7 +327,7 @@ const g = {
327
327
  } catch (a) {
328
328
  throw g.error(a), a;
329
329
  }
330
- }, Je = (e) => ({
330
+ }, qe = (e) => ({
331
331
  body: `
332
332
  <!DOCTYPE html>
333
333
  <html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" xml:lang="en" lang="en">
@@ -345,7 +345,7 @@ const g = {
345
345
  "Content-Type": "text/html;charset=UTF-8"
346
346
  }
347
347
  }
348
- }), Ce = ({ archive: e, baseUrl: n }) => async () => {
348
+ }), Pe = ({ archive: e, baseUrl: n }) => async () => {
349
349
  var r;
350
350
  const s = Object.values(e.files).filter((t) => !t.dir);
351
351
  return {
@@ -371,7 +371,7 @@ const g = {
371
371
  href: `${n}${t.uri}`
372
372
  }))
373
373
  };
374
- }, Pe = ({ archive: e }) => async (n) => {
374
+ }, De = ({ archive: e }) => async (n) => {
375
375
  var a;
376
376
  const s = e.files.find(
377
377
  (i) => i.basename.toLowerCase() === "comicinfo.xml"
@@ -380,9 +380,9 @@ const g = {
380
380
  return n;
381
381
  const r = {
382
382
  ...n,
383
- spineItems: n.spineItems.filter((i) => !i.id.toLowerCase().endsWith("comicinfo.xml")).map((i, o, c) => ({
383
+ spineItems: n.spineItems.filter((i) => !i.id.toLowerCase().endsWith("comicinfo.xml")).map((i, o, d) => ({
384
384
  ...i,
385
- progressionWeight: 1 / c.length
385
+ progressionWeight: 1 / d.length
386
386
  }))
387
387
  }, t = await s.string();
388
388
  try {
@@ -395,22 +395,22 @@ const g = {
395
395
  return console.error(`Unable to parse comicinfo.xml for content
396
396
  `, t), console.error(i), r;
397
397
  }
398
- }, De = (e) => {
398
+ }, Oe = (e) => {
399
399
  var s;
400
400
  const n = (s = e.descendantWithPath("head")) == null ? void 0 : s.childrenNamed("meta").find((r) => r.attr.name === "viewport");
401
401
  return !!(n && n.attr.name === "viewport");
402
- }, Oe = (e) => e.reduce(async (n, s) => {
402
+ }, je = (e) => e.reduce(async (n, s) => {
403
403
  if (!await n || !oe({
404
404
  mimeType: s.encodingFormat,
405
405
  uri: s.uri
406
406
  }))
407
407
  return !1;
408
408
  const t = await s.string();
409
- return t ? De(new y.XmlDocument(t)) : !1;
410
- }, Promise.resolve(!0)), je = ({ archive: e }) => async (n) => {
409
+ return t ? Oe(new y.XmlDocument(t)) : !1;
410
+ }, Promise.resolve(!0)), ze = ({ archive: e }) => async (n) => {
411
411
  if (n.renditionLayout === "reflowable" && n.spineItems.every((r) => r.renditionLayout === "reflowable")) {
412
412
  const r = await K({ archive: e });
413
- if (await Oe(r))
413
+ if (await je(r))
414
414
  return {
415
415
  ...n,
416
416
  spineItems: n.spineItems.map((a) => ({
@@ -428,7 +428,7 @@ const g = {
428
428
  if (s[a] !== r[a])
429
429
  return (t = s[a]) != null && t.match(/\d/) ? +(s[a] || "") - +(r[a] || "") : (s[a] || "").localeCompare(r[a] || "");
430
430
  return 1;
431
- }, ze = ({ archive: e, baseUrl: n }) => async (s) => {
431
+ }, Me = ({ archive: e, baseUrl: n }) => async (s) => {
432
432
  if (s.nav) return s;
433
433
  const r = [...e.files].sort(
434
434
  (a, i) => A(a.uri, i.uri)
@@ -437,8 +437,8 @@ const g = {
437
437
  ).reduce(
438
438
  (a, i) => {
439
439
  const o = i.uri.split("/");
440
- return !i.dir && o.length > 1 && o.forEach((l, d) => {
441
- if (d === o.length - 1) return;
440
+ return !i.dir && o.length > 1 && o.forEach((l, c) => {
441
+ if (c === o.length - 1) return;
442
442
  a.find(({ title: w }) => w === l) || a.push({
443
443
  contents: [],
444
444
  href: N(n, encodeURI(i.uri)).replace(/\/$/, ""),
@@ -455,7 +455,7 @@ const g = {
455
455
  toc: t
456
456
  }
457
457
  };
458
- }, Me = {
458
+ }, Ue = {
459
459
  filename: "",
460
460
  items: [],
461
461
  nav: {
@@ -466,21 +466,21 @@ const g = {
466
466
  renditionSpread: "auto",
467
467
  spineItems: [],
468
468
  title: ""
469
- }, Ue = async (e, { baseUrl: n = "" } = {}) => {
469
+ }, Ve = async (e, { baseUrl: n = "" } = {}) => {
470
470
  const s = [
471
- Ce({ archive: e, baseUrl: n }),
472
- Re({ archive: e, baseUrl: n }),
473
- je({ archive: e, baseUrl: n }),
474
471
  Pe({ archive: e, baseUrl: n }),
475
- ze({ archive: e, baseUrl: n })
472
+ We({ archive: e, baseUrl: n }),
473
+ ze({ archive: e, baseUrl: n }),
474
+ De({ archive: e, baseUrl: n }),
475
+ Me({ archive: e, baseUrl: n })
476
476
  ];
477
477
  try {
478
- const r = await s.reduce(async (t, a) => await a(await t), Promise.resolve(Me));
478
+ const r = await s.reduce(async (t, a) => await a(await t), Promise.resolve(Ue));
479
479
  return g.log("Generated manifest", r), r;
480
480
  } catch (r) {
481
481
  throw g.error(r), r;
482
482
  }
483
- }, $ = (e) => e.substring(e.lastIndexOf("/") + 1) || e, J = (e) => e.endsWith("/") ? e.slice(0, -1) : e, qe = async (e, n) => {
483
+ }, $ = (e) => e.substring(e.lastIndexOf("/") + 1) || e, J = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Ye = async (e, n) => {
484
484
  const s = `
485
485
  <?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
486
486
  <metadata>
@@ -521,13 +521,13 @@ const g = {
521
521
  }, ...r],
522
522
  close: () => Promise.resolve()
523
523
  };
524
- }, Ve = async (e) => new Promise((n) => {
524
+ }, Xe = async (e) => new Promise((n) => {
525
525
  const s = new FileReader();
526
526
  s.readAsDataURL(e), s.onloadend = function() {
527
527
  const r = s.result;
528
528
  n(r);
529
529
  };
530
- }), Ye = async (e, {
530
+ }), Ke = async (e, {
531
531
  mimeType: n,
532
532
  direction: s
533
533
  } = { mimeType: "text/plain" }) => {
@@ -565,14 +565,14 @@ const g = {
565
565
  uri: "p01.txt",
566
566
  blob: async () => typeof e == "string" ? new Blob([e]) : e,
567
567
  string: async () => typeof e == "string" ? e : e.text(),
568
- base64: async () => typeof e == "string" ? btoa(e) : Ve(e),
568
+ base64: async () => typeof e == "string" ? btoa(e) : Xe(e),
569
569
  size: typeof e == "string" ? e.length : e.size,
570
570
  encodingFormat: n
571
571
  }
572
572
  ],
573
573
  close: () => Promise.resolve()
574
574
  };
575
- }, Ke = async (e, { orderByAlpha: n, name: s } = {}) => {
575
+ }, Qe = async (e, { orderByAlpha: n, name: s } = {}) => {
576
576
  let r = Object.values(e.files);
577
577
  n && (r = r.slice().sort((a, i) => A(a.name, i.name)));
578
578
  const t = {
@@ -595,7 +595,7 @@ const g = {
595
595
  close: () => Promise.resolve()
596
596
  };
597
597
  return g.log("Generated archive", t), t;
598
- }, Qe = async (e, { name: n } = {}) => {
598
+ }, Ze = async (e, { name: n } = {}) => {
599
599
  const s = await e.getFilesArray(), r = {
600
600
  close: () => e.close(),
601
601
  filename: n ?? "",
@@ -610,7 +610,7 @@ const g = {
610
610
  }))
611
611
  };
612
612
  return g.log("Generated archive", r), r;
613
- }, Ze = async (e, { orderByAlpha: n, name: s } = {}) => {
613
+ }, et = async (e, { orderByAlpha: n, name: s } = {}) => {
614
614
  let r = e;
615
615
  return n && (r = r.slice().sort((t, a) => A(t.name, a.name))), {
616
616
  filename: s || "",
@@ -631,99 +631,102 @@ const g = {
631
631
  })),
632
632
  close: () => Promise.resolve()
633
633
  };
634
- }, et = ({
634
+ }, tt = ({
635
635
  enableReport: e
636
636
  } = {}) => {
637
637
  g.enable(!!e);
638
- }, Xe = ({
638
+ }, Be = ({
639
639
  getArchive: e,
640
640
  cleanArchiveAfter: n
641
641
  }) => {
642
642
  const s = new U(), r = new U(), t = {}, a = s.pipe(
643
- I((c) => {
644
- const l = t[c];
643
+ I((d) => {
644
+ const l = t[d];
645
645
  return !l || l.getValue().status !== "idle" ? de : (l.next({
646
646
  ...l.getValue(),
647
647
  status: "loading"
648
- }), L(e(c)).pipe(
649
- v((d) => (l.next({
648
+ }), L(e(d)).pipe(
649
+ v((c) => (l.next({
650
650
  ...l.getValue(),
651
- archive: d,
651
+ archive: c,
652
652
  status: "success"
653
- }), { key: c, archiveEntry: l })),
654
- F((d) => {
653
+ }), { key: d, archiveEntry: l })),
654
+ F((c) => {
655
655
  throw l.next({
656
656
  ...l.getValue(),
657
657
  status: "error",
658
- error: d
659
- }), d;
658
+ error: c
659
+ }), c;
660
660
  })
661
661
  ));
662
662
  }),
663
- F((c) => (console.error(c), V)),
663
+ F(() => V),
664
664
  le()
665
665
  ), i = a.pipe(
666
- X(({ archiveEntry: c, key: l }) => c.pipe(v(({ locks: f }) => f)).pipe(v((f) => f <= 0)).pipe(
666
+ X(({ archiveEntry: d, key: l }) => d.pipe(v(({ locks: f }) => f)).pipe(
667
+ v((f) => f <= 0),
668
+ me()
669
+ ).pipe(
667
670
  X(
668
- (f) => f ? me(n) : V
671
+ (f) => f ? pe(n) : V
669
672
  ),
670
673
  B(() => {
671
674
  var f;
672
- delete t[l], (f = c.getValue().archive) == null || f.close();
675
+ delete t[l], (f = d.getValue().archive) == null || f.close();
673
676
  })
674
677
  ))
675
- ), o = (c) => {
678
+ ), o = (d) => {
676
679
  let l = !1;
677
- const d = t[c] ?? new fe({
680
+ const c = t[d] ?? new ue({
678
681
  archive: void 0,
679
682
  status: "idle",
680
683
  locks: 0,
681
684
  error: void 0
682
685
  });
683
- t[c] = d, d.next({
684
- ...d.getValue(),
685
- locks: d.getValue().locks + 1
686
+ t[d] = c, c.next({
687
+ ...c.getValue(),
688
+ locks: c.getValue().locks + 1
686
689
  });
687
690
  const u = () => {
688
- l || (l = !0, d.next({
689
- ...d.getValue(),
690
- locks: d.getValue().locks - 1
691
+ l || (l = !0, c.next({
692
+ ...c.getValue(),
693
+ locks: c.getValue().locks - 1
691
694
  }));
692
695
  };
693
- s.next(c);
694
- const f = d.pipe(
696
+ s.next(d);
697
+ const f = c.pipe(
695
698
  v(({ archive: h }) => h),
696
- ue((h) => !!h)
697
- ), w = d.pipe(
699
+ he((h) => !!h)
700
+ ), w = c.pipe(
698
701
  B(({ error: h }) => {
699
702
  if (h)
700
703
  throw h;
701
704
  }),
702
- he()
705
+ ge()
703
706
  );
704
707
  return _(f, w).pipe(
705
- ge(),
708
+ be(),
706
709
  v((h) => ({ archive: h, release: u })),
707
710
  F((h) => {
708
711
  throw u(), h;
709
712
  })
710
713
  );
711
714
  };
712
- return _(i, a).pipe(pe(r)).subscribe(), {
715
+ return _(i, a).pipe(fe(r)).subscribe(), {
713
716
  access: o
714
717
  };
715
718
  };
716
- class Be {
719
+ class _e {
717
720
  constructor({
718
721
  onError: n,
719
722
  ...s
720
723
  }) {
721
- this.onError = (r) => new Response(String(r), { status: 500 }), this.epubLoader = Xe(s), this.onError = n ?? this.onError;
724
+ this.onError = (r) => new Response(String(r), { status: 500 }), this.epubLoader = Be(s), this.onError = n ?? this.onError;
722
725
  }
723
726
  fetchManifest({ key: n, baseUrl: s }) {
724
727
  const r = this.epubLoader.access(n).pipe(
725
728
  I(({ archive: t, release: a }) => L(
726
- Ue(t, { baseUrl: s })
729
+ Ve(t, { baseUrl: s })
727
730
  ).pipe(
728
731
  v(
729
732
  (o) => new Response(JSON.stringify(o), {
@@ -744,7 +747,7 @@ class Be {
744
747
  }) {
745
748
  const r = this.epubLoader.access(n).pipe(
746
749
  I(({ archive: t, release: a }) => L(
747
- Ae(t, s)
750
+ Ce(t, s)
748
751
  ).pipe(
749
752
  v((o) => new Response(o.body, { status: 200 })),
750
753
  H(() => {
@@ -756,7 +759,7 @@ class Be {
756
759
  return G(r);
757
760
  }
758
761
  }
759
- class tt extends Be {
762
+ class nt extends _e {
760
763
  constructor({
761
764
  getUriInfo: n,
762
765
  ...s
@@ -781,17 +784,17 @@ class tt extends Be {
781
784
  }
782
785
  }
783
786
  export {
784
- tt as ServiceWorkerStreamer,
785
- Be as Streamer,
786
- et as configure,
787
- Ze as createArchiveFromArrayBufferList,
788
- Ke as createArchiveFromJszip,
789
- Qe as createArchiveFromLibArchive,
790
- Ye as createArchiveFromText,
791
- qe as createArchiveFromUrls,
792
- Ue as generateManifestFromArchive,
793
- Ae as generateResourceFromArchive,
794
- Je as generateResourceFromError,
787
+ nt as ServiceWorkerStreamer,
788
+ _e as Streamer,
789
+ tt as configure,
790
+ et as createArchiveFromArrayBufferList,
791
+ Qe as createArchiveFromJszip,
792
+ Ze as createArchiveFromLibArchive,
793
+ Ke as createArchiveFromText,
794
+ Ye as createArchiveFromUrls,
795
+ Ve as generateManifestFromArchive,
796
+ Ce as generateResourceFromArchive,
797
+ qe as generateResourceFromError,
795
798
  T as getArchiveOpfInfo
796
799
  };
797
800
  //# sourceMappingURL=index.js.map