Home / File/ candidates.ts — tailwindcss Source File

candidates.ts — tailwindcss Source File

Architecture documentation for candidates.ts, a typescript file in the tailwindcss codebase. 4 imports, 3 dependents.

File typescript UpgradeToolkit TemplateAnalysis 4 imports 3 dependents 4 functions

Entity Profile

Dependency Diagram

graph LR
  6818f003_fa74_ca6e_8dd1_99a7154be5c9["candidates.ts"]
  669e6a28_c71f_3c5e_9c53_915cede7da78["candidate.ts"]
  6818f003_fa74_ca6e_8dd1_99a7154be5c9 --> 669e6a28_c71f_3c5e_9c53_915cede7da78
  f29ee016_da0a_a564_1658_fedaaac680b6["cloneCandidate"]
  6818f003_fa74_ca6e_8dd1_99a7154be5c9 --> f29ee016_da0a_a564_1658_fedaaac680b6
  7fd72d4c_e95c_d849_1002_1e1c9d8aca1a["design-system.ts"]
  6818f003_fa74_ca6e_8dd1_99a7154be5c9 --> 7fd72d4c_e95c_d849_1002_1e1c9d8aca1a
  8f3a837a_4918_fced_fe0d_2cfdb0bd2b31["oxide"]
  6818f003_fa74_ca6e_8dd1_99a7154be5c9 --> 8f3a837a_4918_fced_fe0d_2cfdb0bd2b31
  31e76df5_525e_7bba_21f3_1c1c32817d76["candidates.test.ts"]
  31e76df5_525e_7bba_21f3_1c1c32817d76 --> 6818f003_fa74_ca6e_8dd1_99a7154be5c9
  f8237e3b_92f4_a95b_9115_6042ea9c4699["migrate-legacy-classes.ts"]
  f8237e3b_92f4_a95b_9115_6042ea9c4699 --> 6818f003_fa74_ca6e_8dd1_99a7154be5c9
  75ba60a9_2614_1c57_ad40_3663d4315f3b["migrate.ts"]
  75ba60a9_2614_1c57_ad40_3663d4315f3b --> 6818f003_fa74_ca6e_8dd1_99a7154be5c9
  style 6818f003_fa74_ca6e_8dd1_99a7154be5c9 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import { Scanner } from '@tailwindcss/oxide'
import { cloneCandidate, type Candidate } from '../../../../tailwindcss/src/candidate'
import type { DesignSystem } from '../../../../tailwindcss/src/design-system'

export async function extractRawCandidates(
  content: string,
  extension: string = 'html',
): Promise<{ rawCandidate: string; start: number; end: number }[]> {
  let scanner = new Scanner({})
  let result = scanner.getCandidatesWithPositions({ content, extension })

  let candidates: { rawCandidate: string; start: number; end: number }[] = []
  for (let { candidate: rawCandidate, position: start } of result) {
    candidates.push({ rawCandidate, start, end: start + rawCandidate.length })
  }
  return candidates
}

// Create a basic stripped candidate without variants or important flag
export function baseCandidate<T extends Candidate>(candidate: T) {
  let base = cloneCandidate(candidate)

  base.important = false
  base.variants = []

  return base
}

export function parseCandidate(designSystem: DesignSystem, input: string) {
  return designSystem.parseCandidate(
    designSystem.theme.prefix && !input.startsWith(`${designSystem.theme.prefix}:`)
      ? `${designSystem.theme.prefix}:${input}`
      : input,
  )
}

export function printUnprefixedCandidate(designSystem: DesignSystem, candidate: Candidate) {
  let candidateString = designSystem.printCandidate(candidate)

  return designSystem.theme.prefix && candidateString.startsWith(`${designSystem.theme.prefix}:`)
    ? candidateString.slice(designSystem.theme.prefix.length + 1)
    : candidateString
}

Subdomains

Frequently Asked Questions

What does candidates.ts do?
candidates.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the UpgradeToolkit domain, TemplateAnalysis subdomain.
What functions are defined in candidates.ts?
candidates.ts defines 4 function(s): baseCandidate, extractRawCandidates, parseCandidate, printUnprefixedCandidate.
What does candidates.ts depend on?
candidates.ts imports 4 module(s): candidate.ts, cloneCandidate, design-system.ts, oxide.
What files import candidates.ts?
candidates.ts is imported by 3 file(s): candidates.test.ts, migrate-legacy-classes.ts, migrate.ts.
Where is candidates.ts in the architecture?
candidates.ts is located at packages/@tailwindcss-upgrade/src/codemods/template/candidates.ts (domain: UpgradeToolkit, subdomain: TemplateAnalysis, directory: packages/@tailwindcss-upgrade/src/codemods/template).

Analyze Your Own Codebase

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

Try Supermodel Free