single-file-cli 2.0.24 → 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.24",
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, hasTargets, closeBrowser };
37
+ export { initialize, getPageData, hasPageTargets, closeBrowser };
38
38
 
39
39
  async function initialize(options) {
40
40
  if (options.browserRemoteDebuggingURL) {
@@ -45,11 +45,10 @@ async function initialize(options) {
45
45
  }
46
46
 
47
47
  async function getPageData(options) {
48
- let Browser, Security, Page, Emulation, Fetch, Network, Runtime, Debugger, Target;
49
48
  let targetInfo;
50
49
  try {
51
50
  targetInfo = await CDP.createTarget(EMPTY_PAGE_URL);
52
- ({ Browser, Security, Page, Emulation, Fetch, Network, Runtime, Debugger, Target } = new CDP(targetInfo));
51
+ const { Browser, Security, Page, Emulation, Fetch, Network, Runtime, Debugger } = new CDP(targetInfo);
53
52
  if (options.browserStartMinimized) {
54
53
  const { windowId, bounds } = await Browser.getWindowForTarget({ targetId: targetInfo.id });
55
54
  if (bounds.windowState !== MINIMIZED_WINDOW_STATE) {
@@ -131,32 +130,33 @@ async function getPageData(options) {
131
130
  }
132
131
  throw error;
133
132
  } finally {
134
- if (targetInfo) {
133
+ if (targetInfo && !options.browserDebug) {
135
134
  await CDP.closeTarget(targetInfo.id);
136
135
  }
137
136
  }
138
137
  }
139
138
 
140
- async function hasTargets() {
139
+ async function hasPageTargets() {
141
140
  const targets = await CDP.getTargets();
142
141
  return targets.filter(target => target.type === "page").length > 0;
143
142
  }
144
143
 
145
144
  async function loadPage({ Page, Runtime }, options) {
145
+ let loadTimeoutAbortController, loadTimeoutAbortSignal;
146
146
  await Runtime.enable();
147
147
  await Page.enable();
148
148
  try {
149
- const loadTimeoutAbortController = new AbortController();
150
- const loadTimeoutAbortSignal = loadTimeoutAbortController.signal;
149
+ loadTimeoutAbortController = new AbortController();
150
+ loadTimeoutAbortSignal = loadTimeoutAbortController.signal;
151
151
  const [contextId] = await Promise.race([
152
152
  Promise.all([getTopFrameContextId({ Page, Runtime }, options), Page.navigate({ url: options.url })]),
153
153
  waitForLoadTimeout(loadTimeoutAbortSignal, options.browserLoadMaxTime)
154
154
  ]);
155
+ return contextId;
156
+ } finally {
155
157
  if (!loadTimeoutAbortSignal.aborted) {
156
158
  loadTimeoutAbortController.abort();
157
159
  }
158
- return contextId;
159
- } finally {
160
160
  await Runtime.disable();
161
161
  await Page.disable();
162
162
  }
@@ -175,7 +175,9 @@ function getTopFrameContextId({ Page, Runtime }, options) {
175
175
 
176
176
  async function onFrameNavigated({ params }) {
177
177
  const { frame } = params;
178
- if (!frame.parentId) {
178
+ if (frame.unreachableUrl) {
179
+ reject(new Error("Unreachable URL: " + frame.unreachableUrl));
180
+ } else if (!frame.parentId) {
179
181
  frameId = frame.id;
180
182
  if (navigationAbortController) {
181
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.24";
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.24",
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 && !options.browserRemoteDebuggingURL && !(await backend.hasTargets())) {
154
+ if (!options.browserDebug && !options.browserRemoteDebuggingURL && !(await backend.hasPageTargets())) {
155
155
  return backend.closeBrowser();
156
156
  }
157
157
  }
@@ -0,0 +1,2 @@
1
+ @echo off
2
+ node "%~dp0\single-file" %*