@dsh-workbench/shared 1.5.2-alpha.4 → 1.5.2-rc.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/dist/components/Activity.css +69 -0
- package/dist/components/Activity.d.ts +56 -0
- package/dist/components/Activity.js +47 -0
- package/dist/components/ApprovalDetail.css +3 -0
- package/dist/components/ApprovalDetail.d.ts +42 -0
- package/dist/components/ApprovalDetail.js +53 -0
- package/dist/components/ApprovalPlan.css +39 -0
- package/dist/components/ApprovalPlan.d.ts +27 -0
- package/dist/components/ApprovalPlan.js +19 -0
- package/dist/components/Card.css +19 -0
- package/dist/components/Card.d.ts +26 -0
- package/dist/components/Card.js +18 -0
- package/dist/components/CardAnchor.d.ts +21 -0
- package/dist/components/CardAnchor.js +19 -0
- package/dist/components/CardAnchor.module.css +3 -0
- package/dist/components/CardBoundary.d.ts +42 -0
- package/dist/components/CardBoundary.js +58 -0
- package/dist/components/CardBoundary.module.css +5 -0
- package/dist/components/CardHead.css +87 -0
- package/dist/components/CardHead.d.ts +30 -0
- package/dist/components/CardHead.js +27 -0
- package/dist/components/ChoiceGroup.css +182 -0
- package/dist/components/ChoiceGroup.d.ts +54 -0
- package/dist/components/ChoiceGroup.js +63 -0
- package/dist/components/ConfirmBar.css +26 -0
- package/dist/components/ConfirmBar.d.ts +36 -0
- package/dist/components/ConfirmBar.js +26 -0
- package/dist/components/EmptyIllustration.d.ts +12 -0
- package/dist/components/EmptyIllustration.js +32 -0
- package/dist/components/Field.css +20 -0
- package/dist/components/Field.d.ts +18 -0
- package/dist/components/Field.js +15 -0
- package/dist/components/Form.css +6 -0
- package/dist/components/Form.d.ts +22 -0
- package/dist/components/Form.js +60 -0
- package/dist/components/FormActions.css +13 -0
- package/dist/components/FormActions.d.ts +29 -0
- package/dist/components/FormActions.js +43 -0
- package/dist/components/FormNodes.d.ts +107 -0
- package/dist/components/FormNodes.js +165 -0
- package/dist/components/FormRows.css +107 -0
- package/dist/components/FormRows.d.ts +36 -0
- package/dist/components/FormRows.js +26 -0
- package/dist/components/FormTypes.d.ts +84 -0
- package/dist/components/FormTypes.js +1 -0
- package/dist/components/Link.css +22 -0
- package/dist/components/Link.d.ts +22 -0
- package/dist/components/Link.js +17 -0
- package/dist/components/LongTaskRow.css +171 -0
- package/dist/components/LongTaskRow.d.ts +94 -0
- package/dist/components/LongTaskRow.js +103 -0
- package/dist/components/Note.css +13 -0
- package/dist/components/Note.d.ts +20 -0
- package/dist/components/Note.js +14 -0
- package/dist/components/ResourceStates.css +114 -0
- package/dist/components/ResourceStates.d.ts +44 -0
- package/dist/components/ResourceStates.js +41 -0
- package/dist/components/Rows.css +42 -0
- package/dist/components/Rows.d.ts +28 -0
- package/dist/components/Rows.js +21 -0
- package/dist/components/SaveBar.d.ts +24 -0
- package/dist/components/SaveBar.js +25 -0
- package/dist/components/SelectField.css +182 -0
- package/dist/components/SelectField.d.ts +89 -0
- package/dist/components/SelectField.js +260 -0
- package/dist/components/SelectFieldNodes.d.ts +49 -0
- package/dist/components/SelectFieldNodes.js +43 -0
- package/dist/components/SettingsSection.css +25 -0
- package/dist/components/SettingsSection.d.ts +20 -0
- package/dist/components/SettingsSection.js +17 -0
- package/dist/components/SetupShell.d.ts +93 -0
- package/dist/components/SetupShell.js +64 -0
- package/dist/components/SetupShell.module.css +81 -0
- package/dist/components/Spinner.css +5 -0
- package/dist/components/Spinner.d.ts +15 -0
- package/dist/components/Spinner.js +13 -0
- package/dist/components/Stack.css +6 -0
- package/dist/components/Stack.d.ts +14 -0
- package/dist/components/Stack.js +10 -0
- package/dist/components/StateBlock.css +38 -0
- package/dist/components/StateBlock.d.ts +24 -0
- package/dist/components/StateBlock.js +22 -0
- package/dist/components/TextField.css +32 -0
- package/dist/components/TextField.d.ts +14 -0
- package/dist/components/TextField.js +10 -0
- package/dist/components/board-module.d.ts +307 -0
- package/dist/components/board-module.js +1 -0
- package/dist/components/card-view-validate.d.ts +5 -0
- package/dist/components/card-view-validate.js +256 -0
- package/dist/components/icons.d.ts +63 -0
- package/dist/components/icons.js +107 -0
- package/dist/components/layout/icon-command.d.ts +8 -0
- package/dist/components/layout/icon-command.js +21 -0
- package/dist/contract/capture.d.ts +16 -0
- package/dist/contract/capture.js +1 -0
- package/dist/contract/diagnostics.d.ts +34 -0
- package/dist/contract/diagnostics.js +124 -0
- package/dist/contract/needs.d.ts +3 -1
- package/dist/contract/needs.js +4 -2
- package/dist/contract/protocol/bundle-install.d.ts +1 -1
- package/dist/contract/protocol/unit-manager.d.ts +50 -0
- package/dist/contract/protocol/unit-manager.js +2 -0
- package/dist/contract/unit.js +2 -1
- package/dist/host/adapter-contract.d.ts +3 -0
- package/dist/host/adapter-contract.js +95 -0
- package/dist/host/adapter-set.d.ts +27 -0
- package/dist/host/adapter-set.js +258 -0
- package/dist/host/adapter-types.d.ts +87 -0
- package/dist/host/adapter-types.js +23 -0
- package/dist/host/adapters/platform.d.ts +14 -0
- package/dist/host/adapters/platform.js +40 -0
- package/dist/host/adapters.d.ts +28 -0
- package/dist/host/adapters.js +9 -0
- package/dist/host/auth-loss.d.ts +33 -0
- package/dist/host/auth-loss.js +107 -0
- package/dist/host/board-fact.d.ts +8 -0
- package/dist/host/board-fact.js +16 -0
- package/dist/host/boot-record.d.ts +11 -0
- package/dist/host/boot-record.js +31 -0
- package/dist/host/browser.d.ts +3 -0
- package/dist/host/browser.js +3 -0
- package/dist/host/bundle-manager.d.ts +4 -0
- package/dist/host/bundle-manager.js +338 -0
- package/dist/host/changelog.d.ts +28 -0
- package/dist/host/changelog.js +201 -0
- package/dist/host/cli-error.d.ts +8 -0
- package/dist/host/cli-error.js +70 -0
- package/dist/host/cli.d.ts +4 -0
- package/dist/host/cli.js +9 -0
- package/dist/host/config-sync.d.ts +40 -0
- package/dist/host/config-sync.js +267 -0
- package/dist/host/context-ref.d.ts +13 -0
- package/dist/host/context-ref.js +41 -0
- package/dist/host/data-error.d.ts +15 -0
- package/dist/host/data-error.js +23 -0
- package/dist/host/data-plan-check.d.ts +10 -0
- package/dist/host/data-plan-check.js +315 -0
- package/dist/host/data-plan.d.ts +15 -0
- package/dist/host/data-plan.js +283 -0
- package/dist/host/data-root.d.ts +5 -0
- package/dist/host/data-root.js +23 -0
- package/dist/host/diy-debug.d.ts +80 -0
- package/dist/host/diy-debug.js +89 -0
- package/dist/host/diy-preset.d.ts +26 -0
- package/dist/host/diy-preset.js +115 -0
- package/dist/host/diy-record.d.ts +135 -0
- package/dist/host/diy-record.js +163 -0
- package/dist/host/dsh-compat.d.ts +27 -0
- package/dist/host/dsh-compat.js +75 -0
- package/dist/host/dsh-plugins.d.ts +5 -0
- package/dist/host/dsh-plugins.js +51 -0
- package/dist/host/env-policy.d.ts +82 -0
- package/dist/host/env-policy.js +181 -0
- package/dist/host/extension.d.ts +7 -0
- package/dist/host/extension.js +40 -0
- package/dist/host/facts.d.ts +31 -0
- package/dist/host/facts.js +58 -0
- package/dist/host/fs-write.d.ts +96 -0
- package/dist/host/fs-write.js +183 -0
- package/dist/host/git.d.ts +5 -0
- package/dist/host/git.js +1 -0
- package/dist/host/host-actions.d.ts +2 -0
- package/dist/host/host-actions.js +5 -0
- package/dist/host/host-kit.d.ts +37 -0
- package/dist/host/host-kit.js +27 -0
- package/dist/host/http.d.ts +47 -0
- package/dist/host/http.js +289 -0
- package/dist/host/install-failure.d.ts +50 -0
- package/dist/host/install-failure.js +184 -0
- package/dist/host/installed-module.d.ts +25 -0
- package/dist/host/installed-module.js +289 -0
- package/dist/host/installed-sources.d.ts +10 -0
- package/dist/host/installed-sources.js +63 -0
- package/dist/host/lease.d.ts +70 -0
- package/dist/host/lease.js +264 -0
- package/dist/host/lib-capabilities.d.ts +22 -0
- package/dist/host/lib-capabilities.js +37 -0
- package/dist/host/lib-install.d.ts +19 -0
- package/dist/host/lib-install.js +40 -0
- package/dist/host/lib-runners.d.ts +18 -0
- package/dist/host/lib-runners.js +46 -0
- package/dist/host/local-declaration.d.ts +7 -0
- package/dist/host/local-declaration.js +33 -0
- package/dist/host/long-task.d.ts +97 -0
- package/dist/host/long-task.js +297 -0
- package/dist/host/market-index-claim.d.ts +19 -0
- package/dist/host/market-index-claim.js +87 -0
- package/dist/host/market-index-doc.d.ts +12 -0
- package/dist/host/market-index-doc.js +1 -0
- package/dist/host/market-index-parse.d.ts +28 -0
- package/dist/host/market-index-parse.js +413 -0
- package/dist/host/market-index.d.ts +13 -0
- package/dist/host/market-index.js +105 -0
- package/dist/host/module-root.d.ts +1 -0
- package/dist/host/module-root.js +5 -0
- package/dist/host/needs.d.ts +4 -0
- package/dist/host/needs.js +2 -0
- package/dist/host/npm-registry.d.ts +10 -0
- package/dist/host/npm-registry.js +16 -0
- package/dist/host/package-content.d.ts +8 -0
- package/dist/host/package-content.js +90 -0
- package/dist/host/package-kind.d.ts +13 -0
- package/dist/host/package-kind.js +51 -0
- package/dist/host/package-route.d.ts +33 -0
- package/dist/host/package-route.js +68 -0
- package/dist/host/panel-state.d.ts +120 -0
- package/dist/host/panel-state.js +177 -0
- package/dist/host/patch-blocks.d.ts +13 -0
- package/dist/host/patch-blocks.js +52 -0
- package/dist/host/patch.d.ts +4 -0
- package/dist/host/patch.js +7 -0
- package/dist/host/paths.d.ts +12 -0
- package/dist/host/paths.js +20 -0
- package/dist/host/payload.d.ts +12 -0
- package/dist/host/payload.js +16 -0
- package/dist/host/plan-results.d.ts +5 -0
- package/dist/host/plan-results.js +71 -0
- package/dist/host/plan-run.d.ts +41 -0
- package/dist/host/plan-run.js +87 -0
- package/dist/host/platform.d.ts +14 -0
- package/dist/host/platform.js +40 -0
- package/dist/host/plugin-ledger.d.ts +32 -0
- package/dist/host/plugin-ledger.js +106 -0
- package/dist/host/plugin.d.ts +3 -0
- package/dist/host/plugin.js +38 -0
- package/dist/host/port-types.d.ts +233 -0
- package/dist/host/port-types.js +1 -0
- package/dist/host/preflight.d.ts +32 -0
- package/dist/host/preflight.js +1 -0
- package/dist/host/process-alive.d.ts +6 -0
- package/dist/host/process-alive.js +16 -0
- package/dist/host/profile-bundles.d.ts +20 -0
- package/dist/host/profile-bundles.js +48 -0
- package/dist/host/profile-create.d.ts +19 -0
- package/dist/host/profile-create.js +124 -0
- package/dist/host/profile-port.d.ts +4 -0
- package/dist/host/profile-port.js +4 -0
- package/dist/host/profile-registries.d.ts +10 -0
- package/dist/host/profile-registries.js +149 -0
- package/dist/host/provision.d.ts +32 -0
- package/dist/host/provision.js +105 -0
- package/dist/host/read-json.d.ts +1 -0
- package/dist/host/read-json.js +11 -0
- package/dist/host/recipe-rules.d.ts +5 -0
- package/dist/host/recipe-rules.js +412 -0
- package/dist/host/recipe.d.ts +14 -0
- package/dist/host/recipe.js +332 -0
- package/dist/host/registry-declaration.d.ts +21 -0
- package/dist/host/registry-declaration.js +42 -0
- package/dist/host/reinstall-record.d.ts +16 -0
- package/dist/host/reinstall-record.js +54 -0
- package/dist/host/release-age.d.ts +24 -0
- package/dist/host/release-age.js +92 -0
- package/dist/host/release-packages.generated.d.ts +1 -0
- package/dist/host/release-packages.generated.js +10 -0
- package/dist/host/release-probe.d.ts +37 -0
- package/dist/host/release-probe.js +156 -0
- package/dist/host/runtime/browser-argv.d.ts +1 -0
- package/dist/host/runtime/browser-argv.js +9 -0
- package/dist/host/runtime/dsh-compat.d.ts +4 -0
- package/dist/host/runtime/dsh-compat.js +32 -16
- package/dist/host/runtime/front-app.d.ts +6 -0
- package/dist/host/runtime/front-app.js +70 -0
- package/dist/host/runtime/verified-dsh.d.ts +5 -0
- package/dist/host/runtime/verified-dsh.js +20 -0
- package/dist/host/shell-render.d.ts +52 -0
- package/dist/host/shell-render.js +117 -0
- package/dist/host/shell-text.d.ts +30 -0
- package/dist/host/shell-text.js +40 -0
- package/dist/host/shell.d.ts +25 -0
- package/dist/host/shell.js +55 -0
- package/dist/host/site.d.ts +45 -0
- package/dist/host/site.js +182 -0
- package/dist/host/spec.d.ts +8 -0
- package/dist/host/spec.js +24 -0
- package/dist/host/submit-confirm.d.ts +19 -0
- package/dist/host/submit-confirm.js +45 -0
- package/dist/host/supply/builtin-catalog.d.ts +3 -0
- package/dist/host/supply/builtin-catalog.js +38 -0
- package/dist/host/supply/preflight.d.ts +14 -1
- package/dist/host/supply/supply-index.js +6 -0
- package/dist/host/supply-index.d.ts +38 -0
- package/dist/host/supply-index.js +209 -0
- package/dist/host/supply-port.d.ts +5 -0
- package/dist/host/supply-port.js +50 -0
- package/dist/host/time.d.ts +22 -0
- package/dist/host/time.js +33 -0
- package/dist/host/tokens.d.ts +26 -0
- package/dist/host/tokens.js +154 -0
- package/dist/host/tool-approval.d.ts +86 -0
- package/dist/host/tool-approval.js +118 -0
- package/dist/host/tool-kit.d.ts +8 -0
- package/dist/host/tool-kit.js +22 -0
- package/dist/host/toolbox-port.d.ts +16 -0
- package/dist/host/toolbox-port.js +1 -0
- package/dist/host/unit-config.d.ts +34 -0
- package/dist/host/unit-config.js +28 -0
- package/dist/host/unit-data.d.ts +3 -0
- package/dist/host/unit-data.js +127 -0
- package/dist/host/unit-face.d.ts +95 -0
- package/dist/host/unit-face.js +1 -0
- package/dist/host/unit-plugin.d.ts +24 -0
- package/dist/host/unit-plugin.js +25 -0
- package/dist/host/update-journal-manifest.d.ts +19 -0
- package/dist/host/update-journal-manifest.js +134 -0
- package/dist/host/update-journal-types.d.ts +33 -0
- package/dist/host/update-journal-types.js +2 -0
- package/dist/host/update-journal.d.ts +43 -0
- package/dist/host/update-journal.js +409 -0
- package/dist/host/value-handoff.d.ts +16 -0
- package/dist/host/value-handoff.js +22 -0
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +13 -0
- package/dist/host/version.d.ts +4 -0
- package/dist/host/version.js +32 -0
- package/dist/host/workspace-store.d.ts +19 -0
- package/dist/host/workspace-store.js +133 -0
- package/dist/host/write-result.d.ts +1 -0
- package/dist/host/write-result.js +18 -0
- package/dist/host.d.ts +2 -0
- package/dist/host.js +2 -0
- package/dist/i18n/en.js +14 -3
- package/dist/i18n/index.d.ts +15 -4
- package/dist/i18n/zh.d.ts +14 -3
- package/dist/i18n/zh.js +14 -3
- package/dist/lib/bundle-requirements.d.ts +1 -0
- package/dist/lib/bundle-requirements.js +9 -0
- package/package.json +1 -1
- package/src/contract/__tests__/unit.test.ts +7 -0
- package/src/contract/needs.ts +5 -3
- package/src/contract/protocol/bundle-install.ts +1 -0
- package/src/contract/unit.ts +2 -1
- package/src/host/runtime/__tests__/dsh-compat.test.ts +19 -1
- package/src/host/runtime/__tests__/verified-dsh.test.ts +55 -0
- package/src/host/runtime/dsh-compat.ts +36 -12
- package/src/host/runtime/verified-dsh.ts +22 -0
- package/src/host/supply/__tests__/builtin-catalog.test.ts +44 -0
- package/src/host/supply/builtin-catalog.ts +38 -0
- package/src/host/supply/preflight.ts +16 -1
- package/src/host/supply/supply-index.ts +3 -0
- package/src/host.ts +2 -0
- package/src/i18n/en.ts +17 -3
- package/src/i18n/zh.ts +16 -3
- package/src/lib/bundle-requirements.ts +11 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
.wb-activityBlock {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--wb-len-6);
|
|
5
|
+
padding-top: var(--wb-len-10);
|
|
6
|
+
border-top: 0.5px solid var(--dsw-alias-border-l2);
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
.wb-activityBlock:first-child {
|
|
10
|
+
padding-top: 0;
|
|
11
|
+
border-top: none;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
.wb-activityBlockHead {
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: space-between;
|
|
18
|
+
gap: var(--wb-len-8);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.wb-activityLine {
|
|
22
|
+
display: flex;
|
|
23
|
+
align-items: center;
|
|
24
|
+
gap: var(--wb-len-6);
|
|
25
|
+
margin: 0;
|
|
26
|
+
font-size: var(--dsw-font-xxs-12-font-size);
|
|
27
|
+
line-height: var(--wb-line-18);
|
|
28
|
+
color: var(--dsw-alias-label-secondary);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.wb-activityLineText {
|
|
32
|
+
flex: none;
|
|
33
|
+
min-width: 0;
|
|
34
|
+
font-size: var(--dsw-font-xxs-12-font-size);
|
|
35
|
+
line-height: var(--wb-line-18);
|
|
36
|
+
overflow-wrap: anywhere;
|
|
37
|
+
white-space: pre-wrap;
|
|
38
|
+
max-height: var(--wb-len-72);
|
|
39
|
+
overflow-y: auto;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
.wb-activityLineAt {
|
|
43
|
+
flex: none;
|
|
44
|
+
margin-left: auto;
|
|
45
|
+
font-size: var(--wb-font-10);
|
|
46
|
+
line-height: var(--wb-line-16);
|
|
47
|
+
font-variant-numeric: tabular-nums;
|
|
48
|
+
color: var(--dsw-alias-label-tertiary);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.wb-activityLine > .wb-activityLineAt,
|
|
52
|
+
.wb-activityLine > .wb-activityLineActions {
|
|
53
|
+
margin-left: auto;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
.wb-activityLine > .wb-activityLineAt + .wb-activityLineActions {
|
|
57
|
+
margin-left: 0;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
.wb-activityLineActions {
|
|
61
|
+
flex: none;
|
|
62
|
+
display: inline-flex;
|
|
63
|
+
align-items: center;
|
|
64
|
+
gap: var(--wb-len-6);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
.wb-activityActionFailed {
|
|
68
|
+
color: var(--dsw-alias-state-error-primary);
|
|
69
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import type { ReactNode } from '../lib/react.js';
|
|
2
|
+
import './Activity.css';
|
|
3
|
+
/**
|
|
4
|
+
* `ActivityBlock` 的契约:块头与块内容。
|
|
5
|
+
*/
|
|
6
|
+
export interface ActivityBlockProps {
|
|
7
|
+
readonly head?: ReactNode | undefined;
|
|
8
|
+
readonly children?: ReactNode | undefined;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* "它做过什么"那一块:上面一行块头、下面一列活动行,卡里放时间线就用它。
|
|
12
|
+
* @param props.head - 块头(如"最近 10 次");不给不画那一行。
|
|
13
|
+
* @param props.children - 块内容,通常是一串 `ActivityLine`。
|
|
14
|
+
* @returns 一个 div。
|
|
15
|
+
*/
|
|
16
|
+
export declare function ActivityBlock({ head, children }: ActivityBlockProps): JSX.Element;
|
|
17
|
+
/**
|
|
18
|
+
* `ActivityLine` 的契约:状态点、正文、时间与行尾动作。
|
|
19
|
+
*/
|
|
20
|
+
export interface ActivityLineProps {
|
|
21
|
+
readonly dot?: ReactNode | undefined;
|
|
22
|
+
readonly text: ReactNode;
|
|
23
|
+
readonly at?: ReactNode | undefined;
|
|
24
|
+
readonly actions?: ReactNode | undefined;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* 一条活动:状态点 + 正文 + 时间,行尾可挂动作;时间一律用它,别自己拼。
|
|
28
|
+
* @param props.dot - 行首那枚状态点;不给就只留正文。
|
|
29
|
+
* @param props.text - 这一条干了什么。
|
|
30
|
+
* @param props.at - 时间那一格(相对时间文本);不给不画。
|
|
31
|
+
* @param props.actions - 行尾动作,通常是一两颗 `ActivityAction`;不给不画。
|
|
32
|
+
* @returns 一行。
|
|
33
|
+
*/
|
|
34
|
+
export declare function ActivityLine({ dot, text, at, actions }: ActivityLineProps): JSX.Element;
|
|
35
|
+
/**
|
|
36
|
+
* `ActivityAction` 的契约:一颗图标钮、一个外链,或一个失败态。
|
|
37
|
+
*/
|
|
38
|
+
export interface ActivityActionProps {
|
|
39
|
+
readonly label: string;
|
|
40
|
+
readonly hint?: string | undefined;
|
|
41
|
+
readonly icon: ReactNode;
|
|
42
|
+
readonly href?: string | undefined;
|
|
43
|
+
readonly onClick?: (() => void) | undefined;
|
|
44
|
+
readonly failed?: boolean | undefined;
|
|
45
|
+
}
|
|
46
|
+
/**
|
|
47
|
+
* 活动行尾那颗动作:给 `href` 就是外链,否则是图标钮并带上 tooltip。
|
|
48
|
+
* @param props.label - 读屏名,也是 `hint` 不给时的 tooltip 文案。
|
|
49
|
+
* @param props.hint - tooltip 上那句更细的说明;不给退化成 `label`。
|
|
50
|
+
* @param props.icon - 那颗图标。
|
|
51
|
+
* @param props.href - 给了就渲染成新窗口外链;与 `onClick` 同时给时以它为准。
|
|
52
|
+
* @param props.onClick - 图标钮的点击回调。
|
|
53
|
+
* @param props.failed - 上一次动作失败了:钮换成危险色(默认 false)。
|
|
54
|
+
* @returns 一个 `<a>` 或一颗 `Button`。
|
|
55
|
+
*/
|
|
56
|
+
export declare function ActivityAction({ label, hint, icon, href, onClick, failed }: ActivityActionProps): JSX.Element;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { Button, Tooltip } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
2
|
+
import { h } from '../lib/react.js';
|
|
3
|
+
import './Activity.css';
|
|
4
|
+
/**
|
|
5
|
+
* "它做过什么"那一块:上面一行块头、下面一列活动行,卡里放时间线就用它。
|
|
6
|
+
* @param props.head - 块头(如"最近 10 次");不给不画那一行。
|
|
7
|
+
* @param props.children - 块内容,通常是一串 `ActivityLine`。
|
|
8
|
+
* @returns 一个 div。
|
|
9
|
+
*/
|
|
10
|
+
export function ActivityBlock({ head, children }) {
|
|
11
|
+
return (h("div", { className: "wb-activityBlock" },
|
|
12
|
+
head === undefined ? null : h("div", { className: "wb-activityBlockHead" }, head),
|
|
13
|
+
children));
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 一条活动:状态点 + 正文 + 时间,行尾可挂动作;时间一律用它,别自己拼。
|
|
17
|
+
* @param props.dot - 行首那枚状态点;不给就只留正文。
|
|
18
|
+
* @param props.text - 这一条干了什么。
|
|
19
|
+
* @param props.at - 时间那一格(相对时间文本);不给不画。
|
|
20
|
+
* @param props.actions - 行尾动作,通常是一两颗 `ActivityAction`;不给不画。
|
|
21
|
+
* @returns 一行。
|
|
22
|
+
*/
|
|
23
|
+
export function ActivityLine({ dot, text, at, actions }) {
|
|
24
|
+
return (h("div", { className: "wb-activityLine" },
|
|
25
|
+
dot,
|
|
26
|
+
h("span", { className: "wb-activityLineText" }, text),
|
|
27
|
+
at === undefined ? null : h("span", { className: "wb-activityLineAt" }, at),
|
|
28
|
+
actions === undefined ? null : h("span", { className: "wb-activityLineActions" }, actions)));
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* 活动行尾那颗动作:给 `href` 就是外链,否则是图标钮并带上 tooltip。
|
|
32
|
+
* @param props.label - 读屏名,也是 `hint` 不给时的 tooltip 文案。
|
|
33
|
+
* @param props.hint - tooltip 上那句更细的说明;不给退化成 `label`。
|
|
34
|
+
* @param props.icon - 那颗图标。
|
|
35
|
+
* @param props.href - 给了就渲染成新窗口外链;与 `onClick` 同时给时以它为准。
|
|
36
|
+
* @param props.onClick - 图标钮的点击回调。
|
|
37
|
+
* @param props.failed - 上一次动作失败了:钮换成危险色(默认 false)。
|
|
38
|
+
* @returns 一个 `<a>` 或一颗 `Button`。
|
|
39
|
+
*/
|
|
40
|
+
export function ActivityAction({ label, hint, icon, href, onClick, failed }) {
|
|
41
|
+
const tip = hint ?? label;
|
|
42
|
+
if (href !== undefined) {
|
|
43
|
+
return (h("a", { className: "wb-iconButton", href: href, target: "_blank", rel: "noreferrer noopener", title: tip, "aria-label": label }, icon));
|
|
44
|
+
}
|
|
45
|
+
return (h(Tooltip, { side: "bottom", align: "end", gap: 6, portal: true, label: tip },
|
|
46
|
+
h(Button, { type: "button", variant: "ghost", size: "sm", className: failed === true ? 'wb-iconButton wb-activityActionFailed' : 'wb-iconButton', "aria-label": label, icon: icon, onClick: onClick })));
|
|
47
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Translate } from '../lib/dsh-client.js';
|
|
2
|
+
import type { ApprovalInput, UnitClientFace } from '../components/board-module.js';
|
|
3
|
+
import { type ReactNode } from '../lib/react.js';
|
|
4
|
+
import './ApprovalDetail.css';
|
|
5
|
+
interface ToolCallRoot {
|
|
6
|
+
readonly callId?: string;
|
|
7
|
+
readonly name?: string;
|
|
8
|
+
readonly phase?: string;
|
|
9
|
+
readonly argsRaw?: string;
|
|
10
|
+
}
|
|
11
|
+
interface ChatSnapshot {
|
|
12
|
+
readonly nodes?: {
|
|
13
|
+
values(): Iterable<{
|
|
14
|
+
readonly kind?: string;
|
|
15
|
+
readonly data?: {
|
|
16
|
+
readonly root?: ToolCallRoot;
|
|
17
|
+
};
|
|
18
|
+
}>;
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
type UseChat = <T>(selector: (snapshot: ChatSnapshot) => T) => T | undefined;
|
|
22
|
+
/**
|
|
23
|
+
* `ApprovalDetail` 的契约:调用 id、读会话快照的钩子、已装模块与兜底渲染。
|
|
24
|
+
*/
|
|
25
|
+
export interface ApprovalDetailProps {
|
|
26
|
+
readonly callId?: string;
|
|
27
|
+
readonly useChat?: UseChat;
|
|
28
|
+
readonly units?: readonly UnitClientFace[];
|
|
29
|
+
readonly t?: Translate;
|
|
30
|
+
readonly renderShell?: ((input: ApprovalInput, t: Translate) => ReactNode) | undefined;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* 审批屏的详情格:按工具名找到认领它的模块交给它渲染,没有模块认领就退回外壳那张表或一段原始命令。
|
|
34
|
+
* @param props.callId - 这次工具调用的 id;不给就直接走兜底(连调用都找不到)。
|
|
35
|
+
* @param props.useChat - 读会话快照的钩子(dsh 注入);不给就当作读不到调用。
|
|
36
|
+
* @param props.units - 已装模块的面,按各自的 `approval.tools` 认领这次调用。
|
|
37
|
+
* @param props.t - 翻译函数;不给就用返回 key 的直通实现。
|
|
38
|
+
* @param props.renderShell - 没有模块认领时外壳自己的渲染(那张表);不给且这次调用没带 `command` 时整格返回 `null`。
|
|
39
|
+
* @returns 认领方的渲染、外壳那张表,或一段可复制的命令。
|
|
40
|
+
*/
|
|
41
|
+
export declare function ApprovalDetail(props: ApprovalDetailProps): JSX.Element | null;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Fragment, h } from '../lib/react.js';
|
|
2
|
+
import { CodeBlock } from '@deepseek-ai/dsh-client-ui-primitives';
|
|
3
|
+
import { CardBoundary } from './CardBoundary.js';
|
|
4
|
+
import './ApprovalDetail.css';
|
|
5
|
+
function callOf(snapshot, callId) {
|
|
6
|
+
if (callId === undefined)
|
|
7
|
+
return undefined;
|
|
8
|
+
for (const node of snapshot.nodes?.values() ?? []) {
|
|
9
|
+
const root = node.kind === 'tool-call' ? node.data?.root : undefined;
|
|
10
|
+
if (root?.callId !== callId || root.phase !== 'start')
|
|
11
|
+
continue;
|
|
12
|
+
return { ...(root.name === undefined ? {} : { name: root.name }), argsRaw: root.argsRaw ?? '' };
|
|
13
|
+
}
|
|
14
|
+
return undefined;
|
|
15
|
+
}
|
|
16
|
+
function parseArgs(raw) {
|
|
17
|
+
try {
|
|
18
|
+
const parsed = JSON.parse(raw);
|
|
19
|
+
return typeof parsed === 'object' && parsed !== null ? parsed : {};
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return {};
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* 审批屏的详情格:按工具名找到认领它的模块交给它渲染,没有模块认领就退回外壳那张表或一段原始命令。
|
|
27
|
+
* @param props.callId - 这次工具调用的 id;不给就直接走兜底(连调用都找不到)。
|
|
28
|
+
* @param props.useChat - 读会话快照的钩子(dsh 注入);不给就当作读不到调用。
|
|
29
|
+
* @param props.units - 已装模块的面,按各自的 `approval.tools` 认领这次调用。
|
|
30
|
+
* @param props.t - 翻译函数;不给就用返回 key 的直通实现。
|
|
31
|
+
* @param props.renderShell - 没有模块认领时外壳自己的渲染(那张表);不给且这次调用没带 `command` 时整格返回 `null`。
|
|
32
|
+
* @returns 认领方的渲染、外壳那张表,或一段可复制的命令。
|
|
33
|
+
*/
|
|
34
|
+
export function ApprovalDetail(props) {
|
|
35
|
+
const useChat = props.useChat ?? (() => undefined);
|
|
36
|
+
const call = useChat((snapshot) => callOf(snapshot, props.callId));
|
|
37
|
+
const t = props.t ?? ((key) => key);
|
|
38
|
+
const args = parseArgs(call?.argsRaw ?? '');
|
|
39
|
+
const input = { tool: call?.name ?? '', args };
|
|
40
|
+
const command = typeof args.command === 'string' ? args.command : '';
|
|
41
|
+
const owner = (props.units ?? []).find((face) => face.approval?.tools.includes(input.tool) === true);
|
|
42
|
+
if (owner?.approval !== undefined) {
|
|
43
|
+
const Render = owner.approval.render;
|
|
44
|
+
return (h(CardBoundary, { unit: owner.unit, resetKey: props.callId ?? '', t: t },
|
|
45
|
+
h(Render, { input: input, t: t })));
|
|
46
|
+
}
|
|
47
|
+
const shell = props.renderShell?.(input, t);
|
|
48
|
+
if (shell !== undefined && shell !== null)
|
|
49
|
+
return h(Fragment, null, shell);
|
|
50
|
+
if (command === '')
|
|
51
|
+
return null;
|
|
52
|
+
return (h(CodeBlock, { code: command, className: "wb-approvalCommand", copyLabel: t('blocker.copy'), copiedLabel: t('env.copied') }));
|
|
53
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
.wb-approvalPlan {
|
|
2
|
+
display: flex;
|
|
3
|
+
flex-direction: column;
|
|
4
|
+
gap: var(--wb-len-6);
|
|
5
|
+
}
|
|
6
|
+
.wb-approvalHint {
|
|
7
|
+
margin: 0;
|
|
8
|
+
font-size: var(--dsw-font-xxs-12-font-size);
|
|
9
|
+
line-height: var(--wb-line-18);
|
|
10
|
+
color: var(--dsw-alias-label-secondary);
|
|
11
|
+
}
|
|
12
|
+
.wb-approvalRows {
|
|
13
|
+
display: grid;
|
|
14
|
+
grid-template-columns: minmax(var(--wb-len-56), auto) minmax(0, 1fr);
|
|
15
|
+
column-gap: var(--wb-len-8);
|
|
16
|
+
row-gap: var(--wb-len-2);
|
|
17
|
+
align-items: baseline;
|
|
18
|
+
margin: 0;
|
|
19
|
+
}
|
|
20
|
+
.wb-approvalRow {
|
|
21
|
+
display: contents;
|
|
22
|
+
}
|
|
23
|
+
.wb-approvalLabel {
|
|
24
|
+
font-size: var(--dsw-font-xxs-12-font-size);
|
|
25
|
+
line-height: var(--wb-line-18);
|
|
26
|
+
color: var(--dsw-alias-label-tertiary);
|
|
27
|
+
overflow-wrap: anywhere;
|
|
28
|
+
}
|
|
29
|
+
.wb-approvalValue {
|
|
30
|
+
margin: 0;
|
|
31
|
+
font-size: var(--dsw-font-xs-13-font-size);
|
|
32
|
+
line-height: var(--wb-line-18);
|
|
33
|
+
font-weight: 500;
|
|
34
|
+
color: var(--dsw-alias-label-primary);
|
|
35
|
+
overflow-wrap: anywhere;
|
|
36
|
+
}
|
|
37
|
+
.wb-approvalWarn {
|
|
38
|
+
color: var(--dsw-alias-label-secondary);
|
|
39
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { ReactNode } from '../lib/react.js';
|
|
2
|
+
import './ApprovalPlan.css';
|
|
3
|
+
/**
|
|
4
|
+
* 审批详情里的一行:左边标签、右边值。
|
|
5
|
+
*/
|
|
6
|
+
export interface ApprovalPlanRow {
|
|
7
|
+
readonly label: ReactNode;
|
|
8
|
+
readonly value: ReactNode;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* `ApprovalPlan` 的契约:详情行,外加附注与警告两格。
|
|
12
|
+
*/
|
|
13
|
+
export interface ApprovalPlanProps {
|
|
14
|
+
readonly rows: readonly ApprovalPlanRow[];
|
|
15
|
+
readonly hint?: ReactNode | undefined;
|
|
16
|
+
readonly warn?: ReactNode | undefined;
|
|
17
|
+
readonly children?: ReactNode | undefined;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* 审批屏那张"这次要做什么"的表:一行一项,上面可给一句附注、下面可给一句警告。
|
|
21
|
+
* @param props.rows - 详情行,按给的顺序渲染;空数组时只剩附注与警告。
|
|
22
|
+
* @param props.hint - 表上面那句说明;不给不画。
|
|
23
|
+
* @param props.warn - 表下面那句警告;不给不画。
|
|
24
|
+
* @param props.children - 插在表与 `warn` 之间的补充内容。
|
|
25
|
+
* @returns 一个 div。
|
|
26
|
+
*/
|
|
27
|
+
export declare function ApprovalPlan({ rows, hint, warn, children }: ApprovalPlanProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { h } from '../lib/react.js';
|
|
2
|
+
import './ApprovalPlan.css';
|
|
3
|
+
/**
|
|
4
|
+
* 审批屏那张"这次要做什么"的表:一行一项,上面可给一句附注、下面可给一句警告。
|
|
5
|
+
* @param props.rows - 详情行,按给的顺序渲染;空数组时只剩附注与警告。
|
|
6
|
+
* @param props.hint - 表上面那句说明;不给不画。
|
|
7
|
+
* @param props.warn - 表下面那句警告;不给不画。
|
|
8
|
+
* @param props.children - 插在表与 `warn` 之间的补充内容。
|
|
9
|
+
* @returns 一个 div。
|
|
10
|
+
*/
|
|
11
|
+
export function ApprovalPlan({ rows, hint, warn, children }) {
|
|
12
|
+
return (h("div", { className: "wb-approvalPlan" },
|
|
13
|
+
hint === undefined ? null : h("p", { className: "wb-approvalHint" }, hint),
|
|
14
|
+
h("dl", { className: "wb-approvalRows" }, rows.map((row, index) => (h("div", { className: "wb-approvalRow", key: String(index) },
|
|
15
|
+
h("dt", { className: "wb-approvalLabel" }, row.label),
|
|
16
|
+
h("dd", { className: "wb-approvalValue" }, row.value))))),
|
|
17
|
+
children,
|
|
18
|
+
warn === undefined ? null : h("p", { className: "wb-approvalWarn" }, warn)));
|
|
19
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
.wb-card {
|
|
2
|
+
border: 0.5px solid var(--dsw-alias-border-l3);
|
|
3
|
+
border-radius: var(--dsw-radius-xl);
|
|
4
|
+
background: var(--dsw-alias-bg-layer-1);
|
|
5
|
+
overflow: hidden;
|
|
6
|
+
display: flex;
|
|
7
|
+
flex-direction: column;
|
|
8
|
+
flex: none;
|
|
9
|
+
}
|
|
10
|
+
.wb-cardBody {
|
|
11
|
+
display: flex;
|
|
12
|
+
flex-direction: column;
|
|
13
|
+
gap: var(--wb-len-12);
|
|
14
|
+
padding: var(--wb-len-12) var(--wb-card-gutter);
|
|
15
|
+
font-size: var(--dsw-font-xxs-12-font-size);
|
|
16
|
+
}
|
|
17
|
+
.wb-cardBleed {
|
|
18
|
+
margin-inline: calc(-1 * var(--wb-card-gutter));
|
|
19
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { ReactNode } from '../lib/react.js';
|
|
2
|
+
import type { Translate } from '../lib/dsh-client.js';
|
|
3
|
+
import './Card.css';
|
|
4
|
+
/**
|
|
5
|
+
* `Card` 的契约:标题、刷新、卡片体,以及可整块替换的卡头。
|
|
6
|
+
*/
|
|
7
|
+
export interface CardProps {
|
|
8
|
+
readonly t: Translate;
|
|
9
|
+
readonly title: string;
|
|
10
|
+
readonly refreshing: boolean;
|
|
11
|
+
readonly onRefresh: () => void;
|
|
12
|
+
readonly meta?: ReactNode | undefined;
|
|
13
|
+
readonly head?: ReactNode | undefined;
|
|
14
|
+
readonly children?: ReactNode | undefined;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* 一张卡的壳:卡头(标题 + 刷新钮)+ 卡片体,面板上每一格都是它。
|
|
18
|
+
* @param props.t - 卡头那两句文案(刷新 / 刷新中)的翻译函数。
|
|
19
|
+
* @param props.refreshing - 正在刷新:刷新钮随之禁用并转圈;接 `resource.phase === 'loading'`。
|
|
20
|
+
* @param props.onRefresh - 点刷新钮做什么,异步由调用点自己管。
|
|
21
|
+
* @param props.meta - 标题右侧那一小段补充(条数、时间);不给不占位。
|
|
22
|
+
* @param props.head - 整块替换卡头时给(如自带齿轮的 `CardHead`);不给用默认卡头。
|
|
23
|
+
* @param props.children - 卡片体。
|
|
24
|
+
* @returns 一个 `<section>`。
|
|
25
|
+
*/
|
|
26
|
+
export declare function Card({ t, title, refreshing, onRefresh, meta, head, children }: CardProps): JSX.Element;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { h } from '../lib/react.js';
|
|
2
|
+
import { CardHead } from './CardHead.js';
|
|
3
|
+
import './Card.css';
|
|
4
|
+
/**
|
|
5
|
+
* 一张卡的壳:卡头(标题 + 刷新钮)+ 卡片体,面板上每一格都是它。
|
|
6
|
+
* @param props.t - 卡头那两句文案(刷新 / 刷新中)的翻译函数。
|
|
7
|
+
* @param props.refreshing - 正在刷新:刷新钮随之禁用并转圈;接 `resource.phase === 'loading'`。
|
|
8
|
+
* @param props.onRefresh - 点刷新钮做什么,异步由调用点自己管。
|
|
9
|
+
* @param props.meta - 标题右侧那一小段补充(条数、时间);不给不占位。
|
|
10
|
+
* @param props.head - 整块替换卡头时给(如自带齿轮的 `CardHead`);不给用默认卡头。
|
|
11
|
+
* @param props.children - 卡片体。
|
|
12
|
+
* @returns 一个 `<section>`。
|
|
13
|
+
*/
|
|
14
|
+
export function Card({ t, title, refreshing, onRefresh, meta, head, children }) {
|
|
15
|
+
return (h("section", { className: "wb-card" },
|
|
16
|
+
head === undefined ? (h(CardHead, { t: t, title: title, refreshing: refreshing, onRefresh: onRefresh, meta: meta })) : (head),
|
|
17
|
+
h("div", { className: "wb-cardBody" }, children)));
|
|
18
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { ReactNode } from '../lib/react.js';
|
|
2
|
+
/**
|
|
3
|
+
* 由 unit id 拼出卡片锚点 id,外壳的截图、滚动与页面探针都按它找卡。
|
|
4
|
+
* @param unit - unit id;`null` 或空串(没有 unit 的卡)时返回 undefined,不生成锚点。
|
|
5
|
+
* @returns `wb-card-<unit>`,或 undefined。
|
|
6
|
+
*/
|
|
7
|
+
export declare function cardIdOf(unit: string | null): string | undefined;
|
|
8
|
+
/**
|
|
9
|
+
* `CardAnchor` 的契约:unit id 与它锚住的内容。
|
|
10
|
+
*/
|
|
11
|
+
export interface CardAnchorProps {
|
|
12
|
+
readonly unit: string;
|
|
13
|
+
readonly children?: ReactNode | undefined;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 外壳自己盖的卡片锚点:套在卡外面给出 `id="wb-card-<unit>"`;模块别自己写,也别删。
|
|
17
|
+
* @param props.unit - 卡的 unit id,用来算锚点 id。
|
|
18
|
+
* @param props.children - 被锚住的卡片本体;锚点自己 `display: contents`,不占布局。
|
|
19
|
+
* @returns 带 id 的占位 div。
|
|
20
|
+
*/
|
|
21
|
+
export declare function CardAnchor({ unit, children }: CardAnchorProps): JSX.Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { h } from '../lib/react.js';
|
|
2
|
+
import styles from './CardAnchor.module.css';
|
|
3
|
+
/**
|
|
4
|
+
* 由 unit id 拼出卡片锚点 id,外壳的截图、滚动与页面探针都按它找卡。
|
|
5
|
+
* @param unit - unit id;`null` 或空串(没有 unit 的卡)时返回 undefined,不生成锚点。
|
|
6
|
+
* @returns `wb-card-<unit>`,或 undefined。
|
|
7
|
+
*/
|
|
8
|
+
export function cardIdOf(unit) {
|
|
9
|
+
return unit === null || unit === '' ? undefined : `wb-card-${unit}`;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 外壳自己盖的卡片锚点:套在卡外面给出 `id="wb-card-<unit>"`;模块别自己写,也别删。
|
|
13
|
+
* @param props.unit - 卡的 unit id,用来算锚点 id。
|
|
14
|
+
* @param props.children - 被锚住的卡片本体;锚点自己 `display: contents`,不占布局。
|
|
15
|
+
* @returns 带 id 的占位 div。
|
|
16
|
+
*/
|
|
17
|
+
export function CardAnchor({ unit, children }) {
|
|
18
|
+
return (h("div", { id: cardIdOf(unit), className: styles.anchor }, children));
|
|
19
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { Translate } from '../lib/dsh-client.js';
|
|
2
|
+
import type { ReactNode } from '../lib/react.js';
|
|
3
|
+
import { Component } from '../lib/react.js';
|
|
4
|
+
/**
|
|
5
|
+
* `CardBoundary` 的契约:被守的 unit、重来键与失败回调。
|
|
6
|
+
*/
|
|
7
|
+
export interface CardBoundaryProps {
|
|
8
|
+
readonly unit: string;
|
|
9
|
+
readonly resetKey: string;
|
|
10
|
+
readonly t: Translate;
|
|
11
|
+
readonly onFailure?: ((reason: string) => void) | undefined;
|
|
12
|
+
readonly children?: ReactNode | undefined;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* `CardBoundary` 的状态:这次渲染炸出来的那句话,没炸是 `null`。
|
|
16
|
+
*/
|
|
17
|
+
export interface CardBoundaryState {
|
|
18
|
+
readonly reason: string | null;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 把抛出来的任何东西收成一句人能看的失败原因,上报与展示都用它。
|
|
22
|
+
* @param error - 抛出来的值:`Error` 取 `message`,字符串原样,其余走 JSON。
|
|
23
|
+
* @returns 一句原因文本;`Error('')` 这种没带 message 的会回空串(调用点别把它当"一定有话")。
|
|
24
|
+
*/
|
|
25
|
+
export declare function errorReasonOf(error: unknown): string;
|
|
26
|
+
/**
|
|
27
|
+
* 卡片级错误边界:一张卡渲染炸了只画一条报错 + 重试,不让整块面板跟着塌。
|
|
28
|
+
* @param props.unit - 出事的 unit id,写进报错文案并作为上报标识。
|
|
29
|
+
* @param props.resetKey - 重来键:它一变(如切了工作区)就自动清掉报错,把卡片重新渲染一遍。
|
|
30
|
+
* @param props.t - 报错那句与重试钮文案的翻译函数。
|
|
31
|
+
* @param props.onFailure - 失败时把原因报给宿主(面板状态要用);不给就只打一条 console。
|
|
32
|
+
* @param props.children - 正常时要渲染的卡片内容。
|
|
33
|
+
* @returns 正常时是 `children`,炸过且还没重来之前是一条报错。
|
|
34
|
+
*/
|
|
35
|
+
export declare class CardBoundary extends Component<CardBoundaryProps, CardBoundaryState> {
|
|
36
|
+
state: CardBoundaryState;
|
|
37
|
+
static getDerivedStateFromError(error: unknown): CardBoundaryState;
|
|
38
|
+
componentDidCatch(error: unknown): void;
|
|
39
|
+
componentDidUpdate(previous: CardBoundaryProps): void;
|
|
40
|
+
private readonly retry;
|
|
41
|
+
render(): ReactNode;
|
|
42
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { Component, h } from '../lib/react.js';
|
|
2
|
+
import { Note } from './Note.js';
|
|
3
|
+
import { FormActions } from './FormActions.js';
|
|
4
|
+
import styles from './CardBoundary.module.css';
|
|
5
|
+
/**
|
|
6
|
+
* 把抛出来的任何东西收成一句人能看的失败原因,上报与展示都用它。
|
|
7
|
+
* @param error - 抛出来的值:`Error` 取 `message`,字符串原样,其余走 JSON。
|
|
8
|
+
* @returns 一句原因文本;`Error('')` 这种没带 message 的会回空串(调用点别把它当"一定有话")。
|
|
9
|
+
*/
|
|
10
|
+
export function errorReasonOf(error) {
|
|
11
|
+
if (error instanceof Error)
|
|
12
|
+
return error.message;
|
|
13
|
+
return typeof error === 'string' ? error : JSON.stringify(error) ?? String(error);
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* 卡片级错误边界:一张卡渲染炸了只画一条报错 + 重试,不让整块面板跟着塌。
|
|
17
|
+
* @param props.unit - 出事的 unit id,写进报错文案并作为上报标识。
|
|
18
|
+
* @param props.resetKey - 重来键:它一变(如切了工作区)就自动清掉报错,把卡片重新渲染一遍。
|
|
19
|
+
* @param props.t - 报错那句与重试钮文案的翻译函数。
|
|
20
|
+
* @param props.onFailure - 失败时把原因报给宿主(面板状态要用);不给就只打一条 console。
|
|
21
|
+
* @param props.children - 正常时要渲染的卡片内容。
|
|
22
|
+
* @returns 正常时是 `children`,炸过且还没重来之前是一条报错。
|
|
23
|
+
*/
|
|
24
|
+
export class CardBoundary extends Component {
|
|
25
|
+
state = { reason: null };
|
|
26
|
+
static getDerivedStateFromError(error) {
|
|
27
|
+
return { reason: errorReasonOf(error) };
|
|
28
|
+
}
|
|
29
|
+
componentDidCatch(error) {
|
|
30
|
+
const reason = errorReasonOf(error);
|
|
31
|
+
console.error(`[dsh-workbench] 模块 ${this.props.unit} 渲染失败:${reason}`, error);
|
|
32
|
+
this.props.onFailure?.(reason);
|
|
33
|
+
}
|
|
34
|
+
componentDidUpdate(previous) {
|
|
35
|
+
if (previous.resetKey !== this.props.resetKey && this.state.reason !== null) {
|
|
36
|
+
this.setState({ reason: null });
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
retry = () => {
|
|
40
|
+
this.setState({ reason: null });
|
|
41
|
+
};
|
|
42
|
+
render() {
|
|
43
|
+
const { reason } = this.state;
|
|
44
|
+
if (reason === null)
|
|
45
|
+
return this.props.children;
|
|
46
|
+
return (h(Note, { tone: "problem" },
|
|
47
|
+
h("div", { className: styles.failure },
|
|
48
|
+
h("span", null, this.props.t('panels.cardBroken', { unit: this.props.unit, reason })),
|
|
49
|
+
h(FormActions, { actions: [
|
|
50
|
+
{
|
|
51
|
+
key: 'retry',
|
|
52
|
+
label: this.props.t('panels.cardRetry'),
|
|
53
|
+
kind: 'default',
|
|
54
|
+
onClick: this.retry,
|
|
55
|
+
},
|
|
56
|
+
] }))));
|
|
57
|
+
}
|
|
58
|
+
}
|