-
Notifications
You must be signed in to change notification settings - Fork 550
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add WASM Support for Uno Platform (#1333)
Co-authored-by: Jérôme Laban <[email protected]> Co-authored-by: Geoffrey Huntley <[email protected]> Co-authored-by: Martin Zikmund <[email protected]>
- Loading branch information
1 parent
99356f9
commit b84f667
Showing
39 changed files
with
1,001 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
<linker> | ||
<assembly fullname="SkiaSharp" /> | ||
<assembly fullname="SkiaSharp.Views.UWP" /> | ||
<assembly fullname="SkiaSharpSample.Wasm" /> | ||
<assembly fullname="Uno.Foundation" /> | ||
<assembly fullname="System.Core"> | ||
<!-- This is required by Json.NET and any expression.Compile caller --> | ||
<type fullname="System.Linq.Expressions*" /> | ||
</assembly> | ||
</linker> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
using Microsoft.Extensions.Logging; | ||
using Uno.Extensions; | ||
using Uno.UI; | ||
using Windows.UI.Xaml; | ||
|
||
namespace SkiaSharpSample | ||
{ | ||
public class Program | ||
{ | ||
private static App _app; | ||
|
||
static int Main(string[] args) | ||
{ | ||
FeatureConfiguration.UIElement.AssignDOMXamlName = true; | ||
|
||
ConfigureFilters(LogExtensionPoint.AmbientLoggerFactory); | ||
|
||
Application.Start(_ => _app = new App()); | ||
|
||
return 0; | ||
} | ||
|
||
static void ConfigureFilters(ILoggerFactory factory) | ||
{ | ||
factory | ||
.WithFilter(new FilterLoggerSettings | ||
{ | ||
{ "Uno", LogLevel.Warning }, | ||
{ "Windows", LogLevel.Warning }, | ||
{ "nVentive.Umbrella", LogLevel.Warning }, | ||
{ "SkiaSharp", LogLevel.Warning }, | ||
|
||
// View Navigation related messages | ||
// { "nVentive.Umbrella.Views.Navigation", LogLevel.Debug }, | ||
// { "nVentive.Umbrella.Presentation.Light.ViewModelRegistry", LogLevel.Debug }, | ||
|
||
// All presentation related messages | ||
// { "nVentive.Umbrella.Presentation.Light", LogLevel.Debug }, | ||
|
||
// ViewModel related messages | ||
// { "nVentive.Umbrella.Presentation.Light.ViewModelBase", LogLevel.Debug }, | ||
|
||
// Dynamic properties related messages | ||
// { "nVentive.Umbrella.Presentation.Light.DynamicProperties", LogLevel.Debug }, | ||
|
||
// AVVM/AVP Related messages | ||
// { "nVentive.Umbrella.Presentation.Light.Extensions.AsyncValueViewModel", LogLevel.Debug }, | ||
// { "nVentive.Umbrella.Views.Controls.AsyncValuePresenter", LogLevel.Debug }, | ||
// { "nVentive.Umbrella.Views.Controls.IfDataContext", LogLevel.Debug }, | ||
|
||
// Layouter specific messages | ||
// { "Windows.UI.Xaml.Controls", LogLevel.Debug }, | ||
// { "Windows.UI.Xaml.Controls.Layouter", LogLevel.Debug }, | ||
// { "Windows.UI.Xaml.Controls.Panel", LogLevel.Debug }, | ||
|
||
// Binding related messages | ||
// { "Windows.UI.Xaml.Data", LogLevel.Debug }, | ||
// { "Windows.UI.Xaml.Data", LogLevel.Debug }, | ||
|
||
// Binder memory references tracking | ||
// { "ReferenceHolder", LogLevel.Debug }, | ||
|
||
// Web Queries related messages | ||
// gManager.SetLoggerLevel("nVentive.Umbrella.Web", LogLevel.Debug }, | ||
|
||
// Location service messages | ||
// { "nVentive.Umbrella.Services.Location", LogLevel.Debug }, | ||
|
||
// Map Component messages | ||
// { "nVentive.Umbrella.Components.Maps", LogLevel.Debug }, | ||
|
||
// ApplicationViewState | ||
// { "nVentive.Umbrella.Views.Services.ApplicationViewState.ApplicationViewStateService", LogLevel.Debug }, | ||
}) | ||
.AddConsole(LogLevel.Debug); | ||
} | ||
} | ||
} |
27 changes: 27 additions & 0 deletions
27
samples/Basic/Uno/SkiaSharpSample.Wasm/Properties/launchSettings.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{ | ||
"iisSettings": { | ||
"windowsAuthentication": false, | ||
"anonymousAuthentication": true, | ||
"iisExpress": { | ||
"applicationUrl": "http://localhost:63559/", | ||
"sslPort": 0 | ||
} | ||
}, | ||
"profiles": { | ||
"IIS Express": { | ||
"commandName": "IISExpress", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
} | ||
}, | ||
"SkiaSharpSample.Wasm": { | ||
"commandName": "Project", | ||
"launchBrowser": true, | ||
"environmentVariables": { | ||
"ASPNETCORE_ENVIRONMENT": "Development" | ||
}, | ||
"applicationUrl": "http://localhost:5000" | ||
} | ||
} | ||
} |
44 changes: 44 additions & 0 deletions
44
samples/Basic/Uno/SkiaSharpSample.Wasm/SkiaSharpSample.Wasm.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<Import Project="..\SkiaSharpSample.Shared\SkiaSharpSample.Shared.projitems" Label="Shared" /> | ||
<Import Project="..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props" Condition="Exists('..\..\..\..\output\SkiaSharp\nuget\build\wasm\SkiaSharp.props')" /> | ||
<PropertyGroup> | ||
<OutputType>Exe</OutputType> | ||
<TargetFramework>netstandard2.0</TargetFramework> | ||
<WasmHead>true</WasmHead> | ||
<DefineConstants>$(DefineConstants);__WASM__</DefineConstants> | ||
<LangVersion>8.0</LangVersion> | ||
<WasmShellILLinkerEnabled>true</WasmShellILLinkerEnabled> | ||
<WasmShellForceDisableWSL Condition="'$(OS)' != 'Unix' and ('$(CI)' == 'true' or '$(BUILD_BUILDID)' != '')">true</WasmShellForceDisableWSL> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Debug'"> | ||
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled> | ||
<DebugType>portable</DebugType> | ||
<DebugSymbols>true</DebugSymbols> | ||
<WasmShellMonoRuntimeExecutionMode>Interpreter</WasmShellMonoRuntimeExecutionMode> | ||
</PropertyGroup> | ||
<PropertyGroup Condition="'$(Configuration)'=='Release'"> | ||
<WasmShellMonoRuntimeExecutionMode>FullAOT</WasmShellMonoRuntimeExecutionMode> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Console" Version="1.1.1" /> | ||
<PackageReference Include="Microsoft.Extensions.Logging.Filter" Version="1.1.1" /> | ||
<PackageReference Include="Uno.UI" Version="2.4.4" /> | ||
</ItemGroup> | ||
<!-- workaround for https://github.com/unoplatform/Uno.Wasm.Bootstrap/issues/253 --> | ||
<ItemGroup Condition=" '$(WasmShellForceDisableWSL)' != 'true' "> | ||
<PackageReference Include="Uno.Wasm.Bootstrap" Version="1.4.0-dev.9" /> | ||
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" Version="1.4.0-dev.9" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<ProjectReference Include="..\..\..\..\binding\SkiaSharp\SkiaSharp.csproj" /> | ||
<ProjectReference Include="..\..\..\..\source\SkiaSharp.Views.Uno\SkiaSharp.Views.Uno.Wasm\SkiaSharp.Views.Uno.Wasm.csproj" /> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Content Include="Assets\**\*" /> | ||
<EmbeddedResource Include="WasmCSS\*.css" /> | ||
<EmbeddedResource Include="WasmScripts\*.js" /> | ||
<LinkerDescriptor Include="LinkerConfig.xml" /> | ||
</ItemGroup> | ||
<Import Project="..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets" Condition="Exists('..\..\..\..\output\SkiaSharp.Views.Uno\nuget\build\netstandard2.0\SkiaSharp.Views.Uno.targets')" /> | ||
</Project> |
Large diffs are not rendered by default.
Oops, something went wrong.
5 changes: 5 additions & 0 deletions
5
samples/Basic/Uno/SkiaSharpSample.Wasm/WasmScripts/AppManifest.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
var UnoAppManifest = { | ||
splashScreenImage: "Assets/SplashScreen.png", | ||
splashScreenColor: "#F8F8F8", | ||
displayName: "SkiaSharp for WebAssembly" | ||
} |
1 change: 1 addition & 0 deletions
1
samples/Basic/Uno/SkiaSharpSample.Wasm/WasmScripts/SkiaSharpSample.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<configuration> | ||
<system.web> | ||
<customErrors mode="Off"/> | ||
</system.web> | ||
|
||
<system.webServer> | ||
|
||
<!-- Disable compression as we're doing it throuh pre-compressed files --> | ||
<urlCompression doStaticCompression="false" doDynamicCompression="false" dynamicCompressionBeforeCache="false" /> | ||
|
||
<staticContent> | ||
<remove fileExtension=".dll" /> | ||
<remove fileExtension=".wasm" /> | ||
<remove fileExtension=".woff" /> | ||
<remove fileExtension=".woff2" /> | ||
<mimeMap fileExtension=".wasm" mimeType="application/wasm" /> | ||
<mimeMap fileExtension=".clr" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".pdb" mimeType="application/octet-stream" /> | ||
<mimeMap fileExtension=".woff" mimeType="application/font-woff" /> | ||
<mimeMap fileExtension=".woff2" mimeType="application/font-woff" /> | ||
|
||
<!-- Required for PWAs --> | ||
<mimeMap fileExtension=".json" mimeType="application/octet-stream" /> | ||
</staticContent> | ||
|
||
<rewrite> | ||
<rules> | ||
<rule name="Lookup for pre-compressed brotli file" stopProcessing="true"> | ||
<match url="(.*)$"/> | ||
<conditions> | ||
<!-- Match brotli requests --> | ||
<add input="{HTTP_ACCEPT_ENCODING}" pattern="br" /> | ||
|
||
<!-- Match all but pre-compressed files --> | ||
<add input="{REQUEST_URI}" pattern="^(?!/_compressed_br/)(.*)$" /> | ||
|
||
<!-- Check if the pre-compressed file exists on the disk --> | ||
<add input="{DOCUMENT_ROOT}/_compressed_br/{C:0}" matchType="IsFile" negate="false" /> | ||
</conditions> | ||
<action type="Rewrite" url="/_compressed_br{C:0}" /> | ||
</rule> | ||
|
||
<rule name="Lookup for pre-compressed gzip file" stopProcessing="true"> | ||
<match url="(.*)$"/> | ||
<conditions> | ||
<!-- Match gzip requests --> | ||
<add input="{HTTP_ACCEPT_ENCODING}" pattern="gzip" /> | ||
|
||
<!-- Match all but pre-compressed files --> | ||
<add input="{REQUEST_URI}" pattern="^(?!/_compressed_gz/)(.*)$" /> | ||
|
||
<!-- Check if the pre-compressed file exists on the disk --> | ||
<add input="{DOCUMENT_ROOT}/_compressed_gz/{C:0}" matchType="IsFile" negate="false" /> | ||
</conditions> | ||
<action type="Rewrite" url="/_compressed_gz{C:0}" /> | ||
</rule> | ||
</rules> | ||
|
||
<outboundRules> | ||
<rule name="Adjust content encoding for gzip pre-compressed files" enabled="true" stopProcessing="true"> | ||
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern="" /> | ||
<conditions> | ||
<add input="{REQUEST_URI}" pattern="/_compressed_gz/.*$" /> | ||
</conditions> | ||
<action type="Rewrite" value="gzip"/> | ||
</rule> | ||
<rule name="Adjust content encoding for brotli pre-compressed files" enabled="true" stopProcessing="true"> | ||
<match serverVariable="RESPONSE_CONTENT_ENCODING" pattern="" /> | ||
<conditions> | ||
<add input="{REQUEST_URI}" pattern="/_compressed_br/.*$" /> | ||
</conditions> | ||
<action type="Rewrite" value="br"/> | ||
</rule> | ||
</outboundRules> | ||
</rewrite> | ||
</system.webServer> | ||
</configuration> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.