chrome-cdp-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +411 -0
- package/dist/cli/CLIApplication.js +92 -0
- package/dist/cli/CLIInterface.js +327 -0
- package/dist/cli/CommandRegistry.js +33 -0
- package/dist/cli/CommandRouter.js +256 -0
- package/dist/cli/index.js +12 -0
- package/dist/client/CDPClient.js +159 -0
- package/dist/client/index.js +17 -0
- package/dist/connection/ConnectionManager.js +164 -0
- package/dist/connection/index.js +5 -0
- package/dist/handlers/EvaluateScriptHandler.js +205 -0
- package/dist/handlers/index.js +17 -0
- package/dist/index.js +44 -0
- package/dist/interfaces/CDPClient.js +2 -0
- package/dist/interfaces/CLIInterface.js +11 -0
- package/dist/interfaces/CommandHandler.js +2 -0
- package/dist/interfaces/ConnectionManager.js +2 -0
- package/dist/interfaces/index.js +20 -0
- package/dist/types/index.js +2 -0
- package/dist/utils/constants.js +31 -0
- package/dist/utils/index.js +18 -0
- package/dist/utils/logger.js +44 -0
- package/package.json +81 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CDP_DOMAINS = exports.OUTPUT_FORMATS = exports.EXIT_CODES = exports.CDP_WEBSOCKET_SUBPROTOCOL = exports.CDP_VERSION = exports.DEFAULT_TIMEOUT = exports.DEFAULT_CHROME_PORT = exports.DEFAULT_CHROME_HOST = exports.APP_VERSION = exports.APP_NAME = void 0;
|
|
4
|
+
exports.APP_NAME = 'chrome-devtools-cli';
|
|
5
|
+
exports.APP_VERSION = '1.0.0';
|
|
6
|
+
exports.DEFAULT_CHROME_HOST = 'localhost';
|
|
7
|
+
exports.DEFAULT_CHROME_PORT = 9222;
|
|
8
|
+
exports.DEFAULT_TIMEOUT = 30000;
|
|
9
|
+
exports.CDP_VERSION = '1.3';
|
|
10
|
+
exports.CDP_WEBSOCKET_SUBPROTOCOL = 'devtools-protocol';
|
|
11
|
+
exports.EXIT_CODES = {
|
|
12
|
+
SUCCESS: 0,
|
|
13
|
+
GENERAL_ERROR: 1,
|
|
14
|
+
CONNECTION_ERROR: 2,
|
|
15
|
+
COMMAND_ERROR: 3,
|
|
16
|
+
TIMEOUT_ERROR: 4,
|
|
17
|
+
INVALID_ARGS: 5,
|
|
18
|
+
};
|
|
19
|
+
exports.OUTPUT_FORMATS = {
|
|
20
|
+
JSON: 'json',
|
|
21
|
+
TEXT: 'text',
|
|
22
|
+
};
|
|
23
|
+
exports.CDP_DOMAINS = {
|
|
24
|
+
RUNTIME: 'Runtime',
|
|
25
|
+
PAGE: 'Page',
|
|
26
|
+
DOM: 'DOM',
|
|
27
|
+
NETWORK: 'Network',
|
|
28
|
+
PERFORMANCE: 'Performance',
|
|
29
|
+
EMULATION: 'Emulation',
|
|
30
|
+
TARGET: 'Target',
|
|
31
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./constants"), exports);
|
|
18
|
+
__exportStar(require("./logger"), exports);
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.logger = exports.Logger = exports.LogLevel = void 0;
|
|
4
|
+
var LogLevel;
|
|
5
|
+
(function (LogLevel) {
|
|
6
|
+
LogLevel[LogLevel["ERROR"] = 0] = "ERROR";
|
|
7
|
+
LogLevel[LogLevel["WARN"] = 1] = "WARN";
|
|
8
|
+
LogLevel[LogLevel["INFO"] = 2] = "INFO";
|
|
9
|
+
LogLevel[LogLevel["DEBUG"] = 3] = "DEBUG";
|
|
10
|
+
})(LogLevel || (exports.LogLevel = LogLevel = {}));
|
|
11
|
+
class Logger {
|
|
12
|
+
constructor(level = LogLevel.INFO, quiet = false) {
|
|
13
|
+
this.level = level;
|
|
14
|
+
this.quiet = quiet;
|
|
15
|
+
}
|
|
16
|
+
setLevel(level) {
|
|
17
|
+
this.level = level;
|
|
18
|
+
}
|
|
19
|
+
setQuiet(quiet) {
|
|
20
|
+
this.quiet = quiet;
|
|
21
|
+
}
|
|
22
|
+
error(message, ...args) {
|
|
23
|
+
if (!this.quiet && this.level >= LogLevel.ERROR) {
|
|
24
|
+
console.error(`[ERROR] ${message}`, ...args);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
warn(message, ...args) {
|
|
28
|
+
if (!this.quiet && this.level >= LogLevel.WARN) {
|
|
29
|
+
console.warn(`[WARN] ${message}`, ...args);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
info(message, ...args) {
|
|
33
|
+
if (!this.quiet && this.level >= LogLevel.INFO) {
|
|
34
|
+
console.info(`[INFO] ${message}`, ...args);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
debug(message, ...args) {
|
|
38
|
+
if (!this.quiet && this.level >= LogLevel.DEBUG) {
|
|
39
|
+
console.debug(`[DEBUG] ${message}`, ...args);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
exports.Logger = Logger;
|
|
44
|
+
exports.logger = new Logger();
|
package/package.json
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "chrome-cdp-cli",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Command-line tool for controlling Chrome browser instances via the Chrome DevTools Protocol",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"chrome-cli": "dist/index.js",
|
|
9
|
+
"chrome-devtools-cli": "dist/index.js"
|
|
10
|
+
},
|
|
11
|
+
"files": [
|
|
12
|
+
"dist/**/*",
|
|
13
|
+
"README.md",
|
|
14
|
+
"LICENSE"
|
|
15
|
+
],
|
|
16
|
+
"engines": {
|
|
17
|
+
"node": ">=18.0.0"
|
|
18
|
+
},
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "node scripts/build.js development",
|
|
21
|
+
"build:prod": "node scripts/build.js production",
|
|
22
|
+
"build:watch": "tsc --watch",
|
|
23
|
+
"dev": "ts-node src/index.ts",
|
|
24
|
+
"demo": "ts-node demo.ts",
|
|
25
|
+
"start": "node dist/index.js",
|
|
26
|
+
"test": "jest",
|
|
27
|
+
"test:watch": "jest --watch",
|
|
28
|
+
"test:coverage": "jest --coverage",
|
|
29
|
+
"test:ci": "jest --ci --coverage --watchAll=false",
|
|
30
|
+
"lint": "eslint src/**/*.ts",
|
|
31
|
+
"lint:fix": "eslint src/**/*.ts --fix",
|
|
32
|
+
"clean": "rimraf dist",
|
|
33
|
+
"package": "npm run build:prod && npm pack",
|
|
34
|
+
"prepublishOnly": "npm run test:ci && npm run build:prod",
|
|
35
|
+
"prepack": "npm run build:prod",
|
|
36
|
+
"postinstall": "npm run build",
|
|
37
|
+
"verify": "npm run lint && npm run test:ci && npm run build:prod"
|
|
38
|
+
},
|
|
39
|
+
"keywords": [
|
|
40
|
+
"chrome",
|
|
41
|
+
"devtools",
|
|
42
|
+
"automation",
|
|
43
|
+
"cli",
|
|
44
|
+
"browser",
|
|
45
|
+
"testing",
|
|
46
|
+
"cdp",
|
|
47
|
+
"chrome-devtools-protocol",
|
|
48
|
+
"browser-automation",
|
|
49
|
+
"headless-chrome"
|
|
50
|
+
],
|
|
51
|
+
"author": "Chrome DevTools CLI Team",
|
|
52
|
+
"license": "MIT",
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/nickxiao42/chrome-devtools-cli.git"
|
|
56
|
+
},
|
|
57
|
+
"bugs": {
|
|
58
|
+
"url": "https://github.com/nickxiao42/chrome-devtools-cli/issues"
|
|
59
|
+
},
|
|
60
|
+
"homepage": "https://github.com/nickxiao42/chrome-devtools-cli#readme",
|
|
61
|
+
"dependencies": {
|
|
62
|
+
"commander": "^11.1.0",
|
|
63
|
+
"node-fetch": "^2.7.0",
|
|
64
|
+
"ws": "^8.14.2"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@types/jest": "^29.5.8",
|
|
68
|
+
"@types/node": "^20.9.0",
|
|
69
|
+
"@types/node-fetch": "^2.6.13",
|
|
70
|
+
"@types/ws": "^8.5.9",
|
|
71
|
+
"@typescript-eslint/eslint-plugin": "^6.12.0",
|
|
72
|
+
"@typescript-eslint/parser": "^6.12.0",
|
|
73
|
+
"eslint": "^8.54.0",
|
|
74
|
+
"fast-check": "^3.15.0",
|
|
75
|
+
"jest": "^29.7.0",
|
|
76
|
+
"rimraf": "^5.0.5",
|
|
77
|
+
"ts-jest": "^29.1.1",
|
|
78
|
+
"ts-node": "^10.9.1",
|
|
79
|
+
"typescript": "^5.2.2"
|
|
80
|
+
}
|
|
81
|
+
}
|