packages feed

react-flux 1.0.1 → 1.0.2

raw patch · 25 files changed

+189/−188 lines, 25 files

Files

ChangeLog.md view
@@ -1,3 +1,10 @@+# 1.0.2++* Update to build with latest ghcjs master.  The breaking change was+  https://github.com/ghcjs/ghcjs-base/commit/968dff527c2be2d3d4815e437ad9b2931ea1f35d+  which renamed JSRef to JSVal.  Therefore, react-flux no longer builds with ghcjs versions without+  this commit.+ # 1.0.1  * Add formatting support for properties to `React.Flux.Addons.Intl`.  These are needed for example to translate@@ -21,7 +28,7 @@ * The type of `callback` has extended to allow arbitrary function properties to be   passed to foreign classes.  The old `callback` accepted callbacks of type `Aeson.Value -> handler`   while the new callback allows functions of any number of arguments, as long as each argument implements-  `FromJSRef`.  Since `Aeson.Value` implements `FromJSRef`, any existing calls to `callback` should still work.+  `FromJSVal`.  Since `Aeson.Value` implements `FromJSVal`, any existing calls to `callback` should still work.   This change also caused some changes to types in `React.Flux.Internal`.  * Add a function `nestedProperty` to `React.Flux.PropertiesAndEvents` to create nested properties.@@ -44,7 +51,7 @@  * Fix to build with latest ghcjs-base (requires at least aaa4d59117f37d1b9c60a154a9128b3bcc6301cd)   of ghcjs-base), so you may need to recompile ghcjs and ghcjs-base.-* Add a function 'property' to create a property from any JSRef, not just Aeson values.+* Add a function 'property' to create a property from any JSVal, not just Aeson values. * Add a function 'elementProperty' to create a property from a ReactElementM, useful for   interacting with foreign React classes. 
example/README.md view
@@ -1,4 +1,4 @@-This directory contains two example applications.+This directory contains three example applications.  # Todo Example 
example/purecss-side-menu/NavStore.hs view
@@ -8,9 +8,9 @@ import GHC.Generics (Generic) import React.Flux -import GHCJS.Types (JSRef, JSString)+import GHCJS.Types (JSVal, JSString) import GHCJS.Foreign.Callback (Callback, syncCallback1, OnBlocked(..))-import GHCJS.Marshal (fromJSRef)+import GHCJS.Marshal (fromJSVal) import qualified Data.JSString as JSString  data NavPageId = Page1@@ -77,7 +77,7 @@  foreign import javascript unsafe     "window['onpopstate'] = function(e) { $1(e['state'] ? e['state'].page : 0); };"-    js_setOnPopState :: Callback (JSRef -> IO ()) -> IO ()+    js_setOnPopState :: Callback (JSVal -> IO ()) -> IO ()  initHistory :: IO () initHistory = do@@ -87,6 +87,6 @@      -- register a callback for onpopstate event     c <- syncCallback1 ContinueAsync $ \pageRef -> do-        pageInt <- fromMaybe (error "Unable to parse page") <$> fromJSRef pageRef+        pageInt <- fromMaybe (error "Unable to parse page") <$> fromJSVal pageRef         alterStore currentNavPageStore $ BackToPage $ toEnum pageInt     js_setOnPopState c
example/purecss-side-menu/index.html view
@@ -9,8 +9,8 @@     </head>     <body>         <div id="side-menu-app"/>-        <script src="https://fb.me/react-0.14.0-rc1.min.js"></script>-        <script src="https://fb.me/react-dom-0.14.0-rc1.min.js"></script>+        <script src="https://fb.me/react-0.14.1.min.js"></script>+        <script src="https://fb.me/react-dom-0.14.1.min.js"></script>         <script src="purecss-side-menu.js"></script>     </body> </html>
example/routing/Router.hs view
@@ -28,7 +28,7 @@ import           Control.Monad (liftM) import qualified Data.JSString as JSS import           GHCJS.Foreign.Callback-import           GHCJS.Types (JSString, JSRef)+import           GHCJS.Types (JSString, JSVal) import           Unsafe.Coerce  #endif@@ -37,7 +37,7 @@  foreign import javascript unsafe   "window.onhashchange = function() {$1(location.hash.toString());}"-  js_attachtLocationHashCb :: (Callback (JSRef -> IO ())) -> IO ()+  js_attachtLocationHashCb :: (Callback (JSVal -> IO ())) -> IO ()  foreign import javascript unsafe   "window.location.hash = $1"
example/todo/Makefile view
@@ -8,8 +8,6 @@ 	echo "})(window, window['React'], window['ReactDOM']);" >> js-build/todo.js 	sed -i 's/goog.provide.*//' js-build/todo.js 	sed -i 's/goog.require.*//' js-build/todo.js-	# https://github.com/ghcjs/shims/issues/21-	sed -i 's/final\([^a-z]\)/final0\1/g' js-build/todo.js  clean: 	rm -rf js-build
example/todo/todo-dev.html view
@@ -7,8 +7,8 @@     </head>     <body>         <section id="todoapp"/>-        <script src="https://fb.me/react-0.14.0-rc1.js"></script>-        <script src=" https://fb.me/react-dom-0.14.0-rc1.js"></script>+        <script src="https://fb.me/react-0.14.1.js"></script>+        <script src=" https://fb.me/react-dom-0.14.1.js"></script>         <script src="../../dist/build/todo/todo.jsexe/all.js"></script>     </body> </html>
example/todo/todo.html view
@@ -7,8 +7,8 @@     </head>     <body>         <section id="todoapp"/>-        <script src="https://fb.me/react-0.14.0-rc1.js"></script>-        <script src="https://fb.me/react-dom-0.14.0-rc1.js"></script>+        <script src="https://fb.me/react-0.14.1.js"></script>+        <script src="https://fb.me/react-dom-0.14.1.js"></script>         <script src="js-build/todo.min.js"></script>     </body> </html>
react-flux.cabal view
@@ -1,5 +1,5 @@ name:                react-flux-version:             1.0.1+version:             1.0.2 synopsis:            A binding to React based on the Flux application architecture for GHCJS category:            Web homepage:            https://bitbucket.org/wuzzeb/react-flux
src/React/Flux.hs view
@@ -106,8 +106,8 @@ import React.Flux.Store  #ifdef __GHCJS__-import GHCJS.Types (JSString, JSRef, nullRef)-import GHCJS.Marshal (fromJSRef)+import GHCJS.Types (JSString, JSVal, nullRef)+import GHCJS.Marshal (fromJSVal) #endif  ----------------------------------------------------------------------------------------------------@@ -155,16 +155,16 @@     sRef <- (if includeStatic then js_ReactRenderStaticMarkup else js_ReactRenderToString) e     --return sRef     --return $ JSS.unpack sRef-    mtxt <- fromJSRef sRef+    mtxt <- fromJSVal sRef     maybe (error "Unable to convert string return to Text") return mtxt  foreign import javascript unsafe     "(typeof ReactDOM === 'object' ? ReactDOM : React)['renderToString']($1)"-    js_ReactRenderToString :: ReactElementRef -> IO JSRef+    js_ReactRenderToString :: ReactElementRef -> IO JSVal  foreign import javascript unsafe     "(typeof ReactDOM === 'object' ? ReactDOM : React)['renderToStaticMarkup']($1)"-    js_ReactRenderStaticMarkup :: ReactElementRef -> IO JSRef+    js_ReactRenderStaticMarkup :: ReactElementRef -> IO JSVal  #else 
src/React/Flux/Addons/Bootstrap.hs view
@@ -8,7 +8,7 @@ import React.Flux  #ifdef __GHCJS__-import GHCJS.Types (JSRef, JSString)+import GHCJS.Types (JSVal, JSString) import React.Flux.Internal (toJSString) #endif @@ -40,7 +40,7 @@  foreign import javascript unsafe     "window['ReactBootstrap'][$1]"-    js_ReactBootstrap :: JSString -> JSRef+    js_ReactBootstrap :: JSString -> JSVal  #else 
src/React/Flux/Addons/Intl.hs view
@@ -74,7 +74,7 @@ -- --        foreign import javascript unsafe --          "window[\'myMessages\'] ? window[\'myMessages\'][$1] : null"---          js_myMessages :: JSString -> JSRef+--          js_myMessages :: JSString -> JSVal -- --        myApp :: ReactView () --        myApp = defineView "my application" $ \() -> do@@ -157,54 +157,54 @@  #ifdef __GHCJS__ -import GHCJS.Types (JSRef, JSString)-import GHCJS.Marshal (ToJSRef(..))+import GHCJS.Types (JSVal, JSString)+import GHCJS.Marshal (ToJSVal(..)) import qualified Data.JSString as JSS  foreign import javascript unsafe     "$r = ReactIntl['IntlProvider']"-    js_intlProvider :: JSRef+    js_intlProvider :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedNumber']"-    js_formatNumber :: JSRef+    js_formatNumber :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedDate']"-    js_formatDate :: JSRef+    js_formatDate :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedRelative']"-    js_formatRelative :: JSRef+    js_formatRelative :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedPlural']"-    js_formatPlural :: JSRef+    js_formatPlural :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedMessage']"-    js_formatMsg :: JSRef+    js_formatMsg :: JSVal  foreign import javascript unsafe     "$r = ReactIntl['FormattedHTMLMessage']"-    js_formatHtmlMsg :: JSRef+    js_formatHtmlMsg :: JSVal  foreign import javascript unsafe     "$r = (new Date($1, $2-1, $3))"-    js_mkDate :: Int -> Int -> Int -> JSRef+    js_mkDate :: Int -> Int -> Int -> JSVal  -- | Convert a day to a javascript Date-dayToRef :: Day -> JSRef+dayToRef :: Day -> JSVal dayToRef day = js_mkDate (fromIntegral y) m d     where         (y, m, d) = toGregorian day  foreign import javascript unsafe     "$r = (new Date(Date.UTC($1, $2-1, $3, $4, $5, $6, $7)))"-    js_mkDateTime :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> JSRef+    js_mkDateTime :: Int -> Int -> Int -> Int -> Int -> Int -> Int -> JSVal  -- | Convert a UTCTime to a javascript date object.-timeToRef :: UTCTime -> JSRef+timeToRef :: UTCTime -> JSVal timeToRef (UTCTime uday time) = js_mkDateTime (fromIntegral year) month day hour minute sec micro     where         (year, month, day) = toGregorian uday@@ -215,52 +215,52 @@  foreign import javascript unsafe     "$1['intl'][$2]($3, $4)"-    js_callContextAPI :: JSRef -> JSString -> JSRef -> JSRef -> IO JSRef+    js_callContextAPI :: JSVal -> JSString -> JSVal -> JSVal -> IO JSVal  -data ContextApiCall a = ContextApiCall String a [Pair] JSRef+data ContextApiCall a = ContextApiCall String a [Pair] JSVal -instance ToJSRef a => ToJSRef (ContextApiCall a) where-    toJSRef (ContextApiCall name a b ctx) = do-        aRef <- toJSRef a-        bRef <- toJSRef $ object b+instance ToJSVal a => ToJSVal (ContextApiCall a) where+    toJSVal (ContextApiCall name a b ctx) = do+        aRef <- toJSVal a+        bRef <- toJSVal $ object b         js_callContextAPI ctx (JSS.pack name) aRef bRef -formatCtx :: ToJSRef a => String -> String -> a -> [Pair] -> PropertyOrHandler handler+formatCtx :: ToJSVal a => String -> String -> a -> [Pair] -> PropertyOrHandler handler formatCtx name func val options = PropertyFromContext name $ ContextApiCall func val options  #else -type JSRef = ()+type JSVal = () -js_intlProvider :: JSRef+js_intlProvider :: JSVal js_intlProvider = () -js_formatNumber :: JSRef+js_formatNumber :: JSVal js_formatNumber = () -js_formatDate :: JSRef+js_formatDate :: JSVal js_formatDate = () -js_formatRelative :: JSRef+js_formatRelative :: JSVal js_formatRelative = () -js_formatPlural :: JSRef+js_formatPlural :: JSVal js_formatPlural = () -js_formatMsg :: JSRef+js_formatMsg :: JSVal js_formatMsg = () -js_formatHtmlMsg :: JSRef+js_formatHtmlMsg :: JSVal js_formatHtmlMsg = () -dayToRef :: Day -> JSRef+dayToRef :: Day -> JSVal dayToRef _ = () -timeToRef :: UTCTime -> JSRef+timeToRef :: UTCTime -> JSVal timeToRef _ = () -class ToJSRef a+class ToJSVal a  formatCtx :: String -> String -> a -> [Pair] -> PropertyOrHandler handler formatCtx name _ _ _ = PropertyFromContext name $ \() -> ()@@ -269,10 +269,10 @@  -- | Use the IntlProvider to set the @locale@, @formats@, and @messages@ property. intlProvider_ :: String -- ^ the locale to use-              -> Maybe JSRef+              -> Maybe JSVal                   -- ^ A reference to translated messages, which must be an object with keys                   -- 'MessageId' and value the translated message.  Set this as Nothing if you are not using-                  -- translated messages, since either @Nothing@ or a null JSRef will cause the messages+                  -- translated messages, since either @Nothing@ or a null JSVal will cause the messages                   -- from the source code to be used.               -> Maybe Object                   -- ^ An object to use for the @formats@ parameter which allows custom formats.  I@@ -311,7 +311,7 @@ -- or 'formattedNumber_' should be prefered because as components they can avoid re-rendering when -- the number has not changed. 'formattedNumberProp' is needed if the formatted number has to be -- a property on another element, such as the placeholder for an input element.-formattedNumberProp :: ToJSRef num+formattedNumberProp :: ToJSVal num                     => String -- ^ the property to set                     -> num -- ^ the number to format                     -> [Pair] -- ^ any options accepted by@@ -468,7 +468,7 @@ -- | Format a number properly based on pluralization, and then use it as the value for a property. -- 'plural_' should be preferred, but 'pluralProp' can be used in places where a component is not -- possible such as the placeholder of an input element.-pluralProp :: ToJSRef val => String -> val -> [Pair] -> PropertyOrHandler eventHandler+pluralProp :: ToJSVal val => String -> val -> [Pair] -> PropertyOrHandler eventHandler pluralProp name val options = formatCtx name "formatPlural" val options  --------------------------------------------------------------------------------
src/React/Flux/Addons/React.hs view
@@ -19,7 +19,7 @@ import React.Flux  #ifdef __GHCJS__-import GHCJS.Types (JSRef, JSString)+import GHCJS.Types (JSVal, JSString) #endif  -- | The <https://facebook.github.io/react/docs/animation.html ReactCSSTransitionGroup> element.@@ -34,7 +34,7 @@  foreign import javascript unsafe     "React['addons']['CSSTransitionGroup']"-    js_CSSTransitionGroup :: JSRef+    js_CSSTransitionGroup :: JSVal  #else cssTransitionGroup _ x = x
src/React/Flux/Combinators.hs view
@@ -16,11 +16,11 @@ import React.Flux.Views  #ifdef __GHCJS__-import GHCJS.Types (JSString, JSRef)+import GHCJS.Types (JSString, JSVal)  foreign import javascript unsafe     "$r = window[$1]"-    js_lookupWindow :: JSString -> JSRef+    js_lookupWindow :: JSString -> JSVal #else js_lookupWindow :: a -> () js_lookupWindow _ = ()
src/React/Flux/Export.hs view
@@ -9,7 +9,7 @@  import GHCJS.Types -newtype Export a = Export JSRef+newtype Export a = Export JSVal  foreign import javascript unsafe     "hsreact$export($1)"
src/React/Flux/Internal.hs view
@@ -33,35 +33,35 @@ import qualified JavaScript.Array as JSA import           GHCJS.Foreign.Callback import qualified JavaScript.Object as JSO-import           GHCJS.Types (JSRef, JSString, IsJSRef, jsref)-import           GHCJS.Marshal (ToJSRef(..))+import           GHCJS.Types (JSVal, JSString, IsJSVal, jsval)+import           GHCJS.Marshal (ToJSVal(..)) import           GHCJS.Foreign (jsNull) import           React.Flux.Export #else import Data.Text (Text) type Callback a = ()-type JSRef = ()-class ToJSRef a-instance ToJSRef Value-instance ToJSRef Text-instance ToJSRef ()-class IsJSRef a-type JSArray = JSRef+type JSVal = ()+class ToJSVal a+instance ToJSVal Value+instance ToJSVal Text+instance ToJSVal ()+class IsJSVal a+type JSArray = JSVal #endif  -- type JSObject a = JSO.Object a  -- | This type is for the return value of @React.createClass@-newtype ReactViewRef props = ReactViewRef { reactViewRef :: JSRef }-instance IsJSRef (ReactViewRef props)+newtype ReactViewRef props = ReactViewRef { reactViewRef :: JSVal }+instance IsJSVal (ReactViewRef props)  -- | This type is for the return value of @React.createElement@-newtype ReactElementRef = ReactElementRef { reactElementRef :: JSRef }-instance IsJSRef ReactElementRef+newtype ReactElementRef = ReactElementRef { reactElementRef :: JSVal }+instance IsJSVal ReactElementRef  -- | The first parameter of an event handler registered with React.-newtype HandlerArg = HandlerArg JSRef-instance IsJSRef HandlerArg+newtype HandlerArg = HandlerArg JSVal+instance IsJSVal HandlerArg  instance Show HandlerArg where     show _ = "HandlerArg"@@ -71,13 +71,13 @@ -- The combination of all properties and event handlers are used to create the javascript object -- passed as the second argument to @React.createElement@. data PropertyOrHandler handler =-   forall ref. ToJSRef ref => Property+   forall ref. ToJSVal ref => Property       { propertyName :: String       , propertyVal :: ref       }- | forall ref. ToJSRef ref => PropertyFromContext + | forall ref. ToJSVal ref => PropertyFromContext        { propFromThisName :: String-      , propFromThisVal :: JSRef -> ref -- ^ will be passed this.context+      , propFromThisVal :: JSVal -> ref -- ^ will be passed this.context       }  | NestedProperty       { nestedPropertyName :: String@@ -105,20 +105,20 @@     fmap f (CallbackPropertyWithArgumentArray name h) = CallbackPropertyWithArgumentArray name (fmap f . h)     fmap f (CallbackPropertyWithSingleArgument name h) = CallbackPropertyWithSingleArgument name (f . h) --- | Create a property from anything that can be converted to a JSRef-property :: ToJSRef val => String -> val -> PropertyOrHandler handler+-- | Create a property from anything that can be converted to a JSVal+property :: ToJSVal val => String -> val -> PropertyOrHandler handler property = Property  -- | Keys in React can either be strings or integers class ReactViewKey key where-    toKeyRef :: key -> IO JSRef+    toKeyRef :: key -> IO JSVal  #if __GHCJS__ instance ReactViewKey String where     toKeyRef = return . unsafeCoerce . toJSString  instance ReactViewKey Int where-    toKeyRef i = toJSRef i+    toKeyRef i = toJSVal i #else instance ReactViewKey String where     toKeyRef = const $ return ()@@ -238,10 +238,10 @@ -- once the class is re-rendered. mkReactElement :: forall eventHandler.                   (eventHandler -> IO ())-               -> IO JSRef -- ^ this.context+               -> IO JSVal -- ^ this.context                -> IO [ReactElementRef] -- ^ this.props.children                -> ReactElementM eventHandler ()-               -> IO (ReactElementRef, [Callback (JSRef -> IO ())])+               -> IO (ReactElementRef, [Callback (JSVal -> IO ())])  #ifdef __GHCJS__ @@ -260,22 +260,22 @@                 [x] -> return x                 xs -> lift $ do                     emptyObj <- JSO.create-                    let arr = jsref $ JSA.fromList $ map reactElementRef xs+                    let arr = jsval $ JSA.fromList $ map reactElementRef xs                     js_ReactCreateElementName "div" emptyObj arr          -- add the property or handler to the javascript object         addPropOrHandlerToObj :: JSO.Object -> PropertyOrHandler eventHandler -> MkReactElementM ()         addPropOrHandlerToObj obj (Property n val) = lift $ do-            vRef <- toJSRef val+            vRef <- toJSVal val             JSO.setProp (toJSString n) vRef obj         addPropOrHandlerToObj obj (PropertyFromContext n f) = lift $ do             ctx <- getContext-            vRef <- toJSRef $ f ctx+            vRef <- toJSVal $ f ctx             JSO.setProp (toJSString n) vRef obj         addPropOrHandlerToObj obj (NestedProperty n vals) = do             nested <- lift $ JSO.create             mapM_ (addPropOrHandlerToObj nested) vals-            lift $ JSO.setProp (toJSString n) (jsref nested) obj+            lift $ JSO.setProp (toJSString n) (jsval nested) obj         addPropOrHandlerToObj obj (ElementProperty name rM) = do             ReactElementRef ref <- mToElem rM             lift $ JSO.setProp (toJSString name) ref obj@@ -292,7 +292,7 @@             cb <- lift $ syncCallback1 ContinueAsync $ \ref ->                 runHandler $ func $ HandlerArg ref             tell [cb]-            lift $ JSO.setProp (toJSString name) (jsref cb) obj+            lift $ JSO.setProp (toJSString name) (jsval cb) obj          -- call React.createElement         createElement :: ReactElement eventHandler -> MkReactElementM [ReactElementRef]@@ -307,7 +307,7 @@             let children = case map reactElementRef childNodes of                              [] -> jsNull                              [x] -> x-                             xs -> jsref $ JSA.fromList xs+                             xs -> jsval $ JSA.fromList xs             e <- lift $ case fName f of                 Left s -> js_ReactCreateElementName (toJSString s) obj children                 Right ref -> js_ReactCreateForeignElement ref obj children@@ -319,7 +319,7 @@             let children = case map reactElementRef childNodes of                              [] -> jsNull                              [x] -> x-                             xs -> jsref $ JSA.fromList xs+                             xs -> jsval $ JSA.fromList xs              e <- lift $ case mkey of                 Just key -> do@@ -328,7 +328,7 @@                 Nothing -> js_ReactCreateClass rc propsE children             return [e] -type MkReactElementM a = WriterT [Callback (JSRef -> IO ())] IO a+type MkReactElementM a = WriterT [Callback (JSVal -> IO ())] IO a  foreign import javascript unsafe     "React['createElement']($1)"@@ -336,23 +336,23 @@  foreign import javascript unsafe     "React['createElement']($1, $2, $3)"-    js_ReactCreateElementName :: JSString -> JSO.Object -> JSRef -> IO ReactElementRef+    js_ReactCreateElementName :: JSString -> JSO.Object -> JSVal -> IO ReactElementRef  foreign import javascript unsafe     "React['createElement']($1, $2, $3)"-    js_ReactCreateForeignElement :: ReactViewRef a -> JSO.Object -> JSRef -> IO ReactElementRef+    js_ReactCreateForeignElement :: ReactViewRef a -> JSO.Object -> JSVal -> IO ReactElementRef  foreign import javascript unsafe     "React['createElement']($1, {hs:$2}, $3)"-    js_ReactCreateClass :: ReactViewRef a -> Export props -> JSRef -> IO ReactElementRef+    js_ReactCreateClass :: ReactViewRef a -> Export props -> JSVal -> IO ReactElementRef  foreign import javascript unsafe     "React['createElement']($1, {key: $2, hs:$3}, $4)"-    js_ReactCreateKeyedElement :: ReactViewRef a -> JSRef -> Export props -> JSRef -> IO ReactElementRef+    js_ReactCreateKeyedElement :: ReactViewRef a -> JSVal -> Export props -> JSVal -> IO ReactElementRef  foreign import javascript unsafe     "hsreact$mk_arguments_callback($1)"-    js_CreateArgumentsCallback :: Callback (JSRef -> IO ()) -> IO JSRef+    js_CreateArgumentsCallback :: Callback (JSVal -> IO ()) -> IO JSVal  js_ReactCreateContent :: String -> ReactElementRef js_ReactCreateContent = ReactElementRef . unsafeCoerce . toJSString
src/React/Flux/Lifecycle.hs view
@@ -50,11 +50,11 @@  import GHCJS.Foreign (jsNull) import GHCJS.Foreign.Callback-import GHCJS.Types (JSRef, jsref)+import GHCJS.Types (JSVal, jsval)  #endif -type HTMLElement = JSRef+type HTMLElement = JSVal  -- | Actions to access the current properties and state. data LPropsAndState props state = LPropsAndState@@ -153,19 +153,19 @@     willUnmountCb <- mkLCallback1 (lComponentWillUnmount cfg) $ \f this ->         f (dom this) -    -- willMountCbRef <- toJSRef willMountCb-    -- didMountCbRef <- toJSRef didMountCb-    -- willRecvPropsCbRef <- toJSRef willRecvPropsCb-    -- willUpdateCbRef  <- toJSRef willUpdateCb-    -- didUpdateCbRef   <- toJSRef didUpdateCb-    -- willUnmountCbRef <- toJSRef willUnmountCb+    -- willMountCbRef <- toJSVal willMountCb+    -- didMountCbRef <- toJSVal didMountCb+    -- willRecvPropsCbRef <- toJSVal willRecvPropsCb+    -- willUpdateCbRef  <- toJSVal willUpdateCb+    -- didUpdateCbRef   <- toJSVal didUpdateCb+    -- willUnmountCbRef <- toJSVal willUnmountCb     ReactView <$> js_makeLifecycleView (toJSString name) initialRef       renderCb willMountCb didMountCb willRecvPropsCb willUpdateCb didUpdateCb willUnmountCb  mkLCallback1 :: (Typeable props, Typeable state)              => Maybe (LPropsAndState props state -> f)              -> (f -> ReactThis state props -> IO ())-             -> IO JSRef+             -> IO JSVal mkLCallback1 Nothing _ = return jsNull mkLCallback1 (Just f) c = do   cb <- syncCallback1 ThrowWouldBlock $ \thisRef -> do@@ -174,12 +174,12 @@                             , lGetState = js_ReactGetState this >>= parseExport                             }     c (f ps) this-  return $ jsref cb+  return $ jsval cb  mkLCallback2 :: (Typeable props, Typeable state)              => Maybe (LPropsAndState props state -> f)-             -> (f -> ReactThis state props -> JSRef -> IO ())-             -> IO JSRef+             -> (f -> ReactThis state props -> JSVal -> IO ())+             -> IO JSVal mkLCallback2 Nothing _ = return jsNull mkLCallback2 (Just f) c = do   cb <- syncCallback2 ThrowWouldBlock $ \thisRef argRef -> do@@ -188,7 +188,7 @@                             , lGetState = js_ReactGetState this >>= parseExport                             }     c (f ps) this argRef-  return $ jsref cb+  return $ jsval cb  #else 
src/React/Flux/PropertiesAndEvents.hs view
@@ -101,16 +101,16 @@ import           Data.Maybe (fromMaybe)  import           GHCJS.Foreign (fromJSBool)-import           GHCJS.Marshal (FromJSRef(..))-import           GHCJS.Types (JSRef, nullRef, JSString, IsJSRef)+import           GHCJS.Marshal (FromJSVal(..))+import           GHCJS.Types (JSVal, nullRef, JSString, IsJSVal) import           JavaScript.Array as JSA  #else-type JSRef = ()+type JSVal = () type JSString = String type JSArray = ()-class FromJSRef a-class IsJSRef a+class FromJSVal a+class IsJSVal a nullRef :: () nullRef = () #endif@@ -136,7 +136,7 @@ nestedProperty = NestedProperty  -- | A class which is used to implement <https://wiki.haskell.org/Varargs variable argument functions>.--- Any function where each argument implements 'FromJSRef' and the result is either+-- Any function where each argument implements 'FromJSVal' and the result is either -- 'ViewEventHandler' or 'StatefulViewEventHandler' is an instance of this class. class CallbackFunction handler a | a -> handler  where     applyFromArguments :: JSArray -> Int -> a -> IO handler@@ -147,10 +147,10 @@ instance CallbackFunction (StatefulViewEventHandler s) (StatefulViewEventHandler s) where     applyFromArguments _ _ h = return h -instance (FromJSRef a, CallbackFunction handler b) => CallbackFunction handler (a -> b) where+instance (FromJSVal a, CallbackFunction handler b) => CallbackFunction handler (a -> b) where #if __GHCJS__     applyFromArguments args k f = do-        ma <- fromJSRef $ if k >= JSA.length args then nullRef else JSA.index k args+        ma <- fromJSVal $ if k >= JSA.length args then nullRef else JSA.index k args         a <- maybe (error "Unable to decode callback argument") return ma         applyFromArguments args (k+1) $ f a #else@@ -162,11 +162,11 @@ -- the handlers below. -- -- The function @func@ can be any function, as long as each argument to the function is an instance--- of 'FromJSRef' and the result of the function is @handler@.  Internally, 'callback' creates a+-- of 'FromJSVal' and the result of the function is @handler@.  Internally, 'callback' creates a -- javascript function which accesses the @arguments@ javascript object and then matches entries in -- @arguments@ to the parameters of @func@.  If @func@ has more parameters than the javascript -- @arguments@ object, a javascript null is used for the conversion.  Since the 'Maybe' instance of--- 'FromJSRef' converts a null reference to 'Nothing', you can exploit this to create+-- 'FromJSVal' converts a null reference to 'Nothing', you can exploit this to create -- variable-argument javascript callbacks. -- -- For example, all three of the following functions could be passed as @func@ inside a view.@@ -206,14 +206,14 @@  -- | A reference to the object that dispatched the event. -- <https://developer.mozilla.org/en-US/docs/Web/API/Event/target>-newtype EventTarget = EventTarget JSRef-instance IsJSRef EventTarget+newtype EventTarget = EventTarget JSVal+instance IsJSVal EventTarget  instance Show (EventTarget) where     show _ = "EventTarget"  -- | Access a property in an event target-eventTargetProp :: FromJSRef val => EventTarget -> String -> val+eventTargetProp :: FromJSVal val => EventTarget -> String -> val eventTargetProp (EventTarget ref) key = ref .: toJSString key  -- | Every event in React is a synthetic event, a cross-browser wrapper around the native event.@@ -240,7 +240,7 @@ -- >           ] -- -- In this case, @val@ would coorespond to the javascript expression @evt.target.value@.-target :: FromJSRef val => Event -> String -> val+target :: FromJSVal val => Event -> String -> val target e s = eventTargetProp (evtTarget e) s  parseEvent :: HandlerArg -> Event@@ -309,11 +309,11 @@  foreign import javascript unsafe     "$1['preventDefault']();"-    js_preventDefault :: JSRef -> IO ()+    js_preventDefault :: JSVal -> IO ()  foreign import javascript unsafe     "$1['stopPropagation']();"-    js_stopProp :: JSRef -> IO ()+    js_stopProp :: JSVal -> IO ()  #else @@ -560,7 +560,7 @@     show (TouchEvent t1 t2 t3 _ t4 t5 t6 t7)         = show (t1, t2, t3, t4, t5, t6, t7) -parseTouch :: JSRef -> Touch+parseTouch :: JSVal -> Touch parseTouch o = Touch     { touchIdentifier = o .: "identifier"     , touchTarget = EventTarget $ js_getProp o "target"@@ -572,7 +572,7 @@     , touchPageY = o .: "pageY"     } -parseTouchList :: JSRef -> JSString -> [Touch]+parseTouchList :: JSVal -> JSString -> [Touch] parseTouchList obj key = unsafePerformIO $ do     let arr = js_getArrayProp obj key         len = arrayLength arr@@ -653,49 +653,49 @@  foreign import javascript unsafe     "$1[$2]"-    js_getProp :: JSRef -> JSString -> JSRef+    js_getProp :: JSVal -> JSString -> JSVal  foreign import javascript unsafe     "$1[$2]"-    js_getArrayProp :: JSRef -> JSString -> JSArray+    js_getArrayProp :: JSVal -> JSString -> JSArray  -- | Access a property from an object.  Since event objects are immutable, we can use -- unsafePerformIO without worry.-(.:) :: FromJSRef b => JSRef -> JSString -> b+(.:) :: FromJSVal b => JSVal -> JSString -> b obj .: key = fromMaybe (error "Unable to decode event target") $ unsafePerformIO $-    fromJSRef $ js_getProp obj key+    fromJSVal $ js_getProp obj key  foreign import javascript unsafe     "$1['getModifierState']($2)"-    js_GetModifierState :: JSRef -> JSString -> JSRef+    js_GetModifierState :: JSVal -> JSString -> JSVal -getModifierState :: JSRef -> String -> Bool+getModifierState :: JSVal -> String -> Bool getModifierState ref = fromJSBool . js_GetModifierState ref . toJSString  arrayLength :: JSArray -> Int arrayLength = JSA.length -arrayIndex :: Int -> JSArray -> JSRef+arrayIndex :: Int -> JSArray -> JSVal arrayIndex = JSA.index  #else -js_getProp :: a -> String -> JSRef+js_getProp :: a -> String -> JSVal js_getProp _ _ = () -js_getArrayProp :: a -> String -> JSRef+js_getArrayProp :: a -> String -> JSVal js_getArrayProp _ _ = () -(.:) :: JSRef -> String -> b+(.:) :: JSVal -> String -> b _ .: _ = undefined -getModifierState :: JSRef -> String -> Bool+getModifierState :: JSVal -> String -> Bool getModifierState _ _ = False  arrayLength :: JSArray -> Int arrayLength _ = 0 -arrayIndex :: Int -> JSArray -> JSRef+arrayIndex :: Int -> JSArray -> JSVal arrayIndex _ _ = ()  #endif
src/React/Flux/Store.hs view
@@ -16,16 +16,16 @@ import System.IO.Unsafe (unsafePerformIO)  #ifdef __GHCJS__-import GHCJS.Types (JSRef, isNull, IsJSRef)+import GHCJS.Types (JSVal, isNull, IsJSVal) import React.Flux.Export (Export, export) #else-type JSRef = ()-class IsJSRef a+type JSVal = ()+class IsJSVal a #endif  -- | This type is used to represent the foreign javascript object part of the store.-newtype ReactStoreRef storeData = ReactStoreRef JSRef-instance IsJSRef (ReactStoreRef storeData)+newtype ReactStoreRef storeData = ReactStoreRef JSVal+instance IsJSVal (ReactStoreRef storeData)  -- | A store contains application state, receives actions from the dispatcher, and notifies -- controller-views to re-render themselves.  You can have multiple stores; it should be the case
src/React/Flux/Views.hs view
@@ -13,11 +13,11 @@ import React.Flux.Export import JavaScript.Array import GHCJS.Foreign.Callback-import GHCJS.Types (JSRef, JSString, IsJSRef, jsref)-import GHCJS.Marshal (ToJSRef(..))+import GHCJS.Types (JSVal, JSString, IsJSVal, jsval)+import GHCJS.Marshal (ToJSVal(..))  #else-type JSRef = ()+type JSVal = () #endif  @@ -273,8 +273,8 @@  #ifdef __GHCJS__ -newtype ReactThis state props = ReactThis JSRef-instance IsJSRef (ReactThis state props)+newtype ReactThis state props = ReactThis JSVal+instance IsJSVal (ReactThis state props)  foreign import javascript unsafe     "$1['state'].hs"@@ -286,7 +286,7 @@  foreign import javascript unsafe     "$1['context']"-    js_ReactGetContext :: ReactThis state props -> IO JSRef+    js_ReactGetContext :: ReactThis state props -> IO JSVal  foreign import javascript unsafe     "hsreact$children_to_array($1['props']['children'])"@@ -301,31 +301,31 @@  foreign import javascript unsafe     "typeof ReactDOM === 'object' ? ReactDOM['findDOMNode']($1) : React['findDOMNode']($1)"-    js_ReactFindDOMNode :: ReactThis state props -> IO JSRef+    js_ReactFindDOMNode :: ReactThis state props -> IO JSVal  foreign import javascript unsafe     "typeof ReactDOM === 'object' ? $1['refs'][$2] : React['findDOMNode']($1['refs'][$2])"-    js_ReactGetRef :: ReactThis state props -> JSString -> IO JSRef+    js_ReactGetRef :: ReactThis state props -> JSString -> IO JSVal -newtype RenderCbArg = RenderCbArg JSRef-instance IsJSRef RenderCbArg+newtype RenderCbArg = RenderCbArg JSVal+instance IsJSVal RenderCbArg  foreign import javascript unsafe     "$1.newCallbacks = $2; $1.elem = $3;"-    js_RenderCbSetResults :: RenderCbArg -> JSRef -> ReactElementRef -> IO ()+    js_RenderCbSetResults :: RenderCbArg -> JSVal -> ReactElementRef -> IO ()  foreign import javascript unsafe     "hsreact$mk_ctrl_view($1, $2, $3)"     js_createControllerView :: JSString                             -> ReactStoreRef storeData-                            -> Callback (JSRef -> JSRef -> IO ())+                            -> Callback (JSVal -> JSVal -> IO ())                             -> IO (ReactViewRef props)  -- | Create a view with no state. foreign import javascript unsafe     "hsreact$mk_view($1, $2)"     js_createView :: JSString-                  -> Callback (JSRef -> JSRef -> IO ())+                  -> Callback (JSVal -> JSVal -> IO ())                   -> IO (ReactViewRef props)  -- | Create a view which tracks its own state.  Similar releasing needs to happen for callbacks and@@ -334,19 +334,19 @@     "hsreact$mk_stateful_view($1, $2, $3)"     js_createStatefulView :: JSString                           -> Export state-                          -> Callback (JSRef -> JSRef -> IO ())+                          -> Callback (JSVal -> JSVal -> IO ())                           -> IO (ReactViewRef props)  foreign import javascript unsafe     "hsreact$mk_lifecycle_view($1, $2, $3, $4, $5, $6, $7, $8, $9)"-    js_makeLifecycleView :: JSString -> Export state -> Callback (JSRef -> JSRef -> IO ())-                         -> JSRef -> JSRef -> JSRef -> JSRef -> JSRef -> JSRef -> IO (ReactViewRef props)+    js_makeLifecycleView :: JSString -> Export state -> Callback (JSVal -> JSVal -> IO ())+                         -> JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> JSVal -> IO (ReactViewRef props)  mkRenderCallback :: Typeable props                  => (ReactThis state props -> IO state) -- ^ parse state                  -> (ReactThis state props -> eventHandler -> IO ()) -- ^ execute event args                  -> (state -> props -> IO (ReactElementM eventHandler ())) -- ^ renderer-                 -> IO (Callback (JSRef -> JSRef -> IO ()))+                 -> IO (Callback (JSVal -> JSVal -> IO ())) mkRenderCallback parseState runHandler render = syncCallback2 ContinueAsync $ \thisRef argRef -> do     let this = ReactThis thisRef         arg = RenderCbArg argRef@@ -360,7 +360,7 @@      (element, evtCallbacks) <- mkReactElement (runHandler this) getContext getPropsChildren node -    evtCallbacksRef <- toJSRef $ map jsref evtCallbacks+    evtCallbacksRef <- toJSVal $ map jsval evtCallbacks     js_RenderCbSetResults arg evtCallbacksRef element  parseExport :: Typeable a => Export a -> IO a@@ -403,7 +403,7 @@  -- | Create a 'ReactElement' for a class defined in javascript.  See -- 'React.Flux.Combinators.foreign_' for a convenient wrapper and some examples.-foreignClass :: JSRef -- ^ The javascript reference to the class+foreignClass :: JSVal -- ^ The javascript reference to the class              -> [PropertyOrHandler eventHandler] -- ^ properties and handlers to pass when creating an instance of this class.              -> ReactElementM eventHandler a -- ^ The child element or elements              -> ReactElementM eventHandler a
test/client/TestClient.hs view
@@ -14,8 +14,8 @@ import React.Flux.Addons.React import React.Flux.Addons.Bootstrap -import GHCJS.Types (JSRef, JSString)-import GHCJS.Marshal (fromJSRef)+import GHCJS.Types (JSVal, JSString)+import GHCJS.Marshal (fromJSVal)  foreign import javascript unsafe     "(function(x) { \@@ -135,13 +135,13 @@  foreign import javascript unsafe     "$1.id"-    js_domGetId :: JSRef -> IO JSRef+    js_domGetId :: JSVal -> IO JSVal  logDOM :: LDOM -> IO () logDOM dom = do-    this <- lThis dom >>= js_domGetId >>= fromJSRef-    x <- lRef dom "refSt" >>= js_domGetId >>= fromJSRef-    y <- lRef dom "refProps" >>= js_domGetId >>= fromJSRef+    this <- lThis dom >>= js_domGetId >>= fromJSVal+    x <- lRef dom "refSt" >>= js_domGetId >>= fromJSVal+    y <- lRef dom "refProps" >>= js_domGetId >>= fromJSVal     outputIO [ "this id = " ++ fromMaybe "Nothing" this              , "refStr id = " ++ fromMaybe "Nothing" x              , "refProps id = " ++ fromMaybe "Nothing" y
test/client/TestClient14.hs view
@@ -4,7 +4,7 @@ import Data.Time import React.Flux import React.Flux.Addons.Intl-import GHCJS.Types (JSRef)+import GHCJS.Types (JSVal) import Data.Aeson ((.=))  import TestClient@@ -15,7 +15,7 @@  foreign import javascript unsafe     "{'with_trans': 'message from translation {abc}'}"-    js_translations :: JSRef+    js_translations :: JSVal  intlSpec :: ReactView () intlSpec = defineView "intl" $ \() ->@@ -63,10 +63,8 @@                     ]                    ] -        {-         li_ ["id" $= "f-relative"] $ relativeTo_ step         li_ ["id" $= "f-relative-days"] $ formattedRelative_ step [ "units" $= "day" ]-        -}          li_ ["id" $= "f-plural"] $ plural_ [ "value" @= (100 :: Int), "one" $= "plural one", "other" $= "plural other"]         li_ ["id" $= "f-plural-prop"] $
test/client/test-client14.html view
@@ -4,8 +4,8 @@     </head>     <body>         <div id="app"></div>-        <script src="https://fb.me/react-with-addons-0.14.0-rc1.js"></script>-        <script src=" https://fb.me/react-dom-0.14.0-rc1.js"></script>+        <script src="https://fb.me/react-with-addons-0.14.1.js"></script>+        <script src=" https://fb.me/react-dom-0.14.1.js"></script>         <script src="node_modules/react-intl/dist/react-intl.js"></script>         <script src="https://cdnjs.cloudflare.com/ajax/libs/react-bootstrap/0.25.2/react-bootstrap.min.js"></script>         <script src="../../dist/build/test-client-14/test-client-14.jsexe/all.js"></script>
test/spec/TestClientSpec.hs view
@@ -5,7 +5,7 @@ import           Control.Monad import           Control.Monad.IO.Class (liftIO) import           Data.List---import           Data.Time+import           Data.Time import qualified Data.Text              as T import           System.Directory       (getCurrentDirectory) import           Test.Hspec.WebDriver@@ -21,7 +21,7 @@                   , "evtCancelable = " ++ show evtBandC ++ ", "                   , "evtCurrentTarget = EventTarget, evtDefaultPrevented = False, "                   , "evtPhase = " ++ show evtPhase ++ ", "-                  , "evtIsTrusted = False, evtTarget = EventTarget, evtTimestamp = "+                  , "evtIsTrusted = True, evtTarget = EventTarget, evtTimestamp = "                   ]     unless (prefix `isPrefixOf` evt) $         error $ "Expecting " ++ prefix ++ " but got " ++ evt@@ -286,7 +286,7 @@         openPage $ "file://" ++ dir ++ "/../client/" ++ filename      it "displays the intl formatted data" $ runWD $ do-        "f-number" `intlSpanShouldBe` "90%"+        "f-number" `intlSpanShouldBe` "90.0%"         "f-int" `intlSpanShouldBe` "100,000"         "f-double" `intlSpanShouldBe` "40,000.2"         "f-shortday" `intlSpanShouldBe` "Jul 20, 1969"@@ -296,14 +296,12 @@         "f-time" `intlSpanShouldBe` "Jul 19, 69, 4:56:00 PM GMT-10"         "f-plural" `intlSpanShouldBe` "plural other" -        {-         today <- liftIO (utctDay <$> getCurrentTime)         let moon = fromGregorian 1969 7 20             daysAgo = diffDays today moon             yearsAgo :: Int = round $ realToFrac daysAgo / (365 :: Double) -- is close enough         "f-relative" `intlSpanShouldBe` (show yearsAgo ++ " years ago")         "f-relative-days" `intlSpanShouldBe` (showWithComma daysAgo ++ " days ago")-        -}      it "displays messages" $ runWD $ do         msg <- findElem $ ById "f-msg"
test/spec/stack.yaml view
@@ -1,3 +1,3 @@-resolver: lts-3.6+resolver: lts-3.11 packages: - '.'