• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1/*
2 * Copyright (c) 2023 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
16enum NodeRenderType {
17  RENDER_TYPE_DISPLAY = 0,
18  RENDER_TYPE_TEXTURE,
19}
20
21declare interface RenderOptions {
22  selfIdealSize?: Size,
23  type?: NodeRenderType,
24  surfaceId?: string
25}
26
27declare class DrawContext { }
28declare type NodePtr = Object | null;
29declare class __JSBaseNode__ {
30  constructor(options?: RenderOptions);
31  create(builder: (...args: Object[]) => void, params: Object, update: (instanceId: number, nodePtr: NodePtr) => void, updateConfiguration, supportLazyBuild: boolean): NodePtr;
32  finishUpdateFunc(): void;
33  postTouchEvent(touchEvent: TouchEvent): boolean;
34  disposeNode(): void;
35  updateStart(): void;
36  updateEnd(): void;
37}
38
39class BaseNode extends __JSBaseNode__ {
40  protected instanceId_?: number;
41  protected nodePtr_: NodePtr;
42  constructor(uiContext: UIContext, options?: RenderOptions) {
43    super(options);
44
45    if (uiContext === undefined) {
46      throw Error('Node constructor error, param uiContext error');
47    } else {
48      if (!(typeof uiContext === 'object') || !('instanceId_' in uiContext)) {
49        throw Error(
50          'Node constructor error, param uiContext is invalid'
51        );
52      }
53    }
54    this.instanceId_ = uiContext.instanceId_;
55  }
56  public getInstanceId() {
57    return this.instanceId_;
58  }
59  updateInstance(uiContext: UIContext): void {
60      this.instanceId_ = uiContext.instanceId_;
61  }
62}
63