import type * as glassEasel from 'glass-easel' import type { utils as typeUtils } from '../types' import type { GeneralComponentType, GeneralBehavior, TraitBehavior } from '../behavior' import type { GeneralComponent } from '../component' export type ResolveBehaviorBuilder< B, TChainingFilter extends ChainingFilterType, > = typeUtils.IsNever extends false ? TChainingFilter extends ChainingFilterType ? Omit & TChainingFilter['add'] : B : B type DataList = typeUtils.DataList type PropertyList = typeUtils.PropertyList type ChainingFilterType = typeUtils.ChainingFilterType type ComponentMethod = typeUtils.ComponentMethod type TaggedMethod = typeUtils.TaggedMethod export interface RelationHandler { list(): TTarget[] listAsTrait: TOut extends never ? undefined : () => TOut[] } export type TraitRelationParams = { target: TraitBehavior type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node' linked?: (target: GeneralComponent) => void linkChanged?: (target: GeneralComponent) => void unlinked?: (target: GeneralComponent) => void linkFailed?: (target: GeneralComponent) => void } export type RelationParams = { target?: string | GeneralComponentType | GeneralBehavior | TraitBehavior type: 'ancestor' | 'descendant' | 'parent' | 'child' | 'parent-common-node' | 'child-common-node' linked?: (target: GeneralComponent) => void linkChanged?: (target: GeneralComponent) => void unlinked?: (target: GeneralComponent) => void linkFailed?: (target: GeneralComponent) => void } export type Lifetimes = { created: () => void attached: () => void moved: () => void detached: () => void ready: () => void } export interface BuilderContext< TPrevData extends DataList, TProperty extends PropertyList, TMethodCaller, > extends ThisType { self: TMethodCaller data: typeUtils.Merge> setData: ( this: void, newData: Partial>, callback?: () => void, ) => void implement: ( this: void, traitBehavior: TraitBehavior, impl: TIn, ) => void relation( this: void, def: TraitRelationParams & ThisType, ): RelationHandler relation(this: void, def: RelationParams & ThisType): RelationHandler observer< P extends typeUtils.ObserverDataPathStrings< typeUtils.DataWithPropertyValues >, V = typeUtils.GetFromObserverPathString< typeUtils.DataWithPropertyValues, P >, >( this: void, paths: P, func: (newValue: V) => void, ): void observer< P extends typeUtils.ObserverDataPathStrings< typeUtils.DataWithPropertyValues >[], V = { [K in keyof P]: typeUtils.GetFromObserverPathString< typeUtils.DataWithPropertyValues, P[K] > }, >( this: void, paths: readonly [...P], func: (...newValues: V extends any[] ? V : never) => void, ): void lifetime: (this: void, name: L, func: Lifetimes[L]) => void pageLifetime: (this: void, name: string, func: (...args: any[]) => void) => void method: (this: void, func: Fn) => TaggedMethod listener: ( this: void, func: glassEasel.EventListener, ) => TaggedMethod> }