mirror of
https://github.com/zen-browser/pdf.js.git
synced 2025-07-08 17:30:09 +02:00
Adds fetch stream logic for networking part of PDF.js
This commit is contained in:
parent
f54dfc63dc
commit
3516a59384
6 changed files with 270 additions and 20 deletions
|
@ -1247,6 +1247,17 @@ function wrapReason(reason) {
|
|||
}
|
||||
}
|
||||
|
||||
function makeReasonSerializable(reason) {
|
||||
if (!(reason instanceof Error) ||
|
||||
reason instanceof AbortException ||
|
||||
reason instanceof MissingPDFException ||
|
||||
reason instanceof UnexpectedResponseException ||
|
||||
reason instanceof UnknownErrorException) {
|
||||
return reason;
|
||||
}
|
||||
return new UnknownErrorException(reason.message, reason.toString());
|
||||
}
|
||||
|
||||
function resolveOrReject(capability, success, reason) {
|
||||
if (success) {
|
||||
capability.resolve();
|
||||
|
@ -1307,16 +1318,12 @@ function MessageHandler(sourceName, targetName, comObj) {
|
|||
data: result,
|
||||
});
|
||||
}, (reason) => {
|
||||
if (reason instanceof Error) {
|
||||
// Serialize error to avoid "DataCloneError"
|
||||
reason = reason + '';
|
||||
}
|
||||
comObj.postMessage({
|
||||
sourceName,
|
||||
targetName,
|
||||
isReply: true,
|
||||
callbackId: data.callbackId,
|
||||
error: reason,
|
||||
error: makeReasonSerializable(reason),
|
||||
});
|
||||
});
|
||||
} else if (data.streamId) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue