Skip to content

Commit

Permalink
chore: Adding wasm target
Browse files Browse the repository at this point in the history
  • Loading branch information
nickrandolph committed Jul 28, 2023
1 parent 6a74365 commit 8ac4dab
Show file tree
Hide file tree
Showing 13 changed files with 294 additions and 2 deletions.
5 changes: 5 additions & 0 deletions samples/MauiEmbedding/Directory.Packages.props
Original file line number Diff line number Diff line change
Expand Up @@ -23,5 +23,10 @@
<PackageVersion Include="CommunityToolkit.Maui" Version="2.0.0" />
<PackageVersion Include="Telerik.UI.for.Maui" Version="5.1.0" Condition="$(_UseTelerik)" />
<PackageVersion Include="Esri.ArcGISRuntime.Maui" Version="200.1.0" />
<PackageVersion Include="Microsoft.Windows.Compatibility" Version="7.0.4" />
<PackageVersion Include="Uno.Extensions.Logging.WebAssembly.Console" Version="1.4.0" />
<PackageVersion Include="Uno.WinUI.WebAssembly" Version="5.0.0-dev.1610" />
<PackageVersion Include="Uno.Wasm.Bootstrap" Version="7.0.27" />
<PackageVersion Include="Uno.Wasm.Bootstrap.DevServer" Version="7.0.27" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@
<!-- Required for C# Hot Reload -->
<UseInterpreter Condition="'$(Configuration)' == 'Debug' and $([MSBuild]::GetTargetPlatformIdentifier('$(TargetFramework)')) != 'maccatalyst'">True</UseInterpreter>
<IsUnoHead>true</IsUnoHead>

<!-- TODO: Remove one issue fixed: https://github.com/unoplatform/uno.extensions-private/issues/78 -->
<!-- Note that the UnoDisableHotRestartHelperGeneration is inverted -->
<UnoDisableHotRestartHelperGeneration>false</UnoDisableHotRestartHelperGeneration>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<!-- This is only required because this project references Uno.Extensions.Maui.WinUI as a package reference (ie by source) -->
<Import Project="..\..\..\src\Uno.Extensions.Maui.UI\build\Package.props" />

<PropertyGroup>
<OutputType Condition="'$(Configuration)'=='Release'">WinExe</OutputType>
<OutputType Condition="'$(Configuration)'=='Debug'">Exe</OutputType>
Expand All @@ -22,4 +25,5 @@
<ProjectReference Include="..\MauiEmbedding\MauiEmbedding.csproj" />
</ItemGroup>
<Import Project="..\MauiEmbedding.Base\base.props" />
<Import Project="..\..\..\src\Uno.Extensions.Maui.UI\build\Package.targets" />
</Project>
11 changes: 11 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/LinkerConfig.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<linker>
<assembly fullname="MauiEmbedding" />
<assembly fullname="MauiEmbedding.Wasm" />

<!--
Uncomment this section when using JSON.NET
<assembly fullname="System.Core">
<type fullname="System.Linq.Expressions*" />
</assembly>
-->
</linker>
75 changes: 75 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/MauiEmbedding.Wasm.csproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<!-- This is only required because this project references Uno.Extensions.Maui.WinUI as a package reference (ie by source) -->
<Import Project="..\..\..\src\Uno.Extensions.Maui.UI\build\Package.props" />

