Home / File/ walk.ts — tailwindcss Source File

walk.ts — tailwindcss Source File

Architecture documentation for walk.ts, a typescript file in the tailwindcss codebase. 0 imports, 27 dependents.

File typescript Oxide Scanner 27 dependents 6 functions

Entity Profile

Dependency Diagram

graph LR
  1b8f1c54_b1e9_e18d_0719_b7ad92808185["walk.ts"]
  95a806ab_8556_4112_9786_fda4ff23eeca["urls.ts"]
  95a806ab_8556_4112_9786_fda4ff23eeca --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  f67a6019_88a0_ffd1_f91c_1a51645f6931["migrate-preflight.ts"]
  f67a6019_88a0_ffd1_f91c_1a51645f6931 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  0064e910_a1e5_1dd9_95f1_ac33aef2f9b1["migrate-automatic-var-injection.ts"]
  0064e910_a1e5_1dd9_95f1_ac33aef2f9b1 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  c36efdeb_7fd2_0935_2c28_bf15095a9dd9["migrate-theme-to-var.ts"]
  c36efdeb_7fd2_0935_2c28_bf15095a9dd9 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  1490304f_c9fd_75da_db3f_0c12d428c646["migrate-variant-order.ts"]
  1490304f_c9fd_75da_db3f_0c12d428c646 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  1721da0c_9e1d_5bee_ab0a_a192cfa6640d["apply.ts"]
  1721da0c_9e1d_5bee_ab0a_a192cfa6640d --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  3cba0ed8_8a2c_6367_67e3_fed6b42249a5["ast.test.ts"]
  3cba0ed8_8a2c_6367_67e3_fed6b42249a5 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  b9cbffa4_c352_cf3c_268f_cbb174fb3a47["ast.ts"]
  b9cbffa4_c352_cf3c_268f_cbb174fb3a47 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  061a1d94_150d_9879_9075_9c457da6010d["at-import.ts"]
  061a1d94_150d_9879_9075_9c457da6010d --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  ba6fca27_7720_5839_0f92_bc2abb8db636["candidate.ts"]
  ba6fca27_7720_5839_0f92_bc2abb8db636 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  f6c14bbb_2e42_58cc_18f1_c89a243da9c0["canonicalize-candidates.ts"]
  f6c14bbb_2e42_58cc_18f1_c89a243da9c0 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  2745c5e0_8ea4_a1c7_4f84_369746e3eb63["apply-compat-hooks.ts"]
  2745c5e0_8ea4_a1c7_4f84_369746e3eb63 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  da5d1116_ab2a_437a_6b13_c1429fd546fa["plugin-api.ts"]
  da5d1116_ab2a_437a_6b13_c1429fd546fa --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  eea0ec96_6369_abc2_64b3_490868392e31["compile.ts"]
  eea0ec96_6369_abc2_64b3_490868392e31 --> 1b8f1c54_b1e9_e18d_0719_b7ad92808185
  style 1b8f1c54_b1e9_e18d_0719_b7ad92808185 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

const enum WalkKind {
  Continue,
  Skip,
  Stop,
  Replace,
  ReplaceSkip,
  ReplaceStop,
}

export const WalkAction = {
  Continue: { kind: WalkKind.Continue } as const,
  Skip: { kind: WalkKind.Skip } as const,
  Stop: { kind: WalkKind.Stop } as const,
  Replace: <T>(nodes: T | T[]) =>
    ({ kind: WalkKind.Replace, nodes: Array.isArray(nodes) ? nodes : [nodes] }) as const,
  ReplaceSkip: <T>(nodes: T | T[]) =>
    ({ kind: WalkKind.ReplaceSkip, nodes: Array.isArray(nodes) ? nodes : [nodes] }) as const,
  ReplaceStop: <T>(nodes: T | T[]) =>
    ({ kind: WalkKind.ReplaceStop, nodes: Array.isArray(nodes) ? nodes : [nodes] }) as const,
} as const

type WalkAction = typeof WalkAction
type WalkResult<T> =
  | WalkAction['Continue']
  | WalkAction['Skip']
  | WalkAction['Stop']
  | ReturnType<typeof WalkAction.Replace<T>>
  | ReturnType<typeof WalkAction.ReplaceSkip<T>>
  | ReturnType<typeof WalkAction.ReplaceStop<T>>

type EnterResult<T> = WalkResult<T>
type ExitResult<T> = Exclude<WalkResult<T>, { kind: WalkKind.Skip }>

type Parent<T> = T & { nodes: T[] }

export interface VisitContext<T> {
  parent: Parent<T> | null
  depth: number
  path: () => T[]
}

export function walk<T extends object>(
  ast: T[],
  hooks:
    | ((node: T, ctx: VisitContext<T>) => EnterResult<T> | void) // Old API, enter only
    | {
        enter?: (node: T, ctx: VisitContext<T>) => EnterResult<T> | void
        exit?: (node: T, ctx: VisitContext<T>) => ExitResult<T> | void
      },
): void {
  if (typeof hooks === 'function') walkImplementation(ast, hooks)
  else walkImplementation(ast, hooks.enter, hooks.exit)
}

interface Stack<T> {
  value: T
  prev: Stack<T> | null
}

function walkImplementation<T extends { nodes?: T[] }>(
// ... (137 more lines)

Domain

Subdomains

Frequently Asked Questions

What does walk.ts do?
walk.ts is a source file in the tailwindcss codebase, written in typescript. It belongs to the Oxide domain, Scanner subdomain.
What functions are defined in walk.ts?
walk.ts defines 6 function(s): T, WalkAction.Replace, WalkAction.ReplaceSkip, WalkAction.ReplaceStop, walk, walkImplementation.
What files import walk.ts?
walk.ts is imported by 27 file(s): apply-compat-hooks.ts, apply.ts, ast.test.ts, ast.ts, at-import.ts, candidate.ts, canonicalize-candidates.ts, compile.ts, and 19 more.
Where is walk.ts in the architecture?
walk.ts is located at packages/tailwindcss/src/walk.ts (domain: Oxide, subdomain: Scanner, directory: packages/tailwindcss/src).

Analyze Your Own Codebase

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

Try Supermodel Free