single-file-cli 2.0.11 → 2.0.13
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 +1 -1
- package/lib/browser.js +7 -1
- package/lib/cdp-client.js +1 -1
- package/lib/deno-polyfill.js +1 -1
- package/lib/version.js +1 -1
- package/package.json +1 -1
- package/single-file-cli-api.js +1 -1
- package/single-file-launcher.js +47 -43
package/deno.json
CHANGED
package/lib/browser.js
CHANGED
|
@@ -66,7 +66,13 @@ 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
|
-
|
|
69
|
+
let message = "Chromium executable not found. ";
|
|
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);
|
|
70
76
|
}
|
|
71
77
|
} else {
|
|
72
78
|
throw error;
|
package/lib/cdp-client.js
CHANGED
|
@@ -43,7 +43,7 @@ async function initialize(options) {
|
|
|
43
43
|
async function getPageData(options) {
|
|
44
44
|
let targetInfo;
|
|
45
45
|
try {
|
|
46
|
-
const targetInfo = await CDP.createTarget(
|
|
46
|
+
const targetInfo = await CDP.createTarget(EMPTY_PAGE_URL);
|
|
47
47
|
const { Browser, Security, Page, Emulation, Fetch, Network, Runtime, Debugger } = new CDP(targetInfo);
|
|
48
48
|
if (options.browserStartMinimized) {
|
|
49
49
|
const { windowId, bounds } = await Browser.getWindowForTarget({ targetId: targetInfo.targetId });
|
package/lib/deno-polyfill.js
CHANGED
|
@@ -167,7 +167,7 @@ async function makeTempDir() {
|
|
|
167
167
|
} else {
|
|
168
168
|
const fsPromise = await import(NODE_MODULES["fs"]);
|
|
169
169
|
const os = await import(NODE_MODULES["os"]);
|
|
170
|
-
return fsPromise.mkdtemp(path.join(os.tmpdir()));
|
|
170
|
+
return fsPromise.mkdtemp(path.join(os.tmpdir(), "/"));
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
173
|
|
package/lib/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const version = "2.0.
|
|
1
|
+
export const version = "2.0.13";
|
package/package.json
CHANGED
package/single-file-cli-api.js
CHANGED
|
@@ -248,7 +248,7 @@ async function capturePage(options) {
|
|
|
248
248
|
if (options.compressContent) {
|
|
249
249
|
await stdout.write(pageData.content);
|
|
250
250
|
} else {
|
|
251
|
-
console.log(pageData.content); // eslint-disable-line no-console
|
|
251
|
+
console.log(pageData.content || ""); // eslint-disable-line no-console
|
|
252
252
|
}
|
|
253
253
|
} else {
|
|
254
254
|
filename = await getFilename(pageData.filename, options);
|
package/single-file-launcher.js
CHANGED
|
@@ -33,53 +33,57 @@ const { toFileUrl } = path;
|
|
|
33
33
|
export { run };
|
|
34
34
|
|
|
35
35
|
async function run() {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
options.url
|
|
39
|
-
|
|
40
|
-
if (options.urlsFile) {
|
|
41
|
-
urls = (await readTextFile(options.urlsFile)).split("\n");
|
|
42
|
-
} else {
|
|
43
|
-
urls = [options.url];
|
|
44
|
-
}
|
|
45
|
-
if (options.browserCookies) {
|
|
46
|
-
const cookies = [];
|
|
47
|
-
for (const cookie of options.browserCookies) {
|
|
48
|
-
const [name, value, domain, path, expires, httpOnly, secure, sameSite, url] = cookie.split(",");
|
|
49
|
-
cookies.push({
|
|
50
|
-
name,
|
|
51
|
-
value,
|
|
52
|
-
url,
|
|
53
|
-
domain,
|
|
54
|
-
path,
|
|
55
|
-
secure,
|
|
56
|
-
httpOnly,
|
|
57
|
-
sameSite,
|
|
58
|
-
expires
|
|
59
|
-
});
|
|
36
|
+
try {
|
|
37
|
+
let urls;
|
|
38
|
+
if (options.url && !VALID_URL_TEST.test(options.url)) {
|
|
39
|
+
options.url = (await toFileUrl(new URL(options.url, import.meta.url).pathname)).href;
|
|
60
40
|
}
|
|
61
|
-
options.
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
try {
|
|
66
|
-
options.browserCookies = JSON.parse(cookiesContent);
|
|
67
|
-
} catch (error) {
|
|
68
|
-
options.browserCookies = parseCookies(cookiesContent);
|
|
41
|
+
if (options.urlsFile) {
|
|
42
|
+
urls = (await readTextFile(options.urlsFile)).split("\n");
|
|
43
|
+
} else {
|
|
44
|
+
urls = [options.url];
|
|
69
45
|
}
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
46
|
+
if (options.browserCookies) {
|
|
47
|
+
const cookies = [];
|
|
48
|
+
for (const cookie of options.browserCookies) {
|
|
49
|
+
const [name, value, domain, path, expires, httpOnly, secure, sameSite, url] = cookie.split(",");
|
|
50
|
+
cookies.push({
|
|
51
|
+
name,
|
|
52
|
+
value,
|
|
53
|
+
url,
|
|
54
|
+
domain,
|
|
55
|
+
path,
|
|
56
|
+
secure,
|
|
57
|
+
httpOnly,
|
|
58
|
+
sameSite,
|
|
59
|
+
expires
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
options.browserCookies = cookies;
|
|
63
|
+
}
|
|
64
|
+
if (options.browserCookiesFile) {
|
|
65
|
+
const cookiesContent = await readTextFile(options.browserCookiesFile);
|
|
66
|
+
try {
|
|
67
|
+
options.browserCookies = JSON.parse(cookiesContent);
|
|
68
|
+
} catch (error) {
|
|
69
|
+
options.browserCookies = parseCookies(cookiesContent);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
if (options.httpHeaders) {
|
|
73
|
+
const headers = {};
|
|
74
|
+
for (const header of options.httpHeaders) {
|
|
75
|
+
const [name, value] = header.split("=");
|
|
76
|
+
headers[name] = value.trim();
|
|
77
|
+
}
|
|
78
|
+
options.httpHeaders = headers;
|
|
76
79
|
}
|
|
77
|
-
options.
|
|
80
|
+
options.retrieveLinks = true;
|
|
81
|
+
const singlefile = await initialize(options);
|
|
82
|
+
await singlefile.capture(urls);
|
|
83
|
+
await singlefile.finish();
|
|
84
|
+
} catch (error) {
|
|
85
|
+
console.error(error.message || error); // eslint-disable-line no-console
|
|
78
86
|
}
|
|
79
|
-
options.retrieveLinks = true;
|
|
80
|
-
const singlefile = await initialize(options);
|
|
81
|
-
await singlefile.capture(urls);
|
|
82
|
-
await singlefile.finish();
|
|
83
87
|
}
|
|
84
88
|
|
|
85
89
|
function parseCookies(textValue) {
|