@codingame/monaco-vscode-api 1.76.2 → 1.76.3-next.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.
Files changed (59) hide show
  1. package/README.md +2 -1
  2. package/dist/api.js +3 -860
  3. package/dist/{extHost.js → api2.js} +16555 -13467
  4. package/dist/async.js +107 -2
  5. package/dist/audioCue.js +105 -103
  6. package/dist/button.js +1 -1
  7. package/dist/cancellation.js +3 -0
  8. package/dist/configuration.js +7 -344
  9. package/dist/configuration2.js +339 -0
  10. package/dist/configurationRegistry.js +441 -0
  11. package/dist/contextkeys.js +211 -0
  12. package/dist/debug.d.ts +22 -0
  13. package/dist/debug.js +15842 -0
  14. package/dist/dialogs.js +855 -9
  15. package/dist/extensionResourceLoader.js +96 -0
  16. package/dist/extensions.d.ts +491 -0
  17. package/dist/extensions.js +70 -0
  18. package/dist/{tools.js → extensionsRegistry.js} +2 -30
  19. package/dist/files.js +1407 -334
  20. package/dist/iconv.js +43 -0
  21. package/dist/injection.js +1 -1
  22. package/dist/jschardet.js +7 -0
  23. package/dist/keybindings.d.ts +1 -485
  24. package/dist/keybindings.js +666 -679
  25. package/dist/labels.js +14 -0
  26. package/dist/languageConfiguration.d.ts +1 -2
  27. package/dist/languageConfiguration.js +9 -16
  28. package/dist/languageService.js +112 -8
  29. package/dist/languages.d.ts +1 -473
  30. package/dist/languages.js +2 -12
  31. package/dist/layout.js +4 -3
  32. package/dist/layoutService.js +1 -1
  33. package/dist/missing-services.js +4710 -74
  34. package/dist/modelEditor.d.ts +324 -2
  35. package/dist/modelEditor.js +15 -228
  36. package/dist/monaco.js +7 -72
  37. package/dist/notifications.js +75 -232
  38. package/dist/polyfill.js +10715 -2459
  39. package/dist/resources.js +197 -0
  40. package/dist/services.d.ts +924 -3
  41. package/dist/services.js +1 -2
  42. package/dist/services2.js +2436 -18
  43. package/dist/snippets.d.ts +1 -473
  44. package/dist/snippets.js +8 -867
  45. package/dist/snippetsService.js +868 -0
  46. package/dist/textFileEditorModel.js +2985 -0
  47. package/dist/textmate.d.ts +3 -475
  48. package/dist/textmate.js +19 -29
  49. package/dist/theme.d.ts +1 -3
  50. package/dist/theme.js +24 -70
  51. package/dist/tokenClassification.d.ts +1 -475
  52. package/dist/tokenClassification.js +11 -37
  53. package/dist/tokenClassificationRegistry.js +8 -4
  54. package/dist/variableResolver.js +1711 -0
  55. package/dist/workbenchThemeService.js +1 -1
  56. package/dist/workspaceContext.js +1 -3
  57. package/package.json +27 -12
  58. package/dist/contextkey.js +0 -419
  59. package/dist/dialog.web.contribution.js +0 -945
package/dist/labels.js ADDED
@@ -0,0 +1,14 @@
1
+ import { isMacintosh, isWindows } from 'monaco-editor/esm/vs/base/common/platform.js';
2
+ function untildify(path, userHome) {
3
+ return path.replace(/^~($|\/|\\)/, `${userHome}$1`);
4
+ }
5
+ function mnemonicButtonLabel(label, forceDisableMnemonics) {
6
+ if (isMacintosh || forceDisableMnemonics) {
7
+ return label.replace(/\(&&\w\)|&&/g, '');
8
+ }
9
+ if (isWindows) {
10
+ return label.replace(/&&|&/g, m => m === '&' ? '&&' : '&');
11
+ }
12
+ return label.replace(/&&/g, '_');
13
+ }
14
+ export { mnemonicButtonLabel as m, untildify as u };
@@ -2,7 +2,6 @@ import * as monaco from 'monaco-editor';
2
2
 
3
3
  type IEditorOverrideServices = monaco.editor.IEditorOverrideServices
4
4
 
5
- declare function setLanguageConfiguration(path: string, getConfiguration: () => Promise<string>): void;
6
5
  declare function getServiceOverride(): IEditorOverrideServices;
7
6
 
8
- export { getServiceOverride as default, setLanguageConfiguration };
7
+ export { getServiceOverride as default };
@@ -1,8 +1,8 @@
1
- import { p as parse, g as getNodeType } from './polyfill.js';
2
- import { f as ITextMateTokenizationService, c as IExtensionService } from './missing-services.js';
3
- import { _ as __decorate, a as __param } from './contextkey.js';
1
+ import { o as onServicesInitialized, p as parse, j as getNodeType } from './polyfill.js';
2
+ import { bW as ITextMateTokenizationService, bp as IExtensionService } from './missing-services.js';
3
+ import { _ as __decorate, a as __param } from './services2.js';
4
4
  import { g as getParseErrorMessage } from './jsonErrorMessages.js';
5
- import { r as registerExtensionFile, g as getServiceOverride$1, I as IExtensionResourceLoaderService } from './files.js';
5
+ import { I as IExtensionResourceLoaderService } from './extensionResourceLoader.js';
6
6
  import { Disposable } from 'monaco-editor/esm/vs/base/common/lifecycle.js';
7
7
  import { hash } from 'monaco-editor/esm/vs/base/common/hash.js';
8
8
  import { localize } from 'monaco-editor/esm/vs/nls.js';
@@ -12,10 +12,7 @@ import { ILanguageConfigurationService } from 'monaco-editor/esm/vs/editor/commo
12
12
  import { Registry } from 'monaco-editor/esm/vs/platform/registry/common/platform.js';
13
13
  import { Extensions } from 'monaco-editor/esm/vs/platform/jsonschemas/common/jsonContributionRegistry.js';
14
14
  import { IndentAction } from 'monaco-editor/esm/vs/editor/common/languages/languageConfiguration.js';
