# chrome-remote-interface [![Build Status][]][travis]
[Build Status]: https://app.travis-ci.com/cyrus-and/chrome-remote-interface.svg?branch=master
[travis]: https://app.travis-ci.com/cyrus-and/chrome-remote-interface
[Chrome Debugging Protocol] interface that helps to instrument Chrome (or any
other suitable [implementation](#implementations)) by providing a simple
abstraction of commands and notifications using a straightforward JavaScript
API.
This module is one of the many [third-party protocol clients][3rd-party].
[3rd-party]: https://developer.chrome.com/devtools/docs/debugging-clients#chrome-remote-interface
## Sample API usage
The following snippet loads `https://github.com` and dumps every request made:
```js
const CDP = require('chrome-remote-interface');
async function example() {
let client;
try {
// connect to endpoint
client = await CDP();
// extract domains
const {Network, Page} = client;
// setup handlers
Network.requestWillBeSent((params) => {
console.log(params.request.url);
});
// enable events then start!
await Network.enable();
await Page.enable();
await Page.navigate({url: 'https://github.com'});
await Page.loadEventFired();
} catch (err) {
console.error(err);
} finally {
if (client) {
await client.close();
}
}
}
example();
```
Find more examples in the [wiki]. You may also want to take a look at the [FAQ].
[wiki]: https://github.com/cyrus-and/chrome-remote-interface/wiki
[async-await-example]: https://github.com/cyrus-and/chrome-remote-interface/wiki/Async-await-example
[FAQ]: https://github.com/cyrus-and/chrome-remote-interface#faq
## Installation
npm install chrome-remote-interface
Install globally (`-g`) to just use the [bundled client](#bundled-client).
## Implementations
This module should work with every application implementing the
[Chrome Debugging Protocol]. In particular, it has been tested against the
following implementations:
Implementation | Protocol version | [Protocol] | [List] | [New] | [Activate] | [Close] | [Version]
---------------------------|--------------------|------------|--------|-------|------------|---------|-----------
[Chrome][1.1] | [tip-of-tree][1.2] | yes¹ | yes | yes | yes | yes | yes
[Opera][2.1] | [tip-of-tree][2.2] | yes | yes | yes | yes | yes | yes
[Node.js][3.1] ([v6.3.0]+) | [node][3.2] | yes | no | no | no | no | yes
[Safari (iOS)][4.1] | [*partial*][4.2] | no | yes | no | no | no | no
[Edge][5.1] | [*partial*][5.2] | yes | yes | no | no | no | yes
[Firefox (Nightly)][6.1] | [*partial*][6.2] | yes | yes | no | yes | yes | yes
¹ Not available on [Chrome for Android][chrome-mobile-protocol], hence a local version of the protocol must be used.
[chrome-mobile-protocol]: https://bugs.chromium.org/p/chromium/issues/detail?id=824626#c4
[1.1]: #chromechromium
[1.2]: https://chromedevtools.github.io/devtools-protocol/tot/
[2.1]: #opera
[2.2]: https://chromedevtools.github.io/devtools-protocol/tot/
[3.1]: #nodejs
[3.2]: https://chromedevtools.github.io/devtools-protocol/v8/
[4.1]: #safari-ios
[4.2]: http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/inspector/protocol
[5.1]: #edge
[5.2]: https://docs.microsoft.com/en-us/microsoft-edge/devtools-protocol/0.1/domains/
[6.1]: #firefox-nightly
[6.2]: https://firefox-source-docs.mozilla.org/remote/index.html
[v6.3.0]: https://nodejs.org/en/blog/release/v6.3.0/
[Protocol]: #cdpprotocoloptions-callback
[List]: #cdplistoptions-callback
[New]: #cdpnewoptions-callback
[Activate]: #cdpactivateoptions-callback
[Close]: #cdpcloseoptions-callback
[Version]: #cdpversionoptions-callback
The meaning of *target* varies according to the implementation, for example,
each Chrome tab represents a target whereas for Node.js a target is the
currently inspected script.
## Setup
An instance of either Chrome itself or another implementation needs to be
running on a known port in order to use this module (defaults to
`localhost:9222`).
### Chrome/Chromium
#### Desktop
Start Chrome with the `--remote-debugging-port` option, for example:
google-chrome --remote-debugging-port=9222
##### Headless
Since version 59, additionally use the `--headless` option, for example:
google-chrome --headless --remote-debugging-port=9222
#### Android
Plug the device and enable the [port forwarding][adb], for example:
adb forward tcp:9222 localabstract:chrome_devtools_remote
Note that in Android, Chrome does not have its own protocol available, a local
version must be used. See [here](#chrome-debugging-protocol-versions) for more information.
[adb]: https://developer.chrome.com/devtools/docs/remote-debugging-legacy
##### WebView
In order to be inspectable, a WebView must
be [configured for debugging][webview] and the corresponding process ID must be
known. There are several ways to obtain it, for example:
adb shell grep -a webview_devtools_remote /proc/net/unix
Finally, port forwarding can be enabled as follows:
adb forward tcp:9222 localabstract:webview_devtools_remote_<pid>
[webview]: https://developers.google.com/web/tools/chrome-devtools/remote-debugging/webviews#configure_webviews_for_debugging
### Opera
Start Opera with the `--remote-debugging-port` option, for example:
opera --remote-debugging-port=9222
### Node.js
Start Node.js with the `--inspect` option, for example:
node --inspect=9222 script.js
### Safari (iOS)
Install and run the [iOS WebKit Debug Proxy][iwdp]. Then use it with the `local`
option set to `true` to use the local version of the protocol or pass a custom
descriptor upon connection (`protocol` option).
[iwdp]: https://github.com/google/ios-webkit-debug-proxy
### Edge
Start Edge with the `--devtools-server-port` option, for example:
MicrosoftEdge.exe --devtools-server-port 9222 about:blank
Please find more information [here][edge-devtools].
[edge-devtools]: https://docs.microsoft.com/en-us/microsoft-edge/devtools-protocol/
### Firefox (Nightly)
Start Firefox with the `--remote-debugging-port` option, for example:
firefox --remote-debugging-port 9222
Bear in mind that this is an experimental feature of Firefox.
## Bundled client
This module comes with a bundled client application that can be used to
interactively control a remote instance.
### Target management
The bundled client exposes subcommands to interact with the HTTP frontend
(e.g., [List](#cdplistoptions-callback), [New](#cdpnewoptions-callback), etc.),
run with `--help` to display the list of available options.
Here are some examples:
```js
$ chrome-remote-interface new 'http://example.com'
{
"description": "",
"devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:9222/devtools/page/b049bb56-de7d-424c-a331-6ae44cf7ae01",
"id": "b049bb56-de7d-424c-a331-6ae44cf7ae01",
"thumbnailUrl": "/thumb/b049bb56-de7d-424c-a331-6ae44cf7ae01",
"title": "",
"type": "page",
"url": "http://example.com/",
"webSocketDebuggerUrl": "ws://localhost:9222/devtools/page/b049bb56-de7d-424c-a331-6ae44cf7ae01"
}
$ chrome-remote-interface close 'b049bb56-de7d-424c-a331-6ae44cf7ae01'
```
### Inspection
Using the `inspect` subcommand it is possible to perform [command execution](#clientdomainmethodparams-callback)
and [event binding](#clientdomaineventcallback) in a REPL fashion that provides completion.
Here is a sample session:
```js
$ chrome-remote-interface inspect
>>> Runtime.evaluate({expression: 'window.location.toString()'})
{ result: { type: 'string', value: 'about:blank' } }
>>> Page.enable()
{}
>>> Page.loadEventFired(console.log)
[Function]
>>> Page.navigate({url: 'https://github.com'})
我的前端代码编辑工具软件
需积分: 0 95 浏览量
更新于2024-06-07
收藏 40.27MB RAR 举报
【我的前端代码编辑工具软件】
在前端开发领域,选择一款合适的代码编辑工具至关重要,它能够极大地提高开发效率,提升代码质量。"我的前端代码编辑工具软件"很可能指的是HBuilderX,这是一款专为前端开发者设计的强大集成开发环境(IDE)。HBuilderX以其高效、智能、全面的特点,在前端开发者群体中广受欢迎。
一、HBuilderX的特点
1. **高效编码**:HBuilderX内置了强大的代码提示功能,支持HTML、CSS、JavaScript、Vue、React等多种前端框架和库的智能补全,让开发者可以快速编写代码,减少手动输入的时间。
2. **实时预览**:该软件提供实时刷新功能,可以在编写代码的同时即时查看页面效果,大大缩短了开发与调试的周期。
3. **语法高亮与代码格式化**:HBuilderX支持多种语言的语法高亮,使得代码更易读,同时具备自动格式化代码的功能,保持代码整洁。
4. **项目管理**:HBuilderX拥有良好的项目管理功能,支持多项目并行开发,方便切换和组织不同的开发任务。
二、HBuilderX的主要功能
1. **代码编辑**:HBuilderX的编辑器提供了丰富的代码编辑功能,如代码折叠、查找替换、书签管理、多光标编辑等,让开发过程更为便捷。
2. **版本控制**:集成了Git等版本控制系统,可以直接在IDE内进行版本控制操作,如提交、拉取、合并等。
3. **构建工具**:HBuilderX内置了构建系统,可以配置自定义脚本,实现一键打包、部署,简化发布流程。
4. **模板与插件**:提供了大量的预设模板和丰富的插件市场,用户可以根据需求选择安装,扩展编辑器功能。
5. **移动端模拟器**:HBuilderX内置了手机模拟器,可以预览和调试移动设备上的应用,无需额外安装其他模拟工具。
6. **DCloud服务**:作为DCloud(数字天堂)的产品,HBuilderX还可以利用DCloud提供的云服务,如云编译、云测试、云打包等,进一步提升开发效率。
三、HBuilderX的适用场景
HBuilderX适用于各种前端开发场合,无论是创建简单的静态网页,还是开发复杂的Web应用程序,甚至是构建跨平台的移动应用,它都能提供强大的支持。特别对于初学者,其友好的界面和丰富的教学资源,可以帮助他们快速上手前端开发。
总结来说,"我的前端代码编辑工具软件"——HBuilderX,凭借其高效的编码体验、丰富的功能和良好的社区支持,成为了众多前端开发者的首选工具。熟练掌握并利用好这款工具,无疑将为前端开发工作带来显著的提升。
z_ling_bao
- 粉丝: 0
- 资源: 1
最新资源
- 后勤管理处服务工作标准.docx
- 后勤维修材料管理制度.docx
- 寒假作息时间表.docx
- 基层应急救援站建设提升基层安全防范和应急救援能力的实施方案.docx
- 磷酸铁、磷酸铁锂生产工艺流程.docx
- 环境问题调查表.docx
- 普通高等学校运动训练、武术与民族传统体育专业招生管理办法.docx
- 设备管理制度(全).docx
- 乳酸阈值对照表.docx
- 神经肌肉中心皮肌炎诊断标准.docx
- 硕士研究生招生考试(初试)《考场规则》.docx
- 消防安全常识二十条.docx
- 学校交通安全知识培训内容.docx
- 医疗废物处置管理制度.docx
- 医疗卫生机构医疗废物管理制度.docx
- 招投标中标后,招标方的操作流程.docx