MCPcopy Create free account
hub / github.com/ecomfe/tempad-dev / codegen

Function codegen

packages/extension/utils/codegen.ts:16–36  ·  view source on GitHub ↗
(
  style: Record<string, string>,
  component: DesignComponent | null,
  options: SerializeOptions,
  pluginCode?: string,
  returnDevComponent?: boolean,
  pluginVariableStyle?: Record<string, string>,
  variableSyntax?: Record<string, string>
)

Source from the content-addressed store, hash-verified

14import { validateCodegenBatchResponse, validateCodegenResponse } from '@/plugin-sandbox/validation'
15
16import { getDesignComponent } from './component'
17import { resolveStylesFromNode } from './figma-style/style-resolver'
18import { formatNodeStyleForPluginVariables, formatNodeStyleForUi } from './variable-output'
19
20const CODEGEN_PREPARE_CONCURRENCY = 4
21const CODEGEN_BATCH_CONCURRENCY = 4
22const CODEGEN_BATCH_MAX_JOBS = 32
23const CODEGEN_JOB_WINDOW = CODEGEN_BATCH_CONCURRENCY * CODEGEN_BATCH_MAX_JOBS
24
25export async function codegen(
26 style: Record<string, string>,
27 component: DesignComponent | null,
28 options: SerializeOptions,
29 pluginCode?: string,
30 returnDevComponent?: boolean,
31 pluginVariableStyle?: Record<string, string>,
32 variableSyntax?: Record<string, string>
33): Promise<ResponsePayload> {
34 return requestCodegen(
35 {
36 style,
37 ...(pluginVariableStyle ? { pluginVariableStyle } : {}),
38 ...(variableSyntax && Object.keys(variableSyntax).length ? { variableSyntax } : {}),
39 component: component ?? undefined,

Callers 3

codegen.test.tsFile · 0.90
installFunction · 0.90

Calls 2

createWorkerRequesterFunction · 0.90
requestFunction · 0.50

Tested by

no test coverage detected