dsh-workbench-danmaku 0.2.2 → 0.2.6

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.
Files changed (3) hide show
  1. package/lib/client.js +476 -181
  2. package/lib/index.js +2 -1
  3. package/package.json +3 -3
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
  }
@@ -1275,6 +1520,7 @@ var require_mount = __commonJS({
1275
1520
  var overlayStyle = require_style();
1276
1521
  var layerModule = require_layer();
1277
1522
  var DOMAIN = "wb-addon-danmaku";
1523
+ var ACTION_PREFIX = "danmaku.";
1278
1524
  var STYLE_ID2 = "wbdm-dm-styles";
1279
1525
  var THEME_DEBOUNCE = 700;
1280
1526
  var DEFAULTS = {
@@ -1306,7 +1552,7 @@ var require_mount = __commonJS({
1306
1552
  (document.head || document.documentElement).appendChild(style);
1307
1553
  }
1308
1554
  function call(action, args) {
1309
- return fetch("/workbench/api/domains/" + DOMAIN + "/actions/" + action, {
1555
+ return fetch("/workbench/api/domains/" + DOMAIN + "/actions/" + encodeURIComponent(ACTION_PREFIX + action), {
1310
1556
  method: "POST",
1311
1557
  headers: { "content-type": "application/json" },
1312
1558
  body: JSON.stringify(args || {})
@@ -1359,6 +1605,7 @@ var require_mount = __commonJS({
1359
1605
  var surface = null;
1360
1606
  var sse = null;
1361
1607
  var retries = 0;
1608
+ var configLoaded = false;
1362
1609
  var themeTimer = null;
1363
1610
  var lastThemeKey = "";
1364
1611
  var typingTimer = null;
@@ -1391,6 +1638,7 @@ var require_mount = __commonJS({
1391
1638
  var result = res && res.result ? res.result : res;
1392
1639
  if (res && res.ok && result && result.values) {
1393
1640
  retries = 0;
1641
+ configLoaded = true;
1394
1642
  apply(result.values);
1395
1643
  return;
1396
1644
  }
@@ -1419,7 +1667,7 @@ var require_mount = __commonJS({
1419
1667
  return target.closest('input, textarea, [contenteditable=""], [contenteditable="true"], [contenteditable="plaintext-only"]');
1420
1668
  }
1421
1669
  function onTyping(event) {
1422
- if (!config.pauseOnInput) return;
1670
+ if (!configLoaded || !config.pauseOnInput) return;
1423
1671
  if (!editableFrom(event.target)) return;
1424
1672
  window.clearTimeout(typingTimer);
1425
1673
  layer.pause(true);
@@ -1429,7 +1677,7 @@ var require_mount = __commonJS({
1429
1677
  }, TYPING_IDLE_MS);
1430
1678
  }
1431
1679
  function onFocusOut(event) {
1432
- if (!config.pauseOnInput) return;
1680
+ if (!configLoaded || !config.pauseOnInput) return;
1433
1681
  if (!editableFrom(event.target)) return;
1434
1682
  window.clearTimeout(typingTimer);
1435
1683
  typingTimer = null;
@@ -1461,6 +1709,12 @@ var require_mount = __commonJS({
1461
1709
  refresh();
1462
1710
  }
1463
1711
  });
1712
+ sse.onopen = function() {
1713
+ if (!configLoaded) {
1714
+ retries = 0;
1715
+ refresh();
1716
+ }
1717
+ };
1464
1718
  sse.onerror = function() {
1465
1719
  };
1466
1720
  }
@@ -1822,6 +2076,8 @@ var require_detail = __commonJS({
1822
2076
  var h = React.createElement;
1823
2077
  var chipStyle = require_chip_style();
1824
2078
  var createOverlay = require_overlay();
2079
+ var SW = require_switch();
2080
+ var NF = require_number_field();
1825
2081
  var REDUCED = false;
1826
2082
  try {
1827
2083
  REDUCED = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
@@ -1945,6 +2201,7 @@ var require_detail = __commonJS({
1945
2201
  );
1946
2202
  }
1947
2203
  function numField(key, label, hint, step, min, max) {
2204
+ var showHint = min + "\u2013" + max + (step === 1 ? "\uFF0C\u6574\u6570" : "\uFF0C\u6B65\u957F " + step);
1948
2205
  return h(
1949
2206
  "label",
1950
2207
  { className: "wbdm-crow" },
@@ -1954,16 +2211,18 @@ var require_detail = __commonJS({
1954
2211
  h("span", { className: "wbdm-crow-t" }, label),
1955
2212
  h("span", { className: "wbdm-crow-h" }, hint)
1956
2213
  ),
1957
- h("input", {
1958
- className: "wbdm-input",
1959
- type: "number",
2214
+ h(NF.NumberField, {
2215
+ h,
1960
2216
  value: numberOrText(detail[key]),
1961
2217
  min,
1962
2218
  max,
1963
- step,
2219
+ integer: Math.round(step) === step,
2220
+ allowEmpty: true,
2221
+ ariaLabel: label,
1964
2222
  placeholder: C.followGlobal,
1965
- onChange: function(e) {
1966
- set(key, e.target.value);
2223
+ hint: showHint,
2224
+ onCommit: function(next) {
2225
+ set(key, next === null ? "" : String(next));
1967
2226
  }
1968
2227
  })
1969
2228
  );
@@ -1995,22 +2254,18 @@ var require_detail = __commonJS({
1995
2254
  }
1996
2255
  function switchField(key, label) {
1997
2256
  return h(
1998
- "label",
2257
+ "div",
1999
2258
  { className: "wbdm-crow" },
2000
2259
  h("span", { className: "wbdm-crow-label" }, h("span", { className: "wbdm-crow-t" }, label)),
2001
- h(
2002
- "span",
2003
- { className: "wbdm-switch" },
2004
- h("input", {
2005
- type: "checkbox",
2006
- checked: Boolean(detail[key]),
2007
- onChange: function() {
2008
- set(key, !detail[key]);
2009
- }
2010
- }),
2011
- h("span", { className: "wbdm-track" }),
2012
- h("span", { className: "wbdm-knob" })
2013
- )
2260
+ // 共享开关自带 role="switch"/aria-checked;左侧已有文案,这里不再重复显示状态。
2261
+ h(SW.Switch, {
2262
+ h,
2263
+ checked: Boolean(detail[key]),
2264
+ ariaLabel: label,
2265
+ onChange: function(next) {
2266
+ set(key, next);
2267
+ }
2268
+ })
2014
2269
  );
2015
2270
  }
2016
2271
  var weights = [{ value: "", label: C.followGlobal }];
@@ -2080,7 +2335,7 @@ var require_detail = __commonJS({
2080
2335
  h("div", { className: "wbdm-tones" }, TONES.map(toneChip))
2081
2336
  ),
2082
2337
  h(
2083
- "label",
2338
+ "div",
2084
2339
  { className: "wbdm-crow" },
2085
2340
  h(
2086
2341
  "span",
@@ -2088,24 +2343,19 @@ var require_detail = __commonJS({
2088
2343
  h("span", { className: "wbdm-crow-t" }, C.card),
2089
2344
  h("span", { className: "wbdm-crow-h" }, C.cardHint)
2090
2345
  ),
2091
- h(
2092
- "span",
2093
- { className: "wbdm-switch" },
2094
- h("input", {
2095
- type: "checkbox",
2096
- checked: Boolean(detail.card),
2097
- onChange: function() {
2098
- set("card", !detail.card);
2099
- }
2100
- }),
2101
- h("span", { className: "wbdm-track" }),
2102
- h("span", { className: "wbdm-knob" })
2103
- )
2346
+ h(SW.Switch, {
2347
+ h,
2348
+ checked: Boolean(detail.card),
2349
+ ariaLabel: C.card,
2350
+ onChange: function(next) {
2351
+ set("card", next);
2352
+ }
2353
+ })
2104
2354
  ),
2105
2355
  numField("fontSize", C.fontSize, C.unitPx + " \xB7 " + C.followGlobal, 1, 10, 48),
2106
2356
  selectField("fontWeight", C.weight, weights),
2107
2357
  selectField("fontFamily", C.family, families),
2108
- numField("opacity", C.opacity, "0.15\u20131 \xB7 " + C.followGlobal, 0.02, 0.15, 1)
2358
+ numField("opacity", C.opacity, C.followGlobal, 0.02, 0.15, 1)
2109
2359
  ),
2110
2360
  h(
2111
2361
  "section",
@@ -2193,6 +2443,7 @@ var require_library = __commonJS({
2193
2443
  var React = require("react");
2194
2444
  var h = React.createElement;
2195
2445
  var copy = require_copy();
2446
+ var SW = require_switch();
2196
2447
  var ICONS = {
2197
2448
  up: GLYPHS2["arrow-up"],
2198
2449
  down: GLYPHS2["arrow-down"],
@@ -2512,19 +2763,16 @@ var require_library = __commonJS({
2512
2763
  "div",
2513
2764
  { key: item.id, className: "wbdm-item" + (item.enabled ? "" : " off") },
2514
2765
  h("span", { className: "wbdm-order" }, String(index + 1)),
2515
- h(
2516
- "label",
2517
- { className: "wbdm-switch", title: item.enabled ? C.disable : C.enable },
2518
- h("input", {
2519
- type: "checkbox",
2520
- checked: Boolean(item.enabled),
2521
- onChange: function() {
2522
- toggle(item);
2523
- }
2524
- }),
2525
- h("span", { className: "wbdm-track" }),
2526
- h("span", { className: "wbdm-knob" })
2527
- ),
2766
+ h(SW.Switch, {
2767
+ h,
2768
+ checked: Boolean(item.enabled),
2769
+ title: item.enabled ? C.disable : C.enable,
2770
+ // 开关的可访问名称用「启用」这个设置名;title 只作为点击后的动作提示。
2771
+ ariaLabel: C.enable,
2772
+ onChange: function() {
2773
+ toggle(item);
2774
+ }
2775
+ }),
2528
2776
  h(
2529
2777
  "span",
2530
2778
  { className: "wbdm-tag" },
@@ -2676,6 +2924,8 @@ var require_config = __commonJS({
2676
2924
  var React = require("react");
2677
2925
  var h = React.createElement;
2678
2926
  var copy = require_copy();
2927
+ var SW = require_switch();
2928
+ var NF = require_number_field();
2679
2929
  var DOMAIN = "danmaku";
2680
2930
  var ICONS = {
2681
2931
  check: GLYPHS2["check"],
@@ -2938,20 +3188,15 @@ var require_config = __commonJS({
2938
3188
  });
2939
3189
  }
2940
3190
  function switchControl(item, value) {
2941
- return h(
2942
- "label",
2943
- { className: "wbdm-switch", title: labelOf(item, lang) },
2944
- h("input", {
2945
- type: "checkbox",
2946
- checked: value === true,
2947
- "aria-label": labelOf(item, lang),
2948
- onChange: function(e) {
2949
- save(item.id, e.target.checked);
2950
- }
2951
- }),
2952
- h("span", { className: "wbdm-track" }),
2953
- h("span", { className: "wbdm-knob" })
2954
- );
3191
+ return h(SW.Switch, {
3192
+ h,
3193
+ checked: value === true,
3194
+ title: labelOf(item, lang),
3195
+ ariaLabel: labelOf(item, lang),
3196
+ onChange: function(next) {
3197
+ save(item.id, next);
3198
+ }
3199
+ });
2955
3200
  }
2956
3201
  function control(item) {
2957
3202
  var value = values()[item.id];
@@ -2980,17 +3225,15 @@ var require_config = __commonJS({
2980
3225
  );
2981
3226
  }
2982
3227
  if (item.type === "int" || item.type === "number") {
2983
- return h("input", {
2984
- className: "wbdm-input",
2985
- type: "number",
2986
- step: item.type === "number" ? 0.05 : 1,
3228
+ return h(NF.NumberField, {
3229
+ h,
3230
+ lang,
3231
+ value: value === void 0 ? "" : value,
2987
3232
  min: item.min,
2988
3233
  max: item.max,
2989
- value: value === void 0 ? "" : value,
2990
- "aria-label": labelOf(item, lang),
2991
- onChange: function(e) {
2992
- var next = Number(e.target.value);
2993
- if (!isFinite(next)) return;
3234
+ integer: item.type === "int",
3235
+ ariaLabel: labelOf(item, lang),
3236
+ onCommit: function(next) {
2994
3237
  save(item.id, next);
2995
3238
  }
2996
3239
  });
@@ -3251,13 +3494,6 @@ var require_data_style = __commonJS({
3251
3494
  "." + 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)}",
3252
3495
  "." + 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}",
3253
3496
  "." + 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)}",
3254
- "." + 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}",
3255
- "." + P + "-switch input{position:absolute;inset:0;width:100%;height:100%;margin:0;opacity:0;cursor:pointer}",
3256
- "." + 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}",
3257
- "." + 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}",
3258
- "." + P + "-switch input:checked+." + P + "-track{background:var(--dsw-alias-brand-primary,currentColor)}",
3259
- "." + P + "-switch input:checked+." + P + "-track::after{transform:translateX(14px);background:var(--dsw-alias-label-primary-inverted,var(--dsw-alias-bg-base))}",
3260
- "." + P + "-switch input:focus-visible+." + P + "-track{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
3261
3497
  "." + 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}",
3262
3498
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3263
3499
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -3286,8 +3522,8 @@ var require_data_style = __commonJS({
3286
3522
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3287
3523
  "." + P + "-grow{flex:1}",
3288
3524
  "." + P + "-pageinfo{font-variant-numeric:tabular-nums}",
3289
- "." + 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}",
3290
- "." + P + "-jump:focus{border-color:var(--dsw-alias-brand-primary,currentColor)}",
3525
+ "." + P + "-jump .wbctl-num-input{width:56px;padding:4px 7px;font-size:11.5px;text-align:right}",
3526
+ "." + P + "-jump .wbctl-num-hint{display:none}",
3291
3527
  "." + 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)}",
3292
3528
  "." + 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}",
3293
3529
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -3325,7 +3561,7 @@ var require_data_style = __commonJS({
3325
3561
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3326
3562
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3327
3563
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3328
- ].join("\n");
3564
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3329
3565
  if (DOMAIN === "storage") {
3330
3566
  var buttons = "." + P + " :is(button)";
3331
3567
  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}";
@@ -3353,8 +3589,10 @@ var require_data_view = __commonJS({
3353
3589
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
3354
3590
  "use strict";
3355
3591
  var React = require("react");
3592
+ var NF = require_number_field();
3356
3593
  var h = React.createElement;
3357
3594
  var COPY = require_data_copy();
3595
+ var SW = require_switch();
3358
3596
  module2.exports = function createDataView(options) {
3359
3597
  var DOMAIN = options.domain;
3360
3598
  function icon(name) {
@@ -3908,17 +4146,18 @@ var require_data_view = __commonJS({
3908
4146
  h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
3909
4147
  setPage(Math.min(pages, page + 1));
3910
4148
  } }, t.next + " \u203A"),
3911
- h("input", {
4149
+ h(NF.NumberField, {
4150
+ h,
4151
+ lang,
3912
4152
  className: P + "-jump",
3913
- type: "number",
4153
+ value: page,
3914
4154
  min: 1,
3915
4155
  max: pages,
3916
- "aria-label": t.jump,
3917
- onKeyDown: function(e) {
3918
- if (e.key === "Enter") {
3919
- var n = Math.floor(Number(e.target.value));
3920
- if (n >= 1) setPage(Math.min(pages, n));
3921
- }
4156
+ integer: true,
4157
+ ariaLabel: t.jump,
4158
+ hint: false,
4159
+ onCommit: function(next) {
4160
+ if (next !== null) setPage(next);
3922
4161
  }
3923
4162
  }),
3924
4163
  data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -4015,25 +4254,23 @@ var require_data_view = __commonJS({
4015
4254
  }
4016
4255
  })
4017
4256
  ),
4018
- h(
4019
- "label",
4020
- { className: P + "-switch" },
4021
- h("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
4022
- setIncludeDeleted(e.target.checked);
4257
+ h(SW.Switch, {
4258
+ h,
4259
+ checked: includeDeleted,
4260
+ label: t.includeDeleted,
4261
+ onChange: function(next) {
4262
+ setIncludeDeleted(next);
4023
4263
  setPage(1);
4024
- } }),
4025
- h("span", { className: P + "-track" }),
4026
- h("span", null, t.includeDeleted)
4027
- ),
4028
- h(
4029
- "label",
4030
- { className: P + "-switch" },
4031
- h("input", { type: "checkbox", checked: showSystem, onChange: function(e) {
4032
- setShowSystem(e.target.checked);
4033
- } }),
4034
- h("span", { className: P + "-track" }),
4035
- h("span", null, t.showSystem)
4036
- ),
4264
+ }
4265
+ }),
4266
+ h(SW.Switch, {
4267
+ h,
4268
+ checked: showSystem,
4269
+ label: t.showSystem,
4270
+ onChange: function(next) {
4271
+ setShowSystem(next);
4272
+ }
4273
+ }),
4037
4274
  h("span", { className: P + "-grow" }),
4038
4275
  h(
4039
4276
  "label",
@@ -4186,16 +4423,13 @@ var require_action_schema_style = __commonJS({
4186
4423
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4187
4424
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4188
4425
  "." + P + "-hintline{margin:0;color:var(--dsw-alias-label-tertiary,inherit);font-size:11.5px;line-height:1.5}",
4189
- "." + 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}",
4190
- "." + 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)}",
4191
- "." + P + "-track::before{content:'';width:12px;height:12px;border-radius:50%;background:currentColor;transition:transform .15s ease}",
4192
- "." + P + "-toggle[aria-checked=true] ." + P + "-track{background:var(--wb-accent);border-color:var(--wb-accent);color:var(--wb-card)}",
4193
- "." + P + "-toggle[aria-checked=true] ." + P + "-track::before{transform:translateX(12px)}",
4194
- "." + P + "-toggle:hover:not(:disabled) ." + P + "-track{outline:1px solid var(--wb-accent)}",
4195
- "." + P + "-toggle:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4196
- "." + P + "-toggle:disabled{opacity:.6;cursor:progress}",
4197
- "@media(prefers-reduced-motion:reduce){." + P + "-track::before{transition:none}}",
4198
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
4426
+ "." + P + "-origins{display:inline-flex;align-items:center;gap:10px;flex-wrap:wrap;justify-content:flex-end}",
4427
+ "." + P + "-origins-label{font-size:11px;color:var(--wb-muted);white-space:nowrap}",
4428
+ "." + P + "-origin{display:inline-flex;align-items:center;gap:4px;font-size:11.5px;color:var(--wb-muted);cursor:pointer;user-select:none}",
4429
+ // 该 action 本身不支持的来源:整项置灰、不可点,示意「不是没开,是开不了」。
4430
+ "." + P + "-origin-off{opacity:.55;cursor:not-allowed}",
4431
+ "." + P + "-origin input[type=checkbox]{width:13px;height:13px;margin:0;accent-color:var(--wb-accent);cursor:inherit}",
4432
+ "." + P + "-origin input[type=checkbox]:focus-visible{outline:2px solid var(--wb-accent);outline-offset:2px}",
4199
4433
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4200
4434
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4201
4435
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -4248,15 +4482,20 @@ var require_action_schema_view = __commonJS({
4248
4482
  zh: {
4249
4483
  title: "Action",
4250
4484
  hint: "\u8FD0\u884C\u65F6\u6CE8\u518C \xB7 \u53EA\u8BFB",
4251
- switchHint: "agent \u5F00\u5173\u843D\u672C\u673A\u3001\u5373\u6539\u5373\u751F\u6548\uFF1B\u754C\u9762\u64CD\u4F5C\u4E0D\u53D7\u5F71\u54CD\u3002",
4252
- 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",
4253
- agentSwitch: "agent \u53EF\u7528",
4254
- agentLocked: "\u4EC5\u754C\u9762 \xB7 \u5B89\u5168\u7EA6\u675F",
4255
- agentLockedHint: "\u8BE5 action \u53EA\u80FD\u5728\u754C\u9762\u6267\u884C\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0Cagent \u5F00\u5173\u4E0D\u53EF\u653E\u5F00",
4256
- agentSaving: "\u4FDD\u5B58\u4E2D\u2026",
4257
- agentOnToast: "\u5DF2\u5141\u8BB8 agent \u8C03\u7528",
4258
- agentOffToast: "\u5DF2\u7981\u6B62 agent \u8C03\u7528",
4259
- agentFail: "\u5207\u6362 agent \u5F00\u5173\u5931\u8D25",
4485
+ 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",
4486
+ hostHint: "\u5BBF\u4E3B action \u7684\u5141\u8BB8\u6765\u6E90\uFF1B\u6807\u300C\u6765\u6E90\u56FA\u5B9A\u300D\u7684\u4E0D\u53EF\u4FEE\u6539\u3002",
4487
+ originsLabel: "\u5141\u8BB8\u6765\u6E90",
4488
+ originUi: "\u754C\u9762",
4489
+ originPlugin: "\u63D2\u4EF6",
4490
+ originAgent: "agent",
4491
+ originSync: "\u540C\u6B65",
4492
+ originsSaving: "\u4FDD\u5B58\u4E2D\u2026",
4493
+ originsToast: "\u5DF2\u66F4\u65B0\u5141\u8BB8\u6765\u6E90",
4494
+ originsFail: "\u66F4\u65B0\u5141\u8BB8\u6765\u6E90\u5931\u8D25",
4495
+ originsEmpty: "\u81F3\u5C11\u8981\u4FDD\u7559\u4E00\u4E2A\u6765\u6E90",
4496
+ originsUnsupported: "\u8BE5 action \u672C\u8EAB\u4E0D\u652F\u6301\u8FD9\u4E2A\u6765\u6E90",
4497
+ originsPinned: "\u6765\u6E90\u56FA\u5B9A",
4498
+ originsPinnedHint: "\u8BE5 action \u7684\u5141\u8BB8\u6765\u6E90\u88AB\u56FA\u5B9A\uFF08\u5B89\u5168\u7EA6\u675F\uFF09\uFF0C\u4E0D\u80FD\u4FEE\u6539",
4260
4499
  domain: "\u57DF",
4261
4500
  versionLabel: "\u7248\u672C",
4262
4501
  shell: "\u5BBF\u4E3B",
@@ -4270,6 +4509,8 @@ var require_action_schema_view = __commonJS({
4270
4509
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
4271
4510
  filterType: "\u53C2\u6570\u7C7B\u578B",
4272
4511
  allTypes: "\u5168\u90E8\u7C7B\u578B",
4512
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
4513
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
4273
4514
  colName: "\u53C2\u6570",
4274
4515
  colType: "\u7C7B\u578B",
4275
4516
  colReq: "\u5FC5\u586B",
@@ -4302,15 +4543,22 @@ var require_action_schema_view = __commonJS({
4302
4543
  en: {
4303
4544
  title: "Actions",
4304
4545
  hint: "runtime registry \xB7 read-only",
4305
- switchHint: "The agent switch is stored locally and applies immediately; UI actions are unaffected.",
4306
- hostHint: "Agent switch for host actions; items marked UI-only (security) cannot be opened up.",
4307
- agentSwitch: "Agent callable",
4308
- agentLocked: "UI only \xB7 security",
4309
- agentLockedHint: "This action can only run from the UI (security constraint); the agent switch cannot be opened",
4310
- agentSaving: "Saving\u2026",
4311
- agentOnToast: "Agent calls allowed",
4312
- agentOffToast: "Agent calls blocked",
4313
- agentFail: "Failed to change the agent switch",
4546
+ switchHint: "Allowed origins are stored locally and apply immediately: only checked origins may call the action; others get ACTION_ORIGIN_DENIED.",
4547
+ hostHint: "Allowed origins for host actions; items marked pinned cannot be changed.",
4548
+ originsLabel: "Origins",
4549
+ originUi: "UI",
4550
+ originPlugin: "Plugin",
4551
+ originAgent: "Agent",
4552
+ originSync: "Sync",
4553
+ originsSaving: "Saving\u2026",
4554
+ originsToast: "Allowed origins updated",
4555
+ originsFail: "Failed to update allowed origins",
4556
+ originsEmpty: "Keep at least one origin",
4557
+ originsUnsupported: "This action does not support this origin",
4558
+ originsPinned: "Pinned",
4559
+ originsPinnedHint: "Allowed origins are pinned for this action (security constraint) and cannot be changed",
4560
+ originsDefaultOn: "Allowed by default",
4561
+ originsDefaultOff: "Off by default, can be enabled",
4314
4562
  domain: "Domain",
4315
4563
  versionLabel: "Version",
4316
4564
  shell: "Host",
@@ -4324,6 +4572,8 @@ var require_action_schema_view = __commonJS({
4324
4572
  onlyOptional: "No required",
4325
4573
  filterType: "Param type",
4326
4574
  allTypes: "All types",
4575
+ filterOrigin: "Origins",
4576
+ allOrigins: "All origins",
4327
4577
  colName: "Param",
4328
4578
  colType: "Type",
4329
4579
  colReq: "Required",
@@ -4467,6 +4717,8 @@ var require_action_schema_view = __commonJS({
4467
4717
  var reqMode = reqState[0], setReqMode = reqState[1];
4468
4718
  var typeState = React.useState("");
4469
4719
  var typePick = typeState[0], setTypePick = typeState[1];
4720
+ var originFilterState = React.useState("");
4721
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
4470
4722
  var toastState = React.useState("");
4471
4723
  var toast = toastState[0], setToast = toastState[1];
4472
4724
  var savingState = React.useState("");
@@ -4522,38 +4774,53 @@ var require_action_schema_view = __commonJS({
4522
4774
  plainCopy(text);
4523
4775
  done();
4524
4776
  }
4525
- function setAgent(action, next) {
4777
+ var ORIGINS = ["ui", "plugin", "agent", "sync"];
4778
+ var originText = { ui: t.originUi, plugin: t.originPlugin, agent: t.originAgent, sync: t.originSync };
4779
+ function setOrigins(action, origin) {
4526
4780
  var name = action.name;
4781
+ var current = Array.isArray(action.origins) ? action.origins.slice() : [];
4782
+ var index = current.indexOf(origin);
4783
+ var next = index >= 0 ? current.filter(function(o) {
4784
+ return o !== origin;
4785
+ }) : current.concat([origin]);
4786
+ if (next.length === 0) {
4787
+ setToast(t.originsEmpty);
4788
+ return;
4789
+ }
4790
+ next = ORIGINS.filter(function(o) {
4791
+ return next.indexOf(o) >= 0;
4792
+ });
4527
4793
  setSaving(name);
4528
4794
  setToast("");
4529
4795
  var fail = function(e) {
4530
4796
  setSaving("");
4531
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
4797
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
4532
4798
  };
4533
4799
  var done = function(r) {
4534
4800
  setSaving("");
4535
4801
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
4536
4802
  if (r && r.ok === false) {
4537
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
4803
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
4538
4804
  return;
4539
4805
  }
4540
- var value = payload && typeof payload.agentEnabled === "boolean" ? payload.agentEnabled : next;
4806
+ var value = payload && Array.isArray(payload.origins) ? payload.origins : next;
4807
+ var source = payload && typeof payload.source === "string" ? payload.source : action.originsSource;
4541
4808
  setSnap(function(prev) {
4542
4809
  if (!prev || !Array.isArray(prev.actions)) return prev;
4543
4810
  return Object.assign({}, prev, {
4544
4811
  actions: prev.actions.map(function(a) {
4545
4812
  if (!a || a.name !== name) return a;
4546
- return Object.assign({}, a, { agentEnabled: value });
4813
+ return Object.assign({}, a, { origins: value, originsSource: source });
4547
4814
  })
4548
4815
  });
4549
4816
  });
4550
- setToast(value ? t.agentOnToast : t.agentOffToast);
4817
+ setToast(t.originsToast);
4551
4818
  };
4552
4819
  if (!api || typeof api.call !== "function") {
4553
4820
  fail(new Error("no call api"));
4554
4821
  return;
4555
4822
  }
4556
- Promise.resolve(api.call("actions.setAgentAccess", { action: name, agentEnabled: next })).then(done, fail);
4823
+ Promise.resolve(api.call("actions.setActionOrigins", { action: name, origins: next })).then(done, fail);
4557
4824
  }
4558
4825
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4559
4826
  return a && a.domain === DOMAIN;
@@ -4588,6 +4855,7 @@ var require_action_schema_view = __commonJS({
4588
4855
  if (typePick && !rows.some(function(row) {
4589
4856
  return row.types.indexOf(typePick) >= 0;
4590
4857
  })) return false;
4858
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
4591
4859
  return true;
4592
4860
  });
4593
4861
  function paramRow(row) {
@@ -4603,33 +4871,45 @@ var require_action_schema_view = __commonJS({
4603
4871
  h("td", null, Highlight.hit(row.description, kw))
4604
4872
  );
4605
4873
  }
4606
- function agentSwitch(action) {
4607
- if (action.agentLocked === true) {
4608
- return h("span", {
4609
- className: P + "-badge " + P + "-locked",
4610
- title: t.agentLockedHint,
4611
- "data-agent-locked": action.name
4612
- }, t.agentLocked);
4874
+ function originsChips(action) {
4875
+ if (!Array.isArray(action.origins)) return null;
4876
+ if (action.originsSource === "invalid") {
4877
+ return h("span", { className: P + "-badge " + P + "-locked", title: t.originsPinnedHint, "data-origins-invalid": action.name }, t.originsPinned);
4613
4878
  }
4614
- if (typeof action.agentEnabled !== "boolean") return null;
4615
4879
  var busy = saving === action.name;
4880
+ var pinned = action.name === "actions.setActionOrigins";
4881
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
4616
4882
  return h(
4617
- "button",
4618
- {
4619
- className: P + "-toggle",
4620
- "data-agent-row": action.name,
4621
- type: "button",
4622
- role: "switch",
4623
- "aria-checked": action.agentEnabled,
4624
- disabled: busy,
4625
- "data-agent-toggle": action.name,
4626
- "aria-label": t.agentSwitch + " \xB7 " + action.name,
4627
- onClick: function() {
4628
- setAgent(action, !action.agentEnabled);
4629
- }
4630
- },
4631
- h("span", { className: P + "-track", "aria-hidden": true }),
4632
- h("span", null, busy ? t.agentSaving : t.agentSwitch)
4883
+ "div",
4884
+ { className: P + "-origins", "data-origins-row": action.name },
4885
+ h("span", { className: P + "-origins-label" }, t.originsLabel),
4886
+ ORIGINS.map(function(origin) {
4887
+ var on = action.origins.indexOf(origin) >= 0;
4888
+ var allowed = supported.indexOf(origin) >= 0;
4889
+ var preset = Array.isArray(action.originsDefault) ? action.originsDefault : supported;
4890
+ var byDefault = preset.indexOf(origin) >= 0;
4891
+ return h(
4892
+ "label",
4893
+ {
4894
+ key: origin,
4895
+ className: P + "-origin" + (allowed ? "" : " " + P + "-origin-off"),
4896
+ title: pinned ? t.originsPinnedHint : !allowed ? t.originsUnsupported : originText[origin] + " \xB7 " + action.name + " \xB7 " + (byDefault ? t.originsDefaultOn : t.originsDefaultOff)
4897
+ },
4898
+ h("input", {
4899
+ type: "checkbox",
4900
+ checked: on,
4901
+ disabled: busy || pinned || !allowed,
4902
+ "data-origin": origin,
4903
+ "data-origin-row": action.name,
4904
+ "data-origin-supported": allowed ? "1" : "0",
4905
+ onChange: function() {
4906
+ setOrigins(action, origin);
4907
+ }
4908
+ }),
4909
+ h("span", null, originText[origin])
4910
+ );
4911
+ }),
4912
+ busy ? h("span", { className: P + "-origins-label" }, t.originsSaving) : null
4633
4913
  );
4634
4914
  }
4635
4915
  function card(action) {
@@ -4650,7 +4930,7 @@ var require_action_schema_view = __commonJS({
4650
4930
  return row.required;
4651
4931
  }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
4652
4932
  ),
4653
- agentSwitch(action)
4933
+ originsChips(action)
4654
4934
  ),
4655
4935
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
4656
4936
  rows.length ? h(
@@ -4773,6 +5053,21 @@ var require_action_schema_view = __commonJS({
4773
5053
  return h("option", { value: name, key: name }, name);
4774
5054
  })
4775
5055
  )
5056
+ ),
5057
+ h(
5058
+ "label",
5059
+ { className: P + "-none" },
5060
+ t.filterOrigin + " ",
5061
+ h(
5062
+ "select",
5063
+ { value: originPick, "aria-label": t.filterOrigin, "data-origin-filter": "", onChange: function(e) {
5064
+ setOriginPick(e.target.value);
5065
+ } },
5066
+ h("option", { value: "" }, t.allOrigins),
5067
+ ORIGINS.map(function(origin) {
5068
+ return h("option", { value: origin, key: origin }, originText[origin]);
5069
+ })
5070
+ )
4776
5071
  )
4777
5072
  ) : null,
4778
5073
  body,
@@ -4843,7 +5138,7 @@ function definition(host) {
4843
5138
  var tab = makeTab(host.react);
4844
5139
  return {
4845
5140
  id: ADDON_ID,
4846
- version: "0.2.2",
5141
+ version: "0.2.6",
4847
5142
  icon: tab("megaphone"),
4848
5143
  views: [
4849
5144
  {
package/lib/index.js CHANGED
@@ -110,7 +110,8 @@ export function apply(ctx) {
110
110
  title: "弹幕",
111
111
  description:
112
112
  "把自建弹幕轮播在整个 DSH 界面,并可叠加到整个桌面;单一宿主调度、SSE 与 Electron helper 双投递,含弹幕库/配置/数据/Action 四个视图",
113
- version: "0.2.2",
113
+ version: "0.2.6",
114
+ category: "comm",
114
115
  tables: TABLES,
115
116
  sync: { tables: [] },
116
117
  views: [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-danmaku",
3
- "version": "0.2.2",
3
+ "version": "0.2.6",
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.2",
20
+ "version": "0.2.6",
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.1"
56
+ "dsh-workbench-host": "^0.9.1"
57
57
  },
58
58
  "dsh": {
59
59
  "bundle": {