Skip to content

Commit 8437314

Browse files
committed
Fixed embedding file provider
1 parent 01ea51e commit 8437314

File tree

15 files changed

+75
-30
lines changed

15 files changed

+75
-30
lines changed

src/Directory.Packages.props

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
<PackageVersion Include="Microsoft.AspNetCore.Components.WebView.Wpf" Version="8.0.3" />
2121
<PackageVersion Include="Microsoft.CodeAnalysis.CSharp" Version="4.4.0" />
2222
<PackageVersion Include="Microsoft.CodeAnalysis.Analyzers" Version="3.3.4" />
23-
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(DotNetVersion)" Condition="'$(UseMaui)' != 'true'" />
24-
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(DotNetVersion)" Condition="'$(UseMaui)' != 'true'" />
25-
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="$(DotNetVersion)" Condition="'$(UseMaui)' != 'true'" />
23+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Abstractions" Version="$(DotNetVersion)" />
24+
<PackageVersion Include="Microsoft.Extensions.FileProviders.Embedded" Version="$(DotNetVersion)" />
25+
<PackageVersion Include="Microsoft.Extensions.Logging" Version="$(DotNetVersion)" />
26+
<PackageVersion Include="Microsoft.Extensions.Logging.Abstractions" Version="$(DotNetVersion)" />
27+
<PackageVersion Include="Microsoft.Extensions.Logging.Debug" Version="$(DotNetVersion)" />
2628
<PackageVersion Include="Microsoft.NET.Test.Sdk" Version="17.1.0" />
2729
<PackageVersion Include="Microsoft.TypeScript.MSBuild" Version="5.3.2" />
2830
<PackageVersion Include="Microsoft.Windows.CsWin32" Version="0.3.18-beta" />

