diff --git a/arkoala-arkts/arkui/src/handwritten/BuilderNdoe.ts b/arkoala-arkts/arkui/src/handwritten/BuilderNdoe.ts new file mode 100644 index 0000000000000000000000000000000000000000..88a43e0002d1e87a62c31ca5555f5cacf10adfb9 --- /dev/null +++ b/arkoala-arkts/arkui/src/handwritten/BuilderNdoe.ts @@ -0,0 +1,80 @@ +/* + * 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 { PeerNode } from "../PeerNode"; +import { ArkComponentRootPeer, ArkRootPeer } from "../generated/peers/ArkStaticComponentsPeer"; +import { FrameNode, FrameNodeInternal, Size } from "../generated"; +import { createUiDetachedRoot, destroyUiDetachedRoot } from "../Application"; +import { KPointer } from "@koalaui/interop"; +export enum NodeRenderType { + RENDER_TYPE_DISPLAY = 0, + RENDER_TYPE_TEXTURE = 1, +} +export interface RenderOptions { + selfIdealSize?: Size; + type?: NodeRenderType; + surfaceId?: string; +} +export class WrappedBuilder { + constructor( + /** @memo */ + builder: (args: Args) => void + ) { + this.builder = builder; + } + /** @memo */ + builder?: (args: Args) => void; +} +export class BuilderNode { + private __options?: RenderOptions; + private __builder?: WrappedBuilder; + private __root?: PeerNode; + + constructor(options?: RenderOptions) { + this.__options = options; + } + build(builder: WrappedBuilder, arg?: Args): void { + this.__builder = builder; + createUiDetachedRoot(() => { + if (this.__root == null) { + let root = ArkComponentRootPeer.create(); + this.__root = root; + } else { + this.__root?.firstChild?.dispose(); + } + return this.__root!; + }, () => { + if (arg) { + this.__builder?.builder?.(arg); + } + }) + } + update(arg: Args): void { + if (this.__builder) { + this.build(this.__builder!, arg); + } + } + getFrameNode(): FrameNode | null { + if (!this.__root){ + return null; + }else { + let ptr:KPointer=this.__root!.peer.ptr; + let node = FrameNodeInternal.fromPtr(ptr); + return node; + } + } + dispose(): void { + if (this.__root) destroyUiDetachedRoot(this.__root!) + } +} \ No newline at end of file diff --git a/arkoala-arkts/arkui/src/handwritten/index.ts b/arkoala-arkts/arkui/src/handwritten/index.ts index d2bde379dd3be8325b6d3f42f85c1c5759c9acc6..336cccb2236fc1bd90947371faaa1f1c9cc3ab7b 100644 --- a/arkoala-arkts/arkui/src/handwritten/index.ts +++ b/arkoala-arkts/arkui/src/handwritten/index.ts @@ -4,6 +4,7 @@ export * from "./ArkPageTransitionData" export * from "./Router" export * from "./ForeignFunctions" export * from "./resources" +export * from "./BuilderNdoe" // TODO: implement this diff --git a/arkoala-arkts/arkui/types/index-full.d.ts b/arkoala-arkts/arkui/types/index-full.d.ts index 4de299b586003113694f51a0117a53011987d4fe..c81307c8cf13f16ecf37c77fb8642bae8d243f67 100644 --- a/arkoala-arkts/arkui/types/index-full.d.ts +++ b/arkoala-arkts/arkui/types/index-full.d.ts @@ -9009,6 +9009,30 @@ declare interface RawFileDescriptor { offset: number; length: number; } +declare enum NodeRenderType { + RENDER_TYPE_DISPLAY = 0, + RENDER_TYPE_TEXTURE = 1, +} +declare class RenderOptions { + selfIdealSize?: Size; + type?: NodeRenderType; + surfaceId?: string; +} +declare class WrappedBuilder { + constructor( + /** @memo */ + builder: (args: Args) => void + ); + /** @memo */ + builder: (args: Args) => void; +} +declare class BuilderNode { + constructor(options?: RenderOptions); + build(builder: WrappedBuilder, arg?: Args): void; + getFrameNode(): FrameNode | null; + update(arg: Args): void; + dispose(): void; +} declare const AbilityComponent: AbilityComponentInterface declare const AbilityComponentInstance: AbilityComponentAttribute declare const AlphabetIndexer: AlphabetIndexerInterface diff --git a/arkoala/arkui-types/index-full.d.ts b/arkoala/arkui-types/index-full.d.ts index 31f758598c3fdbbf4343a2e7946d69d3012a6d46..3bff503fa2be273fea7bdbb36fb52ac5e159ac3f 100644 --- a/arkoala/arkui-types/index-full.d.ts +++ b/arkoala/arkui-types/index-full.d.ts @@ -9087,6 +9087,30 @@ declare interface RawFileDescriptor { offset: number; length: number; } +declare enum NodeRenderType { + RENDER_TYPE_DISPLAY = 0, + RENDER_TYPE_TEXTURE = 1, +} +declare class RenderOptions { + selfIdealSize?: Size; + type?: NodeRenderType; + surfaceId?: string; +} +declare class WrappedBuilder { + constructor( + /** @memo */ + builder: (args: Args) => void + ); + /** @memo */ + builder: (args: Args) => void; +} +declare class BuilderNode { + constructor(options?: RenderOptions); + build(builder: WrappedBuilder, arg?: Args): void; + getFrameNode(): FrameNode | null; + update(arg: Args): void; + dispose(): void; +} declare const AbilityComponent: AbilityComponentInterface declare const AbilityComponentInstance: AbilityComponentAttribute declare const AlphabetIndexer: AlphabetIndexerInterface diff --git a/arkoala/arkui/src/handwritten/BuilderNdoe.ts b/arkoala/arkui/src/handwritten/BuilderNdoe.ts new file mode 100644 index 0000000000000000000000000000000000000000..88a43e0002d1e87a62c31ca5555f5cacf10adfb9 --- /dev/null +++ b/arkoala/arkui/src/handwritten/BuilderNdoe.ts @@ -0,0 +1,80 @@ +/* + * 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 { PeerNode } from "../PeerNode"; +import { ArkComponentRootPeer, ArkRootPeer } from "../generated/peers/ArkStaticComponentsPeer"; +import { FrameNode, FrameNodeInternal, Size } from "../generated"; +import { createUiDetachedRoot, destroyUiDetachedRoot } from "../Application"; +import { KPointer } from "@koalaui/interop"; +export enum NodeRenderType { + RENDER_TYPE_DISPLAY = 0, + RENDER_TYPE_TEXTURE = 1, +} +export interface RenderOptions { + selfIdealSize?: Size; + type?: NodeRenderType; + surfaceId?: string; +} +export class WrappedBuilder { + constructor( + /** @memo */ + builder: (args: Args) => void + ) { + this.builder = builder; + } + /** @memo */ + builder?: (args: Args) => void; +} +export class BuilderNode { + private __options?: RenderOptions; + private __builder?: WrappedBuilder; + private __root?: PeerNode; + + constructor(options?: RenderOptions) { + this.__options = options; + } + build(builder: WrappedBuilder, arg?: Args): void { + this.__builder = builder; + createUiDetachedRoot(() => { + if (this.__root == null) { + let root = ArkComponentRootPeer.create(); + this.__root = root; + } else { + this.__root?.firstChild?.dispose(); + } + return this.__root!; + }, () => { + if (arg) { + this.__builder?.builder?.(arg); + } + }) + } + update(arg: Args): void { + if (this.__builder) { + this.build(this.__builder!, arg); + } + } + getFrameNode(): FrameNode | null { + if (!this.__root){ + return null; + }else { + let ptr:KPointer=this.__root!.peer.ptr; + let node = FrameNodeInternal.fromPtr(ptr); + return node; + } + } + dispose(): void { + if (this.__root) destroyUiDetachedRoot(this.__root!) + } +} \ No newline at end of file diff --git a/arkoala/arkui/src/handwritten/index.ts b/arkoala/arkui/src/handwritten/index.ts index af522bc05c0dfc8f2e7d769b92991f626cb6590e..a3f301a01ee2d68bc9fd3c7bd67f18ab58ecf31e 100644 --- a/arkoala/arkui/src/handwritten/index.ts +++ b/arkoala/arkui/src/handwritten/index.ts @@ -15,5 +15,6 @@ export * from "./ArkNavPathStack" export * from "./ArkPageTransition" +export * from "./BuilderNdoe" export interface AttributeModifier {} export interface NavigationAttribute {} \ No newline at end of file