From 087361e399f90a4c1aff0ddb86cbe53c6b0d4ee9 Mon Sep 17 00:00:00 2001 From: lixingchi1 Date: Fri, 20 Jun 2025 14:38:09 +0800 Subject: [PATCH] add the interop api Signed-off-by: lixingchi1 --- api/arkui/component/interop.d.ets | 104 ++++++++++++++++++++++++++---- 1 file changed, 93 insertions(+), 11 deletions(-) diff --git a/api/arkui/component/interop.d.ets b/api/arkui/component/interop.d.ets index b7d49b0513..a576e7f180 100644 --- a/api/arkui/component/interop.d.ets +++ b/api/arkui/component/interop.d.ets @@ -1,10 +1,10 @@ /* - * Copyright (C) 2025 Huawei Device Co., Ltd. + * 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 + * 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, @@ -18,16 +18,98 @@ * @arkts 1.2 */ +import { Builder } from './builder'; +import { ExtendableComponent } from './extendableComponent'; +import { IDecoratedV1Variable } from '../stateManagement/decorator'; -import { memo, __memo_context_type, __memo_id_type } from '../stateManagement/runtime'; +/** + * 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; -export interface InteropComponent { - name: string, - component: Object + /** + * the compatible custom component + * + * @type { ESValue } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ + component: ESValue; } -@memo -export declare function ArkUICompatible( - init: () => InteropComponent, - update: (elmtId: number, instance: ESObject) => void -): void \ No newline at end of file +/** + * 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; + +/** + * Binds the callback for obtaining the provide's compatible state with compatible custom component. + * + * @param { ExtendableComponent } component - the custom component + * @param { ESValue } createCompatibleState - the callback for creating compatible state + * @param { ESValue } setCallback - set the callback for binding the provide's compatible state + * @param { ESValue } [compatibleComponent] - the compatible custom component + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 20 + */ +export declare function bindCompatibleProvideCallback( + component: ExtendableComponent, + createCompatibleState: ESValue, + setCallback: ESValue, + compatibleComponent?: ESValue +): void; + +/** + * 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