LCOV - code coverage report
Current view: top level - packages/theme-core/src - themePresetSchema.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 100.0 % 8 8
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import { z } from 'zod'
       2              : 
       3              : import { RenderShape } from '@comfyorg/graph-model/globalEnums'
       4              : 
       5         2356 : const nodeSlotSchema = z.object({
       6              :   CLIP: z.string(),
       7              :   CLIP_VISION: z.string(),
       8              :   CLIP_VISION_OUTPUT: z.string(),
       9              :   CONDITIONING: z.string(),
      10              :   CONTROL_NET: z.string(),
      11              :   IMAGE: z.string(),
      12              :   LATENT: z.string(),
      13              :   MASK: z.string(),
      14              :   MODEL: z.string(),
      15              :   STYLE_MODEL: z.string(),
      16              :   VAE: z.string(),
      17              :   NOISE: z.string(),
      18              :   GUIDER: z.string(),
      19              :   SAMPLER: z.string(),
      20              :   SIGMAS: z.string(),
      21              :   TAESD: z.string()
      22              : })
      23              : 
      24         2356 : const litegraphBaseSchema = z.object({
      25              :   BACKGROUND_IMAGE: z.string(),
      26              :   CLEAR_BACKGROUND_COLOR: z.string(),
      27              :   NODE_TITLE_COLOR: z.string(),
      28              :   NODE_SELECTED_TITLE_COLOR: z.string(),
      29              :   NODE_TEXT_COLOR: z.string(),
      30              :   NODE_TEXT_HIGHLIGHT_COLOR: z.string(),
      31              :   NODE_DEFAULT_COLOR: z.string(),
      32              :   NODE_DEFAULT_BGCOLOR: z.string(),
      33              :   NODE_DEFAULT_BOXCOLOR: z.string(),
      34              :   NODE_DEFAULT_SHAPE: z.union([
      35              :     z.literal(RenderShape.BOX),
      36              :     z.literal(RenderShape.ROUND),
      37              :     z.literal(RenderShape.CARD),
      38              :     z.string()
      39              :   ]),
      40              :   NODE_WIDGET_GAP: z.number(),
      41              :   NODE_BOX_OUTLINE_COLOR: z.string(),
      42              :   NODE_BYPASS_BGCOLOR: z.string(),
      43              :   NODE_ERROR_COLOUR: z.string(),
      44              :   DEFAULT_SHADOW_COLOR: z.string(),
      45              :   WIDGET_BGCOLOR: z.string(),
      46              :   WIDGET_OUTLINE_COLOR: z.string(),
      47              :   WIDGET_TEXT_COLOR: z.string(),
      48              :   WIDGET_SECONDARY_TEXT_COLOR: z.string(),
      49              :   WIDGET_DISABLED_TEXT_COLOR: z.string(),
      50              :   LINK_COLOR: z.string(),
      51              :   EVENT_LINK_COLOR: z.string(),
      52              :   CONNECTING_LINK_COLOR: z.string(),
      53              :   BADGE_FG_COLOR: z.string(),
      54              :   BADGE_BG_COLOR: z.string()
      55              : })
      56              : 
      57         2356 : export const comfyBaseSchema = z.object({
      58              :   ['fg-color']: z.string(),
      59              :   ['bg-color']: z.string(),
      60              :   ['bg-img']: z.string().optional(),
      61              :   ['comfy-menu-bg']: z.string(),
      62              :   ['comfy-menu-secondary-bg']: z.string(),
      63              :   ['comfy-input-bg']: z.string(),
      64              :   ['input-text']: z.string(),
      65              :   ['descrip-text']: z.string(),
      66              :   ['drag-text']: z.string(),
      67              :   ['error-text']: z.string(),
      68              :   ['border-color']: z.string(),
      69              :   ['tr-even-bg-color']: z.string(),
      70              :   ['tr-odd-bg-color']: z.string(),
      71              :   ['content-bg']: z.string(),
      72              :   ['content-fg']: z.string(),
      73              :   ['content-hover-bg']: z.string(),
      74              :   ['content-hover-fg']: z.string(),
      75              :   ['bar-shadow']: z.string(),
      76              :   ['contrast-mix-color']: z.string().optional(),
      77              :   ['interface-stroke']: z.string().optional(),
      78              :   ['interface-panel-surface']: z.string().optional(),
      79              :   ['interface-panel-box-shadow']: z.string().optional(),
      80              :   ['interface-panel-drop-shadow']: z.string().optional(),
      81              :   ['interface-floating-panel-shadow']: z.string().optional(),
      82              :   ['interface-panel-hover-surface']: z.string().optional(),
      83              :   ['interface-panel-selected-surface']: z.string().optional(),
      84              :   ['interface-button-hover-surface']: z.string().optional()
      85              : })
      86              : 
      87              : /** Design-system theme variables a palette may override: the shadcn/tweakcn contract plus the node layer. */
      88         2356 : export const themeSchema = z
      89              :   .object({
      90              :     background: z.string(),
      91              :     foreground: z.string(),
      92              :     card: z.string(),
      93              :     popover: z.string(),
      94              :     primary: z.string(),
      95              :     secondary: z.string(),
      96              :     muted: z.string(),
      97              :     ['muted-foreground']: z.string(),
      98              :     accent: z.string(),
      99              :     destructive: z.string(),
     100              :     border: z.string(),
     101              :     input: z.string(),
     102              :     ring: z.string(),
     103              :     node: z.string(),
     104              :     ['node-foreground']: z.string(),
     105              :     ['node-header']: z.string(),
     106              :     ['node-border']: z.string(),
     107              :     ['node-radius']: z.string(),
     108              :     ['node-title-font-size']: z.string(),
     109              :     ['node-icon-style']: z.string(),
     110              :     ['node-widget-height']: z.string(),
     111              :     ['node-widget-radius']: z.string(),
     112              :     ['node-widget-border-width']: z.string(),
     113              :     warning: z.string(),
     114              :     ['shadow-color']: z.string()
     115              :   })
     116              :   .partial()
     117              : 
     118         2356 : const colorsSchema = z.object({
     119              :   node_slot: nodeSlotSchema,
     120              :   litegraph_base: litegraphBaseSchema,
     121              :   comfy_base: comfyBaseSchema,
     122              :   theme: themeSchema.optional()
     123              : })
     124              : 
     125         2356 : const partialColorsSchema = z.object({
     126              :   node_slot: nodeSlotSchema.partial(),
     127              :   litegraph_base: litegraphBaseSchema.partial(),
     128              :   comfy_base: comfyBaseSchema.partial(),
     129              :   theme: themeSchema.optional()
     130              : })
     131              : 
     132         2356 : export const themePresetSchema = z
     133              :   .object({
     134              :     id: z.string(),
     135              :     name: z.string(),
     136              :     colors: partialColorsSchema,
     137              :     light_theme: z.boolean().optional()
     138              :   })
     139              :   .passthrough()
     140              : 
     141         2356 : const completedPresetSchema = z
     142              :   .object({
     143              :     id: z.string(),
     144              :     name: z.string(),
     145              :     light_theme: z.boolean().optional(),
     146              :     colors: colorsSchema
     147              :   })
     148              :   .passthrough()
     149              : 
     150              : export type Colors = z.infer<typeof colorsSchema>
     151              : export type ThemeTokens = z.infer<typeof themeSchema>
     152              : export type ThemePreset = z.infer<typeof themePresetSchema>
     153              : export type CompletedThemePreset = z.infer<typeof completedPresetSchema>
     154              : export type ThemePresets = Record<string, ThemePreset>
        

Generated by: LCOV version 2.0-1