@@ -1,4 +1,5 @@
11{-# LANGUAGE ConstraintKinds #-}
2+{-# LANGUAGE CPP #-}
23{-# LANGUAGE FlexibleContexts #-}
34{-# LANGUAGE FlexibleInstances #-}
45{-# LANGUAGE LambdaCase #-}
@@ -14,7 +15,9 @@ module Obelisk.Frontend
1415 ( ObeliskWidget
1516 , Frontend (..)
1617 , runFrontend
18+ , runFrontendWithConfigs
1719 , renderFrontendHtml
20+ , removeHTMLConfigs
1821 , module Obelisk.Frontend.Cookie
1922 ) where
2023
@@ -31,6 +34,7 @@ import Control.Monad.Trans.Maybe (MaybeT(..), runMaybeT)
3134import Data.ByteString (ByteString)
3235import Data.Foldable (for_)
3336import Data.Functor.Sum
37+import Data.Map (Map)
3438import Data.Maybe (catMaybes)
3539import Data.Monoid ((<>))
3640import Data.Text (Text)
@@ -106,12 +110,23 @@ runFrontend
106110 -> Frontend (R route)
107111 -> JSM ()
108112runFrontend validFullEncoder frontend = do
113+ configs <- liftIO getFrontendConfigs
114+#ifdef ghcjs_HOST_OS
115+ removeHTMLConfigs
116+#endif
117+ runFrontendWithConfigs configs validFullEncoder frontend
118+
119+runFrontendWithConfigs
120+ :: forall backendRoute route
121+ . Map Text Text
122+ -> Encoder Identity Identity (R (Sum backendRoute (ObeliskRoute route))) PageName
123+ -> Frontend (R route)
124+ -> JSM ()
125+runFrontendWithConfigs configs validFullEncoder frontend = do
109126 let ve = validFullEncoder . hoistParse errorLeft (prismEncoder (rPrism $ _InR . _ObeliskRoute_App))
110127 errorLeft = \case
111128 Left _ -> error "runFrontend: Unexpected non-app ObeliskRoute reached the frontend. This shouldn't happen."
112129 Right x -> Identity x
113− configs <- liftIO getFrontendConfigs
114− removeHTMLConfigs
115130 runHydrationWidgetWithHeadAndBody (pure ()) $ \appendHead appendBody -> do
116131 rec switchover <- runRouteViewT ve switchover $ do
117132 (switchover'', fire) <- newTriggerEvent