hono 3.12.7 → 3.12.8

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.
@@ -253,11 +253,9 @@ const _Hono = class extends defineDynamicClass() {
253
253
  } catch (err) {
254
254
  return this.handleError(err, c);
255
255
  }
256
- if (res instanceof Response)
257
- return res;
258
- return res.then(
256
+ return res instanceof Promise ? res.then(
259
257
  (resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c))
260
- ).catch((err) => this.handleError(err, c));
258
+ ).catch((err) => this.handleError(err, c)) : res;
261
259
  }
262
260
  const composed = (0, import_compose.compose)(matchResult[0], this.errorHandler, this.notFoundHandler);
263
261
  return (async () => {
@@ -67,21 +67,26 @@ class HonoRequest {
67
67
  __privateSet(this, _validatedData, {});
68
68
  }
69
69
  param(key) {
70
- if (key) {
71
- const param = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
72
- return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0;
73
- } else {
74
- const decoded = {};
75
- const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
76
- for (let i = 0, len = keys.length; i < len; i++) {
77
- const key2 = keys[i];
78
- const value = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key2]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key2];
79
- if (value && typeof value === "string") {
80
- decoded[key2] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value;
81
- }
70
+ return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
71
+ }
72
+ getDecodedParam(key) {
73
+ const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
74
+ const param = this.getParamValue(paramKey);
75
+ return param ? /\%/.test(param) ? (0, import_url.decodeURIComponent_)(param) : param : void 0;
76
+ }
77
+ getAllDecodedParams() {
78
+ const decoded = {};
79
+ const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
80
+ for (const key of keys) {
81
+ const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
82
+ if (value && typeof value === "string") {
83
+ decoded[key] = /\%/.test(value) ? (0, import_url.decodeURIComponent_)(value) : value;
82
84
  }
83
- return decoded;
84
85
  }
86
+ return decoded;
87
+ }
88
+ getParamValue(paramKey) {
89
+ return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey;
85
90
  }
86
91
  query(key) {
87
92
  return (0, import_url.getQueryParam)(this.url, key);
package/dist/hono-base.js CHANGED
@@ -231,11 +231,9 @@ var _Hono = class extends defineDynamicClass() {
231
231
  } catch (err) {
232
232
  return this.handleError(err, c);
233
233
  }
234
- if (res instanceof Response)
235
- return res;
236
- return res.then(
234
+ return res instanceof Promise ? res.then(
237
235
  (resolved) => resolved || (c.finalized ? c.res : this.notFoundHandler(c))
238
- ).catch((err) => this.handleError(err, c));
236
+ ).catch((err) => this.handleError(err, c)) : res;
239
237
  }
240
238
  const composed = compose(matchResult[0], this.errorHandler, this.notFoundHandler);
241
239
  return (async () => {
package/dist/request.js CHANGED
@@ -46,21 +46,26 @@ var HonoRequest = class {
46
46
  __privateSet(this, _validatedData, {});
47
47
  }
48
48
  param(key) {
49
- if (key) {
50
- const param = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
51
- return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
52
- } else {
53
- const decoded = {};
54
- const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
55
- for (let i = 0, len = keys.length; i < len; i++) {
56
- const key2 = keys[i];
57
- const value = __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][__privateGet(this, _matchResult)[0][this.routeIndex][1][key2]] : __privateGet(this, _matchResult)[0][this.routeIndex][1][key2];
58
- if (value && typeof value === "string") {
59
- decoded[key2] = /\%/.test(value) ? decodeURIComponent_(value) : value;
60
- }
49
+ return key ? this.getDecodedParam(key) : this.getAllDecodedParams();
50
+ }
51
+ getDecodedParam(key) {
52
+ const paramKey = __privateGet(this, _matchResult)[0][this.routeIndex][1][key];
53
+ const param = this.getParamValue(paramKey);
54
+ return param ? /\%/.test(param) ? decodeURIComponent_(param) : param : void 0;
55
+ }
56
+ getAllDecodedParams() {
57
+ const decoded = {};
58
+ const keys = Object.keys(__privateGet(this, _matchResult)[0][this.routeIndex][1]);
59
+ for (const key of keys) {
60
+ const value = this.getParamValue(__privateGet(this, _matchResult)[0][this.routeIndex][1][key]);
61
+ if (value && typeof value === "string") {
62
+ decoded[key] = /\%/.test(value) ? decodeURIComponent_(value) : value;
61
63
  }
62
- return decoded;
63
64
  }
65
+ return decoded;
66
+ }
67
+ getParamValue(paramKey) {
68
+ return __privateGet(this, _matchResult)[1] ? __privateGet(this, _matchResult)[1][paramKey] : paramKey;
64
69
  }
65
70
  query(key) {
66
71
  return getQueryParam(this.url, key);
@@ -111,4 +111,4 @@ export declare class Factory<E extends Env = any, P extends string = any> {
111
111
  * The API might be changed.
112
112
  */
113
113
  export declare const createFactory: <E extends Env = any, P extends string = any>() => Factory<E, P>;
114
- export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler) => MiddlewareHandler<E, P, I>;
114
+ export declare const createMiddleware: <E extends Env = any, P extends string = any, I extends Input = {}>(middleware: MiddlewareHandler<E, P, I>) => MiddlewareHandler<E, P, I>;
@@ -22,6 +22,9 @@ export declare class HonoRequest<P extends string = '/', I extends Input['out']
22
22
  constructor(request: Request, path?: string, matchResult?: Result<[unknown, RouterRoute]>);
23
23
  param<P2 extends string = P>(key: RemoveQuestion<ParamKeys<P2>>): UndefinedIfHavingQuestion<ParamKeys<P2>>;
24
24
  param<P2 extends string = P>(): UnionToIntersection<ParamKeyToRecord<ParamKeys<P2>>>;
25
+ private getDecodedParam;
26
+ private getAllDecodedParams;
27
+ private getParamValue;
25
28
  query(key: string): string | undefined;
26
29
  query(): Record<string, string>;
27
30
  queries(key: string): string[] | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "3.12.7",
3
+ "version": "3.12.8",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",