@workbench-kit/shell-react 0.0.2-prototype.0.2.6
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/package.json +49 -0
- package/src/chat-ai-mock-proposals.ts +39 -0
- package/src/chat-command-input.ts +52 -0
- package/src/chat-command-policy.ts +54 -0
- package/src/chat-command-surface.tsx +155 -0
- package/src/chat-view-data.ts +20 -0
- package/src/chat-view.tsx +220 -0
- package/src/command-inspector-surface.tsx +46 -0
- package/src/commands-view-data.ts +17 -0
- package/src/commands-view.tsx +43 -0
- package/src/createCommandWorkspaceExplorerPort.ts +86 -0
- package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -0
- package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -0
- package/src/devtools/index.ts +11 -0
- package/src/devtools/use-workbench-devtools-snapshot.ts +84 -0
- package/src/devtools/workbench-devtools-snapshot.ts +140 -0
- package/src/devtools/workbench-devtools.css +82 -0
- package/src/editor-area-dnd.ts +69 -0
- package/src/editor-area-model.ts +71 -0
- package/src/editor-area.css +454 -0
- package/src/editor-area.tsx +676 -0
- package/src/editor-host-surface.tsx +634 -0
- package/src/editor-pane-visibility.ts +130 -0
- package/src/editor-resource.ts +36 -0
- package/src/editor-state-storage.ts +193 -0
- package/src/editor-tab-context-menu.ts +118 -0
- package/src/editor-view-providers.tsx +552 -0
- package/src/editor-workspace-file-availability.ts +15 -0
- package/src/editor-workspace-reconcile.tsx +28 -0
- package/src/explorer-context-menu.ts +114 -0
- package/src/explorer-reveal.ts +112 -0
- package/src/explorer-view-data.ts +58 -0
- package/src/explorer-view.tsx +224 -0
- package/src/extension-context-menu.ts +52 -0
- package/src/extension-management-model.ts +313 -0
- package/src/extensions-view-data.ts +19 -0
- package/src/extensions-view.tsx +38 -0
- package/src/field-remap-demo.tsx +18 -0
- package/src/field-remap-editor-surface.tsx +36 -0
- package/src/field-remap-flow-adapter.ts +240 -0
- package/src/field-remap-flow.tsx +369 -0
- package/src/field-remap-graph.tsx +559 -0
- package/src/field-remap-panel.tsx +175 -0
- package/src/field-remap-samples.ts +352 -0
- package/src/field-remap-tree.tsx +404 -0
- package/src/field-remap-view-data.ts +16 -0
- package/src/field-remap-view.css +676 -0
- package/src/field-remap-view.tsx +86 -0
- package/src/index.ts +199 -0
- package/src/jdw-lab-view-data.ts +25 -0
- package/src/jdw-lab-view.css +21 -0
- package/src/jdw-lab-view.tsx +79 -0
- package/src/jdw-widget-form-view.tsx +65 -0
- package/src/jdw-widget-preview-view.tsx +51 -0
- package/src/json-form-source-patch.ts +323 -0
- package/src/jsonata-transform.ts +36 -0
- package/src/keybinding-management-settings.tsx +16 -0
- package/src/keybinding-overrides-storage.ts +57 -0
- package/src/management-palette-commands.ts +38 -0
- package/src/management-settings-ids.ts +12 -0
- package/src/management-settings.tsx +75 -0
- package/src/preference-settings-storage.ts +58 -0
- package/src/provider.tsx +573 -0
- package/src/search-view-data.ts +15 -0
- package/src/search-view.tsx +62 -0
- package/src/shell-model.tsx +149 -0
- package/src/shell-secondary-actions.tsx +59 -0
- package/src/shell-settings-constants.ts +9 -0
- package/src/shell-settings.tsx +599 -0
- package/src/shell-titlebar-layout-controls.tsx +4 -0
- package/src/shell-view-host.tsx +199 -0
- package/src/shell.tsx +649 -0
- package/src/table-mapping-adapter.ts +59 -0
- package/src/use-active-workspace-path.ts +15 -0
- package/src/use-command-management.ts +191 -0
- package/src/use-context-key-revision.ts +18 -0
- package/src/use-editor.ts +107 -0
- package/src/use-extension-management.ts +193 -0
- package/src/use-keybinding-management.ts +130 -0
- package/src/use-persisted-workbench-appearance.ts +33 -0
- package/src/use-workbench-chat-command-proposals.ts +194 -0
- package/src/use-workbench-command-descriptors.ts +41 -0
- package/src/workbench-appearance-storage.ts +115 -0
- package/src/workbench-command-host.tsx +243 -0
- package/src/workbench-command-palette.ts +208 -0
- package/src/workbench-keybinding-bridge.ts +54 -0
- package/src/workbench-layout-storage.ts +145 -0
- package/src/workbench-profile-modal.tsx +118 -0
- package/src/workbench-shell-command-registration.ts +58 -0
- package/src/workbench-startup-gate.tsx +136 -0
- package/src/workbench-status-sections.ts +43 -0
- package/src/workbench-user-commands.ts +46 -0
- package/src/workspace-view-state.ts +35 -0
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import { isValidElement, useEffect, useMemo, useRef, type FocusEvent, type ReactNode } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
ExtensionRegistry,
|
|
4
|
+
ViewHost,
|
|
5
|
+
ViewHostFactoryRegistry,
|
|
6
|
+
ViewProvider,
|
|
7
|
+
} from '@workbench-kit/workbench-core';
|
|
8
|
+
|
|
9
|
+
import { BuiltinChatView } from './chat-view.js';
|
|
10
|
+
import { isBuiltinChatViewRenderData } from './chat-view-data.js';
|
|
11
|
+
import { BuiltinCommandsView } from './commands-view.js';
|
|
12
|
+
import { isBuiltinCommandsViewRenderData } from './commands-view-data.js';
|
|
13
|
+
import { BuiltinExplorerView } from './explorer-view.js';
|
|
14
|
+
import { isBuiltinExplorerViewRenderData } from './explorer-view-data.js';
|
|
15
|
+
import { BuiltinExtensionsView } from './extensions-view.js';
|
|
16
|
+
import { isBuiltinExtensionsViewRenderData } from './extensions-view-data.js';
|
|
17
|
+
import { SampleJdwLabView } from './jdw-lab-view.js';
|
|
18
|
+
import { isSampleJdwLabViewRenderData } from './jdw-lab-view-data.js';
|
|
19
|
+
import { SampleFieldRemapView } from './field-remap-view.js';
|
|
20
|
+
import { isSampleFieldRemapViewRenderData } from './field-remap-view-data.js';
|
|
21
|
+
import { BuiltinSearchView } from './search-view.js';
|
|
22
|
+
import { isBuiltinSearchViewRenderData } from './search-view-data.js';
|
|
23
|
+
|
|
24
|
+
export function renderDefaultPrimarySidebar(
|
|
25
|
+
extensionRegistry: Pick<ExtensionRegistry, 'viewHostFactories' | 'views'>,
|
|
26
|
+
activeViewContainerId: string | undefined,
|
|
27
|
+
catalogUrl?: string | undefined,
|
|
28
|
+
) {
|
|
29
|
+
const views = activeViewContainerId
|
|
30
|
+
? extensionRegistry.views.getViews(activeViewContainerId)
|
|
31
|
+
: extensionRegistry.views.getViews();
|
|
32
|
+
if (views.length === 0) {
|
|
33
|
+
return <aside aria-label="Primary sidebar" />;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return (
|
|
37
|
+
<aside
|
|
38
|
+
aria-label="Primary sidebar"
|
|
39
|
+
className="workbench-primary-side-bar shell-react-primary-sidebar"
|
|
40
|
+
>
|
|
41
|
+
{views.map((view) => (
|
|
42
|
+
<section key={view.id} data-view-id={view.id}>
|
|
43
|
+
<WorkbenchViewHost
|
|
44
|
+
catalogUrl={catalogUrl}
|
|
45
|
+
fallback={view.name}
|
|
46
|
+
provider={extensionRegistry.views.getViewProvider(view.id)}
|
|
47
|
+
viewHostFactories={extensionRegistry.viewHostFactories}
|
|
48
|
+
viewId={view.id}
|
|
49
|
+
/>
|
|
50
|
+
</section>
|
|
51
|
+
))}
|
|
52
|
+
</aside>
|
|
53
|
+
);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
export function WorkbenchViewHost({
|
|
57
|
+
catalogUrl,
|
|
58
|
+
fallback,
|
|
59
|
+
provider,
|
|
60
|
+
viewHostFactories,
|
|
61
|
+
viewId,
|
|
62
|
+
}: {
|
|
63
|
+
catalogUrl?: string | undefined;
|
|
64
|
+
fallback: ReactNode;
|
|
65
|
+
provider: ViewProvider | undefined;
|
|
66
|
+
viewHostFactories: ViewHostFactoryRegistry;
|
|
67
|
+
viewId: string;
|
|
68
|
+
}) {
|
|
69
|
+
const hostFrameRef = useRef<HTMLDivElement>(null);
|
|
70
|
+
const host = useMemo(() => {
|
|
71
|
+
if (!provider) {
|
|
72
|
+
return undefined;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
return viewHostFactories.createViewHost({ viewId, provider });
|
|
76
|
+
}, [provider, viewHostFactories, viewId]);
|
|
77
|
+
|
|
78
|
+
useEffect(() => {
|
|
79
|
+
if (!host) {
|
|
80
|
+
return undefined;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
host.onDidShow?.();
|
|
84
|
+
|
|
85
|
+
const resizeObserver =
|
|
86
|
+
typeof ResizeObserver !== 'undefined' && host.onDidResize
|
|
87
|
+
? new ResizeObserver((entries) => {
|
|
88
|
+
const entry = entries[0];
|
|
89
|
+
if (!entry) return;
|
|
90
|
+
|
|
91
|
+
host.onDidResize?.({
|
|
92
|
+
height: entry.contentRect.height,
|
|
93
|
+
width: entry.contentRect.width,
|
|
94
|
+
});
|
|
95
|
+
})
|
|
96
|
+
: undefined;
|
|
97
|
+
|
|
98
|
+
if (resizeObserver && hostFrameRef.current) {
|
|
99
|
+
resizeObserver.observe(hostFrameRef.current);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return () => {
|
|
103
|
+
resizeObserver?.disconnect();
|
|
104
|
+
host.onDidHide?.();
|
|
105
|
+
host.dispose();
|
|
106
|
+
};
|
|
107
|
+
}, [host]);
|
|
108
|
+
|
|
109
|
+
if (!host) {
|
|
110
|
+
return <>{fallback}</>;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
return (
|
|
114
|
+
<div
|
|
115
|
+
ref={hostFrameRef}
|
|
116
|
+
aria-label={host.title}
|
|
117
|
+
data-view-host-id={host.id ?? provider?.viewId}
|
|
118
|
+
onBlur={(event) => notifyViewHostBlur(host, event)}
|
|
119
|
+
onFocus={(event) => notifyViewHostFocus(host, event)}
|
|
120
|
+
>
|
|
121
|
+
{toWorkbenchViewHostReactNode(host.render(), fallback, { catalogUrl })}
|
|
122
|
+
</div>
|
|
123
|
+
);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
export function notifyViewHostFocus(host: ViewHost, event: FocusEvent<HTMLDivElement>): void {
|
|
127
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
128
|
+
host.onDidFocus?.();
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function notifyViewHostBlur(host: ViewHost, event: FocusEvent<HTMLDivElement>): void {
|
|
133
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
134
|
+
host.onDidBlur?.();
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
export function toReactNode(value: unknown, fallback: ReactNode): ReactNode {
|
|
139
|
+
if (
|
|
140
|
+
value === undefined ||
|
|
141
|
+
value === null ||
|
|
142
|
+
typeof value === 'boolean' ||
|
|
143
|
+
typeof value === 'symbol' ||
|
|
144
|
+
typeof value === 'function'
|
|
145
|
+
) {
|
|
146
|
+
return fallback;
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (typeof value === 'string' || typeof value === 'number' || isValidElement(value)) {
|
|
150
|
+
return value;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (Array.isArray(value)) {
|
|
154
|
+
return value as ReactNode;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
return fallback;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
export function toWorkbenchViewHostReactNode(
|
|
161
|
+
value: unknown,
|
|
162
|
+
fallback: ReactNode,
|
|
163
|
+
options: { catalogUrl?: string | undefined } = {},
|
|
164
|
+
): ReactNode {
|
|
165
|
+
if (isBuiltinExplorerViewRenderData(value)) {
|
|
166
|
+
return <BuiltinExplorerView />;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
if (isBuiltinChatViewRenderData(value)) {
|
|
170
|
+
return <BuiltinChatView mode={value.mode} />;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (isBuiltinSearchViewRenderData(value)) {
|
|
174
|
+
return <BuiltinSearchView />;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (isBuiltinCommandsViewRenderData(value)) {
|
|
178
|
+
return <BuiltinCommandsView />;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (isBuiltinExtensionsViewRenderData(value)) {
|
|
182
|
+
return <BuiltinExtensionsView catalogUrl={options.catalogUrl} />;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (isSampleJdwLabViewRenderData(value)) {
|
|
186
|
+
return (
|
|
187
|
+
<SampleJdwLabView
|
|
188
|
+
templateJdwPath={value.templateJdwPath}
|
|
189
|
+
widgetTreePath={value.widgetTreePath}
|
|
190
|
+
/>
|
|
191
|
+
);
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (isSampleFieldRemapViewRenderData(value)) {
|
|
195
|
+
return <SampleFieldRemapView />;
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return toReactNode(value, fallback);
|
|
199
|
+
}
|