@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,112 +1,112 @@
|
|
|
1
|
-
import type { WorkspaceSelectionState } from '@workbench-kit/workspace';
|
|
2
|
-
|
|
3
|
-
import {
|
|
4
|
-
BUILTIN_EXPLORER_FOCUS_COMMAND_ID,
|
|
5
|
-
BUILTIN_EXPLORER_REVEAL_COMMAND_ID,
|
|
6
|
-
BUILTIN_EXPLORER_VIEW_CONTAINER_ID,
|
|
7
|
-
resolveExplorerRevealPath,
|
|
8
|
-
} from './
|
|
9
|
-
|
|
10
|
-
export {
|
|
11
|
-
BUILTIN_EXPLORER_FOCUS_COMMAND_ID,
|
|
12
|
-
BUILTIN_EXPLORER_REVEAL_COMMAND_ID,
|
|
13
|
-
BUILTIN_EXPLORER_VIEW_CONTAINER_ID,
|
|
14
|
-
resolveExplorerRevealPath,
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type ExplorerRevealListener = (path: string) => void;
|
|
18
|
-
|
|
19
|
-
let pendingRevealPath: string | undefined;
|
|
20
|
-
let revealListener: ExplorerRevealListener | undefined;
|
|
21
|
-
|
|
22
|
-
export function publishExplorerRevealRequest(path: string): void {
|
|
23
|
-
const normalizedPath = path.trim();
|
|
24
|
-
if (!normalizedPath) {
|
|
25
|
-
return;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
pendingRevealPath = normalizedPath;
|
|
29
|
-
revealListener?.(normalizedPath);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export function subscribeExplorerRevealRequest(listener: ExplorerRevealListener): () => void {
|
|
33
|
-
revealListener = listener;
|
|
34
|
-
|
|
35
|
-
if (pendingRevealPath) {
|
|
36
|
-
listener(pendingRevealPath);
|
|
37
|
-
pendingRevealPath = undefined;
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
return () => {
|
|
41
|
-
if (revealListener === listener) {
|
|
42
|
-
revealListener = undefined;
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
export function applyExplorerPathReveal(
|
|
48
|
-
path: string,
|
|
49
|
-
{
|
|
50
|
-
revealFolder,
|
|
51
|
-
setSelection,
|
|
52
|
-
}: {
|
|
53
|
-
revealFolder: (folderPath: string) => void;
|
|
54
|
-
setSelection: (selection: WorkspaceSelectionState) => void;
|
|
55
|
-
},
|
|
56
|
-
): void {
|
|
57
|
-
const normalizedPath = path.trim();
|
|
58
|
-
if (!normalizedPath) {
|
|
59
|
-
return;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
workspaceExplorerParentPaths(normalizedPath).forEach((folderPath) => {
|
|
63
|
-
revealFolder(folderPath);
|
|
64
|
-
});
|
|
65
|
-
setSelection({
|
|
66
|
-
anchorPath: normalizedPath,
|
|
67
|
-
focusedPath: normalizedPath,
|
|
68
|
-
paths: [normalizedPath],
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
function workspaceExplorerParentPaths(path: string): string[] {
|
|
73
|
-
const segments = path.split('/').filter(Boolean);
|
|
74
|
-
return segments.slice(0, -1).map((_, index) => segments.slice(0, index + 1).join('/'));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
export function isExplorerHostCommand(commandId: string): boolean {
|
|
78
|
-
return (
|
|
79
|
-
commandId === BUILTIN_EXPLORER_REVEAL_COMMAND_ID ||
|
|
80
|
-
commandId === BUILTIN_EXPLORER_FOCUS_COMMAND_ID
|
|
81
|
-
);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
export async function runExplorerHostCommandSideEffects(
|
|
85
|
-
commandId: string,
|
|
86
|
-
args: readonly unknown[],
|
|
87
|
-
result: unknown,
|
|
88
|
-
{
|
|
89
|
-
focusExplorerView,
|
|
90
|
-
revealPath,
|
|
91
|
-
}: {
|
|
92
|
-
focusExplorerView: () => void;
|
|
93
|
-
revealPath: (path: string) => void;
|
|
94
|
-
},
|
|
95
|
-
): Promise<void> {
|
|
96
|
-
if (commandId === BUILTIN_EXPLORER_FOCUS_COMMAND_ID) {
|
|
97
|
-
focusExplorerView();
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
if (commandId !== BUILTIN_EXPLORER_REVEAL_COMMAND_ID) {
|
|
102
|
-
return;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const path = resolveExplorerRevealPath(args[0], result);
|
|
106
|
-
if (!path) {
|
|
107
|
-
return;
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
focusExplorerView();
|
|
111
|
-
revealPath(path);
|
|
112
|
-
}
|
|
1
|
+
import type { WorkspaceSelectionState } from '@workbench-kit/workspace';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
BUILTIN_EXPLORER_FOCUS_COMMAND_ID,
|
|
5
|
+
BUILTIN_EXPLORER_REVEAL_COMMAND_ID,
|
|
6
|
+
BUILTIN_EXPLORER_VIEW_CONTAINER_ID,
|
|
7
|
+
resolveExplorerRevealPath,
|
|
8
|
+
} from './view-data.js';
|
|
9
|
+
|
|
10
|
+
export {
|
|
11
|
+
BUILTIN_EXPLORER_FOCUS_COMMAND_ID,
|
|
12
|
+
BUILTIN_EXPLORER_REVEAL_COMMAND_ID,
|
|
13
|
+
BUILTIN_EXPLORER_VIEW_CONTAINER_ID,
|
|
14
|
+
resolveExplorerRevealPath,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type ExplorerRevealListener = (path: string) => void;
|
|
18
|
+
|
|
19
|
+
let pendingRevealPath: string | undefined;
|
|
20
|
+
let revealListener: ExplorerRevealListener | undefined;
|
|
21
|
+
|
|
22
|
+
export function publishExplorerRevealRequest(path: string): void {
|
|
23
|
+
const normalizedPath = path.trim();
|
|
24
|
+
if (!normalizedPath) {
|
|
25
|
+
return;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
pendingRevealPath = normalizedPath;
|
|
29
|
+
revealListener?.(normalizedPath);
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export function subscribeExplorerRevealRequest(listener: ExplorerRevealListener): () => void {
|
|
33
|
+
revealListener = listener;
|
|
34
|
+
|
|
35
|
+
if (pendingRevealPath) {
|
|
36
|
+
listener(pendingRevealPath);
|
|
37
|
+
pendingRevealPath = undefined;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return () => {
|
|
41
|
+
if (revealListener === listener) {
|
|
42
|
+
revealListener = undefined;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export function applyExplorerPathReveal(
|
|
48
|
+
path: string,
|
|
49
|
+
{
|
|
50
|
+
revealFolder,
|
|
51
|
+
setSelection,
|
|
52
|
+
}: {
|
|
53
|
+
revealFolder: (folderPath: string) => void;
|
|
54
|
+
setSelection: (selection: WorkspaceSelectionState) => void;
|
|
55
|
+
},
|
|
56
|
+
): void {
|
|
57
|
+
const normalizedPath = path.trim();
|
|
58
|
+
if (!normalizedPath) {
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
workspaceExplorerParentPaths(normalizedPath).forEach((folderPath) => {
|
|
63
|
+
revealFolder(folderPath);
|
|
64
|
+
});
|
|
65
|
+
setSelection({
|
|
66
|
+
anchorPath: normalizedPath,
|
|
67
|
+
focusedPath: normalizedPath,
|
|
68
|
+
paths: [normalizedPath],
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
function workspaceExplorerParentPaths(path: string): string[] {
|
|
73
|
+
const segments = path.split('/').filter(Boolean);
|
|
74
|
+
return segments.slice(0, -1).map((_, index) => segments.slice(0, index + 1).join('/'));
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function isExplorerHostCommand(commandId: string): boolean {
|
|
78
|
+
return (
|
|
79
|
+
commandId === BUILTIN_EXPLORER_REVEAL_COMMAND_ID ||
|
|
80
|
+
commandId === BUILTIN_EXPLORER_FOCUS_COMMAND_ID
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export async function runExplorerHostCommandSideEffects(
|
|
85
|
+
commandId: string,
|
|
86
|
+
args: readonly unknown[],
|
|
87
|
+
result: unknown,
|
|
88
|
+
{
|
|
89
|
+
focusExplorerView,
|
|
90
|
+
revealPath,
|
|
91
|
+
}: {
|
|
92
|
+
focusExplorerView: () => void;
|
|
93
|
+
revealPath: (path: string) => void;
|
|
94
|
+
},
|
|
95
|
+
): Promise<void> {
|
|
96
|
+
if (commandId === BUILTIN_EXPLORER_FOCUS_COMMAND_ID) {
|
|
97
|
+
focusExplorerView();
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
if (commandId !== BUILTIN_EXPLORER_REVEAL_COMMAND_ID) {
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
const path = resolveExplorerRevealPath(args[0], result);
|
|
106
|
+
if (!path) {
|
|
107
|
+
return;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
focusExplorerView();
|
|
111
|
+
revealPath(path);
|
|
112
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export const BUILTIN_SEARCH_VIEW_RENDER_KIND = 'workbench-kit.builtin.search.view' as const;
|
|
2
|
-
|
|
3
|
-
export interface BuiltinSearchViewRenderData {
|
|
4
|
-
readonly kind: typeof BUILTIN_SEARCH_VIEW_RENDER_KIND;
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
export function isBuiltinSearchViewRenderData(
|
|
8
|
-
value: unknown,
|
|
9
|
-
): value is BuiltinSearchViewRenderData {
|
|
10
|
-
return (
|
|
11
|
-
typeof value === 'object' &&
|
|
12
|
-
value !== null &&
|
|
13
|
-
(value as { kind?: unknown }).kind === BUILTIN_SEARCH_VIEW_RENDER_KIND
|
|
14
|
-
);
|
|
15
|
-
}
|
|
1
|
+
export const BUILTIN_SEARCH_VIEW_RENDER_KIND = 'workbench-kit.builtin.search.view' as const;
|
|
2
|
+
|
|
3
|
+
export interface BuiltinSearchViewRenderData {
|
|
4
|
+
readonly kind: typeof BUILTIN_SEARCH_VIEW_RENDER_KIND;
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function isBuiltinSearchViewRenderData(
|
|
8
|
+
value: unknown,
|
|
9
|
+
): value is BuiltinSearchViewRenderData {
|
|
10
|
+
return (
|
|
11
|
+
typeof value === 'object' &&
|
|
12
|
+
value !== null &&
|
|
13
|
+
(value as { kind?: unknown }).kind === BUILTIN_SEARCH_VIEW_RENDER_KIND
|
|
14
|
+
);
|
|
15
|
+
}
|
|
@@ -1,62 +1,65 @@
|
|
|
1
|
-
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
-
import { ViewEmptyState } from '@workbench-kit/react/primitives';
|
|
3
|
-
import { WorkspaceSearchPanel } from '@workbench-kit/react/workbench/workspace';
|
|
4
|
-
import { searchWorkspaceFiles, type WorkspaceSearchResult } from '@workbench-kit/workspace';
|
|
5
|
-
|
|
6
|
-
import { useWorkbench } from '
|
|
7
|
-
import { useActiveWorkspacePath } from './use-active-workspace-path.js';
|
|
8
|
-
import { useActiveEditorTab } from '
|
|
9
|
-
import {
|
|
10
|
-
BUILTIN_SEARCH_VIEW_RENDER_KIND,
|
|
11
|
-
isBuiltinSearchViewRenderData,
|
|
12
|
-
type BuiltinSearchViewRenderData,
|
|
13
|
-
} from './search-view-data.js';
|
|
14
|
-
import {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
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
|
-
}
|
|
1
|
+
import { useCallback, useMemo, useState } from 'react';
|
|
2
|
+
import { ViewEmptyState } from '@workbench-kit/react/primitives';
|
|
3
|
+
import { WorkspaceSearchPanel } from '@workbench-kit/react/workbench/workspace';
|
|
4
|
+
import { searchWorkspaceFiles, type WorkspaceSearchResult } from '@workbench-kit/workspace';
|
|
5
|
+
|
|
6
|
+
import { useWorkbench } from '../shell/provider.js';
|
|
7
|
+
import { useActiveWorkspacePath } from './use-active-workspace-path.js';
|
|
8
|
+
import { useActiveEditorTab } from '../editor/use-editor.js';
|
|
9
|
+
import {
|
|
10
|
+
BUILTIN_SEARCH_VIEW_RENDER_KIND,
|
|
11
|
+
isBuiltinSearchViewRenderData,
|
|
12
|
+
type BuiltinSearchViewRenderData,
|
|
13
|
+
} from './search-view-data.js';
|
|
14
|
+
import {
|
|
15
|
+
isWorkspaceResourceService,
|
|
16
|
+
useWorkspaceResourceState,
|
|
17
|
+
} from '../workbench/workspace-view-state.js';
|
|
18
|
+
|
|
19
|
+
export type { BuiltinSearchViewRenderData };
|
|
20
|
+
export { BUILTIN_SEARCH_VIEW_RENDER_KIND, isBuiltinSearchViewRenderData };
|
|
21
|
+
|
|
22
|
+
const WORKSPACE_OPEN_COMMAND_ID = 'workspace.open' as const;
|
|
23
|
+
|
|
24
|
+
export function BuiltinSearchView() {
|
|
25
|
+
const { executeCommand, workspaceHostPort } = useWorkbench();
|
|
26
|
+
const activeTab = useActiveEditorTab();
|
|
27
|
+
const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
|
|
28
|
+
? workspaceHostPort.service
|
|
29
|
+
: undefined;
|
|
30
|
+
const workspaceState = useWorkspaceResourceState(workspaceService);
|
|
31
|
+
const [query, setQuery] = useState(workspaceState?.searchQuery ?? '');
|
|
32
|
+
|
|
33
|
+
const activePath = useActiveWorkspacePath(activeTab?.resourceUri);
|
|
34
|
+
|
|
35
|
+
const results = useMemo<WorkspaceSearchResult[]>(() => {
|
|
36
|
+
if (!workspaceState) return [];
|
|
37
|
+
return searchWorkspaceFiles(workspaceState.files, query);
|
|
38
|
+
}, [query, workspaceState]);
|
|
39
|
+
|
|
40
|
+
const openResult = useCallback(
|
|
41
|
+
(result: WorkspaceSearchResult) => {
|
|
42
|
+
void executeCommand(WORKSPACE_OPEN_COMMAND_ID, { path: result.path });
|
|
43
|
+
},
|
|
44
|
+
[executeCommand],
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
if (!workspaceState) {
|
|
48
|
+
return (
|
|
49
|
+
<ViewEmptyState className="workbench-search-view">
|
|
50
|
+
No virtual workspace is registered.
|
|
51
|
+
</ViewEmptyState>
|
|
52
|
+
);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
return (
|
|
56
|
+
<WorkspaceSearchPanel
|
|
57
|
+
activePath={activePath}
|
|
58
|
+
className="workbench-search-view"
|
|
59
|
+
query={query}
|
|
60
|
+
results={results}
|
|
61
|
+
onActivateResult={openResult}
|
|
62
|
+
onQueryChange={setQuery}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { useMemo } from 'react';
|
|
2
|
-
import { parseWorkspaceResourceUri } from '@workbench-kit/workspace';
|
|
3
|
-
|
|
4
|
-
export function resolveActiveWorkspacePath(resourceUri: string | undefined): string | undefined {
|
|
5
|
-
if (!resourceUri) {
|
|
6
|
-
return undefined;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
const resource = parseWorkspaceResourceUri(resourceUri);
|
|
10
|
-
return resource?.kind === 'file' ? resource.path : undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function useActiveWorkspacePath(resourceUri: string | undefined): string | undefined {
|
|
14
|
-
return useMemo(() => resolveActiveWorkspacePath(resourceUri), [resourceUri]);
|
|
15
|
-
}
|
|
1
|
+
import { useMemo } from 'react';
|
|
2
|
+
import { parseWorkspaceResourceUri } from '@workbench-kit/workspace';
|
|
3
|
+
|
|
4
|
+
export function resolveActiveWorkspacePath(resourceUri: string | undefined): string | undefined {
|
|
5
|
+
if (!resourceUri) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const resource = parseWorkspaceResourceUri(resourceUri);
|
|
10
|
+
return resource?.kind === 'file' ? resource.path : undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function useActiveWorkspacePath(resourceUri: string | undefined): string | undefined {
|
|
14
|
+
return useMemo(() => resolveActiveWorkspacePath(resourceUri), [resourceUri]);
|
|
15
|
+
}
|
|
@@ -1,58 +1,58 @@
|
|
|
1
|
-
export const BUILTIN_EXPLORER_VIEW_RENDER_KIND = 'workbench-kit.builtin.explorer.view' as const;
|
|
2
|
-
export const BUILTIN_EXPLORER_VIEW_CONTAINER_ID = 'explorer' as const;
|
|
3
|
-
export const BUILTIN_EXPLORER_MOVE_COMMAND_ID = 'workbench-kit.builtin.explorer.move' as const;
|
|
4
|
-
export const BUILTIN_EXPLORER_REFRESH_COMMAND_ID =
|
|
5
|
-
'workbench-kit.builtin.explorer.refresh' as const;
|
|
6
|
-
export const BUILTIN_EXPLORER_REVEAL_COMMAND_ID = 'workbench-kit.builtin.explorer.reveal' as const;
|
|
7
|
-
export const BUILTIN_EXPLORER_FOCUS_COMMAND_ID = 'workbench-kit.builtin.explorer.focus' as const;
|
|
8
|
-
|
|
9
|
-
interface ExplorerRevealCommandResult {
|
|
10
|
-
readonly path?: string | undefined;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export interface BuiltinExplorerViewRenderData {
|
|
14
|
-
readonly kind: typeof BUILTIN_EXPLORER_VIEW_RENDER_KIND;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export function isBuiltinExplorerViewRenderData(
|
|
18
|
-
value: unknown,
|
|
19
|
-
): value is BuiltinExplorerViewRenderData {
|
|
20
|
-
return (
|
|
21
|
-
typeof value === 'object' &&
|
|
22
|
-
value !== null &&
|
|
23
|
-
(value as { kind?: unknown }).kind === BUILTIN_EXPLORER_VIEW_RENDER_KIND
|
|
24
|
-
);
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
export function resolveExplorerRevealPath(input: unknown, result: unknown): string | undefined {
|
|
28
|
-
const resultPath = readRevealPath(result);
|
|
29
|
-
if (resultPath) {
|
|
30
|
-
return resultPath;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return readRevealPath(input);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
function readRevealPath(value: unknown): string | undefined {
|
|
37
|
-
if (typeof value === 'string') {
|
|
38
|
-
const normalizedPath = value.trim();
|
|
39
|
-
return normalizedPath.length > 0 ? normalizedPath : undefined;
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
if (typeof value !== 'object' || value === null) {
|
|
43
|
-
return undefined;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
const record = value as ExplorerRevealCommandResult & {
|
|
47
|
-
paths?: readonly string[] | undefined;
|
|
48
|
-
};
|
|
49
|
-
const directPath = typeof record.path === 'string' ? record.path.trim() : '';
|
|
50
|
-
if (directPath) {
|
|
51
|
-
return directPath;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
const firstPath = record.paths?.find(
|
|
55
|
-
(path) => typeof path === 'string' && path.trim().length > 0,
|
|
56
|
-
);
|
|
57
|
-
return firstPath?.trim();
|
|
58
|
-
}
|
|
1
|
+
export const BUILTIN_EXPLORER_VIEW_RENDER_KIND = 'workbench-kit.builtin.explorer.view' as const;
|
|
2
|
+
export const BUILTIN_EXPLORER_VIEW_CONTAINER_ID = 'explorer' as const;
|
|
3
|
+
export const BUILTIN_EXPLORER_MOVE_COMMAND_ID = 'workbench-kit.builtin.explorer.move' as const;
|
|
4
|
+
export const BUILTIN_EXPLORER_REFRESH_COMMAND_ID =
|
|
5
|
+
'workbench-kit.builtin.explorer.refresh' as const;
|
|
6
|
+
export const BUILTIN_EXPLORER_REVEAL_COMMAND_ID = 'workbench-kit.builtin.explorer.reveal' as const;
|
|
7
|
+
export const BUILTIN_EXPLORER_FOCUS_COMMAND_ID = 'workbench-kit.builtin.explorer.focus' as const;
|
|
8
|
+
|
|
9
|
+
interface ExplorerRevealCommandResult {
|
|
10
|
+
readonly path?: string | undefined;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export interface BuiltinExplorerViewRenderData {
|
|
14
|
+
readonly kind: typeof BUILTIN_EXPLORER_VIEW_RENDER_KIND;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function isBuiltinExplorerViewRenderData(
|
|
18
|
+
value: unknown,
|
|
19
|
+
): value is BuiltinExplorerViewRenderData {
|
|
20
|
+
return (
|
|
21
|
+
typeof value === 'object' &&
|
|
22
|
+
value !== null &&
|
|
23
|
+
(value as { kind?: unknown }).kind === BUILTIN_EXPLORER_VIEW_RENDER_KIND
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function resolveExplorerRevealPath(input: unknown, result: unknown): string | undefined {
|
|
28
|
+
const resultPath = readRevealPath(result);
|
|
29
|
+
if (resultPath) {
|
|
30
|
+
return resultPath;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return readRevealPath(input);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function readRevealPath(value: unknown): string | undefined {
|
|
37
|
+
if (typeof value === 'string') {
|
|
38
|
+
const normalizedPath = value.trim();
|
|
39
|
+
return normalizedPath.length > 0 ? normalizedPath : undefined;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
if (typeof value !== 'object' || value === null) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const record = value as ExplorerRevealCommandResult & {
|
|
47
|
+
paths?: readonly string[] | undefined;
|
|
48
|
+
};
|
|
49
|
+
const directPath = typeof record.path === 'string' ? record.path.trim() : '';
|
|
50
|
+
if (directPath) {
|
|
51
|
+
return directPath;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
const firstPath = record.paths?.find(
|
|
55
|
+
(path) => typeof path === 'string' && path.trim().length > 0,
|
|
56
|
+
);
|
|
57
|
+
return firstPath?.trim();
|
|
58
|
+
}
|