Skip to content

Commit

Permalink
reflex-platform -> 0.9.2.0 (reflex-dom-core-0.7 (Remove HasJSContext)) (
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-abrar authored Jan 5, 2022
1 parent f0acb10 commit e7ccc91
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 49 deletions.
9 changes: 9 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 3 additions & 3 deletions dep/reflex-platform/github.json
Original file line number Diff line number Diff line change
@@ -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"
}
6 changes: 1 addition & 5 deletions lib/executable-config/lookup/src/Obelisk/Configs.hs
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ import Reflex.Dom.Core
( DomBuilder
, DomRenderHook
, HasDocument
, HasJS
, HasJSContext
, Prerender (Client)
, StaticDomBuilderT
, prerender
Expand Down Expand Up @@ -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
Expand All @@ -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)
Expand Down
12 changes: 6 additions & 6 deletions lib/frontend/src/Obelisk/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion lib/frontend/src/Obelisk/Frontend/Cookie.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
44 changes: 10 additions & 34 deletions lib/route/src/Obelisk/Route/Frontend.hs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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)

Expand All @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e7ccc91

Please sign in to comment.