single-file-cli 2.7.1 → 2.8.0

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 CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  set -e
4
4
 
5
- CORE_PACKAGE="npm:single-file-core@1.5.120"
5
+ CORE_PACKAGE="npm:single-file-core@1.5.121"
6
6
  ESBUILD_PACKAGE="npm:esbuild@0.27.7"
7
7
 
8
8
  project_dir=$(pwd)
package/deno.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@single-file/single-file-cli",
3
- "version": "2.7.1",
3
+ "version": "2.8.0",
4
4
  "description": "SingleFile CLI",
5
5
  "exports": {
6
6
  ".": "./single-file-cli-api.js"
package/lib/cdp-client.js CHANGED
@@ -618,17 +618,20 @@ async function waitForPageReadyState({ Page }, state, { options, debugMessages }
618
618
 
619
619
  function createLifecycleEventHandler(state, timeoutState, resolve, cleanup, { options, debugMessages }) {
620
620
  return ({ params }) => {
621
- const { frameId, name } = params;
622
- if (frameId === state.topFrameId) {
623
- logData(["Detecting lifecycle event", name], { options, debugMessages });
624
- const stateIndex = NETWORK_STATES.indexOf(name);
625
- if (stateIndex != -1 && (state.reachedStateIndex == -1 || stateIndex < state.reachedStateIndex)) {
626
- state.reachedStateIndex = stateIndex;
627
- }
621
+ const { frameId, loaderId, name } = params;
622
+ // the frame keeps its ID across documents: the events of the blank page,
623
+ // whose network goes idle while the server has not answered yet, would
624
+ // satisfy the wait and the page would be captured as soon as it commits
625
+ if (frameId !== state.topFrameId || loaderId !== state.loaderId) {
626
+ return;
627
+ }
628
+ logData(["Detecting lifecycle event", name], { options, debugMessages });
629
+ const stateIndex = NETWORK_STATES.indexOf(name);
630
+ if (stateIndex != -1 && (state.reachedStateIndex == -1 || stateIndex < state.reachedStateIndex)) {
631
+ state.reachedStateIndex = stateIndex;
628
632
  }
629
- const shouldResolve = frameId === state.topFrameId &&
630
- (name === options.browserWaitUntil ||
631
- (timeoutState.timeoutId && NETWORK_STATES.indexOf(name) < NETWORK_STATES.indexOf(options.browserWaitUntil)));
633
+ const shouldResolve = name === options.browserWaitUntil ||
634
+ (timeoutState.timeoutId && NETWORK_STATES.indexOf(name) < NETWORK_STATES.indexOf(options.browserWaitUntil));
632
635
  if (shouldResolve) {
633
636
  // the delay is restarted when the page reaches a further state, so
634
637
  // that it is captured once it stopped settling
@@ -660,6 +663,7 @@ function createFrameNavigatedHandler(state, timeoutState, reject, cleanup, { opt
660
663
  clearTimeout(timeoutState.timeoutId);
661
664
  timeoutState.timeoutId = undefined;
662
665
  state.reachedStateIndex = -1;
666
+ state.loaderId = frame.loaderId;
663
667
  }
664
668
  }
665
669
  };