@dongmingzhixiu/vuexir-compiler 0.5.5 → 0.5.6

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.
@@ -26,12 +26,10 @@ let currentCssVars;
26
26
  function parseColor(c) {
27
27
  const trimmed = c.trim();
28
28
  if (trimmed.startsWith('var(')) {
29
+ // R-THEME:var(--x) 保留语义 → ThemeColor.color("x"),皮肤切换时原生颜色跟随
29
30
  const m = trimmed.match(/^var\(\s*(--[\w-]+)/);
30
- if (m && currentCssVars) {
31
- const val = currentCssVars.get(m[1]);
32
- if (val !== undefined)
33
- return parseColor(val);
34
- }
31
+ if (m)
32
+ return { mode: 'theme', name: m[1].slice(2), r: 0, g: 0, b: 0, a: 1 };
35
33
  return { r: 0, g: 0, b: 0, a: 1 };
36
34
  }
37
35
  if (c.startsWith('#')) {
@@ -47,7 +45,10 @@ function parseColor(c) {
47
45
  return { r: 0, g: 0, b: 0, a: 1 };
48
46
  }
49
47
  function colorExpr(c) {
50
- const { r, g, b, a } = parseColor(c);
48
+ const p = parseColor(c);
49
+ if (p.mode === 'theme' && p.name)
50
+ return `ThemeColor.color("${p.name}")`;
51
+ const { r, g, b, a } = p;
51
52
  // R42:色板已收集时 → Theme.<name> 引用(抽离重复颜色字面量)
52
53
  const name = currentColorNames?.get(rgbHex(r, g, b));
53
54
  const base = name !== undefined ? `Theme.${name}` : `Color(red: ${r}/255.0, green: ${g}/255.0, blue: ${b}/255.0)`;
@@ -1327,6 +1328,8 @@ export function generateScreenSource(screen, opts = {}) {
1327
1328
  `// source: ${screen.id}.ir.json (${screen.width ?? 360}x${screen.height ?? 640})`,
1328
1329
  '',
1329
1330
  `struct ${structName}: View {`,
1331
+ ' // R-THEME:皮肤切换触发视图重建(UserDefaults "vrn.skin" 变化 → body 重算 → ThemeColor.color 取新皮肤色)',
1332
+ ' @AppStorage("vrn.skin") private var skin = "warm"',
1330
1333
  ...(stateDecls ? [stateDecls, ''] : []),
1331
1334
  ...(needDismiss ? [' @Environment(' + '\\' + '.dismiss) private var dismiss', ''] : []),
1332
1335
  // R-VFOBJ-D:静态 v-for 数据属性(数据与布局分离,body 只留 ForEach + 组件引用)
@@ -1507,6 +1510,8 @@ export function generateComponentSource(name, ui, opts = {}) {
1507
1510
  `// source: components/${name}.vue`,
1508
1511
  '',
1509
1512
  `struct ${name}View: View {`,
1513
+ ' // R-THEME:皮肤切换触发组件视图重建(@AppStorage("vrn.skin") 变化 → body 重算 → ThemeColor.color 取新皮肤色)',
1514
+ ' @AppStorage("vrn.skin") private var skin = "warm"',
1510
1515
  ...(propDecls ? [propDecls, ''] : []),
1511
1516
  // R-VFOBJ-D:静态 v-for 数据属性(组件内同样分离)
1512
1517
  ...(dataProps.length ? [dataProps.join('\n'), ''] : []),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dongmingzhixiu/vuexir-compiler",
3
- "version": "0.5.5",
3
+ "version": "0.5.6",
4
4
  "description": "Vue SFC → IR → 原生源码(SwiftUI / Compose)编译器核心:纯函数、零 IO",
5
5
  "type": "module",
6
6
  "license": "MIT",