@doubao-dev/framework 0.0.42 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components-style.css +1 -1
- package/dist/api.d.ts +738 -319
- package/dist/components.d.ts +54 -16
- package/dist/config.d.ts +12 -1
- package/dist/index.d.ts +458 -2
- package/jsx-runtime.d.ts +1 -0
- package/package.json +3 -2
- package/types.d.ts +3 -0
package/dist/components.d.ts
CHANGED
|
@@ -88,6 +88,10 @@ export declare interface Arc {
|
|
|
88
88
|
zIndex?: number;
|
|
89
89
|
}
|
|
90
90
|
|
|
91
|
+
export declare type AudioProps = Omit<VideoEngineProps, 'as' | 'style' | 'poster' | 'objectfit' | 'fullscreenMode' | 'resolution' | 'onFirstFrame' | 'scene' | 'onAppear' | 'onDisappear'>;
|
|
92
|
+
|
|
93
|
+
export declare type AudioRef = VideoEngineRef;
|
|
94
|
+
|
|
91
95
|
declare interface BounceConfig {
|
|
92
96
|
/**
|
|
93
97
|
* 是否启用回弹效果,当 loop 为 true 时忽略此设置
|
|
@@ -1549,7 +1553,7 @@ export declare interface MapMarkerProps {
|
|
|
1549
1553
|
|
|
1550
1554
|
export declare type MapMarkerRef = {
|
|
1551
1555
|
/**
|
|
1552
|
-
*
|
|
1556
|
+
* @deprecated 豆包 14.9.0 及以上版本已支持 marker 响应式刷新,无需手动调用。
|
|
1553
1557
|
*/
|
|
1554
1558
|
refreshMarker: () => void;
|
|
1555
1559
|
};
|
|
@@ -1630,6 +1634,8 @@ export declare interface MapProps {
|
|
|
1630
1634
|
showScale?: boolean;
|
|
1631
1635
|
/**
|
|
1632
1636
|
* 是否显示当前位置标记。开启后会调用定位 API 获取并监听当前位置变化,使用内置 marker 图标展示。
|
|
1637
|
+
* 使用前需在 Manifest 中声明 `scope.userLocation`,并将该权限配置为 JSB 类型。
|
|
1638
|
+
* 未正确声明时不会触发授权弹窗,也不会展示当前位置标记。
|
|
1633
1639
|
* @defaultValue false
|
|
1634
1640
|
*/
|
|
1635
1641
|
showLocation?: boolean;
|
|
@@ -4290,8 +4296,8 @@ declare enum VideoEngineOption {
|
|
|
4290
4296
|
|
|
4291
4297
|
declare type VideoEnginePlaybackCallback = (success: boolean, errCode?: number, errMsg?: string) => void;
|
|
4292
4298
|
|
|
4293
|
-
|
|
4294
|
-
ref?: ForwardedRef<
|
|
4299
|
+
declare interface VideoEngineProps {
|
|
4300
|
+
ref?: ForwardedRef<VideoEngineRef>;
|
|
4295
4301
|
/**
|
|
4296
4302
|
* Style for wrapper, especially for border-radius
|
|
4297
4303
|
* @zh 包装器的样式,特别用于设置圆角
|
|
@@ -4681,7 +4687,7 @@ export declare interface VideoProps {
|
|
|
4681
4687
|
onDisappear?: () => void;
|
|
4682
4688
|
}
|
|
4683
4689
|
|
|
4684
|
-
|
|
4690
|
+
declare interface VideoEngineRef {
|
|
4685
4691
|
/**
|
|
4686
4692
|
* Start playing. You should start play after resource redirect (after `onRedirected`)
|
|
4687
4693
|
* @zh 开始播放。你应该在资源重定向后(`onRedirected`)开始播放
|
|
@@ -4851,6 +4857,10 @@ export declare interface VideoRef {
|
|
|
4851
4857
|
operatePoster: (display: boolean) => void;
|
|
4852
4858
|
}
|
|
4853
4859
|
|
|
4860
|
+
export declare type VideoProps = VideoEngineProps;
|
|
4861
|
+
|
|
4862
|
+
export declare type VideoRef = VideoEngineRef;
|
|
4863
|
+
|
|
4854
4864
|
/**
|
|
4855
4865
|
* 基础布局容器,用于组织和嵌套其他组件,支持 Flexbox 布局。
|
|
4856
4866
|
*/
|
|
@@ -5005,7 +5015,42 @@ declare interface WebGLContextAttributes_2 {
|
|
|
5005
5015
|
* // 或按需导入:import { postMessage, onMessage } from '@doubao-dev/webview-jssdk';
|
|
5006
5016
|
* ```
|
|
5007
5017
|
*
|
|
5008
|
-
*
|
|
5018
|
+
* ## H5 可用 API
|
|
5019
|
+
*
|
|
5020
|
+
* WebView JSSDK 当前提供以下 API:
|
|
5021
|
+
*
|
|
5022
|
+
* | API | 返回值 | 说明 |
|
|
5023
|
+
* | --- | --- | --- |
|
|
5024
|
+
* | `doubao.navigateTo({ url })` | `Promise<unknown>` | 保留当前页面,跳转到智能服务内页面 |
|
|
5025
|
+
* | `doubao.navigateBack({ delta? })` | `Promise<unknown>` | 返回智能服务内的上一页或多级页面,`delta` 默认为 `1` |
|
|
5026
|
+
* | `doubao.redirectTo({ url })` | `Promise<unknown>` | 关闭当前页面,跳转到智能服务内页面 |
|
|
5027
|
+
* | `doubao.reLaunch({ url })` | `Promise<unknown>` | 关闭所有页面,跳转到智能服务内页面 |
|
|
5028
|
+
* | `doubao.postMessage({ data })` | `Promise<unknown>` | 向应用侧的 `<web-view onMessage>` 发送消息 |
|
|
5029
|
+
* | `doubao.setTitle({ title })` | `Promise<unknown>` | 设置应用侧 WebView 头部标题 |
|
|
5030
|
+
* | `doubao.onMessage(handler)` | `() => void` | 监听应用侧消息,返回注销函数 |
|
|
5031
|
+
*
|
|
5032
|
+
* 路由 API 的 `url` 是智能服务内页面路径,不是 H5 页面地址。
|
|
5033
|
+
*
|
|
5034
|
+
* ## 安全限制
|
|
5035
|
+
*
|
|
5036
|
+
* 1. **URL 协议限制**:`src` 仅支持 `https://` 协议,不支持 `http://`、`file://` 等其他协议。
|
|
5037
|
+
* 2. **JSB 白名单**:白名单外的 JSB 调用会被拦截并返回错误;其他 API 调用需要通过消息通道
|
|
5038
|
+
* 交给智能服务页面中转。
|
|
5039
|
+
* 3. **域名校验**:需要在豆包智能服务开放平台配置域名白名单,非白名单域名的 URL 将被拒绝加载。
|
|
5040
|
+
*
|
|
5041
|
+
* ## 判断是否在豆包智能服务中打开
|
|
5042
|
+
*
|
|
5043
|
+
* H5 可通过 User-Agent 中是否包含 `DoubaoApps` 判断:
|
|
5044
|
+
*
|
|
5045
|
+
* ```js
|
|
5046
|
+
* const isInDoubaoApps = navigator.userAgent.includes('DoubaoApps');
|
|
5047
|
+
* ```
|
|
5048
|
+
*
|
|
5049
|
+
* ## 双向通信示例
|
|
5050
|
+
*
|
|
5051
|
+
* ### 应用侧
|
|
5052
|
+
*
|
|
5053
|
+
* `src` 指向 H5 地址,`ref` 用于拿到 `postMessage`,`onMessage` 接收 H5 消息。
|
|
5009
5054
|
*
|
|
5010
5055
|
* ```tsx
|
|
5011
5056
|
* import { useRef } from '@doubao-dev/framework';
|
|
@@ -5033,7 +5078,9 @@ declare interface WebGLContextAttributes_2 {
|
|
|
5033
5078
|
* }
|
|
5034
5079
|
* ```
|
|
5035
5080
|
*
|
|
5036
|
-
* H5
|
|
5081
|
+
* ### H5 侧
|
|
5082
|
+
*
|
|
5083
|
+
* `doubao.onMessage` 接收应用消息并返回注销函数,`doubao.postMessage` 发送消息给应用。
|
|
5037
5084
|
*
|
|
5038
5085
|
* ```js
|
|
5039
5086
|
* const off = doubao.onMessage((raw) => {
|
|
@@ -5050,15 +5097,6 @@ declare interface WebGLContextAttributes_2 {
|
|
|
5050
5097
|
* // off();
|
|
5051
5098
|
* ```
|
|
5052
5099
|
*
|
|
5053
|
-
* 三个容易踩的点:
|
|
5054
|
-
*
|
|
5055
|
-
* - 首条消息放在 `onLoad` 之后发,H5 尚未加载完成时发送的消息会丢失。
|
|
5056
|
-
* - 两个方向的数据形态不同:应用 → H5 时非字符串会被 `JSON.stringify`,H5 收到的是 JSON 字符串,
|
|
5057
|
-
* 需要自行 `JSON.parse`;H5 → 应用时 `onMessage` 的 `event.data` 保持 H5 传入的原始值。
|
|
5058
|
-
* - 如果两侧都写成“收到就回”,务必按消息 `type` 区分,否则会无限互相回声。
|
|
5059
|
-
*
|
|
5060
|
-
* 除消息通道外,H5 还可以调用 `doubao.setTitle({ title })` 同步应用侧 WebView 头部标题。
|
|
5061
|
-
*
|
|
5062
5100
|
* ## Web 模拟器差异
|
|
5063
5101
|
*
|
|
5064
5102
|
* Web 模拟器中的 `<web-view>` 通过本地代理承载 H5 页面,页面脚本读取到的
|
|
@@ -5072,7 +5110,7 @@ export declare interface WebViewProps {
|
|
|
5072
5110
|
*/
|
|
5073
5111
|
ref?: Ref<WebViewRef>;
|
|
5074
5112
|
/**
|
|
5075
|
-
*
|
|
5113
|
+
* 网页资源地址,仅支持 `https://` 协议;需要在豆包智能服务开放平台配置白名单,并通过校验
|
|
5076
5114
|
*/
|
|
5077
5115
|
src?: string;
|
|
5078
5116
|
/**
|
package/dist/config.d.ts
CHANGED
|
@@ -253,7 +253,18 @@ export declare interface DoubaoAppsPlugin {
|
|
|
253
253
|
setup: (api: any) => void | Promise<void>;
|
|
254
254
|
}
|
|
255
255
|
|
|
256
|
-
export declare type DoubaoAppsToolConfig =
|
|
256
|
+
export declare type DoubaoAppsToolConfig = DoubaoAppsToolEntryConfig[];
|
|
257
|
+
|
|
258
|
+
export declare type DoubaoAppsToolEntryConfig = string | ({
|
|
259
|
+
entry: string;
|
|
260
|
+
} & DoubaoAppsToolMetaConfig);
|
|
261
|
+
|
|
262
|
+
export declare type DoubaoAppsToolMetaConfig = {
|
|
263
|
+
/**
|
|
264
|
+
* Tool name. Defaults to the entry directory name.
|
|
265
|
+
*/
|
|
266
|
+
name?: string;
|
|
267
|
+
};
|
|
257
268
|
|
|
258
269
|
export declare type DoubaoAppsWidgetConfig = DoubaoAppsWidgetEntryConfig[] | DoubaoAppsLegacyEntryConfig<DoubaoAppsWidgetMetaConfig>;
|
|
259
270
|
|
package/dist/index.d.ts
CHANGED
|
@@ -103,7 +103,66 @@ import { VoidFunctionComponent } from 'react';
|
|
|
103
103
|
|
|
104
104
|
export declare type AgentEventCallback = (payload: AgentEventPayload) => void;
|
|
105
105
|
|
|
106
|
-
declare type
|
|
106
|
+
export declare type AgentEventHandler = (name: string, payload: AgentEventPayload) => void;
|
|
107
|
+
|
|
108
|
+
export declare type AgentEventPayload = Record<string, unknown>;
|
|
109
|
+
|
|
110
|
+
declare interface AgreePrivacyResult {
|
|
111
|
+
/**
|
|
112
|
+
* 用户是否同意隐私协议授权。
|
|
113
|
+
*/
|
|
114
|
+
result: boolean;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
declare interface AIAppMetadata {
|
|
118
|
+
/**
|
|
119
|
+
*
|
|
120
|
+
* 豆包应用 ID
|
|
121
|
+
*
|
|
122
|
+
*/
|
|
123
|
+
appId: string;
|
|
124
|
+
/**
|
|
125
|
+
* 应用名称
|
|
126
|
+
*/
|
|
127
|
+
name?: string;
|
|
128
|
+
/**
|
|
129
|
+
* 应用描述
|
|
130
|
+
*/
|
|
131
|
+
description?: string;
|
|
132
|
+
/**
|
|
133
|
+
* 应用图标
|
|
134
|
+
*
|
|
135
|
+
* 1x, 2x, 3x 分别对应 1x, 2x, 3x 倍的图标
|
|
136
|
+
*/
|
|
137
|
+
icons?: Icons;
|
|
138
|
+
/**
|
|
139
|
+
* 应用关键词
|
|
140
|
+
*/
|
|
141
|
+
keywords?: string[];
|
|
142
|
+
/**
|
|
143
|
+
* 应用版本
|
|
144
|
+
*/
|
|
145
|
+
version?: string;
|
|
146
|
+
/**
|
|
147
|
+
* 是否声明小程序已适配深色模式
|
|
148
|
+
*/
|
|
149
|
+
darkMode?: boolean;
|
|
150
|
+
/**
|
|
151
|
+
* 应用级对话框能力配置
|
|
152
|
+
*/
|
|
153
|
+
chat?: AppletChatConfig;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export declare type AIToolContext = MessageMeta & {
|
|
157
|
+
/**
|
|
158
|
+
* callback Id
|
|
159
|
+
*/
|
|
160
|
+
callbackId: string;
|
|
161
|
+
/**
|
|
162
|
+
* feature map
|
|
163
|
+
*/
|
|
164
|
+
featureMap: Record<string, string> | undefined;
|
|
165
|
+
};
|
|
107
166
|
|
|
108
167
|
export declare type AIViewContext = MessageMeta & {
|
|
109
168
|
/**
|
|
@@ -141,6 +200,44 @@ export declare type AIViewContext = MessageMeta & {
|
|
|
141
200
|
};
|
|
142
201
|
};
|
|
143
202
|
|
|
203
|
+
export declare type AnyObject = Record<string, any>;
|
|
204
|
+
|
|
205
|
+
export declare type App<T extends DefineAppOptions = DefineAppOptions> = T & {
|
|
206
|
+
readonly eventChannel: EventChannel;
|
|
207
|
+
__APP__: boolean;
|
|
208
|
+
__UI__: boolean;
|
|
209
|
+
};
|
|
210
|
+
|
|
211
|
+
declare type AppAIMeta = Omit<AIAppMetadata, 'appId'> & {
|
|
212
|
+
appId?: string;
|
|
213
|
+
package?: string;
|
|
214
|
+
};
|
|
215
|
+
|
|
216
|
+
declare interface AppletChatConfig {
|
|
217
|
+
/**
|
|
218
|
+
* App-level chat feature overrides.
|
|
219
|
+
*/
|
|
220
|
+
features?: AppletChatFeaturesConfig;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
declare interface AppletChatFeatureConfig {
|
|
224
|
+
/**
|
|
225
|
+
* Whether the chat feature is enabled.
|
|
226
|
+
*/
|
|
227
|
+
enabled: boolean;
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
declare interface AppletChatFeaturesConfig {
|
|
231
|
+
/**
|
|
232
|
+
* Camera entry configuration.
|
|
233
|
+
*/
|
|
234
|
+
camera?: AppletChatFeatureConfig;
|
|
235
|
+
/**
|
|
236
|
+
* Extra actions entry configuration.
|
|
237
|
+
*/
|
|
238
|
+
extraActions?: AppletChatFeatureConfig;
|
|
239
|
+
}
|
|
240
|
+
|
|
144
241
|
export { Attributes }
|
|
145
242
|
|
|
146
243
|
export { CElement }
|
|
@@ -201,12 +298,216 @@ export { createElement }
|
|
|
201
298
|
|
|
202
299
|
export { createRef }
|
|
203
300
|
|
|
301
|
+
/** 当前页面栈中的页面信息。 */
|
|
204
302
|
export declare interface CurrentPage {
|
|
303
|
+
/** 页面路由。 */
|
|
205
304
|
route: string;
|
|
305
|
+
/**
|
|
306
|
+
* @since 0.1.0
|
|
307
|
+
* 页面查询参数。
|
|
308
|
+
*/
|
|
309
|
+
query: Record<string, string>;
|
|
206
310
|
}
|
|
207
311
|
|
|
208
312
|
export { CustomComponentPropsWithRef }
|
|
209
313
|
|
|
314
|
+
export declare function defineApp<T extends DefineAppOptions>(options: T & ThisType<T & {
|
|
315
|
+
readonly aiMeta: AppAIMeta;
|
|
316
|
+
readonly eventChannel: EventChannel;
|
|
317
|
+
}>): App<T>;
|
|
318
|
+
|
|
319
|
+
export declare interface DefineAppOptions {
|
|
320
|
+
[key: string]: any;
|
|
321
|
+
/**
|
|
322
|
+
* @deprecated Configure app metadata in src/app.config.ts instead.
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* ```ts
|
|
326
|
+
* // src/app.config.ts
|
|
327
|
+
* import { defineAppConfig } from '@doubao-dev/framework/config';
|
|
328
|
+
*
|
|
329
|
+
* export default defineAppConfig({
|
|
330
|
+
* appId: 'your-app-id',
|
|
331
|
+
* name: 'Demo App',
|
|
332
|
+
* description: 'Describe what this app can do',
|
|
333
|
+
* icons: 'https://example.com/icon.png',
|
|
334
|
+
* keywords: ['demo', 'doubao']
|
|
335
|
+
* });
|
|
336
|
+
* ```
|
|
337
|
+
*/
|
|
338
|
+
aiMeta?: AppAIMeta;
|
|
339
|
+
/**
|
|
340
|
+
* App launched
|
|
341
|
+
*/
|
|
342
|
+
onLaunch?: () => void;
|
|
343
|
+
/**
|
|
344
|
+
* On page opened
|
|
345
|
+
*/
|
|
346
|
+
onPageOpened?: (params: {
|
|
347
|
+
viewId: string;
|
|
348
|
+
}) => void;
|
|
349
|
+
/**
|
|
350
|
+
* Handle an event sent by the Agent to the app.
|
|
351
|
+
*/
|
|
352
|
+
onAgentEvent?: AgentEventHandler;
|
|
353
|
+
/**
|
|
354
|
+
* On foreground
|
|
355
|
+
*/
|
|
356
|
+
onForeground?: () => void;
|
|
357
|
+
/**
|
|
358
|
+
* On background
|
|
359
|
+
*/
|
|
360
|
+
onBackground?: () => void;
|
|
361
|
+
/**
|
|
362
|
+
* On destroy
|
|
363
|
+
*/
|
|
364
|
+
onDestroy?: () => void;
|
|
365
|
+
/**
|
|
366
|
+
* Handle errors from other App callbacks or tools in the same Applet.
|
|
367
|
+
*/
|
|
368
|
+
onError?: (e: Error) => void;
|
|
369
|
+
}
|
|
370
|
+
|
|
371
|
+
export declare interface DefineFunctionalToolOptions extends Tool {
|
|
372
|
+
onApply: (input: string, context: AIToolContext) => string | object | Promise<string | object>;
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
export declare function defineLoginApi(api: LoginApi): LoginApi;
|
|
376
|
+
|
|
377
|
+
/**
|
|
378
|
+
* 定义 MCP 登录页面
|
|
379
|
+
* @param options 定义 MCP 登录页面的选项
|
|
380
|
+
* @returns 智能服务 MCP 登录页面
|
|
381
|
+
*/
|
|
382
|
+
export declare function defineLoginPage<Data extends AnyObject>(options: Omit<DefinePageToolOptions<Data>, 'aiMeta'> & ThisType<Readonly<PageInstanceMethods<Data>>>): Page<Data>;
|
|
383
|
+
|
|
384
|
+
export declare function definePage<Data extends AnyObject>(options: DefinePageToolOptions<Data> & ThisType<Readonly<PageInstanceMethods<Data>>>): Page<Data>;
|
|
385
|
+
|
|
386
|
+
export declare interface DefinePageToolOptions<Data extends AnyObject> extends DefineUIToolOptions<Data, PageToolExtraMetadata> {
|
|
387
|
+
/**
|
|
388
|
+
* @deprecated Configure page metadata in src/app.config.ts instead.
|
|
389
|
+
*
|
|
390
|
+
* Use `pages` entries in `src/app.config.ts`. For example,
|
|
391
|
+
* `pages/home/index` maps to `src/pages/home/index.tsx`, and
|
|
392
|
+
* `pages/account/demo/index` maps to `src/pages/account/demo/index.tsx`.
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* ```ts
|
|
396
|
+
* // src/app.config.ts
|
|
397
|
+
* import { defineAppConfig } from '@doubao-dev/framework/config';
|
|
398
|
+
*
|
|
399
|
+
* export default defineAppConfig({
|
|
400
|
+
* appId: 'your-app-id',
|
|
401
|
+
* pages: ['pages/home/index']
|
|
402
|
+
* });
|
|
403
|
+
* ```
|
|
404
|
+
*/
|
|
405
|
+
aiMeta?: PageToolMetadata;
|
|
406
|
+
}
|
|
407
|
+
|
|
408
|
+
export declare function definePrivacyApi(api: PrivacyApi): PrivacyApi;
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* 定义 MCP 同意登录和隐私协议卡片组件
|
|
412
|
+
* @param options 定义 MCP 同意登录和隐私协议卡片组件的选项
|
|
413
|
+
* @returns MCP 同意登录和隐私协议卡片组件
|
|
414
|
+
*/
|
|
415
|
+
export declare function definePrivacyLoginWidget<Data extends AnyObject>(options: Omit<DefineWidgetToolOptions<Data>, 'aiMeta'> & ThisType<Readonly<WidgetInstanceMethods<Data>>>): Widget<Data>;
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* @deprecated Export a default Client Tool handler and configure it in `app.config.ts` instead.
|
|
419
|
+
*/
|
|
420
|
+
export declare function defineTool(options: DefineFunctionalToolOptions & ThisType<Readonly<FunctionalToolInstanceMethods>>): FunctionalTool;
|
|
421
|
+
|
|
422
|
+
export declare interface DefineUIToolOptions<Data extends AnyObject, Extra extends AnyObject = AnyObject> extends Tool<Extra> {
|
|
423
|
+
/**
|
|
424
|
+
* Initial data
|
|
425
|
+
*/
|
|
426
|
+
data?: Data;
|
|
427
|
+
/**
|
|
428
|
+
* Trigger on view created
|
|
429
|
+
* @returns
|
|
430
|
+
*/
|
|
431
|
+
onCreated?: () => void;
|
|
432
|
+
/**
|
|
433
|
+
* It is triggered after the view is rendered and will only be called once in the view's life cycle.
|
|
434
|
+
* @returns
|
|
435
|
+
*/
|
|
436
|
+
onMounted?: () => void;
|
|
437
|
+
/**
|
|
438
|
+
* 1. It is triggered when the view is first displayed.
|
|
439
|
+
* 2. It is triggered when the view is displayed again after being hidden.
|
|
440
|
+
* @returns
|
|
441
|
+
*/
|
|
442
|
+
onShow?: () => void;
|
|
443
|
+
/**
|
|
444
|
+
* It is triggered when the view is hidden.
|
|
445
|
+
* @returns
|
|
446
|
+
*/
|
|
447
|
+
onHide?: () => void;
|
|
448
|
+
/**
|
|
449
|
+
* It is triggered when the view is destroyed.
|
|
450
|
+
* @returns
|
|
451
|
+
*/
|
|
452
|
+
onDestroy?: () => void;
|
|
453
|
+
/**
|
|
454
|
+
* It is triggered when an error occurs.
|
|
455
|
+
* @param e
|
|
456
|
+
* @returns
|
|
457
|
+
*/
|
|
458
|
+
onError?: (e: Error) => void;
|
|
459
|
+
/**
|
|
460
|
+
* Render function
|
|
461
|
+
* Use getViewData() and getViewContext() to access data and context
|
|
462
|
+
* @returns
|
|
463
|
+
*/
|
|
464
|
+
render: () => ReactNode;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export declare function defineWidget<Data extends AnyObject>(options: DefineWidgetToolOptions<Data> & ThisType<Readonly<WidgetInstanceMethods<Data>>>): Widget<Data>;
|
|
468
|
+
|
|
469
|
+
export declare interface DefineWidgetToolOptions<Data extends AnyObject> extends DefineUIToolOptions<Data, WidgetToolExtraMetadata> {
|
|
470
|
+
/**
|
|
471
|
+
* @deprecated Configure widget metadata in src/app.config.ts instead.
|
|
472
|
+
*
|
|
473
|
+
* Use `widgets` entries in `src/app.config.ts`. For example,
|
|
474
|
+
* `widgets/card/index` maps to `src/widgets/card/index.tsx`, and
|
|
475
|
+
* `widgets/api/demo/index` maps to `src/widgets/api/demo/index.tsx`.
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* ```ts
|
|
479
|
+
* // src/app.config.ts
|
|
480
|
+
* import { defineAppConfig } from '@doubao-dev/framework/config';
|
|
481
|
+
*
|
|
482
|
+
* export default defineAppConfig({
|
|
483
|
+
* appId: 'your-app-id',
|
|
484
|
+
* widgets: [
|
|
485
|
+
* {
|
|
486
|
+
* entry: 'widgets/card/index',
|
|
487
|
+
* id: 'card-widget',
|
|
488
|
+
* name: 'Card Widget',
|
|
489
|
+
* description: 'Show card content',
|
|
490
|
+
* border: true
|
|
491
|
+
* }
|
|
492
|
+
* ]
|
|
493
|
+
* });
|
|
494
|
+
* ```
|
|
495
|
+
*/
|
|
496
|
+
aiMeta?: WidgetToolMetadata;
|
|
497
|
+
/**
|
|
498
|
+
* 1. It is triggered when the app returns to the foreground from the background.
|
|
499
|
+
* 2. It is triggered when phone is unlocked.
|
|
500
|
+
* @returns
|
|
501
|
+
*/
|
|
502
|
+
onForeground?: () => void;
|
|
503
|
+
/**
|
|
504
|
+
* 1. It is triggered when the app is moved to the background.
|
|
505
|
+
* 2. It is triggered when phone is locked.
|
|
506
|
+
* @returns
|
|
507
|
+
*/
|
|
508
|
+
onBackground?: () => void;
|
|
509
|
+
}
|
|
510
|
+
|
|
210
511
|
export { DependencyList }
|
|
211
512
|
|
|
212
513
|
export { DeprecatedLifecycle }
|
|
@@ -225,6 +526,19 @@ export { ElementRef }
|
|
|
225
526
|
|
|
226
527
|
export { ElementType }
|
|
227
528
|
|
|
529
|
+
export declare type EventCallback = (...args: any[]) => void;
|
|
530
|
+
|
|
531
|
+
export declare class EventChannel {
|
|
532
|
+
private readonly handleError;
|
|
533
|
+
private listeners;
|
|
534
|
+
constructor(handleError?: (error: unknown) => void);
|
|
535
|
+
emit(eventName: string, ...args: any[]): void;
|
|
536
|
+
on(eventName: string, callback: EventCallback): void;
|
|
537
|
+
once(eventName: string, callback: EventCallback): void;
|
|
538
|
+
off(eventName: string, callback?: EventCallback): void;
|
|
539
|
+
private addListener;
|
|
540
|
+
}
|
|
541
|
+
|
|
228
542
|
export { ExoticComponent }
|
|
229
543
|
|
|
230
544
|
export { Factory }
|
|
@@ -241,24 +555,49 @@ export { ForwardRefRenderFunction }
|
|
|
241
555
|
|
|
242
556
|
export { Fragment }
|
|
243
557
|
|
|
558
|
+
export declare interface FunctionalTool extends DefineFunctionalToolOptions {
|
|
559
|
+
__FUNCTIONAL__: boolean;
|
|
560
|
+
}
|
|
561
|
+
|
|
562
|
+
declare type FunctionalToolInstanceMethods = Tool<ToolMetadata>;
|
|
563
|
+
|
|
244
564
|
export { FunctionComponent }
|
|
245
565
|
|
|
246
566
|
export { FunctionComponentElement }
|
|
247
567
|
|
|
248
568
|
export { FunctionComponentFactory }
|
|
249
569
|
|
|
250
|
-
|
|
570
|
+
declare function getApp_2<T extends App = App>(): T;
|
|
571
|
+
export { getApp_2 as getApp }
|
|
572
|
+
|
|
573
|
+
export declare function getCurrentPages(): {
|
|
574
|
+
route: string;
|
|
575
|
+
query: Record<string, string>;
|
|
576
|
+
}[];
|
|
251
577
|
|
|
252
578
|
export { GetDerivedStateFromError }
|
|
253
579
|
|
|
254
580
|
export { GetDerivedStateFromProps }
|
|
255
581
|
|
|
582
|
+
declare interface GetPhoneNumberResult {
|
|
583
|
+
/**
|
|
584
|
+
* 获取手机号结果码。
|
|
585
|
+
*/
|
|
586
|
+
code?: string;
|
|
587
|
+
/**
|
|
588
|
+
* 获取手机号结果信息。
|
|
589
|
+
*/
|
|
590
|
+
message?: string;
|
|
591
|
+
}
|
|
592
|
+
|
|
256
593
|
export declare function getViewContext(): any;
|
|
257
594
|
|
|
258
595
|
export declare function getViewData<T extends Record<string, any>>(): T;
|
|
259
596
|
|
|
260
597
|
export declare function getWidgetInstanceId(): string | undefined;
|
|
261
598
|
|
|
599
|
+
declare type Icons = string | Record<'1x' | '2x' | '3x', string>;
|
|
600
|
+
|
|
262
601
|
export { isValidElement }
|
|
263
602
|
|
|
264
603
|
export { JSXElementConstructor }
|
|
@@ -275,6 +614,13 @@ declare type LifecycleCallback = () => void;
|
|
|
275
614
|
|
|
276
615
|
declare type LifecycleErrorCallback = (error: Error) => void;
|
|
277
616
|
|
|
617
|
+
export declare interface LoginApi {
|
|
618
|
+
onLogin: (res: LoginResult) => Promise<void> | void;
|
|
619
|
+
onRefuseLogin: () => Promise<void> | void;
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
export declare type LoginResult = GetPhoneNumberResult;
|
|
623
|
+
|
|
278
624
|
export { memo }
|
|
279
625
|
|
|
280
626
|
export { MemoExoticComponent }
|
|
@@ -322,6 +668,36 @@ export { NamedExoticComponent }
|
|
|
322
668
|
|
|
323
669
|
export { NewLifecycle }
|
|
324
670
|
|
|
671
|
+
/**
|
|
672
|
+
* Register the runtime error handler.
|
|
673
|
+
*
|
|
674
|
+
* Calling this again replaces the previously registered handler.
|
|
675
|
+
*/
|
|
676
|
+
export declare function onError(callback: (error: Error) => void): void;
|
|
677
|
+
|
|
678
|
+
export declare interface Page<Data extends AnyObject = AnyObject> extends DefineUIToolOptions<Data> {
|
|
679
|
+
__UI__: boolean;
|
|
680
|
+
__PAGE__: boolean;
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
declare type PageInstanceMethods<Data extends AnyObject> = UIInstanceMethods<Data, PageToolExtraMetadata>;
|
|
684
|
+
|
|
685
|
+
declare type PageToolExtraMetadata = {
|
|
686
|
+
/**
|
|
687
|
+
* The page navbar title
|
|
688
|
+
*/
|
|
689
|
+
title?: string;
|
|
690
|
+
};
|
|
691
|
+
|
|
692
|
+
export declare type PageToolMetadata = ToolMeta & PageToolExtraMetadata;
|
|
693
|
+
|
|
694
|
+
export declare type PrivacyAgreeResult = AgreePrivacyResult;
|
|
695
|
+
|
|
696
|
+
export declare interface PrivacyApi {
|
|
697
|
+
onAgreePrivacy: (res: PrivacyAgreeResult) => Promise<void> | void;
|
|
698
|
+
onRefusePrivacy: () => Promise<void> | void;
|
|
699
|
+
}
|
|
700
|
+
|
|
325
701
|
export { PropsWithChildren }
|
|
326
702
|
|
|
327
703
|
export { PropsWithoutRef }
|
|
@@ -382,10 +758,57 @@ export { Suspense }
|
|
|
382
758
|
|
|
383
759
|
export { SVGFactory }
|
|
384
760
|
|
|
761
|
+
export declare interface Tool<Extra extends AnyObject = AnyObject> {
|
|
762
|
+
aiMeta?: ToolMeta & Extra;
|
|
763
|
+
}
|
|
764
|
+
|
|
765
|
+
export declare interface ToolMeta {
|
|
766
|
+
/**
|
|
767
|
+
* unique identifier
|
|
768
|
+
*/
|
|
769
|
+
id: string;
|
|
770
|
+
/**
|
|
771
|
+
* name of the tool
|
|
772
|
+
*/
|
|
773
|
+
name?: string;
|
|
774
|
+
/**
|
|
775
|
+
* description of the tool
|
|
776
|
+
*/
|
|
777
|
+
description?: string;
|
|
778
|
+
/**
|
|
779
|
+
* Widget title type
|
|
780
|
+
* - none: 默认,无标题
|
|
781
|
+
* - normal: 常规标题
|
|
782
|
+
* - float: 浮动标题
|
|
783
|
+
*/
|
|
784
|
+
titleType?: 'none' | 'normal' | 'float';
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
export declare type ToolMetadata = {
|
|
788
|
+
/**
|
|
789
|
+
* specifies when a call to a tool will time out, in ms.
|
|
790
|
+
*/
|
|
791
|
+
timeout?: number;
|
|
792
|
+
};
|
|
793
|
+
|
|
385
794
|
export { TransitionFunction }
|
|
386
795
|
|
|
387
796
|
export { TransitionStartFunction }
|
|
388
797
|
|
|
798
|
+
export declare interface UIInstanceMethods<Data extends AnyObject, Extra extends AnyObject = AnyObject> extends Tool<Extra> {
|
|
799
|
+
/**
|
|
800
|
+
* Instance data
|
|
801
|
+
*/
|
|
802
|
+
data: Data;
|
|
803
|
+
/**
|
|
804
|
+
* Set data asynchronously and trigger view re-rendering
|
|
805
|
+
* @param data
|
|
806
|
+
* @param callback
|
|
807
|
+
* @returns
|
|
808
|
+
*/
|
|
809
|
+
setData: (data: Partial<Data> & AnyObject, callback?: () => void) => Promise<void>;
|
|
810
|
+
}
|
|
811
|
+
|
|
389
812
|
export declare function useAgentEvent(eventName: string, callback: AgentEventCallback): void;
|
|
390
813
|
|
|
391
814
|
export declare function useBackground(callback: LifecycleCallback): void;
|
|
@@ -453,4 +876,37 @@ export { VFC }
|
|
|
453
876
|
|
|
454
877
|
export { VoidFunctionComponent }
|
|
455
878
|
|
|
879
|
+
export declare interface Widget<Data extends AnyObject = AnyObject> extends DefineWidgetToolOptions<Data> {
|
|
880
|
+
__UI__: boolean;
|
|
881
|
+
__WIDGET__: boolean;
|
|
882
|
+
setData: (data: Partial<Data>, callback?: () => void) => void;
|
|
883
|
+
}
|
|
884
|
+
|
|
885
|
+
declare type WidgetInstanceMethods<Data extends AnyObject> = UIInstanceMethods<Data, WidgetToolExtraMetadata>;
|
|
886
|
+
|
|
887
|
+
declare type WidgetToolExtraMetadata = {
|
|
888
|
+
/**
|
|
889
|
+
* Widget box type in Chat UI
|
|
890
|
+
*/
|
|
891
|
+
boxType?: 'inbox' | 'full_box';
|
|
892
|
+
/**
|
|
893
|
+
* Whether add widget border
|
|
894
|
+
*/
|
|
895
|
+
border?: boolean;
|
|
896
|
+
/**
|
|
897
|
+
* Keywords of things
|
|
898
|
+
*/
|
|
899
|
+
keywords?: string[];
|
|
900
|
+
/**
|
|
901
|
+
* Icons
|
|
902
|
+
*/
|
|
903
|
+
icons?: Icons;
|
|
904
|
+
/**
|
|
905
|
+
* Set extra widget properties
|
|
906
|
+
*/
|
|
907
|
+
prop?: string;
|
|
908
|
+
};
|
|
909
|
+
|
|
910
|
+
export declare type WidgetToolMetadata = ToolMeta & WidgetToolExtraMetadata;
|
|
911
|
+
|
|
456
912
|
export { }
|
package/jsx-runtime.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export namespace JSX {
|
|
|
14
14
|
interface IntrinsicClassAttributes<T> extends React.JSX.IntrinsicClassAttributes<T> {}
|
|
15
15
|
interface IntrinsicElements {
|
|
16
16
|
// Extended components
|
|
17
|
+
audio: import('./components.d.ts').AudioProps;
|
|
17
18
|
button: import('./components.d.ts').ButtonProps;
|
|
18
19
|
canvas: import('./components.d.ts').CanvasProps;
|
|
19
20
|
map: import('./components.d.ts').MapProps;
|