Skip to content

Commit 980957f

Browse files
knight.chenliujuping
authored andcommitted
feat: extract simulator type
1 parent 035c213 commit 980957f

File tree

3 files changed

+35
-24
lines changed

3 files changed

+35
-24
lines changed

packages/designer/src/builtin-simulator/renderer.ts

Lines changed: 2 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,7 @@
11
import { Component } from '../simulator';
2-
import { IPublicTypeComponentInstance, IPublicTypeNodeInstance, Asset, IPublicTypeComponentSchema, IPublicTypeProjectSchema, IPublicTypeLowCodeComponent } from '@alilc/lowcode-types';
2+
import { IPublicTypeComponentInstance, IPublicTypeSimulatorRenderer } from '@alilc/lowcode-types';
33

4-
export interface BuiltinSimulatorRenderer {
5-
readonly isSimulatorRenderer: true;
6-
autoRepaintNode?: boolean;
7-
components: Record<string, Component>;
8-
rerender: () => void;
9-
createComponent(schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>): Component | null;
10-
getComponent(componentName: string): Component;
11-
getClosestNodeInstance(
12-
from: IPublicTypeComponentInstance,
13-
nodeId?: string,
14-
): IPublicTypeNodeInstance<IPublicTypeComponentInstance> | null;
15-
findDOMNodes(instance: IPublicTypeComponentInstance): Array<Element | Text> | null;
16-
getClientRects(element: Element | Text): DOMRect[];
17-
setNativeSelection(enableFlag: boolean): void;
18-
setDraggingState(state: boolean): void;
19-
setCopyState(state: boolean): void;
20-
loadAsyncLibrary(asyncMap: { [index: string]: any }): void;
21-
clearState(): void;
22-
stopAutoRepaintNode(): void;
23-
enableAutoRepaintNode(): void;
24-
run(): void;
25-
load(asset: Asset): Promise<any>;
26-
}
4+
export type BuiltinSimulatorRenderer = IPublicTypeSimulatorRenderer<Component, IPublicTypeComponentInstance>;
275

286
export function isSimulatorRenderer(obj: any): obj is BuiltinSimulatorRenderer {
297
return obj && obj.isSimulatorRenderer;

packages/types/src/shell/type/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,3 +90,4 @@ export * from './editor-view-config';
9090
export * from './hotkey-callback-config';
9191
export * from './hotkey-callbacks';
9292
export * from './scrollable';
93+
export * from './simulator-renderer';
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
import { Asset } from '../../assets';
2+
import {
3+
IPublicTypeNodeInstance,
4+
IPublicTypeProjectSchema,
5+
IPublicTypeComponentSchema,
6+
} from './';
7+
8+
export interface IPublicTypeSimulatorRenderer<Component, ComponentInstance> {
9+
readonly isSimulatorRenderer: true;
10+
autoRepaintNode?: boolean;
11+
components: Record<string, Component>;
12+
rerender: () => void;
13+
createComponent(
14+
schema: IPublicTypeProjectSchema<IPublicTypeComponentSchema>,
15+
): Component | null;
16+
getComponent(componentName: string): Component;
17+
getClosestNodeInstance(
18+
from: ComponentInstance,
19+
nodeId?: string,
20+
): IPublicTypeNodeInstance<ComponentInstance> | null;
21+
findDOMNodes(instance: ComponentInstance): Array<Element | Text> | null;
22+
getClientRects(element: Element | Text): DOMRect[];
23+
setNativeSelection(enableFlag: boolean): void;
24+
setDraggingState(state: boolean): void;
25+
setCopyState(state: boolean): void;
26+
loadAsyncLibrary(asyncMap: { [index: string]: any }): void;
27+
clearState(): void;
28+
stopAutoRepaintNode(): void;
29+
enableAutoRepaintNode(): void;
30+
run(): void;
31+
load(asset: Asset): Promise<any>;
32+
}

0 commit comments

Comments
 (0)