mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-22 16:18:08 +02:00
Re-implement working dev-sandbox
/watch-dev-sandbox
gulp-tasks
Compared to the, previously removed, `sandbox`/`watch-sandbox` gulp-tasks, these ones should work even when run against an non-existent/empty `build`-folder. Also, to ensure that the development viewer actually works out-of-the-box, `gulp server` will now also include `gulp watch-dev-sandbox` to remove the need to *manually* invoke the build-tasks. Finally, this patch also removes the `web/devcom.js` file since it shouldn't actually be needed, assuming that the "sandbox"-loading code in the `web/genericcom.js` file is actually *correctly* implemented.
This commit is contained in:
parent
13d7244529
commit
c39f1aedb2
5 changed files with 67 additions and 65 deletions
|
@ -223,14 +223,6 @@ const defaultOptions = {
|
|||
value: false,
|
||||
kind: OptionKind.API,
|
||||
},
|
||||
scriptingSrc: {
|
||||
/** @type {string} */
|
||||
value:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
? "../build/generic/build/pdf.sandbox.js"
|
||||
: "../build/pdf.sandbox.js",
|
||||
kind: OptionKind.VIEWER,
|
||||
},
|
||||
verbosity: {
|
||||
/** @type {number} */
|
||||
value: 1,
|
||||
|
@ -265,6 +257,14 @@ if (
|
|||
value: typeof navigator !== "undefined" ? navigator.language : "en-US",
|
||||
kind: OptionKind.VIEWER,
|
||||
};
|
||||
defaultOptions.sandboxBundleSrc = {
|
||||
/** @type {string} */
|
||||
value:
|
||||
typeof PDFJSDev === "undefined" || !PDFJSDev.test("PRODUCTION")
|
||||
? "../build/dev-sandbox/pdf.sandbox.js"
|
||||
: "../build/pdf.sandbox.js",
|
||||
kind: OptionKind.VIEWER,
|
||||
};
|
||||
}
|
||||
|
||||
const userOptions = Object.create(null);
|
||||
|
|
|
@ -1,43 +0,0 @@
|
|||
/* Copyright 2017 Mozilla Foundation
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { DefaultExternalServices, PDFViewerApplication } from "./app.js";
|
||||
import { loadScript, shadow } from "pdfjs-lib";
|
||||
|
||||
const DevCom = {};
|
||||
|
||||
class DevExternalServices extends DefaultExternalServices {
|
||||
static get scripting() {
|
||||
const promise = loadScript("../build/pdf.sandbox.js").then(() => {
|
||||
return window.pdfjsSandbox.QuickJSSandbox();
|
||||
});
|
||||
const sandbox = {
|
||||
createSandbox(data) {
|
||||
promise.then(sbx => sbx.create(data));
|
||||
},
|
||||
dispatchEventInSandbox(event) {
|
||||
promise.then(sbx => sbx.dispatchEvent(event));
|
||||
},
|
||||
destroySandbox() {
|
||||
promise.then(sbx => sbx.nukeSandbox());
|
||||
},
|
||||
};
|
||||
|
||||
return shadow(this, "scripting", sandbox);
|
||||
}
|
||||
}
|
||||
PDFViewerApplication.externalServices = DevExternalServices;
|
||||
|
||||
export { DevCom };
|
|
@ -53,7 +53,7 @@ class GenericExternalServices extends DefaultExternalServices {
|
|||
}
|
||||
|
||||
static get scripting() {
|
||||
const promise = loadScript(AppOptions.get("scriptingSrc")).then(() => {
|
||||
const promise = loadScript(AppOptions.get("sandboxBundleSrc")).then(() => {
|
||||
return window.pdfjsSandbox.QuickJSSandbox();
|
||||
});
|
||||
const sandbox = {
|
||||
|
|
|
@ -56,9 +56,6 @@ if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("GENERIC")) {
|
|||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME")) {
|
||||
require("./chromecom.js");
|
||||
}
|
||||
if (typeof PDFJSDev === "undefined") {
|
||||
import("./devcom.js");
|
||||
}
|
||||
if (typeof PDFJSDev !== "undefined" && PDFJSDev.test("CHROME || GENERIC")) {
|
||||
require("./pdf_print_service.js");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue