@opensteer/engine-abp 0.8.6 → 0.8.8
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.cjs +59 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -0
- package/dist/index.d.ts +13 -0
- package/dist/index.js +59 -3
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1578,6 +1578,13 @@ async function waitForActionBoundary(input) {
|
|
|
1578
1578
|
continue;
|
|
1579
1579
|
}
|
|
1580
1580
|
if (crossDocument) {
|
|
1581
|
+
if (!postLoadTrackerIsSettled(
|
|
1582
|
+
await input.readTrackerState(),
|
|
1583
|
+
DEFAULT_POST_LOAD_TRACKER_QUIET_WINDOW_MS
|
|
1584
|
+
)) {
|
|
1585
|
+
await delay(Math.min(pollIntervalMs, Math.max(0, deadline - Date.now())));
|
|
1586
|
+
continue;
|
|
1587
|
+
}
|
|
1581
1588
|
return {
|
|
1582
1589
|
trigger,
|
|
1583
1590
|
crossDocument,
|
|
@@ -1725,6 +1732,7 @@ var PAGE_CDP_METHOD_ALLOWLIST = /* @__PURE__ */ new Set([
|
|
|
1725
1732
|
"IndexedDB.requestDatabase",
|
|
1726
1733
|
"IndexedDB.requestDatabaseNames",
|
|
1727
1734
|
"Page.addScriptToEvaluateOnNewDocument",
|
|
1735
|
+
"Page.createIsolatedWorld",
|
|
1728
1736
|
"Page.enable",
|
|
1729
1737
|
"Page.getFrameTree",
|
|
1730
1738
|
"Page.getLayoutMetrics",
|
|
@@ -2409,12 +2417,11 @@ function createAbpActionSettler(context) {
|
|
|
2409
2417
|
}
|
|
2410
2418
|
await beginTrackerObservation(controller);
|
|
2411
2419
|
const tracker = await readTrackerState(controller);
|
|
2420
|
+
const mainFrameUrl = controller.mainFrameRef === void 0 ? void 0 : controller.framesByCdpId.get(controller.mainFrameRef)?.currentDocument.url;
|
|
2412
2421
|
return {
|
|
2413
2422
|
pageRef: controller.pageRef,
|
|
2414
2423
|
documentRef,
|
|
2415
|
-
...
|
|
2416
|
-
url: controller.framesByCdpId.get(controller.mainFrameRef)?.currentDocument.url
|
|
2417
|
-
},
|
|
2424
|
+
...mainFrameUrl === void 0 ? {} : { url: mainFrameUrl },
|
|
2418
2425
|
...tracker === void 0 ? {} : { tracker: capturePostLoadTrackerSnapshot(tracker) }
|
|
2419
2426
|
};
|
|
2420
2427
|
}
|
|
@@ -5684,6 +5691,46 @@ var AbpBrowserCoreEngine = class _AbpBrowserCoreEngine {
|
|
|
5684
5691
|
throw normalizeAbpError(error, controller.pageRef);
|
|
5685
5692
|
}
|
|
5686
5693
|
}
|
|
5694
|
+
async evaluateFrame(input) {
|
|
5695
|
+
const frame = this.requireFrame(input.frameRef);
|
|
5696
|
+
const controller = this.requirePage(frame.pageRef);
|
|
5697
|
+
const startedAt = Date.now();
|
|
5698
|
+
try {
|
|
5699
|
+
const executionContextId = await withTimeout(
|
|
5700
|
+
this.ensureFrameExecutionContext(controller, frame.cdpFrameId),
|
|
5701
|
+
input.timeoutMs
|
|
5702
|
+
);
|
|
5703
|
+
const serialized = JSON.stringify({
|
|
5704
|
+
script: input.script,
|
|
5705
|
+
args: input.args ?? []
|
|
5706
|
+
});
|
|
5707
|
+
const evaluated = await withTimeout(
|
|
5708
|
+
controller.cdp.send("Runtime.evaluate", {
|
|
5709
|
+
contextId: executionContextId,
|
|
5710
|
+
expression: `(() => {
|
|
5711
|
+
const input = ${serialized};
|
|
5712
|
+
const evaluated = (0, eval)(input.script);
|
|
5713
|
+
if (typeof evaluated === "function") {
|
|
5714
|
+
return evaluated(...(input.args ?? []));
|
|
5715
|
+
}
|
|
5716
|
+
return evaluated;
|
|
5717
|
+
})()`,
|
|
5718
|
+
returnByValue: true,
|
|
5719
|
+
awaitPromise: true
|
|
5720
|
+
}),
|
|
5721
|
+
input.timeoutMs
|
|
5722
|
+
);
|
|
5723
|
+
return this.createStepResult(controller.sessionRef, controller.pageRef, startedAt, {
|
|
5724
|
+
frameRef: frame.frameRef,
|
|
5725
|
+
documentRef: frame.currentDocument.documentRef,
|
|
5726
|
+
documentEpoch: frame.currentDocument.documentEpoch,
|
|
5727
|
+
events: this.drainQueuedEvents(controller.pageRef),
|
|
5728
|
+
data: evaluated.result?.value
|
|
5729
|
+
});
|
|
5730
|
+
} catch (error) {
|
|
5731
|
+
throw normalizeAbpError(error, controller.pageRef);
|
|
5732
|
+
}
|
|
5733
|
+
}
|
|
5687
5734
|
async addInitScript(_input) {
|
|
5688
5735
|
throw unsupportedCapabilityError("instrumentation.initScripts");
|
|
5689
5736
|
}
|
|
@@ -6939,6 +6986,15 @@ var AbpBrowserCoreEngine = class _AbpBrowserCoreEngine {
|
|
|
6939
6986
|
}
|
|
6940
6987
|
return frame;
|
|
6941
6988
|
}
|
|
6989
|
+
async ensureFrameExecutionContext(controller, cdpFrameId) {
|
|
6990
|
+
const isolatedWorld = await controller.cdp.send("Page.createIsolatedWorld", {
|
|
6991
|
+
frameId: cdpFrameId,
|
|
6992
|
+
worldName: "__opensteer_snapshot__",
|
|
6993
|
+
// CDP spells this field as `grantUniveralAccess`.
|
|
6994
|
+
grantUniveralAccess: true
|
|
6995
|
+
});
|
|
6996
|
+
return isolatedWorld.executionContextId;
|
|
6997
|
+
}
|
|
6942
6998
|
requireDocument(documentRef) {
|
|
6943
6999
|
const document = this.documents.get(documentRef);
|
|
6944
7000
|
if (!document) {
|