@hyperframes/producer 0.9.96 → 0.9.98
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/distributed.js +82 -23
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +65 -65
- package/dist/index.js +136 -55
- package/dist/public-server.js +134 -55
- package/dist/renderRequest.d.ts +2 -0
- package/dist/services/render/stages/captureStreamingStage.d.ts +1 -0
- package/package.json +7 -7
package/dist/distributed.js
CHANGED
|
@@ -1832,6 +1832,19 @@ function captureModeLabel(mode) {
|
|
|
1832
1832
|
if (mode === "beginframe") return "BeginFrame";
|
|
1833
1833
|
return "screenshot";
|
|
1834
1834
|
}
|
|
1835
|
+
var OPENING_CAPTURE_SESSION = {
|
|
1836
|
+
captureMode: "screenshot",
|
|
1837
|
+
captureStep: "opening the capture session"
|
|
1838
|
+
};
|
|
1839
|
+
async function openCaptureSessionWithinBudget(withinInitBudget, opening) {
|
|
1840
|
+
try {
|
|
1841
|
+
return await withinInitBudget(opening, OPENING_CAPTURE_SESSION);
|
|
1842
|
+
} catch (error) {
|
|
1843
|
+
void opening.then(closeCaptureSession).catch(() => {
|
|
1844
|
+
});
|
|
1845
|
+
throw error;
|
|
1846
|
+
}
|
|
1847
|
+
}
|
|
1835
1848
|
var SequentialCaptureStallError = class extends Error {
|
|
1836
1849
|
captureMode;
|
|
1837
1850
|
constructor(session, stallTimeoutMs, frameIndex, totalFrames) {
|
|
@@ -1845,20 +1858,44 @@ var SequentialCaptureStallError = class extends Error {
|
|
|
1845
1858
|
};
|
|
1846
1859
|
function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
1847
1860
|
return new Promise((resolve11, reject) => {
|
|
1848
|
-
const
|
|
1849
|
-
|
|
1850
|
-
signal?.aborted ? new Error(
|
|
1851
|
-
`[Render] Sequential ${captureModeLabel(input.session.captureMode)} capture aborted while a capture call was in flight (frame ${input.frameIndex}/${input.totalFrames}).`
|
|
1852
|
-
) : new SequentialCaptureStallError(
|
|
1853
|
-
input.session,
|
|
1854
|
-
input.stallTimeoutMs,
|
|
1855
|
-
input.frameIndex,
|
|
1856
|
-
input.totalFrames
|
|
1857
|
-
)
|
|
1861
|
+
const abortError3 = () => new Error(
|
|
1862
|
+
`[Render] Sequential ${captureModeLabel(input.session.captureMode)} capture aborted while a capture call was in flight (frame ${input.frameIndex}/${input.totalFrames}).`
|
|
1858
1863
|
);
|
|
1864
|
+
if (signal?.aborted) {
|
|
1865
|
+
promise.catch(() => {
|
|
1866
|
+
});
|
|
1867
|
+
reject(abortError3());
|
|
1868
|
+
return;
|
|
1869
|
+
}
|
|
1870
|
+
const clock = createStallClock();
|
|
1871
|
+
let settled = false;
|
|
1872
|
+
let timer;
|
|
1873
|
+
const cleanup = () => {
|
|
1874
|
+
clearTimeout(timer);
|
|
1875
|
+
signal?.removeEventListener("abort", onAbort);
|
|
1876
|
+
};
|
|
1877
|
+
const onAbort = () => {
|
|
1878
|
+
if (settled) return;
|
|
1879
|
+
settled = true;
|
|
1880
|
+
cleanup();
|
|
1881
|
+
reject(abortError3());
|
|
1882
|
+
};
|
|
1883
|
+
const trip = () => {
|
|
1884
|
+
if (settled) return;
|
|
1885
|
+
settled = true;
|
|
1886
|
+
cleanup();
|
|
1887
|
+
reject(
|
|
1888
|
+
signal?.aborted ? abortError3() : new SequentialCaptureStallError(
|
|
1889
|
+
input.session,
|
|
1890
|
+
input.stallTimeoutMs,
|
|
1891
|
+
input.frameIndex,
|
|
1892
|
+
input.totalFrames
|
|
1893
|
+
)
|
|
1894
|
+
);
|
|
1895
|
+
};
|
|
1896
|
+
signal?.addEventListener("abort", onAbort, { once: true });
|
|
1859
1897
|
const deadline = Math.max(0, deadlineMs);
|
|
1860
1898
|
let wait = Math.min(deadline, DE_STALL_POLL_MS);
|
|
1861
|
-
let timer;
|
|
1862
1899
|
const look = () => {
|
|
1863
1900
|
const idle = clock.idle(wait);
|
|
1864
1901
|
if (idle >= deadline) return trip();
|
|
@@ -1868,11 +1905,15 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
|
1868
1905
|
timer = setTimeout(look, wait);
|
|
1869
1906
|
promise.then(
|
|
1870
1907
|
(value) => {
|
|
1871
|
-
|
|
1908
|
+
if (settled) return;
|
|
1909
|
+
settled = true;
|
|
1910
|
+
cleanup();
|
|
1872
1911
|
resolve11(value);
|
|
1873
1912
|
},
|
|
1874
1913
|
(error) => {
|
|
1875
|
-
|
|
1914
|
+
if (settled) return;
|
|
1915
|
+
settled = true;
|
|
1916
|
+
cleanup();
|
|
1876
1917
|
reject(error);
|
|
1877
1918
|
}
|
|
1878
1919
|
);
|
|
@@ -8637,25 +8678,26 @@ async function runSequentialDiskCapture(input, captureOptions, captureCfg, check
|
|
|
8637
8678
|
assertNotAborted();
|
|
8638
8679
|
attempt?.throwIfAborted();
|
|
8639
8680
|
};
|
|
8681
|
+
const attemptSignal = combineAbortSignals(abortSignal, attempt);
|
|
8682
|
+
const initBudget = { frameIndex: resumeFrom, totalFrames, abortSignal: attemptSignal };
|
|
8640
8683
|
const videoInjector = createRenderVideoFrameInjector();
|
|
8641
|
-
const session = probeSession ?? await
|
|
8642
|
-
|
|
8684
|
+
const session = probeSession ?? await openSequentialDiskSession({
|
|
8685
|
+
assertAttemptActive,
|
|
8686
|
+
initBudget,
|
|
8687
|
+
fileServerUrl: fileServer.url,
|
|
8643
8688
|
framesDir,
|
|
8644
8689
|
captureOptions,
|
|
8645
8690
|
videoInjector,
|
|
8646
|
-
captureCfg
|
|
8647
|
-
|
|
8691
|
+
captureCfg,
|
|
8692
|
+
attemptSignal
|
|
8693
|
+
});
|
|
8648
8694
|
captureBeyondViewport = session.options.captureBeyondViewport;
|
|
8649
8695
|
try {
|
|
8650
8696
|
if (probeSession) {
|
|
8651
8697
|
await prepareCaptureSessionForReuse3(session, framesDir, videoInjector);
|
|
8652
8698
|
probeSession = null;
|
|
8653
8699
|
}
|
|
8654
|
-
await ensureSessionReady(session,
|
|
8655
|
-
frameIndex: resumeFrom,
|
|
8656
|
-
totalFrames,
|
|
8657
|
-
abortSignal: input.abortSignal
|
|
8658
|
-
});
|
|
8700
|
+
await ensureSessionReady(session, initBudget);
|
|
8659
8701
|
assertAttemptActive();
|
|
8660
8702
|
lastBrowserConsole = session.browserConsoleBuffer;
|
|
8661
8703
|
await captureSessionFrames(session, {
|
|
@@ -8707,9 +8749,26 @@ function planTransientResume(error, ctx) {
|
|
|
8707
8749
|
if (!firstMissing) return null;
|
|
8708
8750
|
return isTransientCaptureRetryEligible(failure.kind, missing, ctx.retriesUsed) ? firstMissing.startFrame : null;
|
|
8709
8751
|
}
|
|
8752
|
+
function combineAbortSignals(first, second) {
|
|
8753
|
+
if (first && second) return AbortSignal.any([first, second]);
|
|
8754
|
+
return second ?? first;
|
|
8755
|
+
}
|
|
8756
|
+
async function openSequentialDiskSession(args) {
|
|
8757
|
+
args.assertAttemptActive();
|
|
8758
|
+
return openCaptureSessionWithinBudget(
|
|
8759
|
+
createSessionInitBudget(args.initBudget),
|
|
8760
|
+
createCaptureSession5(
|
|
8761
|
+
args.fileServerUrl,
|
|
8762
|
+
args.framesDir,
|
|
8763
|
+
args.captureOptions,
|
|
8764
|
+
args.videoInjector,
|
|
8765
|
+
{ ...args.captureCfg, signal: args.attemptSignal }
|
|
8766
|
+
)
|
|
8767
|
+
);
|
|
8768
|
+
}
|
|
8710
8769
|
async function ensureSessionReady(session, budget) {
|
|
8711
8770
|
if (!session.isInitialized) {
|
|
8712
|
-
await initializeSession5(session);
|
|
8771
|
+
await createSessionInitBudget(budget)(initializeSession5(session), session);
|
|
8713
8772
|
return;
|
|
8714
8773
|
}
|
|
8715
8774
|
if (process.env.PRODUCER_EXPERIMENTAL_FAST_CAPTURE === "true") {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": "0.1.0",
|
|
3
3
|
"buildId": "dev",
|
|
4
|
-
"sha256": "
|
|
4
|
+
"sha256": "587c88c9b0378a225f4d5105929a96a04f8d37a8cd6927c2ab26e17790f7d91a",
|
|
5
5
|
"artifacts": {
|
|
6
6
|
"iife": "hyperframe.runtime.iife.js",
|
|
7
7
|
"esm": "hyperframe.runtime.mjs"
|