@svelte-vitals/core 0.40.1 → 0.41.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/index.d.ts CHANGED
@@ -612,6 +612,29 @@ interface KitModuleFacts {
612
612
  parseFailed?: true;
613
613
  }
614
614
 
615
+ /**
616
+ * Resolve an import specifier to a path relative to the analyzed project's root (the
617
+ * cwd svelte-vitals runs from — not necessarily a repo root; in a monorepo the project
618
+ * may live at e.g. `apps/web/`) against the importing file, or undefined when it cannot
619
+ * be a project-local module: the caller's `aliases` list decides which non-relative
620
+ * specifiers resolve, defaulting to `$lib` → `src/lib`; `./`/`../` resolve against the
621
+ * importing file's directory; bare packages and other aliases are skipped (they can't
622
+ * be resolved to a project-local path at all). Also undefined when a relative
623
+ * specifier's `..` segments escape the project root (see `normalizePosix`), or when a
624
+ * matched alias's value is itself absolute (e.g. `/opt/shared/src`, or a posixified Windows
625
+ * drive-letter path like `C:/shared/src`): an absolute target is outside the analyzed project by
626
+ * definition, and without this check `normalizePosix` would quietly drop the leading empty
627
+ * segment and hand back a project-relative-LOOKING path that actually names a different file.
628
+ *
629
+ * Exported from the package's public barrel because `architecture/private-scope-import`
630
+ * and `architecture/route-component-import` (inside `packages/core`) both need resolution
631
+ * that is not restricted to runes modules, unlike `resolveRunesModuleSpecifier` — and
632
+ * because `resolveComponentPath` (`packages/cli/src/providers/source/resolve.ts`), which
633
+ * drives transitive `<head>`/heading resolution, delegates its alias/`$lib`/relative
634
+ * mapping here too, rather than duplicating it. This is the single site for every
635
+ * repo-local specifier resolution in the repo.
636
+ */
637
+ declare function resolveRepoLocalPath(spec: string, importerFile: string, aliases?: readonly KitAlias[]): string | undefined;
615
638
  /**
616
639
  * Resolve an import specifier to a repo-relative `.svelte.ts`/`.svelte.js` path, or
617
640
  * undefined when it cannot be a runes module: delegates to `resolveRepoLocalPath` with
@@ -780,6 +803,14 @@ declare function settingSeverity(setting: RuleSetting | undefined): Severity | '
780
803
  declare function settingOptions(setting: RuleSetting | undefined): RuleOptions | undefined;
781
804
  /** Drop rules disabled via config (design §6). */
782
805
  declare function selectRules(rules: Rule[], config: Config): Rule[];
806
+ /**
807
+ * `config` with `failedRuleIds` (from `runRules`' `failedRules`) forced `'off'`: a rule that threw
808
+ * examined nothing, so leaving it in the inventory would score it as if it had run clean, silently
809
+ * inflating Health. Reuses the exact mechanism a `rules: { id: 'off' }` config entry already gets —
810
+ * `selectRules`/`buildInventory` both drop an `'off'` id from the denominator — rather than adding a
811
+ * second, parallel notion of "not counted" for callers to keep in sync.
812
+ */
813
+ declare function withFailedRulesOff(config: Config, failedRuleIds: readonly string[]): Config;
783
814
  /** Apply per-rule severity overrides to results (design §6). */
784
815
  declare function applyRuleSeverities(results: Result[], config: Config): Result[];
785
816
  /** An override entry with its globs compiled once. Build with `compileOverrides`. */
@@ -1009,14 +1040,21 @@ declare function docsUrlFor(id: string): string;
1009
1040
  */
1010
1041
  declare function isPenalized(detection: Detection, treatDynamicAs: TreatDynamicAs): boolean;
1011
1042
 
1043
+ interface FailedRule {
1044
+ id: string;
1045
+ message: string;
1046
+ }
1012
1047
  /**
1013
1048
  * Run a set of rules against a shared context and collect their findings.
1014
1049
  * Rules are independent, so they run concurrently; results are flattened in
1015
- * rule order for stable output.
1050
+ * rule order for stable output. A rule that throws (sync or async) contributes
1051
+ * no results instead of taking the whole run down with it — dev tooling must
1052
+ * never throw — and is reported in `failedRules` instead.
1016
1053
  */
1017
1054
  declare function runRules(rules: Rule[], ctx: RuleContext): Promise<{
1018
1055
  results: Result[];
1019
1056
  examined: Record<string, Record<string, number>>;
1057
+ failedRules: FailedRule[];
1020
1058
  }>;
1021
1059
 
1022
1060
  /**
@@ -1696,4 +1734,4 @@ declare function escapeHtml(s: string): string;
1696
1734
  */
