@prose-reader/enhancer-pdf 1.305.0 → 1.307.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 +1215 -76
- package/dist/index.js.map +1 -1
- package/dist/index.umd.cjs +16 -6
- package/dist/index.umd.cjs.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,59 +1,1198 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
1
|
+
import { EMPTY as e, catchError as t, from as n, map as r, mergeMap as i, of as a, switchMap as o, tap as s } from "rxjs";
|
|
2
|
+
import * as c from "pdfjs-dist";
|
|
3
|
+
import { RenderingCancelledException as l, TextLayer as u } from "pdfjs-dist";
|
|
4
4
|
import { DocumentRenderer as d, injectCSSToFrame as f, setAttributeIfChanged as p, setPropertyIfChanged as m, setStylePropertyIfChanged as h, upsertCSSToFrame as g, waitForFrameLoad as _, waitForFrameReady as v, waitForSwitch as y } from "@prose-reader/core";
|
|
5
|
-
//#region
|
|
6
|
-
var b =
|
|
7
|
-
|
|
5
|
+
//#region \0rolldown/runtime.js
|
|
6
|
+
var b = (e, t) => () => (t || (e((t = { exports: {} }).exports, t), e = null), t.exports), x = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
7
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
8
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
9
|
+
});
|
|
10
|
+
function S(e) {
|
|
11
|
+
let t = [];
|
|
12
|
+
if (e.length === 0) return "";
|
|
13
|
+
if (typeof e[0] != "string") throw TypeError(`Url must be a string. Received ${e[0]}`);
|
|
14
|
+
e[0].match(/^[^/:]+:\/*$/) && e.length > 1 && (e[0] = e.shift() + e[0]), e[0].match(/^file:\/\/\//) ? e[0] = e[0].replace(/^([^/:]+):\/*/, "$1:///") : e[0] = e[0].replace(/^([^/:]+):\/*/, "$1://");
|
|
15
|
+
for (let n = 0; n < e.length; n++) {
|
|
16
|
+
let r = e[n];
|
|
17
|
+
if (typeof r != "string") throw TypeError(`Url must be a string. Received ${r}`);
|
|
18
|
+
r !== "" && (n > 0 && (r = r.replace(/^[/]+/, "")), r = n < e.length - 1 ? r.replace(/[/]+$/, "") : r.replace(/[/]+$/, "/"), t.push(r));
|
|
19
|
+
}
|
|
20
|
+
let n = t.join("/");
|
|
21
|
+
n = n.replace(/\/(\?|&|#[^!])/g, "$1");
|
|
22
|
+
let r = n.split("?");
|
|
23
|
+
return n = r.shift() + (r.length > 0 ? "?" : "") + r.join("&"), n;
|
|
24
|
+
}
|
|
25
|
+
function C(...e) {
|
|
26
|
+
return S(Array.from(Array.isArray(e[0]) ? e[0] : e));
|
|
27
|
+
}
|
|
28
|
+
var w = () => {
|
|
29
|
+
if (!(typeof window > "u")) return window;
|
|
30
|
+
};
|
|
31
|
+
function T() {
|
|
32
|
+
let e = w()?.__PROSE_READER_DEBUG;
|
|
33
|
+
return e === !0 || e === "true";
|
|
34
|
+
}
|
|
35
|
+
var E = (e, t) => typeof e == "boolean" ? {
|
|
36
|
+
enabled: e,
|
|
37
|
+
options: t
|
|
38
|
+
} : {
|
|
39
|
+
enabled: e?.enabled,
|
|
40
|
+
options: e ?? t
|
|
41
|
+
}, D = (e) => e.at(-1)?.color, O = (e) => {
|
|
42
|
+
if (!e.length) return;
|
|
43
|
+
if (!e.some((e) => e.color)) return [e.map((e) => e.label).join(" ")];
|
|
44
|
+
let t = "", n = [];
|
|
45
|
+
for (let r of e) t += `%c${t ? ` ${r.label}` : r.label}`, n.push(r.color ? `color: ${r.color}` : "");
|
|
46
|
+
return [t, ...n];
|
|
47
|
+
}, k = (e = [], t = T()) => {
|
|
48
|
+
let n = t, r = {
|
|
49
|
+
enable: (e) => {
|
|
50
|
+
a(e);
|
|
51
|
+
},
|
|
52
|
+
namespace: (t, r, i) => {
|
|
53
|
+
let a = E(r, i), o = a.options?.color ?? D(e);
|
|
54
|
+
return k([...e, {
|
|
55
|
+
label: `[${t}]`,
|
|
56
|
+
color: o
|
|
57
|
+
}], a.enabled ?? n);
|
|
58
|
+
},
|
|
59
|
+
isEnabled: () => n,
|
|
60
|
+
debug: () => {},
|
|
61
|
+
info: () => {},
|
|
62
|
+
log: () => {},
|
|
63
|
+
groupCollapsed: () => {},
|
|
64
|
+
groupEnd: () => {},
|
|
65
|
+
getGroupArgs: (t) => {
|
|
66
|
+
let n = O(e);
|
|
67
|
+
if (!n) return [t];
|
|
68
|
+
let [r, ...i] = n;
|
|
69
|
+
return [`${r} ${t}`, ...i];
|
|
70
|
+
},
|
|
71
|
+
warn: () => {},
|
|
72
|
+
error: () => {}
|
|
73
|
+
}, i = (t) => {
|
|
74
|
+
if (!t) {
|
|
75
|
+
r.debug = () => {}, r.info = () => {}, r.log = () => {}, r.groupCollapsed = () => {}, r.groupEnd = () => {}, r.warn = () => {}, r.error = () => {};
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let n = O(e) ?? [];
|
|
79
|
+
r.debug = Function.prototype.bind.call(console.debug, console, ...n), r.info = Function.prototype.bind.call(console.info, console, ...n), r.log = Function.prototype.bind.call(console.log, console, ...n), r.groupCollapsed = Function.prototype.bind.call(console.groupCollapsed, console), r.groupEnd = Function.prototype.bind.call(console.groupEnd, console), r.warn = Function.prototype.bind.call(console.warn, console, ...n), r.error = Function.prototype.bind.call(console.error, console, ...n);
|
|
80
|
+
}, a = (e) => {
|
|
81
|
+
n !== e && (n = e, i(n));
|
|
82
|
+
};
|
|
83
|
+
return i(n), r;
|
|
84
|
+
}, A = k(), j = ({ records: e, ...t }) => {
|
|
85
|
+
let n = /* @__PURE__ */ new Map();
|
|
86
|
+
for (let t of e) n.has(t.uri) || n.set(t.uri, t);
|
|
87
|
+
return {
|
|
88
|
+
...t,
|
|
89
|
+
records: e,
|
|
90
|
+
recordsByUri: n
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
A.namespace("@prose-reader/streamer", !1, { color: "#ffae42" });
|
|
94
|
+
var M = (e) => ({
|
|
95
|
+
blob: e,
|
|
96
|
+
arrayBuffer: () => e().then((e) => e.arrayBuffer())
|
|
97
|
+
}), N = /* @__PURE__ */ b(((e) => {
|
|
98
|
+
(function(e) {
|
|
99
|
+
e.parser = function(e, t) {
|
|
100
|
+
return new n(e, t);
|
|
101
|
+
}, e.SAXParser = n, e.SAXStream = u, e.createStream = c, e.MAX_BUFFER_LENGTH = 64 * 1024;
|
|
102
|
+
var t = [
|
|
103
|
+
"comment",
|
|
104
|
+
"sgmlDecl",
|
|
105
|
+
"textNode",
|
|
106
|
+
"tagName",
|
|
107
|
+
"doctype",
|
|
108
|
+
"procInstName",
|
|
109
|
+
"procInstBody",
|
|
110
|
+
"entity",
|
|
111
|
+
"attribName",
|
|
112
|
+
"attribValue",
|
|
113
|
+
"cdata",
|
|
114
|
+
"script"
|
|
115
|
+
];
|
|
116
|
+
e.EVENTS = [
|
|
117
|
+
"text",
|
|
118
|
+
"processinginstruction",
|
|
119
|
+
"sgmldeclaration",
|
|
120
|
+
"doctype",
|
|
121
|
+
"comment",
|
|
122
|
+
"opentagstart",
|
|
123
|
+
"attribute",
|
|
124
|
+
"opentag",
|
|
125
|
+
"closetag",
|
|
126
|
+
"opencdata",
|
|
127
|
+
"cdata",
|
|
128
|
+
"closecdata",
|
|
129
|
+
"error",
|
|
130
|
+
"end",
|
|
131
|
+
"ready",
|
|
132
|
+
"script",
|
|
133
|
+
"opennamespace",
|
|
134
|
+
"closenamespace"
|
|
135
|
+
];
|
|
136
|
+
function n(t, r) {
|
|
137
|
+
if (!(this instanceof n)) return new n(t, r);
|
|
138
|
+
var a = this;
|
|
139
|
+
i(a), a.q = a.c = "", a.bufferCheckPosition = e.MAX_BUFFER_LENGTH, a.encoding = null, a.opt = r || {}, a.opt.lowercase = a.opt.lowercase || a.opt.lowercasetags, a.looseCase = a.opt.lowercase ? "toLowerCase" : "toUpperCase", a.opt.maxEntityCount = a.opt.maxEntityCount || 512, a.opt.maxEntityDepth = a.opt.maxEntityDepth || 4, a.entityCount = a.entityDepth = 0, a.tags = [], a.closed = a.closedRoot = a.sawRoot = !1, a.tag = a.error = null, a.strict = !!t, a.noscript = !!(t || a.opt.noscript), a.state = E.BEGIN, a.strictEntities = a.opt.strictEntities, a.ENTITIES = a.strictEntities ? Object.create(e.XML_ENTITIES) : Object.create(e.ENTITIES), a.attribList = [], a.opt.xmlns && (a.ns = Object.create(h)), a.opt.unquotedAttributeValues === void 0 && (a.opt.unquotedAttributeValues = !t), a.trackPosition = a.opt.position !== !1, a.trackPosition && (a.position = a.line = a.column = 0), O(a, "onready");
|
|
140
|
+
}
|
|
141
|
+
Object.create || (Object.create = function(e) {
|
|
142
|
+
function t() {}
|
|
143
|
+
return t.prototype = e, new t();
|
|
144
|
+
}), Object.keys || (Object.keys = function(e) {
|
|
145
|
+
var t = [];
|
|
146
|
+
for (var n in e) e.hasOwnProperty(n) && t.push(n);
|
|
147
|
+
return t;
|
|
148
|
+
});
|
|
149
|
+
function r(n) {
|
|
150
|
+
for (var r = Math.max(e.MAX_BUFFER_LENGTH, 10), i = 0, a = 0, o = t.length; a < o; a++) {
|
|
151
|
+
var s = n[t[a]].length;
|
|
152
|
+
if (s > r) switch (t[a]) {
|
|
153
|
+
case "textNode":
|
|
154
|
+
P(n);
|
|
155
|
+
break;
|
|
156
|
+
case "cdata":
|
|
157
|
+
N(n, "oncdata", n.cdata), n.cdata = "";
|
|
158
|
+
break;
|
|
159
|
+
case "script":
|
|
160
|
+
N(n, "onscript", n.script), n.script = "";
|
|
161
|
+
break;
|
|
162
|
+
default: I(n, "Max buffer length exceeded: " + t[a]);
|
|
163
|
+
}
|
|
164
|
+
i = Math.max(i, s);
|
|
165
|
+
}
|
|
166
|
+
n.bufferCheckPosition = e.MAX_BUFFER_LENGTH - i + n.position;
|
|
167
|
+
}
|
|
168
|
+
function i(e) {
|
|
169
|
+
for (var n = 0, r = t.length; n < r; n++) e[t[n]] = "";
|
|
170
|
+
}
|
|
171
|
+
function a(e) {
|
|
172
|
+
P(e), e.cdata !== "" && (N(e, "oncdata", e.cdata), e.cdata = ""), e.script !== "" && (N(e, "onscript", e.script), e.script = "");
|
|
173
|
+
}
|
|
174
|
+
n.prototype = {
|
|
175
|
+
end: function() {
|
|
176
|
+
L(this);
|
|
177
|
+
},
|
|
178
|
+
write: q,
|
|
179
|
+
resume: function() {
|
|
180
|
+
return this.error = null, this;
|
|
181
|
+
},
|
|
182
|
+
close: function() {
|
|
183
|
+
return this.write(null);
|
|
184
|
+
},
|
|
185
|
+
flush: function() {
|
|
186
|
+
a(this);
|
|
187
|
+
}
|
|
188
|
+
};
|
|
189
|
+
var o;
|
|
190
|
+
try {
|
|
191
|
+
o = x("node:stream").Stream;
|
|
192
|
+
} catch {
|
|
193
|
+
o = function() {};
|
|
194
|
+
}
|
|
195
|
+
o ||= function() {};
|
|
196
|
+
var s = e.EVENTS.filter(function(e) {
|
|
197
|
+
return e !== "error" && e !== "end";
|
|
198
|
+
});
|
|
199
|
+
function c(e, t) {
|
|
200
|
+
return new u(e, t);
|
|
201
|
+
}
|
|
202
|
+
function l(e, t) {
|
|
203
|
+
if (e.length >= 2) {
|
|
204
|
+
if (e[0] === 255 && e[1] === 254) return "utf-16le";
|
|
205
|
+
if (e[0] === 254 && e[1] === 255) return "utf-16be";
|
|
206
|
+
}
|
|
207
|
+
return e.length >= 3 && e[0] === 239 && e[1] === 187 && e[2] === 191 ? "utf8" : e.length >= 4 ? e[0] === 60 && e[1] === 0 && e[2] === 63 && e[3] === 0 ? "utf-16le" : e[0] === 0 && e[1] === 60 && e[2] === 0 && e[3] === 63 ? "utf-16be" : "utf8" : t ? "utf8" : null;
|
|
208
|
+
}
|
|
209
|
+
function u(e, t) {
|
|
210
|
+
if (!(this instanceof u)) return new u(e, t);
|
|
211
|
+
o.apply(this), this._parser = new n(e, t), this.writable = !0, this.readable = !0;
|
|
212
|
+
var r = this;
|
|
213
|
+
this._parser.onend = function() {
|
|
214
|
+
r.emit("end");
|
|
215
|
+
}, this._parser.onerror = function(e) {
|
|
216
|
+
r.emit("error", e), r._parser.error = null;
|
|
217
|
+
}, this._decoder = null, this._decoderBuffer = null, s.forEach(function(e) {
|
|
218
|
+
Object.defineProperty(r, "on" + e, {
|
|
219
|
+
get: function() {
|
|
220
|
+
return r._parser["on" + e];
|
|
221
|
+
},
|
|
222
|
+
set: function(t) {
|
|
223
|
+
if (!t) return r.removeAllListeners(e), r._parser["on" + e] = t, t;
|
|
224
|
+
r.on(e, t);
|
|
225
|
+
},
|
|
226
|
+
enumerable: !0,
|
|
227
|
+
configurable: !1
|
|
228
|
+
});
|
|
229
|
+
});
|
|
230
|
+
}
|
|
231
|
+
u.prototype = Object.create(o.prototype, { constructor: { value: u } }), u.prototype._decodeBuffer = function(e, t) {
|
|
232
|
+
if (this._decoderBuffer &&= (e = Buffer.concat([this._decoderBuffer, e]), null), !this._decoder) {
|
|
233
|
+
var n = l(e, t);
|
|
234
|
+
if (!n) return this._decoderBuffer = e, "";
|
|
235
|
+
this._parser.encoding = n, this._decoder = new TextDecoder(n);
|
|
236
|
+
}
|
|
237
|
+
return this._decoder.decode(e, { stream: !t });
|
|
238
|
+
}, u.prototype.write = function(e) {
|
|
239
|
+
if (typeof Buffer == "function" && typeof Buffer.isBuffer == "function" && Buffer.isBuffer(e)) e = this._decodeBuffer(e, !1);
|
|
240
|
+
else if (this._decoderBuffer) {
|
|
241
|
+
var t = this._decodeBuffer(Buffer.alloc(0), !0);
|
|
242
|
+
t && (this._parser.write(t), this.emit("data", t));
|
|
243
|
+
}
|
|
244
|
+
return this._parser.write(e.toString()), this.emit("data", e), !0;
|
|
245
|
+
}, u.prototype.end = function(e) {
|
|
246
|
+
if (e && e.length && this.write(e), this._decoderBuffer) {
|
|
247
|
+
var t = this._decodeBuffer(Buffer.alloc(0), !0);
|
|
248
|
+
t && (this._parser.write(t), this.emit("data", t));
|
|
249
|
+
} else if (this._decoder) {
|
|
250
|
+
var n = this._decoder.decode();
|
|
251
|
+
n && (this._parser.write(n), this.emit("data", n));
|
|
252
|
+
}
|
|
253
|
+
return this._parser.end(), !0;
|
|
254
|
+
}, u.prototype.on = function(e, t) {
|
|
255
|
+
var n = this;
|
|
256
|
+
return !n._parser["on" + e] && s.indexOf(e) !== -1 && (n._parser["on" + e] = function() {
|
|
257
|
+
var t = arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);
|
|
258
|
+
t.splice(0, 0, e), n.emit.apply(n, t);
|
|
259
|
+
}), o.prototype.on.call(n, e, t);
|
|
260
|
+
};
|
|
261
|
+
var d = "[CDATA[", f = "DOCTYPE", p = "http://www.w3.org/XML/1998/namespace", m = "http://www.w3.org/2000/xmlns/", h = {
|
|
262
|
+
xml: p,
|
|
263
|
+
xmlns: m
|
|
264
|
+
}, g = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/, _ = /[:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/, v = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]/, y = /[#:_A-Za-z\u00C0-\u00D6\u00D8-\u00F6\u00F8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C-\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD\u00B7\u0300-\u036F\u203F-\u2040.\d-]/;
|
|
265
|
+
function b(e) {
|
|
266
|
+
return e === " " || e === "\n" || e === "\r" || e === " ";
|
|
267
|
+
}
|
|
268
|
+
function S(e) {
|
|
269
|
+
return e === "\"" || e === "'";
|
|
270
|
+
}
|
|
271
|
+
function C(e) {
|
|
272
|
+
return e === ">" || b(e);
|
|
273
|
+
}
|
|
274
|
+
function w(e, t) {
|
|
275
|
+
return e.test(t);
|
|
276
|
+
}
|
|
277
|
+
function T(e, t) {
|
|
278
|
+
return !w(e, t);
|
|
279
|
+
}
|
|
280
|
+
var E = 0;
|
|
281
|
+
for (var D in e.STATE = {
|
|
282
|
+
BEGIN: E++,
|
|
283
|
+
BEGIN_WHITESPACE: E++,
|
|
284
|
+
TEXT: E++,
|
|
285
|
+
TEXT_ENTITY: E++,
|
|
286
|
+
OPEN_WAKA: E++,
|
|
287
|
+
SGML_DECL: E++,
|
|
288
|
+
SGML_DECL_QUOTED: E++,
|
|
289
|
+
DOCTYPE: E++,
|
|
290
|
+
DOCTYPE_QUOTED: E++,
|
|
291
|
+
DOCTYPE_DTD: E++,
|
|
292
|
+
DOCTYPE_DTD_QUOTED: E++,
|
|
293
|
+
COMMENT_STARTING: E++,
|
|
294
|
+
COMMENT: E++,
|
|
295
|
+
COMMENT_ENDING: E++,
|
|
296
|
+
COMMENT_ENDED: E++,
|
|
297
|
+
CDATA: E++,
|
|
298
|
+
CDATA_ENDING: E++,
|
|
299
|
+
CDATA_ENDING_2: E++,
|
|
300
|
+
PROC_INST: E++,
|
|
301
|
+
PROC_INST_BODY: E++,
|
|
302
|
+
PROC_INST_ENDING: E++,
|
|
303
|
+
OPEN_TAG: E++,
|
|
304
|
+
OPEN_TAG_SLASH: E++,
|
|
305
|
+
ATTRIB: E++,
|
|
306
|
+
ATTRIB_NAME: E++,
|
|
307
|
+
ATTRIB_NAME_SAW_WHITE: E++,
|
|
308
|
+
ATTRIB_VALUE: E++,
|
|
309
|
+
ATTRIB_VALUE_QUOTED: E++,
|
|
310
|
+
ATTRIB_VALUE_CLOSED: E++,
|
|
311
|
+
ATTRIB_VALUE_UNQUOTED: E++,
|
|
312
|
+
ATTRIB_VALUE_ENTITY_Q: E++,
|
|
313
|
+
ATTRIB_VALUE_ENTITY_U: E++,
|
|
314
|
+
CLOSE_TAG: E++,
|
|
315
|
+
CLOSE_TAG_SAW_WHITE: E++,
|
|
316
|
+
SCRIPT: E++,
|
|
317
|
+
SCRIPT_ENDING: E++
|
|
318
|
+
}, e.XML_ENTITIES = {
|
|
319
|
+
amp: "&",
|
|
320
|
+
gt: ">",
|
|
321
|
+
lt: "<",
|
|
322
|
+
quot: "\"",
|
|
323
|
+
apos: "'"
|
|
324
|
+
}, e.ENTITIES = {
|
|
325
|
+
amp: "&",
|
|
326
|
+
gt: ">",
|
|
327
|
+
lt: "<",
|
|
328
|
+
quot: "\"",
|
|
329
|
+
apos: "'",
|
|
330
|
+
AElig: 198,
|
|
331
|
+
Aacute: 193,
|
|
332
|
+
Acirc: 194,
|
|
333
|
+
Agrave: 192,
|
|
334
|
+
Aring: 197,
|
|
335
|
+
Atilde: 195,
|
|
336
|
+
Auml: 196,
|
|
337
|
+
Ccedil: 199,
|
|
338
|
+
ETH: 208,
|
|
339
|
+
Eacute: 201,
|
|
340
|
+
Ecirc: 202,
|
|
341
|
+
Egrave: 200,
|
|
342
|
+
Euml: 203,
|
|
343
|
+
Iacute: 205,
|
|
344
|
+
Icirc: 206,
|
|
345
|
+
Igrave: 204,
|
|
346
|
+
Iuml: 207,
|
|
347
|
+
Ntilde: 209,
|
|
348
|
+
Oacute: 211,
|
|
349
|
+
Ocirc: 212,
|
|
350
|
+
Ograve: 210,
|
|
351
|
+
Oslash: 216,
|
|
352
|
+
Otilde: 213,
|
|
353
|
+
Ouml: 214,
|
|
354
|
+
THORN: 222,
|
|
355
|
+
Uacute: 218,
|
|
356
|
+
Ucirc: 219,
|
|
357
|
+
Ugrave: 217,
|
|
358
|
+
Uuml: 220,
|
|
359
|
+
Yacute: 221,
|
|
360
|
+
aacute: 225,
|
|
361
|
+
acirc: 226,
|
|
362
|
+
aelig: 230,
|
|
363
|
+
agrave: 224,
|
|
364
|
+
aring: 229,
|
|
365
|
+
atilde: 227,
|
|
366
|
+
auml: 228,
|
|
367
|
+
ccedil: 231,
|
|
368
|
+
eacute: 233,
|
|
369
|
+
ecirc: 234,
|
|
370
|
+
egrave: 232,
|
|
371
|
+
eth: 240,
|
|
372
|
+
euml: 235,
|
|
373
|
+
iacute: 237,
|
|
374
|
+
icirc: 238,
|
|
375
|
+
igrave: 236,
|
|
376
|
+
iuml: 239,
|
|
377
|
+
ntilde: 241,
|
|
378
|
+
oacute: 243,
|
|
379
|
+
ocirc: 244,
|
|
380
|
+
ograve: 242,
|
|
381
|
+
oslash: 248,
|
|
382
|
+
otilde: 245,
|
|
383
|
+
ouml: 246,
|
|
384
|
+
szlig: 223,
|
|
385
|
+
thorn: 254,
|
|
386
|
+
uacute: 250,
|
|
387
|
+
ucirc: 251,
|
|
388
|
+
ugrave: 249,
|
|
389
|
+
uuml: 252,
|
|
390
|
+
yacute: 253,
|
|
391
|
+
yuml: 255,
|
|
392
|
+
copy: 169,
|
|
393
|
+
reg: 174,
|
|
394
|
+
nbsp: 160,
|
|
395
|
+
iexcl: 161,
|
|
396
|
+
cent: 162,
|
|
397
|
+
pound: 163,
|
|
398
|
+
curren: 164,
|
|
399
|
+
yen: 165,
|
|
400
|
+
brvbar: 166,
|
|
401
|
+
sect: 167,
|
|
402
|
+
uml: 168,
|
|
403
|
+
ordf: 170,
|
|
404
|
+
laquo: 171,
|
|
405
|
+
not: 172,
|
|
406
|
+
shy: 173,
|
|
407
|
+
macr: 175,
|
|
408
|
+
deg: 176,
|
|
409
|
+
plusmn: 177,
|
|
410
|
+
sup1: 185,
|
|
411
|
+
sup2: 178,
|
|
412
|
+
sup3: 179,
|
|
413
|
+
acute: 180,
|
|
414
|
+
micro: 181,
|
|
415
|
+
para: 182,
|
|
416
|
+
middot: 183,
|
|
417
|
+
cedil: 184,
|
|
418
|
+
ordm: 186,
|
|
419
|
+
raquo: 187,
|
|
420
|
+
frac14: 188,
|
|
421
|
+
frac12: 189,
|
|
422
|
+
frac34: 190,
|
|
423
|
+
iquest: 191,
|
|
424
|
+
times: 215,
|
|
425
|
+
divide: 247,
|
|
426
|
+
OElig: 338,
|
|
427
|
+
oelig: 339,
|
|
428
|
+
Scaron: 352,
|
|
429
|
+
scaron: 353,
|
|
430
|
+
Yuml: 376,
|
|
431
|
+
fnof: 402,
|
|
432
|
+
circ: 710,
|
|
433
|
+
tilde: 732,
|
|
434
|
+
Alpha: 913,
|
|
435
|
+
Beta: 914,
|
|
436
|
+
Gamma: 915,
|
|
437
|
+
Delta: 916,
|
|
438
|
+
Epsilon: 917,
|
|
439
|
+
Zeta: 918,
|
|
440
|
+
Eta: 919,
|
|
441
|
+
Theta: 920,
|
|
442
|
+
Iota: 921,
|
|
443
|
+
Kappa: 922,
|
|
444
|
+
Lambda: 923,
|
|
445
|
+
Mu: 924,
|
|
446
|
+
Nu: 925,
|
|
447
|
+
Xi: 926,
|
|
448
|
+
Omicron: 927,
|
|
449
|
+
Pi: 928,
|
|
450
|
+
Rho: 929,
|
|
451
|
+
Sigma: 931,
|
|
452
|
+
Tau: 932,
|
|
453
|
+
Upsilon: 933,
|
|
454
|
+
Phi: 934,
|
|
455
|
+
Chi: 935,
|
|
456
|
+
Psi: 936,
|
|
457
|
+
Omega: 937,
|
|
458
|
+
alpha: 945,
|
|
459
|
+
beta: 946,
|
|
460
|
+
gamma: 947,
|
|
461
|
+
delta: 948,
|
|
462
|
+
epsilon: 949,
|
|
463
|
+
zeta: 950,
|
|
464
|
+
eta: 951,
|
|
465
|
+
theta: 952,
|
|
466
|
+
iota: 953,
|
|
467
|
+
kappa: 954,
|
|
468
|
+
lambda: 955,
|
|
469
|
+
mu: 956,
|
|
470
|
+
nu: 957,
|
|
471
|
+
xi: 958,
|
|
472
|
+
omicron: 959,
|
|
473
|
+
pi: 960,
|
|
474
|
+
rho: 961,
|
|
475
|
+
sigmaf: 962,
|
|
476
|
+
sigma: 963,
|
|
477
|
+
tau: 964,
|
|
478
|
+
upsilon: 965,
|
|
479
|
+
phi: 966,
|
|
480
|
+
chi: 967,
|
|
481
|
+
psi: 968,
|
|
482
|
+
omega: 969,
|
|
483
|
+
thetasym: 977,
|
|
484
|
+
upsih: 978,
|
|
485
|
+
piv: 982,
|
|
486
|
+
ensp: 8194,
|
|
487
|
+
emsp: 8195,
|
|
488
|
+
thinsp: 8201,
|
|
489
|
+
zwnj: 8204,
|
|
490
|
+
zwj: 8205,
|
|
491
|
+
lrm: 8206,
|
|
492
|
+
rlm: 8207,
|
|
493
|
+
ndash: 8211,
|
|
494
|
+
mdash: 8212,
|
|
495
|
+
lsquo: 8216,
|
|
496
|
+
rsquo: 8217,
|
|
497
|
+
sbquo: 8218,
|
|
498
|
+
ldquo: 8220,
|
|
499
|
+
rdquo: 8221,
|
|
500
|
+
bdquo: 8222,
|
|
501
|
+
dagger: 8224,
|
|
502
|
+
Dagger: 8225,
|
|
503
|
+
bull: 8226,
|
|
504
|
+
hellip: 8230,
|
|
505
|
+
permil: 8240,
|
|
506
|
+
prime: 8242,
|
|
507
|
+
Prime: 8243,
|
|
508
|
+
lsaquo: 8249,
|
|
509
|
+
rsaquo: 8250,
|
|
510
|
+
oline: 8254,
|
|
511
|
+
frasl: 8260,
|
|
512
|
+
euro: 8364,
|
|
513
|
+
image: 8465,
|
|
514
|
+
weierp: 8472,
|
|
515
|
+
real: 8476,
|
|
516
|
+
trade: 8482,
|
|
517
|
+
alefsym: 8501,
|
|
518
|
+
larr: 8592,
|
|
519
|
+
uarr: 8593,
|
|
520
|
+
rarr: 8594,
|
|
521
|
+
darr: 8595,
|
|
522
|
+
harr: 8596,
|
|
523
|
+
crarr: 8629,
|
|
524
|
+
lArr: 8656,
|
|
525
|
+
uArr: 8657,
|
|
526
|
+
rArr: 8658,
|
|
527
|
+
dArr: 8659,
|
|
528
|
+
hArr: 8660,
|
|
529
|
+
forall: 8704,
|
|
530
|
+
part: 8706,
|
|
531
|
+
exist: 8707,
|
|
532
|
+
empty: 8709,
|
|
533
|
+
nabla: 8711,
|
|
534
|
+
isin: 8712,
|
|
535
|
+
notin: 8713,
|
|
536
|
+
ni: 8715,
|
|
537
|
+
prod: 8719,
|
|
538
|
+
sum: 8721,
|
|
539
|
+
minus: 8722,
|
|
540
|
+
lowast: 8727,
|
|
541
|
+
radic: 8730,
|
|
542
|
+
prop: 8733,
|
|
543
|
+
infin: 8734,
|
|
544
|
+
ang: 8736,
|
|
545
|
+
and: 8743,
|
|
546
|
+
or: 8744,
|
|
547
|
+
cap: 8745,
|
|
548
|
+
cup: 8746,
|
|
549
|
+
int: 8747,
|
|
550
|
+
there4: 8756,
|
|
551
|
+
sim: 8764,
|
|
552
|
+
cong: 8773,
|
|
553
|
+
asymp: 8776,
|
|
554
|
+
ne: 8800,
|
|
555
|
+
equiv: 8801,
|
|
556
|
+
le: 8804,
|
|
557
|
+
ge: 8805,
|
|
558
|
+
sub: 8834,
|
|
559
|
+
sup: 8835,
|
|
560
|
+
nsub: 8836,
|
|
561
|
+
sube: 8838,
|
|
562
|
+
supe: 8839,
|
|
563
|
+
oplus: 8853,
|
|
564
|
+
otimes: 8855,
|
|
565
|
+
perp: 8869,
|
|
566
|
+
sdot: 8901,
|
|
567
|
+
lceil: 8968,
|
|
568
|
+
rceil: 8969,
|
|
569
|
+
lfloor: 8970,
|
|
570
|
+
rfloor: 8971,
|
|
571
|
+
lang: 9001,
|
|
572
|
+
rang: 9002,
|
|
573
|
+
loz: 9674,
|
|
574
|
+
spades: 9824,
|
|
575
|
+
clubs: 9827,
|
|
576
|
+
hearts: 9829,
|
|
577
|
+
diams: 9830
|
|
578
|
+
}, Object.keys(e.ENTITIES).forEach(function(t) {
|
|
579
|
+
var n = e.ENTITIES[t], r = typeof n == "number" ? String.fromCharCode(n) : n;
|
|
580
|
+
e.ENTITIES[t] = r;
|
|
581
|
+
}), e.STATE) e.STATE[e.STATE[D]] = D;
|
|
582
|
+
E = e.STATE;
|
|
583
|
+
function O(e, t, n) {
|
|
584
|
+
e[t] && e[t](n);
|
|
585
|
+
}
|
|
586
|
+
function k(e) {
|
|
587
|
+
var t = e && e.match(/(?:^|\s)encoding\s*=\s*(['"])([^'"]+)\1/i);
|
|
588
|
+
return t ? t[2] : null;
|
|
589
|
+
}
|
|
590
|
+
function A(e) {
|
|
591
|
+
return e ? e.toLowerCase().replace(/[^a-z0-9]/g, "") : null;
|
|
592
|
+
}
|
|
593
|
+
function j(e, t) {
|
|
594
|
+
let n = A(e), r = A(t);
|
|
595
|
+
return !n || !r ? !0 : r === "utf16" ? n === "utf16le" || n === "utf16be" : n === r;
|
|
596
|
+
}
|
|
597
|
+
function M(e, t) {
|
|
598
|
+
if (!(!e.strict || !e.encoding || !t || t.name !== "xml")) {
|
|
599
|
+
var n = k(t.body);
|
|
600
|
+
n && !j(e.encoding, n) && R(e, "XML declaration encoding " + n + " does not match detected stream encoding " + e.encoding.toUpperCase());
|
|
601
|
+
}
|
|
602
|
+
}
|
|
603
|
+
function N(e, t, n) {
|
|
604
|
+
e.textNode && P(e), O(e, t, n);
|
|
605
|
+
}
|
|
606
|
+
function P(e) {
|
|
607
|
+
e.textNode = F(e.opt, e.textNode), e.textNode && O(e, "ontext", e.textNode), e.textNode = "";
|
|
608
|
+
}
|
|
609
|
+
function F(e, t) {
|
|
610
|
+
return e.trim && (t = t.trim()), e.normalize && (t = t.replace(/\s+/g, " ")), t;
|
|
611
|
+
}
|
|
612
|
+
function I(e, t) {
|
|
613
|
+
return P(e), e.trackPosition && (t += "\nLine: " + e.line + "\nColumn: " + e.column + "\nChar: " + e.c), t = Error(t), e.error = t, O(e, "onerror", t), e;
|
|
614
|
+
}
|
|
615
|
+
function L(e) {
|
|
616
|
+
return e.sawRoot && !e.closedRoot && R(e, "Unclosed root tag"), e.state !== E.BEGIN && e.state !== E.BEGIN_WHITESPACE && e.state !== E.TEXT && I(e, "Unexpected end"), P(e), e.c = "", e.closed = !0, O(e, "onend"), n.call(e, e.strict, e.opt), e;
|
|
617
|
+
}
|
|
618
|
+
function R(e, t) {
|
|
619
|
+
if (typeof e != "object" || !(e instanceof n)) throw Error("bad call to strictFail");
|
|
620
|
+
e.strict && I(e, t);
|
|
621
|
+
}
|
|
622
|
+
function z(e) {
|
|
623
|
+
e.strict || (e.tagName = e.tagName[e.looseCase]());
|
|
624
|
+
var t = e.tags[e.tags.length - 1] || e, n = e.tag = {
|
|
625
|
+
name: e.tagName,
|
|
626
|
+
attributes: {}
|
|
627
|
+
};
|
|
628
|
+
e.opt.xmlns && (n.ns = t.ns), e.attribList.length = 0, N(e, "onopentagstart", n);
|
|
629
|
+
}
|
|
630
|
+
function B(e, t) {
|
|
631
|
+
var n = e.indexOf(":") < 0 ? ["", e] : e.split(":"), r = n[0], i = n[1];
|
|
632
|
+
return t && e === "xmlns" && (r = "xmlns", i = ""), {
|
|
633
|
+
prefix: r,
|
|
634
|
+
local: i
|
|
635
|
+
};
|
|
636
|
+
}
|
|
637
|
+
function V(e) {
|
|
638
|
+
if (e.strict || (e.attribName = e.attribName[e.looseCase]()), e.attribList.indexOf(e.attribName) !== -1 || e.tag.attributes.hasOwnProperty(e.attribName)) {
|
|
639
|
+
e.attribName = e.attribValue = "";
|
|
640
|
+
return;
|
|
641
|
+
}
|
|
642
|
+
if (e.opt.xmlns) {
|
|
643
|
+
var t = B(e.attribName, !0), n = t.prefix, r = t.local;
|
|
644
|
+
if (n === "xmlns") if (r === "xml" && e.attribValue !== p) R(e, "xml: prefix must be bound to " + p + "\nActual: " + e.attribValue);
|
|
645
|
+
else if (r === "xmlns" && e.attribValue !== m) R(e, "xmlns: prefix must be bound to " + m + "\nActual: " + e.attribValue);
|
|
646
|
+
else {
|
|
647
|
+
var i = e.tag, a = e.tags[e.tags.length - 1] || e;
|
|
648
|
+
i.ns === a.ns && (i.ns = Object.create(a.ns)), i.ns[r] = e.attribValue;
|
|
649
|
+
}
|
|
650
|
+
e.attribList.push([e.attribName, e.attribValue]);
|
|
651
|
+
} else e.tag.attributes[e.attribName] = e.attribValue, N(e, "onattribute", {
|
|
652
|
+
name: e.attribName,
|
|
653
|
+
value: e.attribValue
|
|
654
|
+
});
|
|
655
|
+
e.attribName = e.attribValue = "";
|
|
656
|
+
}
|
|
657
|
+
function H(e, t) {
|
|
658
|
+
if (e.opt.xmlns) {
|
|
659
|
+
var n = e.tag, r = B(e.tagName);
|
|
660
|
+
n.prefix = r.prefix, n.local = r.local, n.uri = n.ns[r.prefix] || "", n.prefix && !n.uri && (R(e, "Unbound namespace prefix: " + JSON.stringify(e.tagName)), n.uri = r.prefix);
|
|
661
|
+
var i = e.tags[e.tags.length - 1] || e;
|
|
662
|
+
n.ns && i.ns !== n.ns && Object.keys(n.ns).forEach(function(t) {
|
|
663
|
+
N(e, "onopennamespace", {
|
|
664
|
+
prefix: t,
|
|
665
|
+
uri: n.ns[t]
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
for (var a = 0, o = e.attribList.length; a < o; a++) {
|
|
669
|
+
var s = e.attribList[a], c = s[0], l = s[1], u = B(c, !0), d = u.prefix, f = u.local, p = d === "" ? "" : n.ns[d] || "", m = {
|
|
670
|
+
name: c,
|
|
671
|
+
value: l,
|
|
672
|
+
prefix: d,
|
|
673
|
+
local: f,
|
|
674
|
+
uri: p
|
|
675
|
+
};
|
|
676
|
+
d && d !== "xmlns" && !p && (R(e, "Unbound namespace prefix: " + JSON.stringify(d)), m.uri = d), e.tag.attributes[c] = m, N(e, "onattribute", m);
|
|
677
|
+
}
|
|
678
|
+
e.attribList.length = 0;
|
|
679
|
+
}
|
|
680
|
+
e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), N(e, "onopentag", e.tag), t || (!e.noscript && e.tagName.toLowerCase() === "script" ? e.state = E.SCRIPT : e.state = E.TEXT, e.tag = null, e.tagName = ""), e.attribName = e.attribValue = "", e.attribList.length = 0;
|
|
681
|
+
}
|
|
682
|
+
function U(e) {
|
|
683
|
+
if (!e.tagName) {
|
|
684
|
+
R(e, "Weird empty close tag."), e.textNode += "</>", e.state = E.TEXT;
|
|
685
|
+
return;
|
|
686
|
+
}
|
|
687
|
+
if (e.script) {
|
|
688
|
+
if (e.tagName !== "script") {
|
|
689
|
+
e.script += "</" + e.tagName + ">", e.tagName = "", e.state = E.SCRIPT;
|
|
690
|
+
return;
|
|
691
|
+
}
|
|
692
|
+
N(e, "onscript", e.script), e.script = "";
|
|
693
|
+
}
|
|
694
|
+
var t = e.tags.length, n = e.tagName;
|
|
695
|
+
e.strict || (n = n[e.looseCase]());
|
|
696
|
+
for (var r = n; t-- && e.tags[t].name !== r;) R(e, "Unexpected close tag");
|
|
697
|
+
if (t < 0) {
|
|
698
|
+
R(e, "Unmatched closing tag: " + e.tagName), e.textNode += "</" + e.tagName + ">", e.state = E.TEXT;
|
|
699
|
+
return;
|
|
700
|
+
}
|
|
701
|
+
e.tagName = n;
|
|
702
|
+
for (var i = e.tags.length; i-- > t;) {
|
|
703
|
+
var a = e.tag = e.tags.pop();
|
|
704
|
+
e.tagName = e.tag.name, N(e, "onclosetag", e.tagName);
|
|
705
|
+
var o = {};
|
|
706
|
+
for (var s in a.ns) o[s] = a.ns[s];
|
|
707
|
+
var c = e.tags[e.tags.length - 1] || e;
|
|
708
|
+
e.opt.xmlns && a.ns !== c.ns && Object.keys(a.ns).forEach(function(t) {
|
|
709
|
+
var n = a.ns[t];
|
|
710
|
+
N(e, "onclosenamespace", {
|
|
711
|
+
prefix: t,
|
|
712
|
+
uri: n
|
|
713
|
+
});
|
|
714
|
+
});
|
|
715
|
+
}
|
|
716
|
+
t === 0 && (e.closedRoot = !0), e.tagName = e.attribValue = e.attribName = "", e.attribList.length = 0, e.state = E.TEXT;
|
|
717
|
+
}
|
|
718
|
+
function W(e) {
|
|
719
|
+
var t = e.entity, n = t.toLowerCase(), r, i = "";
|
|
720
|
+
return e.ENTITIES[t] ? e.ENTITIES[t] : e.ENTITIES[n] ? e.ENTITIES[n] : (t = n, t.charAt(0) === "#" && (t.charAt(1) === "x" ? (t = t.slice(2), r = parseInt(t, 16), i = r.toString(16)) : (t = t.slice(1), r = parseInt(t, 10), i = r.toString(10))), t = t.replace(/^0+/, ""), isNaN(r) || i.toLowerCase() !== t || r < 0 || r > 1114111 ? (R(e, "Invalid character entity"), "&" + e.entity + ";") : String.fromCodePoint(r));
|
|
721
|
+
}
|
|
722
|
+
function G(e, t) {
|
|
723
|
+
t === "<" ? (e.state = E.OPEN_WAKA, e.startTagPosition = e.position) : b(t) || (R(e, "Non-whitespace before first tag."), e.textNode = t, e.state = E.TEXT);
|
|
724
|
+
}
|
|
725
|
+
function K(e, t) {
|
|
726
|
+
var n = "";
|
|
727
|
+
return t < e.length && (n = e.charAt(t)), n;
|
|
728
|
+
}
|
|
729
|
+
function q(t) {
|
|
730
|
+
var n = this;
|
|
731
|
+
if (this.error) throw this.error;
|
|
732
|
+
if (n.closed) return I(n, "Cannot write after close. Assign an onready handler.");
|
|
733
|
+
if (t === null) return L(n);
|
|
734
|
+
typeof t == "object" && (t = t.toString());
|
|
735
|
+
for (var i = 0, a = ""; a = K(t, i++), n.c = a, a;) switch (n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++), n.state) {
|
|
736
|
+
case E.BEGIN:
|
|
737
|
+
if (n.state = E.BEGIN_WHITESPACE, a === "") continue;
|
|
738
|
+
G(n, a);
|
|
739
|
+
continue;
|
|
740
|
+
case E.BEGIN_WHITESPACE:
|
|
741
|
+
G(n, a);
|
|
742
|
+
continue;
|
|
743
|
+
case E.TEXT:
|
|
744
|
+
if (n.sawRoot && !n.closedRoot) {
|
|
745
|
+
for (var o = i - 1; a && a !== "<" && a !== "&";) a = K(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
|
|
746
|
+
n.textNode += t.substring(o, i - 1);
|
|
747
|
+
}
|
|
748
|
+
a === "<" && !(n.sawRoot && n.closedRoot && !n.strict) ? (n.state = E.OPEN_WAKA, n.startTagPosition = n.position) : (!b(a) && (!n.sawRoot || n.closedRoot) && R(n, "Text data outside of root node."), a === "&" ? n.state = E.TEXT_ENTITY : n.textNode += a);
|
|
749
|
+
continue;
|
|
750
|
+
case E.SCRIPT:
|
|
751
|
+
a === "<" ? n.state = E.SCRIPT_ENDING : n.script += a;
|
|
752
|
+
continue;
|
|
753
|
+
case E.SCRIPT_ENDING:
|
|
754
|
+
a === "/" ? n.state = E.CLOSE_TAG : (n.script += "<" + a, n.state = E.SCRIPT);
|
|
755
|
+
continue;
|
|
756
|
+
case E.OPEN_WAKA:
|
|
757
|
+
if (a === "!") n.state = E.SGML_DECL, n.sgmlDecl = "";
|
|
758
|
+
else if (!b(a)) if (w(g, a)) n.state = E.OPEN_TAG, n.tagName = a;
|
|
759
|
+
else if (a === "/") n.state = E.CLOSE_TAG, n.tagName = "";
|
|
760
|
+
else if (a === "?") n.state = E.PROC_INST, n.procInstName = n.procInstBody = "";
|
|
761
|
+
else {
|
|
762
|
+
if (R(n, "Unencoded <"), n.startTagPosition + 1 < n.position) {
|
|
763
|
+
var s = n.position - n.startTagPosition;
|
|
764
|
+
a = Array(s).join(" ") + a;
|
|
765
|
+
}
|
|
766
|
+
n.textNode += "<" + a, n.state = E.TEXT;
|
|
767
|
+
}
|
|
768
|
+
continue;
|
|
769
|
+
case E.SGML_DECL:
|
|
770
|
+
if (n.sgmlDecl + a === "--") {
|
|
771
|
+
n.state = E.COMMENT, n.comment = "", n.sgmlDecl = "";
|
|
772
|
+
continue;
|
|
773
|
+
}
|
|
774
|
+
n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = E.DOCTYPE_DTD, n.doctype += "<!" + n.sgmlDecl + a, n.sgmlDecl = "") : (n.sgmlDecl + a).toUpperCase() === d ? (N(n, "onopencdata"), n.state = E.CDATA, n.sgmlDecl = "", n.cdata = "") : (n.sgmlDecl + a).toUpperCase() === f ? (n.state = E.DOCTYPE, (n.doctype || n.sawRoot) && R(n, "Inappropriately located doctype declaration"), n.doctype = "", n.sgmlDecl = "") : a === ">" ? (N(n, "onsgmldeclaration", n.sgmlDecl), n.sgmlDecl = "", n.state = E.TEXT) : (S(a) && (n.state = E.SGML_DECL_QUOTED), n.sgmlDecl += a);
|
|
775
|
+
continue;
|
|
776
|
+
case E.SGML_DECL_QUOTED:
|
|
777
|
+
a === n.q && (n.state = E.SGML_DECL, n.q = ""), n.sgmlDecl += a;
|
|
778
|
+
continue;
|
|
779
|
+
case E.DOCTYPE:
|
|
780
|
+
a === ">" ? (n.state = E.TEXT, N(n, "ondoctype", n.doctype), n.doctype = !0) : (n.doctype += a, a === "[" ? n.state = E.DOCTYPE_DTD : S(a) && (n.state = E.DOCTYPE_QUOTED, n.q = a));
|
|
781
|
+
continue;
|
|
782
|
+
case E.DOCTYPE_QUOTED:
|
|
783
|
+
n.doctype += a, a === n.q && (n.q = "", n.state = E.DOCTYPE);
|
|
784
|
+
continue;
|
|
785
|
+
case E.DOCTYPE_DTD:
|
|
786
|
+
a === "]" ? (n.doctype += a, n.state = E.DOCTYPE) : a === "<" ? (n.state = E.OPEN_WAKA, n.startTagPosition = n.position) : S(a) ? (n.doctype += a, n.state = E.DOCTYPE_DTD_QUOTED, n.q = a) : n.doctype += a;
|
|
787
|
+
continue;
|
|
788
|
+
case E.DOCTYPE_DTD_QUOTED:
|
|
789
|
+
n.doctype += a, a === n.q && (n.state = E.DOCTYPE_DTD, n.q = "");
|
|
790
|
+
continue;
|
|
791
|
+
case E.COMMENT:
|
|
792
|
+
a === "-" ? n.state = E.COMMENT_ENDING : n.comment += a;
|
|
793
|
+
continue;
|
|
794
|
+
case E.COMMENT_ENDING:
|
|
795
|
+
a === "-" ? (n.state = E.COMMENT_ENDED, n.comment = F(n.opt, n.comment), n.comment && N(n, "oncomment", n.comment), n.comment = "") : (n.comment += "-" + a, n.state = E.COMMENT);
|
|
796
|
+
continue;
|
|
797
|
+
case E.COMMENT_ENDED:
|
|
798
|
+
a === ">" ? n.doctype && n.doctype !== !0 ? n.state = E.DOCTYPE_DTD : n.state = E.TEXT : (R(n, "Malformed comment"), n.comment += "--" + a, n.state = E.COMMENT);
|
|
799
|
+
continue;
|
|
800
|
+
case E.CDATA:
|
|
801
|
+
for (var o = i - 1; a && a !== "]";) a = K(t, i++), a && n.trackPosition && (n.position++, a === "\n" ? (n.line++, n.column = 0) : n.column++);
|
|
802
|
+
n.cdata += t.substring(o, i - 1), a === "]" && (n.state = E.CDATA_ENDING);
|
|
803
|
+
continue;
|
|
804
|
+
case E.CDATA_ENDING:
|
|
805
|
+
a === "]" ? n.state = E.CDATA_ENDING_2 : (n.cdata += "]" + a, n.state = E.CDATA);
|
|
806
|
+
continue;
|
|
807
|
+
case E.CDATA_ENDING_2:
|
|
808
|
+
a === ">" ? (n.cdata && N(n, "oncdata", n.cdata), N(n, "onclosecdata"), n.cdata = "", n.state = E.TEXT) : a === "]" ? n.cdata += "]" : (n.cdata += "]]" + a, n.state = E.CDATA);
|
|
809
|
+
continue;
|
|
810
|
+
case E.PROC_INST:
|
|
811
|
+
a === "?" ? n.state = E.PROC_INST_ENDING : b(a) ? n.state = E.PROC_INST_BODY : n.procInstName += a;
|
|
812
|
+
continue;
|
|
813
|
+
case E.PROC_INST_BODY:
|
|
814
|
+
if (!n.procInstBody && b(a)) continue;
|
|
815
|
+
a === "?" ? n.state = E.PROC_INST_ENDING : n.procInstBody += a;
|
|
816
|
+
continue;
|
|
817
|
+
case E.PROC_INST_ENDING:
|
|
818
|
+
if (a === ">") {
|
|
819
|
+
let e = {
|
|
820
|
+
name: n.procInstName,
|
|
821
|
+
body: n.procInstBody
|
|
822
|
+
};
|
|
823
|
+
M(n, e), N(n, "onprocessinginstruction", e), n.procInstName = n.procInstBody = "", n.state = E.TEXT;
|
|
824
|
+
} else n.procInstBody += "?" + a, n.state = E.PROC_INST_BODY;
|
|
825
|
+
continue;
|
|
826
|
+
case E.OPEN_TAG:
|
|
827
|
+
w(_, a) ? n.tagName += a : (z(n), a === ">" ? H(n) : a === "/" ? n.state = E.OPEN_TAG_SLASH : (b(a) || R(n, "Invalid character in tag name"), n.state = E.ATTRIB));
|
|
828
|
+
continue;
|
|
829
|
+
case E.OPEN_TAG_SLASH:
|
|
830
|
+
a === ">" ? (H(n, !0), U(n)) : (R(n, "Forward-slash in opening tag not followed by >"), n.state = E.ATTRIB);
|
|
831
|
+
continue;
|
|
832
|
+
case E.ATTRIB:
|
|
833
|
+
if (b(a)) continue;
|
|
834
|
+
a === ">" ? H(n) : a === "/" ? n.state = E.OPEN_TAG_SLASH : w(g, a) ? (n.attribName = a, n.attribValue = "", n.state = E.ATTRIB_NAME) : R(n, "Invalid attribute name");
|
|
835
|
+
continue;
|
|
836
|
+
case E.ATTRIB_NAME:
|
|
837
|
+
a === "=" ? n.state = E.ATTRIB_VALUE : a === ">" ? (R(n, "Attribute without value"), n.attribValue = n.attribName, V(n), H(n)) : b(a) ? n.state = E.ATTRIB_NAME_SAW_WHITE : w(_, a) ? n.attribName += a : R(n, "Invalid attribute name");
|
|
838
|
+
continue;
|
|
839
|
+
case E.ATTRIB_NAME_SAW_WHITE:
|
|
840
|
+
if (a === "=") n.state = E.ATTRIB_VALUE;
|
|
841
|
+
else if (b(a)) continue;
|
|
842
|
+
else R(n, "Attribute without value"), n.tag.attributes[n.attribName] = "", n.attribValue = "", N(n, "onattribute", {
|
|
843
|
+
name: n.attribName,
|
|
844
|
+
value: ""
|
|
845
|
+
}), n.attribName = "", a === ">" ? H(n) : w(g, a) ? (n.attribName = a, n.state = E.ATTRIB_NAME) : (R(n, "Invalid attribute name"), n.state = E.ATTRIB);
|
|
846
|
+
continue;
|
|
847
|
+
case E.ATTRIB_VALUE:
|
|
848
|
+
if (b(a)) continue;
|
|
849
|
+
S(a) ? (n.q = a, n.state = E.ATTRIB_VALUE_QUOTED) : (n.opt.unquotedAttributeValues || I(n, "Unquoted attribute value"), n.state = E.ATTRIB_VALUE_UNQUOTED, n.attribValue = a);
|
|
850
|
+
continue;
|
|
851
|
+
case E.ATTRIB_VALUE_QUOTED:
|
|
852
|
+
if (a !== n.q) {
|
|
853
|
+
a === "&" ? n.state = E.ATTRIB_VALUE_ENTITY_Q : n.attribValue += a;
|
|
854
|
+
continue;
|
|
855
|
+
}
|
|
856
|
+
V(n), n.q = "", n.state = E.ATTRIB_VALUE_CLOSED;
|
|
857
|
+
continue;
|
|
858
|
+
case E.ATTRIB_VALUE_CLOSED:
|
|
859
|
+
b(a) ? n.state = E.ATTRIB : a === ">" ? H(n) : a === "/" ? n.state = E.OPEN_TAG_SLASH : w(g, a) ? (R(n, "No whitespace between attributes"), n.attribName = a, n.attribValue = "", n.state = E.ATTRIB_NAME) : R(n, "Invalid attribute name");
|
|
860
|
+
continue;
|
|
861
|
+
case E.ATTRIB_VALUE_UNQUOTED:
|
|
862
|
+
if (!C(a)) {
|
|
863
|
+
a === "&" ? n.state = E.ATTRIB_VALUE_ENTITY_U : n.attribValue += a;
|
|
864
|
+
continue;
|
|
865
|
+
}
|
|
866
|
+
V(n), a === ">" ? H(n) : n.state = E.ATTRIB;
|
|
867
|
+
continue;
|
|
868
|
+
case E.CLOSE_TAG:
|
|
869
|
+
if (n.tagName) a === ">" ? U(n) : w(_, a) ? n.tagName += a : n.script ? (n.script += "</" + n.tagName + a, n.tagName = "", n.state = E.SCRIPT) : (b(a) || R(n, "Invalid tagname in closing tag"), n.state = E.CLOSE_TAG_SAW_WHITE);
|
|
870
|
+
else {
|
|
871
|
+
if (b(a)) continue;
|
|
872
|
+
T(g, a) ? n.script ? (n.script += "</" + a, n.state = E.SCRIPT) : R(n, "Invalid tagname in closing tag.") : n.tagName = a;
|
|
873
|
+
}
|
|
874
|
+
continue;
|
|
875
|
+
case E.CLOSE_TAG_SAW_WHITE:
|
|
876
|
+
if (b(a)) continue;
|
|
877
|
+
a === ">" ? U(n) : R(n, "Invalid characters in closing tag");
|
|
878
|
+
continue;
|
|
879
|
+
case E.TEXT_ENTITY:
|
|
880
|
+
case E.ATTRIB_VALUE_ENTITY_Q:
|
|
881
|
+
case E.ATTRIB_VALUE_ENTITY_U:
|
|
882
|
+
var c, l;
|
|
883
|
+
switch (n.state) {
|
|
884
|
+
case E.TEXT_ENTITY:
|
|
885
|
+
c = E.TEXT, l = "textNode";
|
|
886
|
+
break;
|
|
887
|
+
case E.ATTRIB_VALUE_ENTITY_Q:
|
|
888
|
+
c = E.ATTRIB_VALUE_QUOTED, l = "attribValue";
|
|
889
|
+
break;
|
|
890
|
+
case E.ATTRIB_VALUE_ENTITY_U:
|
|
891
|
+
c = E.ATTRIB_VALUE_UNQUOTED, l = "attribValue";
|
|
892
|
+
break;
|
|
893
|
+
}
|
|
894
|
+
if (a === ";") {
|
|
895
|
+
var u = W(n);
|
|
896
|
+
n.opt.unparsedEntities && !Object.values(e.XML_ENTITIES).includes(u) ? ((n.entityCount += 1) > n.opt.maxEntityCount && I(n, "Parsed entity count exceeds max entity count"), (n.entityDepth += 1) > n.opt.maxEntityDepth && I(n, "Parsed entity depth exceeds max entity depth"), n.entity = "", n.state = c, n.write(u), --n.entityDepth) : (n[l] += u, n.entity = "", n.state = c);
|
|
897
|
+
} else w(n.entity.length ? y : v, a) ? n.entity += a : (R(n, "Invalid character in entity name"), n[l] += "&" + n.entity + a, n.entity = "", n.state = c);
|
|
898
|
+
continue;
|
|
899
|
+
default: throw Error(n, "Unknown state: " + n.state);
|
|
900
|
+
}
|
|
901
|
+
return n.position >= n.bufferCheckPosition && r(n), n;
|
|
902
|
+
}
|
|
903
|
+
/* istanbul ignore next */
|
|
904
|
+
String.fromCodePoint || (function() {
|
|
905
|
+
var e = String.fromCharCode, t = Math.floor, n = function() {
|
|
906
|
+
var n = 16384, r = [], i, a, o = -1, s = arguments.length;
|
|
907
|
+
if (!s) return "";
|
|
908
|
+
for (var c = ""; ++o < s;) {
|
|
909
|
+
var l = Number(arguments[o]);
|
|
910
|
+
if (!isFinite(l) || l < 0 || l > 1114111 || t(l) !== l) throw RangeError("Invalid code point: " + l);
|
|
911
|
+
l <= 65535 ? r.push(l) : (l -= 65536, i = (l >> 10) + 55296, a = l % 1024 + 56320, r.push(i, a)), (o + 1 === s || r.length > n) && (c += e.apply(null, r), r.length = 0);
|
|
912
|
+
}
|
|
913
|
+
return c;
|
|
914
|
+
};
|
|
915
|
+
/* istanbul ignore next */
|
|
916
|
+
Object.defineProperty ? Object.defineProperty(String, "fromCodePoint", {
|
|
917
|
+
value: n,
|
|
918
|
+
configurable: !0,
|
|
919
|
+
writable: !0
|
|
920
|
+
}) : String.fromCodePoint = n;
|
|
921
|
+
})();
|
|
922
|
+
})(e === void 0 ? e.sax = {} : e);
|
|
923
|
+
})), P = (/* @__PURE__ */ b(((e) => {
|
|
924
|
+
var t = e && e.__importDefault || function(e) {
|
|
925
|
+
return e && e.__esModule ? e : { default: e };
|
|
926
|
+
};
|
|
927
|
+
Object.defineProperty(e, "__esModule", { value: !0 }), e.XmlDocument = e.XmlElement = e.XmlCommentNode = e.XmlCDataNode = e.XmlTextNode = void 0;
|
|
928
|
+
var n = t(N()), r = class {
|
|
929
|
+
constructor(e) {
|
|
930
|
+
this.text = e, this.type = "text";
|
|
931
|
+
}
|
|
932
|
+
toString(e) {
|
|
933
|
+
return u(l(this.text), e);
|
|
934
|
+
}
|
|
935
|
+
toStringWithIndent(e, t) {
|
|
936
|
+
return e + this.toString(t);
|
|
937
|
+
}
|
|
938
|
+
};
|
|
939
|
+
e.XmlTextNode = r;
|
|
940
|
+
var i = class {
|
|
941
|
+
constructor(e) {
|
|
942
|
+
this.cdata = e, this.type = "cdata";
|
|
943
|
+
}
|
|
944
|
+
toString(e) {
|
|
945
|
+
return `<![CDATA[${u(this.cdata, e)}]]>`;
|
|
946
|
+
}
|
|
947
|
+
toStringWithIndent(e, t) {
|
|
948
|
+
return e + this.toString(t);
|
|
949
|
+
}
|
|
950
|
+
};
|
|
951
|
+
e.XmlCDataNode = i;
|
|
952
|
+
var a = class {
|
|
953
|
+
constructor(e) {
|
|
954
|
+
this.comment = e, this.type = "comment";
|
|
955
|
+
}
|
|
956
|
+
toString(e) {
|
|
957
|
+
return `<!--${u(l(this.comment), e)}-->`;
|
|
958
|
+
}
|
|
959
|
+
toStringWithIndent(e, t) {
|
|
960
|
+
return e + this.toString(t);
|
|
961
|
+
}
|
|
962
|
+
};
|
|
963
|
+
e.XmlCommentNode = a;
|
|
964
|
+
var o = class e {
|
|
965
|
+
constructor(e, t) {
|
|
966
|
+
if (this.type = "element", !t && s.length) {
|
|
967
|
+
var n = s[s.length - 1];
|
|
968
|
+
"parser" in n && (t = n.parser);
|
|
969
|
+
}
|
|
970
|
+
this.name = e.name, this.attr = e.attributes, this.val = "", this.children = [], this.firstChild = null, this.lastChild = null, this.line = t ? t.line : null, this.column = t ? t.column : null, this.position = t ? t.position : null, this.startTagPosition = t ? t.startTagPosition : null;
|
|
971
|
+
}
|
|
972
|
+
_addChild(e) {
|
|
973
|
+
this.children.push(e), this.firstChild ||= e, this.lastChild = e;
|
|
974
|
+
}
|
|
975
|
+
_opentag(t) {
|
|
976
|
+
let n = new e(t);
|
|
977
|
+
this._addChild(n), s.unshift(n);
|
|
978
|
+
}
|
|
979
|
+
_closetag() {
|
|
980
|
+
s.shift();
|
|
981
|
+
}
|
|
982
|
+
_text(e) {
|
|
983
|
+
this.val += e, this._addChild(new r(e));
|
|
984
|
+
}
|
|
985
|
+
_cdata(e) {
|
|
986
|
+
this.val += e, this._addChild(new i(e));
|
|
987
|
+
}
|
|
988
|
+
_comment(e) {
|
|
989
|
+
this._addChild(new a(e));
|
|
990
|
+
}
|
|
991
|
+
_error(e) {
|
|
992
|
+
throw e;
|
|
993
|
+
}
|
|
994
|
+
eachChild(e, t) {
|
|
995
|
+
for (let n = 0, r = this.children.length; n < r; n++) {
|
|
996
|
+
let r = this.children[n];
|
|
997
|
+
if (r.type === "element" && e.call(t, r, n, this.children) === !1) return;
|
|
998
|
+
}
|
|
999
|
+
}
|
|
1000
|
+
childNamed(e) {
|
|
1001
|
+
for (let t = 0, n = this.children.length; t < n; t++) {
|
|
1002
|
+
let n = this.children[t];
|
|
1003
|
+
if (n.type === "element" && n.name === e) return n;
|
|
1004
|
+
}
|
|
1005
|
+
}
|
|
1006
|
+
childrenNamed(e) {
|
|
1007
|
+
let t = [];
|
|
1008
|
+
for (let n = 0, r = this.children.length; n < r; n++) {
|
|
1009
|
+
let r = this.children[n];
|
|
1010
|
+
r.type === "element" && r.name === e && t.push(r);
|
|
1011
|
+
}
|
|
1012
|
+
return t;
|
|
1013
|
+
}
|
|
1014
|
+
childWithAttribute(e, t) {
|
|
1015
|
+
for (let n = 0, r = this.children.length; n < r; n++) {
|
|
1016
|
+
let r = this.children[n];
|
|
1017
|
+
if (r.type === "element" && (t !== void 0 && r.attr[e] === t || t === void 0 && r.attr[e])) return r;
|
|
1018
|
+
}
|
|
1019
|
+
}
|
|
1020
|
+
descendantsNamed(e) {
|
|
1021
|
+
let t = [];
|
|
1022
|
+
for (let n = 0, r = this.children.length; n < r; n++) {
|
|
1023
|
+
let r = this.children[n];
|
|
1024
|
+
if (r.type === "element") {
|
|
1025
|
+
let n = r;
|
|
1026
|
+
n.name === e && t.push(n), t.push(...n.descendantsNamed(e));
|
|
1027
|
+
}
|
|
1028
|
+
}
|
|
1029
|
+
return t;
|
|
1030
|
+
}
|
|
1031
|
+
descendantWithPath(e) {
|
|
1032
|
+
let t = this, n = e.split(".");
|
|
1033
|
+
for (let e = 0, r = n.length; e < r; e++) if (t && t.type === "element") t = t.childNamed(n[e]);
|
|
1034
|
+
else return;
|
|
1035
|
+
return t;
|
|
1036
|
+
}
|
|
1037
|
+
valueWithPath(e) {
|
|
1038
|
+
let t = e.split("@"), n = this.descendantWithPath(t[0]);
|
|
1039
|
+
if (n) return t.length > 1 ? n.attr[t[1]] : n.val;
|
|
1040
|
+
}
|
|
1041
|
+
toString(e) {
|
|
1042
|
+
return this.toStringWithIndent("", e);
|
|
1043
|
+
}
|
|
1044
|
+
toStringWithIndent(e, t) {
|
|
1045
|
+
let n = `${e}<${this.name}`, r = t?.compressed ? "" : "\n";
|
|
1046
|
+
for (let e in this.attr) Object.prototype.hasOwnProperty.call(this.attr, e) && (n += ` ${e}="${l(this.attr[e])}"`);
|
|
1047
|
+
if (this.children.length === 1 && this.children[0].type !== "element") n += `>${this.children[0].toString(t)}</${this.name}>`;
|
|
1048
|
+
else if (this.children.length) {
|
|
1049
|
+
n += `>${r}`;
|
|
1050
|
+
let i = e + (t?.compressed ? "" : " ");
|
|
1051
|
+
for (let e = 0, a = this.children.length; e < a; e++) n += `${this.children[e].toStringWithIndent(i, t)}${r}`;
|
|
1052
|
+
n += `${e}</${this.name}>`;
|
|
1053
|
+
} else t?.html ? [
|
|
1054
|
+
"area",
|
|
1055
|
+
"base",
|
|
1056
|
+
"br",
|
|
1057
|
+
"col",
|
|
1058
|
+
"embed",
|
|
1059
|
+
"frame",
|
|
1060
|
+
"hr",
|
|
1061
|
+
"img",
|
|
1062
|
+
"input",
|
|
1063
|
+
"keygen",
|
|
1064
|
+
"link",
|
|
1065
|
+
"menuitem",
|
|
1066
|
+
"meta",
|
|
1067
|
+
"param",
|
|
1068
|
+
"source",
|
|
1069
|
+
"track",
|
|
1070
|
+
"wbr"
|
|
1071
|
+
].includes(this.name) ? n += "/>" : n += `></${this.name}>` : n += "/>";
|
|
1072
|
+
return n;
|
|
1073
|
+
}
|
|
1074
|
+
};
|
|
1075
|
+
e.XmlElement = o, e.XmlDocument = class extends o {
|
|
1076
|
+
constructor(e) {
|
|
1077
|
+
if (super({
|
|
1078
|
+
name: "",
|
|
1079
|
+
attributes: {}
|
|
1080
|
+
}), e = e.toString().trim(), !e) throw Error("No XML to parse!");
|
|
1081
|
+
this.doctype = "", this.parser = n.default.parser(!0), c(this.parser), s = [this];
|
|
1082
|
+
try {
|
|
1083
|
+
this.parser.write(e);
|
|
1084
|
+
} finally {
|
|
1085
|
+
delete this.parser;
|
|
1086
|
+
}
|
|
1087
|
+
}
|
|
1088
|
+
_opentag(e) {
|
|
1089
|
+
this.name === "" ? (this.name = e.name, this.attr = e.attributes) : super._opentag(e);
|
|
1090
|
+
}
|
|
1091
|
+
_doctype(e) {
|
|
1092
|
+
this.doctype += e;
|
|
1093
|
+
}
|
|
1094
|
+
};
|
|
1095
|
+
var s = [];
|
|
1096
|
+
function c(e) {
|
|
1097
|
+
e.onopentag = (e) => s[0]?._opentag(e), e.onclosetag = () => s[0]?._closetag(), e.ontext = (e) => s[0]?._text(e), e.oncdata = (e) => s[0]?._cdata(e), e.oncomment = (e) => s[0]?._comment(e), e.ondoctype = (e) => {
|
|
1098
|
+
let t = s[0];
|
|
1099
|
+
t._doctype && t._doctype(e);
|
|
1100
|
+
}, e.onerror = (e) => s[0]?._error(e);
|
|
1101
|
+
}
|
|
1102
|
+
function l(e) {
|
|
1103
|
+
return e.toString().replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/'/g, "'").replace(/"/g, """);
|
|
1104
|
+
}
|
|
1105
|
+
function u(e, t) {
|
|
1106
|
+
let n = e;
|
|
1107
|
+
return t?.trimmed && e.length > 25 && (n = n.substring(0, 25).trim() + "…"), t?.preserveWhitespace || (n = n.trim()), n;
|
|
1108
|
+
}
|
|
1109
|
+
})))(), F = "com.apple.ibooks.display-options.xml", I = "ComicInfo.xml";
|
|
1110
|
+
new Set(["Pages", "ComicInfo"]), new Set([
|
|
1111
|
+
8,
|
|
1112
|
+
12,
|
|
1113
|
+
13,
|
|
1114
|
+
14
|
|
1115
|
+
]), I.toLowerCase(), F.toLowerCase(), I.toLowerCase();
|
|
1116
|
+
var L = (e) => e ? e.children.map((e) => e instanceof P.XmlTextNode ? e.text : e instanceof P.XmlElement ? L(e) : "").join("").trim() : "", R = (e, { basePath: t, baseUrl: n }) => {
|
|
1117
|
+
let r = {
|
|
1118
|
+
contents: [],
|
|
1119
|
+
path: "",
|
|
1120
|
+
href: "",
|
|
1121
|
+
title: ""
|
|
1122
|
+
}, i = e.childNamed("span") || e.childNamed("a");
|
|
1123
|
+
r.title = (i?.attr.title || i?.val.trim() || L(i)) ?? "";
|
|
1124
|
+
let a = i?.name;
|
|
1125
|
+
a !== "a" && (i = e.descendantWithPath(`${a}.a`), i && (a = i.name.toLowerCase())), a === "a" && i?.attr.href && (r.path = C(t, i.attr.href), r.href = C(n, t, i.attr.href));
|
|
1126
|
+
let o = e.childNamed("ol");
|
|
1127
|
+
if (o) {
|
|
1128
|
+
let e = o.childrenNamed("li");
|
|
1129
|
+
e && e.length > 0 && (r.contents = e.map((e) => R(e, {
|
|
1130
|
+
basePath: t,
|
|
1131
|
+
baseUrl: n
|
|
1132
|
+
})));
|
|
1133
|
+
}
|
|
1134
|
+
return r;
|
|
1135
|
+
}, z = (e, { opfBasePath: t, baseUrl: n, prefix: r }) => {
|
|
1136
|
+
let i = e?.childNamed(`${r}content`)?.attr.src || "", a = {
|
|
1137
|
+
title: e?.descendantWithPath(`${r}navLabel.${r}text`)?.val || "",
|
|
1138
|
+
path: C(t, i),
|
|
1139
|
+
href: C(n, t, i),
|
|
1140
|
+
contents: []
|
|
1141
|
+
}, o = e.childrenNamed(`${r}navPoint`);
|
|
1142
|
+
return o && o.length > 0 && (a.contents = o.map((e) => z(e, {
|
|
1143
|
+
opfBasePath: t,
|
|
1144
|
+
baseUrl: n,
|
|
1145
|
+
prefix: r
|
|
1146
|
+
}))), a;
|
|
1147
|
+
}, B = Symbol("pdfjs"), V = (e) => "_symbol" in e && e._symbol === B, H = async (e, t) => {
|
|
1148
|
+
let n = await c.getDocument(await e.arrayBuffer()).promise, r = Array.from({ length: n.numPages }), i = r.map((e, t) => ({
|
|
8
1149
|
id: `page-${t}`,
|
|
9
1150
|
resourcePath: `${t}.pdf`
|
|
10
|
-
})),
|
|
1151
|
+
})), a = `
|
|
11
1152
|
<?xml version="1.0" encoding="UTF-8"?><package xmlns="http://www.idpf.org/2007/opf" version="2.0" unique-identifier="bookid">
|
|
12
1153
|
<metadata>
|
|
13
1154
|
<meta property="rendition:layout">pre-paginated</meta>
|
|
14
1155
|
</metadata>
|
|
15
1156
|
<manifest>
|
|
16
|
-
${
|
|
1157
|
+
${i.map(({ id: e, resourcePath: t }) => `<item id="${e}" href="${t}" />`).join("\n")}
|
|
17
1158
|
</manifest>
|
|
18
1159
|
<spine>
|
|
19
|
-
${
|
|
1160
|
+
${i.map(({ id: e }) => `<itemref idref="${e}" />`).join("\n")}
|
|
20
1161
|
</spine>
|
|
21
1162
|
</package>
|
|
22
1163
|
`;
|
|
23
1164
|
return {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
}))],
|
|
47
|
-
close: () => r.cleanup()
|
|
1165
|
+
...j({
|
|
1166
|
+
filename: t,
|
|
1167
|
+
encodingFormat: "application/pdf",
|
|
1168
|
+
records: [{
|
|
1169
|
+
dir: !1,
|
|
1170
|
+
basename: "content.opf",
|
|
1171
|
+
uri: "content.opf",
|
|
1172
|
+
size: 0,
|
|
1173
|
+
...M(async () => new Blob([a]))
|
|
1174
|
+
}, ...r.map((e, t) => ({
|
|
1175
|
+
dir: !1,
|
|
1176
|
+
basename: `${t}.pdf`,
|
|
1177
|
+
uri: `${t}.pdf`,
|
|
1178
|
+
size: 0,
|
|
1179
|
+
...M(async () => {
|
|
1180
|
+
throw Error("Unable to get blob from pdf");
|
|
1181
|
+
})
|
|
1182
|
+
}))],
|
|
1183
|
+
close: () => n.cleanup()
|
|
1184
|
+
}),
|
|
1185
|
+
proxyDocument: n,
|
|
1186
|
+
_symbol: B
|
|
48
1187
|
};
|
|
49
|
-
},
|
|
1188
|
+
}, U = "html{touch-action:none}body{width:100%;height:100%;margin:0;padding:0;overflow:hidden}", W = (e, t, n) => {
|
|
50
1189
|
if (!e) return;
|
|
51
1190
|
let { height: r, width: i } = n.pageSize;
|
|
52
1191
|
h(e.style, "width", `${i}px`), h(e.style, "height", `${r}px`), t === "right" ? h(e.style, "justify-content", "flex-start") : t === "left" ? h(e.style, "justify-content", "flex-end") : h(e.style, "justify-content", "center");
|
|
53
|
-
},
|
|
1192
|
+
}, G = (e, t, n) => {
|
|
54
1193
|
let r = window.devicePixelRatio || 1, { height: i, width: a } = n.pageSize, { width: o, height: s } = e.getViewport({ scale: 1 }), c = Math.max(a / o, i / s), l = e.getViewport({ scale: c }), u = l.width / l.height, d = a / i, f = u > d ? a : i * u, p = u > d ? a / u : i;
|
|
55
1194
|
m(t, "width", Math.floor(l.width * r)), m(t, "height", Math.floor(l.height * r)), h(t.style, "width", `${Math.floor(f)}px`), h(t.style, "height", `${Math.floor(p)}px`);
|
|
56
|
-
},
|
|
1195
|
+
}, K = ":root {\n --scale-factor: 1;\n --user-unit: 1;\n --total-scale-factor: calc(var(--scale-factor) * var(--user-unit));\n --scale-round-x: 1px;\n --scale-round-y: 1px;\n}", q = class extends d {
|
|
57
1196
|
pdfViewerStyle;
|
|
58
1197
|
pageProxy;
|
|
59
1198
|
renderTask;
|
|
@@ -70,10 +1209,10 @@ var b = Symbol("pdfjs"), x = (e) => "_symbol" in e && e._symbol === b, S = async
|
|
|
70
1209
|
if (e instanceof HTMLIFrameElement) return e;
|
|
71
1210
|
}
|
|
72
1211
|
getPageProxy() {
|
|
73
|
-
return this.pageProxy ?
|
|
1212
|
+
return this.pageProxy ? a(this.pageProxy) : n(this.resourcesHandler.fetchResource()).pipe(o((t) => "custom" in t ? (this.pageProxy = t.data, a(this.pageProxy)) : e));
|
|
74
1213
|
}
|
|
75
1214
|
onUnload() {
|
|
76
|
-
return this.detach(), this.renderTask && this.renderTask.cancel(), this.textLayer?.cancel(), this.pageProxy?.cleanup(),
|
|
1215
|
+
return this.detach(), this.renderTask && this.renderTask.cancel(), this.textLayer?.cancel(), this.pageProxy?.cleanup(), e;
|
|
77
1216
|
}
|
|
78
1217
|
onCreateDocument() {
|
|
79
1218
|
let e = document.createElement("iframe");
|
|
@@ -83,33 +1222,33 @@ var b = Symbol("pdfjs"), x = (e) => "_symbol" in e && e._symbol === b, S = async
|
|
|
83
1222
|
let n = this.containerElement.ownerDocument.createElement("canvas");
|
|
84
1223
|
t.appendChild(e);
|
|
85
1224
|
let r = this.containerElement.ownerDocument.createElement("div");
|
|
86
|
-
return r.style.cssText = "\n display: flex;\n align-items: center;\n justify-content: center;\n ", r.appendChild(n), r.appendChild(t), this.setDocumentContainer(r),
|
|
1225
|
+
return r.style.cssText = "\n display: flex;\n align-items: center;\n justify-content: center;\n ", r.appendChild(n), r.appendChild(t), this.setDocumentContainer(r), a(r);
|
|
87
1226
|
}
|
|
88
1227
|
onLoadDocument() {
|
|
89
|
-
return this.getPageProxy().pipe(
|
|
90
|
-
let
|
|
91
|
-
return !
|
|
1228
|
+
return this.getPageProxy().pipe(o(() => {
|
|
1229
|
+
let t = this.getFrameElement(), r = this.pageProxy;
|
|
1230
|
+
return !t || !r ? e : a(t).pipe(y(this.context.bridgeEvent.viewportFree$), s(() => {
|
|
92
1231
|
this.attach();
|
|
93
|
-
}), _,
|
|
94
|
-
f(
|
|
95
|
-
let
|
|
96
|
-
return !
|
|
97
|
-
container:
|
|
1232
|
+
}), _, o(() => {
|
|
1233
|
+
f(t, "pdfjs-viewer-style", this.pdfViewerStyle), f(t, "enhancer-pdf-style", U), g(t, "pdf-scale-scale", K);
|
|
1234
|
+
let r = t.contentDocument?.body;
|
|
1235
|
+
return !r || !this.pageProxy ? e : (p(r, "class", "textLayer"), this.textLayer = new u({
|
|
1236
|
+
container: r,
|
|
98
1237
|
textContentSource: this.pageProxy.streamTextContent(),
|
|
99
1238
|
viewport: this.pageProxy.getViewport({ scale: 1 })
|
|
100
|
-
}),
|
|
1239
|
+
}), n(this.textLayer.render()));
|
|
101
1240
|
}), v);
|
|
102
1241
|
}));
|
|
103
1242
|
}
|
|
104
1243
|
onLayout({ spreadPosition: e }) {
|
|
105
|
-
let
|
|
106
|
-
if (!
|
|
107
|
-
let { height:
|
|
108
|
-
|
|
109
|
-
let u =
|
|
110
|
-
if (!this.pageProxy || !u) return
|
|
111
|
-
this.renderTask &&= (this.renderTask.cancel(), void 0),
|
|
112
|
-
let { width: f, height: p } = this.pageProxy.getViewport({ scale: 1 }), m = Math.max(
|
|
1244
|
+
let r = this.getFrameElement(), i = this.getCanvas();
|
|
1245
|
+
if (!r || !i) return a(void 0);
|
|
1246
|
+
let { height: s, width: c } = this.viewport.pageSize;
|
|
1247
|
+
W(this.documentContainer, e, this.viewport);
|
|
1248
|
+
let u = i.getContext("2d"), d = window.devicePixelRatio || 1;
|
|
1249
|
+
if (!this.pageProxy || !u) return a(void 0);
|
|
1250
|
+
this.renderTask &&= (this.renderTask.cancel(), void 0), G(this.pageProxy, i, this.viewport);
|
|
1251
|
+
let { width: f, height: p } = this.pageProxy.getViewport({ scale: 1 }), m = Math.max(c / f, s / p), g = this.pageProxy.getViewport({ scale: m }), _ = d === 1 ? null : [
|
|
113
1252
|
d,
|
|
114
1253
|
0,
|
|
115
1254
|
0,
|
|
@@ -121,45 +1260,45 @@ var b = Symbol("pdfjs"), x = (e) => "_symbol" in e && e._symbol === b, S = async
|
|
|
121
1260
|
..._ && { transform: _ },
|
|
122
1261
|
canvasContext: u,
|
|
123
1262
|
viewport: g,
|
|
124
|
-
canvas:
|
|
125
|
-
}),
|
|
1263
|
+
canvas: i
|
|
1264
|
+
}), n(this.renderTask.promise).pipe(o(() => {
|
|
126
1265
|
this.renderTask = void 0;
|
|
127
|
-
let e =
|
|
128
|
-
if (!e || !
|
|
129
|
-
let
|
|
130
|
-
return h(
|
|
131
|
-
}),
|
|
1266
|
+
let e = r?.contentDocument, t = this.pageProxy;
|
|
1267
|
+
if (!e || !r || !t || !this.textLayer) throw Error("Unable to update text layer due to missing elements");
|
|
1268
|
+
let n = e.body, o = i.clientWidth / f;
|
|
1269
|
+
return h(n.style, "top", `${i.offsetTop}px`), h(n.style, "left", `${i.offsetLeft}px`), h(n.style, "height", i.style.height), h(n.style, "width", i.style.width), h(e.documentElement.style, "--scale-factor", `${o}`), this.textLayer.update({ viewport: g }), a(void 0);
|
|
1270
|
+
}), t((e) => (e instanceof l || console.error(e), a(void 0))));
|
|
132
1271
|
}
|
|
133
1272
|
onRenderHeadless() {
|
|
134
|
-
return this.getPageProxy().pipe(
|
|
135
|
-
let t = document.implementation.createHTMLDocument(),
|
|
136
|
-
return
|
|
137
|
-
container:
|
|
1273
|
+
return this.getPageProxy().pipe(o((e) => {
|
|
1274
|
+
let t = document.implementation.createHTMLDocument(), i = t.body;
|
|
1275
|
+
return n(new u({
|
|
1276
|
+
container: i,
|
|
138
1277
|
textContentSource: e.streamTextContent(),
|
|
139
1278
|
viewport: e.getViewport({ scale: 1 })
|
|
140
|
-
}).render()).pipe(
|
|
1279
|
+
}).render()).pipe(r(() => t));
|
|
141
1280
|
}));
|
|
142
1281
|
}
|
|
143
1282
|
getDocumentFrame() {
|
|
144
1283
|
return this.getFrameElement();
|
|
145
1284
|
}
|
|
146
|
-
},
|
|
1285
|
+
}, J = (e) => (t) => e({
|
|
147
1286
|
...t,
|
|
148
1287
|
getRenderer(e) {
|
|
149
1288
|
let n = t.getRenderer?.(e);
|
|
150
|
-
return !n && e.href.endsWith(".pdf") ? (e) => new
|
|
1289
|
+
return !n && e.href.endsWith(".pdf") ? (e) => new q(t.pdf.pdfjsViewerInlineCss, e) : n;
|
|
151
1290
|
},
|
|
152
|
-
getResource: (e) => t.pdf.getArchiveForItem(e).pipe(
|
|
153
|
-
if (!t) return
|
|
154
|
-
if (!
|
|
155
|
-
let
|
|
156
|
-
return
|
|
1291
|
+
getResource: (e) => t.pdf.getArchiveForItem(e).pipe(i((t) => {
|
|
1292
|
+
if (!t) return a(void 0);
|
|
1293
|
+
if (!V(t)) return console.warn("You provided an invalid pdf archive"), a(void 0);
|
|
1294
|
+
let i = t.records.findIndex((t) => e.href.endsWith(t.uri)) - 1;
|
|
1295
|
+
return n(t.proxyDocument.getPage(i + 1)).pipe(r((e) => ({
|
|
157
1296
|
custom: !0,
|
|
158
1297
|
data: e
|
|
159
1298
|
})));
|
|
160
1299
|
}))
|
|
161
1300
|
});
|
|
162
1301
|
//#endregion
|
|
163
|
-
export {
|
|
1302
|
+
export { H as createArchiveFromPdf, V as isPdfJsArchive, J as pdfEnhancer };
|
|
164
1303
|
|
|
165
1304
|
//# sourceMappingURL=index.js.map
|