@lemonriver/core 1.1.0 → 1.3.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.
Files changed (98) hide show
  1. package/dist/{build-Dm7gVRhb.js → build-CSkdswfd.js} +1 -1
  2. package/dist/cli/bin.js +5 -5
  3. package/dist/{config-CubOIzrs.js → config-C5-myPY6.js} +129 -2
  4. package/dist/{dev-DgLeXPqp.js → dev-DHtYH8sw.js} +2 -2
  5. package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
  6. package/dist/{preview-CxXQpPk5.js → preview-C1B6-umF.js} +1 -1
  7. package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
  8. package/dist/vite/index.js +1 -1
  9. package/package.json +5 -2
  10. package/release-notes.json +33 -0
  11. package/src/app/components/player.tsx +6 -1
  12. package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
  13. package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
  14. package/src/app/lemonriver/feedback/dialog.tsx +222 -0
  15. package/src/app/lemonriver/feedback/export.ts +21 -2
  16. package/src/app/lemonriver/feedback/first-success.ts +30 -0
  17. package/src/app/lemonriver/feedback/install.ts +18 -0
  18. package/src/app/lemonriver/feedback/model.ts +88 -0
  19. package/src/app/lemonriver/help/help-page.tsx +16 -1
  20. package/src/app/lemonriver/links.ts +16 -0
  21. package/src/app/lemonriver/present/dual-screen.ts +154 -0
  22. package/src/app/lemonriver/present/presenter-blocked-hint.tsx +28 -0
  23. package/src/app/lemonriver/present/wake-lock.ts +74 -0
  24. package/src/app/lemonriver/settings/backup-section.tsx +13 -0
  25. package/src/app/lemonriver/settings/settings-page.tsx +20 -0
  26. package/src/app/lemonriver/share/editor-share.tsx +6 -3
  27. package/src/app/lemonriver/share/share-dialog.tsx +2 -0
  28. package/src/app/lemonriver/text/en.ts +48 -0
  29. package/src/app/lemonriver/text/es.ts +45 -0
  30. package/src/app/lemonriver/text/ja.ts +44 -0
  31. package/src/app/lemonriver/text/types.ts +48 -0
  32. package/src/app/lemonriver/text/zh-cn.ts +48 -0
  33. package/src/app/lemonriver/text/zh-tw.ts +48 -0
  34. package/src/app/lemonriver/theme/pages.ts +4 -0
  35. package/src/app/lemonriver/update/release-notes.ts +22 -0
  36. package/src/app/lemonriver/update/update-prompt.tsx +28 -4
  37. package/src/app/routes/presenter.tsx +2 -0
  38. package/src/app/routes/slide.tsx +14 -1
  39. package/src/app/components/note-markdown.test.tsx +0 -42
  40. package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
  41. package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
  42. package/src/app/lemonriver/backup/guide.test.ts +0 -45
  43. package/src/app/lemonriver/backup/model.test.ts +0 -108
  44. package/src/app/lemonriver/backup/places.test.ts +0 -154
  45. package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
  46. package/src/app/lemonriver/board/layout.test.ts +0 -245
  47. package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
  48. package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
  49. package/src/app/lemonriver/board/model/cards.test.ts +0 -332
  50. package/src/app/lemonriver/board/model/changes.test.ts +0 -244
  51. package/src/app/lemonriver/board/model/filter.test.ts +0 -50
  52. package/src/app/lemonriver/board/model/history.test.ts +0 -71
  53. package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
  54. package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
  55. package/src/app/lemonriver/board/model/structure.test.ts +0 -350
  56. package/src/app/lemonriver/board/model/timing.test.ts +0 -113
  57. package/src/app/lemonriver/features.test.ts +0 -49
  58. package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
  59. package/src/app/lemonriver/feedback/upload.test.ts +0 -26
  60. package/src/app/lemonriver/help/model.test.ts +0 -179
  61. package/src/app/lemonriver/home/brief.test.ts +0 -38
  62. package/src/app/lemonriver/home/drafts.test.ts +0 -23
  63. package/src/app/lemonriver/home/sorting.test.ts +0 -24
  64. package/src/app/lemonriver/home/time.test.ts +0 -33
  65. package/src/app/lemonriver/outline/files.test.ts +0 -90
  66. package/src/app/lemonriver/outline/model.test.ts +0 -751
  67. package/src/app/lemonriver/public-links.test.ts +0 -32
  68. package/src/app/lemonriver/routes.test.tsx +0 -54
  69. package/src/app/lemonriver/share/codes.test.ts +0 -49
  70. package/src/app/lemonriver/share/compare.test.ts +0 -199
  71. package/src/app/lemonriver/share/folder.test.ts +0 -42
  72. package/src/app/lemonriver/share/guide.test.ts +0 -78
  73. package/src/app/lemonriver/share/naming.test.ts +0 -70
  74. package/src/app/lemonriver/share/paths.test.ts +0 -116
  75. package/src/app/lemonriver/share/pdf.test.ts +0 -79
  76. package/src/app/lemonriver/templates/knobs.test.ts +0 -62
  77. package/src/app/lemonriver/templates/model.test.ts +0 -175
  78. package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
  79. package/src/app/lemonriver/templates/recommend.test.ts +0 -71
  80. package/src/app/lemonriver/text/text.test.ts +0 -90
  81. package/src/app/lemonriver/theme/pages.test.ts +0 -74
  82. package/src/app/lemonriver/theme/themes.test.ts +0 -18
  83. package/src/app/lemonriver/trash/api.test.ts +0 -19
  84. package/src/app/lemonriver/update/prompt.test.ts +0 -84
  85. package/src/app/lemonriver/update/version.test.ts +0 -14
  86. package/src/app/lib/asset-filter.test.ts +0 -176
  87. package/src/app/lib/inspector/fiber.test.ts +0 -154
  88. package/src/app/lib/inspector/geometry.test.ts +0 -324
  89. package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
  90. package/src/app/lib/note-markdown.test.ts +0 -147
  91. package/src/app/lib/pptx/css.test.ts +0 -205
  92. package/src/app/lib/pptx/ooxml.test.ts +0 -199
  93. package/src/app/lib/pptx/text-lines.test.ts +0 -82
  94. package/src/app/lib/print-ready.test.ts +0 -32
  95. package/src/app/lib/sdk.test.ts +0 -13
  96. package/src/app/lib/transition.test.ts +0 -31
  97. package/src/app/lib/use-document-title.test.ts +0 -14
  98. package/src/app/lib/utils.test.ts +0 -49
