@open-slide/core 2.0.0-beta.1 → 2.0.0-beta.3
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/{config-AtA2Bqtn.d.ts → config-DjWifhaA.d.ts} +1 -1
- package/dist/index.d.ts +3 -2
- package/dist/index.js +1 -1
- package/dist/locale/index.d.ts +1 -1
- package/dist/locale/index.js +1 -1
- package/dist/{types-BzPSOxe-.d.ts → types-BWg-Dtbg.d.ts} +1 -2
- package/dist/vite/index.d.ts +1 -1
- package/dist/{zh-tw-BxZ_pYqe.js → zh-tw-DlKyeNX7.js} +4 -8
- package/package.json +2 -2
- package/skills/slide-authoring/SKILL.md +3 -3
- package/skills/slide-authoring/references/morph.md +5 -5
- package/skills/slide-authoring/references/transitions.md +38 -37
- package/skills/slide-authoring/references/webfonts.md +25 -6
- package/src/app/components/command/slide-command-menu.tsx +10 -0
- package/src/app/components/slide-transition-layer.tsx +8 -1
- package/src/app/lib/export-pptx.ts +122 -193
- package/src/app/lib/pptx/color.ts +49 -0
- package/src/app/lib/pptx/css.test.ts +205 -0
- package/src/app/lib/pptx/css.ts +462 -0
- package/src/app/lib/pptx/fonts.ts +145 -0
- package/src/app/lib/pptx/images.ts +116 -0
- package/src/app/lib/pptx/measure.ts +1281 -0
- package/src/app/lib/pptx/ooxml.test.ts +199 -0
- package/src/app/lib/pptx/ooxml.ts +470 -0
- package/src/app/lib/pptx/raster.ts +189 -0
- package/src/app/lib/pptx/render.ts +102 -0
- package/src/app/lib/pptx/scene.ts +116 -0
- package/src/app/lib/pptx/text-lines.test.ts +82 -0
- package/src/app/lib/pptx/text-lines.ts +109 -0
- package/src/app/lib/pptx/units.ts +22 -0
- package/src/app/lib/transition.test.ts +31 -0
- package/src/app/lib/transition.ts +13 -0
- package/src/app/lib/use-document-title.test.ts +14 -0
- package/src/app/lib/use-document-title.ts +16 -0
- package/src/app/routes/presenter.tsx +2 -0
- package/src/app/routes/slide.tsx +23 -27
- package/src/locale/en.ts +1 -3
- package/src/locale/ja.ts +1 -3
- package/src/locale/types.ts +1 -2
- package/src/locale/zh-cn.ts +1 -2
- package/src/locale/zh-tw.ts +1 -2
|
@@ -1,21 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createRoot, type Root } from 'react-dom/client';
|
|
3
|
-
import { designToCssVars } from './design';
|
|
4
|
-
import { downloadBlob, nextPaint, sleep } from './dom';
|
|
5
|
-
import { SlidePageProvider } from './page-context';
|
|
6
|
-
import { isFrameAnimationSettled, waitForDataWaitfor, waitForFonts } from './print-ready';
|
|
1
|
+
import { downloadBlob } from './dom';
|
|
7
2
|
import { CANVAS_HEIGHT, CANVAS_WIDTH, type SlideModule } from './sdk';
|
|
8
3
|
|
|
9
|
-
// 16:9 widescreen in English Metric Units (914400 EMU per inch → 13.333in × 7.5in).
|
|
10
|
-
const EMU_W = 12192000;
|
|
11
|
-
const EMU_H = 6858000;
|
|
12
|
-
const CAPTURE_PIXEL_RATIO = 2;
|
|
13
|
-
|
|
14
|
-
const ANIMATION_TIMEOUT_MS = 15_000;
|
|
15
|
-
const POLL_INTERVAL_MS = 100;
|
|
16
|
-
|
|
17
4
|
const CAPTURE_CLASS = 'os-pptx-capture';
|
|
18
|
-
const
|
|
5
|
+
const CAPTURE_PIXEL_RATIO = 2;
|
|
19
6
|
// Properties intro animations drive from a hidden start state to a visible end
|
|
20
7
|
// state. We read them back once settled and pin them inline so the capture clone
|
|
21
8
|
// can't re-run the keyframes from their invisible 0% frame (see freezeForCapture).
|
|
@@ -23,94 +10,117 @@ const FROZEN_PROPS = ['opacity', 'transform', 'filter', 'clip-path'] as const;
|
|
|
23
10
|
|
|
24
11
|
export type PptxExportProgress = {
|
|
25
12
|
phase: 'processing' | 'generating' | 'done';
|
|
26
|
-
/** Number of pages
|
|
13
|
+
/** Number of pages converted so far (0..total). */
|
|
27
14
|
current: number;
|
|
28
15
|
total: number;
|
|
29
|
-
/** 0–95 while
|
|
16
|
+
/** 0–95 while converting pages, 98 while assembling, 100 when done. */
|
|
30
17
|
percent: number;
|
|
31
18
|
};
|
|
32
19
|
|
|
33
|
-
|
|
20
|
+
type ProgressFn = (progress: PptxExportProgress) => void;
|
|
21
|
+
|
|
22
|
+
async function loadPipeline() {
|
|
23
|
+
const [render, measure, images, raster, color, ooxml, fflate] = await Promise.all([
|
|
24
|
+
import('./pptx/render'),
|
|
25
|
+
import('./pptx/measure'),
|
|
26
|
+
import('./pptx/images'),
|
|
27
|
+
import('./pptx/raster'),
|
|
28
|
+
import('./pptx/color'),
|
|
29
|
+
import('./pptx/ooxml'),
|
|
30
|
+
import('fflate'),
|
|
31
|
+
]);
|
|
32
|
+
return {
|
|
33
|
+
...render,
|
|
34
|
+
...measure,
|
|
35
|
+
...images,
|
|
36
|
+
...raster,
|
|
37
|
+
...color,
|
|
38
|
+
...ooxml,
|
|
39
|
+
zipSync: fflate.zipSync,
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
function download(
|
|
44
|
+
files: Record<string, Uint8Array>,
|
|
45
|
+
zip: (f: Record<string, Uint8Array>) => Uint8Array,
|
|
46
|
+
mime: string,
|
|
47
|
+
slideId: string,
|
|
48
|
+
) {
|
|
49
|
+
const zipped = zip(files);
|
|
50
|
+
downloadBlob(new Blob([zipped as BlobPart], { type: mime }), `${slideId}.pptx`);
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Converts every page into native PowerPoint objects: text boxes with the browser's
|
|
55
|
+
* line breaks pinned, shapes for boxes and borders, pictures for images, and a
|
|
56
|
+
* pixel-exact raster only for effects PowerPoint cannot express.
|
|
57
|
+
*/
|
|
58
|
+
export async function exportSlideAsPptx(
|
|
34
59
|
slide: SlideModule,
|
|
35
60
|
slideId: string,
|
|
36
|
-
onProgress?:
|
|
61
|
+
onProgress?: ProgressFn,
|
|
37
62
|
): Promise<void> {
|
|
38
63
|
const pages = slide.default ?? [];
|
|
39
64
|
if (pages.length === 0) return;
|
|
40
|
-
|
|
41
65
|
const total = pages.length;
|
|
42
66
|
onProgress?.({ phase: 'processing', current: 0, total, percent: 0 });
|
|
43
67
|
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
transition: none !important;
|
|
68
|
-
}`;
|
|
69
|
-
document.head.appendChild(captureStyle);
|
|
70
|
-
|
|
71
|
-
const designVars = slide.design ? designToCssVars(slide.design) : null;
|
|
72
|
-
|
|
73
|
-
const reactRoots: Root[] = [];
|
|
74
|
-
const frames: HTMLElement[] = [];
|
|
75
|
-
for (let i = 0; i < pages.length; i++) {
|
|
76
|
-
const Page = pages[i];
|
|
77
|
-
if (!Page) continue;
|
|
78
|
-
const host = document.createElement('div');
|
|
79
|
-
host.setAttribute('data-osd-canvas', '');
|
|
80
|
-
host.style.width = `${CANVAS_WIDTH}px`;
|
|
81
|
-
host.style.height = `${CANVAS_HEIGHT}px`;
|
|
82
|
-
host.style.overflow = 'hidden';
|
|
83
|
-
host.style.background = '#fff';
|
|
84
|
-
if (designVars) {
|
|
85
|
-
for (const [k, v] of Object.entries(designVars)) host.style.setProperty(k, v);
|
|
68
|
+
const lib = await loadPipeline();
|
|
69
|
+
const mounted = await lib.mountDeckOffscreen(slide, CAPTURE_CLASS);
|
|
70
|
+
try {
|
|
71
|
+
const images = new lib.ImageStore();
|
|
72
|
+
const color = lib.createColorNormalizer();
|
|
73
|
+
const slides = [];
|
|
74
|
+
for (let i = 0; i < mounted.frames.length; i++) {
|
|
75
|
+
const frame = mounted.frames[i];
|
|
76
|
+
slides.push(
|
|
77
|
+
await lib.measurePage({
|
|
78
|
+
frame,
|
|
79
|
+
notes: slide.notes?.[i]?.trim() || null,
|
|
80
|
+
images,
|
|
81
|
+
rasterizer: new lib.Rasterizer(frame),
|
|
82
|
+
color,
|
|
83
|
+
}),
|
|
84
|
+
);
|
|
85
|
+
onProgress?.({
|
|
86
|
+
phase: 'processing',
|
|
87
|
+
current: i + 1,
|
|
88
|
+
total,
|
|
89
|
+
percent: Math.min(95, ((i + 1) / total) * 95),
|
|
90
|
+
});
|
|
86
91
|
}
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
+
onProgress?.({ phase: 'generating', current: total, total, percent: 98 });
|
|
93
|
+
download(
|
|
94
|
+
lib.buildPptxFiles({ slides, images: images.images }),
|
|
95
|
+
lib.zipSync,
|
|
96
|
+
lib.PPTX_MIME,
|
|
97
|
+
slideId,
|
|
92
98
|
);
|
|
93
|
-
|
|
99
|
+
} finally {
|
|
100
|
+
onProgress?.({ phase: 'done', current: total, total, percent: 100 });
|
|
101
|
+
mounted.dispose();
|
|
94
102
|
}
|
|
95
|
-
|
|
96
|
-
await nextPaint();
|
|
97
|
-
|
|
98
|
-
try {
|
|
99
|
-
await waitForFonts();
|
|
103
|
+
}
|
|
100
104
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
105
|
+
export async function exportSlideAsImagePptx(
|
|
106
|
+
slide: SlideModule,
|
|
107
|
+
slideId: string,
|
|
108
|
+
onProgress?: ProgressFn,
|
|
109
|
+
): Promise<void> {
|
|
110
|
+
const pages = slide.default ?? [];
|
|
111
|
+
if (pages.length === 0) return;
|
|
112
|
+
const total = pages.length;
|
|
113
|
+
onProgress?.({ phase: 'processing', current: 0, total, percent: 0 });
|
|
108
114
|
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
115
|
+
const [lib, { toBlob }] = await Promise.all([loadPipeline(), import('html-to-image')]);
|
|
116
|
+
const mounted = await lib.mountDeckOffscreen(slide, CAPTURE_CLASS);
|
|
117
|
+
try {
|
|
118
|
+
const images = new lib.ImageStore();
|
|
119
|
+
const slides = [];
|
|
120
|
+
for (let i = 0; i < mounted.frames.length; i++) {
|
|
121
|
+
const frame = mounted.frames[i];
|
|
122
|
+
freezeForCapture(frame);
|
|
123
|
+
const blob = await toBlob(frame, {
|
|
114
124
|
width: CANVAS_WIDTH,
|
|
115
125
|
height: CANVAS_HEIGHT,
|
|
116
126
|
pixelRatio: CAPTURE_PIXEL_RATIO,
|
|
@@ -118,7 +128,26 @@ export async function exportSlideAsImagePptx(
|
|
|
118
128
|
cacheBust: true,
|
|
119
129
|
});
|
|
120
130
|
if (!blob) throw new Error(`failed to capture page ${i + 1}`);
|
|
121
|
-
images.
|
|
131
|
+
const imageId = images.add(new Uint8Array(await blob.arrayBuffer()), 'png');
|
|
132
|
+
slides.push({
|
|
133
|
+
background: null,
|
|
134
|
+
notes: slide.notes?.[i]?.trim() || null,
|
|
135
|
+
nodes: [
|
|
136
|
+
{
|
|
137
|
+
kind: 'picture' as const,
|
|
138
|
+
name: 'Slide',
|
|
139
|
+
box: { x: 0, y: 0, w: CANVAS_WIDTH, h: CANVAS_HEIGHT },
|
|
140
|
+
rotationDeg: 0,
|
|
141
|
+
flipV: false,
|
|
142
|
+
imageId,
|
|
143
|
+
crop: null,
|
|
144
|
+
alpha: 1,
|
|
145
|
+
geometry: { kind: 'rect' as const },
|
|
146
|
+
outline: null,
|
|
147
|
+
shadow: null,
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
});
|
|
122
151
|
onProgress?.({
|
|
123
152
|
phase: 'processing',
|
|
124
153
|
current: i + 1,
|
|
@@ -126,26 +155,22 @@ export async function exportSlideAsImagePptx(
|
|
|
126
155
|
percent: Math.min(95, ((i + 1) / total) * 95),
|
|
127
156
|
});
|
|
128
157
|
}
|
|
129
|
-
|
|
130
158
|
onProgress?.({ phase: 'generating', current: total, total, percent: 98 });
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
`${slideId}.pptx`,
|
|
159
|
+
download(
|
|
160
|
+
lib.buildPptxFiles({ slides, images: images.images }),
|
|
161
|
+
lib.zipSync,
|
|
162
|
+
lib.PPTX_MIME,
|
|
163
|
+
slideId,
|
|
137
164
|
);
|
|
138
165
|
} finally {
|
|
139
166
|
onProgress?.({ phase: 'done', current: total, total, percent: 100 });
|
|
140
|
-
|
|
141
|
-
container.remove();
|
|
142
|
-
captureStyle.remove();
|
|
167
|
+
mounted.dispose();
|
|
143
168
|
}
|
|
144
169
|
}
|
|
145
170
|
|
|
146
171
|
// Pin each element's settled visual state inline and remove its animation so the
|
|
147
172
|
// clone html-to-image rasterises renders the final frame instead of replaying the
|
|
148
|
-
// (initially invisible) keyframes. Pseudo-elements are handled by
|
|
173
|
+
// (initially invisible) keyframes. Pseudo-elements are handled by the capture style.
|
|
149
174
|
function freezeForCapture(root: HTMLElement): void {
|
|
150
175
|
for (const el of root.querySelectorAll<HTMLElement>('*')) {
|
|
151
176
|
const cs = getComputedStyle(el);
|
|
@@ -156,99 +181,3 @@ function freezeForCapture(root: HTMLElement): void {
|
|
|
156
181
|
el.style.setProperty('transition', 'none', 'important');
|
|
157
182
|
}
|
|
158
183
|
}
|
|
159
|
-
|
|
160
|
-
const XML_DECL = '<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\n';
|
|
161
|
-
const REL_NS = 'http://schemas.openxmlformats.org/package/2006/relationships';
|
|
162
|
-
const OD_REL = 'http://schemas.openxmlformats.org/officeDocument/2006/relationships';
|
|
163
|
-
|
|
164
|
-
async function buildImagePptx(images: Uint8Array[]): Promise<Uint8Array> {
|
|
165
|
-
const { zipSync, strToU8 } = await import('fflate');
|
|
166
|
-
const n = images.length;
|
|
167
|
-
const files: Record<string, Uint8Array> = {};
|
|
168
|
-
|
|
169
|
-
files['[Content_Types].xml'] = strToU8(contentTypesXml(n));
|
|
170
|
-
files['_rels/.rels'] = strToU8(rootRelsXml());
|
|
171
|
-
files['ppt/presentation.xml'] = strToU8(presentationXml(n));
|
|
172
|
-
files['ppt/_rels/presentation.xml.rels'] = strToU8(presentationRelsXml(n));
|
|
173
|
-
files['ppt/presProps.xml'] = strToU8(presPropsXml());
|
|
174
|
-
files['ppt/theme/theme1.xml'] = strToU8(themeXml());
|
|
175
|
-
files['ppt/slideMasters/slideMaster1.xml'] = strToU8(slideMasterXml());
|
|
176
|
-
files['ppt/slideMasters/_rels/slideMaster1.xml.rels'] = strToU8(slideMasterRelsXml());
|
|
177
|
-
files['ppt/slideLayouts/slideLayout1.xml'] = strToU8(slideLayoutXml());
|
|
178
|
-
files['ppt/slideLayouts/_rels/slideLayout1.xml.rels'] = strToU8(slideLayoutRelsXml());
|
|
179
|
-
|
|
180
|
-
for (let i = 0; i < n; i++) {
|
|
181
|
-
const idx = i + 1;
|
|
182
|
-
files[`ppt/slides/slide${idx}.xml`] = strToU8(slideXml());
|
|
183
|
-
files[`ppt/slides/_rels/slide${idx}.xml.rels`] = strToU8(slideRelsXml(idx));
|
|
184
|
-
files[`ppt/media/image${idx}.png`] = images[i];
|
|
185
|
-
}
|
|
186
|
-
|
|
187
|
-
return zipSync(files);
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
function contentTypesXml(n: number): string {
|
|
191
|
-
const slideOverrides = Array.from(
|
|
192
|
-
{ length: n },
|
|
193
|
-
(_, i) =>
|
|
194
|
-
`<Override PartName="/ppt/slides/slide${i + 1}.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slide+xml"/>`,
|
|
195
|
-
).join('');
|
|
196
|
-
return `${XML_DECL}<Types xmlns="http://schemas.openxmlformats.org/package/2006/content-types"><Default Extension="rels" ContentType="application/vnd.openxmlformats-package.relationships+xml"/><Default Extension="xml" ContentType="application/xml"/><Default Extension="png" ContentType="image/png"/><Override PartName="/ppt/presentation.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presentation.main+xml"/><Override PartName="/ppt/presProps.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.presProps+xml"/><Override PartName="/ppt/slideMasters/slideMaster1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideMaster+xml"/><Override PartName="/ppt/slideLayouts/slideLayout1.xml" ContentType="application/vnd.openxmlformats-officedocument.presentationml.slideLayout+xml"/><Override PartName="/ppt/theme/theme1.xml" ContentType="application/vnd.openxmlformats-officedocument.theme+xml"/>${slideOverrides}</Types>`;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function rootRelsXml(): string {
|
|
200
|
-
return `${XML_DECL}<Relationships xmlns="${REL_NS}"><Relationship Id="rId1" Type="${OD_REL}/officeDocument" Target="ppt/presentation.xml"/></Relationships>`;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
function presentationXml(n: number): string {
|
|
204
|
-
const sldIds = Array.from(
|
|
205
|
-
{ length: n },
|
|
206
|
-
(_, i) => `<p:sldId id="${256 + i}" r:id="rId${i + 3}"/>`,
|
|
207
|
-
).join('');
|
|
208
|
-
return `${XML_DECL}<p:presentation xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="${OD_REL}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:sldMasterIdLst><p:sldMasterId id="2147483648" r:id="rId1"/></p:sldMasterIdLst><p:sldIdLst>${sldIds}</p:sldIdLst><p:sldSz cx="${EMU_W}" cy="${EMU_H}"/><p:notesSz cx="6858000" cy="9144000"/></p:presentation>`;
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
function presentationRelsXml(n: number): string {
|
|
212
|
-
const rels = [
|
|
213
|
-
`<Relationship Id="rId1" Type="${OD_REL}/slideMaster" Target="slideMasters/slideMaster1.xml"/>`,
|
|
214
|
-
`<Relationship Id="rId2" Type="${OD_REL}/presProps" Target="presProps.xml"/>`,
|
|
215
|
-
];
|
|
216
|
-
for (let i = 0; i < n; i++) {
|
|
217
|
-
rels.push(
|
|
218
|
-
`<Relationship Id="rId${i + 3}" Type="${OD_REL}/slide" Target="slides/slide${i + 1}.xml"/>`,
|
|
219
|
-
);
|
|
220
|
-
}
|
|
221
|
-
return `${XML_DECL}<Relationships xmlns="${REL_NS}">${rels.join('')}</Relationships>`;
|
|
222
|
-
}
|
|
223
|
-
|
|
224
|
-
function presPropsXml(): string {
|
|
225
|
-
return `${XML_DECL}<p:presentationPr xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="${OD_REL}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"/>`;
|
|
226
|
-
}
|
|
227
|
-
|
|
228
|
-
function slideMasterXml(): string {
|
|
229
|
-
return `${XML_DECL}<p:sldMaster xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="${OD_REL}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld><p:clrMap bg1="lt1" tx1="dk1" bg2="lt2" tx2="dk2" accent1="accent1" accent2="accent2" accent3="accent3" accent4="accent4" accent5="accent5" accent6="accent6" hlink="hlink" folHlink="folHlink"/><p:sldLayoutIdLst><p:sldLayoutId id="2147483649" r:id="rId1"/></p:sldLayoutIdLst></p:sldMaster>`;
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
function slideMasterRelsXml(): string {
|
|
233
|
-
return `${XML_DECL}<Relationships xmlns="${REL_NS}"><Relationship Id="rId1" Type="${OD_REL}/slideLayout" Target="../slideLayouts/slideLayout1.xml"/><Relationship Id="rId2" Type="${OD_REL}/theme" Target="../theme/theme1.xml"/></Relationships>`;
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
function slideLayoutXml(): string {
|
|
237
|
-
return `${XML_DECL}<p:sldLayout xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="${OD_REL}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main" type="blank" preserve="1"><p:cSld name="Blank"><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr></p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sldLayout>`;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
function slideLayoutRelsXml(): string {
|
|
241
|
-
return `${XML_DECL}<Relationships xmlns="${REL_NS}"><Relationship Id="rId1" Type="${OD_REL}/slideMaster" Target="../slideMasters/slideMaster1.xml"/></Relationships>`;
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function slideXml(): string {
|
|
245
|
-
return `${XML_DECL}<p:sld xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="${OD_REL}" xmlns:p="http://schemas.openxmlformats.org/presentationml/2006/main"><p:cSld><p:spTree><p:nvGrpSpPr><p:cNvPr id="1" name=""/><p:cNvGrpSpPr/><p:nvPr/></p:nvGrpSpPr><p:grpSpPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="0" cy="0"/><a:chOff x="0" y="0"/><a:chExt cx="0" cy="0"/></a:xfrm></p:grpSpPr><p:pic><p:nvPicPr><p:cNvPr id="2" name="Slide"/><p:cNvPicPr><a:picLocks noChangeAspect="1"/></p:cNvPicPr><p:nvPr/></p:nvPicPr><p:blipFill><a:blip r:embed="rId2"/><a:stretch><a:fillRect/></a:stretch></p:blipFill><p:spPr><a:xfrm><a:off x="0" y="0"/><a:ext cx="${EMU_W}" cy="${EMU_H}"/></a:xfrm><a:prstGeom prst="rect"><a:avLst/></a:prstGeom></p:spPr></p:pic></p:spTree></p:cSld><p:clrMapOvr><a:masterClrMapping/></p:clrMapOvr></p:sld>`;
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
function slideRelsXml(idx: number): string {
|
|
249
|
-
return `${XML_DECL}<Relationships xmlns="${REL_NS}"><Relationship Id="rId1" Type="${OD_REL}/slideLayout" Target="../slideLayouts/slideLayout1.xml"/><Relationship Id="rId2" Type="${OD_REL}/image" Target="../media/image${idx}.png"/></Relationships>`;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
function themeXml(): string {
|
|
253
|
-
return `${XML_DECL}<a:theme xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" name="Office Theme"><a:themeElements><a:clrScheme name="Office"><a:dk1><a:sysClr val="windowText" lastClr="000000"/></a:dk1><a:lt1><a:sysClr val="window" lastClr="FFFFFF"/></a:lt1><a:dk2><a:srgbClr val="44546A"/></a:dk2><a:lt2><a:srgbClr val="E7E6E6"/></a:lt2><a:accent1><a:srgbClr val="4472C4"/></a:accent1><a:accent2><a:srgbClr val="ED7D31"/></a:accent2><a:accent3><a:srgbClr val="A5A5A5"/></a:accent3><a:accent4><a:srgbClr val="FFC000"/></a:accent4><a:accent5><a:srgbClr val="5B9BD5"/></a:accent5><a:accent6><a:srgbClr val="70AD47"/></a:accent6><a:hlink><a:srgbClr val="0563C1"/></a:hlink><a:folHlink><a:srgbClr val="954F72"/></a:folHlink></a:clrScheme><a:fontScheme name="Office"><a:majorFont><a:latin typeface="Calibri Light"/><a:ea typeface=""/><a:cs typeface=""/></a:majorFont><a:minorFont><a:latin typeface="Calibri"/><a:ea typeface=""/><a:cs typeface=""/></a:minorFont></a:fontScheme><a:fmtScheme name="Office"><a:fillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:lumMod val="110000"/><a:satMod val="105000"/><a:tint val="67000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="103000"/><a:tint val="73000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="105000"/><a:satMod val="109000"/><a:tint val="81000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:satMod val="103000"/><a:lumMod val="102000"/><a:tint val="94000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:satMod val="110000"/><a:lumMod val="100000"/><a:shade val="100000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:lumMod val="99000"/><a:satMod val="120000"/><a:shade val="78000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:fillStyleLst><a:lnStyleLst><a:ln w="6350" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="12700" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln><a:ln w="19050" cap="flat" cmpd="sng" algn="ctr"><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:prstDash val="solid"/><a:miter lim="800000"/></a:ln></a:lnStyleLst><a:effectStyleLst><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle><a:effectStyle><a:effectLst/></a:effectStyle></a:effectStyleLst><a:bgFillStyleLst><a:solidFill><a:schemeClr val="phClr"/></a:solidFill><a:solidFill><a:schemeClr val="phClr"><a:tint val="95000"/><a:satMod val="170000"/></a:schemeClr></a:solidFill><a:gradFill rotWithShape="1"><a:gsLst><a:gs pos="0"><a:schemeClr val="phClr"><a:tint val="93000"/><a:satMod val="150000"/><a:shade val="98000"/><a:lumMod val="102000"/></a:schemeClr></a:gs><a:gs pos="50000"><a:schemeClr val="phClr"><a:tint val="98000"/><a:satMod val="130000"/><a:shade val="90000"/><a:lumMod val="103000"/></a:schemeClr></a:gs><a:gs pos="100000"><a:schemeClr val="phClr"><a:shade val="63000"/><a:satMod val="120000"/></a:schemeClr></a:gs></a:gsLst><a:lin ang="5400000" scaled="0"/></a:gradFill></a:bgFillStyleLst></a:fmtScheme></a:themeElements></a:theme>`;
|
|
254
|
-
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { type ColorParser, parseColor, type Rgba } from './css';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Computed styles keep modern syntaxes such as `oklch()` verbatim, and canvas
|
|
5
|
+
* `fillStyle` echoes them back unchanged, so the only reliable way to get sRGB
|
|
6
|
+
* bytes is to paint the colour and read the pixel. Painting over white and black
|
|
7
|
+
* recovers the alpha channel.
|
|
8
|
+
*/
|
|
9
|
+
export function createColorNormalizer(): ColorParser {
|
|
10
|
+
const cache = new Map<string, Rgba | null>();
|
|
11
|
+
const canvas = document.createElement('canvas');
|
|
12
|
+
canvas.width = 1;
|
|
13
|
+
canvas.height = 1;
|
|
14
|
+
const ctx = canvas.getContext('2d', { willReadFrequently: true });
|
|
15
|
+
|
|
16
|
+
const sample = (value: string, backdrop: string): Uint8ClampedArray | null => {
|
|
17
|
+
if (!ctx) return null;
|
|
18
|
+
ctx.globalCompositeOperation = 'copy';
|
|
19
|
+
ctx.fillStyle = backdrop;
|
|
20
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
21
|
+
ctx.globalCompositeOperation = 'source-over';
|
|
22
|
+
ctx.fillStyle = '#123456';
|
|
23
|
+
ctx.fillStyle = value;
|
|
24
|
+
if (ctx.fillStyle === '#123456' && !/123456/i.test(value)) return null;
|
|
25
|
+
ctx.fillRect(0, 0, 1, 1);
|
|
26
|
+
return ctx.getImageData(0, 0, 1, 1).data;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
return (value: string): Rgba | null => {
|
|
30
|
+
const direct = parseColor(value);
|
|
31
|
+
if (direct) return direct;
|
|
32
|
+
const cached = cache.get(value);
|
|
33
|
+
if (cached !== undefined) return cached;
|
|
34
|
+
let result: Rgba | null = null;
|
|
35
|
+
const onWhite = sample(value, '#ffffff');
|
|
36
|
+
const onBlack = sample(value, '#000000');
|
|
37
|
+
if (onWhite && onBlack) {
|
|
38
|
+
const diffs = [0, 1, 2].map((i) => onWhite[i] - onBlack[i]);
|
|
39
|
+
const alpha = Math.min(1, Math.max(0, 1 - Math.max(...diffs) / 255));
|
|
40
|
+
if (alpha <= 0.002) result = { r: 0, g: 0, b: 0, a: 0 };
|
|
41
|
+
else {
|
|
42
|
+
const c = (i: number) => Math.min(255, Math.max(0, Math.round(onBlack[i] / alpha)));
|
|
43
|
+
result = { r: c(0), g: c(1), b: c(2), a: Number(alpha.toFixed(3)) };
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
cache.set(value, result);
|
|
47
|
+
return result;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
@@ -0,0 +1,205 @@
|
|
|
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
|
+
});
|