meno-core 1.1.5 → 1.1.6
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/chunks/{chunk-H6EOTPJA.js → chunk-GHNLTFCN.js} +44 -12
- package/dist/chunks/chunk-GHNLTFCN.js.map +7 -0
- package/dist/chunks/{chunk-RLBV2R6J.js → chunk-KX2LPIZZ.js} +68 -1
- package/dist/chunks/{chunk-RLBV2R6J.js.map → chunk-KX2LPIZZ.js.map} +2 -2
- package/dist/lib/client/index.js +56 -12
- package/dist/lib/client/index.js.map +2 -2
- package/dist/lib/server/index.js +85 -19
- package/dist/lib/server/index.js.map +3 -3
- package/dist/lib/shared/index.js +7 -1
- package/dist/lib/shared/index.js.map +1 -1
- package/lib/client/core/ComponentBuilder.test.ts +137 -0
- package/lib/client/core/ComponentBuilder.ts +52 -13
- package/lib/client/core/builders/embedBuilder.ts +15 -1
- package/lib/client/core/builders/linkNodeBuilder.ts +15 -1
- package/lib/client/core/builders/localeListBuilder.ts +15 -1
- package/lib/client/templateEngine.test.ts +106 -3
- package/lib/client/templateEngine.ts +50 -10
- package/lib/server/ssr/htmlGenerator.test.ts +105 -2
- package/lib/server/ssr/htmlGenerator.ts +92 -32
- package/lib/server/ssr/ssrRenderer.test.ts +100 -0
- package/lib/server/ssr/ssrRenderer.ts +59 -14
- package/lib/shared/templateStyleVars.ts +49 -0
- package/lib/shared/utilityClassMapper.test.ts +80 -0
- package/lib/shared/utilityClassMapper.ts +116 -0
- package/package.json +1 -1
- package/dist/chunks/chunk-H6EOTPJA.js.map +0 -7
package/dist/lib/client/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import {
|
|
2
|
+
TEMPLATE_VARS_KEY,
|
|
2
3
|
evaluateTemplate,
|
|
3
4
|
extractAttributesFromNode,
|
|
5
|
+
getTemplateVars,
|
|
4
6
|
hasTemplates,
|
|
5
7
|
inlineSvgStyleRules,
|
|
6
8
|
isHtmlMapping,
|
|
@@ -13,7 +15,7 @@ import {
|
|
|
13
15
|
resolveLinkMapping,
|
|
14
16
|
resolveStyleMapping,
|
|
15
17
|
skipEmptyTemplateAttributes
|
|
16
|
-
} from "../../chunks/chunk-
|
|
18
|
+
} from "../../chunks/chunk-GHNLTFCN.js";
|
|
17
19
|
import {
|
|
18
20
|
filterCSSProperties
|
|
19
21
|
} from "../../chunks/chunk-XTKNX4FW.js";
|
|
@@ -58,6 +60,7 @@ import {
|
|
|
58
60
|
logNetworkError,
|
|
59
61
|
logRuntimeError,
|
|
60
62
|
markAsSlotContent,
|
|
63
|
+
mergeInstanceClasses,
|
|
61
64
|
mergeResponsiveStyles,
|
|
62
65
|
normalizeBreakpointConfig,
|
|
63
66
|
pathToString,
|
|
@@ -71,9 +74,10 @@ import {
|
|
|
71
74
|
setGlobalTemplateContext,
|
|
72
75
|
singularize,
|
|
73
76
|
sortClassesByPropertyOrder,
|
|
77
|
+
stripClassOverriddenStyleProps,
|
|
74
78
|
toFriendlyError,
|
|
75
79
|
validatePageData
|
|
76
|
-
} from "../../chunks/chunk-
|
|
80
|
+
} from "../../chunks/chunk-KX2LPIZZ.js";
|
|
77
81
|
import {
|
|
78
82
|
DEFAULT_I18N_CONFIG,
|
|
79
83
|
isI18nValue,
|
|
@@ -1063,6 +1067,12 @@ function buildEmbed(node, ctx, deps) {
|
|
|
1063
1067
|
el.style.setProperty(varName, value);
|
|
1064
1068
|
}
|
|
1065
1069
|
}
|
|
1070
|
+
const templateVars = getTemplateVars(node);
|
|
1071
|
+
if (templateVars) {
|
|
1072
|
+
for (const [varName, value] of Object.entries(templateVars)) {
|
|
1073
|
+
el.style.setProperty(varName, value);
|
|
1074
|
+
}
|
|
1075
|
+
}
|
|
1066
1076
|
}
|
|
1067
1077
|
},
|
|
1068
1078
|
dangerouslySetInnerHTML: { __html: sanitizedHtml }
|
|
@@ -1142,7 +1152,9 @@ function buildEmbed(node, ctx, deps) {
|
|
|
1142
1152
|
if ("class" in extractedAttributes || "className" in extractedAttributes) {
|
|
1143
1153
|
const attrClass = extractedAttributes.class ?? extractedAttributes.className ?? "";
|
|
1144
1154
|
if (attrClass) {
|
|
1145
|
-
|
|
1155
|
+
const classTokens = attrClass.split(/\s+/).filter(Boolean);
|
|
1156
|
+
UtilityClassCollector.collect(classTokens);
|
|
1157
|
+
classNames.push(...classTokens);
|
|
1146
1158
|
}
|
|
1147
1159
|
delete extractedAttributes.class;
|
|
1148
1160
|
delete extractedAttributes.className;
|
|
@@ -1205,6 +1217,12 @@ function buildLinkNode(node, children, ctx, deps) {
|
|
|
1205
1217
|
el.style.setProperty(varName, value);
|
|
1206
1218
|
}
|
|
1207
1219
|
}
|
|
1220
|
+
const templateVars = getTemplateVars(node);
|
|
1221
|
+
if (templateVars) {
|
|
1222
|
+
for (const [varName, value] of Object.entries(templateVars)) {
|
|
1223
|
+
el.style.setProperty(varName, value);
|
|
1224
|
+
}
|
|
1225
|
+
}
|
|
1208
1226
|
}
|
|
1209
1227
|
}
|
|
1210
1228
|
};
|
|
@@ -1283,7 +1301,9 @@ function buildLinkNode(node, children, ctx, deps) {
|
|
|
1283
1301
|
if ("class" in extractedAttributes || "className" in extractedAttributes) {
|
|
1284
1302
|
const attrClass = extractedAttributes.class ?? extractedAttributes.className ?? "";
|
|
1285
1303
|
if (attrClass) {
|
|
1286
|
-
|
|
1304
|
+
const classTokens = attrClass.split(/\s+/).filter(Boolean);
|
|
1305
|
+
UtilityClassCollector.collect(classTokens);
|
|
1306
|
+
classNames.push(...classTokens);
|
|
1287
1307
|
}
|
|
1288
1308
|
delete extractedAttributes.class;
|
|
1289
1309
|
delete extractedAttributes.className;
|
|
@@ -1360,6 +1380,12 @@ function buildLocaleList(node, ctx, deps) {
|
|
|
1360
1380
|
el.style.setProperty(varName, value);
|
|
1361
1381
|
}
|
|
1362
1382
|
}
|
|
1383
|
+
const templateVars = getTemplateVars(node);
|
|
1384
|
+
if (templateVars) {
|
|
1385
|
+
for (const [varName, value] of Object.entries(templateVars)) {
|
|
1386
|
+
el.style.setProperty(varName, value);
|
|
1387
|
+
}
|
|
1388
|
+
}
|
|
1363
1389
|
}
|
|
1364
1390
|
}
|
|
1365
1391
|
};
|
|
@@ -1425,7 +1451,9 @@ function buildLocaleList(node, ctx, deps) {
|
|
|
1425
1451
|
if ("class" in extractedAttributes || "className" in extractedAttributes) {
|
|
1426
1452
|
const attrClass = extractedAttributes.class ?? extractedAttributes.className ?? "";
|
|
1427
1453
|
if (attrClass) {
|
|
1428
|
-
|
|
1454
|
+
const classTokens = attrClass.split(/\s+/).filter(Boolean);
|
|
1455
|
+
UtilityClassCollector.collect(classTokens);
|
|
1456
|
+
classNames.push(...classTokens);
|
|
1429
1457
|
}
|
|
1430
1458
|
delete extractedAttributes.class;
|
|
1431
1459
|
delete extractedAttributes.className;
|
|
@@ -2545,6 +2573,10 @@ var ComponentBuilder = class {
|
|
|
2545
2573
|
*/
|
|
2546
2574
|
applyStyleClasses(props, node, ctx) {
|
|
2547
2575
|
const nodeStyle = node.style || (isComponentNode(node) ? node.props?.style : void 0);
|
|
2576
|
+
const templateVars = getTemplateVars(node);
|
|
2577
|
+
if (templateVars) {
|
|
2578
|
+
props = { ...props, [TEMPLATE_VARS_KEY]: templateVars };
|
|
2579
|
+
}
|
|
2548
2580
|
if (nodeStyle && typeof nodeStyle === "object") {
|
|
2549
2581
|
let processedStyle = nodeStyle;
|
|
2550
2582
|
const templateCtx = ctx.templateContext || ctx.itemContext;
|
|
@@ -2803,14 +2835,19 @@ var ComponentBuilder = class {
|
|
|
2803
2835
|
const instanceClass = typeof finalProps.class === "string" ? finalProps.class : "";
|
|
2804
2836
|
if (instanceClass) {
|
|
2805
2837
|
const root = processedStructure;
|
|
2838
|
+
if (root.style) {
|
|
2839
|
+
const stripped = stripClassOverriddenStyleProps(root.style, instanceClass);
|
|
2840
|
+
if (stripped) root.style = stripped;
|
|
2841
|
+
else delete root.style;
|
|
2842
|
+
}
|
|
2806
2843
|
if (isHtmlNode(root) || isLinkNode(root)) {
|
|
2807
2844
|
if (!root.attributes) root.attributes = {};
|
|
2808
|
-
const
|
|
2809
|
-
root.attributes.class =
|
|
2845
|
+
const own = (root.attributes.class || "").split(/\s+/).filter(Boolean);
|
|
2846
|
+
root.attributes.class = mergeInstanceClasses(own, instanceClass).join(" ");
|
|
2810
2847
|
} else {
|
|
2811
2848
|
if (!root.props) root.props = {};
|
|
2812
|
-
const
|
|
2813
|
-
root.props.className =
|
|
2849
|
+
const own = (root.props.className || "").split(/\s+/).filter(Boolean);
|
|
2850
|
+
root.props.className = mergeInstanceClasses(own, instanceClass).join(" ");
|
|
2814
2851
|
}
|
|
2815
2852
|
const tokens = instanceClass.split(/\s+/).filter(Boolean);
|
|
2816
2853
|
if (tokens.length > 0) UtilityClassCollector.collect(tokens);
|
|
@@ -2877,10 +2914,12 @@ var ComponentBuilder = class {
|
|
|
2877
2914
|
const effectiveParentComponentName = this.getEffectiveParentComponentName(componentContext, parentComponentName);
|
|
2878
2915
|
const { __componentProps, ...customPropsForDOM } = customProps || {};
|
|
2879
2916
|
const isComponentRoot = !!(customProps && "__componentProps" in customProps);
|
|
2880
|
-
|
|
2881
|
-
const
|
|
2917
|
+
const { [TEMPLATE_VARS_KEY]: templateVarsRaw, ...propsSansTemplateVars } = props;
|
|
2918
|
+
const templateVars = templateVarsRaw;
|
|
2919
|
+
let propsForElement = propsSansTemplateVars;
|
|
2920
|
+
const nodeStyle = propsSansTemplateVars.style;
|
|
2882
2921
|
if (nodeStyle && typeof nodeStyle === "object" && ("base" in nodeStyle || "tablet" in nodeStyle || "mobile" in nodeStyle)) {
|
|
2883
|
-
const { style: _, ...rest } =
|
|
2922
|
+
const { style: _, ...rest } = propsSansTemplateVars;
|
|
2884
2923
|
propsForElement = rest;
|
|
2885
2924
|
}
|
|
2886
2925
|
const processedProps = {
|
|
@@ -2935,6 +2974,11 @@ var ComponentBuilder = class {
|
|
|
2935
2974
|
el.style.setProperty(varName, value);
|
|
2936
2975
|
}
|
|
2937
2976
|
}
|
|
2977
|
+
if (templateVars) {
|
|
2978
|
+
for (const [varName, value] of Object.entries(templateVars)) {
|
|
2979
|
+
el.style.setProperty(varName, value);
|
|
2980
|
+
}
|
|
2981
|
+
}
|
|
2938
2982
|
}
|
|
2939
2983
|
const componentProps = isComponentRoot && customProps.__componentProps ? customProps.__componentProps : void 0;
|
|
2940
2984
|
const componentNameForRegistry = isComponentRoot ? componentContext : parentComponentName;
|