@dsh-workbench/shared 0.1.2 → 0.1.3

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.
Files changed (95) hide show
  1. package/dist/api/workbench-contract.d.ts +1 -1
  2. package/dist/components/ApprovalDetail.css +4 -0
  3. package/dist/components/ApprovalDetail.d.ts +1 -0
  4. package/dist/components/ApprovalDetail.js +5 -1
  5. package/dist/components/CardHead.css +92 -0
  6. package/dist/components/CardHead.d.ts +1 -0
  7. package/dist/components/CardHead.js +9 -7
  8. package/dist/components/ChoiceGroup.css +75 -0
  9. package/dist/components/ChoiceGroup.d.ts +1 -0
  10. package/dist/components/ChoiceGroup.js +1 -0
  11. package/dist/components/LongTaskRow.css +53 -0
  12. package/dist/components/LongTaskRow.d.ts +3 -0
  13. package/dist/components/LongTaskRow.js +11 -11
  14. package/dist/components/MockStrip.css +39 -0
  15. package/dist/components/MockStrip.d.ts +1 -0
  16. package/dist/components/MockStrip.js +1 -0
  17. package/dist/components/ResourceStates.css +111 -0
  18. package/dist/components/ResourceStates.d.ts +2 -1
  19. package/dist/components/ResourceStates.js +1 -0
  20. package/dist/components/SaveBar.css +7 -0
  21. package/dist/components/SaveBar.d.ts +1 -0
  22. package/dist/components/SaveBar.js +4 -2
  23. package/dist/components/TextField.css +22 -0
  24. package/dist/components/TextField.d.ts +6 -0
  25. package/dist/components/TextField.js +5 -0
  26. package/dist/components/icons.d.ts +0 -12
  27. package/dist/components/icons.js +0 -61
  28. package/dist/host/http.js +5 -29
  29. package/dist/host/provision.d.ts +18 -1
  30. package/dist/host/provision.js +73 -0
  31. package/dist/host.d.ts +6 -0
  32. package/dist/host.js +6 -0
  33. package/dist/i18n/en.js +126 -1
  34. package/dist/i18n/index.d.ts +129 -4
  35. package/dist/i18n/zh.d.ts +128 -3
  36. package/dist/i18n/zh.js +128 -3
  37. package/dist/index.d.ts +1 -1
  38. package/dist/index.js +1 -1
  39. package/package.json +5 -3
  40. package/src/api/workbench-contract.ts +5 -1
  41. package/src/components/ApprovalDetail.css +4 -0
  42. package/src/components/ApprovalDetail.tsx +11 -1
  43. package/src/components/CardHead.css +92 -0
  44. package/src/components/CardHead.tsx +43 -31
  45. package/src/components/ChoiceGroup.css +75 -0
  46. package/src/components/ChoiceGroup.tsx +1 -0
  47. package/src/components/LongTaskRow.css +53 -0
  48. package/src/components/LongTaskRow.tsx +52 -13
  49. package/src/components/MockStrip.css +39 -0
  50. package/src/components/MockStrip.tsx +1 -0
  51. package/src/components/ResourceStates.css +111 -0
  52. package/src/components/ResourceStates.tsx +2 -1
  53. package/src/components/SaveBar.css +7 -0
  54. package/src/components/SaveBar.tsx +8 -5
  55. package/src/components/TextField.css +22 -0
  56. package/src/components/TextField.tsx +17 -0
  57. package/src/components/icons.tsx +0 -164
  58. package/src/host/__tests__/provision.test.ts +90 -0
  59. package/src/host/http.ts +5 -33
  60. package/src/host/provision.ts +87 -0
  61. package/src/host.ts +6 -0
  62. package/src/i18n/en.ts +127 -1
  63. package/src/i18n/zh.ts +128 -4
  64. package/src/index.ts +1 -1
  65. package/dist/components/StateDot.d.ts +0 -5
  66. package/dist/components/StateDot.js +0 -10
  67. package/dist/host/__tests__/fakes.d.ts +0 -41
  68. package/dist/host/__tests__/fakes.js +0 -76
  69. package/dist/host/__tests__/preflight-fixtures.d.ts +0 -19
  70. package/dist/host/__tests__/preflight-fixtures.js +0 -47
  71. package/dist/host/context-inject.d.ts +0 -24
  72. package/dist/host/context-inject.js +0 -74
  73. package/dist/host/events.d.ts +0 -9
  74. package/dist/host/events.js +0 -70
  75. package/dist/host/mount-units.d.ts +0 -52
  76. package/dist/host/mount-units.js +0 -186
  77. package/dist/host/preflight.d.ts +0 -58
  78. package/dist/host/preflight.js +0 -233
  79. package/dist/host/probe-cache.d.ts +0 -6
  80. package/dist/host/probe-cache.js +0 -19
  81. package/dist/host/probe-libs.d.ts +0 -45
  82. package/dist/host/probe-libs.js +0 -61
  83. package/dist/host/probe-units.d.ts +0 -17
  84. package/dist/host/probe-units.js +0 -102
  85. package/dist/host/probe-verdict.d.ts +0 -7
  86. package/dist/host/probe-verdict.js +0 -143
  87. package/dist/host/tool-scope.d.ts +0 -32
  88. package/dist/host/tool-scope.js +0 -84
  89. package/dist/host/unit-readiness.d.ts +0 -7
  90. package/dist/host/unit-readiness.js +0 -5
  91. package/dist/host/unit-registry.d.ts +0 -9
  92. package/dist/host/unit-registry.js +0 -33
  93. package/dist/host/version-range.d.ts +0 -2
  94. package/dist/host/version-range.js +0 -73
  95. package/src/components/StateDot.tsx +0 -31
