| 1 |
import { failWithFallback } from '@auto-launch/functions/helpers'; |
| 2 |
import { z } from 'zod'; |
| 3 |
|
| 4 |
/** |
| 5 |
* An unknown variable must not sink a design authored against a newer build. |
| 6 |
* A number is a CSS value too, so `0.88` is not dropped. |
| 7 |
*/ |
| 8 |
export const designShape = z.object({ |
| 9 |
vars: z.record(z.string(), z.union([z.string(), z.number()])).optional(), |
| 10 |
shader: z.string().optional(), |
| 11 |
logo: z.string().optional(), |
| 12 |
templates: z.record(z.string(), z.string()).optional(), |
| 13 |
}); |
| 14 |
|
| 15 |
export const handleDesign = async () => |
| 16 |
failWithFallback( |
| 17 |
async () => designShape.parse(window.extLaunchData?.customDesign ?? {}), |
| 18 |
{}, |
| 19 |
{ error: { message: 'Design config unreadable', name: 'DesignError' } }, |
| 20 |
); |
| 21 |
|