api #

Declarations
#

CSS framework and design system for semantic HTML

524 declarations

AcornPlugin
#

ALL_MODIFIER_NAMES
#

ANCESTOR_MODIFIERS
#

ARBITRARY_MAX_WIDTH_PATTERN
#

ARBITRARY_MIN_WIDTH_PATTERN
#

arrayClasses
#

BaseDiagnostic
#

diagnostics.ts view source

BaseDiagnostic

Base diagnostic with common fields.

level

type 'error' | 'warning'

message

type string

suggestion

type string | null

bg
#

bg_0
#

bg_1
#

bg_10
#

bg_2
#

bg_3
#

bg_4
#

bg_5
#

bg_6
#

bg_7
#

bg_8
#

bg_9
#

border_color
#

border_color_1
#

border_color_2
#

border_color_3
#

border_color_4
#

border_color_5
#

border_color_a
#

border_color_b
#

border_color_c
#

border_color_d
#

border_color_e
#

border_color_f
#

border_color_g
#

border_color_h
#

border_color_i
#

border_color_intensity_variants
#

border_color_j
#

border_radius_lg
#

border_radius_md
#

border_radius_sm
#

border_radius_variants
#

border_radius_xl
#

border_radius_xs
#

border_radius_xs2
#

border_radius_xs3
#

border_style
#

border_width
#

border_width_1
#

border_width_2
#

border_width_3
#

border_width_4
#

border_width_5
#

border_width_6
#

border_width_7
#

border_width_8
#

border_width_9
#

border_width_variants
#

BorderColorIntensityVariant
#

BorderRadiusVariant
#

BorderWidthVariant
#

button_shadow
#

button_shadow_active
#

button_shadow_hover
#

CachedExtraction
#

css_cache.ts view source

CachedExtraction

Cached extraction result for a single file. Uses null instead of empty arrays to avoid allocation overhead.

v

Cache version - invalidates cache when bumped

type number

content_hash

SHA-256 hash of the source file contents

type string

classes

Classes as [name, locations] tuples, or null if none

type Array<[string, Array<SourceLocation>]> | null

explicit_classes

Classes from

type Array<string> | null

diagnostics

Extraction diagnostics, or null if none

type Array<ExtractionDiagnostic> | null

check_calc_expression
#

css_literal.ts view source

(value: string): string | null

Checks if a value contains a possibly invalid calc expression.

value

- The formatted CSS value

type string

returns

string | null

Warning message if suspicious, null otherwise

ClassTemplateFn
#

color_a_1
#

color_a_2
#

color_a_3
#

color_a_4
#

color_a_5
#

color_a_6
#

color_a_7
#

color_a_8
#

color_a_9
#

color_b_1
#

color_b_2
#

color_b_3
#

color_b_4
#

color_b_5
#

color_b_6
#

color_b_7
#

color_b_8
#

color_b_9
#

color_c_1
#

color_c_2
#

color_c_3
#

color_c_4
#

color_c_5
#

color_c_6
#

color_c_7
#

color_c_8
#

color_c_9
#

color_d_1
#

color_d_2
#

color_d_3
#

color_d_4
#

color_d_5
#

color_d_6
#

color_d_7
#

color_d_8
#

color_d_9
#

color_e_1
#

color_e_2
#

color_e_3
#

color_e_4
#

color_e_5
#

color_e_6
#

color_e_7
#

color_e_8
#

color_e_9
#

color_f_1
#

color_f_2
#

color_f_3
#

color_f_4
#

color_f_5
#

color_f_6
#

color_f_7
#

color_f_8
#

color_f_9
#

color_g_1
#

color_g_2
#

color_g_3
#

color_g_4
#

color_g_5
#

color_g_6
#

color_g_7
#

color_g_8
#

color_g_9
#

color_h_1
#

color_h_2
#

color_h_3
#

color_h_4
#

color_h_5
#

color_h_6
#

color_h_7
#

color_h_8
#

color_h_9
#

color_i_1
#

color_i_2
#

color_i_3
#

color_i_4
#

color_i_5
#

color_i_6
#

color_i_7
#

color_i_8
#

color_i_9
#

color_j_1
#

color_j_2
#

color_j_3
#

color_j_4
#

color_j_5
#

color_j_6
#

color_j_7
#

color_j_8
#

color_j_9
#

color_schemes
#

color_variants
#

ColorScheme
#

ColorVariant
#

compute_hash
#

css_cache.ts view source

(content: string): Promise<string>

Computes SHA-256 hash of content using Web Crypto API.

content

type string

returns

Promise<string>

create_generation_diagnostic
#

diagnostics.ts view source

(diagnostic: InterpreterDiagnostic, locations: SourceLocation[] | null): GenerationDiagnostic

Converts a InterpreterDiagnostic to a GenerationDiagnostic with locations.

diagnostic

- Interpreter diagnostic to convert

locations

- Source locations where the class was used

type SourceLocation[] | null

returns

GenerationDiagnostic

css_class_composites
#

css_class_definitions
#

css_class_definitions.ts view source

Record<string, CssClassDefinition | undefined>

All built-in CSS class definitions (token classes + composites).

see also

  • ``generate_classes_css``

css_class_interpreters
#

css_class_interpreters.ts view source

CssClassDefinitionInterpreter[]

Collection of all builtin interpreters for dynamic CSS class generation. Order matters: modified_class_interpreter runs first to handle hover:box before css_literal_interpreter tries to interpret it as hover:box (property:value).

CSS_DIRECTIONS
#

css_literal_interpreter
#

css_class_interpreters.ts view source

CssClassDefinitionInterpreter

Interpreter for CSS-literal classes (e.g., display:flex, hover:opacity:80%). Generates full CSS rulesets including any modifier wrappers.

CssClassDefinition
#

CssClassDefinitionBase
#

CssClassDefinitionComposition
#

CssClassDefinitionDeclaration
#

CssClassDefinitionInterpreter
#

css_class_generation.ts view source

CssClassDefinitionInterpreter

Interpreter for dynamic CSS class generation based on pattern matching.

inheritance

pattern

type RegExp

interpret

type (matched: RegExpMatchArray, ctx: CssClassInterpreterContext) => string | null

CssClassDefinitionRuleset
#

CssClassDefinitionStatic
#

CssClasses
#

