monaco-languageclient 8.8.3 → 9.0.0-next.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.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
2
2
 
3
3
  All notable changes to this npm module are documented in this file.
4
4
 
5
+ ## [9.0.0-next.2] - 2024-10-10
6
+
7
+ - Support all arguments for monaco-vscode-api `initialize` [#756](https://github.com/TypeFox/monaco-languageclient/pull/756)
8
+ - Update to monaco-vscode-api 9.0.x [#749](https://github.com/TypeFox/monaco-languageclient/pull/749)
9
+ - Updated all `@codingame/monaco-vscode` packages to `10.0.1`.
10
+ - Enhancements to logging
11
+ - monaco-languageclient config improvement, wrapper+languageclientwrapper improvements [#741](https://github.com/TypeFox/monaco-languageclient/pull/741)
12
+ - Pass MessageTransports directly
13
+ - Allows to configure more than one language client
14
+
5
15
  ## [8.8.3] - 2024-08-26
6
16
 
7
17
  - Update to monaco-vscode-api 8.0.4 (monaco-editor 0.51.0)
@@ -0,0 +1,13 @@
1
+ import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/browser.js';
2
+ export type MonacoLanguageClientOptions = {
3
+ name: string;
4
+ id?: string;
5
+ clientOptions: LanguageClientOptions;
6
+ messageTransports: MessageTransports;
7
+ };
8
+ export declare class MonacoLanguageClient extends BaseLanguageClient {
9
+ protected readonly messageTransports: MessageTransports;
10
+ constructor({ id, name, clientOptions, messageTransports }: MonacoLanguageClientOptions);
11
+ protected createMessageTransports(_encoding: string): Promise<MessageTransports>;
12
+ }
13
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,kCAAkC,CAAC;AAEhH,MAAM,MAAM,2BAA2B,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,qBAAqB,CAAC;IACrC,iBAAiB,EAAE,iBAAiB,CAAC;CACxC,CAAA;AAED,qBAAa,oBAAqB,SAAQ,kBAAkB;IACxD,SAAS,CAAC,QAAQ,CAAC,iBAAiB,EAAE,iBAAiB,CAAC;gBAE5C,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAAE,EAAE,2BAA2B;cAKpE,uBAAuB,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG5F"}
package/lib/client.js ADDED
@@ -0,0 +1,16 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ import { BaseLanguageClient } from 'vscode-languageclient/browser.js';
6
+ export class MonacoLanguageClient extends BaseLanguageClient {
7
+ messageTransports;
8
+ constructor({ id, name, clientOptions, messageTransports }) {
9
+ super(id ?? name.toLowerCase(), name, clientOptions);
10
+ this.messageTransports = messageTransports;
11
+ }
12
+ createMessageTransports(_encoding) {
13
+ return Promise.resolve(this.messageTransports);
14
+ }
15
+ }
16
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAA4C,MAAM,kCAAkC,CAAC;AAShH,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IACrC,iBAAiB,CAAoB;IAExD,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,iBAAiB,EAA+B;QACnF,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,iBAAiB,GAAG,iBAAiB,CAAC;IAC/C,CAAC;IAEkB,uBAAuB,CAAC,SAAiB;QACxD,OAAO,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAC;IACnD,CAAC;CACJ"}
@@ -0,0 +1,47 @@
1
+ import { MonacoLanguageClient } from './client.js';
2
+ export type ConnetionConfigOptions = WebSocketConfigOptionsDirect | WebSocketConfigOptionsParams | WebSocketConfigOptionsUrl | WorkerConfigOptionsParams | WorkerConfigOptionsDirect;
3
+ export interface WebSocketCallOptions {
4
+ /** Adds handle on languageClient */
5
+ onCall: (languageClient?: MonacoLanguageClient) => void;
6
+ /** Reports Status Of Language Client */
7
+ reportStatus?: boolean;
8
+ }
9
+ export interface WebSocketConfigOptionsDirect {
10
+ $type: 'WebSocketDirect';
11
+ webSocket: WebSocket;
12
+ startOptions?: WebSocketCallOptions;
13
+ stopOptions?: WebSocketCallOptions;
14
+ }
15
+ export interface WebSocketUrlParams {
16
+ secured: boolean;
17
+ host: string;
18
+ port?: number;
19
+ path?: string;
20
+ extraParams?: Record<string, string | number | Array<string | number>>;
21
+ }
22
+ export interface WebSocketConfigOptionsParams extends WebSocketUrlParams {
23
+ $type: 'WebSocketParams';
24
+ startOptions?: WebSocketCallOptions;
25
+ stopOptions?: WebSocketCallOptions;
26
+ }
27
+ export interface WebSocketUrlString {
28
+ url: string;
29
+ }
30
+ export interface WebSocketConfigOptionsUrl extends WebSocketUrlString {
31
+ $type: 'WebSocketUrl';
32
+ startOptions?: WebSocketCallOptions;
33
+ stopOptions?: WebSocketCallOptions;
34
+ }
35
+ export interface WorkerConfigOptionsParams {
36
+ $type: 'WorkerConfig';
37
+ url: URL;
38
+ type: 'classic' | 'module';
39
+ messagePort?: MessagePort;
40
+ workerName?: string;
41
+ }
42
+ export interface WorkerConfigOptionsDirect {
43
+ $type: 'WorkerDirect';
44
+ worker: Worker;
45
+ messagePort?: MessagePort;
46
+ }
47
+ //# sourceMappingURL=commonTypes.d.ts.map
@@ -0,0 +1 @@
1
+ {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W,yBAAyB;IACtC,KAAK,EAAE,cAAc,CAAA;IACrB,GAAG,EAAE,GAAG,CAAC;IACT,IAAI,EAAE,SAAS,GAAG,QAAQ,CAAC;IAC3B,WAAW,CAAC,EAAE,WAAW,CAAC;IAC1B,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,yBAAyB;IACtC,KAAK,EAAE,cAAc,CAAC;IACtB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,WAAW,CAAC;CAC7B"}
@@ -0,0 +1,6 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ export {};
6
+ //# sourceMappingURL=commonTypes.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"commonTypes.js","sourceRoot":"","sources":["../src/commonTypes.ts"],"names":[],"mappings":"AAAA;;;gGAGgG"}
package/lib/index.d.ts CHANGED
@@ -1,16 +1,3 @@
1
- import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/lib/common/client.js';
2
- export interface IConnectionProvider {
3
- get(encoding: string): Promise<MessageTransports>;
4
- }
5
- export type MonacoLanguageClientOptions = {
6
- name: string;
7
- id?: string;
8
- clientOptions: LanguageClientOptions;
9
- connectionProvider: IConnectionProvider;
10
- };
11
- export declare class MonacoLanguageClient extends BaseLanguageClient {
12
- protected readonly connectionProvider: IConnectionProvider;
13
- constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClientOptions);
14
- protected createMessageTransports(encoding: string): Promise<MessageTransports>;
15
- }
1
+ export * from './client.js';
2
+ export * from './commonTypes.js';
16
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,qBAAqB,EAAE,MAAM,4CAA4C,CAAC;AAE1H,MAAM,WAAW,mBAAmB;IAChC,GAAG,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrD;AAED,MAAM,MAAM,2BAA2B,GAAG;IACtC,IAAI,EAAE,MAAM,CAAC;IACb,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,aAAa,EAAE,qBAAqB,CAAC;IACrC,kBAAkB,EAAE,mBAAmB,CAAC;CAC3C,CAAA;AAED,qBAAa,oBAAqB,SAAQ,kBAAkB;IACxD,SAAS,CAAC,QAAQ,CAAC,kBAAkB,EAAE,mBAAmB,CAAC;gBAE/C,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAAE,EAAE,2BAA2B;cAKrE,uBAAuB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG3F"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAKA,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
package/lib/index.js CHANGED
@@ -2,15 +2,6 @@
2
2
  * Copyright (c) 2024 TypeFox and others.
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
- import { BaseLanguageClient } from 'vscode-languageclient/lib/common/client.js';
6
- export class MonacoLanguageClient extends BaseLanguageClient {
7
- connectionProvider;
8
- constructor({ id, name, clientOptions, connectionProvider }) {
9
- super(id ?? name.toLowerCase(), name, clientOptions);
10
- this.connectionProvider = connectionProvider;
11
- }
12
- createMessageTransports(encoding) {
13
- return this.connectionProvider.get(encoding);
14
- }
15
- }
5
+ export * from './client.js';
6
+ export * from './commonTypes.js';
16
7
  //# sourceMappingURL=index.js.map
package/lib/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,kBAAkB,EAA4C,MAAM,4CAA4C,CAAC;AAa1H,MAAM,OAAO,oBAAqB,SAAQ,kBAAkB;IACrC,kBAAkB,CAAsB;IAE3D,YAAY,EAAE,EAAE,EAAE,IAAI,EAAE,aAAa,EAAE,kBAAkB,EAA+B;QACpF,KAAK,CAAC,EAAE,IAAI,IAAI,CAAC,WAAW,EAAE,EAAE,IAAI,EAAE,aAAa,CAAC,CAAC;QACrD,IAAI,CAAC,kBAAkB,GAAG,kBAAkB,CAAC;IACjD,CAAC;IAEkB,uBAAuB,CAAC,QAAgB;QACvD,OAAO,IAAI,CAAC,kBAAkB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,aAAa,CAAC;AAC5B,cAAc,kBAAkB,CAAC"}
@@ -1,15 +1,2 @@
1
- export type LoggerConfig = {
2
- enabled: boolean;
3
- debugEnabled?: boolean;
4
- };
5
- export declare class Logger {
6
- private enabled;
7
- private debugEnabled;
8
- constructor(config?: LoggerConfig);
9
- updateConfig(config?: LoggerConfig): void;
10
- isEnabled(): boolean;
11
- isDebugEnabled(): boolean;
12
- info(message: string): void;
13
- debug(message: string, force?: boolean): void;
14
- }
1
+ export * from './logging.js';
15
2
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,YAAY,GAAG;IACvB,OAAO,EAAE,OAAO,CAAC;IACjB,YAAY,CAAC,EAAE,OAAO,CAAA;CACzB,CAAC;AAEF,qBAAa,MAAM;IAEf,OAAO,CAAC,OAAO,CAAU;IACzB,OAAO,CAAC,YAAY,CAAU;gBAElB,MAAM,CAAC,EAAE,YAAY;IAIjC,YAAY,CAAC,MAAM,CAAC,EAAE,YAAY;IAKlC,SAAS;IAIT,cAAc;IAId,IAAI,CAAC,OAAO,EAAE,MAAM;IAMpB,KAAK,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,CAAC,EAAE,OAAO;CAKzC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAKA,cAAc,cAAc,CAAC"}
@@ -2,31 +2,5 @@
2
2
  * Copyright (c) 2024 TypeFox and others.
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
- export class Logger {
6
- enabled;
7
- debugEnabled;
8
- constructor(config) {
9
- this.updateConfig(config);
10
- }
11
- updateConfig(config) {
12
- this.enabled = !config ? true : config.enabled === true;
13
- this.debugEnabled = this.enabled && config?.debugEnabled === true;
14
- }
15
- isEnabled() {
16
- return this.enabled;
17
- }
18
- isDebugEnabled() {
19
- return this.debugEnabled;
20
- }
21
- info(message) {
22
- if (this.enabled) {
23
- console.log(message);
24
- }
25
- }
26
- debug(message, force) {
27
- if (this.enabled && (this.debugEnabled || force === true)) {
28
- console.debug(message);
29
- }
30
- }
31
- }
5
+ export * from './logging.js';
32
6
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAOhG,MAAM,OAAO,MAAM;IAEP,OAAO,CAAU;IACjB,YAAY,CAAU;IAE9B,YAAY,MAAqB;QAC7B,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9B,CAAC;IAED,YAAY,CAAC,MAAqB;QAC9B,IAAI,CAAC,OAAO,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,MAAO,CAAC,OAAO,KAAK,IAAI,CAAC;QACzD,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,OAAO,IAAI,MAAM,EAAE,YAAY,KAAK,IAAI,CAAC;IACtE,CAAC;IAED,SAAS;QACL,OAAO,IAAI,CAAC,OAAO,CAAC;IACxB,CAAC;IAED,cAAc;QACV,OAAO,IAAI,CAAC,YAAY,CAAC;IAC7B,CAAC;IAED,IAAI,CAAC,OAAe;QAChB,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACf,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;QACzB,CAAC;IACL,CAAC;IAED,KAAK,CAAC,OAAe,EAAE,KAAe;QAClC,IAAI,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,YAAY,IAAI,KAAK,KAAK,IAAI,CAAC,EAAE,CAAC;YACxD,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;QAC3B,CAAC;IACL,CAAC;CACJ"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/tools/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,cAAc,CAAC"}
@@ -0,0 +1,10 @@
1
+ import { ConsoleLogger as VSCodeConsoleLogger, ILogger } from '@codingame/monaco-vscode-log-service-override';
2
+ import { LogLevel } from 'vscode/services';
3
+ export interface Logger extends ILogger {
4
+ createErrorAndLog(message: string, ...params: unknown[]): Error;
5
+ }
6
+ export declare class ConsoleLogger extends VSCodeConsoleLogger {
7
+ constructor(logLevel?: LogLevel, useColors?: boolean);
8
+ createErrorAndLog(message: string, ...params: unknown[]): Error;
9
+ }
10
+ //# sourceMappingURL=logging.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.d.ts","sourceRoot":"","sources":["../../src/tools/logging.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAE,OAAO,EAAE,MAAM,+CAA+C,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,WAAW,MAAO,SAAQ,OAAO;IACnC,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE,GAAG,KAAK,CAAC;CACnE;AAED,qBAAa,aAAc,SAAQ,mBAAmB;gBAEtC,QAAQ,CAAC,EAAE,QAAQ,EAAE,SAAS,CAAC,EAAE,OAAO;IAIpD,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,OAAO,EAAE;CAO1D"}
@@ -0,0 +1,18 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ import { ConsoleLogger as VSCodeConsoleLogger } from '@codingame/monaco-vscode-log-service-override';
6
+ import { LogLevel } from 'vscode/services';
7
+ export class ConsoleLogger extends VSCodeConsoleLogger {
8
+ constructor(logLevel, useColors) {
9
+ super(logLevel ?? LogLevel.Off, useColors);
10
+ }
11
+ createErrorAndLog(message, ...params) {
12
+ if (this.getLevel() >= LogLevel.Error) {
13
+ this.error(message, ...params);
14
+ }
15
+ return new Error(message);
16
+ }
17
+ }
18
+ //# sourceMappingURL=logging.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"logging.js","sourceRoot":"","sources":["../../src/tools/logging.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,aAAa,IAAI,mBAAmB,EAAW,MAAM,+CAA+C,CAAC;AAC9G,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAM3C,MAAM,OAAO,aAAc,SAAQ,mBAAmB;IAElD,YAAY,QAAmB,EAAE,SAAmB;QAChD,KAAK,CAAC,QAAQ,IAAI,QAAQ,CAAC,GAAG,EAAE,SAAS,CAAC,CAAC;IAC/C,CAAC;IAED,iBAAiB,CAAC,OAAe,EAAE,GAAG,MAAiB;QACnD,IAAI,IAAI,CAAC,QAAQ,EAAE,IAAI,QAAQ,CAAC,KAAK,EAAE,CAAC;YACpC,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE,GAAG,MAAM,CAAC,CAAC;QACnC,CAAC;QACD,OAAO,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC;CAEJ"}
@@ -0,0 +1,3 @@
1
+ export * from './fakeWorker.js';
2
+ export * from './services.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/vscode/index.ts"],"names":[],"mappings":"AAKA,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -0,0 +1,7 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+ export * from './fakeWorker.js';
6
+ export * from './services.js';
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/vscode/index.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC"}
@@ -1,31 +1,43 @@
1
1
  import * as monaco from 'monaco-editor';
2
2
  import 'vscode/localExtensionHost';
3
3
  import { IWorkbenchConstructionOptions } from 'vscode/services';
4
+ import { OpenEditor } from '@codingame/monaco-vscode-editor-service-override';
4
5
  import type { LocalizationOptions } from '@codingame/monaco-vscode-localization-service-override';
5
- import { Logger } from '../tools/index.js';
6
+ import { EnvironmentOverride } from 'vscode/workbench';
7
+ import { Logger } from 'monaco-languageclient/tools';
6
8
  export interface MonacoEnvironmentEnhanced extends monaco.Environment {
7
9
  vscodeInitialising?: boolean;
8
10
  vscodeApiInitialised?: boolean;
9
11
  }
10
- export type InitializeServiceConfig = {
12
+ export interface UserConfiguration {
13
+ json?: string;
14
+ }
15
+ export interface VscodeApiConfig {
11
16
  userServices?: monaco.editor.IEditorOverrideServices;
12
17
  enableExtHostWorker?: boolean;
13
- debugLogging?: boolean;
14
18
  workspaceConfig?: IWorkbenchConstructionOptions;
15
- };
19
+ userConfiguration?: UserConfiguration;
20
+ viewsConfig?: {
21
+ viewServiceType: 'EditorService' | 'ViewsService' | 'WorkspaceService';
22
+ openEditorFunc?: OpenEditor;
23
+ viewsInitFunc?: () => void;
24
+ };
25
+ envOptions?: EnvironmentOverride;
26
+ }
27
+ export interface InitVscodeApiInstructions extends VscodeApiConfig {
28
+ htmlContainer: HTMLElement;
29
+ caller?: string;
30
+ performChecks?: () => boolean;
31
+ logger?: Logger;
32
+ }
16
33
  export declare const initEnhancedMonacoEnvironment: () => MonacoEnvironmentEnhanced;
34
+ export declare const getMonacoEnvironmentEnhanced: () => MonacoEnvironmentEnhanced;
17
35
  export declare const supplyRequiredServices: () => Promise<{
18
36
  [x: string]: any;
19
37
  }>;
20
38
  export declare const reportServiceLoading: (services: monaco.editor.IEditorOverrideServices, logger?: Logger) => void;
21
39
  export declare const mergeServices: (services: monaco.editor.IEditorOverrideServices, overrideServices: monaco.editor.IEditorOverrideServices) => void;
22
- export type InitServicesInstruction = {
23
- serviceConfig?: InitializeServiceConfig;
24
- caller?: string;
25
- performChecks?: () => boolean;
26
- logger?: Logger;
27
- };
28
- export declare const initServices: (instruction: InitServicesInstruction) => Promise<void>;
40
+ export declare const initServices: (instructions: InitVscodeApiInstructions) => Promise<void>;
29
41
  /**
30
42
  * monaco-vscode-api automatically loads the following services:
31
43
  * - layout
@@ -37,7 +49,7 @@ export declare const initServices: (instruction: InitServicesInstruction) => Pro
37
49
  * - languages
38
50
  * - model
39
51
  */
40
- export declare const importAllServices: (instruction: InitServicesInstruction) => Promise<void>;
52
+ export declare const importAllServices: (instructions: InitVscodeApiInstructions) => Promise<void>;
41
53
  /**
42
54
  * Enable ext host to run in a worker
43
55
  */
@@ -1 +1 @@
1
- {"version":3,"file":"services.d.ts","sourceRoot":"","sources":["../../src/vscode/services.ts"],"names":[],"mappings":"AAKA,OAAO,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C;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,aAAa,CAAC,EAAE,MAAM,OAAO,CAAC;IAC9B,MAAM,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,eAAO,MAAM,6BAA6B,iCAczC,CAAC;AAEF,eAAO,MAAM,4BAA4B,QAEF,yBACtC,CAAC;AAEF,eAAO,MAAM,sBAAsB;;EAMlC,CAAC;AAEF,eAAO,MAAM,oBAAoB,aAAc,MAAM,CAAC,MAAM,CAAC,uBAAuB,WAAW,MAAM,SAIpG,CAAC;AAEF,eAAO,MAAM,aAAa,aAAc,MAAM,CAAC,MAAM,CAAC,uBAAuB,oBAAoB,MAAM,CAAC,MAAM,CAAC,uBAAuB,SAIrI,CAAC;AAEF,eAAO,MAAM,YAAY,iBAAwB,yBAAyB,kBAiBzE,CAAC;AAEF;;;;;;;;;;GAUG;AACH,eAAO,MAAM,iBAAiB,iBAAwB,yBAAyB,kBAiB9E,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,sBAAsB,wBAA+B,OAAO,gBAAgB,MAAM,CAAC,MAAM,CAAC,uBAAuB,kBAa7H,CAAC;AAEF,eAAO,MAAM,gCAAgC,QAAO,mBA8DnD,CAAC"}
@@ -3,12 +3,12 @@
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
5
  import 'vscode/localExtensionHost';
6
- import { ILogService, initialize, LogLevel, StandaloneServices } from 'vscode/services';
6
+ import { initialize } from 'vscode/services';
7
7
  import getExtensionServiceOverride from '@codingame/monaco-vscode-extensions-service-override';
8
8
  import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
9
9
  import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
10
+ import getLogServiceOverride from '@codingame/monaco-vscode-log-service-override';
10
11
  import { FakeWorker as Worker } from './fakeWorker.js';
11
- import { Logger } from '../tools/index.js';
12
12
  export const initEnhancedMonacoEnvironment = () => {
13
13
  const monWin = self;
14
14
  if (!monWin.MonacoEnvironment) {
@@ -23,9 +23,14 @@ export const initEnhancedMonacoEnvironment = () => {
23
23
  }
24
24
  return envEnhanced;
25
25
  };
26
+ export const getMonacoEnvironmentEnhanced = () => {
27
+ const monWin = self;
28
+ return monWin.MonacoEnvironment;
29
+ };
26
30
  export const supplyRequiredServices = async () => {
27
31
  return {
28
32
  ...getLanguagesServiceOverride(),
33
+ ...getLogServiceOverride(),
29
34
  ...getModelServiceOverride()
30
35
  };
31
36
  };
@@ -39,24 +44,18 @@ export const mergeServices = (services, overrideServices) => {
39
44
  overrideServices[name] = service;
40
45
  }
41
46
  };
42
- export const initServices = async (instruction) => {
47
+ export const initServices = async (instructions) => {
43
48
  const envEnhanced = initEnhancedMonacoEnvironment();
44
- // in case debugLogging is set and for whatever reason no logger is passed a proper one is created
45
- if (instruction.serviceConfig?.debugLogging === true && !instruction.logger) {
46
- instruction.logger = new Logger({
47
- enabled: true,
48
- debugEnabled: true
49
- });
50
- }
51
49
  if (!(envEnhanced.vscodeInitialising ?? false)) {
52
50
  if (envEnhanced.vscodeApiInitialised ?? false) {
53
- instruction.logger?.debug('Initialization of vscode services can only performed once!');
51
+ instructions.logger?.debug('Initialization of vscode services can only performed once!');
54
52
  }
55
53
  else {
56
54
  envEnhanced.vscodeInitialising = true;
57
- instruction.logger?.debug(`Initializing vscode services. Caller: ${instruction.caller ?? 'unknown'}`);
58
- await importAllServices(instruction);
59
- instruction.logger?.debug('Initialization of vscode services completed successfully.');
55
+ instructions.logger?.debug(`Initializing vscode services. Caller: ${instructions.caller ?? 'unknown'}`);
56
+ await importAllServices(instructions);
57
+ instructions.viewsConfig?.viewsInitFunc?.();
58
+ instructions.logger?.debug('Initialization of vscode services completed successfully.');
60
59
  envEnhanced.vscodeApiInitialised = true;
61
60
  }
62
61
  }
@@ -72,17 +71,19 @@ export const initServices = async (instruction) => {
72
71
  * - languages
73
72
  * - model
74
73
  */
75
- export const importAllServices = async (instruction) => {
76
- const lc = instruction.serviceConfig ?? {};
77
- const userServices = lc.userServices ?? {};
74
+ export const importAllServices = async (instructions) => {
75
+ const userServices = instructions.userServices ?? {};
78
76
  const lcRequiredServices = await supplyRequiredServices();
79
77
  mergeServices(lcRequiredServices, userServices);
80
- await configureExtHostWorker(instruction.serviceConfig?.enableExtHostWorker === true, userServices);
81
- reportServiceLoading(userServices, instruction.logger);
82
- if (instruction.performChecks === undefined || instruction.performChecks()) {
83
- await initialize(userServices, undefined, lc.workspaceConfig);
84
- const logLevel = lc.workspaceConfig?.developmentOptions?.logLevel ?? LogLevel.Info;
85
- StandaloneServices.get(ILogService).setLevel(logLevel);
78
+ await configureExtHostWorker(instructions.enableExtHostWorker === true, userServices);
79
+ reportServiceLoading(userServices, instructions.logger);
80
+ if (instructions.performChecks === undefined || (typeof instructions.performChecks === 'function' && instructions.performChecks())) {
81
+ if (instructions.viewsConfig?.viewServiceType === 'ViewsService' || instructions.viewsConfig?.viewServiceType === 'WorkspaceService') {
82
+ await initialize(userServices, instructions.htmlContainer, instructions.workspaceConfig, instructions.envOptions);
83
+ }
84
+ else {
85
+ await initialize(userServices, undefined, instructions.workspaceConfig, instructions.envOptions);
86
+ }
86
87
  }
87
88
  };
88
89
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"services.js","sourceRoot":"","sources":["../../src/vscode/services.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAGhG,OAAO,2BAA2B,CAAC;AACnC,OAAO,EAAE,WAAW,EAAE,UAAU,EAAiC,QAAQ,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAEvH,OAAO,2BAA2B,MAAM,sDAAsD,CAAC;AAC/F,OAAO,2BAA2B,MAAM,qDAAqD,CAAC;AAC9F,OAAO,uBAAuB,MAAM,iDAAiD,CAAC;AAEtF,OAAO,EAAE,UAAU,IAAI,MAAM,EAAE,MAAM,iBAAiB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,MAAM,mBAAmB,CAAC;AAc3C,MAAM,CAAC,MAAM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QACD,kBAAkB,EAAE,CAAC;gBACjB,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,OAAO;aACxB,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,QAAQ;aACzB,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,QAAQ;aACzB,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,UAAU;aAC3B,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,QAAQ;aACzB,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,QAAQ;aACzB,EAAE;gBACC,MAAM,EAAE,OAAO;gBACf,YAAY,EAAE,qBAAqB;aACtC,EAAE;gBACC,MAAM,EAAE,UAAU;gBAClB,YAAY,EAAE,iBAAiB;aAClC,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,EAAE;gBACC,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,sBAAsB;aACvC,EAAE;gBACC,MAAM,EAAE,SAAS;gBACjB,YAAY,EAAE,uBAAuB;aACxC,EAAE;gBACC,MAAM,EAAE,IAAI;gBACZ,YAAY,EAAE,SAAS;aAC1B,CAAC;KACL,CAAC;AACN,CAAC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "monaco-languageclient",
3
- "version": "8.8.3",
3
+ "version": "9.0.0-next.2",
4
4
  "description": "Monaco Language client implementation",
5
5
  "author": {
6
6
  "name": "TypeFox GmbH",
@@ -29,8 +29,8 @@
29
29
  "default": "./lib/tools/index.js"
30
30
  },
31
31
  "./vscode/services": {
32
- "types": "./lib/vscode/services.d.ts",
33
- "default": "./lib/vscode/services.js"
32
+ "types": "./lib/vscode/index.d.ts",
33
+ "default": "./lib/vscode/index.js"
34
34
  }
35
35
  },
36
36
  "typesVersions": {
@@ -42,7 +42,7 @@
42
42
  "lib/tools/index"
43
43
  ],
44
44
  "vscode/services": [
45
- "lib/vscode/services"
45
+ "lib/vscode/index"
46
46
  ]
47
47
  }
48
48
  },
@@ -51,8 +51,8 @@
51
51
  "npm": ">=9.0.0"
52
52
  },
53
53
  "volta": {
54
- "node": "20.16.0",
55
- "npm": "10.8.1"
54
+ "node": "20.18.0",
55
+ "npm": "10.8.3"
56
56
  },
57
57
  "files": [
58
58
  "lib",
@@ -62,17 +62,18 @@
62
62
  "LICENSE"
63
63
  ],
64
64
  "dependencies": {
65
- "@codingame/monaco-vscode-extensions-service-override": "~8.0.4",
66
- "@codingame/monaco-vscode-languages-service-override": "~8.0.4",
67
- "@codingame/monaco-vscode-localization-service-override": "~8.0.4",
68
- "@codingame/monaco-vscode-model-service-override": "~8.0.4",
69
- "monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~8.0.4",
70
- "vscode": "npm:@codingame/monaco-vscode-api@~8.0.4",
65
+ "@codingame/monaco-vscode-extensions-service-override": "~10.0.1",
66
+ "@codingame/monaco-vscode-languages-service-override": "~10.0.1",
67
+ "@codingame/monaco-vscode-localization-service-override": "~10.0.1",
68
+ "@codingame/monaco-vscode-log-service-override": "~10.0.1",
69
+ "@codingame/monaco-vscode-model-service-override": "~10.0.1",
70
+ "monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~10.0.1",
71
+ "vscode": "npm:@codingame/monaco-vscode-api@~10.0.1",
71
72
  "vscode-languageclient": "~9.0.1"
72
73
  },
73
74
  "peerDependencies": {
74
- "monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~8.0.4",
75
- "vscode": "npm:@codingame/monaco-vscode-api@~8.0.4"
75
+ "monaco-editor": "npm:@codingame/monaco-vscode-editor-api@~10.0.1",
76
+ "vscode": "npm:@codingame/monaco-vscode-api@~10.0.1"
76
77
  },
77
78
  "peerDependenciesMeta": {
78
79
  "monaco-editor": {
package/src/client.ts ADDED
@@ -0,0 +1,26 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/browser.js';
7
+
8
+ export type MonacoLanguageClientOptions = {
9
+ name: string;
10
+ id?: string;
11
+ clientOptions: LanguageClientOptions;
12
+ messageTransports: MessageTransports;
13
+ }
14
+
15
+ export class MonacoLanguageClient extends BaseLanguageClient {
16
+ protected readonly messageTransports: MessageTransports;
17
+
18
+ constructor({ id, name, clientOptions, messageTransports }: MonacoLanguageClientOptions) {
19
+ super(id ?? name.toLowerCase(), name, clientOptions);
20
+ this.messageTransports = messageTransports;
21
+ }
22
+
23
+ protected override createMessageTransports(_encoding: string): Promise<MessageTransports> {
24
+ return Promise.resolve(this.messageTransports);
25
+ }
26
+ }
@@ -0,0 +1,60 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ import { MonacoLanguageClient } from './client.js';
7
+
8
+ export type ConnetionConfigOptions = WebSocketConfigOptionsDirect | WebSocketConfigOptionsParams | WebSocketConfigOptionsUrl | WorkerConfigOptionsParams | WorkerConfigOptionsDirect;
9
+
10
+ export interface WebSocketCallOptions {
11
+ /** Adds handle on languageClient */
12
+ onCall: (languageClient?: MonacoLanguageClient) => void;
13
+ /** Reports Status Of Language Client */
14
+ reportStatus?: boolean;
15
+ }
16
+
17
+ export interface WebSocketConfigOptionsDirect {
18
+ $type: 'WebSocketDirect'
19
+ webSocket: WebSocket
20
+ startOptions?: WebSocketCallOptions;
21
+ stopOptions?: WebSocketCallOptions;
22
+ }
23
+
24
+ export interface WebSocketUrlParams {
25
+ secured: boolean;
26
+ host: string;
27
+ port?: number;
28
+ path?: string;
29
+ extraParams?: Record<string, string | number | Array<string | number>>;
30
+ }
31
+
32
+ export interface WebSocketConfigOptionsParams extends WebSocketUrlParams {
33
+ $type: 'WebSocketParams'
34
+ startOptions?: WebSocketCallOptions;
35
+ stopOptions?: WebSocketCallOptions;
36
+ }
37
+
38
+ export interface WebSocketUrlString {
39
+ url: string;
40
+ }
41
+
42
+ export interface WebSocketConfigOptionsUrl extends WebSocketUrlString {
43
+ $type: 'WebSocketUrl'
44
+ startOptions?: WebSocketCallOptions;
45
+ stopOptions?: WebSocketCallOptions;
46
+ }
47
+
48
+ export interface WorkerConfigOptionsParams {
49
+ $type: 'WorkerConfig'
50
+ url: URL;
51
+ type: 'classic' | 'module';
52
+ messagePort?: MessagePort;
53
+ workerName?: string;
54
+ }
55
+
56
+ export interface WorkerConfigOptionsDirect {
57
+ $type: 'WorkerDirect';
58
+ worker: Worker;
59
+ messagePort?: MessagePort;
60
+ }
package/src/index.ts CHANGED
@@ -3,28 +3,5 @@
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
5
 
6
- import { BaseLanguageClient, MessageTransports, LanguageClientOptions } from 'vscode-languageclient/lib/common/client.js';
7
-
8
- export interface IConnectionProvider {
9
- get(encoding: string): Promise<MessageTransports>;
10
- }
11
-
12
- export type MonacoLanguageClientOptions = {
13
- name: string;
14
- id?: string;
15
- clientOptions: LanguageClientOptions;
16
- connectionProvider: IConnectionProvider;
17
- }
18
-
19
- export class MonacoLanguageClient extends BaseLanguageClient {
20
- protected readonly connectionProvider: IConnectionProvider;
21
-
22
- constructor({ id, name, clientOptions, connectionProvider }: MonacoLanguageClientOptions) {
23
- super(id ?? name.toLowerCase(), name, clientOptions);
24
- this.connectionProvider = connectionProvider;
25
- }
26
-
27
- protected override createMessageTransports(encoding: string): Promise<MessageTransports> {
28
- return this.connectionProvider.get(encoding);
29
- }
30
- }
6
+ export * from './client.js';
7
+ export * from './commonTypes.js';
@@ -3,42 +3,4 @@
3
3
  * Licensed under the MIT License. See LICENSE in the package root for license information.
4
4
  * ------------------------------------------------------------------------------------------ */
5
5
 
6
- export type LoggerConfig = {
7
- enabled: boolean,
8
- debugEnabled?: boolean
9
- };
10
-
11
- export class Logger {
12
-
13
- private enabled: boolean;
14
- private debugEnabled: boolean;
15
-
16
- constructor(config?: LoggerConfig) {
17
- this.updateConfig(config);
18
- }
19
-
20
- updateConfig(config?: LoggerConfig) {
21
- this.enabled = !config ? true : config!.enabled === true;
22
- this.debugEnabled = this.enabled && config?.debugEnabled === true;
23
- }
24
-
25
- isEnabled() {
26
- return this.enabled;
27
- }
28
-
29
- isDebugEnabled() {
30
- return this.debugEnabled;
31
- }
32
-
33
- info(message: string) {
34
- if (this.enabled) {
35
- console.log(message);
36
- }
37
- }
38
-
39
- debug(message: string, force?: boolean) {
40
- if (this.enabled && (this.debugEnabled || force === true)) {
41
- console.debug(message);
42
- }
43
- }
44
- }
6
+ export * from './logging.js';
@@ -0,0 +1,26 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ import { ConsoleLogger as VSCodeConsoleLogger, ILogger } from '@codingame/monaco-vscode-log-service-override';
7
+ import { LogLevel } from 'vscode/services';
8
+
9
+ export interface Logger extends ILogger {
10
+ createErrorAndLog(message: string, ...params: unknown[]): Error;
11
+ }
12
+
13
+ export class ConsoleLogger extends VSCodeConsoleLogger {
14
+
15
+ constructor(logLevel?: LogLevel, useColors?: boolean) {
16
+ super(logLevel ?? LogLevel.Off, useColors);
17
+ }
18
+
19
+ createErrorAndLog(message: string, ...params: unknown[]) {
20
+ if (this.getLevel() >= LogLevel.Error) {
21
+ this.error(message, ...params);
22
+ }
23
+ return new Error(message);
24
+ }
25
+
26
+ }
@@ -0,0 +1,7 @@
1
+ /* --------------------------------------------------------------------------------------------
2
+ * Copyright (c) 2024 TypeFox and others.
3
+ * Licensed under the MIT License. See LICENSE in the package root for license information.
4
+ * ------------------------------------------------------------------------------------------ */
5
+
6
+ export * from './fakeWorker.js';
7
+ export * from './services.js';
@@ -5,26 +5,46 @@
5
5
 
6
6
  import * as monaco from 'monaco-editor';
7
7
  import 'vscode/localExtensionHost';
8
- import { ILogService, initialize, IWorkbenchConstructionOptions, LogLevel, StandaloneServices } from 'vscode/services';
8
+ import { initialize, IWorkbenchConstructionOptions } from 'vscode/services';
9
+ import { OpenEditor } from '@codingame/monaco-vscode-editor-service-override';
9
10
  import type { WorkerConfig } from '@codingame/monaco-vscode-extensions-service-override';
10
11
  import getExtensionServiceOverride from '@codingame/monaco-vscode-extensions-service-override';
11
12
  import getLanguagesServiceOverride from '@codingame/monaco-vscode-languages-service-override';
12
13
  import getModelServiceOverride from '@codingame/monaco-vscode-model-service-override';
14
+ import getLogServiceOverride from '@codingame/monaco-vscode-log-service-override';
13
15
  import type { LocalizationOptions } from '@codingame/monaco-vscode-localization-service-override';
16
+ import { EnvironmentOverride } from 'vscode/workbench';
17
+ import { Logger } from 'monaco-languageclient/tools';
14
18
  import { FakeWorker as Worker } from './fakeWorker.js';
15
- import { Logger } from '../tools/index.js';
16
19
 
17
20
  export interface MonacoEnvironmentEnhanced extends monaco.Environment {
18
21
  vscodeInitialising?: boolean;
19
22
  vscodeApiInitialised?: boolean;
20
23
  }
21
24
 
22
- export type InitializeServiceConfig = {
25
+ export interface UserConfiguration {
26
+ json?: string;
27
+ }
28
+
29
+ export interface VscodeApiConfig {
23
30
  userServices?: monaco.editor.IEditorOverrideServices;
24
31
  enableExtHostWorker?: boolean;
25
- debugLogging?: boolean;
26
32
  workspaceConfig?: IWorkbenchConstructionOptions;
27
- };
33
+ userConfiguration?: UserConfiguration;
34
+ viewsConfig?: {
35
+ viewServiceType: 'EditorService' | 'ViewsService' | 'WorkspaceService';
36
+ openEditorFunc?: OpenEditor;
37
+ viewsInitFunc?: () => void;
38
+ },
39
+ envOptions?: EnvironmentOverride;
40
+ }
41
+
42
+ export interface InitVscodeApiInstructions extends VscodeApiConfig {
43
+ htmlContainer: HTMLElement;
44
+ caller?: string;
45
+ performChecks?: () => boolean;
46
+ logger?: Logger;
47
+ }
28
48
 
29
49
  export const initEnhancedMonacoEnvironment = () => {
30
50
  const monWin = (self as Window);
@@ -42,9 +62,15 @@ export const initEnhancedMonacoEnvironment = () => {
42
62
  return envEnhanced;
43
63
  };
44
64
 
65
+ export const getMonacoEnvironmentEnhanced = () => {
66
+ const monWin = (self as Window);
67
+ return monWin.MonacoEnvironment as MonacoEnvironmentEnhanced;
68
+ };
69
+
45
70
  export const supplyRequiredServices = async () => {
46
71
  return {
47
72
  ...getLanguagesServiceOverride(),
73
+ ...getLogServiceOverride(),
48
74
  ...getModelServiceOverride()
49
75
  };
50
76
  };
@@ -61,33 +87,19 @@ export const mergeServices = (services: monaco.editor.IEditorOverrideServices, o
61
87
  }
62
88
  };
63
89
 
64
- export type InitServicesInstruction = {
65
- serviceConfig?: InitializeServiceConfig;
66
- caller?: string;
67
- performChecks?: () => boolean;
68
- logger?: Logger;
69
- };
70
-
71
- export const initServices = async (instruction: InitServicesInstruction) => {
90
+ export const initServices = async (instructions: InitVscodeApiInstructions) => {
72
91
  const envEnhanced = initEnhancedMonacoEnvironment();
73
92
 
74
- // in case debugLogging is set and for whatever reason no logger is passed a proper one is created
75
- if (instruction.serviceConfig?.debugLogging === true && !instruction.logger) {
76
- instruction.logger = new Logger({
77
- enabled: true,
78
- debugEnabled: true
79
- });
80
- }
81
-
82
93
  if (!(envEnhanced.vscodeInitialising ?? false)) {
83
94
  if (envEnhanced.vscodeApiInitialised ?? false) {
84
- instruction.logger?.debug('Initialization of vscode services can only performed once!');
95
+ instructions.logger?.debug('Initialization of vscode services can only performed once!');
85
96
  } else {
86
97
  envEnhanced.vscodeInitialising = true;
87
- instruction.logger?.debug(`Initializing vscode services. Caller: ${instruction.caller ?? 'unknown'}`);
98
+ instructions.logger?.debug(`Initializing vscode services. Caller: ${instructions.caller ?? 'unknown'}`);
88
99
 
89
- await importAllServices(instruction);
90
- instruction.logger?.debug('Initialization of vscode services completed successfully.');
100
+ await importAllServices(instructions);
101
+ instructions.viewsConfig?.viewsInitFunc?.();
102
+ instructions.logger?.debug('Initialization of vscode services completed successfully.');
91
103
 
92
104
  envEnhanced.vscodeApiInitialised = true;
93
105
  }
@@ -105,21 +117,22 @@ export const initServices = async (instruction: InitServicesInstruction) => {
105
117
  * - languages
106
118
  * - model
107
119
  */
108
- export const importAllServices = async (instruction: InitServicesInstruction) => {
109
- const lc: InitializeServiceConfig = instruction.serviceConfig ?? {};
110
- const userServices: monaco.editor.IEditorOverrideServices = lc.userServices ?? {};
120
+ export const importAllServices = async (instructions: InitVscodeApiInstructions) => {
121
+ const userServices: monaco.editor.IEditorOverrideServices = instructions.userServices ?? {};
111
122
 
112
123
  const lcRequiredServices = await supplyRequiredServices();
113
124
 
114
125
  mergeServices(lcRequiredServices, userServices);
115
- await configureExtHostWorker(instruction.serviceConfig?.enableExtHostWorker === true, userServices);
126
+ await configureExtHostWorker(instructions.enableExtHostWorker === true, userServices);
116
127
 
117
- reportServiceLoading(userServices, instruction.logger);
128
+ reportServiceLoading(userServices, instructions.logger);
118
129
 
119
- if (instruction.performChecks === undefined || instruction.performChecks()) {
120
- await initialize(userServices, undefined, lc.workspaceConfig);
121
- const logLevel = lc.workspaceConfig?.developmentOptions?.logLevel ?? LogLevel.Info;
122
- StandaloneServices.get(ILogService).setLevel(logLevel);
130
+ if (instructions.performChecks === undefined || (typeof instructions.performChecks === 'function' && instructions.performChecks())) {
131
+ if (instructions.viewsConfig?.viewServiceType === 'ViewsService' || instructions.viewsConfig?.viewServiceType === 'WorkspaceService') {
132
+ await initialize(userServices, instructions.htmlContainer, instructions.workspaceConfig, instructions.envOptions);
133
+ } else {
134
+ await initialize(userServices, undefined, instructions.workspaceConfig, instructions.envOptions);
135
+ }
123
136
  }
124
137
  };
125
138