• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
16import { AsyncCallback } from './@ohos.base';
17import Want from './@ohos.app.ability.Want';
18
19/**
20 * Plugin component template property.
21 *
22 * @interface PluginComponentTemplate
23 * @syscap SystemCapability.ArkUI.ArkUI.Full
24 * @since 8
25 */
26interface PluginComponentTemplate {
27  source: string;
28  ability: string;
29}
30
31/**
32 * Plugin component manager interface.
33 *
34 * @namespace pluginComponentManager
35 * @syscap SystemCapability.ArkUI.ArkUI.Full
36 * @since 8
37 */
38declare namespace pluginComponentManager {
39  type KVObject = { [key: string]: number | string | boolean | [] | KVObject }
40
41  /**
42   * Plugin component push parameters.
43   *
44   * @interface PushParameters
45   * @syscap SystemCapability.ArkUI.ArkUI.Full
46   * @since 8
47   */
48  interface PushParameters {
49    want: Want;
50    name: string;
51    data: KVObject;
52    extraData: KVObject;
53    jsonPath?: string;
54  }
55
56  /**
57   * Plugin component push parameters which is used in push function.
58   *
59   * @interface PushParameterForStage
60   * @syscap SystemCapability.ArkUI.ArkUI.Full
61   * @systemapi
62   * @since 9
63   */
64  interface PushParameterForStage {
65    owner: Want;
66    target: Want;
67    name: string;
68    data: KVObject;
69    extraData: KVObject;
70    jsonPath?: string;
71  }
72
73  /**
74   * Plugin component request parameters.
75   *
76   * @interface RequestParameters
77   * @syscap SystemCapability.ArkUI.ArkUI.Full
78   * @since 8
79   */
80  interface RequestParameters {
81    want: Want;
82    name: string;
83    data: KVObject;
84    jsonPath?: string;
85  }
86
87  /**
88   * Plugin component request parameters which is used in request function.
89   *
90   * @interface RequestParameterForStage
91   * @syscap SystemCapability.ArkUI.ArkUI.Full
92   * @systemapi
93   * @since 9
94   */
95  interface RequestParameterForStage {
96    owner: Want;
97    target: Want;
98    name: string;
99    data: KVObject;
100    jsonPath?: string;
101  }
102
103  /**
104   * Plugin component request callback parameters.
105   *
106   * @interface RequestCallbackParameters
107   * @syscap SystemCapability.ArkUI.ArkUI.Full
108   * @since 8
109   */
110  interface RequestCallbackParameters {
111    componentTemplate: PluginComponentTemplate;
112    data: KVObject;
113    extraData: KVObject;
114  }
115
116  /**
117   * Plugin component request event result value.
118   *
119   * @interface RequestEventResult
120   * @syscap SystemCapability.ArkUI.ArkUI.Full
121   * @since 8
122   */
123  interface RequestEventResult {
124    template?: string;
125    data?: KVObject;
126    extraData?: KVObject;
127  }
128
129  /**
130   * Plugin component push event callback.
131   *
132   * @syscap SystemCapability.ArkUI.ArkUI.Full
133   * @since 8
134   */
135  type OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KVObject,
136    extraData: KVObject) => void;
137
138  /**
139   * Plugin component request event callback.
140   *
141   * @syscap SystemCapability.ArkUI.ArkUI.Full
142   * @since 8
143   */
144
145  type OnRequestEventCallback = (source: Want, name: string, data: KVObject) => RequestEventResult;
146
147  /**
148   * Plugin component push method.
149   *
150   * @param { PushParameters } param
151   * @param { AsyncCallback<void> } callback
152   * @syscap SystemCapability.ArkUI.ArkUI.Full
153   * @since 8
154   */
155  function push(param: PushParameters, callback: AsyncCallback<void>): void;
156
157  /**
158   * Plugin component request method.
159   *
160   * @param { RequestParameters } param
161   * @param { AsyncCallback<RequestCallbackParameters> } callback
162   * @syscap SystemCapability.ArkUI.ArkUI.Full
163   * @since 8
164   */
165  function request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void;
166
167  /**
168   * Plugin component push method used to send the information of the template it provides.
169   *
170   * @param { PushParameterForStage } param - Plugin component push parameters for stage.
171   * @param { AsyncCallback<void> } callback - Plugin component push event callback.
172   * @syscap SystemCapability.ArkUI.ArkUI.Full
173   * @systemapi
174   * @StageModelOnly
175   * @since 9
176   */
177  function push(param: PushParameterForStage, callback: AsyncCallback<void>): void;
178
179  /**
180   * Plugin component request method used to send a request for the information of the template it wants.
181   *
182   * @param { RequestParameterForStage } param - Plugin component request parameters for stage.
183   * @param { AsyncCallback<RequestCallbackParameters> } callback - Plugin component request event callback.
184   * @syscap SystemCapability.ArkUI.ArkUI.Full
185   * @systemapi
186   * @StageModelOnly
187   * @since 9
188   */
189  function request(param: RequestParameterForStage, callback: AsyncCallback<RequestCallbackParameters>): void;
190
191  /**
192   * Plugin component event listener.
193   *
194   * @param { string } eventType
195   * @param { OnPushEventCallback | OnRequestEventCallback } callback
196   * @syscap SystemCapability.ArkUI.ArkUI.Full
197   * @since 8
198   */
199  function on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback): void;
200}
201
202export default pluginComponentManager;
203