← Files Cecil-IA Labs FFmpegARCHIVED FILE

dist/pipeline/presets.js

1.76 KB · Sep 30, 2026 · 23:17 UTC

↓ Download file

import { ToolkitRuntimeError } from "../core/errors.js";
export const MAX_PIPELINE_PRESET_DEPTH = 32;
export const MAX_EXPANDED_PIPELINE_STEPS = 256;
function expandList(steps, document, stack, counter) {
    const expanded = [];
    for (const step of steps) {
        if (!("preset" in step)) {
            counter.value += 1;
            if (counter.value > MAX_EXPANDED_PIPELINE_STEPS) {
                throw new ToolkitRuntimeError("E_CONFIG_CONFLICT", "Expanded pipeline exceeds the supported step limit.", {
                    details: { limit: MAX_EXPANDED_PIPELINE_STEPS },
                });
            }
            expanded.push(step);
            continue;
        }
        const name = step.preset;
        const preset = document.presets[name];
        if (preset === undefined) {
            throw new ToolkitRuntimeError("E_CONFIG_CONFLICT", "Pipeline references an unknown preset.", {
                details: { preset: name, availablePresets: Object.keys(document.presets).sort() },
            });
        }
        if (stack.length >= MAX_PIPELINE_PRESET_DEPTH) {
            throw new ToolkitRuntimeError("E_CONFIG_CONFLICT", "Pipeline preset nesting exceeds the supported depth.", {
                details: { limit: MAX_PIPELINE_PRESET_DEPTH, stack: [...stack, name] },
            });
        }
        if (stack.includes(name)) {
            throw new ToolkitRuntimeError("E_CONFIG_CONFLICT", "Pipeline preset cycle detected.", {
                details: { cycle: [...stack, name] },
            });
        }
        expanded.push(...expandList(preset, document, [...stack, name], counter));
    }
    return expanded;
}
export function expandPipelineSteps(document) {
    return expandList(document.steps, document, [], { value: 0 });
}
//# sourceMappingURL=presets.js.map

SHA-256: a295ce96a57e0168784b156287a29bbe60cd6cf902f4e2dad8ca9c4e66dc3a32