merge v10 to v11

This commit is contained in:
Bjarke Berg
2022-08-18 14:38:28 +02:00
4076 changed files with 320268 additions and 303657 deletions

View File

@@ -1,23 +1,20 @@
using System.Diagnostics;
using System.Diagnostics;
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
/// <summary>
/// Represents a dependency file
/// </summary>
[DebuggerDisplay("Type: {DependencyType}, File: {FilePath}")]
public class AssetFile : IAssetFile
{
/// <summary>
/// Represents a dependency file
/// </summary>
[DebuggerDisplay("Type: {DependencyType}, File: {FilePath}")]
public class AssetFile : IAssetFile
{
#region IAssetFile Members
public AssetFile(AssetType type) => DependencyType = type;
public string? FilePath { get; set; }
public AssetType DependencyType { get; }
#region IAssetFile Members
#endregion
public string? FilePath { get; set; }
public AssetFile(AssetType type)
{
DependencyType = type;
}
}
public AssetType DependencyType { get; }
#endregion
}

View File

@@ -1,8 +1,7 @@
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
public enum AssetType
{
public enum AssetType
{
Javascript,
Css
}
Javascript,
Css,
}

View File

@@ -1,44 +1,46 @@
using System;
namespace Umbraco.Cms.Core.WebAssets;
namespace Umbraco.Cms.Core.WebAssets
public struct BundlingOptions : IEquatable<BundlingOptions>
{
public struct BundlingOptions : IEquatable<BundlingOptions>
public BundlingOptions(bool optimizeOutput = true, bool enabledCompositeFiles = true)
{
public static BundlingOptions OptimizedAndComposite => new BundlingOptions(true, true);
public static BundlingOptions OptimizedNotComposite => new BundlingOptions(true, false);
public static BundlingOptions NotOptimizedNotComposite => new BundlingOptions(false, false);
public static BundlingOptions NotOptimizedAndComposite => new BundlingOptions(false, true);
public BundlingOptions(bool optimizeOutput = true, bool enabledCompositeFiles = true)
{
OptimizeOutput = optimizeOutput;
EnabledCompositeFiles = enabledCompositeFiles;
}
/// <summary>
/// If true, the files in the bundle will be minified
/// </summary>
public bool OptimizeOutput { get; }
/// <summary>
/// If true, the files in the bundle will be combined, if false the files
/// will be served as individual files.
/// </summary>
public bool EnabledCompositeFiles { get; }
public override bool Equals(object? obj) => obj is BundlingOptions options && Equals(options);
public bool Equals(BundlingOptions other) => OptimizeOutput == other.OptimizeOutput && EnabledCompositeFiles == other.EnabledCompositeFiles;
public override int GetHashCode()
{
int hashCode = 2130304063;
hashCode = hashCode * -1521134295 + OptimizeOutput.GetHashCode();
hashCode = hashCode * -1521134295 + EnabledCompositeFiles.GetHashCode();
return hashCode;
}
public static bool operator ==(BundlingOptions left, BundlingOptions right) => left.Equals(right);
public static bool operator !=(BundlingOptions left, BundlingOptions right) => !(left == right);
OptimizeOutput = optimizeOutput;
EnabledCompositeFiles = enabledCompositeFiles;
}
public static BundlingOptions OptimizedAndComposite => new(true);
public static BundlingOptions OptimizedNotComposite => new(true, false);
public static BundlingOptions NotOptimizedNotComposite => new(false, false);
public static BundlingOptions NotOptimizedAndComposite => new(false);
/// <summary>
/// If true, the files in the bundle will be minified
/// </summary>
public bool OptimizeOutput { get; }
/// <summary>
/// If true, the files in the bundle will be combined, if false the files
/// will be served as individual files.
/// </summary>
public bool EnabledCompositeFiles { get; }
public static bool operator ==(BundlingOptions left, BundlingOptions right) => left.Equals(right);
public override bool Equals(object? obj) => obj is BundlingOptions options && Equals(options);
public bool Equals(BundlingOptions other) => OptimizeOutput == other.OptimizeOutput &&
EnabledCompositeFiles == other.EnabledCompositeFiles;
public override int GetHashCode()
{
var hashCode = 2130304063;
hashCode = (hashCode * -1521134295) + OptimizeOutput.GetHashCode();
hashCode = (hashCode * -1521134295) + EnabledCompositeFiles.GetHashCode();
return hashCode;
}
public static bool operator !=(BundlingOptions left, BundlingOptions right) => !(left == right);
}

View File

@@ -1,14 +1,11 @@
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
/// <summary>
/// Represents a CSS asset file
/// </summary>
public class CssFile : AssetFile
{
/// <summary>
/// Represents a CSS asset file
/// </summary>
public class CssFile : AssetFile
{
public CssFile(string filePath)
: base(AssetType.Css)
{
FilePath = filePath;
}
}
public CssFile(string filePath)
: base(AssetType.Css) =>
FilePath = filePath;
}

View File

