hono 4.0.2 → 4.0.3

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.
@@ -124,7 +124,7 @@ class Context {
124
124
  const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
125
125
  return new Response(data, {
126
126
  headers: headers2,
127
- status: arg.status
127
+ status: arg.status ?? __privateGet(this, _status)
128
128
  });
129
129
  }
130
130
  const status = typeof arg === "number" ? arg : __privateGet(this, _status);
@@ -233,10 +233,8 @@ const _Hono = class extends defineDynamicClass() {
233
233
  let res;
234
234
  try {
235
235
  res = matchResult[0][0][0][0](c, async () => {
236
+ c.res = await this.notFoundHandler(c);
236
237
  });
237
- if (!res) {
238
- return this.notFoundHandler(c);
239
- }
240
238
  } catch (err) {
241
239
  return this.handleError(err, c);
242
240
  }
@@ -77,7 +77,7 @@ const ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) =>
77
77
  if (buffer) {
78
78
  buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
79
79
  }
80
- return buffer ? "" : `<template>${fallbackResString}</template><script>
80
+ return buffer ? "" : `<template data-hono-target="E:${index}">${fallbackResString}</template><script>
81
81
  ((d,c,n) => {
82
82
  c=d.currentScript.previousSibling
83
83
  d=d.getElementById('E:${index}')
@@ -95,7 +95,7 @@ d.replaceWith(c.content)
95
95
  return Promise.all(resArray).then(async (htmlArray) => {
96
96
  htmlArray = htmlArray.flat();
97
97
  const content = htmlArray.join("");
98
- let html = buffer ? "" : `<template>${content}</template><script>
98
+ let html = buffer ? "" : `<template data-hono-target="E:${index}">${content}</template><script>
99
99
  ((d,c) => {
100
100
  c=d.currentScript.previousSibling
101
101
  d=d.getElementById('E:${index}')
@@ -141,7 +141,7 @@ d.parentElement.insertBefore(c.content,d.nextSibling)
141
141
  d=d.getElementById('E:${index}')
142
142
  if(!d)return
143
143
  n=d.nextSibling
144
- do{n=n.nextSibling}while(n.nodeType!=8||n.nodeValue!='E:${index}')
144
+ while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
145
145
  n.remove()
146
146
  d.remove()
147
147
  })(document)
@@ -82,7 +82,7 @@ const Suspense = async ({
82
82
  content
83
83
  );
84
84
  }
85
- let html = buffer ? "" : `<template>${content}</template><script>
85
+ let html = buffer ? "" : `<template data-hono-target="H:${index}">${content}</template><script>
86
86
  ((d,c,n) => {
87
87
  c=d.currentScript.previousSibling
88
88
  d=d.getElementById('H:${index}')
@@ -29,10 +29,13 @@ var import_streaming = require("../../jsx/streaming");
29
29
  const RequestContext = (0, import_jsx.createContext)(null);
30
30
  const createRenderer = (c, Layout, component, options) => (children, props) => {
31
31
  const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
32
- const currentLayout = component ? component({
33
- children,
34
- ...{ Layout, ...props }
35
- }) : children;
32
+ const currentLayout = component ? (0, import_jsx.jsx)(
33
+ component,
34
+ {
35
+ ...{ Layout, ...props }
36
+ },
37
+ children
38
+ ) : children;
36
39
  const body = import_html.html`${(0, import_html.raw)(docType)}${(0, import_jsx.jsx)(
37
40
  RequestContext.Provider,
38
41
  { value: c },
package/dist/context.js CHANGED
@@ -102,7 +102,7 @@ var Context = class {
102
102
  const headers2 = setHeaders(new Headers(arg.headers), __privateGet(this, _preparedHeaders));
103
103
  return new Response(data, {
104
104
  headers: headers2,
105
- status: arg.status
105
+ status: arg.status ?? __privateGet(this, _status)
106
106
  });
107
107
  }
108
108
  const status = typeof arg === "number" ? arg : __privateGet(this, _status);
package/dist/hono-base.js CHANGED
@@ -211,10 +211,8 @@ var _Hono = class extends defineDynamicClass() {
211
211
  let res;
212
212
  try {
213
213
  res = matchResult[0][0][0][0](c, async () => {
214
+ c.res = await this.notFoundHandler(c);
214
215
  });
215
- if (!res) {
216
- return this.notFoundHandler(c);
217
- }
218
216
  } catch (err) {
219
217
  return this.handleError(err, c);
220
218
  }
@@ -54,7 +54,7 @@ var ErrorBoundary = async ({ children, fallback, fallbackRender, onError }) => {
54
54
  if (buffer) {
55
55
  buffer[0] = buffer[0].replace(replaceRe, fallbackResString);
56
56
  }
57
- return buffer ? "" : `<template>${fallbackResString}</template><script>
57
+ return buffer ? "" : `<template data-hono-target="E:${index}">${fallbackResString}</template><script>
58
58
  ((d,c,n) => {
59
59
  c=d.currentScript.previousSibling
60
60
  d=d.getElementById('E:${index}')
@@ -72,7 +72,7 @@ d.replaceWith(c.content)
72
72
  return Promise.all(resArray).then(async (htmlArray) => {
73
73
  htmlArray = htmlArray.flat();
74
74
  const content = htmlArray.join("");
75
- let html = buffer ? "" : `<template>${content}</template><script>
75
+ let html = buffer ? "" : `<template data-hono-target="E:${index}">${content}</template><script>
76
76
  ((d,c) => {
77
77
  c=d.currentScript.previousSibling
78
78
  d=d.getElementById('E:${index}')
@@ -118,7 +118,7 @@ d.parentElement.insertBefore(c.content,d.nextSibling)
118
118
  d=d.getElementById('E:${index}')
119
119
  if(!d)return
120
120
  n=d.nextSibling
121
- do{n=n.nextSibling}while(n.nodeType!=8||n.nodeValue!='E:${index}')
121
+ while(n.nodeType!=8||n.nodeValue!='E:${index}'){n=n.nextSibling}
122
122
  n.remove()
123
123
  d.remove()
124
124
  })(document)
@@ -59,7 +59,7 @@ var Suspense = async ({
59
59
  content
60
60
  );
61
61
  }
62
- let html = buffer ? "" : `<template>${content}</template><script>
62
+ let html = buffer ? "" : `<template data-hono-target="H:${index}">${content}</template><script>
63
63
  ((d,c,n) => {
64
64
  c=d.currentScript.previousSibling
65
65
  d=d.getElementById('H:${index}')
@@ -5,10 +5,13 @@ import { renderToReadableStream } from "../../jsx/streaming.js";
5
5
  var RequestContext = createContext(null);
6
6
  var createRenderer = (c, Layout, component, options) => (children, props) => {
7
7
  const docType = typeof options?.docType === "string" ? options.docType : options?.docType === false ? "" : "<!DOCTYPE html>";
8
- const currentLayout = component ? component({
9
- children,
10
- ...{ Layout, ...props }
11
- }) : children;
8
+ const currentLayout = component ? jsx(
9
+ component,
10
+ {
11
+ ...{ Layout, ...props }
12
+ },
13
+ children
14
+ ) : children;
12
15
  const body = html`${raw(docType)}${jsx(
13
16
  RequestContext.Provider,
14
17
  { value: c },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.0.2",
3
+ "version": "4.0.3",
4
4
  "description": "Ultrafast web framework for the Edges",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",