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

@@ -0,0 +1,27 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for the normalized document model of a book, produced by a reader plugin.
/// </summary>
/// <param name="Title">The title of the book.</param>
/// <param name="Author">The author of the book, if known.</param>
/// <param name="CoverResourceKey">The resource key of the cover image of the book, if applicable.</param>
/// <param name="TableOfContents">The hierarchical table of contents of the book.</param>
/// <param name="Spine">The ordered spine of the reading sections of the book.</param>
/// <param name="Resources">The resources of the book, keyed by their resource key.</param>
/// <param name="HasTextContent">Whether the book has extractable text content. A scanned book, whose pages are only images, has no text content.</param>
[DebuggerDisplay("Title: {Title}")]
public sealed record ReadingDocumentDto(
string Title,
string? Author,
string? CoverResourceKey,
IReadOnlyList<ReadingTocEntryDto> TableOfContents,
IReadOnlyList<ReadingSpineItemDto> Spine,
IReadOnlyDictionary<string, ReadingResourceInfoDto> Resources,
bool HasTextContent
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for the binary data of a reading resource.
/// </summary>
/// <param name="Data">The binary data of the resource.</param>
/// <param name="MimeType">The MIME type of the resource.</param>
[DebuggerDisplay("MimeType: {MimeType}")]
public sealed record ReadingResourceDataDto(
byte[] Data,
string MimeType
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for the file information of a resource of a reading document.
/// </summary>
/// <param name="RelativeFilePath">The path of the resource file, relative to the extraction directory of the book.</param>
/// <param name="MimeType">The MIME type of the resource.</param>
[DebuggerDisplay("RelativeFilePath: {RelativeFilePath}")]
public sealed record ReadingResourceInfoDto(
string RelativeFilePath,
string MimeType
);
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for the content of a reading section.
/// </summary>
/// <param name="LocationRef">The opaque location reference of the reading section.</param>
/// <param name="Title">The title of the reading section, if known.</param>
/// <param name="ContentHtml">The sanitized HTML content of the reading section, ready to be rendered by the client.</param>
[DebuggerDisplay("LocationRef: {LocationRef}")]
public sealed record ReadingSectionDto(
string LocationRef,
string? Title,
string ContentHtml
);
@@ -0,0 +1,18 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for an item of the spine of a reading document.
/// </summary>
/// <param name="LocationRef">The opaque location reference of the reading section.</param>
/// <param name="Title">The title of the reading section, if known.</param>
/// <param name="RelativeSectionFilePath">The path of the section content file, relative to the extraction directory of the book.</param>
[DebuggerDisplay("LocationRef: {LocationRef}")]
public sealed record ReadingSpineItemDto(
string LocationRef,
string? Title,
string RelativeSectionFilePath
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.DTO.MediaLibrary.WrittenContentLibrary.BookLibrary.Reading;
/// <summary>
/// Data transfer object for an entry of the table of contents of a reading document.
/// </summary>
/// <param name="Label">The label of the table of contents entry.</param>
/// <param name="LocationRef">The opaque location reference of the reading section the entry points to.</param>
/// <param name="Children">The child entries of the table of contents entry.</param>
[DebuggerDisplay("Label: {Label}")]
public sealed record ReadingTocEntryDto(
string Label,
string LocationRef,
IReadOnlyList<ReadingTocEntryDto> Children
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents a request to check the reading availability of a book.
/// </summary>
/// <param name="BookId">The Id of the book whose reading availability is checked. Required.</param>
[DebuggerDisplay("BookId: {BookId}")]
public sealed record GetReadingAvailabilityRequest(
Guid BookId
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents a request to get the reading manifest of a book.
/// </summary>
/// <param name="BookId">The Id of the book whose reading manifest is retrieved. Required.</param>
[DebuggerDisplay("BookId: {BookId}")]
public sealed record GetReadingManifestRequest(
Guid BookId
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents a request to get a resource of a book, for reading.
/// </summary>
/// <param name="BookId">The Id of the book whose resource is retrieved. Required.</param>
/// <param name="ResourceKey">The opaque resource key of the resource. Required.</param>
[DebuggerDisplay("BookId: {BookId}, ResourceKey: {ResourceKey}")]
public sealed record GetReadingResourceRequest(
Guid BookId,
string ResourceKey
);
@@ -0,0 +1,17 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents a request to get the content of a reading section of a book.
/// </summary>
/// <param name="BookId">The Id of the book whose reading section is retrieved. Required.</param>
/// <param name="LocationRef">The opaque location reference of the reading section. Required.</param>
[DebuggerDisplay("BookId: {BookId}, LocationRef: {LocationRef}")]
public sealed record GetReadingSectionRequest(
Guid BookId,
string LocationRef
);
@@ -0,0 +1,15 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Plugins;
/// <summary>
/// Represents a request to get the book readers configured for a media library.
/// </summary>
/// <param name="LibraryId">The Id of the media library whose book readers are retrieved. Required.</param>
[DebuggerDisplay("LibraryId: {LibraryId}")]
public sealed record GetLibraryBookReadersRequest(
Guid LibraryId
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Requests.Plugins;
/// <summary>
/// Represents a request to enable or disable a book reader for a media library.
/// </summary>
/// <param name="LibraryId">The Id of the media library whose book reader is enabled or disabled. Required.</param>
/// <param name="PluginId">The unique identifier of the plugin providing the book reader. Required.</param>
/// <param name="IsEnabled">Whether the book reader should be enabled for the media library. Required.</param>
[DebuggerDisplay("LibraryId: {LibraryId}, PluginId: {PluginId}")]
public sealed record SetLibraryBookReaderEnabledRequest(
Guid LibraryId,
Guid PluginId,
bool IsEnabled
);
@@ -12,11 +12,15 @@ namespace Lumina.Contracts.Requests.UsersManagement.Settings;
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not. Required.</param>
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not. Required.</param>
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not. Required.</param>
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not. Required.</param>
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not. Required.</param>
[DebuggerDisplay("IsPaginationEnabled: {IsPaginationEnabled}; ItemsPerPage: {ItemsPerPage}")]
public sealed record UpdateUserSettingsRequest(
bool IsPaginationEnabled,
int ItemsPerPage,
bool ShouldIgnoreThePrefixForAlphaPicker,
bool IsThemeCachingEnabled,
bool ShouldAggregateMetadataWhenMissing
bool ShouldAggregateMetadataWhenMissing,
bool ShouldRenderPdfAsImages,
bool ShouldPreserveBookStyles
);
@@ -0,0 +1,21 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents the reading availability of a book.
/// </summary>
/// <param name="BookId">The Id of the book whose reading availability is reported.</param>
/// <param name="LibraryId">The Id of the media library the book belongs to.</param>
/// <param name="IsAvailable">Whether the book can be opened for reading.</param>
/// <param name="ErrorCode">The code of the error preventing the book from being read, when it cannot be read. Can be <see langword="null"/> when the book is available.</param>
[DebuggerDisplay("BookId: {BookId}, IsAvailable: {IsAvailable}")]
public sealed record ReadingAvailabilityResponse(
Guid BookId,
Guid LibraryId,
bool IsAvailable,
string? ErrorCode
);
@@ -0,0 +1,27 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents the reading manifest of a book, containing everything the client needs to render the reader.
/// </summary>
/// <param name="Title">The title of the book.</param>
/// <param name="Author">The author of the book, if known.</param>
/// <param name="CoverResourceKey">The resource key of the cover image of the book, if applicable.</param>
/// <param name="TableOfContents">The hierarchical table of contents of the book.</param>
/// <param name="Spine">The ordered spine of the reading sections of the book.</param>
/// <param name="ResourceKeys">The resource keys of the resources of the book.</param>
/// <param name="HasTextContent">Whether the book has extractable text content. A scanned book, whose pages are only images, has no text content.</param>
[DebuggerDisplay("Title: {Title}")]
public sealed record ReadingManifestResponse(
string Title,
string? Author,
string? CoverResourceKey,
IReadOnlyList<ReadingTocEntryResponse> TableOfContents,
IReadOnlyList<ReadingSpineItemResponse> Spine,
IReadOnlyList<string> ResourceKeys,
bool HasTextContent
);
@@ -0,0 +1,16 @@
#region ========================================================================= USING =====================================================================================
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents an item of the spine of the reading manifest of a book.
/// </summary>
/// <param name="LocationRef">The opaque location reference of the reading section.</param>
/// <param name="Title">The title of the reading section, if known.</param>
[DebuggerDisplay("LocationRef: {LocationRef}")]
public sealed record ReadingSpineItemResponse(
string LocationRef,
string? Title
);
@@ -0,0 +1,19 @@
#region ========================================================================= USING =====================================================================================
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.MediaLibrary.WrittenContentLibrary.BookLibrary.Books.Reading;
/// <summary>
/// Represents an entry of the table of contents of the reading manifest of a book.
/// </summary>
/// <param name="Label">The label of the table of contents entry.</param>
/// <param name="LocationRef">The opaque location reference of the reading section the entry points to.</param>
/// <param name="Children">The child entries of the table of contents entry.</param>
[DebuggerDisplay("Label: {Label}")]
public sealed record ReadingTocEntryResponse(
string Label,
string LocationRef,
IReadOnlyList<ReadingTocEntryResponse> Children
);
@@ -0,0 +1,22 @@
#region ========================================================================= USING =====================================================================================
using System;
using System.Collections.Generic;
using System.Diagnostics;
#endregion
namespace Lumina.Contracts.Responses.Plugins;
/// <summary>
/// Represents a book reader configured for a media library.
/// </summary>
/// <param name="PluginId">The unique identifier of the plugin providing the book reader.</param>
/// <param name="Name">The display name of the book reader.</param>
/// <param name="SupportedExtensions">The file extensions supported by the book reader.</param>
/// <param name="IsEnabled">Whether the book reader is enabled for the media library.</param>
[DebuggerDisplay("Name: {Name}")]
public sealed record LibraryBookReaderResponse(
Guid PluginId,
string Name,
IReadOnlyList<string> SupportedExtensions,
bool IsEnabled
);
@@ -14,6 +14,8 @@ namespace Lumina.Contracts.Responses.UsersManagement.Settings;
/// <param name="ShouldIgnoreThePrefixForAlphaPicker">Whether the "The" prefix of library item titles is ignored by the alpha picker, or not.</param>
/// <param name="IsThemeCachingEnabled">Whether the theme data served to this user is cached, or not.</param>
/// <param name="ShouldAggregateMetadataWhenMissing">Whether the metadata of the media library items is aggregated from multiple providers, when fields are missing, or not.</param>
/// <param name="ShouldRenderPdfAsImages">Whether PDF books are rendered as page images for the user, or not.</param>
/// <param name="ShouldPreserveBookStyles">Whether the styles of the book content are preserved when it is rendered for the user, or not.</param>
[DebuggerDisplay("UserId: {UserId}")]
public sealed record UserSettingsResponse(
Guid UserId,
@@ -21,5 +23,7 @@ public sealed record UserSettingsResponse(
int ItemsPerPage,
bool ShouldIgnoreThePrefixForAlphaPicker,
bool IsThemeCachingEnabled,
bool ShouldAggregateMetadataWhenMissing
bool ShouldAggregateMetadataWhenMissing,
bool ShouldRenderPdfAsImages,
bool ShouldPreserveBookStyles
);