1/* 2 * Copyright (c) 2021 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 * Surface Rectangle information. 23 * 24 * @interface SurfaceRect 25 * @syscap SystemCapability.ArkUI.ArkUI.Full 26 * @atomicservice 27 * @since 12 28 */ 29declare interface SurfaceRect { 30 /** 31 * The horizontal offset of the surface relative to XComponent. 32 * 33 * @type { ?number } 34 * @syscap SystemCapability.ArkUI.ArkUI.Full 35 * @atomicservice 36 * @since 12 37 */ 38 offsetX?: number; 39 40 /** 41 * The vertical offset of the surface relative to XComponent. 42 * 43 * @type { ?number } 44 * @syscap SystemCapability.ArkUI.ArkUI.Full 45 * @atomicservice 46 * @since 12 47 */ 48 offsetY?: number; 49 50 /** 51 * The width of the surface created by XComponent 52 * 53 * @type { number } 54 * @syscap SystemCapability.ArkUI.ArkUI.Full 55 * @atomicservice 56 * @since 12 57 */ 58 surfaceWidth: number; 59 60 /** 61 * The height of the surface created by XComponent 62 * 63 * @type { number } 64 * @syscap SystemCapability.ArkUI.ArkUI.Full 65 * @atomicservice 66 * @since 12 67 */ 68 surfaceHeight: number; 69} 70 71/** 72 * Surface rotation options. 73 * 74 * @interface SurfaceRotationOptions 75 * @syscap SystemCapability.ArkUI.ArkUI.Full 76 * @atomicservice 77 * @since 12 78 */ 79declare interface SurfaceRotationOptions { 80 /** 81 * Lock property of the surface rotation. 82 * 83 * @type { ?boolean } 84 * @syscap SystemCapability.ArkUI.ArkUI.Full 85 * @atomicservice 86 * @since 12 87 */ 88 lock?: boolean; 89} 90 91/** 92 * Defines XComponentController 93 * 94 * @syscap SystemCapability.ArkUI.ArkUI.Full 95 * @since 8 96 */ 97/** 98 * Defines XComponentController 99 * 100 * @syscap SystemCapability.ArkUI.ArkUI.Full 101 * @crossplatform 102 * @atomicservice 103 * @since 12 104 */ 105declare class XComponentController { 106 /** 107 * Constructor. 108 * 109 * @syscap SystemCapability.ArkUI.ArkUI.Full 110 * @since 8 111 */ 112 /** 113 * Constructor. 114 * 115 * @syscap SystemCapability.ArkUI.ArkUI.Full 116 * @crossplatform 117 * @atomicservice 118 * @since 12 119 */ 120 constructor(); 121 122 /** 123 * Get the id of surface created by XComponent. 124 * 125 * @returns { string } The id of surface created by XComponent. 126 * @syscap SystemCapability.ArkUI.ArkUI.Full 127 * @since 9 128 */ 129 /** 130 * Get the id of surface created by XComponent. 131 * 132 * @returns { string } The id of surface created by XComponent. 133 * @syscap SystemCapability.ArkUI.ArkUI.Full 134 * @crossplatform 135 * @atomicservice 136 * @since 12 137 */ 138 getXComponentSurfaceId(): string; 139 140 /** 141 * Get the context of native XComponent. 142 * 143 * @returns { Object } The context of native XComponent. 144 * @syscap SystemCapability.ArkUI.ArkUI.Full 145 * @since 8 146 */ 147 /** 148 * Get the context of native XComponent. 149 * 150 * @returns { Object } The context of native XComponent. 151 * @syscap SystemCapability.ArkUI.ArkUI.Full 152 * @crossplatform 153 * @atomicservice 154 * @since 12 155 */ 156 getXComponentContext(): Object; 157 158 /** 159 * Set the surface size created by XComponent. 160 * 161 * @param { object } value - surface size 162 * @syscap SystemCapability.ArkUI.ArkUI.Full 163 * @since 9 164 * @deprecated since 12 165 * @useinstead setXComponentSurfaceRect 166 */ 167 setXComponentSurfaceSize(value: { 168 surfaceWidth: number; 169 surfaceHeight: number; 170 }): void; 171 172 /** 173 * Set the rectangle information of surface created by XComponent. 174 * 175 * @param { SurfaceRect } rect - The surface rectangle information. 176 * @syscap SystemCapability.ArkUI.ArkUI.Full 177 * @atomicservice 178 * @since 12 179 */ 180 setXComponentSurfaceRect(rect: SurfaceRect): void; 181 182 /** 183 * Get the rectangle information of Surface created by XComponent. 184 * 185 * @returns { SurfaceRect } The surface rectangle information. 186 * @syscap SystemCapability.ArkUI.ArkUI.Full 187 * @atomicservice 188 * @since 12 189 */ 190 getXComponentSurfaceRect(): SurfaceRect; 191 192 /** 193 * Set the rotation options of the Surface created by XComponent. 194 * 195 * @param { SurfaceRotationOptions } rotationOptions - The surface rotation options. 196 * @syscap SystemCapability.ArkUI.ArkUI.Full 197 * @atomicservice 198 * @since 12 199 */ 200 setXComponentSurfaceRotation(rotationOptions: SurfaceRotationOptions): void; 201 202 /** 203 * Get the rotation options result of the Surface created by XComponent. 204 * 205 * @returns { Required<SurfaceRotationOptions> } The surface rotation options result. 206 * @syscap SystemCapability.ArkUI.ArkUI.Full 207 * @atomicservice 208 * @since 12 209 */ 210 getXComponentSurfaceRotation(): Required<SurfaceRotationOptions>; 211 212 /** 213 * Called after the surface is first created. 214 * 215 * @param { string } surfaceId - The id of the surface created by XComponent. 216 * @syscap SystemCapability.ArkUI.ArkUI.Full 217 * @atomicservice 218 * @since 12 219 */ 220 onSurfaceCreated(surfaceId: string): void; 221 222 /** 223 * Called after the surface rectangle information is changed. 224 * 225 * @param { string } surfaceId - The id of the surface created by XComponent. 226 * @param { SurfaceRect } rect - The rectangle information of the surface created by XComponent. 227 * @syscap SystemCapability.ArkUI.ArkUI.Full 228 * @atomicservice 229 * @since 12 230 */ 231 onSurfaceChanged(surfaceId: string, rect: SurfaceRect): void; 232 233 /** 234 * Called when the surface is about to be destroyed. 235 * 236 * @param { string } surfaceId - The id of the surface created by XComponent. 237 * @syscap SystemCapability.ArkUI.ArkUI.Full 238 * @atomicservice 239 * @since 12 240 */ 241 onSurfaceDestroyed(surfaceId: string): void; 242 243 /** 244 * Start image analyzer. 245 * 246 * @param { ImageAnalyzerConfig } config - Image analyzer config. 247 * @returns { Promise<void> } The promise returned by the function. 248 * @throws { BusinessError } 110001 - Image analysis feature is unsupported. 249 * @throws { BusinessError } 110002 - Image analysis is currently being executed. 250 * @throws { BusinessError } 110003 - Image analysis is stopped. 251 * @syscap SystemCapability.ArkUI.ArkUI.Full 252 * @atomicservice 253 * @since 12 254 */ 255 startImageAnalyzer(config: ImageAnalyzerConfig): Promise<void>; 256 257 /** 258 * Stop image analyzer. 259 * 260 * @syscap SystemCapability.ArkUI.ArkUI.Full 261 * @atomicservice 262 * @since 12 263 */ 264 stopImageAnalyzer(): void; 265} 266 267/** 268 * Defines the xcomponent options. 269 * 270 * @interface XComponentOptions 271 * @syscap SystemCapability.ArkUI.ArkUI.Full 272 * @atomicservice 273 * @since 12 274 */ 275declare interface XComponentOptions { 276 /** 277 * The type of xcomponent 278 * 279 * @type { XComponentType } 280 * @syscap SystemCapability.ArkUI.ArkUI.Full 281 * @atomicservice 282 * @since 12 283 */ 284 type: XComponentType; 285 286 /** 287 * The controller of xcomponent. 288 * 289 * @type { XComponentController } 290 * @syscap SystemCapability.ArkUI.ArkUI.Full 291 * @atomicservice 292 * @since 12 293 */ 294 controller: XComponentController; 295 296 /** 297 * Image ai options. 298 * 299 * @type { ?ImageAIOptions } 300 * @syscap SystemCapability.ArkUI.ArkUI.Full 301 * @atomicservice 302 * @since 12 303 */ 304 imageAIOptions?: ImageAIOptions; 305} 306 307/** 308 * Defines XComponent. 309 * 310 * @interface XComponentInterface 311 * @syscap SystemCapability.ArkUI.ArkUI.Full 312 * @since 8 313 */ 314/** 315 * Defines XComponent. 316 * 317 * @interface XComponentInterface 318 * @syscap SystemCapability.ArkUI.ArkUI.Full 319 * @crossplatform 320 * @atomicservice 321 * @since 12 322 */ 323interface XComponentInterface { 324 /** 325 * Constructor parameters 326 * 327 * @param { object } value - Indicates the options of the xcomponent. 328 * @returns { XComponentAttribute } 329 * @syscap SystemCapability.ArkUI.ArkUI.Full 330 * @since 8 331 * @deprecated since 12 332 */ 333 (value: { id: string; type: string; libraryname?: string; controller?: XComponentController }): XComponentAttribute; 334 335 /** 336 * Constructor parameters 337 * 338 * @param { object } value - Indicates the options of the xcomponent. 339 * @returns { XComponentAttribute } The attribute of the xcomponent. 340 * @syscap SystemCapability.ArkUI.ArkUI.Full 341 * @since 10 342 */ 343 /** 344 * Constructor parameters 345 * 346 * @param { object } value - Indicates the options of the xcomponent. 347 * @returns { XComponentAttribute } The attribute of the xcomponent. 348 * @syscap SystemCapability.ArkUI.ArkUI.Full 349 * @crossplatform 350 * @atomicservice 351 * @since 12 352 */ 353 (value: { id: string; type: XComponentType; libraryname?: string; controller?: XComponentController }): XComponentAttribute; 354 355 /** 356 * Constructor parameters 357 * 358 * @param { XComponentOptions } options - Indicates the options of the xcomponent. 359 * @returns { XComponentAttribute } The attribute of the xcomponent. 360 * @syscap SystemCapability.ArkUI.ArkUI.Full 361 * @atomicservice 362 * @since 12 363 */ 364 (options: XComponentOptions): XComponentAttribute; 365} 366 367/** 368 * Defines XComponentAttribute. 369 * 370 * @extends CommonMethod<XComponentAttribute> 371 * @syscap SystemCapability.ArkUI.ArkUI.Full 372 * @since 8 373 */ 374/** 375 * Defines XComponentAttribute. 376 * 377 * @extends CommonMethod<XComponentAttribute> 378 * @syscap SystemCapability.ArkUI.ArkUI.Full 379 * @crossplatform 380 * @atomicservice 381 * @since 12 382 */ 383declare class XComponentAttribute extends CommonMethod<XComponentAttribute> { 384 /** 385 * Called when judging whether the xcomponent surface is created. 386 * 387 * @param { function } [callback] - Called when judging whether the xcomponent surface is created. 388 * @returns { XComponentAttribute } 389 * @syscap SystemCapability.ArkUI.ArkUI.Full 390 * @since 8 391 */ 392 /** 393 * Called when judging whether the xcomponent surface is created. 394 * 395 * @param { function } [callback] - Called when judging whether the xcomponent surface is created. 396 * @returns { XComponentAttribute } 397 * @syscap SystemCapability.ArkUI.ArkUI.Full 398 * @crossplatform 399 * @atomicservice 400 * @since 12 401 */ 402 onLoad(callback: (event?: object) => void): XComponentAttribute; 403 404 /** 405 * Called when judging whether the xcomponent is destroyed. 406 * 407 * @param { function } event - Called when judging whether the xcomponent is destroyed. 408 * @returns { XComponentAttribute } 409 * @syscap SystemCapability.ArkUI.ArkUI.Full 410 * @since 8 411 */ 412 /** 413 * Called when judging whether the xcomponent is destroyed. 414 * 415 * @param { function } event - Called when judging whether the xcomponent is destroyed. 416 * @returns { XComponentAttribute } 417 * @syscap SystemCapability.ArkUI.ArkUI.Full 418 * @crossplatform 419 * @atomicservice 420 * @since 12 421 */ 422 onDestroy(event: () => void): XComponentAttribute; 423 424 /** 425 * Enable image analyzer for XComponent. 426 * 427 * @param { boolean } enable 428 * @returns { XComponentAttribute } 429 * @syscap SystemCapability.ArkUI.ArkUI.Full 430 * @atomicservice 431 * @since 12 432 */ 433 enableAnalyzer(enable: boolean): XComponentAttribute; 434 435 /** 436 * Enable privacy protection for XComponent. 437 * 438 * @param { boolean } isSecure 439 * @returns { XComponentAttribute } 440 * @syscap SystemCapability.ArkUI.ArkUI.Full 441 * @atomicservice 442 * @since 13 443 */ 444 enableSecure(isSecure: boolean): XComponentAttribute; 445} 446 447/** 448 * Defines XComponent Component. 449 * 450 * @syscap SystemCapability.ArkUI.ArkUI.Full 451 * @since 8 452 */ 453/** 454 * Defines XComponent Component. 455 * 456 * @syscap SystemCapability.ArkUI.ArkUI.Full 457 * @crossplatform 458 * @atomicservice 459 * @since 12 460 */ 461declare const XComponent: XComponentInterface; 462 463/** 464 * Defines XComponent Component instance. 465 * 466 * @syscap SystemCapability.ArkUI.ArkUI.Full 467 * @since 8 468 */ 469/** 470 * Defines XComponent Component instance. 471 * 472 * @syscap SystemCapability.ArkUI.ArkUI.Full 473 * @crossplatform 474 * @atomicservice 475 * @since 12 476 */ 477declare const XComponentInstance: XComponentAttribute; 478