mirror of
https://github.com/ckaczor/azuredatastudio.git
synced 2026-01-30 09:35:39 -05:00
33 lines
1.0 KiB
TypeScript
33 lines
1.0 KiB
TypeScript
/*---------------------------------------------------------------------------------------------
|
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
* Licensed under the Source EULA. 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);
|
|
}
|
|
};
|