hono 3.1.8 → 3.2.0-rc.2

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.
Files changed (74) hide show
  1. package/dist/adapter/aws-lambda/handler.js +48 -14
  2. package/dist/adapter/bun/serve-static.js +2 -1
  3. package/dist/adapter/cloudflare-workers/serve-static.js +2 -1
  4. package/dist/adapter/deno/serve-static.js +2 -1
  5. package/dist/adapter/vercel/handler.js +7 -0
  6. package/dist/adapter/vercel/index.js +5 -0
  7. package/dist/cjs/adapter/aws-lambda/handler.js +50 -15
  8. package/dist/cjs/adapter/bun/serve-static.js +2 -1
  9. package/dist/cjs/adapter/cloudflare-workers/serve-static.js +2 -1
  10. package/dist/cjs/adapter/deno/serve-static.js +2 -1
  11. package/dist/cjs/adapter/vercel/handler.js +30 -0
  12. package/dist/cjs/adapter/vercel/index.js +28 -0
  13. package/dist/cjs/client/utils.js +0 -2
  14. package/dist/cjs/context.js +60 -49
  15. package/dist/cjs/hono-base.js +239 -0
  16. package/dist/cjs/hono.js +4 -208
  17. package/dist/cjs/http-exception.js +2 -3
  18. package/dist/cjs/middleware/cookie/index.js +47 -0
  19. package/dist/cjs/middleware/jsx/jsx-dev-runtime.js +1 -1
  20. package/dist/cjs/middleware/logger/index.js +1 -1
  21. package/dist/cjs/preset/quick.js +35 -0
  22. package/dist/cjs/preset/tiny.js +35 -0
  23. package/dist/cjs/request.js +5 -5
  24. package/dist/cjs/router/linear-router/index.js +28 -0
  25. package/dist/cjs/router/linear-router/router.js +148 -0
  26. package/dist/cjs/router/pattern-router/index.js +28 -0
  27. package/dist/cjs/router/pattern-router/router.js +85 -0
  28. package/dist/cjs/router/trie-router/node.js +6 -6
  29. package/dist/cjs/utils/cookie.js +2 -1
  30. package/dist/cjs/utils/http-status.js +0 -57
  31. package/dist/cjs/utils/url.js +18 -12
  32. package/dist/client/utils.js +0 -2
  33. package/dist/context.js +60 -49
  34. package/dist/hono-base.js +216 -0
  35. package/dist/hono.js +4 -208
  36. package/dist/http-exception.js +2 -3
  37. package/dist/middleware/cookie/index.js +23 -0
  38. package/dist/middleware/jsx/jsx-dev-runtime.js +1 -1
  39. package/dist/middleware/logger/index.js +2 -2
  40. package/dist/preset/quick.js +12 -0
  41. package/dist/preset/tiny.js +12 -0
  42. package/dist/request.js +6 -6
  43. package/dist/router/linear-router/index.js +5 -0
  44. package/dist/router/linear-router/router.js +125 -0
  45. package/dist/router/pattern-router/index.js +5 -0
  46. package/dist/router/pattern-router/router.js +62 -0
  47. package/dist/router/trie-router/node.js +6 -6
  48. package/dist/types/adapter/aws-lambda/handler.d.ts +31 -2
  49. package/dist/types/adapter/bun/serve-static.d.ts +1 -0
  50. package/dist/types/adapter/cloudflare-pages/handler.d.ts +1 -1
  51. package/dist/types/adapter/cloudflare-workers/serve-static.d.ts +1 -0
  52. package/dist/types/adapter/deno/serve-static.d.ts +1 -0
  53. package/dist/types/adapter/nextjs/handler.d.ts +5 -1
  54. package/dist/types/adapter/vercel/handler.d.ts +2 -0
  55. package/dist/types/adapter/vercel/index.d.ts +1 -0
  56. package/dist/types/context.d.ts +29 -10
  57. package/dist/types/hono-base.d.ts +54 -0
  58. package/dist/types/hono.d.ts +6 -51
  59. package/dist/types/index.d.ts +2 -2
  60. package/dist/types/middleware/cookie/index.d.ts +9 -0
  61. package/dist/types/preset/quick.d.ts +5 -0
  62. package/dist/types/preset/tiny.d.ts +5 -0
  63. package/dist/types/request.d.ts +19 -1
  64. package/dist/types/router/linear-router/index.d.ts +1 -0
  65. package/dist/types/router/linear-router/router.d.ts +6 -0
  66. package/dist/types/router/pattern-router/index.d.ts +1 -0
  67. package/dist/types/router/pattern-router/router.d.ts +7 -0
  68. package/dist/types/router/trie-router/node.d.ts +1 -1
  69. package/dist/types/utils/http-status.d.ts +1 -2
  70. package/dist/types/utils/url.d.ts +3 -1
  71. package/dist/utils/cookie.js +2 -1
  72. package/dist/utils/http-status.js +0 -50
  73. package/dist/utils/url.js +15 -11
  74. package/package.json +48 -16
