Play Windows games on Apple Silicon Macs. Free, open-source app that installs the official Battle.net, Steam, Epic and GOG launchers and lists your games in one library.
HTML apple-siliconbattle-netcrossover-alternatived3dmetaldiablo-ii-resurrecteddxmtea-appepic-gamesgame-porting-toolkitgogmac-gamingmacosmacos-gamingrockstar-gamessteamubisoft-connectwhisky-alternativewindows-gameswinewine-wrapper
Fix Steam import on React All Games pages and stalled Battle.net setup (v1.6.8) (#53)
Mikekc1fc39f6230e
diff --git a/README.ko.md b/README.ko.mdindex a6d89b5bd6a..05ea95a408c 100644--- a/README.ko.md+++ b/README.ko.md@@ -80,7 +80,7 @@ soju install # 이후: soju battlenet / soju d2r / soju steam / soju epic /설치기는 **다운로드 전에 원하는 런처부터 선택**합니다. Steam만 선택하면 CX 엔진과 애플 GPTK를 받지 않습니다. Steam 그래픽 구성요소는 SHA-256으로 검증한 뒤 Soju 전용 Wine 11.0 환경에 자동으로 설치합니다. Battle.net·Epic·GOG는 공통 CX 엔진과 사용자가 별도로 받은 애플 GPTK를 사용합니다. 각 런처의 보틀·로그인·게임은 독립적으로 유지합니다.-[Soju 맥 앱 다운로드](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip): 네이티브 앱 프리뷰에서 설치된 게임과 보유 게임, 스토어 검색, 즐겨찾기, 게임 실행, 플랫폼 관리를 한 화면에서 다룰 수 있습니다. [설치 안내와 요구 사항](docs/DESKTOP.md)을 확인해 주세요.+[Soju 맥 앱 다운로드](https://github.com/BCD1210/soju/releases/download/v1.6.8/Soju-1.6.8-macos-arm64.zip): 네이티브 앱 프리뷰에서 설치된 게임과 보유 게임, 스토어 검색, 즐겨찾기, 게임 실행, 플랫폼 관리를 한 화면에서 다룰 수 있습니다. [설치 안내와 요구 사항](docs/DESKTOP.md)을 확인해 주세요.## 일상 명령diff --git a/README.md b/README.mdindex 11d64b8eea7..a061273cb7a 100644--- a/README.md+++ b/README.md@@ -24,7 +24,7 @@ CodeWeavers' published sources; Steam uses a separate private Wine 11 setup.Apple's proprietary GPTK/D3DMetal is downloaded separately. Games and storeclients are not included.-**Current release: [v1.6.7](https://github.com/BCD1210/soju/releases/tag/v1.6.7).**+**Current release: [v1.6.8](https://github.com/BCD1210/soju/releases/tag/v1.6.8).**The compatibility examples below were verified on M4 Pro / macOS 26.5.D2R and Hogwarts Legacy are examples of supported games, not the scope of the project.@@ -98,7 +98,7 @@ soju install # then: soju battlenet / soju d2r / soju steam / soju epic / soThe installer asks which launchers you want **before downloading anything**. Steam-only installs skip the CX engine and Apple GPTK. Steam rendering components are downloaded with SHA-256 verification and installed in a Soju-owned Wine 11.0 runtime. Battle.net, Epic and GOG use the shared CX engine and your separately downloaded Apple GPTK. Each official client keeps its own bottle and shortcut in `~/Applications`.-[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip): the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).+[Download Soju for Mac](https://github.com/BCD1210/soju/releases/download/v1.6.8/Soju-1.6.8-macos-arm64.zip): the native desktop preview includes installed and owned games, store search, favorites, game launching and platform management. See [desktop setup and requirements](docs/DESKTOP.md).## Everyday commandsdiff --git a/README.zh.md b/README.zh.mdindex 20b80171eb7..c7fef65c886 100644--- a/README.zh.md+++ b/README.zh.md@@ -84,7 +84,7 @@ soju install # 然后:soju battlenet / soju d2r / soju steam / soju epic /安装器会**先询问要安装哪些启动器,再下载对应组件**。仅选择 Steam 时,不会下载 CX 引擎或 Apple GPTK。Steam 图形组件经过 SHA-256 校验后,自动安装到 Soju 专用的 Wine 11.0 环境中。战网、Epic 和 GOG 使用共享 CX 引擎及用户单独下载的 Apple GPTK。各客户端的 bottle、账户和游戏分别保留。-[下载 Soju Mac 应用](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip):原生桌面预览版在一个窗口中管理已安装和已拥有的游戏、商店搜索、收藏、游戏启动和平台管理。[安装说明与要求](docs/DESKTOP.md)。+[下载 Soju Mac 应用](https://github.com/BCD1210/soju/releases/download/v1.6.8/Soju-1.6.8-macos-arm64.zip):原生桌面预览版在一个窗口中管理已安装和已拥有的游戏、商店搜索、收藏、游戏启动和平台管理。[安装说明与要求](docs/DESKTOP.md)。## 日常维护diff --git a/VERSION b/VERSIONindex 400084b1bf2..d8c5e721a77 100644--- a/VERSION+++ b/VERSION@@ -1 +1 @@-1.6.7+1.6.8diff --git a/app/Accounts.swift b/app/Accounts.swiftindex 7c79112b836..95f64655301 100644--- a/app/Accounts.swift+++ b/app/Accounts.swift@@ -204,7 +204,7 @@ struct AccountsView: View {HStack {Label(platform.title, systemImage: platform.symbol).font(.headline)if let value = summary(platform) {- Text(value.label + " · " + String(value.count) + " games · " + String(value.updatedAt.prefix(10))).font(.caption).foregroundStyle(.secondary)+ Text(verbatim: "\(value.label) · \(value.count) games · \(value.updatedAt.prefix(10))").font(.caption).foregroundStyle(.secondary)Spacer()Button("Disconnect") { model.forgetAccount(platform) }.disabled(model.accountBusy)} else { Spacer(); Text("Not connected").font(.caption).foregroundStyle(.secondary) }diff --git a/docs/DESKTOP.md b/docs/DESKTOP.mdindex b5dcef1de17..091e200e5fd 100644--- a/docs/DESKTOP.md+++ b/docs/DESKTOP.md@@ -1,6 +1,6 @@# Soju for Mac-[Download v1.6.7](https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip)+[Download v1.6.8](https://github.com/BCD1210/soju/releases/download/v1.6.8/Soju-1.6.8-macos-arm64.zip)1. Unzip and move **Soju.app** into Applications or ~/Applications.2. Open **Platforms** to install or open Battle.net, Steam, Epic Games or GOG GALAXY.diff --git a/docs/index.html b/docs/index.htmlindex 49ed3c84b4f..317dafbeadd 100644--- a/docs/index.html+++ b/docs/index.html@@ -124,7 +124,7 @@ its own login, purchases, downloads and game updates.</p><section id="install" aria-labelledby="install-title"><h2 id="install-title">Choose your launchers. Get set up.</h2>-<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.7/Soju-1.6.7-macos-arm64.zip">Download Soju for Mac</a></p>+<p><a class="btn" href="https://github.com/BCD1210/soju/releases/download/v1.6.8/Soju-1.6.8-macos-arm64.zip">Download Soju for Mac</a></p><p>The native desktop preview combines installed and imported owned games, searches stores and manages all four launchers.Apple Silicon · app UI: macOS 14+ · Steam component build: macOS 26+.<a href="https://github.com/BCD1210/soju/blob/main/docs/DESKTOP.md">Setup and signing notes</a>.</p>diff --git a/resources/steam-library.js b/resources/steam-library.jsindex 626994730ac..544bec52b48 100644--- a/resources/steam-library.js+++ b/resources/steam-library.js@@ -7,10 +7,23 @@ const attribute = name => {try { return JSON.parse(config?.getAttribute(name) || "{}"); } catch { return {}; }};const user = attribute("data-userinfo");+// Steam's React pages, the current All Games page among them, have no+// application_config, g_steamID or account menu. Their viewer is UserConfig.+const reactUser = window.UserConfig && typeof window.UserConfig === "object" ? window.UserConfig : null;const validID = value => /^765[0-9]{14}$/.test(String(value || ""));-let steamid = String(window.g_steamID || user.steamid || "");-if (validID(user.steamid) && validID(steamid) && String(user.steamid) !== steamid) {- return { state: "unavailable" };+const viewers = [window.g_steamID, user.steamid, reactUser?.steamid].filter(validID).map(String);+if (new Set(viewers).size > 1) return { state: "unavailable" };+let steamid = viewers[0] || "";+const loggedIn = user.logged_in === true || reactUser?.logged_in === true;+function reactToken() {+ if (reactUser?.logged_in !== true || !Array.isArray(window.SSR?.loaderData)) return "";+ for (const item of window.SSR.loaderData) {+ try {+ const value = typeof item === "string" ? JSON.parse(item) : item;+ if (typeof value?.strWebAPIToken === "string" && value.strWebAPIToken) return value.strWebAPIToken;+ } catch {}+ }+ return "";}function snapshot(rows, count) {@@ -39,7 +52,7 @@ const ownAllGames = () => validID(steamid) && location.hostname === "steamcommunnew URLSearchParams(location.search).get("tab") === "all" && profile === steamid &&Array.isArray(window.rgGames);if (ownAllGames()) return snapshot(window.rgGames, window.rgGames.length);-if (validID(steamid) && validID(profile) && !ownAllGames() && !user.webapi_token) {+if (!reactUser && validID(steamid) && validID(profile) && !ownAllGames() && !user.webapi_token) {return { state: "open-library" };}const signedInPage = !!document.querySelector?.("#account_pulldown");@@ -56,12 +69,12 @@ async function readJSON(url, credentials, limit) {return JSON.parse(raw);}try {- let token = user.logged_in === true && typeof user.webapi_token === "string" ? user.webapi_token : "";+ let token = user.logged_in === true && typeof user.webapi_token === "string" ? user.webapi_token : reactToken();// Steam's legacy community pages can omit both identity and the token.// Ask Steam's own session endpoint on the same origin; do not scrape cookies.const loginPage = /^\/(login|openid)(\/|$)/.test(location.pathname);if (!token && location.hostname === "steamcommunity.com" && !loginPage &&- (validID(steamid) || user.logged_in === true || signedInPage)) {+ (validID(steamid) || loggedIn || signedInPage)) {const session = await readJSON("https://steamcommunity.com/chat/clientjstoken", "same-origin", 64 * 1024);if (session.logged_in !== true || !validID(session.steamid)) {return { state: validID(steamid) ? "open-library" : "sign-in" };diff --git a/scripts/create-bottle.sh b/scripts/create-bottle.shindex 8d4139bf9d9..20513465f23 100755--- a/scripts/create-bottle.sh+++ b/scripts/create-bottle.sh@@ -33,20 +33,67 @@ for HIVE in "HKLM\\Software\\Microsoft\\Windows NT\\CurrentVersion\\AeDebug" \done"$ENGINE/bin/wineserver" -w-echo "==> Downloading the Battle.net installer (official Blizzard)"+BN="$WINEPREFIX/drive_c/Program Files (x86)/Battle.net"+PROGRAMDATA="$WINEPREFIX/drive_c/ProgramData"SETUP="$WORK/Battle.net-Setup.exe"-[ -f "$SETUP" ] || { curl -fL "https://downloader.battle.net/download/getInstaller?os=win&installer=Battle.net-Setup.exe" -o "$SETUP.part" && mv -f "$SETUP.part" "$SETUP"; }+SETUP_TIMEOUT="${SETUP_TIMEOUT:-600}"++download_setup() {+ [ -f "$SETUP" ] || { curl -fL "https://downloader.battle.net/download/getInstaller?os=win&installer=Battle.net-Setup.exe" -o "$SETUP.part" && mv -f "$SETUP.part" "$SETUP"; }+}++# Blizzard's setup resumes from what an unfinished attempt left in ProgramData+# and can stall at 45% on it. Without a finished install, move that state aside+# (kept for its logs) so the installer starts clean.+set_aside_setup_state() {+ [ ! -f "$BN/Battle.net.exe" ] || return 0+ local keep="" dir+ for dir in "Battle.net" "Battle.net_components" "Blizzard Entertainment"; do+ [ -e "$PROGRAMDATA/$dir" ] || continue+ [ -n "$keep" ] || keep=$(mktemp -d "$WORK/previous-setup-$(date +%Y%m%d-%H%M%S).XXXX")+ mv "$PROGRAMDATA/$dir" "$keep/"+ done+ [ -z "$keep" ] || echo " Moved an unfinished earlier setup aside: $keep"+}++# Succeeds once the installer exits or Battle.net.exe exists; stops a stalled+# installer after SETUP_TIMEOUT seconds instead of waiting forever.+run_setup() {+ "$ENGINE/bin/wine" "$SETUP" --lang=enUS >/dev/null 2>&1 &+ local pid=$! waited=0+ while kill -0 "$pid" 2>/dev/null; do+ if [ "$waited" -ge "$SETUP_TIMEOUT" ]; then+ [ ! -f "$BN/Battle.net.exe" ] || return 0+ kill "$pid" 2>/dev/null || true+ "$ENGINE/bin/wineserver" -k 2>/dev/null || true+ wait "$pid" 2>/dev/null || true+ return 1+ fi+ sleep 1; waited=$((waited + 1))+ done+ wait "$pid" 2>/dev/null || true+}++echo "==> Downloading the Battle.net installer (official Blizzard)"+download_setup+set_aside_setup_stateecho "==> Running the installer (a few minutes, fully automatic)"-"$ENGINE/bin/wine" "$SETUP" --lang=enUS >/dev/null 2>&1 || true+if ! run_setup; then+ echo "==> The installer did not finish in $(( (SETUP_TIMEOUT + 59) / 60 )) minutes (Battle.net setup can stall at 45%)."+ echo " Retrying once from a clean state with a fresh installer download"+ set_aside_setup_state+ rm -f "$SETUP"+ download_setup+ run_setup || { echo "The installer stalled again, logs: $PROGRAMDATA/Battle.net/Setup"; exit 1; }+fi# Wait for the install to finish (up to 10 minutes)for i in $(seq 1 60); do- [ -f "$WINEPREFIX/drive_c/Program Files (x86)/Battle.net/Battle.net.exe" ] && break+ [ -f "$BN/Battle.net.exe" ] && breaksleep 10done-BN="$WINEPREFIX/drive_c/Program Files (x86)/Battle.net"-[ -f "$BN/Battle.net.exe" ] || { echo "Install failed, logs: $WINEPREFIX/drive_c/ProgramData/Battle.net/Setup"; exit 1; }+[ -f "$BN/Battle.net.exe" ] || { echo "Install failed, logs: $PROGRAMDATA/Battle.net/Setup"; exit 1; }echo "==> Battle.net installed""$ENGINE/bin/wineserver" -k 2>/dev/null || truediff --git a/tests/test_installation.py b/tests/test_installation.pyindex 2bd0ef0b5b7..1beca0518d3 100644--- a/tests/test_installation.py+++ b/tests/test_installation.py@@ -151,5 +151,61 @@ class RecoveryTests(unittest.TestCase):self.assertEqual((prefix/"user.reg").read_text(),"changed")self.assertEqual((system/"d3d11.dll").read_text(),"changed")+class BattleNetSetupTests(unittest.TestCase):+ def install(self, stalls):+ temp = tempfile.TemporaryDirectory()+ self.addCleanup(temp.cleanup)+ d = Path(temp.name); engine = d/"engine"; work = d/"work"; prefix = d/"bottle"; bin_ = d/"bin"+ for path in (engine/"bin", engine/"lib/external", work, bin_):+ path.mkdir(parents=True)+ (engine/"lib/external/libd3dshared.dylib").write_text("")+ (work/"Battle.net-Setup.exe").write_text("cached installer")+ stale = prefix/"drive_c/ProgramData/Battle.net/Agent"+ stale.mkdir(parents=True); (stale/"state").write_text("unfinished")+ tools = {+ engine/"bin/wineserver": "exit 0\n",+ engine/"bin/wine": f"""case "$1" in wineboot|reg) exit 0;; esac+n=$(( $(cat "{d}/attempts" 2>/dev/null || echo 0) + 1 )); echo $n > "{d}/attempts"+mkdir -p "$WINEPREFIX/drive_c/ProgramData/Battle.net/Setup"+[ $n -le {stalls} ] && exec sleep 30+mkdir -p "$WINEPREFIX/drive_c/Program Files (x86)/Battle.net"+touch "$WINEPREFIX/drive_c/Program Files (x86)/Battle.net/Battle.net.exe"+""",+ bin_/"curl": f"""while [ $# -gt 0 ]; do [ "$1" = -o ] && out="$2"; shift; done+echo fresh > "$out"; echo x >> "{d}/downloads"+""",+ }+ for path, body in tools.items():+ path.write_text("#!/bin/bash\n" + body); path.chmod(0o755)+ result = subprocess.run(["/bin/bash", str(ROOT/"scripts/create-bottle.sh")], capture_output=True, text=True,+ env={**os.environ, "ENGINE": str(engine), "WORK": str(work), "WINEPREFIX": str(prefix),+ "SETUP_TIMEOUT": "1", "PATH": f"{bin_}:{os.environ['PATH']}"}, timeout=60)+ attempts = int((d/"attempts").read_text()) if (d/"attempts").exists() else 0+ downloads = len((d/"downloads").read_text().split()) if (d/"downloads").exists() else 0+ return result, prefix, work, attempts, downloads++ def test_stalled_installer_retries_once_from_clean_state(self):+ result, prefix, work, attempts, downloads = self.install(stalls=1)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertTrue((prefix/"drive_c/Program Files (x86)/Battle.net/Battle.net.exe").exists())+ self.assertEqual((attempts, downloads), (2, 1))+ self.assertIn("Retrying once", result.stdout)+ kept = list(work.glob("previous-setup-*/Battle.net/Agent/state"))+ self.assertEqual([p.read_text() for p in kept], ["unfinished"])+ self.assertEqual((work/"Battle.net-Setup.exe").read_text().strip(), "fresh")++ def test_installer_that_stalls_twice_fails_instead_of_hanging(self):+ result, prefix, work, attempts, downloads = self.install(stalls=2)+ self.assertNotEqual(result.returncode, 0)+ self.assertIn("stalled again", result.stdout)+ self.assertEqual(attempts, 2)+ self.assertFalse((prefix/"drive_c/Program Files (x86)/Battle.net/Battle.net.exe").exists())++ def test_clean_install_runs_once_without_moving_anything(self):+ result, prefix, work, attempts, downloads = self.install(stalls=0)+ self.assertEqual(result.returncode, 0, result.stdout + result.stderr)+ self.assertEqual((attempts, downloads), (1, 0))+ self.assertNotIn("Retrying", result.stdout)+if __name__ == "__main__":unittest.main()diff --git a/tests/test_steam_login.cjs b/tests/test_steam_login.cjsindex f198755f570..7fec2b48503 100644--- a/tests/test_steam_login.cjs+++ b/tests/test_steam_login.cjs@@ -107,3 +107,49 @@ test("partial legacy page can retry after its data finishes loading", async () =const retried=await run(...ctx, ()=>{throw Error("not needed");});assert.equal(retried.state,"ready");});+function reactPage(userConfig, loaderData = [JSON.stringify({steamid:id, sort:"name"})]) {+ const document = {getElementById:()=>null, querySelector:()=>null};+ return [{UserConfig:userConfig, SSR:{loaderData}}, document, new URL("https://steamcommunity.com/id/example/games")];+}+test("React All Games page imports via Steam's own session", async () => {+ const requests = [];+ const result = await run(...reactPage({logged_in:true, steamid:id}), async (url, options) => {+ requests.push(new URL(url).origin + new URL(url).pathname);+ if (url === "https://steamcommunity.com/chat/clientjstoken") {+ assert.equal(options.credentials, "same-origin");+ return {ok:true,text:async()=>JSON.stringify({logged_in:true,steamid:id,token:"session-only"})};+ }+ assert.equal(new URL(url).searchParams.get("access_token"), "session-only");+ assert.equal(options.credentials, "omit");+ return {ok:true,text:async()=>JSON.stringify({response:{game_count:1,games:[{appid:10,name:"Owned"}]}})};+ });+ assert.deepEqual(requests, ["https://steamcommunity.com/chat/clientjstoken",+ "https://api.steampowered.com/IPlayerService/GetOwnedGames/v1/"]);+ assert.deepEqual(result, {state:"ready", steamid:id, game_count:1, games:[{appid:"10", name:"Owned"}]});+ assert.ok(!JSON.stringify(result).includes("session-only"));+});+test("React page token is used directly and never returned", async () => {+ const page = reactPage({logged_in:true, steamid:id}, [JSON.stringify({strWebAPIToken:"page-token"}), "not json"]);+ let requests = 0;+ const result = await run(...page, async (url) => {+ requests++;+ assert.equal(new URL(url).searchParams.get("access_token"), "page-token");+ return {ok:true,text:async()=>JSON.stringify({response:{game_count:0}})};+ });+ assert.equal(requests, 1);+ assert.equal(result.state, "ready");+ assert.ok(!JSON.stringify(result).includes("page-token"));+});+test("signed-out React page asks for sign-in without requests", async () => {+ const page = reactPage({logged_in:false, steamid:"0"}, [JSON.stringify({strWebAPIToken:"ignored"})]);+ assert.deepEqual(await run(...page, () => { throw Error("must not fetch"); }), {state:"sign-in"});+});+test("React viewer must match every other identity on the page", async () => {+ const page = reactPage({logged_in:true, steamid:id});+ page[0].g_steamID = "76561198000000001";+ assert.deepEqual(await run(...page, () => { throw Error("must not fetch"); }), {state:"unavailable"});+ const session = reactPage({logged_in:true, steamid:id});+ const result = await run(...session, async () =>+ ({ok:true,text:async()=>JSON.stringify({logged_in:true,steamid:"76561198000000001",token:"other"})}));+ assert.equal(result.state, "unavailable");+});