Compare commits
1 Commits
main
...
fix/access
| Author | SHA1 | Date | |
|---|---|---|---|
| 28a1ad5228 |
|
|
@ -2,7 +2,7 @@
|
|||
// https://api.rezina.yaltopia.com (2026-11-02): GET /catalog/courses and GET /catalog/courses/12.
|
||||
import assert from 'node:assert/strict';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import { absolute, ids, mapIssue, mapNotification, mapOutline, mapStudent, slugify, type RawOutline } from './api.ts';
|
||||
import { absolute, ApiDataSource, ids, mapIssue, mapNotification, mapOutline, mapStudent, slugify, type RawOutline } from './api.ts';
|
||||
|
||||
const BASE = 'https://api.rezina.yaltopia.com';
|
||||
const fixture = (f: string) => JSON.parse(readFileSync(new URL(f, import.meta.url), 'utf8')).data;
|
||||
|
|
@ -70,4 +70,68 @@ assert.equal(s.progress.l39?.positionSec, 40, 'this session’s resume point sur
|
|||
assert.equal(s.issues['1']?.type, 'PAYMENT');
|
||||
assert.equal(mapStudent({ id: 1, preferred_language: 'fr' }, null, [], {}, now).locale, 'en', 'unknown language falls back to English');
|
||||
|
||||
// sign-out revocation (mocked transport only: these checks never contact the production API)
|
||||
const TOKEN_KEY = 'lms.api.tokens';
|
||||
const storage = new Map<string, string>();
|
||||
Object.defineProperty(globalThis, 'localStorage', { configurable: true, value: {
|
||||
getItem: (key: string) => storage.get(key) ?? null,
|
||||
setItem: (key: string, value: string) => storage.set(key, value),
|
||||
removeItem: (key: string) => storage.delete(key),
|
||||
} });
|
||||
const oldTokens = { access: 'access-old', refresh: 'refresh-old', userId: 9 };
|
||||
const seedTokens = () => storage.set(TOKEN_KEY, JSON.stringify(oldTokens));
|
||||
const mockBase = 'https://mock.invalid';
|
||||
const response = (body: unknown, status = 200) => new Response(body == null ? null : JSON.stringify(body), { status, headers: { 'content-type': 'application/json' } });
|
||||
|
||||
// normal logout carries both credentials, then removes the local session
|
||||
seedTokens();
|
||||
let calls: { url: string; init?: RequestInit }[] = [];
|
||||
globalThis.fetch = async (input, init) => { calls.push({ url: String(input), init }); return response(null, 204); };
|
||||
await new ApiDataSource(mockBase).auth.signOut();
|
||||
assert.equal(calls.length, 1);
|
||||
assert.equal(calls[0].url, `${mockBase}/api/v1/auth/logout`);
|
||||
assert.equal(new Headers(calls[0].init?.headers).get('authorization'), 'Bearer access-old');
|
||||
assert.deepEqual(JSON.parse(String(calls[0].init?.body)), { refresh_token: 'refresh-old' });
|
||||
assert.equal(storage.get(TOKEN_KEY), undefined);
|
||||
|
||||
// an expired access token refreshes once, then revokes with the rotated pair
|
||||
seedTokens(); calls = [];
|
||||
globalThis.fetch = async (input, init) => {
|
||||
const url = String(input); calls.push({ url, init });
|
||||
if (url.endsWith('/auth/logout') && calls.filter((x) => x.url.endsWith('/auth/logout')).length === 1) return response({ message: 'expired' }, 401);
|
||||
if (url.endsWith('/auth/refresh')) return response({ data: { access_token: 'access-new', refresh_token: 'refresh-new', user_id: 9 } });
|
||||
return response(null, 204);
|
||||
};
|
||||
await new ApiDataSource(mockBase).auth.signOut();
|
||||
assert.deepEqual(calls.map((x) => x.url.slice(mockBase.length)), ['/api/v1/auth/logout', '/api/v1/auth/refresh', '/api/v1/auth/logout']);
|
||||
assert.equal(new Headers(calls[2].init?.headers).get('authorization'), 'Bearer access-new');
|
||||
assert.deepEqual(JSON.parse(String(calls[2].init?.body)), { refresh_token: 'refresh-new' });
|
||||
assert.equal(storage.get(TOKEN_KEY), undefined);
|
||||
|
||||
// network failure never prevents local sign-out
|
||||
seedTokens();
|
||||
globalThis.fetch = async () => { throw new Error('offline'); };
|
||||
await new ApiDataSource(mockBase).auth.signOut();
|
||||
assert.equal(storage.get(TOKEN_KEY), undefined);
|
||||
|
||||
// a refresh that started before sign-out cannot restore its result afterward
|
||||
seedTokens();
|
||||
let releaseRefresh!: (value: Response) => void;
|
||||
let refreshStarted!: () => void;
|
||||
const started = new Promise<void>((resolve) => { refreshStarted = resolve; });
|
||||
globalThis.fetch = async (input) => {
|
||||
const url = String(input);
|
||||
if (url.endsWith('/user/user-profile')) return response({ message: 'expired' }, 401);
|
||||
if (url.endsWith('/auth/refresh')) { refreshStarted(); return new Promise<Response>((resolve) => { releaseRefresh = resolve; }); }
|
||||
if (url.endsWith('/auth/logout')) return response(null, 204);
|
||||
throw new Error(`unexpected mocked request: ${url}`);
|
||||
};
|
||||
const racing = new ApiDataSource(mockBase);
|
||||
const viewing = racing.viewer();
|
||||
await started;
|
||||
const signingOut = racing.auth.signOut();
|
||||
releaseRefresh(response({ data: { access_token: 'late-access', refresh_token: 'late-refresh', user_id: 9 } }));
|
||||
await Promise.all([viewing, signingOut]);
|
||||
assert.equal(storage.get(TOKEN_KEY), undefined, 'late refresh must not recreate the signed-out session');
|
||||
|
||||
console.log('api checks: all passed');
|
||||
|
|
|
|||
|
|
@ -146,7 +146,8 @@ type Contact = { phone?: string; email?: string; password?: string };
|
|||
export class ApiDataSource implements DataSource {
|
||||
readonly kind = 'api' as const;
|
||||
private tokens: Tokens | null = readTokens();
|
||||
private refreshing: Promise<boolean> | null = null;
|
||||
private tokenVersion = 0;
|
||||
private refreshing: { version: number; promise: Promise<boolean> } | null = null;
|
||||
private courseCbs = new Set<(c: Course[]) => void>();
|
||||
private studentCbs = new Map<(s: Student | null) => void, string>();
|
||||
private inboxCbs = new Set<(i: InboxItem[]) => void>();
|
||||
|
|
@ -186,20 +187,48 @@ export class ApiDataSource implements DataSource {
|
|||
|
||||
private refresh(): Promise<boolean> {
|
||||
if (!this.tokens) return Promise.resolve(false);
|
||||
this.refreshing ??= fetch(`${this.base.replace(/\/+$/, '')}/api/v1/auth/refresh`, {
|
||||
const tokens = this.tokens;
|
||||
const version = this.tokenVersion;
|
||||
if (this.refreshing?.version === version) return this.refreshing.promise;
|
||||
const promise = fetch(`${this.base.replace(/\/+$/, '')}/api/v1/auth/refresh`, {
|
||||
method: 'POST', headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ access_token: this.tokens.access, refresh_token: this.tokens.refresh }),
|
||||
body: JSON.stringify({ access_token: tokens.access, refresh_token: tokens.refresh }),
|
||||
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
||||
}).then(async (r) => {
|
||||
const j = await r.json().catch(() => null);
|
||||
if (version !== this.tokenVersion || this.tokens !== tokens) return false;
|
||||
if (!r.ok || !j?.data?.access_token) { this.setTokens(null); return false; }
|
||||
this.setTokens({ access: j.data.access_token, refresh: j.data.refresh_token, userId: j.data.user_id });
|
||||
return true;
|
||||
}, () => false).finally(() => { this.refreshing = null; });
|
||||
return this.refreshing;
|
||||
}, () => false).finally(() => { if (this.refreshing?.promise === promise) this.refreshing = null; });
|
||||
this.refreshing = { version, promise };
|
||||
return promise;
|
||||
}
|
||||
|
||||
private setTokens(t: Tokens | null) { this.tokens = t; writeTokens(t); }
|
||||
private setTokens(t: Tokens | null) { this.tokenVersion++; this.tokens = t; writeTokens(t); }
|
||||
|
||||
private logoutRequest(t: Tokens) {
|
||||
return fetch(`${this.base.replace(/\/+$/, '')}/api/v1/auth/logout`, {
|
||||
method: 'POST',
|
||||
headers: { 'content-type': 'application/json', authorization: `Bearer ${t.access}` },
|
||||
body: JSON.stringify({ refresh_token: t.refresh }),
|
||||
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
||||
});
|
||||
}
|
||||
|
||||
/** Refresh only for a final revoke attempt. These tokens are never installed into the signed-out client. */
|
||||
private async refreshForLogout(t: Tokens): Promise<Tokens | null> {
|
||||
try {
|
||||
const r = await fetch(`${this.base.replace(/\/+$/, '')}/api/v1/auth/refresh`, {
|
||||
method: 'POST', headers: { 'content-type': 'application/json' },
|
||||
body: JSON.stringify({ access_token: t.access, refresh_token: t.refresh }),
|
||||
signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS),
|
||||
});
|
||||
const j = await r.json().catch(() => null);
|
||||
if (!r.ok || !j?.data?.access_token || !j.data.refresh_token) return null;
|
||||
return { access: j.data.access_token, refresh: j.data.refresh_token, userId: j.data.user_id ?? t.userId };
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
// ---- auth (the screens reach this through `ds.auth` when it exists; the demo has none)
|
||||
|
||||
|
|
@ -231,10 +260,20 @@ export class ApiDataSource implements DataSource {
|
|||
},
|
||||
signOut: async () => {
|
||||
const t = this.tokens;
|
||||
// Invalidate every refresh already in flight before doing any network work.
|
||||
this.setTokens(null);
|
||||
if (t) await this.request('POST', '/auth/logout', { refresh_token: t.refresh }, false).catch(() => { /* already gone server-side */ });
|
||||
this.localProgress = {};
|
||||
this.refreshAll();
|
||||
try {
|
||||
if (t) {
|
||||
const first = await this.logoutRequest(t);
|
||||
if (first.status === 401) {
|
||||
const fresh = await this.refreshForLogout(t);
|
||||
if (fresh) await this.logoutRequest(fresh);
|
||||
}
|
||||
}
|
||||
} catch { /* local sign-out still wins on timeout, network failure, or API failure */ }
|
||||
// Tokens were cleared above; clearing again here would erase a sign-in made while logout was pending.
|
||||
finally { this.refreshAll(); }
|
||||
},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
import assert from 'node:assert/strict';
|
||||
import type { Course, Student } from '@lms/data';
|
||||
import { applyHeartbeat, DomainError, gradeAssessment, applyPaymentEvent, createOrder, dashboardMetrics, effectiveStatus, isStudentVisible, lessonAccess, publishProblems, validateLocation, validPassword } from './domain.ts';
|
||||
import { decodeLearnerCode, encodeLearnerCode } from './learnerCode.ts';
|
||||
|
||||
const lesson = (id: string, extra = {}) => ({ id, sortOrder: Number(id.slice(-1)), isPreview: false, isPublished: true, durationSec: 100, videoStatus: 'READY' as const, translations: { en: { title: id } }, ...extra });
|
||||
const course = (id: string, extra: Partial<Course> = {}): Course => ({
|
||||
|
|
@ -88,4 +89,13 @@ assert.deepEqual([g2.score, g2.bestPct, g2.passed, g2.attempts], [1, 100, true,
|
|||
assert.equal(gradeAssessment(A, quiz, [1, 1, 1], undefined, now).passed, false);
|
||||
assert.throws(() => gradeAssessment(A, quiz, [0, 1], undefined, now), DomainError);
|
||||
|
||||
// Traceable player watermark: numeric learner ids round-trip without ambiguous characters.
|
||||
for (const id of [0, 1, 31, 32, 9_847_231, Number.MAX_SAFE_INTEGER]) {
|
||||
const code = encodeLearnerCode(id);
|
||||
assert.match(code, /^RZ-[2-9A-HJ-NP-Z]+$/);
|
||||
assert.equal(decodeLearnerCode(code), id);
|
||||
}
|
||||
assert.equal(decodeLearnerCode('RZ-O01I'), null);
|
||||
assert.throws(() => encodeLearnerCode(-1), RangeError);
|
||||
|
||||
console.log('domain checks: all passed');
|
||||
|
|
|
|||
29
packages/features/src/learnerCode.ts
Normal file
29
packages/features/src/learnerCode.ts
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
// A compact support identifier, not a secret. The alphabet omits 0/O and 1/I.
|
||||
const ALPHABET = '23456789ABCDEFGHJKLMNPQRSTUVWXYZ';
|
||||
const PREFIX = 'RZ-';
|
||||
|
||||
export function encodeLearnerCode(id: number): string {
|
||||
if (!Number.isSafeInteger(id) || id < 0) throw new RangeError('Learner id must be a non-negative safe integer');
|
||||
let n = id;
|
||||
let body = '';
|
||||
do {
|
||||
body = ALPHABET[n % ALPHABET.length] + body;
|
||||
n = Math.floor(n / ALPHABET.length);
|
||||
} while (n > 0);
|
||||
return PREFIX + body.padStart(4, ALPHABET[0]);
|
||||
}
|
||||
|
||||
export function decodeLearnerCode(code: string): number | null {
|
||||
const value = code.trim().toUpperCase();
|
||||
if (!value.startsWith(PREFIX)) return null;
|
||||
const body = value.slice(PREFIX.length);
|
||||
if (!body) return null;
|
||||
let id = 0;
|
||||
for (const char of body) {
|
||||
const digit = ALPHABET.indexOf(char);
|
||||
if (digit < 0) return null;
|
||||
id = id * ALPHABET.length + digit;
|
||||
if (!Number.isSafeInteger(id)) return null;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
|
@ -11,6 +11,7 @@ import {
|
|||
} from './domain';
|
||||
import { CAT_PHOTOS, CopyText, Cover, coursePhoto, Empty, FeedbackButton, fmtDate, Icon, KitIcon, Logo, Modal, VIMEO_ORIGIN, VIMEO_PLACEHOLDER, Ring, Skeleton, StatusPill } from './ui';
|
||||
import { PAY_LOGOS } from './payLogos';
|
||||
import { encodeLearnerCode } from './learnerCode';
|
||||
|
||||
const ISSUE_TYPES: IssueType[] = ['BUG', 'PAYMENT', 'VIDEO', 'ACCOUNT', 'CONTENT', 'OTHER'];
|
||||
// Demo checkout lists every method we plan to accept; all of them run through the same simulated ETB order.
|
||||
|
|
@ -955,7 +956,7 @@ export function vimeoPlayerUrl(url: string): string | null {
|
|||
|
||||
function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next?: Lesson; head?: ReactNode }) {
|
||||
const t = useTranslations();
|
||||
const { me, locale, nav, ds, write, signedIn, viewer } = useApp();
|
||||
const { me, locale, nav, ds, write, signedIn } = useApp();
|
||||
// A Vimeo link (what the API's lessons carry) plays in Vimeo's player; no video yet plays the sample clip.
|
||||
const placeholder = !lesson.videoAssetId;
|
||||
const vimeoSrc = placeholder ? VIMEO_PLACEHOLDER : vimeoPlayerUrl(lesson.videoAssetId!);
|
||||
|
|
@ -963,7 +964,9 @@ function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next
|
|||
const [vdur, setVdur] = useState(0);
|
||||
const dur = (vimeo && vdur) || lesson.durationSec || 1;
|
||||
const saved = me?.progress?.[lesson.id];
|
||||
const [pos, setPos] = useState(() => (saved && !saved.completedAt ? Math.min(saved.positionSec, dur - 5) : 0));
|
||||
const [pos, setPos] = useState(() => (saved && !saved.completedAt
|
||||
? Math.max(0, lesson.durationSec ? Math.min(saved.positionSec, lesson.durationSec - 5) : saved.positionSec)
|
||||
: 0));
|
||||
const [playing, setPlaying] = useState(false);
|
||||
const [rate, setRate] = useState(1);
|
||||
const conn = typeof navigator !== 'undefined' ? (navigator as any).connection : undefined;
|
||||
|
|
@ -973,6 +976,8 @@ function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next
|
|||
// L4: when a lesson ends, "up next" appears over the video and plays it after a short count the student can cancel
|
||||
const [ended, setEnded] = useState(false);
|
||||
const [auto, setAuto] = useState<number | null>(null);
|
||||
const [fillViewport, setFillViewport] = useState(false);
|
||||
const [nativeFullscreen, setNativeFullscreen] = useState(false);
|
||||
const videoRef = useRef<HTMLVideoElement>(null);
|
||||
const frameRef = useRef<HTMLIFrameElement>(null);
|
||||
const screenRef = useRef<HTMLDivElement>(null);
|
||||
|
|
@ -1023,6 +1028,26 @@ function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next
|
|||
}, [heartbeat]);
|
||||
useEffect(() => { const v = videoRef.current; if (v) v.playbackRate = rate; }, [rate]);
|
||||
useEffect(() => { if (vimeo && rate !== 1) vcall('setPlaybackRate', rate); }, [rate]);
|
||||
useEffect(() => {
|
||||
const changed = () => setNativeFullscreen(document.fullscreenElement === screenRef.current);
|
||||
document.addEventListener('fullscreenchange', changed);
|
||||
return () => document.removeEventListener('fullscreenchange', changed);
|
||||
}, []);
|
||||
useEffect(() => {
|
||||
if (!fillViewport) return;
|
||||
const root = document.documentElement;
|
||||
const body = document.body;
|
||||
const scrollY = window.scrollY;
|
||||
const before = { rootOverflow: root.style.overflow, bodyOverflow: body.style.overflow, position: body.style.position, top: body.style.top, width: body.style.width };
|
||||
root.style.overflow = 'hidden'; body.style.overflow = 'hidden'; body.style.position = 'fixed'; body.style.top = `-${scrollY}px`; body.style.width = '100%';
|
||||
const escape = (e: KeyboardEvent) => { if (e.key === 'Escape') setFillViewport(false); };
|
||||
addEventListener('keydown', escape, true);
|
||||
return () => {
|
||||
removeEventListener('keydown', escape, true);
|
||||
root.style.overflow = before.rootOverflow; body.style.overflow = before.bodyOverflow; body.style.position = before.position; body.style.top = before.top; body.style.width = before.width;
|
||||
window.scrollTo(0, scrollY);
|
||||
};
|
||||
}, [fillViewport]);
|
||||
const goNext = () => { if (next) nav(`/${locale}/learn/${c.slug}/${next.id}`); };
|
||||
useEffect(() => { if (ended && next) setAuto(AUTO_NEXT_SEC); }, [ended, next]);
|
||||
useEffect(() => {
|
||||
|
|
@ -1038,26 +1063,39 @@ function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next
|
|||
vcall(playing ? 'pause' : 'play');
|
||||
};
|
||||
const seek = (to: number) => { const n = Math.max(0, Math.min(dur, to)); setPos(n); if (videoRef.current) videoRef.current.currentTime = n; else vcall('setCurrentTime', n); };
|
||||
const full = () => { screenRef.current?.requestFullscreen?.().catch(() => { /* not allowed in this frame */ }); };
|
||||
const onKey = (e: React.KeyboardEvent) => {
|
||||
if ((e.target as HTMLElement).tagName === 'SELECT' || (e.target as HTMLElement).tagName === 'INPUT') return;
|
||||
if (e.key === 'Escape' && auto != null) { setAuto(null); return; }
|
||||
if (e.key === ' ') { e.preventDefault(); toggle(); } else if (e.key === 'ArrowLeft') seek(pos - 10); else if (e.key === 'ArrowRight') seek(pos + 10); else if (e.key === 'f') full(); else if (e.key === 'm' && videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
||||
const full = () => {
|
||||
const screen = screenRef.current;
|
||||
if (!screen) return;
|
||||
if (fillViewport) { setFillViewport(false); return; }
|
||||
if (document.fullscreenElement === screen) { document.exitFullscreen().catch(() => {}); return; }
|
||||
if (!screen.requestFullscreen) { setFillViewport(true); return; }
|
||||
screen.requestFullscreen().catch(() => setFillViewport(true));
|
||||
};
|
||||
const mark = (me?.phone || me?.email || viewer?.name || 'student').replace(/^(.{3}).*(.{2})$/, '$1•••$2');
|
||||
const onKey = (e: React.KeyboardEvent) => {
|
||||
const el = e.target as HTMLElement;
|
||||
if (el.tagName === 'SELECT' || el.tagName === 'INPUT' || (el.tagName === 'BUTTON' && (e.key === ' ' || e.key === 'Enter'))) return;
|
||||
if (e.key === 'Escape' && auto != null) { setAuto(null); return; }
|
||||
if (e.key === ' ') { e.preventDefault(); toggle(); } else if (e.key === 'ArrowLeft') seek(pos - 10); else if (e.key === 'ArrowRight') seek(pos + 10); else if (e.key.toLowerCase() === 'f') full(); else if (e.key.toLowerCase() === 'm' && videoRef.current) videoRef.current.muted = !videoRef.current.muted;
|
||||
};
|
||||
const numericLearnerId = me && /^(0|[1-9]\d*)$/.test(me.id) ? Number(me.id) : NaN;
|
||||
const mark = signedIn && Number.isSafeInteger(numericLearnerId) ? encodeLearnerCode(numericLearnerId) : null;
|
||||
const isFullscreen = fillViewport || nativeFullscreen;
|
||||
const done = isCompleted(me, lesson.id) || justDone;
|
||||
const pct = courseProgress(c, me).pct;
|
||||
return (
|
||||
<div className="stack">
|
||||
<div className="screen" ref={screenRef} tabIndex={0} onKeyDown={onKey} aria-label={lessonTitle(lesson, locale)}>
|
||||
{lesson.videoAssetId ? (
|
||||
<video ref={videoRef} src={ds.assetUrl(lesson.videoAssetId)} playsInline preload="metadata"
|
||||
<div className={`screen${fillViewport ? ' is-fill-viewport' : ''}`} ref={screenRef} tabIndex={0} onKeyDown={onKey} aria-label={lessonTitle(lesson, locale)}>
|
||||
{vimeoSrc ? (
|
||||
<iframe ref={frameRef} src={vimeoSrc} onLoad={vlisten} title={lessonTitle(lesson, locale)} allow="autoplay; picture-in-picture" />
|
||||
) : (
|
||||
<video ref={videoRef} src={ds.assetUrl(lesson.videoAssetId!)} playsInline preload="metadata"
|
||||
onLoadedMetadata={(e) => { if (pos) e.currentTarget.currentTime = pos; }}
|
||||
onTimeUpdate={(e) => setPos(e.currentTarget.currentTime)} onPlay={() => { setPlaying(true); setEnded(false); setAuto(null); }} onPause={() => setPlaying(false)} onEnded={() => { setPlaying(false); setEnded(true); }} />
|
||||
) : (
|
||||
<iframe ref={frameRef} src={vimeoSrc!} onLoad={vlisten} title={lessonTitle(lesson, locale)} allow="autoplay; fullscreen; picture-in-picture" allowFullScreen />
|
||||
)}
|
||||
{canSave && <span className="wm" aria-hidden>{mark}</span>}
|
||||
{mark && <span className="wm" aria-hidden>{mark}</span>}
|
||||
<button className="p-full" onClick={full} aria-label={t(isFullscreen ? 'player.exitFullscreen' : 'player.fullscreen')}>
|
||||
<Icon name={isFullscreen ? 'x' : 'expand'} size={20} />
|
||||
</button>
|
||||
{auto != null && next && <div className="p-upnext" role="status">
|
||||
<span className="p-upnext-k">{t('player.upNext')}</span>
|
||||
<strong>{lessonNumber(c, next.id)}. {lessonTitle(next, locale)}</strong>
|
||||
|
|
@ -1082,7 +1120,6 @@ function VideoPanel({ c, lesson, next, head }: { c: Course; lesson: Lesson; next
|
|||
<option value="auto">Auto{saver ? ' (≤360p)' : ''}</option>{['240p', '360p', '480p', '720p'].map((q) => <option key={q} value={q} disabled={saver && (q === '480p' || q === '720p')}>{q}</option>)}
|
||||
</select>
|
||||
<button aria-pressed={saver} onClick={() => { setSaver((s) => !s); if (!saver && (quality === '480p' || quality === '720p')) setQuality('360p'); }}>{t('player.dataSaver')}: {saver ? 'on' : 'off'}</button>
|
||||
<button onClick={full} aria-label={t('player.fullscreen')}><Icon name="expand" size={16} /></button>
|
||||
</div>
|
||||
</div>}
|
||||
</div>
|
||||
|
|
|
|||
|
|
@ -237,12 +237,21 @@ textarea.input { min-height: 110px; resize: vertical; }
|
|||
@media (min-width: 1024px) { .l-bar { display: none; } }
|
||||
@media (min-width: 1024px) { .p-wrap { grid-template-columns: 340px 1fr; align-items: start; } .p-side { position: sticky; top: 80px; max-height: calc(100vh - 100px); overflow: auto; } .p-side-order { order: -1; } }
|
||||
.screen { position: relative; background: #111; color: #fff; border-radius: var(--r-lg); overflow: hidden; aspect-ratio: 16 / 9; max-width: 100%; }
|
||||
.screen:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
|
||||
.screen video { width: 100%; height: 100%; object-fit: contain; background: #000; }
|
||||
.screen .sim { position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 10px; padding: 24px; text-align: center; background: radial-gradient(circle at 30% 20%, #3A3A3A, #111 70%); }
|
||||
.screen .sim h2 { font-family: var(--f-serif); font-size: clamp(22px, 4vw, 36px); color: #fff; }
|
||||
.screen .sim .muted { color: #C8C8C8; }
|
||||
.wm { position: absolute; font-size: 12px; color: rgba(255, 255, 255, .28); pointer-events: none; user-select: none; animation: wm 40s linear infinite alternate; font-variant-numeric: tabular-nums; }
|
||||
.wm { position: absolute; z-index: 1; left: 6%; top: 10%; padding: 2px 5px; border-radius: 4px; background: rgba(0, 0, 0, .16); color: rgba(255, 255, 255, .56); text-shadow: 0 1px 2px rgba(0, 0, 0, .9); font-size: 12px; font-weight: 700; letter-spacing: .08em; pointer-events: none; user-select: none; animation: wm 40s linear infinite alternate; font-variant-numeric: tabular-nums; }
|
||||
@keyframes wm { 0% { left: 6%; top: 10%; } 33% { left: 60%; top: 30%; } 66% { left: 20%; top: 70%; } 100% { left: 70%; top: 80%; } }
|
||||
.p-full { position: absolute; z-index: 4; inset-block-start: calc(8px + env(safe-area-inset-top, 0px)); inset-inline-end: calc(8px + env(safe-area-inset-right, 0px)); width: 44px; height: 44px; display: grid; place-items: center; padding: 0; border: 1px solid rgba(255, 255, 255, .22); border-radius: var(--r-pill); background: rgba(10, 10, 10, .72); color: #fff; box-shadow: 0 2px 10px rgba(0, 0, 0, .28); cursor: pointer; }
|
||||
.p-full:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
|
||||
@media (hover: hover) and (pointer: fine) { .p-full:hover { background: rgba(10, 10, 10, .9); } }
|
||||
.screen:fullscreen, .screen.is-fill-viewport { width: 100vw; height: 100vh; height: 100dvh; max-width: none; aspect-ratio: auto; border-radius: 0; }
|
||||
.screen.is-fill-viewport { position: fixed; inset: 0; z-index: 100; margin: 0 !important; }
|
||||
.screen.is-fill-viewport iframe { inset: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); width: auto; height: auto; }
|
||||
.screen.is-fill-viewport video { box-sizing: border-box; padding: env(safe-area-inset-top, 0px) env(safe-area-inset-right, 0px) env(safe-area-inset-bottom, 0px) env(safe-area-inset-left, 0px); }
|
||||
.screen.is-fill-viewport .controls { padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px)); padding-inline: calc(12px + env(safe-area-inset-left, 0px)) calc(12px + env(safe-area-inset-right, 0px)); }
|
||||
.controls { position: absolute; left: 0; right: 0; bottom: 0; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; background: linear-gradient(transparent, rgba(0, 0, 0, .75)); }
|
||||
.controls .row { gap: 6px; }
|
||||
.controls button, .controls select { background: rgba(255, 255, 255, .12); color: #fff; border: 0; border-radius: var(--r-sm); min-height: 36px; min-width: 36px; padding: 0 10px; cursor: pointer; font-size: var(--fs-sm); font-weight: 700; }
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
"back10": "10 ሰከንድ ወደ ኋላ",
|
||||
"fwd10": "10 ሰከንድ ወደ ፊት",
|
||||
"fullscreen": "ሙሉ ማያ",
|
||||
"exitFullscreen": "ከሙሉ ማያ ውጣ",
|
||||
"contents": "ይዘት",
|
||||
"progress": "ከ{total} ትምህርቶች {done} ተጠናቀዋል",
|
||||
"nowPlaying": "አሁን እየታየ",
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
"back10": "Back 10 seconds",
|
||||
"fwd10": "Forward 10 seconds",
|
||||
"fullscreen": "Full screen",
|
||||
"exitFullscreen": "Exit full screen",
|
||||
"contents": "Contents",
|
||||
"progress": "{done} of {total} lessons completed",
|
||||
"nowPlaying": "Now playing",
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
"back10": "Sekondii 10 duubatti",
|
||||
"fwd10": "Sekondii 10 fuulduratti",
|
||||
"fullscreen": "Guutuu iskiriinii",
|
||||
"exitFullscreen": "Iskiriinii guutuu keessaa ba'i",
|
||||
"contents": "Qabiyyee",
|
||||
"progress": "Barnoota {total} keessaa {done} xumurameera",
|
||||
"nowPlaying": "Amma taphachaa jira",
|
||||
|
|
|
|||
|
|
@ -220,6 +220,7 @@
|
|||
"back10": "10 ካልኢት ንድሕሪት",
|
||||
"fwd10": "10 ካልኢት ንቕድሚት",
|
||||
"fullscreen": "ምሉእ ስክሪን",
|
||||
"exitFullscreen": "ካብ ምሉእ ስክሪን ውጻእ",
|
||||
"contents": "ትሕዝቶ",
|
||||
"progress": "ካብ {total} ትምህርትታት {done} ተወዲኦም",
|
||||
"nowPlaying": "ሕጂ ይርአ ኣሎ",
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user