// This Source Code Form is subject to the terms of the Mozilla Public
// License, v2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/
export class ArtificialWorker extends EventTarget {
    #selfTarget = new EventTarget();
    // Post message from main to worker
    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
    postMessage(data, _transferable) {
        const event = new MessageEvent('message', { data });
        this.#selfTarget.dispatchEvent(event);
    }
    // Listen for worker-to-main messages
    // @ts-expect-error Make it typed
    addEventListener(type, callback) {
        super.addEventListener(type, callback);
    }
    // Post message from worker to main
    // eslint-disable-next-line @typescript-eslint/explicit-module-boundary-types
    postMessageToMain(data, _transferable) {
        const event = new MessageEvent('message', { data });
        super.dispatchEvent(event);
    }
    // Listen for main-to-worker messages
    // @ts-expect-error Make it typed
    addEventListenerFromMain(type, callback) {
        this.#selfTarget.addEventListener(type, callback);
    }
}
//# sourceMappingURL=artificial-worker.js.map