single-file-cli 2.0.20 → 2.0.21
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/deno.json +2 -2
- package/deno.lock +8 -8
- package/lib/browser.js +1 -7
- package/lib/cdp-client.js +8 -3
- package/lib/version.js +1 -1
- package/options.js +1 -0
- package/package.json +2 -2
- package/single-file-cli-api.js +16 -2
package/deno.json
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@single-file/single-file-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "SingleFile CLI",
|
|
5
5
|
"nodeModulesDir": true,
|
|
6
6
|
"exports": {
|
|
7
7
|
".": "./single-file-cli-api.js"
|
|
8
8
|
},
|
|
9
9
|
"imports": {
|
|
10
|
-
"simple-cdp": "jsr:@simple-cdp/simple-cdp@^1.8.
|
|
10
|
+
"simple-cdp": "jsr:@simple-cdp/simple-cdp@^1.8.4",
|
|
11
11
|
"path": "jsr:@std/path@^0.220.1"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/deno.lock
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
"version": "3",
|
|
3
3
|
"packages": {
|
|
4
4
|
"specifiers": {
|
|
5
|
-
"jsr:@simple-cdp/simple-cdp@^1.8.
|
|
5
|
+
"jsr:@simple-cdp/simple-cdp@^1.8.4": "jsr:@simple-cdp/simple-cdp@1.8.4",
|
|
6
6
|
"jsr:@std/assert@^0.220.1": "jsr:@std/assert@0.220.1",
|
|
7
7
|
"jsr:@std/path@^0.220.1": "jsr:@std/path@0.220.1",
|
|
8
|
-
"npm:simple-cdp@^1.8.
|
|
8
|
+
"npm:simple-cdp@^1.8.4": "npm:simple-cdp@1.8.4",
|
|
9
9
|
"npm:ws@^8.16.0": "npm:ws@8.16.0"
|
|
10
10
|
},
|
|
11
11
|
"jsr": {
|
|
12
|
-
"@simple-cdp/simple-cdp@1.8.
|
|
13
|
-
"integrity": "
|
|
12
|
+
"@simple-cdp/simple-cdp@1.8.4": {
|
|
13
|
+
"integrity": "5e31ab90a552f9f1cf84e6cf0454d21c5b9dc1d89f9c1f9a750772b47bad9a4e"
|
|
14
14
|
},
|
|
15
15
|
"@std/assert@0.220.1": {
|
|
16
16
|
"integrity": "88710d54f3afdd7a5761e7805abba1f56cd14e4b212feffeb3e73a9f77482425"
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
}
|
|
24
24
|
},
|
|
25
25
|
"npm": {
|
|
26
|
-
"simple-cdp@1.8.
|
|
27
|
-
"integrity": "sha512-
|
|
26
|
+
"simple-cdp@1.8.4": {
|
|
27
|
+
"integrity": "sha512-fsvMUyz13vzX8nxSPwJfdxdROGxRDdTAFX7XitVpRsKwClowsyL3NZ6kR4vR5tZfxbz31p3uoM14eFUvhaWisA==",
|
|
28
28
|
"dependencies": {}
|
|
29
29
|
},
|
|
30
30
|
"ws@8.16.0": {
|
|
@@ -36,12 +36,12 @@
|
|
|
36
36
|
"remote": {},
|
|
37
37
|
"workspace": {
|
|
38
38
|
"dependencies": [
|
|
39
|
-
"jsr:@simple-cdp/simple-cdp@^1.8.
|
|
39
|
+
"jsr:@simple-cdp/simple-cdp@^1.8.4",
|
|
40
40
|
"jsr:@std/path@^0.220.1"
|
|
41
41
|
],
|
|
42
42
|
"packageJson": {
|
|
43
43
|
"dependencies": [
|
|
44
|
-
"npm:simple-cdp@^1.8.
|
|
44
|
+
"npm:simple-cdp@^1.8.4",
|
|
45
45
|
"npm:ws@^8.16.0"
|
|
46
46
|
]
|
|
47
47
|
}
|
package/lib/browser.js
CHANGED
|
@@ -66,13 +66,7 @@ async function launchBrowser(options = {}, indexPath = 0) {
|
|
|
66
66
|
if (indexPath + 1 < BROWSER_PATHS[build.os].length) {
|
|
67
67
|
await launchBrowser(options, indexPath + 1);
|
|
68
68
|
} else {
|
|
69
|
-
|
|
70
|
-
if (options.executablePath) {
|
|
71
|
-
message += "Make sure --browser-executable-path is correct.";
|
|
72
|
-
} else {
|
|
73
|
-
message += "Set the path using the --browser-executable-path option.";
|
|
74
|
-
}
|
|
75
|
-
throw new Error(message);
|
|
69
|
+
throw error;
|
|
76
70
|
}
|
|
77
71
|
} else {
|
|
78
72
|
throw error;
|
package/lib/cdp-client.js
CHANGED
|
@@ -37,13 +37,17 @@ const EMPTY_PAGE_URL = "about:blank";
|
|
|
37
37
|
export { initialize, getPageData, closeBrowser };
|
|
38
38
|
|
|
39
39
|
async function initialize(options) {
|
|
40
|
-
|
|
40
|
+
if (!options.browserRemoteDebuggingUrl) {
|
|
41
|
+
await launchBrowser(getBrowserOptions(options));
|
|
42
|
+
} else {
|
|
43
|
+
CDP.remoteDebuggingUrl = options.browserRemoteDebuggingUrl;
|
|
44
|
+
}
|
|
41
45
|
}
|
|
42
46
|
|
|
43
47
|
async function getPageData(options) {
|
|
44
48
|
let targetInfo;
|
|
45
49
|
try {
|
|
46
|
-
|
|
50
|
+
targetInfo = await CDP.createTarget(EMPTY_PAGE_URL);
|
|
47
51
|
const { Browser, Security, Page, Emulation, Fetch, Network, Runtime, Debugger } = new CDP(targetInfo);
|
|
48
52
|
if (options.browserStartMinimized) {
|
|
49
53
|
const { windowId, bounds } = await Browser.getWindowForTarget({ targetId: targetInfo.targetId });
|
|
@@ -127,7 +131,7 @@ async function getPageData(options) {
|
|
|
127
131
|
throw error;
|
|
128
132
|
} finally {
|
|
129
133
|
if (targetInfo && !options.browserDebug) {
|
|
130
|
-
await CDP.closeTarget(targetInfo.
|
|
134
|
+
await CDP.closeTarget(targetInfo.id);
|
|
131
135
|
}
|
|
132
136
|
}
|
|
133
137
|
}
|
|
@@ -169,6 +173,7 @@ function getTopFrameContextId({ Page, Runtime }, options) {
|
|
|
169
173
|
frameId = frame.id;
|
|
170
174
|
if (navigationAbortController) {
|
|
171
175
|
navigationAbortController.abort();
|
|
176
|
+
contextIds.length = 0;
|
|
172
177
|
}
|
|
173
178
|
navigationAbortController = new AbortController();
|
|
174
179
|
await onTopFrameNavigated(navigationAbortController.signal);
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.0.
|
|
1
|
+
export const version = "2.0.21";
|
package/options.js
CHANGED
|
@@ -60,6 +60,7 @@ const OPTIONS_INFO = {
|
|
|
60
60
|
"browser-cookie": { description: "Ordered list of cookie parameters separated by a comma (name,value,domain,path,expires,httpOnly,secure,sameSite,url)", type: "string[]" },
|
|
61
61
|
"browser-cookies-file": { description: "Path of the cookies file formatted as a JSON file or a Netscape text file", type: "string" },
|
|
62
62
|
"browser-ignore-insecure-certs": { description: "Ignore HTTPs errors", type: "boolean" },
|
|
63
|
+
"browser-remote-debugging-url": { description: "Remote debugging URL", type: "string" },
|
|
63
64
|
"compress-content": { description: "Compress the output file into a ZIP file", type: "boolean" },
|
|
64
65
|
"compress-CSS": { description: "Compress CSS stylesheets", type: "boolean" },
|
|
65
66
|
"compress-HTML": { description: "Compress HTML content", type: "boolean", defaultValue: true },
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "single-file-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.21",
|
|
4
4
|
"description": "SingleFile CLI",
|
|
5
5
|
"author": "Gildas Lormeau",
|
|
6
6
|
"engines": {
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"single-file": "./single-file-node.js"
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
|
-
"simple-cdp": "^1.8.
|
|
16
|
+
"simple-cdp": "^1.8.4",
|
|
17
17
|
"ws": "^8.16.0"
|
|
18
18
|
}
|
|
19
19
|
}
|
package/single-file-cli-api.js
CHANGED
|
@@ -76,7 +76,7 @@ const DEFAULT_OPTIONS = {
|
|
|
76
76
|
const STATE_PROCESSING = "processing";
|
|
77
77
|
const STATE_PROCESSED = "processed";
|
|
78
78
|
|
|
79
|
-
const { readTextFile, writeTextFile, writeFile, stdout, mkdir, stat } = Deno;
|
|
79
|
+
const { readTextFile, writeTextFile, writeFile, stdout, mkdir, stat, errors } = Deno;
|
|
80
80
|
let tasks = [], maxParallelWorkers, sessionFilename;
|
|
81
81
|
|
|
82
82
|
export { DEFAULT_OPTIONS, VALID_URL_TEST, initialize };
|
|
@@ -84,7 +84,21 @@ export { DEFAULT_OPTIONS, VALID_URL_TEST, initialize };
|
|
|
84
84
|
async function initialize(options) {
|
|
85
85
|
options = Object.assign({}, DEFAULT_OPTIONS, options);
|
|
86
86
|
maxParallelWorkers = options.maxParallelWorkers || 8;
|
|
87
|
-
|
|
87
|
+
try {
|
|
88
|
+
await backend.initialize(options);
|
|
89
|
+
} catch (error) {
|
|
90
|
+
if (error instanceof errors.NotFound) {
|
|
91
|
+
let message = "Chromium executable not found. ";
|
|
92
|
+
if (options.browserExecutablePath) {
|
|
93
|
+
message += "Make sure --browser-executable-path is correct.";
|
|
94
|
+
} else {
|
|
95
|
+
message += "Set the path using the --browser-executable-path option.";
|
|
96
|
+
}
|
|
97
|
+
throw new Error(message);
|
|
98
|
+
} else {
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
88
102
|
if (options.crawlSyncSession || options.crawlLoadSession) {
|
|
89
103
|
try {
|
|
90
104
|
tasks = JSON.parse(await readTextFile(options.crawlSyncSession || options.crawlLoadSession));
|