hono 4.7.7 → 4.7.9
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/dist/cjs/helper/cookie/index.js +1 -1
- package/dist/cjs/helper/ssg/ssg.js +3 -1
- package/dist/cjs/helper/websocket/index.js +21 -9
- package/dist/cjs/hono-base.js +5 -1
- package/dist/helper/cookie/index.js +1 -1
- package/dist/helper/ssg/ssg.js +3 -1
- package/dist/helper/websocket/index.js +21 -9
- package/dist/hono-base.js +5 -1
- package/dist/types/helper/adapter/index.d.ts +1 -1
- package/dist/types/helper/cookie/index.d.ts +3 -3
- package/dist/types/helper/websocket/index.d.ts +8 -4
- package/dist/types/hono-base.d.ts +1 -1
- package/package.json +2 -2
|
@@ -105,7 +105,7 @@ const setSignedCookie = async (c, name, value, secret, opt) => {
|
|
|
105
105
|
c.header("set-cookie", cookie, { append: true });
|
|
106
106
|
};
|
|
107
107
|
const deleteCookie = (c, name, opt) => {
|
|
108
|
-
const deletedCookie = getCookie(c, name);
|
|
108
|
+
const deletedCookie = getCookie(c, name, opt?.prefix);
|
|
109
109
|
setCookie(c, name, "", { ...opt, maxAge: 0 });
|
|
110
110
|
return deletedCookie;
|
|
111
111
|
};
|
|
@@ -240,7 +240,9 @@ const toSSG = async (app, fs, options) => {
|
|
|
240
240
|
return;
|
|
241
241
|
}
|
|
242
242
|
for (const content of getContentGen) {
|
|
243
|
-
savePromises.push(
|
|
243
|
+
savePromises.push(
|
|
244
|
+
saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e)
|
|
245
|
+
);
|
|
244
246
|
}
|
|
245
247
|
})
|
|
246
248
|
);
|
|
@@ -51,15 +51,27 @@ const createWSMessageEvent = (source) => {
|
|
|
51
51
|
});
|
|
52
52
|
};
|
|
53
53
|
const defineWebSocketHelper = (handler) => {
|
|
54
|
-
return (
|
|
55
|
-
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
54
|
+
return (...args) => {
|
|
55
|
+
if (typeof args[0] === "function") {
|
|
56
|
+
const [createEvents, options] = args;
|
|
57
|
+
return async function upgradeWebSocket(c, next) {
|
|
58
|
+
const events = await createEvents(c);
|
|
59
|
+
const result = await handler(c, events, options);
|
|
60
|
+
if (result) {
|
|
61
|
+
return result;
|
|
62
|
+
}
|
|
63
|
+
await next();
|
|
64
|
+
};
|
|
65
|
+
} else {
|
|
66
|
+
const [c, events, options] = args;
|
|
67
|
+
return (async () => {
|
|
68
|
+
const upgraded = await handler(c, events, options);
|
|
69
|
+
if (!upgraded) {
|
|
70
|
+
throw new Error("Failed to upgrade WebSocket");
|
|
71
|
+
}
|
|
72
|
+
return upgraded;
|
|
73
|
+
})();
|
|
74
|
+
}
|
|
63
75
|
};
|
|
64
76
|
};
|
|
65
77
|
// Annotate the CommonJS export names for ESM import in node:
|
package/dist/cjs/hono-base.js
CHANGED
|
@@ -138,7 +138,11 @@ class Hono {
|
|
|
138
138
|
optionHandler = options;
|
|
139
139
|
} else {
|
|
140
140
|
optionHandler = options.optionHandler;
|
|
141
|
-
|
|
141
|
+
if (options.replaceRequest === false) {
|
|
142
|
+
replaceRequest = (request) => request;
|
|
143
|
+
} else {
|
|
144
|
+
replaceRequest = options.replaceRequest;
|
|
145
|
+
}
|
|
142
146
|
}
|
|
143
147
|
}
|
|
144
148
|
const getOptions = optionHandler ? (c) => {
|
|
@@ -79,7 +79,7 @@ var setSignedCookie = async (c, name, value, secret, opt) => {
|
|
|
79
79
|
c.header("set-cookie", cookie, { append: true });
|
|
80
80
|
};
|
|
81
81
|
var deleteCookie = (c, name, opt) => {
|
|
82
|
-
const deletedCookie = getCookie(c, name);
|
|
82
|
+
const deletedCookie = getCookie(c, name, opt?.prefix);
|
|
83
83
|
setCookie(c, name, "", { ...opt, maxAge: 0 });
|
|
84
84
|
return deletedCookie;
|
|
85
85
|
};
|
package/dist/helper/ssg/ssg.js
CHANGED
|
@@ -212,7 +212,9 @@ var toSSG = async (app, fs, options) => {
|
|
|
212
212
|
return;
|
|
213
213
|
}
|
|
214
214
|
for (const content of getContentGen) {
|
|
215
|
-
savePromises.push(
|
|
215
|
+
savePromises.push(
|
|
216
|
+
saveContentToFile(content, fs, outputDir, options?.extensionMap).catch((e) => e)
|
|
217
|
+
);
|
|
216
218
|
}
|
|
217
219
|
})
|
|
218
220
|
);
|
|
@@ -27,15 +27,27 @@ var createWSMessageEvent = (source) => {
|
|
|
27
27
|
});
|
|
28
28
|
};
|
|
29
29
|
var defineWebSocketHelper = (handler) => {
|
|
30
|
-
return (
|
|
31
|
-
|
|
32
|
-
const
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
30
|
+
return (...args) => {
|
|
31
|
+
if (typeof args[0] === "function") {
|
|
32
|
+
const [createEvents, options] = args;
|
|
33
|
+
return async function upgradeWebSocket(c, next) {
|
|
34
|
+
const events = await createEvents(c);
|
|
35
|
+
const result = await handler(c, events, options);
|
|
36
|
+
if (result) {
|
|
37
|
+
return result;
|
|
38
|
+
}
|
|
39
|
+
await next();
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
const [c, events, options] = args;
|
|
43
|
+
return (async () => {
|
|
44
|
+
const upgraded = await handler(c, events, options);
|
|
45
|
+
if (!upgraded) {
|
|
46
|
+
throw new Error("Failed to upgrade WebSocket");
|
|
47
|
+
}
|
|
48
|
+
return upgraded;
|
|
49
|
+
})();
|
|
50
|
+
}
|
|
39
51
|
};
|
|
40
52
|
};
|
|
41
53
|
export {
|
package/dist/hono-base.js
CHANGED
|
@@ -116,7 +116,11 @@ var Hono = class {
|
|
|
116
116
|
optionHandler = options;
|
|
117
117
|
} else {
|
|
118
118
|
optionHandler = options.optionHandler;
|
|
119
|
-
|
|
119
|
+
if (options.replaceRequest === false) {
|
|
120
|
+
replaceRequest = (request) => request;
|
|
121
|
+
} else {
|
|
122
|
+
replaceRequest = options.replaceRequest;
|
|
123
|
+
}
|
|
120
124
|
}
|
|
121
125
|
}
|
|
122
126
|
const getOptions = optionHandler ? (c) => {
|
|
@@ -6,7 +6,7 @@ import type { Context } from '../../context';
|
|
|
6
6
|
export type Runtime = "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "other";
|
|
7
7
|
export declare const env: <T extends Record<string, unknown>, C extends Context = Context<{
|
|
8
8
|
Bindings: T;
|
|
9
|
-
}
|
|
9
|
+
}>>(c: T extends Record<string, unknown> ? Context : C, runtime?: Runtime) => T & C["env"];
|
|
10
10
|
export declare const knownUserAgents: Partial<Record<Runtime, string>>;
|
|
11
11
|
export declare const getRuntimeKey: () => Runtime;
|
|
12
12
|
export declare const checkUserAgentEquals: (platform: string) => boolean;
|
|
@@ -7,12 +7,12 @@ import type { Cookie, CookieOptions, CookiePrefixOptions, SignedCookie } from '.
|
|
|
7
7
|
interface GetCookie {
|
|
8
8
|
(c: Context, key: string): string | undefined;
|
|
9
9
|
(c: Context): Cookie;
|
|
10
|
-
(c: Context, key: string, prefixOptions
|
|
10
|
+
(c: Context, key: string, prefixOptions?: CookiePrefixOptions): string | undefined;
|
|
11
11
|
}
|
|
12
12
|
interface GetSignedCookie {
|
|
13
13
|
(c: Context, secret: string | BufferSource, key: string): Promise<string | undefined | false>;
|
|
14
|
-
(c: Context, secret: string): Promise<SignedCookie>;
|
|
15
|
-
(c: Context, secret: string | BufferSource, key: string, prefixOptions
|
|
14
|
+
(c: Context, secret: string | BufferSource): Promise<SignedCookie>;
|
|
15
|
+
(c: Context, secret: string | BufferSource, key: string, prefixOptions?: CookiePrefixOptions): Promise<string | undefined | false>;
|
|
16
16
|
}
|
|
17
17
|
export declare const getCookie: GetCookie;
|
|
18
18
|
export declare const getSignedCookie: GetSignedCookie;
|
|
@@ -3,7 +3,8 @@
|
|
|
3
3
|
* WebSocket Helper for Hono.
|
|
4
4
|
*/
|
|
5
5
|
import type { Context } from '../../context';
|
|
6
|
-
import type { MiddlewareHandler } from '../../types';
|
|
6
|
+
import type { MiddlewareHandler, TypedResponse } from '../../types';
|
|
7
|
+
import type { StatusCode } from '../../utils/http-status';
|
|
7
8
|
/**
|
|
8
9
|
* WebSocket Event Listeners type
|
|
9
10
|
*/
|
|
@@ -16,9 +17,12 @@ export interface WSEvents<T = unknown> {
|
|
|
16
17
|
/**
|
|
17
18
|
* Upgrade WebSocket Type
|
|
18
19
|
*/
|
|
19
|
-
export
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
export interface UpgradeWebSocket<T = unknown, U = any, _WSEvents = WSEvents<T>> {
|
|
21
|
+
(createEvents: (c: Context) => _WSEvents | Promise<_WSEvents>, options?: U): MiddlewareHandler<any, string, {
|
|
22
|
+
outputFormat: "ws";
|
|
23
|
+
}>;
|
|
24
|
+
(c: Context, events: _WSEvents, options?: U): Promise<Response & TypedResponse<{}, StatusCode, "ws">>;
|
|
25
|
+
}
|
|
22
26
|
/**
|
|
23
27
|
* ReadyState for WebSocket
|
|
24
28
|
*/
|
|
@@ -58,7 +58,7 @@ type MountOptionHandler = (c: Context) => unknown;
|
|
|
58
58
|
type MountReplaceRequest = (originalRequest: Request) => Request;
|
|
59
59
|
type MountOptions = MountOptionHandler | {
|
|
60
60
|
optionHandler?: MountOptionHandler;
|
|
61
|
-
replaceRequest?: MountReplaceRequest;
|
|
61
|
+
replaceRequest?: MountReplaceRequest | false;
|
|
62
62
|
};
|
|
63
63
|
declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends string = "/"> {
|
|
64
64
|
get: HandlerInterface<E, "get", S, BasePath>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "4.7.
|
|
3
|
+
"version": "4.7.9",
|
|
4
4
|
"description": "Web framework built on Web Standards",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -668,7 +668,7 @@
|
|
|
668
668
|
"typescript": "^5.3.3",
|
|
669
669
|
"vite-plugin-fastly-js-compute": "^0.4.2",
|
|
670
670
|
"vitest": "^3.0.5",
|
|
671
|
-
"wrangler": "
|
|
671
|
+
"wrangler": "4.12.0",
|
|
672
672
|
"ws": "^8.18.0",
|
|
673
673
|
"zod": "^3.23.8"
|
|
674
674
|
},
|