@dongmingzhixiu/vuexir-compiler 0.7.6 → 0.7.7

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.
@@ -9,6 +9,7 @@ declare const NAV_TEST_KT: (bundleId: string) => string;
9
9
  interface ComposeCtx {
10
10
  parentAxis?: 'row' | 'column' | 'box';
11
11
  inVerticalScroll?: boolean;
12
+ parentColumnHeightBounded?: boolean;
12
13
  runtimeAsset?: string;
13
14
  warnings: string[];
14
15
  pageId: string;
@@ -741,7 +741,10 @@ function borderModifiers(props) {
741
741
  return mods;
742
742
  }
743
743
  function flexModifier(props, ctx) {
744
- if (ctx?.parentAxis === 'box' || (ctx?.inVerticalScroll && ctx.parentAxis !== 'row'))
744
+ if (ctx?.parentAxis === 'box')
745
+ return '';
746
+ if (ctx?.inVerticalScroll && ctx.parentAxis !== 'row' &&
747
+ (!ctx.parentColumnHeightBounded || (props.flex ?? 0) <= 0))
745
748
  return '';
746
749
  if (props.flex === undefined && props.minWidth === 0 && ctx?.parentAxis === 'row')
747
750
  return 'Modifier.weight(1f, fill = false)';
@@ -1216,6 +1219,10 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1216
1219
  (nd.type === 'group' && stretchModifiers(parentStretch, nd).length > 0) ||
1217
1220
  (ctx.parentAxis === 'row' && p.flex !== undefined);
1218
1221
  const rowContentWidth = ctx.parentAxis === 'row' && p.width === undefined && p.flex === undefined;
1222
+ // 普通列的固定高度或父列分配的完整权重重新提供有限的垂直空间。
1223
+ const columnHeightBounded = kind === 'Column' && nd.type === 'group' &&
1224
+ (typeof p.height === 'number' ||
1225
+ (ctx.parentAxis === 'column' && ctx.parentColumnHeightBounded === true && (p.flex ?? 0) > 0));
1219
1226
  return nd.children
1220
1227
  .map((c) => {
1221
1228
  const cp = (c.props ?? {});
@@ -1249,7 +1256,11 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1249
1256
  : columnHasWidth && !hasDeclaredWidth(cp);
1250
1257
  const stretch = kind === 'Column' && (p.alignItems === undefined || p.alignItems === 'stretch') &&
1251
1258
  autoWidth && cp.position !== 'absolute' && !cp.marginLeftAuto;
1252
- const childCtx = { ...ctx, parentAxis: kind === 'Row' ? 'row' : kind === 'Box' ? 'box' : 'column' };
1259
+ const childCtx = {
1260
+ ...ctx,
1261
+ parentAxis: kind === 'Row' ? 'row' : kind === 'Box' ? 'box' : 'column',
1262
+ parentColumnHeightBounded: columnHeightBounded,
1263
+ };
1253
1264
  const result = emitNode(c, childCtx, d, loop, false, stretch);
1254
1265
  if (childCtx.needsScope)
1255
1266
  ctx.needsScope = true;
@@ -510,6 +510,16 @@ export function boxModifiers(props) {
510
510
  mods.push('.clipped()');
511
511
  return mods;
512
512
  }
513
+ function columnStretchAlignment(node) {
514
+ const props = node.props;
515
+ // 将常规行放到拉伸区域的尾端,不插入会多占一份 gap 的 Spacer。
516
+ if (node.type === 'group' && props?.flexDirection === 'row' && props.justifyContent === 'end' &&
517
+ props.widthDynamic === undefined && props.widthFraction === undefined && props.widthFractionDynamic === undefined &&
518
+ !props.flexWrap && !props.gridColumns && !node.children?.some((child) => child.props?.position === 'absolute')) {
519
+ return '.trailing';
520
+ }
521
+ return props?.textAlign === 'center' ? '.center' : props?.textAlign === 'right' ? '.trailing' : '.leading';
522
+ }
513
523
  function emitChildren(children, axis, ctx, alignRaw = 'stretch', stretchCross = false) {
514
524
  if (!children || children.length === 0)
515
525
  return '';
@@ -562,7 +572,7 @@ function emitChildren(children, axis, ctx, alignRaw = 'stretch', stretchCross =
562
572
  // column:仅默认 stretch 时子项填满父宽(div block 语义);显式 start/center/end → 内容宽对齐
563
573
  const explicitCol = alignRaw === 'start' || alignRaw === 'center' || alignRaw === 'end';
564
574
  if (!explicitCol) {
565
- return body + '\n' + indent(ctx.level) + frameExpr('fillW', c.props?.textAlign === 'center' ? '.center' : c.props?.textAlign === 'right' ? '.trailing' : '.leading');
575
+ return body + '\n' + indent(ctx.level) + frameExpr('fillW', columnStretchAlignment(c));
566
576
  }
567
577
  return body;
568
578
  }
@@ -985,7 +995,7 @@ function emitNodeInner(node, ctx) {
985
995
  // 显式 start/center/end → 子项按内容宽对齐(CSS 交叉轴对齐语义)
986
996
  const explicitCol = (c.props?.alignSelf !== undefined && c.props.alignSelf !== 'stretch') || props.alignItems === 'start' || props.alignItems === 'center' || props.alignItems === 'end';
987
997
  if (!explicitCol) {
988
- body.push(indent(L + 1) + frameExpr('fillW', c.props?.textAlign === 'center' ? '.center' : c.props?.textAlign === 'right' ? '.trailing' : '.leading'));
998
+ body.push(indent(L + 1) + frameExpr('fillW', columnStretchAlignment(c)));
989
999
  }
990
1000
  }
991
1001
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.7.6",
3
+ "version": "0.7.7",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",