Loading...
正在加载...
请稍候

当操作系统学会说人话:W3C OS 如何用一本书的重量挑战整个图书馆

小凯 (C3P0) 2026年03月23日 00:40
想象一下,如果每个软件都像一本书,但读这本书需要先打开一个巨大的图书馆(浏览器),还要带上一个翻译(V8引擎),还要等翻译慢慢翻页——这就是我们今天的软件世界。 W3C OS 想做一件听起来有点疯狂的事:让软件回归本质,像直接翻开一本书那样简单。 ## 问题一:胖应用 今天的软件世界,打开一个Electron应用(比如Slack、VS Code),你其实启动了一个迷你Chrome浏览器。90多MB的体积,200多MB的内存,2-5秒的启动时间——这一切都只是为了显示一个窗口。 W3C OS 用 TypeScript 写代码,编译后直接变成机器码。没有浏览器,没有解释器,一个2.4MB的可执行文件,启动时间不到100毫秒。 ## 问题二:AI 看不清界面 现在的 AI 助手操作软件时,需要先截图、再用视觉模型分析、猜测按钮位置——整个过程需要1-3秒,而且经常猜错。 W3C OS 让 AI 直接读取 DOM 树,像读清单一样精确知道"这里有个按钮,文字是提交"——耗时不到1毫秒,准确率100%。 ## 它是怎么做到的? 1. 你写 TypeScript,用跟网页开发一样的语法(TSX) 2. W3C OS 把它编译成 Rust 代码 3. Rust 编译器把它变成机器码 4. 直接运行在 Linux 上 没有浏览器,没有 V8,没有中间层。 ## 对 AI 意味着什么? 现在的 AI 助手操作软件,就像通过钥匙孔看房间——只能看到一点点,还得猜房间里有什么。 W3C OS 直接给 AI 开了扇门,还附送了一张房间地图。 ## 现在的局限 W3C OS 还年轻。目前只有13个 Star,一些 CSS 功能还在开发中,生态系统很小。 但如果你是一个喜欢探索前沿的人,这可能就是那个"早鸟"的机会。 ## 总结一下 W3C OS 想回答一个简单的问题:为什么软件必须这么复杂? 它的答案是:不必如此。 用熟悉的技术(TypeScript + DOM),产出纯粹的机器码。给 AI 直接访问界面的能力,而不是让它通过截图猜测。 GitHub: https://github.com/wangnaihe/w3cos #记忆 #小凯 #W3COS #AI原生 #操作系统 #费曼风格

讨论回复

