@dongmingzhixiu/vuexir-compiler 0.7.0 → 0.7.1

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.
@@ -743,6 +743,8 @@ function borderModifiers(props) {
743
743
  function flexModifier(props, ctx) {
744
744
  if (ctx?.parentAxis === 'box' || (ctx?.inVerticalScroll && ctx.parentAxis !== 'row'))
745
745
  return '';
746
+ if (props.flex === undefined && props.minWidth === 0 && ctx?.parentAxis === 'row')
747
+ return 'Modifier.weight(1f, fill = false)';
746
748
  return props.flex !== undefined ? `Modifier.weight(${props.flex}f)` : '';
747
749
  }
748
750
  /** 容器选择(对位 iOS VStack/HStack/ZStack) */
@@ -1307,6 +1309,11 @@ function emitNodeInner(node, ctx, depth, loop, useParamModifier = false, parentS
1307
1309
  ].concat(click ? [gm + '.clickable { ' + click + ' }'] : []), pad + ' ');
1308
1310
  if (p.gridColumns && node.children?.length) {
1309
1311
  const columns = p.gridColumns, gap = dp(p.gap ?? 0);
1312
+ if (node.children.length === 1 && node.children[0].type === 'for') {
1313
+ const list = node.children[0];
1314
+ const cells = { ...list, children: list.children?.map((child) => ({ ...child, props: { ...child.props, flex: 1, height: child.props?.height === 'fill' ? undefined : child.props?.height, minHeight: child.props?.minHeight ?? p.minHeight } })) };
1315
+ return pad + 'FlowRow(modifier = Modifier' + chain + ',maxItemsInEachRow = ' + columns + ',horizontalArrangement = Arrangement.spacedBy(' + gap + '),verticalArrangement = Arrangement.spacedBy(' + gap + ')) {\n' + emitNode(cells, { ...ctx, parentAxis: 'row' }, depth + 1, loop) + '\n' + pad + '}';
1316
+ }
1310
1317
  const rows = [];
1311
1318
  for (let i = 0; i < node.children.length; i += columns) {
1312
1319
  const cells = node.children.slice(i, i + columns).map((c) => pad + ' Box(modifier = Modifier.weight(1f)) {\n' + emitNode(c, { ...ctx, parentAxis: 'box' }, depth + 3, loop, false, true) + '\n' + pad + ' }').join('\n');
@@ -2362,8 +2362,11 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
2362
2362
  const inlineTags = new Set(['span', 'b', 'strong', 'i', 'em', 'small', 'u', 'code']);
2363
2363
  const content = node.children.filter((c) => c.type !== NodeTypes.COMMENT && !(c.type === NodeTypes.TEXT && !c.content.trim()));
2364
2364
  const readable = (n) => n.type === NodeTypes.INTERPOLATION || (n.type === NodeTypes.TEXT && !!n.content.trim()) || (n.type === NodeTypes.ELEMENT && n.children.some(readable));
2365
- if (inlineComponentsFlag && mapping.type === 'group' && props.flexDirection === undefined && props.gridColumns === undefined && content.some(readable) && content.every((c) => c.type === NodeTypes.TEXT || c.type === NodeTypes.INTERPOLATION || (c.type === NodeTypes.ELEMENT && inlineTags.has(c.tag))))
2365
+ const inlineConditional = content.some((c) => c.type === NodeTypes.ELEMENT && c.props.some((p) => p.type === NodeTypes.DIRECTIVE && ['if', 'else-if', 'else', 'show'].includes(p.name)));
2366
+ if (inlineComponentsFlag && mapping.type === 'group' && !inlineConditional && props.flexDirection === undefined && props.gridColumns === undefined && content.some(readable) && content.every((c) => c.type === NodeTypes.TEXT || c.type === NodeTypes.INTERPOLATION || (c.type === NodeTypes.ELEMENT && inlineTags.has(c.tag))))
2366
2367
  mapping = { type: 'text' };
2368
+ if (mapping.type === 'text' && inlineConditional)
2369
+ mapping = { type: 'group' };
2367
2370
  if (mapping.type === 'text' && content.length === 0 && ['i', 'span', 'b'].includes(node.tag))
2368
2371
  mapping = { type: 'spacer' };
2369
2372
  // R108:button 只接受 label/bind —— 布局属性丢弃、缺 label 时占位(避免整页失败)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.7.0",
3
+ "version": "0.7.1",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",