@sunshaobei/dsh-session-manager 3.1.2 → 3.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/client.js +19 -12
  2. package/package.json +1 -1
package/client.js CHANGED
@@ -224,21 +224,28 @@ window.__ModuleLoader__.load({
224
224
  let hostTranslate;
225
225
 
226
226
  function attachHostLocale(ctx) {
227
- hostLocale = typeof ctx?.get === 'function' ? ctx.get('locale') : undefined;
227
+ try { hostLocale = ctx?.get?.('locale'); } catch { hostLocale = undefined; }
228
228
  if (!hostLocale || typeof hostLocale.register !== 'function' || typeof hostLocale.bind !== 'function') return;
229
+ let unsubLocale;
229
230
  try {
230
- const dispose = hostLocale.register(LOCALE_NS, MESSAGES);
231
- ctx.effect?.(() => dispose, 'session-trash: locale dictionaries');
232
- } catch {
233
- // A twin instance may already own the namespace; `bind` still resolves
234
- // the same dictionaries, so fall through and probe below.
231
+ hostLocale.register(LOCALE_NS, MESSAGES);
232
+ const bindNow = () => {
233
+ try {
234
+ const bound = hostLocale.bind(LOCALE_NS);
235
+ // Trust the service only once OUR keys resolve through it — translate()
236
+ // returns the raw key when the namespace carries no dictionary.
237
+ if (bound('recycleBin') !== 'recycleBin') hostTranslate = bound;
238
+ } catch { /* keep the built-in table */ }
239
+ };
240
+ bindNow();
241
+ // 语言切换时重绑(同 mcp-manager 的 subscribe 模式)
242
+ if (typeof hostLocale.subscribe === 'function' && typeof hostLocale.getSnapshot === 'function') {
243
+ unsubLocale = hostLocale.subscribe(bindNow);
244
+ }
245
+ } catch (error) {
246
+ console.warn('[dsh-session-manager] locale 注册失败:', error);
235
247
  }
236
- try {
237
- const bound = hostLocale.bind(LOCALE_NS);
238
- // Trust the service only once OUR keys resolve through it — translate()
239
- // returns the raw key when the namespace carries no dictionary.
240
- if (bound('recycleBin') !== 'recycleBin') hostTranslate = bound;
241
- } catch { /* keep the built-in table */ }
248
+ ctx.effect?.(() => () => { if (unsubLocale) unsubLocale(); }, 'session-trash: locale dictionaries');
242
249
  }
243
250
 
244
251
  function browserLocale() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sunshaobei/dsh-session-manager",
3
- "version": "3.1.2",
3
+ "version": "3.1.4",
4
4
  "description": "DSH 会话回收站:会话详情归档入口、回收站多选还原/彻底删除、活跃会话保护。 · Session trash & permanent delete for DeepSeek Harness.",
5
5
  "type": "module",
6
6
  "main": "index.js",