@@ -5,27 +5,34 @@ var handle = (app) => {
5
5
  return async (event) => {
6
6
  const req = createRequest(event);
7
7
  const res = await app.fetch(req);
8
- const arrayBuffer = await res.arrayBuffer();
9
- const result = {
10
- statusCode: res.status,
11
- body: String.fromCharCode(...new Uint8Array(arrayBuffer)),
12
- headers: {},
13
- isBase64Encoded: false
14
- };
15
- res.headers.forEach((value, key) => {
16
- result.headers[key] = value;
17
- });
18
- return result;
8
+ return createResult(res);
19
9
  };
20
10
  };
11
+ var createResult = async (res) => {
12
+ const contentType = res.headers.get("content-type");
13
+ const isBase64Encoded = contentType && isContentTypeBinary(contentType) ? true : false;
14
+ const body = isBase64Encoded ? await fromReadableToString(res) : await res.text();
15
+ const result = {
16
+ body,
17
+ headers: {},
18
+ statusCode: res.status,
19
+ isBase64Encoded
20
+ };
21
+ res.headers.forEach((value, key) => {
22
+ result.headers[key] = value;
23
+ });
24
+ return result;
25
+ };
21
26
  var createRequest = (event) => {
22
- const url = `https://${event.requestContext.domainName}${event.path}`;
27
+ const queryString = extractQueryString(event);
28
+ const urlPath = `https://${event.requestContext.domainName}${isProxyEvent(event) ? event.path : event.rawPath}`;
29
+ const url = queryString ? `${urlPath}?${queryString}` : urlPath;
23
30
  const headers = new Headers();
24
31
  for (const [k, v] of Object.entries(event.headers)) {
25
32
  if (v)
26
33
  headers.set(k, v);
27
34
  }
28
- const method = event.httpMethod;
35
+ const method = "httpMethod" in event ? event.httpMethod : event.requestContext.http.method;
29
36
  const requestInit = {
30
37
  headers,
31
38
  method
@@ -35,6 +42,33 @@ var createRequest = (event) => {
35
42
  }
36
43
  return new Request(url, requestInit);
37
44
  };
45
+ var extractQueryString = (event) => {
46
+ if (isProxyEvent(event)) {
47
+ return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value).map(([key, value]) => `${key}=${value}`).join("&");
48
+ }
49
+ return isProxyEventV2(event) ? event.rawQueryString : event.rawQueryString;
50
+ };
51
+ var isProxyEvent = (event) => {
52
+ return Object.prototype.hasOwnProperty.call(event, "path");
53
+ };
54
+ var isProxyEventV2 = (event) => {
55
+ return Object.prototype.hasOwnProperty.call(event, "rawPath");
56
+ };
57
+ var fromReadableToString = async (res) => {
58
+ const stream = res.body || new ReadableStream();
59
+ const decoder = new TextDecoder();
60
+ let string = "";
61
+ for await (const chunk of stream) {
62
+ string += decoder.decode(chunk);
63
+ }
64
+ return btoa(string);
65
+ };
66
+ var isContentTypeBinary = (contentType) => {
67
+ return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml)$/.test(
68
+ contentType
69
+ );
70
+ };
38
71
  export {
39
- handle
72
+ handle,
73
+ isContentTypeBinary
40
74
  };
@@ -11,8 +11,9 @@ var serveStatic = (options = { root: "" }) => {
11
11
  return;
12
12
  }
13
13
  const url = new URL(c.req.url);
14
+ const filename = options.path ?? decodeURI(url.pathname);
14
15
  let path = getFilePath({
15
- filename: options.path ?? decodeURI(url.pathname),
16
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
16
17
  root: options.root,
17
18
  defaultDocument: DEFAULT_DOCUMENT
18
19
  });
@@ -10,8 +10,9 @@ var serveStatic = (options = { root: "" }) => {
10
10
  return;
11
11
  }
12
12
  const url = new URL(c.req.url);
13
+ const filename = options.path ?? decodeURI(url.pathname);
13
14
  const path = getFilePath({
14
- filename: options.path ?? decodeURI(url.pathname),
15
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
15
16
  root: options.root,
16
17
  defaultDocument: DEFAULT_DOCUMENT
17
18
  });
@@ -9,8 +9,9 @@ var serveStatic = (options = { root: "" }) => {
9
9
  return;
10
10
  }
11
11
  const url = new URL(c.req.url);
12
+ const filename = options.path ?? decodeURI(url.pathname);
12
13
  let path = getFilePath({
13
- filename: options.path ?? decodeURI(url.pathname),
14
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
14
15
  root: options.root,
15
16
  defaultDocument: DEFAULT_DOCUMENT
16
17
  });
@@ -0,0 +1,7 @@
1
+ // src/adapter/vercel/handler.ts
2
+ var handle = (app) => (req) => {
3
+ return app.fetch(req);
4
+ };
5
+ export {
6
+ handle
7
+ };
@@ -0,0 +1,5 @@
1
+ // src/adapter/vercel/index.ts
2
+ import { handle } from "./handler.js";
3
+ export {
4
+ handle
5
+ };
@@ -24,7 +24,8 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
24
24
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
25
25
  var handler_exports = {};
26
26
  __export(handler_exports, {
27
- handle: () => handle
27
+ handle: () => handle,
28
+ isContentTypeBinary: () => isContentTypeBinary
28
29
  });
29
30
  module.exports = __toCommonJS(handler_exports);
30
31
  var import_crypto = __toESM(require("crypto"), 1);
@@ -33,27 +34,34 @@ const handle = (app) => {
33
34
  return async (event) => {
34
35
  const req = createRequest(event);
35
36
  const res = await app.fetch(req);
36
- const arrayBuffer = await res.arrayBuffer();
37
- const result = {
38
- statusCode: res.status,
39
- body: String.fromCharCode(...new Uint8Array(arrayBuffer)),
40
- headers: {},
41
- isBase64Encoded: false
42
- };
43
- res.headers.forEach((value, key) => {
44
- result.headers[key] = value;
45
- });
46
- return result;
37
+ return createResult(res);
47
38
  };
48
39
  };
40
+ const createResult = async (res) => {
41
+ const contentType = res.headers.get("content-type");
42
+ const isBase64Encoded = contentType && isContentTypeBinary(contentType) ? true : false;
43
+ const body = isBase64Encoded ? await fromReadableToString(res) : await res.text();
44
+ const result = {
45
+ body,
46
+ headers: {},
47
+ statusCode: res.status,
48
+ isBase64Encoded
49
+ };
50
+ res.headers.forEach((value, key) => {
51
+ result.headers[key] = value;
52
+ });
53
+ return result;
54
+ };
49
55
  const createRequest = (event) => {
50
- const url = `https://${event.requestContext.domainName}${event.path}`;
56
+ const queryString = extractQueryString(event);
57
+ const urlPath = `https://${event.requestContext.domainName}${isProxyEvent(event) ? event.path : event.rawPath}`;
58
+ const url = queryString ? `${urlPath}?${queryString}` : urlPath;
51
59
  const headers = new Headers();
52
60
  for (const [k, v] of Object.entries(event.headers)) {
53
61
  if (v)
54
62
  headers.set(k, v);
55
63
  }
56
- const method = event.httpMethod;
64
+ const method = "httpMethod" in event ? event.httpMethod : event.requestContext.http.method;
57
65
  const requestInit = {
58
66
  headers,
59
67
  method
@@ -63,7 +71,34 @@ const createRequest = (event) => {
63
71
  }
64
72
  return new Request(url, requestInit);
65
73
  };
74
+ const extractQueryString = (event) => {
75
+ if (isProxyEvent(event)) {
76
+ return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value).map(([key, value]) => `${key}=${value}`).join("&");
77
+ }
78
+ return isProxyEventV2(event) ? event.rawQueryString : event.rawQueryString;
79
+ };
80
+ const isProxyEvent = (event) => {
81
+ return Object.prototype.hasOwnProperty.call(event, "path");
82
+ };
83
+ const isProxyEventV2 = (event) => {
84
+ return Object.prototype.hasOwnProperty.call(event, "rawPath");
85
+ };
86
+ const fromReadableToString = async (res) => {
87
+ const stream = res.body || new ReadableStream();
88
+ const decoder = new TextDecoder();
89
+ let string = "";
90
+ for await (const chunk of stream) {
91
+ string += decoder.decode(chunk);
92
+ }
93
+ return btoa(string);
94
+ };
95
+ const isContentTypeBinary = (contentType) => {
96
+ return !/^(text\/(plain|html|css|javascript|csv).*|application\/(.*json|.*xml).*|image\/svg\+xml)$/.test(
97
+ contentType
98
+ );
99
+ };
66
100
  // Annotate the CommonJS export names for ESM import in node:
