diff --git a/api/arkui/BuilderNode.d.ts b/api/arkui/BuilderNode.d.ts index 328b358da53ec28b49a6c575f8ad08df1a8cab00..3ca4d9d3aa2b89d81fe653c5c33c478bd7b6bf69 100644 --- a/api/arkui/BuilderNode.d.ts +++ b/api/arkui/BuilderNode.d.ts @@ -727,4 +727,202 @@ export declare class BuilderNode { * @arkts 1.2 */ updateConfiguration(): void; - } \ No newline at end of file + } + + /** + * Defines ReactiveBuilderNode. + * Implements a ReactiveBuilderNode, which can create a component tree through the stateless UI method @Builder and hold + * the root node of the component tree. A ReactiveBuilderNode cannot be defined as a state variable. The FrameNode held + * in the ReactiveBuilderNode is only used to mount the ReactiveBuilderNode to other FrameNodes as a child node. + * Undefined behavior may occur if you set attributes or perform operations on subnodes of the FrameNode held by the + * ReactiveBuilderNode. Therefore, after you have obtained a RenderNode through the getFrameNode method of the + * ReactiveBuilderNode and the getRenderNode method of the FrameNode, avoid setting the attributes or operating the + * subnodes through APIs of the RenderNode. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ +export class ReactiveBuilderNode { +/** + * Constructor. + * When the content generated by the ReactiveBuilderNode is embedded in another RenderNode for display, that is, the + * RenderNode corresponding to the ReactiveBuilderNode is mounted to another RenderNode for display, selfIdealSize in + * RenderOptions must be explicitly specified. If selfIdealSize is not set, the node in the builder follows the + * default parent component layout constraint [0, 0], which means that the size of the root node of the subtree in + * ReactiveBuilderNode is [0, 0]. + * + *

Note: + *
The input parameter for uiContext must be a valid value, that is, the UI context must be correct. If an invalid + *
value is passed in or if no value is specified, creation will fail. + *

+ * + * @param { UIContext } uiContext - uiContext used to create the ReactiveBuilderNode + * @param { RenderOptions } [options] - Render options of the Builder Node + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + constructor(uiContext: UIContext, options?: RenderOptions); +/** + * Build the ReactiveBuilderNode with the builder.Support the type that WrappedBuilder contains builder used different + * params. Creates a component tree based on the passed object and holds the root node of the component tree. The + * stateless UI method @Builder has at most one root node. Custom components are allowed. Yet, the custom components + * cannot use decorators, such as @Reusable, @Link, @Provide, and @Consume, for state synchronization with the current + * page. Custom components can receive LocalStorage instances. You can use LocalStorage related + * decorators such as @LocalStorageProp and @LocalStorageLink by passing LocalStorage instances. + * + *

Note: + *
For details about the creation and update using @Builder, see @Builder. + *
The outermost @Builder supports only one input argument. + *

+ * + * @param { WrappedBuilder } builder - Defined the builder will be called to build the node. + * @param { BuildOptions } config - Defined the options will be used when build. + * @param { Args } args - Defined the args will be used in the builder. The type of the input argument + * must be consistent with the type defined by @Builder. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + build(builder: WrappedBuilder, config: BuildOptions, ...args: Args): void; + /** + * Get the FrameNode in ReactiveBuilderNode. + * The FrameNode is generated only after the ReactiveBuilderNode executes the build operation. + * + * @returns { FrameNode | null } - Returns a FrameNode inside the ReactiveBuilderNode, or null if not contained. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + getFrameNode(): FrameNode | null; + + /** + * Dispatch touchEvent to targetNode. + * postTouchEvent dispatches the event from a middle node in the component tree downwards. To ensure the event is + * dispatched correctly, it needs to be transformed into the coordinate system of the parent component, as shown in + * the figure below. + * OffsetA indicates the offset of the BuildNode relative to the parent component. You can obtain this offset by + * calling getPositionToParent in the FrameNode. OffsetB indicates the offset of the touch point relative to the + * BuildNode. You can obtain this offset from the TouchEvent object. OffsetC is the sum of OffsetA and OffsetB. It + * represents the final offset that you need to pass to postTouchEvent. + * + *

Note: + *
The coordinates you pass in need to be converted to pixel values (px). If the ReactiveBuilderNode has any + *
affine transformations applied to it, they must be taken into account and combined with the touch event + *
coordinates. In Webview, coordinate system transformations are already handled internally, so you can directly + *
dispatch the touch event without additional adjustments. + *
The postTouchEvent API can be called only once for the same timestamp. + *
UIExtensionComponent is not supported. + *

+ * + * @param { TouchEvent } event - The touchEvent which will be sent to the targetNode. + * @returns { boolean } - Returns true if the TouchEvent has been successfully posted to the targetNode, false + * otherwise. If the event does not hit the expected component, ensure the following: + * 1. The coordinate system has been correctly transformed + * 2. The component is in an interactive state. + * 3. The event has been bound to the component. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + postTouchEvent(event: TouchEvent): boolean; + + /** + * Dispose the ReactiveBuilderNode immediately. + * Calling dispose on a ReactiveBuilderNode object breaks its reference to the backend entity node, and also + * simultaneously severs the references of its contained FrameNode and RenderNode to their respective entity nodes. + * + *

Note: + *
Calling dispose on a ReactiveBuilderNode object breaks its reference to the backend entity node, and also + *
simultaneously severs the references of its contained FrameNode and RenderNode to their respective entity + *
nodes. If the frontend object ReactiveBuilderNode cannot be released, memory leaks may occur. To avoid this, + *
be sure to call dispose on the ReactiveBuilderNode when you no longer need it. This reduces the complexity + *
of reference relationships and lowers the risk of memory leaks. + *

+ * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + dispose(): void; + + /** + * Reuse the ReactiveBuilderNode based on the provided parameters. + * + * @param { Object } [param] - Parameters for reusing ReactiveBuilderNode. + * It is of the same type as the parameter passed to the build API. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + reuse(param?: Object): void; + + /** + * Recycle the ReactiveBuilderNode. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + recycle(): void; + + /** + * Notify ReactiveBuilderNode to update the configuration to trigger a reload of the ReactiveBuilderNode. + * + *

Note: + *
The updateConfiguration API is used to instruct an object to update, with the system environment used for the + *
update being determined by the changes in the application's current system environment. + *

+ * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + updateConfiguration(): void; + + /** + * Dispatch mouse event to targetNode. + * + * @param { InputEventType } event - The event which will be sent to the targetNode. + * @returns { boolean } - Returns true if the event has been successfully posted to the targetNode, + * false otherwise. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @atomicservice + * @since 22 + */ + postInputEvent(event: InputEventType): boolean; + + /** + * Set if the ReactiveBuilderNode inherits the freezing policy of the parent CustomComponent, ComponentContent, + * ReactiveComponentContent, BuilderNode or ReactiveBuilderNode. + * + * @param { boolean } enabled - If the ReactiveBuilderNode inherits the freezing policy of the parent + * CustomComponent, ComponentContent, ReactiveComponentContent, BuilderNode or ReactiveBuilderNode. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + inheritFreezeOptions(enabled: boolean): void; + + /** + * Get if the node is disposed. + * + * @returns { boolean } - Returns true if the node is disposed, false otherwise. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + isDisposed(): boolean; +} \ No newline at end of file diff --git a/api/arkui/ComponentContent.d.ts b/api/arkui/ComponentContent.d.ts index 95200a415269c443afba6bf10ee085def27bbc9b..f55a6d880cd8209edd8fcf9c0422dfb369ccb6f2 100644 --- a/api/arkui/ComponentContent.d.ts +++ b/api/arkui/ComponentContent.d.ts @@ -267,3 +267,93 @@ export declare class ComponentContent extends Content { */ updateConfiguration(): void; } + +/** + * Defines ReactiveComponentContent. + * + * @extends Content + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ +export class ReactiveComponentContent extends Content { + /** + * Constructor. + * + * @param { UIContext } uiContext - uiContext used to create the ReactiveComponentContent + * @param { WrappedBuilder } builder - Defined the builder will be called to build ReactiveComponentContent. + * @param { BuildOptions } config - Defined the options will be used when build. + * @param { T } args - Parameters used to update the ComponentContentEx. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + constructor(uiContext: UIContext, builder: WrappedBuilder, config: BuildOptions, ...args: T); + /** + * Reuse the ReactiveComponentContent based on the provided parameters. + * + * @param { Object } [param] - Parameters for reusing ReactiveComponentContent. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + reuse(param?: Object): void; + + /** + * Recycle the ReactiveComponentContent. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + recycle(): void; + + /** + * Dispose the ReactiveComponentContent immediately. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + dispose(): void; + + /** + * Notify ReactiveComponentContent to update the configuration to trigger a reload of the ReactiveComponentContent. + * + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + updateConfiguration(): void; + + /** + * Set if the ReactiveComponentContent inherits the freezing policy of the parent CustomComponent, ComponentContent, + * ReactiveComponentContent, BuilderNode, or ReactiveBuilderNode. + * + * @param { boolean } enabled - If the ReactiveComponentContent inherits the freezing policy of the parent + * CustomComponent, ComponentContent, ComponentContent, ReactiveComponentContent, BuilderNode, or + * ReactiveBuilderNode. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + inheritFreezeOptions(enabled: boolean): void; + + /** + * Get if the ReactiveComponentContent is disposed. + * + * @returns { boolean } - Returns true if the ReactiveComponentContent is disposed, false otherwise. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + isDisposed(): boolean; +} \ No newline at end of file diff --git a/api/arkui/FrameNode.d.ts b/api/arkui/FrameNode.d.ts index 6c57ea91b2992ddc2e2513300d5cb74237a1e77b..84f6f3a6ea34480b74fd0c4134ed1406f1edb273 100644 --- a/api/arkui/FrameNode.d.ts +++ b/api/arkui/FrameNode.d.ts @@ -23,7 +23,7 @@ import { UIContext } from '../@ohos.arkui.UIContext'; import { RenderNode } from './RenderNode'; import { Size, Position, Edges, LengthMetrics, SizeT } from './Graphics'; import { DrawContext } from './Graphics'; -import { ComponentContent } from './ComponentContent'; +import { ComponentContent, ReactiveComponentContent } from './ComponentContent'; import { BusinessError } from '../@ohos.base'; /*** if arkts 1.2 */ import { UIContext } from '@ohos.arkui.UIContext'; @@ -1104,7 +1104,18 @@ export declare class FrameNode { * @atomicservice * @since 12 */ - addComponentContent(content: ComponentContent): void; + /** + * Mount ComponentContent and ReactiveComponentContent to FrameNode. + * The current node must be modifiable, which means the return value of isModifiable must be true. + * If the node is not modifiable, an exception is thrown. + * + * @param { ComponentContent | ReactiveComponentContent } content - Newly added ComponentContent. + * @syscap SystemCapability.ArkUI.ArkUI.Full + * @crossplatform + * @atomicservice + * @since 22 + */ + addComponentContent(content: ComponentContent | ReactiveComponentContent): void; /** * Mount ComponentContent to FrameNode.