How to use the @teleporthq/teleport-plugin-common.ASTUtils.objectToObjectExpression function in @teleporthq/teleport-plugin-common

To help you get started, we’ve selected a few @teleporthq/teleport-plugin-common examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github teleporthq / teleport-code-generators / packages / teleport-plugin-vue-head-config / src / index.ts View on Github external
if (uidl.seo.assets) {
      uidl.seo.assets.forEach((asset) => {
        // TODO: Handle other asset types when needed
        if (asset.type === 'canonical') {
          headObject.link = [{ rel: 'canonical', href: asset.path }]
        }
      })
    }

    if (Object.keys(headObject).length > 0) {
      const exportObjectAST = componentChunk.content.declaration as types.ObjectExpression
      exportObjectAST.properties.push(
        types.objectProperty(
          types.identifier(metaObjectKey),
          ASTUtils.objectToObjectExpression(headObject)
        )
      )
    }

    return structure
  }
github teleporthq / teleport-code-generators / packages / teleport-plugin-vue-base-component / src / utils.ts View on Github external
if (componentDependencies.length) {
    const componentsAST = t.objectExpression([
      ...componentDependencies.map((declarationName) => {
        return t.objectProperty(
          t.identifier(declarationName),
          t.identifier(declarationName),
          false,
          true
        )
      }),
    ])
    vueObjectProperties.push(t.objectProperty(t.identifier('components'), componentsAST))
  }

  if (Object.keys(dataObject).length > 0) {
    const dataAST = ASTUtils.objectToObjectExpression(dataObject)
    vueObjectProperties.push(
      t.objectMethod(
        'method',
        t.identifier('data'),
        [],
        t.blockStatement([t.returnStatement(dataAST)])
      )
    )
  }

  if (Object.keys(methodsObject).length > 0) {
    const methodsAST = createMethodsObject(methodsObject, uidl.propDefinitions)
    vueObjectProperties.push(
      t.objectProperty(t.identifier('methods'), t.objectExpression(methodsAST))
    )
  }
github teleporthq / teleport-code-generators / packages / teleport-plugin-jsx-proptypes / src / utils.ts View on Github external
}
      return acc
    },
    { values: {}, count: 0 }
  )

  if (defaultValuesSearch.count === 0) {
    return null
  }

  const memberExpression = t.memberExpression(
    t.identifier(componentName),
    t.identifier('defaultProps')
  )

  const memberExpressionValue = ASTUtils.objectToObjectExpression(defaultValuesSearch.values)

  const assignmentExpression = t.assignmentExpression('=', memberExpression, memberExpressionValue)

  return t.expressionStatement(assignmentExpression)
}
github teleporthq / teleport-code-generators / packages / teleport-plugin-react-jss / src / index.ts View on Github external
}

    dependencies.injectSheet = {
      type: 'library',
      path: 'react-jss',
      version: '8.6.1',
    }

    chunks.push({
      type: ChunkType.AST,
      fileType: FileType.JS,
      name: styleChunkName,
      linkAfter: [importChunkName],
      content: ASTBuilders.createConstAssignment(
        jssDeclarationName,
        ASTUtils.objectToObjectExpression(jssStyleMap)
      ),
    })

    const exportChunk = chunks.find((chunk) => chunk.name === exportChunkName)

    const componentName = UIDLUtils.getComponentClassName(uidl)
    const exportStatement = ASTBuilders.createReactJSSDefaultExport(
      componentName,
      jssDeclarationName
    )

    if (exportChunk) {
      exportChunk.content = exportStatement
      exportChunk.linkAfter = [importChunkName, styleChunkName]
    } else {
      chunks.push({
github teleporthq / teleport-code-generators / packages / teleport-plugin-vue-base-component / src / utils.ts View on Github external
export const generateVueComponentJS = (
  uidl: ComponentUIDL,
  componentDependencies: string[],
  dataObject: Record,
  methodsObject: Record,
  t = types
) => {
  const vueObjectProperties = []

  if (uidl.propDefinitions) {
    const props = createVuePropsDefinition(uidl.propDefinitions)
    const propsAST = ASTUtils.objectToObjectExpression(props)
    vueObjectProperties.push(t.objectProperty(t.identifier('props'), propsAST))
  }

  if (componentDependencies.length) {
    const componentsAST = t.objectExpression([
      ...componentDependencies.map((declarationName) => {
        return t.objectProperty(
          t.identifier(declarationName),
          t.identifier(declarationName),
          false,
          true
        )
      }),
    ])
    vueObjectProperties.push(t.objectProperty(t.identifier('components'), componentsAST))
  }
github teleporthq / teleport-code-generators / packages / teleport-plugin-angular-base-component / src / utils.ts View on Github external
metaTags.forEach((tag: UIDLMetaTag) => {
    metaTagsAST.push(ASTUtils.objectToObjectExpression(tag))
  })
  return metaTagsAST

@teleporthq/teleport-plugin-common

Common building and modelating functions for ASTs and HASTs

MIT
Latest version published 2 days ago

Package Health Score

82 / 100
Full package analysis

Similar packages