From e7ccc91806b94b424b086bf75087a0a5fd3ff0b5 Mon Sep 17 00:00:00 2001 From: Ali Abrar Date: Tue, 4 Jan 2022 23:30:32 -0500 Subject: [PATCH] reflex-platform -> 0.9.2.0 (reflex-dom-core-0.7 (Remove HasJSContext)) (#884) --- ChangeLog.md | 9 ++++ dep/reflex-platform/github.json | 6 +-- .../lookup/src/Obelisk/Configs.hs | 6 +-- lib/frontend/src/Obelisk/Frontend.hs | 12 ++--- lib/frontend/src/Obelisk/Frontend/Cookie.hs | 2 +- lib/route/src/Obelisk/Route/Frontend.hs | 44 +++++-------------- 6 files changed, 30 insertions(+), 49 deletions(-) diff --git a/ChangeLog.md b/ChangeLog.md index b1aedc154..25078bd03 100644 --- a/ChangeLog.md +++ b/ChangeLog.md @@ -2,6 +2,15 @@ This project's release branch is `master`. This log is written from the perspective of the release branch: when changes hit `master`, they are considered released. +## v1.0.0.0 - 2022-01-04 + +* Update reflex-platform to v0.9.2.0 + * This updated reflex-dom-core to [0.7](https://github.com/reflex-frp/reflex-dom/releases/tag/reflex-dom-core-0.7.0.0), which removes the `js` type parameter from `Prerender` (i.e., `Prerender js t m` becomes `Prerender t m`) and removes `HasJS` and `HasJSContext`. This resulted in changes to the following Obelisk modules: + * `Obelisk.Configs`: `HasJSContext` and `HasJS` are no longer derived. + * `Obelisk.Frontend`: `ObeliskWidget js t route m` no longer has the `js` type parameter. It is now `ObeliskWidget t route m`. + * `Obelisk.Route.Frontend`: There are no longer `HasJSContext` or `HasJS` instances for `RoutedT`, `SetRouteT`, `RouteToUrlT`. + * Various functions that were constrained to `Prerender js t m` have been updated to with the constraint `Prerender t m`. + ## v0.9.4.0 - 2021-12-30 * Update reflex-platform to v0.9.0.0 diff --git a/dep/reflex-platform/github.json b/dep/reflex-platform/github.json index 62dba1879..380959824 100644 --- a/dep/reflex-platform/github.json +++ b/dep/reflex-platform/github.json @@ -1,8 +1,8 @@ { "owner": "reflex-frp", "repo": "reflex-platform", - "branch": "release/0.9.0.0", + "branch": "release/0.9.2.0", "private": false, - "rev": "e8e56516b1df0c6e7024bc0e690f54fcddf79a19", - "sha256": "0xb2hdps7bsyd6y84if3317w9fbcpcjh4whrvrhz6mskcw069xjp" + "rev": "123a6f487ca954fd983f6d4cd6b2a69d4c463d10", + "sha256": "16q1rq0rwi6l28fv46q8m0hvb9rxrzf574j865vaz04xy8d5p1ya" } diff --git a/lib/executable-config/lookup/src/Obelisk/Configs.hs b/lib/executable-config/lookup/src/Obelisk/Configs.hs index 5770b3e8d..716c0f71e 100644 --- a/lib/executable-config/lookup/src/Obelisk/Configs.hs +++ b/lib/executable-config/lookup/src/Obelisk/Configs.hs @@ -44,8 +44,6 @@ import Reflex.Dom.Core ( DomBuilder , DomRenderHook , HasDocument - , HasJS - , HasJSContext , Prerender (Client) , StaticDomBuilderT , prerender @@ -106,8 +104,6 @@ newtype ConfigsT m a = ConfigsT { unConfigsT :: ReaderT (Map Text ByteString) m , TriggerEvent t , HasDocument , DomRenderHook t - , HasJSContext - , HasJS js #ifndef ghcjs_HOST_OS , MonadJSM #endif @@ -126,7 +122,7 @@ instance Adjustable t m => Adjustable t (ConfigsT m) where traverseIntMapWithKeyWithAdjust f m e = ConfigsT $ traverseIntMapWithKeyWithAdjust (\k v -> unConfigsT $ f k v) m e traverseDMapWithKeyWithAdjustWithMove f m e = ConfigsT $ traverseDMapWithKeyWithAdjustWithMove (\k v -> unConfigsT $ f k v) m e -instance Prerender js t m => Prerender js t (ConfigsT m) where +instance Prerender t m => Prerender t (ConfigsT m) where type Client (ConfigsT m) = ConfigsT (Client m) prerender server client = ConfigsT $ ReaderT $ \configs -> prerender (runConfigsT configs server) (runConfigsT configs client) diff --git a/lib/frontend/src/Obelisk/Frontend.hs b/lib/frontend/src/Obelisk/Frontend.hs index abd319f6c..15835c9d9 100644 --- a/lib/frontend/src/Obelisk/Frontend.hs +++ b/lib/frontend/src/Obelisk/Frontend.hs @@ -65,7 +65,7 @@ import Debug.Trace makePrisms ''Sum -type ObeliskWidget js t route m = +type ObeliskWidget t route m = ( DomBuilder t m , MonadFix m , MonadHold t m @@ -81,7 +81,7 @@ type ObeliskWidget js t route m = , Ref (Performable m) ~ Ref IO , MonadFix (Performable m) , PrimMonad m - , Prerender js t m + , Prerender t m , PrebuildAgnostic t route m , PrebuildAgnostic t route (Client m) , HasConfigs m @@ -98,11 +98,11 @@ type PrebuildAgnostic t route m = ) data Frontend route = Frontend - { _frontend_head :: !(forall js t m. ObeliskWidget js t route m => RoutedT t route m ()) - , _frontend_body :: !(forall js t m. ObeliskWidget js t route m => RoutedT t route m ()) + { _frontend_head :: !(forall t m. ObeliskWidget t route m => RoutedT t route m ()) + , _frontend_body :: !(forall t m. ObeliskWidget t route m => RoutedT t route m ()) } -baseTag :: forall route js t m. ObeliskWidget js t route m => RoutedT t route m () +baseTag :: forall route t m. ObeliskWidget t route m => RoutedT t route m () baseTag = if os == "ios" then blank @@ -206,7 +206,7 @@ runFrontendWithConfigsAndCurrentRoute mode configs validFullEncoder frontend = d , MonadFix (Client (HydrationDomBuilderT s DomTimeline m)) , MonadFix (Performable m) , MonadFix m - , Prerender js DomTimeline (HydrationDomBuilderT s DomTimeline m) + , Prerender DomTimeline (HydrationDomBuilderT s DomTimeline m) , MonadIO (Performable m) ) => (forall c. HydrationDomBuilderT s DomTimeline m c -> FloatingWidget () c) diff --git a/lib/frontend/src/Obelisk/Frontend/Cookie.hs b/lib/frontend/src/Obelisk/Frontend/Cookie.hs index 7da0257e5..5d547e63d 100644 --- a/lib/frontend/src/Obelisk/Frontend/Cookie.hs +++ b/lib/frontend/src/Obelisk/Frontend/Cookie.hs @@ -69,7 +69,7 @@ newtype CookiesT m a = CookiesT { unCookiesT :: ReaderT Cookies m a } , NotReady t , PerformEvent t , PostBuild t - , Prerender js t + , Prerender t , TriggerEvent t , HasDocument ) diff --git a/lib/route/src/Obelisk/Route/Frontend.hs b/lib/route/src/Obelisk/Route/Frontend.hs index 7675d1cd5..8b848adaf 100644 --- a/lib/route/src/Obelisk/Route/Frontend.hs +++ b/lib/route/src/Obelisk/Route/Frontend.hs @@ -131,11 +131,7 @@ instance MonadReader r' m => MonadReader r' (RoutedT t r m) where ask = lift ask local = mapRoutedT . local -instance HasJSContext m => HasJSContext (RoutedT t r m) where - type JSContextPhantom (RoutedT t r m) = JSContextPhantom m - askJSContext = lift askJSContext - -instance (Prerender js t m, Monad m) => Prerender js t (RoutedT t r m) where +instance (Prerender t m, Monad m) => Prerender t (RoutedT t r m) where type Client (RoutedT t r m) = RoutedT t r (Client m) prerender server client = RoutedT $ do r <- ask @@ -162,10 +158,6 @@ instance MonadRef m => MonadRef (RoutedT t r m) where readRef = lift . readRef writeRef r = lift . writeRef r -instance HasJS x m => HasJS x (RoutedT t r m) where - type JSX (RoutedT t r m) = JSX m - liftJS = lift . liftJS - deriving instance EventWriter t w m => EventWriter t w (RoutedT t r m) instance MonadTransControl (RoutedT t r) where @@ -302,10 +294,6 @@ instance (MonadFix m, MonadHold t m, DomBuilder t m) => DomBuilder t (SetRouteT textAreaElement = lift . textAreaElement selectElement cfg child = SetRouteT $ selectElement cfg $ unSetRouteT child -instance HasJSContext m => HasJSContext (SetRouteT t r m) where - type JSContextPhantom (SetRouteT t r m) = JSContextPhantom m - askJSContext = lift askJSContext - mapSetRouteT :: (forall x. m x -> n x) -> SetRouteT t r m a -> SetRouteT t r n a mapSetRouteT f (SetRouteT x) = SetRouteT (mapEventWriterT f x) @@ -327,7 +315,7 @@ instance (Monad m, SetRoute t r m) => SetRoute t r (RoutedT t r' m) instance (Monad m, SetRoute t r m) => SetRoute t r (ReaderT r' m) -instance (PerformEvent t m, Prerender js t m, Monad m, Reflex t) => Prerender js t (SetRouteT t r m) where +instance (PerformEvent t m, Prerender t m, Monad m, Reflex t) => Prerender t (SetRouteT t r m) where type Client (SetRouteT t r m) = SetRouteT t r (Client m) prerender server client = do d <- lift $ prerender (runSetRouteT server) (runSetRouteT client) @@ -359,10 +347,6 @@ instance MonadRef m => MonadRef (SetRouteT t r m) where readRef = lift . readRef writeRef r = lift . writeRef r -instance HasJS x m => HasJS x (SetRouteT t r m) where - type JSX (SetRouteT t r m) = JSX m - liftJS = lift . liftJS - instance PrimMonad m => PrimMonad (SetRouteT t r m ) where type PrimState (SetRouteT t r m) = PrimState m primitive = lift . primitive @@ -408,11 +392,7 @@ instance (Monad m, RouteToUrl r m) => RouteToUrl r (ReaderT r' m) where instance (Monad m, RouteToUrl r m) => RouteToUrl r (RequesterT t req rsp m) -instance HasJSContext m => HasJSContext (RouteToUrlT r m) where - type JSContextPhantom (RouteToUrlT r m) = JSContextPhantom m - askJSContext = lift askJSContext - -instance (Prerender js t m, Monad m) => Prerender js t (RouteToUrlT r m) where +instance (Prerender t m, Monad m) => Prerender t (RouteToUrlT r m) where type Client (RouteToUrlT r m) = RouteToUrlT r (Client m) prerender server client = do r <- RouteToUrlT ask @@ -439,10 +419,6 @@ instance MonadRef m => MonadRef (RouteToUrlT r m) where readRef = lift . readRef writeRef r = lift . writeRef r -instance HasJS x m => HasJS x (RouteToUrlT r m) where - type JSX (RouteToUrlT r m) = JSX m - liftJS = lift . liftJS - instance MonadTransControl (RouteToUrlT r) where type StT (RouteToUrlT r) a = StT (ReaderT (r -> Text)) a liftWith = defaultLiftWith RouteToUrlT unRouteToUrlT @@ -522,11 +498,11 @@ runRouteViewT routeEncoder switchover useHash a = do -- | A link widget that, when clicked, sets the route to the provided route. In non-javascript -- contexts, this widget falls back to using @href@s to control navigation routeLink - :: forall t m a route js. + :: forall t m a route. ( DomBuilder t m , RouteToUrl route m , SetRoute t route m - , Prerender js t m + , Prerender t m ) => route -- ^ Target route -> m a -- ^ Child widget @@ -555,19 +531,19 @@ routeLinkImpl r w = do setRoute $ r <$ domEvent Click e return (domEvent Click e, a) -scrollToTop :: forall m t js. (Prerender js t m, Monad m) => Event t () -> m () +scrollToTop :: forall m t. (Prerender t m, Monad m) => Event t () -> m () scrollToTop e = prerender_ blank $ performEvent_ $ ffor e $ \_ -> liftJSM $ DOM.currentWindow >>= \case Nothing -> pure () Just win -> Window.scrollTo win 0 0 -- | Like 'routeLinkDynAttr' but without custom attributes. dynRouteLink - :: forall t m a route js. + :: forall t m a route. ( DomBuilder t m , PostBuild t m , RouteToUrl route m , SetRoute t route m - , Prerender js t m + , Prerender t m ) => Dynamic t route -- ^ Target route -> m a -- ^ Child widget @@ -603,12 +579,12 @@ dynRouteLinkImpl dr w = do -- provided dynamic route. In non-JavaScript contexts the value of the dynamic post -- build is used so the link still works like 'routeLink'. routeLinkDynAttr - :: forall t m a route js. + :: forall t m a route. ( DomBuilder t m , PostBuild t m , RouteToUrl (R route) m , SetRoute t (R route) m - , Prerender js t m + , Prerender t m ) => Dynamic t (Map AttributeName Text) -- ^ Attributes for @a@ element. Note that if @href@ is present it will be ignored -> Dynamic t (R route) -- ^ Target route