atom-shell是 GitHub 隨 Atom 一起開源的跨操作系統(tǒng)(Windows,Linux,MacOS X)的利用 Web 技術(shù)(Node.js、JavaScript、HTML 5)開發(fā)桌面應(yīng)用的框架。Atom即構(gòu)建在 atom-shell 之上。
atom-shell 和 Node-Webkit 很像,那么兩者有什么區(qū)別呢?
Node-Webkit 的程序入口是一個(gè)網(wǎng)頁(yè),你在 package.json
中指定主頁(yè),然后這個(gè)主頁(yè)會(huì)在瀏覽器中打開,作為應(yīng)用程序的主窗口。
atom-shell 的程序入口則是一個(gè) JavaScript 腳本,而不是直接指定一個(gè) URL。你需要手動(dòng)創(chuàng)建瀏覽器窗口,并通過(guò)相應(yīng)的 API 加載 html 文件。你同時(shí)需要監(jiān)聽窗口事件以便決定何時(shí)退出應(yīng)用。
因此,atom-shell 更接近 Node.js 運(yùn)行時(shí),API 也更加底層,你可以利用 atom-shell 進(jìn)行 web 測(cè)試,類似 phantomjs。
atom-shell 使用 libchromiumcontent 訪問 Chromium 的 Content API,這樣編譯 atom-shell 的時(shí)候就不用編譯整個(gè) Chromium (編譯 Chromium 非常費(fèi)時(shí))。
順便提一下,GitHub 開發(fā)者還創(chuàng)建了 brightray 庫(kù),讓 libchromiumcontent 的使用更方便。
Node-Webkit 的 Node 集成需要給 Chromium 打補(bǔ)丁才能工作。atom-shell 通過(guò)集成 libuv loop 和 平臺(tái)的 message loop 避免給 Chromium 打補(bǔ)丁。
Node-Webkit 創(chuàng)造了 Node context 和 web context 的概念,而 atom-shell 沒有引入新的 context,而是直接使用 Node 的 Multi-context 特性(這一特性是 Atom 開發(fā)者贊助 Node 添加的)。
GitHub 最初考察了 Node-Webkit,但是最終還是決定雇傭 @zcbenz 來(lái)開發(fā)想要的框架。于是 atom-shell 誕生了。
@zcbenz 真名趙成,是杭 JS 的講師,有興趣和他交流的可以報(bào)名 杭JS哦。
編撰 SegmentFault
聯(lián)系客服