@linxin666/dsh-pet 0.4.9 → 0.4.11
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.i18n.yaml +2 -2
- package/README.md +1 -1
- package/README.zh.md +4 -4
- package/lib/client.js +1092 -348
- package/lib/client.js.map +1 -1
- package/lib/types/client/PetPreview.d.ts +12 -0
- package/lib/types/client/PetPreview.d.ts.map +1 -0
- package/lib/types/client/PetPreview.js +32 -0
- package/lib/types/client/PetSettingsCard.d.ts +30 -2
- package/lib/types/client/PetSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PetSettingsCard.js +48 -8
- package/lib/types/client/PluginSettingsCard.d.ts +131 -17
- package/lib/types/client/PluginSettingsCard.d.ts.map +1 -1
- package/lib/types/client/PluginSettingsCard.js +158 -37
- package/lib/types/client/RangeBubble.d.ts +47 -0
- package/lib/types/client/RangeBubble.d.ts.map +1 -0
- package/lib/types/client/RangeBubble.js +107 -0
- package/lib/types/client/SegmentGroup.d.ts +29 -0
- package/lib/types/client/SegmentGroup.d.ts.map +1 -0
- package/lib/types/client/SegmentGroup.js +81 -0
- package/lib/types/client/index.d.ts.map +1 -1
- package/lib/types/client/index.js +9 -28
- package/lib/types/client/locales.d.ts +36 -44
- package/lib/types/client/locales.d.ts.map +1 -1
- package/lib/types/client/locales.js +36 -44
- package/lib/types/client/settings-form.d.ts +79 -41
- package/lib/types/client/settings-form.d.ts.map +1 -1
- package/lib/types/client/settings-form.js +96 -36
- package/lib/types/client/settings-registration.d.ts +15 -0
- package/lib/types/client/settings-registration.d.ts.map +1 -0
- package/lib/types/client/settings-registration.js +24 -0
- package/lib/types/client/web-extension-contract.d.ts +32 -0
- package/lib/types/client/web-extension-contract.d.ts.map +1 -0
- package/lib/types/client/web-extension-contract.js +6 -0
- package/lib/types/client/web-extension-page.d.ts +51 -0
- package/lib/types/client/web-extension-page.d.ts.map +1 -0
- package/lib/types/client/web-extension-page.js +122 -0
- package/package.json +1 -1
- package/src/client/PetPreview.tsx +51 -0
- package/src/client/PetSettingsCard.test.tsx +28 -22
- package/src/client/PetSettingsCard.tsx +201 -110
- package/src/client/PluginSettingsCard.tsx +369 -108
- package/src/client/RangeBubble.tsx +163 -0
- package/src/client/SegmentGroup.tsx +92 -0
- package/src/client/index.ts +9 -27
- package/src/client/locales.ts +36 -44
- package/src/client/settings-card.module.css +493 -91
- package/src/client/settings-form.ts +116 -49
- package/src/client/settings-registration.test.ts +79 -0
- package/src/client/settings-registration.ts +34 -0
- package/src/client/settings-section.module.css +182 -0
- package/src/client/web-extension-contract.ts +35 -0
- package/src/client/web-extension-page.ts +150 -0
|
@@ -53,40 +53,36 @@ export declare const zh: {
|
|
|
53
53
|
readonly 'pet.moreSessions': "展开其余 {n} 个会话的气泡";
|
|
54
54
|
readonly 'pet.collapseSessions': "收起会话气泡";
|
|
55
55
|
readonly 'settings.title': "宠物";
|
|
56
|
-
readonly 'settings.description': "
|
|
56
|
+
readonly 'settings.description': "选一只宠物,摆在页面的角落里。";
|
|
57
57
|
readonly 'settings.pet': "宠物";
|
|
58
|
-
readonly 'settings.petHint': "
|
|
59
|
-
readonly 'settings.
|
|
60
|
-
readonly 'settings.
|
|
58
|
+
readonly 'settings.petHint': "名字跟着宠物走,在宠物面板里改。";
|
|
59
|
+
readonly 'settings.displayGroup': "显示";
|
|
60
|
+
readonly 'settings.bubbleGroup': "气泡";
|
|
61
61
|
readonly 'settings.decoration': "状态装饰";
|
|
62
|
-
readonly 'settings.decorationHint': "
|
|
62
|
+
readonly 'settings.decorationHint': "气泡里带上喷水鲸鱼这类装饰。";
|
|
63
63
|
readonly 'settings.statusBubbles': "状态气泡";
|
|
64
|
-
readonly 'settings.statusBubblesHint': "
|
|
64
|
+
readonly 'settings.statusBubblesHint': "宠物报告正在思考、正在用哪个工具。";
|
|
65
65
|
readonly 'settings.visible': "显示宠物";
|
|
66
|
-
readonly 'settings.visibleHint': "
|
|
66
|
+
readonly 'settings.visibleHint': "藏起来后可在输入区召唤回来。";
|
|
67
67
|
readonly 'settings.size': "大小(px)";
|
|
68
|
-
readonly 'settings.sizeHint': "
|
|
69
|
-
readonly 'settings.bubbleScale': "
|
|
70
|
-
readonly 'settings.bubbleScaleHint': "
|
|
68
|
+
readonly 'settings.sizeHint': "宠物的高度。";
|
|
69
|
+
readonly 'settings.bubbleScale': "气泡字号";
|
|
70
|
+
readonly 'settings.bubbleScaleHint': "字号随宠物缩放,再乘上这个倍数。";
|
|
71
71
|
readonly 'settings.right': "距右侧(px)";
|
|
72
|
-
readonly 'settings.rightHint': "
|
|
72
|
+
readonly 'settings.rightHint': "离窗口右边的距离。";
|
|
73
73
|
readonly 'settings.bottom': "距底部(px)";
|
|
74
|
-
readonly 'settings.bottomHint': "
|
|
75
|
-
readonly 'settings.inherit': "
|
|
74
|
+
readonly 'settings.bottomHint': "离窗口底边的距离。";
|
|
75
|
+
readonly 'settings.inherit': "默认";
|
|
76
76
|
readonly 'settings.on': "开";
|
|
77
77
|
readonly 'settings.off': "关";
|
|
78
|
-
readonly 'settings.overridden': "
|
|
78
|
+
readonly 'settings.overridden': "已修改";
|
|
79
79
|
readonly 'settings.reset': "恢复默认";
|
|
80
|
-
readonly 'settings.notExposed': "
|
|
81
|
-
readonly 'settings.readOnly': "
|
|
80
|
+
readonly 'settings.notExposed': "这个版本的 DSH 没有开放宠物的设置,可直接编辑 $DSH_HOME/settings.yaml。";
|
|
81
|
+
readonly 'settings.readOnly': "设置只读。";
|
|
82
82
|
readonly 'settings.expand': "展开设置";
|
|
83
83
|
readonly 'settings.collapse': "收起设置";
|
|
84
|
-
readonly 'settings.
|
|
85
|
-
readonly 'settings.
|
|
86
|
-
readonly 'settings.discard': "放弃";
|
|
87
|
-
readonly 'settings.unsaved': "未保存";
|
|
88
|
-
readonly 'settings.saveFailed': "部署未接受这些值,已保留供你修改。";
|
|
89
|
-
readonly 'settings.invalidNumber': "请输入数字,留空则使用默认值。";
|
|
84
|
+
readonly 'settings.saveFailed': "没有保存成功,输入的值还留着。";
|
|
85
|
+
readonly 'settings.invalidNumber': "填一个数字,留空用默认值。";
|
|
90
86
|
};
|
|
91
87
|
/** English copy. */
|
|
92
88
|
export declare const en: {
|
|
@@ -137,40 +133,36 @@ export declare const en: {
|
|
|
137
133
|
readonly 'pet.moreSessions': "Expand {n} more session bubbles";
|
|
138
134
|
readonly 'pet.collapseSessions': "Collapse session bubbles";
|
|
139
135
|
readonly 'settings.title': "Pet";
|
|
140
|
-
readonly 'settings.description': "Pick a pet
|
|
136
|
+
readonly 'settings.description': "Pick a pet to sit in a corner of the page.";
|
|
141
137
|
readonly 'settings.pet': "Pet";
|
|
142
|
-
readonly 'settings.petHint': "
|
|
143
|
-
readonly 'settings.
|
|
144
|
-
readonly 'settings.
|
|
138
|
+
readonly 'settings.petHint': "Each pet keeps its own name; rename it from the pet panel.";
|
|
139
|
+
readonly 'settings.displayGroup': "Display";
|
|
140
|
+
readonly 'settings.bubbleGroup': "Bubbles";
|
|
145
141
|
readonly 'settings.decoration': "Status decoration";
|
|
146
|
-
readonly 'settings.decorationHint': "
|
|
142
|
+
readonly 'settings.decorationHint': "Bubbles carry ornaments like the spouting whale.";
|
|
147
143
|
readonly 'settings.statusBubbles': "Status bubbles";
|
|
148
|
-
readonly 'settings.statusBubblesHint': "The pet
|
|
144
|
+
readonly 'settings.statusBubblesHint': "The pet reports when it is thinking and which tool it is using.";
|
|
149
145
|
readonly 'settings.visible': "Show the pet";
|
|
150
|
-
readonly 'settings.visibleHint': "
|
|
146
|
+
readonly 'settings.visibleHint': "A hidden pet comes back from the input row.";
|
|
151
147
|
readonly 'settings.size': "Size (px)";
|
|
152
|
-
readonly 'settings.sizeHint': "
|
|
153
|
-
readonly 'settings.bubbleScale': "Bubble text
|
|
154
|
-
readonly 'settings.bubbleScaleHint': "
|
|
148
|
+
readonly 'settings.sizeHint': "How tall the pet stands.";
|
|
149
|
+
readonly 'settings.bubbleScale': "Bubble text";
|
|
150
|
+
readonly 'settings.bubbleScaleHint': "Text follows the pet size, times this factor.";
|
|
155
151
|
readonly 'settings.right': "Right inset (px)";
|
|
156
|
-
readonly 'settings.rightHint': "
|
|
152
|
+
readonly 'settings.rightHint': "Distance from the right edge of the window.";
|
|
157
153
|
readonly 'settings.bottom': "Bottom inset (px)";
|
|
158
|
-
readonly 'settings.bottomHint': "
|
|
159
|
-
readonly 'settings.inherit': "
|
|
154
|
+
readonly 'settings.bottomHint': "Distance from the bottom edge of the window.";
|
|
155
|
+
readonly 'settings.inherit': "Default";
|
|
160
156
|
readonly 'settings.on': "On";
|
|
161
157
|
readonly 'settings.off': "Off";
|
|
162
|
-
readonly 'settings.overridden': "
|
|
158
|
+
readonly 'settings.overridden': "Changed";
|
|
163
159
|
readonly 'settings.reset': "Reset to default";
|
|
164
|
-
readonly 'settings.notExposed': "This DSH version does not
|
|
165
|
-
readonly 'settings.readOnly': "
|
|
160
|
+
readonly 'settings.notExposed': "This DSH version does not open the pet settings here; edit $DSH_HOME/settings.yaml instead.";
|
|
161
|
+
readonly 'settings.readOnly': "Settings are read-only.";
|
|
166
162
|
readonly 'settings.expand': "Show settings";
|
|
167
163
|
readonly 'settings.collapse': "Hide settings";
|
|
168
|
-
readonly 'settings.
|
|
169
|
-
readonly 'settings.
|
|
170
|
-
readonly 'settings.discard': "Discard";
|
|
171
|
-
readonly 'settings.unsaved': "Unsaved";
|
|
172
|
-
readonly 'settings.saveFailed': "The deployment did not accept these values; they were left for you to correct.";
|
|
173
|
-
readonly 'settings.invalidNumber': "Enter a number, or leave blank to use the default.";
|
|
164
|
+
readonly 'settings.saveFailed': "Not saved; what you typed is still there.";
|
|
165
|
+
readonly 'settings.invalidNumber': "Enter a number, or leave it empty for the default.";
|
|
174
166
|
};
|
|
175
167
|
/** Key union for this namespace. */
|
|
176
168
|
export type PetKey = keyof typeof zh;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,eAAO,MAAM,EAAE,QAAQ,CAAA;AAEvB,oBAAoB;AACpB,eAAO,MAAM,EAAE
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/client/locales.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,mDAAmD;AACnD,eAAO,MAAM,EAAE,QAAQ,CAAA;AAEvB,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFL,CAAA;AAEV,oBAAoB;AACpB,eAAO,MAAM,EAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAgFL,CAAA;AAEV,oCAAoC;AACpC,MAAM,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,CAAA;AAEpC,qDAAqD;AACrD,MAAM,MAAM,eAAe,GAAG,MAAM,CAAA;AAEpC;;;;;GAKG;AACH,wBAAgB,UAAU,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAGnD;AAED;;;;;;;GAOG;AACH,wBAAgB,CAAC,CAAC,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,MAAM,CAQvE;AAED,OAAO,QAAQ,kCAAkC,CAAC;IAChD,UAAU,kBAAkB;QAC1B,uBAAuB;QACvB,GAAG,EAAE,MAAM,CAAA;KACZ;CACF"}
|
|
@@ -55,40 +55,36 @@ export const zh = {
|
|
|
55
55
|
'pet.collapseSessions': '收起会话气泡',
|
|
56
56
|
// 一级设置页(settings.section 席位)。
|
|
57
57
|
'settings.title': '宠物',
|
|
58
|
-
'settings.description': '
|
|
58
|
+
'settings.description': '选一只宠物,摆在页面的角落里。',
|
|
59
59
|
'settings.pet': '宠物',
|
|
60
|
-
'settings.petHint': '
|
|
61
|
-
'settings.
|
|
62
|
-
'settings.
|
|
60
|
+
'settings.petHint': '名字跟着宠物走,在宠物面板里改。',
|
|
61
|
+
'settings.displayGroup': '显示',
|
|
62
|
+
'settings.bubbleGroup': '气泡',
|
|
63
63
|
'settings.decoration': '状态装饰',
|
|
64
|
-
'settings.decorationHint': '
|
|
64
|
+
'settings.decorationHint': '气泡里带上喷水鲸鱼这类装饰。',
|
|
65
65
|
'settings.statusBubbles': '状态气泡',
|
|
66
|
-
'settings.statusBubblesHint': '
|
|
66
|
+
'settings.statusBubblesHint': '宠物报告正在思考、正在用哪个工具。',
|
|
67
67
|
'settings.visible': '显示宠物',
|
|
68
|
-
'settings.visibleHint': '
|
|
68
|
+
'settings.visibleHint': '藏起来后可在输入区召唤回来。',
|
|
69
69
|
'settings.size': '大小(px)',
|
|
70
|
-
'settings.sizeHint': '
|
|
71
|
-
'settings.bubbleScale': '
|
|
72
|
-
'settings.bubbleScaleHint': '
|
|
70
|
+
'settings.sizeHint': '宠物的高度。',
|
|
71
|
+
'settings.bubbleScale': '气泡字号',
|
|
72
|
+
'settings.bubbleScaleHint': '字号随宠物缩放,再乘上这个倍数。',
|
|
73
73
|
'settings.right': '距右侧(px)',
|
|
74
|
-
'settings.rightHint': '
|
|
74
|
+
'settings.rightHint': '离窗口右边的距离。',
|
|
75
75
|
'settings.bottom': '距底部(px)',
|
|
76
|
-
'settings.bottomHint': '
|
|
77
|
-
'settings.inherit': '
|
|
76
|
+
'settings.bottomHint': '离窗口底边的距离。',
|
|
77
|
+
'settings.inherit': '默认',
|
|
78
78
|
'settings.on': '开',
|
|
79
79
|
'settings.off': '关',
|
|
80
|
-
'settings.overridden': '
|
|
80
|
+
'settings.overridden': '已修改',
|
|
81
81
|
'settings.reset': '恢复默认',
|
|
82
|
-
'settings.notExposed': '
|
|
83
|
-
'settings.readOnly': '
|
|
82
|
+
'settings.notExposed': '这个版本的 DSH 没有开放宠物的设置,可直接编辑 $DSH_HOME/settings.yaml。',
|
|
83
|
+
'settings.readOnly': '设置只读。',
|
|
84
84
|
'settings.expand': '展开设置',
|
|
85
85
|
'settings.collapse': '收起设置',
|
|
86
|
-
'settings.
|
|
87
|
-
'settings.
|
|
88
|
-
'settings.discard': '放弃',
|
|
89
|
-
'settings.unsaved': '未保存',
|
|
90
|
-
'settings.saveFailed': '部署未接受这些值,已保留供你修改。',
|
|
91
|
-
'settings.invalidNumber': '请输入数字,留空则使用默认值。',
|
|
86
|
+
'settings.saveFailed': '没有保存成功,输入的值还留着。',
|
|
87
|
+
'settings.invalidNumber': '填一个数字,留空用默认值。',
|
|
92
88
|
};
|
|
93
89
|
/** English copy. */
|
|
94
90
|
export const en = {
|
|
@@ -141,40 +137,36 @@ export const en = {
|
|
|
141
137
|
'pet.collapseSessions': 'Collapse session bubbles',
|
|
142
138
|
// First-level settings section (the `settings.section` seat).
|
|
143
139
|
'settings.title': 'Pet',
|
|
144
|
-
'settings.description': 'Pick a pet
|
|
140
|
+
'settings.description': 'Pick a pet to sit in a corner of the page.',
|
|
145
141
|
'settings.pet': 'Pet',
|
|
146
|
-
'settings.petHint': '
|
|
147
|
-
'settings.
|
|
148
|
-
'settings.
|
|
142
|
+
'settings.petHint': 'Each pet keeps its own name; rename it from the pet panel.',
|
|
143
|
+
'settings.displayGroup': 'Display',
|
|
144
|
+
'settings.bubbleGroup': 'Bubbles',
|
|
149
145
|
'settings.decoration': 'Status decoration',
|
|
150
|
-
'settings.decorationHint': '
|
|
146
|
+
'settings.decorationHint': 'Bubbles carry ornaments like the spouting whale.',
|
|
151
147
|
'settings.statusBubbles': 'Status bubbles',
|
|
152
|
-
'settings.statusBubblesHint': 'The pet
|
|
148
|
+
'settings.statusBubblesHint': 'The pet reports when it is thinking and which tool it is using.',
|
|
153
149
|
'settings.visible': 'Show the pet',
|
|
154
|
-
'settings.visibleHint': '
|
|
150
|
+
'settings.visibleHint': 'A hidden pet comes back from the input row.',
|
|
155
151
|
'settings.size': 'Size (px)',
|
|
156
|
-
'settings.sizeHint': '
|
|
157
|
-
'settings.bubbleScale': 'Bubble text
|
|
158
|
-
'settings.bubbleScaleHint': '
|
|
152
|
+
'settings.sizeHint': 'How tall the pet stands.',
|
|
153
|
+
'settings.bubbleScale': 'Bubble text',
|
|
154
|
+
'settings.bubbleScaleHint': 'Text follows the pet size, times this factor.',
|
|
159
155
|
'settings.right': 'Right inset (px)',
|
|
160
|
-
'settings.rightHint': '
|
|
156
|
+
'settings.rightHint': 'Distance from the right edge of the window.',
|
|
161
157
|
'settings.bottom': 'Bottom inset (px)',
|
|
162
|
-
'settings.bottomHint': '
|
|
163
|
-
'settings.inherit': '
|
|
158
|
+
'settings.bottomHint': 'Distance from the bottom edge of the window.',
|
|
159
|
+
'settings.inherit': 'Default',
|
|
164
160
|
'settings.on': 'On',
|
|
165
161
|
'settings.off': 'Off',
|
|
166
|
-
'settings.overridden': '
|
|
162
|
+
'settings.overridden': 'Changed',
|
|
167
163
|
'settings.reset': 'Reset to default',
|
|
168
|
-
'settings.notExposed': 'This DSH version does not
|
|
169
|
-
'settings.readOnly': '
|
|
164
|
+
'settings.notExposed': 'This DSH version does not open the pet settings here; edit $DSH_HOME/settings.yaml instead.',
|
|
165
|
+
'settings.readOnly': 'Settings are read-only.',
|
|
170
166
|
'settings.expand': 'Show settings',
|
|
171
167
|
'settings.collapse': 'Hide settings',
|
|
172
|
-
'settings.
|
|
173
|
-
'settings.
|
|
174
|
-
'settings.discard': 'Discard',
|
|
175
|
-
'settings.unsaved': 'Unsaved',
|
|
176
|
-
'settings.saveFailed': 'The deployment did not accept these values; they were left for you to correct.',
|
|
177
|
-
'settings.invalidNumber': 'Enter a number, or leave blank to use the default.',
|
|
168
|
+
'settings.saveFailed': 'Not saved; what you typed is still there.',
|
|
169
|
+
'settings.invalidNumber': 'Enter a number, or leave it empty for the default.',
|
|
178
170
|
};
|
|
179
171
|
/**
|
|
180
172
|
* Active dictionary, picked by the document language at call time. The pet
|
|
@@ -1,14 +1,15 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
2
|
+
* Form model behind the plugin settings card. Every control applies itself:
|
|
3
|
+
* a pick (a segment, a select option, a reset) writes the moment it is made,
|
|
4
|
+
* and typed text writes once typing pauses or the reader leaves the field.
|
|
5
|
+
* Between the edit and the write the edit is held here as a draft, so what is
|
|
6
|
+
* on screen is exactly what the write will store; a write the Host refuses
|
|
7
|
+
* puts a pick back to the stored value and keeps typed text for correcting.
|
|
8
|
+
* Family-shared slice inlined into each plugin's client bundle.
|
|
8
9
|
*/
|
|
9
10
|
import type { ConfigForm } from '@deepseek-ai/dsh-client-ui-settings/client';
|
|
10
11
|
import type { SnapshotStore } from '@deepseek-ai/dsh-client-store';
|
|
11
|
-
/** The write one field's
|
|
12
|
+
/** The write one field's draft text performs when it is applied. */
|
|
12
13
|
export type FieldWrite = {
|
|
13
14
|
kind: 'set';
|
|
14
15
|
value: unknown;
|
|
@@ -19,6 +20,12 @@ export type FieldWrite = {
|
|
|
19
20
|
export interface FieldSpec {
|
|
20
21
|
/** Field name inside the namespace section. */
|
|
21
22
|
field: string;
|
|
23
|
+
/**
|
|
24
|
+
* How the reader enters a value, which decides when it is written: a `pick`
|
|
25
|
+
* is a whole value at once and applies immediately; `type` is text arriving
|
|
26
|
+
* a keystroke at a time and applies once typing pauses or the field is left.
|
|
27
|
+
*/
|
|
28
|
+
entry: 'pick' | 'type';
|
|
22
29
|
/**
|
|
23
30
|
* Whether the Host treats this field as a secret and redacts its value from
|
|
24
31
|
* the read-back (role('secret') in the section schema). Redacted secrets are
|
|
@@ -32,8 +39,9 @@ export interface FieldSpec {
|
|
|
32
39
|
/** Render a stored value as draft text; the empty string when the section carries none. */
|
|
33
40
|
format: (value: unknown) => string;
|
|
34
41
|
/**
|
|
35
|
-
* The write this draft text
|
|
36
|
-
* value this field accepts — which
|
|
42
|
+
* The write this draft text performs, or undefined when the text is not a
|
|
43
|
+
* value this field accepts — which holds the draft unwritten rather than
|
|
44
|
+
* discarding it.
|
|
37
45
|
*/
|
|
38
46
|
parse: (text: string) => FieldWrite | undefined;
|
|
39
47
|
}
|
|
@@ -41,9 +49,9 @@ export interface FieldSpec {
|
|
|
41
49
|
export interface FieldState {
|
|
42
50
|
/** Draft text the control renders. */
|
|
43
51
|
text: string;
|
|
44
|
-
/** Whether
|
|
52
|
+
/** Whether the field leaves (or will leave) a user-layer entry. */
|
|
45
53
|
overridden: boolean;
|
|
46
|
-
/** Whether the draft is not a value this field accepts, which
|
|
54
|
+
/** Whether the draft is not a value this field accepts, which holds it unwritten. */
|
|
47
55
|
invalid: boolean;
|
|
48
56
|
}
|
|
49
57
|
/** Form state every plugin settings card shares. */
|
|
@@ -60,13 +68,13 @@ export interface CardShell {
|
|
|
60
68
|
exposed: boolean;
|
|
61
69
|
/** Whether the Host document accepts writes. */
|
|
62
70
|
writable: boolean;
|
|
63
|
-
/** Whether the form holds
|
|
71
|
+
/** Whether the form holds drafts not yet written (typed text waiting for its pause). */
|
|
64
72
|
dirty: boolean;
|
|
65
|
-
/** Whether any
|
|
73
|
+
/** Whether any draft is invalid, which holds it unwritten. */
|
|
66
74
|
invalid: boolean;
|
|
67
|
-
/** Whether a
|
|
75
|
+
/** Whether a write is crossing the wire. */
|
|
68
76
|
saving: boolean;
|
|
69
|
-
/** Whether the last
|
|
77
|
+
/** Whether the last write did not land; cleared by the next edit or write. */
|
|
70
78
|
failed: boolean;
|
|
71
79
|
/**
|
|
72
80
|
* The rejection code/message the Host returned for the last failed save,
|
|
@@ -77,15 +85,17 @@ export interface CardShell {
|
|
|
77
85
|
}
|
|
78
86
|
/** The write actions the card's slot entry injects. */
|
|
79
87
|
export interface CardActions {
|
|
80
|
-
/**
|
|
88
|
+
/** Take draft text for one field; a pick writes at once, typed text after a pause. */
|
|
81
89
|
edit: (field: string, text: string) => void;
|
|
82
|
-
/**
|
|
90
|
+
/** Clear one field at once, so it re-inherits the composition layer. */
|
|
83
91
|
resetField: (field: string) => void;
|
|
84
|
-
/** Write every
|
|
92
|
+
/** Write every pending draft now (a text field's Enter or blur), then re-seed from what the Host accepted. */
|
|
85
93
|
save: () => void;
|
|
86
|
-
/** Drop every
|
|
94
|
+
/** Drop every pending draft, putting each control back to the stored value (a text field's Escape). */
|
|
87
95
|
discard: () => void;
|
|
88
96
|
}
|
|
97
|
+
/** How long typed text rests before it is written. */
|
|
98
|
+
export declare const TYPE_PAUSE_MS = 600;
|
|
89
99
|
/** One durable write inside the save's atomic form mutation. */
|
|
90
100
|
export interface BatchedWrite {
|
|
91
101
|
/** Field this entry writes. */
|
|
@@ -102,10 +112,13 @@ export interface NumberConstraints {
|
|
|
102
112
|
/** The accepted value must be at least this. */
|
|
103
113
|
min?: number;
|
|
104
114
|
}
|
|
105
|
-
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints
|
|
115
|
+
/** A whole- or decimal-number field. An empty draft clears the field; any other draft that is not a finite number within the constraints stays unwritten. */
|
|
106
116
|
export declare function numberField(field: string, constraints?: NumberConstraints): FieldSpec;
|
|
107
|
-
/**
|
|
108
|
-
|
|
117
|
+
/**
|
|
118
|
+
* A free-text field. An empty draft clears the field. `entry` is `pick` when
|
|
119
|
+
* the text arrives whole from a picker (a preset or a reasoning level).
|
|
120
|
+
*/
|
|
121
|
+
export declare function textField(field: string, entry?: FieldSpec['entry']): FieldSpec;
|
|
109
122
|
/**
|
|
110
123
|
* A free-text field the Host treats as a secret and redacts from the read-back
|
|
111
124
|
* (role('secret') in the section schema). The card still edits it like text,
|
|
@@ -118,12 +131,14 @@ export declare function booleanField(field: string): FieldSpec;
|
|
|
118
131
|
/** An enumerated string field; only the listed choices are accepted. An empty draft clears the field. */
|
|
119
132
|
export declare function choiceField(field: string, choices: readonly string[]): FieldSpec;
|
|
120
133
|
/**
|
|
121
|
-
*
|
|
134
|
+
* Applies one card's edits to one settings namespace as the reader makes them.
|
|
122
135
|
*
|
|
123
136
|
* The Host is the only authority on whether a value was accepted — its
|
|
124
137
|
* validators own the constraints no schema can express — so the outcome is
|
|
125
|
-
* read back from the section rather than predicted here. A
|
|
126
|
-
* land
|
|
138
|
+
* read back from the section rather than predicted here. A write that did not
|
|
139
|
+
* land puts each pick back to the stored value, the way a switch that could not
|
|
140
|
+
* flip springs back, and keeps typed text so the reader can correct it instead
|
|
141
|
+
* of retyping.
|
|
127
142
|
*/
|
|
128
143
|
export declare class CardForm<T> {
|
|
129
144
|
private readonly scope;
|
|
@@ -133,7 +148,11 @@ export declare class CardForm<T> {
|
|
|
133
148
|
/** The form subscription installed in the constructor; released by dispose(). */
|
|
134
149
|
private readonly disposeForm;
|
|
135
150
|
private disposed;
|
|
151
|
+
/** The pending write of typed text, waiting for typing to pause. */
|
|
152
|
+
private typePause;
|
|
136
153
|
private saving;
|
|
154
|
+
/** A save asked for while one was in flight; it runs once the first settles (#1754). */
|
|
155
|
+
private saveQueued;
|
|
137
156
|
private failed;
|
|
138
157
|
private failedReason;
|
|
139
158
|
/** @param scope - the bound configuration form for this card's namespace. */
|
|
@@ -145,33 +164,46 @@ export declare class CardForm<T> {
|
|
|
145
164
|
dispose(): void;
|
|
146
165
|
/** Publish a projection of this form, rebuilt whenever the form or a draft changes. */
|
|
147
166
|
bind<S>(project: () => S): SnapshotStore<S>;
|
|
148
|
-
/** Read the card-level state: what the Host serves, and what
|
|
167
|
+
/** Read the card-level state: what the Host serves, and what is still waiting to be written. */
|
|
149
168
|
shell(): CardShell;
|
|
150
169
|
/** Read one field's state from the effective section and its staged draft. */
|
|
151
170
|
field(field: string): FieldState;
|
|
152
171
|
/** The actions the card's slot registration injects. */
|
|
153
172
|
actions(): CardActions;
|
|
154
173
|
/**
|
|
155
|
-
*
|
|
156
|
-
*
|
|
174
|
+
* Run one write, and re-run it once if another was asked for while this one
|
|
175
|
+
* was still in flight.
|
|
176
|
+
*
|
|
177
|
+
* A write is a Host round trip that also drives the profile reconcile, and
|
|
178
|
+
* the Host runs it inside one exclusive transaction. Answering an edit that
|
|
179
|
+
* arrives mid-flight by returning immediately dropped it with no explanation
|
|
180
|
+
* (#1754). Serializing instead means an edit made while another write is
|
|
181
|
+
* still settling is written against the settled state.
|
|
182
|
+
* @returns settlement after the mutation and the read-back.
|
|
183
|
+
*/
|
|
184
|
+
requestSave(): Promise<void>;
|
|
185
|
+
/**
|
|
186
|
+
* Write every valid draft in one atomic form mutation, then re-seed from
|
|
187
|
+
* what the Host accepted. A draft the field does not accept stays on screen,
|
|
188
|
+
* unwritten, without holding the others back.
|
|
157
189
|
*
|
|
158
|
-
* The
|
|
159
|
-
*
|
|
160
|
-
*
|
|
161
|
-
*
|
|
162
|
-
*
|
|
163
|
-
*
|
|
164
|
-
*
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* the
|
|
190
|
+
* The batch rides one mutate, so cross-field validate hooks (baseURL+model)
|
|
191
|
+
* judge it as a unit: the Host either applies every write or refuses the
|
|
192
|
+
* batch. The form contract answers a refusal or a skipped write with `false`
|
|
193
|
+
* (it recovers with a fresh Host view instead of throwing), so the outcome is
|
|
194
|
+
* judged twice: the answer itself, and then the settled snapshot read back
|
|
195
|
+
* one planned write at a time. One missed write fails the whole batch. A
|
|
196
|
+
* transport that rejects instead (the dsh-web bridge controller on a dead
|
|
197
|
+
* connection) reports through the same failure path with its rejection
|
|
198
|
+
* message. A batch that did not land puts its picks and clears back to the
|
|
199
|
+
* stored value and keeps its typed text, so the reader can correct it.
|
|
168
200
|
* @returns settlement after the mutation and the read-back.
|
|
169
201
|
*/
|
|
170
202
|
save(): Promise<void>;
|
|
171
203
|
/**
|
|
172
|
-
* Every staged edit a
|
|
173
|
-
* its field accepts carries no write: the form is still dirty, and the
|
|
174
|
-
*
|
|
204
|
+
* Every staged edit a write would carry. An entry whose draft is not a value
|
|
205
|
+
* its field accepts carries no write: the form is still dirty, and the draft
|
|
206
|
+
* stays on screen rather than being dropped. A staged edit that matches the
|
|
175
207
|
* effective section is not a write at all.
|
|
176
208
|
* @returns the planned writes, in the order the fields were staged.
|
|
177
209
|
*/
|
|
@@ -186,7 +218,13 @@ export declare class CardForm<T> {
|
|
|
186
218
|
* user layer once the mutation has settled.
|
|
187
219
|
*/
|
|
188
220
|
private landedUnset;
|
|
221
|
+
/**
|
|
222
|
+
* Take one edit and schedule its write: a pick or a clear is written now,
|
|
223
|
+
* typed text once typing has rested for TYPE_PAUSE_MS.
|
|
224
|
+
*/
|
|
189
225
|
private stage;
|
|
226
|
+
/** Write every pending draft now, taking the place of a waiting pause. */
|
|
227
|
+
private applyNow;
|
|
190
228
|
private specOf;
|
|
191
229
|
private snapshotOf;
|
|
192
230
|
private sectionValue;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"settings-form.d.ts","sourceRoot":"","sources":["../../../src/client/settings-form.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"settings-form.d.ts","sourceRoot":"","sources":["../../../src/client/settings-form.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,UAAU,EAAsB,MAAM,4CAA4C,CAAA;AAChG,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,+BAA+B,CAAA;AAGlE,oEAAoE;AACpE,MAAM,MAAM,UAAU,GAClB;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GAC/B;IAAE,IAAI,EAAE,OAAO,CAAA;CAAE,CAAA;AAErB,0EAA0E;AAC1E,MAAM,WAAW,SAAS;IACxB,+CAA+C;IAC/C,KAAK,EAAE,MAAM,CAAA;IACb;;;;OAIG;IACH,KAAK,EAAE,MAAM,GAAG,MAAM,CAAA;IACtB;;;;;;;;OAQG;IACH,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,2FAA2F;IAC3F,MAAM,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAA;IAClC;;;;OAIG;IACH,KAAK,EAA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