Skip to content

Commit

Permalink
Merge pull request #666 from TypeFox/issue-620
Browse files Browse the repository at this point in the history
Fix: Multiple Monaco editor issue
  • Loading branch information
kaisalmen committed May 28, 2024
2 parents 3722b89 + 54eb77b commit 369834a
Show file tree
Hide file tree
Showing 31 changed files with 655 additions and 547 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ loader.config({ monaco });
If you use pnpm, you have to add `vscode` / `@codingame/monaco-vscode-api` as direct dependency (you find the [compatibility table here](https://github.com/TypeFox/monaco-languageclient/blob/main/docs/versions-and-history.md#monaco-editor--codingamemonaco-vscode-api-compatibility-table), otherwise the installation will fail.

```json
"vscode": "npm:@codingame/monaco-vscode-api@~5.1.1"
"vscode": "npm:@codingame/monaco-vscode-api@~5.2.0"
```

## Licenses
Expand Down
1 change: 1 addition & 0 deletions docs/versions-and-history.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The following table describes which version of **monaco-languageclient** and **@

| monaco-languageclient | monaco-editor-wrapper | monaco-editor-react | monaco-vscode-api / editor-api | vscode | monaco-editor | release date | comment |
| :---- | :---- | :--- | :--- | :--- | :--- | :--- | :--- |
| 8.5.0 | 5.2.0 | 4.2.0 | 5.2.0 | 1.89.1 | 0.48.0 | 2024-05-2x | |
| 8.4.0 | 5.1.2 | 4.1.2 | 5.1.1 | 1.89.1 | 0.48.0 | 2024-05-17 | |
| 8.4.0 | 5.1.1 | 4.1.1 | 5.1.1 | 1.89.1 | 0.48.0 | 2024-05-15 | |
| 8.4.0 | 5.1.0 | 4.1.0 | 5.1.1 | 1.89.1 | 0.48.0 | 2024-05-15 | |
Expand Down
817 changes: 422 additions & 395 deletions package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
"type": "module",
"devDependencies": {
"@codingame/esbuild-import-meta-url-plugin": "~1.0.2",
"@codingame/monaco-vscode-rollup-vsix-plugin": "~5.1.1",
"@codingame/monaco-vscode-rollup-vsix-plugin": "~5.2.0",
"@rollup/pluginutils": "~5.1.0",
"@types/node": "~20.12.12",
"@types/react": "~18.3.2",
"@types/react": "~18.3.3",
"@types/react-dom": "~18.3.0",
"@types/vscode": "~1.89.0",
"@typescript-eslint/eslint-plugin": "~7.9.0",
"@typescript-eslint/parser": "~7.9.0",
"@typescript-eslint/eslint-plugin": "~7.10.0",
"@typescript-eslint/parser": "~7.10.0",
"@vitest/browser": "~1.6.0",
"editorconfig": "~2.0.0",
"esbuild": "~0.21.3",
Expand All @@ -24,7 +24,7 @@
"vite": "~5.2.11",
"vitest": "~1.6.0",
"vite-node": "~1.6.0",
"webdriverio": "~8.36.1"
"webdriverio": "~8.37.0"
},
"volta": {
"node": "20.13.1",
Expand Down
4 changes: 4 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this npm module are documented in this file.

## [8.5.0] - 2024-05-2x

- Updated to version `5.2.0` of `@codingame/monaco-vscode` packages

## [8.4.0] - 2024-05-15

- Updated to version `5.1.1` of `@codingame/monaco-vscode` packages
Expand Down
18 changes: 9 additions & 9 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-languageclient",
"version": "8.4.0",
"version": "8.5.0",
"description": "Monaco Language client implementation",
"author": {
"name": "TypeFox GmbH",
Expand Down Expand Up @@ -62,17 +62,17 @@
"LICENSE"
],
"dependencies": {
"@codingame/monaco-vscode-extensions-service-override": "~5.1.1",
"@codingame/monaco-vscode-languages-service-override": "~5.1.1",
"@codingame/monaco-vscode-localization-service-override": "~5.1.1",
"@codingame/monaco-vscode-model-service-override": "~5.1.1",
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.1.1",
"vscode": "npm:@codingame/monaco-vscode-api@~5.1.1",
"@codingame/monaco-vscode-extensions-service-override": "~5.2.0",
"@codingame/monaco-vscode-languages-service-override": "~5.2.0",
"@codingame/monaco-vscode-localization-service-override": "~5.2.0",
"@codingame/monaco-vscode-model-service-override": "~5.2.0",
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@~5.2.0",
"vscode-languageclient": "~9.0.1"
},
"peerDependencies": {
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.1.1",
"vscode": "npm:@codingame/monaco-vscode-api@~5.1.1"
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.2.0",
"vscode": "npm:@codingame/monaco-vscode-api@~5.2.0"
},
"peerDependenciesMeta": {
"monaco-editor": {
Expand Down
4 changes: 4 additions & 0 deletions packages/examples/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

All notable changes to this npm module are documented in this file.

## [2024.5.2x] - 2024-05-2x

- Updated to `monaco-languageclient@8.5.0`, `monaco-editor-wrapper@5.2.0` and `@typefox/monaco-editor-react@4.2.0`. Updated all `@codingame/monaco-vscode` packages to `5.2.0`.

## [2024.5.17] - 2024-05-17

- All example now work with vite/rollup production build (lessons learned for me :-)
Expand Down
52 changes: 26 additions & 26 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-languageclient-examples",
"version": "2024.5.17",
"version": "2024.5.2x",
"description": "Monaco Language client examples",
"author": {
"name": "TypeFox GmbH",
Expand Down Expand Up @@ -54,39 +54,39 @@
}
},
"dependencies": {
"@codingame/monaco-vscode-configuration-service-override": "~5.1.1",
"@codingame/monaco-vscode-files-service-override": "~5.1.1",
"@codingame/monaco-vscode-groovy-default-extension": "~5.1.1",
"@codingame/monaco-vscode-keybindings-service-override": "~5.1.1",
"@codingame/monaco-vscode-lifecycle-service-override": "~5.1.1",
"@codingame/monaco-vscode-localization-service-override": "~5.1.1",
"@codingame/monaco-vscode-javascript-default-extension": "~5.1.1",
"@codingame/monaco-vscode-json-default-extension": "~5.1.1",
"@codingame/monaco-vscode-python-default-extension": "~5.1.1",
"@codingame/monaco-vscode-standalone-languages": "~5.1.1",
"@codingame/monaco-vscode-standalone-typescript-language-features": "~5.1.1",
"@codingame/monaco-vscode-standalone-json-language-features": "~5.1.1",
"@codingame/monaco-vscode-textmate-service-override": "~5.1.1",
"@codingame/monaco-vscode-theme-defaults-default-extension": "~5.1.1",
"@codingame/monaco-vscode-theme-service-override": "~5.1.1",
"@codingame/monaco-vscode-typescript-basics-default-extension": "~5.1.1",
"@codingame/monaco-vscode-typescript-language-features-default-extension": "~5.1.1",
"@typefox/monaco-editor-react": "~4.1.2",
"@codingame/monaco-vscode-configuration-service-override": "~5.2.0",
"@codingame/monaco-vscode-files-service-override": "~5.2.0",
"@codingame/monaco-vscode-groovy-default-extension": "~5.2.0",
"@codingame/monaco-vscode-keybindings-service-override": "~5.2.0",
"@codingame/monaco-vscode-lifecycle-service-override": "~5.2.0",
"@codingame/monaco-vscode-localization-service-override": "~5.2.0",
"@codingame/monaco-vscode-javascript-default-extension": "~5.2.0",
"@codingame/monaco-vscode-json-default-extension": "~5.2.0",
"@codingame/monaco-vscode-python-default-extension": "~5.2.0",
"@codingame/monaco-vscode-standalone-languages": "~5.2.0",
"@codingame/monaco-vscode-standalone-typescript-language-features": "~5.2.0",
"@codingame/monaco-vscode-standalone-json-language-features": "~5.2.0",
"@codingame/monaco-vscode-textmate-service-override": "~5.2.0",
"@codingame/monaco-vscode-theme-defaults-default-extension": "~5.2.0",
"@codingame/monaco-vscode-theme-service-override": "~5.2.0",
"@codingame/monaco-vscode-typescript-basics-default-extension": "~5.2.0",
"@codingame/monaco-vscode-typescript-language-features-default-extension": "~5.2.0",
"@typefox/monaco-editor-react": "~4.2.0",
"express": "~4.19.2",
"langium": "3.0.0",
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.1.1",
"monaco-editor-wrapper": "~5.1.2",
"monaco-languageclient": "~8.4.0",
"pyright": "~1.1.363",
"langium": "~3.0.0",
"monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~5.2.0",
"monaco-editor-wrapper": "~5.2.0",
"monaco-languageclient": "~8.5.0",
"pyright": "~1.1.364",
"react": "~18.3.1",
"react-dom": "~18.3.1",
"request-light": "~0.7.0",
"vscode": "npm:@codingame/monaco-vscode-api@~5.1.1",
"vscode": "npm:@codingame/monaco-vscode-api@~5.2.0",
"vscode-json-languageservice": "~5.3.11",
"vscode-languageclient": "~9.0.1",
"vscode-languageserver": "~9.0.1",
"vscode-uri": "~3.0.8",
"vscode-ws-jsonrpc": "~3.3.1",
"vscode-ws-jsonrpc": "~3.3.2",
"ws": "~8.17.0"
},
"devDependencies": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,20 +6,24 @@
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import getLifecycleServiceOverride from '@codingame/monaco-vscode-lifecycle-service-override';
import getLocalizationServiceOverride from '@codingame/monaco-vscode-localization-service-override';
import { IConnectionProvider } from 'monaco-languageclient';
import { createDefaultLocaleConfiguration } from 'monaco-languageclient/vscode/services';
import { UserConfig } from 'monaco-editor-wrapper';
import { LanguageClientConfig, UserConfig } from 'monaco-editor-wrapper';
// cannot be imported with assert as json contains comments
import statemachineLanguageConfig from './language-configuration.json?raw';
import responseStatemachineTm from '../syntaxes/statemachine.tmLanguage.json?raw';

export const createLangiumGlobalConfig = async (params: {
languageServerId: string,
useLanguageClient: boolean,
text?: string,
worker: Worker,
messagePort?: MessagePort
worker?: Worker,
messagePort?: MessagePort,
connectionProvider?: IConnectionProvider
}): Promise<UserConfig> => {
const extensionFilesOrContents = new Map<string, string | URL>();
extensionFilesOrContents.set('/statemachine-configuration.json', statemachineLanguageConfig);
extensionFilesOrContents.set('/statemachine-grammar.json', responseStatemachineTm);
extensionFilesOrContents.set(`/${params.languageServerId}-statemachine-configuration.json`, statemachineLanguageConfig);
extensionFilesOrContents.set(`/${params.languageServerId}-statemachine-grammar.json`, responseStatemachineTm);

let main;
if (params.text) {
Expand All @@ -29,6 +33,16 @@ export const createLangiumGlobalConfig = async (params: {
};
}

const languageClientConfig: LanguageClientConfig | undefined = params.useLanguageClient && params.worker ? {
languageId: 'statemachine',
options: {
$type: 'WorkerDirect',
worker: params.worker,
messagePort: params.messagePort,
},
connectionProvider: params.connectionProvider
} : undefined;

return {
wrapperConfig: {
serviceConfig: {
Expand Down Expand Up @@ -58,12 +72,12 @@ export const createLangiumGlobalConfig = async (params: {
id: 'statemachine',
extensions: ['.statemachine'],
aliases: ['statemachine', 'Statemachine'],
configuration: './statemachine-configuration.json'
configuration: `./${params.languageServerId}-statemachine-configuration.json`
}],
grammars: [{
language: 'statemachine',
scopeName: 'source.statemachine',
path: './statemachine-grammar.json'
path: `./${params.languageServerId}-statemachine-grammar.json`
}]
}
},
Expand All @@ -78,13 +92,6 @@ export const createLangiumGlobalConfig = async (params: {
}
}
},
languageClientConfig: {
languageId: 'statemachine',
options: {
$type: 'WorkerDirect',
worker: params.worker,
messagePort: params.messagePort
}
}
languageClientConfig
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
statemachine TrafficLight

events
switchCapacity
next

initialState PowerOff

state PowerOff
switchCapacity => RedLight
end

state RedLight
switchCapacity => PowerOff
next => GreenLight
end

state OrangeLight
switchCapacity => PowerOff
next => RedLight
end

state YellowLight
switchCapacity => PowerOff
next => OrangeLight
end

state GreenLight
switchCapacity => PowerOff
next => YellowLight
end
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
* This file was generated by langium-cli 3.0.0-next.e78aeba.
* This file was generated by langium-cli 3.0.3.
* DO NOT EDIT MANUALLY!
******************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/******************************************************************************
* This file was generated by langium-cli 3.0.0-next.e78aeba.
* This file was generated by langium-cli 3.0.3.
* DO NOT EDIT MANUALLY!
******************************************************************************/

Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/******************************************************************************
* This file was generated by langium-cli 3.0.0-next.e78aeba.
* This file was generated by langium-cli 3.0.3.
* DO NOT EDIT MANUALLY!
******************************************************************************/

import type { LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, LanguageMetaData, Module } from 'langium';
import type { LangiumSharedServices, LangiumServices } from 'langium/lsp';
import type { LangiumSharedCoreServices, LangiumCoreServices, LangiumGeneratedCoreServices, LangiumGeneratedSharedCoreServices, LanguageMetaData, Module } from 'langium';
import { StatemachineAstReflection } from './ast.js';
import { StatemachineGrammar } from './grammar.js';

Expand All @@ -14,11 +13,11 @@ export const StatemachineLanguageMetaData = {
caseInsensitive: false
} as const satisfies LanguageMetaData;

export const StatemachineGeneratedSharedModule: Module<LangiumSharedServices, LangiumGeneratedSharedCoreServices> = {
export const StatemachineGeneratedSharedModule: Module<LangiumSharedCoreServices, LangiumGeneratedSharedCoreServices> = {
AstReflection: () => new StatemachineAstReflection()
};

export const StatemachineGeneratedModule: Module<LangiumServices, LangiumGeneratedCoreServices> = {
export const StatemachineGeneratedModule: Module<LangiumCoreServices, LangiumGeneratedCoreServices> = {
Grammar: () => StatemachineGrammar(),
LanguageMetaData: () => StatemachineLanguageMetaData,
parser: {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,11 @@
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */

import type { Module } from 'langium';
import type { DefaultSharedModuleContext, LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp';
import { inject } from 'langium';
import { createDefaultModule, createDefaultSharedModule } from 'langium/lsp';
import { type Module, inject } from 'langium';
import type { LangiumServices, LangiumSharedServices, PartialLangiumServices } from 'langium/lsp';
import { createDefaultModule, createDefaultSharedModule, type DefaultSharedModuleContext } from 'langium/lsp';
import { StatemachineGeneratedModule, StatemachineGeneratedSharedModule } from './generated/module.js';
import { registerValidationChecks, StatemachineValidator } from './statemachine-validator.js';
import { StatemachineValidator, registerValidationChecks } from './statemachine-validator.js';

/**
* Declaration of custom services - add your own service classes here.
Expand Down Expand Up @@ -66,5 +65,10 @@ export function createStatemachineServices(context: DefaultSharedModuleContext):
);
shared.ServiceRegistry.register(statemachine);
registerValidationChecks(statemachine);
if (!context.connection) {
// We don't run inside a language server
// Therefore, initialize the configuration provider instantly
shared.workspace.ConfigurationProvider.initialized({});
}
return { shared, statemachine };
}
2 changes: 2 additions & 0 deletions packages/examples/src/langium/statemachine/main-react.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ export const configureMonacoWorkers = () => {
export const runStatemachineReact = async () => {
try {
const langiumGlobalConfig = await createLangiumGlobalConfig({
languageServerId: 'react',
useLanguageClient: true,
text,
worker: loadStatemachineWorkerRegular()
});
Expand Down
Loading

0 comments on commit 369834a

Please sign in to comment.