Home / Function/ createTranslationMap() — tailwindcss Function Reference

createTranslationMap() — tailwindcss Function Reference

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

Function typescript Oxide Extractor calls 1 called by 1

Entity Profile

Dependency Diagram

graph TD
  0799cdd2_4b0e_a38a_f2e3_313f628e1d75["createTranslationMap()"]
  2638fb39_6a36_5dfe_4705_961a0b5ff737["source-map.ts"]
  0799cdd2_4b0e_a38a_f2e3_313f628e1d75 -->|defined in| 2638fb39_6a36_5dfe_4705_961a0b5ff737
  8ef22b30_0ed6_09d2_959d_163f9c650639["analyze()"]
  8ef22b30_0ed6_09d2_959d_163f9c650639 -->|calls| 0799cdd2_4b0e_a38a_f2e3_313f628e1d75
  1c8e1044_08e4_f6ad_7550_c4fa3667fbf3["createLineTable()"]
  0799cdd2_4b0e_a38a_f2e3_313f628e1d75 -->|calls| 1c8e1044_08e4_f6ad_7550_c4fa3667fbf3
  style 0799cdd2_4b0e_a38a_f2e3_313f628e1d75 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
  }
}

Domain

Subdomains

Called By

Frequently Asked Questions

What does createTranslationMap() do?
createTranslationMap() is a function in the tailwindcss codebase, defined in packages/tailwindcss/src/source-maps/source-map.ts.
Where is createTranslationMap() defined?
createTranslationMap() is defined in packages/tailwindcss/src/source-maps/source-map.ts at line 165.
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