monaco-languageclient 10.7.0 → 11.0.0-next.0

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.
Files changed (76) hide show
  1. package/CHANGELOG.md +13 -4
  2. package/LICENSE +0 -0
  3. package/README.md +63 -63
  4. package/lib/common/commonTypes.d.ts +1 -1
  5. package/lib/common/commonTypes.d.ts.map +1 -1
  6. package/lib/common/utils.d.ts.map +1 -1
  7. package/lib/common/utils.js +2 -2
  8. package/lib/common/utils.js.map +1 -1
  9. package/lib/debugger/index.d.ts +1 -1
  10. package/lib/debugger/index.d.ts.map +1 -1
  11. package/lib/debugger/index.js +2 -4
  12. package/lib/debugger/index.js.map +1 -1
  13. package/lib/editorApp/config.d.ts +11 -11
  14. package/lib/editorApp/config.d.ts.map +1 -1
  15. package/lib/editorApp/config.js +0 -1
  16. package/lib/editorApp/config.js.map +1 -1
  17. package/lib/editorApp/editorApp.d.ts +5 -5
  18. package/lib/editorApp/editorApp.d.ts.map +1 -1
  19. package/lib/editorApp/editorApp.js +21 -23
  20. package/lib/editorApp/editorApp.js.map +1 -1
  21. package/lib/fs/definitions.d.ts.map +1 -1
  22. package/lib/fs/endpoints/defaultEndpoint.d.ts.map +1 -1
  23. package/lib/fs/endpoints/defaultEndpoint.js.map +1 -1
  24. package/lib/index.d.ts +1 -1
  25. package/lib/index.d.ts.map +1 -1
  26. package/lib/index.js +1 -1
  27. package/lib/index.js.map +1 -1
  28. package/lib/vscode/apiWrapper.d.ts +2 -2
  29. package/lib/vscode/apiWrapper.d.ts.map +1 -1
  30. package/lib/vscode/apiWrapper.js +18 -20
  31. package/lib/vscode/apiWrapper.js.map +1 -1
  32. package/lib/vscode/config.d.ts +4 -4
  33. package/lib/vscode/config.d.ts.map +1 -1
  34. package/lib/vscode/config.js +0 -1
  35. package/lib/vscode/config.js.map +1 -1
  36. package/lib/vscode/locales.d.ts +1 -1
  37. package/lib/vscode/locales.d.ts.map +1 -1
  38. package/lib/vscode/locales.js +35 -18
  39. package/lib/vscode/locales.js.map +1 -1
  40. package/lib/vscode/utils.d.ts +3 -3
  41. package/lib/vscode/utils.d.ts.map +1 -1
  42. package/lib/vscode/utils.js +3 -10
  43. package/lib/vscode/utils.js.map +1 -1
  44. package/lib/vscode/viewsService.d.ts.map +1 -1
  45. package/lib/vscode/viewsService.js +13 -7
  46. package/lib/vscode/viewsService.js.map +1 -1
  47. package/lib/worker/index.d.ts +1 -1
  48. package/lib/worker/index.d.ts.map +1 -1
  49. package/lib/worker/index.js.map +1 -1
  50. package/lib/wrapper/lcconfig.d.ts +2 -2
  51. package/lib/wrapper/lcconfig.d.ts.map +1 -1
  52. package/lib/wrapper/lcmanager.d.ts.map +1 -1
  53. package/lib/wrapper/lcmanager.js.map +1 -1
  54. package/lib/wrapper/lcwrapper.d.ts +1 -1
  55. package/lib/wrapper/lcwrapper.d.ts.map +1 -1
  56. package/lib/wrapper/lcwrapper.js +17 -16
  57. package/lib/wrapper/lcwrapper.js.map +1 -1
  58. package/package.json +70 -96
  59. package/src/common/commonTypes.ts +35 -30
  60. package/src/common/index.ts +0 -1
  61. package/src/common/utils.ts +45 -45
  62. package/src/debugger/index.ts +130 -133
  63. package/src/editorApp/config.ts +33 -33
  64. package/src/editorApp/editorApp.ts +382 -370
  65. package/src/fs/definitions.ts +72 -75
  66. package/src/fs/endpoints/defaultEndpoint.ts +50 -41
  67. package/src/index.ts +18 -18
  68. package/src/vscode/apiWrapper.ts +302 -295
  69. package/src/vscode/config.ts +30 -30
  70. package/src/vscode/locales.ts +127 -110
  71. package/src/vscode/utils.ts +20 -26
  72. package/src/vscode/viewsService.ts +44 -37
  73. package/src/worker/index.ts +38 -45
  74. package/src/wrapper/lcconfig.ts +16 -16
  75. package/src/wrapper/lcmanager.ts +68 -69
  76. package/src/wrapper/lcwrapper.ts +256 -249
