-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed asar issues in release builds (quickjs-emscripten, source-map, …
…etc...)
- Loading branch information
Showing
9 changed files
with
137 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,28 +7,7 @@ | |
resolved "https://registry.yarnpkg.com/@jitl/quickjs-ffi-types/-/quickjs-ffi-types-0.29.2.tgz#91aaa6be43471b5c8fc3a85f94582c86d345ba2e" | ||
integrity sha512-069uQTiEla2PphXg6UpyyJ4QXHkTj3S9TeXgaMCd8NDYz3ODBw5U/rkg6fhuU8SMpoDrWjEzybmV5Mi2Pafb5w== | ||
|
||
"@jitl/[email protected]": | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/@jitl/quickjs-wasmfile-debug-asyncify/-/quickjs-wasmfile-debug-asyncify-0.29.2.tgz#ddf58d1ab90b94a70a73b93f95c4e17f16d0a2a9" | ||
integrity sha512-YdRw2414pFkxzyyoJGv81Grbo9THp/5athDMKipaSBNNQvFE9FGRrgE9tt2DT2mhNnBx1kamtOGj0dX84Yy9bg== | ||
dependencies: | ||
"@jitl/quickjs-ffi-types" "0.29.2" | ||
|
||
"@jitl/[email protected]": | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/@jitl/quickjs-wasmfile-debug-sync/-/quickjs-wasmfile-debug-sync-0.29.2.tgz#b1a9c0f9371de2e8e67f8d025c0d9c9b7360f175" | ||
integrity sha512-VgisubjyPMWEr44g+OU0QWGyIxu7VkApkLHMxdORX351cw22aLTJ+Z79DJ8IVrTWc7jh4CBPsaK71RBQDuVB7w== | ||
dependencies: | ||
"@jitl/quickjs-ffi-types" "0.29.2" | ||
|
||
"@jitl/[email protected]": | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/@jitl/quickjs-wasmfile-release-asyncify/-/quickjs-wasmfile-release-asyncify-0.29.2.tgz#51c23bfd93d56d9eaab47ee937838c91376b093a" | ||
integrity sha512-sf3luCPr8wBVmGV6UV8Set+ie8wcO6mz5wMvDVO0b90UVCKfgnx65A1JfeA+zaSGoaFyTZ3sEpXSGJU+6qJmLw== | ||
dependencies: | ||
"@jitl/quickjs-ffi-types" "0.29.2" | ||
|
||
"@jitl/[email protected]": | ||
"@jitl/quickjs-wasmfile-release-sync@^0.29.2": | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/@jitl/quickjs-wasmfile-release-sync/-/quickjs-wasmfile-release-sync-0.29.2.tgz#7a9a055739bfc6261203701a46e2c627cfabe6f2" | ||
integrity sha512-UFIcbY3LxBRUjEqCHq3Oa6bgX5znt51V5NQck8L2US4u989ErasiMLUjmhq6UPC837Sjqu37letEK/ZpqlJ7aA== | ||
|
@@ -132,24 +111,13 @@ node-gyp-build@^4.2.1: | |
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.3.0.tgz#9f256b03e5826150be39c764bf51e993946d71a3" | ||
integrity sha512-iWjXZvmboq0ja1pUGULQBexmxq8CV4xBhX7VDOTbL7ZR4FOowwY/VOtRxBN/yKxmdGoIp4j5ysNT4u3S2pDQ3Q== | ||
|
||
[email protected]: | ||
quickjs-emscripten-core@^0.29.2: | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/quickjs-emscripten-core/-/quickjs-emscripten-core-0.29.2.tgz#ad9bef103fce7d8ba879510905824e33119a62f3" | ||
integrity sha512-jEAiURW4jGqwO/fW01VwlWqa2G0AJxnN5FBy1xnVu8VIVhVhiaxUfCe+bHqS6zWzfjFm86HoO40lzpteusvyJA== | ||
dependencies: | ||
"@jitl/quickjs-ffi-types" "0.29.2" | ||
|
||
quickjs-emscripten@^0.29.2: | ||
version "0.29.2" | ||
resolved "https://registry.yarnpkg.com/quickjs-emscripten/-/quickjs-emscripten-0.29.2.tgz#da6c7afb543cc5b4854eaca457778cfae5069f8b" | ||
integrity sha512-SlvkvyZgarReu2nr4rkf+xz1vN0YDUz7sx4WHz8LFtK6RNg4/vzAGcFjE7nfHYBEbKrzfIWvKnMnxZkctQ898w== | ||
dependencies: | ||
"@jitl/quickjs-wasmfile-debug-asyncify" "0.29.2" | ||
"@jitl/quickjs-wasmfile-debug-sync" "0.29.2" | ||
"@jitl/quickjs-wasmfile-release-asyncify" "0.29.2" | ||
"@jitl/quickjs-wasmfile-release-sync" "0.29.2" | ||
quickjs-emscripten-core "0.29.2" | ||
|
||
"readable-stream@>=1.0.33-1 <1.1.0-0": | ||
version "1.0.34" | ||
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-1.0.34.tgz#125820e34bc842d2f2aaafafe4c2916ee32c157c" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import { app } from 'electron'; | ||
import { existsSync } from 'fs'; | ||
import path from 'path'; | ||
|
||
type Method = (...args: string[]) => string; | ||
|
||
function wrap(method: Method): Method { | ||
return function (): string { | ||
const result = method.call(path, ...arguments); | ||
|
||
// .wasm modules cannot be shipped inside of app.asar | ||
// so we ship them in app.asar.unpacked, but we need to | ||
// adjust the file paths that they are loaded from | ||
if ( | ||
result.endsWith('.wasm') && | ||
result.includes('app.asar') && | ||
!result.includes('app.asar.unpacked') | ||
) { | ||
const unpackedPath = result.replace(/app.asar/g, 'app.asar.unpacked'); | ||
if (existsSync(unpackedPath)) { | ||
return unpackedPath; | ||
} | ||
} | ||
|
||
return result; | ||
}; | ||
} | ||
|
||
if (app.isPackaged) { | ||
path.resolve = wrap(path.resolve); | ||
path.join = wrap(path.join); | ||
path.normalize = wrap(path.normalize); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
import { app } from 'electron'; | ||
import { readFileSync } from 'fs'; | ||
import path from 'path'; | ||
import { | ||
newQuickJSWASMModuleFromVariant, | ||
QuickJSWASMModule, | ||
newVariant, | ||
} from 'quickjs-emscripten-core'; | ||
import releaseSyncVariant from '@jitl/quickjs-wasmfile-release-sync'; | ||
|
||
let loadedQuickJSWASMModule: QuickJSWASMModule | null; | ||
|
||
export async function initQuickJS(): Promise<void> { | ||
const modulePath = path.join( | ||
process.resourcesPath, | ||
'app.asar.unpacked/node_modules', | ||
'@jitl/quickjs-wasmfile-release-sync/dist' | ||
); | ||
|
||
// issue: https://github.com/electron/asar/issues/249 | ||
// fix: https://github.com/electron/electron/pull/37535 | ||
// lots of blockers prevent upgrading electron & NodeJS versions :( | ||
const variant = app.isPackaged | ||
? newVariant( | ||
{ | ||
...releaseSyncVariant, | ||
importModuleLoader: () => { | ||
const mjsSourceCode = readFileSync( | ||
path.join(modulePath, 'emscripten-module.mjs') | ||
) | ||
.toString() | ||
.replace( | ||
/import.meta.url/g, | ||
`"file:///${modulePath.replace(/\\/g, '/')}"` | ||
) | ||
.replace('export default ', ''); | ||
return eval(mjsSourceCode); | ||
}, | ||
}, | ||
{ | ||
wasmBinary: readFileSync( | ||
path.join(modulePath, 'emscripten-module.wasm') | ||
), | ||
} | ||
) | ||
: releaseSyncVariant; | ||
|
||
loadedQuickJSWASMModule = await newQuickJSWASMModuleFromVariant(variant); | ||
} | ||
|
||
export function getQuickJS(): QuickJSWASMModule { | ||
if (loadedQuickJSWASMModule == null) { | ||
throw new Error('QuickJS module not loaded'); | ||
} | ||
return loadedQuickJSWASMModule; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters