getobsrv 0.7.1 → 0.7.2
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/out/main/index.js +20 -0
- package/package.json +1 -1
package/out/main/index.js
CHANGED
|
@@ -660,6 +660,7 @@ function registerIpc(ctx) {
|
|
|
660
660
|
});
|
|
661
661
|
electron.ipcMain.handle(IPC.setViewport, (e, width, height, rawDsf) => {
|
|
662
662
|
assertRenderer(e);
|
|
663
|
+
viewportArrived = true;
|
|
663
664
|
const dsf = parseDeviceScaleFactor(rawDsf);
|
|
664
665
|
if (dsf === null) throw new Error("invalid deviceScaleFactor");
|
|
665
666
|
const v = target.setViewport(width, height, dsf);
|
|
@@ -714,6 +715,7 @@ function registerIpc(ctx) {
|
|
|
714
715
|
waiter(report);
|
|
715
716
|
});
|
|
716
717
|
const scrollBoth = async (req) => {
|
|
718
|
+
await awaitViewportStable();
|
|
717
719
|
const base = { x: req.x, y: req.y };
|
|
718
720
|
if (req.selector !== void 0) base.selector = req.selector;
|
|
719
721
|
if (!native.webContents.isDestroyed()) native.webContents.send(IPC.applyScroll, base);
|
|
@@ -786,6 +788,18 @@ function registerIpc(ctx) {
|
|
|
786
788
|
}
|
|
787
789
|
}
|
|
788
790
|
});
|
|
791
|
+
let viewportPending = false;
|
|
792
|
+
let viewportArrived = false;
|
|
793
|
+
const VIEWPORT_ARRIVAL_MS = 600;
|
|
794
|
+
const awaitViewportStable = async () => {
|
|
795
|
+
if (!viewportPending) return;
|
|
796
|
+
viewportPending = false;
|
|
797
|
+
const arrivalDeadline = Date.now() + VIEWPORT_ARRIVAL_MS;
|
|
798
|
+
while (!viewportArrived && Date.now() < arrivalDeadline) {
|
|
799
|
+
await new Promise((r) => setTimeout(r, SETTLE_POLL_MS));
|
|
800
|
+
}
|
|
801
|
+
await settleTarget();
|
|
802
|
+
};
|
|
789
803
|
const SETTLE_POLL_MS = 80;
|
|
790
804
|
const SETTLE_STABLE_READS = 2;
|
|
791
805
|
const SETTLE_BUDGET_MS = 4e3;
|
|
@@ -880,6 +894,10 @@ function registerIpc(ctx) {
|
|
|
880
894
|
navigate: navigateBoth,
|
|
881
895
|
apply: (patch) => {
|
|
882
896
|
if (win.isDestroyed()) return;
|
|
897
|
+
if (patch.presetId !== void 0) {
|
|
898
|
+
viewportPending = true;
|
|
899
|
+
viewportArrived = false;
|
|
900
|
+
}
|
|
883
901
|
if (!rendererReported) {
|
|
884
902
|
if (pendingApplies.length >= MAX_PENDING_APPLIES) {
|
|
885
903
|
if (!warnedPendingOverflow) {
|
|
@@ -894,12 +912,14 @@ function registerIpc(ctx) {
|
|
|
894
912
|
win.webContents.send(IPC.agentApply, patch);
|
|
895
913
|
},
|
|
896
914
|
captureVisible: async () => {
|
|
915
|
+
await awaitViewportStable();
|
|
897
916
|
await settleTarget();
|
|
898
917
|
const image = await win.webContents.capturePage();
|
|
899
918
|
const size = image.getSize();
|
|
900
919
|
return { data: image.toPNG().toString("base64"), width: size.width, height: size.height };
|
|
901
920
|
},
|
|
902
921
|
captureTarget: async () => {
|
|
922
|
+
await awaitViewportStable();
|
|
903
923
|
const settled = await settleTarget();
|
|
904
924
|
const bounds = canvasBounds ?? targetBounds;
|
|
905
925
|
const known = bounds !== null && bounds.width >= 1 && bounds.height >= 1;
|