@lynn123411/dsh-chat-translate 3.2.0 → 3.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.md +4 -4
- package/assets/icon.svg +6 -0
- package/docs//351/205/215/347/275/256.md +2 -2
- package/lib/client.js +73 -211
- package/lib/client.js.map +4 -4
- package/lib/index.js +1 -1
- package/lib/index.js.map +3 -3
- package/lib/types/client/index.d.ts +11 -12
- package/lib/types/client/locales.d.ts +1 -3
- package/lib/types/client/settings/plugin-page.d.ts +18 -0
- package/lib/types/client/settings/ui.d.ts +12 -9
- package/locale/en.json +6 -0
- package/locale/zh.json +6 -0
- package/package.json +20 -13
- package/lib/types/client/reading-settings-page.d.ts +0 -92
|
@@ -1,16 +1,15 @@
|
|
|
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 keyed assistant-row takeover,
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
12
|
-
*
|
|
13
|
-
* unregistered.
|
|
4
|
+
* Declared services: slots for the keyed assistant-row takeover, this plugin's
|
|
5
|
+
* configuration page on the **Plugins** page, and the composer dock pill;
|
|
6
|
+
* configForms for this plugin's own configuration form plus the host `ui-chat`
|
|
7
|
+
* entry whose `transcriptView` field drives the reasoning-row presentation
|
|
8
|
+
* policy; the remote + remote.credentials pair for the credentials Remote
|
|
9
|
+
* namespace; and locale for the card's own dictionary. The runtime withholds
|
|
10
|
+
* any service not declared here; `locale` is declared rather than sampled
|
|
11
|
+
* because `ctx.get('locale')` at apply time can beat the locale plugin's
|
|
12
|
+
* `provide`, which silently left the card's dictionary unregistered.
|
|
14
13
|
*/
|
|
15
14
|
export declare const inject: string[];
|
|
16
15
|
interface ClientContext {
|
|
@@ -30,8 +29,8 @@ interface ClientContext {
|
|
|
30
29
|
}
|
|
31
30
|
/**
|
|
32
31
|
* Mount the assistant-row takeover (keyed `conversation.chat.node` /
|
|
33
|
-
* `assistant-step`),
|
|
34
|
-
*
|
|
32
|
+
* `assistant-step`), this plugin's configuration page on the **Plugins** page,
|
|
33
|
+
* and the translation toggle in the composer dock.
|
|
35
34
|
* @param ctx - DSH browser client context.
|
|
36
35
|
*/
|
|
37
36
|
export declare function apply(ctx: ClientContext): void;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/** Locale bundles for the chat-translate card
|
|
1
|
+
/** Locale bundles for the chat-translate card on the DSH Plugins page. */
|
|
2
2
|
/** Dictionary namespace owned by this plugin's settings card. */
|
|
3
3
|
export declare const NS = "settings.chatTranslate";
|
|
4
4
|
/**
|
|
@@ -7,8 +7,6 @@ export declare const NS = "settings.chatTranslate";
|
|
|
7
7
|
* inline technical samples rendered by `withSamples` at the call site.
|
|
8
8
|
*/
|
|
9
9
|
export declare const zh: {
|
|
10
|
-
readonly pageNav: "阅读体验";
|
|
11
|
-
readonly title: "正文翻译";
|
|
12
10
|
readonly masterTitle: "翻译总开关";
|
|
13
11
|
readonly enableTranslation: "启用翻译";
|
|
14
12
|
readonly masterDesc: "自动把助手回答正文翻成中文(如 {example}):折叠块里的过程正文与最终汇总一视同仁,整段中文的块也照送,由模型一并改写成自然中文、顺掉机器腔。Think 卡与工具调用行不翻,代码块原样保留。正文块的左缘一条竖线报出状态:正在读译文是蓝线,备着译文正读原文是灰细线,没译成是红实线(鼠标悬停热区报出通道细节——超时、断流或空返回;译文的结构漂移由宿主自动修回或重掷,不再因格式问题挂红线),正在请求是灰脉动线,没送过模型或开关关闭没有线。切换不在正文上:贴着那条线的窄带才是操作区,鼠标移到它上面变手型,点一下在译文与原文间切换——正文整块不再响应点击,选字、拖选复制都不会误触;模型认为原样最好、返回一模一样的文字时同样算翻译过、同样可切。挂红线的块右侧常驻一个小 ↻,点那条窄带即整行重新翻译,已成功的块保持显示不打扰。通道失败不自动重试,恢复后由你点那条窄带救活。译文按原 markdown 格式重新渲染,表格、列表、加粗与行内代码保持结构。回答还在流式输出时不翻,落定后按阅读顺序逐段出中文。只作用于当前查看的会话,译文不写回会话上下文。输入框下方那一行有同款开关,两处状态同步。";
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/** The Plugins page slot a bundle's own configuration registers into. */
|
|
2
|
+
export declare const BUNDLE_CONFIG_SLOT = "plugins.bundle.config";
|
|
3
|
+
/** This plugin's own config key: the bundle's package name. */
|
|
4
|
+
export declare const BUNDLE_CONFIG_KEY = "@lynn123411/dsh-chat-translate";
|
|
5
|
+
/** Services this registration needs from the browser runtime. */
|
|
6
|
+
interface PluginPageSlots {
|
|
7
|
+
inject(name: string, callback: () => unknown): () => void;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* Contribute this plugin's configuration page to the Plugins page.
|
|
11
|
+
* @param slots - the client slot registry.
|
|
12
|
+
* @param register - registers the page component; returns its disposer.
|
|
13
|
+
* @returns A disposer releasing the contribution, or a no-op when the browser
|
|
14
|
+
* runtime hands no slot registry at all (the plugin's other seats stay mounted
|
|
15
|
+
* either way). A throwing `inject` is a real contract violation and propagates.
|
|
16
|
+
*/
|
|
17
|
+
export declare function setupPluginPage(slots: PluginPageSlots | null | undefined, register: () => () => void): () => void;
|
|
18
|
+
export {};
|
|
@@ -2,19 +2,22 @@ import * as React from 'react';
|
|
|
2
2
|
import type { PropsLocale, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
3
3
|
import { NS } from '../locales.ts';
|
|
4
4
|
/**
|
|
5
|
-
* Chat-translate's
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
5
|
+
* Chat-translate's own configuration page inside the DSH **Plugins** page.
|
|
6
|
+
*
|
|
7
|
+
* The host's Plugins page owns per-plugin configuration: it draws the icon, the
|
|
8
|
+
* title and the crumb, and renders a `plugins.bundle.config` entry ON the
|
|
9
|
+
* bundle's own page, under its description and above its rows. The card keeps
|
|
10
|
+
* its own chrome — the switches, the credential form, the section order — so the
|
|
11
|
+
* move from the Settings page changed where it is reached from, not what it does.
|
|
12
|
+
* @param props - renderer-bound seat of the `plugins.bundle.config` slot: the
|
|
13
|
+
* `view` asked for plus the `t` seat its `locale: NS` registration injects.
|
|
10
14
|
* @returns The card element.
|
|
11
15
|
*/
|
|
12
|
-
export declare function TidySettingsPanel(props: PropsRuntime<'
|
|
16
|
+
export declare function TidySettingsPanel(props: PropsRuntime<'plugins.bundle.config'> & PropsLocale<typeof NS>): React.ReactElement;
|
|
13
17
|
/**
|
|
14
18
|
* Bind the settings store to this plugin's own configuration form and the
|
|
15
|
-
* credentials Remote API, then
|
|
16
|
-
*
|
|
17
|
-
* card into its child slot.
|
|
19
|
+
* credentials Remote API, then contribute this plugin's configuration page to
|
|
20
|
+
* the DSH **Plugins** page.
|
|
18
21
|
* @param ctx - DSH browser client context.
|
|
19
22
|
*/
|
|
20
23
|
export declare function setupSettingsUi(ctx: any): void;
|
package/locale/en.json
ADDED
package/locale/zh.json
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lynn123411/dsh-chat-translate",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.3.0",
|
|
4
4
|
"description": "Assistant reply-body translation for the DeepSeek Harness Web UI (OpenAI-compatible channel)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "lynn123411",
|
|
@@ -38,6 +38,8 @@
|
|
|
38
38
|
"default": "./lib/client.js"
|
|
39
39
|
},
|
|
40
40
|
"./cordis.patch.yml": "./cordis.patch.yml",
|
|
41
|
+
"./locale/en.json": "./locale/en.json",
|
|
42
|
+
"./locale/zh.json": "./locale/zh.json",
|
|
41
43
|
"./package.json": "./package.json"
|
|
42
44
|
},
|
|
43
45
|
"dsh": {
|
|
@@ -48,13 +50,16 @@
|
|
|
48
50
|
"platform": "web",
|
|
49
51
|
"immediately": true,
|
|
50
52
|
"inject": [
|
|
51
|
-
"@deepseek-ai/dsh-client-ui-primitives"
|
|
53
|
+
"@deepseek-ai/dsh-client-ui-primitives",
|
|
54
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager"
|
|
52
55
|
]
|
|
53
56
|
}
|
|
54
57
|
},
|
|
55
58
|
"files": [
|
|
56
59
|
"lib",
|
|
57
60
|
"docs",
|
|
61
|
+
"assets",
|
|
62
|
+
"locale",
|
|
58
63
|
"cordis.patch.yml",
|
|
59
64
|
"README.md"
|
|
60
65
|
],
|
|
@@ -67,16 +72,16 @@
|
|
|
67
72
|
},
|
|
68
73
|
"engines": {
|
|
69
74
|
"node": "^22.19 || >=24",
|
|
70
|
-
"dsh": ">=0.
|
|
75
|
+
"dsh": ">=0.2.0-rc.2"
|
|
71
76
|
},
|
|
72
77
|
"devDependencies": {
|
|
73
78
|
"@deepseek-ai/cordis": "^4.0.4",
|
|
74
|
-
"@deepseek-ai/dsh-client-connection": ">=0.
|
|
75
|
-
"@deepseek-ai/dsh-client-ui-primitives": ">=0.
|
|
76
|
-
"@deepseek-ai/dsh-client-ui-renderer": ">=0.
|
|
77
|
-
"@deepseek-ai/dsh-client-ui-settings": ">=0.
|
|
78
|
-
"@deepseek-ai/dsh-client-ui-slots": ">=0.
|
|
79
|
-
"@deepseek-ai/dsh-home-paths": ">=0.
|
|
79
|
+
"@deepseek-ai/dsh-client-connection": ">=0.2.0-rc.2",
|
|
80
|
+
"@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.2",
|
|
81
|
+
"@deepseek-ai/dsh-client-ui-renderer": ">=0.2.0-rc.2",
|
|
82
|
+
"@deepseek-ai/dsh-client-ui-settings": ">=0.2.0-rc.2",
|
|
83
|
+
"@deepseek-ai/dsh-client-ui-slots": ">=0.2.0-rc.2",
|
|
84
|
+
"@deepseek-ai/dsh-home-paths": ">=0.2.0-rc.2",
|
|
80
85
|
"@deepseek-ai/schemastery": "^3.18.4",
|
|
81
86
|
"@eslint/js": "^9.30.0",
|
|
82
87
|
"@types/node": "^22.19.0",
|
|
@@ -85,15 +90,17 @@
|
|
|
85
90
|
"jsdom": "^26.1.0",
|
|
86
91
|
"react": "^18.3.1",
|
|
87
92
|
"react-dom": "^18.3.1",
|
|
88
|
-
"typescript": "^6.0.0"
|
|
93
|
+
"typescript": "^6.0.0",
|
|
94
|
+
"@deepseek-ai/dsh-client-ui-plugin-manager": ">=0.2.0-rc.2"
|
|
89
95
|
},
|
|
90
96
|
"peerDependencies": {
|
|
91
|
-
"@deepseek-ai/dsh-client-ui-primitives": ">=0.
|
|
92
|
-
"@deepseek-ai/dsh-home-paths": ">=0.
|
|
97
|
+
"@deepseek-ai/dsh-client-ui-primitives": ">=0.2.0-rc.2",
|
|
98
|
+
"@deepseek-ai/dsh-home-paths": ">=0.2.0-rc.2"
|
|
93
99
|
},
|
|
94
100
|
"peerDependenciesMeta": {
|
|
95
101
|
"@deepseek-ai/dsh-client-ui-primitives": {
|
|
96
102
|
"optional": true
|
|
97
103
|
}
|
|
98
|
-
}
|
|
104
|
+
},
|
|
105
|
+
"icon": "./assets/icon.svg"
|
|
99
106
|
}
|
|
@@ -1,92 +0,0 @@
|
|
|
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-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
|
-
* Settings storage belongs to the card, not to this shell: since 0.1.7 a
|
|
30
|
-
* participant reads and writes its own Config through
|
|
31
|
-
* `ctx.configForms.get(<profile entry id>)` and gates the registration on
|
|
32
|
-
* `ctx.configForms.whileServed(...)`. The shell only stacks cards — it holds no
|
|
33
|
-
* settings service of its own, which is why it needs nothing beyond
|
|
34
|
-
* `ctx.slots` and the optional `locale`.
|
|
35
|
-
*/
|
|
36
|
-
import type { Context as ClientContext } from '@deepseek-ai/cordis';
|
|
37
|
-
import type { InjectFace, LocaleNamespaceMap, PropsRenderSlots, PropsRuntime } from '@deepseek-ai/dsh-client-ui-slots';
|
|
38
|
-
/** Page id claimed by the first participating plugin to activate. */
|
|
39
|
-
export declare const READING_PAGE_ID = "reading";
|
|
40
|
-
/** Sidebar position of the shared page; own plugins start at 110. */
|
|
41
|
-
export declare const READING_PAGE_ORDER = 110;
|
|
42
|
-
/** The page's one child slot: every participant's card registers here. */
|
|
43
|
-
export declare const READING_ITEM_SLOT = "reading.settings.item";
|
|
44
|
-
declare module '@deepseek-ai/dsh-client-ui-slots' {
|
|
45
|
-
interface SlotMap {
|
|
46
|
-
/** One participating plugin's card inside the shared reading page. */
|
|
47
|
-
'reading.settings.item': {
|
|
48
|
-
kind: 'list';
|
|
49
|
-
scope: 'root';
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
/** One participant's tab, derived from its card registration. */
|
|
54
|
-
export interface ReadingTab {
|
|
55
|
-
/** Registration id — the participant's Host settings namespace. */
|
|
56
|
-
id: string;
|
|
57
|
-
/** Registration order, ascending in the tab bar. */
|
|
58
|
-
order: number;
|
|
59
|
-
/** Registration label, already resolved for the active locale. */
|
|
60
|
-
label: string;
|
|
61
|
-
}
|
|
62
|
-
/** Live tab roster handed to the page component through its inject face. */
|
|
63
|
-
export interface ReadingTabsFace {
|
|
64
|
-
getSnapshot(): readonly ReadingTab[];
|
|
65
|
-
subscribe(listener: () => void): () => void;
|
|
66
|
-
}
|
|
67
|
-
/** Inject face of the shared page. */
|
|
68
|
-
export interface ReadingPageFace {
|
|
69
|
-
readingTabs: ReadingTabsFace;
|
|
70
|
-
}
|
|
71
|
-
type ReadingPageProps = PropsRuntime<'settings.section'> & PropsRenderSlots<typeof READING_ITEM_SLOT> & InjectFace<ReadingPageFace>;
|
|
72
|
-
/**
|
|
73
|
-
* Page body: one tab per registered card, plus the selected card's panel.
|
|
74
|
-
* The shell supplies the section's own seats and `renderSlot` bound to the
|
|
75
|
-
* child slot declared at registration time.
|
|
76
|
-
*/
|
|
77
|
-
export declare function ReadingSettingsSection({ renderSlot, readingTabs }: ReadingPageProps): import("react").DetailedReactHTMLElement<import("react").HTMLAttributes<HTMLElement>, HTMLElement> | null;
|
|
78
|
-
/** Whether a participant already holds the shared page. */
|
|
79
|
-
export declare function readingPageClaimed(ctx: ClientContext): boolean;
|
|
80
|
-
/**
|
|
81
|
-
* Claim the shared page when no participant holds it yet. Call inside
|
|
82
|
-
* `ctx.slots.inject('settings.section', …)`: injection order decides the
|
|
83
|
-
* winner, and the losers stay silent instead of colliding with the kernel's
|
|
84
|
-
* duplicate-id and duplicate-declaration guards.
|
|
85
|
-
* @param ctx - browser context carrying the slot registry.
|
|
86
|
-
* @param label - page label, re-read by the shell on every projection.
|
|
87
|
-
* @param locale - locale namespace the label thunk translates through.
|
|
88
|
-
* @returns The page registration's disposer, or a no-op when another
|
|
89
|
-
* participant already holds the page.
|
|
90
|
-
*/
|
|
91
|
-
export declare function claimReadingSettingsPage(ctx: ClientContext, label: () => string, locale: keyof LocaleNamespaceMap & string): () => void;
|
|
92
|
-
export {};
|