GoogleChromeLabs / carlo
- четверг, 1 ноября 2018 г. в 00:16:20
JavaScript
Web rendering surface for Node applications
Carlo provides your Node application with the rich rendering capabilities powered by the Google Chrome browser.
With Carlo, you can create hybrid applications that use Web stack for rendering and Node for capabilities:
To use Carlo in your project, run:
npm i carlo
# or "yarn add carlo"
Note: Carlo requires at least Node v7.6.0.
Example - Visualize local environment:
Save file as example.js
const carlo = require('carlo');
(async () => {
const app = await carlo.launch();
app.serveFolder(__dirname);
await app.exposeFunction('env', _ => process.env);
await app.load('example.html');
})();
Save file as example.html
<script>
async function run() {
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()">
Execute script on the command line
node example.js
Check out more examples with richer UI and RPC-based communication between the Web and Node componenets under the examples
folder.
Check out contributing guide to get an overview of Puppeteer development.