Skip to content

Commit 6da96fc

Browse files
committed
fix: モバイル連携画面のスクロール干渉バグ修正およびセーフエリア・PWAキャッシュ更新(v10/v13)
1 parent b0598d0 commit 6da96fc

7 files changed

Lines changed: 34 additions & 16 deletions

File tree

public/companion.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<html lang="ja">
33
<head>
44
<meta charset="UTF-8" />
5-
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
5+
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
66
<title>Launcherg Mobile Companion</title>
77
<script>
88
(() => {

public/sw.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const CACHE_NAME = "launcherg-pwa-shell-mobile-pwa-v12";
1+
const CACHE_NAME = "launcherg-pwa-shell-mobile-pwa-v13";
22
const PRECACHE_ASSETS = Array.isArray(self.__LAUNCHERG_PWA_ASSETS__)
33
? self.__LAUNCHERG_PWA_ASSETS__
44
: [];

src/App.svelte

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -195,14 +195,18 @@
195195
}
196196
}, 0);
197197
};
198-
document.addEventListener("focusin", handleFocusIn);
198+
if (!isCompanionRoute) {
199+
document.addEventListener("focusin", handleFocusIn);
200+
}
199201
200202
const preventScroll = () => {
201203
if (window.scrollY !== 0) {
202204
window.scrollTo(0, 0);
203205
}
204206
};
205-
window.addEventListener("scroll", preventScroll, { passive: true });
207+
if (!isCompanionRoute) {
208+
window.addEventListener("scroll", preventScroll, { passive: true });
209+
}
206210
207211
// Disable reload shortcuts inside the app shell.
208212
const handleKeydown = (e: KeyboardEvent) => {
@@ -219,8 +223,10 @@
219223
return () => {
220224
didUnmount = true;
221225
window.removeEventListener("keydown", handleKeydown);
222-
document.removeEventListener("focusin", handleFocusIn);
223-
window.removeEventListener("scroll", preventScroll);
226+
if (!isCompanionRoute) {
227+
document.removeEventListener("focusin", handleFocusIn);
228+
window.removeEventListener("scroll", preventScroll);
229+
}
224230
cleanupGlobalErrorLogging();
225231
cleanupTooltips();
226232
cleanupHistory();

src/lib/mobileCompanionInstall.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import {
88
describe("createMobileCompanionInstallStartUrl", () => {
99
it("keeps the room in the installed launch URL", () => {
1010
const query = new URLSearchParams({
11-
client: "mobile-pwa-v9",
11+
client: "mobile-pwa-v10",
1212
mode: "library",
1313
roomId: "room-1",
1414
gameId: "42",
@@ -21,7 +21,7 @@ describe("createMobileCompanionInstallStartUrl", () => {
2121
query,
2222
),
2323
).toBe(
24-
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v9&mode=library&roomId=room-1&gameId=42&authToken=short-lived-token",
24+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v10&mode=library&roomId=room-1&gameId=42&authToken=short-lived-token",
2525
);
2626
});
2727

@@ -84,15 +84,15 @@ describe("configureMobileCompanionInstallManifest", () => {
8484
const link = document.querySelector<HTMLLinkElement>('link[rel="manifest"]');
8585

8686
expect(startUrl).toBe(
87-
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v9&mode=controller&roomId=room-1&authToken=short-lived-token",
87+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v10&mode=controller&roomId=room-1&authToken=short-lived-token",
8888
);
8989
expect(link?.href).toContain("data:application/manifest+json");
9090
expect(link?.dataset.launchergDynamicCompanionManifest).toBe("true");
9191
const manifest = JSON.parse(
9292
decodeURIComponent(link?.href.split(",")[1] ?? ""),
9393
);
9494
expect(manifest.start_url).toBe(
95-
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v9&mode=controller&roomId=room-1&authToken=short-lived-token",
95+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v10&mode=controller&roomId=room-1&authToken=short-lived-token",
9696
);
9797
});
9898
});

src/lib/mobileCompanionUrl.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ describe("createMobileCompanionUrl", () => {
99
});
1010

1111
expect(url).toBe(
12-
"https://example.test/companion.html?client=mobile-pwa-v9&mode=controller&roomId=room-1",
12+
"https://example.test/companion.html?client=mobile-pwa-v10&mode=controller&roomId=room-1",
1313
);
1414
});
1515

@@ -20,7 +20,7 @@ describe("createMobileCompanionUrl", () => {
2020
});
2121

2222
expect(url).toBe(
23-
"https://example.test/Launcherg-Mod/companion.html?client=mobile-pwa-v9&mode=controller&roomId=room-1",
23+
"https://example.test/Launcherg-Mod/companion.html?client=mobile-pwa-v10&mode=controller&roomId=room-1",
2424
);
2525
});
2626

@@ -34,7 +34,7 @@ describe("createMobileCompanionUrl", () => {
3434
});
3535

3636
expect(url).toBe(
37-
"https://example.test/companion.html?client=mobile-pwa-v9&mode=controller&roomId=room-1&gameId=42&seiyaUrl=https%3A%2F%2Fseiya.example%2Fgame%3Fid%3D42&authToken=token-1",
37+
"https://example.test/companion.html?client=mobile-pwa-v10&mode=controller&roomId=room-1&gameId=42&seiyaUrl=https%3A%2F%2Fseiya.example%2Fgame%3Fid%3D42&authToken=token-1",
3838
);
3939
});
4040

