• 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 * Defines XComponentController
18 *
19 * @syscap SystemCapability.ArkUI.ArkUI.Full
20 * @since 8
21 */
22declare class XComponentController {
23  /**
24   * Constructor.
25   *
26   * @syscap SystemCapability.ArkUI.ArkUI.Full
27   * @since 8
28   */
29  constructor();
30
31  /**
32   * Get the id of surface created by XComponent.
33   *
34   * @returns { string } The id of surface created by XComponent.
35   * @syscap SystemCapability.ArkUI.ArkUI.Full
36   * @since 9
37   */
38  getXComponentSurfaceId(): string;
39
40  /**
41   * Get the context of native XComponent.
42   *
43   * @returns { Object } The context of native XComponent.
44   * @syscap SystemCapability.ArkUI.ArkUI.Full
45   * @since 8
46   */
47  getXComponentContext(): Object;
48
49  /**
50   * Set the surface size created by XComponent.
51   *
52   * @param { object } value - surface size
53   * @syscap SystemCapability.ArkUI.ArkUI.Full
54   * @since 9
55   */
56  setXComponentSurfaceSize(value: {
57    surfaceWidth: number;
58    surfaceHeight: number;
59  }): void;
60}
61
62/**
63 * Defines XComponent.
64 *
65 * @interface XComponentInterface
66 * @syscap SystemCapability.ArkUI.ArkUI.Full
67 * @since 8
68 */
69interface XComponentInterface {
70  /**
71   * Constructor parameters
72   *
73   * @param { object } value - Indicates the options of the xcomponent.
74   * @returns { XComponentAttribute }
75   * @syscap SystemCapability.ArkUI.ArkUI.Full
76   * @since 8
77   */
78  (value: { id: string; type: string; libraryname?: string; controller?: XComponentController }): XComponentAttribute;
79
80  /**
81   * Constructor parameters
82   *
83   * @param { object } value - Indicates the options of the xcomponent.
84   * @returns { XComponentAttribute } The attribute of the xcomponent.
85   * @syscap SystemCapability.ArkUI.ArkUI.Full
86   * @since 10
87   */
88  (value: { id: string; type: XComponentType; libraryname?: string; controller?: XComponentController }): XComponentAttribute;
89}
90
91/**
92 * Defines XComponentAttribute.
93 *
94 * @extends CommonMethod
95 * @since 8
96 */
97declare class XComponentAttribute extends CommonMethod<XComponentAttribute> {
98  /**
99   * Called when judging whether the xcomponent surface is created.
100   *
101   * @param { function } [callback] - Called when judging whether the xcomponent surface is created.
102   * @returns { XComponentAttribute }
103   * @syscap SystemCapability.ArkUI.ArkUI.Full
104   * @since 8
105   */
106  onLoad(callback: (event?: object) => void): XComponentAttribute;
107
108  /**
109   * Called when judging whether the xcomponent is destroyed.
110   *
111   * @param { function } event - Called when judging whether the xcomponent is destroyed.
112   * @returns { XComponentAttribute }
113   * @syscap SystemCapability.ArkUI.ArkUI.Full
114   * @since 8
115   */
116  onDestroy(event: () => void): XComponentAttribute;
117}
118
119/**
120 * Defines XComponent Component.
121 *
122 * @syscap SystemCapability.ArkUI.ArkUI.Full
123 * @since 8
124 */
125declare const XComponent: XComponentInterface;
126
127/**
128 * Defines XComponent Component instance.
129 *
130 * @syscap SystemCapability.ArkUI.ArkUI.Full
131 * @since 8
132 */
133declare const XComponentInstance: XComponentAttribute;
134