import type * as d from '../../../declarations' ; import ts from 'typescript' ; export const addNativeConnectedCallback = ( classMembers , cmp ) => { if ( cmp . isPlain && cmp . hasRenderFn ) { const fnCall = ts . createExpressionStatement ( ts . createAssignment ( ts . createPropertyAccess ( ts . createThis ( ) , 'textContent' ) , ts . createCall ( ts . createPropertyAccess ( ts . createThis ( ) , 'render' ) , undefined , undefined ) ) ) ; const connectedCallback = classMembers . find ( ( classMember ) => { return ts . isMethodDeclaration ( classMember ) && ( classMember . name as any ) . escapedText === 'connectedCallback' ; } ) as ts . MethodDeclaration ; if ( connectedCallback != null ) { const callbackMethod = ts . createMethod ( undefined , undefined , undefined , 'connectedCallback' , undefined , undefined , undefined , undefined , ts . createBlock ( [ fnCall , ... connectedCallback . body . statements ] , true ) ) ; const index = classMembers . indexOf ( connectedCallback ) ; classMembers [ index ] = callbackMethod ; } else { const callbackMethod = ts . createMethod ( undefined , undefined , undefined , 'connectedCallback' , undefined , undefined , undefined , undefined , ts . createBlock ( [ fnCall ] , true ) ) ; classMembers . push ( callbackMethod ) ; } } } ;