@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,323 @@
|
|
|
1
|
+
export type JsonFormPath = readonly (string | number)[];
|
|
2
|
+
|
|
3
|
+
export interface JsonTextRange {
|
|
4
|
+
readonly end: number;
|
|
5
|
+
readonly start: number;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export function replaceJsonValueAtPath(
|
|
9
|
+
source: string,
|
|
10
|
+
path: JsonFormPath,
|
|
11
|
+
nextValue: unknown,
|
|
12
|
+
): string {
|
|
13
|
+
if (path.length === 0) {
|
|
14
|
+
return JSON.stringify(nextValue);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
const range = findJsonValueRangeAtPath(source, path);
|
|
18
|
+
if (!range) {
|
|
19
|
+
return fallbackSerializeJsonPathEdit(source, path, nextValue);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
return `${source.slice(0, range.start)}${JSON.stringify(nextValue)}${source.slice(range.end)}`;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function fallbackSerializeJsonPathEdit(
|
|
26
|
+
source: string,
|
|
27
|
+
path: JsonFormPath,
|
|
28
|
+
nextValue: unknown,
|
|
29
|
+
): string {
|
|
30
|
+
const parsed: unknown = JSON.parse(source);
|
|
31
|
+
const nextRecord = updateJsonPathValue(parsed, path, nextValue);
|
|
32
|
+
return JSON.stringify(nextRecord, null, detectJsonIndent(source));
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function detectJsonIndent(source: string): number {
|
|
36
|
+
return /\n[ \t]+"/.test(source) ? 2 : 0;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function updateJsonPathValue(value: unknown, path: JsonFormPath, nextValue: unknown): unknown {
|
|
40
|
+
if (path.length === 0) {
|
|
41
|
+
return nextValue;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
const [head, ...tail] = path;
|
|
45
|
+
|
|
46
|
+
if (Array.isArray(value) && typeof head === 'number') {
|
|
47
|
+
const nextArray = [...value];
|
|
48
|
+
nextArray[head] = updateJsonPathValue(nextArray[head], tail, nextValue);
|
|
49
|
+
return nextArray;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (isJsonRecord(value) && typeof head === 'string') {
|
|
53
|
+
return {
|
|
54
|
+
...value,
|
|
55
|
+
[head]: updateJsonPathValue(value[head], tail, nextValue),
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
return value;
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function isJsonRecord(value: unknown): value is Record<string, unknown> {
|
|
63
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function findJsonValueRangeAtPath(source: string, path: JsonFormPath): JsonTextRange | null {
|
|
67
|
+
const start = skipWhitespace(source, 0);
|
|
68
|
+
if (start >= source.length) {
|
|
69
|
+
return null;
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return locateJsonValueRange(source, start, path, 0);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function locateJsonValueRange(
|
|
76
|
+
source: string,
|
|
77
|
+
index: number,
|
|
78
|
+
path: JsonFormPath,
|
|
79
|
+
pathIndex: number,
|
|
80
|
+
): JsonTextRange | null {
|
|
81
|
+
index = skipWhitespace(source, index);
|
|
82
|
+
|
|
83
|
+
if (pathIndex >= path.length) {
|
|
84
|
+
const end = scanJsonValueEnd(source, index);
|
|
85
|
+
return end < 0 ? null : { start: index, end };
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
const segment = path[pathIndex];
|
|
89
|
+
if (typeof segment === 'number') {
|
|
90
|
+
if (source[index] !== '[') {
|
|
91
|
+
return null;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return locateJsonValueInArray(source, index + 1, path, pathIndex, segment);
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
if (typeof segment === 'string') {
|
|
98
|
+
if (source[index] !== '{') {
|
|
99
|
+
return null;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
return locateJsonValueInObject(source, index + 1, path, pathIndex, segment);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
return null;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function locateJsonValueInObject(
|
|
109
|
+
source: string,
|
|
110
|
+
index: number,
|
|
111
|
+
path: JsonFormPath,
|
|
112
|
+
pathIndex: number,
|
|
113
|
+
key: string,
|
|
114
|
+
): JsonTextRange | null {
|
|
115
|
+
let cursor = skipWhitespace(source, index);
|
|
116
|
+
|
|
117
|
+
while (cursor < source.length && source[cursor] !== '}') {
|
|
118
|
+
const keyRange = scanJsonStringToken(source, cursor);
|
|
119
|
+
if (!keyRange) {
|
|
120
|
+
return null;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
const parsedKey = JSON.parse(source.slice(keyRange.start, keyRange.end)) as string;
|
|
124
|
+
cursor = skipWhitespace(source, keyRange.end);
|
|
125
|
+
|
|
126
|
+
if (source[cursor] !== ':') {
|
|
127
|
+
return null;
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
cursor = skipWhitespace(source, cursor + 1);
|
|
131
|
+
|
|
132
|
+
if (parsedKey === key) {
|
|
133
|
+
return locateJsonValueRange(source, cursor, path, pathIndex + 1);
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const valueEnd = scanJsonValueEnd(source, cursor);
|
|
137
|
+
if (valueEnd < 0) {
|
|
138
|
+
return null;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
cursor = skipWhitespace(source, valueEnd);
|
|
142
|
+
if (source[cursor] === ',') {
|
|
143
|
+
cursor = skipWhitespace(source, cursor + 1);
|
|
144
|
+
continue;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
if (source[cursor] === '}') {
|
|
148
|
+
return null;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return null;
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
return null;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
function locateJsonValueInArray(
|
|
158
|
+
source: string,
|
|
159
|
+
index: number,
|
|
160
|
+
path: JsonFormPath,
|
|
161
|
+
pathIndex: number,
|
|
162
|
+
targetIndex: number,
|
|
163
|
+
): JsonTextRange | null {
|
|
164
|
+
let cursor = skipWhitespace(source, index);
|
|
165
|
+
let currentIndex = 0;
|
|
166
|
+
|
|
167
|
+
while (cursor < source.length && source[cursor] !== ']') {
|
|
168
|
+
if (currentIndex === targetIndex) {
|
|
169
|
+
return locateJsonValueRange(source, cursor, path, pathIndex + 1);
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
const valueEnd = scanJsonValueEnd(source, cursor);
|
|
173
|
+
if (valueEnd < 0) {
|
|
174
|
+
return null;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
currentIndex += 1;
|
|
178
|
+
cursor = skipWhitespace(source, valueEnd);
|
|
179
|
+
|
|
180
|
+
if (source[cursor] === ',') {
|
|
181
|
+
cursor = skipWhitespace(source, cursor + 1);
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
if (source[cursor] === ']') {
|
|
186
|
+
return null;
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
return null;
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
function scanJsonValueEnd(source: string, index: number): number {
|
|
196
|
+
index = skipWhitespace(source, index);
|
|
197
|
+
if (index >= source.length) {
|
|
198
|
+
return -1;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
const char = source[index];
|
|
202
|
+
|
|
203
|
+
if (char === '"') {
|
|
204
|
+
const stringToken = scanJsonStringToken(source, index);
|
|
205
|
+
return stringToken?.end ?? -1;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
if (char === '{') {
|
|
209
|
+
return scanJsonContainerEnd(source, index, '{', '}');
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
if (char === '[') {
|
|
213
|
+
return scanJsonContainerEnd(source, index, '[', ']');
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
if (source.startsWith('true', index)) {
|
|
217
|
+
return index + 4;
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
if (source.startsWith('false', index)) {
|
|
221
|
+
return index + 5;
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
if (source.startsWith('null', index)) {
|
|
225
|
+
return index + 4;
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
let cursor = index;
|
|
229
|
+
while (cursor < source.length && !',]} \t\r\n'.includes(source[cursor] ?? '')) {
|
|
230
|
+
cursor += 1;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
return cursor > index ? cursor : -1;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
function scanJsonContainerEnd(
|
|
237
|
+
source: string,
|
|
238
|
+
index: number,
|
|
239
|
+
openChar: '{' | '[',
|
|
240
|
+
closeChar: '}' | ']',
|
|
241
|
+
): number {
|
|
242
|
+
let depth = 0;
|
|
243
|
+
let cursor = index;
|
|
244
|
+
let inString = false;
|
|
245
|
+
let escaped = false;
|
|
246
|
+
|
|
247
|
+
while (cursor < source.length) {
|
|
248
|
+
const char = source[cursor];
|
|
249
|
+
|
|
250
|
+
if (inString) {
|
|
251
|
+
if (escaped) {
|
|
252
|
+
escaped = false;
|
|
253
|
+
} else if (char === '\\') {
|
|
254
|
+
escaped = true;
|
|
255
|
+
} else if (char === '"') {
|
|
256
|
+
inString = false;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
cursor += 1;
|
|
260
|
+
continue;
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
if (char === '"') {
|
|
264
|
+
inString = true;
|
|
265
|
+
cursor += 1;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
|
|
269
|
+
if (char === openChar) {
|
|
270
|
+
depth += 1;
|
|
271
|
+
} else if (char === closeChar) {
|
|
272
|
+
depth -= 1;
|
|
273
|
+
if (depth === 0) {
|
|
274
|
+
return cursor + 1;
|
|
275
|
+
}
|
|
276
|
+
}
|
|
277
|
+
|
|
278
|
+
cursor += 1;
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
return -1;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
function scanJsonStringToken(source: string, index: number): JsonTextRange | null {
|
|
285
|
+
if (source[index] !== '"') {
|
|
286
|
+
return null;
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
let cursor = index + 1;
|
|
290
|
+
let escaped = false;
|
|
291
|
+
|
|
292
|
+
while (cursor < source.length) {
|
|
293
|
+
const char = source[cursor];
|
|
294
|
+
|
|
295
|
+
if (escaped) {
|
|
296
|
+
escaped = false;
|
|
297
|
+
cursor += 1;
|
|
298
|
+
continue;
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
if (char === '\\') {
|
|
302
|
+
escaped = true;
|
|
303
|
+
cursor += 1;
|
|
304
|
+
continue;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
if (char === '"') {
|
|
308
|
+
return { start: index, end: cursor + 1 };
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
cursor += 1;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
return null;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
function skipWhitespace(source: string, index: number): number {
|
|
318
|
+
while (index < source.length && /\s/.test(source[index] ?? '')) {
|
|
319
|
+
index += 1;
|
|
320
|
+
}
|
|
321
|
+
|
|
322
|
+
return index;
|
|
323
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
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
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { KeybindingManagementPanel } from '@workbench-kit/react/workbench/management';
|
|
2
|
+
|
|
3
|
+
import { useKeybindingManagementModel } from './use-keybinding-management.js';
|
|
4
|
+
|
|
5
|
+
export function WorkbenchKeybindingManagementSettings() {
|
|
6
|
+
const { entries, overrideCount, resetKeybinding, setKeybinding } = useKeybindingManagementModel();
|
|
7
|
+
|
|
8
|
+
return (
|
|
9
|
+
<KeybindingManagementPanel
|
|
10
|
+
entries={entries}
|
|
11
|
+
summaryLabel={`${entries.length} command${entries.length === 1 ? '' : 's'} · ${overrideCount} user override${overrideCount === 1 ? '' : 's'}`}
|
|
12
|
+
onResetKeybinding={resetKeybinding}
|
|
13
|
+
onSetKeybinding={setKeybinding}
|
|
14
|
+
/>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseWorkbenchKeybindingsConfig,
|
|
3
|
+
type WorkbenchKeybindingDefinition,
|
|
4
|
+
} from '@workbench-kit/workbench-config';
|
|
5
|
+
import type { WorkbenchStorageReader, WorkbenchStorageWriter } from '@workbench-kit/workbench-core';
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY = 'workbench-kit/.workbench/keybindings';
|
|
8
|
+
|
|
9
|
+
export function isWorkbenchKeybindingPersistenceAvailable(): boolean {
|
|
10
|
+
try {
|
|
11
|
+
return typeof globalThis.localStorage !== 'undefined';
|
|
12
|
+
} catch {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export function readPersistedKeybindingOverrides(
|
|
18
|
+
storageKey = DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY,
|
|
19
|
+
storage?: WorkbenchStorageReader,
|
|
20
|
+
): readonly WorkbenchKeybindingDefinition[] {
|
|
21
|
+
const resolvedStorage = storage ?? getBrowserLocalStorage();
|
|
22
|
+
if (!resolvedStorage) {
|
|
23
|
+
return [];
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const raw = resolvedStorage.getItem(storageKey);
|
|
28
|
+
if (!raw) {
|
|
29
|
+
return [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
return parseWorkbenchKeybindingsConfig(JSON.parse(raw) as unknown);
|
|
33
|
+
} catch {
|
|
34
|
+
return [];
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export function writePersistedKeybindingOverrides(
|
|
39
|
+
overrides: readonly WorkbenchKeybindingDefinition[],
|
|
40
|
+
storageKey = DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY,
|
|
41
|
+
storage?: WorkbenchStorageWriter,
|
|
42
|
+
): void {
|
|
43
|
+
const resolvedStorage = storage ?? getBrowserLocalStorage();
|
|
44
|
+
if (!resolvedStorage) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
resolvedStorage.setItem(storageKey, JSON.stringify(overrides, null, 2));
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
function getBrowserLocalStorage(): (WorkbenchStorageReader & WorkbenchStorageWriter) | undefined {
|
|
52
|
+
try {
|
|
53
|
+
return globalThis.localStorage;
|
|
54
|
+
} catch {
|
|
55
|
+
return undefined;
|
|
56
|
+
}
|
|
57
|
+
}
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import type { WorkbenchCommandDescriptor } from '@workbench-kit/react/workbench';
|
|
2
|
+
|
|
3
|
+
import {
|
|
4
|
+
MANAGE_ACCOUNTS_COMMAND_ID,
|
|
5
|
+
MANAGE_COMMANDS_COMMAND_ID,
|
|
6
|
+
MANAGE_EXTENSIONS_COMMAND_ID,
|
|
7
|
+
MANAGE_KEYBINDINGS_COMMAND_ID,
|
|
8
|
+
} from './management-settings-ids.js';
|
|
9
|
+
|
|
10
|
+
/** Pure helper — kept out of React component modules for Fast Refresh. */
|
|
11
|
+
export function createWorkbenchManagementPaletteCommands(): readonly WorkbenchCommandDescriptor[] {
|
|
12
|
+
return [
|
|
13
|
+
{
|
|
14
|
+
category: 'Workbench',
|
|
15
|
+
icon: 'codicon-terminal',
|
|
16
|
+
id: MANAGE_COMMANDS_COMMAND_ID,
|
|
17
|
+
label: 'Manage Commands',
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
category: 'Workbench',
|
|
21
|
+
icon: 'codicon-keyboard',
|
|
22
|
+
id: MANAGE_KEYBINDINGS_COMMAND_ID,
|
|
23
|
+
label: 'Keyboard Shortcuts',
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
category: 'Workbench',
|
|
27
|
+
icon: 'codicon-extensions',
|
|
28
|
+
id: MANAGE_EXTENSIONS_COMMAND_ID,
|
|
29
|
+
label: 'Extensions',
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
category: 'Accounts',
|
|
33
|
+
icon: 'codicon-account',
|
|
34
|
+
id: MANAGE_ACCOUNTS_COMMAND_ID,
|
|
35
|
+
label: 'Manage Linked Accounts',
|
|
36
|
+
},
|
|
37
|
+
];
|
|
38
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export const WORKBENCH_COMMANDS_SETTINGS_CATEGORY_ID =
|
|
2
|
+
'workbench-kit.shell.command-management' as const;
|
|
3
|
+
export const WORKBENCH_KEYBINDINGS_SETTINGS_CATEGORY_ID =
|
|
4
|
+
'workbench-kit.shell.keybinding-management' as const;
|
|
5
|
+
export const WORKBENCH_ACCOUNTS_SETTINGS_CATEGORY_ID =
|
|
6
|
+
'workbench-kit.shell.account-management' as const;
|
|
7
|
+
export const WORKBENCH_EXTENSIONS_SETTINGS_CATEGORY_ID =
|
|
8
|
+
'workbench-kit.shell.extension-management' as const;
|
|
9
|
+
export const MANAGE_COMMANDS_COMMAND_ID = 'workbench-kit.shell.commands.manage' as const;
|
|
10
|
+
export const MANAGE_KEYBINDINGS_COMMAND_ID = 'workbench-kit.shell.keybindings.manage' as const;
|
|
11
|
+
export const MANAGE_EXTENSIONS_COMMAND_ID = 'workbench-kit.shell.extensions.manage' as const;
|
|
12
|
+
export const MANAGE_ACCOUNTS_COMMAND_ID = 'workbench-kit.builtin.accounts.manage' as const;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AccountManagementPanel,
|
|
3
|
+
CommandManagementPanel,
|
|
4
|
+
ExtensionManagementPanel,
|
|
5
|
+
type AccountManagementEntry,
|
|
6
|
+
} from '@workbench-kit/react/workbench/management';
|
|
7
|
+
|
|
8
|
+
import { useCommandManagementModel } from './use-command-management.js';
|
|
9
|
+
import { useExtensionManagementModel } from './use-extension-management.js';
|
|
10
|
+
import { WorkbenchKeybindingManagementSettings } from './keybinding-management-settings.js';
|
|
11
|
+
|
|
12
|
+
export { WorkbenchKeybindingManagementSettings };
|
|
13
|
+
|
|
14
|
+
export interface WorkbenchAccountManagementInput {
|
|
15
|
+
accounts: readonly AccountManagementEntry[];
|
|
16
|
+
activeAccountId?: string | undefined;
|
|
17
|
+
automationHint?: string | undefined;
|
|
18
|
+
emptyLabel?: string | undefined;
|
|
19
|
+
onSignOut?: ((accountId: string) => void) | undefined;
|
|
20
|
+
sessionLabel?: string | undefined;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** Component-only module so Vite Fast Refresh can accept this boundary. */
|
|
24
|
+
export function WorkbenchCommandManagementSettings() {
|
|
25
|
+
const { groups, lastRun, runCommand, totalCount } = useCommandManagementModel();
|
|
26
|
+
|
|
27
|
+
return (
|
|
28
|
+
<CommandManagementPanel
|
|
29
|
+
groups={groups}
|
|
30
|
+
lastRun={lastRun}
|
|
31
|
+
summaryLabel={`${totalCount} registered command${totalCount === 1 ? '' : 's'} · auto-updated from extensions`}
|
|
32
|
+
onRunCommand={runCommand}
|
|
33
|
+
/>
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function WorkbenchExtensionManagementSettings({
|
|
38
|
+
catalogUrl,
|
|
39
|
+
}: {
|
|
40
|
+
catalogUrl?: string | undefined;
|
|
41
|
+
}) {
|
|
42
|
+
const {
|
|
43
|
+
browseEntries,
|
|
44
|
+
catalogError,
|
|
45
|
+
catalogLoading,
|
|
46
|
+
installCatalogEntry,
|
|
47
|
+
installedEntries,
|
|
48
|
+
toggleInstalledEntry,
|
|
49
|
+
} = useExtensionManagementModel({ catalogUrl });
|
|
50
|
+
|
|
51
|
+
return (
|
|
52
|
+
<ExtensionManagementPanel
|
|
53
|
+
browseEntries={browseEntries}
|
|
54
|
+
catalogError={catalogError}
|
|
55
|
+
catalogLoading={catalogLoading}
|
|
56
|
+
installedEntries={installedEntries}
|
|
57
|
+
onInstall={installCatalogEntry}
|
|
58
|
+
onToggleEnabled={toggleInstalledEntry}
|
|
59
|
+
/>
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function WorkbenchAccountManagementSettings({
|
|
64
|
+
accountManagement,
|
|
65
|
+
}: {
|
|
66
|
+
accountManagement: WorkbenchAccountManagementInput;
|
|
67
|
+
}) {
|
|
68
|
+
return (
|
|
69
|
+
<AccountManagementPanel
|
|
70
|
+
automationHint="Linked accounts are project integrations exposed by extensions or host providers. Your Workbench service profile is managed from the profile menu."
|
|
71
|
+
emptyLabel="No linked project accounts are configured."
|
|
72
|
+
{...accountManagement}
|
|
73
|
+
/>
|
|
74
|
+
);
|
|
75
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import {
|
|
2
|
+
parseWorkbenchSettingsConfig,
|
|
3
|
+
type WorkbenchSettingsConfig,
|
|
4
|
+
} from '@workbench-kit/workbench-config';
|
|
5
|
+
import type { WorkbenchStorageReader, WorkbenchStorageWriter } from '@workbench-kit/workbench-core';
|
|
6
|
+
|
|
7
|
+
export const DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY =
|
|
8
|
+
'workbench-kit/.workbench/settings.local';
|
|
9
|
+
|
|
10
|
+
export function isWorkbenchLocalPreferencePersistenceAvailable(): boolean {
|
|
11
|
+
try {
|
|
12
|
+
return typeof globalThis.localStorage !== 'undefined';
|
|
13
|
+
} catch {
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export function readPersistedLocalPreferences(
|
|
19
|
+
storageKey = DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY,
|
|
20
|
+
storage?: WorkbenchStorageReader,
|
|
21
|
+
): WorkbenchSettingsConfig {
|
|
22
|
+
const resolvedStorage = storage ?? getBrowserLocalStorage();
|
|
23
|
+
if (!resolvedStorage) {
|
|
24
|
+
return {};
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
try {
|
|
28
|
+
const raw = resolvedStorage.getItem(storageKey);
|
|
29
|
+
if (!raw) {
|
|
30
|
+
return {};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
return parseWorkbenchSettingsConfig(JSON.parse(raw) as unknown);
|
|
34
|
+
} catch {
|
|
35
|
+
return {};
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function writePersistedLocalPreferences(
|
|
40
|
+
values: WorkbenchSettingsConfig,
|
|
41
|
+
storageKey = DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY,
|
|
42
|
+
storage?: WorkbenchStorageWriter,
|
|
43
|
+
): void {
|
|
44
|
+
const resolvedStorage = storage ?? getBrowserLocalStorage();
|
|
45
|
+
if (!resolvedStorage) {
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
resolvedStorage.setItem(storageKey, JSON.stringify(values, null, 2));
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getBrowserLocalStorage(): (WorkbenchStorageReader & WorkbenchStorageWriter) | undefined {
|
|
53
|
+
try {
|
|
54
|
+
return globalThis.localStorage;
|
|
55
|
+
} catch {
|
|
56
|
+
return undefined;
|
|
57
|
+
}
|
|
58
|
+
}
|