@@ -6,62 +6,62 @@
6
6
  import type { WebSocketUrlParams, WebSocketUrlString } from './commonTypes.js';
7
7
 
8
8
  export const createUrl = (config: WebSocketUrlParams | WebSocketUrlString) => {
9
- let buildUrl = '';
10
- if ((config as WebSocketUrlString).url) {
11
- const options = config as WebSocketUrlString;
12
- if (!options.url.startsWith('ws://') && !options.url.startsWith('wss://')) {
13
- throw new Error(`This is not a proper websocket url: ${options.url}`);
14
- }
15
- buildUrl = options.url;
16
- } else {
17
- const options = config as WebSocketUrlParams;
18
- const protocol = options.secured ? 'wss' : 'ws';
19
- buildUrl = `${protocol}://${options.host}`;
20
- if (options.port !== undefined) {
21
- if (options.port !== 80) {
22
- buildUrl += `:${options.port}`;
23
- }
24
- }
25
- if (options.path !== undefined) {
26
- buildUrl += `/${options.path}`;
27
- }
28
- if (options.extraParams) {
29
- const url = new URL(buildUrl);
9
+ let buildUrl = '';
10
+ if (Object.hasOwn(config, 'url')) {
11
+ const options = config as WebSocketUrlString;
12
+ if (!options.url.startsWith('ws://') && !options.url.startsWith('wss://')) {
13
+ throw new Error(`This is not a proper websocket url: ${options.url}`);
14
+ }
15
+ buildUrl = options.url;
16
+ } else {
17
+ const options = config as WebSocketUrlParams;
18
+ const protocol = options.secured ? 'wss' : 'ws';
19
+ buildUrl = `${protocol}://${options.host}`;
20
+ if (options.port !== undefined) {
21
+ if (options.port !== 80) {
22
+ buildUrl += `:${options.port}`;
23
+ }
24
+ }
25
+ if (options.path !== undefined) {
26
+ buildUrl += `/${options.path}`;
27
+ }
28
+ if (options.extraParams !== undefined) {
29
+ const url = new URL(buildUrl);
30
30
 
31
- for (const [key, value] of Object.entries(options.extraParams)) {
32
- url.searchParams.set(key, value instanceof Array ? value.join(',') : value.toString());
33
- }
31
+ for (const [key, value] of Object.entries(options.extraParams)) {
32
+ url.searchParams.set(key, value instanceof Array ? value.join(',') : value.toString());
33
+ }
34
34
 
35
- buildUrl = url.toString();
36
- }
35
+ buildUrl = url.toString();
37
36
  }
38
- return buildUrl;
37
+ }
38
+ return buildUrl;
39
39
  };
40
40
 
41
41
  export const encodeStringOrUrlToDataUrl = (input: string | URL) => {
42
- if (input instanceof URL) {
43
- return input.href;
44
- } else {
45
- const bytes = new TextEncoder().encode(input);
46
- const binString = Array.from(bytes, (b) => String.fromCodePoint(b)).join('');
47
- const base64 = btoa(binString);
48
- return new URL(`data:text/plain;base64,${base64}`).href;
49
- }
42
+ if (input instanceof URL) {
43
+ return input.href;
44
+ } else {
45
+ const bytes = new TextEncoder().encode(input);
46
+ const binString = Array.from(bytes, (b) => String.fromCodePoint(b)).join('');
47
+ const base64 = btoa(binString);
48
+ return new URL(`data:text/plain;base64,${base64}`).href;
49
+ }
50
50
  };
51
51
 
52
52
  export const delayExecution = (ms: number) => {
53
- return new Promise((resolve) => setTimeout(resolve, ms));
53
+ return new Promise((resolve) => setTimeout(resolve, ms));
54
54
  };
55
55
 
56
56
  export class Deferred<T = void> {
57
- promise: Promise<T>;
58
- resolve: (value: T | PromiseLike<T>) => void;
59
- reject: (reason?: unknown) => void;
57
+ promise: Promise<T>;
58
+ resolve: (value: T | PromiseLike<T>) => void;
59
+ reject: (reason?: unknown) => void;
60
60
 
61
- constructor() {
62
- this.promise = new Promise<T>((res, rej) => {
63
- this.resolve = res;
64
- this.reject = rej;
65
- });
66
- }
61
+ constructor() {
62
+ this.promise = new Promise<T>((res, rej) => {
63
+ this.resolve = res;
64
+ this.reject = rej;
65
+ });
66
+ }
67
67
  }
@@ -14,155 +14,152 @@ import { Uri } from 'vscode';
14
14
  // The client configuration is generic and can be used for a another language
15
15
 
16
16
  export type FileDefinition = {
17
- path: string;
18
- code: string;
19
- uri: Uri;
20
- }
17
+ path: string;
18
+ code: string;
19
+ uri: Uri;
20
+ };
21
21
 
