@codingame/monaco-vscode-quickaccess-service-override 5.3.0 → 6.0.0

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-quickaccess-service-override",
3
- "version": "5.3.0",
3
+ "version": "6.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -26,6 +26,6 @@
26
26
  }
27
27
  },
28
28
  "dependencies": {
29
- "vscode": "npm:@codingame/monaco-vscode-api@5.3.0"
29
+ "vscode": "npm:@codingame/monaco-vscode-api@6.0.0"
30
30
  }
31
31
  }
package/quickaccess.js CHANGED
@@ -46,6 +46,7 @@ let DelegateQuickInputService = class DelegateQuickInputService {
46
46
  this.standaloneQuickInputService ?? (this.standaloneQuickInputService = this.instantiationService.createInstance(StandaloneQuickInputService));
47
47
  return this.standaloneQuickInputService;
48
48
  }
49
+ get currentQuickInput() { return this.activeService.currentQuickInput; }
49
50
  get quickAccess() { return this.activeService.quickAccess; }
50
51
  get backButton() { return this.activeService.backButton; }
51
52
  get onShow() { return this.activeService.onShow; }
@@ -14,7 +14,7 @@ import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/c
14
14
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
15
15
  import { ILogService } from 'vscode/vscode/vs/platform/log/common/log.service';
16
16
  import { PickerQuickAccessProvider } from 'vscode/vscode/vs/platform/quickinput/browser/pickerQuickAccess';
17
- import { WillSaveStateReason } from 'vscode/vscode/vs/platform/storage/common/storage';
17
+ import { WillSaveStateReason, StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
18
18
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
19
19
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
20
20
 
@@ -257,7 +257,7 @@ let CommandsHistory = class CommandsHistory extends Disposable {
257
257
  }
258
258
  }
