Carlo 已不再维护。
Carlo is no longer maintained

原始链接: https://github.com/GoogleChromeLabs/carlo

Carlo 是一个 Node.js 框架,它利用本地安装的 Google Chrome 浏览器进行渲染,从而实现混合应用程序,并由 Puppeteer 提供支持。与 Electron 或 NW.js 不同,Carlo *使用* 现有的浏览器安装,而不是捆绑一个浏览器,从而提供了解耦且易于维护的架构,以及 Node 和 Chrome 独立的更新能力。 它通过远程调用基础设施促进 Node.js 和浏览器之间的通信,允许 Node 应用使用 Web 技术可视化动态状态,并允许 Web 应用从 Node 访问系统级功能。 Carlo 优先考虑生产力和互操作性,而不是品牌,尽管可以使用 `pkg` 将应用程序打包为桌面应用。它需要 Node v7.6.0+ 和 Chrome 70.* 或更高版本,如果未找到 Chrome 则会显示错误。开发者可以访问 Puppeteer 对象进行测试,并在项目的 examples 文件夹中找到更丰富的 UI 和 RPC 通信示例。

Carlo不再维护 (github.com/googlechromelabs) 4点 由 keepamovin 1小时前 | 隐藏 | 过去 | 收藏 | 1评论 kinlan 5分钟前 [–] 作为GoogleChromeLabs组织的拥有者之一。从技术上讲,该组织中的任何内容都不受官方支持,因为它旨在用于原型和可能根据市场适应性升级到更全面支持的产品。尽管如此,我认为这个仓库的这个特定更改是5年前的事。回复 指南 | 常见问题 | 列表 | API | 安全 | 法律 | 申请YC | 联系 搜索:
相关文章

原文

Carlo provides Node applications with Google Chrome rendering capabilities, communicates with the locally-installed browser instance using the Puppeteer project, and implements a remote call infrastructure for communication between Node and the browser.

image

With Carlo, users can create hybrid applications that use Web stack for rendering and Node for capabilities:

  • For Node applications, the web rendering stack lets users visualize the dynamic state of the app.
  • For Web applications, additional system capabilities are accessible from Node.
  • The application can be bundled into a single executable using pkg.
  • Carlo locates Google Chrome installed locally.
  • Launches Chrome and establishes a connection over the process pipe.
  • Exposes a high-level API for rendering in Chrome with the Node environment.

Install Carlo

npm i carlo
# yarn add carlo

Carlo requires at least Node v7.6.0.

Example - Display local environment

Save file as example.js

const carlo = require('carlo');

(async () => {
  // Launch the browser.
  const app = await carlo.launch();

  // Terminate Node.js process on app window closing.
  app.on('exit', () => process.exit());

  // Tell carlo where your web files are located.
  app.serveFolder(__dirname);

  // Expose 'env' function in the web environment.
  await app.exposeFunction('env', _ => process.env);

  // Navigate to the main page of your app.
  await app.load('example.html');
})();

Save file as example.html

<script>
async function run() {
  // Call the function that was exposed in Node.
  const data = await env();
  for (const type in data) {
    const div = document.createElement('div');
    div.textContent = `${type}: ${data[type]}`;
    document.body.appendChild(div);
  }
}
</script>
<body onload="run()">

Run your application:

Check out systeminfo and terminal examples with richer UI and RPC-based communication between the Web and Node in the examples folder.

Check out the API to get familiar with Carlo.

Carlo uses Puppeteer project for testing. Carlo application and all Carlo windows have corresponding Puppeteer objects exposed for testing. Please refer to the API and the systeminfo project for more details.

Look at the contributing guide to get an overview of Carlo's development.

Q: What was the motivation behind this project when we already have Electron and NW.js? How does this project differ from these platforms, how does it achieve something that is not possible/harder with Electron or NW.js?

  • One of the motivations of this project is to demonstrate how browsers that are installed locally can be used with Node out of the box.
  • Node v8 and Chrome v8 engines are decoupled in Carlo, providing a maintainable model with the ability to independently update underlying components. Carlo gives the user control over bundling and is more about productivity than branding.

Q: Can a Node app using Carlo be packaged as a Desktop app?

The pkg project can be used to package a Node app as a Desktop app. Carlo does not provide branding configurability such as application icons or customizable menus, instead, Carlo focuses on productivity and Web/Node interoperability. Check out the systeminfo example and call pkg package.json to see how it works.

Q: What happens if the user does not have Chrome installed?

Carlo prints an error message when Chrome can not be located.

Q: What is the minimum Chrome version that Carlo supports?

Chrome Stable channel, versions 70.* are supported.

联系我们 contact @ memedata.com