Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
bpasero committed Sep 30, 2024
1 parent 946df04 commit ddec62c
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
12 changes: 6 additions & 6 deletions src/vs/base/browser/defaultWorkerFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class WebWorker extends Disposable implements IWorker {
private readonly label: string;
private worker: Promise<Worker> | null;

constructor(esmWorkerLocation: URI | undefined, amdModuleId: string, id: number, label: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void) {
constructor(esmWorkerLocation: URI | undefined, moduleId: string, id: number, label: string, onMessageCallback: IWorkerCallback, onErrorCallback: (err: any) => void) {
super();
this.id = id;
this.label = label;
Expand All @@ -129,7 +129,7 @@ class WebWorker extends Disposable implements IWorker {
} else {
this.worker = Promise.resolve(workerOrPromise);
}
this.postMessage(amdModuleId, []);
this.postMessage(moduleId, []);
this.worker.then((w) => {
w.onmessage = function (ev) {
onMessageCallback(ev.data);
Expand Down Expand Up @@ -171,10 +171,10 @@ export class WorkerDescriptor implements IWorkerDescriptor {
public readonly esmModuleLocation: URI | undefined;

constructor(
public readonly amdModuleId: string,
public readonly moduleId: string,
readonly label: string | undefined,
) {
this.esmModuleLocation = FileAccess.asBrowserUri(`${amdModuleId}.esm.js` as AppResourcePath);
this.esmModuleLocation = FileAccess.asBrowserUri(`${moduleId}.js` as AppResourcePath);
}
}

Expand All @@ -194,15 +194,15 @@ class DefaultWorkerFactory implements IWorkerFactory {
throw this._webWorkerFailedBeforeError;
}

return new WebWorker(desc.esmModuleLocation, desc.amdModuleId, workerId, desc.label || 'anonymous' + workerId, onMessageCallback, (err) => {
return new WebWorker(desc.esmModuleLocation, desc.moduleId, workerId, desc.label || 'anonymous' + workerId, onMessageCallback, (err) => {
logOnceWebWorkerWarning(err);
this._webWorkerFailedBeforeError = err;
onErrorCallback(err);
});
}
}

export function createWebWorker<T extends object>(amdModuleId: string, label: string | undefined): IWorkerClient<T>;
export function createWebWorker<T extends object>(moduleId: string, label: string | undefined): IWorkerClient<T>;
export function createWebWorker<T extends object>(workerDescriptor: IWorkerDescriptor): IWorkerClient<T>;
export function createWebWorker<T extends object>(arg0: string | IWorkerDescriptor, arg1?: string | undefined): IWorkerClient<T> {
const workerDescriptor = (typeof arg0 === 'string' ? new WorkerDescriptor(arg0, arg1) : arg0);
Expand Down
8 changes: 4 additions & 4 deletions src/vs/base/common/worker/simpleWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface IWorkerFactory {
}

export interface IWorkerDescriptor {
readonly amdModuleId: string;
readonly moduleId: string;
readonly esmModuleLocation: URI | undefined;
readonly label: string | undefined;
}
Expand Down Expand Up @@ -332,7 +332,7 @@ export class SimpleWorkerClient<W extends object> extends Disposable implements

this._worker = this._register(workerFactory.create(
{
amdModuleId: 'vs/base/common/worker/simpleWorker',
moduleId: 'vs/base/common/worker/simpleWorker',
esmModuleLocation: workerDescriptor.esmModuleLocation,
label: workerDescriptor.label
},
Expand Down Expand Up @@ -375,12 +375,12 @@ export class SimpleWorkerClient<W extends object> extends Disposable implements
this._onModuleLoaded = this._protocol.sendMessage(DEFAULT_CHANNEL, INITIALIZE, [
this._worker.getId(),
JSON.parse(JSON.stringify(loaderConfiguration)),
workerDescriptor.amdModuleId,
workerDescriptor.moduleId,
]);

this.proxy = this._protocol.createProxyToRemoteChannel(DEFAULT_CHANNEL, async () => { await this._onModuleLoaded; });
this._onModuleLoaded.catch((e) => {
this._onError('Worker failed to load ' + workerDescriptor.amdModuleId, e);
this._onError('Worker failed to load ' + workerDescriptor.moduleId, e);
});
}

Expand Down
2 changes: 1 addition & 1 deletion src/vs/editor/standalone/browser/standaloneWebWorker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ class MonacoWebWorkerImpl<T extends object> extends EditorWorkerClient implement

constructor(modelService: IModelService, opts: IWebWorkerOptions) {
const workerDescriptor: IWorkerDescriptor = {
amdModuleId: standaloneEditorWorkerDescriptor.amdModuleId,
moduleId: standaloneEditorWorkerDescriptor.moduleId,
esmModuleLocation: standaloneEditorWorkerDescriptor.esmModuleLocation,
label: opts.label,
};
Expand Down

0 comments on commit ddec62c

Please sign in to comment.