@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.
Files changed (95) hide show
  1. package/README.md +41 -0
  2. package/package.json +9 -9
  3. package/src/{chat-ai-mock-proposals.ts → chat/ai-mock-proposals.ts} +39 -39
  4. package/src/{chat-command-input.ts → chat/command-input.ts} +52 -52
  5. package/src/{chat-command-policy.ts → chat/command-policy.ts} +54 -54
  6. package/src/{chat-command-surface.tsx → chat/command-surface.tsx} +155 -155
  7. package/src/{use-workbench-chat-command-proposals.ts → chat/use-chat-command-proposals.ts} +194 -194
  8. package/src/{chat-view-data.ts → chat/view-data.ts} +20 -20
  9. package/src/{chat-view.tsx → chat/view.tsx} +220 -220
  10. package/src/{command-inspector-surface.tsx → commands/inspector-surface.tsx} +46 -46
  11. package/src/{use-workbench-command-descriptors.ts → commands/use-command-descriptors.ts} +41 -41
  12. package/src/{use-context-key-revision.ts → commands/use-context-key-revision.ts} +18 -18
  13. package/src/{commands-view-data.ts → commands/view-data.ts} +17 -17
  14. package/src/{commands-view.tsx → commands/view.tsx} +43 -43
  15. package/src/devtools/WorkbenchDevtoolsPanel.tsx +124 -124
  16. package/src/devtools/WorkbenchDevtoolsShell.tsx +17 -17
  17. package/src/devtools/index.ts +11 -11
  18. package/src/devtools/use-workbench-devtools-snapshot.ts +84 -84
  19. package/src/devtools/workbench-devtools-snapshot.ts +140 -140
  20. package/src/devtools/workbench-devtools.css +82 -82
  21. package/src/{editor-area-dnd.ts → editor/area-dnd.ts} +69 -69
  22. package/src/{editor-area-model.ts → editor/area-model.ts} +71 -71
  23. package/src/{editor-area.css → editor/area.css} +454 -454
  24. package/src/{editor-area.tsx → editor/area.tsx} +676 -676
  25. package/src/{editor-host-surface.tsx → editor/host-surface.tsx} +631 -634
  26. package/src/{editor-pane-visibility.ts → editor/pane-visibility.ts} +130 -130
  27. package/src/{editor-resource.ts → editor/resource.ts} +36 -36
  28. package/src/{editor-state-storage.ts → editor/state-storage.ts} +182 -193
  29. package/src/{editor-tab-context-menu.ts → editor/tab-context-menu.ts} +118 -118
  30. package/src/{use-editor.ts → editor/use-editor.ts} +114 -107
  31. package/src/{editor-view-providers.tsx → editor/view-providers.tsx} +552 -552
  32. package/src/{editor-workspace-file-availability.ts → editor/workspace-file-availability.ts} +15 -15
  33. package/src/{editor-workspace-reconcile.tsx → editor/workspace-reconcile.tsx} +31 -28
  34. package/src/{explorer-context-menu.ts → explorer/context-menu.ts} +114 -114
  35. package/src/{createCommandWorkspaceExplorerPort.ts → explorer/create-command-workspace-explorer-port.ts} +86 -86
  36. package/src/{explorer-reveal.ts → explorer/reveal.ts} +112 -112
  37. package/src/{search-view-data.ts → explorer/search-view-data.ts} +15 -15
  38. package/src/{search-view.tsx → explorer/search-view.tsx} +65 -62
  39. package/src/{use-active-workspace-path.ts → explorer/use-active-workspace-path.ts} +15 -15
  40. package/src/{explorer-view-data.ts → explorer/view-data.ts} +58 -58
  41. package/src/{explorer-view.tsx → explorer/view.tsx} +227 -224
  42. package/src/{extension-context-menu.ts → extensions/context-menu.ts} +52 -52
  43. package/src/{extension-management-model.ts → extensions/management-model.ts} +313 -313
  44. package/src/{use-extension-management.ts → extensions/use-extension-management.ts} +241 -193
  45. package/src/{extensions-view-data.ts → extensions/view-data.ts} +19 -19
  46. package/src/{extensions-view.tsx → extensions/view.tsx} +63 -38
  47. package/src/{field-remap-demo.tsx → field-remap/demo.tsx} +18 -18
  48. package/src/{field-remap-editor-surface.tsx → field-remap/editor-surface.tsx} +36 -36
  49. package/src/{field-remap-flow-adapter.ts → field-remap/flow-adapter.ts} +240 -240
  50. package/src/{field-remap-flow.tsx → field-remap/flow.tsx} +369 -369
  51. package/src/{field-remap-graph.tsx → field-remap/graph.tsx} +559 -559
  52. package/src/field-remap/jsonata-transform.ts +166 -0
  53. package/src/{field-remap-panel.tsx → field-remap/panel.tsx} +193 -175
  54. package/src/{field-remap-samples.ts → field-remap/samples.ts} +352 -352
  55. package/src/{table-mapping-adapter.ts → field-remap/table-mapping-adapter.ts} +59 -59
  56. package/src/{field-remap-tree.tsx → field-remap/tree.tsx} +404 -404
  57. package/src/{field-remap-view-data.ts → field-remap/view-data.ts} +16 -16
  58. package/src/{field-remap-view.css → field-remap/view.css} +676 -676
  59. package/src/{field-remap-view.tsx → field-remap/view.tsx} +86 -86
  60. package/src/index.ts +212 -199
  61. package/src/{json-form-source-patch.ts → jdw/json-form-source-patch.ts} +323 -323
  62. package/src/{jdw-lab-view-data.ts → jdw/lab-view-data.ts} +25 -25
  63. package/src/{jdw-lab-view.css → jdw/lab-view.css} +21 -21
  64. package/src/{jdw-lab-view.tsx → jdw/lab-view.tsx} +79 -79
  65. package/src/{jdw-widget-form-view.tsx → jdw/widget-form-view.tsx} +68 -65
  66. package/src/{jdw-widget-preview-view.tsx → jdw/widget-preview-view.tsx} +54 -51
  67. package/src/{keybinding-overrides-storage.ts → management/keybinding-overrides-storage.ts} +49 -57
  68. package/src/{keybinding-management-settings.tsx → management/keybinding-settings.tsx} +16 -16
  69. package/src/{management-palette-commands.ts → management/palette-commands.ts} +38 -38
  70. package/src/{preference-settings-storage.ts → management/preference-settings-storage.ts} +50 -58
  71. package/src/{management-settings-ids.ts → management/settings-ids.ts} +12 -12
  72. package/src/{management-settings.tsx → management/settings.tsx} +96 -75
  73. package/src/{use-command-management.ts → management/use-command-management.ts} +191 -191
  74. package/src/{use-keybinding-management.ts → management/use-keybinding-management.ts} +130 -130
  75. package/src/{shell-model.tsx → shell/model.tsx} +149 -149
  76. package/src/{provider.tsx → shell/provider.tsx} +603 -573
  77. package/src/{shell-secondary-actions.tsx → shell/secondary-actions.tsx} +59 -59
  78. package/src/{shell-settings-constants.ts → shell/settings-constants.ts} +9 -9
  79. package/src/{shell-settings.tsx → shell/settings.tsx} +599 -599
  80. package/src/{shell.tsx → shell/shell.tsx} +680 -649
  81. package/src/{shell-titlebar-layout-controls.tsx → shell/titlebar-layout-controls.tsx} +4 -4
  82. package/src/{shell-view-host.tsx → shell/view-host.tsx} +212 -199
  83. package/src/{workbench-appearance-storage.ts → workbench/appearance-storage.ts} +107 -115
  84. package/src/{workbench-command-host.tsx → workbench/command-host.tsx} +243 -243
  85. package/src/{workbench-command-palette.ts → workbench/command-palette.ts} +208 -208
  86. package/src/{workbench-keybinding-bridge.ts → workbench/keybinding-bridge.ts} +54 -54
  87. package/src/{workbench-layout-storage.ts → workbench/layout-storage.ts} +134 -145
  88. package/src/{workbench-profile-modal.tsx → workbench/profile-modal.tsx} +118 -118
  89. package/src/{workbench-shell-command-registration.ts → workbench/shell-command-registration.ts} +58 -58
  90. package/src/{workbench-startup-gate.tsx → workbench/startup-gate.tsx} +136 -136
  91. package/src/{workbench-status-sections.ts → workbench/status-sections.ts} +43 -43
  92. package/src/{use-persisted-workbench-appearance.ts → workbench/use-persisted-appearance.ts} +33 -33
  93. package/src/{workbench-user-commands.ts → workbench/user-commands.ts} +46 -46
  94. package/src/{workspace-view-state.ts → workbench/workspace-view-state.ts} +35 -35
  95. package/src/jsonata-transform.ts +0 -36
