mirror of
https://github.com/mozilla/pdf.js.git
synced 2025-04-19 22:58:07 +02:00
Merge pull request #17055 from Snuffleupagus/output-modules
[api-major] Output JavaScript modules in the builds (issue 10317)
This commit is contained in:
commit
bab4c7f617
24 changed files with 231 additions and 308 deletions
|
@ -34,7 +34,7 @@ const STANDARD_FONT_DATA_URL = "/build/generic/web/standard_fonts/";
|
|||
const IMAGE_RESOURCES_PATH = "/web/images/";
|
||||
const VIEWER_CSS = "../build/components/pdf_viewer.css";
|
||||
const VIEWER_LOCALE = "en-US";
|
||||
const WORKER_SRC = "../build/generic/build/pdf.worker.js";
|
||||
const WORKER_SRC = "../build/generic/build/pdf.worker.mjs";
|
||||
const RENDER_TASK_ON_CONTINUE_DELAY = 5; // ms
|
||||
const SVG_NS = "http://www.w3.org/2000/svg";
|
||||
|
||||
|
|
|
@ -18,8 +18,8 @@ limitations under the License.
|
|||
<head>
|
||||
<title>PDF.js test slave</title>
|
||||
<meta charset="utf-8">
|
||||
<script src="../build/generic/build/pdf.js"></script>
|
||||
<script src="../build/components/pdf_viewer.js"></script>
|
||||
<script src="../build/generic/build/pdf.mjs" type="module"></script>
|
||||
<script src="../build/components/pdf_viewer.mjs" type="module"></script>
|
||||
|
||||
<link rel="resource" type="application/l10n" href="../build/generic/web/locale/locale.properties">
|
||||
</head>
|
||||
|
|
|
@ -56,6 +56,8 @@ import { GlobalImageCache } from "../../src/core/image_utils.js";
|
|||
import { GlobalWorkerOptions } from "../../src/display/worker_options.js";
|
||||
import { Metadata } from "../../src/display/metadata.js";
|
||||
|
||||
const WORKER_SRC = "../../build/generic/build/pdf.worker.mjs";
|
||||
|
||||
describe("api", function () {
|
||||
const basicApiFileName = "basicapi.pdf";
|
||||
const basicApiFileLength = 105779; // bytes
|
||||
|
@ -914,7 +916,8 @@ describe("api", function () {
|
|||
}
|
||||
|
||||
GlobalWorkerOptions.workerPort = new Worker(
|
||||
new URL("../../build/generic/build/pdf.worker.js", window.location)
|
||||
new URL(WORKER_SRC, window.location),
|
||||
{ type: "module" }
|
||||
);
|
||||
|
||||
const loadingTask1 = getDocument(basicApiGetDocumentParams);
|
||||
|
@ -934,7 +937,8 @@ describe("api", function () {
|
|||
}
|
||||
|
||||
GlobalWorkerOptions.workerPort = new Worker(
|
||||
new URL("../../build/generic/build/pdf.worker.js", window.location)
|
||||
new URL(WORKER_SRC, window.location),
|
||||
{ type: "module" }
|
||||
);
|
||||
|
||||
const loadingTask1 = getDocument(basicApiGetDocumentParams);
|
||||
|
@ -963,7 +967,8 @@ describe("api", function () {
|
|||
}
|
||||
|
||||
GlobalWorkerOptions.workerPort = new Worker(
|
||||
new URL("../../build/generic/build/pdf.worker.js", window.location)
|
||||
new URL(WORKER_SRC, window.location),
|
||||
{ type: "module" }
|
||||
);
|
||||
|
||||
const loadingTask = getDocument(basicApiGetDocumentParams);
|
||||
|
|
|
@ -108,7 +108,7 @@ async function initializePDFJS(callback) {
|
|||
);
|
||||
}
|
||||
// Configure the worker.
|
||||
GlobalWorkerOptions.workerSrc = "../../build/generic/build/pdf.worker.js";
|
||||
GlobalWorkerOptions.workerSrc = "../../build/generic/build/pdf.worker.mjs";
|
||||
|
||||
callback();
|
||||
}
|
||||
|
|
|
@ -49,7 +49,6 @@ import {
|
|||
getXfaPageViewport,
|
||||
isDataScheme,
|
||||
isPdfFile,
|
||||
loadScript,
|
||||
noContextMenu,
|
||||
PDFDateString,
|
||||
PixelsPerInch,
|
||||
|
@ -88,7 +87,6 @@ const expectedAPI = Object.freeze({
|
|||
InvalidPDFException,
|
||||
isDataScheme,
|
||||
isPdfFile,
|
||||
loadScript,
|
||||
MissingPDFException,
|
||||
noContextMenu,
|
||||
normalizeUnicode,
|
||||
|
@ -132,10 +130,9 @@ describe("web_pdfjsLib", function () {
|
|||
if (isNodeJS) {
|
||||
pending("loadScript is not supported in Node.js.");
|
||||
}
|
||||
await loadScript(
|
||||
"../../build/generic/build/pdf.js",
|
||||
/* removeScriptElement = */ true
|
||||
);
|
||||
const apiPath = "../../build/generic/build/pdf.mjs";
|
||||
await import(apiPath);
|
||||
|
||||
const webPdfjsLib = await import("../../web/pdfjs.js");
|
||||
|
||||
expect(Object.keys(webPdfjsLib).sort()).toEqual(
|
||||
|
|
|
@ -13,9 +13,7 @@
|
|||
* limitations under the License.
|
||||
*/
|
||||
|
||||
import { loadScript } from "../../src/display/display_utils.js";
|
||||
|
||||
const sandboxBundleSrc = "../../build/generic/build/pdf.sandbox.js";
|
||||
const sandboxBundleSrc = "../../build/generic/build/pdf.sandbox.mjs";
|
||||
|
||||
describe("Scripting", function () {
|
||||
let sandbox, send_queue, test_id, ref, windowAlert;
|
||||
|
@ -53,8 +51,9 @@ describe("Scripting", function () {
|
|||
const command = "alert";
|
||||
send_queue.set(command, { command, value });
|
||||
};
|
||||
const promise = loadScript(sandboxBundleSrc).then(() => {
|
||||
return window.pdfjsSandbox.QuickJSSandbox();
|
||||
// eslint-disable-next-line no-unsanitized/method
|
||||
const promise = import(sandboxBundleSrc).then(pdfjsSandbox => {
|
||||
return pdfjsSandbox.QuickJSSandbox();
|
||||
});
|
||||
sandbox = {
|
||||
createSandbox(data) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue