@lynn123411/dsh-chat-translate 1.2.5 → 1.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.
@@ -1,10 +1,12 @@
1
1
  /** Client plugin name, shared with the browser bundle id. */
2
2
  export declare const name = "dsh-chat-translate";
3
3
  /**
4
- * Declared services: slots for the settings section, settingsScope for the
5
- * per-namespace settings mirror, and the remote + remote.credentials pair for
6
- * the credentials Remote namespace — the runtime withholds any service not
7
- * declared here, so `ctx.remote.credentials` would be undefined otherwise.
4
+ * Declared services: slots for the shared 「阅读体验」 settings page (page claim
5
+ * plus the card registration), settingsScope for the per-namespace settings
6
+ * mirror, and the remote + remote.credentials pair for the credentials Remote
7
+ * namespace — the runtime withholds any service not declared here, so
8
+ * `ctx.remote.credentials` would be undefined otherwise. The locale service is
9
+ * optional and read through `ctx.get`, like the renderer's slots registry.
8
10
  */
9
11
  export declare const inject: string[];
10
12
  interface ClientContext {
@@ -12,12 +14,14 @@ interface ClientContext {
12
14
  get?(serviceName: string): any;
13
15
  slots?: any;
14
16
  settingsScope?: any;
17
+ locale?: any;
15
18
  remote?: {
16
19
  credentials?: any;
17
20
  };
18
21
  }
19
22
  /**
20
- * Mount the tool-call / think-summary translation observer and the settings UI.
23
+ * Mount the tool-call / think-summary translation observer and the settings UI
24
+ * card inside the shared reading-settings page.
21
25
  * @param ctx - DSH browser client context.
22
26
  */
23
27
  export declare function apply(ctx: ClientContext): void;
@@ -0,0 +1,14 @@
1
+ /** Locale bundles for the chat-translate card inside the shared 「阅读体验」 page. */
2
+ /** Dictionary namespace owned by this plugin's settings card. */
3
+ export declare const NS = "settings.chatTranslate";
4
+ /** Locale keys this plugin renders. */
5
+ export type ChatTranslateLocaleKey = 'pageNav' | 'title';
6
+ /** English copy. */
7
+ export declare const en: Record<ChatTranslateLocaleKey, string>;
8
+ /** Chinese copy. */
9
+ export declare const zh: Record<ChatTranslateLocaleKey, string>;
10
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
11
+ interface LocaleNamespaceMap {
12
+ 'settings.chatTranslate': ChatTranslateLocaleKey;
13
+ }
14
+ }
@@ -0,0 +1,85 @@
1
+ /**
2
+ * The shared 「阅读体验」 settings page.
3
+ *
4
+ * Several plugins contribute their configuration to ONE settings page, but the
5
+ * kernel cannot declare that page jointly: `settings.section` is a list slot
6
+ * that rejects a duplicate `id` at the same priority ("already has an entry
7
+ * with id"), and a child slot may be declared exactly once ("slot … is already
8
+ * declared"). Composing several cards into one page therefore takes one
9
+ * declarer, so every participating plugin carries this same shell and the
10
+ * FIRST one to activate claims the page; the others register their card into
11
+ * {@link READING_ITEM_SLOT} and wait for the winner's declaration through
12
+ * `slots.inject`. Uninstalling the winner promotes another participant on the
13
+ * next boot, so no participant is a fixed owner.
14
+ *
15
+ * The page renders ONE TAB PER REGISTERED CARD: the tab roster comes from the
16
+ * child slot's own registrations (id + `label` + `order`, the same shape the
17
+ * kernel's own Plugins page uses for its tabs), and each panel dispatches
18
+ * through `renderSlot(READING_ITEM_SLOT, {}, { only: id })`. Every panel stays
19
+ * mounted but hidden, so a card's local state survives a tab switch.
20
+ *
21
+ * Keep this file identical across the participating plugins
22
+ * (`dsh-smooth-stream`, `dsh-oil-sticky-prompt`, `dsh-chat-translate`).
23
+ * Participants own their own card component, locale dictionaries, settings
24
+ * namespace and Host half — only the page shell below is shared, because
25
+ * cross-plugin value imports are forbidden by the client bundle purity gate.
26
+ * It imports nothing but `react` plus type-only DSH packages on purpose, so
27
+ * every participant's build configuration compiles it unchanged.
28
+ */
29
+ import type { Context as ClientContext } from '@deepseek-ai/cordis';
30
+ import type { InjectFace, LocaleNamespaceMap, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
31
+ /** Page id claimed by the first participating plugin to activate. */
32
+ export declare const READING_PAGE_ID = "reading";
33
+ /** Sidebar position of the shared page; own plugins start at 110. */
34
+ export declare const READING_PAGE_ORDER = 110;
35
+ /** The page's one child slot: every participant's card registers here. */
36
+ export declare const READING_ITEM_SLOT = "reading.settings.item";
37
+ declare module '@deepseek-ai/dsh-client-ui-slots' {
38
+ interface SlotMap {
39
+ /** One participating plugin's card inside the shared reading page. */
40
+ 'reading.settings.item': {
41
+ kind: 'list';
42
+ scope: 'root';
43
+ };
44
+ }
45
+ }
46
+ /** One participant's tab, derived from its card registration. */
47
+ export interface ReadingTab {
48
+ /** Registration id — the participant's Host settings namespace. */
49
+ id: string;
50
+ /** Registration order, ascending in the tab bar. */
51
+ order: number;
52
+ /** Registration label, already resolved for the active locale. */
53
+ label: string;
54
+ }
55
+ /** Live tab roster handed to the page component through its inject face. */
56
+ export interface ReadingTabsFace {
57
+ getSnapshot(): readonly ReadingTab[];
58
+ subscribe(listener: () => void): () => void;
59
+ }
60
+ /** Inject face of the shared page. */
61
+ export interface ReadingPageFace {
62
+ readingTabs: ReadingTabsFace;
63
+ }
64
+ type ReadingPageProps = PropsRuntime<'settings.section'> & PropsRenderSlots<typeof READING_ITEM_SLOT> & InjectFace<ReadingPageFace>;
65
+ /**
66
+ * Page body: one tab per registered card, plus the selected card's panel.
67
+ * The shell supplies the section's own seats and `renderSlot` bound to the
68
+ * child slot declared at registration time.
69
+ */
70
+ export declare function ReadingSettingsSection({ renderSlot, readingTabs }: ReadingPageProps): import("react").DetailedReactHTMLElement<import("react").HTMLAttributes<HTMLElement>, HTMLElement> | null;
71
+ /** Whether a participant already holds the shared page. */
72
+ export declare function readingPageClaimed(ctx: ClientContext): boolean;
73
+ /**
74
+ * Claim the shared page when no participant holds it yet. Call inside
75
+ * `ctx.slots.inject('settings.section', …)`: injection order decides the
76
+ * winner, and the losers stay silent instead of colliding with the kernel's
77
+ * duplicate-id and duplicate-declaration guards.
78
+ * @param ctx - browser context carrying the slot registry.
79
+ * @param label - page label, re-read by the shell on every projection.
80
+ * @param locale - locale namespace the label thunk translates through.
81
+ * @returns The page registration's disposer, or a no-op when another
82
+ * participant already holds the page.
83
+ */
84
+ export declare function claimReadingSettingsPage(ctx: ClientContext, label: () => string, locale: keyof LocaleNamespaceMap & string): () => void;
85
+ export {};
@@ -1,3 +1,17 @@
1
1
  import * as React from 'react';
2
- export declare function TidySettingsPanel(): React.ReactElement;
2
+ import type { PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
3
+ /**
4
+ * Chat-translate's card inside the shared 「阅读体验」 settings page. The card
5
+ * keeps its own chrome (title rows, switches, credential form); the shared page
6
+ * only stacks the participants' cards.
7
+ * @param _props - renderer-bound seat of the `reading.settings.item` slot.
8
+ * @returns The card element.
9
+ */
10
+ export declare function TidySettingsPanel(_props: PropsRuntime<'reading.settings.item'>): React.ReactElement;
11
+ /**
12
+ * Bind the settings store to DSH's native settings/credentials services and
13
+ * join the shared 「阅读体验」 settings page: whichever participant activates
14
+ * first claims the page, everyone registers a card into its child slot.
15
+ * @param ctx - DSH browser client context; services are resolved defensively.
16
+ */
3
17
  export declare function setupSettingsUi(ctx: any): void;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 把 fetch / 网络失败的可读原因展开成单行文本(宿主与客户端共用)。
3
+ *
4
+ * 背景:Node 18+ 与浏览器的 fetch 在网络层失败时只给一句 `TypeError: fetch failed`
5
+ * (浏览器是 `Failed to fetch`),真实原因藏在 `err.cause` 里——例如
6
+ * `connect ENETUNREACH 172.24.52.126:8081`、`other side closed [UND_ERR_SOCKET]`、
7
+ * `getaddrinfo ENOTFOUND`。只上报 `err.message` 会让「端点不可达 / 被代理断开」和
8
+ * 「插件自身出错」长得一模一样:用户只看到无信息量的 fetch failed,无从判断该改什么。
9
+ *
10
+ * 这里把 message 与 cause 链(含 AggregateError 的多地址失败)拼成 `A ← B ← C`。
11
+ */
12
+ export declare function describeError(err: unknown): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lynn123411/dsh-chat-translate",
3
- "version": "1.2.5",
3
+ "version": "1.3.0",
4
4
  "description": "Tool-call & think-summary translation with dual AI (OpenAI-compatible) + Bing channels for the DeepSeek Harness Web UI",
5
5
  "license": "MIT",
6
6
  "author": "lynn123411",
@@ -60,12 +60,16 @@
60
60
  "scripts": {
61
61
  "build": "node build.mjs",
62
62
  "typecheck": "tsc -p tsconfig.json --noEmit",
63
- "test": "node scripts/test-regression-suite.mjs && node scripts/test-channel-logic.mjs && node scripts/test-store.mjs && node scripts/test-toggle-restore.mjs"
63
+ "test": "node scripts/test-client-wiring.mjs && node scripts/test-regression-suite.mjs && node scripts/test-channel-logic.mjs && node scripts/test-store.mjs && node scripts/test-toggle-restore.mjs"
64
64
  },
65
65
  "engines": {
66
66
  "node": "^22.19 || >=24"
67
67
  },
68
68
  "devDependencies": {
69
+ "@deepseek-ai/cordis": "4.0.2",
70
+ "@deepseek-ai/dsh-client-ui-renderer": "0.1.5-rc.1",
71
+ "@deepseek-ai/dsh-client-ui-settings": "0.1.5-rc.1",
72
+ "@deepseek-ai/dsh-client-ui-slots": "0.1.5-rc.1",
69
73
  "@deepseek-ai/dsh-home-paths": "^0.1.5-rc.1",
70
74
  "@deepseek-ai/schemastery": "^3.18.2",
71
75
  "@eslint/js": "^9.30.0",