tiye/respo/node does not have a README file

RespoAction

pub(open) trait RespoAction {
fn build_states_action(Array[String],
JsObscure
?, Json?) -> Self
}

RespoEffect

pub(open) trait RespoEffect : ToJson {
fn build_effect(Self) -> RespoEffectBox = _
fn make_handler(Self) -> ((RespoEffectType,
Node
) -> Unit) = _
fn run(Self, RespoEffectType,
Node
) -> Unit = _
fn mounted(Self,
Node
) -> Unit = _
fn before_update(Self,
Node
) -> Unit = _
fn updated(Self,
Node
) -> Unit = _
fn before_unmount(Self,
Node
) -> Unit = _
}

implement this on data which creates effect

RespoCommonError

pub(all) suberror RespoCommonError {
RespoCommonError(String)
}

currently it's commonly used for all errors in Respo

AnchorElementTarget

pub(all) enum AnchorElementTarget {
Blank
Parent
Self
Top
}

AnchorElementTarget::to_string

fn AnchorElementTarget::to_string(self : AnchorElementTarget) -> String

ChildDomOp

type ChildDomOp[T, G]

ChildDomOp::to_cirru

fn[T, G] ChildDomOp::to_cirru(self : ChildDomOp[T, G]) ->
Cirru

DispatchFn

pub(all) struct DispatchFn[T]((T) -> Unit raise RespoCommonError)

impl Show for DispatchFn[T]

DispatchFn::empty_state

fn[T : RespoAction, S] DispatchFn::empty_state(self : DispatchFn[T], cursor : RespoCursor[S]) -> Unit raise RespoCommonError

dispatch an action to update states, to empty the state, pass None

DispatchFn::new

fn[T] DispatchFn::new(f : (T) -> Unit raise RespoCommonError) -> DispatchFn[T]

DispatchFn::run

fn[T] DispatchFn::run(self : DispatchFn[T], op : T) -> Unit raise RespoCommonError

DispatchFn::run_empty_state

#deprecated("use `empty_state` instead")
fn[T : RespoAction] DispatchFn::run_empty_state(self : DispatchFn[T], cursor : Array[String]) -> Unit raise RespoCommonError

DispatchFn::set_state

fn[T : RespoAction, S : ToJson] DispatchFn::set_state(self : DispatchFn[T], cursor : RespoCursor[S], state : S) -> Unit raise RespoCommonError

dispatch an action to update states, to empty the state, pass None

DomChange

type DomChange[T, G]

Diff/patch for virtual DOM, note that children are not included in this type
impl Show for DomChange[T, G]

DomChange::get_dom_path

fn[T, G] DomChange::get_dom_path(self : DomChange[T, G]) ->
Vector
[UInt]

DomChange::to_cirru

fn[T, G] DomChange::to_cirru(self : DomChange[T, G]) ->
Cirru

IframeElementLoading

pub(all) enum IframeElementLoading {
Eager
Lazy
}

ImgElementLoading

pub(all) enum ImgElementLoading {
Eager
Lazy
}

RespoComponent

pub(all) struct RespoComponent[T, G] {
name : String
effects : Array[RespoEffectBox]
tree : RespoNode[T, G]
listeners : (G, DispatchFn[T]) -> Unit raise RespoCommonError?
}

impl Eq for RespoComponent[T, G]

RespoComponent::named

fn[T, G] RespoComponent::named(name : String, tree : RespoNode[T, G], effects? : Array[&RespoEffect], listeners? : (G, DispatchFn[T]) -> Unit raise RespoCommonError?) -> RespoComponent[T, G]

RespoComponent::to_cirru

fn[T, G] RespoComponent::to_cirru(self : RespoComponent[T, G]) ->
Cirru

RespoComponent::to_node

fn[T, G] RespoComponent::to_node(self : RespoComponent[T, G]) -> RespoNode[T, G]

RespoCoord

pub(all) enum RespoCoord {
Key(RespoIndexKey)
Comp(String)
}

coord of on virtual dom
impl Show for RespoCoord

RespoCoord::to_cirru

RespoCursor

pub struct RespoCursor[T] {
cursor : Array[String]
_phantom : T?
}

abstract over cursor array with state type

RespoCursor::new

fn[T] RespoCursor::new(cursor : Array[String]) -> RespoCursor[T]

RespoEffectBox

pub(all) struct RespoEffectBox {
args : Json
handler : (RespoEffectType,
Node
) -> Unit
}

RespoEffectType

pub(all) enum RespoEffectType {
Mounted
BeforeUpdate
Updated
BeforeUnmount
} derive(Eq)

currently only support Mounted, BeforeUpdate, Updated, BeforeUnmount

RespoEffectType::to_cirru

RespoElement

pub(all) struct RespoElement[T, G] {
name : String
attrs : Map[String, String]
event : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError]
style :
RespoStyle

children : Array[(RespoIndexKey, RespoNode[T, G])]
}

internal abstraction for an element
impl Eq for RespoElement[T, G]
impl Show for RespoElement[T, G]

RespoElement::set_attribute

fn[T, G] RespoElement::set_attribute(self : RespoElement[T, G], key : String, value : String) -> Unit

RespoElement::to_cirru

fn[T, G] RespoElement::to_cirru(self : RespoElement[T, G]) ->
Cirru

RespoElement::to_node

fn[T, G] RespoElement::to_node(self : RespoElement[T, G]) -> RespoNode[T, G]

RespoEvent

Wraps basic DOM event types with commonly-used properties extracted. This provides a unified interface for handling different event types in Respo applications.
impl Show for RespoEvent

RespoEventMark

pub(all) struct RespoEventMark {
coord :
Vector
[RespoCoord]
name : RespoEventType
event_info : RespoEvent
}

Represents an event mark with its location in the virtual DOM tree. Contains the coordinate path to the element, the event type, and the event data.

RespoEventType

pub(all) enum RespoEventType {
Click
DblClick
Change
Keydown
Keyup
Keypress
Input
Focus
Blur
DragStart
DragEnd
DragOver
DragEnter
DragLeave
Drop
} derive(Eq, Hash)

Defines the types of DOM events that can be handled in Respo. Each variant corresponds to a specific browser event type.

RespoEventType::to_cirru

Converts a RespoEventType to its Cirru representation. Returns a Cirru leaf node with the event type name prefixed with ::.

RespoIndexKey

pub(all) struct RespoIndexKey(String) derive(Eq)

RespoIndexKey::to_cirru

RespoNode

pub(all) enum RespoNode[T, G] {
Component(RespoComponent[T, G])
Element(RespoElement[T, G])
}

impl Eq for RespoNode[T, G]

RespoNode::to_cirru

fn[T, G] RespoNode::to_cirru(self : RespoNode[T, G]) ->
Cirru

TextareaElementAutoComplete

pub(all) enum TextareaElementAutoComplete {
On
Off
}

VideoElementPreload

pub(all) enum VideoElementPreload {
Auto
Metadata
None
}

fn[T, G] a(inner_text? : String, class_name? : String, class_list? : Array[String], href~ : String, download? : String, target? : AnchorElementTarget, attrs? : Map[String, String], type_? : String, event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children? : Array[RespoNode[T, G]]) -> RespoNode[T, G]

anchor element https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a

attach_event

fn attach_event(element :
Element
, key : RespoEventType, coord :
Vector
[RespoCoord], handle_event : (RespoEventMark) -> Unit raise RespoCommonError) -> Unit raise RespoCommonError

fn[T, G] b(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

blockquote

fn[T, G] blockquote(class_name? : String, class_list? : Array[String], inner_text? : String, attrs? : Map[String, String], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] br(attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

build_dom_tree

fn[T, G] build_dom_tree(tree : RespoNode[T, G], coord :
Vector
[RespoCoord], handle_event : (RespoEventMark) -> Unit raise RespoCommonError) ->
Node
raise RespoCommonError

creates a DOM tree from virtual DOM with proxied event handler attached

button

fn[T, G] button(class_name? : String, class_list? : Array[String], inner_text~ : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, on_click? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

canvas

fn[T, G] canvas(class_name? : String, class_list? : Array[String], height? : Int, width? : Int, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

code

fn[T, G] code(class_name? : String, class_list? : Array[String], inner_text~ : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

collect_effects_inside_out_as

fn[T, G] collect_effects_inside_out_as(tree : RespoNode[T, G], coord :
Vector
[RespoCoord], dom_path :
Vector
[UInt], effect_type : RespoEffectType, changes :
Ref
[Array[DomChange[T, G]]]) -> Unit raise RespoCommonError

collect_effects_outside_in_as

fn[T, G] collect_effects_outside_in_as(tree : RespoNode[T, G], coord :
Vector
[RespoCoord], dom_path :
Vector
[UInt], effect_type : RespoEffectType, changes :
Ref
[Array[DomChange[T, G]]]) -> Unit raise RespoCommonError

contained_static_style

#callsite(autofill(loc))
fn[U : Show] contained_static_style(rules : Array[(String?, U,
RespoStyle
)], loc~ : SourceLoc) -> String

Declare a static style in the head of the documentm for example
let _style_demo : String = contained_static_style([
(
Some("@media only screen and (max-width: 600px)"),
"&",
@css.respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96)),
),
])

create_element

fn[T, G] create_element(name : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

create element with a custom name

declare_contained_style

#deprecated("This function is deprecated.")
#callsite(autofill(loc))
fn[U : Show] declare_contained_style(rules : Array[(String?, U,
RespoStyle
)], loc~ : SourceLoc) -> String

use contained_static_style instead

declare_static_style

#deprecated("This function is deprecated.")
#callsite(autofill(loc))
fn[U : Show] declare_static_style(rules : Array[(U,
RespoStyle
)], loc~ : SourceLoc) -> String

use static_style instead

diff_tree

fn[T, G] diff_tree(new_tree : RespoNode[T, G], old_tree : RespoNode[T, G], coord :
Vector
[RespoCoord], dom_path :
Vector
[UInt], changes :
Ref
[Array[DomChange[T, G]]]) -> Unit raise RespoCommonError

Diffing algorithm for RespoNode

div

fn[T, G] div(class_name? : String, class_list? : Array[String], attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]], innerHTML? : String, draggable? : Bool, on_click? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drag_start? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drag_end? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drag_over? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drag_enter? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drag_leave? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_drop? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

div_listed

fn[T, G] div_listed(class_name? : String, class_list? : Array[String], attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[(RespoIndexKey, RespoNode[T, G])]) -> RespoNode[T, G]

create a list of <div/> elements with children. IndexKey is used in children for quick diffing.

dom_path_to_cirru

fn[T, G] h1(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] h2(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] h3(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] h4(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] h5(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] h6(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

fn[T, G] hr(class_name? : String, class_list? : Array[String], attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

Horizontal rule element <hr>.
fn[T, G] i(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]], on_click? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

iframe

fn[T, G] iframe(class_name? : String, class_list? : Array[String], height? : Int, width? : Int, loading? : IframeElementLoading, src~ : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

img

fn[T, G] img(class_name? : String, class_list? : Array[String], alt~ : String, height? : Int, src~ : String, width? : Int, loading? : ImgElementLoading, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]

indexes_to_cirru

turn @hashset.T[Int] to Cirru

input

fn[T, G] input(class_name? : String, class_list? : Array[String], autocomplete? : TextareaElementAutoComplete, autofocus? : Bool, disabled? : Bool, name? : String, placeholder? : String, readonly_? : Bool, spellcheck? : Bool, attrs? : Map[String, String], value~ : String, event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, on_input? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_change? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keydown? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keyup? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keypress? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_focus? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_blur? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

kabab_to_camel_case

fn kabab_to_camel_case(s : String) -> String

fn[T, G] li(class_name? : String, class_list? : Array[String], attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]], innerHTML? : String) -> RespoNode[T, G]

load_coord_target_tree

fn[T, G] load_coord_target_tree(tree : RespoNode[T, G], coord : ArrayView[RespoCoord]) -> RespoNode[T, G] raise RespoCommonError

fn[T, G] p(class_name? : String, class_list? : Array[String], inner_text~ : String, attrs? : Map[String, String], style? :
RespoStyle
, children : Array[RespoNode[T, G]]) -> RespoNode[T, G]

patch_tree

fn[T, G] patch_tree(tree : RespoNode[T, G], old_tree : RespoNode[T, G], mount_target :
Node
, changes : Array[DomChange[T, G]], handle_event : (RespoEventMark) -> Unit raise RespoCommonError) -> Unit raise RespoCommonError

pre

fn[T, G] pre(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children? : Array[RespoNode[T, G]]) -> RespoNode[T, G]

raf_loop

fn raf_loop(f : (Float) -> Unit raise RespoCommonError) -> Unit

respo_attrs

fn respo_attrs(id? : String, class_name? : String, hidden? : Bool, disabled? : Bool, value? : String, src? : String, href? : String, alt? : String, title? : String, placeholder? : String, type_? : String, name? : String, checked? : Bool, selected? : Bool, read_only? : Bool, max_length? : Int, min_length? : Int, tab_index? : Int, content_editable? : Bool, width? : String, height? : String, inner_text? : String, innerHTML? : String, draggable? : Bool, data? : Map[String, String]) -> Map[String, String]

create attributes for an element

space

fn[T, G] space(width? : Float, height? : Float, class_name? : String, class_list? : Array[String]) -> RespoNode[T, G]

create a <div/> element to render space.

span

fn[T, G] span(class_name? : String, class_list? : Array[String], inner_text? : String, innerHTML? : String, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, children : Array[RespoNode[T, G]], on_click? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

static_style

#callsite(autofill(loc))
fn[U : Show] static_style(rules : Array[(U,
RespoStyle
)], loc~ : SourceLoc) -> String

Declare a static style in the head of the documentm for example
let _style_demo : String = static_style([
("&", @css.respo_style(margin=4 |> Px, background_color=Hsl(200, 90, 96))),
])

str_spaced

fn str_spaced(wrap_parens? : Bool, s : Array[&Show]) -> String

convert a list of strings to a single string with spaces between them, mainly used for concatenating class names

text_node

fn[T, G] text_node(class_name? : String, class_list? : Array[String], style? :
RespoStyle
, text : String) -> RespoNode[T, G]

internally using span element to render text.

textarea

fn[T, G] textarea(class_name? : String, class_list? : Array[String], value~ : String, autocomplete? : TextareaElementAutoComplete, autofocus? : Bool, disabled? : Bool, name? : String, placeholder? : String, readonly_? : Bool, spellcheck? : Bool, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
, on_input? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_change? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keydown? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keyup? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_keypress? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_focus? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError, on_blur? : (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError) -> RespoNode[T, G]

video

fn[T, G] video(class_name? : String, class_list? : Array[String], height? : Int, width? : Int, src~ : String, controls? : Bool, preload? : VideoElementPreload, attrs? : Map[String, String], event? : Map[RespoEventType, (RespoEvent, DispatchFn[T]) -> Unit raise RespoCommonError], style? :
RespoStyle
) -> RespoNode[T, G]