dsh-workbench-danmaku 0.3.3 → 0.4.1

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.
@@ -1,80 +1,11 @@
1
1
  "use strict";
2
+ // 弹幕插件与界面层相关的 action:主题色同步、桌面层控制与运行状态。
3
+ // 配置本身由宿主统一配置中心维护(wb.configCenterGet / Set / Reset / Scheme*),
4
+ // 本插件不再注册 danmaku.config*(旧配置兼容 action) 一类兼容 action。
2
5
 
3
- import { configState, loadConfig, resetConfig, schemeActivate, schemeCreate, schemeDelete, schemeRename, writeConfig } from "../config.js";
4
-
5
- export function registerConfigActions(api, deps) {
6
- const db = api.db;
7
-
8
- api.action("danmaku.configGet", {
9
- description: "读取弹幕插件配置:分组、全部配置项(含中文说明)、当前值、用户覆盖与告警",
10
- input: { type: "object", properties: {}, additionalProperties: false },
11
- execute: () => configState(db),
12
- render: (r) => `弹幕配置 ${Object.keys(r.values).length} 项,覆盖 ${Object.keys(r.overrides).length} 项`,
13
- });
14
-
15
- api.action("danmaku.configSet", {
16
- description: "把弹幕配置写入当前方案;值会做类型与范围校验,写入后立即影响调度节奏与显示层",
17
- input: {
18
- type: "object",
19
- properties: {
20
- values: { type: "object", description: '要写入的配置项,如 {"intervalMs": 1200, "surface": "both"}' },
21
- },
22
- required: ["values"],
23
- additionalProperties: false,
24
- },
25
- execute: (args, ctx) => {
26
- const out = writeConfig(db, args.values, ctx && ctx.origin);
27
- if (out.changed.length) deps.changed("config", out.changed.join(","));
28
- return { changed: out.changed, values: out.state.values, overrides: out.state.overrides };
29
- },
30
- render: (r) => (r.changed.length ? `已更新配置:${r.changed.join("、")}` : "配置没有变化"),
31
- });
32
-
33
- api.action("danmaku.configReset", {
34
- description: "把弹幕配置恢复默认;不传 ids 时恢复全部配置项",
35
- input: {
36
- type: "object",
37
- properties: {
38
- ids: { type: "array", items: { type: "string" }, description: "要恢复默认的配置项 id 列表" },
39
- },
40
- additionalProperties: false,
41
- },
42
- execute: (args) => {
43
- const state = resetConfig(db, args.ids);
44
- deps.changed("config-reset", "");
45
- return { values: state.values, overrides: state.overrides };
46
- },
47
- render: () => "弹幕配置已恢复默认",
48
- });
49
-
50
- api.action("danmaku.configSchemeCreate", {
51
- description: "新建配置方案并立即切换过去;from=current 复制当前值,from=default 从插件默认值开始",
52
- input: { type: "object", properties: { name: { type: "string", description: "方案名称,1–64 个字符" }, from: { type: "string", enum: ["current", "default"] } }, required: ["name"], additionalProperties: false },
53
- execute: (args, ctx) => schemeCreate(db, args.name, args.from, ctx && ctx.origin),
54
- render: (r) => `已新建并启用配置方案:${r.state.scheme.name}`,
55
- });
56
-
57
- api.action("danmaku.configSchemeRename", {
58
- description: "重命名配置方案",
59
- input: { type: "object", properties: { id: { type: "string" }, name: { type: "string" } }, required: ["id", "name"], additionalProperties: false },
60
- execute: (args) => schemeRename(db, args.id, args.name),
61
- render: (r) => `配置方案已改名:${r.state.scheme.name}`,
62
- });
63
-
64
- api.action("danmaku.configSchemeDelete", {
65
- description: "软删除配置方案;删除的是当前方案时回到「不使用方案」",
66
- input: { type: "object", properties: { id: { type: "string" } }, required: ["id"], additionalProperties: false },
67
- execute: (args) => schemeDelete(db, args.id),
68
- render: () => "配置方案已删除",
69
- });
70
-
71
- api.action("danmaku.configSchemeActivate", {
72
- description: "切换当前设备的配置方案;id 传空表示不使用方案、回到插件默认配置",
73
- input: { type: "object", properties: { id: { type: "string" } }, additionalProperties: false },
74
- execute: (args) => schemeActivate(db, args.id),
75
- render: (r) => (r.id ? "已切换配置方案" : "已改为不使用方案(插件默认配置)"),
76
- });
6
+ import { configValues } from "../config.js";
77
7
 
8
+ export function registerOverlayActions(api, deps) {
78
9
  api.action("danmaku.theme", {
79
10
  description: "由界面层上报当前 DSH 主题色,桌面透明窗据此换色;不写库",
80
11
  input: {
@@ -124,7 +55,7 @@ export function registerConfigActions(api, deps) {
124
55
  description: "弹幕运行状态:调度器节奏、下一个播放时间、启用条数与当前显示端",
125
56
  input: { type: "object", properties: {}, additionalProperties: false },
126
57
  execute: () => {
127
- const values = loadConfig(db).values;
58
+ const values = configValues();
128
59
  return Object.assign({ config: values }, deps.player.status(), { desktop: deps.desktop.status() });
129
60
  },
130
61
  render: (r) => `弹幕运行中 ${r.enabled} 条,间隔 ${r.intervalMs}ms`,