• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2024 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/*** if arkts 1.2 */
22import Want from '../../@ohos.app.ability.Want'
23import { Callback, ErrorCallback ,BusinessError} from '../../@ohos.base'
24import { CommonMethod, TerminationInfo } from './common'
25import { EmbeddedType } from './enums'
26/*** endif */
27
28/**
29 * Provide an interface for the EmbeddedComponent, which is used
30 * <br/>to render UI asynchronously
31 *
32 * @interface EmbeddedComponentInterface
33 * @syscap SystemCapability.ArkUI.ArkUI.Full
34 * @atomicservice
35 * @since arkts {'1.1':'12','1.2':'20'}
36 * @arkts 1.1&1.2
37 */
38interface EmbeddedComponentInterface {
39  /**
40   * Construct the EmbeddedComponent.<br/>
41   * Called when the EmbeddedComponent is used.
42   *
43   * @param { import('../api/@ohos.app.ability.Want').default } loader - indicates initialization parameter
44   * @param { EmbeddedType } type - indicates type of the EmbeddedComponent
45   * @returns { EmbeddedComponentAttribute }
46   * @syscap SystemCapability.ArkUI.ArkUI.Full
47   * @atomicservice
48   * @since 12
49   */
50  (
51    loader: import('../api/@ohos.app.ability.Want').default,
52    type: EmbeddedType
53  ): EmbeddedComponentAttribute;
54
55  /**
56   * Construct the EmbeddedComponent.<br/>
57   * Called when the EmbeddedComponent is used.
58   *
59   * @param { Want } loader - indicates initialization parameter
60   * @param { EmbeddedType } type - indicates type of the EmbeddedComponent
61   * @returns { EmbeddedComponentAttribute }
62   * @syscap SystemCapability.ArkUI.ArkUI.Full
63   * @atomicservice
64   * @since 20
65   * @arkts 1.2
66   */
67  (
68    loader: Want,
69    type: EmbeddedType
70  ): EmbeddedComponentAttribute;
71}
72
73/**
74 * Indicates the information when the provider of the embedded UI is terminated.
75 *
76 * @interface TerminationInfo
77 * @syscap SystemCapability.ArkUI.ArkUI.Full
78 * @atomicservice
79 * @since 12
80 */
81declare interface TerminationInfo {
82  /**
83   * Defines the termination code.
84   *
85   * @type { number }
86   * @syscap SystemCapability.ArkUI.ArkUI.Full
87   * @atomicservice
88   * @since 12
89   */
90   code: number;
91
92  /**
93   * Defines the additional termination information.
94   *
95   * @type { ?import('../api/@ohos.app.ability.Want').default }
96   * @syscap SystemCapability.ArkUI.ArkUI.Full
97   * @atomicservice
98   * @since 12
99   */
100   want?: import('../api/@ohos.app.ability.Want').default;
101}
102
103/**
104 * Define the attribute functions of EmbeddedComponent.
105 *
106 * @extends CommonMethod<EmbeddedComponentAttribute>
107 * @syscap SystemCapability.ArkUI.ArkUI.Full
108 * @atomicservice
109 * @since arkts {'1.1':'12','1.2':'20'}
110 * @arkts 1.1&1.2
111 */
112declare class EmbeddedComponentAttribute extends CommonMethod<EmbeddedComponentAttribute> {
113  /**
114   * Called when the provider of the embedded UI is terminated.
115   *
116   * @param { import('../api/@ohos.base').Callback<TerminationInfo> } callback
117   * @returns { EmbeddedComponentAttribute }
118   * @syscap SystemCapability.ArkUI.ArkUI.Full
119   * @atomicservice
120   * @since 12
121   */
122  onTerminated(callback: import('../api/@ohos.base').Callback<TerminationInfo>): EmbeddedComponentAttribute;
123
124  /**
125   * Called when the provider of the embedded UI is terminated.
126   *
127   * @param { Callback<TerminationInfo> } callback
128   * @returns { EmbeddedComponentAttribute }
129   * @syscap SystemCapability.ArkUI.ArkUI.Full
130   * @atomicservice
131   * @since 20
132   * @arkts 1.2
133   */
134  onTerminated(callback: Callback<TerminationInfo>): EmbeddedComponentAttribute;
135
136  /**
137   * Called when some error occurred.
138   *
139   * @param { import('../api/@ohos.base').ErrorCallback } callback
140   * @returns { EmbeddedComponentAttribute }
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @atomicservice
143   * @since 12
144   */
145  onError(callback: import('../api/@ohos.base').ErrorCallback): EmbeddedComponentAttribute;
146
147  /**
148   * Called when some error occurred.
149   *
150   * @param { ErrorCallback<BusinessError> } callback
151   * @returns { EmbeddedComponentAttribute }
152   * @syscap SystemCapability.ArkUI.ArkUI.Full
153   * @atomicservice
154   * @since 20
155   * @arkts 1.2
156   */
157  onError(callback: ErrorCallback<BusinessError>): EmbeddedComponentAttribute;
158}
159
160/**
161 * Defines EmbeddedComponent Component.
162 *
163 * @syscap SystemCapability.ArkUI.ArkUI.Full
164 * @atomicservice
165 * @since 12
166 */
167declare const EmbeddedComponent: EmbeddedComponentInterface;
168
169/**
170 * Defines EmbeddedComponent Component instance.
171 *
172 * @syscap SystemCapability.ArkUI.ArkUI.Full
173 * @atomicservice
174 * @since 12
175 */
176declare const EmbeddedComponentInstance: EmbeddedComponentAttribute;
177