@hyperframes/producer 0.4.1 → 0.4.3
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/public-server.js
CHANGED
|
@@ -101584,6 +101584,45 @@ var pooledBrowser = null;
|
|
|
101584
101584
|
var pooledBrowserRefCount = 0;
|
|
101585
101585
|
var pooledCaptureMode = "screenshot";
|
|
101586
101586
|
var ENABLE_BROWSER_POOL = DEFAULT_CONFIG.enableBrowserPool;
|
|
101587
|
+
var BEGINFRAME_ONLY_FLAGS = /* @__PURE__ */ new Set([
|
|
101588
|
+
"--deterministic-mode",
|
|
101589
|
+
"--enable-begin-frame-control",
|
|
101590
|
+
"--disable-new-content-rendering-timeout",
|
|
101591
|
+
"--run-all-compositor-stages-before-draw",
|
|
101592
|
+
"--disable-threaded-animation",
|
|
101593
|
+
"--disable-threaded-scrolling",
|
|
101594
|
+
"--disable-checker-imaging",
|
|
101595
|
+
"--disable-image-animation-resync",
|
|
101596
|
+
"--enable-surface-synchronization"
|
|
101597
|
+
]);
|
|
101598
|
+
function stripBeginFrameFlags(args) {
|
|
101599
|
+
return args.filter((a) => !BEGINFRAME_ONLY_FLAGS.has(a));
|
|
101600
|
+
}
|
|
101601
|
+
async function probeBeginFrameSupport(browser) {
|
|
101602
|
+
let page;
|
|
101603
|
+
try {
|
|
101604
|
+
page = await browser.newPage();
|
|
101605
|
+
const client = await page.createCDPSession();
|
|
101606
|
+
await client.send("HeadlessExperimental.enable");
|
|
101607
|
+
const beginFrame = client.send("HeadlessExperimental.beginFrame", {
|
|
101608
|
+
frameTimeTicks: 0,
|
|
101609
|
+
interval: 33,
|
|
101610
|
+
noDisplayUpdates: true
|
|
101611
|
+
});
|
|
101612
|
+
const timeout2 = new Promise(
|
|
101613
|
+
(_, reject) => setTimeout(() => reject(new Error("beginFrame probe timeout")), 2e3)
|
|
101614
|
+
);
|
|
101615
|
+
await Promise.race([beginFrame, timeout2]);
|
|
101616
|
+
await client.detach().catch(() => {
|
|
101617
|
+
});
|
|
101618
|
+
return true;
|
|
101619
|
+
} catch {
|
|
101620
|
+
return false;
|
|
101621
|
+
} finally {
|
|
101622
|
+
await page?.close().catch(() => {
|
|
101623
|
+
});
|
|
101624
|
+
}
|
|
101625
|
+
}
|
|
101587
101626
|
async function acquireBrowser(chromeArgs, config2) {
|
|
101588
101627
|
const enablePool = config2?.enableBrowserPool ?? DEFAULT_CONFIG.enableBrowserPool;
|
|
101589
101628
|
if (enablePool && pooledBrowser) {
|
|
@@ -101603,14 +101642,35 @@ async function acquireBrowser(chromeArgs, config2) {
|
|
|
101603
101642
|
executablePath2 = headlessShell ?? void 0;
|
|
101604
101643
|
}
|
|
101605
101644
|
const ppt = await getPuppeteer();
|
|
101606
|
-
const
|
|
101645
|
+
const browserTimeout = config2?.browserTimeout ?? DEFAULT_CONFIG.browserTimeout;
|
|
101646
|
+
const protocolTimeout = config2?.protocolTimeout ?? DEFAULT_CONFIG.protocolTimeout;
|
|
101647
|
+
let browser = await ppt.launch({
|
|
101607
101648
|
headless: true,
|
|
101608
101649
|
args: chromeArgs,
|
|
101609
101650
|
defaultViewport: null,
|
|
101610
101651
|
executablePath: executablePath2,
|
|
101611
|
-
timeout:
|
|
101612
|
-
protocolTimeout
|
|
101652
|
+
timeout: browserTimeout,
|
|
101653
|
+
protocolTimeout
|
|
101613
101654
|
});
|
|
101655
|
+
if (captureMode === "beginframe") {
|
|
101656
|
+
const supported = await probeBeginFrameSupport(browser).catch(() => true);
|
|
101657
|
+
if (!supported) {
|
|
101658
|
+
await browser.close().catch(() => {
|
|
101659
|
+
});
|
|
101660
|
+
console.warn(
|
|
101661
|
+
"[BrowserManager] HeadlessExperimental.beginFrame unavailable in this Chromium build; falling back to screenshot mode."
|
|
101662
|
+
);
|
|
101663
|
+
captureMode = "screenshot";
|
|
101664
|
+
browser = await ppt.launch({
|
|
101665
|
+
headless: true,
|
|
101666
|
+
args: stripBeginFrameFlags(chromeArgs),
|
|
101667
|
+
defaultViewport: null,
|
|
101668
|
+
executablePath: executablePath2,
|
|
101669
|
+
timeout: browserTimeout,
|
|
101670
|
+
protocolTimeout
|
|
101671
|
+
});
|
|
101672
|
+
}
|
|
101673
|
+
}
|
|
101614
101674
|
if (enablePool) {
|
|
101615
101675
|
pooledBrowser = browser;
|
|
101616
101676
|
pooledBrowserRefCount = 1;
|