import ts from "typescript"; import { InjectDIToken, Injector } from "@bonbons/di"; import { IComponentAttachMap, IComponentInputMap, IComponentPropMap, IDirectiveInputMap, IPureObject, MapValueType } from "./common"; import { ContextItemsGroup, IFinalScopedContext, IScopeStructure, SourceFileContext } from "./context"; import { IInnerCompnentChildRef, IInnerCompositionChildRef, IInnerDirectiveChildRef } from "../child-ref"; import { IInnerComponent } from "../component"; import { IInnerDirective } from "../directive"; import { IInnerComposition } from "../composition"; import { AnonymousStatementGenerator, ClassGenerator, FunctionGenerator, ImportGenerator, VariableGenerator } from "../typescript"; export declare type EntityType = "directive" | "component" | "composition" | "childref" | "componentChildRef" | "directiveChildRef" | "compositionChildRef" | "entity"; export declare type IBasicComponentAppendType = "push" | "unshift" | "reset"; export interface IBasicImportEntityCreateOptions { moduleName: string; templateName: string; importId: string; } export interface IDirectiveCreateOptions extends IBasicImportEntityCreateOptions { type: "directive"; } export interface IComponentCreateOptions extends IBasicImportEntityCreateOptions { type: "component"; } export interface ICompositionCreateOptions extends IBasicImportEntityCreateOptions { type: "composition"; } export interface IEntitiesGroup { components: IComponentCreateOptions[]; directives: IDirectiveCreateOptions[]; compositions: ICompositionCreateOptions[]; } export interface IDirecChildRefPluginOptions { /** entity id */ refEntityId: string; /** entity name will emit into source code */ entityName: string; options: { input: IDirectiveInputMap; }; } export interface ICompChildRefPluginOptions { /** entity id */ refEntityId: string; /** entity name will emit into source code */ entityName: string; components: IDynamicRefPluginOptions[]; directives: IDirecChildRefPluginOptions[]; options: { input: IComponentInputMap; attach: IComponentAttachMap; props: IComponentPropMap; }; } export interface ICompositeChildRefPluginOptions { /** entity id */ refEntityId: string; /** entity name will emit into source code */ entityName: string; components: IDynamicRefPluginOptions[]; options: { input: IComponentInputMap; }; } export declare type IDynamicRefPluginOptions = ICompChildRefPluginOptions | ICompositeChildRefPluginOptions; export interface IBasicEntityProvider { attachInstance(context: SourceFileContext, ref: IInnerCompnentChildRef): Promise; attachInstance(context: SourceFileContext, ref: IInnerDirectiveChildRef): Promise; attachInstance(context: SourceFileContext, ref: IInnerCompositionChildRef): Promise; resolveExtensionsMetadata(template: InjectDIToken): {}; beforeImportsCreated(context: SourceFileContext, imports: ImportGenerator[]): ImportGenerator[]; beforeVariablesCreated(context: SourceFileContext, variables: VariableGenerator[]): VariableGenerator[]; beforeClassesCreated(context: SourceFileContext, classes: ClassGenerator[]): ClassGenerator[]; beforeFunctionsCreated(context: SourceFileContext, funcs: FunctionGenerator[]): FunctionGenerator[]; beforeStatementsCreated(context: SourceFileContext, funcs: AnonymousStatementGenerator[]): AnonymousStatementGenerator[]; afterImportsCreated(context: SourceFileContext, imports: ts.ImportDeclaration[]): ts.ImportDeclaration[]; afterVariablesCreated(context: SourceFileContext, variables: ts.VariableStatement[]): ts.VariableStatement[]; afterClassesCreated(context: SourceFileContext, classes: ts.ClassDeclaration[]): ts.ClassDeclaration[]; afterFunctionsCreated(context: SourceFileContext, funcs: ts.FunctionDeclaration[]): ts.FunctionDeclaration[]; afterStatementsCreated(context: SourceFileContext, statements: ts.Statement[]): ts.Statement[]; } export interface IEwsEntity { readonly entityId: string; setScopeId(id: string): this; setParentId(id: string): this; } export interface IEwsEntityGetters { getImports(): IScopeStructure; getMethods(): IScopeStructure; getProperties(): IScopeStructure; getFields(): IScopeStructure; getImplementParents(): IScopeStructure; getExtendParent(): IScopeStructure; } export interface IEwsEntitySetters { addImports(args: ts.ImportDeclaration[], type?: IBasicComponentAppendType): void; addMethods(args: ts.MethodDeclaration[], type?: IBasicComponentAppendType): void; addProperties(args: ts.PropertyDeclaration[], type?: IBasicComponentAppendType): void; addFields(args: ts.PropertyDeclaration[], type?: IBasicComponentAppendType): void; addImplementParents(args: ts.HeritageClause[], type?: IBasicComponentAppendType): void; setExtendParent(arg: ts.HeritageClause | null): void; } export interface IEwsEntityState { setState(key: K, value: T[K]): void; getState(key: K, defaultValue?: T[K] | null): T[K]; } export interface IEwsEntityPrivates { readonly __scope: string; readonly __parent: string; readonly __etype: E; __context: SourceFileContext; injector: Injector; __addChildElements(target: keyof IFinalScopedContext, args: A[], type: IBasicComponentAppendType): void; __getChildElements(target: K): MapValueType; } export interface IEwsEntityProtectedHooks { onInit(): Promise; } export interface IInnerEwsEntity extends IEwsEntity, IEwsEntityState, IEwsEntitySetters, IEwsEntityGetters, IEwsEntityProtectedHooks, IEwsEntityPrivates { } export declare class BasicCompilationEntity { protected __scope: string; protected __parent: string; protected __etype: EntityType; protected __state: T; protected __context: SourceFileContext; protected injector: Injector; get entityId(): string; setScopeId(id: string): this; setParentId(id: string): this; protected onInit(): Promise; protected setState(key: K, value: T[K]): void; protected createNode(type: K): InstanceType; protected getState(key: K, defaultValue?: T[K] | null): T[K]; protected addImports(args: IFinalScopedContext["imports"], type?: IBasicComponentAppendType): void; protected getImports(): ImportGenerator[]; protected addVariables(args: IFinalScopedContext["variables"], type?: IBasicComponentAppendType): void; protected getVariables(): VariableGenerator[]; protected addClasses(args: IFinalScopedContext["classes"], type?: IBasicComponentAppendType): void; protected getClasses(): ClassGenerator[]; protected addFunctions(args: IFinalScopedContext["functions"], type?: IBasicComponentAppendType): void; protected getFunctions(): FunctionGenerator[]; private __addChildElements; private __getChildElements; } export declare function resolveSyntaxInsert(type: "string", expression: string): ts.StringLiteral; export declare function resolveSyntaxInsert(type: "number", expression: number): ts.NumericLiteral; export declare function resolveSyntaxInsert(type: "boolean", expression: boolean): ts.BooleanLiteral; export declare function resolveSyntaxInsert(type: string, expression: any, otherHandler?: (type: string, exp: any) => ts.Expression | null): ts.BooleanLiteral;