1/* 2 * Copyright (c) 2023-2025 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15/// <reference path="../../state_mgmt/distRelease/stateMgmt.d.ts" /> 16/// <reference path="../../state_mgmt/src/lib/common/ace_console.native.d.ts" /> 17enum LogTag { 18 ARK_COMPONENT = 1, 19} 20class JSXNodeLogConsole { 21 static warn(...args:any) { 22 aceConsole.warn(LogTag.ARK_COMPONENT, ...args); 23 } 24} 25enum NodeRenderType { 26 RENDER_TYPE_DISPLAY = 0, 27 RENDER_TYPE_TEXTURE, 28} 29 30declare interface RenderOptions { 31 selfIdealSize?: Size, 32 type?: NodeRenderType, 33 surfaceId?: string 34} 35 36declare class DrawContext { } 37declare type NodePtr = Object | null; 38declare class __JSBaseNode__ { 39 constructor(options?: RenderOptions); 40 create(builder: (...args: Object[]) => void, params: Object, update: (instanceId: number, nodePtr: NodePtr) => void, 41 updateConfiguration, supportLazyBuild: boolean, baseNode: BaseNode): NodePtr; 42 finishUpdateFunc(): void; 43 postTouchEvent(touchEvent: TouchEvent): boolean; 44 postInputEvent(event: InputEventType): boolean; 45 disposeNode(): void; 46 updateStart(): void; 47 updateEnd(): void; 48 onRecycleWithBindObject(): void; 49 onReuseWithBindObject(object: Object): void; 50} 51abstract class BaseNode extends ViewBuildNodeBase { 52 protected instanceId_?: number; 53 protected nodePtr_: NodePtr; 54 public builderBaseNode_: __JSBaseNode__; 55 constructor(uiContext: UIContext, options?: RenderOptions) { 56 super(false); 57 let baseNode = new __JSBaseNode__(options); 58 this.builderBaseNode_ = baseNode; 59 60 if (uiContext === undefined) { 61 throw Error('Node constructor error, param uiContext error'); 62 } else { 63 if (!(typeof uiContext === 'object') || !('instanceId_' in uiContext)) { 64 throw Error( 65 'Node constructor error, param uiContext is invalid' 66 ); 67 } 68 } 69 this.instanceId_ = uiContext.instanceId_; 70 } 71 public getInstanceId() { 72 return this.instanceId_; 73 } 74 updateInstance(uiContext: UIContext): void { 75 this.instanceId_ = uiContext.instanceId_; 76 } 77 create(builder: (...args: Object[]) => void, params: Object, update: (instanceId: number, nodePtr: NodePtr) => void, 78 updateConfiguration, supportLazyBuild: boolean): NodePtr { 79 return this.builderBaseNode_.create(builder.bind(this), params, update.bind(this), updateConfiguration.bind(this), supportLazyBuild, this); 80 } 81 finishUpdateFunc(): void { 82 return this.builderBaseNode_.finishUpdateFunc(); 83 } 84 postTouchEvent(touchEvent: TouchEvent): boolean { 85 return this.builderBaseNode_.postTouchEvent(touchEvent); 86 } 87 postInputEvent(event: InputEventType): boolean { 88 return this.builderBaseNode_.postInputEvent(event); 89 } 90 disposeNode(): void { 91 return this.builderBaseNode_.disposeNode(); 92 } 93 updateStart(): void { 94 return this.builderBaseNode_.updateStart(); 95 } 96 updateEnd(): void { 97 return this.builderBaseNode_.updateEnd(); 98 } 99 onRecycleWithBindObject(): void { 100 return this.builderBaseNode_.onRecycleWithBindObject(); 101 } 102 onReuseWithBindObject(object: Object): void { 103 return this.builderBaseNode_.onReuseWithBindObject(object); 104 } 105 public abstract ifElseBranchUpdateFunctionDirtyRetaken(): void; 106 public abstract forceCompleteRerender(deep: boolean): void; 107 public abstract forceRerenderNode(elmtId: number): void; 108 public abstract purgeDeleteElmtId(rmElmtId: number): boolean; 109} 110