miso 0.1.0.3 → 0.1.0.4
raw patch · 8 files changed
+56/−18 lines, 8 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
Files
- ghc-src/Miso/Html/Internal.hs +6/−6
- ghcjs-src/Miso/Delegate.hs +9/−0
- ghcjs-src/Miso/Effect/XHR.hs +10/−10
- ghcjs-src/Miso/FFI.hs +2/−0
- ghcjs-src/Miso/Router.hs +17/−0
- ghcjs-src/Miso/Subscription/Keyboard.hs +1/−0
- ghcjs-src/Miso/Subscription/WebSocket.hs +10/−1
- miso.cabal +1/−1
ghc-src/Miso/Html/Internal.hs view
@@ -149,13 +149,13 @@ -- | Convert `Word` to `Key` instance ToKey Word where toKey = Key . T.pack . show --- | Fields that a DOM node contains+-- | Properties newtype Props = Props (M.Map MisoString Value) --- | Individual CSS property diffing+-- | CSS newtype CSS = CSS (M.Map MisoString MisoString) --- | `View` Attributes to annotate DOM, converted into `Events`, `Props`, `Attrs` and `CSS`+-- | `View` Attributes to annotate DOM, converted into Events, Props, Attrs and CSS data Attribute model = C MisoString MisoString | P MisoString Value@@ -168,7 +168,7 @@ -- | Constructs a property on a `VNode`, used to set fields on a DOM Node prop :: ToJSON a => MisoString -> a -> Attribute model-prop k v = P k (toJSON v) +prop k v = P k (toJSON v) -- | For defining delegated events --@@ -183,7 +183,7 @@ -- | For defining delegated events with options ----- > let clickHandler = on defaultOptions "click" emptyDecoder $ \() -> Action+-- > let clickHandler = onWithOptions defaultOptions "click" emptyDecoder $ \() -> Action -- > in button_ [ clickHandler, class_ "add" ] [ text_ "+" ] -- onWithOptions@@ -194,7 +194,7 @@ -> Attribute action onWithOptions _ _ _ _ = E () --- | Constructs `CSS` for a DOM Element+-- | Constructs CSS for a DOM Element -- -- > import qualified Data.Map as M -- > div_ [ style_ $ M.singleton "background" "red" ] [ ]
ghcjs-src/Miso/Delegate.hs view
@@ -1,3 +1,12 @@+-----------------------------------------------------------------------------+-- |+-- Module : Miso.Delegate+-- Copyright : (C) 2016-2017 David M. Johnson+-- License : BSD3-style (see the file LICENSE)+-- Maintainer : David M. Johnson <djohnson.m@gmail.com>+-- Stability : experimental+-- Portability : non-portable+---------------------------------------------------------------------------- module Miso.Delegate where import Data.IORef
ghcjs-src/Miso/Effect/XHR.hs view
@@ -1,11 +1,11 @@ {-# LANGUAGE UndecidableInstances #-}-{-# LANGUAGE DataKinds #-}-{-# LANGUAGE TypeFamilies #-}-{-# LANGUAGE FlexibleInstances #-}-{-# LANGUAGE TypeOperators #-}-{-# LANGUAGE ScopedTypeVariables #-}-{-# LANGUAGE LambdaCase #-}-{-# LANGUAGE OverloadedStrings #-}+{-# LANGUAGE DataKinds #-}+{-# LANGUAGE TypeFamilies #-}+{-# LANGUAGE FlexibleInstances #-}+{-# LANGUAGE TypeOperators #-}+{-# LANGUAGE ScopedTypeVariables #-}+{-# LANGUAGE LambdaCase #-}+{-# LANGUAGE OverloadedStrings #-} ----------------------------------------------------------------------------- -- | -- Module : Miso.Effect.XHR@@ -23,8 +23,6 @@ import Miso.String import Servant.API -type Path = String- -- | Still a WIP, use ghcjs-base XHR for now, or other -- | Intermediate type for accumulation@@ -41,7 +39,8 @@ -> RouteInfo -> XHR api -type Result a = Either MisoString a+-- | Result of using `XHR`+type Result a = IO (Either MisoString a) -- | Verb instance {-# OVERLAPPABLE #-}@@ -75,6 +74,7 @@ -- } +-- | `Headers`, with `NoContent` instance {-# OVERLAPPING #-} ( BuildHeadersTo ls, ReflectMethod method ) => HasXHR (Verb method status cts (Headers ls NoContent)) where
ghcjs-src/Miso/FFI.hs view
@@ -119,6 +119,8 @@ foreign import javascript unsafe "copyDOMIntoVTree($1);" copyDOMIntoVTree :: JSVal -> IO () +-- | Event delegation FFI, routes events received on body through the virtual dom+-- Invokes event handler when found foreign import javascript unsafe "delegate($1, $2);" delegateEvent :: JSVal -- ^ Events
ghcjs-src/Miso/Router.hs view
@@ -9,6 +9,15 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# OPTIONS_GHC -fno-warn-orphans #-}+-----------------------------------------------------------------------------+-- |+-- Module : Miso.Router+-- Copyright : (C) 2016-2017 David M. Johnson+-- License : BSD3-style (see the file LICENSE)+-- Maintainer : David M. Johnson <djohnson.m@gmail.com>+-- Stability : experimental+-- Portability : non-portable+---------------------------------------------------------------------------- module Miso.Router where import qualified Data.ByteString.Char8 as BS@@ -66,22 +75,26 @@ -- | Transform a route handler into a 'Router'. route :: Proxy layout -> Proxy a -> RouteT layout a -> Router a +-- | Alternative instance (HasRouter x, HasRouter y) => HasRouter (x :<|> y) where type RouteT (x :<|> y) a = RouteT x a :<|> RouteT y a route _ (a :: Proxy a) ((x :: RouteT x a) :<|> (y :: RouteT y a)) = RChoice (route (Proxy :: Proxy x) a x) (route (Proxy :: Proxy y) a y) +-- | Capture instance (HasRouter sublayout, FromHttpApiData x) => HasRouter (Capture sym x :> sublayout) where type RouteT (Capture sym x :> sublayout) a = x -> RouteT sublayout a route _ a f = RCapture (route (Proxy :: Proxy sublayout) a . f) +-- | QueryParam instance (HasRouter sublayout, FromHttpApiData x, KnownSymbol sym) => HasRouter (QueryParam sym x :> sublayout) where type RouteT (QueryParam sym x :> sublayout) a = Maybe x -> RouteT sublayout a route _ a f = RQueryParam (Proxy :: Proxy sym) (route (Proxy :: Proxy sublayout) a . f) +-- | QueryParams instance (HasRouter sublayout, FromHttpApiData x, KnownSymbol sym) => HasRouter (QueryParams sym x :> sublayout) where type RouteT (QueryParams sym x :> sublayout) a = [x] -> RouteT sublayout a@@ -89,6 +102,7 @@ (Proxy :: Proxy sym) (route (Proxy :: Proxy sublayout) a . f) +-- | QueryFlag instance (HasRouter sublayout, KnownSymbol sym) => HasRouter (QueryFlag sym :> sublayout) where type RouteT (QueryFlag sym :> sublayout) a = Bool -> RouteT sublayout a@@ -96,6 +110,7 @@ (Proxy :: Proxy sym) (route (Proxy :: Proxy sublayout) a . f) +-- | Path instance (HasRouter sublayout, KnownSymbol path) => HasRouter (path :> sublayout) where type RouteT (path :> sublayout) a = RouteT sublayout a@@ -103,10 +118,12 @@ (Proxy :: Proxy path) (route (Proxy :: Proxy sublayout) a page) +-- | View instance HasRouter (View a) where type RouteT (View a) x = x route _ _ = RPage +-- | Link instance HasLink (View a) where type MkLink (View a) = MkLink (Get '[] ()) toLink _ = toLink (Proxy :: Proxy (Get '[] ()))
ghcjs-src/Miso/Subscription/Keyboard.hs view
@@ -56,6 +56,7 @@ (_,_) -> 0 } +-- | Maps `Arrows` onto a Keyboard subscription arrowsSub :: (Arrows -> action) -> Sub action model arrowsSub = keyboardSub . (. toArrows)
ghcjs-src/Miso/Subscription/WebSocket.hs view
@@ -20,6 +20,9 @@ , URL (..) , Protocols (..) , SocketState (..)+ , CloseCode (..)+ , WasClean (..)+ , Reason (..) -- * Subscription , websocketSub , send@@ -110,14 +113,18 @@ socket <- createWebSocket url' ps atomicWriteIORef websocket (Just socket) +-- | URL of Websocket server newtype URL = URL MisoString deriving (Show, Eq) +-- | Protocols for Websocket connection newtype Protocols = Protocols [MisoString] deriving (Show, Eq) +-- | Wether or not the connection closed was done so cleanly newtype WasClean = WasClean Bool deriving (Show, Eq) +-- | Reason for closed connection newtype Reason = Reason MisoString deriving (Show, Eq) foreign import javascript unsafe "$r = new WebSocket($1, $2);"@@ -126,6 +133,7 @@ foreign import javascript unsafe "$r = $1.readyState;" getSocketState' :: Socket -> IO Int +-- | `SocketState` corresponding to current WebSocket connection data SocketState = CONNECTING -- ^ 0 | OPEN -- ^ 1@@ -176,7 +184,8 @@ newtype Socket = Socket JSVal ---- | https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent+-- | Code corresponding to a closed connection+-- https://developer.mozilla.org/en-US/docs/Web/API/CloseEvent data CloseCode = CLOSE_NORMAL -- ^ 1000, Normal closure; the connection successfully completed whatever purpose for which it was created.
miso.cabal view
@@ -1,5 +1,5 @@ name: miso-version: 0.1.0.3+version: 0.1.0.4 category: Web, Miso, Data Structures license: BSD3 license-file: LICENSE