@dongmingzhixiu/vuexir-compiler 0.7.4 → 0.7.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.
@@ -1163,6 +1163,10 @@ function stretchModifiers(parentStretch, node) {
1163
1163
  return [];
1164
1164
  return ['Modifier.fillMaxWidth()'];
1165
1165
  }
1166
+ function hasDeclaredWidth(props) {
1167
+ return props.width !== undefined || props.widthFraction !== undefined ||
1168
+ props.widthDynamic !== undefined || props.widthFractionDynamic !== undefined;
1169
+ }
1166
1170
  /** R-PAGESCROLL 守卫:子树内是否存在 flex / marginTopAuto(→ Modifier.weight,滚动容器内不可用) */
1167
1171
  function subtreeHasWeight(node) {
1168
1172
  const p = node.props;
@@ -1208,6 +1212,10 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1208
1212
  const decorated = nd.children.flatMap((c, i) => c.props?.position === 'absolute' ? [c] : i === first ? [{ type: 'group', props: { flexDirection: p.flexDirection, alignItems: p.alignItems, justifyContent: p.justifyContent, gap: p.gap, padding: p.padding, ...((p.width !== undefined || p.widthDynamic) && (p.height !== undefined || p.heightDynamic) ? { width: 'fill', height: 'fill' } : {}) }, children: flow }] : []);
1209
1213
  return decorated.map((child) => emitNode(child, { ...ctx, parentAxis: 'box' }, d, loop)).join('\n');
1210
1214
  }
1215
+ const columnHasWidth = nd.type === 'root' || hasDeclaredWidth(p) ||
1216
+ (nd.type === 'group' && stretchModifiers(parentStretch, nd).length > 0) ||
1217
+ (ctx.parentAxis === 'row' && p.flex !== undefined);
1218
+ const rowContentWidth = ctx.parentAxis === 'row' && p.width === undefined && p.flex === undefined;
1211
1219
  return nd.children
1212
1220
  .map((c) => {
1213
1221
  const cp = (c.props ?? {});
@@ -1235,7 +1243,12 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1235
1243
  if (kind === 'Column' && cp.marginBottom !== undefined && cp.marginBottom !== 0) {
1236
1244
  post = post + '\n' + cpad + 'Spacer(\n' + cpad + ' modifier = Modifier.height(' + dp(cp.marginBottom) + '),\n' + cpad + ')\n';
1237
1245
  }
1238
- const stretch = kind === 'Column' && (p.alignItems === undefined || p.alignItems === 'stretch') && !(ctx.parentAxis === 'row' && p.width === undefined && p.flex === undefined) && cp.width === undefined && cp.flex === undefined && cp.position !== 'absolute' && !cp.marginLeftAuto;
1246
+ // 纵向 flex 只分配高度,列宽已确定时仍按交叉轴拉伸。
1247
+ const autoWidth = cp.flex === undefined
1248
+ ? cp.width === undefined && !rowContentWidth
1249
+ : columnHasWidth && !hasDeclaredWidth(cp);
1250
+ const stretch = kind === 'Column' && (p.alignItems === undefined || p.alignItems === 'stretch') &&
1251
+ autoWidth && cp.position !== 'absolute' && !cp.marginLeftAuto;
1239
1252
  const childCtx = { ...ctx, parentAxis: kind === 'Row' ? 'row' : kind === 'Box' ? 'box' : 'column' };
1240
1253
  const result = emitNode(c, childCtx, d, loop, false, stretch);
1241
1254
  if (childCtx.needsScope)
@@ -1436,7 +1449,8 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1436
1449
  return out;
1437
1450
  }
1438
1451
  case 'button': {
1439
- const chain = modChain([...stretchModifiers(parentStretch, node), ...sizeModifiers(p, ctx), ...absM(p), ...clipModifiers(p), ...visualModifiers(p), ...borderModifiers(p), ...paddingModifiers(p), ...alphaArr, ...transformModifiers(p)], pad + ' ');
1452
+ const flex = p.flex !== undefined ? flexModifier(p, ctx) : '';
1453
+ const chain = modChain([...stretchModifiers(parentStretch, node), ...sizeModifiers(p, ctx), flex, ...absM(p), ...clipModifiers(p), ...visualModifiers(p), ...borderModifiers(p), ...paddingModifiers(p), ...alphaArr, ...transformModifiers(p)], pad + ' ');
1440
1454
  // R108:动态按钮文案(props.bind)优先;Kotlin 里用字符串模板插值
1441
1455
  const label = p.bind !== undefined ? String(p.bind) : (p.label ?? '');
1442
1456
  const click = kotlinClickAction(p, ctx, loop);
@@ -2369,9 +2369,9 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
2369
2369
  mapping = { type: 'group' };
2370
2370
  if (mapping.type === 'text' && content.length === 0 && ['i', 'span', 'b'].includes(node.tag))
2371
2371
  mapping = { type: 'spacer' };
2372
- // R108:button 只接受 label/bind —— 布局属性丢弃、缺 label 时占位(避免整页失败)
2372
+ // R108:button 文案使用 label/bind,保留作为父容器子项的 flex。
2373
2373
  if (mapping.type === 'button') {
2374
- const badProps = ['flexDirection', 'justifyContent', 'alignItems', 'gap', 'flex', 'textAlign', 'lineHeight', 'lineHeightMultiplier', 'overflow', 'clip'];
2374
+ const badProps = ['flexDirection', 'justifyContent', 'alignItems', 'gap', 'textAlign', 'lineHeight', 'lineHeightMultiplier', 'overflow', 'clip'];
2375
2375
  for (const k of badProps)
2376
2376
  delete props[k];
2377
2377
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.7.4",
3
+ "version": "0.7.6",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",