259
259
  load() {
260
- const raw = this.storageService.get(CommandsHistory_1.PREF_KEY_CACHE, 0 );
260
+ const raw = this.storageService.get(CommandsHistory_1.PREF_KEY_CACHE, StorageScope.PROFILE);
261
261
  let serializedCache;
262
262
  if (raw) {
263
263
  try {
@@ -278,7 +278,7 @@ let CommandsHistory = class CommandsHistory extends Disposable {
278
278
  }
279
279
  entries.forEach(entry => cache.set(entry.key, entry.value));
280
280
  }
281
- CommandsHistory_1.counter = this.storageService.getNumber(CommandsHistory_1.PREF_KEY_COUNTER, 0 , CommandsHistory_1.counter);
281
+ CommandsHistory_1.counter = this.storageService.getNumber(CommandsHistory_1.PREF_KEY_COUNTER, StorageScope.PROFILE, CommandsHistory_1.counter);
282
282
  }
283
283
  push(commandId) {
284
284
  if (!CommandsHistory_1.cache) {
@@ -299,8 +299,8 @@ let CommandsHistory = class CommandsHistory extends Disposable {
299
299
  }
300
300
  const serializedCache = { usesLRU: true, entries: [] };
301
301
  CommandsHistory_1.cache.forEach((value, key) => serializedCache.entries.push({ key, value }));
302
- this.storageService.store(CommandsHistory_1.PREF_KEY_CACHE, JSON.stringify(serializedCache), 0 , 0 );
303
- this.storageService.store(CommandsHistory_1.PREF_KEY_COUNTER, CommandsHistory_1.counter, 0 , 0 );
302
+ this.storageService.store(CommandsHistory_1.PREF_KEY_CACHE, JSON.stringify(serializedCache), StorageScope.PROFILE, StorageTarget.USER);
303
+ this.storageService.store(CommandsHistory_1.PREF_KEY_COUNTER, CommandsHistory_1.counter, StorageScope.PROFILE, StorageTarget.USER);
304
304
  CommandsHistory_1.hasChanges = false;
305
305
  }
306
306
  static getConfiguredCommandHistoryLength(configurationService) {
@@ -1,6 +1,7 @@
1
1
  import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
2
2
  import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
3
- import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
3
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
4
+ import { KeybindingsRegistry, KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
4
5
  import { ItemActivation } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
5
6
  import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
6
7
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
@@ -10,15 +11,15 @@ import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
10
11
 
11
12
  const _moduleId = "vs/workbench/browser/actions/quickAccessActions";
12
13
  const globalQuickAccessKeybinding = {
13
- primary: 2048 | 46 ,
14
- secondary: [2048 | 35 ],
15
- mac: { primary: 2048 | 46 , secondary: undefined }
14
+ primary: KeyMod.CtrlCmd | KeyCode.KeyP,
15
+ secondary: [KeyMod.CtrlCmd | KeyCode.KeyE],
16
+ mac: { primary: KeyMod.CtrlCmd | KeyCode.KeyP, secondary: undefined }
16
17
  };
17
18
  KeybindingsRegistry.registerCommandAndKeybindingRule({
18
19
  id: 'workbench.action.closeQuickOpen',
19
- weight: 200 ,
20
+ weight: KeybindingWeight.WorkbenchContrib,
20
21
  when: inQuickPickContext,
21
- primary: 9 , secondary: [1024 | 9 ],
22
+ primary: KeyCode.Escape, secondary: [KeyMod.Shift | KeyCode.Escape],
22
23
  handler: accessor => {
23
24
  const quickInputService = accessor.get(IQuickInputService);
24
25
  return quickInputService.cancel();
@@ -26,7 +27,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
26
27
  });
27
28
  KeybindingsRegistry.registerCommandAndKeybindingRule({
28
29
  id: 'workbench.action.acceptSelectedQuickOpenItem',
29
- weight: 200 ,
30
+ weight: KeybindingWeight.WorkbenchContrib,
30
31
  when: inQuickPickContext,
31
32
  primary: 0,
32
33
  handler: accessor => {
@@ -36,7 +37,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
36
37
  });
37
38
  KeybindingsRegistry.registerCommandAndKeybindingRule({
38
39
  id: 'workbench.action.alternativeAcceptSelectedQuickOpenItem',
39
- weight: 200 ,
40
+ weight: KeybindingWeight.WorkbenchContrib,
40
41
  when: inQuickPickContext,
41
42
  primary: 0,
42
43
  handler: accessor => {
@@ -46,7 +47,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
46
47
  });
47
48
  KeybindingsRegistry.registerCommandAndKeybindingRule({
48
49
  id: 'workbench.action.focusQuickOpen',
49
- weight: 200 ,
50
+ weight: KeybindingWeight.WorkbenchContrib,
50
51
  when: inQuickPickContext,
51
52
  primary: 0,
52
53
  handler: accessor => {
@@ -57,7 +58,7 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
57
58
  const quickAccessNavigateNextInFilePickerId = 'workbench.action.quickOpenNavigateNextInFilePicker';
58
59
  KeybindingsRegistry.registerCommandAndKeybindingRule({
59
60
  id: quickAccessNavigateNextInFilePickerId,
60
- weight: 200 + 50,
61
+ weight: KeybindingWeight.WorkbenchContrib + 50,
61
62
  handler: getQuickNavigateHandler(quickAccessNavigateNextInFilePickerId, true),
62
63
  when: defaultQuickAccessContext,
63
64
  primary: globalQuickAccessKeybinding.primary,
@@ -67,19 +68,19 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
67
68
  const quickAccessNavigatePreviousInFilePickerId = 'workbench.action.quickOpenNavigatePreviousInFilePicker';
68
69
  KeybindingsRegistry.registerCommandAndKeybindingRule({
69
70
  id: quickAccessNavigatePreviousInFilePickerId,
70
- weight: 200 + 50,
71
+ weight: KeybindingWeight.WorkbenchContrib + 50,
71
72
  handler: getQuickNavigateHandler(quickAccessNavigatePreviousInFilePickerId, false),
72
73
  when: defaultQuickAccessContext,
73
- primary: globalQuickAccessKeybinding.primary | 1024 ,
74
- secondary: [globalQuickAccessKeybinding.secondary[0] | 1024 ],
74
+ primary: globalQuickAccessKeybinding.primary | KeyMod.Shift,
75
+ secondary: [globalQuickAccessKeybinding.secondary[0] | KeyMod.Shift],
75
76
  mac: {
76
- primary: globalQuickAccessKeybinding.mac.primary | 1024 ,
77
+ primary: globalQuickAccessKeybinding.mac.primary | KeyMod.Shift,
77
78
  secondary: undefined
78
79
  }
79
80
  });
80
81
  KeybindingsRegistry.registerCommandAndKeybindingRule({
81
82
  id: 'workbench.action.quickPickManyToggle',
82
- weight: 200 ,
83
+ weight: KeybindingWeight.WorkbenchContrib,
83
84
  when: inQuickPickContext,
84
85
  primary: 0,
85
86
  handler: accessor => {
@@ -89,12 +90,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
89
90
  });
90
91
  KeybindingsRegistry.registerCommandAndKeybindingRule({
91
92
  id: 'workbench.action.quickInputBack',
92
- weight: 200 + 50,
93
+ weight: KeybindingWeight.WorkbenchContrib + 50,
93
94
  when: inQuickPickContext,
94
95
  primary: 0,
95
- win: { primary: 512 | 15 },
96
- mac: { primary: 256 | 88 },
97
- linux: { primary: 2048 | 512 | 88 },
96
+ win: { primary: KeyMod.Alt | KeyCode.LeftArrow },
97
+ mac: { primary: KeyMod.WinCtrl | KeyCode.Minus },
98
+ linux: { primary: KeyMod.CtrlCmd | KeyMod.Alt | KeyCode.Minus },
98
99
  handler: accessor => {
99
100
  const quickInputService = accessor.get(IQuickInputService);
100
101
  quickInputService.back();
@@ -115,7 +116,7 @@ registerAction2(class QuickAccessAction extends Action2 {
115
116
  }]
116
117
  },
117
118
  keybinding: {
118
- weight: 200 ,
119
+ weight: KeybindingWeight.WorkbenchContrib,
119
120
  primary: globalQuickAccessKeybinding.primary,
120
121
  secondary: globalQuickAccessKeybinding.secondary,
121
122
  mac: globalQuickAccessKeybinding.mac
@@ -183,20 +184,20 @@ class QuickAccessNavigatePreviousAction extends BaseQuickAccessNavigateAction {
183
184
  class QuickAccessSelectNextAction extends BaseQuickAccessNavigateAction {
184
185
  constructor() {
185
186
  super('workbench.action.quickOpenSelectNext', ( localize2WithPath(_moduleId, 4, 'Select Next in Quick Open')), true, false, {
186
- weight: 200 + 50,
187
+ weight: KeybindingWeight.WorkbenchContrib + 50,
187
188
  when: inQuickPickContext,
188
189
  primary: 0,
189
- mac: { primary: 256 | 44 }
190
+ mac: { primary: KeyMod.WinCtrl | KeyCode.KeyN }
190
191
  });
191
192
  }
192
193
  }
193
194
  class QuickAccessSelectPreviousAction extends BaseQuickAccessNavigateAction {
194
195
  constructor() {
195
196
  super('workbench.action.quickOpenSelectPrevious', ( localize2WithPath(_moduleId, 5, 'Select Previous in Quick Open')), false, false, {
196
- weight: 200 + 50,
197
+ weight: KeybindingWeight.WorkbenchContrib + 50,
197
198
  when: inQuickPickContext,
198
199
  primary: 0,
199
- mac: { primary: 256 | 46 }
200
+ mac: { primary: KeyMod.WinCtrl | KeyCode.KeyP }
200
201
  });
201
202
  }
202
203
  }
@@ -7,6 +7,8 @@ import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
7
7
  import { Extensions } from 'vscode/vscode/vs/platform/quickinput/common/quickAccess';
8
8
  import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/common/configuration.service';
9
9
  import { Action2, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
10
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
11
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
10
12
  import { IEditorGroupsService } from 'vscode/vscode/vs/workbench/services/editor/common/editorGroupsService.service';
11
13
 
12
14
  const _moduleId = "vs/workbench/contrib/codeEditor/browser/quickaccess/gotoLineQuickAccess";
@@ -55,10 +57,10 @@ class GotoLineAction extends Action2 {
55
57
  title: ( localize2WithPath(_moduleId, 0, 'Go to Line/Column...')),
56
58
  f1: true,
57
59
  keybinding: {
58
- weight: 200 ,
60
+ weight: KeybindingWeight.WorkbenchContrib,
59
61
  when: null,
60
- primary: 2048 | 37 ,
61
- mac: { primary: 256 | 37 }
62
+ primary: KeyMod.CtrlCmd | KeyCode.KeyG,
63
+ mac: { primary: KeyMod.WinCtrl | KeyCode.KeyG }
62
64
  }
63
65
  });
64
66
  }
@@ -3,6 +3,7 @@ import { isFirefox } from 'vscode/vscode/vs/base/browser/browser';
3
3
  import { raceTimeout, timeout } from 'vscode/vscode/vs/base/common/async';
4
4
  import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
5
5
  import { stripIcons } from 'vscode/vscode/vs/base/common/iconLabels';
6
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
6
7
  import { Language } from 'vscode/vscode/vs/base/common/platform';
7
8
  import { ThemeIcon } from 'vscode/vscode/vs/base/common/themables';
8
9
  import { AbstractEditorCommandsQuickAccessProvider } from '../../../../editor/contrib/quickAccess/browser/commandsQuickAccess.js';
@@ -15,6 +16,7 @@ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/c
15
16
  import { IDialogService } from 'vscode/vscode/vs/platform/dialogs/common/dialogs.service';
16
17
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
17
18
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
19
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
18
20
  import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
19
21
  import { CommandsHistory } from '../../../../platform/quickinput/browser/commandsQuickAccess.js';
20
22
  import { TriggerAction } from 'vscode/vscode/vs/platform/quickinput/browser/pickerQuickAccess';
@@ -139,7 +141,7 @@ let CommandsQuickAccessProvider = class CommandsQuickAccessProvider extends Abst
139
141
  const defaultAgent = this.chatAgentService.getDefaultAgent(ChatAgentLocation.Panel);
140
142
  if (defaultAgent) {
141
143
  additionalPicks.push({
142
- label: ( localizeWithPath(_moduleId, 2, "Ask {0}: {1}", defaultAgent.metadata.fullName, filter)),
144
+ label: ( localizeWithPath(_moduleId, 2, "Ask {0}: {1}", defaultAgent.fullName, filter)),
143
145
  commandId: this.configuration.experimental.askChatLocation === 'quickChat' ? ASK_QUICK_QUESTION_ACTION_ID : CHAT_OPEN_ACTION_ID,
144
146
  args: [filter]
145
147
  });
@@ -219,10 +221,10 @@ class ShowAllCommandsAction extends Action2 {
219
221
  id: ShowAllCommandsAction.ID,
220
222
  title: ( localize2WithPath(_moduleId, 4, 'Show All Commands')),
221
223
  keybinding: {
222
- weight: 200 ,
224
+ weight: KeybindingWeight.WorkbenchContrib,
223
225
  when: undefined,
224
- primary: !isFirefox ? ((2048 | 1024 | 46) ) : undefined,
225
- secondary: [59 ]
226
+ primary: !isFirefox ? (KeyMod.CtrlCmd | KeyMod.Shift | KeyCode.KeyP) : undefined,
227
+ secondary: [KeyCode.F1]
226
228
  },
227
229
  f1: true
228
230
  });
@@ -5,9 +5,10 @@ import { HelpQuickAccessProvider } from '../../../../platform/quickinput/browser
5
5
  import { ViewQuickAccessProvider, OpenViewPickerAction, QuickAccessViewPickerAction } from './viewQuickAccess.js';
6
6
  import { CommandsQuickAccessProvider, ShowAllCommandsAction, ClearCommandHistoryAction } from './commandsQuickAccess.js';
7
7
  import { MenuRegistry, MenuId, registerAction2 } from 'vscode/vscode/vs/platform/actions/common/actions';
8
+ import { KeyMod } from 'vscode/vscode/vs/base/common/keyCodes';
8
9
  import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
9
10
  import { inQuickPickContext, getQuickNavigateHandler } from 'vscode/vscode/vs/workbench/browser/quickaccess';
10
- import { KeybindingsRegistry } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
11
+ import { KeybindingsRegistry, KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
11
12
  import { EditorContextKeys } from 'vscode/vscode/vs/editor/common/editorContextKeys';
12
13
 
13
14
  const _moduleId = "vs/workbench/contrib/quickaccess/browser/quickAccess.contribution";
@@ -107,7 +108,7 @@ const viewPickerKeybinding = QuickAccessViewPickerAction.KEYBINDING;
107
108
  const quickAccessNavigateNextInViewPickerId = 'workbench.action.quickOpenNavigateNextInViewPicker';
108
109
  KeybindingsRegistry.registerCommandAndKeybindingRule({
109
110
  id: quickAccessNavigateNextInViewPickerId,
110
- weight: 200 + 50,
111
+ weight: KeybindingWeight.WorkbenchContrib + 50,
111
112
  handler: getQuickNavigateHandler(quickAccessNavigateNextInViewPickerId, true),
112
113
  when: inViewsPickerContext,
113
114
  primary: viewPickerKeybinding.primary,
@@ -117,12 +118,12 @@ KeybindingsRegistry.registerCommandAndKeybindingRule({
117
118
  const quickAccessNavigatePreviousInViewPickerId = 'workbench.action.quickOpenNavigatePreviousInViewPicker';
118
119
  KeybindingsRegistry.registerCommandAndKeybindingRule({
119
120
  id: quickAccessNavigatePreviousInViewPickerId,
120
- weight: 200 + 50,
121
+ weight: KeybindingWeight.WorkbenchContrib + 50,
121
122
  handler: getQuickNavigateHandler(quickAccessNavigatePreviousInViewPickerId, false),
122
123
  when: inViewsPickerContext,
123
- primary: viewPickerKeybinding.primary | 1024 ,
124
+ primary: viewPickerKeybinding.primary | KeyMod.Shift,
124
125
  linux: viewPickerKeybinding.linux,
125
126
  mac: {
126
- primary: viewPickerKeybinding.mac.primary | 1024
127
+ primary: viewPickerKeybinding.mac.primary | KeyMod.Shift
127
128
  }
128
129
  });
@@ -3,6 +3,7 @@ import { localizeWithPath, localize2WithPath } from 'vscode/vscode/vs/nls';
3
3
  import { ItemActivation } from 'vscode/vscode/vs/platform/quickinput/common/quickInput';
4
4
  import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
5
5
  import { PickerQuickAccessProvider } from 'vscode/vscode/vs/platform/quickinput/browser/pickerQuickAccess';
6
+ import { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
6
7
  import { IViewDescriptorService } from 'vscode/vscode/vs/workbench/common/views.service';
7
8
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService.service';
8
9
  import { IOutputService } from 'vscode/vscode/vs/workbench/services/output/common/output.service';
@@ -12,6 +13,8 @@ import { matchesFuzzy } from 'vscode/vscode/vs/base/common/filters';
12
13
  import { fuzzyContains } from 'vscode/vscode/vs/base/common/strings';
13
14
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
14
15
  import { Action2 } from 'vscode/vscode/vs/platform/actions/common/actions';
16
+ import { KeyMod, KeyCode } from 'vscode/vscode/vs/base/common/keyCodes';
17
+ import { KeybindingWeight } from 'vscode/vscode/vs/platform/keybinding/common/keybindingsRegistry';
15
18
  import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
16
19
  import { IPaneCompositePartService } from 'vscode/vscode/vs/workbench/services/panecomposite/browser/panecomposite.service';
17
20
  import { REPL_VIEW_ID } from 'vscode/vscode/vs/workbench/contrib/debug/common/debug';
@@ -113,9 +116,9 @@ let ViewQuickAccessProvider = class ViewQuickAccessProvider extends PickerQuickA
113
116
  }
114
117
  }
115
118
  };
116
- addPaneComposites(0 , ( localizeWithPath(_moduleId, 1, "Side Bar")));
117
- addPaneComposites(1 , ( localizeWithPath(_moduleId, 2, "Panel")));
118
- addPaneComposites(2 , ( localizeWithPath(_moduleId, 3, "Secondary Side Bar")));
119
+ addPaneComposites(ViewContainerLocation.Sidebar, ( localizeWithPath(_moduleId, 1, "Side Bar")));
120
+ addPaneComposites(ViewContainerLocation.Panel, ( localizeWithPath(_moduleId, 2, "Panel")));
121
+ addPaneComposites(ViewContainerLocation.AuxiliaryBar, ( localizeWithPath(_moduleId, 3, "Secondary Side Bar")));
119
122
  const addPaneCompositeViews = (location) => {
120
123
  const paneComposites = this.paneCompositeService.getPaneComposites(location);
121
124
  for (const paneComposite of paneComposites) {
@@ -125,9 +128,9 @@ let ViewQuickAccessProvider = class ViewQuickAccessProvider extends PickerQuickA
125
128
  }
126
129
  }
127
130
  };
128
- addPaneCompositeViews(0 );
129
- addPaneCompositeViews(1 );
130
- addPaneCompositeViews(2 );
131
+ addPaneCompositeViews(ViewContainerLocation.Sidebar);
132
+ addPaneCompositeViews(ViewContainerLocation.Panel);
133
+ addPaneCompositeViews(ViewContainerLocation.AuxiliaryBar);
131
134
  this.terminalGroupService.groups.forEach((group, groupIndex) => {
132
135
  group.terminalInstances.forEach((terminal, terminalIndex) => {
133
136
  const label = ( localizeWithPath(
@@ -205,8 +208,8 @@ class OpenViewPickerAction extends Action2 {
205
208
  class QuickAccessViewPickerAction extends Action2 {
206
209
  static { this.ID = 'workbench.action.quickOpenView'; }
207
210
  static { this.KEYBINDING = {
208
- primary: 2048 | 47 ,
209
- mac: { primary: 256 | 47 },
211
+ primary: KeyMod.CtrlCmd | KeyCode.KeyQ,
212
+ mac: { primary: KeyMod.WinCtrl | KeyCode.KeyQ },
210
213
  linux: { primary: 0 }
211
214
  }; }
212
215
  constructor() {
@@ -216,7 +219,7 @@ class QuickAccessViewPickerAction extends Action2 {
216
219
  category: Categories.View,
217
220
  f1: false,
218
221
  keybinding: {
219
- weight: 200 ,
222
+ weight: KeybindingWeight.WorkbenchContrib,
220
223
  when: undefined,
221
224
  ...QuickAccessViewPickerAction.KEYBINDING
222
225
  }
@@ -1,11 +1,12 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
2
  import { Event } from 'vscode/vscode/vs/base/common/event';
3
3
  import { parse } from 'vscode/vscode/vs/base/common/json';
4
- import { FileType } from 'vscode/vscode/vs/platform/files/common/files';
4
+ import { FileType, FileSystemProviderCapabilities } from 'vscode/vscode/vs/platform/files/common/files';
5
5
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
6
+ import { StorageScope, StorageTarget } from 'vscode/vscode/vs/platform/storage/common/storage';
6
7
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
7
8
  import { VSBuffer } from 'vscode/vscode/vs/base/common/buffer';
8
- import { TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, readTrustedDomains, TRUSTED_DOMAINS_STORAGE_KEY } from './trustedDomains.js';
9
+ import { TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, readTrustedDomains, TRUSTED_DOMAINS_STORAGE_KEY } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomains';
9
10
  import { assertIsDefined } from 'vscode/vscode/vs/base/common/types';
10
11
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
11
12
 
@@ -38,7 +39,7 @@ const CONFIG_HELP_TEXT_AFTER = `//
38
39
  const CONFIG_PLACEHOLDER_TEXT = `[
39
40
  // "https://microsoft.com"
40
41
  ]`;
41
- function computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, userTrustedDomains, workspaceTrustedDomains, configuring) {
42
+ function computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, configuring) {
42
43
  let content = CONFIG_HELP_TEXT_PRE;
43
44
  if (defaultTrustedDomains.length > 0) {
44
45
  content += `// By default, VS Code trusts "localhost" as well as the following domains:\n`;
@@ -49,18 +50,6 @@ function computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, user
49
50
  else {
50
51
  content += `// By default, VS Code trusts "localhost".\n`;
51
52
  }
52
- if (userTrustedDomains.length) {
53
- content += `//\n// Additionally, the following domains are trusted based on your logged-in Accounts:\n`;
54
- userTrustedDomains.forEach(d => {
55
- content += `// - "${d}"\n`;
56
- });
57
- }
58
- if (workspaceTrustedDomains.length) {
59
- content += `//\n// Further, the following domains are trusted based on your workspace configuration:\n`;
60
- workspaceTrustedDomains.forEach(d => {
61
- content += `// - "${d}"\n`;
62
- });
63
- }
64
53
  content += CONFIG_HELP_TEXT_AFTER;
65
54
  content += configuring ? `\n// Currently configuring trust for ${configuring}\n` : '';
66
55
  if (trustedDomains.length === 0) {
@@ -77,7 +66,7 @@ let TrustedDomainsFileSystemProvider = class TrustedDomainsFileSystemProvider {
77
66
  this.fileService = fileService;
78
67
  this.storageService = storageService;
79
68
  this.instantiationService = instantiationService;
80
- this.capabilities = 2 ;
69
+ this.capabilities = FileSystemProviderCapabilities.FileReadWrite;
81
70
  this.onDidChangeCapabilities = Event.None;
82
71
  this.onDidChangeFile = Event.None;
83
72
  this.fileService.registerProvider(TRUSTED_DOMAINS_SCHEMA, this);
@@ -86,15 +75,15 @@ let TrustedDomainsFileSystemProvider = class TrustedDomainsFileSystemProvider {
86
75
  return Promise.resolve(TRUSTED_DOMAINS_STAT);
87
76
  }
88
77
  async readFile(resource) {
89
- let trustedDomainsContent = this.storageService.get(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, -1 );
78
+ let trustedDomainsContent = this.storageService.get(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, StorageScope.APPLICATION);
90
79
  const configuring = resource.fragment;
91
- const { defaultTrustedDomains, trustedDomains, userDomains, workspaceDomains } = await this.instantiationService.invokeFunction(readTrustedDomains);
80
+ const { defaultTrustedDomains, trustedDomains } = await this.instantiationService.invokeFunction(readTrustedDomains);
92
81
  if (!trustedDomainsContent ||
93
82
  trustedDomainsContent.indexOf(CONFIG_HELP_TEXT_PRE) === -1 ||
94
83
  trustedDomainsContent.indexOf(CONFIG_HELP_TEXT_AFTER) === -1 ||
95
84
  trustedDomainsContent.indexOf(configuring ?? '') === -1 ||
96
- ( [...defaultTrustedDomains, ...trustedDomains, ...userDomains, ...workspaceDomains].some(d => !assertIsDefined(trustedDomainsContent).includes(d)))) {
97
- trustedDomainsContent = computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, userDomains, workspaceDomains, configuring);
85
+ ( [...defaultTrustedDomains, ...trustedDomains].some(d => !assertIsDefined(trustedDomainsContent).includes(d)))) {
86
+ trustedDomainsContent = computeTrustedDomainContent(defaultTrustedDomains, trustedDomains, configuring);
98
87
  }
99
88
  const buffer = VSBuffer.fromString(trustedDomainsContent).buffer;
100
89
  return buffer;
@@ -103,8 +92,8 @@ let TrustedDomainsFileSystemProvider = class TrustedDomainsFileSystemProvider {
103
92
  try {
104
93
  const trustedDomainsContent = ( VSBuffer.wrap(content).toString());
105
94
  const trustedDomains = parse(trustedDomainsContent);
106
- this.storageService.store(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, trustedDomainsContent, -1 , 0 );
107
- this.storageService.store(TRUSTED_DOMAINS_STORAGE_KEY, JSON.stringify(trustedDomains) || '', -1 , 0 );
95
+ this.storageService.store(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, trustedDomainsContent, StorageScope.APPLICATION, StorageTarget.USER);
96
+ this.storageService.store(TRUSTED_DOMAINS_STORAGE_KEY, JSON.stringify(trustedDomains) || '', StorageScope.APPLICATION, StorageTarget.USER);
108
97
  }
109
98
  catch (err) { }
110
99
  return Promise.resolve();
@@ -1,6 +1,4 @@
1
1
  import { __decorate, __param } from 'vscode/external/tslib/tslib.es6.js';
2
- import { WindowIdleValue } from 'vscode/vscode/vs/base/browser/dom';
3
- import { mainWindow } from 'vscode/vscode/vs/base/browser/window';
4
2
  import { matchesScheme, Schemas } from 'vscode/vscode/vs/base/common/network';
5
3
  import Severity$1 from 'vscode/vscode/vs/base/common/severity';
6
4
  import { URI } from 'vscode/vscode/vs/base/common/uri';
@@ -14,16 +12,15 @@ import { IProductService } from 'vscode/vscode/vs/platform/product/common/produc
14
12
  import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
15
13
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
16
14
  import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
17
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
18
15
  import { IWorkspaceTrustManagementService } from 'vscode/vscode/vs/platform/workspace/common/workspaceTrust.service';
19
- import { readAuthenticationTrustedDomains, readWorkspaceTrustedDomains, readStaticTrustedDomains, configureOpenerTrustedDomainsHandler } from './trustedDomains.js';
20
- import { testUrlMatchesGlob } from 'vscode/vscode/vs/workbench/contrib/url/common/urlGlob';
21
- import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
16
+ import { isURLDomainTrusted } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomainService';
17
+ import { ITrustedDomainService } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomainService.service';
18
+ import { readStaticTrustedDomains, configureOpenerTrustedDomainsHandler } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomains';
22
19
  import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
23
20
 
24
21
  const _moduleId = "vs/workbench/contrib/url/browser/trustedDomainsValidator";
25
22
  let OpenerValidatorContributions = class OpenerValidatorContributions {
26
- constructor(_openerService, _storageService, _dialogService, _productService, _quickInputService, _editorService, _clipboardService, _telemetryService, _instantiationService, _authenticationService, _workspaceContextService, _configurationService, _workspaceTrustService) {
23
+ constructor(_openerService, _storageService, _dialogService, _productService, _quickInputService, _editorService, _clipboardService, _telemetryService, _instantiationService, _configurationService, _workspaceTrustService, _trustedDomainService) {
27
24
  this._openerService = _openerService;
28
25
  this._storageService = _storageService;
29
26
  this._dialogService = _dialogService;
@@ -33,33 +30,10 @@ let OpenerValidatorContributions = class OpenerValidatorContributions {
33
30
  this._clipboardService = _clipboardService;
34
31
  this._telemetryService = _telemetryService;
35
32
  this._instantiationService = _instantiationService;
36
- this._authenticationService = _authenticationService;
37
- this._workspaceContextService = _workspaceContextService;
38
33
  this._configurationService = _configurationService;
39
34
  this._workspaceTrustService = _workspaceTrustService;
35
+ this._trustedDomainService = _trustedDomainService;
40
36
  this._openerService.registerValidator({ shouldOpen: (uri, options) => this.validateLink(uri, options) });
41
- this._readAuthenticationTrustedDomainsResult = ( (new WindowIdleValue(
42
- mainWindow,
43
- () => this._instantiationService.invokeFunction(readAuthenticationTrustedDomains)
44
- )));
45
- this._authenticationService.onDidRegisterAuthenticationProvider(() => {
46
- this._readAuthenticationTrustedDomainsResult?.dispose();
47
- this._readAuthenticationTrustedDomainsResult = ( (new WindowIdleValue(
48
- mainWindow,
49
- () => this._instantiationService.invokeFunction(readAuthenticationTrustedDomains)
50
- )));
51
- });
52
- this._readWorkspaceTrustedDomainsResult = ( (new WindowIdleValue(
53
- mainWindow,
54
- () => this._instantiationService.invokeFunction(readWorkspaceTrustedDomains)
55
- )));
56
- this._workspaceContextService.onDidChangeWorkspaceFolders(() => {
57
- this._readWorkspaceTrustedDomainsResult?.dispose();
58
- this._readWorkspaceTrustedDomainsResult = ( (new WindowIdleValue(
59
- mainWindow,
60
- () => this._instantiationService.invokeFunction(readWorkspaceTrustedDomains)
61
- )));
62
- });
63
37
  }
64
38
  async validateLink(resource, openOptions) {
65
39
  if (!matchesScheme(resource, Schemas.http) && !matchesScheme(resource, Schemas.https)) {
@@ -76,15 +50,11 @@ let OpenerValidatorContributions = class OpenerValidatorContributions {
76
50
  else {
77
51
  resourceUri = resource;
78
52
  }
79
- const { scheme, authority, path, query, fragment } = resourceUri;
80
- const domainToOpen = `${scheme}://${authority}`;
81
- const [workspaceDomains, userDomains] = await Promise.all([this._readWorkspaceTrustedDomainsResult.value, this._readAuthenticationTrustedDomainsResult.value]);
82
- const { defaultTrustedDomains, trustedDomains, } = this._instantiationService.invokeFunction(readStaticTrustedDomains);
83
- const allTrustedDomains = [...defaultTrustedDomains, ...trustedDomains, ...userDomains, ...workspaceDomains];
84
- if (isURLDomainTrusted(resourceUri, allTrustedDomains)) {
53
+ if (await this._trustedDomainService.isValid(resourceUri)) {
85
54
  return true;
86
55
  }
87
56
  else {
57
+ const { scheme, authority, path, query, fragment } = resourceUri;
88
58
  let formattedLink = `${scheme}://${authority}${path}`;
89
59
  const linkTail = `${query ? '?' + query : ''}${fragment ? '#' + fragment : ''}`;
90
60
  const remainingLength = Math.max(0, 60 - formattedLink.length);
@@ -119,6 +89,8 @@ let OpenerValidatorContributions = class OpenerValidatorContributions {
119
89
  {
120
90
  label: ( localizeWithPath(_moduleId, 3, 'Configure &&Trusted Domains')),
121
91
  run: async () => {
92
+ const { trustedDomains, } = this._instantiationService.invokeFunction(readStaticTrustedDomains);
93
+ const domainToOpen = `${scheme}://${authority}`;
122
94
  const pickedDomains = await configureOpenerTrustedDomainsHandler(trustedDomains, domainToOpen, resourceUri, this._quickInputService, this._storageService, this._editorService);
123
95
  if (pickedDomains.indexOf('*') !== -1) {
124
96
  return true;
@@ -148,52 +120,9 @@ OpenerValidatorContributions = ( (__decorate([
148
120
  ( (__param(6, IClipboardService))),
149
121
  ( (__param(7, ITelemetryService))),
150
122
  ( (__param(8, IInstantiationService))),
151
- ( (__param(9, IAuthenticationService))),
152
- ( (__param(10, IWorkspaceContextService))),
153
- ( (__param(11, IConfigurationService))),
154
- ( (__param(12, IWorkspaceTrustManagementService)))
123
+ ( (__param(9, IConfigurationService))),
124
+ ( (__param(10, IWorkspaceTrustManagementService))),
125
+ ( (__param(11, ITrustedDomainService)))
155
126
  ], OpenerValidatorContributions)));
156
- const rLocalhost = /^localhost(:\d+)?$/i;
157
- const r127 = /^127.0.0.1(:\d+)?$/;
158
- function isLocalhostAuthority(authority) {
159
- return rLocalhost.test(authority) || r127.test(authority);
160
- }
161
- function normalizeURL(url) {
162
- const caseInsensitiveAuthorities = ['github.com'];
163
- try {
164
- const parsed = typeof url === 'string' ? ( (URI.parse(url, true))) : url;
165
- if (caseInsensitiveAuthorities.includes(parsed.authority)) {
166
- return (
167
- (parsed.with({ path: parsed.path.toLowerCase() }).toString(true))
168
- );
169
- }
170
- else {
171
- return (
172
- (parsed.toString(true))
173
- );
174
- }
175
- }
176
- catch {
177
- return (
178
- (url.toString())
179
- );
180
- }
181
- }
182
- function isURLDomainTrusted(url, trustedDomains) {
183
- url = ( (URI.parse(normalizeURL(url))));
184
- trustedDomains = ( (trustedDomains.map(normalizeURL)));
185
- if (isLocalhostAuthority(url.authority)) {
186
- return true;
187
- }
188
- for (let i = 0; i < trustedDomains.length; i++) {
189
- if (trustedDomains[i] === '*') {
190
- return true;
191
- }
192
- if (testUrlMatchesGlob(url, trustedDomains[i])) {
193
- return true;
194
- }
195
- }
196
- return false;
197
- }
198
127
 
199
- export { OpenerValidatorContributions, isURLDomainTrusted };
128
+ export { OpenerValidatorContributions };
@@ -2,17 +2,21 @@ import { URI } from 'vscode/vscode/vs/base/common/uri';
2
2
  import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
3
  import { Action2, registerAction2, MenuRegistry, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
4
4
  import { CommandsRegistry } from 'vscode/vscode/vs/platform/commands/common/commands';
5
+ import { LifecyclePhase } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
5
6
  import { IQuickInputService } from 'vscode/vscode/vs/platform/quickinput/common/quickInput.service';
6
7
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
7
8
  import { IURLService } from 'vscode/vscode/vs/platform/url/common/url.service';
8
- import { Extensions, registerWorkbenchContribution2 } from 'vscode/vscode/vs/workbench/common/contributions';
9
+ import { Extensions, registerWorkbenchContribution2, WorkbenchPhase } from 'vscode/vscode/vs/workbench/common/contributions';
9
10
  import { ExternalUriResolverContribution } from './externalUriResolver.js';
10
- import { manageTrustedDomainSettingsCommand } from './trustedDomains.js';
11
+ import { manageTrustedDomainSettingsCommand } from 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomains';
11
12
  import { TrustedDomainsFileSystemProvider } from './trustedDomainsFileSystemProvider.js';
12
13
  import { OpenerValidatorContributions } from './trustedDomainsValidator.js';
13
14
  import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
14
- import { Extensions as Extensions$1 } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
15
+ import { Extensions as Extensions$1, ConfigurationScope } from 'vscode/vscode/vs/platform/configuration/common/configurationRegistry';
15
16
  import { workbenchConfigurationNodeBase } from 'vscode/vscode/vs/workbench/common/configuration';
17
+ import 'vscode/vscode/vs/workbench/contrib/url/browser/trustedDomainService';
18
+ import 'vscode/vscode/vs/platform/instantiation/common/instantiation';
19
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
16
20
 
17
21
  const _moduleId = "vs/workbench/contrib/url/browser/url.contribution";
18
22
  class OpenUrlAction extends Action2 {
@@ -43,15 +47,17 @@ MenuRegistry.appendMenuItem(MenuId.CommandPalette, {
43
47
  title: manageTrustedDomainSettingsCommand.description.description
44
48
  }
45
49
  });
46
- ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(OpenerValidatorContributions, 3 );
47
- registerWorkbenchContribution2(TrustedDomainsFileSystemProvider.ID, TrustedDomainsFileSystemProvider, 2 );
48
- registerWorkbenchContribution2(ExternalUriResolverContribution.ID, ExternalUriResolverContribution, 2 );
50
+ ( (Registry.as(Extensions.Workbench))).registerWorkbenchContribution(OpenerValidatorContributions, LifecyclePhase.Restored);
51
+ registerWorkbenchContribution2(TrustedDomainsFileSystemProvider.ID, TrustedDomainsFileSystemProvider, WorkbenchPhase.BlockRestore
52
+ );
53
+ registerWorkbenchContribution2(ExternalUriResolverContribution.ID, ExternalUriResolverContribution, WorkbenchPhase.BlockRestore
54
+ );
49
55
  const configurationRegistry = ( (Registry.as(Extensions$1.Configuration)));
50
56
  configurationRegistry.registerConfiguration({
51
57
  ...workbenchConfigurationNodeBase,
52
58
  properties: {
53
59
  'workbench.trustedDomains.promptInTrustedWorkspace': {
54
- scope: 1 ,
60
+ scope: ConfigurationScope.APPLICATION,
55
61
  type: 'boolean',
56
62
  default: false,
57
63
  description: ( localizeWithPath(
@@ -6,6 +6,7 @@ import { IConfigurationService } from 'vscode/vscode/vs/platform/configuration/c
6
6
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey.service';
7
7
  import { IKeybindingService } from 'vscode/vscode/vs/platform/keybinding/common/keybinding.service';
8
8
  import { QuickInputService as QuickInputService$1 } from 'vscode/vscode/vs/platform/quickinput/browser/quickInputService';
9
+ import 'vscode/vscode/vs/platform/instantiation/common/extensions';
9
10
  import { InQuickPickContextKey } from 'vscode/vscode/vs/workbench/browser/quickaccess';
10
11
 
11
12
  let QuickInputService = class QuickInputService extends QuickInputService$1 {
@@ -1,174 +0,0 @@
1
- import { URI } from 'vscode/vscode/vs/base/common/uri';
2
- import { localize2WithPath, localizeWithPath } from 'vscode/vscode/vs/nls';
3
- import { IProductService } from 'vscode/vscode/vs/platform/product/common/productService.service';
4
- import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
5
- import { IEditorService } from 'vscode/vscode/vs/workbench/services/editor/common/editorService.service';
6
- import { IAuthenticationService } from 'vscode/vscode/vs/workbench/services/authentication/common/authentication.service';
7
- import { IFileService } from 'vscode/vscode/vs/platform/files/common/files.service';
8
- import { ITextFileService } from 'vscode/vscode/vs/workbench/services/textfile/common/textfiles.service';
9
- import { IWorkspaceContextService } from 'vscode/vscode/vs/platform/workspace/common/workspace.service';
10
- import { IBrowserWorkbenchEnvironmentService } from 'vscode/vscode/vs/workbench/services/environment/browser/environmentService.service';
11
-
12
- const _moduleId = "vs/workbench/contrib/url/browser/trustedDomains";
13
- const TRUSTED_DOMAINS_URI = ( (URI.parse('trustedDomains:/Trusted Domains')));
14
- const TRUSTED_DOMAINS_STORAGE_KEY = 'http.linkProtectionTrustedDomains';
15
- const TRUSTED_DOMAINS_CONTENT_STORAGE_KEY = 'http.linkProtectionTrustedDomainsContent';
16
- const manageTrustedDomainSettingsCommand = {
17
- id: 'workbench.action.manageTrustedDomain',
18
- description: {
19
- description: ( localize2WithPath(_moduleId, 0, 'Manage Trusted Domains')),
20
- args: []
21
- },
22
- handler: async (accessor) => {
23
- const editorService = accessor.get(IEditorService);
24
- editorService.openEditor({ resource: TRUSTED_DOMAINS_URI, languageId: 'jsonc', options: { pinned: true } });
25
- return;
26
- }
27
- };
28
- async function configureOpenerTrustedDomainsHandler(trustedDomains, domainToConfigure, resource, quickInputService, storageService, editorService, telemetryService) {
29
- const parsedDomainToConfigure = ( (URI.parse(domainToConfigure)));
30
- const toplevelDomainSegements = parsedDomainToConfigure.authority.split('.');
31
- const domainEnd = toplevelDomainSegements.slice(toplevelDomainSegements.length - 2).join('.');
32
- const topLevelDomain = '*.' + domainEnd;
33
- const options = [];
34
- options.push({
35
- type: 'item',
36
- label: ( localizeWithPath(_moduleId, 1, 'Trust {0}', domainToConfigure)),
37
- id: 'trust',
38
- toTrust: domainToConfigure,
39
- picked: true
40
- });
41
- const isIP = toplevelDomainSegements.length === 4 &&
42
- toplevelDomainSegements.every(segment => Number.isInteger(+segment) || Number.isInteger(+segment.split(':')[0]));
43
- if (isIP) {
44
- if (parsedDomainToConfigure.authority.includes(':')) {
45
- const base = parsedDomainToConfigure.authority.split(':')[0];
46
- options.push({
47
- type: 'item',
48
- label: ( localizeWithPath(_moduleId, 2, 'Trust {0} on all ports', base)),
49
- toTrust: base + ':*',
50
- id: 'trust'
51
- });
52
- }
53
- }
54
- else {
55
- options.push({
56
- type: 'item',
57
- label: ( localizeWithPath(_moduleId, 3, 'Trust {0} and all its subdomains', domainEnd)),
58
- toTrust: topLevelDomain,
59
- id: 'trust'
60
- });
61
- }
62
- options.push({
63
- type: 'item',
64
- label: ( localizeWithPath(_moduleId, 4, 'Trust all domains (disables link protection)')),
65
- toTrust: '*',
66
- id: 'trust'
67
- });
68
- options.push({
69
- type: 'item',
70
- label: ( localizeWithPath(_moduleId, 5, 'Manage Trusted Domains')),
71
- id: 'manage'
72
- });
73
- const pickedResult = await quickInputService.pick(options, { activeItem: options[0] });
74
- if (pickedResult && pickedResult.id) {
75
- switch (pickedResult.id) {
76
- case 'manage':
77
- await editorService.openEditor({
78
- resource: TRUSTED_DOMAINS_URI.with({ fragment: ( (resource.toString())) }),
79
- languageId: 'jsonc',
80
- options: { pinned: true }
81
- });
82
- return trustedDomains;
83
- case 'trust': {
84
- const itemToTrust = pickedResult.toTrust;
85
- if (trustedDomains.indexOf(itemToTrust) === -1) {
86
- storageService.remove(TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, -1 );
87
- storageService.store(TRUSTED_DOMAINS_STORAGE_KEY, JSON.stringify([...trustedDomains, itemToTrust]), -1 , 0 );
88
- return [...trustedDomains, itemToTrust];
89
- }
90
- }
91
- }
92
- }
93
- return [];
94
- }
95
- function extractGitHubRemotesFromGitConfig(gitConfig) {
96
- const domains = ( (new Set()));
97
- let match;
98
- const RemoteMatcher = /^\s*url\s*=\s*(?:git@|https:\/\/)github\.com(?::|\/)(\S*)\s*$/mg;
99
- while (match = RemoteMatcher.exec(gitConfig)) {
100
- const repo = match[1].replace(/\.git$/, '');
101
- if (repo) {
102
- domains.add(`https://github.com/${repo}/`);
103
- }
104
- }
105
- return [...domains];
106
- }
107
- async function getRemotes(fileService, textFileService, contextService) {
108
- const workspaceUris = ( (contextService.getWorkspace().folders.map(folder => folder.uri)));
109
- const domains = await Promise.race([
110
- ( (new Promise(resolve => setTimeout(() => resolve([]), 2000)))),
111
- Promise.all(( (workspaceUris.map(async (workspaceUri) => {
112
- try {
113
- const path = workspaceUri.path;
114
- const uri = workspaceUri.with({ path: `${path !== '/' ? path : ''}/.git/config` });
115
- const exists = await fileService.exists(uri);
116
- if (!exists) {
117
- return [];
118
- }
119
- const gitConfig = (await (textFileService.read(uri, { acceptTextOnly: true }).catch(() => ({ value: '' })))).value;
120
- return extractGitHubRemotesFromGitConfig(gitConfig);
121
- }
122
- catch {
123
- return [];
124
- }
125
- }))))
126
- ]);
127
- const set = domains.reduce((set, list) => list.reduce((set, item) => set.add(item), set), ( (new Set())));
128
- return [...set];
129
- }
130
- async function readTrustedDomains(accessor) {
131
- const { defaultTrustedDomains, trustedDomains } = readStaticTrustedDomains(accessor);
132
- const [workspaceDomains, userDomains] = await Promise.all([readWorkspaceTrustedDomains(accessor), readAuthenticationTrustedDomains(accessor)]);
133
- return {
134
- workspaceDomains,
135
- userDomains,
136
- defaultTrustedDomains,
137
- trustedDomains,
138
- };
139
- }
140
- async function readWorkspaceTrustedDomains(accessor) {
141
- const fileService = accessor.get(IFileService);
142
- const textFileService = accessor.get(ITextFileService);
143
- const workspaceContextService = accessor.get(IWorkspaceContextService);
144
- return getRemotes(fileService, textFileService, workspaceContextService);
145
- }
146
- async function readAuthenticationTrustedDomains(accessor) {
147
- const authenticationService = accessor.get(IAuthenticationService);
148
- return authenticationService.isAuthenticationProviderRegistered('github') && ((await authenticationService.getSessions('github')) ?? []).length > 0
149
- ? [`https://github.com`]
150
- : [];
151
- }
152
- function readStaticTrustedDomains(accessor) {
153
- const storageService = accessor.get(IStorageService);
154
- const productService = accessor.get(IProductService);
155
- const environmentService = accessor.get(IBrowserWorkbenchEnvironmentService);
156
- const defaultTrustedDomains = [
157
- ...(productService.linkProtectionTrustedDomains ?? []),
158
- ...(environmentService.options?.additionalTrustedDomains ?? [])
159
- ];
160
- let trustedDomains = [];
161
- try {
162
- const trustedDomainsSrc = storageService.get(TRUSTED_DOMAINS_STORAGE_KEY, -1 );
163
- if (trustedDomainsSrc) {
164
- trustedDomains = JSON.parse(trustedDomainsSrc);
165
- }
166
- }
167
- catch (err) { }
168
- return {
169
- defaultTrustedDomains,
170
- trustedDomains,
171
- };
172
- }
173
-
174
- export { TRUSTED_DOMAINS_CONTENT_STORAGE_KEY, TRUSTED_DOMAINS_STORAGE_KEY, configureOpenerTrustedDomainsHandler, extractGitHubRemotesFromGitConfig, manageTrustedDomainSettingsCommand, readAuthenticationTrustedDomains, readStaticTrustedDomains, readTrustedDomains, readWorkspaceTrustedDomains };