diff --git a/reflex-dom-core/reflex-dom-core.cabal b/reflex-dom-core/reflex-dom-core.cabal index 592256dc..1e4fcb7a 100644 --- a/reflex-dom-core/reflex-dom-core.cabal +++ b/reflex-dom-core/reflex-dom-core.cabal @@ -70,13 +70,13 @@ library aeson >= 0.8 && < 2.3, base >= 4.7 && < 4.20, bifunctors >= 4.2 && < 6, - bimap >= 0.3 && < 0.5, + bimap >= 0.3 && < 0.6, blaze-builder >= 0.4.1 && < 0.5, bytestring >= 0.10 && < 0.13, case-insensitive < 1.3, - commutative-semigroups >=0.1 && <0.2, + commutative-semigroups >=0.1 && <0.3, containers >= 0.6 && < 0.7, - constraints >= 0.9 && < 0.14, + constraints >= 0.9 && < 0.15, contravariant >= 1.4 && < 1.6, data-default >= 0.5 && < 0.8, dependent-map >= 0.3 && < 0.5, @@ -95,18 +95,18 @@ library random >= 1.1 && < 1.3, ref-tf >= 0.4 && < 0.6, reflex >= 0.8.2.1 && < 1, - semigroups >= 0.16 && < 0.20, + semigroups >= 0.16 && < 0.21, stm >= 2.4 && < 2.6, - text == 1.2.*, + text >= 1.2 && < 2.1, transformers >= 0.3 && < 0.7, network-uri >= 2.6.1 && < 2.7, zenc == 0.1.* - if impl(ghcjs) + if impl(ghcjs) || arch(javascript) hs-source-dirs: src-ghcjs build-depends: ghcjs-base, - hashable >= 1.2 && < 1.4 + hashable >= 1.2 && < 1.5 else hs-source-dirs: src-ghc if !os(windows) @@ -118,7 +118,7 @@ library these >= 1 && < 1.3 else build-depends: - these >= 0.4 && < 0.9 + these >= 0.4 && < 1.0 exposed-modules: Foreign.JavaScript.TH @@ -170,7 +170,7 @@ library if flag(use-template-haskell) build-depends: dependent-sum-template >= 0.1 && < 0.3, - template-haskell >= 2.12.0 && < 2.22 + template-haskell >= 2.12.0 && < 2.23 other-extensions: TemplateHaskell cpp-options: -DUSE_TEMPLATE_HASKELL other-modules: diff --git a/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs b/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs index 73d7a886..06cb003e 100644 --- a/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs +++ b/reflex-dom-core/src-ghcjs/Foreign/JavaScript/Internal/Utils.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE JavaScriptFFI #-} @@ -9,7 +10,11 @@ module Foreign.JavaScript.Internal.Utils import GHCJS.Concurrent import GHCJS.DOM.Types (JSM, JSVal, RequestAnimationFrameCallback (..)) +#ifdef __GHCJS__ import GHCJS.Foreign.Callback (releaseCallback) +#else +import GHC.JS.Foreign.Callback (releaseCallback) +#endif freeRequestAnimationFrameCallback :: RequestAnimationFrameCallback -> JSM () freeRequestAnimationFrameCallback (RequestAnimationFrameCallback cb) = releaseCallback cb diff --git a/reflex-dom-core/src/Foreign/JavaScript/TH.hs b/reflex-dom-core/src/Foreign/JavaScript/TH.hs index 602bd421..bf2080cc 100644 --- a/reflex-dom-core/src/Foreign/JavaScript/TH.hs +++ b/reflex-dom-core/src/Foreign/JavaScript/TH.hs @@ -35,8 +35,12 @@ import qualified GHCJS.Buffer as JS import GHCJS.DOM.Types (MonadJSM) import qualified GHCJS.DOM.Types as JS import qualified GHCJS.Foreign as JS +#ifdef __GHCJS__ import qualified GHCJS.Foreign.Callback as JS import qualified GHCJS.Foreign.Callback.Internal (Callback (..)) +#else +import qualified GHC.JS.Foreign.Callback as JS +#endif import qualified JavaScript.Array as JS import qualified JavaScript.Array.Internal (SomeJSArray (..)) import qualified JavaScript.Object as JS diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs index dedf268a..20eca905 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs @@ -279,15 +279,6 @@ elementConfig_eventSpec f (ElementConfig a b c d) = (\d' -> ElementConfig a b c {-# INLINE elementConfig_eventSpec #-} #endif -instance (Reflex t, er ~ EventResult, DomSpace s) => Default (ElementConfig er t s) where - {-# INLINABLE def #-} - def = ElementConfig - { _elementConfig_namespace = Nothing - , _elementConfig_initialAttributes = mempty - , _elementConfig_modifyAttributes = Nothing - , _elementConfig_eventSpec = def - } - data Element er d t = Element { _element_events :: EventSelector t (WrapArg er EventName) --TODO: EventSelector should have two arguments , _element_raw :: RawElement d @@ -317,6 +308,15 @@ inputElementConfig_elementConfig f (InputElementConfig a b c d e) = (\e' -> Inpu {-# INLINE inputElementConfig_elementConfig #-} #endif +instance (Reflex t, er ~ EventResult, DomSpace s) => Default (ElementConfig er t s) where + {-# INLINABLE def #-} + def = ElementConfig + { _elementConfig_namespace = Nothing + , _elementConfig_initialAttributes = mempty + , _elementConfig_modifyAttributes = Nothing + , _elementConfig_eventSpec = def + } + instance (Reflex t, er ~ EventResult, DomSpace s) => Default (InputElementConfig er t s) where {-# INLINABLE def #-} def = InputElementConfig diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs index 031997ba..ee7b5136 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs @@ -466,7 +466,11 @@ removeSubsequentNodes :: (MonadJSM m, IsNode n) => n -> m () #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2021-11-06) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var n = $1; while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })()" +#else + "(function(n) { while (n['nextSibling']) { n['parentNode']['removeChild'](n['nextSibling']); }; })" +#endif removeSubsequentNodes_ :: DOM.Node -> IO () removeSubsequentNodes n = liftJSM $ removeSubsequentNodes_ (toNode n) #else @@ -489,7 +493,11 @@ extractBetweenExclusive :: (MonadJSM m, IsNode start, IsNode end) => DOM.Documen #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2021-11-06) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var df = $1; var s = $2; var e = $3; var x; for(;;) { x = s['nextSibling']; if(e===x) { break; }; df['appendChild'](x); } })()" +#else + "(function(df, s, e) { var x; for(;;) { x = s['nextSibling']; if(e===x) { break; }; df['appendChild'](x); } })" +#endif extractBetweenExclusive_ :: DOM.DocumentFragment -> DOM.Node -> DOM.Node -> IO () extractBetweenExclusive df s e = liftJSM $ extractBetweenExclusive_ df (toNode s) (toNode e) #else @@ -510,7 +518,11 @@ extractUpTo :: (MonadJSM m, IsNode start, IsNode end) => DOM.DocumentFragment -> #ifdef ghcjs_HOST_OS --NOTE: Although wrapping this javascript in a function seems unnecessary, GHCJS's optimizer will break it if it is entered without that wrapping (as of 2017-09-04) foreign import javascript unsafe +#ifdef __GHCJS__ "(function() { var x = $2; while(x !== $3) { var y = x['nextSibling']; $1['appendChild'](x); x = y; } })()" +#else + "(function(_, x, $3) { while(x !== $3) { var y = x['nextSibling']; $1['appendChild'](x); x = y; } })" +#endif extractUpTo_ :: DOM.DocumentFragment -> DOM.Node -> DOM.Node -> IO () extractUpTo df s e = liftJSM $ extractUpTo_ df (toNode s) (toNode e) #else diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs index 4463ee38..b2d94deb 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs @@ -18,8 +18,8 @@ module Reflex.Dom.Builder.Static where import Data.IORef (IORef) import Blaze.ByteString.Builder.Html.Utf8 import Control.Lens hiding (element) -import Control.Monad.Exception import Control.Monad +import Control.Monad.Exception import Control.Monad.Fix import Control.Monad.Identity import Control.Monad.Primitive