22
22
  export type InitMessage = {
23
- id: 'init',
24
- files: Record<string, FileDefinition>
25
- defaultFile: string;
26
- debuggerExecCall: string;
23
+ id: 'init';
24
+ files: Record<string, FileDefinition>;
25
+ defaultFile: string;
26
+ debuggerExecCall: string;
27
27
  };
28
28
 
29
29
  export type ConfigParams = {
30
- extensionName: string;
31
- version: string;
32
- publisher: string;
33
- languageId: string;
34
- documentSelector: string[];
35
- homeDir: string;
36
- workspaceRoot: string;
37
- workspaceFile: Uri;
38
- htmlContainer: HTMLElement;
39
- protocol: 'ws' | 'wss';
40
- hostname: string;
41
- port: number;
42
- files: Map<string, FileDefinition>;
43
- defaultFile: string;
44
- helpContainerCmd: string;
45
- debuggerExecCall: string;
46
- }
30
+ extensionName: string;
31
+ version: string;
32
+ publisher: string;
33
+ languageId: string;
34
+ documentSelector: string[];
35
+ homeDir: string;
36
+ workspaceRoot: string;
37
+ workspaceFile: Uri;
38
+ htmlContainer: HTMLElement;
39
+ protocol: 'ws' | 'wss';
40
+ hostname: string;
41
+ port: number;
42
+ files: Map<string, FileDefinition>;
43
+ defaultFile: string;
44
+ helpContainerCmd: string;
45
+ debuggerExecCall: string;
46
+ };
47
47
 
