diff --git a/Beam.Dynamic/Beam.Dynamic.csproj b/Beam.Dynamic/Beam.Dynamic.csproj
index 2a6cd5c..0fe0a46 100644
--- a/Beam.Dynamic/Beam.Dynamic.csproj
+++ b/Beam.Dynamic/Beam.Dynamic.csproj
@@ -1,24 +1,19 @@
-
-
-
- net9.0
- enable
- enable
- Beam Dynamic
- aeqw89
- qwsdcvghyu
-
- Beam utilities facilitating dynamic fetching of elements of webpages
- https://github.com/qwsdcvghyu89/Beam
- aeqw89.Beam.Dynamic
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+ all
+
+
+
\ No newline at end of file
diff --git a/Beam.Exports/Beam.Exports.csproj b/Beam.Exports/Beam.Exports.csproj
index 1ad0212..9ff9a61 100644
--- a/Beam.Exports/Beam.Exports.csproj
+++ b/Beam.Exports/Beam.Exports.csproj
@@ -1,20 +1,16 @@
-
-
-
- net9.0
- enable
- enable
- Beam.Exports
- aeqw89
- qwsdcvghyu
- Beam library that facilitates exporting different kinds of views for IDocuments
- https://github.com/qwsdcvghyu89/Beam
- https://github.com/qwsdcvghyu89/Beam
- aeqw89.Beam.Exports
-
-
-
-
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
-
-
+
+
+ all
+
+
+
\ No newline at end of file
diff --git a/Beam.Puppeteer/Beam.Puppeteer.csproj b/Beam.Puppeteer/Beam.Puppeteer.csproj
index 6e23fcf..bc23420 100644
--- a/Beam.Puppeteer/Beam.Puppeteer.csproj
+++ b/Beam.Puppeteer/Beam.Puppeteer.csproj
@@ -1,17 +1,16 @@
-
-
-
- net9.0
- enable
- enable
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+ all
+
+
+
\ No newline at end of file
diff --git a/Beam.Puppeteer/PuppetedUnitDownloader.cs b/Beam.Puppeteer/PuppetedUnitDownloader.cs
index dd571af..2e62992 100644
--- a/Beam.Puppeteer/PuppetedUnitDownloader.cs
+++ b/Beam.Puppeteer/PuppetedUnitDownloader.cs
@@ -11,8 +11,8 @@ namespace Beam.Puppeteer {
public class PuppetUnitDownloader : UnitDownloader {
public PuppetContext Context { get; }
- public PuppetUnitDownloader(PuppetContext pc, DownloadContext context)
- : base(context.Web, context.AsyncTranformer, context.AsyncFailurePredicates) {
+ public PuppetUnitDownloader(PuppetContext pc, DownloadContext context, AsyncTransformer asyncHtmlTransformer, AsyncDownloadFailurePredicate[] asyncDownloadFailurePredicates)
+ : base(context.Web, asyncHtmlTransformer, asyncDownloadFailurePredicates) {
Context = pc;
}
diff --git a/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj b/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj
index a404a59..4015cee 100644
--- a/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj
+++ b/Beam.Temporary.Cli/Beam.Temporary.Cli.csproj
@@ -1,32 +1,30 @@
-
-
-
- Exe
- net9.0
- enable
- enable
-
- Beam.Temporary.Cli
- aeqw89
- qwsdcvghyu
- A temporary CLI for Beam providing several useful mechanisms
- https://github.com/qwsdcvghyu89/Beam
- https://github.com/qwsdcvghyu89/Beam
- aeqw89.Beam.Temporary.Cli
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+ Exe
+ net9.0
+ enable
+ enable
+
+
+
+
+
+
+
+
+
+
+
+
+
+ all
+
+
+ all
+
+
+ all
+
+
+
\ No newline at end of file
diff --git a/Beam.Temporary.Cli/CommonTransformers.cs b/Beam.Temporary.Cli/CommonTransformers.cs
index 08c6c91..ceeb090 100644
--- a/Beam.Temporary.Cli/CommonTransformers.cs
+++ b/Beam.Temporary.Cli/CommonTransformers.cs
@@ -1,5 +1,6 @@
using aeqw89.DataKeys;
using Beam.Dynamic;
+using HtmlAgilityPack;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -8,16 +9,16 @@ using System.Threading.Tasks;
namespace Beam.Temporary.Cli {
public static class CommonTransformers {
- public static HtmlTransformer ArticleDataTransformer(DataBindings? binding) => (x) => {
- return new ArticleData() {
+ public static AsyncTransformer ArticleDataTransformer(DataBindings? binding) => (x) => {
+ return Task.FromResult(new ArticleData() {
Authors = [OnlineCleaner.Clean(binding?.Authors?.Resolve(x) ?? "")],
Name = OnlineCleaner.Clean(binding?.Title?.ResolveString(x) ?? ""),
Categories = OnlineCleaner.Clean(binding?.Tags?.ResolveString(x) ?? "").Split(';') ?? [],
Description = OnlineCleaner.Clean(binding?.Description?.ResolveString(x) ?? "")
- };
+ });
};
- public static HtmlTransformer DocumentTransformer(DataBindings? binding, IDocumentMetaData? metaData = null) => (x) => {
+ public static AsyncTransformer DocumentTransformer(DataBindings? binding, IDocumentMetaData? metaData = null) => (x) => {
var resolved = binding?.Resolve(x);
var articleData = new ArticleData() {
Name = OnlineCleaner.Clean(resolved?.Title),
@@ -26,9 +27,9 @@ namespace Beam.Temporary.Cli {
meta.Add(IArchitecture.Default.ChapterKey, articleData);
if (metaData is not null)
meta.Add(IArchitecture.Default.BookKey, metaData);
- return new StringDocument(Path.GetRandomFileName(), OnlineCleaner.Clean(resolved?.Content)) {
+ return Task.FromResult(new StringDocument(Path.GetRandomFileName(), OnlineCleaner.Clean(resolved?.Content)) {
MetaData = meta
- };
+ });
};
}
}
diff --git a/Beam.Temporary.Cli/DownloadBuilder.cs b/Beam.Temporary.Cli/DownloadBuilder.cs
index 8d71ead..87cb95e 100644
--- a/Beam.Temporary.Cli/DownloadBuilder.cs
+++ b/Beam.Temporary.Cli/DownloadBuilder.cs
@@ -4,6 +4,7 @@ using Beam;
using Microsoft.Extensions.Logging;
using System;
using System.Collections.Generic;
+using HtmlAgilityPack;
namespace Beam.Temporary.Cli {
///
@@ -11,7 +12,7 @@ namespace Beam.Temporary.Cli {
/// (source → link selection → transformer) and surfaces operational knobs as first‑class
/// methods instead of magic parameters.
///
- public static class DownloadBuilder {
+ public static class DownloadBuilder {
/* ──────────────────────────── Entry points ─────────────────────────── */
public static ILinkStage FromMeta(DataKey novelKey, BeamDataDictionary data) =>
@@ -20,6 +21,9 @@ namespace Beam.Temporary.Cli {
public static ILinkStage FromText(DataKey novelKey, BeamDataDictionary data) =>
Create(novelKey, data, SourceKind.Text);
+ public static IAlternativeLinkStage FromScratch()
+ => new LinkStage(null!, null!, null!, new());
+
/* ────────────────────────────── Stages ─────────────────────────────── */
public interface ILinkStage {
@@ -28,16 +32,25 @@ namespace Beam.Temporary.Cli {
ILinkStage WithRange(Range range);
}
- public interface ITransformStage {
- IContextStage WithTransformer(Func> factory);
+ public interface IAlternativeLinkStage {
+ IAlternativeTransformStage WithLinks(IEnumerable links);
}
- public interface IContextStage {
- IContextStage Configure(Action> configure);
- IContextStage WithParallelism(int degree);
- IContextStage WithTimeout(TimeSpan timeout);
- IContextStage WithRetryReporter(IProgress reporter);
- DownloadEnumerable Build();
+ public interface ITransformStage {
+ IContextStage WithTransformer(Func> factory);
+ }
+
+ public interface IAlternativeTransformStage {
+ IContextStage WithTransformer(AsyncTransformer transformer);
+ }
+
+ public interface IContextStage {
+ IContextStage Configure(Action> configure);
+ IContextStage WithParallelism(int degree);
+ IContextStage WithTimeout(TimeSpan timeout);
+ IContextStage WithRetryReporter(IProgress reporter);
+ DownloadEnumerable Build();
+ IContextStage UseFragments();
}
/* ────────────────────────── Implementation ────────────────────────── */
@@ -46,7 +59,7 @@ namespace Beam.Temporary.Cli {
private static ILinkStage Create(DataKey novelKey, BeamDataDictionary data, SourceKind kind) {
var (source, initial) = Resolve(novelKey, data, kind);
- var ctxBuilder = new DownloadContextBuilder().WithLinks(Array.Empty()); // placeholder, filled later.
+ var ctxBuilder = new DownloadContextBuilder().WithLinks(Array.Empty()); // placeholder, filled later.
return new LinkStage(source, initial, data, ctxBuilder);
}
@@ -71,11 +84,12 @@ namespace Beam.Temporary.Cli {
/* ──────────────────────────── Stage types ─────────────────────────── */
+
private sealed record LinkStage(
WebResource Source,
State Initial,
BeamDataDictionary Data,
- DownloadContextBuilder CtxBuilder) : ILinkStage {
+ DownloadContextBuilder CtxBuilder) : ILinkStage, IAlternativeLinkStage {
private State? endState;
private bool linksFrozen = false;
@@ -97,6 +111,11 @@ namespace Beam.Temporary.Cli {
return new TransformStage(Source, Data, CtxBuilder);
}
+ public IAlternativeTransformStage WithLinks(IEnumerable links) {
+ CtxBuilder.WithLinks(links);
+ return new TransformStage(Source, Data, CtxBuilder);
+ }
+
public ILinkStage WithRange(Range range) {
if (linksFrozen)
throw new InvalidOperationException($"WithRange must be called before WithLinkGenerator");
@@ -114,24 +133,29 @@ namespace Beam.Temporary.Cli {
private sealed record TransformStage(
WebResource Source,
BeamDataDictionary Data,
- DownloadContextBuilder CtxBuilder) : ITransformStage {
- public IContextStage WithTransformer(Func> factory) {
+ DownloadContextBuilder CtxBuilder) : ITransformStage, IAlternativeTransformStage {
+ public IContextStage WithTransformer(Func> factory) {
var transformer = factory(Data.Bindings[Source.Bindings]);
- return new ContextStage(CtxBuilder, transformer);
+ return new ContextStage(CtxBuilder, transformer);
+ }
+
+ public IContextStage WithTransformer(AsyncTransformer transformer) {
+ return new ContextStage(CtxBuilder, transformer);
}
}
- private sealed class ContextStage : IContextStage {
- private readonly DownloadContextBuilder _ctxBuilder;
- private readonly Func