@xmanrui/dsh-im 5.2.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/docs/client-integration.md +6 -2
- package/lib/client.js +398 -115
- 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 +38 -18
- package/plugin-src/client/plugin-page.js +36 -9
- package/plugin-src/client/sidebar-settings.js +129 -0
- package/plugin-src/client/styles.js +8 -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/i18n-en/diagnostics.mjs +5 -0
- package/src/channels/shared/qr-encoding-error.mjs +39 -0
- package/src/channels/weixin/connection-error.mjs +1 -0
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
|
|
|
@@ -20360,6 +20593,14 @@ var CSS15 = String.raw`
|
|
|
20360
20593
|
.dim-botGeneralControl { position: relative; min-width: 0; max-width: 100%; justify-self: end; color: var(--dsw-alias-label-primary, #1f2329); }
|
|
20361
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; }
|
|
20362
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); }
|
|
20363
20604
|
.dim-botGeneralControl select:hover:not(:disabled), .dim-groupHistoryInput:hover:not(:disabled) { background: var(--dsw-alias-interactive-bg-hover, #eef0f3); }
|
|
20364
20605
|
.dim-botGeneralControl select:focus-visible, .dim-groupHistoryInput:focus-visible { outline: 2px solid var(--dsw-alias-state-business-primary, #3370ff); outline-offset: 2px; }
|
|
20365
20606
|
.dim-botGeneralControl select:disabled, .dim-groupHistoryInput:disabled { opacity: .5; cursor: not-allowed; }
|
|
@@ -20769,7 +21010,7 @@ function installSessionChannelLogos(document2 = globalThis.document) {
|
|
|
20769
21010
|
}
|
|
20770
21011
|
|
|
20771
21012
|
// plugin-src/client/update-panel.js
|
|
20772
|
-
var
|
|
21013
|
+
var React39 = __toESM(require("react"), 1);
|
|
20773
21014
|
var import_react_dom4 = require("react-dom");
|
|
20774
21015
|
var import_valid = __toESM(require_valid(), 1);
|
|
20775
21016
|
var import_rcompare = __toESM(require_rcompare(), 1);
|
|
@@ -20862,11 +21103,11 @@ function manualUpdateCommand(snapshot) {
|
|
|
20862
21103
|
return `dsh plugin --profile ${profileArgument} add -w @xmanrui/dsh-im@${version}`;
|
|
20863
21104
|
}
|
|
20864
21105
|
function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
20865
|
-
const [copyState, setCopyState] =
|
|
20866
|
-
const commandRef =
|
|
20867
|
-
const mounted =
|
|
20868
|
-
const copying =
|
|
20869
|
-
|
|
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(() => {
|
|
20870
21111
|
mounted.current = true;
|
|
20871
21112
|
return () => {
|
|
20872
21113
|
mounted.current = false;
|
|
@@ -20898,7 +21139,7 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20898
21139
|
{ className: "dim-updateManual", "aria-label": "\u624B\u5DE5\u66F4\u65B0" },
|
|
20899
21140
|
h2("h4", { className: "dim-updateManualHeading" }, "\u624B\u5DE5\u66F4\u65B0"),
|
|
20900
21141
|
command ? h2(
|
|
20901
|
-
|
|
21142
|
+
React39.Fragment,
|
|
20902
21143
|
null,
|
|
20903
21144
|
h2("p", { className: "dim-updateManualHint" }, "\u81EA\u52A8\u66F4\u65B0\u5931\u8D25\u53EF\u4EE5\u4F7F\u7528\u547D\u4EE4\u66F4\u65B0\uFF1A"),
|
|
20904
21145
|
h2(
|
|
@@ -20934,7 +21175,7 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20934
21175
|
"aria-hidden": "true",
|
|
20935
21176
|
focusable: "false"
|
|
20936
21177
|
}, copyState === "copied" ? h2("path", { d: "m4 10 4 4 8-8" }) : h2(
|
|
20937
|
-
|
|
21178
|
+
React39.Fragment,
|
|
20938
21179
|
null,
|
|
20939
21180
|
h2("rect", { x: 7, y: 7, width: 10, height: 11, rx: 1.5 }),
|
|
20940
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" })
|
|
@@ -20959,10 +21200,10 @@ function ManualUpdateCommand({ command, disabled, sourceInstall, desktop }) {
|
|
|
20959
21200
|
);
|
|
20960
21201
|
}
|
|
20961
21202
|
function UpdateDialog({ children, onClose }) {
|
|
20962
|
-
const dialogRef =
|
|
20963
|
-
const titleId =
|
|
20964
|
-
const descriptionId =
|
|
20965
|
-
|
|
21203
|
+
const dialogRef = React39.useRef(null);
|
|
21204
|
+
const titleId = React39.useId();
|
|
21205
|
+
const descriptionId = React39.useId();
|
|
21206
|
+
React39.useEffect(() => {
|
|
20966
21207
|
const previous = globalThis.document?.activeElement;
|
|
20967
21208
|
dialogRef.current?.focus?.();
|
|
20968
21209
|
return () => {
|
|
@@ -21020,20 +21261,20 @@ function UpdateDialog({ children, onClose }) {
|
|
|
21020
21261
|
return typeof document !== "undefined" && document.body ? (0, import_react_dom4.createPortal)(content, document.body) : content;
|
|
21021
21262
|
}
|
|
21022
21263
|
function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
21023
|
-
const tooltipId =
|
|
21024
|
-
const [snapshot, setSnapshot] =
|
|
21025
|
-
const [action, setAction] =
|
|
21026
|
-
const [error, setError] =
|
|
21027
|
-
const [open, setOpen] =
|
|
21028
|
-
const [uncertainInstall, setUncertainInstall] =
|
|
21029
|
-
const mounted =
|
|
21030
|
-
const busy =
|
|
21031
|
-
const readController =
|
|
21032
|
-
const pollReadController =
|
|
21033
|
-
const installRequest =
|
|
21034
|
-
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);
|
|
21035
21276
|
onStatusRef.current = onStatus;
|
|
21036
|
-
const accept =
|
|
21277
|
+
const accept = React39.useCallback((next) => {
|
|
21037
21278
|
setSnapshot(next);
|
|
21038
21279
|
onStatusRef.current?.(next);
|
|
21039
21280
|
}, []);
|
|
@@ -21042,7 +21283,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21042
21283
|
setUncertainInstall(false);
|
|
21043
21284
|
accept(next);
|
|
21044
21285
|
};
|
|
21045
|
-
const invoke =
|
|
21286
|
+
const invoke = React39.useCallback(async (endpoint, payload = {}, signal) => {
|
|
21046
21287
|
if (typeof rpcCall !== "function") {
|
|
21047
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");
|
|
21048
21289
|
unavailable.code = "update-unavailable";
|
|
@@ -21050,7 +21291,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21050
21291
|
}
|
|
21051
21292
|
return unwrapSnapshot(await rpcCall(endpoint, payload, signal));
|
|
21052
21293
|
}, [rpcCall]);
|
|
21053
|
-
|
|
21294
|
+
React39.useEffect(() => {
|
|
21054
21295
|
mounted.current = true;
|
|
21055
21296
|
busy.current = true;
|
|
21056
21297
|
const controller = new AbortController();
|
|
@@ -21073,7 +21314,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21073
21314
|
const activeJob = ACTIVE_STATES4.has(snapshot?.job?.state);
|
|
21074
21315
|
const restartRequired = snapshot?.job?.state === "restart-required" || snapshot?.blockedReason === "pending-restart";
|
|
21075
21316
|
const shouldPoll = activeJob || uncertainInstall;
|
|
21076
|
-
|
|
21317
|
+
React39.useEffect(() => {
|
|
21077
21318
|
if (!shouldPoll) return void 0;
|
|
21078
21319
|
let controller;
|
|
21079
21320
|
const scheduler = createPollScheduler({
|
|
@@ -21174,7 +21415,7 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21174
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";
|
|
21175
21416
|
const buttonDescription = localizeText(buttonLabel) + (buttonLabel === "\u66F4\u65B0\u81F3" ? ` v${snapshot.latestVersion}` : "");
|
|
21176
21417
|
return h2(
|
|
21177
|
-
|
|
21418
|
+
React39.Fragment,
|
|
21178
21419
|
null,
|
|
21179
21420
|
h2(
|
|
21180
21421
|
"span",
|
|
@@ -21224,25 +21465,25 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21224
21465
|
h2("dt", null, "\u8FD0\u884C\u7248\u672C"),
|
|
21225
21466
|
h2("dd", null, `v${snapshot?.runningVersion ?? clientVersion}`),
|
|
21226
21467
|
snapshot?.installedVersion && snapshot.installedVersion !== snapshot.runningVersion ? h2(
|
|
21227
|
-
|
|
21468
|
+
React39.Fragment,
|
|
21228
21469
|
null,
|
|
21229
21470
|
h2("dt", null, "\u5DF2\u5B89\u88C5\u7248\u672C"),
|
|
21230
21471
|
h2("dd", null, `v${snapshot.installedVersion}`)
|
|
21231
21472
|
) : null,
|
|
21232
21473
|
targetVersion ? h2(
|
|
21233
|
-
|
|
21474
|
+
React39.Fragment,
|
|
21234
21475
|
null,
|
|
21235
21476
|
h2("dt", null, "\u76EE\u6807\u7248\u672C"),
|
|
21236
21477
|
h2("dd", null, `v${targetVersion}`)
|
|
21237
21478
|
) : null,
|
|
21238
21479
|
latestVersion ? h2(
|
|
21239
|
-
|
|
21480
|
+
React39.Fragment,
|
|
21240
21481
|
null,
|
|
21241
21482
|
h2("dt", null, "\u6700\u65B0\u7248\u672C"),
|
|
21242
21483
|
h2("dd", null, `v${latestVersion}`)
|
|
21243
21484
|
) : null,
|
|
21244
21485
|
historicalTargetVersion ? h2(
|
|
21245
|
-
|
|
21486
|
+
React39.Fragment,
|
|
21246
21487
|
null,
|
|
21247
21488
|
h2("dt", null, "\u4E0A\u6B21\u66F4\u65B0\u76EE\u6807"),
|
|
21248
21489
|
h2("dd", null, `v${historicalTargetVersion}`)
|
|
@@ -21319,8 +21560,8 @@ function UpdatePanel({ rpcCall, clientVersion, onStatus }) {
|
|
|
21319
21560
|
}
|
|
21320
21561
|
|
|
21321
21562
|
// plugin-src/client/panel-error-boundary.js
|
|
21322
|
-
var
|
|
21323
|
-
var IMPanelErrorBoundary = class extends
|
|
21563
|
+
var React40 = __toESM(require("react"), 1);
|
|
21564
|
+
var IMPanelErrorBoundary = class extends React40.Component {
|
|
21324
21565
|
state = { failed: false };
|
|
21325
21566
|
static getDerivedStateFromError() {
|
|
21326
21567
|
return { failed: true };
|
|
@@ -21340,9 +21581,9 @@ var IMPanelErrorBoundary = class extends React39.Component {
|
|
|
21340
21581
|
};
|
|
21341
21582
|
|
|
21342
21583
|
// plugin-src/client/plugin-page.js
|
|
21343
|
-
var
|
|
21584
|
+
var React41 = __toESM(require("react"), 1);
|
|
21344
21585
|
var IM_MAIN_PANEL_ID = "xmanrui-dsh-im";
|
|
21345
|
-
var h3 =
|
|
21586
|
+
var h3 = React41.createElement;
|
|
21346
21587
|
function OpenImAction({ subject, packageName, onOpen, t }) {
|
|
21347
21588
|
if (subject?.kind !== "bundle" && subject?.kind !== "row") return null;
|
|
21348
21589
|
if (subject.pkg?.name !== packageName) return null;
|
|
@@ -21390,8 +21631,17 @@ function ImSidebarIcon({ size }) {
|
|
|
21390
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" })
|
|
21391
21632
|
);
|
|
21392
21633
|
}
|
|
21393
|
-
function installImPluginPage(ctx, { packageName, renderPanel }) {
|
|
21394
|
-
|
|
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;
|
|
21395
21645
|
ctx.inject(["layout", "pluginNavigation"], (pageCtx) => pageCtx.slots.inject("main", () => {
|
|
21396
21646
|
const unregisterPage = pageCtx.slots.register({
|
|
21397
21647
|
name: "main",
|
|
@@ -21402,13 +21652,25 @@ function installImPluginPage(ctx, { packageName, renderPanel }) {
|
|
|
21402
21652
|
onBack: () => pageCtx.pluginNavigation.openBundle(packageName)
|
|
21403
21653
|
})
|
|
21404
21654
|
}, ImPluginPage);
|
|
21405
|
-
|
|
21406
|
-
|
|
21407
|
-
|
|
21408
|
-
|
|
21409
|
-
|
|
21410
|
-
|
|
21411
|
-
|
|
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();
|
|
21412
21674
|
const stopActions = pageCtx.slots.inject("plugins.detail.actions", () => pageCtx.slots.register({
|
|
21413
21675
|
name: "plugins.detail.actions",
|
|
21414
21676
|
id: "xmanrui-dsh-im-open",
|
|
@@ -21421,10 +21683,12 @@ function installImPluginPage(ctx, { packageName, renderPanel }) {
|
|
|
21421
21683
|
}, OpenImAction));
|
|
21422
21684
|
return () => {
|
|
21423
21685
|
stopActions();
|
|
21424
|
-
|
|
21686
|
+
updateSidebar = null;
|
|
21687
|
+
stopSidebar?.();
|
|
21425
21688
|
unregisterPage();
|
|
21426
21689
|
};
|
|
21427
21690
|
}));
|
|
21691
|
+
return controller;
|
|
21428
21692
|
}
|
|
21429
21693
|
|
|
21430
21694
|
// plugin-src/client/index.js
|
|
@@ -21601,28 +21865,28 @@ function IMSettingsTab({
|
|
|
21601
21865
|
browserLocation = globalThis.location,
|
|
21602
21866
|
navigateToRecoveryUrl = replacePageLocation
|
|
21603
21867
|
}) {
|
|
21604
|
-
const [selected, setSelected] =
|
|
21605
|
-
const [loopbackRecovery, setLoopbackRecovery] =
|
|
21606
|
-
const [runningVersion, setRunningVersion] =
|
|
21607
|
-
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);
|
|
21608
21872
|
const emailEnabled = useEmailChannelEnabled(emailRpcCall);
|
|
21609
|
-
const visibleChannels =
|
|
21873
|
+
const visibleChannels = React42.useMemo(
|
|
21610
21874
|
() => CHANNELS.filter((channel7) => channel7.id !== "email" || emailEnabled),
|
|
21611
21875
|
[emailEnabled]
|
|
21612
21876
|
);
|
|
21613
|
-
const githubTooltipId =
|
|
21614
|
-
const generalSettingsTooltipId =
|
|
21877
|
+
const githubTooltipId = React42.useId();
|
|
21878
|
+
const generalSettingsTooltipId = React42.useId();
|
|
21615
21879
|
const globalSettingsSelected = selected === GLOBAL_SETTINGS_TAB_ID;
|
|
21616
21880
|
const active = visibleChannels.find((channel7) => channel7.id === selected) ?? visibleChannels[0];
|
|
21617
21881
|
const activeTabId = globalSettingsSelected ? "dim-general-settings-trigger" : `dim-tab-${active.id}`;
|
|
21618
21882
|
const activePanelId = globalSettingsSelected ? `dim-panel-${GLOBAL_SETTINGS_TAB_ID}` : `dim-panel-${active.id}`;
|
|
21619
|
-
const reportLoopbackRecovery =
|
|
21883
|
+
const reportLoopbackRecovery = React42.useCallback((recovery) => {
|
|
21620
21884
|
setLoopbackRecovery((current) => current?.url === recovery.url ? current : recovery);
|
|
21621
21885
|
}, []);
|
|
21622
|
-
const reportUpdateStatus =
|
|
21886
|
+
const reportUpdateStatus = React42.useCallback((snapshot) => {
|
|
21623
21887
|
setRunningVersion(snapshot.runningVersion);
|
|
21624
21888
|
}, []);
|
|
21625
|
-
const rpcCalls =
|
|
21889
|
+
const rpcCalls = React42.useMemo(() => createLoopbackAwareRpcCalls({
|
|
21626
21890
|
dingtalkRpcCall,
|
|
21627
21891
|
discordRpcCall,
|
|
21628
21892
|
feishuRpcCall,
|
|
@@ -21664,7 +21928,7 @@ function IMSettingsTab({
|
|
|
21664
21928
|
weixinRpcCall,
|
|
21665
21929
|
whatsappRpcCall
|
|
21666
21930
|
]);
|
|
21667
|
-
const botSettingsContext =
|
|
21931
|
+
const botSettingsContext = React42.useMemo(() => Object.freeze({
|
|
21668
21932
|
openBotSettings: setDeliverySettings
|
|
21669
21933
|
}), []);
|
|
21670
21934
|
return h2(
|
|
@@ -21843,23 +22107,32 @@ function apply(ctx) {
|
|
|
21843
22107
|
for (const dispose of disposers.reverse()) dispose();
|
|
21844
22108
|
};
|
|
21845
22109
|
}, "im-settings: install combined channel styles");
|
|
21846
|
-
|
|
21847
|
-
const
|
|
21848
|
-
|
|
21849
|
-
|
|
21850
|
-
|
|
21851
|
-
|
|
21852
|
-
|
|
21853
|
-
|
|
21854
|
-
|
|
21855
|
-
const
|
|
21856
|
-
const
|
|
21857
|
-
const
|
|
21858
|
-
const
|
|
21859
|
-
const
|
|
21860
|
-
const
|
|
21861
|
-
const
|
|
21862
|
-
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);
|
|
21863
22136
|
const workspaceDirectoryPicker = Object.freeze({
|
|
21864
22137
|
listDirectory: (path, signal) => callWorkspaceDirectoryApi(ctx, "listDirectory", path, signal),
|
|
21865
22138
|
pickDirectory: () => callWorkspaceDirectoryApi(ctx, "pickDirectory")
|
|
@@ -21888,7 +22161,7 @@ function apply(ctx) {
|
|
|
21888
22161
|
};
|
|
21889
22162
|
const localeSnapshot = () => ctx.locale.getLocale?.()?.active ?? "";
|
|
21890
22163
|
function IMPanel({ preferredSectionId }) {
|
|
21891
|
-
|
|
22164
|
+
React42.useSyncExternalStore(subscribeLocale, localeSnapshot, localeSnapshot);
|
|
21892
22165
|
return h2(
|
|
21893
22166
|
IMPanelErrorBoundary,
|
|
21894
22167
|
null,
|
|
@@ -21898,10 +22171,20 @@ function apply(ctx) {
|
|
|
21898
22171
|
const buildPanelElement = (props = {}) => h2(IMPanel, {
|
|
21899
22172
|
preferredSectionId: props.preferredSectionId
|
|
21900
22173
|
});
|
|
21901
|
-
installImPluginPage(ctx, {
|
|
22174
|
+
const pluginPage = installImPluginPage(ctx, {
|
|
21902
22175
|
packageName: package_default.name,
|
|
21903
22176
|
renderPanel: buildPanelElement
|
|
21904
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");
|
|
21905
22188
|
ctx.effect(() => {
|
|
21906
22189
|
let disposed = false;
|
|
21907
22190
|
let stopSettings = null;
|