15
- import { o as onServicesInitialized } from './tools.js';
16
- import { S as Services } from './services2.js';
17
- import { bj as DEFAULT_EXTENSION } from './extHost.js';
18
- import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
15
+ import { g as getServiceOverride$1 } from './files.js';
19
16
  function isStringArr(something) {
20
17
  if (!Array.isArray(something)) {
21
18
  return false;
@@ -55,12 +52,12 @@ let LanguageConfigurationFileHandler = class LanguageConfigurationFileHandler ex
55
52
  }
56
53
  async _loadConfigurationsForMode(languageId) {
57
54
  const configurationFiles = this._languageService.getConfigurationFiles(languageId);
58
- const configurationHash = hash(configurationFiles.map(uri => ( uri.toString())));
55
+ const configurationHash = hash(( configurationFiles.map(uri => ( uri.toString()))));
59
56
  if (this._done.get(languageId) === configurationHash) {
60
57
  return;
61
58
  }
62
59
  this._done.set(languageId, configurationHash);
63
- const configs = await Promise.all(configurationFiles.map(configFile => this._readConfigFile(configFile)));
60
+ const configs = await Promise.all(( configurationFiles.map(configFile => this._readConfigFile(configFile))));
64
61
  for (const config of configs) {
65
62
  this._handleConfig(languageId, config);
66
63
  }
@@ -71,7 +68,7 @@ let LanguageConfigurationFileHandler = class LanguageConfigurationFileHandler ex
71
68
  const errors = [];
72
69
  let configuration = parse(contents, errors);
73
70
  if (errors.length) {
74
- console.error(( localize('parseErrors', "Errors parsing {0}: {1}", ( configFileLocation.toString()), errors.map(e => (`[${e.offset}, ${e.length}] ${getParseErrorMessage(e.error)}`)).join('\n'))));
71
+ console.error(( localize('parseErrors', "Errors parsing {0}: {1}", ( configFileLocation.toString()), ( errors.map(e => (`[${e.offset}, ${e.length}] ${getParseErrorMessage(e.error)}`))).join('\n'))));
75
72
  }
76
73
  if (getNodeType(configuration) !== 'object') {
77
74
  console.error(( localize(
@@ -910,10 +907,6 @@ const schema = {
910
907
  };
911
908
  const schemaRegistry = ( Registry.as(Extensions.JSONContribution));
912
909
  schemaRegistry.registerSchema(schemaId, schema);
913
- function setLanguageConfiguration(path, getConfiguration) {
914
- const extension = Services.get().extension ?? DEFAULT_EXTENSION;
915
- registerExtensionFile(joinPath(extension.extensionLocation, path), getConfiguration);
916
- }
917
910
  function initialize(instantiationService) {
918
911
  instantiationService.createInstance(LanguageConfigurationFileHandler);
919
912
  }
@@ -923,4 +916,4 @@ function getServiceOverride() {
923
916
  ...getServiceOverride$1()
924
917
  };
925
918
  }
926
- export { getServiceOverride as default, setLanguageConfiguration };
919
+ export { getServiceOverride as default };
@@ -1,16 +1,20 @@
1
- import { _ as __decorate, a as __param } from './contextkey.js';
2
- import { c as IExtensionService } from './missing-services.js';
3
- import { E as ExtensionsRegistry } from './tools.js';
4
- import { O as FILES_ASSOCIATIONS_CONFIG } from './services2.js';
1
+ import { aS as FILES_ASSOCIATIONS_CONFIG, _ as __decorate, a as __param } from './services2.js';
2
+ import { bp as IExtensionService } from './missing-services.js';
3
+ import { E as ExtensionsRegistry } from './extensionsRegistry.js';
5
4
  import { parse } from 'monaco-editor/esm/vs/base/common/glob.js';
6
- import { posix } from 'monaco-editor/esm/vs/base/common/path.js';
5
+ import { posix, basename } from 'monaco-editor/esm/vs/base/common/path.js';
6
+ import { Schemas } from 'monaco-editor/esm/vs/base/common/network.js';
7
+ import { joinPath, DataUri } from 'monaco-editor/esm/vs/base/common/resources.js';
8
+ import { Mimes } from 'monaco-editor/esm/vs/base/common/mime.js';
9
+ import { PLAINTEXT_LANGUAGE_ID } from 'monaco-editor/esm/vs/editor/common/languages/modesRegistry.js';
10
+ import { startsWithUTF8BOM } from 'monaco-editor/esm/vs/base/common/strings.js';
7
11
  import { LanguageService } from 'monaco-editor/esm/vs/editor/common/services/languageService.js';
8
12
  import { localize } from 'monaco-editor/esm/vs/nls.js';
9
- import { joinPath } from 'monaco-editor/esm/vs/base/common/resources.js';
10
13
  import { IConfigurationService } from 'monaco-editor/esm/vs/platform/configuration/common/configuration.js';
11
14
  import { IEnvironmentService } from 'monaco-editor/esm/vs/platform/environment/common/environment.js';
12
15
  import { ILogService } from 'monaco-editor/esm/vs/platform/log/common/log.js';
13
16
  let registeredAssociations = [];
17
+ let nonUserRegisteredAssociations = [];
14
18
  let userRegisteredAssociations = [];
15
19
  function registerConfiguredLanguageAssociation(association) {
16
20
  _registerLanguageAssociation(association, true, false);
@@ -18,7 +22,9 @@ function registerConfiguredLanguageAssociation(association) {
18
22
  function _registerLanguageAssociation(association, userConfigured, warnOnOverwrite) {
19
23
  const associationItem = toLanguageAssociationItem(association, userConfigured);
20
24
  registeredAssociations.push(associationItem);
21
- if (!associationItem.userConfigured) ;
25
+ if (!associationItem.userConfigured) {
26
+ nonUserRegisteredAssociations.push(associationItem);
27
+ }
22
28
  else {
23
29
  userRegisteredAssociations.push(associationItem);
24
30
  }
@@ -61,6 +67,104 @@ function clearConfiguredLanguageAssociations() {
61
67
  registeredAssociations = registeredAssociations.filter(a => !a.userConfigured);
62
68
  userRegisteredAssociations = [];
63
69
  }
70
+ function getMimeTypes(resource, firstLine) {
71
+ return ( getAssociations(resource, firstLine).map(item => item.mime));
72
+ }
73
+ function getAssociations(resource, firstLine) {
74
+ let path;
75
+ if (resource) {
76
+ switch (resource.scheme) {
77
+ case Schemas.file:
78
+ path = resource.fsPath;
79
+ break;
80
+ case Schemas.data: {
81
+ const metadata = DataUri.parseMetaData(resource);
82
+ path = metadata.get(DataUri.META_DATA_LABEL);
83
+ break;
84
+ }
85
+ case Schemas.vscodeNotebookCell:
86
+ path = undefined;
87
+ break;
88
+ default:
89
+ path = resource.path;
90
+ }
91
+ }
92
+ if (!path) {
93
+ return [{ id: 'unknown', mime: Mimes.unknown }];
94
+ }
95
+ path = path.toLowerCase();
96
+ const filename = basename(path);
97
+ const configuredLanguage = getAssociationByPath(path, filename, userRegisteredAssociations);
98
+ if (configuredLanguage) {
99
+ return [configuredLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
100
+ }
101
+ const registeredLanguage = getAssociationByPath(path, filename, nonUserRegisteredAssociations);
102
+ if (registeredLanguage) {
103
+ return [registeredLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
104
+ }
105
+ if (firstLine) {
106
+ const firstlineLanguage = getAssociationByFirstline(firstLine);
107
+ if (firstlineLanguage) {
108
+ return [firstlineLanguage, { id: PLAINTEXT_LANGUAGE_ID, mime: Mimes.text }];
109
+ }
110
+ }
111
+ return [{ id: 'unknown', mime: Mimes.unknown }];
112
+ }
113
+ function getAssociationByPath(path, filename, associations) {
114
+ let filenameMatch = undefined;
115
+ let patternMatch = undefined;
116
+ let extensionMatch = undefined;
117
+ for (let i = associations.length - 1; i >= 0; i--) {
118
+ const association = associations[i];
119
+ if (filename === association.filenameLowercase) {
120
+ filenameMatch = association;
121
+ break;
122
+ }
123
+ if (association.filepattern) {
124
+ if (!patternMatch || association.filepattern.length > patternMatch.filepattern.length) {
125
+ const target = association.filepatternOnPath ? path : filename;
126
+ if (association.filepatternLowercase?.(target)) {
127
+ patternMatch = association;
128
+ }
129
+ }
130
+ }
131
+ if (association.extension) {
132
+ if (!extensionMatch || association.extension.length > extensionMatch.extension.length) {
133
+ if (filename.endsWith(association.extensionLowercase)) {
134
+ extensionMatch = association;
135
+ }
136
+ }
137
+ }
138
+ }
139
+ if (filenameMatch) {
140
+ return filenameMatch;
141
+ }
142
+ if (patternMatch) {
143
+ return patternMatch;
144
+ }
145
+ if (extensionMatch) {
146
+ return extensionMatch;
147
+ }
148
+ return undefined;
149
+ }
150
+ function getAssociationByFirstline(firstLine) {
151
+ if (startsWithUTF8BOM(firstLine)) {
152
+ firstLine = firstLine.substr(1);
153
+ }
154
+ if (firstLine.length > 0) {
155
+ for (let i = registeredAssociations.length - 1; i >= 0; i--) {
156
+ const association = registeredAssociations[i];
157
+ if (!association.firstline) {
158
+ continue;
159
+ }
160
+ const matches = firstLine.match(association.firstline);
161
+ if (matches && matches.length > 0) {
162
+ return association;
163
+ }
164
+ }
165
+ }
166
+ return undefined;
167
+ }
64
168
  const languagesExtPoint = ( ExtensionsRegistry.registerExtensionPoint({
65
169
  extensionPoint: 'languages',
66
170
  jsonSchema: {
@@ -346,4 +450,4 @@ function isValidLanguageExtensionPoint(value, extension, collector) {
346
450
  }
347
451
  return true;
348
452
  }
349
- export { WorkbenchLanguageService as W, languagesExtPoint as l };
453
+ export { WorkbenchLanguageService as W, getMimeTypes as g, languagesExtPoint as l };