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

Function generateCodeBlocksForNode

packages/extension/utils/codegen.ts:54–86  ·  view source on GitHub ↗
(
  node: SceneNode,
  config: CodegenConfig,
  pluginCode?: string,
  opts?: { returnDevComponent?: boolean; variableDisplay?: VariableDisplayMode }
)

Source from the content-addressed store, hash-verified

52 PLUGIN_SANDBOX_WORKER.codegen,
53 {
54 ...job,
55 pluginCode
56 }
57 )
58 return validateCodegenResponse(response)
59}
60
61async function codegenBatch(
62 jobs: CodegenJobPayload[],
63 pluginCode?: string
64): Promise<ResponsePayload[]> {
65 const response = await requestPluginSandbox<CodegenBatchRequestPayload, unknown>(
66 PLUGIN_SANDBOX_WORKER.codegen,
67 { jobs, pluginCode }
68 )
69 const results = validateCodegenBatchResponse(response)
70 if (results.length !== jobs.length) {
71 throw new PluginSandboxError(
72 'protocol-error',
73 `Plugin returned ${results.length} batch results for ${jobs.length} jobs.`
74 )
75 }
76 return results
77}
78
79export type CodegenConfig = {
80 cssUnit: 'px' | 'rem'
81 rootFontSize: number
82 scale: number
83}
84
85export function workerUnitOptions(
86 config: CodegenConfig
87): Pick<SerializeOptions, 'useRem' | 'rootFontSize' | 'scale'> {
88 return {
89 useRem: config.cssUnit === 'rem',

Callers 2

codegen.test.tsFile · 0.90
resolvePluginComponentFunction · 0.90

Calls 6

resolveStylesFromNodeFunction · 0.90
formatNodeStyleForUiFunction · 0.90
getDesignComponentFunction · 0.90
workerUnitOptionsFunction · 0.85
codegenFunction · 0.85

Tested by

no test coverage detected