AssetInliner
Pennington.Book.Composition
Resolves <img src> values to self-contained data: URIs so the composed book renders offline (Chromium navigates via SetContentAsync with no server to fetch from). Internal sources resolve first from the content-copy map (a content source's own static assets), then from the host web root (wwwroot + RCL static web assets). External http(s) images are left untouched — an offline Chromium simply omits them — and unresolved internal sources are rewritten to an absolute URL so they at least point somewhere real.
Constructors
AssetInliner
#public AssetInliner(IFileSystem fileSystem, IFileProvider webRoot, CanonicalBaseUrl canonicalBase)
Creates an inliner over the given file system, web-root provider, and canonical base.
Parameters
fileSystemIFileSystemwebRootIFileProvidercanonicalBaseCanonicalBaseUrl
Methods
BuildContentMapAsync
#public static Task<IReadOnlyDictionary<string, string>> BuildContentMapAsync(IEnumerable<IContentService> services)
Builds the output-path → source-file map from every content service's static-copy declarations. First registration wins on a duplicate output path, mirroring the build's copy pass.
Parameters
servicesIEnumerable<IContentService>
Returns
Task<IReadOnlyDictionary<string, string>>Resolve
#public string Resolve(string src, IReadOnlyDictionary<string, string> contentMap)
Resolves src to a data: URI when the bytes can be found, an absolute URL when an internal source is unresolved, or src unchanged for external images.
Parameters
srcstringcontentMapIReadOnlyDictionary<string, string>
Returns
stringPennington.Book.Composition.AssetInliner
namespace Pennington.Book.Composition;
/// Resolves <img src> values to self-contained data: URIs so the composed book renders offline (Chromium navigates via SetContentAsync with no server to fetch from). Internal sources resolve first from the content-copy map (a content source's own static assets), then from the host web root (wwwroot + RCL static web assets). External http(s) images are left untouched — an offline Chromium simply omits them — and unresolved internal sources are rewritten to an absolute URL so they at least point somewhere real.
public class AssetInliner
{
/// Creates an inliner over the given file system, web-root provider, and canonical base.
public AssetInliner(IFileSystem fileSystem, IFileProvider webRoot, CanonicalBaseUrl canonicalBase)
;
/// Builds the output-path → source-file map from every content service's static-copy declarations. First registration wins on a duplicate output path, mirroring the build's copy pass.
public static Task<IReadOnlyDictionary<string, string>> BuildContentMapAsync(IEnumerable<IContentService> services)
;
/// Resolves src to a data: URI when the bytes can be found, an absolute URL when an internal source is unresolved, or src unchanged for external images.
public string Resolve(string src, IReadOnlyDictionary<string, string> contentMap)
;
}