on develop help sign in
Update changelog; Bump version
7ff258fAli Abrar
reflex-dom-core/ChangeLog.md+4
@@ -1,5 +1,9 @@
1# Revision history for reflex-dom-core
1# Revision history for reflex-dom-core
2
2
3+## 0.6.2.0
4+
5+* ([#400](https://github.com/reflex-frp/reflex-dom/pull/400/files)) Set value of input elements in static renderer
6+
3## 0.6.1.0
7## 0.6.1.0
4
8
5* Bump version bounds
9* Bump version bounds
reflex-dom-core/reflex-dom-core.cabal+1−1
@@ -1,6 +1,6 @@
1cabal-version: 1.24
1cabal-version: 1.24
2Name: reflex-dom-core
2Name: reflex-dom-core
3−Version: 0.6.1.0
3+Version: 0.6.2.0
4Synopsis: Functional Reactive Web Apps with Reflex
4Synopsis: Functional Reactive Web Apps with Reflex
5Description:
5Description:
6 Web applications without callbacks or side-effects.
6 Web applications without callbacks or side-effects.
reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+15−1
@@ -49,6 +49,7 @@ module Reflex.Dom.Builder.Immediate
49 , HydrationMode (..)
49 , HydrationMode (..)
50 , HydrationRunnerT (..)
50 , HydrationRunnerT (..)
51 , runHydrationRunnerT
51 , runHydrationRunnerT
52+ , runHydrationRunnerTWithFailure
52 , ImmediateDomBuilderT
53 , ImmediateDomBuilderT
53 , runHydrationDomBuilderT
54 , runHydrationDomBuilderT
54 , getHydrationMode
55 , getHydrationMode
@@ -292,15 +293,28 @@ localRunner (HydrationRunnerT m) s parent = do
292
293
293{-# INLINABLE runHydrationRunnerT #-}
294{-# INLINABLE runHydrationRunnerT #-}
294runHydrationRunnerT
295runHydrationRunnerT
296+ :: (MonadRef m, Ref m ~ IORef, Monad m, PerformEvent t m, MonadFix m, MonadReflexCreateTrigger t m, MonadJSM m, MonadJSM (Performable m))
297+ => HydrationRunnerT t m a -> Maybe Node -> Node -> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
298+runHydrationRunnerT m = runHydrationRunnerTWithFailure m (pure ()) -- (HydrationRunnerT m) onFailure s parent events = flip runDomRenderHookT events $ flip runReaderT parent $ do
299+ -- (a, s') <- runStateT m (HydrationState s False)
300+ -- traverse_ removeSubsequentNodes $ _hydrationState_previousNode s'
301+ -- when (_hydrationState_failed s') $ liftIO $ putStrLn "reflex-dom warning: hydration failed: the DOM was not as expected at switchover time. This may be due to invalid HTML which the browser has altered upon parsing, some external JS altering the DOM, or the page being served from an outdated cache."
302+ -- when (_hydrationState_failed s') $ liftIO onFailure
303+ -- pure a
304+
305+{-# INLINABLE runHydrationRunnerTWithFailure #-}
306+runHydrationRunnerTWithFailure
295 :: (MonadRef m, Ref m ~ IORef, Monad m, PerformEvent t m, MonadFix m, MonadReflexCreateTrigger t m, MonadJSM m, MonadJSM (Performable m))
307 :: (MonadRef m, Ref m ~ IORef, Monad m, PerformEvent t m, MonadFix m, MonadReflexCreateTrigger t m, MonadJSM m, MonadJSM (Performable m))
296 => HydrationRunnerT t m a -> IO () -> Maybe Node -> Node -> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
308 => HydrationRunnerT t m a -> IO () -> Maybe Node -> Node -> Chan [DSum (EventTriggerRef t) TriggerInvocation] -> m a
297−runHydrationRunnerT (HydrationRunnerT m) onFailure s parent events = flip runDomRenderHookT events $ flip runReaderT parent $ do
309+runHydrationRunnerTWithFailure (HydrationRunnerT m) onFailure s parent events = flip runDomRenderHookT events $ flip runReaderT parent $ do
298 (a, s') <- runStateT m (HydrationState s False)
310 (a, s') <- runStateT m (HydrationState s False)
299 traverse_ removeSubsequentNodes $ _hydrationState_previousNode s'
311 traverse_ removeSubsequentNodes $ _hydrationState_previousNode s'
300 when (_hydrationState_failed s') $ liftIO $ putStrLn "reflex-dom warning: hydration failed: the DOM was not as expected at switchover time. This may be due to invalid HTML which the browser has altered upon parsing, some external JS altering the DOM, or the page being served from an outdated cache."
312 when (_hydrationState_failed s') $ liftIO $ putStrLn "reflex-dom warning: hydration failed: the DOM was not as expected at switchover time. This may be due to invalid HTML which the browser has altered upon parsing, some external JS altering the DOM, or the page being served from an outdated cache."
301 when (_hydrationState_failed s') $ liftIO onFailure
313 when (_hydrationState_failed s') $ liftIO onFailure
302 pure a
314 pure a
303
315
316+
317+
304instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (HydrationRunnerT t m) where
318instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (HydrationRunnerT t m) where
305 {-# INLINABLE newEventWithTrigger #-}
319 {-# INLINABLE newEventWithTrigger #-}
306 newEventWithTrigger = lift . newEventWithTrigger
320 newEventWithTrigger = lift . newEventWithTrigger
reflex-dom-core/src/Reflex/Dom/Main.hs+38−9
@@ -64,22 +64,41 @@ mainHydrationWidgetWithHead = mainHydrationWidgetWithHead'
64{-# INLINABLE mainHydrationWidgetWithHead' #-}
64{-# INLINABLE mainHydrationWidgetWithHead' #-}
65-- | Warning: `mainHydrationWidgetWithHead'` is provided only as performance tweak. It is expected to disappear in future releases.
65-- | Warning: `mainHydrationWidgetWithHead'` is provided only as performance tweak. It is expected to disappear in future releases.
66mainHydrationWidgetWithHead' :: HydrationWidget () () -> HydrationWidget () () -> JSM ()
66mainHydrationWidgetWithHead' :: HydrationWidget () () -> HydrationWidget () () -> JSM ()
67−mainHydrationWidgetWithHead' = mainHydrationWidgetWithSwitchoverAction' (pure ()) (pure ())
67+mainHydrationWidgetWithHead' = mainHydrationWidgetWithSwitchoverAction' (pure ())
68
68
69{-# INLINE mainHydrationWidgetWithSwitchoverAction #-}
69{-# INLINE mainHydrationWidgetWithSwitchoverAction #-}
70−mainHydrationWidgetWithSwitchoverAction :: IO () -> JSM () -> (forall x. HydrationWidget x ()) -> (forall x. HydrationWidget x ()) -> JSM ()
70+mainHydrationWidgetWithSwitchoverAction :: JSM () -> (forall x. HydrationWidget x ()) -> (forall x. HydrationWidget x ()) -> JSM ()
71mainHydrationWidgetWithSwitchoverAction = mainHydrationWidgetWithSwitchoverAction'
71mainHydrationWidgetWithSwitchoverAction = mainHydrationWidgetWithSwitchoverAction'
72
72
73{-# INLINABLE mainHydrationWidgetWithSwitchoverAction' #-}
73{-# INLINABLE mainHydrationWidgetWithSwitchoverAction' #-}
74-- | Warning: `mainHydrationWidgetWithSwitchoverAction'` is provided only as performance tweak. It is expected to disappear in future releases.
74-- | Warning: `mainHydrationWidgetWithSwitchoverAction'` is provided only as performance tweak. It is expected to disappear in future releases.
75−mainHydrationWidgetWithSwitchoverAction' :: IO () -> JSM () -> HydrationWidget () () -> HydrationWidget () () -> JSM ()
75+mainHydrationWidgetWithSwitchoverAction' :: JSM () -> HydrationWidget () () -> HydrationWidget () () -> JSM ()
76+mainHydrationWidgetWithSwitchoverAction' = mainHydrationWidgetWithSwitchoverActionWithFailure' (pure ())
77+
78+
79+{-# INLINABLE mainHydrationWidgetWithSwitchoverActionWithFailure' #-}
80+-- | Warning: `mainHydrationWidgetWithSwitchoverActionWithFaiilure'` is provided only as performance tweak. It is expected to disappear in future releases.
81+mainHydrationWidgetWithSwitchoverActionWithFailure' :: IO () -> JSM () -> HydrationWidget () () -> HydrationWidget () () -> JSM ()
76−mainHydrationWidgetWithSwitchoverAction' onFailure switchoverAction head' body = do
82+mainHydrationWidgetWithSwitchoverActionWithFailure' onFailure switchoverAction head' body = do
77− runHydrationWidgetWithHeadAndBody onFailure switchoverAction $ \appendHead appendBody -> do
83+ runHydrationWidgetWithHeadAndBodyWithFailure onFailure switchoverAction $ \appendHead appendBody -> do
78 appendHead head'
84 appendHead head'
79 appendBody body
85 appendBody body
80
86
81{-# INLINABLE attachHydrationWidget #-}
87{-# INLINABLE attachHydrationWidget #-}
82attachHydrationWidget
88attachHydrationWidget
89+ :: JSM ()
90+ -> JSContextSingleton ()
91+ -> ( Event DomTimeline ()
92+ -> IORef HydrationMode
93+ -> Maybe (IORef [(Node, HydrationRunnerT DomTimeline (DomCoreWidget ()) ())])
94+ -> EventChannel
95+ -> PerformEventT DomTimeline DomHost (a, IORef (Maybe (EventTrigger DomTimeline ())))
96+ )
97+ -> IO (a, FireCommand DomTimeline DomHost)
98+attachHydrationWidget = attachHydrationWidgetWithFailure (pure ())
99+
100+{-# INLINABLE attachHydrationWidgetWithFailure #-}
101+attachHydrationWidgetWithFailure
83 :: IO ()
102 :: IO ()
84 -> JSM ()
103 -> JSM ()
85 -> JSContextSingleton ()
104 -> JSContextSingleton ()
@@ -90,7 +109,7 @@ attachHydrationWidget
90 -> PerformEventT DomTimeline DomHost (a, IORef (Maybe (EventTrigger DomTimeline ())))
109 -> PerformEventT DomTimeline DomHost (a, IORef (Maybe (EventTrigger DomTimeline ())))
91 )
110 )
92 -> IO (a, FireCommand DomTimeline DomHost)
111 -> IO (a, FireCommand DomTimeline DomHost)
93−attachHydrationWidget onFailure switchoverAction jsSing w = do
112+attachHydrationWidgetWithFailure onFailure switchoverAction jsSing w = do
94 hydrationMode <- liftIO $ newIORef HydrationMode_Hydrating
113 hydrationMode <- liftIO $ newIORef HydrationMode_Hydrating
95 rootNodesRef <- liftIO $ newIORef []
114 rootNodesRef <- liftIO $ newIORef []
96 events <- newChan
115 events <- newChan
@@ -106,7 +125,7 @@ attachHydrationWidget onFailure switchoverAction jsSing w = do
106 rootNodes <- liftIO $ readIORef rootNodesRef
125 rootNodes <- liftIO $ readIORef rootNodesRef
107 let delayedAction = do
126 let delayedAction = do
108 for_ (reverse rootNodes) $ \(rootNode, runner) -> do
127 for_ (reverse rootNodes) $ \(rootNode, runner) -> do
109− let hydrate = runHydrationRunnerT runner onFailure Nothing rootNode events
128+ let hydrate = runHydrationRunnerTWithFailure runner onFailure Nothing rootNode events
110 void $ runWithJSContextSingleton (runPostBuildT hydrate never) jsSing
129 void $ runWithJSContextSingleton (runPostBuildT hydrate never) jsSing
111 liftIO $ writeIORef hydrationMode HydrationMode_Immediate
130 liftIO $ writeIORef hydrationMode HydrationMode_Immediate
112 runWithJSContextSingleton (DOM.liftJSM switchoverAction) jsSing
131 runWithJSContextSingleton (DOM.liftJSM switchoverAction) jsSing
@@ -121,6 +140,16 @@ type DomCoreWidget x = PostBuildT DomTimeline (WithJSContextSingleton x (Perform
121
140
122{-# INLINABLE runHydrationWidgetWithHeadAndBody #-}
141{-# INLINABLE runHydrationWidgetWithHeadAndBody #-}
123runHydrationWidgetWithHeadAndBody
142runHydrationWidgetWithHeadAndBody
143+ :: JSM ()
144+ -> ( (forall c. HydrationWidget () c -> FloatingWidget () c) -- "Append to head" --TODO: test invoking this more than once
145+ -> (forall c. HydrationWidget () c -> FloatingWidget () c) -- "Append to body" --TODO: test invoking this more than once
146+ -> FloatingWidget () ()
147+ )
148+ -> JSM ()
149+runHydrationWidgetWithHeadAndBody = runHydrationWidgetWithHeadAndBodyWithFailure (pure ())
150+
151+{-# INLINABLE runHydrationWidgetWithHeadAndBodyWithFailure #-}
152+runHydrationWidgetWithHeadAndBodyWithFailure
124 :: IO ()
153 :: IO ()
125 -> JSM ()
154 -> JSM ()
126 -> ( (forall c. HydrationWidget () c -> FloatingWidget () c) -- "Append to head" --TODO: test invoking this more than once
155 -> ( (forall c. HydrationWidget () c -> FloatingWidget () c) -- "Append to head" --TODO: test invoking this more than once
@@ -128,11 +157,11 @@ runHydrationWidgetWithHeadAndBody
128 -> FloatingWidget () ()
157 -> FloatingWidget () ()
129 )
158 )
130 -> JSM ()
159 -> JSM ()
131−runHydrationWidgetWithHeadAndBody onFailure switchoverAction app = withJSContextSingletonMono $ \jsSing -> do
160+runHydrationWidgetWithHeadAndBodyWithFailure onFailure switchoverAction app = withJSContextSingletonMono $ \jsSing -> do
132 globalDoc <- currentDocumentUnchecked
161 globalDoc <- currentDocumentUnchecked
133 headElement <- getHeadUnchecked globalDoc
162 headElement <- getHeadUnchecked globalDoc
134 bodyElement <- getBodyUnchecked globalDoc
163 bodyElement <- getBodyUnchecked globalDoc
135− (events, fc) <- liftIO . attachHydrationWidget onFailure switchoverAction jsSing $ \switchover hydrationMode hydrationResult events -> do
164+ (events, fc) <- liftIO . attachHydrationWidgetWithFailure onFailure switchoverAction jsSing $ \switchover hydrationMode hydrationResult events -> do
136 (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef
165 (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef
137 let hydrateDom :: DOM.Node -> HydrationWidget () c -> FloatingWidget () c
166 let hydrateDom :: DOM.Node -> HydrationWidget () c -> FloatingWidget () c
138 hydrateDom n w = do
167 hydrateDom n w = do
reflex-dom-core/test/hydration.hs+1−1
@@ -1772,7 +1772,7 @@ testWidgetDebug' hardFailure withDebugging beforeJS afterSwitchover bodyWidget =
1772 liftIO $ putMVar waitUntilSwitchover ()
1772 liftIO $ putMVar waitUntilSwitchover ()
1773 putStrLnDebug "put waitUntilSwitchover"
1773 putStrLnDebug "put waitUntilSwitchover"
1774 putStrLnDebug "running mainHydrationWidgetWithSwitchoverAction"
1774 putStrLnDebug "running mainHydrationWidgetWithSwitchoverAction"
1775− mainHydrationWidgetWithSwitchoverAction onFailure switchOverAction blank bodyWidget
1775+ mainHydrationWidgetWithSwitchoverActionWithFailure' onFailure switchOverAction blank bodyWidget
1776 putStrLnDebug "syncPoint after mainHydrationWidgetWithSwitchoverAction"
1776 putStrLnDebug "syncPoint after mainHydrationWidgetWithSwitchoverAction"
1777 syncPoint
1777 syncPoint
1778 application <- liftIO $ jsaddleOr defaultConnectionOptions entryPoint $ \_ sendResponse -> do
1778 application <- liftIO $ jsaddleOr defaultConnectionOptions entryPoint $ \_ sendResponse -> do