Adds book reading support with EPUB and PDF reader plugins

This commit is contained in:
BinaryAlley committed 2026-09-02 04:45:11 -07:00
1 parent 275fd83ff2
commit f7ccdf3d1c
271 files changed
+11501 -361

No files matched your search

@@ -58,4 +58,38 @@ public interface IMediaLibraryProviderConfigurationStore
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> RemoveProviderConfigurationsAsync(Guid pluginId, CancellationToken cancellationToken);
/// <summary>
/// Adds a disabled book reader configuration for every loaded plugin that supports the provided library type and has no configuration yet, for the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader configurations are ensured.</param>
/// <param name="libraryType">The type of the media library, used to determine the plugins whose book readers apply.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Success>> EnsureBookReaderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
/// <summary>
/// Replaces the book reader configurations of the media library identified by <paramref name="libraryId"/> so that they match the plugins supporting the provided library type.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader configurations are reconciled.</param>
/// <param name="libraryType">The type of the media library, used to determine the plugins whose book readers apply.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Success>> ReconcileBookReaderConfigurationsAsync(Guid libraryId, LibraryType libraryType, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the book reader configurations of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> RemoveBookReaderConfigurationsForLibraryAsync(Guid libraryId, CancellationToken cancellationToken);
/// <summary>
/// Deletes all the book reader configurations referencing the plugin identified by <paramref name="pluginId"/>.
/// </summary>
/// <param name="pluginId">The Id of the plugin whose book reader configurations are deleted.</param>
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
/// <returns>An <see cref="Result{TValue}"/> representing either a successful operation, or an error.</returns>
Task<Result<Deleted>> RemoveBookReaderConfigurationsAsync(Guid pluginId, CancellationToken cancellationToken);
}
@@ -0,0 +1,48 @@
#region ========================================================================= USING =====================================================================================
using System;
#endregion
namespace Lumina.Application.Common.Infrastructure.Reading;
/// <summary>
/// Cache of whether the book reader of a plugin is enabled for a media library. The enablement is read from the database on its first
/// use and cached afterwards, because it is consulted on every section and resource request, and it only changes when the user toggles
/// a reader or a plugin is uninstalled; those operations invalidate the affected entries.
/// </summary>
public interface IBookReaderEnablementCache
{
/// <summary>
/// Gets the cached enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader enablement is retrieved.</param>
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
/// <returns>The cached enablement, or <see langword="null"/> when it is not cached yet.</returns>
bool? Get(Guid libraryId, Guid pluginId);
/// <summary>
/// Caches the enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader enablement is cached.</param>
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
/// <param name="isEnabled">Whether the book reader is enabled for the media library.</param>
void Set(Guid libraryId, Guid pluginId, bool isEnabled);
/// <summary>
/// Removes the cached enablement of the book reader of the plugin identified by <paramref name="pluginId"/> for the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader enablement is invalidated.</param>
/// <param name="pluginId">The Id of the plugin providing the book reader.</param>
void Invalidate(Guid libraryId, Guid pluginId);
/// <summary>
/// Removes every cached enablement of the media library identified by <paramref name="libraryId"/>.
/// </summary>
/// <param name="libraryId">The Id of the media library whose book reader enablements are invalidated.</param>
void InvalidateLibrary(Guid libraryId);
/// <summary>
/// Removes every cached enablement of the plugin identified by <paramref name="pluginId"/>.
/// </summary>
/// <param name="pluginId">The Id of the plugin whose book reader enablements are invalidated.</param>
void InvalidatePlugin(Guid pluginId);
}
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
#endregion
namespace Lumina.Application.Common.Infrastructure.Reading;
/// <summary>
/// Registry of the book readers provided by the loaded plugins.
/// </summary>
public interface IBookReaderRegistry
{
/// <summary>
/// Gets the file extensions supported by the book readers of each loaded plugin, keyed by the Id of the plugin.
/// </summary>
/// <returns>The supported extensions of the book readers, keyed by the Id of the plugin providing them.</returns>
IReadOnlyDictionary<Guid, IReadOnlyList<string>> GetSupportedExtensionsByPluginId();
}