svelte-vitals 0.8.0 → 0.9.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/bin.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  knownRuleIds,
7
7
  readPackageVersion,
8
8
  run
9
- } from "./chunk-L6IHVJKF.js";
9
+ } from "./chunk-Y56I4RGY.js";
10
10
 
11
11
  // src/bin.ts
12
12
  import mri from "mri";
@@ -472,105 +472,6 @@ async function collectRoutes(rt, cwd, config = defaultConfig) {
472
472
  };
473
473
  }
474
474
 
475
- // src/providers/source/a11y.ts
476
- import { compile } from "svelte/compiler";
477
- import { defaultConfig as defaultConfig2 } from "@svelte-vitals/core";
478
-
479
- // src/rules-config.ts
480
- import { allRules } from "@svelte-vitals/core";
481
- var KNOWN_IDS = new Set(allRules.map((r) => r.id));
482
- var A11Y_CODE_PREFIX = "a11y_";
483
- var A11Y_CATEGORY_KEY = "a11y_category";
484
- function findUnknownRuleIds(ids) {
485
- return [
486
- ...new Set(ids.filter((id) => !KNOWN_IDS.has(id) && !(id.startsWith(A11Y_CODE_PREFIX) && id !== A11Y_CATEGORY_KEY)))
487
- ];
488
- }
489
- function knownRuleIds() {
490
- return [...KNOWN_IDS].sort();
491
- }
492
- function buildRulesConfig(allow, ignore) {
493
- const rules = {};
494
- if (allow.length > 0) {
495
- for (const r of allRules) if (!allow.includes(r.id)) rules[r.id] = "off";
496
- if (!allow.some((id) => id.startsWith(A11Y_CODE_PREFIX))) rules[A11Y_CATEGORY_KEY] = "off";
497
- }
498
- for (const id of ignore) rules[id] = "off";
499
- return rules;
500
- }
501
-
502
- // src/providers/source/a11y.ts
503
- function firstLine(message) {
504
- return message.split("\n")[0] ?? message;
505
- }
506
- function fileA11y(source, rel) {
507
- let warnings;
508
- try {
509
- ({ warnings } = compile(source, { generate: false, filename: rel }));
510
- } catch {
511
- return { ok: false, warnings: [] };
512
- }
513
- const out = [];
514
- for (const w of warnings) {
515
- if (w.code.startsWith(A11Y_CODE_PREFIX)) {
516
- out.push({
517
- code: w.code,
518
- message: firstLine(w.message),
519
- line: w.start?.line ?? 0
520
- });
521
- }
522
- }
523
- return { ok: true, warnings: out };
524
- }
525
- async function collectA11y(rt, cwd, config = defaultConfig2) {
526
- if (config.rules[A11Y_CATEGORY_KEY] === "off") return [];
527
- const pages = await enumerateRoutePages(rt, cwd);
528
- const cache = /* @__PURE__ */ new Map();
529
- const results = [];
530
- for (const page of pages) {
531
- const files = await chainFiles(rt, cwd, page);
532
- const route = deriveRoute(page);
533
- const fails = [];
534
- let compiledAll = true;
535
- for (const { rel } of files) {
536
- let entry = cache.get(rel);
537
- if (!entry) {
538
- const source = await rt.readFile(rt.join(cwd, rel));
539
- entry = fileA11y(source, rel);
540
- cache.set(rel, entry);
541
- }
542
- if (!entry.ok) compiledAll = false;
543
- for (const w of entry.warnings) {
544
- if (config.rules[w.code] === "off") continue;
545
- fails.push({
546
- id: w.code,
547
- category: "a11y",
548
- severity: "warning",
549
- detection: { presence: "none", value: "absent" },
550
- route,
551
- location: rel,
552
- ...w.line > 0 ? { line: w.line } : {},
553
- message: w.message,
554
- docsUrl: `https://svelte.dev/e/${w.code}`
555
- });
556
- }
557
- }
558
- if (fails.length > 0) {
559
- results.push(...fails);
560
- } else if (compiledAll) {
561
- results.push({
562
- id: "a11y",
563
- category: "a11y",
564
- severity: "warning",
565
- detection: { presence: "own", value: "static" },
566
- route,
567
- message: "Accessibility"
568
- });
569
- }
570
- }
571
- return results;
572
- }
573
-
574
475
  // src/version.ts