@@ -1,13 +1,11 @@
using System;
using System.Collections.Generic;
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
public class CustomBackOfficeAssetsCollection : BuilderCollectionBase<IAssetFile>
{
public class CustomBackOfficeAssetsCollection : BuilderCollectionBase<IAssetFile>
public CustomBackOfficeAssetsCollection(Func<IEnumerable<IAssetFile>> items)
: base(items)
{
public CustomBackOfficeAssetsCollection(Func<IEnumerable<IAssetFile>> items) : base(items)
{
}
}
}

View File

@@ -1,9 +1,8 @@
using Umbraco.Cms.Core.Composing;
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
public class CustomBackOfficeAssetsCollectionBuilder : OrderedCollectionBuilderBase<CustomBackOfficeAssetsCollectionBuilder, CustomBackOfficeAssetsCollection, IAssetFile>
{
public class CustomBackOfficeAssetsCollectionBuilder : OrderedCollectionBuilderBase<CustomBackOfficeAssetsCollectionBuilder, CustomBackOfficeAssetsCollection, IAssetFile>
{
protected override CustomBackOfficeAssetsCollectionBuilder This => this;
}
protected override CustomBackOfficeAssetsCollectionBuilder This => this;
}

View File

@@ -1,8 +1,8 @@
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
public interface IAssetFile
{
public interface IAssetFile
{
string? FilePath { get; set; }
AssetType DependencyType { get; }
}
string? FilePath { get; set; }
AssetType DependencyType { get; }
}

View File

@@ -1,88 +1,83 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Umbraco.Cms.Core.WebAssets;
namespace Umbraco.Cms.Core.WebAssets
/// <summary>
/// Used for bundling and minifying web assets at runtime
/// </summary>
public interface IRuntimeMinifier
{
/// <summary>
/// Used for bundling and minifying web assets at runtime
/// Returns the cache buster value
/// </summary>
public interface IRuntimeMinifier
{
/// <summary>
/// Returns the cache buster value
/// </summary>
string CacheBuster { get; }
string CacheBuster { get; }
/// <summary>
/// Creates a css bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="filePaths"></param>
/// <remarks>
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException"/>
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if any of the paths specified are not absolute
/// </exception>
void CreateCssBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths);
/// <summary>
/// Creates a css bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="filePaths"></param>
/// <remarks>
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException" />
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if any of the paths specified are not absolute
/// </exception>
void CreateCssBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths);
/// <summary>
/// Renders the html link tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
Task<string> RenderCssHereAsync(string bundleName);
/// <summary>
/// Renders the html link tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
Task<string> RenderCssHereAsync(string bundleName);
/// <summary>
/// Creates a JS bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="optimizeOutput"></param>
/// <param name="filePaths"></param>
/// <remarks>
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException"/>
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if any of the paths specified are not absolute
/// </exception>
void CreateJsBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths);
/// <summary>
/// Creates a JS bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="optimizeOutput"></param>
/// <param name="filePaths"></param>
/// <remarks>
/// All files must be absolute paths, relative paths will throw <see cref="InvalidOperationException" />
/// </remarks>
/// <exception cref="InvalidOperationException">
/// Thrown if any of the paths specified are not absolute
/// </exception>
void CreateJsBundle(string bundleName, BundlingOptions bundleOptions, params string[]? filePaths);
/// <summary>
/// Renders the html script tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
Task<string> RenderJsHereAsync(string bundleName);
/// <summary>
/// Renders the html script tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
Task<string> RenderJsHereAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the JS bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetJsAssetPathsAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the JS bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetJsAssetPathsAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the css bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetCssAssetPathsAsync(string bundleName);
/// <summary>
/// Returns the asset paths for the css bundle name
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// If debug mode is enabled this will return all asset paths (not bundled), else it will return a bundle URL
/// </returns>
Task<IEnumerable<string>> GetCssAssetPathsAsync(string bundleName);
/// <summary>
/// Minify the file content, of a given type
/// </summary>
/// <param name="fileContent"></param>
/// <param name="assetType"></param>
/// <returns></returns>
Task<string> MinifyAsync(string? fileContent, AssetType assetType);
}
/// <summary>
/// Minify the file content, of a given type
/// </summary>
/// <param name="fileContent"></param>
/// <param name="assetType"></param>
/// <returns></returns>
Task<string> MinifyAsync(string? fileContent, AssetType assetType);
}

View File

@@ -1,14 +1,11 @@
namespace Umbraco.Cms.Core.WebAssets
namespace Umbraco.Cms.Core.WebAssets;
/// <summary>
/// Represents a JS asset file
/// </summary>
public class JavaScriptFile : AssetFile
{
/// <summary>
/// Represents a JS asset file
/// </summary>
public class JavaScriptFile : AssetFile
{
public JavaScriptFile(string filePath)
: base(AssetType.Javascript)
{
FilePath = filePath;
}
}
public JavaScriptFile(string filePath)
: base(AssetType.Javascript) =>
FilePath = filePath;
}