@dsh-workbench/shared 1.5.2-alpha.3 → 1.5.2-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/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/protocol/unit-manager.d.ts +50 -0
- package/dist/contract/protocol/unit-manager.js +2 -0
- 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 +1 -1
- package/dist/host/runtime/dsh-compat.js +4 -1
- package/dist/host/runtime/front-app.d.ts +6 -0
- package/dist/host/runtime/front-app.js +70 -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-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/lib/dsh-client.d.ts +1 -1
- package/package.json +51 -47
- package/src/host/runtime/__tests__/dsh-compat.test.ts +10 -2
- package/src/host/runtime/dsh-compat.ts +4 -2
- package/src/lib/dsh-client.ts +2 -1
|
@@ -0,0 +1,182 @@
|
|
|
1
|
+
import { isRecord } from '../contract/guards.js';
|
|
2
|
+
function siteUndeclaredOf(site, sites) {
|
|
3
|
+
return {
|
|
4
|
+
code: 'invalid-request',
|
|
5
|
+
message: sites === undefined
|
|
6
|
+
? `模块清单没有站点表(host.sites),这条配方引用了站点 ${site}`
|
|
7
|
+
: `站点 ${site} 没在清单 host.sites 里声明`,
|
|
8
|
+
pageCode: 'site-undeclared',
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
function siteOf(site, sites) {
|
|
12
|
+
if (site === undefined)
|
|
13
|
+
return { ok: true, value: undefined };
|
|
14
|
+
if (!isRecord(sites) || !Object.hasOwn(sites, site))
|
|
15
|
+
return { ok: false, problem: siteUndeclaredOf(site, sites) };
|
|
16
|
+
const found = sites[site];
|
|
17
|
+
if (!isRecord(found) || typeof found.origin !== 'string' || found.origin.trim() === '') {
|
|
18
|
+
return {
|
|
19
|
+
ok: false,
|
|
20
|
+
problem: {
|
|
21
|
+
code: 'invalid-request',
|
|
22
|
+
message: `站点 ${site} 没有 origin —— 清单 host.sites.${site} 至少要写一个 http(s) origin`,
|
|
23
|
+
pageCode: 'site-undeclared',
|
|
24
|
+
},
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
return { ok: true, value: found };
|
|
28
|
+
}
|
|
29
|
+
function emptyProblemOf(label) {
|
|
30
|
+
return {
|
|
31
|
+
code: 'invalid-request',
|
|
32
|
+
message: `${label}要有 origin 或 site 至少一个`,
|
|
33
|
+
pageCode: 'site-undeclared',
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* 把一条只写 `site`(或同时写 `origin`)的配方解析成带 `origin` 的直白形状。
|
|
38
|
+
* 显式字段优先于站点默认值;`origin` 显式写时只覆盖站点的 origin。
|
|
39
|
+
*/
|
|
40
|
+
export function resolveRecipeOf(recipe, sites) {
|
|
41
|
+
if (typeof recipe !== 'object' || recipe === null || Array.isArray(recipe)) {
|
|
42
|
+
return { ok: false, problem: emptyProblemOf('配方') };
|
|
43
|
+
}
|
|
44
|
+
const originText = typeof recipe.origin === 'string' ? recipe.origin.trim() : '';
|
|
45
|
+
const siteText = typeof recipe.site === 'string' ? recipe.site.trim() : '';
|
|
46
|
+
const siteName = siteText === '' ? undefined : siteText;
|
|
47
|
+
if (originText === '' && siteName === undefined)
|
|
48
|
+
return { ok: false, problem: emptyProblemOf('配方') };
|
|
49
|
+
const picked = siteOf(siteName, sites);
|
|
50
|
+
if (!picked.ok)
|
|
51
|
+
return picked;
|
|
52
|
+
const site = picked.value;
|
|
53
|
+
if (originText === '' && site === undefined)
|
|
54
|
+
return { ok: false, problem: emptyProblemOf('配方') };
|
|
55
|
+
const origin = originText === '' ? site.origin : originText;
|
|
56
|
+
return {
|
|
57
|
+
ok: true,
|
|
58
|
+
value: {
|
|
59
|
+
...recipe,
|
|
60
|
+
origin,
|
|
61
|
+
...(recipe.loginUrl === undefined && site?.loginUrl !== undefined ? { loginUrl: site.loginUrl } : {}),
|
|
62
|
+
...(recipe.session === undefined && site?.session !== undefined ? { session: site.session } : {}),
|
|
63
|
+
...(recipe.timeoutMs === undefined && site?.timeoutMs !== undefined ? { timeoutMs: site.timeoutMs } : {}),
|
|
64
|
+
...(recipe.authLoss === undefined && site?.authLoss !== undefined ? { authLoss: site.authLoss } : {}),
|
|
65
|
+
},
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* 把一份只写 `site`(或同时写 `origin`)的读取计划解析成带 `origin` 的直白形状。
|
|
70
|
+
* 显式字段优先于站点默认值。
|
|
71
|
+
*/
|
|
72
|
+
export function resolvePlanOf(plan, sites) {
|
|
73
|
+
if (typeof plan !== 'object' || plan === null || Array.isArray(plan)) {
|
|
74
|
+
return { ok: false, problem: emptyProblemOf('计划') };
|
|
75
|
+
}
|
|
76
|
+
const originText = typeof plan.origin === 'string' ? plan.origin.trim() : '';
|
|
77
|
+
const siteText = typeof plan.site === 'string' ? plan.site.trim() : '';
|
|
78
|
+
const siteName = siteText === '' ? undefined : siteText;
|
|
79
|
+
if (originText === '' && siteName === undefined)
|
|
80
|
+
return { ok: false, problem: emptyProblemOf('计划') };
|
|
81
|
+
const picked = siteOf(siteName, sites);
|
|
82
|
+
if (!picked.ok)
|
|
83
|
+
return picked;
|
|
84
|
+
const site = picked.value;
|
|
85
|
+
if (originText === '' && site === undefined)
|
|
86
|
+
return { ok: false, problem: emptyProblemOf('计划') };
|
|
87
|
+
const origin = originText === '' ? site.origin : originText;
|
|
88
|
+
return {
|
|
89
|
+
ok: true,
|
|
90
|
+
value: {
|
|
91
|
+
...plan,
|
|
92
|
+
origin,
|
|
93
|
+
...(plan.loginUrl === undefined && site?.loginUrl !== undefined ? { loginUrl: site.loginUrl } : {}),
|
|
94
|
+
...(plan.session === undefined && site?.session !== undefined ? { session: site.session } : {}),
|
|
95
|
+
...(plan.timeoutMs === undefined && site?.timeoutMs !== undefined ? { timeoutMs: site.timeoutMs } : {}),
|
|
96
|
+
...(plan.authLoss === undefined && site?.authLoss !== undefined ? { authLoss: site.authLoss } : {}),
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* 把相对信封 `dataPath` 的路径展开成绝对路径;`envelope: false` 表示从根取、不展开。
|
|
102
|
+
* 多段 `dataPath`(如 `data.list`)不猜语义,要求调用方写全。
|
|
103
|
+
*/
|
|
104
|
+
export function envelopePathOf(path, envelope) {
|
|
105
|
+
if (path !== undefined && typeof path !== 'string') {
|
|
106
|
+
return { ok: false, problem: 'response.path 要是字符串' };
|
|
107
|
+
}
|
|
108
|
+
const rawPath = path?.trim() ?? '';
|
|
109
|
+
const normalizedPath = rawPath === '' ? undefined : rawPath;
|
|
110
|
+
if (rawPath !== '' && rawPath.split('.').some((segment) => segment.trim() === '')) {
|
|
111
|
+
return { ok: false, problem: 'response.path 里不许有空段' };
|
|
112
|
+
}
|
|
113
|
+
if (envelope === undefined || envelope === false)
|
|
114
|
+
return { ok: true, path: normalizedPath };
|
|
115
|
+
if (typeof envelope !== 'object' || envelope === null || Array.isArray(envelope)) {
|
|
116
|
+
return { ok: false, problem: '信封要是对象或 false' };
|
|
117
|
+
}
|
|
118
|
+
if (envelope.dataPath !== undefined && typeof envelope.dataPath !== 'string') {
|
|
119
|
+
return { ok: false, problem: '信封的 dataPath 要是字符串' };
|
|
120
|
+
}
|
|
121
|
+
const dataPath = envelope.dataPath?.trim();
|
|
122
|
+
if (dataPath !== undefined && dataPath.split('.').some((segment) => segment.trim() === '')) {
|
|
123
|
+
return { ok: false, problem: '信封的 dataPath 里不许有空段' };
|
|
124
|
+
}
|
|
125
|
+
if (dataPath === undefined || dataPath === '')
|
|
126
|
+
return { ok: true, path: normalizedPath };
|
|
127
|
+
const current = rawPath;
|
|
128
|
+
if (current === '')
|
|
129
|
+
return { ok: true, path: dataPath };
|
|
130
|
+
const under = current === dataPath || current.startsWith(`${dataPath}.`);
|
|
131
|
+
if (!under && dataPath.includes('.')) {
|
|
132
|
+
return {
|
|
133
|
+
ok: false,
|
|
134
|
+
problem: `站点信封的 dataPath 有多段(${dataPath}),配方路径要写全(以 ${dataPath} 开头)`,
|
|
135
|
+
};
|
|
136
|
+
}
|
|
137
|
+
const next = under ? current : `${dataPath}.${current}`;
|
|
138
|
+
const doubled = `${dataPath}.${dataPath}`;
|
|
139
|
+
if (next === doubled || next.startsWith(`${doubled}.`)) {
|
|
140
|
+
return { ok: false, problem: `路径出现重复前缀 ${doubled}` };
|
|
141
|
+
}
|
|
142
|
+
return { ok: true, path: next };
|
|
143
|
+
}
|
|
144
|
+
function expandedStepOf(step, envelope) {
|
|
145
|
+
if (typeof step !== 'object' || step === null || Array.isArray(step))
|
|
146
|
+
throw new Error('计划里的步骤要是对象');
|
|
147
|
+
const next = { ...step };
|
|
148
|
+
if (step.response === undefined || step.response === null) {
|
|
149
|
+
delete next.response;
|
|
150
|
+
}
|
|
151
|
+
else if ((step.response.kind ?? 'json') === 'json') {
|
|
152
|
+
const got = envelopePathOf(step.response.path, envelope);
|
|
153
|
+
if (!got.ok)
|
|
154
|
+
throw new Error(got.problem);
|
|
155
|
+
next.response = { ...step.response, ...(got.path === undefined ? {} : { path: got.path }) };
|
|
156
|
+
}
|
|
157
|
+
if (step.while === undefined || step.while === null) {
|
|
158
|
+
delete next.while;
|
|
159
|
+
}
|
|
160
|
+
else {
|
|
161
|
+
const got = envelopePathOf(step.while.path, envelope);
|
|
162
|
+
if (!got.ok)
|
|
163
|
+
throw new Error(got.problem);
|
|
164
|
+
next.while = { ...step.while, path: got.path ?? step.while.path };
|
|
165
|
+
}
|
|
166
|
+
return next;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* 手写计划的信封展开:吃一份计划与站点,返回 `response.path` / `while.path` 已展开的计划。
|
|
170
|
+
* 运行时不认识信封;要用这份 helper 在代码里显式展开。
|
|
171
|
+
*/
|
|
172
|
+
export function expandPlanPathsOf(plan, site, options = {}) {
|
|
173
|
+
if (typeof plan !== 'object' || plan === null || !Array.isArray(plan.steps)) {
|
|
174
|
+
throw new Error('计划要是对象且带 steps');
|
|
175
|
+
}
|
|
176
|
+
if (typeof site !== 'object' || site === null)
|
|
177
|
+
throw new Error('站点要是对象');
|
|
178
|
+
const envelope = options.envelope === undefined ? site.envelope : options.envelope;
|
|
179
|
+
if (envelope === undefined || envelope === false)
|
|
180
|
+
return plan;
|
|
181
|
+
return { ...plan, steps: plan.steps.map((step) => expandedStepOf(step, envelope)) };
|
|
182
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface NpmRef {
|
|
2
|
+
readonly name: string;
|
|
3
|
+
readonly version?: string;
|
|
4
|
+
}
|
|
5
|
+
export declare function isPackageName(value: string): boolean;
|
|
6
|
+
export declare function splitNpmSpec(spec: string): NpmRef | undefined;
|
|
7
|
+
export declare function localDirOf(spec: string): string | undefined;
|
|
8
|
+
export declare function refusalReason(): string;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import path from 'node:path';
|
|
2
|
+
const PACKAGE_NAME = /^(?:@[a-z0-9][a-z0-9._~-]*\/)?[a-z0-9][a-z0-9._~-]*$/;
|
|
3
|
+
const VERSION = /^[a-zA-Z0-9][a-zA-Z0-9._+-]*$/;
|
|
4
|
+
export function isPackageName(value) {
|
|
5
|
+
return value.length <= 214 && PACKAGE_NAME.test(value);
|
|
6
|
+
}
|
|
7
|
+
export function splitNpmSpec(spec) {
|
|
8
|
+
const value = spec.trim();
|
|
9
|
+
const at = value.lastIndexOf('@');
|
|
10
|
+
const name = at > 0 ? value.slice(0, at) : value;
|
|
11
|
+
const version = at > 0 ? value.slice(at + 1) : '';
|
|
12
|
+
if (!isPackageName(name))
|
|
13
|
+
return undefined;
|
|
14
|
+
if (version !== '' && !VERSION.test(version))
|
|
15
|
+
return undefined;
|
|
16
|
+
return { name, ...(version === '' ? {} : { version }) };
|
|
17
|
+
}
|
|
18
|
+
export function localDirOf(spec) {
|
|
19
|
+
const dir = spec.trim().replace(/^(?:file|link):/, '');
|
|
20
|
+
return path.isAbsolute(dir) ? dir : undefined;
|
|
21
|
+
}
|
|
22
|
+
export function refusalReason() {
|
|
23
|
+
return '这个包既不是工作台的模块,也不是运行时的插件,装了也用不上';
|
|
24
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { PlanStep } from '../contract/data.js';
|
|
2
|
+
import type { LongTaskStep } from '../contract/long-task.js';
|
|
3
|
+
/**
|
|
4
|
+
* 长任务里逐步骤确认写计划的桥:`confirm` 发一条人工干预,`answer` 把用户回执翻成 yes / no。
|
|
5
|
+
*/
|
|
6
|
+
export interface SubmitPlanConfirmer {
|
|
7
|
+
confirm(step: PlanStep, index: number): Promise<boolean>;
|
|
8
|
+
answer(values: Readonly<Record<string, string>>): boolean;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* 建一个逐步骤确认桥。把 `emit` 接到长任务 `run({ onStep })`,把 `answer` 接到
|
|
12
|
+
* `longTasks.create({ answer })`;用户回执不是 `yes` 就返回 false,写计划会停在当前步。
|
|
13
|
+
* @param options `emit` 是长任务步骤出口;`signal` 停止时自动按 false 收口。
|
|
14
|
+
* @returns `confirm` / `answer` 两个回调。
|
|
15
|
+
*/
|
|
16
|
+
export declare function createSubmitPlanConfirmer(options: {
|
|
17
|
+
readonly emit: (step: LongTaskStep) => void;
|
|
18
|
+
readonly signal?: AbortSignal | undefined;
|
|
19
|
+
}): SubmitPlanConfirmer;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 建一个逐步骤确认桥。把 `emit` 接到长任务 `run({ onStep })`,把 `answer` 接到
|
|
3
|
+
* `longTasks.create({ answer })`;用户回执不是 `yes` 就返回 false,写计划会停在当前步。
|
|
4
|
+
* @param options `emit` 是长任务步骤出口;`signal` 停止时自动按 false 收口。
|
|
5
|
+
* @returns `confirm` / `answer` 两个回调。
|
|
6
|
+
*/
|
|
7
|
+
export function createSubmitPlanConfirmer(options) {
|
|
8
|
+
let pending;
|
|
9
|
+
const onAbort = () => {
|
|
10
|
+
finish(false);
|
|
11
|
+
};
|
|
12
|
+
const finish = (value) => {
|
|
13
|
+
const resolve = pending;
|
|
14
|
+
pending = undefined;
|
|
15
|
+
if (resolve === undefined)
|
|
16
|
+
return false;
|
|
17
|
+
options.signal?.removeEventListener('abort', onAbort);
|
|
18
|
+
resolve(value);
|
|
19
|
+
return true;
|
|
20
|
+
};
|
|
21
|
+
options.signal?.addEventListener('abort', onAbort, { once: true });
|
|
22
|
+
return {
|
|
23
|
+
confirm(step, index) {
|
|
24
|
+
if (options.signal?.aborted === true)
|
|
25
|
+
return Promise.resolve(false);
|
|
26
|
+
finish(false);
|
|
27
|
+
return new Promise((resolve) => {
|
|
28
|
+
pending = resolve;
|
|
29
|
+
options.emit({
|
|
30
|
+
kind: 'info',
|
|
31
|
+
text: `确认第 ${String(index + 1)} 步:${step.name}`,
|
|
32
|
+
intervention: {
|
|
33
|
+
title: `确认写入:${step.name}`,
|
|
34
|
+
hint: `第 ${String(index + 1)} 步;输入 yes 才写`,
|
|
35
|
+
fields: [{ key: 'confirm', label: '写这一步?输入 yes', placeholder: 'yes', required: true }],
|
|
36
|
+
submitLabel: '确认',
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
},
|
|
41
|
+
answer(values) {
|
|
42
|
+
return finish(String(values['confirm'] ?? '').trim().toLowerCase() === 'yes');
|
|
43
|
+
},
|
|
44
|
+
};
|
|
45
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { Need, SupplySource } from '../contract/needs.js';
|
|
2
|
+
export interface SupplyDeclaration {
|
|
3
|
+
readonly id: string;
|
|
4
|
+
readonly needs?: readonly Need[];
|
|
5
|
+
}
|
|
6
|
+
export interface SupplyIndexOptions {
|
|
7
|
+
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
8
|
+
readonly packagePrefix?: string | undefined;
|
|
9
|
+
}
|
|
10
|
+
export interface SupplyEntry {
|
|
11
|
+
readonly key: string;
|
|
12
|
+
readonly kind: 'extension' | 'lib';
|
|
13
|
+
readonly names: readonly string[];
|
|
14
|
+
readonly package: string;
|
|
15
|
+
readonly runtime?: string;
|
|
16
|
+
readonly sources: readonly SupplySource[];
|
|
17
|
+
readonly declarers: readonly string[];
|
|
18
|
+
readonly commands: readonly string[];
|
|
19
|
+
readonly conflicted: boolean;
|
|
20
|
+
}
|
|
21
|
+
export interface SupplyConflict {
|
|
22
|
+
readonly kind: 'source-mismatch' | 'name-mismatch';
|
|
23
|
+
readonly key: string;
|
|
24
|
+
readonly names: readonly string[];
|
|
25
|
+
readonly declarers: readonly string[];
|
|
26
|
+
readonly detail: string;
|
|
27
|
+
}
|
|
28
|
+
export interface SupplyIndex {
|
|
29
|
+
readonly entries: ReadonlyMap<string, SupplyEntry>;
|
|
30
|
+
readonly conflicts: readonly SupplyConflict[];
|
|
31
|
+
readonly problems: readonly string[];
|
|
32
|
+
readonly entryOf: (kind: 'extension' | 'lib', name: string) => SupplyEntry | undefined;
|
|
33
|
+
readonly sourcesOf: (kind: 'extension' | 'lib', name: string) => readonly SupplySource[];
|
|
34
|
+
}
|
|
35
|
+
export declare function npmSourceOf(sources: readonly SupplySource[] | undefined): Extract<SupplySource, {
|
|
36
|
+
kind: 'npm';
|
|
37
|
+
}> | undefined;
|
|
38
|
+
export declare function buildSupplyIndex(declarations: readonly SupplyDeclaration[], options?: SupplyIndexOptions): SupplyIndex;
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
import { npmRegistryOf } from './npm-registry.js';
|
|
2
|
+
export function npmSourceOf(sources) {
|
|
3
|
+
return sources?.find((source) => source.kind === 'npm');
|
|
4
|
+
}
|
|
5
|
+
function text(value) {
|
|
6
|
+
return value === undefined ? '' : value.trim();
|
|
7
|
+
}
|
|
8
|
+
function conventionPackage(name, prefix) {
|
|
9
|
+
return `${prefix}${name}`;
|
|
10
|
+
}
|
|
11
|
+
function nativeSourcePackage(source) {
|
|
12
|
+
if (source.kind === 'npm')
|
|
13
|
+
return text(source.package);
|
|
14
|
+
if (source.kind === 'git')
|
|
15
|
+
return `git:${text(source.url)}`;
|
|
16
|
+
return `local:${text(source.env) || text(source.path)}`;
|
|
17
|
+
}
|
|
18
|
+
function packageOf(need, prefix) {
|
|
19
|
+
if (need.kind === 'lib')
|
|
20
|
+
return text(need.name);
|
|
21
|
+
const first = need.sources?.[0];
|
|
22
|
+
if (first === undefined)
|
|
23
|
+
return conventionPackage(need.name, prefix);
|
|
24
|
+
if (first.kind === 'npm') {
|
|
25
|
+
const pkg = text(first.package);
|
|
26
|
+
return pkg === '' ? conventionPackage(need.name, prefix) : pkg;
|
|
27
|
+
}
|
|
28
|
+
return nativeSourcePackage(first);
|
|
29
|
+
}
|
|
30
|
+
function keyOf(kind, pkg) {
|
|
31
|
+
return `${kind}:${pkg}`;
|
|
32
|
+
}
|
|
33
|
+
function registryAddressOf(source, env) {
|
|
34
|
+
const resolved = npmRegistryOf(source, env);
|
|
35
|
+
return resolved.ok ? resolved.value : undefined;
|
|
36
|
+
}
|
|
37
|
+
function sourceCompatible(left, right, env) {
|
|
38
|
+
if (left.kind !== right.kind)
|
|
39
|
+
return false;
|
|
40
|
+
if (left.kind === 'npm' && right.kind === 'npm') {
|
|
41
|
+
if (text(left.package) !== '' && text(right.package) !== '' && text(left.package) !== text(right.package)) {
|
|
42
|
+
return false;
|
|
43
|
+
}
|
|
44
|
+
const l = registryAddressOf(left, env);
|
|
45
|
+
const r = registryAddressOf(right, env);
|
|
46
|
+
if (l !== undefined && r !== undefined)
|
|
47
|
+
return l === r;
|
|
48
|
+
return text(left.registryEnv) === text(right.registryEnv);
|
|
49
|
+
}
|
|
50
|
+
if (left.kind === 'git' && right.kind === 'git')
|
|
51
|
+
return text(left.url) === text(right.url);
|
|
52
|
+
if (left.kind === 'local' && right.kind === 'local') {
|
|
53
|
+
return text(left.env) === text(right.env) && text(left.path) === text(right.path);
|
|
54
|
+
}
|
|
55
|
+
return false;
|
|
56
|
+
}
|
|
57
|
+
function sourcesCompatible(left, right, env) {
|
|
58
|
+
if (left.length !== right.length)
|
|
59
|
+
return false;
|
|
60
|
+
return left.every((source, index) => {
|
|
61
|
+
const other = right[index];
|
|
62
|
+
return other !== undefined && sourceCompatible(source, other, env);
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
function mergedSource(left, right) {
|
|
66
|
+
if (left.kind === 'npm' && right.kind === 'npm') {
|
|
67
|
+
const pkg = text(left.package) === '' ? right.package : left.package;
|
|
68
|
+
const registryDefault = text(left.registryDefault) === '' ? right.registryDefault : left.registryDefault;
|
|
69
|
+
return {
|
|
70
|
+
...left,
|
|
71
|
+
...(pkg === undefined ? {} : { package: pkg }),
|
|
72
|
+
...(registryDefault === undefined ? {} : { registryDefault }),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
return left;
|
|
76
|
+
}
|
|
77
|
+
function mergeSources(entry, sources, env) {
|
|
78
|
+
if (!entry.declared) {
|
|
79
|
+
entry.declared = true;
|
|
80
|
+
entry.sources = [...sources];
|
|
81
|
+
return true;
|
|
82
|
+
}
|
|
83
|
+
if (!sourcesCompatible(entry.sources, sources, env)) {
|
|
84
|
+
entry.conflicted = true;
|
|
85
|
+
return false;
|
|
86
|
+
}
|
|
87
|
+
entry.sources = entry.sources.map((source, index) => {
|
|
88
|
+
const other = sources[index];
|
|
89
|
+
return other === undefined ? source : mergedSource(source, other);
|
|
90
|
+
});
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
function sourceText(source) {
|
|
94
|
+
if (source.kind === 'npm') {
|
|
95
|
+
return `${source.package === undefined ? '按包名约定' : source.package}(${source.registryEnv ?? '默认源'})`;
|
|
96
|
+
}
|
|
97
|
+
if (source.kind === 'git')
|
|
98
|
+
return `git:${source.url}`;
|
|
99
|
+
return `local:${source.env ?? source.path ?? ''}`;
|
|
100
|
+
}
|
|
101
|
+
function addDeclarer(entry, unit, commands) {
|
|
102
|
+
if (!entry.declarers.includes(unit))
|
|
103
|
+
entry.declarers.push(unit);
|
|
104
|
+
for (const command of commands)
|
|
105
|
+
if (!entry.commands.includes(command))
|
|
106
|
+
entry.commands.push(command);
|
|
107
|
+
}
|
|
108
|
+
export function buildSupplyIndex(declarations, options = {}) {
|
|
109
|
+
const env = options.env ?? {};
|
|
110
|
+
const prefix = options.packagePrefix ?? '';
|
|
111
|
+
const entries = new Map();
|
|
112
|
+
const byName = new Map();
|
|
113
|
+
const conflicts = [];
|
|
114
|
+
const ensure = (kind, pkg) => {
|
|
115
|
+
const key = keyOf(kind, pkg);
|
|
116
|
+
const found = entries.get(key);
|
|
117
|
+
if (found !== undefined)
|
|
118
|
+
return found;
|
|
119
|
+
const created = {
|
|
120
|
+
key,
|
|
121
|
+
kind,
|
|
122
|
+
package: pkg,
|
|
123
|
+
declared: false,
|
|
124
|
+
names: [],
|
|
125
|
+
sources: [],
|
|
126
|
+
declarers: [],
|
|
127
|
+
commands: [],
|
|
128
|
+
conflicted: false,
|
|
129
|
+
};
|
|
130
|
+
entries.set(key, created);
|
|
131
|
+
return created;
|
|
132
|
+
};
|
|
133
|
+
for (const declaration of declarations) {
|
|
134
|
+
for (const need of declaration.needs ?? []) {
|
|
135
|
+
if (need.kind !== 'extension' && need.kind !== 'lib')
|
|
136
|
+
continue;
|
|
137
|
+
const pkg = packageOf(need, prefix);
|
|
138
|
+
const entry = ensure(need.kind, pkg);
|
|
139
|
+
if (!entry.names.includes(need.name))
|
|
140
|
+
entry.names.push(need.name);
|
|
141
|
+
if (need.kind === 'extension') {
|
|
142
|
+
entry.runtime = need.runtime;
|
|
143
|
+
addDeclarer(entry, declaration.id, need.commands ?? []);
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
addDeclarer(entry, declaration.id, []);
|
|
147
|
+
}
|
|
148
|
+
const same = mergeSources(entry, need.sources ?? [], env);
|
|
149
|
+
if (!same) {
|
|
150
|
+
conflicts.push({
|
|
151
|
+
kind: 'source-mismatch',
|
|
152
|
+
key: entry.key,
|
|
153
|
+
names: [...entry.names],
|
|
154
|
+
declarers: [...entry.declarers],
|
|
155
|
+
detail: `${entry.kind === 'extension' ? '插件' : '共用库'} ${entry.names.join('、')} 被 ` +
|
|
156
|
+
`${entry.declarers.join('、')} 声明成了不同的来源(` +
|
|
157
|
+
`${entry.sources.map(sourceText).join(' / ') || '无来源'})`,
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
const nameKey = `${need.kind}:${need.name}`;
|
|
161
|
+
const seen = byName.get(nameKey);
|
|
162
|
+
if (seen !== undefined && seen.key !== entry.key) {
|
|
163
|
+
const detail = `${need.kind === 'extension' ? '插件' : '共用库'} ${need.name} 来自不同的包:` +
|
|
164
|
+
`${seen.package} / ${entry.package}`;
|
|
165
|
+
entry.conflicted = true;
|
|
166
|
+
seen.conflicted = true;
|
|
167
|
+
conflicts.push({
|
|
168
|
+
kind: 'name-mismatch',
|
|
169
|
+
key: entry.key,
|
|
170
|
+
names: [need.name],
|
|
171
|
+
declarers: [...new Set([...seen.declarers, ...entry.declarers])],
|
|
172
|
+
detail,
|
|
173
|
+
});
|
|
174
|
+
}
|
|
175
|
+
else if (seen === undefined) {
|
|
176
|
+
byName.set(nameKey, entry);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
const deduped = new Map();
|
|
181
|
+
for (const conflict of conflicts) {
|
|
182
|
+
deduped.set(`${conflict.kind}:${conflict.key}`, conflict);
|
|
183
|
+
}
|
|
184
|
+
const frozenEntries = new Map();
|
|
185
|
+
for (const [key, entry] of entries) {
|
|
186
|
+
frozenEntries.set(key, {
|
|
187
|
+
key: entry.key,
|
|
188
|
+
kind: entry.kind,
|
|
189
|
+
names: [...entry.names],
|
|
190
|
+
package: entry.package,
|
|
191
|
+
...(entry.runtime === undefined ? {} : { runtime: entry.runtime }),
|
|
192
|
+
sources: entry.sources.map((source) => ({ ...source })),
|
|
193
|
+
declarers: [...entry.declarers],
|
|
194
|
+
commands: [...entry.commands],
|
|
195
|
+
conflicted: entry.conflicted,
|
|
196
|
+
});
|
|
197
|
+
}
|
|
198
|
+
const entryOf = (kind, name) => byName.get(`${kind}:${name}`);
|
|
199
|
+
return {
|
|
200
|
+
entries: frozenEntries,
|
|
201
|
+
conflicts: [...deduped.values()],
|
|
202
|
+
problems: [...deduped.values()].map((conflict) => conflict.detail),
|
|
203
|
+
entryOf,
|
|
204
|
+
sourcesOf: (kind, name) => {
|
|
205
|
+
const entry = entryOf(kind, name);
|
|
206
|
+
return entry === undefined || entry.conflicted ? [] : entry.sources;
|
|
207
|
+
},
|
|
208
|
+
};
|
|
209
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { DshHostContext } from '../api/dsh.js';
|
|
2
|
+
import type { SupplyPort } from './port-types.js';
|
|
3
|
+
export type { SupplyPort } from './port-types.js';
|
|
4
|
+
export declare function supplyPortOf(ctx: DshHostContext): SupplyPort;
|
|
5
|
+
export declare function requireSupply(): SupplyPort;
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { adaptersOf } from './adapters.js';
|
|
2
|
+
export function supplyPortOf(ctx) {
|
|
3
|
+
const set = adaptersOf(ctx);
|
|
4
|
+
const env = set.supply;
|
|
5
|
+
const modules = set.modules;
|
|
6
|
+
const pluginPackagePrefix = modules.pluginPackagePrefix;
|
|
7
|
+
const pluginManifestFile = modules.pluginManifestFile;
|
|
8
|
+
const cliCatalogPath = modules.cliCatalogPath;
|
|
9
|
+
const vendorPluginsDir = modules.vendorPluginsDir;
|
|
10
|
+
const runtimeInstallCommand = modules.runtimeInstallCommand;
|
|
11
|
+
return {
|
|
12
|
+
env,
|
|
13
|
+
modules,
|
|
14
|
+
resolvePluginSource: (source, environment, options) => env.resolvePluginSource(source, environment, options),
|
|
15
|
+
libInstallCommand: (options) => env.libInstallCommand(options),
|
|
16
|
+
libUninstallCommand: (options) => env.libUninstallCommand(options),
|
|
17
|
+
pluginInstallPlan: (options) => env.pluginInstallPlan(options),
|
|
18
|
+
recoveryCommand: (options) => env.recoveryCommand(options),
|
|
19
|
+
latestVersion: (options) => env.latestVersion(options),
|
|
20
|
+
missingReleaseParts: (options) => env.missingReleaseParts(options),
|
|
21
|
+
probeRelease: (options) => env.probeRelease(options),
|
|
22
|
+
splitNpmSpec: (spec) => env.splitNpmSpec(spec),
|
|
23
|
+
isolatedRoot: () => modules.isolatedRoot(),
|
|
24
|
+
isolatedHome: () => modules.isolatedHome(),
|
|
25
|
+
...(pluginPackagePrefix === undefined ? {} : { pluginPackagePrefix: () => pluginPackagePrefix() }),
|
|
26
|
+
...(pluginManifestFile === undefined ? {} : { pluginManifestFile: () => pluginManifestFile() }),
|
|
27
|
+
...(cliCatalogPath === undefined ? {} : { cliCatalogPath: () => cliCatalogPath() }),
|
|
28
|
+
...(vendorPluginsDir === undefined ? {} : { vendorPluginsDir: () => vendorPluginsDir() }),
|
|
29
|
+
...(runtimeInstallCommand === undefined ? {} : { runtimeInstallCommand: () => runtimeInstallCommand() }),
|
|
30
|
+
afterLibInstall: () => modules.afterLibInstall(),
|
|
31
|
+
profileDirOf: (context) => modules.profileDirOf(context),
|
|
32
|
+
profileModules: (dir) => modules.profileModules(dir),
|
|
33
|
+
readInstalledModule: (dir, pkg) => modules.readInstalledModule(dir, pkg),
|
|
34
|
+
readProfilePackage: (dir, pkg) => modules.readProfilePackage(dir, pkg),
|
|
35
|
+
readBundleManager: (context) => modules.readBundleManager(context),
|
|
36
|
+
createRegistryNotebook: (dir) => modules.createRegistryNotebook(dir),
|
|
37
|
+
declarationGaps: (dir) => modules.declarationGaps(dir),
|
|
38
|
+
moduleDeclarationOf: (dir, pkg) => modules.moduleDeclarationOf(dir, pkg),
|
|
39
|
+
registryDeclarationOf: (options) => modules.registryDeclarationOf(options),
|
|
40
|
+
pathDeclarationOf: (spec) => modules.pathDeclarationOf(spec),
|
|
41
|
+
declarationRefusalOf: (name, raw) => modules.declarationRefusalOf(name, raw),
|
|
42
|
+
refusalReason: () => modules.refusalReason(),
|
|
43
|
+
packageRouteOf: (options) => modules.packageRouteOf(options),
|
|
44
|
+
isNewerVersion: (left, right) => modules.isNewerVersion(left, right),
|
|
45
|
+
startSelfUpdate: (request, onError) => modules.startSelfUpdate(request, onError),
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
export function requireSupply() {
|
|
49
|
+
throw new Error('workbenchSupply 未提供');
|
|
50
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UTC 时钟(`HH:mm:ss`):日志与状态行只给人看时分秒,不带日期。
|
|
3
|
+
* @param value ISO 字符串、时间戳或 Date。
|
|
4
|
+
* @returns `HH:mm:ss`;非法时间返回 `Invalid Date`。
|
|
5
|
+
*/
|
|
6
|
+
export declare function clockOf(value: string | number | Date): string;
|
|
7
|
+
/**
|
|
8
|
+
* 把时间戳/ISO 字符串转成毫秒;非法输入给 `NaN`(调用方据此回退)。
|
|
9
|
+
* @param value ISO 字符串、时间戳或 Date。
|
|
10
|
+
* @returns 毫秒时间戳或 `NaN`。
|
|
11
|
+
*/
|
|
12
|
+
export declare function epochOf(value: string | number | Date): number;
|
|
13
|
+
/**
|
|
14
|
+
* 当前时间(毫秒)。宿主里要「现在几点」只走这里,测试可以点住 `Date.now`。
|
|
15
|
+
* @returns 毫秒时间戳。
|
|
16
|
+
*/
|
|
17
|
+
export declare function now(): number;
|
|
18
|
+
/**
|
|
19
|
+
* 当前时间的 ISO 字符串。
|
|
20
|
+
* @returns `new Date().toISOString()` 的等价物。
|
|
21
|
+
*/
|
|
22
|
+
export declare function nowIso(): string;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
2
|
+
import utc from 'dayjs/plugin/utc.js';
|
|
3
|
+
dayjs.extend(utc);
|
|
4
|
+
/**
|
|
5
|
+
* UTC 时钟(`HH:mm:ss`):日志与状态行只给人看时分秒,不带日期。
|
|
6
|
+
* @param value ISO 字符串、时间戳或 Date。
|
|
7
|
+
* @returns `HH:mm:ss`;非法时间返回 `Invalid Date`。
|
|
8
|
+
*/
|
|
9
|
+
export function clockOf(value) {
|
|
10
|
+
return dayjs(value).utc().format('HH:mm:ss');
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* 把时间戳/ISO 字符串转成毫秒;非法输入给 `NaN`(调用方据此回退)。
|
|
14
|
+
* @param value ISO 字符串、时间戳或 Date。
|
|
15
|
+
* @returns 毫秒时间戳或 `NaN`。
|
|
16
|
+
*/
|
|
17
|
+
export function epochOf(value) {
|
|
18
|
+
return dayjs(value).valueOf();
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 当前时间(毫秒)。宿主里要「现在几点」只走这里,测试可以点住 `Date.now`。
|
|
22
|
+
* @returns 毫秒时间戳。
|
|
23
|
+
*/
|
|
24
|
+
export function now() {
|
|
25
|
+
return Date.now();
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* 当前时间的 ISO 字符串。
|
|
29
|
+
* @returns `new Date().toISOString()` 的等价物。
|
|
30
|
+
*/
|
|
31
|
+
export function nowIso() {
|
|
32
|
+
return new Date(now()).toISOString();
|
|
33
|
+
}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export declare const DSH_THEME_PACKAGE = "@deepseek-ai/dsh-client-ui-theme";
|
|
2
|
+
export declare const SHELL_PACKAGE = "@dsh-workbench/core";
|
|
3
|
+
export declare const DSW_PREFIX = "--dsw-";
|
|
4
|
+
export declare const WB_PREFIX = "--wb-";
|
|
5
|
+
export interface TokenValues {
|
|
6
|
+
readonly light: string | null;
|
|
7
|
+
readonly dark: string | null;
|
|
8
|
+
}
|
|
9
|
+
export interface TokenEntry {
|
|
10
|
+
readonly name: string;
|
|
11
|
+
readonly values: TokenValues;
|
|
12
|
+
}
|
|
13
|
+
export interface TokenSource {
|
|
14
|
+
readonly package: string;
|
|
15
|
+
readonly version: string | null;
|
|
16
|
+
readonly file: string;
|
|
17
|
+
readonly entries: readonly TokenEntry[];
|
|
18
|
+
}
|
|
19
|
+
export interface TokenSet {
|
|
20
|
+
readonly dsw: TokenSource | null;
|
|
21
|
+
readonly wb: TokenSource | null;
|
|
22
|
+
}
|
|
23
|
+
export declare function tokenEntriesIn(text: string, prefix: string): readonly TokenEntry[];
|
|
24
|
+
export declare function readTokens(startDirs: readonly string[]): TokenSet;
|
|
25
|
+
export declare function nearestTokens(name: string, names: readonly string[], limit?: number): readonly string[];
|
|
26
|
+
export declare function tokenFamilyOf(name: string): string;
|