import { IReactionPublic, IReactionOptions, IReactionDisposer, IEventBus } from '@alilc/lowcode-editor-core'; import { ISimulatorHost, Component, DropContainer } from '../simulator'; import Viewport from './viewport'; import { Node, INode } from '../document'; import ResourceConsumer from './resource-consumer'; import { Asset, AssetList, UtilsMetadata } from '@alilc/lowcode-utils'; import { ILocateEvent, Designer, IDesigner } from '../designer'; import { IPublicTypeComponentMetadata, IPublicTypePackage, IPublicTypeNodeInstance, IPublicTypeComponentInstance, IPublicTypeRect } from '@alilc/lowcode-types'; import { BuiltinSimulatorRenderer } from './renderer'; import { LiveEditing } from './live-editing/live-editing'; import { IProject, Project } from '../project'; import { IScroller } from '../designer/scroller'; export type LibraryItem = IPublicTypePackage & { package: string; library: string; urls?: Asset; editUrls?: Asset; }; export interface DeviceStyleProps { canvas?: object; viewport?: object; } export interface BuiltinSimulatorProps { designMode?: 'live' | 'design' | 'preview' | 'extend' | 'border'; device?: 'mobile' | 'iphone' | string; deviceClassName?: string; environment?: Asset; /** @property 请求处理器配置 */ requestHandlersMap?: any; extraEnvironment?: Asset; library?: LibraryItem[]; utilsMetadata?: UtilsMetadata; simulatorUrl?: Asset; theme?: Asset; componentsAsset?: Asset; [key: string]: any; } export declare class BuiltinSimulatorHost implements ISimulatorHost { readonly isSimulator = true; readonly project: IProject; readonly designer: IDesigner; readonly viewport: Viewport; readonly scroller: IScroller; readonly emitter: IEventBus; readonly componentsConsumer: ResourceConsumer; readonly injectionConsumer: ResourceConsumer; readonly i18nConsumer: ResourceConsumer; /** * 是否为画布自动渲染 */ autoRender: boolean; get currentDocument(): import("../document").IDocumentModel; get renderEnv(): string; get device(): string; get locale(): string; get deviceClassName(): string | undefined; get designMode(): 'live' | 'design' | 'preview'; get requestHandlersMap(): any; get thisRequiredInJSE(): boolean; get enableStrictNotFoundMode(): any; get notFoundComponent(): any; get faultComponent(): any; get faultComponentMap(): any; get componentsAsset(): Asset | undefined; get theme(): Asset | undefined; get componentsMap(): { [key: string]: import("@alilc/lowcode-types").IPublicTypeNpmInfo | Component; }; get deviceStyle(): DeviceStyleProps | undefined; _props: BuiltinSimulatorProps; private _contentWindow?; get contentWindow(): Window; private _contentDocument?; private _appHelper?; get contentDocument(): Document; private _renderer?; get renderer(): BuiltinSimulatorRenderer; readonly asyncLibraryMap: { [key: string]: {}; }; readonly libraryMap: { [key: string]: string; }; private _iframe?; private disableHovering?; private disableDetecting?; readonly liveEditing: LiveEditing; private instancesMap; private tryScrollAgain; private _sensorAvailable; /** * @see IPublicModelSensor */ get sensorAvailable(): boolean; private sensing; constructor(project: Project, designer: Designer); stopAutoRepaintNode(): void; enableAutoRepaintNode(): void; /** * @see ISimulator */ setProps(props: BuiltinSimulatorProps): void; set(key: string, value: any): void; get(key: string): any; /** * 有 Renderer 进程连接进来,设置同步机制 */ connect(renderer: BuiltinSimulatorRenderer, effect: (reaction: IReactionPublic) => void, options?: IReactionOptions): IReactionDisposer; reaction(expression: (reaction: IReactionPublic) => unknown, effect: (value: unknown, prev: unknown, reaction: IReactionPublic) => void, opts?: IReactionOptions | undefined): IReactionDisposer; autorun(effect: (reaction: IReactionPublic) => void, options?: IReactionOptions): IReactionDisposer; purge(): void; mountViewport(viewport: HTMLElement | null): void; /** * { * "title":"BizCharts", * "package":"bizcharts", * "exportName":"bizcharts", * "version":"4.0.14", * "urls":[ * "https://g.alicdn.com/code/lib/bizcharts/4.0.14/BizCharts.js" * ], * "library":"BizCharts" * } * package:String 资源 npm 包名 * exportName:String umd 包导出名字,用于适配部分物料包 define name 不一致的问题,例如把 BizCharts 改成 bizcharts,用来兼容物料用 define 声明的 bizcharts * version:String 版本号 * urls:Array 资源 cdn 地址,必须是 umd 类型,可以是.js 或者.css * library:String umd 包直接导出的 name */ buildLibrary(library?: LibraryItem[]): AssetList; rerender(): void; mountContentFrame(iframe: HTMLIFrameElement | null): Promise; setupComponents(library: LibraryItem[]): Promise; setupEvents(): void; postEvent(eventName: string, ...data: any[]): void; setupDragAndClick(): void; /** * 设置悬停处理 */ setupDetecting(): void; setupLiveEditing(): void; /** * @see ISimulator */ setSuspense(): boolean; setupContextMenu(): void; /** * @see ISimulator */ generateComponentMetadata(componentName: string): IPublicTypeComponentMetadata; /** * @see ISimulator */ getComponent(componentName: string): Component | null; createComponent(): Component | null; setInstance(docId: string, id: string, instances: IPublicTypeComponentInstance[] | null): void; /** * @see ISimulator */ getComponentInstances(node: INode, context?: IPublicTypeNodeInstance): IPublicTypeComponentInstance[] | null; /** * @see ISimulator */ getComponentContext(): any; /** * @see ISimulator */ getClosestNodeInstance(from: IPublicTypeComponentInstance, specId?: string): IPublicTypeNodeInstance | null; /** * @see ISimulator */ computeRect(node: INode): IPublicTypeRect | null; /** * @see ISimulator */ computeComponentInstanceRect(instance: IPublicTypeComponentInstance, selector?: string): IPublicTypeRect | null; /** * @see ISimulator */ findDOMNodes(instance: IPublicTypeComponentInstance, selector?: string): Array | null; /** * 通过 DOM 节点获取节点,依赖 simulator 的接口 */ getNodeInstanceFromElement(target: Element | null): IPublicTypeNodeInstance | null; /** * @see ISimulator */ scrollToNode(node: Node, detail?: any): void; /** * @see ISimulator */ setNativeSelection(enableFlag: boolean): void; /** * @see ISimulator */ setDraggingState(state: boolean): void; /** * @see ISimulator */ setCopyState(state: boolean): void; /** * @see ISimulator */ clearState(): void; /** * @see IPublicModelSensor */ fixEvent(e: ILocateEvent): ILocateEvent; /** * @see IPublicModelSensor */ isEnter(e: ILocateEvent): boolean; /** * @see IPublicModelSensor */ deactiveSensor(): void; /** * @see IPublicModelSensor */ locate(e: ILocateEvent): any; /** * 查找合适的投放容器 */ getDropContainer(e: ILocateEvent): DropContainer | null; isAcceptable(): boolean; /** * 控制接受 */ handleAccept({ container }: DropContainer, e: ILocateEvent): boolean; /** * 查找邻近容器 */ getNearByContainer({ container, instance }: DropContainer, drillDownExcludes: Set): any; }