css_bundled_resolution.ts

CSS resolution algorithm for bundled CSS generation.

Combines theme variables, base styles, and utility classes into a single bundled output. Resolves which CSS rules and variables to include based on what elements and classes are actually used in the project.

This module provides low-level CSS resolution for advanced use cases. Most users should use gen_fuz_css (Gro) or vite_plugin_fuz_css (Vite) which handle extraction and caching automatically. See those modules for reference implementations.

Declarations
#

6 declarations

view source

CssResolutionOptions
#

css_bundled_resolution.ts view source

CssResolutionOptions

Options for CSS resolution.

style_rule_index

Index of style.css rules

variable_graph

Dependency graph for theme variables

class_variable_index

Index mapping classes to variables

detected_elements

HTML elements detected in source files

type Set<string>

detected_classes

CSS classes detected in source files

type Set<string>

detected_css_variables

CSS variables directly referenced in source files

type Set<string>

utility_variables_used

CSS variables used by generated utility classes

type Set<string>

additional_elements

Additional elements to always include, or 'all' to include all base styles

type Iterable<string> | 'all'

additional_variables

Additional variables to always include, or 'all' to include all theme variables

type Iterable<string> | 'all'

theme_specificity

Specificity multiplier for theme selector (default 1)

type number

include_stats

Whether to include resolution statistics in result

type boolean

warn_unmatched_elements

Warn when detected elements have no matching style rules (default false)

type boolean

exclude_elements

Elements to exclude from base CSS output, even if detected.

type Iterable<string>

exclude_variables

CSS variables to exclude from theme output, even if referenced.

type Iterable<string>

explicit_elements

Elements explicitly annotated via

type Set<string> | null

explicit_variables

Variables explicitly annotated via

type Set<string> | null

CssResolutionResult
#

css_bundled_resolution.ts view source

CssResolutionResult

Result from CSS resolution.

theme_css

CSS for theme variables (light and dark)

type string

base_css

CSS for base styles (from style.css)

type string

resolved_variables

All resolved variable names (including transitive deps)

type Set<string>

included_rule_indices

Indices of rules included from the style index

type Set<number>

included_elements

Element names that were matched

type Set<string>

diagnostics

Diagnostics from resolution

type Array<GenerationDiagnostic>

stats

Resolution statistics (only when include_stats is true)

CssResolutionStats
#

css_bundled_resolution.ts view source

CssResolutionStats

Statistics from CSS resolution (only included when include_stats is true).

element_count

Number of HTML elements included

type number

elements

List of HTML element names included

type Array<string>

included_rules

Number of rules included from style.css

type number

total_rules

Total number of rules in style.css

type number

variable_count

Number of CSS variables resolved (including transitive deps)

type number

generate_bundled_css
#

GenerateBundledCssOptions
#

css_bundled_resolution.ts view source

GenerateBundledCssOptions

Options for bundled CSS output generation.

include_theme

Include theme variables section.

type boolean

include_base

Include base styles section.

type boolean

include_utilities

Include utility classes section.

type boolean

resolve_css
#

css_bundled_resolution.ts view source

(options: CssResolutionOptions): CssResolutionResult

Resolves which CSS to include based on detected usage.

Algorithm: 1. Collect rules: core rules + element-matching + class-matching 2. Collect variables: from rules, class defs, utility generation, detected vars, additional_variables 3. Resolve transitive variable dependencies 4. Generate output: theme_css (light+dark), base_css (source order)

options

resolution options including indexes, detected usage, and config

returns

CssResolutionResult

resolution result with theme CSS, base CSS, and diagnostics

Depends on
#

Imported by
#