@usefragments/core 2.0.0 → 2.0.2
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/{chunk-BMPYIUZE.js → chunk-QPOKQ5H6.js} +8 -2
- package/dist/chunk-QPOKQ5H6.js.map +1 -0
- package/dist/codes/index.js +1 -1
- package/dist/index.d.ts +18 -4
- package/dist/index.js +158 -66
- package/dist/index.js.map +1 -1
- package/dist/schemas/index.js +1 -1
- package/package.json +1 -1
- package/src/canonical-source.ts +41 -0
- package/src/evaluation/canonical-facts-trust.test.ts +337 -0
- package/src/evaluation/evaluate.ts +67 -10
- package/src/evaluation/evaluation-v2-receipt-v1.test.ts +1 -1
- package/src/evaluation/index.ts +1 -1
- package/src/evaluation/types.ts +5 -3
- package/src/facts/builders.ts +4 -0
- package/src/facts/fact-index.ts +4 -0
- package/src/facts/facts.test.ts +70 -0
- package/src/facts/types.ts +4 -0
- package/src/identity/usage.test.ts +64 -0
- package/src/identity/usage.ts +7 -1
- package/src/index.ts +6 -0
- package/src/rules/components-prefer-library.ts +110 -33
- package/dist/chunk-BMPYIUZE.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1053,6 +1053,8 @@ interface UsageComponentFact extends BaseFact {
|
|
|
1053
1053
|
kind: "usage_component";
|
|
1054
1054
|
nodeId: FactId;
|
|
1055
1055
|
componentId: ComponentId;
|
|
1056
|
+
/** Exact local definition resolved from source, separate from catalog/policy identity. */
|
|
1057
|
+
definitionKey?: string;
|
|
1056
1058
|
}
|
|
1057
1059
|
interface UsageImportFact extends BaseFact {
|
|
1058
1060
|
kind: "usage_import";
|
|
@@ -1342,6 +1344,8 @@ interface ComponentDefinitionFact extends BaseFact {
|
|
|
1342
1344
|
componentKey: string;
|
|
1343
1345
|
renderRoot: ComponentDefinitionRenderRoot;
|
|
1344
1346
|
propSurface: string[];
|
|
1347
|
+
/** Implementation region, used to scope exemptions; never part of fact identity. */
|
|
1348
|
+
location?: FactLocation;
|
|
1345
1349
|
stylingChannel?: {
|
|
1346
1350
|
module: string;
|
|
1347
1351
|
ownsVisualRole: boolean;
|
|
@@ -1846,6 +1850,7 @@ declare function makeComponentDefinitionFact(input: {
|
|
|
1846
1850
|
componentKey: string;
|
|
1847
1851
|
renderRoot: ComponentDefinitionFact["renderRoot"];
|
|
1848
1852
|
propSurface: string[];
|
|
1853
|
+
location?: FactLocation;
|
|
1849
1854
|
stylingChannel?: ComponentDefinitionFact["stylingChannel"];
|
|
1850
1855
|
}): ComponentDefinitionFact;
|
|
1851
1856
|
declare function makeComponentIdentityFact(input: {
|
|
@@ -2014,6 +2019,7 @@ declare function makeUsageNodeFact(input: {
|
|
|
2014
2019
|
declare function makeUsageComponentFact(input: {
|
|
2015
2020
|
nodeId: FactId;
|
|
2016
2021
|
componentId: ComponentId;
|
|
2022
|
+
definitionKey?: string;
|
|
2017
2023
|
}): UsageComponentFact;
|
|
2018
2024
|
declare function makeUsageImportFact(input: {
|
|
2019
2025
|
file: string;
|
|
@@ -12745,6 +12751,12 @@ interface ComponentIdentityUsage {
|
|
|
12745
12751
|
/** Join resolved component usages to their usage nodes once for rules and DX surfaces. */
|
|
12746
12752
|
declare function indexComponentIdentityUsage(ix: FactIndex): ReadonlyMap<string, ComponentIdentityUsage>;
|
|
12747
12753
|
|
|
12754
|
+
/** Export filters narrow source ownership; an empty include approves nothing. */
|
|
12755
|
+
declare function canonicalSourceIncludesExport(source: CanonicalSource, name: string): boolean;
|
|
12756
|
+
/** Filesystem ownership only. Package import specifiers are not local paths. */
|
|
12757
|
+
declare function canonicalSourceContainsFile(source: CanonicalSource, file: string): boolean;
|
|
12758
|
+
declare function isCanonicalSourceDefinition(file: string, exportName: string, sources: readonly CanonicalSource[]): boolean;
|
|
12759
|
+
|
|
12748
12760
|
/**
|
|
12749
12761
|
* Rule helpers — small internal queries shared by Phase 5 rules.
|
|
12750
12762
|
*
|
|
@@ -14116,9 +14128,11 @@ declare function coverageArtifactDigestV1(rawPlan: AnalysisPlanV1, rawCoverage:
|
|
|
14116
14128
|
*/
|
|
14117
14129
|
|
|
14118
14130
|
/** Bumped when kernel semantics change in a way that can flip a verdict. */
|
|
14119
|
-
declare const EVALUATOR_VERSION: "evaluation-kernel:v1";
|
|
14120
|
-
/**
|
|
14121
|
-
declare const EVALUATOR_VERSION_V2: "evaluation-kernel:v2";
|
|
14131
|
+
declare const EVALUATOR_VERSION: "evaluation-kernel:v1.1";
|
|
14132
|
+
/** Current facts-only evaluator. The input schema remains V2. */
|
|
14133
|
+
declare const EVALUATOR_VERSION_V2: "evaluation-kernel:v2.1";
|
|
14134
|
+
/** Replay-only generation: its captured mapping judgments remain authoritative. */
|
|
14135
|
+
declare const LEGACY_EVALUATOR_VERSION_V2: "evaluation-kernel:v2";
|
|
14122
14136
|
/**
|
|
14123
14137
|
* Four-state per-finding model (spec §2). `candidate` is the derivation step —
|
|
14124
14138
|
* "severity/rule says it could block" — and always resolves to one of the
|
|
@@ -14530,4 +14544,4 @@ declare const APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH = 512;
|
|
|
14530
14544
|
/** Empty is authored absence; missing is unavailable authority. */
|
|
14531
14545
|
declare function isApprovedContractTokenNames(value: unknown): value is string[];
|
|
14532
14546
|
|
|
14533
|
-
export { type A11yNameRequiredFact, AGENT_CONTEXT_RELATIVE_PATH, ANALYSIS_LIMIT_CEILINGS_V1, ANALYSIS_PLAN_MAX_CAPABILITIES_V1, ANALYSIS_PLAN_MAX_DIALECTS_PER_REGION_V1, ANALYSIS_PLAN_MAX_REGIONS_V1, APPROVED_CONTRACT_TOKEN_MAX_NAMES, APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH, AgentFormat, type AnalysisLimitsV1, type AnalysisPlanId, type AnalysisPlanInputV1, type AnalysisPlanV1, type AnalysisRegionV1, BLOCKING_RULE_ALLOWLIST, BRAND, BlockDefinition, type Brand, type BuildAgentFormatInput, type BuildRegistryInstallPlanInput, type BundleArtifactMetadata, type BundleComponentShard, type BundleManifest, type BundleManifestComponentEntry, type BundleSchemaVersion, type BundleTarget, type BundleTokenFile, CANONICAL_FACT_MAX_CONFLICTS_V1, CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1, CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1, CATALOG_FIXTURE_A_FCID, type CSSGeneratorOptions, type CanonicalBridgeIdentityBinding, CanonicalBridgeV1, type CanonicalCandidateFact, type CanonicalDirectionConflict, type CanonicalFactConflictV1, type CanonicalFactConflictValueV1, type CanonicalFactIntegrityV1, Finding as CanonicalFinding, type CanonicalIdentityReference, type CanonicalMappingFact, type CanonicalReplacementFact, CanonicalSource, type CheckedSpacingValue, type ClassNameDynamicFact, type ClassNameDynamicReason, type ClassNameFact, type ClassNameLiteralFact, type ClassNameOrigin, type ClassifyIdentityInput, type CompileEffectiveGovernanceInputsOptions, CompiledBlock, type CompiledContractOutput, CompiledFragment, type ComplexityTier, type ComponentCapabilityFact, type ComponentContract, type ComponentDefinitionFact, type ComponentDefinitionRenderRoot, type ComponentFactInput, type ComponentId, type ComponentIdentityFact, type ComponentIdentityUsage, type ComponentKeyInput, type ComponentLevelFact, type ComponentMetadataFact, type CompositionAnalysis, type CompositionAuthoringEntry, type CompositionChildSelector, type CompositionConstraint, type CompositionGuideline, type CompositionPattern, type CompositionRegionSelector, type CompositionSuggestion, type CompositionWarning, type ConformChange, type ConformComponentMapping, type ConformConfidence, type ConformCoverage, type ConformInput, type ConformLocation, type ConformPropMapping, type ConformResult, type ConformSuggestion, type ConformToken, type ConformUnresolved, ContractCanonicalMappingInput, ContractCatalogInput, ContractDomain, ContractPreimage, type ContractStampPin, type ContractStampRecord, type ContractTokenReferenceCensus, type CoverageRegionV1, type CoverageStateV1, type CoverageSummaryV1, CoverageValidationErrorV1, DEFAULTS, DEFAULT_ENHANCED_STYLE_PROPERTIES, DEFAULT_STYLE_PROPERTIES, type DTCGColorValue, type DTCGDimensionValue, type DTCGGroup, type DTCGToken, type DTCGTokenFile, type DTCGTokenType, type Defaults, type DeltaEMatch, type DesignSystemContext, type DesignToken, type DesignTokenParseOptions, type DigestHex, type DiscoverComponentsOptions, EFFECTIVE_GOVERNANCE_INPUTS_SCHEMA, EMPTY_VOCABULARY_MESSAGE, EVALUATION_MAX_FINDINGS_V2, EVALUATION_MAX_MAP_ENTRIES_V2, EVALUATION_MAX_POLICY_RULES_V2, EVALUATION_MAX_REASON_CODES_V2, EVALUATION_MAX_WAIVERS_V2, EVALUATION_MAX_WAIVER_MATCHES_V2, EVALUATION_RECEIPT_STRING_MAX_BYTES_V1, EVALUATOR_VERSION, EVALUATOR_VERSION_V2, type EffectiveEvaluationWaiverV2, type EffectiveGovernanceInputs, type EffectiveGovernanceInputsSourceState, type EffectivePolicy, type EffectiveRulePolicy, type EnhancedStyleComparisonResult, type EnhancedStyleDiffItem, type EvaluatedFinding, type EvaluationAuthorityV1, type EvaluationBaseline, type EvaluationContractInput, type EvaluationEvidence, type EvaluationEvidenceTrustV1, type EvaluationFindingInput, type EvaluationFindingState, type EvaluationInput, type EvaluationInputV2, type EvaluationIntegrityInput, type EvaluationIntegrityInputV2, type EvaluationMappingTrust, type EvaluationReason, type EvaluationReasonV2, type EvaluationReceiptId, type EvaluationReceiptMintInputV1, type EvaluationReceiptSemanticV1, type EvaluationReceiptV1, type EvaluationResult, type EvaluationResultV2, type EvaluationScope, type EvaluationSourceTrust, type EvaluationTrust, type EvaluationVerdict, type EvaluationWaiver, EvidenceGrade, type ExternalIdentityReference, FRAGMENTS_INTERNAL_RULE_IDS, FRAGMENT_V3_SCHEMA_URL, type Fact, type FactConflict, type FactEvidence, type FactId, FactIndex, type FactKind, type FactLocation, type FactOfKind, FigmaBooleanMapping, FigmaChildrenMapping, FigmaEnumMapping, FigmaInstanceMapping, FigmaStringMapping, FigmaTextContentMapping, type FigmaVariable, type FigmaVariableCollection, Finding, FindingFix, type FindingV2, FragmentAnnotationsV3, FragmentComponent, FragmentDefinition, FragmentDefinitionV2, FragmentDefinitionV3, FragmentDefinitionV3Body, FragmentDesignV3, FragmentDontExampleV3, FragmentGuidanceV3, FragmentMatrixV3, FragmentMetaV3, FragmentPreviewV3, FragmentStateV3, FragmentsConfig, Severity as FuiSeverity, GovernanceConfig, type GovernanceIntegrityFamily, type GovernanceIntegrityFamilyId, type GovernanceIntegrityInput, type GovernanceIntegrityRoster, type GovernanceIntegrityStatus, type GovernanceIntegrityVerdict, GovernanceSeverity, GovernedFragmentDefinition, type IdentityClassification, type IdentityConfidence, type IdentityDecision, type IdentityFact, type IdentityState, type InertConfigDiagnostic, type InertConfigDiagnosticCode, type InertConfigDiagnosticKind, type InferProps, type JsxComponentPreferredFact, type JsxImportPathPreferredFact, type JsxInlineStyleForbiddenRawFact, type JsxUnknownPropsForbiddenFact, type LocalIdentityReference, type McpBlock, type McpCapability, type McpComponent, type McpComponentExample, type McpComponentGuidance, type McpComponentMetadata, type McpComponentProp, type McpComponentRelation, type McpCompoundChild, type McpGuidancePattern, type McpPerformanceData, type McpPerformanceImport, type McpPerformanceSummary, type McpSnapshot, type McpSnapshotMetadata, type McpSnapshotSchemaVersion, type McpSourceType, type McpToken, type McpTokenData, type NearestByDeltaEOptions, type NormalizedStyleMap, type NormalizedToken, PRESET_NAMES, PROVE_DEFAULT_MAX_PASSES, PROVE_MAX_PASSES, PROVIDER_ID_MAX_BYTES_V1, type ParseTokensOptions, type ParsedToken, type PerformanceData as PerfData, type PerformanceSummary as PerfSummary, type PerformanceBudgets, type PerformanceConfig, type PolicyExclude, type PolicyExcludeInput, type PolicyFact, type PresetRuleState, PropAnnotation, type PropMetadataFact, type PropValueAvoidedFact, type PropValueForbiddenFact, type ProveCallbacks, type ProveLoopResult, type ProveOptions, type ProvePass, type ProvePassSampling, type ProveResidual, type ProveSample, type ProveSamplerArgs, type ProveVerdict, type ProviderProofSemanticV1, type ProviderProofV1, RAW_HTML_ADVISORY_TAGS, RAW_HTML_CANONICAL_TAGS, RAW_HTML_INPUT_TYPE_CANONICALS, RAW_HTML_ROLE_CANONICALS, REPOSITORY_BINDING_ID_MAX_BYTES_V1, type RGB, type RGBA, RULES, RULE_FAMILY_IDS, RULE_FAMILY_MEMBERS, RULE_TIER, type RawHtmlCanonicalMatch, type RawHtmlPrecisionTier, RegistryArtifact, RegistryDependency, RegistryFile, type RegistryInstallPlan, RegistryInstallReceipt, type RegistryInstallSelection, type RegistryInstallSelectionInput, type RegistryInstallSourceFile, type RegistryInstallSources, type RegistryInstallSourcesInput, RegistryManifest, type RegistryWritePlan, RelationshipType, type RepositoryBindingKeyV1, type RepositoryBindingKeyV1Input, type ResolvedDTCGToken, ResolvedGovernedFragmentDefinition, type ResolvedIdentityRenderRoot, type ResolvedIntrinsicIdentityRoot, type Rule, type RuleConfigView, type RuleFn, type RuleTier, type SCSSGeneratorOptions, type ScaleFact, type ScaleValueFact, Severity, type SpacingResolutionScale, type SpacingTokenLookup, type StructuralConfidenceFact, type StyleComparisonOptions, type StyleComparisonResult, type StyleCssVarsMustBeDefinedFact, type StyleDeclarationFact, type StyleDiffItem, type StyleFontSizeScaleFact, type StylePropertyScaleFact, type StyleRawColorForbiddenFact, type StyleUnsupportedFact, type StyleValueProvenance, type SupersededImportPathPreference, type SuppressionDirectiveFact, type TailwindClassFact, type TailwindModifier, type TailwindModifierKind, type TailwindPaletteAllowFact, type TailwindPaletteDenyFact, type TailwindResolutionSource, type TailwindResolvedKind, type TailwindResolvedValue, type TailwindTokenResolvedFact, type TailwindUnknownClassEnabledFact, type TailwindValue, type ThemeDeclarationFact, type ThemeParserResult, type TokenCatalog, type TokenCatalogDefinition, type TokenCatalogDiagnostic, type TokenCatalogLocation, type TokenCatalogReference, type TokenCatalogSourceState, type TokenCategory, TokenConfig, type TokenDefinitionFact, type TokenFix, type TokenFormat, type TokenLookup, type TokenMatchRequest, type TokenMatchResult, type TokenParseError, type TokenParseOutput, type TokenParseResult, type TokenRegistry, type TokenRegistryMeta, type TokenUsageSummary, type UnsupportedStyleReason, type UsageChildContentFact, type UsageComponentFact, type UsageFact, type UsageImportFact, type UsageInlineStyleFact, type UsageNodeFact, type UsagePropResolvedFact, type UsageTextChildFact, aiMetadataSchema, analysisLimitsV1Schema, analysisObligationsDigestV1, analysisPlanDigestV1, analysisPlanIdFromDigest, analysisPlanIdSchema, analysisPlanIdStringSchema, analysisPlanInputV1Schema, analysisPlanV1Schema, analysisRegionV1Schema, analyzeComposition, artifactContentHash, asComponentId, assertPortableRegistryPath, blockDefinitionSchema, budgetBar, buildAgentFormat, buildAnalysisPlanV1, buildComponentKey, buildRegistryInstallPlan, buildRegistryInstallReceipt, buildSpacingTokenLookup, bundleArtifactMetadataSchema, bundleComponentShardSchema, bundleManifestComponentEntrySchema, bundleManifestSchema, bundleSchemaVersionSchema, bundleTargetSchema, bundleTokenFileSchema, calculateDeltaE, canonicalBridgeContractMappings, canonicalBridgeIdentityBindings, canonicalBridgeIdentitySources, canonicalDirectionConflictsTarget, canonicalFactConflictV1Schema, canonicalFactConflictValueV1Schema, canonicalFactIntegrityV1Schema, canonicalJson, canonicalPreimage, capConfiguredSeverity, catalogFixtureA, catalogFixtureAContractPayload, catalogFixtureATokensDtcg, clampMaxPasses, classifyComplexity, classifyIdentity, collectRegistryInstallDependencies, collidingRecordDiagnostic, collidingRecordDiagnostics, colorSimilarity, compareByVocabularyRank, compareColors, compareNumericValues, compareStyleValue, compareStyles, compareStylesWithTokens, compileBlock, compileComponentFacts, compileEffectiveGovernanceInputs, compileFragment, compileGlobalGovernanceFacts, componentContractSchema, componentId, componentRelationSchema, compositionAuthoringEntrySchema, compositionMetadataSchema, compositionPatternSchema, configDeclarationForDiagnostics, configRecordShape, configuredFindingSeverity, containsTailwindV4Theme, contractHash, contractTierRuleIds, contractTokenReferenceCensus, coverageArtifactDigestV1, coverageRegionV1Schema, coverageStateV1Schema, coverageSummaryV1Schema, customerDefaultRuleStates, defineBlock, defineConfig, defineFragment, deriveCoverageSummaryV1, describePolicyExclude, detectOrphanGovernanceScales, detectUnconsumedConfigKeys, detectUnmatchedPolicyExcludes, digestHexSchema, digestHexStringSchema, discoverComponents, dtcgTokenFileSchema, effectiveEvaluationWaiverV2Schema, emptyConformResult, emptyVocabularyConfigFile, evaluate, evaluateGovernanceIntegrity, evaluationInputDigestV2, evaluationInputV2Schema, evaluationReceiptDigestV1, evaluationReceiptIdFromDigest, evaluationReceiptIdSchema, evaluationReceiptIdStringSchema, evaluationReceiptMintInputV1Schema, evaluationReceiptV1Schema, evaluationResultDigestV2, evaluationResultV2Schema, excludeGlobToRegExp, expandRegistryComponentClosure, factId, familyDistance, figma, figmaPropMappingSchema, formatBytes, formatStampHeader, formatStampPin, formatStampVersionHash, formatTokenSummary, fragmentAnnotationsV3Schema, fragmentBanSchema, fragmentContractSchema, fragmentDefinitionSchema, fragmentDefinitionV2Schema, fragmentDefinitionV3BodySchema, fragmentDefinitionV3Schema, fragmentDesignV3Schema, fragmentDontExampleV3Schema, fragmentGeneratedSchema, fragmentGuidanceV3Schema, fragmentMatrixV3Schema, fragmentMetaSchema, fragmentMetaV3Schema, fragmentPreviewV3Schema, fragmentProvenanceSchema, fragmentSourceValues, fragmentStateV3Schema, fragmentUsageSchema, fragmentVariantSchema, fragmentsConfigSchema, fragmentsPresetRuleStates, gatesCi, generateCSSCustomProperties, generateFigmaVariables, generateSCSSVariables, generateTailwindConfig, getComplianceBadge, governedFragmentDefinitionSchema, hasEffectiveComponentVocabulary, hash64Hex, hexToRgb, hygieneTierRuleIds, indexComponentIdentityUsage, inferTokenCategory, inferTokenGroup, isApprovedContractTokenNames, isColorLike, isCompositionPattern, isContractFile, isContractTierRule, isDTCGFile, isDenyEligible, isEffectiveCanonicalSource, isEnforceableHtmlEquivalent, isFigmaPropMapping, isPortableRepoPath, isRawHtmlAdvisoryTier, isReactComponent, isRuleFamilyId, lowerCompositionContract, makeA11yNameRequiredFact, makeCanonicalCandidateFact, makeCanonicalMappingFact, makeCanonicalReplacementFact, makeClassNameDynamicFact, makeClassNameLiteralFact, makeComponentCapabilityFact, makeComponentDefinitionFact, makeComponentIdentityFact, makeComponentMetadataFact, makeContractTokenFact, makeFinding, makeJsxComponentPreferredFact, makeJsxImportPathPreferredFact, makeJsxInlineStyleForbiddenRawFact, makeJsxUnknownPropsForbiddenFact, makePropMetadataFact, makePropValueAvoidedFact, makePropValueForbiddenFact, makeScaleFact, makeScaleValueFact, makeStructuralConfidenceFact, makeStyleCssVarsMustBeDefinedFact, makeStyleDeclarationFact, makeStyleFontSizeScaleFact, makeStylePropertyScaleFact, makeStyleRawColorForbiddenFact, makeStyleUnsupportedFact, makeTailwindClassFact, makeTailwindPaletteAllowFact, makeTailwindPaletteDenyFact, makeTailwindTokenResolvedFact, makeTailwindUnknownClassEnabledFact, makeThemeDeclarationFact, makeTokenDefinitionFact, makeUsageChildContentFact, makeUsageComponentFact, makeUsageImportFact, makeUsageInlineStyleFact, makeUsageNodeFact, makeUsagePropResolvedFact, makeUsageTextChildFact, matchPolicyExclude, matchesGlob, mcpBlockSchema, mcpCapabilitySchema, mcpComponentExampleSchema, mcpComponentGuidanceSchema, mcpComponentMetadataSchema, mcpComponentPropSchema, mcpComponentRelationSchema, mcpComponentSchema, mcpCompoundChildSchema, mcpGuidancePatternSchema, mcpPerformanceDataSchema, mcpPerformanceImportSchema, mcpPerformanceSummarySchema, mcpSnapshotMetadataSchema, mcpSnapshotSchema, mcpSnapshotSchemaVersionSchema, mcpSourceTypeSchema, mcpTokenDataSchema, mcpTokenSchema, mintEvaluationReceiptId, nearestByDeltaE, nearestSignedScaleValue, normalizeAnalysisPlanInputV1, normalizeCanonicalFactIntegrityV1, normalizeColor, normalizeConfigPath, normalizeExcludePath, normalizePolicyExcludes, normalizeRegistryRepoPath, normalizeRepositoryBindingKeyV1, normalizeStyleValue, normalizeToV1, normalizeTokenGroupComment, normalizeTokenValue, overriddenRecordSeverityDiagnostic, parseAnalysisPlanId, parseAnalysisPlanV1, parseColor, parseColorToRgb, parseComponentContract, parseContractStamp, parseCssTokens, parseDtcgTokens as parseDTCGFile, parseDesignTokenContent, parseDigestHex, parseDtcgTokens, parseEvaluationReceiptId, parseEvaluationReceiptV1, parseRgb, parseScssTokens, parseScssVariables, parseTailwindV4Theme, parseTokenFile, parseTokens, policyExcludeMatchesPath, policyExcludeSchema, portableRepoPathError, projectCanonicalDirectionConflicts, projectSupersededImportPathPreferences, propAnnotationSchema, propDefinitionSchema, proveCompliant, proveIssueCount, providerProofDigestV1, providerProofV1Schema, readRuleConfig, repositoryBindingDigestV1, repositoryBindingKeyV1Schema, resolveCanonicalForAriaRole, resolveCanonicalForRawHtml, resolveConfiguredAppPath, resolveDesignTokenValue, resolveFigmaMapping, resolvePerformanceConfig, resolveProveVerdict, resolveRegistryComponentId, resolveRegistryInstallSelection, resolveRegistryInstallSources, resolveSpacingValue, resolveTokenValue, rgbToHex, ruleA11yRequiredAccessibleName, ruleA11yStandard, ruleComponentsForbiddenPropValue, ruleComponentsPreferLibrary, ruleComponentsShadowComponent, ruleComponentsUnknownProp, ruleFamilyMembers, ruleJsxPreferredComponent, ruleJsxPreferredImportPath, rulePropsInvalidValue, ruleStylesNoRawColor, ruleStylesNoRawDimensions, ruleStylesNoRawSpacing, ruleStylesNoRawTypography, ruleTailwindArbitraryColor, ruleTailwindArbitrarySpacing, ruleTailwindForbiddenPalette, ruleTailwindOffScaleSpacingToken, ruleTailwindRawColorViaToken, ruleTailwindUnknownClass, ruleThemeNoThemeCoupledLiteral, ruleTokensRequireDualFallback, runRules, serializeContractStamp, sha256Hex, sourceToRegistryTargetPath, tierFor, tokenIncludesFromConfig, topologyBase, vocabularyRank };
|
|
14547
|
+
export { type A11yNameRequiredFact, AGENT_CONTEXT_RELATIVE_PATH, ANALYSIS_LIMIT_CEILINGS_V1, ANALYSIS_PLAN_MAX_CAPABILITIES_V1, ANALYSIS_PLAN_MAX_DIALECTS_PER_REGION_V1, ANALYSIS_PLAN_MAX_REGIONS_V1, APPROVED_CONTRACT_TOKEN_MAX_NAMES, APPROVED_CONTRACT_TOKEN_MAX_NAME_LENGTH, AgentFormat, type AnalysisLimitsV1, type AnalysisPlanId, type AnalysisPlanInputV1, type AnalysisPlanV1, type AnalysisRegionV1, BLOCKING_RULE_ALLOWLIST, BRAND, BlockDefinition, type Brand, type BuildAgentFormatInput, type BuildRegistryInstallPlanInput, type BundleArtifactMetadata, type BundleComponentShard, type BundleManifest, type BundleManifestComponentEntry, type BundleSchemaVersion, type BundleTarget, type BundleTokenFile, CANONICAL_FACT_MAX_CONFLICTS_V1, CANONICAL_FACT_MAX_PROVENANCE_PER_VALUE_V1, CANONICAL_FACT_MAX_VALUES_PER_CONFLICT_V1, CATALOG_FIXTURE_A_FCID, type CSSGeneratorOptions, type CanonicalBridgeIdentityBinding, CanonicalBridgeV1, type CanonicalCandidateFact, type CanonicalDirectionConflict, type CanonicalFactConflictV1, type CanonicalFactConflictValueV1, type CanonicalFactIntegrityV1, Finding as CanonicalFinding, type CanonicalIdentityReference, type CanonicalMappingFact, type CanonicalReplacementFact, CanonicalSource, type CheckedSpacingValue, type ClassNameDynamicFact, type ClassNameDynamicReason, type ClassNameFact, type ClassNameLiteralFact, type ClassNameOrigin, type ClassifyIdentityInput, type CompileEffectiveGovernanceInputsOptions, CompiledBlock, type CompiledContractOutput, CompiledFragment, type ComplexityTier, type ComponentCapabilityFact, type ComponentContract, type ComponentDefinitionFact, type ComponentDefinitionRenderRoot, type ComponentFactInput, type ComponentId, type ComponentIdentityFact, type ComponentIdentityUsage, type ComponentKeyInput, type ComponentLevelFact, type ComponentMetadataFact, type CompositionAnalysis, type CompositionAuthoringEntry, type CompositionChildSelector, type CompositionConstraint, type CompositionGuideline, type CompositionPattern, type CompositionRegionSelector, type CompositionSuggestion, type CompositionWarning, type ConformChange, type ConformComponentMapping, type ConformConfidence, type ConformCoverage, type ConformInput, type ConformLocation, type ConformPropMapping, type ConformResult, type ConformSuggestion, type ConformToken, type ConformUnresolved, ContractCanonicalMappingInput, ContractCatalogInput, ContractDomain, ContractPreimage, type ContractStampPin, type ContractStampRecord, type ContractTokenReferenceCensus, type CoverageRegionV1, type CoverageStateV1, type CoverageSummaryV1, CoverageValidationErrorV1, DEFAULTS, DEFAULT_ENHANCED_STYLE_PROPERTIES, DEFAULT_STYLE_PROPERTIES, type DTCGColorValue, type DTCGDimensionValue, type DTCGGroup, type DTCGToken, type DTCGTokenFile, type DTCGTokenType, type Defaults, type DeltaEMatch, type DesignSystemContext, type DesignToken, type DesignTokenParseOptions, type DigestHex, type DiscoverComponentsOptions, EFFECTIVE_GOVERNANCE_INPUTS_SCHEMA, EMPTY_VOCABULARY_MESSAGE, EVALUATION_MAX_FINDINGS_V2, EVALUATION_MAX_MAP_ENTRIES_V2, EVALUATION_MAX_POLICY_RULES_V2, EVALUATION_MAX_REASON_CODES_V2, EVALUATION_MAX_WAIVERS_V2, EVALUATION_MAX_WAIVER_MATCHES_V2, EVALUATION_RECEIPT_STRING_MAX_BYTES_V1, EVALUATOR_VERSION, EVALUATOR_VERSION_V2, type EffectiveEvaluationWaiverV2, type EffectiveGovernanceInputs, type EffectiveGovernanceInputsSourceState, type EffectivePolicy, type EffectiveRulePolicy, type EnhancedStyleComparisonResult, type EnhancedStyleDiffItem, type EvaluatedFinding, type EvaluationAuthorityV1, type EvaluationBaseline, type EvaluationContractInput, type EvaluationEvidence, type EvaluationEvidenceTrustV1, type EvaluationFindingInput, type EvaluationFindingState, type EvaluationInput, type EvaluationInputV2, type EvaluationIntegrityInput, type EvaluationIntegrityInputV2, type EvaluationMappingTrust, type EvaluationReason, type EvaluationReasonV2, type EvaluationReceiptId, type EvaluationReceiptMintInputV1, type EvaluationReceiptSemanticV1, type EvaluationReceiptV1, type EvaluationResult, type EvaluationResultV2, type EvaluationScope, type EvaluationSourceTrust, type EvaluationTrust, type EvaluationVerdict, type EvaluationWaiver, EvidenceGrade, type ExternalIdentityReference, FRAGMENTS_INTERNAL_RULE_IDS, FRAGMENT_V3_SCHEMA_URL, type Fact, type FactConflict, type FactEvidence, type FactId, FactIndex, type FactKind, type FactLocation, type FactOfKind, FigmaBooleanMapping, FigmaChildrenMapping, FigmaEnumMapping, FigmaInstanceMapping, FigmaStringMapping, FigmaTextContentMapping, type FigmaVariable, type FigmaVariableCollection, Finding, FindingFix, type FindingV2, FragmentAnnotationsV3, FragmentComponent, FragmentDefinition, FragmentDefinitionV2, FragmentDefinitionV3, FragmentDefinitionV3Body, FragmentDesignV3, FragmentDontExampleV3, FragmentGuidanceV3, FragmentMatrixV3, FragmentMetaV3, FragmentPreviewV3, FragmentStateV3, FragmentsConfig, Severity as FuiSeverity, GovernanceConfig, type GovernanceIntegrityFamily, type GovernanceIntegrityFamilyId, type GovernanceIntegrityInput, type GovernanceIntegrityRoster, type GovernanceIntegrityStatus, type GovernanceIntegrityVerdict, GovernanceSeverity, GovernedFragmentDefinition, type IdentityClassification, type IdentityConfidence, type IdentityDecision, type IdentityFact, type IdentityState, type InertConfigDiagnostic, type InertConfigDiagnosticCode, type InertConfigDiagnosticKind, type InferProps, type JsxComponentPreferredFact, type JsxImportPathPreferredFact, type JsxInlineStyleForbiddenRawFact, type JsxUnknownPropsForbiddenFact, LEGACY_EVALUATOR_VERSION_V2, type LocalIdentityReference, type McpBlock, type McpCapability, type McpComponent, type McpComponentExample, type McpComponentGuidance, type McpComponentMetadata, type McpComponentProp, type McpComponentRelation, type McpCompoundChild, type McpGuidancePattern, type McpPerformanceData, type McpPerformanceImport, type McpPerformanceSummary, type McpSnapshot, type McpSnapshotMetadata, type McpSnapshotSchemaVersion, type McpSourceType, type McpToken, type McpTokenData, type NearestByDeltaEOptions, type NormalizedStyleMap, type NormalizedToken, PRESET_NAMES, PROVE_DEFAULT_MAX_PASSES, PROVE_MAX_PASSES, PROVIDER_ID_MAX_BYTES_V1, type ParseTokensOptions, type ParsedToken, type PerformanceData as PerfData, type PerformanceSummary as PerfSummary, type PerformanceBudgets, type PerformanceConfig, type PolicyExclude, type PolicyExcludeInput, type PolicyFact, type PresetRuleState, PropAnnotation, type PropMetadataFact, type PropValueAvoidedFact, type PropValueForbiddenFact, type ProveCallbacks, type ProveLoopResult, type ProveOptions, type ProvePass, type ProvePassSampling, type ProveResidual, type ProveSample, type ProveSamplerArgs, type ProveVerdict, type ProviderProofSemanticV1, type ProviderProofV1, RAW_HTML_ADVISORY_TAGS, RAW_HTML_CANONICAL_TAGS, RAW_HTML_INPUT_TYPE_CANONICALS, RAW_HTML_ROLE_CANONICALS, REPOSITORY_BINDING_ID_MAX_BYTES_V1, type RGB, type RGBA, RULES, RULE_FAMILY_IDS, RULE_FAMILY_MEMBERS, RULE_TIER, type RawHtmlCanonicalMatch, type RawHtmlPrecisionTier, RegistryArtifact, RegistryDependency, RegistryFile, type RegistryInstallPlan, RegistryInstallReceipt, type RegistryInstallSelection, type RegistryInstallSelectionInput, type RegistryInstallSourceFile, type RegistryInstallSources, type RegistryInstallSourcesInput, RegistryManifest, type RegistryWritePlan, RelationshipType, type RepositoryBindingKeyV1, type RepositoryBindingKeyV1Input, type ResolvedDTCGToken, ResolvedGovernedFragmentDefinition, type ResolvedIdentityRenderRoot, type ResolvedIntrinsicIdentityRoot, type Rule, type RuleConfigView, type RuleFn, type RuleTier, type SCSSGeneratorOptions, type ScaleFact, type ScaleValueFact, Severity, type SpacingResolutionScale, type SpacingTokenLookup, type StructuralConfidenceFact, type StyleComparisonOptions, type StyleComparisonResult, type StyleCssVarsMustBeDefinedFact, type StyleDeclarationFact, type StyleDiffItem, type StyleFontSizeScaleFact, type StylePropertyScaleFact, type StyleRawColorForbiddenFact, type StyleUnsupportedFact, type StyleValueProvenance, type SupersededImportPathPreference, type SuppressionDirectiveFact, type TailwindClassFact, type TailwindModifier, type TailwindModifierKind, type TailwindPaletteAllowFact, type TailwindPaletteDenyFact, type TailwindResolutionSource, type TailwindResolvedKind, type TailwindResolvedValue, type TailwindTokenResolvedFact, type TailwindUnknownClassEnabledFact, type TailwindValue, type ThemeDeclarationFact, type ThemeParserResult, type TokenCatalog, type TokenCatalogDefinition, type TokenCatalogDiagnostic, type TokenCatalogLocation, type TokenCatalogReference, type TokenCatalogSourceState, type TokenCategory, TokenConfig, type TokenDefinitionFact, type TokenFix, type TokenFormat, type TokenLookup, type TokenMatchRequest, type TokenMatchResult, type TokenParseError, type TokenParseOutput, type TokenParseResult, type TokenRegistry, type TokenRegistryMeta, type TokenUsageSummary, type UnsupportedStyleReason, type UsageChildContentFact, type UsageComponentFact, type UsageFact, type UsageImportFact, type UsageInlineStyleFact, type UsageNodeFact, type UsagePropResolvedFact, type UsageTextChildFact, aiMetadataSchema, analysisLimitsV1Schema, analysisObligationsDigestV1, analysisPlanDigestV1, analysisPlanIdFromDigest, analysisPlanIdSchema, analysisPlanIdStringSchema, analysisPlanInputV1Schema, analysisPlanV1Schema, analysisRegionV1Schema, analyzeComposition, artifactContentHash, asComponentId, assertPortableRegistryPath, blockDefinitionSchema, budgetBar, buildAgentFormat, buildAnalysisPlanV1, buildComponentKey, buildRegistryInstallPlan, buildRegistryInstallReceipt, buildSpacingTokenLookup, bundleArtifactMetadataSchema, bundleComponentShardSchema, bundleManifestComponentEntrySchema, bundleManifestSchema, bundleSchemaVersionSchema, bundleTargetSchema, bundleTokenFileSchema, calculateDeltaE, canonicalBridgeContractMappings, canonicalBridgeIdentityBindings, canonicalBridgeIdentitySources, canonicalDirectionConflictsTarget, canonicalFactConflictV1Schema, canonicalFactConflictValueV1Schema, canonicalFactIntegrityV1Schema, canonicalJson, canonicalPreimage, canonicalSourceContainsFile, canonicalSourceIncludesExport, capConfiguredSeverity, catalogFixtureA, catalogFixtureAContractPayload, catalogFixtureATokensDtcg, clampMaxPasses, classifyComplexity, classifyIdentity, collectRegistryInstallDependencies, collidingRecordDiagnostic, collidingRecordDiagnostics, colorSimilarity, compareByVocabularyRank, compareColors, compareNumericValues, compareStyleValue, compareStyles, compareStylesWithTokens, compileBlock, compileComponentFacts, compileEffectiveGovernanceInputs, compileFragment, compileGlobalGovernanceFacts, componentContractSchema, componentId, componentRelationSchema, compositionAuthoringEntrySchema, compositionMetadataSchema, compositionPatternSchema, configDeclarationForDiagnostics, configRecordShape, configuredFindingSeverity, containsTailwindV4Theme, contractHash, contractTierRuleIds, contractTokenReferenceCensus, coverageArtifactDigestV1, coverageRegionV1Schema, coverageStateV1Schema, coverageSummaryV1Schema, customerDefaultRuleStates, defineBlock, defineConfig, defineFragment, deriveCoverageSummaryV1, describePolicyExclude, detectOrphanGovernanceScales, detectUnconsumedConfigKeys, detectUnmatchedPolicyExcludes, digestHexSchema, digestHexStringSchema, discoverComponents, dtcgTokenFileSchema, effectiveEvaluationWaiverV2Schema, emptyConformResult, emptyVocabularyConfigFile, evaluate, evaluateGovernanceIntegrity, evaluationInputDigestV2, evaluationInputV2Schema, evaluationReceiptDigestV1, evaluationReceiptIdFromDigest, evaluationReceiptIdSchema, evaluationReceiptIdStringSchema, evaluationReceiptMintInputV1Schema, evaluationReceiptV1Schema, evaluationResultDigestV2, evaluationResultV2Schema, excludeGlobToRegExp, expandRegistryComponentClosure, factId, familyDistance, figma, figmaPropMappingSchema, formatBytes, formatStampHeader, formatStampPin, formatStampVersionHash, formatTokenSummary, fragmentAnnotationsV3Schema, fragmentBanSchema, fragmentContractSchema, fragmentDefinitionSchema, fragmentDefinitionV2Schema, fragmentDefinitionV3BodySchema, fragmentDefinitionV3Schema, fragmentDesignV3Schema, fragmentDontExampleV3Schema, fragmentGeneratedSchema, fragmentGuidanceV3Schema, fragmentMatrixV3Schema, fragmentMetaSchema, fragmentMetaV3Schema, fragmentPreviewV3Schema, fragmentProvenanceSchema, fragmentSourceValues, fragmentStateV3Schema, fragmentUsageSchema, fragmentVariantSchema, fragmentsConfigSchema, fragmentsPresetRuleStates, gatesCi, generateCSSCustomProperties, generateFigmaVariables, generateSCSSVariables, generateTailwindConfig, getComplianceBadge, governedFragmentDefinitionSchema, hasEffectiveComponentVocabulary, hash64Hex, hexToRgb, hygieneTierRuleIds, indexComponentIdentityUsage, inferTokenCategory, inferTokenGroup, isApprovedContractTokenNames, isCanonicalSourceDefinition, isColorLike, isCompositionPattern, isContractFile, isContractTierRule, isDTCGFile, isDenyEligible, isEffectiveCanonicalSource, isEnforceableHtmlEquivalent, isFigmaPropMapping, isPortableRepoPath, isRawHtmlAdvisoryTier, isReactComponent, isRuleFamilyId, lowerCompositionContract, makeA11yNameRequiredFact, makeCanonicalCandidateFact, makeCanonicalMappingFact, makeCanonicalReplacementFact, makeClassNameDynamicFact, makeClassNameLiteralFact, makeComponentCapabilityFact, makeComponentDefinitionFact, makeComponentIdentityFact, makeComponentMetadataFact, makeContractTokenFact, makeFinding, makeJsxComponentPreferredFact, makeJsxImportPathPreferredFact, makeJsxInlineStyleForbiddenRawFact, makeJsxUnknownPropsForbiddenFact, makePropMetadataFact, makePropValueAvoidedFact, makePropValueForbiddenFact, makeScaleFact, makeScaleValueFact, makeStructuralConfidenceFact, makeStyleCssVarsMustBeDefinedFact, makeStyleDeclarationFact, makeStyleFontSizeScaleFact, makeStylePropertyScaleFact, makeStyleRawColorForbiddenFact, makeStyleUnsupportedFact, makeTailwindClassFact, makeTailwindPaletteAllowFact, makeTailwindPaletteDenyFact, makeTailwindTokenResolvedFact, makeTailwindUnknownClassEnabledFact, makeThemeDeclarationFact, makeTokenDefinitionFact, makeUsageChildContentFact, makeUsageComponentFact, makeUsageImportFact, makeUsageInlineStyleFact, makeUsageNodeFact, makeUsagePropResolvedFact, makeUsageTextChildFact, matchPolicyExclude, matchesGlob, mcpBlockSchema, mcpCapabilitySchema, mcpComponentExampleSchema, mcpComponentGuidanceSchema, mcpComponentMetadataSchema, mcpComponentPropSchema, mcpComponentRelationSchema, mcpComponentSchema, mcpCompoundChildSchema, mcpGuidancePatternSchema, mcpPerformanceDataSchema, mcpPerformanceImportSchema, mcpPerformanceSummarySchema, mcpSnapshotMetadataSchema, mcpSnapshotSchema, mcpSnapshotSchemaVersionSchema, mcpSourceTypeSchema, mcpTokenDataSchema, mcpTokenSchema, mintEvaluationReceiptId, nearestByDeltaE, nearestSignedScaleValue, normalizeAnalysisPlanInputV1, normalizeCanonicalFactIntegrityV1, normalizeColor, normalizeConfigPath, normalizeExcludePath, normalizePolicyExcludes, normalizeRegistryRepoPath, normalizeRepositoryBindingKeyV1, normalizeStyleValue, normalizeToV1, normalizeTokenGroupComment, normalizeTokenValue, overriddenRecordSeverityDiagnostic, parseAnalysisPlanId, parseAnalysisPlanV1, parseColor, parseColorToRgb, parseComponentContract, parseContractStamp, parseCssTokens, parseDtcgTokens as parseDTCGFile, parseDesignTokenContent, parseDigestHex, parseDtcgTokens, parseEvaluationReceiptId, parseEvaluationReceiptV1, parseRgb, parseScssTokens, parseScssVariables, parseTailwindV4Theme, parseTokenFile, parseTokens, policyExcludeMatchesPath, policyExcludeSchema, portableRepoPathError, projectCanonicalDirectionConflicts, projectSupersededImportPathPreferences, propAnnotationSchema, propDefinitionSchema, proveCompliant, proveIssueCount, providerProofDigestV1, providerProofV1Schema, readRuleConfig, repositoryBindingDigestV1, repositoryBindingKeyV1Schema, resolveCanonicalForAriaRole, resolveCanonicalForRawHtml, resolveConfiguredAppPath, resolveDesignTokenValue, resolveFigmaMapping, resolvePerformanceConfig, resolveProveVerdict, resolveRegistryComponentId, resolveRegistryInstallSelection, resolveRegistryInstallSources, resolveSpacingValue, resolveTokenValue, rgbToHex, ruleA11yRequiredAccessibleName, ruleA11yStandard, ruleComponentsForbiddenPropValue, ruleComponentsPreferLibrary, ruleComponentsShadowComponent, ruleComponentsUnknownProp, ruleFamilyMembers, ruleJsxPreferredComponent, ruleJsxPreferredImportPath, rulePropsInvalidValue, ruleStylesNoRawColor, ruleStylesNoRawDimensions, ruleStylesNoRawSpacing, ruleStylesNoRawTypography, ruleTailwindArbitraryColor, ruleTailwindArbitrarySpacing, ruleTailwindForbiddenPalette, ruleTailwindOffScaleSpacingToken, ruleTailwindRawColorViaToken, ruleTailwindUnknownClass, ruleThemeNoThemeCoupledLiteral, ruleTokensRequireDualFallback, runRules, serializeContractStamp, sha256Hex, sourceToRegistryTargetPath, tierFor, tokenIncludesFromConfig, topologyBase, vocabularyRank };
|
package/dist/index.js
CHANGED
|
@@ -201,7 +201,7 @@ import {
|
|
|
201
201
|
suppressionDirectiveSchema,
|
|
202
202
|
validatorResultSchema,
|
|
203
203
|
violationSchema
|
|
204
|
-
} from "./chunk-
|
|
204
|
+
} from "./chunk-QPOKQ5H6.js";
|
|
205
205
|
import {
|
|
206
206
|
isPortableRepoPath,
|
|
207
207
|
normalizeConfigPath,
|
|
@@ -5260,6 +5260,56 @@ function isEnforceableHtmlEquivalent(args) {
|
|
|
5260
5260
|
return builtIn !== null && builtIn.canonical === args.canonical;
|
|
5261
5261
|
}
|
|
5262
5262
|
|
|
5263
|
+
// src/identity/usage.ts
|
|
5264
|
+
function indexComponentIdentityUsage(ix) {
|
|
5265
|
+
const nodesById = new Map(ix.byKind("usage_node").map((node) => [node.id, node]));
|
|
5266
|
+
const definitions = new Set(
|
|
5267
|
+
ix.byKind("component_definition").map((definition) => definition.componentKey)
|
|
5268
|
+
);
|
|
5269
|
+
const nodesByComponent = /* @__PURE__ */ new Map();
|
|
5270
|
+
for (const usage of ix.byKind("usage_component")) {
|
|
5271
|
+
const node = nodesById.get(usage.nodeId);
|
|
5272
|
+
if (!node) continue;
|
|
5273
|
+
const componentKey = usage.definitionKey && definitions.has(usage.definitionKey) ? usage.definitionKey : String(usage.componentId);
|
|
5274
|
+
const nodes = nodesByComponent.get(componentKey) ?? /* @__PURE__ */ new Map();
|
|
5275
|
+
nodes.set(node.id, node);
|
|
5276
|
+
nodesByComponent.set(componentKey, nodes);
|
|
5277
|
+
}
|
|
5278
|
+
return new Map(
|
|
5279
|
+
[...nodesByComponent].map(([componentKey, nodesByIdForComponent]) => {
|
|
5280
|
+
const nodes = [...nodesByIdForComponent.values()];
|
|
5281
|
+
return [
|
|
5282
|
+
componentKey,
|
|
5283
|
+
{
|
|
5284
|
+
usageCount: nodes.length,
|
|
5285
|
+
blastRadius: new Set(nodes.map((node) => node.file)).size,
|
|
5286
|
+
nodes
|
|
5287
|
+
}
|
|
5288
|
+
];
|
|
5289
|
+
})
|
|
5290
|
+
);
|
|
5291
|
+
}
|
|
5292
|
+
|
|
5293
|
+
// src/canonical-source.ts
|
|
5294
|
+
function canonicalSourceIncludesExport(source, name) {
|
|
5295
|
+
const role = name.split(".").at(-1) ?? name;
|
|
5296
|
+
const matches = (names) => names.includes(name) || names.includes(role);
|
|
5297
|
+
return !matches(source.exclude ?? []) && (source.include === void 0 || matches(source.include));
|
|
5298
|
+
}
|
|
5299
|
+
function canonicalSourceContainsFile(source, file) {
|
|
5300
|
+
const root = source.kind === "directory" ? source.path : source.kind === "registry" ? source.installPath : source.implementationPath;
|
|
5301
|
+
if (!root) return false;
|
|
5302
|
+
const normalize = (value) => value.replace(/\\/g, "/").replace(/^\.\//, "").replace(/\/$/, "");
|
|
5303
|
+
const normalizedRoot = normalize(root);
|
|
5304
|
+
const normalizedFile = normalize(file);
|
|
5305
|
+
return normalizedRoot === "." || normalizedFile === normalizedRoot || normalizedFile.startsWith(`${normalizedRoot}/`);
|
|
5306
|
+
}
|
|
5307
|
+
function isCanonicalSourceDefinition(file, exportName, sources) {
|
|
5308
|
+
return sources.some(
|
|
5309
|
+
(source) => canonicalSourceContainsFile(source, file) && canonicalSourceIncludesExport(source, exportName)
|
|
5310
|
+
);
|
|
5311
|
+
}
|
|
5312
|
+
|
|
5263
5313
|
// src/canonical-direction.ts
|
|
5264
5314
|
function projectCanonicalDirectionConflicts(ix, canonicalSources) {
|
|
5265
5315
|
const npmSources = canonicalSources.filter(
|
|
@@ -5493,6 +5543,11 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5493
5543
|
const configuredSources = canonicalSourcesFromPolicy(policy.options?.canonicalSources);
|
|
5494
5544
|
const conflicts = projectCanonicalDirectionConflicts(ix, configuredSources);
|
|
5495
5545
|
const sources = configuredSources.map((source) => suppressConflictedExports(source, conflicts));
|
|
5546
|
+
const approvedLocalDefinitionKeys = Array.isArray(policy.options?.approvedLocalDefinitionKeys) ? new Set(
|
|
5547
|
+
policy.options.approvedLocalDefinitionKeys.filter(
|
|
5548
|
+
(key) => typeof key === "string"
|
|
5549
|
+
)
|
|
5550
|
+
) : void 0;
|
|
5496
5551
|
const mappings = canonicalMappingsFromPolicy(policy.options?.canonicalMappings).filter(
|
|
5497
5552
|
(mapping) => !canonicalDirectionConflictsTarget(conflicts, mapping.importPath, mapping.name)
|
|
5498
5553
|
);
|
|
@@ -5502,12 +5557,33 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5502
5557
|
const textByNode = indexTextChildrenByNodeId(ix);
|
|
5503
5558
|
const classTokensByNode = indexClassTokensByNode(ix);
|
|
5504
5559
|
const reimplTargets = canonicalReimplTargets(sources, mappings);
|
|
5505
|
-
const canonicalDirectoryResolvedNodes = indexCanonicalDirectoryResolvedNodes(
|
|
5560
|
+
const canonicalDirectoryResolvedNodes = indexCanonicalDirectoryResolvedNodes(
|
|
5561
|
+
ix,
|
|
5562
|
+
sources,
|
|
5563
|
+
approvedLocalDefinitionKeys
|
|
5564
|
+
);
|
|
5506
5565
|
const shadowRenderRootNodeIds = ix.policy.ruleConfig("components/shadow-component")?.enabled === true ? indexShadowRenderRootNodeIds(ix) : /* @__PURE__ */ new Set();
|
|
5507
5566
|
const findings = [];
|
|
5508
5567
|
const seenImportFixes = /* @__PURE__ */ new Set();
|
|
5568
|
+
const canonicalIdentities = new Map(
|
|
5569
|
+
ix.byKind("component_identity").map((identity) => [identity.componentKey, identity.state === "canonical"])
|
|
5570
|
+
);
|
|
5571
|
+
const definitionsByFile = /* @__PURE__ */ new Map();
|
|
5572
|
+
for (const definition of ix.byKind("component_definition")) {
|
|
5573
|
+
const file = normalizePath(definition.file);
|
|
5574
|
+
const definitions = definitionsByFile.get(file) ?? [];
|
|
5575
|
+
definitions.push(definition);
|
|
5576
|
+
definitionsByFile.set(file, definitions);
|
|
5577
|
+
}
|
|
5509
5578
|
for (const node of ix.byKind("usage_node")) {
|
|
5510
|
-
if (
|
|
5579
|
+
if (isCanonicalSourceImplementation(
|
|
5580
|
+
node,
|
|
5581
|
+
sources,
|
|
5582
|
+
definitionsByFile,
|
|
5583
|
+
canonicalIdentities,
|
|
5584
|
+
approvedLocalDefinitionKeys
|
|
5585
|
+
))
|
|
5586
|
+
continue;
|
|
5511
5587
|
if (node.element.includes(".")) continue;
|
|
5512
5588
|
if (canonicalDirectoryResolvedNodes.has(node.id)) continue;
|
|
5513
5589
|
if (shadowRenderRootNodeIds.has(node.id)) continue;
|
|
@@ -5518,7 +5594,12 @@ function ruleComponentsPreferLibrary(ix) {
|
|
|
5518
5594
|
const nodeInputType = node.element === "input" ? readStaticStringProp(props, "type") : void 0;
|
|
5519
5595
|
const mapped = findMapping(node, nodeInputType, mappings);
|
|
5520
5596
|
if (mapped && imported && isMappedCanonicalImport(imported, mapped)) continue;
|
|
5521
|
-
if (imported && isCanonicalImport(
|
|
5597
|
+
if (imported && isCanonicalImport(
|
|
5598
|
+
imported,
|
|
5599
|
+
node.element,
|
|
5600
|
+
approvedLocalDefinitionKeys === void 0 ? sources : sources.filter((source) => source.kind !== "directory")
|
|
5601
|
+
))
|
|
5602
|
+
continue;
|
|
5522
5603
|
if (mapped) {
|
|
5523
5604
|
if (!shouldSuggestMapped(node, nodeInputType, imported, mapped)) continue;
|
|
5524
5605
|
const importPath = mapped.importPath;
|
|
@@ -6069,18 +6150,27 @@ function canonicalImportPath(source) {
|
|
|
6069
6150
|
if (source.kind === "registry") return source.importPath;
|
|
6070
6151
|
return void 0;
|
|
6071
6152
|
}
|
|
6072
|
-
function indexCanonicalDirectoryResolvedNodes(ix, sources) {
|
|
6153
|
+
function indexCanonicalDirectoryResolvedNodes(ix, sources, approvedLocalDefinitionKeys) {
|
|
6073
6154
|
const out = /* @__PURE__ */ new Set();
|
|
6074
|
-
const
|
|
6155
|
+
const directorySources = sources.filter(
|
|
6075
6156
|
(source) => source.kind === "directory"
|
|
6076
|
-
)
|
|
6077
|
-
if (
|
|
6078
|
-
|
|
6079
|
-
|
|
6157
|
+
);
|
|
6158
|
+
if (directorySources.length === 0) return out;
|
|
6159
|
+
const identities = new Map(
|
|
6160
|
+
ix.byKind("component_identity").map((identity) => [identity.componentKey, identity])
|
|
6161
|
+
);
|
|
6162
|
+
for (const [componentKey, usage] of indexComponentIdentityUsage(ix)) {
|
|
6163
|
+
if (approvedLocalDefinitionKeys !== void 0 && !approvedLocalDefinitionKeys.has(componentKey))
|
|
6164
|
+
continue;
|
|
6165
|
+
const identity = identities.get(componentKey);
|
|
6166
|
+
if (identity && identity.state !== "canonical") continue;
|
|
6167
|
+
const module = componentIdModule(componentKey);
|
|
6080
6168
|
if (module === void 0) continue;
|
|
6081
|
-
const
|
|
6082
|
-
if (
|
|
6083
|
-
|
|
6169
|
+
const exportName = componentKey.slice(componentKey.indexOf("#") + 1);
|
|
6170
|
+
if (directorySources.some(
|
|
6171
|
+
(source) => canonicalSourceContainsFile(source, module) && canonicalSourceIncludesExport(source, exportName)
|
|
6172
|
+
)) {
|
|
6173
|
+
for (const node of usage.nodes) out.add(node.id);
|
|
6084
6174
|
}
|
|
6085
6175
|
}
|
|
6086
6176
|
return out;
|
|
@@ -6089,24 +6179,23 @@ function componentIdModule(componentId2) {
|
|
|
6089
6179
|
const hash = componentId2.indexOf("#");
|
|
6090
6180
|
return hash > 0 ? componentId2.slice(0, hash) : void 0;
|
|
6091
6181
|
}
|
|
6092
|
-
function
|
|
6093
|
-
const
|
|
6182
|
+
function isCanonicalSourceImplementation(node, sources, definitionsByFile, canonicalIdentities, approvedLocalDefinitionKeys) {
|
|
6183
|
+
const definitions = definitionsByFile.get(normalizePath(node.file)) ?? [];
|
|
6094
6184
|
return sources.some((source) => {
|
|
6095
|
-
if (source
|
|
6096
|
-
|
|
6097
|
-
|
|
6098
|
-
|
|
6099
|
-
|
|
6100
|
-
|
|
6101
|
-
|
|
6102
|
-
|
|
6103
|
-
|
|
6104
|
-
return false;
|
|
6185
|
+
if (!canonicalSourceContainsFile(source, node.file)) return false;
|
|
6186
|
+
if (approvedLocalDefinitionKeys === void 0 && (source.kind !== "directory" || source.include === void 0 && !source.exclude?.length))
|
|
6187
|
+
return true;
|
|
6188
|
+
const owners = definitions.filter(
|
|
6189
|
+
(definition) => definition.location && locationContains(definition.location, node.location)
|
|
6190
|
+
);
|
|
6191
|
+
return owners.length > 0 && owners.every(
|
|
6192
|
+
(definition) => (approvedLocalDefinitionKeys === void 0 || approvedLocalDefinitionKeys.has(definition.componentKey)) && canonicalIdentities.get(definition.componentKey) !== false && canonicalSourceIncludesExport(source, definition.exportName)
|
|
6193
|
+
);
|
|
6105
6194
|
});
|
|
6106
6195
|
}
|
|
6107
|
-
function
|
|
6108
|
-
|
|
6109
|
-
return
|
|
6196
|
+
function locationContains(region, node) {
|
|
6197
|
+
if (region.endLine === void 0 || region.endColumn === void 0) return false;
|
|
6198
|
+
return (node.line > region.line || node.line === region.line && node.column >= region.column) && (node.line < region.endLine || node.line === region.endLine && node.column < region.endColumn);
|
|
6110
6199
|
}
|
|
6111
6200
|
function normalizePath(path) {
|
|
6112
6201
|
return path.replace(/\\/g, "/").replace(/^\.\//, "");
|
|
@@ -6115,33 +6204,6 @@ function isIdentifier(value) {
|
|
|
6115
6204
|
return /^[A-Za-z_$][\w$]*$/.test(value);
|
|
6116
6205
|
}
|
|
6117
6206
|
|
|
6118
|
-
// src/identity/usage.ts
|
|
6119
|
-
function indexComponentIdentityUsage(ix) {
|
|
6120
|
-
const nodesById = new Map(ix.byKind("usage_node").map((node) => [node.id, node]));
|
|
6121
|
-
const nodesByComponent = /* @__PURE__ */ new Map();
|
|
6122
|
-
for (const usage of ix.byKind("usage_component")) {
|
|
6123
|
-
const node = nodesById.get(usage.nodeId);
|
|
6124
|
-
if (!node) continue;
|
|
6125
|
-
const componentKey = String(usage.componentId);
|
|
6126
|
-
const nodes = nodesByComponent.get(componentKey) ?? /* @__PURE__ */ new Map();
|
|
6127
|
-
nodes.set(node.id, node);
|
|
6128
|
-
nodesByComponent.set(componentKey, nodes);
|
|
6129
|
-
}
|
|
6130
|
-
return new Map(
|
|
6131
|
-
[...nodesByComponent].map(([componentKey, nodesByIdForComponent]) => {
|
|
6132
|
-
const nodes = [...nodesByIdForComponent.values()];
|
|
6133
|
-
return [
|
|
6134
|
-
componentKey,
|
|
6135
|
-
{
|
|
6136
|
-
usageCount: nodes.length,
|
|
6137
|
-
blastRadius: new Set(nodes.map((node) => node.file)).size,
|
|
6138
|
-
nodes
|
|
6139
|
-
}
|
|
6140
|
-
];
|
|
6141
|
-
})
|
|
6142
|
-
);
|
|
6143
|
-
}
|
|
6144
|
-
|
|
6145
6207
|
// src/rules/components-shadow-component.ts
|
|
6146
6208
|
var RULE_ID4 = "components/shadow-component";
|
|
6147
6209
|
var RULE_VERSION4 = "1";
|
|
@@ -10883,8 +10945,9 @@ function coverageArtifactDigestV1(rawPlan, rawCoverage) {
|
|
|
10883
10945
|
}
|
|
10884
10946
|
|
|
10885
10947
|
// src/evaluation/types.ts
|
|
10886
|
-
var EVALUATOR_VERSION = "evaluation-kernel:v1";
|
|
10887
|
-
var EVALUATOR_VERSION_V2 = "evaluation-kernel:v2";
|
|
10948
|
+
var EVALUATOR_VERSION = "evaluation-kernel:v1.1";
|
|
10949
|
+
var EVALUATOR_VERSION_V2 = "evaluation-kernel:v2.1";
|
|
10950
|
+
var LEGACY_EVALUATOR_VERSION_V2 = "evaluation-kernel:v2";
|
|
10888
10951
|
|
|
10889
10952
|
// src/evaluation/receipt.ts
|
|
10890
10953
|
import { z as z10 } from "zod";
|
|
@@ -11484,7 +11547,7 @@ function evaluate2(input) {
|
|
|
11484
11547
|
function isEvaluationInputV2(input) {
|
|
11485
11548
|
return "schemaVersion" in input && input.schemaVersion === 2;
|
|
11486
11549
|
}
|
|
11487
|
-
function evaluateV1(input) {
|
|
11550
|
+
function evaluateV1(input, deriveCanonicalTrust = true) {
|
|
11488
11551
|
const reasons = /* @__PURE__ */ new Set();
|
|
11489
11552
|
let fcidVerified = "unavailable";
|
|
11490
11553
|
if (input.contract.state === "unpinned") {
|
|
@@ -11521,7 +11584,7 @@ function evaluateV1(input) {
|
|
|
11521
11584
|
activeWaivers.add(waiver.fingerprint);
|
|
11522
11585
|
}
|
|
11523
11586
|
}
|
|
11524
|
-
const evidence = evidenceFindings(input);
|
|
11587
|
+
const evidence = evidenceFindings(input, deriveCanonicalTrust);
|
|
11525
11588
|
const findings = [...groupByFingerprint(evidence).values()].map((rows) => {
|
|
11526
11589
|
const classified = rows.map((row) => classifyFinding(row, input, activeWaivers));
|
|
11527
11590
|
return classified.reduce(
|
|
@@ -11551,7 +11614,7 @@ function evaluateV1(input) {
|
|
|
11551
11614
|
warnPresent: evidence.some((finding) => finding.severity === "warn"),
|
|
11552
11615
|
gatingFindingsPresent: counts.blocked > 0
|
|
11553
11616
|
};
|
|
11554
|
-
const inputDigest = sha256Hex(canonicalPreimage(normalizeInputForDigest(input)));
|
|
11617
|
+
const inputDigest = sha256Hex(canonicalPreimage(normalizeInputForDigest(input, evidence)));
|
|
11555
11618
|
const partial = {
|
|
11556
11619
|
evaluatorVersion: EVALUATOR_VERSION,
|
|
11557
11620
|
verdict,
|
|
@@ -11586,7 +11649,7 @@ var V2_INTEGRITY_REASONS = /* @__PURE__ */ new Set([
|
|
|
11586
11649
|
var SUPPORTED_FACT_SCHEMA_VERSIONS_V2 = /* @__PURE__ */ new Set(["facts:v1"]);
|
|
11587
11650
|
var SUPPORTED_REACT_WEB_PROFILE_VERSIONS_V1 = /* @__PURE__ */ new Set(["1"]);
|
|
11588
11651
|
function evaluateV2(rawInput) {
|
|
11589
|
-
if (rawInput.evaluatorVersion !== EVALUATOR_VERSION_V2) {
|
|
11652
|
+
if (rawInput.evaluatorVersion !== EVALUATOR_VERSION_V2 && rawInput.evaluatorVersion !== LEGACY_EVALUATOR_VERSION_V2) {
|
|
11590
11653
|
throw new Error(`Unsupported evaluator version: ${rawInput.evaluatorVersion}`);
|
|
11591
11654
|
}
|
|
11592
11655
|
if (!SUPPORTED_FACT_SCHEMA_VERSIONS_V2.has(rawInput.factSchemaVersion)) {
|
|
@@ -11625,7 +11688,10 @@ function evaluateV2(rawInput) {
|
|
|
11625
11688
|
},
|
|
11626
11689
|
evaluatedAt: input.evaluatedAt
|
|
11627
11690
|
};
|
|
11628
|
-
const compatibilityResult = evaluateV1(
|
|
11691
|
+
const compatibilityResult = evaluateV1(
|
|
11692
|
+
compatibilityInput,
|
|
11693
|
+
input.evaluatorVersion === EVALUATOR_VERSION_V2
|
|
11694
|
+
);
|
|
11629
11695
|
const requiredCoverage = coverageSummary.requiredRegions === 0 ? "no_required_regions" : coverageSummary.requiredByState.analyzed === coverageSummary.requiredRegions ? "complete" : "incomplete";
|
|
11630
11696
|
const integrity = {
|
|
11631
11697
|
fcidVerified: compatibilityResult.integrity.fcidVerified === true,
|
|
@@ -11711,17 +11777,39 @@ function normalizeInputV2ForDigest(input, coverageSummary) {
|
|
|
11711
11777
|
evaluatorVersion: input.evaluatorVersion
|
|
11712
11778
|
};
|
|
11713
11779
|
}
|
|
11714
|
-
function evidenceFindings(input) {
|
|
11780
|
+
function evidenceFindings(input, deriveCanonicalTrust) {
|
|
11715
11781
|
if (input.evidence.kind === "findings") return [...input.evidence.findings];
|
|
11716
11782
|
const ruleConfig = readRuleConfig(input.evidence.facts);
|
|
11783
|
+
const hasContractTokens = input.evidence.facts.byKind("contract_token").length > 0;
|
|
11717
11784
|
return runRules(input.evidence.facts).map((finding) => ({
|
|
11718
11785
|
fingerprint: finding.fingerprint,
|
|
11719
11786
|
ruleId: finding.ruleId,
|
|
11720
11787
|
severity: severityLevel(configuredFindingSeverity(finding, ruleConfig)),
|
|
11721
11788
|
advisory: finding.attributes?.advisory === true,
|
|
11722
|
-
evidenceGrade: finding.evidenceGrade
|
|
11789
|
+
evidenceGrade: finding.evidenceGrade,
|
|
11790
|
+
// An explicit trust decision still wins, including unknown/unconfirmed.
|
|
11791
|
+
// Only findings derived here from canonical facts earn the fallback.
|
|
11792
|
+
...deriveCanonicalTrust ? {
|
|
11793
|
+
mappingTrust: input.trust?.mappings[finding.fingerprint] ?? canonicalFactMappingTrust(finding, hasContractTokens)
|
|
11794
|
+
} : {}
|
|
11723
11795
|
}));
|
|
11724
11796
|
}
|
|
11797
|
+
function canonicalFactMappingTrust(finding, hasContractTokens) {
|
|
11798
|
+
switch (finding.ruleId) {
|
|
11799
|
+
case "components/shadow-component":
|
|
11800
|
+
return finding.attributes?.confidence === "confirmed" && typeof finding.attributes.canonicalTarget === "string" && finding.attributes.canonicalTarget.length > 0 ? "confirmed" : void 0;
|
|
11801
|
+
case "components/prefer-library":
|
|
11802
|
+
return typeof finding.attributes?.suggestedComponent === "string" && finding.attributes.suggestedComponent.length > 0 ? "confirmed" : void 0;
|
|
11803
|
+
case "tokens/css-vars-must-be-defined":
|
|
11804
|
+
return hasContractTokens ? "confirmed" : void 0;
|
|
11805
|
+
case "tokens/upstream-drift":
|
|
11806
|
+
return finding.evidence.some(
|
|
11807
|
+
({ fact }) => fact.kind === "token_definition" && "role" in fact && fact.role === "upstream"
|
|
11808
|
+
) ? "confirmed" : void 0;
|
|
11809
|
+
default:
|
|
11810
|
+
return void 0;
|
|
11811
|
+
}
|
|
11812
|
+
}
|
|
11725
11813
|
var STATE_RANK = { blocked: 0, pending_cloud_trust: 1, advisory: 2 };
|
|
11726
11814
|
var SEVERITY_RANK2 = { error: 0, warn: 1, info: 2 };
|
|
11727
11815
|
function canonicalRow(finding) {
|
|
@@ -11845,12 +11933,12 @@ function mappingFact(finding, input) {
|
|
|
11845
11933
|
if (mapping === "unconfirmed") return ["mapping:unconfirmed", "negative"];
|
|
11846
11934
|
return ["mapping:unknown", "unknown"];
|
|
11847
11935
|
}
|
|
11848
|
-
function normalizeInputForDigest(input) {
|
|
11936
|
+
function normalizeInputForDigest(input, evidence) {
|
|
11849
11937
|
return {
|
|
11850
11938
|
schema: "evaluation-input:v1",
|
|
11851
11939
|
contract: input.contract,
|
|
11852
11940
|
scope: input.scope,
|
|
11853
|
-
evidence: canonicalRows(
|
|
11941
|
+
evidence: canonicalRows(evidence),
|
|
11854
11942
|
policy: input.policy,
|
|
11855
11943
|
baseline: input.baseline,
|
|
11856
11944
|
adoption: input.adoption,
|
|
@@ -11937,6 +12025,7 @@ export {
|
|
|
11937
12025
|
GOVERNANCE_TELEMETRY_FIELDS,
|
|
11938
12026
|
GOVERNANCE_TELEMETRY_SOURCE_DISCLOSURE,
|
|
11939
12027
|
GOVERNANCE_TELEMETRY_TOP_LEVEL_FIELDS,
|
|
12028
|
+
LEGACY_EVALUATOR_VERSION_V2,
|
|
11940
12029
|
OWNED_PACKAGE_IDENTITY_EPOCH,
|
|
11941
12030
|
OWNED_PACKAGE_IDENTITY_SOURCE_SHA256,
|
|
11942
12031
|
PRESET_NAMES,
|
|
@@ -12016,6 +12105,8 @@ export {
|
|
|
12016
12105
|
canonicalFactIntegrityV1Schema,
|
|
12017
12106
|
canonicalJson,
|
|
12018
12107
|
canonicalPreimage,
|
|
12108
|
+
canonicalSourceContainsFile,
|
|
12109
|
+
canonicalSourceIncludesExport,
|
|
12019
12110
|
canonicalizeOwnedComponentId,
|
|
12020
12111
|
canonicalizeOwnedImport,
|
|
12021
12112
|
capConfiguredSeverity,
|
|
@@ -12170,6 +12261,7 @@ export {
|
|
|
12170
12261
|
inferTokenCategory,
|
|
12171
12262
|
inferTokenGroup,
|
|
12172
12263
|
isApprovedContractTokenNames,
|
|
12264
|
+
isCanonicalSourceDefinition,
|
|
12173
12265
|
isColorLike,
|
|
12174
12266
|
isCompositionPattern,
|
|
12175
12267
|
isContractFile,
|