1/*
2 * Copyright (c) 2021-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 * PluginComponentTemplate
23 *
24 * @interface PluginComponentTemplate
25 * @syscap SystemCapability.ArkUI.ArkUI.Full
26 * @systemapi
27 * @since 9
28 */
29interface PluginComponentTemplate {
30  /**
31   * Defines the plugin source name.
32   *
33   * @type { string }
34   * @syscap SystemCapability.ArkUI.ArkUI.Full
35   * @systemapi
36   * @since 9
37   */
38  source: string;
39  /**
40   * Defines the bundle name of the Template.
41   *
42   * @type { string }
43   * @syscap SystemCapability.ArkUI.ArkUI.Full
44   * @systemapi
45   * @since 9
46   */
47  bundleName: string;
48}
49
50/**
51 * Define options used to construct a plugin component.
52 *
53 * @interface PluginComponentOptions
54 * @syscap SystemCapability.ArkUI.ArkUI.Full
55 * @systemapi
56 * @since 14
57 */
58declare interface PluginComponentOptions {
59  /**
60   * Plugin component template.
61   * @type { PluginComponentTemplate }
62   * @syscap SystemCapability.ArkUI.ArkUI.Full
63   * @systemapi
64   * @since 9
65   */
66  template: PluginComponentTemplate;
67
68  /**
69   * Plugin component data.
70   * @type { any }
71   * @syscap SystemCapability.ArkUI.ArkUI.Full
72   * @systemapi
73   * @since 9
74   */
75  data: any
76}
77
78/**
79 * Data provided when an error occurs.
80 *
81 * @interface PluginErrorData
82 * @syscap SystemCapability.ArkUI.ArkUI.Full
83 * @systemapi
84 * @since 14
85 */
86declare interface PluginErrorData {
87  /**
88   * Error code.
89   * @type { number }
90   * @syscap SystemCapability.ArkUI.ArkUI.Full
91   * @systemapi
92   * @since 9
93   */
94  errcode: number;
95
96  /**
97   * Error message.
98   * @type { string }
99   * @syscap SystemCapability.ArkUI.ArkUI.Full
100   * @systemapi
101   * @since 9
102   */
103  msg: string;
104}
105
106/**
107 * Callback invoked when an error occurs.
108 *
109 * @typedef { function } PluginErrorCallback
110 * @param { PluginErrorData } info - Plugin error data
111 * @syscap SystemCapability.ArkUI.ArkUI.Full
112 * @systemapi
113 * @since 14
114 */
115declare type PluginErrorCallback = (info: PluginErrorData) => void
116
117/**
118 * Provides plugin component.
119 *
120 * @interface PluginComponentInterface
121 * @syscap SystemCapability.ArkUI.ArkUI.Full
122 * @systemapi
123 * @since 9
124 */
125interface PluginComponentInterface {
126  /**
127   * Called when setting the plugin.
128   *
129   * @param { object } value
130   * @returns { PluginComponentAttribute }
131   * @syscap SystemCapability.ArkUI.ArkUI.Full
132   * @systemapi
133   * @since 9
134   */
135  /**
136   * Called when setting the plugin.
137   *
138   * @param { PluginComponentOptions } options - Plugin component options
139   * @returns { PluginComponentAttribute }
140   * @syscap SystemCapability.ArkUI.ArkUI.Full
141   * @systemapi
142   * @since 14
143   */
144  (options: PluginComponentOptions): PluginComponentAttribute;
145}
146
147/**
148 * Defines the plugin component attribute functions.
149 *
150 * @extends CommonMethod<PluginComponentAttribute>
151 * @syscap SystemCapability.ArkUI.ArkUI.Full
152 * @systemapi
153 * @since 9
154 */
155declare class PluginComponentAttribute extends CommonMethod<PluginComponentAttribute> {
156  /**
157   * pluginComponent onComplete callback,
158   *
159   * @param { function } callback
160   * @returns { PluginComponentAttribute }
161   * @syscap SystemCapability.ArkUI.ArkUI.Full
162   * @systemapi
163   * @since 9
164   */
165  /**
166   * PluginComponent onComplete callback
167   *
168   * @param { VoidCallback } callback
169   * @returns { PluginComponentAttribute }
170   * @syscap SystemCapability.ArkUI.ArkUI.Full
171   * @systemapi
172   * @since 14
173   */
174  onComplete(callback: VoidCallback): PluginComponentAttribute;
175
176  /**
177   * pluginComponent onError callback,
178   *
179   * @param { function } callback
180   * @returns { PluginComponentAttribute }
181   * @syscap SystemCapability.ArkUI.ArkUI.Full
182   * @systemapi
183   * @since 9
184   */
185  /**
186   * PluginComponent onError callback
187   *
188   * @param { PluginErrorCallback } callback
189   * @returns { PluginComponentAttribute }
190   * @syscap SystemCapability.ArkUI.ArkUI.Full
191   * @systemapi
192   * @since 14
193   */
194  onError(callback: PluginErrorCallback): PluginComponentAttribute;
195}
196
197/**
198 * Defines PluginComponent Component.
199 *
200 * @syscap SystemCapability.ArkUI.ArkUI.Full
201 * @systemapi
202 * @since 9
203 */
204declare const PluginComponent: PluginComponentInterface;
205
206/**
207 * Defines PluginComponent Component instance.
208 *
209 * @syscap SystemCapability.ArkUI.ArkUI.Full
210 * @systemapi
211 * @since 9
212 */
213declare const PluginComponentInstance: PluginComponentAttribute;
214