import { Application , ApplicationConfig , isApplicationConfig , Environment , } from '../core/mod.ts' ; import ApplicationEventsMark from "./application_events_mark.ts" ; import { Reflect } from "../../third_party/Reflect.ts" ; import { APPLICATION_EVENTS_MARK_KEY } from "./metadata_keys.ts" ; import { Constructor , Util } from "../util/mod.ts" ; import { injectable } from "./injectable.ts" ; export function MainApplication ( config ) ; export function MainApplication ( target ) ; export function MainApplication ( arg ) { const fn = ( target , config ? ) => { injectable ( target ) ; Environment . shard . run ( new target ( config ) ) . then ( ) ; } ; if ( isApplicationConfig ( arg ) ) { return fn ; } fn ( arg ) ; } export function getEventsMarkInApplication ( application ) { const prototype = Object . getPrototypeOf ( application ) ; const methodName = Object . getOwnPropertyNames ( prototype ) . filter ( item => Util . isFunction ( prototype [ item ] ) && ! Util . canBeConstructed ( prototype [ item ] ) ) ; return methodName . map ( method => { const fn = prototype [ method ] ; const configure = Reflect . getMetadata ( APPLICATION_EVENTS_MARK_KEY , fn ) ; return configure ; } ) . filter ( i => i ) ; }