Merge pull request #11123 from Snuffleupagus/rm-api-postMessageTransfers
[api-minor] Remove the `postMessageTransfers` parameter, and thus the ability to manually disable transferring of data, from the API
This commit is contained in:
commit
a79cb2d5f1
@ -67,29 +67,14 @@ var WorkerMessageHandler = {
|
||||
|
||||
// check if Uint8Array can be sent to worker
|
||||
if (!(data instanceof Uint8Array)) {
|
||||
handler.send('test', false);
|
||||
handler.send('test', null);
|
||||
return;
|
||||
}
|
||||
// making sure postMessage transfers are working
|
||||
var supportTransfers = data[0] === 255;
|
||||
const supportTransfers = data[0] === 255;
|
||||
handler.postMessageTransfers = supportTransfers;
|
||||
// check if the response property is supported by xhr
|
||||
var xhr = new XMLHttpRequest();
|
||||
var responseExists = 'response' in xhr;
|
||||
// check if the property is actually implemented
|
||||
try {
|
||||
xhr.responseType; // eslint-disable-line no-unused-expressions
|
||||
} catch (e) {
|
||||
responseExists = false;
|
||||
}
|
||||
if (!responseExists) {
|
||||
handler.send('test', false);
|
||||
return;
|
||||
}
|
||||
handler.send('test', {
|
||||
supportTypedArray: true,
|
||||
supportTransfers,
|
||||
});
|
||||
|
||||
handler.send('test', { supportTransfers, });
|
||||
});
|
||||
|
||||
handler.on('configure', function wphConfigure(data) {
|
||||
|
@ -146,8 +146,6 @@ function setPDFNetworkStreamFactory(pdfNetworkStreamFactory) {
|
||||
* 2^16 = 65536.
|
||||
* @property {PDFWorker} worker - (optional) The worker that will be used for
|
||||
* the loading and parsing of the PDF data.
|
||||
* @property {boolean} postMessageTransfers - (optional) Enables transfer usage
|
||||
* in postMessage for ArrayBuffers. The default value is `true`.
|
||||
* @property {number} verbosity - (optional) Controls the logging level; the
|
||||
* constants from {VerbosityLevel} should be used.
|
||||
* @property {string} docBaseUrl - (optional) The base URL of the document,
|
||||
@ -319,7 +317,6 @@ function getDocument(src) {
|
||||
|
||||
if (!worker) {
|
||||
const workerParams = {
|
||||
postMessageTransfers: params.postMessageTransfers,
|
||||
verbosity: params.verbosity,
|
||||
port: GlobalWorkerOptions.workerPort,
|
||||
};
|
||||
@ -1476,8 +1473,6 @@ class LoopbackPort {
|
||||
* @typedef {Object} PDFWorkerParameters
|
||||
* @property {string} name - (optional) The name of the worker.
|
||||
* @property {Object} port - (optional) The `workerPort`.
|
||||
* @property {boolean} postMessageTransfers - (optional) Enables transfer usage
|
||||
* in postMessage for ArrayBuffers. The default value is `true`.
|
||||
* @property {number} verbosity - (optional) Controls the logging level; the
|
||||
* constants from {VerbosityLevel} should be used.
|
||||
*/
|
||||
@ -1568,7 +1563,7 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
* @param {PDFWorkerParameters} params - The worker initialization parameters.
|
||||
*/
|
||||
class PDFWorker {
|
||||
constructor({ name = null, port = null, postMessageTransfers = true,
|
||||
constructor({ name = null, port = null,
|
||||
verbosity = getVerbosityLevel(), } = {}) {
|
||||
if (port && pdfWorkerPorts.has(port)) {
|
||||
throw new Error('Cannot use more than one PDFWorker per port');
|
||||
@ -1576,7 +1571,7 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
|
||||
this.name = name;
|
||||
this.destroyed = false;
|
||||
this.postMessageTransfers = postMessageTransfers !== false;
|
||||
this.postMessageTransfers = true;
|
||||
this.verbosity = verbosity;
|
||||
|
||||
this._readyCapability = createPromiseCapability();
|
||||
@ -1665,7 +1660,7 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
terminateEarly();
|
||||
return; // worker was destroyed
|
||||
}
|
||||
if (data && data.supportTypedArray) {
|
||||
if (data) { // supportTypedArray
|
||||
this._messageHandler = messageHandler;
|
||||
this._port = worker;
|
||||
this._webWorker = worker;
|
||||
@ -1705,7 +1700,7 @@ const PDFWorker = (function PDFWorkerClosure() {
|
||||
try {
|
||||
messageHandler.send('test', testObj, [testObj.buffer]);
|
||||
} catch (ex) {
|
||||
info('Cannot use postMessage transfers');
|
||||
warn('Cannot use postMessage transfers.');
|
||||
testObj[0] = 0;
|
||||
messageHandler.send('test', testObj);
|
||||
}
|
||||
|
@ -206,11 +206,6 @@ const defaultOptions = {
|
||||
value: false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
postMessageTransfers: {
|
||||
/** @type {boolean} */
|
||||
value: true,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
verbosity: {
|
||||
/** @type {number} */
|
||||
value: 1,
|
||||
|
Loading…
Reference in New Issue
Block a user