@@ -1,136 +1,136 @@
1
- import { useEffect, useMemo, useRef, type ReactNode } from 'react';
2
- import {
3
- WorkbenchBootstrapGate,
4
- useWorkbenchBootstrap,
5
- type WorkbenchBootstrapTaskDefinition,
6
- } from '@workbench-kit/react/workbench/bootstrap';
7
- import type { VirtualWorkspaceInitialState } from '@workbench-kit/workspace';
8
- import { useWorkbench } from './provider.js';
9
-
10
- export interface WorkbenchStartupGateProps {
11
- children: ReactNode;
12
- className?: string | undefined;
13
- footer?: ReactNode;
14
- heading?: string | undefined;
15
- onFailed?: ((error: Error) => void) | undefined;
16
- onReady?: (() => void) | undefined;
17
- renderBootstrap?:
18
- ((bootstrap: ReturnType<typeof useWorkbenchBootstrap>) => ReactNode) | undefined;
19
- subtitle?: string | undefined;
20
- tasks?: readonly WorkbenchBootstrapTaskDefinition[] | undefined;
21
- workspaceInit?: VirtualWorkspaceInitialState | undefined;
22
- }
23
-
24
- function countWorkspaceEntries(
25
- workspaceInit: VirtualWorkspaceInitialState | undefined,
26
- ): string | undefined {
27
- if (!workspaceInit) {
28
- return undefined;
29
- }
30
-
31
- const fileCount = workspaceInit.files?.length ?? 0;
32
- const folderCount = workspaceInit.folders?.length ?? 0;
33
- const parts: string[] = [];
34
-
35
- if (fileCount > 0) {
36
- parts.push(`${fileCount} file${fileCount === 1 ? '' : 's'}`);
37
- }
38
-
39
- if (folderCount > 0) {
40
- parts.push(`${folderCount} folder${folderCount === 1 ? '' : 's'}`);
41
- }
42
-
43
- return parts.length > 0 ? parts.join(', ') : undefined;
44
- }
45
-
46
- export function WorkbenchStartupGate({
47
- children,
48
- className,
49
- footer,
50
- heading = 'Preparing workbench',
51
- onFailed,
52
- onReady,
53
- renderBootstrap,
54
- subtitle = 'Loading extensions and preparing your workspace.',
55
- tasks,
56
- workspaceInit,
57
- }: WorkbenchStartupGateProps) {
58
- const { executeCommand, missingExtensionIds, waitForExtensionStartup } = useWorkbench();
59
- const bootstrap = useWorkbenchBootstrap();
60
- const startedRef = useRef(false);
61
- const workspaceDetail = countWorkspaceEntries(workspaceInit);
62
-
63
- const startupTasks = useMemo<readonly WorkbenchBootstrapTaskDefinition[]>(() => {
64
- if (tasks) {
65
- return tasks;
66
- }
67
-
68
- const resolvedTasks: WorkbenchBootstrapTaskDefinition[] = [
69
- {
70
- detail:
71
- missingExtensionIds.length > 0 ? `${missingExtensionIds.length} missing` : undefined,
72
- id: 'extensions',
73
- label: 'Loading extensions',
74
- run: async () => {
75
- await waitForExtensionStartup();
76
- },
77
- },
78
- ];
79
-
80
- if (workspaceInit) {
81
- resolvedTasks.push({
82
- detail: workspaceDetail,
83
- id: 'workspace',
84
- label: 'Preparing workspace',
85
- run: async () => {
86
- await executeCommand('workspace.init', workspaceInit);
87
- },
88
- });
89
- }
90
-
91
- return resolvedTasks;
92
- }, [
93
- executeCommand,
94
- missingExtensionIds.length,
95
- tasks,
96
- waitForExtensionStartup,
97
- workspaceDetail,
98
- workspaceInit,
99
- ]);
100
-
101
- useEffect(() => {
102
- if (startedRef.current) {
103
- return;
104
- }
105
-
106
- startedRef.current = true;
107
- void bootstrap.run(startupTasks).catch((error: unknown) => {
108
- onFailed?.(error instanceof Error ? error : new Error('Startup failed.'));
109
- });
110
- }, [bootstrap, onFailed, startupTasks]);
111
-
112
- useEffect(() => {
113
- if (bootstrap.isReady) {
114
- onReady?.();
115
- }
116
- }, [bootstrap.isReady, onReady]);
117
-
118
- useEffect(() => {
119
- if (bootstrap.status === 'failed' && bootstrap.error) {
120
- onFailed?.(new Error(bootstrap.error));
121
- }
122
- }, [bootstrap.error, bootstrap.status, onFailed]);
123
-
124
- return (
125
- <WorkbenchBootstrapGate
126
- bootstrap={bootstrap}
127
- className={className}
128
- footer={footer}
129
- heading={heading}
130
- renderBootstrap={renderBootstrap}
131
- subtitle={subtitle}
132
- >
133
- {children}
134
- </WorkbenchBootstrapGate>
135
- );
136
- }
1
+ import { useEffect, useMemo, useRef, type ReactNode } from 'react';
2
+ import {
3
+ WorkbenchBootstrapGate,
4
+ useWorkbenchBootstrap,
5
+ type WorkbenchBootstrapTaskDefinition,
6
+ } from '@workbench-kit/react/workbench/bootstrap';
7
+ import type { VirtualWorkspaceInitialState } from '@workbench-kit/workspace';
8
+ import { useWorkbench } from '../shell/provider.js';
9
+
10
+ export interface WorkbenchStartupGateProps {
11
+ children: ReactNode;
12
+ className?: string | undefined;
13
+ footer?: ReactNode;
14
+ heading?: string | undefined;
15
+ onFailed?: ((error: Error) => void) | undefined;
16
+ onReady?: (() => void) | undefined;
17
+ renderBootstrap?:
18
+ ((bootstrap: ReturnType<typeof useWorkbenchBootstrap>) => ReactNode) | undefined;
19
+ subtitle?: string | undefined;
20
+ tasks?: readonly WorkbenchBootstrapTaskDefinition[] | undefined;
21
+ workspaceInit?: VirtualWorkspaceInitialState | undefined;
22
+ }
23
+
24
+ function countWorkspaceEntries(
25
+ workspaceInit: VirtualWorkspaceInitialState | undefined,
26
+ ): string | undefined {
27
+ if (!workspaceInit) {
28
+ return undefined;
29
+ }
30
+
31
+ const fileCount = workspaceInit.files?.length ?? 0;
32
+ const folderCount = workspaceInit.folders?.length ?? 0;
33
+ const parts: string[] = [];
34
+
35
+ if (fileCount > 0) {
36
+ parts.push(`${fileCount} file${fileCount === 1 ? '' : 's'}`);
37
+ }
38
+
39
+ if (folderCount > 0) {
40
+ parts.push(`${folderCount} folder${folderCount === 1 ? '' : 's'}`);
41
+ }
42
+
43
+ return parts.length > 0 ? parts.join(', ') : undefined;
44
+ }
45
+
46
+ export function WorkbenchStartupGate({
47
+ children,
48
+ className,
49
+ footer,
50
+ heading = 'Preparing workbench',
51
+ onFailed,
52
+ onReady,
53
+ renderBootstrap,
54
+ subtitle = 'Loading extensions and preparing your workspace.',
55
+ tasks,
56
+ workspaceInit,
57
+ }: WorkbenchStartupGateProps) {
58
+ const { executeCommand, missingExtensionIds, waitForExtensionStartup } = useWorkbench();
59
+ const bootstrap = useWorkbenchBootstrap();
60
+ const startedRef = useRef(false);
61
+ const workspaceDetail = countWorkspaceEntries(workspaceInit);
62
+
63
+ const startupTasks = useMemo<readonly WorkbenchBootstrapTaskDefinition[]>(() => {
64
+ if (tasks) {
65
+ return tasks;
66
+ }
67
+
68
+ const resolvedTasks: WorkbenchBootstrapTaskDefinition[] = [
69
+ {
70
+ detail:
71
+ missingExtensionIds.length > 0 ? `${missingExtensionIds.length} missing` : undefined,
72
+ id: 'extensions',
73
+ label: 'Loading extensions',
74
+ run: async () => {
75
+ await waitForExtensionStartup();
76
+ },
77
+ },
78
+ ];
79
+
80
+ if (workspaceInit) {
81
+ resolvedTasks.push({
82
+ detail: workspaceDetail,
83
+ id: 'workspace',
84
+ label: 'Preparing workspace',
85
+ run: async () => {
86
+ await executeCommand('workspace.init', workspaceInit);
87
+ },
88
+ });
89
+ }
90
+
91
+ return resolvedTasks;
92
+ }, [
93
+ executeCommand,
94
+ missingExtensionIds.length,
95
+ tasks,
96
+ waitForExtensionStartup,
97
+ workspaceDetail,
98
+ workspaceInit,
99
+ ]);
100
+
101
+ useEffect(() => {
102
+ if (startedRef.current) {
103
+ return;
104
+ }
105
+
106
+ startedRef.current = true;
107
+ void bootstrap.run(startupTasks).catch((error: unknown) => {
108
+ onFailed?.(error instanceof Error ? error : new Error('Startup failed.'));
109
+ });
110
+ }, [bootstrap, onFailed, startupTasks]);
111
+
112
+ useEffect(() => {
113
+ if (bootstrap.isReady) {
114
+ onReady?.();
115
+ }
116
+ }, [bootstrap.isReady, onReady]);
117
+
118
+ useEffect(() => {
119
+ if (bootstrap.status === 'failed' && bootstrap.error) {
120
+ onFailed?.(new Error(bootstrap.error));
121
+ }
122
+ }, [bootstrap.error, bootstrap.status, onFailed]);
123
+
124
+ return (
125
+ <WorkbenchBootstrapGate
126
+ bootstrap={bootstrap}
127
+ className={className}
128
+ footer={footer}
129
+ heading={heading}
130
+ renderBootstrap={renderBootstrap}
131
+ subtitle={subtitle}
132
+ >
133
+ {children}
134
+ </WorkbenchBootstrapGate>
135
+ );
136
+ }
@@ -1,43 +1,43 @@
1
- import type {
2
- StatusBarItemModel,
3
- StatusBarSectionModel,
4
- } from '@workbench-kit/react/workbench/shell';
5
-
6
- export interface WorkspaceResourceStatusItemsInput {
7
- fileCount: number;
8
- fileItemId?: string | undefined;
9
- fileTitle?: string | undefined;
10
- folderCount: number;
11
- folderItemId?: string | undefined;
12
- folderTitle?: string | undefined;
13
- }
14
-
15
- export function createWorkspaceResourceStatusItems({
16
- fileCount,
17
- fileItemId = 'workbench.workspace.files',
18
- fileTitle = 'Workspace files',
19
- folderCount,
20
- folderItemId = 'workbench.workspace.folders',
21
- folderTitle = 'Workspace folders',
22
- }: WorkspaceResourceStatusItemsInput): StatusBarItemModel[] {
23
- return [
24
- {
25
- icon: 'files',
26
- id: fileItemId,
27
- label: `${fileCount} files`,
28
- title: fileTitle,
29
- },
30
- {
31
- icon: 'folder',
32
- id: folderItemId,
33
- label: `${folderCount} folders`,
34
- title: folderTitle,
35
- },
36
- ];
37
- }
38
-
39
- export function mergeWorkbenchStatusSections(
40
- ...sectionGroups: ReadonlyArray<readonly StatusBarSectionModel[]>
41
- ): StatusBarSectionModel[] {
42
- return sectionGroups.flat().filter((section) => section.items.length > 0);
43
- }
1
+ import type {
2
+ StatusBarItemModel,
3
+ StatusBarSectionModel,
4
+ } from '@workbench-kit/react/workbench/shell';
5
+
6
+ export interface WorkspaceResourceStatusItemsInput {
7
+ fileCount: number;
8
+ fileItemId?: string | undefined;
9
+ fileTitle?: string | undefined;
10
+ folderCount: number;
11
+ folderItemId?: string | undefined;
12
+ folderTitle?: string | undefined;
13
+ }
14
+
15
+ export function createWorkspaceResourceStatusItems({
16
+ fileCount,
17
+ fileItemId = 'workbench.workspace.files',
18
+ fileTitle = 'Workspace files',
19
+ folderCount,
20
+ folderItemId = 'workbench.workspace.folders',
21
+ folderTitle = 'Workspace folders',
22
+ }: WorkspaceResourceStatusItemsInput): StatusBarItemModel[] {
23
+ return [
24
+ {
25
+ icon: 'files',
26
+ id: fileItemId,
27
+ label: `${fileCount} files`,
28
+ title: fileTitle,
29
+ },
30
+ {
31
+ icon: 'folder',
32
+ id: folderItemId,
33
+ label: `${folderCount} folders`,
34
+ title: folderTitle,
35
+ },
36
+ ];
37
+ }
38
+
39
+ export function mergeWorkbenchStatusSections(
40
+ ...sectionGroups: ReadonlyArray<readonly StatusBarSectionModel[]>
41
+ ): StatusBarSectionModel[] {
42
+ return sectionGroups.flat().filter((section) => section.items.length > 0);
43
+ }
@@ -1,33 +1,33 @@
1
- import { useEffect, useState } from 'react';
2
- import type { WorkbenchStorageAdapter } from '@workbench-kit/workbench-core';
3
-
4
- import {
5
- readPersistedWorkbenchAppearance,
6
- writePersistedWorkbenchAppearance,
7
- type WorkbenchAppearanceSettings,
8
- } from './workbench-appearance-storage.js';
9
-
10
- export interface UsePersistedWorkbenchAppearanceOptions {
11
- persist?: boolean | undefined;
12
- storage?: WorkbenchStorageAdapter | undefined;
13
- storageKey?: string | undefined;
14
- }
15
-
16
- export function usePersistedWorkbenchAppearance(
17
- options: UsePersistedWorkbenchAppearanceOptions = {},
18
- ): [WorkbenchAppearanceSettings, (settings: WorkbenchAppearanceSettings) => void] {
19
- const { persist = true, storage, storageKey } = options;
20
- const [appearance, setAppearance] = useState(() =>
21
- readPersistedWorkbenchAppearance(storageKey, storage),
22
- );
23
-
24
- useEffect(() => {
25
- if (!persist) {
26
- return;
27
- }
28
-
29
- writePersistedWorkbenchAppearance(appearance, storageKey, storage);
30
- }, [appearance, persist, storage, storageKey]);
31
-
32
- return [appearance, setAppearance];
33
- }
1
+ import { useEffect, useState } from 'react';
2
+ import type { WorkbenchStorageAdapter } from '@workbench-kit/workbench-core';
3
+
4
+ import {
5
+ readPersistedWorkbenchAppearance,
6
+ writePersistedWorkbenchAppearance,
7
+ type WorkbenchAppearanceSettings,
8
+ } from './appearance-storage.js';
9
+
10
+ export interface UsePersistedWorkbenchAppearanceOptions {
11
+ persist?: boolean | undefined;
12
+ storage?: WorkbenchStorageAdapter | undefined;
13
+ storageKey?: string | undefined;
14
+ }
15
+
16
+ export function usePersistedWorkbenchAppearance(
17
+ options: UsePersistedWorkbenchAppearanceOptions = {},
18
+ ): [WorkbenchAppearanceSettings, (settings: WorkbenchAppearanceSettings) => void] {
19
+ const { persist = true, storage, storageKey } = options;
20
+ const [appearance, setAppearance] = useState(() =>
21
+ readPersistedWorkbenchAppearance(storageKey, storage),
22
+ );
23
+
24
+ useEffect(() => {
25
+ if (!persist) {
26
+ return;
27
+ }
28
+
29
+ writePersistedWorkbenchAppearance(appearance, storageKey, storage);
30
+ }, [appearance, persist, storage, storageKey]);
31
+
32
+ return [appearance, setAppearance];
33
+ }
@@ -1,46 +1,46 @@
1
- import type {
2
- WorkbenchUserCommandAction,
3
- WorkbenchUserCommandDefinition,
4
- } from '@workbench-kit/workbench-config';
5
- import type { ExtensionRegistry } from '@workbench-kit/workbench-core';
6
-
7
- export async function executeWorkbenchUserCommandAction(
8
- action: WorkbenchUserCommandAction,
9
- executeCommand: (commandId: string, ...args: unknown[]) => Promise<unknown>,
10
- ): Promise<unknown> {
11
- if (action.type === 'executeCommand') {
12
- return executeCommand(action.command, ...(action.args !== undefined ? [action.args] : []));
13
- }
14
-
15
- let lastResult: unknown;
16
- for (const step of action.steps) {
17
- lastResult = await executeWorkbenchUserCommandAction(step, executeCommand);
18
- }
19
-
20
- return lastResult;
21
- }
22
-
23
- export function registerWorkbenchUserCommands(
24
- extensionRegistry: ExtensionRegistry,
25
- userCommands: readonly WorkbenchUserCommandDefinition[],
26
- ): { dispose(): void } {
27
- const disposables = userCommands.map((userCommand) =>
28
- extensionRegistry.commands.registerCommand({
29
- category: userCommand.category,
30
- handler: () =>
31
- executeWorkbenchUserCommandAction(userCommand.action, (commandId, ...args) =>
32
- extensionRegistry.executeCommand(commandId, ...args),
33
- ),
34
- id: userCommand.command,
35
- title: userCommand.title,
36
- }),
37
- );
38
-
39
- return {
40
- dispose() {
41
- for (const disposable of disposables) {
42
- disposable.dispose();
43
- }
44
- },
45
- };
46
- }
1
+ import type {
2
+ WorkbenchUserCommandAction,
3
+ WorkbenchUserCommandDefinition,
4
+ } from '@workbench-kit/workbench-config';
5
+ import type { ExtensionRegistry } from '@workbench-kit/workbench-core';
6
+
7
+ export async function executeWorkbenchUserCommandAction(
8
+ action: WorkbenchUserCommandAction,
9
+ executeCommand: (commandId: string, ...args: unknown[]) => Promise<unknown>,
10
+ ): Promise<unknown> {
11
+ if (action.type === 'executeCommand') {
12
+ return executeCommand(action.command, ...(action.args !== undefined ? [action.args] : []));
13
+ }
14
+
15
+ let lastResult: unknown;
16
+ for (const step of action.steps) {
17
+ lastResult = await executeWorkbenchUserCommandAction(step, executeCommand);
18
+ }
19
+
20
+ return lastResult;
21
+ }
22
+
23
+ export function registerWorkbenchUserCommands(
24
+ extensionRegistry: ExtensionRegistry,
25
+ userCommands: readonly WorkbenchUserCommandDefinition[],
26
+ ): { dispose(): void } {
27
+ const disposables = userCommands.map((userCommand) =>
28
+ extensionRegistry.commands.registerCommand({
29
+ category: userCommand.category,
30
+ handler: () =>
31
+ executeWorkbenchUserCommandAction(userCommand.action, (commandId, ...args) =>
32
+ extensionRegistry.executeCommand(commandId, ...args),
33
+ ),
34
+ id: userCommand.command,
35
+ title: userCommand.title,
36
+ }),
37
+ );
38
+
39
+ return {
40
+ dispose() {
41
+ for (const disposable of disposables) {
42
+ disposable.dispose();
43
+ }
44
+ },
45
+ };
46
+ }
@@ -1,35 +1,35 @@
1
- import { useEffect, useState } from 'react';
2
- import type {
3
- VirtualWorkspaceState,
4
- WorkspaceChangeEvent,
5
- WorkspaceResourceService,
6
- } from '@workbench-kit/workspace';
7
-
8
- export function isWorkspaceResourceService(value: unknown): value is WorkspaceResourceService {
9
- return (
10
- typeof value === 'object' &&
11
- value !== null &&
12
- typeof (value as WorkspaceResourceService).getState === 'function' &&
13
- typeof (value as WorkspaceResourceService).onDidChangeWorkspace === 'function'
14
- );
15
- }
16
-
17
- export function useWorkspaceResourceState(
18
- workspaceService: WorkspaceResourceService | undefined,
19
- ): VirtualWorkspaceState | undefined {
20
- const [state, setState] = useState(() => workspaceService?.getState());
21
-
22
- useEffect(() => {
23
- if (!workspaceService) {
24
- setState(undefined);
25
- return undefined;
26
- }
27
-
28
- setState(workspaceService.getState());
29
- return workspaceService.onDidChangeWorkspace((event: WorkspaceChangeEvent) => {
30
- setState(event.state);
31
- });
32
- }, [workspaceService]);
33
-
34
- return state;
35
- }
1
+ import { useEffect, useState } from 'react';
2
+ import type {
3
+ VirtualWorkspaceState,
4
+ WorkspaceChangeEvent,
5
+ WorkspaceResourceService,
6
+ } from '@workbench-kit/workspace';
7
+
8
+ export function isWorkspaceResourceService(value: unknown): value is WorkspaceResourceService {
9
+ return (
10
+ typeof value === 'object' &&
11
+ value !== null &&
12
+ typeof (value as WorkspaceResourceService).getState === 'function' &&
13
+ typeof (value as WorkspaceResourceService).onDidChangeWorkspace === 'function'
14
+ );
15
+ }
16
+
17
+ export function useWorkspaceResourceState(
18
+ workspaceService: WorkspaceResourceService | undefined,
19
+ ): VirtualWorkspaceState | undefined {
20
+ const [state, setState] = useState(() => workspaceService?.getState());
21
+
22
+ useEffect(() => {
23
+ if (!workspaceService) {
24
+ setState(undefined);
25
+ return undefined;
26
+ }
27
+
28
+ setState(workspaceService.getState());
29
+ return workspaceService.onDidChangeWorkspace((event: WorkspaceChangeEvent) => {
30
+ setState(event.state);
31
+ });
32
+ }, [workspaceService]);
33
+
34
+ return state;
35
+ }
@@ -1,36 +0,0 @@
1
- import jsonata from 'jsonata';
2
- import type { ValueTransformDefinition } from '@workbench-kit/field-remap';
3
-
4
- /** Host-registered JSONata expression transform (Stedi-style advanced mapping). */
5
- export const JSONATA_TRANSFORM_ID = 'expr:jsonata' as const;
6
-
7
- export const jsonataValueTransform: ValueTransformDefinition = {
8
- id: JSONATA_TRANSFORM_ID,
9
- label: 'JSONata expression',
10
- description: 'Evaluate a JSONata expression against the source value (host-registered).',
11
- category: 'expression',
12
- inputTypes: ['string', 'number', 'boolean', 'object', 'array', 'unknown'],
13
- outputType: 'unknown',
14
- optionFields: [
15
- {
16
- key: 'expression',
17
- label: 'Expression',
18
- kind: 'string',
19
- },
20
- ],
21
- apply: (value, context) => {
22
- const expression =
23
- typeof context.options?.expression === 'string' ? context.options.expression.trim() : '';
24
- if (!expression) {
25
- return value;
26
- }
27
- try {
28
- const compiled = jsonata(expression);
29
- // jsonata@1.x evaluate is synchronous (2.x returns a Promise).
30
- const result = compiled.evaluate(value) as unknown;
31
- return result;
32
- } catch {
33
- return value;
34
- }
35
- },
36
- };