-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
24 changed files
with
366 additions
and
6,887 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,188 @@ | ||
@code { | ||
|
||
[Parameter] | ||
public bool Interactive { get; set; } = true; | ||
|
||
[Inject] | ||
public Tools.IDevTools DevToolsData { get; set; } = default!; | ||
|
||
private string view = "pages"; | ||
|
||
protected override async void OnInitialized() { | ||
Console.WriteLine("DevTools.OnInitialized"); | ||
Console.WriteLine($"View: {view}"); | ||
|
||
if(!OperatingSystem.IsBrowser()) { | ||
@* Routes.Clear(); *@ | ||
@* Routes = FindRoutes(); *@ | ||
@* Components = FindComponentsUsed(); *@ | ||
await InvokeAsync(StateHasChanged); | ||
} | ||
|
||
} | ||
|
||
private void SetView(string view) { | ||
this.view = view; | ||
@* InvokeAsync(StateHasChanged); *@ | ||
} | ||
|
||
private IList<string> FindRoutes() | ||
{ | ||
var result = new List<string>(); | ||
var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(asm => !asm.FullName.StartsWith("Microsoft.") || !asm.FullName.StartsWith("System.")); | ||
foreach(var asm in assemblies) { | ||
result.AddRange( | ||
asm.GetExportedTypes() | ||
.Select(t => { | ||
Console.WriteLine($"Looking for Routes in {t.Assembly.FullName}"); | ||
return t; | ||
}) | ||
.Where(t => t.GetCustomAttributes(typeof(RouteAttribute), true).Count() > 0) | ||
.Select(t => | ||
{ | ||
var route = t.GetCustomAttributes(typeof(RouteAttribute), true).FirstOrDefault() as RouteAttribute; | ||
return route!.Template; | ||
}) | ||
); | ||
} | ||
|
||
return result; | ||
@* return AppDomain.CurrentDomain.GetAssemblies() | ||
.GetExportedTypes() | ||
.Select(t => { | ||
Console.WriteLine($"Looking for Routes in {t.Assembly.FullName}"); | ||
return t; | ||
}) | ||
.Where(t => t.GetCustomAttributes(typeof(RouteAttribute), true).Count() > 0) | ||
.Select(t => | ||
{ | ||
var route = t.GetCustomAttributes(typeof(RouteAttribute), true).FirstOrDefault() as RouteAttribute; | ||
return route!.Template; | ||
}).ToList(); *@ | ||
|
||
} | ||
|
||
private IList<string> FindComponentsUsed() | ||
{ | ||
var result = new List<string>(); | ||
@* var assemblies = AppDomain.CurrentDomain.GetAssemblies(); *@ | ||
var assemblies = | ||
new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory).GetFiles("*.dll").ToList().Select(file => { | ||
// load assembly for reflection only | ||
var assembly = System.Reflection.Assembly.LoadFile(file.FullName); | ||
return assembly; | ||
}); | ||
|
||
foreach (var assembly in assemblies) | ||
{ | ||
Console.WriteLine(assembly.FullName); | ||
result.AddRange( | ||
assembly | ||
.GetExportedTypes() | ||
.Where(t => t.IsClass) | ||
@* .Where(t => t.BaseType.Name == "ComponentBase") *@ | ||
.Where(t => t.BaseType == (typeof(ComponentBase)) || t.BaseType.Name == "ReactiveComponentEnvelope") | ||
.Select(t => | ||
{ | ||
return $"{t.FullName}"; | ||
}) | ||
); | ||
} | ||
return result.Distinct().ToList(); | ||
} | ||
} | ||
<style> | ||
/* define a css variable devtools-width */ | ||
:root { | ||
--devtools-width: 80; | ||
} | ||
.devtools { | ||
position: fixed; | ||
left: 50%; | ||
bottom: 0; | ||
} | ||
.devtools-button { | ||
width: var(--devtools-width)px !important; | ||
left: calc(var(--devtools-width) * 0.5px * -1); | ||
position: relative; | ||
height: var(--devtools-width)px !important; | ||
padding: 5px; | ||
display: flex; | ||
justify-content: center; | ||
align-items: center; | ||
& img { | ||
width: calc(var(--devtools-width) * 0.5px); | ||
filter: invert(1); | ||
} | ||
} | ||
</style> | ||
<div data-permanent class="devtools"> | ||
<script> | ||
function toggleDevTools() { | ||
const dialog = document.getElementById("devtools"); | ||
if(!dialog.open) { | ||
dialog.showModal(); | ||
} else { | ||
dialog.close(); | ||
} | ||
} | ||
</script> | ||
<!-- Button to trigger the modal --> | ||
<button | ||
data-target="devtools" | ||
class="devtools-button" | ||
onClick="toggleDevTools()"> | ||
<img src="./images/blazekit-logo.svg" alt="BlazeKit Logo" /> | ||
<span>🛠️</span> | ||
</button> | ||
|
||
<!-- Modal --> | ||
<dialog id="devtools"> | ||
<article> | ||
<a href="#close" | ||
aria-label="Close" | ||
class="close" | ||
data-target="modal-example" | ||
onClick="toggleModal(event)"> | ||
</a> | ||
<h3>BlazeKit DevTools</h3> | ||
<p> | ||
Use the DevTools to inspect the components and routes in your application. | ||
</p> | ||
<article> | ||
<details> | ||
<summary role="button">Routes</summary> | ||
<ul> | ||
@foreach (var route in DevToolsData.Routes()) | ||
{ | ||
<li><a href="@(route)">@route</a></li> | ||
} | ||
</ul> | ||
</details> | ||
<details> | ||
<summary role="button">Components</summary> | ||
<ul> | ||
@foreach (var component in DevToolsData.Components()) | ||
{ | ||
<li>@component</li> | ||
} | ||
</ul> | ||
</details> | ||
</article> | ||
<footer> | ||
<button | ||
@* role="button" *@ | ||
data-target="devtools" | ||
onClick="toggleDevTools()"> | ||
Close | ||
</button> | ||
</footer> | ||
</article> | ||
</dialog> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using Microsoft.AspNetCore.Components; | ||
using Microsoft.AspNetCore.Components.Rendering; | ||
|
||
namespace BlazeKit.Website.Islands; | ||
|
||
public abstract class WASMIsland : ComponentBase | ||
{ | ||
[Parameter] | ||
public ClientLoadMode Client { get; set; } = ClientLoadMode.Idle; | ||
|
||
public WASMIsland() | ||
{ | ||
} | ||
|
||
public enum ClientLoadMode | ||
{ | ||
Idle, | ||
Hover, | ||
Visible, | ||
None | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
namespace BlazeKit.Tools; | ||
public interface IDevTools { | ||
|
||
IList<string> Routes(); | ||
IList<string> Components(); | ||
|
||
} | ||
|
||
public class DevToolsState : IDevTools { | ||
|
||
private readonly IList<string> routes; | ||
private readonly IList<string> components; | ||
|
||
public DevToolsState(IList<string> routes, IList<string> components) | ||
{ | ||
this.routes = routes; | ||
this.components = components; | ||
} | ||
|
||
public IList<string> Routes() => routes; | ||
public IList<string> Components() => components; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
<div id="blazor-loader" class="linear-progress"></div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.