style_rule_parser.ts

Style.css rule parser for bundled CSS generation.

Parses the fuz_css style.css file into a structured index that maps CSS rules to the HTML elements and classes they style. This enables the bundled CSS generator to include only the rules needed for elements actually used in the project.

Declarations
#

14 declarations

view source

collect_rule_variables
#

style_rule_parser.ts view source

(index: StyleRuleIndex, included_indices: Set<number>): Set<string>

Collects all CSS variables used by the included rules.

index

included_indices

set of rule indices to include

type Set<number>

returns

Set<string>

set of variable names (without -- prefix)

CoreReason
#

CoreStyleRule
#

create_style_rule_index
#

generate_base_css
#

get_matching_rules
#

style_rule_parser.ts view source

(index: StyleRuleIndex, detected_elements: Set<string>, detected_classes: Set<string>): Set<number>

Gets rules that should be included based on detected elements and classes.

index

the StyleRuleIndex to query

detected_elements

set of HTML element names found in source

type Set<string>

detected_classes

set of CSS class names found in source

type Set<string>

returns

Set<number>

set of rule indices to include

load_default_style_css
#

style_rule_parser.ts view source

(deps: CacheDeps, style_css_path?: string | undefined): Promise<string>

Loads the raw default style.css content.

deps

filesystem deps for dependency injection

style_css_path?

path to style.css (defaults to package's style.css)

type string | undefined
optional

returns

Promise<string>

promise resolving to the CSS string

load_style_rule_index
#

style_rule_parser.ts view source

(deps: CacheDeps, style_css_path?: string | undefined): Promise<StyleRuleIndex>

Loads and parses the default style.css file.

deps

filesystem deps for dependency injection

style_css_path?

path to style.css (defaults to package's style.css)

type string | undefined
optional

returns

Promise<StyleRuleIndex>

promise resolving to StyleRuleIndex

NonCoreStyleRule
#

parse_style_css
#

style_rule_parser.ts view source

(css: string, content_hash: string): StyleRuleIndex

Parses a CSS stylesheet into a StyleRuleIndex.

css

raw CSS string (e.g., contents of style.css)

type string

content_hash

hash of the CSS for cache invalidation

type string

returns

StyleRuleIndex

StyleRuleIndex with rules and lookup maps

resolve_base_css_option
#

style_rule_parser.ts view source

(base_css: BaseCssOption, deps: CacheDeps): Promise<StyleRuleIndex | null>

Resolves a base_css option to a StyleRuleIndex. Handles all option forms: undefined (defaults), null (disabled), string, or callback.

base_css

the base_css option from generator config

deps

filesystem deps for loading default CSS

returns

Promise<StyleRuleIndex | null>

promise resolving to StyleRuleIndex, or null if disabled

StyleRule
#

StyleRuleBase
#

style_rule_parser.ts view source

StyleRuleBase

Base fields shared by all style rules.

css

The full CSS text for this rule (including selector and declarations)

type string

elements

HTML element names this rule targets (e.g., 'button', 'input')

type Set<string>

classes

CSS class names this rule targets (e.g., 'unstyled', 'selected')

type Set<string>

variables_used

CSS variables referenced in declarations

type Set<string>

order

Original order in style.css (for preserving cascade)

type number

StyleRuleIndex
#

style_rule_parser.ts view source

StyleRuleIndex

Index of parsed style rules for efficient lookup.

rules

All rules in original order

type Array<StyleRule>

by_element

Rules indexed by element name

type Map<string, Array<number>>

by_class

Rules indexed by class name

type Map<string, Array<number>>

content_hash

Content hash for cache invalidation

type string

Depends on
#

Imported by
#