@dsh-workbench/shared 0.3.11 → 1.0.0-beta.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/LICENSE +21 -0
- package/README.md +97 -0
- package/dist/api/blocker-table.d.ts +3 -3
- package/dist/api/blocker-table.js +47 -23
- package/dist/api/dsh.d.ts +1 -1
- package/dist/api/workbench-client.js +2 -1
- package/dist/components/Activity.css +0 -1
- package/dist/components/ApprovalDetail.css +1 -2
- package/dist/components/ApprovalDetail.d.ts +1 -1
- package/dist/components/ApprovalPlan.css +0 -1
- package/dist/components/Card.css +0 -1
- package/dist/components/Card.d.ts +1 -1
- package/dist/components/CardBoundary.d.ts +1 -1
- package/dist/components/CardHead.css +0 -1
- package/dist/components/CardHead.d.ts +1 -1
- package/dist/components/ChoiceGroup.css +1 -2
- package/dist/components/ConfirmBar.d.ts +1 -1
- package/dist/components/ConfirmBar.js +1 -1
- package/dist/components/Form.css +1 -1
- package/dist/components/FormActions.js +1 -1
- package/dist/components/LongTaskRow.css +1 -2
- package/dist/components/LongTaskRow.d.ts +1 -1
- package/dist/components/LongTaskRow.js +1 -1
- package/dist/components/Note.css +0 -1
- package/dist/components/ResourceStates.css +0 -1
- package/dist/components/SettingsSection.css +0 -1
- package/dist/components/Spinner.css +0 -1
- package/dist/components/Stack.css +0 -1
- package/dist/components/StateBlock.css +0 -1
- package/dist/components/board-module.d.ts +3 -3
- package/dist/components/icons.d.ts +1 -1
- package/dist/components/icons.js +11 -4
- package/dist/config/constants.d.ts +2 -2
- package/dist/config/constants.js +2 -2
- package/dist/contract/adapters.d.ts +10 -0
- package/dist/contract/cli.d.ts +3 -0
- package/dist/contract/data.d.ts +126 -0
- package/dist/{api → contract}/facts.d.ts +12 -3
- package/dist/{api → contract}/facts.js +19 -1
- package/dist/contract/needs.d.ts +132 -0
- package/dist/contract/needs.js +232 -0
- package/dist/contract/plugin-source.d.ts +1 -0
- package/dist/contract/protocol/bundle-install.d.ts +136 -0
- package/dist/contract/protocol/bundle-install.js +12 -0
- package/dist/contract/protocol/config-sync.d.ts +55 -0
- package/dist/contract/protocol/config-sync.js +2 -0
- package/dist/contract/protocol/diy.d.ts +4 -0
- package/dist/contract/protocol/diy.js +4 -0
- package/dist/contract/protocol/dsh-plugins.d.ts +11 -0
- package/dist/contract/protocol/dsh-plugins.js +1 -0
- package/dist/contract/protocol/long-tasks.d.ts +13 -0
- package/dist/contract/protocol/long-tasks.js +1 -0
- package/dist/contract/protocol/market-index.d.ts +195 -0
- package/dist/contract/protocol/market-index.js +7 -0
- package/dist/contract/protocol/platform.d.ts +44 -0
- package/dist/contract/protocol/platform.js +1 -0
- package/dist/contract/protocol/preflight-wake.d.ts +7 -0
- package/dist/contract/protocol/preflight-wake.js +1 -0
- package/dist/contract/protocol/profile-create.d.ts +30 -0
- package/dist/contract/protocol/profile-create.js +2 -0
- package/dist/contract/protocol/sidebar-edition.d.ts +14 -0
- package/dist/contract/protocol/sidebar-edition.js +2 -0
- package/dist/contract/protocol/unit-manifests.d.ts +6 -0
- package/dist/contract/protocol/unit-manifests.js +1 -0
- package/dist/contract/unit-board.js +1 -0
- package/dist/contract/unit-capability.d.ts +34 -0
- package/dist/contract/unit-capability.js +1 -0
- package/dist/{host → contract}/unit-declaration.d.ts +7 -5
- package/dist/{api → contract}/unit-declaration.js +19 -13
- package/dist/contract/unit.d.ts +57 -0
- package/dist/contract/unit.js +24 -0
- package/dist/contract/workbench-contract.d.ts +15 -0
- package/dist/contract/workbench-contract.js +1 -0
- package/dist/host/adapter-set.d.ts +26 -0
- package/dist/host/adapter-set.js +243 -0
- package/dist/host/adapter-types.d.ts +79 -0
- package/dist/host/adapter-types.js +23 -0
- package/dist/host/adapters.d.ts +22 -0
- package/dist/host/adapters.js +9 -0
- package/dist/host/browser.d.ts +3 -0
- package/dist/host/browser.js +3 -0
- package/dist/host/changelog.d.ts +21 -0
- package/dist/host/changelog.js +188 -0
- package/dist/host/channel-plugin.d.ts +15 -0
- package/dist/host/channel-plugin.js +42 -0
- package/dist/host/cli.d.ts +4 -0
- package/dist/host/cli.js +7 -0
- package/dist/host/command-name.d.ts +1 -0
- package/dist/host/command-name.js +14 -0
- package/dist/host/data-error.d.ts +13 -0
- package/dist/host/data-error.js +20 -0
- package/dist/host/data-root.js +3 -0
- package/dist/host/diy-debug.js +2 -1
- package/dist/host/diy-record.js +2 -1
- package/dist/host/facts.d.ts +1 -1
- package/dist/host/facts.js +3 -2
- package/dist/host/git.js +2 -2
- package/dist/host/http.js +1 -1
- package/dist/host/lib-capabilities.d.ts +22 -0
- package/dist/host/lib-capabilities.js +37 -0
- package/dist/host/lib-install.d.ts +9 -0
- package/dist/host/lib-install.js +10 -0
- package/dist/host/long-task.d.ts +1 -1
- package/dist/host/long-task.js +4 -3
- package/dist/host/market-index.d.ts +22 -0
- package/dist/host/market-index.js +420 -0
- package/dist/host/needs.d.ts +4 -0
- package/dist/host/needs.js +2 -0
- package/dist/host/patch.d.ts +9 -0
- package/dist/host/patch.js +78 -0
- package/dist/host/paths.d.ts +12 -0
- package/dist/host/paths.js +28 -0
- package/dist/host/platform.d.ts +14 -0
- package/dist/host/platform.js +40 -0
- package/dist/host/plugin-source.d.ts +8 -6
- package/dist/host/plugin-source.js +43 -33
- package/dist/host/plugin.d.ts +4 -0
- package/dist/host/plugin.js +39 -0
- package/dist/host/port-types.d.ts +191 -0
- package/dist/host/port-types.js +1 -0
- package/dist/host/preflight.d.ts +28 -0
- package/dist/host/preflight.js +1 -0
- package/dist/host/profile-port.d.ts +4 -0
- package/dist/host/profile-port.js +4 -0
- package/dist/host/provision.d.ts +2 -2
- package/dist/host/provision.js +5 -3
- package/dist/host/recipe-rules.d.ts +5 -0
- package/dist/host/recipe-rules.js +382 -0
- package/dist/host/recipe.d.ts +14 -0
- package/dist/host/recipe.js +283 -0
- package/dist/host/shell-text.d.ts +9 -2
- package/dist/host/shell-text.js +15 -3
- package/dist/host/shell.d.ts +2 -0
- package/dist/host/shell.js +7 -0
- package/dist/host/spec.d.ts +8 -0
- package/dist/host/spec.js +24 -0
- package/dist/host/supply-index.d.ts +34 -0
- package/dist/host/supply-index.js +202 -0
- package/dist/host/supply-port.d.ts +5 -0
- package/dist/host/supply-port.js +39 -0
- package/dist/host/time.d.ts +12 -0
- package/dist/host/time.js +19 -0
- package/dist/host/tokens.d.ts +26 -0
- package/dist/host/tokens.js +154 -0
- package/dist/host/tool-kit.js +1 -1
- package/dist/host/unit-face.d.ts +5 -4
- package/dist/host/version-range.d.ts +2 -0
- package/dist/host/version-range.js +73 -0
- package/dist/host/version.d.ts +3 -0
- package/dist/host/version.js +29 -0
- package/dist/host.d.ts +47 -16
- package/dist/host.js +47 -16
- package/dist/i18n/en.js +224 -71
- package/dist/i18n/index.d.ts +298 -73
- package/dist/i18n/merge.js +1 -1
- package/dist/i18n/need-text.d.ts +26 -0
- package/dist/i18n/need-text.js +26 -0
- package/dist/i18n/settings.d.ts +70 -0
- package/dist/i18n/settings.js +136 -0
- package/dist/i18n/zh.d.ts +297 -72
- package/dist/i18n/zh.js +226 -73
- package/dist/index.d.ts +23 -7
- package/dist/index.js +23 -7
- package/dist/{api → lib}/dsh-client.d.ts +11 -1
- package/dist/lib/dsh-client.js +1 -0
- package/dist/lib/market-index.d.ts +7 -0
- package/dist/lib/market-index.js +25 -0
- package/dist/lib/react.d.ts +0 -40
- package/dist/lib/react.js +0 -36
- package/dist/lib/ui.js +3 -9
- package/dist/testing/data.d.ts +13 -0
- package/dist/testing/data.js +46 -0
- package/dist/testing/declaration.d.ts +1 -1
- package/dist/testing/declaration.js +1 -1
- package/dist/testing/host-fakes.d.ts +0 -13
- package/dist/testing/host-fakes.js +0 -24
- package/dist/testing/needs.d.ts +16 -0
- package/dist/testing/needs.js +46 -0
- package/dist/testing.d.ts +2 -0
- package/dist/testing.js +2 -0
- package/package.json +18 -2
- package/src/api/__tests__/blocker-table.test.ts +135 -86
- package/src/api/blocker-table.ts +52 -26
- package/src/api/dsh.ts +1 -1
- package/src/api/host-write.ts +0 -1
- package/src/api/workbench-client.test.ts +2 -2
- package/src/api/workbench-client.ts +2 -1
- package/src/components/Activity.css +0 -1
- package/src/components/ApprovalDetail.css +1 -2
- package/src/components/ApprovalDetail.tsx +1 -1
- package/src/components/ApprovalPlan.css +0 -1
- package/src/components/Card.css +0 -1
- package/src/components/Card.tsx +1 -1
- package/src/components/CardAnchor.test.tsx +1 -1
- package/src/components/CardBoundary.tsx +1 -1
- package/src/components/CardHead.css +0 -1
- package/src/components/CardHead.tsx +1 -1
- package/src/components/ChoiceGroup.css +1 -2
- package/src/components/ConfirmBar.tsx +1 -1
- package/src/components/Form.css +1 -1
- package/src/components/Form.tsx +1 -1
- package/src/components/FormActions.tsx +1 -1
- package/src/components/LongTaskRow.css +1 -2
- package/src/components/LongTaskRow.tsx +1 -1
- package/src/components/Note.css +0 -1
- package/src/components/ResourceStates.css +0 -1
- package/src/components/SelectFieldNodes.tsx +0 -1
- package/src/components/SettingsSection.css +0 -1
- package/src/components/Spinner.css +0 -1
- package/src/components/Stack.css +0 -1
- package/src/components/StateBlock.css +0 -1
- package/src/components/__tests__/long-task-row.test.ts +1 -1
- package/src/components/board-module.ts +3 -3
- package/src/components/icons.tsx +16 -8
- package/src/config/constants.ts +2 -2
- package/src/{api → contract}/__tests__/facts.test.ts +73 -25
- package/src/{api → contract}/__tests__/long-task.test.ts +3 -3
- package/src/contract/__tests__/needs.test.ts +74 -0
- package/src/{host → contract}/__tests__/unit-declaration.test.ts +1 -1
- package/src/contract/__tests__/unit.test.ts +43 -0
- package/src/contract/adapters.ts +9 -0
- package/src/contract/cli.ts +3 -0
- package/src/contract/data.ts +145 -0
- package/src/{api → contract}/facts.ts +34 -4
- package/src/contract/needs.ts +331 -0
- package/src/contract/plugin-source.ts +1 -0
- package/src/contract/protocol/bundle-install.ts +198 -0
- package/src/contract/protocol/config-sync.ts +65 -0
- package/src/contract/protocol/diy.ts +4 -0
- package/src/contract/protocol/dsh-plugins.ts +13 -0
- package/src/contract/protocol/long-tasks.ts +16 -0
- package/src/contract/protocol/market-index.ts +246 -0
- package/src/contract/protocol/platform.ts +47 -0
- package/src/contract/protocol/preflight-wake.ts +17 -0
- package/src/contract/protocol/profile-create.ts +36 -0
- package/src/contract/protocol/sidebar-edition.ts +19 -0
- package/src/contract/protocol/unit-manifests.ts +8 -0
- package/src/{api → contract}/unit-board.ts +0 -1
- package/src/contract/unit-capability.ts +37 -0
- package/src/{host → contract}/unit-declaration.ts +22 -18
- package/src/contract/unit.ts +76 -0
- package/src/contract/workbench-contract.ts +30 -0
- package/src/host/__tests__/adapter-set.test.ts +228 -0
- package/src/host/__tests__/adapters.test.ts +27 -0
- package/src/host/__tests__/changelog.test.ts +102 -0
- package/src/host/__tests__/command-name.test.ts +16 -0
- package/src/host/__tests__/diy-record.test.ts +3 -3
- package/src/host/__tests__/facts.test.ts +5 -5
- package/src/host/__tests__/long-task.test.ts +1 -1
- package/src/host/__tests__/market-index.test.ts +179 -0
- package/src/host/__tests__/plugin-ledger.test.ts +10 -10
- package/src/host/__tests__/provision.test.ts +7 -6
- package/src/host/__tests__/shell-text.test.ts +16 -1
- package/src/host/__tests__/supply-index.test.ts +137 -0
- package/src/host/__tests__/tokens.test.ts +110 -0
- package/src/host/__tests__/version-range.test.ts +21 -0
- package/src/host/adapter-set.ts +298 -0
- package/src/host/adapter-types.ts +105 -0
- package/src/host/adapters.ts +44 -0
- package/src/host/browser.ts +3 -0
- package/src/host/changelog.ts +212 -0
- package/src/host/channel-plugin.ts +55 -0
- package/src/host/cli.ts +11 -0
- package/src/host/command-name.ts +15 -0
- package/src/host/data-error.ts +21 -0
- package/src/host/data-root.ts +2 -0
- package/src/host/diy-debug.ts +2 -1
- package/src/host/diy-record.ts +2 -1
- package/src/host/facts.ts +4 -3
- package/src/host/git.ts +2 -2
- package/src/host/http.ts +1 -1
- package/src/host/lib-capabilities.ts +52 -0
- package/src/host/lib-install.ts +18 -0
- package/src/host/long-task.ts +4 -3
- package/src/host/market-index.ts +413 -0
- package/src/host/needs.ts +6 -0
- package/src/host/patch.ts +93 -0
- package/src/host/paths.ts +37 -0
- package/src/host/platform.ts +48 -0
- package/src/host/plugin-source.ts +48 -56
- package/src/host/plugin.ts +39 -0
- package/src/host/port-types.ts +222 -0
- package/src/host/preflight.ts +31 -0
- package/src/host/profile-port.ts +9 -0
- package/src/host/provision.ts +7 -4
- package/src/host/recipe-rules.ts +330 -0
- package/src/host/recipe.test.ts +334 -0
- package/src/host/recipe.ts +323 -0
- package/src/host/shell-text.ts +15 -3
- package/src/host/shell.ts +9 -0
- package/src/host/spec.ts +32 -0
- package/src/host/supply-index.ts +256 -0
- package/src/host/supply-port.ts +45 -0
- package/src/host/time.ts +22 -0
- package/src/host/tokens.ts +186 -0
- package/src/host/tool-kit.ts +1 -1
- package/src/host/unit-face.ts +5 -4
- package/src/host/version-range.ts +71 -0
- package/src/host/version.ts +30 -0
- package/src/host.ts +47 -16
- package/src/i18n/en.ts +224 -71
- package/src/i18n/merge.test.ts +6 -6
- package/src/i18n/merge.ts +1 -1
- package/src/i18n/need-text.ts +27 -0
- package/src/i18n/settings.ts +141 -0
- package/src/i18n/zh.ts +227 -73
- package/src/index.ts +23 -7
- package/src/lib/blocker-action.ts +0 -1
- package/src/{api → lib}/dsh-client.ts +12 -1
- package/src/lib/market-index.ts +36 -0
- package/src/lib/react.ts +0 -40
- package/src/lib/text.test.ts +2 -2
- package/src/lib/ui.test.ts +6 -5
- package/src/lib/ui.ts +3 -9
- package/src/testing/__tests__/declaration.test.ts +1 -1
- package/src/testing/data.ts +66 -0
- package/src/testing/declaration.ts +2 -2
- package/src/testing/host-fakes.ts +0 -38
- package/src/testing/needs.ts +80 -0
- package/src/testing.ts +2 -0
- package/dist/api/unit-declaration.d.ts +0 -65
- package/dist/api/unit.d.ts +0 -85
- package/dist/api/unit.js +0 -8
- package/dist/api/workbench-contract.d.ts +0 -44
- package/dist/components/MockStrip.css +0 -39
- package/dist/components/MockStrip.d.ts +0 -15
- package/dist/components/MockStrip.js +0 -8
- package/dist/components/SaveBar.css +0 -7
- package/dist/host/browser-find.d.ts +0 -38
- package/dist/host/browser-find.js +0 -242
- package/dist/host/browser-read.d.ts +0 -28
- package/dist/host/browser-read.js +0 -243
- package/dist/host/opencli-runtime.d.ts +0 -25
- package/dist/host/opencli-runtime.js +0 -56
- package/dist/host/opencli-window.d.ts +0 -2
- package/dist/host/opencli-window.js +0 -8
- package/dist/host/opencli.d.ts +0 -37
- package/dist/host/opencli.js +0 -155
- package/dist/host/unit-declaration.js +0 -213
- package/dist/host/unit-libs.d.ts +0 -37
- package/dist/lib/diy-debug.d.ts +0 -80
- package/dist/lib/diy-debug.js +0 -88
- package/dist/lib/diy-record.d.ts +0 -135
- package/dist/lib/diy-record.js +0 -162
- package/dist/lib/lint-probe.d.ts +0 -1
- package/dist/lib/lint-probe.js +0 -6
- package/dist/lib/panel-state.d.ts +0 -120
- package/dist/lib/panel-state.js +0 -176
- package/src/api/__tests__/unit.test.ts +0 -38
- package/src/api/unit.ts +0 -93
- package/src/api/workbench-contract.ts +0 -59
- package/src/host/__tests__/browser-find.test.ts +0 -330
- package/src/host/__tests__/browser-read.test.ts +0 -228
- package/src/host/__tests__/opencli-runtime.test.ts +0 -46
- package/src/host/browser-find.ts +0 -311
- package/src/host/browser-read.ts +0 -311
- package/src/host/opencli-runtime.ts +0 -79
- package/src/host/opencli-window.ts +0 -11
- package/src/host/opencli.ts +0 -213
- package/src/host/unit-libs.ts +0 -41
- /package/dist/{api/blocker.js → contract/adapters.js} +0 -0
- /package/dist/{api → contract}/blocker.d.ts +0 -0
- /package/dist/{api/dsh-client.js → contract/blocker.js} +0 -0
- /package/dist/{api/unit-board.js → contract/cli.js} +0 -0
- /package/dist/{api/workbench-contract.js → contract/data.js} +0 -0
- /package/dist/{api → contract}/long-task.d.ts +0 -0
- /package/dist/{api → contract}/long-task.js +0 -0
- /package/dist/{host/unit-libs.js → contract/plugin-source.js} +0 -0
- /package/dist/{api → contract}/unit-board.d.ts +0 -0
- /package/src/{api → contract}/blocker.ts +0 -0
- /package/src/{api → contract}/long-task.ts +0 -0
|
@@ -8,7 +8,7 @@ export interface FactFrame {
|
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
/**
|
|
11
|
-
* 范围查法的后缀:
|
|
11
|
+
* 范围查法的后缀:inventory/* 这类名字表示「这个前缀下的一族」,不是一条事实。
|
|
12
12
|
*/
|
|
13
13
|
export const FACT_SCOPE_SUFFIX = '*';
|
|
14
14
|
|
|
@@ -31,14 +31,25 @@ export function scopePrefixOf(name: string): string {
|
|
|
31
31
|
}
|
|
32
32
|
|
|
33
33
|
/**
|
|
34
|
-
*
|
|
34
|
+
* 事实传输层的来路:SSE 直连,或降级成轮询。
|
|
35
|
+
*/
|
|
36
|
+
export type FactTransportMode = 'sse' | 'polling';
|
|
37
|
+
|
|
38
|
+
/**
|
|
39
|
+
* 事实的来路:start 建连并按帧回调,cursor 报已收到的宿主 rev(断线重连时交给宿主),
|
|
40
|
+
* onMode 报这一层现在是哪种传输。
|
|
35
41
|
*/
|
|
36
42
|
export interface FactTransport {
|
|
37
|
-
start(handlers: {
|
|
43
|
+
start(handlers: {
|
|
44
|
+
readonly onFrame: (frame: FactFrame) => void;
|
|
45
|
+
readonly cursor: () => number;
|
|
46
|
+
readonly onMode?: ((mode: FactTransportMode) => void) | undefined;
|
|
47
|
+
}): () => void;
|
|
38
48
|
}
|
|
39
49
|
|
|
40
50
|
/**
|
|
41
|
-
*
|
|
51
|
+
* 浏览器侧的事实通道:订阅、读版本、手动刷新,帧到了由它分发给订阅者;
|
|
52
|
+
* mode 是传输层现在走的来路(还没建连就是 null),subscribeMode 听它换档。
|
|
42
53
|
*/
|
|
43
54
|
export interface FactChannel {
|
|
44
55
|
subscribe(fact: string, listener: () => void): () => void;
|
|
@@ -46,6 +57,8 @@ export interface FactChannel {
|
|
|
46
57
|
refresh(fact?: string): void;
|
|
47
58
|
applyFrame(frame: FactFrame): void;
|
|
48
59
|
subscriberCount(): number;
|
|
60
|
+
mode(): FactTransportMode | null;
|
|
61
|
+
subscribeMode(listener: () => void): () => void;
|
|
49
62
|
}
|
|
50
63
|
|
|
51
64
|
interface FactEntry {
|
|
@@ -60,10 +73,18 @@ interface FactEntry {
|
|
|
60
73
|
*/
|
|
61
74
|
export function createFactChannel(options: { readonly transport: FactTransport }): FactChannel {
|
|
62
75
|
const entries = new Map<string, FactEntry>();
|
|
76
|
+
const modeListeners = new Set<() => void>();
|
|
63
77
|
let epoch: string | null = null;
|
|
64
78
|
let stopTransport: (() => void) | null = null;
|
|
65
79
|
let hostRev = 0;
|
|
66
80
|
let generation = 0;
|
|
81
|
+
let mode: FactTransportMode | null = null;
|
|
82
|
+
|
|
83
|
+
const setMode = (next: FactTransportMode | null): void => {
|
|
84
|
+
if (mode === next) return;
|
|
85
|
+
mode = next;
|
|
86
|
+
for (const listener of [...modeListeners]) listener();
|
|
87
|
+
};
|
|
67
88
|
|
|
68
89
|
const entryOf = (fact: string): FactEntry => {
|
|
69
90
|
const existing = entries.get(fact);
|
|
@@ -107,6 +128,7 @@ export function createFactChannel(options: { readonly transport: FactTransport }
|
|
|
107
128
|
stopTransport = options.transport.start({
|
|
108
129
|
onFrame: (frame) => channel.applyFrame(frame),
|
|
109
130
|
cursor: () => hostRev,
|
|
131
|
+
onMode: (next) => setMode(next),
|
|
110
132
|
});
|
|
111
133
|
};
|
|
112
134
|
|
|
@@ -114,6 +136,7 @@ export function createFactChannel(options: { readonly transport: FactTransport }
|
|
|
114
136
|
if (stopTransport === null) return;
|
|
115
137
|
stopTransport();
|
|
116
138
|
stopTransport = null;
|
|
139
|
+
setMode(null);
|
|
117
140
|
};
|
|
118
141
|
|
|
119
142
|
const channel: FactChannel = {
|
|
@@ -132,6 +155,13 @@ export function createFactChannel(options: { readonly transport: FactTransport }
|
|
|
132
155
|
for (const entry of entries.values()) count += entry.listeners.size;
|
|
133
156
|
return count;
|
|
134
157
|
},
|
|
158
|
+
mode: () => mode,
|
|
159
|
+
subscribeMode(listener) {
|
|
160
|
+
modeListeners.add(listener);
|
|
161
|
+
return () => {
|
|
162
|
+
modeListeners.delete(listener);
|
|
163
|
+
};
|
|
164
|
+
},
|
|
135
165
|
refresh(fact) {
|
|
136
166
|
generation += 1;
|
|
137
167
|
if (fact === undefined) {
|
|
@@ -0,0 +1,331 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 模块要的一样东西的类别;v2 只认这四种,加种类在注册表里加,不改这份形状。
|
|
3
|
+
*/
|
|
4
|
+
export const NEED_KINDS = ['bin', 'extension', 'lib', 'env'] as const;
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* need 的类别。
|
|
8
|
+
*/
|
|
9
|
+
export type NeedKind = (typeof NEED_KINDS)[number];
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* 一种外部来源;每一种都只说「去哪拿」,装不装、怎么装由宿主决定。
|
|
13
|
+
*/
|
|
14
|
+
export type SupplySource =
|
|
15
|
+
| {
|
|
16
|
+
readonly kind: 'npm';
|
|
17
|
+
readonly package?: string;
|
|
18
|
+
readonly registryEnv?: string;
|
|
19
|
+
readonly registryDefault?: string;
|
|
20
|
+
}
|
|
21
|
+
| { readonly kind: 'git'; readonly url: string; readonly ref?: string }
|
|
22
|
+
| { readonly kind: 'local'; readonly path?: string; readonly env?: string };
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* 协议认得的外部来源种类。
|
|
26
|
+
*/
|
|
27
|
+
export const SUPPLY_SOURCE_KINDS = ['npm', 'git', 'local'] as const;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* 外部来源的类别。
|
|
31
|
+
*/
|
|
32
|
+
export type SupplySourceKind = (typeof SUPPLY_SOURCE_KINDS)[number];
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* 每条 need 都有的字段:为什么需要它、缺了算不算问题。
|
|
36
|
+
*/
|
|
37
|
+
export interface NeedCommon {
|
|
38
|
+
readonly kind: NeedKind;
|
|
39
|
+
readonly purpose: string;
|
|
40
|
+
readonly required?: boolean;
|
|
41
|
+
readonly id?: string;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* 机器上要有一个可执行文件;探法是 `command -v` / `where`。
|
|
46
|
+
*/
|
|
47
|
+
export interface BinNeed extends NeedCommon {
|
|
48
|
+
readonly kind: 'bin';
|
|
49
|
+
readonly name: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/**
|
|
53
|
+
* 某个运行时上要有一个扩展(opencli 的插件就是这种),并且要提供这些命令。
|
|
54
|
+
*/
|
|
55
|
+
export interface ExtensionNeed extends NeedCommon {
|
|
56
|
+
readonly kind: 'extension';
|
|
57
|
+
readonly runtime: string;
|
|
58
|
+
readonly name: string;
|
|
59
|
+
readonly commands?: readonly string[];
|
|
60
|
+
readonly version?: string;
|
|
61
|
+
readonly sources?: readonly SupplySource[];
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* 要在隔离运行时里有一个共用依赖包。
|
|
66
|
+
*/
|
|
67
|
+
export interface LibNeed extends NeedCommon {
|
|
68
|
+
readonly kind: 'lib';
|
|
69
|
+
readonly name: string;
|
|
70
|
+
readonly version?: string;
|
|
71
|
+
readonly sources?: readonly SupplySource[];
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* 跑起来时要有这个环境变量;`secret` 为真时任何地方都不回显它的值。
|
|
76
|
+
*/
|
|
77
|
+
export interface EnvNeed extends NeedCommon {
|
|
78
|
+
readonly kind: 'env';
|
|
79
|
+
readonly name: string;
|
|
80
|
+
readonly secret?: boolean;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/**
|
|
84
|
+
* 模块声明的一条需要。
|
|
85
|
+
*/
|
|
86
|
+
export type Need = BinNeed | ExtensionNeed | LibNeed | EnvNeed;
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* 一份 needs 校验结果:错误拒收,警告只提醒(未知可选字段就是警告)。
|
|
90
|
+
*/
|
|
91
|
+
export interface NeedsProblems {
|
|
92
|
+
readonly errors: readonly string[];
|
|
93
|
+
readonly warnings: readonly string[];
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/**
|
|
97
|
+
* 协议认得的 need 字段;`x-` 前缀的字段留给第三方扩展,直接忽略。
|
|
98
|
+
*/
|
|
99
|
+
export const NEED_KEYS: readonly string[] = [
|
|
100
|
+
'kind',
|
|
101
|
+
'purpose',
|
|
102
|
+
'required',
|
|
103
|
+
'id',
|
|
104
|
+
'name',
|
|
105
|
+
'runtime',
|
|
106
|
+
'commands',
|
|
107
|
+
'version',
|
|
108
|
+
'sources',
|
|
109
|
+
'secret',
|
|
110
|
+
];
|
|
111
|
+
|
|
112
|
+
/**
|
|
113
|
+
* 注册表把「怎么校验、怎么探、能不能代装」收在一处;加一种 kind 只在这里加一行。
|
|
114
|
+
*/
|
|
115
|
+
export interface NeedKindSpec {
|
|
116
|
+
readonly kind: NeedKind;
|
|
117
|
+
readonly probe: 'bin' | 'extension' | 'package' | 'env';
|
|
118
|
+
readonly sources: readonly SupplySourceKind[];
|
|
119
|
+
readonly validate: (raw: Readonly<Record<string, unknown>>, at: string) => readonly string[];
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
const SOURCE_KEYS = ['kind', 'package', 'registryEnv', 'registryDefault', 'url', 'ref', 'path', 'env'];
|
|
123
|
+
const REGISTRY_PATTERN = /^(?:https?|file):\/\//;
|
|
124
|
+
|
|
125
|
+
function text(value: unknown): string {
|
|
126
|
+
return typeof value === 'string' ? value.trim() : '';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
function isRecord(value: unknown): value is Readonly<Record<string, unknown>> {
|
|
130
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/**
|
|
134
|
+
* 这个字符串是不是协议认得的 need 类别。
|
|
135
|
+
* @param value 待判的值。
|
|
136
|
+
* @returns 是就收窄成 NeedKind。
|
|
137
|
+
*/
|
|
138
|
+
export function isKnownNeedKind(value: unknown): value is NeedKind {
|
|
139
|
+
return typeof value === 'string' && (NEED_KINDS as readonly string[]).includes(value);
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* 一条 need 的稳定标识:作者写 `id` 就用它,否则 `kind:name`。
|
|
144
|
+
* @param need 一条 need。
|
|
145
|
+
* @returns 标识串。
|
|
146
|
+
*/
|
|
147
|
+
export function needIdOf(need: Need): string {
|
|
148
|
+
return need.id === undefined || need.id.trim() === '' ? `${need.kind}:${need.name}` : need.id;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
function sourceProblemsOf(raw: unknown, at: string): readonly string[] {
|
|
152
|
+
if (!isRecord(raw)) return [`${at} 要是对象`];
|
|
153
|
+
const kind = text(raw['kind']);
|
|
154
|
+
if (!(SUPPLY_SOURCE_KINDS as readonly string[]).includes(kind)) {
|
|
155
|
+
return [`${at}.kind 不认识 —— ${JSON.stringify(raw['kind'])}(只有 ${SUPPLY_SOURCE_KINDS.join(' / ')})`];
|
|
156
|
+
}
|
|
157
|
+
const errors: string[] = [];
|
|
158
|
+
for (const key of Object.keys(raw)) {
|
|
159
|
+
if (SOURCE_KEYS.includes(key) || key.startsWith('x-')) continue;
|
|
160
|
+
errors.push(`${at} 有不认识的字段 ${key}`);
|
|
161
|
+
}
|
|
162
|
+
if (kind === 'npm') {
|
|
163
|
+
if (raw['package'] !== undefined && text(raw['package']) === '') errors.push(`${at}.package 是空串`);
|
|
164
|
+
if (raw['registryEnv'] !== undefined && text(raw['registryEnv']) === '') {
|
|
165
|
+
errors.push(`${at}.registryEnv 是空串`);
|
|
166
|
+
}
|
|
167
|
+
if (raw['registryDefault'] !== undefined && !REGISTRY_PATTERN.test(text(raw['registryDefault']))) {
|
|
168
|
+
errors.push(`${at}.registryDefault 要是 http(s):// 或 file:// 的源地址`);
|
|
169
|
+
}
|
|
170
|
+
return errors;
|
|
171
|
+
}
|
|
172
|
+
if (kind === 'git') {
|
|
173
|
+
if (text(raw['url']) === '') errors.push(`${at}.url 没写`);
|
|
174
|
+
return errors;
|
|
175
|
+
}
|
|
176
|
+
if (text(raw['path']) === '' && text(raw['env']) === '') {
|
|
177
|
+
errors.push(`${at} 是 local,但 path 与 env 都没写`);
|
|
178
|
+
}
|
|
179
|
+
return errors;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
function sourcesProblemsOf(
|
|
183
|
+
raw: unknown,
|
|
184
|
+
at: string,
|
|
185
|
+
allowed: readonly SupplySourceKind[],
|
|
186
|
+
): readonly string[] {
|
|
187
|
+
if (raw === undefined) return [];
|
|
188
|
+
if (!Array.isArray(raw)) return [`${at}.sources 要是数组`];
|
|
189
|
+
if (raw.length === 0) return [`${at}.sources 是空数组 —— 不代装就整条删掉`];
|
|
190
|
+
if (allowed.length === 0) {
|
|
191
|
+
return [`${at} 这种需要不支持 sources —— 它没有「从哪装」这回事`];
|
|
192
|
+
}
|
|
193
|
+
const errors: string[] = [];
|
|
194
|
+
raw.forEach((source, index) => {
|
|
195
|
+
const one = sourceProblemsOf(source, `${at}.sources[${index}]`);
|
|
196
|
+
errors.push(...one);
|
|
197
|
+
if (one.length === 0 && isRecord(source)) {
|
|
198
|
+
const kind = text(source['kind']) as SupplySourceKind;
|
|
199
|
+
if (!allowed.includes(kind)) {
|
|
200
|
+
errors.push(`${at}.sources[${index}].kind 是 ${kind},这种需要只支持 ${allowed.join(' / ')}`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
});
|
|
204
|
+
return errors;
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
function commonProblemsOf(raw: Readonly<Record<string, unknown>>, at: string): readonly string[] {
|
|
208
|
+
const errors: string[] = [];
|
|
209
|
+
if (text(raw['purpose']) === '') errors.push(`${at}.purpose 没写 —— 「为什么要它」是缺失文案的那半句`);
|
|
210
|
+
if (raw['required'] !== undefined && typeof raw['required'] !== 'boolean') {
|
|
211
|
+
errors.push(`${at}.required 要是布尔`);
|
|
212
|
+
}
|
|
213
|
+
if (raw['id'] !== undefined && text(raw['id']) === '') errors.push(`${at}.id 是空串`);
|
|
214
|
+
return errors;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
function perKindProblemsOf(
|
|
218
|
+
kind: NeedKind,
|
|
219
|
+
raw: Readonly<Record<string, unknown>>,
|
|
220
|
+
at: string,
|
|
221
|
+
): readonly string[] {
|
|
222
|
+
const errors: string[] = [];
|
|
223
|
+
if (kind === 'bin' || kind === 'lib' || kind === 'env') {
|
|
224
|
+
if (text(raw['name']) === '') errors.push(`${at}.name 没写`);
|
|
225
|
+
}
|
|
226
|
+
if (kind === 'extension') {
|
|
227
|
+
if (text(raw['runtime']) === '') errors.push(`${at}.runtime 没写 —— 扩展属于哪个运行时(如 opencli)`);
|
|
228
|
+
if (text(raw['name']) === '') errors.push(`${at}.name 没写`);
|
|
229
|
+
if (raw['commands'] !== undefined) {
|
|
230
|
+
if (!Array.isArray(raw['commands'])) errors.push(`${at}.commands 要是数组`);
|
|
231
|
+
else if (raw['commands'].some((one) => text(one) === '')) errors.push(`${at}.commands 里有空字符串`);
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (kind === 'env' && raw['secret'] !== undefined && typeof raw['secret'] !== 'boolean') {
|
|
235
|
+
errors.push(`${at}.secret 要是布尔`);
|
|
236
|
+
}
|
|
237
|
+
return errors;
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
function validateKind(kind: NeedKind) {
|
|
241
|
+
return (raw: Readonly<Record<string, unknown>>, at: string): readonly string[] =>
|
|
242
|
+
perKindProblemsOf(kind, raw, at);
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* 一张表说了算:每种 kind 的探法、可用来源与校验。
|
|
247
|
+
*/
|
|
248
|
+
export const NEED_KIND_SPECS: Readonly<Record<NeedKind, NeedKindSpec>> = Object.freeze({
|
|
249
|
+
bin: Object.freeze({
|
|
250
|
+
kind: 'bin',
|
|
251
|
+
probe: 'bin',
|
|
252
|
+
sources: Object.freeze([]) as readonly SupplySourceKind[],
|
|
253
|
+
validate: validateKind('bin'),
|
|
254
|
+
}),
|
|
255
|
+
extension: Object.freeze({
|
|
256
|
+
kind: 'extension',
|
|
257
|
+
probe: 'extension',
|
|
258
|
+
sources: Object.freeze(['npm', 'git', 'local'] as SupplySourceKind[]),
|
|
259
|
+
validate: validateKind('extension'),
|
|
260
|
+
}),
|
|
261
|
+
lib: Object.freeze({
|
|
262
|
+
kind: 'lib',
|
|
263
|
+
probe: 'package',
|
|
264
|
+
sources: Object.freeze(['npm'] as SupplySourceKind[]),
|
|
265
|
+
validate: validateKind('lib'),
|
|
266
|
+
}),
|
|
267
|
+
env: Object.freeze({
|
|
268
|
+
kind: 'env',
|
|
269
|
+
probe: 'env',
|
|
270
|
+
sources: Object.freeze([]) as readonly SupplySourceKind[],
|
|
271
|
+
validate: validateKind('env'),
|
|
272
|
+
}),
|
|
273
|
+
});
|
|
274
|
+
|
|
275
|
+
/**
|
|
276
|
+
* 校验一条 need;未知类别是错误,未知字段是警告。
|
|
277
|
+
* @param label 报错时用的主语(模块包名)。
|
|
278
|
+
* @param raw 这一条 need 的原始值。
|
|
279
|
+
* @param index 它在 needs 里的下标。
|
|
280
|
+
* @returns 错误与警告。
|
|
281
|
+
*/
|
|
282
|
+
export function needProblemsOf(label: string, raw: unknown, index: number): NeedsProblems {
|
|
283
|
+
const at = `${label}.needs[${index}]`;
|
|
284
|
+
if (!isRecord(raw)) return { errors: [`${at} 要是对象`], warnings: [] };
|
|
285
|
+
const kind = text(raw['kind']);
|
|
286
|
+
if (!isKnownNeedKind(kind)) {
|
|
287
|
+
return {
|
|
288
|
+
errors: [
|
|
289
|
+
`${at}.kind 不认识 —— ${JSON.stringify(raw['kind'])}(v2 只认 ${NEED_KINDS.join(' / ')};` +
|
|
290
|
+
'要是模块用了更新的工作台才有的种类,升级工作台)',
|
|
291
|
+
],
|
|
292
|
+
warnings: [],
|
|
293
|
+
};
|
|
294
|
+
}
|
|
295
|
+
const warnings: string[] = [];
|
|
296
|
+
for (const key of Object.keys(raw)) {
|
|
297
|
+
if (NEED_KEYS.includes(key) || key.startsWith('x-')) continue;
|
|
298
|
+
warnings.push(`${at} 有不认识的字段 ${key}(宿主会忽略它)`);
|
|
299
|
+
}
|
|
300
|
+
const errors = [
|
|
301
|
+
...commonProblemsOf(raw, at),
|
|
302
|
+
...perKindProblemsOf(kind, raw, at),
|
|
303
|
+
...sourcesProblemsOf(raw['sources'], at, NEED_KIND_SPECS[kind].sources),
|
|
304
|
+
];
|
|
305
|
+
return { errors, warnings };
|
|
306
|
+
}
|
|
307
|
+
|
|
308
|
+
/**
|
|
309
|
+
* 校验整张 needs 表(没写就是空表)。
|
|
310
|
+
* @param label 报错时用的主语。
|
|
311
|
+
* @param raw 声明里的 needs 原始值。
|
|
312
|
+
* @returns 错误与警告。
|
|
313
|
+
*/
|
|
314
|
+
export function needsProblemsOf(label: string, raw: unknown): NeedsProblems {
|
|
315
|
+
if (raw === undefined) return { errors: [], warnings: [] };
|
|
316
|
+
if (!Array.isArray(raw)) return { errors: [`${label}.needs 要是数组`], warnings: [] };
|
|
317
|
+
const errors: string[] = [];
|
|
318
|
+
const warnings: string[] = [];
|
|
319
|
+
const seen = new Set<string>();
|
|
320
|
+
raw.forEach((one, index) => {
|
|
321
|
+
const found = needProblemsOf(label, one, index);
|
|
322
|
+
errors.push(...found.errors);
|
|
323
|
+
warnings.push(...found.warnings);
|
|
324
|
+
if (found.errors.length > 0 || !isRecord(one)) return;
|
|
325
|
+
const kind = text(one['kind']);
|
|
326
|
+
const id = text(one['id']) === '' ? `${kind}:${text(one['name'])}` : text(one['id']);
|
|
327
|
+
if (seen.has(id)) errors.push(`${label}.needs 里 ${id} 重复了 —— 每条 need 的 id 要唯一`);
|
|
328
|
+
seen.add(id);
|
|
329
|
+
});
|
|
330
|
+
return { errors, warnings };
|
|
331
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export type ProvisionProblem = 'not-declared' | 'env-missing' | 'malformed';
|
|
@@ -0,0 +1,198 @@
|
|
|
1
|
+
export const BUNDLE_REGISTRIES_ROUTE = 'bundle-registries';
|
|
2
|
+
|
|
3
|
+
export const BUNDLE_INSPECT_ROUTE = 'bundle-inspect';
|
|
4
|
+
|
|
5
|
+
export const BUNDLE_REGISTRY_DEFAULT = 'default';
|
|
6
|
+
export const MODULE_VERSIONS_ROUTE = 'module-versions';
|
|
7
|
+
|
|
8
|
+
export type BundleRegistry = string | null;
|
|
9
|
+
|
|
10
|
+
export interface BundleRegistries {
|
|
11
|
+
readonly registry: BundleRegistry;
|
|
12
|
+
readonly fallbackRegistries: readonly BundleRegistry[];
|
|
13
|
+
readonly resolved: string | null;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export type BundleInspectProblem =
|
|
17
|
+
| 'invalid-spec'
|
|
18
|
+
| 'already-installed'
|
|
19
|
+
| 'not-found'
|
|
20
|
+
| 'not-a-package'
|
|
21
|
+
| 'not-a-bundle'
|
|
22
|
+
| 'not-a-workbench-module'
|
|
23
|
+
| 'not-a-module-or-plugin'
|
|
24
|
+
| 'network'
|
|
25
|
+
| 'unknown';
|
|
26
|
+
|
|
27
|
+
export type BundleSpecKind = 'registry' | 'path' | 'git' | 'tarball';
|
|
28
|
+
|
|
29
|
+
export interface BundleInspectionAccepted {
|
|
30
|
+
readonly status: 'accepted';
|
|
31
|
+
readonly kind: BundleSpecKind;
|
|
32
|
+
readonly name?: string;
|
|
33
|
+
readonly version?: string;
|
|
34
|
+
readonly description?: string;
|
|
35
|
+
readonly bundle: boolean | null;
|
|
36
|
+
readonly registry: BundleRegistry;
|
|
37
|
+
readonly host?: string;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface BundleInspectionRefused {
|
|
41
|
+
readonly status: 'refused';
|
|
42
|
+
readonly problem: BundleInspectProblem;
|
|
43
|
+
readonly reason: string;
|
|
44
|
+
readonly registries?: readonly BundleRegistry[];
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface BundleInspectionPlugin {
|
|
48
|
+
readonly status: 'plugin';
|
|
49
|
+
readonly pkg: string;
|
|
50
|
+
readonly registry: BundleRegistry;
|
|
51
|
+
readonly pluginName?: string;
|
|
52
|
+
readonly version?: string;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export type BundleInspection =
|
|
56
|
+
| BundleInspectionAccepted
|
|
57
|
+
| BundleInspectionRefused
|
|
58
|
+
| BundleInspectionPlugin;
|
|
59
|
+
|
|
60
|
+
export interface BundleRegistriesPayload {
|
|
61
|
+
readonly available: boolean;
|
|
62
|
+
readonly registries: BundleRegistries | null;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
export interface BundleInspectionPayload {
|
|
66
|
+
readonly inspection: BundleInspection;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export type BundleApplication = 'applied' | 'restart-required' | 'overridden' | 'failed' | 'cancelled';
|
|
70
|
+
|
|
71
|
+
export const SELF_UPDATE_STATES = ['running', 'ok', 'rolled-back', 'failed'] as const;
|
|
72
|
+
|
|
73
|
+
export type SelfUpdateState = (typeof SELF_UPDATE_STATES)[number];
|
|
74
|
+
|
|
75
|
+
export interface WorkbenchSelfUpdate {
|
|
76
|
+
readonly state: SelfUpdateState;
|
|
77
|
+
readonly profile?: string;
|
|
78
|
+
readonly from?: string;
|
|
79
|
+
readonly to?: string;
|
|
80
|
+
readonly version?: string;
|
|
81
|
+
readonly at?: string;
|
|
82
|
+
readonly tail?: string;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export const RESTART_REASONS = [
|
|
86
|
+
'no-hmr',
|
|
87
|
+
'package-moved',
|
|
88
|
+
'host-module',
|
|
89
|
+
'unmanaged-plugin',
|
|
90
|
+
'module-comparison',
|
|
91
|
+
] as const;
|
|
92
|
+
|
|
93
|
+
export type RestartReason = (typeof RESTART_REASONS)[number];
|
|
94
|
+
|
|
95
|
+
export type BundleChangeStage = 'install' | 'enable' | 'remove';
|
|
96
|
+
|
|
97
|
+
export type BundleFailureKind =
|
|
98
|
+
| 'pnpm-missing'
|
|
99
|
+
| 'timeout'
|
|
100
|
+
| 'not-found'
|
|
101
|
+
| 'no-matching-version'
|
|
102
|
+
| 'network'
|
|
103
|
+
| 'disk-full'
|
|
104
|
+
| 'permission'
|
|
105
|
+
| 'build-blocked'
|
|
106
|
+
| 'integrity'
|
|
107
|
+
| 'unknown';
|
|
108
|
+
|
|
109
|
+
export interface BundlePackageResult {
|
|
110
|
+
readonly exitCode: number;
|
|
111
|
+
readonly output: string;
|
|
112
|
+
readonly truncated: boolean;
|
|
113
|
+
readonly logPath: string;
|
|
114
|
+
readonly kind?: BundleFailureKind;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface BundleChange {
|
|
118
|
+
readonly application: BundleApplication;
|
|
119
|
+
readonly stage: BundleChangeStage;
|
|
120
|
+
readonly changed: boolean;
|
|
121
|
+
readonly target: string;
|
|
122
|
+
readonly bundle?: string;
|
|
123
|
+
readonly version?: string;
|
|
124
|
+
readonly errorCode?: string;
|
|
125
|
+
readonly errorDetail?: string;
|
|
126
|
+
readonly packageResult?: BundlePackageResult;
|
|
127
|
+
readonly pendingBuilds?: readonly string[];
|
|
128
|
+
readonly restartReason?: RestartReason;
|
|
129
|
+
readonly failedAt?: 'registry' | 'spec-host';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export interface BundleInstallRequest {
|
|
133
|
+
readonly spec: string;
|
|
134
|
+
readonly registry?: BundleRegistry;
|
|
135
|
+
readonly requestId?: string;
|
|
136
|
+
readonly approvedBuilds?: readonly string[];
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
export type BundleCancellation = 'cancelled' | 'too-late' | 'not-running';
|
|
140
|
+
|
|
141
|
+
export type BundleSupplyState = 'not-a-module' | 'no-needs' | 'installed' | 'failed' | 'pending-restart';
|
|
142
|
+
|
|
143
|
+
export interface BundleModulePayload {
|
|
144
|
+
readonly kind: 'module' | 'not-module' | 'unknown';
|
|
145
|
+
readonly pkg: string;
|
|
146
|
+
readonly unit?: string;
|
|
147
|
+
readonly version?: string;
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
export interface BundleSupplyPayload {
|
|
151
|
+
readonly state: BundleSupplyState;
|
|
152
|
+
readonly reason?: string;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export interface BundleInstalledPlugin {
|
|
156
|
+
readonly kind: 'opencli-plugin';
|
|
157
|
+
readonly pkg: string;
|
|
158
|
+
readonly name?: string;
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
export interface BundleInstallPayload {
|
|
162
|
+
readonly change: BundleChange;
|
|
163
|
+
readonly module: BundleModulePayload;
|
|
164
|
+
readonly supply: BundleSupplyPayload;
|
|
165
|
+
readonly plugin?: BundleInstalledPlugin;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface BundleRemovePayload {
|
|
169
|
+
readonly change: BundleChange;
|
|
170
|
+
readonly keptFor: readonly string[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export interface BundleCancellationPayload {
|
|
174
|
+
readonly cancellation: BundleCancellation | null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export interface ModuleVersion {
|
|
178
|
+
readonly unit: string;
|
|
179
|
+
readonly pkg: string;
|
|
180
|
+
readonly installed: string;
|
|
181
|
+
readonly latest?: string;
|
|
182
|
+
readonly local?: boolean;
|
|
183
|
+
readonly refused?: readonly string[];
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
export interface WorkbenchVersion {
|
|
187
|
+
readonly pkg: string;
|
|
188
|
+
readonly installed: string;
|
|
189
|
+
readonly latest?: string;
|
|
190
|
+
readonly running?: string;
|
|
191
|
+
readonly local?: boolean;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
export interface ModuleVersionsPayload {
|
|
195
|
+
readonly modules: readonly ModuleVersion[];
|
|
196
|
+
readonly workbench?: WorkbenchVersion;
|
|
197
|
+
readonly selfUpdate?: WorkbenchSelfUpdate;
|
|
198
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export const CONFIG_SYNC_ROUTE = 'config-sync';
|
|
2
|
+
|
|
3
|
+
export const CONFIG_SYNC_RESOURCE = 'configSync';
|
|
4
|
+
|
|
5
|
+
export type ConfigSyncState = 'new' | 'differs' | 'same';
|
|
6
|
+
|
|
7
|
+
export type ConfigSyncAssetState = 'missing' | 'differs' | 'same' | 'external';
|
|
8
|
+
|
|
9
|
+
export interface ConfigSyncAssetFile {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly state: ConfigSyncAssetState;
|
|
12
|
+
readonly bytes: number | null;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface ConfigSyncAsset {
|
|
16
|
+
readonly key: string;
|
|
17
|
+
readonly path: string;
|
|
18
|
+
readonly kind: 'file' | 'dir';
|
|
19
|
+
readonly state: ConfigSyncAssetState;
|
|
20
|
+
readonly files: readonly ConfigSyncAssetFile[];
|
|
21
|
+
readonly bytes: number;
|
|
22
|
+
readonly reason?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface ConfigSyncRow {
|
|
26
|
+
readonly key: string;
|
|
27
|
+
readonly id: string;
|
|
28
|
+
readonly insert: boolean;
|
|
29
|
+
readonly state: ConfigSyncState;
|
|
30
|
+
readonly body: string;
|
|
31
|
+
readonly ownBody: string | null;
|
|
32
|
+
readonly missing: readonly string[];
|
|
33
|
+
readonly assets: readonly ConfigSyncAsset[];
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface ConfigSyncProfile {
|
|
37
|
+
readonly name: string;
|
|
38
|
+
readonly readable: boolean;
|
|
39
|
+
readonly candidates: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface ConfigSyncSnapshot {
|
|
43
|
+
readonly self: string;
|
|
44
|
+
readonly home: string;
|
|
45
|
+
readonly source: string;
|
|
46
|
+
readonly profiles: readonly ConfigSyncProfile[];
|
|
47
|
+
readonly rows: readonly ConfigSyncRow[];
|
|
48
|
+
readonly emptyProviders: boolean;
|
|
49
|
+
readonly reason?: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export interface ConfigSyncApplied {
|
|
53
|
+
readonly written: readonly string[];
|
|
54
|
+
readonly skipped: readonly string[];
|
|
55
|
+
readonly files: readonly string[];
|
|
56
|
+
readonly verified: boolean;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export interface ConfigSyncRequest {
|
|
60
|
+
readonly source: string;
|
|
61
|
+
readonly keys: readonly string[];
|
|
62
|
+
readonly overwrite: readonly string[];
|
|
63
|
+
readonly assets?: readonly string[];
|
|
64
|
+
readonly overwriteAssets?: readonly string[];
|
|
65
|
+
}
|