@michengai/dsh-im-connect 1.0.24 → 1.0.25
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/CHANGELOG.md +5 -0
- package/CHANGELOG.zh-CN.md +5 -0
- package/client.js +65 -17
- package/lib/client.js +65 -17
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 1.0.25 - 2026-11-04
|
|
4
|
+
|
|
5
|
+
- Fix settings navigation icon compatibility across host generations: ensure the IM Assistant icon correctly appears in older DSH hosts without falling back to the default gear glyph, while cleanly using the native icon slot without duplicates on newer hosts.
|
|
6
|
+
- Graceful fallback for slot registration: ensure settings icon registration errors are isolated and automatically retried when switching views, preventing host settings dialog interruptions.
|
|
7
|
+
|
|
3
8
|
## 1.0.24 - 2026-11-03
|
|
4
9
|
|
|
5
10
|
- Integrate official native settings navigation icon slot: present dedicated instant messaging vector icon on newer hosts while maintaining graceful compatibility with older hosts to prevent dual icons.
|
package/CHANGELOG.zh-CN.md
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
以下记录近期发布的版本。Git 标签与 GitHub Release 现已和这些条目同步;历史条目继续保留原始发布提交链接。
|
|
6
6
|
|
|
7
|
+
## 1.0.25 - 2026-11-04
|
|
8
|
+
|
|
9
|
+
- 完善不同版本 DSH 宿主设置导航图标兼容性:修复老版本宿主下「IM 助理」图标可能意外退回默认齿轮的问题,同时保持在新版宿主中通过原生插槽优雅展示专属矢量图标,彻底避免双图标重叠。
|
|
10
|
+
- 增强图标插槽容错与自愈能力:隔离图标插槽注册异常并在入口位置切换时自动重试,确保不会影响宿主设置工作台的整体加载。
|
|
11
|
+
|
|
7
12
|
## 1.0.24 - 2026-11-03
|
|
8
13
|
|
|
9
14
|
- 接入官方原生设置导航图标插槽:在 DSH 新版设置页中呈现专属即时通信矢量图标,并精准兼容老版宿主,彻底避免双图标重叠问题。
|
package/client.js
CHANGED
|
@@ -4316,9 +4316,8 @@ window.__ModuleLoader__.load({
|
|
|
4316
4316
|
const isOwn = isOwnNavRow(getNavButtonText(button), typeof wantedLabel === "function" ? wantedLabel() : wantedLabel);
|
|
4317
4317
|
if (isOwn) {
|
|
4318
4318
|
const hasSlotIcon = Array.from((button && button.children) || []).some((child) =>
|
|
4319
|
-
child.tagName === "SPAN" &&
|
|
4320
|
-
|
|
4321
|
-
) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('[class*="navIcon"]'));
|
|
4319
|
+
child.tagName === "SPAN" && child.className && String(child.className).includes("navIcon")
|
|
4320
|
+
) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('span[class*="navIcon"]'));
|
|
4322
4321
|
if (hasSlotIcon) {
|
|
4323
4322
|
if (button.hasAttribute(NAV_ICON_MARKER)) {
|
|
4324
4323
|
button.removeAttribute(NAV_ICON_MARKER);
|
|
@@ -4343,6 +4342,19 @@ window.__ModuleLoader__.load({
|
|
|
4343
4342
|
return true;
|
|
4344
4343
|
}
|
|
4345
4344
|
|
|
4345
|
+
/**
|
|
4346
|
+
* 宿主是否已声明设置图标插槽。
|
|
4347
|
+
* 实测宿主公开面只暴露 `spec`(`specDynamic` 仅在 SlotCore 内部使用),
|
|
4348
|
+
* 两个都探是为了兼容将来把宽形式提到公开面的宿主;返回值可能是 null,
|
|
4349
|
+
* 所以统一按 `!= null` 判定,不能写 `!== undefined`。
|
|
4350
|
+
*/
|
|
4351
|
+
function hostDeclaresIconSlot(slots) {
|
|
4352
|
+
if (!slots) return false;
|
|
4353
|
+
if (typeof slots.specDynamic === "function" && slots.specDynamic("settings.section.icon") != null) return true;
|
|
4354
|
+
if (typeof slots.spec === "function" && slots.spec("settings.section.icon") != null) return true;
|
|
4355
|
+
return false;
|
|
4356
|
+
}
|
|
4357
|
+
|
|
4346
4358
|
function installSettingsNavIcon(targetCtx, resolveLabel) {
|
|
4347
4359
|
if (typeof document === "undefined") return;
|
|
4348
4360
|
ensureNavIconStyle(document);
|
|
@@ -4380,7 +4392,11 @@ window.__ModuleLoader__.load({
|
|
|
4380
4392
|
}, "im-connect: settings nav icon");
|
|
4381
4393
|
}
|
|
4382
4394
|
|
|
4383
|
-
|
|
4395
|
+
const hasIconSlot = hostDeclaresIconSlot(ctx.slots);
|
|
4396
|
+
|
|
4397
|
+
if (!hasIconSlot) {
|
|
4398
|
+
installSettingsNavIcon(ctx, () => t("settings.label"));
|
|
4399
|
+
}
|
|
4384
4400
|
|
|
4385
4401
|
function ImNavIcon({ size = 16 }) {
|
|
4386
4402
|
return React.createElement(
|
|
@@ -4402,18 +4418,52 @@ window.__ModuleLoader__.load({
|
|
|
4402
4418
|
);
|
|
4403
4419
|
}
|
|
4404
4420
|
|
|
4421
|
+
/**
|
|
4422
|
+
* 在宿主声明了 `settings.section.icon` 后注册插件图标,并跟随入口位置启停。
|
|
4423
|
+
* 注册动作必须自带清理:槽位声明被撤销后宿主会重跑 inject 回调,不返回 disposer
|
|
4424
|
+
* 会让本地 unregIcon 变成永久非空、图标再也注册不回去。
|
|
4425
|
+
* 注册失败只影响图标本身(宿主回退自带字形),不得把宿主 settings 壳的注册流程带崩。
|
|
4426
|
+
*/
|
|
4427
|
+
function installSettingsIconSlot(targetCtx, controller, IconComponent) {
|
|
4428
|
+
targetCtx.slots.inject("settings.section.icon", () => {
|
|
4429
|
+
let unregIcon = null;
|
|
4430
|
+
const syncIcon = () => {
|
|
4431
|
+
const shouldShow = controller && typeof controller.isSettingsSectionEnabled === "function"
|
|
4432
|
+
? controller.isSettingsSectionEnabled()
|
|
4433
|
+
: true;
|
|
4434
|
+
if (shouldShow && !unregIcon) {
|
|
4435
|
+
try {
|
|
4436
|
+
const res = targetCtx.slots.register({
|
|
4437
|
+
name: "settings.section.icon",
|
|
4438
|
+
id: "im-assistant",
|
|
4439
|
+
locale: IM_LOCALE_NS,
|
|
4440
|
+
}, IconComponent);
|
|
4441
|
+
unregIcon = typeof res === "function" ? res : () => {};
|
|
4442
|
+
} catch { /* 注册抛错时留空 unregIcon,等下一次位置变化重试 */ }
|
|
4443
|
+
} else if (!shouldShow && unregIcon) {
|
|
4444
|
+
try { unregIcon(); } catch {}
|
|
4445
|
+
unregIcon = null;
|
|
4446
|
+
}
|
|
4447
|
+
};
|
|
4448
|
+
syncIcon();
|
|
4449
|
+
const unlisten = controller && typeof controller.onLocationChange === "function"
|
|
4450
|
+
? controller.onLocationChange(() => syncIcon())
|
|
4451
|
+
: null;
|
|
4452
|
+
return () => {
|
|
4453
|
+
if (typeof unlisten === "function") {
|
|
4454
|
+
try { unlisten(); } catch {}
|
|
4455
|
+
}
|
|
4456
|
+
if (unregIcon) {
|
|
4457
|
+
try { unregIcon(); } catch {}
|
|
4458
|
+
unregIcon = null;
|
|
4459
|
+
}
|
|
4460
|
+
};
|
|
4461
|
+
});
|
|
4462
|
+
}
|
|
4463
|
+
|
|
4405
4464
|
let unregSettings = null;
|
|
4406
|
-
let unregSettingsIcon = null;
|
|
4407
4465
|
const mountSettingsSection = () => {
|
|
4408
4466
|
if (unregSettings) return;
|
|
4409
|
-
try {
|
|
4410
|
-
const iconRes = ctx.slots.register({
|
|
4411
|
-
name: "settings.section.icon",
|
|
4412
|
-
id: "im-assistant",
|
|
4413
|
-
locale: IM_LOCALE_NS,
|
|
4414
|
-
}, ImNavIcon);
|
|
4415
|
-
unregSettingsIcon = typeof iconRes === "function" ? iconRes : () => {};
|
|
4416
|
-
} catch {}
|
|
4417
4467
|
const res = (ctx.slots.register({
|
|
4418
4468
|
name: "settings.section",
|
|
4419
4469
|
id: "im-assistant",
|
|
@@ -4433,10 +4483,6 @@ window.__ModuleLoader__.load({
|
|
|
4433
4483
|
};
|
|
4434
4484
|
|
|
4435
4485
|
const unmountSettingsSection = () => {
|
|
4436
|
-
if (unregSettingsIcon) {
|
|
4437
|
-
try { unregSettingsIcon(); } catch {}
|
|
4438
|
-
unregSettingsIcon = null;
|
|
4439
|
-
}
|
|
4440
4486
|
if (!unregSettings) return;
|
|
4441
4487
|
try { unregSettings(); } catch {}
|
|
4442
4488
|
unregSettings = null;
|
|
@@ -4464,6 +4510,8 @@ window.__ModuleLoader__.load({
|
|
|
4464
4510
|
};
|
|
4465
4511
|
});
|
|
4466
4512
|
|
|
4513
|
+
installSettingsIconSlot(ctx, sidebarController, ImNavIcon);
|
|
4514
|
+
|
|
4467
4515
|
if (sidebarController && typeof sidebarController.onLocationChange === "function") {
|
|
4468
4516
|
sidebarController.onLocationChange(() => syncSettingsSection());
|
|
4469
4517
|
}
|
package/lib/client.js
CHANGED
|
@@ -4718,9 +4718,8 @@ function observePluginUpdate(options) {
|
|
|
4718
4718
|
const isOwn = isOwnNavRow(getNavButtonText(button), typeof wantedLabel === "function" ? wantedLabel() : wantedLabel);
|
|
4719
4719
|
if (isOwn) {
|
|
4720
4720
|
const hasSlotIcon = Array.from((button && button.children) || []).some((child) =>
|
|
4721
|
-
child.tagName === "SPAN" &&
|
|
4722
|
-
|
|
4723
|
-
) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('[class*="navIcon"]'));
|
|
4721
|
+
child.tagName === "SPAN" && child.className && String(child.className).includes("navIcon")
|
|
4722
|
+
) || Boolean(button && typeof button.querySelector === "function" && button.querySelector('span[class*="navIcon"]'));
|
|
4724
4723
|
if (hasSlotIcon) {
|
|
4725
4724
|
if (button.hasAttribute(NAV_ICON_MARKER)) {
|
|
4726
4725
|
button.removeAttribute(NAV_ICON_MARKER);
|
|
@@ -4745,6 +4744,19 @@ function observePluginUpdate(options) {
|
|
|
4745
4744
|
return true;
|
|
4746
4745
|
}
|
|
4747
4746
|
|
|
4747
|
+
/**
|
|
4748
|
+
* 宿主是否已声明设置图标插槽。
|
|
4749
|
+
* 实测宿主公开面只暴露 `spec`(`specDynamic` 仅在 SlotCore 内部使用),
|
|
4750
|
+
* 两个都探是为了兼容将来把宽形式提到公开面的宿主;返回值可能是 null,
|
|
4751
|
+
* 所以统一按 `!= null` 判定,不能写 `!== undefined`。
|
|
4752
|
+
*/
|
|
4753
|
+
function hostDeclaresIconSlot(slots) {
|
|
4754
|
+
if (!slots) return false;
|
|
4755
|
+
if (typeof slots.specDynamic === "function" && slots.specDynamic("settings.section.icon") != null) return true;
|
|
4756
|
+
if (typeof slots.spec === "function" && slots.spec("settings.section.icon") != null) return true;
|
|
4757
|
+
return false;
|
|
4758
|
+
}
|
|
4759
|
+
|
|
4748
4760
|
function installSettingsNavIcon(targetCtx, resolveLabel) {
|
|
4749
4761
|
if (typeof document === "undefined") return;
|
|
4750
4762
|
ensureNavIconStyle(document);
|
|
@@ -4782,7 +4794,11 @@ function observePluginUpdate(options) {
|
|
|
4782
4794
|
}, "im-connect: settings nav icon");
|
|
4783
4795
|
}
|
|
4784
4796
|
|
|
4785
|
-
|
|
4797
|
+
const hasIconSlot = hostDeclaresIconSlot(ctx.slots);
|
|
4798
|
+
|
|
4799
|
+
if (!hasIconSlot) {
|
|
4800
|
+
installSettingsNavIcon(ctx, () => t("settings.label"));
|
|
4801
|
+
}
|
|
4786
4802
|
|
|
4787
4803
|
function ImNavIcon({ size = 16 }) {
|
|
4788
4804
|
return React.createElement(
|
|
@@ -4804,18 +4820,52 @@ function observePluginUpdate(options) {
|
|
|
4804
4820
|
);
|
|
4805
4821
|
}
|
|
4806
4822
|
|
|
4823
|
+
/**
|
|
4824
|
+
* 在宿主声明了 `settings.section.icon` 后注册插件图标,并跟随入口位置启停。
|
|
4825
|
+
* 注册动作必须自带清理:槽位声明被撤销后宿主会重跑 inject 回调,不返回 disposer
|
|
4826
|
+
* 会让本地 unregIcon 变成永久非空、图标再也注册不回去。
|
|
4827
|
+
* 注册失败只影响图标本身(宿主回退自带字形),不得把宿主 settings 壳的注册流程带崩。
|
|
4828
|
+
*/
|
|
4829
|
+
function installSettingsIconSlot(targetCtx, controller, IconComponent) {
|
|
4830
|
+
targetCtx.slots.inject("settings.section.icon", () => {
|
|
4831
|
+
let unregIcon = null;
|
|
4832
|
+
const syncIcon = () => {
|
|
4833
|
+
const shouldShow = controller && typeof controller.isSettingsSectionEnabled === "function"
|
|
4834
|
+
? controller.isSettingsSectionEnabled()
|
|
4835
|
+
: true;
|
|
4836
|
+
if (shouldShow && !unregIcon) {
|
|
4837
|
+
try {
|
|
4838
|
+
const res = targetCtx.slots.register({
|
|
4839
|
+
name: "settings.section.icon",
|
|
4840
|
+
id: "im-assistant",
|
|
4841
|
+
locale: IM_LOCALE_NS,
|
|
4842
|
+
}, IconComponent);
|
|
4843
|
+
unregIcon = typeof res === "function" ? res : () => {};
|
|
4844
|
+
} catch { /* 注册抛错时留空 unregIcon,等下一次位置变化重试 */ }
|
|
4845
|
+
} else if (!shouldShow && unregIcon) {
|
|
4846
|
+
try { unregIcon(); } catch {}
|
|
4847
|
+
unregIcon = null;
|
|
4848
|
+
}
|
|
4849
|
+
};
|
|
4850
|
+
syncIcon();
|
|
4851
|
+
const unlisten = controller && typeof controller.onLocationChange === "function"
|
|
4852
|
+
? controller.onLocationChange(() => syncIcon())
|
|
4853
|
+
: null;
|
|
4854
|
+
return () => {
|
|
4855
|
+
if (typeof unlisten === "function") {
|
|
4856
|
+
try { unlisten(); } catch {}
|
|
4857
|
+
}
|
|
4858
|
+
if (unregIcon) {
|
|
4859
|
+
try { unregIcon(); } catch {}
|
|
4860
|
+
unregIcon = null;
|
|
4861
|
+
}
|
|
4862
|
+
};
|
|
4863
|
+
});
|
|
4864
|
+
}
|
|
4865
|
+
|
|
4807
4866
|
let unregSettings = null;
|
|
4808
|
-
let unregSettingsIcon = null;
|
|
4809
4867
|
const mountSettingsSection = () => {
|
|
4810
4868
|
if (unregSettings) return;
|
|
4811
|
-
try {
|
|
4812
|
-
const iconRes = ctx.slots.register({
|
|
4813
|
-
name: "settings.section.icon",
|
|
4814
|
-
id: "im-assistant",
|
|
4815
|
-
locale: IM_LOCALE_NS,
|
|
4816
|
-
}, ImNavIcon);
|
|
4817
|
-
unregSettingsIcon = typeof iconRes === "function" ? iconRes : () => {};
|
|
4818
|
-
} catch {}
|
|
4819
4869
|
const res = (ctx.slots.register({
|
|
4820
4870
|
name: "settings.section",
|
|
4821
4871
|
id: "im-assistant",
|
|
@@ -4835,10 +4885,6 @@ function observePluginUpdate(options) {
|
|
|
4835
4885
|
};
|
|
4836
4886
|
|
|
4837
4887
|
const unmountSettingsSection = () => {
|
|
4838
|
-
if (unregSettingsIcon) {
|
|
4839
|
-
try { unregSettingsIcon(); } catch {}
|
|
4840
|
-
unregSettingsIcon = null;
|
|
4841
|
-
}
|
|
4842
4888
|
if (!unregSettings) return;
|
|
4843
4889
|
try { unregSettings(); } catch {}
|
|
4844
4890
|
unregSettings = null;
|
|
@@ -4866,6 +4912,8 @@ function observePluginUpdate(options) {
|
|
|
4866
4912
|
};
|
|
4867
4913
|
});
|
|
4868
4914
|
|
|
4915
|
+
installSettingsIconSlot(ctx, sidebarController, ImNavIcon);
|
|
4916
|
+
|
|
4869
4917
|
if (sidebarController && typeof sidebarController.onLocationChange === "function") {
|
|
4870
4918
|
sidebarController.onLocationChange(() => syncSettingsSection());
|
|
4871
4919
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@michengai/dsh-im-connect",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.25",
|
|
4
4
|
"description": "DSH IM Connect — 将主流即时通讯平台接入本机 DeepSeek Harness · Connect major messaging platforms to local DeepSeek Harness agents",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"packageManager": "pnpm@11.22.0",
|