on master help sign in
Added document and element
9bf0a78iko
src/Ur/Run.elm+52−2
@@ -1,10 +1,17 @@
1−module Ur.Run exposing (Model, Msg, Program, application)
1+module Ur.Run exposing
2+ ( Model
3+ , Msg
4+ , Program
5+ , application
6+ , document
7+ , element
8+ )
2
9
3import Browser exposing (Document, UrlRequest)
10import Browser exposing (Document, UrlRequest)
4import Browser.Navigation as Nav
11import Browser.Navigation as Nav
5import Dict exposing (Dict)
12import Dict exposing (Dict)
6import Either exposing (Either(..))
13import Either exposing (Either(..))
7−import Html
14+import Html exposing (Html)
8import Json.Decode as JD
15import Json.Decode as JD
9import Task
16import Task
10import Time
17import Time
@@ -59,6 +66,49 @@ type alias Program model msg =
59 Platform.Program Flags (Model model msg) (Msg msg)
66 Platform.Program Flags (Model model msg) (Msg msg)
60
67
61
68
69+element :
70+ { init : ( model, Ur.Cmd.Cmd msg )
71+ , view : model -> Html msg
72+ , update : msg -> model -> ( model, Ur.Cmd.Cmd msg )
73+ , subscriptions : model -> Sub msg
74+ , urbitSubscriptions : model -> Ur.Sub.Sub msg
75+ , createEventSource : String -> Cmd (Msg msg)
76+ , onEventSourceMsg : (JD.Value -> Msg msg) -> Sub (Msg msg)
77+ , urbitUrl : model -> String
78+ }
79+ -> Program model msg
80+element inp =
81+ Browser.element
82+ { init = init inp inp.init
83+ , view = \model -> inp.view model.app |> Html.map AppMsg
84+ , update = update inp
85+ , subscriptions = subscriptions inp
86+ }
87+
88+
89+document :
90+ { init : ( model, Ur.Cmd.Cmd msg )
91+ , view : model -> Document msg
92+ , update : msg -> model -> ( model, Ur.Cmd.Cmd msg )
93+ , subscriptions : model -> Sub msg
94+ , urbitSubscriptions : model -> Ur.Sub.Sub msg
95+ , createEventSource : String -> Cmd (Msg msg)
96+ , onEventSourceMsg : (JD.Value -> Msg msg) -> Sub (Msg msg)
97+ , urbitUrl : model -> String
98+ }
99+ -> Program model msg
100+document inp =
101+ Browser.document
102+ { init = init inp inp.init
103+ , view =
104+ \model ->
105+ inp.view model.app
106+ |> (\{ body, title } -> { title = title, body = body |> List.map (Html.map AppMsg) })
107+ , update = update inp
108+ , subscriptions = subscriptions inp
109+ }
110+
111+
62application :
112application :
63 { init : Url -> Nav.Key -> ( model, Ur.Cmd.Cmd msg )
113 { init : Url -> Nav.Key -> ( model, Ur.Cmd.Cmd msg )
64 , view : model -> Document msg
114 , view : model -> Document msg