@dongmingzhixiu/vuexir-compiler 0.3.10 → 0.3.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.
@@ -1596,7 +1596,38 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
1596
1596
  if (forDir) {
1597
1597
  // AttributeNode 无 exp;DirectiveNode 才有(find 命中 DIRECTIVE 但 TS 不窄化 union)
1598
1598
  const exp = 'exp' in forDir ? forDir.exp : undefined;
1599
- const vf = parseVFor(exp && exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : '', warnings, vforConsts);
1599
+ const forExp = exp && exp.type === NodeTypes.SIMPLE_EXPRESSION ? exp.content : '';
1600
+ // R105:`v-for="x in stats"` 里的 stats 是 computed/普通变量(不是 ref 状态)
1601
+ // → 下沉成运行时求值的 JSON 数组状态,列表照常渲染
1602
+ let sunkList;
1603
+ {
1604
+ const m = forExp.trim().match(/^(?:\(([^)]+)\)|([A-Za-z_$][\w$]*))\s+in\s+([A-Za-z_$][\w$]*)$/);
1605
+ if (m) {
1606
+ const src = m[3];
1607
+ const isState = (state?.states ?? []).some((st) => st.name === src);
1608
+ const isConst = vforConsts && src in vforConsts;
1609
+ if (!isState && !isConst && scriptDeclaredNames.has(src)) {
1610
+ sunkList = addJsExprState(`JSON.stringify(${src})`);
1611
+ const vfSunk = {
1612
+ listState: sunkList,
1613
+ itemKey: (m[1] ? m[1].split(',')[0] : m[2]).trim(),
1614
+ indexKey: m[1] ? m[1].split(',')[1]?.trim() : undefined,
1615
+ sunk: true,
1616
+ };
1617
+ const innerNodeSunk = {
1618
+ ...node,
1619
+ props: node.props.filter((p) => !(p.type === NodeTypes.DIRECTIVE && p.name === 'for')),
1620
+ };
1621
+ const itemSunk = walkElement(innerNodeSunk, classProps, comboRules, scopedRules, pseudoRules, warnings, state, compTable, propRefs, [
1622
+ ...loopScope,
1623
+ { itemKey: vfSunk.itemKey, indexKey: vfSunk.indexKey },
1624
+ ], ancestorClasses);
1625
+ return { type: 'for', vfor: vfSunk, children: [itemSunk] };
1626
+ }
1627
+ }
1628
+ }
1629
+ const vf = parseVFor(forExp, warnings, vforConsts);
1630
+ void sunkList;
1600
1631
  if (!vf) {
1601
1632
  throw new VueCompileError('v-for 仅支持静态数组字面量(M2,如 v-for="item in [1,2,3]" / v-for="(item, i) in [\'a\',\'b\']";动态列表随 M3/M4)');
1602
1633
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.3.10",
3
+ "version": "0.3.11",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",