48
48
  export const provideDebuggerExtensionConfig = (config: ConfigParams): ExtensionConfig => {
49
- const filesOrContents = new Map<string, string | URL>();
50
- filesOrContents.set('./extension.js', '// nothing');
51
-
52
- return {
53
- config: {
54
- name: config.extensionName,
55
- publisher: config.publisher,
56
- version: config.version,
57
- engines: {
58
- vscode: '*'
59
- },
60
- // A browser field is mandatory for the extension to be flagged as `web`
61
- browser: 'extension.js',
62
- contributes: {
63
- debuggers: [
64
- {
65
- type: config.languageId,
66
- label: 'Test',
67
- languages: [config.languageId]
68
- }
69
- ],
70
- breakpoints: [
71
- {
72
- language: config.languageId
73
- }
74
- ]
75
- },
76
- activationEvents: [
77
- 'onDebug'
78
- ]
79
- },
80
- filesOrContents
81
- };
49
+ const filesOrContents = new Map<string, string | URL>();
50
+ filesOrContents.set('./extension.js', '// nothing');
51
+
52
+ return {
53
+ config: {
54
+ name: config.extensionName,
55
+ publisher: config.publisher,
56
+ version: config.version,
57
+ engines: {
58
+ vscode: '*'
59
+ },
60
+ // A browser field is mandatory for the extension to be flagged as `web`
61
+ browser: 'extension.js',
62
+ contributes: {
63
+ debuggers: [
64
+ {
65
+ type: config.languageId,
66
+ label: 'Test',
67
+ languages: [config.languageId]
68
+ }
69
+ ],
70
+ breakpoints: [
71
+ {
72
+ language: config.languageId
73
+ }
74
+ ]
75
+ },
76
+ activationEvents: ['onDebug']
77
+ },
78
+ filesOrContents
79
+ };
82
80
  };
83
81
 
