@xmanrui/dsh-im 5.1.0 → 5.3.0
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/README.en.md +10 -8
- package/README.md +10 -8
- package/docs/client-integration.md +16 -4
- package/lib/client.js +422 -107
- package/lib/index.js +323 -321
- package/package.json +1 -1
- package/plugin-src/client/connection-error.js +2 -1
- package/plugin-src/client/global-settings.js +2 -1
- package/plugin-src/client/i18n.js +8 -0
- package/plugin-src/client/index.js +41 -18
- package/plugin-src/client/plugin-page.js +47 -2
- package/plugin-src/client/sidebar-settings.js +129 -0
- package/plugin-src/client/styles.js +9 -0
- package/plugin-src/host/channels/dingtalk/rpc.mjs +5 -1
- package/plugin-src/host/channels/feishu/rpc.mjs +5 -1
- package/plugin-src/host/channels/qq/rpc.mjs +5 -1
- package/plugin-src/host/channels/wecom/rpc.mjs +5 -1
- package/plugin-src/host/channels/weixin/rpc.mjs +3 -2
- package/plugin-src/host/channels/whatsapp/rpc.mjs +5 -1
- package/plugin-src/host/index.mjs +7 -0
- package/plugin-src/host/sidebar-settings.mjs +113 -0
- package/src/channels/imessage/imessage-api.mjs +67 -2
- package/src/channels/shared/connection-error.mjs +5 -5
- package/src/channels/shared/diagnostic-details.mjs +15 -1
- package/src/channels/shared/harness-client.mjs +6 -1
- package/src/channels/shared/i18n-en/diagnostics.mjs +5 -0
- package/src/channels/shared/qr-encoding-error.mjs +39 -0
- package/src/channels/wecom/wecom-runtime.mjs +8 -1
- package/src/channels/weixin/connection-error.mjs +1 -0
- package/src/channels/weixin/weixin-api.mjs +21 -2
package/lib/client.js
CHANGED
|
@@ -590,12 +590,12 @@ async function callManagementRpc(connection, channel7, method, payload, signal)
|
|
|
590
590
|
}
|
|
591
591
|
|
|
592
592
|
// plugin-src/client/index.js
|
|
593
|
-
var
|
|
593
|
+
var React42 = __toESM(require("react"), 1);
|
|
594
594
|
|
|
595
595
|
// package.json
|
|
596
596
|
var package_default = {
|
|
597
597
|
name: "@xmanrui/dsh-im",
|
|
598
|
-
version: "5.
|
|
598
|
+
version: "5.3.0",
|
|
599
599
|
icon: "./assets/logo-plugin-message-link-gradient.webp",
|
|
600
600
|
description: "\u628A\u5FAE\u4FE1\u3001\u98DE\u4E66\u3001\u4F01\u5FAE\u3001\u9489\u9489\u3001QQ\u3001Telegram\u3001WhatsApp\u3001Slack\u3001Discord\u3001Matrix\u63A5\u5165DSH\u3002 Connect Telegram, WhatsApp, Slack, Discord, Matrix, WeChat, Feishu, WeCom, DingTalk, and QQ to DSH.",
|
|
601
601
|
keywords: [
|
|
@@ -963,6 +963,10 @@ var image_input_default = {
|
|
|
963
963
|
|
|
964
964
|
// src/channels/shared/i18n-en/diagnostics.mjs
|
|
965
965
|
var diagnostics_default = Object.freeze({
|
|
966
|
+
"\u5F02\u5E38\u7C7B\u578B": "Exception types",
|
|
967
|
+
"\u4E8C\u7EF4\u7801\u7F16\u7801\u5668": "QR encoder",
|
|
968
|
+
"\u4E8C\u7EF4\u7801\u56FE\u7247\u683C\u5F0F": "QR image format",
|
|
969
|
+
"\u672C\u673A\u4E8C\u7EF4\u7801\u56FE\u7247\u751F\u6210\u5931\u8D25\uFF0C\u8BF7\u91CD\u8BD5\uFF1B\u82E5\u6301\u7EED\u5931\u8D25\uFF0C\u8BF7\u590D\u5236\u8BCA\u65AD\u4FE1\u606F\u5E76\u68C0\u67E5 DSH \u8FD0\u884C\u73AF\u5883\u3002": "The QR-code image could not be generated locally. Retry; if it keeps failing, copy the diagnostics and check the DSH runtime environment.",
|
|
966
970
|
"\u51C6\u5907\u4F1A\u8BDD": "Prepare session",
|
|
967
971
|
"\u51C6\u5907\u6D88\u606F": "Prepare message",
|
|
968
972
|
"\u5EFA\u7ACB\u4EA4\u4E92\u901A\u9053": "Open interaction channel",
|
|
@@ -1184,6 +1188,14 @@ var EN = Object.freeze({
|
|
|
1184
1188
|
...diagnostics_default,
|
|
1185
1189
|
...image_input_default,
|
|
1186
1190
|
"$locale": "en",
|
|
1191
|
+
"\u4FA7\u8FB9\u680F\u5165\u53E3": "Sidebar entry",
|
|
1192
|
+
"\u81EA\u52A8\u6A21\u5F0F\uFF1A\u672A\u914D\u7F6E\u6E20\u9053\u65F6\u663E\u793A\uFF0C\u914D\u7F6E\u81F3\u5C11\u4E00\u4E2A\u6E20\u9053\u540E\u9690\u85CF\u3002\u9690\u85CF\u540E\u4ECD\u53EF\u4ECE\u63D2\u4EF6\u8BE6\u60C5\u6216\u8BBE\u7F6E\u8FDB\u5165\uFF0C\u4E0D\u5F71\u54CD\u673A\u5668\u4EBA\u540E\u53F0\u8FD0\u884C\u3002": "Automatic: show before any channel is configured, then hide. Plugin details and Settings remain available; bots keep running in the background.",
|
|
1193
|
+
"\u81EA\u52A8\u9690\u85CF": "Auto-hide",
|
|
1194
|
+
"\u59CB\u7EC8\u663E\u793A": "Always show",
|
|
1195
|
+
"\u59CB\u7EC8\u9690\u85CF": "Always hide",
|
|
1196
|
+
"\u6B63\u5728\u8BFB\u53D6\u4FA7\u8FB9\u680F\u8BBE\u7F6E\u2026": "Loading sidebar settings\u2026",
|
|
1197
|
+
"\u65E0\u6CD5\u8BFB\u53D6\u6216\u4FDD\u5B58\u4FA7\u8FB9\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002": "Unable to read or save sidebar settings. Try again.",
|
|
1198
|
+
"\u4FA7\u8FB9\u680F\u8BBE\u7F6E\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u54CD\u5E94\u3002": "Unrecognized sidebar settings response.",
|
|
1187
1199
|
"\u4FDD\u6301\u672C\u9875\u6253\u5F00\uFF0C\u7B49\u5F85\u6743\u9650\u751F\u6548": "Keep this page open while the permission takes effect",
|
|
1188
1200
|
"\u7FA4\u804A\u5929\u8BB0\u5F55": "Group chat history",
|
|
1189
1201
|
"\u7FA4\u804A\u5929\u8BB0\u5F55\u4FDD\u7559\u5929\u6570": "Group chat retention (days)",
|
|
@@ -2635,6 +2647,20 @@ var REASONS = /* @__PURE__ */ new Set([
|
|
|
2635
2647
|
"EMFILE",
|
|
2636
2648
|
"ENFILE",
|
|
2637
2649
|
"EEXIST",
|
|
2650
|
+
"ERR_INVALID_ARG_TYPE",
|
|
2651
|
+
"ERR_INVALID_ARG_VALUE",
|
|
2652
|
+
"ERR_OUT_OF_RANGE",
|
|
2653
|
+
"ERR_BUFFER_OUT_OF_BOUNDS",
|
|
2654
|
+
"ERR_ZLIB_INITIALIZATION_FAILED",
|
|
2655
|
+
"ERR_STREAM_DESTROYED",
|
|
2656
|
+
"ERR_STREAM_PREMATURE_CLOSE",
|
|
2657
|
+
"Z_STREAM_ERROR",
|
|
2658
|
+
"Z_DATA_ERROR",
|
|
2659
|
+
"Z_MEM_ERROR",
|
|
2660
|
+
"Z_BUF_ERROR",
|
|
2661
|
+
"Z_VERSION_ERROR",
|
|
2662
|
+
"MODULE_NOT_FOUND",
|
|
2663
|
+
"ERR_MODULE_NOT_FOUND",
|
|
2638
2664
|
"unknown",
|
|
2639
2665
|
"multiple-causes",
|
|
2640
2666
|
"timeout",
|
|
@@ -2671,6 +2697,18 @@ var RPC_METHODS = /* @__PURE__ */ new Set([
|
|
|
2671
2697
|
var TRANSPORTS = /* @__PURE__ */ new Set(["host-api", "http", "websocket"]);
|
|
2672
2698
|
var SUBMISSION_STATES = /* @__PURE__ */ new Set(["not-submitted", "accepted", "unknown"]);
|
|
2673
2699
|
var CONFIG_FILES = /* @__PURE__ */ new Set(["config.json", "workspaces.json"]);
|
|
2700
|
+
var DIAGNOSTIC_ERROR_TYPES = /* @__PURE__ */ new Set([
|
|
2701
|
+
"Error",
|
|
2702
|
+
"TypeError",
|
|
2703
|
+
"RangeError",
|
|
2704
|
+
"ReferenceError",
|
|
2705
|
+
"SyntaxError",
|
|
2706
|
+
"AggregateError",
|
|
2707
|
+
"DOMException",
|
|
2708
|
+
"AxiosError",
|
|
2709
|
+
"TimeoutError",
|
|
2710
|
+
"AbortError"
|
|
2711
|
+
]);
|
|
2674
2712
|
var CONFIG_ISSUE_LABELS = Object.freeze({
|
|
2675
2713
|
"expected-object": "\u5E94\u4E3A JSON \u5BF9\u8C61\u3002",
|
|
2676
2714
|
"expected-array": "\u5E94\u4E3A JSON \u6570\u7EC4\u3002",
|
|
@@ -2695,6 +2733,12 @@ function normalizeDiagnosticDetails(value) {
|
|
|
2695
2733
|
if (allowed.has(value[field2])) result2[field2] = value[field2];
|
|
2696
2734
|
}
|
|
2697
2735
|
if (DIAGNOSTIC_CHANNELS.includes(value.channel)) result2.channel = value.channel;
|
|
2736
|
+
if (Array.isArray(value.errorTypes)) {
|
|
2737
|
+
const errorTypes = [...new Set(value.errorTypes.filter((type) => DIAGNOSTIC_ERROR_TYPES.has(type)))];
|
|
2738
|
+
if (errorTypes.length) result2.errorTypes = errorTypes;
|
|
2739
|
+
}
|
|
2740
|
+
if (value.qrEncoder === "qrcode") result2.qrEncoder = value.qrEncoder;
|
|
2741
|
+
if (value.qrRenderer === "png") result2.qrRenderer = value.qrRenderer;
|
|
2698
2742
|
if (Array.isArray(value.reasons)) {
|
|
2699
2743
|
const reasons = [...new Set(value.reasons.filter((v) => REASONS.has(v) && !["unknown", "multiple-causes"].includes(v)))].slice(0, 16);
|
|
2700
2744
|
if (reasons.length) result2.reasons = reasons;
|
|
@@ -2706,7 +2750,7 @@ function normalizeDiagnosticDetails(value) {
|
|
|
2706
2750
|
if (["ilinkai.weixin.qq.com", "oapi.dingtalk.com", "api.dingtalk.com", "api.telegram.org", "discord.com", "slack.com", "open.feishu.cn", "qyapi.weixin.qq.com"].includes(value.host)) result2.host = value.host;
|
|
2707
2751
|
if (value.dependencies && typeof value.dependencies === "object") {
|
|
2708
2752
|
const dependencies = {};
|
|
2709
|
-
for (const name2 of ["dingtalkStream", "axios", "httpsProxyAgent", "agentBase"]) {
|
|
2753
|
+
for (const name2 of ["dingtalkStream", "axios", "httpsProxyAgent", "agentBase", "qrcode", "pngjs", "zlib"]) {
|
|
2710
2754
|
const version = value.dependencies[name2];
|
|
2711
2755
|
if (typeof version === "string" && /^\d+\.\d+\.\d+(?:[-+][A-Za-z0-9.-]+)?$/.test(version) && version.length <= 80) dependencies[name2] = version;
|
|
2712
2756
|
}
|
|
@@ -2799,7 +2843,7 @@ function formatConnectionDiagnostic(value) {
|
|
|
2799
2843
|
localizeText(error.message),
|
|
2800
2844
|
details.hint ? localizeText(details.hint) : null,
|
|
2801
2845
|
localizeText("\u9519\u8BEF\u7801") + ": " + error.code,
|
|
2802
|
-
...["channel", "operation", "stage", "method", "transport", "submissionState", "attempts", "lastFailureReason", "reason", "reasons", "host", "durationMs", "timeoutMs", "nodeVersion", "dshVersion", "platform", "dependencies", "proxyConfigured", "truncated", "httpStatus", "providerCode", "resource", "file", "field", "issue", "referenceId", "occurredAt", "rollback", "pluginVersion"].filter((field2) => details[field2] !== void 0).map((field2) => `${field2}: ${typeof details[field2] === "object" ? JSON.stringify(details[field2]) : details[field2]}`)
|
|
2846
|
+
...["channel", "operation", "stage", "method", "transport", "submissionState", "attempts", "lastFailureReason", "reason", "reasons", "errorTypes", "qrEncoder", "qrRenderer", "host", "durationMs", "timeoutMs", "nodeVersion", "dshVersion", "platform", "dependencies", "proxyConfigured", "truncated", "httpStatus", "providerCode", "resource", "file", "field", "issue", "referenceId", "occurredAt", "rollback", "pluginVersion"].filter((field2) => details[field2] !== void 0).map((field2) => `${field2}: ${typeof details[field2] === "object" ? JSON.stringify(details[field2]) : details[field2]}`)
|
|
2803
2847
|
].filter(Boolean).join("\n");
|
|
2804
2848
|
}
|
|
2805
2849
|
function ConnectionError({ error: value, warning = false, showMessage = true }) {
|
|
@@ -2824,6 +2868,9 @@ function ConnectionError({ error: value, warning = false, showMessage = true })
|
|
|
2824
2868
|
["\u8C03\u7528\u65B9\u5F0F", details.transport === "host-api" ? localizeText("\u5BBF\u4E3B API\uFF08\u8FDB\u7A0B\u5185\uFF09") : details.transport === "http" ? "HTTP" : details.transport === "websocket" ? "WebSocket" : void 0],
|
|
2825
2869
|
["\u6D88\u606F\u63D0\u4EA4\u72B6\u6001", localizeText(SUBMISSION_LABELS[details.submissionState] ?? "")],
|
|
2826
2870
|
["\u8FDE\u63A5\u5C1D\u8BD5\u6B21\u6570", details.attempts],
|
|
2871
|
+
["\u5F02\u5E38\u7C7B\u578B", details.errorTypes?.join(", ")],
|
|
2872
|
+
["\u4E8C\u7EF4\u7801\u7F16\u7801\u5668", details.qrEncoder],
|
|
2873
|
+
["\u4E8C\u7EF4\u7801\u56FE\u7247\u683C\u5F0F", details.qrRenderer],
|
|
2827
2874
|
["\u6700\u8FD1\u4E00\u6B21\u8FDE\u63A5\u5931\u8D25", localizeText(STREAM_REASON_LABELS[details.lastFailureReason] ?? details.lastFailureReason ?? "")],
|
|
2828
2875
|
["\u5E95\u5C42\u539F\u56E0", details.reason === "unknown" ? localizeText("\u6682\u672A\u8BC6\u522B") : details.reason],
|
|
2829
2876
|
["\u591A\u4E2A\u539F\u56E0", details.reasons?.join(", ")],
|
|
@@ -19123,8 +19170,194 @@ function GroupHistorySettings({ rpcCall }) {
|
|
|
19123
19170
|
);
|
|
19124
19171
|
}
|
|
19125
19172
|
|
|
19126
|
-
// plugin-src/client/
|
|
19173
|
+
// plugin-src/client/sidebar-settings.js
|
|
19127
19174
|
var React37 = __toESM(require("react"), 1);
|
|
19175
|
+
var SIDEBAR_SETTINGS_RPC_CHANNEL = "/dsh-im-sidebar";
|
|
19176
|
+
var SIDEBAR_SETTINGS_ENDPOINTS = Object.freeze({
|
|
19177
|
+
get: "settings.sidebar-entry.get",
|
|
19178
|
+
set: "settings.sidebar-entry.set"
|
|
19179
|
+
});
|
|
19180
|
+
function settingsResult(result2) {
|
|
19181
|
+
if (result2?.ok === false) throw new Error(result2.error?.message || "\u65E0\u6CD5\u8BFB\u53D6\u6216\u4FDD\u5B58\u4FA7\u8FB9\u680F\u8BBE\u7F6E\uFF0C\u8BF7\u7A0D\u540E\u91CD\u8BD5\u3002");
|
|
19182
|
+
const value = result2?.ok === true ? result2.value : result2;
|
|
19183
|
+
if (!["auto", "show", "hide"].includes(value?.mode) || typeof value.visible !== "boolean") {
|
|
19184
|
+
throw new Error("\u4FA7\u8FB9\u680F\u8BBE\u7F6E\u8FD4\u56DE\u4E86\u65E0\u6CD5\u8BC6\u522B\u7684\u54CD\u5E94\u3002");
|
|
19185
|
+
}
|
|
19186
|
+
return value;
|
|
19187
|
+
}
|
|
19188
|
+
function installSidebarVisibilitySync({
|
|
19189
|
+
rpcCall,
|
|
19190
|
+
setVisible,
|
|
19191
|
+
setTimeoutFn = globalThis.setTimeout,
|
|
19192
|
+
clearTimeoutFn = globalThis.clearTimeout,
|
|
19193
|
+
pollMs = 3e4
|
|
19194
|
+
}) {
|
|
19195
|
+
const abort = new AbortController();
|
|
19196
|
+
let timer;
|
|
19197
|
+
let running = false;
|
|
19198
|
+
let pending = false;
|
|
19199
|
+
let revision = 0;
|
|
19200
|
+
const schedule = (delay) => {
|
|
19201
|
+
clearTimeoutFn(timer);
|
|
19202
|
+
if (!abort.signal.aborted) timer = setTimeoutFn(refresh, delay);
|
|
19203
|
+
};
|
|
19204
|
+
const refresh = async () => {
|
|
19205
|
+
if (abort.signal.aborted) return;
|
|
19206
|
+
if (running) {
|
|
19207
|
+
pending = true;
|
|
19208
|
+
return;
|
|
19209
|
+
}
|
|
19210
|
+
running = true;
|
|
19211
|
+
pending = false;
|
|
19212
|
+
const current = revision;
|
|
19213
|
+
try {
|
|
19214
|
+
const value = settingsResult(await rpcCall(SIDEBAR_SETTINGS_ENDPOINTS.get, {}, abort.signal));
|
|
19215
|
+
if (!abort.signal.aborted && current === revision && !pending) setVisible(value.visible);
|
|
19216
|
+
} catch {
|
|
19217
|
+
} finally {
|
|
19218
|
+
running = false;
|
|
19219
|
+
schedule(pending ? 0 : pollMs);
|
|
19220
|
+
}
|
|
19221
|
+
};
|
|
19222
|
+
void refresh();
|
|
19223
|
+
return {
|
|
19224
|
+
refresh() {
|
|
19225
|
+
revision++;
|
|
19226
|
+
if (running) pending = true;
|
|
19227
|
+
else schedule(0);
|
|
19228
|
+
},
|
|
19229
|
+
apply(value) {
|
|
19230
|
+
revision++;
|
|
19231
|
+
if (!abort.signal.aborted) setVisible(settingsResult(value).visible);
|
|
19232
|
+
},
|
|
19233
|
+
dispose() {
|
|
19234
|
+
abort.abort();
|
|
19235
|
+
clearTimeoutFn(timer);
|
|
19236
|
+
}
|
|
19237
|
+
};
|
|
19238
|
+
}
|
|
19239
|
+
function SidebarSettings({ rpcCall }) {
|
|
19240
|
+
const [mode, setMode] = React37.useState("auto");
|
|
19241
|
+
const [phase, setPhase] = React37.useState("loading");
|
|
19242
|
+
const [error, setError] = React37.useState(null);
|
|
19243
|
+
const [saved, setSaved] = React37.useState(false);
|
|
19244
|
+
const mounted = React37.useRef(false);
|
|
19245
|
+
const busy = React37.useRef(false);
|
|
19246
|
+
const failedMode = React37.useRef(null);
|
|
19247
|
+
const id6 = React37.useId();
|
|
19248
|
+
const disabled = phase === "loading" || phase === "saving";
|
|
19249
|
+
const load = React37.useCallback(async (signal) => {
|
|
19250
|
+
setPhase("loading");
|
|
19251
|
+
setError(null);
|
|
19252
|
+
setSaved(false);
|
|
19253
|
+
failedMode.current = null;
|
|
19254
|
+
try {
|
|
19255
|
+
const value = settingsResult(await rpcCall(SIDEBAR_SETTINGS_ENDPOINTS.get, {}, signal));
|
|
19256
|
+
if (signal?.aborted || !mounted.current) return;
|
|
19257
|
+
setMode(value.mode);
|
|
19258
|
+
setPhase("ready");
|
|
19259
|
+
} catch (caught) {
|
|
19260
|
+
if (signal?.aborted || !mounted.current) return;
|
|
19261
|
+
setError(caught.message);
|
|
19262
|
+
setPhase("error");
|
|
19263
|
+
}
|
|
19264
|
+
}, [rpcCall]);
|
|
19265
|
+
React37.useEffect(() => {
|
|
19266
|
+
mounted.current = true;
|
|
19267
|
+
const abort = new AbortController();
|
|
19268
|
+
void load(abort.signal);
|
|
19269
|
+
return () => {
|
|
19270
|
+
mounted.current = false;
|
|
19271
|
+
abort.abort();
|
|
19272
|
+
};
|
|
19273
|
+
}, [load]);
|
|
19274
|
+
const save = async (nextMode) => {
|
|
19275
|
+
if (busy.current || disabled) return;
|
|
19276
|
+
const previousMode = mode;
|
|
19277
|
+
busy.current = true;
|
|
19278
|
+
setPhase("saving");
|
|
19279
|
+
setError(null);
|
|
19280
|
+
setSaved(false);
|
|
19281
|
+
setMode(nextMode);
|
|
19282
|
+
failedMode.current = null;
|
|
19283
|
+
try {
|
|
19284
|
+
const value = settingsResult(await rpcCall(SIDEBAR_SETTINGS_ENDPOINTS.set, { mode: nextMode }));
|
|
19285
|
+
if (mounted.current) {
|
|
19286
|
+
setMode(value.mode);
|
|
19287
|
+
setSaved(true);
|
|
19288
|
+
setPhase("ready");
|
|
19289
|
+
}
|
|
19290
|
+
} catch (caught) {
|
|
19291
|
+
if (mounted.current) {
|
|
19292
|
+
failedMode.current = nextMode;
|
|
19293
|
+
setMode(previousMode);
|
|
19294
|
+
setError(caught.message);
|
|
19295
|
+
setPhase("error");
|
|
19296
|
+
}
|
|
19297
|
+
} finally {
|
|
19298
|
+
busy.current = false;
|
|
19299
|
+
}
|
|
19300
|
+
};
|
|
19301
|
+
return h2(
|
|
19302
|
+
"section",
|
|
19303
|
+
{ className: "dim-botGeneralSettings dim-sidebarSettings", "aria-label": "\u4FA7\u8FB9\u680F\u5165\u53E3", "aria-busy": disabled },
|
|
19304
|
+
h2(
|
|
19305
|
+
"div",
|
|
19306
|
+
{ className: "dim-botGeneralRow" },
|
|
19307
|
+
h2(
|
|
19308
|
+
"div",
|
|
19309
|
+
{ className: "dim-botGeneralText" },
|
|
19310
|
+
h2(
|
|
19311
|
+
"div",
|
|
19312
|
+
{ className: "dim-sidebarHeading" },
|
|
19313
|
+
h2("label", { className: "dim-botGeneralTitle", htmlFor: id6 }, "\u4FA7\u8FB9\u680F\u5165\u53E3"),
|
|
19314
|
+
h2(
|
|
19315
|
+
"span",
|
|
19316
|
+
{ role: "status", className: "dim-botGeneralHelp" },
|
|
19317
|
+
phase === "loading" ? "\u6B63\u5728\u8BFB\u53D6\u4FA7\u8FB9\u680F\u8BBE\u7F6E\u2026" : phase === "saving" ? "\u4FDD\u5B58\u4E2D\u2026" : saved ? "\u5DF2\u4FDD\u5B58" : ""
|
|
19318
|
+
)
|
|
19319
|
+
),
|
|
19320
|
+
h2("p", { className: "dim-botGeneralHelp", id: `${id6}-help` }, "\u81EA\u52A8\u6A21\u5F0F\uFF1A\u672A\u914D\u7F6E\u6E20\u9053\u65F6\u663E\u793A\uFF0C\u914D\u7F6E\u81F3\u5C11\u4E00\u4E2A\u6E20\u9053\u540E\u9690\u85CF\u3002\u9690\u85CF\u540E\u4ECD\u53EF\u4ECE\u63D2\u4EF6\u8BE6\u60C5\u6216\u8BBE\u7F6E\u8FDB\u5165\uFF0C\u4E0D\u5F71\u54CD\u673A\u5668\u4EBA\u540E\u53F0\u8FD0\u884C\u3002")
|
|
19321
|
+
),
|
|
19322
|
+
h2(
|
|
19323
|
+
"div",
|
|
19324
|
+
{ className: "dim-botGeneralControl" },
|
|
19325
|
+
h2(
|
|
19326
|
+
"select",
|
|
19327
|
+
{
|
|
19328
|
+
id: id6,
|
|
19329
|
+
className: "dim-sidebarSelect",
|
|
19330
|
+
value: mode,
|
|
19331
|
+
disabled,
|
|
19332
|
+
"aria-describedby": `${id6}-help`,
|
|
19333
|
+
onChange: (event) => save(event.target.value)
|
|
19334
|
+
},
|
|
19335
|
+
h2("option", { value: "auto" }, "\u81EA\u52A8\u9690\u85CF"),
|
|
19336
|
+
h2("option", { value: "show" }, "\u59CB\u7EC8\u663E\u793A"),
|
|
19337
|
+
h2("option", { value: "hide" }, "\u59CB\u7EC8\u9690\u85CF")
|
|
19338
|
+
),
|
|
19339
|
+
h2(
|
|
19340
|
+
"svg",
|
|
19341
|
+
{ width: 16, height: 16, viewBox: "0 0 16 16", "aria-hidden": true },
|
|
19342
|
+
h2("path", { d: "m4 6 4 4 4-4", fill: "none", stroke: "currentColor", strokeWidth: 1.5 })
|
|
19343
|
+
)
|
|
19344
|
+
)
|
|
19345
|
+
),
|
|
19346
|
+
error ? h2(
|
|
19347
|
+
"div",
|
|
19348
|
+
{ className: "dim-sidebarFeedback" },
|
|
19349
|
+
h2("p", { role: "alert", className: "dim-accessFeedback", "data-tone": "error" }, error),
|
|
19350
|
+
h2("button", {
|
|
19351
|
+
type: "button",
|
|
19352
|
+
className: "dim-deliveryButton",
|
|
19353
|
+
onClick: () => failedMode.current === null ? load() : save(failedMode.current)
|
|
19354
|
+
}, "\u91CD\u8BD5")
|
|
19355
|
+
) : null
|
|
19356
|
+
);
|
|
19357
|
+
}
|
|
19358
|
+
|
|
19359
|
+
// plugin-src/client/global-settings.js
|
|
19360
|
+
var React38 = __toESM(require("react"), 1);
|
|
19128
19361
|
|
|
19129
19362
|
// src/channels/shared/inbound-ttl.mjs
|
|
19130
19363
|
var DEFAULT_INBOUND_TTL_HOURS = 168;
|
|
@@ -19209,14 +19442,14 @@ function GlobalButton({ children, kind = "secondary", className = "", ...props }
|
|
|
19209
19442
|
}, children);
|
|
19210
19443
|
}
|
|
19211
19444
|
function ImageInputSettings({ rpcCall }) {
|
|
19212
|
-
const [values, setValues] =
|
|
19213
|
-
const [phase, setPhase] =
|
|
19214
|
-
const [error, setError] =
|
|
19215
|
-
const [saved, setSaved] =
|
|
19216
|
-
const mounted =
|
|
19217
|
-
const saving =
|
|
19218
|
-
const id6 =
|
|
19219
|
-
const load =
|
|
19445
|
+
const [values, setValues] = React38.useState(DEFAULT_IMAGE_INPUT_SETTINGS);
|
|
19446
|
+
const [phase, setPhase] = React38.useState("loading");
|
|
19447
|
+
const [error, setError] = React38.useState(null);
|
|
19448
|
+
const [saved, setSaved] = React38.useState(false);
|
|
19449
|
+
const mounted = React38.useRef(false);
|
|
19450
|
+
const saving = React38.useRef(false);
|
|
19451
|
+
const id6 = React38.useId();
|
|
19452
|
+
const load = React38.useCallback(async (signal) => {
|
|
19220
19453
|
setPhase("loading");
|
|
19221
19454
|
setError(null);
|
|
19222
19455
|
try {
|
|
@@ -19232,7 +19465,7 @@ function ImageInputSettings({ rpcCall }) {
|
|
|
19232
19465
|
setPhase("error");
|
|
19233
19466
|
}
|
|
19234
19467
|
}, [rpcCall]);
|
|
19235
|
-
|
|
19468
|
+
React38.useEffect(() => {
|
|
19236
19469
|
mounted.current = true;
|
|
19237
19470
|
const controller = new AbortController();
|
|
19238
19471
|
void load(controller.signal);
|
|
@@ -19339,29 +19572,29 @@ function ImageInputSettings({ rpcCall }) {
|
|
|
19339
19572
|
);
|
|
19340
19573
|
}
|
|
19341
19574
|
function AttachmentSettingsPanel({ rpcCall }) {
|
|
19342
|
-
const [phase, setPhase] =
|
|
19343
|
-
const [loadError, setLoadError] =
|
|
19344
|
-
const [ttlInput, setTtlInput] =
|
|
19345
|
-
const [savedTtl, setSavedTtl] =
|
|
19346
|
-
const [ttlError, setTtlError] =
|
|
19347
|
-
const [saveError, setSaveError] =
|
|
19348
|
-
const [saveSucceeded, setSaveSucceeded] =
|
|
19349
|
-
const [isSaving, setIsSaving] =
|
|
19350
|
-
const [sweepConfirming, setSweepConfirming] =
|
|
19351
|
-
const [sweeping, setSweeping] =
|
|
19352
|
-
const ttlErrorId =
|
|
19353
|
-
const ttlHintsId =
|
|
19354
|
-
const sweepTriggerId =
|
|
19355
|
-
const sweepConfirmId =
|
|
19356
|
-
const sweepConfirmTextId =
|
|
19357
|
-
const sweepConfirmButtonId =
|
|
19358
|
-
const mounted =
|
|
19359
|
-
const saving =
|
|
19360
|
-
const invoke =
|
|
19575
|
+
const [phase, setPhase] = React38.useState("loading");
|
|
19576
|
+
const [loadError, setLoadError] = React38.useState(null);
|
|
19577
|
+
const [ttlInput, setTtlInput] = React38.useState("");
|
|
19578
|
+
const [savedTtl, setSavedTtl] = React38.useState(null);
|
|
19579
|
+
const [ttlError, setTtlError] = React38.useState(false);
|
|
19580
|
+
const [saveError, setSaveError] = React38.useState(null);
|
|
19581
|
+
const [saveSucceeded, setSaveSucceeded] = React38.useState(false);
|
|
19582
|
+
const [isSaving, setIsSaving] = React38.useState(false);
|
|
19583
|
+
const [sweepConfirming, setSweepConfirming] = React38.useState(false);
|
|
19584
|
+
const [sweeping, setSweeping] = React38.useState(false);
|
|
19585
|
+
const ttlErrorId = React38.useId();
|
|
19586
|
+
const ttlHintsId = React38.useId();
|
|
19587
|
+
const sweepTriggerId = React38.useId();
|
|
19588
|
+
const sweepConfirmId = React38.useId();
|
|
19589
|
+
const sweepConfirmTextId = React38.useId();
|
|
19590
|
+
const sweepConfirmButtonId = React38.useId();
|
|
19591
|
+
const mounted = React38.useRef(true);
|
|
19592
|
+
const saving = React38.useRef(false);
|
|
19593
|
+
const invoke = React38.useCallback(async (endpoint, payload = {}, signal) => {
|
|
19361
19594
|
if (typeof rpcCall !== "function") throw new Error("\u901A\u7528\u8BBE\u7F6E\u6682\u4E0D\u53EF\u7528\u3002");
|
|
19362
19595
|
return unwrapRpcResult16(await rpcCall(endpoint, payload, signal));
|
|
19363
19596
|
}, [rpcCall]);
|
|
19364
|
-
const loadSettings =
|
|
19597
|
+
const loadSettings = React38.useCallback(async ({ signal } = {}) => {
|
|
19365
19598
|
setPhase("loading");
|
|
19366
19599
|
setLoadError(null);
|
|
19367
19600
|
try {
|
|
@@ -19385,7 +19618,7 @@ function AttachmentSettingsPanel({ rpcCall }) {
|
|
|
19385
19618
|
setPhase("error");
|
|
19386
19619
|
}
|
|
19387
19620
|
}, [invoke]);
|
|
19388
|
-
|
|
19621
|
+
React38.useEffect(() => {
|
|
19389
19622
|
mounted.current = true;
|
|
19390
19623
|
const controller = new AbortController();
|
|
19391
19624
|
void loadSettings({ signal: controller.signal });
|
|
@@ -19394,7 +19627,7 @@ function AttachmentSettingsPanel({ rpcCall }) {
|
|
|
19394
19627
|
controller.abort();
|
|
19395
19628
|
};
|
|
19396
19629
|
}, [loadSettings]);
|
|
19397
|
-
|
|
19630
|
+
React38.useEffect(() => {
|
|
19398
19631
|
if (!sweepConfirming) return;
|
|
19399
19632
|
globalThis.document?.getElementById(sweepConfirmButtonId)?.focus();
|
|
19400
19633
|
}, [sweepConfirmButtonId, sweepConfirming]);
|
|
@@ -19616,7 +19849,7 @@ function AttachmentSettingsPanel({ rpcCall }) {
|
|
|
19616
19849
|
);
|
|
19617
19850
|
}
|
|
19618
19851
|
function GlobalSettingsPanel({ rpcCall }) {
|
|
19619
|
-
const [tab, setTab] =
|
|
19852
|
+
const [tab, setTab] = React38.useState("general");
|
|
19620
19853
|
const tabs = [{ key: "general", label: "\u901A\u7528" }, { key: "attachments", label: "\u9644\u4EF6" }];
|
|
19621
19854
|
return h2(
|
|
19622
19855
|
"section",
|
|
@@ -19653,7 +19886,7 @@ function GlobalSettingsPanel({ rpcCall }) {
|
|
|
19653
19886
|
className: "dim-generalSettingsTabPanel",
|
|
19654
19887
|
role: "tabpanel",
|
|
19655
19888
|
"aria-labelledby": "dim-general-settings-tab-general"
|
|
19656
|
-
}, h2(GroupHistorySettings, { rpcCall })) : h2(AttachmentSettingsPanel, { rpcCall })
|
|
19889
|
+
}, h2(SidebarSettings, { rpcCall }), h2(GroupHistorySettings, { rpcCall })) : h2(AttachmentSettingsPanel, { rpcCall })
|
|
19657
19890
|
);
|
|
19658
19891
|
}
|
|
19659
19892
|
|
|
@@ -19715,6 +19948,7 @@ function replacePageLocation(url, location = globalThis.location) {
|
|
|
19715
19948
|
// plugin-src/client/styles.js
|
|
19716
19949
|
var IM_STYLE_ID = "xmanrui-dsh-im-settings";
|
|
19717
19950
|
var CSS15 = String.raw`
|
|
19951
|
+
.dim-sidebarIcon { display: block; flex: none; }
|
|
19718
19952
|
.dim-pluginOpen { display: inline-flex; align-items: center; justify-content: center; min-height: 36px; padding: 7px 14px; border: 1px solid var(--dsw-alias-border-l2, #dfe1e5); border-radius: 8px; color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-1, #fff); font: inherit; font-size: 13px; line-height: 20px; cursor: pointer; }
|
|
19719
19953
|
.dim-pluginOpen:hover { background: var(--dsw-alias-interactive-bg-hover, #f7f8fa); }
|
|
19720
19954
|
.dim-pluginOpen:focus-visible, .dim-pluginBack:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #3370ff); outline-offset: 3px; }
|
|
@@ -20359,6 +20593,14 @@ var CSS15 = String.raw`
|
|
|
20359
20593
|
.dim-botGeneralControl { position: relative; min-width: 0; max-width: 100%; justify-self: end; color: var(--dsw-alias-label-primary, #1f2329); }
|
|
20360
20594
|
.dim-botGeneralControl select, .dim-groupHistoryInput { display: block; min-width: 104px; max-width: 100%; height: 36px; padding: 0 36px 0 14px; border: 0; border-radius: 10px; color: inherit; background: var(--dsw-alias-bg-module-platform, #f5f6f7); font: inherit; font-size: 14px; line-height: 22px; appearance: none; }
|
|
20361
20595
|
.dim-botGeneralControl select { cursor: pointer; }
|
|
20596
|
+
.dim-sidebarSettings { border-bottom: 1px solid var(--dsw-alias-border-l2, #dfe1e5); }
|
|
20597
|
+
.dim-sidebarSettings .dim-botGeneralRow { border-bottom: 0; }
|
|
20598
|
+
.dim-sidebarHeading { display: flex; align-items: baseline; flex-wrap: wrap; gap: 8px; }
|
|
20599
|
+
.dim-sidebarFeedback { display: flex; align-items: center; gap: 12px; padding-bottom: 16px; }
|
|
20600
|
+
.dim-sidebarFeedback .dim-accessFeedback { flex: 1; min-width: 0; }
|
|
20601
|
+
/* Native option popups do not inherit the select's painted background on
|
|
20602
|
+
Windows. Set both colors so dark Host text never lands on a light popup. */
|
|
20603
|
+
.dim-sidebarSelect option { color: var(--dsw-alias-label-primary, #1f2329); background: var(--dsw-alias-bg-layer-3, #fff); }
|
|
20362
20604
|
.dim-botGeneralControl select:hover:not(:disabled), .dim-groupHistoryInput:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, #eef0f3); }
|
|
20363
20605
|
.dim-botGeneralControl select:focus-visible, .dim-groupHistoryInput:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #3370ff); outline-offset: 2px; }
|
|
20364
20606
|
.dim-botGeneralControl select:disabled, .dim-groupHistoryInput:disabled { opacity: .5; cursor: not-allowed; }
|
|
@@ -20768,7 +21010,7 @@ function installSessionChannelLogos(document2 = globalThis.document) {
|
|
|
20768
21010
|
}
|
|
20769
21011
|
|
|
20770
21012
|
// plugin-src/client/update-panel.js
|
|
20771
|
-
var
|
|
21013
|
+
var React39 = __toESM(require("react"), 1);
|
|
20772
21014
|
var import_react_dom4 = require("react-dom");
|
|
20773
21015
|
var import_valid = __toESM(require_valid(), 1);
|
|
20774
21016
|
var import_rcompare = __toESM(require_rcompare(), 1);
|
|
@@ -20861,11 +21103,11 @@ function manualUpdateCommand(snapshot) {
|
|
|
20861
21103
|
return `dsh plugin --profile ${profileArgument} add -w @xmanrui/dsh-im@${version}`;
|
|
20862
21104
|
}
|
|
20863
21105
|
function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
20864
|
-
const [copyState, setCopyState] =
|
|
20865
|
-
const commandRef =
|
|
20866
|
-
const mounted =
|
|
20867
|
-
const copying =
|
|
20868
|
-
|
|
21106
|
+
const [copyState, setCopyState] = React39.useState("idle");
|
|
21107
|
+
const commandRef = React39.useRef(null);
|
|
21108
|
+
const mounted = React39.useRef(false);
|
|
21109
|
+
const copying = React39.useRef(false);
|
|
21110
|
+
React39.useEffect(() => {
|
|
20869
21111
|
mounted.current = true;
|
|
20870
21112
|
return () => {
|
|
20871
21113
|
mounted.current = false;
|
|
@@ -20897,7 +21139,7 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20897
21139
|
{ className: "dim-updateManual", "aria-label": "\u624B\u5DE5\u66F4\u65B0" },
|
|
20898
21140
|
h2("h4", { className: "dim-updateManualHeading" }, "\u624B\u5DE5\u66F4\u65B0"),
|
|
20899
21141
|
command ? h2(
|
|
20900
|
-
|
|
21142
|
+
React39.Fragment,
|
|
20901
21143
|
null,
|
|
20902
21144
|
h2("p", { className: "dim-updateManualHint" }, "\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u53EF\u4EE5\u4F7F\u7528\u547D\u4EE4\u66F4\u65B0\uFF1A"),
|
|
20903
21145
|
h2(
|
|
@@ -20933,7 +21175,7 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20933
21175
|
"aria-hidden": "true",
|
|
20934
21176
|
focusable: "false"
|
|
20935
21177
|
}, copyState === "copied" ? h2("path", { d: "m4 10 4 4 8-8" }) : h2(
|
|
20936
|
-
|
|
21178
|
+
React39.Fragment,
|
|
20937
21179
|
null,
|
|
20938
21180
|
h2("rect", { x: 7, y: 7, width: 10, height: 11, rx: 1.5 }),
|
|
20939
21181
|
h2("path", { d: "M5 13H3.5A1.5 1.5 0 0 1 2 11.5v-8A1.5 1.5 0 0 1 3.5 2h8A1.5 1.5 0 0 1 13 3.5V5" })
|
|
@@ -20958,10 +21200,10 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20958
21200
|
);
|
|
20959
21201
|
}
|
|
20960
21202
|
function UpdateDialog({ children, onClose }) {
|
|
20961
|
-
const dialogRef =
|
|
20962
|
-
const titleId =
|
|
20963
|
-
const descriptionId =
|
|
20964
|
-
|
|
21203
|
+
const dialogRef = React39.useRef(null);
|
|
21204
|
+
const titleId = React39.useId();
|
|
21205
|
+
const descriptionId = React39.useId();
|
|
21206
|
+
React39.useEffect(() => {
|
|
20965
21207
|
const previous = globalThis.document?.activeElement;
|
|
20966
21208
|
dialogRef.current?.focus?.();
|
|
20967
21209
|
return () => {
|
|
@@ -21019,20 +21261,20 @@ function UpdateDialog({ children, onClose }) {
|
|
|
21019
21261
|
return typeof document !== "undefined" && document.body ? (0, import_react_dom4.createPortal)(content, document.body) : content;
|
|
21020
21262
|
}
|
|
21021
21263
|
function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
21022
|
-
const tooltipId =
|
|
21023
|
-
const [snapshot, setSnapshot] =
|
|
21024
|
-
const [action, setAction] =
|
|
21025
|
-
const [error, setError] =
|
|
21026
|
-
const [open, setOpen] =
|
|
21027
|
-
const [uncertainInstall, setUncertainInstall] =
|
|
21028
|
-
const mounted =
|
|
21029
|
-
const busy =
|
|
21030
|
-
const readController =
|
|
21031
|
-
const pollReadController =
|
|
21032
|
-
const installRequest =
|
|
21033
|
-
const onStatusRef =
|
|
21264
|
+
const tooltipId = React39.useId();
|
|
21265
|
+
const [snapshot, setSnapshot] = React39.useState(null);
|
|
21266
|
+
const [action, setAction] = React39.useState("status");
|
|
21267
|
+
const [error, setError] = React39.useState(null);
|
|
21268
|
+
const [open, setOpen] = React39.useState(false);
|
|
21269
|
+
const [uncertainInstall, setUncertainInstall] = React39.useState(false);
|
|
21270
|
+
const mounted = React39.useRef(false);
|
|
21271
|
+
const busy = React39.useRef(false);
|
|
21272
|
+
const readController = React39.useRef(null);
|
|
21273
|
+
const pollReadController = React39.useRef(null);
|
|
21274
|
+
const installRequest = React39.useRef(null);
|
|
21275
|
+
const onStatusRef = React39.useRef(onStatus);
|
|
21034
21276
|
onStatusRef.current = onStatus;
|
|
21035
|
-
const accept =
|
|
21277
|
+
const accept = React39.useCallback((next) => {
|
|
21036
21278
|
setSnapshot(next);
|
|
21037
21279
|
onStatusRef.current?.(next);
|
|
21038
21280
|
}, []);
|
|
@@ -21041,7 +21283,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21041
21283
|
setUncertainInstall(false);
|
|
21042
21284
|
accept(next);
|
|
21043
21285
|
};
|
|
21044
|
-
const invoke =
|
|
21286
|
+
const invoke = React39.useCallback(async (endpoint, payload = {}, signal) => {
|
|
21045
21287
|
if (typeof rpcCall !== "function") {
|
|
21046
21288
|
const unavailable = new Error("\u5F53\u524D Host \u4E0D\u652F\u6301\u66F4\u65B0\u63A5\u53E3\uFF0C\u8BF7\u5148\u624B\u52A8\u66F4\u65B0\u63D2\u4EF6\u5E76\u91CD\u542F\u3002");
|
|
21047
21289
|
unavailable.code = "update-unavailable";
|
|
@@ -21049,7 +21291,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21049
21291
|
}
|
|
21050
21292
|
return unwrapSnapshot(await rpcCall(endpoint, payload, signal));
|
|
21051
21293
|
}, [rpcCall]);
|
|
21052
|
-
|
|
21294
|
+
React39.useEffect(() => {
|
|
21053
21295
|
mounted.current = true;
|
|
21054
21296
|
busy.current = true;
|
|
21055
21297
|
const controller = new AbortController();
|
|
@@ -21072,7 +21314,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21072
21314
|
const activeJob = ACTIVE_STATES4.has(snapshot?.job?.state);
|
|
21073
21315
|
const restartRequired = snapshot?.job?.state === "restart-required" || snapshot?.blockedReason === "pending-restart";
|
|
21074
21316
|
const shouldPoll = activeJob || uncertainInstall;
|
|
21075
|
-
|
|
21317
|
+
React39.useEffect(() => {
|
|
21076
21318
|
if (!shouldPoll) return void 0;
|
|
21077
21319
|
let controller;
|
|
21078
21320
|
const scheduler = createPollScheduler({
|
|
@@ -21173,7 +21415,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21173
21415
|
const buttonLabel = action === "checking" ? "\u68C0\u67E5\u4E2D\u2026" : action === "starting" || activeJob ? "\u6B63\u5728\u66F4\u65B0\u2026" : restartRequired ? "\u5F85\u624B\u52A8\u91CD\u542F" : snapshot?.canInstall ? "\u66F4\u65B0\u81F3" : "\u68C0\u67E5\u66F4\u65B0";
|
|
21174
21416
|
const buttonDescription = localizeText(buttonLabel) + (buttonLabel === "\u66F4\u65B0\u81F3" ? ` v${snapshot.latestVersion}` : "");
|
|
21175
21417
|
return h2(
|
|
21176
|
-
|
|
21418
|
+
React39.Fragment,
|
|
21177
21419
|
null,
|
|
21178
21420
|
h2(
|
|
21179
21421
|
"span",
|
|
@@ -21223,25 +21465,25 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21223
21465
|
h2("dt", null, "\u8FD0\u884C\u7248\u672C"),
|
|
21224
21466
|
h2("dd", null, `v${snapshot?.runningVersion ?? clientVersion}`),
|
|
21225
21467
|
snapshot?.installedVersion && snapshot.installedVersion !== snapshot.runningVersion ? h2(
|
|
21226
|
-
|
|
21468
|
+
React39.Fragment,
|
|
21227
21469
|
null,
|
|
21228
21470
|
h2("dt", null, "\u5DF2\u5B89\u88C5\u7248\u672C"),
|
|
21229
21471
|
h2("dd", null, `v${snapshot.installedVersion}`)
|
|
21230
21472
|
) : null,
|
|
21231
21473
|
targetVersion ? h2(
|
|
21232
|
-
|
|
21474
|
+
React39.Fragment,
|
|
21233
21475
|
null,
|
|
21234
21476
|
h2("dt", null, "\u76EE\u6807\u7248\u672C"),
|
|
21235
21477
|
h2("dd", null, `v${targetVersion}`)
|
|
21236
21478
|
) : null,
|
|
21237
21479
|
latestVersion ? h2(
|
|
21238
|
-
|
|
21480
|
+
React39.Fragment,
|
|
21239
21481
|
null,
|
|
21240
21482
|
h2("dt", null, "\u6700\u65B0\u7248\u672C"),
|
|
21241
21483
|
h2("dd", null, `v${latestVersion}`)
|
|
21242
21484
|
) : null,
|
|
21243
21485
|
historicalTargetVersion ? h2(
|
|
21244
|
-
|
|
21486
|
+
React39.Fragment,
|
|
21245
21487
|
null,
|
|
21246
21488
|
h2("dt", null, "\u4E0A\u6B21\u66F4\u65B0\u76EE\u6807"),
|
|
21247
21489
|
h2("dd", null, `v${historicalTargetVersion}`)
|
|
@@ -21318,8 +21560,8 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21318
21560
|
}
|
|
21319
21561
|
|
|
21320
21562
|
// plugin-src/client/panel-error-boundary.js
|
|
21321
|
-
var
|
|
21322
|
-
var IMPanelErrorBoundary = class extends
|
|
21563
|
+
var React40 = __toESM(require("react"), 1);
|
|
21564
|
+
var IMPanelErrorBoundary = class extends React40.Component {
|
|
21323
21565
|
state = { failed: false };
|
|
21324
21566
|
static getDerivedStateFromError() {
|
|
21325
21567
|
return { failed: true };
|
|
@@ -21339,9 +21581,9 @@ var IMPanelErrorBoundary = class extends React39.Component {
|
|
|
21339
21581
|
};
|
|
21340
21582
|
|
|
21341
21583
|
// plugin-src/client/plugin-page.js
|
|
21342
|
-
var
|
|
21584
|
+
var React41 = __toESM(require("react"), 1);
|
|
21343
21585
|
var IM_MAIN_PANEL_ID = "xmanrui-dsh-im";
|
|
21344
|
-
var h3 =
|
|
21586
|
+
var h3 = React41.createElement;
|
|
21345
21587
|
function OpenImAction({ subject, packageName, onOpen, t }) {
|
|
21346
21588
|
if (subject?.kind !== "bundle" && subject?.kind !== "row") return null;
|
|
21347
21589
|
if (subject.pkg?.name !== packageName) return null;
|
|
@@ -21369,8 +21611,37 @@ function ImPluginPage({ renderPanel, onBack, t }) {
|
|
|
21369
21611
|
)
|
|
21370
21612
|
);
|
|
21371
21613
|
}
|
|
21372
|
-
function
|
|
21373
|
-
|
|
21614
|
+
function ImSidebarIcon({ size }) {
|
|
21615
|
+
return h3(
|
|
21616
|
+
"svg",
|
|
21617
|
+
{
|
|
21618
|
+
className: "dim-sidebarIcon",
|
|
21619
|
+
"aria-hidden": true,
|
|
21620
|
+
focusable: false,
|
|
21621
|
+
width: size,
|
|
21622
|
+
height: size,
|
|
21623
|
+
viewBox: "0 0 16 16",
|
|
21624
|
+
fill: "none",
|
|
21625
|
+
stroke: "currentColor",
|
|
21626
|
+
strokeWidth: 1,
|
|
21627
|
+
strokeLinecap: "round",
|
|
21628
|
+
strokeLinejoin: "round"
|
|
21629
|
+
},
|
|
21630
|
+
h3("path", { d: "M5 9.5H3.8L1.5 10.7l.7-2.2A2.4 2.4 0 0 1 1.5 6.8V4A2.5 2.5 0 0 1 4 1.5h4A2.5 2.5 0 0 1 10.5 4v3A2.5 2.5 0 0 1 8 9.5h-.5" }),
|
|
21631
|
+
h3("path", { d: "M12 6.5A2.5 2.5 0 0 1 14.5 9v2.8a2.4 2.4 0 0 1-.7 1.7l.7 1.2-2.3-.7H8A2.5 2.5 0 0 1 5.5 11.5V9A2.5 2.5 0 0 1 8 6.5h.5" })
|
|
21632
|
+
);
|
|
21633
|
+
}
|
|
21634
|
+
function installImPluginPage(ctx, { packageName, renderPanel, sidebarVisible = false }) {
|
|
21635
|
+
let visible = sidebarVisible;
|
|
21636
|
+
let updateSidebar = null;
|
|
21637
|
+
const controller = {
|
|
21638
|
+
setSidebarVisible(value) {
|
|
21639
|
+
if (typeof value !== "boolean") throw new TypeError("visible must be a boolean");
|
|
21640
|
+
visible = value;
|
|
21641
|
+
updateSidebar?.();
|
|
21642
|
+
}
|
|
21643
|
+
};
|
|
21644
|
+
if (typeof ctx.inject !== "function") return controller;
|
|
21374
21645
|
ctx.inject(["layout", "pluginNavigation"], (pageCtx) => pageCtx.slots.inject("main", () => {
|
|
21375
21646
|
const unregisterPage = pageCtx.slots.register({
|
|
21376
21647
|
name: "main",
|
|
@@ -21381,6 +21652,25 @@ function installImPluginPage(ctx, { packageName, renderPanel }) {
|
|
|
21381
21652
|
onBack: () => pageCtx.pluginNavigation.openBundle(packageName)
|
|
21382
21653
|
})
|
|
21383
21654
|
}, ImPluginPage);
|
|
21655
|
+
let stopSidebar = null;
|
|
21656
|
+
const update = () => {
|
|
21657
|
+
if (visible === (stopSidebar !== null)) return;
|
|
21658
|
+
if (!visible) {
|
|
21659
|
+
const stop = stopSidebar;
|
|
21660
|
+
stopSidebar = null;
|
|
21661
|
+
stop();
|
|
21662
|
+
return;
|
|
21663
|
+
}
|
|
21664
|
+
stopSidebar = pageCtx.slots.inject("sidebar.panellist", () => pageCtx.slots.register({
|
|
21665
|
+
name: "sidebar.panellist",
|
|
21666
|
+
id: IM_MAIN_PANEL_ID,
|
|
21667
|
+
order: 10,
|
|
21668
|
+
label: () => pageCtx.locale.bind(IM_LOCALE_NAMESPACE)("IM\u673A\u5668\u4EBA"),
|
|
21669
|
+
locale: IM_LOCALE_NAMESPACE
|
|
21670
|
+
}, ImSidebarIcon));
|
|
21671
|
+
};
|
|
21672
|
+
updateSidebar = update;
|
|
21673
|
+
update();
|
|
21384
21674
|
const stopActions = pageCtx.slots.inject("plugins.detail.actions", () => pageCtx.slots.register({
|
|
21385
21675
|
name: "plugins.detail.actions",
|
|
21386
21676
|
id: "xmanrui-dsh-im-open",
|
|
@@ -21393,9 +21683,12 @@ function installImPluginPage(ctx, { packageName, renderPanel }) {
|
|
|
21393
21683
|
}, OpenImAction));
|
|
21394
21684
|
return () => {
|
|
21395
21685
|
stopActions();
|
|
21686
|
+
updateSidebar = null;
|
|
21687
|
+
stopSidebar?.();
|
|
21396
21688
|
unregisterPage();
|
|
21397
21689
|
};
|
|
21398
21690
|
}));
|
|
21691
|
+
return controller;
|
|
21399
21692
|
}
|
|
21400
21693
|
|
|
21401
21694
|
// plugin-src/client/index.js
|
|
@@ -21572,28 +21865,28 @@ function IMSettingsTab({
|
|
|
21572
21865
|
browserLocation = globalThis.location,
|
|
21573
21866
|
navigateToRecoveryUrl = replacePageLocation
|
|
21574
21867
|
}) {
|
|
21575
|
-
const [selected, setSelected] =
|
|
21576
|
-
const [loopbackRecovery, setLoopbackRecovery] =
|
|
21577
|
-
const [runningVersion, setRunningVersion] =
|
|
21578
|
-
const [deliverySettings, setDeliverySettings] =
|
|
21868
|
+
const [selected, setSelected] = React42.useState(() => preferredSectionId === GLOBAL_SETTINGS_TAB_ID || CHANNELS.some((channel7) => channel7.id === preferredSectionId) ? preferredSectionId : "weixin");
|
|
21869
|
+
const [loopbackRecovery, setLoopbackRecovery] = React42.useState(null);
|
|
21870
|
+
const [runningVersion, setRunningVersion] = React42.useState(IM_PLUGIN_VERSION);
|
|
21871
|
+
const [deliverySettings, setDeliverySettings] = React42.useState(null);
|
|
21579
21872
|
const emailEnabled = useEmailChannelEnabled(emailRpcCall);
|
|
21580
|
-
const visibleChannels =
|
|
21873
|
+
const visibleChannels = React42.useMemo(
|
|
21581
21874
|
() => CHANNELS.filter((channel7) => channel7.id !== "email" || emailEnabled),
|
|
21582
21875
|
[emailEnabled]
|
|
21583
21876
|
);
|
|
21584
|
-
const githubTooltipId =
|
|
21585
|
-
const generalSettingsTooltipId =
|
|
21877
|
+
const githubTooltipId = React42.useId();
|
|
21878
|
+
const generalSettingsTooltipId = React42.useId();
|
|
21586
21879
|
const globalSettingsSelected = selected === GLOBAL_SETTINGS_TAB_ID;
|
|
21587
21880
|
const active = visibleChannels.find((channel7) => channel7.id === selected) ?? visibleChannels[0];
|
|
21588
21881
|
const activeTabId = globalSettingsSelected ? "dim-general-settings-trigger" : `dim-tab-${active.id}`;
|
|
21589
21882
|
const activePanelId = globalSettingsSelected ? `dim-panel-${GLOBAL_SETTINGS_TAB_ID}` : `dim-panel-${active.id}`;
|
|
21590
|
-
const reportLoopbackRecovery =
|
|
21883
|
+
const reportLoopbackRecovery = React42.useCallback((recovery) => {
|
|
21591
21884
|
setLoopbackRecovery((current) => current?.url === recovery.url ? current : recovery);
|
|
21592
21885
|
}, []);
|
|
21593
|
-
const reportUpdateStatus =
|
|
21886
|
+
const reportUpdateStatus = React42.useCallback((snapshot) => {
|
|
21594
21887
|
setRunningVersion(snapshot.runningVersion);
|
|
21595
21888
|
}, []);
|
|
21596
|
-
const rpcCalls =
|
|
21889
|
+
const rpcCalls = React42.useMemo(() => createLoopbackAwareRpcCalls({
|
|
21597
21890
|
dingtalkRpcCall,
|
|
21598
21891
|
discordRpcCall,
|
|
21599
21892
|
feishuRpcCall,
|
|
@@ -21635,7 +21928,7 @@ function IMSettingsTab({
|
|
|
21635
21928
|
weixinRpcCall,
|
|
21636
21929
|
whatsappRpcCall
|
|
21637
21930
|
]);
|
|
21638
|
-
const botSettingsContext =
|
|
21931
|
+
const botSettingsContext = React42.useMemo(() => Object.freeze({
|
|
21639
21932
|
openBotSettings: setDeliverySettings
|
|
21640
21933
|
}), []);
|
|
21641
21934
|
return h2(
|
|
@@ -21814,23 +22107,32 @@ function apply(ctx) {
|
|
|
21814
22107
|
for (const dispose of disposers.reverse()) dispose();
|
|
21815
22108
|
};
|
|
21816
22109
|
}, "im-settings: install combined channel styles");
|
|
21817
|
-
|
|
21818
|
-
const
|
|
21819
|
-
|
|
21820
|
-
|
|
21821
|
-
|
|
21822
|
-
|
|
21823
|
-
|
|
21824
|
-
|
|
21825
|
-
|
|
21826
|
-
const
|
|
21827
|
-
const
|
|
21828
|
-
const
|
|
21829
|
-
const
|
|
21830
|
-
const
|
|
21831
|
-
const
|
|
21832
|
-
const
|
|
21833
|
-
const
|
|
22110
|
+
let sidebarSync;
|
|
22111
|
+
const managementRpc = async (connection, channel7, endpoint, payload, signal) => {
|
|
22112
|
+
const result2 = await callManagementRpc(connection, channel7, endpoint, payload, signal);
|
|
22113
|
+
if (result2?.ok === true) {
|
|
22114
|
+
if (endpoint === SIDEBAR_SETTINGS_ENDPOINTS.set) sidebarSync?.apply(result2);
|
|
22115
|
+
else if (endpoint !== SIDEBAR_SETTINGS_ENDPOINTS.get) sidebarSync?.refresh();
|
|
22116
|
+
}
|
|
22117
|
+
return result2;
|
|
22118
|
+
};
|
|
22119
|
+
const feishuRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, FEISHU_RPC_CHANNEL, endpoint, payload, signal);
|
|
22120
|
+
const weixinRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, WEIXIN_RPC_CHANNEL, endpoint, payload, signal);
|
|
22121
|
+
const dingtalkRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, DINGTALK_RPC_CHANNEL, endpoint, payload, signal);
|
|
22122
|
+
const qqRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, QQ_RPC_CHANNEL, endpoint, payload, signal);
|
|
22123
|
+
const wecomRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, WECOM_RPC_CHANNEL, endpoint, payload, signal);
|
|
22124
|
+
const wecomAppRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, WECOM_APP_RPC_CHANNEL, endpoint, payload, signal);
|
|
22125
|
+
const telegramRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, TELEGRAM_RPC_CHANNEL, endpoint, payload, signal);
|
|
22126
|
+
const discordRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, DISCORD_RPC_CHANNEL, endpoint, payload, signal);
|
|
22127
|
+
const whatsappRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, WHATSAPP_RPC_CHANNEL, endpoint, payload, signal);
|
|
22128
|
+
const imessageRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, IMESSAGE_RPC_CHANNEL, endpoint, payload, signal);
|
|
22129
|
+
const emailRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, EMAIL_RPC_CHANNEL, endpoint, payload, signal);
|
|
22130
|
+
const matrixRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, MATRIX_RPC_CHANNEL, endpoint, payload, signal);
|
|
22131
|
+
const slackRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, SLACK_RPC_CHANNEL, endpoint, payload, signal);
|
|
22132
|
+
const officeRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, OFFICE_RPC_CHANNEL, endpoint, payload, signal);
|
|
22133
|
+
const updateRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, UPDATE_RPC_CHANNEL, endpoint, payload, signal);
|
|
22134
|
+
const deliveryRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, DELIVERY_RPC_CHANNEL, endpoint, payload, signal);
|
|
22135
|
+
const globalSettingsRpcCall = (endpoint, payload, signal) => managementRpc(ctx.connection, Object.values(SIDEBAR_SETTINGS_ENDPOINTS).includes(endpoint) ? SIDEBAR_SETTINGS_RPC_CHANNEL : GLOBAL_SETTINGS_RPC_CHANNEL, endpoint, payload, signal);
|
|
21834
22136
|
const workspaceDirectoryPicker = Object.freeze({
|
|
21835
22137
|
listDirectory: (path, signal) => callWorkspaceDirectoryApi(ctx, "listDirectory", path, signal),
|
|
21836
22138
|
pickDirectory: () => callWorkspaceDirectoryApi(ctx, "pickDirectory")
|
|
@@ -21859,7 +22161,7 @@ function apply(ctx) {
|
|
|
21859
22161
|
};
|
|
21860
22162
|
const localeSnapshot = () => ctx.locale.getLocale?.()?.active ?? "";
|
|
21861
22163
|
function IMPanel({ preferredSectionId }) {
|
|
21862
|
-
|
|
22164
|
+
React42.useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
|
|
21863
22165
|
return h2(
|
|
21864
22166
|
IMPanelErrorBoundary,
|
|
21865
22167
|
null,
|
|
@@ -21869,7 +22171,20 @@ function apply(ctx) {
|
|
|
21869
22171
|
const buildPanelElement = (props = {}) => h2(IMPanel, {
|
|
21870
22172
|
preferredSectionId: props.preferredSectionId
|
|
21871
22173
|
});
|
|
21872
|
-
installImPluginPage(ctx, {
|
|
22174
|
+
const pluginPage = installImPluginPage(ctx, {
|
|
22175
|
+
packageName: package_default.name,
|
|
22176
|
+
renderPanel: buildPanelElement
|
|
22177
|
+
});
|
|
22178
|
+
ctx.effect(() => {
|
|
22179
|
+
sidebarSync = installSidebarVisibilitySync({
|
|
22180
|
+
rpcCall: (endpoint, payload, signal) => callManagementRpc(ctx.connection, SIDEBAR_SETTINGS_RPC_CHANNEL, endpoint, payload, signal),
|
|
22181
|
+
setVisible: (visible) => pluginPage.setSidebarVisible(visible)
|
|
22182
|
+
});
|
|
22183
|
+
return () => {
|
|
22184
|
+
sidebarSync.dispose();
|
|
22185
|
+
sidebarSync = null;
|
|
22186
|
+
};
|
|
22187
|
+
}, "im-settings: sidebar visibility");
|
|
21873
22188
|
ctx.effect(() => {
|
|
21874
22189
|
let disposed = false;
|
|
21875
22190
|
let stopSettings = null;
|