web/workers: split up args by type

This commit is contained in:
jj 2025-03-29 14:15:40 +00:00
parent 53ca7700a5
commit a183265838
No known key found for this signature in database
3 changed files with 23 additions and 12 deletions

View File

@ -95,6 +95,7 @@ export const createSavePipeline = (info: CobaltLocalProcessingResponse, request:
workerId: crypto.randomUUID(),
parentId,
workerArgs: {
files: [],
ffargs,
output: {
type: info.output.type,

View File

@ -18,11 +18,11 @@ export const startWorker = async ({ worker, workerId, parentId, workerArgs }: Co
switch (worker) {
case "remux":
if (workerArgs?.files) {
if (workerArgs.files) {
files = workerArgs.files;
}
if (files?.length === 0) {
if (files.length === 0) {
const parent = get(queue)[parentId];
if (parent.state === "running" && parent.pipelineResults.length) {
files = parent.pipelineResults;
@ -42,9 +42,7 @@ export const startWorker = async ({ worker, workerId, parentId, workerArgs }: Co
break;
case "fetch":
if (workerArgs?.url) {
await runFetchWorker(workerId, parentId, workerArgs.url)
}
await runFetchWorker(workerId, parentId, workerArgs.url)
break;
}
}

View File

@ -12,16 +12,28 @@ export type CobaltWorkerProgress = {
size: number,
}
export type CobaltWorkerArgs = {
files?: CobaltFileReference[],
url?: string,
ffargs?: string[],
output?: FileInfo,
export type CobaltFetchWorkerArgs = { url: string };
export type CobaltRemuxWorkerArgs = {
files: CobaltFileReference[],
ffargs: string[],
output: FileInfo,
}
export type CobaltPipelineItem = {
export type CobaltPipelineItemBase = {
worker: CobaltWorkerType,
workerId: string,
parentId: string,
workerArgs: CobaltWorkerArgs,
};
type CobaltRemuxPipelineItem = CobaltPipelineItemBase & {
worker: "remux",
workerArgs: CobaltRemuxWorkerArgs,
}
type CobaltFetchPipelineItem = CobaltPipelineItemBase & {
worker: "fetch",
workerArgs: CobaltFetchWorkerArgs,
}
export type CobaltPipelineItem = CobaltRemuxPipelineItem | CobaltFetchPipelineItem;