import { atom } from 'nanostores'; export interface ShaderState { code: string; isCompiled: boolean; isAnimating: boolean; error: string | null; } export const defaultShaderState: ShaderState = { code: 'x^y', isCompiled: false, isAnimating: false, error: null, }; export const $shader = atom(defaultShaderState); export function setShaderCode(code: string) { $shader.set({ ...$shader.get(), code, isCompiled: false, error: null }); } export function setShaderCompiled(isCompiled: boolean, error?: string) { $shader.set({ ...$shader.get(), isCompiled, error: error || null, }); } export function setShaderAnimating(isAnimating: boolean) { $shader.set({ ...$shader.get(), isAnimating }); }