@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,86 @@
|
|
|
1
|
+
import type { JSX } from 'react';
|
|
2
|
+
import { WorkbenchActionSidebar } from '@workbench-kit/react/layout';
|
|
3
|
+
|
|
4
|
+
import './field-remap-view.css';
|
|
5
|
+
|
|
6
|
+
import {
|
|
7
|
+
FIELD_REMAP_SAMPLES,
|
|
8
|
+
resolveFieldRemapSampleId,
|
|
9
|
+
type FieldRemapSampleId,
|
|
10
|
+
} from './field-remap-samples.js';
|
|
11
|
+
import {
|
|
12
|
+
isSampleFieldRemapViewRenderData,
|
|
13
|
+
SAMPLE_FIELD_REMAP_VIEW_RENDER_KIND,
|
|
14
|
+
type SampleFieldRemapViewRenderData,
|
|
15
|
+
} from './field-remap-view-data.js';
|
|
16
|
+
import { useActiveEditorTab, useEditorService } from './use-editor.js';
|
|
17
|
+
|
|
18
|
+
export type { SampleFieldRemapViewRenderData };
|
|
19
|
+
export { isSampleFieldRemapViewRenderData, SAMPLE_FIELD_REMAP_VIEW_RENDER_KIND };
|
|
20
|
+
|
|
21
|
+
const FIELD_REMAP_URI_PREFIX = 'workbench://field-remap/' as const;
|
|
22
|
+
|
|
23
|
+
export function buildFieldRemapEditorUri(sampleId: FieldRemapSampleId | string): string {
|
|
24
|
+
return `${FIELD_REMAP_URI_PREFIX}${encodeURIComponent(sampleId)}`;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
export function parseFieldRemapEditorSampleId(resourceUri: string): FieldRemapSampleId | undefined {
|
|
28
|
+
if (!resourceUri.startsWith(FIELD_REMAP_URI_PREFIX)) {
|
|
29
|
+
return undefined;
|
|
30
|
+
}
|
|
31
|
+
const encodedId = resourceUri.slice(FIELD_REMAP_URI_PREFIX.length);
|
|
32
|
+
if (!encodedId) {
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
try {
|
|
36
|
+
return resolveFieldRemapSampleId(decodeURIComponent(encodedId));
|
|
37
|
+
} catch {
|
|
38
|
+
return undefined;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface SampleFieldRemapViewProps {
|
|
43
|
+
readonly className?: string | undefined;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
/** Sidebar: catalog of field-remap / table-mapping samples. */
|
|
47
|
+
export function SampleFieldRemapView({ className }: SampleFieldRemapViewProps = {}): JSX.Element {
|
|
48
|
+
const editorService = useEditorService();
|
|
49
|
+
const activeTab = useActiveEditorTab();
|
|
50
|
+
const activeSampleId = activeTab
|
|
51
|
+
? parseFieldRemapEditorSampleId(activeTab.resourceUri)
|
|
52
|
+
: undefined;
|
|
53
|
+
|
|
54
|
+
return (
|
|
55
|
+
<WorkbenchActionSidebar
|
|
56
|
+
className={['workbench-field-remap-view', className].filter(Boolean).join(' ')}
|
|
57
|
+
data-testid="field-remap-view"
|
|
58
|
+
items={FIELD_REMAP_SAMPLES.map((sample) => ({
|
|
59
|
+
description: sample.description,
|
|
60
|
+
icon: <i aria-hidden="true" className="codicon codicon-type-hierarchy" />,
|
|
61
|
+
id: sample.id,
|
|
62
|
+
label: sample.title,
|
|
63
|
+
selected: activeSampleId === sample.id,
|
|
64
|
+
testId: `field-remap-open-${sample.id}`,
|
|
65
|
+
title: `Open ${sample.title}`,
|
|
66
|
+
}))}
|
|
67
|
+
listProps={{
|
|
68
|
+
'aria-label': 'Field remap samples',
|
|
69
|
+
className: 'workbench-field-remap-view__list',
|
|
70
|
+
}}
|
|
71
|
+
onSelect={(item) => {
|
|
72
|
+
const sample = FIELD_REMAP_SAMPLES.find((entry) => entry.id === item.id);
|
|
73
|
+
if (!sample) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
editorService.openEditor({
|
|
77
|
+
icon: 'codicon-type-hierarchy',
|
|
78
|
+
pinned: true,
|
|
79
|
+
preview: false,
|
|
80
|
+
resourceUri: buildFieldRemapEditorUri(sample.id),
|
|
81
|
+
title: sample.title,
|
|
82
|
+
});
|
|
83
|
+
}}
|
|
84
|
+
/>
|
|
85
|
+
);
|
|
86
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
export const WORKBENCH_KIT_WORKBENCH_REACT_VERSION = '0.0.0' as const;
|
|
2
|
+
|
|
3
|
+
export {
|
|
4
|
+
WorkbenchProvider,
|
|
5
|
+
useWorkbench,
|
|
6
|
+
type WorkbenchContextValue,
|
|
7
|
+
type WorkbenchStorageAdapter,
|
|
8
|
+
type WorkbenchWorkspaceHostPort,
|
|
9
|
+
} from './provider.js';
|
|
10
|
+
export {
|
|
11
|
+
WorkbenchDevtoolsPanel,
|
|
12
|
+
WorkbenchDevtoolsShell,
|
|
13
|
+
useWorkbenchDevtoolsSnapshot,
|
|
14
|
+
type WorkbenchDevtoolsShellProps,
|
|
15
|
+
type WorkbenchDevtoolsSnapshot,
|
|
16
|
+
} from './devtools/index.js';
|
|
17
|
+
export {
|
|
18
|
+
DEFAULT_WORKBENCH_EDITOR_STATE_STORAGE_KEY,
|
|
19
|
+
isWorkbenchEditorStatePersistenceAvailable,
|
|
20
|
+
readPersistedEditorState,
|
|
21
|
+
writePersistedEditorState,
|
|
22
|
+
} from './editor-state-storage.js';
|
|
23
|
+
export {
|
|
24
|
+
DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY,
|
|
25
|
+
isWorkbenchKeybindingPersistenceAvailable,
|
|
26
|
+
readPersistedKeybindingOverrides,
|
|
27
|
+
writePersistedKeybindingOverrides,
|
|
28
|
+
} from './keybinding-overrides-storage.js';
|
|
29
|
+
export {
|
|
30
|
+
DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY,
|
|
31
|
+
isWorkbenchLocalPreferencePersistenceAvailable,
|
|
32
|
+
readPersistedLocalPreferences,
|
|
33
|
+
writePersistedLocalPreferences,
|
|
34
|
+
} from './preference-settings-storage.js';
|
|
35
|
+
export {
|
|
36
|
+
DEFAULT_WORKBENCH_LAYOUT_STORAGE_KEY,
|
|
37
|
+
isWorkbenchLayoutPersistenceAvailable,
|
|
38
|
+
readPersistedWorkbenchLayout,
|
|
39
|
+
resolvePersistedWorkbenchLayout,
|
|
40
|
+
writePersistedWorkbenchLayout,
|
|
41
|
+
} from './workbench-layout-storage.js';
|
|
42
|
+
export {
|
|
43
|
+
DEFAULT_WORKBENCH_APPEARANCE,
|
|
44
|
+
DEFAULT_WORKBENCH_APPEARANCE_STORAGE_KEY,
|
|
45
|
+
isWorkbenchAppearancePersistenceAvailable,
|
|
46
|
+
readPersistedWorkbenchAppearance,
|
|
47
|
+
writePersistedWorkbenchAppearance,
|
|
48
|
+
type WorkbenchAppearanceSettings,
|
|
49
|
+
} from './workbench-appearance-storage.js';
|
|
50
|
+
export {
|
|
51
|
+
usePersistedWorkbenchAppearance,
|
|
52
|
+
type UsePersistedWorkbenchAppearanceOptions,
|
|
53
|
+
} from './use-persisted-workbench-appearance.js';
|
|
54
|
+
export {
|
|
55
|
+
createWorkspaceResourceStatusItems,
|
|
56
|
+
mergeWorkbenchStatusSections,
|
|
57
|
+
type WorkspaceResourceStatusItemsInput,
|
|
58
|
+
} from './workbench-status-sections.js';
|
|
59
|
+
export { EditorArea, type EditorAreaProps, type EditorViewMode } from './editor-area.js';
|
|
60
|
+
export {
|
|
61
|
+
DEFAULT_EDITOR_DOCUMENT_VIEW_PROVIDERS,
|
|
62
|
+
EditorDocumentViewProviderRegistry,
|
|
63
|
+
JDW_PREVIEW_PROVIDER_ID,
|
|
64
|
+
JDW_WIDGET_FORM_PROVIDER_ID,
|
|
65
|
+
JSON_FORM_PROVIDER,
|
|
66
|
+
JSON_FORM_PROVIDER_ID,
|
|
67
|
+
createEditorDocumentViewProviderRegistry,
|
|
68
|
+
resolveEditorDocumentViewProvider,
|
|
69
|
+
resolveEditorDocumentViews,
|
|
70
|
+
type CreateEditorDocumentViewProviderRegistryOptions,
|
|
71
|
+
type EditorDocumentContext,
|
|
72
|
+
type EditorDocumentViewKind,
|
|
73
|
+
type EditorDocumentViewProvider,
|
|
74
|
+
type EditorDocumentViewRenderContext,
|
|
75
|
+
type ResolvedEditorDocumentViews,
|
|
76
|
+
} from './editor-view-providers.js';
|
|
77
|
+
export { SampleJdwLabView, type SampleJdwLabViewProps } from './jdw-lab-view.js';
|
|
78
|
+
export { JdwWidgetFormView, type JdwWidgetFormViewProps } from './jdw-widget-form-view.js';
|
|
79
|
+
export { JdwWidgetPreviewView, type JdwWidgetPreviewViewProps } from './jdw-widget-preview-view.js';
|
|
80
|
+
export {
|
|
81
|
+
isSampleJdwLabViewRenderData,
|
|
82
|
+
SAMPLE_JDW_LAB_VIEW_RENDER_KIND,
|
|
83
|
+
type SampleJdwLabViewRenderData,
|
|
84
|
+
} from './jdw-lab-view-data.js';
|
|
85
|
+
export { SampleFieldRemapDemo, type SampleFieldRemapDemoProps } from './field-remap-demo.js';
|
|
86
|
+
export { FieldRemapPanel, type FieldRemapPanelProps } from './field-remap-panel.js';
|
|
87
|
+
export { FieldRemapFlowMapper, type FieldRemapFlowMapperProps } from './field-remap-flow.js';
|
|
88
|
+
export {
|
|
89
|
+
FIELD_REMAP_SAMPLES,
|
|
90
|
+
getFieldRemapSample,
|
|
91
|
+
isFieldRemapSampleId,
|
|
92
|
+
resolveFieldRemapSampleId,
|
|
93
|
+
type FieldRemapSampleDefinition,
|
|
94
|
+
type FieldRemapSampleId,
|
|
95
|
+
} from './field-remap-samples.js';
|
|
96
|
+
export {
|
|
97
|
+
SampleFieldRemapView,
|
|
98
|
+
buildFieldRemapEditorUri,
|
|
99
|
+
parseFieldRemapEditorSampleId,
|
|
100
|
+
type SampleFieldRemapViewProps,
|
|
101
|
+
} from './field-remap-view.js';
|
|
102
|
+
export {
|
|
103
|
+
isSampleFieldRemapViewRenderData,
|
|
104
|
+
SAMPLE_FIELD_REMAP_VIEW_RENDER_KIND,
|
|
105
|
+
type SampleFieldRemapViewRenderData,
|
|
106
|
+
} from './field-remap-view-data.js';
|
|
107
|
+
export {
|
|
108
|
+
FieldRemapEditorSurface,
|
|
109
|
+
type FieldRemapEditorSurfaceId,
|
|
110
|
+
type FieldRemapEditorSurfaceProps,
|
|
111
|
+
} from './field-remap-editor-surface.js';
|
|
112
|
+
export {
|
|
113
|
+
WorkbenchShell,
|
|
114
|
+
type WorkbenchLocaleOption,
|
|
115
|
+
type WorkbenchShellProps,
|
|
116
|
+
type WorkbenchThemeOption,
|
|
117
|
+
} from './shell.js';
|
|
118
|
+
export {
|
|
119
|
+
getWorkbenchCommandPaletteShortcutLabel,
|
|
120
|
+
getWorkbenchQuickAccessShortcutLabel,
|
|
121
|
+
WORKBENCH_COMMAND_PALETTE_SHORTCUT,
|
|
122
|
+
WORKBENCH_QUICK_ACCESS_SHORTCUT,
|
|
123
|
+
buildWorkbenchPaletteCommands,
|
|
124
|
+
matchesWorkbenchCommandPaletteShortcut,
|
|
125
|
+
matchesWorkbenchQuickAccessShortcut,
|
|
126
|
+
mergeWorkbenchCommandDescriptors,
|
|
127
|
+
resolveShellCommandActivities,
|
|
128
|
+
} from './workbench-command-palette.js';
|
|
129
|
+
export { WorkbenchCommandHost, type WorkbenchCommandHostProps } from './workbench-command-host.js';
|
|
130
|
+
export { WorkbenchStartupGate, type WorkbenchStartupGateProps } from './workbench-startup-gate.js';
|
|
131
|
+
export {
|
|
132
|
+
normalizeKeybindingKeyFromEvent,
|
|
133
|
+
resolveExtensionKeybindingCommand,
|
|
134
|
+
} from './workbench-keybinding-bridge.js';
|
|
135
|
+
export {
|
|
136
|
+
parseWorkbenchChatCommandInput,
|
|
137
|
+
type WorkbenchChatCommandInputParseResult,
|
|
138
|
+
} from './chat-command-input.js';
|
|
139
|
+
export {
|
|
140
|
+
useWorkbenchChatCommandSurface,
|
|
141
|
+
type WorkbenchChatCommandRunResult,
|
|
142
|
+
type WorkbenchChatCommandSurfaceOptions,
|
|
143
|
+
} from './chat-command-surface.js';
|
|
144
|
+
export { useWorkbenchCommandDescriptors } from './use-workbench-command-descriptors.js';
|
|
145
|
+
export {
|
|
146
|
+
executeWorkbenchUserCommandAction,
|
|
147
|
+
registerWorkbenchUserCommands,
|
|
148
|
+
} from './workbench-user-commands.js';
|
|
149
|
+
export {
|
|
150
|
+
createWorkbenchHostThemeRegistration,
|
|
151
|
+
HOST_WORKBENCH_THEME_EXTENSION_ID,
|
|
152
|
+
registerHostWorkbenchThemes,
|
|
153
|
+
registerWorkbenchTheme,
|
|
154
|
+
REQUIRED_THEME_TOKEN_KEYS,
|
|
155
|
+
type RegisterWorkbenchThemeOptions,
|
|
156
|
+
type WorkbenchHostThemeMode,
|
|
157
|
+
type WorkbenchHostThemeRegistration,
|
|
158
|
+
} from '@workbench-kit/workbench-core';
|
|
159
|
+
export {
|
|
160
|
+
useActiveEditorTab,
|
|
161
|
+
useEditorDocumentViewProviders,
|
|
162
|
+
useEditorHost,
|
|
163
|
+
useEditorService,
|
|
164
|
+
useEditorState,
|
|
165
|
+
} from './use-editor.js';
|
|
166
|
+
export { isWorkspaceResourceService, useWorkspaceResourceState } from './workspace-view-state.js';
|
|
167
|
+
export {
|
|
168
|
+
MANAGE_ACCOUNTS_COMMAND_ID,
|
|
169
|
+
MANAGE_COMMANDS_COMMAND_ID,
|
|
170
|
+
MANAGE_EXTENSIONS_COMMAND_ID,
|
|
171
|
+
MANAGE_KEYBINDINGS_COMMAND_ID,
|
|
172
|
+
WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID,
|
|
173
|
+
WORKBENCH_COMMANDS_SETTINGS_CATEGORY_ID,
|
|
174
|
+
WORKBENCH_EXTENSIONS_SETTINGS_CATEGORY_ID,
|
|
175
|
+
WORKBENCH_KEYBINDINGS_SETTINGS_CATEGORY_ID,
|
|
176
|
+
} from './management-settings-ids.js';
|
|
177
|
+
export { createWorkbenchManagementPaletteCommands } from './management-palette-commands.js';
|
|
178
|
+
export {
|
|
179
|
+
WorkbenchAccountManagementSettings,
|
|
180
|
+
WorkbenchCommandManagementSettings,
|
|
181
|
+
WorkbenchExtensionManagementSettings,
|
|
182
|
+
WorkbenchKeybindingManagementSettings,
|
|
183
|
+
type WorkbenchAccountManagementInput,
|
|
184
|
+
} from './management-settings.js';
|
|
185
|
+
export {
|
|
186
|
+
WORKBENCH_PROFILE_ACTIVITY_ITEM_ID,
|
|
187
|
+
WORKBENCH_ACCOUNT_ACTIVITY_ITEM_ID,
|
|
188
|
+
WORKBENCH_SETTINGS_ACTIVITY_ITEM_ID,
|
|
189
|
+
createWorkbenchSecondaryActivityItems,
|
|
190
|
+
getWorkbenchSecondaryActivityRoute,
|
|
191
|
+
type WorkbenchSecondaryActivityItemsInput,
|
|
192
|
+
type WorkbenchSecondaryActivityRoute,
|
|
193
|
+
} from './shell-secondary-actions.js';
|
|
194
|
+
export {
|
|
195
|
+
WorkbenchProfileModal,
|
|
196
|
+
type WorkbenchProfileDetail,
|
|
197
|
+
type WorkbenchProfileInput,
|
|
198
|
+
type WorkbenchProfileModalProps,
|
|
199
|
+
} from './workbench-profile-modal.js';
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
export const SAMPLE_JDW_LAB_VIEW_RENDER_KIND = 'workbench-kit.samples.jdw.view' as const;
|
|
2
|
+
|
|
3
|
+
export interface SampleJdwLabViewRenderData {
|
|
4
|
+
readonly kind: typeof SAMPLE_JDW_LAB_VIEW_RENDER_KIND;
|
|
5
|
+
readonly templateJdwPath: string;
|
|
6
|
+
readonly widgetTreePath: string;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
export function isSampleJdwLabViewRenderData(value: unknown): value is SampleJdwLabViewRenderData {
|
|
10
|
+
if (typeof value !== 'object' || value === null) {
|
|
11
|
+
return false;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const candidate = value as {
|
|
15
|
+
kind?: unknown;
|
|
16
|
+
templateJdwPath?: unknown;
|
|
17
|
+
widgetTreePath?: unknown;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
return (
|
|
21
|
+
candidate.kind === SAMPLE_JDW_LAB_VIEW_RENDER_KIND &&
|
|
22
|
+
typeof candidate.templateJdwPath === 'string' &&
|
|
23
|
+
typeof candidate.widgetTreePath === 'string'
|
|
24
|
+
);
|
|
25
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
.workbench-jdw-lab-view {
|
|
2
|
+
height: 100%;
|
|
3
|
+
min-height: 0;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
.workbench-jdw-lab-view__list {
|
|
7
|
+
padding-block: 4px;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
.workbench-jdw-lab-view .ui-workbench-action-list-item__description {
|
|
11
|
+
font-family: var(
|
|
12
|
+
--monaco-monospace-font,
|
|
13
|
+
ui-monospace,
|
|
14
|
+
SFMono-Regular,
|
|
15
|
+
Menlo,
|
|
16
|
+
Consolas,
|
|
17
|
+
monospace
|
|
18
|
+
);
|
|
19
|
+
font-size: 11px;
|
|
20
|
+
opacity: 0.85;
|
|
21
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { WorkbenchActionSidebar } from '@workbench-kit/react/layout';
|
|
2
|
+
|
|
3
|
+
import './jdw-lab-view.css';
|
|
4
|
+
|
|
5
|
+
import { useWorkbench } from './provider.js';
|
|
6
|
+
import { useActiveEditorTab } from './use-editor.js';
|
|
7
|
+
import { useActiveWorkspacePath } from './use-active-workspace-path.js';
|
|
8
|
+
import {
|
|
9
|
+
isSampleJdwLabViewRenderData,
|
|
10
|
+
SAMPLE_JDW_LAB_VIEW_RENDER_KIND,
|
|
11
|
+
type SampleJdwLabViewRenderData,
|
|
12
|
+
} from './jdw-lab-view-data.js';
|
|
13
|
+
|
|
14
|
+
export type { SampleJdwLabViewRenderData };
|
|
15
|
+
export { isSampleJdwLabViewRenderData, SAMPLE_JDW_LAB_VIEW_RENDER_KIND };
|
|
16
|
+
|
|
17
|
+
const WORKSPACE_OPEN_COMMAND_ID = 'workspace.open' as const;
|
|
18
|
+
|
|
19
|
+
const DEFAULT_WIDGET_TREE_PATH = 'jdw/showcase/example.jdw.json';
|
|
20
|
+
const DEFAULT_TEMPLATE_JDW_PATH = 'jdw/templates/analytics-dashboard.jdw.json';
|
|
21
|
+
|
|
22
|
+
export interface SampleJdwLabViewProps {
|
|
23
|
+
readonly templateJdwPath?: string | undefined;
|
|
24
|
+
readonly widgetTreePath?: string | undefined;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function pathMatches(activePath: string | undefined, candidate: string): boolean {
|
|
28
|
+
if (!activePath) {
|
|
29
|
+
return false;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return activePath === candidate || activePath.endsWith(`/${candidate}`);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export function SampleJdwLabView({
|
|
36
|
+
templateJdwPath = DEFAULT_TEMPLATE_JDW_PATH,
|
|
37
|
+
widgetTreePath = DEFAULT_WIDGET_TREE_PATH,
|
|
38
|
+
}: SampleJdwLabViewProps = {}) {
|
|
39
|
+
const { executeCommand } = useWorkbench();
|
|
40
|
+
const activeTab = useActiveEditorTab();
|
|
41
|
+
const activePath = useActiveWorkspacePath(activeTab?.resourceUri);
|
|
42
|
+
|
|
43
|
+
return (
|
|
44
|
+
<WorkbenchActionSidebar
|
|
45
|
+
className="workbench-jdw-lab-view"
|
|
46
|
+
data-testid="jdw-lab-view"
|
|
47
|
+
items={[
|
|
48
|
+
{
|
|
49
|
+
description: widgetTreePath,
|
|
50
|
+
icon: <i aria-hidden="true" className="codicon codicon-layout" />,
|
|
51
|
+
id: 'widget-tree',
|
|
52
|
+
label: 'Widget Tree',
|
|
53
|
+
selected: pathMatches(activePath, widgetTreePath),
|
|
54
|
+
testId: 'jdw-lab-open-widget-tree',
|
|
55
|
+
title: `Open ${widgetTreePath}`,
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
description: templateJdwPath,
|
|
59
|
+
icon: <i aria-hidden="true" className="codicon codicon-symbol-structure" />,
|
|
60
|
+
id: 'template-jdw',
|
|
61
|
+
label: 'Template JDW',
|
|
62
|
+
selected: pathMatches(activePath, templateJdwPath),
|
|
63
|
+
testId: 'jdw-lab-open-template-jdw',
|
|
64
|
+
title: `Open ${templateJdwPath}`,
|
|
65
|
+
},
|
|
66
|
+
]}
|
|
67
|
+
listProps={{
|
|
68
|
+
'aria-label': 'JDW lab surfaces',
|
|
69
|
+
className: 'workbench-jdw-lab-view__list',
|
|
70
|
+
}}
|
|
71
|
+
onSelect={(item) => {
|
|
72
|
+
if (typeof item.description !== 'string' || item.description.length === 0) {
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
void executeCommand(WORKSPACE_OPEN_COMMAND_ID, { path: item.description });
|
|
76
|
+
}}
|
|
77
|
+
/>
|
|
78
|
+
);
|
|
79
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { resolveWidgetStudioAssetCatalog } from '@workbench-kit/react/widget-studio';
|
|
3
|
+
import { WidgetTreeLab } from '@workbench-kit/react/widget-tree';
|
|
4
|
+
import { BUILTIN_JDW_REGISTRY } from '@workbench-kit/react/jdw';
|
|
5
|
+
|
|
6
|
+
import { useWorkbench } from './provider.js';
|
|
7
|
+
import { isWorkspaceResourceService, useWorkspaceResourceState } from './workspace-view-state.js';
|
|
8
|
+
|
|
9
|
+
export interface JdwWidgetFormViewProps {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly content: string;
|
|
12
|
+
readonly onContentChange: (content: string) => void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const EMPTY_WORKSPACE_FILES: readonly { readonly path: string; readonly content: string }[] = [];
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Form authoring surface for JDW widgets. Builds the Assets palette from built-in
|
|
19
|
+
* assets, workspace asset packages, and other workspace `*.jdw.json` documents.
|
|
20
|
+
* Preview expands `type: "ref"` via workspace documents without rewriting the
|
|
21
|
+
* authored JSON outline.
|
|
22
|
+
*/
|
|
23
|
+
export function JdwWidgetFormView({ path, content, onContentChange }: JdwWidgetFormViewProps) {
|
|
24
|
+
const { workspaceHostPort } = useWorkbench();
|
|
25
|
+
const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
|
|
26
|
+
? workspaceHostPort.service
|
|
27
|
+
: undefined;
|
|
28
|
+
const workspaceState = useWorkspaceResourceState(workspaceService);
|
|
29
|
+
const files =
|
|
30
|
+
workspaceState?.files ?? workspaceService?.getState().files ?? EMPTY_WORKSPACE_FILES;
|
|
31
|
+
|
|
32
|
+
const filesByPath = useMemo(() => {
|
|
33
|
+
const map = new Map<string, string>();
|
|
34
|
+
for (const file of files) {
|
|
35
|
+
map.set(file.path.replace(/\\/g, '/'), file.content);
|
|
36
|
+
}
|
|
37
|
+
return map;
|
|
38
|
+
}, [files]);
|
|
39
|
+
|
|
40
|
+
const loadDocument = useCallback(
|
|
41
|
+
(documentPath: string) => filesByPath.get(documentPath.replace(/\\/g, '/')) ?? null,
|
|
42
|
+
[filesByPath],
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
const assetCatalog = useMemo(
|
|
46
|
+
() =>
|
|
47
|
+
resolveWidgetStudioAssetCatalog(files, {
|
|
48
|
+
excludeDocumentPaths: [path],
|
|
49
|
+
}),
|
|
50
|
+
[files, path],
|
|
51
|
+
);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<WidgetTreeLab
|
|
55
|
+
assetCatalog={assetCatalog}
|
|
56
|
+
loadDocument={loadDocument}
|
|
57
|
+
path={path}
|
|
58
|
+
registry={BUILTIN_JDW_REGISTRY}
|
|
59
|
+
showDesignSource={false}
|
|
60
|
+
value={content}
|
|
61
|
+
viewMode="design"
|
|
62
|
+
onChange={onContentChange}
|
|
63
|
+
/>
|
|
64
|
+
);
|
|
65
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useCallback, useMemo } from 'react';
|
|
2
|
+
import { JdwPreviewViewport } from '@workbench-kit/react/jdw/preview-viewport';
|
|
3
|
+
import { BUILTIN_JDW_REGISTRY } from '@workbench-kit/react/jdw';
|
|
4
|
+
|
|
5
|
+
import { useWorkbench } from './provider.js';
|
|
6
|
+
import { isWorkspaceResourceService, useWorkspaceResourceState } from './workspace-view-state.js';
|
|
7
|
+
|
|
8
|
+
export interface JdwWidgetPreviewViewProps {
|
|
9
|
+
readonly path: string;
|
|
10
|
+
readonly content: string;
|
|
11
|
+
readonly className?: string | undefined;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const EMPTY_WORKSPACE_FILES: readonly { readonly path: string; readonly content: string }[] = [];
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Preview viewport for JDW documents. Expands workspace `type: "ref"` imports
|
|
18
|
+
* before layout/draw without rewriting the source buffer.
|
|
19
|
+
*/
|
|
20
|
+
export function JdwWidgetPreviewView({ path, content, className }: JdwWidgetPreviewViewProps) {
|
|
21
|
+
const { workspaceHostPort } = useWorkbench();
|
|
22
|
+
const workspaceService = isWorkspaceResourceService(workspaceHostPort?.service)
|
|
23
|
+
? workspaceHostPort.service
|
|
24
|
+
: undefined;
|
|
25
|
+
const workspaceState = useWorkspaceResourceState(workspaceService);
|
|
26
|
+
const files =
|
|
27
|
+
workspaceState?.files ?? workspaceService?.getState().files ?? EMPTY_WORKSPACE_FILES;
|
|
28
|
+
|
|
29
|
+
const filesByPath = useMemo(() => {
|
|
30
|
+
const map = new Map<string, string>();
|
|
31
|
+
for (const file of files) {
|
|
32
|
+
map.set(file.path.replace(/\\/g, '/'), file.content);
|
|
33
|
+
}
|
|
34
|
+
return map;
|
|
35
|
+
}, [files]);
|
|
36
|
+
|
|
37
|
+
const loadDocument = useCallback(
|
|
38
|
+
(documentPath: string) => filesByPath.get(documentPath.replace(/\\/g, '/')) ?? null,
|
|
39
|
+
[filesByPath],
|
|
40
|
+
);
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
<JdwPreviewViewport
|
|
44
|
+
className={className}
|
|
45
|
+
documentPath={path}
|
|
46
|
+
json={content}
|
|
47
|
+
loadDocument={loadDocument}
|
|
48
|
+
registry={BUILTIN_JDW_REGISTRY}
|
|
49
|
+
/>
|
|
50
|
+
);
|
|
51
|
+
}
|