src/app/dev/DevToys.Blazor/Assets/javascript/monacoEditor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/Assets/javascript/monacoEditor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/Assets/javascript/monacoEditor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class MonacoEditor {
1818
// constructor
1919
static {
2020
// this will force loading the monaco library. It happens on the app startup.
21-
require.config({ paths: { "vs": "_content/DevToys.Blazor/lib/monaco-editor/min/vs" } });
21+
require.config({ paths: { "vs": "_content/DevToys.Blazor/wwwroot/lib/monaco-editor/min/vs" } });
2222
require(["vs/editor/editor.main"]);
2323
}
2424

src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/Components/Layout/SplitGrid/SplitGrid.razor.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ async function loadSplitGridLibrary(): Promise<any> {
6363
// Load split-grid library, if needed.
6464
if (!windowSplitGrid.Split) {
6565
/* eslint-disable no-undef */
66-
require(["_content/DevToys.Blazor/lib/split-grid/split-grid"], function (split) {
66+
require(["_content/DevToys.Blazor/wwwroot/lib/split-grid/split-grid"], function (split) {
6767
windowSplitGrid.Split = split;
6868
resolve(null);
6969
});

src/app/dev/DevToys.Blazor/Components/UIElements/UITextInputWrapper.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@
117117
Items="@SmartDetectionDropDownItems"
118118
AnchorOrigin="Origin.BottomRight"
119119
TransformOrigin="Origin.TopRight">
120-
<img src="@(ToolsDetectedBySmartDetection ? "_content/DevToys.Blazor/img/idea.svg" : "_content/DevToys.Blazor/img/idea-disabled.svg")"
120+
<img src="@(ToolsDetectedBySmartDetection ? "_content/DevToys.Blazor/wwwroot/img/idea.svg" : "_content/DevToys.Blazor/wwwroot/img/idea-disabled.svg")"
121121
class="ui-text-input-wrapper-icon"
122122
style="flex-basis: auto; align-self:center;" />
123123
</DropDownButton>
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
using Microsoft.Extensions.FileProviders;
2+
using Microsoft.Extensions.Primitives;
3+
4+
namespace DevToys.Blazor.Core;
5+
6+
public sealed class DevToysBlazorEmbeddedFileProvider : IFileProvider
7+
{
8+
private const string Content = "_content/";
9+
private const string ContentDevToysBlazor = "_content/DevToys.Blazor";
10+
11+
private readonly EmbeddedFileProvider _embeddedFileProvider
12+
= new(typeof(DevToysBlazorEmbeddedFileProvider).Assembly, baseNamespace: string.Empty);
13+
14+
public IDirectoryContents GetDirectoryContents(string subpath)
15+
{
16+
if (subpath.StartsWith(ContentDevToysBlazor))
17+
{
18+
subpath = subpath.Substring(Content.Length);
19+
return _embeddedFileProvider.GetDirectoryContents(subpath);
20+
}
21+
22+
return NotFoundDirectoryContents.Singleton;
23+
}
24+
25+
public IFileInfo GetFileInfo(string subpath)
26+
{
27+
if (subpath.StartsWith(ContentDevToysBlazor))
28+
{
29+
subpath = subpath.Substring(Content.Length);
30+
return _embeddedFileProvider.GetFileInfo(subpath);
31+
}
32+
33+
string name = Path.GetFileName(subpath);
34+
return new NotFoundFileInfo(name);
35+
}
36+
37+
public IChangeToken Watch(string filter)
38+
{
39+
return _embeddedFileProvider.Watch(filter);
40+
}
41+
}

src/app/dev/DevToys.Blazor/DevToys.Blazor.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@
1212

1313
<ItemGroup>
1414
<PackageReference Include="Microsoft.AspNetCore.Components.Web" />
15+
<PackageReference Include="Microsoft.Extensions.FileProviders.Abstractions" />
16+
<PackageReference Include="Microsoft.Extensions.FileProviders.Embedded" />
1517
<PackageReference Include="Microsoft.Extensions.Logging.Debug" />
1618
<PackageReference Include="Microsoft.TypeScript.MSBuild">
1719
<PrivateAssets>all</PrivateAssets>

src/app/dev/DevToys.Blazor/Pages/Index.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@
161161
Style="flex-grow: 1 !important; flex-basis: auto !important; align-self:center;" />
162162
@if (item is GuiToolViewItem guiToolViewItem2 && guiToolViewItem2.IsRecommended)
163163
{
164-
<img src="_content/DevToys.Blazor/img/idea.svg"
164+
<img src="_content/DevToys.Blazor/wwwroot/img/idea.svg"
165165
height="16"
166166
width="16"
167167
style="flex-basis: auto; align-self:center;" />

src/app/dev/DevToys.Blazor/wwwroot/css/devtoys.g.css

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/DevToys.Blazor/wwwroot/js/devtoys.g.js

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/app/dev/platforms/desktop/DevToys.Windows/Controls/WebView/CustomBlazorWebView.cs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
using Microsoft.AspNetCore.Components.WebView.Wpf;
1+
using DevToys.Blazor.Core;
2+
using Microsoft.AspNetCore.Components.WebView.Wpf;
23
using Microsoft.Extensions.FileProviders;
34

45
namespace DevToys.Windows.Controls.WebView;
@@ -7,8 +8,7 @@ internal sealed class CustomBlazorWebView : BlazorWebView
78
{
89
public override IFileProvider CreateFileProvider(string contentRootDir)
910
{
10-
System.Reflection.Assembly assembly = typeof(DevToys.Blazor.Main).Assembly;
11-
var embeddedProvider = new EmbeddedFileProvider(assembly);
11+
var embeddedProvider = new DevToysBlazorEmbeddedFileProvider();
1212
var physicalProvider = new PhysicalFileProvider(contentRootDir);
1313
return new CompositeFileProvider(physicalProvider, embeddedProvider);
1414
}

src/app/dev/platforms/desktop/DevToys.Windows/wwwroot/index.html

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,13 @@
66
<title>DevToys</title>
77
<base href="/" />
88

9-
<script src="_content/DevToys.Blazor/js/require.js"></script>
10-
<script src="_content/DevToys.Blazor/js/devtoys.js" type="text/javascript"></script>
11-
<script src="_content/DevToys.Blazor/js/devtoys.g.js" type="text/javascript"></script>
12-
<script src="_content/DevToys.Blazor/js/simplebar-modified.js" type="text/javascript"></script>
9+
<script src="_content/DevToys.Blazor/wwwroot/js/require.js"></script>
10+
<script src="_content/DevToys.Blazor/wwwroot/js/devtoys.js" type="text/javascript"></script>
11+
<script src="_content/DevToys.Blazor/wwwroot/js/devtoys.g.js" type="text/javascript"></script>
12+
<script src="_content/DevToys.Blazor/wwwroot/js/simplebar-modified.js" type="text/javascript"></script>
1313

14-
<link href="_content/DevToys.Blazor/css/app.css" rel="stylesheet" />
15-
<link href="_content/DevToys.Blazor/css/devtoys.g.css" rel="stylesheet" />
14+
<link href="_content/DevToys.Blazor/wwwroot/css/app.css" rel="stylesheet" />
15+
<link href="_content/DevToys.Blazor/wwwroot/css/devtoys.g.css" rel="stylesheet" />
1616
</head>
1717

1818
<body>
@@ -22,7 +22,7 @@
2222
<div id="app">
2323
<div id="splash-screen-container">
2424
<img id="splash-screen-image"
25-
src="_content/DevToys.Blazor/img/splash-screen.svg"
25+
src="_content/DevToys.Blazor/wwwroot/img/splash-screen.svg"
2626
width="256"
2727
height="256"
2828
alt="Loading..." />
@@ -35,8 +35,8 @@
3535
<a class="dismiss">🗙</a>
3636
</div>
3737

38-
<script src="_content/DevToys.Blazor/lib/monaco-editor/min/vs/loader.js"></script>
39-
<script src="_content/DevToys.Blazor/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
38+
<script src="_content/DevToys.Blazor/wwwroot/lib/monaco-editor/min/vs/loader.js"></script>
39+
<script src="_content/DevToys.Blazor/wwwroot/lib/monaco-editor/min/vs/editor/editor.main.js"></script>
4040
<script src="_framework/blazor.webview.js"></script>
4141

4242
</body>

0 commit comments

Comments
 (0)