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 * This interface is used to set the options for UIExtensionComponentAttribute during construction 51 * 52 * @interface UIExtensionOptions 53 * @syscap SystemCapability.ArkUI.ArkUI.Full 54 * @systemapi 55 * @since 11 56 */ 57declare interface UIExtensionOptions { 58 /** 59 * Set whether the current capability is used as a Caller.<br/> 60 * If set to true, as a Caller, the current token of UIExtensionComponent is set to rootToken. 61 * 62 * @type { ?boolean } 63 * @default false 64 * @syscap SystemCapability.ArkUI.ArkUI.Full 65 * @systemapi 66 * @since 11 67 */ 68 isTransferringCaller?: boolean; 69 70 /** 71 * Set placeholder. 72 * If set placeholder ComponentContent, show placeholder node when connection is not established. 73 * 74 * @type { ?ComponentContent } 75 * @syscap SystemCapability.ArkUI.ArkUI.Full 76 * @systemapi 77 * @since 12 78 */ 79 placeholder?: ComponentContent; 80 81 /** 82 * Set UIExtensionComponent Content Dpi Follow Strategy. 83 * 84 * @type { ?DpiFollowStrategy } 85 * @default DpiFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_DPI 86 * @syscap SystemCapability.ArkUI.ArkUI.Full 87 * @systemapi 88 * @since 12 89 */ 90 dpiFollowStrategy?: DpiFollowStrategy; 91} 92 93/** 94 * Indicates the information when the provider of the embedded UI is terminated. 95 * 96 * @interface TerminationInfo 97 * @syscap SystemCapability.ArkUI.ArkUI.Full 98 * @systemapi 99 * @since 12 100 */ 101declare interface TerminationInfo { 102 /** 103 * Defines the termination code. 104 * 105 * @type { number } 106 * @syscap SystemCapability.ArkUI.ArkUI.Full 107 * @systemapi 108 * @since 12 109 */ 110 code: number; 111 112 /** 113 * Defines the additional termination information. 114 * 115 * @type { ?import('../api/@ohos.app.ability.Want').default } 116 * @syscap SystemCapability.ArkUI.ArkUI.Full 117 * @systemapi 118 * @since 12 119 */ 120 want?: import('../api/@ohos.app.ability.Want').default; 121} 122 123/** 124 * This interface is used for send data to the UIExtensionAbility.<br/> 125 * It is returned from onRemoteReady callback of UIExtensionComponent<br/> 126 * when UIExtensionAbility connects successfully 127 * 128 * @interface UIExtensionProxy 129 * @syscap SystemCapability.ArkUI.ArkUI.Full 130 * @systemapi 131 * @since 10 132 */ 133declare interface UIExtensionProxy { 134 /** 135 * This function is for sending data to the UIExtensionAbility. 136 * 137 * @param { object } data 138 * @syscap SystemCapability.ArkUI.ArkUI.Full 139 * @systemapi 140 * @since 10 141 */ 142 send(data: { [key: string]: Object }): void; 143 144 /** 145 * This function is for sending data to the UIExtensionAbility and waiting the result in blocking mode. 146 * 147 * @param { object } data - data send to the UIExtensionAbility 148 * @returns { object } data - data transferred from the UIExtensionAbility 149 * @throws { BusinessError } 100011 - No callback has been registered to response this request. 150 * @throws { BusinessError } 100012 - Transferring data failed. 151 * @syscap SystemCapability.ArkUI.ArkUI.Full 152 * @systemapi 153 * @since 11 154 */ 155 sendSync(data: { [key: string]: Object }): { [key: string]: Object }; 156 157 /** 158 * Register the listener that watches for async data receiver callback being registered by UIExtensionAbility. 159 * 160 * @param { 'asyncReceiverRegister' } type - Indicates the type of event. 161 * @param { function } callback - callback of the listened event. 162 * @syscap SystemCapability.ArkUI.ArkUI.Full 163 * @systemapi 164 * @since 11 165 */ 166 on(type: 'asyncReceiverRegister', callback: (proxy: UIExtensionProxy) => void): void; 167 168 /** 169 * Register the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 170 * 171 * @param { 'syncReceiverRegister' } type - Indicates the type of event. 172 * @param { function } callback - callback of the listened event. 173 * @syscap SystemCapability.ArkUI.ArkUI.Full 174 * @systemapi 175 * @since 11 176 */ 177 on(type: 'syncReceiverRegister', callback: (proxy: UIExtensionProxy) => void): void; 178 179 /** 180 * Deregisters the listener that watches for async data receiver callback being registered by UIExtensionAbility. 181 * 182 * @param { 'asyncReceiverRegister' } type - type of the listened event. 183 * @param { function } callback - callback of the listened event. 184 * @syscap SystemCapability.ArkUI.ArkUI.Full 185 * @systemapi 186 * @since 11 187 */ 188 off(type: 'asyncReceiverRegister', callback?: (proxy: UIExtensionProxy) => void): void; 189 190 /** 191 * Deregisters the listener that watches for sync data receiver callback being registered by UIExtensionAbility. 192 * 193 * @param { 'syncReceiverRegister' } type - type of the listened event. 194 * @param { function } callback - callback of the listened event. 195 * @syscap SystemCapability.ArkUI.ArkUI.Full 196 * @systemapi 197 * @since 11 198 */ 199 off(type: 'syncReceiverRegister', callback?: (proxy: UIExtensionProxy) => void): void; 200} 201 202/** 203 * Provide an interface for the UIExtensionComponent, which is used 204 * <br/>to render UI of a remote UIExtensionAbility 205 * 206 * @interface UIExtensionComponentInterface 207 * @syscap SystemCapability.ArkUI.ArkUI.Full 208 * @systemapi 209 * @since 10 210 */ 211interface UIExtensionComponentInterface { 212 /** 213 * Construct the UIExtensionComponent.<br/> 214 * Called when the UIExtensionComponent is used. 215 * 216 * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility 217 * @returns { UIExtensionComponentAttribute } 218 * @syscap SystemCapability.ArkUI.ArkUI.Full 219 * @systemapi 220 * @since 10 221 */ 222 /** 223 * Construct the UIExtensionComponent.<br/> 224 * Called when the UIExtensionComponent is used. 225 * 226 * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility 227 * @param { UIExtensionOptions } [options] - Construction configuration of UIExtensionComponentAttribute 228 * @returns { UIExtensionComponentAttribute } 229 * @syscap SystemCapability.ArkUI.ArkUI.Full 230 * @systemapi 231 * @since 11 232 */ 233 ( 234 want: import('../api/@ohos.app.ability.Want').default, 235 options?: UIExtensionOptions 236 ): UIExtensionComponentAttribute; 237} 238 239/** 240 * Define the attribute functions of UIExtensionComponent. 241 * 242 * @extends CommonMethod<UIExtensionComponentAttribute> 243 * @syscap SystemCapability.ArkUI.ArkUI.Full 244 * @systemapi 245 * @since 10 246 */ 247declare class UIExtensionComponentAttribute extends CommonMethod<UIExtensionComponentAttribute> { 248 /** 249 * @param { import('../api/@ohos.base').Callback<UIExtensionProxy> } callback 250 * - callback called when remote UIExtensionAbility object is 251 * <br/>ready for receive data 252 * @returns { UIExtensionComponentAttribute } 253 * @syscap SystemCapability.ArkUI.ArkUI.Full 254 * @systemapi 255 * @since 10 256 */ 257 onRemoteReady( 258 callback: import('../api/@ohos.base').Callback<UIExtensionProxy> 259 ): UIExtensionComponentAttribute; 260 261 /** 262 * @param { import('../api/@ohos.base').Callback<{ [key: string]: Object }> } callback 263 * - called when data received from UIExtensionAbility 264 * @returns { UIExtensionComponentAttribute } 265 * @syscap SystemCapability.ArkUI.ArkUI.Full 266 * @systemapi 267 * @since 10 268 */ 269 onReceive( 270 callback: import('../api/@ohos.base').Callback<{ [key: string]: Object }> 271 ): UIExtensionComponentAttribute; 272 273 /** 274 * @param { import('../api/@ohos.base').Callback<{code: number;want?: import('../api/@ohos.app.ability.Want').default;}> } callback 275 * - called when the UIExtensionAbility is terminated with result data. 276 * @returns { UIExtensionComponentAttribute } 277 * @syscap SystemCapability.ArkUI.ArkUI.Full 278 * @systemapi 279 * @since 10 280 * @deprecated since 12 281 * @useinstead UIExtensionComponentAttribute#onTerminated 282 */ 283 onResult( 284 callback: import('../api/@ohos.base').Callback<{ 285 code: number; 286 want?: import('../api/@ohos.app.ability.Want').default; 287 }> 288 ): UIExtensionComponentAttribute; 289 290 /** 291 * @param { import('../api/@ohos.base').Callback<number> } callback 292 * - number returned from callback function if disconnected from UIExtensionAbility, 0 means the 293 * <br/>UIExtensionAbility is terminate by itself, otherwise the connect is broken abnormal. 294 * @returns { UIExtensionComponentAttribute } 295 * @syscap SystemCapability.ArkUI.ArkUI.Full 296 * @systemapi 297 * @since 10 298 * @deprecated since 12 299 * @useinstead UIExtensionComponentAttribute#onTerminated or UIExtensionComponentAttribute#onError 300 */ 301 onRelease( 302 callback: import('../api/@ohos.base').Callback<number> 303 ): UIExtensionComponentAttribute; 304 305 /** 306 * @param { import('../api/@ohos.base').ErrorCallback } callback 307 * - called when some error occurred except disconnected from UIExtensionAbility. 308 * @returns { UIExtensionComponentAttribute } 309 * @syscap SystemCapability.ArkUI.ArkUI.Full 310 * @systemapi 311 * @since 10 312 */ 313 onError( 314 callback: import('../api/@ohos.base').ErrorCallback 315 ): UIExtensionComponentAttribute; 316 317 /** 318 * Called when the provider of the embedded UI is terminated. 319 * 320 * @param { Callback<TerminationInfo> } callback 321 * @returns { UIExtensionComponentAttribute } 322 * @syscap SystemCapability.ArkUI.ArkUI.Full 323 * @systemapi 324 * @since 12 325 */ 326 onTerminated(callback: Callback<TerminationInfo>): UIExtensionComponentAttribute; 327} 328 329/** 330 * Defines UIExtensionComponent Component. 331 * 332 * @syscap SystemCapability.ArkUI.ArkUI.Full 333 * @systemapi 334 * @since 10 335 */ 336declare const UIExtensionComponent: UIExtensionComponentInterface; 337 338/** 339 * Defines UIExtensionComponent Component instance. 340 * 341 * @syscap SystemCapability.ArkUI.ArkUI.Full 342 * @systemapi 343 * @since 10 344 */ 345declare const UIExtensionComponentInstance: UIExtensionComponentAttribute; 346