threepenny-gui 0.4.1.0 → 0.4.2.0
raw patch · 11 files changed
+87/−52 lines, 11 filesdep ~aesondep ~bytestringdep ~network
Dependency ranges changed: aeson, bytestring, network, template-haskell, transformers
Files
- CHANGELOG.md +8/−0
- samples/Buttons.hs +1/−1
- samples/Chat.hs +1/−1
- samples/MissingDollars.hs +1/−1
- samples/Paths.hs +5/−1
- samples/UseWords.hs +1/−1
- src/Graphics/UI/Threepenny/Core.hs +5/−0
- src/Graphics/UI/Threepenny/Internal/Driver.hs +1/−2
- src/Graphics/UI/Threepenny/Internal/Types.hs +25/−4
- src/Graphics/UI/driver.js +34/−36
- threepenny-gui.cabal +5/−5
CHANGELOG.md view
@@ -1,5 +1,13 @@ ## Changelog for the `threepenny-gui` package +**0.4.2.0** -- Maintenance release.++* Dependency `bytestring >=0.9.2` is now implemented correctly.+* Allow newer versions of `aeson` dependency.+* Allow newer versions of `network`, `transformers` and `template-haskell` dependencies.+* Helper scripts in the `samples` directory now assume that you use a cabal sandbox for development.+* The `UI` monad is now an instance of the `Applicative` class.+ **0.4.1.0** -- Maintenance release. * Dependency on `text` package now from version 0.11 to 1.1.*.
samples/Buttons.hs view
@@ -71,5 +71,5 @@ viewSource = UI.p #+ [UI.anchor #. "view-source" # set UI.href url #+ [string "View source code"]] where- url = "https://github.com/HeinrichApfelmus/threepenny-gui/blob/master/src/Buttons.hs"+ url = samplesURL ++ "Buttons.hs"
samples/Chat.hs view
@@ -102,4 +102,4 @@ viewSource = UI.anchor #. "view-source" # set UI.href url #+ [string "View source code"] where- url = "https://github.com/HeinrichApfelmus/threepenny-gui/blob/master/src/Chat.hs"+ url = samplesURL ++ "Chat.hs"
samples/MissingDollars.hs view
@@ -44,7 +44,7 @@ ] ] where- urlSource = "https://github.com/HeinrichApfelmus/threepenny-gui/blob/master/src/MissingDollars.hs"+ urlSource = samplesURL ++ "MissingDollars.hs" urlAttribution = "http://www.vex.net/~trebla/humour/missing_dollar.html"
samples/Paths.hs view
@@ -1,5 +1,5 @@ {-# LANGUAGE CPP#-}-module Paths (getStaticDir) where+module Paths (getStaticDir, samplesURL) where import Control.Monad import System.FilePath@@ -18,3 +18,7 @@ getStaticDir = return "../wwwroot/" #endif++-- | Base URL for the example source code.+samplesURL :: String+samplesURL = "https://github.com/HeinrichApfelmus/threepenny-gui/blob/master/samples/"
samples/UseWords.hs view
@@ -73,7 +73,7 @@ viewSource = UI.p #+ [UI.anchor #. "view-source" # set UI.href url #+ [UI.string "View source code"]] where- url = "https://github.com/HeinrichApfelmus/threepenny-gui/blob/master/src/UseWords.hs"+ url = samplesURL ++ "UseWords.hs" {----------------------------------------------------------------------------- Parsing
src/Graphics/UI/Threepenny/Core.hs view
@@ -64,6 +64,7 @@ import Data.Functor import Data.String (fromString) +import Control.Applicative (Applicative) import Control.Concurrent.MVar import Control.Monad import Control.Monad.Fix@@ -156,6 +157,10 @@ instance Functor UI where fmap f = UI . fmap f . unUI++instance Applicative UI where+ pure = return+ (<*>) = ap instance Monad UI where return = UI . return
src/Graphics/UI/Threepenny/Internal/Driver.hs view
@@ -88,7 +88,6 @@ import qualified Data.Aeson as JSON import Data.Aeson (Result(..))-import Data.Aeson.Generic import qualified Data.ByteString.Lazy.Char8 as LBS import Data.Data @@ -248,7 +247,7 @@ signal Session{..} = do input <- getParam "signal" let err = error $ "Unable to parse " ++ show input- case JSON.decode . LBS.fromStrict =<< input of+ case JSON.decode . LBS.fromChunks . return =<< input of Just signal -> liftIO $ writeChan sSignals signal Nothing -> err
src/Graphics/UI/Threepenny/Internal/Types.hs view
@@ -17,12 +17,13 @@ import Data.Map (Map) import Data.String (fromString) import Data.Time+import Data.Text.Encoding (encodeUtf8, decodeUtf8) import Network.URI import Data.Data import Data.Aeson as JSON import qualified Data.Aeson.Types as JSON-import qualified Data.Aeson.Generic+import Data.Text import System.IO (stderr) import System.IO.Unsafe@@ -62,9 +63,9 @@ -- Marshalling ElementId instance ToJSON ElementId where- toJSON (ElementId o) = toJSON o+ toJSON (ElementId o) = toJSON $ decodeUtf8 o instance FromJSON ElementId where- parseJSON (Object v) = ElementId <$> v .: "Element"+ parseJSON (Object v) = (ElementId . encodeUtf8) <$> v .: "Element" parseJSON _ = mzero @@ -148,6 +149,10 @@ instance NFData Closure where rnf (Closure x) = rnf x +instance ToJSON Closure where+ toJSON (Closure (x,y)) = toJSON [toJSON x, toJSON y]++ {----------------------------------------------------------------------------- Public types ------------------------------------------------------------------------------}@@ -204,7 +209,23 @@ deriving (Typeable,Data,Show) instance ToJSON Instruction where- toJSON x = Data.Aeson.Generic.toJSON x + toJSON (Debug x) = object [ "tag" .= ("Debug" :: Text)+ , "contents" .= x]+ toJSON (SetToken x) = object [ "tag" .= ("SetToken" :: Text)+ , "contents" .= x]+ toJSON (Bind x y) = object [ "tag" .= ("Bind" :: Text)+ , "contents" .= [toJSON x, toJSON y]]+ toJSON (GetValues xs) = object [ "tag" .= ("GetValues" :: Text)+ , "contents" .= xs]+ toJSON (RunJSFunction x) = object [ "tag" .= ("RunJSFunction" :: Text)+ , "contents" .= x]+ toJSON (CallJSFunction x) = object [ "tag" .= ("CallJSFunction" :: Text)+ , "contents" .= x]+ toJSON (CallDeferredFunction (x,y,z))+ = object [ "tag" .= ("CallDeferredFunction" :: Text)+ , "contents" .= [toJSON x, toJSON y, toJSON z]]+ toJSON (Delete x) = object [ "tag" .= ("Delete" :: Text)+ , "contents" .= x] instance NFData Instruction where rnf (Debug x ) = rnf x
src/Graphics/UI/driver.js view
@@ -205,46 +205,45 @@ // sendEvent -- Function that sends a message { Event : value } to the server. console_log("Event: %s",JSON.stringify(event));- for(var key in event){- switch(key){+ switch(event.tag){ - case "CallDeferredFunction": {- // FIXME: CallDeferredFunction probably doesn't work right now.- var call = event.CallDeferredFunction;- var closure = call[0];- var theFunction = eval(call[1]);- var params = call[2];- theFunction.apply(window, params.concat(function(){- console_log(this);- var args = Array.prototype.slice.call(arguments,0);- sendEvent(closure[0],closure[1],args);- }));- reply();- break;- }- case "RunJSFunction": {- eval(event.RunJSFunction);+ case "CallDeferredFunction": {+ // FIXME: CallDeferredFunction probably doesn't work right now.+ var call = event.contents;+ var closure = call[0];+ var theFunction = eval(call[1]);+ var params = call[2];+ theFunction.apply(window, params.concat(function(){+ console_log(this);+ var args = Array.prototype.slice.call(arguments,0);+ sendEvent(closure[0],closure[1],args);+ }));+ reply();+ break;+ }+ case "RunJSFunction": {+ eval(event.contents); reply(); break;- }- case "CallJSFunction": {- var result = eval(event.CallJSFunction);+ }+ case "CallJSFunction": {+ var result = eval(event.contents); reply({FunctionResult : result}); break;- }- case "Delete": {- deleteElid(event.Delete);+ }+ case "Delete": {+ deleteElid(event.contents); reply(); break;- }- case "Debug": {+ }+ case "Debug": { if(window.console)- console.log("Server debug: %o",event.Debug);+ console.log("Server debug: %o",event.contents); reply(); break;- }- case "GetValues": {- var ids = event.GetValues;+ }+ case "GetValues": {+ var ids = event.contents; var len = ids.length; var values = []; for(var i = 0; i < len; i++) {@@ -252,9 +251,9 @@ } reply({ Values: values }); break;- }- case "Bind": {- var bind = event.Bind;+ }+ case "Bind": {+ var bind = event.contents; var eventType = bind[0]; var elid = bind[1]; var el = elidToElement(elid);@@ -298,9 +297,8 @@ } reply(); break;- }- default: reply();- }+ }+ default: reply(); } }
threepenny-gui.cabal view
@@ -1,5 +1,5 @@ Name: threepenny-gui-Version: 0.4.1.0+Version: 0.4.2.0 Synopsis: GUI framework that uses the web browser as a display. Description: Threepenny-GUI is a GUI framework that uses the web browser as a display.@@ -92,7 +92,7 @@ cpp-options: -DREBUG ghc-options: -O2 build-depends: base >= 4 && < 5- ,aeson == 0.6.*+ ,aeson >= 0.6 && < 0.8 ,attoparsec-enumerator == 0.3.* ,bytestring >= 0.9.2 && < 0.11 ,containers >= 0.4.2 && < 0.6@@ -101,15 +101,15 @@ ,filepath == 1.3.* ,hashable >= 1.1.0 && < 1.3 ,MonadCatchIO-transformers == 0.3.*- ,network >= 2.3.0 && < 2.5+ ,network >= 2.3.0 && < 2.6 ,safe == 0.3.* ,snap-server == 0.9.* ,snap-core == 0.9.* ,stm >= 2.3 && < 2.5- ,template-haskell >= 2.7.0 && < 2.9+ ,template-haskell >= 2.7.0 && < 2.10 ,text >= 0.11 && < 1.2 ,time == 1.4.*- ,transformers == 0.3.*+ ,transformers >= 0.3.0 && < 0.5 ,unordered-containers == 0.2.* ,utf8-string == 0.3.* ,websockets == 0.8.*