From 5e9ad495bacc3930ab3a025b122c687e1ab2c8a4 Mon Sep 17 00:00:00 2001 From: lixingchi1 Date: Fri, 20 Jun 2025 11:59:53 +0800 Subject: [PATCH] add the interop api Signed-off-by: lixingchi1 --- api/arkui/component/interop.d.ets | 117 ++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) create mode 100644 api/arkui/component/interop.d.ets diff --git a/api/arkui/component/interop.d.ets b/api/arkui/component/interop.d.ets new file mode 100644 index 0000000000..c3c78476ac --- /dev/null +++ b/api/arkui/component/interop.d.ets @@ -0,0 +1,117 @@ +/* + * Copyright (c) 2025 Huawei Device Co., Ltd. + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +import { ExtendableComponent } from './extendableComponent'; +import { IDecoratedV1Variable } from '../stateManagement/decorator'; + +/** + * Defines the info of compatible custom component. + * + * @typedef CompatibleComponentInfo + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export interface CompatibleComponentInfo { + /** + * the name of compatible custom component + * + * @type { string } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + name: string, + + /** + * the compatible custom component + * + * @type { ESValue } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + component: ESValue +} + +/** + * Defines the callback for initializing compatible custom component. + * + * @typedef { function } CompatibleInitCallback + * @returns { CompatibleComponentInfo } the info of compatible custom component + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type CompatibleInitCallback = () => CompatibleComponentInfo; + +/** + * Defines the callback for updating compatible custom component. + * + * @typedef { function } CompatibleUpdateCallback + * @param { ESValue } component - the compatible custom component + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type CompatibleUpdateCallback = (component: ESValue) => void; + +/** + * Obtains the compatible custom component. + * + * @param { CompatibleInitCallback } init - the callback for initializing compatible custom component + * @param { CompatibleUpdateCallback } update - the callback for updating compatible custom component + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +@Builder +export declare function compatibleComponent( + init: CompatibleInitCallback, + update: CompatibleUpdateCallback +): void; + +/** + * Defines the callback for finding the provide's compatible state. + * + * @typedef { function } FindCompatibleProvideCallback + * @param { string } providePropertyName - the property name of provide + * @returns { Object } - the compatible state + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export type FindCompatibleProvideCallback = (providePropertyName: string) => Object; + +/** + * Obtains the callback for finding the provide's compatible state. + * + * @param { ExtendableComponent } component - the custom component + * @param { ESValue } createCompatibleState - the callback for creating compatible state + * @returns { FindCompatibleProvideCallback } the callback for finding the provide's compatible state + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare function getCompatibleProvideCallback( + component: ExtendableComponent, + createCompatibleState: ESValue +): FindCompatibleProvideCallback; + +/** + * Obtains the compatible state. + * + * @param { IDecoratedV1Variable } state - the source state + * @param { ESValue } createCompatibleState - the callback for creating compatible state + * @returns { ESValue } the compatible state + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare function getCompatibleState( + state: IDecoratedV1Variable, + createCompatibleState: ESValue +): ESValue; -- Gitee