@hyperframes/producer 0.4.1 → 0.4.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/dist/index.js +63 -3
- package/dist/index.js.map +3 -3
- package/dist/public-server.js +63 -3
- package/dist/public-server.js.map +3 -3
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -98795,6 +98795,45 @@ var pooledBrowser = null;
|
|
|
98795
98795
|
var pooledBrowserRefCount = 0;
|
|
98796
98796
|
var pooledCaptureMode = "screenshot";
|
|
98797
98797
|
var ENABLE_BROWSER_POOL = DEFAULT_CONFIG.enableBrowserPool;
|
|
98798
|
+
var BEGINFRAME_ONLY_FLAGS = /* @__PURE__ */ new Set([
|
|
98799
|
+
"--deterministic-mode",
|
|
98800
|
+
"--enable-begin-frame-control",
|
|
98801
|
+
"--disable-new-content-rendering-timeout",
|
|
98802
|
+
"--run-all-compositor-stages-before-draw",
|
|
98803
|
+
"--disable-threaded-animation",
|
|
98804
|
+
"--disable-threaded-scrolling",
|
|
98805
|
+
"--disable-checker-imaging",
|
|
98806
|
+
"--disable-image-animation-resync",
|
|
98807
|
+
"--enable-surface-synchronization"
|
|
98808
|
+
]);
|
|
98809
|
+
function stripBeginFrameFlags(args) {
|
|
98810
|
+
return args.filter((a) => !BEGINFRAME_ONLY_FLAGS.has(a));
|
|
98811
|
+
}
|
|
98812
|
+
async function probeBeginFrameSupport(browser) {
|
|
98813
|
+
let page;
|
|
98814
|
+
try {
|
|
98815
|
+
page = await browser.newPage();
|
|
98816
|
+
const client = await page.createCDPSession();
|
|
98817
|
+
await client.send("HeadlessExperimental.enable");
|
|
98818
|
+
const beginFrame = client.send("HeadlessExperimental.beginFrame", {
|
|
98819
|
+
frameTimeTicks: 0,
|
|
98820
|
+
interval: 33,
|
|
98821
|
+
noDisplayUpdates: true
|
|
98822
|
+
});
|
|
98823
|
+
const timeout2 = new Promise(
|
|
98824
|
+
(_, reject) => setTimeout(() => reject(new Error("beginFrame probe timeout")), 2e3)
|
|
98825
|
+
);
|
|
98826
|
+
await Promise.race([beginFrame, timeout2]);
|
|
98827
|
+
await client.detach().catch(() => {
|
|
98828
|
+
});
|
|
98829
|
+
return true;
|
|
98830
|
+
} catch {
|
|
98831
|
+
return false;
|
|
98832
|
+
} finally {
|
|
98833
|
+
await page?.close().catch(() => {
|
|
98834
|
+
});
|
|
98835
|
+
}
|
|
98836
|
+
}
|
|
98798
98837
|
async function acquireBrowser(chromeArgs, config2) {
|
|
98799
98838
|
const enablePool = config2?.enableBrowserPool ?? DEFAULT_CONFIG.enableBrowserPool;
|
|
98800
98839
|
if (enablePool && pooledBrowser) {
|
|
@@ -98814,14 +98853,35 @@ async function acquireBrowser(chromeArgs, config2) {
|
|
|
98814
98853
|
executablePath2 = headlessShell ?? void 0;
|
|
98815
98854
|
}
|
|
98816
98855
|
const ppt = await getPuppeteer();
|
|
98817
|
-
const
|
|
98856
|
+
const browserTimeout = config2?.browserTimeout ?? DEFAULT_CONFIG.browserTimeout;
|
|
98857
|
+
const protocolTimeout = config2?.protocolTimeout ?? DEFAULT_CONFIG.protocolTimeout;
|
|
98858
|
+
let browser = await ppt.launch({
|
|
98818
98859
|
headless: true,
|
|
98819
98860
|
args: chromeArgs,
|
|
98820
98861
|
defaultViewport: null,
|
|
98821
98862
|
executablePath: executablePath2,
|
|
98822
|
-
timeout:
|
|
98823
|
-
protocolTimeout
|
|
98863
|
+
timeout: browserTimeout,
|
|
98864
|
+
protocolTimeout
|
|
98824
98865
|
});
|
|
98866
|
+
if (captureMode === "beginframe") {
|
|
98867
|
+
const supported = await probeBeginFrameSupport(browser).catch(() => true);
|
|
98868
|
+
if (!supported) {
|
|
98869
|
+
await browser.close().catch(() => {
|
|
98870
|
+
});
|
|
98871
|
+
console.warn(
|
|
98872
|
+
"[BrowserManager] HeadlessExperimental.beginFrame unavailable in this Chromium build; falling back to screenshot mode."
|
|
98873
|
+
);
|
|
98874
|
+
captureMode = "screenshot";
|
|
98875
|
+
browser = await ppt.launch({
|
|
98876
|
+
headless: true,
|
|
98877
|
+
args: stripBeginFrameFlags(chromeArgs),
|
|
98878
|
+
defaultViewport: null,
|
|
98879
|
+
executablePath: executablePath2,
|
|
98880
|
+
timeout: browserTimeout,
|
|
98881
|
+
protocolTimeout
|
|
98882
|
+
});
|
|
98883
|
+
}
|
|
98884
|
+
}
|
|
98825
98885
|
if (enablePool) {
|
|
98826
98886
|
pooledBrowser = browser;
|
|
98827
98887
|
pooledBrowserRefCount = 1;
|