@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/public-server.js
CHANGED
|
@@ -25,7 +25,7 @@ import {
|
|
|
25
25
|
lstatSync as lstatSync4,
|
|
26
26
|
mkdirSync as mkdirSync16,
|
|
27
27
|
openSync as openSync7,
|
|
28
|
-
statSync as
|
|
28
|
+
statSync as statSync11,
|
|
29
29
|
mkdtempSync,
|
|
30
30
|
writeFileSync as writeFileSync9,
|
|
31
31
|
rmSync as rmSync14,
|
|
@@ -55,7 +55,7 @@ import {
|
|
|
55
55
|
mkdirSync as mkdirSync15,
|
|
56
56
|
readdirSync as readdirSync6,
|
|
57
57
|
rmSync as rmSync13,
|
|
58
|
-
statSync as
|
|
58
|
+
statSync as statSync9,
|
|
59
59
|
writeFileSync as writeFileSync8,
|
|
60
60
|
copyFileSync as copyFileSync5,
|
|
61
61
|
appendFileSync
|
|
@@ -397,6 +397,7 @@ import {
|
|
|
397
397
|
getDrawElementVerificationDetails,
|
|
398
398
|
augmentProtocolTimeoutError,
|
|
399
399
|
augmentPageNavigationTimeoutError,
|
|
400
|
+
createCacheLease,
|
|
400
401
|
displaySize
|
|
401
402
|
} from "@hyperframes/engine";
|
|
402
403
|
import {
|
|
@@ -421,7 +422,7 @@ import {
|
|
|
421
422
|
import {
|
|
422
423
|
existsSync as existsSync2,
|
|
423
424
|
realpathSync,
|
|
424
|
-
statSync
|
|
425
|
+
statSync,
|
|
425
426
|
createReadStream,
|
|
426
427
|
openSync,
|
|
427
428
|
fstatSync,
|
|
@@ -579,15 +580,12 @@ import {
|
|
|
579
580
|
relative as nodeRelative,
|
|
580
581
|
isAbsolute as nodeIsAbsolute
|
|
581
582
|
} from "node:path";
|
|
582
|
-
import { statSync } from "node:fs";
|
|
583
583
|
import { fileURLToPath as fileURLToPath2 } from "node:url";
|
|
584
584
|
import { isPrivateFileUnder, isSafePath, isStudioPrivatePath } from "@hyperframes/core/safe-path";
|
|
585
585
|
import {
|
|
586
|
-
isCopiedOutsideFileType,
|
|
587
|
-
isPrivateOutsideFile,
|
|
588
|
-
isUploadedOutsideFileType,
|
|
589
586
|
leftOutWarning,
|
|
590
|
-
linksOutside
|
|
587
|
+
linksOutside,
|
|
588
|
+
outsideLinkRefusal
|
|
591
589
|
} from "@hyperframes/studio-server/outside-file";
|
|
592
590
|
import { realFilePath } from "@hyperframes/studio-server/safe-path";
|
|
593
591
|
var DEFAULT_RENDERS_DIR = process.env.PRODUCER_RENDERS_DIR ?? // fileURLToPath (not URL.pathname): on Windows .pathname is "/D:/..." which
|
|
@@ -608,15 +606,9 @@ function escapesAssetRoot(path, assetRoot) {
|
|
|
608
606
|
return assetRoot !== void 0 && !isSafePath(assetRoot, path);
|
|
609
607
|
}
|
|
610
608
|
function outsideAssetRefusal(projectDir, path, policy = {}) {
|
|
611
|
-
if (
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
}
|
|
615
|
-
if (isPrivateOutsideFile(projectDir, path)) return "blocklisted";
|
|
616
|
-
const folder = statSync(path, { throwIfNoEntry: false })?.isDirectory();
|
|
617
|
-
if (folder || isUploadedOutsideFileType(path)) return null;
|
|
618
|
-
if (!isCopiedOutsideFileType(path)) return "file_type";
|
|
619
|
-
return policy.includeScripts ? null : "script";
|
|
609
|
+
if (linksOutside(projectDir, path)) return outsideLinkRefusal(projectDir, path, policy);
|
|
610
|
+
const privateByAnotherSpelling = !isPathInside(path, projectDir) && isPrivateFileUnder(projectDir, path, isStudioPrivatePath);
|
|
611
|
+
return privateByAnotherSpelling ? "blocklisted" : null;
|
|
620
612
|
}
|
|
621
613
|
var leftOutOfRender = (file, reference, reason) => leftOutWarning(file, reference, reason, "render");
|
|
622
614
|
function refusesOutsideLink(projectDir, path, warn, policy = {}) {
|
|
@@ -1185,7 +1177,7 @@ function openRegularFile(filePath) {
|
|
|
1185
1177
|
} catch (error) {
|
|
1186
1178
|
if (error instanceof Error && "code" in error && NO_FILE_AT_NAME.has(String(error.code)))
|
|
1187
1179
|
return null;
|
|
1188
|
-
if (!
|
|
1180
|
+
if (!statSync(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
1189
1181
|
throw error;
|
|
1190
1182
|
}
|
|
1191
1183
|
let accepted = false;
|
|
@@ -2140,93 +2132,20 @@ import {
|
|
|
2140
2132
|
mkdirSync as mkdirSync2,
|
|
2141
2133
|
readFileSync as readFileSync2,
|
|
2142
2134
|
readdirSync,
|
|
2143
|
-
readlinkSync as readlinkSync2,
|
|
2144
2135
|
rmSync as rmSync2,
|
|
2145
2136
|
writeFileSync as writeFileSync2
|
|
2146
2137
|
} from "node:fs";
|
|
2147
|
-
import {
|
|
2148
|
-
import {
|
|
2149
|
-
import { basename as basename4, dirname as dirname3, join as join5, win32 } from "node:path";
|
|
2138
|
+
import { basename as basename4, dirname as dirname3, join as join5 } from "node:path";
|
|
2139
|
+
import { ownerRecordState, processOwnerRecord } from "@hyperframes/engine";
|
|
2150
2140
|
import { RENDER_TEMP_DIR } from "@hyperframes/core/project-folders";
|
|
2151
2141
|
import { createStagingDir, toWin32LongPath } from "@hyperframes/core/atomic-file";
|
|
2152
2142
|
var OWNER_FILE = "owner.json";
|
|
2153
2143
|
var TRANSACTION_BACKUP = "backup";
|
|
2154
|
-
var machineIdRead;
|
|
2155
|
-
function machineId() {
|
|
2156
|
-
const read2 = (file, args, pattern) => {
|
|
2157
|
-
try {
|
|
2158
|
-
const out = execFileSync(file, args, {
|
|
2159
|
-
encoding: "utf-8",
|
|
2160
|
-
timeout: 2e3,
|
|
2161
|
-
windowsHide: true
|
|
2162
|
-
});
|
|
2163
|
-
return pattern.exec(out)?.[1];
|
|
2164
|
-
} catch {
|
|
2165
|
-
return void 0;
|
|
2166
|
-
}
|
|
2167
|
-
};
|
|
2168
|
-
if (machineIdRead?.platform === process.platform) return machineIdRead.id;
|
|
2169
|
-
const systemRoot = process.env.SystemRoot;
|
|
2170
|
-
machineIdRead = {
|
|
2171
|
-
platform: process.platform,
|
|
2172
|
-
id: process.platform === "darwin" ? read2(
|
|
2173
|
-
"/usr/sbin/ioreg",
|
|
2174
|
-
["-rd1", "-c", "IOPlatformExpertDevice"],
|
|
2175
|
-
/"IOPlatformUUID" = "([^"]+)"/
|
|
2176
|
-
) : process.platform === "win32" && systemRoot && /^[A-Za-z]:\\/.test(systemRoot) ? read2(
|
|
2177
|
-
win32.join(systemRoot, "System32", "reg.exe"),
|
|
2178
|
-
["query", "HKLM\\SOFTWARE\\Microsoft\\Cryptography", "/v", "MachineGuid"],
|
|
2179
|
-
/MachineGuid\s+REG_SZ\s+(\S+)/
|
|
2180
|
-
) : void 0
|
|
2181
|
-
};
|
|
2182
|
-
return machineIdRead.id;
|
|
2183
|
-
}
|
|
2184
|
-
function pidScope() {
|
|
2185
|
-
const attempt = (read2) => {
|
|
2186
|
-
try {
|
|
2187
|
-
return read2();
|
|
2188
|
-
} catch {
|
|
2189
|
-
return void 0;
|
|
2190
|
-
}
|
|
2191
|
-
};
|
|
2192
|
-
const bootId = attempt(() => readFileSync2("/proc/sys/kernel/random/boot_id", "utf-8").trim());
|
|
2193
|
-
return {
|
|
2194
|
-
host: hostname(),
|
|
2195
|
-
// Without /proc (macOS, Windows) the boot time in seconds stands in for the boot id, on this machine's own id.
|
|
2196
|
-
boot: bootId ?? attempt(() => `s:${Math.round(Date.now() / 1e3 - uptime())}`),
|
|
2197
|
-
pidns: attempt(() => readlinkSync2("/proc/self/ns/pid")),
|
|
2198
|
-
machine: bootId === void 0 ? machineId() : void 0
|
|
2199
|
-
};
|
|
2200
|
-
}
|
|
2201
2144
|
function createOwnedRenderDir(prefix) {
|
|
2202
2145
|
const dir = createStagingDir(dirname3(prefix), basename4(prefix));
|
|
2203
|
-
|
|
2204
|
-
writeFileSync2(toWin32LongPath(join5(dir, OWNER_FILE)), JSON.stringify(owner));
|
|
2146
|
+
writeFileSync2(toWin32LongPath(join5(dir, OWNER_FILE)), JSON.stringify(processOwnerRecord()));
|
|
2205
2147
|
return dir;
|
|
2206
2148
|
}
|
|
2207
|
-
function alive(pid) {
|
|
2208
|
-
try {
|
|
2209
|
-
process.kill(pid, 0);
|
|
2210
|
-
return true;
|
|
2211
|
-
} catch (error) {
|
|
2212
|
-
return error.code === "EPERM";
|
|
2213
|
-
}
|
|
2214
|
-
}
|
|
2215
|
-
function knownPidScope() {
|
|
2216
|
-
const scope = pidScope();
|
|
2217
|
-
const unknown = scope.boot === void 0 || process.platform === "linux" && scope.pidns === void 0 || scope.boot.startsWith("s:") && scope.machine === void 0;
|
|
2218
|
-
return unknown ? void 0 : scope;
|
|
2219
|
-
}
|
|
2220
|
-
function sameBoot(stamped, current) {
|
|
2221
|
-
if (stamped === current) return true;
|
|
2222
|
-
const seconds = (boot) => typeof boot === "string" ? /^s:(\d+)$/.exec(boot)?.[1] : void 0;
|
|
2223
|
-
const [a, b] = [seconds(stamped), seconds(current)];
|
|
2224
|
-
return a !== void 0 && b !== void 0 && Math.abs(Number(a) - Number(b)) <= 2;
|
|
2225
|
-
}
|
|
2226
|
-
function inThisPidScope(owner) {
|
|
2227
|
-
const scope = knownPidScope();
|
|
2228
|
-
return scope !== void 0 && owner.host === scope.host && sameBoot(owner.boot, scope.boot) && owner.pidns === scope.pidns && owner.machine === scope.machine;
|
|
2229
|
-
}
|
|
2230
2149
|
function ownerState(dir) {
|
|
2231
2150
|
let owner;
|
|
2232
2151
|
try {
|
|
@@ -2234,11 +2153,7 @@ function ownerState(dir) {
|
|
|
2234
2153
|
} catch (error) {
|
|
2235
2154
|
return error.code === "ENOENT" ? "none" : "unknown";
|
|
2236
2155
|
}
|
|
2237
|
-
|
|
2238
|
-
if (!inThisPidScope(owner) || typeof pid !== "number" || !Number.isInteger(pid) || pid <= 0) {
|
|
2239
|
-
return "unknown";
|
|
2240
|
-
}
|
|
2241
|
-
return alive(pid) ? "live" : "gone";
|
|
2156
|
+
return ownerRecordState(owner);
|
|
2242
2157
|
}
|
|
2243
2158
|
function newestWriteMs(path) {
|
|
2244
2159
|
const stat = lstatSync2(path);
|
|
@@ -2701,7 +2616,7 @@ function replanAfterFailure(plan, failure) {
|
|
|
2701
2616
|
}
|
|
2702
2617
|
|
|
2703
2618
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2704
|
-
import { existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync6, statSync as
|
|
2619
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync5, rmSync as rmSync6, statSync as statSync3 } from "node:fs";
|
|
2705
2620
|
import { join as join12 } from "node:path";
|
|
2706
2621
|
import {
|
|
2707
2622
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
@@ -3625,7 +3540,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
3625
3540
|
}
|
|
3626
3541
|
|
|
3627
3542
|
// src/services/render/stages/captureHdrResources.ts
|
|
3628
|
-
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync5, statSync as
|
|
3543
|
+
import { mkdirSync as mkdirSync3, readFileSync as readFileSync3, rmSync as rmSync5, statSync as statSync2, statfsSync } from "node:fs";
|
|
3629
3544
|
import {
|
|
3630
3545
|
decodePngToRgb48le,
|
|
3631
3546
|
extractMediaMetadata as extractMediaMetadata2,
|
|
@@ -4050,7 +3965,7 @@ async function extractHdrVideoFrames(args) {
|
|
|
4050
3965
|
failureReason: result.failureReason
|
|
4051
3966
|
});
|
|
4052
3967
|
}
|
|
4053
|
-
return Math.min(Math.floor(
|
|
3968
|
+
return Math.min(Math.floor(statSync2(spec.path).size / frameSize), spec.frames);
|
|
4054
3969
|
}
|
|
4055
3970
|
});
|
|
4056
3971
|
const first = await windows.lease(0);
|
|
@@ -5599,7 +5514,7 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5599
5514
|
path: segmentPath,
|
|
5600
5515
|
// Recorded so resume can prove the file on disk is the one that
|
|
5601
5516
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5602
|
-
bytes: existsSync7(segmentPath) ?
|
|
5517
|
+
bytes: existsSync7(segmentPath) ? statSync3(segmentPath).size : 0,
|
|
5603
5518
|
sha256: existsSync7(segmentPath) ? await hashSegmentFile(segmentPath) : ""
|
|
5604
5519
|
});
|
|
5605
5520
|
return encodeResult;
|
|
@@ -6661,7 +6576,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6661
6576
|
}
|
|
6662
6577
|
|
|
6663
6578
|
// src/services/render/videoFrameWindow.ts
|
|
6664
|
-
import { readdirSync as readdirSync3, statSync as
|
|
6579
|
+
import { readdirSync as readdirSync3, statSync as statSync4 } from "node:fs";
|
|
6665
6580
|
import { join as join16 } from "node:path";
|
|
6666
6581
|
function shouldWindowVideoFrames(args) {
|
|
6667
6582
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
@@ -6677,7 +6592,7 @@ function directoryBytes(path) {
|
|
|
6677
6592
|
for (const entry of entries) {
|
|
6678
6593
|
const child2 = join16(path, entry.name);
|
|
6679
6594
|
try {
|
|
6680
|
-
bytes += entry.isDirectory() ? directoryBytes(child2) :
|
|
6595
|
+
bytes += entry.isDirectory() ? directoryBytes(child2) : statSync4(child2).size;
|
|
6681
6596
|
} catch {
|
|
6682
6597
|
}
|
|
6683
6598
|
}
|
|
@@ -7387,7 +7302,7 @@ import {
|
|
|
7387
7302
|
stylesheetLinkMatches
|
|
7388
7303
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7389
7304
|
import { createHash as createHash6 } from "node:crypto";
|
|
7390
|
-
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync9, statSync as
|
|
7305
|
+
import { createReadStream as createReadStream3, existsSync as existsSync11, mkdirSync as mkdirSync11, readFileSync as readFileSync9, statSync as statSync7 } from "fs";
|
|
7391
7306
|
import { join as join21, dirname as dirname10, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7392
7307
|
import { parseHTML as parseHTML5 } from "@hyperframes/parsers/linkedom";
|
|
7393
7308
|
import { compositionRootSize } from "@hyperframes/parsers";
|
|
@@ -7676,7 +7591,7 @@ import {
|
|
|
7676
7591
|
|
|
7677
7592
|
// src/services/animatedGifPrep.ts
|
|
7678
7593
|
import { createHash as createHash4, randomUUID } from "node:crypto";
|
|
7679
|
-
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync9, readFileSync as readFileSync7, rmSync as rmSync9, statSync as
|
|
7594
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync9, mkdirSync as mkdirSync9, readFileSync as readFileSync7, rmSync as rmSync9, statSync as statSync5 } from "node:fs";
|
|
7680
7595
|
import { dirname as dirname7, isAbsolute as isAbsolute3, join as join18, resolve as resolve6 } from "node:path";
|
|
7681
7596
|
import { parseHTML as parseHTML3 } from "@hyperframes/parsers/linkedom";
|
|
7682
7597
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
@@ -7739,7 +7654,7 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7739
7654
|
}
|
|
7740
7655
|
function isUsableFile(path) {
|
|
7741
7656
|
try {
|
|
7742
|
-
const stat =
|
|
7657
|
+
const stat = statSync5(path);
|
|
7743
7658
|
return stat.isFile() && stat.size > 0;
|
|
7744
7659
|
} catch {
|
|
7745
7660
|
return false;
|
|
@@ -7889,7 +7804,7 @@ async function ensurePreparedWebm(input) {
|
|
|
7889
7804
|
if (!isUsableFile(tmpPath)) {
|
|
7890
7805
|
throw new Error("Animated GIF transcode produced an empty output");
|
|
7891
7806
|
}
|
|
7892
|
-
if (
|
|
7807
|
+
if (statSync5(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP) {
|
|
7893
7808
|
throw new Error("Animated GIF transcode reached its output size limit");
|
|
7894
7809
|
}
|
|
7895
7810
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -8025,7 +7940,7 @@ import {
|
|
|
8025
7940
|
readFileSync as readFileSync8,
|
|
8026
7941
|
readSync as readSync3,
|
|
8027
7942
|
rmSync as rmSync10,
|
|
8028
|
-
statSync as
|
|
7943
|
+
statSync as statSync6,
|
|
8029
7944
|
writeFileSync as writeFileSync4
|
|
8030
7945
|
} from "node:fs";
|
|
8031
7946
|
import { dirname as dirname8, join as join19, resolve as resolve7 } from "node:path";
|
|
@@ -8281,7 +8196,7 @@ function resolveImageSource(src, options) {
|
|
|
8281
8196
|
}
|
|
8282
8197
|
function isUsableFile2(path) {
|
|
8283
8198
|
try {
|
|
8284
|
-
return
|
|
8199
|
+
return statSync6(path).size > 0;
|
|
8285
8200
|
} catch {
|
|
8286
8201
|
return false;
|
|
8287
8202
|
}
|
|
@@ -8302,7 +8217,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
8302
8217
|
signal: options.signal
|
|
8303
8218
|
});
|
|
8304
8219
|
if (!isUsableFile2(tmpPath)) throw new Error("conversion produced an empty file");
|
|
8305
|
-
if (
|
|
8220
|
+
if (statSync6(tmpPath).size >= FFMPEG_SELF_OUTPUT_BYTES_CAP2) {
|
|
8306
8221
|
throw new Error("conversion reached its output size limit");
|
|
8307
8222
|
}
|
|
8308
8223
|
renameWithRetry3(tmpPath, cachePath);
|
|
@@ -9977,7 +9892,7 @@ async function localFontDataUri(localPath, projectDir, assetRoot, dataUriByAbsol
|
|
|
9977
9892
|
if (dataUriByAbsolutePath.has(absPath)) return dataUriByAbsolutePath.get(absPath);
|
|
9978
9893
|
const ext = absPath.match(/\.(woff2?|ttf|otf|ttc)$/i)?.[1]?.toLowerCase() ?? "ttf";
|
|
9979
9894
|
try {
|
|
9980
|
-
if (!reserve(Math.ceil(
|
|
9895
|
+
if (!reserve(Math.ceil(statSync7(absPath).size / 3) * 4 + 64)) {
|
|
9981
9896
|
dataUriByAbsolutePath.set(absPath, void 0);
|
|
9982
9897
|
return void 0;
|
|
9983
9898
|
}
|
|
@@ -11785,14 +11700,14 @@ async function runProbeStage(input) {
|
|
|
11785
11700
|
probeSession.beginFrameTimeTicks,
|
|
11786
11701
|
probeSession.beginFrameIntervalMs
|
|
11787
11702
|
);
|
|
11788
|
-
const
|
|
11703
|
+
const alive = await probeBeginFrameLiveness(
|
|
11789
11704
|
probeSession.page,
|
|
11790
11705
|
probeTimeoutMs,
|
|
11791
11706
|
probeTick,
|
|
11792
11707
|
probeSession.beginFrameIntervalMs
|
|
11793
11708
|
);
|
|
11794
11709
|
assertNotAborted();
|
|
11795
|
-
if (
|
|
11710
|
+
if (alive) {
|
|
11796
11711
|
log.info("BeginFrame liveness probe passed", {
|
|
11797
11712
|
probeMs: Date.now() - livenessStart
|
|
11798
11713
|
});
|
|
@@ -12469,7 +12384,8 @@ async function runExtractVideosStage(input) {
|
|
|
12469
12384
|
shownBoxes,
|
|
12470
12385
|
urlByAbsentLocalPath,
|
|
12471
12386
|
audioDownloadDir,
|
|
12472
|
-
skipFrameExtractionIds = []
|
|
12387
|
+
skipFrameExtractionIds = [],
|
|
12388
|
+
cacheLease
|
|
12473
12389
|
} = input;
|
|
12474
12390
|
const stage2Start = Date.now();
|
|
12475
12391
|
const assetRoots = job.config.allowOutsideProjectAssets ? void 0 : mediaAssetRoots(projectDir, compiledDir);
|
|
@@ -12589,6 +12505,7 @@ async function runExtractVideosStage(input) {
|
|
|
12589
12505
|
contentKeyedDirs: [join26(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
12590
12506
|
urlByAbsentLocalPath,
|
|
12591
12507
|
assetRoots,
|
|
12508
|
+
cacheLease,
|
|
12592
12509
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
12593
12510
|
framesPlanned += planned;
|
|
12594
12511
|
framesDone += done;
|
|
@@ -14994,7 +14911,7 @@ import {
|
|
|
14994
14911
|
readdirSync as readdirSync5,
|
|
14995
14912
|
readFileSync as readFileSync10,
|
|
14996
14913
|
rmSync as rmSync12,
|
|
14997
|
-
statSync as
|
|
14914
|
+
statSync as statSync8,
|
|
14998
14915
|
writeFileSync as writeFileSync7
|
|
14999
14916
|
} from "node:fs";
|
|
15000
14917
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
@@ -15123,7 +15040,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
15123
15040
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
15124
15041
|
if (failure) return failure;
|
|
15125
15042
|
}
|
|
15126
|
-
const fileSize = existsSync21(outputPath) ?
|
|
15043
|
+
const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
|
|
15127
15044
|
return {
|
|
15128
15045
|
success: true,
|
|
15129
15046
|
outputPath,
|
|
@@ -15537,7 +15454,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
15537
15454
|
for (const name of entries) {
|
|
15538
15455
|
const full = join36(current, name);
|
|
15539
15456
|
try {
|
|
15540
|
-
const st =
|
|
15457
|
+
const st = statSync9(full);
|
|
15541
15458
|
if (st.isDirectory()) {
|
|
15542
15459
|
stack.push(full);
|
|
15543
15460
|
} else if (st.isFile()) {
|
|
@@ -15701,7 +15618,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
15701
15618
|
let rangeStart = null;
|
|
15702
15619
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
15703
15620
|
const framePath = join36(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
15704
|
-
const missing = !existsSync22(framePath) ||
|
|
15621
|
+
const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
|
|
15705
15622
|
if (missing && rangeStart === null) {
|
|
15706
15623
|
rangeStart = frameIndex;
|
|
15707
15624
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -16948,6 +16865,8 @@ async function executeRenderPipeline(input) {
|
|
|
16948
16865
|
reason
|
|
16949
16866
|
});
|
|
16950
16867
|
}
|
|
16868
|
+
const cacheLease = createCacheLease();
|
|
16869
|
+
execution.defer("release extraction cache lease", () => cacheLease.release());
|
|
16951
16870
|
const extractResult = await observeRenderStage(
|
|
16952
16871
|
observability,
|
|
16953
16872
|
"video_extract",
|
|
@@ -16965,6 +16884,7 @@ async function executeRenderPipeline(input) {
|
|
|
16965
16884
|
assertNotAborted,
|
|
16966
16885
|
// Local staging can use links; distributed plan() alone requires real copies.
|
|
16967
16886
|
materializeSymlinks: false,
|
|
16887
|
+
cacheLease,
|
|
16968
16888
|
deferRangeExtraction: windowVideoFrames ? true : void 0,
|
|
16969
16889
|
shownBoxes,
|
|
16970
16890
|
onProgress
|
|
@@ -18825,7 +18745,7 @@ async function executeRenderPipeline(input) {
|
|
|
18825
18745
|
import {
|
|
18826
18746
|
existsSync as existsSync23,
|
|
18827
18747
|
readFileSync as readFileSync11,
|
|
18828
|
-
statSync as
|
|
18748
|
+
statSync as statSync10,
|
|
18829
18749
|
openSync as openSync6,
|
|
18830
18750
|
fstatSync as fstatSync4,
|
|
18831
18751
|
closeSync as closeSync6,
|
|
@@ -18866,7 +18786,7 @@ function readEntryHtml(filePath) {
|
|
|
18866
18786
|
} catch (error) {
|
|
18867
18787
|
if (error instanceof Error && "code" in error && (error.code === "ENOENT" || error.code === "ENOTDIR"))
|
|
18868
18788
|
return null;
|
|
18869
|
-
if (!
|
|
18789
|
+
if (!statSync10(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
18870
18790
|
throw error;
|
|
18871
18791
|
}
|
|
18872
18792
|
try {
|
|
@@ -18882,7 +18802,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
18882
18802
|
}
|
|
18883
18803
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
18884
18804
|
const absProjectDir = resolve11(projectDir);
|
|
18885
|
-
if (!existsSync23(absProjectDir) || !
|
|
18805
|
+
if (!existsSync23(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
|
|
18886
18806
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
18887
18807
|
}
|
|
18888
18808
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -19847,7 +19767,7 @@ function prepareProjectDirectory(projectDir, options, policy) {
|
|
|
19847
19767
|
if (!candidate) return null;
|
|
19848
19768
|
const absProjectDir = policy ? resolve12(policy.projectsDir, candidate) : resolve12(candidate);
|
|
19849
19769
|
const shown = policy ? candidate : absProjectDir;
|
|
19850
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !
|
|
19770
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
19851
19771
|
return { error: `Project directory not found: ${shown}` };
|
|
19852
19772
|
}
|
|
19853
19773
|
const entry = options.entryFile || "index.html";
|
|
@@ -19989,7 +19909,7 @@ function publicPerfSummary(job) {
|
|
|
19989
19909
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
19990
19910
|
}
|
|
19991
19911
|
function outputFileSize(path) {
|
|
19992
|
-
return existsSync26(path) ?
|
|
19912
|
+
return existsSync26(path) ? statSync11(path).size : 0;
|
|
19993
19913
|
}
|
|
19994
19914
|
function createBlockingProgressReporter(log, requestId) {
|
|
19995
19915
|
let lastLoggedPct = -10;
|
|
@@ -20360,18 +20280,18 @@ function hostnameOf(host) {
|
|
|
20360
20280
|
return null;
|
|
20361
20281
|
}
|
|
20362
20282
|
}
|
|
20363
|
-
function isAllowedBrowserHostname(
|
|
20364
|
-
if (!
|
|
20365
|
-
if (
|
|
20366
|
-
if (isIP(
|
|
20367
|
-
return allowed.has(
|
|
20283
|
+
function isAllowedBrowserHostname(hostname, allowed) {
|
|
20284
|
+
if (!hostname) return false;
|
|
20285
|
+
if (hostname === "localhost" || hostname.endsWith(".localhost")) return true;
|
|
20286
|
+
if (isIP(hostname.replace(/^\[|\]$/g, "")) !== 0) return true;
|
|
20287
|
+
return allowed.has(hostname);
|
|
20368
20288
|
}
|
|
20369
20289
|
function allowedHostnames(options) {
|
|
20370
20290
|
const fromEnv = (process.env.PRODUCER_ALLOWED_HOSTS ?? "").split(",");
|
|
20371
20291
|
const names = /* @__PURE__ */ new Set();
|
|
20372
20292
|
for (const entry of [...options.allowedHosts ?? [], ...fromEnv]) {
|
|
20373
|
-
const
|
|
20374
|
-
if (
|
|
20293
|
+
const hostname = entry.trim() ? hostnameOf(entry.trim()) : null;
|
|
20294
|
+
if (hostname) names.add(hostname);
|
|
20375
20295
|
}
|
|
20376
20296
|
return names;
|
|
20377
20297
|
}
|
|
@@ -20385,8 +20305,8 @@ function hasBearerToken(c, token) {
|
|
|
20385
20305
|
digest(`Bearer ${token}`)
|
|
20386
20306
|
);
|
|
20387
20307
|
}
|
|
20388
|
-
function isLoopbackHostname(
|
|
20389
|
-
const host =
|
|
20308
|
+
function isLoopbackHostname(hostname) {
|
|
20309
|
+
const host = hostname.replace(/^\[|\]$/g, "").toLowerCase();
|
|
20390
20310
|
return host === "localhost" || host === "::1" || isIP(host) === 4 && host.startsWith("127.");
|
|
20391
20311
|
}
|
|
20392
20312
|
function isDisallowedBrowserHost(c, allowed) {
|
|
@@ -20455,12 +20375,12 @@ function onEscapedRejection(reason, log) {
|
|
|
20455
20375
|
});
|
|
20456
20376
|
scope?.fail(err);
|
|
20457
20377
|
}
|
|
20458
|
-
function serverAuth(options,
|
|
20378
|
+
function serverAuth(options, hostname, port) {
|
|
20459
20379
|
const configured = resolveAuthToken(options);
|
|
20460
20380
|
if (configured) return { token: configured };
|
|
20461
|
-
if (!isLoopbackHostname(
|
|
20381
|
+
if (!isLoopbackHostname(hostname)) {
|
|
20462
20382
|
throw new Error(
|
|
20463
|
-
`Refusing to listen on ${
|
|
20383
|
+
`Refusing to listen on ${hostname} without an auth token. Set authToken or PRODUCER_AUTH_TOKEN, or listen on a loopback address.`
|
|
20464
20384
|
);
|
|
20465
20385
|
}
|
|
20466
20386
|
const file = resolve12(
|
|
@@ -20475,11 +20395,11 @@ function serverAuth(options, hostname2, port) {
|
|
|
20475
20395
|
}
|
|
20476
20396
|
function startServer(options = {}) {
|
|
20477
20397
|
const port = options.port ?? parseInt(process.env.PRODUCER_PORT ?? "9847", 10);
|
|
20478
|
-
const
|
|
20398
|
+
const hostname = options.hostname || process.env.PRODUCER_HOST || "127.0.0.1";
|
|
20479
20399
|
const log = options.logger ?? defaultLogger;
|
|
20480
|
-
const auth = serverAuth(options,
|
|
20400
|
+
const auth = serverAuth(options, hostname, port);
|
|
20481
20401
|
const app = createProducerApp({ ...options, authToken: auth.token });
|
|
20482
|
-
const server = serve2({ fetch: app.fetch, port, hostname
|
|
20402
|
+
const server = serve2({ fetch: app.fetch, port, hostname }, (info) => {
|
|
20483
20403
|
const address = info.family === "IPv6" ? `[${info.address}]` : info.address;
|
|
20484
20404
|
log.info(`Listening on http://${address}:${info.port}`);
|
|
20485
20405
|
if (auth.generatedFile) {
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
* machines (symlinks don't survive S3 / GCS round-trips). Default
|
|
28
28
|
* `false` preserves the in-process renderer's symlink behavior.
|
|
29
29
|
*/
|
|
30
|
-
import { type CaptureVideoMetadataHint, type EngineConfig, type ExtractionResult, type FrameLookupTable, type HdrTransfer, type VideoExtractionFailureKind, type VideoColorSpace, classifyVideoExtractionError, extractAllVideoFrames, type ShownBox } from "@hyperframes/engine";
|
|
30
|
+
import { type CacheLease, type CaptureVideoMetadataHint, type EngineConfig, type ExtractionResult, type FrameLookupTable, type HdrTransfer, type VideoExtractionFailureKind, type VideoColorSpace, classifyVideoExtractionError, extractAllVideoFrames, type ShownBox } from "@hyperframes/engine";
|
|
31
31
|
import { type RenderJob } from "../../renderOrchestrator.js";
|
|
32
32
|
import { type CompositionMetadata } from "../shared.js";
|
|
33
33
|
import type { ProgressCallback } from "../../renderOrchestrator.js";
|
|
@@ -57,6 +57,7 @@ export interface ExtractVideosStageInput {
|
|
|
57
57
|
urlByAbsentLocalPath?: ReadonlyMap<string, string>;
|
|
58
58
|
audioDownloadDir?: string;
|
|
59
59
|
onProgress?: ProgressCallback;
|
|
60
|
+
cacheLease?: CacheLease;
|
|
60
61
|
}
|
|
61
62
|
export interface ExtractVideosStageResult {
|
|
62
63
|
/** Result of `extractAllVideoFrames`, or `null` if the composition has no videos. */
|
package/dist/utils/paths.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Path resolution utilities for the render pipeline.
|
|
3
3
|
*/
|
|
4
|
-
import { type LeftOutReason } from "@hyperframes/studio-server/outside-file";
|
|
4
|
+
import { type LeftOutReason, type OutsideFilePolicy } from "@hyperframes/studio-server/outside-file";
|
|
5
|
+
export type { OutsideFilePolicy };
|
|
5
6
|
export interface RenderPaths {
|
|
6
7
|
absoluteProjectDir: string;
|
|
7
8
|
absoluteOutputPath: string;
|
|
@@ -29,10 +30,6 @@ type IsPathInsideOptions = {
|
|
|
29
30
|
export declare function isPathInside(childPath: string, parentPath: string, options?: IsPathInsideOptions): boolean;
|
|
30
31
|
/** True when `assetRoot` is set and `path`, symlinks resolved, leaves it. */
|
|
31
32
|
export declare function escapesAssetRoot(path: string, assetRoot: string | undefined): boolean;
|
|
32
|
-
export interface OutsideFilePolicy {
|
|
33
|
-
/** The person passed --include-outside-files, so scripts outside the project run too. */
|
|
34
|
-
includeScripts?: boolean;
|
|
35
|
-
}
|
|
36
33
|
/** Why a trusted local render leaves out `path`, which leads outside `projectDir`, as publish does; null to bring it in. */
|
|
37
34
|
export declare function outsideAssetRefusal(projectDir: string, path: string, policy?: OutsideFilePolicy): LeftOutReason | null;
|
|
38
35
|
export declare const leftOutOfRender: (file: string, reference: string, reason: LeftOutReason) => string;
|
|
@@ -63,4 +60,3 @@ export declare function toExternalAssetKey(absPath: string): string;
|
|
|
63
60
|
export declare function formatCaptureFrameName(index: number, ext: string): string;
|
|
64
61
|
export declare function formatExportFrameName(index: number, ext: string): string;
|
|
65
62
|
export declare function resolveRenderPaths(projectDir: string, outputPath: string | null | undefined, rendersDir?: string): RenderPaths;
|
|
66
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hyperframes/producer",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.107",
|
|
4
4
|
"description": "HTML-to-video rendering engine using Chrome's BeginFrame API",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -35,12 +35,12 @@
|
|
|
35
35
|
"postcss": "^8.4.0",
|
|
36
36
|
"puppeteer": "~25.13.0",
|
|
37
37
|
"puppeteer-core": "^25.13.0",
|
|
38
|
-
"@hyperframes/core": "0.9.
|
|
39
|
-
"@hyperframes/engine": "0.9.
|
|
40
|
-
"@hyperframes/
|
|
41
|
-
"@hyperframes/
|
|
42
|
-
"@hyperframes/
|
|
43
|
-
"@hyperframes/
|
|
38
|
+
"@hyperframes/core": "0.9.107",
|
|
39
|
+
"@hyperframes/engine": "0.9.107",
|
|
40
|
+
"@hyperframes/parsers": "0.9.107",
|
|
41
|
+
"@hyperframes/lint": "0.9.107",
|
|
42
|
+
"@hyperframes/studio-server": "0.9.107",
|
|
43
|
+
"@hyperframes/share": "0.9.107"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
46
|
"@types/node": "^25.0.10",
|
|
@@ -49,7 +49,7 @@
|
|
|
49
49
|
"tsx": "^4.21.0",
|
|
50
50
|
"typescript": "^5.7.2",
|
|
51
51
|
"vitest": "^4.1.12",
|
|
52
|
-
"@hyperframes/aws-lambda": "0.9.
|
|
52
|
+
"@hyperframes/aws-lambda": "0.9.107"
|
|
53
53
|
},
|
|
54
54
|
"engines": {
|
|
55
55
|
"node": ">=22"
|