dsh-workbench-danmaku 0.2.11 → 0.2.13

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/client.js CHANGED
@@ -4479,6 +4479,10 @@ var require_action_schema_style = __commonJS({
4479
4479
  "." + P + "-copy:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4480
4480
  "." + P + " details>summary{cursor:pointer;font-size:11.5px;color:var(--dsw-alias-label-secondary,inherit);width:max-content}",
4481
4481
  "." + P + " details>summary:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,#4f6ef7);outline-offset:2px}",
4482
+ // 参数折叠面板:折叠时只留一行「参数 · 必填 n」,展开后与表格之间留一点气口。
4483
+ "." + P + "-params{min-width:0}",
4484
+ "." + P + "-params>summary{user-select:none;max-width:100%}",
4485
+ "." + P + "-params[open]>summary{margin-bottom:6px}",
4482
4486
  "." + P + "-empty{padding:24px;text-align:center;border:1px dashed var(--wb-border,#e3e5e9);border-radius:10px;color:var(--dsw-alias-label-tertiary,inherit)}",
4483
4487
  "." + P + "-error{padding:12px;border:1px solid var(--dsw-alias-state-error-primary,#d9534f);border-radius:10px;color:var(--dsw-alias-state-error-primary,#d9534f);display:flex;gap:10px;align-items:center;flex-wrap:wrap;overflow-wrap:anywhere}",
4484
4488
  "." + P + "-toast{position:sticky;bottom:8px;align-self:flex-start;border-radius:999px;padding:3px 10px;background:var(--dsw-alias-bg-skeleton,#f2f3f5);font-size:11.5px;max-width:100%}",
@@ -4558,6 +4562,10 @@ var require_action_schema_view = __commonJS({
4558
4562
  paramCount: function(n) {
4559
4563
  return n + " \u4E2A\u53C2\u6570";
4560
4564
  },
4565
+ params: "\u53C2\u6570",
4566
+ requiredCount: function(n) {
4567
+ return "\u5FC5\u586B " + n;
4568
+ },
4561
4569
  examples: "\u793A\u4F8B",
4562
4570
  noExamples: "\u65E0\u793A\u4F8B",
4563
4571
  copy: "\u590D\u5236",
@@ -4621,6 +4629,10 @@ var require_action_schema_view = __commonJS({
4621
4629
  paramCount: function(n) {
4622
4630
  return n + " params";
4623
4631
  },
4632
+ params: "Parameters",
4633
+ requiredCount: function(n) {
4634
+ return n + " required";
4635
+ },
4624
4636
  examples: "Examples",
4625
4637
  noExamples: "No examples",
4626
4638
  copy: "Copy",
@@ -4759,6 +4771,8 @@ var require_action_schema_view = __commonJS({
4759
4771
  var toast = toastState[0], setToast = toastState[1];
4760
4772
  var savingState = React.useState("");
4761
4773
  var saving = savingState[0], setSaving = savingState[1];
4774
+ var foldsState = React.useState({});
4775
+ var folds = foldsState[0], setFolds = foldsState[1];
4762
4776
  React.useEffect(function() {
4763
4777
  injectCss();
4764
4778
  }, []);
@@ -4858,6 +4872,15 @@ var require_action_schema_view = __commonJS({
4858
4872
  }
4859
4873
  Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
4860
4874
  }
4875
+ function paramsOpen(action) {
4876
+ if (Object.prototype.hasOwnProperty.call(folds, action.name)) return folds[action.name] === true;
4877
+ return Boolean(String(query || "").trim()) || reqMode !== "all" || Boolean(typePick);
4878
+ }
4879
+ function resetFolds() {
4880
+ setFolds(function(prev) {
4881
+ return Object.keys(prev).length ? {} : prev;
4882
+ });
4883
+ }
4861
4884
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4862
4885
  return a && a.domain === DOMAIN;
4863
4886
  }) : [];
@@ -4954,6 +4977,10 @@ var require_action_schema_view = __commonJS({
4954
4977
  }
4955
4978
  function card(action) {
4956
4979
  var rows = paramRows(action);
4980
+ var required = rows.filter(function(row) {
4981
+ return row.required;
4982
+ }).length;
4983
+ var open = paramsOpen(action);
4957
4984
  var examples = Array.isArray(action.examples) ? action.examples : [];
4958
4985
  return h(
4959
4986
  "div",
@@ -4974,18 +5001,38 @@ var require_action_schema_view = __commonJS({
4974
5001
  ),
4975
5002
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
4976
5003
  rows.length ? h(
4977
- "table",
4978
- { className: P + "-table" },
4979
- h("thead", null, h(
4980
- "tr",
4981
- null,
4982
- h("th", null, t.colName),
4983
- h("th", null, t.colType),
4984
- h("th", null, t.colReq),
4985
- h("th", null, t.colExtra),
4986
- h("th", null, t.colDesc)
4987
- )),
4988
- h("tbody", null, rows.map(paramRow))
5004
+ "details",
5005
+ {
5006
+ className: P + "-params",
5007
+ "data-params-fold": action.name,
5008
+ open,
5009
+ // 原生 details 自带键盘与无障碍语义,这里只记下用户的开合;
5010
+ // 筛选变化引起的程序性开合也会触发 toggle,记下的值与当次默认一致,随后由 resetFolds 清掉。
5011
+ onToggle: function(e) {
5012
+ var next = !!(e && e.currentTarget && e.currentTarget.open);
5013
+ setFolds(function(prev) {
5014
+ if (prev[action.name] === next) return prev;
5015
+ var out = Object.assign({}, prev);
5016
+ out[action.name] = next;
5017
+ return out;
5018
+ });
5019
+ }
5020
+ },
5021
+ h("summary", null, t.params + (required ? " \xB7 " + t.requiredCount(required) : "")),
5022
+ h(
5023
+ "table",
5024
+ { className: P + "-table" },
5025
+ h("thead", null, h(
5026
+ "tr",
5027
+ null,
5028
+ h("th", null, t.colName),
5029
+ h("th", null, t.colType),
5030
+ h("th", null, t.colReq),
5031
+ h("th", null, t.colExtra),
5032
+ h("th", null, t.colDesc)
5033
+ )),
5034
+ h("tbody", null, rows.map(paramRow))
5035
+ )
4989
5036
  ) : h("div", { className: P + "-none" }, t.noParams),
4990
5037
  h(
4991
5038
  "div",
@@ -5062,6 +5109,7 @@ var require_action_schema_view = __commonJS({
5062
5109
  "aria-label": t.search,
5063
5110
  onChange: function(e) {
5064
5111
  setQuery(e.target.value);
5112
+ resetFolds();
5065
5113
  }
5066
5114
  })
5067
5115
  ),
@@ -5073,6 +5121,7 @@ var require_action_schema_view = __commonJS({
5073
5121
  "select",
5074
5122
  { value: reqMode, "aria-label": t.filterReq, onChange: function(e) {
5075
5123
  setReqMode(e.target.value);
5124
+ resetFolds();
5076
5125
  } },
5077
5126
  h("option", { value: "all" }, t.all),
5078
5127
  h("option", { value: "required" }, t.onlyRequired),
@@ -5087,6 +5136,7 @@ var require_action_schema_view = __commonJS({
5087
5136
  "select",
5088
5137
  { value: typePick, "aria-label": t.filterType, onChange: function(e) {
5089
5138
  setTypePick(e.target.value);
5139
+ resetFolds();
5090
5140
  } },
5091
5141
  h("option", { value: "" }, t.allTypes),
5092
5142
  typeOptions.map(function(name) {
@@ -5178,7 +5228,7 @@ function definition(host) {
5178
5228
  var tab = makeTab(host.react);
5179
5229
  return {
5180
5230
  id: ADDON_ID,
5181
- version: "0.2.11",
5231
+ version: "0.2.13",
5182
5232
  icon: tab("megaphone"),
5183
5233
  views: [
5184
5234
  {
package/lib/index.js CHANGED
@@ -12,6 +12,10 @@
12
12
  */
13
13
 
14
14
  import { bindClock, ensureSchema } from "./db/db.js";
15
+ import { createRequire } from "node:module";
16
+
17
+ // 版本号只认 package.json:首页插件卡读的就是这里注册的 version。
18
+ const ADDON_VERSION = createRequire(import.meta.url)("../package.json").version;
15
19
  import { DOMAIN, loadConfig } from "./config.js";
16
20
  import { createPlayer } from "./player.js";
17
21
  import { createSupervisor } from "./desktop/supervisor.js";
@@ -110,7 +114,7 @@ export function apply(ctx) {
110
114
  title: "弹幕",
111
115
  description:
112
116
  "把自建弹幕轮播在整个 DSH 界面,并可叠加到整个桌面;单一宿主调度、SSE 与 Electron helper 双投递,含弹幕库/配置/数据/Action 四个视图",
113
- version: "0.2.6",
117
+ version: ADDON_VERSION,
114
118
  category: "comm",
115
119
  tables: TABLES,
116
120
  sync: { tables: [] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-danmaku",
3
- "version": "0.2.11",
3
+ "version": "0.2.13",
4
4
  "description": "个人工作台弹幕插件:把自建弹幕轮播在整个 DSH 界面,并可叠加到整个桌面",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -17,7 +17,7 @@
17
17
  "id": "wb-addon-danmaku",
18
18
  "title": "弹幕",
19
19
  "description": "在整个 DSH 界面(含工作台业务页与宿主弹窗之外的所有区域)与桌面透明层轮播自建弹幕;含弹幕库、配置、数据与 Action 四个视图",
20
- "version": "0.2.11",
20
+ "version": "0.2.13",
21
21
  "minShell": "0.8.0",
22
22
  "tables": [
23
23
  "danmaku"
@@ -53,7 +53,7 @@
53
53
  "./package.json": "./package.json"
54
54
  },
55
55
  "dependencies": {
56
- "dsh-workbench-host": "^0.10.4"
56
+ "dsh-workbench-host": "^0.10.6"
57
57
  },
58
58
  "dsh": {
59
59
  "bundle": {