Removes unneeded methods/properties in abstraction, removes unneeded usages of it, changes everything to pre-defined bundles, fixes cdf implementation and reduces reflection, renames namespace

This commit is contained in:
Shannon
2020-04-02 17:41:00 +11:00
parent e42c63693f
commit 32deaa12d2
57 changed files with 766 additions and 830 deletions

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,63 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Umbraco.Core.WebAssets
{
/// <summary>
/// Used for bundling and minifying web assets at runtime
/// </summary>
public interface IRuntimeMinifier
{
/// <summary>
/// Returns the cache buster value
/// </summary>
string CacheBuster { get; }
/// <summary>
/// Creates a css bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="filePaths"></param>
void CreateCssBundle(string bundleName, params string[] filePaths);
/// <summary>
/// Renders the html link tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
string RenderCssHere(string bundleName);
/// <summary>
/// Creates a JS bundle
/// </summary>
/// <param name="bundleName"></param>
/// <param name="filePaths"></param>
void CreateJsBundle(string bundleName, params string[] filePaths);
/// <summary>
/// Renders the html script tag for the bundle
/// </summary>
/// <param name="bundleName"></param>
/// <returns>
/// An html encoded string
/// </returns>
string RenderJsHere(string bundleName);
/// <summary>
/// Returns the asset paths for the 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>> GetAssetPathsAsync(string bundleName);
Task<string> MinifyAsync(string fileContent, AssetType assetType);
void Reset();
}
}

View File

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