文章摘要
deno desktop 可将 Deno 项目打包为自包含桌面应用,输出包含代码、运行时和渲染引擎的可分发二进制文件。该功能随 Deno 2.9 发布,目前可通过 canary 版本体验。它默认使用系统 WebView 保持小体积,同时支持 npm 生态,并可选 Chromium 后端。
文章总结
deno desktop 可将 Deno 项目(从单个 TypeScript 文件到 Next.js 应用)转化为独立的桌面应用,输出为包含代码、Deno 运行时和网页渲染引擎的可分发二进制文件,每个平台一个包。该功能随 Deno v2.9.0 发布,目前尚不稳定,可通过 deno upgrade canary 尝试。
核心特性:
- 默认小巧,完全兼容 Node:默认使用操作系统自带 WebView 以减小体积,同时通过 Deno 的 Node 兼容层支持 npm 生态;可选捆绑 Chromium(CEF)后端以实现跨平台一致渲染。
- 框架自动检测:支持 Next.js、Astro、Fresh、Remix、Nuxt、SvelteKit 等框架,无需修改代码即可将现有 Web 项目转为桌面应用,生产模式运行服务器,--hmr 下支持热重载。
- 进程内绑定:后端与 UI 通过进程内通道通信,避免跨进程往返。
- 跨平台编译:单机可构建 macOS、Windows、Linux 版本,后端按需下载。
- 内置二进制差异自动更新:通过 latest.json 清单和 bsdiff 补丁实现自动更新与回滚。
快速示例:创建 main.ts 文件,使用 Deno.serve() 返回 HTML 内容,运行 deno desktop main.ts 即可生成桌面应用窗口,自动绑定地址。
文档涵盖:配置、后端选择、HTTP 服务、框架集成、窗口管理、绑定、菜单、托盘、对话框、通知、热模块替换、DevTools、自动更新、错误报告、分发及与 Electron 等工具的对比。
评论总结
根据评论内容,主要观点和论据如下:
正面评价(认可度较高): - 评论1认为这是明智的发布,会成为选择平台时的考虑因素:"This is a smart thing to ship. For me it would totally be a consideration when deciding on a platform to use." - 评论9称赞零配置选项和功能设计:"The zero config options are nice, all the features seem to be in the place I like" - 评论10欢迎竞争,认为Deno能直接运行TypeScript是优势:"Deno can run true TypeScript directly and not just strip types like the current Node implementation"
负面/质疑观点: - 评论2批评Web技术并非真正的UI工具包,无法提供原生体验:"Web tech is just web tech... the button won't necessarily look native to the OS" - 评论4强调偏好遵循原生UX模式的原生UI:"I also really like native UIs that follow native UX patterns" - 评论12质疑其必要性,认为Web UI是"slop":"The world is trying to make computers faster... more web UI slop isn't going to help that"
技术对比与建议: - 评论3关注权限系统集成,建议向用户展示编译时权限:"I think it would be nice if this could be surfaced to the user somehow" - 评论5认为桌面浏览器应提供更好的WebView支持,替代方案只是过渡:"desktop browsers should provide WebViews on desktop with sandbox and permissions" - 评论7指出架构类似Tauri但业务逻辑用TypeScript:"Sounds like a similar architecture to Tauri, but your business logic is in typescript instead of rust" - 评论10预测会抢占Tauri市场:"this is going to eat a lot of Tauri market" - 评论11希望有与Tauri的对比:"would be cool to have a comparison with tauri"
其他反馈: - 评论6抱怨网页滚动体验:"This web page stole my scroll liberty" - 评论8询问是否支持隐藏浏览器窗口和拦截cookie功能