release: WRNexusJS 0.2.78

This commit is contained in:
2026-07-22 01:53:18 +05:30
parent 7ff5b3e8c5
commit c6fc0f1f63
60 changed files with 228 additions and 96 deletions
+45 -1
View File
@@ -1144,6 +1144,50 @@ function serverLoopLocalsAttribute(ctx: CompCtx): string {
return ` data-wrn-loop-locals="\${__wrnexusEncodeLoopLocals({ ${entries} })}"`;
}
function unwrapDirectiveExpression(raw: string): string {
const value = raw.trim();
if (!value.startsWith("{") || !value.endsWith("}")) {
return value;
}
let depth = 0;
let quote: '"' | "'" | "`" | null = null;
let escaped = false;
for (let index = 0; index < value.length; index++) {
const char = value[index]!;
if (escaped) {
escaped = false;
continue;
}
if (quote) {
if (char === "\\") {
escaped = true;
} else if (char === quote) {
quote = null;
}
continue;
}
if (char === '"' || char === "'" || char === "`") {
quote = char;
continue;
}
if (char === "{") depth++;
if (char === "}") depth--;
if (depth === 0 && index < value.length - 1) {
return value;
}
}
return depth === 0 ? value.slice(1, -1).trim() : value;
}
/** Render a component view node into template-literal-ready source. */
function renderComponentNode(node: ViewNode, ctx: CompCtx): string {
if (node.type === "text") return compileText(node.value, ctx);
@@ -1185,7 +1229,7 @@ function renderComponentNode(node: ViewNode, ctx: CompCtx): string {
if (!attr.event && attr.name.startsWith("class:")) {
conditionalClasses.push({
className: attr.name.slice("class:".length),
expression: attr.value,
expression: unwrapDirectiveExpression(attr.value),
});
}
}