-module(lustre). -compile(no_auto_import). -export([basic/1, application/3, start/2]). -export_type([app/2, error/0]). -opaque app(FOH, FOI) :: {app, {FOH, lustre@cmd:cmd(FOI)}, fun((FOH, FOI) -> {FOH, lustre@cmd:cmd(FOI)}), fun((FOH) -> lustre@element:element(FOI))}. -type error() :: element_not_found. -spec basic(lustre@element:element(FOZ)) -> app(nil, FOZ). basic(Element) -> Init = {nil, lustre@cmd:none()}, Update = fun(_, _) -> {nil, lustre@cmd:none()} end, Render = fun(_) -> Element end, {app, Init, Update, Render}. -spec application( {FPD, lustre@cmd:cmd(FPE)}, fun((FPD, FPE) -> {FPD, lustre@cmd:cmd(FPE)}), fun((FPD) -> lustre@element:element(FPE)) ) -> app(FPD, FPE). application(Init, Update, Render) -> {app, Init, Update, Render}. -spec start(app(any(), FPN), binary()) -> {ok, fun((FPN) -> nil)} | {error, error()}. start(App, Selector) -> _pipe = './ffi.mjs':mount(App, Selector), gleam@result:replace_error(_pipe, element_not_found).