monaco-languageclient-examples 2025.9.2 → 2025.11.1
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 +10 -0
- package/dist/appPlayground/reactMain.js +9 -8
- package/dist/appPlayground/reactMain.js.map +1 -1
- package/dist/clangd/client/main.d.ts.map +1 -1
- package/dist/clangd/client/main.js +3 -1
- package/dist/clangd/client/main.js.map +1 -1
- package/dist/clangd/worker/workerRemoteMessageChannelFs.js +4 -0
- package/dist/clangd/worker/workerRemoteMessageChannelFs.js.map +1 -1
- package/dist/common/client/extendedClient.js +2 -2
- package/dist/common/client/extendedClient.js.map +1 -1
- package/dist/common/client/utils.js +4 -0
- package/dist/common/client/utils.js.map +1 -1
- package/dist/eclipse.jdt.ls/config.js +4 -0
- package/dist/eclipse.jdt.ls/config.js.map +1 -1
- package/dist/groovy/config.js +4 -0
- package/dist/groovy/config.js.map +1 -1
- package/dist/json/client/classic.d.ts.map +1 -1
- package/dist/json/client/classic.js +1 -1
- package/dist/json/client/classic.js.map +1 -1
- package/dist/json/client/config.js +4 -0
- package/dist/json/client/config.js.map +1 -1
- package/dist/langium/langium-dsl/config/langium.monarch.d.ts +6 -6
- package/dist/langium/statemachine/config/statemachineConfig.d.ts.map +1 -1
- package/dist/langium/statemachine/config/statemachineConfig.js +5 -3
- package/dist/langium/statemachine/config/statemachineConfig.js.map +1 -1
- package/dist/langium/statemachine/ls/generated/grammar.js +4 -0
- package/dist/langium/statemachine/ls/generated/grammar.js.map +1 -1
- package/dist/langium/statemachine/ls/generated/module.js +4 -0
- package/dist/langium/statemachine/ls/generated/module.js.map +1 -1
- package/dist/langium/statemachine/ls/statemachine-validator.js +4 -0
- package/dist/langium/statemachine/ls/statemachine-validator.js.map +1 -1
- package/dist/langium/statemachine/main-react.d.ts.map +1 -1
- package/dist/langium/statemachine/main-react.js +36 -19
- package/dist/langium/statemachine/main-react.js.map +1 -1
- package/dist/multi/twoLanguageClients.js +2 -2
- package/dist/multi/twoLanguageClients.js.map +1 -1
- package/dist/python/client/config.d.ts +1 -1
- package/dist/python/client/config.d.ts.map +1 -1
- package/dist/python/client/config.js +3 -2
- package/dist/python/client/config.js.map +1 -1
- package/dist/python/client/main.js +1 -1
- package/dist/python/client/main.js.map +1 -1
- package/dist/python/client/reactPython.d.ts.map +1 -1
- package/dist/python/client/reactPython.js +6 -4
- package/dist/python/client/reactPython.js.map +1 -1
- package/index.html +1 -1
- package/package.json +43 -43
- package/src/appPlayground/reactMain.tsx +3 -3
- package/src/clangd/client/main.ts +3 -1
- package/src/common/client/extendedClient.ts +2 -2
- package/src/debugger/server/debugServer.ts +1 -1
- package/src/json/client/classic.ts +1 -4
- package/src/langium/statemachine/config/statemachineConfig.ts +5 -3
- package/src/langium/statemachine/main-react.tsx +33 -20
- package/src/multi/twoLanguageClients.ts +2 -2
- package/src/python/client/config.ts +3 -2
- package/src/python/client/main.ts +1 -1
- package/src/python/client/reactPython.tsx +14 -12
- package/vite.production.base.ts +0 -1
- package/dist/debugger/client/debugger.d.ts +0 -6
- package/dist/debugger/client/debugger.d.ts.map +0 -1
- package/dist/debugger/client/debugger.js +0 -98
- package/dist/debugger/client/debugger.js.map +0 -1
- package/dist/debugger/common/definitions.d.ts +0 -31
- package/dist/debugger/common/definitions.d.ts.map +0 -1
- package/dist/debugger/common/definitions.js +0 -19
- package/dist/debugger/common/definitions.js.map +0 -1
- package/src/debugger/client/debugger.ts +0 -114
- package/src/debugger/common/definitions.ts +0 -58
|
@@ -1,98 +0,0 @@
|
|
|
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 * as vscode from 'vscode';
|
|
6
|
-
// This is derived from:
|
|
7
|
-
// https://github.com/CodinGame/monaco-vscode-api/blob/main/demo/src/features/debugger.ts
|
|
8
|
-
// The client configuration is generic and can be used for a another language
|
|
9
|
-
export const provideDebuggerExtensionConfig = (config) => {
|
|
10
|
-
const filesOrContents = new Map();
|
|
11
|
-
filesOrContents.set('./extension.js', '// nothing');
|
|
12
|
-
return {
|
|
13
|
-
config: {
|
|
14
|
-
name: config.extensionName,
|
|
15
|
-
publisher: 'TypeFox',
|
|
16
|
-
version: '1.0.0',
|
|
17
|
-
engines: {
|
|
18
|
-
vscode: '*'
|
|
19
|
-
},
|
|
20
|
-
// A browser field is mandatory for the extension to be flagged as `web`
|
|
21
|
-
browser: 'extension.js',
|
|
22
|
-
contributes: {
|
|
23
|
-
debuggers: [
|
|
24
|
-
{
|
|
25
|
-
type: config.languageId,
|
|
26
|
-
label: 'Test',
|
|
27
|
-
languages: [config.languageId]
|
|
28
|
-
}
|
|
29
|
-
],
|
|
30
|
-
breakpoints: [
|
|
31
|
-
{
|
|
32
|
-
language: config.languageId
|
|
33
|
-
}
|
|
34
|
-
]
|
|
35
|
-
},
|
|
36
|
-
activationEvents: [
|
|
37
|
-
'onDebug'
|
|
38
|
-
]
|
|
39
|
-
},
|
|
40
|
-
filesOrContents
|
|
41
|
-
};
|
|
42
|
-
};
|
|
43
|
-
export const configureDebugging = async (api, config) => {
|
|
44
|
-
class WebsocketDebugAdapter {
|
|
45
|
-
websocket;
|
|
46
|
-
constructor(websocket) {
|
|
47
|
-
this.websocket = websocket;
|
|
48
|
-
this.websocket.onmessage = (message) => {
|
|
49
|
-
this._onDidSendMessage.fire(JSON.parse(message.data));
|
|
50
|
-
};
|
|
51
|
-
}
|
|
52
|
-
_onDidSendMessage = new api.EventEmitter();
|
|
53
|
-
onDidSendMessage = this._onDidSendMessage.event;
|
|
54
|
-
handleMessage(message) {
|
|
55
|
-
// path with on Windows (Chrome/Firefox) arrive here with \\ and not like expected with /
|
|
56
|
-
// Chrome on Ubuntu behaves as expected
|
|
57
|
-
const msg = JSON.stringify(message).replaceAll('\\\\', '/');
|
|
58
|
-
this.websocket.send(msg);
|
|
59
|
-
}
|
|
60
|
-
dispose() {
|
|
61
|
-
this.websocket.close();
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
api.debug.registerDebugAdapterDescriptorFactory(config.languageId, {
|
|
65
|
-
async createDebugAdapterDescriptor() {
|
|
66
|
-
const websocket = new WebSocket(`${config.protocol}://${config.hostname}:${config.port}`);
|
|
67
|
-
await new Promise((resolve, reject) => {
|
|
68
|
-
websocket.onopen = resolve;
|
|
69
|
-
websocket.onerror = () => reject(new Error(`Unable to connect to debugger server. Run "${config.helpContainerCmd}"`));
|
|
70
|
-
});
|
|
71
|
-
const adapter = new WebsocketDebugAdapter(websocket);
|
|
72
|
-
const initMessage = {
|
|
73
|
-
id: 'init',
|
|
74
|
-
files: {},
|
|
75
|
-
// the default file is the one that will be used by the debugger
|
|
76
|
-
defaultFile: config.defaultFile,
|
|
77
|
-
debuggerExecCall: config.debuggerExecCall
|
|
78
|
-
};
|
|
79
|
-
for (const [name, fileDef] of config.files.entries()) {
|
|
80
|
-
console.log(`Found: ${name} Sending file: ${fileDef.path}`);
|
|
81
|
-
initMessage.files[name] = {
|
|
82
|
-
path: fileDef.path,
|
|
83
|
-
code: fileDef.code,
|
|
84
|
-
uri: fileDef.uri
|
|
85
|
-
};
|
|
86
|
-
}
|
|
87
|
-
websocket.send(JSON.stringify(initMessage));
|
|
88
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
89
|
-
adapter.onDidSendMessage((message) => {
|
|
90
|
-
if (message.type === 'event' && message.event === 'output') {
|
|
91
|
-
console.log('OUTPUT', message.body.output);
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
return new api.DebugAdapterInlineImplementation(adapter);
|
|
95
|
-
}
|
|
96
|
-
});
|
|
97
|
-
};
|
|
98
|
-
//# sourceMappingURL=debugger.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"debugger.js","sourceRoot":"","sources":["../../../src/debugger/client/debugger.ts"],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AAI,EAAE,OAAO,CAAC,IAAI,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,EAAE,CAAC;gBACnD,OAAO,CAAC,GAAG,CAAC,UAAU,IAAI,kBAAkB,OAAO,CAAC,IAAI,EAAE,CAAC,CAAC;gBAC5D,WAAW,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG;oBACtB,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,IAAI,EAAE,OAAO,CAAC,IAAI;oBAClB,GAAG,EAAE,OAAO,CAAC,GAAG;iBACnB,CAAC;YACN,CAAC;YACD,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,WAAW,CAAC,CAAC,CAAC;YAE5C,8DAA8D;YAC9D,OAAO,CAAC,gBAAgB,CAAC,CAAC,OAAY,EAAE,EAAE,CAAC;gBACvC,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,IAAI,OAAO,CAAC,KAAK,KAAK,QAAQ,EAAE,CAAC;oBACzD,OAAO,CAAC,GAAG,CAAC,QAAQ,EAAE,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;gBAC/C,CAAC;YAAA,CACJ,CAAC,CAAC;YACH,OAAO,IAAI,GAAG,CAAC,gCAAgC,CAAC,OAAO,CAAC,CAAC;QAAA,CAC5D;KACJ,CAAC,CAAC;AAAA,CACN,CAAC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override';
|
|
2
|
-
import { Uri } from 'vscode';
|
|
3
|
-
export type FileDefinition = {
|
|
4
|
-
path: string;
|
|
5
|
-
code: string;
|
|
6
|
-
uri: Uri;
|
|
7
|
-
};
|
|
8
|
-
export type InitMessage = {
|
|
9
|
-
id: 'init';
|
|
10
|
-
files: Record<string, FileDefinition>;
|
|
11
|
-
defaultFile: string;
|
|
12
|
-
debuggerExecCall: string;
|
|
13
|
-
};
|
|
14
|
-
export type ConfigParams = {
|
|
15
|
-
extensionName: string;
|
|
16
|
-
languageId: string;
|
|
17
|
-
documentSelector: string[];
|
|
18
|
-
homeDir: string;
|
|
19
|
-
workspaceRoot: string;
|
|
20
|
-
workspaceFile: Uri;
|
|
21
|
-
htmlContainer: HTMLElement;
|
|
22
|
-
protocol: 'ws' | 'wss';
|
|
23
|
-
hostname: string;
|
|
24
|
-
port: number;
|
|
25
|
-
files: Map<string, FileDefinition>;
|
|
26
|
-
defaultFile: string;
|
|
27
|
-
helpContainerCmd: string;
|
|
28
|
-
debuggerExecCall: string;
|
|
29
|
-
};
|
|
30
|
-
export declare const createDebugLaunchConfigFile: (workspacePath: string, type: string) => RegisteredMemoryFile;
|
|
31
|
-
//# sourceMappingURL=definitions.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.d.ts","sourceRoot":"","sources":["../../../src/debugger/common/definitions.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAE7B,MAAM,MAAM,cAAc,GAAG;IACzB,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,EAAE,GAAG,CAAC;CACZ,CAAA;AAED,MAAM,MAAM,WAAW,GAAG;IACtB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAA;IACrC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;CAC5B,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACvB,aAAa,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;IACnB,gBAAgB,EAAE,MAAM,EAAE,CAAC;IAC3B,OAAO,EAAE,MAAM,CAAC;IAChB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,GAAG,CAAC;IACnB,aAAa,EAAE,WAAW,CAAC;IAC3B,QAAQ,EAAE,IAAI,GAAG,KAAK,CAAC;IACvB,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;IACnC,WAAW,EAAE,MAAM,CAAC;IACpB,gBAAgB,EAAE,MAAM,CAAC;IACzB,gBAAgB,EAAE,MAAM,CAAC;CAC5B,CAAA;AAED,eAAO,MAAM,2BAA2B,+DAkBvC,CAAC"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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 { RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override';
|
|
6
|
-
import { Uri } from 'vscode';
|
|
7
|
-
export const createDebugLaunchConfigFile = (workspacePath, type) => {
|
|
8
|
-
return new RegisteredMemoryFile(Uri.file(`${workspacePath}/.vscode/launch.json`), JSON.stringify({
|
|
9
|
-
version: '0.2.0',
|
|
10
|
-
configurations: [
|
|
11
|
-
{
|
|
12
|
-
name: 'Debugger: Lauch',
|
|
13
|
-
type,
|
|
14
|
-
request: 'attach',
|
|
15
|
-
}
|
|
16
|
-
]
|
|
17
|
-
}, null, 2));
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=definitions.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../../src/debugger/common/definitions.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAEhG,OAAO,EAAE,oBAAoB,EAAE,MAAM,iDAAiD,CAAC;AACvF,OAAO,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAC;AAgC7B,MAAM,CAAC,MAAM,2BAA2B,GAAG,CAAC,aAAqB,EAAE,IAAY,EAAE,EAAE,CAAC;IAChF,OAAO,IAAI,oBAAoB,CAC3B,GAAG,CAAC,IAAI,CAAC,GAAG,aAAa,sBAAsB,CAAC,EAChD,IAAI,CAAC,SAAS,CACV;QACI,OAAO,EAAE,OAAO;QAChB,cAAc,EAAE;YACZ;gBACI,IAAI,EAAE,iBAAiB;gBACvB,IAAI;gBACJ,OAAO,EAAE,QAAQ;aACpB;SACJ;KACJ,EACD,IAAI,EACJ,CAAC,CACJ,CACJ,CAAC;AAAA,CACL,CAAC"}
|
|
@@ -1,114 +0,0 @@
|
|
|
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 * as vscode from 'vscode';
|
|
7
|
-
import type { ExtensionConfig } from 'monaco-languageclient/vscodeApiWrapper';
|
|
8
|
-
import type { ConfigParams, InitMessage } from '../common/definitions.js';
|
|
9
|
-
|
|
10
|
-
// This is derived from:
|
|
11
|
-
// https://github.com/CodinGame/monaco-vscode-api/blob/main/demo/src/features/debugger.ts
|
|
12
|
-
// The client configuration is generic and can be used for a another language
|
|
13
|
-
|
|
14
|
-
export const provideDebuggerExtensionConfig = (config: ConfigParams): ExtensionConfig => {
|
|
15
|
-
const filesOrContents = new Map<string, string | URL>();
|
|
16
|
-
filesOrContents.set('./extension.js', '// nothing');
|
|
17
|
-
|
|
18
|
-
return {
|
|
19
|
-
config: {
|
|
20
|
-
name: config.extensionName,
|
|
21
|
-
publisher: 'TypeFox',
|
|
22
|
-
version: '1.0.0',
|
|
23
|
-
engines: {
|
|
24
|
-
vscode: '*'
|
|
25
|
-
},
|
|
26
|
-
// A browser field is mandatory for the extension to be flagged as `web`
|
|
27
|
-
browser: 'extension.js',
|
|
28
|
-
contributes: {
|
|
29
|
-
debuggers: [
|
|
30
|
-
{
|
|
31
|
-
type: config.languageId,
|
|
32
|
-
label: 'Test',
|
|
33
|
-
languages: [config.languageId]
|
|
34
|
-
}
|
|
35
|
-
],
|
|
36
|
-
breakpoints: [
|
|
37
|
-
{
|
|
38
|
-
language: config.languageId
|
|
39
|
-
}
|
|
40
|
-
]
|
|
41
|
-
},
|
|
42
|
-
activationEvents: [
|
|
43
|
-
'onDebug'
|
|
44
|
-
]
|
|
45
|
-
},
|
|
46
|
-
filesOrContents
|
|
47
|
-
};
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export const configureDebugging = async (api: typeof vscode, config: ConfigParams) => {
|
|
51
|
-
class WebsocketDebugAdapter implements vscode.DebugAdapter {
|
|
52
|
-
private websocket: WebSocket;
|
|
53
|
-
|
|
54
|
-
constructor(websocket: WebSocket) {
|
|
55
|
-
this.websocket = websocket;
|
|
56
|
-
this.websocket.onmessage = (message) => {
|
|
57
|
-
this._onDidSendMessage.fire(JSON.parse(message.data));
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
_onDidSendMessage = new api.EventEmitter<vscode.DebugProtocolMessage>();
|
|
62
|
-
onDidSendMessage = this._onDidSendMessage.event;
|
|
63
|
-
|
|
64
|
-
handleMessage(message: vscode.DebugProtocolMessage): void {
|
|
65
|
-
// path with on Windows (Chrome/Firefox) arrive here with \\ and not like expected with /
|
|
66
|
-
// Chrome on Ubuntu behaves as expected
|
|
67
|
-
const msg = JSON.stringify(message).replaceAll('\\\\', '/');
|
|
68
|
-
this.websocket.send(msg);
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
dispose() {
|
|
72
|
-
this.websocket.close();
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
api.debug.registerDebugAdapterDescriptorFactory(config.languageId, {
|
|
77
|
-
async createDebugAdapterDescriptor() {
|
|
78
|
-
const websocket = new WebSocket(`${config.protocol}://${config.hostname}:${config.port}`);
|
|
79
|
-
|
|
80
|
-
await new Promise((resolve, reject) => {
|
|
81
|
-
websocket.onopen = resolve;
|
|
82
|
-
websocket.onerror = () =>
|
|
83
|
-
reject(new Error(`Unable to connect to debugger server. Run "${config.helpContainerCmd}"`));
|
|
84
|
-
});
|
|
85
|
-
|
|
86
|
-
const adapter = new WebsocketDebugAdapter(websocket);
|
|
87
|
-
|
|
88
|
-
const initMessage: InitMessage = {
|
|
89
|
-
id: 'init',
|
|
90
|
-
files: {},
|
|
91
|
-
// the default file is the one that will be used by the debugger
|
|
92
|
-
defaultFile: config.defaultFile,
|
|
93
|
-
debuggerExecCall: config.debuggerExecCall
|
|
94
|
-
};
|
|
95
|
-
for (const [name, fileDef] of config.files.entries()) {
|
|
96
|
-
console.log(`Found: ${name} Sending file: ${fileDef.path}`);
|
|
97
|
-
initMessage.files[name] = {
|
|
98
|
-
path: fileDef.path,
|
|
99
|
-
code: fileDef.code,
|
|
100
|
-
uri: fileDef.uri
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
websocket.send(JSON.stringify(initMessage));
|
|
104
|
-
|
|
105
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
106
|
-
adapter.onDidSendMessage((message: any) => {
|
|
107
|
-
if (message.type === 'event' && message.event === 'output') {
|
|
108
|
-
console.log('OUTPUT', message.body.output);
|
|
109
|
-
}
|
|
110
|
-
});
|
|
111
|
-
return new api.DebugAdapterInlineImplementation(adapter);
|
|
112
|
-
}
|
|
113
|
-
});
|
|
114
|
-
};
|
|
@@ -1,58 +0,0 @@
|
|
|
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 { RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override';
|
|
7
|
-
import { Uri } from 'vscode';
|
|
8
|
-
|
|
9
|
-
export type FileDefinition = {
|
|
10
|
-
path: string;
|
|
11
|
-
code: string;
|
|
12
|
-
uri: Uri;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export type InitMessage = {
|
|
16
|
-
id: 'init',
|
|
17
|
-
files: Record<string, FileDefinition>
|
|
18
|
-
defaultFile: string;
|
|
19
|
-
debuggerExecCall: string;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type ConfigParams = {
|
|
23
|
-
extensionName: string;
|
|
24
|
-
languageId: string;
|
|
25
|
-
documentSelector: string[];
|
|
26
|
-
homeDir: string;
|
|
27
|
-
workspaceRoot: string;
|
|
28
|
-
workspaceFile: Uri;
|
|
29
|
-
htmlContainer: HTMLElement;
|
|
30
|
-
protocol: 'ws' | 'wss';
|
|
31
|
-
hostname: string;
|
|
32
|
-
port: number;
|
|
33
|
-
files: Map<string, FileDefinition>;
|
|
34
|
-
defaultFile: string;
|
|
35
|
-
helpContainerCmd: string;
|
|
36
|
-
debuggerExecCall: string;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export const createDebugLaunchConfigFile = (workspacePath: string, type: string) => {
|
|
40
|
-
return new RegisteredMemoryFile(
|
|
41
|
-
Uri.file(`${workspacePath}/.vscode/launch.json`),
|
|
42
|
-
JSON.stringify(
|
|
43
|
-
{
|
|
44
|
-
version: '0.2.0',
|
|
45
|
-
configurations: [
|
|
46
|
-
{
|
|
47
|
-
name: 'Debugger: Lauch',
|
|
48
|
-
type,
|
|
49
|
-
request: 'attach',
|
|
50
|
-
}
|
|
51
|
-
]
|
|
52
|
-
},
|
|
53
|
-
null,
|
|
54
|
-
2
|
|
55
|
-
)
|
|
56
|
-
);
|
|
57
|
-
};
|
|
58
|
-
|