mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-20 15:18:08 +02:00
Merge pull request #16305 from Snuffleupagus/PDFJSDev-skip-PRODUCTION
Remove the `PRODUCTION` build-target
This commit is contained in:
commit
c9359957e6
31 changed files with 89 additions and 269 deletions
16
web/app.js
16
web/app.js
|
@ -310,7 +310,7 @@ const PDFViewerApplication = {
|
|||
params = parseQueryString(hash);
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) &&
|
||||
typeof PDFJSDev === "undefined" &&
|
||||
params.get("workermodules") === "true"
|
||||
) {
|
||||
AppOptions.set("workerSrc", "../src/pdf.worker.js");
|
||||
|
@ -377,8 +377,7 @@ const PDFViewerApplication = {
|
|||
}
|
||||
// It is not possible to change locale for the (various) extension builds.
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
params.has("locale")
|
||||
) {
|
||||
AppOptions.set("locale", params.get("locale"));
|
||||
|
@ -390,7 +389,7 @@ const PDFViewerApplication = {
|
|||
*/
|
||||
async _initializeL10n() {
|
||||
this.l10n = this.externalServices.createL10n(
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")
|
||||
? { locale: AppOptions.get("locale") }
|
||||
: null
|
||||
);
|
||||
|
@ -480,8 +479,7 @@ const PDFViewerApplication = {
|
|||
const pdfScriptingManager = new PDFScriptingManager({
|
||||
eventBus,
|
||||
sandboxBundleSrc:
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC || CHROME")
|
||||
typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC || CHROME")
|
||||
? AppOptions.get("sandboxBundleSrc")
|
||||
: null,
|
||||
scriptingFactory: externalServices,
|
||||
|
@ -959,7 +957,7 @@ const PDFViewerApplication = {
|
|||
...args,
|
||||
};
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
params.docBaseUrl ||= document.URL.split("#")[0];
|
||||
} else if (PDFJSDev.test("MOZCENTRAL || CHROME")) {
|
||||
params.docBaseUrl ||= this.baseUrl;
|
||||
|
@ -2159,7 +2157,7 @@ if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
|||
async function loadFakeWorker() {
|
||||
GlobalWorkerOptions.workerSrc ||= AppOptions.get("workerSrc");
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
window.pdfjsWorker = await import("pdfjs/pdf.worker.js");
|
||||
return;
|
||||
}
|
||||
|
@ -2169,7 +2167,7 @@ async function loadFakeWorker() {
|
|||
async function loadPDFBug(self) {
|
||||
const { debuggerScriptPath } = self.appConfig;
|
||||
const { PDFBug } =
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? await import(debuggerScriptPath) // eslint-disable-line no-unsanitized/method
|
||||
: await __non_webpack_import__(debuggerScriptPath); // eslint-disable-line no-undef
|
||||
|
||||
|
|
|
@ -158,7 +158,7 @@ const defaultOptions = {
|
|||
},
|
||||
pdfBugEnabled: {
|
||||
/** @type {boolean} */
|
||||
value: typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION"),
|
||||
value: typeof PDFJSDev === "undefined",
|
||||
kind: OptionKind.VIEWER + OptionKind.PREFERENCE,
|
||||
},
|
||||
printResolution: {
|
||||
|
@ -210,9 +210,7 @@ const defaultOptions = {
|
|||
cMapUrl: {
|
||||
/** @type {string} */
|
||||
value:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
? "../external/bcmaps/"
|
||||
: "../web/cmaps/",
|
||||
typeof PDFJSDev === "undefined" ? "../external/bcmaps/" : "../web/cmaps/",
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
disableAutoFetch: {
|
||||
|
@ -273,7 +271,7 @@ const defaultOptions = {
|
|||
standardFontDataUrl: {
|
||||
/** @type {string} */
|
||||
value:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? "../external/standard_fonts/"
|
||||
: "../web/standard_fonts/",
|
||||
kind: OptionKind.API,
|
||||
|
@ -293,7 +291,7 @@ const defaultOptions = {
|
|||
/** @type {string} */
|
||||
value:
|
||||
// eslint-disable-next-line no-nested-ternary
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? "../src/worker_loader.js"
|
||||
: PDFJSDev.test("MOZCENTRAL")
|
||||
? "resource://pdf.js/build/pdf.worker.js"
|
||||
|
@ -301,10 +299,7 @@ const defaultOptions = {
|
|||
kind: OptionKind.WORKER,
|
||||
},
|
||||
};
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
defaultOptions.defaultUrl = {
|
||||
/** @type {string} */
|
||||
value: "compressed.tracemonkey-pldi-09.pdf",
|
||||
|
@ -323,7 +318,7 @@ if (
|
|||
defaultOptions.sandboxBundleSrc = {
|
||||
/** @type {string} */
|
||||
value:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? "../build/dev-sandbox/pdf.sandbox.js"
|
||||
: "../build/pdf.sandbox.js",
|
||||
kind: OptionKind.VIEWER,
|
||||
|
|
|
@ -165,10 +165,7 @@ class PDFPageView {
|
|||
|
||||
this.renderTask = null;
|
||||
this.resume = null;
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
this._isStandalone = !this.renderingQueue?.hasViewer();
|
||||
}
|
||||
|
||||
|
@ -194,8 +191,7 @@ class PDFPageView {
|
|||
container?.append(div);
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
this._isStandalone
|
||||
) {
|
||||
// Ensure that the various layers always get the correct initial size,
|
||||
|
@ -549,8 +545,7 @@ class PDFPageView {
|
|||
this.#setDimensions();
|
||||
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")) &&
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) &&
|
||||
this._isStandalone
|
||||
) {
|
||||
this.div.parentNode?.style.setProperty(
|
||||
|
@ -687,8 +682,7 @@ class PDFPageView {
|
|||
}) {
|
||||
// Scale target (canvas), its wrapper and page container.
|
||||
if (
|
||||
(typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || TESTING")) &&
|
||||
(typeof PDFJSDev === "undefined" || PDFJSDev.test("TESTING")) &&
|
||||
!(target instanceof HTMLCanvasElement)
|
||||
) {
|
||||
throw new Error("Expected `target` to be a canvas.");
|
||||
|
|
|
@ -240,10 +240,7 @@ class PDFViewer {
|
|||
this.container = options.container;
|
||||
this.viewer = options.viewer || options.container.firstElementChild;
|
||||
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
if (this.container?.tagName !== "DIV" || this.viewer?.tagName !== "DIV") {
|
||||
throw new Error("Invalid `container` and/or `viewer` option.");
|
||||
}
|
||||
|
@ -269,10 +266,7 @@ class PDFViewer {
|
|||
options.annotationEditorMode ?? AnnotationEditorType.NONE;
|
||||
this.imageResourcesPath = options.imageResourcesPath || "";
|
||||
this.enablePrintAutoRotate = options.enablePrintAutoRotate || false;
|
||||
if (
|
||||
typeof PDFJSDev === "undefined" ||
|
||||
PDFJSDev.test("!PRODUCTION || GENERIC")
|
||||
) {
|
||||
if (typeof PDFJSDev === "undefined" || PDFJSDev.test("GENERIC")) {
|
||||
this.removePageBorders = options.removePageBorders || false;
|
||||
}
|
||||
this.useOnlyCssZoom = options.useOnlyCssZoom || false;
|
||||
|
|
|
@ -22,7 +22,7 @@ import { AppOptions, OptionKind } from "./app_options.js";
|
|||
*/
|
||||
class BasePreferences {
|
||||
#defaults = Object.freeze(
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
typeof PDFJSDev === "undefined"
|
||||
? AppOptions.getAll(OptionKind.PREFERENCE)
|
||||
: PDFJSDev.eval("DEFAULT_PREFERENCES")
|
||||
);
|
||||
|
|
|
@ -64,7 +64,7 @@ function getViewerConfiguration() {
|
|||
function webViewerLoad() {
|
||||
const config = getViewerConfiguration();
|
||||
|
||||
if (typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")) {
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
window.isGECKOVIEW = true;
|
||||
}
|
||||
PDFViewerApplication.run(config);
|
||||
|
|
|
@ -49,7 +49,7 @@ See https://github.com/adobe-type-tools/cmap-resources
|
|||
<!--<script src="resource://pdf.js/web/viewer.js"></script>-->
|
||||
<!--#elif !MINIFIED-->
|
||||
<!--<script src="viewer.js"></script>-->
|
||||
<!--#elif !PRODUCTION-->
|
||||
<!--#elif /* Development mode. */-->
|
||||
<link rel="resource" type="application/l10n" href="locale/locale.properties">
|
||||
|
||||
<script defer src="../node_modules/es-module-shims/dist/es-module-shims.js"></script>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue