@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,4 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
WorkbenchShellTitleBarLayoutControls,
|
|
3
|
-
type WorkbenchShellTitleBarLayoutControlsProps,
|
|
4
|
-
} from '@workbench-kit/react/workbench/shell';
|
|
1
|
+
export {
|
|
2
|
+
WorkbenchShellTitleBarLayoutControls,
|
|
3
|
+
type WorkbenchShellTitleBarLayoutControlsProps,
|
|
4
|
+
} from '@workbench-kit/react/workbench/shell';
|
|
@@ -1,199 +1,212 @@
|
|
|
1
|
-
import { isValidElement, useEffect, useMemo, useRef, type FocusEvent, type ReactNode } from 'react';
|
|
2
|
-
import type {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import {
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import {
|
|
19
|
-
import {
|
|
20
|
-
import {
|
|
21
|
-
import {
|
|
22
|
-
import {
|
|
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
|
-
fallback
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
|
|
173
|
-
if (
|
|
174
|
-
return <
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
if (
|
|
178
|
-
return <
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
if (
|
|
182
|
-
return <
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
if (
|
|
186
|
-
return
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
1
|
+
import { isValidElement, useEffect, useMemo, useRef, type FocusEvent, type ReactNode } from 'react';
|
|
2
|
+
import type {
|
|
3
|
+
ExtensionCatalogTrustPolicy,
|
|
4
|
+
ExtensionRegistry,
|
|
5
|
+
ViewHost,
|
|
6
|
+
ViewHostFactoryRegistry,
|
|
7
|
+
ViewProvider,
|
|
8
|
+
} from '@workbench-kit/workbench-core';
|
|
9
|
+
|
|
10
|
+
import { BuiltinChatView } from '../chat/view.js';
|
|
11
|
+
import { isBuiltinChatViewRenderData } from '../chat/view-data.js';
|
|
12
|
+
import { BuiltinCommandsView } from '../commands/view.js';
|
|
13
|
+
import { isBuiltinCommandsViewRenderData } from '../commands/view-data.js';
|
|
14
|
+
import { BuiltinExplorerView } from '../explorer/view.js';
|
|
15
|
+
import { isBuiltinExplorerViewRenderData } from '../explorer/view-data.js';
|
|
16
|
+
import { BuiltinExtensionsView } from '../extensions/view.js';
|
|
17
|
+
import { isBuiltinExtensionsViewRenderData } from '../extensions/view-data.js';
|
|
18
|
+
import { SampleJdwLabView } from '../jdw/lab-view.js';
|
|
19
|
+
import { isSampleJdwLabViewRenderData } from '../jdw/lab-view-data.js';
|
|
20
|
+
import { SampleFieldRemapView } from '../field-remap/view.js';
|
|
21
|
+
import { isSampleFieldRemapViewRenderData } from '../field-remap/view-data.js';
|
|
22
|
+
import { BuiltinSearchView } from '../explorer/search-view.js';
|
|
23
|
+
import { isBuiltinSearchViewRenderData } from '../explorer/search-view-data.js';
|
|
24
|
+
|
|
25
|
+
export function renderDefaultPrimarySidebar(
|
|
26
|
+
extensionRegistry: Pick<ExtensionRegistry, 'viewHostFactories' | 'views'>,
|
|
27
|
+
activeViewContainerId: string | undefined,
|
|
28
|
+
catalogUrl?: string | undefined,
|
|
29
|
+
catalogTrustPolicy?: ExtensionCatalogTrustPolicy | undefined,
|
|
30
|
+
) {
|
|
31
|
+
const views = activeViewContainerId
|
|
32
|
+
? extensionRegistry.views.getViews(activeViewContainerId)
|
|
33
|
+
: extensionRegistry.views.getViews();
|
|
34
|
+
if (views.length === 0) {
|
|
35
|
+
return <aside aria-label="Primary sidebar" />;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<aside
|
|
40
|
+
aria-label="Primary sidebar"
|
|
41
|
+
className="workbench-primary-side-bar shell-react-primary-sidebar"
|
|
42
|
+
>
|
|
43
|
+
{views.map((view) => (
|
|
44
|
+
<section key={view.id} data-view-id={view.id}>
|
|
45
|
+
<WorkbenchViewHost
|
|
46
|
+
catalogTrustPolicy={catalogTrustPolicy}
|
|
47
|
+
catalogUrl={catalogUrl}
|
|
48
|
+
fallback={view.name}
|
|
49
|
+
provider={extensionRegistry.views.getViewProvider(view.id)}
|
|
50
|
+
viewHostFactories={extensionRegistry.viewHostFactories}
|
|
51
|
+
viewId={view.id}
|
|
52
|
+
/>
|
|
53
|
+
</section>
|
|
54
|
+
))}
|
|
55
|
+
</aside>
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function WorkbenchViewHost({
|
|
60
|
+
catalogTrustPolicy,
|
|
61
|
+
catalogUrl,
|
|
62
|
+
fallback,
|
|
63
|
+
provider,
|
|
64
|
+
viewHostFactories,
|
|
65
|
+
viewId,
|
|
66
|
+
}: {
|
|
67
|
+
catalogTrustPolicy?: ExtensionCatalogTrustPolicy | undefined;
|
|
68
|
+
catalogUrl?: string | undefined;
|
|
69
|
+
fallback: ReactNode;
|
|
70
|
+
provider: ViewProvider | undefined;
|
|
71
|
+
viewHostFactories: ViewHostFactoryRegistry;
|
|
72
|
+
viewId: string;
|
|
73
|
+
}) {
|
|
74
|
+
const hostFrameRef = useRef<HTMLDivElement>(null);
|
|
75
|
+
const host = useMemo(() => {
|
|
76
|
+
if (!provider) {
|
|
77
|
+
return undefined;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return viewHostFactories.createViewHost({ viewId, provider });
|
|
81
|
+
}, [provider, viewHostFactories, viewId]);
|
|
82
|
+
|
|
83
|
+
useEffect(() => {
|
|
84
|
+
if (!host) {
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
host.onDidShow?.();
|
|
89
|
+
|
|
90
|
+
const resizeObserver =
|
|
91
|
+
typeof ResizeObserver !== 'undefined' && host.onDidResize
|
|
92
|
+
? new ResizeObserver((entries) => {
|
|
93
|
+
const entry = entries[0];
|
|
94
|
+
if (!entry) return;
|
|
95
|
+
|
|
96
|
+
host.onDidResize?.({
|
|
97
|
+
height: entry.contentRect.height,
|
|
98
|
+
width: entry.contentRect.width,
|
|
99
|
+
});
|
|
100
|
+
})
|
|
101
|
+
: undefined;
|
|
102
|
+
|
|
103
|
+
if (resizeObserver && hostFrameRef.current) {
|
|
104
|
+
resizeObserver.observe(hostFrameRef.current);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
return () => {
|
|
108
|
+
resizeObserver?.disconnect();
|
|
109
|
+
host.onDidHide?.();
|
|
110
|
+
host.dispose();
|
|
111
|
+
};
|
|
112
|
+
}, [host]);
|
|
113
|
+
|
|
114
|
+
if (!host) {
|
|
115
|
+
return <>{fallback}</>;
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
return (
|
|
119
|
+
<div
|
|
120
|
+
ref={hostFrameRef}
|
|
121
|
+
aria-label={host.title}
|
|
122
|
+
data-view-host-id={host.id ?? provider?.viewId}
|
|
123
|
+
onBlur={(event) => notifyViewHostBlur(host, event)}
|
|
124
|
+
onFocus={(event) => notifyViewHostFocus(host, event)}
|
|
125
|
+
>
|
|
126
|
+
{toWorkbenchViewHostReactNode(host.render(), fallback, { catalogTrustPolicy, catalogUrl })}
|
|
127
|
+
</div>
|
|
128
|
+
);
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
export function notifyViewHostFocus(host: ViewHost, event: FocusEvent<HTMLDivElement>): void {
|
|
132
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
133
|
+
host.onDidFocus?.();
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
export function notifyViewHostBlur(host: ViewHost, event: FocusEvent<HTMLDivElement>): void {
|
|
138
|
+
if (!event.currentTarget.contains(event.relatedTarget)) {
|
|
139
|
+
host.onDidBlur?.();
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
export function toReactNode(value: unknown, fallback: ReactNode): ReactNode {
|
|
144
|
+
if (
|
|
145
|
+
value === undefined ||
|
|
146
|
+
value === null ||
|
|
147
|
+
typeof value === 'boolean' ||
|
|
148
|
+
typeof value === 'symbol' ||
|
|
149
|
+
typeof value === 'function'
|
|
150
|
+
) {
|
|
151
|
+
return fallback;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
if (typeof value === 'string' || typeof value === 'number' || isValidElement(value)) {
|
|
155
|
+
return value;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (Array.isArray(value)) {
|
|
159
|
+
return value as ReactNode;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return fallback;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
export function toWorkbenchViewHostReactNode(
|
|
166
|
+
value: unknown,
|
|
167
|
+
fallback: ReactNode,
|
|
168
|
+
options: {
|
|
169
|
+
catalogTrustPolicy?: ExtensionCatalogTrustPolicy | undefined;
|
|
170
|
+
catalogUrl?: string | undefined;
|
|
171
|
+
} = {},
|
|
172
|
+
): ReactNode {
|
|
173
|
+
if (isBuiltinExplorerViewRenderData(value)) {
|
|
174
|
+
return <BuiltinExplorerView />;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
if (isBuiltinChatViewRenderData(value)) {
|
|
178
|
+
return <BuiltinChatView mode={value.mode} />;
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
if (isBuiltinSearchViewRenderData(value)) {
|
|
182
|
+
return <BuiltinSearchView />;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (isBuiltinCommandsViewRenderData(value)) {
|
|
186
|
+
return <BuiltinCommandsView />;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
if (isBuiltinExtensionsViewRenderData(value)) {
|
|
190
|
+
return (
|
|
191
|
+
<BuiltinExtensionsView
|
|
192
|
+
catalogTrustPolicy={options.catalogTrustPolicy}
|
|
193
|
+
catalogUrl={options.catalogUrl}
|
|
194
|
+
/>
|
|
195
|
+
);
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
if (isSampleJdwLabViewRenderData(value)) {
|
|
199
|
+
return (
|
|
200
|
+
<SampleJdwLabView
|
|
201
|
+
templateJdwPath={value.templateJdwPath}
|
|
202
|
+
widgetTreePath={value.widgetTreePath}
|
|
203
|
+
/>
|
|
204
|
+
);
|
|
205
|
+
}
|
|
206
|
+
|
|
207
|
+
if (isSampleFieldRemapViewRenderData(value)) {
|
|
208
|
+
return <SampleFieldRemapView />;
|
|
209
|
+
}
|
|
210
|
+
|
|
211
|
+
return toReactNode(value, fallback);
|
|
212
|
+
}
|
|
@@ -1,115 +1,107 @@
|
|
|
1
|
-
import {
|
|
2
|
-
DEFAULT_DARK_THEME_PRESET,
|
|
3
|
-
DEFAULT_LIGHT_THEME_PRESET,
|
|
4
|
-
DEFAULT_SHELL_PRESET,
|
|
5
|
-
isShellPresetId,
|
|
6
|
-
type WorkbenchAppearanceSettings,
|
|
7
|
-
type WorkbenchColorSchemePreference,
|
|
8
|
-
} from '@workbench-kit/react/workbench';
|
|
9
|
-
import
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
export
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
}
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
export function readPersistedWorkbenchAppearance(
|
|
31
|
-
storageKey = DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY,
|
|
32
|
-
storage?: WorkbenchStorageReader,
|
|
33
|
-
): WorkbenchAppearanceSettings {
|
|
34
|
-
const resolvedStorage = storage ??
|
|
35
|
-
if (!resolvedStorage) {
|
|
36
|
-
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
try {
|
|
40
|
-
const raw = resolvedStorage.getItem(storageKey);
|
|
41
|
-
if (!raw) {
|
|
42
|
-
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return normalizeWorkbenchAppearance(JSON.parse(raw) as unknown);
|
|
46
|
-
} catch {
|
|
47
|
-
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
48
|
-
}
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
export function writePersistedWorkbenchAppearance(
|
|
52
|
-
settings: WorkbenchAppearanceSettings,
|
|
53
|
-
storageKey = DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY,
|
|
54
|
-
storage?: WorkbenchStorageWriter,
|
|
55
|
-
): void {
|
|
56
|
-
const resolvedStorage = storage ??
|
|
57
|
-
if (!resolvedStorage) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
try {
|
|
62
|
-
resolvedStorage.setItem(storageKey, JSON.stringify(settings, null, 2));
|
|
63
|
-
} catch {
|
|
64
|
-
// Ignore quota and security errors so the shell keeps working offline.
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
function normalizeWorkbenchAppearance(value: unknown): WorkbenchAppearanceSettings {
|
|
69
|
-
if (typeof value !== 'object' || value === null) {
|
|
70
|
-
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const record = value as Record<string, unknown>;
|
|
74
|
-
const themePreference = normalizeThemePreference(record.themePreference);
|
|
75
|
-
// Preset ids may belong to a contributed theme, which isn't known until extensions
|
|
76
|
-
// register, so we can only validate shape here; the appearance UI falls back to a
|
|
77
|
-
// default option if the persisted id no longer resolves to anything.
|
|
78
|
-
const lightPreset = normalizePresetId(
|
|
79
|
-
record.lightPreset,
|
|
80
|
-
DEFAULT_WORKBENCH_APPEARANCE.lightPreset,
|
|
81
|
-
);
|
|
82
|
-
const darkPreset = normalizePresetId(record.darkPreset, DEFAULT_WORKBENCH_APPEARANCE.darkPreset);
|
|
83
|
-
const shellPreset = normalizeShellPresetId(record.shellPreset);
|
|
84
|
-
|
|
85
|
-
return {
|
|
86
|
-
darkPreset,
|
|
87
|
-
lightPreset,
|
|
88
|
-
shellPreset,
|
|
89
|
-
themePreference,
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
|
|
93
|
-
function normalizeShellPresetId(value: unknown): string {
|
|
94
|
-
return typeof value === 'string' && isShellPresetId(value) ? value : DEFAULT_SHELL_PRESET;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
function normalizePresetId(value: unknown, fallback: string): string {
|
|
98
|
-
return typeof value === 'string' && value.length > 0 ? value : fallback;
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
function normalizeThemePreference(value: unknown): WorkbenchColorSchemePreference {
|
|
102
|
-
if (value === 'system' || value === 'light' || value === 'dark') {
|
|
103
|
-
return value;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return DEFAULT_WORKBENCH_APPEARANCE.themePreference;
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
function getBrowserLocalStorage(): (WorkbenchStorageReader & WorkbenchStorageWriter) | undefined {
|
|
110
|
-
if (!isWorkbenchAppearancePersistenceAvailable()) {
|
|
111
|
-
return undefined;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
return globalThis.localStorage;
|
|
115
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
DEFAULT_DARK_THEME_PRESET,
|
|
3
|
+
DEFAULT_LIGHT_THEME_PRESET,
|
|
4
|
+
DEFAULT_SHELL_PRESET,
|
|
5
|
+
isShellPresetId,
|
|
6
|
+
type WorkbenchAppearanceSettings,
|
|
7
|
+
type WorkbenchColorSchemePreference,
|
|
8
|
+
} from '@workbench-kit/react/workbench';
|
|
9
|
+
import {
|
|
10
|
+
createBrowserWorkbenchStorage,
|
|
11
|
+
type WorkbenchStorageReader,
|
|
12
|
+
type WorkbenchStorageWriter,
|
|
13
|
+
} from '@workbench-kit/workbench-core';
|
|
14
|
+
|
|
15
|
+
export type { WorkbenchAppearanceSettings } from '@workbench-kit/react/workbench/themePresets';
|
|
16
|
+
|
|
17
|
+
export const DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY = 'workbench-kit/.workbench/appearance';
|
|
18
|
+
|
|
19
|
+
export const DEFAULT_WORKBENCH_APPEARANCE: WorkbenchAppearanceSettings = {
|
|
20
|
+
darkPreset: DEFAULT_DARK_THEME_PRESET,
|
|
21
|
+
lightPreset: DEFAULT_LIGHT_THEME_PRESET,
|
|
22
|
+
shellPreset: DEFAULT_SHELL_PRESET,
|
|
23
|
+
themePreference: 'system',
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export function isWorkbenchAppearancePersistenceAvailable(): boolean {
|
|
27
|
+
return createBrowserWorkbenchStorage({ kind: 'local' }) !== undefined;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function readPersistedWorkbenchAppearance(
|
|
31
|
+
storageKey = DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY,
|
|
32
|
+
storage?: WorkbenchStorageReader,
|
|
33
|
+
): WorkbenchAppearanceSettings {
|
|
34
|
+
const resolvedStorage = storage ?? createBrowserWorkbenchStorage({ kind: 'local' });
|
|
35
|
+
if (!resolvedStorage) {
|
|
36
|
+
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
try {
|
|
40
|
+
const raw = resolvedStorage.getItem(storageKey);
|
|
41
|
+
if (!raw) {
|
|
42
|
+
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
return normalizeWorkbenchAppearance(JSON.parse(raw) as unknown);
|
|
46
|
+
} catch {
|
|
47
|
+
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export function writePersistedWorkbenchAppearance(
|
|
52
|
+
settings: WorkbenchAppearanceSettings,
|
|
53
|
+
storageKey = DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY,
|
|
54
|
+
storage?: WorkbenchStorageWriter,
|
|
55
|
+
): void {
|
|
56
|
+
const resolvedStorage = storage ?? createBrowserWorkbenchStorage({ kind: 'local' });
|
|
57
|
+
if (!resolvedStorage) {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
try {
|
|
62
|
+
resolvedStorage.setItem(storageKey, JSON.stringify(settings, null, 2));
|
|
63
|
+
} catch {
|
|
64
|
+
// Ignore quota and security errors so the shell keeps working offline.
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function normalizeWorkbenchAppearance(value: unknown): WorkbenchAppearanceSettings {
|
|
69
|
+
if (typeof value !== 'object' || value === null) {
|
|
70
|
+
return DEFAULT_WORKBENCH_APPEARANCE;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
const record = value as Record<string, unknown>;
|
|
74
|
+
const themePreference = normalizeThemePreference(record.themePreference);
|
|
75
|
+
// Preset ids may belong to a contributed theme, which isn't known until extensions
|
|
76
|
+
// register, so we can only validate shape here; the appearance UI falls back to a
|
|
77
|
+
// default option if the persisted id no longer resolves to anything.
|
|
78
|
+
const lightPreset = normalizePresetId(
|
|
79
|
+
record.lightPreset,
|
|
80
|
+
DEFAULT_WORKBENCH_APPEARANCE.lightPreset,
|
|
81
|
+
);
|
|
82
|
+
const darkPreset = normalizePresetId(record.darkPreset, DEFAULT_WORKBENCH_APPEARANCE.darkPreset);
|
|
83
|
+
const shellPreset = normalizeShellPresetId(record.shellPreset);
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
darkPreset,
|
|
87
|
+
lightPreset,
|
|
88
|
+
shellPreset,
|
|
89
|
+
themePreference,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
function normalizeShellPresetId(value: unknown): string {
|
|
94
|
+
return typeof value === 'string' && isShellPresetId(value) ? value : DEFAULT_SHELL_PRESET;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
function normalizePresetId(value: unknown, fallback: string): string {
|
|
98
|
+
return typeof value === 'string' && value.length > 0 ? value : fallback;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function normalizeThemePreference(value: unknown): WorkbenchColorSchemePreference {
|
|
102
|
+
if (value === 'system' || value === 'light' || value === 'dark') {
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return DEFAULT_WORKBENCH_APPEARANCE.themePreference;
|
|
107
|
+
}
|