Skip to content

Commit

Permalink
wasm modularize
Browse files Browse the repository at this point in the history
  • Loading branch information
paulocoutinhox committed Nov 8, 2022
1 parent f536ebb commit 6e6db22
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions extras/wasm/template/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
let autoOpenMode = true;
let doc;
let FPDF = {};
let Module = null;

// pdfium initialization
Object.assign(FPDF, {
Expand Down Expand Up @@ -279,15 +280,17 @@
}

// runtime initialized
Module.onRuntimeInitialized = async _ => {
PDFiumModule().then(function (pdfiumModule) {
Module = pdfiumModule;

moduleLoaded = true;

if (pageLoaded) {
console.log('The module was loaded!');
}

checkIfEverythingWasLoaded();
};
});

// functions
async function loadFile() {
Expand Down
8 changes: 4 additions & 4 deletions modules/wasm.py
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,6 @@ def run_task_test():
"ASSERTIONS=1",
"-s",
"ALLOW_MEMORY_GROWTH=1",
"-sMODULARIZE",
"--embed-file",
"assets/web-assembly.pdf",
]
Expand Down Expand Up @@ -621,16 +620,16 @@ def run_task_generate():

f.recreate_dir(gen_out_dir)

html_file = os.path.join(
output_file = os.path.join(
gen_out_dir,
"pdfium.html",
"pdfium.js",
)

command = [
"em++",
"{0}".format("-g" if config == "debug" else "-O3"),
"-o",
html_file,
output_file,
"-s",
'EXPORTED_FUNCTIONS="$(node function-names ../xml/index.xml)"',
"-s",
Expand All @@ -651,6 +650,7 @@ def run_task_generate():
"-s",
"ALLOW_MEMORY_GROWTH=1",
"-sMODULARIZE",
"-sEXPORT_NAME=PDFiumModule",
"-std=c++11",
"-Wall",
"--no-entry",
Expand Down

0 comments on commit 6e6db22

Please sign in to comment.