<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net7.0</TargetFramework>
<NoWarn>$(NoWarn);NU1504;NU1505;NU1701</NoWarn>
<!-- Disabled due to issue with Central Package Management with implicit using -->
<ImplicitUsings>disable</ImplicitUsings>
<WasmPWAManifestFile>manifest.webmanifest</WasmPWAManifestFile>
<AppDesignerFolder>Properties</AppDesignerFolder>
<!--
Supports Deep Linking Routes
https://aka.platform.uno/wasm-deeplink
-->
<WasmShellWebAppBasePath>/</WasmShellWebAppBasePath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Debug'">
<MonoRuntimeDebuggerEnabled>true</MonoRuntimeDebuggerEnabled>
<DefineConstants>$(DefineConstants);TRACE;DEBUG</DefineConstants>
<DebugType>portable</DebugType>
<DebugSymbols>true</DebugSymbols>
<!--
IL Linking is disabled in Debug configuration.
When building in Release, see https://platform.uno/docs/articles/features/using-il-linker-WebAssembly.html
-->
<WasmShellILLinkerEnabled>false</WasmShellILLinkerEnabled>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)'=='Release'">
<!-- XAML Resource trimming https://aka.platform.uno/xaml-trimming -->
<!--<UnoXamlResourcesTrimming>true</UnoXamlResourcesTrimming>-->
<!-- Improve performance with AOT builds https://aka.platform.uno/wasm-aot -->
<!-- <WasmShellMonoRuntimeExecutionMode>InterpreterAndAOT</WasmShellMonoRuntimeExecutionMode> -->
<!-- Temporarily uncomment to generate an AOT profile https://aka.platform.uno/wasm-aot-profile -->
<!-- <WasmShellGenerateAOTProfile>true</WasmShellGenerateAOTProfile> -->
</PropertyGroup>
<ItemGroup>
<Content Include="manifest.webmanifest" />
</ItemGroup>
<ItemGroup>
<EmbeddedResource Include="WasmCSS\Fonts.css" />
<EmbeddedResource Include="WasmScripts\AppManifest.js" />
</ItemGroup>
<ItemGroup>
<LinkerDescriptor Include="LinkerConfig.xml" />
</ItemGroup>
<ItemGroup>
<!--
This item group is required by the project template because of the
new SDK-Style project, otherwise some files are not added automatically.
You can safely remove this ItemGroup completely.
-->
<None Include="Program.cs" />
<None Include="LinkerConfig.xml" />
<None Include="wwwroot\web.config" />
</ItemGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Windows.Compatibility" />
<PackageReference Include="Uno.Wasm.Bootstrap" />
<PackageReference Include="Uno.Wasm.Bootstrap.DevServer" />
<PackageReference Include="Uno.WinUI.WebAssembly" />
<PackageReference Include="Uno.WinUI.RemoteControl" Condition="'$(Configuration)'=='Debug'" />
<PackageReference Include="Uno.UI.Adapter.Microsoft.Extensions.Logging" />
<PackageReference Include="Uno.Extensions.Logging.WebAssembly.Console" />
<PackageReference Include="Microsoft.Extensions.Logging.Console" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\MauiEmbedding\MauiEmbedding.csproj" />
</ItemGroup>
<Import Project="..\MauiEmbedding.Base\base.props" />
<Import Project="..\..\..\src\Uno.Extensions.Maui.UI\build\Package.targets" />
</Project>
13 changes: 13 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/Program.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
namespace MauiEmbedding.Wasm;

public class Program
{
private static App? _app;

public static int Main(string[] args)
{
Microsoft.UI.Xaml.Application.Start(_ => _app = new AppHead());

return 0;
}
}
28 changes: 28 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/WasmCSS/Fonts.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/**
When adding fonts here, make sure to add them using a base64 data uri, otherwise
fonts loading are delayed, and text may get displayed incorrectly.
*/

/* https://github.com/unoplatform/uno/issues/3954 */
@font-face {
font-family: 'Segoe UI';
src: local('Segoe UI'), local('-apple-system'), local('BlinkMacSystemFont'), local('Inter'), local('Cantarell'), local('Ubuntu'), local('Roboto'), local('Open Sans'), local('Noto Sans'), local('Helvetica Neue'), local('sans-serif');
}

@font-face {
font-family: 'Roboto';
src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Light.ttf) format('truetype');
font-weight: 300;
}

@font-face {
font-family: 'Roboto';
src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Regular.ttf) format('truetype');
font-weight: 400;
}

