• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 * This interface is used for send data to the UIExtensionAbility.<br/>
18 * It is returned from onRemoteReady callback of UIExtensionComponent<br/>
19 * when UIExtensionAbility connects successfully
20 *
21 * @interface UIExtensionProxy
22 * @syscap SystemCapability.ArkUI.ArkUI.Full
23 * @systemapi
24 * @since 10
25 */
26declare interface UIExtensionProxy {
27  /**
28   * This function is for sending data to the UIExtensionAbility.
29   *
30   * @param { object } data
31   * @syscap SystemCapability.ArkUI.ArkUI.Full
32   * @systemapi
33   * @since 10
34   */
35  send(data: { [key: string]: Object }): void;
36}
37
38/**
39 * Provide an interface for the UIExtensionComponent, which is used
40 * <br/>to render UI of a remote UIExtensionAbility
41 *
42 * @interface UIExtensionComponentInterface
43 * @syscap SystemCapability.ArkUI.ArkUI.Full
44 * @systemapi
45 * @since 10
46 */
47interface UIExtensionComponentInterface {
48  /**
49   * Construct the UIExtensionComponent.<br/>
50   * Called when the UIExtensionComponent is used.
51   *
52   * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility
53   * @returns { UIExtensionComponentAttribute }
54   * @syscap SystemCapability.ArkUI.ArkUI.Full
55   * @systemapi
56   * @since 10
57   */
58  (
59    want: import('../api/@ohos.app.ability.Want').default
60  ): UIExtensionComponentAttribute;
61}
62
63/**
64 * Define the attribute functions of UIExtensionComponent.
65 *
66 * @extends CommonMethod
67 * @syscap SystemCapability.ArkUI.ArkUI.Full
68 * @systemapi
69 * @since 10
70 */
71declare class UIExtensionComponentAttribute extends CommonMethod<UIExtensionComponentAttribute> {
72  /**
73   * @param { import('../api/@ohos.base').Callback<UIExtensionProxy> } callback
74   * - callback called when remote UIExtensionAbility object is
75   * <br/>ready for receive data
76   * @returns { UIExtensionComponentAttribute }
77   * @syscap SystemCapability.ArkUI.ArkUI.Full
78   * @systemapi
79   * @since 10
80   */
81  onRemoteReady(
82    callback: import('../api/@ohos.base').Callback<UIExtensionProxy>
83  ): UIExtensionComponentAttribute;
84
85  /**
86   * @param { import('../api/@ohos.base').Callback<{ [key: string]: Object }> } callback
87   * - called when data received from UIExtensionAbility
88   * @returns { UIExtensionComponentAttribute }
89   * @syscap SystemCapability.ArkUI.ArkUI.Full
90   * @systemapi
91   * @since 10
92   */
93  onReceive(
94    callback: import('../api/@ohos.base').Callback<{ [key: string]: Object }>
95  ): UIExtensionComponentAttribute;
96
97  /**
98   * @param { import('../api/@ohos.base').Callback<{code: number;want?: import('../api/@ohos.app.ability.Want').default;}> } callback
99   * - called when the UIExtensionAbility is terminated with result data.
100   * @returns { UIExtensionComponentAttribute }
101   * @syscap SystemCapability.ArkUI.ArkUI.Full
102   * @systemapi
103   * @since 10
104   */
105  onResult(
106    callback: import('../api/@ohos.base').Callback<{
107      code: number;
108      want?: import('../api/@ohos.app.ability.Want').default;
109    }>
110  ): UIExtensionComponentAttribute;
111
112  /**
113   * @param { import('../api/@ohos.base').Callback<number> } callback
114   * - number returned from callback function if disconnected from UIExtensionAbility, 0 means the
115   * <br/>UIExtensionAbility is terminate by itself, otherwise the connect is broken abnormal.
116   * @returns { UIExtensionComponentAttribute }
117   * @syscap SystemCapability.ArkUI.ArkUI.Full
118   * @systemapi
119   * @since 10
120   */
121  onRelease(
122    callback: import('../api/@ohos.base').Callback<number>
123  ): UIExtensionComponentAttribute;
124
125  /**
126   * @param { import('../api/@ohos.base').ErrorCallback } callback
127   * - called when some error occurred except disconnected from UIExtensionAbility.
128   * @returns { UIExtensionComponentAttribute }
129   * @syscap SystemCapability.ArkUI.ArkUI.Full
130   * @systemapi
131   * @since 10
132   */
133  onError(
134    callback: import('../api/@ohos.base').ErrorCallback
135  ): UIExtensionComponentAttribute;
136}
137
138/**
139 * Defines UIExtensionComponent Component.
140 *
141 * @syscap SystemCapability.ArkUI.ArkUI.Full
142 * @systemapi
143 * @since 10
144 */
145declare const UIExtensionComponent: UIExtensionComponentInterface;
146
147/**
148 * Defines UIExtensionComponent Component instance.
149 *
150 * @syscap SystemCapability.ArkUI.ArkUI.Full
151 * @systemapi
152 * @since 10
153 */
154declare const UIExtensionComponentInstance: UIExtensionComponentAttribute;
155