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 * Callback invoked when XComponent onload.
369 *
370 * @typedef { function } OnNativeLoadCallback
371 * @param { object } [event] - Get the context of the XCompoonent instance object,
372 * and the methods mounted on the context are defined by the developer in the C++layer.
373 * @syscap SystemCapability.ArkUI.ArkUI.Full
374 * @crossplatform
375 * @atomicservice
376 * @since 14
377 */
378declare type OnNativeLoadCallback = (event?: object) => void
379
380/**
381 * Defines XComponentAttribute.
382 *
383 * @extends CommonMethod<XComponentAttribute>
384 * @syscap SystemCapability.ArkUI.ArkUI.Full
385 * @since 8
386 */
387/**
388 * Defines XComponentAttribute.
389 *
390 * @extends CommonMethod<XComponentAttribute>
391 * @syscap SystemCapability.ArkUI.ArkUI.Full
392 * @crossplatform
393 * @atomicservice
394 * @since 12
395 */
396declare class XComponentAttribute extends CommonMethod<XComponentAttribute> {
397  /**
398   * Called when judging whether the xcomponent surface is created.
399   *
400   * @param { function } [callback] - Called when judging whether the xcomponent surface is created.
401   * @returns { XComponentAttribute }
402   * @syscap SystemCapability.ArkUI.ArkUI.Full
403   * @since 8
404   */
405  /**
406   * Called when judging whether the xcomponent surface is created.
407   *
408   * @param { function } [callback] - Called when judging whether the xcomponent surface is created.
409   * @returns { XComponentAttribute }
410   * @syscap SystemCapability.ArkUI.ArkUI.Full
411   * @crossplatform
412   * @atomicservice
413   * @since 12
414   */
415  /**
416   * Called when judging whether the xcomponent surface is created.
417   *
418   * @param { OnNativeLoadCallback } callback - Called when judging whether the xcomponent surface is created.
419   * @returns { XComponentAttribute }
420   * @syscap SystemCapability.ArkUI.ArkUI.Full
421   * @crossplatform
422   * @atomicservice
423   * @since 14
424   */
425  onLoad(callback: OnNativeLoadCallback): XComponentAttribute;
426
427  /**
428   * Called when judging whether the xcomponent is destroyed.
429   *
430   * @param { function } event - Called when judging whether the xcomponent is destroyed.
431   * @returns { XComponentAttribute }
432   * @syscap SystemCapability.ArkUI.ArkUI.Full
433   * @since 8
434   */
435  /**
436   * Called when judging whether the xcomponent is destroyed.
437   *
438   * @param { function } event - Called when judging whether the xcomponent is destroyed.
439   * @returns { XComponentAttribute }
440   * @syscap SystemCapability.ArkUI.ArkUI.Full
441   * @crossplatform
442   * @atomicservice
443   * @since 12
444   */
445  /**
446   * Called when judging whether the xcomponent is destroyed.
447   *
448   * @param { VoidCallback } event - Called when judging whether the xcomponent is destroyed.
449   * @returns { XComponentAttribute }
450   * @syscap SystemCapability.ArkUI.ArkUI.Full
451   * @crossplatform
452   * @atomicservice
453   * @since 14
454   */
455  onDestroy(event: VoidCallback): XComponentAttribute;
456
457  /**
458   * Enable image analyzer for XComponent.
459   *
460   * @param { boolean } enable
461   * @returns { XComponentAttribute }
462   * @syscap SystemCapability.ArkUI.ArkUI.Full
463   * @atomicservice
464   * @since 12
465   */
466  enableAnalyzer(enable: boolean): XComponentAttribute;
467
468  /**
469   * Enable privacy protection for XComponent.
470   *
471   * @param { boolean } isSecure
472   * @returns { XComponentAttribute }
473   * @syscap SystemCapability.ArkUI.ArkUI.Full
474   * @atomicservice
475   * @since 13
476   */
477  enableSecure(isSecure: boolean): XComponentAttribute;
478}
479
480/**
481 * Defines XComponent Component.
482 *
483 * @syscap SystemCapability.ArkUI.ArkUI.Full
484 * @since 8
485 */
486/**
487 * Defines XComponent Component.
488 *
489 * @syscap SystemCapability.ArkUI.ArkUI.Full
490 * @crossplatform
491 * @atomicservice
492 * @since 12
493 */
494declare const XComponent: XComponentInterface;
495
496/**
497 * Defines XComponent Component instance.
498 *
499 * @syscap SystemCapability.ArkUI.ArkUI.Full
500 * @since 8
501 */
502/**
503 * Defines XComponent Component instance.
504 *
505 * @syscap SystemCapability.ArkUI.ArkUI.Full
506 * @crossplatform
507 * @atomicservice
508 * @since 12
509 */
510declare const XComponentInstance: XComponentAttribute;
511