@workbench-kit/shell-react 0.0.2-prototype.0.2.26 → 0.0.2-prototype.0.2.28
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 +18 -2
- package/package.json +10 -10
- package/src/chat/command-policy.ts +3 -17
- package/src/commands/use-command-descriptors.ts +2 -30
- package/src/commands/use-context-key-revision.ts +12 -12
- package/src/commands/use-extension-registry-command-descriptors.ts +46 -0
- package/src/devtools/use-workbench-devtools-snapshot.ts +1 -1
- package/src/editor/pane-visibility.ts +0 -23
- package/src/editor/view-providers.tsx +0 -7
- package/src/explorer/reveal.ts +1 -12
- package/src/extensions/builtin/commands/src/command-inspector-editor-host.ts +1 -19
- package/src/extensions/builtin/commands/src/index.ts +2 -2
- package/src/field-remap/convert-note-editor.tsx +2 -4
- package/src/field-remap/convert-palette.tsx +17 -20
- package/src/field-remap/flow-adapter.ts +21 -57
- package/src/field-remap/flow-ops.ts +0 -24
- package/src/field-remap/index.ts +0 -1
- package/src/field-remap/io-class-browse.tsx +29 -6
- package/src/field-remap/jsonata-transform.ts +9 -39
- package/src/field-remap/shape-io-editor.tsx +1 -1
- package/src/field-remap/transform-options-editor.tsx +1 -2
- package/src/field-remap/view.css +4 -29
- package/src/index.ts +1 -10
- package/src/jdw/widget-form-view.tsx +3 -20
- package/src/jdw/widget-preview-view.tsx +2 -20
- package/src/management/use-command-management.ts +22 -7
- package/src/management/use-keybinding-management.ts +1 -10
- package/src/shell/provider.tsx +19 -9
- package/src/shell/shell.tsx +11 -4
- package/src/workbench/command-host.tsx +46 -7
- package/src/workbench/command-palette.ts +12 -45
- package/src/workbench/workspace-view-state.ts +18 -1
- package/src/field-remap/graph.tsx +0 -559
- package/src/field-remap/table-mapping-adapter.ts +0 -59
- package/src/field-remap/tree.tsx +0 -404
|
@@ -16,15 +16,18 @@ import {
|
|
|
16
16
|
type WorkbenchCommandRunContext,
|
|
17
17
|
type WorkbenchShellCommandContext,
|
|
18
18
|
} from '@workbench-kit/react/workbench';
|
|
19
|
+
import {
|
|
20
|
+
matchesWorkbenchCommandPaletteShortcut,
|
|
21
|
+
matchesWorkbenchQuickAccessShortcut,
|
|
22
|
+
} from '@workbench-kit/react/workbench/command-ui';
|
|
19
23
|
import { useCallback, useEffect, useMemo, useRef, useState } from 'react';
|
|
20
24
|
|
|
25
|
+
import { useContextKeyRevision } from '../commands/use-context-key-revision.js';
|
|
21
26
|
import { useWorkbench } from '../shell/provider.js';
|
|
22
27
|
import { registerWorkbenchShellCommandHandlers } from './shell-command-registration.js';
|
|
23
28
|
import {
|
|
24
29
|
buildWorkbenchPaletteCommands,
|
|
25
30
|
collectExtensionCommandFeaturesById,
|
|
26
|
-
matchesWorkbenchCommandPaletteShortcut,
|
|
27
|
-
matchesWorkbenchQuickAccessShortcut,
|
|
28
31
|
resolveShellCommandActivities,
|
|
29
32
|
} from './command-palette.js';
|
|
30
33
|
import { resolveExtensionKeybindingCommand } from './keybinding-bridge.js';
|
|
@@ -98,6 +101,7 @@ export function WorkbenchCommandHost({
|
|
|
98
101
|
quickOpenTitle = 'Quick Open',
|
|
99
102
|
}: WorkbenchCommandHostProps) {
|
|
100
103
|
const {
|
|
104
|
+
contextKeyService,
|
|
101
105
|
executeCommand,
|
|
102
106
|
extensionRegistry,
|
|
103
107
|
keybindingOverrides,
|
|
@@ -110,6 +114,11 @@ export function WorkbenchCommandHost({
|
|
|
110
114
|
const [quickOpenQuery, setQuickOpenQuery] = useState('');
|
|
111
115
|
const [layout, setLayout] = useState(() => layoutService.getState());
|
|
112
116
|
const shellContextRef = useRef<WorkbenchShellCommandContext | undefined>(undefined);
|
|
117
|
+
const contextKeyRevision = useContextKeyRevision(contextKeyService);
|
|
118
|
+
const contextKeySnapshot = useMemo(
|
|
119
|
+
() => contextKeyService.createSnapshot(),
|
|
120
|
+
[contextKeyRevision, contextKeyService],
|
|
121
|
+
);
|
|
113
122
|
|
|
114
123
|
const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
|
|
115
124
|
? workspaceHostPort.service
|
|
@@ -126,19 +135,41 @@ export function WorkbenchCommandHost({
|
|
|
126
135
|
};
|
|
127
136
|
}, [layoutService]);
|
|
128
137
|
|
|
129
|
-
const
|
|
138
|
+
const managedShellActivities = useMemo(
|
|
130
139
|
() => resolveShellCommandActivities(extensionRegistry),
|
|
131
140
|
[extensionRegistry],
|
|
132
141
|
);
|
|
142
|
+
const visibleShellActivities = useMemo(
|
|
143
|
+
() => resolveShellCommandActivities(extensionRegistry, contextKeySnapshot),
|
|
144
|
+
[contextKeySnapshot, extensionRegistry],
|
|
145
|
+
);
|
|
146
|
+
const visibleShellActivityIdSet = new Set(visibleShellActivities.map((activity) => activity.id));
|
|
147
|
+
const visibleShellActivitySignature = managedShellActivities
|
|
148
|
+
.map((activity) => (visibleShellActivityIdSet.has(activity.id) ? '1' : '0'))
|
|
149
|
+
.join('');
|
|
133
150
|
|
|
134
151
|
const shellCommandDefinitions = useMemo(
|
|
135
152
|
() =>
|
|
136
153
|
createWorkbenchShellCommands({
|
|
137
|
-
activities:
|
|
154
|
+
activities: managedShellActivities.filter(
|
|
155
|
+
(_activity, index) => visibleShellActivitySignature[index] === '1',
|
|
156
|
+
),
|
|
138
157
|
includeSettings: true,
|
|
139
158
|
includeSidebarToggle: true,
|
|
140
159
|
}),
|
|
141
|
-
[
|
|
160
|
+
[managedShellActivities, visibleShellActivitySignature],
|
|
161
|
+
);
|
|
162
|
+
|
|
163
|
+
const managedShellCommandIds = useMemo(
|
|
164
|
+
() =>
|
|
165
|
+
new Set(
|
|
166
|
+
createWorkbenchShellCommands({
|
|
167
|
+
activities: managedShellActivities,
|
|
168
|
+
includeSettings: true,
|
|
169
|
+
includeSidebarToggle: true,
|
|
170
|
+
}).map((command) => command.id),
|
|
171
|
+
),
|
|
172
|
+
[managedShellActivities],
|
|
142
173
|
);
|
|
143
174
|
|
|
144
175
|
const shellCommandRegistry = useMemo(
|
|
@@ -194,11 +225,19 @@ export function WorkbenchCommandHost({
|
|
|
194
225
|
buildWorkbenchPaletteCommands({
|
|
195
226
|
additionalCommands,
|
|
196
227
|
extensionCommandFeaturesById: collectExtensionCommandFeaturesById(extensionRegistry),
|
|
197
|
-
extensionCommands: extensionRegistry.commands
|
|
228
|
+
extensionCommands: extensionRegistry.commands
|
|
229
|
+
.getCommands()
|
|
230
|
+
.filter((command) => !managedShellCommandIds.has(command.id)),
|
|
198
231
|
shellCommands: shellCommandDefinitions,
|
|
199
232
|
shellContext,
|
|
200
233
|
}),
|
|
201
|
-
[
|
|
234
|
+
[
|
|
235
|
+
additionalCommands,
|
|
236
|
+
extensionRegistry,
|
|
237
|
+
managedShellCommandIds,
|
|
238
|
+
shellContext,
|
|
239
|
+
shellCommandDefinitions,
|
|
240
|
+
],
|
|
202
241
|
);
|
|
203
242
|
|
|
204
243
|
const resolvedQuickOpenProviders = useMemo(() => {
|
|
@@ -4,10 +4,11 @@ import type {
|
|
|
4
4
|
WorkbenchShellCommandActivity,
|
|
5
5
|
WorkbenchShellCommandContext,
|
|
6
6
|
} from '@workbench-kit/react/workbench';
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
7
|
+
import {
|
|
8
|
+
filterActivitiesByWhenClause,
|
|
9
|
+
type ExtensionCommandFeatureSpec,
|
|
10
|
+
type ExtensionRegistry,
|
|
11
|
+
} from '@workbench-kit/workbench-core';
|
|
11
12
|
|
|
12
13
|
type ExtensionCommand = ReturnType<ExtensionRegistry['commands']['getCommands']>[number];
|
|
13
14
|
|
|
@@ -44,10 +45,16 @@ export function resolveExtensionCommandIcon(icon: ExtensionCommand['icon']): str
|
|
|
44
45
|
|
|
45
46
|
export function resolveShellCommandActivities(
|
|
46
47
|
extensionRegistry: ExtensionRegistry,
|
|
48
|
+
contextKeys?: object | undefined,
|
|
47
49
|
): WorkbenchShellCommandActivity[] {
|
|
48
50
|
const activities = extensionRegistry.activities.getActivities();
|
|
49
51
|
if (activities.length > 0) {
|
|
50
|
-
|
|
52
|
+
const visibleActivities =
|
|
53
|
+
contextKeys === undefined
|
|
54
|
+
? activities
|
|
55
|
+
: filterActivitiesByWhenClause(activities, contextKeys);
|
|
56
|
+
|
|
57
|
+
return visibleActivities
|
|
51
58
|
.map((activity) => ({
|
|
52
59
|
icon: formatWorkbenchCommandIcon(activity.icon),
|
|
53
60
|
id: activity.viewContainerId,
|
|
@@ -166,43 +173,3 @@ export function buildWorkbenchPaletteCommands({
|
|
|
166
173
|
...additionalCommands,
|
|
167
174
|
]);
|
|
168
175
|
}
|
|
169
|
-
|
|
170
|
-
export function matchesWorkbenchCommandPaletteShortcut(
|
|
171
|
-
event: Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'key' | 'metaKey' | 'shiftKey'>,
|
|
172
|
-
) {
|
|
173
|
-
const key = event.key.toLowerCase();
|
|
174
|
-
|
|
175
|
-
if (key !== 'p') {
|
|
176
|
-
return false;
|
|
177
|
-
}
|
|
178
|
-
|
|
179
|
-
if (!(event.ctrlKey || event.metaKey) || !event.shiftKey || event.altKey) {
|
|
180
|
-
return false;
|
|
181
|
-
}
|
|
182
|
-
|
|
183
|
-
return true;
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
export function matchesWorkbenchQuickAccessShortcut(
|
|
187
|
-
event: Pick<KeyboardEvent, 'altKey' | 'ctrlKey' | 'key' | 'metaKey' | 'shiftKey'>,
|
|
188
|
-
) {
|
|
189
|
-
const key = event.key.toLowerCase();
|
|
190
|
-
|
|
191
|
-
if (key !== 'p') {
|
|
192
|
-
return false;
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
if (!(event.ctrlKey || event.metaKey) || event.shiftKey || event.altKey) {
|
|
196
|
-
return false;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
return true;
|
|
200
|
-
}
|
|
201
|
-
|
|
202
|
-
export function getWorkbenchCommandPaletteShortcutLabel() {
|
|
203
|
-
return WORKBENCH_COMMAND_PALETTE_SHORTCUT;
|
|
204
|
-
}
|
|
205
|
-
|
|
206
|
-
export function getWorkbenchQuickAccessShortcutLabel() {
|
|
207
|
-
return WORKBENCH_QUICK_ACCESS_SHORTCUT;
|
|
208
|
-
}
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import { useEffect, useState } from 'react';
|
|
1
|
+
import { useCallback, useEffect, useMemo, useState } from 'react';
|
|
2
2
|
import type {
|
|
3
3
|
VirtualWorkspaceState,
|
|
4
4
|
WorkspaceChangeEvent,
|
|
5
5
|
WorkspaceResourceService,
|
|
6
6
|
} from '@workbench-kit/workspace';
|
|
7
7
|
|
|
8
|
+
const EMPTY_WORKSPACE_FILES: VirtualWorkspaceState['files'] = [];
|
|
9
|
+
|
|
8
10
|
export function isWorkspaceResourceService(value: unknown): value is WorkspaceResourceService {
|
|
9
11
|
return (
|
|
10
12
|
typeof value === 'object' &&
|
|
@@ -33,3 +35,18 @@ export function useWorkspaceResourceState(
|
|
|
33
35
|
|
|
34
36
|
return state;
|
|
35
37
|
}
|
|
38
|
+
|
|
39
|
+
export function useWorkspaceTextDocuments(workspaceService: WorkspaceResourceService | undefined) {
|
|
40
|
+
const workspaceState = useWorkspaceResourceState(workspaceService);
|
|
41
|
+
const files =
|
|
42
|
+
workspaceState?.files ?? workspaceService?.getState().files ?? EMPTY_WORKSPACE_FILES;
|
|
43
|
+
const documentsByPath = useMemo(
|
|
44
|
+
() => new Map(files.map((file) => [file.path.replace(/\\/g, '/'), file.content])),
|
|
45
|
+
[files],
|
|
46
|
+
);
|
|
47
|
+
const loadDocument = useCallback(
|
|
48
|
+
(documentPath: string) => documentsByPath.get(documentPath.replace(/\\/g, '/')) ?? null,
|
|
49
|
+
[documentsByPath],
|
|
50
|
+
);
|
|
51
|
+
return { files, loadDocument };
|
|
52
|
+
}
|