@lynn123411/dsh-chat-translate 3.8.1 → 3.9.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/DETAILS.md +6 -6
- package/README.md +2 -2
- package/lib/client.js +97 -109
- package/lib/client.js.map +3 -3
- package/lib/types/client/locales.d.ts +3 -8
- package/lib/types/client/settings/store.d.ts +31 -34
- package/lib/types/client/settings/ui.d.ts +4 -4
- package/package.json +1 -1
|
@@ -15,12 +15,10 @@ export declare const zh: {
|
|
|
15
15
|
readonly badgeConfigured: "已配置";
|
|
16
16
|
readonly badgeUnconfigured: "未配置";
|
|
17
17
|
readonly apiKeyTitle: "API Key";
|
|
18
|
-
readonly apiKeyDesc: "保存至 {home} 的 {ref}
|
|
18
|
+
readonly apiKeyDesc: "保存至 {home} 的 {ref},离开输入框即保存生效;留空离开 = 清除";
|
|
19
19
|
readonly apiKeyPlaceholderConfigured: "已配置(如需更换请直接输入)";
|
|
20
|
-
readonly save: "保存";
|
|
21
20
|
readonly saving: "保存中…";
|
|
22
|
-
readonly
|
|
23
|
-
readonly keyCleared: "已清除 API Key(未配置时正文保持原文,不会翻译)";
|
|
21
|
+
readonly autoSaveHint: "改动在离开输入框时自动保存";
|
|
24
22
|
readonly saveFailed: "保存失败:{error}";
|
|
25
23
|
readonly unknownError: "未知错误";
|
|
26
24
|
readonly baseUrlTitle: "Base URL";
|
|
@@ -33,12 +31,9 @@ export declare const zh: {
|
|
|
33
31
|
readonly testing: "测试中…";
|
|
34
32
|
readonly testOk: "连接正常,延迟 {latency}ms";
|
|
35
33
|
readonly testFail: "失败:{error}";
|
|
36
|
-
readonly unsavedHint: "改动保存后才生效";
|
|
37
34
|
readonly invalidTimeout: "超时填写不合法:请填 500 到 900000 之间的毫秒数";
|
|
38
|
-
readonly saveProbeOk: "设置已保存,通道连接正常";
|
|
39
|
-
readonly saveProbeFail: "设置已保存,但通道探测失败:{error}";
|
|
40
35
|
readonly promptTitle: "翻译提示词";
|
|
41
|
-
readonly promptDesc: "
|
|
36
|
+
readonly promptDesc: "拼在待译正文前面的那段指令。点「编辑」可以改写,离开输入框或点「完成」后立即生效;留空等于用内置默认。";
|
|
42
37
|
readonly promptEdit: "编辑";
|
|
43
38
|
readonly promptDone: "完成";
|
|
44
39
|
readonly promptRestore: "恢复默认";
|
|
@@ -1,22 +1,21 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* This plugin's configuration page state: what the Host serves, what the reader
|
|
3
|
-
* has staged on the page, and what a
|
|
3
|
+
* has staged on the page, and what a commit would write.
|
|
4
4
|
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* a draft never changes what is already on screen.
|
|
5
|
+
* Every control stages its edit in a draft, and a draft is written as soon as
|
|
6
|
+
* the reader leaves that control: there is no save button. Leaving a control
|
|
7
|
+
* that holds an invalid value (an out-of-range timeout) writes nothing, so a
|
|
8
|
+
* bad number never reaches the Host; the page shows why and keeps the draft for
|
|
9
|
+
* correction.
|
|
11
10
|
*
|
|
12
11
|
* The API Key is staged the same way but written through the credentials
|
|
13
|
-
* Remote on the same
|
|
12
|
+
* Remote on the same commit, so the key and the rest of the settings land as
|
|
14
13
|
* one gesture.
|
|
15
14
|
*
|
|
16
15
|
* The prompt is staged like any text control, with one twist: the control shows
|
|
17
16
|
* the *effective* instruction, so an untouched plugin displays the built-in
|
|
18
|
-
* default in full.
|
|
19
|
-
* "empty means the built-in default" true in the stored document.
|
|
17
|
+
* default in full. Committing that exact text clears the field again, which
|
|
18
|
+
* keeps "empty means the built-in default" true in the stored document.
|
|
20
19
|
*/
|
|
21
20
|
/** Resolved config as the Host serves it, plus the derived readiness flag. */
|
|
22
21
|
export interface CommittedConfig {
|
|
@@ -38,12 +37,6 @@ export interface DraftField {
|
|
|
38
37
|
/** Whether the draft is not a value this field accepts (blocks saving). */
|
|
39
38
|
invalid: boolean;
|
|
40
39
|
}
|
|
41
|
-
/** The channel probe run by one save: what the settings page reports. */
|
|
42
|
-
export interface ProbeState {
|
|
43
|
-
running: boolean;
|
|
44
|
-
ok?: boolean;
|
|
45
|
-
message?: string;
|
|
46
|
-
}
|
|
47
40
|
/** Everything the page renders. */
|
|
48
41
|
export interface SettingsPageState {
|
|
49
42
|
/** False while the Host does not serve this plugin's config entry. */
|
|
@@ -76,10 +69,8 @@ export interface SettingsPageState {
|
|
|
76
69
|
/** Whether any draft is invalid, which blocks the save. */
|
|
77
70
|
invalid: boolean;
|
|
78
71
|
saving: boolean;
|
|
79
|
-
/** The last
|
|
72
|
+
/** The last commit did not land: drafts stay for correction. */
|
|
80
73
|
saveFailed: boolean;
|
|
81
|
-
/** Probe from the last save; undefined until a save ran. */
|
|
82
|
-
probe?: ProbeState;
|
|
83
74
|
}
|
|
84
75
|
/** Profile entry id (== settings namespace) + credentials ref. */
|
|
85
76
|
export declare const SETTINGS_NAMESPACE = "dsh-chat-translate";
|
|
@@ -151,11 +142,11 @@ export interface CredentialsRemoteLike {
|
|
|
151
142
|
export declare function parseTimeout(text: string): number | null | undefined;
|
|
152
143
|
/**
|
|
153
144
|
* The configuration page's own store: committed reads for the whole client,
|
|
154
|
-
* plus the drafts and the
|
|
145
|
+
* plus the drafts and the commit this page alone owns.
|
|
155
146
|
*
|
|
156
147
|
* `update` is the surface for controls outside the page — the composer dock
|
|
157
148
|
* toggle writes the master switch straight through, which is the one place a
|
|
158
|
-
* click takes effect without a
|
|
149
|
+
* click takes effect without leaving a control.
|
|
159
150
|
*/
|
|
160
151
|
declare class SettingsStore {
|
|
161
152
|
private state;
|
|
@@ -170,6 +161,8 @@ declare class SettingsStore {
|
|
|
170
161
|
* 输入框下方的「译」胶囊)不该把没保存的草稿冲掉。
|
|
171
162
|
*/
|
|
172
163
|
private seeded;
|
|
164
|
+
/** One in-flight commit shared by every control that leaves at once. */
|
|
165
|
+
private inflight;
|
|
173
166
|
/**
|
|
174
167
|
* Bind the DSH services. Called once from the settings UI setup; re-binding
|
|
175
168
|
* (e.g. after a reconnect) detaches the previous subscription first.
|
|
@@ -192,22 +185,23 @@ declare class SettingsStore {
|
|
|
192
185
|
/** Fold dirty/invalid from every draft into the page-level flags. */
|
|
193
186
|
private recomputeGate;
|
|
194
187
|
/**
|
|
195
|
-
* Stage one text control. The draft is local: nothing leaves this page
|
|
196
|
-
*
|
|
188
|
+
* Stage one text control. The draft is local: nothing leaves this page while
|
|
189
|
+
* the reader types, so a half-typed Base URL never reaches the translation
|
|
190
|
+
* path. The control's blur commits it (see {@link save}).
|
|
197
191
|
*/
|
|
198
192
|
draft(field: 'baseUrl' | 'model' | 'aiTimeoutMs' | 'prompt' | 'apiKey', text: string): void;
|
|
199
193
|
/**
|
|
200
194
|
* Put the built-in instruction back into the draft.
|
|
201
195
|
*
|
|
202
|
-
* Restoring is intentionally a draft edit like typing:
|
|
203
|
-
*
|
|
204
|
-
* the field itself.
|
|
196
|
+
* Restoring is intentionally a draft edit like typing: it becomes committed
|
|
197
|
+
* when the reader leaves the field, so the button beside the field behaves
|
|
198
|
+
* exactly like the field itself.
|
|
205
199
|
*/
|
|
206
200
|
restoreDefaultPrompt(): void;
|
|
207
201
|
/**
|
|
208
202
|
* The master switch, written straight through: the composer dock pill and the
|
|
209
|
-
* page's own switch are two entries into one state, and the pill has no
|
|
210
|
-
*
|
|
203
|
+
* page's own switch are two entries into one state, and the pill has no field
|
|
204
|
+
* to leave.
|
|
211
205
|
*/
|
|
212
206
|
setEnabled(enabled: boolean): Promise<void>;
|
|
213
207
|
/**
|
|
@@ -217,20 +211,23 @@ declare class SettingsStore {
|
|
|
217
211
|
* staged no change — the effective prompt is still the default. Leaving the
|
|
218
212
|
* box blank in that state would contradict what the card promises (the box
|
|
219
213
|
* always shows what the model receives), so it is filled in again. Called when
|
|
220
|
-
* a
|
|
214
|
+
* a commit lands and when the reader leaves the editing state.
|
|
221
215
|
*/
|
|
222
216
|
settlePromptDraft(): void;
|
|
223
217
|
/**
|
|
224
|
-
* Write every staged edit as one revision-fenced batch
|
|
225
|
-
*
|
|
218
|
+
* Write every staged edit as one revision-fenced batch.
|
|
219
|
+
*
|
|
220
|
+
* Called when the reader leaves a control. An invalid draft writes nothing at
|
|
221
|
+
* all, so the page keeps it for correction instead of storing a value it never
|
|
222
|
+
* showed. A refused write keeps every draft for the same reason.
|
|
226
223
|
*
|
|
227
|
-
*
|
|
228
|
-
*
|
|
229
|
-
* has. A refused write keeps every draft so the reader can correct it.
|
|
224
|
+
* Concurrent callers (a field blur racing the prompt's **完成** button) share
|
|
225
|
+
* one in-flight commit instead of starting a second one.
|
|
230
226
|
*
|
|
231
227
|
* @returns nothing; the outcome is published through {@link getState}.
|
|
232
228
|
*/
|
|
233
229
|
save(): Promise<void>;
|
|
230
|
+
private runSave;
|
|
234
231
|
/** Pull the key's status-only view and re-derive readiness. */
|
|
235
232
|
refreshKeyStatus(): Promise<void>;
|
|
236
233
|
/**
|
|
@@ -4,10 +4,10 @@ import { NS } from '../locales.ts';
|
|
|
4
4
|
/**
|
|
5
5
|
* Chat-translate's own configuration page inside the DSH **Plugins** page.
|
|
6
6
|
*
|
|
7
|
-
* Every control stages its edit
|
|
8
|
-
* revision-fenced document mutation
|
|
9
|
-
*
|
|
10
|
-
*
|
|
7
|
+
* Every control stages its edit and leaves no save button; leaving that control
|
|
8
|
+
* writes the whole batch as one revision-fenced document mutation. Nothing here
|
|
9
|
+
* is written while the reader types, so a half-finished Base URL can never reach
|
|
10
|
+
* the translation path.
|
|
11
11
|
*
|
|
12
12
|
* @param props - renderer-bound seat of the `plugins.bundle.config` slot: the
|
|
13
13
|
* `view` asked for plus the `t` seat its `locale: NS` registration injects.
|
package/package.json
CHANGED