@@ -46,7 +46,7 @@ describe("createMobileCompanionUrl", () => {
4646
});
4747

4848
expect(url).toBe(
49-
"https://example.test/companion.html?client=mobile-pwa-v9&mode=library&roomId=room-1",
49+
"https://example.test/companion.html?client=mobile-pwa-v10&mode=library&roomId=room-1",
5050
);
5151
});
5252
});

src/lib/mobileCompanionUrl.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ const configuredMobileCompanionOrigin =
33

44
export const MOBILE_COMPANION_ORIGIN =
55
configuredMobileCompanionOrigin || "https://nnnsmm.github.io/Launcherg-Mod/";
6-
export const MOBILE_COMPANION_CLIENT_VERSION = "mobile-pwa-v9";
6+
export const MOBILE_COMPANION_CLIENT_VERSION = "mobile-pwa-v10";
77
export const SKYWAY_CONNECT_ENDPOINT = "https://launcherg.ryoha.moe/connect";
88

99
export type MobileCompanionUrlParams = {

src/views/MobileCompanion.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -891,6 +891,12 @@
891891
};
892892
893893
onMount(() => {
894+
const appEl = document.querySelector("#app") as HTMLElement | null;
895+
if (appEl) {
896+
appEl.style.overflow = "hidden";
897+
appEl.style.height = "100%";
898+
}
899+
894900
void getAllCachedImages().then((cached) => {
895901
cached.forEach(({ path, blob }) => {
896902
const imageUrl = URL.createObjectURL(blob);
@@ -914,6 +920,12 @@
914920
});
915921
916922
onDestroy(() => {
923+
const appEl = document.querySelector("#app") as HTMLElement | null;
924+
if (appEl) {
925+
appEl.style.overflow = "";
926+
appEl.style.height = "";
927+
}
928+
917929
cleanupCallbacks.forEach((callback) => callback());
918930
cleanupCallbacks = [];
919931
objectUrls.forEach((url) => URL.revokeObjectURL(url));
@@ -1250,7 +1262,7 @@
12501262
12511263
.topbar {
12521264
min-height: 64px;
1253-
padding: 14px 16px 12px;
1265+
padding: calc(14px + env(safe-area-inset-top, 0px)) 16px 12px;
12541266
display: flex;
12551267
align-items: center;
12561268
justify-content: space-between;

0 commit comments

Comments
 (0)