@hyperframes/producer 0.9.104 → 0.9.107
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/compileWorker.js +13 -22
- package/dist/distributed.js +38 -43
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +71 -151
- package/dist/public-server.js +60 -140
- package/dist/services/render/stages/extractVideosStage.d.ts +2 -1
- package/dist/utils/paths.d.ts +2 -6
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
mkdirSync as mkdirSync15,
|
|
14
14
|
readdirSync as readdirSync6,
|
|
15
15
|
rmSync as rmSync13,
|
|
16
|
-
statSync as
|
|
16
|
+
statSync as statSync9,
|
|
17
17
|
writeFileSync as writeFileSync8,
|
|
18
18
|
copyFileSync as copyFileSync5,
|
|
19
19
|
appendFileSync
|
|
@@ -355,6 +355,7 @@ import {
|
|
|
355
355
|
getDrawElementVerificationDetails,
|
|
356
356
|
augmentProtocolTimeoutError,
|
|
357
357
|
augmentPageNavigationTimeoutError,
|
|
358
|
+
createCacheLease,
|
|
358
359
|
displaySize
|
|
359
360
|
} from "@hyperframes/engine";
|
|
360
361
|
import {
|
|
@@ -379,7 +380,7 @@ import {
|
|
|
379
380
|
import {
|
|
380
381
|
existsSync as existsSync2,
|
|
381
382
|
realpathSync,
|
|
382
|
-
statSync
|
|
383
|
+
statSync,
|
|
383
384
|
createReadStream,
|
|
384
385
|
openSync,
|
|
385
386
|
fstatSync,
|
|
@@ -537,15 +538,12 @@ import {
|
|
|
537
538
|
relative as nodeRelative,
|
|
538
539
|
isAbsolute as nodeIsAbsolute
|
|
539
540
|
} from "node:path";
|
|
540
|
-
import { statSync } from "node:fs";
|
|
541
541
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
542
542
|
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
543
543
|
import {
|
|
544
|
-
isCopiedOutsideFileType,
|
|
545
|
-
isPrivateOutsideFile,
|
|
546
|
-
isUploadedOutsideFileType,
|
|
547
544
|
leftOutWarning,
|
|
548
|
-
linksOutside
|
|
545
|
+
linksOutside,
|
|
546
|
+
outsideLinkRefusal
|
|
549
547
|
} from "@hyperframes/studio-server/outside-file";
|
|
550
548
|
import { realFilePath } from "@hyperframes/studio-server/safe-path";
|
|
551
549
|
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
@@ -566,15 +564,9 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
566
564
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
567
565
|
}
|
|
568
566
|
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
569
|
-
if (
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
}
|
|
573
|
-
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
574
|
-
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
575
|
-
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
576
|
-
if (!isCopiedOutsideFileType(path)) return "file_type";
|
|
577
|
-
return policy.includeScripts ? null : "script";
|
|
567
|
+
if (linksOutside(projectDir, path)) return outsideLinkRefusal(projectDir, path, policy);
|
|
568
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir) && isPrivateFileUnder(projectDir, path, isStudioPrivatePath);
|
|
569
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
578
570
|
}
|
|
579
571
|
var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
|
|
580
572
|
function refusesOutsideLink(projectDir, path, warn, policy = {}) {
|
|
@@ -1143,7 +1135,7 @@ function openRegularFile(filePath) {
|
|
|
1143
1135
|
} catch (error) {
|
|
1144
1136
|
if (error instanceof Error && "code" in error && NO_FILE_AT_NAME.has(String(error.code)))
|
|
1145
1137
|
return null;
|
|
1146
|
-
if (!
|
|
1138
|
+
if (!statSync(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
1147
1139
|
throw error;
|
|
1148
1140
|
}
|
|
1149
1141
|
let accepted = false;
|
|
@@ -2101,94 +2093,21 @@ import {
|
|
|
2101
2093
|
mkdirSync as mkdirSync2,
|
|
2102
2094
|
readFileSync as readFileSync2,
|
|
2103
2095
|
readdirSync,
|
|
2104
|
-
readlinkSync as readlinkSync2,
|
|
2105
2096
|
rmSync as rmSync2,
|
|
2106
2097
|
writeFileSync as writeFileSync2
|
|
2107
2098
|
} from "node:fs";
|
|
2108
|
-
import {
|
|
2109
|
-
import {
|
|
2110
|
-
import { basename as basename4, dirname as dirname3, join as join5, win32 } from "node:path";
|
|
2099
|
+
import { basename as basename4, dirname as dirname3, join as join5 } from "node:path";
|
|
2100
|
+
import { ownerRecordState, processOwnerRecord } from "@hyperframes/engine";
|
|
2111
2101
|
import { RENDER_TEMP_DIR } from "@hyperframes/core/project-folders";
|
|
2112
2102
|
import { createStagingDir, toWin32LongPath } from "@hyperframes/core/atomic-file";
|
|
2113
2103
|
var OWNER_FILE = "owner.json";
|
|
2114
2104
|
var TRANSACTION_BACKUP = "backup";
|
|
2115
2105
|
var RENDER_JOB_DIR = /^[0-9a-f]{8}(-[0-9a-f]{4}){3}-[0-9a-f]{12}$/;
|
|
2116
|
-
var machineIdRead;
|
|
2117
|
-
function machineId() {
|
|
2118
|
-
const read2 = (file, args, pattern) => {
|
|
2119
|
-
try {
|
|
2120
|
-
const out = execFileSync(file, args, {
|
|
2121
|
-
encoding: "utf-8",
|
|
2122
|
-
timeout: 2e3,
|
|
2123
|
-
windowsHide: true
|
|
2124
|
-
});
|
|
2125
|
-
return pattern.exec(out)?.[1];
|
|
2126
|
-
} catch {
|
|
2127
|
-
return void 0;
|
|
2128
|
-
}
|
|
2129
|
-
};
|
|
2130
|
-
if (machineIdRead?.platform === process.platform) return machineIdRead.id;
|
|
2131
|
-
const systemRoot = process.env.SystemRoot;
|
|
2132
|
-
machineIdRead = {
|
|
2133
|
-
platform: process.platform,
|
|
2134
|
-
id: process.platform === "darwin" ? read2(
|
|
2135
|
-
"/usr/sbin/ioreg",
|
|
2136
|
-
["-rd1", "-c", "IOPlatformExpertDevice"],
|
|
2137
|
-
/"IOPlatformUUID" = "([^"]+)"/
|
|
2138
|
-
) : process.platform === "win32" && systemRoot && /^[A-Za-z]:\\/.test(systemRoot) ? read2(
|
|
2139
|
-
win32.join(systemRoot, "System32", "reg.exe"),
|
|
2140
|
-
["query", "HKLM\\SOFTWARE\\Microsoft\\Cryptography", "/v", "MachineGuid"],
|
|
2141
|
-
/MachineGuid\s+REG_SZ\s+(\S+)/
|
|
2142
|
-
) : void 0
|
|
2143
|
-
};
|
|
2144
|
-
return machineIdRead.id;
|
|
2145
|
-
}
|
|
2146
|
-
function pidScope() {
|
|
2147
|
-
const attempt = (read2) => {
|
|
2148
|
-
try {
|
|
2149
|
-
return read2();
|
|
2150
|
-
} catch {
|
|
2151
|
-
return void 0;
|
|
2152
|
-
}
|
|
2153
|
-
};
|
|
2154
|
-
const bootId = attempt(() => readFileSync2("/proc/sys/kernel/random/boot_id", "utf-8").trim());
|
|
2155
|
-
return {
|
|
2156
|
-
host: hostname(),
|
|
2157
|
-
// Without /proc (macOS, Windows) the boot time in seconds stands in for the boot id, on this machine's own id.
|
|
2158
|
-
boot: bootId ?? attempt(() => `s:${Math.round(Date.now() / 1e3 - uptime())}`),
|
|
2159
|
-
pidns: attempt(() => readlinkSync2("/proc/self/ns/pid")),
|
|
2160
|
-
machine: bootId === void 0 ? machineId() : void 0
|
|
2161
|
-
};
|
|
2162
|
-
}
|
|
2163
2106
|
function createOwnedRenderDir(prefix) {
|
|
2164
2107
|
const dir = createStagingDir(dirname3(prefix), basename4(prefix));
|
|
2165
|
-
|
|
2166
|
-
writeFileSync2(toWin32LongPath(join5(dir, OWNER_FILE)), JSON.stringify(owner));
|
|
2108
|
+
writeFileSync2(toWin32LongPath(join5(dir, OWNER_FILE)), JSON.stringify(processOwnerRecord()));
|
|
2167
2109
|
return dir;
|
|
2168
2110
|
}
|
|
2169
|
-
function alive(pid) {
|
|
2170
|
-
try {
|
|
2171
|
-
process.kill(pid, 0);
|
|
2172
|
-
return true;
|
|
2173
|
-
} catch (error) {
|
|
2174
|
-
return error.code === "EPERM";
|
|
2175
|
-
}
|
|
2176
|
-
}
|
|
2177
|
-
function knownPidScope() {
|
|
2178
|
-
const scope = pidScope();
|
|
2179
|
-
const unknown = scope.boot === void 0 || process.platform === "linux" && scope.pidns === void 0 || scope.boot.startsWith("s:") && scope.machine === void 0;
|
|
2180
|
-
return unknown ? void 0 : scope;
|
|
2181
|
-
}
|
|
2182
|
-
function sameBoot(stamped, current) {
|
|
2183
|
-
if (stamped === current) return true;
|
|
2184
|
-
const seconds = (boot) => typeof boot === "string" ? /^s:(\d+)$/.exec(boot)?.[1] : void 0;
|
|
2185
|
-
const [a, b] = [seconds(stamped), seconds(current)];
|
|
2186
|
-
return a !== void 0 && b !== void 0 && Math.abs(Number(a) - Number(b)) <= 2;
|
|
2187
|
-
}
|
|
2188
|
-
function inThisPidScope(owner) {
|
|
2189
|
-
const scope = knownPidScope();
|
|
2190
|
-
return scope !== void 0 && owner.host === scope.host && sameBoot(owner.boot, scope.boot) && owner.pidns === scope.pidns && owner.machine === scope.machine;
|
|
2191
|
-
}
|
|
2192
2111
|
function ownerState(dir) {
|
|
2193
2112
|
let owner;
|
|
2194
2113
|
try {
|
|
@@ -2196,11 +2115,7 @@ function ownerState(dir) {
|
|
|
2196
2115
|
} catch (error) {
|
|
2197
2116
|
return error.code === "ENOENT" ? "none" : "unknown";
|
|
2198
2117
|
}
|
|
2199
|
-
|
|
2200
|
-
if (!inThisPidScope(owner) || typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) {
|
|
2201
|
-
return "unknown";
|
|
2202
|
-
}
|
|
2203
|
-
return alive(pid) ? "live" : "gone";
|
|
2118
|
+
return ownerRecordState(owner);
|
|
2204
2119
|
}
|
|
2205
2120
|
function newestWriteMs(path) {
|
|
2206
2121
|
const stat = lstatSync2(path);
|
|
@@ -2663,7 +2578,7 @@ function replanAfterFailure(plan2, failure) {
|
|
|
2663
2578
|
}
|
|
2664
2579
|
|
|
2665
2580
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2666
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync6, statSync as
|
|
2581
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
|
|
2667
2582
|
import { join as join12 } from "node:path";
|
|
2668
2583
|
import {
|
|
2669
2584
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
@@ -3587,7 +3502,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
3587
3502
|
}
|
|
3588
3503
|
|
|
3589
3504
|
// src/services/render/stages/captureHdrResources.ts
|
|
3590
|
-
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync5, statSync as
|
|
3505
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync2, statfsSync } from "node:fs";
|
|
3591
3506
|
import {
|
|
3592
3507
|
decodePngToRgb48le,
|
|
3593
3508
|
extractMediaMetadata as extractMediaMetadata2,
|
|
@@ -4012,7 +3927,7 @@ async function extractHdrVideoFrames(args) {
|
|
|
4012
3927
|
failureReason: result.failureReason
|
|
4013
3928
|
});
|
|
4014
3929
|
}
|
|
4015
|
-
return Math.min(Math.floor(
|
|
3930
|
+
return Math.min(Math.floor(statSync2(spec.path).size / frameSize), spec.frames);
|
|
4016
3931
|
}
|
|
4017
3932
|
});
|
|
4018
3933
|
const first = await windows.lease(0);
|
|
@@ -5561,7 +5476,7 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5561
5476
|
path: segmentPath,
|
|
5562
5477
|
// Recorded so resume can prove the file on disk is the one that
|
|
5563
5478
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5564
|
-
bytes: existsSync7(segmentPath) ?
|
|
5479
|
+
bytes: existsSync7(segmentPath) ? statSync3(segmentPath).size : 0,
|
|
5565
5480
|
sha256: existsSync7(segmentPath) ? await hashSegmentFile(segmentPath) : ""
|
|
5566
5481
|
});
|
|
5567
5482
|
return encodeResult;
|
|
@@ -6623,7 +6538,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6623
6538
|
}
|
|
6624
6539
|
|
|
6625
6540
|
// src/services/render/videoFrameWindow.ts
|
|
6626
|
-
import { readdirSync as readdirSync3, statSync as
|
|
6541
|
+
import { readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
6627
6542
|
import { join as join16 } from "node:path";
|
|
6628
6543
|
function shouldWindowVideoFrames(args) {
|
|
6629
6544
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
@@ -6639,7 +6554,7 @@ function directoryBytes(path) {
|
|
|
6639
6554
|
for (const entry of entries) {
|
|
6640
6555
|
const child3 = join16(path, entry.name);
|
|
6641
6556
|
try {
|
|
6642
|
-
bytes += entry.isDirectory() ? directoryBytes(child3) :
|
|
6557
|
+
bytes += entry.isDirectory() ? directoryBytes(child3) : statSync4(child3).size;
|
|
6643
6558
|
} catch {
|
|
6644
6559
|
}
|
|
6645
6560
|
}
|
|
@@ -7365,7 +7280,7 @@ import {
|
|
|
7365
7280
|
stylesheetLinkMatches
|
|
7366
7281
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7367
7282
|
import { createHash as createHash6 } from "node:crypto";
|
|
7368
|
-
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync9, statSync as
|
|
7283
|
+
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync9, statSync as statSync7 } from "fs";
|
|
7369
7284
|
import { join as join21, dirname as dirname10, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7370
7285
|
import { parseHTML as parseHTML5 } from "@hyperframes/parsers/linkedom";
|
|
7371
7286
|
import { compositionRootSize } from "@hyperframes/parsers";
|
|
@@ -7654,7 +7569,7 @@ import {
|
|
|
7654
7569
|
|
|
7655
7570
|
// src/services/animatedGifPrep.ts
|
|
7656
7571
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
7657
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync9, readFileSync as readFileSync7, rmSync as rmSync9, statSync as
|
|
7572
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync9, readFileSync as readFileSync7, rmSync as rmSync9, statSync as statSync5 } from "node:fs";
|
|
7658
7573
|
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7659
7574
|
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
7660
7575
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -7717,7 +7632,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7717
7632
|
}
|
|
7718
7633
|
function isUsableFile(path) {
|
|
7719
7634
|
try {
|
|
7720
|
-
const stat =
|
|
7635
|
+
const stat = statSync5(path);
|
|
7721
7636
|
return stat.isFile() && stat.size > 0;
|
|
7722
7637
|
} catch {
|
|
7723
7638
|
return false;
|
|
@@ -7867,7 +7782,7 @@ async function ensurePreparedWebm(input) {
|
|
|
7867
7782
|
if (!isUsableFile(tmpPath)) {
|
|
7868
7783
|
throw new Error("Animated GIF transcode produced an empty output");
|
|
7869
7784
|
}
|
|
7870
|
-
if (
|
|
7785
|
+
if (statSync5(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP) {
|
|
7871
7786
|
throw new Error("Animated GIF transcode reached its output size limit");
|
|
7872
7787
|
}
|
|
7873
7788
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -8003,7 +7918,7 @@ import {
|
|
|
8003
7918
|
readFileSync as readFileSync8,
|
|
8004
7919
|
readSync as readSync3,
|
|
8005
7920
|
rmSync as rmSync10,
|
|
8006
|
-
statSync as
|
|
7921
|
+
statSync as statSync6,
|
|
8007
7922
|
writeFileSync as writeFileSync4
|
|
8008
7923
|
} from "node:fs";
|
|
8009
7924
|
import { dirname as dirname8, join as join19, resolve as resolve7 } from "node:path";
|
|
@@ -8259,7 +8174,7 @@ function resolveImageSource(src, options) {
|
|
|
8259
8174
|
}
|
|
8260
8175
|
function isUsableFile2(path) {
|
|
8261
8176
|
try {
|
|
8262
|
-
return
|
|
8177
|
+
return statSync6(path).size > 0;
|
|
8263
8178
|
} catch {
|
|
8264
8179
|
return false;
|
|
8265
8180
|
}
|
|
@@ -8280,7 +8195,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
8280
8195
|
signal: options.signal
|
|
8281
8196
|
});
|
|
8282
8197
|
if (!isUsableFile2(tmpPath)) throw new Error("conversion produced an empty file");
|
|
8283
|
-
if (
|
|
8198
|
+
if (statSync6(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP2) {
|
|
8284
8199
|
throw new Error("conversion reached its output size limit");
|
|
8285
8200
|
}
|
|
8286
8201
|
renameWithRetry3(tmpPath, cachePath);
|
|
@@ -9958,7 +9873,7 @@ async function localFontDataUri(localPath, projectDir, assetRoot, dataUriByAbsol
|
|
|
9958
9873
|
if (dataUriByAbsolutePath.has(absPath)) return dataUriByAbsolutePath.get(absPath);
|
|
9959
9874
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
9960
9875
|
try {
|
|
9961
|
-
if (!reserve(Math.ceil(
|
|
9876
|
+
if (!reserve(Math.ceil(statSync7(absPath).size / 3) * 4 + 64)) {
|
|
9962
9877
|
dataUriByAbsolutePath.set(absPath, void 0);
|
|
9963
9878
|
return void 0;
|
|
9964
9879
|
}
|
|
@@ -11766,14 +11681,14 @@ async function runProbeStage(input) {
|
|
|
11766
11681
|
probeSession.beginFrameTimeTicks,
|
|
11767
11682
|
probeSession.beginFrameIntervalMs
|
|
11768
11683
|
);
|
|
11769
|
-
const
|
|
11684
|
+
const alive = await probeBeginFrameLiveness(
|
|
11770
11685
|
probeSession.page,
|
|
11771
11686
|
probeTimeoutMs,
|
|
11772
11687
|
probeTick,
|
|
11773
11688
|
probeSession.beginFrameIntervalMs
|
|
11774
11689
|
);
|
|
11775
11690
|
assertNotAborted();
|
|
11776
|
-
if (
|
|
11691
|
+
if (alive) {
|
|
11777
11692
|
log.info("BeginFrame liveness probe passed", {
|
|
11778
11693
|
probeMs: Date.now() - livenessStart
|
|
11779
11694
|
});
|
|
@@ -12487,7 +12402,8 @@ async function runExtractVideosStage(input) {
|
|
|
12487
12402
|
shownBoxes,
|
|
12488
12403
|
urlByAbsentLocalPath,
|
|
12489
12404
|
audioDownloadDir,
|
|
12490
|
-
skipFrameExtractionIds = []
|
|
12405
|
+
skipFrameExtractionIds = [],
|
|
12406
|
+
cacheLease
|
|
12491
12407
|
} = input;
|
|
12492
12408
|
const stage2Start = Date.now();
|
|
12493
12409
|
const assetRoots = job.config.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(projectDir, compiledDir);
|
|
@@ -12607,6 +12523,7 @@ async function runExtractVideosStage(input) {
|
|
|
12607
12523
|
contentKeyedDirs: [join26(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
12608
12524
|
urlByAbsentLocalPath,
|
|
12609
12525
|
assetRoots,
|
|
12526
|
+
cacheLease,
|
|
12610
12527
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
12611
12528
|
framesPlanned += planned;
|
|
12612
12529
|
framesDone += done;
|
|
@@ -15012,7 +14929,7 @@ import {
|
|
|
15012
14929
|
readdirSync as readdirSync5,
|
|
15013
14930
|
readFileSync as readFileSync10,
|
|
15014
14931
|
rmSync as rmSync12,
|
|
15015
|
-
statSync as
|
|
14932
|
+
statSync as statSync8,
|
|
15016
14933
|
writeFileSync as writeFileSync7
|
|
15017
14934
|
} from "node:fs";
|
|
15018
14935
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -15141,7 +15058,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
15141
15058
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
15142
15059
|
if (failure) return failure;
|
|
15143
15060
|
}
|
|
15144
|
-
const fileSize = existsSync21(outputPath) ?
|
|
15061
|
+
const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
|
|
15145
15062
|
return {
|
|
15146
15063
|
success: true,
|
|
15147
15064
|
outputPath,
|
|
@@ -15555,7 +15472,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
15555
15472
|
for (const name of entries) {
|
|
15556
15473
|
const full = join36(current, name);
|
|
15557
15474
|
try {
|
|
15558
|
-
const st =
|
|
15475
|
+
const st = statSync9(full);
|
|
15559
15476
|
if (st.isDirectory()) {
|
|
15560
15477
|
stack.push(full);
|
|
15561
15478
|
} else if (st.isFile()) {
|
|
@@ -15719,7 +15636,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
15719
15636
|
let rangeStart = null;
|
|
15720
15637
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
15721
15638
|
const framePath = join36(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
15722
|
-
const missing = !existsSync22(framePath) ||
|
|
15639
|
+
const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
|
|
15723
15640
|
if (missing && rangeStart === null) {
|
|
15724
15641
|
rangeStart = frameIndex;
|
|
15725
15642
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -16966,6 +16883,8 @@ async function executeRenderPipeline(input) {
|
|
|
16966
16883
|
reason
|
|
16967
16884
|
});
|
|
16968
16885
|
}
|
|
16886
|
+
const cacheLease = createCacheLease();
|
|
16887
|
+
execution.defer("release extraction cache lease", () => cacheLease.release());
|
|
16969
16888
|
const extractResult = await observeRenderStage(
|
|
16970
16889
|
observability,
|
|
16971
16890
|
"video_extract",
|
|
@@ -16983,6 +16902,7 @@ async function executeRenderPipeline(input) {
|
|
|
16983
16902
|
assertNotAborted,
|
|
16984
16903
|
// Local staging can use links; distributed plan() alone requires real copies.
|
|
16985
16904
|
materializeSymlinks: false,
|
|
16905
|
+
cacheLease,
|
|
16986
16906
|
deferRangeExtraction: windowVideoFrames ? true : void 0,
|
|
16987
16907
|
shownBoxes,
|
|
16988
16908
|
onProgress
|
|
@@ -21563,7 +21483,7 @@ import {
|
|
|
21563
21483
|
readFileSync as readFileSync14,
|
|
21564
21484
|
readdirSync as readdirSync10,
|
|
21565
21485
|
rmSync as rmSync17,
|
|
21566
|
-
statSync as
|
|
21486
|
+
statSync as statSync11,
|
|
21567
21487
|
writeFileSync as writeFileSync13
|
|
21568
21488
|
} from "node:fs";
|
|
21569
21489
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
@@ -21582,7 +21502,7 @@ import {
|
|
|
21582
21502
|
linkSync as linkSync2,
|
|
21583
21503
|
mkdirSync as mkdirSync20,
|
|
21584
21504
|
rmSync as rmSync16,
|
|
21585
|
-
statSync as
|
|
21505
|
+
statSync as statSync10,
|
|
21586
21506
|
writeFileSync as writeFileSync12
|
|
21587
21507
|
} from "node:fs";
|
|
21588
21508
|
import { renameWithRetry as renameWithRetry8 } from "@hyperframes/engine";
|
|
@@ -21652,7 +21572,7 @@ var LocalPlanV2ArtifactPublisher = class {
|
|
|
21652
21572
|
}
|
|
21653
21573
|
async putBlob(blob) {
|
|
21654
21574
|
const digest = assertPlanV2Sha256(blob.sha256, "published blob sha256");
|
|
21655
|
-
const sourceSize =
|
|
21575
|
+
const sourceSize = statSync10(blob.sourcePath).size;
|
|
21656
21576
|
if (sourceSize !== blob.sizeBytes) {
|
|
21657
21577
|
throw new PlanV2IntegrityError(
|
|
21658
21578
|
`published blob size changed for ${digest}: expected ${blob.sizeBytes}, got ${sourceSize}`
|
|
@@ -21966,7 +21886,7 @@ function publishBlobFor(absolutePath, digests) {
|
|
|
21966
21886
|
return {
|
|
21967
21887
|
sourcePath: absolutePath,
|
|
21968
21888
|
sha256: planFileSha256(absolutePath, digests),
|
|
21969
|
-
sizeBytes:
|
|
21889
|
+
sizeBytes: statSync11(absolutePath).size
|
|
21970
21890
|
};
|
|
21971
21891
|
}
|
|
21972
21892
|
async function putBlobs(publisher, blobs) {
|
|
@@ -22337,7 +22257,7 @@ function verifyBlob(planV2Dir, artifact) {
|
|
|
22337
22257
|
if (!existsSync29(sourcePath)) {
|
|
22338
22258
|
throw new PlanV2IntegrityError(`missing content-addressed artifact ${artifact.sha256}`);
|
|
22339
22259
|
}
|
|
22340
|
-
const stats =
|
|
22260
|
+
const stats = statSync11(sourcePath);
|
|
22341
22261
|
if (!stats.isFile() || stats.size !== artifact.sizeBytes) {
|
|
22342
22262
|
throw new PlanV2IntegrityError(`artifact size mismatch for ${artifact.path}`);
|
|
22343
22263
|
}
|
|
@@ -22430,7 +22350,7 @@ function readValidatedPlanV2Materialization(planDir, expectedTarget) {
|
|
|
22430
22350
|
for (const artifact of required) {
|
|
22431
22351
|
if (Object.hasOwn(remoteSources, artifact.path)) continue;
|
|
22432
22352
|
const path = join48(planDir, ...artifact.path.split("/"));
|
|
22433
|
-
if (!existsSync29(path) ||
|
|
22353
|
+
if (!existsSync29(path) || statSync11(path).size !== artifact.sizeBytes) {
|
|
22434
22354
|
throw new PlanV2IntegrityError(
|
|
22435
22355
|
`materialized artifact missing or truncated: ${artifact.path}`
|
|
22436
22356
|
);
|
|
@@ -23884,7 +23804,7 @@ import {
|
|
|
23884
23804
|
lstatSync as lstatSync6,
|
|
23885
23805
|
mkdirSync as mkdirSync24,
|
|
23886
23806
|
openSync as openSync9,
|
|
23887
|
-
statSync as
|
|
23807
|
+
statSync as statSync13,
|
|
23888
23808
|
mkdtempSync as mkdtempSync2,
|
|
23889
23809
|
writeFileSync as writeFileSync15,
|
|
23890
23810
|
rmSync as rmSync20,
|
|
@@ -23911,7 +23831,7 @@ import { foreignWritablePath } from "@hyperframes/core/cache-dir";
|
|
|
23911
23831
|
import {
|
|
23912
23832
|
existsSync as existsSync31,
|
|
23913
23833
|
readFileSync as readFileSync17,
|
|
23914
|
-
statSync as
|
|
23834
|
+
statSync as statSync12,
|
|
23915
23835
|
openSync as openSync8,
|
|
23916
23836
|
fstatSync as fstatSync4,
|
|
23917
23837
|
closeSync as closeSync8,
|
|
@@ -23952,7 +23872,7 @@ function readEntryHtml(filePath) {
|
|
|
23952
23872
|
} catch (error) {
|
|
23953
23873
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
23954
23874
|
return null;
|
|
23955
|
-
if (!
|
|
23875
|
+
if (!statSync12(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
23956
23876
|
throw error;
|
|
23957
23877
|
}
|
|
23958
23878
|
try {
|
|
@@ -23968,7 +23888,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
23968
23888
|
}
|
|
23969
23889
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
23970
23890
|
const absProjectDir = resolve13(projectDir);
|
|
23971
|
-
if (!existsSync31(absProjectDir) || !
|
|
23891
|
+
if (!existsSync31(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
23972
23892
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
23973
23893
|
}
|
|
23974
23894
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -24470,7 +24390,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
24470
24390
|
if (!candidate) return null;
|
|
24471
24391
|
const absProjectDir = policy ? resolve14(policy.projectsDir, candidate) : resolve14(candidate);
|
|
24472
24392
|
const shown = policy ? candidate : absProjectDir;
|
|
24473
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !
|
|
24393
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
24474
24394
|
return { error: `Project directory not found: ${shown}` };
|
|
24475
24395
|
}
|
|
24476
24396
|
const entry = options.entryFile || "index.html";
|
|
@@ -24612,7 +24532,7 @@ function publicPerfSummary(job) {
|
|
|
24612
24532
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
24613
24533
|
}
|
|
24614
24534
|
function outputFileSize(path) {
|
|
24615
|
-
return existsSync33(path) ?
|
|
24535
|
+
return existsSync33(path) ? statSync13(path).size : 0;
|
|
24616
24536
|
}
|
|
24617
24537
|
function createBlockingProgressReporter(log, requestId) {
|
|
24618
24538
|
let lastLoggedPct = -10;
|
|
@@ -24983,18 +24903,18 @@ function hostnameOf(host) {
|
|
|
24983
24903
|
return null;
|
|
24984
24904
|
}
|
|
24985
24905
|
}
|
|
24986
|
-
function isAllowedBrowserHostname(
|
|
24987
|
-
if (!
|
|
24988
|
-
if (
|
|
24989
|
-
if (isIP(
|
|
24990
|
-
return allowed.has(
|
|
24906
|
+
function isAllowedBrowserHostname(hostname, allowed) {
|
|
24907
|
+
if (!hostname) return false;
|
|
24908
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) return true;
|
|
24909
|
+
if (isIP(hostname.replace(/^\[|\]$/g, "")) !== 0) return true;
|
|
24910
|
+
return allowed.has(hostname);
|
|
24991
24911
|
}
|
|
24992
24912
|
function allowedHostnames(options) {
|
|
24993
24913
|
const fromEnv = (process.env.PRODUCER_ALLOWED_HOSTS ?? "").split(",");
|
|
24994
24914
|
const names = /* @__PURE__ */ new Set();
|
|
24995
24915
|
for (const entry of [...options.allowedHosts ?? [], ...fromEnv]) {
|
|
24996
|
-
const
|
|
24997
|
-
if (
|
|
24916
|
+
const hostname = entry.trim() ? hostnameOf(entry.trim()) : null;
|
|
24917
|
+
if (hostname) names.add(hostname);
|
|
24998
24918
|
}
|
|
24999
24919
|
return names;
|
|
25000
24920
|
}
|
|
@@ -25008,8 +24928,8 @@ function hasBearerToken(c, token) {
|
|
|
25008
24928
|
digest(`Bearer ${token}`)
|
|
25009
24929
|
);
|
|
25010
24930
|
}
|
|
25011
|
-
function isLoopbackHostname(
|
|
25012
|
-
const host =
|
|
24931
|
+
function isLoopbackHostname(hostname) {
|
|
24932
|
+
const host = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
25013
24933
|
return host === "localhost" || host === "::1" || isIP(host) === 4 && host.startsWith("127.");
|
|
25014
24934
|
}
|
|
25015
24935
|
function isDisallowedBrowserHost(c, allowed) {
|
|
@@ -25078,12 +24998,12 @@ function onEscapedRejection(reason, log) {
|
|
|
25078
24998
|
});
|
|
25079
24999
|
scope?.fail(err);
|
|
25080
25000
|
}
|
|
25081
|
-
function serverAuth(options,
|
|
25001
|
+
function serverAuth(options, hostname, port) {
|
|
25082
25002
|
const configured = resolveAuthToken(options);
|
|
25083
25003
|
if (configured) return { token: configured };
|
|
25084
|
-
if (!isLoopbackHostname(
|
|
25004
|
+
if (!isLoopbackHostname(hostname)) {
|
|
25085
25005
|
throw new Error(
|
|
25086
|
-
`Refusing to listen on ${
|
|
25006
|
+
`Refusing to listen on ${hostname} without an auth token. Set authToken or PRODUCER_AUTH_TOKEN, or listen on a loopback address.`
|
|
25087
25007
|
);
|
|
25088
25008
|
}
|
|
25089
25009
|
const file = resolve14(
|
|
@@ -25098,11 +25018,11 @@ function serverAuth(options, hostname2, port) {
|
|
|
25098
25018
|
}
|
|
25099
25019
|
function startServer(options = {}) {
|
|
25100
25020
|
const port = options.port ?? parseInt(process.env.PRODUCER_PORT ?? "9847", 10);
|
|
25101
|
-
const
|
|
25021
|
+
const hostname = options.hostname || process.env.PRODUCER_HOST || "127.0.0.1";
|
|
25102
25022
|
const log = options.logger ?? defaultLogger;
|
|
25103
|
-
const auth = serverAuth(options,
|
|
25023
|
+
const auth = serverAuth(options, hostname, port);
|
|
25104
25024
|
const app = createProducerApp({ ...options, authToken: auth.token });
|
|
25105
|
-
const server = serve2({ fetch: app.fetch, port, hostname
|
|
25025
|
+
const server = serve2({ fetch: app.fetch, port, hostname }, (info) => {
|
|
25106
25026
|
const address = info.family === "IPv6" ? `[${info.address}]` : info.address;
|
|
25107
25027
|
log.info(`Listening on http://${address}:${info.port}`);
|
|
25108
25028
|
if (auth.generatedFile) {
|
|
@@ -25186,7 +25106,7 @@ import {
|
|
|
25186
25106
|
readFileSync as readFileSync18,
|
|
25187
25107
|
readdirSync as readdirSync12,
|
|
25188
25108
|
rmSync as rmSync21,
|
|
25189
|
-
statSync as
|
|
25109
|
+
statSync as statSync14
|
|
25190
25110
|
} from "node:fs";
|
|
25191
25111
|
import { localContainerInputArgs as localContainerInputArgs2 } from "@hyperframes/parsers/ff-binaries";
|
|
25192
25112
|
import { basename as basename10, dirname as dirname24, join as join54 } from "node:path";
|
|
@@ -25233,7 +25153,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
25233
25153
|
outputPath,
|
|
25234
25154
|
durationMs: Date.now() - start,
|
|
25235
25155
|
framesEncoded: plan2.totalFrames,
|
|
25236
|
-
fileSize:
|
|
25156
|
+
fileSize: statSync14(outputPath).size
|
|
25237
25157
|
};
|
|
25238
25158
|
}
|
|
25239
25159
|
const format = plan2.dimensions.format;
|
|
@@ -25280,7 +25200,7 @@ async function assemble(planDir, chunkOutputs, audioPath, outputPath, options) {
|
|
|
25280
25200
|
});
|
|
25281
25201
|
}
|
|
25282
25202
|
}
|
|
25283
|
-
const fileSize = existsSync34(outputPath) ?
|
|
25203
|
+
const fileSize = existsSync34(outputPath) ? statSync14(outputPath).size : 0;
|
|
25284
25204
|
return {
|
|
25285
25205
|
...referenceBackgroundResult8(plan2[REFERENCE_BACKGROUND_FIELD6]),
|
|
25286
25206
|
outputPath,
|
|
@@ -25479,7 +25399,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
25479
25399
|
mkdirSync25(outputPath, { recursive: true });
|
|
25480
25400
|
let globalIdx = 0;
|
|
25481
25401
|
for (const chunkDir of chunkPaths) {
|
|
25482
|
-
if (!
|
|
25402
|
+
if (!statSync14(chunkDir).isDirectory()) {
|
|
25483
25403
|
throw new Error(
|
|
25484
25404
|
`[assemble] png-sequence chunk must be a directory: ${chunkDir} (got a file)`
|
|
25485
25405
|
);
|
|
@@ -25506,7 +25426,7 @@ function mergePngFrameDirs(chunkPaths, outputPath, totalFrames, audioPath, start
|
|
|
25506
25426
|
let fileSize = 0;
|
|
25507
25427
|
for (const name of readdirSync12(outputPath)) {
|
|
25508
25428
|
try {
|
|
25509
|
-
fileSize +=
|
|
25429
|
+
fileSize += statSync14(join54(outputPath, name)).size;
|
|
25510
25430
|
} catch {
|
|
25511
25431
|
}
|
|
25512
25432
|
}
|