@font-face {
font-family: 'Roboto';
src: url(./Uno.Fonts.Roboto/Fonts/Roboto-Medium.ttf) format('truetype');
font-weight: 500;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
var UnoAppManifest = {
displayName: "MauiEmbedding"
}
10 changes: 10 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/manifest.webmanifest
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"background_color": "#ffffff",
"description": "MauiEmbedding",
"display": "standalone",
"name": "MauiEmbedding",
"short_name": "MauiEmbedding",
"start_url": "/index.html",
"theme_color": "#ffffff",
"scope": "/"
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{
"navigationFallback": {
"rewrite": "/index.html",
"exclude": [
"*.{css,js}",
"*.{png}",
"*.{c,h,wasm,clr,pdb,dat,txt}"
]
},
"routes": [
{
"route": "/package_*",
"headers": {
"cache-control": "public, immutable, max-age=31536000"
}
},
{
"route": "/*.ttf",
"headers": {
"cache-control": "public, immutable, max-age=31536000"
}
},
{
"route": "/*",
"headers": {
"cache-control": "must-revalidate, max-age=3600"
}
}
]
}
78 changes: 78 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.Wasm/wwwroot/web.config
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 through 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" />
<mimeMap fileExtension=".dat" mimeType="application/octet-stream" />
<!-- 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>
31 changes: 31 additions & 0 deletions samples/MauiEmbedding/MauiEmbedding.sln
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiApp1", "MauiProjects\Ma
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiEmbedding.Skia.Gtk", "MauiEmbedding.Skia.Gtk\MauiEmbedding.Skia.Gtk.csproj", "{00BAAAC1-9BA0-4F35-B7B6-5B4D64E45FAB}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MauiEmbedding.Wasm", "MauiEmbedding.Wasm\MauiEmbedding.Wasm.csproj", "{8BD5BF69-6C93-44BE-B31E-625636BD6423}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -906,6 +908,34 @@ Global
{00BAAAC1-9BA0-4F35-B7B6-5B4D64E45FAB}.Release|x64.Build.0 = Release|Any CPU
{00BAAAC1-9BA0-4F35-B7B6-5B4D64E45FAB}.Release|x86.ActiveCfg = Release|Any CPU
{00BAAAC1-9BA0-4F35-B7B6-5B4D64E45FAB}.Release|x86.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|Any CPU.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|ARM.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|ARM.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|ARM64.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|ARM64.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|iPhone.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|iPhone.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|iPhoneSimulator.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|iPhoneSimulator.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|x64.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|x64.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|x86.ActiveCfg = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Debug|x86.Build.0 = Debug|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|Any CPU.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|Any CPU.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|ARM.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|ARM.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|ARM64.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|ARM64.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|iPhone.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|iPhone.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|iPhoneSimulator.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|iPhoneSimulator.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|x64.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|x64.Build.0 = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|x86.ActiveCfg = Release|Any CPU
{8BD5BF69-6C93-44BE-B31E-625636BD6423}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down Expand Up @@ -941,6 +971,7 @@ Global
{A158CC84-0219-4BE4-A3F2-7AB7F613855A} = {24511BF4-9869-4773-AF84-CC8F79AF5085}
{8577882E-DA52-4D27-A529-C70998034566} = {24511BF4-9869-4773-AF84-CC8F79AF5085}
{00BAAAC1-9BA0-4F35-B7B6-5B4D64E45FAB} = {1C130CF4-EEF4-44D9-9DEF-C037FE1C221B}
{8BD5BF69-6C93-44BE-B31E-625636BD6423} = {1C130CF4-EEF4-44D9-9DEF-C037FE1C221B}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {584E156C-C094-4968-8A1F-3FB06081E34D}
Expand Down
4 changes: 2 additions & 2 deletions samples/MauiEmbedding/MauiEmbedding/MauiEmbedding.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@
</Choose>

<ItemGroup Condition="!$(IsMauiEmbedding)">
<Compile Remove="Presentation\Maui\EsriMapsPage.xaml.cs"/>
<Page Remove="Presentation\Maui\EsriMapsPage.xaml"/>
<Compile Remove="Presentation\EsriMapsPage.xaml.cs"/>
<Page Remove="Presentation\EsriMapsPage.xaml"/>
</ItemGroup>

<ItemGroup>
Expand Down

0 comments on commit 8ac4dab

Please sign in to comment.