Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix worker configuration #526

Merged
merged 2 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/workers/editor.worker.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export * from 'vs/editor/editor.worker'
export * from 'vs/editor/common/services/editorSimpleWorker.esm.js'
11 changes: 1 addition & 10 deletions src/workers/languageDetection.worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import { create } from 'vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker'
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker'

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg)
}, create)

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data)
}
import 'vs/workbench/services/languageDetection/browser/languageDetectionSimpleWorker.esm.js'
11 changes: 1 addition & 10 deletions src/workers/localFileSearch.worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import { create } from 'vs/workbench/services/search/worker/localFileSearch'
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker'

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg)
}, create)

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data)
}
import 'vs/workbench/services/search/worker/localFileSearch.esm.js'
11 changes: 1 addition & 10 deletions src/workers/notebook.worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import { create } from 'vs/workbench/contrib/notebook/common/services/notebookSimpleWorker'
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker'

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg)
}, create)

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data)
}
import 'vs/workbench/contrib/notebook/common/services/notebookSimpleWorker.esm.js'
11 changes: 1 addition & 10 deletions src/workers/outputLinkComputer.worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker'
import { create } from 'vs/workbench/contrib/output/common/outputLinkComputer'

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg)
}, create)

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data)
}
import 'vs/workbench/contrib/output/common/outputLinkComputer.esm.js'
11 changes: 1 addition & 10 deletions src/workers/textmate.worker.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
import { create } from 'vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker'
import { SimpleWorkerServer } from 'vs/base/common/worker/simpleWorker'

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg)
}, create)

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data)
}
import 'vs/workbench/services/textMate/browser/backgroundTokenization/worker/textMateTokenizationWorker.worker.esm.js'
67 changes: 67 additions & 0 deletions vscode-paches/0058-fix-fix-missing-worker-factory.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Lo=C3=AFc=20Mangeonjean?= <[email protected]>
Date: Tue, 29 Oct 2024 12:00:15 +0100
Subject: [PATCH] fix: fix missing worker factory

---
.../common/services/editorSimpleWorker.esm.ts | 5 +----
.../common/services/editorWorkerBootstrap.ts | 15 +++------------
2 files changed, 4 insertions(+), 16 deletions(-)

diff --git a/src/vs/editor/common/services/editorSimpleWorker.esm.ts b/src/vs/editor/common/services/editorSimpleWorker.esm.ts
index 8d0e18738f4..795f00d68c3 100644
--- a/src/vs/editor/common/services/editorSimpleWorker.esm.ts
+++ b/src/vs/editor/common/services/editorSimpleWorker.esm.ts
@@ -3,7 +3,4 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

-import { create } from './editorSimpleWorker.js';
-import { bootstrapSimpleEditorWorker } from './editorWorkerBootstrap.js';
-
-bootstrapSimpleEditorWorker(create);
+import './editorWorkerBootstrap.js';
diff --git a/src/vs/editor/common/services/editorWorkerBootstrap.ts b/src/vs/editor/common/services/editorWorkerBootstrap.ts
index f754fe8fd4a..27bb817ac9b 100644
--- a/src/vs/editor/common/services/editorWorkerBootstrap.ts
+++ b/src/vs/editor/common/services/editorWorkerBootstrap.ts
@@ -4,7 +4,7 @@
*--------------------------------------------------------------------------------------------*/

import { IWorkerServer, SimpleWorkerServer } from '../../../base/common/worker/simpleWorker.js';
-import { EditorSimpleWorker } from './editorSimpleWorker.js';
+import { EditorSimpleWorker, IForeignModuleFactory } from './editorSimpleWorker.js';
import { EditorWorkerHost } from './editorWorkerHost.js';

type MessageEvent = {
@@ -18,7 +18,7 @@ declare const globalThis: {

let initialized = false;

-export function initialize(factory: any) {
+export function initialize(factory: IForeignModuleFactory | null) {
if (initialized) {
return;
}
@@ -26,7 +26,7 @@ export function initialize(factory: any) {

const simpleWorker = new SimpleWorkerServer((msg) => {
globalThis.postMessage(msg);
- }, (workerServer: IWorkerServer) => new EditorSimpleWorker(EditorWorkerHost.getChannel(workerServer), null));
+ }, (workerServer: IWorkerServer) => new EditorSimpleWorker(EditorWorkerHost.getChannel(workerServer), factory));

globalThis.onmessage = (e: MessageEvent) => {
simpleWorker.onmessage(e.data);
@@ -40,12 +40,3 @@ globalThis.onmessage = (e: MessageEvent) => {
}
};

-type CreateFunction<C, D, R = any> = (ctx: C, data: D) => R;
-
-export function bootstrapSimpleEditorWorker<C, D, R>(createFn: CreateFunction<C, D, R>) {
- globalThis.onmessage = () => {
- initialize((ctx: C, createData: D) => {
- return createFn.call(self, ctx, createData);
- });
- };
-}