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.
- package/CHANGELOG.md +13 -4
- package/LICENSE +0 -0
- package/README.md +63 -63
- package/lib/common/commonTypes.d.ts +1 -1
- package/lib/common/commonTypes.d.ts.map +1 -1
- package/lib/common/utils.d.ts.map +1 -1
- package/lib/common/utils.js +2 -2
- package/lib/common/utils.js.map +1 -1
- package/lib/debugger/index.d.ts +1 -1
- package/lib/debugger/index.d.ts.map +1 -1
- package/lib/debugger/index.js +2 -4
- package/lib/debugger/index.js.map +1 -1
- package/lib/editorApp/config.d.ts +11 -11
- package/lib/editorApp/config.d.ts.map +1 -1
- package/lib/editorApp/config.js +0 -1
- package/lib/editorApp/config.js.map +1 -1
- package/lib/editorApp/editorApp.d.ts +5 -5
- package/lib/editorApp/editorApp.d.ts.map +1 -1
- package/lib/editorApp/editorApp.js +21 -23
- package/lib/editorApp/editorApp.js.map +1 -1
- package/lib/fs/definitions.d.ts.map +1 -1
- package/lib/fs/endpoints/defaultEndpoint.d.ts.map +1 -1
- package/lib/fs/endpoints/defaultEndpoint.js.map +1 -1
- package/lib/index.d.ts +1 -1
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -1
- package/lib/index.js.map +1 -1
- package/lib/vscode/apiWrapper.d.ts +2 -2
- package/lib/vscode/apiWrapper.d.ts.map +1 -1
- package/lib/vscode/apiWrapper.js +18 -20
- package/lib/vscode/apiWrapper.js.map +1 -1
- package/lib/vscode/config.d.ts +4 -4
- package/lib/vscode/config.d.ts.map +1 -1
- package/lib/vscode/config.js +0 -1
- package/lib/vscode/config.js.map +1 -1
- package/lib/vscode/locales.d.ts +1 -1
- package/lib/vscode/locales.d.ts.map +1 -1
- package/lib/vscode/locales.js +35 -18
- package/lib/vscode/locales.js.map +1 -1
- package/lib/vscode/utils.d.ts +3 -3
- package/lib/vscode/utils.d.ts.map +1 -1
- package/lib/vscode/utils.js +3 -10
- package/lib/vscode/utils.js.map +1 -1
- package/lib/vscode/viewsService.d.ts.map +1 -1
- package/lib/vscode/viewsService.js +13 -7
- package/lib/vscode/viewsService.js.map +1 -1
- package/lib/worker/index.d.ts +1 -1
- package/lib/worker/index.d.ts.map +1 -1
- package/lib/worker/index.js.map +1 -1
- package/lib/wrapper/lcconfig.d.ts +2 -2
- package/lib/wrapper/lcconfig.d.ts.map +1 -1
- package/lib/wrapper/lcmanager.d.ts.map +1 -1
- package/lib/wrapper/lcmanager.js.map +1 -1
- package/lib/wrapper/lcwrapper.d.ts +1 -1
- package/lib/wrapper/lcwrapper.d.ts.map +1 -1
- package/lib/wrapper/lcwrapper.js +17 -16
- package/lib/wrapper/lcwrapper.js.map +1 -1
- package/package.json +70 -96
- package/src/common/commonTypes.ts +35 -30
- package/src/common/index.ts +0 -1
- package/src/common/utils.ts +45 -45
- package/src/debugger/index.ts +130 -133
- package/src/editorApp/config.ts +33 -33
- package/src/editorApp/editorApp.ts +382 -370
- package/src/fs/definitions.ts +72 -75
- package/src/fs/endpoints/defaultEndpoint.ts +50 -41
- package/src/index.ts +18 -18
- package/src/vscode/apiWrapper.ts +302 -295
- package/src/vscode/config.ts +30 -30
- package/src/vscode/locales.ts +127 -110
- package/src/vscode/utils.ts +20 -26
- package/src/vscode/viewsService.ts +44 -37
- package/src/worker/index.ts +38 -45
- package/src/wrapper/lcconfig.ts +16 -16
- package/src/wrapper/lcmanager.ts +68 -69
- package/src/wrapper/lcwrapper.ts +256 -249
package/src/common/utils.ts
CHANGED
|
@@ -6,62 +6,62 @@
|
|
|
6
6
|
import type { WebSocketUrlParams, WebSocketUrlString } from './commonTypes.js';
|
|
7
7
|
|
|
8
8
|
export const createUrl = (config: WebSocketUrlParams | WebSocketUrlString) => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
32
|
-
|
|
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
|
-
|
|
36
|
-
}
|
|
35
|
+
buildUrl = url.toString();
|
|
37
36
|
}
|
|
38
|
-
|
|
37
|
+
}
|
|
38
|
+
return buildUrl;
|
|
39
39
|
};
|
|
40
40
|
|
|
41
41
|
export const encodeStringOrUrlToDataUrl = (input: string | URL) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
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
|
-
|
|
53
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
54
54
|
};
|
|
55
55
|
|
|
56
56
|
export class Deferred<T = void> {
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
promise: Promise<T>;
|
|
58
|
+
resolve: (value: T | PromiseLike<T>) => void;
|
|
59
|
+
reject: (reason?: unknown) => void;
|
|
60
60
|
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
61
|
+
constructor() {
|
|
62
|
+
this.promise = new Promise<T>((res, rej) => {
|
|
63
|
+
this.resolve = res;
|
|
64
|
+
this.reject = rej;
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
67
|
}
|
package/src/debugger/index.ts
CHANGED
|
@@ -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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
}
|
|
17
|
+
path: string;
|
|
18
|
+
code: string;
|
|
19
|
+
uri: Uri;
|
|
20
|
+
};
|
|
21
21
|
|
|
22
22
|
export type InitMessage = {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
23
|
+
id: 'init';
|
|
24
|
+
files: Record<string, FileDefinition>;
|
|
25
|
+
defaultFile: string;
|
|
26
|
+
debuggerExecCall: string;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
29
|
export type ConfigParams = {
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
|
|
96
|
-
|
|
93
|
+
_onDidSendMessage = new api.EventEmitter<vscode.DebugProtocolMessage>();
|
|
94
|
+
onDidSendMessage = this._onDidSendMessage.event;
|
|
97
95
|
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
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
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
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
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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
|
};
|
package/src/editorApp/config.ts
CHANGED
|
@@ -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
|
|
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
|
-
|
|
13
|
-
|
|
12
|
+
modified?: IReference<ITextFileEditorModel>;
|
|
13
|
+
original?: IReference<ITextFileEditorModel>;
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
export interface TextModels {
|
|
17
|
-
|
|
18
|
-
|
|
17
|
+
modified?: editor.ITextModel | null;
|
|
18
|
+
original?: editor.ITextModel | null;
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export interface TextContents {
|
|
22
|
-
|
|
23
|
-
|
|
22
|
+
modified?: string;
|
|
23
|
+
original?: string;
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
export interface CodeContent {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
27
|
+
text: string;
|
|
28
|
+
uri: string;
|
|
29
|
+
enforceLanguageId?: string;
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
export interface CodeResources {
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
modified?: CodeContent;
|
|
34
|
+
original?: CodeContent;
|
|
35
35
|
}
|
|
36
36
|
|
|
37
37
|
export interface CallbackDisposeable {
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
modified?: IDisposable;
|
|
39
|
+
original?: IDisposable;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
42
|
export interface DisposableModelRefs {
|
|
43
|
-
|
|
44
|
-
|
|
43
|
+
modified?: IReference<ITextFileEditorModel>;
|
|
44
|
+
original?: IReference<ITextFileEditorModel>;
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export interface EditorAppConfig {
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
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
|
}
|