67
101
  0 && (module.exports = {
68
- handle
102
+ handle,
103
+ isContentTypeBinary
69
104
  });
@@ -33,8 +33,9 @@ const serveStatic = (options = { root: "" }) => {
33
33
  return;
34
34
  }
35
35
  const url = new URL(c.req.url);
36
+ const filename = options.path ?? decodeURI(url.pathname);
36
37
  let path = (0, import_filepath.getFilePath)({
37
- filename: options.path ?? decodeURI(url.pathname),
38
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
38
39
  root: options.root,
39
40
  defaultDocument: DEFAULT_DOCUMENT
40
41
  });
@@ -32,8 +32,9 @@ const serveStatic = (options = { root: "" }) => {
32
32
  return;
33
33
  }
34
34
  const url = new URL(c.req.url);
35
+ const filename = options.path ?? decodeURI(url.pathname);
35
36
  const path = (0, import_filepath.getFilePath)({
36
- filename: options.path ?? decodeURI(url.pathname),
37
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
37
38
  root: options.root,
38
39
  defaultDocument: DEFAULT_DOCUMENT
39
40
  });
@@ -31,8 +31,9 @@ const serveStatic = (options = { root: "" }) => {
31
31
  return;
32
32
  }
33
33
  const url = new URL(c.req.url);
34
+ const filename = options.path ?? decodeURI(url.pathname);
34
35
  let path = (0, import_filepath.getFilePath)({
35
- filename: options.path ?? decodeURI(url.pathname),
36
+ filename: options.rewriteRequestPath ? options.rewriteRequestPath(filename) : filename,
36
37
  root: options.root,
37
38
  defaultDocument: DEFAULT_DOCUMENT
38
39
  });
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var handler_exports = {};
20
+ __export(handler_exports, {
21
+ handle: () => handle
22
+ });
23
+ module.exports = __toCommonJS(handler_exports);
24
+ const handle = (app) => (req) => {
25
+ return app.fetch(req);
26
+ };
27
+ // Annotate the CommonJS export names for ESM import in node:
28
+ 0 && (module.exports = {
29
+ handle
30
+ });
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var vercel_exports = {};
20
+ __export(vercel_exports, {
21
+ handle: () => import_handler.handle
22
+ });
23
+ module.exports = __toCommonJS(vercel_exports);
24
+ var import_handler = require("./handler");
25
+ // Annotate the CommonJS export names for ESM import in node:
26
+ 0 && (module.exports = {
27
+ handle
28
+ });
@@ -24,7 +24,6 @@ __export(utils_exports, {
24
24
  replaceUrlParam: () => replaceUrlParam
25
25
  });
26
26
  module.exports = __toCommonJS(utils_exports);
