dsh-workbench-danmaku 0.2.4 → 0.2.7

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/cordis.patch.yml CHANGED
@@ -1,7 +1,12 @@
1
+ # 弹幕插件:插入宿主行和本插件自己的插件行。
2
+ #
3
+ # 宿主行必须由子插件插入:宿主是传递依赖,DSH 只把 profile 的直接依赖选进
4
+ # dsh.profile.bundles,所以单独装一个子插件时宿主不会被自动选入,只能靠这行加载。
5
+ # 但宿主行用块式写法时,插件市场会把它算进本插件的 insertedIds,任何第二个
6
+ # dsh-workbench 系插件都会被判「和已安装的插件冲突」并整次回滚;写成流式(flow style)
7
+ # 既能被 js-yaml 和 DSH 正常解析、插入同一行,又不会被市场那套逐行正则数到。
8
+ # 详见 docs/AGENTS规范/03-安装与交付.md。
1
9
  - insert:
2
- - id: workbench
3
- name: 'dsh-workbench-host'
4
- config:
5
- enabled: true
10
+ - { id: workbench, name: 'dsh-workbench-host', config: { enabled: true } }
6
11
  - id: workbench-danmaku
7
12
  name: 'dsh-workbench-danmaku'
package/lib/client.js CHANGED
@@ -849,11 +849,262 @@ var require_client_base_styles = __commonJS({
849
849
  }
850
850
  });
851
851
 
