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