Home / File/ source-maps.ts — tailwindcss Source File

source-maps.ts — tailwindcss Source File

Architecture documentation for source-maps.ts, a typescript file in the tailwindcss codebase. 6 imports, 0 dependents.

File typescript NodeServer Compiler 6 imports 2 functions

Entity Profile

Dependency Diagram

graph LR
  6219568c_788d_e9f4_1518_104d7994cc7f["source-maps.ts"]
  2638fb39_6a36_5dfe_4705_961a0b5ff737["source-map.ts"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> 2638fb39_6a36_5dfe_4705_961a0b5ff737
  e646084f_9224_c7a3_3dec_3aeca30a37c1["DecodedSource"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> e646084f_9224_c7a3_3dec_3aeca30a37c1
  5f0d8af7_c6b9_820e_1cf5_b5f68a72c816["DecodedSourceMap"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> 5f0d8af7_c6b9_820e_1cf5_b5f68a72c816
  28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> 28a2f72d_350c_6647_bf9d_77c69e637045
  cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> cfb4af0e_7b2d_34a1_693a_90088443cfec
  46377737_e2b8_a689_bbdf_90f37c3175a3["source-map-js"]
  6219568c_788d_e9f4_1518_104d7994cc7f --> 46377737_e2b8_a689_bbdf_90f37c3175a3
  style 6219568c_788d_e9f4_1518_104d7994cc7f fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { SourceMapGenerator } from 'source-map-js'
import type { DecodedSource, DecodedSourceMap } from '../../tailwindcss/src/source-maps/source-map'
import { DefaultMap } from '../../tailwindcss/src/utils/default-map'

export type { DecodedSource, DecodedSourceMap }
export interface SourceMap {
  readonly raw: string
  readonly inline: string
  comment(url: string): string
}

function serializeSourceMap(map: DecodedSourceMap): string {
  let generator = new SourceMapGenerator()

  let id = 1
  let sourceTable = new DefaultMap<
    DecodedSource | null,
    {
      url: string
      content: string
    }
  >((src) => {
    return {
      url: src?.url ?? `<unknown ${id++}>`,
      content: src?.content ?? '<none>',
    }
  })

  for (let mapping of map.mappings) {
    let original = sourceTable.get(mapping.originalPosition?.source ?? null)

    generator.addMapping({
      generated: mapping.generatedPosition,
      original: mapping.originalPosition,
      source: original.url,
      name: mapping.name,
    })

    generator.setSourceContent(original.url, original.content)
  }

  return generator.toString()
}

export function toSourceMap(map: DecodedSourceMap | string): SourceMap {
  let raw = typeof map === 'string' ? map : serializeSourceMap(map)

  function comment(url: string) {
    return `/*# sourceMappingURL=${url} */\n`
  }

  return {
    raw,
    get inline() {
      let inlined = Buffer.from(raw, 'utf-8').toString('base64')
      return comment(`data:application/json;base64,${inlined}`)
    },
    comment,
  }
}

Domain

Subdomains

Types

Frequently Asked Questions

What does source-maps.ts do?
source-maps.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the NodeServer domain, Compiler subdomain.
What functions are defined in source-maps.ts?
source-maps.ts defines 2 function(s): serializeSourceMap, toSourceMap.
What does source-maps.ts depend on?
source-maps.ts imports 6 module(s): DecodedSource, DecodedSourceMap, DefaultMap, default-map.ts, source-map-js, source-map.ts.
Where is source-maps.ts in the architecture?
source-maps.ts is located at packages/@tailwindcss-node/src/source-maps.ts (domain: NodeServer, subdomain: Compiler, directory: packages/@tailwindcss-node/src).

Analyze Your Own Codebase

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

Try Supermodel Free