svelte-vitals 0.34.0 → 0.35.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
@@ -9,7 +9,7 @@ import {
9
9
  readCoreVersion,
10
10
  readPackageVersion,
11
11
  run
12
- } from "./chunk-WSPRFLPP.js";
12
+ } from "./chunk-D6AUX2GC.js";
13
13
 
14
14
  // src/bin.ts
15
15
  import mri3 from "mri";
@@ -17,8 +17,7 @@ import {
17
17
  defineConfig,
18
18
  selectRules,
19
19
  applyRuleSeverities,
20
- applyOverrides,
21
- collectKitModuleFacts
20
+ applyOverrides
22
21
  } from "@svelte-vitals/core";
23
22
 
24
23
  // src/runtime/node.ts
@@ -47,9 +46,6 @@ function createNodeRuntime() {
47
46
  };
48
47
  }
49
48
 
50
- // src/providers/source/routes.ts
51
- import { defaultConfig } from "@svelte-vitals/core";
52
-
53
49
  // src/providers/source/project.ts
54
50
  import {
55
51
  ROBOTS_SOURCE_PATHS,
@@ -57,6 +53,7 @@ import {
57
53
  SVELTE_CONFIG_FILES,
58
54
  VITE_CONFIG_FILES,
59
55
  findMinifyDisabled,
56
+ resolveKitAliases,
60
57
  resolveKitPathsBase
61
58
  } from "@svelte-vitals/core";
62
59
  var ProjectError = class extends Error {
@@ -169,20 +166,25 @@ async function readFirstConfig(rt, cwd, files) {
169
166
  }
170
167
  return void 0;
171
168
  }
172
- async function detectKitPathsBase(rt, cwd) {
169
+ async function detectKitConfigFacts(rt, cwd) {
173
170
  const [viteConfig, svelteConfig] = await Promise.all([
174
171
  readFirstConfig(rt, cwd, VITE_CONFIG_FILES),
175
172
  readFirstConfig(rt, cwd, SVELTE_CONFIG_FILES)
176
173
  ]);
177
- return resolveKitPathsBase(viteConfig, svelteConfig);
174
+ const kitPathsBase = resolveKitPathsBase(viteConfig, svelteConfig);
175
+ const kitAliases = resolveKitAliases(viteConfig, svelteConfig);
176
+ return {
177
+ ...kitPathsBase ? { kitPathsBase } : {},
178
+ ...kitAliases ? { kitAliases } : {}
179
+ };
178
180
  }
179
181
  async function collectProjectFacts(rt, cwd) {
180
- const [hasRobotsTxt, hasSitemap, htmlLang, viteMinifyDisabled, kitPathsBase] = await Promise.all([
182
+ const [hasRobotsTxt, hasSitemap, htmlLang, viteMinifyDisabled, kitConfig] = await Promise.all([
181
183
  existsAny(rt, cwd, ROBOTS_SOURCE_PATHS),
182
184
  existsAny(rt, cwd, SITEMAP_SOURCE_PATHS),
183
185
  detectAppHtmlLang(rt, cwd),
184
186
  detectViteMinifyDisabled(rt, cwd),
185
- detectKitPathsBase(rt, cwd)
187
+ detectKitConfigFacts(rt, cwd)
186
188
  ]);
187
189
  const robotsReferencesSitemap = await robotsRefsSitemap(rt, cwd);
188
190
  return {
@@ -191,10 +193,22 @@ async function collectProjectFacts(rt, cwd) {
191
193
  htmlLang,
192
194
  ...robotsReferencesSitemap !== void 0 ? { robotsReferencesSitemap } : {},
193
195
  ...viteMinifyDisabled ? { viteMinifyDisabled } : {},
194
- ...kitPathsBase ? { kitPathsBase } : {}
196
+ ...kitConfig
195
197
  };
196
198
  }
197
199
 
200
+ // src/collect-all.ts
201
+ import {
202
+ collectKitModuleFacts,
203
+ collectSourceFiles
204
+ } from "@svelte-vitals/core";
205
+
206
+ // src/providers/source/components.ts
207
+ import { collectComponentFacts } from "@svelte-vitals/core";
208
+
209
+ // src/providers/source/routes.ts
210
+ import { defaultConfig } from "@svelte-vitals/core";
211
+
198
212
  // src/providers/source/adapters/svelte-meta-tags.ts
199
213
  import { attrValueOf, attrTextOf } from "@svelte-vitals/core";
200
214
 
@@ -723,8 +737,27 @@ async function collectRoutes(rt, cwd, config = defaultConfig, cache = /* @__PURE
723
737
  };
724
738
  }
725
739
 
726
- // src/providers/source/components.ts
727
- import { collectComponentFacts } from "@svelte-vitals/core";
740
+ // src/route-matcher.ts
741
+ function routeMatcher(glob2) {
742
+ if (!glob2) return () => true;
743
+ const body = glob2.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, " ").replace(/\*/g, "[^/]*").replace(/\/ $/g, "(?:/.*)?").replace(/^ \//g, "(?:.*/)?").replace(/ \//g, "(?:.*/)?").replace(/\/ /g, "(?:/.*)?").replace(/ /g, ".*");
744
+ const re = new RegExp(`^${body}$`);
745
+ return (route) => re.test(route.replace(/^\//, ""));
746
+ }
747
+
748
+ // src/collect-all.ts
749
+ async function collectAll(rt, cwd, config, opts = {}) {
750
+ const matches = routeMatcher(opts.route);
751
+ const collected = await collectRoutes(rt, cwd, config, opts.parseCache);
752
+ const heads = collected.heads.filter((h) => matches(h.route));
753
+ const images = collected.images.filter((i) => matches(i.route));
754
+ const headings = collected.headings.filter((h) => matches(h.route));
755
+ const project = await collectProjectFacts(rt, cwd);
756
+ const components = opts.route ? [] : await collectComponentFacts(rt, cwd);
757
+ const kitModules = opts.route ? [] : await collectKitModuleFacts(rt, cwd, project.kitAliases);
758
+ const sourceFiles = opts.route ? void 0 : await collectSourceFiles(rt, cwd);
759
+ return { heads, images, headings, project, components, kitModules, sourceFiles };
760
+ }
728
761
 
729
762
  // src/discover-apps.ts
730
763
  import { existsSync } from "fs";
@@ -1431,12 +1464,6 @@ import { defineConfig as defineConfig2 } from "@svelte-vitals/core";
1431
1464
  function spinnerEnabled(opts) {
1432
1465
  return opts.reporter === "console" && opts.stderrIsTTY && !isAutoDetectedAgent(opts.rawReporter, opts.env) && colorEnabled({ reporter: opts.reporter, isTTY: opts.stderrIsTTY, env: opts.env, noColorFlag: opts.noColorFlag });
1433
1466
  }
1434
- function routeMatcher(glob2) {
1435
- if (!glob2) return () => true;
1436
- const body = glob2.replace(/[.+^${}()|[\]\\]/g, "\\$&").replace(/\*\*/g, " ").replace(/\*/g, "[^/]*").replace(/\/ $/g, "(?:/.*)?").replace(/^ \//g, "(?:.*/)?").replace(/ \//g, "(?:.*/)?").replace(/\/ /g, "(?:/.*)?").replace(/ /g, ".*");
1437
- const re = new RegExp(`^${body}$`);
1438
- return (route) => re.test(route.replace(/^\//, ""));
1439
- }
1440
1467
  async function analyzeProject(opts = {}) {
1441
1468
  const cwd = opts.cwd ?? process.cwd();
1442
1469
  const rt = createNodeRuntime();
@@ -1453,19 +1480,15 @@ async function analyzeProject(opts = {}) {
1453
1480
  });
1454
1481
  await detectProject(rt, cwd);
1455
1482
  const warnings = [...loaded?.warnings ?? [], ...await checkVersionFloor(rt, cwd)];
1456
- const matches = routeMatcher(opts.route);
1457
- const collected = await collectRoutes(rt, cwd, config, opts.parseCache);
1458
- const heads = collected.heads.filter((h) => matches(h.route));
1459
- const images = collected.images.filter((i) => matches(i.route));
1460
- const headings = collected.headings.filter((h) => matches(h.route));
1461
- const project = await collectProjectFacts(rt, cwd);
1462
- const components = opts.route ? [] : await collectComponentFacts(rt, cwd);
1463
- const kitModules = opts.route ? [] : await collectKitModuleFacts(rt, cwd);
1483
+ const { heads, images, headings, project, components, kitModules, sourceFiles } = await collectAll(rt, cwd, config, {
1484
+ route: opts.route,
1485
+ parseCache: opts.parseCache
1486
+ });
1464
1487
  const selected = selectRules(allRules2, config);
1465
1488
  const rules = opts.categories ? selected.filter((r) => opts.categories.includes(r.category)) : selected;
1466
1489
  const results = applyOverrides(
1467
1490
  applyRuleSeverities(
1468
- await runRules(rules, { heads, images, headings, components, project, config, kitModules }),
1491
+ await runRules(rules, { heads, images, headings, components, project, config, kitModules, sourceFiles }),
1469
1492
  config
1470
1493
  ),
1471
1494
  config
@@ -1718,6 +1741,7 @@ async function run(opts = {}) {
1718
1741
 
1719
1742
  export {
1720
1743
  ProjectError,
1744
+ routeMatcher,
1721
1745
  discoverApps,
1722
1746
  readPackageVersion,
1723
1747
  readCoreVersion,
@@ -1729,7 +1753,6 @@ export {
1729
1753
  CONFIG_FILENAMES,
1730
1754
  loadConfigFile,
1731
1755
  spinnerEnabled,
1732
- routeMatcher,
1733
1756
  analyzeProject,
1734
1757
  applyScope,
1735
1758
  run,
package/dist/index.d.ts CHANGED
@@ -56,6 +56,8 @@ declare class ProjectError extends Error {
56
56
  constructor(message: string);
57
57
  }
58
58
 
59
+ declare function routeMatcher(glob: string | undefined): (route: string) => boolean;
60
+
59
61
  /** Rule ids passed to --rules/--ignore that aren't part of the built-in registry. */
60
62
  declare function findUnknownRuleIds(ids: string[]): string[];
61
63
  /** All built-in rule ids, sorted — for help and error messages. */
@@ -168,7 +170,6 @@ declare function spinnerEnabled(opts: {
168
170
  env: NodeJS.ProcessEnv;
169
171
  noColorFlag?: boolean;
170
172
  }): boolean;
171
- declare function routeMatcher(glob: string | undefined): (route: string) => boolean;
172
173
  interface AnalyzeOptions {
173
174
  cwd?: string;
174
175
  metaComponents?: string[];
package/dist/index.js CHANGED
@@ -11,7 +11,7 @@ import {
11
11
  ruleOptionsSpec,
12
12
  run,
13
13
  spinnerEnabled
14
- } from "./chunk-WSPRFLPP.js";
14
+ } from "./chunk-D6AUX2GC.js";
15
15
  export {
16
16
  ProjectError,
17
17
  analyzeProject,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svelte-vitals",
3
- "version": "0.34.0",
3
+ "version": "0.35.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",
@@ -43,10 +43,10 @@
43
43
  "log-update": "^8.0.0",
44
44
  "magicast": "^0.5.3",
45
45
  "mri": "^1.2.0",
46
- "smol-toml": "^1.7.0",
46
+ "smol-toml": "^1.7.1",
47
47
  "svelte": "^5.56.8",
48
48
  "tinyglobby": "^0.2.17",
49
- "@svelte-vitals/core": "0.30.0"
49
+ "@svelte-vitals/core": "0.31.0"
50
50
  },
51
51
  "devDependencies": {
52
52
  "@types/estree": "^1.0.9",