build(deps-dev): bump h3 from 1.6.6 to 1.7.0 (#128)
* build(deps-dev): bump h3 from 1.6.6 to 1.7.0 Bumps [h3](https://github.com/unjs/h3) from 1.6.6 to 1.7.0. - [Release notes](https://github.com/unjs/h3/releases) - [Changelog](https://github.com/unjs/h3/blob/main/CHANGELOG.md) - [Commits](https://github.com/unjs/h3/compare/v1.6.6...v1.7.0) --- updated-dependencies: - dependency-name: h3 dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] <support@github.com> * chore(mock server): build with updated dependencies --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Iain Sproat <68657+iainsproat@users.noreply.github.com>
This commit is contained in:
+74
-34
@@ -1313,7 +1313,7 @@ function createError(input) {
|
||||
return err;
|
||||
}
|
||||
function sendError(event, error, debug) {
|
||||
if (event.node.res.writableEnded) {
|
||||
if (event.handled) {
|
||||
return;
|
||||
}
|
||||
const h3Error = isError(error) ? error : createError(error);
|
||||
@@ -1326,7 +1326,7 @@ function sendError(event, error, debug) {
|
||||
if (debug) {
|
||||
responseBody.stack = (h3Error.stack || "").split("\n").map((l) => l.trim());
|
||||
}
|
||||
if (event.node.res.writableEnded) {
|
||||
if (event.handled) {
|
||||
return;
|
||||
}
|
||||
const _code = Number.parseInt(h3Error.statusCode);
|
||||
@@ -1422,9 +1422,15 @@ function readRawBody(event, encoding = "utf8") {
|
||||
assertMethod(event, PayloadMethods$1);
|
||||
const _rawBody = event.node.req[RawBodySymbol] || event.node.req.body;
|
||||
if (_rawBody) {
|
||||
const promise2 = Promise.resolve(_rawBody).then(
|
||||
(_resolved) => Buffer.isBuffer(_resolved) ? _resolved : Buffer.from(_resolved)
|
||||
);
|
||||
const promise2 = Promise.resolve(_rawBody).then((_resolved) => {
|
||||
if (Buffer.isBuffer(_resolved)) {
|
||||
return _resolved;
|
||||
}
|
||||
if (_resolved.constructor === Object) {
|
||||
return Buffer.from(JSON.stringify(_resolved));
|
||||
}
|
||||
return Buffer.from(_resolved);
|
||||
});
|
||||
return encoding ? promise2.then((buff) => buff.toString(encoding)) : promise2;
|
||||
}
|
||||
if (!Number.parseInt(event.node.req.headers["content-length"] || "")) {
|
||||
@@ -1509,7 +1515,9 @@ function handleCacheHeaders(event, opts) {
|
||||
event.node.res.setHeader("cache-control", cacheControls.join(", "));
|
||||
if (cacheMatched) {
|
||||
event.node.res.statusCode = 304;
|
||||
event.node.res.end();
|
||||
if (!event.handled) {
|
||||
event.node.res.end();
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -1658,6 +1666,7 @@ async function sendProxy(event, target, opts = {}) {
|
||||
event.node.res.statusCode
|
||||
);
|
||||
event.node.res.statusMessage = sanitizeStatusMessage(response.statusText);
|
||||
const cookies = [];
|
||||
for (const [key, value] of response.headers.entries()) {
|
||||
if (key === "content-encoding") {
|
||||
continue;
|
||||
@@ -1666,7 +1675,15 @@ async function sendProxy(event, target, opts = {}) {
|
||||
continue;
|
||||
}
|
||||
if (key === "set-cookie") {
|
||||
const cookies = splitCookiesString(value).map((cookie) => {
|
||||
cookies.push(...splitCookiesString(value));
|
||||
continue;
|
||||
}
|
||||
event.node.res.setHeader(key, value);
|
||||
}
|
||||
if (cookies.length > 0) {
|
||||
event.node.res.setHeader(
|
||||
"set-cookie",
|
||||
cookies.map((cookie) => {
|
||||
if (opts.cookieDomainRewrite) {
|
||||
cookie = rewriteCookieProperty(
|
||||
cookie,
|
||||
@@ -1682,15 +1699,18 @@ async function sendProxy(event, target, opts = {}) {
|
||||
);
|
||||
}
|
||||
return cookie;
|
||||
});
|
||||
event.node.res.setHeader("set-cookie", cookies);
|
||||
continue;
|
||||
}
|
||||
event.node.res.setHeader(key, value);
|
||||
})
|
||||
);
|
||||
}
|
||||
if (opts.onResponse) {
|
||||
await opts.onResponse(event, response);
|
||||
}
|
||||
if (response._data !== void 0) {
|
||||
return response._data;
|
||||
}
|
||||
if (event.handled) {
|
||||
return;
|
||||
}
|
||||
if (opts.sendStream === false) {
|
||||
const data = new Uint8Array(await response.arrayBuffer());
|
||||
return event.node.res.end(data);
|
||||
@@ -1749,14 +1769,16 @@ function rewriteCookieProperty(header, map, property) {
|
||||
);
|
||||
}
|
||||
|
||||
const defer = typeof setImmediate !== "undefined" ? setImmediate : (fn) => fn();
|
||||
const defer = typeof setImmediate === "undefined" ? (fn) => fn() : setImmediate;
|
||||
function send(event, data, type) {
|
||||
if (type) {
|
||||
defaultContentType(event, type);
|
||||
}
|
||||
return new Promise((resolve) => {
|
||||
defer(() => {
|
||||
event.node.res.end(data);
|
||||
if (!event.handled) {
|
||||
event.node.res.end(data);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
@@ -1766,7 +1788,9 @@ function sendNoContent(event, code = 204) {
|
||||
if (event.node.res.statusCode === 204) {
|
||||
event.node.res.removeHeader("content-length");
|
||||
}
|
||||
event.node.res.end();
|
||||
if (!event.handled) {
|
||||
event.node.res.end();
|
||||
}
|
||||
}
|
||||
function setResponseStatus(event, code, text) {
|
||||
if (code) {
|
||||
@@ -1949,7 +1973,7 @@ async function getSession(event, config) {
|
||||
Object.assign(session, unsealed);
|
||||
}
|
||||
if (!session.id) {
|
||||
session.id = (config.crypto || crypto).randomUUID();
|
||||
session.id = config.generateId?.() ?? (config.crypto || crypto).randomUUID();
|
||||
session.createdAt = Date.now();
|
||||
await updateSession(event, config);
|
||||
}
|
||||
@@ -2220,12 +2244,16 @@ class H3Response {
|
||||
class H3Event {
|
||||
constructor(req, res) {
|
||||
this["__is_event__"] = true;
|
||||
this._handled = false;
|
||||
this.context = {};
|
||||
this.node = { req, res };
|
||||
}
|
||||
get path() {
|
||||
return getRequestPath(this);
|
||||
}
|
||||
get handled() {
|
||||
return this._handled || this.node.res.writableEnded || this.node.res.headersSent;
|
||||
}
|
||||
/** @deprecated Please use `event.node.req` instead. **/
|
||||
get req() {
|
||||
return this.node.req;
|
||||
@@ -2237,35 +2265,37 @@ class H3Event {
|
||||
// Implementation of FetchEvent
|
||||
respondWith(r) {
|
||||
Promise.resolve(r).then((_response) => {
|
||||
if (this.res.writableEnded) {
|
||||
if (this.handled) {
|
||||
return;
|
||||
}
|
||||
const response = _response instanceof H3Response ? _response : new H3Response(_response);
|
||||
for (const [key, value] of response.headers.entries()) {
|
||||
this.res.setHeader(key, value);
|
||||
this.node.res.setHeader(key, value);
|
||||
}
|
||||
if (response.status) {
|
||||
this.res.statusCode = sanitizeStatusCode(
|
||||
this.node.res.statusCode = sanitizeStatusCode(
|
||||
response.status,
|
||||
this.res.statusCode
|
||||
this.node.res.statusCode
|
||||
);
|
||||
}
|
||||
if (response.statusText) {
|
||||
this.res.statusMessage = sanitizeStatusMessage(response.statusText);
|
||||
this.node.res.statusMessage = sanitizeStatusMessage(
|
||||
response.statusText
|
||||
);
|
||||
}
|
||||
if (response.redirected) {
|
||||
this.res.setHeader("location", response.url);
|
||||
this.node.res.setHeader("location", response.url);
|
||||
}
|
||||
if (!response._body) {
|
||||
return this.res.end();
|
||||
return this.node.res.end();
|
||||
}
|
||||
if (typeof response._body === "string" || "buffer" in response._body || "byteLength" in response._body) {
|
||||
return this.res.end(response._body);
|
||||
return this.node.res.end(response._body);
|
||||
}
|
||||
if (!response.headers.has("content-type")) {
|
||||
response.headers.set("content-type", MIMES.json);
|
||||
}
|
||||
this.res.end(JSON.stringify(response._body));
|
||||
this.node.res.end(JSON.stringify(response._body));
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -2391,7 +2421,7 @@ function createAppEventHandler(stack, options) {
|
||||
continue;
|
||||
}
|
||||
const val = await layer.handler(event);
|
||||
if (event.node.res.writableEnded) {
|
||||
if (event.handled) {
|
||||
return;
|
||||
}
|
||||
const type = typeof val;
|
||||
@@ -2416,10 +2446,10 @@ function createAppEventHandler(stack, options) {
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!event.node.res.writableEnded) {
|
||||
if (!event.handled) {
|
||||
throw createError({
|
||||
statusCode: 404,
|
||||
statusMessage: `Cannot find any route matching ${event.node.req.url || "/"}.`
|
||||
statusMessage: `Cannot find any path matching ${event.node.req.url || "/"}.`
|
||||
});
|
||||
}
|
||||
});
|
||||
@@ -2567,15 +2597,25 @@ function dist_createRouter(opts = {}) {
|
||||
const method = (event.node.req.method || "get").toLowerCase();
|
||||
const handler = matched.handlers[method] || matched.handlers.all;
|
||||
if (!handler) {
|
||||
throw createError({
|
||||
statusCode: 405,
|
||||
name: "Method Not Allowed",
|
||||
statusMessage: `Method ${method} is not allowed on this route.`
|
||||
});
|
||||
if (opts.preemptive || opts.preemtive) {
|
||||
throw createError({
|
||||
statusCode: 405,
|
||||
name: "Method Not Allowed",
|
||||
statusMessage: `Method ${method} is not allowed on this route.`
|
||||
});
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
}
|
||||
const params = matched.params || {};
|
||||
event.context.params = params;
|
||||
return handler(event);
|
||||
return Promise.resolve(handler(event)).then((res) => {
|
||||
if (res === void 0 && (opts.preemptive || opts.preemtive)) {
|
||||
setResponseStatus(event, 204);
|
||||
return "";
|
||||
}
|
||||
return res;
|
||||
});
|
||||
});
|
||||
return router;
|
||||
}
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
+1
-1
@@ -49,7 +49,7 @@
|
||||
"eslint-plugin-prettier": "^4.2.1",
|
||||
"eslint-plugin-vitest": "^0.2.6",
|
||||
"get-port-please": "^3.0.1",
|
||||
"h3": "^1.6.6",
|
||||
"h3": "^1.7.0",
|
||||
"js-yaml": "^4.1.0",
|
||||
"listhen": "^1.0.4",
|
||||
"msw": "^1.2.2",
|
||||
|
||||
@@ -2052,10 +2052,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"destr@npm:^1.2.2":
|
||||
version: 1.2.2
|
||||
resolution: "destr@npm:1.2.2"
|
||||
checksum: 3906b49513a64d8442dacb8b798c59d66257ded4ccd2ef1d99b58644d4aa6b30ca61f9a9823d3dcbc78b4db812596e53e85e499f39a498b3b165a045b5228b2b
|
||||
"destr@npm:^2.0.0":
|
||||
version: 2.0.0
|
||||
resolution: "destr@npm:2.0.0"
|
||||
checksum: 5439cfc8e4b207a4c77cce89b3490dcb68b8cbea1ea5171958b89ae1a814a8f988e54e259d9dae8ebee64cfc9d658497e96d0a8905b2d243cf49bda36e578850
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -3179,18 +3179,18 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"h3@npm:^1.6.6":
|
||||
version: 1.6.6
|
||||
resolution: "h3@npm:1.6.6"
|
||||
"h3@npm:^1.7.0":
|
||||
version: 1.7.0
|
||||
resolution: "h3@npm:1.7.0"
|
||||
dependencies:
|
||||
cookie-es: ^1.0.0
|
||||
defu: ^6.1.2
|
||||
destr: ^1.2.2
|
||||
destr: ^2.0.0
|
||||
iron-webcrypto: ^0.7.0
|
||||
radix3: ^1.0.1
|
||||
ufo: ^1.1.2
|
||||
uncrypto: ^0.1.2
|
||||
checksum: 58a24d0f5eeff0e36caf7299d0237c43e0e10b9fcc8f8858aec51bcac0a0ab6ed28ebff199119a62e5571c0c35e6788acb69fe63468ff04c3134598c7ee46f1a
|
||||
uncrypto: ^0.1.3
|
||||
checksum: 0fa678543c0430812eff8587c3247efd13338885cd2506e86471b7f82e1f7c5d0367348879c86272b9521967e17d9f13fdf843191cfffa9aa8fd0920f32fb1f1
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
@@ -5324,7 +5324,7 @@ __metadata:
|
||||
eslint-plugin-prettier: ^4.2.1
|
||||
eslint-plugin-vitest: ^0.2.6
|
||||
get-port-please: ^3.0.1
|
||||
h3: ^1.6.6
|
||||
h3: ^1.7.0
|
||||
js-yaml: ^4.1.0
|
||||
listhen: ^1.0.4
|
||||
msw: ^1.2.2
|
||||
@@ -5792,10 +5792,10 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"uncrypto@npm:^0.1.2":
|
||||
version: 0.1.2
|
||||
resolution: "uncrypto@npm:0.1.2"
|
||||
checksum: a3095725a0f7ffbfada5a7df40716913aa2aba8c9924feab64ee66b45696bdaa2df4718451577bc243bef65fa9fe7a8744dec3a02c5598795a0f261f8c46adc8
|
||||
"uncrypto@npm:^0.1.3":
|
||||
version: 0.1.3
|
||||
resolution: "uncrypto@npm:0.1.3"
|
||||
checksum: 07160e08806dd6cea16bb96c3fd54cd70fc801e02fc3c6f86980144d15c9ebbd1c55587f7280a207b3af6cd34901c0d0b77ada5a02c2f7081a033a05acf409e2
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
|
||||
Reference in New Issue
Block a user