dsh-workbench-message 0.1.3 → 0.1.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -1119,6 +1119,8 @@ var require_copy = __commonJS({
1119
1119
  saved: "\u5DF2\u4FDD\u5B58",
1120
1120
  resetAll: "\u5168\u90E8\u6062\u590D\u9ED8\u8BA4",
1121
1121
  resetOne: "\u6062\u590D\u9ED8\u8BA4",
1122
+ resetPos: "\u6062\u590D\u9ED8\u8BA4\u4F4D\u7F6E",
1123
+ resetPosHint: "\u6E05\u7A7A\u81EA\u5B9A\u4E49\u4F4D\u7F6E\uFF0C\u56DE\u5230\u300C\u60AC\u6D6E\u5165\u53E3\u4F4D\u7F6E\u300D\u9009\u5B9A\u7684\u89D2\uFF1B\u672A\u62D6\u62FD\u8FC7\u65F6\u4E0D\u53EF\u7528",
1122
1124
  preview: "\u8BD5\u542C",
1123
1125
  quietNote: "\u514D\u6253\u6270\u65F6\u95F4\u6BB5\u5185\u4E0D\u53D1\u58F0\uFF0C\u6D88\u606F\u7167\u5E38\u5165\u5E93\uFF1B\u300C\u514D\u6253\u6270\u4ECD\u54CD\u7684\u7EA7\u522B\u300D\u53EF\u4EE5\u653E\u884C\u91CD\u8981\u6D88\u606F",
1124
1126
  readDaysNote: "\u5DF2\u8BFB\u6D88\u606F\u8D85\u8FC7\u4FDD\u7559\u5929\u6570\u4F1A\u88AB\u6E05\u7406\uFF1B\u672A\u8BFB\u6D88\u606F\u6C38\u4E0D\u6309\u65F6\u95F4\u6E05\u7406",
@@ -1175,6 +1177,8 @@ var require_copy = __commonJS({
1175
1177
  saved: "Saved",
1176
1178
  resetAll: "Reset all",
1177
1179
  resetOne: "Reset",
1180
+ resetPos: "Reset position",
1181
+ resetPosHint: "Clears the custom position and returns to the corner chosen above; unavailable until dragged",
1178
1182
  preview: "Preview",
1179
1183
  quietNote: "Inside quiet hours nothing plays, but messages are still stored. Levels above can pass through.",
1180
1184
  readDaysNote: "Read messages older than the retention window are pruned; unread ones never expire by time.",
@@ -1267,6 +1271,7 @@ var require_notifier = __commonJS({
1267
1271
  var state = {
1268
1272
  running: false,
1269
1273
  source: null,
1274
+ listeners: /* @__PURE__ */ new Set(),
1270
1275
  cfg: { at: 0, values: null },
1271
1276
  audio: null,
1272
1277
  lastKey: "",
@@ -1385,8 +1390,32 @@ var require_notifier = __commonJS({
1385
1390
  if (isQuiet(values, /* @__PURE__ */ new Date()) && !passQuiet(values, level)) return false;
1386
1391
  return playTone(level, values["sound.volume"]);
1387
1392
  }
1393
+ function subscribe(fn) {
1394
+ if (typeof fn !== "function") return function() {
1395
+ };
1396
+ state.listeners.add(fn);
1397
+ return function() {
1398
+ state.listeners.delete(fn);
1399
+ };
1400
+ }
1401
+ function broadcast(event, data) {
1402
+ state.listeners.forEach(function(fn) {
1403
+ try {
1404
+ fn(event, data);
1405
+ } catch (e) {
1406
+ }
1407
+ });
1408
+ }
1388
1409
  function handleEvent(payload) {
1389
- if (!payload || payload.domainId !== DOMAIN || payload.event !== "message.created") return;
1410
+ if (!payload || payload.domainId !== DOMAIN) return;
1411
+ if (payload.event === "message.created") {
1412
+ var created = payload.data && payload.data.message;
1413
+ if (created && created.id) broadcast("message.created", { message: created });
1414
+ } else if (payload.event === "message.read") {
1415
+ broadcast("message.read", payload.data || {});
1416
+ return;
1417
+ }
1418
+ if (payload.event !== "message.created") return;
1390
1419
  var message = payload.data && payload.data.message;
1391
1420
  if (!message || !message.id) return;
1392
1421
  var now = Date.now();
@@ -1426,9 +1455,18 @@ var require_notifier = __commonJS({
1426
1455
  return playTone(lv, values["sound.volume"] === void 0 ? 0.4 : values["sound.volume"]);
1427
1456
  });
1428
1457
  }
1429
- module2.exports = { start, stop, preview, refreshConfig: function() {
1430
- return loadConfig(true);
1431
- } };
1458
+ module2.exports = {
1459
+ start,
1460
+ stop,
1461
+ subscribe,
1462
+ preview,
1463
+ refreshConfig: function() {
1464
+ return loadConfig(true).then(function(values) {
1465
+ broadcast("config", { values: values || {} });
1466
+ return values;
1467
+ });
1468
+ }
1469
+ };
1432
1470
  }
1433
1471
  });
1434
1472
 
@@ -1563,6 +1601,31 @@ var require_config = __commonJS({
1563
1601
  toastOnce(String(e && e.message || e));
1564
1602
  });
1565
1603
  }
1604
+ function resetPositionRow() {
1605
+ var custom = values()["float.customPos"];
1606
+ return h(
1607
+ "div",
1608
+ { className: "wbm-field", key: "float.resetPos" },
1609
+ h(
1610
+ "div",
1611
+ { className: "wbm-field-main" },
1612
+ h("span", { className: "wbm-field-label" }, t.resetPos),
1613
+ h("span", { className: "wbm-field-hint" }, t.resetPosHint)
1614
+ ),
1615
+ h(
1616
+ "div",
1617
+ { className: "wbm-field-ctl" },
1618
+ h(
1619
+ "button",
1620
+ { type: "button", className: "wbm-btn", disabled: !custom, onClick: function() {
1621
+ save("float.customPos", "");
1622
+ } },
1623
+ props.Icon ? h(props.Icon, { name: "reset", size: 12 }) : null,
1624
+ h("span", null, t.resetPos)
1625
+ )
1626
+ )
1627
+ );
1628
+ }
1566
1629
  function control(item) {
1567
1630
  var value = values()[item.id];
1568
1631
  if (item.type === "bool") {
@@ -1731,7 +1794,8 @@ var require_config = __commonJS({
1731
1794
  ) : null
1732
1795
  )
1733
1796
  );
1734
- })
1797
+ }),
1798
+ group.id === "float" ? resetPositionRow() : null
1735
1799
  );
1736
1800
  }),
1737
1801
  h("div", { className: "wbm-note" }, t.quietNote),
