@barefootjs/jsx 0.31.7 → 0.31.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +136 -59
- package/dist/ir-to-client-js/collect-elements.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop-child-arm.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/loop.d.ts.map +1 -1
- package/dist/ir-to-client-js/control-flow/stringify/template-parse.d.ts +66 -38
- package/dist/ir-to-client-js/control-flow/stringify/template-parse.d.ts.map +1 -1
- package/dist/ir-to-client-js/csr-substitute.d.ts.map +1 -1
- package/dist/ir-to-client-js/emit-registration.d.ts.map +1 -1
- package/dist/ir-to-client-js/html-template.d.ts +15 -1
- package/dist/ir-to-client-js/html-template.d.ts.map +1 -1
- package/dist/ir-to-client-js/imports.d.ts +2 -2
- package/dist/ir-to-client-js/imports.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/__tests__/__snapshots__/doc-examples.test.ts.snap +210 -210
- package/src/__tests__/aliased-destructured-prop-csr.test.ts +8 -2
- package/src/__tests__/csr-template-loop-shadowing.test.ts +5 -2
- package/src/__tests__/env-signal-template-prelude.test.ts +89 -0
- package/src/__tests__/inner-loop-mathml-namespace.test.ts +135 -0
- package/src/__tests__/markup-prop-brand.test.ts +161 -0
- package/src/__tests__/mathml-mapArray-namespace.test.ts +230 -0
- package/src/__tests__/text-slot-escaping.test.ts +21 -12
- package/src/ir-to-client-js/collect-elements.ts +38 -5
- package/src/ir-to-client-js/control-flow/stringify/inner-loop.ts +10 -10
- package/src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts +3 -4
- package/src/ir-to-client-js/control-flow/stringify/loop.ts +18 -14
- package/src/ir-to-client-js/control-flow/stringify/template-parse.ts +142 -78
- package/src/ir-to-client-js/csr-substitute.ts +3 -2
- package/src/ir-to-client-js/emit-registration.ts +56 -4
- package/src/ir-to-client-js/html-template.ts +103 -12
- package/src/ir-to-client-js/imports.ts +4 -0
- package/src/ir-to-client-js/index.ts +6 -1
package/dist/index.js
CHANGED
|
@@ -3351,8 +3351,8 @@ function templateAttrExpr(attrName, valExpr, presenceOrUndefined) {
|
|
|
3351
3351
|
function escapeAttrValueExpr(valExpr) {
|
|
3352
3352
|
return `escapeAttr(${valExpr})`;
|
|
3353
3353
|
}
|
|
3354
|
-
function escapeTextSlotExpr(innerExpr) {
|
|
3355
|
-
return
|
|
3354
|
+
function escapeTextSlotExpr(innerExpr, isMarkup = false) {
|
|
3355
|
+
return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
|
|
3356
3356
|
}
|
|
3357
3357
|
function dangerouslyHtmlChildren(attrs, toExpr) {
|
|
3358
3358
|
const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
|
|
@@ -3629,7 +3629,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
3629
3629
|
case "jsx-children": {
|
|
3630
3630
|
const hoistedRecurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth, loopParams, branchSlotsVar, true);
|
|
3631
3631
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
3632
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
3632
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
3633
3633
|
}
|
|
3634
3634
|
case "literal":
|
|
3635
3635
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -3988,6 +3988,9 @@ function irChildrenToJsExpr(children) {
|
|
|
3988
3988
|
return exprs[0];
|
|
3989
3989
|
return `[${exprs.join(", ")}]`;
|
|
3990
3990
|
}
|
|
3991
|
+
function isSingleElementJsxChildren(nodes) {
|
|
3992
|
+
return nodes.length === 1 && nodes[0].type === "element";
|
|
3993
|
+
}
|
|
3991
3994
|
function irNodeToJsExprs(node) {
|
|
3992
3995
|
switch (node.type) {
|
|
3993
3996
|
case "component": {
|
|
@@ -3996,8 +3999,11 @@ function irNodeToJsExprs(node) {
|
|
|
3996
3999
|
return `${quotePropName(p.name)}: ${attrValueToString(p.value) ?? "undefined"}`;
|
|
3997
4000
|
}
|
|
3998
4001
|
switch (p.value.kind) {
|
|
3999
|
-
case "jsx-children":
|
|
4000
|
-
|
|
4002
|
+
case "jsx-children": {
|
|
4003
|
+
const jsxExpr = irChildrenToJsExpr(p.value.children);
|
|
4004
|
+
const wrapped = p.name !== "children" && isSingleElementJsxChildren(p.value.children) ? `bfMarkup(${jsxExpr})` : jsxExpr;
|
|
4005
|
+
return `get ${quotePropName(p.name)}() { return ${wrapped} }`;
|
|
4006
|
+
}
|
|
4001
4007
|
case "literal":
|
|
4002
4008
|
return `get ${quotePropName(p.name)}() { return ${JSON.stringify(p.value.value)} }`;
|
|
4003
4009
|
case "boolean-shorthand":
|
|
@@ -4056,8 +4062,8 @@ function isSingleRootElement(html) {
|
|
|
4056
4062
|
const closingPattern = new RegExp(`</${tag}>\\s*$`);
|
|
4057
4063
|
return closingPattern.test(html.trim());
|
|
4058
4064
|
}
|
|
4059
|
-
function irToComponentTemplate(node, inlinableConstants, restSpreadNames, propsObjectName) {
|
|
4060
|
-
return irToComponentTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, loopDepth: -1 });
|
|
4065
|
+
function irToComponentTemplate(node, inlinableConstants, restSpreadNames, propsObjectName, markupSlotIds) {
|
|
4066
|
+
return irToComponentTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, loopDepth: -1, markupSlotIds });
|
|
4061
4067
|
}
|
|
4062
4068
|
function irToComponentTemplateWithOpts(node, opts) {
|
|
4063
4069
|
const { inlinableConstants, restSpreadNames, propsObjectName, loopDepth = 0 } = opts;
|
|
@@ -4162,7 +4168,8 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
4162
4168
|
const wrapped = transformExpr(node.expr, node.templateExpr);
|
|
4163
4169
|
const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
|
|
4164
4170
|
if (node.slotId) {
|
|
4165
|
-
|
|
4171
|
+
const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
|
|
4172
|
+
return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
|
|
4166
4173
|
}
|
|
4167
4174
|
return `\${${value}}`;
|
|
4168
4175
|
}
|
|
@@ -4189,7 +4196,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
4189
4196
|
case "jsx-children": {
|
|
4190
4197
|
const hoistedRecurse = (n) => irToComponentTemplateWithOpts(n, { ...opts, inHoistedChildren: true });
|
|
4191
4198
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
4192
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
4199
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
4193
4200
|
}
|
|
4194
4201
|
case "literal":
|
|
4195
4202
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -4310,7 +4317,8 @@ function generateCsrTemplate(node, inlinableConstants, ctx, restSpreadNames, pro
|
|
|
4310
4317
|
}
|
|
4311
4318
|
}
|
|
4312
4319
|
const effectiveUnsafeLocalNames = mergeCsrNullUnsafe(ctx, unsafeLocalNames);
|
|
4313
|
-
|
|
4320
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
4321
|
+
return generateCsrTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, csrEnv, unsafeLocalNames: effectiveUnsafeLocalNames, deferredChildSlots, loopDepth: -1, markupSlotIds });
|
|
4314
4322
|
}
|
|
4315
4323
|
function mergeCsrNullUnsafe(ctx, unsafeLocalNames) {
|
|
4316
4324
|
let merged = null;
|
|
@@ -4491,7 +4499,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
4491
4499
|
const expr = transformed === UNSAFE_TEMPLATE_EXPR ? "''" : transformed;
|
|
4492
4500
|
const value = node.joinArrayChild ? `Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')` : expr;
|
|
4493
4501
|
if (node.slotId) {
|
|
4494
|
-
|
|
4502
|
+
const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
|
|
4503
|
+
return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
|
|
4495
4504
|
}
|
|
4496
4505
|
return `\${${value}}`;
|
|
4497
4506
|
}
|
|
@@ -4521,7 +4530,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
4521
4530
|
case "jsx-children": {
|
|
4522
4531
|
const hoistedRecurse = (n) => generateCsrTemplateWithOpts(n, { ...opts, inHoistedChildren: true });
|
|
4523
4532
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
4524
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
4533
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
4525
4534
|
}
|
|
4526
4535
|
case "literal":
|
|
4527
4536
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -14585,25 +14594,85 @@ var SVG_ROOT_TAGS = new Set([
|
|
|
14585
14594
|
"animateTransform",
|
|
14586
14595
|
"animateMotion"
|
|
14587
14596
|
]);
|
|
14588
|
-
|
|
14597
|
+
var MATHML_ROOT_TAGS = new Set([
|
|
14598
|
+
"math",
|
|
14599
|
+
"mrow",
|
|
14600
|
+
"mfrac",
|
|
14601
|
+
"msup",
|
|
14602
|
+
"msub",
|
|
14603
|
+
"msubsup",
|
|
14604
|
+
"mn",
|
|
14605
|
+
"mi",
|
|
14606
|
+
"mo",
|
|
14607
|
+
"mtext",
|
|
14608
|
+
"munder",
|
|
14609
|
+
"mover",
|
|
14610
|
+
"munderover",
|
|
14611
|
+
"mtable",
|
|
14612
|
+
"mtr",
|
|
14613
|
+
"mtd",
|
|
14614
|
+
"msqrt",
|
|
14615
|
+
"mroot",
|
|
14616
|
+
"mstyle",
|
|
14617
|
+
"merror",
|
|
14618
|
+
"mpadded",
|
|
14619
|
+
"mphantom",
|
|
14620
|
+
"menclose",
|
|
14621
|
+
"semantics",
|
|
14622
|
+
"annotation",
|
|
14623
|
+
"annotation-xml"
|
|
14624
|
+
]);
|
|
14625
|
+
function namespaceForTag(tag) {
|
|
14626
|
+
if (SVG_ROOT_TAGS.has(tag) || SVG_ROOT_TAGS.has(tag.toLowerCase()))
|
|
14627
|
+
return "svg";
|
|
14628
|
+
if (MATHML_ROOT_TAGS.has(tag) || MATHML_ROOT_TAGS.has(tag.toLowerCase()))
|
|
14629
|
+
return "math";
|
|
14630
|
+
return null;
|
|
14631
|
+
}
|
|
14632
|
+
function detectRootNamespaceWrapTag(template) {
|
|
14589
14633
|
const stripped = stripLeadingNonContent(template);
|
|
14590
14634
|
const m = stripped.match(/^<\s*([A-Za-z][A-Za-z0-9-]*)/);
|
|
14591
|
-
if (m)
|
|
14592
|
-
|
|
14593
|
-
if (SVG_ROOT_TAGS.has(tag))
|
|
14594
|
-
return true;
|
|
14595
|
-
return SVG_ROOT_TAGS.has(tag.toLowerCase());
|
|
14596
|
-
}
|
|
14635
|
+
if (m)
|
|
14636
|
+
return namespaceForTag(m[1]);
|
|
14597
14637
|
const branches = extractConditionalBranchTemplates(stripped);
|
|
14598
14638
|
if (branches === null || branches.length === 0)
|
|
14599
|
-
return
|
|
14600
|
-
|
|
14639
|
+
return null;
|
|
14640
|
+
let result;
|
|
14641
|
+
for (const branch of branches) {
|
|
14642
|
+
const branchNs = detectRootNamespaceWrapTag(branch);
|
|
14643
|
+
if (result === undefined) {
|
|
14644
|
+
result = branchNs;
|
|
14645
|
+
} else if (result !== branchNs) {
|
|
14646
|
+
return null;
|
|
14647
|
+
}
|
|
14648
|
+
}
|
|
14649
|
+
return result ?? null;
|
|
14601
14650
|
}
|
|
14602
|
-
function
|
|
14651
|
+
function multiRootTemplateNeedsNamespaceWrap(template) {
|
|
14603
14652
|
const m = stripLeadingNonContent(template).match(/^<\s*([A-Za-z][A-Za-z0-9-]*)/);
|
|
14604
|
-
if (m
|
|
14605
|
-
|
|
14606
|
-
|
|
14653
|
+
if (m) {
|
|
14654
|
+
const tagLower = m[1].toLowerCase();
|
|
14655
|
+
if (tagLower === "svg" || tagLower === "math")
|
|
14656
|
+
return null;
|
|
14657
|
+
}
|
|
14658
|
+
return detectRootNamespaceWrapTag(template);
|
|
14659
|
+
}
|
|
14660
|
+
function namespaceWrapForTemplate(template) {
|
|
14661
|
+
const wrapTag = detectRootNamespaceWrapTag(template);
|
|
14662
|
+
return {
|
|
14663
|
+
wrapTag,
|
|
14664
|
+
childPath: wrapTag ? ".firstElementChild.firstElementChild" : ".firstElementChild"
|
|
14665
|
+
};
|
|
14666
|
+
}
|
|
14667
|
+
function multiRootNamespaceWrapForTemplate(template) {
|
|
14668
|
+
const wrapTag = multiRootTemplateNeedsNamespaceWrap(template);
|
|
14669
|
+
return {
|
|
14670
|
+
wrapTag,
|
|
14671
|
+
childPath: wrapTag ? ".firstElementChild" : ""
|
|
14672
|
+
};
|
|
14673
|
+
}
|
|
14674
|
+
function wrapHtmlForNamespace(html, wrapTag) {
|
|
14675
|
+
return wrapTag ? `<${wrapTag}>${html}</${wrapTag}>` : html;
|
|
14607
14676
|
}
|
|
14608
14677
|
function stripLeadingNonContent(template) {
|
|
14609
14678
|
let s = template.trimStart();
|
|
@@ -14628,32 +14697,26 @@ function extractConditionalBranchTemplates(template) {
|
|
|
14628
14697
|
return findTopLevelTemplateLiterals(expr);
|
|
14629
14698
|
}
|
|
14630
14699
|
function emitTemplateCloneInline(template) {
|
|
14631
|
-
|
|
14632
|
-
|
|
14633
|
-
}
|
|
14634
|
-
return `const __tpl = document.createElement('template'); __tpl.innerHTML = \`${template}\`; return __tpl.content.firstElementChild.cloneNode(true)`;
|
|
14700
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(template);
|
|
14701
|
+
const html = wrapHtmlForNamespace(template, wrapTag);
|
|
14702
|
+
return `const __tpl = document.createElement('template'); __tpl.innerHTML = \`${html}\`; return __tpl.content${childPath}.cloneNode(true)`;
|
|
14635
14703
|
}
|
|
14636
14704
|
function emitHoistedTemplateDecl(lines, indent, tplVar, skeletonTemplate) {
|
|
14637
|
-
const
|
|
14638
|
-
const html =
|
|
14705
|
+
const { wrapTag } = namespaceWrapForTemplate(skeletonTemplate);
|
|
14706
|
+
const html = wrapHtmlForNamespace(skeletonTemplate, wrapTag);
|
|
14639
14707
|
lines.push(`${indent}const ${tplVar} = document.createElement('template')`);
|
|
14640
14708
|
lines.push(`${indent}${tplVar}.innerHTML = \`${html}\``);
|
|
14641
14709
|
}
|
|
14642
14710
|
function hoistedCloneExpr(tplVar, skeletonTemplate) {
|
|
14643
|
-
return
|
|
14711
|
+
return `${tplVar}.content${namespaceWrapForTemplate(skeletonTemplate).childPath}.cloneNode(true)`;
|
|
14644
14712
|
}
|
|
14645
14713
|
function emitTemplateCloneLines(template, indent) {
|
|
14646
|
-
|
|
14647
|
-
|
|
14648
|
-
`${indent}const __tpl = document.createElement('template')`,
|
|
14649
|
-
`${indent}__tpl.innerHTML = \`<svg>${template}</svg>\``,
|
|
14650
|
-
`${indent}return __tpl.content.firstElementChild.firstElementChild.cloneNode(true)`
|
|
14651
|
-
];
|
|
14652
|
-
}
|
|
14714
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(template);
|
|
14715
|
+
const html = wrapHtmlForNamespace(template, wrapTag);
|
|
14653
14716
|
return [
|
|
14654
14717
|
`${indent}const __tpl = document.createElement('template')`,
|
|
14655
|
-
`${indent}__tpl.innerHTML = \`${
|
|
14656
|
-
`${indent}return __tpl.content.
|
|
14718
|
+
`${indent}__tpl.innerHTML = \`${html}\``,
|
|
14719
|
+
`${indent}return __tpl.content${childPath}.cloneNode(true)`
|
|
14657
14720
|
];
|
|
14658
14721
|
}
|
|
14659
14722
|
function emitLoopItemElementSetup(lines, opts) {
|
|
@@ -14685,9 +14748,9 @@ function emitLoopItemElementSetup(lines, opts) {
|
|
|
14685
14748
|
lines.push(`${indent}})()${mountRow ? ")" : ""}`);
|
|
14686
14749
|
}
|
|
14687
14750
|
function emitMultiRootTemplateCloneLines(template, indent, varEl, varExtras) {
|
|
14688
|
-
const
|
|
14689
|
-
const innerHtmlExpr =
|
|
14690
|
-
const parentExpr =
|
|
14751
|
+
const { wrapTag, childPath } = multiRootNamespaceWrapForTemplate(template);
|
|
14752
|
+
const innerHtmlExpr = `\`${wrapHtmlForNamespace(template, wrapTag)}\``;
|
|
14753
|
+
const parentExpr = `__tpl.content${childPath}`;
|
|
14691
14754
|
return [
|
|
14692
14755
|
`${indent}const __tpl = document.createElement('template')`,
|
|
14693
14756
|
`${indent}__tpl.innerHTML = ${innerHtmlExpr}`,
|
|
@@ -14918,6 +14981,9 @@ function jsxChildrenContainComponent(nodes) {
|
|
|
14918
14981
|
}
|
|
14919
14982
|
return false;
|
|
14920
14983
|
}
|
|
14984
|
+
function isSingleElementJsxChildren2(nodes) {
|
|
14985
|
+
return nodes.length === 1 && nodes[0].type === "element";
|
|
14986
|
+
}
|
|
14921
14987
|
function buildRestSpreadNames(ctx) {
|
|
14922
14988
|
const names = new Set;
|
|
14923
14989
|
if (ctx.restPropsName)
|
|
@@ -14954,6 +15020,8 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
14954
15020
|
const jsxExpr = irChildrenToJsExpr(prop.value.children);
|
|
14955
15021
|
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
14956
15022
|
propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`);
|
|
15023
|
+
} else if (prop.name !== "children" && isSingleElementJsxChildren2(prop.value.children)) {
|
|
15024
|
+
propsForInit.push(`get ${quotePropName(prop.name)}() { return bfMarkup(${jsxExpr}) }`);
|
|
14957
15025
|
} else {
|
|
14958
15026
|
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`);
|
|
14959
15027
|
}
|
|
@@ -15094,7 +15162,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
15094
15162
|
reactiveTextSlotIds: new Set(bindings.reactiveTexts.map((t) => t.slotId))
|
|
15095
15163
|
};
|
|
15096
15164
|
skeletonTemplate = buildLoopSkeletonTemplate(l.children[0], skeletonSafeSlots) ?? undefined;
|
|
15097
|
-
if (skeletonTemplate && !
|
|
15165
|
+
if (skeletonTemplate && !detectRootNamespaceWrapTag(skeletonTemplate)) {
|
|
15098
15166
|
skeletonPaths = computeSkeletonSlotPaths(l.children[0], skeletonSafeSlots) ?? undefined;
|
|
15099
15167
|
}
|
|
15100
15168
|
}
|
|
@@ -16013,6 +16081,8 @@ var RUNTIME_IMPORT_CANDIDATES = [
|
|
|
16013
16081
|
"escapeAttr",
|
|
16014
16082
|
"escapeText",
|
|
16015
16083
|
"escapeTextOrNode",
|
|
16084
|
+
"bfMarkup",
|
|
16085
|
+
"escapeTextOrMarkup",
|
|
16016
16086
|
"qsa",
|
|
16017
16087
|
"qsaItem",
|
|
16018
16088
|
"qsaChildScope",
|
|
@@ -17006,6 +17076,13 @@ function csrInlinableConstantsFromCtx(ctx) {
|
|
|
17006
17076
|
}
|
|
17007
17077
|
return out;
|
|
17008
17078
|
}
|
|
17079
|
+
function buildTemplateDefPart(ctx, templateHtml) {
|
|
17080
|
+
const envDecls = ctx.signals.filter((s) => Boolean(s.envReader) && Boolean(s.envFactory)).map((s) => `const [${s.getter}] = ${s.envFactory}()`);
|
|
17081
|
+
if (envDecls.length === 0) {
|
|
17082
|
+
return `template: (${PROPS_PARAM}) => \`${templateHtml}\``;
|
|
17083
|
+
}
|
|
17084
|
+
return `template: (${PROPS_PARAM}) => { ${envDecls.join("; ")}; return \`${templateHtml}\` }`;
|
|
17085
|
+
}
|
|
17009
17086
|
function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
|
|
17010
17087
|
const name = ctx.componentName;
|
|
17011
17088
|
lines.push(`}`);
|
|
@@ -17020,15 +17097,16 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
|
|
|
17020
17097
|
const isCommentScope = _ir.root.type === "fragment" && _ir.root.needsScopeComment || _ir.root.type === "component";
|
|
17021
17098
|
const defParts = [`init: init${name}`];
|
|
17022
17099
|
if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
|
|
17023
|
-
const
|
|
17100
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
17101
|
+
const templateHtml = irToComponentTemplate(_ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds);
|
|
17024
17102
|
if (templateHtml) {
|
|
17025
|
-
defParts.push(
|
|
17103
|
+
defParts.push(buildTemplateDefPart(ctx, templateHtml));
|
|
17026
17104
|
}
|
|
17027
17105
|
} else {
|
|
17028
17106
|
const csrInlinableConstants = csrInlinableConstantsFromCtx(ctx);
|
|
17029
17107
|
const templateHtml = generateCsrTemplate(_ir.root, csrInlinableConstants, ctx, restSpreadNames, ctx.propsObjectName, unsafeLocalNames, ctx.deferredChildSlots);
|
|
17030
17108
|
if (templateHtml) {
|
|
17031
|
-
defParts.push(
|
|
17109
|
+
defParts.push(buildTemplateDefPart(ctx, templateHtml));
|
|
17032
17110
|
}
|
|
17033
17111
|
}
|
|
17034
17112
|
if (isCommentScope) {
|
|
@@ -20272,9 +20350,8 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
|
|
|
20272
20350
|
lines.push(`${indent} ${inner.paramUnwrap}`);
|
|
20273
20351
|
}
|
|
20274
20352
|
{
|
|
20275
|
-
const
|
|
20276
|
-
const innerHtml =
|
|
20277
|
-
const childPath = isSvg ? ".firstElementChild.firstElementChild" : ".firstElementChild";
|
|
20353
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(inner.wrappedTemplate);
|
|
20354
|
+
const innerHtml = wrapTag ? `<${wrapTag}>${inner.wrappedTemplate}</${wrapTag}>` : inner.wrappedTemplate;
|
|
20278
20355
|
lines.push(`${indent} let __bel${uid} = __existing ?? (() => { const __t = document.createElement('template'); __t.innerHTML = \`${innerHtml}\`; return __t.content${childPath}.cloneNode(true) })()`);
|
|
20279
20356
|
}
|
|
20280
20357
|
if (inner.wrappedKey) {
|
|
@@ -21015,14 +21092,14 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
21015
21092
|
lines.push(` let __iterEl = ${containerVar}.children[${childIndexExpr}]`);
|
|
21016
21093
|
if (csrMaterialize) {
|
|
21017
21094
|
lines.push(` if (!__iterEl) {`);
|
|
21018
|
-
const
|
|
21019
|
-
const itemHtml =
|
|
21095
|
+
const { wrapTag, childPath } = csrMaterialize.bodyIsMultiRoot ? multiRootNamespaceWrapForTemplate(csrMaterialize.itemTemplate) : namespaceWrapForTemplate(csrMaterialize.itemTemplate);
|
|
21096
|
+
const itemHtml = wrapHtmlForNamespace(csrMaterialize.itemTemplate, wrapTag);
|
|
21020
21097
|
if (csrMaterialize.bodyIsMultiRoot) {
|
|
21021
21098
|
lines.push(` const __mtpl = document.createElement('template')`);
|
|
21022
21099
|
lines.push(` __mtpl.innerHTML = \`${itemHtml}\``);
|
|
21023
21100
|
lines.push(` const __anchor = ${containerVar}.children[${childIndexExpr}] ?? null`);
|
|
21024
21101
|
lines.push(` let __first = null`);
|
|
21025
|
-
lines.push(` let __sib = __mtpl.content${
|
|
21102
|
+
lines.push(` let __sib = __mtpl.content${childPath}.firstElementChild`);
|
|
21026
21103
|
lines.push(` while (__sib) {`);
|
|
21027
21104
|
lines.push(` const __next = __sib.nextElementSibling`);
|
|
21028
21105
|
lines.push(` const __cloned = __sib.cloneNode(true)`);
|
|
@@ -21034,7 +21111,7 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
21034
21111
|
} else {
|
|
21035
21112
|
lines.push(` const __tpl = document.createElement('template')`);
|
|
21036
21113
|
lines.push(` __tpl.innerHTML = \`${itemHtml}\``);
|
|
21037
|
-
lines.push(` const __cloned = __tpl.content${
|
|
21114
|
+
lines.push(` const __cloned = __tpl.content${childPath}`);
|
|
21038
21115
|
lines.push(` if (__cloned) {`);
|
|
21039
21116
|
lines.push(` const __anchor = ${containerVar}.children[${childIndexExpr}] ?? null`);
|
|
21040
21117
|
lines.push(` ${containerVar}.insertBefore(__cloned, __anchor)`);
|
|
@@ -21104,9 +21181,8 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
21104
21181
|
lines.push(`${innerIndent} __innerEl${uid}.__bfExtras = __innerExtras${uid}`);
|
|
21105
21182
|
lines.push(`${indent} }`);
|
|
21106
21183
|
} else {
|
|
21107
|
-
const
|
|
21108
|
-
const innerHtml =
|
|
21109
|
-
const childPath = isSvg ? ".firstElementChild.firstElementChild" : ".firstElementChild";
|
|
21184
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(emit.wrappedTemplate);
|
|
21185
|
+
const innerHtml = wrapTag ? `<${wrapTag}>${emit.wrappedTemplate}</${wrapTag}>` : emit.wrappedTemplate;
|
|
21110
21186
|
lines.push(`${indent} let __innerEl${uid} = __existing ?? (() => { const __t = document.createElement('template'); __t.innerHTML = \`${innerHtml}\`; return __t.content${childPath}.cloneNode(true) })()`);
|
|
21111
21187
|
}
|
|
21112
21188
|
if (emit.wrappedKey) {
|
|
@@ -22433,7 +22509,8 @@ function generateTemplateOnlyMount(ir, ctx) {
|
|
|
22433
22509
|
restSpreadNames.add(ctx.propsObjectName);
|
|
22434
22510
|
let templateHtml;
|
|
22435
22511
|
if (canGenerateStaticTemplate(ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
|
|
22436
|
-
|
|
22512
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
22513
|
+
templateHtml = irToComponentTemplate(ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds);
|
|
22437
22514
|
}
|
|
22438
22515
|
if (!templateHtml) {
|
|
22439
22516
|
const csrInlinableConstants = csrInlinableConstantsFromCtx(ctx);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"collect-elements.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/collect-elements.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,KAAK,MAAM,EAAoC,KAAK,MAAM,EAAmC,MAAM,aAAa,CAAA;AACzH,OAAO,KAAK,EAAE,eAAe,EAA+H,iBAAiB,EAA0B,oBAAoB,EAAc,UAAU,EAAE,MAAM,YAAY,CAAA;AA2GvQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CA0C7E;AAyBD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,wBAAwB;IACvC;;;;;OAKG;IACH,mBAAmB,CAAC,EAAE,OAAO,CAAA;IAC7B;;;;;OAKG;IACH,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB;;;;;;;OAOG;IACH,cAAc,CAAC,EAAE,OAAO,CAAA;CACzB;AAED,4DAA4D;AAC5D,eAAO,MAAM,sBAAsB,EAAE,wBAIpC,CAAA;AAED;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,cAAc,CAAC,EAAE,MAAM,EACvB,GAAG,CAAC,EAAE,eAAe,EACrB,OAAO,CAAC,EAAE,wBAAwB,GACjC,UAAU,EAAE,CA6Id;
|
|
1
|
+
{"version":3,"file":"collect-elements.d.ts","sourceRoot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AM,EAAE,MAAM,EAAE,CAAC,EACrC,SAAS,EAAE,MAAM,EACjB,iBAAiB,EAAE,SAAS,OAAO,aAAa,EAAE,gBAAgB,EAAE,GAAG,SAAS;AAChF;;;;GAIG;AACH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AACnC;;;;GAIG;AACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,iBAAiB,CAenB;AAED,wBAAgB,4BAA4B,CAC1C,IAAI,EAAE,MAAM,EACZ,GAAG,EAAE,eAAe,EACpB,cAAc,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,EACrC,SAAS,CAAC,EAAE,MAAM,EAClB,iBAAiB,CAAC,EAAE,SAAS,OAAO,aAAa,EAAE,gBAAgB,EAAE;AACrE;;;;;;;;GAQG;AACH,aAAa,CAAC,EAAE,WAAW,CAAC,MAAM,CAAC;AACnC;;;GAGG;AACH,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,GACxB,oBAAoB,EAAE,CA2ExB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"loop-child-arm.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,MAAM,EAAE,MAAM,EACd,EAAE,CAAC,EAAE,MAAM,GACV,IAAI,CAcN;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,MAAM,GACb,IAAI,CAYN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,6BAA6B,EACnC,MAAM,EAAE,MAAM,GACb,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,MAAM,EACd,EAAE,CAAC,EAAE,MAAM,GACV,IAAI,
|
|
1
|
+
{"version":3,"file":"loop-child-arm.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/loop-child-arm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AASH,OAAO,KAAK,EACV,6BAA6B,EAC7B,uBAAuB,EACvB,oBAAoB,EACpB,gBAAgB,EAChB,wBAAwB,EACzB,MAAM,2BAA2B,CAAA;AAClC,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,6BAA6B,CAAA;AAEnE;;;;;;;;;;;;;;GAcG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,SAAS,gBAAgB,EAAE,EACjC,MAAM,EAAE,MAAM,EACd,EAAE,CAAC,EAAE,MAAM,GACV,IAAI,CAcN;AAED;;;;;;;GAOG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,uBAAuB,EAC7B,MAAM,EAAE,MAAM,GACb,IAAI,CAYN;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,kCAAkC,CAChD,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,6BAA6B,EACnC,MAAM,EAAE,MAAM,GACb,IAAI,CAIN;AAED;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CACvC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI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E,aAAa,EACnB,SAAS,GAAE,MAAa,GACvB,IAAI,CA+KN;AAoDD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,
|
|
1
|
+
{"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/loop.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AAWH,OAAO,KAAK,EAAE,mBAAmB,EAAE,QAAQ,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAA;AAEpG;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAC/B,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,SAAS,mBAAmB,EAAE,EACpC,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,eAAe,EAAE,OAAO,CAAC;IAAC,kBAAkB,CAAC,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAClH,IAAI,CAaN;AAED;;;;;;;;;;GAUG;AAEH;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,GAAG,IAAI,CAoBnE;AAYD,wBAAgB,kBAAkB,CAChC,KAAK,EAAE,MAAM,EAAE,EACf,IAAI,EAAE,aAAa,EACnB,SAAS,GAAE,MAAa,GACvB,IAAI,CA+KN;AAoDD,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,EAAE,IAAI,EAAE,cAAc,GAAG,IAAI,CAsH/E"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Helpers for emitting code that parses a template literal into a DOM
|
|
3
|
-
* element clone, while preserving the SVG namespace when the loop
|
|
4
|
-
* root is
|
|
3
|
+
* element clone, while preserving the SVG/MathML namespace when the loop
|
|
4
|
+
* body root is a foreign-content element.
|
|
5
5
|
*
|
|
6
6
|
* Background (#135): the standard pattern
|
|
7
7
|
* `const __tpl = document.createElement('template')`
|
|
@@ -14,60 +14,87 @@
|
|
|
14
14
|
* Editor block when a new edge `<path>` was appended via mapArray and
|
|
15
15
|
* never showed up on the canvas.
|
|
16
16
|
*
|
|
17
|
-
* Fix: when the template's root tag is an SVG
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
* extra level to get the
|
|
17
|
+
* Fix: when the template's root tag is an SVG (or, #1096, MathML) element,
|
|
18
|
+
* wrap the parsed markup in the matching synthetic namespace root
|
|
19
|
+
* (`<svg>` / `<math>`) so the HTML5 parser walks into foreign content and
|
|
20
|
+
* assigns the correct namespace, then descend one extra level to get the
|
|
21
|
+
* real root. The two namespaces share every byte of this machinery —
|
|
22
|
+
* only the wrap tag name differs — so `detectRootNamespaceWrapTag` and
|
|
23
|
+
* `namespaceWrapForTemplate` below are the single door every emitter
|
|
24
|
+
* (in this file and its consumers) reads the wrap decision through.
|
|
21
25
|
*/
|
|
26
|
+
/** Namespaces whose root tags need the synthetic-wrap parser nudge. */
|
|
27
|
+
export type NamespaceWrapTag = 'svg' | 'math';
|
|
22
28
|
/**
|
|
23
|
-
* Decide whether a template literal needs
|
|
24
|
-
* Looks at the first opening tag in the literal. The
|
|
25
|
-
* lexical so that interpolations inside attribute values
|
|
26
|
-
* confuse it.
|
|
29
|
+
* Decide whether a template literal needs foreign-content (SVG or MathML)
|
|
30
|
+
* parsing, and which. Looks at the first opening tag in the literal. The
|
|
31
|
+
* check is purely lexical so that interpolations inside attribute values
|
|
32
|
+
* do not confuse it.
|
|
27
33
|
*
|
|
28
34
|
* Three shapes are recognised:
|
|
29
|
-
* 1. Direct element root — `<circle .../>`
|
|
35
|
+
* 1. Direct element root — `<circle .../>` / `<mrow>...</mrow>`
|
|
30
36
|
* 2. Conditional body (#1088) — `${cond ? `<circle .../>` : `<rect .../>`}`
|
|
31
|
-
* where every result-position template literal
|
|
32
|
-
*
|
|
33
|
-
* bodies; without the wrap the cloned
|
|
34
|
-
* namespace and renders nothing.
|
|
37
|
+
* where every result-position template literal (recursively) resolves
|
|
38
|
+
* to the SAME namespace. The compiler emits this shape for
|
|
39
|
+
* `.map(s => cond ? <a/> : <b/>)` bodies; without the wrap the cloned
|
|
40
|
+
* element ends up in the xhtml namespace and renders nothing.
|
|
35
41
|
* 3. Reactive-conditional body — a branch wrapped in `<!--bf-cond-start:sX-->`
|
|
36
42
|
* / `<!--bf-cond-end:sX-->` markers (emitted for nested reactive
|
|
37
43
|
* conditionals). The check skips leading HTML comments and recurses
|
|
38
44
|
* into the inner `${...}`.
|
|
39
45
|
*
|
|
40
|
-
* Mixed-namespace branches (
|
|
41
|
-
* to no-wrap so the user sees the same broken
|
|
42
|
-
* a silent over-wrap
|
|
46
|
+
* Mixed-namespace branches (HTML+SVG, HTML+MathML, or SVG+MathML)
|
|
47
|
+
* intentionally fall through to no-wrap so the user sees the same broken
|
|
48
|
+
* output as before instead of a silent over-wrap that would drag one
|
|
49
|
+
* branch into the wrong foreign-content namespace.
|
|
43
50
|
*/
|
|
44
|
-
export declare function
|
|
51
|
+
export declare function detectRootNamespaceWrapTag(template: string): NamespaceWrapTag | null;
|
|
45
52
|
/**
|
|
46
53
|
* Wrap decision for MULTI-ROOT (fragment) templates, where the synthetic
|
|
47
|
-
*
|
|
54
|
+
* namespace wrap swallows every sibling root at once (#2233 Copilot
|
|
55
|
+
* review, generalised to MathML in #1096).
|
|
48
56
|
*
|
|
49
|
-
* `
|
|
50
|
-
* templates that's exact, but a fragment whose first root is
|
|
51
|
-
* CONTAINER (`<><svg/><span/></>`)
|
|
52
|
-
*
|
|
53
|
-
*
|
|
54
|
-
*
|
|
55
|
-
*
|
|
57
|
+
* `detectRootNamespaceWrapTag` inspects only the FIRST root tag. For
|
|
58
|
+
* single-root templates that's exact, but a fragment whose first root is
|
|
59
|
+
* the namespace CONTAINER itself (`<><svg/><span/></>`, `<><math/><span/></>`)
|
|
60
|
+
* doesn't need the wrap at all — the HTML parser enters foreign content at
|
|
61
|
+
* `<svg>`/`<math>` on its own — and wrapping would drag the HTML siblings
|
|
62
|
+
* into the foreign namespace (`<span>` becomes an SVGUnknownElement/etc.,
|
|
63
|
+
* silently undrawn). So container-first fragments skip the wrap; only
|
|
64
|
+
* leaf-rooted fragments (`<line>`, `<circle>`, `<mrow>`, ...) get it.
|
|
56
65
|
*
|
|
57
|
-
* Known edge (degenerate, pre-existing):
|
|
58
|
-
*
|
|
59
|
-
* in the HTML namespace — exactly the pre-#2219
|
|
60
|
-
* shape correctly needs a scan of every top-level
|
|
61
|
-
* parser until a real component hits it.
|
|
66
|
+
* Known edge (degenerate, pre-existing): a container-first fragment with
|
|
67
|
+
* LEAF siblings of the same namespace (`<><svg/><line/></>`) leaves the
|
|
68
|
+
* bare leaf siblings in the HTML namespace — exactly the pre-#2219
|
|
69
|
+
* behavior. Deciding that shape correctly needs a scan of every top-level
|
|
70
|
+
* root tag; not worth the parser until a real component hits it.
|
|
62
71
|
*/
|
|
63
|
-
export declare function
|
|
72
|
+
export declare function multiRootTemplateNeedsNamespaceWrap(template: string): NamespaceWrapTag | null;
|
|
73
|
+
/**
|
|
74
|
+
* Single door for the "wrap tag + descent path" pair every namespace-aware
|
|
75
|
+
* clone site needs. Consumers outside this file (`inner-loop.ts`,
|
|
76
|
+
* `loop-child-arm.ts`, `loop.ts`) read the wrap decision through this
|
|
77
|
+
* function instead of re-deriving `isSvg ? '<svg>' : ...` locally — keeps
|
|
78
|
+
* the SVG/MathML wrap code path in exactly one place (#1096).
|
|
79
|
+
*/
|
|
80
|
+
export declare function namespaceWrapForTemplate(template: string): {
|
|
81
|
+
wrapTag: NamespaceWrapTag | null;
|
|
82
|
+
childPath: string;
|
|
83
|
+
};
|
|
84
|
+
/** `namespaceWrapForTemplate`, but for the multi-root fragment predicate. */
|
|
85
|
+
export declare function multiRootNamespaceWrapForTemplate(template: string): {
|
|
86
|
+
wrapTag: NamespaceWrapTag | null;
|
|
87
|
+
childPath: string;
|
|
88
|
+
};
|
|
89
|
+
/** Wrap `html` in the namespace's synthetic root tag, or return it as-is. */
|
|
90
|
+
export declare function wrapHtmlForNamespace(html: string, wrapTag: NamespaceWrapTag | null): string;
|
|
64
91
|
/**
|
|
65
92
|
* Build the inline template-clone expression as one line.
|
|
66
93
|
*
|
|
67
94
|
* ` const __tpl = document.createElement('template'); __tpl.innerHTML = \`${template}\`; return __tpl.content.firstElementChild.cloneNode(true) `
|
|
68
95
|
*
|
|
69
|
-
* For SVG roots, the `innerHTML` is wrapped in
|
|
70
|
-
* traversal descends one extra level.
|
|
96
|
+
* For SVG/MathML roots, the `innerHTML` is wrapped in the matching
|
|
97
|
+
* namespace root tag and the traversal descends one extra level.
|
|
71
98
|
*/
|
|
72
99
|
export declare function emitTemplateCloneInline(template: string): string;
|
|
73
100
|
/**
|
|
@@ -78,9 +105,10 @@ export declare function emitTemplateCloneInline(template: string): string;
|
|
|
78
105
|
* STATIC-ONLY skeleton produced by `buildLoopSkeletonTemplate` (dynamic attrs
|
|
79
106
|
* omitted, text markers empty) — never the per-row interpolated `template`.
|
|
80
107
|
*
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
83
|
-
* the interpolated template, so the same wrap decision
|
|
108
|
+
* Namespace wrap mirrors `emitTemplateCloneLines` (#135 / #1088 / #1096):
|
|
109
|
+
* `detectRootNamespaceWrapTag` is re-checked against the skeleton (same
|
|
110
|
+
* root tag as the interpolated template, so the same wrap decision
|
|
111
|
+
* applies).
|
|
84
112
|
*/
|
|
85
113
|
export declare function emitHoistedTemplateDecl(lines: string[], indent: string, tplVar: string, skeletonTemplate: string): void;
|
|
86
114
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-parse.d.ts","sourceRoot":"","sources":["../../../../src/ir-to-client-js/control-flow/stringify/template-parse.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"template-parse.d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;AAED;;;;;;;;GAQG;AACH,wBAAgB,uCAAuC,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAUjF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,sCAAsC,CAAC,QAAQ,EAAE,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAkBpF;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,mBAAmB,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,CAQ/D;AAED;;;;;;;;;;;;GAYG;AACH,wBAAgB,kBAAkB,CAChC,OAAO,EAAE,SAAS,UAAU,EAAE,EAC9B,KAAK,EAAE,SAAS,QAAQ,EAAE,EAC1B,eAAe,EAAE,MAAM,GAAG,IAAI,GAC7B,MAAM,CA4BR"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"emit-registration.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/emit-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"emit-registration.d.ts","sourceRoot":"","sources":["../../src/ir-to-client-js/emit-registration.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,WAAW,EAAc,MAAM,EAAE,eAAe,EAAc,MAAM,aAAa,CAAA;AAC/F,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,YAAY,CAAA;AAMjD;;;;;;;;;;;GAWG;AACH,wBAAgB,kBAAkB,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,EAAE,UAAU,CAAC,EAAE,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,IAAI,CAmD9G;AAED;;;;;;GAMG;AACH,wBAAgB,uBAAuB,CACrC,GAAG,EAAE,eAAe,EACpB,KAAK,EAAE,eAAe,EACtB,MAAM,EAAE,MAAM,GACb;IACD,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;IACvC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAC9B,CAGA;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,4BAA4B,CAAC,GAAG,EAAE,eAAe,GAAG,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAMtF;AAkDD,4EAA4E;AAC5E;;;;GAIG;AACH,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,MAAM,EAAE,EACf,GAAG,EAAE,eAAe,EACpB,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,eAAe;AACtB;;;;;;GAMG;AACH,YAAY,CAAC,EAAE;IAAE,kBAAkB,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAAC,gBAAgB,EAAE,GAAG,CAAC,MAAM,CAAC,CAAA;CAAE,GACxF,MAAM,CAyFR"}
|
|
@@ -323,6 +323,20 @@ export interface TemplateOptions {
|
|
|
323
323
|
* the template phase agree on which children defer (dropped-prop fix).
|
|
324
324
|
*/
|
|
325
325
|
deferredChildSlots?: ReadonlySet<string>;
|
|
326
|
+
/**
|
|
327
|
+
* Slot ids of top-level, non-conditional dynamic expressions
|
|
328
|
+
* (`ctx.dynamicElements`, populated by `collectElements` — the exact set
|
|
329
|
+
* `emit-reactive.ts`'s `emitDynamicTextUpdates` claims `kind: 'markup'`
|
|
330
|
+
* for on the REACTIVE side, #2651). When a text-marker expression's
|
|
331
|
+
* `slotId` is a member, `escapeTextSlotExpr` emits `escapeTextOrMarkup`
|
|
332
|
+
* instead of `escapeText` so a `bfMarkup()`-branded prop value (a JSX
|
|
333
|
+
* element passed at a non-`children` component prop position) reaches
|
|
334
|
+
* the initial-render template raw, matching what the reactive writer
|
|
335
|
+
* already does via `escapeTextOrNode`. Computed once per component from
|
|
336
|
+
* `ctx.dynamicElements` by `irToComponentTemplate` / `generateCsrTemplate`
|
|
337
|
+
* — never re-derived here.
|
|
338
|
+
*/
|
|
339
|
+
markupSlotIds?: ReadonlySet<string>;
|
|
326
340
|
}
|
|
327
341
|
/**
|
|
328
342
|
* Generate HTML template for registerTemplate().
|
|
@@ -333,7 +347,7 @@ export interface TemplateOptions {
|
|
|
333
347
|
* - Local constant references are inlined with their resolved values (#343)
|
|
334
348
|
* - bf markers ARE included so client code can find elements
|
|
335
349
|
*/
|
|
336
|
-
export declare function irToComponentTemplate(node: IRNode, inlinableConstants?: Map<string, string>, restSpreadNames?: Set<string>, propsObjectName?: string | null): string;
|
|
350
|
+
export declare function irToComponentTemplate(node: IRNode, inlinableConstants?: Map<string, string>, restSpreadNames?: Set<string>, propsObjectName?: string | null, markupSlotIds?: ReadonlySet<string>): string;
|
|
337
351
|
/**
|
|
338
352
|
* Check if a component can have a simple static template generated.
|
|
339
353
|
* Returns false if the component has:
|