forked from microsoft/vscode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy patheditor.worker.ts
More file actions
32 lines (26 loc) · 1.01 KB
/
editor.worker.ts
File metadata and controls
32 lines (26 loc) · 1.01 KB
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
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker';
import { EditorSimpleWorkerImpl } from 'vs/editor/common/services/editorSimpleWorker';
let initialized = false;
export function initialize(foreignModule: any) {
if (initialized) {
return;
}
initialized = true;
const editorWorker = new EditorSimpleWorkerImpl(foreignModule);
const simpleWorker = new SimpleWorkerServer((msg) => {
(<any>self).postMessage(msg);
}, editorWorker);
self.onmessage = (e) => {
simpleWorker.onmessage(e.data);
};
}
self.onmessage = (e) => {
// Ignore first message in this case and initialize if not yet initialized
if (!initialized) {
initialize(null);
}
};