From e7704685e370ed33332bb2f63bec8f71a8899a69 Mon Sep 17 00:00:00 2001 From: Eugene Tolmachev Date: Sat, 8 Dec 2018 22:08:41 -0500 Subject: [PATCH 1/5] retargeted to use elmish 3.0 --- .gitignore | 1 + .paket/Paket.Restore.targets | 107 +++++++++++++++++++++++++++++------ RELEASE_NOTES.md | 4 ++ global.json | 2 +- paket.dependencies | 5 +- paket.lock | 10 ++-- src/common.fs | 2 - src/paket.references | 3 +- src/react-native.fs | 2 - src/react.fs | 7 +-- 10 files changed, 105 insertions(+), 38 deletions(-) diff --git a/.gitignore b/.gitignore index bba847b..8110b70 100644 --- a/.gitignore +++ b/.gitignore @@ -34,3 +34,4 @@ Directory.Build.props docs/output temp paket-files +.ionide diff --git a/.paket/Paket.Restore.targets b/.paket/Paket.Restore.targets index 7c61070..b4f593e 100644 --- a/.paket/Paket.Restore.targets +++ b/.paket/Paket.Restore.targets @@ -17,23 +17,43 @@ native /Library/Frameworks/Mono.framework/Commands/mono mono - - $(PaketToolsPath)paket - $(PaketRootPath)paket.exe - $(PaketToolsPath)paket.exe - $(PaketToolsPath)paket.exe - $(PaketToolsPath)paket + + $(PaketRootPath)paket.bootstrapper.exe + $(PaketToolsPath)paket.bootstrapper.exe + $([System.IO.Path]::GetDirectoryName("$(PaketBootStrapperExePath)"))\ + + + + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + $(PaketToolsPath)paket.exe + $(_PaketBootStrapperExeDir)paket.exe + paket.exe + + + $(PaketRootPath)paket + $(PaketToolsPath)paket + $(PaketToolsPath)paket + + + $(PaketRootPath)paket.exe + $(PaketToolsPath)paket.exe + + + $(PaketBootStrapperExeDir)paket.exe + + + paket <_PaketExeExtension>$([System.IO.Path]::GetExtension("$(PaketExePath)")) dotnet "$(PaketExePath)" - "$(PaketExePath)" $(MonoPath) --runtime=v4.0.30319 "$(PaketExePath)" - "$(PaketExePath)" + "$(PaketExePath)" + - $(PaketRootPath)paket.bootstrapper.exe - $(PaketToolsPath)paket.bootstrapper.exe "$(PaketBootStrapperExePath)" $(MonoPath) --runtime=v4.0.30319 "$(PaketBootStrapperExePath)" @@ -151,15 +171,17 @@ + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',').Length) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[0]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[1]) $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[4]) - $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) + $([System.String]::Copy('%(PaketReferencesFileLines.Identity)').Split(',')[5]) %(PaketReferencesFileLinesInfo.PackageVersion) All - runtime + runtime + runtime true @@ -192,19 +214,27 @@ false + $(MSBuildVersion) + 15.8.0 <_NuspecFilesNewLocation Include="$(BaseIntermediateOutputPath)$(Configuration)\*.nuspec"/> + + $(MSBuildProjectDirectory)/$(MSBuildProjectFile) true - false - true + false + true + false + true + false + true $(BaseIntermediateOutputPath)$(Configuration) $(BaseIntermediateOutputPath) @@ -219,9 +249,52 @@ - - + + - = 4.5.2) - restriction: >= netstandard2.0 - Fable.Elmish (2.0) - Fable.Core (>= 2.0) - restriction: >= netstandard2.0 + Fable.Elmish (3.0.0-beta-2) + Fable.Core (>= 2.0.1) - restriction: >= netstandard2.0 Fable.PowerPack (>= 2.0.1) - restriction: >= netstandard2.0 FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 Fable.Import.Browser (1.3) - restriction: >= netstandard2.0 Fable.Core (>= 1.3.17) - restriction: >= netstandard1.6 - Fable.PowerPack (2.0.1) + Fable.PowerPack (2.0.2) Fable.Core (>= 2.0) - restriction: >= netstandard2.0 Fable.Import.Browser (>= 1.3) - restriction: >= netstandard2.0 FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 @@ -24,7 +24,7 @@ NUGET Fable.PowerPack (>= 1.3.2) - restriction: >= netstandard1.6 Fable.React (>= 1.2.2) - restriction: >= netstandard1.6 FSharp.Core (>= 4.2.3) - restriction: >= netstandard1.6 - FSharp.Core (4.5.2) - content: none, redirects: force + FSharp.Core (4.5.3) - content: none, redirects: force System.Collections (>= 4.0.11) - restriction: && (< net45) (>= netstandard1.6) (< netstandard2.0) System.Console (>= 4.0) - restriction: && (< net45) (>= netstandard1.6) (< netstandard2.0) System.Diagnostics.Debug (>= 4.0.11) - restriction: && (< net45) (>= netstandard1.6) (< netstandard2.0) diff --git a/src/common.fs b/src/common.fs index 80d0ff4..404e344 100644 --- a/src/common.fs +++ b/src/common.fs @@ -1,9 +1,7 @@ namespace Elmish.React -open System open Fable.Import.React open Fable.Helpers.React -open Fable.Core open Elmish type LazyProps<'model> = { diff --git a/src/paket.references b/src/paket.references index d665bb2..72f0b00 100644 --- a/src/paket.references +++ b/src/paket.references @@ -1,5 +1,4 @@ FSharp.Core Fable.Core -Fable.PowerPack Fable.React -Fable.Elmish +Fable.Elmish \ No newline at end of file diff --git a/src/react-native.fs b/src/react-native.fs index 59a9b31..471f591 100644 --- a/src/react-native.fs +++ b/src/react-native.fs @@ -1,6 +1,5 @@ namespace Elmish.ReactNative -open System open Fable.Import.React open Fable.Core open Elmish @@ -38,7 +37,6 @@ type AppRegistry = [] module Program = - open Fable.Core.JsInterop open Elmish.React open Components diff --git a/src/react.fs b/src/react.fs index 27b7f2d..8bdf6cd 100644 --- a/src/react.fs +++ b/src/react.fs @@ -1,17 +1,12 @@ namespace Elmish.React -open System -open Fable.Import.React -open Fable.Core -open Fable.Helpers.React - [] module Helpers = open Fable.Helpers.React.Props open Fable.Core.JsInterop /// `Ref` callback that sets the value of an input textbox after DOM element is created. - /// Can be used override input box value. + /// Can be used instead of `DefaultValue` and `Value` props to override input box value. let inline valueOrDefault value = Ref <| (fun e -> if e |> isNull |> not && !!e?value <> !!value then e?value <- !!value) From 38c00c3e484c69a9311eabb315cad23d708db211 Mon Sep 17 00:00:00 2001 From: Fredrik Eilertsen Date: Thu, 13 Dec 2018 07:55:01 +0100 Subject: [PATCH 2/5] Update README.md Dead link --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 41e20ff..e428403 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -Elmish-React: React extensions for [elmish](https://github.com/fable-compiler/elmish) applications. +Elmish-React: React extensions for [elmish](https://github.com/elmish/elmish) applications. ======= [![Windows Build](https://ci.appveyor.com/api/projects/status/vg3200aksdbvx5me?svg=true)](https://ci.appveyor.com/project/et1975/react) [![Mono/OSX build](https://travis-ci.org/elmish/react.svg?branch=master)](https://travis-ci.org/elmish/react) [![NuGet version](https://badge.fury.io/nu/react.svg)](https://badge.fury.io/nu/react) From 9cd6b7084fba255a56b2382cf0b49df420bba8bf Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Tue, 11 Dec 2018 11:56:27 +0100 Subject: [PATCH 3/5] Better semantic for names --- src/react.fs | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/src/react.fs b/src/react.fs index 8bdf6cd..44d37a2 100644 --- a/src/react.fs +++ b/src/react.fs @@ -17,7 +17,7 @@ module Program = open Fable.Import.Browser - let withReactUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = + let withReactBatchedUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = let mutable lastRequest = None let setState model dispatch = match lastRequest with @@ -32,7 +32,7 @@ module Program = { program with setState = setState } - let withReactUnoptimizedUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = + let withReactSynchronousUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = let setState model dispatch = Fable.Import.ReactDom.render( lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) program.view model dispatch, @@ -50,15 +50,25 @@ module Program = { program with setState = setState } - /// Setup rendering of root React component inside html element identified by placeholderId + /// Renders React root component inside html element identified by placeholderId. + /// Uses `requestAnimationFrame` to batch updates to prevent drops in frame rate. + /// NOTE: This may have unexpected effects in React controlled inputs, see https://github.com/elmish/react/issues/12 + let withReactBatched placeholderId (program:Elmish.Program<_,_,_,_>) = + Internal.withReactBatchedUsing lazyView2With placeholderId program + + /// Renders React root component inside html element identified by placeholderId. + /// New renders are triggered immediately after an update. + let withReactSynchronous placeholderId (program:Elmish.Program<_,_,_,_>) = + Internal.withReactSynchronousUsing lazyView2With placeholderId program + + [] let withReact placeholderId (program:Elmish.Program<_,_,_,_>) = - Internal.withReactUsing lazyView2With placeholderId program + Internal.withReactBatchedUsing lazyView2With placeholderId program - /// `withReact` uses `requestAnimationFrame` to optimize rendering in scenarios with updates at a higher rate than 60FPS, but this makes the cursor jump to the end in `input` elements. - /// This function works around the glitch if you don't need the optimization (see https://github.com/elmish/react/issues/12). + [] let withReactUnoptimized placeholderId (program:Elmish.Program<_,_,_,_>) = - Internal.withReactUnoptimizedUsing lazyView2With placeholderId program + Internal.withReactSynchronousUsing lazyView2With placeholderId program - /// Setup rendering of root React component inside html element identified by placeholderId using React.hydrate + /// Renders React root component inside html element identified by placeholderId using `React.hydrate`. let withReactHydrate placeholderId (program:Elmish.Program<_,_,_,_>) = Internal.withReactHydrateUsing lazyView2With placeholderId program From c6c15b5311dc4e6d75fa9fbf1b5654def0003f8c Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Thu, 17 Jan 2019 15:46:02 +0100 Subject: [PATCH 4/5] Fix `withReactNative` for Fable 2 --- src/react-native.fs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/react-native.fs b/src/react-native.fs index 471f591..c3c87c9 100644 --- a/src/react-native.fs +++ b/src/react-native.fs @@ -42,7 +42,7 @@ module Program = /// Setup rendering of root ReactNative component let withReactNative appKey (program:Program<_,_,_,_>) = - AppRegistry.registerComponent(appKey, fun () -> unbox typeof) + AppRegistry.registerComponent(appKey, fun () -> unbox JsInterop.jsConstructor) let render m d = match appState with | Some state -> From 6b0ea1fd1b0750e3d77f8c8591dde5c4e9aaae62 Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Wed, 23 Jan 2019 17:02:44 +0100 Subject: [PATCH 5/5] Compatibility with latest Fable.React --- paket.dependencies | 2 +- paket.lock | 4 ++-- src/Fable.Elmish.React.fsproj | 3 +++ src/common.fs | 3 +-- src/paket.references | 2 +- src/react-native.fs | 4 ++-- src/react.fs | 10 +++++----- 7 files changed, 15 insertions(+), 13 deletions(-) diff --git a/paket.dependencies b/paket.dependencies index 5878691..ec2256c 100644 --- a/paket.dependencies +++ b/paket.dependencies @@ -2,7 +2,7 @@ source https://nuget.org/api/v2 storage: none generate_load_scripts: true nuget FSharp.Core redirects:force, content:none -nuget Fable.Core +nuget Fable.Core prerelease nuget Fable.React nuget Fable.React.Native prerelease nuget Fable.Elmish 3.0.0-beta-2 beta diff --git a/paket.lock b/paket.lock index e055d42..137a53d 100644 --- a/paket.lock +++ b/paket.lock @@ -2,7 +2,7 @@ GENERATE-LOAD-SCRIPTS: ON STORAGE: NONE NUGET remote: https://www.nuget.org/api/v2 - Fable.Core (2.0.1) + Fable.Core (2.1.0-alpha-002) FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 Fable.Elmish (3.0.0-beta-2) Fable.Core (>= 2.0.1) - restriction: >= netstandard2.0 @@ -10,7 +10,7 @@ NUGET FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 Fable.Import.Browser (1.3) - restriction: >= netstandard2.0 Fable.Core (>= 1.3.17) - restriction: >= netstandard1.6 - Fable.PowerPack (2.0.2) + Fable.PowerPack (2.0.2) - restriction: >= netstandard1.6 Fable.Core (>= 2.0) - restriction: >= netstandard2.0 Fable.Import.Browser (>= 1.3) - restriction: >= netstandard2.0 FSharp.Core (>= 4.5.2) - restriction: >= netstandard2.0 diff --git a/src/Fable.Elmish.React.fsproj b/src/Fable.Elmish.React.fsproj index 9d33599..4cec691 100644 --- a/src/Fable.Elmish.React.fsproj +++ b/src/Fable.Elmish.React.fsproj @@ -10,5 +10,8 @@ + + + \ No newline at end of file diff --git a/src/common.fs b/src/common.fs index 404e344..5e84ed9 100644 --- a/src/common.fs +++ b/src/common.fs @@ -1,7 +1,6 @@ namespace Elmish.React -open Fable.Import.React -open Fable.Helpers.React +open Fable.React open Elmish type LazyProps<'model> = { diff --git a/src/paket.references b/src/paket.references index 72f0b00..3305d29 100644 --- a/src/paket.references +++ b/src/paket.references @@ -1,4 +1,4 @@ FSharp.Core Fable.Core -Fable.React +#Fable.React Fable.Elmish \ No newline at end of file diff --git a/src/react-native.fs b/src/react-native.fs index c3c87c9..f5adf00 100644 --- a/src/react-native.fs +++ b/src/react-native.fs @@ -1,6 +1,6 @@ namespace Elmish.ReactNative -open Fable.Import.React +open Fable.React open Fable.Core open Elmish @@ -32,7 +32,7 @@ module Components = [] type AppRegistry = - static member registerComponent(appKey:string, getComponentFunc:unit->ComponentClass<_>) : unit = + static member registerComponent(appKey:string, getComponentFunc:unit->ReactElementType<_>) : unit = failwith "JS only" [] diff --git a/src/react.fs b/src/react.fs index 44d37a2..305f316 100644 --- a/src/react.fs +++ b/src/react.fs @@ -2,7 +2,7 @@ namespace Elmish.React [] module Helpers = - open Fable.Helpers.React.Props + open Fable.React.Props open Fable.Core.JsInterop /// `Ref` callback that sets the value of an input textbox after DOM element is created. @@ -15,7 +15,7 @@ module Program = module Internal = - open Fable.Import.Browser + open Fable.Browser.Dom let withReactBatchedUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = let mutable lastRequest = None @@ -25,7 +25,7 @@ module Program = | _ -> () lastRequest <- Some (window.requestAnimationFrame (fun _ -> - Fable.Import.ReactDom.render( + Fable.ReactDom.render( lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) program.view model dispatch, document.getElementById(placeholderId) ))) @@ -34,7 +34,7 @@ module Program = let withReactSynchronousUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = let setState model dispatch = - Fable.Import.ReactDom.render( + Fable.ReactDom.render( lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) program.view model dispatch, document.getElementById(placeholderId) ) @@ -43,7 +43,7 @@ module Program = let withReactHydrateUsing lazyView2With placeholderId (program:Elmish.Program<_,_,_,_>) = let setState model dispatch = - Fable.Import.ReactDom.hydrate( + Fable.ReactDom.hydrate( lazyView2With (fun x y -> obj.ReferenceEquals(x,y)) program.view model dispatch, document.getElementById(placeholderId) )