@@ -3862,6 +3926,823 @@ var require_actions = __commonJS({
3862
3926
  }
3863
3927
  });
3864
3928
 
3929
+ // packages/addons/message/client/float/style.cjs
3930
+ var require_style = __commonJS({
3931
+ "packages/addons/message/client/float/style.cjs"(exports2, module2) {
3932
+ "use strict";
3933
+ module2.exports = function floatStyles() {
3934
+ return [
3935
+ ".wbm-float-root{position:fixed;left:0;top:0;width:0;height:0;z-index:860;pointer-events:none;-webkit-app-region:no-drag}",
3936
+ ".wbm-float-root .wbm-float-btn{position:absolute;left:0;top:0;right:auto;bottom:auto;display:inline-flex;align-items:center;justify-content:center;",
3937
+ "box-sizing:border-box;width:46px;height:46px;padding:0;flex:0 0 auto;border-radius:50%;",
3938
+ "--wbm-float-bg:var(--dsw-alias-button-floating-fill,var(--wb-card,#2c2c2e));",
3939
+ "--wbm-float-ink:var(--dsw-alias-label-primary,var(--wb-muted,currentColor));",
3940
+ "--wbm-float-line:var(--dsw-alias-border-l2,var(--wb-border,rgba(255,255,255,.14)));",
3941
+ "--wbm-float-danger:var(--dsw-alias-state-error-primary,var(--wb-danger,#dc2626));",
3942
+ "border:1px solid var(--wbm-float-line);background:var(--wbm-float-bg);color:var(--wbm-float-ink);",
3943
+ "cursor:grab;pointer-events:auto;-webkit-app-region:no-drag;overflow:visible;",
3944
+ // 触屏拖动时不要被页面滚动抢走指针,文字也不要被选中。
3945
+ "touch-action:none;-webkit-user-select:none;user-select:none;",
3946
+ "box-shadow:0 8px 22px rgba(0,0,0,.24),0 1px 3px rgba(0,0,0,.18);",
3947
+ "transition:transform .18s ease,box-shadow .18s ease,background .18s ease,border-color .18s ease}",
3948
+ // 首次定位完成后才允许 left/top 过渡(挂载瞬间不要从左上角滑过来)。
3949
+ ".wbm-float-root .wbm-float-btn[data-ready]{transition:left .18s ease,top .18s ease,transform .18s ease,",
3950
+ "box-shadow .18s ease,background .18s ease,border-color .18s ease}",
3951
+ // 拖拽中必须跟手:关掉过渡,hover 的位移也一并取消。
3952
+ ".wbm-float-root .wbm-float-btn[data-dragging=1]{cursor:grabbing;transition:none}",
3953
+ ".wbm-float-root .wbm-float-btn[data-dragging=1]:hover{transform:none;",
3954
+ "box-shadow:0 8px 22px rgba(0,0,0,.24),0 1px 3px rgba(0,0,0,.18)}",
3955
+ ".wbm-float-root .wbm-float-btn:hover{transform:translateY(-1px);box-shadow:0 12px 26px rgba(0,0,0,.28),0 1px 3px rgba(0,0,0,.2);",
3956
+ "background:var(--dsw-alias-button-floating-hover,var(--wbm-float-bg))}",
3957
+ ".wbm-float-root .wbm-float-btn:active{transform:translateY(0)}",
3958
+ ".wbm-float-root .wbm-float-btn:focus-visible{outline:2px solid var(--dsw-alias-brand-primary,var(--wb-accent,#2563eb));outline-offset:2px}",
3959
+ ".wbm-float-root .wbm-float-btn svg{display:block;width:21px;height:21px;flex:0 0 auto}",
3960
+ ".wbm-float-root .wbm-float-badge{position:absolute;top:-5px;right:-5px;min-width:18px;height:18px;padding:0 5px;",
3961
+ "box-sizing:border-box;border-radius:999px;display:none;align-items:center;justify-content:center;",
3962
+ "background:var(--wbm-float-danger,#dc2626);color:var(--dsw-alias-label-on-color,#fff);",
3963
+ "font-size:11px;font-weight:650;line-height:1;font-variant-numeric:tabular-nums;",
3964
+ "box-shadow:0 0 0 2px var(--wbm-float-bg)}",
3965
+ ".wbm-float-root .wbm-float-btn[data-unread] .wbm-float-badge{display:inline-flex}",
3966
+ // 半隐藏时角标会有一半在视口外,直接收起角标;来新消息会先临时展开再显示。
3967
+ ".wbm-float-root .wbm-float-btn[data-collapsed=1] .wbm-float-badge{display:none}",
3968
+ ".wbm-float-root .wbm-float-btn[data-pulse=1]{animation:wbm-float-bounce .6s cubic-bezier(.34,1.56,.64,1)}",
3969
+ "@keyframes wbm-float-bounce{0%{transform:translateY(0)}35%{transform:translateY(-7px)}70%{transform:translateY(0)}100%{transform:translateY(0)}}",
3970
+ "@media (max-width:640px){.wbm-float-root .wbm-float-btn{width:40px;height:40px}",
3971
+ ".wbm-float-root .wbm-float-btn svg{width:18px;height:18px}}",
3972
+ // 降低动态偏好:不做位移,只让描边闪一次颜色。
3973
+ "@media (prefers-reduced-motion: reduce){.wbm-float-root .wbm-float-btn[data-pulse=1]{animation:none;",
3974
+ "border-color:var(--dsw-alias-brand-primary,var(--wb-accent,#2563eb))}",
3975
+ ".wbm-float-root .wbm-float-btn{transition:none}}"
3976
+ ];
3977
+ };
3978
+ }
3979
+ });
3980
+
3981
+ // packages/addons/message/client/float/button.cjs
3982
+ var require_button = __commonJS({
3983
+ "packages/addons/message/client/float/button.cjs"(exports2, module2) {
3984
+ "use strict";
3985
+ var ICON_PATH = "M22 17a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 21.286V5a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2z";
3986
+ var PULSE_MS = 600;
3987
+ function label(lang, count) {
3988
+ var n = count > 0 ? count : 0;
3989
+ if (lang === "en") return n > 0 ? "Messages, " + n + " unread" : "Messages, no unread";
3990
+ return n > 0 ? "\u6D88\u606F\uFF0C" + n + " \u6761\u672A\u8BFB" : "\u6D88\u606F\uFF0C\u65E0\u672A\u8BFB";
3991
+ }
3992
+ function text(count) {
3993
+ return count > 99 ? "99+" : String(count);
3994
+ }
3995
+ function createButton(options) {
3996
+ var doc = options.doc || document;
3997
+ var lang = options.lang === "en" ? "en" : "zh";
3998
+ var onActivate = typeof options.onActivate === "function" ? options.onActivate : function() {
3999
+ };
4000
+ var onClick = typeof options.onClick === "function" ? options.onClick : null;
4001
+ var count = 0;
4002
+ var pulseTimer = null;
4003
+ var btn = doc.createElement("button");
4004
+ btn.type = "button";
4005
+ btn.className = "wbm-float-btn";
4006
+ btn.style.borderRadius = "50%";
4007
+ btn.style.pointerEvents = "auto";
4008
+ btn.setAttribute("data-pos", "bottom-right");
4009
+ btn.setAttribute("aria-label", label(lang, 0));
4010
+ btn.setAttribute("title", label(lang, 0));
4011
+ var svg = doc.createElementNS("http://www.w3.org/2000/svg", "svg");
4012
+ svg.setAttribute("viewBox", "0 0 24 24");
4013
+ svg.setAttribute("fill", "none");
4014
+ svg.setAttribute("stroke", "currentColor");
4015
+ svg.setAttribute("stroke-width", "1.7");
4016
+ svg.setAttribute("stroke-linecap", "round");
4017
+ svg.setAttribute("stroke-linejoin", "round");
4018
+ svg.setAttribute("aria-hidden", "true");
4019
+ var path = doc.createElementNS("http://www.w3.org/2000/svg", "path");
4020
+ path.setAttribute("d", ICON_PATH);
4021
+ svg.appendChild(path);
4022
+ btn.appendChild(svg);
4023
+ var badge = doc.createElement("span");
4024
+ badge.className = "wbm-float-badge";
4025
+ badge.setAttribute("aria-hidden", "true");
4026
+ btn.appendChild(badge);
4027
+ function announce(next) {
4028
+ var text_ = label(lang, next);
4029
+ btn.setAttribute("aria-label", text_);
4030
+ btn.setAttribute("title", text_);
4031
+ }
4032
+ function setCount(next) {
4033
+ var n = Number(next);
4034
+ count = isFinite(n) && n > 0 ? Math.floor(n) : 0;
4035
+ badge.textContent = text(count);
4036
+ if (count > 0) btn.setAttribute("data-unread", "1");
4037
+ else btn.removeAttribute("data-unread");
4038
+ announce(count);
4039
+ return count;
4040
+ }
4041
+ function pulse() {
4042
+ if (!btn || typeof btn.setAttribute !== "function") return;
4043
+ if (btn.getAttribute("data-pulse") === "1") return;
4044
+ btn.setAttribute("data-pulse", "1");
4045
+ if (typeof setTimeout !== "function") return;
4046
+ pulseTimer = setTimeout(function() {
4047
+ pulseTimer = null;
4048
+ btn.removeAttribute("data-pulse");
4049
+ }, PULSE_MS);
4050
+ }
4051
+ function setPosition(pos) {
4052
+ btn.setAttribute("data-pos", pos === "bottom-left" ? "bottom-left" : "bottom-right");
4053
+ }
4054
+ function setLang(next) {
4055
+ lang = next === "en" ? "en" : "zh";
4056
+ announce(count);
4057
+ }
4058
+ function setPoint(x, y) {
4059
+ btn.style.left = Math.round(x) + "px";
4060
+ btn.style.top = Math.round(y) + "px";
4061
+ }
4062
+ function setCollapsed(on) {
4063
+ if (on) btn.setAttribute("data-collapsed", "1");
4064
+ else btn.removeAttribute("data-collapsed");
4065
+ }
4066
+ function setDragging(on) {
4067
+ if (on) btn.setAttribute("data-dragging", "1");
4068
+ else btn.removeAttribute("data-dragging");
4069
+ }
4070
+ function setReady() {
4071
+ btn.setAttribute("data-ready", "1");
4072
+ }
4073
+ btn.addEventListener("click", function(event) {
4074
+ if (event && typeof event.preventDefault === "function") event.preventDefault();
4075
+ if (onClick) {
4076
+ onClick(event);
4077
+ return;
4078
+ }
4079
+ onActivate();
4080
+ });
4081
+ function destroy() {
4082
+ if (pulseTimer && typeof clearTimeout === "function") clearTimeout(pulseTimer);
4083
+ pulseTimer = null;
4084
+ if (btn.parentNode) btn.parentNode.removeChild(btn);
4085
+ }
4086
+ return {
4087
+ el: btn,
4088
+ setCount,
4089
+ pulse,
4090
+ setPosition,
4091
+ setLang,
4092
+ setPoint,
4093
+ setCollapsed,
4094
+ setDragging,
4095
+ setReady,
4096
+ destroy
4097
+ };
4098
+ }
4099
+ module2.exports = { createButton, ICON_PATH, PULSE_MS };
4100
+ }
4101
+ });
4102
+
4103
+ // packages/addons/message/client/float/geometry.cjs
4104
+ var require_geometry = __commonJS({
4105
+ "packages/addons/message/client/float/geometry.cjs"(exports2, module2) {
4106
+ "use strict";
4107
+ var MIN_VISIBLE = 24;
4108
+ var EDGE_ZONE = 48;
4109
+ var EDGE_INSET = 20;
4110
+ var EDGE_INSET_NARROW = 12;
4111
+ var NARROW_WIDTH = 640;
4112
+ var SIZE = 46;
4113
+ var SIZE_NARROW = 40;
4114
+ var FALLBACK_WIDTH = 1280;
4115
+ var FALLBACK_HEIGHT = 800;
4116
+ function clamp(value, min, max) {
4117
+ if (!isFinite(value)) return min;
4118
+ if (max < min) return min;
4119
+ return Math.min(Math.max(value, min), max);
4120
+ }
4121
+ function viewport(doc, win) {
4122
+ var el = doc && doc.documentElement;
4123
+ var width = Number(el && el.clientWidth) || Number(win && win.innerWidth) || FALLBACK_WIDTH;
4124
+ var height = Number(el && el.clientHeight) || Number(win && win.innerHeight) || FALLBACK_HEIGHT;
4125
+ return { width: width > 0 ? width : FALLBACK_WIDTH, height: height > 0 ? height : FALLBACK_HEIGHT };
4126
+ }
4127
+ function sizeOf(el, viewportWidth) {
4128
+ var rect = null;
4129
+ if (el && typeof el.getBoundingClientRect === "function") {
4130
+ try {
4131
+ rect = el.getBoundingClientRect();
4132
+ } catch (e) {
4133
+ rect = null;
4134
+ }
4135
+ }
4136
+ var size = rect && Number(rect.width) > 0 ? Number(rect.width) : 0;
4137
+ if (!size) size = viewportWidth <= NARROW_WIDTH ? SIZE_NARROW : SIZE;
4138
+ return size;
4139
+ }
4140
+ function marginOf(viewportWidth) {
4141
+ return viewportWidth <= NARROW_WIDTH ? EDGE_INSET_NARROW : EDGE_INSET;
4142
+ }
4143
+ function cornerPoint(corner, viewportWidth, viewportHeight, size, lift, margin) {
4144
+ var inset = margin === void 0 ? marginOf(viewportWidth) : margin;
4145
+ var x = corner === "bottom-left" ? inset : viewportWidth - inset - size;
4146
+ var y = viewportHeight - inset - size - (Number(lift) || 0);
4147
+ return { x: clamp(x, 0, Math.max(0, viewportWidth - size)), y: clamp(y, 0, Math.max(0, viewportHeight - size)) };
4148
+ }
4149
+ function parsePos(text) {
4150
+ if (typeof text !== "string") return null;
4151
+ var raw = text.trim();
4152
+ if (!raw) return null;
4153
+ var parts = raw.split(",");
4154
+ if (parts.length !== 2) return null;
4155
+ var rx = Number(parts[0]);
4156
+ var ry = Number(parts[1]);
4157
+ if (!isFinite(rx) || !isFinite(ry)) return null;
4158
+ if (rx < 0 || rx > 1 || ry < 0 || ry > 1) return null;
4159
+ return { rx, ry };
4160
+ }
4161
+ function formatPos(rx, ry) {
4162
+ return Number(rx).toFixed(4) + "," + Number(ry).toFixed(4);
4163
+ }
4164
+ function pointOf(rx, ry, viewportWidth, viewportHeight, size) {
4165
+ return {
4166
+ x: clamp(Number(rx) * viewportWidth - size / 2, 0, Math.max(0, viewportWidth - size)),
4167
+ y: clamp(Number(ry) * viewportHeight - size / 2, 0, Math.max(0, viewportHeight - size))
4168
+ };
4169
+ }
4170
+ function ratioOf(x, y, viewportWidth, viewportHeight, size) {
4171
+ var p = clampPoint(x, y, size, viewportWidth, viewportHeight);
4172
+ return {
4173
+ rx: clamp((p.x + size / 2) / viewportWidth, 0, 1),
4174
+ ry: clamp((p.y + size / 2) / viewportHeight, 0, 1)
4175
+ };
4176
+ }
4177
+ function clampPoint(x, y, size, viewportWidth, viewportHeight) {
4178
+ return {
4179
+ x: clamp(x, 0, Math.max(0, viewportWidth - size)),
4180
+ y: clamp(y, 0, Math.max(0, viewportHeight - size))
4181
+ };
4182
+ }
4183
+ function gaps(left, size, viewportWidth) {
4184
+ return { left, right: viewportWidth - left - size };
4185
+ }
4186
+ function nearEdge(left, size, viewportWidth) {
4187
+ var g = gaps(left, size, viewportWidth);
4188
+ return g.left <= EDGE_ZONE || g.right <= EDGE_ZONE;
4189
+ }
4190
+ function sideOf(left, size, viewportWidth) {
4191
+ var g = gaps(left, size, viewportWidth);
4192
+ return g.left <= g.right ? "left" : "right";
4193
+ }
4194
+ function collapsedPoint(side, size, viewportWidth, y) {
4195
+ return {
4196
+ x: side === "left" ? -size / 2 : viewportWidth - size / 2,
4197
+ y
4198
+ };
4199
+ }
4200
+ module2.exports = {
4201
+ MIN_VISIBLE,
4202
+ EDGE_ZONE,
4203
+ NARROW_WIDTH,
4204
+ SIZE,
4205
+ SIZE_NARROW,
4206
+ clamp,
4207
+ viewport,
4208
+ sizeOf,
4209
+ marginOf,
4210
+ cornerPoint,
4211
+ parsePos,
4212
+ formatPos,
4213
+ pointOf,
4214
+ ratioOf,
4215
+ clampPoint,
4216
+ nearEdge,
4217
+ sideOf,
4218
+ collapsedPoint
4219
+ };
4220
+ }
4221
+ });
4222
+
4223
+ // packages/addons/message/client/float/mount.cjs
4224
+ var require_mount = __commonJS({
4225
+ "packages/addons/message/client/float/mount.cjs"(exports2, module2) {
4226
+ "use strict";
4227
+ var styles = require_style();
4228
+ var buttons = require_button();
4229
+ var geo = require_geometry();
4230
+ var DOMAIN = "wb-addon-message";
4231
+ var BASE = "/workbench/api";
4232
+ var STYLE_ID = "wb-message-float-style";
4233
+ var ADDON_ID = "wb-addon-message";
4234
+ var INBOX_VIEW = "inbox";
4235
+ var HOLD_MS = 2e3;
4236
+ var DRAG_THRESHOLD = 5;
4237
+ var JUST_DRAGGED_MS = 120;
4238
+ var POS_EPSILON = 1e-3;
4239
+ function readLang(doc) {
4240
+ var attr = doc && doc.documentElement && doc.documentElement.getAttribute("lang");
4241
+ return attr && attr.toLowerCase().indexOf("en") === 0 ? "en" : "zh";
4242
+ }
4243
+ function injectStyles(doc) {
4244
+ if (!doc || !doc.head || doc.getElementById(STYLE_ID)) return;
4245
+ var style = doc.createElement("style");
4246
+ style.id = STYLE_ID;
4247
+ style.textContent = styles().join("");
4248
+ doc.head.appendChild(style);
4249
+ }
4250
+ function makeCall(fetchImpl) {
4251
+ return function call(action, args) {
4252
+ return fetchImpl(BASE + "/domains/" + DOMAIN + "/actions/" + action, {
4253
+ method: "POST",
4254
+ headers: { "content-type": "application/json" },
4255
+ body: JSON.stringify(args || {})
4256
+ }).then(function(res) {
4257
+ return res.json();
4258
+ }).then(function(body) {
4259
+ return body && body.result !== void 0 ? body.result : body;
4260
+ });
4261
+ };
4262
+ }
4263
+ function createMount(options) {
4264
+ var opts = options || {};
4265
+ var doc = opts.doc || (typeof document !== "undefined" ? document : null);
4266
+ var win = opts.win || (typeof window !== "undefined" ? window : null);
4267
+ var host = opts.host || win && win.__WB_HOST__ || null;
4268
+ var notifier = opts.notifier || null;
4269
+ var fetchImpl = opts.fetchImpl || (win && win.fetch ? win.fetch.bind(win) : null);
4270
+ var call = fetchImpl ? makeCall(fetchImpl) : null;
4271
+ var state = {
4272
+ mounted: false,
4273
+ root: null,
4274
+ btn: null,
4275
+ unsubscribe: null,
4276
+ seen: /* @__PURE__ */ new Set(),
4277
+ count: 0,
4278
+ enabled: true,
4279
+ corner: "bottom-right",
4280
+ idleSeconds: 3,
4281
+ edgeSnap: true,
4282
+ customText: "",
4283
+ hasCustom: false,
4284
+ rx: 0.5,
4285
+ ry: 0.5,
4286
+ lift: 0,
4287
+ size: geo.SIZE,
4288
+ collapsed: false,
4289
+ side: "right",
4290
+ x: 0,
4291
+ y: 0,
4292
+ hovered: false,
4293
+ focused: false,
4294
+ dragging: false,
4295
+ pressed: false,
4296
+ pressX: 0,
4297
+ pressY: 0,
4298
+ startX: 0,
4299
+ startY: 0,
4300
+ expandedByPress: false,
4301
+ justDraggedUntil: 0,
4302
+ holdUntil: 0,
4303
+ idleTimer: null,
4304
+ onVisible: null,
4305
+ onResize: null,
4306
+ onWindowUp: null
4307
+ };
4308
+ function now() {
4309
+ return Date.now ? Date.now() : (/* @__PURE__ */ new Date()).getTime();
4310
+ }
4311
+ function later(fn, ms) {
4312
+ var setter = win && typeof win.setTimeout === "function" ? win.setTimeout.bind(win) : setTimeout;
4313
+ var timer = setter(fn, Math.max(0, ms || 0));
4314
+ if (timer && typeof timer.unref === "function") timer.unref();
4315
+ return timer;
4316
+ }
4317
+ function cancel(timer) {
4318
+ if (timer === null || timer === void 0) return;
4319
+ var clearer = win && typeof win.clearTimeout === "function" ? win.clearTimeout.bind(win) : clearTimeout;
4320
+ clearer(timer);
4321
+ }
4322
+ function disarm() {
4323
+ cancel(state.idleTimer);
4324
+ state.idleTimer = null;
4325
+ }
4326
+ function hostOverlay() {
4327
+ return doc && doc.querySelector ? doc.querySelector("[data-shell-overlay]") : null;
4328
+ }
4329
+ function metrics() {
4330
+ var vp = geo.viewport(doc, win);
4331
+ var size = geo.sizeOf(state.btn && state.btn.el, vp.width);
4332
+ var origin = { x: 0, y: 0 };
4333
+ if (state.root && typeof state.root.getBoundingClientRect === "function") {
4334
+ var rect = state.root.getBoundingClientRect();
4335
+ origin.x = Number(rect && rect.left) || 0;
4336
+ origin.y = Number(rect && rect.top) || 0;
4337
+ }
4338
+ return { width: vp.width, height: vp.height, size, origin };
4339
+ }
4340
+ function liftAboveComposer() {
4341
+ if (!state.btn) return;
4342
+ state.lift = 0;
4343
+ if (!doc || typeof doc.querySelector !== "function") {
4344
+ state.btn.el.removeAttribute("data-lift");
4345
+ return;
4346
+ }
4347
+ var composer = doc.querySelector("[data-shell-composer], .dsh-composer, [contenteditable=true], .wb-composer");
4348
+ if (!composer || typeof composer.getBoundingClientRect !== "function") {
4349
+ state.btn.el.removeAttribute("data-lift");
4350
+ return;
4351
+ }
4352
+ var rect = composer.getBoundingClientRect();
4353
+ var height = rect && rect.height > 0 ? rect.height : 0;
4354
+ if (!height) {
4355
+ state.btn.el.removeAttribute("data-lift");
4356
+ return;
4357
+ }
4358
+ var lift = Math.min(Math.max(Math.round(height + 12), 48), 140);
4359
+ state.lift = lift;
4360
+ state.btn.el.setAttribute("data-lift", "1");
4361
+ state.btn.el.style.setProperty("--wbm-float-lift", lift + "px");
4362
+ }
4363
+ function place() {
4364
+ if (!state.root || !doc) return;
4365
+ var target = hostOverlay() || doc.body;
4366
+ if (target && state.root.parentNode !== target) target.appendChild(state.root);
4367
+ }
4368
+ function basePoint(m) {
4369
+ if (state.hasCustom) return geo.pointOf(state.rx, state.ry, m.width, m.height, m.size);
4370
+ return geo.cornerPoint(state.corner, m.width, m.height, m.size, state.lift, geo.marginOf(m.width));
4371
+ }
4372
+ function paint(point, m) {
4373
+ state.x = point.x;
4374
+ state.y = point.y;
4375
+ state.size = m.size;
4376
+ if (!state.btn) return;
4377
+ state.btn.setPoint(point.x - m.origin.x, point.y - m.origin.y);
4378
+ }
4379
+ function render() {
4380
+ if (!state.btn) return;
4381
+ var m = metrics();
4382
+ if (state.collapsed) {
4383
+ var base = basePoint(m);
4384
+ var top = geo.clamp(base.y, 0, Math.max(0, m.height - m.size));
4385
+ paint(geo.collapsedPoint(state.side, m.size, m.width, top), m);
4386
+ } else {
4387
+ paint(basePoint(m), m);
4388
+ }
4389
+ state.btn.setCollapsed(state.collapsed);
4390
+ if (!state.dragging) state.btn.setReady();
4391
+ }
4392
+ function expand() {
4393
+ if (!state.collapsed) return;
4394
+ state.collapsed = false;
4395
+ render();
4396
+ }
4397
+ function collapse() {
4398
+ if (!state.enabled || state.collapsed || !state.edgeSnap || state.idleSeconds <= 0) return;
4399
+ if (state.hovered || state.focused || state.dragging || state.pressed) return;
4400
+ var m = metrics();
4401
+ var base = basePoint(m);
4402
+ if (!geo.nearEdge(base.x, m.size, m.width)) return;
4403
+ state.side = geo.sideOf(base.x, m.size, m.width);
4404
+ state.collapsed = true;
4405
+ render();
4406
+ disarm();
4407
+ }
4408
+ function arm(ms) {
4409
+ disarm();
4410
+ if (!state.enabled || !state.edgeSnap || state.idleSeconds <= 0) return;
4411
+ var delay = ms === void 0 ? state.idleSeconds * 1e3 : ms;
4412
+ state.idleTimer = later(function() {
4413
+ state.idleTimer = null;
4414
+ tick();
4415
+ }, delay);
4416
+ }
4417
+ function tick() {
4418
+ if (!state.mounted) return;
4419
+ var wait = state.holdUntil - now();
4420
+ if (wait > 0) {
4421
+ arm(wait);
4422
+ return;
4423
+ }
4424
+ if (state.hovered || state.focused || state.dragging || state.pressed) return;
4425
+ collapse();
4426
+ }
4427
+ function persist() {
4428
+ if (!call) return;
4429
+ var last = geo.parsePos(state.customText);
4430
+ if (last && Math.abs(last.rx - state.rx) < POS_EPSILON && Math.abs(last.ry - state.ry) < POS_EPSILON) return;
4431
+ var text = geo.formatPos(state.rx, state.ry);
4432
+ state.customText = text;
4433
+ state.hasCustom = true;
4434
+ Promise.resolve(call("message.configSet", { values: { "float.customPos": text } })).catch(function() {
4435
+ });
4436
+ }
4437
+ function applyConfig(values) {
4438
+ if (!values) return;
4439
+ if (values["float.enabled"] !== void 0) state.enabled = values["float.enabled"] !== false;
4440
+ if (values["float.position"]) {
4441
+ state.corner = values["float.position"];
4442
+ if (!state.hasCustom) state.collapsed = false;
4443
+ }
4444
+ if (values["float.idleSeconds"] !== void 0) {
4445
+ state.idleSeconds = geo.clamp(Number(values["float.idleSeconds"]) || 0, 0, 60);
4446
+ }
4447
+ if (values["float.edgeSnap"] !== void 0) state.edgeSnap = values["float.edgeSnap"] !== false;
4448
+ if (values["float.customPos"] !== void 0) {
4449
+ var text = values["float.customPos"] === null || values["float.customPos"] === void 0 ? "" : String(values["float.customPos"]);
4450
+ var parsed = geo.parsePos(text);
4451
+ state.customText = text;
4452
+ state.hasCustom = !!parsed;
4453
+ if (parsed) {
4454
+ state.rx = parsed.rx;
4455
+ state.ry = parsed.ry;
4456
+ } else {
4457
+ state.collapsed = false;
4458
+ }
4459
+ }
4460
+ if (!state.btn) return;
4461
+ state.btn.setPosition(state.corner);
4462
+ liftAboveComposer();
4463
+ state.btn.el.style.display = state.enabled ? "" : "none";
4464
+ if (!state.enabled) {
4465
+ state.count = 0;
4466
+ state.btn.setCount(0);
4467
+ state.collapsed = false;
4468
+ disarm();
4469
+ }
4470
+ place();
4471
+ render();
4472
+ if (state.enabled) arm();
4473
+ else disarm();
4474
+ }
4475
+ function applyCount(next) {
4476
+ state.count = next > 0 ? Math.floor(next) : 0;
4477
+ if (state.btn) state.btn.setCount(state.count);
4478
+ return state.count;
4479
+ }
4480
+ function activate() {
4481
+ if (host && typeof host.navigateAddon === "function") {
4482
+ try {
4483
+ if (host.navigateAddon(ADDON_ID, INBOX_VIEW) !== false) return;
4484
+ } catch (e) {
4485
+ }
4486
+ }
4487
+ if (typeof console !== "undefined" && console.info) {
4488
+ console.info("[dsh-workbench-message] \u5F53\u524D\u5BBF\u4E3B\u4E0D\u652F\u6301\u8DF3\u8F6C\u5230\u6D88\u606F\u6536\u4EF6\u7BB1\uFF0C\u8BF7\u5728\u5DE6\u4FA7\u5BFC\u822A\u6253\u5F00\u300C\u6D88\u606F\u300D");
4489
+ }
4490
+ }
4491
+ function detachWindowUp() {
4492
+ if (!state.onWindowUp || !win || typeof win.removeEventListener !== "function") return;
4493
+ win.removeEventListener("mouseup", state.onWindowUp);
4494
+ state.onWindowUp = null;
4495
+ }
4496
+ function eventPoint(event) {
4497
+ return {
4498
+ x: event && typeof event.clientX === "number" ? event.clientX : 0,
4499
+ y: event && typeof event.clientY === "number" ? event.clientY : 0
4500
+ };
4501
+ }
4502
+ function onDown(event) {
4503
+ if (!state.enabled || !state.btn) return;
4504
+ if (event && typeof event.button === "number" && event.button !== 0) return;
4505
+ var m = metrics();
4506
+ var point = eventPoint(event);
4507
+ state.pressed = true;
4508
+ state.dragging = false;
4509
+ state.pressX = point.x;
4510
+ state.pressY = point.y;
4511
+ state.startX = state.x;
4512
+ state.startY = state.y;
4513
+ state.size = m.size;
4514
+ disarm();
4515
+ if (state.collapsed) {
4516
+ expand();
4517
+ state.expandedByPress = true;
4518
+ state.startX = state.x;
4519
+ state.startY = state.y;
4520
+ }
4521
+ if (typeof state.btn.el.setPointerCapture === "function" && event && event.pointerId !== void 0) {
4522
+ try {
4523
+ state.btn.el.setPointerCapture(event.pointerId);
4524
+ } catch (err) {
4525
+ }
4526
+ }
4527
+ if (win && typeof win.addEventListener === "function" && !state.onWindowUp) {
4528
+ state.onWindowUp = function() {
4529
+ endPress();
4530
+ };
4531
+ win.addEventListener("mouseup", state.onWindowUp);
4532
+ }
4533
+ }
4534
+ function onMove(event) {
4535
+ if (!state.pressed) return;
4536
+ var point = eventPoint(event);
4537
+ var dx = point.x - state.pressX;
4538
+ var dy = point.y - state.pressY;
4539
+ if (!state.dragging) {
4540
+ if (Math.sqrt(dx * dx + dy * dy) < DRAG_THRESHOLD) return;
4541
+ state.dragging = true;
4542
+ state.expandedByPress = false;
4543
+ state.holdUntil = 0;
4544
+ disarm();
4545
+ if (state.btn) state.btn.setDragging(true);
4546
+ }
4547
+ var m = metrics();
4548
+ paint(geo.clampPoint(state.startX + dx, state.startY + dy, m.size, m.width, m.height), m);
4549
+ }
4550
+ function endPress() {
4551
+ if (!state.pressed) return;
4552
+ state.pressed = false;
4553
+ detachWindowUp();
4554
+ if (!state.dragging) return;
4555
+ state.dragging = false;
4556
+ if (state.btn) state.btn.setDragging(false);
4557
+ var m = metrics();
4558
+ var ratio = geo.ratioOf(state.x, state.y, m.width, m.height, m.size);
4559
+ state.rx = ratio.rx;
4560
+ state.ry = ratio.ry;
4561
+ state.hasCustom = true;
4562
+ state.collapsed = false;
4563
+ render();
4564
+ persist();
4565
+ state.justDraggedUntil = now() + JUST_DRAGGED_MS;
4566
+ arm();
4567
+ }
4568
+ function onClick() {
4569
+ if (!state.enabled) return;
4570
+ if (now() < state.justDraggedUntil) return;
4571
+ if (state.expandedByPress) {
4572
+ state.expandedByPress = false;
4573
+ expand();
4574
+ arm();
4575
+ return;
4576
+ }
4577
+ if (state.collapsed) {
4578
+ expand();
4579
+ arm();
4580
+ return;
4581
+ }
4582
+ activate();
4583
+ }
4584
+ function onEnter() {
4585
+ state.hovered = true;
4586
+ expand();
4587
+ disarm();
4588
+ }
4589
+ function onLeave() {
4590
+ state.hovered = false;
4591
+ var wait = state.holdUntil - now();
4592
+ arm(wait > 0 ? wait : state.idleSeconds * 1e3);
4593
+ }
4594
+ function onFocus() {
4595
+ state.focused = true;
4596
+ expand();
4597
+ disarm();
4598
+ }
4599
+ function onBlur() {
4600
+ state.focused = false;
4601
+ arm();
4602
+ }
4603
+ function onResize() {
4604
+ if (!state.mounted) return;
4605
+ var m = metrics();
4606
+ if (state.hasCustom && !state.collapsed) {
4607
+ var ratio = geo.ratioOf(state.x, state.y, m.width, m.height, m.size);
4608
+ state.rx = ratio.rx;
4609
+ state.ry = ratio.ry;
4610
+ }
4611
+ if (state.collapsed) state.side = geo.sideOf(basePoint(m).x, m.size, m.width);
4612
+ render();
4613
+ }
4614
+ function onEvent(event, data) {
4615
+ if (!state.btn || !state.mounted) return;
4616
+ if (event === "config") {
4617
+ applyConfig(data && data.values);
4618
+ return;
4619
+ }
4620
+ if (event === "message.read") {
4621
+ if (data && typeof data.unread === "number") applyCount(data.unread);
4622
+ return;
4623
+ }
4624
+ if (event !== "message.created") return;
4625
+ var message = data && data.message;
4626
+ if (!message || !message.id) return;
4627
+ if (state.seen.has(message.id)) return;
4628
+ state.seen.add(message.id);
4629
+ if (state.seen.size > 500) state.seen.clear();
4630
+ applyCount(state.count + 1);
4631
+ if (state.btn) state.btn.pulse();
4632
+ if (state.collapsed) {
4633
+ state.collapsed = false;
4634
+ render();
4635
+ }
4636
+ state.holdUntil = now() + HOLD_MS;
4637
+ if (!state.hovered && !state.focused && !state.dragging) arm(HOLD_MS);
4638
+ }
4639
+ function refreshCount() {
4640
+ if (!call) return Promise.resolve(state.count);
4641
+ return call("message.unreadCount", {}).then(function(body) {
4642
+ var unread = body && typeof body.unread === "number" ? body.unread : null;
4643
+ return unread === null ? state.count : applyCount(unread);
4644
+ }).catch(function() {
4645
+ return state.count;
4646
+ });
4647
+ }
4648
+ function loadConfig() {
4649
+ if (!call) return Promise.resolve(state.enabled);
4650
+ return call("message.configGet", {}).then(function(body) {
4651
+ applyConfig(body && body.values);
4652
+ return state.enabled;
4653
+ }).catch(function() {
4654
+ return state.enabled;
4655
+ });
4656
+ }
4657
+ function bind() {
4658
+ var el = state.btn.el;
4659
+ el.addEventListener("pointerdown", onDown);
4660
+ el.addEventListener("pointermove", onMove);
4661
+ el.addEventListener("pointerup", endPress);
4662
+ el.addEventListener("pointercancel", endPress);
4663
+ el.addEventListener("pointerenter", onEnter);
4664
+ el.addEventListener("pointerleave", onLeave);
4665
+ el.addEventListener("focus", onFocus);
4666
+ el.addEventListener("blur", onBlur);
4667
+ if (win && typeof win.addEventListener === "function") {
4668
+ state.onResize = onResize;
4669
+ win.addEventListener("resize", state.onResize);
4670
+ state.onVisible = function() {
4671
+ if (doc.visibilityState === "visible") refreshCount();
4672
+ };
4673
+ win.addEventListener("visibilitychange", state.onVisible);
4674
+ }
4675
+ }
4676
+ function mount() {
4677
+ if (state.mounted || !doc) return state;
4678
+ injectStyles(doc);
4679
+ var root = doc.createElement("div");
4680
+ root.className = "wbm-float-root";
4681
+ root.setAttribute("data-message-float", "1");
4682
+ root.style.pointerEvents = "none";
4683
+ var btn = buttons.createButton({
4684
+ doc,
4685
+ lang: readLang(doc),
4686
+ onClick
4687
+ });
4688
+ root.appendChild(btn.el);
4689
+ state.root = root;
4690
+ state.btn = btn;
4691
+ state.mounted = true;
4692
+ place();
4693
+ liftAboveComposer();
4694
+ render();
4695
+ bind();
4696
+ if (notifier && typeof notifier.subscribe === "function") state.unsubscribe = notifier.subscribe(onEvent);
4697
+ loadConfig().then(function() {
4698
+ if (state.enabled) refreshCount();
4699
+ });
4700
+ return state;
4701
+ }
4702
+ function destroy() {
4703
+ if (state.unsubscribe) state.unsubscribe();
4704
+ state.unsubscribe = null;
4705
+ disarm();
4706
+ state.holdUntil = 0;
4707
+ detachWindowUp();
4708
+ if (win && typeof win.removeEventListener === "function") {
4709
+ if (state.onResize) win.removeEventListener("resize", state.onResize);
4710
+ if (state.onVisible) win.removeEventListener("visibilitychange", state.onVisible);
4711
+ }
4712
+ state.onResize = null;
4713
+ state.onVisible = null;
4714
+ if (state.btn) state.btn.destroy();
4715
+ if (state.root && state.root.parentNode) state.root.parentNode.removeChild(state.root);
4716
+ state.btn = null;
4717
+ state.root = null;
4718
+ state.mounted = false;
4719
+ }
4720
+ return {
4721
+ mount,
4722
+ destroy,
4723
+ refreshCount,
4724
+ applyConfig,
4725
+ readState: function() {
4726
+ return {
4727
+ mounted: state.mounted,
4728
+ count: state.count,
4729
+ enabled: state.enabled,
4730
+ position: state.corner,
4731
+ collapsed: state.collapsed,
4732
+ side: state.side,
4733
+ custom: state.hasCustom,
4734
+ customText: state.customText,
4735
+ idleSeconds: state.idleSeconds,
4736
+ edgeSnap: state.edgeSnap,
4737
+ seen: state.seen.size
4738
+ };
4739
+ }
4740
+ };
4741
+ }
4742
+ module2.exports = { createMount, STYLE_ID, DOMAIN, HOLD_MS };
4743
+ }
4744
+ });
4745
+
3865
4746
  // packages/addons/message/client/client.src.cjs
