svelte-vitals 0.45.0 → 0.45.1

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
@@ -1,8 +1,8 @@
1
1
  #!/usr/bin/env node
2
2
  import {
3
3
  runAnalyzeCliGunshi
4
- } from "./chunk-2NMVPG4P.js";
5
- import "./chunk-2UGE6HMQ.js";
4
+ } from "./chunk-P4YNVJUO.js";
5
+ import "./chunk-VNVRHWO3.js";
6
6
  import "./chunk-MUIOPL5F.js";
7
7
  import "./chunk-M5KM5SV7.js";
8
8
  import {
@@ -20,7 +20,7 @@ import {
20
20
  async function runCli(argv, io = consoleIO, env = process.env) {
21
21
  const locale = resolveLocale(env);
22
22
  if (argv[0] === "complete") {
23
- const { runCompleteCliGunshi } = await import("./complete-KVRPOFNR.js");
23
+ const { runCompleteCliGunshi } = await import("./complete-HGLO72TI.js");
24
24
  return { code: await runCompleteCliGunshi(argv, io), exit: "natural" };
25
25
  }
26
26
  if (argv[0] === "docs") {
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  run
3
- } from "./chunk-2UGE6HMQ.js";
3
+ } from "./chunk-VNVRHWO3.js";
4
4
  import {
5
5
  VALUE_FLAGS,
6
6
  parseRunArgs,
@@ -31,7 +31,8 @@ import {
31
31
  selectRules,
32
32
  applyRuleSeverities,
33
33
  applyOverrides,
34
- settingSeverity
34
+ settingSeverity,
35
+ withFailedRulesOff
35
36
  } from "@svelte-vitals/core";
36
37
 
37
38
  // src/runtime/node.ts
@@ -221,6 +222,9 @@ import {
221
222
  // src/providers/source/routes.ts
222
223
  import { defaultConfig } from "@svelte-vitals/core";
223
224
 
225
+ // src/providers/source/resolve.ts
226
+ import { resolveRepoLocalPath } from "@svelte-vitals/core";
227
+
224
228
  // src/providers/source/adapters/svelte-meta-tags.ts
225
229
  import { attrValueOf, attrTextOf } from "@svelte-vitals/core";
226
230
 
@@ -606,28 +610,15 @@ function tagKey(tag) {
606
610
  return `script:${tag.href ?? "?"}`;
607
611
  }
608
612
  }
609
- function resolveComponentPath(source, fromFileRel) {
610
- let path;
611
- if (source.startsWith("$lib/")) {
612
- path = `src/lib/${source.slice("$lib/".length)}`;
613
- } else if (source === "$lib") {
614
- return void 0;
615
- } else if (source.startsWith("./") || source.startsWith("../")) {
616
- const dir = fromFileRel.split("/").slice(0, -1);
617
- for (const seg of source.split("/")) {
618
- if (seg === "." || seg === "") continue;
619
- if (seg === "..") dir.pop();
620
- else dir.push(seg);
621
- }
622
- path = dir.join("/");
623
- } else {
624
- return void 0;
625
- }
613
+ function resolveComponentPath(source, fromFileRel, aliases) {
614
+ if (source === "$lib") return void 0;
615
+ const path = resolveRepoLocalPath(source, fromFileRel, aliases);
616
+ if (path === void 0) return void 0;
626
617
  if (path.endsWith(".svelte")) return path;
627
618
  if (/\.[^/]+$/.test(path)) return void 0;
628
619
  return `${path}.svelte`;
629
620
  }
630
- async function resolveFileTags(rt, cwd, fileRel, parsed, config, depth, visited, cache = /* @__PURE__ */ new Map()) {
621
+ async function resolveFileTags(rt, cwd, fileRel, parsed, config, depth, visited, cache = /* @__PURE__ */ new Map(), aliases) {
631
622
  const tags = [...parsed.headTags];
632
623
  const headings = [];
633
624
  let broad = false;
@@ -644,13 +635,23 @@ async function resolveFileTags(rt, cwd, fileRel, parsed, config, depth, visited,
644
635
  broad = true;
645
636
  continue;
646
637
  }
647
- const childRel = info ? resolveComponentPath(info.source, fileRel) : void 0;
638
+ const childRel = info ? resolveComponentPath(info.source, fileRel, aliases) : void 0;
648
639
  if (childRel && depth > 0 && !visited.has(childRel)) {
649
640
  const abs = rt.join(cwd, childRel);
650
641
  if (await rt.exists(abs)) {
651
642
  const childParsed = await readAndParse(rt, cwd, childRel, cache);
652
643
  const childVisited = new Set(visited).add(childRel);
653
- const child = await resolveFileTags(rt, cwd, childRel, childParsed, config, depth - 1, childVisited, cache);
644
+ const child = await resolveFileTags(
645
+ rt,
646
+ cwd,
647
+ childRel,
648
+ childParsed,
649
+ config,
650
+ depth - 1,
651
+ childVisited,
652
+ cache,
653
+ aliases
654
+ );
654
655
  tags.push(...child.tags);
655
656
  broad = broad || child.broad;
656
657
  for (const h of childParsed.headings) headings.push({ ...h, file: childRel });
@@ -727,7 +728,7 @@ function chainFiles(pageRel, layouts) {
727
728
  }
728
729
  return [...chain.map((rel) => ({ rel, isPage: false })), { rel: pageRel, isPage: true }];
729
730
  }
730
- async function resolveRoute(rt, cwd, pageRel, config, layouts, cache) {
731
+ async function resolveRoute(rt, cwd, pageRel, config, layouts, cache, aliases) {
731
732
  const files = chainFiles(pageRel, layouts);
732
733
  const composed = /* @__PURE__ */ new Map();
733
734
  const jsonldTags = [];
@@ -744,7 +745,7 @@ async function resolveRoute(rt, cwd, pageRel, config, layouts, cache) {
744
745
  for (const heading of parsed.headings) {
745
746
  headings.push({ ...heading, file: rel });
746
747
  }
747
- const resolved = await resolveFileTags(rt, cwd, rel, parsed, config, MAX_DEPTH, /* @__PURE__ */ new Set([rel]), cache);
748
+ const resolved = await resolveFileTags(rt, cwd, rel, parsed, config, MAX_DEPTH, /* @__PURE__ */ new Set([rel]), cache, aliases);
748
749
  for (const tag of resolved.tags) {
749
750
  const stamped = { ...tag, presence: isPage ? "own" : "inherited", file: rel };
750
751
  if (tag.kind === "jsonld") jsonldTags.push(stamped);
@@ -770,9 +771,9 @@ async function resolveRoute(rt, cwd, pageRel, config, layouts, cache) {
770
771
  headings: { route, headings, componentHeadings }
771
772
  };
772
773
  }
773
- async function collectRoutes(rt, cwd, config = defaultConfig, cache = /* @__PURE__ */ new Map()) {
774
+ async function collectRoutes(rt, cwd, config = defaultConfig, cache = /* @__PURE__ */ new Map(), aliases) {
774
775
  const [pages, layouts] = await Promise.all([enumerateRoutePages(rt, cwd), collectLayouts(rt, cwd)]);
775
- const facts = await Promise.all(pages.map((page) => resolveRoute(rt, cwd, page, config, layouts, cache)));
776
+ const facts = await Promise.all(pages.map((page) => resolveRoute(rt, cwd, page, config, layouts, cache, aliases)));
776
777
  return {
777
778
  heads: facts.map((f) => f.head),
778
779
  images: facts.map((f) => f.images),
@@ -793,7 +794,7 @@ async function collectAll(rt, cwd, config, opts = {}) {
793
794
  const matches = routeMatcher(opts.route);
794
795
  const project = await collectProjectFacts(rt, cwd);
795
796
  const [collected, components, kitModules, sourceFiles] = await Promise.all([
796
- collectRoutes(rt, cwd, config, opts.parseCache),
797
+ collectRoutes(rt, cwd, config, opts.parseCache, project.kitAliases),
797
798
  // Component (Correctness) facts are file-scoped with no route attribution yet, so a
798
799
  // route-filtered run skips them rather than reporting unrelated components (#68 review);
799
800
  // kitModules is skipped for the same reason.
@@ -1305,6 +1306,9 @@ function skippedFileWarnings(facts) {
1305
1306
  "findings for these files are unavailable until they parse."
1306
1307
  ];
1307
1308
  }
1309
+ function failedRuleWarnings(failedRules) {
1310
+ return failedRules.map((f) => `rule ${f.id} failed and was skipped: ${f.message.split("\n")[0]}`);
1311
+ }
1308
1312
  async function analyzeProject(opts = {}) {
1309
1313
  const cwd = opts.cwd ?? process.cwd();
1310
1314
  const rt = createNodeRuntime();
@@ -1336,7 +1340,11 @@ async function analyzeProject(opts = {}) {
1336
1340
  });
1337
1341
  const selected = selectRules(allRules2, config);
1338
1342
  const rules = opts.categories ? selected.filter((r) => opts.categories.includes(r.category)) : selected;
1339
- const { results: rawResults, examined } = await runRules(rules, {
1343
+ const {
1344
+ results: rawResults,
1345
+ examined,
1346
+ failedRules
1347
+ } = await runRules(rules, {
1340
1348
  heads,
1341
1349
  images,
1342
1350
  headings,
@@ -1347,13 +1355,17 @@ async function analyzeProject(opts = {}) {
1347
1355
  sourceFiles
1348
1356
  });
1349
1357
  const results = applyOverrides(applyRuleSeverities(rawResults, config), config);
1358
+ const scoringConfig = withFailedRulesOff(
1359
+ config,
1360
+ failedRules.map((f) => f.id)
1361
+ );
1350
1362
  return {
1351
1363
  results,
1352
- config,
1364
+ config: scoringConfig,
1353
1365
  version: readPackageVersion(),
1354
1366
  ruleIds: rules.map((r) => r.id),
1355
1367
  examined,
1356
- warnings: [...warnings, ...skippedFileWarnings([...components, ...kitModules])],
1368
+ warnings: [...warnings, ...skippedFileWarnings([...components, ...kitModules]), ...failedRuleWarnings(failedRules)],
1357
1369
  loadedConfig: loaded
1358
1370
  };
1359
1371
  }
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ROOT_ARGS
3
- } from "./chunk-2NMVPG4P.js";
4
- import "./chunk-2UGE6HMQ.js";
3
+ } from "./chunk-P4YNVJUO.js";
4
+ import "./chunk-VNVRHWO3.js";
5
5
  import {
6
6
  DOCS_LIST_ARGS,
7
7
  DOCS_ROOT_ARGS,
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  ROOT_ARGS
3
- } from "./chunk-2NMVPG4P.js";
4
- import "./chunk-2UGE6HMQ.js";
3
+ } from "./chunk-P4YNVJUO.js";
4
+ import "./chunk-VNVRHWO3.js";
5
5
  import {
6
6
  JA_ARG_DESCRIPTIONS
7
7
  } from "./chunk-MHRO4GU7.js";
package/dist/index.js CHANGED
@@ -6,7 +6,7 @@ import {
6
6
  routeMatcher,
7
7
  run,
8
8
  spinnerEnabled
9
- } from "./chunk-2UGE6HMQ.js";
9
+ } from "./chunk-VNVRHWO3.js";
10
10
  import {
11
11
  loadConfigFile
12
12
  } from "./chunk-M5KM5SV7.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "description": "A deterministic SvelteKit code-health scanner (SEO, performance, correctness, security, architecture) — not a runtime Web Vitals reporter.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -52,7 +52,7 @@
52
52
  "magicast": "^0.5.4",
53
53
  "svelte": "^5.56.8",
54
54
  "tinyglobby": "^0.2.17",
55
- "@svelte-vitals/core": "0.41.0"
55
+ "@svelte-vitals/core": "0.41.1"
56
56
  },
57
57
  "devDependencies": {
58
58
  "@gunshi/docs": "0.37.1",