• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2021 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 './basic';
17import { Want } from './ability/want';
18
19/**
20 * Plugin component template property.
21 * @syscap SystemCapability.ArkUI.ArkUI.Full
22 * @since 8
23 */
24interface PluginComponentTemplate {
25  source: string;
26  ability: string;
27}
28
29/**
30 * Plugin component manager interface.
31 * @syscap SystemCapability.ArkUI.ArkUI.Full
32 * @since 8
33 */
34declare namespace pluginComponentManager {
35  type KVObject = {[key: string]: number | string | boolean | [] | KVObject}
36
37  /**
38   * Plugin component push parameters.
39   * @since 8
40   */
41  interface PushParameters {
42    want: Want;
43    name: string;
44    data: KVObject;
45    extraData: KVObject;
46    jsonPath?: string;
47  }
48
49  /**
50   * Plugin component request parameters.
51   * @since 8
52   */
53  interface RequestParameters {
54    want: Want;
55    name: string;
56    data: KVObject;
57    jsonPath?: string;
58  }
59
60  /**
61   * Plugin component request callback parameters.
62   * @since 8
63   */
64  interface RequestCallbackParameters {
65    componentTemplate: PluginComponentTemplate;
66    data: KVObject;
67    extraData: KVObject;
68  }
69
70  /**
71   * Plugin component request event result value.
72   * @since 8
73   */
74  interface RequestEventResult {
75    template?: string;
76    data?: KVObject;
77    extraData?: KVObject;
78  }
79
80  /**
81   * Plugin component push event callback.
82   * @since 8
83   */
84  type OnPushEventCallback = (source: Want, template: PluginComponentTemplate, data: KVObject,
85    extraData: KVObject) => void;
86
87  /**
88   * Plugin component request event callback.
89   * @since 8
90   */
91
92  type OnRequestEventCallback = (source: Want, name: string, data: KVObject) => RequestEventResult;
93
94  /**
95   * Plugin component push method.
96   * @since 8
97   */
98  function push(param: PushParameters, callback: AsyncCallback<void>): void;
99
100  /**
101   * Plugin component request method.
102   * @since 8
103   */
104  function request(param: RequestParameters, callback: AsyncCallback<RequestCallbackParameters>): void;
105
106  /**
107   * Plugin component event listener.
108   * @since 8
109   */
110  function on(eventType: string, callback: OnPushEventCallback | OnRequestEventCallback): void;
111}
112
113export default pluginComponentManager;
114