@lemonriver/core 0.7.0 → 1.0.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/README.md +3 -1
- package/dist/{build-CKwrex8y.js → build-CiT4CNey.js} +1 -1
- package/dist/cli/bin.js +12 -5
- package/dist/client-DpO_eR9X.js +57 -0
- package/dist/{config-B1_gk0sy.js → config-BI3VRI2n.js} +7186 -5275
- package/dist/{dev-DZ2Yzl2p.js → dev-DpzBn_sf.js} +3 -3
- package/dist/index.js +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/mcp-CjYDzcJa.js +262 -0
- package/dist/{preview-hMDcuHfP.js → preview-Dro8hl5_.js} +2 -2
- package/dist/{update-CMRxtTc9.js → update-b1dSg_FW.js} +17 -17
- package/dist/vite/index.js +1 -1
- package/dist/{zh-tw-DcrDeKxr.js → zh-tw-BhYyMx0-.js} +40 -40
- package/package.json +1 -1
- package/skills/slide-authoring/SKILL.md +2 -0
- package/src/app/lemonriver/agent-providers/section.tsx +13 -4
- package/src/app/lemonriver/backup/client.ts +177 -0
- package/src/app/lemonriver/backup/guide.test.ts +45 -0
- package/src/app/lemonriver/backup/guide.ts +138 -0
- package/src/app/lemonriver/backup/model.test.ts +96 -0
- package/src/app/lemonriver/backup/model.ts +255 -0
- package/src/app/lemonriver/backup/places.test.ts +154 -0
- package/src/app/lemonriver/backup/places.ts +74 -0
- package/src/app/lemonriver/board/blocks/snapshot.ts +10 -2
- package/src/app/lemonriver/board/self-check-runner.tsx +60 -15
- package/src/app/lemonriver/board/use-self-check.ts +1 -1
- package/src/app/lemonriver/chrome/app-chrome.tsx +6 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +9 -1
- package/src/app/lemonriver/features.test.ts +5 -0
- package/src/app/lemonriver/features.ts +11 -1
- package/src/app/lemonriver/guide/guide-prompt.tsx +89 -0
- package/src/app/lemonriver/guide/state.ts +29 -0
- package/src/app/lemonriver/guide/use-guide.ts +17 -0
- package/src/app/lemonriver/help/help-page.tsx +267 -0
- package/src/app/lemonriver/help/model.test.ts +179 -0
- package/src/app/lemonriver/help/model.ts +105 -0
- package/src/app/lemonriver/home/home-page.tsx +25 -7
- package/src/app/lemonriver/mcp/respond.ts +47 -0
- package/src/app/lemonriver/mcp/screenshot.tsx +155 -0
- package/src/app/lemonriver/mcp/self-check.tsx +65 -0
- package/src/app/lemonriver/outline/describe-page.tsx +3 -1
- package/src/app/lemonriver/routes.test.tsx +4 -2
- package/src/app/lemonriver/routes.tsx +2 -0
- package/src/app/lemonriver/settings/backup-restore-dialog.tsx +525 -0
- package/src/app/lemonriver/settings/backup-section.tsx +489 -0
- package/src/app/lemonriver/settings/settings-page.tsx +25 -3
- package/src/app/lemonriver/share/client.ts +6 -0
- package/src/app/lemonriver/share/freeze.ts +13 -5
- package/src/app/lemonriver/share/import-dialog.tsx +14 -0
- package/src/app/lemonriver/share/paths.test.ts +41 -0
- package/src/app/lemonriver/share/paths.ts +45 -11
- package/src/app/lemonriver/share/share-dialog.tsx +54 -1
- package/src/app/lemonriver/text/en.ts +742 -4
- package/src/app/lemonriver/text/es.ts +97 -4
- package/src/app/lemonriver/text/ja.ts +94 -4
- package/src/app/lemonriver/text/types.ts +103 -1
- package/src/app/lemonriver/text/zh-cn.ts +711 -3
- package/src/app/lemonriver/text/zh-tw.ts +711 -3
- package/src/app/lemonriver/update/beta-badge.tsx +3 -0
- package/src/app/lemonriver/update/version.test.ts +14 -0
- package/src/app/lemonriver/update/version.ts +5 -0
- package/src/locale/en.ts +8 -8
- package/src/locale/es.ts +10 -8
- package/src/locale/ja.ts +9 -8
- package/src/locale/zh-cn.ts +9 -8
- package/src/locale/zh-tw.ts +9 -8
|
@@ -0,0 +1,489 @@
|
|
|
1
|
+
import { Cloud, Folder, HardDrive } from 'lucide-react';
|
|
2
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
3
|
+
import { Link } from 'react-router-dom';
|
|
4
|
+
import { Button } from '@/components/ui/button';
|
|
5
|
+
import { Dialog, DialogContent, DialogHeader, DialogTitle } from '@/components/ui/dialog';
|
|
6
|
+
import { Progress } from '@/components/ui/progress';
|
|
7
|
+
import { format, useLocale } from '@/lib/use-locale';
|
|
8
|
+
import { useAgentPrefs } from '../agent-prefs/use-prefs';
|
|
9
|
+
import {
|
|
10
|
+
backupPlaces,
|
|
11
|
+
backupSettings,
|
|
12
|
+
pendingRestoreJob,
|
|
13
|
+
pickBackupFolder,
|
|
14
|
+
revealBackup,
|
|
15
|
+
saveBackupSettings,
|
|
16
|
+
sendPrefs,
|
|
17
|
+
startBackup,
|
|
18
|
+
waitForJob,
|
|
19
|
+
} from '../backup/client';
|
|
20
|
+
import { formatSize } from '../backup/guide';
|
|
21
|
+
import {
|
|
22
|
+
BACKUP_TOO_LARGE,
|
|
23
|
+
type BackupJob,
|
|
24
|
+
type BackupPlace,
|
|
25
|
+
type BackupSettings,
|
|
26
|
+
KEEP_CHOICES,
|
|
27
|
+
PREFS_KEYS,
|
|
28
|
+
type PrefsSnapshot,
|
|
29
|
+
} from '../backup/model';
|
|
30
|
+
import { placeLabel } from '../backup/places';
|
|
31
|
+
import { helpAnchorForPlace } from '../help/model';
|
|
32
|
+
import { useLrText } from '../text';
|
|
33
|
+
import { useReduceMotionSetting } from '../theme/motion';
|
|
34
|
+
import { useTheme } from '../theme/use-theme';
|
|
35
|
+
import { BackupRestoreDialog } from './backup-restore-dialog';
|
|
36
|
+
|
|
37
|
+
const SYNC_DELAY = 2000;
|
|
38
|
+
|
|
39
|
+
function snapshotPrefs(): PrefsSnapshot {
|
|
40
|
+
const out: PrefsSnapshot = {};
|
|
41
|
+
try {
|
|
42
|
+
for (const key of PREFS_KEYS) {
|
|
43
|
+
const value = localStorage.getItem(key);
|
|
44
|
+
if (value !== null) out[key] = value;
|
|
45
|
+
}
|
|
46
|
+
} catch {}
|
|
47
|
+
return out;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
function pad(value: number): string {
|
|
51
|
+
return String(value).padStart(2, '0');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function when(at: number, localeId: string): string {
|
|
55
|
+
const date = new Date(at);
|
|
56
|
+
const now = new Date();
|
|
57
|
+
const yesterday = new Date(now);
|
|
58
|
+
yesterday.setDate(now.getDate() - 1);
|
|
59
|
+
const time = `${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
60
|
+
if (date.toDateString() === now.toDateString()) {
|
|
61
|
+
const word =
|
|
62
|
+
localeId === 'ja' ? '今日' : localeId === 'es' ? 'Hoy' : localeId === 'en' ? 'Today' : '今天';
|
|
63
|
+
return `${word} ${time}`;
|
|
64
|
+
}
|
|
65
|
+
if (date.toDateString() === yesterday.toDateString()) {
|
|
66
|
+
const word =
|
|
67
|
+
localeId === 'ja'
|
|
68
|
+
? '昨日'
|
|
69
|
+
: localeId === 'es'
|
|
70
|
+
? 'Ayer'
|
|
71
|
+
: localeId === 'en'
|
|
72
|
+
? 'Yesterday'
|
|
73
|
+
: '昨天';
|
|
74
|
+
return `${word} ${time}`;
|
|
75
|
+
}
|
|
76
|
+
if (localeId === 'en' || localeId === 'es' || localeId === 'ja') {
|
|
77
|
+
const months = [
|
|
78
|
+
'Jan',
|
|
79
|
+
'Feb',
|
|
80
|
+
'Mar',
|
|
81
|
+
'Apr',
|
|
82
|
+
'May',
|
|
83
|
+
'Jun',
|
|
84
|
+
'Jul',
|
|
85
|
+
'Aug',
|
|
86
|
+
'Sep',
|
|
87
|
+
'Oct',
|
|
88
|
+
'Nov',
|
|
89
|
+
'Dec',
|
|
90
|
+
];
|
|
91
|
+
return `${months[date.getMonth()]} ${date.getDate()}, ${time}`;
|
|
92
|
+
}
|
|
93
|
+
return `${date.getMonth() + 1}月${date.getDate()}日 ${time}`;
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
function elideMiddle(text: string, max: number): string {
|
|
97
|
+
if (text.length <= max) return text;
|
|
98
|
+
const half = Math.floor((max - 1) / 2);
|
|
99
|
+
return `${text.slice(0, half)}…${text.slice(text.length - half)}`;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function PlaceIcon({ kind }: { kind: BackupPlace['kind'] }) {
|
|
103
|
+
const className = 'size-4 shrink-0 text-muted-foreground';
|
|
104
|
+
if (kind === 'local') return <HardDrive className={className} />;
|
|
105
|
+
if (kind === 'other') return <Folder className={className} />;
|
|
106
|
+
return <Cloud className={className} />;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
export function BackupSection() {
|
|
110
|
+
const locale = useLocale();
|
|
111
|
+
const lr = useLrText();
|
|
112
|
+
const b = lr.backup;
|
|
113
|
+
const theme = useTheme();
|
|
114
|
+
const reduceMotion = useReduceMotionSetting();
|
|
115
|
+
const agentPrefs = useAgentPrefs();
|
|
116
|
+
const agentStamp = JSON.stringify(agentPrefs);
|
|
117
|
+
|
|
118
|
+
const [settings, setSettings] = useState<BackupSettings | null>(null);
|
|
119
|
+
const [dir, setDir] = useState<string | null>(null);
|
|
120
|
+
const [places, setPlaces] = useState<BackupPlace[]>([]);
|
|
121
|
+
const [pickerOpen, setPickerOpen] = useState(false);
|
|
122
|
+
const [pasteMode, setPasteMode] = useState(false);
|
|
123
|
+
const [manualPath, setManualPath] = useState('');
|
|
124
|
+
const [notice, setNotice] = useState('');
|
|
125
|
+
const [job, setJob] = useState<BackupJob | null>(null);
|
|
126
|
+
const [restoreOpen, setRestoreOpen] = useState(false);
|
|
127
|
+
|
|
128
|
+
const running = job?.state === 'running';
|
|
129
|
+
|
|
130
|
+
const load = useCallback(async () => {
|
|
131
|
+
const [info, found] = await Promise.all([
|
|
132
|
+
backupSettings().catch(() => null),
|
|
133
|
+
backupPlaces().catch(() => [] as BackupPlace[]),
|
|
134
|
+
]);
|
|
135
|
+
if (info) {
|
|
136
|
+
setSettings(info.settings);
|
|
137
|
+
setDir(info.dir);
|
|
138
|
+
}
|
|
139
|
+
setPlaces(found);
|
|
140
|
+
}, []);
|
|
141
|
+
|
|
142
|
+
useEffect(() => {
|
|
143
|
+
void load();
|
|
144
|
+
}, [load]);
|
|
145
|
+
|
|
146
|
+
useEffect(() => {
|
|
147
|
+
// A restore that reloaded the page leaves its job behind; show how it went.
|
|
148
|
+
if (pendingRestoreJob()) setRestoreOpen(true);
|
|
149
|
+
}, []);
|
|
150
|
+
|
|
151
|
+
useEffect(() => {
|
|
152
|
+
void sendPrefs(snapshotPrefs());
|
|
153
|
+
let timer: ReturnType<typeof setTimeout> | null = null;
|
|
154
|
+
const schedule = () => {
|
|
155
|
+
if (timer) clearTimeout(timer);
|
|
156
|
+
timer = setTimeout(() => void sendPrefs(snapshotPrefs()), SYNC_DELAY);
|
|
157
|
+
};
|
|
158
|
+
window.addEventListener('storage', schedule);
|
|
159
|
+
return () => {
|
|
160
|
+
window.removeEventListener('storage', schedule);
|
|
161
|
+
if (timer) clearTimeout(timer);
|
|
162
|
+
};
|
|
163
|
+
}, []);
|
|
164
|
+
|
|
165
|
+
// biome-ignore lint/correctness/useExhaustiveDependencies: these values are watched only to trigger a re-sync
|
|
166
|
+
useEffect(() => {
|
|
167
|
+
const timer = setTimeout(() => void sendPrefs(snapshotPrefs()), SYNC_DELAY);
|
|
168
|
+
return () => clearTimeout(timer);
|
|
169
|
+
}, [theme.theme, reduceMotion, agentStamp, locale.id]);
|
|
170
|
+
|
|
171
|
+
const patch = async (value: { folder?: string | null; auto?: boolean; keep?: number }) => {
|
|
172
|
+
setNotice('');
|
|
173
|
+
const saved = await saveBackupSettings(value);
|
|
174
|
+
if (!saved.ok) {
|
|
175
|
+
setNotice(saved.code === 'no-permission' ? b.permissionDenied : b.badFolder);
|
|
176
|
+
return false;
|
|
177
|
+
}
|
|
178
|
+
setSettings(saved.settings);
|
|
179
|
+
await load();
|
|
180
|
+
return true;
|
|
181
|
+
};
|
|
182
|
+
|
|
183
|
+
const choosePlace = async (folder: string) => {
|
|
184
|
+
if (await patch({ folder })) {
|
|
185
|
+
setPickerOpen(false);
|
|
186
|
+
setPasteMode(false);
|
|
187
|
+
setManualPath('');
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const chooseOther = async () => {
|
|
192
|
+
setNotice('');
|
|
193
|
+
try {
|
|
194
|
+
const picked = await pickBackupFolder(locale.id);
|
|
195
|
+
if ('path' in picked) {
|
|
196
|
+
await choosePlace(picked.path);
|
|
197
|
+
return;
|
|
198
|
+
}
|
|
199
|
+
if ('unsupported' in picked) setPasteMode(true);
|
|
200
|
+
} catch {
|
|
201
|
+
setNotice(b.chooseFailed);
|
|
202
|
+
setPasteMode(true);
|
|
203
|
+
}
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
const failureText = (error: string | null | undefined): string => {
|
|
207
|
+
if (error === BACKUP_TOO_LARGE) return b.tooLarge;
|
|
208
|
+
return /EACCES|EPERM/.test(error ?? '')
|
|
209
|
+
? b.permissionDenied
|
|
210
|
+
: format(b.lastFailed, { error: error ?? b.failed });
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
const runNow = async () => {
|
|
214
|
+
setNotice('');
|
|
215
|
+
try {
|
|
216
|
+
const started = await startBackup(locale.id);
|
|
217
|
+
const finished = await waitForJob(started.jobId, setJob);
|
|
218
|
+
if (finished.state === 'failed') {
|
|
219
|
+
setNotice(failureText(finished.error));
|
|
220
|
+
}
|
|
221
|
+
await load();
|
|
222
|
+
setJob(null);
|
|
223
|
+
} catch (err) {
|
|
224
|
+
setNotice(String((err as Error)?.message ?? err));
|
|
225
|
+
}
|
|
226
|
+
};
|
|
227
|
+
|
|
228
|
+
const last = settings?.last ?? null;
|
|
229
|
+
const keep = settings?.keep ?? 7;
|
|
230
|
+
const currentPlace = settings?.folder
|
|
231
|
+
? places.find((place) => place.path === settings.folder)
|
|
232
|
+
: undefined;
|
|
233
|
+
|
|
234
|
+
return (
|
|
235
|
+
<section
|
|
236
|
+
data-lr-backup
|
|
237
|
+
className="mt-5 rounded-[16px] border border-border bg-card px-6 py-5 shadow-[var(--lr-shadow-1)]"
|
|
238
|
+
>
|
|
239
|
+
<h2 className="text-[16px] font-semibold">{b.title}</h2>
|
|
240
|
+
<p className="mt-1 mb-2 text-[14px] text-muted-foreground">{b.hint}</p>
|
|
241
|
+
|
|
242
|
+
<div className="mt-3 flex items-start gap-4 border-t border-border pt-3">
|
|
243
|
+
<div className="min-w-0 flex-1">
|
|
244
|
+
<p className="text-[14px] font-semibold">{b.location}</p>
|
|
245
|
+
<p
|
|
246
|
+
data-lr-backup-location
|
|
247
|
+
title={dir ?? ''}
|
|
248
|
+
className="truncate text-[12px] text-muted-foreground"
|
|
249
|
+
>
|
|
250
|
+
{dir ? elideMiddle(currentPlace ? placeLabel(currentPlace, lr) : dir, 70) : b.notSet}
|
|
251
|
+
</p>
|
|
252
|
+
</div>
|
|
253
|
+
<Button
|
|
254
|
+
type="button"
|
|
255
|
+
variant="outline"
|
|
256
|
+
size="sm"
|
|
257
|
+
data-lr-backup-change
|
|
258
|
+
onClick={() => setPickerOpen(true)}
|
|
259
|
+
>
|
|
260
|
+
{b.change}
|
|
261
|
+
</Button>
|
|
262
|
+
</div>
|
|
263
|
+
|
|
264
|
+
<div className="mt-3 flex items-center gap-4 border-t border-border pt-3">
|
|
265
|
+
<div className="min-w-0 flex-1">
|
|
266
|
+
<p className="text-[14px] font-semibold">{b.auto}</p>
|
|
267
|
+
<p className="text-[12px] text-muted-foreground">{b.autoHint}</p>
|
|
268
|
+
</div>
|
|
269
|
+
<button
|
|
270
|
+
type="button"
|
|
271
|
+
role="switch"
|
|
272
|
+
aria-checked={settings?.auto === true}
|
|
273
|
+
aria-label={b.auto}
|
|
274
|
+
data-lr-backup-auto
|
|
275
|
+
disabled={!settings?.folder}
|
|
276
|
+
onClick={() => void patch({ auto: !(settings?.auto === true) })}
|
|
277
|
+
className="lr-switch outline-none focus-visible:ring-2 focus-visible:ring-ring/40 disabled:opacity-40"
|
|
278
|
+
/>
|
|
279
|
+
</div>
|
|
280
|
+
|
|
281
|
+
<div className="mt-3 flex items-center gap-4 border-t border-border pt-3">
|
|
282
|
+
<div className="min-w-0 flex-1">
|
|
283
|
+
<p className="text-[14px] font-semibold">{b.keep}</p>
|
|
284
|
+
{last?.ok && last.size > 0 && (
|
|
285
|
+
<p data-lr-backup-keep-size className="text-[12px] text-muted-foreground">
|
|
286
|
+
{format(b.keepSize, {
|
|
287
|
+
size: formatSize(last.size),
|
|
288
|
+
n: keep,
|
|
289
|
+
total: formatSize(last.size * keep),
|
|
290
|
+
})}
|
|
291
|
+
</p>
|
|
292
|
+
)}
|
|
293
|
+
</div>
|
|
294
|
+
<select
|
|
295
|
+
data-lr-backup-keep
|
|
296
|
+
value={keep}
|
|
297
|
+
onChange={(event) => void patch({ keep: Number(event.target.value) })}
|
|
298
|
+
className="rounded-[8px] border border-border bg-card px-2 py-1 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
299
|
+
>
|
|
300
|
+
{KEEP_CHOICES.map((value) => (
|
|
301
|
+
<option key={value} value={value}>
|
|
302
|
+
{format(b.keepOption, { n: value })}
|
|
303
|
+
</option>
|
|
304
|
+
))}
|
|
305
|
+
</select>
|
|
306
|
+
</div>
|
|
307
|
+
|
|
308
|
+
<div className="mt-3 border-t border-border pt-3">
|
|
309
|
+
<div className="flex flex-wrap items-center gap-3">
|
|
310
|
+
<Button
|
|
311
|
+
type="button"
|
|
312
|
+
size="sm"
|
|
313
|
+
data-lr-backup-run
|
|
314
|
+
disabled={!settings?.folder || running}
|
|
315
|
+
onClick={() => void runNow()}
|
|
316
|
+
>
|
|
317
|
+
{b.runNow}
|
|
318
|
+
</Button>
|
|
319
|
+
|
|
320
|
+
{running && (
|
|
321
|
+
<div className="min-w-[180px] flex-1" data-lr-backup-progress>
|
|
322
|
+
<p className="mb-1 text-[12px] text-muted-foreground">
|
|
323
|
+
{format(b.running, { done: job?.done ?? 0, total: job?.total ?? 0 })}
|
|
324
|
+
</p>
|
|
325
|
+
<Progress value={job && job.total > 0 ? (job.done / job.total) * 100 : 0} />
|
|
326
|
+
</div>
|
|
327
|
+
)}
|
|
328
|
+
|
|
329
|
+
{!running && last && (
|
|
330
|
+
<p
|
|
331
|
+
data-lr-backup-last
|
|
332
|
+
className={
|
|
333
|
+
last.ok ? 'text-[12.5px] text-muted-foreground' : 'text-[12.5px] text-destructive'
|
|
334
|
+
}
|
|
335
|
+
>
|
|
336
|
+
{last.ok
|
|
337
|
+
? format(b.lastOk, { when: when(last.at, locale.id), size: formatSize(last.size) })
|
|
338
|
+
: failureText(last.error)}
|
|
339
|
+
</p>
|
|
340
|
+
)}
|
|
341
|
+
{!running && !last && (
|
|
342
|
+
<p data-lr-backup-last className="text-[12.5px] text-muted-foreground">
|
|
343
|
+
{b.never}
|
|
344
|
+
</p>
|
|
345
|
+
)}
|
|
346
|
+
|
|
347
|
+
{!running && last?.ok && (
|
|
348
|
+
<button
|
|
349
|
+
type="button"
|
|
350
|
+
data-lr-backup-reveal
|
|
351
|
+
onClick={() => void revealBackup(last.path)}
|
|
352
|
+
className="rounded text-[12.5px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
353
|
+
>
|
|
354
|
+
{b.reveal}
|
|
355
|
+
</button>
|
|
356
|
+
)}
|
|
357
|
+
</div>
|
|
358
|
+
|
|
359
|
+
{notice !== '' && (
|
|
360
|
+
<p data-lr-backup-notice className="mt-2 text-[12.5px] text-destructive">
|
|
361
|
+
{notice}
|
|
362
|
+
</p>
|
|
363
|
+
)}
|
|
364
|
+
|
|
365
|
+
{!running && last && !last.ok && (
|
|
366
|
+
<Link
|
|
367
|
+
to="/help#cloud-faq"
|
|
368
|
+
data-lr-backup-faq
|
|
369
|
+
className="mt-1 inline-block text-[12.5px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
370
|
+
>
|
|
371
|
+
{b.faqLink}
|
|
372
|
+
</Link>
|
|
373
|
+
)}
|
|
374
|
+
|
|
375
|
+
{!running && last && last.warnings.length > 0 && (
|
|
376
|
+
<div data-lr-backup-warnings className="mt-1 text-[12.5px] text-muted-foreground">
|
|
377
|
+
<p>{format(b.notBackedUp, { n: last.warnings.length })}</p>
|
|
378
|
+
<ul className="mt-1 list-disc break-all pl-4">
|
|
379
|
+
{last.warnings.slice(0, 5).map((warning) => (
|
|
380
|
+
<li key={warning}>{warning}</li>
|
|
381
|
+
))}
|
|
382
|
+
</ul>
|
|
383
|
+
{last.warnings.length > 5 && (
|
|
384
|
+
<details className="mt-1">
|
|
385
|
+
<summary className="cursor-pointer">+{last.warnings.length - 5}</summary>
|
|
386
|
+
<ul className="mt-1 list-disc break-all pl-4">
|
|
387
|
+
{last.warnings.slice(5).map((warning) => (
|
|
388
|
+
<li key={warning}>{warning}</li>
|
|
389
|
+
))}
|
|
390
|
+
</ul>
|
|
391
|
+
</details>
|
|
392
|
+
)}
|
|
393
|
+
</div>
|
|
394
|
+
)}
|
|
395
|
+
|
|
396
|
+
<div className="mt-3 border-t border-border pt-3">
|
|
397
|
+
<Button
|
|
398
|
+
type="button"
|
|
399
|
+
variant="outline"
|
|
400
|
+
size="sm"
|
|
401
|
+
data-lr-backup-restore
|
|
402
|
+
onClick={() => setRestoreOpen(true)}
|
|
403
|
+
>
|
|
404
|
+
{b.restore}
|
|
405
|
+
</Button>
|
|
406
|
+
</div>
|
|
407
|
+
</div>
|
|
408
|
+
|
|
409
|
+
<Dialog open={pickerOpen} onOpenChange={setPickerOpen}>
|
|
410
|
+
<DialogContent className="sm:max-w-[520px]" data-lr-backup-places>
|
|
411
|
+
<DialogHeader>
|
|
412
|
+
<DialogTitle>{b.chooseTitle}</DialogTitle>
|
|
413
|
+
</DialogHeader>
|
|
414
|
+
<div className="flex flex-col gap-1">
|
|
415
|
+
{places.map((place) => (
|
|
416
|
+
<div
|
|
417
|
+
key={place.path}
|
|
418
|
+
className="flex items-center gap-2 rounded-[10px] px-1 py-1.5 hover:bg-muted/40"
|
|
419
|
+
>
|
|
420
|
+
<button
|
|
421
|
+
type="button"
|
|
422
|
+
data-lr-backup-place={place.kind}
|
|
423
|
+
onClick={() => void choosePlace(place.path)}
|
|
424
|
+
className="flex min-w-0 flex-1 items-center gap-2 text-left outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
425
|
+
>
|
|
426
|
+
<PlaceIcon kind={place.kind} />
|
|
427
|
+
<span className="min-w-0 flex-1">
|
|
428
|
+
<span className="block truncate text-[13.5px] font-medium">
|
|
429
|
+
{placeLabel(place, lr)}
|
|
430
|
+
</span>
|
|
431
|
+
<span className="block truncate text-[11.5px] text-muted-foreground">
|
|
432
|
+
{elideMiddle(place.path, 60)}
|
|
433
|
+
</span>
|
|
434
|
+
</span>
|
|
435
|
+
</button>
|
|
436
|
+
<Link
|
|
437
|
+
to={`/help#${helpAnchorForPlace(place.kind)}`}
|
|
438
|
+
data-lr-backup-help={place.kind}
|
|
439
|
+
className="shrink-0 text-[12px] text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
440
|
+
>
|
|
441
|
+
{b.howToSetUp}
|
|
442
|
+
</Link>
|
|
443
|
+
</div>
|
|
444
|
+
))}
|
|
445
|
+
|
|
446
|
+
{pasteMode ? (
|
|
447
|
+
<div className="mt-2 flex flex-col gap-1.5">
|
|
448
|
+
<p className="text-[12px] text-muted-foreground">{b.pastePath}</p>
|
|
449
|
+
<div className="flex gap-1.5">
|
|
450
|
+
<input
|
|
451
|
+
data-lr-backup-folder-path
|
|
452
|
+
value={manualPath}
|
|
453
|
+
onChange={(event) => setManualPath(event.target.value)}
|
|
454
|
+
placeholder={b.pathPlaceholder}
|
|
455
|
+
className="min-w-0 flex-1 rounded-[8px] border border-border bg-card px-2.5 py-1.5 text-[13px] outline-none focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
456
|
+
/>
|
|
457
|
+
<Button
|
|
458
|
+
type="button"
|
|
459
|
+
variant="outline"
|
|
460
|
+
size="sm"
|
|
461
|
+
disabled={manualPath.trim() === ''}
|
|
462
|
+
onClick={() => void choosePlace(manualPath.trim())}
|
|
463
|
+
>
|
|
464
|
+
{b.change}
|
|
465
|
+
</Button>
|
|
466
|
+
</div>
|
|
467
|
+
</div>
|
|
468
|
+
) : (
|
|
469
|
+
<button
|
|
470
|
+
type="button"
|
|
471
|
+
data-lr-backup-choose-other
|
|
472
|
+
onClick={() => void chooseOther()}
|
|
473
|
+
className="mt-1 self-start rounded text-[13px] text-muted-foreground underline-offset-2 outline-none hover:text-foreground hover:underline focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
474
|
+
>
|
|
475
|
+
{b.chooseOther}
|
|
476
|
+
</button>
|
|
477
|
+
)}
|
|
478
|
+
|
|
479
|
+
{notice !== '' && <p className="mt-1 text-[12.5px] text-destructive">{notice}</p>}
|
|
480
|
+
|
|
481
|
+
<p className="mt-2 text-[11.5px] leading-snug text-muted-foreground">{b.cloudHint}</p>
|
|
482
|
+
</div>
|
|
483
|
+
</DialogContent>
|
|
484
|
+
</Dialog>
|
|
485
|
+
|
|
486
|
+
<BackupRestoreDialog open={restoreOpen} onOpenChange={setRestoreOpen} />
|
|
487
|
+
</section>
|
|
488
|
+
);
|
|
489
|
+
}
|
|
@@ -7,11 +7,13 @@ import type { AgentPrefs } from '../agent-prefs/prefs';
|
|
|
7
7
|
import { updateAgentPrefs, useAgentPrefs } from '../agent-prefs/use-prefs';
|
|
8
8
|
import { AgentProvidersSection } from '../agent-providers/section';
|
|
9
9
|
import { HelperMascot, type HelperRole } from '../brand/mascot';
|
|
10
|
-
import {
|
|
10
|
+
import { isFeatureEnabled } from '../features';
|
|
11
|
+
import { GUIDE_SEEN_KEY } from '../guide/state';
|
|
11
12
|
import { useLrText } from '../text';
|
|
12
13
|
import { setReduceMotionSetting, useReduceMotionSetting } from '../theme/motion';
|
|
13
14
|
import { LR_THEME_CHOICES, type LrThemeChoice } from '../theme/themes';
|
|
14
15
|
import { useTheme } from '../theme/use-theme';
|
|
16
|
+
import { BackupSection } from './backup-section';
|
|
15
17
|
|
|
16
18
|
const SWATCH: Record<LrThemeChoice, { bg: string; fg: string }> = {
|
|
17
19
|
system: { bg: 'linear-gradient(90deg,#fafbf5 50%,#111412 50%)', fg: '#13240f' },
|
|
@@ -42,9 +44,9 @@ export function SettingsPage() {
|
|
|
42
44
|
|
|
43
45
|
function replayOnboarding() {
|
|
44
46
|
try {
|
|
45
|
-
localStorage.removeItem(
|
|
47
|
+
localStorage.removeItem(GUIDE_SEEN_KEY);
|
|
46
48
|
} catch {}
|
|
47
|
-
navigate('/
|
|
49
|
+
navigate('/');
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
const helpers: {
|
|
@@ -167,6 +169,8 @@ export function SettingsPage() {
|
|
|
167
169
|
|
|
168
170
|
{import.meta.env.DEV && <AgentProvidersSection />}
|
|
169
171
|
|
|
172
|
+
{isFeatureEnabled('backup') && <BackupSection />}
|
|
173
|
+
|
|
170
174
|
{import.meta.env.DEV && (
|
|
171
175
|
<section
|
|
172
176
|
data-lr-agent-prefs
|
|
@@ -254,6 +258,24 @@ export function SettingsPage() {
|
|
|
254
258
|
</div>
|
|
255
259
|
</section>
|
|
256
260
|
)}
|
|
261
|
+
|
|
262
|
+
{isFeatureEnabled('help') && (
|
|
263
|
+
<section
|
|
264
|
+
data-lr-settings-help
|
|
265
|
+
className="mt-5 rounded-[16px] border border-border bg-card px-6 py-5 shadow-[var(--lr-shadow-1)]"
|
|
266
|
+
>
|
|
267
|
+
<h2 className="text-[16px] font-semibold">{lr.settings.helpTitle}</h2>
|
|
268
|
+
<p className="mt-1 text-[14px] text-muted-foreground">{lr.settings.helpHint}</p>
|
|
269
|
+
<button
|
|
270
|
+
type="button"
|
|
271
|
+
data-lr-settings-help-open
|
|
272
|
+
onClick={() => navigate('/help')}
|
|
273
|
+
className="mt-3 rounded-[10px] border border-border bg-card px-3 py-1.5 text-[13px] font-medium outline-none hover:border-[var(--lr-text-3)] focus-visible:ring-2 focus-visible:ring-ring/40"
|
|
274
|
+
>
|
|
275
|
+
{lr.settings.helpOpen}
|
|
276
|
+
</button>
|
|
277
|
+
</section>
|
|
278
|
+
)}
|
|
257
279
|
</div>
|
|
258
280
|
);
|
|
259
281
|
}
|
|
@@ -10,6 +10,8 @@ export type PackResponse = {
|
|
|
10
10
|
name: string;
|
|
11
11
|
size: number;
|
|
12
12
|
warnings: string[];
|
|
13
|
+
skipped: string[];
|
|
14
|
+
workFiles: number;
|
|
13
15
|
};
|
|
14
16
|
|
|
15
17
|
export type PackFailure = { ok: false; error: string; paths?: string[] };
|
|
@@ -70,6 +72,8 @@ export async function packShare(input: {
|
|
|
70
72
|
name?: string;
|
|
71
73
|
size?: number;
|
|
72
74
|
warnings?: string[];
|
|
75
|
+
skipped?: string[];
|
|
76
|
+
workFiles?: number;
|
|
73
77
|
error?: string;
|
|
74
78
|
paths?: string[];
|
|
75
79
|
}>(res);
|
|
@@ -82,6 +86,8 @@ export async function packShare(input: {
|
|
|
82
86
|
name: typeof data.name === 'string' ? data.name : '',
|
|
83
87
|
size: typeof data.size === 'number' ? data.size : 0,
|
|
84
88
|
warnings: Array.isArray(data.warnings) ? data.warnings : [],
|
|
89
|
+
skipped: Array.isArray(data.skipped) ? data.skipped : [],
|
|
90
|
+
workFiles: typeof data.workFiles === 'number' ? data.workFiles : 0,
|
|
85
91
|
};
|
|
86
92
|
}
|
|
87
93
|
|
|
@@ -34,18 +34,26 @@ export function canvasJpeg(canvas: HTMLCanvasElement, quality: number): Promise<
|
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
export async function canvasThumb(
|
|
37
|
+
export function canvasScaled(
|
|
39
38
|
source: HTMLCanvasElement,
|
|
40
39
|
width: number,
|
|
41
40
|
height: number,
|
|
42
|
-
|
|
43
|
-
): Promise<Uint8Array> {
|
|
41
|
+
): HTMLCanvasElement {
|
|
44
42
|
const canvas = document.createElement('canvas');
|
|
45
43
|
canvas.width = width;
|
|
46
44
|
canvas.height = height;
|
|
47
45
|
const ctx = canvas.getContext('2d');
|
|
48
46
|
if (!ctx) throw new Error('canvas is unavailable');
|
|
49
47
|
ctx.drawImage(source, 0, 0, width, height);
|
|
50
|
-
return
|
|
48
|
+
return canvas;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Scales the full-size capture down instead of drawing the page a second time. */
|
|
52
|
+
export async function canvasThumb(
|
|
53
|
+
source: HTMLCanvasElement,
|
|
54
|
+
width: number,
|
|
55
|
+
height: number,
|
|
56
|
+
quality: number,
|
|
57
|
+
): Promise<Uint8Array> {
|
|
58
|
+
return canvasJpeg(canvasScaled(source, width, height), quality);
|
|
51
59
|
}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ChevronLeft, ChevronRight, ShieldAlert } from 'lucide-react';
|
|
2
2
|
import { useState } from 'react';
|
|
3
3
|
import { createPortal } from 'react-dom';
|
|
4
|
+
import { Link } from 'react-router-dom';
|
|
4
5
|
import { Button } from '@/components/ui/button';
|
|
5
6
|
import {
|
|
6
7
|
Dialog,
|
|
@@ -11,6 +12,7 @@ import {
|
|
|
11
12
|
} from '@/components/ui/dialog';
|
|
12
13
|
import { format, useLocale } from '@/lib/use-locale';
|
|
13
14
|
import { cn } from '@/lib/utils';
|
|
15
|
+
import { isFeatureEnabled } from '../features';
|
|
14
16
|
import { savePendingToast } from '../feedback/pending-toast';
|
|
15
17
|
import { useLrText } from '../text';
|
|
16
18
|
import { type InspectDeck, type InspectOk, importPackages, thumbUrl } from './client';
|
|
@@ -359,6 +361,18 @@ export function ImportDialog({
|
|
|
359
361
|
|
|
360
362
|
{error !== '' && <p className="text-[13px] text-destructive">{error}</p>}
|
|
361
363
|
|
|
364
|
+
{isFeatureEnabled('help') && (
|
|
365
|
+
<p className="text-[12.5px]">
|
|
366
|
+
<Link
|
|
367
|
+
to="/help#import"
|
|
368
|
+
data-lr-import-help
|
|
369
|
+
className="text-muted-foreground underline-offset-2 hover:text-foreground hover:underline"
|
|
370
|
+
>
|
|
371
|
+
{lr.share.importHelp}
|
|
372
|
+
</Link>
|
|
373
|
+
</p>
|
|
374
|
+
)}
|
|
375
|
+
|
|
362
376
|
<DialogFooter>
|
|
363
377
|
<Button type="button" variant="outline" size="sm" onClick={onClose} disabled={busy}>
|
|
364
378
|
{t.common.cancel}
|
|
@@ -72,4 +72,45 @@ describe('package paths', () => {
|
|
|
72
72
|
expect(isJunkPath('LemonRiver-files/.DS_Store')).toBe(true);
|
|
73
73
|
expect(isJunkPath('LemonRiver-files/slides/q3/index.tsx')).toBe(false);
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it('lets only a backup carry global assets and the workspace file', () => {
|
|
77
|
+
expect(packagePathProblem('assets/logo.png', 'backup')).toBeNull();
|
|
78
|
+
expect(packagePathProblem('assets/team/photo.jpg', 'backup')).toBeNull();
|
|
79
|
+
expect(packagePathProblem('workspace.json', 'backup')).toBeNull();
|
|
80
|
+
expect(packagePathProblem('assets/logo.png')?.code).toBe('bad-path');
|
|
81
|
+
expect(packagePathProblem('workspace.json')?.code).toBe('bad-path');
|
|
82
|
+
expect(packagePathProblem('assets/../x.png', 'backup')?.code).toBe('bad-path');
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
it('carries a workspace file whatever it is named', () => {
|
|
86
|
+
expect(packagePathProblem('assets/setup.sh', 'backup')).toBeNull();
|
|
87
|
+
expect(packagePathProblem('slides/q3/_backups/x.tar.gz', 'backup')).toBeNull();
|
|
88
|
+
expect(packagePathProblem('slides/q3/.playwright-cli/a.log', 'backup')).toBeNull();
|
|
89
|
+
expect(packagePathProblem('themes/t-assets/a.png', 'backup')).toBeNull();
|
|
90
|
+
expect(packagePathProblem('themes/t-assets/kit/a.png', 'backup')).toBeNull();
|
|
91
|
+
expect(packagePathProblem('slides/q3/package.json', 'backup')?.code).toBe('blocked-file');
|
|
92
|
+
expect(packagePathProblem('slides/q3/kit/pnpm-lock.yaml', 'backup')?.code).toBe('blocked-file');
|
|
93
|
+
expect(packagePathProblem('slides/q3/node_modules/x.js', 'backup')?.code).toBe('blocked-file');
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
it('widens what a shared deck may carry', () => {
|
|
97
|
+
for (const name of [
|
|
98
|
+
'slides/q3/subtitles.vtt',
|
|
99
|
+
'slides/q3/subtitles.srt',
|
|
100
|
+
'slides/q3/diagram.excalidraw',
|
|
101
|
+
'slides/q3/data.yaml',
|
|
102
|
+
'slides/q3/data.yml',
|
|
103
|
+
'slides/q3/data.xml',
|
|
104
|
+
'slides/q3/data.tsv',
|
|
105
|
+
'slides/q3/loader.lottie',
|
|
106
|
+
'slides/q3/loader.riv',
|
|
107
|
+
'slides/q3/model.glb',
|
|
108
|
+
'slides/q3/model.gltf',
|
|
109
|
+
]) {
|
|
110
|
+
expect(packagePathProblem(name), name).toBeNull();
|
|
111
|
+
}
|
|
112
|
+
expect(packagePathProblem('themes/aero-assets/bg.png')).toBeNull();
|
|
113
|
+
expect(packagePathProblem('themes/aero-assets/kit/bg.png')?.code).toBe('bad-path');
|
|
114
|
+
expect(packagePathProblem('themes/aero-assets/run.sh')?.code).toBe('blocked-file');
|
|
115
|
+
});
|
|
75
116
|
});
|