84
82
  export const configureDebugging = async (api: typeof vscode, config: ConfigParams, logger?: ILogger) => {
85
- class WebsocketDebugAdapter implements vscode.DebugAdapter {
86
- private websocket: WebSocket;
87
-
88
- constructor(websocket: WebSocket) {
89
- this.websocket = websocket;
90
- this.websocket.onmessage = (message) => {
91
- this._onDidSendMessage.fire(JSON.parse(message.data));
92
- };
93
- }
83
+ class WebsocketDebugAdapter implements vscode.DebugAdapter {
84
+ private websocket: WebSocket;
85
+
86
+ constructor(websocket: WebSocket) {
87
+ this.websocket = websocket;
88
+ this.websocket.onmessage = (message) => {
89
+ this._onDidSendMessage.fire(JSON.parse(message.data));
90
+ };
91
+ }
94
92
 
95
- _onDidSendMessage = new api.EventEmitter<vscode.DebugProtocolMessage>();
96
- onDidSendMessage = this._onDidSendMessage.event;
93
+ _onDidSendMessage = new api.EventEmitter<vscode.DebugProtocolMessage>();
94
+ onDidSendMessage = this._onDidSendMessage.event;
97
95
 
98
- handleMessage(message: vscode.DebugProtocolMessage): void {
99
- // path with on Windows (Chrome/Firefox) arrive here with \\ and not like expected with /
100
- // Chrome on Ubuntu behaves as expected
101
- const msg = JSON.stringify(message).replaceAll('\\\\', '/');
102
- this.websocket.send(msg);
103
- }
104
-
105
- dispose() {
106
- this.websocket.close();
107
- }
96
+ handleMessage(message: vscode.DebugProtocolMessage): void {
97
+ // path with on Windows (Chrome/Firefox) arrive here with \\ and not like expected with /
98
+ // Chrome on Ubuntu behaves as expected
99
+ const msg = JSON.stringify(message).replaceAll('\\\\', '/');
100
+ this.websocket.send(msg);
108
101
  }
109
102
 
110
- api.debug.registerDebugAdapterDescriptorFactory(config.languageId, {
111
- async createDebugAdapterDescriptor() {
112
- const websocket = new WebSocket(`${config.protocol}://${config.hostname}:${config.port}`);
113
-
114
- await new Promise((resolve, reject) => {
115
- websocket.onopen = resolve;
116
- websocket.onerror = () =>
117
- reject(new Error(`Unable to connect to debugger server. Run "${config.helpContainerCmd}"`));
118
- });
119
-
120
- const adapter = new WebsocketDebugAdapter(websocket);
121
-
122
- const initMessage: InitMessage = {
123
- id: 'init',
124
- files: {},
125
- // the default file is the one that will be used by the debugger
126
- defaultFile: config.defaultFile,
127
- debuggerExecCall: config.debuggerExecCall
128
- };
129
- for (const [name, fileDef] of config.files.entries()) {
130
- logger?.info(`Found: ${name} Sending file: ${fileDef.path}`);
131
- initMessage.files[name] = {
132
- path: fileDef.path,
133
- code: fileDef.code,
134
- uri: fileDef.uri
135
- };
136
- }
137
- websocket.send(JSON.stringify(initMessage));
138
-
139
- // oxlint-disable-next-line @typescript-eslint/no-explicit-any
140
- adapter.onDidSendMessage((message: any) => {
141
- if (message.type === 'event' && message.event === 'output') {
142
- logger?.info('OUTPUT', message.body.output);
143
- }
144
- });
145
- return new api.DebugAdapterInlineImplementation(adapter);
103
+ dispose() {
104
+ this.websocket.close();
105
+ }
106
+ }
107
+
108
+ api.debug.registerDebugAdapterDescriptorFactory(config.languageId, {
109
+ async createDebugAdapterDescriptor() {
110
+ const websocket = new WebSocket(`${config.protocol}://${config.hostname}:${config.port}`);
111
+
112
+ await new Promise((resolve, reject) => {
113
+ websocket.onopen = resolve;
114
+ websocket.onerror = () => reject(new Error(`Unable to connect to debugger server. Run "${config.helpContainerCmd}"`));
115
+ });
116
+
117
+ const adapter = new WebsocketDebugAdapter(websocket);
118
+
119
+ const initMessage: InitMessage = {
120
+ id: 'init',
121
+ files: {},
122
+ // the default file is the one that will be used by the debugger
123
+ defaultFile: config.defaultFile,
124
+ debuggerExecCall: config.debuggerExecCall
125
+ };
126
+ for (const [name, fileDef] of config.files.entries()) {
127
+ logger?.info(`Found: ${name} Sending file: ${fileDef.path}`);
128
+ initMessage.files[name] = {
129
+ path: fileDef.path,
130
+ code: fileDef.code,
131
+ uri: fileDef.uri
132
+ };
133
+ }
134
+ websocket.send(JSON.stringify(initMessage));
135
+
136
+ // oxlint-disable-next-line @typescript-eslint/no-explicit-any
137
+ adapter.onDidSendMessage((message: any) => {
138
+ if (message.type === 'event' && message.event === 'output') {
139
+ logger?.info('OUTPUT', message.body.output);
146
140
  }
147
- });
141
+ });
142
+ return new api.DebugAdapterInlineImplementation(adapter);
143
+ }
144
+ });
148
145
  };
149
146
 
150
147
  export const createDebugLaunchConfigFile = (workspacePath: string, type: string) => {
151
- return new RegisteredMemoryFile(
152
- Uri.file(`${workspacePath}/.vscode/launch.json`),
153
- JSON.stringify(
154
- {
155
- version: '0.2.0',
156
- configurations: [
157
- {
158
- name: 'Debugger: Lauch',
159
- type,
160
- request: 'attach',
161
- }
162
- ]
163
- },
164
- null,
165
- 2
166
- )
167
- );
148
+ return new RegisteredMemoryFile(
149
+ Uri.file(`${workspacePath}/.vscode/launch.json`),
150
+ JSON.stringify(
151
+ {
152
+ version: '0.2.0',
153
+ configurations: [
154
+ {
155
+ name: 'Debugger: Lauch',
156
+ type,
157
+ request: 'attach'
158
+ }
159
+ ]
160
+ },
161
+ null,
162
+ 2
163
+ )
164
+ );
168
165
  };
@@ -5,61 +5,61 @@
5
5
 
6
6
  import { LogLevel } from '@codingame/monaco-vscode-api';
7
7
  import { type ITextFileEditorModel } from '@codingame/monaco-vscode-api/monaco';
8
- import * as monaco from '@codingame/monaco-vscode-editor-api';
8
+ import type { editor, languages, IDisposable } from '@codingame/monaco-vscode-editor-api';
9
9
  import type { IReference } from '@codingame/monaco-vscode-editor-service-override';
10
10
 
11
11
  export class ModelRefs {
12
- modified?: IReference<ITextFileEditorModel>;
13
- original?: IReference<ITextFileEditorModel>;
12
+ modified?: IReference<ITextFileEditorModel>;
13
+ original?: IReference<ITextFileEditorModel>;
14
14
  }
15
15
 
16
16
  export interface TextModels {
17
- modified?: monaco.editor.ITextModel | null;
18
- original?: monaco.editor.ITextModel | null;
17
+ modified?: editor.ITextModel | null;
18
+ original?: editor.ITextModel | null;
19
19
  }
20
20
 
21
21
  export interface TextContents {
22
- modified?: string;
23
- original?: string;
22
+ modified?: string;
23
+ original?: string;
24
24
  }
25
25
 
26
26
  export interface CodeContent {
27
- text: string;
28
- uri: string;
29
- enforceLanguageId?: string;
27
+ text: string;
28
+ uri: string;
29
+ enforceLanguageId?: string;
30
30
  }
31
31
 
32
32
  export interface CodeResources {
33
- modified?: CodeContent;
34
- original?: CodeContent;
33
+ modified?: CodeContent;
34
+ original?: CodeContent;
35
35
  }
36
36
 
37
37
  export interface CallbackDisposeable {
38
- modified?: monaco.IDisposable;
39
- original?: monaco.IDisposable;
38
+ modified?: IDisposable;
39
+ original?: IDisposable;
40
40
  }
41
41
 
42
42
  export interface DisposableModelRefs {
43
- modified?: IReference<ITextFileEditorModel>;
44
- original?: IReference<ITextFileEditorModel>;
43
+ modified?: IReference<ITextFileEditorModel>;
44
+ original?: IReference<ITextFileEditorModel>;
45
45
  }
46
46
 
47
47
  export interface EditorAppConfig {
48
- id?: string;
49
- logLevel?: LogLevel | number;
50
- codeResources?: CodeResources;
51
- useDiffEditor?: boolean;
52
- domReadOnly?: boolean;
53
- readOnly?: boolean;
54
- overrideAutomaticLayout?: boolean;
55
- editorOptions?: monaco.editor.IStandaloneEditorConstructionOptions;
56
- diffEditorOptions?: monaco.editor.IStandaloneDiffEditorConstructionOptions;
57
- languageDef?: {
58
- languageExtensionConfig: monaco.languages.ILanguageExtensionPoint;
59
- monarchLanguage?: monaco.languages.IMonarchLanguage;
60
- theme?: {
61
- name: monaco.editor.BuiltinTheme | string;
62
- data: monaco.editor.IStandaloneThemeData;
63
- }
64
- }
48
+ id?: string;
49
+ logLevel?: LogLevel | number;
50
+ codeResources?: CodeResources;
51
+ useDiffEditor?: boolean;
52
+ domReadOnly?: boolean;
53
+ readOnly?: boolean;
54
+ overrideAutomaticLayout?: boolean;
55
+ editorOptions?: editor.IStandaloneEditorConstructionOptions;
56
+ diffEditorOptions?: editor.IStandaloneDiffEditorConstructionOptions;
57
+ languageDef?: {
58
+ languageExtensionConfig: languages.ILanguageExtensionPoint;
59
+ monarchLanguage?: languages.IMonarchLanguage;
60
+ theme?: {
61
+ name: string;
62
+ data: editor.IStandaloneThemeData;
63
+ };
64
+ };
65
65
  }