WebSharper 4.4
This is a major release for WebSharper 4.
Templates for .NET Core SDK: dotnet new -i WebSharper.Templates::4.4.0.255
Templates for Visual Studio 2017: http://websharper.com/installers/WebSharper.4.4.0.255.vsix
Features
- #641, #970: Add support for Web Workers.
- Add the
Worker
API toWebSharper.JavaScript
. - Add a set of special constructors for
Worker
which takes a function as argument. The compiler automatically compiles this function into a minimal bundle script and compiles the constructor call to reference this script by URL. See the documentation for more details. - Add a new compiler setting
scriptBaseUrl
which determines the base URL under which the worker scripts are located. The full URL is<scriptBaseUrl>/<assemblyname>/<assemblyname>.<scriptname>.js
, where<scriptname>
isworker
unless specified in the constructor call.
- Add the
- #807: Merge the class
WebSharper.JavaScript.JS
from the assemblyWebSharper.JavaScript
with the module of the same name from the assemblyWebSharper.Main
. This mean that all uses ofJSModule
in C# must be replaced withJS
. - #939: Add JavaScript Promises support. This includes:
- Add a proxy for the
Promise<'T>
class. - Add a
Promise
module with functionsAsAysnc
,OfAsync
,AsTask
andOfTask
.
TheAs*
functions handle rejected promises as follows: if the rejection value is anError
, then it is used directly as the exception raised from the Async / Task. Otherwise, it is wrapped as theReason
property of aNonStandardPromiseRejectionException
. - Add the above functions as extension methods to their respective relevant classes.
- Add a
promise
computation expression.
- Add a proxy for the
- #975: Drop the
[Serializable]
requirement for classes used in JSON serialization (RPC, Sitelets,WebSharper.Json
). - #976: Allow Bundle projects to reference other Bundle projects that have an EntryPoint.
- #979: Change signature of
Router.Create
to parse to option. - #980: Sitelets: add
Content.FromContent(Content<obj>)
to convert an F# content into a C# content. - #981: Add
Sitelet.MapContent
.- For F#: module function
Sitelet.MapContent : (Async<Content<'T>> -> Async<Content<'T>>) -> Sitelet<'T> -> Sitelet<'T>
- For C#: extension method
Sitelet<obj> Sitelet<obj>.MapContent(Func<Task<Content>, Task<Content>>)
- For F#: module function
- #982: Make all exceptions inherit from the JavaScript
Error
type. This affects exceptions declared with the F# keywordexception
as well as classes inheriting fromSystem.Exception
. This makes it possible to perform runtime type tests (F#:?
, C#is
) againstSystem.Exception
.
Fixes
- #971: WIG: properly fail when trying to declare that a class implements a class, rather than inherits from it.
- #977: Give a better error if there is a conflict where two projects include a server-side compiled quotation from the exact same file and position.
- #978: Give a better error if a Bundle is missing a project reference.
- #983: Fix
dotnet build
on a C# project failing to find FSharp.Core. - WebSharper.Testing: reference QUnit via
https
. - #987: Change the assemblies
WebSharper.Compiler
,WebSharper.Compiler.CSharp
andWebSharper.Compiler.FSharp
to referenceFSharp.Core
4.4.1.0 rather than 4.5.0.0. This fixes assembly loading issues in the Roslyn analyzer.
As a consequence, we reduced the minimum dependency of the WebSharper.Compiler packages on FSharp.Core from >= 4.5.0 to >= 4.1.0.