Skip to content

Commit

Permalink
Cherry pick NPM fix
Browse files Browse the repository at this point in the history
  • Loading branch information
lpugin committed Nov 26, 2019
1 parent 3725b68 commit 654119c
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 48 deletions.
4 changes: 2 additions & 2 deletions emscripten/buildToolkit
Original file line number Diff line number Diff line change
Expand Up @@ -207,8 +207,8 @@ if ($? == 0) {
# the wrapper is necessary with closure 1 for avoiding to conflict with globals
`cat $BUILD_DIR/verovio.js verovio-js-start.js verovio-proxy.js > $BUILD_DIR/$FILENAME`;

# wrap the npm package (but not with wasm build for now)
if (!$wasmQ) {
# wrap the npm package (but not with wasm build and without humdrum for now)
if (!$wasmQ && !$lightQ && $nohumdrum) {
print "Building $NPM package\n";
# the cat order is different for the npm package because we want to wrap the Module in the init function
`cat verovio-npm-start.js $BUILD_DIR/verovio.js verovio-proxy.js verovio-npm-end.js > $NPM/index.js`;
Expand Down
20 changes: 1 addition & 19 deletions emscripten/verovio-npm-end.js
Original file line number Diff line number Diff line change
@@ -1,21 +1,3 @@
// ... verovio-proxy.js preceed

//console.log(Module.getMemory());

// Check what to return - an instance, or the contructor method
if (createInstance) {
return new verovio.toolkit();
}
else {
return { toolkit:verovio.toolkit };
}
}

// Minimal function
verovio.toolkit = function() {
return init(0, true);
}

// Both exports
module.exports = { toolkit:verovio.toolkit };
module.exports.init = init;

27 changes: 0 additions & 27 deletions emscripten/verovio-npm-start.js
Original file line number Diff line number Diff line change
@@ -1,29 +1,2 @@

var verovio = verovio || {};

/* beginning of the init function that adjsut the memory (if required) and load the module */

init = function (memory, createInstance = false) {

// If we ask for creating an instance are already have one, just call the contructor
if (createInstance && verovio.ptr != undefined) {
return new verovio.toolkit();
}

var Module;if(typeof Module==="undefined")Module={};
if (memory > 0) {
if (memory < 256) {
console.warn("Memory setting ignore because it should be at least 256");
}
else if (memory >= 1024) {
console.warn("Memory setting ignored because it should be less than 1024");
}
else {
Module.TOTAL_MEMORY = 2*memory*1024*1024;
Module.TOTAL_STACK = memory*1024*1024;
console.info("Maxmimum memory increased to " + memory + "MB");
}
}

// The verovio-proxy.js follows...

0 comments on commit 654119c

Please sign in to comment.