Home / Function/ parseObjectLiteral() — ui Function Reference

parseObjectLiteral() — ui Function Reference

Architecture documentation for the parseObjectLiteral() function in update-tailwind-config.ts from the ui codebase.

Entity Profile

Dependency Diagram

graph TD
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e["parseObjectLiteral()"]
  ef3e192c_eced_bc46_1021_689faf6b7065["update-tailwind-config.ts"]
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e -->|defined in| ef3e192c_eced_bc46_1021_689faf6b7065
  c25108fa_c2e6_295b_b5ed_e67e55e05d20["addTailwindConfigTheme()"]
  c25108fa_c2e6_295b_b5ed_e67e55e05d20 -->|calls| c5708093_d860_eaff_f0d3_0bcb8e1daa1e
  54febefd_ee20_a17f_1f9e_12babcc8092a["_createSourceFile()"]
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e -->|calls| 54febefd_ee20_a17f_1f9e_12babcc8092a
  2bbe4a89_5776_ed01_9450_72290f2a14b4["parseObjectLiteralExpression()"]
  c5708093_d860_eaff_f0d3_0bcb8e1daa1e -->|calls| 2bbe4a89_5776_ed01_9450_72290f2a14b4
  style c5708093_d860_eaff_f0d3_0bcb8e1daa1e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

packages/shadcn/src/utils/updaters/update-tailwind-config.ts lines 416–434

async function parseObjectLiteral(objectLiteralString: string): Promise<any> {
  const sourceFile = await _createSourceFile(
    `const theme = ${objectLiteralString}`,
    null
  )

  const statement = sourceFile.getStatements()[0]
  if (statement?.getKind() === SyntaxKind.VariableStatement) {
    const declaration = (statement as VariableStatement)
      .getDeclarationList()
      ?.getDeclarations()[0]
    const initializer = declaration.getInitializer()
    if (initializer?.isKind(SyntaxKind.ObjectLiteralExpression)) {
      return await parseObjectLiteralExpression(initializer)
    }
  }

  throw new Error("Invalid input: not an object literal")
}

Subdomains

Frequently Asked Questions

What does parseObjectLiteral() do?
parseObjectLiteral() is a function in the ui codebase, defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts.
Where is parseObjectLiteral() defined?
parseObjectLiteral() is defined in packages/shadcn/src/utils/updaters/update-tailwind-config.ts at line 416.
What does parseObjectLiteral() call?
parseObjectLiteral() calls 2 function(s): _createSourceFile, parseObjectLiteralExpression.
What calls parseObjectLiteral()?
parseObjectLiteral() is called by 1 function(s): addTailwindConfigTheme.

Analyze Your Own Codebase

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

Try Supermodel Free