@codingame/monaco-editor-wrapper 1.13.1 → 1.14.2

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.
@@ -1,3 +1,3 @@
1
1
  import * as monaco from 'monaco-editor';
2
2
  import './semanticTokens';
3
- export declare function getOrCreateTextMateTokensProvider(languageId: string): Promise<monaco.languages.ITokenizationSupport>;
3
+ export declare function getOrCreateTextMateTokensProvider(languageId: string): Promise<monaco.languages.ITokenizationSupport | null>;
package/dist/main.js CHANGED
@@ -161,8 +161,12 @@ const themes = [];
161
161
  async function defineVSCodeTheme(id, vscodeThemeLoader, themeExtensionPoint, extensionData) {
162
162
  var _themeExtensionPoint$, _themeExtensionPoint$2, _ref, _themeExtensionPoint$3, _themeExtensionPoint$4;
163
163
 
164
- const path = "/theme-".concat(id, ".json");
165
- const rootUri = monaco$2.Uri.file((_themeExtensionPoint$ = themeExtensionPoint === null || themeExtensionPoint === void 0 ? void 0 : (_themeExtensionPoint$2 = themeExtensionPoint.path) === null || _themeExtensionPoint$2 === void 0 ? void 0 : _themeExtensionPoint$2.slice(1)) !== null && _themeExtensionPoint$ !== void 0 ? _themeExtensionPoint$ : path);
164
+ const path = "/theme-".concat(id, ".json"); // Do not use `file` scheme or monaco will replace `/` by `\` on windows
165
+
166
+ const rootUri = monaco$2.Uri.from({
167
+ scheme: 'browser',
168
+ path: (_themeExtensionPoint$ = themeExtensionPoint === null || themeExtensionPoint === void 0 ? void 0 : (_themeExtensionPoint$2 = themeExtensionPoint.path) === null || _themeExtensionPoint$2 === void 0 ? void 0 : _themeExtensionPoint$2.slice(1)) !== null && _themeExtensionPoint$ !== void 0 ? _themeExtensionPoint$ : path
169
+ });
166
170
  const themeData = monaco$2.extra.ColorThemeData.fromExtensionTheme(_objectSpread2({
167
171
  id,
168
172
  path: path,
@@ -211,7 +215,9 @@ const getOnigLib = async binaryUrl => {
211
215
  createOnigString
212
216
  };
213
217
  } catch (error) {
214
- console.error('Unable to load wasm', error);
218
+ monaco$2.errorHandler.onUnexpectedError(new Error('Unable to load vscode-oniguruma wasm', {
219
+ cause: error
220
+ }));
215
221
  throw error;
216
222
  }
217
223
  };
@@ -229,7 +235,11 @@ class CGTMGrammarFactory extends monaco$2.extra.TMGrammarFactory {
229
235
  const grammarFactoryHost = {
230
236
  // eslint-disable-next-line no-console
231
237
  logTrace: console.debug,
232
- logError: console.error,
238
+ logError: (msg, error) => {
239
+ monaco$2.errorHandler.onUnexpectedError(new Error(msg, {
240
+ cause: error
241
+ }));
242
+ },
233
243
 
234
244
  async readFile(resource) {
235
245
  const scopeName = resource.path.slice(resource.path.lastIndexOf('/') + 1, -'.json'.length);
@@ -1499,7 +1509,10 @@ for (const contribution of extensions.semanticTokenScopes) {
1499
1509
  function createGrammarFactory() {
1500
1510
  const languageService = monaco$2.extra.StandaloneServices.get(monaco$2.languages.ILanguageService);
1501
1511
  const parsedGrammars = rawGrammars.map(grammar => _objectSpread2(_objectSpread2({}, monaco$2.extra.parseTextMateGrammar(grammar, languageService)), {}, {
1502
- location: monaco$2.Uri.file(grammar.scopeName + '.json')
1512
+ location: monaco$2.Uri.from({
1513
+ scheme: 'browser',
1514
+ path: grammar.scopeName + '.json'
1515
+ })
1503
1516
  }));
1504
1517
  return new CGTMGrammarFactory(parsedGrammars, loader$3, onigFile);
1505
1518
  }
@@ -1526,7 +1539,7 @@ async function createTextMateTokensProvider(languageId) {
1526
1539
  } = await grammarFactory.createGrammar(languageId, encodedLanguageId);
1527
1540
 
1528
1541
  if (grammar == null) {
1529
- throw new Error("No grammar found for language ".concat(languageId));
1542
+ return null;
1530
1543
  }
1531
1544
 
1532
1545
  const tokenization = new monaco$2.extra.TMTokenization(grammar, initialState, containsEmbeddedLanguages);
@@ -3518,14 +3531,25 @@ for (const languageId of languagesIds) {
3518
3531
  });
3519
3532
  monaco$2.languages.setTokenizationSupportFactory(languageId, {
3520
3533
  createTokenizationSupport: async () => {
3521
- return getOrCreateTextMateTokensProvider(languageId).catch(async err => {
3534
+ return getOrCreateTextMateTokensProvider(languageId).catch(async error => {
3522
3535
  const monarchLoader = languageLoader[languageId];
3523
3536
 
3524
3537
  if (monarchLoader != null) {
3525
- console.warn("Failed to load TextMate grammar for language ".concat(languageId, ", fallback to monarch"), err);
3526
- monaco$2.languages.setMonarchTokensProvider(languageId, (await monarchLoader()).language);
3538
+ monaco$2.errorHandler.onUnexpectedError(new Error("Failed to load TextMate grammar for language ".concat(languageId, ", fallback to monarch"), {
3539
+ cause: error
3540
+ }));
3541
+
3542
+ try {
3543
+ monaco$2.languages.setMonarchTokensProvider(languageId, (await monarchLoader()).language);
3544
+ } catch (error) {
3545
+ monaco$2.errorHandler.onUnexpectedError(new Error("Failed to load Monarch grammar for language ".concat(languageId), {
3546
+ cause: error
3547
+ }));
3548
+ }
3527
3549
  } else {
3528
- console.warn("Failed to load TextMate grammar for language ".concat(languageId, " and no fallback monarch"), err);
3550
+ monaco$2.errorHandler.onUnexpectedError(new Error("Failed to load TextMate grammar for language ".concat(languageId, " and no fallback monarch"), {
3551
+ cause: error
3552
+ }));
3529
3553
  }
3530
3554
 
3531
3555
  return null;
@@ -3568,7 +3592,9 @@ languageService.onDidEncounterLanguage(async languageId => {
3568
3592
  }
3569
3593
 
3570
3594
  loadLanguageConfiguration(languageId).catch(error => {
3571
- console.error('Unable to load language configuration', error);
3595
+ monaco$2.errorHandler.onUnexpectedError(new Error("Unable to load language configuration for language ".concat(languageId), {
3596
+ cause: error
3597
+ }));
3572
3598
  });
3573
3599
  });
3574
3600
 
@@ -3716,7 +3742,9 @@ for (const themeExtensionPoint of defaultThemes) {
3716
3742
  extensionName: themeExtensionPoint.extension,
3717
3743
  extensionIsBuiltin: true
3718
3744
  }).catch(error => {
3719
- console.error('Unable to define vscode theme', error);
3745
+ monaco$2.errorHandler.onUnexpectedError(new Error("Unable to define \"".concat(themeExtensionPoint.id, "\" vscode theme"), {
3746
+ cause: error
3747
+ }));
3720
3748
  });
3721
3749
  }
3722
3750
 
@@ -4171,8 +4199,10 @@ monaco$2.extra.StandaloneServices.initialize({
4171
4199
  }); // Force EOL to be '\n' even on Windows
4172
4200
 
4173
4201
  const configurationService = monaco$2.extra.StandaloneServices.get(monaco$2.extra.IConfigurationService);
4174
- configurationService.updateValue('files.eol', '\n').catch(err => {
4175
- console.error('Unable to set file eol', err);
4202
+ configurationService.updateValue('files.eol', '\n').catch(error => {
4203
+ monaco$2.errorHandler.onUnexpectedError(new Error('Unable to set file eol', {
4204
+ cause: error
4205
+ }));
4176
4206
  });
4177
4207
  monaco$2.errorHandler.setUnexpectedErrorHandler(error => {
4178
4208
  console.warn('Unexpected error', error);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-editor-wrapper",
3
- "version": "1.13.1",
3
+ "version": "1.14.2",
4
4
  "private": false,
5
5
  "description": "Enhanced Monaco editor with TextMate grammars and more",
6
6
  "scripts": {