on develop help sign in
Update changelog; Bump version
commit7ff258f114c2919f9bcc0e39a1ef2b04caf1e16c authorAli Abrar <aliabrar@gmail.com> dateFri 16 Apr 2021, 06:14 (6 years ago) parentb31529a
5 files changed+59−12
reflex-dom-core/ChangeLog.md+4 reflex-dom-core/reflex-dom-core.cabal+1−1 reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs+15−1 reflex-dom-core/src/Reflex/Dom/Main.hs+38−9 reflex-dom-core/test/hydration.hs+1−1
reflex-dom-core/ChangeLog.md+4
@@ -1,5 +1,9 @@
11# Revision history for reflex-dom-core
22
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+
37## 0.6.1.0
48
59* Bump version bounds
reflex-dom-core/reflex-dom-core.cabal+1−1
@@ -1,6 +1,6 @@
11cabal-version: 1.24
22Name: reflex-dom-core
3−Version: 0.6.1.0
3+Version: 0.6.2.0
44Synopsis: Functional Reactive Web Apps with Reflex
55Description:
66 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
4949 , HydrationMode (..)
5050 , HydrationRunnerT (..)
5151 , runHydrationRunnerT
52+ , runHydrationRunnerTWithFailure
5253 , ImmediateDomBuilderT
5354 , runHydrationDomBuilderT
5455 , getHydrationMode
@@ -292,15 +293,28 @@ localRunner (HydrationRunnerT m) s parent = do
292293
293294{-# INLINABLE runHydrationRunnerT #-}
294295runHydrationRunnerT
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
295307 :: (MonadRef m, Ref m ~ IORef, Monad m, PerformEvent t m, MonadFix m, MonadReflexCreateTrigger t m, MonadJSM m, MonadJSM (Performable m))
296308 => 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
298310 (a, s') <- runStateT m (HydrationState s False)
299311 traverse_ removeSubsequentNodes $ _hydrationState_previousNode s'
300312 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."
301313 when (_hydrationState_failed s') $ liftIO onFailure
302314 pure a
303315
316+
317+
304318instance MonadReflexCreateTrigger t m => MonadReflexCreateTrigger t (HydrationRunnerT t m) where
305319 {-# INLINABLE newEventWithTrigger #-}
306320 newEventWithTrigger = lift . newEventWithTrigger
reflex-dom-core/src/Reflex/Dom/Main.hs+38−9
@@ -64,22 +64,41 @@ mainHydrationWidgetWithHead = mainHydrationWidgetWithHead'
6464{-# INLINABLE mainHydrationWidgetWithHead' #-}
6565-- | Warning: `mainHydrationWidgetWithHead'` is provided only as performance tweak. It is expected to disappear in future releases.
6666mainHydrationWidgetWithHead' :: HydrationWidget () () -> HydrationWidget () () -> JSM ()
67−mainHydrationWidgetWithHead' = mainHydrationWidgetWithSwitchoverAction' (pure ()) (pure ())
67+mainHydrationWidgetWithHead' = mainHydrationWidgetWithSwitchoverAction' (pure ())
6868
6969{-# 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 ()
7171mainHydrationWidgetWithSwitchoverAction = mainHydrationWidgetWithSwitchoverAction'
7272
7373{-# INLINABLE mainHydrationWidgetWithSwitchoverAction' #-}
7474-- | Warning: `mainHydrationWidgetWithSwitchoverAction'` is provided only as performance tweak. It is expected to disappear in future releases.
75−mainHydrationWidgetWithSwitchoverAction' :: IO () -> JSM () -> HydrationWidget () () -> HydrationWidget () () -> JSM ()
76−mainHydrationWidgetWithSwitchoverAction' onFailure switchoverAction head' body = do
77− runHydrationWidgetWithHeadAndBody onFailure switchoverAction $ \appendHead appendBody -> do
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 ()
82+mainHydrationWidgetWithSwitchoverActionWithFailure' onFailure switchoverAction head' body = do
83+ runHydrationWidgetWithHeadAndBodyWithFailure onFailure switchoverAction $ \appendHead appendBody -> do
7884 appendHead head'
7985 appendBody body
8086
8187{-# INLINABLE attachHydrationWidget #-}
8288attachHydrationWidget
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
83102 :: IO ()
84103 -> JSM ()
85104 -> JSContextSingleton ()
@@ -90,7 +109,7 @@ attachHydrationWidget
90109 -> PerformEventT DomTimeline DomHost (a, IORef (Maybe (EventTrigger DomTimeline ())))
91110 )
92111 -> IO (a, FireCommand DomTimeline DomHost)
93−attachHydrationWidget onFailure switchoverAction jsSing w = do
112+attachHydrationWidgetWithFailure onFailure switchoverAction jsSing w = do
94113 hydrationMode <- liftIO $ newIORef HydrationMode_Hydrating
95114 rootNodesRef <- liftIO $ newIORef []
96115 events <- newChan
@@ -106,7 +125,7 @@ attachHydrationWidget onFailure switchoverAction jsSing w = do
106125 rootNodes <- liftIO $ readIORef rootNodesRef
107126 let delayedAction = do
108127 for_ (reverse rootNodes) $ \(rootNode, runner) -> do
109− let hydrate = runHydrationRunnerT runner onFailure Nothing rootNode events
128+ let hydrate = runHydrationRunnerTWithFailure runner onFailure Nothing rootNode events
110129 void $ runWithJSContextSingleton (runPostBuildT hydrate never) jsSing
111130 liftIO $ writeIORef hydrationMode HydrationMode_Immediate
112131 runWithJSContextSingleton (DOM.liftJSM switchoverAction) jsSing
@@ -121,6 +140,16 @@ type DomCoreWidget x = PostBuildT DomTimeline (WithJSContextSingleton x (Perform
121140
122141{-# INLINABLE runHydrationWidgetWithHeadAndBody #-}
123142runHydrationWidgetWithHeadAndBody
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
124153 :: IO ()
125154 -> JSM ()
126155 -> ( (forall c. HydrationWidget () c -> FloatingWidget () c) -- "Append to head" --TODO: test invoking this more than once
@@ -128,11 +157,11 @@ runHydrationWidgetWithHeadAndBody
128157 -> FloatingWidget () ()
129158 )
130159 -> JSM ()
131−runHydrationWidgetWithHeadAndBody onFailure switchoverAction app = withJSContextSingletonMono $ \jsSing -> do
160+runHydrationWidgetWithHeadAndBodyWithFailure onFailure switchoverAction app = withJSContextSingletonMono $ \jsSing -> do
132161 globalDoc <- currentDocumentUnchecked
133162 headElement <- getHeadUnchecked globalDoc
134163 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
136165 (postBuild, postBuildTriggerRef) <- newEventWithTriggerRef
137166 let hydrateDom :: DOM.Node -> HydrationWidget () c -> FloatingWidget () c
138167 hydrateDom n w = do
reflex-dom-core/test/hydration.hs+1−1
@@ -1772,7 +1772,7 @@ testWidgetDebug' hardFailure withDebugging beforeJS afterSwitchover bodyWidget =
17721772 liftIO $ putMVar waitUntilSwitchover ()
17731773 putStrLnDebug "put waitUntilSwitchover"
17741774 putStrLnDebug "running mainHydrationWidgetWithSwitchoverAction"
1775− mainHydrationWidgetWithSwitchoverAction onFailure switchOverAction blank bodyWidget
1775+ mainHydrationWidgetWithSwitchoverActionWithFailure' onFailure switchOverAction blank bodyWidget
17761776 putStrLnDebug "syncPoint after mainHydrationWidgetWithSwitchoverAction"
17771777 syncPoint
17781778 application <- liftIO $ jsaddleOr defaultConnectionOptions entryPoint $ \_ sendResponse -> do