mirror of
https://github.com/BinaryAlley/Nemera.git
synced 2026-12-03 12:11:10 +00:00
Adds the server-side theme repository and reworks the web theme engine onto it
This commit is contained in:
1 parent
85928f7c3c
commit
bf8faba24d
136 files changed
+6942
-1197
No files matched your search
@@ -0,0 +1,19 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a downloadable archive of a theme pack.
|
||||
/// </summary>
|
||||
/// <param name="Bytes">The bytes of the ZIP archive.</param>
|
||||
/// <param name="FileName">The file name to expose when downloading the archive.</param>
|
||||
/// <param name="ContentType">The MIME content type of the archive.</param>
|
||||
[DebuggerDisplay("FileName: {FileName}")]
|
||||
public sealed record ThemeArchiveDto(
|
||||
byte[] Bytes,
|
||||
string FileName,
|
||||
string ContentType
|
||||
);
|
||||
@@ -0,0 +1,17 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for a theme asset file served by the theme service.
|
||||
/// </summary>
|
||||
/// <param name="Bytes">The bytes of the asset file.</param>
|
||||
/// <param name="ContentType">The MIME content type of the asset file.</param>
|
||||
[DebuggerDisplay("ContentType: {ContentType}")]
|
||||
public sealed record ThemeAssetDto(
|
||||
byte[] Bytes,
|
||||
string ContentType
|
||||
);
|
||||
@@ -0,0 +1,54 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Data transfer object for the theme.json manifest of a theme pack.
|
||||
/// </summary>
|
||||
[DebuggerDisplay("Id: {Id}, Name: {Name}")]
|
||||
public sealed class ThemeManifestDto
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets or sets the supported schema version of the manifest.
|
||||
/// </summary>
|
||||
public int SchemaVersion { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the unique identifier of the theme, a lowercase kebab-case value used by clients to reference it.
|
||||
/// </summary>
|
||||
public string Id { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the display name of the theme.
|
||||
/// </summary>
|
||||
public string Name { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the description of the theme.
|
||||
/// </summary>
|
||||
public string Description { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the author of the theme.
|
||||
/// </summary>
|
||||
public string Author { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the version of the theme, using semantic version form.
|
||||
/// </summary>
|
||||
public string Version { get; set; } = string.Empty;
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the preview image path relative to the theme pack root, or <see langword="null"/> when the theme has no preview.
|
||||
/// </summary>
|
||||
public string? Preview { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the template mappings from template key to a file path under templates/.
|
||||
/// </summary>
|
||||
public Dictionary<string, string> Templates { get; set; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
}
|
||||
@@ -0,0 +1,103 @@
|
||||
#region ========================================================================= USING =====================================================================================
|
||||
using Lumina.Application.Common.Infrastructure.Models.DTO.Themes;
|
||||
using Lumina.Domain.Common.Primitives;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
#endregion
|
||||
|
||||
namespace Lumina.Application.Common.Infrastructure.Themes;
|
||||
|
||||
/// <summary>
|
||||
/// Service for the storage and serving of theme packs.
|
||||
/// </summary>
|
||||
public interface IThemeService
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether theme templates may contain script elements and theme assets may include script files.
|
||||
/// </summary>
|
||||
bool AllowThemeScripts { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum allowed size of a theme archive, in bytes.
|
||||
/// </summary>
|
||||
long MaxArchiveBytes { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the identifier of the theme selected when no valid current theme is available.
|
||||
/// </summary>
|
||||
string DefaultThemeId { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Installs a theme pack from the provided archive, replacing the files of an existing theme with the same manifest id.
|
||||
/// </summary>
|
||||
/// <param name="archive">The ZIP archive stream of the theme pack.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the parsed manifest of the installed theme, or an error.</returns>
|
||||
Task<Result<ThemeManifestDto>> InstallAsync(Stream archive, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Reads the manifest of a theme pack archive without installing it.
|
||||
/// </summary>
|
||||
/// <param name="archivePath">The path of the theme pack ZIP archive.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the parsed manifest, or an error.</returns>
|
||||
Task<Result<ThemeManifestDto>> ReadManifestFromArchiveAsync(string archivePath, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Deletes the stored files of a theme pack.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</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>> DeleteAsync(string themeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Loads the manifest of an installed theme pack from its storage location.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the parsed manifest, or an error.</returns>
|
||||
Task<Result<ThemeManifestDto>> LoadManifestAsync(string themeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the sanitized content of the template selected by a page key, falling back to the default template when the key is missing.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</param>
|
||||
/// <param name="pageKey">The page key that selects the template.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the template content, or an error.</returns>
|
||||
Task<Result<string>> GetTemplateAsync(string themeId, string pageKey, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a theme asset file.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</param>
|
||||
/// <param name="assetPath">The asset path relative to the theme pack root.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the asset, or an error.</returns>
|
||||
Task<Result<ThemeAssetDto>> GetAssetAsync(string themeId, string assetPath, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Builds a downloadable ZIP archive of an installed theme pack.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</param>
|
||||
/// <param name="cancellationToken">Cancellation token that can be used to stop the execution.</param>
|
||||
/// <returns>An <see cref="Result{TValue}"/> containing either the archive, or an error.</returns>
|
||||
Task<Result<ThemeArchiveDto>> BuildArchiveAsync(string themeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Restores the files of a bundled theme from its shipped archive, used when the stored files were removed externally.
|
||||
/// </summary>
|
||||
/// <param name="themeId">The manifest id of the theme.</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>> RestoreBundledThemeAsync(string themeId, CancellationToken cancellationToken);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the paths of the theme pack archives shipped with the application.
|
||||
/// </summary>
|
||||
/// <returns>The list of bundled theme archive paths.</returns>
|
||||
IReadOnlyList<string> GetBundledThemeArchivePaths();
|
||||
}
|
||||
Reference in new issue
Block a user