Class: JsxRosetta::IR::Component
- Inherits:
-
Data
- Object
- Data
- JsxRosetta::IR::Component
- Includes:
- Node
- Defined in:
- lib/jsx_rosetta/ir/types.rb
Overview
A translated component definition. The root of a lowered IR tree.
name : String — component name as it appears in JSX (e.g. “Button”). props : [Prop] body : Node — usually an Element or Fragment. rest_prop_name : String | nil — name of a rest-destructured prop
(`function X({ a, ...rest })`). When non-nil, the
backend should generate a `**rest` initializer kwarg
and make it available via `@rest_prop_name`.
local_bindings : [LocalBinding] — non-JSX local ‘const` bindings inside
the component body. Backends typically render these as
a TODO comment block since arbitrary JS-to-Ruby
translation isn't attempted.
local_binding_names : [String] — flat list of all names bound by the
component body (destructure patterns, hook tuples,
ordinary const bindings). Backends pass this into the
ExpressionTranslator so an identifier reference like
`count` resolves to a `nil` placeholder instead of
a bare unresolved snake_case identifier that NameErrors
at render time. Includes hook destructures (e.g.
`open` and `setOpen` from `useState`) even though
those names don't appear in `local_bindings`.
stimulus_methods : [StimulusMethod] — event handlers extracted from
inline arrows / const-bound arrows used in onX={...}.
When non-empty, backends should emit a sibling
Stimulus controller file alongside the .rb/.erb pair.
react_hooks : [ReactHookCall] — calls to React hooks (useState,
useEffect, useRef, useContext, useMemo, useCallback,
useReducer, useImperativeHandle, useLayoutEffect).
Surfaced as a distinct TODO block so the human
reviewer knows to translate behavior to Stimulus
and state to server-side rendering.
module_bindings : [LocalBinding] — top-level ‘const`/`let` declarations
outside the component function that aren't themselves
components. Captured so backends can either translate
to Ruby constants (literal initializers) or surface
as a TODO comment block before the class definition.
Without this capture, references to module-level
constants from inside the JSX silently drop and
produce unbacked snake_case references at render time.
Instance Attribute Summary collapse
-
#body ⇒ Object
readonly
Returns the value of attribute body.
-
#local_binding_names ⇒ Object
readonly
Returns the value of attribute local_binding_names.
-
#local_bindings ⇒ Object
readonly
Returns the value of attribute local_bindings.
-
#module_bindings ⇒ Object
readonly
Returns the value of attribute module_bindings.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#props ⇒ Object
readonly
Returns the value of attribute props.
-
#react_hooks ⇒ Object
readonly
Returns the value of attribute react_hooks.
-
#rest_prop_name ⇒ Object
readonly
Returns the value of attribute rest_prop_name.
-
#stimulus_methods ⇒ Object
readonly
Returns the value of attribute stimulus_methods.
Instance Attribute Details
#body ⇒ Object (readonly)
Returns the value of attribute body
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def body @body end |
#local_binding_names ⇒ Object (readonly)
Returns the value of attribute local_binding_names
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def local_binding_names @local_binding_names end |
#local_bindings ⇒ Object (readonly)
Returns the value of attribute local_bindings
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def local_bindings @local_bindings end |
#module_bindings ⇒ Object (readonly)
Returns the value of attribute module_bindings
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def module_bindings @module_bindings end |
#name ⇒ Object (readonly)
Returns the value of attribute name
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def name @name end |
#props ⇒ Object (readonly)
Returns the value of attribute props
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def props @props end |
#react_hooks ⇒ Object (readonly)
Returns the value of attribute react_hooks
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def react_hooks @react_hooks end |
#rest_prop_name ⇒ Object (readonly)
Returns the value of attribute rest_prop_name
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def rest_prop_name @rest_prop_name end |
#stimulus_methods ⇒ Object (readonly)
Returns the value of attribute stimulus_methods
50 51 52 |
# File 'lib/jsx_rosetta/ir/types.rb', line 50 def stimulus_methods @stimulus_methods end |