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.
@@ -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
  };
@@ -172,13 +172,14 @@ var useState = (initialState) => {
172
172
  ];
173
173
  };
174
174
  var useReducer = (reducer, initialArg, init) => {
175
- const [state, setState] = useState(() => init ? init(initialArg) : initialArg);
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,7 +1 @@
1
- import type { JSXNode, Props } from '../base';
2
1
  export declare const setInternalTagFlag: (fn: Function) => Function;
3
- export declare const newJSXNode: (obj: {
4
- tag: string | Function;
5
- props?: Props;
6
- key?: string;
7
- }) => JSXNode;
@@ -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' | string;
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?: string | undefined;
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?: string | undefined;
201
+ target?: HTMLAttributeAnchorTarget | undefined;
200
202
  }
201
203
  interface BaseHTMLAttributes extends HTMLAttributes {
202
204
  href?: string | undefined;
203
- target?: string | undefined;
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?: string | undefined;
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?: string | undefined;
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' | string;
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?: string | undefined;
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?: string | undefined;
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?: string | undefined;
386
- 'http-equiv'?: string | undefined;
387
- name?: string | undefined;
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
- httpEquiv?: string | undefined;
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 {};
@@ -14,13 +14,14 @@ var escapeRe = /[&<>'"]/;
14
14
  var stringBufferToString = async (buffer, callbacks) => {
15
15
  let str = "";
16
16
  callbacks ||= [];
17
- for (let i = buffer.length - 1; ; i--) {
18
- str += buffer[i];
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 = await buffer[i];
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(; boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/;
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
- if (form[key] === void 0) {
46
- form[key] = [value2];
47
- } else if (Array.isArray(form[key])) {
48
- ;
49
- form[key].push(value2);
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
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "hono",
3
- "version": "4.5.5",
3
+ "version": "4.5.7",
4
4
  "description": "Web framework built on Web Standards",
5
5
  "main": "dist/cjs/index.js",
6
6
  "type": "module",