hono 4.5.7 → 4.5.9
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/middleware/csrf/index.js +1 -1
- package/dist/cjs/middleware/pretty-json/index.js +4 -3
- package/dist/cjs/utils/color.js +1 -1
- package/dist/middleware/csrf/index.js +1 -1
- package/dist/middleware/pretty-json/index.js +4 -3
- package/dist/types/jsx/intrinsic-elements.d.ts +13 -6
- package/dist/types/middleware/pretty-json/index.d.ts +14 -6
- package/dist/types/utils/color.d.ts +7 -0
- package/dist/utils/color.js +1 -1
- package/package.json +1 -1
|
@@ -23,7 +23,7 @@ __export(csrf_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(csrf_exports);
|
|
24
24
|
var import_http_exception = require("../../http-exception");
|
|
25
25
|
const isSafeMethodRe = /^(GET|HEAD)$/;
|
|
26
|
-
const isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b
|
|
26
|
+
const isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
27
27
|
const csrf = (options) => {
|
|
28
28
|
const handler = ((optsOrigin) => {
|
|
29
29
|
if (!optsOrigin) {
|
|
@@ -21,13 +21,14 @@ __export(pretty_json_exports, {
|
|
|
21
21
|
prettyJSON: () => prettyJSON
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(pretty_json_exports);
|
|
24
|
-
const prettyJSON = (options
|
|
24
|
+
const prettyJSON = (options) => {
|
|
25
|
+
const targetQuery = options?.query ?? "pretty";
|
|
25
26
|
return async function prettyJSON2(c, next) {
|
|
26
|
-
const pretty = c.req.query(
|
|
27
|
+
const pretty = c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
27
28
|
await next();
|
|
28
29
|
if (pretty && c.res.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
29
30
|
const obj = await c.res.json();
|
|
30
|
-
c.res = new Response(JSON.stringify(obj, null, options
|
|
31
|
+
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
31
32
|
}
|
|
32
33
|
};
|
|
33
34
|
};
|
package/dist/cjs/utils/color.js
CHANGED
|
@@ -23,7 +23,7 @@ __export(color_exports, {
|
|
|
23
23
|
module.exports = __toCommonJS(color_exports);
|
|
24
24
|
function getColorEnabled() {
|
|
25
25
|
const { process, Deno } = globalThis;
|
|
26
|
-
const isNoColor = typeof process !== "undefined" ? "NO_COLOR" in process?.env :
|
|
26
|
+
const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : typeof process !== "undefined" ? "NO_COLOR" in process?.env : false;
|
|
27
27
|
return !isNoColor;
|
|
28
28
|
}
|
|
29
29
|
// Annotate the CommonJS export names for ESM import in node:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/middleware/csrf/index.ts
|
|
2
2
|
import { HTTPException } from "../../http-exception.js";
|
|
3
3
|
var isSafeMethodRe = /^(GET|HEAD)$/;
|
|
4
|
-
var isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b
|
|
4
|
+
var isRequestedByFormElementRe = /^\b(application\/x-www-form-urlencoded|multipart\/form-data|text\/plain)\b/i;
|
|
5
5
|
var csrf = (options) => {
|
|
6
6
|
const handler = ((optsOrigin) => {
|
|
7
7
|
if (!optsOrigin) {
|
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
// src/middleware/pretty-json/index.ts
|
|
2
|
-
var prettyJSON = (options
|
|
2
|
+
var prettyJSON = (options) => {
|
|
3
|
+
const targetQuery = options?.query ?? "pretty";
|
|
3
4
|
return async function prettyJSON2(c, next) {
|
|
4
|
-
const pretty = c.req.query(
|
|
5
|
+
const pretty = c.req.query(targetQuery) || c.req.query(targetQuery) === "";
|
|
5
6
|
await next();
|
|
6
7
|
if (pretty && c.res.headers.get("Content-Type")?.startsWith("application/json")) {
|
|
7
8
|
const obj = await c.res.json();
|
|
8
|
-
c.res = new Response(JSON.stringify(obj, null, options
|
|
9
|
+
c.res = new Response(JSON.stringify(obj, null, options?.space ?? 2), c.res);
|
|
9
10
|
}
|
|
10
11
|
};
|
|
11
12
|
};
|
|
@@ -246,7 +246,7 @@ export declare namespace JSX {
|
|
|
246
246
|
interface EmbedHTMLAttributes extends HTMLAttributes {
|
|
247
247
|
height?: number | string | undefined;
|
|
248
248
|
src?: string | undefined;
|
|
249
|
-
type?:
|
|
249
|
+
type?: StringLiteralUnion<BaseMime> | undefined;
|
|
250
250
|
width?: number | string | undefined;
|
|
251
251
|
}
|
|
252
252
|
interface FieldsetHTMLAttributes extends HTMLAttributes {
|
|
@@ -366,7 +366,7 @@ export declare namespace JSX {
|
|
|
366
366
|
imagesizes?: string | undefined;
|
|
367
367
|
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
368
368
|
sizes?: string | undefined;
|
|
369
|
-
type?:
|
|
369
|
+
type?: StringLiteralUnion<BaseMime> | undefined;
|
|
370
370
|
charSet?: string | undefined;
|
|
371
371
|
rel?: string | undefined;
|
|
372
372
|
precedence?: string | undefined;
|
|
@@ -432,7 +432,7 @@ export declare namespace JSX {
|
|
|
432
432
|
form?: string | undefined;
|
|
433
433
|
height?: number | string | undefined;
|
|
434
434
|
name?: string | undefined;
|
|
435
|
-
type?:
|
|
435
|
+
type?: StringLiteralUnion<BaseMime> | undefined;
|
|
436
436
|
usemap?: string | undefined;
|
|
437
437
|
width?: number | string | undefined;
|
|
438
438
|
}
|
|
@@ -475,7 +475,10 @@ export declare namespace JSX {
|
|
|
475
475
|
nomodule?: boolean | undefined;
|
|
476
476
|
referrerpolicy?: HTMLAttributeReferrerPolicy | undefined;
|
|
477
477
|
src?: string | undefined;
|
|
478
|
-
|
|
478
|
+
/**
|
|
479
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/script/type
|
|
480
|
+
*/
|
|
481
|
+
type?: StringLiteralUnion<'' | 'text/javascript' | 'importmap' | 'module'> | undefined;
|
|
479
482
|
crossOrigin?: CrossOrigin;
|
|
480
483
|
fetchPriority?: string | undefined;
|
|
481
484
|
noModule?: boolean | undefined;
|
|
@@ -494,19 +497,23 @@ export declare namespace JSX {
|
|
|
494
497
|
size?: number | undefined;
|
|
495
498
|
value?: string | ReadonlyArray<string> | number | undefined;
|
|
496
499
|
}
|
|
500
|
+
type MediaMime = BaseMime & (`image/${string}` | `audio/${string}` | `video/${string}`);
|
|
497
501
|
interface SourceHTMLAttributes extends HTMLAttributes {
|
|
498
502
|
height?: number | string | undefined;
|
|
499
503
|
media?: string | undefined;
|
|
500
504
|
sizes?: string | undefined;
|
|
501
505
|
src?: string | undefined;
|
|
502
506
|
srcset?: string | undefined;
|
|
503
|
-
type?:
|
|
507
|
+
type?: StringLiteralUnion<MediaMime> | undefined;
|
|
504
508
|
width?: number | string | undefined;
|
|
505
509
|
}
|
|
506
510
|
interface StyleHTMLAttributes extends HTMLAttributes {
|
|
507
511
|
media?: string | undefined;
|
|
508
512
|
scoped?: boolean | undefined;
|
|
509
|
-
|
|
513
|
+
/**
|
|
514
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/style#type
|
|
515
|
+
*/
|
|
516
|
+
type?: '' | 'text/css' | undefined;
|
|
510
517
|
href?: string | undefined;
|
|
511
518
|
precedence?: string | undefined;
|
|
512
519
|
title?: string | undefined;
|
|
@@ -3,16 +3,24 @@
|
|
|
3
3
|
* Pretty JSON Middleware for Hono.
|
|
4
4
|
*/
|
|
5
5
|
import type { MiddlewareHandler } from '../../types';
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
interface PrettyOptions {
|
|
7
|
+
/**
|
|
8
|
+
* Number of spaces for indentation.
|
|
9
|
+
* @default 2
|
|
10
|
+
*/
|
|
11
|
+
space?: number;
|
|
12
|
+
/**
|
|
13
|
+
* Query conditions for when to Pretty.
|
|
14
|
+
* @default 'pretty'
|
|
15
|
+
*/
|
|
16
|
+
query?: string;
|
|
17
|
+
}
|
|
9
18
|
/**
|
|
10
19
|
* Pretty JSON Middleware for Hono.
|
|
11
20
|
*
|
|
12
21
|
* @see {@link https://hono.dev/docs/middleware/builtin/pretty-json}
|
|
13
22
|
*
|
|
14
|
-
* @param
|
|
15
|
-
* @param {number} [options.space=2] - Number of spaces for indentation.
|
|
23
|
+
* @param options - The options for the pretty JSON middleware.
|
|
16
24
|
* @returns {MiddlewareHandler} The middleware handler function.
|
|
17
25
|
*
|
|
18
26
|
* @example
|
|
@@ -25,5 +33,5 @@ type prettyOptions = {
|
|
|
25
33
|
* })
|
|
26
34
|
* ```
|
|
27
35
|
*/
|
|
28
|
-
export declare const prettyJSON: (options?:
|
|
36
|
+
export declare const prettyJSON: (options?: PrettyOptions) => MiddlewareHandler;
|
|
29
37
|
export {};
|
|
@@ -2,4 +2,11 @@
|
|
|
2
2
|
* @module
|
|
3
3
|
* Color utility.
|
|
4
4
|
*/
|
|
5
|
+
/**
|
|
6
|
+
* Get whether color change on terminal is enabled or disabled.
|
|
7
|
+
* If `NO_COLOR` environment variable is set, this function returns `false`.
|
|
8
|
+
* @see {@link https://no-color.org/}
|
|
9
|
+
*
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
5
12
|
export declare function getColorEnabled(): boolean;
|
package/dist/utils/color.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// src/utils/color.ts
|
|
2
2
|
function getColorEnabled() {
|
|
3
3
|
const { process, Deno } = globalThis;
|
|
4
|
-
const isNoColor = typeof process !== "undefined" ? "NO_COLOR" in process?.env :
|
|
4
|
+
const isNoColor = typeof Deno?.noColor === "boolean" ? Deno.noColor : typeof process !== "undefined" ? "NO_COLOR" in process?.env : false;
|
|
5
5
|
return !isNoColor;
|
|
6
6
|
}
|
|
7
7
|
export {
|