2013-02-06 15:19:29 -08:00
|
|
|
/* Copyright 2012 Mozilla Foundation
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-03-07 17:41:41 +01:00
|
|
|
import { assert, PromiseCapability, stringToBytes } from "../shared/util.js";
|
2017-04-02 16:14:30 +02:00
|
|
|
import {
|
2018-01-13 09:01:50 +01:00
|
|
|
createResponseStatusError,
|
|
|
|
extractFilenameFromHeader,
|
|
|
|
validateRangeRequestCapabilities,
|
2020-01-02 12:00:16 +01:00
|
|
|
} from "./network_utils.js";
|
Enable auto-formatting of the entire code-base using Prettier (issue 11444)
Note that Prettier, purposely, has only limited [configuration options](https://prettier.io/docs/en/options.html). The configuration file is based on [the one in `mozilla central`](https://searchfox.org/mozilla-central/source/.prettierrc) with just a few additions (to avoid future breakage if the defaults ever changes).
Prettier is being used for a couple of reasons:
- To be consistent with `mozilla-central`, where Prettier is already in use across the tree.
- To ensure a *consistent* coding style everywhere, which is automatically enforced during linting (since Prettier is used as an ESLint plugin). This thus ends "all" formatting disussions once and for all, removing the need for review comments on most stylistic matters.
Many ESLint options are now redundant, and I've tried my best to remove all the now unnecessary options (but I may have missed some).
Note also that since Prettier considers the `printWidth` option as a guide, rather than a hard rule, this patch resorts to a small hack in the ESLint config to ensure that *comments* won't become too long.
*Please note:* This patch is generated automatically, by appending the `--fix` argument to the ESLint call used in the `gulp lint` task. It will thus require some additional clean-up, which will be done in a *separate* commit.
(On a more personal note, I'll readily admit that some of the changes Prettier makes are *extremely* ugly. However, in the name of consistency we'll probably have to live with that.)
2019-12-25 15:59:37 +01:00
|
|
|
|
2020-01-08 13:57:31 +01:00
|
|
|
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
|
2017-04-02 16:14:30 +02:00
|
|
|
throw new Error(
|
2020-01-08 13:57:31 +01:00
|
|
|
'Module "./network.js" shall not be used with MOZCENTRAL builds.'
|
2016-10-14 10:57:53 -05:00
|
|
|
);
|
|
|
|
}
|
2013-04-25 10:57:40 -07:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
const OK_RESPONSE = 200;
|
|
|
|
const PARTIAL_CONTENT_RESPONSE = 206;
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
function getArrayBuffer(xhr) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const data = xhr.response;
|
2017-04-02 16:14:30 +02:00
|
|
|
if (typeof data !== "string") {
|
|
|
|
return data;
|
|
|
|
}
|
[api-minor] Enabling transferring of data fetched with the `PDFFetchStream` implementation
Note how in the API we're transferring the PDF data that's fetched over the network[1]:
- https://github.com/mozilla/pdf.js/blob/f28bf23a314e36d9e255037f5716ae1eb8e16fbf/src/display/api.js#L2467-L2480
- https://github.com/mozilla/pdf.js/blob/f28bf23a314e36d9e255037f5716ae1eb8e16fbf/src/display/api.js#L2553-L2564
To support that functionality we have the `PDFDataTransportStream`, `PDFFetchStream`, `PDFNetworkStream`, and `PDFNodeStream` implementations. Here these stream-implementations vary slightly in how they handle `ArrayBuffer`s internally, w.r.t. transferring or copying the data:
- In `PDFDataTransportStream` we optionally, after PR 15908, allow transferring of the PDF data as provided externally (used e.g. in the Firefox PDF Viewer).
- In `PDFFetchStream` we're currenly always copying the PDF data returned by the Fetch API, which seems unnecessary. As discussed in PR 15908, it'd seem very weird if this sort of browser API didn't allow transferring of the returned data.
- In `PDFNetworkStream` we're already, since many years, transferring the PDF data returned by the `XMLHttpRequest` functionality. Note how the `getArrayBuffer` helper function simply returns an `ArrayBuffer` response as-is.
- In `PDFNodeStream` we're currently copying the PDF data, however this is unfortunately necessary since Node.js returns data as a `Buffer` object[2].
Given that the `PDFNetworkStream` has been, indirectly, supporting transferring of PDF data for years it would seem really strange if this didn't also apply to the `PDFFetchStream`-implementation.
Hence this patch simply enables transferring of PDF data, when accessed using the Fetch API, unconditionally to help reduced main-thread memory usage since the `PDFFetchStream`-implementation is used *by default* in browsers (for the GENERIC build).
---
[1] As opposed to PDF data being provided as e.g. a TypedArray when calling `getDocument` in the API.
[2] This is a "special" Node.js object, see https://nodejs.org/api/buffer.html#buffer, which doesn't exist in browsers.
2023-01-11 22:03:36 +01:00
|
|
|
return stringToBytes(data).buffer;
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
class NetworkManager {
|
2021-08-30 09:37:06 +02:00
|
|
|
constructor(url, args = {}) {
|
2019-05-16 09:30:06 +02:00
|
|
|
this.url = url;
|
|
|
|
this.isHttp = /^https?:/i.test(url);
|
2021-08-30 09:37:06 +02:00
|
|
|
this.httpHeaders = (this.isHttp && args.httpHeaders) || Object.create(null);
|
2019-05-16 09:30:06 +02:00
|
|
|
this.withCredentials = args.withCredentials || false;
|
|
|
|
|
|
|
|
this.currXhrId = 0;
|
|
|
|
this.pendingRequests = Object.create(null);
|
|
|
|
}
|
|
|
|
|
|
|
|
requestRange(begin, end, listeners) {
|
|
|
|
const args = {
|
2017-04-02 16:14:30 +02:00
|
|
|
begin,
|
|
|
|
end,
|
|
|
|
};
|
2019-05-16 09:30:06 +02:00
|
|
|
for (const prop in listeners) {
|
2017-04-02 16:14:30 +02:00
|
|
|
args[prop] = listeners[prop];
|
2014-10-29 16:31:15 +01:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
return this.request(args);
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
requestFull(listeners) {
|
2017-04-02 16:14:30 +02:00
|
|
|
return this.request(listeners);
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
request(args) {
|
2023-04-27 11:32:32 +02:00
|
|
|
const xhr = new XMLHttpRequest();
|
2019-05-16 09:30:06 +02:00
|
|
|
const xhrId = this.currXhrId++;
|
2021-08-30 09:37:06 +02:00
|
|
|
const pendingRequest = (this.pendingRequests[xhrId] = { xhr });
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
xhr.open("GET", this.url);
|
|
|
|
xhr.withCredentials = this.withCredentials;
|
2019-05-16 09:30:06 +02:00
|
|
|
for (const property in this.httpHeaders) {
|
|
|
|
const value = this.httpHeaders[property];
|
2022-11-27 17:16:46 +01:00
|
|
|
if (value === undefined) {
|
2017-04-02 16:14:30 +02:00
|
|
|
continue;
|
2013-02-06 15:19:29 -08:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
xhr.setRequestHeader(property, value);
|
|
|
|
}
|
|
|
|
if (this.isHttp && "begin" in args && "end" in args) {
|
2019-05-16 09:30:06 +02:00
|
|
|
xhr.setRequestHeader("Range", `bytes=${args.begin}-${args.end - 1}`);
|
|
|
|
pendingRequest.expectedStatus = PARTIAL_CONTENT_RESPONSE;
|
2017-04-02 16:14:30 +02:00
|
|
|
} else {
|
2019-05-16 09:30:06 +02:00
|
|
|
pendingRequest.expectedStatus = OK_RESPONSE;
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2019-03-25 11:07:18 +01:00
|
|
|
xhr.responseType = "arraybuffer";
|
2014-09-05 20:02:54 -05:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
if (args.onError) {
|
2020-04-14 12:28:14 +02:00
|
|
|
xhr.onerror = function (evt) {
|
2017-04-02 16:14:30 +02:00
|
|
|
args.onError(xhr.status);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
xhr.onreadystatechange = this.onStateChange.bind(this, xhrId);
|
|
|
|
xhr.onprogress = this.onProgress.bind(this, xhrId);
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
pendingRequest.onHeadersReceived = args.onHeadersReceived;
|
|
|
|
pendingRequest.onDone = args.onDone;
|
|
|
|
pendingRequest.onError = args.onError;
|
|
|
|
pendingRequest.onProgress = args.onProgress;
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
xhr.send(null);
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
return xhrId;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
onProgress(xhrId, evt) {
|
|
|
|
const pendingRequest = this.pendingRequests[xhrId];
|
2017-04-02 16:14:30 +02:00
|
|
|
if (!pendingRequest) {
|
2021-08-30 09:37:06 +02:00
|
|
|
return; // Maybe abortRequest was called...
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2021-08-30 09:37:06 +02:00
|
|
|
pendingRequest.onProgress?.(evt);
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2014-09-05 20:02:54 -05:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
onStateChange(xhrId, evt) {
|
|
|
|
const pendingRequest = this.pendingRequests[xhrId];
|
2017-04-02 16:14:30 +02:00
|
|
|
if (!pendingRequest) {
|
2021-08-30 09:37:06 +02:00
|
|
|
return; // Maybe abortRequest was called...
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
const xhr = pendingRequest.xhr;
|
2017-04-02 16:14:30 +02:00
|
|
|
if (xhr.readyState >= 2 && pendingRequest.onHeadersReceived) {
|
|
|
|
pendingRequest.onHeadersReceived();
|
|
|
|
delete pendingRequest.onHeadersReceived;
|
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
if (xhr.readyState !== 4) {
|
|
|
|
return;
|
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
if (!(xhrId in this.pendingRequests)) {
|
|
|
|
// The XHR request might have been aborted in onHeadersReceived()
|
2019-05-16 09:30:06 +02:00
|
|
|
// callback, in which case we should abort request.
|
2017-04-02 16:14:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
delete this.pendingRequests[xhrId];
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
// Success status == 0 can be on ftp, file and other protocols.
|
2017-04-02 16:14:30 +02:00
|
|
|
if (xhr.status === 0 && this.isHttp) {
|
2021-08-30 09:37:06 +02:00
|
|
|
pendingRequest.onError?.(xhr.status);
|
2017-04-02 16:14:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2019-05-16 09:30:06 +02:00
|
|
|
const xhrStatus = xhr.status || OK_RESPONSE;
|
2017-04-02 16:14:30 +02:00
|
|
|
|
|
|
|
// From http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.35.2:
|
|
|
|
// "A server MAY ignore the Range header". This means it's possible to
|
|
|
|
// get a 200 rather than a 206 response from a range request.
|
2019-05-16 09:30:06 +02:00
|
|
|
const ok_response_on_range_request =
|
|
|
|
xhrStatus === OK_RESPONSE &&
|
|
|
|
pendingRequest.expectedStatus === PARTIAL_CONTENT_RESPONSE;
|
2017-04-02 16:14:30 +02:00
|
|
|
|
|
|
|
if (
|
|
|
|
!ok_response_on_range_request &&
|
|
|
|
xhrStatus !== pendingRequest.expectedStatus
|
|
|
|
) {
|
2021-08-30 09:37:06 +02:00
|
|
|
pendingRequest.onError?.(xhr.status);
|
2017-04-02 16:14:30 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
const chunk = getArrayBuffer(xhr);
|
2017-04-02 16:14:30 +02:00
|
|
|
if (xhrStatus === PARTIAL_CONTENT_RESPONSE) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const rangeHeader = xhr.getResponseHeader("Content-Range");
|
|
|
|
const matches = /bytes (\d+)-(\d+)\/(\d+)/.exec(rangeHeader);
|
2017-04-02 16:14:30 +02:00
|
|
|
pendingRequest.onDone({
|
2019-05-16 09:30:06 +02:00
|
|
|
begin: parseInt(matches[1], 10),
|
2017-04-02 16:14:30 +02:00
|
|
|
chunk,
|
|
|
|
});
|
|
|
|
} else if (chunk) {
|
|
|
|
pendingRequest.onDone({
|
|
|
|
begin: 0,
|
|
|
|
chunk,
|
|
|
|
});
|
2021-08-30 09:37:06 +02:00
|
|
|
} else {
|
|
|
|
pendingRequest.onError?.(xhr.status);
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
getRequestXhr(xhrId) {
|
2017-04-02 16:14:30 +02:00
|
|
|
return this.pendingRequests[xhrId].xhr;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
isPendingRequest(xhrId) {
|
2017-04-02 16:14:30 +02:00
|
|
|
return xhrId in this.pendingRequests;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2013-02-06 15:19:29 -08:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
abortRequest(xhrId) {
|
|
|
|
const xhr = this.pendingRequests[xhrId].xhr;
|
2017-04-02 16:14:30 +02:00
|
|
|
delete this.pendingRequests[xhrId];
|
|
|
|
xhr.abort();
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
|
|
|
/** @implements {IPDFStream} */
|
2019-05-16 09:30:06 +02:00
|
|
|
class PDFNetworkStream {
|
|
|
|
constructor(source) {
|
|
|
|
this._source = source;
|
|
|
|
this._manager = new NetworkManager(source.url, {
|
|
|
|
httpHeaders: source.httpHeaders,
|
|
|
|
withCredentials: source.withCredentials,
|
|
|
|
});
|
|
|
|
this._rangeChunkSize = source.rangeChunkSize;
|
|
|
|
this._fullRequestReader = null;
|
|
|
|
this._rangeRequestReaders = [];
|
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
_onRangeRequestReaderClosed(reader) {
|
|
|
|
const i = this._rangeRequestReaders.indexOf(reader);
|
2017-04-02 16:14:30 +02:00
|
|
|
if (i >= 0) {
|
|
|
|
this._rangeRequestReaders.splice(i, 1);
|
|
|
|
}
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
getFullReader() {
|
2020-05-05 12:40:01 +02:00
|
|
|
assert(
|
|
|
|
!this._fullRequestReader,
|
|
|
|
"PDFNetworkStream.getFullReader can only be called once."
|
|
|
|
);
|
2017-10-16 15:52:20 +02:00
|
|
|
this._fullRequestReader = new PDFNetworkStreamFullRequestReader(
|
|
|
|
this._manager,
|
|
|
|
this._source
|
|
|
|
);
|
2017-04-02 16:14:30 +02:00
|
|
|
return this._fullRequestReader;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
getRangeReader(begin, end) {
|
|
|
|
const reader = new PDFNetworkStreamRangeRequestReader(
|
|
|
|
this._manager,
|
|
|
|
begin,
|
|
|
|
end
|
|
|
|
);
|
2017-04-02 16:14:30 +02:00
|
|
|
reader.onClosed = this._onRangeRequestReaderClosed.bind(this);
|
|
|
|
this._rangeRequestReaders.push(reader);
|
|
|
|
return reader;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
cancelAllRequests(reason) {
|
2021-08-30 09:37:06 +02:00
|
|
|
this._fullRequestReader?.cancel(reason);
|
|
|
|
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const reader of this._rangeRequestReaders.slice(0)) {
|
2017-04-02 16:14:30 +02:00
|
|
|
reader.cancel(reason);
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
|
|
|
/** @implements {IPDFStreamReader} */
|
2019-05-16 09:30:06 +02:00
|
|
|
class PDFNetworkStreamFullRequestReader {
|
|
|
|
constructor(manager, source) {
|
|
|
|
this._manager = manager;
|
|
|
|
|
|
|
|
const args = {
|
|
|
|
onHeadersReceived: this._onHeadersReceived.bind(this),
|
|
|
|
onDone: this._onDone.bind(this),
|
|
|
|
onError: this._onError.bind(this),
|
|
|
|
onProgress: this._onProgress.bind(this),
|
|
|
|
};
|
|
|
|
this._url = source.url;
|
|
|
|
this._fullRequestId = manager.requestFull(args);
|
2022-03-07 17:41:41 +01:00
|
|
|
this._headersReceivedCapability = new PromiseCapability();
|
2019-05-16 09:30:06 +02:00
|
|
|
this._disableRange = source.disableRange || false;
|
|
|
|
this._contentLength = source.length; // Optional
|
|
|
|
this._rangeChunkSize = source.rangeChunkSize;
|
|
|
|
if (!this._rangeChunkSize && !this._disableRange) {
|
|
|
|
this._disableRange = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
this._isStreamingSupported = false;
|
|
|
|
this._isRangeSupported = false;
|
|
|
|
|
|
|
|
this._cachedChunks = [];
|
|
|
|
this._requests = [];
|
|
|
|
this._done = false;
|
|
|
|
this._storedError = undefined;
|
|
|
|
this._filename = null;
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
this.onProgress = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
_onHeadersReceived() {
|
|
|
|
const fullRequestXhrId = this._fullRequestId;
|
|
|
|
const fullRequestXhr = this._manager.getRequestXhr(fullRequestXhrId);
|
2017-08-05 01:00:37 +05:30
|
|
|
|
2024-01-21 10:13:12 +01:00
|
|
|
const getResponseHeader = name => fullRequestXhr.getResponseHeader(name);
|
|
|
|
|
2021-05-16 10:58:34 +02:00
|
|
|
const { allowRangeRequests, suggestedLength } =
|
|
|
|
validateRangeRequestCapabilities({
|
|
|
|
getResponseHeader,
|
|
|
|
isHttp: this._manager.isHttp,
|
|
|
|
rangeChunkSize: this._rangeChunkSize,
|
|
|
|
disableRange: this._disableRange,
|
|
|
|
});
|
2017-07-30 20:28:32 +05:30
|
|
|
|
|
|
|
if (allowRangeRequests) {
|
2017-04-02 16:14:30 +02:00
|
|
|
this._isRangeSupported = true;
|
|
|
|
}
|
2018-02-09 13:39:38 +01:00
|
|
|
// Setting right content length.
|
|
|
|
this._contentLength = suggestedLength || this._contentLength;
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2018-01-16 16:24:36 +01:00
|
|
|
this._filename = extractFilenameFromHeader(getResponseHeader);
|
|
|
|
|
2019-03-25 11:07:18 +01:00
|
|
|
if (this._isRangeSupported) {
|
2017-04-02 16:14:30 +02:00
|
|
|
// NOTE: by cancelling the full request, and then issuing range
|
|
|
|
// requests, there will be an issue for sites where you can only
|
|
|
|
// request the pdf once. However, if this is the case, then the
|
2019-03-25 11:07:18 +01:00
|
|
|
// server should not be returning that it can support range requests.
|
|
|
|
this._manager.abortRequest(fullRequestXhrId);
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
this._headersReceivedCapability.resolve();
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2021-08-30 09:37:06 +02:00
|
|
|
_onDone(data) {
|
|
|
|
if (data) {
|
2019-03-25 11:07:18 +01:00
|
|
|
if (this._requests.length > 0) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const requestCapability = this._requests.shift();
|
2021-08-30 09:37:06 +02:00
|
|
|
requestCapability.resolve({ value: data.chunk, done: false });
|
2019-03-25 11:07:18 +01:00
|
|
|
} else {
|
2021-08-30 09:37:06 +02:00
|
|
|
this._cachedChunks.push(data.chunk);
|
2019-03-25 11:07:18 +01:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
|
|
|
this._done = true;
|
|
|
|
if (this._cachedChunks.length > 0) {
|
|
|
|
return;
|
|
|
|
}
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const requestCapability of this._requests) {
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 11:16:24 +02:00
|
|
|
requestCapability.resolve({ value: undefined, done: true });
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2021-04-24 12:52:09 +02:00
|
|
|
this._requests.length = 0;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
_onError(status) {
|
2021-08-30 09:37:06 +02:00
|
|
|
this._storedError = createResponseStatusError(status, this._url);
|
|
|
|
this._headersReceivedCapability.reject(this._storedError);
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const requestCapability of this._requests) {
|
2021-08-30 09:37:06 +02:00
|
|
|
requestCapability.reject(this._storedError);
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2021-04-24 12:52:09 +02:00
|
|
|
this._requests.length = 0;
|
|
|
|
this._cachedChunks.length = 0;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2021-08-30 09:37:06 +02:00
|
|
|
_onProgress(evt) {
|
|
|
|
this.onProgress?.({
|
|
|
|
loaded: evt.loaded,
|
|
|
|
total: evt.lengthComputable ? evt.total : this._contentLength,
|
|
|
|
});
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2018-01-16 16:24:36 +01:00
|
|
|
get filename() {
|
|
|
|
return this._filename;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2018-01-13 09:01:50 +01:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
get isRangeSupported() {
|
|
|
|
return this._isRangeSupported;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
get isStreamingSupported() {
|
|
|
|
return this._isStreamingSupported;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
get contentLength() {
|
|
|
|
return this._contentLength;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
get headersReady() {
|
|
|
|
return this._headersReceivedCapability.promise;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2018-07-30 13:58:09 +02:00
|
|
|
async read() {
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._storedError) {
|
2018-07-30 13:58:09 +02:00
|
|
|
throw this._storedError;
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
|
|
|
if (this._cachedChunks.length > 0) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const chunk = this._cachedChunks.shift();
|
2018-07-30 13:58:09 +02:00
|
|
|
return { value: chunk, done: false };
|
2016-02-09 14:55:11 -06:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._done) {
|
2018-07-30 13:58:09 +02:00
|
|
|
return { value: undefined, done: true };
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2022-03-07 17:41:41 +01:00
|
|
|
const requestCapability = new PromiseCapability();
|
2017-04-02 16:14:30 +02:00
|
|
|
this._requests.push(requestCapability);
|
|
|
|
return requestCapability.promise;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
cancel(reason) {
|
2017-04-02 16:14:30 +02:00
|
|
|
this._done = true;
|
|
|
|
this._headersReceivedCapability.reject(reason);
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const requestCapability of this._requests) {
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 11:16:24 +02:00
|
|
|
requestCapability.resolve({ value: undefined, done: true });
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2021-04-24 12:52:09 +02:00
|
|
|
this._requests.length = 0;
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._manager.isPendingRequest(this._fullRequestId)) {
|
|
|
|
this._manager.abortRequest(this._fullRequestId);
|
|
|
|
}
|
|
|
|
this._fullRequestReader = null;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
|
|
|
/** @implements {IPDFStreamRangeReader} */
|
2019-05-16 09:30:06 +02:00
|
|
|
class PDFNetworkStreamRangeRequestReader {
|
|
|
|
constructor(manager, begin, end) {
|
|
|
|
this._manager = manager;
|
2021-08-30 09:57:39 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
const args = {
|
|
|
|
onDone: this._onDone.bind(this),
|
2021-08-30 09:57:39 +02:00
|
|
|
onError: this._onError.bind(this),
|
2019-05-16 09:30:06 +02:00
|
|
|
onProgress: this._onProgress.bind(this),
|
|
|
|
};
|
2021-08-30 09:57:39 +02:00
|
|
|
this._url = manager.url;
|
2019-05-16 09:30:06 +02:00
|
|
|
this._requestId = manager.requestRange(begin, end, args);
|
|
|
|
this._requests = [];
|
|
|
|
this._queuedChunk = null;
|
|
|
|
this._done = false;
|
2021-08-30 09:57:39 +02:00
|
|
|
this._storedError = undefined;
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
this.onProgress = null;
|
|
|
|
this.onClosed = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
_close() {
|
2021-08-30 09:37:06 +02:00
|
|
|
this.onClosed?.(this);
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
_onDone(data) {
|
|
|
|
const chunk = data.chunk;
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._requests.length > 0) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const requestCapability = this._requests.shift();
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 11:16:24 +02:00
|
|
|
requestCapability.resolve({ value: chunk, done: false });
|
2017-04-02 16:14:30 +02:00
|
|
|
} else {
|
|
|
|
this._queuedChunk = chunk;
|
|
|
|
}
|
|
|
|
this._done = true;
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const requestCapability of this._requests) {
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 11:16:24 +02:00
|
|
|
requestCapability.resolve({ value: undefined, done: true });
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2021-04-24 12:52:09 +02:00
|
|
|
this._requests.length = 0;
|
2017-04-02 16:14:30 +02:00
|
|
|
this._close();
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2021-08-30 09:57:39 +02:00
|
|
|
_onError(status) {
|
|
|
|
this._storedError = createResponseStatusError(status, this._url);
|
|
|
|
for (const requestCapability of this._requests) {
|
|
|
|
requestCapability.reject(this._storedError);
|
|
|
|
}
|
|
|
|
this._requests.length = 0;
|
|
|
|
this._queuedChunk = null;
|
|
|
|
}
|
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
_onProgress(evt) {
|
2021-08-30 09:37:06 +02:00
|
|
|
if (!this.isStreamingSupported) {
|
|
|
|
this.onProgress?.({ loaded: evt.loaded });
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
get isStreamingSupported() {
|
2019-05-16 09:30:06 +02:00
|
|
|
return false;
|
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2018-07-30 13:58:09 +02:00
|
|
|
async read() {
|
2021-08-30 09:57:39 +02:00
|
|
|
if (this._storedError) {
|
|
|
|
throw this._storedError;
|
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._queuedChunk !== null) {
|
2019-05-16 09:30:06 +02:00
|
|
|
const chunk = this._queuedChunk;
|
2017-04-02 16:14:30 +02:00
|
|
|
this._queuedChunk = null;
|
2018-07-30 13:58:09 +02:00
|
|
|
return { value: chunk, done: false };
|
2016-02-09 14:55:11 -06:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._done) {
|
2018-07-30 13:58:09 +02:00
|
|
|
return { value: undefined, done: true };
|
2017-04-02 16:14:30 +02:00
|
|
|
}
|
2022-03-07 17:41:41 +01:00
|
|
|
const requestCapability = new PromiseCapability();
|
2017-04-02 16:14:30 +02:00
|
|
|
this._requests.push(requestCapability);
|
|
|
|
return requestCapability.promise;
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
2017-04-02 16:14:30 +02:00
|
|
|
|
2019-05-16 09:30:06 +02:00
|
|
|
cancel(reason) {
|
2017-04-02 16:14:30 +02:00
|
|
|
this._done = true;
|
2021-04-24 12:36:01 +02:00
|
|
|
for (const requestCapability of this._requests) {
|
Fix inconsistent spacing and trailing commas in objects in `src/core/` files, so we can enable the `comma-dangle` and `object-curly-spacing` ESLint rules later on
*Unfortunately this patch is fairly big, even though it only covers the `src/core` folder, but splitting it even further seemed difficult.*
http://eslint.org/docs/rules/comma-dangle
http://eslint.org/docs/rules/object-curly-spacing
Given that we currently have quite inconsistent object formatting, fixing this in *one* big patch probably wouldn't be feasible (since I cannot imagine anyone wanting to review that); hence I've opted to try and do this piecewise instead.
Please note: This patch was created automatically, using the ESLint --fix command line option. In a couple of places this caused lines to become too long, and I've fixed those manually; please refer to the interdiff below for the only hand-edits in this patch.
```diff
diff --git a/src/core/evaluator.js b/src/core/evaluator.js
index abab9027..dcd3594b 100644
--- a/src/core/evaluator.js
+++ b/src/core/evaluator.js
@@ -2785,7 +2785,8 @@ var EvaluatorPreprocessor = (function EvaluatorPreprocessorClosure() {
t['Tz'] = { id: OPS.setHScale, numArgs: 1, variableArgs: false, };
t['TL'] = { id: OPS.setLeading, numArgs: 1, variableArgs: false, };
t['Tf'] = { id: OPS.setFont, numArgs: 2, variableArgs: false, };
- t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1, variableArgs: false, };
+ t['Tr'] = { id: OPS.setTextRenderingMode, numArgs: 1,
+ variableArgs: false, };
t['Ts'] = { id: OPS.setTextRise, numArgs: 1, variableArgs: false, };
t['Td'] = { id: OPS.moveText, numArgs: 2, variableArgs: false, };
t['TD'] = { id: OPS.setLeadingMoveText, numArgs: 2, variableArgs: false, };
diff --git a/src/core/jbig2.js b/src/core/jbig2.js
index 5a17d482..71671541 100644
--- a/src/core/jbig2.js
+++ b/src/core/jbig2.js
@@ -123,19 +123,22 @@ var Jbig2Image = (function Jbig2ImageClosure() {
{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -2, y: 0, },
{ x: -1, y: 0, }],
[{ x: -3, y: -1, }, { x: -2, y: -1, }, { x: -1, y: -1, }, { x: 0, y: -1, },
- { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, }, { x: -1, y: 0, }]
+ { x: 1, y: -1, }, { x: -4, y: 0, }, { x: -3, y: 0, }, { x: -2, y: 0, },
+ { x: -1, y: 0, }]
];
var RefinementTemplates = [
{
coding: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
- { x: 1, y: 0, }, { x: -1, y: 1, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
+ reference: [{ x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, },
+ { x: 0, y: 0, }, { x: 1, y: 0, }, { x: -1, y: 1, },
+ { x: 0, y: 1, }, { x: 1, y: 1, }],
},
{
- coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, }, { x: -1, y: 0, }],
- reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, }, { x: 1, y: 0, },
- { x: 0, y: 1, }, { x: 1, y: 1, }],
+ coding: [{ x: -1, y: -1, }, { x: 0, y: -1, }, { x: 1, y: -1, },
+ { x: -1, y: 0, }],
+ reference: [{ x: 0, y: -1, }, { x: -1, y: 0, }, { x: 0, y: 0, },
+ { x: 1, y: 0, }, { x: 0, y: 1, }, { x: 1, y: 1, }],
}
];
```
2017-06-02 11:16:24 +02:00
|
|
|
requestCapability.resolve({ value: undefined, done: true });
|
2021-04-24 12:36:01 +02:00
|
|
|
}
|
2021-04-24 12:52:09 +02:00
|
|
|
this._requests.length = 0;
|
2017-04-02 16:14:30 +02:00
|
|
|
if (this._manager.isPendingRequest(this._requestId)) {
|
|
|
|
this._manager.abortRequest(this._requestId);
|
|
|
|
}
|
|
|
|
this._close();
|
2019-05-16 09:30:06 +02:00
|
|
|
}
|
|
|
|
}
|
2016-02-09 14:55:11 -06:00
|
|
|
|
2017-04-02 16:14:30 +02:00
|
|
|
export { PDFNetworkStream };
|