Skip to main content

Module css_in_js

Module css_in_js 

Source
Expand description

CSS-in-JS analytics front-ends (CSS program Phases 3b / 3c / 3d).

Three front-ends feed the shared styling-analytics pipeline, converging on the same virtual-stylesheet output that compute_css_analytics consumes:

  • template: the Phase 3b lexical lifter for styled.div`...` tagged templates.
  • object: the Phase 3c AST object-to-CSS serializer (style({...}), stylex.create({...}), …).
  • tokens: the Phase 3d design-token definition extraction + cross-module consumer scan (StyleX defineVars, vanilla-extract createTheme).

shared holds the small invariants the front-ends agree on (the synthetic wrapper selector, the newline counter).

Structs§

CssInJsObjectSheets
The three virtual stylesheets lifted from a source’s object-notation CSS-in-JS, each blank-line-padded so CSS metric line numbers map back onto the real source. Each is None when the source has no object CSS-in-JS of that class (so callers skip it; no files_analyzed inflation). See the module docs for the per-sheet engine policy.
CssInJsToken
A single defined design token: its dotted LEAF path relative to the access binding (color.primary, or flat primaryColor for StyleX), the 1-based source line of its key, and the static value when the literal is recoverable.
CssInJsTokenDef
A CSS-in-JS token-definition site: the exported access binding consumers read through (e.g. vars) and the flattened leaf tokens it defines.
TokenConsumerHit
One located consumer of a CSS-in-JS token: the defined LEAF token path it reads (relative to the binding, e.g. color.primary) and the 1-based line of the member-access site.

Enums§

CssInJsTokenOrigin
The CSS-in-JS token system that produced a token definition.

Functions§

css_in_js_object_sheets
Lift the object-notation CSS-in-JS in a JS/TS source into the structural / structural-partial / atomic virtual stylesheets. Parses with oxc (source type inferred from path), maps import bindings to recognized libraries, walks for style calls, serializes each bucket, and pads each to its source line. All sheets are None when the source has no recognized object CSS-in-JS import.
css_in_js_theme_consumers
Walk a consuming JS/TS source for styled-components / Emotion theme reads such as theme.colors.brand and props.theme.colors.brand.
css_in_js_theme_token_defs
Walk a JS/TS source for statically-authored theme object definitions used by styled-components and Emotion. A theme or *Theme variable with an object literal initializer becomes a token surface, with nested scalar leaves exposed as dotted paths.
css_in_js_token_consumers
Walk a consuming JS/TS source for cross-module reads of a token binding, returning the located reads that resolve to a DEFINED leaf token path. The caller supplies the local alias the consuming file imported the token binding under (so aliased imports work) and the set of defined leaf paths. A member access <alias>.a.b is a hit when a.b is exactly a defined leaf path; intermediate groups (<alias>.a where only a.b is defined) and accesses on other bindings are not hits, so there is no double-count and no false match.
css_in_js_token_defs
Walk a JS/TS source for CSS-in-JS design-token DEFINITIONS, returning each access binding and its flattened leaf token paths. Empty when the source has no recognized token-library import (provenance gate closed).
css_in_js_virtual_stylesheet
Build a virtual stylesheet from the CSS-in-JS tagged templates in a JS/TS source. Each template body is placed at its real line in the source via blank-line padding, so CSS metric line numbers from crate::compute_css_analytics map straight back onto the source. Every ${...} interpolation is masked to a CSS-valid placeholder (newline count preserved so lines after a multi-line interpolation stay aligned). Returns None when the source has no CSS-in-JS tagged template, so callers skip the file entirely (no files_analyzed inflation).
panda_style_value_consumers
Walk a consuming JS/TS source for common PandaCSS style calls whose object literal values statically name token paths.
panda_token_call_consumers
Walk a consuming JS/TS source for PandaCSS token('path.to.token') calls. The caller supplies the local alias imported from Panda’s generated styled-system token module and the set of defined leaf paths.