@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,193 +1,241 @@
|
|
|
1
|
-
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
})
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
DEFAULT_EXTENSION_CATALOG_TRUST_POLICY,
|
|
4
|
+
DEFAULT_EXTENSION_INSTALL_TRUST_STORAGE_KEY,
|
|
5
|
+
DEFAULT_INSTALLED_EXTENSIONS_STORAGE_KEY,
|
|
6
|
+
ExtensionInstallApprovalRequiredError,
|
|
7
|
+
applyExtensionInstallPlanToRecords,
|
|
8
|
+
assertExtensionCatalogUrlAllowed,
|
|
9
|
+
loadExtensionInstallTrustRecords,
|
|
10
|
+
loadInstalledExtensions,
|
|
11
|
+
parseExtensionCatalog,
|
|
12
|
+
recordExtensionInstallTrust,
|
|
13
|
+
saveExtensionInstallTrustRecords,
|
|
14
|
+
saveInstalledExtensions,
|
|
15
|
+
toggleInstalledExtensionEnabled,
|
|
16
|
+
type ExtensionCatalogEntry,
|
|
17
|
+
type ExtensionCatalogTrustPolicy,
|
|
18
|
+
type ExtensionInstallTrustRecord,
|
|
19
|
+
type InstalledExtensionRecord,
|
|
20
|
+
} from '@workbench-kit/workbench-core';
|
|
21
|
+
import type {
|
|
22
|
+
ExtensionCatalogBrowseEntry,
|
|
23
|
+
ExtensionInstallOptions,
|
|
24
|
+
ExtensionManagementEntry,
|
|
25
|
+
ExtensionManagementPendingAction,
|
|
26
|
+
} from '@workbench-kit/react/workbench/management';
|
|
27
|
+
|
|
28
|
+
import {
|
|
29
|
+
createCatalogEntryInstallPlan,
|
|
30
|
+
createExtensionCatalogBrowseEntries,
|
|
31
|
+
createExtensionInstallPlanningContext,
|
|
32
|
+
createExtensionManagementEntries,
|
|
33
|
+
} from './management-model.js';
|
|
34
|
+
import { useWorkbench, type WorkbenchStorageAdapter } from '../shell/provider.js';
|
|
35
|
+
|
|
36
|
+
export interface UseExtensionManagementModelOptions {
|
|
37
|
+
catalogTrustPolicy?: ExtensionCatalogTrustPolicy | undefined;
|
|
38
|
+
catalogUrl?: string | undefined;
|
|
39
|
+
installedExtensionsStorage?: WorkbenchStorageAdapter | undefined;
|
|
40
|
+
installedExtensionsStorageKey?: string | undefined;
|
|
41
|
+
installTrustStorage?: WorkbenchStorageAdapter | undefined;
|
|
42
|
+
installTrustStorageKey?: string | undefined;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function useExtensionManagementModel({
|
|
46
|
+
catalogTrustPolicy = DEFAULT_EXTENSION_CATALOG_TRUST_POLICY,
|
|
47
|
+
catalogUrl = '/extension-catalog.json',
|
|
48
|
+
installedExtensionsStorage,
|
|
49
|
+
installedExtensionsStorageKey,
|
|
50
|
+
installTrustStorage,
|
|
51
|
+
installTrustStorageKey = DEFAULT_EXTENSION_INSTALL_TRUST_STORAGE_KEY,
|
|
52
|
+
}: UseExtensionManagementModelOptions = {}) {
|
|
53
|
+
const workbench = useWorkbench();
|
|
54
|
+
const { extensionRegistry } = workbench;
|
|
55
|
+
const resolvedInstalledExtensionsStorage =
|
|
56
|
+
installedExtensionsStorage ?? workbench.installedExtensionsStorage;
|
|
57
|
+
const resolvedInstalledExtensionsStorageKey =
|
|
58
|
+
installedExtensionsStorageKey ??
|
|
59
|
+
workbench.installedExtensionsStorageKey ??
|
|
60
|
+
DEFAULT_INSTALLED_EXTENSIONS_STORAGE_KEY;
|
|
61
|
+
const resolvedInstallTrustStorage = installTrustStorage ?? resolvedInstalledExtensionsStorage;
|
|
62
|
+
const [catalogEntries, setCatalogEntries] = useState<readonly ExtensionCatalogEntry[]>([]);
|
|
63
|
+
const [catalogLoading, setCatalogLoading] = useState(Boolean(catalogUrl));
|
|
64
|
+
const [catalogError, setCatalogError] = useState<string | undefined>();
|
|
65
|
+
const [pendingAction, setPendingAction] = useState<
|
|
66
|
+
ExtensionManagementPendingAction | undefined
|
|
67
|
+
>();
|
|
68
|
+
const [installedRecords, setInstalledRecords] = useState<readonly InstalledExtensionRecord[]>(
|
|
69
|
+
() =>
|
|
70
|
+
loadInstalledExtensions(
|
|
71
|
+
resolvedInstalledExtensionsStorageKey,
|
|
72
|
+
resolvedInstalledExtensionsStorage,
|
|
73
|
+
),
|
|
74
|
+
);
|
|
75
|
+
const [installTrustRecords, setInstallTrustRecords] = useState<
|
|
76
|
+
readonly ExtensionInstallTrustRecord[]
|
|
77
|
+
>(() => loadExtensionInstallTrustRecords(installTrustStorageKey, resolvedInstallTrustStorage));
|
|
78
|
+
|
|
79
|
+
useEffect(() => {
|
|
80
|
+
setInstalledRecords(
|
|
81
|
+
loadInstalledExtensions(
|
|
82
|
+
resolvedInstalledExtensionsStorageKey,
|
|
83
|
+
resolvedInstalledExtensionsStorage,
|
|
84
|
+
),
|
|
85
|
+
);
|
|
86
|
+
}, [resolvedInstalledExtensionsStorage, resolvedInstalledExtensionsStorageKey]);
|
|
87
|
+
|
|
88
|
+
useEffect(() => {
|
|
89
|
+
setInstallTrustRecords(
|
|
90
|
+
loadExtensionInstallTrustRecords(installTrustStorageKey, resolvedInstallTrustStorage),
|
|
91
|
+
);
|
|
92
|
+
}, [installTrustStorageKey, resolvedInstallTrustStorage]);
|
|
93
|
+
|
|
94
|
+
useEffect(() => {
|
|
95
|
+
if (!catalogUrl) {
|
|
96
|
+
setCatalogEntries([]);
|
|
97
|
+
setCatalogLoading(false);
|
|
98
|
+
setCatalogError(undefined);
|
|
99
|
+
return;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
let cancelled = false;
|
|
103
|
+
setCatalogLoading(true);
|
|
104
|
+
setCatalogError(undefined);
|
|
105
|
+
|
|
106
|
+
void Promise.resolve()
|
|
107
|
+
.then(() => {
|
|
108
|
+
assertExtensionCatalogUrlAllowed(catalogUrl, catalogTrustPolicy);
|
|
109
|
+
return fetch(catalogUrl);
|
|
110
|
+
})
|
|
111
|
+
.then(async (response) => {
|
|
112
|
+
if (!response.ok) {
|
|
113
|
+
throw new Error(`Catalog request failed with status ${response.status}.`);
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const catalog = parseExtensionCatalog(await response.json());
|
|
117
|
+
if (!cancelled) {
|
|
118
|
+
setCatalogEntries(catalog.entries);
|
|
119
|
+
}
|
|
120
|
+
})
|
|
121
|
+
.catch((error: unknown) => {
|
|
122
|
+
if (!cancelled) {
|
|
123
|
+
setCatalogEntries([]);
|
|
124
|
+
setCatalogError(
|
|
125
|
+
error instanceof Error ? error.message : 'Failed to load extension catalog.',
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
})
|
|
129
|
+
.finally(() => {
|
|
130
|
+
if (!cancelled) {
|
|
131
|
+
setCatalogLoading(false);
|
|
132
|
+
}
|
|
133
|
+
});
|
|
134
|
+
|
|
135
|
+
return () => {
|
|
136
|
+
cancelled = true;
|
|
137
|
+
};
|
|
138
|
+
}, [catalogTrustPolicy, catalogUrl]);
|
|
139
|
+
|
|
140
|
+
const installedEntries = useMemo<readonly ExtensionManagementEntry[]>(() => {
|
|
141
|
+
return createExtensionManagementEntries({ extensionRegistry, installedRecords });
|
|
142
|
+
}, [extensionRegistry, installedRecords]);
|
|
143
|
+
|
|
144
|
+
const browseEntries = useMemo<readonly ExtensionCatalogBrowseEntry[]>(() => {
|
|
145
|
+
return createExtensionCatalogBrowseEntries({
|
|
146
|
+
catalogEntries,
|
|
147
|
+
extensionRegistry,
|
|
148
|
+
installedRecords,
|
|
149
|
+
});
|
|
150
|
+
}, [catalogEntries, extensionRegistry, installedRecords]);
|
|
151
|
+
|
|
152
|
+
const installCatalogEntry = useCallback(
|
|
153
|
+
(entry: ExtensionCatalogBrowseEntry, options?: ExtensionInstallOptions) => {
|
|
154
|
+
const installContext = createExtensionInstallPlanningContext({
|
|
155
|
+
catalogEntries,
|
|
156
|
+
extensionRegistry,
|
|
157
|
+
installedRecords,
|
|
158
|
+
});
|
|
159
|
+
const plan = createCatalogEntryInstallPlan(entry, installContext);
|
|
160
|
+
if (!plan || plan.blocked) {
|
|
161
|
+
return;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Align with core hard gate: unapproved privileged installs must not persist.
|
|
165
|
+
if (plan.requiresApproval && options?.approved !== true) {
|
|
166
|
+
throw new ExtensionInstallApprovalRequiredError();
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
const next = applyExtensionInstallPlanToRecords({
|
|
170
|
+
approved: options?.approved === true,
|
|
171
|
+
currentRecords: installedRecords,
|
|
172
|
+
installSources: installContext.installSources,
|
|
173
|
+
plan,
|
|
174
|
+
});
|
|
175
|
+
saveInstalledExtensions(
|
|
176
|
+
next,
|
|
177
|
+
resolvedInstalledExtensionsStorageKey,
|
|
178
|
+
resolvedInstalledExtensionsStorage,
|
|
179
|
+
);
|
|
180
|
+
setInstalledRecords(next);
|
|
181
|
+
setPendingAction({ entryId: entry.id, kind: 'install' });
|
|
182
|
+
if (typeof window !== 'undefined') {
|
|
183
|
+
window.requestAnimationFrame(() => {
|
|
184
|
+
window.location.reload();
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
},
|
|
188
|
+
[
|
|
189
|
+
catalogEntries,
|
|
190
|
+
extensionRegistry,
|
|
191
|
+
installedRecords,
|
|
192
|
+
resolvedInstalledExtensionsStorage,
|
|
193
|
+
resolvedInstalledExtensionsStorageKey,
|
|
194
|
+
],
|
|
195
|
+
);
|
|
196
|
+
|
|
197
|
+
const toggleInstalledEntry = useCallback(
|
|
198
|
+
(entry: ExtensionManagementEntry, enabled: boolean) => {
|
|
199
|
+
if (entry.source === 'bundled' && entry.id.startsWith('workbench-kit.builtin.')) {
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
const next = toggleInstalledExtensionEnabled(
|
|
204
|
+
entry.id,
|
|
205
|
+
enabled,
|
|
206
|
+
resolvedInstalledExtensionsStorageKey,
|
|
207
|
+
resolvedInstalledExtensionsStorage,
|
|
208
|
+
);
|
|
209
|
+
setInstalledRecords(next);
|
|
210
|
+
setPendingAction({ entryId: entry.id, kind: 'toggle' });
|
|
211
|
+
if (typeof window !== 'undefined') {
|
|
212
|
+
window.requestAnimationFrame(() => {
|
|
213
|
+
window.location.reload();
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
},
|
|
217
|
+
[resolvedInstalledExtensionsStorage, resolvedInstalledExtensionsStorageKey],
|
|
218
|
+
);
|
|
219
|
+
|
|
220
|
+
const rememberInstallTrust = useCallback(
|
|
221
|
+
(entry: ExtensionCatalogBrowseEntry) => {
|
|
222
|
+
const permissions = entry.installPlan?.permissions ?? [];
|
|
223
|
+
const next = recordExtensionInstallTrust(entry.id, permissions, installTrustRecords);
|
|
224
|
+
saveExtensionInstallTrustRecords(next, installTrustStorageKey, resolvedInstallTrustStorage);
|
|
225
|
+
setInstallTrustRecords(next);
|
|
226
|
+
},
|
|
227
|
+
[installTrustRecords, installTrustStorageKey, resolvedInstallTrustStorage],
|
|
228
|
+
);
|
|
229
|
+
|
|
230
|
+
return {
|
|
231
|
+
browseEntries,
|
|
232
|
+
catalogError,
|
|
233
|
+
catalogLoading,
|
|
234
|
+
installCatalogEntry,
|
|
235
|
+
installedEntries,
|
|
236
|
+
installTrustRecords,
|
|
237
|
+
pendingAction,
|
|
238
|
+
rememberInstallTrust,
|
|
239
|
+
toggleInstalledEntry,
|
|
240
|
+
};
|
|
241
|
+
}
|
|
@@ -1,19 +1,19 @@
|
|
|
1
|
-
export const BUILTIN_EXTENSIONS_VIEW_RENDER_KIND = 'workbench-kit.builtin.extensions.view' as const;
|
|
2
|
-
export const BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID = 'extensions' as const;
|
|
3
|
-
export const BUILTIN_EXTENSIONS_FOCUS_COMMAND_ID =
|
|
4
|
-
'workbench-kit.builtin.extensions.focus' as const;
|
|
5
|
-
|
|
6
|
-
export interface BuiltinExtensionsViewRenderData {
|
|
7
|
-
readonly kind: typeof BUILTIN_EXTENSIONS_VIEW_RENDER_KIND;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
export function isBuiltinExtensionsViewRenderData(
|
|
11
|
-
value: unknown,
|
|
12
|
-
): value is BuiltinExtensionsViewRenderData {
|
|
13
|
-
return (
|
|
14
|
-
typeof value === 'object' &&
|
|
15
|
-
value !== null &&
|
|
16
|
-
'kind' in value &&
|
|
17
|
-
(value as BuiltinExtensionsViewRenderData).kind === BUILTIN_EXTENSIONS_VIEW_RENDER_KIND
|
|
18
|
-
);
|
|
19
|
-
}
|
|
1
|
+
export const BUILTIN_EXTENSIONS_VIEW_RENDER_KIND = 'workbench-kit.builtin.extensions.view' as const;
|
|
2
|
+
export const BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID = 'extensions' as const;
|
|
3
|
+
export const BUILTIN_EXTENSIONS_FOCUS_COMMAND_ID =
|
|
4
|
+
'workbench-kit.builtin.extensions.focus' as const;
|
|
5
|
+
|
|
6
|
+
export interface BuiltinExtensionsViewRenderData {
|
|
7
|
+
readonly kind: typeof BUILTIN_EXTENSIONS_VIEW_RENDER_KIND;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export function isBuiltinExtensionsViewRenderData(
|
|
11
|
+
value: unknown,
|
|
12
|
+
): value is BuiltinExtensionsViewRenderData {
|
|
13
|
+
return (
|
|
14
|
+
typeof value === 'object' &&
|
|
15
|
+
value !== null &&
|
|
16
|
+
'kind' in value &&
|
|
17
|
+
(value as BuiltinExtensionsViewRenderData).kind === BUILTIN_EXTENSIONS_VIEW_RENDER_KIND
|
|
18
|
+
);
|
|
19
|
+
}
|
|
@@ -1,38 +1,63 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
import {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
);
|
|
38
|
-
|
|
1
|
+
import { useCallback } from 'react';
|
|
2
|
+
import { ExtensionManagementSidebar } from '@workbench-kit/react/workbench/management';
|
|
3
|
+
import {
|
|
4
|
+
isExtensionInstallTrusted,
|
|
5
|
+
type ExtensionCatalogTrustPolicy,
|
|
6
|
+
} from '@workbench-kit/workbench-core';
|
|
7
|
+
|
|
8
|
+
import {
|
|
9
|
+
BUILTIN_EXTENSIONS_VIEW_RENDER_KIND,
|
|
10
|
+
isBuiltinExtensionsViewRenderData,
|
|
11
|
+
type BuiltinExtensionsViewRenderData,
|
|
12
|
+
} from './view-data.js';
|
|
13
|
+
import { useExtensionManagementModel } from './use-extension-management.js';
|
|
14
|
+
import { useWorkbench } from '../shell/provider.js';
|
|
15
|
+
|
|
16
|
+
export type { BuiltinExtensionsViewRenderData };
|
|
17
|
+
export { BUILTIN_EXTENSIONS_VIEW_RENDER_KIND, isBuiltinExtensionsViewRenderData };
|
|
18
|
+
|
|
19
|
+
export function BuiltinExtensionsView({
|
|
20
|
+
catalogTrustPolicy,
|
|
21
|
+
catalogUrl,
|
|
22
|
+
}: {
|
|
23
|
+
catalogTrustPolicy?: ExtensionCatalogTrustPolicy | undefined;
|
|
24
|
+
catalogUrl?: string | undefined;
|
|
25
|
+
}) {
|
|
26
|
+
const { missingExtensionIds } = useWorkbench();
|
|
27
|
+
const {
|
|
28
|
+
browseEntries,
|
|
29
|
+
catalogError,
|
|
30
|
+
catalogLoading,
|
|
31
|
+
installCatalogEntry,
|
|
32
|
+
installedEntries,
|
|
33
|
+
installTrustRecords,
|
|
34
|
+
pendingAction,
|
|
35
|
+
rememberInstallTrust,
|
|
36
|
+
toggleInstalledEntry,
|
|
37
|
+
} = useExtensionManagementModel({ catalogTrustPolicy, catalogUrl });
|
|
38
|
+
|
|
39
|
+
const isInstallTrusted = useCallback(
|
|
40
|
+
(entry: (typeof browseEntries)[number]) =>
|
|
41
|
+
isExtensionInstallTrusted(
|
|
42
|
+
entry.id,
|
|
43
|
+
entry.installPlan?.permissions ?? [],
|
|
44
|
+
installTrustRecords,
|
|
45
|
+
),
|
|
46
|
+
[installTrustRecords],
|
|
47
|
+
);
|
|
48
|
+
|
|
49
|
+
return (
|
|
50
|
+
<ExtensionManagementSidebar
|
|
51
|
+
browseEntries={browseEntries}
|
|
52
|
+
catalogError={catalogError}
|
|
53
|
+
catalogLoading={catalogLoading}
|
|
54
|
+
installedEntries={installedEntries}
|
|
55
|
+
isInstallTrusted={isInstallTrusted}
|
|
56
|
+
missingExtensionIds={missingExtensionIds}
|
|
57
|
+
pendingAction={pendingAction}
|
|
58
|
+
onInstall={installCatalogEntry}
|
|
59
|
+
onRememberInstallTrust={rememberInstallTrust}
|
|
60
|
+
onToggleEnabled={toggleInstalledEntry}
|
|
61
|
+
/>
|
|
62
|
+
);
|
|
63
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import type { JSX } from 'react';
|
|
2
|
-
|
|
3
|
-
import { FieldRemapPanel } from './
|
|
4
|
-
import { getFieldRemapSample, type FieldRemapSampleId } from './
|
|
5
|
-
|
|
6
|
-
export interface SampleFieldRemapDemoProps {
|
|
7
|
-
readonly sampleId?: FieldRemapSampleId | string | undefined;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
/**
|
|
11
|
-
* Sample host wrapper around {@link FieldRemapPanel}.
|
|
12
|
-
*/
|
|
13
|
-
export function SampleFieldRemapDemo({
|
|
14
|
-
sampleId = 'nested-ab',
|
|
15
|
-
}: SampleFieldRemapDemoProps = {}): JSX.Element {
|
|
16
|
-
const sample = getFieldRemapSample(sampleId);
|
|
17
|
-
return <FieldRemapPanel key={sample.id} sample={sample} />;
|
|
18
|
-
}
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
|
|
3
|
+
import { FieldRemapPanel } from './panel.js';
|
|
4
|
+
import { getFieldRemapSample, type FieldRemapSampleId } from './samples.js';
|
|
5
|
+
|
|
6
|
+
export interface SampleFieldRemapDemoProps {
|
|
7
|
+
readonly sampleId?: FieldRemapSampleId | string | undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Sample host wrapper around {@link FieldRemapPanel}.
|
|
12
|
+
*/
|
|
13
|
+
export function SampleFieldRemapDemo({
|
|
14
|
+
sampleId = 'nested-ab',
|
|
15
|
+
}: SampleFieldRemapDemoProps = {}): JSX.Element {
|
|
16
|
+
const sample = getFieldRemapSample(sampleId);
|
|
17
|
+
return <FieldRemapPanel key={sample.id} sample={sample} />;
|
|
18
|
+
}
|