@@ -0,0 +1,90 @@
1
+ import { describe, expect, it } from 'vitest';
2
+ import { PROVISION_ACTIONS, parseProvisionBody, provisionTargetOf } from '../provision.js';
3
+
4
+ describe('provision 请求体:每类动作各有各的目标字段', () => {
5
+ it('每个声明过的动作都分得出去一个目标字段(加动作忘了配就会红)', () => {
6
+ expect(PROVISION_ACTIONS.map((action) => [action, provisionTargetOf(action)])).toEqual([
7
+ ['install', 'unit'],
8
+ ['update', 'unit'],
9
+ ['uninstall', 'unit'],
10
+ ['install-bundle', 'spec'],
11
+ ['update-bundle', 'unit'],
12
+ ['remove-bundle', 'name'],
13
+ ['cancel-install', 'requestId'],
14
+ ['update-dependency', 'id'],
15
+ ]);
16
+ });
17
+
18
+ it('老三种动作照旧只认 unit / id,请求里不多带字段', () => {
19
+ expect(parseProvisionBody({ action: 'install', unit: ' issues ' })).toEqual({
20
+ ok: true,
21
+ request: { action: 'install', unit: 'issues' },
22
+ });
23
+ expect(parseProvisionBody({ action: 'update-dependency', id: 'plugin:coding' })).toEqual({
24
+ ok: true,
25
+ request: { action: 'update-dependency', id: 'plugin:coding' },
26
+ });
27
+ });
28
+
29
+ it('install-bundle:spec 必填,registry / approvedBuilds 可选且会清空串', () => {
30
+ expect(parseProvisionBody({ action: 'install-bundle', spec: '@a/b@1.2.3' })).toEqual({
31
+ ok: true,
32
+ request: { action: 'install-bundle', spec: '@a/b@1.2.3' },
33
+ });
34
+ expect(
35
+ parseProvisionBody({
36
+ action: 'install-bundle',
37
+ spec: '@a/b',
38
+ registry: ' https://r.example/ ',
39
+ approvedBuilds: ['esbuild', '', 7, 'sharp'],
40
+ }),
41
+ ).toEqual({
42
+ ok: true,
43
+ request: { action: 'install-bundle', spec: '@a/b', registry: 'https://r.example/', approvedBuilds: ['esbuild', 'sharp'] },
44
+ });
45
+ });
46
+
47
+ it('remove-bundle / cancel-install 各认各的字段', () => {
48
+ expect(parseProvisionBody({ action: 'remove-bundle', name: '@a/b' })).toEqual({
49
+ ok: true,
50
+ request: { action: 'remove-bundle', name: '@a/b' },
51
+ });
52
+ expect(parseProvisionBody({ action: 'cancel-install', requestId: 'req-1' })).toEqual({
53
+ ok: true,
54
+ request: { action: 'cancel-install', requestId: 'req-1' },
55
+ });
56
+ });
57
+
58
+ it('拿错字段不算数(spec 动作给了 unit 也要打回)', () => {
59
+ expect(parseProvisionBody({ action: 'install-bundle', unit: 'issues' })).toEqual({
60
+ ok: false,
61
+ code: 'workbench/no-spec',
62
+ message: '缺少 spec',
63
+ });
64
+ expect(parseProvisionBody({ action: 'install', spec: 'x' })).toEqual({
65
+ ok: false,
66
+ code: 'workbench/no-unit',
67
+ message: '缺少 unit',
68
+ });
69
+ expect(parseProvisionBody({ action: 'remove-bundle', name: ' ' })).toEqual({
70
+ ok: false,
71
+ code: 'workbench/no-name',
72
+ message: '缺少 name',
73
+ });
74
+ expect(parseProvisionBody({ action: 'cancel-install' })).toEqual({
75
+ ok: false,
76
+ code: 'workbench/no-request-id',
77
+ message: '缺少 requestId',
78
+ });
79
+ });
80
+
81
+ it('不认识的 action / 不是对象 / 空体 → 都是 bad-action', () => {
82
+ for (const body of [{ action: 'destroy' }, {}, null, 'nonsense', undefined]) {
83
+ const parsed = parseProvisionBody(body);
84
+ expect(parsed.ok).toBe(false);
85
+ if (!parsed.ok) expect(parsed.code).toBe('workbench/bad-action');
86
+ }
87
+ const parsed = parseProvisionBody({ action: 'destroy' });
88
+ if (!parsed.ok) expect(parsed.message).toContain('不认识的 action:destroy');
89
+ });
90
+ });
package/src/host/http.ts CHANGED
@@ -2,9 +2,7 @@ import type { DshHostContext, DshRequest, DshResponse } from '../api/dsh.js';
2
2
  import { unitFactScope } from '../api/facts.js';
3
3
  import { ACTIONS_PREFIX, API_PREFIX, PLUGIN_ID, PREFS_PREFIX, PROVISION_PREFIX } from '../config/constants.js';
4
4
  import {
5
- isDependencyAction,
6
- PROVISION_ACTIONS,
7
- type ProvisionAction,
5
+ parseProvisionBody,
8
6
  type ProvisionHandler,
9
7
  type ProvisionRequest,
10
8
  } from './provision.js';
@@ -118,38 +116,12 @@ export function registerProvision(
118
116
  return;
119
117
  }
120
118
 
