Comparing version 4.0.4 to 4.0.5
@@ -38,7 +38,6 @@ "use strict"; | ||
const generateFilePath = (routePath, outDir, mimeType) => { | ||
const hasExtension = /\.[^\/]+$/.test(routePath); | ||
if (hasExtension) { | ||
const extension = determineExtension(mimeType); | ||
if (routePath.endsWith(`.${extension}`)) { | ||
return (0, import_utils2.joinPaths)(outDir, routePath); | ||
} | ||
const extension = determineExtension(mimeType); | ||
if (routePath === "/") { | ||
@@ -45,0 +44,0 @@ return (0, import_utils2.joinPaths)(outDir, `index.${extension}`); |
@@ -30,2 +30,3 @@ "use strict"; | ||
var import_hooks = require("../hooks"); | ||
var import__ = require("."); | ||
const eventAliasMap = { | ||
@@ -35,3 +36,8 @@ Change: "Input", | ||
}; | ||
const nameSpaceMap = { | ||
svg: "http://www.w3.org/2000/svg", | ||
math: "http://www.w3.org/1998/Math/MathML" | ||
}; | ||
const buildDataStack = []; | ||
let nameSpaceContext = void 0; | ||
const isNodeString = (node) => Array.isArray(node); | ||
@@ -210,3 +216,3 @@ const getEventSpec = (key) => { | ||
} else { | ||
el = child.e || (child.e = document.createElement(child.tag)); | ||
el = child.e || (child.e = child.n ? document.createElementNS(child.n, child.tag) : document.createElement(child.tag)); | ||
applyProps(el, child.props, child.pP); | ||
@@ -272,2 +278,7 @@ applyNode(child, el); | ||
} | ||
} else if (!isNodeString(child) && nameSpaceContext) { | ||
const ns = (0, import__.useContext)(nameSpaceContext); | ||
if (ns) { | ||
child.n = ns; | ||
} | ||
} | ||
@@ -310,2 +321,18 @@ if (!isNodeString(child)) { | ||
node[import_constants.DOM_STASH] = [0, []]; | ||
} else { | ||
const ns = nameSpaceMap[node.tag]; | ||
if (ns) { | ||
; | ||
node.n = ns; | ||
nameSpaceContext || (nameSpaceContext = (0, import__.createContext)("")); | ||
node.children = [ | ||
{ | ||
tag: nameSpaceContext.Provider, | ||
props: { | ||
value: ns | ||
}, | ||
children: node.children | ||
} | ||
]; | ||
} | ||
} | ||
@@ -312,0 +339,0 @@ return node; |
@@ -9,7 +9,6 @@ // src/helper/ssg/index.ts | ||
var generateFilePath = (routePath, outDir, mimeType) => { | ||
const hasExtension = /\.[^\/]+$/.test(routePath); | ||
if (hasExtension) { | ||
const extension = determineExtension(mimeType); | ||
if (routePath.endsWith(`.${extension}`)) { | ||
return joinPaths(outDir, routePath); | ||
} | ||
const extension = determineExtension(mimeType); | ||
if (routePath === "/") { | ||
@@ -16,0 +15,0 @@ return joinPaths(outDir, `index.${extension}`); |
@@ -5,2 +5,3 @@ // src/jsx/dom/render.ts | ||
import { STASH_EFFECT } from "../hooks/index.js"; | ||
import { useContext, createContext } from "./index.js"; | ||
var eventAliasMap = { | ||
@@ -10,3 +11,8 @@ Change: "Input", | ||
}; | ||
var nameSpaceMap = { | ||
svg: "http://www.w3.org/2000/svg", | ||
math: "http://www.w3.org/1998/Math/MathML" | ||
}; | ||
var buildDataStack = []; | ||
var nameSpaceContext = void 0; | ||
var isNodeString = (node) => Array.isArray(node); | ||
@@ -185,3 +191,3 @@ var getEventSpec = (key) => { | ||
} else { | ||
el = child.e || (child.e = document.createElement(child.tag)); | ||
el = child.e || (child.e = child.n ? document.createElementNS(child.n, child.tag) : document.createElement(child.tag)); | ||
applyProps(el, child.props, child.pP); | ||
@@ -247,2 +253,7 @@ applyNode(child, el); | ||
} | ||
} else if (!isNodeString(child) && nameSpaceContext) { | ||
const ns = useContext(nameSpaceContext); | ||
if (ns) { | ||
child.n = ns; | ||
} | ||
} | ||
@@ -285,2 +296,18 @@ if (!isNodeString(child)) { | ||
node[DOM_STASH] = [0, []]; | ||
} else { | ||
const ns = nameSpaceMap[node.tag]; | ||
if (ns) { | ||
; | ||
node.n = ns; | ||
nameSpaceContext || (nameSpaceContext = createContext("")); | ||
node.children = [ | ||
{ | ||
tag: nameSpaceContext.Provider, | ||
props: { | ||
value: ns | ||
}, | ||
children: node.children | ||
} | ||
]; | ||
} | ||
} | ||
@@ -287,0 +314,0 @@ return node; |
@@ -1,3 +0,1 @@ | ||
import type { FC } from './jsx'; | ||
import type { PropsForRenderer } from './middleware/jsx-renderer'; | ||
import type { HonoRequest } from './request'; | ||
@@ -21,2 +19,4 @@ import type { Env, FetchEventLike, NotFoundHandler, Input, TypedResponse } from './types'; | ||
export type Renderer = ContextRenderer extends Function ? ContextRenderer : DefaultRenderer; | ||
export type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown; | ||
export type Layout<T = Record<string, any>> = (props: T) => any; | ||
interface Get<E extends Env> { | ||
@@ -116,9 +116,9 @@ <Key extends keyof ContextVariableMap>(key: Key): ContextVariableMap[Key]; | ||
render: Renderer; | ||
setLayout: (layout: FC<PropsForRenderer & { | ||
Layout: FC; | ||
}>) => FC<{ | ||
Layout: FC; | ||
setLayout: (layout: Layout<PropsForRenderer & { | ||
Layout: Layout; | ||
}>) => Layout<{ | ||
Layout: Layout; | ||
}>; | ||
getLayout: () => FC<{ | ||
Layout: FC; | ||
getLayout: () => Layout<{ | ||
Layout: Layout; | ||
}> | undefined; | ||
@@ -125,0 +125,0 @@ /** |
@@ -11,2 +11,3 @@ import type { JSXNode } from '../base'; | ||
type LocalJSXContexts = [JSXContext<unknown>, unknown][] | undefined; | ||
type SupportedElement = HTMLElement | SVGElement | MathMLElement; | ||
export type NodeObject = { | ||
@@ -18,4 +19,5 @@ pP: Props | undefined; | ||
s?: Node[]; | ||
n?: string; | ||
c: Container | undefined; | ||
e: HTMLElement | Text | undefined; | ||
e: SupportedElement | Text | undefined; | ||
[DOM_STASH]: [ | ||
@@ -22,0 +24,0 @@ number, |
@@ -1,6 +0,5 @@ | ||
import type { Context, Renderer } from '../../context'; | ||
import type { Context, PropsForRenderer } from '../../context'; | ||
import type { FC, PropsWithChildren } from '../../jsx'; | ||
import type { Env, Input, MiddlewareHandler } from '../../types'; | ||
export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>; | ||
export type PropsForRenderer = [...Required<Parameters<Renderer>>] extends [unknown, infer Props] ? Props : unknown; | ||
type RendererOptions = { | ||
@@ -7,0 +6,0 @@ docType?: boolean | string; |
{ | ||
"name": "hono", | ||
"version": "4.0.4", | ||
"version": "4.0.5", | ||
"description": "Ultrafast web framework for the Edges", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
696098
19141