@prose-reader/streamer 1.208.0 → 1.209.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.
@@ -29,6 +29,6 @@ export declare const createArchiveLoader: ({ getArchive, cleanArchiveAfter, }: {
29
29
  release: () => void;
30
30
  }>;
31
31
  purge: () => void;
32
- archives: Record<string, ArchiveEntry>;
32
+ _archives: Record<string, ArchiveEntry>;
33
33
  };
34
34
  export {};
package/dist/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import $, { XmlDocument as de, XmlTextNode as le, XmlElement as pe } from "xmldoc";
2
- import { urlJoin as W, isXmlBasedMimeType as fe, parseContentType as ue, detectMimeTypeFromName as O } from "@prose-reader/shared";
3
- import { Subject as R, mergeMap as M, EMPTY as _, pairwise as me, filter as D, startWith as he, from as P, tap as j, catchError as C, switchMap as L, merge as q, takeUntil as ge, map as F, 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 v, { XmlDocument as le, XmlTextNode as pe, XmlElement as fe } from "xmldoc";
2
+ import { urlJoin as N, isXmlBasedMimeType as ue, parseContentType as me, detectMimeTypeFromName as O } from "@prose-reader/shared";
3
+ import { Subject as R, mergeMap as M, EMPTY as _, pairwise as he, filter as D, startWith as ge, from as C, tap as j, catchError as P, switchMap as W, merge as q, first as G, takeUntil as ye, map as F, ignoreElements as be, BehaviorSubject as we, distinctUntilChanged as ve, shareReplay as $e, NEVER as K, timer as xe, finalize as J, of as Y, lastValueFrom as Q } from "rxjs";
4
4
  let S = !1;
5
- const v = {
5
+ const w = {
6
6
  enable: (e) => {
7
7
  S = e;
8
8
  },
@@ -36,7 +36,7 @@ const v = {
36
36
  (n) => n.uri === t
37
37
  );
38
38
  if (r != null && r.basename.endsWith(".xhtml")) {
39
- const n = i.body ?? await r.string(), s = new de(n);
39
+ const n = i.body ?? await r.string(), s = new le(n);
40
40
  if (Fe(s)) {
41
41
  const o = Ae(s);
42
42
  return o && delete o.attr.preserveAspectRatio, {
@@ -61,10 +61,10 @@ const v = {
61
61
  };
62
62
  }
63
63
  return i;
64
- }, ee = (e) => e ? e.children.map((t) => t instanceof le ? t.text : t instanceof pe ? ee(t) : "").join("").trim() : "", A = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Q = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Ne = (e) => {
64
+ }, te = (e) => e ? e.children.map((t) => t instanceof pe ? t.text : t instanceof fe ? te(t) : "").join("").trim() : "", A = (e) => e.substring(e.lastIndexOf("/") + 1) || e, Z = (e) => e.endsWith("/") ? e.slice(0, -1) : e, Ne = (e) => {
65
65
  const t = e.lastIndexOf("/");
66
66
  return t >= 0 ? e.substring(0, t) : "";
67
- }, te = (e, { basePath: t, baseUrl: i }) => {
67
+ }, ne = (e, { basePath: t, baseUrl: i }) => {
68
68
  const r = {
69
69
  contents: [],
70
70
  path: "",
@@ -72,14 +72,14 @@ const v = {
72
72
  title: ""
73
73
  };
74
74
  let n = e.childNamed("span") || e.childNamed("a");
75
- r.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || ee(n)) ?? "";
75
+ r.title = ((n == null ? void 0 : n.attr.title) || (n == null ? void 0 : n.val.trim()) || te(n)) ?? "";
76
76
  let s = n == null ? void 0 : n.name;
77
- s !== "a" && (n = e.descendantWithPath(`${s}.a`), n && (s = n.name.toLowerCase())), s === "a" && (n != null && n.attr.href) && (r.path = W(t, n.attr.href), r.href = W(i, t, n.attr.href));
77
+ 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));
78
78
  const o = e.childNamed("ol");
79
79
  if (o) {
80
80
  const a = o.childrenNamed("li");
81
81
  a && a.length > 0 && (r.contents = a.map(
82
- (d) => te(d, { basePath: t, baseUrl: i })
82
+ (d) => ne(d, { basePath: t, baseUrl: i })
83
83
  ));
84
84
  }
85
85
  return r;
@@ -88,7 +88,7 @@ const v = {
88
88
  const r = [];
89
89
  let n;
90
90
  return e.descendantWithPath("body.nav.ol") ? n = (s = e.descendantWithPath("body.nav.ol")) == null ? void 0 : s.children : e.descendantWithPath("body.section.nav.ol") && (n = (o = e.descendantWithPath("body.section.nav.ol")) == null ? void 0 : o.children), n && n.length > 0 && n.filter((a) => a.name === "li").forEach(
91
- (a) => r.push(te(a, { basePath: t, baseUrl: i }))
91
+ (a) => r.push(ne(a, { basePath: t, baseUrl: i }))
92
92
  ), r;
93
93
  }, Se = async (e, t, { baseUrl: i }) => {
94
94
  var n;
@@ -98,11 +98,11 @@ const v = {
98
98
  (o) => o.uri.endsWith(r.attr.href || "")
99
99
  );
100
100
  if (s) {
101
- const o = new $.XmlDocument(await s.string()), a = Ne(s.uri);
101
+ const o = new v.XmlDocument(await s.string()), a = Ne(s.uri);
102
102
  return ke(o, { basePath: a, baseUrl: i });
103
103
  }
104
104
  }
105
- }, ne = (e, {
105
+ }, re = (e, {
106
106
  opfBasePath: t,
107
107
  baseUrl: i,
108
108
  prefix: r
@@ -110,21 +110,21 @@ const v = {
110
110
  var a, d;
111
111
  const n = ((a = e == null ? void 0 : e.childNamed(`${r}content`)) == null ? void 0 : a.attr.src) || "", s = {
112
112
  title: ((d = e == null ? void 0 : e.descendantWithPath(`${r}navLabel.${r}text`)) == null ? void 0 : d.val) || "",
113
- path: W(t, n),
114
- href: W(i, t, n),
113
+ path: N(t, n),
114
+ href: N(i, t, n),
115
115
  contents: []
116
116
  }, o = e.childrenNamed(`${r}navPoint`);
117
117
  return o && o.length > 0 && (s.contents = o.map(
118
- (l) => ne(l, { opfBasePath: t, baseUrl: i, prefix: r })
118
+ (l) => re(l, { opfBasePath: t, baseUrl: i, prefix: r })
119
119
  )), s;
120
- }, Pe = (e, { opfBasePath: t, baseUrl: i }) => {
120
+ }, Ce = (e, { opfBasePath: t, baseUrl: i }) => {
121
121
  var o;
122
122
  const r = [], n = e.name;
123
123
  let s = "";
124
124
  return n.indexOf(":") !== -1 && (s = `${n.split(":")[0]}:`), (o = e.childNamed(`${s}navMap`)) == null || o.childrenNamed(`${s}navPoint`).forEach(
125
- (a) => r.push(ne(a, { opfBasePath: t, baseUrl: i, prefix: s }))
125
+ (a) => r.push(re(a, { opfBasePath: t, baseUrl: i, prefix: s }))
126
126
  ), r;
127
- }, Ce = async ({
127
+ }, Pe = async ({
128
128
  opfData: e,
129
129
  opfBasePath: t,
130
130
  baseUrl: i,
@@ -139,13 +139,13 @@ const v = {
139
139
  (c) => c.uri.endsWith(d)
140
140
  );
141
141
  if (l) {
142
- const c = new $.XmlDocument(await l.string());
143
- return Pe(c, { opfBasePath: t, baseUrl: i });
142
+ const c = new v.XmlDocument(await l.string());
143
+ return Ce(c, { opfBasePath: t, baseUrl: i });
144
144
  }
145
145
  }
146
146
  }
147
147
  }, Ie = async (e, t, { baseUrl: i }) => {
148
- const { basePath: r } = N(t) || {}, n = await Ce({
148
+ const { basePath: r } = k(t) || {}, n = await Pe({
149
149
  opfData: e,
150
150
  opfBasePath: r,
151
151
  archive: t,
@@ -163,18 +163,18 @@ const v = {
163
163
  pageSpreadLeft: t.some((n) => n === "page-spread-left") || void 0,
164
164
  pageSpreadRight: t.some((n) => n === "page-spread-right") || void 0
165
165
  };
166
- }, N = (e) => {
166
+ }, k = (e) => {
167
167
  const i = Object.values(e.files).filter((r) => !r.dir).find((r) => r.uri.endsWith(".opf"));
168
168
  return {
169
169
  data: i,
170
170
  basePath: (i == null ? void 0 : i.uri.substring(0, i.uri.lastIndexOf("/"))) || ""
171
171
  };
172
- }, re = async ({
172
+ }, se = async ({
173
173
  archive: e
174
174
  }) => {
175
- const { data: t, basePath: i } = N(e) || {}, r = await (t == null ? void 0 : t.string());
175
+ const { data: t, basePath: i } = k(e) || {}, r = await (t == null ? void 0 : t.string());
176
176
  if (!r) return [];
177
- const n = new $.XmlDocument(r), s = n.childNamed("manifest"), o = n.childNamed("spine"), a = o == null ? void 0 : o.childrenNamed("itemref").map((c) => c.attr.idref), d = (s == null ? void 0 : s.childrenNamed("item").filter((c) => a.includes(c.attr.id || ""))) || [];
177
+ const n = new v.XmlDocument(r), s = n.childNamed("manifest"), o = n.childNamed("spine"), a = o == null ? void 0 : o.childrenNamed("itemref").map((c) => c.attr.idref), d = (s == null ? void 0 : s.childrenNamed("item").filter((c) => a.includes(c.attr.id || ""))) || [];
178
178
  return e.files.filter((c) => d.find((p) => i ? `${i}/${p.attr.href}` === c.uri : `${p.attr.href}` === c.uri));
179
179
  }, De = (e, t, i) => {
180
180
  const r = e.attr.href || "", n = i == null ? void 0 : i(e);
@@ -183,25 +183,25 @@ const v = {
183
183
  id: e.attr.id || "",
184
184
  mediaType: e.attr["media-type"]
185
185
  };
186
- }, se = (e, t, i) => {
186
+ }, ie = (e, t, i) => {
187
187
  var s;
188
- const r = e.childNamed("manifest"), { basePath: n } = N(t) || {};
188
+ const r = e.childNamed("manifest"), { basePath: n } = k(t) || {};
189
189
  return ((s = r == null ? void 0 : r.childrenNamed("item")) == null ? void 0 : s.map((o) => De(o, n, i))) || [];
190
190
  }, je = ({ archive: e, baseUrl: t }) => async (i) => {
191
191
  var X;
192
- const { data: r, basePath: n } = N(e) || {};
192
+ const { data: r, basePath: n } = k(e) || {};
193
193
  if (!r)
194
194
  return i;
195
195
  const s = await r.string();
196
- v.log("data", s);
197
- const o = new $.XmlDocument(s), a = await Ie(o, e, { baseUrl: t }) || [], d = o.childNamed("metadata"), l = o.childNamed("manifest"), c = o.childNamed("spine"), p = o.childNamed("guide"), u = d == null ? void 0 : d.childNamed("dc:title"), g = (d == null ? void 0 : d.childrenNamed("meta")) || [], b = g.find(
196
+ w.log("data", s);
197
+ const o = new v.XmlDocument(s), a = await Ie(o, e, { baseUrl: t }) || [], d = o.childNamed("metadata"), l = o.childNamed("manifest"), c = o.childNamed("spine"), p = o.childNamed("guide"), u = d == null ? void 0 : d.childNamed("dc:title"), g = (d == null ? void 0 : d.childrenNamed("meta")) || [], b = g.find(
198
198
  (m) => m.attr.property === "rendition:layout"
199
199
  ), h = g.find(
200
200
  (m) => m.attr.property === "rendition:flow"
201
- ), x = g.find(
201
+ ), $ = g.find(
202
202
  (m) => m.attr.property === "rendition:spread"
203
- ), y = b == null ? void 0 : b.val, w = h == null ? void 0 : h.val, k = x == null ? void 0 : x.val, ie = (u == null ? void 0 : u.val) || ((X = e.files.find(({ dir: m }) => m)) == null ? void 0 : X.basename) || "", oe = c == null ? void 0 : c.attr["page-progression-direction"], ae = (await re({ archive: e })).reduce(
204
- (m, T) => T.size + m,
203
+ ), y = b == null ? void 0 : b.val, x = h == null ? void 0 : h.val, T = $ == null ? void 0 : $.val, oe = (u == null ? void 0 : u.val) || ((X = e.files.find(({ dir: m }) => m)) == null ? void 0 : X.basename) || "", ae = c == null ? void 0 : c.attr["page-progression-direction"], ce = (await se({ archive: e })).reduce(
204
+ (m, L) => L.size + m,
205
205
  0
206
206
  );
207
207
  return {
@@ -210,30 +210,30 @@ const v = {
210
210
  toc: a
211
211
  },
212
212
  renditionLayout: y,
213
- renditionFlow: w || "auto",
214
- renditionSpread: k,
215
- title: ie,
216
- readingDirection: oe || "ltr",
213
+ renditionFlow: x || "auto",
214
+ renditionSpread: T,
215
+ title: oe,
216
+ readingDirection: ae || "ltr",
217
217
  /**
218
218
  * @see https://www.w3.org/TR/epub/#sec-itemref-elem
219
219
  */
220
- spineItems: (c == null ? void 0 : c.childrenNamed("itemref").map((m, T) => {
220
+ spineItems: (c == null ? void 0 : c.childrenNamed("itemref").map((m, L) => {
221
221
  var H, V;
222
- const f = l == null ? void 0 : l.childrenNamed("item").find((I) => I.attr.id === (m == null ? void 0 : m.attr.idref)), U = (f == null ? void 0 : f.attr.href) || "", ce = ((H = e.files.find((I) => I.uri.endsWith(U))) == null ? void 0 : H.size) || 0, B = t || (/^https?:\/\//.test(U) ? "" : "file://"), E = Re(m);
222
+ const f = l == null ? void 0 : l.childrenNamed("item").find((I) => I.attr.id === (m == null ? void 0 : m.attr.idref)), U = (f == null ? void 0 : f.attr.href) || "", de = ((H = e.files.find((I) => I.uri.endsWith(U))) == null ? void 0 : H.size) || 0, B = t || (/^https?:\/\//.test(U) ? "" : "file://"), E = Re(m);
223
223
  return {
224
224
  ...E,
225
225
  id: (f == null ? void 0 : f.attr.id) || "",
226
- index: T,
226
+ index: L,
227
227
  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}`,
228
228
  renditionLayout: E.renditionLayout ?? y,
229
- progressionWeight: ce / ae,
229
+ progressionWeight: de / ce,
230
230
  // size: itemSize
231
231
  mediaType: f == null ? void 0 : f.attr["media-type"]
232
232
  };
233
233
  })) || [],
234
- items: se(o, e, (m) => {
235
- const T = m.attr.href || "";
236
- return /^https?:\/\//.test(T) ? "" : t || "file://";
234
+ items: ie(o, e, (m) => {
235
+ const L = m.attr.href || "";
236
+ return /^https?:\/\//.test(L) ? "" : t || "file://";
237
237
  }),
238
238
  guide: p == null ? void 0 : p.childrenNamed("reference").map((m) => ({
239
239
  href: m.attr.href || "",
@@ -243,9 +243,9 @@ const v = {
243
243
  };
244
244
  }, Oe = async (e, t) => {
245
245
  var n, s, o;
246
- const r = await ((n = N(e).data) == null ? void 0 : n.string());
246
+ const r = await ((n = k(e).data) == null ? void 0 : n.string());
247
247
  if (r) {
248
- const a = new $.XmlDocument(r), d = se(a, e, () => "");
248
+ const a = new v.XmlDocument(r), d = ie(a, e, () => "");
249
249
  if ((s = d.find(
250
250
  (c) => t.endsWith(c.href)
251
251
  )) == null ? void 0 : s.mediaType)
@@ -285,7 +285,7 @@ const v = {
285
285
  }
286
286
  }
287
287
  };
288
- }, Z = [
288
+ }, ee = [
289
289
  "div",
290
290
  "span",
291
291
  "p",
@@ -343,12 +343,12 @@ const v = {
343
343
  if (r != null && r.basename.endsWith(".xhtml")) {
344
344
  const n = i.body ?? await r.string();
345
345
  if (!new RegExp(
346
- `<(${Z.join("|")})[\\s/>]`,
346
+ `<(${ee.join("|")})[\\s/>]`,
347
347
  "i"
348
348
  ).test(n))
349
349
  return i;
350
350
  const o = new RegExp(
351
- `<(${Z.join("|")})(\\s[^>]*)?\\s*/>`,
351
+ `<(${ee.join("|")})(\\s[^>]*)?\\s*/>`,
352
352
  "gi"
353
353
  ), a = n.replace(
354
354
  o,
@@ -376,12 +376,12 @@ const v = {
376
376
  ];
377
377
  try {
378
378
  const s = await n.reduce(async (o, a) => await a(await o), Promise.resolve(r));
379
- return v.log("Generated resource", t, s), {
379
+ return w.log("Generated resource", t, s), {
380
380
  ...s,
381
381
  body: s.body ?? await i.blob()
382
382
  };
383
383
  } catch (s) {
384
- throw v.error(s), s;
384
+ throw w.error(s), s;
385
385
  }
386
386
  }, Be = ({ archive: e, baseUrl: t }) => async () => {
387
387
  var r;
@@ -421,7 +421,7 @@ const v = {
421
421
  e.files.map(async (i) => {
422
422
  var r, n;
423
423
  if (i.uri.endsWith("com.kobobooks.display-options.xml")) {
424
- const o = (r = new $.XmlDocument(await i.string()).childNamed("platform")) == null ? void 0 : r.childNamed("option");
424
+ const o = (r = new v.XmlDocument(await i.string()).childNamed("platform")) == null ? void 0 : r.childNamed("option");
425
425
  ((n = o == null ? void 0 : o.attr) == null ? void 0 : n.name) === "fixed-layout" && o.val === "true" && (t.renditionLayout = "pre-paginated");
426
426
  }
427
427
  })
@@ -437,16 +437,16 @@ const v = {
437
437
  const t = (i = e.descendantWithPath("head")) == null ? void 0 : i.childrenNamed("meta").find((r) => r.attr.name === "viewport");
438
438
  return !!(t && t.attr.name === "viewport");
439
439
  }, _e = (e) => e.reduce(async (t, i) => {
440
- if (!await t || !fe({
440
+ if (!await t || !ue({
441
441
  mimeType: i.encodingFormat,
442
442
  uri: i.uri
443
443
  }))
444
444
  return !1;
445
445
  const n = await i.string();
446
- return n ? Ve(new $.XmlDocument(n)) : !1;
446
+ return n ? Ve(new v.XmlDocument(n)) : !1;
447
447
  }, Promise.resolve(!0)), qe = ({ archive: e }) => async (t) => {
448
448
  if (t.renditionLayout === "reflowable" && t.spineItems.every((r) => r.renditionLayout === "reflowable")) {
449
- const r = await re({ archive: e });
449
+ const r = await se({ archive: e });
450
450
  if (await _e(r))
451
451
  return {
452
452
  ...t,
@@ -472,7 +472,7 @@ const v = {
472
472
  ), n = Object.values(r), s = (a, d, l, c, p) => {
473
473
  const u = a.find((h) => h.title === d), [g, ...b] = l;
474
474
  return u ? g ? [
475
- ...a.filter((x) => x !== u),
475
+ ...a.filter(($) => $ !== u),
476
476
  {
477
477
  ...u,
478
478
  contents: [
@@ -487,7 +487,7 @@ const v = {
487
487
  ]
488
488
  }
489
489
  ] : u.path.split("/").length > p.split("/").length ? [
490
- ...a.filter((x) => x !== u),
490
+ ...a.filter(($) => $ !== u),
491
491
  {
492
492
  ...u,
493
493
  path: p,
@@ -521,7 +521,7 @@ const v = {
521
521
  if (d.dir) return a;
522
522
  const c = d.uri.split("/").slice(0, -1), [p, ...u] = c;
523
523
  if (p) {
524
- const g = W(t, encodeURI(d.uri)).replace(/\/$/, ""), b = d.uri.replace(/\/$/, "");
524
+ const g = N(t, encodeURI(d.uri)).replace(/\/$/, ""), b = d.uri.replace(/\/$/, "");
525
525
  return s(a, p, u, g, b);
526
526
  }
527
527
  return a;
@@ -549,7 +549,7 @@ const v = {
549
549
  }))
550
550
  }, n = await i.string();
551
551
  try {
552
- const a = ((s = new $.XmlDocument(n).childNamed("Manga")) == null ? void 0 : s.val) || "unknown";
552
+ const a = ((s = new v.XmlDocument(n).childNamed("Manga")) == null ? void 0 : s.val) || "unknown";
553
553
  return {
554
554
  ...r,
555
555
  readingDirection: a === "YesAndRightToLeft" ? "rtl" : "ltr"
@@ -563,7 +563,7 @@ const v = {
563
563
  spineItems: t.spineItems.map((r) => {
564
564
  const n = e.files.find(
565
565
  (o) => decodeURI(r.href).endsWith(o.uri)
566
- ), s = ue((n == null ? void 0 : n.encodingFormat) ?? "") ?? O((n == null ? void 0 : n.basename) ?? "");
566
+ ), s = me((n == null ? void 0 : n.encodingFormat) ?? "") ?? O((n == null ? void 0 : n.basename) ?? "");
567
567
  return {
568
568
  ...r,
569
569
  renditionLayout: s != null && s.startsWith("image/") ? "pre-paginated" : r.renditionLayout
@@ -578,7 +578,7 @@ const v = {
578
578
  return t;
579
579
  const r = await (await i.blob()).text();
580
580
  try {
581
- const a = new $.XmlDocument(r).childNamed("platform"), d = ((s = (n = a == null ? void 0 : a.childrenNamed("option")) == null ? void 0 : n.find((l) => l.attr.name === "fixed-layout")) == null ? void 0 : s.val) || "false";
581
+ const a = new v.XmlDocument(r).childNamed("platform"), d = ((s = (n = a == null ? void 0 : a.childrenNamed("option")) == null ? void 0 : n.find((l) => l.attr.name === "fixed-layout")) == null ? void 0 : s.val) || "false";
582
582
  return {
583
583
  ...t,
584
584
  renditionLayout: d === "true" ? "pre-paginated" : t.renditionLayout
@@ -602,9 +602,9 @@ const v = {
602
602
  ];
603
603
  try {
604
604
  const r = Be({ archive: e, baseUrl: t })(), n = await i.reduce(async (s, o) => await o(await s), r);
605
- return v.log("Generated manifest", n), n;
605
+ return w.log("Generated manifest", n), n;
606
606
  } catch (r) {
607
- throw v.error(r), r;
607
+ throw w.error(r), r;
608
608
  }
609
609
  }, at = async (e, t) => {
610
610
  const i = `
@@ -708,7 +708,7 @@ const v = {
708
708
  })),
709
709
  close: () => Promise.resolve()
710
710
  };
711
- return v.log("Generated archive", n), n;
711
+ return w.log("Generated archive", n), n;
712
712
  }, lt = async (e, { name: t } = {}) => {
713
713
  const i = await e.getFilesArray(), r = {
714
714
  close: () => e.close(),
@@ -722,7 +722,7 @@ const v = {
722
722
  string: async () => (await n.file.extract()).text()
723
723
  }))
724
724
  };
725
- return v.log("Generated archive", r), r;
725
+ return w.log("Generated archive", r), r;
726
726
  }, pt = async (e, { orderByAlpha: t, name: i } = {}) => {
727
727
  let r = e;
728
728
  return t && (r = r.slice().sort((n, s) => z(n.name, s.name))), {
@@ -746,7 +746,7 @@ const v = {
746
746
  }, ft = ({
747
747
  enableReport: e
748
748
  } = {}) => {
749
- v.enable(!!e);
749
+ w.enable(!!e);
750
750
  };
751
751
  class et {
752
752
  constructor(t) {
@@ -773,8 +773,8 @@ class et {
773
773
  }
774
774
  get overTTL$() {
775
775
  return this.isUnlocked$.pipe(
776
- L(
777
- (t) => t ? this.cleanArchiveAfter === 1 / 0 ? G : xe(this.cleanArchiveAfter) : G
776
+ W(
777
+ (t) => t ? this.cleanArchiveAfter === 1 / 0 ? K : xe(this.cleanArchiveAfter) : K
778
778
  )
779
779
  );
780
780
  }
@@ -790,44 +790,46 @@ const tt = ({
790
790
  if (!c || c.state.status !== "idle") return _;
791
791
  let p = !1;
792
792
  const u = (y) => {
793
- var k;
794
- v.debug(`Cleaning up archive with key: ${y}`);
795
- const w = s[y];
796
- delete s[y], p || ((k = w == null ? void 0 : w.state.archive) == null || k.close(), p = !0);
793
+ var T;
794
+ w.debug(`Cleaning up archive with key: ${y}`);
795
+ const x = s[y];
796
+ delete s[y], p || ((T = x == null ? void 0 : x.state.archive) == null || T.close(), p = !0);
797
797
  };
798
798
  c.update({
799
799
  status: "loading"
800
800
  });
801
801
  const g = c.locks$, b = c.isUnlocked$, h = g.pipe(
802
- me(),
803
- D(([y, w]) => w > y),
804
- he(!0)
802
+ he(),
803
+ D(([y, x]) => x > y),
804
+ ge(!0)
805
805
  );
806
- return P(e(l)).pipe(
806
+ return C(e(l)).pipe(
807
807
  j((y) => {
808
808
  c.update({
809
809
  archive: y,
810
810
  status: "success"
811
811
  });
812
812
  }),
813
- C((y) => (u(l), c.update({
813
+ P((y) => (u(l), c.update({
814
814
  status: "error",
815
815
  error: y
816
816
  }), _)),
817
- L(() => {
817
+ W(() => {
818
818
  const y = h.pipe(
819
- L(() => n),
820
- L(() => b),
821
- D((w) => w)
819
+ W(() => n),
820
+ W(() => b),
821
+ D((T) => T)
822
+ );
823
+ return q(y, c.overTTL$).pipe(
824
+ G(),
825
+ j(() => {
826
+ u(l);
827
+ })
822
828
  );
823
- return q(y, c.overTTL$);
824
- }),
825
- j(() => {
826
- u(l);
827
829
  })
828
830
  );
829
831
  }),
830
- ge(r)
832
+ ye(r)
831
833
  ), a = (l) => {
832
834
  let c = !1;
833
835
  const p = s[l] ?? new et(t);
@@ -848,12 +850,12 @@ const tt = ({
848
850
  if (h)
849
851
  throw h;
850
852
  }),
851
- ye()
853
+ be()
852
854
  );
853
855
  return q(g, b).pipe(
854
- be(),
856
+ G(),
855
857
  F((h) => ({ archive: h, release: u })),
856
- C((h) => {
858
+ P((h) => {
857
859
  throw u(), h;
858
860
  })
859
861
  );
@@ -863,7 +865,7 @@ const tt = ({
863
865
  return o.subscribe(), {
864
866
  access: a,
865
867
  purge: d,
866
- archives: s
868
+ _archives: s
867
869
  };
868
870
  };
869
871
  class nt {
@@ -887,24 +889,24 @@ class nt {
887
889
  }
888
890
  fetchManifest({ key: t, baseUrl: i }) {
889
891
  const r = this.accessArchive(t).pipe(
890
- M(({ archive: n, release: s }) => P(
892
+ M(({ archive: n, release: s }) => C(
891
893
  Ze(n, { baseUrl: i })
892
894
  ).pipe(
893
- L(
894
- (a) => P(this.onManifestSuccess({ manifest: a, archive: n }))
895
+ W(
896
+ (a) => C(this.onManifestSuccess({ manifest: a, archive: n }))
895
897
  ),
896
898
  F(
897
899
  (a) => new Response(JSON.stringify(a), {
898
900
  status: 200
899
901
  })
900
902
  ),
901
- K(() => {
903
+ J(() => {
902
904
  s();
903
905
  })
904
906
  )),
905
- C((n) => J(this.onError(n)))
907
+ P((n) => Y(this.onError(n)))
906
908
  );
907
- return Y(r);
909
+ return Q(r);
908
910
  }
909
911
  fetchResource({
910
912
  key: t,
@@ -913,7 +915,7 @@ class nt {
913
915
  const r = this.accessArchive(t).pipe(
914
916
  M(({ archive: n, release: s }) => {
915
917
  const o = i.replaceAll("file://", "");
916
- return P(
918
+ return C(
917
919
  Ue(n, o)
918
920
  ).pipe(
919
921
  F(
@@ -926,14 +928,14 @@ class nt {
926
928
  }
927
929
  })
928
930
  ),
929
- K(() => {
931
+ J(() => {
930
932
  s();
931
933
  })
932
934
  );
933
935
  }),
934
- C((n) => J(this.onError(n)))
936
+ P((n) => Y(this.onError(n)))
935
937
  );
936
- return Y(r);
938
+ return Q(r);
937
939
  }
938
940
  }
939
941
  class ut extends nt {
@@ -947,10 +949,10 @@ class ut extends nt {
947
949
  try {
948
950
  const i = this.getUriInfo(t);
949
951
  if (!i) return;
950
- const r = Q(i.baseUrl), n = t.request.url.substring(
952
+ const r = Z(i.baseUrl), n = t.request.url.substring(
951
953
  r.length + 1
952
954
  ), [s = ""] = n.split("/"), o = decodeURIComponent(
953
- Q(n.substring(s.length + 1))
955
+ Z(n.substring(s.length + 1))
954
956
  );
955
957
  n.endsWith("/manifest") ? t.respondWith(
956
958
  this.fetchManifest({ key: s, baseUrl: `${r}/${s}/` })
@@ -971,6 +973,6 @@ export {
971
973
  at as createArchiveFromUrls,
972
974
  Ze as generateManifestFromArchive,
973
975
  Ue as generateResourceFromArchive,
974
- N as getArchiveOpfInfo
976
+ k as getArchiveOpfInfo
975
977
  };
976
978
  //# sourceMappingURL=index.js.map