Skip to content

Commit

Permalink
Add FDC3 IIFE Bundle Directly from dist
Browse files Browse the repository at this point in the history
  • Loading branch information
kruplm committed Jul 3, 2023
1 parent e28fade commit 66f3901
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 35 deletions.
18 changes: 2 additions & 16 deletions src/shell/dotnet/Shell/App.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,6 @@
// */

using System;
using System.IO;
using System.Reflection;
using System.Text.Json;
using System.Threading;
using System.Threading.Tasks;
Expand Down Expand Up @@ -181,21 +179,9 @@ private void InjectMessageRouterConfig()

private void InjectFdc3()
{
string bundle = @"fdc3-iife-bundle.js";
string iife = ReadPreloadResource(bundle);
string bundle = @"Shell.fdc3-iife-bundle.js";
string iife = ResourceReader.ReadResource(bundle);

WebWindow.AddPreloadScript(iife);
}

public string ReadPreloadResource(string name)
{
var assembly = Assembly.GetExecutingAssembly();
string resourcePath = $$"""Shell.Preload.{{name}}""";

using (var stream = assembly.GetManifestResourceStream(resourcePath))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
12 changes: 3 additions & 9 deletions src/shell/dotnet/Shell/Shell.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,10 @@
<None Remove="MainWindow.xaml" />
<None Remove="WebWindow.xaml" />
</ItemGroup>

<ItemGroup>
<EmbeddedResource Include="Preload\fdc3-iife-bundle.js">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</EmbeddedResource>
<EmbeddedResource Include="..\..\js\composeui-fdc3\dist\fdc3-iife-bundle.js" >
</EmbeddedResource>
</ItemGroup>

<ItemGroup>
Expand All @@ -44,7 +43,6 @@
</ItemGroup>

<ItemGroup>
<Folder Include="Preload\" />
<Folder Include="Utilities\" />
</ItemGroup>

Expand All @@ -53,8 +51,4 @@
<ProjectReference Include="..\..\..\messaging\dotnet\src\Host\MorganStanley.ComposeUI.Messaging.Host.csproj" />
</ItemGroup>

<Target Name="PreBuild" BeforeTargets="PreBuildEvent">
<Exec Command="PowerShell cd ..\..\..\..\ ; .\src\shell\dotnet\copy-fdc3-iife-bundle.ps1" />
</Target>

</Project>
25 changes: 25 additions & 0 deletions src/shell/dotnet/Shell/Utilities/ResourceReader.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;

namespace Shell.Utilities
{
public static class ResourceReader
{
public static string ReadResource(string name)
{
var assembly = Assembly.GetExecutingAssembly();
string resourcePath = name;

using (var stream = assembly.GetManifestResourceStream(resourcePath))
using (var reader = new StreamReader(stream))
{
return reader.ReadToEnd();
}
}
}
}
10 changes: 0 additions & 10 deletions src/shell/dotnet/copy-fdc3-iife-bundle.ps1

This file was deleted.

0 comments on commit 66f3901

Please sign in to comment.