hono 4.5.5 → 4.5.7
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/README.md +1 -1
- package/dist/cjs/client/utils.js +2 -2
- package/dist/cjs/jsx/dom/context.js +1 -1
- package/dist/cjs/jsx/dom/intrinsic-element/components.js +43 -28
- package/dist/cjs/jsx/dom/jsx-dev-runtime.js +9 -5
- package/dist/cjs/jsx/dom/render.js +153 -86
- package/dist/cjs/jsx/dom/utils.js +0 -15
- package/dist/cjs/jsx/hooks/index.js +6 -5
- package/dist/cjs/utils/html.js +4 -3
- package/dist/cjs/validator/validator.js +9 -8
- package/dist/client/utils.js +2 -2
- package/dist/jsx/dom/context.js +2 -2
- package/dist/jsx/dom/intrinsic-element/components.js +43 -28
- package/dist/jsx/dom/jsx-dev-runtime.js +9 -5
- package/dist/jsx/dom/render.js +153 -86
- package/dist/jsx/dom/utils.js +0 -14
- package/dist/jsx/hooks/index.js +6 -5
- package/dist/types/client/utils.d.ts +1 -1
- package/dist/types/jsx/dom/render.d.ts +2 -1
- package/dist/types/jsx/dom/utils.d.ts +0 -6
- package/dist/types/jsx/intrinsic-elements.d.ts +39 -13
- package/dist/types/utils/types.d.ts +5 -0
- package/dist/utils/html.js +4 -3
- package/dist/validator/validator.js +9 -8
- package/package.json +1 -1
package/dist/jsx/dom/utils.js
CHANGED
|
@@ -5,20 +5,6 @@ var setInternalTagFlag = (fn) => {
|
|
|
5
5
|
fn[DOM_INTERNAL_TAG] = true;
|
|
6
6
|
return fn;
|
|
7
7
|
};
|
|
8
|
-
var JSXNodeCompatPrototype = {
|
|
9
|
-
type: {
|
|
10
|
-
get() {
|
|
11
|
-
return this.tag;
|
|
12
|
-
}
|
|
13
|
-
},
|
|
14
|
-
ref: {
|
|
15
|
-
get() {
|
|
16
|
-
return this.props?.ref;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var newJSXNode = (obj) => Object.defineProperties(obj, JSXNodeCompatPrototype);
|
|
21
8
|
export {
|
|
22
|
-
newJSXNode,
|
|
23
9
|
setInternalTagFlag
|
|
24
10
|
};
|
package/dist/jsx/hooks/index.js
CHANGED
|
@@ -172,13 +172,14 @@ var useState = (initialState) => {
|
|
|
172
172
|
];
|
|
173
173
|
};
|
|
174
174
|
var useReducer = (reducer, initialArg, init) => {
|
|
175
|
-
const
|
|
176
|
-
return [
|
|
177
|
-
state,
|
|
175
|
+
const handler = useCallback(
|
|
178
176
|
(action) => {
|
|
179
177
|
setState((state2) => reducer(state2, action));
|
|
180
|
-
}
|
|
181
|
-
|
|
178
|
+
},
|
|
179
|
+
[reducer]
|
|
180
|
+
);
|
|
181
|
+
const [state, setState] = useState(() => init ? init(initialArg) : initialArg);
|
|
182
|
+
return [state, handler];
|
|
182
183
|
};
|
|
183
184
|
var useEffectCommon = (index, effect, deps) => {
|
|
184
185
|
const buildData = buildDataStack.at(-1);
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export declare const mergePath: (base: string, path: string) => string;
|
|
2
|
-
export declare const replaceUrlParam: (urlString: string, params: Record<string, string>) => string;
|
|
2
|
+
export declare const replaceUrlParam: (urlString: string, params: Record<string, string | undefined>) => string;
|
|
3
3
|
export declare const replaceUrlProtocol: (urlString: string, protocol: 'ws' | 'http') => string;
|
|
4
4
|
export declare const removeIndexString: (urlSting: string) => string;
|
|
5
5
|
export declare function deepMerge<T>(target: T, source: Record<string, unknown>): T;
|
|
@@ -15,9 +15,9 @@ export type NodeObject = {
|
|
|
15
15
|
vC: Node[];
|
|
16
16
|
pC?: Node[];
|
|
17
17
|
vR: Node[];
|
|
18
|
-
s?: Node[];
|
|
19
18
|
n?: string;
|
|
20
19
|
f?: boolean;
|
|
20
|
+
s?: boolean;
|
|
21
21
|
c: Container | undefined;
|
|
22
22
|
e: SupportedElement | Text | undefined;
|
|
23
23
|
p?: PreserveNodeType;
|
|
@@ -36,6 +36,7 @@ export type NodeObject = {
|
|
|
36
36
|
type NodeString = {
|
|
37
37
|
t: string;
|
|
38
38
|
d: boolean;
|
|
39
|
+
s?: boolean;
|
|
39
40
|
} & {
|
|
40
41
|
e?: Text;
|
|
41
42
|
vC: undefined;
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import type { BaseMime } from '../utils/mime';
|
|
2
|
+
import type { StringLiteralUnion } from '../utils/types';
|
|
1
3
|
/**
|
|
2
4
|
* This code is based on React.
|
|
3
5
|
* https://github.com/facebook/react
|
|
@@ -174,7 +176,7 @@ export declare namespace JSX {
|
|
|
174
176
|
itemProp?: string | undefined;
|
|
175
177
|
}
|
|
176
178
|
type HTMLAttributeReferrerPolicy = '' | 'no-referrer' | 'no-referrer-when-downgrade' | 'origin' | 'origin-when-cross-origin' | 'same-origin' | 'strict-origin' | 'strict-origin-when-cross-origin' | 'unsafe-url';
|
|
177
|
-
type HTMLAttributeAnchorTarget = '_self' | '_blank' | '_parent' | '_top'
|
|
179
|
+
type HTMLAttributeAnchorTarget = StringLiteralUnion<'_self' | '_blank' | '_parent' | '_top'>;
|
|
178
180
|
interface AnchorHTMLAttributes extends HTMLAttributes {
|
|
179
181
|
download?: string | boolean | undefined;
|
|
180
182
|
href?: string | undefined;
|
|
@@ -182,7 +184,7 @@ export declare namespace JSX {
|
|
|
182
184
|
media?: string | undefined;
|
|
183
185
|
ping?: string | undefined;
|
|
184
186
|
target?: HTMLAttributeAnchorTarget | undefined;
|
|
185
|
-
type?:
|
|
187
|
+
type?: StringLiteralUnion<BaseMime> | undefined;
|
|
186
188
|
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
187
189
|
}
|
|
188
190
|
interface AudioHTMLAttributes extends MediaHTMLAttributes {
|
|
@@ -196,11 +198,11 @@ export declare namespace JSX {
|
|
|
196
198
|
media?: string | undefined;
|
|
197
199
|
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
198
200
|
shape?: string | undefined;
|
|
199
|
-
target?:
|
|
201
|
+
target?: HTMLAttributeAnchorTarget | undefined;
|
|
200
202
|
}
|
|
201
203
|
interface BaseHTMLAttributes extends HTMLAttributes {
|
|
202
204
|
href?: string | undefined;
|
|
203
|
-
target?:
|
|
205
|
+
target?: HTMLAttributeAnchorTarget | undefined;
|
|
204
206
|
}
|
|
205
207
|
interface BlockquoteHTMLAttributes extends HTMLAttributes {
|
|
206
208
|
cite?: string | undefined;
|
|
@@ -211,7 +213,7 @@ export declare namespace JSX {
|
|
|
211
213
|
formenctype?: string | undefined;
|
|
212
214
|
formmethod?: string | undefined;
|
|
213
215
|
formnovalidate?: boolean | undefined;
|
|
214
|
-
formtarget?:
|
|
216
|
+
formtarget?: HTMLAttributeAnchorTarget | undefined;
|
|
215
217
|
name?: string | undefined;
|
|
216
218
|
type?: 'submit' | 'reset' | 'button' | undefined;
|
|
217
219
|
value?: string | ReadonlyArray<string> | number | undefined;
|
|
@@ -259,7 +261,7 @@ export declare namespace JSX {
|
|
|
259
261
|
method?: string | undefined;
|
|
260
262
|
name?: string | undefined;
|
|
261
263
|
novalidate?: boolean | undefined;
|
|
262
|
-
target?:
|
|
264
|
+
target?: HTMLAttributeAnchorTarget | undefined;
|
|
263
265
|
action?: string | Function | undefined;
|
|
264
266
|
}
|
|
265
267
|
interface HtmlHTMLAttributes extends HTMLAttributes {
|
|
@@ -295,11 +297,22 @@ export declare namespace JSX {
|
|
|
295
297
|
cite?: string | undefined;
|
|
296
298
|
datetime?: string | undefined;
|
|
297
299
|
}
|
|
298
|
-
type HTMLInputTypeAttribute = 'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'
|
|
300
|
+
type HTMLInputTypeAttribute = StringLiteralUnion<'button' | 'checkbox' | 'color' | 'date' | 'datetime-local' | 'email' | 'file' | 'hidden' | 'image' | 'month' | 'number' | 'password' | 'radio' | 'range' | 'reset' | 'search' | 'submit' | 'tel' | 'text' | 'time' | 'url' | 'week'>;
|
|
301
|
+
type AutoFillAddressKind = 'billing' | 'shipping';
|
|
302
|
+
type AutoFillBase = '' | 'off' | 'on';
|
|
303
|
+
type AutoFillContactField = 'email' | 'tel' | 'tel-area-code' | 'tel-country-code' | 'tel-extension' | 'tel-local' | 'tel-local-prefix' | 'tel-local-suffix' | 'tel-national';
|
|
304
|
+
type AutoFillContactKind = 'home' | 'mobile' | 'work';
|
|
305
|
+
type AutoFillCredentialField = 'webauthn';
|
|
306
|
+
type AutoFillNormalField = 'additional-name' | 'address-level1' | 'address-level2' | 'address-level3' | 'address-level4' | 'address-line1' | 'address-line2' | 'address-line3' | 'bday-day' | 'bday-month' | 'bday-year' | 'cc-csc' | 'cc-exp' | 'cc-exp-month' | 'cc-exp-year' | 'cc-family-name' | 'cc-given-name' | 'cc-name' | 'cc-number' | 'cc-type' | 'country' | 'country-name' | 'current-password' | 'family-name' | 'given-name' | 'honorific-prefix' | 'honorific-suffix' | 'name' | 'new-password' | 'one-time-code' | 'organization' | 'postal-code' | 'street-address' | 'transaction-amount' | 'transaction-currency' | 'username';
|
|
307
|
+
type OptionalPrefixToken<T extends string> = `${T} ` | '';
|
|
308
|
+
type OptionalPostfixToken<T extends string> = ` ${T}` | '';
|
|
309
|
+
type AutoFillField = AutoFillNormalField | `${OptionalPrefixToken<AutoFillContactKind>}${AutoFillContactField}`;
|
|
310
|
+
type AutoFillSection = `section-${string}`;
|
|
311
|
+
type AutoFill = AutoFillBase | `${OptionalPrefixToken<AutoFillSection>}${OptionalPrefixToken<AutoFillAddressKind>}${AutoFillField}${OptionalPostfixToken<AutoFillCredentialField>}`;
|
|
299
312
|
interface InputHTMLAttributes extends HTMLAttributes {
|
|
300
313
|
accept?: string | undefined;
|
|
301
314
|
alt?: string | undefined;
|
|
302
|
-
autocomplete?:
|
|
315
|
+
autocomplete?: StringLiteralUnion<AutoFill> | undefined;
|
|
303
316
|
capture?: boolean | 'user' | 'environment' | undefined;
|
|
304
317
|
checked?: boolean | undefined;
|
|
305
318
|
disabled?: boolean | undefined;
|
|
@@ -307,7 +320,7 @@ export declare namespace JSX {
|
|
|
307
320
|
formenctype?: string | undefined;
|
|
308
321
|
formmethod?: string | undefined;
|
|
309
322
|
formnovalidate?: boolean | undefined;
|
|
310
|
-
formtarget?:
|
|
323
|
+
formtarget?: HTMLAttributeAnchorTarget | undefined;
|
|
311
324
|
height?: number | string | undefined;
|
|
312
325
|
list?: string | undefined;
|
|
313
326
|
max?: number | string | undefined;
|
|
@@ -381,13 +394,26 @@ export declare namespace JSX {
|
|
|
381
394
|
preload?: string | undefined;
|
|
382
395
|
src?: string | undefined;
|
|
383
396
|
}
|
|
397
|
+
/**
|
|
398
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta#http-equiv
|
|
399
|
+
*/
|
|
400
|
+
type MetaHttpEquiv = 'content-security-policy' | 'content-type' | 'default-style' | 'x-ua-compatible' | 'refresh';
|
|
401
|
+
/**
|
|
402
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/meta/name
|
|
403
|
+
*/
|
|
404
|
+
type MetaName = 'application-name' | 'author' | 'description' | 'generator' | 'keywords' | 'referrer' | 'theme-color' | 'color-scheme' | 'viewport' | 'creator' | 'googlebot' | 'publisher' | 'robots';
|
|
405
|
+
/**
|
|
406
|
+
* @see https://ogp.me/
|
|
407
|
+
*/
|
|
408
|
+
type MetaProperty = 'og:title' | 'og:type' | 'og:image' | 'og:url' | 'og:audio' | 'og:description' | 'og:determiner' | 'og:locale' | 'og:locale:alternate' | 'og:site_name' | 'og:video' | 'og:image:url' | 'og:image:secure_url' | 'og:image:type' | 'og:image:width' | 'og:image:height' | 'og:image:alt';
|
|
384
409
|
interface MetaHTMLAttributes extends HTMLAttributes {
|
|
385
|
-
charset?:
|
|
386
|
-
'http-equiv'?:
|
|
387
|
-
name?:
|
|
410
|
+
charset?: StringLiteralUnion<'utf-8'> | undefined;
|
|
411
|
+
'http-equiv'?: StringLiteralUnion<MetaHttpEquiv> | undefined;
|
|
412
|
+
name?: StringLiteralUnion<MetaName> | undefined;
|
|
388
413
|
media?: string | undefined;
|
|
389
414
|
content?: string | undefined;
|
|
390
|
-
|
|
415
|
+
property?: StringLiteralUnion<MetaProperty> | undefined;
|
|
416
|
+
httpEquiv?: StringLiteralUnion<MetaHttpEquiv> | undefined;
|
|
391
417
|
}
|
|
392
418
|
interface MeterHTMLAttributes extends HTMLAttributes {
|
|
393
419
|
form?: string | undefined;
|
|
@@ -51,4 +51,9 @@ export type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
|
51
51
|
}[keyof BaseType], undefined>;
|
|
52
52
|
export type HasRequiredKeys<BaseType extends object> = RequiredKeysOf<BaseType> extends never ? false : true;
|
|
53
53
|
export type IsAny<T> = boolean extends (T extends never ? true : false) ? true : false;
|
|
54
|
+
/**
|
|
55
|
+
* String literal types with auto-completion
|
|
56
|
+
* @see https://github.com/Microsoft/TypeScript/issues/29729
|
|
57
|
+
*/
|
|
58
|
+
export type StringLiteralUnion<T> = T | (string & Record<never, never>);
|
|
54
59
|
export {};
|
package/dist/utils/html.js
CHANGED
|
@@ -14,13 +14,14 @@ var escapeRe = /[&<>'"]/;
|
|
|
14
14
|
var stringBufferToString = async (buffer, callbacks) => {
|
|
15
15
|
let str = "";
|
|
16
16
|
callbacks ||= [];
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
const resolvedBuffer = await Promise.all(buffer);
|
|
18
|
+
for (let i = resolvedBuffer.length - 1; ; i--) {
|
|
19
|
+
str += resolvedBuffer[i];
|
|
19
20
|
i--;
|
|
20
21
|
if (i < 0) {
|
|
21
22
|
break;
|
|
22
23
|
}
|
|
23
|
-
let r =
|
|
24
|
+
let r = resolvedBuffer[i];
|
|
24
25
|
if (typeof r === "object") {
|
|
25
26
|
callbacks.push(...r.callbacks || []);
|
|
26
27
|
}
|
|
@@ -3,8 +3,8 @@ import { getCookie } from "../helper/cookie/index.js";
|
|
|
3
3
|
import { HTTPException } from "../http-exception.js";
|
|
4
4
|
import { bufferToFormData } from "../utils/buffer.js";
|
|
5
5
|
var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
6
|
-
var multipartRegex = /^multipart\/form-data(
|
|
7
|
-
var urlencodedRegex = /^application\/x-www-form-urlencoded
|
|
6
|
+
var multipartRegex = /^multipart\/form-data(;\s?boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
|
|
7
|
+
var urlencodedRegex = /^application\/x-www-form-urlencoded(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/;
|
|
8
8
|
var validator = (target, validationFunc) => {
|
|
9
9
|
return async (c, next) => {
|
|
10
10
|
let value = {};
|
|
@@ -42,12 +42,13 @@ var validator = (target, validationFunc) => {
|
|
|
42
42
|
const form = {};
|
|
43
43
|
formData.forEach((value2, key) => {
|
|
44
44
|
if (key.endsWith("[]")) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
45
|
+
;
|
|
46
|
+
(form[key] ??= []).push(value2);
|
|
47
|
+
} else if (Array.isArray(form[key])) {
|
|
48
|
+
;
|
|
49
|
+
form[key].push(value2);
|
|
50
|
+
} else if (key in form) {
|
|
51
|
+
form[key] = [form[key], value2];
|
|
51
52
|
} else {
|
|
52
53
|
form[key] = value2;
|
|
53
54
|
}
|