852
+ // packages/addons/lib/switch.cjs
853
+ var require_switch = __commonJS({
854
+ "packages/addons/lib/switch.cjs"(exports2, module2) {
855
+ "use strict";
856
+ var SWITCH_STYLES = [
857
+ ".wbctl-switch{display:inline-flex;align-items:center;gap:7px;min-height:24px;padding:2px;border:0;background:transparent;font:inherit;font-size:12px;color:var(--wb-muted,#6b7280);cursor:pointer;user-select:none;border-radius:999px}",
858
+ ".wbctl-switch-track{position:relative;display:inline-flex;align-items:center;box-sizing:border-box;width:34px;height:20px;padding:2px;border-radius:999px;background:color-mix(in oklab,currentColor 22%,transparent);transition:background .16s ease;flex:none}",
859
+ ".wbctl-switch-knob{display:block;width:16px;height:16px;border-radius:50%;background:var(--wb-card,#fff);box-shadow:0 1px 2px rgba(0,0,0,.25);transition:transform .16s ease}",
860
+ ".wbctl-switch[aria-checked=true]{color:var(--wb-accent,#2563eb)}",
861
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-track{background:var(--wb-accent,#2563eb)}",
862
+ ".wbctl-switch[aria-checked=true] .wbctl-switch-knob{transform:translateX(14px)}",
863
+ ".wbctl-switch:hover:not(:disabled) .wbctl-switch-track{outline:1px solid var(--wb-accent,#2563eb)}",
864
+ ".wbctl-switch:focus-visible{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
865
+ ".wbctl-switch:disabled{opacity:.45;cursor:not-allowed}",
866
+ ".wbctl-switch-text{white-space:nowrap}",
867
+ "@media (prefers-reduced-motion:reduce){.wbctl-switch-track,.wbctl-switch-knob{transition:none}}"
868
+ ];
869
+ function Switch(props) {
870
+ var h = props.h;
871
+ var on = props.checked === true || props.checked === "true";
872
+ var disabled = !!props.disabled;
873
+ var text = props.label;
874
+ if (props.showState) text = on ? props.onText || "\u5F00" : props.offText || "\u5173";
875
+ return h(
876
+ "button",
877
+ {
878
+ type: "button",
879
+ role: "switch",
880
+ "aria-checked": on ? "true" : "false",
881
+ className: "wbctl-switch" + (props.className ? " " + props.className : ""),
882
+ disabled,
883
+ title: props.title,
884
+ "aria-label": text ? void 0 : props.ariaLabel,
885
+ onClick: function(e) {
886
+ e.preventDefault();
887
+ if (disabled) return;
888
+ if (typeof props.onChange === "function") props.onChange(!on);
889
+ }
890
+ },
891
+ h(
892
+ "span",
893
+ { className: "wbctl-switch-track", "aria-hidden": "true" },
894
+ h("span", { className: "wbctl-switch-knob" })
895
+ ),
896
+ text ? h("span", { className: "wbctl-switch-text" }, text) : null
897
+ );
898
+ }
899
+ module2.exports = { Switch, styles: SWITCH_STYLES };
900
+ }
901
+ });
902
+
903
+ // packages/addons/lib/number-field.cjs
904
+ var require_number_field = __commonJS({
905
+ "packages/addons/lib/number-field.cjs"(exports2, module2) {
906
+ "use strict";
907
+ var React = require("react");
908
+ var NUM = /^[+-]?(?:\d+(?:\.\d*)?|\.\d+)$/;
909
+ var TEXT = {
910
+ zh: {
911
+ required: "\u8BF7\u586B\u5199\u6570\u5B57",
912
+ invalid: "\u8BF7\u8F93\u5165\u6570\u5B57",
913
+ integer: "\u9700\u8981\u662F\u6574\u6570",
914
+ min: "\u4E0D\u80FD\u5C0F\u4E8E {min}",
915
+ max: "\u4E0D\u80FD\u5927\u4E8E {max}",
916
+ range: "\u9700\u8981\u5728 {min}\u2013{max} \u4E4B\u95F4",
917
+ step: "\u9700\u8981\u662F {step} \u7684\u500D\u6570",
918
+ unit: "\u5355\u4F4D"
919
+ },
920
+ en: {
921
+ required: "Please enter a number",
922
+ invalid: "Please enter a number",
923
+ integer: "Must be a whole number",
924
+ min: "Must be at least {min}",
925
+ max: "Must be at most {max}",
926
+ range: "Must be between {min} and {max}",
927
+ step: "Must be a multiple of {step}",
928
+ unit: "unit"
929
+ }
930
+ };
931
+ function messages(lang) {
932
+ return lang === "en" ? TEXT.en : TEXT.zh;
933
+ }
934
+ function fill(text, vars) {
935
+ return String(text).replace(/\{(\w+)\}/g, function(m, key) {
936
+ return vars && vars[key] !== void 0 ? String(vars[key]) : m;
937
+ });
938
+ }
939
+ function validateNumber(raw, opts) {
940
+ var o = opts || {};
941
+ var M = messages(o.lang);
942
+ var text = raw === null || raw === void 0 ? "" : String(raw).trim();
943
+ if (text === "") {
944
+ return o.allowEmpty ? { ok: true, value: null, error: "" } : { ok: false, value: null, error: M.required };
945
+ }
946
+ if (!NUM.test(text)) return { ok: false, value: null, error: M.invalid };
947
+ var n = Number(text);
948
+ if (!isFinite(n)) return { ok: false, value: null, error: M.invalid };
949
+ if (o.integer && Math.round(n) !== n) return { ok: false, value: null, error: M.integer };
950
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
951
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
952
+ if (hasMin && hasMax && n >= o.min && n <= o.max) {
953
+ } else if (hasMin && hasMax) {
954
+ return { ok: false, value: null, error: fill(M.range, { min: o.min, max: o.max }) };
955
+ } else if (hasMin && n < o.min) {
956
+ return { ok: false, value: null, error: fill(M.min, { min: o.min }) };
957
+ } else if (hasMax && n > o.max) {
958
+ return { ok: false, value: null, error: fill(M.max, { max: o.max }) };
959
+ }
960
+ if (o.step && Number(o.step) > 0) {
961
+ var q = n / Number(o.step);
962
+ if (Math.abs(q - Math.round(q)) > 1e-9) {
963
+ return { ok: false, value: null, error: fill(M.step, { step: o.step }) };
964
+ }
965
+ }
966
+ return { ok: true, value: n, error: "" };
967
+ }
968
+ function rangeHint(opts, lang) {
969
+ var o = opts || {};
970
+ var M = messages(lang);
971
+ var en = lang === "en";
972
+ var hasMin = o.min !== void 0 && o.min !== null && o.min !== "";
973
+ var hasMax = o.max !== void 0 && o.max !== null && o.max !== "";
974
+ var parts = [];
975
+ if (hasMin && hasMax) parts.push(String(o.min) + "\u2013" + String(o.max));
976
+ else if (hasMin) parts.push((en ? "\u2265 " : "\u2265 ") + String(o.min));
977
+ else if (hasMax) parts.push((en ? "\u2264 " : "\u2264 ") + String(o.max));
978
+ if (o.integer) parts.push(en ? "whole numbers" : "\u6574\u6570");
979
+ else if (o.step && Number(o.step) > 0) parts.push((en ? "step " : "\u6B65\u957F ") + String(o.step));
980
+ return parts.join(en ? ", " : "\uFF0C");
981
+ }
982
+ function NumberField(props) {
983
+ var h = props.h || React.createElement;
984
+ var lang = props.lang;
985
+ var M = messages(lang);
986
+ var text = props.value === null || props.value === void 0 ? "" : String(props.value);
987
+ var draftS = React.useState(text);
988
+ var draft = draftS[0];
989
+ var setDraft = draftS[1];
990
+ var focusS = React.useState(false);
991
+ var focused = focusS[0];
992
+ var setFocused = focusS[1];
993
+ var errS = React.useState("");
994
+ var err = errS[0];
995
+ var setErr = errS[1];
996
+ var lastRef = React.useRef(text);
997
+ var skipBlurRef = React.useRef(false);
998
+ React.useEffect(
999
+ function() {
1000
+ if (focused) return;
1001
+ if (lastRef.current === text) return;
1002
+ lastRef.current = text;
1003
+ setDraft(text);
1004
+ setErr("");
1005
+ },
1006
+ [text, focused]
1007
+ );
1008
+ function commit(raw) {
1009
+ var r = validateNumber(raw, props);
1010
+ if (!r.ok) {
1011
+ setErr(r.error);
1012
+ if (typeof props.onValidChange === "function") props.onValidChange(false, r.error);
1013
+ return false;
1014
+ }
1015
+ setErr("");
1016
+ if (typeof props.onValidChange === "function") props.onValidChange(true, "");
1017
+ var cur = props.value === null || props.value === void 0 ? null : Number(props.value);
1018
+ if (r.value !== cur) {
1019
+ lastRef.current = r.value === null ? "" : String(r.value);
1020
+ if (typeof props.onCommit === "function") props.onCommit(r.value);
1021
+ }
1022
+ return true;
1023
+ }
1024
+ var hint = props.hint !== void 0 ? props.hint : rangeHint(props, lang);
1025
+ var shown = props.hint === false ? "" : hint;
1026
+ return h(
1027
+ "span",
1028
+ { className: "wbctl-num" + (props.wide ? " is-wide" : "") + (props.className ? " " + props.className : "") },
1029
+ h(
1030
+ "span",
1031
+ { className: "wbctl-num-box" },
1032
+ h("input", {
1033
+ className: "wbctl-num-input" + (err ? " is-invalid" : ""),
1034
+ type: "text",
1035
+ inputMode: props.integer || Number(props.step) === 1 ? "numeric" : "decimal",
1036
+ value: draft,
1037
+ disabled: !!props.disabled,
1038
+ placeholder: props.placeholder,
1039
+ title: props.title,
1040
+ "aria-label": props.ariaLabel,
1041
+ "aria-invalid": err ? "true" : void 0,
1042
+ onFocus: function() {
1043
+ setFocused(true);
1044
+ },
1045
+ onChange: function(e) {
1046
+ setDraft(e.target.value);
1047
+ if (err) setErr("");
1048
+ if (typeof props.onDraft === "function") props.onDraft(e.target.value);
1049
+ },
1050
+ onBlur: function() {
1051
+ setFocused(false);
1052
+ if (skipBlurRef.current) {
1053
+ skipBlurRef.current = false;
1054
+ return;
1055
+ }
1056
+ commit(draft);
1057
+ },
1058
+ onKeyDown: function(e) {
1059
+ if (e.key === "Enter") {
1060
+ e.preventDefault();
1061
+ if (e.target && e.target.blur) e.target.blur();
1062
+ } else if (e.key === "Escape") {
1063
+ e.preventDefault();
1064
+ skipBlurRef.current = true;
1065
+ setDraft(text);
1066
+ setErr("");
1067
+ if (e.target && e.target.blur) e.target.blur();
1068
+ }
1069
+ }
1070
+ }),
1071
+ props.unit ? h("span", { className: "wbctl-num-unit" }, props.unit) : null
1072
+ ),
1073
+ err ? h("span", { className: "wbctl-num-err", role: "alert" }, err) : shown ? h("span", { className: "wbctl-num-hint" }, shown) : null
1074
+ );
1075
+ }
1076
+ var NUMBER_STYLES = [
1077
+ ".wbctl-num{display:inline-flex;flex-direction:column;gap:3px;min-width:0;max-width:100%}",
1078
+ ".wbctl-num.is-wide{display:flex;width:100%}",
1079
+ ".wbctl-num-box{display:inline-flex;align-items:center;gap:6px;min-width:0}",
1080
+ ".wbctl-num-input{box-sizing:border-box;width:96px;min-width:0;padding:6px 9px;border:1px solid var(--wb-line,rgba(127,127,127,.35));border-radius:6px;background:var(--wb-surface,var(--wb-card,transparent));color:inherit;font:inherit;font-size:13px;font-variant-numeric:tabular-nums;transition:border-color .14s ease,outline-color .14s ease}",
1081
+ ".wbctl-num-input:hover:not(:disabled){border-color:var(--wb-border,var(--wb-line))}",
1082
+ ".wbctl-num-input:focus{outline:2px solid color-mix(in oklab,var(--wb-accent,#2563eb) 55%,transparent);outline-offset:1px;border-color:var(--wb-accent,#2563eb)}",
1083
+ ".wbctl-num-input.is-invalid{border-color:var(--wb-danger,#dc2626)}",
1084
+ ".wbctl-num-input.is-invalid:focus{outline-color:color-mix(in oklab,var(--wb-danger,#dc2626) 55%,transparent)}",
1085
+ ".wbctl-num-input:disabled{opacity:.5;cursor:not-allowed}",
1086
+ ".wbctl-num-unit{color:var(--wb-muted,inherit);font-size:12px;white-space:nowrap}",
1087
+ ".wbctl-num-hint{color:var(--wb-muted,inherit);font-size:11px;line-height:1.4}",
1088
+ ".wbctl-num-err{color:var(--wb-danger,#dc2626);font-size:11px;line-height:1.4}",
1089
+ "@media (prefers-reduced-motion:reduce){.wbctl-num-input{transition:none}}"
1090
+ ];
1091
+ module2.exports = {
1092
+ NumberField,
1093
+ validateNumber,
1094
+ rangeHint,
1095
+ messages,
1096
+ styles: NUMBER_STYLES
1097
+ };
1098
+ }
1099
+ });
1100
+
852
1101
  // packages/addons/danmaku/client/styles.cjs
853
1102
  var require_styles = __commonJS({
854
1103
  "packages/addons/danmaku/client/styles.cjs"(exports2, module2) {
855
1104
  "use strict";
856
1105
  var baseStyles = require_client_base_styles();
1106
+ var SW = require_switch();
1107
+ var NF = require_number_field();
857
1108
  function pageStyles() {
858
1109
  return [
859
1110
  /* 页面骨架:hero 一行,下面是卡片 */
@@ -909,14 +1160,7 @@ var require_styles = __commonJS({
909
1160
  ".wbdm-icon-btn:hover{background:rgba(127,127,127,.12);color:var(--wb-accent,#2563eb)}",
910
1161
  ".wbdm-icon-btn.danger:hover{color:var(--wb-danger,#dc2626)}",
911
1162
  ".wbdm-icon-btn:disabled{opacity:.3;cursor:not-allowed}",
912
- /* 开关 */
913
- ".wbdm-switch{position:relative;display:inline-flex;flex:none;width:34px;height:20px;cursor:pointer}",
914
- ".wbdm-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
915
- ".wbdm-track{display:block;width:100%;height:100%;border-radius:999px;background:var(--wb-line,#e5e7eb);transition:background .15s}",
916
- ".wbdm-knob{position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--wb-card,#fff);box-shadow:0 1px 2px rgba(0,0,0,.3);transition:transform .15s;pointer-events:none}",
917
- ".wbdm-switch input:checked+.wbdm-track{background:var(--wb-accent,#2563eb)}",
918
- ".wbdm-switch input:checked~.wbdm-knob{transform:translateX(14px)}",
919
- ".wbdm-switch input:focus-visible+.wbdm-track{outline:2px solid var(--wb-accent,#2563eb);outline-offset:2px}",
1163
+ /* 开关外观统一由 lib/switch.cjs 的 wbctl-* 规则提供,见文件末尾追加 */
920
1164
  // 行内小开关(添加卡里的「卡片背景」)
921
1165
  ".wbdm-inline-label{white-space:nowrap}",
922
1166
  // 行内「卡片/纯文字」标签:点一下切换该条弹幕是否有底
@@ -936,7 +1180,8 @@ var require_styles = __commonJS({
936
1180
  ".wbdm-ctl{display:flex;align-items:center;gap:8px;min-width:0}",
937
1181
  ".wbdm-input,.wbdm-select{box-sizing:border-box;padding:5px 9px;border:1px solid var(--wb-border,#e5e7eb);border-radius:8px;background:var(--wb-surface,#fff);color:inherit;font:inherit;font-size:12px}",
938
1182
  ".wbdm-input{width:100%;max-width:280px}",
939
- ".wbdm-input[type=number]{width:96px}",
1183
+ /* 数字项改用共享控件(wbctl-num*)后,这里只给它一个与其它控件一致的窄宽度。 */
1184
+ ".wbdm-crow .wbctl-num .wbctl-num-input{width:120px}",
940
1185
  ".wbdm-select{min-width:140px;max-width:280px}",
941
1186
  ".wbdm-input:focus,.wbdm-select:focus{outline:none;border-color:var(--wb-accent,#2563eb);box-shadow:0 0 0 3px rgba(37,99,235,.14)}",
942
1187
  /* 桌面层状态 */
@@ -983,7 +1228,7 @@ var require_styles = __commonJS({
983
1228
  ];
984
1229
  }
985
1230
  module2.exports = function styles2() {
986
- return baseStyles("wbdm").concat(pageStyles());
1231
+ return baseStyles("wbdm").concat(pageStyles(), SW.styles, NF.styles);
987
1232
  };
988
1233
  module2.exports.pageStyles = pageStyles;
989
1234
  }
@@ -1755,8 +2000,9 @@ var require_overlay = __commonJS({
1755
2000
  var autoFocusDialog = opts.autoFocusDialog !== false;
1756
2001
  var focusableSelector = opts.focusableSelector || FOCUSABLE;
1757
2002
  function Modal(props) {
1758
- var ref = React.useRef(null);
1759
- React.useEffect(function() {
2003
+ var R = props.React || React;
2004
+ var ref = R.useRef(null);
2005
+ R.useEffect(function() {
1760
2006
  var previous = typeof document !== "undefined" ? document.activeElement : null;
1761
2007
  var focusIt = props.autoFocus !== void 0 ? props.autoFocus : autoFocusDialog;
1762
2008
  if (focusIt && ref.current) ref.current.focus();
@@ -1831,6 +2077,8 @@ var require_detail = __commonJS({
1831
2077
  var h = React.createElement;
1832
2078
  var chipStyle = require_chip_style();
1833
2079
  var createOverlay = require_overlay();
2080
+ var SW = require_switch();
2081
+ var NF = require_number_field();
1834
2082
  var REDUCED = false;
1835
2083
  try {
1836
2084
  REDUCED = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
@@ -1954,6 +2202,7 @@ var require_detail = __commonJS({
1954
2202
  );
1955
2203
  }
1956
2204
  function numField(key, label, hint, step, min, max) {
2205
+ var showHint = min + "\u2013" + max + (step === 1 ? "\uFF0C\u6574\u6570" : "\uFF0C\u6B65\u957F " + step);
1957
2206
  return h(
1958
2207
  "label",
1959
2208
  { className: "wbdm-crow" },
@@ -1963,16 +2212,18 @@ var require_detail = __commonJS({
1963
2212
  h("span", { className: "wbdm-crow-t" }, label),
1964
2213
  h("span", { className: "wbdm-crow-h" }, hint)
1965
2214
  ),
1966
- h("input", {
1967
- className: "wbdm-input",
1968
- type: "number",
2215
+ h(NF.NumberField, {
2216
+ h,
1969
2217
  value: numberOrText(detail[key]),
1970
2218
  min,
1971
2219
  max,
1972
- step,
2220
+ integer: Math.round(step) === step,
2221
+ allowEmpty: true,
2222
+ ariaLabel: label,
1973
2223
  placeholder: C.followGlobal,
1974
- onChange: function(e) {
1975
- set(key, e.target.value);
2224
+ hint: showHint,
2225
+ onCommit: function(next) {
2226
+ set(key, next === null ? "" : String(next));
1976
2227
  }
1977
2228
  })
1978
2229
  );
@@ -2004,22 +2255,18 @@ var require_detail = __commonJS({
2004
2255
  }
2005
2256
  function switchField(key, label) {
2006
2257
  return h(
2007
- "label",
2258
+ "div",
2008
2259
  { className: "wbdm-crow" },
2009
2260
  h("span", { className: "wbdm-crow-label" }, h("span", { className: "wbdm-crow-t" }, label)),
2010
- h(
2011
- "span",
2012
- { className: "wbdm-switch" },
2013
- h("input", {
2014
- type: "checkbox",
2015
- checked: Boolean(detail[key]),
2016
- onChange: function() {
2017
- set(key, !detail[key]);
2018
- }
2019
- }),
2020
- h("span", { className: "wbdm-track" }),
2021
- h("span", { className: "wbdm-knob" })
2022
- )
2261
+ // 共享开关自带 role="switch"/aria-checked;左侧已有文案,这里不再重复显示状态。
2262
+ h(SW.Switch, {
2263
+ h,
2264
+ checked: Boolean(detail[key]),
2265
+ ariaLabel: label,
2266
+ onChange: function(next) {
2267
+ set(key, next);
2268
+ }
2269
+ })
2023
2270
  );
2024
2271
  }
2025
2272
  var weights = [{ value: "", label: C.followGlobal }];
@@ -2089,7 +2336,7 @@ var require_detail = __commonJS({
2089
2336
  h("div", { className: "wbdm-tones" }, TONES.map(toneChip))
2090
2337
  ),
2091
2338
  h(
2092
- "label",
2339
+ "div",
2093
2340
  { className: "wbdm-crow" },
2094
2341
  h(
2095
2342
  "span",
@@ -2097,24 +2344,19 @@ var require_detail = __commonJS({
2097
2344
  h("span", { className: "wbdm-crow-t" }, C.card),
2098
2345
  h("span", { className: "wbdm-crow-h" }, C.cardHint)
2099
2346
  ),
2100
- h(
2101
- "span",
2102
- { className: "wbdm-switch" },
2103
- h("input", {
2104
- type: "checkbox",
2105
- checked: Boolean(detail.card),
2106
- onChange: function() {
2107
- set("card", !detail.card);
2108
- }
2109
- }),
2110
- h("span", { className: "wbdm-track" }),
2111
- h("span", { className: "wbdm-knob" })
2112
- )
2347
+ h(SW.Switch, {
2348
+ h,
2349
+ checked: Boolean(detail.card),
2350
+ ariaLabel: C.card,
2351
+ onChange: function(next) {
2352
+ set("card", next);
2353
+ }
2354
+ })
2113
2355
  ),
2114
2356
  numField("fontSize", C.fontSize, C.unitPx + " \xB7 " + C.followGlobal, 1, 10, 48),
2115
2357
  selectField("fontWeight", C.weight, weights),
2116
2358
  selectField("fontFamily", C.family, families),
2117
- numField("opacity", C.opacity, "0.15\u20131 \xB7 " + C.followGlobal, 0.02, 0.15, 1)
2359
+ numField("opacity", C.opacity, C.followGlobal, 0.02, 0.15, 1)
2118
2360
  ),
2119
2361
  h(
2120
2362
  "section",
@@ -2202,6 +2444,7 @@ var require_library = __commonJS({
2202
2444
  var React = require("react");
2203
2445
  var h = React.createElement;
2204
2446
  var copy = require_copy();
2447
+ var SW = require_switch();
2205
2448
  var ICONS = {
2206
2449
  up: GLYPHS2["arrow-up"],
2207
2450
  down: GLYPHS2["arrow-down"],
@@ -2521,19 +2764,16 @@ var require_library = __commonJS({
2521
2764
  "div",
2522
2765
  { key: item.id, className: "wbdm-item" + (item.enabled ? "" : " off") },
2523
2766
  h("span", { className: "wbdm-order" }, String(index + 1)),
2524
- h(
2525
- "label",
2526
- { className: "wbdm-switch", title: item.enabled ? C.disable : C.enable },
2527
- h("input", {
2528
- type: "checkbox",
2529
- checked: Boolean(item.enabled),
2530
- onChange: function() {
2531
- toggle(item);
2532
- }
2533
- }),
2534
- h("span", { className: "wbdm-track" }),
2535
- h("span", { className: "wbdm-knob" })
2536
- ),
2767
+ h(SW.Switch, {
2768
+ h,
2769
+ checked: Boolean(item.enabled),
2770
+ title: item.enabled ? C.disable : C.enable,
2771
+ // 开关的可访问名称用「启用」这个设置名;title 只作为点击后的动作提示。
2772
+ ariaLabel: C.enable,
2773
+ onChange: function() {
2774
+ toggle(item);
2775
+ }
2776
+ }),
2537
2777
  h(
2538
2778
  "span",
2539
2779
  { className: "wbdm-tag" },
@@ -2685,6 +2925,8 @@ var require_config = __commonJS({
2685
2925
  var React = require("react");
2686
2926
  var h = React.createElement;
2687
2927
  var copy = require_copy();
2928
+ var SW = require_switch();
2929
+ var NF = require_number_field();
2688
2930
  var DOMAIN = "danmaku";
2689
2931
  var ICONS = {
2690
2932
  check: GLYPHS2["check"],
@@ -2947,20 +3189,15 @@ var require_config = __commonJS({
2947
3189
  });
2948
3190
  }
2949
3191
  function switchControl(item, value) {
2950
- return h(
2951
- "label",
2952
- { className: "wbdm-switch", title: labelOf(item, lang) },
2953
- h("input", {
2954
- type: "checkbox",
2955
- checked: value === true,
2956
- "aria-label": labelOf(item, lang),
2957
- onChange: function(e) {
2958
- save(item.id, e.target.checked);
2959
- }
2960
- }),
2961
- h("span", { className: "wbdm-track" }),
2962
- h("span", { className: "wbdm-knob" })
2963
- );
3192
+ return h(SW.Switch, {
3193
+ h,
3194
+ checked: value === true,
3195
+ title: labelOf(item, lang),
3196
+ ariaLabel: labelOf(item, lang),
3197
+ onChange: function(next) {
3198
+ save(item.id, next);
3199
+ }
3200
+ });
2964
3201
  }
2965
3202
  function control(item) {
2966
3203
  var value = values()[item.id];
@@ -2989,17 +3226,15 @@ var require_config = __commonJS({
2989
3226
  );
2990
3227
  }
2991
3228
  if (item.type === "int" || item.type === "number") {
2992
- return h("input", {
2993
- className: "wbdm-input",
2994
- type: "number",
2995
- step: item.type === "number" ? 0.05 : 1,
3229
+ return h(NF.NumberField, {
3230
+ h,
3231
+ lang,
3232
+ value: value === void 0 ? "" : value,
2996
3233
  min: item.min,
2997
3234
  max: item.max,
2998
- value: value === void 0 ? "" : value,
2999
- "aria-label": labelOf(item, lang),
3000
- onChange: function(e) {
3001
- var next = Number(e.target.value);
3002
- if (!isFinite(next)) return;
3235
+ integer: item.type === "int",
3236
+ ariaLabel: labelOf(item, lang),
3237
+ onCommit: function(next) {
3003
3238
  save(item.id, next);
3004
3239
  }
3005
3240
  });
@@ -3260,13 +3495,6 @@ var require_data_style = __commonJS({
3260
3495
  "." + P + "-search input:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3261
3496
  "." + P + "-select{border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:9px;padding:7px 10px;font:inherit;font-size:12px;outline:none}",
3262
3497
  "." + P + "-select:focus{border-color:var(--dsw-alias-brand-primary,currentColor);box-shadow:0 0 0 3px color-mix(in oklab,var(--dsw-alias-brand-primary,currentColor) 14%,transparent)}",
3263
- "." + P + "-switch{position:relative;display:inline-flex;align-items:center;gap:7px;cursor:pointer;font-size:12px;color:var(--cfg-muted);user-select:none;padding:4px 2px}",
3264
- "." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
3265
- "." + P + "-track{position:relative;width:34px;height:20px;border-radius:999px;background:color-mix(in oklab,currentColor 18%,transparent);transition:background .16s ease;flex:none}",
3266
- "." + P + "-track::after{content:'';position:absolute;top:2px;left:2px;width:16px;height:16px;border-radius:50%;background:var(--dsw-alias-label-primary,currentColor);transition:transform .16s ease,background .16s ease}",
3267
- "." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
3268
- "." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
3269
- "." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3270
3498
  "." + P + "-btn{display:inline-flex;align-items:center;gap:5px;border:1px solid var(--cfg-line);background:transparent;color:var(--cfg-muted);border-radius:8px;padding:6px 10px;font:inherit;font-size:11.5px;cursor:pointer;white-space:nowrap;transition:background .12s ease,color .12s ease}",
3271
3499
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3272
3500
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -3295,8 +3523,8 @@ var require_data_style = __commonJS({
3295
3523
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3296
3524
  "." + P + "-grow{flex:1}",
3297
3525
  "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
3298
- "." + P + "-jump{width:56px;border:1px solid var(--cfg-line);background:var(--dsw-alias-bg-base,transparent);color:inherit;border-radius:7px;padding:4px 7px;font:inherit;font-size:11.5px;text-align:right;outline:none}",
3299
- "." + P + "-jump:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
3526
+ "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
3527
+ "." + P + "-jump .wbctl-num-hint{display:none}",
3300
3528
  "." + P + "-empty{border:1px dashed var(--cfg-line);border-radius:11px;padding:44px 16px;text-align:center;font-size:12.5px;color:var(--cfg-muted)}",
3301
3529
  "." + P + "-err{display:flex;align-items:center;gap:10px;flex-wrap:wrap;border:1px solid color-mix(in oklab,var(--dsw-alias-state-error-primary,currentColor) 32%,var(--cfg-line));border-radius:10px;padding:9px 12px;color:var(--dsw-alias-state-error-primary,inherit);font-size:12px;line-height:1.5}",
3302
3530
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -3334,7 +3562,7 @@ var require_data_style = __commonJS({
3334
3562
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3335
3563
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3336
3564
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3337
- ].join("\n");
3565
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3338
3566
  if (DOMAIN === "storage") {
3339
3567
  var buttons = "." + P + " :is(button)";
3340
3568
  CSS += buttons + "{border:none;background:var(--wb-btn-bg);min-height:var(--wb-btn-size-sm);min-width:var(--wb-btn-size-sm)}" + buttons + ":enabled:hover{background:var(--wb-btn-hover-bg)}" + buttons + ":enabled:active{background:var(--wb-btn-active-bg)}" + buttons + ":disabled{background:var(--wb-btn-bg);color:var(--cfg-muted)}" + buttons + ":focus-visible{outline:var(--wb-btn-focus);outline-offset:var(--wb-btn-focus-offset)}." + P + "-fcell:has(button) input{padding-right:34px}";
@@ -3362,8 +3590,10 @@ var require_data_view = __commonJS({
3362
3590
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
3363
3591
  "use strict";
3364
3592
  var React = require("react");
3593
+ var NF = require_number_field();
3365
3594
  var h = React.createElement;
3366
3595
  var COPY = require_data_copy();
3596
+ var SW = require_switch();
3367
3597
  module2.exports = function createDataView(options) {
3368
3598
  var DOMAIN = options.domain;
3369
3599
  function icon(name) {
@@ -3917,17 +4147,18 @@ var require_data_view = __commonJS({
3917
4147
  h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
3918
4148
  setPage(Math.min(pages, page + 1));
3919
4149
  } }, t.next + " \u203A"),
3920
- h("input", {
4150
+ h(NF.NumberField, {
4151
+ h,
4152
+ lang,
3921
4153
  className: P + "-jump",
3922
- type: "number",
4154
+ value: page,
3923
4155
  min: 1,
3924
4156
  max: pages,
3925
- "aria-label": t.jump,
3926
- onKeyDown: function(e) {
3927
- if (e.key === "Enter") {
3928
- var n = Math.floor(Number(e.target.value));
3929
- if (n >= 1) setPage(Math.min(pages, n));
3930
- }
4157
+ integer: true,
4158
+ ariaLabel: t.jump,
4159
+ hint: false,
4160
+ onCommit: function(next) {
4161
+ if (next !== null) setPage(next);
3931
4162
  }
3932
4163
  }),
3933
4164
  data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -4024,25 +4255,23 @@ var require_data_view = __commonJS({
4024
4255
  }
4025
4256
  })
4026
4257
  ),
4027
- h(
4028
- "label",
4029
- { className: P + "-switch" },
4030
- h("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
4031
- setIncludeDeleted(e.target.checked);
4258
+ h(SW.Switch, {
4259
+ h,
4260
+ checked: includeDeleted,
4261
+ label: t.includeDeleted,
4262
+ onChange: function(next) {
4263
+ setIncludeDeleted(next);
4032
4264
  setPage(1);
4033
- } }),
4034
- h("span", { className: P + "-track" }),
4035
- h("span", null, t.includeDeleted)
4036
- ),
4037
- h(
4038
- "label",
4039
- { className: P + "-switch" },
4040
- h("input", { type: "checkbox", checked: showSystem, onChange: function(e) {
4041
- setShowSystem(e.target.checked);
4042
- } }),
4043
- h("span", { className: P + "-track" }),
4044
- h("span", null, t.showSystem)
4045
- ),
4265
+ }
4266
+ }),
4267
+ h(SW.Switch, {
4268
+ h,
4269
+ checked: showSystem,
4270
+ label: t.showSystem,
4271
+ onChange: function(next) {
4272
+ setShowSystem(next);
4273
+ }
4274
+ }),
4046
4275
  h("span", { className: P + "-grow" }),
4047
4276
  h(
4048
4277
  "label",
@@ -4195,16 +4424,13 @@ var require_action_schema_style = __commonJS({
4195
4424
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4196
4425
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4197
4426
  "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
4198
- "." + P + "-toggle{display:inline-flex;align-items:center;gap:6px;min-height:24px;padding:0 2px;border:0;background:transparent;font:inherit;font-size:11.5px;color:var(--wb-muted);cursor:pointer}",
4199
- "." + P + "-track{display:inline-flex;align-items:center;box-sizing:border-box;width:30px;height:18px;padding:2px;border:1px solid var(--wb-muted);border-radius:999px;background:var(--wb-surface);color:var(--wb-muted)}",
4200
- "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
4201
- "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
4202
- "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
4203
- "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
4204
- "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4205
- "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
4206
- "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
4207
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
4427
+ "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
4428
+ "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
4429
+ "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
4430
+ // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
4431
+ "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
4432
+ "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
4433
+ "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4208
4434
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4209
4435
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4210
4436
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -4257,15 +4483,20 @@ var require_action_schema_view = __commonJS({
4257
4483
  zh: {
4258
4484
  title: "Action",
4259
4485
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
4260
- switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
4261
- hostHint: "\u5BBF\u4E3B action \u7684 agent \u5F00\u5173\uFF1B\u6807\u300C\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F\u300D\u7684\u4E0D\u53EF\u653E\u5F00\u3002",
4262
- agentSwitch: "agent \u53EF\u7528",
4263
- agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
4264
- agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
4265
- agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
4266
- agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
4267
- agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
4268
- agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
4486
+ switchHint: "\u5141\u8BB8\u6765\u6E90\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1A\u52FE\u4E0A\u7684\u6765\u6E90\u624D\u80FD\u8C03\u7528\u8BE5 action\uFF0C\u5176\u4F59\u4F1A\u88AB ACTION_ORIGIN_DENIED \u62E6\u4E0B\u3002",
4487
+ hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
4488
+ originsLabel: "\u5141\u8BB8\u6765\u6E90",
4489
+ originUi: "\u754C\u9762",
4490
+ originPlugin: "\u63D2\u4EF6",
4491
+ originAgent: "agent",
4492
+ originSync: "\u540C\u6B65",
4493
+ originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
4494
+ originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
4495
+ originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
4496
+ originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
4497
+ originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
4498
+ originsPinned: "\u6765\u6E90\u56FA\u5B9A",
4499
+ originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
4269
4500
  domain: "\u57DF",
4270
4501
  versionLabel: "\u7248\u672C",
4271
4502
  shell: "\u5BBF\u4E3B",
@@ -4279,6 +4510,8 @@ var require_action_schema_view = __commonJS({
4279
4510
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
4280
4511
  filterType: "\u53C2\u6570\u7C7B\u578B",
4281
4512
  allTypes: "\u5168\u90E8\u7C7B\u578B",
4513
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
4514
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
4282
4515
  colName: "\u53C2\u6570",
4283
4516
  colType: "\u7C7B\u578B",
4284
4517
  colReq: "\u5FC5\u586B",
@@ -4311,15 +4544,22 @@ var require_action_schema_view = __commonJS({
4311
4544
  en: {
4312
4545
  title: "Actions",
4313
4546
  hint: "runtime registry \xB7 read-only",
4314
- switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
4315
- hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
4316
- agentSwitch: "Agent callable",
4317
- agentLocked: "UI only \xB7 security",
4318
- agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
4319
- agentSaving: "Saving\u2026",
4320
- agentOnToast: "Agent calls allowed",
4321
- agentOffToast: "Agent calls blocked",
4322
- agentFail: "Failed to change the agent switch",
4547
+ switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
4548
+ hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
4549
+ originsLabel: "Origins",
4550
+ originUi: "UI",
4551
+ originPlugin: "Plugin",
4552
+ originAgent: "Agent",
4553
+ originSync: "Sync",
4554
+ originsSaving: "Saving\u2026",
4555
+ originsToast: "Allowed origins updated",
4556
+ originsFail: "Failed to update allowed origins",
4557
+ originsEmpty: "Keep at least one origin",
4558
+ originsUnsupported: "This action does not support this origin",
4559
+ originsPinned: "Pinned",
4560
+ originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
4561
+ originsDefaultOn: "Allowed by default",
4562
+ originsDefaultOff: "Off by default, can be enabled",
4323
4563
  domain: "Domain",
4324
4564
  versionLabel: "Version",
4325
4565
  shell: "Host",
@@ -4333,6 +4573,8 @@ var require_action_schema_view = __commonJS({
4333
4573
  onlyOptional: "No required",
4334
4574
  filterType: "Param type",
4335
4575
  allTypes: "All types",
4576
+ filterOrigin: "Origins",
4577
+ allOrigins: "All origins",
4336
4578
  colName: "Param",
4337
4579
  colType: "Type",
4338
4580
  colReq: "Required",
@@ -4476,6 +4718,8 @@ var require_action_schema_view = __commonJS({
4476
4718
  var reqMode = reqState[0], setReqMode = reqState[1];
4477
4719
  var typeState = React.useState("");
4478
4720
  var typePick = typeState[0], setTypePick = typeState[1];
4721
+ var originFilterState = React.useState("");
4722
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
4479
4723
  var toastState = React.useState("");
4480
4724
  var toast = toastState[0], setToast = toastState[1];
4481
4725
  var savingState = React.useState("");
@@ -4531,38 +4775,53 @@ var require_action_schema_view = __commonJS({
4531
4775
  plainCopy(text);
4532
4776
  done();
4533
4777
  }
4534
- function setAgent(action, next) {
4778
+ var ORIGINS = ["ui", "plugin", "agent", "sync"];
4779
+ var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
4780
+ function setOrigins(action, origin) {
4535
4781
  var name = action.name;
4782
+ var current = Array.isArray(action.origins) ? action.origins.slice() : [];
4783
+ var index = current.indexOf(origin);
4784
+ var next = index >= 0 ? current.filter(function(o) {
4785
+ return o !== origin;
4786
+ }) : current.concat([origin]);
4787
+ if (next.length === 0) {
4788
+ setToast(t.originsEmpty);
4789
+ return;
4790
+ }
4791
+ next = ORIGINS.filter(function(o) {
4792
+ return next.indexOf(o) >= 0;
4793
+ });
4536
4794
  setSaving(name);
4537
4795
  setToast("");
4538
4796
  var fail = function(e) {
4539
4797
  setSaving("");
4540
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
4798
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
4541
4799
  };
4542
4800
  var done = function(r) {
4543
4801
  setSaving("");
4544
4802
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
4545
4803
  if (r && r.ok === false) {
4546
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
4804
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
4547
4805
  return;
4548
4806
  }
4549
- var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
4807
+ var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
4808
+ var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
4550
4809
  setSnap(function(prev) {
4551
4810
  if (!prev || !Array.isArray(prev.actions)) return prev;
4552
4811
  return Object.assign({}, prev, {
4553
4812
  actions: prev.actions.map(function(a) {
4554
4813
  if (!a || a.name !== name) return a;
4555
- return Object.assign({}, a, { agentEnabled: value });
4814
+ return Object.assign({}, a, { origins: value, originsSource: source });
4556
4815
  })
4557
4816
  });
4558
4817
  });
4559
- setToast(value ? t.agentOnToast : t.agentOffToast);
4818
+ setToast(t.originsToast);
4560
4819
  };
4561
4820
  if (!api || typeof api.call !== "function") {
4562
4821
  fail(new Error("no call api"));
4563
4822
  return;
4564
4823
  }
4565
- Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
4824
+ Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
4566
4825
  }
4567
4826
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4568
4827
  return a && a.domain === DOMAIN;
@@ -4597,6 +4856,7 @@ var require_action_schema_view = __commonJS({
4597
4856
  if (typePick && !rows.some(function(row) {
4598
4857
  return row.types.indexOf(typePick) >= 0;
4599
4858
  })) return false;
4859
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
4600
4860
  return true;
4601
4861
  });
4602
4862
  function paramRow(row) {
@@ -4612,33 +4872,45 @@ var require_action_schema_view = __commonJS({
4612
4872
  h("td", null, Highlight.hit(row.description, kw))
4613
4873
  );
4614
4874
  }
4615
- function agentSwitch(action) {
4616
- if (action.agentLocked === true) {
4617
- return h("span", {
4618
- className: P + "-badge " + P + "-locked",
4619
- title: t.agentLockedHint,
4620
- "data-agent-locked": action.name
4621
- }, t.agentLocked);
4875
+ function originsChips(action) {
4876
+ if (!Array.isArray(action.origins)) return null;
4877
+ if (action.originsSource === "invalid") {
4878
+ return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
4622
4879
  }
4623
- if (typeof action.agentEnabled !== "boolean") return null;
4624
4880
  var busy = saving === action.name;
4881
+ var pinned = action.name === "actions.setActionOrigins";
4882
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
4625
4883
  return h(
4626
- "button",
4627
- {
4628
- className: P + "-toggle",
4629
- "data-agent-row": action.name,
4630
- type: "button",
4631
- role: "switch",
4632
- "aria-checked": action.agentEnabled,
4633
- disabled: busy,
4634
- "data-agent-toggle": action.name,
4635
- "aria-label": t.agentSwitch + " \xB7 " + action.name,
4636
- onClick: function() {
4637
- setAgent(action, !action.agentEnabled);
4638
- }
4639
- },
4640
- h("span", { className: P + "-track", "aria-hidden": true }),
4641
- h("span", null, busy ? t.agentSaving : t.agentSwitch)
4884
+ "div",
4885
+ { className: P + "-origins", "data-origins-row": action.name },
4886
+ h("span", { className: P + "-origins-label" }, t.originsLabel),
4887
+ ORIGINS.map(function(origin) {
4888
+ var on = action.origins.indexOf(origin) >= 0;
4889
+ var allowed = supported.indexOf(origin) >= 0;
4890
+ var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
4891
+ var byDefault = preset.indexOf(origin) >= 0;
4892
+ return h(
4893
+ "label",
4894
+ {
4895
+ key: origin,
4896
+ className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
4897
+ title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
4898
+ },
4899
+ h("input", {
4900
+ type: "checkbox",
4901
+ checked: on,
4902
+ disabled: busy || pinned || !allowed,
4903
+ "data-origin": origin,
4904
+ "data-origin-row": action.name,
4905
+ "data-origin-supported": allowed ? "1" : "0",
4906
+ onChange: function() {
4907
+ setOrigins(action, origin);
4908
+ }
4909
+ }),
4910
+ h("span", null, originText[origin])
4911
+ );
4912
+ }),
4913
+ busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
4642
4914
  );
4643
4915
  }
4644
4916
  function card(action) {
@@ -4659,7 +4931,7 @@ var require_action_schema_view = __commonJS({
4659
4931
  return row.required;
4660
4932
  }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
4661
4933
  ),
4662
- agentSwitch(action)
4934
+ originsChips(action)
4663
4935
  ),
4664
4936
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
4665
4937
  rows.length ? h(
@@ -4782,6 +5054,21 @@ var require_action_schema_view = __commonJS({
4782
5054
  return h("option", { value: name, key: name }, name);
4783
5055
  })
4784
5056
  )
5057
+ ),
5058
+ h(
5059
+ "label",
5060
+ { className: P + "-none" },
5061
+ t.filterOrigin + " ",
5062
+ h(
5063
+ "select",
5064
+ { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
5065
+ setOriginPick(e.target.value);
5066
+ } },
5067
+ h("option", { value: "" }, t.allOrigins),
5068
+ ORIGINS.map(function(origin) {
5069
+ return h("option", { value: origin, key: origin }, originText[origin]);
5070
+ })
5071
+ )
4785
5072
  )
4786
5073
  ) : null,
4787
5074
  body,
@@ -4852,7 +5139,7 @@ function definition(host) {
4852
5139
  var tab = makeTab(host.react);
4853
5140
  return {
4854
5141
  id: ADDON_ID,
4855
- version: "0.2.4",
5142
+ version: "0.2.7",
4856
5143
  icon: tab("megaphone"),
4857
5144
  views: [
4858
5145
  {
package/lib/index.js CHANGED
@@ -110,7 +110,7 @@ export function apply(ctx) {
110
110
  title: "弹幕",
111
111
  description:
112
112
  "把自建弹幕轮播在整个 DSH 界面,并可叠加到整个桌面;单一宿主调度、SSE 与 Electron helper 双投递,含弹幕库/配置/数据/Action 四个视图",
113
- version: "0.2.4",
113
+ version: "0.2.6",
114
114
  category: "comm",
115
115
  tables: TABLES,
116
116
  sync: { tables: [] },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-danmaku",
3
- "version": "0.2.4",
3
+ "version": "0.2.7",
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.4",
20
+ "version": "0.2.7",
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.8.2"
56
+ "dsh-workbench-host": "^0.10.0"
57
57
  },
58
58
  "dsh": {
59
59
  "bundle": {