Comparing version 4.0.0-rc.4 to 4.0.0
@@ -27,2 +27,2 @@ "use strict"; | ||
__reExport(helper_exports, require("./helper/dev"), module.exports); | ||
__reExport(helper_exports, require("./helper/ssg"), module.exports); | ||
__reExport(helper_exports, require("./adapter/deno/ssg"), module.exports); |
@@ -27,5 +27,5 @@ "use strict"; | ||
var import_html = require("../helper/html"); | ||
var import_base = require("./base"); | ||
var import_constants = require("./constants"); | ||
var import_context = require("./dom/context"); | ||
var import__ = require("."); | ||
const globalContexts = []; | ||
@@ -40,3 +40,3 @@ const createContext = (defaultValue) => { | ||
try { | ||
string = props.children ? (Array.isArray(props.children) ? new import__.JSXFragmentNode("", {}, props.children) : props.children).toString() : ""; | ||
string = props.children ? (Array.isArray(props.children) ? new import_base.JSXFragmentNode("", {}, props.children) : props.children).toString() : ""; | ||
} finally { | ||
@@ -43,0 +43,0 @@ values.pop(); |
@@ -38,3 +38,6 @@ "use strict"; | ||
}; | ||
const Suspense = ({ children, fallback }) => { | ||
const Suspense = ({ | ||
children, | ||
fallback | ||
}) => { | ||
const res = (0, import_jsx_runtime.Fragment)({ children }); | ||
@@ -41,0 +44,0 @@ res[import_constants.DOM_ERROR_HANDLER] = (err, retry) => { |
@@ -25,4 +25,4 @@ "use strict"; | ||
createContext: () => import_context2.createContext, | ||
isValidElement: () => import__.isValidElement, | ||
memo: () => import__.memo, | ||
isValidElement: () => import_base.isValidElement, | ||
memo: () => import_base.memo, | ||
render: () => import_render.render, | ||
@@ -49,3 +49,3 @@ startTransition: () => import_hooks.startTransition, | ||
var import_context2 = require("./context"); | ||
var import__ = require(".."); | ||
var import_base = require("../base"); | ||
var import_jsx_runtime = require("./jsx-runtime"); | ||
@@ -52,0 +52,0 @@ const cloneElement = (element, props, ...children) => { |
@@ -25,5 +25,14 @@ "use strict"; | ||
module.exports = __toCommonJS(jsx_dev_runtime_exports); | ||
var import_utils = require("../utils"); | ||
const jsxDEV = (tag, props, key) => { | ||
const children = "children" in props ? props.children : []; | ||
delete props["children"]; | ||
if (typeof tag === "string") { | ||
(0, import_utils.normalizeIntrinsicElementProps)(props); | ||
} | ||
let children; | ||
if (props && "children" in props) { | ||
children = props.children; | ||
delete props["children"]; | ||
} else { | ||
children = []; | ||
} | ||
return { | ||
@@ -30,0 +39,0 @@ tag, |
@@ -31,6 +31,15 @@ "use strict"; | ||
const eventAliasMap = { | ||
change: "input" | ||
Change: "Input", | ||
DoubleClick: "DblClick" | ||
}; | ||
const buildDataStack = []; | ||
const isNodeString = (node) => Array.isArray(node); | ||
const getEventSpec = (key) => { | ||
const match = key.match(/^on([A-Z][a-zA-Z]+?)((?<!Pointer)Capture)?$/); | ||
if (match) { | ||
const [, eventName, capture] = match; | ||
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture]; | ||
} | ||
return void 0; | ||
}; | ||
const applyProps = (container, attributes, oldAttributes) => { | ||
@@ -40,3 +49,12 @@ attributes || (attributes = {}); | ||
if (!oldAttributes || oldAttributes[key] !== value) { | ||
if (key === "dangerouslySetInnerHTML" && value) { | ||
const eventSpec = getEventSpec(key); | ||
if (eventSpec) { | ||
if (typeof value !== "function") { | ||
throw new Error(`Event handler for "${key}" is not a function`); | ||
} | ||
if (oldAttributes) { | ||
container.removeEventListener(eventSpec[0], oldAttributes[key], eventSpec[1]); | ||
} | ||
container.addEventListener(eventSpec[0], value, eventSpec[1]); | ||
} else if (key === "dangerouslySetInnerHTML" && value) { | ||
container.innerHTML = value.__html; | ||
@@ -49,9 +67,2 @@ } else if (key === "ref") { | ||
} | ||
} else if (key.startsWith("on") && typeof value === "function") { | ||
const jsxEventName = key.slice(2).toLowerCase(); | ||
const eventName = eventAliasMap[jsxEventName] || jsxEventName; | ||
if (oldAttributes) { | ||
container.removeEventListener(eventName, oldAttributes[key]); | ||
} | ||
container.addEventListener(eventName, value); | ||
} else if (key === "style") { | ||
@@ -80,3 +91,6 @@ if (typeof value === "string") { | ||
if (!(key in attributes)) { | ||
if (key === "ref") { | ||
const eventSpec = getEventSpec(key); | ||
if (eventSpec) { | ||
container.removeEventListener(eventSpec[0], value, eventSpec[1]); | ||
} else if (key === "ref") { | ||
if (typeof value === "function") { | ||
@@ -87,5 +101,2 @@ value(null); | ||
} | ||
} else if (key.startsWith("on")) { | ||
const eventName = key.slice(2).toLowerCase(); | ||
container.removeEventListener(eventName, value); | ||
} else { | ||
@@ -92,0 +103,0 @@ container.removeAttribute(key); |
@@ -18,2 +18,3 @@ "use strict"; | ||
}; | ||
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default")); | ||
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod); | ||
@@ -23,12 +24,9 @@ var jsx_exports = {}; | ||
ErrorBoundary: () => import_components.ErrorBoundary, | ||
Fragment: () => Fragment, | ||
JSXFragmentNode: () => JSXFragmentNode, | ||
JSXNode: () => JSXNode, | ||
Fragment: () => import_base.Fragment, | ||
Suspense: () => import_streaming.Suspense, | ||
cloneElement: () => cloneElement, | ||
createContext: () => import_context2.createContext, | ||
isValidElement: () => isValidElement, | ||
jsx: () => jsx, | ||
jsxFn: () => jsxFn, | ||
memo: () => memo, | ||
cloneElement: () => import_base.cloneElement, | ||
createContext: () => import_context.createContext, | ||
isValidElement: () => import_base.isValidElement, | ||
jsx: () => import_base.jsx, | ||
memo: () => import_base.memo, | ||
startTransition: () => import_hooks.startTransition, | ||
@@ -38,3 +36,3 @@ startViewTransition: () => import_hooks.startViewTransition, | ||
useCallback: () => import_hooks.useCallback, | ||
useContext: () => import_context2.useContext, | ||
useContext: () => import_context.useContext, | ||
useDeferredValue: () => import_hooks.useDeferredValue, | ||
@@ -50,243 +48,8 @@ useEffect: () => import_hooks.useEffect, | ||
module.exports = __toCommonJS(jsx_exports); | ||
var import_html = require("../helper/html"); | ||
var import_html2 = require("../utils/html"); | ||
var import_context = require("./context"); | ||
var import_base = require("./base"); | ||
var import_components = require("./components"); | ||
var import_streaming = require("./streaming"); | ||
var import_hooks = require("./hooks"); | ||
var import_context2 = require("./context"); | ||
const emptyTags = [ | ||
"area", | ||
"base", | ||
"br", | ||
"col", | ||
"embed", | ||
"hr", | ||
"img", | ||
"input", | ||
"keygen", | ||
"link", | ||
"meta", | ||
"param", | ||
"source", | ||
"track", | ||
"wbr" | ||
]; | ||
const booleanAttributes = [ | ||
"allowfullscreen", | ||
"async", | ||
"autofocus", | ||
"autoplay", | ||
"checked", | ||
"controls", | ||
"default", | ||
"defer", | ||
"disabled", | ||
"formnovalidate", | ||
"hidden", | ||
"inert", | ||
"ismap", | ||
"itemscope", | ||
"loop", | ||
"multiple", | ||
"muted", | ||
"nomodule", | ||
"novalidate", | ||
"open", | ||
"playsinline", | ||
"readonly", | ||
"required", | ||
"reversed", | ||
"selected" | ||
]; | ||
const childrenToStringToBuffer = (children, buffer) => { | ||
for (let i = 0, len = children.length; i < len; i++) { | ||
const child = children[i]; | ||
if (typeof child === "string") { | ||
(0, import_html2.escapeToBuffer)(child, buffer); | ||
} else if (typeof child === "boolean" || child === null || child === void 0) { | ||
continue; | ||
} else if (child instanceof JSXNode) { | ||
child.toStringToBuffer(buffer); | ||
} else if (typeof child === "number" || child.isEscaped) { | ||
; | ||
buffer[0] += child; | ||
} else if (child instanceof Promise) { | ||
buffer.unshift("", child); | ||
} else { | ||
childrenToStringToBuffer(child, buffer); | ||
} | ||
} | ||
}; | ||
class JSXNode { | ||
constructor(tag, props, children) { | ||
this.isEscaped = true; | ||
this.tag = tag; | ||
this.props = props; | ||
this.children = children; | ||
} | ||
toString() { | ||
const buffer = [""]; | ||
this.localContexts?.forEach(([context, value]) => { | ||
context.values.push(value); | ||
}); | ||
try { | ||
this.toStringToBuffer(buffer); | ||
} finally { | ||
this.localContexts?.forEach(([context]) => { | ||
context.values.pop(); | ||
}); | ||
} | ||
return buffer.length === 1 ? buffer[0] : (0, import_html2.stringBufferToString)(buffer); | ||
} | ||
toStringToBuffer(buffer) { | ||
const tag = this.tag; | ||
const props = this.props; | ||
let { children } = this; | ||
buffer[0] += `<${tag}`; | ||
const propsKeys = Object.keys(props || {}); | ||
for (let i = 0, len = propsKeys.length; i < len; i++) { | ||
const key = propsKeys[i]; | ||
const v = props[key]; | ||
if (key === "style" && typeof v === "object") { | ||
const styles = Object.keys(v).map((k) => { | ||
const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); | ||
return `${property}:${v[k]}`; | ||
}).join(";"); | ||
buffer[0] += ` style="${styles}"`; | ||
} else if (typeof v === "string") { | ||
buffer[0] += ` ${key}="`; | ||
(0, import_html2.escapeToBuffer)(v, buffer); | ||
buffer[0] += '"'; | ||
} else if (v === null || v === void 0) { | ||
} else if (typeof v === "number" || v.isEscaped) { | ||
buffer[0] += ` ${key}="${v}"`; | ||
} else if (typeof v === "boolean" && booleanAttributes.includes(key)) { | ||
if (v) { | ||
buffer[0] += ` ${key}=""`; | ||
} | ||
} else if (key === "dangerouslySetInnerHTML") { | ||
if (children.length > 0) { | ||
throw "Can only set one of `children` or `props.dangerouslySetInnerHTML`."; | ||
} | ||
children = [(0, import_html.raw)(v.__html)]; | ||
} else if (v instanceof Promise) { | ||
buffer[0] += ` ${key}="`; | ||
buffer.unshift('"', v); | ||
} else { | ||
buffer[0] += ` ${key}="`; | ||
(0, import_html2.escapeToBuffer)(v.toString(), buffer); | ||
buffer[0] += '"'; | ||
} | ||
} | ||
if (emptyTags.includes(tag)) { | ||
buffer[0] += "/>"; | ||
return; | ||
} | ||
buffer[0] += ">"; | ||
childrenToStringToBuffer(children, buffer); | ||
buffer[0] += `</${tag}>`; | ||
} | ||
} | ||
class JSXFunctionNode extends JSXNode { | ||
toStringToBuffer(buffer) { | ||
const { children } = this; | ||
const res = this.tag.call(null, { | ||
...this.props, | ||
children: children.length <= 1 ? children[0] : children | ||
}); | ||
if (res instanceof Promise) { | ||
if (import_context.globalContexts.length === 0) { | ||
buffer.unshift("", res); | ||
} else { | ||
const currentContexts = import_context.globalContexts.map((c) => [c, c.values.at(-1)]); | ||
buffer.unshift( | ||
"", | ||
res.then((childRes) => { | ||
if (childRes instanceof JSXNode) { | ||
childRes.localContexts = currentContexts; | ||
} | ||
return childRes; | ||
}) | ||
); | ||
} | ||
} else if (res instanceof JSXNode) { | ||
res.toStringToBuffer(buffer); | ||
} else if (typeof res === "number" || res.isEscaped) { | ||
buffer[0] += res; | ||
} else { | ||
(0, import_html2.escapeToBuffer)(res, buffer); | ||
} | ||
} | ||
} | ||
class JSXFragmentNode extends JSXNode { | ||
toStringToBuffer(buffer) { | ||
childrenToStringToBuffer(this.children, buffer); | ||
} | ||
} | ||
const jsx = (tag, props, ...children) => { | ||
let key; | ||
if (props) { | ||
key = props?.key; | ||
delete props["key"]; | ||
} | ||
const node = jsxFn(tag, props, children); | ||
node.key = key; | ||
return node; | ||
}; | ||
const jsxFn = (tag, props, children) => { | ||
if (typeof tag === "function") { | ||
return new JSXFunctionNode(tag, props, children); | ||
} else { | ||
return new JSXNode(tag, props, children); | ||
} | ||
}; | ||
const shallowEqual = (a, b) => { | ||
if (a === b) { | ||
return true; | ||
} | ||
const aKeys = Object.keys(a).sort(); | ||
const bKeys = Object.keys(b).sort(); | ||
if (aKeys.length !== bKeys.length) { | ||
return false; | ||
} | ||
for (let i = 0, len = aKeys.length; i < len; i++) { | ||
if (aKeys[i] === "children" && bKeys[i] === "children" && !a.children?.length && !b.children?.length) { | ||
continue; | ||
} else if (a[aKeys[i]] !== b[aKeys[i]]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
const memo = (component, propsAreEqual = shallowEqual) => { | ||
let computed = void 0; | ||
let prevProps = void 0; | ||
return (props) => { | ||
if (prevProps && !propsAreEqual(prevProps, props)) { | ||
computed = void 0; | ||
} | ||
prevProps = props; | ||
return computed || (computed = component(props)); | ||
}; | ||
}; | ||
const Fragment = ({ | ||
children | ||
}) => { | ||
return new JSXFragmentNode( | ||
"", | ||
{}, | ||
Array.isArray(children) ? children : children ? [children] : [] | ||
); | ||
}; | ||
const isValidElement = (element) => { | ||
return !!(element && typeof element === "object" && "tag" in element && "props" in element && "children" in element); | ||
}; | ||
const cloneElement = (element, props, ...children) => { | ||
return jsxFn( | ||
element.tag, | ||
{ ...element.props, ...props }, | ||
children.length ? children : element.children || [] | ||
); | ||
}; | ||
var import_context = require("./context"); | ||
__reExport(jsx_exports, require("./types"), module.exports); | ||
// Annotate the CommonJS export names for ESM import in node: | ||
@@ -296,4 +59,2 @@ 0 && (module.exports = { | ||
Fragment, | ||
JSXFragmentNode, | ||
JSXNode, | ||
Suspense, | ||
@@ -304,3 +65,2 @@ cloneElement, | ||
jsx, | ||
jsxFn, | ||
memo, | ||
@@ -307,0 +67,0 @@ startTransition, |
@@ -21,16 +21,16 @@ "use strict"; | ||
__export(jsx_dev_runtime_exports, { | ||
Fragment: () => import__2.Fragment, | ||
Fragment: () => import_base2.Fragment, | ||
jsxDEV: () => jsxDEV | ||
}); | ||
module.exports = __toCommonJS(jsx_dev_runtime_exports); | ||
var import__ = require("."); | ||
var import__2 = require("."); | ||
var import_base = require("./base"); | ||
var import_base2 = require("./base"); | ||
function jsxDEV(tag, props, key) { | ||
let node; | ||
if (!props || !("children" in props)) { | ||
node = (0, import__.jsxFn)(tag, props, []); | ||
node = (0, import_base.jsxFn)(tag, props, []); | ||
} else { | ||
const children = props.children; | ||
delete props["children"]; | ||
node = Array.isArray(children) ? (0, import__.jsxFn)(tag, props, children) : (0, import__.jsxFn)(tag, props, [children]); | ||
node = Array.isArray(children) ? (0, import_base.jsxFn)(tag, props, children) : (0, import_base.jsxFn)(tag, props, [children]); | ||
} | ||
@@ -37,0 +37,0 @@ node.key = key; |
@@ -32,3 +32,6 @@ "use strict"; | ||
let suspenseCounter = 0; | ||
const Suspense = async ({ children, fallback }) => { | ||
const Suspense = async ({ | ||
children, | ||
fallback | ||
}) => { | ||
if (!children) { | ||
@@ -35,0 +38,0 @@ return fallback.toString(); |
@@ -38,3 +38,7 @@ "use strict"; | ||
const getExtension = (mimeType) => { | ||
return Object.keys(baseMimes).find((ext) => baseMimes[ext] === mimeType); | ||
for (const ext in baseMimes) { | ||
if (baseMimes[ext] === mimeType) { | ||
return ext; | ||
} | ||
} | ||
}; | ||
@@ -41,0 +45,0 @@ const baseMimes = { |
@@ -11,2 +11,2 @@ // src/helper.ts | ||
export * from "./helper/dev/index.js"; | ||
export * from "./helper/ssg/index.js"; | ||
export * from "./adapter/deno/ssg.js"; |
// src/jsx/context.ts | ||
import { raw } from "../helper/html/index.js"; | ||
import { JSXFragmentNode } from "./base.js"; | ||
import { DOM_RENDERER } from "./constants.js"; | ||
import { createContextProviderFunction } from "./dom/context.js"; | ||
import { JSXFragmentNode } from "./index.js"; | ||
var globalContexts = []; | ||
@@ -7,0 +7,0 @@ var createContext = (defaultValue) => { |
@@ -15,3 +15,6 @@ // src/jsx/dom/components.ts | ||
}; | ||
var Suspense = ({ children, fallback }) => { | ||
var Suspense = ({ | ||
children, | ||
fallback | ||
}) => { | ||
const res = Fragment({ children }); | ||
@@ -18,0 +21,0 @@ res[DOM_ERROR_HANDLER] = (err, retry) => { |
@@ -20,3 +20,3 @@ // src/jsx/dom/index.ts | ||
import { createContext } from "./context.js"; | ||
import { memo, isValidElement } from "../index.js"; | ||
import { memo, isValidElement } from "../base.js"; | ||
import { jsx } from "./jsx-runtime.js"; | ||
@@ -23,0 +23,0 @@ var cloneElement = (element, props, ...children) => { |
// src/jsx/dom/jsx-dev-runtime.ts | ||
import { normalizeIntrinsicElementProps } from "../utils.js"; | ||
var jsxDEV = (tag, props, key) => { | ||
const children = "children" in props ? props.children : []; | ||
delete props["children"]; | ||
if (typeof tag === "string") { | ||
normalizeIntrinsicElementProps(props); | ||
} | ||
let children; | ||
if (props && "children" in props) { | ||
children = props.children; | ||
delete props["children"]; | ||
} else { | ||
children = []; | ||
} | ||
return { | ||
@@ -6,0 +15,0 @@ tag, |
@@ -6,6 +6,15 @@ // src/jsx/dom/render.ts | ||
var eventAliasMap = { | ||
change: "input" | ||
Change: "Input", | ||
DoubleClick: "DblClick" | ||
}; | ||
var buildDataStack = []; | ||
var isNodeString = (node) => Array.isArray(node); | ||
var getEventSpec = (key) => { | ||
const match = key.match(/^on([A-Z][a-zA-Z]+?)((?<!Pointer)Capture)?$/); | ||
if (match) { | ||
const [, eventName, capture] = match; | ||
return [(eventAliasMap[eventName] || eventName).toLowerCase(), !!capture]; | ||
} | ||
return void 0; | ||
}; | ||
var applyProps = (container, attributes, oldAttributes) => { | ||
@@ -15,3 +24,12 @@ attributes || (attributes = {}); | ||
if (!oldAttributes || oldAttributes[key] !== value) { | ||
if (key === "dangerouslySetInnerHTML" && value) { | ||
const eventSpec = getEventSpec(key); | ||
if (eventSpec) { | ||
if (typeof value !== "function") { | ||
throw new Error(`Event handler for "${key}" is not a function`); | ||
} | ||
if (oldAttributes) { | ||
container.removeEventListener(eventSpec[0], oldAttributes[key], eventSpec[1]); | ||
} | ||
container.addEventListener(eventSpec[0], value, eventSpec[1]); | ||
} else if (key === "dangerouslySetInnerHTML" && value) { | ||
container.innerHTML = value.__html; | ||
@@ -24,9 +42,2 @@ } else if (key === "ref") { | ||
} | ||
} else if (key.startsWith("on") && typeof value === "function") { | ||
const jsxEventName = key.slice(2).toLowerCase(); | ||
const eventName = eventAliasMap[jsxEventName] || jsxEventName; | ||
if (oldAttributes) { | ||
container.removeEventListener(eventName, oldAttributes[key]); | ||
} | ||
container.addEventListener(eventName, value); | ||
} else if (key === "style") { | ||
@@ -55,3 +66,6 @@ if (typeof value === "string") { | ||
if (!(key in attributes)) { | ||
if (key === "ref") { | ||
const eventSpec = getEventSpec(key); | ||
if (eventSpec) { | ||
container.removeEventListener(eventSpec[0], value, eventSpec[1]); | ||
} else if (key === "ref") { | ||
if (typeof value === "function") { | ||
@@ -62,5 +76,2 @@ value(null); | ||
} | ||
} else if (key.startsWith("on")) { | ||
const eventName = key.slice(2).toLowerCase(); | ||
container.removeEventListener(eventName, value); | ||
} else { | ||
@@ -67,0 +78,0 @@ container.removeAttribute(key); |
// src/jsx/index.ts | ||
import { raw } from "../helper/html/index.js"; | ||
import { escapeToBuffer, stringBufferToString } from "../utils/html.js"; | ||
import { globalContexts } from "./context.js"; | ||
import { jsx, memo, Fragment, isValidElement, cloneElement } from "./base.js"; | ||
import { ErrorBoundary } from "./components.js"; | ||
@@ -22,241 +20,6 @@ import { Suspense } from "./streaming.js"; | ||
import { createContext, useContext } from "./context.js"; | ||
var emptyTags = [ | ||
"area", | ||
"base", | ||
"br", | ||
"col", | ||
"embed", | ||
"hr", | ||
"img", | ||
"input", | ||
"keygen", | ||
"link", | ||
"meta", | ||
"param", | ||
"source", | ||
"track", | ||
"wbr" | ||
]; | ||
var booleanAttributes = [ | ||
"allowfullscreen", | ||
"async", | ||
"autofocus", | ||
"autoplay", | ||
"checked", | ||
"controls", | ||
"default", | ||
"defer", | ||
"disabled", | ||
"formnovalidate", | ||
"hidden", | ||
"inert", | ||
"ismap", | ||
"itemscope", | ||
"loop", | ||
"multiple", | ||
"muted", | ||
"nomodule", | ||
"novalidate", | ||
"open", | ||
"playsinline", | ||
"readonly", | ||
"required", | ||
"reversed", | ||
"selected" | ||
]; | ||
var childrenToStringToBuffer = (children, buffer) => { | ||
for (let i = 0, len = children.length; i < len; i++) { | ||
const child = children[i]; | ||
if (typeof child === "string") { | ||
escapeToBuffer(child, buffer); | ||
} else if (typeof child === "boolean" || child === null || child === void 0) { | ||
continue; | ||
} else if (child instanceof JSXNode) { | ||
child.toStringToBuffer(buffer); | ||
} else if (typeof child === "number" || child.isEscaped) { | ||
; | ||
buffer[0] += child; | ||
} else if (child instanceof Promise) { | ||
buffer.unshift("", child); | ||
} else { | ||
childrenToStringToBuffer(child, buffer); | ||
} | ||
} | ||
}; | ||
var JSXNode = class { | ||
constructor(tag, props, children) { | ||
this.isEscaped = true; | ||
this.tag = tag; | ||
this.props = props; | ||
this.children = children; | ||
} | ||
toString() { | ||
const buffer = [""]; | ||
this.localContexts?.forEach(([context, value]) => { | ||
context.values.push(value); | ||
}); | ||
try { | ||
this.toStringToBuffer(buffer); | ||
} finally { | ||
this.localContexts?.forEach(([context]) => { | ||
context.values.pop(); | ||
}); | ||
} | ||
return buffer.length === 1 ? buffer[0] : stringBufferToString(buffer); | ||
} | ||
toStringToBuffer(buffer) { | ||
const tag = this.tag; | ||
const props = this.props; | ||
let { children } = this; | ||
buffer[0] += `<${tag}`; | ||
const propsKeys = Object.keys(props || {}); | ||
for (let i = 0, len = propsKeys.length; i < len; i++) { | ||
const key = propsKeys[i]; | ||
const v = props[key]; | ||
if (key === "style" && typeof v === "object") { | ||
const styles = Object.keys(v).map((k) => { | ||
const property = k.replace(/[A-Z]/g, (match) => `-${match.toLowerCase()}`); | ||
return `${property}:${v[k]}`; | ||
}).join(";"); | ||
buffer[0] += ` style="${styles}"`; | ||
} else if (typeof v === "string") { | ||
buffer[0] += ` ${key}="`; | ||
escapeToBuffer(v, buffer); | ||
buffer[0] += '"'; | ||
} else if (v === null || v === void 0) { | ||
} else if (typeof v === "number" || v.isEscaped) { | ||
buffer[0] += ` ${key}="${v}"`; | ||
} else if (typeof v === "boolean" && booleanAttributes.includes(key)) { | ||
if (v) { | ||
buffer[0] += ` ${key}=""`; | ||
} | ||
} else if (key === "dangerouslySetInnerHTML") { | ||
if (children.length > 0) { | ||
throw "Can only set one of `children` or `props.dangerouslySetInnerHTML`."; | ||
} | ||
children = [raw(v.__html)]; | ||
} else if (v instanceof Promise) { | ||
buffer[0] += ` ${key}="`; | ||
buffer.unshift('"', v); | ||
} else { | ||
buffer[0] += ` ${key}="`; | ||
escapeToBuffer(v.toString(), buffer); | ||
buffer[0] += '"'; | ||
} | ||
} | ||
if (emptyTags.includes(tag)) { | ||
buffer[0] += "/>"; | ||
return; | ||
} | ||
buffer[0] += ">"; | ||
childrenToStringToBuffer(children, buffer); | ||
buffer[0] += `</${tag}>`; | ||
} | ||
}; | ||
var JSXFunctionNode = class extends JSXNode { | ||
toStringToBuffer(buffer) { | ||
const { children } = this; | ||
const res = this.tag.call(null, { | ||
...this.props, | ||
children: children.length <= 1 ? children[0] : children | ||
}); | ||
if (res instanceof Promise) { | ||
if (globalContexts.length === 0) { | ||
buffer.unshift("", res); | ||
} else { | ||
const currentContexts = globalContexts.map((c) => [c, c.values.at(-1)]); | ||
buffer.unshift( | ||
"", | ||
res.then((childRes) => { | ||
if (childRes instanceof JSXNode) { | ||
childRes.localContexts = currentContexts; | ||
} | ||
return childRes; | ||
}) | ||
); | ||
} | ||
} else if (res instanceof JSXNode) { | ||
res.toStringToBuffer(buffer); | ||
} else if (typeof res === "number" || res.isEscaped) { | ||
buffer[0] += res; | ||
} else { | ||
escapeToBuffer(res, buffer); | ||
} | ||
} | ||
}; | ||
var JSXFragmentNode = class extends JSXNode { | ||
toStringToBuffer(buffer) { | ||
childrenToStringToBuffer(this.children, buffer); | ||
} | ||
}; | ||
var jsx = (tag, props, ...children) => { | ||
let key; | ||
if (props) { | ||
key = props?.key; | ||
delete props["key"]; | ||
} | ||
const node = jsxFn(tag, props, children); | ||
node.key = key; | ||
return node; | ||
}; | ||
var jsxFn = (tag, props, children) => { | ||
if (typeof tag === "function") { | ||
return new JSXFunctionNode(tag, props, children); | ||
} else { | ||
return new JSXNode(tag, props, children); | ||
} | ||
}; | ||
var shallowEqual = (a, b) => { | ||
if (a === b) { | ||
return true; | ||
} | ||
const aKeys = Object.keys(a).sort(); | ||
const bKeys = Object.keys(b).sort(); | ||
if (aKeys.length !== bKeys.length) { | ||
return false; | ||
} | ||
for (let i = 0, len = aKeys.length; i < len; i++) { | ||
if (aKeys[i] === "children" && bKeys[i] === "children" && !a.children?.length && !b.children?.length) { | ||
continue; | ||
} else if (a[aKeys[i]] !== b[aKeys[i]]) { | ||
return false; | ||
} | ||
} | ||
return true; | ||
}; | ||
var memo = (component, propsAreEqual = shallowEqual) => { | ||
let computed = void 0; | ||
let prevProps = void 0; | ||
return (props) => { | ||
if (prevProps && !propsAreEqual(prevProps, props)) { | ||
computed = void 0; | ||
} | ||
prevProps = props; | ||
return computed || (computed = component(props)); | ||
}; | ||
}; | ||
var Fragment = ({ | ||
children | ||
}) => { | ||
return new JSXFragmentNode( | ||
"", | ||
{}, | ||
Array.isArray(children) ? children : children ? [children] : [] | ||
); | ||
}; | ||
var isValidElement = (element) => { | ||
return !!(element && typeof element === "object" && "tag" in element && "props" in element && "children" in element); | ||
}; | ||
var cloneElement = (element, props, ...children) => { | ||
return jsxFn( | ||
element.tag, | ||
{ ...element.props, ...props }, | ||
children.length ? children : element.children || [] | ||
); | ||
}; | ||
export * from "./types.js"; | ||
export { | ||
ErrorBoundary, | ||
Fragment, | ||
JSXFragmentNode, | ||
JSXNode, | ||
Suspense, | ||
@@ -267,3 +30,2 @@ cloneElement, | ||
jsx, | ||
jsxFn, | ||
memo, | ||
@@ -270,0 +32,0 @@ startTransition, |
// src/jsx/jsx-dev-runtime.ts | ||
import { jsxFn } from "./index.js"; | ||
import { Fragment } from "./index.js"; | ||
import { jsxFn } from "./base.js"; | ||
import { Fragment } from "./base.js"; | ||
function jsxDEV(tag, props, key) { | ||
@@ -5,0 +5,0 @@ let node; |
@@ -9,3 +9,6 @@ // src/jsx/streaming.ts | ||
var suspenseCounter = 0; | ||
var Suspense = async ({ children, fallback }) => { | ||
var Suspense = async ({ | ||
children, | ||
fallback | ||
}) => { | ||
if (!children) { | ||
@@ -12,0 +15,0 @@ return fallback.toString(); |
@@ -10,2 +10,2 @@ export * from './helper/accepts'; | ||
export * from './helper/dev'; | ||
export * from './helper/ssg'; | ||
export * from './adapter/deno/ssg'; |
import type { HtmlEscapedString } from '../utils/html'; | ||
import type { FC, Child } from '.'; | ||
import type { FC, PropsWithChildren, Child } from '.'; | ||
export declare const childrenToString: (children: Child[]) => Promise<HtmlEscapedString[]>; | ||
@@ -11,6 +11,6 @@ export type ErrorHandler = (error: Error) => void; | ||
*/ | ||
export declare const ErrorBoundary: FC<{ | ||
export declare const ErrorBoundary: FC<PropsWithChildren<{ | ||
fallback?: Child; | ||
fallbackRender?: FallbackRender; | ||
onError?: ErrorHandler; | ||
}>; | ||
}>>; |
@@ -1,7 +0,7 @@ | ||
import type { FC } from '.'; | ||
import type { FC, PropsWithChildren } from '.'; | ||
export interface Context<T> { | ||
values: T[]; | ||
Provider: FC<{ | ||
Provider: FC<PropsWithChildren<{ | ||
value: T; | ||
}>; | ||
}>>; | ||
} | ||
@@ -8,0 +8,0 @@ export declare const globalContexts: Context<unknown>[]; |
@@ -1,10 +0,10 @@ | ||
import type { FC, Child } from '..'; | ||
import type { FC, PropsWithChildren, Child } from '..'; | ||
import type { FallbackRender, ErrorHandler } from '../components'; | ||
export declare const ErrorBoundary: FC<{ | ||
export declare const ErrorBoundary: FC<PropsWithChildren<{ | ||
fallback?: Child; | ||
fallbackRender?: FallbackRender; | ||
onError?: ErrorHandler; | ||
}>; | ||
export declare const Suspense: FC<{ | ||
}>>; | ||
export declare const Suspense: FC<PropsWithChildren<{ | ||
fallback: any; | ||
}>; | ||
}>>; |
@@ -1,2 +0,2 @@ | ||
import type { Child } from '..'; | ||
import type { Child } from '../base'; | ||
import type { Context } from '../context'; | ||
@@ -8,3 +8,3 @@ export declare const createContextProviderFunction: <T>(values: T[]) => ({ value, children }: { | ||
tag: string | Function; | ||
props: import("..").Props; | ||
props: import("../base").Props; | ||
key: string | undefined; | ||
@@ -11,0 +11,0 @@ children: any[]; |
@@ -0,3 +1,3 @@ | ||
import type { FC, PropsWithChildren } from '..'; | ||
import type { CssClassName, CssVariableType } from '../../helper/css/common'; | ||
import type { FC } from '../../jsx'; | ||
export { rawCssString } from '../../helper/css/common'; | ||
@@ -8,3 +8,3 @@ export declare const createCssJsxDomObjects: ({ id }: { | ||
toString(this: CssClassName): string; | ||
}, FC<void>]; | ||
}, FC<PropsWithChildren<void>>]; | ||
/** | ||
@@ -26,3 +26,3 @@ * @experimental | ||
}; | ||
Style: FC<void>; | ||
Style: FC<PropsWithChildren<void>>; | ||
}; | ||
@@ -62,2 +62,2 @@ /** | ||
*/ | ||
export declare const Style: FC<void>; | ||
export declare const Style: FC<PropsWithChildren<void>>; |
@@ -7,4 +7,4 @@ export { useState, useEffect, useRef, useCallback, use, startTransition, useTransition, useDeferredValue, startViewTransition, useViewTransition, useMemo, useLayoutEffect, } from '../hooks'; | ||
export { createContext } from './context'; | ||
export { memo, isValidElement } from '..'; | ||
import type { Props, Child, JSXNode } from '..'; | ||
export { memo, isValidElement } from '../base'; | ||
import type { Props, Child, JSXNode } from '../base'; | ||
export declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Props, ...children: Child[]) => T; |
@@ -1,3 +0,3 @@ | ||
import type { Props } from '..'; | ||
export declare const jsxDEV: (tag: string | Function, props: Props, key: string | undefined) => { | ||
import type { Props } from '../base'; | ||
export declare const jsxDEV: (tag: string | Function, props: Props, key?: string) => { | ||
tag: string | Function; | ||
@@ -4,0 +4,0 @@ props: Props; |
@@ -1,3 +0,3 @@ | ||
import type { FC, Child, Props } from '..'; | ||
import type { JSXNode } from '..'; | ||
import type { JSXNode } from '../base'; | ||
import type { FC, Child, Props } from '../base'; | ||
import { DOM_RENDERER, DOM_STASH } from '../constants'; | ||
@@ -4,0 +4,0 @@ import type { Context as JSXContext } from '../context'; |
@@ -1,49 +0,6 @@ | ||
import type { StringBuffer, HtmlEscaped, HtmlEscapedString } from '../utils/html'; | ||
import type { Context } from './context'; | ||
import type { IntrinsicElements as IntrinsicElementsDefined } from './intrinsic-elements'; | ||
export { jsx, memo, Fragment, isValidElement, cloneElement } from './base'; | ||
export { ErrorBoundary } from './components'; | ||
export { Suspense } from './streaming'; | ||
export { useState, useEffect, useRef, useCallback, use, startTransition, useTransition, useDeferredValue, startViewTransition, useViewTransition, useMemo, useLayoutEffect, } from './hooks'; | ||
export type { RefObject } from './hooks'; | ||
export { createContext, useContext } from './context'; | ||
export type { Context } from './context'; | ||
export type Props = Record<string, any>; | ||
declare global { | ||
namespace JSX { | ||
type Element = HtmlEscapedString | Promise<HtmlEscapedString>; | ||
interface ElementChildrenAttribute { | ||
children: Child; | ||
} | ||
interface IntrinsicElements extends IntrinsicElementsDefined { | ||
[tagName: string]: Props; | ||
} | ||
} | ||
} | ||
type LocalContexts = [Context<unknown>, unknown][]; | ||
export type Child = string | Promise<string> | number | JSXNode | Child[]; | ||
export declare class JSXNode implements HtmlEscaped { | ||
tag: string | Function; | ||
props: Props; | ||
key?: string; | ||
children: Child[]; | ||
isEscaped: true; | ||
localContexts?: LocalContexts; | ||
constructor(tag: string | Function, props: Props, children: Child[]); | ||
toString(): string | Promise<string>; | ||
toStringToBuffer(buffer: StringBuffer): void; | ||
} | ||
export declare class JSXFragmentNode extends JSXNode { | ||
toStringToBuffer(buffer: StringBuffer): void; | ||
} | ||
export declare const jsx: (tag: string | Function, props: Props, ...children: (string | HtmlEscapedString)[]) => JSXNode; | ||
export declare const jsxFn: (tag: string | Function, props: Props, children: (string | HtmlEscapedString)[]) => JSXNode; | ||
export type FC<T = Props> = (props: T & { | ||
children?: Child; | ||
}) => HtmlEscapedString | Promise<HtmlEscapedString>; | ||
export declare const memo: <T>(component: FC<T>, propsAreEqual?: (prevProps: Readonly<T>, nextProps: Readonly<T>) => boolean) => FC<T>; | ||
export declare const Fragment: ({ children, }: { | ||
key?: string | undefined; | ||
children?: HtmlEscapedString | Child | undefined; | ||
}) => HtmlEscapedString; | ||
export declare const isValidElement: (element: unknown) => element is JSXNode; | ||
export declare const cloneElement: <T extends JSXNode | JSX.Element>(element: T, props: Partial<Props>, ...children: Child[]) => T; | ||
export * from './types'; |
@@ -19,3 +19,127 @@ /** | ||
} | ||
interface HTMLAttributes extends JSXAttributes, AnyAttributes { | ||
interface EventAttributes { | ||
onScroll?: (event: Event) => void; | ||
onScrollCapture?: (event: Event) => void; | ||
onScrollEnd?: (event: Event) => void; | ||
onScrollEndCapture?: (event: Event) => void; | ||
onWheel?: (event: WheelEvent) => void; | ||
onWheelCapture?: (event: WheelEvent) => void; | ||
onAnimationCancel?: (event: AnimationEvent) => void; | ||
onAnimationCancelCapture?: (event: AnimationEvent) => void; | ||
onAnimationEnd?: (event: AnimationEvent) => void; | ||
onAnimationEndCapture?: (event: AnimationEvent) => void; | ||
onAnimationIteration?: (event: AnimationEvent) => void; | ||
onAnimationIterationCapture?: (event: AnimationEvent) => void; | ||
onAnimationStart?: (event: AnimationEvent) => void; | ||
onAnimationStartCapture?: (event: AnimationEvent) => void; | ||
onCopy?: (event: ClipboardEvent) => void; | ||
onCopyCapture?: (event: ClipboardEvent) => void; | ||
onCut?: (event: ClipboardEvent) => void; | ||
onCutCapture?: (event: ClipboardEvent) => void; | ||
onPaste?: (event: ClipboardEvent) => void; | ||
onPasteCapture?: (event: ClipboardEvent) => void; | ||
onCompositionEnd?: (event: CompositionEvent) => void; | ||
onCompositionEndCapture?: (event: CompositionEvent) => void; | ||
onCompositionStart?: (event: CompositionEvent) => void; | ||
onCompositionStartCapture?: (event: CompositionEvent) => void; | ||
onCompositionUpdate?: (event: CompositionEvent) => void; | ||
onCompositionUpdateCapture?: (event: CompositionEvent) => void; | ||
onBlur?: (event: FocusEvent) => void; | ||
onBlurCapture?: (event: FocusEvent) => void; | ||
onFocus?: (event: FocusEvent) => void; | ||
onFocusCapture?: (event: FocusEvent) => void; | ||
onFocusIn?: (event: FocusEvent) => void; | ||
onFocusInCapture?: (event: FocusEvent) => void; | ||
onFocusOut?: (event: FocusEvent) => void; | ||
onFocusOutCapture?: (event: FocusEvent) => void; | ||
onFullscreenChange?: (event: Event) => void; | ||
onFullscreenChangeCapture?: (event: Event) => void; | ||
onFullscreenError?: (event: Event) => void; | ||
onFullscreenErrorCapture?: (event: Event) => void; | ||
onKeyDown?: (event: KeyboardEvent) => void; | ||
onKeyDownCapture?: (event: KeyboardEvent) => void; | ||
onKeyPress?: (event: KeyboardEvent) => void; | ||
onKeyPressCapture?: (event: KeyboardEvent) => void; | ||
onKeyUp?: (event: KeyboardEvent) => void; | ||
onKeyUpCapture?: (event: KeyboardEvent) => void; | ||
onAuxClick?: (event: MouseEvent) => void; | ||
onAuxClickCapture?: (event: MouseEvent) => void; | ||
onClick?: (event: MouseEvent) => void; | ||
onClickCapture?: (event: MouseEvent) => void; | ||
onContextMenu?: (event: MouseEvent) => void; | ||
onContextMenuCapture?: (event: MouseEvent) => void; | ||
onDoubleClick?: (event: MouseEvent) => void; | ||
onDoubleClickCapture?: (event: MouseEvent) => void; | ||
onMouseDown?: (event: MouseEvent) => void; | ||
onMouseDownCapture?: (event: MouseEvent) => void; | ||
onMouseEnter?: (event: MouseEvent) => void; | ||
onMouseEnterCapture?: (event: MouseEvent) => void; | ||
onMouseLeave?: (event: MouseEvent) => void; | ||
onMouseLeaveCapture?: (event: MouseEvent) => void; | ||
onMouseMove?: (event: MouseEvent) => void; | ||
onMouseMoveCapture?: (event: MouseEvent) => void; | ||
onMouseOut?: (event: MouseEvent) => void; | ||
onMouseOutCapture?: (event: MouseEvent) => void; | ||
onMouseOver?: (event: MouseEvent) => void; | ||
onMouseOverCapture?: (event: MouseEvent) => void; | ||
onMouseUp?: (event: MouseEvent) => void; | ||
onMouseUpCapture?: (event: MouseEvent) => void; | ||
onMouseWheel?: (event: WheelEvent) => void; | ||
onMouseWheelCapture?: (event: WheelEvent) => void; | ||
onGotPointerCapture?: (event: PointerEvent) => void; | ||
onGotPointerCaptureCapture?: (event: PointerEvent) => void; | ||
onLostPointerCapture?: (event: PointerEvent) => void; | ||
onLostPointerCaptureCapture?: (event: PointerEvent) => void; | ||
onPointerCancel?: (event: PointerEvent) => void; | ||
onPointerCancelCapture?: (event: PointerEvent) => void; | ||
onPointerDown?: (event: PointerEvent) => void; | ||
onPointerDownCapture?: (event: PointerEvent) => void; | ||
onPointerEnter?: (event: PointerEvent) => void; | ||
onPointerEnterCapture?: (event: PointerEvent) => void; | ||
onPointerLeave?: (event: PointerEvent) => void; | ||
onPointerLeaveCapture?: (event: PointerEvent) => void; | ||
onPointerMove?: (event: PointerEvent) => void; | ||
onPointerMoveCapture?: (event: PointerEvent) => void; | ||
onPointerOut?: (event: PointerEvent) => void; | ||
onPointerOutCapture?: (event: PointerEvent) => void; | ||
onPointerOver?: (event: PointerEvent) => void; | ||
onPointerOverCapture?: (event: PointerEvent) => void; | ||
onPointerUp?: (event: PointerEvent) => void; | ||
onPointerUpCapture?: (event: PointerEvent) => void; | ||
onTouchCancel?: (event: TouchEvent) => void; | ||
onTouchCancelCapture?: (event: TouchEvent) => void; | ||
onTouchEnd?: (event: TouchEvent) => void; | ||
onTouchEndCapture?: (event: TouchEvent) => void; | ||
onTouchMove?: (event: TouchEvent) => void; | ||
onTouchMoveCapture?: (event: TouchEvent) => void; | ||
onTouchStart?: (event: TouchEvent) => void; | ||
onTouchStartCapture?: (event: TouchEvent) => void; | ||
onTransitionCancel?: (event: TransitionEvent) => void; | ||
onTransitionCancelCapture?: (event: TransitionEvent) => void; | ||
onTransitionEnd?: (event: TransitionEvent) => void; | ||
onTransitionEndCapture?: (event: TransitionEvent) => void; | ||
onTransitionRun?: (event: TransitionEvent) => void; | ||
onTransitionRunCapture?: (event: TransitionEvent) => void; | ||
onTransitionStart?: (event: TransitionEvent) => void; | ||
onTransitionStartCapture?: (event: TransitionEvent) => void; | ||
onFormData?: (event: FormDataEvent) => void; | ||
onFormDataCapture?: (event: FormDataEvent) => void; | ||
onReset?: (event: Event) => void; | ||
onResetCapture?: (event: Event) => void; | ||
onSubmit?: (event: Event) => void; | ||
onSubmitCapture?: (event: Event) => void; | ||
onInvalid?: (event: Event) => void; | ||
onInvalidCapture?: (event: Event) => void; | ||
onSelect?: (event: Event) => void; | ||
onSelectCapture?: (event: Event) => void; | ||
onSelectChange?: (event: Event) => void; | ||
onSelectChangeCapture?: (event: Event) => void; | ||
onInput?: (event: InputEvent) => void; | ||
onInputCapture?: (event: InputEvent) => void; | ||
onBeforeInput?: (event: InputEvent) => void; | ||
onBeforeInputCapture?: (event: InputEvent) => void; | ||
onChange?: (event: Event) => void; | ||
onChangeCapture?: (event: Event) => void; | ||
} | ||
interface HTMLAttributes extends JSXAttributes, EventAttributes, AnyAttributes { | ||
accesskey?: string | undefined; | ||
@@ -22,0 +146,0 @@ autofocus?: boolean | undefined; |
@@ -1,3 +0,3 @@ | ||
import type { JSXNode } from '.'; | ||
export { Fragment } from '.'; | ||
export declare function jsxDEV(tag: string | Function, props: Record<string, unknown>, key: string | undefined): JSXNode; | ||
import type { JSXNode } from './base'; | ||
export { Fragment } from './base'; | ||
export declare function jsxDEV(tag: string | Function, props: Record<string, unknown>, key?: string): JSXNode; |
import type { HtmlEscapedString } from '../utils/html'; | ||
import type { FC } from '.'; | ||
import type { FC, PropsWithChildren } from '.'; | ||
/** | ||
@@ -8,5 +8,5 @@ * @experimental | ||
*/ | ||
export declare const Suspense: FC<{ | ||
export declare const Suspense: FC<PropsWithChildren<{ | ||
fallback: any; | ||
}>; | ||
}>>; | ||
/** | ||
@@ -13,0 +13,0 @@ * @experimental |
import type { Context, Renderer } from '../../context'; | ||
import type { FC } from '../../jsx'; | ||
import type { FC, PropsWithChildren } from '../../jsx'; | ||
import type { Env, Input, MiddlewareHandler } from '../../types'; | ||
@@ -10,6 +10,6 @@ export declare const RequestContext: import("../../jsx").Context<Context<any, any, {}> | null>; | ||
}; | ||
export declare const jsxRenderer: (component?: FC<PropsForRenderer & { | ||
export declare const jsxRenderer: (component?: FC<PropsWithChildren<PropsForRenderer & { | ||
Layout: FC; | ||
}>, options?: RendererOptions) => MiddlewareHandler; | ||
}>>, options?: RendererOptions) => MiddlewareHandler; | ||
export declare const useRequestContext: <E extends Env = any, P extends string = any, I extends Input = {}>() => Context<E, P, I>; | ||
export {}; |
@@ -387,2 +387,5 @@ import type { Context } from './context'; | ||
} : never; | ||
type FlattenIfIntersect<T> = T extends infer O ? { | ||
[K in keyof O]: O[K]; | ||
} : never; | ||
export type MergeSchemaPath<OrigSchema extends Schema, SubPath extends string> = { | ||
@@ -395,7 +398,7 @@ [P in keyof OrigSchema as MergePath<SubPath, P & string>]: { | ||
input: Input extends { | ||
param: infer Params; | ||
} ? { | ||
param: Params & ExtractParams<SubPath>; | ||
} : RemoveBlankRecord<ExtractParams<SubPath>> extends never ? Input : Input & { | ||
param: infer _; | ||
} ? ExtractParams<SubPath> extends never ? Input : FlattenIfIntersect<Input & { | ||
param: ExtractParams<SubPath>; | ||
}> : RemoveBlankRecord<ExtractParams<SubPath>> extends never ? Input : Input & { | ||
param: ExtractParams<SubPath>; | ||
}; | ||
@@ -406,3 +409,5 @@ output: Output; | ||
}; | ||
export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I & { | ||
export type AddParam<I, P extends string> = ParamKeys<P> extends never ? I : I extends { | ||
param: infer _; | ||
} ? I : I & { | ||
param: UnionToIntersection<ParamKeyToRecord<ParamKeys<P>>>; | ||
@@ -409,0 +414,0 @@ }; |
@@ -15,3 +15,7 @@ // src/utils/mime.ts | ||
var getExtension = (mimeType) => { | ||
return Object.keys(baseMimes).find((ext) => baseMimes[ext] === mimeType); | ||
for (const ext in baseMimes) { | ||
if (baseMimes[ext] === mimeType) { | ||
return ext; | ||
} | ||
} | ||
}; | ||
@@ -18,0 +22,0 @@ var baseMimes = { |
{ | ||
"name": "hono", | ||
"version": "4.0.0-rc.4", | ||
"version": "4.0.0", | ||
"description": "Ultrafast web framework for the Edges", | ||
@@ -5,0 +5,0 @@ "main": "dist/cjs/index.js", |
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
690186
365
18951
0