single-file-cli 2.0.16 → 2.0.18

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.16",
3
+ "version": "2.0.18",
4
4
  "description": "SingleFile CLI",
5
5
  "nodeModulesDir": true,
6
6
  "exports": {
package/lib/cdp-client.js CHANGED
@@ -128,13 +128,15 @@ async function getPageData(options) {
128
128
  const pageNavigated = Page.navigate({ url: options.url });
129
129
  const pageReady = new Promise(resolve => {
130
130
  const LIFE_CYCLE_EVENT = "lifecycleEvent";
131
+ const FRAME_NAVIGATED_EVENT = "frameNavigated";
131
132
  let contentLoaded;
132
133
  Page.addEventListener(LIFE_CYCLE_EVENT, onLifecycleEvent);
134
+ Page.addEventListener(FRAME_NAVIGATED_EVENT, onFrameNavigated);
133
135
 
134
136
  async function onLifecycleEvent({ params }) {
135
137
  const { name, frameId } = params;
136
138
  if (frameId === topFrameId) {
137
- if (name === "DOMContentLoaded") {
139
+ if (!contentLoaded && name === "init" || name === "firstPaint") {
138
140
  contentLoaded = true;
139
141
  }
140
142
  if (contentLoaded && name === (options.browserWaitUntil || NETWORK_IDLE_STATE)) {
@@ -142,6 +144,7 @@ async function getPageData(options) {
142
144
  setTimeout(() => resolve, options.browserWaitDelay);
143
145
  } else {
144
146
  Page.removeEventListener(LIFE_CYCLE_EVENT, onLifecycleEvent);
147
+ Page.removeEventListener(FRAME_NAVIGATED_EVENT, onFrameNavigated);
145
148
  await Page.setLifecycleEventsEnabled({ enabled: false });
146
149
  await Page.disable();
147
150
  resolve();
@@ -149,6 +152,13 @@ async function getPageData(options) {
149
152
  }
150
153
  }
151
154
  }
155
+
156
+ async function onFrameNavigated({ params }) {
157
+ const { frame } = params;
158
+ if (!frame.parentId) {
159
+ contextId = undefined;
160
+ }
161
+ }
152
162
  });
153
163
  let timeoutReady, timeoutId, resolveTimeoutReady;
154
164
  if (options.browserLoadMaxTime) {
@@ -182,7 +192,7 @@ async function getPageData(options) {
182
192
 
183
193
  async function executionContextCreated({ params }) {
184
194
  const { context } = params;
185
- if (context.name === SINGLE_FILE_WORLD_NAME && context.auxData && context.auxData.frameId === topFrameId) {
195
+ if (contextId === undefined && context.name === SINGLE_FILE_WORLD_NAME && context.auxData && context.auxData.frameId === topFrameId) {
186
196
  contextId = context.id;
187
197
  }
188
198
  }
package/lib/version.js CHANGED
@@ -1 +1 @@
1
- export const version = "2.0.16";
1
+ export const version = "2.0.18";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "single-file-cli",
3
- "version": "2.0.16",
3
+ "version": "2.0.18",
4
4
  "description": "SingleFile CLI",
5
5
  "author": "Gildas Lormeau",
6
6
  "engines": {
File without changes
File without changes