single-file-cli 2.0.23 → 2.0.25

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@single-file/single-file-cli",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "SingleFile CLI",
5
5
  "nodeModulesDir": true,
6
6
  "exports": {
package/lib/cdp-client.js CHANGED
@@ -34,7 +34,7 @@ const MINIMIZED_WINDOW_STATE = "minimized";
34
34
  const SINGLE_FILE_WORLD_NAME = "singlefile";
35
35
  const EMPTY_PAGE_URL = "about:blank";
36
36
 
37
- export { initialize, getPageData, closeBrowser };
37
+ export { initialize, getPageData, hasPageTargets, closeBrowser };
38
38
 
39
39
  async function initialize(options) {
40
40
  if (options.browserRemoteDebuggingURL) {
@@ -136,21 +136,27 @@ async function getPageData(options) {
136
136
  }
137
137
  }
138
138
 
139
+ async function hasPageTargets() {
140
+ const targets = await CDP.getTargets();
141
+ return targets.filter(target => target.type === "page").length > 0;
142
+ }
143
+
139
144
  async function loadPage({ Page, Runtime }, options) {
145
+ let loadTimeoutAbortController, loadTimeoutAbortSignal;
140
146
  await Runtime.enable();
141
147
  await Page.enable();
142
148
  try {
143
- const loadTimeoutAbortController = new AbortController();
144
- const loadTimeoutAbortSignal = loadTimeoutAbortController.signal;
149
+ loadTimeoutAbortController = new AbortController();
150
+ loadTimeoutAbortSignal = loadTimeoutAbortController.signal;
145
151
  const [contextId] = await Promise.race([
146
152
  Promise.all([getTopFrameContextId({ Page, Runtime }, options), Page.navigate({ url: options.url })]),
147
153
  waitForLoadTimeout(loadTimeoutAbortSignal, options.browserLoadMaxTime)
148
154
  ]);
155
+ return contextId;
156
+ } finally {
149
157
  if (!loadTimeoutAbortSignal.aborted) {
150
158
  loadTimeoutAbortController.abort();
151
159
  }
152
- return contextId;
153
- } finally {
154
160
  await Runtime.disable();
155
161
  await Page.disable();
156
162
  }
@@ -169,7 +175,9 @@ function getTopFrameContextId({ Page, Runtime }, options) {
169
175
 
170
176
  async function onFrameNavigated({ params }) {
171
177
  const { frame } = params;
172
- if (!frame.parentId) {
178
+ if (frame.unreachableUrl) {
179
+ reject(new Error("Unreachable URL: " + frame.unreachableUrl));
180
+ } else if (!frame.parentId) {
173
181
  frameId = frame.id;
174
182
  if (navigationAbortController) {
175
183
  navigationAbortController.abort();
package/lib/constants.js CHANGED
@@ -37,20 +37,17 @@ const BROWSER_ARGS = [
37
37
  "--disable-dev-shm-usage",
38
38
  "--disable-extensions",
39
39
  "--disable-features=ImprovedCookieControls,LazyFrameLoading,GlobalMediaControls,DestroyProfileOnBrowserClose,MediaRouter,DialMediaRouteProvider,AcceptCHFrame,AutoExpandDetailsElement,CertificateTransparencyComponentUpdater,AvoidUnnecessaryBeforeUnloadCheckSync,Translate,HttpsUpgrades,PaintHolding",
40
- "--allow-pre-commit-input",
41
40
  "--disable-hang-monitor",
42
41
  "--disable-ipc-flooding-protection",
43
42
  "--disable-popup-blocking",
44
43
  "--disable-prompt-on-repost",
45
44
  "--disable-renderer-backgrounding",
46
45
  "--force-color-profile=srgb",
47
- "--metrics-recording-only",
48
46
  "--no-first-run",
49
47
  "--enable-automation",
50
48
  "--password-store=basic",
51
49
  "--use-mock-keychain",
52
50
  "--no-service-autorun",
53
- "--export-tagged-pdf",
54
51
  "--disable-search-engine-choice-screen",
55
52
  "--enable-use-zoom-for-dsf=false",
56
53
  "--no-sandbox",
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "2.0.23";
1
+ export const version = "2.0.25";
package/options.js CHANGED
@@ -103,7 +103,7 @@ const OPTIONS_INFO = {
103
103
  "max-resource-size-enabled": { description: "Enable removal of embedded resources exceeding a given size", type: "boolean" },
104
104
  "max-resource-size": { description: "Maximum size of embedded resources in MB (i.e. images, stylesheets, scripts and iframes)", type: "number", defaultValue: 10 },
105
105
  "move-styles-in-head": { description: "Move style elements outside the head element into the head element", type: "boolean" },
106
- "password": { description: "Password of the zip file", type: "string" },
106
+ "password": { description: "Password of the zip file when using --compress-content or --self-extracting-archive", type: "string" },
107
107
  "remove-frames": { description: "Remove frames", type: "boolean" },
108
108
  "remove-hidden-elements": { description: "Remove HTML elements which are not displayed", type: "boolean", defaultValue: true },
109
109
  "remove-unused-styles": { description: "Remove unused CSS rules and unneeded declarations", type: "boolean", defaultValue: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "2.0.23",
3
+ "version": "2.0.25",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "engines": {
@@ -151,7 +151,7 @@ async function finish(options) {
151
151
  }
152
152
  }
153
153
  }
154
- if (!options.browserDebug) {
154
+ if (!options.browserDebug && !options.browserRemoteDebuggingURL && !(await backend.hasPageTargets())) {
155
155
  return backend.closeBrowser();
156
156
  }
157
157
  }
@@ -206,7 +206,7 @@ function createTask(url, options, parentTask, rootTask) {
206
206
  if (!VALID_URL_TEST.test(url)) {
207
207
  try {
208
208
  url = url.replace(/\\/g, "/");
209
- url = url.replace(/#/g, "%23");
209
+ url = url.replace(/#/g, "%23");
210
210
  url = new URL(url, import.meta.url).href;
211
211
  } catch (error) {
212
212
  throw new Error("Invalid URL or file path: " + url);
@@ -21,8 +21,6 @@
21
21
  * Source.
22
22
  */
23
23
 
24
- /* global URL */
25
-
26
24
  import { initialize } from "./single-file-cli-api.js";
27
25
  import { Deno } from "./lib/deno-polyfill.js";
28
26
  import options from "./options.js";
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ node "%~dp0\single-file" %*