575
476
  import { readFileSync } from "fs";
576
477
  function readPackageVersion() {
@@ -611,6 +512,24 @@ function isAutoDetectedGithub(explicit, env = process.env) {
611
512
  return !explicit && !isReporterName(env.SVELTE_VITALS_REPORTER) && !isAgentEnv(env) && isGithubActionsEnv(env);
612
513
  }
613
514
 
515
+ // src/rules-config.ts
516
+ import { allRules } from "@svelte-vitals/core";
517
+ var KNOWN_IDS = new Set(allRules.map((r) => r.id));
518
+ function findUnknownRuleIds(ids) {
519
+ return [...new Set(ids.filter((id) => !KNOWN_IDS.has(id)))];
520
+ }
521
+ function knownRuleIds() {
522
+ return [...KNOWN_IDS].sort();
523
+ }
524
+ function buildRulesConfig(allow, ignore) {
525
+ const rules = {};
526
+ if (allow.length > 0) {
527
+ for (const r of allRules) if (!allow.includes(r.id)) rules[r.id] = "off";
528
+ }
529
+ for (const id of ignore) rules[id] = "off";
530
+ return rules;
531
+ }
532
+
614
533
  // src/index.ts
615
534
  function routeMatcher(glob) {
616
535
  if (!glob) return () => true;
@@ -634,9 +553,7 @@ async function analyzeProject(opts = {}) {
634
553
  const images = collected.images.filter((i) => matches(i.route));
635
554
  const project = await collectProjectFacts(rt, cwd);
636
555
  const rules = selectRules(allRules2, config);
637
- const a11y = (await collectA11y(rt, cwd, config)).filter((r) => r.route === void 0 || matches(r.route));
638
- const ruleResults = await runRules(rules, { heads, images, project, config });
639
- const results = applyRuleSeverities([...ruleResults, ...a11y], config);
556
+ const results = applyRuleSeverities(await runRules(rules, { heads, images, project, config }), config);
640
557
  return { results, config, version: readPackageVersion() };
641
558
  }
642
559
  async function run(opts = {}) {
@@ -702,11 +619,11 @@ async function run(opts = {}) {
702
619
 
703
620
  export {
704
621
  ProjectError,
622
+ readPackageVersion,
623
+ isReporterName,
705
624
  findUnknownRuleIds,
706
625
  knownRuleIds,
707
626
  buildRulesConfig,
708
- readPackageVersion,
709
- isReporterName,
710
627
  routeMatcher,
711
628
  analyzeProject,
712
629
  run
package/dist/index.d.ts CHANGED
@@ -16,10 +16,6 @@ declare function knownRuleIds(): string[];
16
16
  * (--ignore). An allow-list disables every rule not listed; deny always wins.
17
17
  * Callers should reject unknown ids first (see findUnknownRuleIds) so a typo in
18
18
  * --rules can't silently disable every rule.
19
- *
20
- * When the allow-list is non-empty and contains no `a11y_*` entries, the
21
- * `A11Y_CATEGORY_KEY` sentinel is set to `'off'`; `collectA11y` checks this key
22
- * to suppress the entire Accessibility category.
23
19
  */
24
20
  declare function buildRulesConfig(allow: string[], ignore: string[]): Record<string, RuleSetting>;
25
21
 
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  knownRuleIds,
7
7
  routeMatcher,
8
8
  run
9
- } from "./chunk-L6IHVJKF.js";
9
+ } from "./chunk-Y56I4RGY.js";
10
10
  export {
11
11
  ProjectError,
12
12
  analyzeProject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.8.0",
3
+ "version": "0.9.0",
4
4
  "description": "A SvelteKit SEO checker — not a runtime Web Vitals reporter. Static analysis of your routes' head metadata.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -42,7 +42,7 @@
42
42
  "mri": "^1.2.0",
43
43
  "svelte": "^5.56.3",
44
44
  "tinyglobby": "^0.2.17",
45
- "@svelte-vitals/core": "0.9.0"
45
+ "@svelte-vitals/core": "0.10.0"
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/node": "^24.7.0"