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

Function serializeComponent

packages/extension/utils/component.ts:404–419  ·  view source on GitHub ↗
(
  component: DesignComponent,
  { lang = 'jsx' }: SerializeOptions,
  { transformComponent }: TransformOptions = {}
)

Source from the content-addressed store, hash-verified

402}
403
404export function serializeComponent(
405 component: DesignComponent,
406 { lang = 'jsx' }: SerializeOptions,
407 { transformComponent }: TransformOptions = {}
408) {
409 if (typeof transformComponent === 'function') {
410 const result = transformComponent({ component })
411 if (typeof result === 'string') {
412 return result
413 }
414
415 return stringifyComponent(result, { lang })
416 }
417
418 return ''
419}
420
421export function mergeAttributes(code: string, attrs: Record<string, string>): string {
422 if (!code || !Object.keys(attrs).length) return code

Callers 2

component.test.tsFile · 0.90
worker.tsFile · 0.90

Calls 1

stringifyComponentFunction · 0.85

Tested by

no test coverage detected