@codingame/monaco-vscode-keybindings-service-override 25.1.2 → 26.0.1

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.
@@ -71,8 +71,8 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
71
71
  this._mru = [];
72
72
  this._activeKeymapInfo = null;
73
73
  if (navigator.keyboard && navigator.keyboard.addEventListener) {
74
- navigator.keyboard.addEventListener('layoutchange', () => {
75
- this._getBrowserKeyMapping().then((mapping) => {
74
+ navigator.keyboard.addEventListener("layoutchange", () => {
75
+ this._getBrowserKeyMapping().then(mapping => {
76
76
  if (this.isKeyMappingActive(mapping)) {
77
77
  return;
78
78
  }
@@ -80,8 +80,8 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
80
80
  });
81
81
  });
82
82
  }
83
- this._register(this._configurationService.onDidChangeConfiguration((e) => {
84
- if (e.affectsConfiguration('keyboard')) {
83
+ this._register(this._configurationService.onDidChangeConfiguration(e => {
84
+ if (e.affectsConfiguration("keyboard")) {
85
85
  this._keyboardMapper = null;
86
86
  this._onDidChangeKeyboardMapper.fire();
87
87
  }
@@ -159,8 +159,7 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
159
159
  if (!this._activeKeymapInfo) {
160
160
  this._activeKeymapInfo = matchedKeyboardLayout.result;
161
161
  keymapUpdated = true;
162
- }
163
- else if (keymap) {
162
+ } else if (keymap) {
164
163
  if (matchedKeyboardLayout.result.getScore(keymap) > this._activeKeymapInfo.getScore(keymap)) {
165
164
  this._activeKeymapInfo = matchedKeyboardLayout.result;
166
165
  keymapUpdated = true;
@@ -256,17 +255,17 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
256
255
  if (!currentKeymap) {
257
256
  return true;
258
257
  }
259
- if (standardKeyboardEvent.browserEvent.key === 'Dead' || standardKeyboardEvent.browserEvent.isComposing) {
258
+ if (standardKeyboardEvent.browserEvent.key === "Dead" || standardKeyboardEvent.browserEvent.isComposing) {
260
259
  return true;
261
260
  }
262
261
  const mapping = currentKeymap.mapping[standardKeyboardEvent.code];
263
262
  if (!mapping) {
264
263
  return false;
265
264
  }
266
- if (mapping.value === '') {
265
+ if (mapping.value === "") {
267
266
  if (keyboardEvent.ctrlKey || keyboardEvent.metaKey) {
268
267
  setTimeout(() => {
269
- this._getBrowserKeyMapping().then((keymap) => {
268
+ this._getBrowserKeyMapping().then(keymap => {
270
269
  if (this.isKeyMappingActive(keymap)) {
271
270
  return;
272
271
  }
@@ -276,14 +275,9 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
276
275
  }
277
276
  return true;
278
277
  }
279
- const expectedValue = standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey ? mapping.withShiftAltGr :
280
- standardKeyboardEvent.altKey ? mapping.withAltGr :
281
- standardKeyboardEvent.shiftKey ? mapping.withShift : mapping.value;
282
- const isDead = (standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey && mapping.withShiftAltGrIsDeadKey) ||
283
- (standardKeyboardEvent.altKey && mapping.withAltGrIsDeadKey) ||
284
- (standardKeyboardEvent.shiftKey && mapping.withShiftIsDeadKey) ||
285
- mapping.valueIsDeadKey;
286
- if (isDead && standardKeyboardEvent.browserEvent.key !== 'Dead') {
278
+ const expectedValue = standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey ? mapping.withShiftAltGr : standardKeyboardEvent.altKey ? mapping.withAltGr : standardKeyboardEvent.shiftKey ? mapping.withShift : mapping.value;
279
+ const isDead = (standardKeyboardEvent.altKey && standardKeyboardEvent.shiftKey && mapping.withShiftAltGrIsDeadKey) || (standardKeyboardEvent.altKey && mapping.withAltGrIsDeadKey) || (standardKeyboardEvent.shiftKey && mapping.withShiftIsDeadKey) || mapping.valueIsDeadKey;
280
+ if (isDead && standardKeyboardEvent.browserEvent.key !== "Dead") {
287
281
  return false;
288
282
  }
289
283
  if (!isDead && standardKeyboardEvent.browserEvent.key !== expectedValue) {
@@ -294,20 +288,19 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
294
288
  async _getBrowserKeyMapping(keyboardEvent) {
295
289
  if (this.keyboardLayoutMapAllowed) {
296
290
  try {
297
- return await navigator.keyboard.getLayoutMap().then((e) => {
291
+ return await navigator.keyboard.getLayoutMap().then(e => {
298
292
  const ret = {};
299
293
  for (const key of e) {
300
294
  ret[key[0]] = {
301
- 'value': key[1],
302
- 'withShift': '',
303
- 'withAltGr': '',
304
- 'withShiftAltGr': ''
295
+ "value": key[1],
296
+ "withShift": "",
297
+ "withAltGr": "",
298
+ "withShiftAltGr": ""
305
299
  };
306
300
  }
307
301
  return ret;
308
302
  });
309
- }
310
- catch {
303
+ } catch {
311
304
  this.keyboardLayoutMapAllowed = false;
312
305
  }
313
306
  }
@@ -315,10 +308,10 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
315
308
  const ret = {};
316
309
  const standardKeyboardEvent = keyboardEvent;
317
310
  ret[standardKeyboardEvent.browserEvent.code] = {
318
- 'value': standardKeyboardEvent.browserEvent.key,
319
- 'withShift': '',
320
- 'withAltGr': '',
321
- 'withShiftAltGr': ''
311
+ "value": standardKeyboardEvent.browserEvent.key,
312
+ "withShift": "",
313
+ "withAltGr": "",
314
+ "withShiftAltGr": ""
322
315
  };
323
316
  const matchedKeyboardLayout = this.getMatchedKeymapInfo(ret);
324
317
  if (matchedKeyboardLayout) {
@@ -332,15 +325,15 @@ class BrowserKeyboardMapperFactoryBase extends Disposable {
332
325
  class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
333
326
  constructor(configurationService, notificationService, storageService, commandService) {
334
327
  super(configurationService);
335
- const platform = isWindows ? 'win' : isMacintosh ? 'darwin' : 'linux';
336
- __variableDynamicImportRuntime0__(`./keyboardLayouts/layout.contribution.${platform}.js`).then((m) => {
328
+ const platform = isWindows ? "win" : isMacintosh ? "darwin" : "linux";
329
+ __variableDynamicImportRuntime0__(`./keyboardLayouts/layout.contribution.${platform}.js`).then(m => {
337
330
  const keymapInfos = m.KeyboardLayoutContribution.INSTANCE.layoutInfos;
338
- this._keymapInfos.push(...( keymapInfos.map(info => (( new KeymapInfo(
331
+ this._keymapInfos.push(...( keymapInfos.map(info => ( new KeymapInfo(
339
332
  info.layout,
340
333
  info.secondaryLayouts,
341
334
  info.mapping,
342
335
  info.isUserKeyboardLayout
343
- ))))));
336
+ )))));
344
337
  this._mru = this._keymapInfos;
345
338
  this._initialized = true;
346
339
  this.setLayoutFromBrowserAPI();
@@ -348,7 +341,9 @@ class BrowserKeyboardMapperFactory extends BrowserKeyboardMapperFactoryBase {
348
341
  }
349
342
  }
350
343
  class UserKeyboardLayout extends Disposable {
351
- get keyboardLayout() { return this._keyboardLayout; }
344
+ get keyboardLayout() {
345
+ return this._keyboardLayout;
346
+ }
352
347
  constructor(keyboardLayoutResource, fileService) {
353
348
  super();
354
349
  this.keyboardLayoutResource = keyboardLayoutResource;
@@ -361,7 +356,10 @@ class UserKeyboardLayout extends Disposable {
361
356
  this._onDidChange.fire();
362
357
  }
363
358
  }), 50)));
364
- this._register(Event.filter(this.fileService.onDidFilesChange, e => e.contains(this.keyboardLayoutResource))(() => this.reloadConfigurationScheduler.schedule()));
359
+ this._register(Event.filter(
360
+ this.fileService.onDidFilesChange,
361
+ e => e.contains(this.keyboardLayoutResource)
362
+ )(() => this.reloadConfigurationScheduler.schedule()));
365
363
  }
366
364
  async initialize() {
367
365
  await this.reload();
@@ -371,46 +369,50 @@ class UserKeyboardLayout extends Disposable {
371
369
  try {
372
370
  const content = await this.fileService.readFile(this.keyboardLayoutResource);
373
371
  const value = parse(( content.value.toString()));
374
- if (getNodeType(value) === 'object') {
372
+ if (getNodeType(value) === "object") {
375
373
  const layoutInfo = value.layout;
376
374
  const mappings = value.rawMapping;
377
375
  this._keyboardLayout = KeymapInfo.createKeyboardLayoutFromDebugInfo(layoutInfo, mappings, true);
378
- }
379
- else {
376
+ } else {
380
377
  this._keyboardLayout = null;
381
378
  }
382
- }
383
- catch (e) {
379
+ } catch (e) {
384
380
  this._keyboardLayout = null;
385
381
  }
386
382
  return existing ? !equals(existing, this._keyboardLayout) : true;
387
383
  }
388
384
  }
389
385
  let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Disposable {
390
- constructor(environmentService, fileService, notificationService, storageService, commandService, configurationService) {
386
+ constructor(
387
+ environmentService,
388
+ fileService,
389
+ notificationService,
390
+ storageService,
391
+ commandService,
392
+ configurationService
393
+ ) {
391
394
  super();
392
395
  this.configurationService = configurationService;
393
396
  this._onDidChangeKeyboardLayout = ( new Emitter());
394
397
  this.onDidChangeKeyboardLayout = this._onDidChangeKeyboardLayout.event;
395
- const keyboardConfig = configurationService.getValue('keyboard');
398
+ const keyboardConfig = configurationService.getValue("keyboard");
396
399
  const layout = keyboardConfig.layout;
397
- this._keyboardLayoutMode = layout ?? 'autodetect';
400
+ this._keyboardLayoutMode = layout ?? "autodetect";
398
401
  this._factory = ( new BrowserKeyboardMapperFactory(configurationService, notificationService, storageService, commandService));
399
402
  this._register(this._factory.onDidChangeKeyboardMapper(() => {
400
403
  this._onDidChangeKeyboardLayout.fire();
401
404
  }));
402
- if (layout && layout !== 'autodetect') {
405
+ if (layout && layout !== "autodetect") {
403
406
  this._factory.setKeyboardLayout(layout);
404
407
  }
405
408
  this._register(configurationService.onDidChangeConfiguration(e => {
406
- if (e.affectsConfiguration('keyboard.layout')) {
407
- const keyboardConfig = configurationService.getValue('keyboard');
409
+ if (e.affectsConfiguration("keyboard.layout")) {
410
+ const keyboardConfig = configurationService.getValue("keyboard");
408
411
  const layout = keyboardConfig.layout;
409
412
  this._keyboardLayoutMode = layout;
410
- if (layout === 'autodetect') {
413
+ if (layout === "autodetect") {
411
414
  this._factory.setLayoutFromBrowserAPI();
412
- }
413
- else {
415
+ } else {
414
416
  this._factory.setKeyboardLayout(layout);
415
417
  }
416
418
  }
@@ -427,12 +429,10 @@ let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Di
427
429
  if (userKeyboardLayouts.length) {
428
430
  if (this._userKeyboardLayout.keyboardLayout) {
429
431
  userKeyboardLayouts[0].update(this._userKeyboardLayout.keyboardLayout);
430
- }
431
- else {
432
+ } else {
432
433
  this._factory.removeKeyboardLayout(userKeyboardLayouts[0]);
433
434
  }
434
- }
435
- else {
435
+ } else {
436
436
  if (this._userKeyboardLayout.keyboardLayout) {
437
437
  this._factory.registerKeyboardLayout(this._userKeyboardLayout.keyboardLayout);
438
438
  }
@@ -441,7 +441,7 @@ let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Di
441
441
  }));
442
442
  }
443
443
  setUserKeyboardLayoutIfMatched() {
444
- const keyboardConfig = this.configurationService.getValue('keyboard');
444
+ const keyboardConfig = this.configurationService.getValue("keyboard");
445
445
  const layout = keyboardConfig.layout;
446
446
  if (layout && this._userKeyboardLayout.keyboardLayout) {
447
447
  if (getKeyboardLayoutId(this._userKeyboardLayout.keyboardLayout.layout) === layout && this._factory.activeKeymap) {
@@ -464,31 +464,24 @@ let BrowserKeyboardLayoutService = class BrowserKeyboardLayoutService extends Di
464
464
  return this._factory.activeKeyMapping;
465
465
  }
466
466
  validateCurrentKeyboardMapping(keyboardEvent) {
467
- if (this._keyboardLayoutMode !== 'autodetect') {
467
+ if (this._keyboardLayoutMode !== "autodetect") {
468
468
  return;
469
469
  }
470
470
  this._factory.validateCurrentKeyboardMapping(keyboardEvent);
471
471
  }
472
472
  };
473
- BrowserKeyboardLayoutService = ( __decorate([
474
- ( __param(0, IEnvironmentService)),
475
- ( __param(1, IFileService)),
476
- ( __param(2, INotificationService)),
477
- ( __param(3, IStorageService)),
478
- ( __param(4, ICommandService)),
479
- ( __param(5, IConfigurationService))
480
- ], BrowserKeyboardLayoutService));
473
+ BrowserKeyboardLayoutService = ( __decorate([( __param(0, IEnvironmentService)), ( __param(1, IFileService)), ( __param(2, INotificationService)), ( __param(3, IStorageService)), ( __param(4, ICommandService)), ( __param(5, IConfigurationService))], BrowserKeyboardLayoutService));
481
474
  const configurationRegistry = ( Registry.as(Extensions.Configuration));
482
475
  const keyboardConfiguration = {
483
- 'id': 'keyboard',
484
- 'order': 15,
485
- 'type': 'object',
486
- 'title': ( localize(14136, "Keyboard")),
487
- 'properties': {
488
- 'keyboard.layout': {
489
- 'type': 'string',
490
- 'default': 'autodetect',
491
- 'description': ( localize(14137, "Control the keyboard layout used in web."))
476
+ "id": "keyboard",
477
+ "order": 15,
478
+ "type": "object",
479
+ "title": ( localize(14525, "Keyboard")),
480
+ "properties": {
481
+ "keyboard.layout": {
482
+ "type": "string",
483
+ "default": "autodetect",
484
+ "description": ( localize(14526, "Control the keyboard layout used in web."))
492
485
  }
493
486
  }
494
487
  };
@@ -1,7 +1,9 @@
1
1
 
2
2
 
3
3
  class KeyboardLayoutContribution {
4
- static { this.INSTANCE = ( new KeyboardLayoutContribution()); }
4
+ static {
5
+ this.INSTANCE = ( new KeyboardLayoutContribution());
6
+ }
5
7
  get layoutInfos() {
6
8
  return this._layoutInfos;
7
9
  }
@@ -8,67 +8,62 @@ class KeybindingIO {
8
8
  return;
9
9
  }
10
10
  const quotedSerializedKeybinding = JSON.stringify(item.resolvedKeybinding.getUserSettingsLabel());
11
- out.write(`{ "key": ${rightPaddedString(quotedSerializedKeybinding + ',', 25)} "command": `);
12
- const quotedSerializedWhen = item.when ? JSON.stringify(item.when.serialize()) : '';
11
+ out.write(
12
+ `{ "key": ${rightPaddedString(quotedSerializedKeybinding + ",", 25)} "command": `
13
+ );
14
+ const quotedSerializedWhen = item.when ? JSON.stringify(item.when.serialize()) : "";
13
15
  const quotedSerializeCommand = JSON.stringify(item.command);
14
16
  if (quotedSerializedWhen.length > 0) {
15
17
  out.write(`${quotedSerializeCommand},`);
16
18
  out.writeLine();
17
19
  out.write(` "when": ${quotedSerializedWhen}`);
18
- }
19
- else {
20
+ } else {
20
21
  out.write(`${quotedSerializeCommand}`);
21
22
  }
22
23
  if (item.commandArgs) {
23
- out.write(',');
24
+ out.write(",");
24
25
  out.writeLine();
25
- out.write(` "args": ${JSON.stringify(item.commandArgs)}`);
26
+ out.write(
27
+ ` "args": ${JSON.stringify(item.commandArgs)}`
28
+ );
26
29
  }
27
- out.write(' }');
30
+ out.write(" }");
28
31
  }
29
32
  static readUserKeybindingItem(input) {
30
- const keybinding = 'key' in input && typeof input.key === 'string'
31
- ? KeybindingParser.parseKeybinding(input.key)
32
- : null;
33
- const when = 'when' in input && typeof input.when === 'string'
34
- ? ContextKeyExpr.deserialize(input.when)
35
- : undefined;
36
- const command = 'command' in input && typeof input.command === 'string'
37
- ? input.command
38
- : null;
39
- const commandArgs = 'args' in input && typeof input.args !== 'undefined'
40
- ? input.args
41
- : undefined;
33
+ const keybinding = "key" in input && typeof input.key === "string" ? KeybindingParser.parseKeybinding(input.key) : null;
34
+ const when = "when" in input && typeof input.when === "string" ? ContextKeyExpr.deserialize(input.when) : undefined;
35
+ const command = "command" in input && typeof input.command === "string" ? input.command : null;
36
+ const commandArgs = "args" in input && typeof input.args !== "undefined" ? input.args : undefined;
42
37
  return {
43
38
  keybinding,
44
39
  command,
45
40
  commandArgs,
46
41
  when,
47
- _sourceKey: 'key' in input && typeof input.key === 'string' ? input.key : undefined,
42
+ _sourceKey: "key" in input && typeof input.key === "string" ? input.key : undefined
48
43
  };
49
44
  }
50
45
  }
51
46
  function rightPaddedString(str, minChars) {
52
47
  if (str.length < minChars) {
53
- return str + (( new Array(minChars - str.length)).join(' '));
48
+ return str + (( new Array(minChars - str.length)).join(" "));
54
49
  }
55
50
  return str;
56
51
  }
57
52
  class OutputBuilder {
58
53
  constructor() {
59
54
  this._lines = [];
60
- this._currentLine = '';
55
+ this._currentLine = "";
61
56
  }
62
57
  write(str) {
63
58
  this._currentLine += str;
64
59
  }
65
- writeLine(str = '') {
60
+ writeLine(str = "") {
66
61
  this._lines.push(this._currentLine + str);
67
- this._currentLine = '';
62
+ this._currentLine = "";
68
63
  }
69
64
  toString() {
70
65
  this.writeLine();
71
- return this._lines.join('\n');
66
+ return this._lines.join("\n");
72
67
  }
73
68
  }
74
69
 
@@ -15,27 +15,26 @@ function deserializeMapping(serializedMapping) {
15
15
  const mask = Number(result[4]);
16
16
  const vkey = result.length === 6 ? result[5] : undefined;
17
17
  ret[key] = {
18
- 'value': value,
19
- 'vkey': vkey,
20
- 'withShift': withShift,
21
- 'withAltGr': withAltGr,
22
- 'withShiftAltGr': withShiftAltGr,
23
- 'valueIsDeadKey': (mask & 1) > 0,
24
- 'withShiftIsDeadKey': (mask & 2) > 0,
25
- 'withAltGrIsDeadKey': (mask & 4) > 0,
26
- 'withShiftAltGrIsDeadKey': (mask & 8) > 0
18
+ "value": value,
19
+ "vkey": vkey,
20
+ "withShift": withShift,
21
+ "withAltGr": withAltGr,
22
+ "withShiftAltGr": withShiftAltGr,
23
+ "valueIsDeadKey": (mask & 1) > 0,
24
+ "withShiftIsDeadKey": (mask & 2) > 0,
25
+ "withAltGrIsDeadKey": (mask & 4) > 0,
26
+ "withShiftAltGrIsDeadKey": (mask & 8) > 0
27
27
  };
28
- }
29
- else {
28
+ } else {
30
29
  ret[key] = {
31
- 'value': '',
32
- 'valueIsDeadKey': false,
33
- 'withShift': '',
34
- 'withShiftIsDeadKey': false,
35
- 'withAltGr': '',
36
- 'withAltGrIsDeadKey': false,
37
- 'withShiftAltGr': '',
38
- 'withShiftAltGrIsDeadKey': false
30
+ "value": "",
31
+ "valueIsDeadKey": false,
32
+ "withShift": "",
33
+ "withShiftIsDeadKey": false,
34
+ "withAltGr": "",
35
+ "withAltGrIsDeadKey": false,
36
+ "withShiftAltGr": "",
37
+ "withShiftAltGrIsDeadKey": false
39
38
  };
40
39
  }
41
40
  }
@@ -64,10 +63,10 @@ class KeymapInfo {
64
63
  getScore(other) {
65
64
  let score = 0;
66
65
  for (const key in other) {
67
- if (isWindows && (key === 'Backslash' || key === 'KeyQ')) {
66
+ if (isWindows && (key === "Backslash" || key === "KeyQ")) {
68
67
  continue;
69
68
  }
70
- if (isLinux && (key === 'Backspace' || key === 'Escape')) {
69
+ if (isLinux && (key === "Backspace" || key === "Escape")) {
71
70
  continue;
72
71
  }
73
72
  const currentMapping = this.mapping[key];
@@ -92,7 +91,7 @@ class KeymapInfo {
92
91
  }
93
92
  fuzzyEqual(other) {
94
93
  for (const key in other) {
95
- if (isWindows && (key === 'Backslash' || key === 'KeyQ')) {
94
+ if (isWindows && (key === "Backslash" || key === "KeyQ")) {
96
95
  continue;
97
96
  }
98
97
  if (this.mapping[key] === undefined) {