0.12.0-3 Plugin Integration

This commit is contained in:
2026-03-21 15:58:57 +00:00
parent d9969dfbe5
commit e99cdf1895
20 changed files with 928 additions and 115 deletions
@@ -94,16 +94,40 @@ function DriveDevicesEditor({ value, onChange, settingKey }) {
try {
const parsed = JSON.parse(val || '[]');
if (!Array.isArray(parsed)) return [];
return parsed.map((e) => {
const normalized = parsed.map((e) => {
if (typeof e === 'string') {
const p = e.trim();
const m = p.match(/sr(\d+)$/);
return { path: p, makemkvIndex: m ? Number(m[1]) : 0 };
if (!p) return null;
return { path: p, makemkvIndex: null };
}
if (e && typeof e === 'object') {
return { path: String(e.path || '').trim(), makemkvIndex: Number.isFinite(Number(e.makemkvIndex)) ? Number(e.makemkvIndex) : 0 };
const p = String(e.path || '').trim();
if (!p) return null;
const idxRaw = Number(e.makemkvIndex);
return {
path: p,
makemkvIndex: Number.isFinite(idxRaw) && idxRaw >= 0 ? Math.trunc(idxRaw) : null
};
}
return { path: '', makemkvIndex: 0 };
return null;
}).filter(Boolean);
const used = new Set();
let nextAutoIndex = 0;
return normalized.map((entry) => {
if (entry.makemkvIndex != null) {
used.add(entry.makemkvIndex);
if (entry.makemkvIndex >= nextAutoIndex) {
nextAutoIndex = entry.makemkvIndex + 1;
}
return entry;
}
while (used.has(nextAutoIndex)) {
nextAutoIndex += 1;
}
const resolved = { path: entry.path, makemkvIndex: nextAutoIndex };
used.add(nextAutoIndex);
nextAutoIndex += 1;
return resolved;
});
} catch (_e) {
return [];
@@ -129,8 +153,7 @@ function DriveDevicesEditor({ value, onChange, settingKey }) {
onChange={(e) => {
const next = [...devices];
const p = e.target.value;
const m = p.match(/sr(\d+)$/);
next[idx] = { ...next[idx], path: p, makemkvIndex: m ? Number(m[1]) : next[idx].makemkvIndex };
next[idx] = { ...next[idx], path: p };
updateDevices(next);
}}
className="drive-device-input"