dsh-folia 4.26.0-pre.29 → 4.26.0-pre.30
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/lib/boot/index.js +83 -6
- package/lib/client.js +63 -2
- package/lib/routes/boot.js +39 -6
- package/package.json +1 -1
package/lib/boot/index.js
CHANGED
|
@@ -43,9 +43,16 @@ function readConfig() {
|
|
|
43
43
|
export function readBoot() {
|
|
44
44
|
const cfg = readConfig();
|
|
45
45
|
const raw = cfg && typeof cfg.boot === 'object' && cfg.boot ? cfg.boot : {};
|
|
46
|
+
// 素材池:items 是 id 数组;旧配置只有 clipId ⇒ 自动包成单条池(向后兼容)
|
|
47
|
+
const rawItems = Array.isArray(raw.items) ? raw.items.filter((x) => typeof x === 'string' && x) : [];
|
|
48
|
+
const legacyId = typeof raw.clipId === 'string' ? raw.clipId : '';
|
|
49
|
+
const items = rawItems.length ? rawItems : (legacyId ? [legacyId] : []);
|
|
46
50
|
return {
|
|
47
51
|
enabled: raw.enabled === true,
|
|
48
|
-
clipId:
|
|
52
|
+
clipId: legacyId || (items[0] || ''),
|
|
53
|
+
items,
|
|
54
|
+
// 素材池取片方式:first=固定第一条;random=随机;rotate=按启动次数轮换
|
|
55
|
+
poolMode: ['first', 'random', 'rotate'].includes(String(raw.poolMode)) ? String(raw.poolMode) : 'first',
|
|
49
56
|
// 进入方式:tail = 播完再进(默认);ready = 应用就绪就进;click = 点一下才进。
|
|
50
57
|
// 之前没有这个字段,一律「就绪即进」,于是 8~15 秒的片子 1.2 秒就被掐掉。
|
|
51
58
|
enterMode: ['tail', 'ready', 'click'].includes(String(raw.enterMode)) ? String(raw.enterMode) : 'tail',
|
|
@@ -63,7 +70,16 @@ export function readBoot() {
|
|
|
63
70
|
export function writeBoot(patch) {
|
|
64
71
|
const cfg = readConfig();
|
|
65
72
|
const cur = cfg && typeof cfg.boot === 'object' && cfg.boot ? cfg.boot : {};
|
|
66
|
-
|
|
73
|
+
const next = { ...cur, ...patch };
|
|
74
|
+
// items 与 clipId 保持一致:写 items 时把 clipId 定成第一条(旧读路径仍能工作)
|
|
75
|
+
if (Array.isArray(next.items)) {
|
|
76
|
+
next.items = next.items.filter((x) => typeof x === 'string' && x);
|
|
77
|
+
if (next.items.length) next.clipId = next.items[0];
|
|
78
|
+
else if (typeof next.clipId === 'string' && next.clipId) next.items = [next.clipId];
|
|
79
|
+
} else if (typeof next.clipId === 'string' && next.clipId) {
|
|
80
|
+
next.items = [next.clipId];
|
|
81
|
+
}
|
|
82
|
+
cfg.boot = next;
|
|
67
83
|
writeFileSync(bootConfigPath(), JSON.stringify(cfg, null, 2) + '\n');
|
|
68
84
|
return readBoot();
|
|
69
85
|
}
|
|
@@ -156,7 +172,11 @@ export function listLocalClips() {
|
|
|
156
172
|
let meta = {};
|
|
157
173
|
try { meta = JSON.parse(readFileSync(join(dir, stem + '.json'), 'utf8')) || {}; } catch { /* 没 meta 也能用 */ }
|
|
158
174
|
const id = String(meta.id || stem);
|
|
159
|
-
out.push({
|
|
175
|
+
out.push({
|
|
176
|
+
id, bytes, title: meta.title || id, durationSec: meta.durationSec || null,
|
|
177
|
+
// 来源:站点下载的 meta 里有 url/sha256;本地导入的 meta.source='local'
|
|
178
|
+
source: meta.source === 'local' ? 'local' : 'site',
|
|
179
|
+
});
|
|
160
180
|
}
|
|
161
181
|
return out;
|
|
162
182
|
}
|
|
@@ -271,6 +291,61 @@ export const BOOT_SCREEN_SOURCE = String.raw`
|
|
|
271
291
|
})();
|
|
272
292
|
`;
|
|
273
293
|
|
|
294
|
+
/** 素材池状态文件(轮换计数;与 config.json 分开,避免每次启动都改配置)。 */
|
|
295
|
+
function poolStatePath() { return join(bootHome(), 'boot-pool.json'); }
|
|
296
|
+
function readPoolState() {
|
|
297
|
+
try { return JSON.parse(readFileSync(poolStatePath(), 'utf8')) || {}; } catch { return {}; }
|
|
298
|
+
}
|
|
299
|
+
function writePoolState(next) {
|
|
300
|
+
try { writeFileSync(poolStatePath(), JSON.stringify(next, null, 2) + '\n'); } catch { /* 只读盘:轮换退化成固定第一条 */ }
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/**
|
|
304
|
+
* 按 poolMode 从素材池里挑一条;只挑**本地真的存在**的(缺文件不能注入,否则黑屏)。
|
|
305
|
+
* return null ⇒ 一条可用的都没有,调用方直接不注入。
|
|
306
|
+
*/
|
|
307
|
+
export function pickClipForBoot(boot) {
|
|
308
|
+
const items = Array.isArray(boot && boot.items) ? boot.items.filter((id) => id && clipExists(id)) : [];
|
|
309
|
+
if (!items.length) return null;
|
|
310
|
+
const mode = (boot && boot.poolMode) || 'first';
|
|
311
|
+
if (mode === 'random') return items[Math.floor(Math.random() * items.length)];
|
|
312
|
+
if (mode === 'rotate') {
|
|
313
|
+
const state = readPoolState();
|
|
314
|
+
const next = (Number(state.index) || 0) % items.length;
|
|
315
|
+
writePoolState({ index: next + 1 });
|
|
316
|
+
return items[next];
|
|
317
|
+
}
|
|
318
|
+
return items[0];
|
|
319
|
+
}
|
|
320
|
+
|
|
321
|
+
/**
|
|
322
|
+
* 导入一条本地动画(mp4/webm)。只写 `$DSH_HOME/boot/`,不碰站点、不联网。
|
|
323
|
+
* 校验:文件头必须像视频(ftyp/EBML)、大小 ≤ CLIP_MAX_BYTES、目录固定。
|
|
324
|
+
* @returns {{ok:true,id:string,bytes:number}|{ok:false,error:string}}
|
|
325
|
+
*/
|
|
326
|
+
export function importLocalClip(buffer, options = {}) {
|
|
327
|
+
const max = Number(options.maxBytes) || 64 * 1024 * 1024;
|
|
328
|
+
if (!buffer || !buffer.length) return { ok: false, error: 'empty' };
|
|
329
|
+
if (buffer.length > max) return { ok: false, error: 'too-large' };
|
|
330
|
+
const head = buffer.subarray(0, 12);
|
|
331
|
+
const isMp4 = head.length >= 8 && head.toString('latin1', 4, 8) === 'ftyp';
|
|
332
|
+
const isWebm = head.length >= 4 && head[0] === 0x1a && head[1] === 0x45 && head[2] === 0xdf && head[3] === 0xa3;
|
|
333
|
+
if (!isMp4 && !isWebm) return { ok: false, error: 'not-a-video' };
|
|
334
|
+
const title = String(options.title || '').trim() || '本地导入';
|
|
335
|
+
const id = 'local-' + createHash('sha256').update(buffer).digest('hex').slice(0, 12);
|
|
336
|
+
const dest = clipFile(id);
|
|
337
|
+
try {
|
|
338
|
+
writeFileSync(dest, buffer);
|
|
339
|
+
writeFileSync(clipMetaFile(id), JSON.stringify({
|
|
340
|
+
id, title, source: 'local', bytes: buffer.length,
|
|
341
|
+
mime: isMp4 ? 'video/mp4' : 'video/webm', importedAt: Date.now(),
|
|
342
|
+
}, null, 2) + '\n');
|
|
343
|
+
} catch (error) {
|
|
344
|
+
try { rmSync(dest, { force: true }); } catch { /* ignore */ }
|
|
345
|
+
return { ok: false, error: String((error && error.message) || error) };
|
|
346
|
+
}
|
|
347
|
+
return { ok: true, id, bytes: buffer.length, title };
|
|
348
|
+
}
|
|
274
349
|
/**
|
|
275
350
|
* 装注入。**订阅在 apply() 里做一次**,每次 index 渲染时按当前配置决定注不注。
|
|
276
351
|
*
|
|
@@ -286,10 +361,12 @@ export function installBootInjection(ctx, note) {
|
|
|
286
361
|
if (!Array.isArray(table)) return;
|
|
287
362
|
const boot = readBoot();
|
|
288
363
|
// 关 = 一行都不注入(不是"注入了再自己退出")。
|
|
289
|
-
if (!boot.enabled
|
|
290
|
-
|
|
364
|
+
if (!boot.enabled) return;
|
|
365
|
+
// 素材池取片:按 poolMode 从 items 里挑一条本地真的存在的;一条都没有就不注入。
|
|
366
|
+
const picked = pickClipForBoot(boot);
|
|
367
|
+
if (!picked) return; // 片段被删了:静默不注入,别让用户卡黑屏
|
|
291
368
|
const cfg = {
|
|
292
|
-
clip: '/folia/boot/clip?v=' + encodeURIComponent(
|
|
369
|
+
clip: '/folia/boot/clip?v=' + encodeURIComponent(picked),
|
|
293
370
|
fadeMs: boot.fadeMs,
|
|
294
371
|
minShowMs: boot.minShowMs,
|
|
295
372
|
maxHoldMs: boot.maxHoldMs,
|
package/lib/client.js
CHANGED
|
@@ -764,6 +764,15 @@ window.__ModuleLoader__.load({
|
|
|
764
764
|
"对话": "Chat",
|
|
765
765
|
"可选工作能力(已安装才可用)": "Optional work capabilities (installed only)",
|
|
766
766
|
"能力": "Capabilities",
|
|
767
|
+
"导入本地动画": "Import local clip",
|
|
768
|
+
"支持 mp4 / webm,≤64MB;导入后只在本地,不上传站点": "mp4 / webm, up to 64MB; kept locally, never uploaded",
|
|
769
|
+
"文件太大(上限 64MB)": "File too large (64MB max)",
|
|
770
|
+
"读取文件失败": "Failed to read the file",
|
|
771
|
+
"本地": "Local",
|
|
772
|
+
"多条时": "With several",
|
|
773
|
+
"固定第一条": "Always first",
|
|
774
|
+
"轮换": "Rotate",
|
|
775
|
+
"已导入:{name}": "Imported: {name}",
|
|
767
776
|
"功能": "Features",
|
|
768
777
|
"你可以这样说": "Try saying",
|
|
769
778
|
"提高日常办事效率": "Get daily work done faster",
|
|
@@ -17970,7 +17979,7 @@ window.__ModuleLoader__.load({
|
|
|
17970
17979
|
async function act(kind, payload, label, ev, jobUrl) {
|
|
17971
17980
|
if (busy) return;
|
|
17972
17981
|
// 只有结构性操作(下载 / 选择 / 删除)才锁 UI;开关与参数是幂等的,锁了反而闪。
|
|
17973
|
-
const structural = kind === "download" || kind === "select" || kind === "remove";
|
|
17982
|
+
const structural = kind === "download" || kind === "select" || kind === "remove" || kind === "import";
|
|
17974
17983
|
const cardId = String((payload && payload.id) || "");
|
|
17975
17984
|
const isDownload = kind === "download";
|
|
17976
17985
|
// 4.23.3:**下载走队列后不再锁整页** —— 进度落在卡片上(dlBusyLabel),锁住反而让人
|
|
@@ -18033,6 +18042,7 @@ window.__ModuleLoader__.load({
|
|
|
18033
18042
|
}
|
|
18034
18043
|
if (kind === "select") setNote({ ok: true, text: weT("已选中「{name}」,下次启动生效", { name: label }) });
|
|
18035
18044
|
if (kind === "remove") setNote({ ok: true, text: weT("已删除:{name}", { name: label }) });
|
|
18045
|
+
if (kind === "import") setNote({ ok: true, text: weT("已导入:{name}", { name: label }) });
|
|
18036
18046
|
if (kind === "toggle") setNote({ ok: true, text: payload.enabled ? weT("开机动画已开启") : weT("开机动画已关闭") });
|
|
18037
18047
|
if (kind === "settings") setNote({ ok: true, text: weT("已保存") });
|
|
18038
18048
|
// 开关/参数类:宿主把整份 boot 配置回给我们({ ok, ...boot }),直接并进 state,
|
|
@@ -18152,11 +18162,58 @@ window.__ModuleLoader__.load({
|
|
|
18152
18162
|
}),
|
|
18153
18163
|
weT("带声音"),
|
|
18154
18164
|
),
|
|
18165
|
+
// 素材池取片方式:装了多条时才有意义
|
|
18166
|
+
React.createElement("label", { style: { display: "flex", gap: "4px", alignItems: "center", fontSize: "12px" } },
|
|
18167
|
+
weT("多条时"),
|
|
18168
|
+
React.createElement("select", {
|
|
18169
|
+
className: "we-picker__playlist-select",
|
|
18170
|
+
value: String(state.poolMode || "first"),
|
|
18171
|
+
disabled: Boolean(busy),
|
|
18172
|
+
onChange: (e) => act("settings", { poolMode: e.target.value }, ""),
|
|
18173
|
+
},
|
|
18174
|
+
React.createElement("option", { value: "first" }, weT("固定第一条")),
|
|
18175
|
+
React.createElement("option", { value: "random" }, weT("随机")),
|
|
18176
|
+
React.createElement("option", { value: "rotate" }, weT("轮换")),
|
|
18177
|
+
),
|
|
18178
|
+
),
|
|
18155
18179
|
opt(weT("最短显示"), "minShowMs", [[0, weT("不限制")], [600, weT("0.6 秒")], [1200, weT("1.2 秒")], [2000, weT("2 秒")]]),
|
|
18156
18180
|
opt(weT("最长停留"), "maxHoldMs", [[10000, weT("10 秒")], [20000, weT("20 秒(默认)")], [30000, weT("30 秒")], [60000, weT("60 秒")]]),
|
|
18157
18181
|
));
|
|
18158
18182
|
}
|
|
18159
18183
|
|
|
18184
|
+
children.push(React.createElement("div", {
|
|
18185
|
+
key: "import",
|
|
18186
|
+
style: { display: "flex", alignItems: "center", gap: "8px", margin: "2px 0 6px", flexWrap: "wrap" },
|
|
18187
|
+
},
|
|
18188
|
+
React.createElement("button", {
|
|
18189
|
+
type: "button",
|
|
18190
|
+
className: "we-picker__btn",
|
|
18191
|
+
disabled: Boolean(busy),
|
|
18192
|
+
onClick: () => {
|
|
18193
|
+
const input = document.createElement("input");
|
|
18194
|
+
input.type = "file";
|
|
18195
|
+
input.accept = "video/mp4,video/webm,.mp4,.webm";
|
|
18196
|
+
input.style.display = "none";
|
|
18197
|
+
input.addEventListener("change", () => {
|
|
18198
|
+
const file = input.files && input.files[0];
|
|
18199
|
+
if (!file) return;
|
|
18200
|
+
if (file.size > 64 * 1024 * 1024) { setNote({ ok: false, text: weT("文件太大(上限 64MB)") }); return; }
|
|
18201
|
+
const reader = new FileReader();
|
|
18202
|
+
reader.onload = () => {
|
|
18203
|
+
const raw = String(reader.result || "");
|
|
18204
|
+
const comma = raw.indexOf(",");
|
|
18205
|
+
const data = comma >= 0 ? raw.slice(comma + 1) : raw;
|
|
18206
|
+
void act("import", { data, filename: file.name }, file.name);
|
|
18207
|
+
};
|
|
18208
|
+
reader.onerror = () => setNote({ ok: false, text: weT("读取文件失败") });
|
|
18209
|
+
reader.readAsDataURL(file);
|
|
18210
|
+
});
|
|
18211
|
+
input.click();
|
|
18212
|
+
},
|
|
18213
|
+
}, weT("导入本地动画")),
|
|
18214
|
+
React.createElement("span", { className: "we-picker__hint" },
|
|
18215
|
+
weT("支持 mp4 / webm,≤64MB;导入后只在本地,不上传站点")),
|
|
18216
|
+
));
|
|
18160
18217
|
children.push(React.createElement("div", { key: "count", className: "we-picker__hint", style: { margin: "2px 0 4px" } },
|
|
18161
18218
|
weT("已下载 {done} / {total}", { done: installedCount, total: clips.length })));
|
|
18162
18219
|
|
|
@@ -18200,7 +18257,11 @@ window.__ModuleLoader__.load({
|
|
|
18200
18257
|
onError: (e) => { e.target.style.display = "none"; },
|
|
18201
18258
|
})
|
|
18202
18259
|
: null,
|
|
18203
|
-
React.createElement("div", { style: BOOT_STYLE.title },
|
|
18260
|
+
React.createElement("div", { style: BOOT_STYLE.title },
|
|
18261
|
+
(c.title || c.id),
|
|
18262
|
+
c.source === "local"
|
|
18263
|
+
? React.createElement("span", { className: "we-picker__hint", style: { marginLeft: "6px" } }, weT("本地"))
|
|
18264
|
+
: null),
|
|
18204
18265
|
React.createElement("div", { style: BOOT_STYLE.meta },
|
|
18205
18266
|
[c.durationSec ? Number(c.durationSec).toFixed(1) + "s" : null,
|
|
18206
18267
|
bootFmtBytes(c.localBytes || c.bytes)].filter(Boolean).join(" · ")),
|
package/lib/routes/boot.js
CHANGED
|
@@ -13,7 +13,7 @@ import { createReadStream, existsSync, readFileSync, rmSync, statSync, writeFile
|
|
|
13
13
|
import { sendJson } from '../json-response.js';
|
|
14
14
|
import { bodyReader } from '../http-body.js';
|
|
15
15
|
import { resolveModules } from './modules.js';
|
|
16
|
-
import { clipExists, clipFile, clipMetaFile, listLocalClips, readBoot, removeClip, resolveClipFile, writeBoot } from '../boot/index.js';
|
|
16
|
+
import { clipExists, clipFile, clipMetaFile, listLocalClips, readBoot, importLocalClip, removeClip, resolveClipFile, writeBoot } from '../boot/index.js';
|
|
17
17
|
// 4.24.0:站点清单端点偏好(v1 优先 / v0 回退)的唯一实现 —— 四族共用。
|
|
18
18
|
import { siteListFetch } from '../site-list.js';
|
|
19
19
|
// 4.23.3:开机动画下载改走**下载队列**(Range 续传 / 自适应多连接 / 进度可读)。
|
|
@@ -270,7 +270,7 @@ export function registerBootRoutes(webServer, c) {
|
|
|
270
270
|
const localById = new Map(local.map((x) => [x.id, x]));
|
|
271
271
|
const clips = candidates.clips.map((c) => {
|
|
272
272
|
const have = localById.get(c.id) || null;
|
|
273
|
-
return { ...c, installed: Boolean(have), localBytes: have ? have.bytes : null };
|
|
273
|
+
return { ...c, installed: Boolean(have), localBytes: have ? have.bytes : null, source: have && have.source === 'local' ? 'local' : 'site' };
|
|
274
274
|
});
|
|
275
275
|
// 本地有、清单里没有的(我们换了站点/清单):也列出来,否则用户删不掉。
|
|
276
276
|
const known = new Set(clips.map((c) => c.id));
|
|
@@ -279,12 +279,14 @@ export function registerBootRoutes(webServer, c) {
|
|
|
279
279
|
clips.push({
|
|
280
280
|
id: it.id, title: it.title, url: null, bytes: null, sha256: null,
|
|
281
281
|
durationSec: it.durationSec, faststart: true, cover: null,
|
|
282
|
-
installed: true, localBytes: it.bytes, orphan: true,
|
|
282
|
+
installed: true, localBytes: it.bytes, orphan: true, source: it.source || 'local',
|
|
283
283
|
});
|
|
284
284
|
}
|
|
285
285
|
sendJson(res, 200, {
|
|
286
286
|
ok: true,
|
|
287
287
|
enabled: boot.enabled,
|
|
288
|
+
items: boot.items,
|
|
289
|
+
poolMode: boot.poolMode,
|
|
288
290
|
clipId: boot.clipId,
|
|
289
291
|
enterMode: boot.enterMode,
|
|
290
292
|
sound: boot.sound,
|
|
@@ -388,7 +390,32 @@ export function registerBootRoutes(webServer, c) {
|
|
|
388
390
|
},
|
|
389
391
|
}));
|
|
390
392
|
|
|
391
|
-
/*
|
|
393
|
+
/* ②b 导入本地动画(base64 JSON;只写 ~/.dsh-folia/boot,不联网、不碰站点) */
|
|
394
|
+
disposers.push(webServer.register({
|
|
395
|
+
kind: 'exact',
|
|
396
|
+
path: `${BASE}/boot/import`,
|
|
397
|
+
handler: async (req, res) => {
|
|
398
|
+
let doc = null;
|
|
399
|
+
try {
|
|
400
|
+
const text = await readBodyText(req, 40 * 1024 * 1024);
|
|
401
|
+
doc = JSON.parse(text || '{}');
|
|
402
|
+
} catch { doc = null; }
|
|
403
|
+
if (!doc || typeof doc.data !== 'string' || !doc.data) { sendJson(res, 400, { ok: false, error: 'bad-request' }); return; }
|
|
404
|
+
let buf = null;
|
|
405
|
+
try { buf = Buffer.from(doc.data, 'base64'); } catch { buf = null; }
|
|
406
|
+
if (!buf || !buf.length) { sendJson(res, 400, { ok: false, error: 'bad-data' }); return; }
|
|
407
|
+
const out = importLocalClip(buf, { title: doc.filename });
|
|
408
|
+
if (!out.ok) {
|
|
409
|
+
const status = out.error === 'too-large' ? 413 : (out.error === 'not-a-video' ? 415 : 400);
|
|
410
|
+
sendJson(res, status, { ok: false, error: out.error });
|
|
411
|
+
return;
|
|
412
|
+
}
|
|
413
|
+
if (typeof log === 'function') log(`[boot] imported ${out.id} bytes=${out.bytes}`);
|
|
414
|
+
sendJson(res, 200, { ok: true, id: out.id, bytes: out.bytes });
|
|
415
|
+
},
|
|
416
|
+
}));
|
|
417
|
+
|
|
418
|
+
/* ③ 选择(并顺手启用) */
|
|
392
419
|
disposers.push(webServer.register({
|
|
393
420
|
kind: 'exact',
|
|
394
421
|
path: `${BASE}/boot/select`,
|
|
@@ -396,7 +423,9 @@ export function registerBootRoutes(webServer, c) {
|
|
|
396
423
|
const id = await readIdBody(req);
|
|
397
424
|
if (!id) { sendJson(res, 400, { ok: false, error: 'bad-id' }); return; }
|
|
398
425
|
if (!clipExists(id)) { sendJson(res, 404, { ok: false, error: 'not-installed' }); return; }
|
|
399
|
-
const
|
|
426
|
+
const cur = readBoot();
|
|
427
|
+
const items = Array.isArray(cur.items) && cur.items.includes(id) ? cur.items : [id, ...(cur.items || []).filter((x) => x !== id)];
|
|
428
|
+
const boot = writeBoot({ clipId: id, items, enabled: true });
|
|
400
429
|
if (typeof log === 'function') log(`[boot] selected ${id}`);
|
|
401
430
|
sendJson(res, 200, { ok: true, ...boot });
|
|
402
431
|
},
|
|
@@ -436,6 +465,7 @@ export function registerBootRoutes(webServer, c) {
|
|
|
436
465
|
...(patch.fadeMs !== undefined ? { fadeMs: Number(patch.fadeMs) } : {}),
|
|
437
466
|
...(patch.minShowMs !== undefined ? { minShowMs: Number(patch.minShowMs) } : {}),
|
|
438
467
|
...(patch.maxHoldMs !== undefined ? { maxHoldMs: Number(patch.maxHoldMs) } : {}),
|
|
468
|
+
...(patch.poolMode !== undefined ? { poolMode: String(patch.poolMode) } : {}),
|
|
439
469
|
});
|
|
440
470
|
sendJson(res, 200, { ok: true, ...boot });
|
|
441
471
|
},
|
|
@@ -449,7 +479,10 @@ export function registerBootRoutes(webServer, c) {
|
|
|
449
479
|
const id = await readIdBody(req);
|
|
450
480
|
if (!id) { sendJson(res, 400, { ok: false, error: 'bad-id' }); return; }
|
|
451
481
|
const boot = readBoot();
|
|
452
|
-
|
|
482
|
+
const bootNow = readBoot();
|
|
483
|
+
const items = (Array.isArray(bootNow.items) ? bootNow.items : []).filter((x) => x !== id);
|
|
484
|
+
if (bootNow.clipId === id) writeBoot({ clipId: items[0] || '', items, enabled: items.length > 0 });
|
|
485
|
+
else writeBoot({ items });
|
|
453
486
|
const ok = removeClip(id);
|
|
454
487
|
sendJson(res, 200, { ok, id });
|
|
455
488
|
},
|