diff --git a/.github/workflows/haskell.yml b/.github/workflows/haskell.yml index 8a8bbe26..b3ceefbc 100644 --- a/.github/workflows/haskell.yml +++ b/.github/workflows/haskell.yml @@ -8,6 +8,11 @@ jobs: matrix: ghc: ['8.6', '8.8', '8.10', '9.0', '9.2', '9.4', '9.6', '9.8', '9.10', '9.12'] os: ['ubuntu-latest', 'macos-13'] # https://github.com/haskell-actions/setup/issues/77 + exclude: + - os: 'macos-13' + ghc: '8.6' + - os: 'macos-13' + ghc: '8.8' runs-on: ${{ matrix.os }} name: GHC ${{ matrix.ghc }} on ${{ matrix.os }} diff --git a/.gitignore b/.gitignore index e28ef49b..a241d7e1 100644 --- a/.gitignore +++ b/.gitignore @@ -34,6 +34,7 @@ hsenv.log *_stub.h .cabal-sandbox/ cabal.sandbox.config +cabal.project.local .stack-work codex.tags *.dump-* diff --git a/reflex-dom-core/reflex-dom-core.cabal b/reflex-dom-core/reflex-dom-core.cabal index fda2139e..de8008b3 100644 --- a/reflex-dom-core/reflex-dom-core.cabal +++ b/reflex-dom-core/reflex-dom-core.cabal @@ -1,268 +1,288 @@ -cabal-version: 1.24 -Name: reflex-dom-core -Version: 0.8.1.4 -Synopsis: Functional Reactive Web Apps with Reflex -Description: - Web applications without callbacks or side-effects. - Reflex-DOM brings the power of functional reactive programming (FRP) to the web. - Build HTML and other Document Object Model (DOM) data with a pure functional interface. - . - Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: . - . - The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the - correct set of dependencies for each target platform (GHCJS, WebKitGTK, WASM, mobile, etc.). - Libraries should depend on @reflex-dom-core@ and executables will usually depend on @reflex-dom@. - All of @reflex-dom-core@'s modules are re-exported by @reflex-dom@. -License: BSD3 -License-file: LICENSE -Author: Ryan Trinkle -Maintainer: ryan.trinkle@gmail.com -Stability: Experimental -Category: FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface -Build-type: Simple --- Deal with https://github.com/haskell/cabal/issues/2544 / https://github.com/haskell/cabal/issues/367 -extra-source-files: src-ghc/Foreign/JavaScript/Internal/Utils.hs - src-ghcjs/Foreign/JavaScript/Internal/Utils.hs - src/Reflex/Dom/Xhr/Foreign.hs - src/Reflex/Dom/WebSocket/Foreign.hs - src/Reflex/Dom/Xhr/ResponseType.hs - src/Reflex/Dom/Xhr/Exception.hs - ChangeLog.md +cabal-version: 1.24 +name: reflex-dom-core +version: 0.8.1.4 +license: BSD3 +license-file: LICENSE +maintainer: ryan.trinkle@gmail.com +author: Ryan Trinkle +stability: Experimental +synopsis: Functional Reactive Web Apps with Reflex +description: + Web applications without callbacks or side-effects. + Reflex-DOM brings the power of functional reactive programming (FRP) to the web. + Build HTML and other Document Object Model (DOM) data with a pure functional interface. + . + Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: . + . + The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the + correct set of dependencies for each target platform (GHCJS, WebKitGTK, WASM, mobile, etc.). + Libraries should depend on @reflex-dom-core@ and executables will usually depend on @reflex-dom@. + All of @reflex-dom-core@'s modules are re-exported by @reflex-dom@. + +category: + FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface + +build-type: Simple +extra-source-files: + src-ghc/Foreign/JavaScript/Internal/Utils.hs + src-ghcjs/Foreign/JavaScript/Internal/Utils.hs + src/Reflex/Dom/Xhr/Foreign.hs + src/Reflex/Dom/WebSocket/Foreign.hs + src/Reflex/Dom/Xhr/ResponseType.hs + src/Reflex/Dom/Xhr/Exception.hs + ChangeLog.md + +source-repository head + type: git + location: https://github.com/reflex-frp/reflex-dom + subdir: reflex-dom-core flag use-template-haskell - description: Use template haskell to generate lenses - default: True - manual: True + description: Use template haskell to generate lenses + manual: True flag use-reflex-optimizer - description: Use the GHC plugin Reflex.Optimizer on some of the modules in the package. This is still experimental. - default: False - manual: True + description: + Use the GHC plugin Reflex.Optimizer on some of the modules in the package. This is still experimental. + + default: False + manual: True flag expose-all-unfoldings - description: Build the library with -fexpose-all-unfoldings which can help client code specialize better - default: False - manual: True + description: + Build the library with -fexpose-all-unfoldings which can help client code specialize better + + default: False + manual: True flag profile-reflex - description: Add a layer of profiling to all Reflex events in the system - default: False - manual: True + description: Add a layer of profiling to all Reflex events in the system + default: False + manual: True flag split-these - description: Use split these/semialign packages - manual: False - default: True + description: Use split these/semialign packages + manual: False + default: True flag hydration-tests - description: Whether to run the hydration tests (currently only available on linux) - default: True - manual: True + description: + Whether to run the hydration tests (currently only available on linux) + manual: True + default: True flag gc-tests - description: Whether to run the gc tests (currently only available on linux) - default: True - manual: True + description: + Whether to run the gc tests (currently only available on linux) + manual: True + default: True flag hlint-tests - description: Whether to run the hlint tests - default: False - manual: True + description: Whether to run the hlint tests + manual: False + default: True library - hs-source-dirs: src - build-depends: - aeson >= 0.8 && < 2.3, - base >= 4.7 && < 4.22, - bifunctors >= 4.2 && < 6, - 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.3, - containers >= 0.6 && < 0.8, - constraints >= 0.9 && < 0.15, - contravariant >= 1.4 && < 1.6, - data-default >= 0.5 && < 0.9, - dependent-map >= 0.3 && < 0.5, - dependent-sum >= 0.6 && < 0.8, - dependent-sum-template >= 0.1 && < 0.3, - directory >= 1.2 && < 1.4, - exception-transformers == 0.4.*, - ghcjs-dom >= 0.9.1.0 && < 0.10, - jsaddle >= 0.9.0.0 && < 0.10, - -- keycode-0.2 has a bug on firefox - keycode >= 0.2.1 && < 0.3, - lens >= 4.7 && < 5.4, - monad-control >= 1.0.1 && < 1.1, - mtl >= 2.1 && < 2.4, - primitive >= 0.5 && < 0.10, - random >= 1.1 && < 1.4, - ref-tf >= 0.4 && < 0.6, - reflex >= 0.8.2.1 && < 1, - semigroups >= 0.16 && < 0.21, - stm >= 2.4 && < 2.6, - text >= 1.2 && < 2.2, - transformers >= 0.3 && < 0.7, - network-uri >= 2.6.1 && < 2.7, - zenc == 0.1.* - - if impl(ghcjs) || arch(javascript) - hs-source-dirs: src-ghcjs - build-depends: - ghcjs-base, - hashable >= 1.2 && < 1.6 - else - hs-source-dirs: src-ghc - if !os(windows) - build-depends: unix >= 2.7 && <2.9 - - if flag(split-these) - build-depends: - semialign >= 1 && < 1.4, - these >= 1 && < 1.3 - else - build-depends: - these >= 0.4 && < 1.0 - - exposed-modules: - Foreign.JavaScript.TH - Foreign.JavaScript.Orphans - Foreign.JavaScript.Utils - Reflex.Dom.Builder.Class - Reflex.Dom.Builder.Class.Events - Reflex.Dom.Builder.Immediate - Reflex.Dom.Builder.InputDisabled - Reflex.Dom.Builder.Hydratable - Reflex.Dom.Builder.Static - Reflex.Dom.Class - Reflex.Dom.Core - Reflex.Dom.Location - Reflex.Dom.Main - Reflex.Dom.Modals.Class - Reflex.Dom.Old - Reflex.Dom.Prerender - Reflex.Dom.Time - Reflex.Dom.WebSocket - Reflex.Dom.WebSocket.Query - Reflex.Dom.Widget - Reflex.Dom.Widget.Basic - Reflex.Dom.Widget.Input - Reflex.Dom.Widget.Lazy - Reflex.Dom.Widget.Resize - Reflex.Dom.Xhr - Reflex.Dom.Xhr.FormData - other-modules: - Foreign.JavaScript.Internal.Utils - Reflex.Dom.WebSocket.Foreign - Reflex.Dom.Xhr.Foreign - Reflex.Dom.Xhr.ResponseType - Reflex.Dom.Xhr.Exception - - default-language: Haskell98 - ghc-options: -Wall -fwarn-tabs -Wredundant-constraints -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively - ghc-prof-options: -fprof-auto - - if flag(expose-all-unfoldings) - ghc-options: -fexpose-all-unfoldings - - if flag(use-reflex-optimizer) - ghc-options: -fplugin=Reflex.Optimizer - - if flag(profile-reflex) - cpp-options: -DPROFILE_REFLEX - - if flag(use-template-haskell) - build-depends: - dependent-sum-template >= 0.1 && < 0.3, - template-haskell >= 2.12.0 && < 2.24 - other-extensions: TemplateHaskell - cpp-options: -DUSE_TEMPLATE_HASKELL + exposed-modules: + Foreign.JavaScript.TH + Foreign.JavaScript.Orphans + Foreign.JavaScript.Utils + Reflex.Dom.Builder.Class + Reflex.Dom.Builder.Class.Events + Reflex.Dom.Builder.Immediate + Reflex.Dom.Builder.InputDisabled + Reflex.Dom.Builder.Hydratable + Reflex.Dom.Builder.Static + Reflex.Dom.Class + Reflex.Dom.Core + Reflex.Dom.Location + Reflex.Dom.Main + Reflex.Dom.Modals.Class + Reflex.Dom.Old + Reflex.Dom.Prerender + Reflex.Dom.Time + Reflex.Dom.WebSocket + Reflex.Dom.WebSocket.Query + Reflex.Dom.Widget + Reflex.Dom.Widget.Basic + Reflex.Dom.Widget.Input + Reflex.Dom.Widget.Lazy + Reflex.Dom.Widget.Resize + Reflex.Dom.Xhr + Reflex.Dom.Xhr.FormData + + hs-source-dirs: src other-modules: - Reflex.Dom.Builder.Class.TH + Foreign.JavaScript.Internal.Utils + Reflex.Dom.WebSocket.Foreign + Reflex.Dom.Xhr.Foreign + Reflex.Dom.Xhr.ResponseType + Reflex.Dom.Xhr.Exception + + default-language: Haskell98 + ghc-options: + -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans + -fspecialise-aggressively + + ghc-prof-options: -fprof-auto + build-depends: + aeson >= 0.8 && < 2.3, + base >= 4.7 && < 4.22, + bifunctors >= 4.2 && < 6, + 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.3, + containers >= 0.6 && < 0.8, + constraints >= 0.9 && < 0.15, + contravariant >= 1.4 && < 1.6, + data-default >= 0.5 && < 0.9, + dependent-map >= 0.3 && < 0.5, + dependent-sum >= 0.6 && < 0.8, + dependent-sum-template >= 0.2 && < 0.3, + directory >= 1.2 && < 1.4, + exception-transformers == 0.4.*, + ghcjs-dom >= 0.9.1.0 && < 0.10, + jsaddle >= 0.9.0.0 && < 0.10, + -- keycode-0.2 has a bug on firefox + keycode >= 0.2.1 && < 0.3, + lens >= 4.7 && < 5.4, + monad-control >= 1.0.1 && < 1.1, + mtl >= 2.1 && < 2.4, + primitive >= 0.5 && < 0.10, + random >= 1.1 && < 1.4, + ref-tf >= 0.4 && < 0.6, + reflex >= 0.8.2.1 && < 1, + semigroups >= 0.16 && < 0.21, + stm >= 2.4 && < 2.6, + text >= 1.2 && < 2.2, + transformers >= 0.3 && < 0.7, + network-uri >= 2.6.1 && < 2.7, + zenc == 0.1.* + + if (impl(ghcjs >=0) || arch(javascript)) + hs-source-dirs: src-ghcjs + build-depends: + ghcjs-base, + hashable >= 1.2 && < 1.6 + + else + hs-source-dirs: src-ghc + + if !os(windows) + build-depends: unix >=2.7 && <2.9 + + if flag(split-these) + build-depends: + semialign >=1 && <1.4, + these >=1 && <1.3 + + else + build-depends: these >=0.4 && <1.0 + + if flag(expose-all-unfoldings) + ghc-options: -fexpose-all-unfoldings + + if flag(profile-reflex) + cpp-options: -DPROFILE_REFLEX + + if flag(use-template-haskell) + cpp-options: -DUSE_TEMPLATE_HASKELL + other-modules: Reflex.Dom.Builder.Class.TH + other-extensions: TemplateHaskell + build-depends: + dependent-sum-template >=0.1 && <0.3, + template-haskell >=2.12.0 && <2.24 test-suite hlint - build-depends: - base, - hlint >= 2.0 && < 4.0, - reflex-dom-core - hs-source-dirs: test - main-is: hlint.hs - type: exitcode-stdio-1.0 - default-language: Haskell98 - if !flag(hlint-tests) - buildable: False + type: exitcode-stdio-1.0 + main-is: hlint.hs + hs-source-dirs: test + default-language: Haskell98 + build-depends: + base, + hlint >=2.0 && <4.0, + reflex-dom-core + + if !flag(hlint-tests) || arch(javascript) + buildable: False test-suite hydration - build-depends: base - , aeson - , async - , bytestring - , chrome-test-utils - , constraints - , constraints-extras - , containers - , dependent-map - , dependent-sum - , dependent-sum-template - , directory - , exceptions - , filepath - , ghcjs-dom - , hspec - , hspec-core - , hspec-webdriver - , http-types - , HUnit - , jsaddle - , jsaddle-warp - , lens - , lifted-base - , network - , random - , ref-tf - , reflex - , reflex-dom-core - , process - , silently - , temporary - , text - , wai - , wai-websockets - , warp - , webdriver - , websockets - , which - hs-source-dirs: test - ghc-options: -rtsopts "-with-rtsopts=-T -V0" -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans - ghc-prof-options: -fprof-auto -optP-DPROFILING - main-is: hydration.hs - type: exitcode-stdio-1.0 - default-language: Haskell98 - if !os(linux) || !arch(x86_64) || flag(profile-reflex) || !flag(hydration-tests) - buildable: False + type: exitcode-stdio-1.0 + main-is: hydration.hs + hs-source-dirs: test + default-language: Haskell98 + ghc-options: + -rtsopts "-with-rtsopts=-T -V0" -Wall -fwarn-tabs + -funbox-strict-fields -O2 -ferror-spans + + ghc-prof-options: -fprof-auto -optP-DPROFILING + build-depends: + base + , aeson + , async + , bytestring + , chrome-test-utils + , constraints + , constraints-extras + , containers + , dependent-map + , dependent-sum + , dependent-sum-template + , directory + , exceptions + , filepath + , ghcjs-dom + , hspec + , hspec-core + , hspec-webdriver + , http-types + , HUnit + , jsaddle + , jsaddle-warp + , lens + , lifted-base + , network + , random + , ref-tf + , reflex + , reflex-dom-core + , process + , silently + , temporary + , text + , wai + , wai-websockets + , warp + , webdriver + , websockets + , which + + if (((!os(linux) || !arch(x86_64)) || flag(profile-reflex)) || !flag(hydration-tests)) + buildable: False -- broken test on base 4.11 & ghc 8.4.3 -- needs to be updated for changes in GHC.Stats test-suite gc - build-depends: base - , chrome-test-utils - , jsaddle - , jsaddle-warp - , process - , reflex - , reflex-dom-core - , text - hs-source-dirs: test - ghc-options: -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans - ghc-prof-options: -fprof-auto -optP-DPROFILING - main-is: gc.hs - type: exitcode-stdio-1.0 - default-language: Haskell98 - if !os(linux) || !arch(x86_64) || !flag(gc-tests) - buildable: False + type: exitcode-stdio-1.0 + main-is: gc.hs + hs-source-dirs: test + default-language: Haskell98 + ghc-options: + -rtsopts -with-rtsopts=-T -Wall -fwarn-tabs -funbox-strict-fields + -O2 -ferror-spans -source-repository head - type: git - location: https://github.com/reflex-frp/reflex-dom - subdir: reflex-dom-core + ghc-prof-options: -fprof-auto -optP-DPROFILING + build-depends: + base + , chrome-test-utils + , jsaddle + , jsaddle-warp + , process + , reflex + , reflex-dom-core + , text + + if ((!os(linux) || !arch(x86_64)) || !flag(gc-tests)) + buildable: False diff --git a/reflex-dom-core/src/Foreign/JavaScript/TH.hs b/reflex-dom-core/src/Foreign/JavaScript/TH.hs index 702b3edd..e126fb55 100644 --- a/reflex-dom-core/src/Foreign/JavaScript/TH.hs +++ b/reflex-dom-core/src/Foreign/JavaScript/TH.hs @@ -10,13 +10,17 @@ {-# LANGUAGE UndecidableInstances #-} #ifdef ghcjs_HOST_OS {-# LANGUAGE ForeignFunctionInterface #-} +#ifdef __GHCJS__ {-# LANGUAGE JavaScriptFFI #-} #endif -module Foreign.JavaScript.TH ( module Foreign.JavaScript.TH +#endif + +module Foreign.JavaScript.TH + ( module Foreign.JavaScript.TH #ifdef USE_TEMPLATE_HASKELL - , Safety (..) + , Safety (..) #endif - ) where + ) where import Foreign.JavaScript.Orphans () import Prelude hiding ((!!)) @@ -31,16 +35,12 @@ import Language.Haskell.TH import GHCJS.DOM.Types (JSContextRef, askJSM) #ifdef ghcjs_HOST_OS -import qualified GHCJS.Buffer as JS import GHCJS.DOM.Types (MonadJSM) import qualified GHCJS.DOM.Types as JS import qualified GHCJS.Foreign as JS #if __GLASGOW_HASKELL__ < 900 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 @@ -52,6 +52,8 @@ import Data.Word import Foreign.C.Types import Foreign.Ptr import Text.Encoding.Z +#endif + #else import GHCJS.DOM.Types (MonadJSM (..), runJSM) #endif diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs index c749bfb0..913ae07d 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Class.hs @@ -24,27 +24,12 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -module Reflex.Dom.Builder.Class - ( module Reflex.Dom.Builder.Class - , module Reflex.Dom.Builder.Class.Events - , module Reflex.NotReady.Class - ) where -import Reflex.Adjustable.Class -import Reflex.Class as Reflex -import Reflex.Dom.Builder.Class.Events -#ifdef USE_TEMPLATE_HASKELL -import Reflex.Dom.Builder.Class.TH -#endif -import Reflex.BehaviorWriter.Base -import Reflex.DynamicWriter.Base -import Reflex.EventWriter.Base -import Reflex.NotReady.Class -import Reflex.PerformEvent.Class -import Reflex.PostBuild.Base -import Reflex.Query.Base -import Reflex.Query.Class -import Reflex.Requester.Base +module Reflex.Dom.Builder.Class + ( module Reflex.Dom.Builder.Class + , module Reflex.Dom.Builder.Class.Events + , module Reflex.NotReady.Class + ) where import qualified Control.Category import Control.Lens hiding (element) @@ -67,6 +52,26 @@ import Data.Type.Coercion import GHCJS.DOM.Types (JSM) import qualified GHCJS.DOM.Types as DOM +#if !MIN_VERSION_base(4,18,0) +import Data.Semigroup +#endif + +import Reflex.Adjustable.Class +import Reflex.Class as Reflex +import Reflex.Dom.Builder.Class.Events +#ifdef USE_TEMPLATE_HASKELL +import Reflex.Dom.Builder.Class.TH +#endif +import Reflex.BehaviorWriter.Base +import Reflex.DynamicWriter.Base +import Reflex.EventWriter.Base +import Reflex.NotReady.Class +import Reflex.PerformEvent.Class +import Reflex.PostBuild.Base +import Reflex.Query.Base +import Reflex.Query.Class +import Reflex.Requester.Base + class Default (EventSpec d EventResult) => DomSpace d where type EventSpec d :: (EventTag -> Type) -> Type type RawDocument d :: Type diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Class/Events.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Class/Events.hs index 978be6fe..05721ad9 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Class/Events.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Class/Events.hs @@ -6,6 +6,7 @@ {-# LANGUAGE TemplateHaskell #-} #endif {-# LANGUAGE TypeFamilies #-} + module Reflex.Dom.Builder.Class.Events where #ifdef USE_TEMPLATE_HASKELL diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Hydratable.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Hydratable.hs index 6b699723..32bcb62b 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Hydratable.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Hydratable.hs @@ -6,6 +6,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} + module Reflex.Dom.Builder.Hydratable where import Control.Monad.Fix @@ -18,6 +19,7 @@ import qualified Data.Map as Map #ifndef ghcjs_HOST_OS import GHCJS.DOM.Types (MonadJSM (..)) #endif + import Reflex import Reflex.Dom.Builder.Class import Reflex.Dom.Builder.Immediate (hydratableAttribute) diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs index 05598e8e..5c3e170d 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Immediate.hs @@ -25,8 +25,11 @@ {-# LANGUAGE UndecidableInstances #-} #ifdef ghcjs_HOST_OS {-# LANGUAGE ForeignFunctionInterface #-} +#ifdef __GHCJS__ {-# LANGUAGE JavaScriptFFI #-} #endif +#endif + -- | This is a builder to be used on the client side. It can be run in two modes: -- -- 1. in "hydration mode", reusing DOM nodes already in the page (as produced @@ -158,24 +161,6 @@ import GHCJS.DOM.UIEvent #ifndef ghcjs_HOST_OS import Language.Javascript.JSaddle (call, eval) -- Avoid using eval in ghcjs. Use ffi instead #endif -import Reflex.Adjustable.Class -import Reflex.Class as Reflex -import Reflex.Dom.Builder.Class -import Reflex.Dynamic -import Reflex.Host.Class -import Reflex.Patch.MapWithMove (PatchMapWithMove(..)) -import Reflex.PerformEvent.Base (PerformEventT) -import Reflex.PerformEvent.Class -import Reflex.PostBuild.Base (PostBuildT) -import Reflex.PostBuild.Class -#ifdef PROFILE_REFLEX -import Reflex.Profiled -#endif -import Reflex.Requester.Base -import Reflex.Requester.Class -import Reflex.Spider (Spider, SpiderHost, Global) -import Reflex.TriggerEvent.Base hiding (askEvents) -import Reflex.TriggerEvent.Class import qualified Data.Dependent.Map as DMap import qualified Data.FastMutableIntMap as FastMutableIntMap @@ -202,6 +187,31 @@ import qualified GHCJS.DOM.TouchList as TouchList import qualified GHCJS.DOM.Types as DOM import qualified GHCJS.DOM.Window as Window import qualified GHCJS.DOM.WheelEvent as WheelEvent + +#if !MIN_VERSION_base(4,18,0) +import Data.FastMutableIntMap (PatchIntMap (..)) +import Data.Monoid ((<>)) +import GHCJS.DOM.Types (KeyboardEvent, ClipboardEvent) +#endif + +import Reflex.Adjustable.Class +import Reflex.Class as Reflex +import Reflex.Dom.Builder.Class +import Reflex.Dynamic +import Reflex.Host.Class +import Reflex.Patch.MapWithMove (PatchMapWithMove(..)) +import Reflex.PerformEvent.Base (PerformEventT) +import Reflex.PerformEvent.Class +import Reflex.PostBuild.Base (PostBuildT) +import Reflex.PostBuild.Class +#ifdef PROFILE_REFLEX +import Reflex.Profiled +#endif +import Reflex.Requester.Base +import Reflex.Requester.Class +import Reflex.Spider (Spider, SpiderHost, Global) +import Reflex.TriggerEvent.Base hiding (askEvents) +import Reflex.TriggerEvent.Class import qualified Reflex.Patch.DMap as PatchDMap import qualified Reflex.Patch.DMapWithMove as PatchDMapWithMove import qualified Reflex.Patch.MapWithMove as PatchMapWithMove @@ -1537,7 +1547,7 @@ instance (Reflex t, Monad m, Adjustable t m, MonadHold t m, MonadFix m) => Adjus traverseDMapWithKeyWithAdjust f m = DomRenderHookT . traverseDMapWithKeyWithAdjust (\k -> unDomRenderHookT . f k) m traverseDMapWithKeyWithAdjustWithMove f m = DomRenderHookT . traverseDMapWithKeyWithAdjustWithMove (\k -> unDomRenderHookT . f k) m -instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document) => Adjustable t (HydrationDomBuilderT s t m) where +instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, PrimMonad m, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document) => Adjustable t (HydrationDomBuilderT s t m) where {-# INLINABLE runWithReplace #-} runWithReplace a0 a' = do initialEnv <- HydrationDomBuilderT ask @@ -1699,7 +1709,7 @@ instance (Adjustable t m, MonadJSM m, MonadHold t m, MonadFix m, RawDocument (Do {-# INLINABLE traverseDMapWithKeyWithAdjust' #-} traverseDMapWithKeyWithAdjust' - :: forall s t m (k :: Type -> Type) v v'. (Adjustable t m, MonadHold t m, MonadFix m, MonadJSM m, GCompare k, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document) + :: forall s t m (k :: Type -> Type) v v'. (Adjustable t m, MonadHold t m, MonadFix m, MonadJSM m, PrimMonad m, GCompare k, RawDocument (DomBuilderSpace (HydrationDomBuilderT s t m)) ~ Document) => (forall a. k a -> v a -> HydrationDomBuilderT s t m (v' a)) -> DMap k v -> Event t (PatchDMap k v) diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/InputDisabled.hs b/reflex-dom-core/src/Reflex/Dom/Builder/InputDisabled.hs index bb0a04c4..4ab6987d 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/InputDisabled.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/InputDisabled.hs @@ -6,6 +6,7 @@ {-# LANGUAGE StandaloneDeriving #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE UndecidableInstances #-} + module Reflex.Dom.Builder.InputDisabled where import Control.Monad.Fix diff --git a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs index 963836cc..c7e6adc6 100644 --- a/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs +++ b/reflex-dom-core/src/Reflex/Dom/Builder/Static.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE ConstraintKinds #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE DeriveGeneric #-} @@ -13,6 +14,7 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} + module Reflex.Dom.Builder.Static where import Data.IORef (IORef) @@ -36,16 +38,22 @@ import Data.Functor.Compose import Data.Functor.Constant import Data.IntMap (IntMap) import qualified Data.IntMap as IntMap +import Data.Kind (Type) import qualified Data.Map as Map import Data.Map.Misc (applyMap) import Data.Maybe (fromMaybe) -import Data.Kind (Type) import qualified Data.Set as Set import Data.Text (Text) import qualified Data.Text as T import Data.Text.Encoding import Data.Tuple import GHC.Generics + +#if !MIN_VERSION_base(4,18,0) +import Control.Monad.Identity +import Data.Monoid ((<>)) +#endif + import Reflex.Adjustable.Class import Reflex.Class import Reflex.Dom.Main (DomHost, DomTimeline, runDomHost) diff --git a/reflex-dom-core/src/Reflex/Dom/Class.hs b/reflex-dom-core/src/Reflex/Dom/Class.hs index f774b69b..97452eb5 100644 --- a/reflex-dom-core/src/Reflex/Dom/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Class.hs @@ -1,8 +1,10 @@ {-# LANGUAGE MultiParamTypeClasses #-} -module Reflex.Dom.Class ( module Reflex.Dom.Class - , module Foreign.JavaScript.TH - , module Web.KeyCode - ) where + +module Reflex.Dom.Class + ( module Reflex.Dom.Class + , module Foreign.JavaScript.TH + , module Web.KeyCode + ) where import Control.Lens import Reflex.Class diff --git a/reflex-dom-core/src/Reflex/Dom/Core.hs b/reflex-dom-core/src/Reflex/Dom/Core.hs index eb0b24c1..6a414b6a 100644 --- a/reflex-dom-core/src/Reflex/Dom/Core.hs +++ b/reflex-dom-core/src/Reflex/Dom/Core.hs @@ -2,6 +2,7 @@ -- reexporting on ghc > 8.2. -- https://github.com/haskell/haddock/issues/979 {-# OPTIONS_HADDOCK hide, prune, ignore-exports #-} + module Reflex.Dom.Core (module X) where import Reflex as X hiding (askEvents) diff --git a/reflex-dom-core/src/Reflex/Dom/Location.hs b/reflex-dom-core/src/Reflex/Dom/Location.hs index d3e3a910..7f68d83e 100644 --- a/reflex-dom-core/src/Reflex/Dom/Location.hs +++ b/reflex-dom-core/src/Reflex/Dom/Location.hs @@ -1,8 +1,10 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} + module Reflex.Dom.Location ( browserHistoryWith , getLocationAfterHost @@ -21,9 +23,6 @@ module Reflex.Dom.Location , popHistoryState ) where -import Reflex -import Reflex.Dom.Builder.Immediate (wrapDomEvent) - import Control.Lens ((^.)) import Control.Monad ((>=>)) import Control.Monad.Fix (MonadFix) @@ -42,6 +41,13 @@ import qualified GHCJS.DOM.WindowEventHandlers as DOM import Language.Javascript.JSaddle (FromJSString, MonadJSM, ToJSString, fromJSValUnchecked, js1, ToJSVal (..), FromJSVal (..)) import Network.URI +#if !MIN_VERSION_base(4,18,0) +import Data.Monoid +#endif + +import Reflex +import Reflex.Dom.Builder.Immediate (wrapDomEvent) + withLocation :: (MonadJSM m) => (Location -> m a) -> m a withLocation f = DOM.currentWindowUnchecked >>= Window.getLocation >>= f diff --git a/reflex-dom-core/src/Reflex/Dom/Main.hs b/reflex-dom-core/src/Reflex/Dom/Main.hs index e9eae893..3345fba8 100644 --- a/reflex-dom-core/src/Reflex/Dom/Main.hs +++ b/reflex-dom-core/src/Reflex/Dom/Main.hs @@ -12,28 +12,19 @@ {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} {-# OPTIONS_GHC -fspecialise-aggressively #-} + module Reflex.Dom.Main where import Prelude hiding (concat, mapM, mapM_, sequence, sequence_) -import Reflex.Adjustable.Class -import Reflex.Class -import Reflex.Dom.Builder.Immediate -import Reflex.Dom.Class -import Reflex.Host.Class -import Reflex.PerformEvent.Base -import Reflex.PostBuild.Base -import Reflex.Spider (Global, Spider, SpiderHost, runSpiderHost) -import Reflex.TriggerEvent.Base -import Reflex.TriggerEvent.Class -#ifdef PROFILE_REFLEX -import Reflex.Profiled -#endif - import Control.Concurrent import Control.Lens import Control.Monad +#if MIN_VERSION_base(4,18,0) import Control.Monad.Reader +#else +import Control.Monad.Reader hiding (forM, forM_, mapM, mapM_, sequence, sequence_) +#endif import Control.Monad.Ref import Data.ByteString (ByteString) import Data.Dependent.Sum (DSum (..)) @@ -51,6 +42,20 @@ import GHCJS.DOM.NonElementParentNode import GHCJS.DOM.Types (JSM) import qualified GHCJS.DOM.Types as DOM +#if !MIN_VERSION_base(4,18,0) +import Data.Monoid ((<>)) +#endif + +import Reflex.Adjustable.Class +import Reflex.Class +import Reflex.Dom.Builder.Immediate +import Reflex.Dom.Class +import Reflex.Host.Class +import Reflex.PerformEvent.Base +import Reflex.PostBuild.Base +import Reflex.Spider (Global, Spider, SpiderHost, runSpiderHost) +import Reflex.TriggerEvent.Base +import Reflex.TriggerEvent.Class #ifdef PROFILE_REFLEX import Reflex.Profiled #endif diff --git a/reflex-dom-core/src/Reflex/Dom/Modals/Class.hs b/reflex-dom-core/src/Reflex/Dom/Modals/Class.hs index f115e94d..03b0fa28 100644 --- a/reflex-dom-core/src/Reflex/Dom/Modals/Class.hs +++ b/reflex-dom-core/src/Reflex/Dom/Modals/Class.hs @@ -1,4 +1,5 @@ {-# LANGUAGE MultiParamTypeClasses #-} + module Reflex.Dom.Modals.Class where import Reflex diff --git a/reflex-dom-core/src/Reflex/Dom/Old.hs b/reflex-dom-core/src/Reflex/Dom/Old.hs index c10b9fc3..85236e3d 100644 --- a/reflex-dom-core/src/Reflex/Dom/Old.hs +++ b/reflex-dom-core/src/Reflex/Dom/Old.hs @@ -6,44 +6,45 @@ {-# LANGUAGE Rank2Types #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} +{-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} {-# LANGUAGE LambdaCase #-} #ifdef USE_TEMPLATE_HASKELL {-# LANGUAGE TemplateHaskell #-} #endif -{-# LANGUAGE TypeOperators #-} + module Reflex.Dom.Old - ( MonadWidget - , El - , ElConfig (..) - , elConfig_namespace - , elConfig_attributes - , _el_clicked - , _el_element - , _el_events - , addVoidAction - , AttributeMap - , Attributes (..) - , buildElement - , buildElementNS - , buildEmptyElement - , buildEmptyElementNS - , elDynHtml' - , elDynHtmlAttr' - , elStopPropagationNS - , elWith - , elWith' - , emptyElWith - , emptyElWith' - , namedNodeMapGetNames - , nodeClear - , onEventName - , schedulePostBuild - , text' - , unsafePlaceElement - , WidgetHost - , wrapElement - ) where + ( MonadWidget + , El + , ElConfig (..) + , elConfig_namespace + , elConfig_attributes + , _el_clicked + , _el_element + , _el_events + , addVoidAction + , AttributeMap + , Attributes (..) + , buildElement + , buildElementNS + , buildEmptyElement + , buildEmptyElementNS + , elDynHtml' + , elDynHtmlAttr' + , elStopPropagationNS + , elWith + , elWith' + , emptyElWith + , emptyElWith' + , namedNodeMapGetNames + , nodeClear + , onEventName + , schedulePostBuild + , text' + , unsafePlaceElement + , WidgetHost + , wrapElement + ) where import Control.Arrow (first) #ifdef USE_TEMPLATE_HASKELL diff --git a/reflex-dom-core/src/Reflex/Dom/Prerender.hs b/reflex-dom-core/src/Reflex/Dom/Prerender.hs index 9752276a..4070fdd3 100644 --- a/reflex-dom-core/src/Reflex/Dom/Prerender.hs +++ b/reflex-dom-core/src/Reflex/Dom/Prerender.hs @@ -17,11 +17,11 @@ -- | Render the first widget on the server, and the second on the client. module Reflex.Dom.Prerender - ( Prerender (..) - , prerender_ - , PrerenderClientConstraint - , PrerenderBaseConstraints - ) where + ( Prerender (..) + , prerender_ + , PrerenderClientConstraint + , PrerenderBaseConstraints + ) where import Control.Monad import Control.Monad.Fix @@ -33,7 +33,19 @@ import Data.Kind (Type) import Data.Semigroup.Commutative import Data.Text (Text) import Data.Void +import Data.IntMap.Strict (IntMap) +import qualified Data.IntMap.Strict as IntMap + +#if !MIN_VERSION_base(4,18,0) +import Data.Semigroup (Semigroup) +import Foreign.JavaScript.TH +#endif + import GHCJS.DOM.Types (MonadJSM) +import qualified GHCJS.DOM.Document as Document +import qualified GHCJS.DOM.Node as Node +import qualified GHCJS.DOM.Types as DOM + import Reflex hiding (askEvents) import Reflex.Dom.Builder.Class import Reflex.Dom.Builder.Hydratable @@ -41,12 +53,6 @@ import Reflex.Dom.Builder.Immediate import Reflex.Dom.Builder.InputDisabled import Reflex.Dom.Builder.Static import Reflex.Host.Class -import Data.IntMap.Strict (IntMap) -import qualified Data.IntMap.Strict as IntMap - -import qualified GHCJS.DOM.Document as Document -import qualified GHCJS.DOM.Node as Node -import qualified GHCJS.DOM.Types as DOM type PrerenderClientConstraint t m = ( DomBuilder t m diff --git a/reflex-dom-core/src/Reflex/Dom/WebSocket.hs b/reflex-dom-core/src/Reflex/Dom/WebSocket.hs index 005218a5..d8800bd2 100644 --- a/reflex-dom-core/src/Reflex/Dom/WebSocket.hs +++ b/reflex-dom-core/src/Reflex/Dom/WebSocket.hs @@ -8,6 +8,9 @@ {-# LANGUAGE ForeignFunctionInterface #-} {-# LANGUAGE GADTs #-} {-# LANGUAGE GeneralizedNewtypeDeriving #-} +#ifdef __GHCJS__ +{-# LANGUAGE JavaScriptFFI #-} +#endif {-# LANGUAGE LambdaCase #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE NoMonomorphismRestriction #-} @@ -29,17 +32,15 @@ module Reflex.Dom.WebSocket import Prelude hiding (all, concat, concatMap, div, mapM, mapM_, sequence, span) -import Reflex.Class -import Reflex.Dom.WebSocket.Foreign -import Reflex.PerformEvent.Class -import Reflex.PostBuild.Class -import Reflex.TriggerEvent.Class - import Control.Concurrent import Control.Concurrent.STM import Control.Exception import Control.Lens +#if MIN_VERSION_base(4,18,0) import Control.Monad hiding (forM, mapM, mapM_, sequence) +#else +import Control.Monad hiding (forM, forM_, mapM, mapM_, sequence) +#endif import Control.Monad.IO.Class import Data.Aeson import Data.ByteString (ByteString) @@ -56,6 +57,16 @@ import GHCJS.DOM.WebSocket (getReadyState) import GHCJS.Marshal import qualified Language.Javascript.JSaddle.Monad as JS (catch) +#if !MIN_VERSION_base(4,18,0) +import Control.Monad.State +#endif + +import Reflex.Class +import Reflex.Dom.WebSocket.Foreign +import Reflex.PerformEvent.Class +import Reflex.PostBuild.Class +import Reflex.TriggerEvent.Class + data WebSocketConfig t a = WebSocketConfig { _webSocketConfig_send :: Event t [a] , _webSocketConfig_close :: Event t (Word, Text) diff --git a/reflex-dom-core/src/Reflex/Dom/WebSocket/Foreign.hs b/reflex-dom-core/src/Reflex/Dom/WebSocket/Foreign.hs index 1ad06a2a..753e6c13 100644 --- a/reflex-dom-core/src/Reflex/Dom/WebSocket/Foreign.hs +++ b/reflex-dom-core/src/Reflex/Dom/WebSocket/Foreign.hs @@ -1,8 +1,10 @@ {-# LANGUAGE CPP #-} #ifdef ghcjs_HOST_OS {-# LANGUAGE ForeignFunctionInterface #-} +#ifdef __GHCJS__ {-# LANGUAGE JavaScriptFFI #-} #endif +#endif {-# LANGUAGE LambdaCase #-} module Reflex.Dom.WebSocket.Foreign diff --git a/reflex-dom-core/src/Reflex/Dom/WebSocket/Query.hs b/reflex-dom-core/src/Reflex/Dom/WebSocket/Query.hs index 8e66d637..772b7016 100644 --- a/reflex-dom-core/src/Reflex/Dom/WebSocket/Query.hs +++ b/reflex-dom-core/src/Reflex/Dom/WebSocket/Query.hs @@ -1,6 +1,10 @@ {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE RecursiveDo #-} -module Reflex.Dom.WebSocket.Query (cropQueryT, runWebSocketQuery) where + +module Reflex.Dom.WebSocket.Query + ( cropQueryT + , runWebSocketQuery + ) where import Data.Default import Control.Monad.Fix diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs index 2322d6b1..8203847b 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs @@ -1,4 +1,5 @@ {-# LANGUAGE ConstraintKinds #-} +{-# LANGUAGE CPP #-} {-# LANGUAGE DataKinds #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE FlexibleInstances #-} @@ -9,6 +10,7 @@ {-# LANGUAGE RecursiveDo #-} {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} + module Reflex.Dom.Widget.Basic ( -- * Displaying Values @@ -60,16 +62,6 @@ module Reflex.Dom.Widget.Basic , partitionMapBySetLT ) where -import Reflex.Adjustable.Class -import Reflex.Class -import Reflex.Collection -import Reflex.Dom.Builder.Class -import Reflex.Dom.Class -import Reflex.Dynamic -import Reflex.Network -import Reflex.PostBuild.Class -import Reflex.Workflow - import Control.Lens hiding (children, element) import Control.Monad.Fix import Data.Align @@ -86,6 +78,16 @@ import Data.Text (Text) import qualified Data.Text as T import Data.These +import Reflex.Adjustable.Class +import Reflex.Class +import Reflex.Collection +import Reflex.Dom.Builder.Class +import Reflex.Dom.Class +import Reflex.Dynamic +import Reflex.Network +import Reflex.PostBuild.Class +import Reflex.Workflow + -- | Breaks the given Map into pieces based on the given Set. Each piece will contain only keys that are less than the key of the piece, and greater than or equal to the key of the piece with the next-smaller key. There will be one additional piece containing all keys from the original Map that are larger or equal to the largest key in the Set. -- Either k () is used instead of Maybe k so that the resulting map of pieces is sorted so that the additional piece has the largest key. -- No empty pieces will be included in the output. diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs index 2b031614..1331a15a 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Input.hs @@ -15,7 +15,11 @@ {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} {-# LANGUAGE UndecidableInstances #-} -module Reflex.Dom.Widget.Input (module Reflex.Dom.Widget.Input, def, (&), (.~)) where + +module Reflex.Dom.Widget.Input + ( module Reflex.Dom.Widget.Input + , def, (&), (.~) + ) where import Prelude @@ -35,10 +39,19 @@ import qualified Data.Map as Map import Data.Maybe import Data.Text (Text) import qualified Data.Text as T +import qualified Text.Read as T + +#if !MIN_VERSION_base(4,18,0) +import Data.Semigroup +#endif + +import qualified GHCJS.DOM.Event as Event +import qualified GHCJS.DOM.HTMLInputElement as Input import GHCJS.DOM.HTMLInputElement (HTMLInputElement) import GHCJS.DOM.HTMLTextAreaElement (HTMLTextAreaElement) import GHCJS.DOM.Types (File, uncheckedCastTo) import qualified GHCJS.DOM.Types as DOM (HTMLElement(..), EventTarget(..)) + import Reflex.Class import Reflex.Collection import Reflex.Dom.Builder.Class @@ -47,10 +60,6 @@ import Reflex.Dom.Class import Reflex.Dom.Widget.Basic import Reflex.Dynamic import Reflex.PostBuild.Class -import qualified Text.Read as T - -import qualified GHCJS.DOM.Event as Event -import qualified GHCJS.DOM.HTMLInputElement as Input {-# DEPRECATED TextInput, _textInput_element, TextInputConfig, textInput "Use 'inputElement' directly" #-} data TextInput t diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Lazy.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Lazy.hs index 39e5391d..d64ef30c 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Lazy.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Lazy.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} @@ -5,8 +6,22 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} + module Reflex.Dom.Widget.Lazy where +import Control.Monad.Fix +import Data.Fixed +import Data.Map (Map) +import qualified Data.Map as Map +import Data.Text (Text) +import qualified Data.Text as T +import GHCJS.DOM.Element +import GHCJS.DOM.Types (MonadJSM) + +#if !MIN_VERSION_base(4,18,0) +import Data.Monoid +#endif + import Reflex.Class import Reflex.Collection import Reflex.Dom.Builder.Class @@ -17,15 +32,6 @@ import Reflex.Dynamic import Reflex.PerformEvent.Class import Reflex.PostBuild.Class -import Control.Monad.Fix -import Data.Fixed -import Data.Map (Map) -import qualified Data.Map as Map -import Data.Text (Text) -import qualified Data.Text as T -import GHCJS.DOM.Element -import GHCJS.DOM.Types (MonadJSM) - -- |A list view for long lists. Creates a scrollable element and only renders child row elements near the current scroll position. virtualListWithSelection :: forall t m k v. (DomBuilder t m, PostBuild t m, MonadHold t m, PerformEvent t m, MonadJSM (Performable m), DomBuilderSpace m ~ GhcjsDomSpace, MonadFix m, Ord k, Eq v) => Dynamic t Int -- ^ The height of the visible region in pixels diff --git a/reflex-dom-core/src/Reflex/Dom/Widget/Resize.hs b/reflex-dom-core/src/Reflex/Dom/Widget/Resize.hs index a9c1e4e9..65b71930 100644 --- a/reflex-dom-core/src/Reflex/Dom/Widget/Resize.hs +++ b/reflex-dom-core/src/Reflex/Dom/Widget/Resize.hs @@ -1,3 +1,4 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE MultiParamTypeClasses #-} {-# LANGUAGE OverloadedStrings #-} @@ -5,17 +6,8 @@ {-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE TypeOperators #-} -module Reflex.Dom.Widget.Resize where -import Reflex.Class -import Reflex.Time -import Reflex.Dom.Builder.Class -import Reflex.Dom.Builder.Immediate -import Reflex.Dom.Class -import Reflex.Dom.Widget.Basic -import Reflex.PerformEvent.Class -import Reflex.PostBuild.Class -import Reflex.TriggerEvent.Class +module Reflex.Dom.Widget.Resize where import Control.Monad.Fix import Control.Monad.IO.Class @@ -30,6 +22,21 @@ import GHCJS.DOM.Types (MonadJSM, liftJSM, uncheckedCastTo, HTMLElement(..)) import GHCJS.DOM.HTMLElement (getOffsetWidth, getOffsetHeight) import qualified GHCJS.DOM.Types as DOM +#if !MIN_VERSION_base(4,18,0) +import Control.Monad +import Data.Monoid +#endif + +import Reflex.Class +import Reflex.Time +import Reflex.Dom.Builder.Class +import Reflex.Dom.Builder.Immediate +import Reflex.Dom.Class +import Reflex.Dom.Widget.Basic +import Reflex.PerformEvent.Class +import Reflex.PostBuild.Class +import Reflex.TriggerEvent.Class + -- | A widget that wraps the given widget in a div and fires an event when resized. -- Adapted from @github.com\/marcj\/css-element-queries@ -- diff --git a/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs b/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs index 2528f99d..09d476ad 100644 --- a/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs +++ b/reflex-dom-core/src/Reflex/Dom/Xhr/Foreign.hs @@ -1,11 +1,15 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleInstances #-} +#ifdef __GHCJS__ +{-# LANGUAGE JavaScriptFFI #-} +#endif {-# LANGUAGE OverloadedStrings #-} -module Reflex.Dom.Xhr.Foreign ( - XMLHttpRequest +module Reflex.Dom.Xhr.Foreign + ( XMLHttpRequest , XMLHttpRequestResponseType(..) , module Reflex.Dom.Xhr.Foreign -) where + ) where import Control.Exception (throwIO) import Control.Monad.IO.Class (MonadIO(..)) diff --git a/reflex-dom-core/src/Reflex/Dom/Xhr/FormData.hs b/reflex-dom-core/src/Reflex/Dom/Xhr/FormData.hs index 629188cf..556e0e64 100644 --- a/reflex-dom-core/src/Reflex/Dom/Xhr/FormData.hs +++ b/reflex-dom-core/src/Reflex/Dom/Xhr/FormData.hs @@ -1,12 +1,13 @@ +{-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} {-# LANGUAGE OverloadedStrings #-} + module Reflex.Dom.Xhr.FormData ( postForms , postForms' , FormValue (..) , fileToFormValue - ) - where + ) where import Control.Lens import Data.Default @@ -17,6 +18,11 @@ import qualified GHCJS.DOM.FormData as FD import GHCJS.DOM.File (getName) import GHCJS.DOM.Types (File, IsBlob) import Language.Javascript.JSaddle.Monad (MonadJSM, liftJSM) + +#if !MIN_VERSION_base(4,18,0) +import Foreign.JavaScript.TH +#endif + import Reflex import Reflex.Dom.Xhr diff --git a/reflex-dom-test-selenium/reflex-dom-test-selenium.cabal b/reflex-dom-test-selenium/reflex-dom-test-selenium.cabal index 5e1025e2..ac3825aa 100644 --- a/reflex-dom-test-selenium/reflex-dom-test-selenium.cabal +++ b/reflex-dom-test-selenium/reflex-dom-test-selenium.cabal @@ -1,41 +1,45 @@ cabal-version: 1.24 -Name: reflex-dom-test-selenium -Version: 0.0.0.1 -Synopsis: Testing framework for selenium tests -Description: -License: BSD3 -License-file: LICENSE -Author: Ryan Trinkle -Maintainer: ryan.trinkle@gmail.com -Stability: Experimental -Category: FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface -Build-type: Simple +name: reflex-dom-test-selenium +version: 0.0.0.1 +license: BSD3 +license-file: LICENSE +maintainer: ryan.trinkle@gmail.com +author: Ryan Trinkle +stability: Experimental +synopsis: Testing framework for selenium tests +category: + FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface + +build-type: Simple library - hs-source-dirs: src - build-depends: - async, - base >= 4.7 && < 4.22, - bytestring >= 0.10 && < 0.13, - chrome-test-utils, - exceptions, - hspec-core < 2.12, - hspec-webdriver >= 1.2.2, - http-types, - jsaddle >= 0.9.0.0 && < 0.10, - jsaddle-warp, - network, - process, - reflex-dom-core, - silently, - text >= 1.2 && < 2.2, - wai, - warp, - webdriver, - websockets + exposed-modules: Reflex.Dom.Test.Selenium + hs-source-dirs: src + default-language: Haskell98 + ghc-options: + -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans + -fspecialise-aggressively - exposed-modules: - Reflex.Dom.Test.Selenium + build-depends: + async, + base >= 4.7 && < 4.22, + bytestring >= 0.10 && < 0.13, + chrome-test-utils, + exceptions, + hspec-core < 2.12, + hspec-webdriver >= 1.2.2, + http-types, + jsaddle >= 0.9.0.0 && < 0.10, + jsaddle-warp, + network, + process, + reflex-dom-core, + silently, + text >= 1.2 && < 2.2, + wai, + warp, + webdriver, + websockets - default-language: Haskell98 - ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively + if (!os(linux) || !arch(x86_64)) + buildable: False diff --git a/reflex-dom/reflex-dom.cabal b/reflex-dom/reflex-dom.cabal index cf9f53ac..9a47be74 100644 --- a/reflex-dom/reflex-dom.cabal +++ b/reflex-dom/reflex-dom.cabal @@ -1,209 +1,225 @@ -cabal-version: 1.24 -Name: reflex-dom -Version: 0.6.3.4 -Synopsis: Functional Reactive Web Apps with Reflex -Description: - Web applications without callbacks or side-effects. - Reflex-DOM brings the power of functional reactive programming (FRP) to the web. - Build HTML and other Document Object Model (DOM) data with a pure functional interface. - . - Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: . - . - The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the - correct set of dependencies for each target platform (GHCJS, WebKitGTK, WASM, mobile, etc.). - Libraries should depend on @reflex-dom-core@ and executables will usually depend on @reflex-dom@. - All of @reflex-dom-core@'s modules are re-exported by @reflex-dom@. - . - For Hackage documentation, please see: . -License: BSD3 -License-file: LICENSE -Author: Ryan Trinkle -Maintainer: ryan.trinkle@gmail.com -Stability: Experimental -Category: FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface -Build-type: Simple +cabal-version: 1.24 +name: reflex-dom +version: 0.6.3.4 +license: BSD3 +license-file: LICENSE +maintainer: ryan.trinkle@gmail.com +author: Ryan Trinkle +stability: Experimental +synopsis: Functional Reactive Web Apps with Reflex +description: + Web applications without callbacks or side-effects. + Reflex-DOM brings the power of functional reactive programming (FRP) to the web. + Build HTML and other Document Object Model (DOM) data with a pure functional interface. + . + Reflex-DOM is a Functional Reactive web framework based on the Reflex FRP engine: . + . + The @reflex-dom@ package is a small wrapper around the @reflex-dom-core@ package. It pulls in the + correct set of dependencies for each target platform (GHCJS, WebKitGTK, WASM, mobile, etc.). + Libraries should depend on @reflex-dom-core@ and executables will usually depend on @reflex-dom@. + All of @reflex-dom-core@'s modules are re-exported by @reflex-dom@. + . + For Hackage documentation, please see: . + +category: + FRP, Web, GUI, HTML, Javascript, Reactive, Reactivity, User Interfaces, User-interface + +build-type: Simple extra-source-files: - java/org/reflexfrp/reflexdom/MainWidget.java - ChangeLog.md + java/org/reflexfrp/reflexdom/MainWidget.java + ChangeLog.md + +source-repository head + type: git + location: https://github.com/reflex-frp/reflex-dom + subdir: reflex-dom flag use-warp - description: Use jsaddle-warp server - default: False - manual: True + description: Use jsaddle-warp server + default: False + manual: True flag webkit2gtk - description: Use WebKit2 version of WebKitGTK. - default: True - -flag use-reflex-optimizer - description: Use the GHC plugin Reflex.Optimizer on some of the modules in the package. This is still experimental. - default: False - manual: True + description: Use WebKit2 version of WebKitGTK. + default: True flag expose-all-unfoldings - description: Build the library with -fexpose-all-unfoldings which can help client code specialize better - default: False - manual: True + description: + Build the library with -fexpose-all-unfoldings which can help client code specialize better + + default: False + manual: True flag build-examples - description: Build the executables in ./examples - default: False - manual: True + description: Build the executables in ./examples + default: False + manual: True library - hs-source-dirs: src - if os(android) - hs-source-dirs: src-android - other-modules: Reflex.Dom.Android.MainWidget + exposed-modules: + Reflex.Dom + Reflex.Dom.Internal + Reflex.Dom.Location.Platform + + reexported-modules: + Foreign.JavaScript.Orphans, + Foreign.JavaScript.TH, + Foreign.JavaScript.Utils, + Reflex.Dom.Builder.Class, + Reflex.Dom.Builder.Class.Events, + Reflex.Dom.Builder.Hydratable, + Reflex.Dom.Builder.Immediate, + Reflex.Dom.Builder.InputDisabled, + Reflex.Dom.Builder.Static, + Reflex.Dom.Class, + Reflex.Dom.Core, + Reflex.Dom.Location, + Reflex.Dom.Main, + Reflex.Dom.Modals.Class, + Reflex.Dom.Old, + Reflex.Dom.Prerender, + Reflex.Dom.Time, + Reflex.Dom.WebSocket, + Reflex.Dom.WebSocket.Query, + Reflex.Dom.Widget, + Reflex.Dom.Widget.Basic, + Reflex.Dom.Widget.Input, + Reflex.Dom.Widget.Lazy, + Reflex.Dom.Widget.Resize, + Reflex.Dom.Xhr, + Reflex.Dom.Xhr.FormData + + cc-options: -fPIC + hs-source-dirs: src + default-language: Haskell2010 + ghc-options: + -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fPIC + build-depends: - aeson >= 1.4 && < 2.3, - android-activity == 0.2.*, - data-default >= 0.7 && < 0.9, - jsaddle >= 0.9.6 && < 0.10 - c-sources: cbits/MainWidget.c - include-dirs: cbits/include - install-includes: MainWidget.h - cpp-options: -DANDROID - build-tools: hsc2hs - build-depends: - base >= 4.7 && < 4.22, - bytestring >= 0.10 && < 0.13, - reflex >= 0.8 && < 1, - reflex-dom-core >= 0.8.1.0 && <0.9, - text >= 1.2 && < 2.2 - if !impl(ghcjs) - if flag(use-warp) - build-depends: - jsaddle >= 0.9.6 && < 0.10, - jsaddle-warp >= 0.9.6 && < 0.10 - else - if os(osx) || os(ios) + base >= 4.7 && < 4.22, + bytestring >= 0.10 && < 0.13, + reflex >= 0.8 && < 1, + reflex-dom-core >= 0.6.1.0 && <0.9, + text >= 1.2 && < 2.2 + + if os(android) + build-tools: hsc2hs + cpp-options: -DANDROID + c-sources: cbits/MainWidget.c + hs-source-dirs: src-android + other-modules: Reflex.Dom.Android.MainWidget + include-dirs: cbits/include + install-includes: MainWidget.h build-depends: - data-default >= 0.7 && < 0.9, - jsaddle >= 0.9.6 && < 0.10, - jsaddle-wkwebview >= 0.9.6 && < 0.10 - else - if arch(wasm32) - build-depends: - jsaddle >= 0.9.6 && < 0.10, - jsaddle-wasm >= 0.1 && < 0.2 - else - if flag(webkit2gtk) && !os(android) + aeson >= 1.4 && < 2.3, + android-activity == 0.2.*, + data-default >= 0.7 && < 0.9, + jsaddle >= 0.9.6 && < 0.10 + + if !(impl(ghcjs >=0) || arch(javascript)) + if flag(use-warp) build-depends: - jsaddle-webkit2gtk >= 0.9.6 && < 0.10 - - exposed-modules: - Reflex.Dom - Reflex.Dom.Internal - Reflex.Dom.Location.Platform - reexported-modules: - Foreign.JavaScript.Orphans - , Foreign.JavaScript.TH - , Foreign.JavaScript.Utils - , Reflex.Dom.Builder.Class - , Reflex.Dom.Builder.Class.Events - , Reflex.Dom.Builder.Hydratable - , Reflex.Dom.Builder.Immediate - , Reflex.Dom.Builder.InputDisabled - , Reflex.Dom.Builder.Static - , Reflex.Dom.Class - , Reflex.Dom.Core - , Reflex.Dom.Location - , Reflex.Dom.Main - , Reflex.Dom.Modals.Class - , Reflex.Dom.Old - , Reflex.Dom.Prerender - , Reflex.Dom.Time - , Reflex.Dom.WebSocket - , Reflex.Dom.WebSocket.Query - , Reflex.Dom.Widget - , Reflex.Dom.Widget.Basic - , Reflex.Dom.Widget.Input - , Reflex.Dom.Widget.Lazy - , Reflex.Dom.Widget.Resize - , Reflex.Dom.Xhr - , Reflex.Dom.Xhr.FormData - ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fPIC - cc-options: -fPIC - if flag(expose-all-unfoldings) - ghc-options: -fexpose-all-unfoldings - if flag(use-reflex-optimizer) - ghc-options: -fplugin=Reflex.Optimizer - default-language: Haskell2010 + jsaddle >=0.9.6 && <0.10, + jsaddle-warp >=0.9.6 && <0.10 + + else + if (os(osx) || os(ios)) + build-depends: + data-default >=0.7 && <0.9, + jsaddle >=0.9.6 && <0.10, + jsaddle-wkwebview >=0.9.6 && <0.10 + + else + if arch(wasm32) + build-depends: + jsaddle >=0.9.6 && <0.10, + jsaddle-wasm >=0.1 && <0.2 + + else + if (flag(webkit2gtk) && !os(android)) + build-depends: jsaddle-webkit2gtk >=0.9.6 && <0.10 + + if flag(expose-all-unfoldings) + ghc-options: -fexpose-all-unfoldings executable sortableList - build-depends: base - , containers - , dependent-map - , lens - , mtl - , patch - , random - , reflex - , reflex-dom - , text - , time - , transformers - hs-source-dirs: examples - main-is: sortableList.hs - ghc-options: -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans -fspecialise-aggressively - if !flag(build-examples) - buildable: False - if flag(expose-all-unfoldings) - ghc-options: -fexpose-all-unfoldings - if flag(use-reflex-optimizer) - ghc-options: -fplugin=Reflex.Optimizer - default-language: Haskell2010 - if arch(wasm32) - ghc-options: -no-hs-main -optl-mexec-model=reactor "-optl-Wl,--export=hs_start" + main-is: sortableList.hs + hs-source-dirs: examples + default-language: Haskell2010 + ghc-options: + -Wall -fwarn-tabs -funbox-strict-fields -O2 -ferror-spans + -fspecialise-aggressively + + build-depends: + base + , containers + , dependent-map + , lens + , mtl + , patch + , random + , reflex + , reflex-dom + , text + , time + , transformers + + if !flag(build-examples) + buildable: False + + if flag(expose-all-unfoldings) + ghc-options: -fexpose-all-unfoldings + + if arch(wasm32) + ghc-options: -no-hs-main -optl-mexec-model=reactor "-optl-Wl,--export=hs_start" executable benchmark - build-depends: base - , containers - , dependent-map - , dependent-sum - , ghc-prim - , ghcjs-dom - , mtl - , prim-uniq - , random - , reflex - , reflex-dom - , text - , transformers - hs-source-dirs: . - main-is: benchmark.hs - ghc-options: -O2 -fspecialise-aggressively - if !impl(ghcjs) - buildable: False - default-language: Haskell2010 + main-is: benchmark.hs + hs-source-dirs: . + default-language: Haskell2010 + ghc-options: -O2 -fspecialise-aggressively + build-depends: + base + , containers + , dependent-map + , dependent-sum + , ghc-prim + , ghcjs-dom + , mtl + , prim-uniq + , random + , reflex + , reflex-dom + , text + , transformers + + if !impl(ghcjs) + buildable: False executable krausest - build-depends: base - , containers - , dependent-map - , dependent-sum - , ghc-prim - , ghcjs-dom - , mtl - , prim-uniq - , random - , reflex - , reflex-dom - , text - , transformers - , vector - hs-source-dirs: benchmarks - main-is: krausest.hs - ghc-options: -O2 -fspecialise-aggressively - if impl(ghcjs) - ghcjs-options: -dedupe - cpp-options: -DGHCJS_BROWSER -DGHCJS_GC_INTERVAL=60000 - else - buildable: False - default-language: Haskell2010 + main-is: krausest.hs + hs-source-dirs: benchmarks + default-language: Haskell2010 + ghc-options: -O2 -fspecialise-aggressively + build-depends: + base + , containers + , dependent-map + , dependent-sum + , ghc-prim + , ghcjs-dom + , mtl + , prim-uniq + , random + , reflex + , reflex-dom + , text + , transformers + , vector -source-repository head - type: git - location: https://github.com/reflex-frp/reflex-dom - subdir: reflex-dom + if impl(ghcjs) + cpp-options: -DGHCJS_BROWSER -DGHCJS_GC_INTERVAL=60000 + ghcjs-options: -dedupe + + else + buildable: False diff --git a/reflex-dom/src/Reflex/Dom.hs b/reflex-dom/src/Reflex/Dom.hs index aad89735..8d86e316 100644 --- a/reflex-dom/src/Reflex/Dom.hs +++ b/reflex-dom/src/Reflex/Dom.hs @@ -5,7 +5,9 @@ module Reflex.Dom (module X) where import Foreign.JavaScript.Orphans () -import Reflex.Dom.Core as X hiding (mainWidget, mainWidgetInElementById, mainWidgetWithCss, - mainWidgetWithHead, mainWidgetWithHead', runApp', - mainHydrationWidgetWithHead, mainHydrationWidgetWithHead') +import Reflex.Dom.Core as X hiding + ( mainWidget, mainWidgetInElementById, mainWidgetWithCss + , mainWidgetWithHead, mainWidgetWithHead', runApp' + , mainHydrationWidgetWithHead, mainHydrationWidgetWithHead' + ) import Reflex.Dom.Internal as X diff --git a/reflex-dom/src/Reflex/Dom/Internal.hs b/reflex-dom/src/Reflex/Dom/Internal.hs index e6fd915e..99af8a43 100644 --- a/reflex-dom/src/Reflex/Dom/Internal.hs +++ b/reflex-dom/src/Reflex/Dom/Internal.hs @@ -3,6 +3,7 @@ {-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE RankNTypes #-} {-# LANGUAGE TypeFamilies #-} + module Reflex.Dom.Internal ( module Main , run @@ -14,13 +15,15 @@ module Reflex.Dom.Internal import Data.ByteString (ByteString) import Data.Text (Text) import Reflex.Dom.Main as Main hiding - (mainWidget, mainWidgetWithHead, mainWidgetWithCss, - mainWidgetWithHead', mainWidgetInElementById, runApp', - mainHydrationWidgetWithHead, mainHydrationWidgetWithHead') + ( mainWidget, mainWidgetWithHead, mainWidgetWithCss + , mainWidgetWithHead', mainWidgetInElementById, runApp' + , mainHydrationWidgetWithHead, mainHydrationWidgetWithHead' + ) import qualified Reflex.Dom.Main as Main - (mainWidget, mainWidgetWithHead, mainWidgetWithCss, - mainWidgetWithHead', mainWidgetInElementById, runApp', - mainHydrationWidgetWithHead, mainHydrationWidgetWithHead') + ( mainWidget, mainWidgetWithHead, mainWidgetWithCss + , mainWidgetWithHead', mainWidgetInElementById, runApp' + , mainHydrationWidgetWithHead, mainHydrationWidgetWithHead' + ) #if defined(ghcjs_HOST_OS) run :: a -> a diff --git a/reflex-dom/src/Reflex/Dom/Location/Platform.hs b/reflex-dom/src/Reflex/Dom/Location/Platform.hs index 220111ec..10c1edc1 100644 --- a/reflex-dom/src/Reflex/Dom/Location/Platform.hs +++ b/reflex-dom/src/Reflex/Dom/Location/Platform.hs @@ -1,5 +1,6 @@ {-# LANGUAGE CPP #-} {-# LANGUAGE FlexibleContexts #-} + #if defined(ANDROID) module Reflex.Dom.Location.Platform where