@lemonriver/core 0.3.0 → 0.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{build-Bqo69DWP.js → build-Nl7EeJ6x.js} +1 -1
- package/dist/cli/bin.js +3 -3
- package/dist/{config-teo3kWz7.d.ts → config-CYNOR93W.d.ts} +1 -1
- package/dist/{config-DJ5rkMMg.js → config-CpC0nM3r.js} +697 -2
- package/dist/{dev-B2FJD5bJ.js → dev-BB3THd5I.js} +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{preview-C93BOZL1.js → preview-BGjgTg7H.js} +1 -1
- package/dist/{types-DFK02XVv.d.ts → types-tdaXSyah.d.ts} +1 -0
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DwTAZKa6.js → zh-tw-DcrDeKxr.js} +5 -0
- package/package.json +1 -1
- package/src/agent/prompt.ts +2 -0
- package/src/app/components/agent/agent-panel.tsx +2 -0
- package/src/app/components/player.tsx +105 -23
- package/src/app/components/present/curtain.tsx +52 -0
- package/src/app/components/present/last-slide-hint.tsx +36 -0
- package/src/app/components/sidebar/sidebar-footer.tsx +6 -1
- package/src/app/components/thumbnail-rail.tsx +1 -0
- package/src/app/lemonriver/agent/lemon.tsx +16 -1
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +173 -0
- package/src/app/lemonriver/agent-prefs/prefs.ts +137 -0
- package/src/app/lemonriver/agent-prefs/use-prefs.ts +36 -0
- package/src/app/lemonriver/brand/mascot.tsx +86 -0
- package/src/app/lemonriver/brand/mascots/design-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/design-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/outline-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/research-working.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-done.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-idle.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-needs-you.png +0 -0
- package/src/app/lemonriver/brand/mascots/review-working.png +0 -0
- package/src/app/lemonriver/chrome/app-chrome.tsx +2 -0
- package/src/app/lemonriver/features.test.ts +5 -0
- package/src/app/lemonriver/features.ts +2 -1
- package/src/app/lemonriver/home/brief-card.tsx +8 -1
- package/src/app/lemonriver/home/home-page.tsx +11 -7
- package/src/app/lemonriver/onboarding/onboarding.tsx +182 -0
- package/src/app/lemonriver/outline/build-team.tsx +278 -0
- package/src/app/lemonriver/outline/describe-page.tsx +380 -0
- package/src/app/lemonriver/outline/files.test.ts +90 -0
- package/src/app/lemonriver/outline/files.ts +69 -0
- package/src/app/lemonriver/outline/model.test.ts +633 -0
- package/src/app/lemonriver/outline/model.ts +443 -0
- package/src/app/lemonriver/outline/outline-page.tsx +504 -0
- package/src/app/lemonriver/outline/pending-pages.tsx +39 -0
- package/src/app/lemonriver/outline/rule.ts +3 -0
- package/src/app/lemonriver/outline/steps.tsx +43 -0
- package/src/app/lemonriver/outline/use-build-driver.ts +258 -0
- package/src/app/lemonriver/routes.test.tsx +6 -6
- package/src/app/lemonriver/routes.tsx +28 -0
- package/src/app/lemonriver/settings/settings-page.tsx +211 -0
- package/src/app/lemonriver/slide-extensions.tsx +31 -24
- package/src/app/lemonriver/text/en.ts +149 -0
- package/src/app/lemonriver/text/es.ts +148 -0
- package/src/app/lemonriver/text/ja.ts +150 -0
- package/src/app/lemonriver/text/text.test.ts +33 -0
- package/src/app/lemonriver/text/types.ts +169 -0
- package/src/app/lemonriver/text/zh-cn.ts +146 -0
- package/src/app/lemonriver/text/zh-tw.ts +146 -0
- package/src/app/lemonriver/theme/app.css +12 -1
- package/src/app/lemonriver/theme/pages.test.ts +4 -0
- package/src/app/lemonriver/theme/pages.ts +11 -2
- package/src/app/lemonriver/update/beta-badge.tsx +26 -0
- package/src/app/lemonriver/update/prompt.test.ts +84 -0
- package/src/app/lemonriver/update/prompt.ts +48 -0
- package/src/app/lemonriver/update/update-prompt.tsx +113 -0
- package/src/app/routes/home.tsx +13 -5
- package/src/app/routes/slide.tsx +70 -13
- package/src/locale/en.ts +1 -0
- package/src/locale/es.ts +1 -0
- package/src/locale/ja.ts +1 -0
- package/src/locale/types.ts +1 -0
- package/src/locale/zh-cn.ts +1 -0
- package/src/locale/zh-tw.ts +1 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import {
|
|
3
|
+
promptsOnPage,
|
|
4
|
+
readSnooze,
|
|
5
|
+
SNOOZE_KEY,
|
|
6
|
+
SNOOZE_MS,
|
|
7
|
+
type Snooze,
|
|
8
|
+
saveSnooze,
|
|
9
|
+
shouldPrompt,
|
|
10
|
+
type UpdateCheck,
|
|
11
|
+
} from './prompt';
|
|
12
|
+
|
|
13
|
+
function memoryStorage(): Storage {
|
|
14
|
+
const map = new Map<string, string>();
|
|
15
|
+
return {
|
|
16
|
+
get length() {
|
|
17
|
+
return map.size;
|
|
18
|
+
},
|
|
19
|
+
clear: () => map.clear(),
|
|
20
|
+
getItem: (k) => map.get(k) ?? null,
|
|
21
|
+
key: (i) => [...map.keys()][i] ?? null,
|
|
22
|
+
removeItem: (k) => {
|
|
23
|
+
map.delete(k);
|
|
24
|
+
},
|
|
25
|
+
setItem: (k, v) => {
|
|
26
|
+
map.set(k, v);
|
|
27
|
+
},
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const outdated: UpdateCheck = { current: '0.3.0', latest: '9.9.9', outdated: true };
|
|
32
|
+
|
|
33
|
+
describe('shouldPrompt', () => {
|
|
34
|
+
it('stays quiet without an update', () => {
|
|
35
|
+
expect(shouldPrompt(null, null, 0)).toBe(false);
|
|
36
|
+
expect(shouldPrompt({ ...outdated, outdated: false }, null, 0)).toBe(false);
|
|
37
|
+
expect(shouldPrompt({ ...outdated, latest: null }, null, 0)).toBe(false);
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
it('prompts for an outdated version with no snooze', () => {
|
|
41
|
+
expect(shouldPrompt(outdated, null, 0)).toBe(true);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('respects a snooze on the same version until it expires', () => {
|
|
45
|
+
const snooze: Snooze = { version: '9.9.9', until: 1000 };
|
|
46
|
+
expect(shouldPrompt(outdated, snooze, 999)).toBe(false);
|
|
47
|
+
expect(shouldPrompt(outdated, snooze, 1000)).toBe(true);
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
it('prompts again as soon as a newer version ships', () => {
|
|
51
|
+
const snooze: Snooze = { version: '9.9.9', until: 1000 };
|
|
52
|
+
expect(shouldPrompt({ ...outdated, latest: '9.9.10' }, snooze, 0)).toBe(true);
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
describe('snooze storage', () => {
|
|
57
|
+
it('round-trips the version and its deadline', () => {
|
|
58
|
+
const storage = memoryStorage();
|
|
59
|
+
saveSnooze(storage, '9.9.9', 5000);
|
|
60
|
+
expect(readSnooze(storage)).toEqual({ version: '9.9.9', until: 5000 + SNOOZE_MS });
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
it('ignores anything it did not write', () => {
|
|
64
|
+
const storage = memoryStorage();
|
|
65
|
+
storage.setItem(SNOOZE_KEY, 'not json');
|
|
66
|
+
expect(readSnooze(storage)).toBeNull();
|
|
67
|
+
storage.setItem(SNOOZE_KEY, '{"version":"9.9.9"}');
|
|
68
|
+
expect(readSnooze(storage)).toBeNull();
|
|
69
|
+
storage.setItem(SNOOZE_KEY, '{"version":9,"until":1}');
|
|
70
|
+
expect(readSnooze(storage)).toBeNull();
|
|
71
|
+
storage.setItem(SNOOZE_KEY, '{"version":"9.9.9","until":"soon"}');
|
|
72
|
+
expect(readSnooze(storage)).toBeNull();
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
describe('promptsOnPage', () => {
|
|
77
|
+
it('asks on the pages people read and stays off the captures', () => {
|
|
78
|
+
expect(promptsOnPage('/')).toBe(true);
|
|
79
|
+
expect(promptsOnPage('/s/alpha')).toBe(true);
|
|
80
|
+
expect(promptsOnPage('/trash')).toBe(true);
|
|
81
|
+
expect(promptsOnPage('/s/alpha/preview')).toBe(false);
|
|
82
|
+
expect(promptsOnPage('/s/alpha/presenter')).toBe(false);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { pageForPath } from '../theme/pages';
|
|
2
|
+
|
|
3
|
+
export const UPDATE_CHECK_INTERVAL_MS = 60 * 60 * 1000;
|
|
4
|
+
export const SNOOZE_MS = 24 * 60 * 60 * 1000;
|
|
5
|
+
export const SNOOZE_KEY = 'lemonriver:update-snooze';
|
|
6
|
+
|
|
7
|
+
export type UpdateCheck = { current: string; latest: string | null; outdated: boolean };
|
|
8
|
+
export type Snooze = { version: string; until: number };
|
|
9
|
+
|
|
10
|
+
export function shouldPrompt(
|
|
11
|
+
check: UpdateCheck | null,
|
|
12
|
+
snooze: Snooze | null,
|
|
13
|
+
now: number,
|
|
14
|
+
): boolean {
|
|
15
|
+
if (!check || !check.outdated || !check.latest) return false;
|
|
16
|
+
const snoozed = snooze !== null && snooze.version === check.latest && now < snooze.until;
|
|
17
|
+
return !snoozed;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export function readSnooze(storage: Storage): Snooze | null {
|
|
21
|
+
let raw: string | null = null;
|
|
22
|
+
try {
|
|
23
|
+
raw = storage.getItem(SNOOZE_KEY);
|
|
24
|
+
} catch {
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
if (!raw) return null;
|
|
28
|
+
try {
|
|
29
|
+
const value = JSON.parse(raw) as Record<string, unknown> | null;
|
|
30
|
+
if (!value || typeof value !== 'object') return null;
|
|
31
|
+
if (typeof value.version !== 'string') return null;
|
|
32
|
+
if (typeof value.until !== 'number' || !Number.isFinite(value.until)) return null;
|
|
33
|
+
return { version: value.version, until: value.until };
|
|
34
|
+
} catch {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
export function saveSnooze(storage: Storage, version: string, now: number): void {
|
|
40
|
+
try {
|
|
41
|
+
storage.setItem(SNOOZE_KEY, JSON.stringify({ version, until: now + SNOOZE_MS }));
|
|
42
|
+
} catch {}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export function promptsOnPage(pathname: string): boolean {
|
|
46
|
+
const page = pageForPath(pathname);
|
|
47
|
+
return page !== 'preview' && page !== 'presenter';
|
|
48
|
+
}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
import { useLocation } from 'react-router-dom';
|
|
3
|
+
import { toast } from 'sonner';
|
|
4
|
+
import { format } from '@/lib/use-locale';
|
|
5
|
+
import { useRestartServer } from '@/lib/use-restart-server';
|
|
6
|
+
import { useLrText } from '../text';
|
|
7
|
+
import {
|
|
8
|
+
promptsOnPage,
|
|
9
|
+
readSnooze,
|
|
10
|
+
saveSnooze,
|
|
11
|
+
shouldPrompt,
|
|
12
|
+
UPDATE_CHECK_INTERVAL_MS,
|
|
13
|
+
type UpdateCheck,
|
|
14
|
+
} from './prompt';
|
|
15
|
+
|
|
16
|
+
const TOAST_ID = 'lemonriver-update';
|
|
17
|
+
|
|
18
|
+
export function UpdatePrompt() {
|
|
19
|
+
const { pathname } = useLocation();
|
|
20
|
+
const lr = useLrText();
|
|
21
|
+
const { canRestart, restartServer } = useRestartServer();
|
|
22
|
+
const phase = useRef<'idle' | 'busy' | 'done'>('idle');
|
|
23
|
+
const settled = useRef<string | null>(null);
|
|
24
|
+
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
if (!import.meta.env.DEV) return;
|
|
27
|
+
if (!promptsOnPage(pathname)) {
|
|
28
|
+
toast.dismiss(TOAST_ID);
|
|
29
|
+
return;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
let cancelled = false;
|
|
33
|
+
|
|
34
|
+
function snooze(latest: string) {
|
|
35
|
+
saveSnooze(localStorage, latest, Date.now());
|
|
36
|
+
toast.dismiss(TOAST_ID);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
async function runUpdate(latest: string) {
|
|
40
|
+
if (phase.current === 'busy') return;
|
|
41
|
+
phase.current = 'busy';
|
|
42
|
+
toast.loading(lr.update.updating, { id: TOAST_ID, duration: Infinity });
|
|
43
|
+
|
|
44
|
+
let ok = false;
|
|
45
|
+
try {
|
|
46
|
+
const res = await fetch('/__update-package', { method: 'POST' });
|
|
47
|
+
ok = res.ok;
|
|
48
|
+
} catch {
|
|
49
|
+
ok = false;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (!ok) {
|
|
53
|
+
phase.current = 'idle';
|
|
54
|
+
if (cancelled) return;
|
|
55
|
+
toast.error(lr.update.failed, {
|
|
56
|
+
id: TOAST_ID,
|
|
57
|
+
duration: Infinity,
|
|
58
|
+
description: lr.update.failedHint,
|
|
59
|
+
action: { label: lr.update.retry, onClick: () => void runUpdate(latest) },
|
|
60
|
+
cancel: { label: lr.update.later, onClick: () => snooze(latest) },
|
|
61
|
+
});
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
phase.current = 'done';
|
|
66
|
+
settled.current = latest;
|
|
67
|
+
if (cancelled) return;
|
|
68
|
+
toast.success(format(lr.update.updated, { version: latest }), {
|
|
69
|
+
id: TOAST_ID,
|
|
70
|
+
duration: Infinity,
|
|
71
|
+
description: canRestart ? lr.update.updatedHint : lr.update.updatedManual,
|
|
72
|
+
action: canRestart
|
|
73
|
+
? { label: lr.update.restart, onClick: () => void restartServer() }
|
|
74
|
+
: undefined,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function showPrompt(check: UpdateCheck) {
|
|
79
|
+
const latest = check.latest as string;
|
|
80
|
+
toast.warning(format(lr.update.title, { version: latest }), {
|
|
81
|
+
id: TOAST_ID,
|
|
82
|
+
duration: Infinity,
|
|
83
|
+
description: format(lr.update.hint, { current: check.current }),
|
|
84
|
+
action: { label: lr.update.now, onClick: () => void runUpdate(latest) },
|
|
85
|
+
cancel: { label: lr.update.later, onClick: () => snooze(latest) },
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
async function check() {
|
|
90
|
+
let data: UpdateCheck | null = null;
|
|
91
|
+
try {
|
|
92
|
+
const res = await fetch('/__update-check');
|
|
93
|
+
if (!res.ok) return;
|
|
94
|
+
data = (await res.json()) as UpdateCheck;
|
|
95
|
+
} catch {
|
|
96
|
+
return;
|
|
97
|
+
}
|
|
98
|
+
if (cancelled || !shouldPrompt(data, readSnooze(localStorage), Date.now())) return;
|
|
99
|
+
if (phase.current === 'busy') return;
|
|
100
|
+
if (phase.current === 'done' && settled.current === data.latest) return;
|
|
101
|
+
showPrompt(data);
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
void check();
|
|
105
|
+
const timer = setInterval(() => void check(), UPDATE_CHECK_INTERVAL_MS);
|
|
106
|
+
return () => {
|
|
107
|
+
cancelled = true;
|
|
108
|
+
clearInterval(timer);
|
|
109
|
+
};
|
|
110
|
+
}, [pathname, lr, canRestart, restartServer]);
|
|
111
|
+
|
|
112
|
+
return null;
|
|
113
|
+
}
|
package/src/app/routes/home.tsx
CHANGED
|
@@ -323,10 +323,12 @@ function SortControl({ value, onChange }: { value: SortKey; onChange: (next: Sor
|
|
|
323
323
|
);
|
|
324
324
|
}
|
|
325
325
|
|
|
326
|
+
// Offered even before an agent is connected: the new deck opens the agent
|
|
327
|
+
// panel, which walks first-time users through installing one.
|
|
326
328
|
function useCreateDeckWithAgent() {
|
|
327
|
-
const { provider } = useAgentStatus();
|
|
329
|
+
const { enabled, provider } = useAgentStatus();
|
|
328
330
|
const start = useCreateDeck();
|
|
329
|
-
if (!
|
|
331
|
+
if (!enabled) return null;
|
|
330
332
|
return { provider, start };
|
|
331
333
|
}
|
|
332
334
|
|
|
@@ -339,7 +341,11 @@ function NewDeckButton() {
|
|
|
339
341
|
size="sm"
|
|
340
342
|
className="h-8 shrink-0"
|
|
341
343
|
onClick={agent.start}
|
|
342
|
-
title={
|
|
344
|
+
title={
|
|
345
|
+
agent.provider
|
|
346
|
+
? format(t.agent.createDeckWith, { provider: agent.provider.name })
|
|
347
|
+
: t.agent.createDeck
|
|
348
|
+
}
|
|
343
349
|
>
|
|
344
350
|
<Plus />
|
|
345
351
|
{t.agent.createDeck}
|
|
@@ -404,8 +410,10 @@ function EmptyState({ isDraft, folderName }: { isDraft: boolean; folderName?: st
|
|
|
404
410
|
</p>
|
|
405
411
|
{agent ? (
|
|
406
412
|
<Button size="sm" className="mt-4" onClick={agent.start}>
|
|
407
|
-
<ProviderLogo provider={agent.provider.id} />
|
|
408
|
-
{
|
|
413
|
+
{agent.provider ? <ProviderLogo provider={agent.provider.id} /> : <Plus />}
|
|
414
|
+
{agent.provider
|
|
415
|
+
? format(t.agent.createDeckWith, { provider: agent.provider.name })
|
|
416
|
+
: t.agent.createDeck}
|
|
409
417
|
</Button>
|
|
410
418
|
) : (
|
|
411
419
|
<p className="mt-1.5 text-[13px] leading-relaxed text-muted-foreground">
|
package/src/app/routes/slide.tsx
CHANGED
|
@@ -87,6 +87,12 @@ import { PdfProgressToast, PptxProgressToast } from '../components/export-progre
|
|
|
87
87
|
import { NotesDrawer } from '../components/notes-drawer';
|
|
88
88
|
import { OverviewGrid } from '../components/overview-grid';
|
|
89
89
|
import { openPresenterWindow, Player } from '../components/player';
|
|
90
|
+
import {
|
|
91
|
+
afterPaint,
|
|
92
|
+
CURTAIN_FADE_MS,
|
|
93
|
+
PresentCurtain,
|
|
94
|
+
whenFullscreenSettled,
|
|
95
|
+
} from '../components/present/curtain';
|
|
90
96
|
import { SlideCanvas } from '../components/slide-canvas';
|
|
91
97
|
import { isDeckWarmed, markDeckWarmed, SlidePreloadLayer } from '../components/slide-preload-layer';
|
|
92
98
|
import { SlideTransitionLayer } from '../components/slide-transition-layer';
|
|
@@ -168,6 +174,55 @@ export function Slide() {
|
|
|
168
174
|
const narrowToolbar = useMediaQuery('(max-width: 639.98px)');
|
|
169
175
|
const prefersReducedMotion = usePrefersReducedMotion();
|
|
170
176
|
|
|
177
|
+
// 'entering' darkens the editor before the Player mounts; 'leaving' keeps
|
|
178
|
+
// the editor dark after the Player unmounts, then fades it back in.
|
|
179
|
+
const [curtain, setCurtain] = useState<'entering' | 'leaving' | null>(null);
|
|
180
|
+
const curtainTimerRef = useRef<ReturnType<typeof setTimeout> | null>(null);
|
|
181
|
+
useEffect(
|
|
182
|
+
() => () => {
|
|
183
|
+
if (curtainTimerRef.current) clearTimeout(curtainTimerRef.current);
|
|
184
|
+
},
|
|
185
|
+
[],
|
|
186
|
+
);
|
|
187
|
+
const present = useCallback(
|
|
188
|
+
(mode: 'window' | 'fullscreen') => {
|
|
189
|
+
if (prefersReducedMotion) {
|
|
190
|
+
setPlayMode(mode);
|
|
191
|
+
return;
|
|
192
|
+
}
|
|
193
|
+
if (curtainTimerRef.current) return;
|
|
194
|
+
setCurtain('entering');
|
|
195
|
+
// Fullscreen is requested when the Player mounts; the delay stays well
|
|
196
|
+
// inside the browser's transient user-activation window.
|
|
197
|
+
curtainTimerRef.current = setTimeout(() => {
|
|
198
|
+
curtainTimerRef.current = null;
|
|
199
|
+
setCurtain(null);
|
|
200
|
+
setPlayMode(mode);
|
|
201
|
+
}, CURTAIN_FADE_MS);
|
|
202
|
+
},
|
|
203
|
+
[prefersReducedMotion],
|
|
204
|
+
);
|
|
205
|
+
const exitPresent = useCallback(() => {
|
|
206
|
+
setPlayMode(null);
|
|
207
|
+
if (!prefersReducedMotion) setCurtain('leaving');
|
|
208
|
+
}, [prefersReducedMotion]);
|
|
209
|
+
useEffect(() => {
|
|
210
|
+
if (curtain !== 'leaving' || playMode) return;
|
|
211
|
+
let cancelPaint = () => {};
|
|
212
|
+
const reveal = () => {
|
|
213
|
+
cancelPaint = afterPaint(() => setCurtain(null));
|
|
214
|
+
};
|
|
215
|
+
if (!document.fullscreenElement) {
|
|
216
|
+
reveal();
|
|
217
|
+
return () => cancelPaint();
|
|
218
|
+
}
|
|
219
|
+
const cancelWait = whenFullscreenSettled(reveal);
|
|
220
|
+
return () => {
|
|
221
|
+
cancelWait();
|
|
222
|
+
cancelPaint();
|
|
223
|
+
};
|
|
224
|
+
}, [curtain, playMode]);
|
|
225
|
+
|
|
171
226
|
const modulePages = useMemo(() => slide?.default ?? [], [slide]);
|
|
172
227
|
const [pages, setPages] = useState<typeof modulePages>(modulePages);
|
|
173
228
|
useEffect(() => {
|
|
@@ -337,7 +392,7 @@ export function Slide() {
|
|
|
337
392
|
// When showSlideUi is false the read-only <Player> is rendered and owns
|
|
338
393
|
// keyboard navigation (including step-aware advance/retreat). Attaching this
|
|
339
394
|
// page-nav handler too would race it and skip <Steps> reveals, so bail out.
|
|
340
|
-
if (playMode || !showSlideUi) return;
|
|
395
|
+
if (playMode || curtain || !showSlideUi) return;
|
|
341
396
|
const onKey = (e: KeyboardEvent) => {
|
|
342
397
|
if (
|
|
343
398
|
isTypingTarget(e.target) ||
|
|
@@ -370,12 +425,12 @@ export function Slide() {
|
|
|
370
425
|
return;
|
|
371
426
|
}
|
|
372
427
|
if (e.key === 'f' || e.key === 'F') {
|
|
373
|
-
|
|
428
|
+
present('fullscreen');
|
|
374
429
|
} else if (e.key === 'Enter') {
|
|
375
|
-
|
|
430
|
+
present('window');
|
|
376
431
|
} else if (e.key === 'p' || e.key === 'P') {
|
|
377
432
|
if (slideId) openPresenterWindow(slideId);
|
|
378
|
-
|
|
433
|
+
present('window');
|
|
379
434
|
} else if (import.meta.env.DEV && (e.key === 'd' || e.key === 'D')) {
|
|
380
435
|
setDesignOpen((v) => !v);
|
|
381
436
|
} else if (import.meta.env.DEV && (e.key === 'a' || e.key === 'A')) {
|
|
@@ -384,7 +439,7 @@ export function Slide() {
|
|
|
384
439
|
};
|
|
385
440
|
window.addEventListener('keydown', onKey);
|
|
386
441
|
return () => window.removeEventListener('keydown', onKey);
|
|
387
|
-
}, [index, goTo, playMode, slideId, overviewOpen, toggleAgent]);
|
|
442
|
+
}, [index, goTo, playMode, curtain, slideId, overviewOpen, toggleAgent, present]);
|
|
388
443
|
|
|
389
444
|
if (error) {
|
|
390
445
|
return (
|
|
@@ -425,8 +480,9 @@ export function Slide() {
|
|
|
425
480
|
transition={presented.slide.transition}
|
|
426
481
|
index={presented.index}
|
|
427
482
|
onIndexChange={presentReady ? goTo : noop}
|
|
428
|
-
onExit={
|
|
483
|
+
onExit={exitPresent}
|
|
429
484
|
controls
|
|
485
|
+
curtain={!prefersReducedMotion}
|
|
430
486
|
slideId={presented.slideId}
|
|
431
487
|
onSwitchSlide={switchPresentedSlide}
|
|
432
488
|
fullscreen={playMode === 'fullscreen'}
|
|
@@ -807,7 +863,7 @@ export function Slide() {
|
|
|
807
863
|
size="sm"
|
|
808
864
|
variant="brand"
|
|
809
865
|
aria-label={t.slide.present}
|
|
810
|
-
onClick={() =>
|
|
866
|
+
onClick={() => present(isMobile ? 'window' : 'fullscreen')}
|
|
811
867
|
className="rounded-r-none px-2.5 lg:px-3"
|
|
812
868
|
>
|
|
813
869
|
<Play className="size-3.5 fill-current" />
|
|
@@ -827,12 +883,12 @@ export function Slide() {
|
|
|
827
883
|
</DropdownMenuTrigger>
|
|
828
884
|
<DropdownMenuContent align="end" className="min-w-[200px]">
|
|
829
885
|
<DropdownMenuGroup>
|
|
830
|
-
<DropdownMenuItem onClick={() =>
|
|
886
|
+
<DropdownMenuItem onClick={() => present('window')}>
|
|
831
887
|
<Play />
|
|
832
888
|
{t.slide.presentInWindow}
|
|
833
889
|
<DropdownMenuShortcut>↵</DropdownMenuShortcut>
|
|
834
890
|
</DropdownMenuItem>
|
|
835
|
-
<DropdownMenuItem onClick={() =>
|
|
891
|
+
<DropdownMenuItem onClick={() => present('fullscreen')}>
|
|
836
892
|
<Maximize />
|
|
837
893
|
{t.slide.presentFullscreen}
|
|
838
894
|
<DropdownMenuShortcut>F</DropdownMenuShortcut>
|
|
@@ -840,7 +896,7 @@ export function Slide() {
|
|
|
840
896
|
<DropdownMenuItem
|
|
841
897
|
onClick={() => {
|
|
842
898
|
if (slideId) openPresenterWindow(slideId);
|
|
843
|
-
|
|
899
|
+
present('window');
|
|
844
900
|
}}
|
|
845
901
|
>
|
|
846
902
|
<MonitorSpeaker />
|
|
@@ -964,11 +1020,11 @@ export function Slide() {
|
|
|
964
1020
|
currentIndex={index}
|
|
965
1021
|
exporting={exporting}
|
|
966
1022
|
handlers={{
|
|
967
|
-
onPresentWindow: () =>
|
|
968
|
-
onPresentFullscreen: () =>
|
|
1023
|
+
onPresentWindow: () => present('window'),
|
|
1024
|
+
onPresentFullscreen: () => present('fullscreen'),
|
|
969
1025
|
onPresenterView: () => {
|
|
970
1026
|
if (slideId) openPresenterWindow(slideId);
|
|
971
|
-
|
|
1027
|
+
present('window');
|
|
972
1028
|
},
|
|
973
1029
|
onCopyLink: copyLink,
|
|
974
1030
|
onOverview: () => setOverviewOpen(true),
|
|
@@ -983,6 +1039,7 @@ export function Slide() {
|
|
|
983
1039
|
/>
|
|
984
1040
|
)}
|
|
985
1041
|
</div>
|
|
1042
|
+
<PresentCurtain opaque={curtain !== null} className="fixed z-[1000]" />
|
|
986
1043
|
</InspectorProvider>
|
|
987
1044
|
</HistoryProvider>
|
|
988
1045
|
);
|
package/src/locale/en.ts
CHANGED
|
@@ -178,6 +178,7 @@ export const en: Locale = {
|
|
|
178
178
|
helpAria: 'Keyboard shortcuts (?)',
|
|
179
179
|
exitAria: 'Exit (Esc)',
|
|
180
180
|
elapsedTime: 'Elapsed time',
|
|
181
|
+
lastSlideHint: 'Last slide · Press Esc to exit',
|
|
181
182
|
helpEyebrow: 'Present mode',
|
|
182
183
|
helpTitle: 'Keyboard shortcuts',
|
|
183
184
|
shortcutNext: 'Next slide',
|
package/src/locale/es.ts
CHANGED
|
@@ -180,6 +180,7 @@ export const es: Locale = {
|
|
|
180
180
|
helpAria: 'Atajos de teclado (?)',
|
|
181
181
|
exitAria: 'Salir (Esc)',
|
|
182
182
|
elapsedTime: 'Tiempo transcurrido',
|
|
183
|
+
lastSlideHint: 'Última diapositiva · Pulsa Esc para salir',
|
|
183
184
|
helpEyebrow: 'Modo presentación',
|
|
184
185
|
helpTitle: 'Atajos de teclado',
|
|
185
186
|
shortcutNext: 'Diapositiva siguiente',
|
package/src/locale/ja.ts
CHANGED
package/src/locale/types.ts
CHANGED
package/src/locale/zh-cn.ts
CHANGED
package/src/locale/zh-tw.ts
CHANGED