dsh-workbench-danmaku 0.2.4 → 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 +464 -178
  2. package/lib/index.js +1 -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
  }
@@ -1831,6 +2076,8 @@ var require_detail = __commonJS({
1831
2076
  var h = React.createElement;
1832
2077
  var chipStyle = require_chip_style();
1833
2078
  var createOverlay = require_overlay();
2079
+ var SW = require_switch();
2080
+ var NF = require_number_field();
1834
2081
  var REDUCED = false;
1835
2082
  try {
1836
2083
  REDUCED = window.matchMedia("(prefers-reduced-motion: reduce)").matches;
@@ -1954,6 +2201,7 @@ var require_detail = __commonJS({
1954
2201
  );
1955
2202
  }
1956
2203
  function numField(key, label, hint, step, min, max) {
2204
+ var showHint = min + "\u2013" + max + (step === 1 ? "\uFF0C\u6574\u6570" : "\uFF0C\u6B65\u957F " + step);
1957
2205
  return h(
1958
2206
  "label",
1959
2207
  { className: "wbdm-crow" },
@@ -1963,16 +2211,18 @@ var require_detail = __commonJS({
1963
2211
  h("span", { className: "wbdm-crow-t" }, label),
1964
2212
  h("span", { className: "wbdm-crow-h" }, hint)
1965
2213
  ),
1966
- h("input", {
1967
- className: "wbdm-input",
1968
- type: "number",
2214
+ h(NF.NumberField, {
2215
+ h,
1969
2216
  value: numberOrText(detail[key]),
1970
2217
  min,
1971
2218
  max,
1972
- step,
2219
+ integer: Math.round(step) === step,
2220
+ allowEmpty: true,
2221
+ ariaLabel: label,
1973
2222
  placeholder: C.followGlobal,
1974
- onChange: function(e) {
1975
- set(key, e.target.value);
2223
+ hint: showHint,
2224
+ onCommit: function(next) {
2225
+ set(key, next === null ? "" : String(next));
1976
2226
  }
1977
2227
  })
1978
2228
  );
@@ -2004,22 +2254,18 @@ var require_detail = __commonJS({
2004
2254
  }
2005
2255
  function switchField(key, label) {
2006
2256
  return h(
2007
- "label",
2257
+ "div",
2008
2258
  { className: "wbdm-crow" },
2009
2259
  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
- )
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
+ })
2023
2269
  );
2024
2270
  }
2025
2271
  var weights = [{ value: "", label: C.followGlobal }];
@@ -2089,7 +2335,7 @@ var require_detail = __commonJS({
2089
2335
  h("div", { className: "wbdm-tones" }, TONES.map(toneChip))
2090
2336
  ),
2091
2337
  h(
2092
- "label",
2338
+ "div",
2093
2339
  { className: "wbdm-crow" },
2094
2340
  h(
2095
2341
  "span",
@@ -2097,24 +2343,19 @@ var require_detail = __commonJS({
2097
2343
  h("span", { className: "wbdm-crow-t" }, C.card),
2098
2344
  h("span", { className: "wbdm-crow-h" }, C.cardHint)
2099
2345
  ),
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
- )
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
+ })
2113
2354
  ),
2114
2355
  numField("fontSize", C.fontSize, C.unitPx + " \xB7 " + C.followGlobal, 1, 10, 48),
2115
2356
  selectField("fontWeight", C.weight, weights),
2116
2357
  selectField("fontFamily", C.family, families),
2117
- 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)
2118
2359
  ),
2119
2360
  h(
2120
2361
  "section",
@@ -2202,6 +2443,7 @@ var require_library = __commonJS({
2202
2443
  var React = require("react");
2203
2444
  var h = React.createElement;
2204
2445
  var copy = require_copy();
2446
+ var SW = require_switch();
2205
2447
  var ICONS = {
2206
2448
  up: GLYPHS2["arrow-up"],
2207
2449
  down: GLYPHS2["arrow-down"],
@@ -2521,19 +2763,16 @@ var require_library = __commonJS({
2521
2763
  "div",
2522
2764
  { key: item.id, className: "wbdm-item" + (item.enabled ? "" : " off") },
2523
2765
  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
- ),
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
+ }),
2537
2776
  h(
2538
2777
  "span",
2539
2778
  { className: "wbdm-tag" },
@@ -2685,6 +2924,8 @@ var require_config = __commonJS({
2685
2924
  var React = require("react");
2686
2925
  var h = React.createElement;
2687
2926
  var copy = require_copy();
2927
+ var SW = require_switch();
2928
+ var NF = require_number_field();
2688
2929
  var DOMAIN = "danmaku";
2689
2930
  var ICONS = {
2690
2931
  check: GLYPHS2["check"],
@@ -2947,20 +3188,15 @@ var require_config = __commonJS({
2947
3188
  });
2948
3189
  }
2949
3190
  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
- );
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
+ });
2964
3200
  }
2965
3201
  function control(item) {
2966
3202
  var value = values()[item.id];
@@ -2989,17 +3225,15 @@ var require_config = __commonJS({
2989
3225
  );
2990
3226
  }
2991
3227
  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,
3228
+ return h(NF.NumberField, {
3229
+ h,
3230
+ lang,
3231
+ value: value === void 0 ? "" : value,
2996
3232
  min: item.min,
2997
3233
  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;
3234
+ integer: item.type === "int",
3235
+ ariaLabel: labelOf(item, lang),
3236
+ onCommit: function(next) {
3003
3237
  save(item.id, next);
3004
3238
  }
3005
3239
  });
@@ -3260,13 +3494,6 @@ var require_data_style = __commonJS({
3260
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)}",
3261
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}",
3262
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)}",
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
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}",
3271
3498
  "." + P + "-btn:hover{background:var(--cfg-hover);color:var(--dsw-alias-label-primary,inherit)}",
3272
3499
  "." + P + "-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,currentColor);outline-offset:2px}",
@@ -3295,8 +3522,8 @@ var require_data_style = __commonJS({
3295
3522
  "." + P + "-foot{display:flex;align-items:center;gap:8px;flex-wrap:wrap;padding-top:2px;font-size:11.5px;color:var(--cfg-muted)}",
3296
3523
  "." + P + "-grow{flex:1}",
3297
3524
  "." + 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)}",
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}",
3300
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)}",
3301
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}",
3302
3529
  "." + P + "-skwrap{display:flex;flex-direction:column;gap:1px;padding:2px}",