27
- var import_url = require("../utils/url");
28
27
  const mergePath = (base, path) => {
29
28
  base = base.replace(/\/+$/, "");
30
29
  base = base + "/";
@@ -39,7 +38,6 @@ const replaceUrlParam = (urlString, params) => {
39
38
  return urlString;
40
39
  };
41
40
  const removeIndexString = (urlSting) => {
42
- const path = (0, import_url.getPathFromURL)(urlSting);
43
41
  return urlSting.replace(/\/index$/, "/");
44
42
  };
45
43
  function isObject(item) {
@@ -29,25 +29,36 @@ class Context {
29
29
  this.finalized = false;
30
30
  this.error = void 0;
31
31
  this._status = 200;
32
- this._pretty = false;
33
- this._prettySpace = 2;
34
- this._headers = void 0;
35
- this._preparedHeaders = void 0;
32
+ this._pre = false;
33
+ this._preS = 2;
34
+ this._h = void 0;
35
+ this._pH = void 0;
36
36
  this._path = "/";
37
37
  this.notFoundHandler = () => new Response();
38
38
  this.header = (name, value, options) => {
39
+ if (value === void 0) {
40
+ if (this._h) {
41
+ this._h.delete(name);
42
+ } else if (this._pH) {
43
+ delete this._pH[name.toLocaleLowerCase()];
44
+ }
45
+ if (this.finalized) {
46
+ this.res.headers.delete(name);
47
+ }
48
+ return;
49
+ }
39
50
  if (options?.append) {
40
- if (!this._headers) {
41
- this._headers = new Headers(this._preparedHeaders);
42
- this._preparedHeaders = {};
51
+ if (!this._h) {
52
+ this._h = new Headers(this._pH);
53
+ this._pH = {};
43
54
  }
44
- this._headers.append(name, value);
55
+ this._h.append(name, value);
45
56
  } else {
46
- if (this._headers) {
47
- this._headers.set(name, value);
57
+ if (this._h) {
58
+ this._h.set(name, value);
48
59
  } else {
49
- this._preparedHeaders ?? (this._preparedHeaders = {});
50
- this._preparedHeaders[name.toLowerCase()] = value;
60
+ this._pH ?? (this._pH = {});
61
+ this._pH[name.toLowerCase()] = value;
51
62
  }
52
63
  }
53
64
  if (this.finalized) {
@@ -66,75 +77,75 @@ class Context {
66
77
  this._map[key] = value;
67
78
  };
68
79
  this.get = (key) => {
69
- return this._map?.[key];
80
+ return this._map ? this._map[key] : void 0;
70
81
  };
71
82
  this.pretty = (prettyJSON, space = 2) => {
72
- this._pretty = prettyJSON;
73
- this._prettySpace = space;
83
+ this._pre = prettyJSON;
84
+ this._preS = space;
74
85
  };
75
86
  this.newResponse = (data, arg, headers) => {
76
- if (!headers && !this._headers && !this._res && !arg && this._status === 200) {
87
+ if (!headers && !this._h && !this._res && !arg && this._status === 200) {
77
88
  return new Response(data, {
78
- headers: this._preparedHeaders
89
+ headers: this._pH
79
90
  });
80
91
  }
81
92
  if (arg && typeof arg !== "number") {
82
93
  const res = new Response(data, arg);
83
- const contentType = this._preparedHeaders?.["content-type"];
94
+ const contentType = this._pH?.["content-type"];
84
95
  if (contentType) {
85
96
  res.headers.set("content-type", contentType);
86
97
  }
87
98
  return res;
88
99
  }
89
100
  const status = arg ?? this._status;
90
- this._preparedHeaders ?? (this._preparedHeaders = {});
91
- this._headers ?? (this._headers = new Headers());
92
- for (const [k, v] of Object.entries(this._preparedHeaders)) {
93
- this._headers.set(k, v);
101
+ this._pH ?? (this._pH = {});
102
+ this._h ?? (this._h = new Headers());
103
+ for (const [k, v] of Object.entries(this._pH)) {
104
+ this._h.set(k, v);
94
105
  }
95
106
  if (this._res) {
96
107
  this._res.headers.forEach((v, k) => {
97
- this._headers?.set(k, v);
108
+ this._h?.set(k, v);
98
109
  });
99
- for (const [k, v] of Object.entries(this._preparedHeaders)) {
100
- this._headers.set(k, v);
110
+ for (const [k, v] of Object.entries(this._pH)) {
111
+ this._h.set(k, v);
101
112
  }
102
113
  }
103
114
  headers ?? (headers = {});
104
115
  for (const [k, v] of Object.entries(headers)) {
105
116
  if (typeof v === "string") {
106
- this._headers.set(k, v);
117
+ this._h.set(k, v);
107
118
  } else {
108
- this._headers.delete(k);
119
+ this._h.delete(k);
109
120
  for (const v2 of v) {
110
- this._headers.append(k, v2);
121
+ this._h.append(k, v2);
111
122
  }
112
123
  }
113
124
  }
114
125
  return new Response(data, {
115
126
  status,
116
- headers: this._headers
127
+ headers: this._h
117
128
  });
118
129
  };
119
130
  this.body = (data, arg, headers) => {
120
131
  return typeof arg === "number" ? this.newResponse(data, arg, headers) : this.newResponse(data, arg);
121
132
  };
122
133
  this.text = (text, arg, headers) => {
123
- if (!this._preparedHeaders) {
124
- if (!headers && !this._res && !this._headers && !arg) {
134
+ if (!this._pH) {
135
+ if (!headers && !this._res && !this._h && !arg) {
125
136
  return new Response(text);
126
137
  }
127
- this._preparedHeaders = {};
138
+ this._pH = {};
128
139
  }
129
- if (this._preparedHeaders["content-type"]) {
130
- this._preparedHeaders["content-type"] = "text/plain; charset=UTF-8";
140
+ if (this._pH["content-type"]) {
141
+ this._pH["content-type"] = "text/plain; charset=UTF-8";
131
142
  }
132
143
  return typeof arg === "number" ? this.newResponse(text, arg, headers) : this.newResponse(text, arg);
133
144
  };
134
145
  this.json = (object, arg, headers) => {
135
- const body = this._pretty ? JSON.stringify(object, null, this._prettySpace) : JSON.stringify(object);
136
- this._preparedHeaders ?? (this._preparedHeaders = {});
137
- this._preparedHeaders["content-type"] = "application/json; charset=UTF-8";
146
+ const body = this._pre ? JSON.stringify(object, null, this._preS) : JSON.stringify(object);
147
+ this._pH ?? (this._pH = {});
148
+ this._pH["content-type"] = "application/json; charset=UTF-8";
138
149
  return typeof arg === "number" ? this.newResponse(body, arg, headers) : this.newResponse(body, arg);
139
150
  };
140
151
  this.jsonT = (object, arg, headers) => {
@@ -145,13 +156,13 @@ class Context {
145
156
  };
146
157
  };
147
158
  this.html = (html, arg, headers) => {
148
- this._preparedHeaders ?? (this._preparedHeaders = {});
149
- this._preparedHeaders["content-type"] = "text/html; charset=UTF-8";
159
+ this._pH ?? (this._pH = {});
160
+ this._pH["content-type"] = "text/html; charset=UTF-8";
150
161
  return typeof arg === "number" ? this.newResponse(html, arg, headers) : this.newResponse(html, arg);
151
162
  };
152
163
  this.redirect = (location, status = 302) => {
153
- this._headers ?? (this._headers = new Headers());
154
- this._headers.set("Location", location);
164
+ this._h ?? (this._h = new Headers());
165
+ this._h.set("Location", location);
155
166
  return this.newResponse(null, status);
156
167
  };
157
168
  this.cookie = (name, value, opt) => {
@@ -163,9 +174,9 @@ class Context {
163
174
  };
164
175
  this.rawRequest = req;
165
176
  if (options) {
166
- this._executionCtx = options.executionCtx;
177
+ this._exCtx = options.executionCtx;
167
178
  this._path = options.path ?? "/";
168
- this._paramData = options.paramData;
179
+ this._pData = options.paramData;
169
180
  this.env = options.env;
170
181
  if (options.notFoundHandler) {
171
182
  this.notFoundHandler = options.notFoundHandler;
@@ -176,22 +187,22 @@ class Context {
176
187
  if (this._req) {
177
188
  return this._req;
178
189
  } else {
179
- this._req = new import_request.HonoRequest(this.rawRequest, this._path, this._paramData);
190
+ this._req = new import_request.HonoRequest(this.rawRequest, this._path, this._pData);
180
191
  this.rawRequest = void 0;
181
- this._paramData = void 0;
192
+ this._pData = void 0;
182
193
  return this._req;
183
194
  }
184
195
  }
185
196
  get event() {
186
- if (this._executionCtx instanceof FetchEvent) {
187
- return this._executionCtx;
197
+ if (this._exCtx instanceof FetchEvent) {
198
+ return this._exCtx;
188
199
  } else {
189
200
  throw Error("This context has no FetchEvent");
190
201
  }
191
202
  }
192
203
  get executionCtx() {
193
- if (this._executionCtx) {
194
- return this._executionCtx;
204
+ if (this._exCtx) {
205
+ return this._exCtx;
195
206
  } else {
196
207
  throw Error("This context has no ExecutionContext");
197
208
  }