• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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   * Identifier of a screen.
308   *
309   * @type { ?number }
310   * @syscap SystemCapability.ArkUI.ArkUI.Full
311   * @systemapi
312   * @since 17
313   */
314  screenId?: number;
315}
316
317/**
318 * Defines XComponent.
319 *
320 * @interface XComponentInterface
321 * @syscap SystemCapability.ArkUI.ArkUI.Full
322 * @since 8
323 */
324/**
325 * Defines XComponent.
326 *
327 * @interface XComponentInterface
328 * @syscap SystemCapability.ArkUI.ArkUI.Full
329 * @crossplatform
330 * @atomicservice
331 * @since 12
332 */
333interface XComponentInterface {
334  /**
335   * Constructor parameters
336   *
337   * @param { object } value - Indicates the options of the xcomponent.
338   * @returns { XComponentAttribute }
339   * @syscap SystemCapability.ArkUI.ArkUI.Full
340   * @since 8
341   * @deprecated since 12
342   */
343  (value: { id: string; type: string; libraryname?: string; controller?: XComponentController }): XComponentAttribute;
344
345  /**
346   * Constructor parameters
347   *
348   * @param { object } value - Indicates the options of the xcomponent.
349   * @returns { XComponentAttribute } The attribute of the xcomponent.
350   * @syscap SystemCapability.ArkUI.ArkUI.Full
351   * @since 10
352   */
353  /**
354   * Constructor parameters
355   *
356   * @param { object } value - Indicates the options of the xcomponent.
357   * @returns { XComponentAttribute } The attribute of the xcomponent.
358   * @syscap SystemCapability.ArkUI.ArkUI.Full
359   * @crossplatform
360   * @atomicservice
361   * @since 12
362   */
363  (value: { id: string; type: XComponentType; libraryname?: string; controller?: XComponentController }): XComponentAttribute;
364
365  /**
366   * Constructor parameters
367   *
368   * @param { XComponentOptions } options - Indicates the options of the xcomponent.
369   * @returns { XComponentAttribute } The attribute of the xcomponent.
370   * @syscap SystemCapability.ArkUI.ArkUI.Full
371   * @atomicservice
372   * @since 12
373   */
374  (options: XComponentOptions): XComponentAttribute;
375}
376
377/**
378 * Callback invoked when XComponent onload.
379 *
380 * @typedef { function } OnNativeLoadCallback
381 * @param { object } [event] - Get the context of the XCompoonent instance object,
382 * and the methods mounted on the context are defined by the developer in the C++layer.
383 * @syscap SystemCapability.ArkUI.ArkUI.Full
384 * @crossplatform
385 * @atomicservice
386 * @since 18
387 */
388declare type OnNativeLoadCallback = (event?: object) => void;
389
390/**
391 * Defines XComponentAttribute.
392 *
393 * @extends CommonMethod<XComponentAttribute>
394 * @syscap SystemCapability.ArkUI.ArkUI.Full
395 * @since 8
396 */
397/**
398 * Defines XComponentAttribute.
399 *
400 * @extends CommonMethod<XComponentAttribute>
401 * @syscap SystemCapability.ArkUI.ArkUI.Full
402 * @crossplatform
403 * @atomicservice
404 * @since 12
405 */
406declare class XComponentAttribute extends CommonMethod<XComponentAttribute> {
407  /**
408   * Called when judging whether the xcomponent surface is created.
409   *
410   * @param { function } [callback] - Called when judging whether the xcomponent surface is created.
411   * @returns { XComponentAttribute }
412   * @syscap SystemCapability.ArkUI.ArkUI.Full
413   * @since 8
414   */
415  /**
416   * Called when judging whether the xcomponent surface is created.
417   *
418   * @param { function } [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 12
424   */
425  /**
426   * Called when judging whether the xcomponent surface is created.
427   * Anonymous Object Rectification.
428   *
429   * @param { OnNativeLoadCallback } callback - Called when judging whether the xcomponent surface is created.
430   * @returns { XComponentAttribute }
431   * @syscap SystemCapability.ArkUI.ArkUI.Full
432   * @crossplatform
433   * @atomicservice
434   * @since 18
435   */
436  onLoad(callback: OnNativeLoadCallback): XComponentAttribute;
437
438  /**
439   * Called when judging whether the xcomponent is destroyed.
440   *
441   * @param { function } event - Called when judging whether the xcomponent is destroyed.
442   * @returns { XComponentAttribute }
443   * @syscap SystemCapability.ArkUI.ArkUI.Full
444   * @since 8
445   */
446  /**
447   * Called when judging whether the xcomponent is destroyed.
448   *
449   * @param { function } event - Called when judging whether the xcomponent is destroyed.
450   * @returns { XComponentAttribute }
451   * @syscap SystemCapability.ArkUI.ArkUI.Full
452   * @crossplatform
453   * @atomicservice
454   * @since 12
455   */
456  /**
457   * Called when judging whether the xcomponent is destroyed.
458   * Anonymous Object Rectification.
459   *
460   * @param { VoidCallback } event - Called when judging whether the xcomponent is destroyed.
461   * @returns { XComponentAttribute }
462   * @syscap SystemCapability.ArkUI.ArkUI.Full
463   * @crossplatform
464   * @atomicservice
465   * @since 18
466   */
467  onDestroy(event: VoidCallback): XComponentAttribute;
468
469  /**
470   * Enable image analyzer for XComponent.
471   *
472   * @param { boolean } enable
473   * @returns { XComponentAttribute }
474   * @syscap SystemCapability.ArkUI.ArkUI.Full
475   * @atomicservice
476   * @since 12
477   */
478  enableAnalyzer(enable: boolean): XComponentAttribute;
479
480  /**
481   * Enable privacy protection for XComponent.
482   *
483   * @param { boolean } isSecure
484   * @returns { XComponentAttribute }
485   * @syscap SystemCapability.ArkUI.ArkUI.Full
486   * @atomicservice
487   * @since 13
488   */
489  enableSecure(isSecure: boolean): XComponentAttribute;
490
491  /**
492   * Set hdrBrightness for XComponent.
493   *
494   * @param { number } brightness - control the brightness of HDR video
495   * @returns { XComponentAttribute }
496   * @syscap SystemCapability.ArkUI.ArkUI.Full
497   * @systemapi
498   * @since 14
499   */
500  hdrBrightness(brightness: number): XComponentAttribute;
501
502  /**
503   * Enable transparent layer for XComponent.
504   *
505   * @param { boolean } enabled - whether to enable transparent layer for XComponent.
506   * @returns { XComponentAttribute }
507   * @syscap SystemCapability.ArkUI.ArkUI.Full
508   * @systemapi
509   * @since 18
510   */
511  enableTransparentLayer(enabled: boolean): XComponentAttribute;
512}
513
514/**
515 * Defines XComponent Component.
516 *
517 * @syscap SystemCapability.ArkUI.ArkUI.Full
518 * @since 8
519 */
520/**
521 * Defines XComponent Component.
522 *
523 * @syscap SystemCapability.ArkUI.ArkUI.Full
524 * @crossplatform
525 * @atomicservice
526 * @since 12
527 */
528declare const XComponent: XComponentInterface;
529
530/**
531 * Defines XComponent Component instance.
532 *
533 * @syscap SystemCapability.ArkUI.ArkUI.Full
534 * @since 8
535 */
536/**
537 * Defines XComponent Component instance.
538 *
539 * @syscap SystemCapability.ArkUI.ArkUI.Full
540 * @crossplatform
541 * @atomicservice
542 * @since 12
543 */
544declare const XComponentInstance: XComponentAttribute;
545