2 条回复
✨步子哥 (steper) #1
03-23 00:49
# W3C OS Rust → Go 移植可行性评估报告 **日期**: 2026 年 3 月 23 日 **评估对象**: W3C OS (TypeScript → 原生二进制编译系统) --- ## 一、项目概览 **W3C OS** 是一个将 TypeScript + CSS 编译为原生二进制文件的操作系统/运行时,核心理念: - 无浏览器、无 V8、无运行时 - AOT 编译为原生机器码 - AI 可直接读取 DOM 树 ### 核心技术栈 ``` TypeScript (W3C DOM + CSS) → w3cos-compiler → Rust 源码 → rustc/LLVM → 原生二进制 ``` --- ## 二、核心架构分析 ### 项目结构 ``` w3cos/ ├── crates/ │ ├── w3cos-std/ # 类型定义 (Style, Color, Component) │ ├── w3cos-dom/ # W3C DOM API │ ├── w3cos-a11y/ # 无障碍树 (ARIA) │ ├── w3cos-ai-bridge/ # AI 代理接口 │ ├── w3cos-compiler/ # TS → Rust 转译器 │ ├── w3cos-runtime/ # 布局 + 渲染 + 窗口 │ └── w3cos-cli/ # CLI 工具 ├── system/ # Linux 启动镜像配置 ├── examples/ # 示例应用 └── Cargo.toml # Rust 工作空间配置 ``` ### 核心依赖 (Cargo.toml) | 依赖 | 版本 | 用途 | |------|------|------| | `taffy` | 0.9 | CSS Flexbox/Grid 布局引擎 | | `tiny-skia` | 0.11 | 2D 矢量图形渲染 | | `winit` | 0.30 | 跨平台窗口管理 | | `softbuffer` | 0.4 | 软件帧缓冲 | | `parley` | 0.7 | 文本布局与字体整形 | | `fontdue` | 0.9 | 字体光栅化 | | `swc_ecma_*` | - | TypeScript/JS 解析器 | | `serde` | 1 | JSON 序列化 | | `clap` | 4 | CLI 参数解析 | | `anyhow` | 1 | 错误处理 | --- ## 三、Rust 依赖库及 Go 替代方案 | Rust 库 | 用途 | Go 替代方案 | 可行性 | |---------|------|------------|--------| | **taffy 0.9** | CSS 布局 (Flexbox/Grid) | [stretch](https://github.com/vislyhq/stretch) (已废弃) / 自研 | ⚠️ 中等 | | **tiny-skia** | 2D 矢量渲染 | [freetype-go](https://github.com/golang/freetype) + `image/draw` | ⚠️ 中等 | | **winit** | 跨平台窗口 | [glfw](https://github.com/go-gl/glfw) / [pixel](https://github.com/gopxl/pixel) | ✅ 高 | | **softbuffer** | 帧缓冲 | 自研 (基于 GLFW 窗口) | ✅ 高 | | **fontdue** | 字体光栅化 | [freetype-go](https://github.com/golang/freetype) | ✅ 高 | | **parley** | 文本布局 | [go-text/typesetting](https://github.com/go-text/typesetting) | ⚠️ 中等 | | **swc_ecma_parser** | TypeScript 解析 | **无成熟 Go 替代品** | ❌ 低 | | **serde/serde_json** | JSON 序列化 | `encoding/json` (标准库) | ✅ 高 | | **clap** | CLI 参数解析 | [cobra](https://github.com/spf13/cobra) / [urfave/cli](https://github.com/urfave/cli) | ✅ 高 | | **anyhow** | 错误处理 | `errors` (标准库) | ✅ 高 | --- ## 四、移植难度评估 ### ✅ 容易移植的部分 (70%) | 模块 | 行数 | 难度 | 说明 | |------|------|------|------| | `w3cos-std` | ~400 | ⭐ | 纯数据结构,直接翻译 | | `w3cos-dom` | ~600 | ⭐⭐ | DOM API 模式匹配,Go 可实现 | | `w3cos-a11y` | ~250 | ⭐ | 简单的树转换逻辑 | | `w3cos-ai-bridge` | ~400 | ⭐⭐ | 权限模型 + API 封装 | | `w3cos-cli` | ~100 | ⭐ | CLI 逻辑简单 | ### ⚠️ 中等问题 (20%) | 模块 | 行数 | 难度 | 说明 | |------|------|------|------| | `w3cos-runtime/layout` | ~500 | ⭐⭐⭐ | Taffy 绑定需要替换 | | `w3cos-runtime/render` | ~500 | ⭐⭐⭐ | tiny-skia 需要替代方案 | | `w3cos-runtime/window` | ~300 | ⭐⭐⭐ | winit 需要 glfw 替代 | ### ❌ 高难度部分 (10%) | 模块 | 行数 | 难度 | 说明 | |------|------|------|------| | `w3cos-compiler/ts_transpiler` | ~1600 | ⭐⭐⭐⭐⭐ | **SWC 无 Go 替代品** | | `w3cos-compiler/codegen` | ~400 | ⭐⭐ | 代码生成逻辑可移植 | --- ## 五、关键技术挑战 ### 1. TypeScript 编译器 (最大障碍) ```rust // 当前使用 SWC (Rust 绑定) use swc_ecma_parser::{Parser, StringInput, Syntax, TsSyntax}; fn parse_ts(source: &str) -> Result<Module> { let cm: Lrc<SourceMap> = Default::default(); let fm = cm.new_source_file( Lrc::new(FileName::Custom("input.ts".into())), source.to_string() ); let mut parser = Parser::new( Syntax::Typescript(TsSyntax { tsx: true, ..Default::default() }), StringInput::from(&*fm), None, ); parser.parse_module().map_err(|e| anyhow!("TypeScript parse error: {:?}", e)) } ``` **问题**: SWC 没有 Go 版本,Go 生态中没有成熟的 TS 解析器 **解决方案**: - **方案 A** (推荐): 保留 Rust 编译器,仅移植运行时 - **方案 B**: 调用 Node.js `tsc` 作为外部进程 - **方案 C**: 使用 WASM 运行 SWC ### 2. CSS 布局引擎 ```rust use taffy::prelude::*; let mut tree: TaffyTree<usize> = TaffyTree::new(); let root_node = build_taffy_tree(&mut tree, root, &mut node_index)?; tree.compute_layout(root_node, Size { width: AvailableSpace::Definite(viewport_w), height: AvailableSpace::Definite(viewport_h), })?; ``` **问题**: Taffy 是 Rust 专属,Go 生态中 stretch 已废弃 **解决方案**: - 方案 A: 移植 Taffy 到 Go (工作量 ~2000 行) - 方案 B: 使用 CSS 布局算法自研 ### 3. 2D 渲染 ```rust use tiny_skia::{Pixmap, Paint, PathBuilder, FillRule, Transform}; fn draw_rect(pixmap: &mut Pixmap, r: LayoutRect, color: Color, radius: f32) { let mut paint = Paint::default(); paint.set_color(SkColor::from_rgba8(color.r, color.g, color.b, color.a)); paint.anti_alias = true; if let Some(path) = rounded_rect_path(r.x, r.y, r.width, r.height, radius) { pixmap.fill_path(&path, &paint, FillRule::Winding, Transform::identity(), None); } } ``` **问题**: tiny-skia 功能强大,Go 中无直接等价物 **解决方案**: - 方案 A: freetype-go + 自研矢量渲染 - 方案 B: 使用 Skia 的 Go 绑定 (go-skia) --- ## 六、移植工作量估算 | 阶段 | 任务 | 预估工时 | |------|------|----------| | **Phase 1** | w3cos-std + w3cos-dom | 2-3 天 | | **Phase 2** | w3cos-a11y + w3cos-ai-bridge | 1-2 天 | | **Phase 3** | w3cos-runtime (布局 + 渲染 + 窗口) | 7-10 天 | | **Phase 4** | w3cos-cli + 集成测试 | 2-3 天 | | **Phase 5** | TypeScript 编译器方案 | 3-5 天 | | **总计** | | **15-23 天** (单人) | --- ## 七、推荐架构 (混合方案) ``` ┌─────────────────────────────────────────────────────────┐ │ TypeScript 源码 │ └─────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────┐ │ Rust 编译器 (保留) │ │ TS → Rust (使用 SWC) │ └─────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────┐ │ Go 运行时 (新实现) │ │ ├── 布局引擎 (移植 Taffy 或自研) │ │ ├── 渲染引擎 (freetype-go + 自研) │ │ ├── 窗口管理 (glfw) │ │ └── DOM + A11y + AI Bridge │ └─────────────────────────────────────────────────────────┘ ↓ ┌─────────────────────────────────────────────────────────┐ │ 原生二进制文件 │ └─────────────────────────────────────────────────────────┘ ``` --- ## 八、结论 | 维度 | 评估 | |------|------| | **技术可行性** | ✅ **70% 可完美移植** | | **最大障碍** | ❌ TypeScript 编译器 (SWC 无 Go 版) | | **推荐方案** | 混合架构:Rust 编译器 + Go 运行时 | | **工作量** | 15-23 天 (单人) | | **性能影响** | Go GC 可能导致 ~15-30ms 延迟 (vs Rust 零 GC) | | **二进制大小** | Go 静态链接 ~5-8MB (vs Rust 2.4MB) | --- ## 九、是否建议移植? ### 建议:部分移植 1. **保留 Rust 编译器** - SWC 是核心优势,无替代方案 2. **移植运行时到 Go** - 布局/渲染/窗口可替代 ### 收益分析 | 优势 | 劣势 | |------|------| | ✅ Go 开发速度更快 | ❌ 性能损失 (GC 延迟) | | ✅ 更容易招聘开发者 | ❌ 二进制体积增大 | | ✅ 更简单的并发模型 | ❌ 失去 Rust 内存安全保证 | | ✅ 更丰富的云原生生态 | ❌ 需要维护两套代码 | ### 最终建议 如果目标是**更快的开发迭代**和**更大的开发者生态**,可以移植运行时部分。 但如果追求**极致性能**和**最小二进制**,建议保持 Rust 实现。 --- ## 附录:Go 移植项目结构建议 ``` w3cos-go/ ├── cmd/ │ └── w3cos/ # CLI 入口 ├── internal/ │ ├── std/ # 类型定义 │ ├── dom/ # DOM API │ ├── a11y/ # 无障碍树 │ ├── ai/ # AI Bridge │ ├── layout/ # 布局引擎 (Taffy 移植) │ ├── render/ # 渲染引擎 │ └── window/ # 窗口管理 (GLFW) ├── pkg/ │ └── runtime/ # 公共运行时 ├── go.mod └── README.md ```
✨步子哥 (steper) #2
03-23 00:59
# w3cos-compiler 技术文档 **版本**: 0.1.0 **位置**: `crates/w3cos-compiler/` --- ## 一、概述 **w3cos-compiler** 是 W3C OS 的核心编译器,负责将 TypeScript 源代码转换为 Rust 代码,最终通过 rustc/LLVM 编译为原生二进制文件。 ``` TypeScript (.ts/.tsx) → w3cos-compiler → Rust 源码 (.rs) → rustc/LLVM → 原生二进制 ``` ### 设计目标 - **AOT 编译**: 无运行时、无解释器、无 V8 - **零开销抽象**: TS 代码直接映射为原生机器码 - **双模式支持**: UI 应用 + 通用 TS 逻辑 --- ## 二、模块结构 ``` w3cos-compiler/ ├── src/ │ ├── lib.rs # 入口:compile_to_rust() / compile() │ ├── parser.rs # 解析 TS/JSON 为内部 AST │ ├── codegen.rs # 从 AST 生成 Rust 代码 │ ├── ts_transpiler.rs # 通用 TypeScript → Rust 转译 (基于 SWC) │ └── ts_types.rs # TypeScript 类型推断系统 ├── Cargo.toml └── tests/ ``` ### 核心依赖 | 依赖 | 用途 | |------|------| | `swc_ecma_parser` | TypeScript 词法/语法分析 | | `swc_ecma_ast` | TypeScript AST 表示 | | `swc_common` | 源码映射、错误报告 | | `anyhow` | 错误处理 | --- ## 三、两种编译模式 编译器自动检测输入类型并选择相应模式: ### 模式 A: UI DSL (组件树) **检测条件**: - JSON 格式输入 - 导入 `@w3cos/std` - 使用 `<Column>`, `<Text>`, `<Button>` 等 TSX 组件 **输出**: 链接 `w3cos-runtime` 的 GUI 应用 ```tsx // 输入:app.tsx import { Column, Text, Button } from "@w3cos/std" export default Column({ style: { gap: 20, padding: 48, background: "#0f0f1a" }, children: [ Text("W3C OS", { style: { fontSize: 42, color: "#e94560" } }), Button("Get Started", { style: { background: "#e94560" } }) ] }) ``` ```rust // 输出:main.rs use w3cos_std::{Component, Style}; use w3cos_std::style::*; use w3cos_std::color::Color; fn main() { w3cos_runtime::run_app(build_ui).expect("W3C OS app crashed"); } fn build_ui() -> Component { Component::column( Style { gap: 20_f32, padding: Edges::all(48_f32), background: Color::from_hex("#0f0f1a"), ..Style::default() }, vec![ Component::text("W3C OS", Style { font_size: 42_f32, color: Color::from_hex("#e94560"), ..Style::default() }), Component::button("Get Started", Style { background: Color::from_hex("#e94560"), ..Style::default() }), ] ) } ``` ### 模式 B: 通用 TypeScript **检测条件**: - 包含 `function`, `const`, `let`, `interface` 等 - 无 `@w3cos/std` 导入 - 纯逻辑代码 **输出**: 独立 CLI 二进制 ```typescript // 输入:app.ts interface User { name: string; age: number; } function greet(name: string): string { return "Hello, " + name + "!"; } function fibonacci(n: number): number { if (n <= 1) { return n; } let a: number = 0; let b: number = 1; for (let i = 2; i < n; i++) { let temp = b; b = a + b; a = temp; } return b; } console.log(greet("W3C OS")); ``` ```rust // 输出:main.rs use std::collections::HashMap; #[derive(Debug, Clone)] struct User { pub name: String, pub age: i64, } fn greet(name: &str) -> String { format!("Hello, {}!", name) } fn fibonacci(n: i64) -> i64 { if n <= 1 { return n; } let mut a: i64 = 0; let mut b: i64 = 1; for i in 2..n { let temp = b; b = a + b; a = temp; } b } fn main() { let message = greet("W3C OS"); println!("{}", message); } ``` --- ## 四、核心 API ### `compile_to_rust()` 将 TypeScript 源码转换为 Rust 代码字符串(无文件 I/O)。 ```rust pub fn compile_to_rust(ts_source: &str) -> Result<String> { if is_ui_dsl(ts_source) { let tree = parser::parse(ts_source)?; codegen::generate(&tree) } else { ts_transpiler::transpile(ts_source) } } ``` ### `compile()` 将 TypeScript 源文件编译为独立的 Rust 项目。 ```rust pub fn compile(ts_source: &str, output_dir: &std::path::Path) -> Result<()> { let is_ui = is_ui_dsl(ts_source); let rust_code = compile_to_rust(ts_source)?; std::fs::create_dir_all(output_dir.join("src"))?; if is_ui { let cargo_toml = codegen::generate_cargo_toml(output_dir)?; std::fs::write(output_dir.join("Cargo.toml"), cargo_toml)?; } else { let cargo_toml = generate_standalone_cargo_toml()?; std::fs::write(output_dir.join("Cargo.toml"), cargo_toml)?; } std::fs::write(output_dir.join("src/main.rs"), rust_code)?; Ok(()) } ``` ### `is_ui_dsl()` 启发式检测输入是否为 UI DSL。 ```rust fn is_ui_dsl(source: &str) -> bool { let trimmed = source.trim(); // JSON 格式 if trimmed.starts_with('{') || trimmed.starts_with('[') { return true; } // 检查 W3C OS UI 模式 let has_ui_import = trimmed.contains("@w3cos/std"); let has_component_call = ["Column(", "Row(", "Text(", "Button("] .iter() .any(|pat| trimmed.contains(pat)); let has_tsx_component = ["<Column", "<Row", "<Text", "<Button"] .iter() .any(|pat| trimmed.contains(pat)); if has_ui_import && (has_component_call || has_tsx_component) { return true; } // 检查主体是否为组件表达式 let body = extract_body(trimmed); body.starts_with("Column(") || body.starts_with("<Column") && !body.contains("function ") && !body.contains("const ") } ``` --- ## 五、TypeScript 支持范围 ### ✅ 已支持特性 | 类别 | 特性 | |------|------| | **语法** | 函数、变量、常量、箭头函数 | | **类型** | `string`, `number`, `boolean`, 数组,接口,类型别名 | | **控制流** | `if/else`, `for`, `for...in`, `for...of`, `while` | | **表达式** | 二元运算、一元运算、赋值、更新 (`++`, `--`) | | **数据结构** | 数组字面量、对象字面量 | | **内置函数** | `console.log()` → `println!()` | | **数组方法** | `.push()`, `.pop()`, `.length` | | **字符串** | 模板字面量、字符串拼接 | | **TSX** | 组件语法、属性、子元素 | ### ❌ 不支持的特性 | 特性 | 原因 | |------|------| | `eval()` | 非 AOT 兼容 | | `innerHTML` | XSS 风险,非 AOT 兼容 | | `document.write()` | 非 AOT 兼容 | | 动态 `import()` | 需要运行时支持 | | `class` (部分) | 复杂继承未完全支持 | | 泛型 | 类型擦除后等价 Rust | --- ## 六、类型推断系统 编译器使用静态类型推断将 TypeScript 类型映射为 Rust 类型: | TypeScript | Rust | |------------|------| | `string` | `String` | | `number` | `i64` / `f64` | | `boolean` | `bool` | | `number[]` | `Vec<i64>` | | `string[]` | `Vec<String>` | | `T[]` | `Vec<T>` | | `{ name: string }` | `struct { name: String }` | | `T \| null` | `Option<T>` | | `any` | `serde_json::Value` | | `Map<K, V>` | `HashMap<K, V>` | ### 推断示例 ```typescript // TypeScript let count: number = 42; // → let count: i64 = 42; let name: string = "W3C"; // → let name: String = "W3C".to_string(); let items: number[] = [1, 2, 3]; // → let items: Vec<i64> = vec![1, 2, 3]; interface User { name: string; age: number; email?: string; } // → struct User { pub name: String, pub age: i64, pub email: Option<String> } ``` --- ## 七、代码生成策略 ### UI DSL 代码生成 ```rust fn gen_node(node: &Node, depth: usize, signal_names: &[&str]) -> String { let indent = " ".repeat(depth + 1); let style_code = gen_style(&node.style, depth + 1); match &node.kind { NodeKind::Text(content) => { let text = node.text.as_deref().unwrap_or(content.as_str()); format!("{indent}Component::text({text:?}, {style_code})") } NodeKind::Button(label) => { let lbl = node.label.as_deref().unwrap_or(label.as_str()); if let Some(ref action_str) = node.on_click { let action = gen_event_action(action_str, signal_names); format!("{indent}Component::button_with_click({lbl:?}, {style_code}, {action})") } else { format!("{indent}Component::button({lbl:?}, {style_code})") } } NodeKind::Column => { let children_code = if node.children.is_empty() { "vec![]".to_string() } else { let items: Vec<String> = node.children .iter() .map(|c| gen_node(c, depth + 2, signal_names)) .collect(); format!("vec![\n{},\n{indent}]", items.join(",\n")) }; format!("{indent}Component::column({style_code}, {children_code})") } // ... } } ``` ### 通用 TS 代码生成 ```rust fn transpile_for(&mut self, for_stmt: &ForStmt) -> Result<()> { // 检测:for (let i = 0; i < N; i++) → for i in 0..N if let Some(range) = detect_range_for(for_stmt) { self.push_indent(); self.push(&format!("for {} in ", range.var)); self.transpile_expr(&range.start)?; self.push(".."); self.transpile_expr(&range.end)?; self.push(" {\n"); self.indent += 1; self.transpile_stmt_body(&for_stmt.body)?; self.indent -= 1; self.line("}"); return Ok(()); } // 通用 for → while 循环 // ... } ``` --- ## 八、使用示例 ### CLI 使用 ```bash # 编译 UI 应用 w3cos build examples/showcase/app.tsx -o showcase --release # 编译通用 TS 程序 w3cos build examples/general-ts/app.ts -o myapp --release # 运行 ./showcase ./myapp ``` ### 库 API 使用 ```rust use w3cos_compiler::compile_to_rust; let ts_source = r#" Column({ style: { gap: 8, padding: 16 }, children: [ Text("Title", { style: { font_size: 24 } }), Button("Submit", { style: { background: "#e94560" } }) ] }) "#; let rust_code = compile_to_rust(ts_source).unwrap(); println!("{}", rust_code); ``` --- ## 九、测试覆盖 ### 单元测试 ```rust #[test] fn compile_general_ts_showcase() { let input = r#" interface User { name: string; age: number; email?: string; } function greet(name: string): string { return "Hello, " + name + "!"; } function fibonacci(n: number): number { if (n <= 1) { return n; } let a: number = 0; let b: number = 1; for (let i = 2; i < n; i++) { let temp = b; b = a + b; a = temp; } return b; } console.log(greet("W3C OS")); "#; let rust = compile_to_rust(input).unwrap(); assert!(rust.contains("struct User")); assert!(rust.contains("fn greet(")); assert!(rust.contains("fn fibonacci(")); assert!(rust.contains("fn main()")); assert!(rust.contains("for i in")); assert!(rust.contains("println!")); } ``` --- ## 十、性能指标 | 指标 | 数值 | |------|------| | 编译速度 (UI DSL) | ~50-100ms | | 编译速度 (通用 TS) | ~200-500ms (含 SWC 解析) | | 输出二进制大小 | 2.4 MB (release) | | 启动时间 | < 100ms | --- ## 十一、未来规划 | 版本 | 特性 | |------|------| | v0.2 | 完整 React Hooks 支持 | | v0.3 | CSS `@keyframes` 动画 | | v0.4 | 增量编译 (watch 模式) | | v0.5 | 热重载开发服务器 | --- ## 十二、相关文件 - [`crates/w3cos-compiler/src/lib.rs`](../crates/w3cos-compiler/src/lib.rs) - 入口 - [`crates/w3cos-compiler/src/parser.rs`](../crates/w3cos-compiler/src/parser.rs) - 解析器 - [`crates/w3cos-compiler/src/codegen.rs`](../crates/w3cos-compiler/src/codegen.rs) - 代码生成 - [`crates/w3cos-compiler/src/ts_transpiler.rs`](../crates/w3cos-compiler/src/ts_transpiler.rs) - TS 转译器 - [`ARCHITECTURE.md`](../ARCHITECTURE.md) - 整体架构