native README

项目的 README,来自 github.com/vercel-labs/native。合并为一个 markdown 文件:README.md。

Native SDK

Vercel Labs Experiment npm version: @native-sdk/cli License: Apache-2.0 npm downloads per month: @native-sdk/cli

Native SDK is a toolkit for building native desktop applications with TypeScript and Native markup. The toolkit compiles app logic and views into a native executable and renders the interface in OS windows. Zig cores and optional embedded web content are also supported.

Native SDK is experimental. Platform capabilities vary, and mobile support is still evolving. See the platform support matrix for current support.

Quick start

Install the CLI with Node.js 24 or later:

npm install -g @native-sdk/cli

Create and run an app:

native init my_app
cd my_app
native dev

The generated project opens a counter app and includes:

native dev watches markup changes and updates the view while preserving app state. TypeScript core changes rebuild and restart the app. Use native dev --core to exercise core logic under Node.js without opening a window, native check to validate the project, and native build to create a release binary.

The CLI uses a compatible Zig toolchain from your PATH or offers to download the pinned version. See Quick Start for platform prerequisites and the complete workflow.

App model

Events dispatch typed messages to update, which returns the next model and any effects. The view derives its content from the model. Filesystem access, network requests, and other external work run through effects and TypeScript services.

App cores use a checked TypeScript subset and compile to native code. To write a Zig core instead, create the project with native init my_app --template zig-core. See App Model and TypeScript Cores.

Examples

The Soundboard example app rendered by the Native SDK engine: a music library with album cover art, search, and a playback bar

The Soundboard example rendered by the Native SDK engine. More apps are in examples/:

See the example catalog for additional apps and their authoring languages.

Documentation

Contributing

See CONTRIBUTING.md for repository setup and local checks. For larger changes, open an issue to discuss the design first.

License

Apache-2.0

native (vercel-labs/native)

正在搜索数据库…

这是什么?Native SDK 是一个用于开发原生桌面应用的工具包:你用声明式的 .native 标记语言编写界面,用普通的 TypeScript(或 Zig)编写逻辑。SDK 会把所有内容编译为原生代码,由它自带的引擎直接渲染到真正的操作系统窗口中。最终生成的程序里不包含浏览器、WebView 或 JS 运行时。
这是一个 UI 框架,还是更像一个自己绘制窗口的游戏引擎?它是一个带有自研渲染引擎的声明式 UI 框架。标记文件(.native)与状态绑定,并在“模型/消息/更新”的循环中分发消息;自研引擎把每个像素绘制到真正的操作系统窗口中,而不是交给浏览器或操作系统的原生控件库来完成。
我该如何创建并运行第一个应用?先安装 CLI,然后运行 native init 生成一个新应用(包括界面、逻辑和清单三个文件,没有构建配置),再运行 native dev 在真正的窗口中启动它,并看到一个可以正常计数的按钮。native dev 运行期间,编辑 src/app.native 会直接更新窗口内容。
我需要了解 Zig 吗,还是只用 TypeScript 就够了?应用逻辑的主要编写方式是 TypeScript,它会在构建时编译为原生代码。如果你更喜欢 Zig,它也是一等支持的替代核心(可使用 native init myapp --template zig-core),但并非必需。
这个东西可以直接用于生产环境吗?不可以。Native SDK 仍处于 1.0 之前的版本,API 还在变动,可能出现不兼容的修改。移动端支持(iOS/Android)也被明确标注为实验性功能,桌面端则被视为较为成熟的部分。
我可以把它发布到 iOS 或 Android 上吗?移动端仍是实验性的:iOS 已通过嵌入库在模拟器中验证可行;Android 可以使用完整的嵌入 ABI 进行交叉编译。但两个平台上的 API 和工具链仍在演进中。
它在 Windows 和 Linux 上的表现和 macOS 一样吗?不一样。macOS 是主要平台,支持最完善(包括 Metal 呈现、原生菜单、托盘和对话框);Linux 通过确定性的软件渲染器运行完整的展示程序;Windows 基于 Win32 宿主运行,支持原生右键菜单和输入法(IME),并在 CI 中进行测试。
内置的自动化服务器能让 AI 代理做什么?每个应用都内嵌了一个自动化服务器,使代理可以读取无障碍快照、操作控件、对运行时状态进行断言,并对正在运行的窗口截取确定性的截图。CLI 还附带了代理技能(运行 native skills list 即可查看),用于讲解这套工作流程。
主题和样式是如何工作的?样式从头到尾都基于设计令牌:颜色、圆角和字体都通过名称解析,主题切换时会实时更新,并且可以整体替换。因此,只需修改令牌,同一个应用就能呈现出完全不同的外观。
编译后的应用有多大?标记内容在构建时直接编译进可执行文件,因此发布版本中不包含解析器或解释器。脚手架生成的计数器示例会被构建为一个只有几兆字节的单一可执行文件。
有哪些类似的项目?mygo, nanoui, Valdi, whisker, ng-native, gpui-kit, kivy, nsh
大小
46.7 MB
星标
7.8K
时长
6个月
提交 · 90 天