├── Diff ├── _Imports.razor ├── DiffOutputFormat.cs ├── DiffInputTitle.cs ├── DiffStyle.cs ├── Diff.razor ├── ServiceCollectionExtension.cs ├── IDiff.cs ├── HtmlConfiguration.cs ├── DiffApi.cs ├── Diff.razor.cs ├── Diff.csproj ├── JsInterop.cs └── README.md ├── FFmpeg ├── _Imports.razor ├── Resources │ └── System.Private.Runtime.InteropServices.JavaScript.dll ├── IFFmpeg.cs ├── FFmpeg.cs ├── ServiceExtensions.cs ├── FFmpeg.csproj └── wwwroot │ └── ffmpeg.min.js ├── Split ├── _Imports.razor ├── SplitPane.razor ├── SplitDirection.cs ├── SplitGutterAlign.cs ├── Options.cs ├── JsInterop.cs ├── SplitPane.razor.cs ├── Split.razor ├── Split.csproj ├── Split.razor.cs └── README.md ├── StreamSaver ├── _Imports.razor ├── Resources │ └── System.Private.Runtime.InteropServices.JavaScript.dll ├── IStreamSaver.cs ├── ServiceExtensions.cs ├── README.md ├── StreamSaver.csproj ├── StreamSaver.cs ├── WritableFileStream.cs └── wwwroot │ ├── StreamSaver.min.js │ └── polyfill.min.js ├── doc ├── me.png └── Blazorme.gif ├── DemoApp ├── wwwroot │ ├── me.png │ ├── favicon.ico │ ├── css │ │ ├── open-iconic │ │ │ ├── font │ │ │ │ ├── fonts │ │ │ │ │ ├── open-iconic.eot │ │ │ │ │ ├── open-iconic.otf │ │ │ │ │ ├── open-iconic.ttf │ │ │ │ │ └── open-iconic.woff │ │ │ │ └── css │ │ │ │ │ └── open-iconic-bootstrap.min.css │ │ │ ├── ICON-LICENSE │ │ │ ├── README.md │ │ │ └── FONT-LICENSE │ │ └── app.css │ ├── sample-data │ │ └── weather.json │ └── index.html ├── Pages │ ├── Index.razor │ ├── SplitDemo.razor.cs │ ├── DiffDemo.razor.cs │ ├── StreamSaverDemo.razor │ ├── DiffDemo.razor │ ├── SplitDemo.razor │ └── StreamSaverDemo.razor.cs ├── App.razor ├── Models │ └── StreamSaverModel.cs ├── Shared │ ├── MainLayout.razor │ ├── NavMenu.razor.css │ ├── MainLayout.razor.css │ └── NavMenu.razor ├── _Imports.razor ├── DemoApp.csproj ├── Program.cs └── Properties │ └── launchSettings.json ├── TestHost ├── TestHtmlDocument.cs ├── README.md ├── MockHttpExtensions.cs ├── TestHost.csproj ├── RenderedComponent.cs ├── EventDispatchExtensions.cs ├── TestRenderer.cs ├── ContainerComponent.cs ├── TestHost.cs └── Htmlizer.cs ├── LICENSE ├── README.md ├── .gitattributes ├── Blazorme.sln └── .gitignore /Diff/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | -------------------------------------------------------------------------------- /FFmpeg/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | -------------------------------------------------------------------------------- /Split/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | -------------------------------------------------------------------------------- /StreamSaver/_Imports.razor: -------------------------------------------------------------------------------- 1 | @using Microsoft.AspNetCore.Components.Web 2 | -------------------------------------------------------------------------------- /doc/me.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/doc/me.png -------------------------------------------------------------------------------- /doc/Blazorme.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/doc/Blazorme.gif -------------------------------------------------------------------------------- /DemoApp/wwwroot/me.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/me.png -------------------------------------------------------------------------------- /DemoApp/wwwroot/favicon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/favicon.ico -------------------------------------------------------------------------------- /Split/SplitPane.razor: -------------------------------------------------------------------------------- 1 | @namespace Blazorme 2 | 3 |
4 | @ChildContent 5 |
6 | 7 | 8 | -------------------------------------------------------------------------------- /DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.eot -------------------------------------------------------------------------------- /DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.otf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.otf -------------------------------------------------------------------------------- /DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.ttf -------------------------------------------------------------------------------- /DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/DemoApp/wwwroot/css/open-iconic/font/fonts/open-iconic.woff -------------------------------------------------------------------------------- /Diff/DiffOutputFormat.cs: -------------------------------------------------------------------------------- 1 | namespace Blazorme 2 | { 3 | public enum DiffOutputFormat 4 | { 5 | Inline, 6 | Row, 7 | Column, 8 | } 9 | } 10 | -------------------------------------------------------------------------------- /FFmpeg/Resources/System.Private.Runtime.InteropServices.JavaScript.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/FFmpeg/Resources/System.Private.Runtime.InteropServices.JavaScript.dll -------------------------------------------------------------------------------- /StreamSaver/Resources/System.Private.Runtime.InteropServices.JavaScript.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/melihercan/Blazorme/HEAD/StreamSaver/Resources/System.Private.Runtime.InteropServices.JavaScript.dll -------------------------------------------------------------------------------- /Diff/DiffInputTitle.cs: -------------------------------------------------------------------------------- 1 | namespace Blazorme 2 | { 3 | public static class DiffInputTitle 4 | { 5 | public const string First = "First"; 6 | public const string Second = "Second"; 7 | } 8 | } 9 | -------------------------------------------------------------------------------- /Diff/DiffStyle.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Blazorme 6 | { 7 | public enum DiffStyle 8 | { 9 | Word, 10 | Char 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /Split/SplitDirection.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Blazorme 6 | { 7 | public enum SplitDirection 8 | { 9 | Horizontal, 10 | Vertical 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /FFmpeg/IFFmpeg.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Text; 5 | using System.Threading.Tasks; 6 | 7 | namespace Blazorme 8 | { 9 | public interface IFFmpeg 10 | { 11 | } 12 | } 13 | -------------------------------------------------------------------------------- /DemoApp/Pages/Index.razor: -------------------------------------------------------------------------------- 1 | 2 | @page "/" 3 | 4 |
5 | 6 |

Blazorme

7 | 8 |
Component libraries, © melihercan@@2020
9 | -------------------------------------------------------------------------------- /Split/SplitGutterAlign.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace Blazorme 6 | { 7 | public enum SplitGutterAlign 8 | { 9 | Center, 10 | Start, 11 | End, 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /FFmpeg/FFmpeg.cs: -------------------------------------------------------------------------------- 1 | using Blazorme; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace BlazormeFFmpeg 9 | { 10 | internal class FFmpeg : IFFmpeg 11 | { 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Diff/Diff.razor: -------------------------------------------------------------------------------- 1 | @namespace Blazorme 2 | @((MarkupString)_diff) 3 | 4 | 16 | 17 | -------------------------------------------------------------------------------- /StreamSaver/IStreamSaver.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.IO; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Blazorme 9 | { 10 | public interface IStreamSaver 11 | { 12 | Task CreateWritableFileStreamAsync(string fileName); 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /TestHost/TestHtmlDocument.cs: -------------------------------------------------------------------------------- 1 | using HtmlAgilityPack; 2 | 3 | namespace BlazormeTestHost 4 | { 5 | internal class TestHtmlDocument : HtmlDocument 6 | { 7 | public TestHtmlDocument(TestRenderer renderer) 8 | { 9 | Renderer = renderer; 10 | } 11 | 12 | public TestRenderer Renderer { get; } 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /Diff/ServiceCollectionExtension.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | 3 | namespace Blazorme 4 | { 5 | public static class ServiceCollectionExtension 6 | { 7 | public static IServiceCollection AddDiff(this IServiceCollection services) 8 | { 9 | return services.AddScoped(); 10 | } 11 | 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /DemoApp/App.razor: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 |

Sorry, there's nothing at this address.

8 |
9 |
10 |
11 | -------------------------------------------------------------------------------- /DemoApp/Models/StreamSaverModel.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Linq; 4 | using System.Threading.Tasks; 5 | 6 | namespace DemoApp.Models 7 | { 8 | public class StreamSaverModel 9 | { 10 | public string Filename { get; set; } 11 | public bool FilenameDisabled { get; set; } 12 | public string Text { get; set; } 13 | public int NumLoremIpsum { get; set; } 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /DemoApp/Pages/SplitDemo.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Threading.Tasks; 6 | 7 | namespace DemoApp.Pages 8 | { 9 | public partial class SplitDemo : ComponentBase 10 | { 11 | 12 | protected override Task OnInitializedAsync() 13 | { 14 | return base.OnInitializedAsync(); 15 | } 16 | } 17 | } 18 | -------------------------------------------------------------------------------- /DemoApp/Shared/MainLayout.razor: -------------------------------------------------------------------------------- 1 | @inherits LayoutComponentBase 2 | 3 |
4 | 7 | 8 |
9 |
10 | About 11 |
12 | 13 |
14 | @Body 15 |
16 |
17 |
18 | -------------------------------------------------------------------------------- /DemoApp/_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.AspNetCore.Components.WebAssembly.Http 8 | @using Microsoft.JSInterop 9 | @using DemoApp 10 | @using DemoApp.Shared 11 | @using DemoApp.Models 12 | @using Blazorme 13 | -------------------------------------------------------------------------------- /FFmpeg/ServiceExtensions.cs: -------------------------------------------------------------------------------- 1 | using BlazormeFFmpeg; 2 | using Microsoft.Extensions.DependencyInjection; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading.Tasks; 8 | 9 | namespace Blazorme 10 | { 11 | public static class FFmpegerviceExtensions 12 | { 13 | public static IServiceCollection AddFFmpeg(this IServiceCollection services) 14 | { 15 | services.AddSingleton(); 16 | 17 | return services; 18 | } 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /StreamSaver/ServiceExtensions.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.Extensions.DependencyInjection; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Linq; 5 | using System.Text; 6 | using System.Threading.Tasks; 7 | 8 | namespace Blazorme 9 | { 10 | public static class StreamSaverServiceExtensions 11 | { 12 | public static IServiceCollection AddStreamSaver(this IServiceCollection services) 13 | { 14 | services.AddSingleton(); 15 | 16 | return services; 17 | } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /DemoApp/wwwroot/sample-data/weather.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "date": "2018-05-06", 4 | "temperatureC": 1, 5 | "summary": "Freezing" 6 | }, 7 | { 8 | "date": "2018-05-07", 9 | "temperatureC": 14, 10 | "summary": "Bracing" 11 | }, 12 | { 13 | "date": "2018-05-08", 14 | "temperatureC": -13, 15 | "summary": "Freezing" 16 | }, 17 | { 18 | "date": "2018-05-09", 19 | "temperatureC": -16, 20 | "summary": "Balmy" 21 | }, 22 | { 23 | "date": "2018-05-10", 24 | "temperatureC": -2, 25 | "summary": "Chilly" 26 | } 27 | ] 28 | -------------------------------------------------------------------------------- /Split/Options.cs: -------------------------------------------------------------------------------- 1 | using System; 2 | using System.Collections.Generic; 3 | using System.Text; 4 | 5 | namespace BlazormeSplit 6 | { 7 | public class Options 8 | { 9 | public int[] Sizes { get; set; } 10 | public int[] MinSize { get; set; } 11 | public bool ExpandToMin { get; set; } 12 | public int GutterSize { get; set; } 13 | public string GutterAlign { get; set; } 14 | public int SnapOffset { get; set; } 15 | public int DragInterval { get; set; } 16 | public string Direction { get; set; } 17 | public string Cursor { get; set; } 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /Diff/IDiff.cs: -------------------------------------------------------------------------------- 1 | using System.Threading.Tasks; 2 | 3 | namespace Blazorme 4 | { 5 | public interface IDiff 6 | { 7 | public Task GetAsync(string firstInput, string secondInput, 8 | string firstTitle = DiffInputTitle.First, string secondTitle = DiffInputTitle.Second); 9 | 10 | public Task GetHtmlAsync(string firstInput, string secondInput, 11 | string firstTitle = DiffInputTitle.First, string secondTitle = DiffInputTitle.Second, 12 | DiffOutputFormat outputFormat = DiffOutputFormat.Inline, 13 | DiffStyle style = DiffStyle.Word); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /Split/JsInterop.cs: -------------------------------------------------------------------------------- 1 | using BlazormeSplit; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.JSInterop; 4 | using System.Threading.Tasks; 5 | 6 | namespace BlazormeSplit 7 | { 8 | internal class JsInterop 9 | { 10 | internal static async ValueTask InvokeAsync(IJSRuntime jsRuntime, ElementReference[] elements, 11 | Options options) 12 | { 13 | await jsRuntime.InvokeAsync( 14 | "Split", 15 | new object[] 16 | { 17 | elements, 18 | options 19 | }); 20 | 21 | } 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /TestHost/README.md: -------------------------------------------------------------------------------- 1 | # Blazorme.TestHost 2 | Support library for Blazor component unit testing. The source code is taken from Steve Sanderson's [BlazorUnitTestingPrototype](https://github.com/SteveSandersonMS/BlazorUnitTestingPrototype) project. See his [blog post](https://blog.stevensanderson.com/2019/08/29/blazor-unit-testing-prototype/ 3 | ) for more details. His project is available only as source code. I believe getting this library as NuGet package is much more convenient. Therefore I integrated his code into a NuGet package with updated packages. 4 | 5 | I have also added .NET5 support. The original code (.NetStandard2.0) was broken ([see the discussion thread](https://github.com/dotnet/aspnetcore/issues/25727)) when used with .NET5 components/applications. NuGet now supports both .NetStandard2.1 and .NET5. 6 | 7 | 8 | -------------------------------------------------------------------------------- /FFmpeg/FFmpeg.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | BlazormeFFmpeg 6 | Blazorme.FFmpeg 7 | true 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | Resources\System.Private.Runtime.InteropServices.JavaScript.dll 22 | false 23 | 24 | 25 | 26 | 27 | -------------------------------------------------------------------------------- /DemoApp/DemoApp.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | -------------------------------------------------------------------------------- /Split/SplitPane.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.Text; 5 | 6 | namespace Blazorme 7 | { 8 | public partial class SplitPane 9 | { 10 | [CascadingParameter] 11 | private Split _split { get; set; } 12 | 13 | [Parameter] 14 | public int SizeInPercentage { get; set; } 15 | 16 | [Parameter] 17 | public int? MinSize { get; set; } 18 | 19 | [Parameter] 20 | public RenderFragment ChildContent { get; set; } 21 | 22 | public ElementReference ElementReference; 23 | 24 | protected override void OnInitialized() 25 | { 26 | base.OnInitialized(); 27 | 28 | if(_split == null) 29 | { 30 | throw new Exception("SplitPane should be a child of Split"); 31 | } 32 | _split.AddSplitPane(this); 33 | } 34 | } 35 | } 36 | -------------------------------------------------------------------------------- /DemoApp/Program.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components.WebAssembly.Hosting; 2 | using Microsoft.Extensions.Configuration; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Net.Http; 8 | using System.Text; 9 | using System.Threading.Tasks; 10 | using Blazorme; 11 | 12 | namespace DemoApp 13 | { 14 | public class Program 15 | { 16 | public static async Task Main(string[] args) 17 | { 18 | var builder = WebAssemblyHostBuilder.CreateDefault(args); 19 | builder.RootComponents.Add("#app"); 20 | 21 | builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) }); 22 | 23 | builder.Services.AddDiff(); 24 | builder.Services.AddStreamSaver(); 25 | 26 | await builder.Build().RunAsync(); 27 | } 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Split/Split.razor: -------------------------------------------------------------------------------- 1 | @namespace Blazorme 2 | @using System.Drawing; 3 | 4 | 32 | 33 | 34 |
35 | 36 | @ChildContent 37 | 38 |
39 | 40 | -------------------------------------------------------------------------------- /Diff/HtmlConfiguration.cs: -------------------------------------------------------------------------------- 1 | namespace BlazormeDiff 2 | { 3 | public class HtmlConfiguration 4 | { 5 | // "line-by-line" or "side-by-side", default is "line-by-line" 6 | internal const string SideBySide = "side-by-side"; 7 | internal const string LineByLine = "line-by-line"; 8 | public string OutputFormat { get; set; } 9 | 10 | // default is true 11 | public bool DrawFileList { get; set; } 12 | 13 | // show differences level in each line: word or char, default is word 14 | internal const string Word = "word"; 15 | internal const string Char = "char"; 16 | public string DiffStyle { get; set; } 17 | 18 | // matching level: 'lines' for matching lines, 'words' for matching lines and words or 'none', default is none 19 | internal const string Lines = "lines"; 20 | internal const string Words = "words"; 21 | internal const string None = "none"; 22 | public string Matching { get; set; } 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /DemoApp/Properties/launchSettings.json: -------------------------------------------------------------------------------- 1 | { 2 | "iisSettings": { 3 | "windowsAuthentication": false, 4 | "anonymousAuthentication": true, 5 | "iisExpress": { 6 | "applicationUrl": "http://localhost:60941", 7 | "sslPort": 44391 8 | } 9 | }, 10 | "profiles": { 11 | "IIS Express": { 12 | "commandName": "IISExpress", 13 | "launchBrowser": true, 14 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 15 | "environmentVariables": { 16 | "ASPNETCORE_ENVIRONMENT": "Development" 17 | } 18 | }, 19 | "DemoApp": { 20 | "commandName": "Project", 21 | "dotnetRunMessages": "true", 22 | "launchBrowser": true, 23 | "inspectUri": "{wsProtocol}://{url.hostname}:{url.port}/_framework/debug/ws-proxy?browser={browserInspectUri}", 24 | "applicationUrl": "https://localhost:5001;http://localhost:5000", 25 | "environmentVariables": { 26 | "ASPNETCORE_ENVIRONMENT": "Development" 27 | } 28 | } 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2020 melihercan 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy of 6 | this software and associated documentation files (the "Software"), to deal in 7 | the Software without restriction, including without limitation the rights to 8 | use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 9 | of the Software, and to permit persons to whom the Software is furnished to do 10 | so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | 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 THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /DemoApp/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 | a, .btn-link { 8 | color: #0366d6; 9 | } 10 | 11 | .btn-primary { 12 | color: #fff; 13 | background-color: #1b6ec2; 14 | border-color: #1861ac; 15 | } 16 | 17 | .content { 18 | padding-top: 1.1rem; 19 | } 20 | 21 | .valid.modified:not([type=checkbox]) { 22 | outline: 1px solid #26b050; 23 | } 24 | 25 | .invalid { 26 | outline: 1px solid red; 27 | } 28 | 29 | .validation-message { 30 | color: red; 31 | } 32 | 33 | #blazor-error-ui { 34 | background: lightyellow; 35 | bottom: 0; 36 | box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.2); 37 | display: none; 38 | left: 0; 39 | padding: 0.6rem 1.25rem 0.7rem 1.25rem; 40 | position: fixed; 41 | width: 100%; 42 | z-index: 1000; 43 | } 44 | 45 | #blazor-error-ui .dismiss { 46 | cursor: pointer; 47 | position: absolute; 48 | right: 0.75rem; 49 | top: 0.5rem; 50 | } 51 | -------------------------------------------------------------------------------- /DemoApp/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. -------------------------------------------------------------------------------- /Diff/DiffApi.cs: -------------------------------------------------------------------------------- 1 | using BlazormeDiff; 2 | using Microsoft.JSInterop; 3 | using System.Threading.Tasks; 4 | 5 | namespace Blazorme 6 | { 7 | public class DiffApi : IDiff 8 | { 9 | private readonly IJSRuntime _jsRuntime; 10 | 11 | public DiffApi(IJSRuntime jsRuntime) 12 | { 13 | _jsRuntime = jsRuntime; 14 | } 15 | 16 | public async Task GetAsync(string firstInput, string secondInput, 17 | string firstTitle, string secondTitle) 18 | { 19 | return await JsInterop.GetAsync(_jsRuntime, firstInput, secondInput, firstTitle, secondTitle); 20 | } 21 | 22 | public async Task GetHtmlAsync(string firstInput, string secondInput, 23 | string firstTitle, string secondTitle, 24 | DiffOutputFormat outputFormat, DiffStyle style) 25 | { 26 | if (outputFormat == DiffOutputFormat.Inline) 27 | { 28 | return new HtmlDiff.HtmlDiff(firstInput, secondInput).Build(); 29 | } 30 | else 31 | { 32 | return await JsInterop.GetHtmlAsync(_jsRuntime, firstInput, secondInput, firstTitle, secondTitle, 33 | outputFormat, style); 34 | } 35 | } 36 | } 37 | } 38 | -------------------------------------------------------------------------------- /DemoApp/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 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Blazorme 2 | This project provides utility component libraries for Blazor apps. 3 | Currently three component libraries have been implemented: 4 | * [Blazorme.Diff:](Diff/README.md) It will render diff of the two input strings in different output display formats. 5 | It can also be used as a library to get diff or html diff output strings from code behind. [![NuGet](https://img.shields.io/nuget/v/Blazorme.Diff.svg)](https://www.nuget.org/packages/Blazorme.Diff) 6 | * [Blazorme.Split:](Split/README.md) It provides resizeable split views (panes). [![NuGet](https://img.shields.io/nuget/v/Blazorme.Split.svg)](https://www.nuget.org/packages/Blazorme.Split) 7 | * [Blazorme.TestHost:](TestHost/README.md) Library for Blazor components unit testing. [![NuGet](https://img.shields.io/nuget/v/Blazorme.TestHost.svg)](https://www.nuget.org/packages/Blazorme.TestHost) 8 | * [Blazorme.StreamSaver:](StreamSaver/README.md) (WASM only) Download files by writing incoming data chunks directly to the file instead of accumulating them in memory. That will prevent memory overflows for very large files. [![NuGet](https://img.shields.io/nuget/v/Blazorme.StreamSaver.svg)](https://www.nuget.org/packages/Blazorme.StreamSaver) 9 | 10 | 11 | You can run the [Demo](https://melihercan.github.io/) here. 12 | 13 | ![alt text](https://github.com/melihercan/Blazorme/blob/master/doc/Blazorme.gif) 14 | -------------------------------------------------------------------------------- /DemoApp/Pages/DiffDemo.razor.cs: -------------------------------------------------------------------------------- 1 | using Blazorme; 2 | using Markdig; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Components.Web; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Linq; 8 | using System.Threading.Tasks; 9 | 10 | namespace DemoApp.Pages 11 | { 12 | public partial class DiffDemo : ComponentBase 13 | { 14 | [Inject] 15 | private IDiff _diffApi { get; set; } 16 | 17 | public string Body1 { get; set; } = string.Empty; 18 | public string Preview1 => Markdown.ToHtml(Body1); 19 | public string Body2 { get; set; } = string.Empty; 20 | public string Preview2 => Markdown.ToHtml(Body2); 21 | 22 | protected override async Task OnInitializedAsync() 23 | { 24 | await base.OnInitializedAsync(); 25 | 26 | // API usage example. 27 | var firstInput = "Hello World"; 28 | var secondInput = "Hell World!"; 29 | var diff = await _diffApi.GetAsync(firstInput, secondInput); 30 | var diffHtml = await _diffApi.GetHtmlAsync(firstInput, secondInput, 31 | DiffInputTitle.First, DiffInputTitle.Second, 32 | DiffOutputFormat.Row, DiffStyle.Word); 33 | Console.WriteLine("diff:"); 34 | Console.WriteLine(diff); 35 | Console.WriteLine("diffHtml:"); 36 | Console.WriteLine(diffHtml); 37 | } 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /TestHost/MockHttpExtensions.cs: -------------------------------------------------------------------------------- 1 | using RichardSzalay.MockHttp; 2 | using System; 3 | using System.Net; 4 | using System.Net.Http; 5 | using System.Threading.Tasks; 6 | using System.Text.Json; 7 | using System.Net.Http.Headers; 8 | 9 | namespace Blazorme 10 | { 11 | public static class MockHttpExtensions 12 | { 13 | public static MockHttpMessageHandler AddMockHttp(this TestHost host) 14 | { 15 | var mockHttp = new MockHttpMessageHandler(); 16 | var httpClient = mockHttp.ToHttpClient(); 17 | httpClient.BaseAddress = new Uri("http://example.com"); 18 | host.AddService(httpClient); 19 | return mockHttp; 20 | } 21 | 22 | public static TaskCompletionSource Capture(this MockHttpMessageHandler handler, string url) 23 | { 24 | var tcs = new TaskCompletionSource(); 25 | 26 | handler.When(url).Respond(() => 27 | { 28 | return tcs.Task.ContinueWith(task => 29 | { 30 | var response = new HttpResponseMessage(HttpStatusCode.OK); 31 | response.Content = new StringContent(JsonSerializer.Serialize(task.Result)); 32 | response.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json"); 33 | return response; 34 | }); 35 | }); 36 | 37 | return tcs; 38 | } 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Diff/Diff.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using System.Threading.Tasks; 3 | 4 | namespace Blazorme 5 | { 6 | public partial class Diff 7 | { 8 | private string _diff { get; set; } = string.Empty; 9 | 10 | [Inject] 11 | private IDiff _diffApi { get; set; } 12 | 13 | [Parameter] 14 | public string FirstInput { get; set; } = string.Empty; 15 | 16 | [Parameter] 17 | public string SecondInput { get; set; } = string.Empty; 18 | 19 | [Parameter] 20 | public string FirstTitle { get; set; } = DiffInputTitle.First; 21 | 22 | [Parameter] 23 | public string SecondTitle { get; set; } = DiffInputTitle.Second; 24 | 25 | [Parameter] 26 | public DiffOutputFormat OutputFormat { get; set; } = DiffOutputFormat.Inline; 27 | 28 | [Parameter] 29 | public DiffStyle Style { get; set; } = DiffStyle.Word; 30 | 31 | protected override async Task OnInitializedAsync() 32 | { 33 | await base.OnInitializedAsync(); 34 | 35 | _diff = await _diffApi.GetHtmlAsync(FirstInput, SecondInput, FirstTitle, SecondTitle, OutputFormat, Style); 36 | } 37 | 38 | protected override async Task OnParametersSetAsync() 39 | { 40 | await base.OnParametersSetAsync(); 41 | 42 | _diff = await _diffApi.GetHtmlAsync(FirstInput, SecondInput, FirstTitle, SecondTitle, OutputFormat, Style); 43 | } 44 | } 45 | } 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /DemoApp/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 .btn-link { 25 | white-space: nowrap; 26 | margin-left: 1.5rem; 27 | } 28 | 29 | .top-row a:first-child { 30 | overflow: hidden; 31 | text-overflow: ellipsis; 32 | } 33 | 34 | @media (max-width: 640.98px) { 35 | .top-row:not(.auth) { 36 | display: none; 37 | } 38 | 39 | .top-row.auth { 40 | justify-content: space-between; 41 | } 42 | 43 | .top-row a, .top-row .btn-link { 44 | margin-left: 0; 45 | } 46 | } 47 | 48 | @media (min-width: 641px) { 49 | .page { 50 | flex-direction: row; 51 | } 52 | 53 | .sidebar { 54 | width: 250px; 55 | height: 100vh; 56 | position: sticky; 57 | top: 0; 58 | } 59 | 60 | .top-row { 61 | position: sticky; 62 | top: 0; 63 | z-index: 1; 64 | } 65 | 66 | .main > div { 67 | padding-left: 2rem !important; 68 | padding-right: 1.5rem !important; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /DemoApp/Shared/NavMenu.razor: -------------------------------------------------------------------------------- 1 | 7 | 8 |
9 | 31 |
32 | 33 | @code { 34 | private bool collapseNavMenu = true; 35 | 36 | private string NavMenuCssClass => collapseNavMenu ? "collapse" : null; 37 | 38 | private void ToggleNavMenu() 39 | { 40 | collapseNavMenu = !collapseNavMenu; 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /DemoApp/Pages/StreamSaverDemo.razor: -------------------------------------------------------------------------------- 1 | @page "/streamsaverdemo" 2 | 3 |

StreamSaverDemo

4 | 5 | 6 |
7 | 8 | 11 |
12 | 13 |
14 | 15 | 18 | 21 |
22 | 23 |
24 | 25 | 28 |
29 | 30 |
31 | 34 | 37 | 40 |
41 |
42 | 43 | 44 | @code { 45 | 46 | } 47 | -------------------------------------------------------------------------------- /StreamSaver/README.md: -------------------------------------------------------------------------------- 1 | # Blazorme.StreamSaver 2 | JSInterop of [StreamSaver](https://github.com/jimmywarting/StreamSaver.js) package for Blazor WASM. 3 | With this package, you can download files by writing incoming data chunks directly to the file instead of accumulating them in memory. 4 | This will prevent memory overflows for very large files. 5 | 6 | It provides a very simple API: 7 | ```cs 8 | public interface IStreamSaver 9 | { 10 | Task CreateWritableFileStreamAsync(string fileName); 11 | } 12 | ``` 13 | With this call, a C# stream will be returned to the caller. The caller can write(append) data chunks to the file by calling the `Stream` interface `WriteAsync` call. 14 | After all chunks are written, `Close` call on the stream will complete the file download. 15 | 16 | ## Installation 17 | * Install NuGet package: 18 | ``` 19 | Install-Package Blazorme.StreamSaver 20 | ``` 21 | ## Using 22 | 23 | In `_Imports.razor` add: 24 | ``` 25 | @using Blazorme 26 | ``` 27 | In a `razor` file add: 28 | ```cs 29 | [Inject] 30 | IStreamSaver StreamSaver { get; set; } 31 | ``` 32 | From code behind, inject the interface to your constructor: 33 | ```cs 34 | using Blazorme; 35 | ``` 36 | ```cs 37 | Xxx(IStreamSaver streamSaver, ...) 38 | ``` 39 | 40 | ## JS references 41 | 42 | Add the following lines to your `index.html` file: 43 | ```html 44 | 45 | 46 | 47 | 48 | ``` 49 | ## Service addition 50 | 51 | Add the following to `Program.cs`: 52 | ```cs 53 | using Blazorme; 54 | 55 | Main 56 | { 57 | ... 58 | builder.Services.AddStreamSaver(); 59 | ... 60 | } 61 | ``` 62 | 63 | -------------------------------------------------------------------------------- /Split/Split.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net5.0 5 | 3.0 6 | true 7 | melihercan 8 | melihercan 9 | Blazorme.Split 10 | Split component library for Blazor apps. 11 | It provides resizeable split views (panes). 12 | melihercan 2020 13 | MIT 14 | me.png 15 | https://github.com/melihercan/Blazorme 16 | git 17 | blazor split resizable panes components 18 | Added .NET 5 support. 19 | Blazorme.Split 20 | Blazorme.Split 21 | BlazormeSplit 22 | 1.0.1 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | True 40 | 41 | 42 | 43 | 44 | 45 | -------------------------------------------------------------------------------- /StreamSaver/StreamSaver.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | net5.0 5 | BlazormeStreamSaver 6 | Blazorme.StreamSaver 7 | true 8 | melihercan 9 | JSInterop of StreamSaver (https://github.com/jimmywarting/StreamSaver.js) package for Blazor WASM. 10 | With this package, you can download files by writing incoming data chunks directly to the file instead of accumulating them in memory. That will prevent memory overflows for very large files. 11 | melihercan2021 12 | MIT 13 | me.png 14 | 15 | https://github.com/melihercan/Blazorme 16 | git 17 | blazor file download writable stream 18 | Creation 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | True 37 | 38 | 39 | 40 | 41 | 42 | 43 | Resources\System.Private.Runtime.InteropServices.JavaScript.dll 44 | false 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /Diff/Diff.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net5.0 5 | 3.0 6 | true 7 | Blazorme.Diff 8 | melihercan 9 | melihercan 10 | Blazorme.Diff 11 | Diff component library for Blazor apps. 12 | It will render diff of the two input strings in different output display formats. 13 | It can also be used as a library to get diff or html diff output strings from code behind. 14 | melihercan 2020 15 | 16 | 17 | https://github.com/melihercan/Blazorme 18 | Added .NET 5 support. 19 | blazor diff components 20 | MIT 21 | git 22 | me.png 23 | 1.0.2 24 | Blazorme.Diff 25 | BlazormeDiff 26 | 27 | 28 | 29 | 30 | True 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 | 46 | 47 | 48 | 49 | -------------------------------------------------------------------------------- /DemoApp/Pages/DiffDemo.razor: -------------------------------------------------------------------------------- 1 | @page "/diffdemo" 2 | 3 |
4 | 5 |

Diff inputs

6 |
7 | 8 |

@DiffInputTitle.First

9 |
10 |
11 |
type text or markdown...
12 | 13 |
14 |
15 |
and see it in HTML
16 | @((MarkupString) Preview1) 17 |
18 |
19 |
20 | 21 |

@DiffInputTitle.Second

22 |
23 |
24 |
type text or markdown...
25 | 26 |
27 |
28 |
and see it in HTML
29 | @((MarkupString) Preview2) 30 |
31 |
32 |
33 |
34 |
35 | 36 | 37 |
38 |

Diff outputs

39 |
40 | 41 |

Inline

42 |
43 | 45 |
46 |
47 | 48 |

Row

49 | 55 |
56 | 57 |

Column

58 | 64 |
65 |
66 |
67 | 68 | 69 | -------------------------------------------------------------------------------- /TestHost/TestHost.csproj: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | netstandard2.1;net5.0 5 | BlazormeTestHost 6 | Steve Sanderson's TestHost implementation as NuGet package from his BlazorUnitTestingPrototype project source code. This library provides helpers for unit testing of Blazor components. Additionally .NET5 support has been provided. NuGet now supports both .NetStandard2.1 and .NET5. See the following links for more details: 7 | https://blog.stevensanderson.com/2019/08/29/blazor-unit-testing-prototype/ 8 | https://github.com/SteveSandersonMS/BlazorUnitTestingPrototype 9 | 10 | Blazorme.TestHost 11 | melihercan 12 | Blazorme.TestHost 13 | melihercan 2020 14 | MIT 15 | me.png 16 | https://github.com/melihercan/Blazorme 17 | git 18 | blazor testing TestHost 19 | First version. 20 | true 21 | Blazorme.TestHost 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | True 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /TestHost/RenderedComponent.cs: -------------------------------------------------------------------------------- 1 | using BlazormeTestHost; 2 | using Fizzler.Systems.HtmlAgilityPack; 3 | using HtmlAgilityPack; 4 | using Microsoft.AspNetCore.Components; 5 | using System.Collections.Generic; 6 | using System.Linq; 7 | 8 | namespace Blazorme 9 | { 10 | public class RenderedComponent where TComponent : IComponent 11 | { 12 | private readonly TestRenderer _renderer; 13 | private readonly ContainerComponent _containerTestRootComponent; 14 | private int _testComponentId; 15 | private TComponent _testComponentInstance; 16 | 17 | internal RenderedComponent(TestRenderer renderer) 18 | { 19 | _renderer = renderer; 20 | _containerTestRootComponent = new ContainerComponent(_renderer); 21 | } 22 | 23 | public TComponent Instance => _testComponentInstance; 24 | 25 | public string GetMarkup() 26 | { 27 | return Htmlizer.GetHtml(_renderer, _testComponentId); 28 | } 29 | 30 | internal void SetParametersAndRender(ParameterView parameters) 31 | { 32 | _containerTestRootComponent.RenderComponentUnderTest( 33 | typeof(TComponent), parameters); 34 | var foundTestComponent = _containerTestRootComponent.FindComponentUnderTest(); 35 | _testComponentId = foundTestComponent.Item1; 36 | _testComponentInstance = (TComponent)foundTestComponent.Item2; 37 | } 38 | 39 | public HtmlNode Find(string selector) 40 | { 41 | return FindAll(selector).FirstOrDefault(); 42 | } 43 | 44 | public ICollection FindAll(string selector) 45 | { 46 | // Rather than using HTML strings, it would be faster and more powerful 47 | // to implement Fizzler's APIs for walking directly over the rendered 48 | // frames, since Fizzler's core isn't tied to HTML (or HtmlAgilityPack). 49 | // The most awkward part of this will be handling Markup frames, since 50 | // they are HTML strings so would need to be parsed, or perhaps you can 51 | // pass through those calls into Fizzler.Systems.HtmlAgilityPack. 52 | 53 | var markup = GetMarkup(); 54 | var html = new TestHtmlDocument(_renderer); 55 | 56 | html.LoadHtml(markup); 57 | return html.DocumentNode.QuerySelectorAll(selector).ToList(); 58 | } 59 | } 60 | } 61 | -------------------------------------------------------------------------------- /DemoApp/wwwroot/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | DemoApp 8 | 9 | 10 | 11 | 12 | 16 | 17 | 18 | 19 |
Loading...
20 | 21 |
22 | An unhandled error has occurred. 23 | Reload 24 | 🗙 25 |
26 | 27 | 28 | 29 | 32 | 35 | 38 | 42 | 46 | 47 | 48 | 49 | 50 | 51 | 52 | 53 | 54 | -------------------------------------------------------------------------------- /Diff/JsInterop.cs: -------------------------------------------------------------------------------- 1 | using Blazorme; 2 | using Microsoft.JSInterop; 3 | using System.Threading.Tasks; 4 | 5 | namespace BlazormeDiff 6 | { 7 | internal class JsInterop 8 | { 9 | internal static async ValueTask GetAsync(IJSRuntime jsRuntime, 10 | string firstInput, string secondInput, 11 | string firstTitle, string secondTitle) 12 | { 13 | return await jsRuntime.InvokeAsync( 14 | "Diff.createTwoFilesPatch", 15 | new object[] 16 | { 17 | firstTitle, secondTitle, firstInput, secondInput 18 | }); 19 | } 20 | 21 | internal static async ValueTask GetHtmlAsync(IJSRuntime jsRuntime, 22 | string firstInput, string secondInput, 23 | string firstTitle, string secondTitle, 24 | DiffOutputFormat outputFormat, DiffStyle style) 25 | { 26 | var diff = await GetAsync(jsRuntime, firstInput, secondInput, firstTitle, secondTitle); 27 | 28 | string styleStr = style == DiffStyle.Word ? HtmlConfiguration.Word : HtmlConfiguration.Char; 29 | return outputFormat switch 30 | { 31 | DiffOutputFormat.Row => await jsRuntime.InvokeAsync( 32 | "Diff2Html.html", 33 | new object[] 34 | { 35 | diff, 36 | new HtmlConfiguration 37 | { 38 | DiffStyle = styleStr, 39 | DrawFileList = false, 40 | Matching = HtmlConfiguration.Words, 41 | OutputFormat = HtmlConfiguration.LineByLine 42 | } 43 | }), 44 | 45 | DiffOutputFormat.Column => await jsRuntime.InvokeAsync( 46 | "Diff2Html.html", 47 | new object[] 48 | { 49 | diff, 50 | new HtmlConfiguration 51 | { 52 | DiffStyle = styleStr, 53 | DrawFileList = false, 54 | Matching = HtmlConfiguration.Words, 55 | OutputFormat = HtmlConfiguration.SideBySide 56 | } 57 | }), 58 | 59 | _ => string.Empty, 60 | }; 61 | } 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /DemoApp/Pages/SplitDemo.razor: -------------------------------------------------------------------------------- 1 | @page "/splitdemo" 2 | 3 |
4 | 5 | 6 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 7 | 8 | 9 | 10 | 11 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 12 | 13 | 14 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 15 | 16 | 17 | 18 | 19 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 20 | 21 | 22 |
23 | -------------------------------------------------------------------------------- /TestHost/EventDispatchExtensions.cs: -------------------------------------------------------------------------------- 1 | using BlazormeTestHost; 2 | using HtmlAgilityPack; 3 | using Microsoft.AspNetCore.Components; 4 | using Microsoft.AspNetCore.Components.RenderTree; 5 | using Microsoft.AspNetCore.Components.Web; 6 | using System; 7 | using System.Diagnostics.CodeAnalysis; 8 | using System.Threading.Tasks; 9 | 10 | namespace Blazorme 11 | { 12 | public static class EventDispatchExtensions 13 | { 14 | public static void Click(this HtmlNode element) 15 | { 16 | _ = ClickAsync(element); 17 | } 18 | 19 | public static Task ClickAsync(this HtmlNode element) 20 | { 21 | return element.TriggerEventAsync("onclick", new MouseEventArgs()); 22 | } 23 | public static void Submit(this HtmlNode element) 24 | { 25 | _ = SubmitAsync(element); 26 | } 27 | 28 | public static Task SubmitAsync(this HtmlNode element) 29 | { 30 | return element.TriggerEventAsync("onsubmit", new EventArgs()); 31 | } 32 | 33 | public static void Change(this HtmlNode element, string newValue) 34 | { 35 | _ = ChangeAsync(element, newValue); 36 | } 37 | 38 | public static Task ChangeAsync(this HtmlNode element, string newValue) 39 | { 40 | return element.TriggerEventAsync("onchange", new ChangeEventArgs { Value = newValue }); 41 | } 42 | 43 | public static void Change(this HtmlNode element, bool newValue) 44 | { 45 | _ = ChangeAsync(element, newValue); 46 | } 47 | 48 | public static Task ChangeAsync(this HtmlNode element, bool newValue) 49 | { 50 | return element.TriggerEventAsync("onchange", new ChangeEventArgs { Value = newValue }); 51 | } 52 | 53 | [SuppressMessage("Usage", "BL0006:Do not use RenderTree types", Justification = "")] 54 | public static Task TriggerEventAsync(this HtmlNode element, string attributeName, EventArgs eventArgs) 55 | { 56 | var eventHandlerIdString = element.GetAttributeValue(attributeName, string.Empty); 57 | if (string.IsNullOrEmpty(eventHandlerIdString)) 58 | { 59 | throw new ArgumentException($"The element does not have an event handler for the event '{attributeName}'."); 60 | } 61 | var eventHandlerId = ulong.Parse(eventHandlerIdString); 62 | 63 | var renderer = ((TestHtmlDocument)element.OwnerDocument).Renderer; 64 | return renderer.DispatchEventAsync(eventHandlerId, 65 | new EventFieldInfo(), 66 | eventArgs); 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /TestHost/TestRenderer.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.RenderTree; 3 | using Microsoft.Extensions.Logging; 4 | using System; 5 | using System.Diagnostics.CodeAnalysis; 6 | using System.Runtime.ExceptionServices; 7 | using System.Threading.Tasks; 8 | 9 | namespace BlazormeTestHost 10 | { 11 | [SuppressMessage("Usage", "BL0006:Do not use RenderTree types", Justification = "")] 12 | internal class TestRenderer : Renderer 13 | { 14 | private Exception _unhandledException; 15 | 16 | private TaskCompletionSource _nextRenderTcs = new TaskCompletionSource(); 17 | 18 | public TestRenderer(IServiceProvider serviceProvider, ILoggerFactory loggerFactory) 19 | : base(serviceProvider, loggerFactory) 20 | { 21 | } 22 | 23 | public new ArrayRange GetCurrentRenderTreeFrames(int componentId) 24 | => base.GetCurrentRenderTreeFrames(componentId); 25 | 26 | public int AttachTestRootComponent(ContainerComponent testRootComponent) 27 | => AssignRootComponentId(testRootComponent); 28 | 29 | public new Task DispatchEventAsync(ulong eventHandlerId, EventFieldInfo fieldInfo, EventArgs eventArgs) 30 | { 31 | var task = Dispatcher.InvokeAsync( 32 | () => base.DispatchEventAsync(eventHandlerId, fieldInfo, eventArgs)); 33 | AssertNoSynchronousErrors(); 34 | return task; 35 | } 36 | 37 | public override Dispatcher Dispatcher { get; } = Dispatcher.CreateDefault(); 38 | 39 | public Task NextRender => _nextRenderTcs.Task; 40 | 41 | protected override void HandleException(Exception exception) 42 | { 43 | _unhandledException = exception; 44 | } 45 | 46 | protected override Task UpdateDisplayAsync(in RenderBatch renderBatch) 47 | { 48 | // TODO: Capture batches (and the state of component output) for individual inspection 49 | var prevTcs = _nextRenderTcs; 50 | _nextRenderTcs = new TaskCompletionSource(); 51 | prevTcs.SetResult(null); 52 | return Task.CompletedTask; 53 | } 54 | 55 | public void DispatchAndAssertNoSynchronousErrors(Action callback) 56 | { 57 | Dispatcher.InvokeAsync(callback).Wait(); 58 | AssertNoSynchronousErrors(); 59 | } 60 | 61 | private void AssertNoSynchronousErrors() 62 | { 63 | if (_unhandledException != null) 64 | { 65 | ExceptionDispatchInfo.Capture(_unhandledException).Throw(); 66 | } 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /DemoApp/Pages/StreamSaverDemo.razor.cs: -------------------------------------------------------------------------------- 1 | using Blazorme; 2 | using BlazormeStreamSaver; 3 | using DemoApp.Models; 4 | using Microsoft.AspNetCore.Components; 5 | using Microsoft.JSInterop; 6 | using System; 7 | using System.Collections.Generic; 8 | using System.IO; 9 | using System.Linq; 10 | using System.Text; 11 | using System.Threading.Tasks; 12 | 13 | namespace DemoApp.Pages 14 | { 15 | public partial class StreamSaverDemo 16 | { 17 | private StreamSaverModel _streamSaverModel = new(); 18 | 19 | private StringBuilder _stringBuilder = new(); 20 | private const string LoremIpsum = "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum."; 21 | 22 | private Stream _writableFileStream; 23 | 24 | [Inject] 25 | private IStreamSaver StreamSaver { get; set; } 26 | 27 | private void ClearFilename() 28 | { 29 | _streamSaverModel.Filename = string.Empty; 30 | } 31 | 32 | private void AddText() 33 | { 34 | _stringBuilder.AppendLine(_streamSaverModel.Text); 35 | } 36 | 37 | private void ClearText() 38 | { 39 | _streamSaverModel.Text = string.Empty; 40 | } 41 | 42 | private void AddLoremIpsum() 43 | { 44 | for(int i=0; i<_streamSaverModel.NumLoremIpsum; i++) 45 | _stringBuilder.AppendLine(LoremIpsum); 46 | } 47 | 48 | private async Task AppendAsync() 49 | { 50 | _writableFileStream ??= await StreamSaver.CreateWritableFileStreamAsync(_streamSaverModel.Filename); 51 | await _writableFileStream.WriteAsync(Encoding.UTF8.GetBytes(_stringBuilder.ToString())); 52 | 53 | _stringBuilder.Clear(); 54 | _streamSaverModel.FilenameDisabled = true; 55 | ClearText(); 56 | 57 | await Task.Delay(1); 58 | } 59 | 60 | private async Task CloseAsync() 61 | { 62 | await ResetAsync(); 63 | } 64 | 65 | private async Task ResetAsync() 66 | { 67 | await _writableFileStream?.DisposeAsync().AsTask(); 68 | _writableFileStream = null; 69 | _stringBuilder.Clear(); 70 | ClearFilename(); 71 | _streamSaverModel.FilenameDisabled = false; 72 | ClearText(); 73 | } 74 | } 75 | } 76 | -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | ############################################################################### 2 | # Set default behavior to automatically normalize line endings. 3 | ############################################################################### 4 | * text=auto 5 | 6 | ############################################################################### 7 | # Set default behavior for command prompt diff. 8 | # 9 | # This is need for earlier builds of msysgit that does not have it on by 10 | # default for csharp files. 11 | # Note: This is only used by command line 12 | ############################################################################### 13 | #*.cs diff=csharp 14 | 15 | ############################################################################### 16 | # Set the merge driver for project and solution files 17 | # 18 | # Merging from the command prompt will add diff markers to the files if there 19 | # are conflicts (Merging from VS is not affected by the settings below, in VS 20 | # the diff markers are never inserted). Diff markers may cause the following 21 | # file extensions to fail to load in VS. An alternative would be to treat 22 | # these files as binary and thus will always conflict and require user 23 | # intervention with every merge. To do so, just uncomment the entries below 24 | ############################################################################### 25 | #*.sln merge=binary 26 | #*.csproj merge=binary 27 | #*.vbproj merge=binary 28 | #*.vcxproj merge=binary 29 | #*.vcproj merge=binary 30 | #*.dbproj merge=binary 31 | #*.fsproj merge=binary 32 | #*.lsproj merge=binary 33 | #*.wixproj merge=binary 34 | #*.modelproj merge=binary 35 | #*.sqlproj merge=binary 36 | #*.wwaproj merge=binary 37 | 38 | ############################################################################### 39 | # behavior for image files 40 | # 41 | # image files are treated as binary by default. 42 | ############################################################################### 43 | #*.jpg binary 44 | #*.png binary 45 | #*.gif binary 46 | 47 | ############################################################################### 48 | # diff behavior for common document formats 49 | # 50 | # Convert binary document formats to text before diffing them. This feature 51 | # is only available from the command line. Turn it on by uncommenting the 52 | # entries below. 53 | ############################################################################### 54 | #*.doc diff=astextplain 55 | #*.DOC diff=astextplain 56 | #*.docx diff=astextplain 57 | #*.DOCX diff=astextplain 58 | #*.dot diff=astextplain 59 | #*.DOT diff=astextplain 60 | #*.pdf diff=astextplain 61 | #*.PDF diff=astextplain 62 | #*.rtf diff=astextplain 63 | #*.RTF diff=astextplain 64 | -------------------------------------------------------------------------------- /StreamSaver/StreamSaver.cs: -------------------------------------------------------------------------------- 1 | using BlazormeStreamSaver; 2 | using Microsoft.JSInterop; 3 | using System; 4 | using System.Collections.Generic; 5 | using System.IO; 6 | using System.Linq; 7 | using System.Text; 8 | using System.Threading.Tasks; 9 | 10 | namespace Blazorme 11 | { 12 | public class StreamSaver : IStreamSaver, IAsyncDisposable 13 | { 14 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 15 | /// JSISOLATION ONLY WORKS WITH MODULES THAT EXPORT FUNCTIONS. 16 | ////private readonly Lazy> _streamSaverModuleTask; 17 | ////private readonly Lazy> _polyfillModuleTask; 18 | ////private readonly Lazy> _jsInteropModuleTask; 19 | 20 | 21 | private readonly IJSRuntime _jsRuntime; 22 | 23 | public StreamSaver(IJSRuntime jsRuntime) 24 | { 25 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 26 | //_streamSaverModuleTask = new(() => jsRuntime.InvokeAsync( 27 | // "import", "./_content/Blazorme.StreamSaver/StreamSaver.min.js").AsTask()); 28 | //_polyfillModuleTask = new(() => jsRuntime.InvokeAsync( 29 | // "import", "./_content/Blazorme.StreamSaver/polyfill.min.js").AsTask()); 30 | //_jsInteropModuleTask = new(() => jsRuntime.InvokeAsync( 31 | // "import", "./_content/Blazorme.StreamSaver/StreamSaverJsInterop.js").AsTask()); 32 | 33 | _jsRuntime = jsRuntime; 34 | } 35 | 36 | public async Task CreateWritableFileStreamAsync(string fileName) 37 | { 38 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 39 | //return new WritableFileStream( 40 | // await _streamSaverModuleTask.Value, 41 | // await _jsInteropModuleTask.Value, 42 | // fileName); 43 | var writeableFileStream = new WritableFileStream(_jsRuntime, fileName); 44 | await writeableFileStream.CreateAsync(); 45 | return writeableFileStream; 46 | } 47 | 48 | public ValueTask DisposeAsync() 49 | { 50 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 51 | //if (_streamSaverModuleTask.IsValueCreated) 52 | //{ 53 | // var streamSaverModule = await _streamSaverModuleTask.Value; 54 | // await streamSaverModule.DisposeAsync(); 55 | //} 56 | //if (_streamSaverModuleTask.IsValueCreated) 57 | //{ 58 | // var polyfillModule = await _polyfillModuleTask.Value; 59 | // await polyfillModule.DisposeAsync(); 60 | //} 61 | //if (_jsInteropModuleTask.IsValueCreated) 62 | //{ 63 | // var jsInteropModule = await _jsInteropModuleTask.Value; 64 | // await jsInteropModule.DisposeAsync(); 65 | //} 66 | return ValueTask.CompletedTask; 67 | } 68 | } 69 | } 70 | -------------------------------------------------------------------------------- /TestHost/ContainerComponent.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.RenderTree; 3 | using System; 4 | using System.Diagnostics; 5 | using System.Diagnostics.CodeAnalysis; 6 | using System.Threading.Tasks; 7 | 8 | namespace BlazormeTestHost 9 | { 10 | // This provides the ability for test code to trigger rendering at arbitrary times, 11 | // and to supply arbitrary parameters to the component being tested (including ones 12 | // flagged as 'cascading'). 13 | // 14 | // This also avoids the use of Renderer's RenderRootComponentAsync APIs, which are 15 | // not a good entrypoint for unit tests, because their asynchrony is all about waiting 16 | // for quiescence. We don't want that in tests because we want to assert about all 17 | // possible states, including loading states. 18 | 19 | [SuppressMessage("Usage", "BL0006:Do not use RenderTree types", Justification = "")] 20 | internal class ContainerComponent : IComponent 21 | { 22 | private readonly TestRenderer _renderer; 23 | private RenderHandle _renderHandle; 24 | private int _componentId; 25 | 26 | public ContainerComponent(TestRenderer renderer) 27 | { 28 | _renderer = renderer; 29 | _componentId = renderer.AttachTestRootComponent(this); 30 | } 31 | 32 | public void Attach(RenderHandle renderHandle) 33 | { 34 | _renderHandle = renderHandle; 35 | } 36 | 37 | public Task SetParametersAsync(ParameterView parameters) 38 | { 39 | throw new NotImplementedException($"{nameof(ContainerComponent)} shouldn't receive any parameters"); 40 | } 41 | 42 | public (int, object) FindComponentUnderTest() 43 | { 44 | var ownFrames = _renderer.GetCurrentRenderTreeFrames(_componentId); 45 | if (ownFrames.Count == 0) 46 | { 47 | throw new InvalidOperationException($"{nameof(ContainerComponent)} hasn't yet rendered"); 48 | } 49 | 50 | ref var childComponentFrame = ref ownFrames.Array[0]; 51 | Debug.Assert(childComponentFrame.FrameType == RenderTreeFrameType.Component); 52 | Debug.Assert(childComponentFrame.Component != null); 53 | return (childComponentFrame.ComponentId, childComponentFrame.Component); 54 | } 55 | 56 | public void RenderComponentUnderTest(Type componentType, ParameterView parameters) 57 | { 58 | _renderer.DispatchAndAssertNoSynchronousErrors(() => 59 | { 60 | _renderHandle.Render(builder => 61 | { 62 | builder.OpenComponent(0, componentType); 63 | 64 | foreach (var parameterValue in parameters) 65 | { 66 | builder.AddAttribute(1, parameterValue.Name, parameterValue.Value); 67 | } 68 | 69 | builder.CloseComponent(); 70 | }); 71 | }); 72 | } 73 | } 74 | } 75 | -------------------------------------------------------------------------------- /TestHost/TestHost.cs: -------------------------------------------------------------------------------- 1 | using BlazormeTestHost; 2 | using Microsoft.AspNetCore.Components; 3 | using Microsoft.Extensions.DependencyInjection; 4 | using Microsoft.Extensions.Logging; 5 | using Microsoft.Extensions.Logging.Abstractions; 6 | using System; 7 | using System.Collections.Generic; 8 | 9 | namespace Blazorme 10 | { 11 | public class TestHost 12 | { 13 | private readonly ServiceCollection _serviceCollection = new ServiceCollection(); 14 | private readonly Lazy _renderer; 15 | private readonly Lazy _serviceProvider; 16 | 17 | public TestHost() 18 | { 19 | _serviceProvider = new Lazy(() => 20 | { 21 | return _serviceCollection.BuildServiceProvider(); 22 | }); 23 | 24 | _renderer = new Lazy(() => 25 | { 26 | var loggerFactory = Services.GetService() ?? new NullLoggerFactory(); 27 | return new TestRenderer(Services, loggerFactory); 28 | }); 29 | } 30 | 31 | public IServiceProvider Services => _serviceProvider.Value; 32 | 33 | public void AddService(T implementation) 34 | => AddService(implementation); 35 | 36 | public void AddService(TImplementation implementation) where TImplementation: TContract 37 | { 38 | if (_renderer.IsValueCreated) 39 | { 40 | throw new InvalidOperationException("Cannot configure services after the host has started operation"); 41 | } 42 | 43 | _serviceCollection.AddSingleton(typeof(TContract), implementation); 44 | } 45 | 46 | public void WaitForNextRender(Action trigger) 47 | { 48 | var task = Renderer.NextRender; 49 | trigger(); 50 | task.Wait(millisecondsTimeout: 1000); 51 | 52 | if (!task.IsCompleted) 53 | { 54 | throw new TimeoutException("No render occurred within the timeout period."); 55 | } 56 | } 57 | 58 | public RenderedComponent AddComponent() where TComponent: IComponent 59 | { 60 | var result = new RenderedComponent(Renderer); 61 | result.SetParametersAndRender(ParameterView.Empty); 62 | return result; 63 | } 64 | 65 | public RenderedComponent AddComponent(ParameterView parameters) where TComponent : IComponent 66 | { 67 | var result = new RenderedComponent(Renderer); 68 | result.SetParametersAndRender(parameters); 69 | return result; 70 | } 71 | 72 | public RenderedComponent AddComponent(IDictionary parameters) where TComponent : IComponent 73 | { 74 | return AddComponent(ParameterView.FromDictionary(parameters)); 75 | } 76 | 77 | private TestRenderer Renderer => _renderer.Value; 78 | } 79 | } 80 | -------------------------------------------------------------------------------- /Split/Split.razor.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.AspNetCore.Components; 2 | using Microsoft.AspNetCore.Components.Rendering; 3 | using Microsoft.JSInterop; 4 | using BlazormeSplit; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Dynamic; 8 | using System.Linq; 9 | using System.Text; 10 | using System.Threading.Tasks; 11 | 12 | namespace Blazorme 13 | { 14 | public partial class Split 15 | { 16 | [Inject] 17 | private IJSRuntime _jsRuntime { get; set; } 18 | 19 | [Parameter] 20 | public int DefaultMinSize { get; set; } = 100; 21 | 22 | [Parameter] 23 | public bool ExpandToMin { get; set; } = false; 24 | 25 | [Parameter] 26 | public int GutterSize { get; set; } = 10; 27 | 28 | [Parameter] 29 | public SplitGutterAlign GutterAlign { get; set; } = SplitGutterAlign.Center; 30 | 31 | [Parameter] 32 | public string GutterColor { get; set; } = "#cfcfcf"; 33 | 34 | 35 | [Parameter] 36 | public int SnapOffset { get; set; } = 30; 37 | 38 | [Parameter] 39 | public int DragInterval { get; set; } = 1; 40 | 41 | [Parameter] 42 | public SplitDirection Direction { get; set; } = SplitDirection.Horizontal; 43 | 44 | [Parameter] 45 | public string Cursor { get; set; } = string.Empty; 46 | 47 | [Parameter] 48 | public RenderFragment ChildContent { get; set; } 49 | 50 | private List _splitPanes = new List(); 51 | 52 | 53 | internal void AddSplitPane(SplitPane splitPane) 54 | { 55 | _splitPanes.Add(splitPane); 56 | } 57 | 58 | protected override void OnInitialized() 59 | { 60 | base.OnInitialized(); 61 | if (string.IsNullOrEmpty(Cursor)) 62 | { 63 | if(Direction == SplitDirection.Horizontal) 64 | { 65 | Cursor = "col-resize"; 66 | } 67 | else 68 | { 69 | Cursor = "row-resize"; 70 | } 71 | } 72 | } 73 | 74 | protected override async Task OnAfterRenderAsync(bool firstRender) 75 | { 76 | await base.OnAfterRenderAsync(firstRender); 77 | 78 | if(firstRender) 79 | { 80 | await JsInterop.InvokeAsync(_jsRuntime, 81 | _splitPanes.Select(splitPane => splitPane.ElementReference).ToArray(), 82 | new Options 83 | { 84 | Sizes = _splitPanes.All(splitPane => splitPane.SizeInPercentage == 0) ? null : 85 | _splitPanes.Select(splitPane => splitPane.SizeInPercentage).ToArray(), 86 | MinSize = _splitPanes.Select(splitPane => splitPane.MinSize ?? DefaultMinSize).ToArray(), 87 | ExpandToMin = ExpandToMin, 88 | GutterSize = GutterSize, 89 | GutterAlign = GutterAlign.ToString().ToLower(), 90 | SnapOffset = SnapOffset, 91 | DragInterval = DragInterval, 92 | Direction = Direction.ToString().ToLower(), 93 | Cursor = Cursor 94 | }); 95 | } 96 | } 97 | } 98 | } 99 | -------------------------------------------------------------------------------- /Blazorme.sln: -------------------------------------------------------------------------------- 1 | 2 | Microsoft Visual Studio Solution File, Format Version 12.00 3 | # Visual Studio Version 16 4 | VisualStudioVersion = 16.0.30114.105 5 | MinimumVisualStudioVersion = 10.0.40219.1 6 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Diff", "Diff\Diff.csproj", "{2EBC7D56-59FE-461F-9B89-F4880AC7F03F}" 7 | EndProject 8 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Split", "Split\Split.csproj", "{C0ED2524-2CCA-48ED-B342-86A1AF7CFBF3}" 9 | EndProject 10 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "TestHost", "TestHost\TestHost.csproj", "{8780CE48-431C-4179-B64D-D8DBC6C7CA9B}" 11 | EndProject 12 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "StreamSaver", "StreamSaver\StreamSaver.csproj", "{CA5CC7D0-3E10-48F4-98B3-8423E4CDCD38}" 13 | EndProject 14 | Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DemoApp", "DemoApp\DemoApp.csproj", "{5E20E00F-F10C-4FC0-83D6-4E1AD5835C9A}" 15 | EndProject 16 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "FFmpeg", "FFmpeg\FFmpeg.csproj", "{D5C66689-727D-4056-A996-18010FA45C40}" 17 | EndProject 18 | Global 19 | GlobalSection(SolutionConfigurationPlatforms) = preSolution 20 | Debug|Any CPU = Debug|Any CPU 21 | Release|Any CPU = Release|Any CPU 22 | EndGlobalSection 23 | GlobalSection(ProjectConfigurationPlatforms) = postSolution 24 | {2EBC7D56-59FE-461F-9B89-F4880AC7F03F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 25 | {2EBC7D56-59FE-461F-9B89-F4880AC7F03F}.Debug|Any CPU.Build.0 = Debug|Any CPU 26 | {2EBC7D56-59FE-461F-9B89-F4880AC7F03F}.Release|Any CPU.ActiveCfg = Release|Any CPU 27 | {2EBC7D56-59FE-461F-9B89-F4880AC7F03F}.Release|Any CPU.Build.0 = Release|Any CPU 28 | {C0ED2524-2CCA-48ED-B342-86A1AF7CFBF3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 29 | {C0ED2524-2CCA-48ED-B342-86A1AF7CFBF3}.Debug|Any CPU.Build.0 = Debug|Any CPU 30 | {C0ED2524-2CCA-48ED-B342-86A1AF7CFBF3}.Release|Any CPU.ActiveCfg = Release|Any CPU 31 | {C0ED2524-2CCA-48ED-B342-86A1AF7CFBF3}.Release|Any CPU.Build.0 = Release|Any CPU 32 | {8780CE48-431C-4179-B64D-D8DBC6C7CA9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 33 | {8780CE48-431C-4179-B64D-D8DBC6C7CA9B}.Debug|Any CPU.Build.0 = Debug|Any CPU 34 | {8780CE48-431C-4179-B64D-D8DBC6C7CA9B}.Release|Any CPU.ActiveCfg = Release|Any CPU 35 | {8780CE48-431C-4179-B64D-D8DBC6C7CA9B}.Release|Any CPU.Build.0 = Release|Any CPU 36 | {CA5CC7D0-3E10-48F4-98B3-8423E4CDCD38}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 37 | {CA5CC7D0-3E10-48F4-98B3-8423E4CDCD38}.Debug|Any CPU.Build.0 = Debug|Any CPU 38 | {CA5CC7D0-3E10-48F4-98B3-8423E4CDCD38}.Release|Any CPU.ActiveCfg = Release|Any CPU 39 | {CA5CC7D0-3E10-48F4-98B3-8423E4CDCD38}.Release|Any CPU.Build.0 = Release|Any CPU 40 | {5E20E00F-F10C-4FC0-83D6-4E1AD5835C9A}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 41 | {5E20E00F-F10C-4FC0-83D6-4E1AD5835C9A}.Debug|Any CPU.Build.0 = Debug|Any CPU 42 | {5E20E00F-F10C-4FC0-83D6-4E1AD5835C9A}.Release|Any CPU.ActiveCfg = Release|Any CPU 43 | {5E20E00F-F10C-4FC0-83D6-4E1AD5835C9A}.Release|Any CPU.Build.0 = Release|Any CPU 44 | {D5C66689-727D-4056-A996-18010FA45C40}.Debug|Any CPU.ActiveCfg = Debug|Any CPU 45 | {D5C66689-727D-4056-A996-18010FA45C40}.Debug|Any CPU.Build.0 = Debug|Any CPU 46 | {D5C66689-727D-4056-A996-18010FA45C40}.Release|Any CPU.ActiveCfg = Release|Any CPU 47 | {D5C66689-727D-4056-A996-18010FA45C40}.Release|Any CPU.Build.0 = Release|Any CPU 48 | EndGlobalSection 49 | GlobalSection(SolutionProperties) = preSolution 50 | HideSolutionNode = FALSE 51 | EndGlobalSection 52 | GlobalSection(ExtensibilityGlobals) = postSolution 53 | SolutionGuid = {E8EECCC0-2304-444A-B2E5-1211D63B5591} 54 | EndGlobalSection 55 | EndGlobal 56 | -------------------------------------------------------------------------------- /StreamSaver/WritableFileStream.cs: -------------------------------------------------------------------------------- 1 | using Microsoft.JSInterop; 2 | using System; 3 | using System.Collections.Generic; 4 | using System.IO; 5 | using System.Linq; 6 | using System.Text; 7 | using System.Threading; 8 | using System.Threading.Tasks; 9 | using System.Runtime.InteropServices.JavaScript; 10 | 11 | namespace BlazormeStreamSaver 12 | { 13 | internal class WritableFileStream : Stream 14 | { 15 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 16 | //private readonly IJSObjectReference _streamSaverModule; 17 | //private readonly IJSObjectReference _jsInteropModule; 18 | private readonly IJSRuntime _jsRuntime; 19 | private readonly string _fileName; 20 | 21 | private JSObject _streamSaverJsObject; 22 | private JSObject _writeableStreamJsObject; 23 | private JSObject _writerJsObject; 24 | 25 | public WritableFileStream(IJSRuntime jsRuntime, string fileName) 26 | { 27 | _jsRuntime = jsRuntime; 28 | _fileName = fileName; 29 | } 30 | 31 | //// TODO: INCLUDE IF YOU CAN CONVERT JS FILES TO MODULE 32 | //public WritableFileStream(IJSObjectReference streamSaverModule, IJSObjectReference jsInteropModule, 33 | // string fileName) 34 | //{ 35 | // _streamSaverModule = streamSaverModule; 36 | // _jsInteropModule = jsInteropModule; 37 | // _fileName = fileName; 38 | //} 39 | 40 | public Task CreateAsync() 41 | { 42 | var windowJsObject = (JSObject)Runtime.GetGlobalObject("window"); 43 | _streamSaverJsObject = (JSObject)windowJsObject.GetObjectProperty("streamSaver"); 44 | _writeableStreamJsObject = (JSObject)_streamSaverJsObject.Invoke("createWriteStream", _fileName); 45 | _writerJsObject = (JSObject)_writeableStreamJsObject.Invoke("getWriter"); 46 | return Task.CompletedTask; 47 | } 48 | 49 | public override bool CanRead => false; 50 | 51 | public override bool CanSeek => false; 52 | 53 | public override bool CanWrite => true; 54 | 55 | public override long Length => 0; 56 | 57 | public override long Position 58 | { 59 | get => throw new NotImplementedException(); 60 | set => throw new NotImplementedException(); 61 | } 62 | 63 | public override void Flush() 64 | { 65 | throw new NotImplementedException(); 66 | } 67 | 68 | public override int Read(byte[] buffer, int offset, int count) 69 | { 70 | throw new NotImplementedException(); 71 | } 72 | 73 | public override long Seek(long offset, SeekOrigin origin) 74 | { 75 | throw new NotImplementedException(); 76 | } 77 | 78 | public override void SetLength(long value) 79 | { 80 | throw new NotImplementedException(); 81 | } 82 | 83 | public override void Write(byte[] buffer, int offset, int count) 84 | { 85 | throw new NotImplementedException(); 86 | } 87 | 88 | public override async Task WriteAsync(byte[] buffer, int offset, int count, CancellationToken cancellationToken) 89 | { 90 | await (Task)_writerJsObject.Invoke("write", Uint8Array.From(buffer)); 91 | } 92 | 93 | public override async ValueTask DisposeAsync() 94 | { 95 | await (Task)_writerJsObject.Invoke("close"); 96 | _writerJsObject.Dispose(); 97 | _writeableStreamJsObject.Dispose(); 98 | _streamSaverJsObject.Dispose(); 99 | Close(); 100 | await base.DisposeAsync(); 101 | } 102 | } 103 | } 104 | -------------------------------------------------------------------------------- /DemoApp/wwwroot/css/open-iconic/README.md: -------------------------------------------------------------------------------- 1 | [Open Iconic v1.1.1](http://useiconic.com/open) 2 | =========== 3 | 4 | ### Open Iconic is the open source sibling of [Iconic](http://useiconic.com). It is a hyper-legible collection of 223 icons with a tiny footprint—ready to use with Bootstrap and Foundation. [View the collection](http://useiconic.com/open#icons) 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](http://useiconic.com/open#icons) and [Reference](http://useiconic.com/open#reference) 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 | -------------------------------------------------------------------------------- /StreamSaver/wwwroot/StreamSaver.min.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Minified by jsDelivr using Terser v5.3.0. 3 | * Original file: /npm/streamsaver@2.0.5/StreamSaver.js 4 | * 5 | * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files 6 | */ 7 | ((e,t)=>{"undefined"!=typeof module?module.exports=t():"function"==typeof define&&"object"==typeof define.amd?define(t):this.streamSaver=t()})(0,()=>{"use strict";const e="object"==typeof window?window:this;e.HTMLElement||console.warn("streamsaver is meant to run on browsers main thread");let t=null,a=!1;const r=e.WebStreamsPolyfill||{},n=e.isSecureContext;let o=/constructor/i.test(e.HTMLElement)||!!e.safari||!!e.WebKitPoint;const s=n||"MozAppearance"in document.documentElement.style?"iframe":"navigate",i={createWriteStream:function(r,m,c){let d={size:null,pathname:null,writableStrategy:void 0,readableStrategy:void 0},p=0,u=null,f=null,g=null;Number.isFinite(m)?([c,m]=[m,c],console.warn("[StreamSaver] Depricated pass an object as 2nd argument when creating a write stream"),d.size=c,d.writableStrategy=m):m&&m.highWaterMark?(console.warn("[StreamSaver] Depricated pass an object as 2nd argument when creating a write stream"),d.size=c,d.writableStrategy=m):d=m||{};if(!o){t||(t=n?l(i.mitm):function(t){const a="width=200,height=100",r=document.createDocumentFragment(),n={frame:e.open(t,"popup",a),loaded:!1,isIframe:!1,isPopup:!0,remove(){n.frame.close()},addEventListener(...e){r.addEventListener(...e)},dispatchEvent(...e){r.dispatchEvent(...e)},removeEventListener(...e){r.removeEventListener(...e)},postMessage(...e){n.frame.postMessage(...e)}},o=t=>{t.source===n.frame&&(n.loaded=!0,e.removeEventListener("message",o),n.dispatchEvent(new Event("load")))};return e.addEventListener("message",o),n}(i.mitm)),f=new MessageChannel,r=encodeURIComponent(r.replace(/\//g,":")).replace(/['()]/g,escape).replace(/\*/g,"%2A");const o={transferringReadable:a,pathname:d.pathname||Math.random().toString().slice(-6)+"/"+r,headers:{"Content-Type":"application/octet-stream; charset=utf-8","Content-Disposition":"attachment; filename*=UTF-8''"+r}};d.size&&(o.headers["Content-Length"]=d.size);const m=[o,"*",[f.port2]];if(a){const e="iframe"===s?void 0:{transform(e,t){if(!(e instanceof Uint8Array))throw new TypeError("Can only wirte Uint8Arrays");p+=e.length,t.enqueue(e),u&&(location.href=u,u=null)},flush(){u&&(location.href=u)}};g=new i.TransformStream(e,d.writableStrategy,d.readableStrategy);const t=g.readable;f.port1.postMessage({readableStream:t},[t])}f.port1.onmessage=e=>{e.data.download&&("navigate"===s?(t.remove(),t=null,p?location.href=e.data.download:u=e.data.download):(t.isPopup&&(t.remove(),t=null,"iframe"===s&&l(i.mitm)),l(e.data.download)))},t.loaded?t.postMessage(...m):t.addEventListener("load",()=>{t.postMessage(...m)},{once:!0})}let h=[];return!o&&g&&g.writable||new i.WritableStream({write(e){if(!(e instanceof Uint8Array))throw new TypeError("Can only wirte Uint8Arrays");o?h.push(e):(f.port1.postMessage(e),p+=e.length,u&&(location.href=u,u=null))},close(){if(o){const e=new Blob(h,{type:"application/octet-stream; charset=utf-8"}),t=document.createElement("a");t.href=URL.createObjectURL(e),t.download=r,t.click()}else f.port1.postMessage("end")},abort(){h=[],f.port1.postMessage("abort"),f.port1.onmessage=null,f.port1.close(),f.port2.close(),f=null}},d.writableStrategy)},WritableStream:e.WritableStream||r.WritableStream,supported:!0,version:{full:"2.0.5",major:2,minor:0,dot:5},mitm:"https://jimmywarting.github.io/StreamSaver.js/mitm.html?version=2.0.0"};function l(e){if(!e)throw new Error("meh");const t=document.createElement("iframe");return t.hidden=!0,t.src=e,t.loaded=!1,t.name="iframe",t.isIframe=!0,t.postMessage=(...e)=>t.contentWindow.postMessage(...e),t.addEventListener("load",()=>{t.loaded=!0},{once:!0}),document.body.appendChild(t),t}try{new Response(new ReadableStream),n&&!("serviceWorker"in navigator)&&(o=!0)}catch(e){o=!0}return(e=>{try{e()}catch(e){}})(()=>{const{readable:e}=new TransformStream,t=new MessageChannel;t.port1.postMessage(e,[e]),t.port1.close(),t.port2.close(),a=!0,Object.defineProperty(i,"TransformStream",{configurable:!1,writable:!1,value:TransformStream})}),i}); 8 | //# sourceMappingURL=/sm/d8950babbb3d7572ec9167db8494559b320803ca90f10ac4e1e0960af58a5b48.map -------------------------------------------------------------------------------- /DemoApp/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 | -------------------------------------------------------------------------------- /Split/README.md: -------------------------------------------------------------------------------- 1 | # Blazorme.Split 2 | Split component library for Blazor apps. The library provides resizeable split views (panes). 3 | 4 | Use `DemoApp` as a reference for your implementation. 5 | 6 | ## Implementation 7 | Currently the library interops by using the `split.js` package: [GitHub](https://github.com/nathancahill/split), [jsdelivr](https://www.jsdelivr.com/package/npm/split.js) 8 | ## Installation 9 | * Install NuGet package: 10 | ``` 11 | Install-Package Blazorme.Split 12 | ``` 13 | * Using: 14 | 15 | In `_Imports.razor` add: 16 | ``` 17 | @using Blazorme 18 | ``` 19 | * JS reference: 20 | 21 | Add the following line to your `index.html` (WebAsembly) or `_Host.cshtml` (Server) files: 22 | ```html 23 | 24 | 25 | ``` 26 | ## Usage 27 | In your Blazor page, add the top level `Split` entry and `SplitPane` sub-entires to form the split view. Here is a simple example: 28 | ```html 29 |
30 | 31 | 32 | One 33 | 34 | 35 | Two 36 | 37 | 38 | Three 39 | 40 | 41 |
42 | ``` 43 | ## Parameters 44 | ``` cs 45 | public enum SplitDirection 46 | { 47 | Horizontal, 48 | Vertical 49 | } 50 | ``` 51 | ``` cs 52 | public enum SplitGutterAlign 53 | { 54 | Center, 55 | Start, 56 | End, 57 | } 58 | ``` 59 | ### Split 60 | Parameter | Type | Default | Description 61 | --- | --- | --- | --- 62 | DefaultMinSize | int | 100 | Minimum size of each pane in pixels. It will be used if min size is not specified in `SplitPane`. 63 | ExpandToMin | bool | false | Grow initial sizes to min size. 64 | GutterSize | int | 10 | Gutter size in pixels. 65 | GutterAlign | SplitGutterAlign | SplitGutterAlign.Center | Gutter alignment between elements. 66 | GutterColor | string | "#cfcfcf" | Gutter color in HTML hex string. 67 | SnapOffset | int | 30 | Snap to min size offset in pixels. 68 | DragInterval | int | 1 | Number of pixels to drag. 69 | Direction | SplitDirection | SplitDirection.Horizontal | Direction to split, horizontal or vertical. 70 | Cursor | string | "col-resize" or "row-resize" depending on direction | [Cursor](https://www.w3schools.com/cssref/pr_class_cursor.asp) to display while dragging. 71 | ### SplitPane 72 | Parameter | Type | Default | Description 73 | --- | --- | --- | --- 74 | SizeInPercentage | int | 0 | Pane size in percentage. 75 | MinSize | int? | null | Minimum size of the pane in pixels. 76 | ## Example 77 | From demo app: 78 | ``` html 79 |
80 | 81 | 82 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 83 | 84 | 85 | 86 | 87 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 88 | 89 | 90 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 91 | 92 | 93 | 94 | 95 | Lorem ipsum dolor sit amet, consectetur adipiscing elit. In vel ullamcorper ipsum, at blandit leo. Sed egestas est tellus, nec rutrum leo ultricies vitae. Praesent scelerisque libero in lacus gravida, a ultrices tortor rutrum. Donec et justo nibh. Nulla congue volutpat sapien, eu pretium sapien porttitor id. Vivamus sit amet aliquet libero. Vestibulum sit amet ex pharetra, dapibus enim nec, ullamcorper metus. Integer pellentesque aliquam aliquet. 96 | 97 | 98 |
99 | ```` 100 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | ## Ignore Visual Studio temporary files, build results, and 2 | ## files generated by popular Visual Studio add-ons. 3 | ## 4 | ## Get latest from https://github.com/github/gitignore/blob/master/VisualStudio.gitignore 5 | 6 | # User-specific files 7 | *.rsuser 8 | *.suo 9 | *.user 10 | *.userosscache 11 | *.sln.docstates 12 | 13 | # User-specific files (MonoDevelop/Xamarin Studio) 14 | *.userprefs 15 | 16 | # Build results 17 | [Dd]ebug/ 18 | [Dd]ebugPublic/ 19 | [Rr]elease/ 20 | [Rr]eleases/ 21 | x64/ 22 | x86/ 23 | [Aa][Rr][Mm]/ 24 | [Aa][Rr][Mm]64/ 25 | bld/ 26 | [Bb]in/ 27 | [Oo]bj/ 28 | [Ll]og/ 29 | 30 | # Visual Studio 2015/2017 cache/options directory 31 | .vs/ 32 | # Uncomment if you have tasks that create the project's static files in wwwroot 33 | #wwwroot/ 34 | 35 | # Visual Studio 2017 auto generated files 36 | Generated\ Files/ 37 | 38 | # MSTest test Results 39 | [Tt]est[Rr]esult*/ 40 | [Bb]uild[Ll]og.* 41 | 42 | # NUNIT 43 | *.VisualState.xml 44 | TestResult.xml 45 | 46 | # Build Results of an ATL Project 47 | [Dd]ebugPS/ 48 | [Rr]eleasePS/ 49 | dlldata.c 50 | 51 | # Benchmark Results 52 | BenchmarkDotNet.Artifacts/ 53 | 54 | # .NET Core 55 | project.lock.json 56 | project.fragment.lock.json 57 | artifacts/ 58 | 59 | # StyleCop 60 | StyleCopReport.xml 61 | 62 | # Files built by Visual Studio 63 | *_i.c 64 | *_p.c 65 | *_h.h 66 | *.ilk 67 | *.meta 68 | *.obj 69 | *.iobj 70 | *.pch 71 | *.pdb 72 | *.ipdb 73 | *.pgc 74 | *.pgd 75 | *.rsp 76 | *.sbr 77 | *.tlb 78 | *.tli 79 | *.tlh 80 | *.tmp 81 | *.tmp_proj 82 | *_wpftmp.csproj 83 | *.log 84 | *.vspscc 85 | *.vssscc 86 | .builds 87 | *.pidb 88 | *.svclog 89 | *.scc 90 | 91 | # Chutzpah Test files 92 | _Chutzpah* 93 | 94 | # Visual C++ cache files 95 | ipch/ 96 | *.aps 97 | *.ncb 98 | *.opendb 99 | *.opensdf 100 | *.sdf 101 | *.cachefile 102 | *.VC.db 103 | *.VC.VC.opendb 104 | 105 | # Visual Studio profiler 106 | *.psess 107 | *.vsp 108 | *.vspx 109 | *.sap 110 | 111 | # Visual Studio Trace Files 112 | *.e2e 113 | 114 | # TFS 2012 Local Workspace 115 | $tf/ 116 | 117 | # Guidance Automation Toolkit 118 | *.gpState 119 | 120 | # ReSharper is a .NET coding add-in 121 | _ReSharper*/ 122 | *.[Rr]e[Ss]harper 123 | *.DotSettings.user 124 | 125 | # JustCode is a .NET coding add-in 126 | .JustCode 127 | 128 | # TeamCity is a build add-in 129 | _TeamCity* 130 | 131 | # DotCover is a Code Coverage Tool 132 | *.dotCover 133 | 134 | # AxoCover is a Code Coverage Tool 135 | .axoCover/* 136 | !.axoCover/settings.json 137 | 138 | # Visual Studio code coverage results 139 | *.coverage 140 | *.coveragexml 141 | 142 | # NCrunch 143 | _NCrunch_* 144 | .*crunch*.local.xml 145 | nCrunchTemp_* 146 | 147 | # MightyMoose 148 | *.mm.* 149 | AutoTest.Net/ 150 | 151 | # Web workbench (sass) 152 | .sass-cache/ 153 | 154 | # Installshield output folder 155 | [Ee]xpress/ 156 | 157 | # DocProject is a documentation generator add-in 158 | DocProject/buildhelp/ 159 | DocProject/Help/*.HxT 160 | DocProject/Help/*.HxC 161 | DocProject/Help/*.hhc 162 | DocProject/Help/*.hhk 163 | DocProject/Help/*.hhp 164 | DocProject/Help/Html2 165 | DocProject/Help/html 166 | 167 | # Click-Once directory 168 | publish/ 169 | 170 | # Publish Web Output 171 | *.[Pp]ublish.xml 172 | *.azurePubxml 173 | # Note: Comment the next line if you want to checkin your web deploy settings, 174 | # but database connection strings (with potential passwords) will be unencrypted 175 | *.pubxml 176 | *.publishproj 177 | 178 | # Microsoft Azure Web App publish settings. Comment the next line if you want to 179 | # checkin your Azure Web App publish settings, but sensitive information contained 180 | # in these scripts will be unencrypted 181 | PublishScripts/ 182 | 183 | # NuGet Packages 184 | *.nupkg 185 | # The packages folder can be ignored because of Package Restore 186 | **/[Pp]ackages/* 187 | # except build/, which is used as an MSBuild target. 188 | !**/[Pp]ackages/build/ 189 | # Uncomment if necessary however generally it will be regenerated when needed 190 | #!**/[Pp]ackages/repositories.config 191 | # NuGet v3's project.json files produces more ignorable files 192 | *.nuget.props 193 | *.nuget.targets 194 | 195 | # Microsoft Azure Build Output 196 | csx/ 197 | *.build.csdef 198 | 199 | # Microsoft Azure Emulator 200 | ecf/ 201 | rcf/ 202 | 203 | # Windows Store app package directories and files 204 | AppPackages/ 205 | BundleArtifacts/ 206 | Package.StoreAssociation.xml 207 | _pkginfo.txt 208 | *.appx 209 | 210 | # Visual Studio cache files 211 | # files ending in .cache can be ignored 212 | *.[Cc]ache 213 | # but keep track of directories ending in .cache 214 | !?*.[Cc]ache/ 215 | 216 | # Others 217 | ClientBin/ 218 | ~$* 219 | *~ 220 | *.dbmdl 221 | *.dbproj.schemaview 222 | *.jfm 223 | *.pfx 224 | *.publishsettings 225 | orleans.codegen.cs 226 | 227 | # Including strong name files can present a security risk 228 | # (https://github.com/github/gitignore/pull/2483#issue-259490424) 229 | #*.snk 230 | 231 | # Since there are multiple workflows, uncomment next line to ignore bower_components 232 | # (https://github.com/github/gitignore/pull/1529#issuecomment-104372622) 233 | #bower_components/ 234 | 235 | # RIA/Silverlight projects 236 | Generated_Code/ 237 | 238 | # Backup & report files from converting an old project file 239 | # to a newer Visual Studio version. Backup files are not needed, 240 | # because we have git ;-) 241 | _UpgradeReport_Files/ 242 | Backup*/ 243 | UpgradeLog*.XML 244 | UpgradeLog*.htm 245 | ServiceFabricBackup/ 246 | *.rptproj.bak 247 | 248 | # SQL Server files 249 | *.mdf 250 | *.ldf 251 | *.ndf 252 | 253 | # Business Intelligence projects 254 | *.rdl.data 255 | *.bim.layout 256 | *.bim_*.settings 257 | *.rptproj.rsuser 258 | *- Backup*.rdl 259 | 260 | # Microsoft Fakes 261 | FakesAssemblies/ 262 | 263 | # GhostDoc plugin setting file 264 | *.GhostDoc.xml 265 | 266 | # Node.js Tools for Visual Studio 267 | .ntvs_analysis.dat 268 | node_modules/ 269 | 270 | # Visual Studio 6 build log 271 | *.plg 272 | 273 | # Visual Studio 6 workspace options file 274 | *.opt 275 | 276 | # Visual Studio 6 auto-generated workspace file (contains which files were open etc.) 277 | *.vbw 278 | 279 | # Visual Studio LightSwitch build output 280 | **/*.HTMLClient/GeneratedArtifacts 281 | **/*.DesktopClient/GeneratedArtifacts 282 | **/*.DesktopClient/ModelManifest.xml 283 | **/*.Server/GeneratedArtifacts 284 | **/*.Server/ModelManifest.xml 285 | _Pvt_Extensions 286 | 287 | # Paket dependency manager 288 | .paket/paket.exe 289 | paket-files/ 290 | 291 | # FAKE - F# Make 292 | .fake/ 293 | 294 | # JetBrains Rider 295 | .idea/ 296 | *.sln.iml 297 | 298 | # CodeRush personal settings 299 | .cr/personal 300 | 301 | # Python Tools for Visual Studio (PTVS) 302 | __pycache__/ 303 | *.pyc 304 | 305 | # Cake - Uncomment if you are using it 306 | # tools/** 307 | # !tools/packages.config 308 | 309 | # Tabs Studio 310 | *.tss 311 | 312 | # Telerik's JustMock configuration file 313 | *.jmconfig 314 | 315 | # BizTalk build output 316 | *.btp.cs 317 | *.btm.cs 318 | *.odx.cs 319 | *.xsd.cs 320 | 321 | # OpenCover UI analysis results 322 | OpenCover/ 323 | 324 | # Azure Stream Analytics local run output 325 | ASALocalRun/ 326 | 327 | # MSBuild Binary and Structured Log 328 | *.binlog 329 | 330 | # NVidia Nsight GPU debugger configuration file 331 | *.nvuser 332 | 333 | # MFractors (Xamarin productivity tool) working folder 334 | .mfractor/ 335 | 336 | # Local History for Visual Studio 337 | .localhistory/ 338 | 339 | # BeatPulse healthcheck temp database 340 | healthchecksdb -------------------------------------------------------------------------------- /Diff/README.md: -------------------------------------------------------------------------------- 1 | # Blazorme.Diff 2 | Diff component library for Blazor apps. 3 | The library will render diff of the two input strings in different output display formats. Output is always in HTML and currently 3 output display formats are provided via `OutputFormat` parameter: 4 | * Inline: Inlined format. Intented for HTML inputs although plain text can also be used. 5 | * Row: Line by line format for text inputs. 6 | * Column: Side by side format for text inputs. 7 | 8 | For `html diff`, two show difference levels are provided via `Style` parameter: 9 | * Word: Diff will be displayed based on words. This is default. 10 | * Char: Diff will be displayed based on characters. 11 | 12 | Use `DemoApp` as a reference for your implementation. 13 | 14 | ## Third Party Packages 15 | The following packages have been used: 16 | * htmldiff.net: [GitHub](https://github.com/Rohland/htmldiff.net), [NuGet](https://www.nuget.org/packages/htmldiff.net/) 17 | * diff: [GitHub](https://github.com/kpdecker/jsdiff), [jsdelivr](https://www.jsdelivr.com/package/npm/diff) (JS interop) 18 | * diff2html: [GitHub](https://github.com/rtfpessoa/diff2html), [jsdelivr](https://www.jsdelivr.com/package/npm/diff2html) (JS interop) 19 | ## Installation 20 | * Install NuGet package: 21 | ``` 22 | Install-Package Blazorme.Diff 23 | ``` 24 | * Using: 25 | 26 | In `_Imports.razor` add: 27 | ``` 28 | @using Blazorme 29 | ``` 30 | For API calls from code behine add: 31 | ``` 32 | using Blazorme; 33 | ``` 34 | * Inject 35 | 36 | If you like to use API from code behind, inject `IDiff`: 37 | ```cs 38 | [Inject] 39 | private IDiff DiffApi { get; set; } 40 | ``` 41 | * JS and CSS references: 42 | 43 | Add the following lines to your `index.html` (WebAsembly) or `_Host.cshtml` (Server) files: 44 | ```html 45 | 46 | 50 | 51 | 52 | 56 | 60 | ``` 61 | * Service addition: 62 | 63 | Add the following entires to `Program.cs` in `Main` (WebAssembly) or `Startup.cs` in `Configure` (Server) function. 64 | ```cs 65 | using Blazorme; 66 | 67 | ... 68 | 69 | Main 70 | { 71 | ... 72 | builder.Services.AddDiff(); 73 | ... 74 | } 75 | 76 | Configure 77 | { 78 | ... 79 | services.AddDiff(); 80 | ... 81 | } 82 | ``` 83 | ## Parameters 84 | ``` cs 85 | public class DiffInputTitle 86 | { 87 | public const string First = "First"; 88 | public const string Second = "Second"; 89 | } 90 | ``` 91 | ``` cs 92 | public enum DiffOutputFormat 93 | { 94 | Inline, 95 | Row, 96 | Column, 97 | } 98 | ``` 99 | ``` cs 100 | public enum DiffStyle 101 | { 102 | Word, 103 | Char 104 | } 105 | ``` 106 | 107 | Parameter | Type | Default | Description 108 | --- | --- | --- | --- 109 | FirstInput | string | "" | First input string to diff. 110 | SecondInput | string | "" | Second input string to diff. 111 | FirstTitle | string | DiffInputTitle.First | First title. 112 | SecondInput | string | DiffInputTitle.Second | Second title. 113 | OutputFormat | DiffOutputFormat | DiffOutputFormat.Inline | Output format to display. 114 | Style | DiffStyle | DiffStyle.Word | Showing difference levels, word or character. 115 | ## Component Usage 116 | In your Blazor page, add the `Diff` entry for the desired output format as shown below: 117 | ### For Inline format 118 | No need to specify titles or style for inline as they are are not used for this format. 119 | Also OutputFormat is Inline by default, hence no need to specify the OutputFormat explicitly. 120 | ```html 121 | 123 | ``` 124 | ### For Row or Column formats 125 | ```html 126 | 132 | or 133 | OutputFormat=@DiffOutputFormat.Column 134 | Style=@DiffStyle.Char /> 135 | ``` 136 | ## API Usage 137 | The Diff component can also be used as a library to get `diff` or `html diff` output strings with API calls from code behind. The API interface is defined in `IDiff.cs` as follows: 138 | ```cs 139 | public Task GetAsync(string firstInput, string secondInput, 140 | string firstTitle = DiffInputTitle.First, string secondTitle = DiffInputTitle.Second); 141 | 142 | public Task GetHtmlAsync(string firstInput, string secondInput, 143 | string firstTitle = DiffInputTitle.First, string secondTitle = DiffInputTitle.Second, 144 | DiffOutputFormat outputFormat = DiffOutputFormat.Inline, 145 | DiffStyle style = DiffStyle.Word); 146 | ``` 147 | ### Example 148 | Inject IDiff and call API functions. 149 | ```cs 150 | [Inject] 151 | private IDiff DiffApi { get; set; } 152 | 153 | ... 154 | 155 | public async Task Sample() 156 | { 157 | var firstInput = "Hello World"; 158 | var secondInput = "Hell World!"; 159 | var diff = await DiffApi.GetAsync(firstInput, secondInput); 160 | var diffHtml = await DiffApi.GetHtmlAsync(firstInput, secondInput, 161 | DiffInputTitle.First, DiffInputTitle.Second, 162 | DiffOutputFormat.Row, DiffStyle.Word); 163 | } 164 | ``` 165 | The above code will produce the following outputs: 166 | 167 | diff: 168 | ``` 169 | =================================================================== 170 | --- First 171 | +++ Second 172 | @@ -1,1 +1,1 @@ 173 | -Hello World 174 | \ No newline at end of file 175 | +Hell World! 176 | \ No newline at end of file 177 | ``` 178 | diffHtml: 179 | ```html 180 |
181 |
182 |
183 | 184 | First → Second 187 | RENAMED 188 |
189 |
190 |
191 | 192 | 193 | 194 | 195 | 198 | 199 | 203 | 209 | 210 | 214 | 220 | 221 | 222 |
196 |
@@ -1,1 +1,1 @@
197 |
200 |
1
201 |
202 |
204 |
205 | - 206 | Hello World 207 |
208 |
211 |
212 |
1
213 |
215 |
216 | + 217 | Hell World! 218 |
219 |
223 |
224 |
225 |
226 |
227 | ``` 228 | -------------------------------------------------------------------------------- /DemoApp/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'} -------------------------------------------------------------------------------- /TestHost/Htmlizer.cs: -------------------------------------------------------------------------------- 1 | // Copyright (c) .NET Foundation. All rights reserved. 2 | // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. 3 | 4 | using Microsoft.AspNetCore.Components.RenderTree; 5 | using System; 6 | using System.Collections.Generic; 7 | using System.Diagnostics; 8 | using System.Diagnostics.CodeAnalysis; 9 | using System.Text.Encodings.Web; 10 | 11 | namespace BlazormeTestHost 12 | { 13 | [SuppressMessage("Usage", "BL0006:Do not use RenderTree types", Justification = "")] 14 | internal class Htmlizer 15 | { 16 | private static readonly HtmlEncoder _htmlEncoder = HtmlEncoder.Default; 17 | 18 | private static readonly HashSet _selfClosingElements = new HashSet(StringComparer.OrdinalIgnoreCase) 19 | { 20 | "area", "base", "br", "col", "embed", "hr", "img", "input", "link", "meta", "param", "source", "track", "wbr" 21 | }; 22 | 23 | public static string GetHtml(TestRenderer renderer, int componentId) 24 | { 25 | var frames = renderer.GetCurrentRenderTreeFrames(componentId); 26 | var context = new HtmlRenderingContext(renderer); 27 | var newPosition = RenderFrames(context, frames, 0, frames.Count); 28 | Debug.Assert(newPosition == frames.Count); 29 | return string.Join(string.Empty, context.Result); 30 | } 31 | 32 | private static int RenderFrames(HtmlRenderingContext context, ArrayRange frames, int position, int maxElements) 33 | { 34 | var nextPosition = position; 35 | var endPosition = position + maxElements; 36 | while (position < endPosition) 37 | { 38 | nextPosition = RenderCore(context, frames, position); 39 | if (position == nextPosition) 40 | { 41 | throw new InvalidOperationException("We didn't consume any input."); 42 | } 43 | position = nextPosition; 44 | } 45 | 46 | return nextPosition; 47 | } 48 | 49 | private static int RenderCore( 50 | HtmlRenderingContext context, 51 | ArrayRange frames, 52 | int position) 53 | { 54 | ref var frame = ref frames.Array[position]; 55 | switch (frame.FrameType) 56 | { 57 | case RenderTreeFrameType.Element: 58 | return RenderElement(context, frames, position); 59 | case RenderTreeFrameType.Attribute: 60 | throw new InvalidOperationException($"Attributes should only be encountered within {nameof(RenderElement)}"); 61 | case RenderTreeFrameType.Text: 62 | context.Result.Add(_htmlEncoder.Encode(frame.TextContent)); 63 | return ++position; 64 | case RenderTreeFrameType.Markup: 65 | context.Result.Add(frame.MarkupContent); 66 | return ++position; 67 | case RenderTreeFrameType.Component: 68 | return RenderChildComponent(context, frames, position); 69 | case RenderTreeFrameType.Region: 70 | return RenderFrames(context, frames, position + 1, frame.RegionSubtreeLength - 1); 71 | case RenderTreeFrameType.ElementReferenceCapture: 72 | case RenderTreeFrameType.ComponentReferenceCapture: 73 | return ++position; 74 | default: 75 | throw new InvalidOperationException($"Invalid element frame type '{frame.FrameType}'."); 76 | } 77 | } 78 | 79 | private static int RenderChildComponent( 80 | HtmlRenderingContext context, 81 | ArrayRange frames, 82 | int position) 83 | { 84 | ref var frame = ref frames.Array[position]; 85 | var childFrames = context.Renderer.GetCurrentRenderTreeFrames(frame.ComponentId); 86 | RenderFrames(context, childFrames, 0, childFrames.Count); 87 | return position + frame.ComponentSubtreeLength; 88 | } 89 | 90 | private static int RenderElement( 91 | HtmlRenderingContext context, 92 | ArrayRange frames, 93 | int position) 94 | { 95 | ref var frame = ref frames.Array[position]; 96 | var result = context.Result; 97 | result.Add("<"); 98 | result.Add(frame.ElementName); 99 | var afterAttributes = RenderAttributes(context, frames, position + 1, frame.ElementSubtreeLength - 1, out var capturedValueAttribute); 100 | 101 | // When we see an