fix(tooling): reconcile framework fixes in canonical WireJS checkout

This commit is contained in:
Clintchiz committed 2026-08-26 18:10:58 +05:30
1 parent a077515336
commit 65d63dfbe7
19 files changed
+312 -156

No files matched your search

+52 -13
View File
@@ -1,6 +1,6 @@
"use strict";
// Generated by scripts/build-editor-compiler.mjs. Do not edit directly.
// WRN editor compiler source hash: 3d346a264807ba7b107584dc9a7b505b1d14057b2ad1aa85c5ea890f9b09c272
// WRN editor compiler source hash: 89199942be0196a3d06ea3d30dff80d361253192108bd978b5b80d921195c59f
// WRN editor compiler generator hash: f8c1094b47e695151205899de28cd63d574356d26ac49219c4a43db0f2391ef5
// Generated with TypeScript: 6.0.3
const __nodeRequire = require;
@@ -1202,10 +1202,16 @@ function renderAttrs(attrs, csrId, reactive = null, dynamicExpressions) {
if (expression &&
exprRefsState(expression, reactive.runtimeStateNames) &&
dynamicExpressions) {
const marker = exprRefsState(expression, reactive.stateNames)
? ` data-wrn-bind-${bindIndex++}="${attrEscape(JSON.stringify([attr.name, attr.value]))}"`
: "";
if (isHtmlBooleanAttribute(attr.name)) {
dynamicExpressions.push(`\${(${expression}) ? ${JSON.stringify(` ${attr.name}`)} : ""}`);
return `\x00WRNEACH${dynamicExpressions.length - 1}\x00${marker}`;
}
dynamicExpressions.push(`\${__wrnexusPropAttr(${expression})}`);
const sentinel = `\x00WRNEACH${dynamicExpressions.length - 1}\x00`;
const marker = JSON.stringify([attr.name, attr.value]);
return ` ${attr.name}="${sentinel}" data-wrn-bind-${bindIndex++}="${attrEscape(marker)}"`;
return ` ${attr.name}="${sentinel}"${marker}`;
}
const initial = reactiveAttrValue(attr.value, reactive);
if (initial === null)
@@ -1253,17 +1259,20 @@ function evalStateSeeds(states) {
*/
function substituteReactiveText(raw, reactive, dynamicExpressions) {
const text = substituteTMarkers(raw);
if (!reactive || reactive.stateNames.size === 0)
if (!reactive)
return text;
return text.replace(/\{([^{}]+)\}/g, (whole, inner) => {
const expr = inner.trim();
if (expr.startsWith("t:") || !exprRefsState(expr, reactive.stateNames))
const clientReactive = exprRefsState(expr, reactive.stateNames);
if (expr.startsWith("t:"))
return whole;
if (exprRefsState(expr, reactive.runtimeStateNames) && dynamicExpressions) {
dynamicExpressions.push(`\${__wrnexusEscapeHtml(${expr})}`);
const sentinel = `\x00WRNEACH${dynamicExpressions.length - 1}\x00`;
return `<span data-text="${attrEscape(expr)}">${sentinel}</span>`;
return clientReactive ? `<span data-text="${attrEscape(expr)}">${sentinel}</span>` : sentinel;
}
if (!clientReactive)
return whole;
let value;
try {
value = new Function("with(this){return (" + expr + ");}").call(reactive.scope);
@@ -1339,6 +1348,18 @@ function renderLoopBody(node, locals = []) {
if (attr.boolean) {
return escLit(` ${name}`);
}
// Native boolean attributes inside #if/#each must use presence semantics,
// just like attributes on the page root. disabled="false" still disables
// an HTML input. Component props retain their serialized boolean value.
if (!componentTag &&
!node.attrs.some((a) => a.name === "data-component") &&
isHtmlBooleanAttribute(name)) {
const expression = wholeAttributeExpression(attr.value);
if (expression)
return "${(" + expression + ") ? " + JSON.stringify(` ${name}`) + ' : ""}';
if (attr.value === "false")
return "";
}
return escLit(` ${name}="`) + bakeLoopAttr(attr.value, componentTag) + escLit(`"`);
})
.join("");
@@ -1458,6 +1479,16 @@ function renderNode(node, ssrBindings, csrBindings, apiBindings, loops, reactive
// templateEscape, swapped for its real `${…}` code after escaping.
if (node.type === "each" || node.type === "if") {
loops.push(node.type === "each" ? compileEachExpr(node) : compileIfExpr(node));
const conditions = node.type === "each"
? [node.list]
: node.branches.flatMap((branch) => (branch.cond ? [branch.cond] : []));
// Server-only loader values are not serialized into browser state. Their
// controls must not be re-evaluated by a surrounding component's hydration.
if (reactive &&
conditions.some((condition) => exprRefsState(condition, reactive.runtimeStateNames)) &&
!conditions.some((condition) => exprRefsState(condition, reactive.stateNames))) {
return `\x00WRNEACH${loops.length - 1}\x00`;
}
const definition = node.type === "each"
? {
list: node.list,
@@ -1621,7 +1652,7 @@ function renderNestedComponentInvocation(node, ctx) {
const wholeExpression = wholeAttributeExpression(attr.value);
const compiledValue = wholeExpression
? `\${__wrnProp(${ctx.resolveExpr(wholeExpression)})}`
: compileAttrValue(attr.value, ctx);
: compileAttrValue(attr.value, ctx, attr.name === "pattern");
const rendered = ` ${attr.name}="${compiledValue}"`;
if (!attr.value.includes("{") ||
(!exprRefsState(attr.value, ctx.stateNames) && !exprRefsState(attr.value, ctx.propNames))) {
@@ -2250,7 +2281,7 @@ function generateInner(ast) {
.map((load) => load.name),
];
const runtimeStateNames = runtimeComputedNames(orderedStates, orderedComputed, runtimeRoots);
const reactive = reactiveNames.length > 0
const reactive = reactiveNames.length > 0 || runtimeStateNames.size > 0
? { stateNames: new Set(reactiveNames), runtimeStateNames, scope: seedScope }
: null;
const loops = [];
@@ -2739,7 +2770,7 @@ function compileText(raw, ctx) {
return out + escLit(raw.slice(last));
}
/** Compile an attribute value; `{expr}` is baked server-side (loop vars stay literal). */
function compileAttrValue(raw, ctx) {
function compileAttrValue(raw, ctx, regexPattern = false) {
if (!raw.includes("{"))
return escLit(attrEscape(raw));
let out = "";
@@ -2749,7 +2780,10 @@ function compileAttrValue(raw, ctx) {
while ((m = INTERP_RE.exec(raw))) {
out += escLit(attrEscape(raw.slice(last, m.index)));
const expr = m[1].trim();
if (ctx.loopVars && exprRefsState(expr, ctx.loopVars)) {
if (regexPattern && /^\d+(?:,\d*)?$/.test(expr)) {
out += escLit(attrEscape(m[0])); // Regex quantifiers are not template expressions.
}
else if (ctx.loopVars && exprRefsState(expr, ctx.loopVars)) {
out += escLit(`{${expr}}`); // hydrated per-item by the list renderer
}
else {
@@ -3047,7 +3081,7 @@ function renderComponentNode(node, ctx) {
}
const compiledValue = isExplicitComponentMount && wholeExpression
? `\${__wrnProp(${elementContext.resolveExpr(wholeExpression)})}`
: compileAttrValue(a.value, elementContext);
: compileAttrValue(a.value, elementContext, a.name === "pattern");
/*
* A constraint attribute whose value is only known at render time (a
* component prop defaulting to "") must be decided at render time, so
@@ -3528,7 +3562,7 @@ function __wrnProp(v) {
const value = v !== null && typeof v === "object" ? JSON.stringify(v) : String(v == null ? "" : v);
return __wrnAttr(value);
}
function renderPageComponentAttr(attr, dynamicExpressions, _reactive) {
function renderPageComponentAttr(attr, dynamicExpressions, reactive) {
if (attr.event) {
return ` ${componentEventAttribute(attr.name)}="${attrEscape(attr.value)}"`;
}
@@ -3541,6 +3575,11 @@ function renderPageComponentAttr(attr, dynamicExpressions, _reactive) {
}
dynamicExpressions.push(`\${__wrnexusPropAttr(${expression})}`);
const marker = `\x00WRNEACH${dynamicExpressions.length - 1}\x00`;
if (reactive &&
exprRefsState(expression, reactive.runtimeStateNames) &&
!exprRefsState(expression, reactive.stateNames)) {
return ` ${attr.name}="${marker}"`;
}
// The mount disappears during SSR. Preserve every dynamic component prop
// as a parent-owned binding; server-only expressions simply fail closed in
// the browser, while page state can continue driving the mounted child.
@@ -6229,7 +6268,7 @@ function expandStructuredStateDeclarations(lines, unit) {
});
}
function formatStructuredPropDeclaration(value, unit, depth, printWidth) {
const match = /^([A-Za-z_$][\w$]*\??\s*(?::\s*[^=]+?)?\s*=\s*)([\[{][\s\S]*)$/.exec(value);
const match = /^([A-Za-z_$][\w$]*\??\s*(?::\s*[^=]+?)?\s*=\s*)([[{][\s\S]*)$/.exec(value);
if (!match)
return null;
try {