MCPcopy Create free account
hub / github.com/formkit/formkit / apiTheme

Function apiTheme

packages/cli/src/theme.ts:639–668  ·  view source on GitHub ↗
(
  themeName: string,
  endpoint: string,
  variables: string,
  isTS: boolean,
  semantic: boolean,
  spinner?: Ora
)

Source from the content-addressed store, hash-verified

637}
638
639async function apiTheme(
640 themeName: string,
641 endpoint: string,
642 variables: string,
643 isTS: boolean,
644 semantic: boolean,
645 spinner?: Ora
646): Promise<string> {
647 if (spinner) {
648 spinner.text = `🔨 building ${themeName}`
649 } else {
650 info(`⚡️ building theme: ${themeName}`)
651 }
652 const res = await fetch(`${endpoint}/generate`, {
653 method: 'POST',
654 headers: { 'Content-Type': 'application/json' },
655 body: JSON.stringify({
656 theme: themeName,
657 variables,
658 ts: String(isTS),
659 semantic: String(semantic),
660 }),
661 })
662 if (res.ok) {
663 const code = normalizeGeneratedTheme(themeName, await res.text())
664 return semantic ? code : scopeGeneratedThemeStateClasses(code)
665 } else {
666 error(`Could not generate theme — ${res.statusText}`)
667 }
668}

Callers 2

buildThemeFunction · 0.85
editModeFunction · 0.85

Calls 4

infoFunction · 0.90
normalizeGeneratedThemeFunction · 0.90
errorFunction · 0.90

Tested by

no test coverage detected