{"version":3,"file":"index.js","sources":["../src/defaultTemplate.ts","../src/variables.ts","../src/index.ts"],"sourcesContent":["import type { Template } from './types'\n\nexport const defaultTemplate: Template = (variables, { tpl }) => {\n  return tpl`\n${variables.imports};\n\n${variables.interfaces};\n\nconst ${variables.componentName} = (${variables.props}) => (\n  ${variables.jsx}\n);\n \n${variables.exports};\n`\n}\n","import { types as t, template } from '@babel/core'\nimport type { Options, TemplateVariables, JSXRuntimeImport } from './types'\nimport type { ImportDeclaration } from '@babel/types'\n\nconst tsOptionalPropertySignature = (\n  ...args: Parameters<typeof t.tsPropertySignature>\n) => {\n  return {\n    ...t.tsPropertySignature(...args),\n    optional: true,\n  } as t.TSPropertySignature\n}\n\ninterface Context {\n  opts: Options\n  interfaces: t.TSInterfaceDeclaration[]\n  props: (t.Identifier | t.ObjectPattern)[]\n  imports: t.ImportDeclaration[]\n  importSource: string\n}\n\nconst getOrCreateImport = (\n  { imports }: Context,\n  sourceValue: string,\n  importKind: ImportDeclaration['importKind'] = undefined,\n) => {\n  const existing = imports.find(\n    (imp) =>\n      imp.source.value === sourceValue &&\n      imp.importKind === importKind &&\n      !imp.specifiers.some(\n        (specifier) => specifier.type === 'ImportNamespaceSpecifier',\n      ),\n  )\n  if (existing) return existing\n  const imp = t.importDeclaration([], t.stringLiteral(sourceValue))\n  if (importKind !== undefined) {\n    imp.importKind = importKind\n  }\n  imports.push(imp)\n  return imp\n}\n\nconst tsTypeReferenceSVGProps = (ctx: Context) => {\n  if (ctx.opts.native) {\n    const identifier = t.identifier('SvgProps')\n    getOrCreateImport(ctx, 'react-native-svg', 'type').specifiers.push(\n      t.importSpecifier(identifier, identifier),\n    )\n    return t.tsTypeReference(identifier)\n  }\n  const identifier = t.identifier('SVGProps')\n  getOrCreateImport(ctx, ctx.importSource, 'type').specifiers.push(\n    t.importSpecifier(identifier, identifier),\n  )\n  return t.tsTypeReference(\n    identifier,\n    t.tsTypeParameterInstantiation([\n      t.tsTypeReference(t.identifier('SVGSVGElement')),\n    ]),\n  )\n}\n\nconst tsTypeReferenceSVGRef = (ctx: Context) => {\n  const identifier = t.identifier('Ref')\n  getOrCreateImport(ctx, ctx.importSource).specifiers.push(\n    t.importSpecifier(identifier, identifier),\n  )\n  return t.tsTypeReference(\n    identifier,\n    t.tsTypeParameterInstantiation([\n      t.tsTypeReference(t.identifier('SVGSVGElement')),\n    ]),\n  )\n}\n\nconst getJsxRuntimeImport = (cfg: JSXRuntimeImport) => {\n  const specifiers = (() => {\n    if (cfg.namespace)\n      return [t.importNamespaceSpecifier(t.identifier(cfg.namespace))]\n    if (cfg.defaultSpecifier) {\n      const identifier = t.identifier(cfg.defaultSpecifier)\n      return [t.importDefaultSpecifier(identifier)]\n    }\n    if (cfg.specifiers)\n      return cfg.specifiers.map((specifier) => {\n        const identifier = t.identifier(specifier)\n        return t.importSpecifier(identifier, identifier)\n      })\n    throw new Error(\n      `Specify \"namespace\", \"defaultSpecifier\", or \"specifiers\" in \"jsxRuntimeImport\" option`,\n    )\n  })()\n  return t.importDeclaration(specifiers, t.stringLiteral(cfg.source))\n}\n\nconst defaultJsxRuntimeImport: JSXRuntimeImport = {\n  source: 'react',\n  namespace: 'React',\n}\n\nconst defaultImportSource = 'react'\n\nexport const getVariables = ({\n  opts,\n  jsx,\n}: {\n  opts: Options\n  jsx: t.JSXElement\n}): TemplateVariables => {\n  const interfaces: t.TSInterfaceDeclaration[] = []\n  const props: (t.Identifier | t.ObjectPattern)[] = []\n  const imports: t.ImportDeclaration[] = []\n  const exports: (t.VariableDeclaration | t.ExportDeclaration | t.Statement)[] =\n    []\n  const ctx = {\n    importSource: opts.importSource ?? defaultImportSource,\n    exportIdentifier: t.identifier(opts.state.componentName),\n    opts,\n    interfaces,\n    props,\n    imports,\n    exports,\n  }\n\n  if (opts.jsxRuntime !== 'automatic') {\n    imports.push(\n      getJsxRuntimeImport(opts.jsxRuntimeImport ?? defaultJsxRuntimeImport),\n    )\n  }\n\n  if (opts.native) {\n    getOrCreateImport(ctx, 'react-native-svg').specifiers.push(\n      t.importDefaultSpecifier(t.identifier('Svg')),\n    )\n  }\n\n  if (opts.titleProp || opts.descProp) {\n    const properties = []\n    const propertySignatures = []\n    const createProperty = (attr: string) => {\n      return t.objectProperty(\n        t.identifier(attr),\n        t.identifier(attr),\n        false,\n        true,\n      )\n    }\n    const createSignature = (attr: string) => {\n      return tsOptionalPropertySignature(\n        t.identifier(attr),\n        t.tsTypeAnnotation(t.tsStringKeyword()),\n      )\n    }\n\n    if (opts.titleProp) {\n      properties.push(createProperty('title'), createProperty('titleId'))\n\n      if (opts.typescript) {\n        propertySignatures.push(\n          createSignature('title'),\n          createSignature('titleId'),\n        )\n      }\n    }\n\n    if (opts.descProp) {\n      properties.push(createProperty('desc'), createProperty('descId'))\n\n      if (opts.typescript) {\n        propertySignatures.push(\n          createSignature('desc'),\n          createSignature('descId'),\n        )\n      }\n    }\n\n    const prop = t.objectPattern(properties)\n    props.push(prop)\n    if (opts.typescript) {\n      interfaces.push(\n        t.tsInterfaceDeclaration(\n          t.identifier('SVGRProps'),\n          null,\n          null,\n          t.tSInterfaceBody(propertySignatures),\n        ),\n      )\n      prop.typeAnnotation = t.tsTypeAnnotation(\n        t.tsTypeReference(t.identifier('SVGRProps')),\n      )\n    }\n  }\n\n  if (opts.expandProps) {\n    const identifier = t.identifier('props')\n    if (t.isObjectPattern(props[0])) {\n      props[0].properties.push(t.restElement(identifier))\n      if (opts.typescript) {\n        props[0].typeAnnotation = t.tsTypeAnnotation(\n          t.tsIntersectionType([\n            tsTypeReferenceSVGProps(ctx),\n            (props[0].typeAnnotation as t.TSTypeAnnotation).typeAnnotation,\n          ]),\n        )\n      }\n    } else {\n      props.push(identifier)\n      if (opts.typescript) {\n        identifier.typeAnnotation = t.tsTypeAnnotation(\n          tsTypeReferenceSVGProps(ctx),\n        )\n      }\n    }\n  }\n\n  if (opts.ref) {\n    if (props.length === 0) {\n      props.push(t.identifier('_'))\n    }\n    const prop = t.identifier('ref')\n    props.push(prop)\n    if (opts.typescript) {\n      prop.typeAnnotation = t.tsTypeAnnotation(tsTypeReferenceSVGRef(ctx))\n    }\n    const forwardRef = t.identifier('forwardRef')\n    const ForwardRef = t.identifier('ForwardRef')\n    getOrCreateImport(ctx, ctx.importSource).specifiers.push(\n      t.importSpecifier(forwardRef, forwardRef),\n    )\n    exports.push(\n      t.variableDeclaration('const', [\n        t.variableDeclarator(\n          ForwardRef,\n          t.callExpression(forwardRef, [ctx.exportIdentifier]),\n        ),\n      ]),\n    )\n    ctx.exportIdentifier = ForwardRef\n  }\n\n  if (opts.memo) {\n    const memo = t.identifier('memo')\n    const Memo = t.identifier('Memo')\n    getOrCreateImport(ctx, ctx.importSource).specifiers.push(\n      t.importSpecifier(memo, memo),\n    )\n    exports.push(\n      t.variableDeclaration('const', [\n        t.variableDeclarator(\n          Memo,\n          t.callExpression(memo, [ctx.exportIdentifier]),\n        ),\n      ]),\n    )\n    ctx.exportIdentifier = Memo\n  }\n\n  if (opts.state.caller?.previousExport || opts.exportType === 'named') {\n    if (!opts.namedExport) {\n      throw new Error(`\"namedExport\" not specified`)\n    }\n    exports.push(\n      t.exportNamedDeclaration(null, [\n        t.exportSpecifier(ctx.exportIdentifier, t.identifier(opts.namedExport)),\n      ]),\n    )\n    if (opts.state.caller?.previousExport) {\n      const previousExportAst = template.ast(opts.state.caller.previousExport)\n      exports.push(\n        ...(Array.isArray(previousExportAst)\n          ? previousExportAst\n          : [previousExportAst]),\n      )\n    }\n  } else {\n    exports.push(t.exportDefaultDeclaration(ctx.exportIdentifier))\n  }\n  return {\n    componentName: opts.state.componentName,\n    props,\n    interfaces,\n    imports,\n    exports,\n    jsx,\n  }\n}\n","/* eslint-disable @typescript-eslint/explicit-module-boundary-types */\nimport {\n  ConfigAPI,\n  NodePath,\n  types as t,\n  template as babelTemplate,\n  ParserOptions,\n} from '@babel/core'\nimport type { Options } from './types'\nimport { defaultTemplate } from './defaultTemplate'\nimport { getVariables } from './variables'\n\nexport type { Options, Template } from './types'\n\nconst plugin = (_: ConfigAPI, opts: Options) => {\n  const template = opts.template || defaultTemplate\n  const plugins: ParserOptions['plugins'] = opts.typescript\n    ? ['jsx', 'typescript']\n    : ['jsx']\n  const tpl = babelTemplate.smart({ plugins, preserveComments: true }).ast\n  return {\n    visitor: {\n      Program(path: NodePath<t.Program>) {\n        const jsx = (path.node.body[0] as t.ExpressionStatement)\n          .expression as t.JSXElement\n        const variables = getVariables({\n          opts,\n          jsx,\n        })\n        const body = template(variables, { options: opts, tpl })\n        path.node.body = Array.isArray(body) ? body : [body]\n        path.replaceWith(path.node)\n      },\n    },\n  }\n}\n\nexport default plugin\n"],"names":["t","imp","identifier","template","babelTemplate"],"mappings":";;;;AAEO,MAAM,eAA4B,GAAA,CAAC,SAAW,EAAA,EAAE,KAAU,KAAA;AAC/D,EAAO,OAAA,GAAA,CAAA;AAAA,EACP,SAAU,CAAA,OAAA,CAAA;AAAA;AAAA,EAEV,SAAU,CAAA,UAAA,CAAA;AAAA;AAAA,MAEJ,EAAA,SAAA,CAAU,oBAAoB,SAAU,CAAA,KAAA,CAAA;AAAA,EAAA,EAC5C,SAAU,CAAA,GAAA,CAAA;AAAA;AAAA;AAAA,EAGZ,SAAU,CAAA,OAAA,CAAA;AAAA,CAAA,CAAA;AAEZ,CAAA;;;;;;;;;;;;;;;;;;;;;ACVA,MAAM,2BAAA,GAA8B,IAC/B,IACA,KAAA;AACH,EAAA,OAAO,aACF,CAAA,cAAA,CAAA,EAAA,EAAAA,UAAA,CAAE,mBAAoB,CAAA,GAAG,IAAI,CAD3B,CAAA,EAAA;AAAA,IAEL,QAAU,EAAA,IAAA;AAAA,GACZ,CAAA,CAAA;AACF,CAAA,CAAA;AAUA,MAAM,oBAAoB,CACxB,EAAE,SACF,EAAA,WAAA,EACA,aAA8C,KAC3C,CAAA,KAAA;AACH,EAAA,MAAM,WAAW,OAAQ,CAAA,IAAA;AAAA,IACvB,CAACC,IACCA,KAAAA,IAAAA,CAAI,MAAO,CAAA,KAAA,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