Emscripten: Enable modularity
This allows multiple instances of the game to be loaded in a single page. Also stop emitting htmls as a build artifact and require presence of #PowderSessionInfo.
This commit is contained in:
parent
25b15208cf
commit
7cb0ac96c9
2
.github/build.sh
vendored
2
.github/build.sh
vendored
@ -449,7 +449,7 @@ if [[ $PACKAGE_MODE == dmg ]]; then
|
||||
cp ../README.md dmgroot/README.md
|
||||
hdiutil create -format UDZO -volname $APP_NAME -fs HFS+ -srcfolder dmgroot -o $ASSET_PATH
|
||||
elif [[ $PACKAGE_MODE == emscripten ]]; then
|
||||
tar cvf $ASSET_PATH $APP_EXE.html $APP_EXE.js $APP_EXE.worker.js $APP_EXE.wasm
|
||||
tar cvf $ASSET_PATH $APP_EXE.js $APP_EXE.worker.js $APP_EXE.wasm
|
||||
elif [[ $PACKAGE_MODE == appimage ]]; then
|
||||
# so far this can only happen with $BSH_HOST_PLATFORM-$BSH_HOST_LIBC == linux-gnu, but this may change later
|
||||
case $BSH_HOST_ARCH in
|
||||
|
@ -212,6 +212,8 @@ if host_platform == 'emscripten'
|
||||
'-s', 'EXIT_RUNTIME=0',
|
||||
'-s', 'EXPORTED_RUNTIME_METHODS=ccall,cwrap',
|
||||
'-s', 'FS_DEBUG',
|
||||
'-s', 'MODULARIZE',
|
||||
'-s', 'EXPORT_NAME=create_' + app_exe,
|
||||
'-lidbfs.js',
|
||||
]
|
||||
emcc_args = [
|
||||
@ -371,7 +373,7 @@ font_files += data_files
|
||||
|
||||
if host_platform == 'emscripten'
|
||||
project_link_args += [
|
||||
'-o', app_exe + '.html', # so we get a .wasm, a .js, and a .html
|
||||
'-o', app_exe + '.js', # so we get a .wasm, and a .js
|
||||
]
|
||||
endif
|
||||
|
||||
|
@ -1,33 +1,33 @@
|
||||
#include "Client.h"
|
||||
#include "prefs/GlobalPrefs.h"
|
||||
#include <emscripten.h>
|
||||
#include <iostream>
|
||||
|
||||
void Client::LoadAuthUser()
|
||||
{
|
||||
std::optional<ByteString> newUsername;
|
||||
ByteString newUsername, newSessionKey;
|
||||
if (EM_ASM_INT({
|
||||
return document.querySelector("#PowderSessionInfo [name='Username']") ? 1 : 0;
|
||||
return (document.querySelector("#PowderSessionInfo [name='Username']") &&
|
||||
document.querySelector("#PowderSessionInfo [name='SessionKey']")) ? 1 : 0;
|
||||
}))
|
||||
{
|
||||
newUsername = ByteString(std::unique_ptr<char, decltype(&free)>((char *)EM_ASM_PTR({
|
||||
return stringToNewUTF8(document.querySelector("#PowderSessionInfo [name='Username']").value);
|
||||
}), free).get());
|
||||
}
|
||||
std::optional<ByteString> newSessionKey;
|
||||
if (EM_ASM_INT({
|
||||
return document.querySelector("#PowderSessionInfo [name='SessionKey']") ? 1 : 0;
|
||||
}))
|
||||
{
|
||||
newSessionKey = ByteString(std::unique_ptr<char, decltype(&free)>((char *)EM_ASM_PTR({
|
||||
return stringToNewUTF8(document.querySelector("#PowderSessionInfo [name='SessionKey']").value);
|
||||
}), free).get());
|
||||
}
|
||||
if (newUsername && newSessionKey)
|
||||
else
|
||||
{
|
||||
std::cerr << "required #PowderSessionInfo elements not found, can't authenticate" << std::endl;
|
||||
}
|
||||
if (newUsername.size() && newSessionKey.size())
|
||||
{
|
||||
authUser.UserID = -1; // Not quite valid but evaluates to true and that's all that matters for this codebase.
|
||||
authUser.Username = *newUsername;
|
||||
authUser.Username = newUsername;
|
||||
authUser.SessionID = "(invalid)";
|
||||
authUser.SessionKey = *newSessionKey;
|
||||
authUser.SessionKey = newSessionKey;
|
||||
authUser.UserElevation = User::ElevationNone; // We don't deal with this in the browser.
|
||||
}
|
||||
else
|
||||
|
@ -232,9 +232,6 @@ namespace http
|
||||
Module.emscriptenRequestManager.requests[$0].fetchMethod = UTF8ToString($1);
|
||||
}, handle->id, requestHandle->verb->c_str());
|
||||
}
|
||||
// TODO: set max redirects
|
||||
// TODO: set max concurrent streams
|
||||
// TODO: set connect timeout
|
||||
EM_ASM({
|
||||
let request = Module.emscriptenRequestManager.requests[$0];
|
||||
let token = $1;
|
||||
|
Loading…
Reference in New Issue
Block a user