text
stringlengths
0
601k
let program { init ; update ; view } pnode flags = let initModel , initCmd = init flags in let opnode = Js . Null_undefined . toOption pnode in let modelState = programStateWrapperInit initModel in let rec viewState msgHandler = programLoopInit msgHandler view initModel opnode and pump_unfixed msgHandler = programLoop ...
let makeProgram p = let module P = ( val p : Program ) in ( module struct let x = P . init let y = 42 end : ProgramState )
module type Main = sig end
module type App = sig end
module Make ( MainProg : Main ) : App = struct end ) *
type ' msg applicationCallbacks = ' msg Vdom . applicationCallbacks
type ' msg t = | NoCmd | Tagger of ( ' msg applicationCallbacks ref -> unit ) | Batch of ' msg t list | EnqueueCall of ( ' msg applicationCallbacks ref -> unit )
let batch cmds = Batch cmds
let call call = EnqueueCall call
let fnMsg fnMsg = let open Vdom in EnqueueCall ( fun callbacks -> ! callbacks . enqueue ( fnMsg ( ) ) )
let msg msg = let open Vdom in EnqueueCall ( fun callbacks -> ! callbacks . enqueue msg )
let rec run callbacks = function | NoCmd -> ( ) | Tagger tagger -> tagger callbacks | Batch cmds -> List . fold_left ( fun ( ) cmd -> run callbacks cmd ) ( ) cmds | EnqueueCall cb -> cb callbacks
let map : ( ' a -> ' b ) -> ' a t -> ' b t = fun func cmd -> let open Vdom in Tagger ( fun callbacks -> run ( wrapCallbacks func callbacks ) cmd )
module LocalStorage = struct open Tea_task open Tea_result let length = nativeBinding ( fun cb -> match Web . Window . LocalStorage . length Web . Window . window with | None -> cb ( Error " localStorage is not available " ) | Some value -> cb ( Ok value ) ) let clear = nativeBinding ( fun cb -> match Web . Window . Lo...
let text str = text str
let lazy1 key gen = lazyGen key gen
let node ( ? namespace " " ) = tagName ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode namespace tagName key unique props nodes
let br props = fullnode " " " br " " br " " br " props [ ]
let br ' ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " br " key unique props nodes
let div ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " div " key unique props nodes
let span ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " span " key unique props nodes
let p ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " p " key unique props nodes
let pre ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " pre " key unique props nodes
let a ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " a " key unique props nodes
let section ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " section " key unique props nodes
let header ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " header " key unique props nodes
let footer ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " footer " key unique props nodes
let h1 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h1 " key unique props nodes
let h2 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h2 " key unique props nodes
let h3 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h3 " key unique props nodes
let h4 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h4 " key unique props nodes
let h5 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h5 " key unique props nodes
let h6 ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " h6 " key unique props nodes
let i ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " i " key unique props nodes
let strong ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " strong " key unique props nodes
let button ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " button " key unique props nodes
let input ' ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " input " key unique props nodes
let textarea ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " textarea " key unique props nodes
let label ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " label " key unique props nodes
let ul ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " ul " key unique props nodes
let ol ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " ol " key unique props nodes
let li ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " li " key unique props nodes
let table ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " table " key unique props nodes
let thead ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " thead " key unique props nodes
let tfoot ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " tfoot " key unique props nodes
let tbody ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " tbody " key unique props nodes
let th ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " th " key unique props nodes
let tr ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " tr " key unique props nodes
let td ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " td " key unique props nodes
let progress ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " progress " key unique props nodes
let img ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " img " key unique props nodes
let select ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " select " key unique props nodes
let option ' ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " option " key unique props nodes
let form ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " form " key unique props nodes
let nav ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " nav " key unique props nodes
let main ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " main " key unique props nodes
let aside ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " aside " key unique props nodes
let article ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " article " key unique props nodes
let details ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " details " key unique props nodes
let figcaption ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " figcaption " key unique props nodes
let figure ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " figure " key unique props nodes
let mark ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " mark " key unique props nodes
let summary ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " summary " key unique props nodes
let time ( ? key " " ) = ( ? unique " " ) = props nodes = fullnode " " " time " key unique props nodes
let id str = prop " id " str
let href str = attribute " " " href " str
let src str = attribute " " " src " str
let class ' name = prop " className " name
let classList classes = classes |> List . filter ( fun ( _fst , snd ) -> snd ) |> List . map ( fun ( fst , _snd ) -> fst ) |> String . concat " " |> class '
let type ' typ = prop " type " typ
let style key value = style key value
let styles s = styles s
let placeholder str = prop " placeholder " str
let autofocus b = if b then prop " autofocus " " autofocus " else noProp
let value str = prop " value " str
let name str = prop " name " str
let checked b = if b then prop " checked " " checked " else noProp
let for ' str = prop " htmlFor " str
let hidden b = if b then prop " hidden " " hidden " else noProp
let target t = prop " target " t
let action a = prop " action " a
let method ' m = prop " method " m
let onCB eventName key cb = onCB eventName key cb
let onMsg eventName msg = onMsg eventName msg
let onInputOpt ( ? key " " ) = msg = onCB " input " key ( fun ev -> match Js . Undefined . toOption ev ## target with | None -> None | Some target -> match Js . Undefined . toOption target ## value with | None -> None | Some value -> msg value )
let onInput ( ? key " " ) = msg = onInputOpt ~ key : key ( fun ev -> Some ( msg ev ) )
let onChangeOpt ( ? key " " ) = msg = onCB " change " key ( fun ev -> match Js . Undefined . toOption ev ## target with | None -> None | Some target -> match Js . Undefined . toOption target ## value with | None -> None | Some value -> msg value )
let onChange ( ? key " " ) = msg = onChangeOpt ~ key : key ( fun ev -> Some ( msg ev ) )
let onClick msg = onMsg " click " msg
let onDoubleClick msg = onMsg " dblclick " msg
let onBlur msg = onMsg " blur " msg
let onFocus msg = onMsg " focus " msg
let onCheckOpt ( ? key " " ) = msg = onCB " change " key ( fun ev -> match Js . Undefined . toOption ev ## target with | None -> None | Some target -> match Js . Undefined . toOption target ## checked with | None -> None | Some value -> msg value )
let onCheck ( ? key " " ) = msg = onCheckOpt ~ key : key ( fun ev -> Some ( msg ev ) )
let onMouseDown msg = onMsg " mousedown " msg
let onMouseUp msg = onMsg " mouseup " msg
let onMouseEnter msg = onMsg " mouseenter " msg
let onMouseLeave msg = onMsg " mouseleave " msg
let onMouseOver msg = onMsg " mouseover " msg
let onMouseOut msg = onMsg " mouseout " msg