@doubao-dev/framework 0.0.39 → 0.0.40

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/dist/api.d.ts CHANGED
@@ -47,6 +47,153 @@ export declare enum ActionDirectiveType {
47
47
  FORM_SUBMIT = "form_submit"
48
48
  }
49
49
 
50
+ /**
51
+ * 向系统日历添加事件。
52
+ *
53
+ * @example
54
+ * ```typescript
55
+ * import { addPhoneCalendar } from '@doubao-dev/framework/api';
56
+ *
57
+ * const startTime = Math.floor(Date.now() / 1000) + 3600;
58
+ *
59
+ * await addPhoneCalendar({
60
+ * title: '项目评审',
61
+ * startTime,
62
+ * endTime: startTime + 1800,
63
+ * alarm: true,
64
+ * alarmOffset: 300
65
+ * });
66
+ * ```
67
+ *
68
+ * @since 0.0.19
69
+ * @contractStatus verified | Android、iOS 均支持向系统日历写入一次性事件;成功通过 Promise resolve 空对象,失败通过 Promise reject。
70
+ * @platformSupport Android | supported | 写入系统日历事件;path 传入后按原值追加到日历备注。
71
+ * @platformSupport iOS | supported | 写入系统日历事件;path 传入后按原值追加到日历备注。
72
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
73
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
74
+ * @permission applet | scope.addPhoneCalendar | required | Android,iOS | 需要在 manifest 中声明 scope.addPhoneCalendar,并由用户授权写入系统日历。
75
+ * @authorizationBehavior Android | 首次调用会依次申请应用日历授权和系统日历读写权限;用户拒绝、取消或权限被撤销后调用失败,可通过重新发起授权或系统设置恢复。
76
+ * @authorizationBehavior iOS | 首次调用会依次申请应用日历授权和系统日历写入权限;用户拒绝、取消或权限被撤销后调用失败,可通过重新发起授权或系统设置恢复。
77
+ * @precondition iOS | 设备需要存在可写入的系统日历账户。
78
+ * @usageNote All | startTime、endTime 使用 Unix 秒级时间戳;alarmOffset 单位为秒,Android 系统日历提醒粒度会按分钟处理。
79
+ * @errorCode none | - | - | Android,iOS | 当前失败通过 Promise reject 返回文本信息,未稳定返回顶层 errNo/errMsg | 根据异常信息检查授权、日历账户和时间参数
80
+ *
81
+ * @public
82
+ */
83
+ export declare const addPhoneCalendar: (params: AddPhoneCalendarParams) => Promise<object>;
84
+
85
+ /**
86
+ * 添加系统日历事件的请求参数。
87
+ *
88
+ * @public
89
+ */
90
+ export declare interface AddPhoneCalendarParams {
91
+ /** 日历事件标题。 */
92
+ title: string;
93
+ /** 开始时间的 Unix 秒级时间戳。 */
94
+ startTime: number;
95
+ /**
96
+ * 是否为全天事件。
97
+ *
98
+ * @default false
99
+ */
100
+ allDay?: boolean;
101
+ /**
102
+ * 事件描述。
103
+ *
104
+ * @default -
105
+ */
106
+ description?: string;
107
+ /**
108
+ * 事件位置。
109
+ *
110
+ * @default -
111
+ */
112
+ location?: string;
113
+ /**
114
+ * 结束时间的 Unix 秒级时间戳。
115
+ *
116
+ * @default startTime
117
+ */
118
+ endTime?: number;
119
+ /**
120
+ * 是否提醒。
121
+ *
122
+ * @default true
123
+ */
124
+ alarm?: boolean;
125
+ /**
126
+ * 提前提醒时间,单位秒。0 表示开始时提醒。
127
+ *
128
+ * @default 0
129
+ */
130
+ alarmOffset?: number;
131
+ /**
132
+ * 跳转链接或客户端路由。传入后按原值追加到日历备注。
133
+ *
134
+ * @default -
135
+ */
136
+ path?: string;
137
+ }
138
+
139
+ /**
140
+ * 向系统日历添加重复事件。
141
+ *
142
+ * @example
143
+ * ```typescript
144
+ * import { addPhoneRepeatCalendar } from '@doubao-dev/framework/api';
145
+ *
146
+ * const startTime = Math.floor(Date.now() / 1000) + 3600;
147
+ *
148
+ * await addPhoneRepeatCalendar({
149
+ * title: '每周例会',
150
+ * startTime,
151
+ * endTime: startTime + 1800,
152
+ * repeatInterval: 'week'
153
+ * });
154
+ * ```
155
+ *
156
+ * @since 0.0.25
157
+ * @contractStatus verified | Android、iOS 均支持向系统日历写入重复事件;成功通过 Promise resolve 空对象,失败通过 Promise reject。
158
+ * @platformSupport Android | supported | 写入系统日历重复事件;repeatInterval 支持 day、week、month、year,path 行为与 addPhoneCalendar 一致。
159
+ * @platformSupport iOS | supported | 写入系统日历重复事件;repeatInterval 支持 day、week、month、year,path 行为与 addPhoneCalendar 一致。
160
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
161
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
162
+ * @permission applet | scope.addPhoneCalendar | required | Android,iOS | 需要在 manifest 中声明 scope.addPhoneCalendar,并由用户授权写入系统日历。
163
+ * @authorizationBehavior Android | 首次调用会依次申请应用日历授权和系统日历读写权限;用户拒绝、取消或权限被撤销后调用失败,可通过重新发起授权或系统设置恢复。
164
+ * @authorizationBehavior iOS | 首次调用会依次申请应用日历授权和系统日历写入权限;用户拒绝、取消或权限被撤销后调用失败,可通过重新发起授权或系统设置恢复。
165
+ * @precondition iOS | 设备需要存在可写入的系统日历账户。
166
+ * @precondition All | repeatInterval 为 month 时,startTime 所在日期不能大于 28 日。
167
+ * @usageNote All | repeatInterval 默认 month;repeatEndTime 不传表示一直重复;startTime、endTime、repeatEndTime 使用 Unix 秒级时间戳。
168
+ * @errorCode none | - | - | Android,iOS | 当前失败通过 Promise reject 返回文本信息,未稳定返回顶层 errNo/errMsg | 根据异常信息检查授权、日历账户、重复周期和时间参数
169
+ *
170
+ * @public
171
+ */
172
+ export declare const addPhoneRepeatCalendar: (params: AddPhoneRepeatCalendarParams) => Promise<object>;
173
+
174
+ /**
175
+ * 添加重复日历事件的请求参数。
176
+ *
177
+ * @public
178
+ */
179
+ export declare interface AddPhoneRepeatCalendarParams extends AddPhoneCalendarParams {
180
+ /**
181
+ * 重复周期。
182
+ *
183
+ * @default month
184
+ */
185
+ repeatInterval?: CalendarRepeatInterval;
186
+ /**
187
+ * 重复结束时间的 Unix 秒级时间戳。
188
+ *
189
+ * @default -
190
+ */
191
+ repeatEndTime?: number;
192
+ }
193
+
194
+ /** @public */
195
+ export declare type AppAuthorizeStatus = 'authorized' | 'denied' | 'not determined';
196
+
50
197
  /** @public */
