Home / Function/ createTranslationMap() — tailwindcss Function Reference

createTranslationMap() — tailwindcss Function Reference

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

Entity Profile

Dependency Diagram

graph TD
  f91122be_c147_e5b3_0c21_f626d873cf8a["createTranslationMap()"]
  b5142dec_f0ec_66d6_59a1_82d3dbd6f965["analyze()"]
  b5142dec_f0ec_66d6_59a1_82d3dbd6f965 -->|calls| f91122be_c147_e5b3_0c21_f626d873cf8a
  2c7b6e31_c902_cd2d_f5ec_bf42f894f3a3["createLineTable()"]
  f91122be_c147_e5b3_0c21_f626d873cf8a -->|calls| 2c7b6e31_c902_cd2d_f5ec_bf42f894f3a3
  style f91122be_c147_e5b3_0c21_f626d873cf8a fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/tailwindcss/src/source-maps/source-map.ts lines 165–198

export function createTranslationMap({
  original,
  generated,
}: {
  original: string
  generated: string
}) {
  // Compute line tables for both the original and generated source lazily so we
  // don't have to do it during parsing or printing.
  let originalTable = createLineTable(original)
  let generatedTable = createLineTable(generated)

  type Translation = [
    originalStart: Position,
    originalEnd: Position,
    generatedStart: Position | null,
    generatedEnd: Position | null,
  ]

  return (node: AstNode) => {
    if (!node.src) return []

    let translations: Translation[] = []

    translations.push([
      originalTable.find(node.src[1]),
      originalTable.find(node.src[2]),
      node.dst ? generatedTable.find(node.dst[1]) : null,
      node.dst ? generatedTable.find(node.dst[2]) : null,
    ])

    return translations
  }
}

Subdomains

Called By

Frequently Asked Questions

What does createTranslationMap() do?
createTranslationMap() is a function in the tailwindcss codebase.
What does createTranslationMap() call?
createTranslationMap() calls 1 function(s): createLineTable.
What calls createTranslationMap()?
createTranslationMap() is called by 1 function(s): analyze.

Analyze Your Own Codebase

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

Try Supermodel Free