on master help sign in
checkpoint
commit4d44ef3aaf3cbebbbf14c430f7386a7d5d130adb authorTom Smalley <tfsmalley@gmail.com> dateFri 16 Nov 2018, 16:34 (8 years ago) parent742e3bc
3 files changed+23−33
dep/reflex-dom/github.json+2−2 lib/frontend/src/Obelisk/Frontend.hs+6−19 skeleton/frontend/src/Frontend.hs+15−12
dep/reflex-dom/github.json+2−2
@@ -2,6 +2,6 @@
22 "owner": "reflex-frp",
33 "repo": "reflex-dom",
44 "branch": "ts-hydration",
5− "rev": "a945be75317ff0b8577cb011145cdf16861c6817",
6− "sha256": "1baq0sgiqlkr5mdp22q637k4h6lbslp30198d3wh0rd1m8k1k4mn"
5+ "rev": "54e0b3fd63fe94fe8f4d244fad323dbb0d773606",
6+ "sha256": "05hk54jb4ixzwnb73ll6ggq2cxxlb8vlj8xxknc82l931fqpiwyn"
77}
lib/frontend/src/Obelisk/Frontend.hs+6−19
@@ -105,24 +105,14 @@ attachWidget''' doc bodyNode hydrationMode hres jsSing w = do
105105 pure a
106106 mPostBuildTrigger <- readRef postBuildTriggerRef
107107 lift $ forM_ mPostBuildTrigger $ \postBuildTrigger -> fire [postBuildTrigger :=> Identity ()] $ return ()
108− liftIO $ putStrLn "-------------------------------------- Finished postBuild"
109108 liftIO $ fireSync ()
110− unreadyChildren <- liftIO $ newIORef 0
111109 forest <- liftIO $ readIORef hres
112110 -- TODO: DomHost is SpiderHost Global only if we're not in profiling mode
113− let env = HydrationRunnerEnv
114− { _hydrationRunnerEnv_document = doc
115− , _hydrationRunnerEnv_parent = bodyNode
116− , _hydrationRunnerEnv_unreadyChildren = unreadyChildren
117− , _hydrationRunnerEnv_commitAction = pure ()
118− }
119− state = HydrationRunnerState
120− { _hydrationRunnerState_previousNode = Nothing
121− }
122− delayedAction = do
123− void $ runWithJSContextSingleton (runPostBuildT (runHydrationDomBuilderT (runDOMForest forest) env state events) never) jsSing
111+ let delayedAction = do
112+ liftIO $ putStrLn "-------------------------------------- Performing delayed actions"
113+ void $ runWithJSContextSingleton (runPostBuildT (runHydrationRunnerT (runDOMForest forest) Nothing bodyNode events) never) jsSing
114+ liftIO $ putStrLn "-------------------------------------- Performed delayed actions"
124115 liftIO $ writeIORef hydrationMode HydrationMode_Immediate
125− liftIO $ putStrLn "-------------------------------------- Performing delayed actions"
126116 liftIO $ processAsyncEvents events fc
127117
128118--TODO: This is a collection of random stuff; we should make it make some more sense and then upstream to reflex-dom-core
@@ -155,11 +145,8 @@ runWithHeadAndBody app = withJSContextSingletonMono $ \jsSing -> do
155145 , _hydrationDomBuilderEnv_hydrationMode = hydrationMode
156146 , _hydrationDomBuilderEnv_prerenderDepth = prerenderDepth
157147 }
158− state = HydrationDomBuilderState
159− { _hydrationDomBuilderState_delayed = []
160− }
161− (a, res) <- runHydrationDomBuilderT w builderEnv state events'
162− liftIO $ modifyIORef' hydrationResult $ \xs -> xs ++ _hydrationDomBuilderState_delayed res
148+ (a, res) <- runHydrationDomBuilderT w builderEnv events'
149+ liftIO $ modifyIORef' hydrationResult $ \xs -> xs ++ res -- TODO
163150 pure a
164151 flip runPostBuildT postBuild $ flip runTriggerEventT events $ app (hydrateDom $ toNode headElement) (hydrateDom $ toNode bodyElement)
165152-- liftIO (readIORef unreadyChildren) >>= \case
skeleton/frontend/src/Frontend.hs+15−12
@@ -39,7 +39,9 @@ tshow = T.pack . show
3939
4040frontend :: Frontend (R FrontendRoute)
4141frontend = Frontend
42− { _frontend_head = pure () -- el "title" $ text "Obelisk Minimal Example"
42+ { _frontend_head = pure ()
43+ -- TODO lib/Frontend needs fixing for this to work
44+ -- el "title" $ text "Obelisk Minimal Example"
4345 , _frontend_body = do
4446 text "Welcome to Obelisk!"
4547 el "p" $ text $ T.pack commonStuff
@@ -61,7 +63,6 @@ frontend = Frontend
6163-- (el "a" $ text "JS link")
6264
6365 pb <- getPostBuild
64− pure ()
6566
6667 elAttr "article" ("style" =: "background: moccasin") $ do
6768 widgetHold_ (el "div" $ text "first") $ ffor pb $ \() -> display seconds
@@ -82,8 +83,6 @@ frontend = Frontend
8283 1 -> text "Odd"
8384 1 -> el "span" $ text "Odd inner"
8485
85− pure ()
86−
8786 -- These will be squashed into a single text node by the static renderer
8887-- text "Test"
8988-- text "Test"
@@ -91,14 +90,18 @@ frontend = Frontend
9190-- text "Test"
9291-- text "Test"
9392
94− {-
9593 --traverseDMapWithKeyWithAdjust' :: (forall a. k a -> v a -> m (v' a)) -> DMap k v -> Event t (PatchDMap k v) -> m (DMap k v', Event t (PatchDMap k v'))
96− elAttr "article" ("style" =: "background: thistle") $ do
97− (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \x -> case x `mod` 2 of
98− 0 -> PatchDMap $ DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity x)
99− 1 -> PatchDMap $ DMap.singleton Key_Bool (ComposeMaybe $ case x `mod` 3 of 0 -> Nothing; _ -> Just $ Identity True) <> DMap.singleton Key_Char (ComposeMaybe $ Just $ Identity (toEnum $ fromEnum 'A' + x))
94+-- elAttr "article" ("style" =: "background: thistle") $ do
95+-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $ ffor (updated clicks) $ \_ -> case 0 of -- x -> case x `mod` 2 of
96+-- 0 -> PatchDMap $ DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity 10)
97+-- 1 -> PatchDMap $ DMap.singleton Key_Bool (ComposeMaybe $ case x `mod` 3 of 0 -> Nothing; _ -> Just $ Identity True) <> DMap.singleton Key_Char (ComposeMaybe $ Just $ Identity (toEnum $ fromEnum 'A' + x))
10098 pure ()
101−-}
99+
100+
101+-- elAttr "article" ("style" =: "background: thistle") $ do
102+-- (m', e') <- traverseDMapWithKeyWithAdjust (\k v -> has @Show k $ dkeyWidget k v) keyMap $
103+-- PatchDMap (DMap.singleton Key_Int (ComposeMaybe $ Just $ Identity 10)) <$ pb
104+-- pure ()
102105
103106 {-
104107 elAttr "article" ("style" =: "background: maroon") $ do
@@ -130,10 +133,10 @@ frontend = Frontend
130133 , ffor del $ \() -> PatchIntMap $ IntMap.singleton 3 Nothing
131134 ]
132135 pure ()
133−
134−-}
136+ -}
135137
136138-- el "footer" $ text "Footer"
139+ pure ()
137140 }
138141
139142intkeyWidget :: (MonadHold t m, PostBuild t m, PerformEvent t m, TriggerEvent t m, DomBuilder t m, MonadFix m, MonadIO m, MonadIO (Performable m)) => Int -> Char -> m ()