1/* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16/** 17 * @file 18 * @kit ArkUI 19 */ 20 21/** 22 * Enumeration of different types of DpiFollowStrategy. 23 * 24 * @enum { number } 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @systemapi 27 * @since 12 28 */ 29declare enum DpiFollowStrategy { 30 /** 31 * Followed the host DPI. 32 * 33 * @syscap SystemCapability.ArkUI.ArkUI.Full 34 * @systemapi 35 * @since 12 36 */ 37 FOLLOW_HOST_DPI = 0, 38 39 /** 40 * Followed the UIExtensionAbility. 41 * 42 * @syscap SystemCapability.ArkUI.ArkUI.Full 43 * @systemapi 44 * @since 12 45 */ 46 FOLLOW_UI_EXTENSION_ABILITY_DPI = 1, 47} 48 49/** 50 * Enumeration of different types of WindowModeFollowStrategy. 51 * @enum { number } 52 * @syscap SystemCapability.ArkUI.ArkUI.Full 53 * @systemapi 54 * @since 18 55 */ 56declare enum WindowModeFollowStrategy { 57 /** 58 * Followed the host Window Mode. 59 * @syscap SystemCapability.ArkUI.ArkUI.Full 60 * @systemapi 61 * @since 18 62 */ 63 FOLLOW_HOST_WINDOW_MODE = 0, 64 65 /** 66 * Followed the UIExtensionAbility. 67 * @syscap SystemCapability.ArkUI.ArkUI.Full 68 * @systemapi 69 * @since 18 70 */ 71 FOLLOW_UI_EXTENSION_ABILITY_WINDOW_MODE = 1, 72} 73 74/** 75 * This interface is used to set the options for UIExtensionComponentAttribute during construction 76 * 77 * @interface UIExtensionOptions 78 * @syscap SystemCapability.ArkUI.ArkUI.Full 79 * @systemapi 80 * @since 11 81 */ 82declare interface UIExtensionOptions { 83 /** 84 * Set whether the current capability is used as a Caller.<br/> 85 * If set to true, as a Caller, the current token of UIExtensionComponent is set to rootToken. 86 * 87 * @type { ?boolean } 88 * @default false 89 * @syscap SystemCapability.ArkUI.ArkUI.Full 90 * @systemapi 91 * @since 11 92 */ 93 isTransferringCaller?: boolean; 94 95 /** 96 * Set placeholder. 97 * If set placeholder ComponentContent, show placeholder node when connection is not established. 98 * 99 * @type { ?ComponentContent } 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @systemapi 102 * @since 12 103 */ 104 placeholder?: ComponentContent; 105 106 /** 107 * Set Areachange placeholder. 108 * If the Areachange placeholder ComponentContent is set, the placeholder node is displayed until 109 * the UIExtensionComponent size change is complete. 110 * 111 * @type { ?Record<string, ComponentContent> } 112 * @syscap SystemCapability.ArkUI.ArkUI.Full 113 * @systemapi 114 * @since 14 115 */ 116 areaChangePlaceholder?: Record<string, ComponentContent>; 117 118 /** 119 * Set UIExtensionComponent Content Dpi Follow Strategy. 120 * 121 * @type { ?DpiFollowStrategy } 122 * @default DpiFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_DPI 123 * @syscap SystemCapability.ArkUI.ArkUI.Full 124 * @systemapi 125 * @since 12 126 */ 127 dpiFollowStrategy?: DpiFollowStrategy; 128 129 /** 130 * Set UIExtensionComponent Content Window Mode Follow Strategy. 131 * @type { ?WindowModeFollowStrategy } 132 * @default WindowModeFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_WINDOW_MODE 133 * @syscap SystemCapability.ArkUI.ArkUI.Full 134 * @systemapi 135 * @since 18 136 */ 137 windowModeFollowStrategy?: WindowModeFollowStrategy; 138} 139 140/** 141 * Indicates the information when the provider of the embedded UI is terminated. 142 * 143 * @interface TerminationInfo 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @systemapi 146 * @since 12 147 */ 148declare interface TerminationInfo { 149 /** 150 * Defines the termination code. 151 * 152 * @type { number } 153 * @syscap SystemCapability.ArkUI.ArkUI.Full 154 * @systemapi 155 * @since 12 156 */ 157 code: number; 158 159 /** 160 * Defines the additional termination information. 161 * 162 * @type { ?import('../api/@ohos.app.ability.Want').default } 163 * @syscap SystemCapability.ArkUI.ArkUI.Full 164 * @systemapi 165 * @since 12 166 */ 167 want?: import('../api/@ohos.app.ability.Want').default; 168} 169 170/** 171 * Get Callback from @ohos.base. 172 * AnonyMous Object Rectification 173 * 174 * @typedef { import('../api/@ohos.base').Callback<Record<string, Object>> } 175 * @syscap SystemCapability.ArkUI.ArkUI.Full 176 * @systemapi 177 * @since 18 178 */ 179declare type ReceiveCallback = import('../api/@ohos.base').Callback<Record<string, Object>>; 180 181/** 182 * This interface is used for send data to the UIExtensionAbility.<br/> 183 * It is returned from onRemoteReady callback of UIExtensionComponent<br/> 184 * when UIExtensionAbility connects successfully 185 * 186 * @interface UIExtensionProxy 187 * @syscap SystemCapability.ArkUI.ArkUI.Full 188 * @systemapi 189 * @since 10 190 */ 191declare interface UIExtensionProxy { 192 /** 193 * This function is for sending data to the UIExtensionAbility. 194 * 195 * @param { object } data 196 * @syscap SystemCapability.ArkUI.ArkUI.Full 197 * @systemapi 198 * @since 10 199 */ 200 /** 201 * This function is for sending data to the UIExtensionAbility. 202 * AnonyMous Object Rectification 203 * 204 * @param { Record<string, Object> } data 205 * @syscap SystemCapability.ArkUI.ArkUI.Full 206 * @systemapi 207 * @since 18 208 */ 209 send(data: Record<string, Object>): void; 210 211 /** 212 * This function is for sending data to the UIExtensionAbility and waiting the result in blocking mode. 213 * 214 * @param { object } data - data send to the UIExtensionAbility 215 * @returns { object } data - data transferred from the UIExtensionAbility 216 * @throws { BusinessError } 100011 - No callback has been registered to response this request. 217 * @throws { BusinessError } 100012 - Transferring data failed. 218 * @syscap SystemCapability.ArkUI.ArkUI.Full 219 * @systemapi 220 * @since 11 221 */ 222 /** 223 * This function is for sending data to the UIExtensionAbility and waiting the result in blocking mode. 224 * AnonyMous Object Rectification 225 * 226 * @param { Record<string, Object> } data - Data send to the UIExtensionAbility. 227 * @returns { Record<string, Object> } data - Data transferred from the UIExtensionAbility. 228 * @throws { BusinessError } 100011 - No callback has been registered to response this request. 229 * @throws { BusinessError } 100012 - Transferring data failed. 230 * @syscap SystemCapability.ArkUI.ArkUI.Full 231 * @systemapi 232 * @since 18 233 */ 234 sendSync(data: Record<string, Object>): Record<string, Object>; 235 236 /** 237 * Register the listener that watches for async data receiver callback being registered by UIExtensionAbility. 238 * 239 * @param { 'asyncReceiverRegister' } type - Indicates the type of event. 240 * @param { function } callback - callback of the listened event. 241 * @syscap SystemCapability.ArkUI.ArkUI.Full 242 * @systemapi 243 * @since 11 244 */ 245 /** 246 * Register the listener that watches for async data receiver callback being registered by UIExtensionAbility. 247 * AnonyMous Object Rectification 248 * 249 * @param { 'asyncReceiverRegister' } type - Indicates the type of event. 250 * @param { Callback<UIExtensionProxy> } callback - Callback of the listened event. 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @systemapi 253 * @since 18 254 */ 255 on(type: 'asyncReceiverRegister', callback: Callback<UIExtensionProxy>): void; 256 257 /** 258 * Register the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 259 * 260 * @param { 'syncReceiverRegister' } type - Indicates the type of event. 261 * @param { function } callback - callback of the listened event. 262 * @syscap SystemCapability.ArkUI.ArkUI.Full 263 * @systemapi 264 * @since 11 265 */ 266 /** 267 * Register the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 268 * AnonyMous Object Rectification 269 * 270 * @param { 'syncReceiverRegister' } type - Indicates the type of event. 271 * @param { Callback<UIExtensionProxy> } callback - Callback of the listened event. 272 * @syscap SystemCapability.ArkUI.ArkUI.Full 273 * @systemapi 274 * @since 18 275 */ 276 on(type: 'syncReceiverRegister', callback: Callback<UIExtensionProxy>): void; 277 278 /** 279 * Deregisters the listener that watches for async data receiver callback being registered by UIExtensionAbility. 280 * 281 * @param { 'asyncReceiverRegister' } type - type of the listened event. 282 * @param { function } callback - callback of the listened event. 283 * @syscap SystemCapability.ArkUI.ArkUI.Full 284 * @systemapi 285 * @since 11 286 */ 287 /** 288 * Deregisters the listener that watches for async data receiver callback being registered by UIExtensionAbility. 289 * AnonyMous Object Rectification 290 * 291 * @param { 'asyncReceiverRegister' } type - Type of the listened event. 292 * @param { Callback<UIExtensionProxy> } [callback] - Callback of the listened event. 293 * @syscap SystemCapability.ArkUI.ArkUI.Full 294 * @systemapi 295 * @since 18 296 */ 297 off(type: 'asyncReceiverRegister', callback?: Callback<UIExtensionProxy>): void; 298 299 /** 300 * Deregisters the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 301 * 302 * @param { 'syncReceiverRegister' } type - type of the listened event. 303 * @param { function } callback - callback of the listened event. 304 * @syscap SystemCapability.ArkUI.ArkUI.Full 305 * @systemapi 306 * @since 11 307 */ 308 /** 309 * Deregisters the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 310 * AnonyMous Object Rectification 311 * 312 * @param { 'syncReceiverRegister' } type - Type of the listened event. 313 * @param { Callback<UIExtensionProxy> } [callback] - Callback of the listened event. 314 * @syscap SystemCapability.ArkUI.ArkUI.Full 315 * @systemapi 316 * @since 18 317 */ 318 off(type: 'syncReceiverRegister', callback?: Callback<UIExtensionProxy>): void; 319} 320 321/** 322 * Provide an interface for the UIExtensionComponent, which is used 323 * <br/>to render UI of a remote UIExtensionAbility 324 * 325 * @interface UIExtensionComponentInterface 326 * @syscap SystemCapability.ArkUI.ArkUI.Full 327 * @systemapi 328 * @since 10 329 */ 330interface UIExtensionComponentInterface { 331 /** 332 * Construct the UIExtensionComponent.<br/> 333 * Called when the UIExtensionComponent is used. 334 * 335 * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility 336 * @returns { UIExtensionComponentAttribute } 337 * @syscap SystemCapability.ArkUI.ArkUI.Full 338 * @systemapi 339 * @since 10 340 */ 341 /** 342 * Construct the UIExtensionComponent.<br/> 343 * Called when the UIExtensionComponent is used. 344 * 345 * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility 346 * @param { UIExtensionOptions } [options] - Construction configuration of UIExtensionComponentAttribute 347 * @returns { UIExtensionComponentAttribute } 348 * @syscap SystemCapability.ArkUI.ArkUI.Full 349 * @systemapi 350 * @since 11 351 */ 352 ( 353 want: import('../api/@ohos.app.ability.Want').default, 354 options?: UIExtensionOptions 355 ): UIExtensionComponentAttribute; 356} 357 358/** 359 * Define the attribute functions of UIExtensionComponent. 360 * 361 * @extends CommonMethod<UIExtensionComponentAttribute> 362 * @syscap SystemCapability.ArkUI.ArkUI.Full 363 * @systemapi 364 * @since 10 365 */ 366declare class UIExtensionComponentAttribute extends CommonMethod<UIExtensionComponentAttribute> { 367 /** 368 * @param { import('../api/@ohos.base').Callback<UIExtensionProxy> } callback 369 * - callback called when remote UIExtensionAbility object is 370 * <br/>ready for receive data 371 * @returns { UIExtensionComponentAttribute } 372 * @syscap SystemCapability.ArkUI.ArkUI.Full 373 * @systemapi 374 * @since 10 375 */ 376 onRemoteReady( 377 callback: import('../api/@ohos.base').Callback<UIExtensionProxy> 378 ): UIExtensionComponentAttribute; 379 380 /** 381 * @param { import('../api/@ohos.base').Callback<{ [key: string]: Object }> } callback 382 * - called when data received from UIExtensionAbility 383 * @returns { UIExtensionComponentAttribute } 384 * @syscap SystemCapability.ArkUI.ArkUI.Full 385 * @systemapi 386 * @since 10 387 */ 388 /** 389 * AnonyMous Object Rectification 390 * 391 * @param { ReceiveCallback } callback - Called when data received from UIExtensionAbility 392 * @returns { UIExtensionComponentAttribute } 393 * @syscap SystemCapability.ArkUI.ArkUI.Full 394 * @systemapi 395 * @since 18 396 */ 397 onReceive(callback: ReceiveCallback): UIExtensionComponentAttribute; 398 399 /** 400 * @param { import('../api/@ohos.base').Callback<{code: number;want?: import('../api/@ohos.app.ability.Want').default;}> } callback 401 * - called when the UIExtensionAbility is terminated with result data. 402 * @returns { UIExtensionComponentAttribute } 403 * @syscap SystemCapability.ArkUI.ArkUI.Full 404 * @systemapi 405 * @since 10 406 * @deprecated since 12 407 * @useinstead UIExtensionComponentAttribute#onTerminated 408 */ 409 onResult( 410 callback: import('../api/@ohos.base').Callback<{ 411 code: number; 412 want?: import('../api/@ohos.app.ability.Want').default; 413 }> 414 ): UIExtensionComponentAttribute; 415 416 /** 417 * @param { import('../api/@ohos.base').Callback<number> } callback 418 * - number returned from callback function if disconnected from UIExtensionAbility, 0 means the 419 * <br/>UIExtensionAbility is terminate by itself, otherwise the connect is broken abnormal. 420 * @returns { UIExtensionComponentAttribute } 421 * @syscap SystemCapability.ArkUI.ArkUI.Full 422 * @systemapi 423 * @since 10 424 * @deprecated since 12 425 * @useinstead UIExtensionComponentAttribute#onTerminated or UIExtensionComponentAttribute#onError 426 */ 427 onRelease( 428 callback: import('../api/@ohos.base').Callback<number> 429 ): UIExtensionComponentAttribute; 430 431 /** 432 * @param { import('../api/@ohos.base').ErrorCallback } callback 433 * - called when some error occurred except disconnected from UIExtensionAbility. 434 * @returns { UIExtensionComponentAttribute } 435 * @syscap SystemCapability.ArkUI.ArkUI.Full 436 * @systemapi 437 * @since 10 438 */ 439 onError( 440 callback: import('../api/@ohos.base').ErrorCallback 441 ): UIExtensionComponentAttribute; 442 443 /** 444 * Called when the provider of the embedded UI is terminated. 445 * 446 * @param { Callback<TerminationInfo> } callback 447 * @returns { UIExtensionComponentAttribute } 448 * @syscap SystemCapability.ArkUI.ArkUI.Full 449 * @systemapi 450 * @since 12 451 */ 452 onTerminated(callback: Callback<TerminationInfo>): UIExtensionComponentAttribute; 453 454 /** 455 * Callback called when the UIExtensionAbility draw the first frame. 456 * @param { Callback<void> } callback 457 * @returns { UIExtensionComponentAttribute } 458 * @syscap SystemCapability.ArkUI.ArkUI.Full 459 * @systemapi 460 * @since 18 461 */ 462 onDrawReady(callback: Callback<void>): UIExtensionComponentAttribute; 463} 464 465/** 466 * Defines UIExtensionComponent Component. 467 * 468 * @syscap SystemCapability.ArkUI.ArkUI.Full 469 * @systemapi 470 * @since 10 471 */ 472declare const UIExtensionComponent: UIExtensionComponentInterface; 473 474/** 475 * Defines UIExtensionComponent Component instance. 476 * 477 * @syscap SystemCapability.ArkUI.ArkUI.Full 478 * @systemapi 479 * @since 10 480 */ 481declare const UIExtensionComponentInstance: UIExtensionComponentAttribute; 482