@dongmingzhixiu/vuexir-compiler 0.3.21 → 0.4.0
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
|
@@ -1700,6 +1700,7 @@ function runTabs(appDir, opts = {}) {
|
|
|
1700
1700
|
title: tab.title,
|
|
1701
1701
|
components: loadComponents(tab.file),
|
|
1702
1702
|
storeSources: loadStoreSources(tab.file),
|
|
1703
|
+
allowUnknownComponents: true,
|
|
1703
1704
|
});
|
|
1704
1705
|
if (r.warnings.length > 0) {
|
|
1705
1706
|
console.log(`[gen-android] 编译提示(${tab.id},${r.warnings.length} 条):`);
|
|
@@ -1738,6 +1739,7 @@ function runTabs(appDir, opts = {}) {
|
|
|
1738
1739
|
title: d.title,
|
|
1739
1740
|
components: loadComponents(d.file),
|
|
1740
1741
|
storeSources: loadStoreSources(d.file),
|
|
1742
|
+
allowUnknownComponents: true,
|
|
1741
1743
|
});
|
|
1742
1744
|
if (r.warnings.length > 0) {
|
|
1743
1745
|
console.log(`[gen-android] 编译提示(${d.id},${r.warnings.length} 条):`);
|
package/dist/codegen/swiftui.js
CHANGED
|
@@ -64,6 +64,7 @@ function rgbHex(r, g, b) {
|
|
|
64
64
|
return [r, g, b].map((v) => Math.round(v).toString(16).padStart(2, '0')).join('');
|
|
65
65
|
}
|
|
66
66
|
/** 当前工程的色板(hex → Theme 名 / fontKey → Theme 名);generateScreenSource 设置 */
|
|
67
|
+
let currentStateNames = new Set();
|
|
67
68
|
let currentColorNames;
|
|
68
69
|
let currentFontNames;
|
|
69
70
|
/** R43:frame 组合抽离为 View 扩展方法(theme 模式启用) */
|
|
@@ -511,11 +512,12 @@ function emitNode(node, ctx) {
|
|
|
511
512
|
/** JS 条件表达式 → Swift 兼容:===/!== 为 JS 严格比较,Swift 用 ==/!=;字符串字面量单引号 → 双引号 */
|
|
512
513
|
function swiftCondExpr(expr, known) {
|
|
513
514
|
// R114:条件引用原生端不存在的标识符 → true(保留内容),避免整页编译失败
|
|
514
|
-
|
|
515
|
+
const knownSet = known && known.size > 0 ? known : currentStateNames;
|
|
516
|
+
if (knownSet && knownSet.size > 0) {
|
|
515
517
|
// 先剥掉字符串字面量,避免把 "success" 之类当成标识符
|
|
516
518
|
const stripped = expr.replace(/'[^']*'|"[^"]*"/g, '""');
|
|
517
519
|
const ids = [...stripped.matchAll(/(?<![.\w$])([A-Za-z_$][\w$]*)/g)].map((m) => m[1]);
|
|
518
|
-
const unknown = ids.filter((id) => !
|
|
520
|
+
const unknown = ids.filter((id) => !knownSet.has(id) && !['true', 'false', 'Math', 'String', 'Number', 'vrnTruthy'].includes(id));
|
|
519
521
|
if (unknown.length > 0)
|
|
520
522
|
return 'true';
|
|
521
523
|
}
|
|
@@ -1127,6 +1129,7 @@ function navBarModifiers(screen, warnings) {
|
|
|
1127
1129
|
}
|
|
1128
1130
|
export function generateScreenSource(screen, opts = {}) {
|
|
1129
1131
|
const __stateNames = new Set((screen.state ?? []).map((st) => st.name));
|
|
1132
|
+
currentStateNames = __stateNames;
|
|
1130
1133
|
const rt = opts.runtime ?? 'Runtime.shared';
|
|
1131
1134
|
// R42:色板存在时颜色/字体走 Theme token;R43:frame 走 View 扩展短调用
|
|
1132
1135
|
currentColorNames = opts.theme?.colorNames;
|
|
@@ -65,6 +65,8 @@ export declare function resolveSetCall(handler: string, state: ScreenStateInfo,
|
|
|
65
65
|
export interface Vue2IrOptions {
|
|
66
66
|
/** R86 Pinia store 源码(文件名 → 源码);提供后页面可用 `const ui = useUiStore()` 读状态 */
|
|
67
67
|
storeSources?: Record<string, string>;
|
|
68
|
+
/** R115:允许未注册的自定义组件降级为占位(工程迁移用;库默认仍按 R13 报错) */
|
|
69
|
+
allowUnknownComponents?: boolean;
|
|
68
70
|
screenId?: string;
|
|
69
71
|
title?: string;
|
|
70
72
|
/** 设计稿高度(默认 640,R16 适配基准) */
|
package/dist/transform/vue2ir.js
CHANGED
|
@@ -41,6 +41,8 @@ function addJsExprState(expr) {
|
|
|
41
41
|
jsExprStates.push({ name, init: '', computed: js });
|
|
42
42
|
return name;
|
|
43
43
|
}
|
|
44
|
+
/** R115 是否允许未注册组件降级(由 vueToIr 选项设置) */
|
|
45
|
+
let allowUnknownComponentsFlag = false;
|
|
44
46
|
/** R104 脚本里声明过的名字(const/let/function)——未登记为 state 时走运行时求值 */
|
|
45
47
|
let scriptDeclaredNames = new Set();
|
|
46
48
|
/** R86 store 别名表:`ui` → StoreDef(每次 vueToIr 重建;与 vforConsts 同风格) */
|
|
@@ -923,6 +925,7 @@ export function vueToIr(source, opts = {}) {
|
|
|
923
925
|
storeGetterWarnings = [];
|
|
924
926
|
jsExprSeq = 0;
|
|
925
927
|
jsExprStates = [];
|
|
928
|
+
allowUnknownComponentsFlag = opts.allowUnknownComponents === true;
|
|
926
929
|
const warnings = [];
|
|
927
930
|
const { descriptor, errors } = parse(source, { filename: 'Screen.vue' });
|
|
928
931
|
if (errors.length > 0) {
|
|
@@ -1735,6 +1738,10 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
|
|
|
1735
1738
|
const pos = compPosition.get(comp.name) ?? {};
|
|
1736
1739
|
return componentUseNode(node, comp, pos, warnings);
|
|
1737
1740
|
}
|
|
1741
|
+
if (allowUnknownComponentsFlag) {
|
|
1742
|
+
warnings.push(`自定义组件 <${node.tag}> 未迁移 → 已降级为占位(R115)`);
|
|
1743
|
+
return { type: 'group', props: { flexDirection: 'column', padding: 8 }, children: [{ type: 'text', props: { text: ' ' } }] };
|
|
1744
|
+
}
|
|
1738
1745
|
throw new VueCompileError(`未知标签 <${node.tag}>(元素归一化表外;组件/自定义标签暂不支持,R13)`);
|
|
1739
1746
|
}
|
|
1740
1747
|
// overflow:auto(div 等容器)→ 节点升级为 scroll(生成 ScrollView,内容区可滚动占满剩余)
|
|
@@ -2091,7 +2098,11 @@ function walkElement(node, classProps, comboRules, scopedRules, pseudoRules, war
|
|
|
2091
2098
|
}
|
|
2092
2099
|
// R108:文本节点丢弃布局类属性(原生端 width/height/flexDirection 只对容器有意义)
|
|
2093
2100
|
if (mapping.type === 'text') {
|
|
2094
|
-
const LAYOUT_ONLY = [
|
|
2101
|
+
const LAYOUT_ONLY = [
|
|
2102
|
+
'height', 'width', 'flexDirection', 'justifyContent', 'alignItems', 'flex', 'gap',
|
|
2103
|
+
'clip', 'overflow', 'marginBottom', 'marginRight', 'marginLeft', 'borderSides',
|
|
2104
|
+
'radius', 'opacity', 'position', 'absTop', 'absLeft', 'absRight', 'absBottom',
|
|
2105
|
+
];
|
|
2095
2106
|
const dropped = LAYOUT_ONLY.filter((k) => props[k] !== undefined);
|
|
2096
2107
|
if (dropped.length > 0) {
|
|
2097
2108
|
for (const k of dropped)
|