Home / Function/ formattedMappings() — tailwindcss Function Reference

formattedMappings() — tailwindcss Function Reference

Architecture documentation for the formattedMappings() function in source-map.test.ts from the tailwindcss codebase.

Entity Profile

Dependency Diagram

graph TD
  e1431d4b_1885_1204_7955_59de26dd3eea["formattedMappings()"]
  483bc469_09cd_2782_6511_f5eb78cfc4c1["run()"]
  483bc469_09cd_2782_6511_f5eb78cfc4c1 -->|calls| e1431d4b_1885_1204_7955_59de26dd3eea
  d10c97e7_f102_49e0_8e10_f57a3a4179b6["formatRange()"]
  e1431d4b_1885_1204_7955_59de26dd3eea -->|calls| d10c97e7_f102_49e0_8e10_f57a3a4179b6
  style e1431d4b_1885_1204_7955_59de26dd3eea fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/source-maps/source-map.test.ts lines 92–130

function formattedMappings(map: RawSourceMap) {
  const smc = new SourceMapConsumer(map)
  const annotations: Record<
    number,
    {
      original: { start: [number, number]; end: [number, number] }
      generated: { start: [number, number]; end: [number, number] }
      source: string
    }
  > = {}

  smc.eachMapping((mapping) => {
    let annotation = (annotations[mapping.generatedLine] = annotations[mapping.generatedLine] || {
      ...mapping,

      original: {
        start: [mapping.originalLine, mapping.originalColumn],
        end: [mapping.originalLine, mapping.originalColumn],
      },

      generated: {
        start: [mapping.generatedLine, mapping.generatedColumn],
        end: [mapping.generatedLine, mapping.generatedColumn],
      },

      source: mapping.source,
    })

    annotation.generated.end[0] = mapping.generatedLine
    annotation.generated.end[1] = mapping.generatedColumn

    annotation.original.end[0] = mapping.originalLine!
    annotation.original.end[1] = mapping.originalColumn!
  })

  return Object.values(annotations).map((annotation) => {
    return `${annotation.source}: ${formatRange(annotation.generated)} <- ${formatRange(annotation.original)}`
  })
}

Subdomains

Called By

Frequently Asked Questions

What does formattedMappings() do?
formattedMappings() is a function in the tailwindcss codebase.
What does formattedMappings() call?
formattedMappings() calls 1 function(s): formatRange.
What calls formattedMappings()?
formattedMappings() is called by 1 function(s): run.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free