2d1fadb50c
CI / changes (pull_request) Successful in 2s
CI / unit (pull_request) Successful in 10s
CI / integration (pull_request) Successful in 20s
CI / ui (pull_request) Successful in 1m12s
CI / conformance (pull_request) Successful in 10s
CI / gate (pull_request) Successful in 0s
CI / deploy (pull_request) Successful in 1m54s
Land the offline-model redesign (ANDROID_PLAN.md O1-O7): replace the explicit offline toggle with a single detected net-state machine, unify the lobby, and add a two-tier client-version gate. Contour-safe: both version vars empty => dormant, the wire change is additive, so web/pwa/vk/tg behaviour is unchanged unless the gate is deliberately configured. O1 net-state reducer (test-first). O2 store + wiring (connection/offline shims; +@capacitor/network). O3 remove the offline toggle + migrate the pref. O4 two-tier gate: hard update_required degrades to an offline Update/Play-offline notice (not terminal); soft GATEWAY_RECOMMENDED_CLIENT_VERSION -> X-Update-Recommended nudge. O5 unified lobby (device-local + greyed-from-cache server games; self-set identity; closes G-step-0). O6 create flows (with-friends online/offline segment + offline dict guard). O7 docs. Telegram/VK stay online-only (contour review): the offline model is channel-gated via offlineCapable() (native + plain web; false in the mini-apps). offlineMode.active is hard-gated on it, so the whole model (blue chrome, unified/greyed lobby, transport kill switch, device-local vs_ai/hotseat create) stays inert in Telegram/VK regardless of the detected net state (closing a version-lock path that could have flipped them offline); and New Game's with-friends hides the online/offline segment there, leaving the remote invite alone. ARCHITECTURE already declared "Telegram/VK are exempt" - this makes the code match. Deploy/CI: wire the version gate through the deploy (GATEWAY_MIN_CLIENT_VERSION + GATEWAY_RECOMMENDED_CLIENT_VERSION as plain unprefixed vars via compose + ci.yaml + prod-deploy.yaml + write-prod-env.sh + .env.example) so the gate is live when set (test-contour commit-hash version fails open; empty => dormant). Disable the manual android-build CI workflow for now (rename .disabled). Bump the app bundle budget 127->130 KB for the added always-loaded wiring. Fix the UI Docker stage (gateway/Dockerfile): install --ignore-scripts so the Alpine/musl SPA build no longer tries to native-build sharp (a local android:assets tool, unused in the image); esbuild's binary is an optional dep so Vite still builds. Tests: gateway go green (two-tier gate over a real HTTP handler); docker build of the landing + gateway targets green locally; compose --no-interpolate confirms the gateway env; two new telegram.spec.ts e2e (offline signal keeps the chrome online + quick-match opponent choice visible => server enqueue; with-friends shows no pass-and-play), RED-verified; svelte-check 0/0, vitest 617, e2e 248 (chromium + webkit), build + bundle-size 127.8/130.
144 lines
3.7 KiB
Svelte
144 lines
3.7 KiB
Svelte
<script lang="ts">
|
|
import {
|
|
app,
|
|
setBoardLabels,
|
|
setLocalePref,
|
|
setReduceMotion,
|
|
setTheme,
|
|
setZoomBoard,
|
|
} from '../lib/app.svelte';
|
|
import { t, type Locale, type MessageKey } from '../lib/i18n/index.svelte';
|
|
import type { ThemePref } from '../lib/theme';
|
|
import type { BoardLabelMode } from '../lib/boardlabels';
|
|
import { insideTelegram } from '../lib/telegram';
|
|
import InstallApp from '../components/InstallApp.svelte';
|
|
|
|
// The board-zoom toggle only makes sense on a touch device (the desktop / landscape layouts fit
|
|
// the whole board and never auto-zoom), so it is shown only for a coarse pointer.
|
|
const coarsePointer = typeof matchMedia !== 'undefined' && matchMedia('(pointer: coarse)').matches;
|
|
|
|
const themes: ThemePref[] = ['auto', 'light', 'dark'];
|
|
const themeLabel: Record<ThemePref, MessageKey> = {
|
|
auto: 'settings.themeAuto',
|
|
light: 'settings.themeLight',
|
|
dark: 'settings.themeDark',
|
|
};
|
|
const locales: Locale[] = ['en', 'ru'];
|
|
const labelModes: BoardLabelMode[] = ['beginner', 'classic', 'none'];
|
|
const labelModeKey: Record<BoardLabelMode, MessageKey> = {
|
|
beginner: 'settings.labelsBeginner',
|
|
classic: 'settings.labelsClassic',
|
|
none: 'settings.labelsNone',
|
|
};
|
|
|
|
</script>
|
|
|
|
<div class="page">
|
|
{#if !insideTelegram()}
|
|
<section>
|
|
<h3>{t('settings.theme')}</h3>
|
|
<div class="seg">
|
|
{#each themes as th (th)}
|
|
<button class="opt" class:active={app.theme === th} onclick={() => setTheme(th)}>
|
|
{t(themeLabel[th])}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
</section>
|
|
{/if}
|
|
|
|
<section>
|
|
<h3>{t('settings.language')}</h3>
|
|
<div class="seg">
|
|
{#each locales as lc (lc)}
|
|
<button class="opt" class:active={app.locale === lc} onclick={() => setLocalePref(lc)}>
|
|
{t(lc === 'en' ? 'lang.en' : 'lang.ru')}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<h3>{t('settings.boardStyle')}</h3>
|
|
<div class="sub">{t('settings.boardLabels')}</div>
|
|
<div class="seg">
|
|
{#each labelModes as lm (lm)}
|
|
<button class="opt" class:active={app.boardLabels === lm} onclick={() => setBoardLabels(lm)}>
|
|
{t(labelModeKey[lm])}
|
|
</button>
|
|
{/each}
|
|
</div>
|
|
</section>
|
|
|
|
<section>
|
|
<label class="row">
|
|
<span>{t('settings.reduceMotion')}</span>
|
|
<input
|
|
type="checkbox"
|
|
checked={app.reduceMotion}
|
|
onchange={(e) => setReduceMotion(e.currentTarget.checked)}
|
|
/>
|
|
</label>
|
|
{#if coarsePointer}
|
|
<label class="row">
|
|
<span>{t('settings.zoomBoard')}</span>
|
|
<input
|
|
type="checkbox"
|
|
checked={app.zoomBoard}
|
|
onchange={(e) => setZoomBoard(e.currentTarget.checked)}
|
|
/>
|
|
</label>
|
|
{/if}
|
|
</section>
|
|
|
|
<!-- Web-only install call-to-action at the bottom of Settings (renders nothing unless the app
|
|
is installable here — see components/InstallApp.svelte / lib/pwa). -->
|
|
<InstallApp />
|
|
</div>
|
|
|
|
<style>
|
|
.page {
|
|
padding: var(--pad);
|
|
display: flex;
|
|
flex-direction: column;
|
|
gap: 20px;
|
|
}
|
|
h3 {
|
|
margin: 0 0 8px;
|
|
font-size: 0.95rem;
|
|
color: var(--text-muted);
|
|
}
|
|
.sub {
|
|
font-size: 0.85rem;
|
|
color: var(--text-muted);
|
|
margin-bottom: 6px;
|
|
}
|
|
.seg {
|
|
display: flex;
|
|
gap: 8px;
|
|
}
|
|
.opt {
|
|
flex: 1;
|
|
padding: 10px;
|
|
border: 1px solid var(--border);
|
|
background: var(--surface);
|
|
color: var(--text);
|
|
border-radius: var(--radius-sm);
|
|
user-select: none;
|
|
}
|
|
.opt.active {
|
|
background: var(--accent);
|
|
color: var(--accent-text);
|
|
border-color: var(--accent);
|
|
}
|
|
.opt:disabled {
|
|
opacity: 0.55;
|
|
cursor: default;
|
|
}
|
|
.row {
|
|
display: flex;
|
|
align-items: center;
|
|
justify-content: space-between;
|
|
}
|
|
</style>
|