@hyperframes/producer 0.9.30 → 0.9.31
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 +320 -301
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +377 -358
- package/dist/public-server.js +181 -162
- package/dist/services/bundledScripts.d.ts +4 -0
- package/package.json +7 -7
package/dist/public-server.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/server.ts
|
|
4
4
|
import {
|
|
5
|
-
existsSync as
|
|
5
|
+
existsSync as existsSync25,
|
|
6
6
|
mkdirSync as mkdirSync13,
|
|
7
7
|
statSync as statSync11,
|
|
8
8
|
mkdtempSync,
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
rmSync as rmSync13,
|
|
11
11
|
createReadStream as createReadStream3
|
|
12
12
|
} from "node:fs";
|
|
13
|
-
import { resolve as resolve10, dirname as dirname15, join as
|
|
13
|
+
import { resolve as resolve10, dirname as dirname15, join as join35 } from "node:path";
|
|
14
14
|
import { tmpdir as tmpdir3 } from "node:os";
|
|
15
15
|
import { parseArgs } from "node:util";
|
|
16
16
|
import crypto from "node:crypto";
|
|
@@ -26,7 +26,7 @@ import {
|
|
|
26
26
|
// src/services/renderOrchestrator.ts
|
|
27
27
|
import { audioFailureDiagnostics as audioFailureDiagnostics2 } from "@hyperframes/engine";
|
|
28
28
|
import {
|
|
29
|
-
existsSync as
|
|
29
|
+
existsSync as existsSync22,
|
|
30
30
|
mkdirSync as mkdirSync12,
|
|
31
31
|
readdirSync as readdirSync6,
|
|
32
32
|
rmSync as rmSync12,
|
|
@@ -84,7 +84,7 @@ import {
|
|
|
84
84
|
referenceBackgroundResult,
|
|
85
85
|
createReferenceBackgroundRecorder
|
|
86
86
|
} from "@hyperframes/engine";
|
|
87
|
-
import { join as
|
|
87
|
+
import { join as join31, dirname as dirname13, resolve as resolve8 } from "path";
|
|
88
88
|
import { totalmem as totalmem2 } from "node:os";
|
|
89
89
|
import { randomUUID } from "crypto";
|
|
90
90
|
import { fileURLToPath as fileURLToPath4 } from "url";
|
|
@@ -6353,8 +6353,8 @@ function countAuthoredTimedClips(html) {
|
|
|
6353
6353
|
}
|
|
6354
6354
|
|
|
6355
6355
|
// src/services/render/stages/compileStage.ts
|
|
6356
|
-
import { existsSync as
|
|
6357
|
-
import { join as
|
|
6356
|
+
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
6357
|
+
import { join as join19 } from "node:path";
|
|
6358
6358
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
6359
6359
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
6360
6360
|
import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolution";
|
|
@@ -6362,9 +6362,23 @@ import { readTextFile as readTextFile2 } from "@hyperframes/parsers/asset-resolu
|
|
|
6362
6362
|
// src/services/htmlCompiler.ts
|
|
6363
6363
|
import { decodedUrlPath as decodedUrlPath2 } from "@hyperframes/parsers/asset-paths";
|
|
6364
6364
|
import { createHash as createHash6 } from "node:crypto";
|
|
6365
|
-
import { createReadStream as createReadStream2, existsSync as
|
|
6366
|
-
import { join as
|
|
6365
|
+
import { createReadStream as createReadStream2, existsSync as existsSync12, mkdirSync as mkdirSync9, readFileSync as readFileSync8 } from "fs";
|
|
6366
|
+
import { join as join18, dirname as dirname8, resolve as resolve7, basename as basename5, relative as relative2, sep as sep2 } from "path";
|
|
6367
6367
|
import { parseHTML as parseHTML5 } from "linkedom";
|
|
6368
|
+
|
|
6369
|
+
// src/services/bundledScripts.ts
|
|
6370
|
+
import { existsSync as existsSync9, readFileSync as readFileSync5 } from "node:fs";
|
|
6371
|
+
import { join as join15 } from "node:path";
|
|
6372
|
+
import { gsapCdnDist } from "@hyperframes/core/gsap-cdn";
|
|
6373
|
+
var GSAP_VENDOR_DIR_ENV = "HYPERFRAMES_GSAP_VENDOR_DIR";
|
|
6374
|
+
function bundledScript(url) {
|
|
6375
|
+
const dir = process.env[GSAP_VENDOR_DIR_ENV];
|
|
6376
|
+
if (!dir || url !== `${gsapCdnDist()}gsap.min.js`) return null;
|
|
6377
|
+
const file = join15(dir, "gsap.min.js");
|
|
6378
|
+
return existsSync9(file) ? readFileSync5(file) : null;
|
|
6379
|
+
}
|
|
6380
|
+
|
|
6381
|
+
// src/services/htmlCompiler.ts
|
|
6368
6382
|
import {
|
|
6369
6383
|
COMPOSITION_SOURCE_URL,
|
|
6370
6384
|
compileTimingAttrs,
|
|
@@ -6386,7 +6400,7 @@ import {
|
|
|
6386
6400
|
import { MAX_AUDIO_GAIN } from "@hyperframes/core/audio-gain";
|
|
6387
6401
|
import { readPlaybackRate } from "@hyperframes/parsers/media-duration";
|
|
6388
6402
|
import { resolveRateSpec } from "@hyperframes/core/speed-ramp";
|
|
6389
|
-
import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
6403
|
+
import { gsapCdnDist as gsapCdnDist2, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
6390
6404
|
import {
|
|
6391
6405
|
assignBundledRuntimeCompositionIds,
|
|
6392
6406
|
assignMediaRenderIds,
|
|
@@ -6609,8 +6623,8 @@ import {
|
|
|
6609
6623
|
|
|
6610
6624
|
// src/services/animatedGifPrep.ts
|
|
6611
6625
|
import { createHash as createHash4 } from "node:crypto";
|
|
6612
|
-
import { copyFileSync as copyFileSync2, existsSync as
|
|
6613
|
-
import { dirname as dirname6, isAbsolute as isAbsolute2, join as
|
|
6626
|
+
import { copyFileSync as copyFileSync2, existsSync as existsSync10, mkdirSync as mkdirSync7, readFileSync as readFileSync6, rmSync as rmSync9, statSync as statSync6 } from "node:fs";
|
|
6627
|
+
import { dirname as dirname6, isAbsolute as isAbsolute2, join as join16, resolve as resolve5 } from "node:path";
|
|
6614
6628
|
import { parseHTML as parseHTML3 } from "linkedom";
|
|
6615
6629
|
import { parseAnimatedGifMetadata } from "@hyperframes/core";
|
|
6616
6630
|
import { DEFAULT_VP9_CPU_USED, runFfmpeg as runFfmpeg2, renameWithRetry as renameWithRetry3 } from "@hyperframes/engine";
|
|
@@ -6648,14 +6662,14 @@ function resolveLocalImageSourcePath(src, options) {
|
|
|
6648
6662
|
const { basePath } = splitUrlSuffix(trimmed);
|
|
6649
6663
|
const normalizedBase = normalizeRelPath(basePath);
|
|
6650
6664
|
const mapped = options.sourceAssets?.get(trimmed) ?? options.sourceAssets?.get(basePath) ?? options.sourceAssets?.get(normalizedBase);
|
|
6651
|
-
if (mapped &&
|
|
6665
|
+
if (mapped && existsSync10(mapped)) return mapped;
|
|
6652
6666
|
if (isHttpUrl(trimmed)) return null;
|
|
6653
6667
|
const projectRelative = basePath.startsWith("/") ? basePath.slice(1) : basePath;
|
|
6654
6668
|
const candidates = [
|
|
6655
6669
|
isAbsolute2(basePath) ? basePath : resolve5(options.projectDir, projectRelative),
|
|
6656
6670
|
resolve5(options.downloadDir, normalizedBase)
|
|
6657
6671
|
];
|
|
6658
|
-
return candidates.find((candidate) =>
|
|
6672
|
+
return candidates.find((candidate) => existsSync10(candidate)) ?? null;
|
|
6659
6673
|
}
|
|
6660
6674
|
function isUsableFile(path) {
|
|
6661
6675
|
try {
|
|
@@ -6766,10 +6780,10 @@ async function runAnimatedGifTranscode(request) {
|
|
|
6766
6780
|
throw result.error ?? new Error(`Animated GIF transcode failed (${result.exitCode}): ${result.stderr.slice(-500)}`);
|
|
6767
6781
|
}
|
|
6768
6782
|
async function ensurePreparedWebm(input) {
|
|
6769
|
-
if (!
|
|
6783
|
+
if (!existsSync10(dirname6(input.cachePath))) {
|
|
6770
6784
|
mkdirSync7(dirname6(input.cachePath), { recursive: true });
|
|
6771
6785
|
}
|
|
6772
|
-
if (!
|
|
6786
|
+
if (!existsSync10(dirname6(input.outputPath))) {
|
|
6773
6787
|
mkdirSync7(dirname6(input.outputPath), { recursive: true });
|
|
6774
6788
|
}
|
|
6775
6789
|
if (!isUsableFile(input.cachePath)) {
|
|
@@ -6853,7 +6867,7 @@ function replaceImageWithVideo(input) {
|
|
|
6853
6867
|
return video;
|
|
6854
6868
|
}
|
|
6855
6869
|
async function prepareAnimatedGifInputs(html, options) {
|
|
6856
|
-
const outputDir = options.outputDir ??
|
|
6870
|
+
const outputDir = options.outputDir ?? join16(options.downloadDir, PREPARED_GIF_SUBDIR);
|
|
6857
6871
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_GIF_SUBDIR);
|
|
6858
6872
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
6859
6873
|
const { document: document2 } = parseHTML3(html);
|
|
@@ -6867,7 +6881,7 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6867
6881
|
if (!hasGifExtension(src)) continue;
|
|
6868
6882
|
const sourcePath = resolveLocalImageSourcePath(src, options);
|
|
6869
6883
|
if (!sourcePath) continue;
|
|
6870
|
-
const bytes =
|
|
6884
|
+
const bytes = readFileSync6(sourcePath);
|
|
6871
6885
|
const metadata = parseAnimatedGifMetadata(bytes);
|
|
6872
6886
|
if (!metadata?.animated) continue;
|
|
6873
6887
|
const loopOverride = readLoopOverride(img);
|
|
@@ -6880,8 +6894,8 @@ async function prepareAnimatedGifInputs(html, options) {
|
|
|
6880
6894
|
);
|
|
6881
6895
|
const hash = computePreparedGifHash(bytes, loopIterations, padSeconds);
|
|
6882
6896
|
const filename = `${CACHE_SCHEMA}-${hash.slice(0, 24)}.webm`;
|
|
6883
|
-
const cachePath =
|
|
6884
|
-
const outputPath =
|
|
6897
|
+
const cachePath = join16(cacheDir, filename);
|
|
6898
|
+
const outputPath = join16(outputDir, filename);
|
|
6885
6899
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
6886
6900
|
await ensurePreparedWebm({
|
|
6887
6901
|
sourcePath,
|
|
@@ -6920,13 +6934,13 @@ import {
|
|
|
6920
6934
|
copyFileSync as copyFileSync3,
|
|
6921
6935
|
mkdirSync as mkdirSync8,
|
|
6922
6936
|
openSync as openSync4,
|
|
6923
|
-
readFileSync as
|
|
6937
|
+
readFileSync as readFileSync7,
|
|
6924
6938
|
readSync as readSync3,
|
|
6925
6939
|
rmSync as rmSync10,
|
|
6926
6940
|
statSync as statSync7,
|
|
6927
6941
|
writeFileSync as writeFileSync4
|
|
6928
6942
|
} from "node:fs";
|
|
6929
|
-
import { dirname as dirname7, join as
|
|
6943
|
+
import { dirname as dirname7, join as join17, resolve as resolve6 } from "node:path";
|
|
6930
6944
|
import { parseHTML as parseHTML4 } from "linkedom";
|
|
6931
6945
|
import { renameWithRetry as renameWithRetry4, runFfmpeg as runFfmpeg3, runFfprobe } from "@hyperframes/engine";
|
|
6932
6946
|
|
|
@@ -7104,7 +7118,7 @@ function primaryGrid(probed) {
|
|
|
7104
7118
|
async function convertHeifToJpeg(request) {
|
|
7105
7119
|
const probed = await probeJson(request.inputPath, true);
|
|
7106
7120
|
const grid = primaryGrid(probed);
|
|
7107
|
-
const rotation = readHeifPrimaryRotation(
|
|
7121
|
+
const rotation = readHeifPrimaryRotation(readFileSync7(request.inputPath));
|
|
7108
7122
|
const filters = [];
|
|
7109
7123
|
let inputs = [];
|
|
7110
7124
|
let size = probed.streams?.[0];
|
|
@@ -7162,7 +7176,7 @@ function resolveImageSource(src, options) {
|
|
|
7162
7176
|
const path = resolveLocalImageSourcePath(src, options);
|
|
7163
7177
|
const head = path ? readHead(path) : null;
|
|
7164
7178
|
if (!path || !head || !isHeifBytes(head)) return null;
|
|
7165
|
-
return { path, bytes:
|
|
7179
|
+
return { path, bytes: readFileSync7(path), label: `"${splitUrlSuffix(src).basePath}"` };
|
|
7166
7180
|
}
|
|
7167
7181
|
function isUsableFile2(path) {
|
|
7168
7182
|
try {
|
|
@@ -7200,7 +7214,7 @@ async function ensurePreparedJpeg(source, cachePath, outputPath, options) {
|
|
|
7200
7214
|
}
|
|
7201
7215
|
}
|
|
7202
7216
|
async function prepareHeifImageInputs(html, options) {
|
|
7203
|
-
const outputDir = options.outputDir ??
|
|
7217
|
+
const outputDir = options.outputDir ?? join17(options.downloadDir, PREPARED_HEIF_SUBDIR);
|
|
7204
7218
|
const outputSrcPrefix = normalizeRelPath(options.outputSrcPrefix ?? PREPARED_HEIF_SUBDIR);
|
|
7205
7219
|
const cacheDir = options.cacheDir ?? outputDir;
|
|
7206
7220
|
const preparedAssets = /* @__PURE__ */ new Map();
|
|
@@ -7221,7 +7235,7 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7221
7235
|
await Promise.all(
|
|
7222
7236
|
[...unique].map(
|
|
7223
7237
|
([filename, source]) => withMediaProbeSlot(
|
|
7224
|
-
() => ensurePreparedJpeg(source,
|
|
7238
|
+
() => ensurePreparedJpeg(source, join17(cacheDir, filename), join17(outputDir, filename), options)
|
|
7225
7239
|
).catch((error) => {
|
|
7226
7240
|
if (!options.onFailure) throw error;
|
|
7227
7241
|
failed.add(filename);
|
|
@@ -7233,8 +7247,8 @@ async function prepareHeifImageInputs(html, options) {
|
|
|
7233
7247
|
if (failed.has(filename)) continue;
|
|
7234
7248
|
const outputSrc = `${outputSrcPrefix}/${filename}`;
|
|
7235
7249
|
img.setAttribute("src", outputSrc);
|
|
7236
|
-
preparedAssets.set(outputSrc,
|
|
7237
|
-
preparedImages.push({ sourceSrc: src, outputSrc, outputPath:
|
|
7250
|
+
preparedAssets.set(outputSrc, join17(outputDir, filename));
|
|
7251
|
+
preparedImages.push({ sourceSrc: src, outputSrc, outputPath: join17(outputDir, filename) });
|
|
7238
7252
|
}
|
|
7239
7253
|
return { html: document2.toString(), preparedAssets, preparedImages };
|
|
7240
7254
|
}
|
|
@@ -7244,7 +7258,7 @@ import { createStudioPositionSeekReapplyScript } from "@hyperframes/studio-serve
|
|
|
7244
7258
|
import { getPositionEditsRenderScript } from "@hyperframes/core/runtime/position-edits-render";
|
|
7245
7259
|
|
|
7246
7260
|
// src/services/assetMediaType.ts
|
|
7247
|
-
import { existsSync as
|
|
7261
|
+
import { existsSync as existsSync11 } from "node:fs";
|
|
7248
7262
|
import {
|
|
7249
7263
|
fingerprintElementId,
|
|
7250
7264
|
isNotMediaPayload,
|
|
@@ -7317,7 +7331,7 @@ async function preflightCompositionAssetMediaTypes(input) {
|
|
|
7317
7331
|
input.projectDir,
|
|
7318
7332
|
input.compiledDir
|
|
7319
7333
|
);
|
|
7320
|
-
if (!
|
|
7334
|
+
if (!existsSync11(resolvedPath)) continue;
|
|
7321
7335
|
byPath.set(resolvedPath, [...byPath.get(resolvedPath) ?? [], reference]);
|
|
7322
7336
|
}
|
|
7323
7337
|
const mismatches = [];
|
|
@@ -7570,8 +7584,8 @@ function detectShaderTransitionUsage(html) {
|
|
|
7570
7584
|
async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, downloadDir, tagName, elementIdentity, log, urlByAbsentLocalPath, probes) {
|
|
7571
7585
|
let filePath = src;
|
|
7572
7586
|
if (isHttpUrl(src)) {
|
|
7573
|
-
const remoteDir =
|
|
7574
|
-
if (!
|
|
7587
|
+
const remoteDir = join18(downloadDir, REMOTE_MEDIA_SUBDIR);
|
|
7588
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
7575
7589
|
try {
|
|
7576
7590
|
filePath = await downloadToTemp(src, remoteDir, void 0, void 0, void 0, {
|
|
7577
7591
|
onTelemetry: logRemoteDownloadTelemetry
|
|
@@ -7581,10 +7595,10 @@ async function resolveMediaDuration(src, mediaStart, playbackRate, baseDir, down
|
|
|
7581
7595
|
}
|
|
7582
7596
|
} else {
|
|
7583
7597
|
filePath = decodedUrlPath2(src);
|
|
7584
|
-
if (!filePath.startsWith("/")) filePath =
|
|
7598
|
+
if (!filePath.startsWith("/")) filePath = join18(baseDir, filePath);
|
|
7585
7599
|
filePath = urlByAbsentLocalPath?.get(filePath) ?? filePath;
|
|
7586
7600
|
}
|
|
7587
|
-
if (!isHttpUrl(filePath) && !
|
|
7601
|
+
if (!isHttpUrl(filePath) && !existsSync12(filePath)) {
|
|
7588
7602
|
return { duration: null, resolvedPath: filePath };
|
|
7589
7603
|
}
|
|
7590
7604
|
const withSrcContext = (error) => {
|
|
@@ -7933,7 +7947,7 @@ function inlineSubCompositions(html, subCompositions, projectDir, variableOverri
|
|
|
7933
7947
|
parseHtml: (htmlStr) => parseHTML5(htmlStr).document,
|
|
7934
7948
|
// Mirrors the preview bundler: a sub-composition's SIBLING assets resolve
|
|
7935
7949
|
// against its own directory, project-root refs stay as authored.
|
|
7936
|
-
assetExists: (path) =>
|
|
7950
|
+
assetExists: (path) => existsSync12(resolve7(projectDir, path)),
|
|
7937
7951
|
// Preserve the authored root wrapper as a child of the host, matching
|
|
7938
7952
|
// the preview bundler's shape (htmlBundler.ts's prepareFlattenedInnerRoot,
|
|
7939
7953
|
// which the runtime compositionLoader mirrors with its own copy for the
|
|
@@ -8078,12 +8092,17 @@ async function inlineExternalScripts(html) {
|
|
|
8078
8092
|
if (externalScripts.length === 0) return html;
|
|
8079
8093
|
const downloads = await Promise.allSettled(
|
|
8080
8094
|
externalScripts.map(async ({ el, src }) => {
|
|
8095
|
+
const integrity = el.getAttribute("integrity") || "";
|
|
8096
|
+
const bundled = bundledScript(src);
|
|
8097
|
+
if (bundled && matchesScriptIntegrity(bundled, integrity)) {
|
|
8098
|
+
return { src, text: new TextDecoder().decode(bundled) };
|
|
8099
|
+
}
|
|
8081
8100
|
const response = await fetch(src, {
|
|
8082
8101
|
signal: AbortSignal.timeout(15e3)
|
|
8083
8102
|
});
|
|
8084
8103
|
if (!response.ok) throw new Error(`HTTP ${response.status} for ${src}`);
|
|
8085
8104
|
const bytes = new Uint8Array(await response.arrayBuffer());
|
|
8086
|
-
if (!matchesScriptIntegrity(bytes,
|
|
8105
|
+
if (!matchesScriptIntegrity(bytes, integrity)) {
|
|
8087
8106
|
throw new ScriptIntegrityError(`Subresource integrity mismatch for ${src}`);
|
|
8088
8107
|
}
|
|
8089
8108
|
return { src, text: new TextDecoder().decode(bytes) };
|
|
@@ -8124,7 +8143,7 @@ function collectExternalAssets(html, projectDir) {
|
|
|
8124
8143
|
if (isPathInside2(absPath, absProjectDir)) {
|
|
8125
8144
|
return null;
|
|
8126
8145
|
}
|
|
8127
|
-
if (!
|
|
8146
|
+
if (!existsSync12(absPath)) return null;
|
|
8128
8147
|
const safeKey = toExternalAssetKey(absPath);
|
|
8129
8148
|
externalAssets.set(safeKey, absPath);
|
|
8130
8149
|
return safeKey;
|
|
@@ -8174,7 +8193,7 @@ var REMOTE_SOURCE_TAG_RE = /<source\b[^>]*?\bsrc\s*=\s*["'](https?:\/\/[^"']+)["
|
|
|
8174
8193
|
var REMOTE_IMG_TAG_RE = /<img\b[^>]*?(?<![\w-])src\s*=\s*["'](https?:\/\/[^"']+)["'][^>]*>/gi;
|
|
8175
8194
|
async function downloadAndRewriteUrls(urlSet, html, remoteDir, warnLabel, logLabel, extraRewrite) {
|
|
8176
8195
|
if (urlSet.size === 0) return { html, remoteMediaAssets: /* @__PURE__ */ new Map() };
|
|
8177
|
-
if (!
|
|
8196
|
+
if (!existsSync12(remoteDir)) mkdirSync9(remoteDir, { recursive: true });
|
|
8178
8197
|
const urlToLocal = /* @__PURE__ */ new Map();
|
|
8179
8198
|
await Promise.all(
|
|
8180
8199
|
[...urlSet].map(async (url) => {
|
|
@@ -8221,7 +8240,7 @@ async function localizeRemoteMediaSources(html, downloadDir) {
|
|
|
8221
8240
|
return downloadAndRewriteUrls(
|
|
8222
8241
|
urlSet,
|
|
8223
8242
|
html,
|
|
8224
|
-
|
|
8243
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8225
8244
|
"Remote media download failed",
|
|
8226
8245
|
"Localized remote media source(s)"
|
|
8227
8246
|
);
|
|
@@ -8236,7 +8255,7 @@ async function localizeRemoteImageSources(html, downloadDir) {
|
|
|
8236
8255
|
return downloadAndRewriteUrls(
|
|
8237
8256
|
urlSet,
|
|
8238
8257
|
html,
|
|
8239
|
-
|
|
8258
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8240
8259
|
"Remote image download failed",
|
|
8241
8260
|
"Localized remote image source(s)"
|
|
8242
8261
|
);
|
|
@@ -8252,7 +8271,7 @@ async function localizeRemoteBackgroundImages(html, downloadDir) {
|
|
|
8252
8271
|
return downloadAndRewriteUrls(
|
|
8253
8272
|
urlSet,
|
|
8254
8273
|
html,
|
|
8255
|
-
|
|
8274
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8256
8275
|
"Remote background-image download failed",
|
|
8257
8276
|
"Localized remote background-image(s)",
|
|
8258
8277
|
// Quoted url('..')/url("..") are rewritten by downloadAndRewriteUrls' default
|
|
@@ -8357,13 +8376,13 @@ function projectStylesheetFontFamilies(html, projectDir) {
|
|
|
8357
8376
|
const href = /\bhref=["']([^"']+)["']/i.exec(tag)?.[1];
|
|
8358
8377
|
if (!href || /^(?:[a-z][a-z\d+.-]*:|\/\/)/i.test(href)) continue;
|
|
8359
8378
|
const sheet = resolve7(projectDir, decodedUrlPath2(href).replace(/^(?:\.?\/)+/, ""));
|
|
8360
|
-
if (!isPathInside2(sheet, projectDir) || !
|
|
8361
|
-
for (const face of extractFontFaceBlocks(
|
|
8379
|
+
if (!isPathInside2(sheet, projectDir) || !existsSync12(sheet)) continue;
|
|
8380
|
+
for (const face of extractFontFaceBlocks(readFileSync8(sheet, "utf8"))) {
|
|
8362
8381
|
const family = /font-family\s*:\s*([^;}]+)/i.exec(face)?.[1]?.trim().replace(/^['"]|['"]$/g, "");
|
|
8363
8382
|
const shipsFile = [...face.matchAll(LOCAL_FONTFACE_URL_RE)].some(([, url = ""]) => {
|
|
8364
8383
|
const path = decodedUrlPath2(url);
|
|
8365
8384
|
const file = path.startsWith("/") ? resolve7(projectDir, `.${path}`) : resolve7(dirname8(sheet), path);
|
|
8366
|
-
return isPathInside2(file, projectDir) &&
|
|
8385
|
+
return isPathInside2(file, projectDir) && existsSync12(file);
|
|
8367
8386
|
});
|
|
8368
8387
|
if (family && shipsFile) families.push(family);
|
|
8369
8388
|
}
|
|
@@ -8404,7 +8423,7 @@ function localizeFontFaceUrls(html, downloadDir) {
|
|
|
8404
8423
|
return downloadAndRewriteUrls(
|
|
8405
8424
|
collectFontFaceUrls(html),
|
|
8406
8425
|
html,
|
|
8407
|
-
|
|
8426
|
+
join18(downloadDir, REMOTE_MEDIA_SUBDIR),
|
|
8408
8427
|
"Remote font download failed",
|
|
8409
8428
|
"Localized remote font face(s)",
|
|
8410
8429
|
(h, url, relPath) => h.replaceAll(`url(${url})`, `url("${relPath}")`)
|
|
@@ -8488,7 +8507,7 @@ async function embedLocalFontFaces(html, projectDir) {
|
|
|
8488
8507
|
}
|
|
8489
8508
|
function renderGsapDist() {
|
|
8490
8509
|
try {
|
|
8491
|
-
return
|
|
8510
|
+
return gsapCdnDist2(void 0, normalizeGsapBaseUrl(process.env.HYPERFRAMES_GSAP_BASE_URL));
|
|
8492
8511
|
} catch (cause) {
|
|
8493
8512
|
throw new Error(
|
|
8494
8513
|
"Invalid HYPERFRAMES_GSAP_BASE_URL: use an absolute HTTPS npm mirror root (plain HTTP only for localhost) without credentials, query, or fragment",
|
|
@@ -8498,7 +8517,7 @@ function renderGsapDist() {
|
|
|
8498
8517
|
}
|
|
8499
8518
|
function rewriteUnresolvableGsapToCdn(html, projectDir, compSrcPath) {
|
|
8500
8519
|
let gsapDist;
|
|
8501
|
-
const exists = (path) =>
|
|
8520
|
+
const exists = (path) => existsSync12(resolve7(projectDir, path));
|
|
8502
8521
|
return html.replace(
|
|
8503
8522
|
/(<script\b[^>]*\bsrc=["'])([^"']*gsap[^"']*\/dist\/([^"']+))(["'][^>]*>)/gi,
|
|
8504
8523
|
(full, prefix, src, file, suffix) => {
|
|
@@ -8515,7 +8534,7 @@ function rebaseDirectEntryAssetPaths(html, projectDir, htmlPath) {
|
|
|
8515
8534
|
const entryPath = relative2(projectDir, htmlPath).replace(/\\/g, "/");
|
|
8516
8535
|
if (!entryPath.includes("/")) return html;
|
|
8517
8536
|
const { document: document2 } = parseHTML5(html);
|
|
8518
|
-
const assetExists = (path) =>
|
|
8537
|
+
const assetExists = (path) => existsSync12(resolve7(projectDir, path));
|
|
8519
8538
|
rewriteAssetPaths(
|
|
8520
8539
|
document2.querySelectorAll("[src], [href], [srcset]"),
|
|
8521
8540
|
entryPath,
|
|
@@ -9081,11 +9100,11 @@ function adaptAspectAgnosticResolution(requested, aspectAgnostic, width, height,
|
|
|
9081
9100
|
}
|
|
9082
9101
|
function resolveEntryHtmlPath(input) {
|
|
9083
9102
|
const { projectDir, workDir, entryFile, log } = input;
|
|
9084
|
-
const htmlPath =
|
|
9103
|
+
const htmlPath = join19(projectDir, entryFile);
|
|
9085
9104
|
const rawEntry = readTextFile2(htmlPath);
|
|
9086
9105
|
if (entryFile === "index.html" || !isTemplateEntry(rawEntry)) return htmlPath;
|
|
9087
|
-
const projectIndexPath =
|
|
9088
|
-
if (!
|
|
9106
|
+
const projectIndexPath = join19(projectDir, "index.html");
|
|
9107
|
+
if (!existsSync13(projectIndexPath)) {
|
|
9089
9108
|
throw new Error(
|
|
9090
9109
|
`Template entry file "${entryFile}" requires a project index.html to extract its render shell.`
|
|
9091
9110
|
);
|
|
@@ -9100,7 +9119,7 @@ function resolveEntryHtmlPath(input) {
|
|
|
9100
9119
|
`Entry file "${entryFile}" is not mounted from index.html via data-composition-src, so it cannot be rendered independently.`
|
|
9101
9120
|
);
|
|
9102
9121
|
}
|
|
9103
|
-
const wrapperPath =
|
|
9122
|
+
const wrapperPath = join19(workDir, "standalone-entry.html");
|
|
9104
9123
|
writeFileSync5(wrapperPath, standaloneHtml, "utf-8");
|
|
9105
9124
|
log.info("Extracted standalone entry from index.html host context", { entryFile });
|
|
9106
9125
|
return wrapperPath;
|
|
@@ -9121,7 +9140,7 @@ async function runCompileStage(input) {
|
|
|
9121
9140
|
} = input;
|
|
9122
9141
|
const htmlPath = resolveEntryHtmlPath({ projectDir, workDir, entryFile, log });
|
|
9123
9142
|
const compileStart = Date.now();
|
|
9124
|
-
const compiled = await compileForRender(projectDir, htmlPath,
|
|
9143
|
+
const compiled = await compileForRender(projectDir, htmlPath, join19(workDir, "downloads"), {
|
|
9125
9144
|
log,
|
|
9126
9145
|
failClosedFontFetch: failClosedFontFetch === true,
|
|
9127
9146
|
allowSystemFontCapture,
|
|
@@ -9129,7 +9148,7 @@ async function runCompileStage(input) {
|
|
|
9129
9148
|
variables: input.variables,
|
|
9130
9149
|
urlByAbsentLocalPath: input.urlByAbsentLocalPath,
|
|
9131
9150
|
pageMotionBlur: input.pageMotionBlur,
|
|
9132
|
-
animatedGifCacheDir: cfg.extractCacheDir ?
|
|
9151
|
+
animatedGifCacheDir: cfg.extractCacheDir ? join19(cfg.extractCacheDir, "animated-gif") : void 0,
|
|
9133
9152
|
ffmpegProcessTimeout: cfg.ffmpegProcessTimeout
|
|
9134
9153
|
});
|
|
9135
9154
|
assertNotAborted();
|
|
@@ -9186,7 +9205,7 @@ async function runCompileStage(input) {
|
|
|
9186
9205
|
};
|
|
9187
9206
|
await preflightCompositionAssetMediaTypes({
|
|
9188
9207
|
projectDir,
|
|
9189
|
-
compiledDir:
|
|
9208
|
+
compiledDir: join19(workDir, "compiled"),
|
|
9190
9209
|
composition,
|
|
9191
9210
|
signal: abortSignal
|
|
9192
9211
|
});
|
|
@@ -9232,7 +9251,7 @@ async function runCompileStage(input) {
|
|
|
9232
9251
|
|
|
9233
9252
|
// src/services/render/stages/probeStage.ts
|
|
9234
9253
|
import { createHash as createHash7 } from "node:crypto";
|
|
9235
|
-
import { basename as basename6, join as
|
|
9254
|
+
import { basename as basename6, join as join20 } from "node:path";
|
|
9236
9255
|
import { parseHTML as parseHTML6 } from "linkedom";
|
|
9237
9256
|
import {
|
|
9238
9257
|
closeCaptureSession as closeCaptureSession4,
|
|
@@ -9441,7 +9460,7 @@ async function runProbeStage(input) {
|
|
|
9441
9460
|
});
|
|
9442
9461
|
fileServer = await createFileServer({
|
|
9443
9462
|
projectDir,
|
|
9444
|
-
compiledDir:
|
|
9463
|
+
compiledDir: join20(workDir, "compiled"),
|
|
9445
9464
|
port: 0,
|
|
9446
9465
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
9447
9466
|
fps: job.config.fps
|
|
@@ -9471,7 +9490,7 @@ async function runProbeStage(input) {
|
|
|
9471
9490
|
log.info("Creating capture session...", { attempt, maxAttempts: PROBE_MAX_ATTEMPTS });
|
|
9472
9491
|
probeSession = await createCaptureSession4(
|
|
9473
9492
|
fileServer.url,
|
|
9474
|
-
|
|
9493
|
+
join20(workDir, "probe"),
|
|
9475
9494
|
captureOpts,
|
|
9476
9495
|
null,
|
|
9477
9496
|
probeCfg
|
|
@@ -9556,7 +9575,7 @@ async function runProbeStage(input) {
|
|
|
9556
9575
|
});
|
|
9557
9576
|
probeSession = await createCaptureSession4(
|
|
9558
9577
|
fileServer.url,
|
|
9559
|
-
|
|
9578
|
+
join20(workDir, "probe-screenshot"),
|
|
9560
9579
|
captureOpts,
|
|
9561
9580
|
null,
|
|
9562
9581
|
{ ...probeCfg, forceScreenshot: true }
|
|
@@ -9594,7 +9613,7 @@ async function runProbeStage(input) {
|
|
|
9594
9613
|
compiled,
|
|
9595
9614
|
resolutions,
|
|
9596
9615
|
projectDir,
|
|
9597
|
-
|
|
9616
|
+
join20(workDir, "downloads")
|
|
9598
9617
|
);
|
|
9599
9618
|
assertNotAborted();
|
|
9600
9619
|
composition.videos = compiled.videos;
|
|
@@ -9785,7 +9804,7 @@ async function runProbeStage(input) {
|
|
|
9785
9804
|
}
|
|
9786
9805
|
await preflightCompositionAssetMediaTypes({
|
|
9787
9806
|
projectDir,
|
|
9788
|
-
compiledDir:
|
|
9807
|
+
compiledDir: join20(workDir, "compiled"),
|
|
9789
9808
|
composition,
|
|
9790
9809
|
signal: abortSignal
|
|
9791
9810
|
});
|
|
@@ -9919,8 +9938,8 @@ function validateRenderDuration(input) {
|
|
|
9919
9938
|
}
|
|
9920
9939
|
|
|
9921
9940
|
// src/services/render/stages/extractVideosStage.ts
|
|
9922
|
-
import { existsSync as
|
|
9923
|
-
import { join as
|
|
9941
|
+
import { existsSync as existsSync14 } from "node:fs";
|
|
9942
|
+
import { join as join21 } from "node:path";
|
|
9924
9943
|
import {
|
|
9925
9944
|
classifyVideoExtractionError,
|
|
9926
9945
|
createFrameLookupTable as createFrameLookupTable3,
|
|
@@ -10189,7 +10208,7 @@ async function runExtractVideosStage(input) {
|
|
|
10189
10208
|
const probeFailures = await Promise.all(
|
|
10190
10209
|
composition.videos.map(async (v) => {
|
|
10191
10210
|
const videoPath = resolveProjectRelativeSrc3(v.src, projectDir, compiledDir);
|
|
10192
|
-
if (!
|
|
10211
|
+
if (!existsSync14(videoPath)) return null;
|
|
10193
10212
|
try {
|
|
10194
10213
|
const attempted = extractionPolicy.maxTransientRetries === 0 ? { result: await extractMediaMetadata3(videoPath), retries: 0 } : await runVideoExtractionWithRetry2(() => extractMediaMetadata3(videoPath), {
|
|
10195
10214
|
signal: abortSignal,
|
|
@@ -10227,7 +10246,7 @@ async function runExtractVideosStage(input) {
|
|
|
10227
10246
|
const probed = await Promise.all(
|
|
10228
10247
|
composition.images.map(async (img) => {
|
|
10229
10248
|
const imgPath = resolveProjectRelativeSrc3(img.src, projectDir, compiledDir);
|
|
10230
|
-
if (!
|
|
10249
|
+
if (!existsSync14(imgPath)) return null;
|
|
10231
10250
|
const colorSpace = await probeColorSpaceSafely(imgPath, log);
|
|
10232
10251
|
if (isHdrColorSpace2(colorSpace)) {
|
|
10233
10252
|
nativeHdrImageIds.add(img.id);
|
|
@@ -10261,14 +10280,14 @@ async function runExtractVideosStage(input) {
|
|
|
10261
10280
|
// because short boundary counts can differ by one frame.
|
|
10262
10281
|
{
|
|
10263
10282
|
fps: job.config.fps,
|
|
10264
|
-
outputDir:
|
|
10283
|
+
outputDir: join21(compiledDir, "__hyperframes_video_frames"),
|
|
10265
10284
|
format: job.config.videoFrameFormat ?? "auto",
|
|
10266
10285
|
toneMapHdrToSdr: rendersSdrOnly(job.config, composition),
|
|
10267
10286
|
timelineEnd: composition.duration,
|
|
10268
10287
|
maxTransientRetries: extractionPolicy.maxTransientRetries,
|
|
10269
10288
|
collectProbeFailures: extractionPolicy.failureMode === "enforce",
|
|
10270
10289
|
deferRangeExtraction,
|
|
10271
|
-
contentKeyedDirs: [
|
|
10290
|
+
contentKeyedDirs: [join21(compiledDir, REMOTE_MEDIA_SUBDIR)],
|
|
10272
10291
|
urlByAbsentLocalPath,
|
|
10273
10292
|
onProgress: ({ planned = 0, done = 0 }) => {
|
|
10274
10293
|
framesPlanned += planned;
|
|
@@ -10347,7 +10366,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10347
10366
|
videos.map(async (video) => {
|
|
10348
10367
|
const path = isHttpUrl2(video.src) ? video.src : resolveProjectRelativeSrc3(video.src, projectDir, compiledDir);
|
|
10349
10368
|
const readFrom = urlByAbsentLocalPath?.get(path) ?? path;
|
|
10350
|
-
if (!isHttpUrl2(readFrom) && !
|
|
10369
|
+
if (!isHttpUrl2(readFrom) && !existsSync14(readFrom)) return null;
|
|
10351
10370
|
const metadata = await extractMediaMetadata3(readFrom);
|
|
10352
10371
|
const window2 = await resolveFinalFrameExtractionWindow2(
|
|
10353
10372
|
readFrom,
|
|
@@ -10367,7 +10386,7 @@ async function appendVideoAudioFromProbe(input) {
|
|
|
10367
10386
|
}
|
|
10368
10387
|
|
|
10369
10388
|
// src/services/render/videoLayerPassthroughPlan.ts
|
|
10370
|
-
import { existsSync as
|
|
10389
|
+
import { existsSync as existsSync15 } from "node:fs";
|
|
10371
10390
|
import {
|
|
10372
10391
|
buildVideoLayerInput,
|
|
10373
10392
|
isHttpUrl as isHttpUrl3,
|
|
@@ -10435,7 +10454,7 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10435
10454
|
const { video } = q;
|
|
10436
10455
|
if (isHttpUrl3(video.src)) return { reason: "remote_source" };
|
|
10437
10456
|
const path = resolveProjectRelativeSrc4(video.src, input.projectDir, input.compiledDir);
|
|
10438
|
-
if (!
|
|
10457
|
+
if (!existsSync15(path)) return { reason: "source_missing" };
|
|
10439
10458
|
const layout = await probeVideoLayout(input.page, video.id, input.canvas, input.duration);
|
|
10440
10459
|
if ("reason" in layout) return layout;
|
|
10441
10460
|
const layer = await buildVideoLayerInput(
|
|
@@ -10450,8 +10469,8 @@ async function planVideoLayerPassthrough(input) {
|
|
|
10450
10469
|
}
|
|
10451
10470
|
|
|
10452
10471
|
// src/services/render/stages/audioStage.ts
|
|
10453
|
-
import { existsSync as
|
|
10454
|
-
import { join as
|
|
10472
|
+
import { existsSync as existsSync17 } from "node:fs";
|
|
10473
|
+
import { join as join24 } from "node:path";
|
|
10455
10474
|
import {
|
|
10456
10475
|
MIXED_AUDIO_FILENAME,
|
|
10457
10476
|
audioFailureDiagnostics,
|
|
@@ -10461,8 +10480,8 @@ import {
|
|
|
10461
10480
|
} from "@hyperframes/engine";
|
|
10462
10481
|
|
|
10463
10482
|
// src/services/render/audioDeliveryLimit.ts
|
|
10464
|
-
import { existsSync as
|
|
10465
|
-
import { dirname as dirname10, join as
|
|
10483
|
+
import { existsSync as existsSync16 } from "node:fs";
|
|
10484
|
+
import { dirname as dirname10, join as join23 } from "node:path";
|
|
10466
10485
|
import {
|
|
10467
10486
|
applyAudioFxChain,
|
|
10468
10487
|
describeFfmpegFailure as describeFfmpegFailure3,
|
|
@@ -10472,7 +10491,7 @@ import {
|
|
|
10472
10491
|
|
|
10473
10492
|
// src/services/render/audioPadTrim.ts
|
|
10474
10493
|
import { spawn } from "node:child_process";
|
|
10475
|
-
import { dirname as dirname9, join as
|
|
10494
|
+
import { dirname as dirname9, join as join22 } from "node:path";
|
|
10476
10495
|
import {
|
|
10477
10496
|
DEFAULT_CONFIG,
|
|
10478
10497
|
describeFfmpegFailure as describeFfmpegFailure2,
|
|
@@ -10752,7 +10771,7 @@ async function constrainAacTruePeak(input) {
|
|
|
10752
10771
|
}
|
|
10753
10772
|
async function cutSource(input, scratchDir, attenuationDb) {
|
|
10754
10773
|
if (!input.sourcePath || !input.rewriteSource) return true;
|
|
10755
|
-
const cutPath =
|
|
10774
|
+
const cutPath = join22(scratchDir, "source.wav");
|
|
10756
10775
|
try {
|
|
10757
10776
|
const result = await input.rewriteSource(input.sourcePath, cutPath, gainFilter(attenuationDb));
|
|
10758
10777
|
if (!result.success) throw new Error(result.error);
|
|
@@ -10767,7 +10786,7 @@ async function enforceAacTruePeak(input) {
|
|
|
10767
10786
|
let scratchDir;
|
|
10768
10787
|
try {
|
|
10769
10788
|
scratchDir = createStagingDir3(dirname9(input.audioPath), ".true-peak-");
|
|
10770
|
-
const correctedPath =
|
|
10789
|
+
const correctedPath = join22(scratchDir, "audio.m4a");
|
|
10771
10790
|
const measurements = [];
|
|
10772
10791
|
let attenuationDb = 0;
|
|
10773
10792
|
let sourcePeakDbfs;
|
|
@@ -10970,14 +10989,14 @@ async function limitDeliveryPeaks(input, deps = {
|
|
|
10970
10989
|
applyChain: applyAudioFxChain,
|
|
10971
10990
|
encode: encodeAac2,
|
|
10972
10991
|
rename: renameWithRetry6,
|
|
10973
|
-
sourceExists:
|
|
10992
|
+
sourceExists: existsSync16
|
|
10974
10993
|
}) {
|
|
10975
10994
|
const { audioPath, sourcePath, signal, timeoutMs } = input;
|
|
10976
10995
|
if (!deps.sourceExists(sourcePath)) return { success: true };
|
|
10977
10996
|
const peak = await deps.measure(audioPath, { timeoutMs, signal });
|
|
10978
10997
|
if (peak <= AAC_DELIVERY_TRUE_PEAK_DBFS) return { success: true };
|
|
10979
10998
|
const alternating = ["a", "b"].map(
|
|
10980
|
-
(k) =>
|
|
10999
|
+
(k) => join23(dirname10(sourcePath), `audio-source-limited-${k}.wav`)
|
|
10981
11000
|
);
|
|
10982
11001
|
let encodedFrom;
|
|
10983
11002
|
let ceiling = AAC_DELIVERY_TRUE_PEAK_DBFS;
|
|
@@ -11049,7 +11068,7 @@ function runAudioStage(input) {
|
|
|
11049
11068
|
}
|
|
11050
11069
|
async function runAudioStageScoped(input) {
|
|
11051
11070
|
const stageStart = Date.now();
|
|
11052
|
-
const pcmSourcePath =
|
|
11071
|
+
const pcmSourcePath = join24(input.workDir, "audio-source.wav");
|
|
11053
11072
|
const duration = input.totalFrames * input.fps.den / input.fps.num;
|
|
11054
11073
|
let deliverySourcePath;
|
|
11055
11074
|
try {
|
|
@@ -11065,7 +11084,7 @@ async function runAudioStageScoped(input) {
|
|
|
11065
11084
|
);
|
|
11066
11085
|
audioLoweredDb = guard.loweredDb;
|
|
11067
11086
|
input.log?.info("[audio] phases", { ...result.audioPhaseMs, guard: Date.now() - guardStart });
|
|
11068
|
-
if (input.keepDeliverySource && !guard.sourceStale &&
|
|
11087
|
+
if (input.keepDeliverySource && !guard.sourceStale && existsSync17(pcmSourcePath)) {
|
|
11069
11088
|
deliverySourcePath = pcmSourcePath;
|
|
11070
11089
|
}
|
|
11071
11090
|
}
|
|
@@ -11114,7 +11133,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11114
11133
|
assertNotAborted,
|
|
11115
11134
|
log
|
|
11116
11135
|
} = input;
|
|
11117
|
-
const audioOutputPath =
|
|
11136
|
+
const audioOutputPath = join24(workDir, MIXED_AUDIO_FILENAME);
|
|
11118
11137
|
let hasAudio = false;
|
|
11119
11138
|
let audioError;
|
|
11120
11139
|
let audioFailures;
|
|
@@ -11125,7 +11144,7 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11125
11144
|
audioResult = await processCompositionAudio(
|
|
11126
11145
|
audios,
|
|
11127
11146
|
projectDir,
|
|
11128
|
-
|
|
11147
|
+
join24(workDir, "audio-work"),
|
|
11129
11148
|
audioOutputPath,
|
|
11130
11149
|
duration,
|
|
11131
11150
|
abortSignal,
|
|
@@ -11193,8 +11212,8 @@ async function mixAudioForDelivery(input, duration, pcmSourcePath) {
|
|
|
11193
11212
|
}
|
|
11194
11213
|
|
|
11195
11214
|
// src/services/render/stages/captureStage.ts
|
|
11196
|
-
import { existsSync as
|
|
11197
|
-
import { join as
|
|
11215
|
+
import { existsSync as existsSync18, readdirSync as readdirSync4, statfsSync as statfsSync2 } from "node:fs";
|
|
11216
|
+
import { join as join25 } from "node:path";
|
|
11198
11217
|
import {
|
|
11199
11218
|
classifyCaptureFailure as classifyCaptureFailure2,
|
|
11200
11219
|
frameFileExtension,
|
|
@@ -11264,16 +11283,16 @@ function diskCaptureShortfallError(needBytes, freeBytes, framesDir, basis, remed
|
|
|
11264
11283
|
}
|
|
11265
11284
|
function measureCaptureFrameBytes(workDir, framesDir) {
|
|
11266
11285
|
let total = sampleDirectoryBytes(framesDir);
|
|
11267
|
-
if (!
|
|
11286
|
+
if (!existsSync18(workDir)) return total;
|
|
11268
11287
|
for (const attempt of readdirSync4(workDir)) {
|
|
11269
11288
|
if (/^retry-\d+-batch-\d+-worker-\d+$/.test(attempt)) {
|
|
11270
|
-
total += sampleDirectoryBytes(
|
|
11289
|
+
total += sampleDirectoryBytes(join25(workDir, attempt));
|
|
11271
11290
|
continue;
|
|
11272
11291
|
}
|
|
11273
11292
|
if (!/^capture-attempt-\d+$/.test(attempt)) continue;
|
|
11274
|
-
const attemptDir =
|
|
11293
|
+
const attemptDir = join25(workDir, attempt);
|
|
11275
11294
|
for (const name of readdirSync4(attemptDir)) {
|
|
11276
|
-
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(
|
|
11295
|
+
if (/^worker-\d+$/.test(name)) total += sampleDirectoryBytes(join25(attemptDir, name));
|
|
11277
11296
|
}
|
|
11278
11297
|
}
|
|
11279
11298
|
return total;
|
|
@@ -11571,8 +11590,8 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
11571
11590
|
}
|
|
11572
11591
|
|
|
11573
11592
|
// src/services/render/stages/captureHdrStage.ts
|
|
11574
|
-
import { existsSync as
|
|
11575
|
-
import { join as
|
|
11593
|
+
import { existsSync as existsSync20, mkdirSync as mkdirSync10 } from "node:fs";
|
|
11594
|
+
import { join as join29 } from "node:path";
|
|
11576
11595
|
import {
|
|
11577
11596
|
closeCaptureSession as closeCaptureSession7,
|
|
11578
11597
|
cloneCaptureWarnings as cloneCaptureWarnings2,
|
|
@@ -11644,7 +11663,7 @@ function createHdrImageTransferCache(options = {}) {
|
|
|
11644
11663
|
}
|
|
11645
11664
|
|
|
11646
11665
|
// src/services/render/stages/captureHdrSequentialLoop.ts
|
|
11647
|
-
import { join as
|
|
11666
|
+
import { join as join26 } from "node:path";
|
|
11648
11667
|
import {
|
|
11649
11668
|
TRANSITIONS,
|
|
11650
11669
|
crossfade
|
|
@@ -11769,7 +11788,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11769
11788
|
);
|
|
11770
11789
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
11771
11790
|
writeFileExclusiveSync(
|
|
11772
|
-
|
|
11791
|
+
join26(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
11773
11792
|
normalCanvas
|
|
11774
11793
|
);
|
|
11775
11794
|
}
|
|
@@ -11801,7 +11820,7 @@ async function runSequentialLayeredFrameLoop(input) {
|
|
|
11801
11820
|
}
|
|
11802
11821
|
|
|
11803
11822
|
// src/services/render/stages/captureHdrHybridLoop.ts
|
|
11804
|
-
import { join as
|
|
11823
|
+
import { join as join28 } from "node:path";
|
|
11805
11824
|
import {
|
|
11806
11825
|
TRANSITIONS as TRANSITIONS2,
|
|
11807
11826
|
closeCaptureSession as closeCaptureSession6,
|
|
@@ -11815,9 +11834,9 @@ import {
|
|
|
11815
11834
|
// src/services/shaderTransitionWorkerPool.ts
|
|
11816
11835
|
import { Worker } from "node:worker_threads";
|
|
11817
11836
|
import { fileURLToPath as fileURLToPath3, pathToFileURL } from "node:url";
|
|
11818
|
-
import { dirname as dirname11, join as
|
|
11837
|
+
import { dirname as dirname11, join as join27 } from "node:path";
|
|
11819
11838
|
import { createRequire } from "node:module";
|
|
11820
|
-
import { existsSync as
|
|
11839
|
+
import { existsSync as existsSync19 } from "node:fs";
|
|
11821
11840
|
import { cpus as cpus2 } from "node:os";
|
|
11822
11841
|
function resolveWorkerEntry(explicit) {
|
|
11823
11842
|
if (explicit && explicit.length > 0) {
|
|
@@ -11829,9 +11848,9 @@ function resolveWorkerEntry(explicit) {
|
|
|
11829
11848
|
return { path: override, isTs };
|
|
11830
11849
|
}
|
|
11831
11850
|
const moduleDir = dirname11(fileURLToPath3(import.meta.url));
|
|
11832
|
-
const jsPath =
|
|
11833
|
-
if (
|
|
11834
|
-
const tsPath =
|
|
11851
|
+
const jsPath = join27(moduleDir, "shaderTransitionWorker.js");
|
|
11852
|
+
if (existsSync19(jsPath)) return { path: jsPath, isTs: false };
|
|
11853
|
+
const tsPath = join27(moduleDir, "shaderTransitionWorker.ts");
|
|
11835
11854
|
return { path: tsPath, isTs: true };
|
|
11836
11855
|
}
|
|
11837
11856
|
function buildExecArgv(entryIsTs) {
|
|
@@ -12199,7 +12218,7 @@ async function runHybridLayeredFrameLoop(input) {
|
|
|
12199
12218
|
);
|
|
12200
12219
|
if (debugDumpEnabled && debugDumpDir && i % 30 === 0) {
|
|
12201
12220
|
writeFileExclusiveSync(
|
|
12202
|
-
|
|
12221
|
+
join28(debugDumpDir, `frame_${String(i).padStart(4, "0")}_final_rgb48le.bin`),
|
|
12203
12222
|
canvas
|
|
12204
12223
|
);
|
|
12205
12224
|
}
|
|
@@ -12390,8 +12409,8 @@ async function runCaptureHdrStage(input) {
|
|
|
12390
12409
|
if (hdrVideoFrameSources.has(v.id)) hdrVideoEndTimes.set(v.id, v.end);
|
|
12391
12410
|
}
|
|
12392
12411
|
const debugDumpEnabled = process.env.KEEP_TEMP === "1";
|
|
12393
|
-
const debugDumpDir = debugDumpEnabled ?
|
|
12394
|
-
if (debugDumpDir && !
|
|
12412
|
+
const debugDumpDir = debugDumpEnabled ? join29(framesDir, "debug-composite") : null;
|
|
12413
|
+
if (debugDumpDir && !existsSync20(debugDumpDir)) {
|
|
12395
12414
|
mkdirSync10(debugDumpDir, { recursive: true });
|
|
12396
12415
|
}
|
|
12397
12416
|
const compositeTransfer = resolveCompositeTransfer(hasHdrContent, effectiveHdr);
|
|
@@ -12548,16 +12567,16 @@ async function runCaptureHdrStage(input) {
|
|
|
12548
12567
|
// src/services/render/stages/encodeStage.ts
|
|
12549
12568
|
import {
|
|
12550
12569
|
copyFileSync as copyFileSync4,
|
|
12551
|
-
existsSync as
|
|
12570
|
+
existsSync as existsSync21,
|
|
12552
12571
|
mkdirSync as mkdirSync11,
|
|
12553
12572
|
readdirSync as readdirSync5,
|
|
12554
|
-
readFileSync as
|
|
12573
|
+
readFileSync as readFileSync9,
|
|
12555
12574
|
rmSync as rmSync11,
|
|
12556
12575
|
statSync as statSync8,
|
|
12557
12576
|
writeFileSync as writeFileSync6
|
|
12558
12577
|
} from "node:fs";
|
|
12559
12578
|
import { readFile as readFile2 } from "node:fs/promises";
|
|
12560
|
-
import { dirname as dirname12, join as
|
|
12579
|
+
import { dirname as dirname12, join as join30 } from "node:path";
|
|
12561
12580
|
import {
|
|
12562
12581
|
encodeFramesChunkedConcat,
|
|
12563
12582
|
encodeFramesFromDir,
|
|
@@ -12645,7 +12664,7 @@ async function reencodeWithClearedWholeFrames(argsInput, run, startTime) {
|
|
|
12645
12664
|
const error = formatFfmpegError(result.exitCode, result.stderr);
|
|
12646
12665
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
12647
12666
|
}
|
|
12648
|
-
const gif =
|
|
12667
|
+
const gif = readFileSync9(outputPath);
|
|
12649
12668
|
if (!clearGifFramesBeforeNext(gif)) {
|
|
12650
12669
|
const error = "[FFmpeg] GIF output could not be parsed to clear its frames";
|
|
12651
12670
|
return gifEncodeFailure(startTime, outputPath, error);
|
|
@@ -12678,11 +12697,11 @@ async function encodeGifFromDir(framesDir, framePattern, outputPath, input) {
|
|
|
12678
12697
|
return gifEncodeFailure(startTime, outputPath, error, result.failureReason);
|
|
12679
12698
|
}
|
|
12680
12699
|
}
|
|
12681
|
-
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(
|
|
12700
|
+
if (input.preserveAlpha && gifClearsAfterLeavingFrameInPlace(readFileSync9(outputPath)) !== false) {
|
|
12682
12701
|
const failure = await reencodeWithClearedWholeFrames(argsInput, run, startTime);
|
|
12683
12702
|
if (failure) return failure;
|
|
12684
12703
|
}
|
|
12685
|
-
const fileSize =
|
|
12704
|
+
const fileSize = existsSync21(outputPath) ? statSync8(outputPath).size : 0;
|
|
12686
12705
|
return {
|
|
12687
12706
|
success: true,
|
|
12688
12707
|
outputPath,
|
|
@@ -12768,7 +12787,7 @@ function encodeWhileCapturing(input, totalFrames) {
|
|
|
12768
12787
|
await new Promise((resolve11) => wake = resolve11);
|
|
12769
12788
|
}
|
|
12770
12789
|
if (signal.aborted) return;
|
|
12771
|
-
const mergedPath =
|
|
12790
|
+
const mergedPath = join30(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
12772
12791
|
const frame = await readLandedFrame(landed.get(next), mergedPath);
|
|
12773
12792
|
landed.delete(next);
|
|
12774
12793
|
if (!await stream.writeFrame(frame)) {
|
|
@@ -12843,7 +12862,7 @@ async function runEncodeStage(input) {
|
|
|
12843
12862
|
const stage5Start = Date.now();
|
|
12844
12863
|
if (isPngSequence) {
|
|
12845
12864
|
const encoded = startEncodeProgress(job, "Writing PNG sequence", onProgress);
|
|
12846
|
-
if (!
|
|
12865
|
+
if (!existsSync21(outputPath)) mkdirSync11(outputPath, { recursive: true });
|
|
12847
12866
|
const captured = readdirSync5(framesDir).filter((name) => name.endsWith(".png")).sort();
|
|
12848
12867
|
if (captured.length === 0) {
|
|
12849
12868
|
throw new Error(
|
|
@@ -12851,11 +12870,11 @@ async function runEncodeStage(input) {
|
|
|
12851
12870
|
);
|
|
12852
12871
|
}
|
|
12853
12872
|
captured.forEach((name, i) => {
|
|
12854
|
-
const dst =
|
|
12855
|
-
copyFileSync4(
|
|
12873
|
+
const dst = join30(outputPath, formatExportFrameName(i, "png"));
|
|
12874
|
+
copyFileSync4(join30(framesDir, name), dst);
|
|
12856
12875
|
});
|
|
12857
|
-
if (hasAudio && audioOutputPath &&
|
|
12858
|
-
copyFileSync4(audioOutputPath,
|
|
12876
|
+
if (hasAudio && audioOutputPath && existsSync21(audioOutputPath)) {
|
|
12877
|
+
copyFileSync4(audioOutputPath, join30(outputPath, MIXED_AUDIO_FILENAME2));
|
|
12859
12878
|
log.info(
|
|
12860
12879
|
`[Render] png-sequence: ${MIXED_AUDIO_FILENAME2} sidecar written to ${outputPath}/${MIXED_AUDIO_FILENAME2}`
|
|
12861
12880
|
);
|
|
@@ -12875,7 +12894,7 @@ async function runEncodeStage(input) {
|
|
|
12875
12894
|
const encodeResult2 = await encodeGifFromDir(framesDir, framePattern2, outputPath, {
|
|
12876
12895
|
fps: job.config.fps,
|
|
12877
12896
|
loop,
|
|
12878
|
-
palettePath:
|
|
12897
|
+
palettePath: join30(dirname12(videoOnlyPath), "gif-palette.png"),
|
|
12879
12898
|
preserveAlpha: needsAlpha,
|
|
12880
12899
|
signal: abortSignal,
|
|
12881
12900
|
timeout: engineCfg.ffmpegEncodeTimeout
|
|
@@ -13086,7 +13105,7 @@ function sampleDirectoryBytes(dir) {
|
|
|
13086
13105
|
continue;
|
|
13087
13106
|
}
|
|
13088
13107
|
for (const name of entries) {
|
|
13089
|
-
const full =
|
|
13108
|
+
const full = join31(current, name);
|
|
13090
13109
|
try {
|
|
13091
13110
|
const st = statSync9(full);
|
|
13092
13111
|
if (st.isDirectory()) {
|
|
@@ -13242,8 +13261,8 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13242
13261
|
const ranges = [];
|
|
13243
13262
|
let rangeStart = null;
|
|
13244
13263
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13245
|
-
const framePath =
|
|
13246
|
-
const missing = !
|
|
13264
|
+
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13265
|
+
const missing = !existsSync22(framePath) || statSync9(framePath).size <= 8;
|
|
13247
13266
|
if (missing && rangeStart === null) {
|
|
13248
13267
|
rangeStart = frameIndex;
|
|
13249
13268
|
} else if (!missing && rangeStart !== null) {
|
|
@@ -13259,7 +13278,7 @@ function findMissingFrameRanges(totalFrames, framesDir, frameExt) {
|
|
|
13259
13278
|
function buildMissingFrameRetryBatches(ranges, maxWorkers, workDir, attempt, rangeStart = 0, stride = 1) {
|
|
13260
13279
|
const workersPerBatch = Math.max(1, Math.floor(maxWorkers));
|
|
13261
13280
|
const batches = [];
|
|
13262
|
-
const outputDirFor = (batchIndex, workerId) =>
|
|
13281
|
+
const outputDirFor = (batchIndex, workerId) => join31(workDir, `retry-${attempt}-batch-${batchIndex}-worker-${workerId}`);
|
|
13263
13282
|
if (stride > 1) {
|
|
13264
13283
|
const spans = /* @__PURE__ */ new Map();
|
|
13265
13284
|
for (const range of ranges) {
|
|
@@ -13319,8 +13338,8 @@ function getNextRetryWorkerCount(currentWorkers) {
|
|
|
13319
13338
|
return Math.max(1, Math.floor(currentWorkers / 2));
|
|
13320
13339
|
}
|
|
13321
13340
|
function resolveRenderWorkDirPrefix(outputPath, jobId, platform2 = process.platform, systemTempDir = tmpdir2()) {
|
|
13322
|
-
if (platform2 === "win32" || platform2 === "darwin") return
|
|
13323
|
-
return
|
|
13341
|
+
if (platform2 === "win32" || platform2 === "darwin") return join31(systemTempDir, "hf-render-");
|
|
13342
|
+
return join31(dirname13(outputPath), `work-${jobId}-`);
|
|
13324
13343
|
}
|
|
13325
13344
|
var MAX_TRANSIENT_CAPTURE_RETRIES = 1;
|
|
13326
13345
|
function isTransientCaptureRetryEligible(failureKind, missing, retriesUsed) {
|
|
@@ -13367,8 +13386,8 @@ The composition is too large for the available memory. To reduce memory pressure
|
|
|
13367
13386
|
function countCapturedFrames(totalFrames, framesDir, frameExt) {
|
|
13368
13387
|
let captured = 0;
|
|
13369
13388
|
for (let frameIndex = 0; frameIndex < totalFrames; frameIndex++) {
|
|
13370
|
-
const framePath =
|
|
13371
|
-
if (
|
|
13389
|
+
const framePath = join31(framesDir, formatCaptureFrameName(frameIndex, frameExt));
|
|
13390
|
+
if (existsSync22(framePath)) captured++;
|
|
13372
13391
|
}
|
|
13373
13392
|
return captured;
|
|
13374
13393
|
}
|
|
@@ -13393,7 +13412,7 @@ async function executeDiskCaptureWithAdaptiveRetry(options) {
|
|
|
13393
13412
|
reason: attempt === 0 ? "initial" : pendingTransientRetry ? "transient-retry" : "retry"
|
|
13394
13413
|
});
|
|
13395
13414
|
pendingTransientRetry = false;
|
|
13396
|
-
const attemptWorkDir =
|
|
13415
|
+
const attemptWorkDir = join31(options.workDir, `capture-attempt-${attempt}`);
|
|
13397
13416
|
const batches = missingRanges ? buildMissingFrameRetryBatches(
|
|
13398
13417
|
missingRanges,
|
|
13399
13418
|
currentWorkers,
|
|
@@ -14026,18 +14045,18 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
14026
14045
|
}
|
|
14027
14046
|
function resolveRenderDebugDir() {
|
|
14028
14047
|
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve8(process.env.PRODUCER_RENDERS_DIR, "..") : resolve8(dirname13(fileURLToPath4(import.meta.url)), "../..");
|
|
14029
|
-
return
|
|
14048
|
+
return join31(producerRoot, ".debug");
|
|
14030
14049
|
}
|
|
14031
14050
|
async function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
14032
14051
|
validateHlsRenderConfig(job.config);
|
|
14033
14052
|
validateDeliveryEncoderConfig(job.config);
|
|
14034
14053
|
const debugDir = resolveRenderDebugDir();
|
|
14035
14054
|
const outputDir = dirname13(outputPath);
|
|
14036
|
-
if (!
|
|
14037
|
-
const workDir = job.config.debug ?
|
|
14055
|
+
if (!existsSync22(outputDir)) mkdirSync12(outputDir, { recursive: true });
|
|
14056
|
+
const workDir = job.config.debug ? join31(debugDir, job.id) : createRenderWorkDir(resolveRenderWorkDirPrefix(outputPath, job.id), outputDir);
|
|
14038
14057
|
const pipelineStart = Date.now();
|
|
14039
14058
|
const baseLog = job.config.logger ?? defaultLogger;
|
|
14040
|
-
const logPath = job.config.debug ?
|
|
14059
|
+
const logPath = job.config.debug ? join31(workDir, "render.log") : null;
|
|
14041
14060
|
const execution = new RenderExecutionContext({
|
|
14042
14061
|
request: { renderJobId: job.id, projectDir, outputPath },
|
|
14043
14062
|
logger: logPath ? createRenderFileLogger(logPath, baseLog) : baseLog,
|
|
@@ -14099,7 +14118,7 @@ async function executeRenderPipeline(input) {
|
|
|
14099
14118
|
imageDecodeFailures: 0
|
|
14100
14119
|
};
|
|
14101
14120
|
let hdrPerf;
|
|
14102
|
-
const perfOutputPath =
|
|
14121
|
+
const perfOutputPath = join31(workDir, "perf-summary.json");
|
|
14103
14122
|
const cfg = { ...job.config.producerConfig ?? resolveConfig2() };
|
|
14104
14123
|
const observability = new RenderObservabilityRecorder({
|
|
14105
14124
|
pipelineStartMs: pipelineStart,
|
|
@@ -14175,7 +14194,7 @@ async function executeRenderPipeline(input) {
|
|
|
14175
14194
|
job.startedAt = /* @__PURE__ */ new Date();
|
|
14176
14195
|
assertNotAborted();
|
|
14177
14196
|
assertConfiguredFfmpegBinariesExist();
|
|
14178
|
-
if (!
|
|
14197
|
+
if (!existsSync22(workDir)) mkdirSync12(workDir, { recursive: true });
|
|
14179
14198
|
if (job.config.debug) {
|
|
14180
14199
|
log.info("[Render] Debug artifacts enabled", { workDir, logPath });
|
|
14181
14200
|
}
|
|
@@ -14204,8 +14223,8 @@ async function executeRenderPipeline(input) {
|
|
|
14204
14223
|
requestedWorkers: job.config.workers ?? "auto"
|
|
14205
14224
|
});
|
|
14206
14225
|
const entryFile = job.config.entryFile || "index.html";
|
|
14207
|
-
const htmlPath =
|
|
14208
|
-
if (!
|
|
14226
|
+
const htmlPath = join31(projectDir, entryFile);
|
|
14227
|
+
if (!existsSync22(htmlPath)) {
|
|
14209
14228
|
throw new Error(`Entry file not found: ${htmlPath}`);
|
|
14210
14229
|
}
|
|
14211
14230
|
assertNotAborted();
|
|
@@ -14381,7 +14400,7 @@ async function executeRenderPipeline(input) {
|
|
|
14381
14400
|
canvas: { width, height },
|
|
14382
14401
|
page: probeSession.page,
|
|
14383
14402
|
projectDir,
|
|
14384
|
-
compiledDir:
|
|
14403
|
+
compiledDir: join31(workDir, "compiled")
|
|
14385
14404
|
});
|
|
14386
14405
|
if (videoLayerPlan.videoId === void 0) {
|
|
14387
14406
|
log.info(`[Render] Video layer passthrough off: ${videoLayerPlan.reason}`);
|
|
@@ -14399,7 +14418,7 @@ async function executeRenderPipeline(input) {
|
|
|
14399
14418
|
updateJobStatus(job, "preprocessing", "Extracting video frames", 10, onProgress, {
|
|
14400
14419
|
code: "extract_video"
|
|
14401
14420
|
});
|
|
14402
|
-
const compiledDir =
|
|
14421
|
+
const compiledDir = join31(workDir, "compiled");
|
|
14403
14422
|
const segmentsCapture = (layeredOrEffectRoute) => shouldSegmentCapture({
|
|
14404
14423
|
env: process.env,
|
|
14405
14424
|
durationSeconds: probeResult.duration,
|
|
@@ -14530,7 +14549,7 @@ async function executeRenderPipeline(input) {
|
|
|
14530
14549
|
try {
|
|
14531
14550
|
fileServer = await createFileServer({
|
|
14532
14551
|
projectDir,
|
|
14533
|
-
compiledDir:
|
|
14552
|
+
compiledDir: join31(workDir, "compiled"),
|
|
14534
14553
|
port: 0,
|
|
14535
14554
|
preHeadScripts: [VIRTUAL_TIME_SHIM],
|
|
14536
14555
|
fps: job.config.fps
|
|
@@ -14548,8 +14567,8 @@ async function executeRenderPipeline(input) {
|
|
|
14548
14567
|
if (!activeFileServer) {
|
|
14549
14568
|
throw new Error("File server failed to initialize before frame capture");
|
|
14550
14569
|
}
|
|
14551
|
-
const framesDir =
|
|
14552
|
-
if (!
|
|
14570
|
+
const framesDir = join31(workDir, "captured-frames");
|
|
14571
|
+
if (!existsSync22(framesDir)) mkdirSync12(framesDir, { recursive: true });
|
|
14553
14572
|
updateJobStatus(job, "rendering", "Checking browser GPU", 25, onProgress, {
|
|
14554
14573
|
code: "start_browsers"
|
|
14555
14574
|
});
|
|
@@ -15113,7 +15132,7 @@ async function executeRenderPipeline(input) {
|
|
|
15113
15132
|
hls: ".mp4"
|
|
15114
15133
|
};
|
|
15115
15134
|
const videoExt = FORMAT_EXT[outputFormat] ?? ".mp4";
|
|
15116
|
-
const videoOnlyPath =
|
|
15135
|
+
const videoOnlyPath = join31(workDir, `video-only${videoExt}`);
|
|
15117
15136
|
const usePageSideCompositingForTransitions = (cfg.enablePageSideCompositing || isGif) && compiled.hasShaderTransitions && !hasHdrContent && outputSupportsPageSideShaderCompositing(outputFormat);
|
|
15118
15137
|
if (usePageSideCompositingForTransitions) {
|
|
15119
15138
|
activeFileServer.addPreHeadScript(HF_PAGE_SIDE_COMPOSITING_STUB);
|
|
@@ -15399,7 +15418,7 @@ async function executeRenderPipeline(input) {
|
|
|
15399
15418
|
pageMotionBlur: job.config.pageMotionBlur,
|
|
15400
15419
|
captureQuality: captureOptions.quality
|
|
15401
15420
|
});
|
|
15402
|
-
const segmentDir = segmentDirFor(
|
|
15421
|
+
const segmentDir = segmentDirFor(join31(projectDir, "renders"), segmentPlanHash);
|
|
15403
15422
|
let completedSegments = /* @__PURE__ */ new Set();
|
|
15404
15423
|
if (job.config.resumeSegments === true) {
|
|
15405
15424
|
const existing = readSegmentManifest(segmentDir);
|
|
@@ -15940,7 +15959,7 @@ async function executeRenderPipeline(input) {
|
|
|
15940
15959
|
})
|
|
15941
15960
|
);
|
|
15942
15961
|
const totalElapsed = Date.now() - pipelineStart;
|
|
15943
|
-
const tmpPeakBytes =
|
|
15962
|
+
const tmpPeakBytes = existsSync22(workDir) ? sampleDirectoryBytes(workDir) : 0;
|
|
15944
15963
|
recordTransientRetryObservability();
|
|
15945
15964
|
observability.checkpoint("pipeline", "artifact validated", { totalElapsedMs: totalElapsed });
|
|
15946
15965
|
const observabilitySummary = observability.summary({
|
|
@@ -16021,8 +16040,8 @@ async function executeRenderPipeline(input) {
|
|
|
16021
16040
|
}
|
|
16022
16041
|
}
|
|
16023
16042
|
if (job.config.debug) {
|
|
16024
|
-
if (!isPngSequence && !isHls &&
|
|
16025
|
-
const debugOutput =
|
|
16043
|
+
if (!isPngSequence && !isHls && existsSync22(stagedOutputPath)) {
|
|
16044
|
+
const debugOutput = join31(workDir, `output${videoExt}`);
|
|
16026
16045
|
copyFileSync5(stagedOutputPath, debugOutput);
|
|
16027
16046
|
}
|
|
16028
16047
|
}
|
|
@@ -16133,15 +16152,15 @@ async function executeRenderPipeline(input) {
|
|
|
16133
16152
|
|
|
16134
16153
|
// src/services/hyperframeLint.ts
|
|
16135
16154
|
import {
|
|
16136
|
-
existsSync as
|
|
16137
|
-
readFileSync as
|
|
16155
|
+
existsSync as existsSync23,
|
|
16156
|
+
readFileSync as readFileSync10,
|
|
16138
16157
|
statSync as statSync10,
|
|
16139
16158
|
openSync as openSync5,
|
|
16140
16159
|
fstatSync as fstatSync3,
|
|
16141
16160
|
closeSync as closeSync5,
|
|
16142
16161
|
constants as constants3
|
|
16143
16162
|
} from "node:fs";
|
|
16144
|
-
import { resolve as resolve9, join as
|
|
16163
|
+
import { resolve as resolve9, join as join32, relative as relative3, isAbsolute as isAbsolute3, sep as sep3 } from "node:path";
|
|
16145
16164
|
import { lintHyperframeHtml } from "@hyperframes/lint";
|
|
16146
16165
|
function isStringRecord(value) {
|
|
16147
16166
|
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
@@ -16180,14 +16199,14 @@ function readEntryHtml(filePath) {
|
|
|
16180
16199
|
}
|
|
16181
16200
|
try {
|
|
16182
16201
|
if (!fstatSync3(fd).isFile()) return null;
|
|
16183
|
-
return
|
|
16202
|
+
return readFileSync10(fd, "utf-8");
|
|
16184
16203
|
} finally {
|
|
16185
16204
|
closeSync5(fd);
|
|
16186
16205
|
}
|
|
16187
16206
|
}
|
|
16188
16207
|
function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
16189
16208
|
const absProjectDir = resolve9(projectDir);
|
|
16190
|
-
if (!
|
|
16209
|
+
if (!existsSync23(absProjectDir) || !statSync10(absProjectDir).isDirectory()) {
|
|
16191
16210
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
16192
16211
|
}
|
|
16193
16212
|
const entryCandidates = [preferredEntryFile, "index.html", "src/index.html"].filter(
|
|
@@ -16209,7 +16228,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile) {
|
|
|
16209
16228
|
}
|
|
16210
16229
|
}
|
|
16211
16230
|
return {
|
|
16212
|
-
error: `No HTML entry file found in project directory: ${
|
|
16231
|
+
error: `No HTML entry file found in project directory: ${join32(absProjectDir, preferredEntryFile || "index.html")}`
|
|
16213
16232
|
};
|
|
16214
16233
|
}
|
|
16215
16234
|
function prepareHyperframeLintBody(body) {
|
|
@@ -16255,8 +16274,8 @@ async function runHyperframeLint(prepared) {
|
|
|
16255
16274
|
// src/services/healthWorker.ts
|
|
16256
16275
|
import { Worker as Worker2 } from "node:worker_threads";
|
|
16257
16276
|
import { fileURLToPath as fileURLToPath5 } from "node:url";
|
|
16258
|
-
import { dirname as dirname14, join as
|
|
16259
|
-
import { existsSync as
|
|
16277
|
+
import { dirname as dirname14, join as join33 } from "node:path";
|
|
16278
|
+
import { existsSync as existsSync24 } from "node:fs";
|
|
16260
16279
|
var DEFAULT_HEALTH_PORT = 9848;
|
|
16261
16280
|
async function startHealthWorker(options = {}) {
|
|
16262
16281
|
const log = options.logger ?? defaultLogger2();
|
|
@@ -16331,9 +16350,9 @@ function defaultLogger2() {
|
|
|
16331
16350
|
}
|
|
16332
16351
|
function resolveWorkerEntry2() {
|
|
16333
16352
|
const here = dirname14(fileURLToPath5(import.meta.url));
|
|
16334
|
-
const candidates = [
|
|
16353
|
+
const candidates = [join33(here, "healthWorkerThread.js"), join33(here, "healthWorkerThread.ts")];
|
|
16335
16354
|
for (const candidate of candidates) {
|
|
16336
|
-
if (
|
|
16355
|
+
if (existsSync24(candidate)) return candidate;
|
|
16337
16356
|
}
|
|
16338
16357
|
return void 0;
|
|
16339
16358
|
}
|
|
@@ -16373,7 +16392,7 @@ import {
|
|
|
16373
16392
|
createReferenceBackgroundRecorder as createReferenceBackgroundRecorder2
|
|
16374
16393
|
} from "@hyperframes/engine";
|
|
16375
16394
|
import { audioFailureDiagnostics as audioFailureDiagnostics3 } from "@hyperframes/engine";
|
|
16376
|
-
import { extname as extname4, isAbsolute as isAbsolute4, join as
|
|
16395
|
+
import { extname as extname4, isAbsolute as isAbsolute4, join as join34, relative as relative4, sep as sep4 } from "node:path";
|
|
16377
16396
|
import {
|
|
16378
16397
|
fpsToNumber as fpsToNumber9,
|
|
16379
16398
|
HF_COLOR_GRADING_ATTR as HF_COLOR_GRADING_ATTR2
|
|
@@ -16491,9 +16510,9 @@ var PLAN_ROOT_CATEGORY = {
|
|
|
16491
16510
|
var PLAN_DIR_SIZE_LIMIT_BYTES = 2 * 1024 * 1024 * 1024;
|
|
16492
16511
|
var FREEZE_OWNED_PLAN_FILES = [
|
|
16493
16512
|
"plan.json",
|
|
16494
|
-
|
|
16495
|
-
|
|
16496
|
-
|
|
16513
|
+
join34("meta", "composition.json"),
|
|
16514
|
+
join34("meta", "encoder.json"),
|
|
16515
|
+
join34("meta", "chunks.json")
|
|
16497
16516
|
];
|
|
16498
16517
|
|
|
16499
16518
|
// src/services/distributed/renderConfigValidation.ts
|
|
@@ -16883,7 +16902,7 @@ function resolvePreparedRenderOutput(prepared, rendersDir, log) {
|
|
|
16883
16902
|
const { input, cleanupProjectDir } = prepared;
|
|
16884
16903
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, input.outputPath, rendersDir, log);
|
|
16885
16904
|
const outputDir = dirname15(absoluteOutputPath);
|
|
16886
|
-
if (!
|
|
16905
|
+
if (!existsSync25(outputDir)) mkdirSync13(outputDir, { recursive: true });
|
|
16887
16906
|
return { input, cleanupProjectDir, absoluteOutputPath };
|
|
16888
16907
|
}
|
|
16889
16908
|
function validateRenderOverrides(body) {
|
|
@@ -16924,11 +16943,11 @@ function prepareProjectDirectory(projectDir, options) {
|
|
|
16924
16943
|
const candidate = nonEmptyString(projectDir);
|
|
16925
16944
|
if (!candidate) return null;
|
|
16926
16945
|
const absProjectDir = resolve10(candidate);
|
|
16927
|
-
if (!
|
|
16946
|
+
if (!existsSync25(absProjectDir) || !statSync11(absProjectDir).isDirectory()) {
|
|
16928
16947
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
16929
16948
|
}
|
|
16930
16949
|
const entry = options.entryFile || "index.html";
|
|
16931
|
-
if (!
|
|
16950
|
+
if (!existsSync25(resolve10(absProjectDir, entry))) {
|
|
16932
16951
|
return { error: `Entry file "${entry}" not found in project directory: ${absProjectDir}` };
|
|
16933
16952
|
}
|
|
16934
16953
|
return { prepared: { input: { projectDir: absProjectDir, ...options } } };
|
|
@@ -16949,8 +16968,8 @@ async function resolveInlineRenderHtml(body) {
|
|
|
16949
16968
|
}
|
|
16950
16969
|
function materializeInlineProject(html, options) {
|
|
16951
16970
|
const tempRoot = process.env.PRODUCER_TMP_PROJECT_DIR || tmpdir3();
|
|
16952
|
-
const tempProjectDir = mkdtempSync(
|
|
16953
|
-
writeFileSync8(
|
|
16971
|
+
const tempProjectDir = mkdtempSync(join35(tempRoot, "producer-project-"));
|
|
16972
|
+
writeFileSync8(join35(tempProjectDir, "index.html"), html, "utf-8");
|
|
16954
16973
|
return {
|
|
16955
16974
|
prepared: {
|
|
16956
16975
|
input: { projectDir: tempProjectDir, ...options },
|
|
@@ -17020,7 +17039,7 @@ function cleanupTempDir(dir, log) {
|
|
|
17020
17039
|
}
|
|
17021
17040
|
}
|
|
17022
17041
|
function outputFileSize(path) {
|
|
17023
|
-
return
|
|
17042
|
+
return existsSync25(path) ? statSync11(path).size : 0;
|
|
17024
17043
|
}
|
|
17025
17044
|
function createBlockingProgressReporter(log, requestId) {
|
|
17026
17045
|
let lastLoggedPct = -10;
|
|
@@ -17324,7 +17343,7 @@ function createRenderHandlers(options = {}) {
|
|
|
17324
17343
|
if (!artifact) {
|
|
17325
17344
|
return c.json({ success: false, error: "Output artifact not found or expired" }, 404);
|
|
17326
17345
|
}
|
|
17327
|
-
if (!
|
|
17346
|
+
if (!existsSync25(artifact.path)) {
|
|
17328
17347
|
store.delete(token);
|
|
17329
17348
|
return c.json({ success: false, error: "Output artifact file missing" }, 404);
|
|
17330
17349
|
}
|