3866
4747
  (function() {
3867
4748
  var root = typeof window !== "undefined" ? window : null;
@@ -3883,6 +4764,7 @@ var require_actions = __commonJS({
3883
4764
  var DataView = require_data().DataView;
3884
4765
  var ActionSchemaView = require_actions().ActionSchemaView;
3885
4766
  var notifier = require_notifier();
4767
+ var floatMount = require_mount();
3886
4768
  var InboxView = inboxFactory({ React });
3887
4769
  var StatsView = statsFactory({ React });
3888
4770
  function langOf(props) {
@@ -3912,7 +4794,7 @@ var require_actions = __commonJS({
3912
4794
  ensureStyles();
3913
4795
  host.registerAddon({
3914
4796
  id: "wb-addon-message",
3915
- version: "0.1.3",
4797
+ version: "0.1.7",
3916
4798
  icon: ICONS["message-square"],
3917
4799
  views: [
3918
4800
  { id: "stats", icon: tabIcon("chart"), title: { zh: "\u7EDF\u8BA1", en: "Stats" }, component: Stats },
@@ -3927,6 +4809,11 @@ var require_actions = __commonJS({
3927
4809
  } catch (e) {
3928
4810
  if (typeof console !== "undefined") console.warn("[dsh-workbench-message] \u63D0\u793A\u97F3\u542F\u52A8\u5931\u8D25", e);
3929
4811
  }
4812
+ try {
4813
+ floatMount.createMount({ doc: typeof document !== "undefined" ? document : null, win: root, host, notifier }).mount();
4814
+ } catch (e) {
4815
+ if (typeof console !== "undefined") console.warn("[dsh-workbench-message] \u60AC\u6D6E\u5165\u53E3\u542F\u52A8\u5931\u8D25", e);
4816
+ }
3930
4817
  module.exports = {
3931
4818
  name: "dsh-workbench-message",
3932
4819
  inject: [],
package/lib/index.js CHANGED
@@ -82,7 +82,7 @@ export function apply(ctx) {
82
82
  id: "wb-addon-message",
83
83
  title: "消息",
84
84
  description: "统一消息入口:子插件与 agent 都能发消息,含未读计数、提示音与保留期清理;含统计、收件箱、配置、数据与 Action 五个视图",
85
- version: "0.1.3",
85
+ version: "0.1.7",
86
86
  category: "comm",
87
87
  tables: ["message"],
88
88
  // 只在本机保存:显式声明不同步任何表(不写 sync 时宿主默认按行同步)。
@@ -16,6 +16,7 @@ const GROUPS = [
16
16
  { id: "quiet", zh: "免打扰", en: "Quiet hours" },
17
17
  { id: "retention", zh: "保留期", en: "Retention" },
18
18
  { id: "list", zh: "列表", en: "List" },
19
+ { id: "float", zh: "悬浮入口", en: "Floating button" },
19
20
  ];
20
21
 
21
22
  const ITEMS = [
@@ -65,6 +66,36 @@ const ITEMS = [
65
66
  zh: "已读保留天数", en: "Keep read messages (days)",
66
67
  hintZh: "已读消息超过该天数自动清理;未读永不按时间清理,0 表示不按时间清理", hintEn: "Read messages older than this are pruned; unread never expires by time, 0 disables",
67
68
  },
69
+ {
70
+ id: "float.enabled", group: "float", type: "bool", surface: "ui", apply: "mount", default: true,
71
+ zh: "显示消息悬浮入口", en: "Show floating message button",
72
+ hintZh: "任意页面右下角常驻消息按钮,带未读角标;关闭后该按钮立即隐藏", hintEn: "A persistent message button in the corner with unread badge; turning it off hides it",
73
+ },
74
+ {
75
+ id: "float.position", group: "float", type: "enum", surface: "ui", apply: "mount", default: "bottom-right",
76
+ zh: "悬浮入口位置", en: "Floating position",
77
+ hintZh: "右下角默认避开输入区;与其它浮层冲突时可换到左下角", hintEn: "Bottom right avoids the input area; switch to bottom left when it collides",
78
+ values: [
79
+ { value: "bottom-right", zh: "右下角", en: "Bottom right" },
80
+ { value: "bottom-left", zh: "左下角", en: "Bottom left" },
81
+ ],
82
+ },
83
+ {
84
+ id: "float.customPos", group: "float", type: "string", surface: "ui", apply: "mount", default: "", maxLength: 32,
85
+ zh: "自定义位置", en: "Custom position",
86
+ hintZh: "拖拽后自动写入「rx,ry」归一化中心;清空即回到默认角,一般无需手改",
87
+ hintEn: "Written after a drag as normalized center \"rx,ry\"; clear it to return to the default corner",
88
+ },
89
+ {
90
+ id: "float.idleSeconds", group: "float", type: "int", surface: "ui", apply: "mount", default: 3, min: 0, max: 60,
91
+ zh: "空闲多久贴边收起(秒)", en: "Idle seconds before edge collapse",
92
+ hintZh: "0 表示不自动收起;只在按钮靠近左右边缘时生效", hintEn: "0 disables; only applies near the left or right edge",
93
+ },
94
+ {
95
+ id: "float.edgeSnap", group: "float", type: "bool", surface: "ui", apply: "mount", default: true,
96
+ zh: "靠近边缘自动半隐藏", en: "Auto collapse at the edge",
97
+ hintZh: "关闭后空闲也不会贴边,按钮始终完整显示", hintEn: "When off the button never collapses at the edge",
98
+ },
68
99
  {
69
100
  id: "list.pageSize", group: "list", type: "enum", surface: "ui", apply: "mount", default: 20,
70
101
  zh: "每页条数", en: "Page size",
@@ -248,7 +279,7 @@ export function resetConfig(db, ids) {
248
279
  export function registerConfigActions(api) {
249
280
  const action = api.action;
250
281
  action("message.configGet", {
251
- description: "只读:消息插件的配置项定义、当前值与覆盖项(含提示音、免打扰、保留期、列表分页)",
282
+ description: "只读:消息插件的配置项定义、当前值与覆盖项(含提示音、免打扰、保留期、悬浮入口与列表分页)",
252
283
  input: { type: "object", properties: {}, additionalProperties: false },
253
284
  execute: () => configState(api.db),
254
285
  render: (r) =>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-workbench-message",
3
- "version": "0.1.3",
3
+ "version": "0.1.7",
4
4
  "description": "个人工作台消息插件:统一消息发送入口、收件箱、未读统计与提示音",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -16,7 +16,7 @@
16
16
  "id": "wb-addon-message",
17
17
  "title": "消息",
18
18
  "description": "统一消息入口 + 统计/收件箱/配置/数据四个视图:子插件与 agent 都能发消息,带未读计数与提示音",
19
- "version": "0.1.3",
19
+ "version": "0.1.7",
20
20
  "minShell": "0.8.0",
21
21
  "tables": [
22
22
  "message"
@@ -49,7 +49,7 @@
49
49
  "./package.json": "./package.json"
50
50
  },
51
51
  "dependencies": {
52
- "dsh-workbench-host": "^0.8.2"
52
+ "dsh-workbench-host": "^0.8.4"
53
53
  },
54
54
  "dsh": {
55
55
  "bundle": {