51
198
  export declare interface AppBaseInfoHost {
52
199
  /** 宿主 app 对应的 appId */
@@ -568,6 +715,13 @@ export declare interface BottomSheetCancelResult {
568
715
  */
569
716
  export declare type BottomSheetCancelSource = 'mask' | 'gesture' | 'hostUnavailable' | 'unknown';
570
717
 
718
+ /**
719
+ * 日历重复周期。
720
+ *
721
+ * @public
722
+ */
723
+ export declare type CalendarRepeatInterval = 'day' | 'week' | 'month' | 'year';
724
+
571
725
  /** @public */
572
726
  export declare interface CanIUseParams {
573
727
  /** 需要检测的能力标识,例如 API 名称 */
@@ -958,7 +1112,7 @@ declare type ClientEventRegistry<Params extends object = object> = (handler: (pa
958
1112
  * @usageNote All | close 已废弃,推荐使用 navigateBack 返回上一页;省略 containerID 时关闭当前栈顶页面。
959
1113
  * @errorCode none | - | - | Android,iOS | 无 API 专属错误码 | 无需处理
960
1114
  *
961
- * @public
1115
+ * @internal
962
1116
  */
963
1117
  declare const close_2: (params?: CloseParams | undefined) => Promise<object>;
964
1118
  export { close_2 as close }
@@ -1898,6 +2052,167 @@ export declare interface DoubaoAppAccountInfo {
1898
2052
  version: string;
1899
2053
  }
1900
2054
 
2055
+ /**
2056
+ * 下载文件,并返回可取消、可监听进度的 {@link DownloadTask}。
2057
+ *
2058
+ * @summary 下载文件。
2059
+ * @param params 下载参数,字段见 {@link DownloadFileParams}。
2060
+ * @returns 下载任务。
2061
+ *
2062
+ * @remarks
2063
+ * - 下载使用 GET 请求。
2064
+ * - HTTP 传输完成且文件写入成功后,无论 statusCode 是 2xx、4xx 还是 5xx,Promise 都会 resolve。
2065
+ * - 域名校验失败、路径非法、超时、取消、网络异常、写入失败会使 Promise reject。
2066
+ *
2067
+ * @example
2068
+ * ```typescript
2069
+ * import { downloadFile } from '@doubao-dev/framework/api';
2070
+ *
2071
+ * const downloadTask = downloadFile({
2072
+ * url: 'https://example.com/files/report.pdf'
2073
+ * });
2074
+ *
2075
+ * downloadTask
2076
+ * .then((result) => {
2077
+ * console.log(result.statusCode, result.tempFilePath ?? result.filePath);
2078
+ * })
2079
+ * .catch((error) => {
2080
+ * console.error(error);
2081
+ * })
2082
+ * .finally(() => {
2083
+ * console.log('download finished');
2084
+ * });
2085
+ *
2086
+ * downloadTask.onProgressUpdate((event) => {
2087
+ * console.log(`downloaded ${event.progress}%`);
2088
+ * });
2089
+ *
2090
+ * downloadTask.onHeadersReceived((event) => {
2091
+ * console.log(event.header);
2092
+ * });
2093
+ * ```
2094
+ *
2095
+ * @since 0.0.40
2096
+ * @contractStatus verified | Android、iOS 均支持 HTTPS GET 下载、域名校验、临时或用户目录写入、超时、取消及进度和响应头监听。
2097
+ * @platformSupport Android | supported | 支持 HTTPS GET 下载、域名白名单校验、临时或用户目录写入、超时、取消及任务事件监听。
2098
+ * @platformSupport iOS | supported | 支持 HTTPS GET 下载、域名白名单校验、临时或用户目录写入、超时、取消及任务事件监听。
2099
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
2100
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
2101
+ * @permission none | - | none | Android,iOS | 无需额外权限
2102
+ * @precondition All | 下载地址需通过宿主侧下载域名白名单校验,单个文件不得超过 200 MB,单个智能服务同时最多执行 10 个下载任务;指定 filePath 时仅支持临时目录或用户目录。
2103
+ * @usageNote All | 未指定 filePath 时文件写入临时目录,并通过 Promise resolve 结果的 tempFilePath 返回;临时文件的生命周期由宿主管理。
2104
+ * @usageNote All | 不跟随 HTTP 重定向,3xx 响应使 Promise reject;4xx、5xx 响应在文件写入成功后仍使 Promise resolve。
2105
+ * @resultExample
2106
+ * ```json
2107
+ * {
2108
+ * "statusCode": 200,
2109
+ * "header": {
2110
+ * "content-type": "application/pdf"
2111
+ * },
2112
+ * "tempFilePath": "appletfile://temp/report.pdf"
2113
+ * }
2114
+ * ```
2115
+ * @errorCode none | - | - | Android,iOS | 下载失败会使 Promise reject,当前不提供稳定的 API 专属错误码 | 根据错误信息检查 URL、域名白名单、重定向、并发任务数、文件路径、文件大小和网络状态后重试
2116
+ *
2117
+ * @public
2118
+ */
2119
+ export declare function downloadFile(params: DownloadFileParams): DownloadTask;
2120
+
2121
+ /**
2122
+ * 下载文件参数。
2123
+ *
2124
+ * @public
2125
+ */
2126
+ export declare interface DownloadFileParams {
2127
+ /** 下载资源地址,需为完整 HTTPS URL,并通过宿主侧下载域名白名单校验。 */
2128
+ url: string;
2129
+ /**
2130
+ * 请求 Header。`referer` 和 `user-agent` 由宿主管控,业务传入值不会透传。
2131
+ *
2132
+ * @default -
2133
+ */
2134
+ header?: Record<string, string>;
2135
+ /**
2136
+ * 下载任务超时时间,单位 ms;不传或传入非正数时使用 60000,超过 300000 时按 300000 处理。
2137
+ *
2138
+ * @default 60000
2139
+ * @constraint 有效范围为 1-300000
2140
+ */
2141
+ timeout?: number;
2142
+ /**
2143
+ * 目标文件路径,仅支持 `appletfile://temp/...` 或 `appletfile://user/...`。
2144
+ *
2145
+ * @default 由系统创建临时下载文件
2146
+ */
2147
+ filePath?: string;
2148
+ }
2149
+
2150
+ /** @public */
2151
+ export declare interface DownloadFileProgressUpdate {
2152
+ /** 下载进度百分比,范围 0-100。 */
2153
+ progress: number;
2154
+ /** 已经下载的数据长度,单位 Bytes。 */
2155
+ totalBytesWritten: number;
2156
+ /** 预期需要下载的数据总长度,未知时可能为 -1。 */
2157
+ totalBytesExpectedToWrite: number;
2158
+ }
2159
+
2160
+ /** @public */
2161
+ export declare interface DownloadFileResult {
2162
+ /** HTTP 状态码。非 2xx 响应也会在下载写入成功后返回。 */
2163
+ statusCode: number;
2164
+ /** HTTP 响应头。 */
2165
+ header: Record<string, string>;
2166
+ /** 未指定 `filePath` 时返回的临时文件路径。 */
2167
+ tempFilePath?: string;
2168
+ /** 指定 `filePath` 时返回的目标文件路径。 */
2169
+ filePath?: string;
2170
+ }
2171
+
2172
+ /**
2173
+ * 下载任务。
2174
+ *
2175
+ * @public
2176
+ */
2177
+ export declare interface DownloadTask extends Promise<DownloadFileResult> {
2178
+ /**
2179
+ * 取消下载任务。
2180
+ *
2181
+ * 任务完成后调用不会产生额外效果;取消成功后下载 Promise 会 reject。
2182
+ */
2183
+ abort: () => void;
2184
+ /**
2185
+ * 监听下载进度变化。
2186
+ *
2187
+ * 同一个回调只会注册一次,可以注册多个不同回调。
2188
+ */
2189
+ onProgressUpdate: (callback: (event: DownloadFileProgressUpdate) => void) => void;
2190
+ /**
2191
+ * 取消监听下载进度变化。
2192
+ *
2193
+ * 传入 callback 时仅移除该回调;不传 callback 时移除当前任务的全部进度监听。
2194
+ */
2195
+ offProgressUpdate: (callback?: (event: DownloadFileProgressUpdate) => void) => void;
2196
+ /**
2197
+ * 监听 HTTP Response Header 事件。
2198
+ *
2199
+ * 同一个回调只会注册一次,可以注册多个不同回调。
2200
+ */
2201
+ onHeadersReceived: (callback: (event: DownloadTaskHeadersReceivedEvent) => void) => void;
2202
+ /**
2203
+ * 取消监听 HTTP Response Header 事件。
2204
+ *
2205
+ * 传入 callback 时仅移除该回调;不传 callback 时移除当前任务的全部 Header 监听。
2206
+ */
2207
+ offHeadersReceived: (callback?: (event: DownloadTaskHeadersReceivedEvent) => void) => void;
2208
+ }
2209
+
2210
+ /** @public */
2211
+ export declare interface DownloadTaskHeadersReceivedEvent {
2212
+ /** HTTP 响应头。 */
2213
+ header: Record<string, string>;
2214
+ }
2215
+
1901
2216
  /**
1902
2217
  * 允许用户录屏。
1903
2218
  *
@@ -2051,9 +2366,9 @@ export declare interface FileSystemManager {
2051
2366
  readFile: (params: ReadFileParams) => Promise<ReadFileResult>;
2052
2367
  /** 读取文件内容(同步);返回 {@link ReadFileResult},其中 data 按 encoding 为 UTF-8 或 Base64 字符串。 */
2053
2368
  readFileSync: (params: ReadFileParams) => ReadFileResult;
2054
- /** 写入文件内容(异步)。文件不存在则创建,已存在则覆盖;父目录不存在时失败。 */
2369
+ /** 写入文件内容(异步)。文件和父目录不存在则创建,文件已存在则覆盖。 */
2055
2370
  writeFile: (params: WriteFileParams) => Promise<void>;
2056
- /** 写入文件内容(同步)。文件不存在则创建,已存在则覆盖;父目录不存在时抛出异常。 */
2371
+ /** 写入文件内容(同步)。文件和父目录不存在则创建,文件已存在则覆盖。 */
2057
2372
  writeFileSync: (params: WriteFileParams) => void;
2058
2373
  /** 在文件末尾追加内容(异步)。文件不存在则创建,不会覆盖已有内容。 */
2059
2374
  appendFile: (params: AppendFileParams) => Promise<void>;
@@ -2195,6 +2510,84 @@ export declare interface GetAccountInfoResult {
2195
2510
  */
2196
2511
  export declare function getAccountInfoSync(params?: {}): GetAccountInfoResult;
2197
2512
 
2513
+ /**
2514
+ * 获取宿主应用的系统授权设置。
2515
+ *
2516
+ * 调用只读取当前系统授权状态,不会申请权限或触发系统授权弹窗。状态字段固定返回
2517
+ * `authorized`、`denied` 或 `not determined`。
2518
+ *
2519
+ * @returns 返回宿主应用相册、蓝牙、摄像头、定位、麦克风、通知和日历权限状态。
2520
+ * @example
2521
+ * ```typescript
2522
+ * import { getAppAuthorizeSetting } from '@doubao-dev/framework/api';
2523
+ *
2524
+ * const result = getAppAuthorizeSetting();
2525
+ * console.log(result.cameraAuthorized, result.microphoneAuthorized);
2526
+ * console.log(result.notificationAuthorized, result.locationReducedAccuracy);
2527
+ * ```
2528
+ *
2529
+ * @since 0.0.40
2530
+ * @contractStatus verified | Android 与 iOS 均同步返回固定 11 个字段;除 locationReducedAccuracy 为 boolean 外,其余授权状态字段均限定为 authorized、denied 或 not determined,调用不会触发权限申请。
2531
+ * @platformSupport Android | supported | 支持同步读取宿主应用授权状态。
2532
+ * @platformSupport iOS | supported | 支持同步读取宿主应用授权状态。
2533
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
2534
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
2535
+ * @permission none | - | none | Android,iOS | 无需额外权限
2536
+ * @precondition All | 无额外前置条件
2537
+ * @usageNote All | 本接口查询宿主应用权限,不等同于查询当前小程序 scope 授权。
2538
+ * @usageNote iOS | SDK 首次完成通知设置异步预热前,或应用重新激活后的刷新尚未完成时,四个通知字段可能仍为旧值或 not determined。
2539
+ * @resultExample
2540
+ * ```json
2541
+ * {
2542
+ * "albumAuthorized": "authorized",
2543
+ * "bluetoothAuthorized": "denied",
2544
+ * "cameraAuthorized": "authorized",
2545
+ * "locationAuthorized": "authorized",
2546
+ * "locationReducedAccuracy": false,
2547
+ * "microphoneAuthorized": "authorized",
2548
+ * "notificationAuthorized": "authorized",
2549
+ * "notificationAlertAuthorized": "authorized",
2550
+ * "notificationBadgeAuthorized": "denied",
2551
+ * "notificationSoundAuthorized": "authorized",
2552
+ * "phoneCalendarAuthorized": "not determined"
2553
+ * }
2554
+ * ```
2555
+ * @errorCode none | - | - | Android,iOS | 无 API 专属错误码 | 无需处理
2556
+ * @platformNote Android | albumAuthorized 和通知分项固定返回 not determined,locationReducedAccuracy 固定返回 false 且不表示实际定位精度
2557
+ * @platformNote Android | bluetoothAuthorized、cameraAuthorized、locationAuthorized、microphoneAuthorized、notificationAuthorized 和 phoneCalendarAuthorized 不区分尚未申请和已经拒绝,两种情况均返回 denied
2558
+ * @platformNote Android | locationAuthorized 在粗略或精确定位任一权限已授权时返回 authorized;phoneCalendarAuthorized 仅在读、写日历权限均授权时返回 authorized
2559
+ * @platformNote iOS | 相册 limited 映射为 authorized,通知 provisional 和 ephemeral 映射为 authorized
2560
+ *
2561
+ * @public
2562
+ */
2563
+ export declare const getAppAuthorizeSetting: (params?: {} | undefined) => GetAppAuthorizeSettingResult;
2564
+
2565
+ /** @public */
2566
+ export declare interface GetAppAuthorizeSettingResult {
2567
+ /** 相册授权状态;Android 固定返回 not determined */
2568
+ albumAuthorized: AppAuthorizeStatus;
2569
+ /** 蓝牙授权状态 */
2570
+ bluetoothAuthorized: AppAuthorizeStatus;
2571
+ /** 摄像头授权状态 */
2572
+ cameraAuthorized: AppAuthorizeStatus;
2573
+ /** 定位授权状态 */
2574
+ locationAuthorized: AppAuthorizeStatus;
2575
+ /** 是否只能使用模糊定位;仅在 iOS 且定位已授权时具有精度含义,Android 固定返回 false */
2576
+ locationReducedAccuracy: boolean;
2577
+ /** 麦克风授权状态 */
2578
+ microphoneAuthorized: AppAuthorizeStatus;
2579
+ /** 通知总授权状态 */
2580
+ notificationAuthorized: AppAuthorizeStatus;
2581
+ /** 通知提醒授权状态;Android 固定返回 not determined */
2582
+ notificationAlertAuthorized: AppAuthorizeStatus;
2583
+ /** 通知角标授权状态;Android 固定返回 not determined */
2584
+ notificationBadgeAuthorized: AppAuthorizeStatus;
2585
+ /** 通知声音授权状态;Android 固定返回 not determined */
2586
+ notificationSoundAuthorized: AppAuthorizeStatus;
2587
+ /** 系统日历授权状态 */
2588
+ phoneCalendarAuthorized: AppAuthorizeStatus;
2589
+ }
2590
+
2198
2591
  /**
2199
2592
  * 获取应用基础信息。
2200
2593
  *
@@ -3888,8 +4281,7 @@ export declare interface GetScreenBrightnessResult {
3888
4281
  * ```
3889
4282
  *
3890
4283
  * @since 0.0.36
3891
- * @contractStatus conflict | withSubscriptions 公开可传 true,但豆包 Android、iOS 当前不支持订阅模板,传入 true 会失败。
3892
- * @contractMismatch blocking | parameter | withSubscriptions | Android,iOS | withSubscriptions 为 true 时一并返回订阅消息设置 | 传入 true 时调用直接失败,只有默认的 false 可成功返回授权设置 | 依赖订阅设置的调用无法成功 | packages/open-api/src/basic/setting.ts; ai-sdk/android/ai-sdk/src/main/java/com/bytedance/ai/bridge/method/authorize; ai-sdk/ios/AISDK/Sources/JSBridge/Methods/Auth/AIBridgeGetSettingMethod.swift | 补齐豆包订阅模板设置查询,或从公开参数中移除 withSubscriptions
4284
+ * @contractStatus verified | withSubscriptions 当前仅允许 false,Android、iOS 均支持返回授权设置。
3893
4285
  * @platformSupport Android | supported | 支持获取用户的应用授权设置。
3894
4286
  * @platformSupport iOS | supported | 支持获取用户的应用授权设置。
3895
4287
  * @platformSupport PC | unsupported | 当前未提供该平台实现。
@@ -3915,12 +4307,12 @@ export declare const getSetting: (params?: GetSettingParams | undefined) => Prom
3915
4307
  /** @public */
3916
4308
  export declare interface GetSettingParams {
3917
4309
  /**
3918
- * 是否同时获取用户订阅消息的订阅状态,默认不获取。
4310
+ * 是否同时获取用户订阅消息的订阅状态;当前仅支持 false。
3919
4311
  *
3920
4312
  * @default false
3921
- * @constraint 豆包 Android、iOS 当前不支持订阅模板,传入 true 时调用会失败
4313
+ * @constraint 豆包 Android、iOS 当前不支持订阅模板,仅支持 false
3922
4314
  */
3923
- withSubscriptions?: boolean;
4315
+ withSubscriptions?: false;
3924
4316
  }
3925
4317
 
3926
4318
  /** @public */
@@ -4611,6 +5003,17 @@ export declare const hideLoading: (params?: HideInteractionParams | undefined) =
4611
5003
  * await hideToast();
4612
5004
  * ```
4613
5005
  *
5006
+ * @since 0.0.26
5007
+ * @contractStatus verified | 无参数、无返回字段,与 Android、iOS 实现一致。
5008
+ * @platformSupport Android | supported | 支持隐藏当前 Toast。
5009
+ * @platformSupport iOS | supported | 支持隐藏当前 Toast。
5010
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
5011
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
5012
+ * @permission none | - | none | Android,iOS | 无需额外权限
5013
+ * @precondition All | 无额外前置条件
5014
+ * @usageNote All | 当前没有 Toast 时调用无副作用。
5015
+ * @errorCode common | 102 | Android
5016
+ *
4614
5017
  * @public
4615
5018
  */
4616
5019
  export declare const hideToast: (params?: HideInteractionParams | undefined) => Promise<object>;
@@ -5344,84 +5747,6 @@ export declare interface NotifyBLECharacteristicValueChangeParams {
5344
5747
  type?: BluetoothNotifyType;
5345
5748
  }
5346
5749
 
5347
- /**
5348
- * 取消注册地理位置变化回调。
5349
- *
5350
- * @example
5351
- * ```typescript
5352
- * import {
5353
- * offLocationChange,
5354
- * onLocationChange,
5355
- * type LocationChangeEvent
5356
- * } from '@doubao-dev/framework/api';
5357
- *
5358
- * const handleLocationChange = ({ latitude, longitude }: LocationChangeEvent) => {
5359
- * console.log(latitude, longitude);
5360
- * };
5361
- *
5362
- * onLocationChange(handleLocationChange);
5363
- * offLocationChange(handleLocationChange);
5364
- * ```
5365
- * @since 0.0.32
5366
- * @contractStatus verified | 注销指定监听和清空全部监听的行为由公开可选参数准确表达
5367
- * @platformSupport Android | supported | 支持注销位置变化监听
5368
- * @platformSupport iOS | supported | 支持注销位置变化监听
5369
- * @platformSupport PC | unsupported | 暂不支持
5370
- * @platformSupport HarmonyOS | unsupported | 暂不支持
5371
- * @permission none | - | none | Android,iOS | 无需额外权限
5372
- * @precondition All | 无额外前置条件
5373
- * @usageNote All | 传入注册时使用的同一个 callback 可只取消该监听;省略 callback 会取消全部位置变化回调
5374
- * @errorCode none | - | - | Android,iOS | 同步注销操作不产生 API 专属错误码 | 无需处理
5375
- *
5376
- * @public
5377
- */
5378
- export declare function offLocationChange(
5379
- /**
5380
- * 要取消的回调;省略时取消当前 API 注册的全部位置变化回调。
5381
- *
5382
- * @default 取消全部位置变化回调
5383
- */
5384
- callback?: LocationChangeListener): void;
5385
-
5386
- /**
5387
- * 取消注册位置更新异常回调。
5388
- *
5389
- * @example
5390
- * ```typescript
5391
- * import {
5392
- * offLocationChangeError,
5393
- * onLocationChangeError,
5394
- * type LocationChangeErrorEvent
5395
- * } from '@doubao-dev/framework/api';
5396
- *
5397
- * const handleLocationError = ({ errMsg, errCode }: LocationChangeErrorEvent) => {
5398
- * console.error(errMsg, errCode);
5399
- * };
5400
- *
5401
- * onLocationChangeError(handleLocationError);
5402
- * offLocationChangeError(handleLocationError);
5403
- * ```
5404
- * @since 0.0.32
5405
- * @contractStatus verified | 注销指定监听和清空全部监听的行为由公开可选参数准确表达
5406
- * @platformSupport Android | supported | 支持注销位置异常监听
5407
- * @platformSupport iOS | supported | 支持注销位置异常监听
5408
- * @platformSupport PC | unsupported | 暂不支持
5409
- * @platformSupport HarmonyOS | unsupported | 暂不支持
5410
- * @permission none | - | none | Android,iOS | 无需额外权限
5411
- * @precondition All | 无额外前置条件
5412
- * @usageNote All | 传入注册时使用的同一个 callback 可只取消该监听;省略 callback 会取消全部位置异常回调
5413
- * @errorCode none | - | - | Android,iOS | 同步注销操作不产生 API 专属错误码 | 无需处理
5414
- *
5415
- * @public
5416
- */
5417
- export declare function offLocationChangeError(
5418
- /**
5419
- * 要取消的回调;省略时取消当前 API 注册的全部位置异常回调。
5420
- *
5421
- * @default 取消全部位置异常回调
5422
- */
5423
- callback?: LocationChangeErrorListener): void;
5424
-
5425
5750
  /**
5426
5751
  * 监听加速度数据变化事件。
5427
5752
  *
@@ -5815,13 +6140,17 @@ export declare const onKeyboardHeightChange: ClientEventRegistry<KeyboardHeightC
5815
6140
  /**
5816
6141
  * 注册地理位置变化回调。
5817
6142
  *
6143
+ * @returns 返回取消当前监听函数的函数。
6144
+ *
5818
6145
  * @example
5819
6146
  * ```typescript
5820
6147
  * import { onLocationChange } from '@doubao-dev/framework/api';
5821
6148
  *
5822
- * onLocationChange(({ latitude, longitude }) => {
6149
+ * const unsubscribe = onLocationChange(({ latitude, longitude }) => {
5823
6150
  * console.log(latitude, longitude);
5824
6151
  * });
6152
+ *
6153
+ * unsubscribe();
5825
6154
  * ```
5826
6155
  * @since 0.0.32
5827
6156
  * @contractStatus verified | 豆包 Android、iOS 成功事件均会返回必需的 latitude 和 longitude,其他字段可由公开可选类型承载
@@ -5832,7 +6161,7 @@ export declare const onKeyboardHeightChange: ClientEventRegistry<KeyboardHeightC
5832
6161
  * @platformSupport HarmonyOS | unsupported | 暂不支持
5833
6162
  * @permission none | - | none | Android,iOS | 无需额外权限
5834
6163
  * @precondition All | 无额外前置条件
5835
- * @usageNote All | 建议在调用 `startLocationUpdate` 前注册;同一 callback 重复注册不会产生多个监听,不再使用时调用 `offLocationChange` 释放监听
6164
+ * @usageNote All | 建议在调用 `startLocationUpdate` 前注册;不再使用时调用返回的取消函数释放当前监听
5836
6165
  * @usageNote All | 定位信息属于敏感数据,仅在业务确有需要时监听和使用;事件回调频率不固定
5837
6166
  * @resultExample
5838
6167
  * ```json
@@ -5854,18 +6183,22 @@ export declare const onKeyboardHeightChange: ClientEventRegistry<KeyboardHeightC
5854
6183
  *
5855
6184
  * @public
5856
6185
  */
5857
- export declare function onLocationChange(callback: LocationChangeListener): void;
6186
+ export declare function onLocationChange(callback: LocationChangeListener): () => void;
5858
6187
 
5859
6188
  /**
5860
6189
  * 注册位置更新异常回调。
5861
6190
  *
6191
+ * @returns 返回取消当前监听函数的函数。
6192
+ *
5862
6193
  * @example
5863
6194
  * ```typescript
5864
6195
  * import { onLocationChangeError } from '@doubao-dev/framework/api';
5865
6196
  *
5866
- * onLocationChangeError(({ errMsg, errCode }) => {
6197
+ * const unsubscribe = onLocationChangeError(({ errMsg, errCode }) => {
5867
6198
  * console.log(errMsg, errCode);
5868
6199
  * });
6200
+ *
6201
+ * unsubscribe();
5869
6202
  * ```
5870
6203
  * @since 0.0.32
5871
6204
  * @contractStatus verified | 错误信息必返、错误码可选的公开类型可准确表达双端事件
@@ -5876,7 +6209,7 @@ export declare function onLocationChange(callback: LocationChangeListener): void
5876
6209
  * @platformSupport HarmonyOS | unsupported | 暂不支持
5877
6210
  * @permission none | - | none | Android,iOS | 无需额外权限
5878
6211
  * @precondition All | 无额外前置条件
5879
- * @usageNote All | 建议在调用 `startLocationUpdate` 前注册;同一 callback 重复注册不会产生多个监听,不再使用时调用 `offLocationChangeError` 释放监听
6212
+ * @usageNote All | 建议在调用 `startLocationUpdate` 前注册;不再使用时调用返回的取消函数释放当前监听
5880
6213
  * @resultExample
5881
6214
  * ```json
5882
6215
  * {
@@ -5901,7 +6234,7 @@ export declare function onLocationChange(callback: LocationChangeListener): void
5901
6234
  *
5902
6235
  * @public
5903
6236
  */
5904
- export declare function onLocationChangeError(callback: LocationChangeErrorListener): void;
6237
+ export declare function onLocationChangeError(callback: LocationChangeErrorListener): () => void;
5905
6238
 
5906
6239
  /**
5907
6240
  * 监听网络状态变化事件。
@@ -6296,6 +6629,26 @@ export declare interface OpenLocationParams {
6296
6629
  * }
6297
6630
  * ```
6298
6631
  *
6632
+ * @since 0.0.39
6633
+ * @contractStatus verified | withSubscriptions 当前仅允许 false,Android、iOS 均支持打开设置页并返回授权设置。
6634
+ * @platformSupport Android | supported | 支持打开授权设置页并在关闭后返回最新授权设置。
6635
+ * @platformSupport iOS | supported | 支持打开授权设置页并在关闭后返回最新授权设置。
6636
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
6637
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
6638
+ * @permission none | - | none | Android,iOS | 无需额外权限
6639
+ * @precondition All | 无额外前置条件,不要求在用户点击事件中调用。
6640
+ * @usageNote All | 豆包当前不支持订阅模板,不要传入 withSubscriptions: true。
6641
+ * @resultExample
6642
+ * ```json
6643
+ * {
6644
+ * "authSetting": {
6645
+ * "scope.userLocation": true,
6646
+ * "scope.record": false
6647
+ * }
6648
+ * }
6649
+ * ```
6650
+ * @errorCode none | - | - | Android,iOS | 传入 withSubscriptions: true 等失败当前只返回文本信息,未稳定返回顶层 errNo/errMsg | 不要传入 withSubscriptions: true
6651
+ *
6299
6652
  * @public
6300
6653
  */
6301
6654
  export declare const openSetting: (params?: OpenSettingOptions | undefined) => Promise<OpenSettingResult>;
@@ -6303,9 +6656,12 @@ export declare const openSetting: (params?: OpenSettingOptions | undefined) => P
6303
6656
  /** @public */
6304
6657
  export declare interface OpenSettingOptions {
6305
6658
  /**
6306
- * 是否同时获取用户订阅消息的订阅状态,默认不获取。
6659
+ * 是否同时获取用户订阅消息的订阅状态;当前仅支持 false。
6660
+ *
6661
+ * @default false
6662
+ * @constraint 豆包 Android、iOS 当前不支持订阅模板,仅支持 false
6307
6663
  */
6308
- withSubscriptions?: boolean;
6664
+ withSubscriptions?: false;
6309
6665
  }
6310
6666
 
6311
6667
  /** @public */
@@ -7408,10 +7764,10 @@ export declare type SelectedMessageFileType = 'video' | 'image' | 'file';
7408
7764
  * 以用户身份发送后续消息,触发新一轮对话或 API 调用。
7409
7765
  *
7410
7766
  * @param params - 要发送的后续消息内容。
7411
- * @returns 返回一个 Promise,在消息发送成功时解析。
7767
+ * @returns 返回一个 Promise,在消息发送请求提交后解析。
7412
7768
  * @remarks
7413
- * 可在 Widget、智能服务页面或 Worker 中调用。宿主会根据调用上下文关联会话:Widget 使用其所在
7414
- * 会话,从 Widget 打开的页面沿用该会话,其他页面和 Worker 使用主会话。
7769
+ * 可在卡片或智能服务页面中调用,不支持在 app.ts 代码中调用。客户端会根据调用上下文关联会话:
7770
+ * 卡片使用其所在会话,从卡片打开的页面沿用该会话,其他页面使用主会话。
7415
7771
  *
7416
7772
  * @example
7417
7773
  * ```typescript
@@ -7431,6 +7787,18 @@ export declare type SelectedMessageFileType = 'video' | 'image' | 'file';
7431
7787
  * });
7432
7788
  * ```
7433
7789
  *
7790
+ * @since 0.0.37
7791
+ * @contractStatus verified | 公开参数与 Android、iOS 的消息提交行为一致。
7792
+ * @platformSupport Android | supported | 支持在卡片或智能服务页面中发送后续消息。
7793
+ * @platformSupport iOS | supported | 支持在卡片和智能服务页面中发送后续消息。
7794
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
7795
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
7796
+ * @permission none | - | none | Android,iOS | 无需额外权限
7797
+ * @precondition Android | 在卡片或智能服务页面中调用。
7798
+ * @precondition iOS | 在卡片或智能服务页面中调用,且当前上下文已关联有效会话。
7799
+ * @usageNote All | Promise 解析表示发送请求已提交,不表示消息已成功送达;实际发送失败不会通过该 Promise 返回。
7800
+ * @errorCode none | - | - | Android,iOS | 调用失败时未稳定返回 API 专属错误码 | 检查 content 与调用场景后重试
7801
+ *
7434
7802
  * @public
7435
7803
  */
7436
7804
  export declare const sendFollowUpMessage: (params: SendFollowUpMessageParams) => Promise<object>;
@@ -7441,7 +7809,10 @@ export declare const sendFollowUpMessage: (params: SendFollowUpMessageParams) =>
7441
7809
  * @public
7442
7810
  */
7443
7811
  export declare interface SendFollowUpMessageParams {
7444
- /** 消息内容。 */
7812
+ /**
7813
+ * 消息内容。
7814
+ * @constraint 至少包含一条 text 类型且 text 不为空白的消息;第一条符合条件的消息作为本轮用户输入。
7815
+ */
7445
7816
  content: Content[];
7446
7817
  }
7447
7818
 
@@ -7476,7 +7847,7 @@ export declare interface SendFollowUpMessageParams {
7476
7847
  * @usageNote All | 该 API 已废弃,请改用 dispatchActionDirective 描述用户行为并约束模型后续动作。
7477
7848
  * @errorCode none | - | - | Android,iOS | 无 API 专属错误码 | 无需处理
7478
7849
  *
7479
- * @public
7850
+ * @internal
7480
7851
  */
7481
7852
  export declare const sendQueryMessage: (params: SendQueryMessageParams) => Promise<object>;
7482
7853
 
@@ -7579,7 +7950,7 @@ export declare type SensorInterval = 'game' | 'ui' | 'normal';
7579
7950
  * @usageNote All | 该 API 已废弃,请改用 updateModelContext 按任务或实体维度补充模型上下文。
7580
7951
  * @errorCode none | - | - | Android,iOS | 无 API 专属错误码 | 无需处理
7581
7952
  *
7582
- * @public
7953
+ * @internal
7583
7954
  */
7584
7955
  export declare const setAdditionalContext: (params: SetAdditionalContextParams) => Promise<object>;
7585
7956
 
@@ -9556,27 +9927,83 @@ export declare interface UpdateWidgetParams {
9556
9927
  * @param params 上传参数,字段见 {@link UploadFileParams}。
9557
9928
  * @returns 当前上传任务对应的 {@link UploadTask}。
9558
9929
  *
9559
- * @public
9560
- */
9561
- export declare function uploadFile(params: UploadFileParams): UploadTask;
9562
-
9563
- /**
9564
- * 文件上传失败回调结果。
9930
+ * @remarks
9931
+ * `uploadFile` 会同步返回可监听、可中断的 Promise 任务对象。
9932
+ * 建议在调用后立即注册进度和响应头监听;不再需要上传时调用 `UploadTask.abort`。
9933
+ * @example
9934
+ * ```typescript
9935
+ * import { uploadFile } from '@doubao-dev/framework/api';
9936
+ *
9937
+ * const task = uploadFile({
9938
+ * url: 'https://example.com/upload',
9939
+ * filePath: 'ttfile://temp/example.png',
9940
+ * name: 'file',
9941
+ * formData: { scene: 'profile' }
9942
+ * });
9943
+ *
9944
+ * task
9945
+ * .then((result) => {
9946
+ * console.log(result.statusCode, result.data);
9947
+ * })
9948
+ * .catch((error) => {
9949
+ * console.error(error);
9950
+ * })
9951
+ * .finally(() => {
9952
+ * console.log('upload finished');
9953
+ * });
9954
+ *
9955
+ * task.onProgressUpdate((event) => {
9956
+ * console.log(event.progress, event.totalBytesSent);
9957
+ * });
9958
+ * task.onHeadersReceived((event) => {
9959
+ * console.log(event.header);
9960
+ * });
9961
+ *
9962
+ * // 不再需要上传时中断任务。
9963
+ * // task.abort();
9964
+ * ```
9965
+ *
9966
+ * @since 0.0.39
9967
+ * @contractStatus verified | enableProfile 当前仅允许 false,Android、iOS 均支持正常发起上传。
9968
+ * @platformSupport Android | supported | 支持文件上传、进度监听、响应头监听和中断任务。
9969
+ * @platformSupport iOS | supported | 支持文件上传、进度监听、响应头监听和中断任务。
9970
+ * @platformSupport PC | unsupported | 当前未提供该平台实现。
9971
+ * @platformSupport HarmonyOS | unsupported | 当前未提供该平台实现。
9972
+ * @permission none | - | none | Android,iOS | 无需额外权限
9973
+ * @precondition All | url 需命中当前智能服务的上传域名白名单,filePath 需指向当前智能服务可访问的本地文件。
9974
+ * @usageNote All | 上传成功时 Promise resolve,上传失败或取消时 Promise reject;任务结束或不再使用时应移除监听,必要时调用 abort。
9975
+ * @errorCode errNo | 121999 | uploadFile:fail url is invalid | Android,iOS | url 缺失或不是有效上传地址 | 传入完整的 HTTP/HTTPS URL
9976
+ * @errorCode errNo | 121999 | uploadFile:fail name is required | Android,iOS | name 缺失或为空 | 传入服务端接收文件所使用的 form field name
9977
+ * @errorCode errNo | 121901 | uploadFile:fail url not in domain list | Android,iOS | url 未命中上传域名白名单 | 在智能服务配置中添加上传域名后重试
9978
+ * @errorCode errNo | 121902 | uploadFile:fail no file exist | Android,iOS | filePath 为空、文件不存在或路径不是文件 | 使用文件 API 获取当前智能服务可访问的有效文件路径
9979
+ * @errorCode errNo | 121905 | uploadFile:fail upload file abort | Android,iOS | 调用 UploadTask.abort 中断上传 | 按业务需要处理取消状态,无需自动重试
9980
+ * @errorCode errNo | 121906 | uploadFile:fail file path permission denied | Android,iOS | 当前智能服务无权访问 filePath | 改用当前智能服务目录内的文件
9981
+ * @errorCode errNo | 121920 | uploadFile:fail request time out | Android,iOS | 上传超过宿主超时时间 | 检查网络或设置合理的 timeout 后重试
9982
+ * @errorCode errNo | 121985 | uploadFile:fail network unavailable | Android,iOS | 当前网络不可用 | 恢复网络连接后重试
9983
+ * @errorCode errNo | 121991 | uploadFile:fail network error | Android,iOS | 上传过程中发生网络错误 | 检查网络和服务端状态后重试
9984
+ * @errorCode errNo | 121992 | uploadFile:fail enableProfile is not supported | Android,iOS | enableProfile 设置为 true | 移除 enableProfile 或设置为 false
9985
+ * @resultExample
9986
+ * ```json
9987
+ * {
9988
+ * "statusCode": 200,
9989
+ * "header": {
9990
+ * "content-type": "application/json"
9991
+ * },
9992
+ * "data": "{\"ok\":true}"
9993
+ * }
9994
+ * ```
9995
+ * @errorExample
9996
+ * ```json
9997
+ * {
9998
+ * "errMsg": "uploadFile:fail request time out",
9999
+ * "errNo": 121920,
10000
+ * "errorCode": 121920
10001
+ * }
10002
+ * ```
9565
10003
  *
9566
10004
  * @public
9567
10005
  */
9568
- export declare interface UploadFileFailCallbackResult {
9569
- /** 错误信息。 */
9570
- errMsg: string;
9571
- /** 错误码,尽量对齐抖音小程序 uploadFile 错误码。 */
9572
- errNo?: number;
9573
- /** 抖音小程序风格错误码字段。 */
9574
- errorCode?: number;
9575
- /** HTTP 状态码;请求已收到响应但被判定失败时可能存在。 */
9576
- statusCode?: number;
9577
- /** HTTP 响应头;请求已收到响应但被判定失败时可能存在。 */
9578
- header?: Record<string, string>;
9579
- }
10006
+ export declare function uploadFile(params: UploadFileParams): UploadTask;
9580
10007
 
9581
10008
  /**
9582
10009
  * 文件上传参数。
@@ -9590,28 +10017,38 @@ export declare interface UploadFileParams {
9590
10017
  filePath: string;
9591
10018
  /** 文件对应的 form field name/key,服务端通过该 key 获取文件内容;multipart filename 使用 filePath 的 basename。 */
9592
10019
  name: string;
9593
- /** HTTP 请求 Header。`referer`、`user-agent`、`content-type` 等宿主管控字段不会被业务覆盖。 */
10020
+ /**
10021
+ * HTTP 请求 Header。`referer`、`user-agent`、`content-type` 等宿主管控字段不会被业务覆盖。
10022
+ *
10023
+ * @default -
10024
+ */
9594
10025
  header?: Record<string, string>;
9595
- /** 额外的 form-data 字段。对象或数组值会按 JSON 字符串传递。 */
10026
+ /**
10027
+ * 额外的 form-data 字段。对象或数组值会按 JSON 字符串传递。
10028
+ *
10029
+ * @default -
10030
+ */
9596
10031
  formData?: Record<string, unknown>;
9597
- /** 超时时间,单位 ms。 */
10032
+ /**
10033
+ * 超时时间,单位 ms;不传时使用宿主侧默认超时配置。
10034
+ *
10035
+ * @default -
10036
+ */
9598
10037
  timeout?: number;
9599
- /** 是否返回网络 profile。当前 native upload 链路暂不支持,设置为 true 会触发 fail。 */
9600
- enableProfile?: boolean;
9601
- /** 上传成功回调。 */
9602
- success?: (result: UploadFileSuccessCallbackResult) => void;
9603
- /** 上传失败回调。 */
9604
- fail?: (result: UploadFileFailCallbackResult) => void;
9605
- /** 上传完成回调,成功或失败都会触发。 */
9606
- complete?: (result: UploadFileSuccessCallbackResult | UploadFileFailCallbackResult) => void;
10038
+ /**
10039
+ * 是否返回网络 profile。当前 native upload 链路暂不支持,仅支持 false。
10040
+ *
10041
+ * @default false
10042
+ */
10043
+ enableProfile?: false;
9607
10044
  }
9608
10045
 
9609
10046
  /**
9610
- * 文件上传成功回调结果。
10047
+ * 文件上传结果。
9611
10048
  *
9612
10049
  * @public
9613
10050
  */
9614
- export declare interface UploadFileSuccessCallbackResult {
10051
+ export declare interface UploadFileResult {
9615
10052
  /** HTTP 状态码。 */
9616
10053
  statusCode: number;
9617
10054
  /** HTTP 响应头。 */
@@ -9625,17 +10062,37 @@ export declare interface UploadFileSuccessCallbackResult {
9625
10062
  *
9626
10063
  * @public
9627
10064
  */
9628
- export declare interface UploadTask {
9629
- /** 中断上传任务。 */
9630
- abort(): void;
9631
- /** 监听上传进度变化。 */
9632
- onProgressUpdate(callback: (event: UploadTaskProgressUpdateEvent) => void): void;
9633
- /** 取消监听上传进度变化;不传 callback 时移除当前任务的全部进度监听。 */
9634
- offProgressUpdate(callback?: (event: UploadTaskProgressUpdateEvent) => void): void;
9635
- /** 监听 HTTP Response Header 事件。 */
9636
- onHeadersReceived(callback: (event: UploadTaskHeadersReceivedEvent) => void): void;
9637
- /** 取消监听 HTTP Response Header 事件;不传 callback 时移除当前任务的全部 Header 监听。 */
9638
- offHeadersReceived(callback?: (event: UploadTaskHeadersReceivedEvent) => void): void;
10065
+ export declare interface UploadTask extends Promise<UploadFileResult> {
10066
+ /**
10067
+ * 中断当前上传任务。
10068
+ *
10069
+ * 中断成功后上传 Promise reject;任务已经结束时调用无副作用。
10070
+ */
10071
+ abort: () => void;
10072
+ /**
10073
+ * 监听上传进度变化。
10074
+ *
10075
+ * 同一个任务可以注册多个回调,每次收到宿主进度事件时依次调用。
10076
+ */
10077
+ onProgressUpdate: (callback: (event: UploadTaskProgressUpdateEvent) => void) => void;
10078
+ /**
10079
+ * 取消监听上传进度变化。
10080
+ *
10081
+ * 传入 callback 时只移除该回调;不传 callback 时移除当前任务的全部进度监听。
10082
+ */
10083
+ offProgressUpdate: (callback?: (event: UploadTaskProgressUpdateEvent) => void) => void;
10084
+ /**
10085
+ * 监听 HTTP Response Header 事件。
10086
+ *
10087
+ * 同一个任务可以注册多个回调,宿主收到上传响应头时依次调用。
10088
+ */
10089
+ onHeadersReceived: (callback: (event: UploadTaskHeadersReceivedEvent) => void) => void;
10090
+ /**
10091
+ * 取消监听 HTTP Response Header 事件。
10092
+ *
10093
+ * 传入 callback 时只移除该回调;不传 callback 时移除当前任务的全部 Header 监听。
10094
+ */
10095
+ offHeadersReceived: (callback?: (event: UploadTaskHeadersReceivedEvent) => void) => void;
9639
10096
  }
9640
10097
 
9641
10098
  /**
@@ -9930,7 +10387,7 @@ export declare interface WriteBLECharacteristicValueParams {
9930
10387
  *
9931
10388
  * @remarks
9932
10389
  * - 如果文件不存在会自动创建;如果文件已存在则会覆盖原有内容。
9933
- * - 父目录不存在时写入会失败,需先通过 {@link FileSystemManager.mkdir} 创建目录。
10390
+ * - 父目录不存在时会自动创建。
9934
10391
  *
9935
10392
  * @public
9936
10393
  */
@@ -328,6 +328,11 @@ export declare interface CanvasProps {
328
328
  * 元素的唯一标识
329
329
  */
330
330
  id?: string;
331
+ /**
332
+ * 原生属性透传,一般由自带画布渲染的三方库使用,业务代码请改用 `ref` 上的绘图方法。
333
+ * 传入后画布交由外部通过 `attachToCanvasView(name)` 接管,组件不再创建自己的画布实例,`ref` 上的绘图方法随之失效。
334
+ */
335
+ name?: string;
331
336
  /**
332
337
  * 手指触摸动作开始
333
338
  * @eventProperty
@@ -3032,6 +3037,47 @@ export declare interface RenderLongImageSegmentsOptions {
3032
3037
  listItemReuseIdentifierPrefix?: string;
3033
3038
  }
3034
3039
 
3040
+ /** An allowlisted HTML element in a rich-text node tree. */
3041
+ export declare interface RichTextElementNode {
3042
+ /** Optional mini-program-compatible element node discriminator. */
3043
+ type?: 'node';
3044
+ /** Name of the allowlisted HTML element to render. */
3045
+ name: string;
3046
+ /** Element attributes; unsupported attributes are removed during parsing. */
3047
+ attrs?: Record<string, string>;
3048
+ /** Nested text and element nodes rendered inside this element. */
3049
+ children?: RichTextNode[];
3050
+ }
3051
+
3052
+ /** A text or element node accepted by RichText. */
3053
+ export declare type RichTextNode = RichTextTextNode | RichTextElementNode;
3054
+
3055
+ /** Props for the mini-program-compatible RichText adapter. */
3056
+ export declare interface RichTextProps {
3057
+ /**
3058
+ * An HTML string or a structured node array to render. Unsupported nodes and
3059
+ * attributes are removed before the content is passed to Lynx UI RichText.
3060
+ */
3061
+ nodes?: string | RichTextNode[];
3062
+ /** How plain spaces in text nodes are converted. */
3063
+ space?: RichTextSpace;
3064
+ /** Class name applied to the outer Lynx container. */
3065
+ className?: string;
3066
+ /** Inline style applied to the outer Lynx container. */
3067
+ style?: CSSProperties | string;
3068
+ }
3069
+
3070
+ /** Whitespace replacement mode compatible with mini-program rich-text. */
3071
+ export declare type RichTextSpace = '' | 'nbsp' | 'ensp' | 'emsp';
3072
+
3073
+ /** Text content in a rich-text node tree. */
3074
+ export declare interface RichTextTextNode {
3075
+ /** Identifies this entry as a text node. */
3076
+ type: 'text';
3077
+ /** Plain text rendered at this position in the node tree. */
3078
+ text: string;
3079
+ }
3080
+
3035
3081
  export declare interface RouteLabel {
3036
3082
  /**
3037
3083
  * 标签 ID。
@@ -3055,6 +3101,11 @@ export declare interface RouteLabel {
3055
3101
  * @defaultValue 12
3056
3102
  */
3057
3103
  fontSize?: number;
3104
+ /**
3105
+ * 标签文字字重。
3106
+ * @defaultValue "normal"
3107
+ */
3108
+ fontWeight?: 'normal' | 'bold';
3058
3109
  /**
3059
3110
  * 标签边框颜色。
3060
3111
  * @defaultValue "#cccccc"
@@ -4626,6 +4677,86 @@ declare interface WebGLContextAttributes_2 {
4626
4677
  antialias?: boolean;
4627
4678
  }
4628
4679
 
4680
+ /**
4681
+ * 网页视图组件,用于在智能服务页面内承载 H5 页面。
4682
+ *
4683
+ * @remarks
4684
+ * ## 与 H5 双向通信
4685
+ *
4686
+ * H5 页面需要先引入 WebView JSSDK,才能收发消息。可以用 script 标签引入:
4687
+ *
4688
+ * ```html
4689
+ * <script src="https://lf3-static.bytednsdoc.com/obj/eden-cn/msvdeh7pfhpquly/doubao-jssdk-0.0.34-canary-1022d83a-20260615035129.js"></script>
4690
+ * ```
4691
+ *
4692
+ * 构建型项目也可以安装 `@doubao-dev/webview-jssdk` 后导入,导入时会同时挂载全局 `window.doubao`:
4693
+ *
4694
+ * ```js
4695
+ * import doubao from '@doubao-dev/webview-jssdk';
4696
+ * // 或按需导入:import { postMessage, onMessage } from '@doubao-dev/webview-jssdk';
4697
+ * ```
4698
+ *
4699
+ * 应用侧:`src` 指向 H5 地址,`ref` 用于拿到 `postMessage`,`onMessage` 接收 H5 消息。
4700
+ *
4701
+ * ```tsx
4702
+ * import { definePage, useRef } from '@doubao-dev/framework';
4703
+ * import type { WebViewRef } from '@doubao-dev/framework/components';
4704
+ *
4705
+ * function WebViewPage() {
4706
+ * const webViewRef = useRef<WebViewRef>(null);
4707
+ *
4708
+ * return (
4709
+ * <web-view
4710
+ * ref={webViewRef}
4711
+ * src="https://example.com/page"
4712
+ * // 网页加载完成后再发首条消息,H5 才接得住
4713
+ * onLoad={(event) => webViewRef.current?.postMessage({ type: 'ready', src: event.src })}
4714
+ * // H5 → 应用:event.data 就是 H5 传入的原始值
4715
+ * onMessage={(event) => {
4716
+ * const data = event.data as { type?: string };
4717
+ * if (data?.type === 'submit') {
4718
+ * webViewRef.current?.postMessage({ type: 'ack', timestamp: Date.now() });
4719
+ * }
4720
+ * }}
4721
+ * onError={(event) => console.error(event.errorMsg, event.errorCode)}
4722
+ * />
4723
+ * );
4724
+ * }
4725
+ *
4726
+ * export default definePage({ render: () => <WebViewPage /> });
4727
+ * ```
4728
+ *
4729
+ * H5 侧:`doubao.onMessage` 接收应用消息并返回注销函数,`doubao.postMessage` 发送消息给应用。
4730
+ *
4731
+ * ```js
4732
+ * const off = doubao.onMessage((raw) => {
4733
+ * // 应用侧发送的对象会被序列化,这里统一还原
4734
+ * const data = typeof raw === 'string' ? JSON.parse(raw) : raw;
4735
+ *
4736
+ * if (data.type === 'ready') {
4737
+ * // H5 → 应用:参数是 { data },不是直接传值
4738
+ * doubao.postMessage({ data: { type: 'submit', payload: { name: '豆包' } } });
4739
+ * }
4740
+ * });
4741
+ *
4742
+ * // 页面卸载或不再需要时注销
4743
+ * // off();
4744
+ * ```
4745
+ *
4746
+ * 三个容易踩的点:
4747
+ *
4748
+ * - 首条消息放在 `onLoad` 之后发,H5 尚未加载完成时发送的消息会丢失。
4749
+ * - 两个方向的数据形态不同:应用 → H5 时非字符串会被 `JSON.stringify`,H5 收到的是 JSON 字符串,
4750
+ * 需要自行 `JSON.parse`;H5 → 应用时 `onMessage` 的 `event.data` 保持 H5 传入的原始值。
4751
+ * - 如果两侧都写成“收到就回”,务必按消息 `type` 区分,否则会无限互相回声。
4752
+ *
4753
+ * 除消息通道外,H5 还可以调用 `doubao.setTitle({ title })` 同步应用侧 WebView 头部标题。
4754
+ *
4755
+ * Web 模拟器中的 `<web-view>` 通过本地代理承载 H5 页面,页面脚本读取到的
4756
+ * `location.origin` / `location.host` 可能是调试器本地域名,而不是真机 WebView 中的业务域名。
4757
+ * 如果 H5 依赖 `location.origin` 或 `location.host` 判断测试环境、线上环境、白名单或鉴权逻辑,
4758
+ * Web 模拟器结果可能与真机不一致,请使用真机调试确认。
4759
+ */
4629
4760
  export declare interface WebViewProps {
4630
4761
  /**
4631
4762
  * 用于获取 WebView 实例方法
package/dist/index.d.ts CHANGED
@@ -583,6 +583,13 @@ export { NamedExoticComponent }
583
583
 
584
584
  export { NewLifecycle }
585
585
 
586
+ /**
587
+ * Register the runtime error handler.
588
+ *
589
+ * Calling this again replaces the previously registered handler.
590
+ */
591
+ export declare function onError(callback: (error: Error) => void): void;
592
+
586
593
  export declare interface Page<Data extends AnyObject = AnyObject> extends DefineUIToolOptions<Data> {
587
594
  __UI__: boolean;
588
595
  __PAGE__: boolean;
package/jsx-runtime.d.ts CHANGED
@@ -26,6 +26,7 @@ export namespace JSX {
26
26
  popup: import('./components.d.ts').PopupProps;
27
27
  radio: import('./components.d.ts').RadioProps;
28
28
  'radio-group': import('./components.d.ts').RadioGroupProps;
29
+ 'rich-text': import('./components.d.ts').RichTextProps;
29
30
  slider: import('./components.d.ts').SliderProps;
30
31
  switch: import('./components.d.ts').SwitchProps;
31
32
  swiper: import('./components.d.ts').SwiperProps;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@doubao-dev/framework",
3
- "version": "0.0.39",
3
+ "version": "0.0.40",
4
4
  "type": "module",
5
5
  "types": "./dist/index.d.ts",
6
6
  "exports": {
@@ -68,7 +68,7 @@
68
68
  "types.d.ts"
69
69
  ],
70
70
  "dependencies": {
71
- "@lynx-js/types": "4.0.0",
71
+ "@lynx-js/types": "4.1.0",
72
72
  "@types/react": "18.3.27"
73
73
  },
74
74
  "publishConfig": {