Comparing version 4.5.2 to 4.5.3
// src/adapter/service-worker/handler.ts | ||
var handle = (app, opts = { | ||
fetch | ||
fetch: globalThis.self !== void 0 ? globalThis.self.fetch : fetch | ||
}) => { | ||
@@ -5,0 +5,0 @@ return (evt) => { |
@@ -25,3 +25,3 @@ "use strict"; | ||
const handle = (app, opts = { | ||
fetch | ||
fetch: globalThis.self !== void 0 ? globalThis.self.fetch : fetch | ||
}) => { | ||
@@ -28,0 +28,0 @@ return (evt) => { |
@@ -31,2 +31,3 @@ "use strict"; | ||
cloneElement: () => cloneElement, | ||
getNameSpaceContext: () => getNameSpaceContext, | ||
isValidElement: () => isValidElement, | ||
@@ -46,2 +47,7 @@ jsx: () => jsx, | ||
var import_common = require("./intrinsic-element/common"); | ||
let nameSpaceContext = void 0; | ||
const getNameSpaceContext = () => nameSpaceContext; | ||
const toSVGAttributeName = (key) => /[A-Z]/.test(key) && key.match( | ||
/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/ | ||
) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key; | ||
const emptyTags = [ | ||
@@ -148,4 +154,5 @@ "area", | ||
buffer[0] += `<${tag}`; | ||
const normalizeKey = nameSpaceContext && (0, import_context.useContext)(nameSpaceContext) === "svg" ? (key) => toSVGAttributeName((0, import_utils.normalizeIntrinsicElementKey)(key)) : (key) => (0, import_utils.normalizeIntrinsicElementKey)(key); | ||
for (let [key, v] of Object.entries(props)) { | ||
key = (0, import_utils.normalizeIntrinsicElementKey)(key); | ||
key = normalizeKey(key); | ||
if (key === "children") { | ||
@@ -268,2 +275,13 @@ } else if (key === "style" && typeof v === "object") { | ||
); | ||
} else if (tag === "svg") { | ||
nameSpaceContext ||= (0, import_context.createContext)(""); | ||
return new JSXNode(tag, props, [ | ||
new JSXFunctionNode( | ||
nameSpaceContext, | ||
{ | ||
value: tag | ||
}, | ||
children | ||
) | ||
]); | ||
} else { | ||
@@ -330,2 +348,3 @@ return new JSXNode(tag, props, children); | ||
cloneElement, | ||
getNameSpaceContext, | ||
isValidElement, | ||
@@ -332,0 +351,0 @@ jsx, |
@@ -190,18 +190,3 @@ "use strict"; | ||
const findInsertBefore = (node) => { | ||
if (!node) { | ||
return null; | ||
} else if (node.tag === HONO_PORTAL_ELEMENT) { | ||
return findInsertBefore(node.nN); | ||
} else if (node.e) { | ||
return node.e; | ||
} | ||
if (node.vC) { | ||
for (let i = 0, len = node.vC.length; i < len; i++) { | ||
const e = findInsertBefore(node.vC[i]); | ||
if (e) { | ||
return e; | ||
} | ||
} | ||
} | ||
return findInsertBefore(node.nN); | ||
return !node ? null : node.tag === HONO_PORTAL_ELEMENT ? findInsertBefore(node.nN) : node.e || node.vC && node.pP && findInsertBefore(node.vC[0]) || findInsertBefore(node.nN); | ||
}; | ||
@@ -208,0 +193,0 @@ const removeNode = (node) => { |
@@ -32,2 +32,3 @@ "use strict"; | ||
var import_base = require("../base"); | ||
var import_context = require("../context"); | ||
var import_html = require("../../helper/html"); | ||
@@ -109,2 +110,6 @@ var import_common = require("./common"); | ||
const title = ({ children, ...props }) => { | ||
const nameSpaceContext = (0, import_base.getNameSpaceContext)(); | ||
if (nameSpaceContext && (0, import_context.useContext)(nameSpaceContext) === "svg") { | ||
new import_base.JSXNode("title", props, (0, import_children.toArray)(children ?? [])); | ||
} | ||
return documentMetadataTag("title", children, props, false); | ||
@@ -111,0 +116,0 @@ }; |
@@ -27,4 +27,4 @@ "use strict"; | ||
var import_buffer = require("../utils/buffer"); | ||
const jsonRegex = /^application\/([a-z-\.]+\+)?json$/; | ||
const multipartRegex = /^multipart\/form-data(; boundary=[A-Za-z0-9'()+_,\-./:=?]+)?$/; | ||
const jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
const multipartRegex = /^multipart\/form-data(; boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/; | ||
const urlencodedRegex = /^application\/x-www-form-urlencoded$/; | ||
@@ -31,0 +31,0 @@ const validator = (target, validationFunc) => { |
// src/jsx/base.ts | ||
import { raw } from "../helper/html/index.js"; | ||
import { escapeToBuffer, resolveCallbackSync, stringBufferToString } from "../utils/html.js"; | ||
import { globalContexts } from "./context.js"; | ||
import { createContext, globalContexts, useContext } from "./context.js"; | ||
import { DOM_RENDERER } from "./constants.js"; | ||
@@ -9,2 +9,7 @@ import { normalizeIntrinsicElementKey, styleObjectForEach } from "./utils.js"; | ||
import { domRenderers } from "./intrinsic-element/common.js"; | ||
var nameSpaceContext = void 0; | ||
var getNameSpaceContext = () => nameSpaceContext; | ||
var toSVGAttributeName = (key) => /[A-Z]/.test(key) && key.match( | ||
/^(?:al|basel|clip(?:Path|Rule)$|co|do|fill|fl|fo|gl|let|lig|i|marker[EMS]|o|pai|pointe|sh|st[or]|text[^L]|tr|u|ve|w)/ | ||
) ? key.replace(/([A-Z])/g, "-$1").toLowerCase() : key; | ||
var emptyTags = [ | ||
@@ -111,4 +116,5 @@ "area", | ||
buffer[0] += `<${tag}`; | ||
const normalizeKey = nameSpaceContext && useContext(nameSpaceContext) === "svg" ? (key) => toSVGAttributeName(normalizeIntrinsicElementKey(key)) : (key) => normalizeIntrinsicElementKey(key); | ||
for (let [key, v] of Object.entries(props)) { | ||
key = normalizeIntrinsicElementKey(key); | ||
key = normalizeKey(key); | ||
if (key === "children") { | ||
@@ -231,2 +237,13 @@ } else if (key === "style" && typeof v === "object") { | ||
); | ||
} else if (tag === "svg") { | ||
nameSpaceContext ||= createContext(""); | ||
return new JSXNode(tag, props, [ | ||
new JSXFunctionNode( | ||
nameSpaceContext, | ||
{ | ||
value: tag | ||
}, | ||
children | ||
) | ||
]); | ||
} else { | ||
@@ -292,2 +309,3 @@ return new JSXNode(tag, props, children); | ||
cloneElement, | ||
getNameSpaceContext, | ||
isValidElement, | ||
@@ -294,0 +312,0 @@ jsx, |
@@ -160,18 +160,3 @@ // src/jsx/dom/render.ts | ||
var findInsertBefore = (node) => { | ||
if (!node) { | ||
return null; | ||
} else if (node.tag === HONO_PORTAL_ELEMENT) { | ||
return findInsertBefore(node.nN); | ||
} else if (node.e) { | ||
return node.e; | ||
} | ||
if (node.vC) { | ||
for (let i = 0, len = node.vC.length; i < len; i++) { | ||
const e = findInsertBefore(node.vC[i]); | ||
if (e) { | ||
return e; | ||
} | ||
} | ||
} | ||
return findInsertBefore(node.nN); | ||
return !node ? null : node.tag === HONO_PORTAL_ELEMENT ? findInsertBefore(node.nN) : node.e || node.vC && node.pP && findInsertBefore(node.vC[0]) || findInsertBefore(node.nN); | ||
}; | ||
@@ -178,0 +163,0 @@ var removeNode = (node) => { |
// src/jsx/intrinsic-element/components.ts | ||
import { JSXNode } from "../base.js"; | ||
import { JSXNode, getNameSpaceContext } from "../base.js"; | ||
import { useContext } from "../context.js"; | ||
import { raw } from "../../helper/html/index.js"; | ||
@@ -79,2 +80,6 @@ import { dataPrecedenceAttr, deDupeKeyMap } from "./common.js"; | ||
var title = ({ children, ...props }) => { | ||
const nameSpaceContext = getNameSpaceContext(); | ||
if (nameSpaceContext && useContext(nameSpaceContext) === "svg") { | ||
new JSXNode("title", props, toArray(children ?? [])); | ||
} | ||
return documentMetadataTag("title", children, props, false); | ||
@@ -81,0 +86,0 @@ }; |
@@ -20,2 +20,3 @@ import type { HtmlEscaped, HtmlEscapedString, StringBufferWithCallbacks } from '../utils/html'; | ||
} | ||
export declare const getNameSpaceContext: () => Context<string> | undefined; | ||
type LocalContexts = [Context<unknown>, unknown][]; | ||
@@ -22,0 +23,0 @@ export type Child = string | Promise<string> | number | JSXNode | null | undefined | boolean | Child[]; |
@@ -5,4 +5,4 @@ // src/validator/validator.ts | ||
import { bufferToFormData } from "../utils/buffer.js"; | ||
var jsonRegex = /^application\/([a-z-\.]+\+)?json$/; | ||
var multipartRegex = /^multipart\/form-data(; boundary=[A-Za-z0-9'()+_,\-./:=?]+)?$/; | ||
var jsonRegex = /^application\/([a-z-\.]+\+)?json(;\s*[a-zA-Z0-9\-]+\=([^;]+))*$/; | ||
var multipartRegex = /^multipart\/form-data(; boundary=[a-zA-Z0-9'"()+_,\-./:=?]+)?$/; | ||
var urlencodedRegex = /^application\/x-www-form-urlencoded$/; | ||
@@ -9,0 +9,0 @@ var validator = (target, validationFunc) => { |
{ | ||
"name": "hono", | ||
"version": "4.5.2", | ||
"version": "4.5.3", | ||
"description": "Web framework built on Web Standards", | ||
@@ -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
999668
28392