Merge pull request #11919 from Snuffleupagus/less-SystemJS
Reduce usage of SystemJS, in the development viewer, even further
This commit is contained in:
commit
604a6f96aa
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"parserOptions": {
|
"parserOptions": {
|
||||||
"ecmaVersion": 8,
|
"ecmaVersion": 2020,
|
||||||
"sourceType": "module",
|
"sourceType": "module",
|
||||||
},
|
},
|
||||||
|
|
||||||
@ -17,13 +17,12 @@
|
|||||||
|
|
||||||
"env": {
|
"env": {
|
||||||
"browser": true,
|
"browser": true,
|
||||||
"es6": true,
|
"es2020": true,
|
||||||
"worker": true,
|
"worker": true,
|
||||||
"amd": true,
|
"amd": true,
|
||||||
},
|
},
|
||||||
|
|
||||||
"globals": {
|
"globals": {
|
||||||
"globalThis": false,
|
|
||||||
"PDFJSDev": false,
|
"PDFJSDev": false,
|
||||||
"exports": false,
|
"exports": false,
|
||||||
"SystemJS": false,
|
"SystemJS": false,
|
||||||
|
2
external/builder/preprocessor2.js
vendored
2
external/builder/preprocessor2.js
vendored
@ -322,7 +322,7 @@ function preprocessPDFJSCode(ctx, code) {
|
|||||||
},
|
},
|
||||||
};
|
};
|
||||||
var parseOptions = {
|
var parseOptions = {
|
||||||
ecmaVersion: 8,
|
ecmaVersion: 2020,
|
||||||
locations: true,
|
locations: true,
|
||||||
sourceFile: ctx.sourceFile,
|
sourceFile: ctx.sourceFile,
|
||||||
sourceType: "module",
|
sourceType: "module",
|
||||||
|
6
package-lock.json
generated
6
package-lock.json
generated
@ -3726,6 +3726,12 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"es-module-shims": {
|
||||||
|
"version": "0.4.6",
|
||||||
|
"resolved": "https://registry.npmjs.org/es-module-shims/-/es-module-shims-0.4.6.tgz",
|
||||||
|
"integrity": "sha512-EzVhnLyA/zvmGrAy2RU8m9xpxX7u2yb2by1GZH80SHF6lakG21YAm3Vo56KsLIXaIjT9QabqjYpQU1S5FkM8+Q==",
|
||||||
|
"dev": true
|
||||||
|
},
|
||||||
"es-to-primitive": {
|
"es-to-primitive": {
|
||||||
"version": "1.2.1",
|
"version": "1.2.1",
|
||||||
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
|
"resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz",
|
||||||
|
@ -23,6 +23,7 @@
|
|||||||
"eslint-plugin-no-unsanitized": "^3.1.1",
|
"eslint-plugin-no-unsanitized": "^3.1.1",
|
||||||
"eslint-plugin-prettier": "^3.1.3",
|
"eslint-plugin-prettier": "^3.1.3",
|
||||||
"eslint-plugin-unicorn": "^20.0.0",
|
"eslint-plugin-unicorn": "^20.0.0",
|
||||||
|
"es-module-shims": "^0.4.6",
|
||||||
"fancy-log": "^1.3.3",
|
"fancy-log": "^1.3.3",
|
||||||
"globals": "^11.12.0",
|
"globals": "^11.12.0",
|
||||||
"gulp": "^4.0.2",
|
"gulp": "^4.0.2",
|
||||||
|
13
src/core/.eslintrc
Normal file
13
src/core/.eslintrc
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{
|
||||||
|
"parserOptions": {
|
||||||
|
"ecmaVersion": 2017,
|
||||||
|
},
|
||||||
|
|
||||||
|
"extends": [
|
||||||
|
"../../.eslintrc"
|
||||||
|
],
|
||||||
|
|
||||||
|
"env": {
|
||||||
|
"es2017": true,
|
||||||
|
},
|
||||||
|
}
|
@ -1650,7 +1650,9 @@ const PDFWorker = (function PDFWorkerClosure() {
|
|||||||
}
|
}
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||||
if (typeof SystemJS !== "object") {
|
if (typeof SystemJS !== "object") {
|
||||||
throw new Error("SystemJS must be used to load fake worker.");
|
// Manually load SystemJS, since it's only necessary for fake workers.
|
||||||
|
await loadScript("../node_modules/systemjs/dist/system.js");
|
||||||
|
await loadScript("../systemjs.config.js");
|
||||||
}
|
}
|
||||||
const worker = await SystemJS.import("pdfjs/core/worker.js");
|
const worker = await SystemJS.import("pdfjs/core/worker.js");
|
||||||
return worker.WorkerMessageHandler;
|
return worker.WorkerMessageHandler;
|
||||||
|
@ -65,8 +65,8 @@ const pdfjsBuild =
|
|||||||
|
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||||
const streamsPromise = Promise.all([
|
const streamsPromise = Promise.all([
|
||||||
SystemJS.import("pdfjs/display/network.js"),
|
import("pdfjs/display/network.js"),
|
||||||
SystemJS.import("pdfjs/display/fetch_stream.js"),
|
import("pdfjs/display/fetch_stream.js"),
|
||||||
]);
|
]);
|
||||||
setPDFNetworkStreamFactory(params => {
|
setPDFNetworkStreamFactory(params => {
|
||||||
return streamsPromise.then(streams => {
|
return streamsPromise.then(streams => {
|
||||||
|
@ -1833,7 +1833,9 @@ async function loadFakeWorker() {
|
|||||||
}
|
}
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||||
if (typeof SystemJS !== "object") {
|
if (typeof SystemJS !== "object") {
|
||||||
throw new Error("SystemJS must be used to load fake worker.");
|
// Manually load SystemJS, since it's only necessary for fake workers.
|
||||||
|
await loadScript("../node_modules/systemjs/dist/system.js");
|
||||||
|
await loadScript("../systemjs.config.js");
|
||||||
}
|
}
|
||||||
window.pdfjsWorker = await SystemJS.import("pdfjs/core/worker.js");
|
window.pdfjsWorker = await SystemJS.import("pdfjs/core/worker.js");
|
||||||
return undefined;
|
return undefined;
|
||||||
|
@ -45,8 +45,18 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if !PRODUCTION-->
|
<!--#if !PRODUCTION-->
|
||||||
<script src="../node_modules/systemjs/dist/system.js"></script>
|
<script defer src="../node_modules/es-module-shims/dist/es-module-shims.js"></script>
|
||||||
<script src="../systemjs.config.js"></script>
|
<script type="importmap-shim">
|
||||||
|
{
|
||||||
|
"imports": {
|
||||||
|
"pdfjs/": "../src/",
|
||||||
|
"pdfjs-lib": "../src/pdf.js",
|
||||||
|
"pdfjs-web/": "./"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="viewer.js" type="module-shim"></script>
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if (GENERIC && !MINIFIED) -->
|
<!--#if (GENERIC && !MINIFIED) -->
|
||||||
@ -54,7 +64,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
|
||||||
<!--#if !MINIFIED -->
|
<!--#if !MINIFIED -->
|
||||||
<script src="viewer.js"></script>
|
<!--<script src="viewer.js"></script>-->
|
||||||
<!--#else-->
|
<!--#else-->
|
||||||
<!--#include viewer-snippet-minified.html-->
|
<!--#include viewer-snippet-minified.html-->
|
||||||
<!--#endif-->
|
<!--#endif-->
|
||||||
|
@ -189,11 +189,11 @@ function webViewerLoad() {
|
|||||||
const config = getViewerConfiguration();
|
const config = getViewerConfiguration();
|
||||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||||
Promise.all([
|
Promise.all([
|
||||||
SystemJS.import("pdfjs-web/app.js"),
|
import("pdfjs-web/app.js"),
|
||||||
SystemJS.import("pdfjs-web/app_options.js"),
|
import("pdfjs-web/app_options.js"),
|
||||||
SystemJS.import("pdfjs-web/genericcom.js"),
|
import("pdfjs-web/genericcom.js"),
|
||||||
SystemJS.import("pdfjs-web/pdf_print_service.js"),
|
import("pdfjs-web/pdf_print_service.js"),
|
||||||
]).then(function ([app, appOptions, ...otherModules]) {
|
]).then(function ([app, appOptions, genericCom, pdfPrintService]) {
|
||||||
window.PDFViewerApplication = app.PDFViewerApplication;
|
window.PDFViewerApplication = app.PDFViewerApplication;
|
||||||
window.PDFViewerApplicationOptions = appOptions.AppOptions;
|
window.PDFViewerApplicationOptions = appOptions.AppOptions;
|
||||||
app.PDFViewerApplication.run(config);
|
app.PDFViewerApplication.run(config);
|
||||||
|
Loading…
Reference in New Issue
Block a user