ipx 4.0.0-beta.1 → 4.0.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/README.md +222 -209
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +22 -23
- package/dist/_chunks/libs/css-select.mjs +1077 -937
- package/dist/_chunks/libs/css-tree.mjs +107 -191
- package/dist/_chunks/libs/csso.mjs +50 -82
- package/dist/_chunks/libs/h3.mjs +107 -106
- package/dist/_chunks/libs/image-meta.d.mts +2 -2
- package/dist/_chunks/libs/image-meta.mjs +464 -305
- package/dist/_chunks/libs/sax.mjs +61 -60
- package/dist/_chunks/libs/svgo.mjs +933 -1008
- package/dist/_chunks/node-fs.mjs +125 -49
- package/dist/_chunks/rolldown-runtime.mjs +2 -11
- package/dist/cli.mjs +4 -3
- package/dist/index.d.mts +64 -11
- package/package.json +30 -29
- package/dist/THIRD-PARTY-LICENSES.md +0 -593
|
@@ -130,17 +130,10 @@ var n = e(((e, t) => {
|
|
|
130
130
|
})), o = e(((e, n) => {
|
|
131
131
|
let r = t(), i = a();
|
|
132
132
|
function o(e, t, n) {
|
|
133
|
-
if (e.block && (this.stylesheet !== null && (this.stylesheet.firstAtrulesAllowed = !1), i.hasNoChildren(e.block)))
|
|
134
|
-
|
|
135
|
-
return;
|
|
136
|
-
}
|
|
137
|
-
switch (e.name) {
|
|
133
|
+
if (e.block && (this.stylesheet !== null && (this.stylesheet.firstAtrulesAllowed = !1), i.hasNoChildren(e.block))) n.remove(t);
|
|
134
|
+
else switch (e.name) {
|
|
138
135
|
case `charset`:
|
|
139
|
-
if (i.hasNoChildren(e.prelude)) {
|
|
140
|
-
n.remove(t);
|
|
141
|
-
return;
|
|
142
|
-
}
|
|
143
|
-
if (t.prev) {
|
|
136
|
+
if (i.hasNoChildren(e.prelude) || t.prev) {
|
|
144
137
|
n.remove(t);
|
|
145
138
|
return;
|
|
146
139
|
}
|
|
@@ -169,11 +162,7 @@ var n = e(((e, t) => {
|
|
|
169
162
|
})), c = e(((e, n) => {
|
|
170
163
|
let r = t();
|
|
171
164
|
function i(e, t, n) {
|
|
172
|
-
|
|
173
|
-
n.remove(t);
|
|
174
|
-
return;
|
|
175
|
-
}
|
|
176
|
-
r.property(e.property).custom && /\S/.test(e.value.value) && (e.value.value = e.value.value.trim());
|
|
165
|
+
e.value.children && e.value.children.isEmpty ? n.remove(t) : r.property(e.property).custom && /\S/.test(e.value.value) && (e.value.value = e.value.value.trim());
|
|
177
166
|
}
|
|
178
167
|
n.exports = i;
|
|
179
168
|
})), l = e(((e, t) => {
|
|
@@ -198,9 +187,7 @@ var n = e(((e, t) => {
|
|
|
198
187
|
case `IdSelector`:
|
|
199
188
|
t.whitelist !== null && t.whitelist.ids !== null && !o.call(t.whitelist.ids, n.name) && (s = !0), t.blacklist !== null && t.blacklist.ids !== null && o.call(t.blacklist.ids, n.name) && (s = !0);
|
|
200
189
|
break;
|
|
201
|
-
case `TypeSelector`:
|
|
202
|
-
n.name.charAt(n.name.length - 1) !== `*` && (t.whitelist !== null && t.whitelist.tags !== null && !o.call(t.whitelist.tags, n.name.toLowerCase()) && (s = !0), t.blacklist !== null && t.blacklist.tags !== null && o.call(t.blacklist.tags, n.name.toLowerCase()) && (s = !0));
|
|
203
|
-
break;
|
|
190
|
+
case `TypeSelector`: n.name.charAt(n.name.length - 1) !== `*` && (t.whitelist !== null && t.whitelist.tags !== null && !o.call(t.whitelist.tags, n.name.toLowerCase()) && (s = !0), t.blacklist !== null && t.blacklist.tags !== null && o.call(t.blacklist.tags, n.name.toLowerCase()) && (s = !0));
|
|
204
191
|
}
|
|
205
192
|
}), s && a.remove(i);
|
|
206
193
|
}), e.children.isEmpty;
|
|
@@ -212,10 +199,7 @@ var n = e(((e, t) => {
|
|
|
212
199
|
}
|
|
213
200
|
if (this.atrule && s.has(r.keyword(this.atrule.name).basename)) return;
|
|
214
201
|
let { usage: o } = a;
|
|
215
|
-
|
|
216
|
-
n.remove(t);
|
|
217
|
-
return;
|
|
218
|
-
}
|
|
202
|
+
o && (o.whitelist !== null || o.blacklist !== null) && (c(e.prelude, o), i.hasNoChildren(e.prelude)) && n.remove(t);
|
|
219
203
|
}
|
|
220
204
|
n.exports = l;
|
|
221
205
|
})), d = e(((e, t) => {
|
|
@@ -278,7 +262,7 @@ var n = e(((e, t) => {
|
|
|
278
262
|
}
|
|
279
263
|
function i(e) {
|
|
280
264
|
let t = e.value;
|
|
281
|
-
|
|
265
|
+
t && t.type === `String` && r(t.value) && (e.value = {
|
|
282
266
|
type: `Identifier`,
|
|
283
267
|
loc: t.loc,
|
|
284
268
|
name: t.value
|
|
@@ -317,13 +301,11 @@ var n = e(((e, t) => {
|
|
|
317
301
|
value: `400`
|
|
318
302
|
};
|
|
319
303
|
break;
|
|
320
|
-
case `bold`:
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
};
|
|
326
|
-
break;
|
|
304
|
+
case `bold`: e.children.head.data = {
|
|
305
|
+
type: `Number`,
|
|
306
|
+
loc: t.loc,
|
|
307
|
+
value: `700`
|
|
308
|
+
};
|
|
327
309
|
}
|
|
328
310
|
}
|
|
329
311
|
t.exports = n;
|
|
@@ -343,11 +325,7 @@ var n = e(((e, t) => {
|
|
|
343
325
|
}
|
|
344
326
|
let n = [], i = [];
|
|
345
327
|
e.children.forEach((e) => {
|
|
346
|
-
|
|
347
|
-
t(), n.push(e);
|
|
348
|
-
return;
|
|
349
|
-
}
|
|
350
|
-
(e.type !== `Identifier` || e.name !== `transparent` && e.name !== `none` && e.name !== `repeat` && e.name !== `scroll`) && i.push(e);
|
|
328
|
+
e.type === `Operator` && e.value === `,` ? (t(), n.push(e)) : (e.type !== `Identifier` || e.name !== `transparent` && e.name !== `none` && e.name !== `repeat` && e.name !== `scroll`) && i.push(e);
|
|
351
329
|
}), t(), e.children = new r.List().fromArray(n);
|
|
352
330
|
}
|
|
353
331
|
n.exports = i;
|
|
@@ -731,11 +709,7 @@ var n = e(((e, t) => {
|
|
|
731
709
|
}
|
|
732
710
|
if (i[3] !== 1) {
|
|
733
711
|
e.children.forEach((e, t, n) => {
|
|
734
|
-
|
|
735
|
-
e.value !== `,` && n.remove(t);
|
|
736
|
-
return;
|
|
737
|
-
}
|
|
738
|
-
t.data = {
|
|
712
|
+
e.type === `Operator` ? e.value !== `,` && n.remove(t) : t.data = {
|
|
739
713
|
type: `Number`,
|
|
740
714
|
loc: e.loc,
|
|
741
715
|
value: r.packNumber(i.shift())
|
|
@@ -990,7 +964,7 @@ var n = e(((e, t) => {
|
|
|
990
964
|
function c(e, t, n) {
|
|
991
965
|
if (!s(e)) return;
|
|
992
966
|
let r = t.prev && t.prev.data;
|
|
993
|
-
|
|
967
|
+
r && s(r) && e.prelude && r.prelude && e.prelude.id === r.prelude.id && (r.block.children.appendList(e.block.children), n.remove(t));
|
|
994
968
|
}
|
|
995
969
|
function l(e, t) {
|
|
996
970
|
o(e, t), r.walk(e, {
|
|
@@ -1236,7 +1210,8 @@ var n = e(((e, t) => {
|
|
|
1236
1210
|
if (!e || !e.length) return !1;
|
|
1237
1211
|
for (let t in n) if (n[t] !== null && n[t].special !== e[0].special) return !1;
|
|
1238
1212
|
return this.canOverride(r, e[0]) && (n[r] = e[0]), !0;
|
|
1239
|
-
}
|
|
1213
|
+
}
|
|
1214
|
+
if (e === this.name) {
|
|
1240
1215
|
let e = this.getValueSequence(t, 4);
|
|
1241
1216
|
if (!e || !e.length) return !1;
|
|
1242
1217
|
switch (e.length) {
|
|
@@ -1303,16 +1278,12 @@ var n = e(((e, t) => {
|
|
|
1303
1278
|
let l = e.property;
|
|
1304
1279
|
if (!o.hasOwnProperty(l)) return;
|
|
1305
1280
|
let u = o[l], d, f;
|
|
1306
|
-
|
|
1307
|
-
r = null;
|
|
1308
|
-
return;
|
|
1309
|
-
}
|
|
1310
|
-
t[u] = d, n.push({
|
|
1281
|
+
(!r || a === r) && u in t && (f = 2, d = t[u]), (!d || !d.add(l, e)) && (f = 1, d = new s(u), !d.add(l, e)) ? r = null : (t[u] = d, n.push({
|
|
1311
1282
|
operation: f,
|
|
1312
1283
|
block: i,
|
|
1313
1284
|
item: c,
|
|
1314
1285
|
shorthand: d
|
|
1315
|
-
}), r = a;
|
|
1286
|
+
}), r = a);
|
|
1316
1287
|
}), r;
|
|
1317
1288
|
}
|
|
1318
1289
|
function l(e, t) {
|
|
@@ -1556,21 +1527,18 @@ var n = e(((e, t) => {
|
|
|
1556
1527
|
if (e.pseudoSignature !== t.pseudoSignature) return !0;
|
|
1557
1528
|
let l = t.prelude.children.head, u = t.block.children, d = l.data.compareMarker;
|
|
1558
1529
|
if (d in s) return !0;
|
|
1559
|
-
if (r.head === r.tail && r.first.id === l.data.id)
|
|
1560
|
-
|
|
1561
|
-
return;
|
|
1562
|
-
}
|
|
1563
|
-
if (i.isEqualDeclarations(a, u)) {
|
|
1530
|
+
if (r.head === r.tail && r.first.id === l.data.id) a.appendList(u), n.remove(c);
|
|
1531
|
+
else if (i.isEqualDeclarations(a, u)) {
|
|
1564
1532
|
let e = l.data.id;
|
|
1565
1533
|
r.some((t, n) => {
|
|
1566
1534
|
let i = t.id;
|
|
1567
1535
|
if (e < i) return r.insert(l, n), !0;
|
|
1568
1536
|
if (!n.next) return r.insert(l), !0;
|
|
1569
1537
|
}), n.remove(c);
|
|
1570
|
-
|
|
1538
|
+
} else {
|
|
1539
|
+
if (d === o) return !0;
|
|
1540
|
+
s[d] = !0;
|
|
1571
1541
|
}
|
|
1572
|
-
if (d === o) return !0;
|
|
1573
|
-
s[d] = !0;
|
|
1574
1542
|
});
|
|
1575
1543
|
}
|
|
1576
1544
|
function o(e) {
|
|
@@ -1612,31 +1580,33 @@ var n = e(((e, t) => {
|
|
|
1612
1580
|
let v = i.compareDeclarations(l.children, h.children);
|
|
1613
1581
|
if (v.eq.length) {
|
|
1614
1582
|
if (!v.ne1.length && !v.ne2.length) return f && (i.addSelectors(c, _), n.remove(m)), !0;
|
|
1615
|
-
if (!s)
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
children: i.addSelectors(_.copy(), c)
|
|
1626
|
-
}, u = a(s.children) + 2;
|
|
1627
|
-
if (o(v.eq) >= u) {
|
|
1628
|
-
let i = n.createItem({
|
|
1629
|
-
type: `Rule`,
|
|
1583
|
+
if (!s) {
|
|
1584
|
+
if (v.ne1.length && !v.ne2.length) {
|
|
1585
|
+
let e = a(c), t = o(v.eq);
|
|
1586
|
+
d && e < t && (i.addSelectors(_, c), l.children.fromArray(v.ne1));
|
|
1587
|
+
} else if (!v.ne1.length && v.ne2.length) {
|
|
1588
|
+
let e = a(_), t = o(v.eq);
|
|
1589
|
+
f && e < t && (i.addSelectors(c, _), h.children.fromArray(v.ne2));
|
|
1590
|
+
} else {
|
|
1591
|
+
let s = {
|
|
1592
|
+
type: `SelectorList`,
|
|
1630
1593
|
loc: null,
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1594
|
+
children: i.addSelectors(_.copy(), c)
|
|
1595
|
+
}, u = a(s.children) + 2;
|
|
1596
|
+
if (o(v.eq) >= u) {
|
|
1597
|
+
let i = n.createItem({
|
|
1598
|
+
type: `Rule`,
|
|
1634
1599
|
loc: null,
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1600
|
+
prelude: s,
|
|
1601
|
+
block: {
|
|
1602
|
+
type: `Block`,
|
|
1603
|
+
loc: null,
|
|
1604
|
+
children: new r.List().fromArray(v.eq)
|
|
1605
|
+
},
|
|
1606
|
+
pseudoSignature: e.pseudoSignature
|
|
1607
|
+
});
|
|
1608
|
+
return l.children.fromArray(v.ne1), h.children.fromArray(v.ne2overrided), d ? n.insert(i, m) : n.insert(i, t), !0;
|
|
1609
|
+
}
|
|
1640
1610
|
}
|
|
1641
1611
|
}
|
|
1642
1612
|
}
|
|
@@ -1672,9 +1642,7 @@ var n = e(((e, t) => {
|
|
|
1672
1642
|
}
|
|
1673
1643
|
if (i || a) return !0;
|
|
1674
1644
|
o.remove(r), a = e;
|
|
1675
|
-
|
|
1676
|
-
}
|
|
1677
|
-
e.type !== `WhiteSpace` && (i = !0), n.insert(o.remove(r));
|
|
1645
|
+
} else e.type !== `WhiteSpace` && (i = !0), n.insert(o.remove(r));
|
|
1678
1646
|
}), {
|
|
1679
1647
|
comment: a,
|
|
1680
1648
|
stylesheet: {
|
package/dist/_chunks/libs/h3.mjs
CHANGED
|
@@ -2,30 +2,34 @@ import { FastResponse as e, FastURL as t } from "srvx";
|
|
|
2
2
|
const n = (() => {
|
|
3
3
|
let e = function() {};
|
|
4
4
|
return e.prototype = Object.create(null), Object.freeze(e.prototype), e;
|
|
5
|
-
})();
|
|
6
|
-
function
|
|
7
|
-
return
|
|
5
|
+
})(), r = String.raw`%(?:2[146-9A-E]|3[0-9ABD]|4[0-9A-F]|5[0-9ABDF]|6[1-9A-F]|7[0-9ACE])`, i = new RegExp(r, `i`), a = new RegExp(r, `gi`);
|
|
6
|
+
function o(e) {
|
|
7
|
+
return i.test(e);
|
|
8
8
|
}
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
function s(e) {
|
|
10
|
+
return e.replace(a, (e) => String.fromCharCode(Number.parseInt(e.slice(1), 16)));
|
|
11
|
+
}
|
|
12
|
+
function c(e) {
|
|
13
|
+
try {
|
|
14
|
+
return decodeURI(e);
|
|
15
|
+
} catch {
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
const l = `h3.internal.event.`, u = Symbol.for(`${l}res`), d = Symbol.for(`${l}res.headers`), f = Symbol.for(`${l}res.err.headers`), p = Symbol.for(`${l}malformed`);
|
|
20
|
+
var m = class {
|
|
11
21
|
app;
|
|
12
22
|
req;
|
|
13
23
|
url;
|
|
14
24
|
context;
|
|
15
25
|
static __is_event__ = !0;
|
|
16
|
-
constructor(e,
|
|
17
|
-
this.context = e.context =
|
|
18
|
-
let
|
|
19
|
-
|
|
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;
|
|
26
|
+
constructor(e, r, i) {
|
|
27
|
+
this.context = e.context = r || e.context || new n(), this.req = e, this.app = i;
|
|
28
|
+
let a = e._url, l = a && a instanceof URL ? a : new t(e.url), u = l.pathname;
|
|
29
|
+
u.includes(`%`) && (c(u) === void 0 ? this[p] = !0 : o(u) && (l = new t(`${l.protocol}//${l.host}${s(u)}${l.search}`))), this.url = l;
|
|
26
30
|
}
|
|
27
31
|
get res() {
|
|
28
|
-
return this[
|
|
32
|
+
return this[u] ||= new h();
|
|
29
33
|
}
|
|
30
34
|
get runtime() {
|
|
31
35
|
return this.req.runtime;
|
|
@@ -51,24 +55,24 @@ var l = class {
|
|
|
51
55
|
get method() {
|
|
52
56
|
return this.req.method;
|
|
53
57
|
}
|
|
54
|
-
},
|
|
58
|
+
}, h = class {
|
|
55
59
|
status;
|
|
56
60
|
statusText;
|
|
57
61
|
get headers() {
|
|
58
|
-
return this[
|
|
62
|
+
return this[d] ||= new Headers();
|
|
59
63
|
}
|
|
60
64
|
get errHeaders() {
|
|
61
|
-
return this[
|
|
65
|
+
return this[f] ||= new Headers();
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
|
-
const
|
|
65
|
-
function
|
|
66
|
-
return e.replace(
|
|
68
|
+
const g = /[^\u0009\u0020-\u007E]/g;
|
|
69
|
+
function _(e = ``) {
|
|
70
|
+
return e.replace(g, ``);
|
|
67
71
|
}
|
|
68
|
-
function
|
|
72
|
+
function v(e, t = 200) {
|
|
69
73
|
return !e || (typeof e == `string` && (e = +e), !Number.isInteger(e) || e < 100 || e > 599) ? t : e;
|
|
70
74
|
}
|
|
71
|
-
var
|
|
75
|
+
var y = class e extends Error {
|
|
72
76
|
get name() {
|
|
73
77
|
return `HTTPError`;
|
|
74
78
|
}
|
|
@@ -80,7 +84,7 @@ var m = class e extends Error {
|
|
|
80
84
|
body;
|
|
81
85
|
unhandled;
|
|
82
86
|
static isError(e) {
|
|
83
|
-
return e instanceof Error && e?.name === `HTTPError
|
|
87
|
+
return e instanceof Error && e?.name === `HTTPError` && e.status > 99;
|
|
84
88
|
}
|
|
85
89
|
static status(t, n, r) {
|
|
86
90
|
return new e({
|
|
@@ -92,7 +96,7 @@ var m = class e extends Error {
|
|
|
92
96
|
constructor(e, t) {
|
|
93
97
|
let n, r;
|
|
94
98
|
typeof e == `string` ? (n = e, r = t) : r = e;
|
|
95
|
-
let i =
|
|
99
|
+
let i = v(r?.status || r?.statusCode || r?.cause?.status || r?.cause?.statusCode, 500), a = _(r?.statusText || r?.statusMessage || r?.cause?.statusText || r?.cause?.statusMessage), o = n || r?.message || r?.cause?.message || r?.statusText || r?.statusMessage || [
|
|
96
100
|
`HTTPError`,
|
|
97
101
|
i,
|
|
98
102
|
a
|
|
@@ -119,7 +123,7 @@ var m = class e extends Error {
|
|
|
119
123
|
};
|
|
120
124
|
}
|
|
121
125
|
};
|
|
122
|
-
function
|
|
126
|
+
function b(e, t) {
|
|
123
127
|
if (e == null) return !0;
|
|
124
128
|
if (t !== `object`) return t === `boolean` || t === `number` || t === `string`;
|
|
125
129
|
if (typeof e.toJSON == `function` || Array.isArray(e)) return !0;
|
|
@@ -128,99 +132,96 @@ function h(e, t) {
|
|
|
128
132
|
let r = Object.getPrototypeOf(e);
|
|
129
133
|
return r === Object.prototype || r === null;
|
|
130
134
|
}
|
|
131
|
-
const
|
|
132
|
-
function
|
|
133
|
-
if (typeof e?.then == `function`) return e.then((e) =>
|
|
135
|
+
const x = Symbol.for(`h3.internal.event.dispose`), S = Symbol.for(`h3.notFound`), C = Symbol.for(`h3.handled`);
|
|
136
|
+
function w(e, t, n = {}) {
|
|
137
|
+
if (typeof e?.then == `function`) return e.then((e) => w(e, t, n), (e) => w(T(e), t, n));
|
|
134
138
|
let r;
|
|
135
139
|
try {
|
|
136
|
-
r =
|
|
140
|
+
r = O(e, t, n);
|
|
137
141
|
} catch (e) {
|
|
138
|
-
return
|
|
142
|
+
return w(T(e), t, n);
|
|
139
143
|
}
|
|
140
|
-
if (typeof r?.then == `function`) return
|
|
144
|
+
if (typeof r?.then == `function`) return w(r, t, n);
|
|
141
145
|
let { onResponse: i } = n;
|
|
142
146
|
return i ? Promise.resolve().then(() => i(r, t)).catch((e) => {
|
|
143
147
|
n.silent || console.error(e);
|
|
144
|
-
}).then(() => t[
|
|
148
|
+
}).then(() => t[x]?.observe(r, e) ?? r) : t[x]?.observe(r, e) ?? r;
|
|
145
149
|
}
|
|
146
|
-
function
|
|
147
|
-
if (e ===
|
|
148
|
-
if (typeof e == `number`) return new
|
|
149
|
-
let t = new
|
|
150
|
+
function T(e) {
|
|
151
|
+
if (e === S || e === C || e instanceof Error) return e;
|
|
152
|
+
if (typeof e == `number`) return new y({ status: e });
|
|
153
|
+
let t = new y({
|
|
150
154
|
status: 500,
|
|
151
155
|
unhandled: !0
|
|
152
156
|
});
|
|
153
157
|
return t.cause = e, t;
|
|
154
158
|
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
#
|
|
159
|
+
const E = Symbol.for(`h3.HTTPResponse`);
|
|
160
|
+
var D = class {
|
|
161
|
+
#e;
|
|
162
|
+
#t;
|
|
158
163
|
body;
|
|
159
164
|
constructor(e, t) {
|
|
160
|
-
this.body = e, this.#
|
|
165
|
+
this.body = e, this.#t = t;
|
|
161
166
|
}
|
|
162
167
|
get status() {
|
|
163
|
-
return this.#
|
|
168
|
+
return this.#t?.status;
|
|
164
169
|
}
|
|
165
170
|
get statusText() {
|
|
166
|
-
return this.#
|
|
171
|
+
return this.#t?.statusText;
|
|
167
172
|
}
|
|
168
173
|
get headers() {
|
|
169
|
-
return this.#
|
|
174
|
+
return this.#e ||= new Headers(this.#t?.headers);
|
|
170
175
|
}
|
|
171
176
|
};
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
if (t ===
|
|
177
|
+
D.prototype[E] = !0;
|
|
178
|
+
function O(t, n, r, i) {
|
|
179
|
+
if (t === C) return new e(null);
|
|
180
|
+
if (t === S && (t = new y({
|
|
175
181
|
status: 404,
|
|
176
182
|
message: `Cannot find any route matching [${n.req.method}] ${n.url}`
|
|
177
183
|
})), t && t instanceof Error) {
|
|
178
|
-
let e =
|
|
179
|
-
e || (
|
|
180
|
-
let { onError:
|
|
181
|
-
return
|
|
184
|
+
let e = y.isError(t), a = e ? t : new y(t);
|
|
185
|
+
e || (a.unhandled = !0, t?.stack && (a.stack = t.stack)), a.unhandled && !r.silent && console.error(a);
|
|
186
|
+
let { onError: o } = r, s = n[u]?.[f];
|
|
187
|
+
return o && !i ? Promise.resolve().then(() => o(a, n)).catch(T).then((e) => O(e ?? t, n, r, !0)) : (n[u] = void 0, I(a, r.debug, s));
|
|
182
188
|
}
|
|
183
|
-
let
|
|
184
|
-
if (n[
|
|
185
|
-
let i =
|
|
186
|
-
return new e(
|
|
187
|
-
status:
|
|
188
|
-
statusText:
|
|
189
|
-
headers: i.headers &&
|
|
189
|
+
let a = n[u], o = a?.[d];
|
|
190
|
+
if (n[u] = void 0, !(t instanceof Response)) {
|
|
191
|
+
let i = P(t, n, r), s = i.status || a?.status, c = s ? v(s) : void 0, l = i.statusText || a?.statusText;
|
|
192
|
+
return new e(F(n.req.method, c) ? null : i.body, {
|
|
193
|
+
status: c,
|
|
194
|
+
statusText: l === void 0 ? void 0 : _(l),
|
|
195
|
+
headers: i.headers && o ? k(i.headers, o) : i.headers || o
|
|
190
196
|
});
|
|
191
197
|
}
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
statusText: t.statusText,
|
|
198
|
-
headers: C(t.headers, l)
|
|
199
|
-
});
|
|
200
|
-
}
|
|
201
|
-
return n.req.method === `HEAD` && t.body !== null ? new e(null, {
|
|
198
|
+
return t.status >= 400 && (o = a?.[f]), o && !i && !o.keys().next().done ? new e(F(n.req.method, t.status) ? null : t.body, {
|
|
199
|
+
status: t.status,
|
|
200
|
+
statusText: t.statusText,
|
|
201
|
+
headers: k(t.headers, o)
|
|
202
|
+
}) : n.req.method === `HEAD` && t.body !== null ? new e(null, {
|
|
202
203
|
status: t.status,
|
|
203
204
|
statusText: t.statusText,
|
|
204
205
|
headers: t.headers
|
|
205
206
|
}) : t;
|
|
206
207
|
}
|
|
207
|
-
function
|
|
208
|
+
function k(e, t, n = new Headers(e)) {
|
|
208
209
|
for (let [e, r] of t) e === `set-cookie` ? n.append(e, r) : n.set(e, r);
|
|
209
210
|
return n;
|
|
210
211
|
}
|
|
211
|
-
const
|
|
212
|
+
const A = (e) => (...t) => {
|
|
212
213
|
throw Error(`Headers are frozen (${e} ${t.join(`, `)})`);
|
|
213
214
|
};
|
|
214
|
-
var
|
|
215
|
-
set =
|
|
216
|
-
append =
|
|
217
|
-
delete =
|
|
215
|
+
var j = class extends Headers {
|
|
216
|
+
set = A(`set`);
|
|
217
|
+
append = A(`append`);
|
|
218
|
+
delete = A(`delete`);
|
|
218
219
|
};
|
|
219
|
-
const
|
|
220
|
-
function
|
|
220
|
+
const M = new j({ "content-length": `0` }), N = new j({ "content-type": `application/json;charset=UTF-8` });
|
|
221
|
+
function P(e, t, n) {
|
|
221
222
|
if (e == null) return {
|
|
222
223
|
body: ``,
|
|
223
|
-
headers:
|
|
224
|
+
headers: M
|
|
224
225
|
};
|
|
225
226
|
let r = typeof e;
|
|
226
227
|
if (r === `string`) return { body: e };
|
|
@@ -228,14 +229,14 @@ function O(e, t, n) {
|
|
|
228
229
|
body: e,
|
|
229
230
|
headers: new Headers({ "content-length": e.byteLength.toString() })
|
|
230
231
|
};
|
|
231
|
-
if (e instanceof
|
|
232
|
-
if (
|
|
232
|
+
if (e instanceof D || e?.[E] === !0) return e;
|
|
233
|
+
if (b(e, r)) return {
|
|
233
234
|
body: JSON.stringify(e, void 0, n.debug ? 2 : void 0),
|
|
234
|
-
headers:
|
|
235
|
+
headers: N
|
|
235
236
|
};
|
|
236
237
|
if (r === `bigint`) return {
|
|
237
238
|
body: e.toString(),
|
|
238
|
-
headers:
|
|
239
|
+
headers: N
|
|
239
240
|
};
|
|
240
241
|
if (e instanceof Blob) {
|
|
241
242
|
let t = new Headers({
|
|
@@ -249,12 +250,12 @@ function O(e, t, n) {
|
|
|
249
250
|
}
|
|
250
251
|
return r === `symbol` ? { body: e.toString() } : r === `function` ? { body: `${e.name}()` } : { body: e };
|
|
251
252
|
}
|
|
252
|
-
function
|
|
253
|
+
function F(e, t) {
|
|
253
254
|
return e === `HEAD` || t === 100 || t === 101 || t === 102 || t === 204 || t === 205 || t === 304;
|
|
254
255
|
}
|
|
255
|
-
function
|
|
256
|
-
let i = t.headers ?
|
|
257
|
-
return r && (i =
|
|
256
|
+
function I(t, n, r) {
|
|
257
|
+
let i = t.headers ? k(N, t.headers) : new Headers(N);
|
|
258
|
+
return r && (i = k(i, r)), new e(JSON.stringify({
|
|
258
259
|
...t.toJSON(),
|
|
259
260
|
stack: n && t.stack ? t.stack.split(`
|
|
260
261
|
`).map((e) => e.trim()) : void 0
|
|
@@ -264,46 +265,46 @@ function A(t, n, r) {
|
|
|
264
265
|
headers: i
|
|
265
266
|
});
|
|
266
267
|
}
|
|
267
|
-
function
|
|
268
|
+
function L(e) {
|
|
268
269
|
let t = (e, t) => t(e);
|
|
269
270
|
for (let n = e.length - 1; n >= 0; n--) {
|
|
270
271
|
let r = e[n], i = t;
|
|
271
|
-
t = (e, t) =>
|
|
272
|
+
t = (e, t) => z(r, e, t, i);
|
|
272
273
|
}
|
|
273
274
|
return t;
|
|
274
275
|
}
|
|
275
|
-
function
|
|
276
|
-
let n =
|
|
276
|
+
function R(e, t) {
|
|
277
|
+
let n = L(e);
|
|
277
278
|
return function(e) {
|
|
278
279
|
return n(e, t);
|
|
279
280
|
};
|
|
280
281
|
}
|
|
281
|
-
function
|
|
282
|
-
let i, a, o = () => i
|
|
283
|
-
return
|
|
282
|
+
function z(e, t, n, r) {
|
|
283
|
+
let i, a, o = () => (i || (i = !0, a = r(t, n)), a), s = e(t, o);
|
|
284
|
+
return B(s) ? o() : typeof s?.then == `function` ? s.then((e) => B(e) ? o() : e) : s;
|
|
284
285
|
}
|
|
285
|
-
function
|
|
286
|
-
return e === void 0 || e ===
|
|
286
|
+
function B(e) {
|
|
287
|
+
return e === void 0 || e === S;
|
|
287
288
|
}
|
|
288
|
-
function
|
|
289
|
-
if (typeof e == `function`) return
|
|
289
|
+
function V(e) {
|
|
290
|
+
if (typeof e == `function`) return H(e);
|
|
290
291
|
let t = e.handler || (e.fetch ? function(t) {
|
|
291
292
|
return e.fetch(t.req);
|
|
292
|
-
} :
|
|
293
|
-
return Object.assign(
|
|
293
|
+
} : U), n = e.middleware?.length && R(e.middleware, t), r = H(n || t);
|
|
294
|
+
return Object.assign(r, e, n && { fetch: r.fetch });
|
|
294
295
|
}
|
|
295
|
-
function
|
|
296
|
+
function H(e) {
|
|
296
297
|
return `fetch` in e ? e : Object.assign(e, { fetch: (t) => {
|
|
297
298
|
typeof t == `string` && (t = new URL(t, `http://_`)), t instanceof URL && (t = new Request(t));
|
|
298
|
-
let n = new
|
|
299
|
+
let n = new m(t);
|
|
299
300
|
try {
|
|
300
|
-
return Promise.resolve(
|
|
301
|
+
return Promise.resolve(w(e(n), n));
|
|
301
302
|
} catch (e) {
|
|
302
|
-
return Promise.resolve(
|
|
303
|
+
return Promise.resolve(w(T(e), n));
|
|
303
304
|
}
|
|
304
305
|
} });
|
|
305
306
|
}
|
|
306
|
-
const
|
|
307
|
+
const U = () => S;
|
|
307
308
|
String.raw`(?:^|/)(?:\.|%(?:25)*2e){1,2}(?:/|$)`, String.raw`%(?:25)*(?:2f|5c)`;
|
|
308
|
-
const
|
|
309
|
-
export {
|
|
309
|
+
const W = V;
|
|
310
|
+
export { y as HTTPError, W as defineEventHandler };
|