css_classes.ts view source

Collection of CSS classes extracted from source files. Tracks classes per-file for efficient incremental updates. Handles include/exclude filtering and explicit class tracking. Uses null instead of empty collections to avoid allocation overhead.

constructor

Creates a new CssClasses collection.

type new (include_classes?: Set<string> | null, exclude_classes?: Set<string> | null): CssClasses

include_classes

- Classes to always include (also treated as explicit for warnings)

type Set<string> | null
default null
exclude_classes

- Classes to exclude from output (also suppresses warnings)

type Set<string> | null
default null

add

Adds extraction results for a file. Replaces any previous classes and diagnostics for this file.

type (id: string, classes: Map<string, SourceLocation[]> | null, explicit_classes?: Set<string> | null | undefined, diagnostics?: ExtractionDiagnostic[] | null | undefined): void

id

- File identifier

type string
classes

- Map of class names to their source locations, or null if none

type Map<string, SourceLocation[]> | null
explicit_classes?

- Classes from

type Set<string> | null | undefined
optional
diagnostics?

- Extraction diagnostics from this file, or null if none

type ExtractionDiagnostic[] | null | undefined
optional
returns void

delete

type (id: string): void

id
type string
returns void

get

Gets all unique class names as a Set (with exclude filter applied).

type (): Set<string>

returns Set<string>

get_with_locations

Gets all classes with their source locations (with exclude filter applied). Locations from include_classes are null.

type (): Map<string, SourceLocation[] | null>

returns Map<string, SourceLocation[] | null>

get_all

Gets all classes and their locations in a single call. More efficient than calling get() and get_with_locations() separately when both are needed (avoids potential double recalculation).

Results have exclude filter applied and explicit_classes includes include_classes.

type (): { all_classes: Set<string>; all_classes_with_locations: Map<string, SourceLocation[] | null>; explicit_classes: Set<string> | null; }

returns { all_classes: Set<string>; all_classes_with_locations: Map<string, SourceLocation[] | null>; explicit_classes: Set<string> | null; }

get_diagnostics

Gets all extraction diagnostics from all files.

type (): ExtractionDiagnostic[]

returns ExtractionDiagnostic[]

CssClassInterpreterContext
#

css_class_generation.ts view source

CssClassInterpreterContext

Context passed to CSS class interpreters. Provides access to logging, diagnostics collection, and the class registry.

log

Optional logger for warnings/errors

type Logger

diagnostics

Diagnostics array to collect warnings and errors

type Array<InterpreterDiagnostic>

class_definitions

All known CSS class definitions (token + composite classes)

type Record<string, CssClassDefinition | undefined>

css_properties

Valid CSS properties for literal validation, or null to skip validation

type Set<string> | null

CssDirection
#

CssGenerationError
#

diagnostics.ts view source

Error thrown when CSS generation encounters errors or warnings (depending on on_error and on_warning settings). Contains the full diagnostics array for programmatic access.

inheritance

extends:
  • Error

diagnostics

type Array<Diagnostic>

constructor

type new (diagnostics: Diagnostic[]): CssGenerationError

diagnostics
type Diagnostic[]

CssLiteralOutput
#

css_literal.ts view source

CssLiteralOutput

Information needed to generate CSS output for a CSS-literal class.

declaration

CSS declaration (property: value;)

type string

selector

Full CSS selector including pseudo-classes/elements

type string

media_wrapper

Media query wrapper if any

type string | null

ancestor_wrapper

Ancestor wrapper if any

type string | null

CssLiteralParseResult
#

css_literal.ts view source

CssLiteralParseResult

Result of parsing a CSS-literal class name.

Uses a discriminated union (Result type) because parsing a single class is binary: it either succeeds or fails entirely. This differs from which uses embedded diagnostics because file extraction can partially succeed (some classes extracted, others have errors).

Uses | null for diagnostics to avoid allocating empty arrays. Callers should use a guard pattern: if (result.diagnostics) { ... }

darken_1
#

darken_2
#

darken_3
#

darken_4
#

darken_5
#

darken_6
#

darken_7
#

darken_8
#

darken_9
#

DEFAULT_CACHE_DIR
#

DEFAULT_THEME
#

default_themes
#

default_variables
#

variables.ts view source

StyleVariable[]

These are implicitly the variables for the base theme. See also the empty variables array of the base theme above.

delete_cached_extraction
#

css_cache.ts view source

(cache_path: string): Promise<void>

Deletes a cached extraction file. Silently succeeds if the file doesn't exist.

cache_path

- Absolute path to the cache file

type string

returns

Promise<void>

demo_class
#

DEMO_CLASS
#

demo_class_list
#

demo_class_lists
#

demo_class_name
#

demo_class_names
#

demo_classes
#

demoClass
#

demoClasses
#

demoClassList
#

demoClassLists
#

demoClassName
#

demoClassNames
#

Diagnostic
#

disabled_opacity
#

distance_lg
#

distance_md
#

distance_sm
#

distance_variants
#

distance_xl
#

distance_xs
#

DistanceVariant
#

duration_1
#

duration_2
#

duration_3
#

duration_4
#

duration_5
#

duration_6
#

escape_css_selector
#

css_class_generation.ts view source

(name: string): string

Escapes special characters in a CSS class name for use in a selector. CSS selectors require escaping of characters like :, %, (, ), etc.

name

type string

returns

string

examples

Example 1

extract_and_validate_modifiers
#

css_literal.ts view source

(segments: string[], class_name: string): ModifierExtractionResult

Extracts and validates modifiers from the beginning of a segments array. Modifiers are consumed from the front until a non-modifier segment is found.

Used by both CSS-literal parsing and modified class interpretation.

segments

- Array of colon-separated segments

type string[]

class_name

- Original class name for error messages

type string

returns

ModifierExtractionResult

ModifierExtractionResult with modifiers and remaining segments, or error

extract_css_classes
#

css_class_extractor.ts view source

(source: string, options?: ExtractCssClassesOptions): Set<string>

Unified extraction function that auto-detects file type. Returns just the class names as a Set.

source

- The file source code

type string

options

- Extraction options

default {}

returns

Set<string>

Set of class names

extract_css_classes_with_locations
#

css_class_extractor.ts view source

(source: string, options?: ExtractCssClassesOptions): ExtractionResult

