Skip to content

Commit c2ed569

Browse files
committed
Updated DevToys MacOS
1 parent 8437314 commit c2ed569

File tree

8 files changed

+19
-172
lines changed

8 files changed

+19
-172
lines changed

src/DevToys-MacOS.sln

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,6 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution
3333
EndProjectSection
3434
EndProject
3535
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "desktops", "desktops", "{22EE9386-CEFA-47D8-97B2-09A63EDF7F2E}"
36-
ProjectSection(SolutionItems) = preProject
37-
app\dev\platforms\desktop\Directory.Build.props = app\dev\platforms\desktop\Directory.Build.props
38-
app\dev\platforms\desktop\Directory.Build.targets = app\dev\platforms\desktop\Directory.Build.targets
39-
EndProjectSection
4036
EndProject
4137
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "DevToys.CLI", "app\dev\platforms\desktop\DevToys.CLI\DevToys.CLI.csproj", "{8C72D38A-658D-4C9D-B0AD-2DA975BE7826}"
4238
EndProject

src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorAssetFileProvider.cs

Lines changed: 0 additions & 75 deletions
This file was deleted.

src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebView.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1+
using DevToys.Blazor.Core;
12
using Microsoft.Extensions.DependencyInjection;
3+
using Microsoft.Extensions.FileProviders;
24
using WebKit;
35

46
namespace DevToys.Linux.Components;
@@ -26,7 +28,7 @@ internal BlazorWebView(IServiceProvider serviceProvider)
2628
this,
2729
serviceProvider,
2830
options,
29-
contentRootDir,
31+
CreateFileProvider(options, contentRootDir),
3032
hostPageRelativePath,
3133
OnBlazorInitialized);
3234
}
@@ -37,4 +39,12 @@ private void OnBlazorInitialized()
3739
{
3840
BlazorWebViewInitialized?.Invoke(this, EventArgs.Empty);
3941
}
42+
43+
private static IFileProvider CreateFileProvider(BlazorWebViewOptions options, string contentRootDir)
44+
{
45+
string bundleRootDir = Path.Combine(options.ContentRoot, contentRootDir);
46+
var physicalProvider = new PhysicalFileProvider(bundleRootDir);
47+
var embeddedProvider = new DevToysBlazorEmbeddedFileProvider();
48+
return new CompositeFileProvider(physicalProvider, embeddedProvider);
49+
}
4050
}

src/app/dev/platforms/desktop/DevToys.Linux/Components/BlazorWebView/BlazorWebViewBridge.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,14 @@ public BlazorWebViewBridge(
2222
BlazorWebView webView,
2323
IServiceProvider serviceProvider,
2424
BlazorWebViewOptions options,
25-
string contentRootRelativeToAppRoot,
25+
IFileProvider fileProvider,
2626
string hostPageRelativePath,
2727
Action onBlazorInitialized)
2828
: base(
2929
serviceProvider,
3030
Dispatcher.CreateDefault(),
3131
AppOriginUri,
32-
new BlazorAssetFileProvider(Path.Combine(options.ContentRoot, contentRootRelativeToAppRoot)),
32+
fileProvider,
3333
new JSComponentConfigurationStore(),
3434
hostPageRelativePath)
3535
{

src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorAssetFileProvider.cs

Lines changed: 0 additions & 74 deletions
This file was deleted.

src/app/dev/platforms/desktop/DevToys.MacOS/Controls/BlazorWebView/BlazorWKWebView.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
using System.Collections.Specialized;
22
using System.Globalization;
33
using DevToys.Api;
4+
using DevToys.Blazor.Core;
45
using Microsoft.Extensions.FileProviders;
56
using Microsoft.Extensions.Logging;
67
using WebKit;
@@ -259,7 +260,10 @@ private void StartWebViewCoreIfPossible()
259260

260261
private static IFileProvider CreateFileProvider(string contentRootDir)
261262
{
262-
return new BlazorAssetFileProvider(contentRootDir);
263+
string bundleRootDir = Path.Combine(NSBundle.MainBundle.ResourcePath, contentRootDir);
264+
var physicalProvider = new PhysicalFileProvider(bundleRootDir);
265+
var embeddedProvider = new DevToysBlazorEmbeddedFileProvider();
266+
return new CompositeFileProvider(physicalProvider, embeddedProvider);
263267
}
264268

265269
[LoggerMessage(EventId = 0, Level = LogLevel.Debug, Message = "Creating file provider at content root '{contentRootDir}', using host page relative path '{hostPageRelativePath}'.")]

src/app/dev/platforms/desktop/DevToys.MacOS/DevToys.MacOS.csproj

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -81,19 +81,5 @@
8181
<Content Remove="Assets.xcassets\AppIcon.appiconset\Contents.json"/>
8282
<BundleResource Include="Assets.xcassets\AppIcon.appiconset\Contents.json"/>
8383
</ItemGroup>
84-
85-
<Target Name="PublishStaticWebAssetsFiles" AfterTargets="_ComputePublishLocation">
86-
<!-- Include the .staticwebassets.runtime.json files to the app bundle -->
87-
<PropertyGroup>
88-
<_AssemblyPublishDir Condition="'$(_PlatformName)' == 'iOS' Or '$(_PlatformName)' == 'tvOS' Or '$(_PlatformName)' == 'watchOS'">$(_RelativeAppBundlePath)\</_AssemblyPublishDir>
89-
<_AssemblyPublishDir Condition="'$(_PlatformName)' == 'macOS' Or '$(_PlatformName)' == 'MacCatalyst'">$(_RelativeAppBundlePath)\Contents\$(_CustomBundleName)\</_AssemblyPublishDir>
90-
</PropertyGroup>
91-
<ItemGroup>
92-
<StaticWebAssetsFiles Include="$(OutputPath)\*.staticwebassets.runtime.json"/>
93-
<ResolvedFileToPublish
94-
Include="@(StaticWebAssetsFiles)"
95-
RelativePath="$(_AssemblyPublishDir)\%(Filename)%(Extension)" />
96-
</ItemGroup>
97-
</Target>
9884

9985
</Project>

src/app/dev/platforms/desktop/DevToys.MacOS/Views/MainWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ private void InitializeView()
105105
// Create WebView and add it to NSVisualEffectView
106106
Guard.IsNotNull(AppDelegate.ServiceProvider);
107107
var webView = new BlazorWkWebView(AppDelegate.ServiceProvider, EnableDeveloperTools);
108-
webView.BlazorWebViewInitialized+= OnBlazorWebViewInitialized;
108+
webView.BlazorWebViewInitialized += OnBlazorWebViewInitialized;
109109
visualEffectView.AddSubview(webView.View);
110110

111111
// Make the WKWebView resizing with the window and anchor it below the title bar, so we can still move the window with the title bar.

0 commit comments

Comments
 (0)