Re-factor setPDFNetworkStreamFactory, in src/display/api.js, to also accept an asynchronous function

As part of trying to reduce the usage of SystemJS in the development viewer, this patch is a necessary step that will allow removal of some `require` statements.

Currently this uses `SystemJS.import` in non-PRODUCTION mode, but it should be possible to replace those with standard *dynamic* `import` calls in the future.
This commit is contained in:
Jonas Jenwald 2020-05-19 15:10:05 +02:00
parent 0960e6c0b5
commit d4d933538b
4 changed files with 72 additions and 32 deletions

View file

@ -14,11 +14,6 @@
*/
/* globals __non_webpack_require__ */
const fs = __non_webpack_require__("fs");
const http = __non_webpack_require__("http");
const https = __non_webpack_require__("https");
const url = __non_webpack_require__("url");
import {
AbortException,
assert,
@ -30,6 +25,17 @@ import {
validateRangeRequestCapabilities,
} from "./network_utils.js";
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")) {
throw new Error(
'Module "./node_stream.js" shall not be used with MOZCENTRAL builds.'
);
}
const fs = __non_webpack_require__("fs");
const http = __non_webpack_require__("http");
const https = __non_webpack_require__("https");
const url = __non_webpack_require__("url");
const fileUriRegex = /^file:\/\/\/[a-zA-Z]:\//;
function parseUrl(sourceUrl) {