Skip to content

Commit b2b9f4c

Browse files
authored
refactor: simplify plugin architecutre (#164)
2 parents a2831fb + d5f82de commit b2b9f4c

30 files changed

Lines changed: 394 additions & 297 deletions

SharpFM.sln

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.Plugin.XmlViewer",
2121
EndProject
2222
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.Model", "src\SharpFM.Model\SharpFM.Model.csproj", "{E0FF2DD8-E4B8-4495-92FA-F17AF9B78086}"
2323
EndProject
24+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SharpFM.Plugin.UI", "src\SharpFM.Plugin.UI\SharpFM.Plugin.UI.csproj", "{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}"
25+
EndProject
2426
Global
2527
GlobalSection(SolutionConfigurationPlatforms) = preSolution
2628
Debug|Any CPU = Debug|Any CPU
@@ -115,6 +117,18 @@ Global
115117
{E0FF2DD8-E4B8-4495-92FA-F17AF9B78086}.Release|x64.Build.0 = Release|Any CPU
116118
{E0FF2DD8-E4B8-4495-92FA-F17AF9B78086}.Release|x86.ActiveCfg = Release|Any CPU
117119
{E0FF2DD8-E4B8-4495-92FA-F17AF9B78086}.Release|x86.Build.0 = Release|Any CPU
120+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
121+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|Any CPU.Build.0 = Debug|Any CPU
122+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|x64.ActiveCfg = Debug|Any CPU
123+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|x64.Build.0 = Debug|Any CPU
124+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|x86.ActiveCfg = Debug|Any CPU
125+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Debug|x86.Build.0 = Debug|Any CPU
126+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|Any CPU.ActiveCfg = Release|Any CPU
127+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|Any CPU.Build.0 = Release|Any CPU
128+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|x64.ActiveCfg = Release|Any CPU
129+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|x64.Build.0 = Release|Any CPU
130+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|x86.ActiveCfg = Release|Any CPU
131+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE}.Release|x86.Build.0 = Release|Any CPU
118132
EndGlobalSection
119133
GlobalSection(SolutionProperties) = preSolution
120134
HideSolutionNode = FALSE
@@ -126,5 +140,6 @@ Global
126140
{74337D8E-5EC6-4E5F-9E9E-F2B59E8ECABB} = {E2FF2BB3-AF37-44BA-BD84-999B352D814E}
127141
{E988ECF3-E096-4F29-88C0-27B50FD6C703} = {1515B0F2-1419-4778-92A8-430A8B4931F7}
128142
{E0FF2DD8-E4B8-4495-92FA-F17AF9B78086} = {1515B0F2-1419-4778-92A8-430A8B4931F7}
143+
{8DDBA57D-48E1-400C-A9F6-F02DEFD35EFE} = {1515B0F2-1419-4778-92A8-430A8B4931F7}
129144
EndGlobalSection
130145
EndGlobal

src/SharpFM.Plugin.Sample/ClipInspectorPlugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
using Avalonia.Controls;
55
using SharpFM.Model;
66
using SharpFM.Plugin;
7+
using SharpFM.Plugin.UI;
78

89
namespace SharpFM.Plugin.Sample;
910

