on develop help sign in
Merge branch 'develop' into ts-deprecate-input
commitb9941d6debef58758d4f502203a41cf268cbe0a7 authorJohn Ericson <John.Ericson@Obsidian.Systems> dateThu 12 Dec 2019, 17:26 (7 years ago) parent8d98ac1d2c55a7
7 files changed+84−65
FAQ.md+31 default.nix−53 dep/reflex-platform/github.json+2−2 reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+3−1 reflex-dom/ChangeLog.md+6 reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java+6 release.nix+36−9
FAQ.mdnew file+31
@@ -0,0 +1,31 @@
1+# Frequently Asked Questions
2+
3+### How do I configure DOM events with flags like `preventDefault` and `stopPropagation`?
4+
5+Using `element`, a low-level DOM builder function. Its second argument, `ElementConfig`, has a `_elementConfig_eventSpec` field that can be modified using `addEventSpecFlags`. It takes a `Proxy` that specifies the `DomSpace`, an event name, and a callback which takes the event result and returns an event flag, which can enable behavior like `preventDefault` and `stopPropagation`.
6+
7+The type signature on `def` is needed because the fields of the `ElementConfig` can change the type of the `ElementConfig`. GHC can probably figure out the type of the resulting `ElementConfig`, but it doesn't know what the type of `def` was before the modifications, since it never gets used with that configuration.
8+
9+For example:
10+
11+```haskell
12+{-# LANGUAGE OverloadedStrings #-}
13+{-# LANGUAGE ScopedTypeVariables #-}
14+
15+import Control.Lens ((&), (%~), (.~))
16+import Data.Proxy
17+import Reflex.Dom
18+
19+main :: IO ()
20+main = mainWidget $ do
21+ (click, ()) <- linkPreventDefault $ text "reflex-frp"
22+ display =<< count click
23+
24+linkPreventDefault :: forall t m a. DomBuilder t m => m a -> m (Event t (), a)
25+linkPreventDefault c = do
26+ let cfg = (def :: ElementConfig EventResult t (DomBuilderSpace m))
27+ & elementConfig_initialAttributes .~ ("href" =: "https://reflex-frp.org")
28+ & elementConfig_eventSpec %~ addEventSpecFlags (Proxy :: Proxy (DomBuilderSpace m)) Click (const preventDefault)
29+ (link, a) <- element "a" cfg c
30+ return (domEvent Click link, a)
31+```
default.nixdeleted−53
@@ -1,53 +0,0 @@
1−haskellPackages: let
2− pkgs = haskellPackages.callPackage ({ pkgs }: pkgs) {};
3− inherit (pkgs) stdenv;
4− haskellLib = pkgs.haskell.lib;
5−in {
6− reflex-dom-core = let
7− inherit (haskellPackages) ghc;
8− noGcTest = stdenv.hostPlatform.system != "x86_64-linux"
9− || stdenv.hostPlatform != stdenv.buildPlatform
10− || (ghc.isGhcjs or false);
11− in haskellLib.overrideCabal
12− (haskellPackages.callCabal2nix "reflex-dom-core" ./reflex-dom-core { })
13− (drv: {
14− #TODO: Get hlint working for cross-compilation
15− doCheck = stdenv.hostPlatform == stdenv.buildPlatform && !(ghc.isGhcjs or false);
16−
17− # The headless browser run as part of the tests will exit without this
18− preBuild = ''
19− export HOME="$PWD"
20− '';
21−
22− # Show some output while running tests, so we might notice what's wrong
23− testTarget = "--show-details=streaming";
24−
25− testHaskellDepends = with haskellPackages; (drv.testHaskellDepends or []) ++ stdenv.lib.optionals (!noGcTest) [
26− temporary
27− jsaddle-warp
28− process
29− chrome-test-utils
30− ];
31−
32− testSystemDepends = with pkgs; (drv.testSystemDepends or []) ++ [
33− selenium-server-standalone which
34− ] ++ stdenv.lib.optionals (!noGcTest) [
35− chromium
36− pkgs.iproute
37− ];
38− } // stdenv.lib.optionalAttrs (!noGcTest) {
39− # The headless browser run as part of gc tests would hang/crash without this
40− preCheck = ''
41− export FONTCONFIG_PATH=${pkgs.fontconfig.out}/etc/fonts
42− '';
43− });
44− reflex-dom = haskellLib.overrideCabal
45− (haskellPackages.callCabal2nix "reflex-dom" ./reflex-dom { })
46− (drv: {
47− # Hack until https://github.com/NixOS/cabal2nix/pull/432 lands
48− libraryHaskellDepends = (drv.libraryHaskellDepends or []) ++ stdenv.lib.optionals (with stdenv.hostPlatform; isAndroid && is32bit) [
49− haskellPackages.android-activity
50− ];
51− });
52− chrome-test-utils = haskellPackages.callCabal2nix "chrome-test-utils" ./chrome-test-utils {};
53−}
dep/reflex-platform/github.json+2−2
@@ -2,6 +2,6 @@
22 "owner": "reflex-frp",
33 "repo": "reflex-platform",
44 "branch": "develop",
5− "rev": "338fc907e37d70e6469c529456f33221fb05ca1f",
6− "sha256": "08gfhpp0pkvvi1wnlpcn6wmpzdjvy5z7dy1h66gp2w8b5cx8hx5h"
5+ "rev": "e7b76dd552a10916c7d8702c11292dac4f4299ea",
6+ "sha256": "0s1183arrwldcs50qhzgnv94v24n9bgq6dfq64wp0a3q2nzyvgwh"
77}
reflex-dom-core/src/Reflex/Dom/Widget/Basic.hs+3−1
@@ -146,7 +146,9 @@ button t = do
146146
147147--TODO: Should this be renamed to 'widgetView' for consistency with 'widgetHold'?
148148-- | Given a Dynamic of widget-creating actions, create a widget that is recreated whenever the Dynamic updates.
149−-- The returned Event of widget results occurs when the Dynamic does.
149+-- The returned Event occurs whenever the child widget is updated, which is
150+-- at post-build in addition to the times at which the input Dynamic is
151+-- updated, and its value is the result of running the widget.
150152-- Note: Often, the type @a@ is an 'Event', in which case the return value is an Event-of-Events that would typically be flattened (via 'switchHold').
151153dyn :: (Adjustable t m, NotReady t m, PostBuild t m) => Dynamic t (m a) -> m (Event t a)
152154dyn = networkView
reflex-dom/ChangeLog.md+6
@@ -1,5 +1,11 @@
11# Revision history for reflex-dom
22
3+## Unreleased
4+* On Android, enable propting the user for geolocation
5+ permissions on demand by default. See
6+ https://developer.android.com/reference/android/webkit/WebChromeClient.html#onGeolocationPermissionsShowPrompt(java.lang.String,%20android.webkit.GeolocationPermissions.Callback)
7+ for details.
8+
39## 0.5.1
410
511* The default jsaddle backend on macOS when built from nix
reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java+6
@@ -8,6 +8,7 @@ import android.util.Log;
88import android.view.ViewGroup.LayoutParams;
99import android.view.Window;
1010import android.webkit.CookieManager;
11+import android.webkit.GeolocationPermissions;
1112import android.webkit.JavascriptInterface;
1213import android.webkit.MimeTypeMap;
1314import android.webkit.PermissionRequest;
@@ -122,6 +123,11 @@ public class MainWidget {
122123 public Bitmap getDefaultVideoPoster() {
123124 return Bitmap.createBitmap(10, 10, Bitmap.Config.ARGB_8888);
124125 }
126+
127+ @Override
128+ public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions.Callback callback) {
129+ callback.invoke(origin, true, false);
130+ }
125131 });
126132
127133 wv.addJavascriptInterface(new JSaddleCallbacks(jsaddleCallbacks), "jsaddle");
release.nix+36−9
@@ -17,16 +17,43 @@ let
1717 ] ++ lib.optionals (reflex-platform.iosSupport) [
1818 "ghcIosAarch64"
1919 ];
20− hsPkgs = lib.genAttrs compilers (ghc: let
21− ghc' = reflex-platform.${ghc}.override {
22− overrides = self: super: import ./. self;
23− };
24− in {
25− inherit (ghc') reflex-dom reflex-dom-core;
20+ variations = map (v: "reflex-dom" + v) [
21+ ""
22+ ];
23+ compilerPkgs = lib.genAttrs compilers (ghc: let
24+ variationPkgs = lib.genAttrs variations (variation: let
25+ reflex-platform = reflex-platform-fun {
26+ inherit system;
27+ haskellOverlays = [
28+ # Use this package's source for reflex
29+ (self: super: {
30+ _dep = super._dep // {
31+ reflex-dom = builtins.filterSource (path: type: !(builtins.elem (baseNameOf path) [
32+ "release.nix"
33+ ".git"
34+ "dist"
35+ ])) ./.;
36+ };
37+ })
38+ ];
39+ };
40+ all = {
41+ inherit (reflex-platform.${ghc})
42+ reflex-dom-core
43+ reflex-dom
44+ ;
45+ };
46+ in all // {
47+ cache = reflex-platform.pinBuildInputs "reflex-${system}-${ghc}-${variation}"
48+ (builtins.attrValues all);
49+ });
50+ in variationPkgs // {
51+ cache = reflex-platform.pinBuildInputs "reflex-${system}-${ghc}"
52+ (map (a: a.cache) (builtins.attrValues variationPkgs));
2653 });
27− in hsPkgs // {
28− cache = reflex-platform.pinBuildInputs "reflex-dom-${system}"
29− (lib.concatLists (map builtins.attrValues (builtins.attrValues hsPkgs)));
54+ in compilerPkgs // {
55+ cache = reflex-platform.pinBuildInputs "reflex-${system}"
56+ (map (a: a.cache) (builtins.attrValues compilerPkgs));
3057 });
3158
3259 metaCache = native-reflex-platform.pinBuildInputs "reflex-dom-everywhere"