This commit is contained in:
2026-08-14 16:03:47 +01:00
parent fd53e3f4fb
commit dfdc3b2840
2463 changed files with 186456 additions and 111315 deletions
+15 -16
View File
@@ -1,4 +1,3 @@
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
@@ -126,8 +125,11 @@ class JSXNode {
key;
children;
isEscaped = true;
localContexts;
suspendedContext;
constructor(tag, props, children) {
if (typeof tag !== "function" && !(0, import_utils.isValidTagName)(tag)) {
throw new Error(`Invalid JSX tag name: ${tag}`);
}
this.tag = tag;
this.props = props;
this.children = children;
@@ -141,27 +143,24 @@ class JSXNode {
return this.props.ref || null;
}
toString() {
const buffer = [""];
this.localContexts?.forEach(([context, value]) => {
context.values.push(value);
});
try {
const render = () => {
const buffer = [""];
this.toStringToBuffer(buffer);
} finally {
this.localContexts?.forEach(([context]) => {
context.values.pop();
});
}
return buffer.length === 1 ? "callbacks" in buffer ? (0, import_html2.resolveCallbackSync)((0, import_html.raw)(buffer[0], buffer.callbacks)).toString() : buffer[0] : (0, import_html2.stringBufferToString)(buffer, buffer.callbacks);
return buffer.length === 1 ? "callbacks" in buffer ? (0, import_html2.resolveCallbackSync)((0, import_html.raw)(buffer[0], buffer.callbacks)).toString() : buffer[0] : (0, import_html2.stringBufferToString)(buffer, buffer.callbacks);
};
return this.suspendedContext ? this.suspendedContext(render) : (0, import_context.runWithRenderContext)(render);
}
toStringToBuffer(buffer) {
const tag = this.tag;
const props = this.props;
let { children } = this;
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);
const normalizeKey = tag === "svg" || 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 = normalizeKey(key);
if (!(0, import_utils.isValidAttributeName)(key)) {
continue;
}
if (key === "children") {
} else if (key === "style" && typeof v === "object") {
let styleStr = "";
@@ -225,12 +224,12 @@ class JSXFunctionNode extends JSXNode {
if (import_context.globalContexts.length === 0) {
buffer.unshift("", res);
} else {
const currentContexts = import_context.globalContexts.map((c) => [c, c.values.at(-1)]);
const suspendedContext = (0, import_context.captureRenderContext)();
buffer.unshift(
"",
res.then((childRes) => {
if (childRes instanceof JSXNode) {
childRes.localContexts = currentContexts;
childRes.suspendedContext = suspendedContext;
}
return childRes;
})