Skip to content

Commit 54f3fbc

Browse files
committed
fix: Webkitのキーボードに伴う位置ズレバグをfocusin/outスクロールリセットと背景色同期により根本解決(v12/v15)
1 parent 4ea8f70 commit 54f3fbc

5 files changed

Lines changed: 26 additions & 10 deletions

File tree

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-v14";
1+
const CACHE_NAME = "launcherg-pwa-shell-mobile-pwa-v15";
22
const PRECACHE_ASSETS = Array.isArray(self.__LAUNCHERG_PWA_ASSETS__)
33
? self.__LAUNCHERG_PWA_ASSETS__
44
: [];

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-v11",
11+
client: "mobile-pwa-v12",
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-v11&mode=library&roomId=room-1&gameId=42&authToken=short-lived-token",
24+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v12&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-v11&mode=controller&roomId=room-1&authToken=short-lived-token",
87+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v12&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-v11&mode=controller&roomId=room-1&authToken=short-lived-token",
95+
"https://example.test/Launcherg-Mod/#/companion?client=mobile-pwa-v12&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-v11&mode=controller&roomId=room-1",
12+
"https://example.test/companion.html?client=mobile-pwa-v12&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-v11&mode=controller&roomId=room-1",
23+
"https://example.test/Launcherg-Mod/companion.html?client=mobile-pwa-v12&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-v11&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-v12&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-v11&mode=library&roomId=room-1",
49+
"https://example.test/companion.html?client=mobile-pwa-v12&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-v11";
6+
export const MOBILE_COMPANION_CLIENT_VERSION = "mobile-pwa-v12";
77
export const SKYWAY_CONNECT_ENDPOINT = "https://launcherg.ryoha.moe/connect";
88

99
export type MobileCompanionUrlParams = {

src/views/MobileCompanion.svelte

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -890,21 +890,32 @@
890890
lastActionText = "メモを同期しました";
891891
};
892892
893+
const handleViewportReset = () => {
894+
setTimeout(() => {
895+
window.scrollTo(0, 0);
896+
}, 50);
897+
};
898+
893899
onMount(() => {
894900
const htmlEl = document.documentElement;
895901
const bodyEl = document.body;
896902
const appEl = document.querySelector("#app") as HTMLElement | null;
897903
if (htmlEl) {
898904
htmlEl.style.height = "100dvh";
905+
htmlEl.style.backgroundColor = "#151515";
899906
}
900907
if (bodyEl) {
901908
bodyEl.style.height = "100dvh";
909+
bodyEl.style.backgroundColor = "#151515";
902910
}
903911
if (appEl) {
904912
appEl.style.overflow = "hidden";
905913
appEl.style.height = "100dvh";
906914
}
907915
916+
document.addEventListener("focusin", handleViewportReset);
917+
document.addEventListener("focusout", handleViewportReset);
918+
908919
void getAllCachedImages().then((cached) => {
909920
cached.forEach(({ path, blob }) => {
910921
const imageUrl = URL.createObjectURL(blob);
@@ -933,15 +944,20 @@
933944
const appEl = document.querySelector("#app") as HTMLElement | null;
934945
if (htmlEl) {
935946
htmlEl.style.height = "";
947+
htmlEl.style.backgroundColor = "";
936948
}
937949
if (bodyEl) {
938950
bodyEl.style.height = "";
951+
bodyEl.style.backgroundColor = "";
939952
}
940953
if (appEl) {
941954
appEl.style.overflow = "";
942955
appEl.style.height = "";
943956
}
944957
958+
document.removeEventListener("focusin", handleViewportReset);
959+
document.removeEventListener("focusout", handleViewportReset);
960+
945961
cleanupCallbacks.forEach((callback) => callback());
946962
cleanupCallbacks = [];
947963
objectUrls.forEach((url) => URL.revokeObjectURL(url));

0 commit comments

Comments
 (0)