forked from TypeFox/monaco-languageclient
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
38 lines (34 loc) · 1.75 KB
/
main.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/* --------------------------------------------------------------------------------------------
* Copyright (c) 2024 TypeFox and others.
* Licensed under the MIT License. See LICENSE in the package root for license information.
* ------------------------------------------------------------------------------------------ */
import * as vscode from 'vscode';
// this is required syntax highlighting
import '@codingame/monaco-vscode-python-default-extension';
import { disposeEditor, startEditor } from '../../common/example-apps-common.js';
import { RegisteredFileSystemProvider, registerFileSystemOverlay, RegisteredMemoryFile } from '@codingame/monaco-vscode-files-service-override';
import { createUserConfig } from './config.js';
import { useWorkerFactory } from 'monaco-editor-wrapper/workerFactory';
export const configureMonacoWorkers = () => {
useWorkerFactory({
basePath: '../../../node_modules'
});
};
export const runPythonWrapper = () => {
const code = 'print("Hello, World!")';
const fileSystemProvider = new RegisteredFileSystemProvider(false);
fileSystemProvider.registerFile(new RegisteredMemoryFile(vscode.Uri.file('/workspace/hello.py'), code));
registerFileSystemOverlay(1, fileSystemProvider);
try {
const userConfig = createUserConfig(code);
const htmlElement = document.getElementById('monaco-editor-root');
document.querySelector('#button-start')?.addEventListener('click', async () => {
await startEditor(userConfig, htmlElement, code);
});
document.querySelector('#button-dispose')?.addEventListener('click', async () => {
await disposeEditor(userConfig.wrapperConfig.editorAppConfig.useDiffEditor);
});
} catch (e) {
console.error(e);
}
};