From b471d10ce5e7462052226ec368b0cb9b5d94d890 Mon Sep 17 00:00:00 2001 From: ZhangYu Date: Fri, 1 Mar 2024 10:15:05 +0000 Subject: [PATCH] EmbedddedComponent Signed-off-by: ZhangYu --- .../component/ets/embedded_component.d.ts | 113 ++++++++++++++++++ api/@internal/component/ets/enums.d.ts | 19 ++- api/@internal/component/ets/index-full.d.ts | 3 +- 3 files changed, 133 insertions(+), 2 deletions(-) create mode 100644 api/@internal/component/ets/embedded_component.d.ts diff --git a/api/@internal/component/ets/embedded_component.d.ts b/api/@internal/component/ets/embedded_component.d.ts new file mode 100644 index 0000000000..e857c017ba --- /dev/null +++ b/api/@internal/component/ets/embedded_component.d.ts @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2024 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. + */ +/// +/// + +/** + * Provide an interface for the EmbeddedComponent, which is used + *
to render UI asynchronously + * + * @interface EmbeddedComponentInterface + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +interface EmbeddedComponentInterface { + /** + * Construct the EmbeddedComponent.
+ * Called when the EmbeddedComponent is used. + * + * @param { import('../api/@ohos.app.ability.Want').default } loader - indicates initialization parameter + * @param { EmbeddedType } type - indicates type of the EmbeddedComponent + * @returns { EmbeddedComponentAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + ( + loader: import('../api/@ohos.app.ability.Want').default, + type: EmbeddedType + ): EmbeddedComponentAttribute; +} + +/** + * Indicates the information when the provider of the embedded UI is terminated. + * + * @interface TerminationInfo + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +declare interface TerminationInfo { + /** + * Defines the termination code. + * + * @type { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + code: number; + + /** + * Defines the additional termination information. + * + * @type { ?import('../api/@ohos.app.ability.Want').default } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + want?: import('../api/@ohos.app.ability.Want').default; +} + +/** + * Define the attribute functions of EmbeddedComponent. + * + * @extends CommonMethod + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +declare class EmbeddedComponentAttribute extends CommonMethod { + /** + * Called when the provider of the embedded UI is terminated. + * + * @param { import('../api/@ohos.base').Callback } callback + * @returns { EmbeddedComponentAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + onTerminated(callback: import('../api/@ohos.base').Callback): EmbeddedComponentAttribute; + + /** + * Called when some error occurred. + * + * @param { import('../api/@ohos.base').ErrorCallback } callback + * @returns { EmbeddedComponentAttribute } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + onError(callback: import('../api/@ohos.base').ErrorCallback): EmbeddedComponentAttribute; +} + +/** + * Defines EmbeddedComponent Component. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +declare const EmbeddedComponent: EmbeddedComponentInterface; + +/** + * Defines EmbeddedComponent Component instance. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +declare const EmbeddedComponentInstance: EmbeddedComponentAttribute; diff --git a/api/@internal/component/ets/enums.d.ts b/api/@internal/component/ets/enums.d.ts index 5165539c93..c34c69ed80 100644 --- a/api/@internal/component/ets/enums.d.ts +++ b/api/@internal/component/ets/enums.d.ts @@ -9032,9 +9032,26 @@ declare enum AppRotation { ROTATION_270 = 3 } +/** + * Enum of EmbeddedType + * + * @enum { number } + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ +declare enum EmbeddedType { + /** + * The EmbeddedComponent show the UI in EmbeddedUIExtensionAbility. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @since 12 + */ + EMBEDDED_UI_EXTENSION = 0, +} + declare module 'borderStyle' { module 'borderStyle' { // @ts-ignore export type { BorderStyle }; } -} \ No newline at end of file +} diff --git a/api/@internal/component/ets/index-full.d.ts b/api/@internal/component/ets/index-full.d.ts index 8ae2661f20..6500ffa1a9 100644 --- a/api/@internal/component/ets/index-full.d.ts +++ b/api/@internal/component/ets/index-full.d.ts @@ -135,4 +135,5 @@ /// /// /// -/// \ No newline at end of file +/// +/// -- Gitee