Skip to content

Commit

Permalink
Updated to [email protected]. Align with workspaceConfig chan…
Browse files Browse the repository at this point in the history
…ges (#575)

- Implemented review feedback
- Implemented #577
  • Loading branch information
kaisalmen authored Nov 27, 2023
1 parent d3cdabf commit adc7b63
Show file tree
Hide file tree
Showing 15 changed files with 671 additions and 370 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ Click [here](https://www.typefox.io/blog/teaching-the-language-server-protocol-t
- [Server processes](#server-processes)
- [Verification Example Servers](#verification-example-servers)
- [VSCode integration](#vscode-integration)
- [Featured projects](#featured-projects)
- [Troubleshooting](#troubleshooting)
- [General](#general)
- [Dependency issues: monaco-editor / @codingame/monaco-editor-treemended](#dependency-issues-monaco-editor--codingamemonaco-editor-treemended)
- [Volta](#volta)
- [Vite dev server troubleshooting](#vite-dev-server-troubleshooting)
- [Serve all files required](#serve-all-files-required)
- [Bad Polyfills](#bad-polyfills)
- [buffer](#buffer)
- [monaco-editor-core](#monaco-editor-core)
Expand Down Expand Up @@ -91,12 +93,12 @@ With v7 we decided to use readily treemended version of monaco-editor called [@c

```yaml
"overrides": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"resolutions": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
}
```

Expand Down Expand Up @@ -203,6 +205,11 @@ npm run start:verify:vite

You can as well run [vscode tasks](./.vscode/launch.json) to start and debug the server in different modes and the client.

## Featured projects

- JSONA Editor: [Showcase](https://jsona.github.io/editor/schema) ([GitHub](https://github.com/jsona/editor))
- monaco-editor-wrapper: [Showcase](https://langium.org/showcase/minilogo/) ([GitHub](https://github.com/TypeFox/monaco-components))

## Troubleshooting

### General
Expand All @@ -216,6 +223,8 @@ Ensure **monaco-editor**, **vscode** and **monaco-languageclient** are imported
It is recommended to study this chapter first: [NEW with v7: Treemended monaco-editor](#new-with-v7-treemended-monaco-editor).
If you have mutiple, possibly hundreds of compile errors resulting from missing functions deep in `monaco-editor` or `vscode` then it is very likely your `package-lock.json` or `node_modules` are dirty. Remove both and do a fresh `npm install`. Always `npm list monaco-editor` is very useful. If you see different or errornous versions, then this is an indicator something is wrong.

Current observation is: When using npm overrides upgrading them seems to be problematic. Best practices seems to be to remove `package-lock.json` or `node_modules` and do a full re-installation with `npm i` afterwards.

### Volta

There are [Volta](https://volta.sh/) instructions in the `package.json` files. When you have Volta available it will ensure the exactly specified `node` and `npm` versions are used.
Expand All @@ -232,6 +241,10 @@ resolve: {
}
```

### Serve all files required

`@codingame/monaco-vscode-api` requires json and other files to be served. In your project's web-server configuration you have to ensure you don't prevent this.

### Bad Polyfills

#### buffer
Expand Down Expand Up @@ -295,7 +308,7 @@ loader.config({ monaco });
If you use pnpm, you have to add `vscode` / `@codingame/monaco-vscode-api` as direct dependency (see the [following table](#monaco-editor--codingamemonaco-vscode-api-compatibility-table)), otherwise the installation will fail.

```json
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
```

## Monaco-editor / @codingame/monaco-vscode-api compatibility table
Expand All @@ -306,6 +319,7 @@ The following table describes which version of **monaco-languageclient** and **@

| monaco-languageclient | monaco-vscode-api | monaco-editor-treemended | monaco-editor | release date | comment |
| :---- | :---- | :--- | :--- | :--- | :--- |
| 7.1.0 | 1.83.12 | 1.83.12 | 0.44.0 | 2023-11-27 | |
| 7.0.2 | 1.83.7 | 1.83.7 | 0.44.0 | 2023-11-02 | |
| 7.0.1 | 1.83.5 | 1.83.5 | 0.44.0 | 2023-11-10 | |
| 7.0.0 | 1.83.5 | 1.83.5 | 0.44.0 | 2023-11-02 | Introduction of `@codingame/monaco-editor-treemended` |
Expand Down
837 changes: 541 additions & 296 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,26 @@
"type": "module",
"devDependencies": {
"@types/vscode": "~1.83.3",
"@typescript-eslint/eslint-plugin": "~6.9.1",
"@typescript-eslint/parser": "~6.9.1",
"@typescript-eslint/eslint-plugin": "~6.12.0",
"@typescript-eslint/parser": "~6.12.0",
"editorconfig": "~2.0.0",
"eslint": "~8.52.0",
"eslint": "~8.54.0",
"eslint-config-standard": "~17.1.0",
"eslint-plugin-header": "~3.1.1",
"eslint-plugin-import": "~2.29.0",
"eslint-plugin-promise": "~6.1.1",
"eslint-plugin-unused-imports": "~3.0.0",
"shx": "~0.3.4",
"typescript": "~5.2.2",
"vite": "~4.5.0"
"typescript": "~5.3.2",
"vite": "~5.0.2"
},
"overrides": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"resolutions": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"volta": {
"node": "18.18.2",
Expand Down
6 changes: 5 additions & 1 deletion packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,13 @@

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

## [7.1.0] - 2023-11-27

- Updated to `[email protected]`.

## [7.0.2] - 2023-11-15

- Updated to `monaco-vscode-api` `1.83.7`.
- Updated to `monaco-vscode-api@1.83.7`.

## [7.0.1] - 2023-11-10

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": "7.0.2",
"version": "7.1.0",
"description": "Monaco Language client implementation",
"author": {
"name": "TypeFox GmbH",
Expand Down Expand Up @@ -48,16 +48,16 @@
"License.txt"
],
"dependencies": {
"@codingame/monaco-vscode-editor-service-override": "~1.83.7",
"@codingame/monaco-vscode-languages-service-override": "~1.83.7",
"@codingame/monaco-vscode-model-service-override": "~1.83.7",
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0",
"@codingame/monaco-vscode-editor-service-override": "~1.83.12",
"@codingame/monaco-vscode-languages-service-override": "~1.83.12",
"@codingame/monaco-vscode-model-service-override": "~1.83.12",
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0",
"vscode-languageclient": "~9.0.1"
},
"peerDependencies": {
"monaco-editor": "0.44.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"peerDependenciesMeta": {
"monaco-editor": {
Expand All @@ -72,8 +72,8 @@
"vscode": "$vscode"
},
"resolutions": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"scripts": {
"clean": "shx rm -fr lib *.tsbuildinfo",
Expand Down
22 changes: 11 additions & 11 deletions packages/client/src/monaco-vscode-api-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* ------------------------------------------------------------------------------------------ */

import { editor, Environment } from 'monaco-editor';
import { ILogService, initialize, LogLevel, StandaloneServices } from 'vscode/services';
import { ILogService, initialize, IWorkbenchConstructionOptions, StandaloneServices } from 'vscode/services';
import { initialize as initializeVscodeExtensions } from 'vscode/extensions';
import { OpenEditor } from '@codingame/monaco-vscode-editor-service-override';
import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
Expand All @@ -17,7 +17,7 @@ export interface MonacoEnvironmentEnhanced extends Environment {
export type InitializeServiceConfig = {
userServices?: editor.IEditorOverrideServices;
debugLogging?: boolean;
logLevel?: LogLevel
workspaceConfig?: IWorkbenchConstructionOptions;
};

export const wasVscodeApiInitialized = () => {
Expand Down Expand Up @@ -85,7 +85,6 @@ export const mergeServices = (services: editor.IEditorOverrideServices, override
* - model
*/
export const importAllServices = async (config?: InitializeServiceConfig) => {
const serviceNames: string[] = [];
const lc: InitializeServiceConfig = config ?? {};
const userServices: editor.IEditorOverrideServices = lc.userServices ?? {};

Expand All @@ -96,23 +95,24 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
mergeServices(mlcDefautServices, userServices);
reportServiceLoading(userServices, lc.debugLogging === true);

const haveThemeService = serviceNames.includes('theme') || Object.keys(userServices).includes('themeService');
const haveTextmateService = serviceNames.includes('textmate') || Object.keys(userServices).includes('textMateTokenizationFeature');
const haveMarkersService = serviceNames.includes('markers');
const haveViewsService = serviceNames.includes('views') || Object.keys(userServices).includes('viewsService');
const haveThemeService = Object.keys(userServices).includes('themeService');
const haveTextmateService = Object.keys(userServices).includes('textMateTokenizationFeature');
const haveMarkersService = Object.keys(userServices).includes('markersService');
const haveViewsService = Object.keys(userServices).includes('viewsService');

// theme requires textmate
if (haveThemeService && !haveTextmateService) {
throw new Error('"theme" requires "textmate" service. Please add it to the "userServices".');
throw new Error('"theme" service requires "textmate" service. Please add it to the "userServices".');
}

// markers service requires views service
if (haveMarkersService && !haveViewsService) {
throw new Error('"markers" requires "views" service. Please add it to the "userServices".');
throw new Error('"markers" service requires "views" service. Please add it to the "userServices".');
}

await initialize(userServices);
if (lc.logLevel) {
StandaloneServices.get(ILogService).setLevel(lc.logLevel);
const logLevel = lc.workspaceConfig?.developmentOptions?.logLevel;
if (logLevel) {
StandaloneServices.get(ILogService).setLevel(logLevel);
}
};
5 changes: 5 additions & 0 deletions packages/examples/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@

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

## [7.1.0] - 2023-11-27

- Updated to `[email protected]`.
- Updated usage of configuration service to be in line with `[email protected]`.

## [7.0.2] - 2023-11-15

- Updated to `[email protected]`.
Expand Down
36 changes: 18 additions & 18 deletions packages/examples/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-languageclient-examples",
"version": "7.0.2",
"version": "7.1.0",
"description": "Monaco Language client examples",
"author": {
"name": "TypeFox GmbH",
Expand Down Expand Up @@ -43,29 +43,29 @@
}
},
"dependencies": {
"@codingame/monaco-vscode-configuration-service-override": "~1.83.7",
"@codingame/monaco-vscode-editor-service-override": "~1.83.7",
"@codingame/monaco-vscode-files-service-override": "~1.83.7",
"@codingame/monaco-vscode-json-default-extension": "~1.83.7",
"@codingame/monaco-vscode-keybindings-service-override": "~1.83.7",
"@codingame/monaco-vscode-python-default-extension": "~1.83.7",
"@codingame/monaco-vscode-textmate-service-override": "~1.83.7",
"@codingame/monaco-vscode-theme-defaults-default-extension": "~1.83.7",
"@codingame/monaco-vscode-theme-service-override": "~1.83.7",
"@codingame/monaco-vscode-language-pack-de": "~1.83.7",
"@codingame/monaco-vscode-language-pack-es": "~1.83.7",
"@codingame/monaco-vscode-language-pack-fr": "~1.83.7",
"@codingame/monaco-vscode-configuration-service-override": "~1.83.12",
"@codingame/monaco-vscode-editor-service-override": "~1.83.12",
"@codingame/monaco-vscode-files-service-override": "~1.83.12",
"@codingame/monaco-vscode-json-default-extension": "~1.83.12",
"@codingame/monaco-vscode-keybindings-service-override": "~1.83.12",
"@codingame/monaco-vscode-python-default-extension": "~1.83.12",
"@codingame/monaco-vscode-textmate-service-override": "~1.83.12",
"@codingame/monaco-vscode-theme-defaults-default-extension": "~1.83.12",
"@codingame/monaco-vscode-theme-service-override": "~1.83.12",
"@codingame/monaco-vscode-language-pack-de": "~1.83.12",
"@codingame/monaco-vscode-language-pack-es": "~1.83.12",
"@codingame/monaco-vscode-language-pack-fr": "~1.83.12",
"express": "~4.18.2",
"langium": "~2.1.0",
"langium-statemachine-dsl": "~2.1.0",
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"monaco-editor-workers": "~0.44.0",
"monaco-languageclient": "~7.0.2",
"monaco-languageclient": "~7.1.0",
"pyright": "~1.1.333",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"request-light": "~0.7.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0",
"vscode-json-languageservice": "~5.3.7",
"vscode-languageclient": "~9.0.1",
"vscode-languageserver": "~9.0.1",
Expand All @@ -87,8 +87,8 @@
"vscode": "$vscode"
},
"resolutions": {
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.7 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.7 <1.84.0"
"monaco-editor": "npm:@codingame/monaco-editor-treemended@>=1.83.12 <1.84.0",
"vscode": "npm:@codingame/monaco-vscode-api@>=1.83.12 <1.84.0"
},
"volta": {
"node": "18.18.2",
Expand Down
15 changes: 13 additions & 2 deletions packages/examples/src/common/client-commons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,21 @@ export const performInit = async (vscodeApiInit: boolean) => {
userServices: {
...getThemeServiceOverride(),
...getTextmateServiceOverride(),
...getConfigurationServiceOverride(Uri.file('/workspace')),
...getConfigurationServiceOverride(),
...getKeybindingsServiceOverride()
},
debugLogging: true
debugLogging: true,
workspaceConfig: {
workspaceProvider: {
trusted: true,
workspace: {
workspaceUri: Uri.file('/workspace')
},
async open() {
return false;
}
}
}
});

// register the JSON language with Monaco
Expand Down
15 changes: 12 additions & 3 deletions packages/examples/src/langium/statemachineClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import getEditorServiceOverride from '@codingame/monaco-vscode-editor-service-ov
import getKeybindingsServiceOverride from '@codingame/monaco-vscode-keybindings-service-override';
import getThemeServiceOverride from '@codingame/monaco-vscode-theme-service-override';
import getTextmateServiceOverride from '@codingame/monaco-vscode-textmate-service-override';
import { LogLevel } from 'vscode/services';
import '@codingame/monaco-vscode-theme-defaults-default-extension';
import { Uri } from 'vscode';

Expand All @@ -28,12 +27,22 @@ export const setupStatemachineClient = async () => {
userServices: {
...getThemeServiceOverride(),
...getTextmateServiceOverride(),
...getConfigurationServiceOverride(Uri.file('/workspace')),
...getConfigurationServiceOverride(),
...getEditorServiceOverride(useOpenEditorStub),
...getKeybindingsServiceOverride()
},
debugLogging: true,
logLevel: LogLevel.Info
workspaceConfig: {
workspaceProvider: {
trusted: true,
workspace: {
workspaceUri: Uri.file('/workspace')
},
async open() {
return false;
}
}
}
};
await initServices(serviceConfig);

Expand Down
17 changes: 15 additions & 2 deletions packages/examples/src/python/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,24 @@ export const startPythonClient = async () => {
userServices: {
...getThemeServiceOverride(),
...getTextmateServiceOverride(),
...getConfigurationServiceOverride(Uri.file('/workspace')),
...getConfigurationServiceOverride(),
...getKeybindingsServiceOverride()
},
debugLogging: true,
logLevel: LogLevel.Debug
workspaceConfig: {
workspaceProvider: {
trusted: true,
workspace: {
workspaceUri: Uri.file('/workspace')
},
async open() {
return false;
}
},
developmentOptions: {
logLevel: LogLevel.Debug
}
}
});

console.log('Before ready themes');
Expand Down
Loading

0 comments on commit adc7b63

Please sign in to comment.