@hyperframes/producer 0.9.66 → 0.9.67
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 +91 -46
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +61 -61
- package/dist/index.d.ts +1 -0
- package/dist/index.js +649 -519
- package/dist/public-server.js +448 -318
- package/dist/services/compositionSizeLimit.d.ts +2 -0
- package/dist/services/htmlCompiler.d.ts +5 -2
- package/dist/services/render/cleanup.d.ts +2 -0
- package/dist/services/render/missingPath.d.ts +15 -0
- package/dist/services/render/observability.d.ts +1 -0
- package/dist/services/renderOrchestrator.d.ts +2 -0
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -18,7 +18,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
18
18
|
|
|
19
19
|
// src/server.ts
|
|
20
20
|
import {
|
|
21
|
-
existsSync as
|
|
21
|
+
existsSync as existsSync26,
|
|
22
22
|
mkdirSync as mkdirSync13,
|
|
23
23
|
statSync as statSync13,
|
|
24
24
|
mkdtempSync,
|
|
@@ -26,8 +26,8 @@ import {
|
|
|
26
26
|
rmSync as rmSync13,
|
|
27
27
|
createReadStream as createReadStream3
|
|
28
28
|
} from "node:fs";
|
|
29
|
-
import { resolve as
|
|
30
|
-
import { tmpdir as
|
|
29
|
+
import { resolve as resolve11, dirname as dirname18, join as join38 } from "node:path";
|
|
30
|
+
import { tmpdir as tmpdir4 } from "node:os";
|
|
31
31
|
import { parseArgs } from "node:util";
|
|
32
32
|
import { isIP } from "node:net";
|
|
33
33
|
import crypto from "node:crypto";
|
|
@@ -44,7 +44,7 @@ import { isSafePath as isSafePath3 } from "@hyperframes/core/safe-path";
|
|
|
44
44
|
// src/services/renderOrchestrator.ts
|
|
45
45
|
import { audioFailureDiagnostics as audioFailureDiagnostics2, usableCpuCount as usableCpuCount2 } from "@hyperframes/engine";
|
|
46
46
|
import {
|
|
47
|
-
existsSync as
|
|
47
|
+
existsSync as existsSync22,
|
|
48
48
|
mkdirSync as mkdirSync12,
|
|
49
49
|
readdirSync as readdirSync6,
|
|
50
50
|
rmSync as rmSync12,
|
|
@@ -53,7 +53,7 @@ import {
|
|
|
53
53
|
copyFileSync as copyFileSync5,
|
|
54
54
|
appendFileSync
|
|
55
55
|
} from "fs";
|
|
56
|
-
import { tmpdir as
|
|
56
|
+
import { tmpdir as tmpdir3 } from "node:os";
|
|
57
57
|
import {
|
|
58
58
|
chainCapture,
|
|
59
59
|
fpsToNumber as fpsToNumber8,
|
|
@@ -395,7 +395,7 @@ import {
|
|
|
395
395
|
referenceBackgroundResult,
|
|
396
396
|
createReferenceBackgroundRecorder
|
|
397
397
|
} from "@hyperframes/engine";
|
|
398
|
-
import { join as
|
|
398
|
+
import { join as join33, dirname as dirname14, resolve as resolve9 } from "path";
|
|
399
399
|
import { totalmem as totalmem2 } from "node:os";
|
|
400
400
|
import { randomUUID } from "crypto";
|
|
401
401
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -1302,13 +1302,13 @@ function createFileServer(options) {
|
|
|
1302
1302
|
if (!streamOwnsFd) closeSync(fd);
|
|
1303
1303
|
}
|
|
1304
1304
|
});
|
|
1305
|
-
return new Promise((
|
|
1305
|
+
return new Promise((resolve12, reject) => {
|
|
1306
1306
|
const connections = /* @__PURE__ */ new Set();
|
|
1307
1307
|
const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
|
|
1308
1308
|
const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
|
|
1309
1309
|
bound.then((boundPort) => {
|
|
1310
1310
|
listeningPort = boundPort;
|
|
1311
|
-
|
|
1311
|
+
resolve12({
|
|
1312
1312
|
url: `http://localhost:${boundPort}`,
|
|
1313
1313
|
port: boundPort,
|
|
1314
1314
|
addPreHeadScript: (script) => {
|
|
@@ -1871,10 +1871,96 @@ function buildRenderErrorDetails(input) {
|
|
|
1871
1871
|
perfStages: Object.keys(input.perfStages).length > 0 ? { ...input.perfStages } : void 0,
|
|
1872
1872
|
hdrDiagnostics: input.hdrDiagnostics.videoExtractionFailures > 0 || input.hdrDiagnostics.imageDecodeFailures > 0 ? { ...input.hdrDiagnostics } : void 0,
|
|
1873
1873
|
observability: input.observability,
|
|
1874
|
-
subTimelineWait: input.subTimelineWait
|
|
1874
|
+
subTimelineWait: input.subTimelineWait,
|
|
1875
|
+
missingPath: input.missingPath
|
|
1875
1876
|
};
|
|
1876
1877
|
}
|
|
1877
1878
|
|
|
1879
|
+
// src/services/render/missingPath.ts
|
|
1880
|
+
import { existsSync as existsSync4, lstatSync, readlinkSync } from "node:fs";
|
|
1881
|
+
import { tmpdir } from "node:os";
|
|
1882
|
+
import { basename as basename3, join as join4, relative as relative2, resolve as resolve4, isAbsolute as isAbsolute2, sep as sep3 } from "node:path";
|
|
1883
|
+
import { errnoMissingPathOf } from "@hyperframes/core/missing-path";
|
|
1884
|
+
var SYNCED = /onedrive|dropbox|icloud|mobile documents|clouddocs|google ?drive|cloudstorage/i;
|
|
1885
|
+
var inside = (path, folder) => {
|
|
1886
|
+
const rel = relative2(resolve4(folder), resolve4(path));
|
|
1887
|
+
return rel === "" || !rel.startsWith("..") && !isAbsolute2(rel);
|
|
1888
|
+
};
|
|
1889
|
+
function lstatOrNull(path) {
|
|
1890
|
+
try {
|
|
1891
|
+
return lstatSync(path);
|
|
1892
|
+
} catch {
|
|
1893
|
+
return null;
|
|
1894
|
+
}
|
|
1895
|
+
}
|
|
1896
|
+
var ROOT_SCOPES = [
|
|
1897
|
+
["tempRoot", "temp_root"],
|
|
1898
|
+
["cacheDir", "cache_root"],
|
|
1899
|
+
["workDir", "work_dir"]
|
|
1900
|
+
];
|
|
1901
|
+
var NAME_SCOPES = [
|
|
1902
|
+
[/\.partial/, "cache_partial"],
|
|
1903
|
+
[/^hfcache-/, "cache_entry"],
|
|
1904
|
+
[/^hyperframes-extract-cache/, "cache_root"],
|
|
1905
|
+
[/^(hf-render-|work-[0-9a-f]{8}-)/, "work_dir"]
|
|
1906
|
+
];
|
|
1907
|
+
function scopeOfGone(path, where, throughLink) {
|
|
1908
|
+
const root = ROOT_SCOPES.find(([key]) => {
|
|
1909
|
+
const dir = where[key];
|
|
1910
|
+
return !!dir && resolve4(path) === resolve4(dir);
|
|
1911
|
+
});
|
|
1912
|
+
if (root) return root[1];
|
|
1913
|
+
const name = basename3(path);
|
|
1914
|
+
return NAME_SCOPES.find(([pattern]) => pattern.test(name))?.[1] ?? (throughLink ? "link_target" : "other");
|
|
1915
|
+
}
|
|
1916
|
+
var MAX_LINK_HOPS = 4;
|
|
1917
|
+
function rootOf(path, where) {
|
|
1918
|
+
if (inside(path, where.tempRoot)) return "system_temp";
|
|
1919
|
+
if (where.cacheDir && inside(path, where.cacheDir)) return "cache_dir";
|
|
1920
|
+
return "other";
|
|
1921
|
+
}
|
|
1922
|
+
var ownerOf = (path, where) => [where.tempRoot, where.cacheDir, where.workDir].filter((root) => !!root && inside(path, root)).sort((a, b) => resolve4(a).length - resolve4(b).length)[0];
|
|
1923
|
+
var linkTarget = (link, folder) => resolve4(folder, readlinkSync(link).replace(/^\\\\\?\\/, ""));
|
|
1924
|
+
function goneAt(path, last, where, hops) {
|
|
1925
|
+
const scope = scopeOfGone(path, where, hops > 0);
|
|
1926
|
+
return last && scope === "other" ? "file" : scope;
|
|
1927
|
+
}
|
|
1928
|
+
function highestGone(path, where, hops = 0) {
|
|
1929
|
+
const root = ownerOf(path, where);
|
|
1930
|
+
if (!root || hops > MAX_LINK_HOPS) return "link_target";
|
|
1931
|
+
if (!existsSync4(root)) return scopeOfGone(root, where, hops > 0);
|
|
1932
|
+
const parts = relative2(resolve4(root), resolve4(path)).split(sep3).filter(Boolean);
|
|
1933
|
+
let at = resolve4(root);
|
|
1934
|
+
for (const [index, part] of parts.entries()) {
|
|
1935
|
+
const next = join4(at, part);
|
|
1936
|
+
const stat = lstatOrNull(next);
|
|
1937
|
+
if (!stat) return goneAt(next, index === parts.length - 1, where, hops);
|
|
1938
|
+
at = stat.isSymbolicLink() ? linkTarget(next, at) : next;
|
|
1939
|
+
const gone = at === next ? void 0 : highestGone(at, where, hops + 1);
|
|
1940
|
+
if (gone) return gone;
|
|
1941
|
+
}
|
|
1942
|
+
return void 0;
|
|
1943
|
+
}
|
|
1944
|
+
var isSpawnFailure = (error) => !!error?.syscall?.startsWith("spawn");
|
|
1945
|
+
function describeMissingPath(error, {
|
|
1946
|
+
cacheDir,
|
|
1947
|
+
workDir,
|
|
1948
|
+
tempRoot = tmpdir()
|
|
1949
|
+
} = {}) {
|
|
1950
|
+
try {
|
|
1951
|
+
const path = errnoMissingPathOf(error);
|
|
1952
|
+
if (!path || isSpawnFailure(error)) return void 0;
|
|
1953
|
+
const where = { tempRoot, cacheDir, workDir };
|
|
1954
|
+
return {
|
|
1955
|
+
scope: ownerOf(path, where) ? highestGone(path, where) ?? "other" : scopeOfGone(path, where, false),
|
|
1956
|
+
synced: SYNCED.test(path),
|
|
1957
|
+
root: rootOf(path, where)
|
|
1958
|
+
};
|
|
1959
|
+
} catch {
|
|
1960
|
+
return void 0;
|
|
1961
|
+
}
|
|
1962
|
+
}
|
|
1963
|
+
|
|
1878
1964
|
// src/services/render/renderEventPublisher.ts
|
|
1879
1965
|
import { cloneCaptureWarnings } from "@hyperframes/engine";
|
|
1880
1966
|
var FLUSH_TIMEOUT_MS = 1e4;
|
|
@@ -1910,8 +1996,8 @@ var OrderedRenderEventPublisher = class {
|
|
|
1910
1996
|
let timer;
|
|
1911
1997
|
const drained = await Promise.race([
|
|
1912
1998
|
this.tail.then(() => true),
|
|
1913
|
-
new Promise((
|
|
1914
|
-
timer = setTimeout(() =>
|
|
1999
|
+
new Promise((resolve12) => {
|
|
2000
|
+
timer = setTimeout(() => resolve12(false), FLUSH_TIMEOUT_MS);
|
|
1915
2001
|
})
|
|
1916
2002
|
]);
|
|
1917
2003
|
clearTimeout(timer);
|
|
@@ -2015,8 +2101,8 @@ var RenderExecutionContext = class {
|
|
|
2015
2101
|
};
|
|
2016
2102
|
|
|
2017
2103
|
// src/services/render/artifactTransaction.ts
|
|
2018
|
-
import { closeSync as closeSync2, existsSync as
|
|
2019
|
-
import { basename as
|
|
2104
|
+
import { closeSync as closeSync2, existsSync as existsSync6, fstatSync as fstatSync2, openSync as openSync2, readSync, readdirSync as readdirSync2, rmSync as rmSync3 } from "node:fs";
|
|
2105
|
+
import { basename as basename5, dirname as dirname4, extname as extname2, join as join6, resolve as resolve5 } from "node:path";
|
|
2020
2106
|
import { HLS_MASTER_PLAYLIST, HLS_VIDEO_PLAYLIST, renameWithRetry } from "@hyperframes/engine";
|
|
2021
2107
|
|
|
2022
2108
|
// src/utils/ffprobe.ts
|
|
@@ -2028,16 +2114,16 @@ import {
|
|
|
2028
2114
|
|
|
2029
2115
|
// src/services/render/renderDirOwner.ts
|
|
2030
2116
|
import {
|
|
2031
|
-
existsSync as
|
|
2032
|
-
lstatSync,
|
|
2117
|
+
existsSync as existsSync5,
|
|
2118
|
+
lstatSync as lstatSync2,
|
|
2033
2119
|
readFileSync as readFileSync2,
|
|
2034
2120
|
readdirSync,
|
|
2035
|
-
readlinkSync,
|
|
2121
|
+
readlinkSync as readlinkSync2,
|
|
2036
2122
|
rmSync as rmSync2,
|
|
2037
2123
|
writeFileSync as writeFileSync2
|
|
2038
2124
|
} from "node:fs";
|
|
2039
2125
|
import { hostname, uptime } from "node:os";
|
|
2040
|
-
import { basename as
|
|
2126
|
+
import { basename as basename4, dirname as dirname3, join as join5 } from "node:path";
|
|
2041
2127
|
import { RENDER_TEMP_DIR } from "@hyperframes/core/project-folders";
|
|
2042
2128
|
import { createStagingDir } from "@hyperframes/core/atomic-file";
|
|
2043
2129
|
var OWNER_FILE = "owner.json";
|
|
@@ -2054,13 +2140,13 @@ function pidScope() {
|
|
|
2054
2140
|
host: hostname(),
|
|
2055
2141
|
// Without /proc (macOS, Windows) the boot time, to the minute, stands in for the boot id.
|
|
2056
2142
|
boot: attempt(() => readFileSync2("/proc/sys/kernel/random/boot_id", "utf-8").trim()) ?? attempt(() => String(Math.round(Date.now() / 6e4 - uptime() / 60))),
|
|
2057
|
-
pidns: attempt(() =>
|
|
2143
|
+
pidns: attempt(() => readlinkSync2("/proc/self/ns/pid"))
|
|
2058
2144
|
};
|
|
2059
2145
|
}
|
|
2060
2146
|
function createOwnedRenderDir(prefix) {
|
|
2061
|
-
const dir = createStagingDir(dirname3(prefix),
|
|
2147
|
+
const dir = createStagingDir(dirname3(prefix), basename4(prefix));
|
|
2062
2148
|
const owner = { pid: process.pid, ...pidScope() };
|
|
2063
|
-
writeFileSync2(
|
|
2149
|
+
writeFileSync2(join5(dir, OWNER_FILE), JSON.stringify(owner));
|
|
2064
2150
|
return dir;
|
|
2065
2151
|
}
|
|
2066
2152
|
function alive(pid) {
|
|
@@ -2083,7 +2169,7 @@ function inThisPidScope(owner) {
|
|
|
2083
2169
|
function ownerState(dir) {
|
|
2084
2170
|
let owner;
|
|
2085
2171
|
try {
|
|
2086
|
-
owner = JSON.parse(readFileSync2(
|
|
2172
|
+
owner = JSON.parse(readFileSync2(join5(dir, OWNER_FILE), "utf-8"));
|
|
2087
2173
|
} catch (error) {
|
|
2088
2174
|
return error.code === "ENOENT" ? "none" : "unknown";
|
|
2089
2175
|
}
|
|
@@ -2094,16 +2180,16 @@ function ownerState(dir) {
|
|
|
2094
2180
|
return alive(pid) ? "live" : "gone";
|
|
2095
2181
|
}
|
|
2096
2182
|
function newestWriteMs(path) {
|
|
2097
|
-
const stat =
|
|
2183
|
+
const stat = lstatSync2(path);
|
|
2098
2184
|
if (!stat.isDirectory()) return stat.mtimeMs;
|
|
2099
2185
|
return readdirSync(path).reduce(
|
|
2100
|
-
(newest, name) => Math.max(newest, newestWriteMs(
|
|
2186
|
+
(newest, name) => Math.max(newest, newestWriteMs(join5(path, name))),
|
|
2101
2187
|
stat.mtimeMs
|
|
2102
2188
|
);
|
|
2103
2189
|
}
|
|
2104
2190
|
function isAbandoned(dir, ownerlessIdleMs, now) {
|
|
2105
2191
|
try {
|
|
2106
|
-
if (!
|
|
2192
|
+
if (!lstatSync2(dir).isDirectory() || existsSync5(join5(dir, TRANSACTION_BACKUP))) return false;
|
|
2107
2193
|
const owner = ownerState(dir);
|
|
2108
2194
|
if (owner === "gone") return true;
|
|
2109
2195
|
return owner === "none" && ownerlessIdleMs !== void 0 && now - newestWriteMs(dir) >= ownerlessIdleMs;
|
|
@@ -2119,7 +2205,7 @@ function listAbandonedRenderDirs(parent, options = {}) {
|
|
|
2119
2205
|
return [];
|
|
2120
2206
|
}
|
|
2121
2207
|
const now = Date.now();
|
|
2122
|
-
return names.filter((name) => (options.names ?? RENDER_TEMP_DIR).test(name)).map((name) =>
|
|
2208
|
+
return names.filter((name) => (options.names ?? RENDER_TEMP_DIR).test(name)).map((name) => join5(parent, name)).filter((dir) => isAbandoned(dir, options.ownerlessIdleMs, now));
|
|
2123
2209
|
}
|
|
2124
2210
|
function createRenderWorkDir(prefix, outputDir) {
|
|
2125
2211
|
for (const parent of /* @__PURE__ */ new Set([outputDir, dirname3(prefix)])) {
|
|
@@ -2135,7 +2221,7 @@ function createRenderWorkDir(prefix, outputDir) {
|
|
|
2135
2221
|
|
|
2136
2222
|
// src/services/render/artifactTransaction.ts
|
|
2137
2223
|
var defaultFileSystem = {
|
|
2138
|
-
existsSync:
|
|
2224
|
+
existsSync: existsSync6,
|
|
2139
2225
|
renameSync: (source, destination) => renameWithRetry(source, destination),
|
|
2140
2226
|
rmSync: rmSync3
|
|
2141
2227
|
};
|
|
@@ -2168,8 +2254,8 @@ function buildArtifactExpectation(input) {
|
|
|
2168
2254
|
function createSiblingTransactionDirectory(destination) {
|
|
2169
2255
|
const parent = dirname4(destination);
|
|
2170
2256
|
const extension = extname2(destination);
|
|
2171
|
-
const stem = extension ?
|
|
2172
|
-
return createOwnedRenderDir(
|
|
2257
|
+
const stem = extension ? basename5(destination, extension) : basename5(destination);
|
|
2258
|
+
return createOwnedRenderDir(join6(parent, `.${stem}.hf-transaction-`));
|
|
2173
2259
|
}
|
|
2174
2260
|
function assertReadableNonEmptyFile(path) {
|
|
2175
2261
|
const fd = openSync2(path, "r");
|
|
@@ -2187,7 +2273,7 @@ function collectDirectoryFiles(root) {
|
|
|
2187
2273
|
const files = [];
|
|
2188
2274
|
const visit = (directory) => {
|
|
2189
2275
|
for (const entry of readdirSync2(directory, { withFileTypes: true })) {
|
|
2190
|
-
const path =
|
|
2276
|
+
const path = join6(directory, entry.name);
|
|
2191
2277
|
if (entry.isDirectory()) visit(path);
|
|
2192
2278
|
else if (entry.isFile()) files.push(path);
|
|
2193
2279
|
}
|
|
@@ -2242,10 +2328,10 @@ var ArtifactTransaction = class {
|
|
|
2242
2328
|
this.kind = kind;
|
|
2243
2329
|
this.fileSystem = fileSystem;
|
|
2244
2330
|
this.logger = logger;
|
|
2245
|
-
this.destinationPath =
|
|
2331
|
+
this.destinationPath = resolve5(destinationPath);
|
|
2246
2332
|
this.transactionDirectory = createSiblingTransactionDirectory(this.destinationPath);
|
|
2247
|
-
this.stagingPath =
|
|
2248
|
-
this.backupPath =
|
|
2333
|
+
this.stagingPath = join6(this.transactionDirectory, basename5(this.destinationPath));
|
|
2334
|
+
this.backupPath = join6(this.transactionDirectory, TRANSACTION_BACKUP);
|
|
2249
2335
|
this.durationProbe = durationProbe;
|
|
2250
2336
|
}
|
|
2251
2337
|
kind;
|
|
@@ -2288,19 +2374,19 @@ var ArtifactTransaction = class {
|
|
|
2288
2374
|
*/
|
|
2289
2375
|
async assertDirectoryExpectation(expected, files) {
|
|
2290
2376
|
for (const required of expected.requiredFiles ?? []) {
|
|
2291
|
-
const path =
|
|
2292
|
-
if (!
|
|
2377
|
+
const path = join6(this.stagingPath, required);
|
|
2378
|
+
if (!existsSync6(path)) {
|
|
2293
2379
|
throw new Error(`Render artifact directory is missing ${required}: ${this.stagingPath}`);
|
|
2294
2380
|
}
|
|
2295
2381
|
assertReadableNonEmptyFile(path);
|
|
2296
2382
|
}
|
|
2297
2383
|
if (expected.probeTarget !== void 0) {
|
|
2298
|
-
await this.assertArtifactDuration(expected,
|
|
2384
|
+
await this.assertArtifactDuration(expected, join6(this.stagingPath, expected.probeTarget));
|
|
2299
2385
|
return;
|
|
2300
2386
|
}
|
|
2301
2387
|
if (expected.expectedFrames === void 0) return;
|
|
2302
2388
|
const frameCount = files.filter(
|
|
2303
|
-
(file) => dirname4(file) === this.stagingPath && /^frame_\d+\.png$/.test(
|
|
2389
|
+
(file) => dirname4(file) === this.stagingPath && /^frame_\d+\.png$/.test(basename5(file))
|
|
2304
2390
|
).length;
|
|
2305
2391
|
if (frameCount === 0) {
|
|
2306
2392
|
throw new Error(
|
|
@@ -2538,8 +2624,8 @@ function replanAfterFailure(plan, failure) {
|
|
|
2538
2624
|
}
|
|
2539
2625
|
|
|
2540
2626
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
2541
|
-
import { existsSync as
|
|
2542
|
-
import { join as
|
|
2627
|
+
import { existsSync as existsSync7, mkdirSync as mkdirSync3, rmSync as rmSync6, statSync as statSync4 } from "node:fs";
|
|
2628
|
+
import { join as join10 } from "node:path";
|
|
2543
2629
|
import {
|
|
2544
2630
|
captureFrameToBuffer as captureFrameToBuffer2,
|
|
2545
2631
|
closeCaptureSession as closeCaptureSession2,
|
|
@@ -2960,7 +3046,7 @@ import {
|
|
|
2960
3046
|
|
|
2961
3047
|
// src/services/hdrCompositor.ts
|
|
2962
3048
|
import { readSync as readSync2 } from "fs";
|
|
2963
|
-
import { join as
|
|
3049
|
+
import { join as join7 } from "path";
|
|
2964
3050
|
import {
|
|
2965
3051
|
captureAlphaPng,
|
|
2966
3052
|
applyDomLayerMask,
|
|
@@ -3400,7 +3486,7 @@ async function compositeHdrFrame(ctx, canvas, time, fullStacking, elementFilter,
|
|
|
3400
3486
|
if (shouldLog && debugDumpDir) {
|
|
3401
3487
|
const after = countNonZeroRgb48(canvas);
|
|
3402
3488
|
const dumpName = `frame_${String(debugFrameIndex).padStart(4, "0")}_layer_${String(layerIdx).padStart(2, "0")}_dom.png`;
|
|
3403
|
-
const dumpPath =
|
|
3489
|
+
const dumpPath = join7(debugDumpDir, dumpName);
|
|
3404
3490
|
writeFileExclusiveSync(dumpPath, domPng);
|
|
3405
3491
|
log.info("[diag] dom layer blit", {
|
|
3406
3492
|
frame: debugFrameIndex,
|
|
@@ -3455,7 +3541,7 @@ import { fpsToFfmpegArg, fpsToNumber as fpsToNumber3 } from "@hyperframes/core";
|
|
|
3455
3541
|
|
|
3456
3542
|
// src/services/hdrFrameWindows.ts
|
|
3457
3543
|
import { closeSync as closeSync3, constants as constants2, openSync as openSync3, rmSync as rmSync4 } from "node:fs";
|
|
3458
|
-
import { join as
|
|
3544
|
+
import { join as join8 } from "node:path";
|
|
3459
3545
|
function createHdrFrameWindows(opts) {
|
|
3460
3546
|
const { dir, frameSize, windowFrames, maxResident, extract } = opts;
|
|
3461
3547
|
let totalFrames = opts.totalFrames;
|
|
@@ -3479,7 +3565,7 @@ function createHdrFrameWindows(opts) {
|
|
|
3479
3565
|
const firstFrame = index * windowFrames;
|
|
3480
3566
|
const w = {
|
|
3481
3567
|
firstFrame,
|
|
3482
|
-
path:
|
|
3568
|
+
path: join8(dir, `window-${index}.rgb48le`),
|
|
3483
3569
|
frames: 0,
|
|
3484
3570
|
fd: -1,
|
|
3485
3571
|
pins: 0,
|
|
@@ -4279,8 +4365,8 @@ function isTargetLossError(error) {
|
|
|
4279
4365
|
|
|
4280
4366
|
// src/services/render/stages/captureStreamingStage.ts
|
|
4281
4367
|
import { mkdtemp, writeFile } from "node:fs/promises";
|
|
4282
|
-
import { tmpdir } from "node:os";
|
|
4283
|
-
import { join as
|
|
4368
|
+
import { tmpdir as tmpdir2 } from "node:os";
|
|
4369
|
+
import { join as join9 } from "node:path";
|
|
4284
4370
|
import {
|
|
4285
4371
|
DrawElementVerificationError,
|
|
4286
4372
|
captureFrameToBuffer,
|
|
@@ -4374,7 +4460,7 @@ var SequentialCaptureStallError = class extends Error {
|
|
|
4374
4460
|
}
|
|
4375
4461
|
};
|
|
4376
4462
|
function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
4377
|
-
return new Promise((
|
|
4463
|
+
return new Promise((resolve12, reject) => {
|
|
4378
4464
|
const clock = createStallClock();
|
|
4379
4465
|
const trip = () => reject(
|
|
4380
4466
|
signal?.aborted ? new Error(
|
|
@@ -4399,7 +4485,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
|
4399
4485
|
promise.then(
|
|
4400
4486
|
(value) => {
|
|
4401
4487
|
clearTimeout(timer);
|
|
4402
|
-
|
|
4488
|
+
resolve12(value);
|
|
4403
4489
|
},
|
|
4404
4490
|
(error) => {
|
|
4405
4491
|
clearTimeout(timer);
|
|
@@ -4503,11 +4589,11 @@ async function verifyDrawElementSample(session, idx, buf, ctx) {
|
|
|
4503
4589
|
return;
|
|
4504
4590
|
}
|
|
4505
4591
|
if (db < verifyMinDb) {
|
|
4506
|
-
const dumpDir = await mkdtemp(
|
|
4592
|
+
const dumpDir = await mkdtemp(join9(tmpdir2(), "hf-de-verify-fail-")).catch(() => null);
|
|
4507
4593
|
if (dumpDir) {
|
|
4508
4594
|
await Promise.all([
|
|
4509
|
-
writeFile(
|
|
4510
|
-
writeFile(
|
|
4595
|
+
writeFile(join9(dumpDir, `frame-${idx}-de.jpg`), buf),
|
|
4596
|
+
writeFile(join9(dumpDir, `frame-${idx}-truth.jpg`), truth)
|
|
4511
4597
|
]).catch(() => {
|
|
4512
4598
|
});
|
|
4513
4599
|
}
|
|
@@ -5078,7 +5164,7 @@ async function runCaptureStreamingStage(input) {
|
|
|
5078
5164
|
|
|
5079
5165
|
// src/services/render/stages/captureSegmentedStage.ts
|
|
5080
5166
|
function segmentOutputPath(segmentDir, index) {
|
|
5081
|
-
return
|
|
5167
|
+
return join10(segmentDir, `segment_${String(index).padStart(5, "0")}.mp4`);
|
|
5082
5168
|
}
|
|
5083
5169
|
function segmentEncoderOptions(base, segment) {
|
|
5084
5170
|
return {
|
|
@@ -5177,7 +5263,7 @@ async function captureSegmentToEncoder(ctx, segment) {
|
|
|
5177
5263
|
path: segmentPath,
|
|
5178
5264
|
// Recorded so resume can prove the file on disk is the one that
|
|
5179
5265
|
// finished; absent only in unit tests, whose fake encoder writes none.
|
|
5180
|
-
bytes:
|
|
5266
|
+
bytes: existsSync7(segmentPath) ? statSync4(segmentPath).size : 0
|
|
5181
5267
|
});
|
|
5182
5268
|
return encodeResult;
|
|
5183
5269
|
} finally {
|
|
@@ -5411,7 +5497,7 @@ async function runCaptureSegmentedStage(input) {
|
|
|
5411
5497
|
const { log, dedupPerfs, assertNotAborted } = input;
|
|
5412
5498
|
const deps = { ...DEFAULT_DEPS, ...input.deps };
|
|
5413
5499
|
const segments = planSegments(input.totalFrames, input.segmentFrames);
|
|
5414
|
-
const segmentDir = input.segmentDir ??
|
|
5500
|
+
const segmentDir = input.segmentDir ?? join10(input.workDir, "segments");
|
|
5415
5501
|
mkdirSync3(segmentDir, { recursive: true });
|
|
5416
5502
|
const skip = input.completedSegments ?? /* @__PURE__ */ new Set();
|
|
5417
5503
|
const pending = segments.filter((s) => !skip.has(s.index));
|
|
@@ -5567,7 +5653,7 @@ function startRenderEtaGuard(options) {
|
|
|
5567
5653
|
}
|
|
5568
5654
|
|
|
5569
5655
|
// src/services/render/captureCost.ts
|
|
5570
|
-
import { join as
|
|
5656
|
+
import { join as join11 } from "node:path";
|
|
5571
5657
|
import { fpsToNumber as fpsToNumber4 } from "@hyperframes/core";
|
|
5572
5658
|
import {
|
|
5573
5659
|
calculateOptimalWorkers,
|
|
@@ -5820,7 +5906,7 @@ async function runCaptureCalibration(input) {
|
|
|
5820
5906
|
});
|
|
5821
5907
|
let calibration;
|
|
5822
5908
|
try {
|
|
5823
|
-
calibration = await runOneCalibration(
|
|
5909
|
+
calibration = await runOneCalibration(join11(workDir, "capture-calibration"), calibrationCfg);
|
|
5824
5910
|
} catch (error) {
|
|
5825
5911
|
const shouldFallback = !forceScreenshot && shouldFallbackToScreenshotAfterCalibrationError(error);
|
|
5826
5912
|
if (!shouldFallback) {
|
|
@@ -5854,7 +5940,7 @@ async function runCaptureCalibration(input) {
|
|
|
5854
5940
|
const screenshotCfg = createCaptureCalibrationConfig({ ...cfg, forceScreenshot: true });
|
|
5855
5941
|
try {
|
|
5856
5942
|
calibration = await runOneCalibration(
|
|
5857
|
-
|
|
5943
|
+
join11(workDir, "capture-calibration-screenshot"),
|
|
5858
5944
|
screenshotCfg
|
|
5859
5945
|
);
|
|
5860
5946
|
} catch (fallbackError) {
|
|
@@ -5919,7 +6005,7 @@ function checkPageNeverReady(input) {
|
|
|
5919
6005
|
|
|
5920
6006
|
// src/services/render/deferredVideoFrames.ts
|
|
5921
6007
|
import { mkdirSync as mkdirSync4, rmSync as rmSync7 } from "node:fs";
|
|
5922
|
-
import { dirname as dirname5, join as
|
|
6008
|
+
import { dirname as dirname5, join as join12 } from "node:path";
|
|
5923
6009
|
import {
|
|
5924
6010
|
createFrameLookupTable,
|
|
5925
6011
|
extractVideoFramesRange,
|
|
@@ -5964,7 +6050,7 @@ async function extractDeferredFrames(input) {
|
|
|
5964
6050
|
const shown = shownDeferredFrameIndexes(input, input.frames, input.fps);
|
|
5965
6051
|
return Promise.all(
|
|
5966
6052
|
deferred.map(async (video) => {
|
|
5967
|
-
const outputDir =
|
|
6053
|
+
const outputDir = join12(input.outputRoot, mediaIdPathSegment2(video.videoId));
|
|
5968
6054
|
const indexes = [...shown.get(video.videoId) ?? []].sort((a, b) => a - b);
|
|
5969
6055
|
if (indexes.length === 0) {
|
|
5970
6056
|
return { ...video, outputDir, framePaths: /* @__PURE__ */ new Map(), ownedByLookup: false };
|
|
@@ -6112,13 +6198,13 @@ async function measureLocalShownBoxes(page, videos, fps, duration, log) {
|
|
|
6112
6198
|
|
|
6113
6199
|
// src/services/render/segmentVideoFrames.ts
|
|
6114
6200
|
import { mkdirSync as mkdirSync5, rmSync as rmSync8 } from "node:fs";
|
|
6115
|
-
import { join as
|
|
6201
|
+
import { join as join13 } from "node:path";
|
|
6116
6202
|
import {
|
|
6117
6203
|
createFrameLookupTable as createFrameLookupTable2,
|
|
6118
6204
|
createVideoFrameInjector
|
|
6119
6205
|
} from "@hyperframes/engine";
|
|
6120
6206
|
function segmentFramesDir(rootDir, index) {
|
|
6121
|
-
return
|
|
6207
|
+
return join13(rootDir, "segment-frames", `segment_${String(index).padStart(5, "0")}`);
|
|
6122
6208
|
}
|
|
6123
6209
|
function createSegmentVideoFrames(input) {
|
|
6124
6210
|
const extractFrames = input.extractFrames ?? extractDeferredFrames;
|
|
@@ -6149,7 +6235,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6149
6235
|
let onDemandCalls = 0;
|
|
6150
6236
|
const onDemandHook = () => Object.assign(
|
|
6151
6237
|
async (page, time, heldVideoTime) => {
|
|
6152
|
-
const dir =
|
|
6238
|
+
const dir = join13(
|
|
6153
6239
|
input.rootDir,
|
|
6154
6240
|
"segment-frames",
|
|
6155
6241
|
`on-demand_${String(onDemandCalls++).padStart(5, "0")}`
|
|
@@ -6166,7 +6252,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6166
6252
|
);
|
|
6167
6253
|
return {
|
|
6168
6254
|
async forFrames(frames, name) {
|
|
6169
|
-
const dir =
|
|
6255
|
+
const dir = join13(input.rootDir, "segment-frames", name);
|
|
6170
6256
|
const release = () => rmSync8(dir, { recursive: true, force: true });
|
|
6171
6257
|
try {
|
|
6172
6258
|
release();
|
|
@@ -6219,7 +6305,7 @@ function createSegmentVideoFrames(input) {
|
|
|
6219
6305
|
|
|
6220
6306
|
// src/services/render/videoFrameWindow.ts
|
|
6221
6307
|
import { readdirSync as readdirSync3, statSync as statSync5 } from "node:fs";
|
|
6222
|
-
import { join as
|
|
6308
|
+
import { join as join14 } from "node:path";
|
|
6223
6309
|
function shouldWindowVideoFrames(args) {
|
|
6224
6310
|
return args.segmented && args.env.HF_VIDEO_FRAME_WINDOW?.trim().toLowerCase() === "true";
|
|
6225
6311
|
}
|
|
@@ -6232,7 +6318,7 @@ function directoryBytes(path) {
|
|
|
6232
6318
|
return 0;
|
|
6233
6319
|
}
|
|
6234
6320
|
for (const entry of entries) {
|
|
6235
|
-
const child2 =
|
|
6321
|
+
const child2 = join14(path, entry.name);
|
|
6236
6322
|
try {
|
|
6237
6323
|
bytes += entry.isDirectory() ? directoryBytes(child2) : statSync5(child2).size;
|
|
6238
6324
|
} catch {
|
|
@@ -6250,7 +6336,7 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6250
6336
|
...worker,
|
|
6251
6337
|
async prepare(segment) {
|
|
6252
6338
|
await worker.prepare(segment);
|
|
6253
|
-
const held = directoryBytes(
|
|
6339
|
+
const held = directoryBytes(join14(rootDir, "segment-frames"));
|
|
6254
6340
|
if (held > peak) {
|
|
6255
6341
|
peak = held;
|
|
6256
6342
|
onPeak(peak);
|
|
@@ -6263,8 +6349,8 @@ function trackSegmentFramePeak(frames, rootDir, onPeak) {
|
|
|
6263
6349
|
|
|
6264
6350
|
// src/services/render/segmentManifest.ts
|
|
6265
6351
|
import { createHash as createHash2 } from "node:crypto";
|
|
6266
|
-
import { existsSync as
|
|
6267
|
-
import { join as
|
|
6352
|
+
import { existsSync as existsSync8, mkdirSync as mkdirSync6, readFileSync as readFileSync4, statSync as statSync6, writeFileSync as writeFileSync3 } from "node:fs";
|
|
6353
|
+
import { join as join15 } from "node:path";
|
|
6268
6354
|
import { renameWithRetry as renameWithRetry2 } from "@hyperframes/engine";
|
|
6269
6355
|
var MANIFEST_FILENAME = "segments.json";
|
|
6270
6356
|
function computeSegmentPlanHash(input) {
|
|
@@ -6292,7 +6378,7 @@ function computeSegmentPlanHash(input) {
|
|
|
6292
6378
|
return createHash2("sha256").update(ordered.join(" ")).digest("hex").slice(0, 16);
|
|
6293
6379
|
}
|
|
6294
6380
|
function segmentDirFor(projectRendersDir, planHash) {
|
|
6295
|
-
return
|
|
6381
|
+
return join15(projectRendersDir, ".hf-segments", planHash);
|
|
6296
6382
|
}
|
|
6297
6383
|
function hasNumber(value, key) {
|
|
6298
6384
|
return key in value && typeof Reflect.get(value, key) === "number";
|
|
@@ -6310,8 +6396,8 @@ function isManifest(value) {
|
|
|
6310
6396
|
return Reflect.get(value, "version") === 1 && hasString(value, "planHash") && hasNumber(value, "totalFrames") && hasNumber(value, "segmentFrames") && Array.isArray(completed) && completed.every(isEntry);
|
|
6311
6397
|
}
|
|
6312
6398
|
function readSegmentManifest(segmentDir) {
|
|
6313
|
-
const path =
|
|
6314
|
-
if (!
|
|
6399
|
+
const path = join15(segmentDir, MANIFEST_FILENAME);
|
|
6400
|
+
if (!existsSync8(path)) return null;
|
|
6315
6401
|
try {
|
|
6316
6402
|
const parsed = JSON.parse(readFileSync4(path, "utf-8"));
|
|
6317
6403
|
return isManifest(parsed) ? parsed : null;
|
|
@@ -6321,9 +6407,9 @@ function readSegmentManifest(segmentDir) {
|
|
|
6321
6407
|
}
|
|
6322
6408
|
function writeSegmentManifest(segmentDir, manifest) {
|
|
6323
6409
|
mkdirSync6(segmentDir, { recursive: true });
|
|
6324
|
-
const tmp =
|
|
6410
|
+
const tmp = join15(segmentDir, `${MANIFEST_FILENAME}.${process.pid}.tmp`);
|
|
6325
6411
|
writeFileSync3(tmp, JSON.stringify(manifest, null, 2), "utf-8");
|
|
6326
|
-
renameWithRetry2(tmp,
|
|
6412
|
+
renameWithRetry2(tmp, join15(segmentDir, MANIFEST_FILENAME));
|
|
6327
6413
|
}
|
|
6328
6414
|
async function probeSegmentFrameCount(path, probe) {
|
|
6329
6415
|
try {
|
|
@@ -6340,7 +6426,7 @@ async function validateCompletedSegments(manifest, expectedHash, probeFrames) {
|
|
|
6340
6426
|
const ok = /* @__PURE__ */ new Set();
|
|
6341
6427
|
if (manifest.planHash !== expectedHash) return ok;
|
|
6342
6428
|
for (const entry of manifest.completed) {
|
|
6343
|
-
if (!
|
|
6429
|
+
if (!existsSync8(entry.path)) continue;
|
|
6344
6430
|
const size = statSync6(entry.path).size;
|
|
6345
6431
|
if (size <= 0 || size !== entry.bytes) continue;
|
|
6346
6432
|
const frames = await probeFrames(entry.path);
|
|
@@ -6929,8 +7015,8 @@ function countAuthoredTimedClips(html) {
|
|
|
6929
7015
|
}
|
|
6930
7016
|
|
|
6931
7017
|
// src/services/render/stages/compileStage.ts
|
|
6932
|
-
import { existsSync as
|
|
6933
|
-
import { join as
|
|
7018
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7019
|
+
import { join as join21, relative as relative4 } from "node:path";
|
|
6934
7020
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
6935
7021
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
6936
7022
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -6960,6 +7046,8 @@ var fileTooLarge = (file, bytes) => new CompositionTooLargeError(
|
|
|
6960
7046
|
{ bytes, limitBytes: MAX_COMPOSITION_HTML_BYTES }
|
|
6961
7047
|
);
|
|
6962
7048
|
var limitText = `One render generates at most ${megabytes(MAX_EXPANDED_COMPOSITION_BYTES)}`;
|
|
7049
|
+
var REMOTE_SCRIPTS = "remote scripts";
|
|
7050
|
+
var REMOTE_STYLESHEETS = "remote stylesheets";
|
|
6963
7051
|
function generatedTooLarge(file, bytes) {
|
|
6964
7052
|
if (file === "composition variables") {
|
|
6965
7053
|
return `Composition variable styles add up to ${megabytes(bytes)}. ${limitText}. Shorten the variable values or declare them on fewer elements.`;
|
|
@@ -6967,6 +7055,9 @@ function generatedTooLarge(file, bytes) {
|
|
|
6967
7055
|
if (file === "variable media sources") {
|
|
6968
7056
|
return `Variable-bound media sources add up to ${megabytes(bytes)}. ${limitText}. Use shorter URLs or bind fewer elements.`;
|
|
6969
7057
|
}
|
|
7058
|
+
if (file === REMOTE_SCRIPTS || file === REMOTE_STYLESHEETS) {
|
|
7059
|
+
return `Inlined ${file} add up to ${megabytes(bytes)}. ${limitText}. Bundle scripts and fonts with the project, or link each one once.`;
|
|
7060
|
+
}
|
|
6970
7061
|
return `Scripts, styles and rebased asset paths generated for compositions, ending at "${file}", add up to ${megabytes(bytes)}. One render generates at most ${megabytes(MAX_EXPANDED_COMPOSITION_BYTES)} for its mounts. Merge small inline scripts and style rules, keep data-composition-id values short, or mount scenes fewer times.`;
|
|
6971
7062
|
}
|
|
6972
7063
|
var CompositionExpansionBudget = class {
|
|
@@ -7033,20 +7124,20 @@ import {
|
|
|
7033
7124
|
stylesheetLinkMatches
|
|
7034
7125
|
} from "@hyperframes/parsers/css-url-scans";
|
|
7035
7126
|
import { createHash as createHash6 } from "node:crypto";
|
|
7036
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
7037
|
-
import { join as
|
|
7127
|
+
import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
7128
|
+
import { join as join20, dirname as dirname9, resolve as resolve8, basename as basename6, relative as relative3, sep as sep4 } from "path";
|
|
7038
7129
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
7039
7130
|
|
|
7040
7131
|
// src/services/bundledScripts.ts
|
|
7041
|
-
import { existsSync as
|
|
7042
|
-
import { join as
|
|
7132
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
7133
|
+
import { join as join16 } from "node:path";
|
|
7043
7134
|
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
7044
7135
|
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
7045
7136
|
function bundledScript(url) {
|
|
7046
7137
|
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
7047
7138
|
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
7048
|
-
const file =
|
|
7049
|
-
return
|
|
7139
|
+
const file = join16(dir, "gsap.min.js");
|
|
7140
|
+
return existsSync9(file) ? readFileSync5(file) : null;
|
|
7050
7141
|
}
|
|
7051
7142
|
|
|
7052
7143
|
// src/services/htmlCompiler.ts
|
|
@@ -7279,6 +7370,7 @@ function placeAudio(audio, window2) {
|
|
|
7279
7370
|
import {
|
|
7280
7371
|
analyzeKeyframeIntervals,
|
|
7281
7372
|
assertMediaPayload,
|
|
7373
|
+
createConcurrencyLimit,
|
|
7282
7374
|
isPrivateUnderAssetRoots as isPrivateUnderAssetRoots3,
|
|
7283
7375
|
NotMediaPayloadError as NotMediaPayloadError2,
|
|
7284
7376
|
parseMasterFxChain,
|
|
@@ -7303,8 +7395,8 @@ import {
|
|
|
7303
7395
|
|
|
7304
7396
|
// src/services/animatedGifPrep.ts
|
|
7305
7397
|
import { createHash as createHash4 } from "node:crypto";
|
|
7306
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
7307
|
-
import { dirname as dirname6, isAbsolute as
|
|
7398
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync8 } from "node:fs";
|
|
7399
|
+
import { dirname as dirname6, isAbsolute as isAbsolute3, join as join17, resolve as resolve6 } from "node:path";
|
|
7308
7400
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
7309
7401
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
7310
7402
|
import {
|
|
@@ -7349,16 +7441,16 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
7349
7441
|
const { basePath } = splitUrlSuffix(trimmed);
|
|
7350
7442
|
const normalizedBase = normalizeRelPath(basePath);
|
|
7351
7443
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
7352
|
-
if (mapped &&
|
|
7444
|
+
if (mapped && existsSync10(mapped)) return mapped;
|
|
7353
7445
|
if (isHttpUrl(trimmed)) return null;
|
|
7354
7446
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
7355
7447
|
const candidates = [
|
|
7356
|
-
|
|
7357
|
-
|
|
7448
|
+
isAbsolute3(basePath) ? basePath : resolve6(options.projectDir, projectRelative),
|
|
7449
|
+
resolve6(options.downloadDir, normalizedBase)
|
|
7358
7450
|
];
|
|
7359
7451
|
const assetRoot = options.allowOutsideFiles ? void 0 : options.projectDir;
|
|
7360
7452
|
const allowed = (candidate) => !namesAnotherNetworkRoot(options.projectDir, candidate) && !isPrivateUnderAssetRoots(candidate, [options.projectDir, options.downloadDir]) && (!escapesAssetRoot(candidate, assetRoot) && outsideAssetRefusal(options.projectDir, candidate) !== "blocklisted" || !escapesAssetRoot(candidate, options.downloadDir));
|
|
7361
|
-
return candidates.find((candidate) => allowed(candidate) &&
|
|
7453
|
+
return candidates.find((candidate) => allowed(candidate) && existsSync10(candidate)) ?? null;
|
|
7362
7454
|
}
|
|
7363
7455
|
function isUsableFile(path) {
|
|
7364
7456
|
try {
|
|
@@ -7470,10 +7562,10 @@ async function runAnimatedGifTranscode(request) {
|
|
|
7470
7562
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
7471
7563
|
}
|
|
7472
7564
|
async function ensurePreparedWebm(input) {
|
|
7473
|
-
if (!
|
|
7565
|
+
if (!existsSync10(dirname6(input.cachePath))) {
|
|
7474
7566
|
mkdirSync7(dirname6(input.cachePath), { recursive: true });
|
|
7475
7567
|
}
|
|
7476
|
-
if (!
|
|
7568
|
+
if (!existsSync10(dirname6(input.outputPath))) {
|
|
7477
7569
|
mkdirSync7(dirname6(input.outputPath), { recursive: true });
|
|
7478
7570
|
}
|
|
7479
7571
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -7505,7 +7597,7 @@ async function ensurePreparedWebm(input) {
|
|
|
7505
7597
|
throw error;
|
|
7506
7598
|
}
|
|
7507
7599
|
}
|
|
7508
|
-
if (
|
|
7600
|
+
if (resolve6(input.outputPath) !== resolve6(input.cachePath) && !isUsableFile(input.outputPath)) {
|
|
7509
7601
|
copyFileSync2(input.cachePath, input.outputPath);
|
|
7510
7602
|
}
|
|
7511
7603
|
}
|
|
@@ -7557,7 +7649,7 @@ function replaceImageWithVideo(input) {
|
|
|
7557
7649
|
return video;
|
|
7558
7650
|
}
|
|
7559
7651
|
async function prepareAnimatedGifInputs(html, options) {
|
|
7560
|
-
const outputDir = options.outputDir ??
|
|
7652
|
+
const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_GIF_SUBDIR);
|
|
7561
7653
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
|
|
7562
7654
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7563
7655
|
const { document: document2 } = parseHTML3(html);
|
|
@@ -7584,8 +7676,8 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
7584
7676
|
);
|
|
7585
7677
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
7586
7678
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
7587
|
-
const cachePath =
|
|
7588
|
-
const outputPath =
|
|
7679
|
+
const cachePath = join17(cacheDir, filename);
|
|
7680
|
+
const outputPath = join17(outputDir, filename);
|
|
7589
7681
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7590
7682
|
await ensurePreparedWebm({
|
|
7591
7683
|
sourcePath,
|
|
@@ -7630,7 +7722,7 @@ import {
|
|
|
7630
7722
|
statSync as statSync9,
|
|
7631
7723
|
writeFileSync as writeFileSync4
|
|
7632
7724
|
} from "node:fs";
|
|
7633
|
-
import { dirname as dirname7, join as
|
|
7725
|
+
import { dirname as dirname7, join as join18, resolve as resolve7 } from "node:path";
|
|
7634
7726
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
7635
7727
|
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe, urlInputArgs as urlInputArgs3 } from "@hyperframes/engine";
|
|
7636
7728
|
|
|
@@ -7699,10 +7791,10 @@ var Semaphore = class {
|
|
|
7699
7791
|
this.active++;
|
|
7700
7792
|
return () => this.release();
|
|
7701
7793
|
}
|
|
7702
|
-
return new Promise((
|
|
7794
|
+
return new Promise((resolve12) => {
|
|
7703
7795
|
this.queue.push(() => {
|
|
7704
7796
|
this.active++;
|
|
7705
|
-
|
|
7797
|
+
resolve12(() => this.release());
|
|
7706
7798
|
});
|
|
7707
7799
|
});
|
|
7708
7800
|
}
|
|
@@ -7900,12 +7992,12 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
7900
7992
|
rmSync10(inlinePath, { force: true });
|
|
7901
7993
|
}
|
|
7902
7994
|
}
|
|
7903
|
-
if (
|
|
7995
|
+
if (resolve7(outputPath) !== resolve7(cachePath) && !isUsableFile2(outputPath)) {
|
|
7904
7996
|
copyFileSync3(cachePath, outputPath);
|
|
7905
7997
|
}
|
|
7906
7998
|
}
|
|
7907
7999
|
async function prepareHeifImageInputs(html, options) {
|
|
7908
|
-
const outputDir = options.outputDir ??
|
|
8000
|
+
const outputDir = options.outputDir ?? join18(options.downloadDir, PREPARED_HEIF_SUBDIR);
|
|
7909
8001
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
|
|
7910
8002
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7911
8003
|
const preparedAssets = /* @__PURE__ */ new Map();
|
|
@@ -7926,7 +8018,7 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7926
8018
|
await Promise.all(
|
|
7927
8019
|
[...unique].map(
|
|
7928
8020
|
([filename, source]) => withMediaProbeSlot(
|
|
7929
|
-
() => ensurePreparedJpeg(source,
|
|
8021
|
+
() => ensurePreparedJpeg(source, join18(cacheDir, filename), join18(outputDir, filename), options)
|
|
7930
8022
|
).catch((error) => {
|
|
7931
8023
|
if (!options.onFailure) throw error;
|
|
7932
8024
|
failed.add(filename);
|
|
@@ -7938,8 +8030,8 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7938
8030
|
if (failed.has(filename)) continue;
|
|
7939
8031
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7940
8032
|
img.setAttribute("src", outputSrc);
|
|
7941
|
-
preparedAssets.set(outputSrc,
|
|
7942
|
-
preparedImages.push({ sourceSrc: src, outputSrc, outputPath:
|
|
8033
|
+
preparedAssets.set(outputSrc, join18(outputDir, filename));
|
|
8034
|
+
preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join18(outputDir, filename) });
|
|
7943
8035
|
}
|
|
7944
8036
|
return { html: document2.toString(), preparedAssets, preparedImages };
|
|
7945
8037
|
}
|
|
@@ -7949,8 +8041,8 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
|
|
|
7949
8041
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
7950
8042
|
|
|
7951
8043
|
// src/services/assetMediaType.ts
|
|
7952
|
-
import { existsSync as
|
|
7953
|
-
import { dirname as dirname8, join as
|
|
8044
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
8045
|
+
import { dirname as dirname8, join as join19 } from "node:path";
|
|
7954
8046
|
import {
|
|
7955
8047
|
fingerprintElementId,
|
|
7956
8048
|
isHttpUrl as isHttpUrl2,
|
|
@@ -8003,11 +8095,11 @@ function assertAssetMediaTypeProfile(expected, profile, elementIdentity) {
|
|
|
8003
8095
|
]);
|
|
8004
8096
|
}
|
|
8005
8097
|
function mediaAssetRoots(projectDir, compiledDir) {
|
|
8006
|
-
return [projectDir, compiledDir,
|
|
8098
|
+
return [projectDir, compiledDir, join19(dirname8(compiledDir), "downloads")];
|
|
8007
8099
|
}
|
|
8008
8100
|
function dropMediaOutsideProject(input) {
|
|
8009
8101
|
const { projectDir, workDir, composition, log } = input;
|
|
8010
|
-
const compiledDir =
|
|
8102
|
+
const compiledDir = join19(workDir, "compiled");
|
|
8011
8103
|
const roots = mediaAssetRoots(projectDir, compiledDir);
|
|
8012
8104
|
const staysInside = ({ id, src }) => {
|
|
8013
8105
|
if (!src || isHttpUrl2(src)) return true;
|
|
@@ -8062,7 +8154,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
8062
8154
|
input.projectDir,
|
|
8063
8155
|
input.compiledDir
|
|
8064
8156
|
);
|
|
8065
|
-
if (!
|
|
8157
|
+
if (!existsSync11(resolvedPath)) continue;
|
|
8066
8158
|
byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
|
|
8067
8159
|
}
|
|
8068
8160
|
const mismatches = [];
|
|
@@ -8153,7 +8245,7 @@ function normalizeCompositionSrcs(html, projectDir) {
|
|
|
8153
8245
|
if (!value.includes("%") && !/^\.?[\\/]/.test(value)) return whole;
|
|
8154
8246
|
const file = resolveCompositionSrc(projectDir, value);
|
|
8155
8247
|
if (file === null) return whole;
|
|
8156
|
-
return `${name}${quote}${
|
|
8248
|
+
return `${name}${quote}${relative3(projectDir, file).split(sep4).join("/")}${quote}`;
|
|
8157
8249
|
});
|
|
8158
8250
|
}
|
|
8159
8251
|
var COMPOSITION_FILE = /\.html?$/i;
|
|
@@ -8358,8 +8450,8 @@ function detectShaderTransitionUsage(html) {
|
|
|
8358
8450
|
async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes, assetRoot) {
|
|
8359
8451
|
let filePath = src;
|
|
8360
8452
|
if (isHttpUrl(src)) {
|
|
8361
|
-
const remoteDir =
|
|
8362
|
-
if (!
|
|
8453
|
+
const remoteDir = join20(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
8454
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8363
8455
|
try {
|
|
8364
8456
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
8365
8457
|
onTelemetry: logRemoteDownloadTelemetry
|
|
@@ -8369,7 +8461,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8369
8461
|
}
|
|
8370
8462
|
} else {
|
|
8371
8463
|
filePath = decodedUrlPath(src);
|
|
8372
|
-
if (!filePath.startsWith("/")) filePath =
|
|
8464
|
+
if (!filePath.startsWith("/")) filePath = join20(baseDir, filePath);
|
|
8373
8465
|
if (escapesAssetRoot(filePath, assetRoot) || isPrivateUnderAssetRoots3(filePath, [projectDir, downloadDir])) {
|
|
8374
8466
|
return { duration: null, resolvedPath: filePath };
|
|
8375
8467
|
}
|
|
@@ -8378,7 +8470,7 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, projectDir, b
|
|
|
8378
8470
|
return { duration: null, resolvedPath: filePath };
|
|
8379
8471
|
}
|
|
8380
8472
|
}
|
|
8381
|
-
if (!isHttpUrl(filePath) && !
|
|
8473
|
+
if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
|
|
8382
8474
|
return { duration: null, resolvedPath: filePath };
|
|
8383
8475
|
}
|
|
8384
8476
|
const withSrcContext = (error) => {
|
|
@@ -8748,7 +8840,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
8748
8840
|
parseHostVariables: parseHostVariableValues,
|
|
8749
8841
|
resolveFilePath: (srcPath) => {
|
|
8750
8842
|
const file = resolveCompositionFile(projectDir, srcPath, assetRoot);
|
|
8751
|
-
return file &&
|
|
8843
|
+
return file && relative3(projectDir, file).split(sep4).join("/");
|
|
8752
8844
|
},
|
|
8753
8845
|
resolveHtml: (srcPath) => {
|
|
8754
8846
|
const compHtml = resolveMountHtml(srcPath);
|
|
@@ -8912,7 +9004,8 @@ async function downloadScript(src, mirror) {
|
|
|
8912
9004
|
}
|
|
8913
9005
|
return fetchPublicHttpsBytes(src, { maxBytes: MAX_SCRIPT_BYTES, timeoutMs: 15e3 });
|
|
8914
9006
|
}
|
|
8915
|
-
|
|
9007
|
+
var MAX_CONCURRENT_SCRIPT_FETCHES = 4;
|
|
9008
|
+
async function inlineExternalScripts(html, budget = new CompositionExpansionBudget()) {
|
|
8916
9009
|
const fullHtml = ensureFullDocument(html);
|
|
8917
9010
|
const wrappedFragment = fullHtml !== html;
|
|
8918
9011
|
const { document: document2 } = parseHTML5(fullHtml);
|
|
@@ -8926,20 +9019,52 @@ async function inlineExternalScripts(html) {
|
|
|
8926
9019
|
}
|
|
8927
9020
|
if (externalScripts.length === 0) return html;
|
|
8928
9021
|
const mirror = operatorGsapMirror();
|
|
9022
|
+
const limit = createConcurrencyLimit(MAX_CONCURRENT_SCRIPT_FETCHES);
|
|
9023
|
+
const stop = new AbortController();
|
|
9024
|
+
const fail = (error) => {
|
|
9025
|
+
stop.abort(error);
|
|
9026
|
+
throw error;
|
|
9027
|
+
};
|
|
9028
|
+
const charge = (bytes) => {
|
|
9029
|
+
try {
|
|
9030
|
+
budget.chargeGenerated(REMOTE_SCRIPTS, bytes);
|
|
9031
|
+
} catch (error) {
|
|
9032
|
+
fail(error);
|
|
9033
|
+
}
|
|
9034
|
+
};
|
|
9035
|
+
const fetches = /* @__PURE__ */ new Map();
|
|
9036
|
+
const fetchOnce = (src) => {
|
|
9037
|
+
let bytes = fetches.get(src);
|
|
9038
|
+
if (!bytes) {
|
|
9039
|
+
bytes = limit(async () => {
|
|
9040
|
+
if (stop.signal.aborted) throw stop.signal.reason;
|
|
9041
|
+
const downloaded = await downloadScript(src, mirror);
|
|
9042
|
+
charge(downloaded.byteLength);
|
|
9043
|
+
return downloaded;
|
|
9044
|
+
}, stop.signal);
|
|
9045
|
+
fetches.set(src, bytes);
|
|
9046
|
+
}
|
|
9047
|
+
return bytes;
|
|
9048
|
+
};
|
|
9049
|
+
const placed = /* @__PURE__ */ new Set();
|
|
8929
9050
|
const downloads = await Promise.allSettled(
|
|
8930
9051
|
externalScripts.map(async ({ el, src }) => {
|
|
8931
9052
|
const integrity = el.getAttribute("integrity") || "";
|
|
8932
|
-
|
|
8933
|
-
if (
|
|
8934
|
-
|
|
8935
|
-
}
|
|
8936
|
-
|
|
8937
|
-
|
|
8938
|
-
|
|
9053
|
+
let bytes = bundledScript(src);
|
|
9054
|
+
if (bytes && matchesScriptIntegrity(bytes, integrity)) {
|
|
9055
|
+
charge(bytes.byteLength);
|
|
9056
|
+
} else {
|
|
9057
|
+
bytes = await fetchOnce(src);
|
|
9058
|
+
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
9059
|
+
fail(new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`));
|
|
9060
|
+
}
|
|
9061
|
+
if (placed.has(src)) charge(bytes.byteLength);
|
|
9062
|
+
placed.add(src);
|
|
8939
9063
|
}
|
|
8940
9064
|
return { src, text: new TextDecoder().decode(bytes) };
|
|
8941
9065
|
})
|
|
8942
9066
|
);
|
|
9067
|
+
if (stop.signal.aborted) throw stop.signal.reason;
|
|
8943
9068
|
for (let i = 0; i < downloads.length; i++) {
|
|
8944
9069
|
const download = downloads[i];
|
|
8945
9070
|
const { el, src } = externalScripts[i];
|
|
@@ -8966,18 +9091,18 @@ ${safeText}
|
|
|
8966
9091
|
return wrappedFragment ? document2.body.innerHTML || "" : document2.toString();
|
|
8967
9092
|
}
|
|
8968
9093
|
function collectExternalAssets(html, projectDir, log = defaultLogger, file = "index.html", policy = {}) {
|
|
8969
|
-
const absProjectDir =
|
|
9094
|
+
const absProjectDir = resolve8(projectDir);
|
|
8970
9095
|
const externalAssets = /* @__PURE__ */ new Map();
|
|
8971
9096
|
const leftOut = /* @__PURE__ */ new Set();
|
|
8972
9097
|
function processPath(rawPath) {
|
|
8973
9098
|
const trimmed = rawPath.trim();
|
|
8974
9099
|
if (isNonRelativeUrl(trimmed)) return null;
|
|
8975
|
-
const absPath =
|
|
9100
|
+
const absPath = resolve8(absProjectDir, trimmed);
|
|
8976
9101
|
if (isPathInside(absPath, absProjectDir)) {
|
|
8977
9102
|
return null;
|
|
8978
9103
|
}
|
|
8979
9104
|
const onShare = namesAnotherNetworkRoot2(absProjectDir, absPath);
|
|
8980
|
-
if (!onShare && !
|
|
9105
|
+
if (!onShare && !existsSync12(absPath)) return null;
|
|
8981
9106
|
const refusal = onShare ? "network_share" : outsideAssetRefusal(absProjectDir, absPath, policy);
|
|
8982
9107
|
if (refusal) {
|
|
8983
9108
|
if (!leftOut.has(trimmed)) log.warn(`[Compiler] ${leftOutOfRender(file, trimmed, refusal)}`);
|
|
@@ -9030,7 +9155,7 @@ function collectExternalAssets(html, projectDir, log = defaultLogger, file = "in
|
|
|
9030
9155
|
var REMOTE_MEDIA_SUBDIR = "_remote_media";
|
|
9031
9156
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
9032
9157
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
9033
|
-
if (!
|
|
9158
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
9034
9159
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
9035
9160
|
await Promise.all(
|
|
9036
9161
|
[...urlSet].map(async (url) => {
|
|
@@ -9053,7 +9178,7 @@ async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLab
|
|
|
9053
9178
|
const remoteMediaAssets = /* @__PURE__ */ new Map();
|
|
9054
9179
|
const urlToRelPath = /* @__PURE__ */ new Map();
|
|
9055
9180
|
for (const [url, absPath] of urlToLocal) {
|
|
9056
|
-
const relPath = `${REMOTE_MEDIA_SUBDIR}/${
|
|
9181
|
+
const relPath = `${REMOTE_MEDIA_SUBDIR}/${basename6(absPath)}`;
|
|
9057
9182
|
remoteMediaAssets.set(relPath, absPath);
|
|
9058
9183
|
urlToRelPath.set(url, relPath);
|
|
9059
9184
|
}
|
|
@@ -9070,7 +9195,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
9070
9195
|
const localized = await downloadAndRewriteUrls(
|
|
9071
9196
|
urlSet,
|
|
9072
9197
|
html,
|
|
9073
|
-
|
|
9198
|
+
join20(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9074
9199
|
"Remote media download failed",
|
|
9075
9200
|
"Localized remote media source(s)"
|
|
9076
9201
|
);
|
|
@@ -9093,7 +9218,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
9093
9218
|
return downloadAndRewriteUrls(
|
|
9094
9219
|
urlSet,
|
|
9095
9220
|
html,
|
|
9096
|
-
|
|
9221
|
+
join20(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9097
9222
|
"Remote image download failed",
|
|
9098
9223
|
"Localized remote image source(s)"
|
|
9099
9224
|
);
|
|
@@ -9106,7 +9231,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
9106
9231
|
return downloadAndRewriteUrls(
|
|
9107
9232
|
urlSet,
|
|
9108
9233
|
html,
|
|
9109
|
-
|
|
9234
|
+
join20(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9110
9235
|
"Remote background-image download failed",
|
|
9111
9236
|
"Localized remote background-image(s)",
|
|
9112
9237
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -9163,48 +9288,50 @@ function matchingBraces(css) {
|
|
|
9163
9288
|
}
|
|
9164
9289
|
return closes;
|
|
9165
9290
|
}
|
|
9166
|
-
|
|
9167
|
-
const
|
|
9168
|
-
|
|
9291
|
+
function remoteFontStylesheetHref(tag) {
|
|
9292
|
+
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
9293
|
+
if (!href || !/^https?:\/\//i.test(href) || isGoogleFontsUrl(href)) return void 0;
|
|
9294
|
+
return href;
|
|
9295
|
+
}
|
|
9296
|
+
async function inlineExternalFontStylesheets(html, budget = new CompositionExpansionBudget()) {
|
|
9297
|
+
const hrefs = /* @__PURE__ */ new Set();
|
|
9169
9298
|
for (const { parts } of stylesheetLinkMatches(html)) {
|
|
9170
|
-
const
|
|
9171
|
-
|
|
9172
|
-
if (!hrefMatch?.[1]) continue;
|
|
9173
|
-
const href = hrefMatch[1];
|
|
9174
|
-
if (!/^https?:\/\//i.test(href)) continue;
|
|
9175
|
-
if (isGoogleFontsUrl(href)) continue;
|
|
9176
|
-
linkMatches.push({ fullMatch: tag, href });
|
|
9177
|
-
}
|
|
9178
|
-
if (linkMatches.length === 0) return html;
|
|
9179
|
-
const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
|
|
9180
|
-
const fetches = [];
|
|
9181
|
-
for (let i = 0; i < linkMatches.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
|
|
9182
|
-
const batch = linkMatches.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
|
|
9183
|
-
const results = await Promise.all(
|
|
9184
|
-
batch.map(async ({ fullMatch, href }) => {
|
|
9185
|
-
const css = await fetchExternalStylesheetCss(href);
|
|
9186
|
-
return { fullMatch, href, css };
|
|
9187
|
-
})
|
|
9188
|
-
);
|
|
9189
|
-
fetches.push(...results);
|
|
9299
|
+
const href = remoteFontStylesheetHref(parts[0]);
|
|
9300
|
+
if (href) hrefs.add(href);
|
|
9190
9301
|
}
|
|
9191
|
-
|
|
9192
|
-
|
|
9193
|
-
|
|
9194
|
-
|
|
9195
|
-
|
|
9196
|
-
const
|
|
9197
|
-
const
|
|
9302
|
+
if (hrefs.size === 0) return html;
|
|
9303
|
+
const MAX_CONCURRENT_STYLESHEET_FETCHES = 4;
|
|
9304
|
+
const inlineByHref = /* @__PURE__ */ new Map();
|
|
9305
|
+
const unique = [...hrefs];
|
|
9306
|
+
for (let i = 0; i < unique.length; i += MAX_CONCURRENT_STYLESHEET_FETCHES) {
|
|
9307
|
+
const batch = unique.slice(i, i + MAX_CONCURRENT_STYLESHEET_FETCHES);
|
|
9308
|
+
const sheets = await Promise.all(batch.map(fetchExternalStylesheetCss));
|
|
9309
|
+
batch.forEach((href, index) => {
|
|
9310
|
+
const css = sheets[index];
|
|
9311
|
+
const fontFaceBlocks = css ? extractFontFaceBlocks(css) : [];
|
|
9312
|
+
if (fontFaceBlocks.length === 0) return;
|
|
9313
|
+
const inlineStyle = `<style>/* Inlined external font stylesheet */
|
|
9198
9314
|
${fontFaceBlocks.join("\n")}
|
|
9199
9315
|
</style>`;
|
|
9200
|
-
|
|
9201
|
-
|
|
9202
|
-
|
|
9203
|
-
|
|
9204
|
-
|
|
9316
|
+
budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
9317
|
+
inlineByHref.set(href, inlineStyle);
|
|
9318
|
+
const identity = safeDownloadUrlIdentity(href);
|
|
9319
|
+
defaultLogger.debug("[Compiler] Inlined external @font-face rule(s)", {
|
|
9320
|
+
count: fontFaceBlocks.length,
|
|
9321
|
+
urlFingerprint: identity.urlFingerprint,
|
|
9322
|
+
host: identity.host
|
|
9323
|
+
});
|
|
9205
9324
|
});
|
|
9206
9325
|
}
|
|
9207
|
-
|
|
9326
|
+
const placed = /* @__PURE__ */ new Set();
|
|
9327
|
+
return replaceMatches(html, stylesheetLinkMatches(html), (tag) => {
|
|
9328
|
+
const href = remoteFontStylesheetHref(tag);
|
|
9329
|
+
const inlineStyle = href ? inlineByHref.get(href) : void 0;
|
|
9330
|
+
if (!href || !inlineStyle) return tag;
|
|
9331
|
+
if (placed.has(href)) budget.chargeGenerated(REMOTE_STYLESHEETS, inlineStyle.length);
|
|
9332
|
+
placed.add(href);
|
|
9333
|
+
return inlineStyle;
|
|
9334
|
+
});
|
|
9208
9335
|
}
|
|
9209
9336
|
function projectStylesheetFontFamilies(html, projectDir) {
|
|
9210
9337
|
const families = [];
|
|
@@ -9213,14 +9340,14 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
9213
9340
|
} of stylesheetLinkMatches(html)) {
|
|
9214
9341
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
9215
9342
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
9216
|
-
const sheet =
|
|
9217
|
-
if (!isPathInside(sheet, projectDir) || !
|
|
9343
|
+
const sheet = resolve8(projectDir, decodedUrlPath(href).replace(/^(?:\.?\/)+/, ""));
|
|
9344
|
+
if (!isPathInside(sheet, projectDir) || !existsSync12(sheet)) continue;
|
|
9218
9345
|
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
9219
9346
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
9220
9347
|
const shipsFile = [...localFontFaceUrlMatches(face)].some(({ parts: [, url = ""] }) => {
|
|
9221
9348
|
const path = decodedUrlPath(url);
|
|
9222
|
-
const file = path.startsWith("/") ?
|
|
9223
|
-
return isPathInside(file, projectDir) &&
|
|
9349
|
+
const file = path.startsWith("/") ? resolve8(projectDir, `.${path}`) : resolve8(dirname9(sheet), path);
|
|
9350
|
+
return isPathInside(file, projectDir) && existsSync12(file);
|
|
9224
9351
|
});
|
|
9225
9352
|
if (family && shipsFile) families.push(family);
|
|
9226
9353
|
}
|
|
@@ -9257,7 +9384,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
9257
9384
|
return downloadAndRewriteUrls(
|
|
9258
9385
|
collectFontFaceUrls(html),
|
|
9259
9386
|
html,
|
|
9260
|
-
|
|
9387
|
+
join20(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
9261
9388
|
"Remote font download failed",
|
|
9262
9389
|
"Localized remote font face(s)",
|
|
9263
9390
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -9278,7 +9405,7 @@ async function readLocalFont(absPath) {
|
|
|
9278
9405
|
return { kind: "inline", buffer: Buffer.concat(chunks, totalBytes) };
|
|
9279
9406
|
}
|
|
9280
9407
|
async function localFontDataUri(localPath, projectDir, assetRoot, dataUriByAbsolutePath, log) {
|
|
9281
|
-
const absPath = localPath.startsWith("/") ? localPath :
|
|
9408
|
+
const absPath = localPath.startsWith("/") ? localPath : resolve8(projectDir, localPath);
|
|
9282
9409
|
if (!isPathInside(absPath, projectDir) || escapesAssetRoot(absPath, assetRoot)) return void 0;
|
|
9283
9410
|
if (refusesOutsideLink(projectDir, absPath, (line) => log.warn(`[Compiler] ${line}`))) {
|
|
9284
9411
|
return void 0;
|
|
@@ -9368,8 +9495,8 @@ function renderGsapDist() {
|
|
|
9368
9495
|
function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
9369
9496
|
let gsapDist;
|
|
9370
9497
|
const exists = (path) => {
|
|
9371
|
-
const file =
|
|
9372
|
-
return !namesAnotherNetworkRoot2(projectDir, file) &&
|
|
9498
|
+
const file = resolve8(projectDir, path);
|
|
9499
|
+
return !namesAnotherNetworkRoot2(projectDir, file) && existsSync12(file);
|
|
9373
9500
|
};
|
|
9374
9501
|
return replaceGsapDistScripts(html, (full, prefix, src, file, suffix) => {
|
|
9375
9502
|
if (/^https?:\/\//i.test(src)) return full;
|
|
@@ -9381,7 +9508,7 @@ function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
|
9381
9508
|
}
|
|
9382
9509
|
function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath, budget) {
|
|
9383
9510
|
if (!isPathInside(htmlPath, projectDir)) return html;
|
|
9384
|
-
const entryPath =
|
|
9511
|
+
const entryPath = relative3(projectDir, htmlPath).replace(/\\/g, "/");
|
|
9385
9512
|
if (!entryPath.includes("/")) return html;
|
|
9386
9513
|
const { document: document2 } = parseHTML5(html);
|
|
9387
9514
|
const assetExists = projectAssetExists(projectDir);
|
|
@@ -9441,7 +9568,7 @@ function bindVariableMediaSources(html, variables, budget, log) {
|
|
|
9441
9568
|
}
|
|
9442
9569
|
return changed ? document2.toString() : html;
|
|
9443
9570
|
}
|
|
9444
|
-
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ?
|
|
9571
|
+
var entryFileName = (projectDir, htmlPath) => isPathInside(htmlPath, projectDir) ? relative3(projectDir, htmlPath).split(sep4).join("/") : basename6(htmlPath);
|
|
9445
9572
|
async function compileForRender(projectDir, htmlPath, downloadDir, options = {}) {
|
|
9446
9573
|
const assetRoot = options.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
9447
9574
|
const outsideFiles = { includeScripts: options.includeOutsideScripts };
|
|
@@ -9454,7 +9581,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9454
9581
|
if (!COMPOSITION_FILE.test(htmlPath)) {
|
|
9455
9582
|
throw new Error(`Entry file ${htmlPath} is not an .html file, so it is refused`);
|
|
9456
9583
|
}
|
|
9457
|
-
assertCompositionFileSize(htmlPath,
|
|
9584
|
+
assertCompositionFileSize(htmlPath, basename6(htmlPath));
|
|
9458
9585
|
const budget = new CompositionExpansionBudget();
|
|
9459
9586
|
const entryHtml = rebaseDirectEntryAssetPaths(
|
|
9460
9587
|
readTextFile(htmlPath),
|
|
@@ -9506,7 +9633,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9506
9633
|
const usesThreeDTransforms = detectThreeDTransformUsage(sanitizedHtml);
|
|
9507
9634
|
const hasAncestorBackgroundImage = detectAncestorBackgroundImage(sanitizedHtml);
|
|
9508
9635
|
const fontSheetHtml = await inlineExternalFontStylesheets(
|
|
9509
|
-
promoteCssImportsToLinkTags(sanitizedHtml)
|
|
9636
|
+
promoteCssImportsToLinkTags(sanitizedHtml),
|
|
9637
|
+
budget
|
|
9510
9638
|
);
|
|
9511
9639
|
const normalizedFontHtml = normalizeSystemFontPrimaryFamilies(
|
|
9512
9640
|
injectTextRenderingRule(coalesceHeadStylesAndBodyScripts(fontSheetHtml))
|
|
@@ -9518,7 +9646,7 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9518
9646
|
projectFontFamilies: projectStylesheetFontFamilies(fontSheetHtml, projectDir),
|
|
9519
9647
|
abortSignal: options.abortSignal
|
|
9520
9648
|
});
|
|
9521
|
-
const assembledHtml = await inlineExternalScripts(coalescedHtml);
|
|
9649
|
+
const assembledHtml = await inlineExternalScripts(coalescedHtml, budget);
|
|
9522
9650
|
const HF_POSITION_ATTRS = [
|
|
9523
9651
|
'data-hf-studio-path-offset="true"',
|
|
9524
9652
|
'data-hf-studio-box-size="true"',
|
|
@@ -9610,8 +9738,8 @@ async function compileForRender(projectDir, htmlPath, downloadDir, options = {})
|
|
|
9610
9738
|
const advised = /* @__PURE__ */ new Set();
|
|
9611
9739
|
for (const video of videos) {
|
|
9612
9740
|
if (isHttpUrl(video.src)) continue;
|
|
9613
|
-
const videoPath =
|
|
9614
|
-
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !
|
|
9741
|
+
const videoPath = resolve8(projectDir, video.src);
|
|
9742
|
+
if (advised.has(videoPath) || namesAnotherNetworkRoot2(projectDir, videoPath) || !existsSync12(videoPath) || escapesAssetRoot(videoPath, assetRoot) || isPrivateUnderAssetRoots3(videoPath, [projectDir, downloadDir]))
|
|
9615
9743
|
continue;
|
|
9616
9744
|
advised.add(videoPath);
|
|
9617
9745
|
const reencode = `ffmpeg -i "${video.src}" -c:v libx264 -r 30 -g 30 -keyint_min 30 -movflags +faststart -c:a copy output.mp4`;
|
|
@@ -10026,7 +10154,7 @@ async function recompileWithResolutions(compiled, resolutions, projectDir, downl
|
|
|
10026
10154
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10027
10155
|
try {
|
|
10028
10156
|
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10029
|
-
return root ?
|
|
10157
|
+
return root ? join21(root, "animated-gif") : void 0;
|
|
10030
10158
|
} catch {
|
|
10031
10159
|
return void 0;
|
|
10032
10160
|
}
|
|
@@ -10048,17 +10176,17 @@ function resolveEntryHtmlPath(input) {
|
|
|
10048
10176
|
const readEntry = (path) => {
|
|
10049
10177
|
if (escapesAssetRoot(path, input.assetRoot)) {
|
|
10050
10178
|
throw new Error(
|
|
10051
|
-
`Entry file "${
|
|
10179
|
+
`Entry file "${relative4(projectDir, path)}" leads outside the project folder`
|
|
10052
10180
|
);
|
|
10053
10181
|
}
|
|
10054
|
-
assertCompositionFileSize(path,
|
|
10182
|
+
assertCompositionFileSize(path, relative4(projectDir, path));
|
|
10055
10183
|
return readTextFile2(path);
|
|
10056
10184
|
};
|
|
10057
|
-
const htmlPath =
|
|
10185
|
+
const htmlPath = join21(projectDir, entryFile);
|
|
10058
10186
|
const rawEntry = readEntry(htmlPath);
|
|
10059
10187
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
10060
|
-
const projectIndexPath =
|
|
10061
|
-
if (!
|
|
10188
|
+
const projectIndexPath = join21(projectDir, "index.html");
|
|
10189
|
+
if (!existsSync13(projectIndexPath)) {
|
|
10062
10190
|
throw new Error(
|
|
10063
10191
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
10064
10192
|
);
|
|
@@ -10073,7 +10201,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
10073
10201
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
10074
10202
|
);
|
|
10075
10203
|
}
|
|
10076
|
-
const wrapperPath =
|
|
10204
|
+
const wrapperPath = join21(workDir, "standalone-entry.html");
|
|
10077
10205
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
10078
10206
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
10079
10207
|
return wrapperPath;
|
|
@@ -10103,7 +10231,7 @@ async function runCompileStage(input) {
|
|
|
10103
10231
|
const assetRoot = job.config.allowOutsideProjectAssets ? void 0 : projectDir;
|
|
10104
10232
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log, assetRoot });
|
|
10105
10233
|
const compileStart = Date.now();
|
|
10106
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
10234
|
+
const compiled = await compileForRender(projectDir, htmlPath, join21(workDir, "downloads"), {
|
|
10107
10235
|
log,
|
|
10108
10236
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
10109
10237
|
allowSystemFontCapture,
|
|
@@ -10178,7 +10306,7 @@ async function runCompileStage(input) {
|
|
|
10178
10306
|
});
|
|
10179
10307
|
await preflightCompositionAssetMediaTypes({
|
|
10180
10308
|
projectDir,
|
|
10181
|
-
compiledDir:
|
|
10309
|
+
compiledDir: join21(workDir, "compiled"),
|
|
10182
10310
|
composition,
|
|
10183
10311
|
signal: abortSignal
|
|
10184
10312
|
});
|
|
@@ -10226,7 +10354,7 @@ async function runCompileStage(input) {
|
|
|
10226
10354
|
|
|
10227
10355
|
// src/services/render/stages/probeStage.ts
|
|
10228
10356
|
import { createHash as createHash7 } from "node:crypto";
|
|
10229
|
-
import { basename as
|
|
10357
|
+
import { basename as basename7, join as join22 } from "node:path";
|
|
10230
10358
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
10231
10359
|
import {
|
|
10232
10360
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -10474,7 +10602,7 @@ function probeRequiresBrowser(args) {
|
|
|
10474
10602
|
function reportedLengthSource(source) {
|
|
10475
10603
|
if (!source) return null;
|
|
10476
10604
|
if (source.from !== "media") return { from: source.from };
|
|
10477
|
-
const name =
|
|
10605
|
+
const name = basename7(source.src.split(/[?#]/, 1)[0] ?? "");
|
|
10478
10606
|
const srcHash = createHash7("sha256").update(name).digest("hex").slice(0, 12);
|
|
10479
10607
|
return { from: "media", tag: source.tag, trimmed: source.trimmed, srcHash };
|
|
10480
10608
|
}
|
|
@@ -10540,7 +10668,7 @@ async function runProbeStage(input) {
|
|
|
10540
10668
|
});
|
|
10541
10669
|
fileServer = await createFileServer({
|
|
10542
10670
|
projectDir,
|
|
10543
|
-
compiledDir:
|
|
10671
|
+
compiledDir: join22(workDir, "compiled"),
|
|
10544
10672
|
port: 0,
|
|
10545
10673
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
10546
10674
|
fps: job.config.fps,
|
|
@@ -10577,7 +10705,7 @@ async function runProbeStage(input) {
|
|
|
10577
10705
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
10578
10706
|
probeSession = await createCaptureSession4(
|
|
10579
10707
|
fileServer.url,
|
|
10580
|
-
|
|
10708
|
+
join22(workDir, "probe"),
|
|
10581
10709
|
captureOpts,
|
|
10582
10710
|
null,
|
|
10583
10711
|
probeCfg
|
|
@@ -10662,7 +10790,7 @@ async function runProbeStage(input) {
|
|
|
10662
10790
|
});
|
|
10663
10791
|
probeSession = await createCaptureSession4(
|
|
10664
10792
|
fileServer.url,
|
|
10665
|
-
|
|
10793
|
+
join22(workDir, "probe-screenshot"),
|
|
10666
10794
|
captureOpts,
|
|
10667
10795
|
null,
|
|
10668
10796
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -10700,7 +10828,7 @@ async function runProbeStage(input) {
|
|
|
10700
10828
|
compiled,
|
|
10701
10829
|
resolutions,
|
|
10702
10830
|
projectDir,
|
|
10703
|
-
|
|
10831
|
+
join22(workDir, "downloads"),
|
|
10704
10832
|
job.config.allowOutsideProjectAssets ? void 0 : projectDir,
|
|
10705
10833
|
{ includeScripts: job.config.includeOutsideScripts }
|
|
10706
10834
|
);
|
|
@@ -10900,7 +11028,7 @@ async function runProbeStage(input) {
|
|
|
10900
11028
|
});
|
|
10901
11029
|
await preflightCompositionAssetMediaTypes({
|
|
10902
11030
|
projectDir,
|
|
10903
|
-
compiledDir:
|
|
11031
|
+
compiledDir: join22(workDir, "compiled"),
|
|
10904
11032
|
composition,
|
|
10905
11033
|
signal: abortSignal
|
|
10906
11034
|
});
|
|
@@ -11035,8 +11163,8 @@ function validateRenderDuration(input) {
|
|
|
11035
11163
|
}
|
|
11036
11164
|
|
|
11037
11165
|
// src/services/render/stages/extractVideosStage.ts
|
|
11038
|
-
import { existsSync as
|
|
11039
|
-
import { join as
|
|
11166
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
11167
|
+
import { join as join23 } from "node:path";
|
|
11040
11168
|
import {
|
|
11041
11169
|
classifyVideoExtractionError,
|
|
11042
11170
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -11395,7 +11523,7 @@ async function runExtractVideosStage(input) {
|
|
|
11395
11523
|
// because short boundary counts can differ by one frame.
|
|
11396
11524
|
{
|
|
11397
11525
|
fps: job.config.fps,
|
|
11398
|
-
outputDir:
|
|
11526
|
+
outputDir: join23(compiledDir, "__hyperframes_video_frames"),
|
|
11399
11527
|
format: job.config.videoFrameFormat ?? "auto",
|
|
11400
11528
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
11401
11529
|
timelineEnd: composition.duration,
|
|
@@ -11403,7 +11531,7 @@ async function runExtractVideosStage(input) {
|
|
|
11403
11531
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
11404
11532
|
deferRangeExtraction,
|
|
11405
11533
|
shownBoxes,
|
|
11406
|
-
contentKeyedDirs: [
|
|
11534
|
+
contentKeyedDirs: [join23(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
11407
11535
|
urlByAbsentLocalPath,
|
|
11408
11536
|
assetRoots,
|
|
11409
11537
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
@@ -11483,7 +11611,7 @@ function isPublicHttpsUrl(url) {
|
|
|
11483
11611
|
}
|
|
11484
11612
|
}
|
|
11485
11613
|
function opensLocally(path, assetRoots) {
|
|
11486
|
-
return
|
|
11614
|
+
return existsSync14(path) && (!assetRoots || assetRootsRefusal(path, assetRoots) === null);
|
|
11487
11615
|
}
|
|
11488
11616
|
function localProbeSource(src, input) {
|
|
11489
11617
|
const path = resolveProjectRelativeSrc4(src, input.projectDir, input.compiledDir);
|
|
@@ -11495,7 +11623,7 @@ async function remoteProbeSource(video, input) {
|
|
|
11495
11623
|
if (!isPublicHttpsUrl(video.src)) return null;
|
|
11496
11624
|
if (!resolveRestrictPageNetwork()) return video.src;
|
|
11497
11625
|
if (!video.hasAudio || video.hidden) return null;
|
|
11498
|
-
const downloadDir = input.downloadDir ??
|
|
11626
|
+
const downloadDir = input.downloadDir ?? join23(input.compiledDir, REMOTE_MEDIA_SUBDIR);
|
|
11499
11627
|
try {
|
|
11500
11628
|
return await downloadToTemp2(video.src, downloadDir, void 0, input.signal, void 0, {
|
|
11501
11629
|
onTelemetry: writeUrlDownloadTelemetry2
|
|
@@ -11536,7 +11664,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
11536
11664
|
}
|
|
11537
11665
|
|
|
11538
11666
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
11539
|
-
import { existsSync as
|
|
11667
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
11540
11668
|
import {
|
|
11541
11669
|
buildVideoLayerInput,
|
|
11542
11670
|
isHttpUrl as isHttpUrl4,
|
|
@@ -11604,7 +11732,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11604
11732
|
const { video } = q;
|
|
11605
11733
|
if (isHttpUrl4(video.src)) return { reason: "remote_source" };
|
|
11606
11734
|
const path = resolveProjectRelativeSrc5(video.src, input.projectDir, input.compiledDir);
|
|
11607
|
-
if (!
|
|
11735
|
+
if (!existsSync15(path)) return { reason: "source_missing" };
|
|
11608
11736
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
11609
11737
|
if ("reason" in layout) return layout;
|
|
11610
11738
|
const layer = await buildVideoLayerInput(
|
|
@@ -11619,8 +11747,8 @@ async function planVideoLayerPassthrough(input) {
|
|
|
11619
11747
|
}
|
|
11620
11748
|
|
|
11621
11749
|
// src/services/render/stages/audioStage.ts
|
|
11622
|
-
import { existsSync as
|
|
11623
|
-
import { join as
|
|
11750
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
11751
|
+
import { join as join26 } from "node:path";
|
|
11624
11752
|
import {
|
|
11625
11753
|
MIXED_AUDIO_FILENAME,
|
|
11626
11754
|
audioFailureDiagnostics,
|
|
@@ -11631,8 +11759,8 @@ import {
|
|
|
11631
11759
|
} from "@hyperframes/engine";
|
|
11632
11760
|
|
|
11633
11761
|
// src/services/render/audioDeliveryLimit.ts
|
|
11634
|
-
import { existsSync as
|
|
11635
|
-
import { dirname as dirname11, join as
|
|
11762
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
11763
|
+
import { dirname as dirname11, join as join25 } from "node:path";
|
|
11636
11764
|
import {
|
|
11637
11765
|
applyAudioFxChain,
|
|
11638
11766
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -11642,7 +11770,7 @@ import {
|
|
|
11642
11770
|
|
|
11643
11771
|
// src/services/render/audioPadTrim.ts
|
|
11644
11772
|
import { spawn } from "node:child_process";
|
|
11645
|
-
import { dirname as dirname10, join as
|
|
11773
|
+
import { dirname as dirname10, join as join24 } from "node:path";
|
|
11646
11774
|
import {
|
|
11647
11775
|
DEFAULT_CONFIG,
|
|
11648
11776
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -11923,7 +12051,7 @@ async function constrainAacTruePeak(input) {
|
|
|
11923
12051
|
}
|
|
11924
12052
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
11925
12053
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
11926
|
-
const cutPath =
|
|
12054
|
+
const cutPath = join24(scratchDir, "source.wav");
|
|
11927
12055
|
try {
|
|
11928
12056
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
11929
12057
|
if (!result.success) throw new Error(result.error);
|
|
@@ -11938,7 +12066,7 @@ async function enforceAacTruePeak(input) {
|
|
|
11938
12066
|
let scratchDir;
|
|
11939
12067
|
try {
|
|
11940
12068
|
scratchDir = createStagingDir3(dirname10(input.audioPath), ".true-peak-");
|
|
11941
|
-
const correctedPath =
|
|
12069
|
+
const correctedPath = join24(scratchDir, "audio.m4a");
|
|
11942
12070
|
const measurements = [];
|
|
11943
12071
|
let attenuationDb = 0;
|
|
11944
12072
|
let sourcePeakDbfs;
|
|
@@ -12151,14 +12279,14 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
12151
12279
|
applyChain: applyAudioFxChain,
|
|
12152
12280
|
encode: encodeAac2,
|
|
12153
12281
|
rename: renameWithRetry6,
|
|
12154
|
-
sourceExists:
|
|
12282
|
+
sourceExists: existsSync16
|
|
12155
12283
|
}) {
|
|
12156
12284
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
12157
12285
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
12158
12286
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
12159
12287
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
12160
12288
|
const alternating = ["a", "b"].map(
|
|
12161
|
-
(k) =>
|
|
12289
|
+
(k) => join25(dirname11(sourcePath), `audio-source-limited-${k}.wav`)
|
|
12162
12290
|
);
|
|
12163
12291
|
let encodedFrom;
|
|
12164
12292
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -12231,7 +12359,7 @@ function runAudioStage(input) {
|
|
|
12231
12359
|
}
|
|
12232
12360
|
async function runAudioStageScoped(input) {
|
|
12233
12361
|
const stageStart = Date.now();
|
|
12234
|
-
const pcmSourcePath =
|
|
12362
|
+
const pcmSourcePath = join26(input.workDir, "audio-source.wav");
|
|
12235
12363
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
12236
12364
|
let deliverySourcePath;
|
|
12237
12365
|
try {
|
|
@@ -12247,7 +12375,7 @@ async function runAudioStageScoped(input) {
|
|
|
12247
12375
|
);
|
|
12248
12376
|
audioLoweredDb = guard.loweredDb;
|
|
12249
12377
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
12250
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
12378
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
|
|
12251
12379
|
deliverySourcePath = pcmSourcePath;
|
|
12252
12380
|
}
|
|
12253
12381
|
}
|
|
@@ -12296,7 +12424,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12296
12424
|
assertNotAborted,
|
|
12297
12425
|
log
|
|
12298
12426
|
} = input;
|
|
12299
|
-
const audioOutputPath =
|
|
12427
|
+
const audioOutputPath = join26(workDir, MIXED_AUDIO_FILENAME);
|
|
12300
12428
|
let hasAudio = false;
|
|
12301
12429
|
let audioError;
|
|
12302
12430
|
let audioFailures;
|
|
@@ -12376,8 +12504,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
12376
12504
|
}
|
|
12377
12505
|
|
|
12378
12506
|
// src/services/render/stages/captureStage.ts
|
|
12379
|
-
import { existsSync as
|
|
12380
|
-
import { join as
|
|
12507
|
+
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
12508
|
+
import { join as join27 } from "node:path";
|
|
12381
12509
|
import {
|
|
12382
12510
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
12383
12511
|
frameFileExtension,
|
|
@@ -12447,16 +12575,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
12447
12575
|
}
|
|
12448
12576
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
12449
12577
|
let total = sampleDirectoryBytes(framesDir);
|
|
12450
|
-
if (!
|
|
12578
|
+
if (!existsSync18(workDir)) return total;
|
|
12451
12579
|
for (const attempt of readdirSync4(workDir)) {
|
|
12452
12580
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
12453
|
-
total += sampleDirectoryBytes(
|
|
12581
|
+
total += sampleDirectoryBytes(join27(workDir, attempt));
|
|
12454
12582
|
continue;
|
|
12455
12583
|
}
|
|
12456
12584
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
12457
|
-
const attemptDir =
|
|
12585
|
+
const attemptDir = join27(workDir, attempt);
|
|
12458
12586
|
for (const name of readdirSync4(attemptDir)) {
|
|
12459
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
12587
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join27(attemptDir, name));
|
|
12460
12588
|
}
|
|
12461
12589
|
}
|
|
12462
12590
|
return total;
|
|
@@ -12754,8 +12882,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
12754
12882
|
}
|
|
12755
12883
|
|
|
12756
12884
|
// src/services/render/stages/captureHdrStage.ts
|
|
12757
|
-
import { existsSync as
|
|
12758
|
-
import { join as
|
|
12885
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
12886
|
+
import { join as join31 } from "node:path";
|
|
12759
12887
|
import {
|
|
12760
12888
|
closeCaptureSession as closeCaptureSession7,
|
|
12761
12889
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -12827,7 +12955,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
12827
12955
|
}
|
|
12828
12956
|
|
|
12829
12957
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
12830
|
-
import { join as
|
|
12958
|
+
import { join as join28 } from "node:path";
|
|
12831
12959
|
import {
|
|
12832
12960
|
TRANSITIONS,
|
|
12833
12961
|
crossfade
|
|
@@ -12952,7 +13080,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
12952
13080
|
);
|
|
12953
13081
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
12954
13082
|
writeFileExclusiveSync(
|
|
12955
|
-
|
|
13083
|
+
join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
12956
13084
|
normalCanvas
|
|
12957
13085
|
);
|
|
12958
13086
|
}
|
|
@@ -12984,7 +13112,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
12984
13112
|
}
|
|
12985
13113
|
|
|
12986
13114
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
12987
|
-
import { join as
|
|
13115
|
+
import { join as join30 } from "node:path";
|
|
12988
13116
|
import {
|
|
12989
13117
|
TRANSITIONS as TRANSITIONS2,
|
|
12990
13118
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -12998,10 +13126,10 @@ import {
|
|
|
12998
13126
|
// src/services/shaderTransitionWorkerPool.ts
|
|
12999
13127
|
import { Worker } from "node:worker_threads";
|
|
13000
13128
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
13001
|
-
import { dirname as dirname12, join as
|
|
13129
|
+
import { dirname as dirname12, join as join29 } from "node:path";
|
|
13002
13130
|
import { createRequire } from "node:module";
|
|
13003
13131
|
import { usableCpuCount } from "@hyperframes/engine";
|
|
13004
|
-
import { existsSync as
|
|
13132
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
13005
13133
|
function resolveWorkerEntry(explicit) {
|
|
13006
13134
|
if (explicit && explicit.length > 0) {
|
|
13007
13135
|
return { path: explicit, isTs: explicit.endsWith(".ts") };
|
|
@@ -13012,9 +13140,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
13012
13140
|
return { path: override, isTs };
|
|
13013
13141
|
}
|
|
13014
13142
|
const moduleDir = dirname12(fileURLToPath3(import.meta.url));
|
|
13015
|
-
const jsPath =
|
|
13016
|
-
if (
|
|
13017
|
-
const tsPath =
|
|
13143
|
+
const jsPath = join29(moduleDir, "shaderTransitionWorker.js");
|
|
13144
|
+
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
13145
|
+
const tsPath = join29(moduleDir, "shaderTransitionWorker.ts");
|
|
13018
13146
|
return { path: tsPath, isTs: true };
|
|
13019
13147
|
}
|
|
13020
13148
|
function buildExecArgv(entryIsTs) {
|
|
@@ -13157,8 +13285,8 @@ async function createShaderTransitionWorkerPool(opts) {
|
|
|
13157
13285
|
if (terminated) {
|
|
13158
13286
|
throw new Error("shader-blend pool already terminated");
|
|
13159
13287
|
}
|
|
13160
|
-
return new Promise((
|
|
13161
|
-
const task = traceEnabled ? { req, resolve:
|
|
13288
|
+
return new Promise((resolve12, reject) => {
|
|
13289
|
+
const task = traceEnabled ? { req, resolve: resolve12, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve12, reject };
|
|
13162
13290
|
const idle = slots.find((s) => !s.busy && !s.dead);
|
|
13163
13291
|
if (idle) {
|
|
13164
13292
|
queue.unshift(task);
|
|
@@ -13382,7 +13510,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
13382
13510
|
);
|
|
13383
13511
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
13384
13512
|
writeFileExclusiveSync(
|
|
13385
|
-
|
|
13513
|
+
join30(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
13386
13514
|
canvas
|
|
13387
13515
|
);
|
|
13388
13516
|
}
|
|
@@ -13578,8 +13706,8 @@ async function runCaptureHdrStage(input) {
|
|
|
13578
13706
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
13579
13707
|
}
|
|
13580
13708
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
13581
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
13582
|
-
if (debugDumpDir && !
|
|
13709
|
+
const debugDumpDir = debugDumpEnabled ? join31(framesDir, "debug-composite") : null;
|
|
13710
|
+
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
13583
13711
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
13584
13712
|
}
|
|
13585
13713
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -13738,7 +13866,7 @@ async function runCaptureHdrStage(input) {
|
|
|
13738
13866
|
// src/services/render/stages/encodeStage.ts
|
|
13739
13867
|
import {
|
|
13740
13868
|
copyFileSync as copyFileSync4,
|
|
13741
|
-
existsSync as
|
|
13869
|
+
existsSync as existsSync21,
|
|
13742
13870
|
mkdirSync as mkdirSync11,
|
|
13743
13871
|
readdirSync as readdirSync5,
|
|
13744
13872
|
readFileSync as readFileSync9,
|
|
@@ -13747,7 +13875,7 @@ import {
|
|
|
13747
13875
|
writeFileSync as writeFileSync6
|
|
13748
13876
|
} from "node:fs";
|
|
13749
13877
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
13750
|
-
import { dirname as dirname13, join as
|
|
13878
|
+
import { dirname as dirname13, join as join32 } from "node:path";
|
|
13751
13879
|
import {
|
|
13752
13880
|
encodeFramesChunkedConcat,
|
|
13753
13881
|
encodeFramesFromDir,
|
|
@@ -13872,7 +14000,7 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
13872
14000
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
13873
14001
|
if (failure) return failure;
|
|
13874
14002
|
}
|
|
13875
|
-
const fileSize =
|
|
14003
|
+
const fileSize = existsSync21(outputPath) ? statSync10(outputPath).size : 0;
|
|
13876
14004
|
return {
|
|
13877
14005
|
success: true,
|
|
13878
14006
|
outputPath,
|
|
@@ -13963,10 +14091,10 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
13963
14091
|
const stream = await encoder;
|
|
13964
14092
|
for (let next = 0; next < totalFrames; next++) {
|
|
13965
14093
|
while (!landed.has(next) && !captureDone && !signal.aborted) {
|
|
13966
|
-
await new Promise((
|
|
14094
|
+
await new Promise((resolve12) => wake = resolve12);
|
|
13967
14095
|
}
|
|
13968
14096
|
if (signal.aborted) return;
|
|
13969
|
-
const mergedPath =
|
|
14097
|
+
const mergedPath = join32(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
13970
14098
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
13971
14099
|
landed.delete(next);
|
|
13972
14100
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -14041,7 +14169,7 @@ async function runEncodeStage(input) {
|
|
|
14041
14169
|
const stage5Start = Date.now();
|
|
14042
14170
|
if (isPngSequence) {
|
|
14043
14171
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
14044
|
-
if (!
|
|
14172
|
+
if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
14045
14173
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
14046
14174
|
if (captured.length === 0) {
|
|
14047
14175
|
throw new Error(
|
|
@@ -14049,11 +14177,11 @@ async function runEncodeStage(input) {
|
|
|
14049
14177
|
);
|
|
14050
14178
|
}
|
|
14051
14179
|
captured.forEach((name, i) => {
|
|
14052
|
-
const dst =
|
|
14053
|
-
copyFileSync4(
|
|
14180
|
+
const dst = join32(outputPath, formatExportFrameName(i, "png"));
|
|
14181
|
+
copyFileSync4(join32(framesDir, name), dst);
|
|
14054
14182
|
});
|
|
14055
|
-
if (hasAudio && audioOutputPath &&
|
|
14056
|
-
copyFileSync4(audioOutputPath,
|
|
14183
|
+
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
14184
|
+
copyFileSync4(audioOutputPath, join32(outputPath, MIXED_AUDIO_FILENAME2));
|
|
14057
14185
|
log.info(
|
|
14058
14186
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
14059
14187
|
);
|
|
@@ -14073,7 +14201,7 @@ async function runEncodeStage(input) {
|
|
|
14073
14201
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
14074
14202
|
fps: job.config.fps,
|
|
14075
14203
|
loop,
|
|
14076
|
-
palettePath:
|
|
14204
|
+
palettePath: join32(dirname13(videoOnlyPath), "gif-palette.png"),
|
|
14077
14205
|
preserveAlpha: needsAlpha,
|
|
14078
14206
|
signal: abortSignal,
|
|
14079
14207
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -14284,7 +14412,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
14284
14412
|
continue;
|
|
14285
14413
|
}
|
|
14286
14414
|
for (const name of entries) {
|
|
14287
|
-
const full =
|
|
14415
|
+
const full = join33(current, name);
|
|
14288
14416
|
try {
|
|
14289
14417
|
const st = statSync11(full);
|
|
14290
14418
|
if (st.isDirectory()) {
|
|
@@ -14320,6 +14448,7 @@ function summarizeExtractionObservability(extractionResult, videoCount, coverage
|
|
|
14320
14448
|
vfrPreflightCount: phaseBreakdown?.vfrPreflightCount,
|
|
14321
14449
|
cacheHits: phaseBreakdown?.cacheHits,
|
|
14322
14450
|
cacheMisses: phaseBreakdown?.cacheMisses,
|
|
14451
|
+
cachePublishFailures: phaseBreakdown?.cachePublishFailures,
|
|
14323
14452
|
transientRetries: phaseBreakdown?.transientRetries,
|
|
14324
14453
|
...coverageGauges,
|
|
14325
14454
|
authoredTimedClipCount
|
|
@@ -14441,8 +14570,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14441
14570
|
const ranges = [];
|
|
14442
14571
|
let rangeStart = null;
|
|
14443
14572
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14444
|
-
const framePath =
|
|
14445
|
-
const missing = !
|
|
14573
|
+
const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14574
|
+
const missing = !existsSync22(framePath) || statSync11(framePath).size <= 8;
|
|
14446
14575
|
if (missing && rangeStart === null) {
|
|
14447
14576
|
rangeStart = frameIndex;
|
|
14448
14577
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -14458,7 +14587,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
14458
14587
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
14459
14588
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
14460
14589
|
const batches = [];
|
|
14461
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
14590
|
+
const outputDirFor = (batchIndex, workerId) => join33(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
14462
14591
|
if (stride > 1) {
|
|
14463
14592
|
const spans = /* @__PURE__ */ new Map();
|
|
14464
14593
|
for (const range of ranges) {
|
|
@@ -14517,9 +14646,9 @@ function createCaptureObservabilityUpdater(observability, platform2 = process.pl
|
|
|
14517
14646
|
function getNextRetryWorkerCount(currentWorkers) {
|
|
14518
14647
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
14519
14648
|
}
|
|
14520
|
-
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir =
|
|
14521
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
14522
|
-
return
|
|
14649
|
+
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir3()) {
|
|
14650
|
+
if (platform2 === "win32" || platform2 === "darwin") return join33(systemTempDir, "hf-render-");
|
|
14651
|
+
return join33(dirname14(outputPath), `work-${jobId}-`);
|
|
14523
14652
|
}
|
|
14524
14653
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
14525
14654
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -14574,8 +14703,8 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
14574
14703
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
14575
14704
|
let captured = 0;
|
|
14576
14705
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
14577
|
-
const framePath =
|
|
14578
|
-
if (
|
|
14706
|
+
const framePath = join33(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
14707
|
+
if (existsSync22(framePath)) captured++;
|
|
14579
14708
|
}
|
|
14580
14709
|
return captured;
|
|
14581
14710
|
}
|
|
@@ -14600,7 +14729,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
14600
14729
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
14601
14730
|
});
|
|
14602
14731
|
pendingTransientRetry = false;
|
|
14603
|
-
const attemptWorkDir =
|
|
14732
|
+
const attemptWorkDir = join33(options.workDir, `capture-attempt-${attempt}`);
|
|
14604
14733
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
14605
14734
|
missingRanges,
|
|
14606
14735
|
currentWorkers,
|
|
@@ -15247,8 +15376,8 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
15247
15376
|
};
|
|
15248
15377
|
}
|
|
15249
15378
|
function resolveRenderDebugDir() {
|
|
15250
|
-
const producerRoot = process.env.PRODUCER_RENDERS_DIR ?
|
|
15251
|
-
return
|
|
15379
|
+
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve9(process.env.PRODUCER_RENDERS_DIR, "..") : resolve9(dirname14(fileURLToPath4(import.meta.url)), "../..");
|
|
15380
|
+
return join33(producerRoot, ".debug");
|
|
15252
15381
|
}
|
|
15253
15382
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
15254
15383
|
validateHlsRenderConfig(job.config);
|
|
@@ -15256,11 +15385,11 @@ async function executeRenderJob(job, projectDir, outputPath, progressSink, abort
|
|
|
15256
15385
|
validateChromaSubsamplingConfig(job.config);
|
|
15257
15386
|
const debugDir = resolveRenderDebugDir();
|
|
15258
15387
|
const outputDir = dirname14(outputPath);
|
|
15259
|
-
if (!
|
|
15260
|
-
const workDir = job.config.debug ?
|
|
15388
|
+
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
15389
|
+
const workDir = job.config.debug ? join33(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
15261
15390
|
const pipelineStart = Date.now();
|
|
15262
15391
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
15263
|
-
const logPath = job.config.debug ?
|
|
15392
|
+
const logPath = job.config.debug ? join33(workDir, "render.log") : null;
|
|
15264
15393
|
const execution = new RenderExecutionContext({
|
|
15265
15394
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
15266
15395
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -15328,7 +15457,7 @@ async function executeRenderPipeline(input) {
|
|
|
15328
15457
|
imageDecodeFailures: 0
|
|
15329
15458
|
};
|
|
15330
15459
|
let hdrPerf;
|
|
15331
|
-
const perfOutputPath =
|
|
15460
|
+
const perfOutputPath = join33(workDir, "perf-summary.json");
|
|
15332
15461
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
15333
15462
|
const observability = new RenderObservabilityRecorder({
|
|
15334
15463
|
pipelineStartMs: pipelineStart,
|
|
@@ -15404,7 +15533,7 @@ async function executeRenderPipeline(input) {
|
|
|
15404
15533
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
15405
15534
|
assertNotAborted();
|
|
15406
15535
|
assertConfiguredFfmpegBinariesExist();
|
|
15407
|
-
if (!
|
|
15536
|
+
if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
15408
15537
|
if (job.config.debug) {
|
|
15409
15538
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
15410
15539
|
}
|
|
@@ -15433,8 +15562,8 @@ async function executeRenderPipeline(input) {
|
|
|
15433
15562
|
requestedWorkers: job.config.workers ?? "auto"
|
|
15434
15563
|
});
|
|
15435
15564
|
const entryFile = job.config.entryFile || "index.html";
|
|
15436
|
-
const htmlPath =
|
|
15437
|
-
if (!
|
|
15565
|
+
const htmlPath = join33(projectDir, entryFile);
|
|
15566
|
+
if (!existsSync22(htmlPath)) {
|
|
15438
15567
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
15439
15568
|
}
|
|
15440
15569
|
assertNotAborted();
|
|
@@ -15530,7 +15659,7 @@ async function executeRenderPipeline(input) {
|
|
|
15530
15659
|
const largerThanCanvas = await oversizedVideos(
|
|
15531
15660
|
composition.videos,
|
|
15532
15661
|
projectDir,
|
|
15533
|
-
|
|
15662
|
+
join33(workDir, "compiled"),
|
|
15534
15663
|
{ width: outputWidth, height: outputHeight }
|
|
15535
15664
|
);
|
|
15536
15665
|
const probeResult = await observeRenderStage(
|
|
@@ -15627,7 +15756,7 @@ async function executeRenderPipeline(input) {
|
|
|
15627
15756
|
canvas: { width, height },
|
|
15628
15757
|
page: probeSession.page,
|
|
15629
15758
|
projectDir,
|
|
15630
|
-
compiledDir:
|
|
15759
|
+
compiledDir: join33(workDir, "compiled")
|
|
15631
15760
|
});
|
|
15632
15761
|
if (videoLayerPlan.videoId === void 0) {
|
|
15633
15762
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -15645,7 +15774,7 @@ async function executeRenderPipeline(input) {
|
|
|
15645
15774
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
15646
15775
|
code: "extract_video"
|
|
15647
15776
|
});
|
|
15648
|
-
const compiledDir =
|
|
15777
|
+
const compiledDir = join33(workDir, "compiled");
|
|
15649
15778
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
15650
15779
|
env: process.env,
|
|
15651
15780
|
durationSeconds: probeResult.duration,
|
|
@@ -15781,7 +15910,7 @@ async function executeRenderPipeline(input) {
|
|
|
15781
15910
|
try {
|
|
15782
15911
|
fileServer = await createFileServer({
|
|
15783
15912
|
projectDir,
|
|
15784
|
-
compiledDir:
|
|
15913
|
+
compiledDir: join33(workDir, "compiled"),
|
|
15785
15914
|
port: 0,
|
|
15786
15915
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
15787
15916
|
fps: job.config.fps,
|
|
@@ -15801,8 +15930,8 @@ async function executeRenderPipeline(input) {
|
|
|
15801
15930
|
if (!activeFileServer) {
|
|
15802
15931
|
throw new Error("File server failed to initialize before frame capture");
|
|
15803
15932
|
}
|
|
15804
|
-
const framesDir =
|
|
15805
|
-
if (!
|
|
15933
|
+
const framesDir = join33(workDir, "captured-frames");
|
|
15934
|
+
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
15806
15935
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
15807
15936
|
code: "start_browsers"
|
|
15808
15937
|
});
|
|
@@ -16382,7 +16511,7 @@ async function executeRenderPipeline(input) {
|
|
|
16382
16511
|
hls: ".mp4"
|
|
16383
16512
|
};
|
|
16384
16513
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
16385
|
-
const videoOnlyPath =
|
|
16514
|
+
const videoOnlyPath = join33(workDir, `video-only${videoExt}`);
|
|
16386
16515
|
let usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
16387
16516
|
if (usePageSideCompositingForTransitions) {
|
|
16388
16517
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -16699,7 +16828,7 @@ async function executeRenderPipeline(input) {
|
|
|
16699
16828
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
16700
16829
|
captureQuality: captureOptions.quality
|
|
16701
16830
|
});
|
|
16702
|
-
const segmentDir = segmentDirFor(
|
|
16831
|
+
const segmentDir = segmentDirFor(join33(projectDir, "renders"), segmentPlanHash);
|
|
16703
16832
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
16704
16833
|
if (job.config.resumeSegments === true) {
|
|
16705
16834
|
const existing = readSegmentManifest(segmentDir);
|
|
@@ -17243,7 +17372,7 @@ async function executeRenderPipeline(input) {
|
|
|
17243
17372
|
})
|
|
17244
17373
|
);
|
|
17245
17374
|
const totalElapsed = Date.now() - pipelineStart;
|
|
17246
|
-
const tmpPeakBytes =
|
|
17375
|
+
const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
17247
17376
|
recordTransientRetryObservability();
|
|
17248
17377
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
17249
17378
|
const observabilitySummary = observability.summary({
|
|
@@ -17324,8 +17453,8 @@ async function executeRenderPipeline(input) {
|
|
|
17324
17453
|
}
|
|
17325
17454
|
}
|
|
17326
17455
|
if (job.config.debug) {
|
|
17327
|
-
if (!isPngSequence && !isHls &&
|
|
17328
|
-
const debugOutput =
|
|
17456
|
+
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
17457
|
+
const debugOutput = join33(workDir, `output${videoExt}`);
|
|
17329
17458
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
17330
17459
|
}
|
|
17331
17460
|
}
|
|
@@ -17404,7 +17533,8 @@ async function executeRenderPipeline(input) {
|
|
|
17404
17533
|
perfStages,
|
|
17405
17534
|
hdrDiagnostics,
|
|
17406
17535
|
observability: observabilitySummary,
|
|
17407
|
-
subTimelineWait: worstSubTimelineWaitOutcome(dedupPerfs)
|
|
17536
|
+
subTimelineWait: worstSubTimelineWaitOutcome(dedupPerfs),
|
|
17537
|
+
missingPath: describeMissingPath(error, { cacheDir: cfg.extractCacheDir, workDir })
|
|
17408
17538
|
});
|
|
17409
17539
|
publishRenderFailure(
|
|
17410
17540
|
job,
|
|
@@ -17439,7 +17569,7 @@ async function executeRenderPipeline(input) {
|
|
|
17439
17569
|
|
|
17440
17570
|
// src/services/hyperframeLint.ts
|
|
17441
17571
|
import {
|
|
17442
|
-
existsSync as
|
|
17572
|
+
existsSync as existsSync23,
|
|
17443
17573
|
readFileSync as readFileSync10,
|
|
17444
17574
|
statSync as statSync12,
|
|
17445
17575
|
openSync as openSync5,
|
|
@@ -17447,7 +17577,7 @@ import {
|
|
|
17447
17577
|
closeSync as closeSync5,
|
|
17448
17578
|
constants as constants3
|
|
17449
17579
|
} from "node:fs";
|
|
17450
|
-
import { resolve as
|
|
17580
|
+
import { resolve as resolve10, join as join34, relative as relative5, isAbsolute as isAbsolute4, sep as sep5, dirname as dirname15 } from "node:path";
|
|
17451
17581
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
17452
17582
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
17453
17583
|
function isStringRecord(value) {
|
|
@@ -17493,19 +17623,19 @@ function readEntryHtml(filePath) {
|
|
|
17493
17623
|
}
|
|
17494
17624
|
}
|
|
17495
17625
|
function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
17496
|
-
const entryRelativePath =
|
|
17497
|
-
return entryRelativePath === ".." || entryRelativePath.startsWith(`..${
|
|
17626
|
+
const entryRelativePath = relative5(absProjectDir, absoluteEntryPath);
|
|
17627
|
+
return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep5}`) || isAbsolute4(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
|
|
17498
17628
|
}
|
|
17499
17629
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
17500
|
-
const absProjectDir =
|
|
17501
|
-
if (!
|
|
17630
|
+
const absProjectDir = resolve10(projectDir);
|
|
17631
|
+
if (!existsSync23(absProjectDir) || !statSync12(absProjectDir).isDirectory()) {
|
|
17502
17632
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
17503
17633
|
}
|
|
17504
17634
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
17505
17635
|
(value) => typeof value === "string" && value.trim().length > 0
|
|
17506
17636
|
);
|
|
17507
17637
|
for (const entryFile of entryCandidates) {
|
|
17508
|
-
const absoluteEntryPath =
|
|
17638
|
+
const absoluteEntryPath = resolve10(absProjectDir, entryFile);
|
|
17509
17639
|
if (leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry)) {
|
|
17510
17640
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
17511
17641
|
}
|
|
@@ -17519,7 +17649,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
17519
17649
|
}
|
|
17520
17650
|
}
|
|
17521
17651
|
return {
|
|
17522
|
-
error: `No HTML entry file found in project directory: ${
|
|
17652
|
+
error: `No HTML entry file found in project directory: ${join34(absProjectDir, preferredEntryFile || "index.html")}`
|
|
17523
17653
|
};
|
|
17524
17654
|
}
|
|
17525
17655
|
function prepareHyperframeLintBody(body, isAllowedEntry) {
|
|
@@ -17565,16 +17695,16 @@ function takeLintSlot(limit, waitMs) {
|
|
|
17565
17695
|
running++;
|
|
17566
17696
|
return Promise.resolve(true);
|
|
17567
17697
|
}
|
|
17568
|
-
return new Promise((
|
|
17698
|
+
return new Promise((resolve12) => {
|
|
17569
17699
|
const entry = () => {
|
|
17570
17700
|
clearTimeout(timer);
|
|
17571
17701
|
running++;
|
|
17572
|
-
|
|
17702
|
+
resolve12(true);
|
|
17573
17703
|
};
|
|
17574
17704
|
const timer = setTimeout(
|
|
17575
17705
|
() => {
|
|
17576
17706
|
waiting.splice(waiting.indexOf(entry), 1);
|
|
17577
|
-
|
|
17707
|
+
resolve12(false);
|
|
17578
17708
|
},
|
|
17579
17709
|
Math.max(0, waitMs)
|
|
17580
17710
|
);
|
|
@@ -17588,8 +17718,8 @@ function freeLintSlot() {
|
|
|
17588
17718
|
function resolveLintWorkerEntry() {
|
|
17589
17719
|
const here = dirname15(fileURLToPath5(import.meta.url));
|
|
17590
17720
|
for (const name of ["hyperframeLintWorker.js", "hyperframeLintWorker.ts"]) {
|
|
17591
|
-
const candidate =
|
|
17592
|
-
if (
|
|
17721
|
+
const candidate = join34(here, name);
|
|
17722
|
+
if (existsSync23(candidate)) return candidate;
|
|
17593
17723
|
}
|
|
17594
17724
|
return void 0;
|
|
17595
17725
|
}
|
|
@@ -17659,8 +17789,8 @@ async function runHyperframeLint(prepared, options = {}) {
|
|
|
17659
17789
|
// src/services/healthWorker.ts
|
|
17660
17790
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
17661
17791
|
import { fileURLToPath as fileURLToPath6 } from "node:url";
|
|
17662
|
-
import { dirname as dirname16, join as
|
|
17663
|
-
import { existsSync as
|
|
17792
|
+
import { dirname as dirname16, join as join35 } from "node:path";
|
|
17793
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
17664
17794
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
17665
17795
|
async function startHealthWorker(options = {}) {
|
|
17666
17796
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -17678,12 +17808,12 @@ async function startHealthWorker(options = {}) {
|
|
|
17678
17808
|
stdout: false,
|
|
17679
17809
|
stderr: false
|
|
17680
17810
|
});
|
|
17681
|
-
await new Promise((
|
|
17811
|
+
await new Promise((resolve12, reject) => {
|
|
17682
17812
|
const onMessage = (msg) => {
|
|
17683
17813
|
if (msg?.type === "listening") {
|
|
17684
17814
|
worker.off("error", onError);
|
|
17685
17815
|
worker.off("message", onMessage);
|
|
17686
|
-
|
|
17816
|
+
resolve12();
|
|
17687
17817
|
} else if (msg?.type === "listen-error") {
|
|
17688
17818
|
worker.off("error", onError);
|
|
17689
17819
|
worker.off("message", onMessage);
|
|
@@ -17735,9 +17865,9 @@ function defaultLogger2() {
|
|
|
17735
17865
|
}
|
|
17736
17866
|
function resolveWorkerEntry2() {
|
|
17737
17867
|
const here = dirname16(fileURLToPath6(import.meta.url));
|
|
17738
|
-
const candidates = [
|
|
17868
|
+
const candidates = [join35(here, "healthWorkerThread.js"), join35(here, "healthWorkerThread.ts")];
|
|
17739
17869
|
for (const candidate of candidates) {
|
|
17740
|
-
if (
|
|
17870
|
+
if (existsSync24(candidate)) return candidate;
|
|
17741
17871
|
}
|
|
17742
17872
|
return void 0;
|
|
17743
17873
|
}
|
|
@@ -17777,7 +17907,7 @@ import {
|
|
|
17777
17907
|
createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
|
|
17778
17908
|
} from "@hyperframes/engine";
|
|
17779
17909
|
import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
|
|
17780
|
-
import { extname as extname4, isAbsolute as
|
|
17910
|
+
import { extname as extname4, isAbsolute as isAbsolute5, join as join37, relative as relative6, sep as sep6 } from "node:path";
|
|
17781
17911
|
import {
|
|
17782
17912
|
fpsToNumber as fpsToNumber9,
|
|
17783
17913
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -17810,8 +17940,8 @@ import {
|
|
|
17810
17940
|
|
|
17811
17941
|
// src/services/distributed/shared.ts
|
|
17812
17942
|
import { execFile as execFileCallback } from "node:child_process";
|
|
17813
|
-
import { dirname as dirname17, join as
|
|
17814
|
-
import { existsSync as
|
|
17943
|
+
import { dirname as dirname17, join as join36 } from "node:path";
|
|
17944
|
+
import { existsSync as existsSync25, readFileSync as readFileSync11 } from "node:fs";
|
|
17815
17945
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
17816
17946
|
import { promisify as promisify2 } from "node:util";
|
|
17817
17947
|
import {
|
|
@@ -17826,8 +17956,8 @@ function readProducerVersion() {
|
|
|
17826
17956
|
const startDir = dirname17(fileURLToPath7(import.meta.url));
|
|
17827
17957
|
let current = startDir;
|
|
17828
17958
|
for (let i = 0; i < 10; i++) {
|
|
17829
|
-
const candidate =
|
|
17830
|
-
if (
|
|
17959
|
+
const candidate = join36(current, "package.json");
|
|
17960
|
+
if (existsSync25(candidate)) {
|
|
17831
17961
|
try {
|
|
17832
17962
|
const pkg = JSON.parse(readFileSync11(candidate, "utf-8"));
|
|
17833
17963
|
if (pkg.name === "@hyperframes/producer" && typeof pkg.version === "string") {
|
|
@@ -17924,9 +18054,9 @@ var PLAN_ROOT_CATEGORY = {
|
|
|
17924
18054
|
var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
17925
18055
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
17926
18056
|
"plan.json",
|
|
17927
|
-
|
|
17928
|
-
|
|
17929
|
-
|
|
18057
|
+
join37("meta", "composition.json"),
|
|
18058
|
+
join37("meta", "encoder.json"),
|
|
18059
|
+
join37("meta", "chunks.json")
|
|
17930
18060
|
];
|
|
17931
18061
|
|
|
17932
18062
|
// src/services/distributed/renderConfigValidation.ts
|
|
@@ -18354,7 +18484,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
|
18354
18484
|
}
|
|
18355
18485
|
}
|
|
18356
18486
|
const outputDir = dirname18(absoluteOutputPath);
|
|
18357
|
-
if (!
|
|
18487
|
+
if (!existsSync26(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
18358
18488
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
18359
18489
|
}
|
|
18360
18490
|
function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
|
|
@@ -18415,7 +18545,7 @@ function validateOutputResolutionOverride(body) {
|
|
|
18415
18545
|
var MAX_PREVIEW_HTML_BYTES = 20 * 1024 * 1024;
|
|
18416
18546
|
function resolveRenderRequestPolicy(options) {
|
|
18417
18547
|
return {
|
|
18418
|
-
projectsDir:
|
|
18548
|
+
projectsDir: resolve11(
|
|
18419
18549
|
options.projectsDir ?? (process.env.PRODUCER_PROJECTS_DIR || process.cwd())
|
|
18420
18550
|
),
|
|
18421
18551
|
allowDebug: options.allowDebug ?? process.env.PRODUCER_ALLOW_DEBUG === "1"
|
|
@@ -18430,14 +18560,14 @@ function isAllowedEntryPath(policy, projectDir, path) {
|
|
|
18430
18560
|
function prepareProjectDirectory(projectDir, options, policy) {
|
|
18431
18561
|
const candidate = nonEmptyString(projectDir);
|
|
18432
18562
|
if (!candidate) return null;
|
|
18433
|
-
const absProjectDir = policy ?
|
|
18563
|
+
const absProjectDir = policy ? resolve11(policy.projectsDir, candidate) : resolve11(candidate);
|
|
18434
18564
|
const shown = policy ? candidate : absProjectDir;
|
|
18435
|
-
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !
|
|
18565
|
+
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync26(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
18436
18566
|
return { error: `Project directory not found: ${shown}` };
|
|
18437
18567
|
}
|
|
18438
18568
|
const entry = options.entryFile || "index.html";
|
|
18439
|
-
const entryPath =
|
|
18440
|
-
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !
|
|
18569
|
+
const entryPath = resolve11(absProjectDir, entry);
|
|
18570
|
+
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync26(entryPath)) {
|
|
18441
18571
|
return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
|
|
18442
18572
|
}
|
|
18443
18573
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -18457,9 +18587,9 @@ async function resolveInlineRenderHtml(body) {
|
|
|
18457
18587
|
}
|
|
18458
18588
|
}
|
|
18459
18589
|
function materializeInlineProject(html, options) {
|
|
18460
|
-
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR ||
|
|
18461
|
-
const tempProjectDir = mkdtempSync(
|
|
18462
|
-
writeFileSync8(
|
|
18590
|
+
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir4();
|
|
18591
|
+
const tempProjectDir = mkdtempSync(join38(tempRoot, "producer-project-"));
|
|
18592
|
+
writeFileSync8(join38(tempProjectDir, "index.html"), html, "utf-8");
|
|
18463
18593
|
return {
|
|
18464
18594
|
prepared: {
|
|
18465
18595
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -18487,7 +18617,7 @@ function resolveOutputPath(projectDir, outputCandidate, rendersDir, log) {
|
|
|
18487
18617
|
try {
|
|
18488
18618
|
return resolveRenderPaths(projectDir, outputCandidate, rendersDir).absoluteOutputPath;
|
|
18489
18619
|
} catch (error) {
|
|
18490
|
-
const fallbackPath =
|
|
18620
|
+
const fallbackPath = resolve11(rendersDir, `producer-fallback-${Date.now()}.mp4`);
|
|
18491
18621
|
log.warn("Failed to resolve output path, using fallback", {
|
|
18492
18622
|
fallback: fallbackPath,
|
|
18493
18623
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -18535,7 +18665,7 @@ function publicPerfSummary(job) {
|
|
|
18535
18665
|
return job.perfSummary ? { ...job.perfSummary, renderId: void 0 } : null;
|
|
18536
18666
|
}
|
|
18537
18667
|
function outputFileSize(path) {
|
|
18538
|
-
return
|
|
18668
|
+
return existsSync26(path) ? statSync13(path).size : 0;
|
|
18539
18669
|
}
|
|
18540
18670
|
function createBlockingProgressReporter(log, requestId) {
|
|
18541
18671
|
let lastLoggedPct = -10;
|
|
@@ -18655,7 +18785,7 @@ function createRenderHandlers(options = {}) {
|
|
|
18655
18785
|
const lintProjectDir = nonEmptyString(body.projectDir);
|
|
18656
18786
|
let isAllowedEntry;
|
|
18657
18787
|
if (policy && lintProjectDir) {
|
|
18658
|
-
const absProjectDir =
|
|
18788
|
+
const absProjectDir = resolve11(policy.projectsDir, lintProjectDir);
|
|
18659
18789
|
if (!isAllowedProjectPath(policy.projectsDir, absProjectDir)) {
|
|
18660
18790
|
const error = `Project directory not found: ${lintProjectDir}`;
|
|
18661
18791
|
return c.json({ success: false, requestId, error }, 400);
|
|
@@ -18862,7 +18992,7 @@ function createRenderHandlers(options = {}) {
|
|
|
18862
18992
|
if (!artifact) {
|
|
18863
18993
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
18864
18994
|
}
|
|
18865
|
-
if (!
|
|
18995
|
+
if (!existsSync26(artifact.path)) {
|
|
18866
18996
|
store.delete(token);
|
|
18867
18997
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
18868
18998
|
}
|
|
@@ -19027,7 +19157,7 @@ function startServer(options = {}) {
|
|
|
19027
19157
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
19028
19158
|
return server;
|
|
19029
19159
|
}
|
|
19030
|
-
var entryScript = process.argv[1] ?
|
|
19160
|
+
var entryScript = process.argv[1] ? resolve11(process.argv[1]) : "";
|
|
19031
19161
|
var isPublicServerEntry = entryScript.endsWith("/public-server.js") || entryScript.endsWith("/src/server.ts");
|
|
19032
19162
|
if (isPublicServerEntry) {
|
|
19033
19163
|
const { values } = parseArgs({
|