Merge pull request #15500 from Snuffleupagus/LoopbackPort-rm-export

[api-minor] Stop exposing the `LoopbackPort` class in the API
This commit is contained in:
Tim van der Meij 2022-09-24 14:45:59 +02:00 committed by GitHub
commit 4cedbca365
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 12 deletions

View File

@ -1853,34 +1853,33 @@ class PDFPageProxy {
}
class LoopbackPort {
constructor() {
this._listeners = [];
this._deferred = Promise.resolve();
}
#listeners = [];
#deferred = Promise.resolve();
postMessage(obj, transfers) {
const event = {
data: structuredClone(obj, transfers),
};
this._deferred.then(() => {
for (const listener of this._listeners) {
this.#deferred.then(() => {
for (const listener of this.#listeners) {
listener.call(this, event);
}
});
}
addEventListener(name, listener) {
this._listeners.push(listener);
this.#listeners.push(listener);
}
removeEventListener(name, listener) {
const i = this._listeners.indexOf(listener);
this._listeners.splice(i, 1);
const i = this.#listeners.indexOf(listener);
this.#listeners.splice(i, 1);
}
terminate() {
this._listeners.length = 0;
this.#listeners.length = 0;
}
}

View File

@ -43,7 +43,6 @@ import {
import {
build,
getDocument,
LoopbackPort,
PDFDataRangeTransport,
PDFWorker,
setPDFNetworkStreamFactory,
@ -128,7 +127,6 @@ export {
InvalidPDFException,
isPdfFile,
loadScript,
LoopbackPort,
MissingPDFException,
OPS,
PasswordResponses,