@@ -3334,7 +3561,7 @@ var require_data_style = __commonJS({
3334
3561
  "." + P + "-images img{width:36px;height:36px;object-fit:cover;border-radius:5px}",
3335
3562
  "." + P + "-gallery{display:flex;flex-direction:column;gap:12px;overflow:auto;flex:1}",
3336
3563
  "." + P + "-gallery img{width:100%;height:auto;object-fit:contain;border-radius:8px}"
3337
- ].join("\n");
3564
+ ].concat(require_switch().styles).concat(require_number_field().styles).join("\n");
3338
3565
  if (DOMAIN === "storage") {
3339
3566
  var buttons = "." + P + " :is(button)";
3340
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}";
@@ -3362,8 +3589,10 @@ var require_data_view = __commonJS({
3362
3589
  "packages/addons/lib/data-view.cjs"(exports2, module2) {
3363
3590
  "use strict";
3364
3591
  var React = require("react");
3592
+ var NF = require_number_field();
3365
3593
  var h = React.createElement;
3366
3594
  var COPY = require_data_copy();
3595
+ var SW = require_switch();
3367
3596
  module2.exports = function createDataView(options) {
3368
3597
  var DOMAIN = options.domain;
3369
3598
  function icon(name) {
@@ -3917,17 +4146,18 @@ var require_data_view = __commonJS({
3917
4146
  h("button", { type: "button", className: P + "-btn", disabled: !data || page >= pages, onClick: function() {
3918
4147
  setPage(Math.min(pages, page + 1));
3919
4148
  } }, t.next + " \u203A"),
3920
- h("input", {
4149
+ h(NF.NumberField, {
4150
+ h,
4151
+ lang,
3921
4152
  className: P + "-jump",
3922
- type: "number",
4153
+ value: page,
3923
4154
  min: 1,
3924
4155
  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
- }
4156
+ integer: true,
4157
+ ariaLabel: t.jump,
4158
+ hint: false,
4159
+ onCommit: function(next) {
4160
+ if (next !== null) setPage(next);
3931
4161
  }
3932
4162
  }),
3933
4163
  data && data.queryMs !== void 0 ? h("span", null, fmt(t.queryTime, { n: data.queryMs })) : null
@@ -4024,25 +4254,23 @@ var require_data_view = __commonJS({
4024
4254
  }
4025
4255
  })
4026
4256
  ),
4027
- h(
4028
- "label",
4029
- { className: P + "-switch" },
4030
- h("input", { type: "checkbox", checked: includeDeleted, onChange: function(e) {
4031
- setIncludeDeleted(e.target.checked);
4257
+ h(SW.Switch, {
4258
+ h,
4259
+ checked: includeDeleted,
4260
+ label: t.includeDeleted,
4261
+ onChange: function(next) {
4262
+ setIncludeDeleted(next);
4032
4263
  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
- ),
4264
+ }
4265
+ }),
4266
+ h(SW.Switch, {
4267
+ h,
4268
+ checked: showSystem,
4269
+ label: t.showSystem,
4270
+ onChange: function(next) {
4271
+ setShowSystem(next);
4272
+ }
4273
+ }),
4046
4274
  h("span", { className: P + "-grow" }),
4047
4275
  h(
4048
4276
  "label",
@@ -4195,16 +4423,13 @@ var require_action_schema_style = __commonJS({
4195
4423
  "." + P + "-cardmeta{display:flex;align-items:center;flex-wrap:wrap;gap:8px;min-width:0;min-height:24px}",
4196
4424
  "." + P + "-cardhead code{font-weight:640;overflow-wrap:anywhere;min-width:0}",
4197
4425
  "." + 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
- // 安全约束(不可放开):用警示色描边,和可切换的开关区分开。
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}",
4208
4433
  "." + P + "-locked{border-color:var(--wb-warn,#b7791f);color:var(--wb-warn,#b7791f)}",
4209
4434
  "." + P + "-desc{margin:0;color:var(--dsw-alias-label-secondary,inherit);line-height:1.55;font-size:12.5px}",
4210
4435
  // 搜索命中:用品牌色透明度叠加而不是写死浅色,深浅主题都可读;继承文字颜色、不覆盖 ::selection。
@@ -4257,15 +4482,20 @@ var require_action_schema_view = __commonJS({
4257
4482
  zh: {
4258
4483
  title: "Action",
4259
4484
  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",
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",
4269
4499
  domain: "\u57DF",
4270
4500
  versionLabel: "\u7248\u672C",
4271
4501
  shell: "\u5BBF\u4E3B",
@@ -4279,6 +4509,8 @@ var require_action_schema_view = __commonJS({
4279
4509
  onlyOptional: "\u65E0\u5FC5\u586B\u9879",
4280
4510
  filterType: "\u53C2\u6570\u7C7B\u578B",
4281
4511
  allTypes: "\u5168\u90E8\u7C7B\u578B",
4512
+ filterOrigin: "\u5141\u8BB8\u6765\u6E90",
4513
+ allOrigins: "\u5168\u90E8\u6765\u6E90",
4282
4514
  colName: "\u53C2\u6570",
4283
4515
  colType: "\u7C7B\u578B",
4284
4516
  colReq: "\u5FC5\u586B",
@@ -4311,15 +4543,22 @@ var require_action_schema_view = __commonJS({
4311
4543
  en: {
4312
4544
  title: "Actions",
4313
4545
  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",
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",
4323
4562
  domain: "Domain",
4324
4563
  versionLabel: "Version",
4325
4564
  shell: "Host",
@@ -4333,6 +4572,8 @@ var require_action_schema_view = __commonJS({
4333
4572
  onlyOptional: "No required",
4334
4573
  filterType: "Param type",
4335
4574
  allTypes: "All types",
4575
+ filterOrigin: "Origins",
4576
+ allOrigins: "All origins",
4336
4577
  colName: "Param",
4337
4578
  colType: "Type",
4338
4579
  colReq: "Required",
@@ -4476,6 +4717,8 @@ var require_action_schema_view = __commonJS({
4476
4717
  var reqMode = reqState[0], setReqMode = reqState[1];
4477
4718
  var typeState = React.useState("");
4478
4719
  var typePick = typeState[0], setTypePick = typeState[1];
4720
+ var originFilterState = React.useState("");
4721
+ var originPick = originFilterState[0], setOriginPick = originFilterState[1];
4479
4722
  var toastState = React.useState("");
4480
4723
  var toast = toastState[0], setToast = toastState[1];
4481
4724
  var savingState = React.useState("");
@@ -4531,38 +4774,53 @@ var require_action_schema_view = __commonJS({
4531
4774
  plainCopy(text);
4532
4775
  done();
4533
4776
  }
4534
- 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) {
4535
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
+ });
4536
4793
  setSaving(name);
4537
4794
  setToast("");
4538
4795
  var fail = function(e) {
4539
4796
  setSaving("");
4540
- setToast(t.agentFail + "\uFF1A" + String(e && e.message || e || ""));
4797
+ setToast(t.originsFail + "\uFF1A" + String(e && e.message || e || ""));
4541
4798
  };
4542
4799
  var done = function(r) {
4543
4800
  setSaving("");
4544
4801
  var payload = r && typeof r === "object" && Object.prototype.hasOwnProperty.call(r, "result") ? r.result : r;
4545
4802
  if (r && r.ok === false) {
4546
- setToast(t.agentFail + "\uFF1A" + String(r.error || r.text || ""));
4803
+ setToast(t.originsFail + "\uFF1A" + String(r.error || r.text || ""));
4547
4804
  return;
4548
4805
  }
4549
- 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;
4550
4808
  setSnap(function(prev) {
4551
4809
  if (!prev || !Array.isArray(prev.actions)) return prev;
4552
4810
  return Object.assign({}, prev, {
4553
4811
  actions: prev.actions.map(function(a) {
4554
4812
  if (!a || a.name !== name) return a;
4555
- return Object.assign({}, a, { agentEnabled: value });
4813
+ return Object.assign({}, a, { origins: value, originsSource: source });
4556
4814
  })
4557
4815
  });
4558
4816
  });
4559
- setToast(value ? t.agentOnToast : t.agentOffToast);
4817
+ setToast(t.originsToast);
4560
4818
  };
4561
4819
  if (!api || typeof api.call !== "function") {
4562
4820
  fail(new Error("no call api"));
4563
4821
  return;
4564
4822
  }
4565
- 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);
4566
4824
  }
4567
4825
  var all = snap && Array.isArray(snap.actions) ? snap.actions.filter(function(a) {
4568
4826
  return a && a.domain === DOMAIN;
@@ -4597,6 +4855,7 @@ var require_action_schema_view = __commonJS({
4597
4855
  if (typePick && !rows.some(function(row) {
4598
4856
  return row.types.indexOf(typePick) >= 0;
4599
4857
  })) return false;
4858
+ if (originPick && (!Array.isArray(a.origins) || a.origins.indexOf(originPick) < 0)) return false;
4600
4859
  return true;
4601
4860
  });
4602
4861
  function paramRow(row) {
@@ -4612,33 +4871,45 @@ var require_action_schema_view = __commonJS({
4612
4871
  h("td", null, Highlight.hit(row.description, kw))
4613
4872
  );
4614
4873
  }
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);
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);
4622
4878
  }
4623
- if (typeof action.agentEnabled !== "boolean") return null;
4624
4879
  var busy = saving === action.name;
4880
+ var pinned = action.name === "actions.setActionOrigins";
4881
+ var supported = Array.isArray(action.originsDeclared) ? action.originsDeclared : action.origins;
4625
4882
  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)
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
4642
4913
  );
4643
4914
  }
4644
4915
  function card(action) {
@@ -4659,7 +4930,7 @@ var require_action_schema_view = __commonJS({
4659
4930
  return row.required;
4660
4931
  }) ? h("span", { className: P + "-badge " + P + "-req" }, t.required) : null
4661
4932
  ),
4662
- agentSwitch(action)
4933
+ originsChips(action)
4663
4934
  ),
4664
4935
  action.description ? h("p", { className: P + "-desc" }, Highlight.hit(action.description, kw)) : null,
4665
4936
  rows.length ? h(
@@ -4782,6 +5053,21 @@ var require_action_schema_view = __commonJS({
4782
5053
  return h("option", { value: name, key: name }, name);
4783
5054
  })
4784
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
+ )
4785
5071
  )
4786
5072
  ) : null,
4787
5073
  body,
@@ -4852,7 +5138,7 @@ function definition(host) {
4852
5138
  var tab = makeTab(host.react);
4853
5139
  return {
4854
5140
  id: ADDON_ID,
4855
- version: "0.2.4",
5141
+ version: "0.2.6",
4856
5142
  icon: tab("megaphone"),
4857
5143
  views: [
4858
5144
  {
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.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.4",
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.2"
56
+ "dsh-workbench-host": "^0.9.1"
57
57
  },
58
58
  "dsh": {
59
59
  "bundle": {