├── .gitignore ├── .vscode ├── launch.json ├── settings.json └── tasks.json ├── BlazorHybridLinux.sln ├── LICENSE ├── README.md ├── Screens └── screenshot.png ├── WSL2.md ├── WebKitGtk.Test ├── App.razor ├── Data │ ├── WeatherForecast.cs │ └── WeatherForecastService.cs ├── Pages │ ├── Counter.razor │ ├── FetchData.razor │ └── Index.razor ├── Program.cs ├── Properties │ └── launchSettings.json ├── Shared │ ├── MainLayout.razor │ ├── MainLayout.razor.css │ ├── NavMenu.razor │ ├── NavMenu.razor.css │ └── SurveyPrompt.razor ├── WebKitGtk.Test.csproj ├── _Imports.razor └── wwwroot │ ├── css │ ├── app.css │ ├── bootstrap │ │ ├── bootstrap.min.css │ │ └── bootstrap.min.css.map │ └── open-iconic │ │ ├── FONT-LICENSE │ │ ├── ICON-LICENSE │ │ ├── README.md │ │ └── font │ │ ├── css │ │ └── open-iconic-bootstrap.min.css │ │ └── fonts │ │ ├── open-iconic.eot │ │ ├── open-iconic.otf │ │ ├── open-iconic.svg │ │ ├── open-iconic.ttf │ │ └── open-iconic.woff │ └── index.html └── WebKitGtk ├── BlazorWebView.cs ├── BlazorWebViewOptions.cs ├── ServiceCollectionExtensions.cs └── WebKitGtk.csproj /.gitignore: -------------------------------------------------------------------------------- 1 | .vs 2 | **/obj 3 | **/bin 4 | **/*.user 5 | -------------------------------------------------------------------------------- /.vscode/launch.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "0.2.0", 3 | "configurations": [ 4 | { 5 | // Use IntelliSense to find out which attributes exist for C# debugging 6 | // Use hover for the description of the existing attributes 7 | // For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md 8 | "name": ".NET Core Launch (console)", 9 | "type": "coreclr", 10 | "request": "launch", 11 | "preLaunchTask": "build", 12 | // If you have changed target frameworks, make sure to update the program path. 13 | "program": "${workspaceFolder}/${config:projectName}/bin/Debug/net8.0/${config:projectName}.dll", 14 | "args": [], 15 | "cwd": "${workspaceFolder}/${config:projectName}/bin/Debug/net8.0/", 16 | // For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console 17 | "console": "internalConsole", 18 | "stopAtEntry": false 19 | }, 20 | { 21 | // For this to work you need to install your public key on the remote machine so it will 22 | // not require a password. Also you need to install vsdbg on the remote machine: 23 | // $ wget https://aka.ms/getvsdbgsh 24 | // $ chmod +x getvsdbgsh 25 | // $ sudo ./getvsdbgsh -v latest -l /opt/Microsoft/vsdbg 26 | "name": "Remote Debug", 27 | "type": "coreclr", 28 | "request": "launch", 29 | "preLaunchTask": "postdeploy", 30 | "program": "${config:projectName}", 31 | "args": [], 32 | "cwd": "${config:targetDir}", 33 | "console": "internalConsole", 34 | "stopAtEntry": false, 35 | "pipeTransport": { 36 | "pipeCwd": "${workspaceRoot}", 37 | "pipeProgram": "ssh", 38 | "pipeArgs": [ 39 | "pi@${config:targetMachine}" 40 | ], 41 | "debuggerPath": "/opt/Microsoft/vsdbg/vsdbg", 42 | }, 43 | "env": { 44 | "DISPLAY": ":0.0" 45 | }, 46 | "logging": { 47 | "moduleLoad": false 48 | } 49 | }, 50 | ] 51 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "projectName": "WebKitGtk.Test", 3 | "targetMachine": "192.168.0.21", 4 | "targetDir": "debug/", 5 | "files.exclude": { 6 | "**/bin": true, 7 | "**/obj": true 8 | } 9 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | "version": "2.0.0", 3 | "tasks": [ 4 | { 5 | "label": "build", 6 | "command": "dotnet", 7 | "type": "process", 8 | "args": [ 9 | "build", 10 | "${workspaceFolder}/${config:projectName}/${config:projectName}.csproj", 11 | "/property:GenerateFullPaths=true", 12 | "/consoleloggerparameters:NoSummary" 13 | ], 14 | "problemMatcher": "$msCompile" 15 | }, 16 | { 17 | "label": "publish", 18 | "command": "dotnet", 19 | "type": "process", 20 | "args": [ 21 | "publish", 22 | "${workspaceFolder}/${config:projectName}/${config:projectName}.csproj", 23 | "/property:GenerateFullPaths=true", 24 | "/consoleloggerparameters:NoSummary" 25 | ], 26 | "problemMatcher": "$msCompile" 27 | }, 28 | { 29 | "label": "watch", 30 | "command": "dotnet", 31 | "type": "process", 32 | "args": [ 33 | "watch", 34 | "run", 35 | "--project", 36 | "${workspaceFolder}/${config:projectName}/${config:projectName}.csproj" 37 | ], 38 | "problemMatcher": "$msCompile" 39 | }, 40 | { 41 | "label": "publish Remote", 42 | "command": "dotnet", 43 | "type": "process", 44 | "args": [ 45 | "publish", 46 | "-c", 47 | "Debug", 48 | "-r", 49 | "linux-arm64", 50 | "--self-contained", 51 | "false", 52 | "${workspaceFolder}/${config:projectName}/${config:projectName}.csproj", 53 | "/property:GenerateFullPaths=true", 54 | "/consoleloggerparameters:NoSummary" 55 | ], 56 | "problemMatcher": "$msCompile" 57 | }, 58 | { 59 | "label": "predeploy", 60 | "dependsOn": "publish Remote", 61 | "command": "ssh", 62 | "type": "shell", 63 | "args": [ 64 | "pi@${config:targetMachine}", 65 | "mkdir -p ${config:targetDir}" 66 | ], 67 | "problemMatcher": [] 68 | }, 69 | { 70 | "label": "deploy", 71 | "dependsOn": "predeploy", 72 | "command": "bash", 73 | "type": "shell", 74 | "args": [ 75 | "-c", 76 | "rsync -ruv --delete ${workspaceFolder}/${config:projectName}/bin/Debug/net8.0/linux-arm64/publish/* pi@${config:targetMachine}:${config:targetDir}" 77 | ], 78 | "problemMatcher": [] 79 | }, 80 | { 81 | "label": "postdeploy", 82 | "dependsOn": "deploy", 83 | "command": "ssh", 84 | "type": "shell", 85 | "args": [ 86 | "pi@${config:targetMachine}", 87 | "chmod +x ${config:targetDir}/${config:projectName}" 88 | ], 89 | "problemMatcher": [] 90 | } 91 | ] 92 | } -------------------------------------------------------------------------------- /BlazorHybridLinux.sln: -------------------------------------------------------------------------------- 1 |  2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 17 4 | VisualStudioVersion = 17.10.34916.146 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebKitGtk.Test", "WebKitGtk.Test\WebKitGtk.Test.csproj", "{35E493E3-2237-4278-8A13-8FBD0CAA671D}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "WebKitGtk", "WebKitGtk\WebKitGtk.csproj", "{2F5C9742-E7EE-4481-B01E-A8538980A0FF}" 9 | EndProject 10 | Global 11 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 12 | Debug|Any CPU = Debug|Any CPU 13 | Release|Any CPU = Release|Any CPU 14 | EndGlobalSection 15 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 16 | {2F5C9742-E7EE-4481-B01E-A8538980A0FF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 17 | {2F5C9742-E7EE-4481-B01E-A8538980A0FF}.Debug|Any CPU.Build.0 = Debug|Any CPU 18 | {2F5C9742-E7EE-4481-B01E-A8538980A0FF}.Release|Any CPU.ActiveCfg = Release|Any CPU 19 | {2F5C9742-E7EE-4481-B01E-A8538980A0FF}.Release|Any CPU.Build.0 = Release|Any CPU 20 | {35E493E3-2237-4278-8A13-8FBD0CAA671D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 21 | {35E493E3-2237-4278-8A13-8FBD0CAA671D}.Debug|Any CPU.Build.0 = Debug|Any CPU 22 | {35E493E3-2237-4278-8A13-8FBD0CAA671D}.Release|Any CPU.ActiveCfg = Release|Any CPU 23 | {35E493E3-2237-4278-8A13-8FBD0CAA671D}.Release|Any CPU.Build.0 = Release|Any CPU 24 | EndGlobalSection 25 | GlobalSection(SolutionProperties) = preSolution 26 | HideSolutionNode = FALSE 27 | EndGlobalSection 28 | GlobalSection(ExtensibilityGlobals) = postSolution 29 | SolutionGuid = {91BA0967-21DD-4980-AFDE-6A54F7C890B0} 30 | EndGlobalSection 31 | EndGlobal 32 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # BlazorWebView 2 | A [WebKitGTK](https://webkitgtk.org/) WebView, utilizing [Gir.Core](https://gircore.github.io/), for running [Blazor Hybrid](https://learn.microsoft.com/en-us/aspnet/core/blazor/hybrid/) applications on Linux without the need to compile a native library. It is analagous to the [Winforms BlazorWebView](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.webview.windowsforms.blazorwebview) or the [WPF BlazorWebView](https://learn.microsoft.com/en-us/dotnet/api/microsoft.aspnetcore.components.webview.wpf), but for Linux instead of Windows. 3 | 4 | Blazor Hybrid apps allow one to create Blazor desktop applications that uses the local machine's .NET runtime (not Blazor WASM), has full access to local resources (not sandboxed), and does not require hosting through a web server (e.g. Blazor server). It is just like any other desktop application written in C#, but uses Blazor and web technologies to implement the user interface. 5 | 6 | ## Why? 7 | Microsoft has decided to not support Maui on Linux, so there is currently no way to create Blazor Hybrid apps on Linux using *only* C#. 8 | 9 | ## How? 10 | BlazorWebView uses some of the same code as [Steve Sanderson's WebWindow](https://github.com/SteveSandersonMS/WebWindow) and leverages [Microsoft's WebView infrastructure](https://github.com/dotnet/aspnetcore/tree/main/src/Components/WebView) to get Blazor Hybrid working. However, it differs from WebWindow in that it doesn't require one to compile a native shared library in C++, instead utilizing [Gir.Core](https://gircore.github.io/) to call into the native libraries. This has the benefit that, as long as the native libraries are installed on the Linux system, one only needs to use the `dotnet` CLI to build and run BlazorWebView. 11 | 12 | ## Screenshot 13 | 14 | 15 | ## Demonstration 16 | 17 | ### Using a Linux terminal 18 | ``` 19 | git clone https://github.com/JinShil/BlazorWebView.git 20 | cd BlazorWebView/WebKitGtk.Test 21 | dotnet run 22 | ``` 23 | 24 | ### Using Visual Studio Code 25 | On a Linux computer, simply open this repository in Visual Studio Code and press F5 to start a debug session. 26 | 27 | ### Ubuntu 24.04 bwrap error fix 28 | Running the demo project may fail with the following error on ubuntu 24.04: 29 | 30 | bwrap: setting up uid map: Permission denied 31 | 32 | This is due to the Ubuntu developers' decision to use AppArmor to restrict the creation of user namespaces. Below are the steps for applying a new AppArmor profile to enable user namespace restriction: 33 | 34 | ```sh 35 | # Download the new profile: 36 | 37 | sudo wget -O /etc/apparmor.d/bwrap-userns-restrict "https://gitlab.com/apparmor/apparmor/-/raw/master/profiles/apparmor/profiles/extras/bwrap-userns-restrict?ref_type=heads&inline=false" 38 | 39 | # Load the new profile into AppArmor: 40 | sudo apparmor_parser -r /etc/apparmor.d/bwrap-userns-restrict 41 | 42 | # Restart the AppArmor service: 43 | sudo systemctl restart apparmor 44 | ``` 45 | 46 | ## Usage 47 | See the project in [WebKitGtk.Test](https://github.com/JinShil/BlazorWebView/tree/main/WebKitGtk.Test) for an example illustrating how to create a Blazor Hybrid application using the BlazorWebView. 48 | 49 | You may need to install the following packages: 50 | * libadwaita-1-0 51 | * libwebkitgtk-6.0-4 52 | 53 | ## Status 54 | This project was tested on: 55 | - Windows Subsystem for Linux. Detailed setup instructions are available [here](./WSL2.md). 56 | - Raspberry Pi Bullseye 64-bit 57 | - Debian Bullseye 64-bit. 58 | - Ubuntu 24.04 LTS desktop amd64 59 | 60 | The root .vscode directory has the necessary configuration files to build, deploy, and debug a Raspberry Pi from a Debian Bullseyse 64-bit workstation PC. 61 | -------------------------------------------------------------------------------- /Screens/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JinShil/BlazorWebView/1b52948353a90fcee8801dd031f94261e92ee920/Screens/screenshot.png -------------------------------------------------------------------------------- /WSL2.md: -------------------------------------------------------------------------------- 1 | # WSL2 Setup Guide 2 | 3 | ## Installing WSL2 4 | 5 | 1. **Open a PowerShell window with administrative privileges.** 6 | 2. **Run the following commands to enable WSL and Virtual Machine Platform features:** 7 | 8 | ```powershell 9 | dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all /norestart 10 | dism.exe /online /enable-feature /featurename:VirtualMachinePlatform /all /norestart 11 | 12 | # Restart your computer to apply changes 13 | Restart-Computer 14 | ``` 15 | 16 | ## Updating WSL2 Kernel and Installing Ubuntu 24.04 17 | 18 | 1. **After restarting, open PowerShell.** 19 | 2. **Update the WSL kernel:** 20 | 21 | ```powershell 22 | wsl --update 23 | ``` 24 | 25 | 3. **Set WSL2 as the default version:** 26 | 27 | ```powershell 28 | wsl --set-default-version 2 29 | ``` 30 | 31 | 4. **Install Ubuntu 24.04:** 32 | 33 | ```powershell 34 | wsl --install -d Ubuntu-24.04 35 | ``` 36 | 37 | 5. **Update Ubuntu packages after installation:** 38 | 39 | ```bash 40 | sudo apt update && sudo apt full-upgrade -y 41 | ``` 42 | 43 | ## Setting Up WSL2 GUI (WSLg Links) 44 | 45 | For more information about the WSLg Links project, visit [viruscamp WSLg Links](https://github.com/viruscamp/wslg-links). 46 | 47 | 1. **Install WSLg Links:** 48 | 49 | ```bash 50 | # Using unzip (if installed) 51 | # sudo apt install unzip 52 | wget https://github.com/viruscamp/wslg-links/archive/refs/heads/main.zip 53 | unzip main.zip && cd wslg-links-main 54 | 55 | # Using git (if installed) 56 | # sudo apt install git 57 | git clone https://github.com/viruscamp/wslg-links.git 58 | cd wslg-links 59 | 60 | sudo cp wslg-tmp-x11.service /usr/lib/systemd/system/ 61 | sudo cp wslg-runtime-dir.service /usr/lib/systemd/user/ 62 | sudo systemctl enable wslg-tmp-x11 63 | sudo systemctl --global enable wslg-runtime-dir 64 | exit 65 | ``` 66 | 67 | 2. **Shutdown WSL:** 68 | 69 | ```powershell 70 | wsl --shutdown 71 | ``` 72 | 73 | ## Configuring WSL2 GUI Environment Variables 74 | 75 | 1. **Open the Ubuntu terminal in WSL2:** 76 | 77 | ```powershell 78 | wsl -d Ubuntu-24.04 --cd ~ 79 | ``` 80 | 81 | ### CPU Rendering (Faster but Uses CPU Only) 82 | 83 | ```bash 84 | export LIBGL_ALWAYS_SOFTWARE=true 85 | export GALLIUM_DRIVER=llvmpipe 86 | # Alternative: 87 | # export GALLIUM_DRIVER=softpipe 88 | ``` 89 | 90 | ### GPU Rendering (Requires Compatible Hardware) 91 | 92 | Follow the [Microsoft WSL2 GUI setup documentation](https://learn.microsoft.com/en-us/windows/wsl/tutorials/gui-apps#prerequisites) for prerequisites. (Installed driver for vGPU) 93 | 94 | #### For Intel GPUs 95 | 96 | ```bash 97 | export GALLIUM_DRIVER=d3d12 98 | export MESA_D3D12_DEFAULT_ADAPTER_NAME=INTEL 99 | ``` 100 | 101 | #### For NVIDIA GPUs 102 | 103 | ```bash 104 | export GALLIUM_DRIVER=d3d12 105 | export MESA_D3D12_DEFAULT_ADAPTER_NAME=NVIDIA 106 | ``` 107 | 108 | #### For AMD GPUs (Not Tested) 109 | 110 | ```bash 111 | export GALLIUM_DRIVER=d3d12 112 | export MESA_D3D12_DEFAULT_ADAPTER_NAME=AMD 113 | ``` 114 | 115 | --- 116 | 117 | This guide provides a comprehensive setup for WSL2 with Ubuntu 24.04, including optional GUI configurations. Ensure all dependencies are installed as needed. 118 | -------------------------------------------------------------------------------- /WebKitGtk.Test/App.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Routing 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |

Sorry, there's nothing at this address.

11 |
12 |
13 |
14 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Data/WeatherForecast.cs: -------------------------------------------------------------------------------- 1 | namespace WebKitGtk.Test.Data; 2 | 3 | using System; 4 | 5 | public class WeatherForecast 6 | { 7 | public DateTime Date { get; set; } 8 | 9 | public int TemperatureC { get; set; } 10 | 11 | public int TemperatureF => 32 + (int)(TemperatureC / 0.5556); 12 | 13 | public string? Summary { get; set; } 14 | } 15 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Data/WeatherForecastService.cs: -------------------------------------------------------------------------------- 1 | namespace WebKitGtk.Test.Data; 2 | 3 | using System; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | public class WeatherForecastService 8 | { 9 | private static readonly string[] Summaries = new[] 10 | { 11 | "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering", "Scorching" 12 | }; 13 | 14 | public Task GetForecastAsync(DateTime startDate) 15 | { 16 | return Task.FromResult(Enumerable.Range(1, 5).Select(index => new WeatherForecast 17 | { 18 | Date = startDate.AddDays(index), 19 | TemperatureC = Random.Shared.Next(-20, 55), 20 | Summary = Summaries[Random.Shared.Next(Summaries.Length)] 21 | }).ToArray()); 22 | } 23 | } 24 | 25 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Pages/Counter.razor: -------------------------------------------------------------------------------- 1 | @page "/counter" 2 | 3 |

Counter

4 | 5 |

Current count: @currentCount

6 | 7 | 8 | 9 | @code { 10 | private int currentCount = 0; 11 | 12 | private void IncrementCount() 13 | { 14 | currentCount++; 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Pages/FetchData.razor: -------------------------------------------------------------------------------- 1 | @page "/fetchdata" 2 | 3 | @using WebKitGtk.Test.Data 4 | @inject WeatherForecastService ForecastService 5 | 6 |

Weather forecast

7 | 8 |

This component demonstrates fetching data from a service.

9 | 10 | @if (forecasts == null) 11 | { 12 |

Loading...

13 | } 14 | else 15 | { 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | @foreach (var forecast in forecasts) 27 | { 28 | 29 | 30 | 31 | 32 | 33 | 34 | } 35 | 36 |
DateTemp. (C)Temp. (F)Summary
@forecast.Date.ToShortDateString()@forecast.TemperatureC@forecast.TemperatureF@forecast.Summary
37 | } 38 | 39 | @code { 40 | private WeatherForecast[]? forecasts; 41 | 42 | protected override async Task OnInitializedAsync() 43 | { 44 | forecasts = await ForecastService.GetForecastAsync(DateTime.Now); 45 | } 46 | } 47 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | @page "/" 2 | 3 | @* @using WebKitGtk.Test.Components *@ 4 | @using System.Diagnostics 5 | 6 |

Welcome to Blazor Hybrid for Linux!

7 | 8 |

Application took @StartupTime ms to start

9 | 10 | @code { 11 | string StartupTime 12 | { 13 | get 14 | { 15 | return (DateTime.Now - Process.GetCurrentProcess().StartTime).TotalMilliseconds.ToString("#,0"); 16 | } 17 | } 18 | } -------------------------------------------------------------------------------- /WebKitGtk.Test/Program.cs: -------------------------------------------------------------------------------- 1 | using WebKitGtk; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.Logging; 4 | using Microsoft.Extensions.Hosting; 5 | using System.Runtime.Versioning; 6 | using WebKitGtk.Test.Data; 7 | using System.Threading.Tasks; 8 | 9 | using System.Threading; 10 | using System; 11 | 12 | [UnsupportedOSPlatform("OSX")] 13 | [UnsupportedOSPlatform("Windows")] 14 | internal class Program : IHostedService 15 | { 16 | private static async Task Main(string[] args) 17 | { 18 | var builder = Host.CreateApplicationBuilder(args); 19 | //appBuilder.Logging.AddDebug(); 20 | builder.Logging.AddSimpleConsole( 21 | options => { 22 | options.ColorBehavior = Microsoft.Extensions.Logging.Console.LoggerColorBehavior.Disabled; 23 | options.IncludeScopes = false; 24 | options.SingleLine = true; 25 | options.TimestampFormat = "hh:mm:ss "; 26 | }) 27 | .SetMinimumLevel(LogLevel.Information); 28 | 29 | builder.Services.AddBlazorWebViewOptions( 30 | new BlazorWebViewOptions() 31 | { 32 | RootComponent = typeof(WebKitGtk.Test.App), 33 | HostPath = "wwwroot/index.html" 34 | } 35 | ) 36 | .AddSingleton() 37 | .AddHostedService(); 38 | 39 | using var host = builder.Build(); 40 | 41 | await host.RunAsync(); 42 | } 43 | 44 | public Program(IHostApplicationLifetime lifetime, IServiceProvider serviceProvider) 45 | { 46 | WebKit.Module.Initialize(); 47 | 48 | _serviceProvider = serviceProvider; 49 | _app = Adw.Application.New("org.gir.core", Gio.ApplicationFlags.FlagsNone); 50 | 51 | _app.OnActivate += (sender, args) => 52 | { 53 | var window = Gtk.ApplicationWindow.New((Adw.Application)sender); 54 | window.Title = "Blazor"; 55 | window.SetDefaultSize(800, 600); 56 | 57 | var webView = new BlazorWebView(_serviceProvider); 58 | window.SetChild(webView); 59 | window.Show(); 60 | 61 | // Allow opening developer tools 62 | webView.GetSettings().EnableDeveloperExtras = true; 63 | }; 64 | 65 | _app.OnShutdown += (sender, args) => 66 | { 67 | lifetime.StopApplication(); 68 | }; 69 | 70 | lifetime.ApplicationStarted.Register(() => 71 | { 72 | Task.Run(() => 73 | { 74 | Environment.ExitCode = _app.Run(0, []); 75 | }); 76 | }); 77 | 78 | lifetime.ApplicationStopping.Register(() => 79 | { 80 | _app.Quit(); 81 | }); 82 | } 83 | 84 | readonly IServiceProvider _serviceProvider; 85 | readonly Adw.Application _app; 86 | 87 | public Task StartAsync(CancellationToken cancellationToken) 88 | { 89 | return Task.CompletedTask; 90 | } 91 | 92 | public Task StopAsync(CancellationToken cancellationToken) 93 | { 94 | return Task.CompletedTask; 95 | } 96 | } -------------------------------------------------------------------------------- /WebKitGtk.Test/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "profiles": { 3 | "WebKitGtk.Test": { 4 | "commandName": "Project" 5 | }, 6 | "WSL": { 7 | "commandName": "WSL2", 8 | "distributionName": "" 9 | } 10 | } 11 | } -------------------------------------------------------------------------------- /WebKitGtk.Test/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Shared/MainLayout.razor.css: -------------------------------------------------------------------------------- 1 | .page { 2 | position: relative; 3 | display: flex; 4 | flex-direction: column; 5 | } 6 | 7 | main { 8 | flex: 1; 9 | } 10 | 11 | .sidebar { 12 | background-image: linear-gradient(180deg, rgb(5, 39, 103) 0%, #3a0647 70%); 13 | } 14 | 15 | .top-row { 16 | background-color: #f7f7f7; 17 | border-bottom: 1px solid #d6d5d5; 18 | justify-content: flex-end; 19 | height: 3.5rem; 20 | display: flex; 21 | align-items: center; 22 | } 23 | 24 | .top-row ::deep a, .top-row ::deep .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | text-decoration: none; 28 | } 29 | 30 | .top-row ::deep a:hover, .top-row ::deep .btn-link:hover { 31 | text-decoration: underline; 32 | } 33 | 34 | .top-row ::deep a:first-child { 35 | overflow: hidden; 36 | text-overflow: ellipsis; 37 | } 38 | 39 | @media (max-width: 640.98px) { 40 | .top-row:not(.auth) { 41 | display: none; 42 | } 43 | 44 | .top-row.auth { 45 | justify-content: space-between; 46 | } 47 | 48 | .top-row ::deep a, .top-row ::deep .btn-link { 49 | margin-left: 0; 50 | } 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .page { 55 | flex-direction: row; 56 | } 57 | 58 | .sidebar { 59 | width: 250px; 60 | height: 100vh; 61 | position: sticky; 62 | top: 0; 63 | } 64 | 65 | .top-row { 66 | position: sticky; 67 | top: 0; 68 | z-index: 1; 69 | } 70 | 71 | .top-row, article { 72 | padding-left: 2rem !important; 73 | padding-right: 1.5rem !important; 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 | @using WebKitGtk.Test.Shared 2 | 3 | 11 | 12 |
13 | 30 |
31 | 32 | @code { 33 | private bool collapseNavMenu = true; 34 | 35 | private string? NavMenuCssClass => collapseNavMenu ? "collapse" : null; 36 | 37 | private void ToggleNavMenu() 38 | { 39 | collapseNavMenu = !collapseNavMenu; 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Shared/NavMenu.razor.css: -------------------------------------------------------------------------------- 1 | .navbar-toggler { 2 | background-color: rgba(255, 255, 255, 0.1); 3 | } 4 | 5 | .top-row { 6 | height: 3.5rem; 7 | background-color: rgba(0,0,0,0.4); 8 | } 9 | 10 | .navbar-brand { 11 | font-size: 1.1rem; 12 | } 13 | 14 | .oi { 15 | width: 2rem; 16 | font-size: 1.1rem; 17 | vertical-align: text-top; 18 | top: -2px; 19 | } 20 | 21 | .nav-item { 22 | font-size: 0.9rem; 23 | padding-bottom: 0.5rem; 24 | } 25 | 26 | .nav-item:first-of-type { 27 | padding-top: 1rem; 28 | } 29 | 30 | .nav-item:last-of-type { 31 | padding-bottom: 1rem; 32 | } 33 | 34 | .nav-item ::deep a { 35 | color: #d7d7d7; 36 | border-radius: 4px; 37 | height: 3rem; 38 | display: flex; 39 | align-items: center; 40 | line-height: 3rem; 41 | } 42 | 43 | .nav-item ::deep a.active { 44 | background-color: rgba(255,255,255,0.25); 45 | color: white; 46 | } 47 | 48 | .nav-item ::deep a:hover { 49 | background-color: rgba(255,255,255,0.1); 50 | color: white; 51 | } 52 | 53 | @media (min-width: 641px) { 54 | .navbar-toggler { 55 | display: none; 56 | } 57 | 58 | .collapse { 59 | /* Never collapse the sidebar for wide screens */ 60 | display: block; 61 | } 62 | } 63 | -------------------------------------------------------------------------------- /WebKitGtk.Test/Shared/SurveyPrompt.razor: -------------------------------------------------------------------------------- 1 | 
2 | 3 | @Title 4 | 5 | 6 | Please take our 7 | brief survey 8 | 9 | and tell us what you think. 10 |
11 | 12 | @code { 13 | // Demonstrates how a parent component can supply parameters 14 | [Parameter] 15 | public string? Title { get; set; } 16 | } 17 | -------------------------------------------------------------------------------- /WebKitGtk.Test/WebKitGtk.Test.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | Exe 5 | net8.0 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | Always 25 | 26 | 27 | 28 | -------------------------------------------------------------------------------- /WebKitGtk.Test/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using System.Net.Http 2 | @using System.Net.Http.Json 3 | @using Microsoft.AspNetCore.Components.Forms 4 | @using Microsoft.AspNetCore.Components.Routing 5 | @using Microsoft.AspNetCore.Components.Web 6 | @using Microsoft.AspNetCore.Components.Web.Virtualization 7 | @using Microsoft.JSInterop 8 | @using WebKitGtk.Test 9 | @using WebKitGtk.Test.Shared 10 | @using WebKitGtk.Test.Pages 11 | @using WebKitGtk 12 | -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/app.css: -------------------------------------------------------------------------------- 1 | @import url('open-iconic/font/css/open-iconic-bootstrap.min.css'); 2 | 3 | html, body { 4 | font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif; 5 | } 6 | 7 | h1:focus { 8 | outline: none; 9 | } 10 | 11 | a, .btn-link { 12 | color: #0071c1; 13 | } 14 | 15 | .btn-primary { 16 | color: #fff; 17 | background-color: #1b6ec2; 18 | border-color: #1861ac; 19 | } 20 | 21 | .content { 22 | padding-top: 1.1rem; 23 | } 24 | 25 | .valid.modified:not([type=checkbox]) { 26 | outline: 1px solid #26b050; 27 | } 28 | 29 | .invalid { 30 | outline: 1px solid red; 31 | } 32 | 33 | .validation-message { 34 | color: red; 35 | } 36 | 37 | #blazor-error-ui { 38 | background: lightyellow; 39 | bottom: 0; 40 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 41 | display: none; 42 | left: 0; 43 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 44 | position: fixed; 45 | width: 100%; 46 | z-index: 1000; 47 | } 48 | 49 | #blazor-error-ui .dismiss { 50 | cursor: pointer; 51 | position: absolute; 52 | right: 0.75rem; 53 | top: 0.5rem; 54 | } 55 | 56 | .blazor-error-boundary { 57 | background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI4OS4wMzggOTkgMjg2LjYxNyA5OUwyNDAuMzgzIDk5QzIzNy45NjMgOTkgMjM2IDk3LjA2NTEgMjM2IDk0LjY3ODIgMjM2IDk0LjM3OTkgMjM2LjAzMSA5NC4wODg2IDIzNi4wODkgOTMuODA3MkwyMzYuMzM4IDkzLjAxNjIgMjM2Ljg1OCA5Mi4xMzE0IDI1OS40NzMgNTMuNjI5NCAyNTkuOTYxIDUyLjc5ODUgMjYwLjQwNyA1Mi4yNjU4QzI2MS4yIDUxLjQ4MzcgMjYyLjI5NiA1MSAyNjMuNTA2IDUxWk0yNjMuNTg2IDY2LjAxODNDMjYwLjczNyA2Ni4wMTgzIDI1OS4zMTMgNjcuMTI0NSAyNTkuMzEzIDY5LjMzNyAyNTkuMzEzIDY5LjYxMDIgMjU5LjMzMiA2OS44NjA4IDI1OS4zNzEgNzAuMDg4N0wyNjEuNzk1IDg0LjAxNjEgMjY1LjM4IDg0LjAxNjEgMjY3LjgyMSA2OS43NDc1QzI2Ny44NiA2OS43MzA5IDI2Ny44NzkgNjkuNTg3NyAyNjcuODc5IDY5LjMxNzkgMjY3Ljg3OSA2Ny4xMTgyIDI2Ni40NDggNjYuMDE4MyAyNjMuNTg2IDY2LjAxODNaTTI2My41NzYgODYuMDU0N0MyNjEuMDQ5IDg2LjA1NDcgMjU5Ljc4NiA4Ny4zMDA1IDI1OS43ODYgODkuNzkyMSAyNTkuNzg2IDkyLjI4MzcgMjYxLjA0OSA5My41Mjk1IDI2My41NzYgOTMuNTI5NSAyNjYuMTE2IDkzLjUyOTUgMjY3LjM4NyA5Mi4yODM3IDI2Ny4zODcgODkuNzkyMSAyNjcuMzg3IDg3LjMwMDUgMjY2LjExNiA4Ni4wNTQ3IDI2My41NzYgODYuMDU0N1oiIGZpbGw9IiNGRkU1MDAiIGZpbGwtcnVsZT0iZXZlbm9kZCIvPjwvZz48L3N2Zz4=) no-repeat 1rem/1.8rem, #b32121; 58 | padding: 1rem 1rem 1rem 3.7rem; 59 | color: white; 60 | } 61 | 62 | .blazor-error-boundary::after { 63 | content: "An error has occurred." 64 | } 65 | 66 | .status-bar-safe-area { 67 | display: none; 68 | } 69 | 70 | @supports (-webkit-touch-callout: none) { 71 | .status-bar-safe-area { 72 | display: flex; 73 | position: sticky; 74 | top: 0; 75 | height: env(safe-area-inset-top); 76 | background-color: #f7f7f7; 77 | width: 100%; 78 | z-index: 1; 79 | } 80 | 81 | .flex-column, .navbar-brand { 82 | padding-left: env(safe-area-inset-left); 83 | } 84 | } 85 | -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/FONT-LICENSE: -------------------------------------------------------------------------------- 1 | SIL OPEN FONT LICENSE Version 1.1 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | PREAMBLE 6 | The goals of the Open Font License (OFL) are to stimulate worldwide 7 | development of collaborative font projects, to support the font creation 8 | efforts of academic and linguistic communities, and to provide a free and 9 | open framework in which fonts may be shared and improved in partnership 10 | with others. 11 | 12 | The OFL allows the licensed fonts to be used, studied, modified and 13 | redistributed freely as long as they are not sold by themselves. The 14 | fonts, including any derivative works, can be bundled, embedded, 15 | redistributed and/or sold with any software provided that any reserved 16 | names are not used by derivative works. The fonts and derivatives, 17 | however, cannot be released under any other type of license. The 18 | requirement for fonts to remain under this license does not apply 19 | to any document created using the fonts or their derivatives. 20 | 21 | DEFINITIONS 22 | "Font Software" refers to the set of files released by the Copyright 23 | Holder(s) under this license and clearly marked as such. This may 24 | include source files, build scripts and documentation. 25 | 26 | "Reserved Font Name" refers to any names specified as such after the 27 | copyright statement(s). 28 | 29 | "Original Version" refers to the collection of Font Software components as 30 | distributed by the Copyright Holder(s). 31 | 32 | "Modified Version" refers to any derivative made by adding to, deleting, 33 | or substituting -- in part or in whole -- any of the components of the 34 | Original Version, by changing formats or by porting the Font Software to a 35 | new environment. 36 | 37 | "Author" refers to any designer, engineer, programmer, technical 38 | writer or other person who contributed to the Font Software. 39 | 40 | PERMISSION & CONDITIONS 41 | Permission is hereby granted, free of charge, to any person obtaining 42 | a copy of the Font Software, to use, study, copy, merge, embed, modify, 43 | redistribute, and sell modified and unmodified copies of the Font 44 | Software, subject to the following conditions: 45 | 46 | 1) Neither the Font Software nor any of its individual components, 47 | in Original or Modified Versions, may be sold by itself. 48 | 49 | 2) Original or Modified Versions of the Font Software may be bundled, 50 | redistributed and/or sold with any software, provided that each copy 51 | contains the above copyright notice and this license. These can be 52 | included either as stand-alone text files, human-readable headers or 53 | in the appropriate machine-readable metadata fields within text or 54 | binary files as long as those fields can be easily viewed by the user. 55 | 56 | 3) No Modified Version of the Font Software may use the Reserved Font 57 | Name(s) unless explicit written permission is granted by the corresponding 58 | Copyright Holder. This restriction only applies to the primary font name as 59 | presented to the users. 60 | 61 | 4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font 62 | Software shall not be used to promote, endorse or advertise any 63 | Modified Version, except to acknowledge the contribution(s) of the 64 | Copyright Holder(s) and the Author(s) or with their explicit written 65 | permission. 66 | 67 | 5) The Font Software, modified or unmodified, in part or in whole, 68 | must be distributed entirely under this license, and must not be 69 | distributed under any other license. The requirement for fonts to 70 | remain under this license does not apply to any document created 71 | using the Font Software. 72 | 73 | TERMINATION 74 | This license becomes null and void if any of the above conditions are 75 | not met. 76 | 77 | DISCLAIMER 78 | THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 79 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF 80 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT 81 | OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE 82 | COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 83 | INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL 84 | DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 85 | FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM 86 | OTHER DEALINGS IN THE FONT SOFTWARE. 87 | -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/ICON-LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2014 Waybury 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](https://github.com/iconic/open-iconic) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](https://github.com/iconic/open-iconic). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](https://github.com/iconic/open-iconic) 5 | 6 | 7 | 8 | ## What's in Open Iconic? 9 | 10 | * 223 icons designed to be legible down to 8 pixels 11 | * Super-light SVG files - 61.8 for the entire set 12 | * SVG sprite—the modern replacement for icon fonts 13 | * Webfont (EOT, OTF, SVG, TTF, WOFF), PNG and WebP formats 14 | * Webfont stylesheets (including versions for Bootstrap and Foundation) in CSS, LESS, SCSS and Stylus formats 15 | * PNG and WebP raster images in 8px, 16px, 24px, 32px, 48px and 64px. 16 | 17 | 18 | ## Getting Started 19 | 20 | #### For code samples and everything else you need to get started with Open Iconic, check out our [Icons](https://github.com/iconic/open-iconic) and [Reference](https://github.com/iconic/open-iconic) sections. 21 | 22 | ### General Usage 23 | 24 | #### Using Open Iconic's SVGs 25 | 26 | We like SVGs and we think they're the way to display icons on the web. Since Open Iconic are just basic SVGs, we suggest you display them like you would any other image (don't forget the `alt` attribute). 27 | 28 | ``` 29 | icon name 30 | ``` 31 | 32 | #### Using Open Iconic's SVG Sprite 33 | 34 | Open Iconic also comes in a SVG sprite which allows you to display all the icons in the set with a single request. It's like an icon font, without being a hack. 35 | 36 | Adding an icon from an SVG sprite is a little different than what you're used to, but it's still a piece of cake. *Tip: To make your icons easily style able, we suggest adding a general class to the* `` *tag and a unique class name for each different icon in the* `` *tag.* 37 | 38 | ``` 39 | 40 | 41 | 42 | ``` 43 | 44 | Sizing icons only needs basic CSS. All the icons are in a square format, so just set the `` tag with equal width and height dimensions. 45 | 46 | ``` 47 | .icon { 48 | width: 16px; 49 | height: 16px; 50 | } 51 | ``` 52 | 53 | Coloring icons is even easier. All you need to do is set the `fill` rule on the `` tag. 54 | 55 | ``` 56 | .icon-account-login { 57 | fill: #f00; 58 | } 59 | ``` 60 | 61 | To learn more about SVG Sprites, read [Chris Coyier's guide](http://css-tricks.com/svg-sprites-use-better-icon-fonts/). 62 | 63 | #### Using Open Iconic's Icon Font... 64 | 65 | 66 | ##### …with Bootstrap 67 | 68 | You can find our Bootstrap stylesheets in `font/css/open-iconic-bootstrap.{css, less, scss, styl}` 69 | 70 | 71 | ``` 72 | 73 | ``` 74 | 75 | 76 | ``` 77 | 78 | ``` 79 | 80 | ##### …with Foundation 81 | 82 | You can find our Foundation stylesheets in `font/css/open-iconic-foundation.{css, less, scss, styl}` 83 | 84 | ``` 85 | 86 | ``` 87 | 88 | 89 | ``` 90 | 91 | ``` 92 | 93 | ##### …on its own 94 | 95 | You can find our default stylesheets in `font/css/open-iconic.{css, less, scss, styl}` 96 | 97 | ``` 98 | 99 | ``` 100 | 101 | ``` 102 | 103 | ``` 104 | 105 | 106 | ## License 107 | 108 | ### Icons 109 | 110 | All code (including SVG markup) is under the [MIT License](http://opensource.org/licenses/MIT). 111 | 112 | ### Fonts 113 | 114 | All fonts are under the [SIL Licensed](http://scripts.sil.org/cms/scripts/page.php?item_id=OFL_web). 115 | -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/css/open-iconic-bootstrap.min.css: -------------------------------------------------------------------------------- 1 | @font-face{font-family:Icons;src:url(../fonts/open-iconic.eot);src:url(../fonts/open-iconic.eot?#iconic-sm) format('embedded-opentype'),url(../fonts/open-iconic.woff) format('woff'),url(../fonts/open-iconic.ttf) format('truetype'),url(../fonts/open-iconic.otf) format('opentype'),url(../fonts/open-iconic.svg#iconic-sm) format('svg');font-weight:400;font-style:normal}.oi{position:relative;top:1px;display:inline-block;speak:none;font-family:Icons;font-style:normal;font-weight:400;line-height:1;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale}.oi:empty:before{width:1em;text-align:center;box-sizing:content-box}.oi.oi-align-center:before{text-align:center}.oi.oi-align-left:before{text-align:left}.oi.oi-align-right:before{text-align:right}.oi.oi-flip-horizontal:before{-webkit-transform:scale(-1,1);-ms-transform:scale(-1,1);transform:scale(-1,1)}.oi.oi-flip-vertical:before{-webkit-transform:scale(1,-1);-ms-transform:scale(-1,1);transform:scale(1,-1)}.oi.oi-flip-horizontal-vertical:before{-webkit-transform:scale(-1,-1);-ms-transform:scale(-1,1);transform:scale(-1,-1)}.oi-account-login:before{content:'\e000'}.oi-account-logout:before{content:'\e001'}.oi-action-redo:before{content:'\e002'}.oi-action-undo:before{content:'\e003'}.oi-align-center:before{content:'\e004'}.oi-align-left:before{content:'\e005'}.oi-align-right:before{content:'\e006'}.oi-aperture:before{content:'\e007'}.oi-arrow-bottom:before{content:'\e008'}.oi-arrow-circle-bottom:before{content:'\e009'}.oi-arrow-circle-left:before{content:'\e00a'}.oi-arrow-circle-right:before{content:'\e00b'}.oi-arrow-circle-top:before{content:'\e00c'}.oi-arrow-left:before{content:'\e00d'}.oi-arrow-right:before{content:'\e00e'}.oi-arrow-thick-bottom:before{content:'\e00f'}.oi-arrow-thick-left:before{content:'\e010'}.oi-arrow-thick-right:before{content:'\e011'}.oi-arrow-thick-top:before{content:'\e012'}.oi-arrow-top:before{content:'\e013'}.oi-audio-spectrum:before{content:'\e014'}.oi-audio:before{content:'\e015'}.oi-badge:before{content:'\e016'}.oi-ban:before{content:'\e017'}.oi-bar-chart:before{content:'\e018'}.oi-basket:before{content:'\e019'}.oi-battery-empty:before{content:'\e01a'}.oi-battery-full:before{content:'\e01b'}.oi-beaker:before{content:'\e01c'}.oi-bell:before{content:'\e01d'}.oi-bluetooth:before{content:'\e01e'}.oi-bold:before{content:'\e01f'}.oi-bolt:before{content:'\e020'}.oi-book:before{content:'\e021'}.oi-bookmark:before{content:'\e022'}.oi-box:before{content:'\e023'}.oi-briefcase:before{content:'\e024'}.oi-british-pound:before{content:'\e025'}.oi-browser:before{content:'\e026'}.oi-brush:before{content:'\e027'}.oi-bug:before{content:'\e028'}.oi-bullhorn:before{content:'\e029'}.oi-calculator:before{content:'\e02a'}.oi-calendar:before{content:'\e02b'}.oi-camera-slr:before{content:'\e02c'}.oi-caret-bottom:before{content:'\e02d'}.oi-caret-left:before{content:'\e02e'}.oi-caret-right:before{content:'\e02f'}.oi-caret-top:before{content:'\e030'}.oi-cart:before{content:'\e031'}.oi-chat:before{content:'\e032'}.oi-check:before{content:'\e033'}.oi-chevron-bottom:before{content:'\e034'}.oi-chevron-left:before{content:'\e035'}.oi-chevron-right:before{content:'\e036'}.oi-chevron-top:before{content:'\e037'}.oi-circle-check:before{content:'\e038'}.oi-circle-x:before{content:'\e039'}.oi-clipboard:before{content:'\e03a'}.oi-clock:before{content:'\e03b'}.oi-cloud-download:before{content:'\e03c'}.oi-cloud-upload:before{content:'\e03d'}.oi-cloud:before{content:'\e03e'}.oi-cloudy:before{content:'\e03f'}.oi-code:before{content:'\e040'}.oi-cog:before{content:'\e041'}.oi-collapse-down:before{content:'\e042'}.oi-collapse-left:before{content:'\e043'}.oi-collapse-right:before{content:'\e044'}.oi-collapse-up:before{content:'\e045'}.oi-command:before{content:'\e046'}.oi-comment-square:before{content:'\e047'}.oi-compass:before{content:'\e048'}.oi-contrast:before{content:'\e049'}.oi-copywriting:before{content:'\e04a'}.oi-credit-card:before{content:'\e04b'}.oi-crop:before{content:'\e04c'}.oi-dashboard:before{content:'\e04d'}.oi-data-transfer-download:before{content:'\e04e'}.oi-data-transfer-upload:before{content:'\e04f'}.oi-delete:before{content:'\e050'}.oi-dial:before{content:'\e051'}.oi-document:before{content:'\e052'}.oi-dollar:before{content:'\e053'}.oi-double-quote-sans-left:before{content:'\e054'}.oi-double-quote-sans-right:before{content:'\e055'}.oi-double-quote-serif-left:before{content:'\e056'}.oi-double-quote-serif-right:before{content:'\e057'}.oi-droplet:before{content:'\e058'}.oi-eject:before{content:'\e059'}.oi-elevator:before{content:'\e05a'}.oi-ellipses:before{content:'\e05b'}.oi-envelope-closed:before{content:'\e05c'}.oi-envelope-open:before{content:'\e05d'}.oi-euro:before{content:'\e05e'}.oi-excerpt:before{content:'\e05f'}.oi-expand-down:before{content:'\e060'}.oi-expand-left:before{content:'\e061'}.oi-expand-right:before{content:'\e062'}.oi-expand-up:before{content:'\e063'}.oi-external-link:before{content:'\e064'}.oi-eye:before{content:'\e065'}.oi-eyedropper:before{content:'\e066'}.oi-file:before{content:'\e067'}.oi-fire:before{content:'\e068'}.oi-flag:before{content:'\e069'}.oi-flash:before{content:'\e06a'}.oi-folder:before{content:'\e06b'}.oi-fork:before{content:'\e06c'}.oi-fullscreen-enter:before{content:'\e06d'}.oi-fullscreen-exit:before{content:'\e06e'}.oi-globe:before{content:'\e06f'}.oi-graph:before{content:'\e070'}.oi-grid-four-up:before{content:'\e071'}.oi-grid-three-up:before{content:'\e072'}.oi-grid-two-up:before{content:'\e073'}.oi-hard-drive:before{content:'\e074'}.oi-header:before{content:'\e075'}.oi-headphones:before{content:'\e076'}.oi-heart:before{content:'\e077'}.oi-home:before{content:'\e078'}.oi-image:before{content:'\e079'}.oi-inbox:before{content:'\e07a'}.oi-infinity:before{content:'\e07b'}.oi-info:before{content:'\e07c'}.oi-italic:before{content:'\e07d'}.oi-justify-center:before{content:'\e07e'}.oi-justify-left:before{content:'\e07f'}.oi-justify-right:before{content:'\e080'}.oi-key:before{content:'\e081'}.oi-laptop:before{content:'\e082'}.oi-layers:before{content:'\e083'}.oi-lightbulb:before{content:'\e084'}.oi-link-broken:before{content:'\e085'}.oi-link-intact:before{content:'\e086'}.oi-list-rich:before{content:'\e087'}.oi-list:before{content:'\e088'}.oi-location:before{content:'\e089'}.oi-lock-locked:before{content:'\e08a'}.oi-lock-unlocked:before{content:'\e08b'}.oi-loop-circular:before{content:'\e08c'}.oi-loop-square:before{content:'\e08d'}.oi-loop:before{content:'\e08e'}.oi-magnifying-glass:before{content:'\e08f'}.oi-map-marker:before{content:'\e090'}.oi-map:before{content:'\e091'}.oi-media-pause:before{content:'\e092'}.oi-media-play:before{content:'\e093'}.oi-media-record:before{content:'\e094'}.oi-media-skip-backward:before{content:'\e095'}.oi-media-skip-forward:before{content:'\e096'}.oi-media-step-backward:before{content:'\e097'}.oi-media-step-forward:before{content:'\e098'}.oi-media-stop:before{content:'\e099'}.oi-medical-cross:before{content:'\e09a'}.oi-menu:before{content:'\e09b'}.oi-microphone:before{content:'\e09c'}.oi-minus:before{content:'\e09d'}.oi-monitor:before{content:'\e09e'}.oi-moon:before{content:'\e09f'}.oi-move:before{content:'\e0a0'}.oi-musical-note:before{content:'\e0a1'}.oi-paperclip:before{content:'\e0a2'}.oi-pencil:before{content:'\e0a3'}.oi-people:before{content:'\e0a4'}.oi-person:before{content:'\e0a5'}.oi-phone:before{content:'\e0a6'}.oi-pie-chart:before{content:'\e0a7'}.oi-pin:before{content:'\e0a8'}.oi-play-circle:before{content:'\e0a9'}.oi-plus:before{content:'\e0aa'}.oi-power-standby:before{content:'\e0ab'}.oi-print:before{content:'\e0ac'}.oi-project:before{content:'\e0ad'}.oi-pulse:before{content:'\e0ae'}.oi-puzzle-piece:before{content:'\e0af'}.oi-question-mark:before{content:'\e0b0'}.oi-rain:before{content:'\e0b1'}.oi-random:before{content:'\e0b2'}.oi-reload:before{content:'\e0b3'}.oi-resize-both:before{content:'\e0b4'}.oi-resize-height:before{content:'\e0b5'}.oi-resize-width:before{content:'\e0b6'}.oi-rss-alt:before{content:'\e0b7'}.oi-rss:before{content:'\e0b8'}.oi-script:before{content:'\e0b9'}.oi-share-boxed:before{content:'\e0ba'}.oi-share:before{content:'\e0bb'}.oi-shield:before{content:'\e0bc'}.oi-signal:before{content:'\e0bd'}.oi-signpost:before{content:'\e0be'}.oi-sort-ascending:before{content:'\e0bf'}.oi-sort-descending:before{content:'\e0c0'}.oi-spreadsheet:before{content:'\e0c1'}.oi-star:before{content:'\e0c2'}.oi-sun:before{content:'\e0c3'}.oi-tablet:before{content:'\e0c4'}.oi-tag:before{content:'\e0c5'}.oi-tags:before{content:'\e0c6'}.oi-target:before{content:'\e0c7'}.oi-task:before{content:'\e0c8'}.oi-terminal:before{content:'\e0c9'}.oi-text:before{content:'\e0ca'}.oi-thumb-down:before{content:'\e0cb'}.oi-thumb-up:before{content:'\e0cc'}.oi-timer:before{content:'\e0cd'}.oi-transfer:before{content:'\e0ce'}.oi-trash:before{content:'\e0cf'}.oi-underline:before{content:'\e0d0'}.oi-vertical-align-bottom:before{content:'\e0d1'}.oi-vertical-align-center:before{content:'\e0d2'}.oi-vertical-align-top:before{content:'\e0d3'}.oi-video:before{content:'\e0d4'}.oi-volume-high:before{content:'\e0d5'}.oi-volume-low:before{content:'\e0d6'}.oi-volume-off:before{content:'\e0d7'}.oi-warning:before{content:'\e0d8'}.oi-wifi:before{content:'\e0d9'}.oi-wrench:before{content:'\e0da'}.oi-x:before{content:'\e0db'}.oi-yen:before{content:'\e0dc'}.oi-zoom-in:before{content:'\e0dd'}.oi-zoom-out:before{content:'\e0de'} -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JinShil/BlazorWebView/1b52948353a90fcee8801dd031f94261e92ee920/WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JinShil/BlazorWebView/1b52948353a90fcee8801dd031f94261e92ee920/WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.svg: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | 7 | 8 | Created by FontForge 20120731 at Tue Jul 1 20:39:22 2014 9 | By P.J. Onori 10 | Created by P.J. Onori with FontForge 2.0 (http://fontforge.sf.net) 11 | 12 | 13 | 14 | 27 | 28 | 30 | 32 | 34 | 36 | 38 | 40 | 42 | 45 | 47 | 49 | 51 | 53 | 55 | 57 | 59 | 61 | 63 | 65 | 67 | 69 | 71 | 74 | 76 | 79 | 81 | 84 | 86 | 88 | 91 | 93 | 95 | 98 | 100 | 102 | 104 | 106 | 109 | 112 | 115 | 117 | 121 | 123 | 125 | 127 | 130 | 132 | 134 | 136 | 138 | 141 | 143 | 145 | 147 | 149 | 151 | 153 | 155 | 157 | 159 | 162 | 165 | 167 | 169 | 172 | 174 | 177 | 179 | 181 | 183 | 185 | 189 | 191 | 194 | 196 | 198 | 200 | 202 | 205 | 207 | 209 | 211 | 213 | 215 | 218 | 220 | 222 | 224 | 226 | 228 | 230 | 232 | 234 | 236 | 238 | 241 | 243 | 245 | 247 | 249 | 251 | 253 | 256 | 259 | 261 | 263 | 265 | 267 | 269 | 272 | 274 | 276 | 280 | 282 | 285 | 287 | 289 | 292 | 295 | 298 | 300 | 302 | 304 | 306 | 309 | 312 | 314 | 316 | 318 | 320 | 322 | 324 | 326 | 330 | 334 | 338 | 340 | 343 | 345 | 347 | 349 | 351 | 353 | 355 | 358 | 360 | 363 | 365 | 367 | 369 | 371 | 373 | 375 | 377 | 379 | 381 | 383 | 386 | 388 | 390 | 392 | 394 | 396 | 399 | 401 | 404 | 406 | 408 | 410 | 412 | 414 | 416 | 419 | 421 | 423 | 425 | 428 | 431 | 435 | 438 | 440 | 442 | 444 | 446 | 448 | 451 | 453 | 455 | 457 | 460 | 462 | 464 | 466 | 468 | 471 | 473 | 477 | 479 | 481 | 483 | 486 | 488 | 490 | 492 | 494 | 496 | 499 | 501 | 504 | 506 | 509 | 512 | 515 | 517 | 520 | 522 | 524 | 526 | 529 | 532 | 534 | 536 | 539 | 542 | 543 | 544 | -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JinShil/BlazorWebView/1b52948353a90fcee8801dd031f94261e92ee920/WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/JinShil/BlazorWebView/1b52948353a90fcee8801dd031f94261e92ee920/WebKitGtk.Test/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /WebKitGtk.Test/wwwroot/index.html: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | 7 | AvaloniaBlazorAppTemplate 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 |
17 | 18 |
Loading...
19 | 20 |
21 | An unhandled error has occurred. 22 | Reload 23 | 🗙 24 |
25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /WebKitGtk/BlazorWebView.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using Microsoft.Extensions.FileProviders; 4 | using Microsoft.Extensions.Logging; 5 | using System.Runtime.Versioning; 6 | using System.Web; 7 | using WebKit; 8 | using MemoryInputStream = Gio.Internal.MemoryInputStream; 9 | using Uri = System.Uri; 10 | 11 | namespace WebKitGtk; 12 | 13 | [UnsupportedOSPlatform("OSX")] 14 | [UnsupportedOSPlatform("Windows")] 15 | public class BlazorWebView : WebView 16 | { 17 | public BlazorWebView(IServiceProvider serviceProvider) 18 | { 19 | _ = new WebViewManager(this, serviceProvider); 20 | } 21 | } 22 | 23 | [UnsupportedOSPlatform("OSX")] 24 | [UnsupportedOSPlatform("Windows")] 25 | class WebViewManager : Microsoft.AspNetCore.Components.WebView.WebViewManager 26 | { 27 | // Workaround for protection level access 28 | class InputStream : Gio.InputStream 29 | { 30 | protected internal InputStream(IntPtr ptr, bool ownedRef) : base(ptr, ownedRef) 31 | { } 32 | } 33 | 34 | const string Scheme = "app"; 35 | static readonly Uri BaseUri = new($"{Scheme}://localhost/"); 36 | 37 | public WebViewManager(WebView webView, IServiceProvider serviceProvider) : base( 38 | serviceProvider, 39 | Dispatcher.CreateDefault(), 40 | BaseUri, 41 | new PhysicalFileProvider(serviceProvider.GetRequiredService().ContentRoot), 42 | new(), 43 | serviceProvider.GetRequiredService().RelativeHostPath) 44 | { 45 | var options = serviceProvider.GetRequiredService(); 46 | _relativeHostPath = options.RelativeHostPath; 47 | var rootComponent = options.RootComponent; 48 | _logger = serviceProvider.GetService>(); 49 | 50 | _webView = webView; 51 | 52 | // This is necessary to automatically serve the files in the `_framework` virtual folder. 53 | // Using `file://` will cause the webview to look for the `_framework` files on the file system, 54 | // and it won't find them. 55 | if (_webView.WebContext is null) 56 | { 57 | throw new Exception("WebView.WebContext is null"); 58 | } 59 | _webView.WebContext.RegisterUriScheme(Scheme, HandleUriScheme); 60 | 61 | Dispatcher.InvokeAsync(async () => 62 | { 63 | await AddRootComponentAsync(rootComponent, "#app", ParameterView.Empty); 64 | }); 65 | 66 | var ucm = webView.GetUserContentManager(); 67 | ucm.AddScript(UserScript.New( 68 | source: 69 | """ 70 | window.__receiveMessageCallbacks = []; 71 | 72 | window.__dispatchMessageCallback = function(message) { 73 | window.__receiveMessageCallbacks.forEach(function(callback) { callback(message); }); 74 | }; 75 | 76 | window.external = { 77 | sendMessage: function(message) { 78 | window.webkit.messageHandlers.webview.postMessage(message); 79 | }, 80 | receiveMessage: function(callback) { 81 | window.__receiveMessageCallbacks.push(callback); 82 | } 83 | }; 84 | """, 85 | injectedFrames: UserContentInjectedFrames.AllFrames, 86 | injectionTime: UserScriptInjectionTime.Start, 87 | null, 88 | null) 89 | ); 90 | 91 | UserContentManager.ScriptMessageReceivedSignal.Connect(ucm, (_, signalArgs) => 92 | { 93 | var result = signalArgs.Value; 94 | MessageReceived(BaseUri, result.ToString()); 95 | }, true, "webview"); 96 | 97 | if (!ucm.RegisterScriptMessageHandler("webview", null)) 98 | { 99 | throw new Exception("Could not register script message handler"); 100 | } 101 | 102 | Navigate("/"); 103 | } 104 | 105 | readonly WebView _webView; 106 | readonly string _relativeHostPath; 107 | readonly ILogger? _logger; 108 | 109 | void HandleUriScheme(URISchemeRequest request) 110 | { 111 | if (request.GetScheme() != Scheme) 112 | { 113 | throw new Exception($"Invalid scheme \"{request.GetScheme()}\""); 114 | } 115 | 116 | var uri = request.GetUri(); 117 | if (request.GetPath() == "/") 118 | { 119 | uri += _relativeHostPath; 120 | } 121 | 122 | _logger?.LogDebug($"Fetching \"{uri}\""); 123 | 124 | if (TryGetResponseContent(uri, false, out var statusCode, out var statusMessage, out var content, out var headers)) 125 | { 126 | using var ms = new MemoryStream(); 127 | content.CopyTo(ms); 128 | var streamPtr = MemoryInputStream.NewFromData(ref ms.GetBuffer()[0], (uint)ms.Length, _ => { }); 129 | var inputStream = new InputStream(streamPtr, false); 130 | request.Finish(inputStream, ms.Length, headers["Content-Type"]); 131 | } 132 | else 133 | { 134 | throw new Exception($"Failed to serve \"{uri}\". {statusCode} - {statusMessage}"); 135 | } 136 | } 137 | 138 | protected override void NavigateCore(Uri absoluteUri) 139 | { 140 | _logger?.LogDebug($"Navigating to \"{absoluteUri}\""); 141 | _webView.LoadUri(absoluteUri.ToString()); 142 | } 143 | 144 | protected override async void SendMessage(string message) 145 | { 146 | var script = $"__dispatchMessageCallback(\"{HttpUtility.JavaScriptStringEncode(message)}\")"; 147 | _logger?.LogDebug($"Dispatching `{script}`"); 148 | _ = await _webView.EvaluateJavascriptAsync(script); 149 | } 150 | } -------------------------------------------------------------------------------- /WebKitGtk/BlazorWebViewOptions.cs: -------------------------------------------------------------------------------- 1 | namespace WebKitGtk; 2 | 3 | public record BlazorWebViewOptions 4 | { 5 | public required Type RootComponent { get; init; } 6 | public string HostPath { get; init; } = Path.Combine("wwwroot", "index.html"); 7 | public string ContentRoot => Path.GetDirectoryName(Path.GetFullPath(HostPath))!; 8 | public string RelativeHostPath => Path.GetRelativePath(ContentRoot, HostPath); 9 | } -------------------------------------------------------------------------------- /WebKitGtk/ServiceCollectionExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace WebKitGtk; 4 | 5 | public static class ServiceCollectionExtensions 6 | { 7 | public static IServiceCollection AddBlazorWebViewOptions(this IServiceCollection services, BlazorWebViewOptions options) 8 | { 9 | return services 10 | .AddBlazorWebView() 11 | .AddSingleton(options); 12 | } 13 | } -------------------------------------------------------------------------------- /WebKitGtk/WebKitGtk.csproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | net8.0 5 | enable 6 | enable 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | --------------------------------------------------------------------------------