1011
public class ClipInspectorPlugin : IPanelPlugin
1112
{
1213
public string Id => "clip-inspector";
1314
public string DisplayName => "Clip Inspector";
15+
public string Description => "Displays clip metadata including name, type, element count, and size.";
1416
public string Version => GetType().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
1517
public IReadOnlyList<PluginKeyBinding> KeyBindings => [];
1618
public IReadOnlyList<PluginMenuAction> MenuActions => [];

src/SharpFM.Plugin.Sample/SharpFM.Plugin.Sample.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<ProjectReference Include="..\SharpFM.Plugin\SharpFM.Plugin.csproj" />
15+
<ProjectReference Include="..\SharpFM.Plugin.UI\SharpFM.Plugin.UI.csproj" />
1616
</ItemGroup>
1717

1818
<ItemGroup>
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
using Avalonia.Controls;
22

3-
namespace SharpFM.Plugin;
3+
namespace SharpFM.Plugin.UI;
44

55
/// <summary>
66
/// A plugin that provides a dockable side panel in the SharpFM UI.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
using System.Threading.Tasks;
2+
using Avalonia.Controls;
3+
4+
namespace SharpFM.Plugin.UI;
5+
6+
/// <summary>
7+
/// Extended host interface for plugins that need UI capabilities beyond
8+
/// the simple dialogs on <see cref="IPluginHost"/>. Provides content
9+
/// dialog hosting backed by Avalonia.
10+
/// </summary>
11+
public interface IPluginUIHost : IPluginHost
12+
{
13+
/// <summary>
14+
/// Show a modal dialog containing plugin-provided content.
15+
/// Returns true if the user accepted (OK), false if cancelled.
16+
/// </summary>
17+
Task<bool> ShowContentDialogAsync(string title, Control content);
18+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<TargetFramework>net10.0</TargetFramework>
4+
<Nullable>enable</Nullable>
5+
<LangVersion>latest</LangVersion>
6+
</PropertyGroup>
7+
8+
<PropertyGroup>
9+
<MinVerMinimumMajorMinor>2.0</MinVerMinimumMajorMinor>
10+
<MinVerTagPrefix>v</MinVerTagPrefix>
11+
<MinVerDefaultPreReleaseIdentifiers>beta.0</MinVerDefaultPreReleaseIdentifiers>
12+
</PropertyGroup>
13+
14+
<ItemGroup>
15+
<ProjectReference Include="..\SharpFM.Plugin\SharpFM.Plugin.csproj" />
16+
</ItemGroup>
17+
18+
<ItemGroup>
19+
<PackageReference Include="Avalonia" Version="11.2.4" />
20+
<PackageReference Include="MinVer" Version="6.0.0">
21+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
22+
<PrivateAssets>all</PrivateAssets>
23+
</PackageReference>
24+
</ItemGroup>
25+
</Project>

src/SharpFM.Plugin.XmlViewer/SharpFM.Plugin.XmlViewer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
</PropertyGroup>
1313

1414
<ItemGroup>
15-
<ProjectReference Include="..\SharpFM.Plugin\SharpFM.Plugin.csproj" />
15+
<ProjectReference Include="..\SharpFM.Plugin.UI\SharpFM.Plugin.UI.csproj" />
1616
</ItemGroup>
1717

1818
<ItemGroup>

src/SharpFM.Plugin.XmlViewer/XmlViewerPlugin.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,15 @@
44
using Avalonia.Controls;
55
using SharpFM.Model;
66
using SharpFM.Plugin;
7+
using SharpFM.Plugin.UI;
78

89
namespace SharpFM.Plugin.XmlViewer;
910

1011
public class XmlViewerPlugin : IPanelPlugin
1112
{
1213
public string Id => "xml-viewer";
1314
public string DisplayName => "XML Viewer";
15+
public string Description => "Live XML panel with syntax highlighting and bidirectional sync.";
1416
public string Version => GetType().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion ?? "0.0.0";
1517

1618
private IPluginHost? _host;

src/SharpFM.Plugin/ClipContentChangedArgs.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace SharpFM.Plugin;
66
/// Event arguments for <see cref="IPluginHost.ClipContentChanged"/>.
77
/// </summary>
88
/// <param name="Clip">Fresh snapshot of the clip with synced XML.</param>
9-
/// <param name="Origin">"editor" for user edits, or the originating plugin's <see cref="IPanelPlugin.Id"/>.</param>
9+
/// <param name="Origin">"editor" for user edits, or the originating plugin's <see cref="IPlugin.Id"/>.</param>
1010
/// <param name="IsPartial">True if the XML was produced from an incomplete parse (e.g. mid-typing).</param>
1111
public record ClipContentChangedArgs(ClipData Clip, string Origin, bool IsPartial);

src/SharpFM.Plugin/IClipTransformPlugin.cs renamed to src/SharpFM.Plugin/IClipTransform.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
namespace SharpFM.Plugin;
44

55
/// <summary>
6-
/// A plugin that transforms clip XML during import or export operations.
7-
/// Transforms run in plugin load order. Use <see cref="IsEnabled"/> to allow
8-
/// users to toggle transforms without uninstalling.
6+
/// A clip transform that runs during import/export operations.
7+
/// Register instances with <see cref="IPluginHost.RegisterTransform"/>.
98
/// </summary>
10-
public interface IClipTransformPlugin : IPlugin
9+
public interface IClipTransform
1110
{
1211
/// <summary>
1312
/// Transform clip XML when a clip is imported (pasted from FileMaker or loaded from storage).
@@ -22,8 +21,7 @@ public interface IClipTransformPlugin : IPlugin
2221
Task<string> OnExportAsync(string clipType, string xml);
2322

2423
/// <summary>
25-
/// Whether this transformer is currently enabled.
26-
/// The user can toggle transformers on/off without uninstalling them.
24+
/// Whether this transform is currently enabled.
2725
/// </summary>
2826
bool IsEnabled { get; set; }
2927
}

0 commit comments

Comments
 (0)