@dongmingzhixiu/vuexir-compiler 0.3.19 → 0.3.21
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.
package/dist/codegen/compose.js
CHANGED
|
@@ -441,7 +441,9 @@ function safeBind(name, ctx, loop) {
|
|
|
441
441
|
function kotlinCondExpr(expr, ctx, loop) {
|
|
442
442
|
// R114:条件里引用了原生端不存在的标识符 → 回退为 true(保留内容)并告警,避免整页编译失败
|
|
443
443
|
{
|
|
444
|
-
|
|
444
|
+
// 先剥掉字符串字面量,避免把 "success" 之类当成标识符
|
|
445
|
+
const stripped = expr.replace(/'[^']*'|"[^"]*"/g, '""');
|
|
446
|
+
const ids = [...stripped.matchAll(/(?<![.\w$])([A-Za-z_$][\w$]*)/g)].map((m) => m[1]);
|
|
445
447
|
const known = new Set((ctx?.states ?? []).map((st) => st.name));
|
|
446
448
|
if (loop) {
|
|
447
449
|
known.add(loop.itemKey);
|
|
@@ -451,7 +453,7 @@ function kotlinCondExpr(expr, ctx, loop) {
|
|
|
451
453
|
for (const k of ['true', 'false', 'Math', 'String', 'Number', 'stateStore'])
|
|
452
454
|
known.add(k);
|
|
453
455
|
const unknown = ids.filter((id) => !known.has(id));
|
|
454
|
-
if (unknown.length > 0 && ctx) {
|
|
456
|
+
if (unknown.length > 0 && ctx && (ctx.states ?? []).length > 0) {
|
|
455
457
|
ctx.warnings?.push?.(`条件「${expr.slice(0, 40)}」引用了原生端不存在的标识符(${unknown.join(', ')})→ 按 true 处理(R114)`);
|
|
456
458
|
return 'true';
|
|
457
459
|
}
|
package/dist/codegen/swiftui.js
CHANGED
|
@@ -502,7 +502,7 @@ function emitNode(node, ctx) {
|
|
|
502
502
|
if (node.condition) {
|
|
503
503
|
const L = ctx.level;
|
|
504
504
|
const inner = emitNodeInner(node, ctx);
|
|
505
|
-
const known = ctx.stateNames
|
|
505
|
+
const known = ctx.stateNames && ctx.stateNames.size > 0 ? ctx.stateNames : undefined;
|
|
506
506
|
const swiftCond = swiftCondExpr(node.condition, known);
|
|
507
507
|
return `${indent(L)}if ${swiftCond} {\n${inner}\n${indent(L)}}`;
|
|
508
508
|
}
|
|
@@ -511,9 +511,11 @@ function emitNode(node, ctx) {
|
|
|
511
511
|
/** JS 条件表达式 → Swift 兼容:===/!== 为 JS 严格比较,Swift 用 ==/!=;字符串字面量单引号 → 双引号 */
|
|
512
512
|
function swiftCondExpr(expr, known) {
|
|
513
513
|
// R114:条件引用原生端不存在的标识符 → true(保留内容),避免整页编译失败
|
|
514
|
-
if (known) {
|
|
515
|
-
|
|
516
|
-
const
|
|
514
|
+
if (known && known.size > 0) {
|
|
515
|
+
// 先剥掉字符串字面量,避免把 "success" 之类当成标识符
|
|
516
|
+
const stripped = expr.replace(/'[^']*'|"[^"]*"/g, '""');
|
|
517
|
+
const ids = [...stripped.matchAll(/(?<![.\w$])([A-Za-z_$][\w$]*)/g)].map((m) => m[1]);
|
|
518
|
+
const unknown = ids.filter((id) => !known.has(id) && !['true', 'false', 'Math', 'String', 'Number', 'vrnTruthy'].includes(id));
|
|
517
519
|
if (unknown.length > 0)
|
|
518
520
|
return 'true';
|
|
519
521
|
}
|