autokap 1.3.29 → 1.3.30
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/browser.js +19 -4
- package/package.json +1 -1
package/dist/browser.js
CHANGED
|
@@ -1042,10 +1042,20 @@ export class Browser {
|
|
|
1042
1042
|
});
|
|
1043
1043
|
instance.browser = instance.context.browser();
|
|
1044
1044
|
instance.persistentContext = true;
|
|
1045
|
-
|
|
1046
|
-
|
|
1045
|
+
// launchPersistentContext opens an initial about:blank page automatically.
|
|
1046
|
+
// Reuse it instead of closing it + opening a new one: Chromium's --kiosk
|
|
1047
|
+
// mode blocks `Target.createTarget` (one-window-only enforcement), so
|
|
1048
|
+
// `context.newPage()` would fail with "Failed to open a new tab" — which
|
|
1049
|
+
// is exactly what bricked 1.3.29. The init scripts registered below run
|
|
1050
|
+
// on the next navigation regardless of when the page was created.
|
|
1051
|
+
const existingPages = instance.context.pages();
|
|
1052
|
+
instance.page = existingPages[0] ?? await instance.context.newPage();
|
|
1053
|
+
// Defensive: close any extra pages Chromium might have opened (unlikely
|
|
1054
|
+
// under --kiosk but cheap insurance). Keep index 0.
|
|
1055
|
+
for (let i = 1; i < existingPages.length; i++) {
|
|
1056
|
+
await existingPages[i].close().catch(() => undefined);
|
|
1047
1057
|
}
|
|
1048
|
-
logger.info(`[capture] Cloud clip capture: persistent Chromium profile seeded at ${cloudChromiumProfileDir}`);
|
|
1058
|
+
logger.info(`[capture] Cloud clip capture: persistent Chromium profile seeded at ${cloudChromiumProfileDir} (reusing initial page, kiosk blocks Target.createTarget)`);
|
|
1049
1059
|
}
|
|
1050
1060
|
else {
|
|
1051
1061
|
// Non-cloud clip capture keeps the regular browser + incognito context
|
|
@@ -1098,7 +1108,12 @@ export class Browser {
|
|
|
1098
1108
|
document.addEventListener('DOMContentLoaded', install, { once: true });
|
|
1099
1109
|
}
|
|
1100
1110
|
}, { styleId: CAPTURE_HIDE_STYLE_ID, css: getCaptureHideCSS() });
|
|
1101
|
-
instance.page
|
|
1111
|
+
// Persistent context (cloud) already set instance.page by reusing the
|
|
1112
|
+
// initial page launchPersistentContext opened. Only call newPage() for
|
|
1113
|
+
// the regular browser+context path (Mac/Win/local Linux).
|
|
1114
|
+
if (!instance.page) {
|
|
1115
|
+
instance.page = await instance.context.newPage();
|
|
1116
|
+
}
|
|
1102
1117
|
// Cloud Run only: force the page window to fullscreen via CDP. The
|
|
1103
1118
|
// --kiosk launch flag is silently ignored by Chromium for windows
|
|
1104
1119
|
// created by Playwright via Target.createTarget (CDP) — kiosk only
|