Added internal flag for plugins

This commit is contained in:
Thorsten Sommer 2025-03-27 07:38:37 +01:00
parent 64669088ed
commit 3b0a35eaac
Signed by: tsommer
GPG Key ID: 371BBA77A02C0108
4 changed files with 21 additions and 8 deletions

View File

@ -66,4 +66,9 @@ public interface IPluginMetadata
/// The message that should be displayed when the plugin is deprecated. /// The message that should be displayed when the plugin is deprecated.
/// </summary> /// </summary>
public string DeprecationMessage { get; } public string DeprecationMessage { get; }
/// <summary>
/// True, when the plugin is AI Studio internal.
/// </summary>
public bool IsInternal { get; }
} }

View File

@ -8,6 +8,12 @@ namespace AIStudio.Tools.PluginSystem;
/// </summary> /// </summary>
public abstract class PluginBase : IPluginMetadata public abstract class PluginBase : IPluginMetadata
{ {
private static readonly Guid[] MANDATORY_INTERNAL_PLUGINS =
[
new("97dfb1ba-50c4-4440-8dfa-6575daf543c8"), // Language EN-US (base language)
new("43065dbc-78d0-45b7-92be-f14c2926e2dc"), // Language DE-DE
];
private readonly IReadOnlyCollection<string> baseIssues; private readonly IReadOnlyCollection<string> baseIssues;
protected readonly LuaState state; protected readonly LuaState state;
@ -51,7 +57,10 @@ public abstract class PluginBase : IPluginMetadata
/// <inheritdoc /> /// <inheritdoc />
public string DeprecationMessage { get; } = string.Empty; public string DeprecationMessage { get; } = string.Empty;
/// <inheritdoc />
public bool IsInternal { get; }
/// <summary> /// <summary>
/// The issues that occurred during the initialization of this plugin. /// The issues that occurred during the initialization of this plugin.
/// </summary> /// </summary>
@ -80,7 +89,10 @@ public abstract class PluginBase : IPluginMetadata
this.IconSVG = iconSVG; this.IconSVG = iconSVG;
if(this.TryInitId(out var issue, out var id)) if(this.TryInitId(out var issue, out var id))
{
this.Id = id; this.Id = id;
this.IsInternal = MANDATORY_INTERNAL_PLUGINS.Contains(id);
}
else if(this is not NoPlugin) else if(this is not NoPlugin)
issues.Add(issue); issues.Add(issue);

View File

@ -17,13 +17,6 @@ public static partial class PluginFactory
private static readonly Dictionary<IPluginMetadata, string> AVAILABLE_PLUGINS = new(); private static readonly Dictionary<IPluginMetadata, string> AVAILABLE_PLUGINS = new();
private static readonly SettingsManager SETTINGS = Program.SERVICE_PROVIDER.GetRequiredService<SettingsManager>();
private static readonly Guid[] MANDATORY_INTERNAL_PLUGINS =
[
new("97dfb1ba-50c4-4440-8dfa-6575daf543c8"), // Language EN-US (base language)
];
/// <summary> /// <summary>
/// A list of all available plugins. /// A list of all available plugins.
/// </summary> /// </summary>

View File

@ -43,5 +43,8 @@ public sealed class PluginMetadata(PluginBase plugin) : IPluginMetadata
/// <inheritdoc /> /// <inheritdoc />
public string DeprecationMessage { get; } = plugin.DeprecationMessage; public string DeprecationMessage { get; } = plugin.DeprecationMessage;
/// <inheritdoc />
public bool IsInternal { get; } = plugin.IsInternal;
#endregion #endregion
} }