hono 3.9.0-rc.1 → 3.9.1
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/helper/adapter/index.js +2 -2
- package/dist/cjs/middleware/jsx-renderer/index.js +12 -9
- package/dist/helper/adapter/index.js +2 -2
- package/dist/middleware/jsx-renderer/index.js +12 -9
- package/dist/types/context.d.ts +1 -1
- package/dist/types/helper/adapter/index.d.ts +2 -1
- package/dist/types/middleware/jsx-renderer/index.d.ts +4 -1
- package/package.json +7 -1
|
@@ -22,10 +22,10 @@ __export(adapter_exports, {
|
|
|
22
22
|
getRuntimeKey: () => getRuntimeKey
|
|
23
23
|
});
|
|
24
24
|
module.exports = __toCommonJS(adapter_exports);
|
|
25
|
-
const env = (c) => {
|
|
25
|
+
const env = (c, runtime) => {
|
|
26
26
|
const global = globalThis;
|
|
27
27
|
const globalEnv = global?.process?.env;
|
|
28
|
-
|
|
28
|
+
runtime ?? (runtime = getRuntimeKey());
|
|
29
29
|
const runtimeEnvHandlers = {
|
|
30
30
|
bun: () => globalEnv,
|
|
31
31
|
node: () => globalEnv,
|
|
@@ -25,15 +25,18 @@ __export(jsx_renderer_exports, {
|
|
|
25
25
|
module.exports = __toCommonJS(jsx_renderer_exports);
|
|
26
26
|
var import_jsx = require("../../jsx");
|
|
27
27
|
const RequestContext = (0, import_jsx.createContext)(null);
|
|
28
|
-
const createRenderer = (c, component) => (children, props) =>
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
)
|
|
35
|
-
|
|
36
|
-
|
|
28
|
+
const createRenderer = (c, component, options) => (children, props) => {
|
|
29
|
+
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === true ? "<!DOCTYPE html>" : "";
|
|
30
|
+
return c.html(
|
|
31
|
+
docType + (0, import_jsx.jsx)(
|
|
32
|
+
RequestContext.Provider,
|
|
33
|
+
{ value: c },
|
|
34
|
+
component ? component({ children, ...props || {} }) : children
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
};
|
|
38
|
+
const jsxRenderer = (component, options) => (c, next) => {
|
|
39
|
+
c.setRenderer(createRenderer(c, component, options));
|
|
37
40
|
return next();
|
|
38
41
|
};
|
|
39
42
|
const useRequestContext = () => {
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
// src/helper/adapter/index.ts
|
|
2
|
-
var env = (c) => {
|
|
2
|
+
var env = (c, runtime) => {
|
|
3
3
|
const global = globalThis;
|
|
4
4
|
const globalEnv = global?.process?.env;
|
|
5
|
-
|
|
5
|
+
runtime ?? (runtime = getRuntimeKey());
|
|
6
6
|
const runtimeEnvHandlers = {
|
|
7
7
|
bun: () => globalEnv,
|
|
8
8
|
node: () => globalEnv,
|
|
@@ -1,15 +1,18 @@
|
|
|
1
1
|
// src/middleware/jsx-renderer/index.ts
|
|
2
2
|
import { jsx, createContext, useContext } from "../../jsx/index.js";
|
|
3
3
|
var RequestContext = createContext(null);
|
|
4
|
-
var createRenderer = (c, component) => (children, props) =>
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
)
|
|
11
|
-
|
|
12
|
-
|
|
4
|
+
var createRenderer = (c, component, options) => (children, props) => {
|
|
5
|
+
const docType = typeof options?.docType === "string" ? options.docType : options?.docType === true ? "<!DOCTYPE html>" : "";
|
|
6
|
+
return c.html(
|
|
7
|
+
docType + jsx(
|
|
8
|
+
RequestContext.Provider,
|
|
9
|
+
{ value: c },
|
|
10
|
+
component ? component({ children, ...props || {} }) : children
|
|
11
|
+
)
|
|
12
|
+
);
|
|
13
|
+
};
|
|
14
|
+
var jsxRenderer = (component, options) => (c, next) => {
|
|
15
|
+
c.setRenderer(createRenderer(c, component, options));
|
|
13
16
|
return next();
|
|
14
17
|
};
|
|
15
18
|
var useRequestContext = () => {
|
package/dist/types/context.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
+
import type { Runtime } from './helper/adapter';
|
|
1
2
|
import type { HonoRequest } from './request';
|
|
2
3
|
import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types';
|
|
3
4
|
import type { CookieOptions } from './utils/cookie';
|
|
4
5
|
import type { StatusCode } from './utils/http-status';
|
|
5
6
|
import { StreamingApi } from './utils/stream';
|
|
6
7
|
import type { JSONValue, InterfaceToType } from './utils/types';
|
|
7
|
-
declare type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other';
|
|
8
8
|
declare type HeaderRecord = Record<string, string | string[]>;
|
|
9
9
|
declare type Data = string | ArrayBuffer | ReadableStream;
|
|
10
10
|
export interface ExecutionContext {
|
|
@@ -1,3 +1,4 @@
|
|
|
1
1
|
import type { Context } from '../../context';
|
|
2
|
-
export declare
|
|
2
|
+
export declare type Runtime = 'node' | 'deno' | 'bun' | 'workerd' | 'fastly' | 'edge-light' | 'lagon' | 'other';
|
|
3
|
+
export declare const env: <T extends Record<string, string>, C extends Context<any, any, {}> = Context<{}, any, {}>>(c: C, runtime?: Runtime) => T & C["env"];
|
|
3
4
|
export declare const getRuntimeKey: () => "other" | "node" | "deno" | "bun" | "workerd" | "fastly" | "edge-light" | "lagon";
|
|
@@ -3,6 +3,9 @@ import type { FC } from '../../jsx';
|
|
|
3
3
|
import type { Env, Input, MiddlewareHandler } from '../../types';
|
|
4
4
|
export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>;
|
|
5
5
|
declare type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown;
|
|
6
|
-
|
|
6
|
+
declare type RendererOptions = {
|
|
7
|
+
docType?: boolean | string;
|
|
8
|
+
};
|
|
9
|
+
export declare const jsxRenderer: (component?: FC<PropsForRenderer>, options?: RendererOptions) => MiddlewareHandler;
|
|
7
10
|
export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>;
|
|
8
11
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hono",
|
|
3
|
-
"version": "3.9.
|
|
3
|
+
"version": "3.9.1",
|
|
4
4
|
"description": "Ultrafast web framework for the Edges",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"type": "module",
|
|
@@ -262,6 +262,12 @@
|
|
|
262
262
|
},
|
|
263
263
|
"typesVersions": {
|
|
264
264
|
"*": {
|
|
265
|
+
"types": [
|
|
266
|
+
"./dist/types/types"
|
|
267
|
+
],
|
|
268
|
+
"hono-base": [
|
|
269
|
+
"./dist/types/hono-base"
|
|
270
|
+
],
|
|
265
271
|
"tiny": [
|
|
266
272
|
"./dist/types/preset/tiny"
|
|
267
273
|
],
|