Engine and CLI

Architecture

One package, jx_cli, made of separate tested libraries, each responsible for one step of the pipeline. Use the engine alone, replace the theme or add your own rules.

The pipeline

A string of classes goes through four steps: the parser splits it into tokens, the registry finds the rule for each utility, the theme resolves named values and the generator writes the CSS.

"md:hover:bg:blue!"
  -> parser     token: variants [md, hover], bg, blue, important
  -> rules      background-color rule
  -> theme      blue = #3b82f6
  -> engine     selector .md\:hover\:bg\:blue\!:hover inside @media (min-width: 768px)
  -> generator  final CSS
md : hover : bg : blue !
@media (min-width: 768px) {
  .md\:hover\:bg\:blue\!:hover {
    background-color: #3b82f6 !important;
  }
}

The libraries

  1. 01
    package:jx_cli/core.dart

    Shared contracts and models: class tokens, CSS rules, configuration, value validation.

  2. 02
    package:jx_cli/parser.dart

    Parses the [variants:]utility[:value][!] syntax, explains every rejection and blocks values able to inject CSS.

  3. 03
    package:jx_cli/theme.dart

    Theme tokens (colors, spacing, breakpoints…), extensible through configuration.

  4. 04
    package:jx_cli/rules.dart

    The utility catalog and its registry: each rule produces declarations.

  5. 05
    package:jx_cli/engine.dart

    Runs the pipeline and applies variants, sorted mobile-first. Also the Tailwind converter.

  6. 06
    package:jx_cli/generator.dart

    Serializes the CSS, minified or not, after the preflight.

  7. 07
    jx (command)

    jx build, jx init and jx migrate: class extraction from Dart files, watch mode.

  8. 08
    package:jx_cli/builder.dart

    build_runner integration: jaspr serve and jaspr build write the stylesheet.

  9. 09
    package:jx_cli/ui.dart

    Accessible Jaspr components styled with JX classes.

Rule ordering

The engine sorts the stylesheet mobile-first: rules without a media query first, then breakpoints by increasing width. An md: class therefore always wins over the same property without a variant.

Note

Design decisions (pseudo-elements at the end of the selector, focus ring through a custom property…) are documented in docs/architecture.md in the repository.