Unified extraction function that auto-detects file type. Returns full extraction result with locations and diagnostics.

source

- The file source code

type string

options

- Extraction options

default {}

returns

ExtractionResult

Full extraction result with classes, tracked variables, and diagnostics

extract_css_comment
#

css_ruleset_parser.ts view source

(css: string, rules: ParsedRule[]): string | null

Extracts the CSS comment from a ruleset (if any). Looks for comments before the first rule.

css

- Raw CSS string

type string

rules

- Parsed rules

type ParsedRule[]

returns

string | null

Comment text without delimiters, or null if no comment

extract_from_svelte
#

css_class_extractor.ts view source

(source: string, file?: string): ExtractionResult

Extracts CSS classes from a Svelte file using AST parsing.

source

- The Svelte file source code

type string

file

- File path for location tracking

type string
default '<unknown>'

returns

ExtractionResult

Extraction result with classes, tracked variables, and diagnostics

extract_from_ts
#

css_class_extractor.ts view source

(source: string, file?: string, acorn_plugins?: AcornPlugin[] | undefined): ExtractionResult

Extracts CSS classes from a TypeScript/JS file using AST parsing.

source

- The TS/JS file source code

type string

file

- File path for location tracking

type string
default '<unknown>'

acorn_plugins?

- Additional acorn plugins (e.g., acorn-jsx for React)

type AcornPlugin[] | undefined
optional

returns

ExtractionResult

Extraction result with classes, tracked variables, and diagnostics

extract_segments
#

css_literal.ts view source

(class_name: string): string[]

Extracts colon-separated segments from a class name, handling parentheses. Parenthesized content (like function arguments) is kept intact.

class_name

type string

returns

string[]

examples

Example 1

ExtractCssClassesOptions
#

css_class_extractor.ts view source

ExtractCssClassesOptions

Options for CSS class extraction.

filename

File path used to determine extraction method (Svelte vs TS) and for location tracking in diagnostics.

type string

acorn_plugins

Additional acorn plugins to use when parsing TS/JS files. Useful for adding JSX support via acorn-jsx for React projects.

type Array<AcornPlugin>

ExtractedModifiers
#

css_literal.ts view source

ExtractedModifiers

Extracted modifiers from a class name. Used by both CSS-literal parsing and modified class interpretation.

media

Media modifier (breakpoint or feature query)

type ModifierDefinition | null

ancestor

Ancestor modifier (dark/light)

type ModifierDefinition | null

states

State modifiers in alphabetical order (can have multiple)

type Array<ModifierDefinition>

pseudo_element

Pseudo-element modifier (before, after, etc.)

type ModifierDefinition | null

ExtractionDiagnostic
#

ExtractionResult
#

css_class_extractor.ts view source

ExtractionResult

Extraction result with classes mapped to their source locations. Uses null instead of empty collections to avoid allocation overhead.

Uses embedded diagnostics (rather than a Result type) because file extraction can partially succeed: some classes may be extracted while others produce errors. This differs from which uses a discriminated union because single-class parsing is binary success/failure.

classes

Map from class name to locations where it was used, or null if none. Keys = unique classes, values = locations for diagnostics/IDE integration.

type Map<string, Array<SourceLocation>> | null

explicit_classes

Classes explicitly annotated via @fuz-classes comments, or null if none. These should produce warnings if they can't be resolved during generation.

type Set<string> | null

tracked_vars

Variables that were used in class contexts, or null if none

type Set<string> | null

diagnostics

Diagnostics from the extraction phase, or null if none

type Array<ExtractionDiagnostic> | null

fg
#

fg_0
#

fg_1
#

fg_10
#

fg_2
#

fg_3
#

fg_4
#

fg_5
#

fg_6
#

fg_7
#

fg_8
#

fg_9
#

FileFilter
#

fill
#

fill_a
#

fill_b
#

fill_c
#

fill_d
#

fill_e
#

fill_f
#

fill_g
#

fill_h
#

fill_i
#

fill_j
#

filter_file_default
#

file_filter.ts view source

(path: string): boolean

Default file filter for CSS class extraction. Includes .svelte, .html, .ts, .js, .tsx, .jsx files. Excludes test files and generated files.

path

type string

returns

boolean

find_compound_end
#

css_ruleset_parser.ts view source

(selector: string, class_pos: number): number

Finds the end position of the compound selector containing the class at class_pos. A compound selector is a sequence of simple selectors without combinators.

selector

- The CSS selector string

type string

class_pos

- Position of the . in .class_name

type number

returns

number

Position where state modifiers should be inserted (before any pseudo-element)

font_family_mono
#

font_family_sans
#

font_family_serif
#

font_family_variants
#

font_size_lg
#

font_size_md
#

font_size_names
#

font_size_sm
#

font_size_variants
#

font_size_xl
#

font_size_xl2
#

font_size_xl3
#

font_size_xl4
#

font_size_xl5
#

font_size_xl6
#

font_size_xl7
#

font_size_xl8
#

font_size_xl9
#

font_size_xs
#

FontFamilyVariant
#

format_css_value
#

css_literal.ts view source

(value: string): string

Formats a CSS-literal value for CSS output. - Replaces ~ with space - Ensures space before !important

value

- Raw value from class name

type string

returns

string

Formatted CSS value

format_diagnostic
#

format_dimension_value
#

css_class_generators.ts view source

(value: string): string

Format width/height values for CSS (handles 0, auto, percentages, pixels, content values, and CSS variables). Used by width and height properties.

value

type string

returns

string

format_spacing_value
#

css_class_generators.ts view source

(value: string): string

Format spacing values for CSS (handles 0, auto, percentages, pixels, and CSS variables). Used by margin, padding, gap, inset, top/right/bottom/left, etc.

value

type string

returns

string

format_variable_name
#

from_cached_extraction
#

css_cache.ts view source

(cached: CachedExtraction): { classes: Map<string, SourceLocation[]> | null; explicit_classes: Set<string> | null; diagnostics: ExtractionDiagnostic[] | null; }

Converts a cached extraction back to the runtime format. Preserves null semantics (null = empty).

cached

- Cached extraction data

returns

{ classes: Map<string, SourceLocation[]> | null; explicit_classes: Set<string> | null; diagnostics: ExtractionDiagnostic[] | null; }

