chrome-remote-interface
Advanced tools
Comparing version 0.15.1 to 0.16.0
#!/usr/bin/env node | ||
'use strict'; | ||
const repl = require('repl'); | ||
@@ -53,3 +55,3 @@ const util = require('util'); | ||
const chromeRepl = repl.start({ | ||
'prompt': '\033[32m>>>\033[0m ', | ||
'prompt': '\x1b[32m>>>\x1b[0m ', | ||
'ignoreUndefined': true, | ||
@@ -59,3 +61,4 @@ 'writer': display | ||
const historyFile = path.join(process.env.HOME, '.cri_history'); | ||
const homePath = process.env.HOME || process.env.USERPROFILE; | ||
const historyFile = path.join(homePath, '.cri_history'); | ||
const historySize = 10000; | ||
@@ -65,3 +68,3 @@ | ||
// attempt to open the history file | ||
var fd; | ||
let fd; | ||
try { | ||
@@ -92,3 +95,3 @@ fd = fs.openSync(historyFile, 'r'); | ||
// hack to get rid of the prompt (clean line and reposition cursor) | ||
console.log('\033[2K\033[G%s', string); | ||
console.log('\x1b[2K\x1b[G%s', string); | ||
chromeRepl.displayPrompt(true); | ||
@@ -168,3 +171,3 @@ } | ||
// walk the items in the domain and override commands and events | ||
var item = chrome[domainName][itemName]; | ||
let item = chrome[domainName][itemName]; | ||
switch (item.category) { | ||
@@ -250,3 +253,3 @@ case 'command': | ||
var action; | ||
let action; | ||
@@ -253,0 +256,0 @@ program |
@@ -1,3 +0,5 @@ | ||
const events = require('events'); | ||
'use strict'; | ||
const EventEmitter = require('events'); | ||
const devtools = require('./lib/devtools.js'); | ||
@@ -11,3 +13,3 @@ const Chrome = require('./lib/chrome.js'); | ||
} | ||
const notifier = new events.EventEmitter(); | ||
const notifier = new EventEmitter(); | ||
if (typeof callback === 'function') { | ||
@@ -14,0 +16,0 @@ // allow to register the error callback later |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
function arrayToObject(parameters) { | ||
@@ -14,2 +16,6 @@ const keyValue = {}; | ||
Object.keys(object).forEach(function (field) { | ||
// skip the 'name' field as it is part of the function prototype | ||
if (field === 'name') { | ||
return; | ||
} | ||
// commands and events have parameters whereas types have properties | ||
@@ -16,0 +22,0 @@ if (category === 'type' && field === 'properties' || |
@@ -1,2 +0,4 @@ | ||
const events = require('events'); | ||
'use strict'; | ||
const EventEmitter = require('events'); | ||
const util = require('util'); | ||
@@ -10,21 +12,22 @@ | ||
function Chrome(options, notifier) { | ||
// options | ||
options = options || {}; | ||
this.host = options.host || defaults.HOST; | ||
this.port = options.port || defaults.PORT; | ||
this.protocol = options.protocol; | ||
this.remote = !!(options.remote); | ||
this.chooseTab = options.chooseTab || function () { return 0; }; | ||
// locals | ||
events.EventEmitter.call(this); | ||
this.notifier = notifier; | ||
this.callbacks = {}; | ||
this.nextCommandId = 1; | ||
// operations | ||
start.call(this); | ||
class Chrome extends EventEmitter { | ||
constructor(options, notifier) { | ||
super(); | ||
// options | ||
options = options || {}; | ||
this.host = options.host || defaults.HOST; | ||
this.port = options.port || defaults.PORT; | ||
this.protocol = options.protocol; | ||
this.remote = !!(options.remote); | ||
this.chooseTab = options.chooseTab || function () { return 0; }; | ||
// locals | ||
EventEmitter.call(this); | ||
this.notifier = notifier; | ||
this.callbacks = {}; | ||
this.nextCommandId = 1; | ||
// operations | ||
start.call(this); | ||
} | ||
} | ||
util.inherits(Chrome, events.EventEmitter); | ||
// avoid misinterpreting protocol's members as custom util.inspect functions | ||
@@ -101,3 +104,9 @@ Chrome.prototype.inspect = function (depth, options) { | ||
}).then(function () { | ||
chrome.notifier.emit('connect', chrome); | ||
// since the handler is executed synchronously, the emit() must be | ||
// performed in the next tick so that uncaught errors in the client code | ||
// are not intercepted by the Promise mechanism and therefore reported | ||
// via the 'error' event | ||
process.nextTick(function () { | ||
chrome.notifier.emit('connect', chrome); | ||
}); | ||
}).catch(function (err) { | ||
@@ -133,3 +142,3 @@ chrome.notifier.emit('error', err); | ||
const busyTabError = new Error('Tab does not support inspection'); | ||
var url; | ||
let url; | ||
switch (typeof chrome.chooseTab) { | ||
@@ -136,0 +145,0 @@ case 'string': |
@@ -0,2 +1,4 @@ | ||
'use strict'; | ||
module.exports.HOST = 'localhost'; | ||
module.exports.PORT = 9222; |
@@ -0,1 +1,3 @@ | ||
'use strict'; | ||
const http = require('http'); | ||
@@ -27,3 +29,3 @@ const https = require('https'); | ||
// use the proper protocol fetcher | ||
var fetcher; | ||
let fetcher; | ||
if (browser.match(/^Chrome\//)) { | ||
@@ -148,3 +150,3 @@ fetcher = fetchFromChromeRepo; | ||
const request = transport.get(options, function (response) { | ||
var data = ''; | ||
let data = ''; | ||
response.on('data', function (chunk) { | ||
@@ -184,3 +186,3 @@ data += chunk; | ||
const fromChromiumDotOrg = (hash <= 202666); | ||
var templates; | ||
let templates; | ||
if (fromChromiumDotOrg) { | ||
@@ -196,3 +198,3 @@ templates = ['https://src.chromium.org/blink/trunk/Source/devtools/protocol.json?p=%s']; | ||
['https://chromium.googlesource.com/chromium/src/+/%s/third_party/WebKit/Source/core/inspector/browser_protocol.json?format=TEXT', | ||
'https://chromium.googlesource.com/chromium/src/+/%s/third_party/WebKit/Source/platform/v8_inspector/js_protocol.json?format=TEXT']); | ||
'https://chromium.googlesource.com/chromium/src/+/%s/third_party/WebKit/Source/platform/v8_inspector/js_protocol.json?format=TEXT']); | ||
} | ||
@@ -205,3 +207,3 @@ const urls = templates.map(function (template) { | ||
fetchObject(https, url, function (err, data) { | ||
var descriptor; | ||
let descriptor; | ||
if (!err) { | ||
@@ -208,0 +210,0 @@ try { |
@@ -12,3 +12,3 @@ { | ||
"homepage": "https://github.com/cyrus-and/chrome-remote-interface", | ||
"version": "0.15.1", | ||
"version": "0.16.0", | ||
"repository": { | ||
@@ -22,3 +22,3 @@ "type": "git", | ||
"engines": { | ||
"node": ">=0.12.15" | ||
"node": ">=4" | ||
}, | ||
@@ -38,4 +38,8 @@ "dependencies": { | ||
"devDependencies": { | ||
"mocha": "*" | ||
"mocha": "3.x.x", | ||
"eslint": "3.x.x" | ||
}, | ||
"scripts": { | ||
"test": "./scripts/run-tests.sh" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
chrome-remote-interface | ||
chrome-remote-interface [![Build Status](https://travis-ci.org/cyrus-and/chrome-remote-interface.svg?branch=master)](https://travis-ci.org/cyrus-and/chrome-remote-interface) | ||
======================= | ||
@@ -25,3 +25,5 @@ | ||
}); | ||
Page.loadEventFired(close); | ||
Page.loadEventFired(function () { | ||
close(); | ||
}); | ||
Network.enable(); | ||
@@ -57,2 +59,3 @@ Page.enable(); | ||
[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 | ||
@@ -65,2 +68,4 @@ [1.1]: https://www.chromium.org/ | ||
[3.2]: https://chromedevtools.github.io/debugger-protocol-viewer/v8/ | ||
[4.1]: https://www.apple.com/safari/ | ||
[4.2]: http://trac.webkit.org/browser/trunk/Source/JavaScriptCore/inspector/protocol | ||
@@ -111,2 +116,8 @@ [v6.3.0]: https://nodejs.org/en/blog/release/v6.3.0/ | ||
### Safari (iOS) | ||
Install and run the [iOS WebKit Debug Proxy][iwdp]. | ||
[iwdp]: https://github.com/google/ios-webkit-debug-proxy | ||
Bundled client | ||
@@ -113,0 +124,0 @@ -------------- |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
601748
13606
722
2
4