hono 4.4.4 → 4.4.5
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/context.js +1 -1
- package/dist/cjs/hono-base.js +0 -6
- package/dist/cjs/jsx/base.js +2 -5
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +2 -6
- package/dist/cjs/jsx/dom/render.js +7 -7
- package/dist/cjs/jsx/utils.js +7 -12
- package/dist/cjs/middleware/cors/index.js +6 -1
- package/dist/cjs/request.js +8 -18
- package/dist/context.js +1 -1
- package/dist/hono-base.js +0 -6
- package/dist/jsx/base.js +3 -6
- package/dist/jsx/dom/jsx-dev-runtime.js +0 -4
- package/dist/jsx/dom/render.js +8 -8
- package/dist/jsx/utils.js +6 -11
- package/dist/middleware/cors/index.js +6 -1
- package/dist/request.js +8 -18
- package/dist/types/context.d.ts +4 -4
- package/dist/types/hono-base.d.ts +1 -1
- package/dist/types/jsx/base.d.ts +2 -2
- package/dist/types/jsx/index.d.ts +1 -0
- package/dist/types/jsx/intrinsic-elements.d.ts +2 -2
- package/dist/types/jsx/types.d.ts +2 -2
- package/dist/types/jsx/utils.d.ts +1 -7
- package/package.json +1 -1
package/dist/cjs/context.js
CHANGED
package/dist/cjs/hono-base.js
CHANGED
|
@@ -71,9 +71,6 @@ class Hono {
|
|
|
71
71
|
};
|
|
72
72
|
});
|
|
73
73
|
this.on = (method, path, ...handlers) => {
|
|
74
|
-
if (!method) {
|
|
75
|
-
return this;
|
|
76
|
-
}
|
|
77
74
|
for (const p of [path].flat()) {
|
|
78
75
|
this.#path = p;
|
|
79
76
|
for (const m of [method].flat()) {
|
|
@@ -113,9 +110,6 @@ class Hono {
|
|
|
113
110
|
errorHandler = errorHandler;
|
|
114
111
|
route(path, app) {
|
|
115
112
|
const subApp = this.basePath(path);
|
|
116
|
-
if (!app) {
|
|
117
|
-
return subApp;
|
|
118
|
-
}
|
|
119
113
|
app.routes.map((r) => {
|
|
120
114
|
let handler;
|
|
121
115
|
if (app.errorHandler === errorHandler) {
|
package/dist/cjs/jsx/base.js
CHANGED
|
@@ -133,10 +133,8 @@ class JSXNode {
|
|
|
133
133
|
const props = this.props;
|
|
134
134
|
let { children } = this;
|
|
135
135
|
buffer[0] += `<${tag}`;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
const key = propsKeys[i];
|
|
139
|
-
const v = props[key];
|
|
136
|
+
for (let [key, v] of Object.entries(props)) {
|
|
137
|
+
key = (0, import_utils.normalizeIntrinsicElementKey)(key);
|
|
140
138
|
if (key === "children") {
|
|
141
139
|
} else if (key === "style" && typeof v === "object") {
|
|
142
140
|
let styleStr = "";
|
|
@@ -237,7 +235,6 @@ const jsxFn = (tag, props, children) => {
|
|
|
237
235
|
if (typeof tag === "function") {
|
|
238
236
|
return new JSXFunctionNode(tag, props, children);
|
|
239
237
|
} else {
|
|
240
|
-
(0, import_utils.normalizeIntrinsicElementProps)(props);
|
|
241
238
|
return new JSXNode(tag, props, children);
|
|
242
239
|
}
|
|
243
240
|
};
|
|
@@ -22,13 +22,9 @@ __export(jsx_dev_runtime_exports, {
|
|
|
22
22
|
jsxDEV: () => jsxDEV
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(jsx_dev_runtime_exports);
|
|
25
|
-
var import_utils = require("
|
|
26
|
-
var import_utils2 = require("./utils");
|
|
25
|
+
var import_utils = require("./utils");
|
|
27
26
|
const jsxDEV = (tag, props, key) => {
|
|
28
|
-
|
|
29
|
-
(0, import_utils.normalizeIntrinsicElementProps)(props);
|
|
30
|
-
}
|
|
31
|
-
return (0, import_utils2.newJSXNode)({
|
|
27
|
+
return (0, import_utils.newJSXNode)({
|
|
32
28
|
tag,
|
|
33
29
|
props,
|
|
34
30
|
key
|
|
@@ -41,8 +41,8 @@ const eventAliasMap = {
|
|
|
41
41
|
DoubleClick: "DblClick"
|
|
42
42
|
};
|
|
43
43
|
const nameSpaceMap = {
|
|
44
|
-
svg: "
|
|
45
|
-
math: "
|
|
44
|
+
svg: "2000/svg",
|
|
45
|
+
math: "1998/Math/MathML"
|
|
46
46
|
};
|
|
47
47
|
const skipProps = /* @__PURE__ */ new Set(["children"]);
|
|
48
48
|
const buildDataStack = [];
|
|
@@ -59,8 +59,9 @@ const getEventSpec = (key) => {
|
|
|
59
59
|
const toAttributeName = (element, key) => element instanceof SVGElement && /[A-Z]/.test(key) && (key in element.style || key.match(/^(?:o|pai|str|u|ve)/)) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
60
60
|
const applyProps = (container, attributes, oldAttributes) => {
|
|
61
61
|
attributes ||= {};
|
|
62
|
-
for (
|
|
62
|
+
for (let [key, value] of Object.entries(attributes)) {
|
|
63
63
|
if (!skipProps.has(key) && (!oldAttributes || oldAttributes[key] !== value)) {
|
|
64
|
+
key = (0, import_utils.normalizeIntrinsicElementKey)(key);
|
|
64
65
|
const eventSpec = getEventSpec(key);
|
|
65
66
|
if (eventSpec) {
|
|
66
67
|
if (oldAttributes) {
|
|
@@ -125,8 +126,9 @@ const applyProps = (container, attributes, oldAttributes) => {
|
|
|
125
126
|
}
|
|
126
127
|
}
|
|
127
128
|
if (oldAttributes) {
|
|
128
|
-
for (
|
|
129
|
+
for (let [key, value] of Object.entries(oldAttributes)) {
|
|
129
130
|
if (!skipProps.has(key) && !(key in attributes)) {
|
|
131
|
+
key = (0, import_utils.normalizeIntrinsicElementKey)(key);
|
|
130
132
|
const eventSpec = getEventSpec(key);
|
|
131
133
|
if (eventSpec) {
|
|
132
134
|
container.removeEventListener(eventSpec[0], value, eventSpec[1]);
|
|
@@ -386,14 +388,12 @@ const buildNode = (node) => {
|
|
|
386
388
|
} else {
|
|
387
389
|
const ns = nameSpaceMap[node.tag];
|
|
388
390
|
if (ns) {
|
|
389
|
-
;
|
|
390
|
-
node.n = ns;
|
|
391
391
|
nameSpaceContext ||= (0, import_context2.createContext)("");
|
|
392
392
|
node.props.children = [
|
|
393
393
|
{
|
|
394
394
|
tag: nameSpaceContext.Provider,
|
|
395
395
|
props: {
|
|
396
|
-
value: ns
|
|
396
|
+
value: node.n = `http://www.w3.org/${ns}`,
|
|
397
397
|
children: node.props.children
|
|
398
398
|
}
|
|
399
399
|
}
|
package/dist/cjs/jsx/utils.js
CHANGED
|
@@ -18,20 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var utils_exports = {};
|
|
20
20
|
__export(utils_exports, {
|
|
21
|
-
|
|
21
|
+
normalizeIntrinsicElementKey: () => normalizeIntrinsicElementKey,
|
|
22
22
|
styleObjectForEach: () => styleObjectForEach
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(utils_exports);
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
if (props && "htmlFor" in props) {
|
|
31
|
-
props["for"] = props["htmlFor"];
|
|
32
|
-
delete props["htmlFor"];
|
|
33
|
-
}
|
|
34
|
-
};
|
|
25
|
+
const normalizeElementKeyMap = /* @__PURE__ */ new Map([
|
|
26
|
+
["className", "class"],
|
|
27
|
+
["htmlFor", "for"]
|
|
28
|
+
]);
|
|
29
|
+
const normalizeIntrinsicElementKey = (key) => normalizeElementKeyMap.get(key) || key;
|
|
35
30
|
const styleObjectForEach = (style, fn) => {
|
|
36
31
|
for (const [k, v] of Object.entries(style)) {
|
|
37
32
|
const key = k[0] === "-" || !/[A-Z]/.test(k) ? k : k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
@@ -45,6 +40,6 @@ const styleObjectForEach = (style, fn) => {
|
|
|
45
40
|
};
|
|
46
41
|
// Annotate the CommonJS export names for ESM import in node:
|
|
47
42
|
0 && (module.exports = {
|
|
48
|
-
|
|
43
|
+
normalizeIntrinsicElementKey,
|
|
49
44
|
styleObjectForEach
|
|
50
45
|
});
|
|
@@ -50,7 +50,12 @@ const cors = (options) => {
|
|
|
50
50
|
set("Access-Control-Allow-Origin", allowOrigin);
|
|
51
51
|
}
|
|
52
52
|
if (opts.origin !== "*") {
|
|
53
|
-
|
|
53
|
+
const existingVary = c.req.header("Vary");
|
|
54
|
+
if (existingVary) {
|
|
55
|
+
set("Vary", existingVary);
|
|
56
|
+
} else {
|
|
57
|
+
set("Vary", "Origin");
|
|
58
|
+
}
|
|
54
59
|
}
|
|
55
60
|
if (opts.credentials) {
|
|
56
61
|
set("Access-Control-Allow-Credentials", "true");
|
package/dist/cjs/request.js
CHANGED
|
@@ -75,12 +75,7 @@ class HonoRequest {
|
|
|
75
75
|
return headerData;
|
|
76
76
|
}
|
|
77
77
|
async parseBody(options) {
|
|
78
|
-
|
|
79
|
-
return this.bodyCache.parsedBody;
|
|
80
|
-
}
|
|
81
|
-
const parsedBody = await (0, import_body.parseBody)(this, options);
|
|
82
|
-
this.bodyCache.parsedBody = parsedBody;
|
|
83
|
-
return parsedBody;
|
|
78
|
+
return this.bodyCache.parsedBody ??= await (0, import_body.parseBody)(this, options);
|
|
84
79
|
}
|
|
85
80
|
cachedBody = (key) => {
|
|
86
81
|
const { bodyCache, raw } = this;
|
|
@@ -88,19 +83,14 @@ class HonoRequest {
|
|
|
88
83
|
if (cachedBody) {
|
|
89
84
|
return cachedBody;
|
|
90
85
|
}
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
86
|
+
const anyCachedKey = Object.keys(bodyCache)[0];
|
|
87
|
+
if (anyCachedKey) {
|
|
88
|
+
return bodyCache[anyCachedKey].then((body) => {
|
|
89
|
+
if (anyCachedKey === "json") {
|
|
90
|
+
body = JSON.stringify(body);
|
|
95
91
|
}
|
|
96
|
-
return
|
|
97
|
-
|
|
98
|
-
if (keyOfBodyCache === "json") {
|
|
99
|
-
body = JSON.stringify(body);
|
|
100
|
-
}
|
|
101
|
-
return await new Response(body)[key]();
|
|
102
|
-
})();
|
|
103
|
-
}
|
|
92
|
+
return new Response(body)[key]();
|
|
93
|
+
});
|
|
104
94
|
}
|
|
105
95
|
return bodyCache[key] = raw[key]();
|
|
106
96
|
};
|
package/dist/context.js
CHANGED
package/dist/hono-base.js
CHANGED
|
@@ -48,9 +48,6 @@ var Hono = class {
|
|
|
48
48
|
};
|
|
49
49
|
});
|
|
50
50
|
this.on = (method, path, ...handlers) => {
|
|
51
|
-
if (!method) {
|
|
52
|
-
return this;
|
|
53
|
-
}
|
|
54
51
|
for (const p of [path].flat()) {
|
|
55
52
|
this.#path = p;
|
|
56
53
|
for (const m of [method].flat()) {
|
|
@@ -90,9 +87,6 @@ var Hono = class {
|
|
|
90
87
|
errorHandler = errorHandler;
|
|
91
88
|
route(path, app) {
|
|
92
89
|
const subApp = this.basePath(path);
|
|
93
|
-
if (!app) {
|
|
94
|
-
return subApp;
|
|
95
|
-
}
|
|
96
90
|
app.routes.map((r) => {
|
|
97
91
|
let handler;
|
|
98
92
|
if (app.errorHandler === errorHandler) {
|
package/dist/jsx/base.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import { raw } from "../helper/html/index.js";
|
|
3
3
|
import { escapeToBuffer, stringBufferToString } from "../utils/html.js";
|
|
4
4
|
import { globalContexts } from "./context.js";
|
|
5
|
-
import {
|
|
5
|
+
import { normalizeIntrinsicElementKey, styleObjectForEach } from "./utils.js";
|
|
6
6
|
var emptyTags = [
|
|
7
7
|
"area",
|
|
8
8
|
"base",
|
|
@@ -103,10 +103,8 @@ var JSXNode = class {
|
|
|
103
103
|
const props = this.props;
|
|
104
104
|
let { children } = this;
|
|
105
105
|
buffer[0] += `<${tag}`;
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
const key = propsKeys[i];
|
|
109
|
-
const v = props[key];
|
|
106
|
+
for (let [key, v] of Object.entries(props)) {
|
|
107
|
+
key = normalizeIntrinsicElementKey(key);
|
|
110
108
|
if (key === "children") {
|
|
111
109
|
} else if (key === "style" && typeof v === "object") {
|
|
112
110
|
let styleStr = "";
|
|
@@ -207,7 +205,6 @@ var jsxFn = (tag, props, children) => {
|
|
|
207
205
|
if (typeof tag === "function") {
|
|
208
206
|
return new JSXFunctionNode(tag, props, children);
|
|
209
207
|
} else {
|
|
210
|
-
normalizeIntrinsicElementProps(props);
|
|
211
208
|
return new JSXNode(tag, props, children);
|
|
212
209
|
}
|
|
213
210
|
};
|
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
// src/jsx/dom/jsx-dev-runtime.ts
|
|
2
|
-
import { normalizeIntrinsicElementProps } from "../utils.js";
|
|
3
2
|
import { newJSXNode } from "./utils.js";
|
|
4
3
|
var jsxDEV = (tag, props, key) => {
|
|
5
|
-
if (typeof tag === "string") {
|
|
6
|
-
normalizeIntrinsicElementProps(props);
|
|
7
|
-
}
|
|
8
4
|
return newJSXNode({
|
|
9
5
|
tag,
|
|
10
6
|
props,
|
package/dist/jsx/dom/render.js
CHANGED
|
@@ -3,7 +3,7 @@ import { toArray } from "../children.js";
|
|
|
3
3
|
import { DOM_ERROR_HANDLER, DOM_INTERNAL_TAG, DOM_RENDERER, DOM_STASH } from "../constants.js";
|
|
4
4
|
import { globalContexts as globalJSXContexts, useContext } from "../context.js";
|
|
5
5
|
import { STASH_EFFECT } from "../hooks/index.js";
|
|
6
|
-
import { styleObjectForEach } from "../utils.js";
|
|
6
|
+
import { normalizeIntrinsicElementKey, styleObjectForEach } from "../utils.js";
|
|
7
7
|
import { createContext } from "./context.js";
|
|
8
8
|
import { newJSXNode } from "./utils.js";
|
|
9
9
|
var HONO_PORTAL_ELEMENT = "_hp";
|
|
@@ -12,8 +12,8 @@ var eventAliasMap = {
|
|
|
12
12
|
DoubleClick: "DblClick"
|
|
13
13
|
};
|
|
14
14
|
var nameSpaceMap = {
|
|
15
|
-
svg: "
|
|
16
|
-
math: "
|
|
15
|
+
svg: "2000/svg",
|
|
16
|
+
math: "1998/Math/MathML"
|
|
17
17
|
};
|
|
18
18
|
var skipProps = /* @__PURE__ */ new Set(["children"]);
|
|
19
19
|
var buildDataStack = [];
|
|
@@ -30,8 +30,9 @@ var getEventSpec = (key) => {
|
|
|
30
30
|
var toAttributeName = (element, key) => element instanceof SVGElement && /[A-Z]/.test(key) && (key in element.style || key.match(/^(?:o|pai|str|u|ve)/)) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key;
|
|
31
31
|
var applyProps = (container, attributes, oldAttributes) => {
|
|
32
32
|
attributes ||= {};
|
|
33
|
-
for (
|
|
33
|
+
for (let [key, value] of Object.entries(attributes)) {
|
|
34
34
|
if (!skipProps.has(key) && (!oldAttributes || oldAttributes[key] !== value)) {
|
|
35
|
+
key = normalizeIntrinsicElementKey(key);
|
|
35
36
|
const eventSpec = getEventSpec(key);
|
|
36
37
|
if (eventSpec) {
|
|
37
38
|
if (oldAttributes) {
|
|
@@ -96,8 +97,9 @@ var applyProps = (container, attributes, oldAttributes) => {
|
|
|
96
97
|
}
|
|
97
98
|
}
|
|
98
99
|
if (oldAttributes) {
|
|
99
|
-
for (
|
|
100
|
+
for (let [key, value] of Object.entries(oldAttributes)) {
|
|
100
101
|
if (!skipProps.has(key) && !(key in attributes)) {
|
|
102
|
+
key = normalizeIntrinsicElementKey(key);
|
|
101
103
|
const eventSpec = getEventSpec(key);
|
|
102
104
|
if (eventSpec) {
|
|
103
105
|
container.removeEventListener(eventSpec[0], value, eventSpec[1]);
|
|
@@ -357,14 +359,12 @@ var buildNode = (node) => {
|
|
|
357
359
|
} else {
|
|
358
360
|
const ns = nameSpaceMap[node.tag];
|
|
359
361
|
if (ns) {
|
|
360
|
-
;
|
|
361
|
-
node.n = ns;
|
|
362
362
|
nameSpaceContext ||= createContext("");
|
|
363
363
|
node.props.children = [
|
|
364
364
|
{
|
|
365
365
|
tag: nameSpaceContext.Provider,
|
|
366
366
|
props: {
|
|
367
|
-
value: ns
|
|
367
|
+
value: node.n = `http://www.w3.org/${ns}`,
|
|
368
368
|
children: node.props.children
|
|
369
369
|
}
|
|
370
370
|
}
|
package/dist/jsx/utils.js
CHANGED
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
// src/jsx/utils.ts
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (props && "htmlFor" in props) {
|
|
8
|
-
props["for"] = props["htmlFor"];
|
|
9
|
-
delete props["htmlFor"];
|
|
10
|
-
}
|
|
11
|
-
};
|
|
2
|
+
var normalizeElementKeyMap = /* @__PURE__ */ new Map([
|
|
3
|
+
["className", "class"],
|
|
4
|
+
["htmlFor", "for"]
|
|
5
|
+
]);
|
|
6
|
+
var normalizeIntrinsicElementKey = (key) => normalizeElementKeyMap.get(key) || key;
|
|
12
7
|
var styleObjectForEach = (style, fn) => {
|
|
13
8
|
for (const [k, v] of Object.entries(style)) {
|
|
14
9
|
const key = k[0] === "-" || !/[A-Z]/.test(k) ? k : k.replace(/[A-Z]/g, (m) => `-${m.toLowerCase()}`);
|
|
@@ -21,6 +16,6 @@ var styleObjectForEach = (style, fn) => {
|
|
|
21
16
|
}
|
|
22
17
|
};
|
|
23
18
|
export {
|
|
24
|
-
|
|
19
|
+
normalizeIntrinsicElementKey,
|
|
25
20
|
styleObjectForEach
|
|
26
21
|
};
|
|
@@ -28,7 +28,12 @@ var cors = (options) => {
|
|
|
28
28
|
set("Access-Control-Allow-Origin", allowOrigin);
|
|
29
29
|
}
|
|
30
30
|
if (opts.origin !== "*") {
|
|
31
|
-
|
|
31
|
+
const existingVary = c.req.header("Vary");
|
|
32
|
+
if (existingVary) {
|
|
33
|
+
set("Vary", existingVary);
|
|
34
|
+
} else {
|
|
35
|
+
set("Vary", "Origin");
|
|
36
|
+
}
|
|
32
37
|
}
|
|
33
38
|
if (opts.credentials) {
|
|
34
39
|
set("Access-Control-Allow-Credentials", "true");
|
package/dist/request.js
CHANGED
|
@@ -53,12 +53,7 @@ var HonoRequest = class {
|
|
|
53
53
|
return headerData;
|
|
54
54
|
}
|
|
55
55
|
async parseBody(options) {
|
|
56
|
-
|
|
57
|
-
return this.bodyCache.parsedBody;
|
|
58
|
-
}
|
|
59
|
-
const parsedBody = await parseBody(this, options);
|
|
60
|
-
this.bodyCache.parsedBody = parsedBody;
|
|
61
|
-
return parsedBody;
|
|
56
|
+
return this.bodyCache.parsedBody ??= await parseBody(this, options);
|
|
62
57
|
}
|
|
63
58
|
cachedBody = (key) => {
|
|
64
59
|
const { bodyCache, raw } = this;
|
|
@@ -66,19 +61,14 @@ var HonoRequest = class {
|
|
|
66
61
|
if (cachedBody) {
|
|
67
62
|
return cachedBody;
|
|
68
63
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
64
|
+
const anyCachedKey = Object.keys(bodyCache)[0];
|
|
65
|
+
if (anyCachedKey) {
|
|
66
|
+
return bodyCache[anyCachedKey].then((body) => {
|
|
67
|
+
if (anyCachedKey === "json") {
|
|
68
|
+
body = JSON.stringify(body);
|
|
73
69
|
}
|
|
74
|
-
return
|
|
75
|
-
|
|
76
|
-
if (keyOfBodyCache === "json") {
|
|
77
|
-
body = JSON.stringify(body);
|
|
78
|
-
}
|
|
79
|
-
return await new Response(body)[key]();
|
|
80
|
-
})();
|
|
81
|
-
}
|
|
70
|
+
return new Response(body)[key]();
|
|
71
|
+
});
|
|
82
72
|
}
|
|
83
73
|
return bodyCache[key] = raw[key]();
|
|
84
74
|
};
|
package/dist/types/context.d.ts
CHANGED
|
@@ -95,8 +95,8 @@ interface BodyRespond extends NewResponse {
|
|
|
95
95
|
* @returns {Response & TypedResponse<T, U, 'text'>} - The response after rendering the text content, typed with the provided text and status code types.
|
|
96
96
|
*/
|
|
97
97
|
interface TextRespond {
|
|
98
|
-
<T extends string, U extends StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, 'text'>;
|
|
99
|
-
<T extends string, U extends StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, 'text'>;
|
|
98
|
+
<T extends string, U extends StatusCode = StatusCode>(text: T, status?: U, headers?: HeaderRecord): Response & TypedResponse<T, U, 'text'>;
|
|
99
|
+
<T extends string, U extends StatusCode = StatusCode>(text: T, init?: ResponseInit): Response & TypedResponse<T, U, 'text'>;
|
|
100
100
|
}
|
|
101
101
|
/**
|
|
102
102
|
* Interface for responding with JSON.
|
|
@@ -112,8 +112,8 @@ interface TextRespond {
|
|
|
112
112
|
* @returns {JSONRespondReturn<T, U>} - The response after rendering the JSON object, typed with the provided object and status code types.
|
|
113
113
|
*/
|
|
114
114
|
interface JSONRespond {
|
|
115
|
-
<T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>;
|
|
116
|
-
<T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>;
|
|
115
|
+
<T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode = StatusCode>(object: T, status?: U, headers?: HeaderRecord): JSONRespondReturn<T, U>;
|
|
116
|
+
<T extends JSONValue | SimplifyDeepArray<unknown>, U extends StatusCode = StatusCode>(object: T, init?: ResponseInit): JSONRespondReturn<T, U>;
|
|
117
117
|
}
|
|
118
118
|
/**
|
|
119
119
|
* @template T - The type of the JSON value or simplified unknown type.
|
|
@@ -98,7 +98,7 @@ declare class Hono<E extends Env = Env, S extends Schema = {}, BasePath extends
|
|
|
98
98
|
* app.route("/api", app2) // GET /api/user
|
|
99
99
|
* ```
|
|
100
100
|
*/
|
|
101
|
-
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app
|
|
101
|
+
route<SubPath extends string, SubEnv extends Env, SubSchema extends Schema, SubBasePath extends string>(path: SubPath, app: Hono<SubEnv, SubSchema, SubBasePath>): Hono<E, MergeSchemaPath<SubSchema, MergePath<BasePath, SubPath>> & S, BasePath>;
|
|
102
102
|
/**
|
|
103
103
|
* `.basePath()` allows base paths to be specified.
|
|
104
104
|
*
|
package/dist/types/jsx/base.d.ts
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { HtmlEscaped, HtmlEscapedString, StringBuffer } from '../utils/html';
|
|
2
2
|
import type { Context } from './context';
|
|
3
|
-
import type {
|
|
3
|
+
import type { JSX as HonoJSX, IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements';
|
|
4
4
|
export type Props = Record<string, any>;
|
|
5
5
|
export type FC<P = Props> = {
|
|
6
6
|
(props: P): HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
7
7
|
defaultProps?: Partial<P> | undefined;
|
|
8
8
|
displayName?: string | undefined;
|
|
9
9
|
};
|
|
10
|
-
export type DOMAttributes =
|
|
10
|
+
export type DOMAttributes = HonoJSX.HTMLAttributes;
|
|
11
11
|
export declare namespace JSX {
|
|
12
12
|
type Element = HtmlEscapedString | Promise<HtmlEscapedString>;
|
|
13
13
|
interface ElementChildrenAttribute {
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* MIT License
|
|
5
5
|
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
6
6
|
*/
|
|
7
|
-
export declare namespace
|
|
7
|
+
export declare namespace JSX {
|
|
8
8
|
export type CrossOrigin = 'anonymous' | 'use-credentials' | '' | undefined;
|
|
9
9
|
export type CSSProperties = {};
|
|
10
10
|
type AnyAttributes = {
|
|
@@ -636,5 +636,5 @@ export declare namespace Hono {
|
|
|
636
636
|
}
|
|
637
637
|
export {};
|
|
638
638
|
}
|
|
639
|
-
export interface IntrinsicElements extends
|
|
639
|
+
export interface IntrinsicElements extends JSX.IntrinsicElements {
|
|
640
640
|
}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* All types exported from "hono/jsx" are in this file.
|
|
3
3
|
*/
|
|
4
4
|
import type { Child, JSXNode } from './base';
|
|
5
|
-
import type {
|
|
5
|
+
import type { JSX } from './intrinsic-elements';
|
|
6
6
|
export type { Child, JSXNode, FC } from './base';
|
|
7
7
|
export type { RefObject } from './hooks';
|
|
8
8
|
export type { Context } from './context';
|
|
9
9
|
export type PropsWithChildren<P = unknown> = P & {
|
|
10
10
|
children?: Child | undefined;
|
|
11
11
|
};
|
|
12
|
-
export type CSSProperties =
|
|
12
|
+
export type CSSProperties = JSX.CSSProperties;
|
|
13
13
|
/**
|
|
14
14
|
* React types
|
|
15
15
|
*/
|
|
@@ -1,8 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
* Normalizes intrinsic element properties by converting JSX element properties
|
|
3
|
-
* to their corresponding HTML attributes.
|
|
4
|
-
*
|
|
5
|
-
* @param props - JSX element properties.
|
|
6
|
-
*/
|
|
7
|
-
export declare const normalizeIntrinsicElementProps: (props: Record<string, unknown>) => void;
|
|
1
|
+
export declare const normalizeIntrinsicElementKey: (key: string) => string;
|
|
8
2
|
export declare const styleObjectForEach: (style: Record<string, string | number>, fn: (key: string, value: string | null) => void) => void;
|