How to use the @teleporthq/teleport-plugin-common.ASTBuilders.createComponentDecorator 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-angular-base-component / src / index.ts View on Github external
type: ChunkType.HAST,
      name: angularTemplateChunkName,
      fileType: FileType.HTML,
      meta: {
        nodesLookup: templateLookup,
      },
      content: templateContent,
      linkAfter: [],
    })

    const componentName = UIDLUtils.getComponentClassName(uidl)
    const params = {
      selector: UIDLUtils.createWebComponentFriendlyName(componentName),
      templateUrl: `${UIDLUtils.getComponentFileName(uidl)}.${FileType.HTML}`,
    }
    const componentDecoratorAST = ASTBuilders.createComponentDecorator(params)

    chunks.push({
      type: ChunkType.AST,
      name: componentDecoratorChunkName,
      fileType: FileType.TS,
      linkAfter: tsChunkAfter,
      content: componentDecoratorAST,
    })

    /* We need to import EventEmitter and Output in Angular to temit events to the parent
    So, to make sure if we need to import them we need to loop through all the methods and
    check if any of them are referring to the function that is passed as prop*/
    if (Object.keys(methodsObject).length > 0) {
      const shouldImportEventEmitter = Object.keys(methodsObject).some((method) => {
        const statements = methodsObject[method]
        if (statements.length > 0) {
github teleporthq / teleport-code-generators / packages / teleport-plugin-stencil-app-routing / src / index.ts View on Github external
const stencilAppRoutingtPlugin: ComponentPlugin = async (structure) => {
    const { chunks, uidl, dependencies } = structure

    dependencies.Component = STENCIL_CORE_DEPENDENCY
    dependencies.h = STENCIL_CORE_DEPENDENCY

    const routes = UIDLUtils.extractRoutes(uidl)
    const routeDefinitions = uidl.stateDefinitions.route

    /* The name should be injected only with AppRoot only then it acts as entry point,
    Sending only Root because app is appended while generation of decorators*/
    const params = {
      tag: 'app-root',
      shadow: true,
    }
    const decoratorAST = ASTBuilders.createComponentDecorator(params)

    chunks.push({
      name: componentDecoratorChunkName,
      type: ChunkType.AST,
      fileType: FileType.TSX,
      content: [decoratorAST],
      linkAfter: [importChunkName],
    })

    const classDeclarationAST = createClassDeclaration(routes, routeDefinitions)

    chunks.push({
      name: componentChunkName,
      type: ChunkType.AST,
      fileType: FileType.TSX,
      content: classDeclarationAST,
github teleporthq / teleport-code-generators / packages / teleport-plugin-stencil-base-component / src / index.ts View on Github external
}

    const componentName = UIDLUtils.getComponentClassName(uidl)
    const exportAST = createClassDeclaration(
      componentName,
      propDefinitions,
      stateDefinitions,
      jsxTagStructure
    )

    const params = {
      tag: UIDLUtils.createWebComponentFriendlyName(componentName),
      shadow: true,
    }

    const decoratorAST = ASTBuilders.createComponentDecorator(params)

    structure.chunks.push({
      type: ChunkType.AST,
      fileType: FileType.TSX,
      name: componentDecoratorChunkName,
      meta: {
        nodesLookup,
      },
      content: decoratorAST,
      linkAfter: [importChunkName],
    })

    structure.chunks.push({
      type: ChunkType.AST,
      fileType: FileType.TSX,
      name: componentChunkName,

@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