fromComment
#

FUZ_CSS_MARKER
#

gen_fuz_css
#

generate_border_radius_corners
#

css_class_generators.ts view source

(values: Iterable<string>, formatter?: ((value: string) => string) | undefined): Record<string, CssClassDefinition>

Generate border radius corner classes for all four corners. Creates classes for top-left, top-right, bottom-left, bottom-right corners.

values

- The values to generate classes for

type Iterable<string>

formatter?

- Optional function to format values

type ((value: string) => string) | undefined
optional

returns

Record<string, CssClassDefinition>

generate_classes
#

css_class_generators.ts view source

<T1 = string, T2 = string, T3 = string>(template: ClassTemplateFn<T1, T2, T3>, values: Iterable<T1>, secondary?: Iterable<T2> | undefined, tertiary?: Iterable<...> | undefined): Record<...>

Generates CSS class declarations from templates. Supports up to 3 dimensions of multiplicative combinations.

template

- Function that generates CSS from values, can return null to skip

type ClassTemplateFn<T1, T2, T3>

values

- Primary iterable of values

type Iterable<T1>

secondary?

- Optional second dimension (makes it multiplicative)

type Iterable<T2> | undefined
optional

tertiary?

- Optional third dimension for even more combinations

type Iterable<T3> | undefined
optional

returns

Record<string, CssClassDefinition>

examples

Example 1
Example 2

generate_classes_css
#

generate_css_literal_simple
#

css_literal.ts view source

(output: CssLiteralOutput): string

Generates simple CSS for a CSS-literal class (without grouping). Used by the interpreter for basic output.

output

- The CSS-literal output info

returns

string

CSS string for this class

generate_declaration
#

generate_directional_classes
#

css_class_generators.ts view source

(property: string, values: Iterable<string>, formatter?: ((v: string) => string) | undefined): Record<string, CssClassDefinition>

Generate directional classes for properties like margin and padding. Creates classes for all directions: base, top, right, bottom, left, x (horizontal), y (vertical).

property

- The base CSS property name (e.g. 'margin', 'padding')

type string

values

- The values to generate classes for

type Iterable<string>

formatter?

- Optional function to format values (defaults to identity)

type ((v: string) => string) | undefined
optional

returns

Record<string, CssClassDefinition>

generate_modified_ruleset
#

css_ruleset_parser.ts view source

(original_ruleset: string, original_class: string, new_class_escaped: string, state_css: string, pseudo_element_css: string, media_wrapper: string | null, ancestor_wrapper: string | null): ModifiedRulesetResult

Generates CSS for a modified ruleset with applied modifiers.

Conflict handling is per-selector within selector lists: - For .plain:hover, .plain:active with hover: modifier, only .plain:hover skips the :hover addition; .plain:active still gets :hover appended. - For multiple states like :hover:focus, each is checked individually; conflicting states are skipped while non-conflicting ones are still applied.

original_ruleset

- The original CSS ruleset string

type string

original_class

- The base class name

type string

new_class_escaped

- The escaped new class name with modifiers

type string

state_css

- State modifier CSS (e.g., ":hover" or ":hover:focus")

type string

pseudo_element_css

- Pseudo-element modifier CSS (e.g., "::before")

type string

media_wrapper

- Media query wrapper (e.g., "@media (width >= 48rem)")

type string | null

ancestor_wrapper

- Ancestor wrapper (e.g., ":root.dark")

type string | null

returns

ModifiedRulesetResult

Result with generated CSS and information about skipped modifiers

generate_property_classes
#

css_class_generators.ts view source

(property: string, values: Iterable<string>, formatter?: ((value: string) => string) | undefined, prefix?: string): Record<string, CssClassDefinition>

Generate classes for a single CSS property with various values.

property

- The CSS property name (e.g. 'font-size', 'gap')

type string

values

- The values to generate classes for

type Iterable<string>

formatter?

- Optional function to format values (e.g. v => var(--space_${v}))

type ((value: string) => string) | undefined
optional

prefix

- Optional class name prefix (defaults to property with dashes replaced by underscores)

type string
default format_variable_name(property)

returns

Record<string, CssClassDefinition>

generate_selector
#

css_literal.ts view source

(escaped_class_name: string, parsed: ParsedCssLiteral): string

Generates the CSS selector for a parsed CSS-literal class. Includes state pseudo-classes and pseudo-element in the selector.

escaped_class_name

type string

parsed

returns

string

generate_shadow_classes
#

css_class_generators.ts view source

(sizes: Iterable<string>, alpha_mapping: Record<string, string>): Record<string, CssClassDefinition>

Generate shadow classes for various shadow types and sizes. Creates classes for regular, top, bottom, inset, inset-top, and inset-bottom shadows. Each shadow uses color-mix with alpha values for transparency.

sizes

- The shadow size variants (xs, sm, md, lg, xl)

type Iterable<string>

alpha_mapping

- Mapping of sizes to alpha numbers (1-5)

type Record<string, string>

returns

Record<string, CssClassDefinition>

GenerateClassesCssOptions
#

css_class_generation.ts view source

GenerateClassesCssOptions

class_names

type Iterable<string>

class_definitions

type Record<string, CssClassDefinition | undefined>

interpreters

type Array<CssClassDefinitionInterpreter>

css_properties

Valid CSS properties for literal validation, or null to skip validation

type Set<string> | null

log

type Logger

class_locations

type Map<string, Array<SourceLocation> | null>

explicit_classes

