Skip to content

Commit

Permalink
Update to monaco-vscode-api 1.81.1
Browse files Browse the repository at this point in the history
- Remove normalize-url as it does not format ws urls
  • Loading branch information
kaisalmen committed Aug 17, 2023
1 parent fe2cd88 commit cf8f6ba
Show file tree
Hide file tree
Showing 17 changed files with 80 additions and 108 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ The following table describes which version of **monaco-languageclient** and **m

| monaco-languageclient | monaco-vscode-api | monaco-editor | comment |
| :---- | :---- | :--- | :--- |
| 6.4.1 | 1.81.1 | 0.41.0 | Released 2023-08-1x |
| 6.4.0 | 1.81.0 | 0.41.0 | Released 2023-08-10 |
| 6.3.0 | 1.80.2 | 0.40.0 | Released 2023-08-04 |
| 6.2.0 | 1.79.3 | 0.39.0 | Released 2023-06-16 |
Expand Down Expand Up @@ -252,7 +253,7 @@ loader.config({ monaco });
If you use pnpm, you have to add `vscode` / `monaco-vscode-api` as direct dependency (see the [following table](#monaco-editor--monaco-vscode-api-compatibility-table)), otherwise the installation will fail.

```json
"vscode": "npm:@codingame/monaco-vscode-api@~1.81.0"
"vscode": "npm:@codingame/monaco-vscode-api@~1.81.1"
```

## Licenses
Expand Down
32 changes: 9 additions & 23 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions packages/client/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

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

## [6.4.1] - 2023-08-17

- `monaco-vscode-api` `1.81.1` [#523](https://github.com/TypeFox/monaco-languageclient/pull/523)
- Removed `enableQuickaccessService` as it is always loaded now as default
- Aligned naming of properties in `InitializeServiceConfig`

## [6.4.0] - 2023-08-10

- Update to `monaco-editor` `0.41.0` and `monaco-vscode-api` `1.81.0` [#520](https://github.com/TypeFox/monaco-languageclient/pull/520)
Expand Down
6 changes: 3 additions & 3 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "monaco-languageclient",
"version": "6.4.0",
"version": "6.4.1-next.1",
"description": "Monaco Language client implementation",
"author": {
"name": "TypeFox GmbH",
Expand Down Expand Up @@ -49,13 +49,13 @@
],
"dependencies": {
"monaco-editor": "~0.41.0",
"vscode": "npm:@codingame/monaco-vscode-api@1.81.0",
"vscode": "npm:@codingame/monaco-vscode-api@1.81.1",
"vscode-jsonrpc": "~8.1.0",
"vscode-languageclient": "~8.1.0"
},
"peerDependencies": {
"monaco-editor": "~0.41.0",
"vscode": "npm:@codingame/monaco-vscode-api@1.81.0"
"vscode": "npm:@codingame/monaco-vscode-api@1.81.1"
},
"peerDependenciesMeta": {
"monaco-editor": {
Expand Down
66 changes: 29 additions & 37 deletions packages/client/src/monaco-vscode-api-services.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { ILogService, initialize as initializeMonacoService, LogLevel, Standalon
import { initialize as initializeVscodeExtensions } from 'vscode/extensions';
import type { OpenEditor } from 'vscode/service-override/editor';
import { ITerminalBackend, SimpleTerminalBackend } from 'vscode/service-override/terminal';
import { IStorageProvider } from 'vscode/service-override/storage';

interface MonacoEnvironmentEnhanced extends Environment {
vscodeApiInitialised: boolean;
Expand All @@ -20,11 +21,11 @@ export type InitializeServiceConfig = {
/**
* editor service is the default. If you want to use the views service, set enableViewsService to true.
*/
configureEditorOrViewsServiceConfig?: {
configureEditorOrViewsService?: {
enableViewsService?: boolean;
openEditorFunc?: OpenEditor
};
configureConfigurationServiceConfig?: {
configureConfigurationService?: {
defaultWorkspaceUri: string;
};
enableThemeService?: boolean;
Expand All @@ -35,15 +36,17 @@ export type InitializeServiceConfig = {
enableDebugService?: boolean;
enablePreferencesService?: boolean;
enableSnippetsService?: boolean;
enableQuickaccessService?: boolean;
enableOutputService?: boolean;
configureTerminalServiceConfig?: {
configureTerminalService?: {
backendImpl: SimpleTerminalBackend | ITerminalBackend
}
enableSearchService?: boolean;
enableMarkersService?: boolean;
enableAccessibilityService?: boolean;
enableLanguageDetectionWorkerService?: boolean;
configureStorateService?: {
provider: IStorageProvider
},
userServices?: editor.IEditorOverrideServices;
debugLogging?: boolean;
logLevel?: LogLevel
Expand Down Expand Up @@ -78,7 +81,12 @@ export type ModuleWithDefaultExport = {
}

/**
* files, extension, environment and layout services are loaded automatically by monaco-vscode-api
* monaco-vscode-api automatically loads the following services:
* - layout
* - environment
* - extension
* - files
* - quickAccess
*/
export const importAllServices = async (config?: InitializeServiceConfig) => {
const serviceNames: string[] = [];
Expand All @@ -94,14 +102,14 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
if (lc.enableModelService === true) {
addService('model', import('vscode/service-override/model'));
}
if (lc.configureEditorOrViewsServiceConfig !== undefined) {
if (lc.configureEditorOrViewsServiceConfig.enableViewsService === true) {
if (lc.configureEditorOrViewsService !== undefined) {
if (lc.configureEditorOrViewsService.enableViewsService === true) {
addService('views', import('vscode/service-override/views'));
} else {
addService('editor', import('vscode/service-override/editor'));
}
}
if (lc.configureConfigurationServiceConfig !== undefined) {
if (lc.configureConfigurationService !== undefined) {
addService('configuration', import('vscode/service-override/configuration'));
}
if (lc.enableDialogService === true) {
Expand Down Expand Up @@ -134,13 +142,10 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
if (lc.enableSnippetsService === true) {
addService('snippets', import('vscode/service-override/snippets'));
}
if (lc.enableQuickaccessService === true) {
addService('quickaccess', import('vscode/service-override/quickaccess'));
}
if (lc.enableOutputService === true) {
addService('output', import('vscode/service-override/output'));
}
if (lc.configureTerminalServiceConfig !== undefined) {
if (lc.configureTerminalService !== undefined) {
addService('terminal', import('vscode/service-override/terminal'));
}
if (lc.enableSearchService === true) {
Expand All @@ -155,6 +160,9 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
if (lc.enableLanguageDetectionWorkerService === true) {
addService('languageDetectionWorker', import('vscode/service-override/languageDetectionWorker'));
}
if (lc.enableLanguageDetectionWorkerService === true) {
addService('languageDetectionWorker', import('vscode/service-override/languageDetectionWorker'));
}

const reportServiceLoading = (services: editor.IEditorOverrideServices, debugLogging: boolean, origin?: string) => {
for (const serviceName of Object.keys(services)) {
Expand Down Expand Up @@ -184,8 +192,6 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {

const haveThemeService = serviceNames.includes('theme') || Object.keys(overrideServices).includes('themeService');
const haveTextmateService = serviceNames.includes('textmate') || Object.keys(overrideServices).includes('textMateTokenizationFeature');
const haveQuickaccessService = serviceNames.includes('quickaccess') || Object.keys(overrideServices).includes('quickInputService');
const haveKeybindingsService = serviceNames.includes('keybindings') || Object.keys(overrideServices).includes('keybindingService');
const haveMarkersService = serviceNames.includes('markers');
const haveViewsService = serviceNames.includes('views') || Object.keys(overrideServices).includes('viewsService');

Expand All @@ -194,11 +200,6 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
throw new Error('"theme" requires "textmate" service. Please add it to the "initServices" config.');
}

// quickaccess requires keybindings
if (haveQuickaccessService && !haveKeybindingsService) {
throw new Error('"quickaccess" requires "keybindings" service. Please add it to the "initServices" config.');
}

// markers service requires views service
if (haveMarkersService && !haveViewsService) {
throw new Error('"markers" requires "views" service. Please add it to the "initServices" config.');
Expand All @@ -212,8 +213,8 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {

let services: editor.IEditorOverrideServices = {};
if (serviceName === 'editor' || serviceName === 'views') {
if (lc.configureEditorOrViewsServiceConfig?.openEditorFunc) {
services = loadedImport.default(lc.configureEditorOrViewsServiceConfig.openEditorFunc);
if (lc.configureEditorOrViewsService?.openEditorFunc) {
services = loadedImport.default(lc.configureEditorOrViewsService.openEditorFunc);
} else {
const defaultOpenEditorFunc: OpenEditor = async (model, options, sideBySide) => {
console.log('Trying to open a model', model, options, sideBySide);
Expand All @@ -222,26 +223,17 @@ export const importAllServices = async (config?: InitializeServiceConfig) => {
services = loadedImport.default(defaultOpenEditorFunc);
}
} else if (serviceName === 'configuration') {
if (lc.configureConfigurationServiceConfig?.defaultWorkspaceUri) {
const uri = Uri.file(lc.configureConfigurationServiceConfig!.defaultWorkspaceUri);
if (lc.configureConfigurationService?.defaultWorkspaceUri) {
const uri = Uri.file(lc.configureConfigurationService!.defaultWorkspaceUri);
services = loadedImport.default(uri);
}
} else if (serviceName === 'terminal') {
if (lc.configureTerminalServiceConfig?.backendImpl) {
services = loadedImport.default(lc.configureTerminalServiceConfig.backendImpl);
if (lc.configureTerminalService?.backendImpl) {
services = loadedImport.default(lc.configureTerminalService.backendImpl);
}
} else if (serviceName === 'quickaccess') {
if (lc.configureEditorOrViewsServiceConfig?.enableViewsService === true) {
const {
isEditorPartVisible
} = await import('vscode/service-override/views');
services = loadedImport.default({
isKeybindingConfigurationVisible: isEditorPartVisible,
shouldUseGlobalPicker: isEditorPartVisible
});
services = loadedImport.default();
} else {
services = loadedImport.default();
} else if (serviceName === 'storage') {
if (lc.configureStorateService?.provider) {
services = loadedImport.default(lc.configureStorateService.provider);
}
} else {
services = loadedImport.default();
Expand Down
3 changes: 1 addition & 2 deletions packages/examples/main/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,7 @@
"langium": "~1.2.1",
"langium-statemachine-dsl": "~1.2.0",
"monaco-editor-workers": "~0.41.0",
"monaco-languageclient": "~6.4.0",
"normalize-url": "~8.0.0",
"monaco-languageclient": "6.4.1-next.1",
"react": "~18.2.0",
"react-dom": "~18.2.0",
"request-light": "~0.7.0",
Expand Down
5 changes: 2 additions & 3 deletions packages/examples/main/src/client/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocket, performInit } from '../common.js';
import { createDefaultJsonContent, createJsonEditor, createUrl, createWebSocketAndStartClient, performInit } from '../common.js';
import { buildWorkerDefinition } from 'monaco-editor-workers';
buildWorkerDefinition('../../../node_modules/monaco-editor-workers/dist/workers/', new URL('', window.location.href).href, false);

Expand All @@ -15,9 +15,8 @@ const start = async () => {
content: createDefaultJsonContent()
});

// create the web socket
const url = createUrl('localhost', 3000, '/sampleServer');
createWebSocket(url);
createWebSocketAndStartClient(url);
};

start();
18 changes: 7 additions & 11 deletions packages/examples/main/src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,11 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */

import 'monaco-editor/esm/vs/editor/editor.all.js';
import 'monaco-editor/esm/vs/editor/standalone/browser/iPadShowKeyboard/iPadShowKeyboard.js';
import { editor, languages, Uri } from 'monaco-editor/esm/vs/editor/editor.api.js';
import { editor, languages, Uri } from 'monaco-editor';
import { createConfiguredEditor, createModelReference, IReference, ITextFileEditorModel } from 'vscode/monaco';
import 'vscode/default-extensions/theme-defaults';
import 'vscode/default-extensions/json';
import { initServices, MonacoLanguageClient } from 'monaco-languageclient';
import normalizeUrl from 'normalize-url';
import { CloseAction, ErrorAction, MessageTransports } from 'vscode-languageclient';
import { WebSocketMessageReader, WebSocketMessageWriter, toSocket } from 'vscode-ws-jsonrpc';

Expand All @@ -37,10 +34,10 @@ export const createLanguageClient = (transports: MessageTransports): MonacoLangu

export const createUrl = (hostname: string, port: number, path: string): string => {
const protocol = location.protocol === 'https:' ? 'wss' : 'ws';
return normalizeUrl(`${protocol}://${hostname}:${port}${path}`);
return `${protocol}://${hostname}:${port}${path}`;
};

export const createWebSocket = (url: string): WebSocket => {
export const createWebSocketAndStartClient = (url: string): WebSocket => {
const webSocket = new WebSocket(url);
webSocket.onopen = () => {
const socket = toSocket(webSocket);
Expand All @@ -58,9 +55,9 @@ export const createWebSocket = (url: string): WebSocket => {

export const createDefaultJsonContent = (): string => {
return `{
"$schema": "http://json.schemastore.org/coffeelint",
"line_endings": "unix"
}`;
"$schema": "http://json.schemastore.org/coffeelint",
"line_endings": "unix"
} `;
};

export type ExampleJsonEditor = {
Expand All @@ -76,11 +73,10 @@ export const performInit = async (vscodeApiInit: boolean) => {
enableThemeService: true,
enableTextmateService: true,
enableModelService: true,
configureEditorOrViewsServiceConfig: {
configureEditorOrViewsService: {
},
enableKeybindingsService: true,
enableLanguagesService: true,
enableQuickaccessService: true,
enableOutputService: true,
enableAccessibilityService: true,
debugLogging: false
Expand Down
Loading

0 comments on commit cf8f6ba

Please sign in to comment.