Module: JsxRosetta::IR

Defined in:
lib/jsx_rosetta/ir.rb,
lib/jsx_rosetta/ir/types.rb,
lib/jsx_rosetta/ir/lowering.rb,
lib/jsx_rosetta/ir/radix_registry.rb,
lib/jsx_rosetta/ir/module_shape_classifier.rb

Defined Under Namespace

Modules: Node, RadixRegistry Classes: ArrayLiteral, Attribute, ClassList, Comment, Component, ComponentInvocation, Conditional, ConditionalSegment, CvaAxisPair, CvaBinding, CvaCallSite, Element, EventBinding, EventHandler, Fragment, Interpolation, Lambda, LayoutYield, LocalBinding, LocalRenderCall, Loop, Lowering, ModuleConstant, ModuleImport, ModuleShapeClassifier, ObjectLiteral, Prop, ReactHookCall, RenderMethod, RenderProp, RouteEntry, RouteTree, ServerDataSource, Slot, SpreadAttribute, StimulusBinding, StimulusMethod, Style, StyleBinding, StyleDeclaration, Text

Constant Summary collapse

RADIX_SOURCE_PATTERN =

When a shadcn TSX wraps a Radix primitive like ‘<SeparatorPrimitive.Root orientation=“horizontal” />`, the translator has historically lowered it to a `ComponentInvocation` whose name is the member chain (`“SeparatorPrimitive.Root”`) — which emits as `render SeparatorPrimitive::Root.new(…)`, an undefined-constant NameError at render time.

The shapes underneath are stable enough across Radix that we can map the common (LocalImportName, MemberName) pairs to plain HTML elements plus any always-applied attributes. The mapping is keyed on the LOCAL binding name shadcn uses by convention (e.g. ‘SeparatorPrimitive`), which matches the import-aliasing pattern in every shadcn fork I’ve surveyed. Unknown pairs fall through to the existing ComponentInvocation / TODO behavior so consumers can hand-shim primitives we don’t cover.

Source specifiers that count as “Radix” — both the ‘radix-ui` umbrella package and the older `@radix-ui/react-*` per-primitive packages.

%r{\A(?:radix-ui|@radix-ui/react-[\w-]+)\z}
SLOT_LOCAL_NAME_PATTERN =

Local binding names that resolve to Radix’s ‘Slot` primitive. Matches `Slot` (shadcn-v4 umbrella) and `SlotPrimitive` (older convention). Anything looser would silently drop user-defined components whose names happen to start with “Slot”.

/\ASlot(?:Primitive)?\z/

Class Method Summary collapse

Class Method Details

.lower(ast_file, source:, keep_slot: false) ⇒ Object



9
10
11
# File 'lib/jsx_rosetta/ir.rb', line 9

def self.lower(ast_file, source:, keep_slot: false)
  Lowering.lower(ast_file, source: source, keep_slot: keep_slot)
end

.lower_all(ast_file, source:, keep_slot: false) ⇒ Object



13
14
15
# File 'lib/jsx_rosetta/ir.rb', line 13

def self.lower_all(ast_file, source:, keep_slot: false)
  Lowering.lower_all(ast_file, source: source, keep_slot: keep_slot)
end