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 16/** 17 * Defines XComponentController 18 * @since 8 19 */ 20declare class XComponentController { 21 /** 22 * Constructor. 23 * @since 8 24 */ 25 constructor(); 26 27 /** 28 * Get the id of surface created by XComponent. 29 * @since 9 30 */ 31 getXComponentSurfaceId(): string; 32 33 /** 34 * Get the context of native XComponent. 35 * @since 8 36 */ 37 getXComponentContext(): Object; 38 39 /** 40 * Set the surface size created by XComponent. 41 * @since 9 42 */ 43 setXComponentSurfaceSize(value: { 44 surfaceWidth: number; 45 surfaceHeight: number; 46 }): void; 47} 48 49/** 50 * Defines XComponent. 51 * @since 8 52 */ 53interface XComponentInterface { 54 /** 55 * Constructor parameters 56 * @since 8 57 */ 58 (value: { id: string; type: string; libraryname?: string; controller?: XComponentController }): XComponentAttribute; 59} 60 61/** 62 * Defines XComponentAttribute. 63 * @since 8 64 */ 65declare class XComponentAttribute extends CommonMethod<XComponentAttribute> { 66 /** 67 * Called when judging whether the xcomponent surface is created. 68 * @since 8 69 */ 70 onLoad(callback: (event?: object) => void): XComponentAttribute; 71 72 /** 73 * Called when judging whether the xcomponent is destroyed. 74 * @since 8 75 */ 76 onDestroy(event: () => void): XComponentAttribute; 77} 78 79/** 80 * Defines XComponent Component. 81 * @since 8 82 */ 83declare const XComponent: XComponentInterface; 84 85/** 86 * Defines XComponent Component instance. 87 * @since 8 88 */ 89declare const XComponentInstance: XComponentAttribute; 90