Change the createPromiseCapability
helper function into a PromiseCapability
class
This is not only slightly more compact, but it also simplifies the handling of the `settled` getter.
This commit is contained in:
parent
f9c2a8d437
commit
317abd6d07
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { arrayBuffersToBytes, MissingDataException } from "./core_utils.js";
|
import { arrayBuffersToBytes, MissingDataException } from "./core_utils.js";
|
||||||
import { assert, createPromiseCapability } from "../shared/util.js";
|
import { assert, PromiseCapability } from "../shared/util.js";
|
||||||
import { Stream } from "./stream.js";
|
import { Stream } from "./stream.js";
|
||||||
|
|
||||||
class ChunkedStream extends Stream {
|
class ChunkedStream extends Stream {
|
||||||
@ -275,7 +275,7 @@ class ChunkedStreamManager {
|
|||||||
this.progressiveDataLength = 0;
|
this.progressiveDataLength = 0;
|
||||||
this.aborted = false;
|
this.aborted = false;
|
||||||
|
|
||||||
this._loadedStreamCapability = createPromiseCapability();
|
this._loadedStreamCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
sendRequest(begin, end) {
|
sendRequest(begin, end) {
|
||||||
@ -349,7 +349,7 @@ class ChunkedStreamManager {
|
|||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
const capability = createPromiseCapability();
|
const capability = new PromiseCapability();
|
||||||
this._promisesByRequest.set(requestId, capability);
|
this._promisesByRequest.set(requestId, capability);
|
||||||
|
|
||||||
const chunksToRequest = [];
|
const chunksToRequest = [];
|
||||||
|
@ -18,7 +18,6 @@ import {
|
|||||||
AbortException,
|
AbortException,
|
||||||
assert,
|
assert,
|
||||||
CMapCompressionType,
|
CMapCompressionType,
|
||||||
createPromiseCapability,
|
|
||||||
FONT_IDENTITY_MATRIX,
|
FONT_IDENTITY_MATRIX,
|
||||||
FormatError,
|
FormatError,
|
||||||
IDENTITY_MATRIX,
|
IDENTITY_MATRIX,
|
||||||
@ -26,6 +25,7 @@ import {
|
|||||||
isArrayEqual,
|
isArrayEqual,
|
||||||
normalizeUnicode,
|
normalizeUnicode,
|
||||||
OPS,
|
OPS,
|
||||||
|
PromiseCapability,
|
||||||
shadow,
|
shadow,
|
||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
TextRenderingMode,
|
TextRenderingMode,
|
||||||
@ -1253,7 +1253,7 @@ class PartialEvaluator {
|
|||||||
return this.fontCache.get(font.cacheKey);
|
return this.fontCache.get(font.cacheKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
const fontCapability = createPromiseCapability();
|
const fontCapability = new PromiseCapability();
|
||||||
|
|
||||||
let preEvaluatedFont;
|
let preEvaluatedFont;
|
||||||
try {
|
try {
|
||||||
|
@ -16,12 +16,12 @@
|
|||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
assert,
|
assert,
|
||||||
createPromiseCapability,
|
|
||||||
getVerbosityLevel,
|
getVerbosityLevel,
|
||||||
info,
|
info,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
PasswordException,
|
PasswordException,
|
||||||
|
PromiseCapability,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
@ -46,7 +46,7 @@ class WorkerTask {
|
|||||||
constructor(name) {
|
constructor(name) {
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.terminated = false;
|
this.terminated = false;
|
||||||
this._capability = createPromiseCapability();
|
this._capability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
get finished() {
|
get finished() {
|
||||||
@ -228,7 +228,7 @@ class WorkerMessageHandler {
|
|||||||
password,
|
password,
|
||||||
rangeChunkSize,
|
rangeChunkSize,
|
||||||
};
|
};
|
||||||
const pdfManagerCapability = createPromiseCapability();
|
const pdfManagerCapability = new PromiseCapability();
|
||||||
let newPdfManager;
|
let newPdfManager;
|
||||||
|
|
||||||
if (data) {
|
if (data) {
|
||||||
|
@ -21,7 +21,6 @@ import {
|
|||||||
AbortException,
|
AbortException,
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
assert,
|
assert,
|
||||||
createPromiseCapability,
|
|
||||||
getVerbosityLevel,
|
getVerbosityLevel,
|
||||||
info,
|
info,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
@ -29,6 +28,7 @@ import {
|
|||||||
MAX_IMAGE_SIZE_TO_CACHE,
|
MAX_IMAGE_SIZE_TO_CACHE,
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
PasswordException,
|
PasswordException,
|
||||||
|
PromiseCapability,
|
||||||
RenderingIntentFlag,
|
RenderingIntentFlag,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
shadow,
|
shadow,
|
||||||
@ -588,7 +588,7 @@ class PDFDocumentLoadingTask {
|
|||||||
static #docId = 0;
|
static #docId = 0;
|
||||||
|
|
||||||
constructor() {
|
constructor() {
|
||||||
this._capability = createPromiseCapability();
|
this._capability = new PromiseCapability();
|
||||||
this._transport = null;
|
this._transport = null;
|
||||||
this._worker = null;
|
this._worker = null;
|
||||||
|
|
||||||
@ -675,7 +675,7 @@ class PDFDataRangeTransport {
|
|||||||
this._progressListeners = [];
|
this._progressListeners = [];
|
||||||
this._progressiveReadListeners = [];
|
this._progressiveReadListeners = [];
|
||||||
this._progressiveDoneListeners = [];
|
this._progressiveDoneListeners = [];
|
||||||
this._readyCapability = createPromiseCapability();
|
this._readyCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1460,7 +1460,7 @@ class PDFPageProxy {
|
|||||||
// If there's no displayReadyCapability yet, then the operatorList
|
// If there's no displayReadyCapability yet, then the operatorList
|
||||||
// was never requested before. Make the request and create the promise.
|
// was never requested before. Make the request and create the promise.
|
||||||
if (!intentState.displayReadyCapability) {
|
if (!intentState.displayReadyCapability) {
|
||||||
intentState.displayReadyCapability = createPromiseCapability();
|
intentState.displayReadyCapability = new PromiseCapability();
|
||||||
intentState.operatorList = {
|
intentState.operatorList = {
|
||||||
fnArray: [],
|
fnArray: [],
|
||||||
argsArray: [],
|
argsArray: [],
|
||||||
@ -1578,7 +1578,7 @@ class PDFPageProxy {
|
|||||||
if (!intentState.opListReadCapability) {
|
if (!intentState.opListReadCapability) {
|
||||||
opListTask = Object.create(null);
|
opListTask = Object.create(null);
|
||||||
opListTask.operatorListChanged = operatorListChanged;
|
opListTask.operatorListChanged = operatorListChanged;
|
||||||
intentState.opListReadCapability = createPromiseCapability();
|
intentState.opListReadCapability = new PromiseCapability();
|
||||||
(intentState.renderTasks ||= new Set()).add(opListTask);
|
(intentState.renderTasks ||= new Set()).add(opListTask);
|
||||||
intentState.operatorList = {
|
intentState.operatorList = {
|
||||||
fnArray: [],
|
fnArray: [],
|
||||||
@ -2054,7 +2054,7 @@ class PDFWorker {
|
|||||||
this.destroyed = false;
|
this.destroyed = false;
|
||||||
this.verbosity = verbosity;
|
this.verbosity = verbosity;
|
||||||
|
|
||||||
this._readyCapability = createPromiseCapability();
|
this._readyCapability = new PromiseCapability();
|
||||||
this._port = null;
|
this._port = null;
|
||||||
this._webWorker = null;
|
this._webWorker = null;
|
||||||
this._messageHandler = null;
|
this._messageHandler = null;
|
||||||
@ -2388,7 +2388,7 @@ class WorkerTransport {
|
|||||||
this._networkStream = networkStream;
|
this._networkStream = networkStream;
|
||||||
this._fullReader = null;
|
this._fullReader = null;
|
||||||
this._lastProgress = null;
|
this._lastProgress = null;
|
||||||
this.downloadInfoCapability = createPromiseCapability();
|
this.downloadInfoCapability = new PromiseCapability();
|
||||||
|
|
||||||
this.setupMessageHandler();
|
this.setupMessageHandler();
|
||||||
|
|
||||||
@ -2487,7 +2487,7 @@ class WorkerTransport {
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.destroyed = true;
|
this.destroyed = true;
|
||||||
this.destroyCapability = createPromiseCapability();
|
this.destroyCapability = new PromiseCapability();
|
||||||
|
|
||||||
if (this._passwordCapability) {
|
if (this._passwordCapability) {
|
||||||
this._passwordCapability.reject(
|
this._passwordCapability.reject(
|
||||||
@ -2581,7 +2581,7 @@ class WorkerTransport {
|
|||||||
});
|
});
|
||||||
|
|
||||||
messageHandler.on("ReaderHeadersReady", data => {
|
messageHandler.on("ReaderHeadersReady", data => {
|
||||||
const headersCapability = createPromiseCapability();
|
const headersCapability = new PromiseCapability();
|
||||||
const fullReader = this._fullReader;
|
const fullReader = this._fullReader;
|
||||||
fullReader.headersReady.then(() => {
|
fullReader.headersReady.then(() => {
|
||||||
// If stream or range are disabled, it's our only way to report
|
// If stream or range are disabled, it's our only way to report
|
||||||
@ -2696,7 +2696,7 @@ class WorkerTransport {
|
|||||||
});
|
});
|
||||||
|
|
||||||
messageHandler.on("PasswordRequest", exception => {
|
messageHandler.on("PasswordRequest", exception => {
|
||||||
this._passwordCapability = createPromiseCapability();
|
this._passwordCapability = new PromiseCapability();
|
||||||
|
|
||||||
if (loadingTask.onPassword) {
|
if (loadingTask.onPassword) {
|
||||||
const updatePassword = password => {
|
const updatePassword = password => {
|
||||||
@ -3117,7 +3117,7 @@ class PDFObjects {
|
|||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
return (this.#objs[objId] = {
|
return (this.#objs[objId] = {
|
||||||
capability: createPromiseCapability(),
|
capability: new PromiseCapability(),
|
||||||
data: null,
|
data: null,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -3277,7 +3277,7 @@ class InternalRenderTask {
|
|||||||
this._useRequestAnimationFrame =
|
this._useRequestAnimationFrame =
|
||||||
useRequestAnimationFrame === true && typeof window !== "undefined";
|
useRequestAnimationFrame === true && typeof window !== "undefined";
|
||||||
this.cancelled = false;
|
this.cancelled = false;
|
||||||
this.capability = createPromiseCapability();
|
this.capability = new PromiseCapability();
|
||||||
this.task = new RenderTask(this);
|
this.task = new RenderTask(this);
|
||||||
// caching this-bound methods
|
// caching this-bound methods
|
||||||
this._cancelBound = this.cancel.bind(this);
|
this._cancelBound = this.cancel.bind(this);
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
assert,
|
assert,
|
||||||
createPromiseCapability,
|
PromiseCapability,
|
||||||
warn,
|
warn,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import {
|
import {
|
||||||
@ -118,7 +118,7 @@ class PDFFetchStreamReader {
|
|||||||
const source = stream.source;
|
const source = stream.source;
|
||||||
this._withCredentials = source.withCredentials || false;
|
this._withCredentials = source.withCredentials || false;
|
||||||
this._contentLength = source.length;
|
this._contentLength = source.length;
|
||||||
this._headersCapability = createPromiseCapability();
|
this._headersCapability = new PromiseCapability();
|
||||||
this._disableRange = source.disableRange || false;
|
this._disableRange = source.disableRange || false;
|
||||||
this._rangeChunkSize = source.rangeChunkSize;
|
this._rangeChunkSize = source.rangeChunkSize;
|
||||||
if (!this._rangeChunkSize && !this._disableRange) {
|
if (!this._rangeChunkSize && !this._disableRange) {
|
||||||
@ -224,7 +224,7 @@ class PDFFetchStreamRangeReader {
|
|||||||
this._loaded = 0;
|
this._loaded = 0;
|
||||||
const source = stream.source;
|
const source = stream.source;
|
||||||
this._withCredentials = source.withCredentials || false;
|
this._withCredentials = source.withCredentials || false;
|
||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = new PromiseCapability();
|
||||||
this._isStreamingSupported = !source.disableStream;
|
this._isStreamingSupported = !source.disableStream;
|
||||||
|
|
||||||
this._abortController = new AbortController();
|
this._abortController = new AbortController();
|
||||||
|
@ -13,11 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import {
|
import { assert, PromiseCapability, stringToBytes } from "../shared/util.js";
|
||||||
assert,
|
|
||||||
createPromiseCapability,
|
|
||||||
stringToBytes,
|
|
||||||
} from "../shared/util.js";
|
|
||||||
import {
|
import {
|
||||||
createResponseStatusError,
|
createResponseStatusError,
|
||||||
extractFilenameFromHeader,
|
extractFilenameFromHeader,
|
||||||
@ -259,7 +255,7 @@ class PDFNetworkStreamFullRequestReader {
|
|||||||
};
|
};
|
||||||
this._url = source.url;
|
this._url = source.url;
|
||||||
this._fullRequestId = manager.requestFull(args);
|
this._fullRequestId = manager.requestFull(args);
|
||||||
this._headersReceivedCapability = createPromiseCapability();
|
this._headersReceivedCapability = new PromiseCapability();
|
||||||
this._disableRange = source.disableRange || false;
|
this._disableRange = source.disableRange || false;
|
||||||
this._contentLength = source.length; // Optional
|
this._contentLength = source.length; // Optional
|
||||||
this._rangeChunkSize = source.rangeChunkSize;
|
this._rangeChunkSize = source.rangeChunkSize;
|
||||||
@ -380,7 +376,7 @@ class PDFNetworkStreamFullRequestReader {
|
|||||||
if (this._done) {
|
if (this._done) {
|
||||||
return { value: undefined, done: true };
|
return { value: undefined, done: true };
|
||||||
}
|
}
|
||||||
const requestCapability = createPromiseCapability();
|
const requestCapability = new PromiseCapability();
|
||||||
this._requests.push(requestCapability);
|
this._requests.push(requestCapability);
|
||||||
return requestCapability.promise;
|
return requestCapability.promise;
|
||||||
}
|
}
|
||||||
@ -471,7 +467,7 @@ class PDFNetworkStreamRangeRequestReader {
|
|||||||
if (this._done) {
|
if (this._done) {
|
||||||
return { value: undefined, done: true };
|
return { value: undefined, done: true };
|
||||||
}
|
}
|
||||||
const requestCapability = createPromiseCapability();
|
const requestCapability = new PromiseCapability();
|
||||||
this._requests.push(requestCapability);
|
this._requests.push(requestCapability);
|
||||||
return requestCapability.promise;
|
return requestCapability.promise;
|
||||||
}
|
}
|
||||||
|
@ -17,8 +17,8 @@
|
|||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
assert,
|
assert,
|
||||||
createPromiseCapability,
|
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
|
PromiseCapability,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import {
|
import {
|
||||||
extractFilenameFromHeader,
|
extractFilenameFromHeader,
|
||||||
@ -124,8 +124,8 @@ class BaseFullReader {
|
|||||||
this._isRangeSupported = !source.disableRange;
|
this._isRangeSupported = !source.disableRange;
|
||||||
|
|
||||||
this._readableStream = null;
|
this._readableStream = null;
|
||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = new PromiseCapability();
|
||||||
this._headersCapability = createPromiseCapability();
|
this._headersCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
get headersReady() {
|
get headersReady() {
|
||||||
@ -159,7 +159,7 @@ class BaseFullReader {
|
|||||||
|
|
||||||
const chunk = this._readableStream.read();
|
const chunk = this._readableStream.read();
|
||||||
if (chunk === null) {
|
if (chunk === null) {
|
||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = new PromiseCapability();
|
||||||
return this.read();
|
return this.read();
|
||||||
}
|
}
|
||||||
this._loaded += chunk.length;
|
this._loaded += chunk.length;
|
||||||
@ -226,7 +226,7 @@ class BaseRangeReader {
|
|||||||
this.onProgress = null;
|
this.onProgress = null;
|
||||||
this._loaded = 0;
|
this._loaded = 0;
|
||||||
this._readableStream = null;
|
this._readableStream = null;
|
||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = new PromiseCapability();
|
||||||
const source = stream.source;
|
const source = stream.source;
|
||||||
this._isStreamingSupported = !source.disableStream;
|
this._isStreamingSupported = !source.disableStream;
|
||||||
}
|
}
|
||||||
@ -246,7 +246,7 @@ class BaseRangeReader {
|
|||||||
|
|
||||||
const chunk = this._readableStream.read();
|
const chunk = this._readableStream.read();
|
||||||
if (chunk === null) {
|
if (chunk === null) {
|
||||||
this._readCapability = createPromiseCapability();
|
this._readCapability = new PromiseCapability();
|
||||||
return this.read();
|
return this.read();
|
||||||
}
|
}
|
||||||
this._loaded += chunk.length;
|
this._loaded += chunk.length;
|
||||||
|
@ -18,8 +18,8 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
createPromiseCapability,
|
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
|
PromiseCapability,
|
||||||
Util,
|
Util,
|
||||||
} from "../shared/util.js";
|
} from "../shared/util.js";
|
||||||
import { deprecated, setLayerDimensions } from "./display_utils.js";
|
import { deprecated, setLayerDimensions } from "./display_utils.js";
|
||||||
@ -317,7 +317,7 @@ class TextLayerRenderTask {
|
|||||||
this._reader = null;
|
this._reader = null;
|
||||||
this._textDivProperties = textDivProperties || new WeakMap();
|
this._textDivProperties = textDivProperties || new WeakMap();
|
||||||
this._canceled = false;
|
this._canceled = false;
|
||||||
this._capability = createPromiseCapability();
|
this._capability = new PromiseCapability();
|
||||||
this._layoutTextParams = {
|
this._layoutTextParams = {
|
||||||
prevFontSize: null,
|
prevFontSize: null,
|
||||||
prevFontFamily: null,
|
prevFontFamily: null,
|
||||||
@ -417,7 +417,7 @@ class TextLayerRenderTask {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_render() {
|
_render() {
|
||||||
const capability = createPromiseCapability();
|
const capability = new PromiseCapability();
|
||||||
let styleCache = Object.create(null);
|
let styleCache = Object.create(null);
|
||||||
|
|
||||||
if (this._isReadableStream) {
|
if (this._isReadableStream) {
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { assert, createPromiseCapability } from "../shared/util.js";
|
import { assert, PromiseCapability } from "../shared/util.js";
|
||||||
import { isPdfFile } from "./display_utils.js";
|
import { isPdfFile } from "./display_utils.js";
|
||||||
|
|
||||||
/** @implements {IPDFStream} */
|
/** @implements {IPDFStream} */
|
||||||
@ -235,7 +235,7 @@ class PDFDataTransportStreamReader {
|
|||||||
if (this._done) {
|
if (this._done) {
|
||||||
return { value: undefined, done: true };
|
return { value: undefined, done: true };
|
||||||
}
|
}
|
||||||
const requestCapability = createPromiseCapability();
|
const requestCapability = new PromiseCapability();
|
||||||
this._requests.push(requestCapability);
|
this._requests.push(requestCapability);
|
||||||
return requestCapability.promise;
|
return requestCapability.promise;
|
||||||
}
|
}
|
||||||
@ -300,7 +300,7 @@ class PDFDataTransportStreamRangeReader {
|
|||||||
if (this._done) {
|
if (this._done) {
|
||||||
return { value: undefined, done: true };
|
return { value: undefined, done: true };
|
||||||
}
|
}
|
||||||
const requestCapability = createPromiseCapability();
|
const requestCapability = new PromiseCapability();
|
||||||
this._requests.push(requestCapability);
|
this._requests.push(requestCapability);
|
||||||
return requestCapability.promise;
|
return requestCapability.promise;
|
||||||
}
|
}
|
||||||
|
@ -30,7 +30,6 @@ import {
|
|||||||
AnnotationEditorType,
|
AnnotationEditorType,
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
CMapCompressionType,
|
CMapCompressionType,
|
||||||
createPromiseCapability,
|
|
||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
@ -39,6 +38,7 @@ import {
|
|||||||
OPS,
|
OPS,
|
||||||
PasswordResponses,
|
PasswordResponses,
|
||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
|
PromiseCapability,
|
||||||
shadow,
|
shadow,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
Util,
|
Util,
|
||||||
@ -88,7 +88,6 @@ export {
|
|||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
build,
|
build,
|
||||||
CMapCompressionType,
|
CMapCompressionType,
|
||||||
createPromiseCapability,
|
|
||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
getDocument,
|
getDocument,
|
||||||
@ -109,6 +108,7 @@ export {
|
|||||||
PDFWorker,
|
PDFWorker,
|
||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
|
PromiseCapability,
|
||||||
RenderingCancelledException,
|
RenderingCancelledException,
|
||||||
renderTextLayer,
|
renderTextLayer,
|
||||||
setLayerDimensions,
|
setLayerDimensions,
|
||||||
|
@ -16,9 +16,9 @@
|
|||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
assert,
|
assert,
|
||||||
createPromiseCapability,
|
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
PasswordException,
|
PasswordException,
|
||||||
|
PromiseCapability,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
UnknownErrorException,
|
UnknownErrorException,
|
||||||
unreachable,
|
unreachable,
|
||||||
@ -190,7 +190,7 @@ class MessageHandler {
|
|||||||
*/
|
*/
|
||||||
sendWithPromise(actionName, data, transfers) {
|
sendWithPromise(actionName, data, transfers) {
|
||||||
const callbackId = this.callbackId++;
|
const callbackId = this.callbackId++;
|
||||||
const capability = createPromiseCapability();
|
const capability = new PromiseCapability();
|
||||||
this.callbackCapabilities[callbackId] = capability;
|
this.callbackCapabilities[callbackId] = capability;
|
||||||
try {
|
try {
|
||||||
this.comObj.postMessage(
|
this.comObj.postMessage(
|
||||||
@ -228,7 +228,7 @@ class MessageHandler {
|
|||||||
return new ReadableStream(
|
return new ReadableStream(
|
||||||
{
|
{
|
||||||
start: controller => {
|
start: controller => {
|
||||||
const startCapability = createPromiseCapability();
|
const startCapability = new PromiseCapability();
|
||||||
this.streamControllers[streamId] = {
|
this.streamControllers[streamId] = {
|
||||||
controller,
|
controller,
|
||||||
startCall: startCapability,
|
startCall: startCapability,
|
||||||
@ -252,7 +252,7 @@ class MessageHandler {
|
|||||||
},
|
},
|
||||||
|
|
||||||
pull: controller => {
|
pull: controller => {
|
||||||
const pullCapability = createPromiseCapability();
|
const pullCapability = new PromiseCapability();
|
||||||
this.streamControllers[streamId].pullCall = pullCapability;
|
this.streamControllers[streamId].pullCall = pullCapability;
|
||||||
comObj.postMessage({
|
comObj.postMessage({
|
||||||
sourceName,
|
sourceName,
|
||||||
@ -268,7 +268,7 @@ class MessageHandler {
|
|||||||
|
|
||||||
cancel: reason => {
|
cancel: reason => {
|
||||||
assert(reason instanceof Error, "cancel must have a valid reason");
|
assert(reason instanceof Error, "cancel must have a valid reason");
|
||||||
const cancelCapability = createPromiseCapability();
|
const cancelCapability = new PromiseCapability();
|
||||||
this.streamControllers[streamId].cancelCall = cancelCapability;
|
this.streamControllers[streamId].cancelCall = cancelCapability;
|
||||||
this.streamControllers[streamId].isClosed = true;
|
this.streamControllers[streamId].isClosed = true;
|
||||||
comObj.postMessage({
|
comObj.postMessage({
|
||||||
@ -305,7 +305,7 @@ class MessageHandler {
|
|||||||
// so when it changes from positive to negative,
|
// so when it changes from positive to negative,
|
||||||
// set ready as unresolved promise.
|
// set ready as unresolved promise.
|
||||||
if (lastDesiredSize > 0 && this.desiredSize <= 0) {
|
if (lastDesiredSize > 0 && this.desiredSize <= 0) {
|
||||||
this.sinkCapability = createPromiseCapability();
|
this.sinkCapability = new PromiseCapability();
|
||||||
this.ready = this.sinkCapability.promise;
|
this.ready = this.sinkCapability.promise;
|
||||||
}
|
}
|
||||||
comObj.postMessage(
|
comObj.postMessage(
|
||||||
@ -349,7 +349,7 @@ class MessageHandler {
|
|||||||
});
|
});
|
||||||
},
|
},
|
||||||
|
|
||||||
sinkCapability: createPromiseCapability(),
|
sinkCapability: new PromiseCapability(),
|
||||||
onPull: null,
|
onPull: null,
|
||||||
onCancel: null,
|
onCancel: null,
|
||||||
isCancelled: false,
|
isCancelled: false,
|
||||||
|
@ -975,42 +975,41 @@ function getModificationDate(date = new Date()) {
|
|||||||
return buffer.join("");
|
return buffer.join("");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
class PromiseCapability {
|
||||||
* Promise Capability object.
|
#settled = false;
|
||||||
*
|
|
||||||
* @typedef {Object} PromiseCapability
|
|
||||||
* @property {Promise<any>} promise - A Promise object.
|
|
||||||
* @property {boolean} settled - If the Promise has been fulfilled/rejected.
|
|
||||||
* @property {function} resolve - Fulfills the Promise.
|
|
||||||
* @property {function} reject - Rejects the Promise.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
constructor() {
|
||||||
* Creates a promise capability object.
|
/**
|
||||||
* @alias createPromiseCapability
|
* @type {Promise<any>} The Promise object.
|
||||||
*
|
*/
|
||||||
* @returns {PromiseCapability}
|
this.promise = new Promise((resolve, reject) => {
|
||||||
*/
|
/**
|
||||||
function createPromiseCapability() {
|
* @type {function} Fulfills the Promise.
|
||||||
const capability = Object.create(null);
|
*/
|
||||||
let isSettled = false;
|
this.resolve = data => {
|
||||||
|
this.#settled = true;
|
||||||
|
resolve(data);
|
||||||
|
};
|
||||||
|
|
||||||
Object.defineProperty(capability, "settled", {
|
/**
|
||||||
get() {
|
* @type {function} Rejects the Promise.
|
||||||
return isSettled;
|
*/
|
||||||
},
|
this.reject = reason => {
|
||||||
});
|
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) {
|
||||||
capability.promise = new Promise(function (resolve, reject) {
|
assert(reason instanceof Error, 'Expected valid "reason" argument.');
|
||||||
capability.resolve = function (data) {
|
}
|
||||||
isSettled = true;
|
this.#settled = true;
|
||||||
resolve(data);
|
reject(reason);
|
||||||
};
|
};
|
||||||
capability.reject = function (reason) {
|
});
|
||||||
isSettled = true;
|
}
|
||||||
reject(reason);
|
|
||||||
};
|
/**
|
||||||
});
|
* @type {boolean} If the Promise has been fulfilled/rejected.
|
||||||
return capability;
|
*/
|
||||||
|
get settled() {
|
||||||
|
return this.#settled;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let NormalizeRegex = null;
|
let NormalizeRegex = null;
|
||||||
@ -1052,7 +1051,6 @@ export {
|
|||||||
BASELINE_FACTOR,
|
BASELINE_FACTOR,
|
||||||
bytesToString,
|
bytesToString,
|
||||||
CMapCompressionType,
|
CMapCompressionType,
|
||||||
createPromiseCapability,
|
|
||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
DocumentActionEventType,
|
DocumentActionEventType,
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
@ -1078,6 +1076,7 @@ export {
|
|||||||
PasswordException,
|
PasswordException,
|
||||||
PasswordResponses,
|
PasswordResponses,
|
||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
|
PromiseCapability,
|
||||||
RenderingIntentFlag,
|
RenderingIntentFlag,
|
||||||
setVerbosityLevel,
|
setVerbosityLevel,
|
||||||
shadow,
|
shadow,
|
||||||
|
@ -17,10 +17,10 @@
|
|||||||
const {
|
const {
|
||||||
AnnotationLayer,
|
AnnotationLayer,
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
createPromiseCapability,
|
|
||||||
getDocument,
|
getDocument,
|
||||||
GlobalWorkerOptions,
|
GlobalWorkerOptions,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
|
PromiseCapability,
|
||||||
renderTextLayer,
|
renderTextLayer,
|
||||||
shadow,
|
shadow,
|
||||||
XfaLayer,
|
XfaLayer,
|
||||||
@ -922,7 +922,7 @@ class Driver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
_send(url, message) {
|
_send(url, message) {
|
||||||
const capability = createPromiseCapability();
|
const capability = new PromiseCapability();
|
||||||
this.inflight.textContent = this.inFlightRequests++;
|
this.inflight.textContent = this.inFlightRequests++;
|
||||||
|
|
||||||
fetch(url, {
|
fetch(url, {
|
||||||
|
@ -17,7 +17,6 @@ import {
|
|||||||
AnnotationEditorType,
|
AnnotationEditorType,
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
AnnotationType,
|
AnnotationType,
|
||||||
createPromiseCapability,
|
|
||||||
ImageKind,
|
ImageKind,
|
||||||
InvalidPDFException,
|
InvalidPDFException,
|
||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
@ -26,6 +25,7 @@ import {
|
|||||||
PasswordException,
|
PasswordException,
|
||||||
PasswordResponses,
|
PasswordResponses,
|
||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
|
PromiseCapability,
|
||||||
UnknownErrorException,
|
UnknownErrorException,
|
||||||
} from "../../src/shared/util.js";
|
} from "../../src/shared/util.js";
|
||||||
import {
|
import {
|
||||||
@ -137,7 +137,7 @@ describe("api", function () {
|
|||||||
const loadingTask = getDocument(basicApiGetDocumentParams);
|
const loadingTask = getDocument(basicApiGetDocumentParams);
|
||||||
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||||
|
|
||||||
const progressReportedCapability = createPromiseCapability();
|
const progressReportedCapability = new PromiseCapability();
|
||||||
// Attach the callback that is used to report loading progress;
|
// Attach the callback that is used to report loading progress;
|
||||||
// similarly to how viewer.js works.
|
// similarly to how viewer.js works.
|
||||||
loadingTask.onProgress = function (progressData) {
|
loadingTask.onProgress = function (progressData) {
|
||||||
@ -199,7 +199,7 @@ describe("api", function () {
|
|||||||
const loadingTask = getDocument(typedArrayPdf);
|
const loadingTask = getDocument(typedArrayPdf);
|
||||||
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||||
|
|
||||||
const progressReportedCapability = createPromiseCapability();
|
const progressReportedCapability = new PromiseCapability();
|
||||||
loadingTask.onProgress = function (data) {
|
loadingTask.onProgress = function (data) {
|
||||||
progressReportedCapability.resolve(data);
|
progressReportedCapability.resolve(data);
|
||||||
};
|
};
|
||||||
@ -229,7 +229,7 @@ describe("api", function () {
|
|||||||
const loadingTask = getDocument(arrayBufferPdf);
|
const loadingTask = getDocument(arrayBufferPdf);
|
||||||
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||||
|
|
||||||
const progressReportedCapability = createPromiseCapability();
|
const progressReportedCapability = new PromiseCapability();
|
||||||
loadingTask.onProgress = function (data) {
|
loadingTask.onProgress = function (data) {
|
||||||
progressReportedCapability.resolve(data);
|
progressReportedCapability.resolve(data);
|
||||||
};
|
};
|
||||||
@ -291,8 +291,8 @@ describe("api", function () {
|
|||||||
const loadingTask = getDocument(buildGetDocumentParams("pr6531_1.pdf"));
|
const loadingTask = getDocument(buildGetDocumentParams("pr6531_1.pdf"));
|
||||||
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
expect(loadingTask instanceof PDFDocumentLoadingTask).toEqual(true);
|
||||||
|
|
||||||
const passwordNeededCapability = createPromiseCapability();
|
const passwordNeededCapability = new PromiseCapability();
|
||||||
const passwordIncorrectCapability = createPromiseCapability();
|
const passwordIncorrectCapability = new PromiseCapability();
|
||||||
// Attach the callback that is used to request a password;
|
// Attach the callback that is used to request a password;
|
||||||
// similarly to how the default viewer handles passwords.
|
// similarly to how the default viewer handles passwords.
|
||||||
loadingTask.onPassword = function (updatePassword, reason) {
|
loadingTask.onPassword = function (updatePassword, reason) {
|
||||||
|
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
AbortException,
|
AbortException,
|
||||||
createPromiseCapability,
|
PromiseCapability,
|
||||||
UnknownErrorException,
|
UnknownErrorException,
|
||||||
} from "../../src/shared/util.js";
|
} from "../../src/shared/util.js";
|
||||||
import { LoopbackPort } from "../../src/display/api.js";
|
import { LoopbackPort } from "../../src/display/api.js";
|
||||||
@ -338,7 +338,7 @@ describe("message_handler", function () {
|
|||||||
it("should ignore any pull after close is called", async function () {
|
it("should ignore any pull after close is called", async function () {
|
||||||
let log = "";
|
let log = "";
|
||||||
const port = new LoopbackPort();
|
const port = new LoopbackPort();
|
||||||
const capability = createPromiseCapability();
|
const capability = new PromiseCapability();
|
||||||
const messageHandler2 = new MessageHandler("worker", "main", port);
|
const messageHandler2 = new MessageHandler("worker", "main", port);
|
||||||
messageHandler2.on("fakeHandler", (data, sink) => {
|
messageHandler2.on("fakeHandler", (data, sink) => {
|
||||||
sink.onPull = function () {
|
sink.onPull = function () {
|
||||||
|
@ -15,10 +15,10 @@
|
|||||||
|
|
||||||
import {
|
import {
|
||||||
bytesToString,
|
bytesToString,
|
||||||
createPromiseCapability,
|
|
||||||
createValidAbsoluteUrl,
|
createValidAbsoluteUrl,
|
||||||
getModificationDate,
|
getModificationDate,
|
||||||
isArrayBuffer,
|
isArrayBuffer,
|
||||||
|
PromiseCapability,
|
||||||
string32,
|
string32,
|
||||||
stringToBytes,
|
stringToBytes,
|
||||||
stringToPDFString,
|
stringToPDFString,
|
||||||
@ -212,9 +212,9 @@ describe("util", function () {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
describe("createPromiseCapability", function () {
|
describe("PromiseCapability", function () {
|
||||||
it("should resolve with correct data", async function () {
|
it("should resolve with correct data", async function () {
|
||||||
const promiseCapability = createPromiseCapability();
|
const promiseCapability = new PromiseCapability();
|
||||||
expect(promiseCapability.settled).toEqual(false);
|
expect(promiseCapability.settled).toEqual(false);
|
||||||
|
|
||||||
promiseCapability.resolve({ test: "abc" });
|
promiseCapability.resolve({ test: "abc" });
|
||||||
@ -225,7 +225,7 @@ describe("util", function () {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it("should reject with correct reason", async function () {
|
it("should reject with correct reason", async function () {
|
||||||
const promiseCapability = createPromiseCapability();
|
const promiseCapability = new PromiseCapability();
|
||||||
expect(promiseCapability.settled).toEqual(false);
|
expect(promiseCapability.settled).toEqual(false);
|
||||||
|
|
||||||
promiseCapability.reject(new Error("reason"));
|
promiseCapability.reject(new Error("reason"));
|
||||||
|
@ -36,7 +36,6 @@ import {
|
|||||||
import {
|
import {
|
||||||
AnnotationEditorType,
|
AnnotationEditorType,
|
||||||
build,
|
build,
|
||||||
createPromiseCapability,
|
|
||||||
FeatureTest,
|
FeatureTest,
|
||||||
getDocument,
|
getDocument,
|
||||||
getFilenameFromUrl,
|
getFilenameFromUrl,
|
||||||
@ -49,6 +48,7 @@ import {
|
|||||||
MissingPDFException,
|
MissingPDFException,
|
||||||
OPS,
|
OPS,
|
||||||
PDFWorker,
|
PDFWorker,
|
||||||
|
PromiseCapability,
|
||||||
shadow,
|
shadow,
|
||||||
UnexpectedResponseException,
|
UnexpectedResponseException,
|
||||||
version,
|
version,
|
||||||
@ -156,7 +156,7 @@ class DefaultExternalServices {
|
|||||||
|
|
||||||
const PDFViewerApplication = {
|
const PDFViewerApplication = {
|
||||||
initialBookmark: document.location.hash.substring(1),
|
initialBookmark: document.location.hash.substring(1),
|
||||||
_initializedCapability: createPromiseCapability(),
|
_initializedCapability: new PromiseCapability(),
|
||||||
appConfig: null,
|
appConfig: null,
|
||||||
pdfDocument: null,
|
pdfDocument: null,
|
||||||
pdfLoadingTask: null,
|
pdfLoadingTask: null,
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createPromiseCapability, PasswordResponses } from "pdfjs-lib";
|
import { PasswordResponses, PromiseCapability } from "pdfjs-lib";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PasswordPromptOptions
|
* @typedef {Object} PasswordPromptOptions
|
||||||
@ -69,7 +69,7 @@ class PasswordPrompt {
|
|||||||
if (this.#activeCapability) {
|
if (this.#activeCapability) {
|
||||||
await this.#activeCapability.promise;
|
await this.#activeCapability.promise;
|
||||||
}
|
}
|
||||||
this.#activeCapability = createPromiseCapability();
|
this.#activeCapability = new PromiseCapability();
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await this.overlayManager.open(this.dialog);
|
await this.overlayManager.open(this.dialog);
|
||||||
|
@ -13,7 +13,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createPromiseCapability, getFilenameFromUrl } from "pdfjs-lib";
|
import { getFilenameFromUrl, PromiseCapability } from "pdfjs-lib";
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
import { waitOnEventOrTimeout } from "./event_utils.js";
|
import { waitOnEventOrTimeout } from "./event_utils.js";
|
||||||
|
|
||||||
@ -50,7 +50,7 @@ class PDFAttachmentViewer extends BaseTreeViewer {
|
|||||||
if (!keepRenderedCapability) {
|
if (!keepRenderedCapability) {
|
||||||
// The only situation in which the `_renderedCapability` should *not* be
|
// The only situation in which the `_renderedCapability` should *not* be
|
||||||
// replaced is when appending FileAttachment annotations.
|
// replaced is when appending FileAttachment annotations.
|
||||||
this._renderedCapability = createPromiseCapability();
|
this._renderedCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
this._pendingDispatchEvent = false;
|
this._pendingDispatchEvent = false;
|
||||||
}
|
}
|
||||||
|
@ -13,8 +13,8 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
import { createPromiseCapability, PDFDateString } from "pdfjs-lib";
|
|
||||||
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
|
import { getPageSizeInches, isPortraitOrientation } from "./ui_utils.js";
|
||||||
|
import { PDFDateString, PromiseCapability } from "pdfjs-lib";
|
||||||
|
|
||||||
const DEFAULT_FIELD_CONTENT = "-";
|
const DEFAULT_FIELD_CONTENT = "-";
|
||||||
|
|
||||||
@ -201,7 +201,7 @@ class PDFDocumentProperties {
|
|||||||
this.pdfDocument = null;
|
this.pdfDocument = null;
|
||||||
|
|
||||||
this.#fieldData = null;
|
this.#fieldData = null;
|
||||||
this._dataAvailableCapability = createPromiseCapability();
|
this._dataAvailableCapability = new PromiseCapability();
|
||||||
this._currentPageNumber = 1;
|
this._currentPageNumber = 1;
|
||||||
this._pagesRotation = 0;
|
this._pagesRotation = 0;
|
||||||
}
|
}
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
import { binarySearchFirstItem, scrollIntoView } from "./ui_utils.js";
|
import { binarySearchFirstItem, scrollIntoView } from "./ui_utils.js";
|
||||||
import { getCharacterType, getNormalizeWithNFKC } from "./pdf_find_utils.js";
|
import { getCharacterType, getNormalizeWithNFKC } from "./pdf_find_utils.js";
|
||||||
import { createPromiseCapability } from "pdfjs-lib";
|
import { PromiseCapability } from "pdfjs-lib";
|
||||||
|
|
||||||
const FindState = {
|
const FindState = {
|
||||||
FOUND: 0,
|
FOUND: 0,
|
||||||
@ -582,7 +582,7 @@ class PDFFindController {
|
|||||||
clearTimeout(this._findTimeout);
|
clearTimeout(this._findTimeout);
|
||||||
this._findTimeout = null;
|
this._findTimeout = null;
|
||||||
|
|
||||||
this._firstPageCapability = createPromiseCapability();
|
this._firstPageCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -849,7 +849,7 @@ class PDFFindController {
|
|||||||
let promise = Promise.resolve();
|
let promise = Promise.resolve();
|
||||||
const textOptions = { disableNormalization: true };
|
const textOptions = { disableNormalization: true };
|
||||||
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
|
for (let i = 0, ii = this._linkService.pagesCount; i < ii; i++) {
|
||||||
const extractTextCapability = createPromiseCapability();
|
const extractTextCapability = new PromiseCapability();
|
||||||
this._extractTextPromises[i] = extractTextCapability.promise;
|
this._extractTextPromises[i] = extractTextCapability.promise;
|
||||||
|
|
||||||
promise = promise.then(() => {
|
promise = promise.then(() => {
|
||||||
|
@ -14,7 +14,7 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
import { BaseTreeViewer } from "./base_tree_viewer.js";
|
||||||
import { createPromiseCapability } from "pdfjs-lib";
|
import { PromiseCapability } from "pdfjs-lib";
|
||||||
import { SidebarView } from "./ui_utils.js";
|
import { SidebarView } from "./ui_utils.js";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -89,7 +89,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_dispatchEvent(outlineCount) {
|
_dispatchEvent(outlineCount) {
|
||||||
this._currentOutlineItemCapability = createPromiseCapability();
|
this._currentOutlineItemCapability = new PromiseCapability();
|
||||||
if (
|
if (
|
||||||
outlineCount === 0 ||
|
outlineCount === 0 ||
|
||||||
this._pdfDocument?.loadingParams.disableAutoFetch
|
this._pdfDocument?.loadingParams.disableAutoFetch
|
||||||
@ -308,7 +308,7 @@ class PDFOutlineViewer extends BaseTreeViewer {
|
|||||||
if (this._pageNumberToDestHashCapability) {
|
if (this._pageNumberToDestHashCapability) {
|
||||||
return this._pageNumberToDestHashCapability.promise;
|
return this._pageNumberToDestHashCapability.promise;
|
||||||
}
|
}
|
||||||
this._pageNumberToDestHashCapability = createPromiseCapability();
|
this._pageNumberToDestHashCapability = new PromiseCapability();
|
||||||
|
|
||||||
const pageNumberToDestHash = new Map(),
|
const pageNumberToDestHash = new Map(),
|
||||||
pageNumberNesting = new Map();
|
pageNumberNesting = new Map();
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
/** @typedef {import("./event_utils").EventBus} EventBus */
|
/** @typedef {import("./event_utils").EventBus} EventBus */
|
||||||
|
|
||||||
import { apiPageLayoutToViewerModes, RenderingStates } from "./ui_utils.js";
|
import { apiPageLayoutToViewerModes, RenderingStates } from "./ui_utils.js";
|
||||||
import { createPromiseCapability, shadow } from "pdfjs-lib";
|
import { PromiseCapability, shadow } from "pdfjs-lib";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @typedef {Object} PDFScriptingManagerOptions
|
* @typedef {Object} PDFScriptingManagerOptions
|
||||||
@ -357,7 +357,7 @@ class PDFScriptingManager {
|
|||||||
visitedPages = this._visitedPages;
|
visitedPages = this._visitedPages;
|
||||||
|
|
||||||
if (initialize) {
|
if (initialize) {
|
||||||
this._closeCapability = createPromiseCapability();
|
this._closeCapability = new PromiseCapability();
|
||||||
}
|
}
|
||||||
if (!this._closeCapability) {
|
if (!this._closeCapability) {
|
||||||
return; // Scripting isn't fully initialized yet.
|
return; // Scripting isn't fully initialized yet.
|
||||||
@ -443,7 +443,7 @@ class PDFScriptingManager {
|
|||||||
* @private
|
* @private
|
||||||
*/
|
*/
|
||||||
_createScripting() {
|
_createScripting() {
|
||||||
this._destroyCapability = createPromiseCapability();
|
this._destroyCapability = new PromiseCapability();
|
||||||
|
|
||||||
if (this._scripting) {
|
if (this._scripting) {
|
||||||
throw new Error("_createScripting: Scripting already exists.");
|
throw new Error("_createScripting: Scripting already exists.");
|
||||||
|
@ -28,9 +28,9 @@ import {
|
|||||||
AnnotationEditorType,
|
AnnotationEditorType,
|
||||||
AnnotationEditorUIManager,
|
AnnotationEditorUIManager,
|
||||||
AnnotationMode,
|
AnnotationMode,
|
||||||
createPromiseCapability,
|
|
||||||
PermissionFlag,
|
PermissionFlag,
|
||||||
PixelsPerInch,
|
PixelsPerInch,
|
||||||
|
PromiseCapability,
|
||||||
version,
|
version,
|
||||||
} from "pdfjs-lib";
|
} from "pdfjs-lib";
|
||||||
import {
|
import {
|
||||||
@ -1025,9 +1025,9 @@ class PDFViewer {
|
|||||||
this._location = null;
|
this._location = null;
|
||||||
this._pagesRotation = 0;
|
this._pagesRotation = 0;
|
||||||
this._optionalContentConfigPromise = null;
|
this._optionalContentConfigPromise = null;
|
||||||
this._firstPageCapability = createPromiseCapability();
|
this._firstPageCapability = new PromiseCapability();
|
||||||
this._onePageRenderedCapability = createPromiseCapability();
|
this._onePageRenderedCapability = new PromiseCapability();
|
||||||
this._pagesCapability = createPromiseCapability();
|
this._pagesCapability = new PromiseCapability();
|
||||||
this._scrollMode = ScrollMode.VERTICAL;
|
this._scrollMode = ScrollMode.VERTICAL;
|
||||||
this._previousScrollMode = ScrollMode.UNKNOWN;
|
this._previousScrollMode = ScrollMode.UNKNOWN;
|
||||||
this._spreadMode = SpreadMode.NONE;
|
this._spreadMode = SpreadMode.NONE;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user