121
- const body =
122
- typeof payload === 'object' && payload !== null
123
- ? (payload as { action?: unknown; unit?: unknown; id?: unknown })
124
- : {};
125
- const action = body.action;
126
- if (typeof action !== 'string' || !PROVISION_ACTIONS.includes(action as ProvisionAction)) {
127
- sendJson(res, 400, {
128
- ok: false,
129
- error: {
130
- code: 'workbench/bad-action',
131
- message: `不认识的 action:${String(action)}(可用:${PROVISION_ACTIONS.join(' / ')})`,
132
- },
133
- });
119
+ const parsed = parseProvisionBody(payload);
120
+ if (!parsed.ok) {
121
+ sendJson(res, 400, { ok: false, error: { code: parsed.code, message: parsed.message } });
134
122
  return;
135
123
  }
136
- const wanted = action as ProvisionAction;
137
- const target = isDependencyAction(wanted) ? body.id : body.unit;
138
- if (typeof target !== 'string' || target.trim() === '') {
139
- sendJson(res, 400, {
140
- ok: false,
141
- error: {
142
- code: isDependencyAction(wanted) ? 'workbench/no-id' : 'workbench/no-unit',
143
- message: isDependencyAction(wanted) ? '缺少 id' : '缺少 unit',
144
- },
145
- });
146
- return;
147
- }
148
-
149
- const key = target.trim();
150
- const request: ProvisionRequest = isDependencyAction(wanted)
151
- ? { action: wanted, id: key }
152
- : { action: wanted, unit: key };
124
+ const request: ProvisionRequest = parsed.request;
153
125
  try {
154
126
  const result = await provision.handle(request);
155
127
  log?.bump(provisionFacts(provision, request));
@@ -6,6 +6,10 @@ export const PROVISION_ACTIONS = [
6
6
  'install',
7
7
  'update',
8
8
  'uninstall',
9
+ 'install-bundle',
10
+ 'update-bundle',
11
+ 'remove-bundle',
12
+ 'cancel-install',
9
13
  'update-dependency',
10
14
  ] as const satisfies readonly ProvisionAction[];
11
15
 
@@ -22,13 +26,96 @@ type MissingAction = Exclude<ProvisionAction, (typeof PROVISION_ACTIONS)[number]
22
26
  const ALL_ACTIONS_COVERED: MissingAction extends never ? true : never = true;
23
27
  void ALL_ACTIONS_COVERED;
24
28
 
29
+ export type ProvisionTarget = 'unit' | 'id' | 'spec' | 'name' | 'requestId';
30
+
31
+ export function provisionTargetOf(action: ProvisionAction): ProvisionTarget {
32
+ if (action === 'update-dependency') return 'id';
33
+ if (action === 'install-bundle') return 'spec';
34
+ if (action === 'remove-bundle') return 'name';
35
+ if (action === 'cancel-install') return 'requestId';
36
+ return 'unit';
37
+ }
38
+
25
39
  export interface ProvisionRequest {
26
40
  readonly action: ProvisionAction;
27
41
  readonly unit?: string;
28
42
  readonly id?: string;
43
+ readonly spec?: string;
44
+ readonly name?: string;
45
+ readonly requestId?: string;
46
+ readonly registry?: string;
47
+ readonly approvedBuilds?: readonly string[];
29
48
  }
30
49
 
31
50
  export interface ProvisionHandler {
32
51
  handle(request: ProvisionRequest): Promise<unknown> | unknown;
33
52
  affectedUnits?(request: ProvisionRequest): readonly string[];
34
53
  }
54
+
55
+ const TARGET_CODE: Readonly<Record<ProvisionTarget, string>> = {
56
+ unit: 'workbench/no-unit',
57
+ id: 'workbench/no-id',
58
+ spec: 'workbench/no-spec',
59
+ name: 'workbench/no-name',
60
+ requestId: 'workbench/no-request-id',
61
+ };
62
+
63
+ function asRecord(value: unknown): Readonly<Record<string, unknown>> {
64
+ return typeof value === 'object' && value !== null ? (value as Readonly<Record<string, unknown>>) : {};
65
+ }
66
+
67
+ function stringsOf(value: unknown): string[] | undefined {
68
+ if (!Array.isArray(value)) return undefined;
69
+ const items = value.filter((item): item is string => typeof item === 'string' && item.trim() !== '');
70
+ return items.length === 0 ? undefined : items;
71
+ }
72
+
73
+ function requestOf(action: ProvisionAction, value: string): ProvisionRequest {
74
+ if (action === 'update-dependency') return { action, id: value };
75
+ if (action === 'install-bundle') return { action, spec: value };
76
+ if (action === 'remove-bundle') return { action, name: value };
77
+ if (action === 'cancel-install') return { action, requestId: value };
78
+ return { action, unit: value };
79
+ }
80
+
81
+ export interface ProvisionRejected {
82
+ readonly ok: false;
83
+ readonly code: string;
84
+ readonly message: string;
85
+ }
86
+
87
+ export type ProvisionParsed =
88
+ | { readonly ok: true; readonly request: ProvisionRequest }
89
+ | ProvisionRejected;
90
+
91
+ export function parseProvisionBody(body: unknown): ProvisionParsed {
92
+ const raw = asRecord(body);
93
+ const action = raw.action;
94
+ if (typeof action !== 'string' || !(PROVISION_ACTIONS as readonly string[]).includes(action)) {
95
+ return {
96
+ ok: false,
97
+ code: 'workbench/bad-action',
98
+ message: `不认识的 action:${String(action)}(可用:${PROVISION_ACTIONS.join(' / ')})`,
99
+ };
100
+ }
101
+ const wanted = action as ProvisionAction;
102
+ const target = provisionTargetOf(wanted);
103
+ const value = raw[target];
104
+ if (typeof value !== 'string' || value.trim() === '') {
105
+ return { ok: false, code: TARGET_CODE[target], message: `缺少 ${target}` };
106
+ }
107
+ if (wanted !== 'install-bundle') return { ok: true, request: requestOf(wanted, value.trim()) };
108
+
109
+ const registry = typeof raw.registry === 'string' && raw.registry.trim() !== '' ? raw.registry.trim() : undefined;
110
+ const approvedBuilds = stringsOf(raw.approvedBuilds);
111
+ const requestId = typeof raw.requestId === 'string' && raw.requestId.trim() !== '' ? raw.requestId.trim() : undefined;
112
+ return {
113
+ ok: true,
114
+ request: {
115
+ ...requestOf(wanted, value.trim()),
116
+ ...(registry === undefined ? {} : { registry }),
117
+ ...(approvedBuilds === undefined ? {} : { approvedBuilds }),
118
+ ...(requestId === undefined ? {} : { requestId }),
119
+ },
120
+ };
121
+ }
package/src/host.ts CHANGED
@@ -1,3 +1,9 @@
1
+ export * from './config/constants.js';
2
+ export * from './api/context-ref.js';
3
+ export * from './api/unit.js';
4
+ export * from './api/facts.js';
5
+ export * from './api/long-task.js';
6
+ export * from './lib/text.js';
1
7
  export * from './host/cli-error.js';
2
8
  export * from './host/data-root.js';
3
9
  export * from './host/facts.js';
package/src/i18n/en.ts CHANGED
@@ -68,12 +68,15 @@ export const en: Record<keyof WorkbenchMessages, string> = {
68
68
  'panels.market.install': 'Install',
69
69
  'panels.market.update': 'Update',
70
70
  'panels.market.uninstall': 'Uninstall',
71
+ 'panels.market.uninstallLabel': 'Uninstall {name}',
71
72
  'panels.market.installing': 'Installing…',
72
73
  'panels.market.updating': 'Updating…',
73
74
  'panels.market.uninstalling': 'Uninstalling…',
74
- 'panels.market.confirmUninstall': 'Uninstall?',
75
+ 'panels.market.confirmUninstallTitle': 'Uninstall "{name}"?',
75
76
  'panels.market.confirmUninstallDetail':
76
77
  'It will be gone from this machine, and removed from every project panel (bindings and settings are kept).',
78
+ 'panels.market.confirmUninstallAck':
79
+ 'I understand: using it again means reinstalling it.',
77
80
  'panels.market.confirmYes': 'Uninstall',
78
81
  'panels.market.confirmNo': 'Cancel',
79
82
  'panels.market.failed': 'Failed: {reason}',
@@ -81,6 +84,9 @@ export const en: Record<keyof WorkbenchMessages, string> = {
81
84
  'panels.market.noSource': 'This module declares no install method — install it yourself',
82
85
  'panels.market.badSource': 'The install method is incomplete — install it yourself',
83
86
  'panels.market.empty': 'No modules available',
87
+ 'panels.market.installedSection': 'Installed',
88
+ 'panels.market.moduleUpdate': 'Version {version} is out: it may need a restart after installing.',
89
+ 'panels.market.restartNeeded': 'The new version is installed — restart once to pick it up.',
84
90
  'panels.market.foot': 'After installing, enable it in the panel page of that project.',
85
91
  'panels.market.recheck': 'Check for updates',
86
92
  'panels.market.checkUpdates': 'Check for updates',
@@ -88,6 +94,126 @@ export const en: Record<keyof WorkbenchMessages, string> = {
88
94
  'panels.market.justNow': 'just now',
89
95
  'panels.market.minutesAgo': '{n} min ago',
90
96
  'panels.market.hoursAgo': '{n} h ago',
97
+ 'panels.market.add.description': 'Enter a package name, a Git URL, or a path to a local directory.',
98
+ 'panels.market.add.specPlaceholder': 'e.g. @dsh-workbench/module-hello',
99
+ 'panels.market.add.guideToggle': 'Install guide and examples',
100
+ 'panels.market.add.guideHide': 'Hide guide',
101
+ 'panels.market.add.guideIdTitle': 'Package name',
102
+ 'panels.market.add.guideIdExample': '@dsh-workbench/module-hello',
103
+ 'panels.market.add.guideIdHint': 'The module package name is its npm name (like dsh-workbench-module-xxx or @author/module) — whatever follows dsh plugin add or pnpm add in the README of a community module.',
104
+ 'panels.market.add.guideGitTitle': 'Git URL',
105
+ 'panels.market.add.guideGitExample': 'https://github.com/author/dsh-workbench-module-x',
106
+ 'panels.market.add.guideGitHint': 'The public repository of the module on GitHub; other Git hosts work too.',
107
+ 'panels.market.add.guidePathTitle': 'Local module directory',
108
+ 'panels.market.add.guidePathExample': '/Users/name/my-workbench-module',
109
+ 'panels.market.add.guidePathHint': 'Absolute path to the module directory on this machine, for modules you develop or have already downloaded.',
110
+ 'panels.market.add.guideExampleLabel': 'Example:',
111
+ 'panels.market.add.guideFill': 'Fill in',
112
+ 'panels.market.add.guideSafety': 'Make sure you trust the source. Modules run on this machine with your permissions; an unknown module can damage the workbench or read and leak your data.',
113
+ 'panels.market.add.registryLegend': 'Which npm registry to download from',
114
+ 'panels.market.add.registryOfficial': 'npm registry',
115
+ 'panels.market.add.registryMirror': 'China mirror',
116
+ 'panels.market.add.registryWithHost': '{name} ({host})',
117
+ 'panels.market.add.registryToggle': 'Source',
118
+ 'panels.market.add.installVersion': 'Version {version}',
119
+ 'panels.market.add.registryDefault': 'Default source',
120
+ 'panels.market.add.registryCustom': 'Custom address',
121
+ 'panels.market.add.registryCustomPlaceholder': 'https://npm.example.com/',
122
+ 'panels.market.add.registryCustomHint': 'A corporate or private npm registry; for one that needs auth, put the credentials in ~/.npmrc on this machine',
123
+ 'panels.market.add.registryCustomInvalid': 'Enter an address starting with http:// or https://',
124
+ 'panels.market.add.run': 'Install',
125
+ 'panels.market.add.edit': 'Edit',
126
+ 'panels.market.add.changeRegistry': 'Change source',
127
+ 'panels.market.add.installingTitle': 'Installing the module…',
128
+ 'panels.market.add.installedTitle': 'Installed',
129
+ 'panels.market.add.failedTitle': 'Module install failed',
130
+ 'panels.market.add.cancelledTitle': 'Cancelled',
131
+ 'panels.market.add.failureNetworkHost': 'Cannot reach {host}. Git URLs and .tgz links bypass the registry, so this machine needs direct access or a proxy; if the module is also on npm, use its package name instead.',
132
+ 'panels.market.add.problemInvalid': 'Cannot read this package name or address: {reason}',
133
+ 'panels.market.add.problemInstalled': 'This module is already installed',
134
+ 'panels.market.add.problemNotFound': 'No such module found',
135
+ 'panels.market.add.problemNotPackage': 'That path does not exist or is not a valid module package',
136
+ 'panels.market.add.problemNotBundle': 'This package declares no bundle, so it cannot be installed as a module: {reason}',
137
+ 'panels.market.add.problemNetwork': 'Cannot reach the module source; check the network and retry',
138
+ 'panels.market.add.problemUnknown': 'Cannot fetch module information: {reason}',
139
+ 'panels.market.add.failureNetwork': 'The network connection failed',
140
+ 'panels.market.add.failureNotFound': 'No such module found',
141
+ 'panels.market.add.failureNoMatchingVersion': 'No matching version',
142
+ 'panels.market.add.failureDiskFull': 'Out of disk space, install stopped',
143
+ 'panels.market.add.failurePermission': 'No write permission, cannot install',
144
+ 'panels.market.add.failureBuildBlocked': 'A dependency wants to run install scripts; you have to allow it first',
145
+ 'panels.market.add.failureIntegrity': 'The downloaded package failed its integrity check',
146
+ 'panels.market.add.failureTimeout': 'The install timed out',
147
+ 'panels.market.add.failurePnpmMissing': 'pnpm was not found, cannot install',
148
+ 'panels.market.add.failureGeneric': 'Something went wrong during install — see the install details',
149
+ 'panels.market.add.approveTitle': 'Your approval is needed for install scripts',
150
+ 'panels.market.add.approveCaution': 'Only allow packages you trust: install scripts run on this machine with your permissions.',
151
+ 'panels.market.add.approveRun': 'Allow and continue installing',
152
+ 'panels.market.add.restart': 'Installed — restart once to pick it up.',
153
+ 'panels.market.add.tookEffect': 'Live.',
154
+ 'panels.market.add.details': 'Install details',
155
+ 'panels.market.add.open': 'Add module',
156
+ 'panels.market.add.title': 'Add module',
157
+ 'panels.market.add.intro': 'Install a workbench module by package name. It goes on this machine, shared by every project.',
158
+ 'panels.market.add.specLabel': 'Package',
159
+ 'panels.market.add.specHint': 'The same thing you would put after `dsh plugin add`: a package name (optional @version), a git URL, a tarball, or an absolute local path.',
160
+ 'panels.market.add.exampleTitle': 'Examples',
161
+ 'panels.market.add.exampleFill': 'Fill in an example',
162
+ 'panels.market.add.registryLabel': 'Source',
163
+ 'panels.market.add.registryProfile': "This profile's registry",
164
+ 'panels.market.add.registryPnpm': "pnpm's own registry",
165
+ 'panels.market.add.check': 'Check',
166
+ 'panels.market.add.checking': 'Checking…',
167
+ 'panels.market.add.change': 'Edit',
168
+ 'panels.market.add.previewTitle': 'About to install',
169
+ 'panels.market.add.fieldName': 'Package',
170
+ 'panels.market.add.fieldVersion': 'Version',
171
+ 'panels.market.add.fieldDescription': 'Description',
172
+ 'panels.market.add.fieldSource': 'Source',
173
+ 'panels.market.add.install': 'Install',
174
+ 'panels.market.add.installing': 'Installing…',
175
+ 'panels.market.add.cancel': 'Cancel install',
176
+ 'panels.market.add.close': 'Close',
177
+ 'panels.market.add.retry': 'Retry',
178
+ 'panels.market.add.changeSource': 'Change source',
179
+ 'panels.market.add.approveBuilds': 'Allow these scripts and retry',
180
+ 'panels.market.add.approveHint': 'These packages want to run install scripts: {packages}',
181
+ 'panels.market.add.doneApplied': 'Installed and live.',
182
+ 'panels.market.add.doneRestart': 'Installed — restart once to pick it up.',
183
+ 'panels.market.add.cancelled': 'Cancelled.',
184
+ 'panels.market.add.failed': "Didn't work: {reason}",
185
+ 'panels.market.add.supplyInstalled': 'The plugins it needs are installed too.',
186
+ 'panels.market.add.supplyPending': 'Its plugins install after you restart.',
187
+ 'panels.market.add.supplyFailed': "Its plugins didn't install: {reason}",
188
+ 'panels.market.add.notModule': "This is not a workbench module (no dsh.workbench declaration), so it will not show up on the board.",
189
+ 'panels.market.add.removed': 'Removed.',
190
+ 'panels.market.add.removedRestart': 'Removed — restart once to finish.',
191
+ 'panels.market.add.remove': 'Remove it',
192
+ 'panels.market.add.problem.invalidSpec': "That is not a spec we accept: it cannot be empty or start with a dash.",
193
+ 'panels.market.add.problem.alreadyInstalled': 'That package is already in the profile (add @version to switch versions).',
194
+ 'panels.market.add.problem.notFound': 'No such package on that source.',
195
+ 'panels.market.add.problem.notAPackage': 'There is no package at that location.',
196
+ 'panels.market.add.problem.notABundle': 'It is an npm package, but not a dsh plugin (no bundle patch).',
197
+ 'panels.market.add.problem.network': 'The source is unreachable.',
198
+ 'panels.market.add.problem.unknown': 'The check did not pass (reason unknown).',
199
+ 'panels.market.add.reason.invalidSpec': 'the spec is not accepted',
200
+ 'panels.market.add.reason.incompatible': 'it wants a different dsh version than this machine runs',
201
+ 'panels.market.add.reason.notBundle': 'it is not a dsh plugin package',
202
+ 'panels.market.add.reason.notRemovable': 'it ships with the installation and cannot be removed',
203
+ 'panels.market.add.reason.bundleInUse': 'something is still using it',
204
+ 'panels.market.add.reason.stopProfile': 'this profile has no hot reload, so stop the process first',
205
+ 'panels.market.add.reason.staleApproval': 'the scripts to allow changed — start over',
206
+ 'panels.market.add.reason.operationError': 'pnpm failed (see the install output)',
207
+ 'panels.market.add.reason.buildBlocked': 'pnpm blocked install scripts',
208
+ 'panels.market.add.reason.pnpmMissing': 'pnpm is not on this machine',
209
+ 'panels.market.add.reason.noMatchingVersion': 'no version matching that range on the source',
210
+ 'panels.market.add.reason.diskFull': 'the disk is full',
211
+ 'panels.market.add.reason.permission': 'no permission to write',
212
+ 'panels.market.add.reason.integrity': 'the download failed its integrity check',
213
+ 'panels.market.add.reason.timeout': 'no output for too long, so it was stopped',
214
+ 'panels.market.add.reason.network': 'the network is unreachable',
215
+ 'panels.market.add.reason.notFound': 'no such package on the source',
216
+ 'panels.market.add.reason.unknown': 'It failed without saying why (see the install output)',
91
217
  'blocker.fix.install': 'Install for me',
92
218
  'blocker.fix.update': 'Upgrade for me',
93
219
  'blocker.fix.running': 'Running…',
package/src/i18n/zh.ts CHANGED
@@ -66,19 +66,23 @@ export const zh = {
66
66
  'panels.market.install': '安装',
67
67
  'panels.market.update': '更新',
68
68
  'panels.market.uninstall': '卸载',
69
+ 'panels.market.uninstallLabel': '卸载 {name}',
69
70
  'panels.market.installing': '正在安装…',
70
71
  'panels.market.updating': '正在更新…',
71
72
  'panels.market.uninstalling': '正在卸载…',
72
- 'panels.market.confirmUninstall': '要卸载吗?',
73
- 'panels.market.confirmUninstallDetail':
74
- '卸载后这台机器上就没有它了,所有项目的面板也会把它一起拿掉(绑定与设置不会丢)。',
75
- 'panels.market.confirmYes': '确定卸载',
73
+ 'panels.market.confirmUninstallTitle': '卸载「{name}」?',
74
+ 'panels.market.confirmUninstallDetail': '卸载后它提供的功能会消失。',
75
+ 'panels.market.confirmUninstallAck': '我明白:卸载后想再用,得重新装一遍。',
76
+ 'panels.market.confirmYes': '卸载',
76
77
  'panels.market.confirmNo': '取消',
77
78
  'panels.market.failed': '没成功:{reason}',
78
79
  'panels.market.needEnv': '先在启动工作台的终端里设 {env}',
79
80
  'panels.market.noSource': '这个模块没声明怎么装,只能自己动手',
80
81
  'panels.market.badSource': '安装方式没写全,只能自己动手',
81
82
  'panels.market.empty': '暂无可用模块',
83
+ 'panels.market.installedSection': '已装',
84
+ 'panels.market.moduleUpdate': '有新版 {version}:安装完成后可能需要重启才生效。',
85
+ 'panels.market.restartNeeded': '新版装好了,重启一次才生效。',
82
86
  'panels.market.foot': '装好后到那个项目的面板页勾选它,模块才会出现。',
83
87
  'panels.market.recheck': '重新检查更新',
84
88
  'panels.market.checkUpdates': '检查更新',
@@ -86,6 +90,126 @@ export const zh = {
86
90
  'panels.market.justNow': '刚刚',
87
91
  'panels.market.minutesAgo': '{n} 分钟前',
88
92
  'panels.market.hoursAgo': '{n} 小时前',
93
+ 'panels.market.add.description': '输入模块的包名、Git 仓库地址或本地目录路径。',
94
+ 'panels.market.add.specPlaceholder': '例如 @dsh-workbench/module-hello',
95
+ 'panels.market.add.guideToggle': '模块安装引导和示例',
96
+ 'panels.market.add.guideHide': '收起引导',
97
+ 'panels.market.add.guideIdTitle': '包名',
98
+ 'panels.market.add.guideIdExample': '@dsh-workbench/module-hello',
99
+ 'panels.market.add.guideIdHint': '模块包名即 npm 包名(如 dsh-workbench-module-xxx 或 @作者/模块名),社区模块的 README 安装命令中 dsh plugin add 或 pnpm add 之后的部分。',
100
+ 'panels.market.add.guideGitTitle': 'Git 仓库地址',
101
+ 'panels.market.add.guideGitExample': 'https://github.com/author/dsh-workbench-module-x',
102
+ 'panels.market.add.guideGitHint': '模块在 GitHub 上的开源仓库地址,也支持其他 Git 仓库。',
103
+ 'panels.market.add.guidePathTitle': '本地模块目录',
104
+ 'panels.market.add.guidePathExample': '/Users/name/my-workbench-module',
105
+ 'panels.market.add.guidePathHint': '本机上模块目录的绝对路径,适用于自行开发或已下载的模块。',
106
+ 'panels.market.add.guideExampleLabel': '示例:',
107
+ 'panels.market.add.guideFill': '填入示例',
108
+ 'panels.market.add.guideSafety': '请确认模块来源可信。模块在本机以你的权限运行,来源不明的模块可能损坏工作台,或读取和泄露你的数据。',
109
+ 'panels.market.add.registryLegend': '从哪个 npm 源下载模块',
110
+ 'panels.market.add.registryOfficial': 'npm 官方源',
111
+ 'panels.market.add.registryMirror': '中国大陆镜像源',
112
+ 'panels.market.add.registryWithHost': '{name}({host})',
113
+ 'panels.market.add.registryToggle': '安装源',
114
+ 'panels.market.add.installVersion': '版本 {version}',
115
+ 'panels.market.add.registryDefault': '默认安装源',
116
+ 'panels.market.add.registryCustom': '自定义地址',
117
+ 'panels.market.add.registryCustomPlaceholder': 'https://npm.example.com/',
118
+ 'panels.market.add.registryCustomHint': '公司内网或私有 npm 源;需要登录的源,把凭据放在本机的 ~/.npmrc 里',
119
+ 'panels.market.add.registryCustomInvalid': '请输入以 http:// 或 https:// 开头的地址',
120
+ 'panels.market.add.run': '安装',
121
+ 'panels.market.add.edit': '编辑',
122
+ 'panels.market.add.changeRegistry': '更换安装源',
123
+ 'panels.market.add.installingTitle': '模块安装中…',
124
+ 'panels.market.add.installedTitle': '已安装',
125
+ 'panels.market.add.failedTitle': '模块安装失败',
126
+ 'panels.market.add.cancelledTitle': '已取消',
127
+ 'panels.market.add.failureNetworkHost': '无法连接 {host}。Git 地址和 .tgz 直链不经过安装源,需要本机能直接访问它或配置代理;如果这个模块也发布到了 npm,请改填包名。',
128
+ 'panels.market.add.problemInvalid': '无法识别这个包名或地址:{reason}',
129
+ 'panels.market.add.problemInstalled': '该模块已安装',
130
+ 'panels.market.add.problemNotFound': '未找到相关模块',
131
+ 'panels.market.add.problemNotPackage': '该路径不存在或不是有效的模块包',
132
+ 'panels.market.add.problemNotBundle': '这个包没有声明组合包,无法作为模块安装:{reason}',
133
+ 'panels.market.add.problemNetwork': '无法连接模块源,请检查网络后重试',
134
+ 'panels.market.add.problemUnknown': '无法获取模块信息:{reason}',
135
+ 'panels.market.add.failureNetwork': '网络连接失败',
136
+ 'panels.market.add.failureNotFound': '未找到相关模块',
137
+ 'panels.market.add.failureNoMatchingVersion': '没有匹配的版本',
138
+ 'panels.market.add.failureDiskFull': '磁盘空间不足,安装已停止',
139
+ 'panels.market.add.failurePermission': '没有写入权限,无法安装',
140
+ 'panels.market.add.failureBuildBlocked': '有依赖的安装脚本需要你允许后才能继续',
141
+ 'panels.market.add.failureIntegrity': '下载的安装包校验失败',
142
+ 'panels.market.add.failureTimeout': '安装超时',
143
+ 'panels.market.add.failurePnpmMissing': '没有找到 pnpm,无法安装',
144
+ 'panels.market.add.failureGeneric': '安装过程中出错,原因见安装详情',
145
+ 'panels.market.add.approveTitle': '需要你允许安装脚本',
146
+ 'panels.market.add.approveCaution': '只允许你信得过的包:安装脚本会以你的权限在这台机器上运行。',
147
+ 'panels.market.add.approveRun': '允许并继续安装',
148
+ 'panels.market.add.restart': '装好了,重启一次才生效。',
149
+ 'panels.market.add.tookEffect': '已生效。',
150
+ 'panels.market.add.details': '安装详情',
151
+ 'panels.market.add.open': '添加模块',
152
+ 'panels.market.add.title': '添加模块',
153
+ 'panels.market.add.intro': '按包名装工作台模块。装在这台机器上,所有项目共用。',
154
+ 'panels.market.add.specLabel': '包名',
155
+ 'panels.market.add.specHint': '就是命令里 `dsh plugin add` 后面那一段:包名(可带 @版本)、git 地址、压缩包或本地绝对路径。',
156
+ 'panels.market.add.exampleTitle': '示例',
157
+ 'panels.market.add.exampleFill': '填入示例',
158
+ 'panels.market.add.registryLabel': '安装源',
159
+ 'panels.market.add.registryProfile': '这个 profile 配的源',
160
+ 'panels.market.add.registryPnpm': 'pnpm 自己配的源',
161
+ 'panels.market.add.check': '预检',
162
+ 'panels.market.add.checking': '正在预检…',
163
+ 'panels.market.add.change': '改一下',
164
+ 'panels.market.add.previewTitle': '将要安装',
165
+ 'panels.market.add.fieldName': '包名',
166
+ 'panels.market.add.fieldVersion': '版本',
167
+ 'panels.market.add.fieldDescription': '简介',
168
+ 'panels.market.add.fieldSource': '来源',
169
+ 'panels.market.add.install': '安装',
170
+ 'panels.market.add.installing': '正在安装…',
171
+ 'panels.market.add.cancel': '取消安装',
172
+ 'panels.market.add.close': '关闭',
173
+ 'panels.market.add.retry': '重试',
174
+ 'panels.market.add.changeSource': '换源',
175
+ 'panels.market.add.approveBuilds': '允许这些脚本并重试',
176
+ 'panels.market.add.approveHint': '这几个包要跑安装脚本:{packages}',
177
+ 'panels.market.add.doneApplied': '装好了,已经生效。',
178
+ 'panels.market.add.doneRestart': '装好了,重启一次才生效。',
179
+ 'panels.market.add.cancelled': '已取消。',
180
+ 'panels.market.add.failed': '没成功:{reason}',
181
+ 'panels.market.add.supplyInstalled': '它要的插件也装上了。',
182
+ 'panels.market.add.supplyPending': '它要的插件重启后再装。',
183
+ 'panels.market.add.supplyFailed': '它要的插件没装上:{reason}',
184
+ 'panels.market.add.notModule': '这不是工作台模块(没有 dsh.workbench 声明),不会出现在面板上。',
185
+ 'panels.market.add.removed': '已经移除了。',
186
+ 'panels.market.add.removedRestart': '卸掉了,重启一次才彻底生效。',
187
+ 'panels.market.add.remove': '移除它',
188
+ 'panels.market.add.problem.invalidSpec': '这个写法不认:不能是空的,也不能以横杠开头。',
189
+ 'panels.market.add.problem.alreadyInstalled': '这个包已经在 profile 里了(要换版本请带上 @版本)。',
190
+ 'panels.market.add.problem.notFound': '源上没有这个包。',
191
+ 'panels.market.add.problem.notAPackage': '这个位置没有包。',
192
+ 'panels.market.add.problem.notABundle': '它是一个 npm 包,但不是 dsh 插件包(没有 bundle patch)。',
193
+ 'panels.market.add.problem.network': '源连不上。',
194
+ 'panels.market.add.problem.unknown': '预检没通过(原因未知)。',
195
+ 'panels.market.add.reason.invalidSpec': '写法不认',
196
+ 'panels.market.add.reason.incompatible': '它要的 dsh 版本和这台机器上的不一致',
197
+ 'panels.market.add.reason.notBundle': '它不是一个 dsh 插件包',
198
+ 'panels.market.add.reason.notRemovable': '它是安装自带的组合包,不能卸',
199
+ 'panels.market.add.reason.bundleInUse': '还有东西在用它,卸不掉',
200
+ 'panels.market.add.reason.stopProfile': '这个 profile 没开热更新,得先停掉进程',
201
+ 'panels.market.add.reason.staleApproval': '要允许的安装脚本已经变了,重新来一次',
202
+ 'panels.market.add.reason.operationError': 'pnpm 执行出错(详情见安装输出)',
203
+ 'panels.market.add.reason.buildBlocked': 'pnpm 拦下了安装脚本',
204
+ 'panels.market.add.reason.pnpmMissing': '这台机器上没有 pnpm',
205
+ 'panels.market.add.reason.noMatchingVersion': '源上没有符合这个版本范围的版本',
206
+ 'panels.market.add.reason.diskFull': '磁盘满了',
207
+ 'panels.market.add.reason.permission': '没有写权限',
208
+ 'panels.market.add.reason.integrity': '下载内容校验不过',
209
+ 'panels.market.add.reason.timeout': '太久没有输出,被中断了',
210
+ 'panels.market.add.reason.network': '网络不通',
211
+ 'panels.market.add.reason.notFound': '源上没有这个包',
212
+ 'panels.market.add.reason.unknown': '没成功,但它没说是为什么(详情见安装输出的那一行)',
89
213
  'blocker.fix.install': '帮我安装',
90
214
  'blocker.fix.update': '帮我升级',
91
215
  'blocker.fix.running': '正在执行…',
package/src/index.ts CHANGED
@@ -17,7 +17,7 @@ export * from './components/LongTaskRow.js';
17
17
  export * from './components/MockStrip.js';
18
18
  export * from './components/ResourceStates.js';
19
19
  export * from './components/SaveBar.js';
20
- export * from './components/StateDot.js';
20
+ export * from './components/TextField.js';
21
21
  export * from './components/board-module.js';
22
22
  export * from './components/icons.js';
23
23
  export * from './config/constants.js';
@@ -1,5 +0,0 @@
1
- export type DotState = 'ongoing' | 'warning' | 'done' | 'idle' | string;
2
- export declare function StateDot({ state, size }: {
3
- state: DotState;
4
- size: number;
5
- }): JSX.Element;
@@ -1,10 +0,0 @@
1
- import { h } from '../lib/react.js';
2
- export function StateDot({ state, size }) {
3
- if (state === 'ongoing') {
4
- return (h("svg", { className: "wb-loading", viewBox: "0 0 24 24", width: size, height: size, "aria-hidden": "true", style: { display: 'block' } },
5
- h("g", { className: "wb-loadingMotion" },
6
- h("circle", { className: "wb-loadingTrack", cx: 12, cy: 12, r: 9.5 }),
7
- h("circle", { className: "wb-loadingArc", cx: 12, cy: 12, r: 9.5 }))));
8
- }
9
- return (h("span", { className: "wb-stateDot", "data-state": state, style: { width: size, height: size }, "aria-hidden": "true" }));
10
- }
@@ -1,41 +0,0 @@
1
- import type { DshShell } from '../../api/dsh.js';
2
- import type { Opencli } from '../../host/opencli.js';
3
- export interface ShellCall {
4
- command: string;
5
- workdir?: string;
6
- timeoutMs?: number;
7
- onExpiry?: string;
8
- stdoutMaxBytes?: number;
9
- }
10
- export interface ShellReply {
11
- stdout?: string;
12
- stderr?: string;
13
- exitCode?: number | null;
14
- timedOut?: boolean;
15
- aborted?: boolean;
16
- failWith?: Error;
17
- }
18
- export declare function createFakeShell(replies?: ShellReply[] | ((call: ShellCall, index: number) => ShellReply)): {
19
- shell: DshShell;
20
- calls: ShellCall[];
21
- peak: () => number;
22
- commands: () => string[];
23
- };
24
- export interface OpencliCall {
25
- args: readonly string[];
26
- key?: string;
27
- workdir?: string;
28
- refresh?: boolean;
29
- }
30
- export declare function createFakeOpencli(replies?: Array<unknown | Error> | ((call: OpencliCall, index: number) => unknown | Error)): {
31
- opencli: Opencli;
32
- calls: OpencliCall[];
33
- keys: () => (string | undefined)[];
34
- };
35
- export declare function createFakeLogger(): {
36
- logger: {
37
- info: () => void;
38
- warn: (message: string) => void;
39
- };
40
- warnings: string[];
41
- };