@svelte-vitals/core 0.20.0 → 0.21.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts +11 -1
- package/dist/index.js +77 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -717,6 +717,16 @@ declare function formatSarifReport(results: Result[], config: Config, meta: {
|
|
|
717
717
|
*/
|
|
718
718
|
declare function formatGithubReport(results: Result[], config: Config): string;
|
|
719
719
|
|
|
720
|
+
/**
|
|
721
|
+
* Render a compact Markdown summary — Health score, per-category table, severity counts, and
|
|
722
|
+
* a findings table — suitable for a GitHub Actions job summary or a sticky PR comment
|
|
723
|
+
* (`svelte-vitals ci install`). Delegates all aggregation to `buildJsonReport` so the numbers
|
|
724
|
+
* never drift from the JSON/console reporters.
|
|
725
|
+
*/
|
|
726
|
+
declare function formatMarkdownReport(results: Result[], config: Config, meta: {
|
|
727
|
+
version: string;
|
|
728
|
+
}): string;
|
|
729
|
+
|
|
720
730
|
type Band = 'good' | 'warn' | 'poor';
|
|
721
731
|
declare const BAND_COLOR: Record<Band, string>;
|
|
722
732
|
declare function scoreBand(score: number): Band;
|
|
@@ -743,4 +753,4 @@ declare function selectRules(rules: Rule[], config: Config): Rule[];
|
|
|
743
753
|
/** Apply per-rule severity overrides to results (design §6). */
|
|
744
754
|
declare function applyRuleSeverities(results: Result[], config: Config): Result[];
|
|
745
755
|
|
|
746
|
-
export { BAND_COLOR, CHILD_NODE_KEYS, type Category, type Classification, type ComponentFacts, type Config, type ConsoleReportOptions, type Detection, type EachBlockFact, type EffectFact, type Fix, type HeadProvider, type HeadTag, type HeadingInfo, type HealthResult, type ImageInfo, type JsonReport, type Palette, type Presence, type Project, ROBOTS_SOURCE_PATHS, type ResolvedHead, type ResolvedHeadings, type ResolvedImages, type Result, type Rule, type RuleContext, type RuleInfo, type RuleSetting, type Runtime, SITEMAP_SOURCE_PATHS, type Scope, type ScoreModel, type ScoreOptions, type ScoreResult, type Severity, type SourceSpan, type Summary, type SuppressionDirective, type TreatDynamicAs, type Value, allRules, applyRuleSeverities, arch001ComponentSize, arch002PropCount, attrText, attrTextOf, attrValue, attrValueOf, buildHtmlDocument, buildJsonReport, classify, collectComponentFacts, computeHealth, computeScore, correct001EachKey, correct002EffectDerived, correct003EffectAsOnMount, correct004UnmutatedState, correct005PropMutation, defaultConfig, defaultProject, defineConfig, docsUrlFor, effectiveSeverity, emptyComponentFacts, escapeHtml, explainRule, findAttr, formatAgentReport, formatConsoleReport, formatGithubReport, formatHtmlReport, formatJsonReport, formatSarifReport, hasFailureAtOrAbove, headTagRule, imageRule, isPenalized, lineOf, linkRule, noColorPalette, parseComponentFacts, perf001ImageDimensions, perf002ImageLoading, perf003PreloadAs, perf004FontPreloadCrossorigin, perf005LcpImage, perf006ResponsiveImage, perf007RenderBlockingScript, perf008Preconnect, perf009HeavyImport, perf010NamespaceImport, runRules, safeHref, scoreBand, scoreColor, scoresByCategory, sec001Html, sec002JavascriptUrl, selectRules, seo001Title, seo002Description, seo003Canonical, seo004OgImage, seo005OgTitle, seo006Robots, seo007Sitemap, seo008JsonLd, seo009HtmlLang, seo010Indexability, seo011TwitterCard, seo012OgDescription, seo013OgUrl, seo014Viewport, seo015SitemapInRobots, seo016JsonLdValidity, seo017DeprecatedType, seo018RelativeUrl, seo019DateFormat, seo020Placeholder, seo021RequiredProps, seo022TitleLength, seo023DescriptionLength, seo024Charset, seo025ImageAlt, seo026Hreflang, seo027Heading, seo028TitleUnique, seo029DescriptionUnique, seo030HeadingOrder, summarize, textFromNodes, valueFromNodes };
|
|
756
|
+
export { BAND_COLOR, CHILD_NODE_KEYS, type Category, type Classification, type ComponentFacts, type Config, type ConsoleReportOptions, type Detection, type EachBlockFact, type EffectFact, type Fix, type HeadProvider, type HeadTag, type HeadingInfo, type HealthResult, type ImageInfo, type JsonReport, type Palette, type Presence, type Project, ROBOTS_SOURCE_PATHS, type ResolvedHead, type ResolvedHeadings, type ResolvedImages, type Result, type Rule, type RuleContext, type RuleInfo, type RuleSetting, type Runtime, SITEMAP_SOURCE_PATHS, type Scope, type ScoreModel, type ScoreOptions, type ScoreResult, type Severity, type SourceSpan, type Summary, type SuppressionDirective, type TreatDynamicAs, type Value, allRules, applyRuleSeverities, arch001ComponentSize, arch002PropCount, attrText, attrTextOf, attrValue, attrValueOf, buildHtmlDocument, buildJsonReport, classify, collectComponentFacts, computeHealth, computeScore, correct001EachKey, correct002EffectDerived, correct003EffectAsOnMount, correct004UnmutatedState, correct005PropMutation, defaultConfig, defaultProject, defineConfig, docsUrlFor, effectiveSeverity, emptyComponentFacts, escapeHtml, explainRule, findAttr, formatAgentReport, formatConsoleReport, formatGithubReport, formatHtmlReport, formatJsonReport, formatMarkdownReport, formatSarifReport, hasFailureAtOrAbove, headTagRule, imageRule, isPenalized, lineOf, linkRule, noColorPalette, parseComponentFacts, perf001ImageDimensions, perf002ImageLoading, perf003PreloadAs, perf004FontPreloadCrossorigin, perf005LcpImage, perf006ResponsiveImage, perf007RenderBlockingScript, perf008Preconnect, perf009HeavyImport, perf010NamespaceImport, runRules, safeHref, scoreBand, scoreColor, scoresByCategory, sec001Html, sec002JavascriptUrl, selectRules, seo001Title, seo002Description, seo003Canonical, seo004OgImage, seo005OgTitle, seo006Robots, seo007Sitemap, seo008JsonLd, seo009HtmlLang, seo010Indexability, seo011TwitterCard, seo012OgDescription, seo013OgUrl, seo014Viewport, seo015SitemapInRobots, seo016JsonLdValidity, seo017DeprecatedType, seo018RelativeUrl, seo019DateFormat, seo020Placeholder, seo021RequiredProps, seo022TitleLength, seo023DescriptionLength, seo024Charset, seo025ImageAlt, seo026Hreflang, seo027Heading, seo028TitleUnique, seo029DescriptionUnique, seo030HeadingOrder, summarize, textFromNodes, valueFromNodes };
|
package/dist/index.js
CHANGED
|
@@ -2654,6 +2654,82 @@ function formatGithubReport(results, config) {
|
|
|
2654
2654
|
return lines.join("\n");
|
|
2655
2655
|
}
|
|
2656
2656
|
|
|
2657
|
+
// src/reporter/markdown.ts
|
|
2658
|
+
var MAX_FINDINGS = 50;
|
|
2659
|
+
var SEVERITY_EMOJI = { critical: "\u{1F534}", warning: "\u{1F7E1}", info: "\u{1F535}" };
|
|
2660
|
+
var SEVERITY_RANK2 = { critical: 0, warning: 1, info: 2 };
|
|
2661
|
+
function escapeCell(s) {
|
|
2662
|
+
return s.replace(/\|/g, "\\|").replace(/\r\n|\r|\n/g, " ");
|
|
2663
|
+
}
|
|
2664
|
+
function locationOf(issue, route) {
|
|
2665
|
+
if (issue.location) return issue.line !== void 0 ? `${issue.location}:${issue.line}` : issue.location;
|
|
2666
|
+
return route ?? "-";
|
|
2667
|
+
}
|
|
2668
|
+
function flattenFindings(report) {
|
|
2669
|
+
const findings = [];
|
|
2670
|
+
for (const r of report.routes) {
|
|
2671
|
+
for (const issue of r.issues) {
|
|
2672
|
+
findings.push({
|
|
2673
|
+
severity: issue.severity,
|
|
2674
|
+
id: issue.id,
|
|
2675
|
+
location: locationOf(issue, r.route),
|
|
2676
|
+
message: issue.title
|
|
2677
|
+
});
|
|
2678
|
+
}
|
|
2679
|
+
}
|
|
2680
|
+
for (const issue of report.siteIssues) {
|
|
2681
|
+
findings.push({
|
|
2682
|
+
severity: issue.severity,
|
|
2683
|
+
id: issue.id,
|
|
2684
|
+
location: locationOf(issue, void 0),
|
|
2685
|
+
message: issue.title
|
|
2686
|
+
});
|
|
2687
|
+
}
|
|
2688
|
+
return findings.map((f, index) => ({ f, index })).sort((a, b) => SEVERITY_RANK2[a.f.severity] - SEVERITY_RANK2[b.f.severity] || a.index - b.index).map(({ f }) => f);
|
|
2689
|
+
}
|
|
2690
|
+
function categoryRows(categories) {
|
|
2691
|
+
const names = Object.keys(categories).sort();
|
|
2692
|
+
return names.map((cat) => `| ${cat} | ${categories[cat].score} |`);
|
|
2693
|
+
}
|
|
2694
|
+
function formatMarkdownReport(results, config, meta) {
|
|
2695
|
+
const report = buildJsonReport(results, config, meta);
|
|
2696
|
+
const lines = [];
|
|
2697
|
+
lines.push(`<!-- svelte-vitals v${meta.version} -->`);
|
|
2698
|
+
lines.push(`## svelte-vitals \u2014 Health ${report.score}/100`);
|
|
2699
|
+
lines.push("");
|
|
2700
|
+
const catRows = categoryRows(report.categories);
|
|
2701
|
+
if (catRows.length > 0) {
|
|
2702
|
+
lines.push("| Category | Score |");
|
|
2703
|
+
lines.push("| --- | --- |");
|
|
2704
|
+
lines.push(...catRows);
|
|
2705
|
+
lines.push("");
|
|
2706
|
+
}
|
|
2707
|
+
const { critical, warning, info, passed } = report.summary;
|
|
2708
|
+
lines.push(`**${critical} critical \xB7 ${warning} warning \xB7 ${info} info** (${passed} checks passed)`);
|
|
2709
|
+
lines.push("");
|
|
2710
|
+
const findings = flattenFindings(report);
|
|
2711
|
+
if (findings.length === 0) {
|
|
2712
|
+
lines.push("\u2705 No issues found.");
|
|
2713
|
+
} else {
|
|
2714
|
+
lines.push("### Findings");
|
|
2715
|
+
lines.push("");
|
|
2716
|
+
lines.push("| Severity | Rule | Location | Message |");
|
|
2717
|
+
lines.push("| --- | --- | --- | --- |");
|
|
2718
|
+
const shown = findings.slice(0, MAX_FINDINGS);
|
|
2719
|
+
for (const f of shown) {
|
|
2720
|
+
const rule = `[${f.id}](${docsUrlFor(f.id)})`;
|
|
2721
|
+
lines.push(
|
|
2722
|
+
`| ${SEVERITY_EMOJI[f.severity]} ${f.severity} | ${rule} | ${escapeCell(f.location)} | ${escapeCell(f.message)} |`
|
|
2723
|
+
);
|
|
2724
|
+
}
|
|
2725
|
+
if (findings.length > MAX_FINDINGS) {
|
|
2726
|
+
lines.push("");
|
|
2727
|
+
lines.push(`\u2026and ${findings.length - MAX_FINDINGS} more (run \`npx svelte-vitals\` locally for the full report)`);
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
return lines.join("\n");
|
|
2731
|
+
}
|
|
2732
|
+
|
|
2657
2733
|
// src/reporter/html.ts
|
|
2658
2734
|
var BAND_COLOR = {
|
|
2659
2735
|
good: "#2FA968",
|
|
@@ -2888,6 +2964,7 @@ export {
|
|
|
2888
2964
|
formatGithubReport,
|
|
2889
2965
|
formatHtmlReport,
|
|
2890
2966
|
formatJsonReport,
|
|
2967
|
+
formatMarkdownReport,
|
|
2891
2968
|
formatSarifReport,
|
|
2892
2969
|
hasFailureAtOrAbove,
|
|
2893
2970
|
headTagRule,
|