Home / File/ translation-map.test.ts — tailwindcss Source File

translation-map.test.ts — tailwindcss Source File

Architecture documentation for translation-map.test.ts, a typescript file in the tailwindcss codebase. 7 imports, 0 dependents.

File typescript OxideEngine Scanner 7 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  83f56732_94d8_aae2_694c_e38d0ec61bfd["translation-map.test.ts"]
  42640952_ea63_55f1_1ff1_00816e2980ae["ast.ts"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 42640952_ea63_55f1_1ff1_00816e2980ae
  2da63033_d079_7b37_5cfb_3877674a70b9["toCss"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 2da63033_d079_7b37_5cfb_3877674a70b9
  54851997_7544_bab2_96ab_548e5f5df205["css-parser.ts"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 54851997_7544_bab2_96ab_548e5f5df205
  94f6a4ae_3b1f_8e71_a096_1f7d17efc49a["source-map.ts"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 94f6a4ae_3b1f_8e71_a096_1f7d17efc49a
  b8973deb_e07f_d1e1_e7f9_7a680d9120d4["createTranslationMap"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> b8973deb_e07f_d1e1_e7f9_7a680d9120d4
  211db6bb_9759_d0cf_acda_36d7f5733ce2["dedent"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 211db6bb_9759_d0cf_acda_36d7f5733ce2
  696bd648_5f24_1b59_8e8b_7a97a692869e["vitest"]
  83f56732_94d8_aae2_694c_e38d0ec61bfd --> 696bd648_5f24_1b59_8e8b_7a97a692869e
  style 83f56732_94d8_aae2_694c_e38d0ec61bfd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import dedent from 'dedent'
import { assert, expect, test } from 'vitest'
import { toCss, type AstNode } from '../ast'
import * as CSS from '../css-parser'
import { createTranslationMap } from './source-map'

async function analyze(input: string) {
  let ast = CSS.parse(input, { from: 'input.css' })
  let css = toCss(ast, true)
  let translate = createTranslationMap({
    original: input,
    generated: css,
  })

  function format(node: AstNode) {
    let lines: string[] = []

    for (let [oStart, oEnd, gStart, gEnd] of translate(node)) {
      let src = `${oStart.line}:${oStart.column}-${oEnd.line}:${oEnd.column}`

      let dst = '(none)'

      if (gStart && gEnd) {
        dst = `${gStart.line}:${gStart.column}-${gEnd.line}:${gEnd.column}`
      }

      lines.push(`${dst} <- ${src}`)
    }

    return lines
  }

  return { ast, css, format }
}

test('comment, single line', async () => {
  let { ast, css, format } = await analyze(`/*! foo */`)

  assert(ast[0].kind === 'comment')
  expect(format(ast[0])).toMatchInlineSnapshot(`
    [
      "1:0-1:10 <- 1:0-1:10",
    ]
  `)

  expect(css).toMatchInlineSnapshot(`
    "/*! foo */
    "
  `)
})

test('comment, multi line', async () => {
  let { ast, css, format } = await analyze(`/*! foo \n bar */`)

  assert(ast[0].kind === 'comment')
  expect(format(ast[0])).toMatchInlineSnapshot(`
    [
      "1:0-2:7 <- 1:0-2:7",
    ]
  `)
// ... (220 more lines)

Domain

Subdomains

Functions

Frequently Asked Questions

What does translation-map.test.ts do?
translation-map.test.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the OxideEngine domain, Scanner subdomain.
What functions are defined in translation-map.test.ts?
translation-map.test.ts defines 1 function(s): analyze.
What does translation-map.test.ts depend on?
translation-map.test.ts imports 7 module(s): ast.ts, createTranslationMap, css-parser.ts, dedent, source-map.ts, toCss, vitest.
Where is translation-map.test.ts in the architecture?
translation-map.test.ts is located at packages/tailwindcss/src/source-maps/translation-map.test.ts (domain: OxideEngine, subdomain: Scanner, directory: packages/tailwindcss/src/source-maps).

Analyze Your Own Codebase

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

Try Supermodel Free