Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Version 3.0.3 #487

Merged
merged 16 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,14 @@ jobs:
uses: actions/setup-java@v1
with:
java-version: 17
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- uses: actions/setup-dotnet@v4
with:
dotnet-version: '9'
- name: Cache SonarCloud packages
uses: actions/cache@v1
uses: actions/cache@v4
with:
path: ~\sonar\cache
key: ${{ runner.os }}-sonar
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: DeployDemoToGitHubPages
env:
PUBLISH_DIR: site/Site/bin/Release/net8.0/publish/wwwroot
PUBLISH_DIR: site/Site/bin/Release/net9.0/publish/wwwroot

on:
push:
Expand Down
21 changes: 20 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,26 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).

## Diagram (3.0.0) - 2024-02-24
## Diagrams (3.0.3) - 2024-12-03

### Added

- Support for .NET 9 (thanks to @[PanayiotisTheodosiou](https://github.com/PanayiotisTheodosiou))
- `registerDefaultBehaviors` argument to `BlazorDiagram` constructor, it's `true` by default and can be disabled if you want to control what behaviors are added and their order.

### Changed

- Make `DiagramCanvas` await un-subscription to resizes subscription (thanks to @[toluwtglobal](https://github.com/toluwtglobal))

### Fixed

- Exception thrown when `node.Visible` was `false` from the creation and the library was trying to observe its resizes when the element won't exist (fixes #476).

### Removed

- gzip versions of assets, it was causing an issue with .NET 9 (fixes #471, thanks a lot @[robertmclaws](https://github.com/robertmclaws))

## Diagram (3.0.2) - 2024-02-24

### Added

Expand Down
72 changes: 41 additions & 31 deletions Directory.Packages.props
Original file line number Diff line number Diff line change
@@ -1,37 +1,47 @@
<Project>

<ItemGroup>
<PackageVersion Include="SvgPathProperties" Version="1.1.2" />
<PackageVersion Include="System.Net.Http.Json" Version="8.0.0" />
<PackageVersion Include="GraphShape" Version="1.2.1" />
<PackageVersion Include="MatBlazor" Version="2.10.0" />
<PackageVersion Include="bunit" Version="1.25.3" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5"/>
<PackageVersion Include="coverlet.collector" Version="6.0.0"/>
</ItemGroup>
<ItemGroup>
<PackageVersion Include="SvgPathProperties" Version="1.1.2" />
<PackageVersion Include="System.Net.Http" Version="4.3.4" />
<PackageVersion Include="System.Net.Http.Json" Version="9.0.0" />
<PackageVersion Include="GraphShape" Version="1.2.1" />
<PackageVersion Include="MatBlazor" Version="2.10.0" />
<PackageVersion Include="bunit" Version="1.36.0" />
<PackageVersion Include="FluentAssertions" Version="6.12.0" />
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.8.0" />
<PackageVersion Include="System.Text.RegularExpressions" Version="4.3.1" />
<PackageVersion Include="xunit" Version="2.6.3" />
<PackageVersion Include="Moq" Version="[4.18.4]" />
<PackageVersion Include="xunit.runner.visualstudio" Version="2.5.5" />
<PackageVersion Include="coverlet.collector" Version="6.0.0" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.25" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net6.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="6.0.25" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="6.0.25" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.14" />
</ItemGroup>
<ItemGroup Condition="'$(TargetFramework)' == 'net7.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="7.0.14" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="7.0.14" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="[8, 9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="[8, 9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="[8,9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="[8,9.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net9.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="[9, 10.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="[9, 10.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="[9, 10.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="[9, 10.0.0)" />
</ItemGroup>

<ItemGroup Condition="'$(TargetFramework)' == 'net8.0'">
<PackageVersion Include="Microsoft.AspNetCore.Components" Version="[8, 9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.Web" Version="[8, 9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly" Version="[8,9.0.0)" />
<PackageVersion Include="Microsoft.AspNetCore.Components.WebAssembly.DevServer" Version="[8,9.0.0)" />
</ItemGroup>
</Project>
2 changes: 1 addition & 1 deletion docs/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
Expand Down
2 changes: 1 addition & 1 deletion samples/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
Expand Down
2 changes: 1 addition & 1 deletion site/Site/Site.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.BlazorWebAssembly">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>Algorithms for Z.Blazor.Diagrams</Description>
<AssemblyVersion>3.0.2</AssemblyVersion>
<FileVersion>3.0.2</FileVersion>
<AssemblyVersion>3.0.3</AssemblyVersion>
<FileVersion>3.0.3</FileVersion>
<RepositoryUrl>https://github.com/zHaytam/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.2</Version>
<Version>3.0.3</Version>
<PackageId>Z.Blazor.Diagrams.Algorithms</PackageId>
<PackageTags>blazor diagrams diagramming svg drag algorithms layouts</PackageTags>
<Product>Z.Blazor.Diagrams.Algorithms</Product>
Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams.Core/Blazor.Diagrams.Core.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,10 @@
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<Authors>zHaytam</Authors>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<AssemblyVersion>3.0.2</AssemblyVersion>
<FileVersion>3.0.2</FileVersion>
<AssemblyVersion>3.0.3</AssemblyVersion>
<FileVersion>3.0.3</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Version>3.0.2</Version>
<Version>3.0.3</Version>
<PackageId>Z.Blazor.Diagrams.Core</PackageId>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<Product>Z.Blazor.Diagrams.Core</Product>
Expand Down
8 changes: 4 additions & 4 deletions src/Blazor.Diagrams.Core/Diagram.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,6 @@
using Blazor.Diagrams.Core.Layers;
using Blazor.Diagrams.Core.Models.Base;
using Blazor.Diagrams.Core.Events;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using Blazor.Diagrams.Core.Options;
using Blazor.Diagrams.Core.Controls;
Expand Down Expand Up @@ -38,7 +35,7 @@
public event Action? ContainerChanged;
public event Action? Changed;

protected Diagram()
protected Diagram(bool registerDefaultBehaviors = true)
{
_behaviors = new Dictionary<Type, Behavior>();
_orderedSelectables = new List<SelectableModel>();
Expand All @@ -56,6 +53,9 @@
Links.Removed += OnSelectableRemoved;
Groups.Removed += OnSelectableRemoved;

if (!registerDefaultBehaviors)
return;

RegisterBehavior(new SelectionBehavior(this));
RegisterBehavior(new DragMovablesBehavior(this));
RegisterBehavior(new DragNewLinkBehavior(this));
Expand Down Expand Up @@ -161,7 +161,7 @@
{
model.Selected = false;
model.Refresh();
// Todo: will result in many events, maybe one event for all of them?

Check warning on line 164 in src/Blazor.Diagrams.Core/Diagram.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 164 in src/Blazor.Diagrams.Core/Diagram.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
SelectionChanged?.Invoke(model);
}
}
Expand Down Expand Up @@ -301,7 +301,7 @@

_orderedSelectables.Insert(0, model);

// Todo: can optimize this by only updating the order of items before model

Check warning on line 304 in src/Blazor.Diagrams.Core/Diagram.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)

Check warning on line 304 in src/Blazor.Diagrams.Core/Diagram.cs

View workflow job for this annotation

GitHub Actions / Build

Complete the task associated to this 'TODO' comment. (https://rules.sonarsource.com/csharp/RSPEC-1135)
Batch(() =>
{
SuspendSorting = true;
Expand Down
8 changes: 4 additions & 4 deletions src/Blazor.Diagrams/Blazor.Diagrams.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
<Nullable>enable</Nullable>
<Authors>zHaytam</Authors>
<PackageLicenseExpression>MIT</PackageLicenseExpression>
<AssemblyVersion>3.0.2</AssemblyVersion>
<FileVersion>3.0.2</FileVersion>
<AssemblyVersion>3.0.3</AssemblyVersion>
<FileVersion>3.0.3</FileVersion>
<RepositoryUrl>https://github.com/Blazor-Diagrams/Blazor.Diagrams</RepositoryUrl>
<Description>A fully customizable and extensible all-purpose diagrams library for Blazor</Description>
<Version>3.0.2</Version>
<Version>3.0.3</Version>
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
<PackageTags>blazor diagrams diagramming svg drag</PackageTags>
<PackageId>Z.Blazor.Diagrams</PackageId>
Expand Down Expand Up @@ -47,7 +47,7 @@
</Target>

<Target Name="CompileStaticAssets" AfterTargets="CoreCompile;TestWebCompiler" Condition="'$(ErrorCode)' == '0'">
<Exec Command="webcompiler -r wwwroot" StandardOutputImportance="high" StandardErrorImportance="high" />
<Exec Command="webcompiler --zip disable -r wwwroot" StandardOutputImportance="high" StandardErrorImportance="high" />
</Target>

</Project>
6 changes: 2 additions & 4 deletions src/Blazor.Diagrams/BlazorDiagram.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Collections.Generic;
using Blazor.Diagrams.Components.Controls;
using Blazor.Diagrams.Components.Controls;
using Blazor.Diagrams.Core;
using Blazor.Diagrams.Core.Controls.Default;
using Blazor.Diagrams.Core.Models.Base;
Expand All @@ -12,7 +10,7 @@ public class BlazorDiagram : Diagram
{
private readonly Dictionary<Type, Type> _componentsMapping;

public BlazorDiagram(BlazorDiagramOptions? options = null)
public BlazorDiagram(BlazorDiagramOptions? options = null, bool registerDefaultBehaviors = true) : base(registerDefaultBehaviors)
{
_componentsMapping = new Dictionary<Type, Type>
{
Expand Down
6 changes: 3 additions & 3 deletions src/Blazor.Diagrams/Components/DiagramCanvas.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace Blazor.Diagrams.Components;

public partial class DiagramCanvas : IDisposable
public partial class DiagramCanvas : IAsyncDisposable
{
private DotNetObjectReference<DiagramCanvas>? _reference;
private bool _shouldRender;
Expand All @@ -27,15 +27,15 @@ public partial class DiagramCanvas : IDisposable

[Inject] public IJSRuntime JSRuntime { get; set; } = null!;

public void Dispose()
public async ValueTask DisposeAsync()
{
BlazorDiagram.Changed -= OnDiagramChanged;

if (_reference == null)
return;

if (elementReference.Id != null)
_ = JSRuntime.UnobserveResizes(elementReference);
await JSRuntime.UnobserveResizes(elementReference);

_reference.Dispose();
}
Expand Down
7 changes: 4 additions & 3 deletions src/Blazor.Diagrams/Components/Renderers/NodeRenderer.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
using System;
using System.Text;
using System.Threading.Tasks;
using System.Text;
using Blazor.Diagrams.Core.Extensions;
using Blazor.Diagrams.Core.Geometry;
using Blazor.Diagrams.Core.Models;
Expand Down Expand Up @@ -129,6 +127,9 @@ protected override void BuildRenderTree(RenderTreeBuilder builder)

protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender && !Node.Visible)
return;

if (firstRender || _becameVisible)
{
_becameVisible = false;
Expand Down
Binary file removed src/Blazor.Diagrams/wwwroot/default.styles.min.css.gz
Binary file not shown.
Binary file removed src/Blazor.Diagrams/wwwroot/script.min.js.gz
Binary file not shown.
Binary file removed src/Blazor.Diagrams/wwwroot/style.min.css.gz
Binary file not shown.
12 changes: 6 additions & 6 deletions src/Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<Project>
<PropertyGroup>
<TargetFrameworks>net8.0;net7.0;net6.0;</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
<PropertyGroup>
<TargetFrameworks>net9.0;net8.0;net7.0;net6.0;</TargetFrameworks>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<ManagePackageVersionsCentrally>true</ManagePackageVersionsCentrally>
</PropertyGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
<ItemGroup>
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Net.Http" />
<PackageReference Include="System.Text.RegularExpressions" />
<PackageReference Include="xunit" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit.runner.visualstudio" >
<PackageReference Include="xunit.runner.visualstudio">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
<PackageReference Include="coverlet.collector" >
<PackageReference Include="coverlet.collector">
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
<PrivateAssets>all</PrivateAssets>
</PackageReference>
Expand Down
2 changes: 2 additions & 0 deletions tests/Blazor.Diagrams.Tests/Blazor.Diagrams.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
<PackageReference Include="bunit" />
<PackageReference Include="FluentAssertions" />
<PackageReference Include="Microsoft.NET.Test.Sdk" />
<PackageReference Include="System.Net.Http" />
<PackageReference Include="System.Text.RegularExpressions" />
<PackageReference Include="xunit" />
<PackageReference Include="Moq" />
<PackageReference Include="xunit.runner.visualstudio" />
Expand Down
28 changes: 28 additions & 0 deletions tests/Blazor.Diagrams.Tests/Components/DiagramCanvasTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
using Blazor.Diagrams.Components;
using Blazor.Diagrams.Core.Geometry;
using Bunit;
using Xunit;

namespace Blazor.Diagrams.Tests.Components
{
public class DiagramCanvasTests
{
[Fact]
public void Behavior_WhenDisposing_ShouldUnsubscribeToResizes()
{
// Arrange
JSRuntimeInvocationHandler call;
using (var ctx = new TestContext())
{
ctx.JSInterop.Setup<Rectangle>("ZBlazorDiagrams.getBoundingClientRect", _ => true);
call = ctx.JSInterop.SetupVoid("ZBlazorDiagrams.unobserve", _ => true).SetVoidResult();

// Act
var cut = ctx.RenderComponent<DiagramCanvas>(p => p.Add(n => n.BlazorDiagram, new BlazorDiagram()));
}

// Assert
call.VerifyInvoke("ZBlazorDiagrams.unobserve", calledTimes: 1);
}
}
}
Loading
Loading