@dongmingzhixiu/vuexir-compiler 0.7.5 → 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)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.7.5",
3
+ "version": "0.7.6",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",