import { Attributes } from 'react'; import { CElement } from 'react'; import { CFactory } from 'react'; import { ChildContextProvider } from 'react'; import { ClassAttributes } from 'react'; import { ClassicComponent } from 'react'; import { ClassicComponentClass } from 'react'; import { ClassicElement } from 'react'; import { ClassicFactory } from 'react'; import { ClassType } from 'react'; import { cloneElement } from 'react'; import { Component } from 'react'; import { ComponentClass } from 'react'; import { ComponentElement } from 'react'; import { ComponentFactory } from 'react'; import { ComponentLifecycle } from 'react'; import { ComponentProps } from 'react'; import { ComponentPropsWithoutRef } from 'react'; import { ComponentPropsWithRef } from 'react'; import { ComponentRef } from 'react'; import { ComponentSpec } from 'react'; import { ComponentState } from 'react'; import { ComponentType } from 'react'; import { Consumer } from 'react'; import { ConsumerProps } from 'react'; import { Context } from 'react'; import { ContextType } from 'react'; import { createContext } from 'react'; import { createElement } from 'react'; import { createRef } from 'react'; import { CustomComponentPropsWithRef } from 'react'; import { DependencyList } from 'react'; import { DeprecatedLifecycle } from 'react'; import { Dispatch } from 'react'; import { DispatchWithoutAction } from 'react'; import { EffectCallback } from 'react'; import { ElementRef } from 'react'; import { ElementType } from 'react'; import { ExoticComponent } from 'react'; import { Factory } from 'react'; import { FC } from 'react'; import { ForwardedRef } from 'react'; import { forwardRef } from 'react'; import { ForwardRefExoticComponent } from 'react'; import { ForwardRefRenderFunction } from 'react'; import { Fragment } from 'react'; import { FunctionComponent } from 'react'; import { FunctionComponentElement } from 'react'; import { FunctionComponentFactory } from 'react'; import { GetDerivedStateFromError } from 'react'; import { GetDerivedStateFromProps } from 'react'; import { isValidElement } from 'react'; import { JSXElementConstructor } from 'react'; import { Key } from 'react'; import { lazy } from 'react'; import { LazyExoticComponent } from 'react'; import { LegacyRef } from 'react'; import { memo } from 'react'; import { MemoExoticComponent } from 'react'; import { Mixin } from 'react'; import { MutableRefObject } from 'react'; import { NamedExoticComponent } from 'react'; import { NewLifecycle } from 'react'; import { PropsWithChildren } from 'react'; import { PropsWithoutRef } from 'react'; import { PropsWithRef } from 'react'; import { Provider } from 'react'; import { ProviderExoticComponent } from 'react'; import { ProviderProps } from 'react'; import { PureComponent } from 'react'; import { ReactComponentElement } from 'react'; import { ReactElement } from 'react'; import { ReactInstance } from 'react'; import { ReactNode } from 'react'; import { Reducer } from 'react'; import { ReducerAction } from 'react'; import { ReducerState } from 'react'; import { ReducerStateWithoutAction } from 'react'; import { ReducerWithoutAction } from 'react'; import { Ref } from 'react'; import { RefAttributes } from 'react'; import { RefCallback } from 'react'; import { RefObject } from 'react'; import { SetStateAction } from 'react'; import { SFCFactory } from 'react'; import { StaticLifecycle } from 'react'; import { Suspense } from 'react'; import { SVGFactory } from 'react'; import { TransitionFunction } from 'react'; import { TransitionStartFunction } from 'react'; import { useCallback } from 'react'; import { useContext } from 'react'; import { useDebugValue } from 'react'; import { useEffect } from 'react'; import { useImperativeHandle } from 'react'; import { useMemo } from 'react'; import { useReducer } from 'react'; import { useRef } from 'react'; import { useState } from 'react'; import { useSyncExternalStore } from 'react'; import { VFC } from 'react'; import { VoidFunctionComponent } from 'react'; declare interface AgreePrivacyResult { /** Whether the save was successful */ result: boolean; } declare interface AIAppMetadata { /** * * 豆包应用 ID * */ appId: string; /** * 应用名称 */ name?: string; /** * 应用描述 */ description?: string; /** * 应用图标 * * 1x, 2x, 3x 分别对应 1x, 2x, 3x 倍的图标 */ icons?: Icons; /** * 应用关键词 */ keywords?: string[]; /** * 应用版本 */ version?: string; } export declare type AIToolContext = MessageMeta & { /** * callback Id */ callbackId: string; /** * feature map */ featureMap: Record | undefined; }; export declare type AIViewContext = MessageMeta & { /** * View ID */ viewId: string; /** * this message is replying for which message */ replyFor: string; /** * this page name */ pageName: string; /** * The view setting info */ appSettings: Record; /** * Language type */ lang: string; /** * Custom extra message from client */ extra?: { /** * Width of widget container */ width: number; /** * Height of widget container */ height: number; }; }; export declare type AnyObject = Record; export declare type App = T & { __APP__: boolean; __UI__: boolean; }; declare type AppAIMeta = Omit & { appId?: string; package?: string; }; export { Attributes } export { CElement } export { CFactory } export { ChildContextProvider } export { ClassAttributes } export { ClassicComponent } export { ClassicComponentClass } export { ClassicElement } export { ClassicFactory } export { ClassType } export { cloneElement } export { Component } export { ComponentClass } export { ComponentElement } export { ComponentFactory } export { ComponentLifecycle } export { ComponentProps } export { ComponentPropsWithoutRef } export { ComponentPropsWithRef } export { ComponentRef } export { ComponentSpec } export { ComponentState } export { ComponentType } export { Consumer } export { ConsumerProps } export { Context } export { ContextType } export { createContext } export { createElement } export { createRef } export declare interface CurrentPage { route: string; } export { CustomComponentPropsWithRef } export declare function defineApp(options: T & ThisType): App; export declare interface DefineAppOptions { [key: string]: any; /** * @deprecated Configure app metadata in src/app.config.ts instead. * * @example * ```ts * // src/app.config.ts * import { defineAppConfig } from '@doubao-apps/framework/config'; * * export default defineAppConfig({ * appId: 'your-app-id', * name: 'Demo App', * description: 'Describe what this app can do', * icons: 'https://example.com/icon.png', * keywords: ['demo', 'doubao'] * }); * ``` */ aiMeta?: AppAIMeta; /** * App launched */ onLaunch?: () => void; /** * On page opened */ onPageOpened?: (params: { viewId: string; }) => void; /** * On foreground */ onForeground?: () => void; /** * On background */ onBackground?: () => void; /** * On destroy */ onDestroy?: () => void; /** * Handle errors from other lifecycle hooks in this class or from tools in same Applet */ onError?: (e: Error) => void; } export declare interface DefineFunctionalToolOptions extends Tool { onApply: (input: string, context: AIToolContext) => string | object | Promise; } export declare function defineLoginApi(api: LoginApi): LoginApi; /** * 定义 MCP 登录页面 * @param options 定义 MCP 登录页面的选项 * @returns 小程序 MCP 登录页面 */ export declare function defineLoginPage(options: Omit, 'aiMeta'> & ThisType>>): Page; export declare function definePage(options: DefinePageToolOptions & ThisType>>): Page; export declare interface DefinePageToolOptions extends DefineUIToolOptions { /** * @deprecated Configure page metadata in src/app.config.ts instead. * * Use `pages` entries in `src/app.config.ts`. For example, * `pages/home/index` maps to `src/pages/home/index.tsx`, and * `pages/account/demo/index` maps to `src/pages/account/demo/index.tsx`. * * @example * ```ts * // src/app.config.ts * import { defineAppConfig } from '@doubao-apps/framework/config'; * * export default defineAppConfig({ * appId: 'your-app-id', * pages: ['pages/home/index'] * }); * ``` */ aiMeta?: PageToolMetadata; } export declare function definePrivacyApi(api: PrivacyApi): PrivacyApi; /** * 定义 MCP 同意登录和隐私协议卡片组件 * @param options 定义 MCP 同意登录和隐私协议卡片组件的选项 * @returns MCP 同意登录和隐私协议卡片组件 */ export declare function definePrivacyLoginWidget(options: Omit, 'aiMeta'> & ThisType>>): Widget; export declare function defineTool(options: DefineFunctionalToolOptions & ThisType>): FunctionalTool; export declare interface DefineUIToolOptions extends Tool { /** * Initial data */ data?: Data; /** * Trigger on view created * @returns */ onCreated?: () => void; /** * It is triggered after the view is rendered and will only be called once in the view's life cycle. * @returns */ onMounted?: () => void; /** * 1. It is triggered when the view is first displayed. * 2. It is triggered when the view is displayed again after being hidden. * @returns */ onShow?: () => void; /** * It is triggered when the view is hidden. * @returns */ onHide?: () => void; /** * It is triggered when the view is destroyed. * @returns */ onDestroy?: () => void; /** * It is triggered when an error occurs. * @param e * @returns */ onError?: (e: Error) => void; /** * Render function * Use getViewData() and getViewContext() to access data and context * @returns */ render: () => ReactNode; } export declare function defineWidget(options: DefineWidgetToolOptions & ThisType>>): Widget; export declare interface DefineWidgetToolOptions extends DefineUIToolOptions { /** * @deprecated Configure widget metadata in src/app.config.ts instead. * * Use `widgets` entries in `src/app.config.ts`. For example, * `widgets/card/index` maps to `src/widgets/card/index.tsx`, and * `widgets/api/demo/index` maps to `src/widgets/api/demo/index.tsx`. * * @example * ```ts * // src/app.config.ts * import { defineAppConfig } from '@doubao-apps/framework/config'; * * export default defineAppConfig({ * appId: 'your-app-id', * widgets: [ * { * entry: 'widgets/card/index', * id: 'card-widget', * name: 'Card Widget', * description: 'Show card content', * border: true * } * ] * }); * ``` */ aiMeta?: WidgetToolMetadata; /** * 1. It is triggered when the app returns to the foreground from the background. * 2. It is triggered when phone is unlocked. * @returns */ onForeground?: () => void; /** * 1. It is triggered when the app is moved to the background. * 2. It is triggered when phone is locked. * @returns */ onBackground?: () => void; } export { DependencyList } export { DeprecatedLifecycle } export { Dispatch } export { DispatchWithoutAction } /** 当前小程序基础库版本。 */ export declare const DoubaoAppsSDKVersion: string; export { EffectCallback } export { ElementRef } export { ElementType } export { ExoticComponent } export { Factory } export { FC } export { ForwardedRef } export { forwardRef } export { ForwardRefExoticComponent } export { ForwardRefRenderFunction } export { Fragment } export declare interface FunctionalTool extends DefineFunctionalToolOptions { __FUNCTIONAL__: boolean; } declare type FunctionalToolInstanceMethods = Tool; export { FunctionComponent } export { FunctionComponentElement } export { FunctionComponentFactory } export declare function getApp(): T; export declare function getCurrentPages(): CurrentPage[]; export { GetDerivedStateFromError } export { GetDerivedStateFromProps } declare interface GetPhoneNumberResult { code?: string; message?: string; } export declare function getViewContext(): any; export declare function getViewData>(): T; export declare function getWidgetInstanceId(): string | undefined; declare type Icons = string | Record<'1x' | '2x' | '3x', string>; export { isValidElement } export { JSXElementConstructor } export { Key } export { lazy } export { LazyExoticComponent } export { LegacyRef } declare type LifecycleCallback = () => void; declare type LifecycleErrorCallback = (error: Error) => void; export declare interface LoginApi { onLogin: (res: LoginResult) => Promise | void; onRefuseLogin: () => Promise | void; } export declare type LoginResult = GetPhoneNumberResult; export { memo } export { MemoExoticComponent } export declare interface MessageMeta { /** * Bot ID */ botId: string; /** * message ID */ msgId: string; /** * IM message create time */ msgCreateTime: number; /** * IM message received time */ msgReceivedTime: number; /** * conversation ID */ conversationId?: string; } export { Mixin } export { MutableRefObject } export { NamedExoticComponent } export { NewLifecycle } export declare interface Page extends DefineUIToolOptions { __UI__: boolean; __PAGE__: boolean; } declare type PageInstanceMethods = UIInstanceMethods; declare type PageToolExtraMetadata = { /** * The page navbar title */ title?: string; }; export declare type PageToolMetadata = ToolMeta & PageToolExtraMetadata; export declare type PrivacyAgreeResult = AgreePrivacyResult; export declare interface PrivacyApi { onAgreePrivacy: (res: PrivacyAgreeResult) => Promise | void; onRefusePrivacy: () => Promise | void; } export { PropsWithChildren } export { PropsWithoutRef } export { PropsWithRef } export { Provider } export { ProviderExoticComponent } export { ProviderProps } export { PureComponent } export { ReactComponentElement } export { ReactElement } export { ReactInstance } export { ReactNode } export { Reducer } export { ReducerAction } export { ReducerState } export { ReducerStateWithoutAction } export { ReducerWithoutAction } export { Ref } export { RefAttributes } export { RefCallback } export { RefObject } export { SetStateAction } export { SFCFactory } export { StaticLifecycle } export { Suspense } export { SVGFactory } export declare interface Tool { aiMeta?: ToolMeta & Extra; } export declare interface ToolMeta { /** * unique identifier */ id: string; /** * name of the tool */ name?: string; /** * description of the tool */ description?: string; /** * Widget title type * - none: 默认,无标题 * - normal: 常规标题 * - float: 浮动标题 */ titleType?: 'none' | 'normal' | 'float'; } export declare type ToolMetadata = { /** * specifies when a call to a tool will time out, in ms. */ timeout?: number; }; export { TransitionFunction } export { TransitionStartFunction } export declare interface UIInstanceMethods extends Tool { /** * Instance data */ data: Data; /** * Set data asynchronously and trigger view re-rendering * @param data * @param callback * @returns */ setData: (data: Partial & AnyObject, callback?: () => void) => Promise; } export declare function useBackground(callback: LifecycleCallback): void; export { useCallback } export { useContext } export declare function useCreated(callback: LifecycleCallback): void; export { useDebugValue } export declare function useDestroy(callback: LifecycleCallback): void; export { useEffect } export declare function useError(callback: LifecycleErrorCallback): void; export declare function useForeground(callback: LifecycleCallback): void; export declare function useHide(callback: LifecycleCallback): void; export { useImperativeHandle } export { useMemo } export declare function useMounted(callback: LifecycleCallback): void; export { useReducer } export { useRef } export declare function useShow(callback: LifecycleCallback): void; export { useState } export { useSyncExternalStore } export declare function useViewData = Record>(): T; export { VFC } export { VoidFunctionComponent } export declare interface Widget extends DefineWidgetToolOptions { __UI__: boolean; __WIDGET__: boolean; setData: (data: Partial, callback?: () => void) => void; } declare type WidgetInstanceMethods = UIInstanceMethods; declare type WidgetToolExtraMetadata = { /** * Widget box type in Chat UI */ boxType?: 'inbox' | 'full_box'; /** * Whether add widget border */ border?: boolean; /** * Keywords of things */ keywords?: string[]; /** * Icons */ icons?: Icons; /** * Set extra widget properties */ prop?: string; }; export declare type WidgetToolMetadata = ToolMeta & WidgetToolExtraMetadata; export { }