@opensteer/engine-playwright 0.8.4 → 0.8.6

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/dist/index.d.cts CHANGED
@@ -770,6 +770,12 @@ interface BrowserInspector {
770
770
  readonly args?: readonly unknown[];
771
771
  readonly timeoutMs?: number;
772
772
  }): Promise<StepResult<unknown>>;
773
+ evaluateFrame(input: {
774
+ readonly frameRef: FrameRef;
775
+ readonly script: string;
776
+ readonly args?: readonly unknown[];
777
+ readonly timeoutMs?: number;
778
+ }): Promise<StepResult<unknown>>;
773
779
  }
774
780
  interface SessionTransportExecutor {
775
781
  readonly capabilities: Readonly<BrowserCapabilities>;
@@ -1191,6 +1197,12 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
1191
1197
  readonly args?: readonly unknown[];
1192
1198
  readonly timeoutMs?: number;
1193
1199
  }): Promise<StepResult<unknown>>;
1200
+ evaluateFrame(input: {
1201
+ readonly frameRef: FrameRef;
1202
+ readonly script: string;
1203
+ readonly args?: readonly unknown[];
1204
+ readonly timeoutMs?: number;
1205
+ }): Promise<StepResult<unknown>>;
1194
1206
  addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
1195
1207
  registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
1196
1208
  executeRequest(input: {
package/dist/index.d.ts CHANGED
@@ -770,6 +770,12 @@ interface BrowserInspector {
770
770
  readonly args?: readonly unknown[];
771
771
  readonly timeoutMs?: number;
772
772
  }): Promise<StepResult<unknown>>;
773
+ evaluateFrame(input: {
774
+ readonly frameRef: FrameRef;
775
+ readonly script: string;
776
+ readonly args?: readonly unknown[];
777
+ readonly timeoutMs?: number;
778
+ }): Promise<StepResult<unknown>>;
773
779
  }
774
780
  interface SessionTransportExecutor {
775
781
  readonly capabilities: Readonly<BrowserCapabilities>;
@@ -1191,6 +1197,12 @@ declare class PlaywrightBrowserCoreEngine implements BrowserCoreEngine {
1191
1197
  readonly args?: readonly unknown[];
1192
1198
  readonly timeoutMs?: number;
1193
1199
  }): Promise<StepResult<unknown>>;
1200
+ evaluateFrame(input: {
1201
+ readonly frameRef: FrameRef;
1202
+ readonly script: string;
1203
+ readonly args?: readonly unknown[];
1204
+ readonly timeoutMs?: number;
1205
+ }): Promise<StepResult<unknown>>;
1194
1206
  addInitScript(input: BrowserInitScriptInput): Promise<BrowserInitScriptRegistration>;
1195
1207
  registerRoute(input: BrowserRouteRegistrationInput): Promise<BrowserRouteRegistration>;
1196
1208
  executeRequest(input: {
package/dist/index.js CHANGED
@@ -1576,6 +1576,13 @@ async function waitForActionBoundary(input) {
1576
1576
  continue;
1577
1577
  }
1578
1578
  if (crossDocument) {
1579
+ if (!postLoadTrackerIsSettled(
1580
+ await input.readTrackerState(),
1581
+ DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS
1582
+ )) {
1583
+ await delay(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
1584
+ continue;
1585
+ }
1579
1586
  return {
1580
1587
  trigger,
1581
1588
  crossDocument,
@@ -4948,6 +4955,39 @@ var PlaywrightBrowserCoreEngine = class _PlaywrightBrowserCoreEngine {
4948
4955
  throw normalizePlaywrightError(error, controller.pageRef);
4949
4956
  }
4950
4957
  }
4958
+ async evaluateFrame(input) {
4959
+ const frameState = this.requireFrame(input.frameRef);
4960
+ const controller = this.requirePage(frameState.pageRef);
4961
+ const startedAt = Date.now();
4962
+ const frame = this.requireLiveFrame(input.frameRef);
4963
+ try {
4964
+ const result = await withTimeout(
4965
+ frame.evaluate(
4966
+ ({ script, args }) => {
4967
+ const evaluated = (0, eval)(script);
4968
+ if (typeof evaluated === "function") {
4969
+ return evaluated(...args ?? []);
4970
+ }
4971
+ return evaluated;
4972
+ },
4973
+ {
4974
+ script: input.script,
4975
+ args: input.args ?? []
4976
+ }
4977
+ ),
4978
+ input.timeoutMs
4979
+ );
4980
+ return this.createStepResult(controller.sessionRef, controller.pageRef, startedAt, {
4981
+ frameRef: frameState.frameRef,
4982
+ documentRef: frameState.currentDocument.documentRef,
4983
+ documentEpoch: frameState.currentDocument.documentEpoch,
4984
+ events: this.drainQueuedEvents(controller.pageRef),
4985
+ data: result
4986
+ });
4987
+ } catch (error) {
4988
+ throw normalizePlaywrightError(error, controller.pageRef);
4989
+ }
4990
+ }
4951
4991
  async addInitScript(input) {
4952
4992
  if (!hasCapability(this.capabilities, "instrumentation.initScripts")) {
4953
4993
  throw unsupportedCapabilityError("instrumentation.initScripts");