import { Component, AsyncComponent, ComponentOptions, FunctionalComponentOptions, DirectiveOptions, DirectiveFunction, RecordPropsDefinition, ThisTypedComponentOptionsWithArrayProps, ThisTypedComponentOptionsWithRecordProps, WatchOptions } from './options' import { KNode, KNodeData, KNodeChildren, NormalizedScopedSlot } from './knode' import { PluginFunction, PluginObject } from './plugin' import { DefineComponent } from './v3-define-component' import { nextTick, UnwrapNestedRefs, ShallowUnwrapRef } from './v3-generated' import { UnwrapMixinsType, IntersectionMixin } from './v3-component-public-instance' import { ExtractComputedReturns, ComponentOptionsMixin } from './v3-component-options' import { Directive, ObjectDirective } from './v3-directive' export interface CreateElement { ( tag?: | string | Component | AsyncComponent | (() => Component), children?: KNodeChildren ): KNode ( tag?: | string | Component | AsyncComponent | (() => Component), data?: KNodeData, children?: KNodeChildren ): KNode } type NeverFallback = [T] extends [never] ? D : T export interface Kdu< Data = Record, Props = Record, Instance = never, Options = never, Emit = (event: string, ...args: any[]) => Kdu > { // properties with different types in defineComponent() readonly $data: Data readonly $props: Props readonly $parent: NeverFallback | null readonly $root: NeverFallback readonly $children: NeverFallback[] readonly $options: NeverFallback> $emit: Emit // Kdu 2 only or shared readonly $el: Element readonly $refs: { [key: string]: | NeverFallback | Kdu | Element | (NeverFallback | Kdu | Element)[] | undefined } readonly $slots: { [key: string]: KNode[] | undefined } readonly $scopedSlots: { [key: string]: NormalizedScopedSlot | undefined } readonly $isServer: boolean readonly $ssrContext: any readonly $knode: KNode readonly $attrs: Record readonly $listeners: Record $mount(elementOrSelector?: Element | string, hydrating?: boolean): this $forceUpdate(): void $destroy(): void $set: typeof Kdu.set $delete: typeof Kdu.delete $watch( expOrFn: string, callback: (this: this, n: any, o: any) => void, options?: WatchOptions ): () => void $watch( expOrFn: (this: this) => T, callback: (this: this, n: T, o: T) => void, options?: WatchOptions ): () => void $on(event: string | string[], callback: Function): this $once(event: string | string[], callback: Function): this $off(event?: string | string[], callback?: Function): this $nextTick: typeof nextTick $createElement: CreateElement } export type CombinedKduInstance< Instance extends Kdu, Data, Methods, Computed, Props, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin, PublicMixin = IntersectionMixin & IntersectionMixin > = UnwrapNestedRefs> & Data & UnwrapMixinsType & Methods & ExtractComputedReturns> & Computed & UnwrapMixinsType & Props & Instance & ShallowUnwrapRef> & (SetupBindings extends void ? {} : SetupBindings) export type ExtendedKdu< Instance extends Kdu, Data, Methods, Computed, Props, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin > = KduConstructor< CombinedKduInstance< Instance, Data, Methods, Computed, Props, SetupBindings, Mixin, Extends > & Kdu > export interface KduConfiguration { silent: boolean optionMergeStrategies: any devtools: boolean productionTip: boolean performance: boolean errorHandler(err: Error, vm: Kdu, info: string): void warnHandler(msg: string, vm: Kdu, trace: string): void ignoredElements: (string | RegExp)[] keyCodes: { [key: string]: number | number[] } async: boolean } export interface KduConstructor { /** * new with array props */ new < Data = object, Methods = object, Computed = object, PropNames extends string = never, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( options?: ThisTypedComponentOptionsWithArrayProps< V, Data, Methods, Computed, PropNames, SetupBindings, Mixin, Extends > ): CombinedKduInstance< V, Data, Methods, Computed, Record, SetupBindings, Mixin, Extends > /** * new with object props * ideally, the return type should just contain Props, * not Record. But TS requires to have Base constructors * with the same return type. */ new < Data = object, Methods = object, Computed = object, Props = object, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( options?: ThisTypedComponentOptionsWithRecordProps< V, Data, Methods, Computed, Props, SetupBindings, Mixin, Extends > ): CombinedKduInstance< V, Data, Methods, Computed, Record, SetupBindings, Mixin, Extends > /** * new with no props */ new (options?: ComponentOptions): CombinedKduInstance< V, object, object, object, Record, {} > /** * extend with array props */ extend< Data, Methods, Computed, PropNames extends string = never, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( options?: ThisTypedComponentOptionsWithArrayProps< V, Data, Methods, Computed, PropNames, SetupBindings, Mixin, Extends > ): ExtendedKdu< V, Data, Methods, Computed, Record, SetupBindings, Mixin, Extends > /** * extend with object props */ extend< Data, Methods, Computed, Props, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( options?: ThisTypedComponentOptionsWithRecordProps< V, Data, Methods, Computed, Props, SetupBindings, Mixin, Extends > ): ExtendedKdu< V, Data, Methods, Computed, Props, SetupBindings, Mixin, Extends > /** * extend with functional + array props */ extend( definition: FunctionalComponentOptions, PropNames[]> ): ExtendedKdu, {}> /** * extend with functional + object props */ extend( definition: FunctionalComponentOptions> ): ExtendedKdu /** * extend with no props */ extend(options?: ComponentOptions): ExtendedKdu nextTick(callback: (this: T) => void, context?: T): void nextTick(): Promise set(object: object, key: string | number, value: T): T set(array: T[], key: number, value: T): T delete(object: object, key: string | number): void delete(array: T[], key: number): void directive( id: string, definition?: DirectiveOptions | DirectiveFunction ): DirectiveOptions directive( id: string, definition?: Directive ): ObjectDirective filter(id: string, definition?: Function): Function component(id: string): KduConstructor component(id: string, constructor: VC): VC component( id: string, definition: AsyncComponent ): ExtendedKdu component< Data, Methods, Computed, PropNames extends string = never, SetupBindings = {}, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( id: string, definition?: ThisTypedComponentOptionsWithArrayProps< V, Data, Methods, Computed, PropNames, SetupBindings, Mixin, Extends > ): ExtendedKdu< V, Data, Methods, Computed, Record, SetupBindings, Mixin, Extends > component< Data, Methods, Computed, Props, SetupBindings, Mixin extends ComponentOptionsMixin = ComponentOptionsMixin, Extends extends ComponentOptionsMixin = ComponentOptionsMixin >( id: string, definition?: ThisTypedComponentOptionsWithRecordProps< V, Data, Methods, Computed, Props, SetupBindings, Mixin, Extends > ): ExtendedKdu component( id: string, definition: FunctionalComponentOptions, PropNames[]> ): ExtendedKdu, {}> component( id: string, definition: FunctionalComponentOptions> ): ExtendedKdu component( id: string, definition?: ComponentOptions ): ExtendedKdu component>( id: string, definition?: T ): T use( plugin: PluginObject | PluginFunction, options?: T ): KduConstructor use( plugin: PluginObject | PluginFunction, ...options: any[] ): KduConstructor mixin(mixin: KduConstructor | ComponentOptions): KduConstructor compile(template: string): { render(createElement: typeof Kdu.prototype.$createElement): KNode staticRenderFns: (() => KNode)[] } observable(obj: T): T util: { warn(msg: string, vm?: InstanceType): void } config: KduConfiguration version: string } export const Kdu: KduConstructor