ast.ts — tailwindcss Source File
Architecture documentation for ast.ts, a typescript file in the tailwindcss codebase. 13 imports, 3 dependents.
Entity Profile
Dependency Diagram
graph LR 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d["ast.ts"] b9cbffa4_c352_cf3c_268f_cbb174fb3a47["ast.ts"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> b9cbffa4_c352_cf3c_268f_cbb174fb3a47 2f6881be_62d9_4b96_7331_a962ced095f7["atRule"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 2f6881be_62d9_4b96_7331_a962ced095f7 fdbae017_3891_f845_038f_5fc0e026e5e4["comment"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> fdbae017_3891_f845_038f_5fc0e026e5e4 1369a6dc_e395_347d_5d24_b88e22c5446d["decl"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 1369a6dc_e395_347d_5d24_b88e22c5446d 085cf56e_8188_afb1_04da_5ccd0fb7babc["rule"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 085cf56e_8188_afb1_04da_5ccd0fb7babc c078df4e_9ae3_a02e_4feb_6380507fddd9["line-table.ts"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> c078df4e_9ae3_a02e_4feb_6380507fddd9 1c8e1044_08e4_f6ad_7550_c4fa3667fbf3["createLineTable"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 1c8e1044_08e4_f6ad_7550_c4fa3667fbf3 45262882_ddec_eb81_dedb_b4f286a3f721["source.ts"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 45262882_ddec_eb81_dedb_b4f286a3f721 c559b871_eb1d_407d_d482_821ec44dea54["Source"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> c559b871_eb1d_407d_d482_821ec44dea54 0befe1e4_cbdb_e481_9c0a_5c5c6d3e2a01["SourceLocation"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 0befe1e4_cbdb_e481_9c0a_5c5c6d3e2a01 28a2f72d_350c_6647_bf9d_77c69e637045["default-map.ts"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 28a2f72d_350c_6647_bf9d_77c69e637045 cfb4af0e_7b2d_34a1_693a_90088443cfec["DefaultMap"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> cfb4af0e_7b2d_34a1_693a_90088443cfec 7c3c22f8_be1a_4490_9f3e_622280887fe1["postcss"] 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d --> 7c3c22f8_be1a_4490_9f3e_622280887fe1 85ba2ac2_aa8c_15cb_ed3c_011dc66339d7["ast.test.ts"] 85ba2ac2_aa8c_15cb_ed3c_011dc66339d7 --> 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d style 9106ed35_a5a8_5f41_7f5e_a6fe5287f68d fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import type * as postcss from 'postcss'
import { atRule, comment, decl, rule, type AstNode } from '../../tailwindcss/src/ast'
import { createLineTable, type LineTable } from '../../tailwindcss/src/source-maps/line-table'
import type { Source, SourceLocation } from '../../tailwindcss/src/source-maps/source'
import { DefaultMap } from '../../tailwindcss/src/utils/default-map'
const EXCLAMATION_MARK = 0x21
export function cssAstToPostCssAst(
postcss: postcss.Postcss,
ast: AstNode[],
source?: postcss.Source,
): postcss.Root {
let inputMap = new DefaultMap<Source, postcss.Input>((src) => {
return new postcss.Input(src.code, {
map: source?.input.map,
from: src.file ?? undefined,
})
})
let lineTables = new DefaultMap<Source, LineTable>((src) => createLineTable(src.code))
let root = postcss.root()
root.source = source
function toSource(loc: SourceLocation | undefined): postcss.Source | undefined {
// Use the fallback if this node has no location info in the AST
if (!loc) return
if (!loc[0]) return
let table = lineTables.get(loc[0])
let start = table.find(loc[1])
let end = table.find(loc[2])
return {
input: inputMap.get(loc[0]),
start: {
line: start.line,
column: start.column + 1,
offset: loc[1],
},
end: {
line: end.line,
column: end.column + 1,
offset: loc[2],
},
}
}
function updateSource(astNode: postcss.ChildNode, loc: SourceLocation | undefined) {
let source = toSource(loc)
// The `source` property on PostCSS nodes must be defined if present because
// `toJSON()` reads each property and tries to read from source.input if it
// sees a `source` property. This means for a missing or otherwise absent
// source it must be *missing* from the object rather than just `undefined`
if (source) {
astNode.source = source
} else {
delete astNode.source
// ... (130 more lines)
Domain
Subdomains
Functions
Dependencies
Imported By
Source
Frequently Asked Questions
What does ast.ts do?
ast.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the PostCSSPlugin domain, AST subdomain.
What functions are defined in ast.ts?
ast.ts defines 2 function(s): cssAstToPostCssAst, postCssAstToCssAst.
What does ast.ts depend on?
ast.ts imports 13 module(s): DefaultMap, Source, SourceLocation, ast.ts, atRule, comment, createLineTable, decl, and 5 more.
What files import ast.ts?
ast.ts is imported by 3 file(s): ast.test.ts, index.ts, stylesheet.ts.
Where is ast.ts in the architecture?
ast.ts is located at packages/@tailwindcss-postcss/src/ast.ts (domain: PostCSSPlugin, subdomain: AST, directory: packages/@tailwindcss-postcss/src).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free