@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
package/dist/contract/needs.d.ts
CHANGED
|
@@ -22,11 +22,13 @@ export type SupplySource = {
|
|
|
22
22
|
readonly kind: 'local';
|
|
23
23
|
readonly path?: string;
|
|
24
24
|
readonly env?: string;
|
|
25
|
+
} | {
|
|
26
|
+
readonly kind: 'builtin';
|
|
25
27
|
};
|
|
26
28
|
/**
|
|
27
29
|
* 协议认得的外部来源种类。
|
|
28
30
|
*/
|
|
29
|
-
export declare const SUPPLY_SOURCE_KINDS: readonly ["npm", "git", "local"];
|
|
31
|
+
export declare const SUPPLY_SOURCE_KINDS: readonly ["npm", "git", "local", "builtin"];
|
|
30
32
|
/**
|
|
31
33
|
* 外部来源的类别。
|
|
32
34
|
*/
|
package/dist/contract/needs.js
CHANGED
|
@@ -6,7 +6,7 @@ export const NEED_KINDS = ['bin', 'extension', 'lib', 'env'];
|
|
|
6
6
|
/**
|
|
7
7
|
* 协议认得的外部来源种类。
|
|
8
8
|
*/
|
|
9
|
-
export const SUPPLY_SOURCE_KINDS = ['npm', 'git', 'local'];
|
|
9
|
+
export const SUPPLY_SOURCE_KINDS = ['npm', 'git', 'local', 'builtin'];
|
|
10
10
|
/**
|
|
11
11
|
* 协议认得的 need 字段;`x-` 前缀的字段留给第三方扩展,直接忽略。
|
|
12
12
|
*/
|
|
@@ -72,6 +72,8 @@ function sourceProblemsOf(raw, at) {
|
|
|
72
72
|
errors.push(`${at}.url 没写`);
|
|
73
73
|
return errors;
|
|
74
74
|
}
|
|
75
|
+
if (kind === 'builtin')
|
|
76
|
+
return errors;
|
|
75
77
|
if (text(raw['path']) === '' && text(raw['env']) === '') {
|
|
76
78
|
errors.push(`${at} 是 local,但 path 与 env 都没写`);
|
|
77
79
|
}
|
|
@@ -204,7 +206,7 @@ export const NEED_KIND_SPECS = Object.freeze({
|
|
|
204
206
|
extension: Object.freeze({
|
|
205
207
|
kind: 'extension',
|
|
206
208
|
probe: 'extension',
|
|
207
|
-
sources: Object.freeze(['npm', 'git', 'local']),
|
|
209
|
+
sources: Object.freeze(['npm', 'git', 'local', 'builtin']),
|
|
208
210
|
validate: validateKind('extension'),
|
|
209
211
|
}),
|
|
210
212
|
lib: Object.freeze({
|
|
@@ -10,7 +10,7 @@ export interface BundleRegistries {
|
|
|
10
10
|
readonly fallbackRegistries: readonly BundleRegistry[];
|
|
11
11
|
readonly resolved: string | null;
|
|
12
12
|
}
|
|
13
|
-
export type BundleInspectProblem = 'invalid-spec' | 'already-installed' | 'not-found' | 'not-a-package' | 'not-a-bundle' | 'not-a-workbench-module' | 'not-a-module-or-plugin' | 'network' | 'unknown';
|
|
13
|
+
export type BundleInspectProblem = 'invalid-spec' | 'already-installed' | 'not-found' | 'not-a-package' | 'not-a-bundle' | 'not-a-workbench-module' | 'not-a-module-or-plugin' | 'module-builtin-missing' | 'network' | 'unknown';
|
|
14
14
|
export type BundleSpecKind = 'registry' | 'path' | 'git' | 'tarball';
|
|
15
15
|
export interface BundleInspectionAccepted {
|
|
16
16
|
readonly status: 'accepted';
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import type { UnitTitle } from '../unit.js';
|
|
2
|
+
export declare const UNIT_MANAGER_ROUTE = "unit-manager";
|
|
3
|
+
export declare const UNIT_MODULE_ROUTE = "unit-module";
|
|
4
|
+
export interface UnitEntry {
|
|
5
|
+
readonly id: string;
|
|
6
|
+
readonly pkg: string;
|
|
7
|
+
readonly version?: string | undefined;
|
|
8
|
+
readonly enabled: boolean;
|
|
9
|
+
readonly local?: boolean | undefined;
|
|
10
|
+
readonly title?: UnitTitle | undefined;
|
|
11
|
+
}
|
|
12
|
+
export type UnitStage = 'install' | 'enable' | 'remove';
|
|
13
|
+
export type UnitApplication = 'applied' | 'restart-required' | 'failed' | 'cancelled';
|
|
14
|
+
export type UnitRestartReason = 'module-comparison' | 'no-hmr' | 'package-moved';
|
|
15
|
+
export interface UnitError {
|
|
16
|
+
readonly code: string;
|
|
17
|
+
readonly message: string;
|
|
18
|
+
readonly detail?: string | undefined;
|
|
19
|
+
}
|
|
20
|
+
export interface UnitChangeResult {
|
|
21
|
+
readonly changed: boolean;
|
|
22
|
+
readonly application: UnitApplication;
|
|
23
|
+
readonly restartReason?: UnitRestartReason | undefined;
|
|
24
|
+
readonly stage: UnitStage;
|
|
25
|
+
readonly target: string;
|
|
26
|
+
readonly enabled?: boolean | undefined;
|
|
27
|
+
readonly error?: UnitError | undefined;
|
|
28
|
+
readonly version?: string | undefined;
|
|
29
|
+
readonly warnings?: readonly string[] | undefined;
|
|
30
|
+
}
|
|
31
|
+
export interface UnitListPayload {
|
|
32
|
+
readonly ok: true;
|
|
33
|
+
readonly units: readonly UnitEntry[];
|
|
34
|
+
}
|
|
35
|
+
export interface UnitChangePayload {
|
|
36
|
+
readonly ok: boolean;
|
|
37
|
+
readonly result?: UnitChangeResult | undefined;
|
|
38
|
+
readonly error?: UnitError | undefined;
|
|
39
|
+
}
|
|
40
|
+
export interface UnitModuleDescriptor {
|
|
41
|
+
readonly unit: string;
|
|
42
|
+
readonly pkg: string;
|
|
43
|
+
readonly url: string;
|
|
44
|
+
readonly hash: string;
|
|
45
|
+
}
|
|
46
|
+
export interface UnitModulePayload {
|
|
47
|
+
readonly ok: boolean;
|
|
48
|
+
readonly module?: UnitModuleDescriptor | undefined;
|
|
49
|
+
readonly error?: UnitError | undefined;
|
|
50
|
+
}
|
package/dist/contract/unit.js
CHANGED
|
@@ -20,7 +20,8 @@ export function needsOf(manifest) {
|
|
|
20
20
|
* @returns 可代装的 need 列表。
|
|
21
21
|
*/
|
|
22
22
|
export function provisionableNeedsOf(manifest) {
|
|
23
|
-
return needsOf(manifest).filter((need) => (need.kind === 'extension' || need.kind === 'lib') &&
|
|
23
|
+
return needsOf(manifest).filter((need) => (need.kind === 'extension' || need.kind === 'lib') &&
|
|
24
|
+
(need.sources ?? []).some((source) => source.kind !== 'builtin'));
|
|
24
25
|
}
|
|
25
26
|
/**
|
|
26
27
|
* 市场门槛要看的那些需要:声明了 extension / lib 就算(不要求写了来源)。
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { validateAdapterSet } from './adapter-set.js';
|
|
2
|
+
const CAPABILITY_KEYS = ['console', 'pluginMarket', 'browserBridge'];
|
|
3
|
+
const CAPABILITIES_COVERED = true;
|
|
4
|
+
void CAPABILITIES_COVERED;
|
|
5
|
+
const DATA_METHODS = ['read', 'request', 'requestMany', 'submit', 'plan'];
|
|
6
|
+
function isNonEmptyString(value) {
|
|
7
|
+
return typeof value === 'string' && value.trim() !== '';
|
|
8
|
+
}
|
|
9
|
+
const CLI_DIR_METHODS = [
|
|
10
|
+
['cliCatalogPath', 'cliCatalogPath'],
|
|
11
|
+
['vendorPluginsDir', 'vendorPluginsDir'],
|
|
12
|
+
];
|
|
13
|
+
export function adapterContractGaps(set, ctx) {
|
|
14
|
+
const gaps = [];
|
|
15
|
+
const validated = validateAdapterSet(set, '契约');
|
|
16
|
+
if (!validated.ok) {
|
|
17
|
+
gaps.push(`成员不全:${validated.detail}`);
|
|
18
|
+
return gaps;
|
|
19
|
+
}
|
|
20
|
+
if (!Number.isInteger(set.apiVersion) || set.apiVersion < 1) {
|
|
21
|
+
gaps.push(`apiVersion 不是正整数:${String(set.apiVersion)}`);
|
|
22
|
+
}
|
|
23
|
+
const capabilities = set.runtime.capabilities(ctx);
|
|
24
|
+
for (const key of CAPABILITY_KEYS) {
|
|
25
|
+
if (typeof capabilities[key] !== 'boolean')
|
|
26
|
+
gaps.push(`capabilities.${key} 不是布尔值`);
|
|
27
|
+
}
|
|
28
|
+
if (typeof set.runtime.profile === 'function') {
|
|
29
|
+
const profile = set.runtime.profile(ctx);
|
|
30
|
+
if (!isNonEmptyString(profile?.label))
|
|
31
|
+
gaps.push('runtime.profile().label 不是非空字符串');
|
|
32
|
+
for (const key of ['plugin', 'pluginOf', 'pluginThing', 'pluginArea']) {
|
|
33
|
+
const text = profile?.terms?.[key];
|
|
34
|
+
if (!isNonEmptyString(text?.zh) || !isNonEmptyString(text?.en)) {
|
|
35
|
+
gaps.push(`runtime.profile().terms.${key} 要给 zh / en 两份非空文案`);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
if (!isNonEmptyString(profile?.installHint?.zh) || !isNonEmptyString(profile?.installHint?.en)) {
|
|
39
|
+
gaps.push('runtime.profile().installHint 要给 zh / en 两份非空文案');
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
if (typeof set.runtime.commandSurface === 'function') {
|
|
43
|
+
const surface = set.runtime.commandSurface(ctx);
|
|
44
|
+
if (surface !== undefined) {
|
|
45
|
+
if (!isNonEmptyString(surface.name))
|
|
46
|
+
gaps.push('runtime.commandSurface().name 不是非空字符串');
|
|
47
|
+
if (!isNonEmptyString(surface.pluginPrefix)) {
|
|
48
|
+
gaps.push('runtime.commandSurface().pluginPrefix 不是非空字符串');
|
|
49
|
+
}
|
|
50
|
+
if (typeof surface.invoke !== 'function')
|
|
51
|
+
gaps.push('runtime.commandSurface().invoke 不是函数');
|
|
52
|
+
else if (!isNonEmptyString(surface.invoke('site', 'command'))) {
|
|
53
|
+
gaps.push('runtime.commandSurface().invoke(site, command) 拼不出非空命令行');
|
|
54
|
+
}
|
|
55
|
+
if (typeof surface.help !== 'function')
|
|
56
|
+
gaps.push('runtime.commandSurface().help 不是函数');
|
|
57
|
+
else if (!isNonEmptyString(surface.help('site'))) {
|
|
58
|
+
gaps.push('runtime.commandSurface().help(site) 拼不出非空提示');
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
const health = set.runtime.health(ctx);
|
|
63
|
+
const commands = set.runtime.commands(ctx);
|
|
64
|
+
for (const [name, status] of Object.entries(health)) {
|
|
65
|
+
if (!isNonEmptyString(status?.command))
|
|
66
|
+
gaps.push(`health['${name}'].command 不是非空字符串`);
|
|
67
|
+
if (!['env', 'isolated', 'path'].includes(status?.source))
|
|
68
|
+
gaps.push(`health['${name}'].source 不是已知来源`);
|
|
69
|
+
}
|
|
70
|
+
for (const name of Object.keys(commands)) {
|
|
71
|
+
if (health[name] === undefined)
|
|
72
|
+
gaps.push(`commands 里的 ${name} 在 health 里没有对应条目`);
|
|
73
|
+
else if (!isNonEmptyString(commands[name]))
|
|
74
|
+
gaps.push(`commands['${name}'] 不是非空字符串`);
|
|
75
|
+
}
|
|
76
|
+
for (const method of DATA_METHODS) {
|
|
77
|
+
if (typeof set.data[method] !== 'function')
|
|
78
|
+
gaps.push(`data.${method} 不是函数`);
|
|
79
|
+
}
|
|
80
|
+
if (!isNonEmptyString(set.modules.isolatedRoot()))
|
|
81
|
+
gaps.push('modules.isolatedRoot() 不是非空字符串');
|
|
82
|
+
if (set.modules.runtimeInstallCommand !== undefined && !isNonEmptyString(set.modules.runtimeInstallCommand())) {
|
|
83
|
+
gaps.push('modules.runtimeInstallCommand() 给了但不是非空字符串');
|
|
84
|
+
}
|
|
85
|
+
for (const [name, method] of CLI_DIR_METHODS) {
|
|
86
|
+
const given = set.modules[method];
|
|
87
|
+
if (given !== undefined && !isNonEmptyString(given()))
|
|
88
|
+
gaps.push(`modules.${method}() 给了但不是非空字符串(${name})`);
|
|
89
|
+
}
|
|
90
|
+
if (typeof set.probe.probeUnits !== 'function')
|
|
91
|
+
gaps.push('probe.probeUnits 不是函数');
|
|
92
|
+
if (typeof set.probe.registerPreflight !== 'function')
|
|
93
|
+
gaps.push('probe.registerPreflight 不是函数');
|
|
94
|
+
return gaps;
|
|
95
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { DshHostContext } from '../api/dsh.js';
|
|
2
|
+
import { type AdapterSet, type CoreAdapterSet } from './adapters.js';
|
|
3
|
+
export interface WorkbenchConfig {
|
|
4
|
+
readonly adapterSet?: string;
|
|
5
|
+
}
|
|
6
|
+
export type AdapterSetFailure = 'not-configured' | 'no-profile' | 'malformed' | 'not-resolvable' | 'import-failed' | 'bad-export' | 'factory-failed' | 'incompatible-version' | 'missing-member';
|
|
7
|
+
export type AdapterSetLoad = {
|
|
8
|
+
readonly ok: true;
|
|
9
|
+
readonly spec: string;
|
|
10
|
+
readonly set: CoreAdapterSet;
|
|
11
|
+
} | {
|
|
12
|
+
readonly ok: false;
|
|
13
|
+
readonly spec?: string;
|
|
14
|
+
readonly failure: AdapterSetFailure;
|
|
15
|
+
readonly detail: string;
|
|
16
|
+
readonly cause?: unknown;
|
|
17
|
+
};
|
|
18
|
+
export declare const CORE_METHODS: readonly [readonly ["data", "read"], readonly ["data", "request"], readonly ["data", "requestMany"], readonly ["data", "submit"], readonly ["data", "plan"], readonly ["data", "submitPlan"], readonly ["supply", "resolvePluginSource"], readonly ["supply", "libInstallCommand"], readonly ["supply", "libUninstallCommand"], readonly ["supply", "pluginInstallPlan"], readonly ["supply", "recoveryCommand"], readonly ["supply", "latestVersion"], readonly ["supply", "missingReleaseParts"], readonly ["supply", "probeRelease"], readonly ["supply", "splitNpmSpec"], readonly ["profile", "dirOf"], readonly ["profile", "dshPlugins"], readonly ["profile", "selfUpdateView"], readonly ["probe", "probeUnits"], readonly ["probe", "registerPreflight"], readonly ["probe", "declaredPluginCommands"]];
|
|
19
|
+
export declare function validateAdapterSet(value: unknown, spec: string): AdapterSetLoad;
|
|
20
|
+
export declare function loadAdapterSet(ctx: DshHostContext, spec: string | undefined): Promise<AdapterSetLoad>;
|
|
21
|
+
export declare function withDefaultAdapterSet(defaults: AdapterSet, loaded: AdapterSetLoad): AdapterSet;
|
|
22
|
+
export declare function resolveAdapterSet(ctx: DshHostContext, spec: string | undefined, makeDefaults: () => Promise<AdapterSet>): Promise<{
|
|
23
|
+
readonly set: AdapterSet;
|
|
24
|
+
readonly load: AdapterSetLoad;
|
|
25
|
+
readonly usedDefaults: boolean;
|
|
26
|
+
}>;
|
|
27
|
+
export type { AdapterSet, CoreAdapterSet };
|
|
@@ -0,0 +1,258 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from 'node:fs';
|
|
2
|
+
import { createRequire } from 'node:module';
|
|
3
|
+
import { dirname, join } from 'node:path';
|
|
4
|
+
import { pathToFileURL } from 'node:url';
|
|
5
|
+
import { ADAPTER_SET_API_VERSION, SUPPORTED_ADAPTER_API_VERSIONS, } from './adapters.js';
|
|
6
|
+
import { profileDirOf } from './installed-module.js';
|
|
7
|
+
import { isPackageName } from './spec.js';
|
|
8
|
+
const CORE_MEMBERS = ['data', 'supply', 'profile', 'probe'];
|
|
9
|
+
export const CORE_METHODS = [
|
|
10
|
+
['data', 'read'],
|
|
11
|
+
['data', 'request'],
|
|
12
|
+
['data', 'requestMany'],
|
|
13
|
+
['data', 'submit'],
|
|
14
|
+
['data', 'plan'],
|
|
15
|
+
['data', 'submitPlan'],
|
|
16
|
+
['supply', 'resolvePluginSource'],
|
|
17
|
+
['supply', 'libInstallCommand'],
|
|
18
|
+
['supply', 'libUninstallCommand'],
|
|
19
|
+
['supply', 'pluginInstallPlan'],
|
|
20
|
+
['supply', 'recoveryCommand'],
|
|
21
|
+
['supply', 'latestVersion'],
|
|
22
|
+
['supply', 'missingReleaseParts'],
|
|
23
|
+
['supply', 'probeRelease'],
|
|
24
|
+
['supply', 'splitNpmSpec'],
|
|
25
|
+
['profile', 'dirOf'],
|
|
26
|
+
['profile', 'dshPlugins'],
|
|
27
|
+
['profile', 'selfUpdateView'],
|
|
28
|
+
['probe', 'probeUnits'],
|
|
29
|
+
['probe', 'registerPreflight'],
|
|
30
|
+
['probe', 'declaredPluginCommands'],
|
|
31
|
+
];
|
|
32
|
+
const DATA_METHODS_COVERED = true;
|
|
33
|
+
const SUPPLY_METHODS_COVERED = true;
|
|
34
|
+
const PROFILE_METHODS_COVERED = true;
|
|
35
|
+
const PROBE_METHODS_COVERED = true;
|
|
36
|
+
void DATA_METHODS_COVERED;
|
|
37
|
+
void SUPPLY_METHODS_COVERED;
|
|
38
|
+
void PROFILE_METHODS_COVERED;
|
|
39
|
+
void PROBE_METHODS_COVERED;
|
|
40
|
+
const FULL_MEMBERS = ['modules', 'runtime', 'plugins', 'actions'];
|
|
41
|
+
const FULL_METHODS = [
|
|
42
|
+
['modules', 'isolatedRoot'],
|
|
43
|
+
['modules', 'isolatedHome'],
|
|
44
|
+
['modules', 'afterLibInstall'],
|
|
45
|
+
['modules', 'profileDirOf'],
|
|
46
|
+
['modules', 'profileModules'],
|
|
47
|
+
['modules', 'readInstalledModule'],
|
|
48
|
+
['modules', 'readProfilePackage'],
|
|
49
|
+
['modules', 'readBundleManager'],
|
|
50
|
+
['modules', 'createRegistryNotebook'],
|
|
51
|
+
['modules', 'declarationGaps'],
|
|
52
|
+
['modules', 'moduleDeclarationOf'],
|
|
53
|
+
['modules', 'registryDeclarationOf'],
|
|
54
|
+
['modules', 'pathDeclarationOf'],
|
|
55
|
+
['modules', 'declarationRefusalOf'],
|
|
56
|
+
['modules', 'refusalReason'],
|
|
57
|
+
['modules', 'packageRouteOf'],
|
|
58
|
+
['modules', 'isNewerVersion'],
|
|
59
|
+
['modules', 'startSelfUpdate'],
|
|
60
|
+
['runtime', 'packageRoot'],
|
|
61
|
+
['runtime', 'capabilities'],
|
|
62
|
+
['runtime', 'commands'],
|
|
63
|
+
['runtime', 'runners'],
|
|
64
|
+
['runtime', 'health'],
|
|
65
|
+
['runtime', 'seed'],
|
|
66
|
+
['plugins', 'declarationLookup'],
|
|
67
|
+
['plugins', 'createUnits'],
|
|
68
|
+
['actions', 'configSyncHandler'],
|
|
69
|
+
['actions', 'profileCreateHandler'],
|
|
70
|
+
['actions', 'configSyncAction'],
|
|
71
|
+
['actions', 'profileCreateAction'],
|
|
72
|
+
];
|
|
73
|
+
function methodOf(value, member, method) {
|
|
74
|
+
const part = value[member];
|
|
75
|
+
if (typeof part !== 'object' || part === null)
|
|
76
|
+
return undefined;
|
|
77
|
+
return part[method];
|
|
78
|
+
}
|
|
79
|
+
function failure(failureKind, detail, spec, cause) {
|
|
80
|
+
return {
|
|
81
|
+
ok: false,
|
|
82
|
+
...(spec === undefined ? {} : { spec }),
|
|
83
|
+
failure: failureKind,
|
|
84
|
+
detail,
|
|
85
|
+
...(cause === undefined ? {} : { cause }),
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
function packageDirOf(spec, from) {
|
|
89
|
+
let dir = from;
|
|
90
|
+
for (;;) {
|
|
91
|
+
const candidate = join(dir, 'node_modules', spec);
|
|
92
|
+
if (existsSync(join(candidate, 'package.json')))
|
|
93
|
+
return candidate;
|
|
94
|
+
const up = dirname(dir);
|
|
95
|
+
if (up === dir)
|
|
96
|
+
return undefined;
|
|
97
|
+
dir = up;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function entryOf(value) {
|
|
101
|
+
if (typeof value === 'string')
|
|
102
|
+
return value;
|
|
103
|
+
if (typeof value !== 'object' || value === null)
|
|
104
|
+
return undefined;
|
|
105
|
+
const record = value;
|
|
106
|
+
for (const key of ['import', 'node', 'module', 'default', 'require']) {
|
|
107
|
+
const found = entryOf(record[key]);
|
|
108
|
+
if (found !== undefined)
|
|
109
|
+
return found;
|
|
110
|
+
}
|
|
111
|
+
return undefined;
|
|
112
|
+
}
|
|
113
|
+
function exportsEntryOf(value) {
|
|
114
|
+
if (typeof value !== 'object' || value === null)
|
|
115
|
+
return entryOf(value);
|
|
116
|
+
const record = value;
|
|
117
|
+
return '.' in record ? entryOf(record['.']) : entryOf(record);
|
|
118
|
+
}
|
|
119
|
+
function esmEntryUrl(spec, profileDir) {
|
|
120
|
+
const dir = packageDirOf(spec, profileDir);
|
|
121
|
+
if (dir === undefined)
|
|
122
|
+
return undefined;
|
|
123
|
+
let pkg;
|
|
124
|
+
try {
|
|
125
|
+
pkg = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'));
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return undefined;
|
|
129
|
+
}
|
|
130
|
+
const main = typeof pkg['main'] === 'string' ? pkg['main'] : undefined;
|
|
131
|
+
const module = typeof pkg['module'] === 'string' ? pkg['module'] : undefined;
|
|
132
|
+
const entry = exportsEntryOf(pkg['exports']) ?? module ?? main ?? 'index.js';
|
|
133
|
+
const file = join(dir, entry);
|
|
134
|
+
return existsSync(file) ? pathToFileURL(file).href : undefined;
|
|
135
|
+
}
|
|
136
|
+
function resolveFromProfile(spec, profileDir) {
|
|
137
|
+
const esm = esmEntryUrl(spec, profileDir);
|
|
138
|
+
if (esm !== undefined)
|
|
139
|
+
return esm;
|
|
140
|
+
const parent = pathToFileURL(join(profileDir, 'package.json')).href;
|
|
141
|
+
try {
|
|
142
|
+
return pathToFileURL(createRequire(parent).resolve(spec)).href;
|
|
143
|
+
}
|
|
144
|
+
catch {
|
|
145
|
+
return undefined;
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
function versionOf(value) {
|
|
149
|
+
const version = value['apiVersion'];
|
|
150
|
+
return typeof version === 'number' && Number.isInteger(version) ? version : undefined;
|
|
151
|
+
}
|
|
152
|
+
export function validateAdapterSet(value, spec) {
|
|
153
|
+
if (typeof value !== 'object' || value === null) {
|
|
154
|
+
return failure('missing-member', `${spec} 的 createAdapterSet(ctx) 没回一个对象`, spec);
|
|
155
|
+
}
|
|
156
|
+
const record = value;
|
|
157
|
+
const version = versionOf(record);
|
|
158
|
+
if (version === undefined || !SUPPORTED_ADAPTER_API_VERSIONS.includes(version)) {
|
|
159
|
+
return failure('incompatible-version', `${spec} 的适配器协议版本是 ${String(record['apiVersion'])},工作台只认 v${ADAPTER_SET_API_VERSION};v1 集合要补 data.plan 与 data.submitPlan 并升到 v2`, spec);
|
|
160
|
+
}
|
|
161
|
+
const missing = CORE_MEMBERS.filter((member) => record[member] === undefined || record[member] === null);
|
|
162
|
+
for (const [member, method] of CORE_METHODS) {
|
|
163
|
+
if (typeof methodOf(record, member, method) !== 'function')
|
|
164
|
+
missing.push(`${member}.${method}`);
|
|
165
|
+
}
|
|
166
|
+
if (typeof record['id'] !== 'string' || record['id'].trim() === '')
|
|
167
|
+
missing.push('id');
|
|
168
|
+
if (typeof record['version'] !== 'string' || record['version'].trim() === '')
|
|
169
|
+
missing.push('version');
|
|
170
|
+
if (FULL_MEMBERS.some((member) => record[member] !== undefined)) {
|
|
171
|
+
for (const member of FULL_MEMBERS) {
|
|
172
|
+
if (typeof record[member] !== 'object' || record[member] === null)
|
|
173
|
+
missing.push(member);
|
|
174
|
+
}
|
|
175
|
+
for (const [member, method] of FULL_METHODS) {
|
|
176
|
+
if (typeof methodOf(record, member, method) !== 'function')
|
|
177
|
+
missing.push(`${member}.${method}`);
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
if (missing.length > 0) {
|
|
181
|
+
const hint = missing.includes('data.submitPlan')
|
|
182
|
+
? '(适配器集合要补写计划 data.submitPlan)'
|
|
183
|
+
: missing.includes('data.plan')
|
|
184
|
+
? '(适配器集合要补多跳读取 data.plan)'
|
|
185
|
+
: '';
|
|
186
|
+
return failure('missing-member', `${spec} 少了 ${missing.join(' / ')}${hint}`, spec);
|
|
187
|
+
}
|
|
188
|
+
return { ok: true, spec, set: record };
|
|
189
|
+
}
|
|
190
|
+
export async function loadAdapterSet(ctx, spec) {
|
|
191
|
+
const wanted = typeof spec === 'string' ? spec.trim() : spec === undefined ? '' : String(spec).trim();
|
|
192
|
+
if (wanted === '')
|
|
193
|
+
return failure('not-configured', '没有配置 adapterSet');
|
|
194
|
+
const profileDir = profileDirOf(ctx);
|
|
195
|
+
if (profileDir === null)
|
|
196
|
+
return failure('no-profile', '找不到 profile 目录,无法从 profile 解析适配器集合', wanted);
|
|
197
|
+
if (!isPackageName(wanted)) {
|
|
198
|
+
return failure('malformed', `适配器集合要写包名(如 @acme/adapters-set),收到 ${JSON.stringify(wanted)}`, wanted);
|
|
199
|
+
}
|
|
200
|
+
const url = resolveFromProfile(wanted, profileDir);
|
|
201
|
+
if (url === undefined) {
|
|
202
|
+
return failure('not-resolvable', `在 profile 里解析不到 ${wanted},先把它装进这个 profile`, wanted);
|
|
203
|
+
}
|
|
204
|
+
let mod;
|
|
205
|
+
try {
|
|
206
|
+
mod = (await import(url));
|
|
207
|
+
}
|
|
208
|
+
catch (error) {
|
|
209
|
+
return failure('import-failed', `${wanted} 的入口没加载成:${String(error)}`, wanted, error);
|
|
210
|
+
}
|
|
211
|
+
const factory = mod['createAdapterSet'] ?? mod['default'];
|
|
212
|
+
if (typeof factory !== 'function') {
|
|
213
|
+
return failure('bad-export', `${wanted} 没导出 createAdapterSet(ctx),导出键:${Object.keys(mod).join(', ')}`, wanted);
|
|
214
|
+
}
|
|
215
|
+
let value;
|
|
216
|
+
try {
|
|
217
|
+
const raw = await factory(ctx);
|
|
218
|
+
if (typeof raw !== 'object' || raw === null) {
|
|
219
|
+
return failure('missing-member', `${wanted} 的 createAdapterSet(ctx) 没回一个对象`, wanted);
|
|
220
|
+
}
|
|
221
|
+
value = raw;
|
|
222
|
+
}
|
|
223
|
+
catch (error) {
|
|
224
|
+
return failure('factory-failed', `${wanted} 的 createAdapterSet(ctx) 抛了:${String(error)}`, wanted, error);
|
|
225
|
+
}
|
|
226
|
+
return validateAdapterSet(value, wanted);
|
|
227
|
+
}
|
|
228
|
+
export function withDefaultAdapterSet(defaults, loaded) {
|
|
229
|
+
if (!loaded.ok)
|
|
230
|
+
return defaults;
|
|
231
|
+
const set = loaded.set;
|
|
232
|
+
return {
|
|
233
|
+
apiVersion: set.apiVersion ?? defaults.apiVersion,
|
|
234
|
+
id: set.id ?? defaults.id,
|
|
235
|
+
version: set.version ?? defaults.version,
|
|
236
|
+
data: set.data ?? defaults.data,
|
|
237
|
+
libs: set.libs ?? defaults.libs,
|
|
238
|
+
supply: set.supply ?? defaults.supply,
|
|
239
|
+
modules: set.modules ?? defaults.modules,
|
|
240
|
+
profile: set.profile ?? defaults.profile,
|
|
241
|
+
probe: set.probe ?? defaults.probe,
|
|
242
|
+
runtime: set.runtime ?? defaults.runtime,
|
|
243
|
+
plugins: set.plugins ?? defaults.plugins,
|
|
244
|
+
actions: set.actions ?? defaults.actions,
|
|
245
|
+
};
|
|
246
|
+
}
|
|
247
|
+
function isFullAdapterSet(value) {
|
|
248
|
+
const candidate = value;
|
|
249
|
+
return ['modules', 'runtime', 'plugins', 'actions'].every((member) => typeof candidate[member] === 'object' && candidate[member] !== null);
|
|
250
|
+
}
|
|
251
|
+
export async function resolveAdapterSet(ctx, spec, makeDefaults) {
|
|
252
|
+
const load = await loadAdapterSet(ctx, spec);
|
|
253
|
+
if (load.ok && isFullAdapterSet(load.set)) {
|
|
254
|
+
return { set: load.set, load, usedDefaults: false };
|
|
255
|
+
}
|
|
256
|
+
const defaults = await makeDefaults();
|
|
257
|
+
return { set: withDefaultAdapterSet(defaults, load), load, usedDefaults: true };
|
|
258
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { BundleCancellation, BundleChange, BundleInspection, BundleInstallRequest, BundleRegistries, BundleRegistry, BundleUpdateOutcome, BundleUpdateRequest, BundleVersionList } from '../contract/protocol/bundle-install.js';
|
|
2
|
+
export type InstalledModule = {
|
|
3
|
+
readonly kind: 'module';
|
|
4
|
+
readonly pkg: string;
|
|
5
|
+
readonly unit: string;
|
|
6
|
+
readonly version: string;
|
|
7
|
+
readonly registry?: string;
|
|
8
|
+
readonly local?: boolean;
|
|
9
|
+
} | {
|
|
10
|
+
readonly kind: 'not-module';
|
|
11
|
+
readonly pkg: string;
|
|
12
|
+
} | {
|
|
13
|
+
readonly kind: 'unknown';
|
|
14
|
+
readonly pkg: string;
|
|
15
|
+
};
|
|
16
|
+
export interface ProfileModule {
|
|
17
|
+
readonly pkg: string;
|
|
18
|
+
readonly unit: string;
|
|
19
|
+
readonly version: string;
|
|
20
|
+
readonly registry?: string;
|
|
21
|
+
readonly local?: boolean;
|
|
22
|
+
readonly fromRegistry?: boolean;
|
|
23
|
+
}
|
|
24
|
+
export interface ProfilePackage {
|
|
25
|
+
readonly pkg: string;
|
|
26
|
+
readonly version: string;
|
|
27
|
+
readonly registry?: string;
|
|
28
|
+
readonly local?: boolean;
|
|
29
|
+
}
|
|
30
|
+
export interface BundleManager {
|
|
31
|
+
registries(): Promise<BundleRegistries | null>;
|
|
32
|
+
inspect(spec: string, registry?: BundleRegistry): Promise<BundleInspection | null>;
|
|
33
|
+
install(request: BundleInstallRequest): Promise<BundleChange | null>;
|
|
34
|
+
remove(name: string): Promise<BundleChange | null>;
|
|
35
|
+
setEnabled?(name: string, enabled: boolean): Promise<BundleChange | null>;
|
|
36
|
+
cancel(requestId: string): Promise<BundleCancellation | null>;
|
|
37
|
+
listVersions?(name: string, registry?: BundleRegistry): Promise<BundleVersionList | null>;
|
|
38
|
+
updateBundle?(name: string, version: string, request?: BundleUpdateRequest): Promise<BundleUpdateOutcome | null>;
|
|
39
|
+
waitForInstall?(requestId: string): Promise<BundleChange | null>;
|
|
40
|
+
}
|
|
41
|
+
export interface RegistryEntry {
|
|
42
|
+
readonly scope: string;
|
|
43
|
+
readonly registry: string;
|
|
44
|
+
}
|
|
45
|
+
export interface RegistryNotebook {
|
|
46
|
+
sources(): readonly RegistryEntry[];
|
|
47
|
+
remember(entries: readonly RegistryEntry[]): readonly string[];
|
|
48
|
+
swapScope?(scope: string, registry: string): () => void;
|
|
49
|
+
}
|
|
50
|
+
export interface SelfUpdatePaths {
|
|
51
|
+
readonly dir: string;
|
|
52
|
+
readonly planFile: string;
|
|
53
|
+
readonly marker: string;
|
|
54
|
+
readonly log: string;
|
|
55
|
+
readonly versionsDir: string;
|
|
56
|
+
}
|
|
57
|
+
export interface SelfUpdateRequest {
|
|
58
|
+
readonly dshHome: string;
|
|
59
|
+
readonly profile: string;
|
|
60
|
+
readonly pkg: string;
|
|
61
|
+
readonly from: string;
|
|
62
|
+
readonly to: string;
|
|
63
|
+
readonly running?: string | undefined;
|
|
64
|
+
readonly dshVersion?: string | undefined;
|
|
65
|
+
readonly pinned: boolean;
|
|
66
|
+
}
|
|
67
|
+
export interface SelfUpdateStart {
|
|
68
|
+
readonly started: boolean;
|
|
69
|
+
readonly paths: SelfUpdatePaths;
|
|
70
|
+
readonly forward: string;
|
|
71
|
+
}
|
|
72
|
+
export interface RuntimeStatus {
|
|
73
|
+
readonly command: string;
|
|
74
|
+
readonly source: 'env' | 'isolated' | 'path';
|
|
75
|
+
readonly isolated: string | null;
|
|
76
|
+
}
|
|
77
|
+
export declare function scopeOf(pkg: string): string | null;
|
|
78
|
+
export declare function normalizeRegistry(url: string): string;
|
|
79
|
+
export declare function sameRegistry(a: string | null | undefined, b: string | null | undefined): boolean;
|
|
80
|
+
export declare function registryFailure(change: {
|
|
81
|
+
application?: string;
|
|
82
|
+
packageResult?: {
|
|
83
|
+
kind?: string;
|
|
84
|
+
output?: string;
|
|
85
|
+
};
|
|
86
|
+
errorDetail?: string;
|
|
87
|
+
}): boolean;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export function scopeOf(pkg) {
|
|
2
|
+
const slash = pkg.indexOf('/');
|
|
3
|
+
return pkg.startsWith('@') && slash > 1 ? pkg.slice(0, slash) : null;
|
|
4
|
+
}
|
|
5
|
+
export function normalizeRegistry(url) {
|
|
6
|
+
const trimmed = url.trim();
|
|
7
|
+
return trimmed.endsWith('/') ? trimmed : `${trimmed}/`;
|
|
8
|
+
}
|
|
9
|
+
export function sameRegistry(a, b) {
|
|
10
|
+
if (a === null || a === undefined || b === null || b === undefined)
|
|
11
|
+
return false;
|
|
12
|
+
if (a.trim() === '' || b.trim() === '')
|
|
13
|
+
return false;
|
|
14
|
+
return normalizeRegistry(a) === normalizeRegistry(b);
|
|
15
|
+
}
|
|
16
|
+
export function registryFailure(change) {
|
|
17
|
+
if (change.application !== 'failed')
|
|
18
|
+
return false;
|
|
19
|
+
if (change.packageResult?.kind === 'not-found')
|
|
20
|
+
return true;
|
|
21
|
+
const output = change.packageResult?.output ?? change.errorDetail ?? '';
|
|
22
|
+
return /ERR_PNPM_[A-Z_]*FETCH/.test(output);
|
|
23
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { HostOs, HostSurface, ProfileName } from '../../contract/protocol/platform.js';
|
|
2
|
+
export interface HostSurfaceInput {
|
|
3
|
+
readonly proc?: {
|
|
4
|
+
readonly versions: {
|
|
5
|
+
readonly electron?: string | undefined;
|
|
6
|
+
readonly node?: string | undefined;
|
|
7
|
+
};
|
|
8
|
+
};
|
|
9
|
+
readonly profile?: string | undefined;
|
|
10
|
+
readonly platform?: NodeJS.Platform | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function profileNameOf(raw: string | undefined): ProfileName;
|
|
13
|
+
export declare function hostOsOf(platform: NodeJS.Platform): HostOs;
|
|
14
|
+
export declare function hostSurface(input?: HostSurfaceInput): HostSurface;
|