diff --git a/src/core/chunked_stream.js b/src/core/chunked_stream.js index eaa13e29c..680ac85fc 100644 --- a/src/core/chunked_stream.js +++ b/src/core/chunked_stream.js @@ -283,19 +283,15 @@ class ChunkedStreamManager { sendRequest(begin, end) { const rangeReader = this.pdfNetworkStream.getRangeReader(begin, end); - if (!rangeReader.isStreamingSupported) { - rangeReader.onProgress = this.onProgress.bind(this); - } + rangeReader.onProgress = this.onProgress.bind(this); - let chunks = [], - loaded = 0; + let chunks = []; return new Promise((resolve, reject) => { const readChunk = ({ value, done }) => { try { if (done) { - const chunkData = arrayBuffersToBytes(chunks); + resolve(arrayBuffersToBytes(chunks)); chunks = null; - resolve(chunkData); return; } if (typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) { @@ -304,12 +300,6 @@ class ChunkedStreamManager { "readChunk (sendRequest) - expected an ArrayBuffer." ); } - loaded += value.byteLength; - - if (rangeReader.isStreamingSupported) { - this.onProgress({ loaded }); - } - chunks.push(value); rangeReader.read().then(readChunk, reject); } catch (e) { diff --git a/src/core/worker_stream.js b/src/core/worker_stream.js index 047935316..eb8f97f3c 100644 --- a/src/core/worker_stream.js +++ b/src/core/worker_stream.js @@ -114,10 +114,6 @@ class PDFWorkerStreamRangeReader { this._reader = readableStream.getReader(); } - get isStreamingSupported() { - return false; - } - async read() { const { value, done } = await this._reader.read(); if (done) { diff --git a/src/display/fetch_stream.js b/src/display/fetch_stream.js index acbf3c868..dc08637cc 100644 --- a/src/display/fetch_stream.js +++ b/src/display/fetch_stream.js @@ -209,7 +209,6 @@ class PDFFetchStreamRangeReader { const source = stream.source; this._withCredentials = source.withCredentials || false; this._readCapability = Promise.withResolvers(); - this._isStreamingSupported = !source.disableStream; this._abortController = new AbortController(); // Always create a copy of the headers. @@ -240,10 +239,6 @@ class PDFFetchStreamRangeReader { this.onProgress = null; } - get isStreamingSupported() { - return this._isStreamingSupported; - } - async read() { await this._readCapability.promise; const { value, done } = await this._reader.read(); diff --git a/src/display/network.js b/src/display/network.js index f4a83bfc2..48bf60e2a 100644 --- a/src/display/network.js +++ b/src/display/network.js @@ -413,13 +413,7 @@ class PDFNetworkStreamRangeRequestReader { } _onProgress(evt) { - if (!this.isStreamingSupported) { - this.onProgress?.({ loaded: evt.loaded }); - } - } - - get isStreamingSupported() { - return false; + this.onProgress?.({ loaded: evt.loaded }); } async read() { diff --git a/src/display/node_stream.js b/src/display/node_stream.js index e2f3b9cc6..4c6276505 100644 --- a/src/display/node_stream.js +++ b/src/display/node_stream.js @@ -208,8 +208,6 @@ class PDFNodeStreamFsRangeReader { constructor(stream, begin, end) { this.onProgress = null; this._loaded = 0; - const source = stream.source; - this._isStreamingSupported = !source.disableStream; const url = stream.url; const fs = process.getBuiltinModule("fs"); @@ -228,10 +226,6 @@ class PDFNodeStreamFsRangeReader { } } - get isStreamingSupported() { - return this._isStreamingSupported; - } - async read() { await this._readCapability.promise; const { value, done } = await this._reader.read(); diff --git a/src/display/transport_stream.js b/src/display/transport_stream.js index 36bef6dc1..8c1a21f16 100644 --- a/src/display/transport_stream.js +++ b/src/display/transport_stream.js @@ -287,10 +287,6 @@ class PDFDataTransportStreamRangeReader { this._stream._removeRangeReader(this); } - get isStreamingSupported() { - return false; - } - async read() { if (this._queuedChunk) { const chunk = this._queuedChunk; diff --git a/src/interfaces.js b/src/interfaces.js index 15493bdb8..587727327 100644 --- a/src/interfaces.js +++ b/src/interfaces.js @@ -145,14 +145,6 @@ class IPDFStreamRangeReader { this.onProgress = null; } - /** - * Gets ability of the stream to progressively load binary data. - * @type {boolean} - */ - get isStreamingSupported() { - return false; - } - /** * Requests a chunk of the binary data. The method returns the promise, which * is resolved into object with properties "value" and "done". If the done