ipx 4.0.0-alpha.2 → 4.0.0-beta.1
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/README.md +492 -77
- package/dist/THIRD-PARTY-LICENSES.md +54 -0
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +1 -1
- package/dist/_chunks/libs/crossws.d.mts +1 -0
- package/dist/_chunks/libs/css-select.mjs +2 -2
- package/dist/_chunks/libs/css-tree.mjs +68 -106
- package/dist/_chunks/libs/csso.mjs +16 -29
- package/dist/_chunks/libs/etag.mjs +1 -1
- package/dist/_chunks/libs/h3.d.mts +3 -0
- package/dist/_chunks/libs/h3.mjs +114 -72
- package/dist/_chunks/libs/image-meta.d.mts +0 -4
- package/dist/_chunks/libs/image-meta.mjs +6 -6
- package/dist/_chunks/libs/sax.mjs +21 -20
- package/dist/_chunks/libs/svgo.mjs +788 -756
- package/dist/_chunks/libs/ufo.mjs +17 -24
- package/dist/_chunks/node-fs.mjs +982 -158
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.d.mts +184 -16
- package/dist/index.mjs +2 -2
- package/package.json +20 -17
package/dist/_chunks/libs/h3.mjs
CHANGED
|
@@ -6,20 +6,26 @@ const n = (() => {
|
|
|
6
6
|
function r(e) {
|
|
7
7
|
return decodeURI(e.includes(`%25`) ? e.replace(/%25/g, `%2525`) : e);
|
|
8
8
|
}
|
|
9
|
-
const i = `h3.internal.event.`, a = Symbol.for(`${i}res`), o = Symbol.for(`${i}res.headers`), s = Symbol.for(`${i}res.err.headers`);
|
|
10
|
-
var
|
|
9
|
+
const i = `h3.internal.event.`, a = Symbol.for(`${i}res`), o = Symbol.for(`${i}res.headers`), s = Symbol.for(`${i}res.err.headers`), c = Symbol.for(`${i}malformed`);
|
|
10
|
+
var l = class {
|
|
11
11
|
app;
|
|
12
12
|
req;
|
|
13
13
|
url;
|
|
14
14
|
context;
|
|
15
15
|
static __is_event__ = !0;
|
|
16
16
|
constructor(e, i, a) {
|
|
17
|
-
this.context = i || e.context || new n(), this.req = e, this.app = a;
|
|
17
|
+
this.context = e.context = i || e.context || new n(), this.req = e, this.app = a;
|
|
18
18
|
let o = e._url, s = o && o instanceof URL ? o : new t(e.url);
|
|
19
|
-
s.pathname.includes(`%`)
|
|
19
|
+
if (s.pathname.includes(`%`)) try {
|
|
20
|
+
let e = r(s.pathname);
|
|
21
|
+
e !== s.pathname && (s = new t(`${s.protocol}//${s.host}${e}${s.search}`));
|
|
22
|
+
} catch {
|
|
23
|
+
this[c] = !0;
|
|
24
|
+
}
|
|
25
|
+
this.url = s;
|
|
20
26
|
}
|
|
21
27
|
get res() {
|
|
22
|
-
return this[a] ||= new
|
|
28
|
+
return this[a] ||= new u();
|
|
23
29
|
}
|
|
24
30
|
get runtime() {
|
|
25
31
|
return this.req.runtime;
|
|
@@ -45,7 +51,7 @@ var c = class {
|
|
|
45
51
|
get method() {
|
|
46
52
|
return this.req.method;
|
|
47
53
|
}
|
|
48
|
-
},
|
|
54
|
+
}, u = class {
|
|
49
55
|
status;
|
|
50
56
|
statusText;
|
|
51
57
|
get headers() {
|
|
@@ -55,14 +61,14 @@ var c = class {
|
|
|
55
61
|
return this[s] ||= new Headers();
|
|
56
62
|
}
|
|
57
63
|
};
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
return e.replace(
|
|
64
|
+
const d = /[^\u0009\u0020-\u007E]/g;
|
|
65
|
+
function f(e = ``) {
|
|
66
|
+
return e.replace(d, ``);
|
|
61
67
|
}
|
|
62
|
-
function
|
|
63
|
-
return !e || (typeof e == `string` && (e = +e), e < 100 || e > 599) ? t : e;
|
|
68
|
+
function p(e, t = 200) {
|
|
69
|
+
return !e || (typeof e == `string` && (e = +e), !Number.isInteger(e) || e < 100 || e > 599) ? t : e;
|
|
64
70
|
}
|
|
65
|
-
var
|
|
71
|
+
var m = class e extends Error {
|
|
66
72
|
get name() {
|
|
67
73
|
return `HTTPError`;
|
|
68
74
|
}
|
|
@@ -86,7 +92,7 @@ var p = class e extends Error {
|
|
|
86
92
|
constructor(e, t) {
|
|
87
93
|
let n, r;
|
|
88
94
|
typeof e == `string` ? (n = e, r = t) : r = e;
|
|
89
|
-
let i =
|
|
95
|
+
let i = p(r?.status || r?.statusCode || r?.cause?.status || r?.cause?.statusCode, 500), a = f(r?.statusText || r?.statusMessage || r?.cause?.statusText || r?.cause?.statusMessage), o = n || r?.message || r?.cause?.message || r?.statusText || r?.statusMessage || [
|
|
90
96
|
`HTTPError`,
|
|
91
97
|
i,
|
|
92
98
|
a
|
|
@@ -113,7 +119,7 @@ var p = class e extends Error {
|
|
|
113
119
|
};
|
|
114
120
|
}
|
|
115
121
|
};
|
|
116
|
-
function
|
|
122
|
+
function h(e, t) {
|
|
117
123
|
if (e == null) return !0;
|
|
118
124
|
if (t !== `object`) return t === `boolean` || t === `number` || t === `string`;
|
|
119
125
|
if (typeof e.toJSON == `function` || Array.isArray(e)) return !0;
|
|
@@ -122,15 +128,31 @@ function m(e, t) {
|
|
|
122
128
|
let r = Object.getPrototypeOf(e);
|
|
123
129
|
return r === Object.prototype || r === null;
|
|
124
130
|
}
|
|
125
|
-
const
|
|
126
|
-
function
|
|
127
|
-
if (typeof e?.then == `function`) return e.then((e) =>
|
|
128
|
-
let r
|
|
129
|
-
|
|
131
|
+
const g = Symbol.for(`h3.internal.event.dispose`), _ = Symbol.for(`h3.notFound`), v = Symbol.for(`h3.handled`);
|
|
132
|
+
function y(e, t, n = {}) {
|
|
133
|
+
if (typeof e?.then == `function`) return e.then((e) => y(e, t, n), (e) => y(b(e), t, n));
|
|
134
|
+
let r;
|
|
135
|
+
try {
|
|
136
|
+
r = S(e, t, n);
|
|
137
|
+
} catch (e) {
|
|
138
|
+
return y(b(e), t, n);
|
|
139
|
+
}
|
|
140
|
+
if (typeof r?.then == `function`) return y(r, t, n);
|
|
130
141
|
let { onResponse: i } = n;
|
|
131
|
-
return i ? Promise.resolve(i(r, t)).
|
|
142
|
+
return i ? Promise.resolve().then(() => i(r, t)).catch((e) => {
|
|
143
|
+
n.silent || console.error(e);
|
|
144
|
+
}).then(() => t[g]?.observe(r, e) ?? r) : t[g]?.observe(r, e) ?? r;
|
|
145
|
+
}
|
|
146
|
+
function b(e) {
|
|
147
|
+
if (e === _ || e === v || e instanceof Error) return e;
|
|
148
|
+
if (typeof e == `number`) return new m({ status: e });
|
|
149
|
+
let t = new m({
|
|
150
|
+
status: 500,
|
|
151
|
+
unhandled: !0
|
|
152
|
+
});
|
|
153
|
+
return t.cause = e, t;
|
|
132
154
|
}
|
|
133
|
-
var
|
|
155
|
+
var x = class {
|
|
134
156
|
#headers;
|
|
135
157
|
#init;
|
|
136
158
|
body;
|
|
@@ -138,75 +160,82 @@ var v = class {
|
|
|
138
160
|
this.body = e, this.#init = t;
|
|
139
161
|
}
|
|
140
162
|
get status() {
|
|
141
|
-
return this.#init?.status
|
|
163
|
+
return this.#init?.status;
|
|
142
164
|
}
|
|
143
165
|
get statusText() {
|
|
144
|
-
return this.#init?.statusText
|
|
166
|
+
return this.#init?.statusText;
|
|
145
167
|
}
|
|
146
168
|
get headers() {
|
|
147
169
|
return this.#headers ||= new Headers(this.#init?.headers);
|
|
148
170
|
}
|
|
149
171
|
};
|
|
150
|
-
function
|
|
151
|
-
if (t ===
|
|
152
|
-
if (t ===
|
|
172
|
+
function S(t, n, r, i) {
|
|
173
|
+
if (t === v) return new e(null);
|
|
174
|
+
if (t === _ && (t = new m({
|
|
153
175
|
status: 404,
|
|
154
176
|
message: `Cannot find any route matching [${n.req.method}] ${n.url}`
|
|
155
177
|
})), t && t instanceof Error) {
|
|
156
|
-
let e =
|
|
178
|
+
let e = m.isError(t), o = e ? t : new m(t);
|
|
157
179
|
e || (o.unhandled = !0, t?.stack && (o.stack = t.stack)), o.unhandled && !r.silent && console.error(o);
|
|
158
180
|
let { onError: c } = r, l = n[a]?.[s];
|
|
159
|
-
return c && !i ? Promise.resolve(c(o, n)).catch((e) => e).then((e) =>
|
|
181
|
+
return c && !i ? Promise.resolve().then(() => c(o, n)).catch((e) => e).then((e) => S(e ?? t, n, r, !0)) : A(o, r.debug, l);
|
|
160
182
|
}
|
|
161
183
|
let c = n[a], l = c?.[o];
|
|
162
184
|
if (n[a] = void 0, !(t instanceof Response)) {
|
|
163
|
-
let i =
|
|
164
|
-
return new e(
|
|
185
|
+
let i = O(t, n, r), a = i.status || c?.status;
|
|
186
|
+
return new e(k(n.req.method, a) ? null : i.body, {
|
|
165
187
|
status: a,
|
|
166
188
|
statusText: i.statusText || c?.statusText,
|
|
167
|
-
headers: i.headers && l ?
|
|
189
|
+
headers: i.headers && l ? C(i.headers, l) : i.headers || l
|
|
168
190
|
});
|
|
169
191
|
}
|
|
170
|
-
if (
|
|
171
|
-
|
|
172
|
-
return b(t.headers, l, t.headers), t;
|
|
192
|
+
if (t.status >= 400 && (l = c?.[s]), l && !i) try {
|
|
193
|
+
C(t.headers, l, t.headers);
|
|
173
194
|
} catch {
|
|
174
|
-
return new e(
|
|
195
|
+
return new e(k(n.req.method, t.status) ? null : t.body, {
|
|
175
196
|
status: t.status,
|
|
176
197
|
statusText: t.statusText,
|
|
177
|
-
headers:
|
|
198
|
+
headers: C(t.headers, l)
|
|
178
199
|
});
|
|
179
200
|
}
|
|
201
|
+
return n.req.method === `HEAD` && t.body !== null ? new e(null, {
|
|
202
|
+
status: t.status,
|
|
203
|
+
statusText: t.statusText,
|
|
204
|
+
headers: t.headers
|
|
205
|
+
}) : t;
|
|
180
206
|
}
|
|
181
|
-
function
|
|
207
|
+
function C(e, t, n = new Headers(e)) {
|
|
182
208
|
for (let [e, r] of t) e === `set-cookie` ? n.append(e, r) : n.set(e, r);
|
|
183
209
|
return n;
|
|
184
210
|
}
|
|
185
|
-
const
|
|
211
|
+
const w = (e) => (...t) => {
|
|
186
212
|
throw Error(`Headers are frozen (${e} ${t.join(`, `)})`);
|
|
187
213
|
};
|
|
188
|
-
var
|
|
189
|
-
set =
|
|
190
|
-
append =
|
|
191
|
-
delete =
|
|
214
|
+
var T = class extends Headers {
|
|
215
|
+
set = w(`set`);
|
|
216
|
+
append = w(`append`);
|
|
217
|
+
delete = w(`delete`);
|
|
192
218
|
};
|
|
193
|
-
const
|
|
194
|
-
function
|
|
219
|
+
const E = new T({ "content-length": `0` }), D = new T({ "content-type": `application/json;charset=UTF-8` });
|
|
220
|
+
function O(e, t, n) {
|
|
195
221
|
if (e == null) return {
|
|
196
222
|
body: ``,
|
|
197
|
-
headers:
|
|
223
|
+
headers: E
|
|
198
224
|
};
|
|
199
225
|
let r = typeof e;
|
|
200
226
|
if (r === `string`) return { body: e };
|
|
201
|
-
if (e instanceof Uint8Array) return
|
|
202
|
-
|
|
203
|
-
|
|
227
|
+
if (e instanceof Uint8Array) return {
|
|
228
|
+
body: e,
|
|
229
|
+
headers: new Headers({ "content-length": e.byteLength.toString() })
|
|
230
|
+
};
|
|
231
|
+
if (e instanceof x || e?.constructor?.name === `HTTPResponse`) return e;
|
|
232
|
+
if (h(e, r)) return {
|
|
204
233
|
body: JSON.stringify(e, void 0, n.debug ? 2 : void 0),
|
|
205
|
-
headers:
|
|
234
|
+
headers: D
|
|
206
235
|
};
|
|
207
236
|
if (r === `bigint`) return {
|
|
208
237
|
body: e.toString(),
|
|
209
|
-
headers:
|
|
238
|
+
headers: D
|
|
210
239
|
};
|
|
211
240
|
if (e instanceof Blob) {
|
|
212
241
|
let t = new Headers({
|
|
@@ -220,12 +249,12 @@ function T(e, t, n) {
|
|
|
220
249
|
}
|
|
221
250
|
return r === `symbol` ? { body: e.toString() } : r === `function` ? { body: `${e.name}()` } : { body: e };
|
|
222
251
|
}
|
|
223
|
-
function
|
|
252
|
+
function k(e, t) {
|
|
224
253
|
return e === `HEAD` || t === 100 || t === 101 || t === 102 || t === 204 || t === 205 || t === 304;
|
|
225
254
|
}
|
|
226
|
-
function
|
|
227
|
-
let i = t.headers ?
|
|
228
|
-
return r && (i =
|
|
255
|
+
function A(t, n, r) {
|
|
256
|
+
let i = t.headers ? C(D, t.headers) : new Headers(D);
|
|
257
|
+
return r && (i = C(i, r)), new e(JSON.stringify({
|
|
229
258
|
...t.toJSON(),
|
|
230
259
|
stack: n && t.stack ? t.stack.split(`
|
|
231
260
|
`).map((e) => e.trim()) : void 0
|
|
@@ -235,33 +264,46 @@ function D(t, n, r) {
|
|
|
235
264
|
headers: i
|
|
236
265
|
});
|
|
237
266
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
240
|
-
let
|
|
241
|
-
|
|
267
|
+
function j(e) {
|
|
268
|
+
let t = (e, t) => t(e);
|
|
269
|
+
for (let n = e.length - 1; n >= 0; n--) {
|
|
270
|
+
let r = e[n], i = t;
|
|
271
|
+
t = (e, t) => N(r, e, t, i);
|
|
272
|
+
}
|
|
273
|
+
return t;
|
|
242
274
|
}
|
|
243
|
-
function
|
|
244
|
-
|
|
275
|
+
function M(e, t) {
|
|
276
|
+
let n = j(e);
|
|
277
|
+
return function(e) {
|
|
278
|
+
return n(e, t);
|
|
279
|
+
};
|
|
245
280
|
}
|
|
246
|
-
function
|
|
247
|
-
|
|
281
|
+
function N(e, t, n, r) {
|
|
282
|
+
let i, a, o = () => i ? a : (i = !0, a = r(t, n), a), s = e(t, o);
|
|
283
|
+
return P(s) ? o() : typeof s?.then == `function` ? s.then((e) => P(e) ? o() : e) : s;
|
|
284
|
+
}
|
|
285
|
+
function P(e) {
|
|
286
|
+
return e === void 0 || e === _;
|
|
287
|
+
}
|
|
288
|
+
function F(e) {
|
|
289
|
+
if (typeof e == `function`) return I(e);
|
|
248
290
|
let t = e.handler || (e.fetch ? function(t) {
|
|
249
291
|
return e.fetch(t.req);
|
|
250
|
-
} :
|
|
251
|
-
return Object.assign(
|
|
252
|
-
return O(n, e.middleware, t);
|
|
253
|
-
} : t), e);
|
|
292
|
+
} : L);
|
|
293
|
+
return Object.assign(I(e.middleware?.length ? M(e.middleware, t) : t), e);
|
|
254
294
|
}
|
|
255
|
-
function
|
|
295
|
+
function I(e) {
|
|
256
296
|
return `fetch` in e ? e : Object.assign(e, { fetch: (t) => {
|
|
257
297
|
typeof t == `string` && (t = new URL(t, `http://_`)), t instanceof URL && (t = new Request(t));
|
|
258
|
-
let n = new
|
|
298
|
+
let n = new l(t);
|
|
259
299
|
try {
|
|
260
|
-
return Promise.resolve(
|
|
300
|
+
return Promise.resolve(y(e(n), n));
|
|
261
301
|
} catch (e) {
|
|
262
|
-
return Promise.resolve(
|
|
302
|
+
return Promise.resolve(y(b(e), n));
|
|
263
303
|
}
|
|
264
304
|
} });
|
|
265
305
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
306
|
+
const L = () => _;
|
|
307
|
+
String.raw`(?:^|/)(?:\.|%(?:25)*2e){1,2}(?:/|$)`, String.raw`%(?:25)*(?:2f|5c)`;
|
|
308
|
+
const R = F;
|
|
309
|
+
export { m as HTTPError, R as defineEventHandler };
|
|
@@ -5,8 +5,4 @@ type e = {
|
|
|
5
5
|
orientation?: number;
|
|
6
6
|
type?: string;
|
|
7
7
|
};
|
|
8
|
-
/**
|
|
9
|
-
* @param {Uint8Array|string} input - Uint8Array or relative/absolute path of the image file
|
|
10
|
-
* @param {Function=} [callback] - optional function for async detection
|
|
11
|
-
*/
|
|
12
8
|
export type { e as ImageMeta };
|
|
@@ -9,8 +9,8 @@ const e = new TextDecoder(), t = (t, n = 0, r = t.length) => e.decode(t.slice(n,
|
|
|
9
9
|
};
|
|
10
10
|
function d(e, t, n, r) {
|
|
11
11
|
n ||= 0;
|
|
12
|
-
let i = r ? `BE` : `LE
|
|
13
|
-
return u[
|
|
12
|
+
let i = r ? `BE` : `LE`, a = `readUInt` + t + i;
|
|
13
|
+
return u[a](e, n);
|
|
14
14
|
}
|
|
15
15
|
const ee = {
|
|
16
16
|
validate: (e) => t(e, 0, 2) === `BM`,
|
|
@@ -203,8 +203,8 @@ const ne = {
|
|
|
203
203
|
validate(e) {
|
|
204
204
|
let t = n(e, 4, 8), r = c(e, 0);
|
|
205
205
|
if (t !== w.jp__ || r < 1) return !1;
|
|
206
|
-
let i = r + 4, a = c(e, r);
|
|
207
|
-
return n(
|
|
206
|
+
let i = r + 4, a = c(e, r), o = e.slice(i, i + a);
|
|
207
|
+
return n(o, 0, 4) === w.ftyp;
|
|
208
208
|
},
|
|
209
209
|
calculate(e) {
|
|
210
210
|
let r = c(e, 0), a = i(e, r + 2), o = r + 4 + a;
|
|
@@ -328,8 +328,8 @@ const M = {
|
|
|
328
328
|
}, R = {
|
|
329
329
|
validate: (e) => t(e, 0, 2) in I,
|
|
330
330
|
calculate(e) {
|
|
331
|
-
let n =
|
|
332
|
-
return (L[
|
|
331
|
+
let n = t(e, 0, 2), r = I[n], i = t(e, 3).split(/[\n\r]+/);
|
|
332
|
+
return (L[r] || L.default)(i);
|
|
333
333
|
}
|
|
334
334
|
}, z = {
|
|
335
335
|
validate: (e) => t(e, 0, 4) === `8BPS`,
|
|
@@ -80,7 +80,7 @@ var n = e(((e) => {
|
|
|
80
80
|
end: function() {
|
|
81
81
|
L(this);
|
|
82
82
|
},
|
|
83
|
-
write:
|
|
83
|
+
write: J,
|
|
84
84
|
resume: function() {
|
|
85
85
|
return this.error = null, this;
|
|
86
86
|
},
|
|
@@ -163,7 +163,7 @@ var n = e(((e) => {
|
|
|
163
163
|
t.splice(0, 0, e), n.emit.apply(n, t);
|
|
164
164
|
}), s.prototype.on.call(n, e, t);
|
|
165
165
|
};
|
|
166
|
-
var f =
|
|
166
|
+
var f = /^\[CDATA\[$/i, p = /^DOCTYPE$/i, m = `http://www.w3.org/XML/1998/namespace`, h = `http://www.w3.org/2000/xmlns/`, g = {
|
|
167
167
|
xml: m,
|
|
168
168
|
xmlns: h
|
|
169
169
|
}, _ = /[:_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]/, 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\u00B7\u0300-\u036F\u203F-\u2040.\d-]/, 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]/, b = /[#:_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-]/;
|
|
@@ -221,13 +221,13 @@ var n = e(((e) => {
|
|
|
221
221
|
CLOSE_TAG_SAW_WHITE: E++,
|
|
222
222
|
SCRIPT: E++,
|
|
223
223
|
SCRIPT_ENDING: E++
|
|
224
|
-
}, e.XML_ENTITIES = {
|
|
224
|
+
}, e.XML_ENTITIES = Object.assign(Object.create(null), {
|
|
225
225
|
amp: `&`,
|
|
226
226
|
gt: `>`,
|
|
227
227
|
lt: `<`,
|
|
228
228
|
quot: `"`,
|
|
229
229
|
apos: `'`
|
|
230
|
-
}, e.ENTITIES = {
|
|
230
|
+
}), e.ENTITIES = Object.assign(Object.create(null), {
|
|
231
231
|
amp: `&`,
|
|
232
232
|
gt: `>`,
|
|
233
233
|
lt: `<`,
|
|
@@ -481,7 +481,7 @@ var n = e(((e) => {
|
|
|
481
481
|
clubs: 9827,
|
|
482
482
|
hearts: 9829,
|
|
483
483
|
diams: 9830
|
|
484
|
-
}, Object.keys(e.ENTITIES).forEach(function(t) {
|
|
484
|
+
}), Object.keys(e.ENTITIES).forEach(function(t) {
|
|
485
485
|
var n = e.ENTITIES[t], r = typeof n == `number` ? String.fromCharCode(n) : n;
|
|
486
486
|
e.ENTITIES[t] = r;
|
|
487
487
|
}), e.STATE) e.STATE[e.STATE[D]] = D;
|
|
@@ -588,7 +588,7 @@ Actual: ` + e.attribValue);
|
|
|
588
588
|
}
|
|
589
589
|
e.attribList.length = 0;
|
|
590
590
|
}
|
|
591
|
-
e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), N(e, `onopentag`, e.tag), t || (!e.noscript && e.tagName.toLowerCase() === `script` ?
|
|
591
|
+
e.tag.isSelfClosing = !!t, e.sawRoot = !0, e.tags.push(e.tag), N(e, `onopentag`, e.tag), t || (e.state = !e.noscript && e.tagName.toLowerCase() === `script` ? E.SCRIPT : E.TEXT, e.tag = null, e.tagName = ``), e.attribName = e.attribValue = ``, e.attribList.length = 0;
|
|
592
592
|
}
|
|
593
593
|
function U(e) {
|
|
594
594
|
if (!e.tagName) {
|
|
@@ -628,33 +628,36 @@ Actual: ` + e.attribValue);
|
|
|
628
628
|
}
|
|
629
629
|
function W(e) {
|
|
630
630
|
var t = e.entity, n = t.toLowerCase(), r, i = ``;
|
|
631
|
-
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));
|
|
631
|
+
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 || !G(r) ? (R(e, `Invalid character entity`), `&` + e.entity + `;`) : String.fromCodePoint(r));
|
|
632
632
|
}
|
|
633
|
-
function G(e
|
|
634
|
-
|
|
633
|
+
function G(e) {
|
|
634
|
+
return e === 9 || e === 10 || e === 13 || e >= 32 && e <= 55295 || e >= 57344 && e <= 65533 || e >= 65536 && e <= 1114111;
|
|
635
635
|
}
|
|
636
636
|
function K(e, t) {
|
|
637
|
+
t === `<` ? (e.state = E.OPEN_WAKA, e.startTagPosition = e.position) : x(t) || (R(e, `Non-whitespace before first tag.`), e.textNode = t, e.state = E.TEXT);
|
|
638
|
+
}
|
|
639
|
+
function q(e, t) {
|
|
637
640
|
var n = ``;
|
|
638
641
|
return t < e.length && (n = e.charAt(t)), n;
|
|
639
642
|
}
|
|
640
|
-
function
|
|
643
|
+
function J(t) {
|
|
641
644
|
var n = this;
|
|
642
645
|
if (this.error) throw this.error;
|
|
643
646
|
if (n.closed) return I(n, `Cannot write after close. Assign an onready handler.`);
|
|
644
647
|
if (t === null) return L(n);
|
|
645
648
|
typeof t == `object` && (t = t.toString());
|
|
646
|
-
for (var r = 0, a = ``; a =
|
|
649
|
+
for (var r = 0, a = ``; a = q(t, r++), n.c = a, a;) switch (n.trackPosition && (n.position++, a === `
|
|
647
650
|
` ? (n.line++, n.column = 0) : n.column++), n.state) {
|
|
648
651
|
case E.BEGIN:
|
|
649
652
|
if (n.state = E.BEGIN_WHITESPACE, a === ``) continue;
|
|
650
|
-
|
|
653
|
+
K(n, a);
|
|
651
654
|
continue;
|
|
652
655
|
case E.BEGIN_WHITESPACE:
|
|
653
|
-
|
|
656
|
+
K(n, a);
|
|
654
657
|
continue;
|
|
655
658
|
case E.TEXT:
|
|
656
659
|
if (n.sawRoot && !n.closedRoot) {
|
|
657
|
-
for (var o = r - 1; a && a !== `<` && a !== `&`;) a =
|
|
660
|
+
for (var o = r - 1; a && a !== `<` && a !== `&`;) a = q(t, r++), a && n.trackPosition && (n.position++, a === `
|
|
658
661
|
` ? (n.line++, n.column = 0) : n.column++);
|
|
659
662
|
n.textNode += t.substring(o, r - 1);
|
|
660
663
|
}
|
|
@@ -684,7 +687,7 @@ Actual: ` + e.attribValue);
|
|
|
684
687
|
n.state = E.COMMENT, n.comment = ``, n.sgmlDecl = ``;
|
|
685
688
|
continue;
|
|
686
689
|
}
|
|
687
|
-
n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = E.DOCTYPE_DTD, n.doctype += `<!` + n.sgmlDecl + a, n.sgmlDecl = ``) : (n.sgmlDecl + a)
|
|
690
|
+
n.doctype && n.doctype !== !0 && n.sgmlDecl ? (n.state = E.DOCTYPE_DTD, n.doctype += `<!` + n.sgmlDecl + a, n.sgmlDecl = ``) : f.test(n.sgmlDecl + a) ? (N(n, `onopencdata`), n.state = E.CDATA, n.sgmlDecl = ``, n.cdata = ``) : p.test(n.sgmlDecl + a) ? (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);
|
|
688
691
|
continue;
|
|
689
692
|
case E.SGML_DECL_QUOTED:
|
|
690
693
|
a === n.q && (n.state = E.SGML_DECL, n.q = ``), n.sgmlDecl += a;
|
|
@@ -708,10 +711,10 @@ Actual: ` + e.attribValue);
|
|
|
708
711
|
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);
|
|
709
712
|
continue;
|
|
710
713
|
case E.COMMENT_ENDED:
|
|
711
|
-
a === `>` ? n.doctype && n.doctype !== !0 ?
|
|
714
|
+
a === `>` ? n.state = n.doctype && n.doctype !== !0 ? E.DOCTYPE_DTD : E.TEXT : (R(n, `Malformed comment`), n.comment += `--` + a, n.state = E.COMMENT);
|
|
712
715
|
continue;
|
|
713
716
|
case E.CDATA:
|
|
714
|
-
for (var o = r - 1; a && a !== `]`;) a =
|
|
717
|
+
for (var o = r - 1; a && a !== `]`;) a = q(t, r++), a && n.trackPosition && (n.position++, a === `
|
|
715
718
|
` ? (n.line++, n.column = 0) : n.column++);
|
|
716
719
|
n.cdata += t.substring(o, r - 1), a === `]` && (n.state = E.CDATA_ENDING);
|
|
717
720
|
continue;
|
|
@@ -801,9 +804,7 @@ Actual: ` + e.attribValue);
|
|
|
801
804
|
case E.ATTRIB_VALUE_ENTITY_Q:
|
|
802
805
|
c = E.ATTRIB_VALUE_QUOTED, l = `attribValue`;
|
|
803
806
|
break;
|
|
804
|
-
case E.ATTRIB_VALUE_ENTITY_U:
|
|
805
|
-
c = E.ATTRIB_VALUE_UNQUOTED, l = `attribValue`;
|
|
806
|
-
break;
|
|
807
|
+
case E.ATTRIB_VALUE_ENTITY_U: c = E.ATTRIB_VALUE_UNQUOTED, l = `attribValue`;
|
|
807
808
|
}
|
|
808
809
|
if (a === `;`) {
|
|
809
810
|
var u = W(n);
|