37070c3cb7
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Has been skipped
CI / integration (pull_request) Has been skipped
CI / ui (pull_request) Successful in 56s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 2m13s
Finalises the Telegram Mini App navigation work after on-device testing (Pixel 10 / Android 17 + iOS, fresh beta clients): - Remove requestFullscreen entirely. Immersive fullscreen hid Telegram's native header (and its BackButton) and the Android system swipe-back minimised the app; the owner prefers the windowed full-size (expand) presentation, so the app never requests fullscreen on any platform now. - The app's own back chevron (Header, showBack = !!back) drives back-navigation on every platform; the native Telegram BackButton is dropped — it does not render in the windowed Mini App (backVisible=false on iOS and Android), so relying on it lost back navigation (notably none on iOS). - Replace the temporary always-on diagnostic overlay with a hidden debug panel (components/DebugPanel): ten quick taps on the header title open it; it shows a privacy-safe client diagnostic snapshot (app version, locale, online, userId, Telegram chrome / viewport / SDK state — no secrets, no IP) and shares it via the OS share sheet / clipboard; a tap anywhere except Share dismisses it. - Drop the now-dead telegramRequestFullscreen / telegramBackButton / isTelegramAndroid helpers and the iOS-fullscreen unit test. Telegram has no native non-modal notification API (only modal showPopup / showAlert), so in-app toasts stay ours. Docs: UI_DESIGN.md.
149 lines
5.7 KiB
Svelte
149 lines
5.7 KiB
Svelte
<script lang="ts">
|
|
import { onMount } from 'svelte';
|
|
import { cubicOut } from 'svelte/easing';
|
|
import { app, bootstrap } from './lib/app.svelte';
|
|
import { router, type RouteName } from './lib/router.svelte';
|
|
import { t } from './lib/i18n/index.svelte';
|
|
import Toast from './components/Toast.svelte';
|
|
import Splash from './components/Splash.svelte';
|
|
import StaleInviteModal from './components/StaleInviteModal.svelte';
|
|
import WelcomeRedeemModal from './components/WelcomeRedeemModal.svelte';
|
|
import DebugPanel from './components/DebugPanel.svelte';
|
|
import Login from './screens/Login.svelte';
|
|
import Lobby from './screens/Lobby.svelte';
|
|
import NewGame from './screens/NewGame.svelte';
|
|
import SettingsHub from './screens/SettingsHub.svelte';
|
|
import Stats from './screens/Stats.svelte';
|
|
import Game from './game/Game.svelte';
|
|
import CommsHub from './game/CommsHub.svelte';
|
|
import Feedback from './screens/Feedback.svelte';
|
|
import Blocked from './screens/Blocked.svelte';
|
|
import BootError from './screens/BootError.svelte';
|
|
import TelegramLaunchError from './screens/TelegramLaunchError.svelte';
|
|
|
|
onMount(() => {
|
|
void bootstrap();
|
|
});
|
|
|
|
// The lobby is the cold-start landing (an empty hash and Telegram launch params both parse
|
|
// to it). The tile loading splash overlays it until its first load settles; a deep-link to
|
|
// another screen is not covered.
|
|
const routeIsLobby = $derived(router.route.name === 'lobby');
|
|
|
|
// Screen transitions: the lobby is the navigation root. Entering a screen from the
|
|
// lobby slides it in from the right (forward); returning to the lobby slides the
|
|
// screen out to the right and reveals the lobby (back). Transitions are local, so
|
|
// they do not play on the initial mount, and collapse to nothing under reduce-motion.
|
|
// Slide direction by route depth: going deeper (lobby → game → chat/check) slides forward,
|
|
// returning to a shallower screen slides back. A plain "lobby is back" rule slid the chat/check
|
|
// back-to-the-game the wrong way. dir is read with the previous depth (the effect updates it
|
|
// only after the transition has captured its sign).
|
|
function routeDepth(name: RouteName): number {
|
|
if (name === 'gameChat' || name === 'gameCheck' || name === 'feedback') return 2;
|
|
if (name === 'lobby' || name === 'login') return 0;
|
|
return 1;
|
|
}
|
|
const curDepth = $derived(routeDepth(router.route.name));
|
|
let prevDepth = $state(routeDepth(router.route.name));
|
|
const dir = $derived(curDepth < prevDepth ? 'back' : 'forward');
|
|
$effect(() => {
|
|
prevDepth = curDepth;
|
|
});
|
|
const enterSign = $derived(dir === 'forward' ? 1 : -1);
|
|
const leaveSign = $derived(dir === 'forward' ? -1 : 1);
|
|
const routeKey = $derived(router.route.name + (router.route.params.id ?? ''));
|
|
const animMs = $derived(app.reduceMotion ? 0 : 260);
|
|
|
|
// slideX slides a pane horizontally by a full width. sign>0 enters from / exits to
|
|
// the right; sign<0 the left. Percentage keeps it viewport-relative without reading
|
|
// innerWidth, and the .router clips the off-screen pane.
|
|
function slideX(_node: Element, { duration, sign }: { duration: number; sign: number }) {
|
|
return {
|
|
duration,
|
|
easing: cubicOut,
|
|
css: (tt: number) => `transform: translateX(${(1 - tt) * sign * 100}%)`,
|
|
};
|
|
}
|
|
</script>
|
|
|
|
{#if !app.ready}
|
|
<!-- On a cold lobby open the tile splash (below) covers bootstrap too; a deep-link to
|
|
another screen keeps the plain text splash while bootstrap runs. -->
|
|
{#if !routeIsLobby}
|
|
<div class="splash">{t('common.loading')}</div>
|
|
{/if}
|
|
{:else if app.launchError}
|
|
<!-- The /telegram/ entry without sign-in data: a compact, shareable diagnostic screen instead
|
|
of bouncing to the marketing landing (also the probe for the empty-initData failure on
|
|
some Android clients). -->
|
|
<TelegramLaunchError />
|
|
{:else if app.bootError}
|
|
<!-- A Mini App launch that failed to authenticate (e.g. the backend was down mid-deploy):
|
|
show the retry screen instead of falling back to the web login. -->
|
|
<BootError />
|
|
{:else if app.blocked}
|
|
<Blocked />
|
|
{:else}
|
|
<div class="router">
|
|
{#key routeKey}
|
|
<div class="pane" in:slideX={{ duration: animMs, sign: enterSign }} out:slideX={{ duration: animMs, sign: leaveSign }}>
|
|
{#if router.route.name === 'login'}
|
|
<Login />
|
|
{:else if router.route.name === 'new'}
|
|
<NewGame />
|
|
{:else if router.route.name === 'game'}
|
|
<Game id={router.route.params.id} />
|
|
{:else if router.route.name === 'gameChat'}
|
|
<CommsHub id={router.route.params.id} initialTab="chat" />
|
|
{:else if router.route.name === 'gameCheck'}
|
|
<CommsHub id={router.route.params.id} initialTab="dictionary" />
|
|
{:else if router.route.name === 'profile'}
|
|
<SettingsHub initialTab="profile" />
|
|
{:else if router.route.name === 'settings'}
|
|
<SettingsHub initialTab="settings" />
|
|
{:else if router.route.name === 'about'}
|
|
<SettingsHub initialTab="about" />
|
|
{:else if router.route.name === 'friends'}
|
|
<SettingsHub initialTab="friends" />
|
|
{:else if router.route.name === 'feedback'}
|
|
<Feedback />
|
|
{:else if router.route.name === 'stats'}
|
|
<Stats />
|
|
{:else}
|
|
<Lobby />
|
|
{/if}
|
|
</div>
|
|
{/key}
|
|
</div>
|
|
{/if}
|
|
|
|
<Toast />
|
|
<StaleInviteModal />
|
|
<WelcomeRedeemModal />
|
|
|
|
{#if routeIsLobby && !app.splashDone && !app.blocked && !app.bootError && !app.launchError}
|
|
<Splash />
|
|
{/if}
|
|
|
|
{#if app.debugOpen}
|
|
<DebugPanel />
|
|
{/if}
|
|
|
|
<style>
|
|
.splash {
|
|
height: 100%;
|
|
display: grid;
|
|
place-items: center;
|
|
color: var(--text-muted);
|
|
}
|
|
.router {
|
|
position: relative;
|
|
height: 100%;
|
|
overflow: hidden;
|
|
}
|
|
.pane {
|
|
position: absolute;
|
|
inset: 0;
|
|
}
|
|
</style>
|