ipx 4.0.0-alpha.2 → 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 +505 -77
- package/dist/THIRD-PARTY-LICENSES.md.gz +0 -0
- package/dist/_chunks/libs/@fastify/accept-negotiator.mjs +23 -24
- package/dist/_chunks/libs/crossws.d.mts +1 -0
- package/dist/_chunks/libs/css-select.mjs +1078 -938
- package/dist/_chunks/libs/css-tree.mjs +175 -297
- package/dist/_chunks/libs/csso.mjs +65 -110
- package/dist/_chunks/libs/etag.mjs +1 -1
- package/dist/_chunks/libs/h3.d.mts +3 -0
- package/dist/_chunks/libs/h3.mjs +138 -95
- package/dist/_chunks/libs/image-meta.d.mts +2 -6
- package/dist/_chunks/libs/image-meta.mjs +465 -306
- package/dist/_chunks/libs/sax.mjs +82 -80
- package/dist/_chunks/libs/svgo.mjs +970 -1013
- package/dist/_chunks/libs/ufo.mjs +17 -24
- package/dist/_chunks/node-fs.mjs +1100 -200
- package/dist/_chunks/rolldown-runtime.mjs +2 -11
- package/dist/cli.d.mts +1 -1
- package/dist/cli.mjs +4 -3
- package/dist/index.d.mts +242 -21
- package/dist/index.mjs +2 -2
- package/package.json +32 -28
- package/dist/THIRD-PARTY-LICENSES.md +0 -539
package/dist/_chunks/libs/h3.mjs
CHANGED
|
@@ -2,24 +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 =
|
|
18
|
-
let
|
|
19
|
-
|
|
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;
|
|
20
30
|
}
|
|
21
31
|
get res() {
|
|
22
|
-
return this[
|
|
32
|
+
return this[u] ||= new h();
|
|
23
33
|
}
|
|
24
34
|
get runtime() {
|
|
25
35
|
return this.req.runtime;
|
|
@@ -45,24 +55,24 @@ var c = class {
|
|
|
45
55
|
get method() {
|
|
46
56
|
return this.req.method;
|
|
47
57
|
}
|
|
48
|
-
},
|
|
58
|
+
}, h = class {
|
|
49
59
|
status;
|
|
50
60
|
statusText;
|
|
51
61
|
get headers() {
|
|
52
|
-
return this[
|
|
62
|
+
return this[d] ||= new Headers();
|
|
53
63
|
}
|
|
54
64
|
get errHeaders() {
|
|
55
|
-
return this[
|
|
65
|
+
return this[f] ||= new Headers();
|
|
56
66
|
}
|
|
57
67
|
};
|
|
58
|
-
const
|
|
59
|
-
function
|
|
60
|
-
return e.replace(
|
|
68
|
+
const g = /[^\u0009\u0020-\u007E]/g;
|
|
69
|
+
function _(e = ``) {
|
|
70
|
+
return e.replace(g, ``);
|
|
61
71
|
}
|
|
62
|
-
function
|
|
63
|
-
return !e || (typeof e == `string` && (e = +e), e < 100 || e > 599) ? t : e;
|
|
72
|
+
function v(e, t = 200) {
|
|
73
|
+
return !e || (typeof e == `string` && (e = +e), !Number.isInteger(e) || e < 100 || e > 599) ? t : e;
|
|
64
74
|
}
|
|
65
|
-
var
|
|
75
|
+
var y = class e extends Error {
|
|
66
76
|
get name() {
|
|
67
77
|
return `HTTPError`;
|
|
68
78
|
}
|
|
@@ -74,7 +84,7 @@ var p = class e extends Error {
|
|
|
74
84
|
body;
|
|
75
85
|
unhandled;
|
|
76
86
|
static isError(e) {
|
|
77
|
-
return e instanceof Error && e?.name === `HTTPError
|
|
87
|
+
return e instanceof Error && e?.name === `HTTPError` && e.status > 99;
|
|
78
88
|
}
|
|
79
89
|
static status(t, n, r) {
|
|
80
90
|
return new e({
|
|
@@ -86,7 +96,7 @@ var p = class e extends Error {
|
|
|
86
96
|
constructor(e, t) {
|
|
87
97
|
let n, r;
|
|
88
98
|
typeof e == `string` ? (n = e, r = t) : r = e;
|
|
89
|
-
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 || [
|
|
90
100
|
`HTTPError`,
|
|
91
101
|
i,
|
|
92
102
|
a
|
|
@@ -113,7 +123,7 @@ var p = class e extends Error {
|
|
|
113
123
|
};
|
|
114
124
|
}
|
|
115
125
|
};
|
|
116
|
-
function
|
|
126
|
+
function b(e, t) {
|
|
117
127
|
if (e == null) return !0;
|
|
118
128
|
if (t !== `object`) return t === `boolean` || t === `number` || t === `string`;
|
|
119
129
|
if (typeof e.toJSON == `function` || Array.isArray(e)) return !0;
|
|
@@ -122,91 +132,111 @@ function m(e, t) {
|
|
|
122
132
|
let r = Object.getPrototypeOf(e);
|
|
123
133
|
return r === Object.prototype || r === null;
|
|
124
134
|
}
|
|
125
|
-
const
|
|
126
|
-
function
|
|
127
|
-
if (typeof e?.then == `function`) return e.then((e) =>
|
|
128
|
-
let r
|
|
129
|
-
|
|
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));
|
|
138
|
+
let r;
|
|
139
|
+
try {
|
|
140
|
+
r = O(e, t, n);
|
|
141
|
+
} catch (e) {
|
|
142
|
+
return w(T(e), t, n);
|
|
143
|
+
}
|
|
144
|
+
if (typeof r?.then == `function`) return w(r, t, n);
|
|
130
145
|
let { onResponse: i } = n;
|
|
131
|
-
return i ? Promise.resolve(i(r, t)).
|
|
146
|
+
return i ? Promise.resolve().then(() => i(r, t)).catch((e) => {
|
|
147
|
+
n.silent || console.error(e);
|
|
148
|
+
}).then(() => t[x]?.observe(r, e) ?? r) : t[x]?.observe(r, e) ?? r;
|
|
149
|
+
}
|
|
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({
|
|
154
|
+
status: 500,
|
|
155
|
+
unhandled: !0
|
|
156
|
+
});
|
|
157
|
+
return t.cause = e, t;
|
|
132
158
|
}
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
#
|
|
159
|
+
const E = Symbol.for(`h3.HTTPResponse`);
|
|
160
|
+
var D = class {
|
|
161
|
+
#e;
|
|
162
|
+
#t;
|
|
136
163
|
body;
|
|
137
164
|
constructor(e, t) {
|
|
138
|
-
this.body = e, this.#
|
|
165
|
+
this.body = e, this.#t = t;
|
|
139
166
|
}
|
|
140
167
|
get status() {
|
|
141
|
-
return this.#
|
|
168
|
+
return this.#t?.status;
|
|
142
169
|
}
|
|
143
170
|
get statusText() {
|
|
144
|
-
return this.#
|
|
171
|
+
return this.#t?.statusText;
|
|
145
172
|
}
|
|
146
173
|
get headers() {
|
|
147
|
-
return this.#
|
|
174
|
+
return this.#e ||= new Headers(this.#t?.headers);
|
|
148
175
|
}
|
|
149
176
|
};
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
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({
|
|
153
181
|
status: 404,
|
|
154
182
|
message: `Cannot find any route matching [${n.req.method}] ${n.url}`
|
|
155
183
|
})), t && t instanceof Error) {
|
|
156
|
-
let e =
|
|
157
|
-
e || (
|
|
158
|
-
let { onError:
|
|
159
|
-
return
|
|
160
|
-
}
|
|
161
|
-
let c = n[a], l = c?.[o];
|
|
162
|
-
if (n[a] = void 0, !(t instanceof Response)) {
|
|
163
|
-
let i = T(t, n, r), a = i.status || c?.status;
|
|
164
|
-
return new e(E(n.req.method, a) ? null : i.body, {
|
|
165
|
-
status: a,
|
|
166
|
-
statusText: i.statusText || c?.statusText,
|
|
167
|
-
headers: i.headers && l ? b(i.headers, l) : i.headers || l
|
|
168
|
-
});
|
|
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));
|
|
169
188
|
}
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
headers: b(t.headers, l)
|
|
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
|
|
178
196
|
});
|
|
179
197
|
}
|
|
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, {
|
|
203
|
+
status: t.status,
|
|
204
|
+
statusText: t.statusText,
|
|
205
|
+
headers: t.headers
|
|
206
|
+
}) : t;
|
|
180
207
|
}
|
|
181
|
-
function
|
|
208
|
+
function k(e, t, n = new Headers(e)) {
|
|
182
209
|
for (let [e, r] of t) e === `set-cookie` ? n.append(e, r) : n.set(e, r);
|
|
183
210
|
return n;
|
|
184
211
|
}
|
|
185
|
-
const
|
|
212
|
+
const A = (e) => (...t) => {
|
|
186
213
|
throw Error(`Headers are frozen (${e} ${t.join(`, `)})`);
|
|
187
214
|
};
|
|
188
|
-
var
|
|
189
|
-
set =
|
|
190
|
-
append =
|
|
191
|
-
delete =
|
|
215
|
+
var j = class extends Headers {
|
|
216
|
+
set = A(`set`);
|
|
217
|
+
append = A(`append`);
|
|
218
|
+
delete = A(`delete`);
|
|
192
219
|
};
|
|
193
|
-
const
|
|
194
|
-
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) {
|
|
195
222
|
if (e == null) return {
|
|
196
223
|
body: ``,
|
|
197
|
-
headers:
|
|
224
|
+
headers: M
|
|
198
225
|
};
|
|
199
226
|
let r = typeof e;
|
|
200
227
|
if (r === `string`) return { body: e };
|
|
201
|
-
if (e instanceof Uint8Array) return
|
|
202
|
-
|
|
203
|
-
|
|
228
|
+
if (e instanceof Uint8Array) return {
|
|
229
|
+
body: e,
|
|
230
|
+
headers: new Headers({ "content-length": e.byteLength.toString() })
|
|
231
|
+
};
|
|
232
|
+
if (e instanceof D || e?.[E] === !0) return e;
|
|
233
|
+
if (b(e, r)) return {
|
|
204
234
|
body: JSON.stringify(e, void 0, n.debug ? 2 : void 0),
|
|
205
|
-
headers:
|
|
235
|
+
headers: N
|
|
206
236
|
};
|
|
207
237
|
if (r === `bigint`) return {
|
|
208
238
|
body: e.toString(),
|
|
209
|
-
headers:
|
|
239
|
+
headers: N
|
|
210
240
|
};
|
|
211
241
|
if (e instanceof Blob) {
|
|
212
242
|
let t = new Headers({
|
|
@@ -220,12 +250,12 @@ function T(e, t, n) {
|
|
|
220
250
|
}
|
|
221
251
|
return r === `symbol` ? { body: e.toString() } : r === `function` ? { body: `${e.name}()` } : { body: e };
|
|
222
252
|
}
|
|
223
|
-
function
|
|
253
|
+
function F(e, t) {
|
|
224
254
|
return e === `HEAD` || t === 100 || t === 101 || t === 102 || t === 204 || t === 205 || t === 304;
|
|
225
255
|
}
|
|
226
|
-
function
|
|
227
|
-
let i = t.headers ?
|
|
228
|
-
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({
|
|
229
259
|
...t.toJSON(),
|
|
230
260
|
stack: n && t.stack ? t.stack.split(`
|
|
231
261
|
`).map((e) => e.trim()) : void 0
|
|
@@ -235,33 +265,46 @@ function D(t, n, r) {
|
|
|
235
265
|
headers: i
|
|
236
266
|
});
|
|
237
267
|
}
|
|
238
|
-
function
|
|
239
|
-
|
|
240
|
-
let
|
|
241
|
-
|
|
268
|
+
function L(e) {
|
|
269
|
+
let t = (e, t) => t(e);
|
|
270
|
+
for (let n = e.length - 1; n >= 0; n--) {
|
|
271
|
+
let r = e[n], i = t;
|
|
272
|
+
t = (e, t) => z(r, e, t, i);
|
|
273
|
+
}
|
|
274
|
+
return t;
|
|
275
|
+
}
|
|
276
|
+
function R(e, t) {
|
|
277
|
+
let n = L(e);
|
|
278
|
+
return function(e) {
|
|
279
|
+
return n(e, t);
|
|
280
|
+
};
|
|
281
|
+
}
|
|
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;
|
|
242
285
|
}
|
|
243
|
-
function
|
|
244
|
-
return e === void 0 || e ===
|
|
286
|
+
function B(e) {
|
|
287
|
+
return e === void 0 || e === S;
|
|
245
288
|
}
|
|
246
|
-
function
|
|
247
|
-
if (typeof e == `function`) return
|
|
289
|
+
function V(e) {
|
|
290
|
+
if (typeof e == `function`) return H(e);
|
|
248
291
|
let t = e.handler || (e.fetch ? function(t) {
|
|
249
292
|
return e.fetch(t.req);
|
|
250
|
-
} :
|
|
251
|
-
return Object.assign(
|
|
252
|
-
return O(n, e.middleware, t);
|
|
253
|
-
} : t), e);
|
|
293
|
+
} : U), n = e.middleware?.length && R(e.middleware, t), r = H(n || t);
|
|
294
|
+
return Object.assign(r, e, n && { fetch: r.fetch });
|
|
254
295
|
}
|
|
255
|
-
function
|
|
296
|
+
function H(e) {
|
|
256
297
|
return `fetch` in e ? e : Object.assign(e, { fetch: (t) => {
|
|
257
298
|
typeof t == `string` && (t = new URL(t, `http://_`)), t instanceof URL && (t = new Request(t));
|
|
258
|
-
let n = new
|
|
299
|
+
let n = new m(t);
|
|
259
300
|
try {
|
|
260
|
-
return Promise.resolve(
|
|
301
|
+
return Promise.resolve(w(e(n), n));
|
|
261
302
|
} catch (e) {
|
|
262
|
-
return Promise.resolve(
|
|
303
|
+
return Promise.resolve(w(T(e), n));
|
|
263
304
|
}
|
|
264
305
|
} });
|
|
265
306
|
}
|
|
266
|
-
const
|
|
267
|
-
|
|
307
|
+
const U = () => S;
|
|
308
|
+
String.raw`(?:^|/)(?:\.|%(?:25)*2e){1,2}(?:/|$)`, String.raw`%(?:25)*(?:2f|5c)`;
|
|
309
|
+
const W = V;
|
|
310
|
+
export { y as HTTPError, W as defineEventHandler };
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
type e = {
|
|
2
2
|
images?: Omit<e, "images">[];
|
|
3
|
-
width: number
|
|
4
|
-
height: number
|
|
3
|
+
width: number;
|
|
4
|
+
height: number;
|
|
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 };
|