@dongmingzhixiu/vuexir-compiler 0.4.7 → 0.4.8

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.
@@ -879,7 +879,15 @@ function emitNodeInner(node, ctx) {
879
879
  // M1:页面级 {{ state }} → props.bind / node.bind → Text(<@State 名>)(状态引用,非字面量)
880
880
  const isRef = props.ref !== undefined;
881
881
  const bindKey = props.bind ?? node.bind?.key;
882
- const isBind = bindKey !== undefined;
882
+ // R133:bind 指向的名字必须是真实状态(或循环变量),否则说明作用域丢失 →
883
+ // 输出空串并告警,绝不能把状态名当文本渲染(日历页出现 Text("_vrnE1") 即是此因)
884
+ const bindValid = bindKey !== undefined &&
885
+ (currentStateNames.has(bindKey.split('.')[0]) ||
886
+ (ctx.loop !== undefined && (ctx.loop.itemKey === bindKey.split('.')[0] || ctx.loop.indexKey === bindKey.split('.')[0])));
887
+ const isBind = bindKey !== undefined && bindValid;
888
+ if (bindKey !== undefined && !bindValid) {
889
+ ctx.warnings.push(`${ctx.path}: 绑定「${bindKey}」在原生端无对应状态/循环变量 → 输出空串(R133)`);
890
+ }
883
891
  const content = props.text !== undefined ? props.text : '';
884
892
  const fs = props.fontSize ?? 15;
885
893
  let line = isRef
@@ -895,10 +903,14 @@ function emitNodeInner(node, ctx) {
895
903
  .map((p) => 'text' in p
896
904
  ? swiftStringEscape(p.text)
897
905
  : 'bind' in p
898
- ? `\\(${p.bind})`
899
- : 'fieldOf' in p
900
- ? `\\(vrnField(${p.fieldOf.obj}, "${p.fieldOf.field}"${p.fieldOf.fallback !== undefined ? `, "${swiftStringEscape(p.fieldOf.fallback)}"` : ''}))`
901
- : `\\(${dictFieldExpr(p.dynField.var, p.dynField.field)})`)
906
+ ? currentStateNames.has(p.bind.split('.')[0])
907
+ ? `\\(${p.bind})`
908
+ : '' // R133:无效绑定 → 空串,避免把状态名当文本
909
+ : false
910
+ ? ''
911
+ : 'fieldOf' in p
912
+ ? `\\(vrnField(${p.fieldOf.obj}, "${p.fieldOf.field}"${p.fieldOf.fallback !== undefined ? `, "${swiftStringEscape(p.fieldOf.fallback)}"` : ''}))`
913
+ : `\\(${dictFieldExpr(p.dynField.var, p.dynField.field)})`)
902
914
  .join('')}")`)
903
915
  : isBind
904
916
  ? ctx.loop && (bindKey === ctx.loop.itemKey || bindKey === ctx.loop.indexKey)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.4.7",
3
+ "version": "0.4.8",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",