@@ -1,32 +0,0 @@
1
- import { readdirSync, readFileSync, statSync } from 'node:fs';
2
- import path from 'node:path';
3
- import { fileURLToPath } from 'node:url';
4
- import { describe, expect, it } from 'vitest';
5
-
6
- const ROOT = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '../../../../..');
7
-
8
- // The main repository is private now, so anything a user can open has to point
9
- // at lemonriver-slide instead.
10
- const PRIVATE_REPO = /(?:github\.com|raw\.githubusercontent\.com)\/SegawaBeer\/lemonriver\//;
11
-
12
- function sourceFiles(dir: string): string[] {
13
- return readdirSync(dir).flatMap((name) => {
14
- const full = path.join(dir, name);
15
- if (statSync(full).isDirectory()) return sourceFiles(full);
16
- if (/\.test\.tsx?$/.test(name)) return [];
17
- return /\.(?:ts|tsx|css|html|json)$/.test(name) ? [full] : [];
18
- });
19
- }
20
-
21
- describe('public links', () => {
22
- it('never point at the private repository', () => {
23
- const files = [
24
- ...sourceFiles(path.join(ROOT, 'packages/core/src')),
25
- path.join(ROOT, 'packages/core/README.md'),
26
- path.join(ROOT, 'packages/cli/README.md'),
27
- ];
28
- expect(files.length).toBeGreaterThan(0);
29
- const offenders = files.filter((file) => PRIVATE_REPO.test(readFileSync(file, 'utf8')));
30
- expect(offenders.map((file) => path.relative(ROOT, file))).toEqual([]);
31
- });
32
- });
@@ -1,54 +0,0 @@
1
- import type { ReactElement, ReactNode } from 'react';
2
- import { describe, expect, it, vi } from 'vitest';
3
-
4
- vi.mock('./features', () => ({ isFeatureEnabled: vi.fn(() => true) }));
5
- vi.mock('./chrome/not-found', () => ({ NotFound: () => null }));
6
- vi.mock('./home/home-page', () => ({ LemonRiverHome: () => null }));
7
- vi.mock('./help/help-page', () => ({ HelpPage: () => null }));
8
- vi.mock('./settings/settings-page', () => ({ SettingsPage: () => null }));
9
- vi.mock('./trash/trash-page', () => ({ TrashPage: () => null }));
10
- vi.mock('./update/lazy-page', () => ({
11
- LazyPage: ({ children }: { children: ReactNode }) => children,
12
- }));
13
-
14
- import { isFeatureEnabled } from './features';
15
- import { lemonRiverRoutes, lemonRiverShellRoutes } from './routes';
16
-
17
- const paths = (routes: unknown[]) =>
18
- routes.filter(Boolean).map((r) => (r as ReactElement<{ path: string }>).props.path);
19
-
20
- describe('lemonRiverRoutes', () => {
21
- it('adds the board, the outline, the template demo and the not-found page', () => {
22
- expect(paths(lemonRiverRoutes())).toEqual([
23
- '/s/:slideId/board',
24
- '/s/:slideId/outline',
25
- '/template-demo/:templateId',
26
- '*',
27
- ]);
28
- });
29
-
30
- it('drops the pages whose feature is off', () => {
31
- vi.mocked(isFeatureEnabled).mockReturnValue(false);
32
- expect(paths(lemonRiverRoutes())).toEqual(['*']);
33
- vi.mocked(isFeatureEnabled).mockReturnValue(true);
34
- });
35
- });
36
-
37
- describe('lemonRiverShellRoutes', () => {
38
- it('puts our home and the guided flow first, then settings, help, templates and trash', () => {
39
- expect(paths(lemonRiverShellRoutes())).toEqual([
40
- '/',
41
- '/new',
42
- '/settings',
43
- '/help',
44
- '/templates',
45
- '/trash',
46
- ]);
47
- });
48
-
49
- it('leaves out the pages whose feature is off', () => {
50
- vi.mocked(isFeatureEnabled).mockImplementation((id) => id !== 'trash' && id !== 'templates');
51
- expect(paths(lemonRiverShellRoutes())).toEqual(['/', '/new', '/settings', '/help']);
52
- vi.mocked(isFeatureEnabled).mockReturnValue(true);
53
- });
54
- });
@@ -1,49 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { en } from '../text/en';
3
- import { es } from '../text/es';
4
- import { ja } from '../text/ja';
5
- import { zhCN } from '../text/zh-cn';
6
- import { zhTW } from '../text/zh-tw';
7
- import { shareErrorText } from './codes';
8
- import type { ShareCode } from './model';
9
-
10
- const CODES: ShareCode[] = [
11
- 'not-a-package',
12
- 'bad-manifest',
13
- 'newer-version',
14
- 'bad-path',
15
- 'blocked-file',
16
- 'checksum',
17
- 'missing-file',
18
- 'extra-file',
19
- 'too-large',
20
- 'too-many-files',
21
- ];
22
-
23
- describe('shareErrorText', () => {
24
- it('has a sentence for every code in every language', () => {
25
- for (const text of [zhCN, zhTW, en, ja, es]) {
26
- for (const code of CODES) {
27
- const message = shareErrorText(text.share.errors, code, '', text.share.unknownVersion);
28
- expect(message, code).not.toContain('{');
29
- expect(message.length, code).toBeGreaterThan(4);
30
- }
31
- }
32
- });
33
-
34
- it('names the version that made a package we cannot read yet', () => {
35
- expect(shareErrorText(en.share.errors, 'newer-version', '9.9.9')).toBe(
36
- 'This package was made by a newer LemonRiver (9.9.9). Update first, then import.',
37
- );
38
- expect(shareErrorText(zhCN.share.errors, 'newer-version', '9.9.9')).toBe(
39
- '这个包是用更新的 LemonRiver(9.9.9)做的,先更新再导入。',
40
- );
41
- expect(
42
- shareErrorText(zhCN.share.errors, 'newer-version', '', zhCN.share.unknownVersion),
43
- ).toContain('未知版本');
44
- });
45
-
46
- it('treats a code it has never heard of as a broken package', () => {
47
- expect(shareErrorText(en.share.errors, 'something-new')).toBe(en.share.errors.badManifest);
48
- });
49
- });
@@ -1,199 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { compareDeck } from './compare';
3
-
4
- const encoder = new TextEncoder();
5
- const bytes = (text: string) => encoder.encode(text);
6
-
7
- const BASE = `import type { Page } from '@lemonriver/core';
8
-
9
- export const meta = { title: 'Q3' };
10
-
11
- const Cover: Page = () => <div>Cover</div>;
12
- const Body: Page = () => <div>Body</div>;
13
-
14
- export const notes = ['first', 'second'];
15
-
16
- export default [Cover, Body] satisfies Page[];
17
- `;
18
-
19
- function deck(source: string, extra: Record<string, string | Uint8Array> = {}) {
20
- const files: Record<string, Uint8Array> = { 'index.tsx': bytes(source) };
21
- for (const [path, data] of Object.entries(extra)) {
22
- files[path] = typeof data === 'string' ? bytes(data) : data;
23
- }
24
- return files;
25
- }
26
-
27
- const statuses = (changes: ReturnType<typeof compareDeck>) =>
28
- changes.pages.map((page) => [page.n, page.status]);
29
-
30
- describe('compareDeck', () => {
31
- it('reports nothing when the two copies are identical, reformatting included', () => {
32
- const reformatted = BASE.replace(/\n\n/g, '\n\n\n')
33
- .replace('<div>Cover</div>', '<div> Cover </div>')
34
- .replace("title: 'Q3'", "title: 'Q3'");
35
- const changes = compareDeck(deck(BASE), deck(reformatted));
36
- expect(changes.readable).toBe(true);
37
- expect(statuses(changes)).toEqual([
38
- [1, 'same'],
39
- [2, 'same'],
40
- ]);
41
- expect(changes.shared).toBe(false);
42
- expect(changes.assets).toEqual({ added: [], changed: [], removed: [] });
43
- });
44
-
45
- it('marks a page whose code changed', () => {
46
- const changes = compareDeck(deck(BASE), deck(BASE.replace('Body</div>', 'Body, v2</div>')));
47
- expect(statuses(changes)).toEqual([
48
- [1, 'same'],
49
- [2, 'changed'],
50
- ]);
51
- expect(changes.pages[1]?.name).toBe('Body');
52
- expect(changes.shared).toBe(false);
53
- });
54
-
55
- it('marks a page that only moved', () => {
56
- const moved = BASE.replace('export default [Cover, Body]', 'export default [Body, Cover]');
57
- const changes = compareDeck(deck(BASE), deck(moved));
58
- expect(statuses(changes)).toEqual([
59
- [1, 'moved'],
60
- [2, 'moved'],
61
- ]);
62
- });
63
-
64
- it('marks an added page with its place in the package', () => {
65
- const extra = BASE.replace(
66
- 'const Body: Page = () => <div>Body</div>;',
67
- 'const Body: Page = () => <div>Body</div>;\nconst More: Page = () => <div>More</div>;',
68
- ).replace('[Cover, Body]', '[Cover, Body, More]');
69
- const changes = compareDeck(deck(BASE), deck(extra));
70
- expect(statuses(changes)).toEqual([
71
- [1, 'same'],
72
- [2, 'same'],
73
- [3, 'added'],
74
- ]);
75
- expect(changes.pages[2]?.name).toBe('More');
76
- });
77
-
78
- it('marks a page this machine has and the package does not', () => {
79
- const fewer = BASE.replace('const Body: Page = () => <div>Body</div>;\n', '').replace(
80
- '[Cover, Body]',
81
- '[Cover]',
82
- );
83
- const changes = compareDeck(deck(BASE), deck(fewer));
84
- expect(statuses(changes)).toEqual([
85
- [1, 'same'],
86
- [2, 'removed'],
87
- ]);
88
- });
89
-
90
- it('counts a page whose only change is its speaker note', () => {
91
- const changes = compareDeck(
92
- deck(BASE),
93
- deck(BASE.replace("['first', 'second']", "['first', 'second, rewritten']")),
94
- );
95
- expect(statuses(changes)).toEqual([
96
- [1, 'same'],
97
- [2, 'changed'],
98
- ]);
99
- expect(changes.pages[1]?.notes).toBe(true);
100
- expect(changes.pages[0]?.notes).toBe(false);
101
- expect(changes.shared).toBe(false);
102
- });
103
-
104
- it('does not treat a title change as shared code', () => {
105
- const changes = compareDeck(deck(BASE), deck(BASE.replace("title: 'Q3'", "title: 'Q3 FY26'")));
106
- expect(changes.shared).toBe(false);
107
- expect(statuses(changes)).toEqual([
108
- [1, 'same'],
109
- [2, 'same'],
110
- ]);
111
- });
112
-
113
- it('keeps exported pages out of the shared check', () => {
114
- const exported = BASE.replace('const Cover: Page', 'export const Cover: Page').replace(
115
- 'const Body: Page',
116
- 'export const Body: Page',
117
- );
118
- const changes = compareDeck(
119
- deck(exported),
120
- deck(exported.replace('Body</div>', 'Body v2</div>')),
121
- );
122
- expect(statuses(changes)).toEqual([
123
- [1, 'same'],
124
- [2, 'changed'],
125
- ]);
126
- expect(changes.shared).toBe(false);
127
- });
128
-
129
- it('flags a component both pages use as shared', () => {
130
- const source = `import type { Page } from '@lemonriver/core';
131
-
132
- export const meta = { title: 'Q3' };
133
-
134
- const Card = () => <p>card</p>;
135
-
136
- const Cover: Page = () => <div><Card />Cover</div>;
137
- const Body: Page = () => <div><Card />Body</div>;
138
-
139
- export const notes = ['first', 'second'];
140
-
141
- export default [Cover, Body] satisfies Page[];
142
- `;
143
- const changes = compareDeck(deck(source), deck(source.replace('card</p>', 'card v2</p>')));
144
- expect(changes.shared).toBe(true);
145
- expect(statuses(changes)).toEqual([
146
- [1, 'same'],
147
- [2, 'same'],
148
- ]);
149
- });
150
-
151
- it('ignores how packing rewrote an asset reference', () => {
152
- const local = deck(
153
- BASE.replace('Cover</div>', 'Cover<Logo /></div>').replace(
154
- 'const Cover',
155
- "import logo from '@assets/logo.png';\n\nconst Cover",
156
- ),
157
- );
158
- const packaged = deck(
159
- BASE.replace('Cover</div>', 'Cover<Logo /></div>').replace(
160
- 'const Cover',
161
- "import logo from './assets/logo.png';\n\nconst Cover",
162
- ),
163
- { 'assets/logo.png': bytes('PNG') },
164
- );
165
- const changes = compareDeck(local, packaged);
166
- expect(statuses(changes)).toEqual([
167
- [1, 'same'],
168
- [2, 'same'],
169
- ]);
170
- expect(changes.shared).toBe(false);
171
- expect(changes.assets.added).toEqual(['logo.png']);
172
- });
173
-
174
- it('lists assets that were added, changed and removed', () => {
175
- const local = deck(BASE, { 'assets/a.png': 'old', 'assets/gone.png': 'x' });
176
- const packaged = deck(BASE, { 'assets/a.png': 'new', 'assets/b.png': 'y' });
177
- const changes = compareDeck(local, packaged);
178
- expect(changes.assets).toEqual({ added: ['b.png'], changed: ['a.png'], removed: ['gone.png'] });
179
- });
180
-
181
- it('pairs inline pages by position', () => {
182
- const inline = (b: string) =>
183
- `import type { Page } from '@lemonriver/core';\n\nexport default [() => <div>${b}</div>, () => <div>Y</div>] satisfies Page[];\n`;
184
- const changes = compareDeck(deck(inline('X')), deck(inline('X2')));
185
- expect(statuses(changes)).toEqual([
186
- [1, 'changed'],
187
- [2, 'same'],
188
- ]);
189
- expect(changes.pages[0]?.name).toBeNull();
190
- });
191
-
192
- it('says when the file cannot be read page by page', () => {
193
- const spread = `import type { Page } from '@lemonriver/core';\nconst rest: Page[] = [];\nexport default [() => <div>X</div>, ...rest];\n`;
194
- const changes = compareDeck(deck(BASE), deck(spread));
195
- expect(changes.readable).toBe(false);
196
- expect(changes.pages).toEqual([]);
197
- expect(changes.shared).toBe(true);
198
- });
199
- });
@@ -1,42 +0,0 @@
1
- import { unzipSync } from 'fflate';
2
- import { describe, expect, it } from 'vitest';
3
- import { zipDroppedFolder } from './folder';
4
-
5
- const bytes = (text: string) => new TextEncoder().encode(text);
6
-
7
- function names(zip: Uint8Array): string[] {
8
- return Object.keys(unzipSync(zip)).sort();
9
- }
10
-
11
- describe('zipDroppedFolder', () => {
12
- it('keeps the folder paths exactly as they were', async () => {
13
- const zip = await zipDroppedFolder([
14
- { path: 'LemonRiver-files/manifest.json', bytes: bytes('{}') },
15
- { path: 'LemonRiver-files/slides/alpha/index.tsx', bytes: bytes('export default [];') },
16
- ]);
17
- expect(names(zip)).toEqual([
18
- 'LemonRiver-files/manifest.json',
19
- 'LemonRiver-files/slides/alpha/index.tsx',
20
- ]);
21
- });
22
-
23
- it('drops what Safari and Finder leave behind', async () => {
24
- const zip = await zipDroppedFolder([
25
- { path: 'LemonRiver-files/manifest.json', bytes: bytes('{}') },
26
- { path: 'LemonRiver-files/.DS_Store', bytes: bytes('junk') },
27
- { path: 'LemonRiver-files/slides/alpha/.DS_Store', bytes: bytes('junk') },
28
- { path: '__MACOSX/LemonRiver-files/manifest.json', bytes: bytes('junk') },
29
- { path: 'LemonRiver-files/__MACOSX/._index.tsx', bytes: bytes('junk') },
30
- ]);
31
- expect(names(zip)).toEqual(['LemonRiver-files/manifest.json']);
32
- });
33
-
34
- it('ignores paths that climb out or are empty', async () => {
35
- const zip = await zipDroppedFolder([
36
- { path: '../outside.txt', bytes: bytes('x') },
37
- { path: '', bytes: bytes('x') },
38
- { path: './LemonRiver-files/manifest.json', bytes: bytes('{}') },
39
- ]);
40
- expect(names(zip)).toEqual(['LemonRiver-files/manifest.json']);
41
- });
42
- });
@@ -1,78 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { buildGuideHtml, guideFileName, guideLocaleFor } from './guide';
3
-
4
- const base = {
5
- pages: 12,
6
- appVersion: '0.6.0',
7
- createdAt: new Date(2026, 10, 1).getTime(),
8
- };
9
-
10
- const decoder = new TextDecoder();
11
-
12
- describe('buildGuideHtml', () => {
13
- it('writes the page in the interface language, English for the rest', () => {
14
- const zh = buildGuideHtml({ ...base, title: '季度报告', locale: 'zh-CN' });
15
- const tw = buildGuideHtml({ ...base, title: '季度報告', locale: 'zh-TW' });
16
- const en = buildGuideHtml({ ...base, title: 'Q3 report', locale: 'en' });
17
- expect(zh).toContain('怎么打开「季度报告」');
18
- expect(zh).toContain('12 页 · 用 LemonRiver 0.6.0 制作 · 2026年11月1日');
19
- expect(tw).toContain('怎麼打開「季度報告」');
20
- expect(tw).toContain('12 頁 · 用 LemonRiver 0.6.0 製作');
21
- expect(en).toContain('How to open “Q3 report”');
22
- expect(en).toContain('12 pages · Made with LemonRiver 0.6.0 · November 1, 2026');
23
- expect(guideLocaleFor('ja')).toBe('en');
24
- expect(guideLocaleFor('es')).toBe('en');
25
- expect(guideLocaleFor('zh-TW')).toBe('zh-TW');
26
- });
27
-
28
- it('escapes whatever the deck calls itself', () => {
29
- const html = buildGuideHtml({
30
- ...base,
31
- title: '<script>alert("x")</script> A & B',
32
- locale: 'en',
33
- });
34
- expect(html).not.toContain('<script');
35
- expect(html).toContain('&lt;script&gt;alert(&quot;x&quot;)&lt;/script&gt; A &amp; B');
36
- expect(html).toContain('<title>How to open “&lt;script&gt;');
37
- expect(html).not.toContain('How to open “<script>');
38
- });
39
-
40
- it('has no script tag, and links only to the release list', () => {
41
- for (const locale of ['zh-CN', 'zh-TW', 'en'] as const) {
42
- const html = buildGuideHtml({ ...base, title: 'Deck', locale });
43
- expect(html.toLowerCase()).not.toContain('<script');
44
- expect(html).toContain('https://github.com/SegawaBeer/lemonriver-slide/releases/latest');
45
- const hrefs = [...html.matchAll(/href="([^"]+)"/g)].map((match) => match[1]);
46
- for (const href of hrefs) {
47
- expect(href).toBe('https://github.com/SegawaBeer/lemonriver-slide/releases/latest');
48
- }
49
- expect(html).toContain('LemonRiver-0.6.0-arm64.dmg');
50
- }
51
- });
52
-
53
- it('says the package has no PDF when it does not', () => {
54
- const withPdf = buildGuideHtml({ ...base, title: '季度报告', locale: 'zh-CN' });
55
- const without = buildGuideHtml({
56
- ...base,
57
- title: '季度报告',
58
- locale: 'zh-CN',
59
- hasPdf: false,
60
- });
61
- expect(withPdf).toContain('打开同一个文件夹里的「季度报告.pdf」就行');
62
- expect(without).not.toContain('季度报告.pdf');
63
- expect(without).toContain('这个包没有附带 PDF,装好 LemonRiver 后导入就能看。');
64
- });
65
-
66
- it('names the file the way the system would show it', () => {
67
- expect(guideFileName('zh-CN')).toBe('怎么打开.html');
68
- expect(guideFileName('zh-TW')).toBe('怎麼打開.html');
69
- expect(guideFileName('en')).toBe('How to open.html');
70
- });
71
-
72
- it('is a complete html file', () => {
73
- const html = buildGuideHtml({ ...base, title: 'Deck', locale: 'en' });
74
- expect(html.startsWith('<!doctype html>')).toBe(true);
75
- expect(html.trim().endsWith('</html>')).toBe(true);
76
- expect(decoder.decode(new TextEncoder().encode(html))).toBe(html);
77
- });
78
- });
@@ -1,70 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- dayStamp,
4
- exportBaseName,
5
- freeImportSlideId,
6
- isValidExtraName,
7
- packageBaseName,
8
- safeFileName,
9
- uniqueFileName,
10
- } from './naming.ts';
11
-
12
- describe('export file names', () => {
13
- it('uses the deck title with characters a file name cannot hold removed', () => {
14
- expect(`${exportBaseName('季度经营汇报:Q3', 'draft-731')}.pptx`).toBe('季度经营汇报Q3.pptx');
15
- });
16
-
17
- it('uses the slide id when the deck has no title', () => {
18
- expect(`${exportBaseName(undefined, 'draft-731')}.pptx`).toBe('draft-731.pptx');
19
- });
20
- });
21
-
22
- describe('package file names', () => {
23
- it('strips what Finder and Explorer refuse', () => {
24
- expect(safeFileName('Q3/经营:汇报*?"<>|', 'q3')).toBe('Q3经营汇报');
25
- expect(safeFileName(' 前后有空格 ', 'q3')).toBe('前后有空格');
26
- expect(safeFileName('a\u0007b', 'q3')).toBe('ab');
27
- });
28
-
29
- it('falls back to the slide id, then to a name', () => {
30
- expect(safeFileName('///', 'q3-report')).toBe('q3-report');
31
- expect(safeFileName('', '')).toBe('LemonRiver');
32
- });
33
-
34
- it('keeps the name to 80 characters', () => {
35
- expect(safeFileName('长'.repeat(200), 'q3')).toHaveLength(80);
36
- });
37
-
38
- it('numbers a second package with the same name', () => {
39
- expect(uniqueFileName('Q3', [])).toBe('Q3');
40
- expect(uniqueFileName('Q3', ['q3'])).toBe('Q3 (2)');
41
- expect(uniqueFileName('Q3', ['Q3', 'Q3 (2)'])).toBe('Q3 (3)');
42
- });
43
-
44
- it('names one deck after itself and several after the day', () => {
45
- expect(packageBaseName([{ title: 'Q3 经营汇报', slideId: 'q3' }], 0)).toBe('Q3 经营汇报');
46
- const many = [
47
- { title: 'A', slideId: 'a' },
48
- { title: 'B', slideId: 'b' },
49
- ];
50
- const now = new Date(2026, 10, 1, 12).getTime();
51
- expect(packageBaseName(many, now)).toBe('LemonRiver 备份 2026-11-01');
52
- expect(dayStamp(now)).toBe('2026-11-01');
53
- });
54
-
55
- it('gives an imported deck its own id', () => {
56
- expect(freeImportSlideId('q3', [])).toBe('q3');
57
- expect(freeImportSlideId('q3', ['Q3'])).toBe('q3-imported');
58
- expect(freeImportSlideId('q3', ['q3', 'q3-imported'])).toBe('q3-imported-2');
59
- });
60
-
61
- it('only lets a PDF, an HTML page or text ride along', () => {
62
- expect(isValidExtraName('Q3 经营汇报.pdf')).toBe(true);
63
- expect(isValidExtraName('怎么打开.html')).toBe(true);
64
- expect(isValidExtraName('README.txt')).toBe(true);
65
- expect(isValidExtraName('setup.sh')).toBe(false);
66
- expect(isValidExtraName('../x.pdf')).toBe(false);
67
- expect(isValidExtraName('.hidden.pdf')).toBe(false);
68
- expect(isValidExtraName('no-extension')).toBe(false);
69
- });
70
- });
@@ -1,116 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import { isJunkPath, isPackagePath, packagePathProblem, slideIdOfPath } from './paths.ts';
3
-
4
- describe('package paths', () => {
5
- it('accepts the folders a package is made of', () => {
6
- expect(isPackagePath('manifest.json')).toBe(true);
7
- expect(isPackagePath('slides/q3-report/index.tsx')).toBe(true);
8
- expect(isPackagePath('slides/q3-report/kit/skeletons.tsx')).toBe(true);
9
- expect(isPackagePath('slides/q3-report/assets/logo.png')).toBe(true);
10
- expect(isPackagePath('board/q3-report.json')).toBe(true);
11
- expect(isPackagePath('thumbs/q3-report/01.jpg')).toBe(true);
12
- expect(isPackagePath('themes/aero.md')).toBe(true);
13
- expect(isPackagePath('themes/aero.demo.tsx')).toBe(true);
14
- expect(isPackagePath('slides/q3-report/kit/fonts/OFL.txt')).toBe(true);
15
- expect(isPackagePath('slides/q3-report/kit/LICENSE')).toBe(true);
16
- });
17
-
18
- it('refuses paths that climb out or lie about where they are', () => {
19
- expect(packagePathProblem('../x')?.code).toBe('bad-path');
20
- expect(packagePathProblem('slides/../x.tsx')?.code).toBe('bad-path');
21
- expect(packagePathProblem('slides/q3/kit/../index.tsx')?.code).toBe('bad-path');
22
- expect(packagePathProblem('slides/q3/kit/../../logo.png')?.code).toBe('bad-path');
23
- expect(packagePathProblem('slides/q3/./index.tsx')?.code).toBe('bad-path');
24
- expect(packagePathProblem('/etc/passwd')?.code).toBe('bad-path');
25
- expect(packagePathProblem('C:/x.tsx')?.code).toBe('bad-path');
26
- expect(packagePathProblem('slides\\q3\\index.tsx')?.code).toBe('bad-path');
27
- expect(packagePathProblem('slides//index.tsx')?.code).toBe('bad-path');
28
- expect(packagePathProblem('slides/q3/.hidden.tsx')?.code).toBe('bad-path');
29
- expect(packagePathProblem('slides/q3/index.tsx\0.png')?.code).toBe('bad-path');
30
- });
31
-
32
- it('refuses node_modules and files that would configure the other machine', () => {
33
- expect(packagePathProblem('slides/q3/node_modules/x.js')?.code).toBe('blocked-file');
34
- expect(packagePathProblem('slides/q3/package.json')?.code).toBe('blocked-file');
35
- expect(packagePathProblem('slides/q3/package-lock.json')?.code).toBe('blocked-file');
36
- expect(packagePathProblem('slides/q3/pnpm-lock.yaml')?.code).toBe('blocked-file');
37
- expect(packagePathProblem('slides/q3/yarn.lock')?.code).toBe('blocked-file');
38
- expect(packagePathProblem('slides/q3/bun.lockb')?.code).toBe('blocked-file');
39
- expect(packagePathProblem('slides/q3/.npmrc')?.code).toBe('bad-path');
40
- expect(packagePathProblem('slides/q3/vite.config.ts')?.code).toBe('blocked-file');
41
- expect(packagePathProblem('slides/q3/lemonriver.config.ts')?.code).toBe('blocked-file');
42
- expect(packagePathProblem('slides/q3/open-slide.config.ts')?.code).toBe('blocked-file');
43
- });
44
-
45
- it('refuses an extension a deck may not carry', () => {
46
- expect(packagePathProblem('slides/q3/setup.sh')?.code).toBe('blocked-file');
47
- expect(packagePathProblem('slides/q3/run.command')?.code).toBe('blocked-file');
48
- expect(packagePathProblem('slides/q3/Evil.app')?.code).toBe('blocked-file');
49
- expect(packagePathProblem('slides/q3/tool')?.code).toBe('blocked-file');
50
- });
51
-
52
- it('wants one of the shapes for every folder', () => {
53
- expect(packagePathProblem('slides/q3')?.code).toBe('bad-path');
54
- expect(packagePathProblem('board/q3')?.code).toBe('bad-path');
55
- expect(packagePathProblem('board/a/b.json')?.code).toBe('bad-path');
56
- expect(packagePathProblem('thumbs/q3/1.jpg')?.code).toBe('bad-path');
57
- expect(packagePathProblem('themes/aero.css')?.code).toBe('bad-path');
58
- expect(packagePathProblem('extras/Q3.pdf')?.code).toBe('bad-path');
59
- expect(packagePathProblem('manifest.json/x')?.code).toBe('bad-path');
60
- });
61
-
62
- it('names the deck a file belongs to', () => {
63
- expect(slideIdOfPath('slides/q3-report/index.tsx')).toBe('q3-report');
64
- expect(slideIdOfPath('board/q3-report.json')).toBe('q3-report');
65
- expect(slideIdOfPath('thumbs/q3-report/01.jpg')).toBe('q3-report');
66
- expect(slideIdOfPath('manifest.json')).toBeNull();
67
- expect(slideIdOfPath('themes/aero.md')).toBeNull();
68
- });
69
-
70
- it('ignores what a Mac leaves in a zip', () => {
71
- expect(isJunkPath('__MACOSX/._index.tsx')).toBe(true);
72
- expect(isJunkPath('LemonRiver-files/.DS_Store')).toBe(true);
73
- expect(isJunkPath('LemonRiver-files/slides/q3/index.tsx')).toBe(false);
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
- });
116
- });