@aiot-toolkit/aiotpack 2.1.0-prender.10 → 2.1.0-prender.11
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.
|
@@ -595,7 +595,7 @@ function elementToJson(el, styleSheet, importMap, scopeVars, pageDir) {
|
|
|
595
595
|
}
|
|
596
596
|
} else if (name === 'style') {
|
|
597
597
|
if (/^\{\{[^}]+\}\}$/.test(value.trim())) {
|
|
598
|
-
//
|
|
598
|
+
// style="{{variable}}" — whole style bound to a single variable.
|
|
599
599
|
const inner = value.replace(/\{\{|\}\}/g, '').trim();
|
|
600
600
|
if (/^[a-zA-Z_$][\w$.]*$/.test(inner)) {
|
|
601
601
|
node['$style'] = inner;
|
|
@@ -604,46 +604,51 @@ function elementToJson(el, styleSheet, importMap, scopeVars, pageDir) {
|
|
|
604
604
|
}
|
|
605
605
|
hasBind = true;
|
|
606
606
|
} else {
|
|
607
|
-
//
|
|
608
|
-
//
|
|
609
|
-
//
|
|
610
|
-
//
|
|
611
|
-
const
|
|
607
|
+
// Per-property scan. Any dynamic entry promotes the whole attribute
|
|
608
|
+
// to $style-as-object, merging static and dynamic keys together
|
|
609
|
+
// (dynamic → `$key: function`, static → `key: value`). All-static
|
|
610
|
+
// falls back to staticInlineStyle for the pure-static merge path.
|
|
611
|
+
const dynEntries = {};
|
|
612
|
+
const staticEntries = {};
|
|
612
613
|
let hasDynamicInlineStyle = false;
|
|
613
614
|
value.split(';').forEach(decl => {
|
|
614
615
|
const [prop, ...vals] = decl.split(':');
|
|
615
|
-
if (prop
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
const
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
// else drop — invalid inline value; class-level rule (or default) applies
|
|
639
|
-
} else {
|
|
640
|
-
staticInlineStyle[key] = propVal;
|
|
641
|
-
}
|
|
616
|
+
if (!prop || !vals.length) return;
|
|
617
|
+
const key = prop.trim().replace(/-([a-z])/g, (_, c) => c.toUpperCase());
|
|
618
|
+
const propVal = vals.join(':').trim();
|
|
619
|
+
if (/\{\{[\s\S]*?\}\}/.test(propVal)) {
|
|
620
|
+
const parts = propVal.split(/(\{\{[\s\S]*?\}\})/);
|
|
621
|
+
const exprs = parts.filter(Boolean).map(p => {
|
|
622
|
+
const m = p.match(/^\{\{([\s\S]*?)\}\}$/);
|
|
623
|
+
if (m) return addThisPrefix(m[1].trim());
|
|
624
|
+
return `'${p.replace(/'/g, "\\'")}'`;
|
|
625
|
+
});
|
|
626
|
+
const fullExpr = exprs.length === 1 ? exprs[0] : `'' + ${exprs.join(' + ')}`;
|
|
627
|
+
dynEntries['$' + key] = `function () { return ${fullExpr}; }`;
|
|
628
|
+
hasDynamicInlineStyle = true;
|
|
629
|
+
} else {
|
|
630
|
+
let normalized = propVal;
|
|
631
|
+
if (key === 'transform') {
|
|
632
|
+
normalized = normalizeCssTransform(propVal) ?? propVal;
|
|
633
|
+
} else if (key === 'transitionProperty') {
|
|
634
|
+
normalized = normalizeTransitionPropertyValue(propVal);
|
|
635
|
+
} else if (key === 'animationTimingFunction' || key === 'transitionTimingFunction') {
|
|
636
|
+
const n = normalizeAnimationTimingFunction(propVal);
|
|
637
|
+
if (n === null) return;
|
|
638
|
+
normalized = n;
|
|
642
639
|
}
|
|
640
|
+
staticEntries[key] = normalized;
|
|
643
641
|
}
|
|
644
642
|
});
|
|
645
|
-
if (
|
|
646
|
-
|
|
643
|
+
if (hasDynamicInlineStyle) {
|
|
644
|
+
node['$style'] = {
|
|
645
|
+
...staticEntries,
|
|
646
|
+
...dynEntries
|
|
647
|
+
};
|
|
648
|
+
hasBind = true;
|
|
649
|
+
} else {
|
|
650
|
+
for (const [k, v] of Object.entries(staticEntries)) staticInlineStyle[k] = v;
|
|
651
|
+
}
|
|
647
652
|
}
|
|
648
653
|
} else if (/\{\{.*\}\}/.test(value)) {
|
|
649
654
|
// Dynamic binding - build expression from mixed static/dynamic parts
|
|
@@ -786,17 +791,7 @@ function elementToJson(el, styleSheet, importMap, scopeVars, pageDir) {
|
|
|
786
791
|
[inlined.animationName]: styleSheet['@KEYFRAMES'][inlined.animationName]
|
|
787
792
|
};
|
|
788
793
|
}
|
|
789
|
-
if (Object.keys(inlined).length)
|
|
790
|
-
if (hasDynClass) {
|
|
791
|
-
const existing = node['inlineStyle'] || {};
|
|
792
|
-
node['inlineStyle'] = {
|
|
793
|
-
...inlined,
|
|
794
|
-
...existing
|
|
795
|
-
};
|
|
796
|
-
} else {
|
|
797
|
-
node.style = inlined;
|
|
798
|
-
}
|
|
799
|
-
}
|
|
794
|
+
if (Object.keys(inlined).length) node.style = inlined;
|
|
800
795
|
} else {
|
|
801
796
|
const merged = {};
|
|
802
797
|
if (styleSheet[el.tagName]) Object.assign(merged, styleSheet[el.tagName]);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aiot-toolkit/aiotpack",
|
|
3
|
-
"version": "2.1.0-prender.
|
|
3
|
+
"version": "2.1.0-prender.11",
|
|
4
4
|
"description": "The process tool for packaging aiot projects.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aiotpack"
|
|
@@ -19,16 +19,16 @@
|
|
|
19
19
|
"test": "node ./__tests__/aiotpack.test.js"
|
|
20
20
|
},
|
|
21
21
|
"dependencies": {
|
|
22
|
-
"@aiot-toolkit/generator": "2.1.0-prender.
|
|
23
|
-
"@aiot-toolkit/parser": "2.1.0-prender.
|
|
24
|
-
"@aiot-toolkit/shared-utils": "2.1.0-prender.
|
|
22
|
+
"@aiot-toolkit/generator": "2.1.0-prender.11",
|
|
23
|
+
"@aiot-toolkit/parser": "2.1.0-prender.11",
|
|
24
|
+
"@aiot-toolkit/shared-utils": "2.1.0-prender.11",
|
|
25
25
|
"@hap-toolkit/aaptjs": "^2.0.0",
|
|
26
26
|
"@rspack/core": "^1.3.9",
|
|
27
27
|
"acorn": "^8.16.0",
|
|
28
28
|
"aiot-parse5": "^1.0.2",
|
|
29
29
|
"astring": "^1.9.0",
|
|
30
30
|
"babel-loader": "^9.1.3",
|
|
31
|
-
"file-lane": "2.1.0-prender.
|
|
31
|
+
"file-lane": "2.1.0-prender.11",
|
|
32
32
|
"file-loader": "^6.2.0",
|
|
33
33
|
"fs-extra": "^11.2.0",
|
|
34
34
|
"jsrsasign": "^11.1.0",
|