Skip to content

Commit

Permalink
fix: do not crash when AL and Browser are not accessible, fix #36
Browse files Browse the repository at this point in the history
  • Loading branch information
arianrhodsandlot committed Aug 16, 2024
1 parent ea35451 commit 7b9a80c
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,12 +78,24 @@ function patchCoreJs({ js, name }: { js: string; name: string }) {
Module.FS = FS;
Module.PATH = PATH;
Module.ERRNO_CODES = ERRNO_CODES;
return { AL, Browser, JSEvents, Module, exit: _emscripten_force_exit }
return {
AL: typeof AL === 'undefined' ? null: AL,
Browser: typeof Browser === 'undefined' ? null: Browser,
JSEvents,
Module,
exit: _emscripten_force_exit
}
}`
} else if (isEsmScript(js)) {
jsContent = `${js.replace(
'readyPromiseResolve(Module)',
'readyPromiseResolve({ AL, Browser, JSEvents, Module, exit: _emscripten_force_exit })',
`readyPromiseResolve({
AL: typeof AL === 'undefined' ? null: AL,
Browser: typeof Browser === 'undefined' ? null: Browser,
JSEvents,
Module,
exit: _emscripten_force_exit
})`,
)};
export function getEmscripten({ Module }) {
return (libretro_${name} || ${name})(Module)
Expand Down

0 comments on commit 7b9a80c

Please sign in to comment.