0.12.0 Begin neu Architecture

This commit is contained in:
2026-03-18 15:35:10 +00:00
parent d00191324b
commit 0a9cf6969f
30 changed files with 4570 additions and 183 deletions
+77
View File
@@ -0,0 +1,77 @@
function normalizeStage(value) {
const stage = String(value || '').trim().toLowerCase();
return stage || null;
}
const STAGE_LABELS = {
analyze: 'Analyse',
rip: 'Rip',
review: 'Review',
encode: 'Encode',
finalize: 'Finalize',
oncancel: 'Cancel',
onretry: 'Retry'
};
export function normalizePluginExecutionState(rawState) {
if (!rawState || typeof rawState !== 'object' || Array.isArray(rawState)) {
return null;
}
const markerSource = String(rawState.markerSource || '').trim().toLowerCase();
const pluginFile = String(rawState.pluginFile || '').trim();
if (markerSource !== 'plugin-file' || !pluginFile) {
return null;
}
const pluginId = String(rawState.pluginId || '').trim().toLowerCase() || null;
const pluginName = String(rawState.pluginName || '').trim() || pluginId || 'Plugin';
const explicitStages = Array.isArray(rawState.stages)
? rawState.stages.map((stage) => normalizeStage(stage)).filter(Boolean)
: [];
const byStage = rawState.byStage && typeof rawState.byStage === 'object' && !Array.isArray(rawState.byStage)
? rawState.byStage
: {};
const stages = Array.from(new Set([
...explicitStages,
...Object.keys(byStage).map((stage) => normalizeStage(stage)).filter(Boolean),
...[normalizeStage(rawState.lastStage)].filter(Boolean)
]));
const stageLabels = stages.map((stage) => STAGE_LABELS[stage] || stage);
const titleParts = [
`Plugin-Code aktiv: ${pluginName}`,
pluginId ? `ID: ${pluginId}` : null,
`Datei: ${pluginFile}`,
stageLabels.length > 0 ? `Phasen: ${stageLabels.join(', ')}` : null
].filter(Boolean);
return {
markerSource,
pluginId,
pluginName,
pluginFile,
stages,
stageLabels,
label: `Beta: ${pluginName}`,
title: titleParts.join(' | ')
};
}
export function resolveJobPluginExecution(job = null, liveContext = null) {
const liveExecution = normalizePluginExecutionState(liveContext?.pluginExecution);
if (liveExecution) {
return liveExecution;
}
const makemkvExecution = normalizePluginExecutionState(job?.makemkvInfo?.pluginExecution);
if (makemkvExecution) {
return makemkvExecution;
}
const handbrakeExecution = normalizePluginExecutionState(job?.handbrakeInfo?.pluginExecution);
if (handbrakeExecution) {
return handbrakeExecution;
}
return normalizePluginExecutionState(job?.pluginExecution);
}