1697
1735
  declare function safeHref(url: string): string | null;
1698
1736
 
1699
- export { APP_SCRIPT, APP_STYLE, type AppSnapshot, BAND_COLOR, CATEGORIES, CHILD_NODE_KEYS, type Category, type Classification, type CompiledOverride, 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 KitAlias, type KitModuleFacts, type OrphanEffectFact, type Palette, type Presence, type Project, ROBOTS_SOURCE_PATHS, type RawKitAliases, type ResolvedHead, type ResolvedHeadings, type ResolvedImages, type Result, type RouteBadge, type Rule, type RuleContext, type RuleEvidence, type RuleInfo, type RuleOptionInfo, type RuleOptionSpec, type RuleOptions, type RuleOptionsSpec, type RuleOverride, type RuleSetting, type RuleSettingObject, type Runtime, SITEMAP_SOURCE_PATHS, SVELTE_CONFIG_FILES, type Scope, type ScoreModel, type ScoreOptions, type ScoreResult, type Severity, type SourceSpan, type Summary, type SuppressionDirective, type TreatDynamicAs, VITE_CONFIG_FILES, type Value, type ViteKitConfigResult, allRules, applyOverrides, applyRuleSeverities, architectureComponentSize, architectureDirectoryNaming, architectureDocLinkTarget, architecturePrivateScopeImport, architecturePropCount, architectureReservedDirectoryNames, architectureReservedNamePlacement, architectureRouteComponentImport, architectureUnitEntryFile, attrText, attrTextOf, attrValue, attrValueOf, buildHtmlDocument, buildJsonReport, classify, collectComponentFacts, collectKitModuleFacts, collectSourceFiles, compileOverrides, computeHealth, computeScore, correctnessBasePathNavigation, correctnessCheckableBindValue, correctnessEachIndexKey, correctnessEachKey, correctnessEffectAsDerived, correctnessEffectAsOnMount, correctnessInstanceBrowserGlobal, correctnessNonreactiveBuiltinState, correctnessOrphanEffect, correctnessOrphanLifecycle, correctnessPropMutation, correctnessServerBrowserGlobal, correctnessStalePropDerivation, correctnessUnmutatedState, defaultConfig, defaultProject, defineConfig, docsUrlFor, effectiveSeverity, emptyComponentFacts, emptyKitModuleFacts, escapeHtml, explainRule, findAttr, findKitAliasesInSvelteConfig, findKitPathsBaseInSvelteConfig, findKitPathsBaseInViteConfig, findMinifyDisabled, formatAgentReport, formatConsoleReport, formatGithubReport, formatHtmlReport, formatJsonReport, formatMarkdownReport, formatSarifReport, hasFailureAtOrAbove, headTagRule, imageRule, intOption, isMentionedAnywhere, isPenalized, lineOf, linkRule, listOption, mapOption, noColorPalette, overrideMatches, parseComponentFacts, parseKitModuleFacts, performanceFontPreloadCrossorigin, performanceHeavyImport, performanceImageDimensions, performanceImageLoadingHint, performanceLcpImage, performanceLoadWaterfall, performanceMinifyDisabled, performanceNamespaceImport, performancePreconnect, performancePreloadMissingAs, performanceRenderBlockingScript, performanceResponsiveImage, performanceSequentialAwaits, performanceStateRaw, renderAppShell, resolveKitAliases, resolveKitPathsBase, resolveRuleOptions, resolveRunesModuleSpecifier, runRules, safeHref, scoreBand, scoreColor, scoresByCategory, securityHandlerStateWrite, securityJavascriptUrl, securityRawHtml, securityServerModuleState, securitySharedStateImport, selectRules, seoCanonicalUrl, seoCharset, seoDescriptionLength, seoDescriptionPresence, seoDuplicateDescription, seoDuplicateTitle, seoHeadingLevelSkip, seoHreflang, seoHtmlLang, seoImageAlt, seoIndexability, seoJsonLd, seoJsonLdDateFormat, seoJsonLdDeprecatedType, seoJsonLdPlaceholder, seoJsonLdRelativeUrl, seoJsonLdRequiredProps, seoJsonLdValidity, seoOgDescription, seoOgImage, seoOgTitle, seoOgUrl, seoRobotsTxt, seoSingleH1, seoSitemapInRobots, seoSitemapXml, seoSsrDisabled, seoTitleLength, seoTitlePresence, seoTwitterCard, seoViewport, settingOptions, settingSeverity, shouldSkipRangeCheck, summarize, textFromNodes, validateRuleOptions, validateRuleSetting, valueFromNodes };
1737
+ export { APP_SCRIPT, APP_STYLE, type AppSnapshot, BAND_COLOR, CATEGORIES, CHILD_NODE_KEYS, type Category, type Classification, type CompiledOverride, type ComponentFacts, type Config, type ConsoleReportOptions, type Detection, type EachBlockFact, type EffectFact, type FailedRule, type Fix, type HeadProvider, type HeadTag, type HeadingInfo, type HealthResult, type ImageInfo, type JsonReport, type KitAlias, type KitModuleFacts, type OrphanEffectFact, type Palette, type Presence, type Project, ROBOTS_SOURCE_PATHS, type RawKitAliases, type ResolvedHead, type ResolvedHeadings, type ResolvedImages, type Result, type RouteBadge, type Rule, type RuleContext, type RuleEvidence, type RuleInfo, type RuleOptionInfo, type RuleOptionSpec, type RuleOptions, type RuleOptionsSpec, type RuleOverride, type RuleSetting, type RuleSettingObject, type Runtime, SITEMAP_SOURCE_PATHS, SVELTE_CONFIG_FILES, type Scope, type ScoreModel, type ScoreOptions, type ScoreResult, type Severity, type SourceSpan, type Summary, type SuppressionDirective, type TreatDynamicAs, VITE_CONFIG_FILES, type Value, type ViteKitConfigResult, allRules, applyOverrides, applyRuleSeverities, architectureComponentSize, architectureDirectoryNaming, architectureDocLinkTarget, architecturePrivateScopeImport, architecturePropCount, architectureReservedDirectoryNames, architectureReservedNamePlacement, architectureRouteComponentImport, architectureUnitEntryFile, attrText, attrTextOf, attrValue, attrValueOf, buildHtmlDocument, buildJsonReport, classify, collectComponentFacts, collectKitModuleFacts, collectSourceFiles, compileOverrides, computeHealth, computeScore, correctnessBasePathNavigation, correctnessCheckableBindValue, correctnessEachIndexKey, correctnessEachKey, correctnessEffectAsDerived, correctnessEffectAsOnMount, correctnessInstanceBrowserGlobal, correctnessNonreactiveBuiltinState, correctnessOrphanEffect, correctnessOrphanLifecycle, correctnessPropMutation, correctnessServerBrowserGlobal, correctnessStalePropDerivation, correctnessUnmutatedState, defaultConfig, defaultProject, defineConfig, docsUrlFor, effectiveSeverity, emptyComponentFacts, emptyKitModuleFacts, escapeHtml, explainRule, findAttr, findKitAliasesInSvelteConfig, findKitPathsBaseInSvelteConfig, findKitPathsBaseInViteConfig, findMinifyDisabled, formatAgentReport, formatConsoleReport, formatGithubReport, formatHtmlReport, formatJsonReport, formatMarkdownReport, formatSarifReport, hasFailureAtOrAbove, headTagRule, imageRule, intOption, isMentionedAnywhere, isPenalized, lineOf, linkRule, listOption, mapOption, noColorPalette, overrideMatches, parseComponentFacts, parseKitModuleFacts, performanceFontPreloadCrossorigin, performanceHeavyImport, performanceImageDimensions, performanceImageLoadingHint, performanceLcpImage, performanceLoadWaterfall, performanceMinifyDisabled, performanceNamespaceImport, performancePreconnect, performancePreloadMissingAs, performanceRenderBlockingScript, performanceResponsiveImage, performanceSequentialAwaits, performanceStateRaw, renderAppShell, resolveKitAliases, resolveKitPathsBase, resolveRepoLocalPath, resolveRuleOptions, resolveRunesModuleSpecifier, runRules, safeHref, scoreBand, scoreColor, scoresByCategory, securityHandlerStateWrite, securityJavascriptUrl, securityRawHtml, securityServerModuleState, securitySharedStateImport, selectRules, seoCanonicalUrl, seoCharset, seoDescriptionLength, seoDescriptionPresence, seoDuplicateDescription, seoDuplicateTitle, seoHeadingLevelSkip, seoHreflang, seoHtmlLang, seoImageAlt, seoIndexability, seoJsonLd, seoJsonLdDateFormat, seoJsonLdDeprecatedType, seoJsonLdPlaceholder, seoJsonLdRelativeUrl, seoJsonLdRequiredProps, seoJsonLdValidity, seoOgDescription, seoOgImage, seoOgTitle, seoOgUrl, seoRobotsTxt, seoSingleH1, seoSitemapInRobots, seoSitemapXml, seoSsrDisabled, seoTitleLength, seoTitlePresence, seoTwitterCard, seoViewport, settingOptions, settingSeverity, shouldSkipRangeCheck, summarize, textFromNodes, validateRuleOptions, validateRuleSetting, valueFromNodes, withFailedRulesOff };