@hyperframes/producer 0.9.94 → 0.9.96
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/compileWorker.js +6 -2
- package/dist/distributed.js +49 -30
- package/dist/hyperframe.manifest.json +1 -1
- package/dist/hyperframe.runtime.iife.js +67 -67
- package/dist/index.js +89 -57
- package/dist/public-server.js +80 -48
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -361,7 +361,8 @@ import {
|
|
|
361
361
|
referenceBackgroundResult,
|
|
362
362
|
createReferenceBackgroundRecorder
|
|
363
363
|
} from "@hyperframes/engine";
|
|
364
|
-
import { join as join35, dirname as dirname16, resolve as
|
|
364
|
+
import { join as join35, dirname as dirname16, resolve as resolve10 } from "path";
|
|
365
|
+
import { fromEmptyFolder } from "@hyperframes/parsers/ff-binaries";
|
|
365
366
|
import { totalmem as totalmem2 } from "node:os";
|
|
366
367
|
import { randomUUID as randomUUID3 } from "crypto";
|
|
367
368
|
import { fileURLToPath as fileURLToPath5 } from "url";
|
|
@@ -369,7 +370,11 @@ import { fileURLToPath as fileURLToPath5 } from "url";
|
|
|
369
370
|
// src/services/fileServer.ts
|
|
370
371
|
import { Hono } from "hono";
|
|
371
372
|
import { serve } from "@hono/node-server";
|
|
372
|
-
import {
|
|
373
|
+
import {
|
|
374
|
+
answerOwnLoopbackHostOnly,
|
|
375
|
+
boundedPageText,
|
|
376
|
+
settleOnBrowserSafePort
|
|
377
|
+
} from "@hyperframes/engine";
|
|
373
378
|
import {
|
|
374
379
|
existsSync as existsSync2,
|
|
375
380
|
realpathSync,
|
|
@@ -1129,12 +1134,13 @@ function closeFileServerSafely(fileServer, label, log = defaultLogger) {
|
|
|
1129
1134
|
});
|
|
1130
1135
|
}
|
|
1131
1136
|
}
|
|
1137
|
+
var NO_FILE_AT_NAME = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR", "ENAMETOOLONG"]);
|
|
1132
1138
|
function openRegularFile(filePath) {
|
|
1133
1139
|
let fd;
|
|
1134
1140
|
try {
|
|
1135
1141
|
fd = openSync(filePath, constants.O_RDONLY | constants.O_NONBLOCK);
|
|
1136
1142
|
} catch (error) {
|
|
1137
|
-
if (error instanceof Error && "code" in error && (error.code
|
|
1143
|
+
if (error instanceof Error && "code" in error && NO_FILE_AT_NAME.has(String(error.code)))
|
|
1138
1144
|
return null;
|
|
1139
1145
|
if (!statSync2(filePath, { throwIfNoEntry: false })?.isFile()) return null;
|
|
1140
1146
|
throw error;
|
|
@@ -1197,7 +1203,7 @@ function createFileServer(options) {
|
|
|
1197
1203
|
}
|
|
1198
1204
|
if (!file) {
|
|
1199
1205
|
if (!/favicon\.ico$/i.test(requestPath)) {
|
|
1200
|
-
console.warn(`[FileServer] 404 Not Found: ${terminalText2(requestPath)}`);
|
|
1206
|
+
console.warn(`[FileServer] 404 Not Found: ${terminalText2(boundedPageText(requestPath))}`);
|
|
1201
1207
|
}
|
|
1202
1208
|
return c.text("Not found", 404);
|
|
1203
1209
|
}
|
|
@@ -1271,13 +1277,13 @@ function createFileServer(options) {
|
|
|
1271
1277
|
if (!streamOwnsFd) closeSync(fd);
|
|
1272
1278
|
}
|
|
1273
1279
|
});
|
|
1274
|
-
return new Promise((
|
|
1280
|
+
return new Promise((resolve15, reject) => {
|
|
1275
1281
|
const connections = /* @__PURE__ */ new Set();
|
|
1276
1282
|
const server = serve({ fetch: app.fetch, port, hostname: "127.0.0.1" }, (info) => {
|
|
1277
1283
|
const bound = port === 0 ? settleOnBrowserSafePort(server, "127.0.0.1") : Promise.resolve(info.port);
|
|
1278
1284
|
bound.then((boundPort) => {
|
|
1279
1285
|
listeningPort = boundPort;
|
|
1280
|
-
|
|
1286
|
+
resolve15({
|
|
1281
1287
|
url: `http://localhost:${boundPort}`,
|
|
1282
1288
|
port: boundPort,
|
|
1283
1289
|
addPreHeadScript: (script) => {
|
|
@@ -1968,8 +1974,8 @@ var OrderedRenderEventPublisher = class {
|
|
|
1968
1974
|
let timer;
|
|
1969
1975
|
const drained = await Promise.race([
|
|
1970
1976
|
this.tail.then(() => true),
|
|
1971
|
-
new Promise((
|
|
1972
|
-
timer = setTimeout(() =>
|
|
1977
|
+
new Promise((resolve15) => {
|
|
1978
|
+
timer = setTimeout(() => resolve15(false), FLUSH_TIMEOUT_MS);
|
|
1973
1979
|
})
|
|
1974
1980
|
]);
|
|
1975
1981
|
clearTimeout(timer);
|
|
@@ -2645,6 +2651,7 @@ import {
|
|
|
2645
2651
|
concatVideoFiles,
|
|
2646
2652
|
createCaptureSession as createCaptureSession2,
|
|
2647
2653
|
getCapturePerfSummary as getCapturePerfSummary2,
|
|
2654
|
+
retainCapturePerf as retainCapturePerf3,
|
|
2648
2655
|
initializeSession as initializeSession2,
|
|
2649
2656
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse2,
|
|
2650
2657
|
resolveDeVerifyMinDb as resolveDeVerifyMinDb2,
|
|
@@ -2658,7 +2665,7 @@ import { CaptureFailure, classifyCaptureFailure } from "@hyperframes/engine";
|
|
|
2658
2665
|
// src/services/render/perfSummary.ts
|
|
2659
2666
|
import { arch, platform, totalmem } from "node:os";
|
|
2660
2667
|
import { fpsToNumber as fpsToNumber2 } from "@hyperframes/core";
|
|
2661
|
-
import { hostCpuCount } from "@hyperframes/engine";
|
|
2668
|
+
import { hostCpuCount, retainCapturePerf } from "@hyperframes/engine";
|
|
2662
2669
|
|
|
2663
2670
|
// src/services/render/hdrPerf.ts
|
|
2664
2671
|
function createHdrPerfCollector() {
|
|
@@ -2774,7 +2781,7 @@ function worstSubTimelineWaitOutcome(perfs) {
|
|
|
2774
2781
|
}
|
|
2775
2782
|
function pushWorkerDedupPerfs(results, sink) {
|
|
2776
2783
|
for (const r of results) {
|
|
2777
|
-
if (r.perf) sink
|
|
2784
|
+
if (r.perf) retainCapturePerf(sink, r.perf);
|
|
2778
2785
|
}
|
|
2779
2786
|
}
|
|
2780
2787
|
function capturedBeyondViewport(perfs, fallback) {
|
|
@@ -4612,6 +4619,7 @@ import {
|
|
|
4612
4619
|
distributeFramesInterleaved,
|
|
4613
4620
|
executeParallelCapture,
|
|
4614
4621
|
getCapturePerfSummary,
|
|
4622
|
+
retainCapturePerf as retainCapturePerf2,
|
|
4615
4623
|
psnrDb,
|
|
4616
4624
|
resolveDeVerifyMinDb,
|
|
4617
4625
|
recaptureDrawElementFrameForVerify,
|
|
@@ -4693,7 +4701,7 @@ var SequentialCaptureStallError = class extends Error {
|
|
|
4693
4701
|
}
|
|
4694
4702
|
};
|
|
4695
4703
|
function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
4696
|
-
return new Promise((
|
|
4704
|
+
return new Promise((resolve15, reject) => {
|
|
4697
4705
|
const clock = createStallClock();
|
|
4698
4706
|
const trip = () => reject(
|
|
4699
4707
|
signal?.aborted ? new Error(
|
|
@@ -4718,7 +4726,7 @@ function raceAgainstStall(promise, deadlineMs, input, signal) {
|
|
|
4718
4726
|
promise.then(
|
|
4719
4727
|
(value) => {
|
|
4720
4728
|
clearTimeout(timer);
|
|
4721
|
-
|
|
4729
|
+
resolve15(value);
|
|
4722
4730
|
},
|
|
4723
4731
|
(error) => {
|
|
4724
4732
|
clearTimeout(timer);
|
|
@@ -5340,7 +5348,7 @@ async function runCaptureStreamingStage(input) {
|
|
|
5340
5348
|
);
|
|
5341
5349
|
}
|
|
5342
5350
|
}
|
|
5343
|
-
dedupPerfs
|
|
5351
|
+
retainCapturePerf2(dedupPerfs, getCapturePerfSummary(session));
|
|
5344
5352
|
} catch (error) {
|
|
5345
5353
|
lastBrowserConsole = session.browserConsoleBuffer;
|
|
5346
5354
|
if (!resumesAfterStall(error, abortSignal, resume, resumes)) {
|
|
@@ -5640,7 +5648,7 @@ async function openSegmentWorkersTogether(run, workersToCloseLater) {
|
|
|
5640
5648
|
if (failure && failure.status === "rejected") throw failure.reason;
|
|
5641
5649
|
}
|
|
5642
5650
|
async function recycleWorkerSession(run, worker, why) {
|
|
5643
|
-
run.input.dedupPerfs
|
|
5651
|
+
retainCapturePerf3(run.input.dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
|
|
5644
5652
|
const memory = worker.ctx.session.chromeMemory?.stats();
|
|
5645
5653
|
await run.deps.closeSession(worker.ctx.session);
|
|
5646
5654
|
const { frames } = worker.ctx;
|
|
@@ -5769,7 +5777,8 @@ async function runCaptureSegmentedStage(input) {
|
|
|
5769
5777
|
assertNotAborted();
|
|
5770
5778
|
await openSegmentWorkersTogether(run, workers);
|
|
5771
5779
|
const outcomes = await Promise.allSettled(workers.map((w) => runWorkerLoop(w)));
|
|
5772
|
-
for (const worker of workers)
|
|
5780
|
+
for (const worker of workers)
|
|
5781
|
+
retainCapturePerf3(dedupPerfs, getCapturePerfSummary2(worker.ctx.session));
|
|
5773
5782
|
const failure = outcomes.find((o) => o.status === "rejected");
|
|
5774
5783
|
if (failure && failure.status === "rejected") throw failure.reason;
|
|
5775
5784
|
} catch (error) {
|
|
@@ -7244,7 +7253,7 @@ function requireOutputDimensions(expected, width, height) {
|
|
|
7244
7253
|
|
|
7245
7254
|
// src/services/render/stages/compileStage.ts
|
|
7246
7255
|
import { existsSync as existsSync13, writeFileSync as writeFileSync5 } from "node:fs";
|
|
7247
|
-
import { join as join23, relative as relative5 } from "node:path";
|
|
7256
|
+
import { join as join23, relative as relative5, resolve as resolve9 } from "node:path";
|
|
7248
7257
|
import { privateCacheRoot } from "@hyperframes/engine";
|
|
7249
7258
|
import { suggestMatchingPreset } from "@hyperframes/core";
|
|
7250
7259
|
import { extractStandaloneEntryFromIndex, isTemplateEntry } from "@hyperframes/core/compiler";
|
|
@@ -7253,6 +7262,7 @@ import { assertCompositionFileSize as assertCompositionFileSize2 } from "@hyperf
|
|
|
7253
7262
|
|
|
7254
7263
|
// src/services/compileInWorker.ts
|
|
7255
7264
|
import { existsSync as existsSync12, rmSync as rmSync11 } from "node:fs";
|
|
7265
|
+
import { ffmpegCwd } from "@hyperframes/parsers/ff-binaries";
|
|
7256
7266
|
import { dirname as dirname11, isAbsolute as isAbsolute4, join as join22, relative as relative4, resolve as resolvePath } from "node:path";
|
|
7257
7267
|
import { fileURLToPath as fileURLToPath3 } from "node:url";
|
|
7258
7268
|
import { Worker } from "node:worker_threads";
|
|
@@ -7324,6 +7334,7 @@ import { gsapCdnDist, normalizeGsapBaseUrl } from "@hyperframes/core/gsap-cdn";
|
|
|
7324
7334
|
import {
|
|
7325
7335
|
assignBundledRuntimeCompositionIds,
|
|
7326
7336
|
assignMediaRenderIds,
|
|
7337
|
+
dropAuthoredCompositionFiles,
|
|
7327
7338
|
emitVariablesByCompScript,
|
|
7328
7339
|
inlineSubCompositions as inlineSubCompositionsShared,
|
|
7329
7340
|
ensureExternalLinkTag,
|
|
@@ -7981,10 +7992,10 @@ var Semaphore = class {
|
|
|
7981
7992
|
this.active++;
|
|
7982
7993
|
return () => this.release();
|
|
7983
7994
|
}
|
|
7984
|
-
return new Promise((
|
|
7995
|
+
return new Promise((resolve15) => {
|
|
7985
7996
|
this.queue.push(() => {
|
|
7986
7997
|
this.active++;
|
|
7987
|
-
|
|
7998
|
+
resolve15(() => this.release());
|
|
7988
7999
|
});
|
|
7989
8000
|
});
|
|
7990
8001
|
}
|
|
@@ -8786,7 +8797,7 @@ var AssetDownloads = class {
|
|
|
8786
8797
|
}
|
|
8787
8798
|
async download(url, destDir) {
|
|
8788
8799
|
while (this.running >= ASSET_DOWNLOADS_AT_ONCE) {
|
|
8789
|
-
await new Promise((
|
|
8800
|
+
await new Promise((resolve15) => this.queued.push(resolve15));
|
|
8790
8801
|
}
|
|
8791
8802
|
if (this.signal?.aborted) {
|
|
8792
8803
|
this.queued.shift()?.();
|
|
@@ -9175,6 +9186,7 @@ function coalesceHeadStylesAndBodyScripts(html) {
|
|
|
9175
9186
|
}
|
|
9176
9187
|
function inlineSubCompositions(html, subCompositions, projectDir, variableOverrides, assetRoot, outsideFiles, budget) {
|
|
9177
9188
|
const { document: document2 } = parseHTML5(html);
|
|
9189
|
+
dropAuthoredCompositionFiles(document2);
|
|
9178
9190
|
budget.chargeElements(ENTRY_PAGE, document2.querySelectorAll("*").length);
|
|
9179
9191
|
const head = document2.querySelector("head");
|
|
9180
9192
|
const body = document2.querySelector("body");
|
|
@@ -10705,9 +10717,15 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10705
10717
|
if (!entry) return compileForRender(projectDir, htmlPath, downloadDir, options);
|
|
10706
10718
|
abortSignal?.throwIfAborted();
|
|
10707
10719
|
const timeoutMs = worker.timeoutMs ?? compileTimeoutMs();
|
|
10708
|
-
return new Promise((
|
|
10720
|
+
return new Promise((resolve15, reject) => {
|
|
10709
10721
|
const thread = new Worker(entry, {
|
|
10710
|
-
workerData: {
|
|
10722
|
+
workerData: {
|
|
10723
|
+
projectDir,
|
|
10724
|
+
htmlPath,
|
|
10725
|
+
downloadDir,
|
|
10726
|
+
options: cloneable,
|
|
10727
|
+
emptyFolder: ffmpegCwd() !== void 0
|
|
10728
|
+
}
|
|
10711
10729
|
});
|
|
10712
10730
|
const children = /* @__PURE__ */ new Map();
|
|
10713
10731
|
const scratchRoots = [downloadDir, options.animatedGifCacheDir].flatMap(
|
|
@@ -10761,7 +10779,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10761
10779
|
log?.[message.level](message.message ?? "", message.meta);
|
|
10762
10780
|
} else if (message.type === "result" && message.compiled) {
|
|
10763
10781
|
const { compiled } = message;
|
|
10764
|
-
settle(() =>
|
|
10782
|
+
settle(() => resolve15(compiled));
|
|
10765
10783
|
retire(ADVISORY_GRACE_MS);
|
|
10766
10784
|
} else if (message.type === "error" && message.error) {
|
|
10767
10785
|
const { error } = message;
|
|
@@ -10793,7 +10811,7 @@ async function compileForRenderInWorker(projectDir, htmlPath, downloadDir, optio
|
|
|
10793
10811
|
// src/services/render/stages/compileStage.ts
|
|
10794
10812
|
function animatedGifCacheDir(extractCacheDir) {
|
|
10795
10813
|
try {
|
|
10796
|
-
const root = extractCacheDir && privateCacheRoot(extractCacheDir);
|
|
10814
|
+
const root = extractCacheDir && privateCacheRoot(resolve9(extractCacheDir));
|
|
10797
10815
|
return root ? join23(root, "animated-gif") : void 0;
|
|
10798
10816
|
} catch {
|
|
10799
10817
|
return void 0;
|
|
@@ -12516,7 +12534,7 @@ import {
|
|
|
12516
12534
|
} from "@hyperframes/engine";
|
|
12517
12535
|
|
|
12518
12536
|
// src/services/render/audioPadTrim.ts
|
|
12519
|
-
import { localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12537
|
+
import { ffmpegCwd as ffmpegCwd2, localContainerInputArgs } from "@hyperframes/parsers/ff-binaries";
|
|
12520
12538
|
import { spawn } from "node:child_process";
|
|
12521
12539
|
import { dirname as dirname12, join as join26 } from "node:path";
|
|
12522
12540
|
import {
|
|
@@ -12987,6 +13005,7 @@ async function spawnFfprobeJson(args, env, signal) {
|
|
|
12987
13005
|
const proc = spawn(getFfprobeBinary(), args, {
|
|
12988
13006
|
...env && { env },
|
|
12989
13007
|
stdio: ["ignore", "pipe", "pipe"],
|
|
13008
|
+
cwd: ffmpegCwd2(),
|
|
12990
13009
|
windowsHide: true
|
|
12991
13010
|
});
|
|
12992
13011
|
trackChildProcess(proc);
|
|
@@ -13274,6 +13293,7 @@ import {
|
|
|
13274
13293
|
completeDeferredDrawElementInit as completeDeferredDrawElementInit3,
|
|
13275
13294
|
createCaptureSession as createCaptureSession5,
|
|
13276
13295
|
getCapturePerfSummary as getCapturePerfSummary3,
|
|
13296
|
+
retainCapturePerf as retainCapturePerf4,
|
|
13277
13297
|
initializeSession as initializeSession5,
|
|
13278
13298
|
prepareCaptureSessionForReuse as prepareCaptureSessionForReuse3
|
|
13279
13299
|
} from "@hyperframes/engine";
|
|
@@ -13635,7 +13655,7 @@ async function captureSessionFrames(session, { input, rangeStart, rangeEnd, resu
|
|
|
13635
13655
|
},
|
|
13636
13656
|
false
|
|
13637
13657
|
);
|
|
13638
|
-
dedupPerfs
|
|
13658
|
+
retainCapturePerf4(dedupPerfs, getCapturePerfSummary3(session));
|
|
13639
13659
|
}
|
|
13640
13660
|
|
|
13641
13661
|
// src/services/render/stages/captureHdrStage.ts
|
|
@@ -14051,8 +14071,8 @@ async function createShaderTransitionWorkerPool(opts) {
|
|
|
14051
14071
|
if (terminated) {
|
|
14052
14072
|
throw new Error("shader-blend pool already terminated");
|
|
14053
14073
|
}
|
|
14054
|
-
return new Promise((
|
|
14055
|
-
const task = traceEnabled ? { req, resolve:
|
|
14074
|
+
return new Promise((resolve15, reject) => {
|
|
14075
|
+
const task = traceEnabled ? { req, resolve: resolve15, reject, enqueuedAtMs: Date.now(), traceId: ++nextTaskId } : { req, resolve: resolve15, reject };
|
|
14056
14076
|
const idle = slots.find((s) => !s.busy && !s.dead);
|
|
14057
14077
|
if (idle) {
|
|
14058
14078
|
queue.unshift(task);
|
|
@@ -14881,7 +14901,7 @@ function encodeWhileCapturing(input, totalFrames, captureBudget) {
|
|
|
14881
14901
|
const stream = await encoder;
|
|
14882
14902
|
for (let next = 0; next < totalFrames; next++) {
|
|
14883
14903
|
while (!landed.has(next) && !captureDone && !signal.aborted) {
|
|
14884
|
-
await new Promise((
|
|
14904
|
+
await new Promise((resolve15) => wake = resolve15);
|
|
14885
14905
|
}
|
|
14886
14906
|
if (signal.aborted) return;
|
|
14887
14907
|
const mergedPath = join34(input.framesDir, formatCaptureFrameName(next, "jpg"));
|
|
@@ -16173,10 +16193,22 @@ function deVerifyFallbackTelemetry(err) {
|
|
|
16173
16193
|
};
|
|
16174
16194
|
}
|
|
16175
16195
|
function resolveRenderDebugDir() {
|
|
16176
|
-
const producerRoot = process.env.PRODUCER_RENDERS_DIR ?
|
|
16196
|
+
const producerRoot = process.env.PRODUCER_RENDERS_DIR ? resolve10(process.env.PRODUCER_RENDERS_DIR, "..") : resolve10(dirname16(fileURLToPath5(import.meta.url)), "../..");
|
|
16177
16197
|
return join35(producerRoot, ".debug");
|
|
16178
16198
|
}
|
|
16179
|
-
|
|
16199
|
+
function executeRenderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
16200
|
+
return fromEmptyFolder(
|
|
16201
|
+
() => renderJob(
|
|
16202
|
+
job,
|
|
16203
|
+
resolve10(projectDir),
|
|
16204
|
+
resolve10(outputPath),
|
|
16205
|
+
progressSink,
|
|
16206
|
+
abortSignal,
|
|
16207
|
+
assertRenderActive
|
|
16208
|
+
)
|
|
16209
|
+
);
|
|
16210
|
+
}
|
|
16211
|
+
async function renderJob(job, projectDir, outputPath, progressSink, abortSignal, assertRenderActive) {
|
|
16180
16212
|
validateHlsRenderConfig(job.config);
|
|
16181
16213
|
validateDeliveryEncoderConfig(job.config);
|
|
16182
16214
|
validateChromaSubsamplingConfig(job.config);
|
|
@@ -19556,7 +19588,7 @@ async function readPlanReferenceBackground(input) {
|
|
|
19556
19588
|
|
|
19557
19589
|
// src/services/render/stages/freezePlan.ts
|
|
19558
19590
|
import { existsSync as existsSync25, mkdirSync as mkdirSync15, readFileSync as readFileSync12, readdirSync as readdirSync8, writeFileSync as writeFileSync8 } from "node:fs";
|
|
19559
|
-
import { join as join41, relative as relative6, resolve as
|
|
19591
|
+
import { join as join41, relative as relative6, resolve as resolve11 } from "node:path";
|
|
19560
19592
|
import {
|
|
19561
19593
|
REFERENCE_BACKGROUND_FIELD,
|
|
19562
19594
|
referenceBackgroundResult as referenceBackgroundResult3
|
|
@@ -19770,7 +19802,7 @@ function stripUndefined(value) {
|
|
|
19770
19802
|
}
|
|
19771
19803
|
function listPlanFiles(planDir) {
|
|
19772
19804
|
const results = [];
|
|
19773
|
-
const rootResolved =
|
|
19805
|
+
const rootResolved = resolve11(planDir);
|
|
19774
19806
|
function walk(dir) {
|
|
19775
19807
|
const entries = readdirSync8(dir, { withFileTypes: true });
|
|
19776
19808
|
for (const entry of entries) {
|
|
@@ -21201,7 +21233,7 @@ import {
|
|
|
21201
21233
|
writeFileSync as writeFileSync12
|
|
21202
21234
|
} from "node:fs";
|
|
21203
21235
|
import { tmpdir as tmpdir4 } from "node:os";
|
|
21204
|
-
import { dirname as dirname20, isAbsolute as isAbsolute6, join as join47, relative as relative9, resolve as
|
|
21236
|
+
import { dirname as dirname20, isAbsolute as isAbsolute6, join as join47, relative as relative9, resolve as resolve12, sep as sep6 } from "node:path";
|
|
21205
21237
|
import { DISTRIBUTED_FPS, isDistributedFps } from "@hyperframes/core";
|
|
21206
21238
|
import {
|
|
21207
21239
|
createFrameLookupTable as createFrameLookupTable5,
|
|
@@ -21360,7 +21392,7 @@ function assertSafeRelativePath(path) {
|
|
|
21360
21392
|
}
|
|
21361
21393
|
function listFiles(root) {
|
|
21362
21394
|
const files = [];
|
|
21363
|
-
const rootResolved =
|
|
21395
|
+
const rootResolved = resolve12(root);
|
|
21364
21396
|
function walk(dir) {
|
|
21365
21397
|
for (const entry of readdirSync10(dir, { withFileTypes: true })) {
|
|
21366
21398
|
const absolutePath = join47(dir, entry.name);
|
|
@@ -21406,8 +21438,8 @@ function isExtractionCacheCompleteSentinelPath(path) {
|
|
|
21406
21438
|
return segments.length === 3 && segments[0] === "video-frames" && segments[1] !== "" && segments[2] === EXTRACTION_CACHE_COMPLETE_SENTINEL;
|
|
21407
21439
|
}
|
|
21408
21440
|
function resolveExtractedVideoOutputDir(planDir, videoId) {
|
|
21409
|
-
const videoRoot =
|
|
21410
|
-
const outputDir =
|
|
21441
|
+
const videoRoot = resolve12(planDir, "video-frames");
|
|
21442
|
+
const outputDir = resolve12(videoRoot, mediaIdPathSegment4(videoId));
|
|
21411
21443
|
if (outputDir === videoRoot || !outputDir.startsWith(`${videoRoot}${sep6}`)) {
|
|
21412
21444
|
throw new PlanV2IntegrityError(`unsafe extracted video id: ${JSON.stringify(videoId)}`);
|
|
21413
21445
|
}
|
|
@@ -21568,7 +21600,7 @@ function collectChunkVideoDependencies(input) {
|
|
|
21568
21600
|
for (let frame = chunk.startFrame; frame < chunk.endFrame; frame++) {
|
|
21569
21601
|
const globalTime = frame * input.fpsDen / input.fpsNum;
|
|
21570
21602
|
for (const [videoId, payload] of input.table.getActiveFramePayloads(globalTime)) {
|
|
21571
|
-
const path = input.deferredSources.get(videoId) ?? relative9(
|
|
21603
|
+
const path = input.deferredSources.get(videoId) ?? relative9(resolve12(input.executionPlanDir), payload.framePath).split(sep6).join("/");
|
|
21572
21604
|
assertSafeRelativePath(path);
|
|
21573
21605
|
const indexes = mutable.get(path) ?? /* @__PURE__ */ new Set();
|
|
21574
21606
|
indexes.add(chunk.index);
|
|
@@ -22390,8 +22422,8 @@ async function renderChunk(planDir, chunkIndex, outputChunkPath, options) {
|
|
|
22390
22422
|
const verifyInWorker = chunkWorkerCount > 1 && !forceScreenshotForChunk;
|
|
22391
22423
|
let boxesMeasured;
|
|
22392
22424
|
let boxesFailed;
|
|
22393
|
-
const boxesReady = new Promise((
|
|
22394
|
-
boxesMeasured =
|
|
22425
|
+
const boxesReady = new Promise((resolve15, reject) => {
|
|
22426
|
+
boxesMeasured = resolve15;
|
|
22395
22427
|
boxesFailed = reject;
|
|
22396
22428
|
});
|
|
22397
22429
|
boxesReady.catch(() => {
|
|
@@ -23508,7 +23540,7 @@ import {
|
|
|
23508
23540
|
createReadStream as createReadStream6
|
|
23509
23541
|
} from "node:fs";
|
|
23510
23542
|
import { AsyncLocalStorage } from "node:async_hooks";
|
|
23511
|
-
import { basename as basename9, resolve as
|
|
23543
|
+
import { basename as basename9, resolve as resolve14, dirname as dirname23, join as join52 } from "node:path";
|
|
23512
23544
|
import { homedir, tmpdir as tmpdir6 } from "node:os";
|
|
23513
23545
|
import { parseArgs } from "node:util";
|
|
23514
23546
|
import { isIP } from "node:net";
|
|
@@ -23534,7 +23566,7 @@ import {
|
|
|
23534
23566
|
closeSync as closeSync8,
|
|
23535
23567
|
constants as constants4
|
|
23536
23568
|
} from "node:fs";
|
|
23537
|
-
import { resolve as
|
|
23569
|
+
import { resolve as resolve13, join as join50, relative as relative10, isAbsolute as isAbsolute7, sep as sep7, dirname as dirname21 } from "node:path";
|
|
23538
23570
|
import { fileURLToPath as fileURLToPath7 } from "node:url";
|
|
23539
23571
|
import { Worker as Worker3 } from "node:worker_threads";
|
|
23540
23572
|
function isStringRecord(value) {
|
|
@@ -23584,7 +23616,7 @@ function leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry) {
|
|
|
23584
23616
|
return entryRelativePath === ".." || entryRelativePath.startsWith(`..${sep7}`) || isAbsolute7(entryRelativePath) || isAllowedEntry !== void 0 && !isAllowedEntry(absoluteEntryPath);
|
|
23585
23617
|
}
|
|
23586
23618
|
function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
23587
|
-
const absProjectDir =
|
|
23619
|
+
const absProjectDir = resolve13(projectDir);
|
|
23588
23620
|
if (!existsSync31(absProjectDir) || !statSync13(absProjectDir).isDirectory()) {
|
|
23589
23621
|
return { error: `Project directory not found: ${absProjectDir}` };
|
|
23590
23622
|
}
|
|
@@ -23592,7 +23624,7 @@ function readProjectEntryFile(projectDir, preferredEntryFile, isAllowedEntry) {
|
|
|
23592
23624
|
(value) => typeof value === "string" && value.trim().length > 0
|
|
23593
23625
|
);
|
|
23594
23626
|
for (const entryFile of entryCandidates) {
|
|
23595
|
-
const absoluteEntryPath =
|
|
23627
|
+
const absoluteEntryPath = resolve13(absProjectDir, entryFile);
|
|
23596
23628
|
if (leavesProject(absProjectDir, absoluteEntryPath, isAllowedEntry)) {
|
|
23597
23629
|
return { error: `Entry file must stay inside project directory: ${entryFile}` };
|
|
23598
23630
|
}
|
|
@@ -23652,16 +23684,16 @@ function takeLintSlot(limit, waitMs) {
|
|
|
23652
23684
|
running++;
|
|
23653
23685
|
return Promise.resolve(true);
|
|
23654
23686
|
}
|
|
23655
|
-
return new Promise((
|
|
23687
|
+
return new Promise((resolve15) => {
|
|
23656
23688
|
const entry = () => {
|
|
23657
23689
|
clearTimeout(timer);
|
|
23658
23690
|
running++;
|
|
23659
|
-
|
|
23691
|
+
resolve15(true);
|
|
23660
23692
|
};
|
|
23661
23693
|
const timer = setTimeout(
|
|
23662
23694
|
() => {
|
|
23663
23695
|
waiting.splice(waiting.indexOf(entry), 1);
|
|
23664
|
-
|
|
23696
|
+
resolve15(false);
|
|
23665
23697
|
},
|
|
23666
23698
|
Math.max(0, waitMs)
|
|
23667
23699
|
);
|
|
@@ -23765,12 +23797,12 @@ async function startHealthWorker(options = {}) {
|
|
|
23765
23797
|
stdout: false,
|
|
23766
23798
|
stderr: false
|
|
23767
23799
|
});
|
|
23768
|
-
await new Promise((
|
|
23800
|
+
await new Promise((resolve15, reject) => {
|
|
23769
23801
|
const onMessage = (msg) => {
|
|
23770
23802
|
if (msg?.type === "listening") {
|
|
23771
23803
|
worker.off("error", onError);
|
|
23772
23804
|
worker.off("message", onMessage);
|
|
23773
|
-
|
|
23805
|
+
resolve15();
|
|
23774
23806
|
} else if (msg?.type === "listen-error") {
|
|
23775
23807
|
worker.off("error", onError);
|
|
23776
23808
|
worker.off("message", onMessage);
|
|
@@ -23987,7 +24019,7 @@ function buildRenderJobConfig(input, outputPath, log) {
|
|
|
23987
24019
|
function resolvePreparedRenderOutput(prepared, rendersDir, log, confineOutput) {
|
|
23988
24020
|
const { input, cleanupProjectDir } = prepared;
|
|
23989
24021
|
const serverNamed = input.outputPath == null;
|
|
23990
|
-
const outputCandidate = input.outputPath ?? join52(rendersDir, `${basename9(
|
|
24022
|
+
const outputCandidate = input.outputPath ?? join52(rendersDir, `${basename9(resolve14(input.projectDir))}-${crypto.randomUUID()}.mp4`);
|
|
23991
24023
|
const absoluteOutputPath = resolveOutputPath(input.projectDir, outputCandidate, rendersDir, log);
|
|
23992
24024
|
const outputDir = dirname23(absoluteOutputPath);
|
|
23993
24025
|
if (confineOutput) {
|
|
@@ -24009,7 +24041,7 @@ var STICKY_BIT = 512;
|
|
|
24009
24041
|
var SERVER_FOLDER_MODE = 493;
|
|
24010
24042
|
function folderAnotherAccountCanChange(dir, rendersDir) {
|
|
24011
24043
|
const foreign = foreignWritablePath(dir, rendersDir);
|
|
24012
|
-
const stickyRoot = foreign ===
|
|
24044
|
+
const stickyRoot = foreign === resolve14(rendersDir) && (lstatSync6(foreign).mode & STICKY_BIT) !== 0;
|
|
24013
24045
|
return stickyRoot ? void 0 : foreign;
|
|
24014
24046
|
}
|
|
24015
24047
|
function prepareRenderJob(prepared, rendersDir, log, confineOutput) {
|
|
@@ -24070,7 +24102,7 @@ function validateOutputResolutionOverride(body) {
|
|
|
24070
24102
|
var MAX_PREVIEW_HTML_BYTES = 20 * 1024 * 1024;
|
|
24071
24103
|
function resolveRenderRequestPolicy(options) {
|
|
24072
24104
|
return {
|
|
24073
|
-
projectsDir:
|
|
24105
|
+
projectsDir: resolve14(
|
|
24074
24106
|
options.projectsDir ?? (process.env.PRODUCER_PROJECTS_DIR || process.cwd())
|
|
24075
24107
|
),
|
|
24076
24108
|
allowDebug: options.allowDebug ?? process.env.PRODUCER_ALLOW_DEBUG === "1"
|
|
@@ -24085,13 +24117,13 @@ function isAllowedEntryPath(policy, projectDir, path) {
|
|
|
24085
24117
|
function prepareProjectDirectory(projectDir, options, policy) {
|
|
24086
24118
|
const candidate = nonEmptyString(projectDir);
|
|
24087
24119
|
if (!candidate) return null;
|
|
24088
|
-
const absProjectDir = policy ?
|
|
24120
|
+
const absProjectDir = policy ? resolve14(policy.projectsDir, candidate) : resolve14(candidate);
|
|
24089
24121
|
const shown = policy ? candidate : absProjectDir;
|
|
24090
24122
|
if (policy && !isAllowedProjectPath(policy.projectsDir, absProjectDir) || !existsSync33(absProjectDir) || !statSync14(absProjectDir).isDirectory()) {
|
|
24091
24123
|
return { error: `Project directory not found: ${shown}` };
|
|
24092
24124
|
}
|
|
24093
24125
|
const entry = options.entryFile || "index.html";
|
|
24094
|
-
const entryPath =
|
|
24126
|
+
const entryPath = resolve14(absProjectDir, entry);
|
|
24095
24127
|
if (policy && !isAllowedEntryPath(policy, absProjectDir, entryPath) || !existsSync33(entryPath)) {
|
|
24096
24128
|
return { error: `Entry file "${entry}" not found in project directory: ${shown}` };
|
|
24097
24129
|
}
|
|
@@ -24142,7 +24174,7 @@ function resolveOutputPath(projectDir, outputCandidate, rendersDir, log) {
|
|
|
24142
24174
|
try {
|
|
24143
24175
|
return resolveRenderPaths(projectDir, outputCandidate, rendersDir).absoluteOutputPath;
|
|
24144
24176
|
} catch (error) {
|
|
24145
|
-
const fallbackPath =
|
|
24177
|
+
const fallbackPath = resolve14(rendersDir, `producer-fallback-${Date.now()}.mp4`);
|
|
24146
24178
|
log.warn("Failed to resolve output path, using fallback", {
|
|
24147
24179
|
fallback: fallbackPath,
|
|
24148
24180
|
error: error instanceof Error ? error.message : String(error)
|
|
@@ -24349,7 +24381,7 @@ function createRenderHandlers(options = {}) {
|
|
|
24349
24381
|
const lintProjectDir = nonEmptyString(body.projectDir);
|
|
24350
24382
|
let isAllowedEntry;
|
|
24351
24383
|
if (policy && lintProjectDir) {
|
|
24352
|
-
const absProjectDir =
|
|
24384
|
+
const absProjectDir = resolve14(policy.projectsDir, lintProjectDir);
|
|
24353
24385
|
if (!isAllowedProjectPath(policy.projectsDir, absProjectDir)) {
|
|
24354
24386
|
const error = `Project directory not found: ${lintProjectDir}`;
|
|
24355
24387
|
return c.json({ success: false, requestId, error }, 400);
|
|
@@ -24703,7 +24735,7 @@ function serverAuth(options, hostname2, port) {
|
|
|
24703
24735
|
`Refusing to listen on ${hostname2} without an auth token. Set authToken or PRODUCER_AUTH_TOKEN, or listen on a loopback address.`
|
|
24704
24736
|
);
|
|
24705
24737
|
}
|
|
24706
|
-
const file =
|
|
24738
|
+
const file = resolve14(
|
|
24707
24739
|
options.authTokenFile?.trim() || process.env.PRODUCER_AUTH_TOKEN_FILE?.trim() || join52(homedir(), ".hyperframes", "producer", `${port}.token`)
|
|
24708
24740
|
);
|
|
24709
24741
|
const token = crypto.randomBytes(32).toString("base64url");
|
|
@@ -24763,7 +24795,7 @@ function startServer(options = {}) {
|
|
|
24763
24795
|
process.on("SIGINT", () => shutdown("SIGINT"));
|
|
24764
24796
|
return server;
|
|
24765
24797
|
}
|
|
24766
|
-
var entryScript = process.argv[1] ?
|
|
24798
|
+
var entryScript = process.argv[1] ? resolve14(process.argv[1]) : "";
|
|
24767
24799
|
var isPublicServerEntry = entryScript.endsWith("/public-server.js") || entryScript.endsWith("/src/server.ts");
|
|
24768
24800
|
if (isPublicServerEntry) {
|
|
24769
24801
|
const { values } = parseArgs({
|