@dongmingzhixiu/vuexir-compiler 0.5.1 → 0.5.3

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.
@@ -1058,6 +1058,8 @@ export function vueToIr(source, opts = {}) {
1058
1058
  scopedRules: cs,
1059
1059
  pseudoRules: cps,
1060
1060
  propNames: script ? extractPropNames(script.content) : new Set(),
1061
+ // R139:组件内部的常量数组(const tabs = [...])也要能内联进 v-for
1062
+ constArrays: script ? extractScreenConstArrays(script.content) : {},
1061
1063
  refs: new Set(),
1062
1064
  });
1063
1065
  }
@@ -1671,8 +1673,12 @@ function buildComponentTree(comp, warnings) {
1671
1673
  if (roots.length !== 1 || roots[0].type !== NodeTypes.ELEMENT) {
1672
1674
  throw new VueCompileError(`组件 ${comp.name} 需单根元素(<template> 内仅一个根元素)`);
1673
1675
  }
1676
+ // R139:进组件模板前切换常量数组表为「组件自己的常量数组」,出栈后恢复
1677
+ const prevConsts = vforConsts;
1678
+ vforConsts = { ...prevConsts, ...comp.constArrays };
1674
1679
  const tree = walkElement(roots[0], comp.classProps, comp.comboRules, comp.scopedRules, comp.pseudoRules, warnings, undefined, [], // 组件内不支持嵌套组件
1675
1680
  comp.propNames);
1681
+ vforConsts = prevConsts;
1676
1682
  // 组件根布局 props 剥离 → 使用点
1677
1683
  const POSITION_KEYS = ['flex', 'width', 'marginTop', 'marginTopAuto', 'marginLeftAuto'];
1678
1684
  const position = {};
@@ -2172,12 +2178,26 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
2172
2178
  continue;
2173
2179
  }
2174
2180
  if (child.type === NodeTypes.ELEMENT) {
2175
- // R137:<button><span>{{ x }}</span></button> → 动态文案走 bind(此前只能收静态文本)
2176
- const interp = (child.children ?? []).find((cc) => cc.type === NodeTypes.INTERPOLATION);
2177
- if (interp && !props.bind && !props.label) {
2178
- const raw = textOf(interp.content).trim();
2179
- if (raw && !/['"]/.test(raw)) {
2180
- props.bind = addJsExprState(raw);
2181
+ // R137/R138:<button><span>{{ a }}</span><span>{{ b }}</span></button>
2182
+ // → 把所有动态段拼成一句文案(此前只收静态文本,或只取第一段)
2183
+ if (!props.bind && !props.label) {
2184
+ const names = [];
2185
+ const collect = (el) => {
2186
+ for (const cc of el.children ?? []) {
2187
+ const node2 = cc;
2188
+ if (node2.type === NodeTypes.INTERPOLATION) {
2189
+ const raw = textOf(node2.content).trim();
2190
+ if (raw && !/['"]/.test(raw))
2191
+ names.push(raw);
2192
+ }
2193
+ else if (node2.children) {
2194
+ collect(node2);
2195
+ }
2196
+ }
2197
+ };
2198
+ collect(child);
2199
+ if (names.length > 0) {
2200
+ props.bind = addJsExprState(names.length === 1 ? names[0] : names.map((n) => `(${n})`).join(` + " · " + `));
2181
2201
  continue;
2182
2202
  }
2183
2203
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.5.1",
3
+ "version": "0.5.3",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",