• 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 * @file
18 * @kit ArkUI
19 */
20
21/**
22 * Enumeration of different types of DpiFollowStrategy.
23 *
24 * @enum { number }
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @systemapi
27 * @since 12
28 */
29declare enum DpiFollowStrategy {
30  /**
31   * Followed the host DPI.
32   *
33   * @syscap SystemCapability.ArkUI.ArkUI.Full
34   * @systemapi
35   * @since 12
36   */
37  FOLLOW_HOST_DPI = 0,
38
39  /**
40   * Followed the UIExtensionAbility.
41   *
42   * @syscap SystemCapability.ArkUI.ArkUI.Full
43   * @systemapi
44   * @since 12
45   */
46  FOLLOW_UI_EXTENSION_ABILITY_DPI = 1,
47}
48
49/**
50 * This interface is used to set the options for UIExtensionComponentAttribute during construction
51 *
52 * @interface UIExtensionOptions
53 * @syscap SystemCapability.ArkUI.ArkUI.Full
54 * @systemapi
55 * @since 11
56 */
57declare interface UIExtensionOptions {
58  /**
59   * Set whether the current capability is used as a Caller.<br/>
60   * If set to true, as a Caller, the current token of UIExtensionComponent is set to rootToken.
61   *
62   * @type { ?boolean }
63   * @default false
64   * @syscap SystemCapability.ArkUI.ArkUI.Full
65   * @systemapi
66   * @since 11
67   */
68  isTransferringCaller?: boolean;
69
70  /**
71   * Set placeholder.
72   * If set placeholder ComponentContent, show placeholder node when connection is not established.
73   *
74   * @type { ?ComponentContent }
75   * @syscap SystemCapability.ArkUI.ArkUI.Full
76   * @systemapi
77   * @since 12
78   */
79  placeholder?: ComponentContent;
80
81  /**
82   * Set Areachange placeholder.
83   * If the Areachange placeholder ComponentContent is set, the placeholder node is displayed until
84   * the UIExtensionComponent size change is complete.
85   *
86   * @type { ?Record<string, ComponentContent> }
87   * @syscap SystemCapability.ArkUI.ArkUI.Full
88   * @systemapi
89   * @since 14
90   */
91  areaChangePlaceholder?: Record<string, ComponentContent>;
92
93  /**
94   * Set UIExtensionComponent Content Dpi Follow Strategy.
95   *
96   * @type { ?DpiFollowStrategy }
97   * @default DpiFollowStrategy.FOLLOW_UI_EXTENSION_ABILITY_DPI
98   * @syscap SystemCapability.ArkUI.ArkUI.Full
99   * @systemapi
100   * @since 12
101   */
102  dpiFollowStrategy?: DpiFollowStrategy;
103}
104
105/**
106 * Indicates the information when the provider of the embedded UI is terminated.
107 *
108 * @interface TerminationInfo
109 * @syscap SystemCapability.ArkUI.ArkUI.Full
110 * @systemapi
111 * @since 12
112 */
113declare interface TerminationInfo {
114  /**
115   * Defines the termination code.
116   *
117   * @type { number }
118   * @syscap SystemCapability.ArkUI.ArkUI.Full
119   * @systemapi
120   * @since 12
121   */
122   code: number;
123
124  /**
125   * Defines the additional termination information.
126   *
127   * @type { ?import('../api/@ohos.app.ability.Want').default }
128   * @syscap SystemCapability.ArkUI.ArkUI.Full
129   * @systemapi
130   * @since 12
131   */
132   want?: import('../api/@ohos.app.ability.Want').default;
133}
134
135/**
136 * This interface is used for send data to the UIExtensionAbility.<br/>
137 * It is returned from onRemoteReady callback of UIExtensionComponent<br/>
138 * when UIExtensionAbility connects successfully
139 *
140 * @interface UIExtensionProxy
141 * @syscap SystemCapability.ArkUI.ArkUI.Full
142 * @systemapi
143 * @since 10
144 */
145declare interface UIExtensionProxy {
146  /**
147   * This function is for sending data to the UIExtensionAbility.
148   *
149   * @param { object } data
150   * @syscap SystemCapability.ArkUI.ArkUI.Full
151   * @systemapi
152   * @since 10
153   */
154  send(data: { [key: string]: Object }): void;
155
156  /**
157   * This function is for sending data to the UIExtensionAbility and waiting the result in blocking mode.
158   *
159   * @param { object } data - data send to the UIExtensionAbility
160   * @returns { object } data - data transferred from the UIExtensionAbility
161   * @throws { BusinessError } 100011 - No callback has been registered to response this request.
162   * @throws { BusinessError } 100012 - Transferring data failed.
163   * @syscap SystemCapability.ArkUI.ArkUI.Full
164   * @systemapi
165   * @since 11
166   */
167  sendSync(data: { [key: string]: Object }): { [key: string]: Object };
168
169  /**
170   * Register the listener that watches for async data receiver callback being registered by UIExtensionAbility.
171   *
172   * @param { 'asyncReceiverRegister' } type - Indicates the type of event.
173   * @param { function } callback - callback of the listened event.
174   * @syscap SystemCapability.ArkUI.ArkUI.Full
175   * @systemapi
176   * @since 11
177   */
178  on(type: 'asyncReceiverRegister', callback: (proxy: UIExtensionProxy) => void): void;
179
180  /**
181   * Register the listener that watches for sync data receiver callback being registered by UIExtensionAbility.
182   *
183   * @param { 'syncReceiverRegister' } type - Indicates the type of event.
184   * @param { function } callback - callback of the listened event.
185   * @syscap SystemCapability.ArkUI.ArkUI.Full
186   * @systemapi
187   * @since 11
188   */
189  on(type: 'syncReceiverRegister', callback: (proxy: UIExtensionProxy) => void): void;
190
191  /**
192   * Deregisters the listener that watches for async data receiver callback being registered by UIExtensionAbility.
193   *
194   * @param { 'asyncReceiverRegister' } type - type of the listened event.
195   * @param { function } callback - callback of the listened event.
196   * @syscap SystemCapability.ArkUI.ArkUI.Full
197   * @systemapi
198   * @since 11
199   */
200  off(type: 'asyncReceiverRegister', callback?: (proxy: UIExtensionProxy) => void): void;
201
202  /**
203   * Deregisters the listener that watches for sync data receiver callback being registered by UIExtensionAbility.
204   *
205   * @param { 'syncReceiverRegister' } type - type of the listened event.
206   * @param { function } callback - callback of the listened event.
207   * @syscap SystemCapability.ArkUI.ArkUI.Full
208   * @systemapi
209   * @since 11
210   */
211  off(type: 'syncReceiverRegister', callback?: (proxy: UIExtensionProxy) => void): void;
212}
213
214/**
215 * Provide an interface for the UIExtensionComponent, which is used
216 * <br/>to render UI of a remote UIExtensionAbility
217 *
218 * @interface UIExtensionComponentInterface
219 * @syscap SystemCapability.ArkUI.ArkUI.Full
220 * @systemapi
221 * @since 10
222 */
223interface UIExtensionComponentInterface {
224  /**
225   * Construct the UIExtensionComponent.<br/>
226   * Called when the UIExtensionComponent is used.
227   *
228   * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility
229   * @returns { UIExtensionComponentAttribute }
230   * @syscap SystemCapability.ArkUI.ArkUI.Full
231   * @systemapi
232   * @since 10
233   */
234  /**
235   * Construct the UIExtensionComponent.<br/>
236   * Called when the UIExtensionComponent is used.
237   *
238   * @param { import('../api/@ohos.app.ability.Want').default } want - indicates the want of UIExtensionAbility
239   * @param { UIExtensionOptions } [options] - Construction configuration of UIExtensionComponentAttribute
240   * @returns { UIExtensionComponentAttribute }
241   * @syscap SystemCapability.ArkUI.ArkUI.Full
242   * @systemapi
243   * @since 11
244   */
245  (
246    want: import('../api/@ohos.app.ability.Want').default,
247    options?: UIExtensionOptions
248  ): UIExtensionComponentAttribute;
249}
250
251/**
252 * Define the attribute functions of UIExtensionComponent.
253 *
254 * @extends CommonMethod<UIExtensionComponentAttribute>
255 * @syscap SystemCapability.ArkUI.ArkUI.Full
256 * @systemapi
257 * @since 10
258 */
259declare class UIExtensionComponentAttribute extends CommonMethod<UIExtensionComponentAttribute> {
260  /**
261   * @param { import('../api/@ohos.base').Callback<UIExtensionProxy> } callback
262   * - callback called when remote UIExtensionAbility object is
263   * <br/>ready for receive data
264   * @returns { UIExtensionComponentAttribute }
265   * @syscap SystemCapability.ArkUI.ArkUI.Full
266   * @systemapi
267   * @since 10
268   */
269  onRemoteReady(
270    callback: import('../api/@ohos.base').Callback<UIExtensionProxy>
271  ): UIExtensionComponentAttribute;
272
273  /**
274   * @param { import('../api/@ohos.base').Callback<{ [key: string]: Object }> } callback
275   * - called when data received from UIExtensionAbility
276   * @returns { UIExtensionComponentAttribute }
277   * @syscap SystemCapability.ArkUI.ArkUI.Full
278   * @systemapi
279   * @since 10
280   */
281  onReceive(
282    callback: import('../api/@ohos.base').Callback<{ [key: string]: Object }>
283  ): UIExtensionComponentAttribute;
284
285  /**
286   * @param { import('../api/@ohos.base').Callback<{code: number;want?: import('../api/@ohos.app.ability.Want').default;}> } callback
287   * - called when the UIExtensionAbility is terminated with result data.
288   * @returns { UIExtensionComponentAttribute }
289   * @syscap SystemCapability.ArkUI.ArkUI.Full
290   * @systemapi
291   * @since 10
292   * @deprecated since 12
293   * @useinstead UIExtensionComponentAttribute#onTerminated
294   */
295  onResult(
296    callback: import('../api/@ohos.base').Callback<{
297      code: number;
298      want?: import('../api/@ohos.app.ability.Want').default;
299    }>
300  ): UIExtensionComponentAttribute;
301
302  /**
303   * @param { import('../api/@ohos.base').Callback<number> } callback
304   * - number returned from callback function if disconnected from UIExtensionAbility, 0 means the
305   * <br/>UIExtensionAbility is terminate by itself, otherwise the connect is broken abnormal.
306   * @returns { UIExtensionComponentAttribute }
307   * @syscap SystemCapability.ArkUI.ArkUI.Full
308   * @systemapi
309   * @since 10
310   * @deprecated since 12
311   * @useinstead UIExtensionComponentAttribute#onTerminated or UIExtensionComponentAttribute#onError
312   */
313  onRelease(
314    callback: import('../api/@ohos.base').Callback<number>
315  ): UIExtensionComponentAttribute;
316
317  /**
318   * @param { import('../api/@ohos.base').ErrorCallback } callback
319   * - called when some error occurred except disconnected from UIExtensionAbility.
320   * @returns { UIExtensionComponentAttribute }
321   * @syscap SystemCapability.ArkUI.ArkUI.Full
322   * @systemapi
323   * @since 10
324   */
325  onError(
326    callback: import('../api/@ohos.base').ErrorCallback
327  ): UIExtensionComponentAttribute;
328
329  /**
330   * Called when the provider of the embedded UI is terminated.
331   *
332   * @param { Callback<TerminationInfo> } callback
333   * @returns { UIExtensionComponentAttribute }
334   * @syscap SystemCapability.ArkUI.ArkUI.Full
335   * @systemapi
336   * @since 12
337   */
338  onTerminated(callback: Callback<TerminationInfo>): UIExtensionComponentAttribute;
339}
340
341/**
342 * Defines UIExtensionComponent Component.
343 *
344 * @syscap SystemCapability.ArkUI.ArkUI.Full
345 * @systemapi
346 * @since 10
347 */
348declare const UIExtensionComponent: UIExtensionComponentInterface;
349
350/**
351 * Defines UIExtensionComponent Component instance.
352 *
353 * @syscap SystemCapability.ArkUI.ArkUI.Full
354 * @systemapi
355 * @since 10
356 */
357declare const UIExtensionComponentInstance: UIExtensionComponentAttribute;
358