@lemonriver/core 1.2.0 → 1.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-CSkdswfd.js → build-Cv0nNc4G.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-C5-myPY6.js → config-Di9kipre.js} +2773 -714
- package/dist/{config-CYNOR93W.d.ts → config-f1SqAhtR.d.ts} +1 -1
- package/dist/{dev-DHtYH8sw.js → dev-Az1UzCQp.js} +11 -11
- package/dist/index.d.ts +2 -2
- package/dist/index.js +21 -2
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{mcp-B2UeO1un.js → mcp-CW7H6oUg.js} +1 -1
- package/dist/{preview-C1B6-umF.js → preview-DtSq5uN1.js} +1 -1
- package/dist/{types-tdaXSyah.d.ts → types-C4VfD89E.d.ts} +12 -0
- package/dist/{update-DzL8fpcI.js → update-DVe2kQA7.js} +86 -13
- package/dist/vite/index.d.ts +1 -1
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-BhYyMx0-.js → zh-tw-BX3oQAc2.js} +110 -0
- package/package.json +5 -6
- package/release-notes.json +34 -0
- package/src/agent/types.ts +9 -2
- package/src/app/app.tsx +2 -0
- package/src/app/components/agent/agent-panel.tsx +12 -3
- package/src/app/components/agent/agent-presence.tsx +1 -1
- package/src/app/components/command/home-command-menu.tsx +4 -1
- package/src/app/components/command/slide-command-menu.tsx +4 -1
- package/src/app/components/export-progress-toast.tsx +3 -1
- package/src/app/components/inspector/asset-picker-dialog.tsx +1 -1
- package/src/app/components/inspector/comment-layer.tsx +3 -3
- package/src/app/components/inspector/inline-text-editor.tsx +1 -12
- package/src/app/components/inspector/inspect-overlay.tsx +9 -1
- package/src/app/components/inspector/inspector-panel.tsx +7 -23
- package/src/app/components/inspector/inspector-provider.tsx +177 -36
- package/src/app/components/inspector/page-panel.tsx +270 -0
- package/src/app/components/language-toggle.tsx +13 -11
- package/src/app/components/overview-grid.tsx +3 -3
- package/src/app/components/panel/editor-sidebar.tsx +43 -8
- package/src/app/components/panel/panel-shell.tsx +9 -5
- package/src/app/components/panel/save-card.tsx +1 -1
- package/src/app/components/player.tsx +6 -1
- package/src/app/components/sidebar/folder-item.tsx +4 -1
- package/src/app/components/sidebar/sidebar.tsx +11 -8
- package/src/app/components/slide-canvas.tsx +1 -1
- package/src/app/components/style-panel/design-provider.tsx +48 -11
- package/src/app/components/style-panel/use-design.ts +6 -1
- package/src/app/components/theme-toggle.tsx +16 -22
- package/src/app/components/thumbnail-rail.tsx +69 -50
- package/src/app/components/ui/context-menu.tsx +9 -10
- package/src/app/components/ui/dialog.tsx +2 -4
- package/src/app/components/ui/dropdown-menu.tsx +9 -10
- package/src/app/components/ui/popover.tsx +1 -1
- package/src/app/components/ui/select.tsx +2 -2
- package/src/app/components/ui/sonner.tsx +2 -2
- package/src/app/index.html +7 -0
- package/src/app/lemonriver/agent-cli/model.ts +22 -0
- package/src/app/lemonriver/agent-install/model.ts +46 -0
- package/src/app/lemonriver/agent-install/section.tsx +178 -0
- package/src/app/lemonriver/agent-install/use-install.ts +51 -0
- package/src/app/lemonriver/agent-providers/section.tsx +385 -44
- package/src/app/lemonriver/agent-providers/use-providers.ts +50 -3
- package/src/app/lemonriver/backup/places.ts +22 -12
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +1 -1
- package/src/app/lemonriver/feedback/dialog.tsx +1 -2
- package/src/app/lemonriver/feedback/model.ts +0 -5
- package/src/app/lemonriver/guide/clipboard.ts +19 -0
- package/src/app/lemonriver/guide/create-board.tsx +150 -0
- package/src/app/lemonriver/guide/install-board.tsx +208 -0
- package/src/app/lemonriver/guide/more-agents-page.tsx +89 -0
- package/src/app/lemonriver/guide/more-agents.ts +137 -0
- package/src/app/lemonriver/guide/quick-board.tsx +57 -0
- package/src/app/lemonriver/guide/start-board.tsx +38 -0
- package/src/app/lemonriver/guide/start-card.tsx +105 -0
- package/src/app/lemonriver/guide/start.ts +174 -0
- package/src/app/lemonriver/guide/state.ts +5 -21
- package/src/app/lemonriver/help/help-page.tsx +24 -6
- package/src/app/lemonriver/help/model.ts +1 -0
- package/src/app/lemonriver/home/home-page.tsx +12 -6
- package/src/app/lemonriver/home/sorting.ts +45 -0
- package/src/app/lemonriver/home/use-deck-times.ts +1 -2
- package/src/app/lemonriver/i18n/system-locale.ts +39 -0
- package/src/app/lemonriver/present/dual-screen.ts +154 -0
- package/src/app/lemonriver/present/presenter-blocked-hint.tsx +28 -0
- package/src/app/lemonriver/present/wake-lock.ts +74 -0
- package/src/app/lemonriver/routes.tsx +2 -0
- package/src/app/lemonriver/settings/backup-section.tsx +3 -2
- package/src/app/lemonriver/settings/settings-page.tsx +5 -6
- package/src/app/lemonriver/settings/workspace-card.tsx +2 -1
- package/src/app/lemonriver/share/share-dialog.tsx +2 -1
- package/src/app/lemonriver/text/en.ts +594 -452
- package/src/app/lemonriver/text/es.ts +404 -270
- package/src/app/lemonriver/text/ja.ts +405 -273
- package/src/app/lemonriver/text/platform.ts +7 -0
- package/src/app/lemonriver/text/types.ts +122 -1
- package/src/app/lemonriver/text/zh-cn.ts +645 -507
- package/src/app/lemonriver/text/zh-tw.ts +681 -544
- package/src/app/lemonriver/theme/app.css +9 -0
- package/src/app/lemonriver/theme/controls.css +5 -2
- package/src/app/lemonriver/theme/index.css +9 -0
- package/src/app/lemonriver/theme/pages.ts +2 -0
- package/src/app/lemonriver/theme/theme-menu.tsx +10 -11
- package/src/app/lemonriver/update/restart-wait.ts +45 -0
- package/src/app/lemonriver/update/update-prompt.tsx +9 -0
- package/src/app/lib/agent/use-agent.ts +117 -30
- package/src/app/lib/desktop-host.ts +31 -0
- package/src/app/lib/desktop-routes.ts +22 -0
- package/src/app/lib/desktop.ts +106 -0
- package/src/app/lib/export-pdf.ts +15 -7
- package/src/app/lib/inspector/color.ts +51 -0
- package/src/app/lib/inspector/fiber.ts +6 -0
- package/src/app/lib/inspector/use-editor.ts +2 -1
- package/src/app/lib/inspector/use-notes.ts +331 -57
- package/src/app/lib/inspector/use-visual-editor.ts +9 -1
- package/src/app/lib/locale-store.ts +6 -1
- package/src/app/lib/transition.ts +43 -0
- package/src/app/lib/unsaved.ts +155 -0
- package/src/app/routes/home.tsx +1 -1
- package/src/app/routes/presenter.tsx +2 -0
- package/src/app/routes/slide.tsx +130 -74
- package/src/app/styles.css +39 -1
- package/src/locale/en.ts +19 -0
- package/src/locale/es.ts +19 -0
- package/src/locale/ja.ts +19 -0
- package/src/locale/types.ts +12 -0
- package/src/locale/zh-cn.ts +19 -0
- package/src/locale/zh-tw.ts +19 -0
- package/src/app/lemonriver/guide/guide-prompt.tsx +0 -89
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { X } from 'lucide-react';
|
|
2
|
+
import { useCallback, useEffect, useRef, useState } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { Dialog, DialogClose, DialogContent } from '@/components/ui/dialog';
|
|
5
|
+
import { slideIds } from '../../lib/slides';
|
|
6
|
+
import { useAgentInstall } from '../agent-install/use-install';
|
|
7
|
+
import { useLrText } from '../text';
|
|
8
|
+
import { CreateBoard } from './create-board';
|
|
9
|
+
import { InstallBoard } from './install-board';
|
|
10
|
+
import { QuickBoard } from './quick-board';
|
|
11
|
+
import { readStart, type StartState, saveStart, startProgress, startVisible } from './start';
|
|
12
|
+
|
|
13
|
+
export function StartCard({ times }: { times: Record<string, { modifiedAt: number }> }) {
|
|
14
|
+
const lr = useLrText();
|
|
15
|
+
const t = lr.start;
|
|
16
|
+
const { catalog, working, act } = useAgentInstall();
|
|
17
|
+
const [start, setStart] = useState<StartState>(() => readStart(localStorage));
|
|
18
|
+
const [finishedNow, setFinishedNow] = useState(false);
|
|
19
|
+
const shownAtMount = useRef<boolean | null>(null);
|
|
20
|
+
if (shownAtMount.current === null) shownAtMount.current = startVisible(start, slideIds);
|
|
21
|
+
|
|
22
|
+
const apps = catalog?.apps ?? [];
|
|
23
|
+
const progress = startProgress(start, times);
|
|
24
|
+
|
|
25
|
+
const update = useCallback((patch: Partial<StartState>) => {
|
|
26
|
+
setStart((current) => {
|
|
27
|
+
const next = { ...current, ...patch };
|
|
28
|
+
saveStart(localStorage, next);
|
|
29
|
+
return next;
|
|
30
|
+
});
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
if (shownAtMount.current && start.since === null) update({ since: Date.now() });
|
|
35
|
+
}, [start.since, update]);
|
|
36
|
+
|
|
37
|
+
useEffect(() => {
|
|
38
|
+
if (shownAtMount.current && progress.made && !start.made) {
|
|
39
|
+
update({ made: true, madeDeck: progress.madeDeck });
|
|
40
|
+
}
|
|
41
|
+
}, [progress.made, progress.madeDeck, start.made, update]);
|
|
42
|
+
|
|
43
|
+
useEffect(() => {
|
|
44
|
+
if (shownAtMount.current && progress.done && !start.done) {
|
|
45
|
+
update({ done: true });
|
|
46
|
+
setFinishedNow(true);
|
|
47
|
+
}
|
|
48
|
+
}, [progress.done, start.done, update]);
|
|
49
|
+
|
|
50
|
+
if (!shownAtMount.current) return null;
|
|
51
|
+
const open = !start.collapsed && (!start.done || finishedNow);
|
|
52
|
+
|
|
53
|
+
return (
|
|
54
|
+
<Dialog
|
|
55
|
+
open={open}
|
|
56
|
+
onOpenChange={(next) => {
|
|
57
|
+
// Closing (the X, Escape or the mask) keeps the card away for good;
|
|
58
|
+
// the help page can bring it back.
|
|
59
|
+
if (!next) update({ collapsed: true });
|
|
60
|
+
}}
|
|
61
|
+
>
|
|
62
|
+
<DialogContent
|
|
63
|
+
showCloseButton={false}
|
|
64
|
+
data-lr-start-card
|
|
65
|
+
data-lr-start-done={progress.done ? '' : undefined}
|
|
66
|
+
className="max-h-[calc(100dvh-2rem)] w-[calc(100vw-2rem)] gap-4 overflow-y-auto p-5 sm:max-w-[940px] sm:p-6"
|
|
67
|
+
>
|
|
68
|
+
<div className="flex items-start gap-4">
|
|
69
|
+
<div className="min-w-0 flex-1">
|
|
70
|
+
<h2 className="font-heading text-[19px] font-semibold leading-6">
|
|
71
|
+
{progress.done ? t.done : t.title}
|
|
72
|
+
</h2>
|
|
73
|
+
{!progress.done && (
|
|
74
|
+
<p className="mt-1 text-[13px] text-muted-foreground">{t.subtitle}</p>
|
|
75
|
+
)}
|
|
76
|
+
</div>
|
|
77
|
+
<DialogClose
|
|
78
|
+
data-lr-start-close
|
|
79
|
+
aria-label={t.close}
|
|
80
|
+
title={t.close}
|
|
81
|
+
className="flex size-8 shrink-0 items-center justify-center rounded-[8px] text-muted-foreground outline-none hover:bg-muted hover:text-foreground focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
82
|
+
>
|
|
83
|
+
<X className="size-4" />
|
|
84
|
+
</DialogClose>
|
|
85
|
+
</div>
|
|
86
|
+
|
|
87
|
+
<div data-lr-start-boards className="grid gap-3 md:grid-cols-3">
|
|
88
|
+
<QuickBoard copied={start.copied} onCopied={() => update({ copied: true })} />
|
|
89
|
+
<InstallBoard apps={apps} working={working} act={act} />
|
|
90
|
+
<CreateBoard />
|
|
91
|
+
</div>
|
|
92
|
+
|
|
93
|
+
<div className="text-right">
|
|
94
|
+
<Link
|
|
95
|
+
to="/help#guide"
|
|
96
|
+
data-lr-start-help
|
|
97
|
+
className="text-[12px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
98
|
+
>
|
|
99
|
+
{lr.guide.sidebar}
|
|
100
|
+
</Link>
|
|
101
|
+
</div>
|
|
102
|
+
</DialogContent>
|
|
103
|
+
</Dialog>
|
|
104
|
+
);
|
|
105
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { format } from '../../../locale/format';
|
|
2
|
+
|
|
3
|
+
// Decks every new workspace ships with. A workspace holding only these is
|
|
4
|
+
// still new: upgrading an existing install must not pop the start card.
|
|
5
|
+
export const BUILT_IN_SLIDES: ReadonlySet<string> = new Set([
|
|
6
|
+
'getting-started',
|
|
7
|
+
'getting-started-zh',
|
|
8
|
+
'try-lemonriver',
|
|
9
|
+
'lemonriver-intro',
|
|
10
|
+
'lemonriver-intro-en',
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
/** Sample decks generated from the template library all start this way. */
|
|
14
|
+
export const SAMPLE_PREFIX = 'sample-';
|
|
15
|
+
|
|
16
|
+
export function isBuiltInSlide(
|
|
17
|
+
id: string,
|
|
18
|
+
builtIns: ReadonlySet<string> = BUILT_IN_SLIDES,
|
|
19
|
+
): boolean {
|
|
20
|
+
return id.startsWith(SAMPLE_PREFIX) || builtIns.has(id);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export type StartState = {
|
|
24
|
+
copied: boolean;
|
|
25
|
+
made: boolean;
|
|
26
|
+
madeDeck: string | null;
|
|
27
|
+
done: boolean;
|
|
28
|
+
collapsed: boolean;
|
|
29
|
+
reopened: boolean;
|
|
30
|
+
/** Epoch ms of the first time the card was shown, for "a deck changed after this". */
|
|
31
|
+
since: number | null;
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export const START_KEY = 'lemonriver:start';
|
|
35
|
+
|
|
36
|
+
export const DEFAULT_START: StartState = {
|
|
37
|
+
copied: false,
|
|
38
|
+
made: false,
|
|
39
|
+
madeDeck: null,
|
|
40
|
+
done: false,
|
|
41
|
+
collapsed: false,
|
|
42
|
+
reopened: false,
|
|
43
|
+
since: null,
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
function flag(value: unknown, fallback: boolean): boolean {
|
|
47
|
+
return typeof value === 'boolean' ? value : fallback;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function sanitizeStart(raw: unknown): StartState {
|
|
51
|
+
if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return { ...DEFAULT_START };
|
|
52
|
+
const r = raw as Record<string, unknown>;
|
|
53
|
+
const madeDeck = typeof r.madeDeck === 'string' ? r.madeDeck : null;
|
|
54
|
+
// Earlier versions recorded a change to a shipped deck as the user's first
|
|
55
|
+
// deck; treat that stored result as unfinished so the card comes back.
|
|
56
|
+
const bogus = madeDeck !== null && isBuiltInSlide(madeDeck);
|
|
57
|
+
return {
|
|
58
|
+
copied: flag(r.copied, false),
|
|
59
|
+
made: bogus ? false : flag(r.made, false),
|
|
60
|
+
madeDeck: bogus ? null : madeDeck,
|
|
61
|
+
done: bogus ? false : flag(r.done, false),
|
|
62
|
+
collapsed: flag(r.collapsed, false),
|
|
63
|
+
reopened: flag(r.reopened, false),
|
|
64
|
+
since: typeof r.since === 'number' && Number.isFinite(r.since) ? r.since : null,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function readStart(storage: Storage): StartState {
|
|
69
|
+
try {
|
|
70
|
+
const raw = storage.getItem(START_KEY);
|
|
71
|
+
return raw ? sanitizeStart(JSON.parse(raw)) : { ...DEFAULT_START };
|
|
72
|
+
} catch {
|
|
73
|
+
return { ...DEFAULT_START };
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function saveStart(storage: Storage, state: StartState): void {
|
|
78
|
+
try {
|
|
79
|
+
storage.setItem(START_KEY, JSON.stringify(state));
|
|
80
|
+
} catch {}
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
export function clearStart(storage: Storage): void {
|
|
84
|
+
try {
|
|
85
|
+
storage.removeItem(START_KEY);
|
|
86
|
+
} catch {}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** True when every deck is one the product shipped; an old user has their own. */
|
|
90
|
+
export function isNewWorkspace(
|
|
91
|
+
slideIds: readonly string[],
|
|
92
|
+
builtIns: ReadonlySet<string> = BUILT_IN_SLIDES,
|
|
93
|
+
): boolean {
|
|
94
|
+
return slideIds.every((id) => isBuiltInSlide(id, builtIns));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
type Times = Record<string, { modifiedAt: number } | undefined>;
|
|
98
|
+
|
|
99
|
+
/** The deck the user changed since the card first appeared, newest first. */
|
|
100
|
+
export function changedDeck(
|
|
101
|
+
times: Times,
|
|
102
|
+
since: number | null,
|
|
103
|
+
builtIns: ReadonlySet<string> = BUILT_IN_SLIDES,
|
|
104
|
+
): string | null {
|
|
105
|
+
if (since === null) return null;
|
|
106
|
+
let best: { id: string; at: number } | null = null;
|
|
107
|
+
for (const [id, time] of Object.entries(times)) {
|
|
108
|
+
if (isBuiltInSlide(id, builtIns)) continue;
|
|
109
|
+
if (!time || !Number.isFinite(time.modifiedAt)) continue;
|
|
110
|
+
if (time.modifiedAt <= since) continue;
|
|
111
|
+
if (!best || time.modifiedAt > best.at) best = { id, at: time.modifiedAt };
|
|
112
|
+
}
|
|
113
|
+
return best?.id ?? null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export type StartProgress = {
|
|
117
|
+
made: boolean;
|
|
118
|
+
madeDeck: string | null;
|
|
119
|
+
done: boolean;
|
|
120
|
+
};
|
|
121
|
+
|
|
122
|
+
/**
|
|
123
|
+
* Any of the three boards finishes the card once a new deck is here — copied
|
|
124
|
+
* prompts and installed plugins only line up the deck that follows.
|
|
125
|
+
*/
|
|
126
|
+
export function startProgress(state: StartState, times: Times): StartProgress {
|
|
127
|
+
const changed = changedDeck(times, state.since);
|
|
128
|
+
const madeDeck = state.madeDeck ?? changed;
|
|
129
|
+
const made = state.made || changed !== null;
|
|
130
|
+
return { made, madeDeck, done: made };
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The quick-start prompt, with the live workspace path and address filled in. */
|
|
134
|
+
export function startPrompt(
|
|
135
|
+
template: string,
|
|
136
|
+
workspace: string | null,
|
|
137
|
+
url: string,
|
|
138
|
+
): string | null {
|
|
139
|
+
if (!workspace) return null;
|
|
140
|
+
return format(template, { path: workspace, url });
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Apps whose desktop program is on this machine first; the rest keep their order. */
|
|
144
|
+
export function orderInstallApps<T extends { state: string }>(apps: readonly T[]): T[] {
|
|
145
|
+
return [
|
|
146
|
+
...apps.filter((app) => app.state !== 'no-app'),
|
|
147
|
+
...apps.filter((a) => a.state === 'no-app'),
|
|
148
|
+
];
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
type CliLike = { state: string } | null;
|
|
152
|
+
|
|
153
|
+
/** Command lines found on this machine (signed in or not) first. */
|
|
154
|
+
export function orderCliAgents<T extends { cli: CliLike }>(rows: readonly T[]): T[] {
|
|
155
|
+
return [
|
|
156
|
+
...rows.filter((row) => row.cli && row.cli.state !== 'missing'),
|
|
157
|
+
...rows.filter((row) => !row.cli || row.cli.state === 'missing'),
|
|
158
|
+
];
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
// Starting a deck needs a command line the panel can actually drive, signed in;
|
|
162
|
+
// a detected agent the panel has no provider for does not count.
|
|
163
|
+
export function hasReadyCli(rows: readonly { cli: CliLike; connectable?: boolean }[]): boolean {
|
|
164
|
+
return rows.some((row) => row.connectable === true && row.cli?.state === 'found');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
/** Whether the card belongs on the home page at all. */
|
|
168
|
+
export function startVisible(state: StartState, slideIds: readonly string[]): boolean {
|
|
169
|
+
if (state.done) return false;
|
|
170
|
+
// Once the card has been shown, keep it until it is finished: the deck the
|
|
171
|
+
// user just made must not turn them into an "old user" and hide the card.
|
|
172
|
+
if (state.reopened || state.since !== null) return true;
|
|
173
|
+
return isNewWorkspace(slideIds);
|
|
174
|
+
}
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
export type GuideFlags = {
|
|
1
|
+
export type GuideFlags = { guided: boolean };
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export function guideSeen(): boolean {
|
|
6
|
-
try {
|
|
7
|
-
return localStorage.getItem(GUIDE_SEEN_KEY) === '1';
|
|
8
|
-
} catch {
|
|
9
|
-
return true;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export function markGuideSeen(): void {
|
|
14
|
-
try {
|
|
15
|
-
localStorage.setItem(GUIDE_SEEN_KEY, '1');
|
|
16
|
-
} catch {}
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
/** The server decides both: the chooser on first open, and the in-app agent entry points. */
|
|
3
|
+
/** The server decides whether the in-app agent entry points stay on. */
|
|
20
4
|
export async function guideFlags(): Promise<GuideFlags> {
|
|
21
5
|
try {
|
|
22
6
|
const res = await fetch('/__lr/guide');
|
|
23
7
|
if (!res.ok) throw new Error(String(res.status));
|
|
24
|
-
const data = (await res.json()) as {
|
|
25
|
-
return {
|
|
8
|
+
const data = (await res.json()) as { guided?: unknown };
|
|
9
|
+
return { guided: data.guided === true };
|
|
26
10
|
} catch {
|
|
27
|
-
return {
|
|
11
|
+
return { guided: false };
|
|
28
12
|
}
|
|
29
13
|
}
|
|
@@ -3,9 +3,10 @@ import { useEffect, useMemo, useState } from 'react';
|
|
|
3
3
|
import { Link, useLocation } from 'react-router-dom';
|
|
4
4
|
import { format } from '@/lib/use-locale';
|
|
5
5
|
import { cn } from '@/lib/utils';
|
|
6
|
-
import {
|
|
6
|
+
import { DEFAULT_START, saveStart } from '../guide/start';
|
|
7
7
|
import { SUPPORT_URL } from '../links';
|
|
8
8
|
import { useLrText } from '../text';
|
|
9
|
+
import { revealLabel } from '../text/platform';
|
|
9
10
|
import { useReduceMotionSetting } from '../theme/motion';
|
|
10
11
|
import {
|
|
11
12
|
filterHelpSections,
|
|
@@ -220,10 +221,6 @@ export function HelpPage() {
|
|
|
220
221
|
|
|
221
222
|
const anchor = location.hash.replace(/^#/, '');
|
|
222
223
|
|
|
223
|
-
useEffect(() => {
|
|
224
|
-
if (anchor.startsWith('guide')) markGuideSeen();
|
|
225
|
-
}, [anchor]);
|
|
226
|
-
|
|
227
224
|
useEffect(() => {
|
|
228
225
|
if (anchor === '') return;
|
|
229
226
|
const target = document.getElementById(`help-${anchor}`);
|
|
@@ -248,6 +245,20 @@ export function HelpPage() {
|
|
|
248
245
|
{help.title}
|
|
249
246
|
</h1>
|
|
250
247
|
<p className="mt-0.5 text-[14px] text-muted-foreground">{help.intro}</p>
|
|
248
|
+
<Link
|
|
249
|
+
to="/"
|
|
250
|
+
data-lr-start-reopen
|
|
251
|
+
onClick={() => {
|
|
252
|
+
saveStart(localStorage, {
|
|
253
|
+
...DEFAULT_START,
|
|
254
|
+
reopened: true,
|
|
255
|
+
since: Date.now(),
|
|
256
|
+
});
|
|
257
|
+
}}
|
|
258
|
+
className="mt-2 inline-block text-[13px] text-foreground underline underline-offset-2 outline-none hover:no-underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
259
|
+
>
|
|
260
|
+
{lr.start.reopen}
|
|
261
|
+
</Link>
|
|
251
262
|
</header>
|
|
252
263
|
|
|
253
264
|
<input
|
|
@@ -270,7 +281,14 @@ export function HelpPage() {
|
|
|
270
281
|
<Section
|
|
271
282
|
key={section.id}
|
|
272
283
|
section={section}
|
|
273
|
-
values={
|
|
284
|
+
values={{
|
|
285
|
+
...help.buttons,
|
|
286
|
+
reveal: revealLabel(
|
|
287
|
+
navigator.userAgent,
|
|
288
|
+
help.buttons.reveal,
|
|
289
|
+
help.buttons.revealExplorer,
|
|
290
|
+
),
|
|
291
|
+
}}
|
|
274
292
|
highlighted={highlight === section.id}
|
|
275
293
|
/>
|
|
276
294
|
))}
|
|
@@ -19,7 +19,7 @@ import type { HomeOutletContext } from '../../routes/home-shell';
|
|
|
19
19
|
import { FilterPill } from '../chrome/filter-pill';
|
|
20
20
|
import { isFeatureEnabled } from '../features';
|
|
21
21
|
import { LemonEmpty } from '../feedback/lemon-empty';
|
|
22
|
-
import {
|
|
22
|
+
import { StartCard } from '../guide/start-card';
|
|
23
23
|
import { useGuideFlags } from '../guide/use-guide';
|
|
24
24
|
import { type InspectOk, inspectPackage } from '../share/client';
|
|
25
25
|
import { shareErrorText } from '../share/codes';
|
|
@@ -35,7 +35,7 @@ import { SearchInput, SortControl } from './controls';
|
|
|
35
35
|
import { DeckCard } from './deck-card';
|
|
36
36
|
import { MoveDialog, RenameDialog, TypedConfirmDialog } from './dialogs';
|
|
37
37
|
import { OrganizeDraftsDialog } from './organize-drafts';
|
|
38
|
-
import { filterDecks,
|
|
38
|
+
import { filterDecks, homeOrder, useSortPref } from './sorting';
|
|
39
39
|
import { greetingFor } from './time';
|
|
40
40
|
import { useDeckTimes } from './use-deck-times';
|
|
41
41
|
import { useDelayed } from './use-delayed';
|
|
@@ -95,11 +95,17 @@ export function LemonRiverHome() {
|
|
|
95
95
|
() => (occasion ? filtered.filter((id) => times[id]?.occasion === occasion) : filtered),
|
|
96
96
|
[filtered, occasion, times],
|
|
97
97
|
);
|
|
98
|
+
const searching = query.trim().length > 0;
|
|
98
99
|
const sorted = useMemo(
|
|
99
|
-
() =>
|
|
100
|
-
|
|
100
|
+
() =>
|
|
101
|
+
homeOrder(
|
|
102
|
+
shown,
|
|
103
|
+
{ sort: sortKey, all: isAll, searching, locale: t.id },
|
|
104
|
+
(id) => titleMap[id] ?? id,
|
|
105
|
+
slideCreatedAt,
|
|
106
|
+
),
|
|
107
|
+
[shown, sortKey, isAll, searching, t.id, titleMap],
|
|
101
108
|
);
|
|
102
|
-
const searching = query.trim().length > 0;
|
|
103
109
|
const narrowing = searching || occasion !== null;
|
|
104
110
|
const showLoading = useDelayed(loading);
|
|
105
111
|
const titleOf = (id: string) => titleMap[id] ?? id;
|
|
@@ -199,7 +205,7 @@ export function LemonRiverHome() {
|
|
|
199
205
|
return (
|
|
200
206
|
<div data-lr-home {...(shareOn ? dropHandlers : {})}>
|
|
201
207
|
{shareOn && dropHint}
|
|
202
|
-
{
|
|
208
|
+
<StartCard times={times} />
|
|
203
209
|
{import.meta.env.DEV && isAll && (
|
|
204
210
|
<>
|
|
205
211
|
<header className="mb-6">
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { useState } from 'react';
|
|
2
|
+
import { BUILT_IN_SLIDES } from '../guide/start';
|
|
2
3
|
|
|
3
4
|
export type SortKey = 'created-desc' | 'created-asc' | 'title-asc' | 'title-desc';
|
|
4
5
|
|
|
@@ -57,3 +58,47 @@ export function filterDecks(
|
|
|
57
58
|
if (!q) return ids;
|
|
58
59
|
return ids.filter((id) => id.toLowerCase().includes(q) || titles[id]?.toLowerCase().includes(q));
|
|
59
60
|
}
|
|
61
|
+
|
|
62
|
+
/** The decks every workspace ships with, in the order the home page puts them first. */
|
|
63
|
+
export function builtInOrder(locale: string): readonly string[] {
|
|
64
|
+
const chinese = locale === 'zh-CN' || locale === 'zh-TW';
|
|
65
|
+
return chinese
|
|
66
|
+
? [
|
|
67
|
+
'lemonriver-intro',
|
|
68
|
+
'getting-started-zh',
|
|
69
|
+
'try-lemonriver',
|
|
70
|
+
'lemonriver-intro-en',
|
|
71
|
+
'getting-started',
|
|
72
|
+
]
|
|
73
|
+
: [
|
|
74
|
+
'lemonriver-intro-en',
|
|
75
|
+
'getting-started',
|
|
76
|
+
'try-lemonriver',
|
|
77
|
+
'lemonriver-intro',
|
|
78
|
+
'getting-started-zh',
|
|
79
|
+
];
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The decks' order on the home page. The built-ins lead the all-slides view
|
|
84
|
+
* under the default "newest first" sort, so a new workspace opens on the
|
|
85
|
+
* introduction instead of on whatever was written last; any other sort, the
|
|
86
|
+
* folder views and search results keep the plain key order.
|
|
87
|
+
*/
|
|
88
|
+
export function homeOrder(
|
|
89
|
+
ids: readonly string[],
|
|
90
|
+
opts: { sort: SortKey; all: boolean; searching: boolean; locale: string },
|
|
91
|
+
titleOf: (id: string) => string,
|
|
92
|
+
createdAt: Record<string, number>,
|
|
93
|
+
): string[] {
|
|
94
|
+
const sorted = sortDecks([...ids], opts.sort, titleOf, createdAt);
|
|
95
|
+
if (!opts.all || opts.searching || opts.sort !== 'created-desc') return sorted;
|
|
96
|
+
const rest = new Set(sorted);
|
|
97
|
+
const pinned: string[] = [];
|
|
98
|
+
for (const id of builtInOrder(opts.locale)) {
|
|
99
|
+
if (!BUILT_IN_SLIDES.has(id) || !rest.has(id)) continue;
|
|
100
|
+
pinned.push(id);
|
|
101
|
+
rest.delete(id);
|
|
102
|
+
}
|
|
103
|
+
return [...pinned, ...sorted.filter((id) => rest.has(id))];
|
|
104
|
+
}
|
|
@@ -5,11 +5,10 @@ export type DeckTimes = Record<
|
|
|
5
5
|
{ modifiedAt: number; occasion: string | null; template?: string | null }
|
|
6
6
|
>;
|
|
7
7
|
|
|
8
|
-
/** When each deck was last saved
|
|
8
|
+
/** When each deck was last saved, so the home page can sort and the start card can tick. */
|
|
9
9
|
export function useDeckTimes(): DeckTimes {
|
|
10
10
|
const [times, setTimes] = useState<DeckTimes>({});
|
|
11
11
|
useEffect(() => {
|
|
12
|
-
if (!import.meta.env.DEV) return;
|
|
13
12
|
let cancelled = false;
|
|
14
13
|
const load = () =>
|
|
15
14
|
fetch('/__lr/decks')
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { Locale } from '../../../locale/types';
|
|
2
|
+
|
|
3
|
+
function matchTag(tag: string): Locale['id'] | null {
|
|
4
|
+
const t = tag.trim().toLowerCase().replace(/_/g, '-');
|
|
5
|
+
if (
|
|
6
|
+
t === 'zh' ||
|
|
7
|
+
t.startsWith('zh-hans') ||
|
|
8
|
+
t === 'zh-cn' ||
|
|
9
|
+
t.startsWith('zh-cn-') ||
|
|
10
|
+
t === 'zh-sg' ||
|
|
11
|
+
t.startsWith('zh-sg-')
|
|
12
|
+
) {
|
|
13
|
+
return 'zh-CN';
|
|
14
|
+
}
|
|
15
|
+
if (
|
|
16
|
+
t.startsWith('zh-hant') ||
|
|
17
|
+
t === 'zh-tw' ||
|
|
18
|
+
t.startsWith('zh-tw-') ||
|
|
19
|
+
t === 'zh-hk' ||
|
|
20
|
+
t.startsWith('zh-hk-') ||
|
|
21
|
+
t === 'zh-mo' ||
|
|
22
|
+
t.startsWith('zh-mo-')
|
|
23
|
+
) {
|
|
24
|
+
return 'zh-TW';
|
|
25
|
+
}
|
|
26
|
+
const base = t.split('-')[0];
|
|
27
|
+
if (base === 'ja') return 'ja';
|
|
28
|
+
if (base === 'es') return 'es';
|
|
29
|
+
return null;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/** The UI language for a browser language list, English when none matches. */
|
|
33
|
+
export function systemLocaleId(languages: readonly string[] | undefined): Locale['id'] {
|
|
34
|
+
for (const tag of languages ?? []) {
|
|
35
|
+
const id = matchTag(tag);
|
|
36
|
+
if (id) return id;
|
|
37
|
+
}
|
|
38
|
+
return 'en';
|
|
39
|
+
}
|
|
@@ -0,0 +1,154 @@
|
|
|
1
|
+
export type ScreenLike = {
|
|
2
|
+
isCurrent?: boolean;
|
|
3
|
+
left: number;
|
|
4
|
+
top: number;
|
|
5
|
+
width: number;
|
|
6
|
+
height: number;
|
|
7
|
+
availLeft: number;
|
|
8
|
+
availTop: number;
|
|
9
|
+
availWidth: number;
|
|
10
|
+
availHeight: number;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
type ScreenDetailsLike = {
|
|
14
|
+
screens: ScreenLike[];
|
|
15
|
+
currentScreen: ScreenLike;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
type WindowManagementApi = {
|
|
19
|
+
getScreenDetails?: () => Promise<ScreenDetailsLike>;
|
|
20
|
+
screen: ScreenLike & { isExtended?: boolean };
|
|
21
|
+
open: (url: string, name: string, features: string) => unknown;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export type PresenterPopupNotice = { slideId: string; blocked: boolean };
|
|
25
|
+
|
|
26
|
+
function windowApi(): WindowManagementApi | null {
|
|
27
|
+
return typeof window === 'undefined' ? null : (window as unknown as WindowManagementApi);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export function pickAudienceScreen<T extends ScreenLike>(
|
|
31
|
+
screens: readonly T[],
|
|
32
|
+
current: T | null | undefined,
|
|
33
|
+
): T | null {
|
|
34
|
+
const others = screens.filter((screen) => screen !== current && !screen.isCurrent);
|
|
35
|
+
if (others.length === 0) return null;
|
|
36
|
+
return others.reduce((largest, screen) =>
|
|
37
|
+
screen.width * screen.height > largest.width * largest.height ? screen : largest,
|
|
38
|
+
);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function supportsAudienceScreens(): boolean {
|
|
42
|
+
const win = windowApi();
|
|
43
|
+
return Boolean(win?.getScreenDetails) && win?.screen?.isExtended === true;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
export async function resolveAudienceScreen(): Promise<ScreenLike | null> {
|
|
47
|
+
const win = windowApi();
|
|
48
|
+
if (!win?.getScreenDetails) return null;
|
|
49
|
+
try {
|
|
50
|
+
const details = await win.getScreenDetails();
|
|
51
|
+
return pickAudienceScreen(details.screens, details.currentScreen);
|
|
52
|
+
} catch {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
let audienceScreen: ScreenLike | null = null;
|
|
58
|
+
let audienceSlideId: string | null = null;
|
|
59
|
+
let presenterOpened = false;
|
|
60
|
+
|
|
61
|
+
export function clearAudiencePresentation(): void {
|
|
62
|
+
audienceScreen = null;
|
|
63
|
+
audienceSlideId = null;
|
|
64
|
+
presenterOpened = false;
|
|
65
|
+
setPopupNotice(null);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// The browser only grants one user-activated action per click. Entering
|
|
69
|
+
// fullscreen has to happen first and the presenter window only once it
|
|
70
|
+
// resolved, or the popup consumes the click and fullscreen is refused.
|
|
71
|
+
export function requestPresentFullscreen(el: Element): void {
|
|
72
|
+
const options = audienceScreen
|
|
73
|
+
? ({ screen: audienceScreen } as unknown as FullscreenOptions)
|
|
74
|
+
: undefined;
|
|
75
|
+
const request = el.requestFullscreen?.(options);
|
|
76
|
+
if (!request) return;
|
|
77
|
+
request.then(
|
|
78
|
+
() => openAudiencePresenter(),
|
|
79
|
+
() => {},
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function openAudiencePresenter(): void {
|
|
84
|
+
const slideId = audienceSlideId;
|
|
85
|
+
const win = windowApi();
|
|
86
|
+
if (!audienceScreen || !slideId || presenterOpened || !win) return;
|
|
87
|
+
presenterOpened = true;
|
|
88
|
+
const blocked = !openPresenterPopup(slideId, win.screen);
|
|
89
|
+
setPopupNotice({ slideId, blocked });
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
export function openPresenterPopup(slideId: string, current: ScreenLike): boolean {
|
|
93
|
+
const win = windowApi();
|
|
94
|
+
if (!win) return false;
|
|
95
|
+
const url = `${import.meta.env.BASE_URL}s/${encodeURIComponent(slideId)}/presenter`;
|
|
96
|
+
const left = Math.round(current.availLeft ?? current.left);
|
|
97
|
+
const top = Math.round(current.availTop ?? current.top);
|
|
98
|
+
const width = Math.round(current.availWidth || current.width);
|
|
99
|
+
const height = Math.round(current.availHeight || current.height);
|
|
100
|
+
const features = `popup,left=${left},top=${top},width=${width},height=${height}`;
|
|
101
|
+
try {
|
|
102
|
+
return win.open(url, `open-slide-presenter-${slideId}`, features) !== null;
|
|
103
|
+
} catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
let popupNotice: PresenterPopupNotice | null = null;
|
|
109
|
+
const popupListeners = new Set<() => void>();
|
|
110
|
+
|
|
111
|
+
function setPopupNotice(next: PresenterPopupNotice | null) {
|
|
112
|
+
popupNotice = next;
|
|
113
|
+
for (const listener of popupListeners) listener();
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
export function subscribePresenterPopupNotice(listener: () => void): () => void {
|
|
117
|
+
popupListeners.add(listener);
|
|
118
|
+
return () => {
|
|
119
|
+
popupListeners.delete(listener);
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export function getPresenterPopupNotice(): PresenterPopupNotice | null {
|
|
124
|
+
return popupNotice;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function retryPresenterPopup(slideId: string): void {
|
|
128
|
+
const win = windowApi();
|
|
129
|
+
if (!win) return;
|
|
130
|
+
if (openPresenterPopup(slideId, win.screen)) setPopupNotice({ slideId, blocked: false });
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
export async function startAudiencePresentation(
|
|
134
|
+
slideId: string | undefined,
|
|
135
|
+
enter: () => void,
|
|
136
|
+
): Promise<void> {
|
|
137
|
+
audienceScreen = null;
|
|
138
|
+
audienceSlideId = null;
|
|
139
|
+
presenterOpened = false;
|
|
140
|
+
const win = windowApi();
|
|
141
|
+
if (!slideId || !win || !supportsAudienceScreens()) {
|
|
142
|
+
enter();
|
|
143
|
+
return;
|
|
144
|
+
}
|
|
145
|
+
const audience = await resolveAudienceScreen();
|
|
146
|
+
if (!audience) {
|
|
147
|
+
enter();
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
audienceScreen = audience;
|
|
151
|
+
audienceSlideId = slideId;
|
|
152
|
+
setPopupNotice({ slideId, blocked: false });
|
|
153
|
+
enter();
|
|
154
|
+
}
|