Skip to content

Commit

Permalink
Merge pull request #19337 from Snuffleupagus/dev-wasm
Browse files Browse the repository at this point in the history
Support multiple wasm-files in the development viewer
  • Loading branch information
Snuffleupagus authored Jan 21, 2025
2 parents 23dc3ff + 0053b36 commit 79a976c
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 11 deletions.
26 changes: 22 additions & 4 deletions gulpfile.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -650,10 +650,12 @@ function createStandardFontBundle() {
}

function createWasmBundle() {
return gulp.src(["external/openjpeg/openjpeg.wasm"], {
base: "external/openjpeg",
encoding: false,
});
return ordered([
gulp.src(["external/openjpeg/*.wasm"], {
base: "external/openjpeg",
encoding: false,
}),
]);
}

function checkFile(filePath) {
Expand Down Expand Up @@ -2077,6 +2079,15 @@ gulp.task(
)
);

gulp.task("dev-wasm", function () {
const VIEWER_WASM_OUTPUT = "web/wasm/";

fs.rmSync(VIEWER_WASM_OUTPUT, { recursive: true, force: true });
fs.mkdirSync(VIEWER_WASM_OUTPUT, { recursive: true });

return createWasmBundle().pipe(gulp.dest(VIEWER_WASM_OUTPUT));
});

gulp.task(
"dev-sandbox",
gulp.series(
Expand Down Expand Up @@ -2112,6 +2123,13 @@ gulp.task(
gulp.series("locale")
);
},
function watchWasm() {
gulp.watch(
"external/openjpeg/*",
{ ignoreInitial: false },
gulp.series("dev-wasm")
);
},
function watchDevSandbox() {
gulp.watch(
[
Expand Down
2 changes: 1 addition & 1 deletion web/.gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
locale.properties
locale/
cmaps/
wasm/
9 changes: 3 additions & 6 deletions web/app_options.js
Original file line number Diff line number Diff line change
Expand Up @@ -434,12 +434,9 @@ const defaultOptions = {
wasmUrl: {
/** @type {string} */
value:
// eslint-disable-next-line no-nested-ternary
typeof PDFJSDev === "undefined"
? "../external/openjpeg/"
: PDFJSDev.test("MOZCENTRAL")
? "resource://pdf.js/web/wasm/"
: "../web/wasm/",
typeof PDFJSDev !== "undefined" && PDFJSDev.test("MOZCENTRAL")
? "resource://pdf.js/web/wasm/"
: "../web/wasm/",
kind: OptionKind.API,
},

Expand Down

0 comments on commit 79a976c

Please sign in to comment.