@barefootjs/vite 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/package.json +6 -6
package/dist/index.js
CHANGED
|
@@ -3113,8 +3113,8 @@ function templateAttrExpr(attrName, valExpr, presenceOrUndefined) {
|
|
|
3113
3113
|
function escapeAttrValueExpr(valExpr) {
|
|
3114
3114
|
return `escapeAttr(${valExpr})`;
|
|
3115
3115
|
}
|
|
3116
|
-
function escapeTextSlotExpr(innerExpr) {
|
|
3117
|
-
return
|
|
3116
|
+
function escapeTextSlotExpr(innerExpr, isMarkup = false) {
|
|
3117
|
+
return `${isMarkup ? "escapeTextOrMarkup" : "escapeText"}(${innerExpr})`;
|
|
3118
3118
|
}
|
|
3119
3119
|
function dangerouslyHtmlChildren(attrs, toExpr) {
|
|
3120
3120
|
const attr = attrs.find((a) => a.name === "dangerouslySetInnerHTML");
|
|
@@ -3391,7 +3391,7 @@ function irToHtmlTemplate(node, restSpreadNames, loopDepth = 0, loopParams, bran
|
|
|
3391
3391
|
case "jsx-children": {
|
|
3392
3392
|
const hoistedRecurse = (n) => irToHtmlTemplate(n, restSpreadNames, loopDepth, loopParams, branchSlotsVar, true);
|
|
3393
3393
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
3394
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
3394
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
3395
3395
|
}
|
|
3396
3396
|
case "literal":
|
|
3397
3397
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -3750,6 +3750,9 @@ function irChildrenToJsExpr(children) {
|
|
|
3750
3750
|
return exprs[0];
|
|
3751
3751
|
return `[${exprs.join(", ")}]`;
|
|
3752
3752
|
}
|
|
3753
|
+
function isSingleElementJsxChildren(nodes) {
|
|
3754
|
+
return nodes.length === 1 && nodes[0].type === "element";
|
|
3755
|
+
}
|
|
3753
3756
|
function irNodeToJsExprs(node) {
|
|
3754
3757
|
switch (node.type) {
|
|
3755
3758
|
case "component": {
|
|
@@ -3758,8 +3761,11 @@ function irNodeToJsExprs(node) {
|
|
|
3758
3761
|
return `${quotePropName(p.name)}: ${attrValueToString(p.value) ?? "undefined"}`;
|
|
3759
3762
|
}
|
|
3760
3763
|
switch (p.value.kind) {
|
|
3761
|
-
case "jsx-children":
|
|
3762
|
-
|
|
3764
|
+
case "jsx-children": {
|
|
3765
|
+
const jsxExpr = irChildrenToJsExpr(p.value.children);
|
|
3766
|
+
const wrapped = p.name !== "children" && isSingleElementJsxChildren(p.value.children) ? `bfMarkup(${jsxExpr})` : jsxExpr;
|
|
3767
|
+
return `get ${quotePropName(p.name)}() { return ${wrapped} }`;
|
|
3768
|
+
}
|
|
3763
3769
|
case "literal":
|
|
3764
3770
|
return `get ${quotePropName(p.name)}() { return ${JSON.stringify(p.value.value)} }`;
|
|
3765
3771
|
case "boolean-shorthand":
|
|
@@ -3818,8 +3824,8 @@ function isSingleRootElement(html) {
|
|
|
3818
3824
|
const closingPattern = new RegExp(`</${tag}>\\s*$`);
|
|
3819
3825
|
return closingPattern.test(html.trim());
|
|
3820
3826
|
}
|
|
3821
|
-
function irToComponentTemplate(node, inlinableConstants, restSpreadNames, propsObjectName) {
|
|
3822
|
-
return irToComponentTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, loopDepth: -1 });
|
|
3827
|
+
function irToComponentTemplate(node, inlinableConstants, restSpreadNames, propsObjectName, markupSlotIds) {
|
|
3828
|
+
return irToComponentTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, loopDepth: -1, markupSlotIds });
|
|
3823
3829
|
}
|
|
3824
3830
|
function irToComponentTemplateWithOpts(node, opts) {
|
|
3825
3831
|
const { inlinableConstants, restSpreadNames, propsObjectName, loopDepth = 0 } = opts;
|
|
@@ -3924,7 +3930,8 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
3924
3930
|
const wrapped = transformExpr(node.expr, node.templateExpr);
|
|
3925
3931
|
const value = node.joinArrayChild ? `Array.isArray(${wrapped}) ? ${wrapped}.join('') : (${wrapped} ?? '')` : wrapped;
|
|
3926
3932
|
if (node.slotId) {
|
|
3927
|
-
|
|
3933
|
+
const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
|
|
3934
|
+
return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(wrapped, isMarkup)}}<!--/-->`;
|
|
3928
3935
|
}
|
|
3929
3936
|
return `\${${value}}`;
|
|
3930
3937
|
}
|
|
@@ -3951,7 +3958,7 @@ function irToComponentTemplateWithOpts(node, opts) {
|
|
|
3951
3958
|
case "jsx-children": {
|
|
3952
3959
|
const hoistedRecurse = (n) => irToComponentTemplateWithOpts(n, { ...opts, inHoistedChildren: true });
|
|
3953
3960
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
3954
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
3961
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
3955
3962
|
}
|
|
3956
3963
|
case "literal":
|
|
3957
3964
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -4072,7 +4079,8 @@ function generateCsrTemplate(node, inlinableConstants, ctx, restSpreadNames, pro
|
|
|
4072
4079
|
}
|
|
4073
4080
|
}
|
|
4074
4081
|
const effectiveUnsafeLocalNames = mergeCsrNullUnsafe(ctx, unsafeLocalNames);
|
|
4075
|
-
|
|
4082
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
4083
|
+
return generateCsrTemplateWithOpts(node, { inlinableConstants, restSpreadNames, propsObjectName, csrEnv, unsafeLocalNames: effectiveUnsafeLocalNames, deferredChildSlots, loopDepth: -1, markupSlotIds });
|
|
4076
4084
|
}
|
|
4077
4085
|
function mergeCsrNullUnsafe(ctx, unsafeLocalNames) {
|
|
4078
4086
|
let merged = null;
|
|
@@ -4253,7 +4261,8 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
4253
4261
|
const expr = transformed === UNSAFE_TEMPLATE_EXPR ? "''" : transformed;
|
|
4254
4262
|
const value = node.joinArrayChild ? `Array.isArray(${expr}) ? ${expr}.join('') : (${expr} ?? '')` : expr;
|
|
4255
4263
|
if (node.slotId) {
|
|
4256
|
-
|
|
4264
|
+
const isMarkup = opts.markupSlotIds?.has(node.slotId) ?? false;
|
|
4265
|
+
return `<!--bf:${node.slotId}-->\${${node.joinArrayChild ? value : escapeTextSlotExpr(expr, isMarkup)}}<!--/-->`;
|
|
4257
4266
|
}
|
|
4258
4267
|
return `\${${value}}`;
|
|
4259
4268
|
}
|
|
@@ -4283,7 +4292,7 @@ function generateCsrTemplateWithOpts(node, opts) {
|
|
|
4283
4292
|
case "jsx-children": {
|
|
4284
4293
|
const hoistedRecurse = (n) => generateCsrTemplateWithOpts(n, { ...opts, inHoistedChildren: true });
|
|
4285
4294
|
const childHtml = p.value.children.map((c) => hoistedRecurse(c)).join("");
|
|
4286
|
-
return `${quotePropName(p.name)}: \`${childHtml}
|
|
4295
|
+
return p.name === "children" ? `${quotePropName(p.name)}: \`${childHtml}\`` : `${quotePropName(p.name)}: bfMarkup(\`${childHtml}\`)`;
|
|
4287
4296
|
}
|
|
4288
4297
|
case "literal":
|
|
4289
4298
|
return `${quotePropName(p.name)}: ${JSON.stringify(p.value.value)}`;
|
|
@@ -13988,25 +13997,85 @@ var SVG_ROOT_TAGS = new Set([
|
|
|
13988
13997
|
"animateTransform",
|
|
13989
13998
|
"animateMotion"
|
|
13990
13999
|
]);
|
|
13991
|
-
|
|
14000
|
+
var MATHML_ROOT_TAGS = new Set([
|
|
14001
|
+
"math",
|
|
14002
|
+
"mrow",
|
|
14003
|
+
"mfrac",
|
|
14004
|
+
"msup",
|
|
14005
|
+
"msub",
|
|
14006
|
+
"msubsup",
|
|
14007
|
+
"mn",
|
|
14008
|
+
"mi",
|
|
14009
|
+
"mo",
|
|
14010
|
+
"mtext",
|
|
14011
|
+
"munder",
|
|
14012
|
+
"mover",
|
|
14013
|
+
"munderover",
|
|
14014
|
+
"mtable",
|
|
14015
|
+
"mtr",
|
|
14016
|
+
"mtd",
|
|
14017
|
+
"msqrt",
|
|
14018
|
+
"mroot",
|
|
14019
|
+
"mstyle",
|
|
14020
|
+
"merror",
|
|
14021
|
+
"mpadded",
|
|
14022
|
+
"mphantom",
|
|
14023
|
+
"menclose",
|
|
14024
|
+
"semantics",
|
|
14025
|
+
"annotation",
|
|
14026
|
+
"annotation-xml"
|
|
14027
|
+
]);
|
|
14028
|
+
function namespaceForTag(tag) {
|
|
14029
|
+
if (SVG_ROOT_TAGS.has(tag) || SVG_ROOT_TAGS.has(tag.toLowerCase()))
|
|
14030
|
+
return "svg";
|
|
14031
|
+
if (MATHML_ROOT_TAGS.has(tag) || MATHML_ROOT_TAGS.has(tag.toLowerCase()))
|
|
14032
|
+
return "math";
|
|
14033
|
+
return null;
|
|
14034
|
+
}
|
|
14035
|
+
function detectRootNamespaceWrapTag(template) {
|
|
13992
14036
|
const stripped = stripLeadingNonContent(template);
|
|
13993
14037
|
const m = stripped.match(/^<\s*([A-Za-z][A-Za-z0-9-]*)/);
|
|
13994
|
-
if (m)
|
|
13995
|
-
|
|
13996
|
-
if (SVG_ROOT_TAGS.has(tag))
|
|
13997
|
-
return true;
|
|
13998
|
-
return SVG_ROOT_TAGS.has(tag.toLowerCase());
|
|
13999
|
-
}
|
|
14038
|
+
if (m)
|
|
14039
|
+
return namespaceForTag(m[1]);
|
|
14000
14040
|
const branches = extractConditionalBranchTemplates(stripped);
|
|
14001
14041
|
if (branches === null || branches.length === 0)
|
|
14002
|
-
return
|
|
14003
|
-
|
|
14042
|
+
return null;
|
|
14043
|
+
let result;
|
|
14044
|
+
for (const branch of branches) {
|
|
14045
|
+
const branchNs = detectRootNamespaceWrapTag(branch);
|
|
14046
|
+
if (result === undefined) {
|
|
14047
|
+
result = branchNs;
|
|
14048
|
+
} else if (result !== branchNs) {
|
|
14049
|
+
return null;
|
|
14050
|
+
}
|
|
14051
|
+
}
|
|
14052
|
+
return result ?? null;
|
|
14004
14053
|
}
|
|
14005
|
-
function
|
|
14054
|
+
function multiRootTemplateNeedsNamespaceWrap(template) {
|
|
14006
14055
|
const m = stripLeadingNonContent(template).match(/^<\s*([A-Za-z][A-Za-z0-9-]*)/);
|
|
14007
|
-
if (m
|
|
14008
|
-
|
|
14009
|
-
|
|
14056
|
+
if (m) {
|
|
14057
|
+
const tagLower = m[1].toLowerCase();
|
|
14058
|
+
if (tagLower === "svg" || tagLower === "math")
|
|
14059
|
+
return null;
|
|
14060
|
+
}
|
|
14061
|
+
return detectRootNamespaceWrapTag(template);
|
|
14062
|
+
}
|
|
14063
|
+
function namespaceWrapForTemplate(template) {
|
|
14064
|
+
const wrapTag = detectRootNamespaceWrapTag(template);
|
|
14065
|
+
return {
|
|
14066
|
+
wrapTag,
|
|
14067
|
+
childPath: wrapTag ? ".firstElementChild.firstElementChild" : ".firstElementChild"
|
|
14068
|
+
};
|
|
14069
|
+
}
|
|
14070
|
+
function multiRootNamespaceWrapForTemplate(template) {
|
|
14071
|
+
const wrapTag = multiRootTemplateNeedsNamespaceWrap(template);
|
|
14072
|
+
return {
|
|
14073
|
+
wrapTag,
|
|
14074
|
+
childPath: wrapTag ? ".firstElementChild" : ""
|
|
14075
|
+
};
|
|
14076
|
+
}
|
|
14077
|
+
function wrapHtmlForNamespace(html, wrapTag) {
|
|
14078
|
+
return wrapTag ? `<${wrapTag}>${html}</${wrapTag}>` : html;
|
|
14010
14079
|
}
|
|
14011
14080
|
function stripLeadingNonContent(template) {
|
|
14012
14081
|
let s = template.trimStart();
|
|
@@ -14031,32 +14100,26 @@ function extractConditionalBranchTemplates(template) {
|
|
|
14031
14100
|
return findTopLevelTemplateLiterals(expr);
|
|
14032
14101
|
}
|
|
14033
14102
|
function emitTemplateCloneInline(template) {
|
|
14034
|
-
|
|
14035
|
-
|
|
14036
|
-
}
|
|
14037
|
-
return `const __tpl = document.createElement('template'); __tpl.innerHTML = \`${template}\`; return __tpl.content.firstElementChild.cloneNode(true)`;
|
|
14103
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(template);
|
|
14104
|
+
const html = wrapHtmlForNamespace(template, wrapTag);
|
|
14105
|
+
return `const __tpl = document.createElement('template'); __tpl.innerHTML = \`${html}\`; return __tpl.content${childPath}.cloneNode(true)`;
|
|
14038
14106
|
}
|
|
14039
14107
|
function emitHoistedTemplateDecl(lines, indent, tplVar, skeletonTemplate) {
|
|
14040
|
-
const
|
|
14041
|
-
const html =
|
|
14108
|
+
const { wrapTag } = namespaceWrapForTemplate(skeletonTemplate);
|
|
14109
|
+
const html = wrapHtmlForNamespace(skeletonTemplate, wrapTag);
|
|
14042
14110
|
lines.push(`${indent}const ${tplVar} = document.createElement('template')`);
|
|
14043
14111
|
lines.push(`${indent}${tplVar}.innerHTML = \`${html}\``);
|
|
14044
14112
|
}
|
|
14045
14113
|
function hoistedCloneExpr(tplVar, skeletonTemplate) {
|
|
14046
|
-
return
|
|
14114
|
+
return `${tplVar}.content${namespaceWrapForTemplate(skeletonTemplate).childPath}.cloneNode(true)`;
|
|
14047
14115
|
}
|
|
14048
14116
|
function emitTemplateCloneLines(template, indent) {
|
|
14049
|
-
|
|
14050
|
-
|
|
14051
|
-
`${indent}const __tpl = document.createElement('template')`,
|
|
14052
|
-
`${indent}__tpl.innerHTML = \`<svg>${template}</svg>\``,
|
|
14053
|
-
`${indent}return __tpl.content.firstElementChild.firstElementChild.cloneNode(true)`
|
|
14054
|
-
];
|
|
14055
|
-
}
|
|
14117
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(template);
|
|
14118
|
+
const html = wrapHtmlForNamespace(template, wrapTag);
|
|
14056
14119
|
return [
|
|
14057
14120
|
`${indent}const __tpl = document.createElement('template')`,
|
|
14058
|
-
`${indent}__tpl.innerHTML = \`${
|
|
14059
|
-
`${indent}return __tpl.content.
|
|
14121
|
+
`${indent}__tpl.innerHTML = \`${html}\``,
|
|
14122
|
+
`${indent}return __tpl.content${childPath}.cloneNode(true)`
|
|
14060
14123
|
];
|
|
14061
14124
|
}
|
|
14062
14125
|
function emitLoopItemElementSetup(lines, opts) {
|
|
@@ -14088,9 +14151,9 @@ function emitLoopItemElementSetup(lines, opts) {
|
|
|
14088
14151
|
lines.push(`${indent}})()${mountRow ? ")" : ""}`);
|
|
14089
14152
|
}
|
|
14090
14153
|
function emitMultiRootTemplateCloneLines(template, indent, varEl, varExtras) {
|
|
14091
|
-
const
|
|
14092
|
-
const innerHtmlExpr =
|
|
14093
|
-
const parentExpr =
|
|
14154
|
+
const { wrapTag, childPath } = multiRootNamespaceWrapForTemplate(template);
|
|
14155
|
+
const innerHtmlExpr = `\`${wrapHtmlForNamespace(template, wrapTag)}\``;
|
|
14156
|
+
const parentExpr = `__tpl.content${childPath}`;
|
|
14094
14157
|
return [
|
|
14095
14158
|
`${indent}const __tpl = document.createElement('template')`,
|
|
14096
14159
|
`${indent}__tpl.innerHTML = ${innerHtmlExpr}`,
|
|
@@ -14321,6 +14384,9 @@ function jsxChildrenContainComponent(nodes) {
|
|
|
14321
14384
|
}
|
|
14322
14385
|
return false;
|
|
14323
14386
|
}
|
|
14387
|
+
function isSingleElementJsxChildren2(nodes) {
|
|
14388
|
+
return nodes.length === 1 && nodes[0].type === "element";
|
|
14389
|
+
}
|
|
14324
14390
|
function buildRestSpreadNames(ctx) {
|
|
14325
14391
|
const names = new Set;
|
|
14326
14392
|
if (ctx.restPropsName)
|
|
@@ -14357,6 +14423,8 @@ function buildComponentPropsExpr(props, ctx) {
|
|
|
14357
14423
|
const jsxExpr = irChildrenToJsExpr(prop.value.children);
|
|
14358
14424
|
if (jsxChildrenContainComponent(prop.value.children)) {
|
|
14359
14425
|
propsForInit.push(`get ${quotePropName(prop.name)}() { return __slot(() => ${jsxExpr}) }`);
|
|
14426
|
+
} else if (prop.name !== "children" && isSingleElementJsxChildren2(prop.value.children)) {
|
|
14427
|
+
propsForInit.push(`get ${quotePropName(prop.name)}() { return bfMarkup(${jsxExpr}) }`);
|
|
14360
14428
|
} else {
|
|
14361
14429
|
propsForInit.push(`get ${quotePropName(prop.name)}() { return ${jsxExpr} }`);
|
|
14362
14430
|
}
|
|
@@ -14497,7 +14565,7 @@ function collectElements(node, ctx, siblingOffsets, insideConditional = false) {
|
|
|
14497
14565
|
reactiveTextSlotIds: new Set(bindings.reactiveTexts.map((t) => t.slotId))
|
|
14498
14566
|
};
|
|
14499
14567
|
skeletonTemplate = buildLoopSkeletonTemplate(l.children[0], skeletonSafeSlots) ?? undefined;
|
|
14500
|
-
if (skeletonTemplate && !
|
|
14568
|
+
if (skeletonTemplate && !detectRootNamespaceWrapTag(skeletonTemplate)) {
|
|
14501
14569
|
skeletonPaths = computeSkeletonSlotPaths(l.children[0], skeletonSafeSlots) ?? undefined;
|
|
14502
14570
|
}
|
|
14503
14571
|
}
|
|
@@ -15416,6 +15484,8 @@ var RUNTIME_IMPORT_CANDIDATES = [
|
|
|
15416
15484
|
"escapeAttr",
|
|
15417
15485
|
"escapeText",
|
|
15418
15486
|
"escapeTextOrNode",
|
|
15487
|
+
"bfMarkup",
|
|
15488
|
+
"escapeTextOrMarkup",
|
|
15419
15489
|
"qsa",
|
|
15420
15490
|
"qsaItem",
|
|
15421
15491
|
"qsaChildScope",
|
|
@@ -16391,6 +16461,13 @@ function csrInlinableConstantsFromCtx(ctx) {
|
|
|
16391
16461
|
}
|
|
16392
16462
|
return out;
|
|
16393
16463
|
}
|
|
16464
|
+
function buildTemplateDefPart(ctx, templateHtml) {
|
|
16465
|
+
const envDecls = ctx.signals.filter((s) => Boolean(s.envReader) && Boolean(s.envFactory)).map((s) => `const [${s.getter}] = ${s.envFactory}()`);
|
|
16466
|
+
if (envDecls.length === 0) {
|
|
16467
|
+
return `template: (${PROPS_PARAM}) => \`${templateHtml}\``;
|
|
16468
|
+
}
|
|
16469
|
+
return `template: (${PROPS_PARAM}) => { ${envDecls.join("; ")}; return \`${templateHtml}\` }`;
|
|
16470
|
+
}
|
|
16394
16471
|
function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
|
|
16395
16472
|
const name = ctx.componentName;
|
|
16396
16473
|
lines.push(`}`);
|
|
@@ -16405,15 +16482,16 @@ function emitRegistrationAndHydration(lines, ctx, _ir, graph, inlinability) {
|
|
|
16405
16482
|
const isCommentScope = _ir.root.type === "fragment" && _ir.root.needsScopeComment || _ir.root.type === "component";
|
|
16406
16483
|
const defParts = [`init: init${name}`];
|
|
16407
16484
|
if (canGenerateStaticTemplate(_ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
|
|
16408
|
-
const
|
|
16485
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
16486
|
+
const templateHtml = irToComponentTemplate(_ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds);
|
|
16409
16487
|
if (templateHtml) {
|
|
16410
|
-
defParts.push(
|
|
16488
|
+
defParts.push(buildTemplateDefPart(ctx, templateHtml));
|
|
16411
16489
|
}
|
|
16412
16490
|
} else {
|
|
16413
16491
|
const csrInlinableConstants = csrInlinableConstantsFromCtx(ctx);
|
|
16414
16492
|
const templateHtml = generateCsrTemplate(_ir.root, csrInlinableConstants, ctx, restSpreadNames, ctx.propsObjectName, unsafeLocalNames, ctx.deferredChildSlots);
|
|
16415
16493
|
if (templateHtml) {
|
|
16416
|
-
defParts.push(
|
|
16494
|
+
defParts.push(buildTemplateDefPart(ctx, templateHtml));
|
|
16417
16495
|
}
|
|
16418
16496
|
}
|
|
16419
16497
|
if (isCommentScope) {
|
|
@@ -19631,9 +19709,8 @@ function stringifyBranchInnerLoops(lines, plan, indent, pc) {
|
|
|
19631
19709
|
lines.push(`${indent} ${inner.paramUnwrap}`);
|
|
19632
19710
|
}
|
|
19633
19711
|
{
|
|
19634
|
-
const
|
|
19635
|
-
const innerHtml =
|
|
19636
|
-
const childPath = isSvg ? ".firstElementChild.firstElementChild" : ".firstElementChild";
|
|
19712
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(inner.wrappedTemplate);
|
|
19713
|
+
const innerHtml = wrapTag ? `<${wrapTag}>${inner.wrappedTemplate}</${wrapTag}>` : inner.wrappedTemplate;
|
|
19637
19714
|
lines.push(`${indent} let __bel${uid} = __existing ?? (() => { const __t = document.createElement('template'); __t.innerHTML = \`${innerHtml}\`; return __t.content${childPath}.cloneNode(true) })()`);
|
|
19638
19715
|
}
|
|
19639
19716
|
if (inner.wrappedKey) {
|
|
@@ -20374,14 +20451,14 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
20374
20451
|
lines.push(` let __iterEl = ${containerVar}.children[${childIndexExpr}]`);
|
|
20375
20452
|
if (csrMaterialize) {
|
|
20376
20453
|
lines.push(` if (!__iterEl) {`);
|
|
20377
|
-
const
|
|
20378
|
-
const itemHtml =
|
|
20454
|
+
const { wrapTag, childPath } = csrMaterialize.bodyIsMultiRoot ? multiRootNamespaceWrapForTemplate(csrMaterialize.itemTemplate) : namespaceWrapForTemplate(csrMaterialize.itemTemplate);
|
|
20455
|
+
const itemHtml = wrapHtmlForNamespace(csrMaterialize.itemTemplate, wrapTag);
|
|
20379
20456
|
if (csrMaterialize.bodyIsMultiRoot) {
|
|
20380
20457
|
lines.push(` const __mtpl = document.createElement('template')`);
|
|
20381
20458
|
lines.push(` __mtpl.innerHTML = \`${itemHtml}\``);
|
|
20382
20459
|
lines.push(` const __anchor = ${containerVar}.children[${childIndexExpr}] ?? null`);
|
|
20383
20460
|
lines.push(` let __first = null`);
|
|
20384
|
-
lines.push(` let __sib = __mtpl.content${
|
|
20461
|
+
lines.push(` let __sib = __mtpl.content${childPath}.firstElementChild`);
|
|
20385
20462
|
lines.push(` while (__sib) {`);
|
|
20386
20463
|
lines.push(` const __next = __sib.nextElementSibling`);
|
|
20387
20464
|
lines.push(` const __cloned = __sib.cloneNode(true)`);
|
|
@@ -20393,7 +20470,7 @@ function stringifyStaticLoop(lines, plan) {
|
|
|
20393
20470
|
} else {
|
|
20394
20471
|
lines.push(` const __tpl = document.createElement('template')`);
|
|
20395
20472
|
lines.push(` __tpl.innerHTML = \`${itemHtml}\``);
|
|
20396
|
-
lines.push(` const __cloned = __tpl.content${
|
|
20473
|
+
lines.push(` const __cloned = __tpl.content${childPath}`);
|
|
20397
20474
|
lines.push(` if (__cloned) {`);
|
|
20398
20475
|
lines.push(` const __anchor = ${containerVar}.children[${childIndexExpr}] ?? null`);
|
|
20399
20476
|
lines.push(` ${containerVar}.insertBefore(__cloned, __anchor)`);
|
|
@@ -20463,9 +20540,8 @@ function emitReactive(lines, inner, indent, pc) {
|
|
|
20463
20540
|
lines.push(`${innerIndent} __innerEl${uid}.__bfExtras = __innerExtras${uid}`);
|
|
20464
20541
|
lines.push(`${indent} }`);
|
|
20465
20542
|
} else {
|
|
20466
|
-
const
|
|
20467
|
-
const innerHtml =
|
|
20468
|
-
const childPath = isSvg ? ".firstElementChild.firstElementChild" : ".firstElementChild";
|
|
20543
|
+
const { wrapTag, childPath } = namespaceWrapForTemplate(emit.wrappedTemplate);
|
|
20544
|
+
const innerHtml = wrapTag ? `<${wrapTag}>${emit.wrappedTemplate}</${wrapTag}>` : emit.wrappedTemplate;
|
|
20469
20545
|
lines.push(`${indent} let __innerEl${uid} = __existing ?? (() => { const __t = document.createElement('template'); __t.innerHTML = \`${innerHtml}\`; return __t.content${childPath}.cloneNode(true) })()`);
|
|
20470
20546
|
}
|
|
20471
20547
|
if (emit.wrappedKey) {
|
|
@@ -21791,7 +21867,8 @@ function generateTemplateOnlyMount(ir, ctx) {
|
|
|
21791
21867
|
restSpreadNames.add(ctx.propsObjectName);
|
|
21792
21868
|
let templateHtml;
|
|
21793
21869
|
if (canGenerateStaticTemplate(ir.root, propNamesForStaticCheck, inlinableConstants, unsafeLocalNames)) {
|
|
21794
|
-
|
|
21870
|
+
const markupSlotIds = new Set(ctx.dynamicElements.map((e) => e.slotId));
|
|
21871
|
+
templateHtml = irToComponentTemplate(ir.root, inlinableConstants, restSpreadNames, ctx.propsObjectName, markupSlotIds);
|
|
21795
21872
|
}
|
|
21796
21873
|
if (!templateHtml) {
|
|
21797
21874
|
const csrInlinableConstants = csrInlinableConstantsFromCtx(ctx);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@barefootjs/vite",
|
|
3
|
-
"version": "0.31.
|
|
3
|
+
"version": "0.31.9",
|
|
4
4
|
"description": "Vite plugin for BarefootJS: Vite/Rollup owns bundling, hashing, chunking, tree-shaking and minification of client assets, BarefootJS keeps only the JSX to (template, client JS) compile",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -38,17 +38,17 @@
|
|
|
38
38
|
"directory": "packages/vite"
|
|
39
39
|
},
|
|
40
40
|
"dependencies": {
|
|
41
|
-
"@barefootjs/shared": "0.31.
|
|
41
|
+
"@barefootjs/shared": "0.31.9"
|
|
42
42
|
},
|
|
43
43
|
"peerDependencies": {
|
|
44
44
|
"@barefootjs/jsx": ">=0.2.0",
|
|
45
45
|
"vite": "^6.0.0"
|
|
46
46
|
},
|
|
47
47
|
"devDependencies": {
|
|
48
|
-
"@barefootjs/client": "0.31.
|
|
49
|
-
"@barefootjs/go-template": "0.31.
|
|
50
|
-
"@barefootjs/hono": "0.31.
|
|
51
|
-
"@barefootjs/jsx": "0.31.
|
|
48
|
+
"@barefootjs/client": "0.31.9",
|
|
49
|
+
"@barefootjs/go-template": "0.31.9",
|
|
50
|
+
"@barefootjs/hono": "0.31.9",
|
|
51
|
+
"@barefootjs/jsx": "0.31.9",
|
|
52
52
|
"typescript": "^5.0.0",
|
|
53
53
|
"vite": "^6.0.0"
|
|
54
54
|
}
|