@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,573 +1,603 @@
|
|
|
1
|
-
import {
|
|
2
|
-
createContext,
|
|
3
|
-
useCallback,
|
|
4
|
-
useContext,
|
|
5
|
-
useEffect,
|
|
6
|
-
useMemo,
|
|
7
|
-
useRef,
|
|
8
|
-
useState,
|
|
9
|
-
type ReactNode,
|
|
10
|
-
} from 'react';
|
|
11
|
-
import {
|
|
12
|
-
BUILTIN_WORKBENCH_EXTENSIONS,
|
|
13
|
-
collectConfigurationDefaults,
|
|
14
|
-
createEditorService,
|
|
15
|
-
ExtensionRegistry,
|
|
16
|
-
LayoutService,
|
|
17
|
-
loadInstalledExtensions,
|
|
18
|
-
mergeExtensionsConfigWithInstallState,
|
|
19
|
-
PreferenceService,
|
|
20
|
-
registerEditorSaveCommand,
|
|
21
|
-
registerHostWorkbenchThemes,
|
|
22
|
-
resolveInstalledAvailableExtensions,
|
|
23
|
-
resolveWorkbenchExtensions,
|
|
24
|
-
SAMPLE_WORKBENCH_EXTENSIONS,
|
|
25
|
-
DEFAULT_INSTALLED_EXTENSIONS_STORAGE_KEY,
|
|
26
|
-
WORKBENCH_EDITOR_SERVICE_CAPABILITY_ID,
|
|
27
|
-
|
|
28
|
-
type
|
|
29
|
-
type
|
|
30
|
-
type
|
|
31
|
-
type
|
|
32
|
-
type
|
|
33
|
-
type
|
|
34
|
-
type
|
|
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
|
-
waitForExtensionStartup(): Promise<void>;
|
|
162
|
-
workspaceHostPort?: WorkbenchWorkspaceHostPort | undefined;
|
|
163
|
-
}
|
|
164
|
-
|
|
165
|
-
interface
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
return
|
|
285
|
-
}
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
)
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
const
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
const
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
const
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
const
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
const
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
const
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
}
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
services.
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
};
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
}
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
1
|
+
import {
|
|
2
|
+
createContext,
|
|
3
|
+
useCallback,
|
|
4
|
+
useContext,
|
|
5
|
+
useEffect,
|
|
6
|
+
useMemo,
|
|
7
|
+
useRef,
|
|
8
|
+
useState,
|
|
9
|
+
type ReactNode,
|
|
10
|
+
} from 'react';
|
|
11
|
+
import {
|
|
12
|
+
BUILTIN_WORKBENCH_EXTENSIONS,
|
|
13
|
+
collectConfigurationDefaults,
|
|
14
|
+
createEditorService,
|
|
15
|
+
ExtensionRegistry,
|
|
16
|
+
LayoutService,
|
|
17
|
+
loadInstalledExtensions,
|
|
18
|
+
mergeExtensionsConfigWithInstallState,
|
|
19
|
+
PreferenceService,
|
|
20
|
+
registerEditorSaveCommand,
|
|
21
|
+
registerHostWorkbenchThemes,
|
|
22
|
+
resolveInstalledAvailableExtensions,
|
|
23
|
+
resolveWorkbenchExtensions,
|
|
24
|
+
SAMPLE_WORKBENCH_EXTENSIONS,
|
|
25
|
+
DEFAULT_INSTALLED_EXTENSIONS_STORAGE_KEY,
|
|
26
|
+
WORKBENCH_EDITOR_SERVICE_CAPABILITY_ID,
|
|
27
|
+
verifyWorkbenchExtensionsAgainstLock,
|
|
28
|
+
type EditorState,
|
|
29
|
+
type EditorService,
|
|
30
|
+
type ExtensionIntegrityMode,
|
|
31
|
+
type PreferenceService as PreferenceServiceType,
|
|
32
|
+
type WorkbenchHostThemeRegistration,
|
|
33
|
+
type WorkbenchStorageAdapter,
|
|
34
|
+
type WorkbenchEditorSavePort,
|
|
35
|
+
type WorkbenchExtensionDescription,
|
|
36
|
+
type WorkbenchLayoutStateInput,
|
|
37
|
+
} from '@workbench-kit/workbench-core';
|
|
38
|
+
import {
|
|
39
|
+
ContextKeyService,
|
|
40
|
+
createWorkbenchPermissionContextKeys,
|
|
41
|
+
type ContextKeyValue,
|
|
42
|
+
} from '@workbench-kit/platform';
|
|
43
|
+
import type {
|
|
44
|
+
WorkbenchExtensionsConfig,
|
|
45
|
+
WorkbenchExtensionsLock,
|
|
46
|
+
WorkbenchKeybindingDefinition,
|
|
47
|
+
WorkbenchSettingsConfig,
|
|
48
|
+
WorkbenchUserCommandDefinition,
|
|
49
|
+
} from '@workbench-kit/workbench-config';
|
|
50
|
+
import {
|
|
51
|
+
DEFAULT_WORKBENCH_LAYOUT_STORAGE_KEY,
|
|
52
|
+
isWorkbenchLayoutPersistenceAvailable,
|
|
53
|
+
resolvePersistedWorkbenchLayout,
|
|
54
|
+
writePersistedWorkbenchLayout,
|
|
55
|
+
} from '../workbench/layout-storage.js';
|
|
56
|
+
import {
|
|
57
|
+
DEFAULT_WORKBENCH_EDITOR_STATE_STORAGE_KEY,
|
|
58
|
+
isWorkbenchEditorStatePersistenceAvailable,
|
|
59
|
+
readPersistedEditorState,
|
|
60
|
+
writePersistedEditorState,
|
|
61
|
+
} from '../editor/state-storage.js';
|
|
62
|
+
import {
|
|
63
|
+
DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY,
|
|
64
|
+
isWorkbenchKeybindingPersistenceAvailable,
|
|
65
|
+
readPersistedKeybindingOverrides,
|
|
66
|
+
writePersistedKeybindingOverrides,
|
|
67
|
+
} from '../management/keybinding-overrides-storage.js';
|
|
68
|
+
import {
|
|
69
|
+
BUILTIN_EXPLORER_VIEW_CONTAINER_ID,
|
|
70
|
+
publishExplorerRevealRequest,
|
|
71
|
+
runExplorerHostCommandSideEffects,
|
|
72
|
+
} from '../explorer/reveal.js';
|
|
73
|
+
import {
|
|
74
|
+
BUILTIN_EXTENSIONS_FOCUS_COMMAND_ID,
|
|
75
|
+
BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID,
|
|
76
|
+
} from '../extensions/view-data.js';
|
|
77
|
+
import {
|
|
78
|
+
DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY,
|
|
79
|
+
isWorkbenchLocalPreferencePersistenceAvailable,
|
|
80
|
+
readPersistedLocalPreferences,
|
|
81
|
+
writePersistedLocalPreferences,
|
|
82
|
+
} from '../management/preference-settings-storage.js';
|
|
83
|
+
import { registerWorkbenchUserCommands } from '../workbench/user-commands.js';
|
|
84
|
+
import { EditorWorkspaceReconciler } from '../editor/workspace-reconcile.js';
|
|
85
|
+
import {
|
|
86
|
+
DEFAULT_EDITOR_DOCUMENT_VIEW_PROVIDERS,
|
|
87
|
+
type EditorDocumentViewProvider,
|
|
88
|
+
} from '../editor/view-providers.js';
|
|
89
|
+
import type { EditorDocumentViewProviderRegistry } from '@workbench-kit/workbench-core';
|
|
90
|
+
|
|
91
|
+
export interface WorkbenchWorkspaceHostPort extends WorkbenchEditorSavePort {
|
|
92
|
+
readonly capabilityId?: string | undefined;
|
|
93
|
+
readonly service?: unknown;
|
|
94
|
+
dispose?(): void;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
export type { WorkbenchStorageAdapter };
|
|
98
|
+
|
|
99
|
+
const DEFAULT_AVAILABLE_EXTENSIONS = [
|
|
100
|
+
...BUILTIN_WORKBENCH_EXTENSIONS,
|
|
101
|
+
...SAMPLE_WORKBENCH_EXTENSIONS,
|
|
102
|
+
] as const;
|
|
103
|
+
|
|
104
|
+
export interface WorkbenchProviderProps {
|
|
105
|
+
availableExtensions?: readonly WorkbenchExtensionDescription[];
|
|
106
|
+
children: ReactNode;
|
|
107
|
+
contextKeyValues?: Readonly<Record<string, ContextKeyValue>> | undefined;
|
|
108
|
+
documentViewProviders?: readonly EditorDocumentViewProvider[] | undefined;
|
|
109
|
+
/**
|
|
110
|
+
* When set with `extensionIntegrityMode` other than `off`, enabled extensions
|
|
111
|
+
* are checked against the lock before registration.
|
|
112
|
+
*/
|
|
113
|
+
extensionsLock?: WorkbenchExtensionsLock | undefined;
|
|
114
|
+
/**
|
|
115
|
+
* Lock verification mode. Default `off` preserves existing hosts.
|
|
116
|
+
* Sample hosts may opt into `fail-closed`.
|
|
117
|
+
*/
|
|
118
|
+
extensionIntegrityMode?: ExtensionIntegrityMode | undefined;
|
|
119
|
+
extensionsConfig?: WorkbenchExtensionsConfig;
|
|
120
|
+
editorStateStorage?: WorkbenchStorageAdapter;
|
|
121
|
+
editorStateStorageKey?: string;
|
|
122
|
+
hostThemes?: readonly WorkbenchHostThemeRegistration[];
|
|
123
|
+
initialKeybindingOverrides?: readonly WorkbenchKeybindingDefinition[];
|
|
124
|
+
initialEditorState?: EditorState;
|
|
125
|
+
initialLayout?: WorkbenchLayoutStateInput;
|
|
126
|
+
initialWorkspaceSettings?: WorkbenchSettingsConfig;
|
|
127
|
+
includeDefaultDocumentViewProviders?: boolean | undefined;
|
|
128
|
+
installedExtensionsStorage?: WorkbenchStorageAdapter;
|
|
129
|
+
installedExtensionsStorageKey?: string;
|
|
130
|
+
keybindingOverridesStorage?: WorkbenchStorageAdapter;
|
|
131
|
+
keybindingOverridesStorageKey?: string;
|
|
132
|
+
layoutStorage?: WorkbenchStorageAdapter;
|
|
133
|
+
layoutStorageKey?: string;
|
|
134
|
+
localPreferenceStorage?: WorkbenchStorageAdapter;
|
|
135
|
+
localPreferenceStorageKey?: string;
|
|
136
|
+
onKeybindingOverridesChange?:
|
|
137
|
+
((overrides: readonly WorkbenchKeybindingDefinition[]) => void) | undefined;
|
|
138
|
+
persistEditorState?: boolean;
|
|
139
|
+
persistKeybindingOverrides?: boolean;
|
|
140
|
+
persistLayout?: boolean;
|
|
141
|
+
persistLocalPreferences?: boolean;
|
|
142
|
+
userCommands?: readonly WorkbenchUserCommandDefinition[];
|
|
143
|
+
workspaceHostPort?: WorkbenchWorkspaceHostPort | undefined;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export interface WorkbenchContextValue {
|
|
147
|
+
activateCommand(commandId: string): Promise<readonly { readonly extensionId: string }[]>;
|
|
148
|
+
contextKeyService: ContextKeyService;
|
|
149
|
+
editorDocumentViewProviders: EditorDocumentViewProviderRegistry;
|
|
150
|
+
editorService: EditorService;
|
|
151
|
+
executeCommand(commandId: string, ...args: unknown[]): Promise<unknown>;
|
|
152
|
+
extensionRegistry: ExtensionRegistry;
|
|
153
|
+
installedExtensionsStorage?: WorkbenchStorageAdapter;
|
|
154
|
+
installedExtensionsStorageKey: string;
|
|
155
|
+
keybindingOverrides: readonly WorkbenchKeybindingDefinition[];
|
|
156
|
+
layoutService: LayoutService;
|
|
157
|
+
missingExtensionIds: readonly string[];
|
|
158
|
+
preferenceService: PreferenceServiceType;
|
|
159
|
+
resetCommandKeybindingOverride(commandId: string): void;
|
|
160
|
+
setCommandKeybindingOverride(commandId: string, key: string): void;
|
|
161
|
+
waitForExtensionStartup(): Promise<void>;
|
|
162
|
+
workspaceHostPort?: WorkbenchWorkspaceHostPort | undefined;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
interface WorkbenchProviderServices {
|
|
166
|
+
activateStartup(): void;
|
|
167
|
+
dispose(): void;
|
|
168
|
+
editorDocumentViewProviders: EditorDocumentViewProviderRegistry;
|
|
169
|
+
editorService: EditorService;
|
|
170
|
+
extensionRegistry: ExtensionRegistry;
|
|
171
|
+
layoutService: LayoutService;
|
|
172
|
+
missingExtensionIds: readonly string[];
|
|
173
|
+
preferenceService: PreferenceServiceType;
|
|
174
|
+
waitForExtensionStartup(): Promise<void>;
|
|
175
|
+
workspaceHostPort?: WorkbenchWorkspaceHostPort | undefined;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
interface DeferredProviderDispose {
|
|
179
|
+
readonly services: WorkbenchProviderServices;
|
|
180
|
+
readonly timeout: ReturnType<typeof setTimeout>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
const WorkbenchContext = createContext<WorkbenchContextValue | undefined>(undefined);
|
|
184
|
+
|
|
185
|
+
export function WorkbenchProvider({
|
|
186
|
+
availableExtensions,
|
|
187
|
+
children,
|
|
188
|
+
contextKeyValues,
|
|
189
|
+
documentViewProviders,
|
|
190
|
+
editorStateStorage,
|
|
191
|
+
editorStateStorageKey = DEFAULT_WORKBENCH_EDITOR_STATE_STORAGE_KEY,
|
|
192
|
+
extensionIntegrityMode = 'off',
|
|
193
|
+
extensionsConfig,
|
|
194
|
+
extensionsLock,
|
|
195
|
+
hostThemes = [],
|
|
196
|
+
initialEditorState,
|
|
197
|
+
initialKeybindingOverrides,
|
|
198
|
+
initialLayout,
|
|
199
|
+
initialWorkspaceSettings,
|
|
200
|
+
includeDefaultDocumentViewProviders,
|
|
201
|
+
installedExtensionsStorage,
|
|
202
|
+
installedExtensionsStorageKey = DEFAULT_INSTALLED_EXTENSIONS_STORAGE_KEY,
|
|
203
|
+
keybindingOverridesStorage,
|
|
204
|
+
keybindingOverridesStorageKey = DEFAULT_WORKBENCH_KEYBINDING_STORAGE_KEY,
|
|
205
|
+
layoutStorage,
|
|
206
|
+
layoutStorageKey = DEFAULT_WORKBENCH_LAYOUT_STORAGE_KEY,
|
|
207
|
+
localPreferenceStorage,
|
|
208
|
+
localPreferenceStorageKey = DEFAULT_WORKBENCH_LOCAL_PREFERENCE_STORAGE_KEY,
|
|
209
|
+
onKeybindingOverridesChange,
|
|
210
|
+
persistEditorState,
|
|
211
|
+
persistKeybindingOverrides,
|
|
212
|
+
persistLayout,
|
|
213
|
+
persistLocalPreferences,
|
|
214
|
+
userCommands = [],
|
|
215
|
+
workspaceHostPort,
|
|
216
|
+
}: WorkbenchProviderProps) {
|
|
217
|
+
const hostAvailableExtensions = availableExtensions ?? DEFAULT_AVAILABLE_EXTENSIONS;
|
|
218
|
+
const deferredDisposeRef = useRef<DeferredProviderDispose | undefined>(undefined);
|
|
219
|
+
const shouldPersistEditorState =
|
|
220
|
+
persistEditorState ??
|
|
221
|
+
(editorStateStorage !== undefined || isWorkbenchEditorStatePersistenceAvailable());
|
|
222
|
+
const shouldPersistKeybindingOverrides =
|
|
223
|
+
persistKeybindingOverrides ??
|
|
224
|
+
(keybindingOverridesStorage !== undefined || isWorkbenchKeybindingPersistenceAvailable());
|
|
225
|
+
const shouldPersistLayout =
|
|
226
|
+
persistLayout ?? (layoutStorage !== undefined || isWorkbenchLayoutPersistenceAvailable());
|
|
227
|
+
const shouldPersistLocalPreferences =
|
|
228
|
+
persistLocalPreferences ??
|
|
229
|
+
(localPreferenceStorage !== undefined || isWorkbenchLocalPreferencePersistenceAvailable());
|
|
230
|
+
const resolvedInitialLayout = useMemo(
|
|
231
|
+
() =>
|
|
232
|
+
resolvePersistedWorkbenchLayout(initialLayout, {
|
|
233
|
+
persistLayout: shouldPersistLayout,
|
|
234
|
+
storage: layoutStorage,
|
|
235
|
+
storageKey: layoutStorageKey,
|
|
236
|
+
}),
|
|
237
|
+
[initialLayout, layoutStorage, layoutStorageKey, shouldPersistLayout],
|
|
238
|
+
);
|
|
239
|
+
const resolvedInitialEditorState = useMemo(
|
|
240
|
+
() =>
|
|
241
|
+
initialEditorState ??
|
|
242
|
+
(shouldPersistEditorState
|
|
243
|
+
? readPersistedEditorState(editorStateStorageKey, editorStateStorage)
|
|
244
|
+
: undefined),
|
|
245
|
+
[editorStateStorage, editorStateStorageKey, initialEditorState, shouldPersistEditorState],
|
|
246
|
+
);
|
|
247
|
+
const resolvedInitialKeybindingOverrides = useMemo(
|
|
248
|
+
() =>
|
|
249
|
+
initialKeybindingOverrides ??
|
|
250
|
+
(shouldPersistKeybindingOverrides
|
|
251
|
+
? readPersistedKeybindingOverrides(
|
|
252
|
+
keybindingOverridesStorageKey,
|
|
253
|
+
keybindingOverridesStorage,
|
|
254
|
+
)
|
|
255
|
+
: []),
|
|
256
|
+
[
|
|
257
|
+
initialKeybindingOverrides,
|
|
258
|
+
keybindingOverridesStorage,
|
|
259
|
+
keybindingOverridesStorageKey,
|
|
260
|
+
shouldPersistKeybindingOverrides,
|
|
261
|
+
],
|
|
262
|
+
);
|
|
263
|
+
const [keybindingOverrides, setKeybindingOverridesState] = useState(
|
|
264
|
+
resolvedInitialKeybindingOverrides,
|
|
265
|
+
);
|
|
266
|
+
const contextKeyService = useMemo(() => {
|
|
267
|
+
const service = new ContextKeyService();
|
|
268
|
+
for (const [key, value] of Object.entries(
|
|
269
|
+
createWorkbenchPermissionContextKeys({ role: 'owner' }),
|
|
270
|
+
)) {
|
|
271
|
+
service.set(key, value);
|
|
272
|
+
}
|
|
273
|
+
return service;
|
|
274
|
+
}, []);
|
|
275
|
+
|
|
276
|
+
useEffect(() => {
|
|
277
|
+
return () => {
|
|
278
|
+
contextKeyService.dispose();
|
|
279
|
+
};
|
|
280
|
+
}, [contextKeyService]);
|
|
281
|
+
|
|
282
|
+
useEffect(() => {
|
|
283
|
+
if (contextKeyValues === undefined) {
|
|
284
|
+
return;
|
|
285
|
+
}
|
|
286
|
+
|
|
287
|
+
for (const [key, value] of Object.entries(contextKeyValues)) {
|
|
288
|
+
contextKeyService.set(key, value);
|
|
289
|
+
}
|
|
290
|
+
}, [contextKeyService, contextKeyValues]);
|
|
291
|
+
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
setKeybindingOverridesState(resolvedInitialKeybindingOverrides);
|
|
294
|
+
}, [resolvedInitialKeybindingOverrides]);
|
|
295
|
+
|
|
296
|
+
const setCommandKeybindingOverride = useCallback((commandId: string, key: string) => {
|
|
297
|
+
setKeybindingOverridesState((current) => {
|
|
298
|
+
const without = current.filter((binding) => binding.command !== commandId);
|
|
299
|
+
return [...without, { command: commandId, key }];
|
|
300
|
+
});
|
|
301
|
+
}, []);
|
|
302
|
+
|
|
303
|
+
const resetCommandKeybindingOverride = useCallback((commandId: string) => {
|
|
304
|
+
setKeybindingOverridesState((current) =>
|
|
305
|
+
current.filter((binding) => binding.command !== commandId),
|
|
306
|
+
);
|
|
307
|
+
}, []);
|
|
308
|
+
|
|
309
|
+
useEffect(() => {
|
|
310
|
+
onKeybindingOverridesChange?.(keybindingOverrides);
|
|
311
|
+
if (!shouldPersistKeybindingOverrides) {
|
|
312
|
+
return;
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
writePersistedKeybindingOverrides(
|
|
316
|
+
keybindingOverrides,
|
|
317
|
+
keybindingOverridesStorageKey,
|
|
318
|
+
keybindingOverridesStorage,
|
|
319
|
+
);
|
|
320
|
+
}, [
|
|
321
|
+
keybindingOverrides,
|
|
322
|
+
keybindingOverridesStorage,
|
|
323
|
+
keybindingOverridesStorageKey,
|
|
324
|
+
onKeybindingOverridesChange,
|
|
325
|
+
shouldPersistKeybindingOverrides,
|
|
326
|
+
]);
|
|
327
|
+
|
|
328
|
+
const resolvedInitialLocalPreferences = useMemo(
|
|
329
|
+
() =>
|
|
330
|
+
shouldPersistLocalPreferences
|
|
331
|
+
? readPersistedLocalPreferences(localPreferenceStorageKey, localPreferenceStorage)
|
|
332
|
+
: {},
|
|
333
|
+
[localPreferenceStorage, localPreferenceStorageKey, shouldPersistLocalPreferences],
|
|
334
|
+
);
|
|
335
|
+
|
|
336
|
+
const services = useMemo<WorkbenchProviderServices>(() => {
|
|
337
|
+
const extensionRegistry = new ExtensionRegistry();
|
|
338
|
+
const editorDocumentViewProviders = extensionRegistry.editorDocumentViews;
|
|
339
|
+
const editorDocumentViewProviderDisposables = [
|
|
340
|
+
...(includeDefaultDocumentViewProviders === false
|
|
341
|
+
? []
|
|
342
|
+
: DEFAULT_EDITOR_DOCUMENT_VIEW_PROVIDERS),
|
|
343
|
+
...(documentViewProviders ?? []),
|
|
344
|
+
].map((provider) => editorDocumentViewProviders.registerProvider(provider));
|
|
345
|
+
const layoutService = new LayoutService(resolvedInitialLayout);
|
|
346
|
+
const editorService = createEditorService({
|
|
347
|
+
editorHostFactories: extensionRegistry.editorHostFactories,
|
|
348
|
+
editorResolvers: extensionRegistry.editorResolvers,
|
|
349
|
+
initialState: resolvedInitialEditorState,
|
|
350
|
+
resolveEditorResource: workspaceHostPort?.resolveResource?.bind(workspaceHostPort),
|
|
351
|
+
});
|
|
352
|
+
const installedRecords = loadInstalledExtensions(
|
|
353
|
+
installedExtensionsStorageKey,
|
|
354
|
+
installedExtensionsStorage,
|
|
355
|
+
);
|
|
356
|
+
const resolvedAvailableExtensions =
|
|
357
|
+
availableExtensions === undefined
|
|
358
|
+
? resolveInstalledAvailableExtensions(hostAvailableExtensions, installedRecords)
|
|
359
|
+
: hostAvailableExtensions;
|
|
360
|
+
const config = mergeExtensionsConfigWithInstallState(
|
|
361
|
+
extensionsConfig ??
|
|
362
|
+
({
|
|
363
|
+
enabled: resolvedAvailableExtensions.map(({ manifest }) => manifest.id),
|
|
364
|
+
recommendations: [],
|
|
365
|
+
} satisfies WorkbenchExtensionsConfig),
|
|
366
|
+
installedRecords,
|
|
367
|
+
);
|
|
368
|
+
const resolution = resolveWorkbenchExtensions(config, resolvedAvailableExtensions);
|
|
369
|
+
const integrity = verifyWorkbenchExtensionsAgainstLock(
|
|
370
|
+
resolution.enabledExtensions,
|
|
371
|
+
extensionsLock,
|
|
372
|
+
extensionIntegrityMode,
|
|
373
|
+
);
|
|
374
|
+
if (integrity.diagnostics.length > 0 && typeof console !== 'undefined') {
|
|
375
|
+
for (const diagnostic of integrity.diagnostics) {
|
|
376
|
+
console.warn(`[workbench-kit] ${diagnostic.message}`);
|
|
377
|
+
}
|
|
378
|
+
}
|
|
379
|
+
const extensionDisposables = extensionRegistry.registerExtensions(integrity.accepted);
|
|
380
|
+
const hostThemeDisposables = registerHostWorkbenchThemes(extensionRegistry.themes, hostThemes);
|
|
381
|
+
const editorServiceCapabilityDisposable = extensionRegistry.capabilityRegistry.register({
|
|
382
|
+
id: WORKBENCH_EDITOR_SERVICE_CAPABILITY_ID,
|
|
383
|
+
get: () => editorService,
|
|
384
|
+
});
|
|
385
|
+
const workspaceHostCapabilityDisposable =
|
|
386
|
+
workspaceHostPort?.capabilityId && workspaceHostPort.service !== undefined
|
|
387
|
+
? extensionRegistry.capabilityRegistry.register({
|
|
388
|
+
id: workspaceHostPort.capabilityId,
|
|
389
|
+
get: () => workspaceHostPort.service,
|
|
390
|
+
dispose: workspaceHostPort.dispose,
|
|
391
|
+
})
|
|
392
|
+
: undefined;
|
|
393
|
+
const saveCommandDisposable = workspaceHostPort
|
|
394
|
+
? registerEditorSaveCommand(extensionRegistry.commands, {
|
|
395
|
+
editorSavePort: workspaceHostPort,
|
|
396
|
+
editorService,
|
|
397
|
+
})
|
|
398
|
+
: undefined;
|
|
399
|
+
const userCommandDisposables = registerWorkbenchUserCommands(extensionRegistry, userCommands);
|
|
400
|
+
const preferenceService = new PreferenceService({
|
|
401
|
+
contributionDefaults: collectConfigurationDefaults(
|
|
402
|
+
extensionRegistry.configurations.getConfigurations(),
|
|
403
|
+
),
|
|
404
|
+
initialValuesByScope: {
|
|
405
|
+
local: resolvedInitialLocalPreferences,
|
|
406
|
+
workspace: initialWorkspaceSettings ?? {},
|
|
407
|
+
},
|
|
408
|
+
});
|
|
409
|
+
let startupActivation: Promise<readonly { readonly extensionId: string }[]> | undefined;
|
|
410
|
+
const ensureStartupActivation = () => {
|
|
411
|
+
startupActivation ??= extensionRegistry.activateStartup();
|
|
412
|
+
return startupActivation;
|
|
413
|
+
};
|
|
414
|
+
|
|
415
|
+
return {
|
|
416
|
+
activateStartup: () => {
|
|
417
|
+
void ensureStartupActivation();
|
|
418
|
+
},
|
|
419
|
+
dispose: () => {
|
|
420
|
+
saveCommandDisposable?.dispose();
|
|
421
|
+
userCommandDisposables.dispose();
|
|
422
|
+
editorServiceCapabilityDisposable.dispose();
|
|
423
|
+
workspaceHostCapabilityDisposable?.dispose();
|
|
424
|
+
hostThemeDisposables.dispose();
|
|
425
|
+
extensionDisposables.dispose();
|
|
426
|
+
if (!workspaceHostCapabilityDisposable) {
|
|
427
|
+
workspaceHostPort?.dispose?.();
|
|
428
|
+
}
|
|
429
|
+
editorService.dispose();
|
|
430
|
+
for (const disposable of editorDocumentViewProviderDisposables) {
|
|
431
|
+
disposable.dispose();
|
|
432
|
+
}
|
|
433
|
+
extensionRegistry.dispose();
|
|
434
|
+
layoutService.dispose();
|
|
435
|
+
preferenceService.dispose();
|
|
436
|
+
},
|
|
437
|
+
editorDocumentViewProviders,
|
|
438
|
+
editorService,
|
|
439
|
+
extensionRegistry,
|
|
440
|
+
layoutService,
|
|
441
|
+
missingExtensionIds: [
|
|
442
|
+
...resolution.missingExtensionIds,
|
|
443
|
+
...integrity.rejected.map((extension) => extension.manifest.id),
|
|
444
|
+
],
|
|
445
|
+
preferenceService,
|
|
446
|
+
waitForExtensionStartup: () => ensureStartupActivation().then(() => undefined),
|
|
447
|
+
workspaceHostPort,
|
|
448
|
+
};
|
|
449
|
+
}, [
|
|
450
|
+
availableExtensions,
|
|
451
|
+
documentViewProviders,
|
|
452
|
+
extensionIntegrityMode,
|
|
453
|
+
extensionsLock,
|
|
454
|
+
hostAvailableExtensions,
|
|
455
|
+
extensionsConfig,
|
|
456
|
+
hostThemes,
|
|
457
|
+
includeDefaultDocumentViewProviders,
|
|
458
|
+
initialWorkspaceSettings,
|
|
459
|
+
installedExtensionsStorage,
|
|
460
|
+
installedExtensionsStorageKey,
|
|
461
|
+
resolvedInitialEditorState,
|
|
462
|
+
resolvedInitialLayout,
|
|
463
|
+
resolvedInitialLocalPreferences,
|
|
464
|
+
userCommands,
|
|
465
|
+
workspaceHostPort,
|
|
466
|
+
]);
|
|
467
|
+
|
|
468
|
+
useEffect(() => {
|
|
469
|
+
if (!shouldPersistLayout) {
|
|
470
|
+
return undefined;
|
|
471
|
+
}
|
|
472
|
+
|
|
473
|
+
const disposable = services.layoutService.onDidChangeLayout(({ state }) => {
|
|
474
|
+
writePersistedWorkbenchLayout(state, layoutStorageKey, layoutStorage);
|
|
475
|
+
});
|
|
476
|
+
|
|
477
|
+
return () => {
|
|
478
|
+
disposable.dispose();
|
|
479
|
+
};
|
|
480
|
+
}, [layoutStorage, layoutStorageKey, services.layoutService, shouldPersistLayout]);
|
|
481
|
+
|
|
482
|
+
useEffect(() => {
|
|
483
|
+
if (!shouldPersistEditorState) {
|
|
484
|
+
return undefined;
|
|
485
|
+
}
|
|
486
|
+
|
|
487
|
+
const disposable = services.editorService.onDidChangeEditors(({ state }) => {
|
|
488
|
+
writePersistedEditorState(state, editorStateStorageKey, editorStateStorage);
|
|
489
|
+
});
|
|
490
|
+
|
|
491
|
+
return () => {
|
|
492
|
+
disposable.dispose();
|
|
493
|
+
};
|
|
494
|
+
}, [editorStateStorage, editorStateStorageKey, services.editorService, shouldPersistEditorState]);
|
|
495
|
+
|
|
496
|
+
useEffect(() => {
|
|
497
|
+
if (!shouldPersistLocalPreferences) {
|
|
498
|
+
return undefined;
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
const disposable = services.preferenceService.onDidChangePreference((event) => {
|
|
502
|
+
if (event.scope !== 'local') {
|
|
503
|
+
return;
|
|
504
|
+
}
|
|
505
|
+
|
|
506
|
+
writePersistedLocalPreferences(
|
|
507
|
+
services.preferenceService.getScopedValues('local'),
|
|
508
|
+
localPreferenceStorageKey,
|
|
509
|
+
localPreferenceStorage,
|
|
510
|
+
);
|
|
511
|
+
});
|
|
512
|
+
|
|
513
|
+
return () => {
|
|
514
|
+
disposable.dispose();
|
|
515
|
+
};
|
|
516
|
+
}, [
|
|
517
|
+
localPreferenceStorage,
|
|
518
|
+
localPreferenceStorageKey,
|
|
519
|
+
services.preferenceService,
|
|
520
|
+
shouldPersistLocalPreferences,
|
|
521
|
+
]);
|
|
522
|
+
|
|
523
|
+
useEffect(() => {
|
|
524
|
+
const deferredDispose = deferredDisposeRef.current;
|
|
525
|
+
if (deferredDispose?.services === services) {
|
|
526
|
+
clearTimeout(deferredDispose.timeout);
|
|
527
|
+
deferredDisposeRef.current = undefined;
|
|
528
|
+
}
|
|
529
|
+
|
|
530
|
+
services.activateStartup();
|
|
531
|
+
|
|
532
|
+
return () => {
|
|
533
|
+
const timeout = setTimeout(() => {
|
|
534
|
+
if (deferredDisposeRef.current?.services === services) {
|
|
535
|
+
deferredDisposeRef.current = undefined;
|
|
536
|
+
}
|
|
537
|
+
services.dispose();
|
|
538
|
+
}, 0);
|
|
539
|
+
|
|
540
|
+
deferredDisposeRef.current = { services, timeout };
|
|
541
|
+
};
|
|
542
|
+
}, [services]);
|
|
543
|
+
|
|
544
|
+
const value = useMemo<WorkbenchContextValue>(
|
|
545
|
+
() => ({
|
|
546
|
+
activateCommand: (commandId) => services.extensionRegistry.activateCommand(commandId),
|
|
547
|
+
contextKeyService,
|
|
548
|
+
editorDocumentViewProviders: services.editorDocumentViewProviders,
|
|
549
|
+
editorService: services.editorService,
|
|
550
|
+
executeCommand: async (commandId, ...args) => {
|
|
551
|
+
const result = await services.extensionRegistry.executeCommand(commandId, ...args);
|
|
552
|
+
await runExplorerHostCommandSideEffects(commandId, args, result, {
|
|
553
|
+
focusExplorerView: () => {
|
|
554
|
+
services.layoutService.setActiveViewContainer(BUILTIN_EXPLORER_VIEW_CONTAINER_ID);
|
|
555
|
+
services.layoutService.setSideBarVisible(true);
|
|
556
|
+
},
|
|
557
|
+
revealPath: publishExplorerRevealRequest,
|
|
558
|
+
});
|
|
559
|
+
if (commandId === BUILTIN_EXTENSIONS_FOCUS_COMMAND_ID) {
|
|
560
|
+
services.layoutService.setActiveViewContainer(BUILTIN_EXTENSIONS_VIEW_CONTAINER_ID);
|
|
561
|
+
services.layoutService.setSideBarVisible(true);
|
|
562
|
+
}
|
|
563
|
+
return result;
|
|
564
|
+
},
|
|
565
|
+
extensionRegistry: services.extensionRegistry,
|
|
566
|
+
installedExtensionsStorage,
|
|
567
|
+
installedExtensionsStorageKey,
|
|
568
|
+
keybindingOverrides,
|
|
569
|
+
layoutService: services.layoutService,
|
|
570
|
+
missingExtensionIds: services.missingExtensionIds,
|
|
571
|
+
preferenceService: services.preferenceService,
|
|
572
|
+
resetCommandKeybindingOverride,
|
|
573
|
+
setCommandKeybindingOverride,
|
|
574
|
+
waitForExtensionStartup: services.waitForExtensionStartup,
|
|
575
|
+
workspaceHostPort: services.workspaceHostPort,
|
|
576
|
+
}),
|
|
577
|
+
[
|
|
578
|
+
contextKeyService,
|
|
579
|
+
installedExtensionsStorage,
|
|
580
|
+
installedExtensionsStorageKey,
|
|
581
|
+
keybindingOverrides,
|
|
582
|
+
resetCommandKeybindingOverride,
|
|
583
|
+
services,
|
|
584
|
+
setCommandKeybindingOverride,
|
|
585
|
+
],
|
|
586
|
+
);
|
|
587
|
+
|
|
588
|
+
return (
|
|
589
|
+
<WorkbenchContext.Provider value={value}>
|
|
590
|
+
<EditorWorkspaceReconciler />
|
|
591
|
+
{children}
|
|
592
|
+
</WorkbenchContext.Provider>
|
|
593
|
+
);
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
export function useWorkbench(): WorkbenchContextValue {
|
|
597
|
+
const value = useContext(WorkbenchContext);
|
|
598
|
+
if (!value) {
|
|
599
|
+
throw new Error('useWorkbench must be used inside WorkbenchProvider.');
|
|
600
|
+
}
|
|
601
|
+
|
|
602
|
+
return value;
|
|
603
|
+
}
|