@prose-reader/cbz 1.296.0 → 1.298.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/LICENCE +7 -0
- package/dist/enhancer.d.ts +5 -1
- package/dist/enhancer.test.d.ts +1 -0
- package/dist/index.js +288 -290
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +9 -342
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +5 -2
package/LICENCE
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2021 @prose-reader/core
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/dist/enhancer.d.ts
CHANGED
|
@@ -1 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
import { Reader } from '@prose-reader/core';
|
|
2
|
+
export type CbzEnhancerAPI = {
|
|
3
|
+
__PROSE_READER_ENHANCER_CBZ: true;
|
|
4
|
+
};
|
|
5
|
+
export declare const cbzEnhancer: <InheritOptions, InheritOutput extends Reader>(next: (options: InheritOptions) => InheritOutput) => (options: InheritOptions) => InheritOutput & CbzEnhancerAPI;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/index.js
CHANGED
|
@@ -1,359 +1,357 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const
|
|
4
|
-
const
|
|
5
|
-
if (
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const explicitPageRangeMatch = /(?:^|[\s._(-]|\[)p\s*(\d{1,5})\s*[-_]\s*(?:p\s*)?(\d{1,5})(?=$|[^\d])/i.exec(
|
|
11
|
-
basenameWithoutExtension
|
|
1
|
+
import { updateEpubCfiSpineItemref as w, getEpubCfiSpineItemref as b } from "@prose-reader/cfi";
|
|
2
|
+
import { detectMimeTypeFromName as c, parseContentType as U, escapeXmlAttributeValue as $ } from "@prose-reader/shared";
|
|
3
|
+
const M = 2e3, m = (e) => {
|
|
4
|
+
const t = Number.parseInt(e, 10);
|
|
5
|
+
if (Number.isFinite(t) && !(t < 0 || t > M))
|
|
6
|
+
return t;
|
|
7
|
+
}, C = (e) => {
|
|
8
|
+
const t = /(?:^|[\s._(-]|\[)p\s*(\d{1,5})\s*[-_]\s*(?:p\s*)?(\d{1,5})(?=$|[^\d])/i.exec(
|
|
9
|
+
e
|
|
12
10
|
);
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
basenameWithoutExtension
|
|
11
|
+
return t || /(?:^|[\s._(]|\[)(0\d{1,4})\s*[-_]\s*(0\d{1,4})(?=$|[^\d])/i.exec(
|
|
12
|
+
e
|
|
16
13
|
);
|
|
17
|
-
}
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
if (
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
};
|
|
38
|
-
};
|
|
39
|
-
const PAGE_SPREAD_RESOURCE_PREFIX = `__prose-reader__/page-spread`;
|
|
40
|
-
const PAGE_SPREAD_SPLIT_DOCUMENT_MEDIA_TYPE = `application/xhtml+xml`;
|
|
41
|
-
const supportedImageMediaTypes = /* @__PURE__ */ new Set([
|
|
42
|
-
`image/jpg`,
|
|
43
|
-
`image/jpeg`,
|
|
44
|
-
`image/png`,
|
|
45
|
-
`image/webp`
|
|
46
|
-
]);
|
|
47
|
-
const isPageSpreadSplitSupportedImage = (mimeType) => {
|
|
48
|
-
if (mimeType === void 0) return false;
|
|
49
|
-
return supportedImageMediaTypes.has(mimeType);
|
|
50
|
-
};
|
|
51
|
-
const encodeOriginalUriSegment = (uri) => encodeURIComponent(uri);
|
|
52
|
-
const createManifestResourceHref = ({
|
|
53
|
-
baseUrl = ``,
|
|
54
|
-
resourcePath
|
|
55
|
-
}) => {
|
|
56
|
-
if (!baseUrl && /^https?:\/\//.test(resourcePath)) {
|
|
57
|
-
return encodeURI(resourcePath);
|
|
58
|
-
}
|
|
59
|
-
const hrefBaseUrl = baseUrl ? `${baseUrl}${baseUrl.endsWith(`/`) ? `` : `/`}` : `file://`;
|
|
60
|
-
return encodeURI(`${hrefBaseUrl}${resourcePath}`);
|
|
61
|
-
};
|
|
62
|
-
const hasOpfExtension = (path) => path.toLowerCase().endsWith(`.opf`);
|
|
63
|
-
const isArchiveEpub = (archive) => archive.records.some(
|
|
64
|
-
(file) => !file.dir && (hasOpfExtension(file.basename) || hasOpfExtension(file.uri))
|
|
65
|
-
);
|
|
66
|
-
const buildVirtualPageSpreadResourcePath = ({
|
|
67
|
-
cropSide,
|
|
68
|
-
originalUri
|
|
14
|
+
}, A = (e) => {
|
|
15
|
+
const t = e.replace(/\.[^.]+$/, ""), r = C(t);
|
|
16
|
+
if (!r) return;
|
|
17
|
+
const [, i, o] = r;
|
|
18
|
+
if (i === void 0 || o === void 0)
|
|
19
|
+
return;
|
|
20
|
+
const n = m(i), s = m(o);
|
|
21
|
+
if (!(n === void 0 || s === void 0) && s === n + 1)
|
|
22
|
+
return {
|
|
23
|
+
firstPageLabel: i,
|
|
24
|
+
secondPageLabel: o
|
|
25
|
+
};
|
|
26
|
+
}, P = "__prose-reader__/page-spread", x = "application/xhtml+xml", T = /* @__PURE__ */ new Set([
|
|
27
|
+
"image/jpg",
|
|
28
|
+
"image/jpeg",
|
|
29
|
+
"image/png",
|
|
30
|
+
"image/webp"
|
|
31
|
+
]), S = (e) => e === void 0 ? !1 : T.has(e), F = (e) => encodeURIComponent(e), O = ({
|
|
32
|
+
baseUrl: e = "",
|
|
33
|
+
resourcePath: t
|
|
69
34
|
}) => {
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
35
|
+
if (!e && /^https?:\/\//.test(t))
|
|
36
|
+
return encodeURI(t);
|
|
37
|
+
const r = e ? `${e}${e.endsWith("/") ? "" : "/"}` : "file://";
|
|
38
|
+
return encodeURI(`${r}${t}`);
|
|
39
|
+
}, v = (e) => e.toLowerCase().endsWith(".opf"), L = (e) => e.records.some(
|
|
40
|
+
(t) => !t.dir && (v(t.basename) || v(t.uri))
|
|
41
|
+
), N = ({
|
|
42
|
+
cropSide: e,
|
|
43
|
+
originalUri: t
|
|
44
|
+
}) => `${P}/${F(t)}/${e}.xhtml`, W = (e) => e === "left" ? { pageSpreadLeft: !0, pageSpreadRight: void 0 } : { pageSpreadLeft: void 0, pageSpreadRight: !0 }, B = (e) => e === "rtl" ? ["right", "left"] : ["left", "right"], R = ({
|
|
45
|
+
baseUrl: e,
|
|
46
|
+
cropSide: t,
|
|
47
|
+
label: r,
|
|
48
|
+
originalSpineItem: i,
|
|
49
|
+
originalUri: o,
|
|
50
|
+
progressionWeight: n
|
|
81
51
|
}) => {
|
|
82
|
-
const
|
|
83
|
-
cropSide,
|
|
84
|
-
originalUri
|
|
52
|
+
const s = N({
|
|
53
|
+
cropSide: t,
|
|
54
|
+
originalUri: o
|
|
85
55
|
});
|
|
86
56
|
return {
|
|
87
|
-
...
|
|
88
|
-
id: `${
|
|
89
|
-
href:
|
|
90
|
-
mediaType:
|
|
91
|
-
progressionWeight,
|
|
92
|
-
renditionLayout:
|
|
93
|
-
...
|
|
57
|
+
...i,
|
|
58
|
+
id: `${i.id}.${r}`,
|
|
59
|
+
href: O({ baseUrl: e, resourcePath: s }),
|
|
60
|
+
mediaType: x,
|
|
61
|
+
progressionWeight: n,
|
|
62
|
+
renditionLayout: "pre-paginated",
|
|
63
|
+
...W(t)
|
|
94
64
|
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
mediaType
|
|
65
|
+
}, I = ({
|
|
66
|
+
href: e,
|
|
67
|
+
id: t,
|
|
68
|
+
mediaType: r
|
|
100
69
|
}) => ({
|
|
101
|
-
href,
|
|
102
|
-
id,
|
|
103
|
-
mediaType
|
|
104
|
-
})
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
spineItem
|
|
70
|
+
href: e,
|
|
71
|
+
id: t,
|
|
72
|
+
mediaType: r
|
|
73
|
+
}), k = ({
|
|
74
|
+
archive: e,
|
|
75
|
+
baseUrl: t,
|
|
76
|
+
spineItem: r
|
|
109
77
|
}) => {
|
|
110
|
-
const
|
|
111
|
-
|
|
112
|
-
hrefCandidates.flatMap((href) => getResourcePathCandidates(href, baseUrl))
|
|
78
|
+
const i = [r.href, H(r.href)], o = new Set(
|
|
79
|
+
i.flatMap((n) => D(n, t))
|
|
113
80
|
);
|
|
114
|
-
return
|
|
115
|
-
(
|
|
81
|
+
return e.records.find(
|
|
82
|
+
(n) => !n.dir && o.has(n.uri)
|
|
116
83
|
);
|
|
117
|
-
}
|
|
118
|
-
const decodeManifestHref = (href) => {
|
|
84
|
+
}, H = (e) => {
|
|
119
85
|
try {
|
|
120
|
-
return decodeURI(
|
|
86
|
+
return decodeURI(e);
|
|
121
87
|
} catch {
|
|
122
|
-
return
|
|
88
|
+
return e;
|
|
123
89
|
}
|
|
124
|
-
}
|
|
125
|
-
const
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
candidates.push(href.slice(`file://`.length));
|
|
130
|
-
}
|
|
131
|
-
if (baseUrl) {
|
|
132
|
-
const normalizedBaseUrl = normalizeBaseUrl(baseUrl);
|
|
133
|
-
if (href.startsWith(normalizedBaseUrl)) {
|
|
134
|
-
candidates.push(href.slice(normalizedBaseUrl.length));
|
|
135
|
-
}
|
|
90
|
+
}, V = (e) => e.endsWith("/") ? e : `${e}/`, D = (e, t) => {
|
|
91
|
+
const r = [e];
|
|
92
|
+
if (e.startsWith("file://") && r.push(e.slice(7)), t) {
|
|
93
|
+
const i = V(t);
|
|
94
|
+
e.startsWith(i) && r.push(e.slice(i.length));
|
|
136
95
|
}
|
|
137
|
-
return
|
|
138
|
-
}
|
|
139
|
-
|
|
140
|
-
const
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
const virtualManifestItems = [];
|
|
150
|
-
const spineItems = manifest.spineItems.flatMap((spineItem) => {
|
|
151
|
-
const archiveRecord = getArchiveRecordForManifestItem({
|
|
152
|
-
archive,
|
|
153
|
-
baseUrl,
|
|
154
|
-
spineItem
|
|
155
|
-
});
|
|
156
|
-
if (!isPageSpreadSplitSupportedArchiveRecord(archiveRecord)) {
|
|
157
|
-
return [spineItem];
|
|
158
|
-
}
|
|
159
|
-
const detected = detectPageSpreadFromBasename(archiveRecord.basename);
|
|
160
|
-
if (detected === void 0) return [spineItem];
|
|
161
|
-
const [firstCropSide, secondCropSide] = cropSidesInReadingOrder(
|
|
162
|
-
manifest.readingDirection
|
|
163
|
-
);
|
|
164
|
-
const splitProgressionWeight = spineItem.progressionWeight !== void 0 ? spineItem.progressionWeight / 2 : void 0;
|
|
165
|
-
const firstSpineItem = createVirtualSpineItem({
|
|
166
|
-
baseUrl,
|
|
167
|
-
cropSide: firstCropSide,
|
|
168
|
-
label: detected.firstPageLabel,
|
|
169
|
-
originalSpineItem: spineItem,
|
|
170
|
-
originalUri: archiveRecord.uri,
|
|
171
|
-
progressionWeight: splitProgressionWeight
|
|
96
|
+
return r;
|
|
97
|
+
}, X = (e) => U(e?.encodingFormat ?? "") || c(e?.basename ?? ""), G = (e) => c(e.uri) || c(e.basename), z = (e) => {
|
|
98
|
+
if (e === void 0 || e.dir) return !1;
|
|
99
|
+
const t = G(e);
|
|
100
|
+
return S(t) ? S(X(e)) : !1;
|
|
101
|
+
}, j = ({ archive: e, baseUrl: t }) => async (r) => {
|
|
102
|
+
if (L(e)) return r;
|
|
103
|
+
const i = [], o = r.spineItems.flatMap((n) => {
|
|
104
|
+
const s = k({
|
|
105
|
+
archive: e,
|
|
106
|
+
baseUrl: t,
|
|
107
|
+
spineItem: n
|
|
172
108
|
});
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
109
|
+
if (!z(s))
|
|
110
|
+
return [n];
|
|
111
|
+
const a = A(s.basename);
|
|
112
|
+
if (a === void 0) return [n];
|
|
113
|
+
const [_, y] = B(
|
|
114
|
+
r.readingDirection
|
|
115
|
+
), l = n.progressionWeight !== void 0 ? n.progressionWeight / 2 : void 0, h = R({
|
|
116
|
+
baseUrl: t,
|
|
117
|
+
cropSide: _,
|
|
118
|
+
label: a.firstPageLabel,
|
|
119
|
+
originalSpineItem: n,
|
|
120
|
+
originalUri: s.uri,
|
|
121
|
+
progressionWeight: l
|
|
122
|
+
}), f = R({
|
|
123
|
+
baseUrl: t,
|
|
124
|
+
cropSide: y,
|
|
125
|
+
label: a.secondPageLabel,
|
|
126
|
+
originalSpineItem: n,
|
|
127
|
+
originalUri: s.uri,
|
|
128
|
+
progressionWeight: l
|
|
180
129
|
});
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
);
|
|
185
|
-
return [firstSpineItem, secondSpineItem];
|
|
130
|
+
return i.push(
|
|
131
|
+
I(h),
|
|
132
|
+
I(f)
|
|
133
|
+
), [h, f];
|
|
186
134
|
});
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
index
|
|
135
|
+
return i.length === 0 ? r : {
|
|
136
|
+
...r,
|
|
137
|
+
spineItems: o.map((n, s) => ({
|
|
138
|
+
...n,
|
|
139
|
+
index: s
|
|
193
140
|
})),
|
|
194
|
-
items: [...
|
|
141
|
+
items: [...r.items, ...i]
|
|
195
142
|
};
|
|
196
|
-
}
|
|
197
|
-
const imageDimensionsCache = /* @__PURE__ */ new WeakMap();
|
|
198
|
-
const decodeOriginalUriSegment = (encoded) => {
|
|
143
|
+
}, d = /* @__PURE__ */ new WeakMap(), q = (e) => {
|
|
199
144
|
try {
|
|
200
|
-
return decodeURIComponent(
|
|
145
|
+
return decodeURIComponent(e);
|
|
201
146
|
} catch {
|
|
202
|
-
return
|
|
203
|
-
}
|
|
204
|
-
};
|
|
205
|
-
const parseVirtualPageSpreadResourcePath = (resourcePath) => {
|
|
206
|
-
const prefixIndex = resourcePath.indexOf(`${PAGE_SPREAD_RESOURCE_PREFIX}/`);
|
|
207
|
-
if (prefixIndex < 0) return void 0;
|
|
208
|
-
const virtualPath = resourcePath.slice(prefixIndex);
|
|
209
|
-
const parts = virtualPath.split(`/`);
|
|
210
|
-
const encodedOriginalUri = parts[2];
|
|
211
|
-
const cropFileName = parts[3];
|
|
212
|
-
if (parts.length !== 4 || parts[0] !== `__prose-reader__` || parts[1] !== `page-spread` || encodedOriginalUri === void 0 || cropFileName === void 0) {
|
|
213
|
-
return void 0;
|
|
147
|
+
return;
|
|
214
148
|
}
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
149
|
+
}, p = (e) => {
|
|
150
|
+
const t = e.indexOf(`${P}/`);
|
|
151
|
+
if (t < 0) return;
|
|
152
|
+
const i = e.slice(t).split("/"), o = i[2], n = i[3];
|
|
153
|
+
if (i.length !== 4 || i[0] !== "__prose-reader__" || i[1] !== "page-spread" || o === void 0 || n === void 0)
|
|
154
|
+
return;
|
|
155
|
+
const s = n.split(".")[0];
|
|
156
|
+
if (s !== "left" && s !== "right") return;
|
|
157
|
+
const a = q(o);
|
|
158
|
+
if (a !== void 0)
|
|
159
|
+
return {
|
|
160
|
+
originalUri: a,
|
|
161
|
+
cropSide: s
|
|
162
|
+
};
|
|
163
|
+
}, Y = ({
|
|
164
|
+
cropSide: e,
|
|
165
|
+
imageHeight: t,
|
|
166
|
+
imageWidth: r
|
|
228
167
|
}) => {
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
return `../../../${encodeURI(originalUri)}`;
|
|
236
|
-
};
|
|
237
|
-
const readImageDimensions = async (source) => {
|
|
238
|
-
if (typeof createImageBitmap !== `function`) {
|
|
239
|
-
throw new Error(`Page spread XHTML generation requires createImageBitmap`);
|
|
240
|
-
}
|
|
241
|
-
const bitmap = await createImageBitmap(source);
|
|
168
|
+
const i = Math.floor(r / 2), o = r - i;
|
|
169
|
+
return e === "left" ? { x: 0, width: i, height: t } : { x: i, width: o, height: t };
|
|
170
|
+
}, Z = (e) => /^https?:\/\//.test(e) ? e : `../../../${encodeURI(e)}`, J = async (e) => {
|
|
171
|
+
if (typeof createImageBitmap != "function")
|
|
172
|
+
throw new Error("Page spread XHTML generation requires createImageBitmap");
|
|
173
|
+
const t = await createImageBitmap(e);
|
|
242
174
|
try {
|
|
243
175
|
return {
|
|
244
|
-
height:
|
|
245
|
-
width:
|
|
176
|
+
height: t.height,
|
|
177
|
+
width: t.width
|
|
246
178
|
};
|
|
247
179
|
} finally {
|
|
248
|
-
|
|
180
|
+
t.close();
|
|
249
181
|
}
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
originalUri
|
|
182
|
+
}, K = ({
|
|
183
|
+
cropSide: e,
|
|
184
|
+
imageDimensions: t,
|
|
185
|
+
originalUri: r
|
|
255
186
|
}) => {
|
|
256
|
-
if (
|
|
257
|
-
throw new Error(
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
imageWidth: imageDimensions.width
|
|
187
|
+
if (t.width < 2)
|
|
188
|
+
throw new Error("Page spread image is too narrow to split");
|
|
189
|
+
const i = Y({
|
|
190
|
+
cropSide: e,
|
|
191
|
+
imageHeight: t.height,
|
|
192
|
+
imageWidth: t.width
|
|
263
193
|
});
|
|
264
194
|
return `<?xml version="1.0" encoding="UTF-8"?>
|
|
265
195
|
<html xmlns="http://www.w3.org/1999/xhtml">
|
|
266
196
|
<head>
|
|
267
|
-
<meta name="viewport" content="width=${
|
|
197
|
+
<meta name="viewport" content="width=${i.width}, height=${i.height}" />
|
|
268
198
|
<style>
|
|
269
199
|
html,
|
|
270
200
|
body {
|
|
271
|
-
width: ${
|
|
272
|
-
height: ${
|
|
201
|
+
width: ${i.width}px;
|
|
202
|
+
height: ${i.height}px;
|
|
273
203
|
margin: 0;
|
|
274
204
|
overflow: hidden;
|
|
275
205
|
}
|
|
276
206
|
|
|
277
207
|
img {
|
|
278
208
|
display: block;
|
|
279
|
-
width: ${
|
|
280
|
-
height: ${
|
|
209
|
+
width: ${t.width}px;
|
|
210
|
+
height: ${t.height}px;
|
|
281
211
|
max-width: none;
|
|
282
|
-
transform: translateX(-${
|
|
212
|
+
transform: translateX(-${i.x}px);
|
|
283
213
|
user-select: none;
|
|
284
214
|
-webkit-user-drag: none;
|
|
285
215
|
}
|
|
286
216
|
</style>
|
|
287
217
|
</head>
|
|
288
218
|
<body>
|
|
289
|
-
<img src="${
|
|
219
|
+
<img src="${$(Z(r))}" alt="" />
|
|
290
220
|
</body>
|
|
291
221
|
</html>`;
|
|
292
|
-
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
resourcePath
|
|
222
|
+
}, Q = async ({
|
|
223
|
+
archive: e,
|
|
224
|
+
resourcePath: t
|
|
296
225
|
}) => {
|
|
297
|
-
const
|
|
298
|
-
if (
|
|
299
|
-
const
|
|
300
|
-
(
|
|
226
|
+
const r = p(t);
|
|
227
|
+
if (r === void 0) return;
|
|
228
|
+
const i = e.records.find(
|
|
229
|
+
(a) => a.uri === r.originalUri && !a.dir
|
|
301
230
|
);
|
|
302
|
-
if (
|
|
231
|
+
if (i === void 0 || i.dir)
|
|
303
232
|
throw new Error(
|
|
304
|
-
`no source file found for virtual page spread resourcePath:${
|
|
233
|
+
`no source file found for virtual page spread resourcePath:${t}`
|
|
305
234
|
);
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
imageDimensions,
|
|
316
|
-
originalUri: virtualResource.originalUri
|
|
317
|
-
});
|
|
318
|
-
return {
|
|
319
|
-
body,
|
|
235
|
+
const o = d.get(e) ?? /* @__PURE__ */ new Map();
|
|
236
|
+
d.has(e) || d.set(e, o);
|
|
237
|
+
const n = o.get(r.originalUri) ?? await J(await i.blob());
|
|
238
|
+
return o.set(r.originalUri, n), {
|
|
239
|
+
body: K({
|
|
240
|
+
cropSide: r.cropSide,
|
|
241
|
+
imageDimensions: n,
|
|
242
|
+
originalUri: r.originalUri
|
|
243
|
+
}),
|
|
320
244
|
params: {
|
|
321
|
-
contentType:
|
|
245
|
+
contentType: x
|
|
322
246
|
}
|
|
323
247
|
};
|
|
324
|
-
}
|
|
325
|
-
const
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
resourcePath
|
|
248
|
+
}, ee = ({ archive: e, resourcePath: t }) => async (r) => {
|
|
249
|
+
const i = await Q({
|
|
250
|
+
archive: e,
|
|
251
|
+
resourcePath: t
|
|
329
252
|
});
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
...
|
|
333
|
-
...pageSpreadResource,
|
|
253
|
+
return i === void 0 ? r : {
|
|
254
|
+
...r,
|
|
255
|
+
...i,
|
|
334
256
|
params: {
|
|
335
|
-
...
|
|
336
|
-
...
|
|
257
|
+
...r.params,
|
|
258
|
+
...i.params
|
|
337
259
|
}
|
|
338
260
|
};
|
|
339
|
-
}
|
|
340
|
-
|
|
261
|
+
}, g = "vnd.prose-reader.cbz.virtual-spine-id", E = (e) => {
|
|
262
|
+
try {
|
|
263
|
+
return decodeURIComponent(e);
|
|
264
|
+
} catch {
|
|
265
|
+
return e;
|
|
266
|
+
}
|
|
267
|
+
}, te = (e) => {
|
|
268
|
+
try {
|
|
269
|
+
return decodeURI(e);
|
|
270
|
+
} catch {
|
|
271
|
+
return e;
|
|
272
|
+
}
|
|
273
|
+
}, u = (e) => {
|
|
274
|
+
const t = p(e) ?? p(te(e));
|
|
275
|
+
if (t)
|
|
276
|
+
return {
|
|
277
|
+
...t,
|
|
278
|
+
originalUri: E(t.originalUri)
|
|
279
|
+
};
|
|
280
|
+
}, re = (e, t) => {
|
|
281
|
+
const r = /* @__PURE__ */ new Set();
|
|
282
|
+
let i = 0;
|
|
283
|
+
for (const o of e.spineItemsManager.items) {
|
|
284
|
+
const n = u(o.item.href);
|
|
285
|
+
if (!n) {
|
|
286
|
+
i++;
|
|
287
|
+
continue;
|
|
288
|
+
}
|
|
289
|
+
if (n.originalUri === t)
|
|
290
|
+
return i;
|
|
291
|
+
r.has(n.originalUri) || (r.add(n.originalUri), i++);
|
|
292
|
+
}
|
|
293
|
+
}, ie = (e, t, r) => {
|
|
294
|
+
const i = u(r.href);
|
|
295
|
+
if (!i) return;
|
|
296
|
+
const o = re(
|
|
297
|
+
e,
|
|
298
|
+
i.originalUri
|
|
299
|
+
);
|
|
300
|
+
if (o !== void 0)
|
|
301
|
+
return w(t, {
|
|
302
|
+
extensions: {
|
|
303
|
+
[g]: encodeURIComponent(r.id)
|
|
304
|
+
},
|
|
305
|
+
spineId: i.originalUri,
|
|
306
|
+
spineIndex: o
|
|
307
|
+
});
|
|
308
|
+
}, ne = (e, t) => {
|
|
309
|
+
const r = b(t)?.extensions?.[g];
|
|
310
|
+
if (!r) return;
|
|
311
|
+
const i = e.spineItemsManager.get(
|
|
312
|
+
E(r)
|
|
313
|
+
);
|
|
314
|
+
if (!(!i || !u(i.item.href)))
|
|
315
|
+
return w(t, {
|
|
316
|
+
extensions: {
|
|
317
|
+
[g]: void 0
|
|
318
|
+
},
|
|
319
|
+
spineId: i.item.id,
|
|
320
|
+
spineIndex: i.item.index
|
|
321
|
+
});
|
|
322
|
+
}, ae = (e) => (t) => {
|
|
323
|
+
const r = e(t), i = r.hookManager.register(
|
|
324
|
+
"cfi.afterGenerate",
|
|
325
|
+
({ cfi: s, spineItem: a }) => ie(r, s, a)
|
|
326
|
+
), o = r.hookManager.register(
|
|
327
|
+
"cfi.beforeResolve",
|
|
328
|
+
({ cfi: s }) => ne(r, s)
|
|
329
|
+
);
|
|
330
|
+
return {
|
|
331
|
+
...r,
|
|
332
|
+
__PROSE_READER_ENHANCER_CBZ: !0,
|
|
333
|
+
destroy: () => {
|
|
334
|
+
i(), o(), r.destroy();
|
|
335
|
+
}
|
|
336
|
+
};
|
|
337
|
+
}, de = {
|
|
341
338
|
manifest: {
|
|
342
|
-
spine: [
|
|
339
|
+
spine: [j]
|
|
343
340
|
},
|
|
344
|
-
resource: [
|
|
341
|
+
resource: [ee]
|
|
345
342
|
};
|
|
346
343
|
export {
|
|
347
|
-
PAGE_SPREAD_RESOURCE_PREFIX,
|
|
348
|
-
PAGE_SPREAD_SPLIT_DOCUMENT_MEDIA_TYPE,
|
|
349
|
-
buildVirtualPageSpreadResourcePath,
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
344
|
+
P as PAGE_SPREAD_RESOURCE_PREFIX,
|
|
345
|
+
x as PAGE_SPREAD_SPLIT_DOCUMENT_MEDIA_TYPE,
|
|
346
|
+
N as buildVirtualPageSpreadResourcePath,
|
|
347
|
+
ae as cbzEnhancer,
|
|
348
|
+
K as createPageSpreadSplitXhtml,
|
|
349
|
+
A as detectPageSpreadFromBasename,
|
|
350
|
+
z as isPageSpreadSplitSupportedArchiveRecord,
|
|
351
|
+
S as isPageSpreadSplitSupportedImage,
|
|
352
|
+
j as pageSpreadSplit,
|
|
353
|
+
ee as pageSpreadSplitResourceHook,
|
|
354
|
+
p as parseVirtualPageSpreadResourcePath,
|
|
355
|
+
de as streamerHooks
|
|
358
356
|
};
|
|
359
357
|
//# sourceMappingURL=index.js.map
|