@dsh-workbench/shared 0.3.3 → 0.3.5
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/dist/api/blocker-table.d.ts +13 -0
- package/dist/api/blocker-table.js +13 -0
- package/dist/api/blocker.d.ts +6 -0
- package/dist/api/context-ref.d.ts +31 -0
- package/dist/api/context-ref.js +28 -0
- package/dist/api/dsh-client.d.ts +99 -0
- package/dist/api/dsh.d.ts +55 -3
- package/dist/api/facts.d.ts +42 -0
- package/dist/api/facts.js +33 -0
- package/dist/api/host-write.d.ts +19 -1
- package/dist/api/host-write.js +12 -0
- package/dist/api/long-task.d.ts +36 -0
- package/dist/api/long-task.js +27 -0
- package/dist/api/unit-board.d.ts +25 -0
- package/dist/api/unit-board.js +16 -0
- package/dist/api/unit-declaration.d.ts +36 -0
- package/dist/api/unit-declaration.js +24 -0
- package/dist/api/unit.d.ts +32 -0
- package/dist/api/unit.js +5 -0
- package/dist/api/workbench-client.d.ts +25 -0
- package/dist/api/workbench-client.js +13 -0
- package/dist/api/workbench-contract.d.ts +12 -0
- package/dist/components/Activity.d.ts +33 -0
- package/dist/components/Activity.js +24 -0
- package/dist/components/ApprovalDetail.d.ts +15 -1
- package/dist/components/ApprovalDetail.js +13 -1
- package/dist/components/ApprovalPlan.d.ts +14 -0
- package/dist/components/ApprovalPlan.js +8 -0
- package/dist/components/Card.d.ts +13 -0
- package/dist/components/Card.js +10 -0
- package/dist/components/CardAnchor.d.ts +14 -0
- package/dist/components/CardAnchor.js +11 -0
- package/dist/components/CardBoundary.d.ts +20 -0
- package/dist/components/CardBoundary.js +14 -0
- package/dist/components/CardHead.d.ts +13 -0
- package/dist/components/CardHead.js +10 -0
- package/dist/components/ChoiceGroup.d.ts +24 -0
- package/dist/components/ChoiceGroup.js +12 -0
- package/dist/components/Field.d.ts +10 -0
- package/dist/components/Field.js +7 -0
- package/dist/components/Form.css +6 -0
- package/dist/components/Form.d.ts +20 -0
- package/dist/components/Form.js +58 -0
- package/dist/components/FormActions.d.ts +14 -0
- package/dist/components/FormActions.js +5 -0
- package/dist/components/FormNodes.d.ts +103 -0
- package/dist/components/FormNodes.js +153 -0
- package/dist/components/FormRows.d.ts +20 -0
- package/dist/components/FormRows.js +14 -0
- package/dist/components/FormTypes.d.ts +59 -0
- package/dist/components/FormTypes.js +1 -0
- package/dist/components/Link.d.ts +12 -0
- package/dist/components/Link.js +9 -0
- package/dist/components/LongTaskRow.d.ts +19 -0
- package/dist/components/LongTaskRow.js +13 -0
- package/dist/components/Note.d.ts +11 -0
- package/dist/components/Note.js +8 -0
- package/dist/components/ResourceStates.d.ts +25 -0
- package/dist/components/ResourceStates.js +22 -0
- package/dist/components/Rows.d.ts +17 -0
- package/dist/components/Rows.js +11 -0
- package/dist/components/SaveBar.d.ts +12 -0
- package/dist/components/SaveBar.js +9 -0
- package/dist/components/SelectField.d.ts +26 -0
- package/dist/components/SelectField.js +22 -0
- package/dist/components/SelectFieldNodes.d.ts +24 -0
- package/dist/components/SelectFieldNodes.js +24 -0
- package/dist/components/SettingsSection.d.ts +11 -0
- package/dist/components/SettingsSection.js +8 -0
- package/dist/components/Spinner.d.ts +9 -0
- package/dist/components/Spinner.js +6 -0
- package/dist/components/Stack.d.ts +8 -0
- package/dist/components/Stack.js +5 -0
- package/dist/components/StateBlock.d.ts +13 -0
- package/dist/components/StateBlock.js +10 -0
- package/dist/components/TextField.d.ts +8 -0
- package/dist/components/TextField.js +5 -0
- package/dist/components/board-module.d.ts +30 -0
- package/dist/components/icons.d.ts +38 -0
- package/dist/components/icons.js +35 -0
- package/dist/config/constants.d.ts +45 -0
- package/dist/config/constants.js +45 -0
- package/dist/config/storage.d.ts +4 -0
- package/dist/config/storage.js +4 -0
- package/dist/host/browser-read.d.ts +1 -0
- package/dist/host/browser-read.js +1 -0
- package/dist/host/http.d.ts +3 -0
- package/dist/host/http.js +10 -1
- package/dist/host/tool-approval.d.ts +5 -0
- package/dist/host/tool-approval.js +11 -5
- package/dist/host/unit-face.d.ts +5 -1
- package/dist/host.d.ts +1 -0
- package/dist/host.js +1 -0
- package/dist/i18n/en.d.ts +1 -0
- package/dist/i18n/en.js +22 -8
- package/dist/i18n/index.d.ts +25 -9
- package/dist/i18n/index.js +1 -0
- package/dist/i18n/merge.d.ts +5 -0
- package/dist/i18n/merge.js +2 -0
- package/dist/i18n/zh.d.ts +23 -8
- package/dist/i18n/zh.js +22 -8
- package/dist/index.d.ts +7 -2
- package/dist/index.js +7 -2
- package/dist/lib/blocker-action.d.ts +22 -0
- package/dist/lib/blocker-action.js +13 -0
- package/dist/lib/board-fact.d.ts +27 -0
- package/dist/lib/board-fact.js +18 -0
- package/dist/lib/busy.d.ts +10 -0
- package/dist/lib/busy.js +7 -0
- package/dist/lib/diy-debug.d.ts +42 -2
- package/dist/lib/diy-debug.js +19 -1
- package/dist/lib/diy-record.d.ts +98 -0
- package/dist/lib/diy-record.js +96 -0
- package/dist/lib/form-problem.d.ts +10 -0
- package/dist/lib/form-problem.js +10 -0
- package/dist/lib/panel-state.d.ts +60 -0
- package/dist/lib/panel-state.js +30 -0
- package/dist/lib/react.d.ts +39 -0
- package/dist/lib/react.js +36 -0
- package/dist/lib/text.d.ts +22 -0
- package/dist/lib/text.js +22 -0
- package/dist/lib/ui.d.ts +50 -0
- package/dist/lib/ui.js +41 -0
- package/package.json +1 -1
- package/src/api/blocker-table.ts +13 -0
- package/src/api/blocker.ts +6 -0
- package/src/api/context-ref.ts +31 -0
- package/src/api/dsh-client.ts +99 -0
- package/src/api/dsh.ts +56 -1
- package/src/api/facts.ts +42 -0
- package/src/api/host-write.ts +20 -1
- package/src/api/long-task.ts +36 -0
- package/src/api/unit-board.ts +25 -0
- package/src/api/unit-declaration.ts +36 -0
- package/src/api/unit.ts +32 -0
- package/src/api/workbench-client.ts +25 -0
- package/src/api/workbench-contract.ts +12 -0
- package/src/components/Activity.tsx +33 -0
- package/src/components/ApprovalDetail.tsx +17 -1
- package/src/components/ApprovalPlan.tsx +14 -0
- package/src/components/Card.tsx +13 -0
- package/src/components/CardAnchor.tsx +14 -0
- package/src/components/CardBoundary.tsx +20 -0
- package/src/components/CardHead.tsx +13 -0
- package/src/components/ChoiceGroup.tsx +24 -0
- package/src/components/Field.tsx +10 -0
- package/src/components/Form.css +6 -0
- package/src/components/Form.test.tsx +475 -0
- package/src/components/Form.tsx +78 -0
- package/src/components/FormActions.tsx +14 -0
- package/src/components/FormNodes.tsx +193 -0
- package/src/components/FormRows.tsx +20 -0
- package/src/components/FormTypes.ts +65 -0
- package/src/components/FormWiring.test.tsx +88 -0
- package/src/components/Link.tsx +12 -0
- package/src/components/LongTaskRow.tsx +19 -0
- package/src/components/Note.tsx +11 -0
- package/src/components/ResourceStates.tsx +25 -0
- package/src/components/Rows.tsx +17 -0
- package/src/components/SaveBar.tsx +12 -0
- package/src/components/SelectField.tsx +26 -0
- package/src/components/SelectFieldNodes.tsx +24 -0
- package/src/components/SettingsSection.tsx +11 -0
- package/src/components/Spinner.tsx +9 -0
- package/src/components/Stack.tsx +8 -0
- package/src/components/StateBlock.tsx +13 -0
- package/src/components/TextField.tsx +8 -0
- package/src/components/board-module.ts +30 -0
- package/src/components/icons.tsx +38 -0
- package/src/config/constants.ts +48 -0
- package/src/config/storage.ts +4 -0
- package/src/host/browser-read.ts +1 -0
- package/src/host/http.ts +15 -1
- package/src/host/tool-approval.ts +18 -4
- package/src/host/unit-face.ts +6 -1
- package/src/host.ts +1 -0
- package/src/i18n/en.ts +22 -8
- package/src/i18n/index.ts +3 -0
- package/src/i18n/merge.ts +5 -0
- package/src/i18n/zh.ts +23 -8
- package/src/index.ts +7 -2
- package/src/lib/blocker-action.ts +22 -0
- package/src/lib/board-fact.ts +27 -0
- package/src/lib/busy.ts +10 -0
- package/src/lib/diy-debug.test.ts +2 -1
- package/src/lib/diy-debug.ts +44 -3
- package/src/lib/diy-record.test.ts +171 -0
- package/src/lib/diy-record.ts +185 -0
- package/src/lib/form-problem.ts +10 -0
- package/src/lib/panel-state.ts +60 -0
- package/src/lib/react.ts +39 -0
- package/src/lib/text.ts +22 -0
- package/src/lib/ui.ts +50 -0
package/dist/i18n/zh.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** 外壳自带的中文词表(命名空间 `workbench`):`en` 与它逐键对齐,模块那份在它之上合并。 */
|
|
1
2
|
export declare const zh: {
|
|
2
3
|
readonly 'brand.name': "工作台";
|
|
3
4
|
readonly 'toggle.open': "打开侧边栏";
|
|
@@ -408,19 +409,33 @@ export declare const zh: {
|
|
|
408
409
|
readonly 'configSync.noSource': "这台机器上只有工作台这一个 profile,没有可同步的来源";
|
|
409
410
|
readonly 'configSync.emptyProviders': "工作台还没有任何模型供应商 —— 去「配置同步」从某个 profile 把 llm- 那几行搬过来,或自己去「模型」里配。";
|
|
410
411
|
readonly 'configSync.failed': "同步没成功,再试一次。";
|
|
411
|
-
readonly 'debug.
|
|
412
|
-
readonly 'debug.status
|
|
413
|
-
readonly 'debug.
|
|
412
|
+
readonly 'debug.workspace': "这个工作区";
|
|
413
|
+
readonly 'debug.status': "「{title}」调试中";
|
|
414
|
+
readonly 'debug.status.trouble': "调试要你看一眼({title})";
|
|
415
|
+
readonly 'debug.stalled': "调试已暂停({title})";
|
|
414
416
|
readonly 'debug.act.pause': "暂停调试";
|
|
415
417
|
readonly 'debug.act.resume': "继续调试";
|
|
416
418
|
readonly 'debug.act.stop': "结束调试";
|
|
417
419
|
readonly 'debug.act.stop.ask': "确认结束";
|
|
418
|
-
readonly 'debug.card.here.title': "
|
|
420
|
+
readonly 'debug.card.here.title': "正在调试「{title}」";
|
|
419
421
|
readonly 'debug.card.here.note': "请勿切换工作区和操作面板";
|
|
420
|
-
readonly 'debug.card.away.
|
|
421
|
-
readonly 'debug.card.away.note': "请切换到工作台 DIY 工作区";
|
|
422
|
+
readonly 'debug.card.away.note': "请切回「{title}」那一屏";
|
|
422
423
|
readonly 'debug.card.paused.note': "已暂停";
|
|
423
|
-
readonly 'debug.card.hidden.note': "
|
|
424
|
-
readonly '
|
|
424
|
+
readonly 'debug.card.hidden.note': "请切回工作台面板";
|
|
425
|
+
readonly 'record.waiting': "取证交接 · 等你出手";
|
|
426
|
+
readonly 'record.waiting.note': "请在那一页按「开始录制」,做完按「结束录制」(录完不替你切回来)";
|
|
427
|
+
readonly 'record.recording': "录制中";
|
|
428
|
+
readonly 'record.recording.note': "做完按「结束录制」;浮条没了按「停」,让 agent 先取再收";
|
|
429
|
+
readonly 'record.finished': "录制完成";
|
|
430
|
+
readonly 'record.finished.note': "这一段录完了 —— agent 会自己来取并收工,不用你点";
|
|
431
|
+
readonly 'record.act.cancel': "取消";
|
|
432
|
+
readonly 'record.act.halt': "停";
|
|
433
|
+
readonly 'approval.record.site': "站点";
|
|
434
|
+
readonly 'approval.record.what': "录制功能";
|
|
435
|
+
readonly 'approval.record.lands': "落点";
|
|
436
|
+
readonly 'approval.record.noUrl': "没给站点地址(这次会被当场拒)";
|
|
437
|
+
readonly 'approval.record.oneAction': "一次操作";
|
|
438
|
+
readonly 'approval.record.noSwitch': "录完不会替你切回来(左栏底部会亮一条状态)";
|
|
425
439
|
};
|
|
440
|
+
/** 中文词表的键类型:`en` 与模块词表都得覆盖同一批键。 */
|
|
426
441
|
export type WorkbenchMessages = typeof zh;
|
package/dist/i18n/zh.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
/** 外壳自带的中文词表(命名空间 `workbench`):`en` 与它逐键对齐,模块那份在它之上合并。 */
|
|
1
2
|
export const zh = {
|
|
2
3
|
'brand.name': '工作台',
|
|
3
4
|
'toggle.open': '打开侧边栏',
|
|
@@ -408,18 +409,31 @@ export const zh = {
|
|
|
408
409
|
'configSync.noSource': '这台机器上只有工作台这一个 profile,没有可同步的来源',
|
|
409
410
|
'configSync.emptyProviders': '工作台还没有任何模型供应商 —— 去「配置同步」从某个 profile 把 llm- 那几行搬过来,或自己去「模型」里配。',
|
|
410
411
|
'configSync.failed': '同步没成功,再试一次。',
|
|
411
|
-
'debug.
|
|
412
|
-
'debug.status
|
|
413
|
-
'debug.
|
|
412
|
+
'debug.workspace': '这个工作区',
|
|
413
|
+
'debug.status': '「{title}」调试中',
|
|
414
|
+
'debug.status.trouble': '调试要你看一眼({title})',
|
|
415
|
+
'debug.stalled': '调试已暂停({title})',
|
|
414
416
|
'debug.act.pause': '暂停调试',
|
|
415
417
|
'debug.act.resume': '继续调试',
|
|
416
418
|
'debug.act.stop': '结束调试',
|
|
417
419
|
'debug.act.stop.ask': '确认结束',
|
|
418
|
-
'debug.card.here.title': '
|
|
420
|
+
'debug.card.here.title': '正在调试「{title}」',
|
|
419
421
|
'debug.card.here.note': '请勿切换工作区和操作面板',
|
|
420
|
-
'debug.card.away.
|
|
421
|
-
'debug.card.away.note': '请切换到工作台 DIY 工作区',
|
|
422
|
+
'debug.card.away.note': '请切回「{title}」那一屏',
|
|
422
423
|
'debug.card.paused.note': '已暂停',
|
|
423
|
-
'debug.card.hidden.note': '
|
|
424
|
-
'
|
|
424
|
+
'debug.card.hidden.note': '请切回工作台面板',
|
|
425
|
+
'record.waiting': '取证交接 · 等你出手',
|
|
426
|
+
'record.waiting.note': '请在那一页按「开始录制」,做完按「结束录制」(录完不替你切回来)',
|
|
427
|
+
'record.recording': '录制中',
|
|
428
|
+
'record.recording.note': '做完按「结束录制」;浮条没了按「停」,让 agent 先取再收',
|
|
429
|
+
'record.finished': '录制完成',
|
|
430
|
+
'record.finished.note': '这一段录完了 —— agent 会自己来取并收工,不用你点',
|
|
431
|
+
'record.act.cancel': '取消',
|
|
432
|
+
'record.act.halt': '停',
|
|
433
|
+
'approval.record.site': '站点',
|
|
434
|
+
'approval.record.what': '录制功能',
|
|
435
|
+
'approval.record.lands': '落点',
|
|
436
|
+
'approval.record.noUrl': '没给站点地址(这次会被当场拒)',
|
|
437
|
+
'approval.record.oneAction': '一次操作',
|
|
438
|
+
'approval.record.noSwitch': '录完不会替你切回来(左栏底部会亮一条状态)',
|
|
425
439
|
};
|
package/dist/index.d.ts
CHANGED
|
@@ -20,8 +20,11 @@ export * from './components/CardBoundary.js';
|
|
|
20
20
|
export * from './components/CardHead.js';
|
|
21
21
|
export * from './components/ChoiceGroup.js';
|
|
22
22
|
export * from './components/Field.js';
|
|
23
|
+
export * from './components/Form.js';
|
|
23
24
|
export * from './components/FormActions.js';
|
|
25
|
+
export * from './components/FormNodes.js';
|
|
24
26
|
export * from './components/FormRows.js';
|
|
27
|
+
export * from './components/FormTypes.js';
|
|
25
28
|
export * from './components/Link.js';
|
|
26
29
|
export * from './components/LongTaskRow.js';
|
|
27
30
|
export * from './components/Note.js';
|
|
@@ -29,6 +32,7 @@ export * from './components/ResourceStates.js';
|
|
|
29
32
|
export * from './components/Rows.js';
|
|
30
33
|
export * from './components/SaveBar.js';
|
|
31
34
|
export * from './components/SelectField.js';
|
|
35
|
+
export * from './components/SelectFieldNodes.js';
|
|
32
36
|
export * from './components/SettingsSection.js';
|
|
33
37
|
export * from './components/Spinner.js';
|
|
34
38
|
export * from './components/Stack.js';
|
|
@@ -43,10 +47,11 @@ export * from './i18n/index.js';
|
|
|
43
47
|
export * from './i18n/merge.js';
|
|
44
48
|
export * from './i18n/zh.js';
|
|
45
49
|
export * from './lib/blocker-action.js';
|
|
46
|
-
export * from './lib/busy.js';
|
|
47
|
-
export * from './lib/form-problem.js';
|
|
48
50
|
export * from './lib/board-fact.js';
|
|
51
|
+
export * from './lib/busy.js';
|
|
49
52
|
export * from './lib/diy-debug.js';
|
|
53
|
+
export * from './lib/diy-record.js';
|
|
54
|
+
export * from './lib/form-problem.js';
|
|
50
55
|
export * from './lib/panel-state.js';
|
|
51
56
|
export * from './lib/react.js';
|
|
52
57
|
export * from './lib/text.js';
|
package/dist/index.js
CHANGED
|
@@ -20,8 +20,11 @@ export * from './components/CardBoundary.js';
|
|
|
20
20
|
export * from './components/CardHead.js';
|
|
21
21
|
export * from './components/ChoiceGroup.js';
|
|
22
22
|
export * from './components/Field.js';
|
|
23
|
+
export * from './components/Form.js';
|
|
23
24
|
export * from './components/FormActions.js';
|
|
25
|
+
export * from './components/FormNodes.js';
|
|
24
26
|
export * from './components/FormRows.js';
|
|
27
|
+
export * from './components/FormTypes.js';
|
|
25
28
|
export * from './components/Link.js';
|
|
26
29
|
export * from './components/LongTaskRow.js';
|
|
27
30
|
export * from './components/Note.js';
|
|
@@ -29,6 +32,7 @@ export * from './components/ResourceStates.js';
|
|
|
29
32
|
export * from './components/Rows.js';
|
|
30
33
|
export * from './components/SaveBar.js';
|
|
31
34
|
export * from './components/SelectField.js';
|
|
35
|
+
export * from './components/SelectFieldNodes.js';
|
|
32
36
|
export * from './components/SettingsSection.js';
|
|
33
37
|
export * from './components/Spinner.js';
|
|
34
38
|
export * from './components/Stack.js';
|
|
@@ -43,10 +47,11 @@ export * from './i18n/index.js';
|
|
|
43
47
|
export * from './i18n/merge.js';
|
|
44
48
|
export * from './i18n/zh.js';
|
|
45
49
|
export * from './lib/blocker-action.js';
|
|
46
|
-
export * from './lib/busy.js';
|
|
47
|
-
export * from './lib/form-problem.js';
|
|
48
50
|
export * from './lib/board-fact.js';
|
|
51
|
+
export * from './lib/busy.js';
|
|
49
52
|
export * from './lib/diy-debug.js';
|
|
53
|
+
export * from './lib/diy-record.js';
|
|
54
|
+
export * from './lib/form-problem.js';
|
|
50
55
|
export * from './lib/panel-state.js';
|
|
51
56
|
export * from './lib/react.js';
|
|
52
57
|
export * from './lib/text.js';
|
|
@@ -1,13 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 阻断态取词:i18n 的 `(key) => 文案` 那一半;那几颗钮的「重试中…」等临时说法都从它来。
|
|
3
|
+
*/
|
|
1
4
|
export type BlockerLabelTranslate = (key: string) => string;
|
|
5
|
+
/**
|
|
6
|
+
* 阻断态上一颗钮的形状:`kind` 定行为(`retry` / `copy` 等),`label` 是它平时的文案。
|
|
7
|
+
*/
|
|
2
8
|
export interface BlockerActionShape {
|
|
3
9
|
readonly kind: string;
|
|
4
10
|
readonly label: string;
|
|
5
11
|
readonly text?: string | undefined;
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* 这颗钮此刻的运行态:是否正在重试、哪一支正在跑(按 label 认)、刚复制过哪段文本。
|
|
15
|
+
*/
|
|
7
16
|
export interface BlockerLabelState {
|
|
8
17
|
readonly retrying: boolean;
|
|
9
18
|
readonly running: string | null;
|
|
10
19
|
readonly copied: string | null;
|
|
11
20
|
}
|
|
21
|
+
/**
|
|
22
|
+
* 这颗钮此刻该不该按成等待态:这一轮忙还没收,或有一支正在跑。
|
|
23
|
+
* @param busy - 这一轮忙是不是还在。
|
|
24
|
+
* @param running - 正在跑的那一支的 label;没有就给 `null`。
|
|
25
|
+
* @returns 该等待给 `true`,否则 `false`。
|
|
26
|
+
*/
|
|
12
27
|
export declare function blockerPending(busy: boolean, running: string | null): boolean;
|
|
28
|
+
/**
|
|
29
|
+
* 这颗钮此刻该显示什么字:正在重试说「重试中…」,正在跑的那一支说「修复中…」,刚复制过的说「已复制」,其余原样。
|
|
30
|
+
* @param action - 这颗钮的形状(行为 + 平时文案)。
|
|
31
|
+
* @param state - 此刻的运行态。
|
|
32
|
+
* @param t - i18n 取词函数。
|
|
33
|
+
* @returns 要显示的文案;三种临时态都不成立时就是 `action.label`。
|
|
34
|
+
*/
|
|
13
35
|
export declare function blockerActionLabel(action: BlockerActionShape, state: BlockerLabelState, t: BlockerLabelTranslate): string;
|
|
@@ -1,6 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 这颗钮此刻该不该按成等待态:这一轮忙还没收,或有一支正在跑。
|
|
3
|
+
* @param busy - 这一轮忙是不是还在。
|
|
4
|
+
* @param running - 正在跑的那一支的 label;没有就给 `null`。
|
|
5
|
+
* @returns 该等待给 `true`,否则 `false`。
|
|
6
|
+
*/
|
|
1
7
|
export function blockerPending(busy, running) {
|
|
2
8
|
return busy || running !== null;
|
|
3
9
|
}
|
|
10
|
+
/**
|
|
11
|
+
* 这颗钮此刻该显示什么字:正在重试说「重试中…」,正在跑的那一支说「修复中…」,刚复制过的说「已复制」,其余原样。
|
|
12
|
+
* @param action - 这颗钮的形状(行为 + 平时文案)。
|
|
13
|
+
* @param state - 此刻的运行态。
|
|
14
|
+
* @param t - i18n 取词函数。
|
|
15
|
+
* @returns 要显示的文案;三种临时态都不成立时就是 `action.label`。
|
|
16
|
+
*/
|
|
4
17
|
export function blockerActionLabel(action, state, t) {
|
|
5
18
|
if (action.kind === 'retry' && state.retrying)
|
|
6
19
|
return t('blocker.retry.running');
|
package/dist/lib/board-fact.d.ts
CHANGED
|
@@ -1,5 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 椅面(右栏那块画板)此刻归属哪一类:`workshop` 本工坊、`other` 别家、`hidden` 没画出来、`unknown` 探不到。
|
|
3
|
+
*/
|
|
1
4
|
export type BoardFactState = 'workshop' | 'other' | 'hidden' | 'unknown';
|
|
5
|
+
/**
|
|
6
|
+
* 左栏底部「调试」那条状态要说的档位:`ok` 在板上、`off-workspace` 切去了别的项目、`panel-closed` 面板没开、`other-board` 画的是别家的板、`unknown` 探不到。
|
|
7
|
+
*/
|
|
2
8
|
export type BoardSituation = 'ok' | 'off-workspace' | 'panel-closed' | 'other-board' | 'unknown';
|
|
9
|
+
/**
|
|
10
|
+
* 一次页面探针的读数:外壳在不在、探的是哪个工作区、右栏开没开、板上挂的路径、椅面画出来没有。
|
|
11
|
+
*/
|
|
3
12
|
export interface BoardProbe {
|
|
4
13
|
readonly workbench: boolean;
|
|
5
14
|
readonly where: string;
|
|
@@ -8,6 +17,24 @@ export interface BoardProbe {
|
|
|
8
17
|
readonly open: boolean;
|
|
9
18
|
readonly drawn: boolean;
|
|
10
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* 判一个路径落不落在这个工作区里(按路径前缀比,不是字符串包含)。
|
|
22
|
+
* @param root - 工作区根路径。
|
|
23
|
+
* @param target - 要判的路径。
|
|
24
|
+
* @returns 同一个路径或在其下给 `true`;`root` 末尾带不带斜杠都认(`/a` 不匹配 `/ab`)。
|
|
25
|
+
*/
|
|
11
26
|
export declare function insideWorkshop(root: string, target: string): boolean;
|
|
27
|
+
/**
|
|
28
|
+
* 把一次探针读数归成椅面归属。
|
|
29
|
+
* @param probe - 探针读数。
|
|
30
|
+
* @param workshop - 当前工作区根路径;`null` 表示还不知道当前是哪个工作区。
|
|
31
|
+
* @returns 外壳不在、或板路径与工作区缺一 → `unknown`;右栏没开或没画出来 → `hidden`;板在本工作区 → `workshop`,否则 `other`。
|
|
32
|
+
*/
|
|
12
33
|
export declare function boardFactOf(probe: BoardProbe, workshop: string | null): BoardFactState;
|
|
34
|
+
/**
|
|
35
|
+
* 把探针读数归成左栏那句人话的档位。
|
|
36
|
+
* @param probe - 探针读数。
|
|
37
|
+
* @param workshop - 当前工作区根路径;`null` 一律 `unknown`。
|
|
38
|
+
* @returns 椅面画着 → 本板 `ok` / 别板 `other-board`;没画着 → 页面已走 `off-workspace`,否则 `panel-closed`。
|
|
39
|
+
*/
|
|
13
40
|
export declare function boardSituation(probe: BoardProbe, workshop: string | null): BoardSituation;
|
package/dist/lib/board-fact.js
CHANGED
|
@@ -1,9 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 判一个路径落不落在这个工作区里(按路径前缀比,不是字符串包含)。
|
|
3
|
+
* @param root - 工作区根路径。
|
|
4
|
+
* @param target - 要判的路径。
|
|
5
|
+
* @returns 同一个路径或在其下给 `true`;`root` 末尾带不带斜杠都认(`/a` 不匹配 `/ab`)。
|
|
6
|
+
*/
|
|
1
7
|
export function insideWorkshop(root, target) {
|
|
2
8
|
if (target === root)
|
|
3
9
|
return true;
|
|
4
10
|
const base = root.endsWith('/') ? root : `${root}/`;
|
|
5
11
|
return target.startsWith(base);
|
|
6
12
|
}
|
|
13
|
+
/**
|
|
14
|
+
* 把一次探针读数归成椅面归属。
|
|
15
|
+
* @param probe - 探针读数。
|
|
16
|
+
* @param workshop - 当前工作区根路径;`null` 表示还不知道当前是哪个工作区。
|
|
17
|
+
* @returns 外壳不在、或板路径与工作区缺一 → `unknown`;右栏没开或没画出来 → `hidden`;板在本工作区 → `workshop`,否则 `other`。
|
|
18
|
+
*/
|
|
7
19
|
export function boardFactOf(probe, workshop) {
|
|
8
20
|
if (!probe.workbench)
|
|
9
21
|
return 'unknown';
|
|
@@ -13,6 +25,12 @@ export function boardFactOf(probe, workshop) {
|
|
|
13
25
|
return 'unknown';
|
|
14
26
|
return insideWorkshop(workshop, probe.board) ? 'workshop' : 'other';
|
|
15
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* 把探针读数归成左栏那句人话的档位。
|
|
30
|
+
* @param probe - 探针读数。
|
|
31
|
+
* @param workshop - 当前工作区根路径;`null` 一律 `unknown`。
|
|
32
|
+
* @returns 椅面画着 → 本板 `ok` / 别板 `other-board`;没画着 → 页面已走 `off-workspace`,否则 `panel-closed`。
|
|
33
|
+
*/
|
|
16
34
|
export function boardSituation(probe, workshop) {
|
|
17
35
|
if (!probe.workbench || workshop === null)
|
|
18
36
|
return 'unknown';
|
package/dist/lib/busy.d.ts
CHANGED
|
@@ -1,5 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 忙态按下限收尾的判据结果:还该不该显示(`visible`),以及还要按住多少毫秒(`releaseInMs`,0 = 立刻可收)。
|
|
3
|
+
*/
|
|
1
4
|
export interface BusyHold {
|
|
2
5
|
readonly visible: boolean;
|
|
3
6
|
readonly releaseInMs: number;
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* 按「至少显示 floorMs」算这一轮忙此刻该不该收:没到下限就继续显示,并给出剩余时长供调用方起定时器。
|
|
10
|
+
* @param since - 这一轮忙开始的时间戳;`null`(没开过这一轮)一律不显示。
|
|
11
|
+
* @param now - 当前时间戳。
|
|
12
|
+
* @param floorMs - 至少显示的时长(毫秒)。
|
|
13
|
+
* @returns 还该不该显示 + 剩余毫秒;到点或已过下限给不显示,时钟倒退按「刚开头」算(剩余 = 下限,不给负数)。
|
|
14
|
+
*/
|
|
5
15
|
export declare function holdBusy(since: number | null, now: number, floorMs: number): BusyHold;
|
package/dist/lib/busy.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 按「至少显示 floorMs」算这一轮忙此刻该不该收:没到下限就继续显示,并给出剩余时长供调用方起定时器。
|
|
3
|
+
* @param since - 这一轮忙开始的时间戳;`null`(没开过这一轮)一律不显示。
|
|
4
|
+
* @param now - 当前时间戳。
|
|
5
|
+
* @param floorMs - 至少显示的时长(毫秒)。
|
|
6
|
+
* @returns 还该不该显示 + 剩余毫秒;到点或已过下限给不显示,时钟倒退按「刚开头」算(剩余 = 下限,不给负数)。
|
|
7
|
+
*/
|
|
1
8
|
export function holdBusy(since, now, floorMs) {
|
|
2
9
|
if (since === null)
|
|
3
10
|
return { visible: false, releaseInMs: 0 };
|
package/dist/lib/diy-debug.d.ts
CHANGED
|
@@ -1,26 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 调试约定的两个相位:`debugging` 正占着用户的屏,`paused` 已暂停但仍持着约定。
|
|
3
|
+
*/
|
|
1
4
|
export type DebugPhase = 'debugging' | 'paused';
|
|
5
|
+
/**
|
|
6
|
+
* 调试约定收得下的三个人话动作:暂停 / 继续 / 结束。
|
|
7
|
+
*/
|
|
2
8
|
export type DebugIntent = 'pause' | 'resume' | 'stop';
|
|
9
|
+
/**
|
|
10
|
+
* 把工具入参收成人话动作。
|
|
11
|
+
* @param value - 任意入参值。
|
|
12
|
+
* @returns `'pause'` / `'resume'` / `'stop'` 原样;别的值(含 `undefined`、多余空白、大小写不同)给 `null`,由调用方拒。
|
|
13
|
+
*/
|
|
3
14
|
export declare function parseDebugIntent(value: unknown): DebugIntent | null;
|
|
15
|
+
/**
|
|
16
|
+
* 调试约定的有效期(4 小时,毫秒):超过它没动静的约定算过期、当场让人。
|
|
17
|
+
*/
|
|
4
18
|
export declare const DEBUG_STALE_MS: number;
|
|
19
|
+
/**
|
|
20
|
+
* 一份活着的调试约定:相位 + 谁的会话 + 哪个工作区 / 板 / 单元 + 起于何时(`at` 是最后一次动作)。
|
|
21
|
+
*/
|
|
5
22
|
export interface DebugState {
|
|
6
23
|
readonly phase: DebugPhase;
|
|
7
24
|
readonly sessionId: string;
|
|
8
|
-
readonly
|
|
25
|
+
readonly workspacePath: string;
|
|
26
|
+
readonly title: string;
|
|
9
27
|
readonly board: string;
|
|
10
28
|
readonly unit: string;
|
|
11
29
|
readonly name: string;
|
|
12
30
|
readonly startedAt: number;
|
|
13
31
|
readonly at: number;
|
|
14
32
|
}
|
|
33
|
+
/**
|
|
34
|
+
* 建立约定要交的那几件:会话、工作区、板、单元、名字,以及此刻的时间戳。
|
|
35
|
+
*/
|
|
15
36
|
export interface DebugPact {
|
|
16
37
|
readonly sessionId: string;
|
|
17
|
-
readonly
|
|
38
|
+
readonly workspacePath: string;
|
|
39
|
+
readonly title: string;
|
|
18
40
|
readonly board: string;
|
|
19
41
|
readonly unit: string;
|
|
20
42
|
readonly name: string;
|
|
21
43
|
readonly now: number;
|
|
22
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* 约定被拒的原因码:自己已持有 / 别人持着 / 不是持有者 / 没有约定 / 已暂停 / 已在调试。
|
|
47
|
+
*/
|
|
23
48
|
export type DebugRefusal = 'already-held' | 'held-by-other' | 'not-owner' | 'none' | 'already-paused' | 'already-debugging';
|
|
49
|
+
/**
|
|
50
|
+
* 一次约定动作的结果:成功带新状态,失败带拒绝码。
|
|
51
|
+
*/
|
|
24
52
|
export type DebugMove = {
|
|
25
53
|
readonly ok: true;
|
|
26
54
|
readonly state: DebugState;
|
|
@@ -28,6 +56,9 @@ export type DebugMove = {
|
|
|
28
56
|
readonly ok: false;
|
|
29
57
|
readonly code: DebugRefusal;
|
|
30
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* 调试约定的存取口(外壳持有一份):`live` 取当前有效的约定,`begin` / `pause` / `resume` / `stop` 推相位。
|
|
61
|
+
*/
|
|
31
62
|
export interface DebugStore {
|
|
32
63
|
live(now: number): DebugState | null;
|
|
33
64
|
begin(pact: DebugPact): DebugMove;
|
|
@@ -36,5 +67,14 @@ export interface DebugStore {
|
|
|
36
67
|
stop(sessionId: string, now: number): DebugMove;
|
|
37
68
|
settle?(): Promise<void>;
|
|
38
69
|
}
|
|
70
|
+
/**
|
|
71
|
+
* 造一份新的调试约定存储(进程内存,同一时刻只可能有一份有效约定)。
|
|
72
|
+
* @returns 存取口;动作成不成都在返回的 `DebugMove` 里,不抛异常。
|
|
73
|
+
*/
|
|
39
74
|
export declare function createDebugStore(): DebugStore;
|
|
75
|
+
/**
|
|
76
|
+
* 「谁还占着」的一句话,用于别人来抢时说清现况。
|
|
77
|
+
* @param state - 当前有效的那份约定。
|
|
78
|
+
* @returns 形如「会话 x(自 HH:mm:ssZ 起在调试 y)」的中文串。
|
|
79
|
+
*/
|
|
40
80
|
export declare function debugOwnerText(state: DebugState): string;
|
package/dist/lib/diy-debug.js
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 把工具入参收成人话动作。
|
|
3
|
+
* @param value - 任意入参值。
|
|
4
|
+
* @returns `'pause'` / `'resume'` / `'stop'` 原样;别的值(含 `undefined`、多余空白、大小写不同)给 `null`,由调用方拒。
|
|
5
|
+
*/
|
|
1
6
|
export function parseDebugIntent(value) {
|
|
2
7
|
return value === 'pause' || value === 'resume' || value === 'stop' ? value : null;
|
|
3
8
|
}
|
|
9
|
+
/**
|
|
10
|
+
* 调试约定的有效期(4 小时,毫秒):超过它没动静的约定算过期、当场让人。
|
|
11
|
+
*/
|
|
4
12
|
export const DEBUG_STALE_MS = 4 * 60 * 60 * 1000;
|
|
5
13
|
function alive(state, now) {
|
|
6
14
|
if (state === null)
|
|
@@ -13,6 +21,10 @@ function ownerOf(state, sessionId, now) {
|
|
|
13
21
|
return 'none';
|
|
14
22
|
return held.sessionId === sessionId ? held : 'not-owner';
|
|
15
23
|
}
|
|
24
|
+
/**
|
|
25
|
+
* 造一份新的调试约定存储(进程内存,同一时刻只可能有一份有效约定)。
|
|
26
|
+
* @returns 存取口;动作成不成都在返回的 `DebugMove` 里,不抛异常。
|
|
27
|
+
*/
|
|
16
28
|
export function createDebugStore() {
|
|
17
29
|
let held = null;
|
|
18
30
|
const live = (now) => alive(held, now);
|
|
@@ -26,7 +38,8 @@ export function createDebugStore() {
|
|
|
26
38
|
const state = {
|
|
27
39
|
phase: 'debugging',
|
|
28
40
|
sessionId: pact.sessionId,
|
|
29
|
-
|
|
41
|
+
workspacePath: pact.workspacePath,
|
|
42
|
+
title: pact.title,
|
|
30
43
|
board: pact.board,
|
|
31
44
|
unit: pact.unit,
|
|
32
45
|
name: pact.name,
|
|
@@ -65,6 +78,11 @@ export function createDebugStore() {
|
|
|
65
78
|
},
|
|
66
79
|
};
|
|
67
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* 「谁还占着」的一句话,用于别人来抢时说清现况。
|
|
83
|
+
* @param state - 当前有效的那份约定。
|
|
84
|
+
* @returns 形如「会话 x(自 HH:mm:ssZ 起在调试 y)」的中文串。
|
|
85
|
+
*/
|
|
68
86
|
export function debugOwnerText(state) {
|
|
69
87
|
return `会话 ${state.sessionId}(自 ${new Date(state.startedAt).toISOString().slice(11, 19)}Z 起在调试 ${state.unit})`;
|
|
70
88
|
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 录制交接的三个相位:`armed` 等用户在外站页面上动手,`recording` 正在录,`finished` 录完待取。
|
|
3
|
+
*/
|
|
4
|
+
export type RecordPhase = 'armed' | 'recording' | 'finished';
|
|
5
|
+
/**
|
|
6
|
+
* 录制约定的有效期(15 分钟,毫秒):超过它没动静的约定算过期、当场让人。
|
|
7
|
+
*/
|
|
8
|
+
export declare const RECORD_STALE_MS: number;
|
|
9
|
+
/**
|
|
10
|
+
* 这次录制要找的那一次写:HTTP 方法 + URL 里必须含的一段(不填就是只认方法)。
|
|
11
|
+
*/
|
|
12
|
+
export interface RecordExpect {
|
|
13
|
+
readonly method: string;
|
|
14
|
+
readonly urlContains: string;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 一份活着的录制约定:相位 + 谁的会话 + 哪个工作区 / 单元 + 页面 URL 与标题 + 要找的那一次写 + 落盘文件 + 三个时间戳。
|
|
18
|
+
*/
|
|
19
|
+
export interface RecordState {
|
|
20
|
+
readonly phase: RecordPhase;
|
|
21
|
+
readonly sessionId: string;
|
|
22
|
+
readonly workspace: string;
|
|
23
|
+
readonly unit: string;
|
|
24
|
+
readonly name: string;
|
|
25
|
+
readonly url: string;
|
|
26
|
+
readonly title: string;
|
|
27
|
+
readonly action: string;
|
|
28
|
+
readonly expect: RecordExpect | null;
|
|
29
|
+
readonly captureFile: string;
|
|
30
|
+
readonly startedAt: number;
|
|
31
|
+
readonly t0: number | null;
|
|
32
|
+
readonly t1: number | null;
|
|
33
|
+
readonly at: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* 开一次录制要交的那几件:会话、工作区、单元、名字、页面 URL 与标题、动作名、期望、落盘文件,以及此刻时间。
|
|
37
|
+
*/
|
|
38
|
+
export interface RecordPact {
|
|
39
|
+
readonly sessionId: string;
|
|
40
|
+
readonly workspace: string;
|
|
41
|
+
readonly unit: string;
|
|
42
|
+
readonly name: string;
|
|
43
|
+
readonly url: string;
|
|
44
|
+
readonly title: string;
|
|
45
|
+
readonly action: string;
|
|
46
|
+
readonly expect: RecordExpect | null;
|
|
47
|
+
readonly captureFile: string;
|
|
48
|
+
readonly now: number;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* 录制被拒的原因码:自己已持有 / 别人持着 / 不是持有者 / 没有约定 / 已在录 / 还没 arm / 不在录 / 还没录完。
|
|
52
|
+
*/
|
|
53
|
+
export type RecordRefusal = 'already-held' | 'held-by-other' | 'not-owner' | 'none' | 'already-recording' | 'not-armed' | 'not-recording' | 'not-finished';
|
|
54
|
+
/**
|
|
55
|
+
* 一次录制动作的结果:成功带新状态,失败带拒绝码。
|
|
56
|
+
*/
|
|
57
|
+
export type RecordMove = {
|
|
58
|
+
readonly ok: true;
|
|
59
|
+
readonly state: RecordState;
|
|
60
|
+
} | {
|
|
61
|
+
readonly ok: false;
|
|
62
|
+
readonly code: RecordRefusal;
|
|
63
|
+
};
|
|
64
|
+
/**
|
|
65
|
+
* 录制约定收得下的三个人话动作:看看进度 / 停手 / 结束并取回。
|
|
66
|
+
*/
|
|
67
|
+
export type RecordIntent = 'peek' | 'halt' | 'stop';
|
|
68
|
+
/**
|
|
69
|
+
* 把工具入参收成人话动作。
|
|
70
|
+
* @param raw - 任意入参值。
|
|
71
|
+
* @returns `'peek'` / `'halt'` / `'stop'` 原样;别的值(含 `undefined`、多余空白)给 `null`,由调用方拒。
|
|
72
|
+
*/
|
|
73
|
+
export declare function parseRecordIntent(raw: unknown): RecordIntent | null;
|
|
74
|
+
/**
|
|
75
|
+
* 录制约定的存取口(外壳持有一份):相位随 `begin → started → finished` 推进,`release` 是收尾时放掉浏览器那一跳。
|
|
76
|
+
*/
|
|
77
|
+
export interface RecordStore {
|
|
78
|
+
readonly release?: ((state: RecordState) => Promise<{
|
|
79
|
+
readonly tab: boolean;
|
|
80
|
+
readonly capture: boolean;
|
|
81
|
+
}>) | undefined;
|
|
82
|
+
live(now: number): RecordState | null;
|
|
83
|
+
begin(pact: RecordPact): RecordMove;
|
|
84
|
+
started(sessionId: string, at: number, now: number): RecordMove;
|
|
85
|
+
finished(sessionId: string, at: number, now: number): RecordMove;
|
|
86
|
+
stop(sessionId: string, now: number): RecordMove;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 造一份新的录制约定存储(进程内存,同一时刻只可能有一份有效约定)。
|
|
90
|
+
* @returns 存取口;动作成不成都在返回的 `RecordMove` 里,不抛异常。
|
|
91
|
+
*/
|
|
92
|
+
export declare function createRecordStore(): RecordStore;
|
|
93
|
+
/**
|
|
94
|
+
* 「谁还占着、在录哪个动作」的一句话,用于别人来抢时说清现况。
|
|
95
|
+
* @param state - 当前有效的那份约定。
|
|
96
|
+
* @returns 形如「会话 x(自 HH:mm:ssZ 起在录 y 的「动作」)」的中文串。
|
|
97
|
+
*/
|
|
98
|
+
export declare function recordOwnerText(state: RecordState): string;
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 录制约定的有效期(15 分钟,毫秒):超过它没动静的约定算过期、当场让人。
|
|
3
|
+
*/
|
|
4
|
+
export const RECORD_STALE_MS = 15 * 60 * 1000;
|
|
5
|
+
/**
|
|
6
|
+
* 把工具入参收成人话动作。
|
|
7
|
+
* @param raw - 任意入参值。
|
|
8
|
+
* @returns `'peek'` / `'halt'` / `'stop'` 原样;别的值(含 `undefined`、多余空白)给 `null`,由调用方拒。
|
|
9
|
+
*/
|
|
10
|
+
export function parseRecordIntent(raw) {
|
|
11
|
+
return raw === 'peek' || raw === 'halt' || raw === 'stop' ? raw : null;
|
|
12
|
+
}
|
|
13
|
+
function alive(state, now) {
|
|
14
|
+
if (state === null)
|
|
15
|
+
return null;
|
|
16
|
+
return now - state.at <= RECORD_STALE_MS ? state : null;
|
|
17
|
+
}
|
|
18
|
+
function ownerOf(state, sessionId, now) {
|
|
19
|
+
const held = alive(state, now);
|
|
20
|
+
if (held === null)
|
|
21
|
+
return 'none';
|
|
22
|
+
return held.sessionId === sessionId ? held : 'not-owner';
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* 造一份新的录制约定存储(进程内存,同一时刻只可能有一份有效约定)。
|
|
26
|
+
* @returns 存取口;动作成不成都在返回的 `RecordMove` 里,不抛异常。
|
|
27
|
+
*/
|
|
28
|
+
export function createRecordStore() {
|
|
29
|
+
let held = null;
|
|
30
|
+
const live = (now) => alive(held, now);
|
|
31
|
+
return {
|
|
32
|
+
live,
|
|
33
|
+
begin(pact) {
|
|
34
|
+
const current = alive(held, pact.now);
|
|
35
|
+
if (current !== null) {
|
|
36
|
+
return { ok: false, code: current.sessionId === pact.sessionId ? 'already-held' : 'held-by-other' };
|
|
37
|
+
}
|
|
38
|
+
const state = {
|
|
39
|
+
phase: 'armed',
|
|
40
|
+
sessionId: pact.sessionId,
|
|
41
|
+
workspace: pact.workspace,
|
|
42
|
+
unit: pact.unit,
|
|
43
|
+
name: pact.name,
|
|
44
|
+
url: pact.url,
|
|
45
|
+
title: pact.title,
|
|
46
|
+
action: pact.action,
|
|
47
|
+
expect: pact.expect,
|
|
48
|
+
captureFile: pact.captureFile,
|
|
49
|
+
startedAt: pact.now,
|
|
50
|
+
t0: null,
|
|
51
|
+
t1: null,
|
|
52
|
+
at: pact.now,
|
|
53
|
+
};
|
|
54
|
+
held = state;
|
|
55
|
+
return { ok: true, state };
|
|
56
|
+
},
|
|
57
|
+
started(sessionId, at, now) {
|
|
58
|
+
const found = ownerOf(held, sessionId, now);
|
|
59
|
+
if (typeof found === 'string')
|
|
60
|
+
return { ok: false, code: found };
|
|
61
|
+
if (found.phase === 'recording')
|
|
62
|
+
return { ok: false, code: 'already-recording' };
|
|
63
|
+
if (found.phase !== 'armed')
|
|
64
|
+
return { ok: false, code: 'not-armed' };
|
|
65
|
+
const state = { ...found, phase: 'recording', t0: at, at: now };
|
|
66
|
+
held = state;
|
|
67
|
+
return { ok: true, state };
|
|
68
|
+
},
|
|
69
|
+
finished(sessionId, at, now) {
|
|
70
|
+
const found = ownerOf(held, sessionId, now);
|
|
71
|
+
if (typeof found === 'string')
|
|
72
|
+
return { ok: false, code: found };
|
|
73
|
+
if (found.phase !== 'recording')
|
|
74
|
+
return { ok: false, code: 'not-recording' };
|
|
75
|
+
const state = { ...found, phase: 'finished', t1: at, at: now };
|
|
76
|
+
held = state;
|
|
77
|
+
return { ok: true, state };
|
|
78
|
+
},
|
|
79
|
+
stop(sessionId, now) {
|
|
80
|
+
const found = ownerOf(held, sessionId, now);
|
|
81
|
+
if (typeof found === 'string')
|
|
82
|
+
return { ok: false, code: found };
|
|
83
|
+
held = null;
|
|
84
|
+
return { ok: true, state: found };
|
|
85
|
+
},
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* 「谁还占着、在录哪个动作」的一句话,用于别人来抢时说清现况。
|
|
90
|
+
* @param state - 当前有效的那份约定。
|
|
91
|
+
* @returns 形如「会话 x(自 HH:mm:ssZ 起在录 y 的「动作」)」的中文串。
|
|
92
|
+
*/
|
|
93
|
+
export function recordOwnerText(state) {
|
|
94
|
+
const at = new Date(state.startedAt).toISOString().slice(11, 19);
|
|
95
|
+
return `会话 ${state.sessionId}(自 ${at}Z 起在录 ${state.unit} 的「${state.action}」)`;
|
|
96
|
+
}
|
|
@@ -1,2 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 找 `root` 里第一个带 `[data-wb-problem]` 标记的元素 —— 表单校验失败时,调用方拿它定位「哪一格错了」。
|
|
3
|
+
* @param root - 要搜的范围(表单容器,或 document)。
|
|
4
|
+
* @returns 第一个出问题的元素;一个标记都没有就给 `null`。
|
|
5
|
+
*/
|
|
1
6
|
export declare function firstProblemOf(root: ParentNode): Element | null;
|
|
7
|
+
/**
|
|
8
|
+
* 把第一个出问题的元素滚进视野、并把焦点交给它里面第一个可聚焦控件(输入框 / 按钮 / 链接等)。
|
|
9
|
+
* @param root - 要搜的范围。
|
|
10
|
+
* @returns 找到并滚过给 `true`;没有问题给 `false`(不滚、不抢焦点);元素不可滚或没有可聚焦控件也不报错,只是少做一步。
|
|
11
|
+
*/
|
|
2
12
|
export declare function revealFirstProblem(root: ParentNode): boolean;
|