@zuplo/cli 6.74.10 → 6.74.12
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/node_modules/@hono/node-server/README.md +47 -1
- package/node_modules/@hono/node-server/dist/early-hints.cjs +35 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.cts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.d.mts +16 -0
- package/node_modules/@hono/node-server/dist/early-hints.mjs +33 -0
- package/node_modules/@hono/node-server/dist/index.cjs +4 -1
- package/node_modules/@hono/node-server/dist/index.mjs +4 -1
- package/node_modules/@hono/node-server/package.json +14 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/out/esm/index.js +12 -12
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +2 -2
- package/node_modules/@zuplo/otel/out/esm/{chunk-TXIQ6WNA.js → chunk-AHNBOCFU.js} +1 -1
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-AVDTZRWM.js +26 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-AVDTZRWM.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/{chunk-2EFTGELI.js → chunk-VVVYHDCV.js} +94 -92
- package/node_modules/@zuplo/runtime/out/esm/chunk-VVVYHDCV.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js.map +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +177 -0
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/hono/dist/cjs/context.js +28 -13
- package/node_modules/hono/dist/cjs/hono-base.js +3 -2
- package/node_modules/hono/dist/cjs/jsx/base.js +26 -14
- package/node_modules/hono/dist/cjs/jsx/hooks/index.js +2 -2
- package/node_modules/hono/dist/cjs/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/cjs/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/cjs/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/cjs/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/cjs/middleware/method-not-allowed/index.js +90 -0
- package/node_modules/hono/dist/cjs/request.js +6 -8
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/cjs/router.js +1 -1
- package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
- package/node_modules/hono/dist/cjs/utils/url.js +7 -7
- package/node_modules/hono/dist/context.js +28 -13
- package/node_modules/hono/dist/hono-base.js +3 -2
- package/node_modules/hono/dist/jsx/base.js +26 -14
- package/node_modules/hono/dist/jsx/hooks/index.js +2 -2
- package/node_modules/hono/dist/middleware/cache/index.js +103 -8
- package/node_modules/hono/dist/middleware/compress/index.js +5 -0
- package/node_modules/hono/dist/middleware/cors/index.js +1 -1
- package/node_modules/hono/dist/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/middleware/jwk/jwk.js +9 -4
- package/node_modules/hono/dist/middleware/jwt/jwt.js +9 -4
- package/node_modules/hono/dist/middleware/method-not-allowed/index.js +68 -0
- package/node_modules/hono/dist/request.js +7 -9
- package/node_modules/hono/dist/router/reg-exp-router/node.js +55 -56
- package/node_modules/hono/dist/router/reg-exp-router/router.js +64 -85
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +13 -5
- package/node_modules/hono/dist/router.js +1 -1
- package/node_modules/hono/dist/types/client/types.d.ts +1 -1
- package/node_modules/hono/dist/types/hono-base.d.ts +4 -3
- package/node_modules/hono/dist/types/jsx/base.d.ts +4 -2
- package/node_modules/hono/dist/types/jsx/dom/index.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/dom/intrinsic-element/components.d.ts +2 -2
- package/node_modules/hono/dist/types/jsx/dom/server.d.ts +5 -5
- package/node_modules/hono/dist/types/jsx/hooks/index.d.ts +8 -6
- package/node_modules/hono/dist/types/jsx/index.d.ts +5 -5
- package/node_modules/hono/dist/types/middleware/cache/index.d.ts +6 -4
- package/node_modules/hono/dist/types/middleware/cors/index.d.ts +1 -1
- package/node_modules/hono/dist/types/middleware/jsx-renderer/index.d.ts +2 -2
- package/node_modules/hono/dist/types/middleware/jwk/jwk.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/jwt/jwt.d.ts +2 -0
- package/node_modules/hono/dist/types/middleware/method-not-allowed/index.d.ts +49 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +1 -1
- package/node_modules/hono/dist/types/router/reg-exp-router/trie.d.ts +2 -1
- package/node_modules/hono/dist/types/router.d.ts +1 -1
- package/node_modules/hono/dist/types/utils/headers.d.ts +2 -2
- package/node_modules/hono/dist/types/utils/url.d.ts +1 -0
- package/node_modules/hono/dist/utils/cookie.js +2 -2
- package/node_modules/hono/dist/utils/url.js +5 -6
- package/node_modules/hono/package.json +9 -1
- package/package.json +6 -6
- package/node_modules/@zuplo/runtime/out/esm/chunk-2EFTGELI.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZB7PAWBM.js +0 -26
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZB7PAWBM.js.map +0 -1
- /package/node_modules/@zuplo/otel/out/esm/{chunk-TXIQ6WNA.js.map → chunk-AHNBOCFU.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-2EFTGELI.js.LEGAL.txt → chunk-VVVYHDCV.js.LEGAL.txt} +0 -0
|
@@ -86,7 +86,7 @@ app.get(
|
|
|
86
86
|
}))
|
|
87
87
|
)
|
|
88
88
|
|
|
89
|
-
const wss = new WebSocketServer({ noServer: true })
|
|
89
|
+
const wss = new WebSocketServer({ noServer: true })
|
|
90
90
|
serve({
|
|
91
91
|
fetch: app.fetch,
|
|
92
92
|
websocket: { server: wss },
|
|
@@ -332,6 +332,52 @@ type Http2Bindings = {
|
|
|
332
332
|
}
|
|
333
333
|
```
|
|
334
334
|
|
|
335
|
+
## Early Hints Middleware
|
|
336
|
+
|
|
337
|
+
You can send HTTP 103 Early Hints to instruct browsers to preload or preconnect resources before the final response is prepared. The middleware is supported under Node.js bindings (HTTP/1.1 and HTTP/2).
|
|
338
|
+
|
|
339
|
+
### Usage
|
|
340
|
+
|
|
341
|
+
Import `earlyHints` from `@hono/node-server/early-hints`:
|
|
342
|
+
|
|
343
|
+
#### Static links
|
|
344
|
+
|
|
345
|
+
```ts
|
|
346
|
+
import { serve } from '@hono/node-server'
|
|
347
|
+
import { earlyHints } from '@hono/node-server/early-hints'
|
|
348
|
+
import { Hono } from 'hono'
|
|
349
|
+
|
|
350
|
+
const app = new Hono()
|
|
351
|
+
|
|
352
|
+
app.use(
|
|
353
|
+
earlyHints({
|
|
354
|
+
link: '</styles.css>; rel=preload; as=style',
|
|
355
|
+
})
|
|
356
|
+
)
|
|
357
|
+
|
|
358
|
+
app.get('/', (c) => {
|
|
359
|
+
return c.html('<!DOCTYPE html><html><body><h1>Hello Hono!</h1></body></html>')
|
|
360
|
+
})
|
|
361
|
+
|
|
362
|
+
serve(app)
|
|
363
|
+
```
|
|
364
|
+
|
|
365
|
+
#### Dynamic links
|
|
366
|
+
|
|
367
|
+
```ts
|
|
368
|
+
app.use(
|
|
369
|
+
earlyHints({
|
|
370
|
+
link: (c) =>
|
|
371
|
+
c.req.query('theme') === 'dark'
|
|
372
|
+
? '</dark.css>; rel=preload; as=style'
|
|
373
|
+
: '</light.css>; rel=preload; as=style',
|
|
374
|
+
})
|
|
375
|
+
)
|
|
376
|
+
```
|
|
377
|
+
|
|
378
|
+
> [!NOTE]
|
|
379
|
+
> Early Hints are sent only for requests that look like document navigations. If `Sec-Fetch-Mode` or `Sec-Fetch-Dest` is present with a value other than `navigate` or `document`, for example a `fetch()` or XHR call from a browser, a subresource request, or an iframe navigation, the middleware skips the hints and continues to the handler. Requests without these headers, such as `curl` or `fetch()` from a JavaScript runtime, are treated as navigations and do receive Early Hints.
|
|
380
|
+
|
|
335
381
|
## Direct response from Node.js API
|
|
336
382
|
|
|
337
383
|
You can directly respond to the client from the Node.js API.
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
|
+
|
|
3
|
+
//#region src/early-hints.ts
|
|
4
|
+
/**
|
|
5
|
+
* Early Hints middleware for Node.js
|
|
6
|
+
* Automatically sends a 103 Early Hints informational response with the specified Link header(s).
|
|
7
|
+
*
|
|
8
|
+
* @param options EarlyHintsOptions
|
|
9
|
+
* @returns MiddlewareHandler
|
|
10
|
+
*/
|
|
11
|
+
const earlyHints = (options) => {
|
|
12
|
+
let warned = false;
|
|
13
|
+
return async (c, next) => {
|
|
14
|
+
const mode = c.req.header("Sec-Fetch-Mode");
|
|
15
|
+
const dest = c.req.header("Sec-Fetch-Dest");
|
|
16
|
+
if (mode && mode !== "navigate" || dest && dest !== "document") return next();
|
|
17
|
+
const env = c.env || {};
|
|
18
|
+
const outgoing = (env.server ? env.server : env)?.outgoing;
|
|
19
|
+
if (typeof outgoing?.writeEarlyHints !== "function") {
|
|
20
|
+
if (!warned) {
|
|
21
|
+
console.warn("Early Hints Middleware is not supported because writeEarlyHints is not defined.");
|
|
22
|
+
warned = true;
|
|
23
|
+
}
|
|
24
|
+
return await next();
|
|
25
|
+
}
|
|
26
|
+
if (!outgoing.headersSent) {
|
|
27
|
+
const link = typeof options.link === "function" ? options.link(c) : options.link;
|
|
28
|
+
if (link !== void 0 && (Array.isArray(link) ? link.length > 0 : Boolean(link))) outgoing.writeEarlyHints({ link });
|
|
29
|
+
}
|
|
30
|
+
await next();
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
//#endregion
|
|
35
|
+
exports.earlyHints = earlyHints;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Env, MiddlewareHandler } from "hono";
|
|
2
|
+
|
|
3
|
+
//#region src/early-hints.d.ts
|
|
4
|
+
type EarlyHintsOptions<E extends Env = Env> = {
|
|
5
|
+
link: string | string[] | ((c: Context<E>) => string | string[] | undefined);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Early Hints middleware for Node.js
|
|
9
|
+
* Automatically sends a 103 Early Hints informational response with the specified Link header(s).
|
|
10
|
+
*
|
|
11
|
+
* @param options EarlyHintsOptions
|
|
12
|
+
* @returns MiddlewareHandler
|
|
13
|
+
*/
|
|
14
|
+
declare const earlyHints: <E extends Env = any>(options: EarlyHintsOptions<E>) => MiddlewareHandler<E>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { EarlyHintsOptions, earlyHints };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Context, Env, MiddlewareHandler } from "hono";
|
|
2
|
+
|
|
3
|
+
//#region src/early-hints.d.ts
|
|
4
|
+
type EarlyHintsOptions<E extends Env = Env> = {
|
|
5
|
+
link: string | string[] | ((c: Context<E>) => string | string[] | undefined);
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* Early Hints middleware for Node.js
|
|
9
|
+
* Automatically sends a 103 Early Hints informational response with the specified Link header(s).
|
|
10
|
+
*
|
|
11
|
+
* @param options EarlyHintsOptions
|
|
12
|
+
* @returns MiddlewareHandler
|
|
13
|
+
*/
|
|
14
|
+
declare const earlyHints: <E extends Env = any>(options: EarlyHintsOptions<E>) => MiddlewareHandler<E>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { EarlyHintsOptions, earlyHints };
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
//#region src/early-hints.ts
|
|
2
|
+
/**
|
|
3
|
+
* Early Hints middleware for Node.js
|
|
4
|
+
* Automatically sends a 103 Early Hints informational response with the specified Link header(s).
|
|
5
|
+
*
|
|
6
|
+
* @param options EarlyHintsOptions
|
|
7
|
+
* @returns MiddlewareHandler
|
|
8
|
+
*/
|
|
9
|
+
const earlyHints = (options) => {
|
|
10
|
+
let warned = false;
|
|
11
|
+
return async (c, next) => {
|
|
12
|
+
const mode = c.req.header("Sec-Fetch-Mode");
|
|
13
|
+
const dest = c.req.header("Sec-Fetch-Dest");
|
|
14
|
+
if (mode && mode !== "navigate" || dest && dest !== "document") return next();
|
|
15
|
+
const env = c.env || {};
|
|
16
|
+
const outgoing = (env.server ? env.server : env)?.outgoing;
|
|
17
|
+
if (typeof outgoing?.writeEarlyHints !== "function") {
|
|
18
|
+
if (!warned) {
|
|
19
|
+
console.warn("Early Hints Middleware is not supported because writeEarlyHints is not defined.");
|
|
20
|
+
warned = true;
|
|
21
|
+
}
|
|
22
|
+
return await next();
|
|
23
|
+
}
|
|
24
|
+
if (!outgoing.headersSent) {
|
|
25
|
+
const link = typeof options.link === "function" ? options.link(c) : options.link;
|
|
26
|
+
if (link !== void 0 && (Array.isArray(link) ? link.length > 0 : Boolean(link))) outgoing.writeEarlyHints({ link });
|
|
27
|
+
}
|
|
28
|
+
await next();
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { earlyHints };
|
|
@@ -684,7 +684,10 @@ const drainIncoming = (incoming) => {
|
|
|
684
684
|
const forceClose = () => {
|
|
685
685
|
cleanup();
|
|
686
686
|
const socket = incoming.socket;
|
|
687
|
-
if (socket && !socket.destroyed)
|
|
687
|
+
if (socket && !socket.destroyed) {
|
|
688
|
+
if (typeof socket.destroySoon === "function") socket.destroySoon();
|
|
689
|
+
else if (typeof socket.destroy === "function") socket.destroy();
|
|
690
|
+
}
|
|
688
691
|
};
|
|
689
692
|
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
690
693
|
timer.unref?.();
|
|
@@ -683,7 +683,10 @@ const drainIncoming = (incoming) => {
|
|
|
683
683
|
const forceClose = () => {
|
|
684
684
|
cleanup();
|
|
685
685
|
const socket = incoming.socket;
|
|
686
|
-
if (socket && !socket.destroyed)
|
|
686
|
+
if (socket && !socket.destroyed) {
|
|
687
|
+
if (typeof socket.destroySoon === "function") socket.destroySoon();
|
|
688
|
+
else if (typeof socket.destroy === "function") socket.destroy();
|
|
689
|
+
}
|
|
687
690
|
};
|
|
688
691
|
const timer = setTimeout(forceClose, DRAIN_TIMEOUT_MS);
|
|
689
692
|
timer.unref?.();
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hono/node-server",
|
|
3
|
-
"version": "2.0
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"description": "Node.js Adapter for Hono",
|
|
5
5
|
"main": "dist/index.mjs",
|
|
6
6
|
"type": "module",
|
|
@@ -48,6 +48,16 @@
|
|
|
48
48
|
"types": "./dist/conninfo.d.cts",
|
|
49
49
|
"default": "./dist/conninfo.cjs"
|
|
50
50
|
}
|
|
51
|
+
},
|
|
52
|
+
"./early-hints": {
|
|
53
|
+
"import": {
|
|
54
|
+
"types": "./dist/early-hints.d.mts",
|
|
55
|
+
"default": "./dist/early-hints.mjs"
|
|
56
|
+
},
|
|
57
|
+
"require": {
|
|
58
|
+
"types": "./dist/early-hints.d.cts",
|
|
59
|
+
"default": "./dist/early-hints.cjs"
|
|
60
|
+
}
|
|
51
61
|
}
|
|
52
62
|
},
|
|
53
63
|
"typesVersions": {
|
|
@@ -63,6 +73,9 @@
|
|
|
63
73
|
],
|
|
64
74
|
"conninfo": [
|
|
65
75
|
"./dist/conninfo.d.mts"
|
|
76
|
+
],
|
|
77
|
+
"early-hints": [
|
|
78
|
+
"./dist/early-hints.d.mts"
|
|
66
79
|
]
|
|
67
80
|
}
|
|
68
81
|
},
|