@lemonriver/core 1.0.2 → 1.2.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 (110) hide show
  1. package/dist/{build-DYN-H65n.js → build-CSkdswfd.js} +1 -1
  2. package/dist/cli/bin.js +5 -5
  3. package/dist/{config-DW1wSoxa.js → config-C5-myPY6.js} +2087 -1439
  4. package/dist/{dev-_VDoRfAK.js → dev-DHtYH8sw.js} +2 -2
  5. package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
  6. package/dist/{preview-CYIGh3Z8.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 +19 -0
  11. package/src/app/components/command/slide-command-menu.tsx +0 -9
  12. package/src/app/lemonriver/backup/client.ts +25 -1
  13. package/src/app/lemonriver/backup/model.ts +63 -18
  14. package/src/app/lemonriver/board/board-page.tsx +2 -2
  15. package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
  16. package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
  17. package/src/app/lemonriver/feedback/dialog.tsx +222 -0
  18. package/src/app/lemonriver/feedback/export.ts +21 -2
  19. package/src/app/lemonriver/feedback/first-success.ts +30 -0
  20. package/src/app/lemonriver/feedback/install.ts +18 -0
  21. package/src/app/lemonriver/feedback/model.ts +88 -0
  22. package/src/app/lemonriver/help/help-page.tsx +16 -1
  23. package/src/app/lemonriver/help/model.ts +1 -1
  24. package/src/app/lemonriver/home/drafts.ts +57 -0
  25. package/src/app/lemonriver/home/home-page.tsx +94 -10
  26. package/src/app/lemonriver/home/organize-drafts.tsx +192 -0
  27. package/src/app/lemonriver/links.ts +16 -0
  28. package/src/app/lemonriver/outline/outline-page.tsx +8 -1
  29. package/src/app/lemonriver/settings/backup-restore-dialog.tsx +15 -1
  30. package/src/app/lemonriver/settings/backup-section.tsx +159 -28
  31. package/src/app/lemonriver/settings/settings-page.tsx +23 -0
  32. package/src/app/lemonriver/settings/workspace-card.tsx +53 -0
  33. package/src/app/lemonriver/settings/workspace.ts +37 -0
  34. package/src/app/lemonriver/share/editor-share.tsx +58 -0
  35. package/src/app/lemonriver/share/import-dialog.tsx +14 -0
  36. package/src/app/lemonriver/share/naming.ts +6 -1
  37. package/src/app/lemonriver/share/share-dialog.tsx +2 -0
  38. package/src/app/lemonriver/slide-extensions.tsx +37 -53
  39. package/src/app/lemonriver/text/en.ts +91 -11
  40. package/src/app/lemonriver/text/es.ts +81 -6
  41. package/src/app/lemonriver/text/ja.ts +80 -6
  42. package/src/app/lemonriver/text/types.ts +89 -6
  43. package/src/app/lemonriver/text/zh-cn.ts +92 -11
  44. package/src/app/lemonriver/text/zh-tw.ts +92 -11
  45. package/src/app/lemonriver/theme/pages.ts +4 -0
  46. package/src/app/lemonriver/update/beta-badge.tsx +69 -0
  47. package/src/app/lemonriver/update/release-notes.ts +22 -0
  48. package/src/app/lemonriver/update/update-prompt.tsx +28 -4
  49. package/src/app/lib/export-html.ts +5 -3
  50. package/src/app/lib/export-pptx.ts +5 -4
  51. package/src/app/routes/slide.tsx +6 -57
  52. package/src/app/components/note-markdown.test.tsx +0 -42
  53. package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
  54. package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
  55. package/src/app/lemonriver/backup/guide.test.ts +0 -45
  56. package/src/app/lemonriver/backup/model.test.ts +0 -96
  57. package/src/app/lemonriver/backup/places.test.ts +0 -154
  58. package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
  59. package/src/app/lemonriver/board/layout.test.ts +0 -245
  60. package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
  61. package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
  62. package/src/app/lemonriver/board/model/cards.test.ts +0 -332
  63. package/src/app/lemonriver/board/model/changes.test.ts +0 -244
  64. package/src/app/lemonriver/board/model/filter.test.ts +0 -50
  65. package/src/app/lemonriver/board/model/history.test.ts +0 -71
  66. package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
  67. package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
  68. package/src/app/lemonriver/board/model/structure.test.ts +0 -350
  69. package/src/app/lemonriver/board/model/timing.test.ts +0 -113
  70. package/src/app/lemonriver/features.test.ts +0 -49
  71. package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
  72. package/src/app/lemonriver/feedback/upload.test.ts +0 -26
  73. package/src/app/lemonriver/help/model.test.ts +0 -179
  74. package/src/app/lemonriver/home/brief.test.ts +0 -38
  75. package/src/app/lemonriver/home/sorting.test.ts +0 -24
  76. package/src/app/lemonriver/home/time.test.ts +0 -33
  77. package/src/app/lemonriver/outline/files.test.ts +0 -90
  78. package/src/app/lemonriver/outline/model.test.ts +0 -751
  79. package/src/app/lemonriver/public-links.test.ts +0 -32
  80. package/src/app/lemonriver/routes.test.tsx +0 -54
  81. package/src/app/lemonriver/share/codes.test.ts +0 -49
  82. package/src/app/lemonriver/share/compare.test.ts +0 -199
  83. package/src/app/lemonriver/share/folder.test.ts +0 -42
  84. package/src/app/lemonriver/share/guide.test.ts +0 -78
  85. package/src/app/lemonriver/share/naming.test.ts +0 -59
  86. package/src/app/lemonriver/share/paths.test.ts +0 -116
  87. package/src/app/lemonriver/share/pdf.test.ts +0 -79
  88. package/src/app/lemonriver/templates/knobs.test.ts +0 -62
  89. package/src/app/lemonriver/templates/model.test.ts +0 -175
  90. package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
  91. package/src/app/lemonriver/templates/recommend.test.ts +0 -71
  92. package/src/app/lemonriver/text/text.test.ts +0 -90
  93. package/src/app/lemonriver/theme/pages.test.ts +0 -74
  94. package/src/app/lemonriver/theme/themes.test.ts +0 -18
  95. package/src/app/lemonriver/trash/api.test.ts +0 -19
  96. package/src/app/lemonriver/update/prompt.test.ts +0 -84
  97. package/src/app/lemonriver/update/version.test.ts +0 -14
  98. package/src/app/lib/asset-filter.test.ts +0 -176
  99. package/src/app/lib/inspector/fiber.test.ts +0 -154
  100. package/src/app/lib/inspector/geometry.test.ts +0 -324
  101. package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
  102. package/src/app/lib/note-markdown.test.ts +0 -147
  103. package/src/app/lib/pptx/css.test.ts +0 -205
  104. package/src/app/lib/pptx/ooxml.test.ts +0 -199
  105. package/src/app/lib/pptx/text-lines.test.ts +0 -82
  106. package/src/app/lib/print-ready.test.ts +0 -32
  107. package/src/app/lib/sdk.test.ts +0 -13
  108. package/src/app/lib/transition.test.ts +0 -31
  109. package/src/app/lib/use-document-title.test.ts +0 -14
  110. 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,59 +0,0 @@
1
- import { describe, expect, it } from 'vitest';
2
- import {
3
- dayStamp,
4
- freeImportSlideId,
5
- isValidExtraName,
6
- packageBaseName,
7
- safeFileName,
8
- uniqueFileName,
9
- } from './naming.ts';
10
-
11
- describe('package file names', () => {
12
- it('strips what Finder and Explorer refuse', () => {
13
- expect(safeFileName('Q3/经营:汇报*?"<>|', 'q3')).toBe('Q3经营汇报');
14
- expect(safeFileName(' 前后有空格 ', 'q3')).toBe('前后有空格');
15
- expect(safeFileName('a\u0007b', 'q3')).toBe('ab');
16
- });
17
-
18
- it('falls back to the slide id, then to a name', () => {
19
- expect(safeFileName('///', 'q3-report')).toBe('q3-report');
20
- expect(safeFileName('', '')).toBe('LemonRiver');
21
- });
22
-
23
- it('keeps the name to 80 characters', () => {
24
- expect(safeFileName('长'.repeat(200), 'q3')).toHaveLength(80);
25
- });
26
-
27
- it('numbers a second package with the same name', () => {
28
- expect(uniqueFileName('Q3', [])).toBe('Q3');
29
- expect(uniqueFileName('Q3', ['q3'])).toBe('Q3 (2)');
30
- expect(uniqueFileName('Q3', ['Q3', 'Q3 (2)'])).toBe('Q3 (3)');
31
- });
32
-
33
- it('names one deck after itself and several after the day', () => {
34
- expect(packageBaseName([{ title: 'Q3 经营汇报', slideId: 'q3' }], 0)).toBe('Q3 经营汇报');
35
- const many = [
36
- { title: 'A', slideId: 'a' },
37
- { title: 'B', slideId: 'b' },
38
- ];
39
- const now = new Date(2026, 10, 1, 12).getTime();
40
- expect(packageBaseName(many, now)).toBe('LemonRiver 备份 2026-11-01');
41
- expect(dayStamp(now)).toBe('2026-11-01');
42
- });
43
-
44
- it('gives an imported deck its own id', () => {
45
- expect(freeImportSlideId('q3', [])).toBe('q3');
46
- expect(freeImportSlideId('q3', ['Q3'])).toBe('q3-imported');
47
- expect(freeImportSlideId('q3', ['q3', 'q3-imported'])).toBe('q3-imported-2');
48
- });
49
-
50
- it('only lets a PDF, an HTML page or text ride along', () => {
51
- expect(isValidExtraName('Q3 经营汇报.pdf')).toBe(true);
52
- expect(isValidExtraName('怎么打开.html')).toBe(true);
53
- expect(isValidExtraName('README.txt')).toBe(true);
54
- expect(isValidExtraName('setup.sh')).toBe(false);
55
- expect(isValidExtraName('../x.pdf')).toBe(false);
56
- expect(isValidExtraName('.hidden.pdf')).toBe(false);
57
- expect(isValidExtraName('no-extension')).toBe(false);
58
- });
59
- });
@@ -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
- });