import type { InnerRenderFn, IntermediateSegment } from './renderer/types'; import type { Interfaceable, ServiceProvision, ServiceContainer, ServiceInterface, ServiceScope, MaybeContainer } from './service'; import type { DispatchFrame, DispatchResponse } from './engine/types'; import type { MACHINAT_ELEMENT_TYPE, MACHINAT_NATIVE_TYPE, MACHINAT_FRAGMENT_TYPE, MACHINAT_PAUSE_TYPE, MACHINAT_PROVIDER_TYPE, MACHINAT_THUNK_TYPE, MACHINAT_RAW_TYPE } from './symbol'; export type { default as MachinatApp } from './app'; export type { MachinatProfile } from './base/Profiler'; export declare type MachinatRenderable = MachinatText | GeneralElement | PauseElement | ProviderElement | RawElement | ThunkElement | FunctionalElement | ContainerElement; export declare type MachinatNode = MachinatEmpty | MachinatRenderable | ThunkElement | Array; export declare type MachinatElementType = string | FunctionalComponent | ContainerComponent | NativeComponent | typeof MACHINAT_FRAGMENT_TYPE | typeof MACHINAT_PAUSE_TYPE | typeof MACHINAT_PROVIDER_TYPE | typeof MACHINAT_THUNK_TYPE | typeof MACHINAT_RAW_TYPE; export declare type MachinatElement = { $$typeof: typeof MACHINAT_ELEMENT_TYPE; type: T; props: P; }; export declare type MachinatText = string | number; export declare type MachinatEmpty = null | undefined | boolean; export declare type GeneralElement = MachinatElement<{ [key: string]: any; }, string>; declare type RenderEnv = { path: string; platform: string; }; export declare type FunctionalComponent = (props: Props, circs: RenderEnv) => MachinatElement; export declare type FunctionalElement> = MachinatElement; declare type ContainerComponentFn = (props: Props, circs: RenderEnv) => MachinatNode | Promise; export declare type ContainerComponent = ServiceContainer, unknown[]>; export declare type ContainerElement> = MachinatElement; export declare type NativeComponent> = { (element: NativeElement>, path: string, render: InnerRenderFn): null | Segment[] | Promise; $$typeof: typeof MACHINAT_NATIVE_TYPE; $$platform: string; new (): NativeComponent; }; export declare type NativeElement> = MachinatElement; export declare type FragmentProps = { children: MachinatNode; }; export declare type FragmentElement = MachinatElement; export declare type ProviderProps = { provide: Interfaceable; value: unknown; children: MachinatNode; }; export declare type ProviderElement = MachinatElement; export declare type PauseDelayFn = () => Promise; export declare type PauseProps = { time?: number; delay?: PauseDelayFn; }; export declare type PauseElement = MachinatElement; export declare type ThunkEffectFn = () => unknown | Promise; export declare type ThunkProps = { effect: ThunkEffectFn; }; export declare type ThunkElement = MachinatElement; export declare type RawProps = { value: unknown; }; export declare type RawElement = MachinatElement; export interface MachinatChannel { readonly platform: string; readonly uid: string; } export interface MachinatUser { readonly platform: string; readonly uid: string; } export interface MachinatEvent { readonly platform: string; readonly category: string; readonly type: string; readonly payload: Payload; readonly channel: null | MachinatChannel; readonly user: null | MachinatUser; } export interface TextMessageMixin { readonly category: 'message'; readonly type: 'text'; readonly text: string; } export interface MediaMessageMixin { readonly category: 'message'; readonly type: 'image' | 'video' | 'audio' | 'file'; readonly url?: string; } export interface LocationMessageMixin { readonly category: 'message'; readonly type: 'location'; readonly latitude: number; readonly longitude: number; } export interface PostbackMixin { readonly category: 'postback'; readonly type: string; readonly data: string; } export interface MachinatMetadata { source: string; } export interface MachinatBot { render(channel: Channel, message: MachinatNode): Promise>; } export declare type EventContext, Metadata extends MachinatMetadata, Bot extends MachinatBot> = { platform: string; event: Event; metadata: Metadata; bot: Bot; reply(message: MachinatNode): ReturnType; }; export declare type AnyEventContext = EventContext; export declare type Middleware = (input: Input, next: (input: Input) => Promise) => Promise; export declare type EventMiddleware = Middleware; export declare type DispatchMiddleware, Result> = Middleware>; export declare type ServiceModule = { provisions: ServiceProvision[]; startHook?: null | ServiceContainer, unknown[]>; stopHook?: null | ServiceContainer, unknown[]>; }; export declare type MachinatPlatform, Result> = { name: string; utilitiesInterface: ServiceInterface>; provisions: ServiceProvision[]; startHook?: ServiceContainer, unknown[]>; stopHook?: null | ServiceContainer, unknown[]>; eventMiddlewares?: MaybeContainer>[]; dispatchMiddlewares?: MaybeContainer>[]; }; export declare type AnyMachinatPlatform = MachinatPlatform; export declare type AppConfig = { platforms?: Platform[]; modules?: ServiceModule[]; services?: ServiceProvision[]; }; export declare type EventContextOfPlatform = Platform extends MachinatPlatform ? Context : never; export declare type InitScopeFn = () => ServiceScope; export declare type PopEventFn = (context: Context, scope?: ServiceScope) => Promise; export declare type PopEventWrapper = (finalHandler: (ctx: Context) => Promise) => PopEventFn; export declare type PopErrorFn = (err: Error, scope?: ServiceScope) => void; export declare type DispatchFn, Result> = (frame: Frame, scope?: ServiceScope) => Promise>; export declare type DispatchWrapper, Result> = (dispatch: (frame: Frame) => Promise>) => DispatchFn; export declare type ModuleUtilities = { initScope: InitScopeFn; popError: PopErrorFn; }; export declare type PlatformUtilities, Result> = { popEventWrapper: PopEventWrapper; dispatchWrapper: DispatchWrapper; };