@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.
- package/dist/{build-Dm7gVRhb.js → build-CSkdswfd.js} +1 -1
- package/dist/cli/bin.js +5 -5
- package/dist/{config-CubOIzrs.js → config-C5-myPY6.js} +129 -2
- package/dist/{dev-DgLeXPqp.js → dev-DHtYH8sw.js} +2 -2
- package/dist/{mcp-CjYDzcJa.js → mcp-B2UeO1un.js} +1 -1
- package/dist/{preview-CxXQpPk5.js → preview-C1B6-umF.js} +1 -1
- package/dist/{update-b1dSg_FW.js → update-DzL8fpcI.js} +1 -1
- package/dist/vite/index.js +1 -1
- package/package.json +5 -2
- package/release-notes.json +33 -0
- package/src/app/components/player.tsx +6 -1
- package/src/app/lemonriver/chrome/app-chrome.tsx +52 -0
- package/src/app/lemonriver/chrome/sidebar-extras.tsx +8 -1
- package/src/app/lemonriver/feedback/dialog.tsx +222 -0
- package/src/app/lemonriver/feedback/export.ts +21 -2
- package/src/app/lemonriver/feedback/first-success.ts +30 -0
- package/src/app/lemonriver/feedback/install.ts +18 -0
- package/src/app/lemonriver/feedback/model.ts +88 -0
- package/src/app/lemonriver/help/help-page.tsx +16 -1
- package/src/app/lemonriver/links.ts +16 -0
- package/src/app/lemonriver/present/dual-screen.ts +154 -0
- package/src/app/lemonriver/present/presenter-blocked-hint.tsx +28 -0
- package/src/app/lemonriver/present/wake-lock.ts +74 -0
- package/src/app/lemonriver/settings/backup-section.tsx +13 -0
- package/src/app/lemonriver/settings/settings-page.tsx +20 -0
- package/src/app/lemonriver/share/editor-share.tsx +6 -3
- package/src/app/lemonriver/share/share-dialog.tsx +2 -0
- package/src/app/lemonriver/text/en.ts +48 -0
- package/src/app/lemonriver/text/es.ts +45 -0
- package/src/app/lemonriver/text/ja.ts +44 -0
- package/src/app/lemonriver/text/types.ts +48 -0
- package/src/app/lemonriver/text/zh-cn.ts +48 -0
- package/src/app/lemonriver/text/zh-tw.ts +48 -0
- package/src/app/lemonriver/theme/pages.ts +4 -0
- package/src/app/lemonriver/update/release-notes.ts +22 -0
- package/src/app/lemonriver/update/update-prompt.tsx +28 -4
- package/src/app/routes/presenter.tsx +2 -0
- package/src/app/routes/slide.tsx +14 -1
- package/src/app/components/note-markdown.test.tsx +0 -42
- package/src/app/components/thumbnail-rail-scroll.test.ts +0 -60
- package/src/app/lemonriver/agent-prefs/prefs.test.ts +0 -173
- package/src/app/lemonriver/backup/guide.test.ts +0 -45
- package/src/app/lemonriver/backup/model.test.ts +0 -108
- package/src/app/lemonriver/backup/places.test.ts +0 -154
- package/src/app/lemonriver/board/blocks/classify.test.ts +0 -209
- package/src/app/lemonriver/board/layout.test.ts +0 -245
- package/src/app/lemonriver/board/model/agent-tasks.test.ts +0 -200
- package/src/app/lemonriver/board/model/apply-prompt.test.ts +0 -121
- package/src/app/lemonriver/board/model/cards.test.ts +0 -332
- package/src/app/lemonriver/board/model/changes.test.ts +0 -244
- package/src/app/lemonriver/board/model/filter.test.ts +0 -50
- package/src/app/lemonriver/board/model/history.test.ts +0 -71
- package/src/app/lemonriver/board/model/restructure.test.ts +0 -205
- package/src/app/lemonriver/board/model/self-check.test.ts +0 -329
- package/src/app/lemonriver/board/model/structure.test.ts +0 -350
- package/src/app/lemonriver/board/model/timing.test.ts +0 -113
- package/src/app/lemonriver/features.test.ts +0 -49
- package/src/app/lemonriver/feedback/pending-toast.test.ts +0 -44
- package/src/app/lemonriver/feedback/upload.test.ts +0 -26
- package/src/app/lemonriver/help/model.test.ts +0 -179
- package/src/app/lemonriver/home/brief.test.ts +0 -38
- package/src/app/lemonriver/home/drafts.test.ts +0 -23
- package/src/app/lemonriver/home/sorting.test.ts +0 -24
- package/src/app/lemonriver/home/time.test.ts +0 -33
- package/src/app/lemonriver/outline/files.test.ts +0 -90
- package/src/app/lemonriver/outline/model.test.ts +0 -751
- package/src/app/lemonriver/public-links.test.ts +0 -32
- package/src/app/lemonriver/routes.test.tsx +0 -54
- package/src/app/lemonriver/share/codes.test.ts +0 -49
- package/src/app/lemonriver/share/compare.test.ts +0 -199
- package/src/app/lemonriver/share/folder.test.ts +0 -42
- package/src/app/lemonriver/share/guide.test.ts +0 -78
- package/src/app/lemonriver/share/naming.test.ts +0 -70
- package/src/app/lemonriver/share/paths.test.ts +0 -116
- package/src/app/lemonriver/share/pdf.test.ts +0 -79
- package/src/app/lemonriver/templates/knobs.test.ts +0 -62
- package/src/app/lemonriver/templates/model.test.ts +0 -175
- package/src/app/lemonriver/templates/preview-content.test.ts +0 -117
- package/src/app/lemonriver/templates/recommend.test.ts +0 -71
- package/src/app/lemonriver/text/text.test.ts +0 -90
- package/src/app/lemonriver/theme/pages.test.ts +0 -74
- package/src/app/lemonriver/theme/themes.test.ts +0 -18
- package/src/app/lemonriver/trash/api.test.ts +0 -19
- package/src/app/lemonriver/update/prompt.test.ts +0 -84
- package/src/app/lemonriver/update/version.test.ts +0 -14
- package/src/app/lib/asset-filter.test.ts +0 -176
- package/src/app/lib/inspector/fiber.test.ts +0 -154
- package/src/app/lib/inspector/geometry.test.ts +0 -324
- package/src/app/lib/inspector/text-edit-timeline.test.ts +0 -121
- package/src/app/lib/note-markdown.test.ts +0 -147
- package/src/app/lib/pptx/css.test.ts +0 -205
- package/src/app/lib/pptx/ooxml.test.ts +0 -199
- package/src/app/lib/pptx/text-lines.test.ts +0 -82
- package/src/app/lib/print-ready.test.ts +0 -32
- package/src/app/lib/sdk.test.ts +0 -13
- package/src/app/lib/transition.test.ts +0 -31
- package/src/app/lib/use-document-title.test.ts +0 -14
- package/src/app/lib/utils.test.ts +0 -49
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import {
|
|
3
|
-
applyTextTransform,
|
|
4
|
-
decompose,
|
|
5
|
-
geometryFor,
|
|
6
|
-
gradientLineLength,
|
|
7
|
-
multiply,
|
|
8
|
-
normalizeRadii,
|
|
9
|
-
parseBlurPx,
|
|
10
|
-
parseColor,
|
|
11
|
-
parseCornerRadius,
|
|
12
|
-
parseFontFamilies,
|
|
13
|
-
parseLinearGradient,
|
|
14
|
-
parseShadows,
|
|
15
|
-
parseTransform,
|
|
16
|
-
splitTopLevel,
|
|
17
|
-
toHex,
|
|
18
|
-
transformedBounds,
|
|
19
|
-
translation,
|
|
20
|
-
} from './css';
|
|
21
|
-
|
|
22
|
-
describe('parseColor', () => {
|
|
23
|
-
it('parses legacy and modern rgb syntax', () => {
|
|
24
|
-
expect(parseColor('rgb(255, 0, 128)')).toEqual({ r: 255, g: 0, b: 128, a: 1 });
|
|
25
|
-
expect(parseColor('rgba(0, 0, 0, 0.5)')).toEqual({ r: 0, g: 0, b: 0, a: 0.5 });
|
|
26
|
-
expect(parseColor('rgb(255 0 0 / 50%)')).toEqual({ r: 255, g: 0, b: 0, a: 0.5 });
|
|
27
|
-
expect(parseColor('transparent')).toEqual({ r: 0, g: 0, b: 0, a: 0 });
|
|
28
|
-
});
|
|
29
|
-
it('parses hex forms', () => {
|
|
30
|
-
expect(parseColor('#fff')).toEqual({ r: 255, g: 255, b: 255, a: 1 });
|
|
31
|
-
expect(parseColor('#6d4cff')).toEqual({ r: 109, g: 76, b: 255, a: 1 });
|
|
32
|
-
expect(parseColor('#00000080')?.a).toBeCloseTo(0.502, 2);
|
|
33
|
-
});
|
|
34
|
-
it('rejects colours it cannot resolve', () => {
|
|
35
|
-
expect(parseColor('oklch(0.62 0.18 250)')).toBeNull();
|
|
36
|
-
expect(parseColor('red')).toBeNull();
|
|
37
|
-
});
|
|
38
|
-
it('formats hex', () => {
|
|
39
|
-
expect(toHex({ r: 109, g: 76, b: 255, a: 1 })).toBe('6D4CFF');
|
|
40
|
-
});
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
describe('splitTopLevel', () => {
|
|
44
|
-
it('ignores separators inside parentheses and quotes', () => {
|
|
45
|
-
expect(splitTopLevel('rgba(1, 2, 3, 0.5) 0px 4px, url("a,b") 1px')).toEqual([
|
|
46
|
-
'rgba(1, 2, 3, 0.5) 0px 4px',
|
|
47
|
-
'url("a,b") 1px',
|
|
48
|
-
]);
|
|
49
|
-
});
|
|
50
|
-
});
|
|
51
|
-
|
|
52
|
-
describe('transforms', () => {
|
|
53
|
-
it('parses matrix and flat matrix3d', () => {
|
|
54
|
-
expect(parseTransform('none')).toEqual([1, 0, 0, 1, 0, 0]);
|
|
55
|
-
expect(parseTransform('matrix(1, 0, 0, 1, -50, -25)')).toEqual([1, 0, 0, 1, -50, -25]);
|
|
56
|
-
expect(parseTransform('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 10, 20, 0, 1)')).toEqual([
|
|
57
|
-
1, 0, 0, 1, 10, 20,
|
|
58
|
-
]);
|
|
59
|
-
expect(
|
|
60
|
-
parseTransform('matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0.001, 0, 0, 0, 1)'),
|
|
61
|
-
).toBeNull();
|
|
62
|
-
});
|
|
63
|
-
it('decomposes rotation and scale', () => {
|
|
64
|
-
const rotated = parseTransform('matrix(0.984808, 0.173648, -0.173648, 0.984808, 0, 0)');
|
|
65
|
-
const d = rotated ? decompose(rotated) : null;
|
|
66
|
-
expect(d?.rotationDeg).toBeCloseTo(10, 3);
|
|
67
|
-
expect(d?.scaleX).toBeCloseTo(1, 5);
|
|
68
|
-
expect(d?.scaleY).toBeCloseTo(1, 5);
|
|
69
|
-
expect(d?.skewed).toBe(false);
|
|
70
|
-
expect(d?.flipV).toBe(false);
|
|
71
|
-
const s = decompose([2, 0, 0, -3, 0, 0]);
|
|
72
|
-
expect(s).toMatchObject({ scaleX: 2, scaleY: 3, flipV: true, skewed: false });
|
|
73
|
-
expect(decompose([1, 0, 1, 1, 0, 0])?.skewed).toBe(true);
|
|
74
|
-
});
|
|
75
|
-
it('composes translations and computes bounds', () => {
|
|
76
|
-
const m = multiply(translation(10, 20), [2, 0, 0, 2, 0, 0]);
|
|
77
|
-
expect(transformedBounds(m, 0, 0, 10, 10)).toEqual({ x: 10, y: 20, w: 20, h: 20 });
|
|
78
|
-
});
|
|
79
|
-
});
|
|
80
|
-
|
|
81
|
-
describe('parseLinearGradient', () => {
|
|
82
|
-
it('parses angle, stops and interpolates missing positions', () => {
|
|
83
|
-
const g = parseLinearGradient(
|
|
84
|
-
'linear-gradient(135deg, rgba(120, 120, 130, 0.06) 0%, rgb(0, 0, 0), rgba(120, 120, 130, 0.06) 100%)',
|
|
85
|
-
100,
|
|
86
|
-
100,
|
|
87
|
-
);
|
|
88
|
-
expect(g?.angleDeg).toBe(135);
|
|
89
|
-
expect(g?.stops.map((s) => s.pos)).toEqual([0, 0.5, 1]);
|
|
90
|
-
});
|
|
91
|
-
it('defaults to top-to-bottom and resolves side keywords', () => {
|
|
92
|
-
expect(
|
|
93
|
-
parseLinearGradient('linear-gradient(rgb(0, 0, 0), rgb(255, 255, 255))', 10, 10)?.angleDeg,
|
|
94
|
-
).toBe(180);
|
|
95
|
-
expect(
|
|
96
|
-
parseLinearGradient('linear-gradient(to right, rgb(0, 0, 0), rgb(255, 255, 255))', 10, 10)
|
|
97
|
-
?.angleDeg,
|
|
98
|
-
).toBe(90);
|
|
99
|
-
const corner = parseLinearGradient(
|
|
100
|
-
'linear-gradient(to bottom right, rgb(0, 0, 0), rgb(255, 255, 255))',
|
|
101
|
-
100,
|
|
102
|
-
100,
|
|
103
|
-
);
|
|
104
|
-
expect(corner?.angleDeg).toBeCloseTo(135, 5);
|
|
105
|
-
});
|
|
106
|
-
it('converts px stop positions against the gradient line', () => {
|
|
107
|
-
const g = parseLinearGradient(
|
|
108
|
-
'linear-gradient(to right, rgb(0, 0, 0) 25px, rgb(255, 255, 255) 75px)',
|
|
109
|
-
100,
|
|
110
|
-
50,
|
|
111
|
-
);
|
|
112
|
-
expect(g?.stops.map((s) => s.pos)).toEqual([0.25, 0.75]);
|
|
113
|
-
expect(gradientLineLength(90, 100, 50)).toBeCloseTo(100);
|
|
114
|
-
});
|
|
115
|
-
it('rejects unsupported colour syntax and non-linear gradients', () => {
|
|
116
|
-
expect(
|
|
117
|
-
parseLinearGradient('linear-gradient(oklch(0.6 0.1 20), rgb(0, 0, 0))', 10, 10),
|
|
118
|
-
).toBeNull();
|
|
119
|
-
expect(parseLinearGradient('radial-gradient(rgb(0, 0, 0), rgb(1, 1, 1))', 10, 10)).toBeNull();
|
|
120
|
-
});
|
|
121
|
-
});
|
|
122
|
-
|
|
123
|
-
describe('parseShadows', () => {
|
|
124
|
-
it('parses Chrome computed box-shadow values', () => {
|
|
125
|
-
const s = parseShadows(
|
|
126
|
-
'rgba(0, 0, 0, 0.25) 0px 10px 30px 0px, rgb(255, 0, 0) 0px 0px 0px 2px inset',
|
|
127
|
-
);
|
|
128
|
-
expect(s).toHaveLength(2);
|
|
129
|
-
expect(s[0]).toMatchObject({ x: 0, y: 10, blur: 30, spread: 0, inset: false });
|
|
130
|
-
expect(s[1]).toMatchObject({ spread: 2, inset: true });
|
|
131
|
-
expect(parseShadows('none')).toEqual([]);
|
|
132
|
-
});
|
|
133
|
-
});
|
|
134
|
-
|
|
135
|
-
describe('radii', () => {
|
|
136
|
-
it('parses px, percentage and elliptical corners', () => {
|
|
137
|
-
expect(parseCornerRadius('12px', 100, 50)).toEqual({ x: 12, y: 12 });
|
|
138
|
-
expect(parseCornerRadius('50%', 100, 50)).toEqual({ x: 50, y: 25 });
|
|
139
|
-
expect(parseCornerRadius('10px 20px', 100, 50)).toEqual({ x: 10, y: 20 });
|
|
140
|
-
});
|
|
141
|
-
it('scales overlapping radii down like CSS', () => {
|
|
142
|
-
const r = normalizeRadii(
|
|
143
|
-
[
|
|
144
|
-
{ x: 80, y: 80 },
|
|
145
|
-
{ x: 80, y: 80 },
|
|
146
|
-
{ x: 0, y: 0 },
|
|
147
|
-
{ x: 0, y: 0 },
|
|
148
|
-
],
|
|
149
|
-
100,
|
|
150
|
-
100,
|
|
151
|
-
);
|
|
152
|
-
expect(r[0].x).toBeCloseTo(50);
|
|
153
|
-
expect(r[1].x).toBeCloseTo(50);
|
|
154
|
-
});
|
|
155
|
-
});
|
|
156
|
-
|
|
157
|
-
describe('misc', () => {
|
|
158
|
-
it('sums blur radii and parses families', () => {
|
|
159
|
-
expect(parseBlurPx('blur(40px) brightness(1.2) blur(10px)')).toBe(50);
|
|
160
|
-
expect(parseBlurPx('none')).toBe(0);
|
|
161
|
-
expect(parseFontFamilies('"Inter", -apple-system, \'JetBrains Mono\', monospace')).toEqual([
|
|
162
|
-
'Inter',
|
|
163
|
-
'-apple-system',
|
|
164
|
-
'JetBrains Mono',
|
|
165
|
-
'monospace',
|
|
166
|
-
]);
|
|
167
|
-
});
|
|
168
|
-
it('applies text-transform', () => {
|
|
169
|
-
expect(applyTextTransform('hello world', 'uppercase')).toBe('HELLO WORLD');
|
|
170
|
-
expect(applyTextTransform('hello world', 'capitalize')).toBe('Hello World');
|
|
171
|
-
expect(applyTextTransform('Hello', 'none')).toBe('Hello');
|
|
172
|
-
});
|
|
173
|
-
});
|
|
174
|
-
|
|
175
|
-
describe('geometryFor', () => {
|
|
176
|
-
const uniform = (x: number, y = x): Parameters<typeof geometryFor>[0] => [
|
|
177
|
-
{ x, y },
|
|
178
|
-
{ x, y },
|
|
179
|
-
{ x, y },
|
|
180
|
-
{ x, y },
|
|
181
|
-
];
|
|
182
|
-
it('keeps a pill as a rounded rectangle', () => {
|
|
183
|
-
const radii = normalizeRadii(uniform(9999), 540, 56);
|
|
184
|
-
expect(geometryFor(radii, 540, 56)).toEqual({ kind: 'roundRect', radius: 28 });
|
|
185
|
-
});
|
|
186
|
-
it('treats a fully rounded square as an ellipse', () => {
|
|
187
|
-
const radii = normalizeRadii(uniform(9999), 64, 64);
|
|
188
|
-
expect(geometryFor(radii, 64, 64)).toEqual({ kind: 'ellipse' });
|
|
189
|
-
});
|
|
190
|
-
it('treats 50% corners on a wide box as an ellipse', () => {
|
|
191
|
-
expect(geometryFor(uniform(100, 30), 200, 60)).toEqual({ kind: 'ellipse' });
|
|
192
|
-
});
|
|
193
|
-
it('maps small uniform corners to a rounded rectangle', () => {
|
|
194
|
-
expect(geometryFor(uniform(12), 300, 80)).toEqual({ kind: 'roundRect', radius: 12 });
|
|
195
|
-
});
|
|
196
|
-
it('falls back to a custom path for mixed or elliptical corners', () => {
|
|
197
|
-
const mixed = uniform(12);
|
|
198
|
-
mixed[2] = { x: 0, y: 0 };
|
|
199
|
-
expect(geometryFor(mixed, 300, 80).kind).toBe('custom');
|
|
200
|
-
expect(geometryFor(uniform(40, 10), 300, 80).kind).toBe('custom');
|
|
201
|
-
});
|
|
202
|
-
it('maps no radius to a plain rectangle', () => {
|
|
203
|
-
expect(geometryFor(uniform(0), 300, 80)).toEqual({ kind: 'rect' });
|
|
204
|
-
});
|
|
205
|
-
});
|
|
@@ -1,199 +0,0 @@
|
|
|
1
|
-
import { mkdirSync, writeFileSync } from 'node:fs';
|
|
2
|
-
import { dirname } from 'node:path';
|
|
3
|
-
import { strFromU8, unzipSync, zipSync } from 'fflate';
|
|
4
|
-
import { describe, expect, it } from 'vitest';
|
|
5
|
-
import { buildPptxFiles, escapeXml, geometryXml } from './ooxml';
|
|
6
|
-
import type { DeckScene, RunStyle } from './scene';
|
|
7
|
-
|
|
8
|
-
const PNG_1PX = Uint8Array.from(
|
|
9
|
-
atob(
|
|
10
|
-
'iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mNkYPhfDwAChwGA60e6kgAAAABJRU5ErkJggg==',
|
|
11
|
-
),
|
|
12
|
-
(c) => c.charCodeAt(0),
|
|
13
|
-
);
|
|
14
|
-
|
|
15
|
-
const style: RunStyle = {
|
|
16
|
-
font: 'Inter',
|
|
17
|
-
sizePx: 40,
|
|
18
|
-
bold: true,
|
|
19
|
-
italic: false,
|
|
20
|
-
underline: false,
|
|
21
|
-
strike: false,
|
|
22
|
-
color: { r: 26, g: 24, b: 20, a: 1 },
|
|
23
|
-
letterSpacingPx: -0.8,
|
|
24
|
-
baselineShift: null,
|
|
25
|
-
shadow: null,
|
|
26
|
-
outline: null,
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
const deck: DeckScene = {
|
|
30
|
-
images: [{ id: 1, bytes: PNG_1PX, format: 'png' }],
|
|
31
|
-
slides: [
|
|
32
|
-
{
|
|
33
|
-
background: { kind: 'solid', color: { r: 247, g: 245, b: 240, a: 1 } },
|
|
34
|
-
notes: 'Open with the quote.\n\nPause.',
|
|
35
|
-
nodes: [
|
|
36
|
-
{
|
|
37
|
-
kind: 'shape',
|
|
38
|
-
name: 'Card',
|
|
39
|
-
box: { x: 100, y: 100, w: 400, h: 200 },
|
|
40
|
-
rotationDeg: 0,
|
|
41
|
-
flipV: false,
|
|
42
|
-
geometry: { kind: 'roundRect', radius: 24 },
|
|
43
|
-
fill: {
|
|
44
|
-
kind: 'gradient',
|
|
45
|
-
angleDeg: 90,
|
|
46
|
-
stops: [
|
|
47
|
-
{ pos: 0, color: { r: 255, g: 0, b: 0, a: 1 } },
|
|
48
|
-
{ pos: 1, color: { r: 0, g: 0, b: 255, a: 0.5 } },
|
|
49
|
-
],
|
|
50
|
-
},
|
|
51
|
-
outline: { width: 2, color: { r: 0, g: 0, b: 0, a: 1 }, dash: 'dash' },
|
|
52
|
-
shadow: {
|
|
53
|
-
blur: 30,
|
|
54
|
-
dist: 10,
|
|
55
|
-
dirDeg: 90,
|
|
56
|
-
color: { r: 0, g: 0, b: 0, a: 0.25 },
|
|
57
|
-
spread: 0,
|
|
58
|
-
inner: false,
|
|
59
|
-
},
|
|
60
|
-
},
|
|
61
|
-
{
|
|
62
|
-
kind: 'text',
|
|
63
|
-
name: 'Text: Hello',
|
|
64
|
-
box: { x: 120, y: 120, w: 300, h: 128 },
|
|
65
|
-
rotationDeg: -3,
|
|
66
|
-
flipV: false,
|
|
67
|
-
paragraphs: [
|
|
68
|
-
{
|
|
69
|
-
lineSpacingPx: 64,
|
|
70
|
-
align: 'ctr',
|
|
71
|
-
bullet: { kind: 'char', char: '•', color: { r: 0, g: 0, b: 0, a: 1 }, font: 'Arial' },
|
|
72
|
-
marginLeftPx: 20,
|
|
73
|
-
indentPx: -20,
|
|
74
|
-
endSizePx: 40,
|
|
75
|
-
lines: [
|
|
76
|
-
{ runs: [{ text: 'Hello <world> & "friends"', style }], sizePx: 40 },
|
|
77
|
-
{ runs: [], sizePx: 40 },
|
|
78
|
-
{ runs: [{ text: 'again', style: { ...style, bold: false } }], sizePx: 40 },
|
|
79
|
-
],
|
|
80
|
-
},
|
|
81
|
-
],
|
|
82
|
-
},
|
|
83
|
-
{
|
|
84
|
-
kind: 'picture',
|
|
85
|
-
name: 'Image',
|
|
86
|
-
box: { x: 600, y: 100, w: 200, h: 100 },
|
|
87
|
-
rotationDeg: 0,
|
|
88
|
-
flipV: false,
|
|
89
|
-
imageId: 1,
|
|
90
|
-
crop: { l: 0.1, t: 0, r: 0.1, b: 0 },
|
|
91
|
-
alpha: 0.8,
|
|
92
|
-
geometry: { kind: 'ellipse' },
|
|
93
|
-
outline: null,
|
|
94
|
-
shadow: null,
|
|
95
|
-
},
|
|
96
|
-
],
|
|
97
|
-
},
|
|
98
|
-
{ background: null, notes: null, nodes: [] },
|
|
99
|
-
],
|
|
100
|
-
};
|
|
101
|
-
|
|
102
|
-
describe('buildPptxFiles', () => {
|
|
103
|
-
const files = buildPptxFiles(deck);
|
|
104
|
-
const text = (name: string) => strFromU8(files[name]);
|
|
105
|
-
|
|
106
|
-
it('emits every package part and wires the relationships', () => {
|
|
107
|
-
expect(Object.keys(files).sort()).toEqual(
|
|
108
|
-
[
|
|
109
|
-
'[Content_Types].xml',
|
|
110
|
-
'_rels/.rels',
|
|
111
|
-
'ppt/_rels/presentation.xml.rels',
|
|
112
|
-
'ppt/media/image1.png',
|
|
113
|
-
'ppt/notesMasters/_rels/notesMaster1.xml.rels',
|
|
114
|
-
'ppt/notesMasters/notesMaster1.xml',
|
|
115
|
-
'ppt/notesSlides/_rels/notesSlide1.xml.rels',
|
|
116
|
-
'ppt/notesSlides/notesSlide1.xml',
|
|
117
|
-
'ppt/presProps.xml',
|
|
118
|
-
'ppt/presentation.xml',
|
|
119
|
-
'ppt/slideLayouts/_rels/slideLayout1.xml.rels',
|
|
120
|
-
'ppt/slideLayouts/slideLayout1.xml',
|
|
121
|
-
'ppt/slideMasters/_rels/slideMaster1.xml.rels',
|
|
122
|
-
'ppt/slideMasters/slideMaster1.xml',
|
|
123
|
-
'ppt/slides/_rels/slide1.xml.rels',
|
|
124
|
-
'ppt/slides/_rels/slide2.xml.rels',
|
|
125
|
-
'ppt/slides/slide1.xml',
|
|
126
|
-
'ppt/slides/slide2.xml',
|
|
127
|
-
'ppt/theme/theme1.xml',
|
|
128
|
-
'ppt/theme/theme2.xml',
|
|
129
|
-
].sort(),
|
|
130
|
-
);
|
|
131
|
-
expect(text('ppt/presentation.xml')).toContain('<p:sldSz cx="12192000" cy="6858000"/>');
|
|
132
|
-
expect(text('ppt/presentation.xml')).toContain('<p:notesMasterId r:id="rId5"/>');
|
|
133
|
-
expect(text('ppt/slides/_rels/slide1.xml.rels')).toContain('Target="../media/image1.png"');
|
|
134
|
-
expect(text('ppt/slides/_rels/slide1.xml.rels')).toContain('notesSlides/notesSlide1.xml');
|
|
135
|
-
expect(text('ppt/slides/_rels/slide2.xml.rels')).not.toContain('notesSlide');
|
|
136
|
-
expect(text('[Content_Types].xml')).toContain('/ppt/notesSlides/notesSlide1.xml');
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('converts geometry, text and fills into DrawingML', () => {
|
|
140
|
-
const slide = text('ppt/slides/slide1.xml');
|
|
141
|
-
expect(slide).toContain(
|
|
142
|
-
'<p:bg><p:bgPr><a:solidFill><a:srgbClr val="F7F5F0"></a:srgbClr></a:solidFill>',
|
|
143
|
-
);
|
|
144
|
-
expect(slide).toContain('<a:off x="635000" y="635000"/><a:ext cx="2540000" cy="1270000"/>');
|
|
145
|
-
expect(slide).toContain(
|
|
146
|
-
'<a:prstGeom prst="roundRect"><a:avLst><a:gd name="adj" fmla="val 12000"/>',
|
|
147
|
-
);
|
|
148
|
-
expect(slide).toContain('<a:lin ang="0" scaled="0"/>');
|
|
149
|
-
expect(slide).toContain('<a:alpha val="50000"/>');
|
|
150
|
-
expect(slide).toContain('<a:prstDash val="dash"/>');
|
|
151
|
-
expect(slide).toContain('<a:outerShdw blurRad="190500" dist="63500" dir="5400000"');
|
|
152
|
-
expect(slide).toContain('<a:xfrm rot="21420000">');
|
|
153
|
-
expect(slide).toContain('<a:lnSpc><a:spcPts val="3200"/></a:lnSpc>');
|
|
154
|
-
expect(slide).toContain('marL="127000" indent="-127000" algn="ctr"');
|
|
155
|
-
expect(slide).toContain('<a:buChar char="•"/>');
|
|
156
|
-
expect(slide).toContain('sz="2000" b="1" spc="-40" dirty="0"');
|
|
157
|
-
expect(slide).toContain('<a:t>Hello <world> & "friends"</a:t>');
|
|
158
|
-
expect(slide.match(/<a:br>/g)).toHaveLength(2);
|
|
159
|
-
expect(slide).toContain('<a:latin typeface="Inter"/><a:ea typeface="Inter"/>');
|
|
160
|
-
expect(slide).toContain('<a:alphaModFix amt="80000"/>');
|
|
161
|
-
expect(slide).toContain('<a:srcRect l="10000" t="0" r="10000" b="0"/>');
|
|
162
|
-
expect(slide).toContain('<a:prstGeom prst="ellipse">');
|
|
163
|
-
expect(text('ppt/notesSlides/notesSlide1.xml')).toContain('<a:t>Open with the quote.</a:t>');
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('builds a custom rounded path for uneven corners', () => {
|
|
167
|
-
const xml = geometryXml(
|
|
168
|
-
{
|
|
169
|
-
kind: 'custom',
|
|
170
|
-
radii: [
|
|
171
|
-
{ x: 10, y: 10 },
|
|
172
|
-
{ x: 0, y: 0 },
|
|
173
|
-
{ x: 10, y: 10 },
|
|
174
|
-
{ x: 0, y: 0 },
|
|
175
|
-
],
|
|
176
|
-
},
|
|
177
|
-
{ x: 0, y: 0, w: 100, h: 50 },
|
|
178
|
-
);
|
|
179
|
-
expect(xml).toContain('<a:path w="635000" h="317500">');
|
|
180
|
-
expect(xml.match(/<a:arcTo /g)).toHaveLength(2);
|
|
181
|
-
expect(xml).toContain('stAng="10800000"');
|
|
182
|
-
expect(xml).toContain('stAng="0"');
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
it('strips control characters', () => {
|
|
186
|
-
expect(escapeXml('a\u0000b\u0007c\td')).toBe('abc\td');
|
|
187
|
-
});
|
|
188
|
-
|
|
189
|
-
it('round-trips through a zip', () => {
|
|
190
|
-
const zipped = zipSync(files);
|
|
191
|
-
const unzipped = unzipSync(zipped);
|
|
192
|
-
expect(Object.keys(unzipped)).toHaveLength(Object.keys(files).length);
|
|
193
|
-
const out = process.env.PPTX_SAMPLE_OUT;
|
|
194
|
-
if (out) {
|
|
195
|
-
mkdirSync(dirname(out), { recursive: true });
|
|
196
|
-
writeFileSync(out, zipped);
|
|
197
|
-
}
|
|
198
|
-
});
|
|
199
|
-
});
|
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import type { RunStyle } from './scene';
|
|
3
|
-
import { type Atom, fillEmptyLines, groupAtomsIntoLines, lineToRuns } from './text-lines';
|
|
4
|
-
|
|
5
|
-
const style = (over: Partial<RunStyle> = {}): RunStyle => ({
|
|
6
|
-
font: 'Arial',
|
|
7
|
-
sizePx: 40,
|
|
8
|
-
bold: false,
|
|
9
|
-
italic: false,
|
|
10
|
-
underline: false,
|
|
11
|
-
strike: false,
|
|
12
|
-
color: { r: 0, g: 0, b: 0, a: 1 },
|
|
13
|
-
letterSpacingPx: 0,
|
|
14
|
-
baselineShift: null,
|
|
15
|
-
shadow: null,
|
|
16
|
-
outline: null,
|
|
17
|
-
...over,
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
const atom = (
|
|
21
|
-
text: string,
|
|
22
|
-
x: number,
|
|
23
|
-
y: number,
|
|
24
|
-
w = 10,
|
|
25
|
-
h = 44,
|
|
26
|
-
key = 'a',
|
|
27
|
-
over: Partial<Atom> = {},
|
|
28
|
-
): Atom => ({
|
|
29
|
-
text,
|
|
30
|
-
rect: { x, y, w, h },
|
|
31
|
-
styleKey: key,
|
|
32
|
-
style: style(),
|
|
33
|
-
preserveSpaces: false,
|
|
34
|
-
...over,
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
describe('groupAtomsIntoLines', () => {
|
|
38
|
-
it('starts a new line when x moves back or y moves fully below', () => {
|
|
39
|
-
const lines = groupAtomsIntoLines([
|
|
40
|
-
atom('H', 0, 10),
|
|
41
|
-
atom('i', 10, 10),
|
|
42
|
-
atom('t', 0, 74),
|
|
43
|
-
atom('x', 300, 74),
|
|
44
|
-
atom('y', 320, 140),
|
|
45
|
-
]);
|
|
46
|
-
expect(lines.map((l) => l.atoms.map((a) => a.text).join(''))).toEqual(['Hi', 'tx', 'y']);
|
|
47
|
-
expect(lines[0]).toMatchObject({ top: 10, bottom: 54, left: 0, right: 20 });
|
|
48
|
-
});
|
|
49
|
-
it('keeps superscripts on the same line', () => {
|
|
50
|
-
const lines = groupAtomsIntoLines([atom('x', 0, 10), atom('2', 10, 0, 6, 26)]);
|
|
51
|
-
expect(lines).toHaveLength(1);
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
describe('fillEmptyLines', () => {
|
|
56
|
-
it('inserts blank lines for multi-pitch gaps', () => {
|
|
57
|
-
const lines = fillEmptyLines(
|
|
58
|
-
groupAtomsIntoLines([atom('a', 0, 0), atom('b', 0, 60), atom('c', 0, 180)]),
|
|
59
|
-
);
|
|
60
|
-
expect(lines).toHaveLength(4);
|
|
61
|
-
expect(lines[2].atoms).toHaveLength(0);
|
|
62
|
-
expect(lines[2].bottom).toBeCloseTo(164);
|
|
63
|
-
});
|
|
64
|
-
});
|
|
65
|
-
|
|
66
|
-
describe('lineToRuns', () => {
|
|
67
|
-
it('merges same-style atoms, collapses whitespace and trims line edges', () => {
|
|
68
|
-
const [line] = groupAtomsIntoLines([
|
|
69
|
-
atom(' Hello ', 0, 0, 100),
|
|
70
|
-
atom(' big', 100, 0, 50, 44, 'b'),
|
|
71
|
-
atom(' world ', 150, 0, 80, 44, 'b'),
|
|
72
|
-
]);
|
|
73
|
-
const { runs } = lineToRuns(line);
|
|
74
|
-
expect(runs.map((r) => r.text)).toEqual(['Hello ', 'big world']);
|
|
75
|
-
});
|
|
76
|
-
it('keeps indentation for preformatted text', () => {
|
|
77
|
-
const [line] = groupAtomsIntoLines([
|
|
78
|
-
atom(' const x', 0, 0, 100, 44, 'a', { preserveSpaces: true }),
|
|
79
|
-
]);
|
|
80
|
-
expect(lineToRuns(line).runs[0].text).toBe(' const x');
|
|
81
|
-
});
|
|
82
|
-
});
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { afterEach, describe, expect, it, vi } from 'vitest';
|
|
2
|
-
import { waitForFonts } from './print-ready';
|
|
3
|
-
|
|
4
|
-
afterEach(() => {
|
|
5
|
-
vi.unstubAllGlobals();
|
|
6
|
-
});
|
|
7
|
-
|
|
8
|
-
describe('waitForFonts', () => {
|
|
9
|
-
it('awaits document.fonts.ready without force-loading any face', async () => {
|
|
10
|
-
const load = vi.fn();
|
|
11
|
-
const faces = [
|
|
12
|
-
{ status: 'loaded', load },
|
|
13
|
-
{ status: 'unloaded', load },
|
|
14
|
-
{ status: 'unloaded', load },
|
|
15
|
-
];
|
|
16
|
-
const fonts = {
|
|
17
|
-
ready: Promise.resolve(),
|
|
18
|
-
[Symbol.iterator]: () => faces[Symbol.iterator](),
|
|
19
|
-
};
|
|
20
|
-
vi.stubGlobal('document', { fonts });
|
|
21
|
-
|
|
22
|
-
await waitForFonts();
|
|
23
|
-
|
|
24
|
-
expect(load).not.toHaveBeenCalled();
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
it('resolves when the FontFaceSet API is unavailable', async () => {
|
|
28
|
-
vi.stubGlobal('document', {});
|
|
29
|
-
|
|
30
|
-
await expect(waitForFonts()).resolves.toBeUndefined();
|
|
31
|
-
});
|
|
32
|
-
});
|
package/src/app/lib/sdk.test.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { CANVAS_HEIGHT, CANVAS_WIDTH } from './sdk.ts';
|
|
3
|
-
|
|
4
|
-
describe('canvas constants', () => {
|
|
5
|
-
it('targets a 1920x1080 canvas', () => {
|
|
6
|
-
expect(CANVAS_WIDTH).toBe(1920);
|
|
7
|
-
expect(CANVAS_HEIGHT).toBe(1080);
|
|
8
|
-
});
|
|
9
|
-
|
|
10
|
-
it('preserves a 16:9 aspect ratio', () => {
|
|
11
|
-
expect(CANVAS_WIDTH / CANVAS_HEIGHT).toBeCloseTo(16 / 9);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { holdOpacity } from './transition';
|
|
3
|
-
|
|
4
|
-
describe('holdOpacity', () => {
|
|
5
|
-
it('drops opacity from array keyframes and keeps everything else', () => {
|
|
6
|
-
const phase = holdOpacity({
|
|
7
|
-
duration: 140,
|
|
8
|
-
keyframes: [
|
|
9
|
-
{ opacity: 1, transform: 'translateY(0)' },
|
|
10
|
-
{ opacity: 0, transform: 'translateY(-4px)', offset: 1 },
|
|
11
|
-
],
|
|
12
|
-
});
|
|
13
|
-
|
|
14
|
-
expect(phase).toEqual({
|
|
15
|
-
duration: 140,
|
|
16
|
-
keyframes: [{ transform: 'translateY(0)' }, { transform: 'translateY(-4px)', offset: 1 }],
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('drops opacity from property-indexed keyframes', () => {
|
|
21
|
-
const phase = holdOpacity({
|
|
22
|
-
keyframes: { opacity: [1, 0], transform: ['scale(1)', 'scale(1.01)'] },
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
expect(phase?.keyframes).toEqual({ transform: ['scale(1)', 'scale(1.01)'] });
|
|
26
|
-
});
|
|
27
|
-
|
|
28
|
-
it('passes an undefined phase through', () => {
|
|
29
|
-
expect(holdOpacity(undefined)).toBeUndefined();
|
|
30
|
-
});
|
|
31
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { DEFAULT_DOCUMENT_TITLE, resolveDocumentTitle } from './use-document-title.ts';
|
|
3
|
-
|
|
4
|
-
describe('resolveDocumentTitle', () => {
|
|
5
|
-
it('uses the deck title', () => {
|
|
6
|
-
expect(resolveDocumentTitle('Quarterly Product Review')).toBe('Quarterly Product Review');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('falls back when the deck has no title', () => {
|
|
10
|
-
expect(resolveDocumentTitle()).toBe(DEFAULT_DOCUMENT_TITLE);
|
|
11
|
-
expect(resolveDocumentTitle('')).toBe(DEFAULT_DOCUMENT_TITLE);
|
|
12
|
-
expect(resolveDocumentTitle(' ')).toBe(DEFAULT_DOCUMENT_TITLE);
|
|
13
|
-
});
|
|
14
|
-
});
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { cn, pad2, round2 } from './utils.ts';
|
|
3
|
-
|
|
4
|
-
describe('cn', () => {
|
|
5
|
-
it('joins multiple class names', () => {
|
|
6
|
-
expect(cn('a', 'b', 'c')).toBe('a b c');
|
|
7
|
-
});
|
|
8
|
-
|
|
9
|
-
it('drops falsy values', () => {
|
|
10
|
-
expect(cn('a', false, undefined, null, '', 'b')).toBe('a b');
|
|
11
|
-
});
|
|
12
|
-
|
|
13
|
-
it('flattens arrays and conditional objects from clsx', () => {
|
|
14
|
-
expect(cn(['a', 'b'], { c: true, d: false })).toBe('a b c');
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('lets later tailwind classes override earlier ones', () => {
|
|
18
|
-
expect(cn('p-2', 'p-4')).toBe('p-4');
|
|
19
|
-
expect(cn('text-red-500', 'text-blue-500')).toBe('text-blue-500');
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
it('preserves classes that target different properties', () => {
|
|
23
|
-
expect(cn('p-2', 'm-4')).toBe('p-2 m-4');
|
|
24
|
-
});
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
describe('pad2', () => {
|
|
28
|
-
it('pads single digits to two', () => {
|
|
29
|
-
expect(pad2(0)).toBe('00');
|
|
30
|
-
expect(pad2(7)).toBe('07');
|
|
31
|
-
});
|
|
32
|
-
|
|
33
|
-
it('leaves two or more digits alone', () => {
|
|
34
|
-
expect(pad2(12)).toBe('12');
|
|
35
|
-
expect(pad2(340)).toBe('340');
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe('round2', () => {
|
|
40
|
-
it('rounds to two decimal places', () => {
|
|
41
|
-
expect(round2(1.005)).toBe(1);
|
|
42
|
-
expect(round2(1.2345)).toBe(1.23);
|
|
43
|
-
expect(round2(1.2355)).toBe(1.24);
|
|
44
|
-
});
|
|
45
|
-
|
|
46
|
-
it('leaves whole numbers alone', () => {
|
|
47
|
-
expect(round2(42)).toBe(42);
|
|
48
|
-
});
|
|
49
|
-
});
|