Classes that were explicitly annotated (via

type Set<string> | null

GenerateClassesCssResult
#

GeneratedClassResult
#

GenerationDiagnostic
#

diagnostics.ts view source

GenerationDiagnostic

Diagnostic from the generation phase.

phase

type 'generation'

level

type 'error' | 'warning'

message

type string

suggestion

type string | null

class_name

type string

locations

Source locations where this class was used, or null if from include_classes

type Array<SourceLocation> | null

GenFuzCssOptions
#

gen_fuz_css.ts view source

GenFuzCssOptions

filter_file

include_stats

type boolean

class_definitions

Additional class definitions to merge with defaults. User definitions take precedence over defaults with the same name. Required when include_default_definitions is false.

type Record<string, CssClassDefinition | undefined>

include_default_definitions

Whether to include default class definitions (token and composite classes). When false, class_definitions is required.

type boolean

class_interpreters

Custom interpreters for dynamic class generation. Replaces the builtin interpreters entirely if provided.

type Array<CssClassDefinitionInterpreter>

on_error

How to handle CSS-literal errors during generation. - 'log': Log errors, skip invalid classes, continue - 'throw': Throw on first error, fail the build

type 'log' | 'throw'

on_warning

How to handle warnings during generation. - 'log': Log warnings, continue - 'throw': Throw on first warning, fail the build - 'ignore': Suppress warnings entirely

type 'log' | 'throw' | 'ignore'

include_classes

Classes to always include in the output, regardless of whether they're detected in source files. Useful for dynamically generated class names that can't be statically extracted.

type Iterable<string>

exclude_classes

Classes to exclude from the output, even if they're detected in source files. Useful for filtering out false positives from extraction.

type Iterable<string>

cache_dir

Cache directory relative to project_root.

type string

project_root

Project root directory. Source paths must be under this directory.

type string

concurrency

Max concurrent file processing (cache read + extract). Bottlenecked by CPU-bound AST parsing.

type number

cache_io_concurrency

Max concurrent cache writes and deletes (I/O-bound).

type number

acorn_plugins

Additional acorn plugins to use when parsing TS/JS files. Useful for adding JSX support via acorn-jsx for React projects.

type Array<AcornPlugin>

get_all_modifier_names
#

get_cache_path
#

css_cache.ts view source

(source_path: string, cache_dir: string, project_root: string): string

Computes the cache file path for a source file. Cache structure mirrors source tree: src/lib/Foo.svelte → .fuz/cache/css/src/lib/Foo.svelte.json

source_path

- Absolute path to the source file

type string

cache_dir

- Absolute path to the cache directory

type string

project_root

- Normalized project root (must end with /)

type string

returns

string

get_modifier
#

modifiers.ts view source

(segment: string): (ModifierDefinition & { is_arbitrary?: boolean | undefined; }) | null

Gets the modifier definition for a segment. Handles both static modifiers and dynamic patterns (arbitrary breakpoints, parameterized states).

segment

type string

returns

(ModifierDefinition & { is_arbitrary?: boolean | undefined; }) | null

The modifier definition or null if not a known modifier

has_extracted_modifiers
#

css_literal.ts view source

(modifiers: ExtractedModifiers): boolean

Checks if extracted modifiers contain any modifier. Useful for tooling that needs to detect modified classes.

modifiers

returns

boolean

has_modifiers
#

hue_a
#

hue_b
#

hue_c
#

hue_d
#

hue_e
#

hue_f
#

hue_g
#

hue_h
#

hue_i
#

hue_j
#

icon_size_lg
#

icon_size_md
#

icon_size_sm
#

icon_size_variants
#

icon_size_xl
#

icon_size_xl2
#

icon_size_xl3
#

icon_size_xs
#

icon_sizes
#

variable_data.ts view source

{ icon_size_xs: string; icon_size_sm: string; icon_size_md: string; icon_size_lg: string; icon_size_xl: string; icon_size_xl2: string; icon_size_xl3: string; }

IconSizeVariant
#

input_fill
#

input_height
#

input_height_inner
#

input_height_sm
#

input_padding_x
#

input_padding_y
#

input_width_min
#

intensity_variants
#

IntensityVariant
#

interpret_css_literal
#

css_literal.ts view source

(class_name: string, escaped_class_name: string, css_properties: Set<string> | null): InterpretCssLiteralResult

Interprets a CSS-literal class and returns CSS generation info.

Callers should first check is_possible_css_literal() to filter non-CSS-literal classes.

class_name

- The class name to interpret

type string

escaped_class_name

- The CSS-escaped version of the class name

type string

css_properties

- Set of valid CSS properties from load_css_properties(). Pass null to skip property validation.

type Set<string> | null

returns

InterpretCssLiteralResult

Result with output and warnings on success, or error on failure

InterpretCssLiteralResult
#

css_literal.ts view source

InterpretCssLiteralResult

Result of interpreting a CSS-literal class.

Uses | null for warnings to avoid allocating empty arrays. Callers should use a guard pattern: if (result.warnings) { ... }

InterpreterDiagnostic
#

diagnostics.ts view source

InterpreterDiagnostic

Diagnostic from CSS class interpretation. Used internally by interpreters; converted to GenerationDiagnostic with locations.

level

type 'error' | 'warning'

message

type string

class_name

type string

suggestion

type string | null

is_possible_css_literal
#

css_literal.ts view source

(class_name: string): boolean

Checks if a class name could be a CSS-literal class. Quick check before attempting full parse.

class_name

- The class name to check

type string

returns

boolean

True if it could be CSS-literal syntax

is_single_selector_ruleset
#

css_ruleset_parser.ts view source

(rules: ParsedRule[], escaped_class_name: string): boolean

Checks if a ruleset has only a single simple selector (just the class name). Used to detect rulesets that could be converted to declaration format.

rules

- Parsed rules from the ruleset

type ParsedRule[]

escaped_class_name

- The CSS-escaped class name (e.g., "box" or "hover\\:card")

type string

returns

boolean

True if there's exactly one rule with selector ".class_name"

is_style_variable_name
#

is_valid_css_property
#

css_literal.ts view source

(property: string, properties: Set<string> | null): boolean

Checks if a property name is a valid CSS property. Custom properties (--*) always return true.

property

- The CSS property name to validate

type string

properties

- Set of valid CSS properties from load_css_properties(). Pass null to skip validation.

type Set<string> | null

returns

boolean

True if valid CSS property or custom property

lighten_1
#

lighten_2
#

lighten_3
#

lighten_4
#

lighten_5
#

lighten_6
#

lighten_7
#

lighten_8
#

lighten_9
#

line_height_lg
#

line_height_md
#

line_height_names
#

line_height_sm
#

line_height_variants
#

line_height_xl
#

line_height_xs
#

LineHeightVariant
#

link_color
#

link_color_selected
#

LiteralResolutionResult
#

load_cached_extraction
#

css_cache.ts view source

(cache_path: string): Promise<CachedExtraction | null>

Loads a cached extraction result from disk. Returns null if the cache is missing, corrupted, or has a version mismatch. This makes the cache self-healing: any error triggers re-extraction.

cache_path

- Absolute path to the cache file

type string

returns

Promise<CachedExtraction | null>

load_css_properties
#

logicalClass
#

MEDIA_MODIFIERS
#

modified_class_interpreter
#

css_class_interpreters.ts view source

CssClassDefinitionInterpreter

Interpreter for modified token/composite classes (e.g., hover:p_md, md:box, dark:hover:panel). Applies modifiers to existing declaration-based or ruleset-based classes.

This interpreter must run BEFORE css_literal_interpreter to handle cases like hover:box where box is a known class (not a CSS property).

ModifiedRulesetResult
#

css_ruleset_parser.ts view source

ModifiedRulesetResult

Result from generating a modified ruleset.

Uses | null for skipped_modifiers to avoid allocating empty arrays. Callers should use a guard pattern: if (result.skipped_modifiers) { ... }

css

The generated CSS

type string

skipped_modifiers

Information about modifiers that were skipped for certain rules, or null if none

type Array<SkippedModifierInfo> | null

ModifiedSelectorGroupResult
#

css_ruleset_parser.ts view source

ModifiedSelectorGroupResult

Result from modifying a selector group with conflict detection.

Uses | null for skipped_modifiers to avoid allocating empty arrays. Callers should use a guard pattern: if (result.skipped_modifiers) { ... }

selector

The modified selector list as a string

type string

skipped_modifiers

Information about modifiers skipped for specific selectors, or null if none

type Array<SkippedModifierInfo> | null

ModifierDefinition
#

modifiers.ts view source

ModifierDefinition

Definition for a single modifier.

name

The prefix used in class names (e.g., 'hover', 'md', 'dark')

type string

type

Type determines position in modifier order and CSS output behavior

css

The CSS output - wrapper for media/ancestor, suffix for state/pseudo-element

type string

order

Optional ordering within type (for breakpoints, sorted by this value)

type number

ModifierExtractionResult
#

MODIFIERS
#

modifiers.ts view source

ModifierDefinition[]

All modifier definitions in a single declarative structure. Adding a new modifier requires only adding to this array.

ModifierType
#

modifiers.ts view source

ModifierType

Type of modifier determining its position in the class name and CSS output.

Order in class names: [media:][ancestor:][state...:][pseudo-element:]property:value

modify_selector_group
#

css_ruleset_parser.ts view source

(selector_group: string, original_class: string, new_class_escaped: string, states_to_add: string[], pseudo_element_css: string): ModifiedSelectorGroupResult

Modifies a selector list (comma-separated selectors) to add modifiers. Handles conflicts per-selector: if one selector in a list has a conflict, only that selector skips the modifier; other selectors still get it.

selector_group

- CSS selector list (may contain commas)

type string

original_class

- The base class name

type string

new_class_escaped

- The escaped new class name

type string

states_to_add

- Individual state modifiers (e.g., [":hover", ":focus"])

type string[]

pseudo_element_css

- Pseudo-element modifier CSS to insert (e.g., "::before")

type string

returns

ModifiedSelectorGroupResult

Result with modified selector list and information about skipped modifiers

modify_single_selector
#

css_ruleset_parser.ts view source

(selector: string, original_class: string, new_class_escaped: string, state_css: string, pseudo_element_css: string): string

Modifies a single CSS selector to add modifiers.

selector

- A single CSS selector (not a selector list)

type string

original_class

- The base class name (e.g., "menu_item")

type string

new_class_escaped

- The escaped new class name (e.g., "hover\\:menu_item")

type string

state_css

- State modifier CSS to insert (e.g., ":hover")

type string

pseudo_element_css

- Pseudo-element modifier CSS to insert (e.g., "::before")

type string

returns

string

Modified selector

examples

Example 1

NTH_CHILD_PATTERN
#

NTH_LAST_CHILD_PATTERN
#

NTH_LAST_OF_TYPE_PATTERN
#

NTH_OF_TYPE_PATTERN
#

objectClasses
#

outline_color
#

outline_style
#

outline_width
#

outline_width_active
#

outline_width_focus
#

outline_width_variants
#

OutlineWidthVariant
#

parse_arbitrary_breakpoint
#

modifiers.ts view source

(segment: string): string | null

Parses an arbitrary breakpoint modifier.

segment

type string

returns

string | null

The CSS media query or null if not an arbitrary breakpoint

parse_css_literal
#

css_literal.ts view source

(class_name: string, css_properties: Set<string> | null): CssLiteralParseResult

Parses a CSS-literal class name into its components.

class_name

- The class name to parse

type string

css_properties

- Set of valid CSS properties from load_css_properties(). Pass null to skip property validation.

type Set<string> | null

returns

CssLiteralParseResult

CssLiteralParseResult with parsed data or error

parse_parameterized_state
#

modifiers.ts view source

(segment: string): { name: string; css: string; type: "state"; } | null

Parses a parameterized state modifier (nth-child, nth-last-child, nth-of-type, nth-last-of-type).

segment

type string

returns

{ name: string; css: string; type: "state"; } | null

Object with name (including parameter) and CSS, or null if not parameterized

parse_ruleset
#

css_ruleset_parser.ts view source

(css: string): ParsedRuleset

Parses a CSS ruleset string using Svelte's CSS parser.

css

- Raw CSS string (e.g., ".box { display: flex; }")

type string

returns

ParsedRuleset

ParsedRuleset with structured rule data and positions

ParsedCssLiteral
#

css_literal.ts view source

ParsedCssLiteral

Parsed CSS-literal class with all components extracted.

class_name

Original class name

type string

media

Media modifier (breakpoint or feature query)

type ModifierDefinition | null

ancestor

Ancestor modifier (dark/light)

type ModifierDefinition | null

states

State modifiers in alphabetical order (can have multiple)

type Array<ModifierDefinition>

pseudo_element

Pseudo-element modifier (before, after, etc.)

type ModifierDefinition | null

property

CSS property name

type string

value

CSS value (with ~ replaced by spaces)

type string

ParsedRule
#

css_ruleset_parser.ts view source

ParsedRule

A parsed CSS rule with its components and positions.

selector

Full selector string (e.g., ".box", ".selectable:hover")

type string

selector_start

Start position of selector in original CSS (0-indexed, relative to style wrapper)

type number

selector_end

End position of selector in original CSS

type number

declarations

The declarations block (without braces)

type string

rule_start

Start position of the entire rule

type number

rule_end

End position of the entire rule

type number

ParsedRuleset
#

css_ruleset_parser.ts view source

ParsedRuleset

Result of parsing a CSS ruleset.

rules

All rules in the ruleset

type Array<ParsedRule>

wrapper_offset

The offset added by the <style> wrapper (characters before actual CSS)

type number

PSEUDO_ELEMENT_MODIFIERS
#

render_theme_style
#

render_theme_variable
#

theme.ts view source

(variable: StyleVariable, dark?: boolean, comments?: boolean): string

variable

dark

type boolean
default false

comments

type boolean
default true

returns

string

RenderThemeStyleOptions
#

theme.ts view source

RenderThemeStyleOptions

comments

type boolean

id

type string | null

empty_default_theme

type boolean

specificity

Repeats the theme selector to handle unpredictable head content insertion order. Accepts any integer >= 1, defaults to 2.

type number

resolve_class_definition
#

css_class_resolution.ts view source

(def: CssClassDefinitionStatic, class_name: string, definitions: Record<string, CssClassDefinition | undefined>, css_properties?: Set<...> | null): ResolveComposesResult

Resolves a class definition's declaration, handling composes composition.

If the definition has a composes property, resolves those classes recursively and combines with any explicit declaration. If no composes, returns the explicit declaration directly.

def

- The class definition to resolve

class_name

- The name of the class being resolved (for error messages)

type string

definitions

- Record of all known class definitions

type Record<string, CssClassDefinition | undefined>

css_properties

- Set of valid CSS properties for literal validation, or null to skip

type Set<string> | null
default null

returns

ResolveComposesResult

Combined declaration or an error

resolve_composes
#

css_class_resolution.ts view source

(class_names: string[], definitions: Record<string, CssClassDefinition | undefined>, resolution_stack: Set<string>, visited: Set<string>, original_class_name: string, css_properties?: Set<...> | null): ResolveComposesResult

Resolves an array of class names to their combined CSS declarations.

Recursively resolves nested composes arrays and combines all declarations. Validates that referenced classes exist and are resolvable (not rulesets or interpreters). Supports unmodified CSS literals (e.g., text-align:center) in the composes array.

Deduplication behavior: - Diamond dependencies (class reached via different composition branches) are silently skipped - Redundant listings (class already included by an earlier sibling in this array) emit a warning

class_names

- Array of class names to resolve

type string[]

definitions

- Record of all known class definitions

type Record<string, CssClassDefinition | undefined>

resolution_stack

- Set of class names currently being resolved (for cycle detection)

type Set<string>

visited

- Set of all class names already resolved (for deduplication)

type Set<string>

original_class_name

- The class name being defined (for error messages)

type string

css_properties

- Set of valid CSS properties for literal validation, or null to skip

type Set<string> | null
default null

returns

ResolveComposesResult

Combined declarations or an error

ResolveComposesResult
#

ruleset_contains_class
#

css_ruleset_parser.ts view source

(rules: ParsedRule[], escaped_class_name: string): boolean

Checks if any selector in the ruleset contains the expected class name. Used to validate that ruleset definitions match their key.

rules

- Parsed rules from the ruleset

type ParsedRule[]

escaped_class_name

- The CSS-escaped class name (e.g., "clickable" or "hover\\:card")

type string

returns

boolean

True if at least one selector contains ".class_name"

save_cached_extraction
#

css_cache.ts view source

(cache_path: string, content_hash: string, classes: Map<string, SourceLocation[]> | null, explicit_classes: Set<string> | null, diagnostics: ExtractionDiagnostic[] | null): Promise<...>

Saves an extraction result to the cache. Uses atomic write (temp file + rename) for crash safety. Converts empty arrays to null to avoid allocation overhead on load.

cache_path

- Absolute path to the cache file

type string

content_hash

- SHA-256 hash of the source file contents

type string

classes

- Extracted classes with their locations, or null if none

type Map<string, SourceLocation[]> | null

explicit_classes

- Classes from

type Set<string> | null

diagnostics

- Extraction diagnostics, or null if none

type ExtractionDiagnostic[] | null

returns

Promise<void>

shadow_alpha_1
#

shadow_alpha_2
#

shadow_alpha_3
#

shadow_alpha_4
#

shadow_alpha_5
#

shadow_alpha_variants
#

shadow_bottom_lg
#

shadow_bottom_md
#

shadow_bottom_sm
#

shadow_bottom_xl
#

shadow_bottom_xs
#

shadow_color
#

shadow_color_a
#

shadow_color_b
#

shadow_color_c
#

shadow_color_d
#

shadow_color_e
#

shadow_color_f
#

shadow_color_g
#

shadow_color_glow
#

shadow_color_h
#

shadow_color_highlight
#

shadow_color_i
#

shadow_color_j
#

shadow_color_shroud
#

shadow_inset_bottom_lg
#

shadow_inset_bottom_md
#

shadow_inset_bottom_sm
#

shadow_inset_bottom_xl
#

shadow_inset_bottom_xs
#

shadow_inset_lg
#

shadow_inset_md
#

shadow_inset_sm
#

shadow_inset_top_lg
#

shadow_inset_top_md
#

shadow_inset_top_sm
#

shadow_inset_top_xl
#

shadow_inset_top_xs
#

shadow_inset_xl
#

shadow_inset_xs
#

shadow_lg
#

shadow_md
#

shadow_semantic_values
#

shadow_size_variants
#

shadow_sm
#

shadow_top_lg
#

shadow_top_md
#

shadow_top_sm
#

shadow_top_xl
#

shadow_top_xs
#

shadow_variant_prefixes
#

variable_data.ts view source

readonly ["shadow_", "shadow_top_", "shadow_bottom_", "shadow_inset_", "shadow_inset_top_", "shadow_inset_bottom_"]

shadow_xl
#

shadow_xs
#

ShadowAlphaVariant
#

ShadowSemanticValue
#

ShadowSizeVariant
#

SizeVariant
#

SkippedModifierInfo
#

css_ruleset_parser.ts view source

SkippedModifierInfo

Information about a modifier that was skipped for a selector during ruleset modification. The selector is still included in output, just without the conflicting modifier applied.

selector

The specific selector where the modifier was skipped (not the full selector list)

type string

reason

Reason the modifier was skipped

type 'pseudo_element_conflict' | 'state_conflict'

conflicting_modifier

The conflicting modifier that was not applied (e.g., "::before" or ":hover")

type string

SourceIndex
#

css_class_extractor.ts view source

Helper class for converting character offsets to line/column positions. Svelte template nodes (Comment, Text, ExpressionTag) only have char offsets, so this class enables efficient conversion.

Build: O(n) where n = source length Lookup: O(log m) where m = number of lines (binary search)

line_starts

type Array<number>

private

constructor

type new (source: string): SourceIndex

source
type string

get_location

Converts a character offset to a source location.

type (offset: number, file: string): SourceLocation

offset

- 0-based character offset in the source

type number
file

- File path for the location

type string

SourceLocation with 1-based line and column

SourceLocation
#

diagnostics.ts view source

SourceLocation

Source location for IDE/LSP integration.

file

type string

line

1-based line number

type number

column

1-based column number

type number

space_lg
#

space_md
#

space_sm
#

space_variants
#

variable_data.ts view source

readonly ["xs5", "xs4", "xs3", "xs2", "xs", "sm", "md", "lg", "xl", "xl2", "xl3", "xl4", "xl5", "xl6", "xl7", "xl8", "xl9", "xl10", "xl11", "xl12", "xl13", "xl14", "xl15"]

space_xl
#

space_xl10
#

space_xl11
#

space_xl12
#

space_xl13
#

space_xl14
#

space_xl15
#

space_xl2
#

space_xl3
#

space_xl4
#

space_xl5
#

space_xl6
#

space_xl7
#

space_xl8
#

space_xl9
#

space_xs
#

space_xs2
#

space_xs3
#

space_xs4
#

space_xs5
#

SpaceVariant
#

variable_data.ts view source

"xs" | "sm" | "md" | "lg" | "xl" | "xl2" | "xl3" | "xl4" | "xl5" | "xl6" | "xl7" | "xl8" | "xl9" | "xs5" | "xs4" | "xs3" | "xs2" | "xl10" | "xl11" | "xl12" | "xl13" | "xl14" | "xl15"

split_selector_list
#

css_ruleset_parser.ts view source

(selector_group: string): string[]

Splits a selector list by commas, respecting parentheses, brackets, and quoted strings.

selector_group

type string

returns

string[]

examples

Example 1

STATE_MODIFIERS
#

STYLE_VARIABLE_NAME_MATCHER
#

StyleVariable
#

StyleVariableName
#

suggest_css_property
#

css_literal.ts view source

(typo: string, properties: Set<string> | null): string | null

Suggests a correct property name for a typo using Levenshtein distance.

typo

- The mistyped property name

type string

properties

- Set of valid CSS properties from load_css_properties(). Pass null to skip suggestions.

type Set<string> | null

returns

string | null

The suggested property or null if no close match (Levenshtein distance > 2)

suggest_modifier
#

css_literal.ts view source

(typo: string): string | null

Suggests a correct modifier name for a typo using Levenshtein distance.

typo

- The mistyped modifier name

type string

returns

string | null

The suggested modifier or null if no close match (Levenshtein distance > 2)

ternaryClass
#

text_active
#

text_color
#

text_color_0
#

text_color_1
#

text_color_10
#

text_color_2
#

text_color_3
#

text_color_4
#

text_color_5
#

text_color_6
#

text_color_7
#

text_color_8
#

text_color_9
#

text_color_disabled
#

text_color_variants
#

text_decoration
#

text_decoration_hover
#

text_decoration_selected
#

TextColorVariant
#

Theme
#

tint_hue
#

tint_saturation
#

try_resolve_literal
#

css_literal.ts view source

(class_name: string, css_properties: Set<string> | null, context_class_name: string): LiteralResolutionResult

Attempts to resolve a class name as an unmodified CSS literal for composition.

Used by resolve_composes to support literals in composes arrays. Returns the declaration if successful, null if not a literal, or an error if it's a literal with issues (modifiers, invalid property, etc.).

class_name

- The class name to try resolving

type string

css_properties

- Set of valid CSS properties, or null to skip validation

type Set<string> | null

context_class_name

- The class being defined (for error messages)

type string

returns

LiteralResolutionResult

Resolution result with declaration, or error, or null if not a literal

vite_plugin_fuz_css
#

vite_plugin_fuz_css.ts view source

(options?: VitePluginFuzCssOptions): Plugin$1<any>

Creates the fuz_css Vite plugin.

Extracts CSS classes from source files during Vite's transform phase and generates optimized CSS via the virtual:fuz.css virtual module.

options

default {}

returns

Plugin$1<any>

VitePluginFuzCssOptions
#

vite_plugin_fuz_css.ts view source

VitePluginFuzCssOptions

Options for the fuz_css Vite plugin.

filter_file

Filter function to determine which files to extract classes from. By default, extracts from .svelte, .html, .ts, .js, .tsx, .jsx files, excluding test files and .gen files.

class_definitions

Additional class definitions to merge with defaults. User definitions take precedence over defaults with the same name. Required when include_default_definitions is false.

type Record<string, CssClassDefinition | undefined>

include_default_definitions

Whether to include default class definitions (token and composite classes). When false, class_definitions is required.

type boolean

class_interpreters

Custom interpreters for dynamic class generation. Replaces the builtin interpreters entirely if provided.

type Array<CssClassDefinitionInterpreter>

include_classes

Classes to always include in the output, regardless of detection.

type Iterable<string>

exclude_classes

Classes to exclude from the output, even if detected.

type Iterable<string>

acorn_plugins

Additional acorn plugins for parsing. Use acorn-jsx for React/Preact/Solid projects.

type Array<AcornPlugin>

on_error

How to handle CSS-literal errors during generation. - 'log': Log errors, skip invalid classes, continue - 'throw': Throw on first error, fail the build

type 'log' | 'throw'

on_warning

How to handle warnings during generation. - 'log': Log warnings, continue - 'throw': Throw on first warning, fail the build - 'ignore': Suppress warnings entirely

type 'log' | 'throw' | 'ignore'

cache_dir

Cache directory relative to project root.

type string

Z_INDEX_MAX
#