single-file-cli 2.0.70 → 2.0.72
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/build.sh +1 -1
- package/compile.sh +1 -1
- package/deno.json +2 -2
- package/deno.lock +27 -32
- package/lib/cdp-client.js +30 -16
- package/lib/single-file-bundle.js +1 -1
- package/lib/version.js +1 -1
- package/options.js +2 -1
- package/package.json +1 -1
- package/single-file-cli-api.js +1 -0
package/build.sh
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
mv package.json package.json.tmp
|
|
4
4
|
mv deno.json deno.json.tmp
|
|
5
5
|
mv deno.lock deno.lock.tmp
|
|
6
|
-
deno install --vendor --quiet "npm:single-file-core@1.5.
|
|
6
|
+
deno install --vendor --quiet "npm:single-file-core@1.5.42"
|
|
7
7
|
mv package.json.tmp package.json
|
|
8
8
|
mv deno.json.tmp deno.json
|
|
9
9
|
mv deno.lock.tmp deno.lock
|
package/compile.sh
CHANGED
|
@@ -8,7 +8,7 @@ deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ex
|
|
|
8
8
|
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-x86_64-apple-darwin --target=x86_64-apple-darwin ./single-file
|
|
9
9
|
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-x86_64-linux --target=x86_64-unknown-linux-gnu ./single-file
|
|
10
10
|
deno compile --allow-read --allow-write --allow-net --allow-env --allow-run --ext=js --output=./dist/single-file-aarch64-linux --target=aarch64-unknown-linux-gnu ./single-file
|
|
11
|
-
deno compile --allow-
|
|
11
|
+
deno compile --allow-all --ext=js --output=./dist/single-file.exe --target=x86_64-pc-windows-msvc --icon=./resources/single-file.ico ./single-file
|
|
12
12
|
|
|
13
13
|
dev_id=$(security find-identity -p codesigning -v | grep "Apple Development" | awk '{print $2}')
|
|
14
14
|
codesign -f -s $dev_id ./dist/single-file-aarch64-apple-darwin
|
package/deno.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@single-file/single-file-cli",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.72",
|
|
4
4
|
"description": "SingleFile CLI",
|
|
5
5
|
"nodeModulesDir": "auto",
|
|
6
6
|
"exports": {
|
|
@@ -8,6 +8,6 @@
|
|
|
8
8
|
},
|
|
9
9
|
"imports": {
|
|
10
10
|
"simple-cdp": "jsr:@simple-cdp/simple-cdp@^1.8.5",
|
|
11
|
-
"path": "jsr:@std/path@^0.
|
|
11
|
+
"path": "jsr:@std/path@^0.224.0"
|
|
12
12
|
}
|
|
13
13
|
}
|
package/deno.lock
CHANGED
|
@@ -1,43 +1,38 @@
|
|
|
1
1
|
{
|
|
2
|
-
"version": "
|
|
3
|
-
"
|
|
4
|
-
"
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
2
|
+
"version": "4",
|
|
3
|
+
"specifiers": {
|
|
4
|
+
"jsr:@simple-cdp/simple-cdp@^1.8.5": "1.8.5",
|
|
5
|
+
"jsr:@std/assert@0.224": "0.224.0",
|
|
6
|
+
"jsr:@std/path@0.224": "0.224.0",
|
|
7
|
+
"npm:simple-cdp@^1.8.5": "1.8.5",
|
|
8
|
+
"npm:ws@^8.16.0": "8.16.0"
|
|
9
|
+
},
|
|
10
|
+
"jsr": {
|
|
11
|
+
"@simple-cdp/simple-cdp@1.8.5": {
|
|
12
|
+
"integrity": "7386ca561cd6293bb3115eadf14b8c98d1c41c35a69c79774ea70e5101159413"
|
|
13
|
+
},
|
|
14
|
+
"@std/assert@0.224.0": {
|
|
15
|
+
"integrity": "8643233ec7aec38a940a8264a6e3eed9bfa44e7a71cc6b3c8874213ff401967f"
|
|
10
16
|
},
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
"jsr:@std/assert@^0.220.1"
|
|
22
|
-
]
|
|
23
|
-
}
|
|
17
|
+
"@std/path@0.224.0": {
|
|
18
|
+
"integrity": "55bca6361e5a6d158b9380e82d4981d82d338ec587de02951e2b7c3a24910ee6",
|
|
19
|
+
"dependencies": [
|
|
20
|
+
"jsr:@std/assert"
|
|
21
|
+
]
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"npm": {
|
|
25
|
+
"simple-cdp@1.8.5": {
|
|
26
|
+
"integrity": "sha512-bpXoeCk0mwFrr+8C8vVkhCug5h4HO49GI+MZdnyLQcFVKzTlokrimTjEoc69X2Y2n7mtjzDHTriq6B/kgUeUcA=="
|
|
24
27
|
},
|
|
25
|
-
"
|
|
26
|
-
"
|
|
27
|
-
"integrity": "sha512-bpXoeCk0mwFrr+8C8vVkhCug5h4HO49GI+MZdnyLQcFVKzTlokrimTjEoc69X2Y2n7mtjzDHTriq6B/kgUeUcA==",
|
|
28
|
-
"dependencies": {}
|
|
29
|
-
},
|
|
30
|
-
"ws@8.16.0": {
|
|
31
|
-
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ==",
|
|
32
|
-
"dependencies": {}
|
|
33
|
-
}
|
|
28
|
+
"ws@8.16.0": {
|
|
29
|
+
"integrity": "sha512-HS0c//TP7Ina87TfiPUz1rQzMhHrl/SG2guqRcTOIUYD2q8uhUdNHZYJUaQ8aTGPzCh+c6oawMKW35nFl1dxyQ=="
|
|
34
30
|
}
|
|
35
31
|
},
|
|
36
|
-
"remote": {},
|
|
37
32
|
"workspace": {
|
|
38
33
|
"dependencies": [
|
|
39
34
|
"jsr:@simple-cdp/simple-cdp@^1.8.5",
|
|
40
|
-
"jsr:@std/path
|
|
35
|
+
"jsr:@std/path@0.224"
|
|
41
36
|
],
|
|
42
37
|
"packageJson": {
|
|
43
38
|
"dependencies": [
|
package/lib/cdp-client.js
CHANGED
|
@@ -28,6 +28,7 @@ import { getScriptSource, getHookScriptSource } from "./single-file-script.js";
|
|
|
28
28
|
import { CDP, options } from "simple-cdp";
|
|
29
29
|
|
|
30
30
|
const LOAD_TIMEOUT_ERROR = "ERR_LOAD_TIMEOUT";
|
|
31
|
+
const CAPTURE_TIMEOUT_ERROR = "ERR_CAPTURE_TIMEOUT";
|
|
31
32
|
const NETWORK_STATES = ["InteractiveTime", "networkIdle", "networkAlmostIdle", "load", "DOMContentLoaded"];
|
|
32
33
|
const MINIMIZED_WINDOW_STATE = "minimized";
|
|
33
34
|
const SINGLE_FILE_WORLD_NAME = "singlefile";
|
|
@@ -319,18 +320,31 @@ async function getPageData(options) {
|
|
|
319
320
|
}
|
|
320
321
|
await new Promise(resolve => setTimeout(resolve, options.browserWaitDelay));
|
|
321
322
|
}
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
323
|
+
const captureTimeoutAbortController = new AbortController();
|
|
324
|
+
const captureTimeoutAbortSignal = captureTimeoutAbortController.signal;
|
|
325
|
+
try {
|
|
326
|
+
if (options.debugMessagesFile) {
|
|
327
|
+
debugMessages.push([Date.now(), ["Capturing page"]]);
|
|
328
|
+
}
|
|
329
|
+
const { result } = await Promise.race([
|
|
330
|
+
Runtime.evaluate({
|
|
331
|
+
expression: `(${getPageDataScriptSource.toString()})(${JSON.stringify(options)},${JSON.stringify([SET_SCREENSHOT_FUNCTION_NAME, SET_PDF_FUNCTION_NAME, SET_PAGE_DATA_FUNCTION_NAME, CAPTURE_SCREENSHOT_FUNCTION_NAME, PRINT_TO_PDF_FUNCTION_NAME])})`,
|
|
332
|
+
awaitPromise: true,
|
|
333
|
+
returnByValue: true,
|
|
334
|
+
contextId
|
|
335
|
+
}),
|
|
336
|
+
waitForTimeout(captureTimeoutAbortSignal, options.browserCaptureMaxTime, "Capture timeout", CAPTURE_TIMEOUT_ERROR)
|
|
337
|
+
]);
|
|
338
|
+
const { subtype, description } = result;
|
|
339
|
+
if (subtype === "error") {
|
|
340
|
+
throw new Error(description);
|
|
341
|
+
}
|
|
342
|
+
} finally {
|
|
343
|
+
if (!captureTimeoutAbortSignal.aborted) {
|
|
344
|
+
captureTimeoutAbortController.abort();
|
|
345
|
+
}
|
|
346
|
+
await Runtime.disable();
|
|
347
|
+
await Page.disable();
|
|
334
348
|
}
|
|
335
349
|
const pageData = await pageDataPromise;
|
|
336
350
|
if (options.consoleMessagesFile) {
|
|
@@ -429,7 +443,7 @@ async function loadPage({ Page, Runtime }, options, debugMessages) {
|
|
|
429
443
|
}
|
|
430
444
|
const [contextId] = await Promise.race([
|
|
431
445
|
Promise.all([getTopFrameContextId({ Page, Runtime }, options, debugMessages), Page.navigate({ url: options.url })]),
|
|
432
|
-
|
|
446
|
+
waitForTimeout(loadTimeoutAbortSignal, options.browserLoadMaxTime, "Load timeout", LOAD_TIMEOUT_ERROR)
|
|
433
447
|
]);
|
|
434
448
|
return contextId;
|
|
435
449
|
} finally {
|
|
@@ -555,14 +569,14 @@ async function getTopFrameContextId({ Page, Runtime }, options, debugMessages) {
|
|
|
555
569
|
}
|
|
556
570
|
}
|
|
557
571
|
|
|
558
|
-
function
|
|
572
|
+
function waitForTimeout(abortSignal, maxDelay, errorMessage, errorCode) {
|
|
559
573
|
return new Promise((resolve, reject) => {
|
|
560
574
|
const ABORT_EVENT = "abort";
|
|
561
575
|
abortSignal.addEventListener(ABORT_EVENT, onAbort);
|
|
562
576
|
const timeoutId = setTimeout(() => {
|
|
563
577
|
abortSignal.removeEventListener(ABORT_EVENT, onAbort);
|
|
564
|
-
const error = new Error(
|
|
565
|
-
error.code =
|
|
578
|
+
const error = new Error(errorMessage);
|
|
579
|
+
error.code = errorCode;
|
|
566
580
|
reject(error);
|
|
567
581
|
}, maxDelay);
|
|
568
582
|
|