@workbench-kit/shell-react 0.0.2-prototype.0.2.6 → 0.0.2-prototype.0.2.8
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/README.md +41 -0
- package/package.json +9 -9
- package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
- package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
- package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
- package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
- package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
- package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
- package/src/{chat-view.tsx → chat/view.tsx} +220 -220
- package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
- package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
- package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
- package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
- package/src/{commands-view.tsx → commands/view.tsx} +43 -43
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
- package/src/devtools/index.ts +11 -11
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
- package/src/devtools/workbench-devtools-snapshot.ts +140 -140
- package/src/devtools/workbench-devtools.css +82 -82
- package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
- package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
- package/src/{editor-area.css → editor/area.css} +454 -454
- package/src/{editor-area.tsx → editor/area.tsx} +676 -676
- package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
- package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
- package/src/{editor-resource.ts → editor/resource.ts} +36 -36
- package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
- package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
- package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
- package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
- package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
- package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
- package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
- package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
- package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
- package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
- package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
- package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
- package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
- package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
- package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
- package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
- package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
- package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
- package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
- package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
- package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
- package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
- package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
- package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
- package/src/field-remap/jsonata-transform.ts +166 -0
- package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
- package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
- package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
- package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
- package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
- package/src/{field-remap-view.css → field-remap/view.css} +676 -676
- package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
- package/src/index.ts +212 -199
- package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
- package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
- package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
- package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
- package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
- package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
- package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
- package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
- package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
- package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
- package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
- package/src/{management-settings.tsx → management/settings.tsx} +96 -75
- package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
- package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
- package/src/{shell-model.tsx → shell/model.tsx} +149 -149
- package/src/{provider.tsx → shell/provider.tsx} +603 -573
- package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
- package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
- package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
- package/src/{shell.tsx → shell/shell.tsx} +680 -649
- package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
- package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
- package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
- package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
- package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
- package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
- package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
- package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
- package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
- package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
- package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
- package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
- package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
- package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
- package/src/jsonata-transform.ts +0 -36
|
@@ -1,313 +1,313 @@
|
|
|
1
|
-
import {
|
|
2
|
-
BUILTIN_WORKBENCH_EXTENSIONS,
|
|
3
|
-
SAMPLE_WORKBENCH_EXTENSIONS,
|
|
4
|
-
createExtensionFeatureSpec,
|
|
5
|
-
createExtensionInstallPlan,
|
|
6
|
-
resolveBundledExtensionByManifestUrl,
|
|
7
|
-
type ExtensionCatalogEntry,
|
|
8
|
-
type ExtensionFeatureInspection,
|
|
9
|
-
type ExtensionFeatureSpec,
|
|
10
|
-
type ExtensionInstallPlan,
|
|
11
|
-
type ExtensionInstallPlanInstallSource,
|
|
12
|
-
type ExtensionRegistry,
|
|
13
|
-
type InstalledExtensionRecord,
|
|
14
|
-
type WorkbenchExtensionDescription,
|
|
15
|
-
} from '@workbench-kit/workbench-core';
|
|
16
|
-
import type {
|
|
17
|
-
ExtensionCatalogBrowseEntry,
|
|
18
|
-
ExtensionManagementDiagnosticSummary,
|
|
19
|
-
ExtensionManagementEntry,
|
|
20
|
-
ExtensionManagementFeatureSummary,
|
|
21
|
-
} from '@workbench-kit/react/workbench/management';
|
|
22
|
-
|
|
23
|
-
export const BUNDLED_EXTENSIONS = [
|
|
24
|
-
...BUILTIN_WORKBENCH_EXTENSIONS,
|
|
25
|
-
...SAMPLE_WORKBENCH_EXTENSIONS,
|
|
26
|
-
] as const;
|
|
27
|
-
|
|
28
|
-
export interface CreateExtensionManagementEntriesInput {
|
|
29
|
-
readonly extensionRegistry: ExtensionRegistry;
|
|
30
|
-
readonly installedRecords: readonly InstalledExtensionRecord[];
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
export interface CreateExtensionCatalogBrowseEntriesInput extends CreateExtensionManagementEntriesInput {
|
|
34
|
-
readonly catalogEntries: readonly ExtensionCatalogEntry[];
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export interface ExtensionInstallPlanningContext extends CreateExtensionManagementEntriesInput {
|
|
38
|
-
readonly availableExtensions: readonly WorkbenchExtensionDescription[];
|
|
39
|
-
readonly enabledExtensionIds: readonly string[];
|
|
40
|
-
readonly hostCapabilityIds: readonly string[];
|
|
41
|
-
readonly installSources: readonly ExtensionInstallPlanInstallSource[];
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function createExtensionManagementEntries({
|
|
45
|
-
extensionRegistry,
|
|
46
|
-
installedRecords,
|
|
47
|
-
}: CreateExtensionManagementEntriesInput): readonly ExtensionManagementEntry[] {
|
|
48
|
-
const installedById = new Map(installedRecords.map((record) => [record.id, record]));
|
|
49
|
-
const extensionFeatures = createExtensionManagementFeatureMaps(extensionRegistry);
|
|
50
|
-
const bundledEntries = BUNDLED_EXTENSIONS.map((extension) => {
|
|
51
|
-
const installed = installedById.get(extension.manifest.id);
|
|
52
|
-
const isBuiltin = extension.manifest.id.startsWith('workbench-kit.builtin.');
|
|
53
|
-
const featureState = resolveExtensionManagementFeatureState(
|
|
54
|
-
extension.manifest.id,
|
|
55
|
-
extensionFeatures,
|
|
56
|
-
);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
category: installed?.category ?? (isBuiltin ? 'builtin' : 'sample'),
|
|
60
|
-
description: extension.manifest.displayName,
|
|
61
|
-
diagnostics: featureState.diagnostics,
|
|
62
|
-
displayName: extension.manifest.displayName,
|
|
63
|
-
enabled: isBuiltin ? true : (installed?.enabled ?? false),
|
|
64
|
-
features: featureState.features,
|
|
65
|
-
id: extension.manifest.id,
|
|
66
|
-
installedAt: installed?.installedAt,
|
|
67
|
-
manifestUrl: installed?.manifestUrl,
|
|
68
|
-
source: isBuiltin ? ('bundled' as const) : ('installed' as const),
|
|
69
|
-
} satisfies ExtensionManagementEntry;
|
|
70
|
-
}).filter((entry) => entry.source === 'bundled' || installedById.has(entry.id));
|
|
71
|
-
|
|
72
|
-
const activeExtensions = extensionRegistry
|
|
73
|
-
.getExtensions()
|
|
74
|
-
.filter(
|
|
75
|
-
(extension) =>
|
|
76
|
-
!BUNDLED_EXTENSIONS.some((bundled) => bundled.manifest.id === extension.manifest.id),
|
|
77
|
-
)
|
|
78
|
-
.map((extension) => {
|
|
79
|
-
const installed = installedById.get(extension.manifest.id);
|
|
80
|
-
const featureState = resolveExtensionManagementFeatureState(
|
|
81
|
-
extension.manifest.id,
|
|
82
|
-
extensionFeatures,
|
|
83
|
-
);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
category: installed?.category ?? 'installed',
|
|
87
|
-
description: extension.manifest.displayName,
|
|
88
|
-
diagnostics: featureState.diagnostics,
|
|
89
|
-
displayName: extension.manifest.displayName,
|
|
90
|
-
enabled: installed?.enabled ?? true,
|
|
91
|
-
features: featureState.features,
|
|
92
|
-
id: extension.manifest.id,
|
|
93
|
-
installedAt: installed?.installedAt,
|
|
94
|
-
manifestUrl: installed?.manifestUrl,
|
|
95
|
-
source: 'installed',
|
|
96
|
-
} satisfies ExtensionManagementEntry;
|
|
97
|
-
});
|
|
98
|
-
|
|
99
|
-
return [...bundledEntries, ...activeExtensions].sort((left, right) =>
|
|
100
|
-
left.displayName.localeCompare(right.displayName),
|
|
101
|
-
);
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
export function createExtensionCatalogBrowseEntries({
|
|
105
|
-
catalogEntries,
|
|
106
|
-
extensionRegistry,
|
|
107
|
-
installedRecords,
|
|
108
|
-
}: CreateExtensionCatalogBrowseEntriesInput): readonly ExtensionCatalogBrowseEntry[] {
|
|
109
|
-
const installedIds = new Set(installedRecords.map((record) => record.id));
|
|
110
|
-
const installContext = createExtensionInstallPlanningContext({
|
|
111
|
-
catalogEntries,
|
|
112
|
-
extensionRegistry,
|
|
113
|
-
installedRecords,
|
|
114
|
-
});
|
|
115
|
-
|
|
116
|
-
return catalogEntries.map((entry) => {
|
|
117
|
-
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
118
|
-
entry.manifestUrl,
|
|
119
|
-
installContext.availableExtensions,
|
|
120
|
-
);
|
|
121
|
-
const extensionId = bundledExtension?.manifest.id ?? entry.id;
|
|
122
|
-
const plan = createCatalogEntryInstallPlan(entry, installContext);
|
|
123
|
-
|
|
124
|
-
return {
|
|
125
|
-
category: entry.category,
|
|
126
|
-
description: entry.description,
|
|
127
|
-
displayName: entry.displayName,
|
|
128
|
-
icon: entry.icon,
|
|
129
|
-
id: extensionId,
|
|
130
|
-
installPlan: plan ? toExtensionInstallPlanSummary(plan) : undefined,
|
|
131
|
-
installed: installedIds.has(extensionId),
|
|
132
|
-
manifestUrl: entry.manifestUrl,
|
|
133
|
-
};
|
|
134
|
-
});
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
export function createExtensionInstallPlanningContext({
|
|
138
|
-
catalogEntries,
|
|
139
|
-
extensionRegistry,
|
|
140
|
-
installedRecords,
|
|
141
|
-
}: CreateExtensionCatalogBrowseEntriesInput): ExtensionInstallPlanningContext {
|
|
142
|
-
const availableExtensions = mergeUniqueExtensionDescriptions([
|
|
143
|
-
...BUNDLED_EXTENSIONS,
|
|
144
|
-
...extensionRegistry.getExtensions(),
|
|
145
|
-
]);
|
|
146
|
-
|
|
147
|
-
return {
|
|
148
|
-
availableExtensions,
|
|
149
|
-
enabledExtensionIds: extensionRegistry
|
|
150
|
-
.getExtensions()
|
|
151
|
-
.map((extension) => extension.manifest.id),
|
|
152
|
-
extensionRegistry,
|
|
153
|
-
hostCapabilityIds: extensionRegistry.capabilityRegistry.listProviderIds(),
|
|
154
|
-
installSources: createExtensionInstallSources(catalogEntries, availableExtensions),
|
|
155
|
-
installedRecords,
|
|
156
|
-
};
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
export function createCatalogEntryInstallPlan(
|
|
160
|
-
entry: Pick<ExtensionCatalogBrowseEntry, 'manifestUrl'>,
|
|
161
|
-
{
|
|
162
|
-
availableExtensions,
|
|
163
|
-
enabledExtensionIds,
|
|
164
|
-
hostCapabilityIds,
|
|
165
|
-
installedRecords,
|
|
166
|
-
installSources,
|
|
167
|
-
}: ExtensionInstallPlanningContext,
|
|
168
|
-
): ExtensionInstallPlan | undefined {
|
|
169
|
-
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
170
|
-
entry.manifestUrl,
|
|
171
|
-
availableExtensions,
|
|
172
|
-
);
|
|
173
|
-
if (!bundledExtension) {
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
return createExtensionInstallPlan({
|
|
178
|
-
availableExtensions,
|
|
179
|
-
enabledExtensionIds,
|
|
180
|
-
hostCapabilityIds,
|
|
181
|
-
installSources,
|
|
182
|
-
installedRecords,
|
|
183
|
-
targetExtensionId: bundledExtension.manifest.id,
|
|
184
|
-
});
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
function createExtensionInstallSources(
|
|
188
|
-
catalogEntries: readonly ExtensionCatalogEntry[],
|
|
189
|
-
availableExtensions: readonly WorkbenchExtensionDescription[],
|
|
190
|
-
): readonly ExtensionInstallPlanInstallSource[] {
|
|
191
|
-
const byId = new Map<string, ExtensionInstallPlanInstallSource>();
|
|
192
|
-
for (const entry of catalogEntries) {
|
|
193
|
-
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
194
|
-
entry.manifestUrl,
|
|
195
|
-
availableExtensions,
|
|
196
|
-
);
|
|
197
|
-
const extensionId = bundledExtension?.manifest.id ?? entry.id;
|
|
198
|
-
byId.set(extensionId, {
|
|
199
|
-
category: entry.category,
|
|
200
|
-
id: extensionId,
|
|
201
|
-
manifestUrl: entry.manifestUrl,
|
|
202
|
-
});
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
return [...byId.values()];
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
function mergeUniqueExtensionDescriptions(
|
|
209
|
-
descriptions: readonly WorkbenchExtensionDescription[],
|
|
210
|
-
): readonly WorkbenchExtensionDescription[] {
|
|
211
|
-
const byId = new Map<string, WorkbenchExtensionDescription>();
|
|
212
|
-
for (const description of descriptions) {
|
|
213
|
-
byId.set(description.manifest.id, description);
|
|
214
|
-
}
|
|
215
|
-
return [...byId.values()];
|
|
216
|
-
}
|
|
217
|
-
|
|
218
|
-
function createExtensionManagementFeatureMaps(extensionRegistry: ExtensionRegistry) {
|
|
219
|
-
return {
|
|
220
|
-
bundledFeaturesById: new Map(
|
|
221
|
-
BUNDLED_EXTENSIONS.map((extension) => [
|
|
222
|
-
extension.manifest.id,
|
|
223
|
-
createExtensionFeatureSpec(extension),
|
|
224
|
-
]),
|
|
225
|
-
),
|
|
226
|
-
inspectionsById: new Map(
|
|
227
|
-
extensionRegistry
|
|
228
|
-
.getFeatureInspections()
|
|
229
|
-
.map((inspection) => [inspection.feature.id, inspection]),
|
|
230
|
-
),
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
function resolveExtensionManagementFeatureState(
|
|
235
|
-
extensionId: string,
|
|
236
|
-
{
|
|
237
|
-
bundledFeaturesById,
|
|
238
|
-
inspectionsById,
|
|
239
|
-
}: {
|
|
240
|
-
bundledFeaturesById: ReadonlyMap<string, ExtensionFeatureSpec>;
|
|
241
|
-
inspectionsById: ReadonlyMap<string, ExtensionFeatureInspection>;
|
|
242
|
-
},
|
|
243
|
-
): {
|
|
244
|
-
readonly diagnostics?: readonly ExtensionManagementDiagnosticSummary[] | undefined;
|
|
245
|
-
readonly features?: ExtensionManagementFeatureSummary | undefined;
|
|
246
|
-
} {
|
|
247
|
-
const inspection = inspectionsById.get(extensionId);
|
|
248
|
-
const feature = inspection?.feature ?? bundledFeaturesById.get(extensionId);
|
|
249
|
-
|
|
250
|
-
return {
|
|
251
|
-
diagnostics: inspection?.diagnostics.map(({ message, severity }) => ({ message, severity })),
|
|
252
|
-
features: feature ? toExtensionManagementFeatureSummary(feature) : undefined,
|
|
253
|
-
};
|
|
254
|
-
}
|
|
255
|
-
|
|
256
|
-
function toExtensionManagementFeatureSummary(
|
|
257
|
-
feature: ExtensionFeatureSpec,
|
|
258
|
-
): ExtensionManagementFeatureSummary {
|
|
259
|
-
const commandTitlesById = new Map(feature.commands.map((command) => [command.id, command.title]));
|
|
260
|
-
|
|
261
|
-
return {
|
|
262
|
-
capabilities: feature.capabilities,
|
|
263
|
-
commands: feature.commands.map((command) => ({
|
|
264
|
-
description: command.description,
|
|
265
|
-
id: command.id,
|
|
266
|
-
label: command.title,
|
|
267
|
-
})),
|
|
268
|
-
documentViews: feature.documentViews.map((view) => ({
|
|
269
|
-
id: view.id,
|
|
270
|
-
label: view.label,
|
|
271
|
-
})),
|
|
272
|
-
menus: feature.menus.map((menu) => ({
|
|
273
|
-
description: formatMenuContributionDescription(menu.group, menu.order),
|
|
274
|
-
id: `${menu.menu}:${menu.command}`,
|
|
275
|
-
label: `${menu.menu}: ${commandTitlesById.get(menu.command) ?? menu.command}`,
|
|
276
|
-
})),
|
|
277
|
-
permissions: feature.permissions,
|
|
278
|
-
settings: feature.settings.map((setting) => ({
|
|
279
|
-
description: setting.description,
|
|
280
|
-
id: setting.key,
|
|
281
|
-
label: setting.key,
|
|
282
|
-
})),
|
|
283
|
-
views: feature.views.map((view) => ({
|
|
284
|
-
id: view.id,
|
|
285
|
-
label: view.name,
|
|
286
|
-
})),
|
|
287
|
-
};
|
|
288
|
-
}
|
|
289
|
-
|
|
290
|
-
function toExtensionInstallPlanSummary(
|
|
291
|
-
plan: ExtensionInstallPlan,
|
|
292
|
-
): ExtensionCatalogBrowseEntry['installPlan'] {
|
|
293
|
-
return {
|
|
294
|
-
blocked: plan.blocked,
|
|
295
|
-
diagnostics: plan.diagnostics.map(({ message, severity }) => ({ message, severity })),
|
|
296
|
-
enableExtensionIds: plan.enableExtensionIds,
|
|
297
|
-
installExtensionIds: plan.installExtensionIds,
|
|
298
|
-
permissions: plan.permissions,
|
|
299
|
-
requiresApproval: plan.requiresApproval,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
function formatMenuContributionDescription(
|
|
304
|
-
group: string | undefined,
|
|
305
|
-
order: number | undefined,
|
|
306
|
-
): string | undefined {
|
|
307
|
-
const parts = [
|
|
308
|
-
group ? `group: ${group}` : undefined,
|
|
309
|
-
order !== undefined ? `order: ${order}` : undefined,
|
|
310
|
-
].filter((part): part is string => part !== undefined);
|
|
311
|
-
|
|
312
|
-
return parts.length > 0 ? parts.join(', ') : undefined;
|
|
313
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
BUILTIN_WORKBENCH_EXTENSIONS,
|
|
3
|
+
SAMPLE_WORKBENCH_EXTENSIONS,
|
|
4
|
+
createExtensionFeatureSpec,
|
|
5
|
+
createExtensionInstallPlan,
|
|
6
|
+
resolveBundledExtensionByManifestUrl,
|
|
7
|
+
type ExtensionCatalogEntry,
|
|
8
|
+
type ExtensionFeatureInspection,
|
|
9
|
+
type ExtensionFeatureSpec,
|
|
10
|
+
type ExtensionInstallPlan,
|
|
11
|
+
type ExtensionInstallPlanInstallSource,
|
|
12
|
+
type ExtensionRegistry,
|
|
13
|
+
type InstalledExtensionRecord,
|
|
14
|
+
type WorkbenchExtensionDescription,
|
|
15
|
+
} from '@workbench-kit/workbench-core';
|
|
16
|
+
import type {
|
|
17
|
+
ExtensionCatalogBrowseEntry,
|
|
18
|
+
ExtensionManagementDiagnosticSummary,
|
|
19
|
+
ExtensionManagementEntry,
|
|
20
|
+
ExtensionManagementFeatureSummary,
|
|
21
|
+
} from '@workbench-kit/react/workbench/management';
|
|
22
|
+
|
|
23
|
+
export const BUNDLED_EXTENSIONS = [
|
|
24
|
+
...BUILTIN_WORKBENCH_EXTENSIONS,
|
|
25
|
+
...SAMPLE_WORKBENCH_EXTENSIONS,
|
|
26
|
+
] as const;
|
|
27
|
+
|
|
28
|
+
export interface CreateExtensionManagementEntriesInput {
|
|
29
|
+
readonly extensionRegistry: ExtensionRegistry;
|
|
30
|
+
readonly installedRecords: readonly InstalledExtensionRecord[];
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export interface CreateExtensionCatalogBrowseEntriesInput extends CreateExtensionManagementEntriesInput {
|
|
34
|
+
readonly catalogEntries: readonly ExtensionCatalogEntry[];
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface ExtensionInstallPlanningContext extends CreateExtensionManagementEntriesInput {
|
|
38
|
+
readonly availableExtensions: readonly WorkbenchExtensionDescription[];
|
|
39
|
+
readonly enabledExtensionIds: readonly string[];
|
|
40
|
+
readonly hostCapabilityIds: readonly string[];
|
|
41
|
+
readonly installSources: readonly ExtensionInstallPlanInstallSource[];
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export function createExtensionManagementEntries({
|
|
45
|
+
extensionRegistry,
|
|
46
|
+
installedRecords,
|
|
47
|
+
}: CreateExtensionManagementEntriesInput): readonly ExtensionManagementEntry[] {
|
|
48
|
+
const installedById = new Map(installedRecords.map((record) => [record.id, record]));
|
|
49
|
+
const extensionFeatures = createExtensionManagementFeatureMaps(extensionRegistry);
|
|
50
|
+
const bundledEntries = BUNDLED_EXTENSIONS.map((extension) => {
|
|
51
|
+
const installed = installedById.get(extension.manifest.id);
|
|
52
|
+
const isBuiltin = extension.manifest.id.startsWith('workbench-kit.builtin.');
|
|
53
|
+
const featureState = resolveExtensionManagementFeatureState(
|
|
54
|
+
extension.manifest.id,
|
|
55
|
+
extensionFeatures,
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
category: installed?.category ?? (isBuiltin ? 'builtin' : 'sample'),
|
|
60
|
+
description: extension.manifest.displayName,
|
|
61
|
+
diagnostics: featureState.diagnostics,
|
|
62
|
+
displayName: extension.manifest.displayName,
|
|
63
|
+
enabled: isBuiltin ? true : (installed?.enabled ?? false),
|
|
64
|
+
features: featureState.features,
|
|
65
|
+
id: extension.manifest.id,
|
|
66
|
+
installedAt: installed?.installedAt,
|
|
67
|
+
manifestUrl: installed?.manifestUrl,
|
|
68
|
+
source: isBuiltin ? ('bundled' as const) : ('installed' as const),
|
|
69
|
+
} satisfies ExtensionManagementEntry;
|
|
70
|
+
}).filter((entry) => entry.source === 'bundled' || installedById.has(entry.id));
|
|
71
|
+
|
|
72
|
+
const activeExtensions = extensionRegistry
|
|
73
|
+
.getExtensions()
|
|
74
|
+
.filter(
|
|
75
|
+
(extension) =>
|
|
76
|
+
!BUNDLED_EXTENSIONS.some((bundled) => bundled.manifest.id === extension.manifest.id),
|
|
77
|
+
)
|
|
78
|
+
.map((extension) => {
|
|
79
|
+
const installed = installedById.get(extension.manifest.id);
|
|
80
|
+
const featureState = resolveExtensionManagementFeatureState(
|
|
81
|
+
extension.manifest.id,
|
|
82
|
+
extensionFeatures,
|
|
83
|
+
);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
category: installed?.category ?? 'installed',
|
|
87
|
+
description: extension.manifest.displayName,
|
|
88
|
+
diagnostics: featureState.diagnostics,
|
|
89
|
+
displayName: extension.manifest.displayName,
|
|
90
|
+
enabled: installed?.enabled ?? true,
|
|
91
|
+
features: featureState.features,
|
|
92
|
+
id: extension.manifest.id,
|
|
93
|
+
installedAt: installed?.installedAt,
|
|
94
|
+
manifestUrl: installed?.manifestUrl,
|
|
95
|
+
source: 'installed',
|
|
96
|
+
} satisfies ExtensionManagementEntry;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
return [...bundledEntries, ...activeExtensions].sort((left, right) =>
|
|
100
|
+
left.displayName.localeCompare(right.displayName),
|
|
101
|
+
);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export function createExtensionCatalogBrowseEntries({
|
|
105
|
+
catalogEntries,
|
|
106
|
+
extensionRegistry,
|
|
107
|
+
installedRecords,
|
|
108
|
+
}: CreateExtensionCatalogBrowseEntriesInput): readonly ExtensionCatalogBrowseEntry[] {
|
|
109
|
+
const installedIds = new Set(installedRecords.map((record) => record.id));
|
|
110
|
+
const installContext = createExtensionInstallPlanningContext({
|
|
111
|
+
catalogEntries,
|
|
112
|
+
extensionRegistry,
|
|
113
|
+
installedRecords,
|
|
114
|
+
});
|
|
115
|
+
|
|
116
|
+
return catalogEntries.map((entry) => {
|
|
117
|
+
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
118
|
+
entry.manifestUrl,
|
|
119
|
+
installContext.availableExtensions,
|
|
120
|
+
);
|
|
121
|
+
const extensionId = bundledExtension?.manifest.id ?? entry.id;
|
|
122
|
+
const plan = createCatalogEntryInstallPlan(entry, installContext);
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
category: entry.category,
|
|
126
|
+
description: entry.description,
|
|
127
|
+
displayName: entry.displayName,
|
|
128
|
+
icon: entry.icon,
|
|
129
|
+
id: extensionId,
|
|
130
|
+
installPlan: plan ? toExtensionInstallPlanSummary(plan) : undefined,
|
|
131
|
+
installed: installedIds.has(extensionId),
|
|
132
|
+
manifestUrl: entry.manifestUrl,
|
|
133
|
+
};
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function createExtensionInstallPlanningContext({
|
|
138
|
+
catalogEntries,
|
|
139
|
+
extensionRegistry,
|
|
140
|
+
installedRecords,
|
|
141
|
+
}: CreateExtensionCatalogBrowseEntriesInput): ExtensionInstallPlanningContext {
|
|
142
|
+
const availableExtensions = mergeUniqueExtensionDescriptions([
|
|
143
|
+
...BUNDLED_EXTENSIONS,
|
|
144
|
+
...extensionRegistry.getExtensions(),
|
|
145
|
+
]);
|
|
146
|
+
|
|
147
|
+
return {
|
|
148
|
+
availableExtensions,
|
|
149
|
+
enabledExtensionIds: extensionRegistry
|
|
150
|
+
.getExtensions()
|
|
151
|
+
.map((extension) => extension.manifest.id),
|
|
152
|
+
extensionRegistry,
|
|
153
|
+
hostCapabilityIds: extensionRegistry.capabilityRegistry.listProviderIds(),
|
|
154
|
+
installSources: createExtensionInstallSources(catalogEntries, availableExtensions),
|
|
155
|
+
installedRecords,
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function createCatalogEntryInstallPlan(
|
|
160
|
+
entry: Pick<ExtensionCatalogBrowseEntry, 'manifestUrl'>,
|
|
161
|
+
{
|
|
162
|
+
availableExtensions,
|
|
163
|
+
enabledExtensionIds,
|
|
164
|
+
hostCapabilityIds,
|
|
165
|
+
installedRecords,
|
|
166
|
+
installSources,
|
|
167
|
+
}: ExtensionInstallPlanningContext,
|
|
168
|
+
): ExtensionInstallPlan | undefined {
|
|
169
|
+
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
170
|
+
entry.manifestUrl,
|
|
171
|
+
availableExtensions,
|
|
172
|
+
);
|
|
173
|
+
if (!bundledExtension) {
|
|
174
|
+
return undefined;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
return createExtensionInstallPlan({
|
|
178
|
+
availableExtensions,
|
|
179
|
+
enabledExtensionIds,
|
|
180
|
+
hostCapabilityIds,
|
|
181
|
+
installSources,
|
|
182
|
+
installedRecords,
|
|
183
|
+
targetExtensionId: bundledExtension.manifest.id,
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
function createExtensionInstallSources(
|
|
188
|
+
catalogEntries: readonly ExtensionCatalogEntry[],
|
|
189
|
+
availableExtensions: readonly WorkbenchExtensionDescription[],
|
|
190
|
+
): readonly ExtensionInstallPlanInstallSource[] {
|
|
191
|
+
const byId = new Map<string, ExtensionInstallPlanInstallSource>();
|
|
192
|
+
for (const entry of catalogEntries) {
|
|
193
|
+
const bundledExtension = resolveBundledExtensionByManifestUrl(
|
|
194
|
+
entry.manifestUrl,
|
|
195
|
+
availableExtensions,
|
|
196
|
+
);
|
|
197
|
+
const extensionId = bundledExtension?.manifest.id ?? entry.id;
|
|
198
|
+
byId.set(extensionId, {
|
|
199
|
+
category: entry.category,
|
|
200
|
+
id: extensionId,
|
|
201
|
+
manifestUrl: entry.manifestUrl,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
return [...byId.values()];
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
function mergeUniqueExtensionDescriptions(
|
|
209
|
+
descriptions: readonly WorkbenchExtensionDescription[],
|
|
210
|
+
): readonly WorkbenchExtensionDescription[] {
|
|
211
|
+
const byId = new Map<string, WorkbenchExtensionDescription>();
|
|
212
|
+
for (const description of descriptions) {
|
|
213
|
+
byId.set(description.manifest.id, description);
|
|
214
|
+
}
|
|
215
|
+
return [...byId.values()];
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
function createExtensionManagementFeatureMaps(extensionRegistry: ExtensionRegistry) {
|
|
219
|
+
return {
|
|
220
|
+
bundledFeaturesById: new Map(
|
|
221
|
+
BUNDLED_EXTENSIONS.map((extension) => [
|
|
222
|
+
extension.manifest.id,
|
|
223
|
+
createExtensionFeatureSpec(extension),
|
|
224
|
+
]),
|
|
225
|
+
),
|
|
226
|
+
inspectionsById: new Map(
|
|
227
|
+
extensionRegistry
|
|
228
|
+
.getFeatureInspections()
|
|
229
|
+
.map((inspection) => [inspection.feature.id, inspection]),
|
|
230
|
+
),
|
|
231
|
+
};
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
function resolveExtensionManagementFeatureState(
|
|
235
|
+
extensionId: string,
|
|
236
|
+
{
|
|
237
|
+
bundledFeaturesById,
|
|
238
|
+
inspectionsById,
|
|
239
|
+
}: {
|
|
240
|
+
bundledFeaturesById: ReadonlyMap<string, ExtensionFeatureSpec>;
|
|
241
|
+
inspectionsById: ReadonlyMap<string, ExtensionFeatureInspection>;
|
|
242
|
+
},
|
|
243
|
+
): {
|
|
244
|
+
readonly diagnostics?: readonly ExtensionManagementDiagnosticSummary[] | undefined;
|
|
245
|
+
readonly features?: ExtensionManagementFeatureSummary | undefined;
|
|
246
|
+
} {
|
|
247
|
+
const inspection = inspectionsById.get(extensionId);
|
|
248
|
+
const feature = inspection?.feature ?? bundledFeaturesById.get(extensionId);
|
|
249
|
+
|
|
250
|
+
return {
|
|
251
|
+
diagnostics: inspection?.diagnostics.map(({ message, severity }) => ({ message, severity })),
|
|
252
|
+
features: feature ? toExtensionManagementFeatureSummary(feature) : undefined,
|
|
253
|
+
};
|
|
254
|
+
}
|
|
255
|
+
|
|
256
|
+
function toExtensionManagementFeatureSummary(
|
|
257
|
+
feature: ExtensionFeatureSpec,
|
|
258
|
+
): ExtensionManagementFeatureSummary {
|
|
259
|
+
const commandTitlesById = new Map(feature.commands.map((command) => [command.id, command.title]));
|
|
260
|
+
|
|
261
|
+
return {
|
|
262
|
+
capabilities: feature.capabilities,
|
|
263
|
+
commands: feature.commands.map((command) => ({
|
|
264
|
+
description: command.description,
|
|
265
|
+
id: command.id,
|
|
266
|
+
label: command.title,
|
|
267
|
+
})),
|
|
268
|
+
documentViews: feature.documentViews.map((view) => ({
|
|
269
|
+
id: view.id,
|
|
270
|
+
label: view.label,
|
|
271
|
+
})),
|
|
272
|
+
menus: feature.menus.map((menu) => ({
|
|
273
|
+
description: formatMenuContributionDescription(menu.group, menu.order),
|
|
274
|
+
id: `${menu.menu}:${menu.command}`,
|
|
275
|
+
label: `${menu.menu}: ${commandTitlesById.get(menu.command) ?? menu.command}`,
|
|
276
|
+
})),
|
|
277
|
+
permissions: feature.permissions,
|
|
278
|
+
settings: feature.settings.map((setting) => ({
|
|
279
|
+
description: setting.description,
|
|
280
|
+
id: setting.key,
|
|
281
|
+
label: setting.key,
|
|
282
|
+
})),
|
|
283
|
+
views: feature.views.map((view) => ({
|
|
284
|
+
id: view.id,
|
|
285
|
+
label: view.name,
|
|
286
|
+
})),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
function toExtensionInstallPlanSummary(
|
|
291
|
+
plan: ExtensionInstallPlan,
|
|
292
|
+
): ExtensionCatalogBrowseEntry['installPlan'] {
|
|
293
|
+
return {
|
|
294
|
+
blocked: plan.blocked,
|
|
295
|
+
diagnostics: plan.diagnostics.map(({ message, severity }) => ({ message, severity })),
|
|
296
|
+
enableExtensionIds: plan.enableExtensionIds,
|
|
297
|
+
installExtensionIds: plan.installExtensionIds,
|
|
298
|
+
permissions: plan.permissions,
|
|
299
|
+
requiresApproval: plan.requiresApproval,
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
function formatMenuContributionDescription(
|
|
304
|
+
group: string | undefined,
|
|
305
|
+
order: number | undefined,
|
|
306
|
+
): string | undefined {
|
|
307
|
+
const parts = [
|
|
308
|
+
group ? `group: ${group}` : undefined,
|
|
309
|
+
order !== undefined ? `order: ${order}` : undefined,
|
|
310
|
+
].filter((part): part is string => part !== undefined);
|
|
311
|
+
|
|
312
|
+
return parts.length > 0 ? parts.join(', ') : undefined;
|
|
313
|
+
}
|