@easy-editor/core 0.0.15 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/README.md +26 -28
  2. package/dist/config.d.ts +131 -0
  3. package/dist/designer/active-tracker.d.ts +17 -0
  4. package/dist/designer/designer.d.ts +31 -13
  5. package/dist/designer/dragon.d.ts +4 -5
  6. package/dist/designer/index.d.ts +0 -1
  7. package/dist/designer/location.d.ts +0 -3
  8. package/dist/designer/scroller.d.ts +34 -0
  9. package/dist/designer/selection.d.ts +1 -1
  10. package/dist/designer/sensor.d.ts +1 -1
  11. package/dist/designer/setting/setting-entry.d.ts +2 -2
  12. package/dist/designer/setting/setting-field.d.ts +2 -2
  13. package/dist/designer/setting/setting-manager.d.ts +2 -2
  14. package/dist/designer/setting/setting-prop-entry.d.ts +4 -4
  15. package/dist/designer/setting/setting-top-entry.d.ts +2 -2
  16. package/dist/document/document.d.ts +2 -4
  17. package/dist/document/node/node-children.d.ts +2 -3
  18. package/dist/document/node/node.d.ts +2 -3
  19. package/dist/document/prop/prop.d.ts +2 -3
  20. package/dist/document/prop/props.d.ts +2 -3
  21. package/dist/engine/editor.d.ts +45 -0
  22. package/dist/engine/engine.d.ts +11 -0
  23. package/dist/engine/index.d.ts +5 -0
  24. package/dist/{cjs/index.development.js → index.cjs} +6113 -5362
  25. package/dist/index.d.ts +4 -3
  26. package/dist/index.js +6089 -5351
  27. package/dist/{designer/component-meta → materials}/component-meta.d.ts +4 -4
  28. package/dist/materials/index.d.ts +2 -0
  29. package/dist/{designer/component-meta/component-meta-manager.d.ts → materials/materials.d.ts} +9 -6
  30. package/dist/plugin/index.d.ts +1 -1
  31. package/dist/plugin/plugin-context.d.ts +10 -10
  32. package/dist/plugin/plugin-extend.d.ts +3 -3
  33. package/dist/plugin/plugin-runtime.d.ts +3 -2
  34. package/dist/plugin/{plugin-manager.d.ts → plugins.d.ts} +4 -2
  35. package/dist/plugin/sequencify.d.ts +3 -3
  36. package/dist/project/project.d.ts +3 -4
  37. package/dist/setters/index.d.ts +1 -0
  38. package/dist/{setter-manager/setter-manager.d.ts → setters/setters.d.ts} +10 -7
  39. package/dist/simulator/simulator-renderer.d.ts +7 -2
  40. package/dist/simulator/simulator.d.ts +15 -14
  41. package/dist/simulator/viewport.d.ts +13 -0
  42. package/dist/types/component.d.ts +28 -0
  43. package/dist/types/data-source.d.ts +27 -0
  44. package/dist/{editor.d.ts → types/editor.d.ts} +35 -54
  45. package/dist/types/index.d.ts +5 -0
  46. package/dist/{designer/component-meta → types}/meta.d.ts +6 -60
  47. package/dist/types/schema.d.ts +5 -0
  48. package/dist/types/setter.d.ts +26 -0
  49. package/dist/utils/event-bus.d.ts +11 -13
  50. package/dist/utils/event.d.ts +39 -0
  51. package/dist/utils/hotkey.d.ts +1 -5
  52. package/dist/utils/index.d.ts +1 -0
  53. package/dist/utils/is.d.ts +16 -0
  54. package/dist/utils/logger.d.ts +37 -17
  55. package/package.json +17 -12
  56. package/dist/cjs/index.development.js.map +0 -1
  57. package/dist/cjs/index.js +0 -11259
  58. package/dist/cjs/index.js.map +0 -1
  59. package/dist/cjs/index.production.js +0 -11259
  60. package/dist/cjs/index.production.js.map +0 -1
  61. package/dist/designer/component-meta/index.d.ts +0 -3
  62. package/dist/esm/index.development.js +0 -11152
  63. package/dist/esm/index.development.js.map +0 -1
  64. package/dist/esm/index.js +0 -11152
  65. package/dist/esm/index.js.map +0 -1
  66. package/dist/esm/index.production.js +0 -11152
  67. package/dist/esm/index.production.js.map +0 -1
  68. package/dist/setter-manager/index.d.ts +0 -1
package/README.md CHANGED
@@ -1,38 +1,36 @@
1
1
  # @easy-editor/core
2
2
 
3
- Core engine package for EasyEditor.
3
+ Core specification and type package for EasyEditor, a cross-framework low-code editor with a scalable architecture.
4
4
 
5
- ## Features
6
-
7
- - **Decoupling Design**:Engine core is framework-independent, supporting multiple framework rendering extensions
8
- - **Visual Design**:Complete implementation of the designer, drag-and-drop layout, snapping alignment, multi-device preview, undo/redo stack...
9
- - **Plugin Architecture**:Flexible plugin system design, lifecycle management, hotkey binding, class extension mechanism, dependency injection...
10
- - **Rendering Engine**:Multi-framework support, real-time preview, Schema driven, component isolation sandbox
11
- - **Enterprise-level Capabilities**:Data source management, multi-language support, version control, online collaboration
5
+ ## Package Structure
12
6
 
13
- ## Usage
7
+ This package provides two main entry points:
14
8
 
15
- ### Dashboard + React
9
+ ### 1. Main Entry Point (`@easy-editor/core`)
16
10
 
17
- 1. Install
11
+ The main entry point provides specifications, interfaces, and types:
12
+ - Core interfaces and abstract classes
13
+ - Type definitions for all components and modules
14
+ - Base structures for plugins, documents, and components
15
+ - Standard events and constants
16
+ - Utility functions and helpers
18
17
 
19
- ```bash
20
- pnpm install @easyeditor/core
21
- ```
18
+ ### 2. Engine Entry Point (`@easy-editor/core/engine`)
22
19
 
23
- 2. Init
20
+ The engine entry point provides the concrete implementation that users should import and use directly:
21
+ - Ready-to-use editor instance
22
+ - Fully configured plugin system
23
+ - Initialized core modules
24
+ - Export of common services (designer, project, etc.)
25
+ - Lifecycle management (init, destroy)
24
26
 
25
- ```ts
26
- import { createEditor } from '@easyeditor/core'
27
-
28
- export const editor = createEasyEditor({
29
- setters,
30
- components,
31
- componentMetas,
32
- })
27
+ ## Features
33
28
 
34
- // get core modules
35
- export const designer = await editor.onceGot<Designer>('designer')
36
- export const project = await editor.onceGot<Project>('project')
37
- export const simulator = await editor.onceGot<Simulator>('simulator')
38
- ```
29
+ - **Framework Agnostic**: Core is designed to work with any frontend framework
30
+ - **Plugin Architecture**: Extensible system for adding features and capabilities
31
+ - **Visual Design**: Complete designer implementation with drag-and-drop, alignment, and undo/redo
32
+ - **Component Model**: Structured component definition and management system
33
+ - **Event System**: Powerful event bus for communication between modules
34
+ - **Configuration System**: Centralized config management with plugin integration
35
+ - **Project Management**: Handles documents, history, serialization, and more
36
+ - **Type Safety**: Comprehensive TypeScript definitions for all components
@@ -0,0 +1,131 @@
1
+ import type { Component, DataSourceEngine } from './types';
2
+ export interface ConfigOptions {
3
+ /**
4
+ * 是否开启 condition 的能力,默认在设计器中不管 condition 是啥都正常展示
5
+ * @default false
6
+ */
7
+ enableCondition?: boolean;
8
+ /**
9
+ * 设计模式,live 模式将会实时展示变量值
10
+ * @default 'design'
11
+ */
12
+ designMode?: 'design' | 'live';
13
+ /**
14
+ * 设备类型
15
+ * @default 'default'
16
+ */
17
+ device?: 'default' | 'mobile' | string;
18
+ /**
19
+ * 指定初始化的 deviceClassName,挂载到画布的顶层节点上
20
+ */
21
+ deviceClassName?: string;
22
+ /**
23
+ * 语言
24
+ * @default 'zh-CN'
25
+ */
26
+ locale?: string;
27
+ /**
28
+ * 渲染器类型
29
+ */
30
+ renderEnv?: 'react' | 'vue' | string;
31
+ /**
32
+ * 关闭画布自动渲染
33
+ * @default false
34
+ */
35
+ disableAutoRender?: boolean;
36
+ /**
37
+ * 容器锁定后,容器本身是否可以设置属性,仅当画布锁定特性开启时生效
38
+ * @default false
39
+ * @todo
40
+ */
41
+ enableLockedNodeSetting?: boolean;
42
+ /**
43
+ * 与 renderer 的 appHelper 一致
44
+ */
45
+ appHelper?: {
46
+ utils?: Record<string, any>;
47
+ constants?: Record<string, any>;
48
+ [key: string]: any;
49
+ };
50
+ /**
51
+ * 数据源引擎
52
+ */
53
+ dataSourceEngine?: DataSourceEngine;
54
+ /**
55
+ * 当开启组件未找到严格模式时,渲染模块不会默认给一个容器组件
56
+ * @default false
57
+ */
58
+ enableStrictNotFoundMode?: boolean;
59
+ /**
60
+ * 是否在设计态中执行生命周期,默认只在运行态执行
61
+ * @default false
62
+ */
63
+ excuteLifeCycleInDesignMode?: boolean;
64
+ /**
65
+ * 当找不到组件时显示的组件
66
+ */
67
+ notFoundComponent?: Component;
68
+ /**
69
+ * 当组件渲染异常时显示的组件
70
+ */
71
+ faultComponent?: Component;
72
+ /**
73
+ * 项目进行初始化加载时显示的组件
74
+ */
75
+ loadingComponent?: Component;
76
+ }
77
+ export declare class Config {
78
+ private config;
79
+ private waits;
80
+ constructor(config?: {
81
+ [key: string]: any;
82
+ });
83
+ /**
84
+ * 判断指定 key 是否有值
85
+ * @param key
86
+ */
87
+ has(key: string): boolean;
88
+ /**
89
+ * 获取指定 key 的值
90
+ * @param key
91
+ * @param defaultValue
92
+ */
93
+ get(key: string, defaultValue?: any): any;
94
+ /**
95
+ * 设置指定 key 的值
96
+ * @param key
97
+ * @param value
98
+ */
99
+ set(key: string, value: any): void;
100
+ /**
101
+ * 批量设值,set 的对象版本
102
+ * @param config
103
+ */
104
+ setConfig(config: {
105
+ [key: string]: any;
106
+ }): void;
107
+ /**
108
+ * if engineOptions.strictPluginMode === true, only accept propertied predefined in EngineOptions.
109
+ *
110
+ * @param {ConfigOptions} engineOptions
111
+ */
112
+ setEngineOptions(engineOptions: ConfigOptions): void;
113
+ /**
114
+ * 获取指定 key 的值,若此时还未赋值,则等待,若已有值,则直接返回值
115
+ * 注:此函数返回 Promise 实例,只会执行(fullfill)一次
116
+ * @param key
117
+ * @returns
118
+ */
119
+ onceGot(key: string): Promise<any>;
120
+ /**
121
+ * 获取指定 key 的值,函数回调模式,若多次被赋值,回调会被多次调用
122
+ * @param key
123
+ * @param fn
124
+ * @returns
125
+ */
126
+ onGot(key: string, fn: (data: any) => void): () => void;
127
+ notifyGot(key: string): void;
128
+ setWait(key: string, resolve: (data: any) => void, once?: boolean): void;
129
+ delWait(key: string, fn: any): void;
130
+ }
131
+ export declare const config: Config;
@@ -0,0 +1,17 @@
1
+ import { type Node } from '../document';
2
+ import type { ComponentInstance } from '../types';
3
+ import type { LocationDetail } from './location';
4
+ export interface ActiveTarget {
5
+ node: Node;
6
+ detail?: LocationDetail;
7
+ instance?: ComponentInstance;
8
+ }
9
+ export declare class ActiveTracker {
10
+ private accessor _target;
11
+ private emitter;
12
+ track(originalTarget: ActiveTarget | Node): void;
13
+ get currentNode(): Node<import("..").NodeSchema>;
14
+ get detail(): LocationDetail | undefined;
15
+ get instance(): any;
16
+ onChange(fn: (target: ActiveTarget) => void): () => void;
17
+ }
@@ -1,14 +1,14 @@
1
- import type { Node, PropsMap } from '../document';
2
- import type { Editor } from '../editor';
3
- import type { ProjectSchema, TRANSFORM_STAGE } from '../types';
4
- import type { ComponentMetaManager } from './component-meta';
5
- import type { DragObject } from './dragon';
6
- import type { LocateEvent, LocationData } from './location';
1
+ import { type Node, type PropsMap } from '../document';
2
+ import type { Materials } from '../materials';
7
3
  import { Project } from '../project';
4
+ import type { ComponentMetadata, Editor, ProjectSchema, TRANSFORM_STAGE } from '../types';
5
+ import { ActiveTracker } from './active-tracker';
8
6
  import { Detecting } from './detecting';
7
+ import type { DragObject } from './dragon';
9
8
  import { Dragon } from './dragon';
10
- import { DropLocation } from './location';
9
+ import { DropLocation, type LocateEvent, type LocationData } from './location';
11
10
  import { type NodeSelector, type OffsetObserver } from './offset-observer';
11
+ import { type Scrollable, Scroller } from './scroller';
12
12
  import { Selection } from './selection';
13
13
  import { SettingsManager } from './setting';
14
14
  import { SettingTopEntry } from './setting/setting-top-entry';
@@ -18,6 +18,11 @@ export type PropsTransducer = (props: PropsMap, node: Node, ctx?: {
18
18
  export interface DesignerProps {
19
19
  editor: Editor;
20
20
  defaultSchema?: ProjectSchema;
21
+ hotkeys?: object;
22
+ simulatorProps?: Record<string, any> | ((project: Project) => object);
23
+ suspended?: boolean;
24
+ componentMetadatas?: ComponentMetadata[];
25
+ onMount?: (designer: Designer) => void;
21
26
  onDragstart?: (e: LocateEvent) => void;
22
27
  onDrag?: (e: LocateEvent) => void;
23
28
  onDragend?: (e: {
@@ -27,14 +32,17 @@ export interface DesignerProps {
27
32
  [key: string]: any;
28
33
  }
29
34
  export declare enum DESIGNER_EVENT {
35
+ MOUNT = "designer:mount",
30
36
  INIT = "designer:init",
31
37
  DRAG_START = "designer:dragstart",
32
38
  DRAG = "designer:drag",
33
39
  DRAG_END = "designer:dragend",
34
- CURRENT_DOCUMENT_CHANGE = "designer:current-document.change",
35
- CURRENT_HISTORY_CHANGE = "designer:current-history.change",
36
40
  DROP_LOCATION_CHANGE = "designer:dropLocation.change",
37
41
  DOCUMENT_DROP_LOCATION_CHANGE = "designer:document.dropLocation.change",
42
+ SETTING_TOP_ENTRY_VALUE_CHANGE = "designer:setting.top-entry.value.change",
43
+ SELECTION_CHANGE = "designer:selection.change",
44
+ CURRENT_DOCUMENT_CHANGE = "designer:current-document.change",
45
+ CURRENT_HISTORY_CHANGE = "designer:current-history.change",
38
46
  INSERT_NODE_BEFORE = "designer:node.insert.before",
39
47
  INSERT_NODE_AFTER = "designer:node.insert.after",
40
48
  NODE_VISIBLE_CHANGE = "designer:node.visible.change",
@@ -43,13 +51,12 @@ export declare enum DESIGNER_EVENT {
43
51
  NODE_PROPS_CHANGE = "designer:node.props.change",
44
52
  NODE_REMOVE = "designer:node.remove",
45
53
  NODE_RENDER = "designer:node.render",
46
- SETTING_TOP_ENTRY_VALUE_CHANGE = "designer:setting.top-entry.value.change",
47
- SELECTION_CHANGE = "designer:selection.change",
48
54
  SIMULATOR_SELECT = "designer:simulator.select",
49
55
  VIEWPORT_MOUNT = "simulator:viewport.mount"
50
56
  }
51
57
  export declare class Designer {
52
58
  private emitter;
59
+ readonly activeTracker: ActiveTracker;
53
60
  readonly editor: Editor;
54
61
  readonly dragon: Dragon;
55
62
  readonly detecting: Detecting;
@@ -57,10 +64,12 @@ export declare class Designer {
57
64
  readonly selection: Selection;
58
65
  readonly settingsManager: SettingsManager;
59
66
  private _dropLocation?;
60
- get componentMetaManager(): ComponentMetaManager;
67
+ get materials(): Materials;
61
68
  private props?;
62
69
  private propsReducers;
63
70
  private oobxList;
71
+ private accessor _simulatorProps;
72
+ private accessor _suspended;
64
73
  get currentDocument(): import("..").Document | undefined;
65
74
  get currentHistory(): import("..").History<import("..").RootSchema> | undefined;
66
75
  constructor(props: DesignerProps);
@@ -68,19 +77,28 @@ export declare class Designer {
68
77
  * 该函数用于 Designer constructor 的插件扩展,因为 Object.defineProperty 无法修改 constructor
69
78
  */
70
79
  init(): void;
71
- setProps(nextProps: DesignerProps): void;
80
+ setProps(nextProps: Partial<DesignerProps>): void;
72
81
  get(key: string): any;
73
82
  postEvent(event: string, ...args: any[]): void;
74
83
  onEvent(event: string, listener: (...args: any[]) => void): () => void;
75
84
  createLocation(locationData: LocationData<Node>): DropLocation;
76
85
  clearLocation(): void;
86
+ createScroller(scrollable: Scrollable): Scroller;
77
87
  createOffsetObserver(nodeInstance: NodeSelector): OffsetObserver | null;
78
88
  private clearOobxList;
79
89
  touchOffsetObserver(): void;
80
90
  onInit(listener: (designer: Designer) => void): void;
81
91
  get schema(): ProjectSchema<import("..").RootSchema>;
92
+ get simulatorProps(): Record<string, any>;
93
+ /**
94
+ * 提供给模拟器的参数
95
+ */
96
+ get projectSimulatorProps(): any;
97
+ get suspended(): boolean;
98
+ set suspended(flag: boolean);
82
99
  setSchema(schema: ProjectSchema): void;
83
100
  transformProps(props: PropsMap, node: Node, stage: TRANSFORM_STAGE): PropsMap;
84
101
  addPropsReducer(reducer: PropsTransducer, stage: TRANSFORM_STAGE): void;
85
102
  createSettingEntry(nodes: Node[]): SettingTopEntry;
103
+ purge(): void;
86
104
  }
@@ -1,14 +1,13 @@
1
1
  import type { Designer } from '.';
2
2
  import type { Node } from '../document';
3
3
  import type { Simulator } from '../simulator';
4
- import type { NodeSchema } from '../types';
5
- import type { ComponentInstance } from './component-meta';
4
+ import type { ComponentInstance, NodeSchema } from '../types';
6
5
  import type { LocateEvent } from './location';
7
6
  import type { Sensor } from './sensor';
8
7
  export declare enum DRAGON_EVENT {
9
- DRAGSTART = "dragstart",
10
- DRAG = "drag",
11
- DRAGEND = "dragend"
8
+ DRAGSTART = "dragon:dragstart",
9
+ DRAG = "dragon:drag",
10
+ DRAGEND = "dragon:dragend"
12
11
  }
13
12
  export declare enum DragObjectType {
14
13
  Node = "node",
@@ -1,5 +1,4 @@
1
1
  export * from './clipboard';
2
- export * from './component-meta';
3
2
  export * from './designer';
4
3
  export * from './detecting';
5
4
  export * from './dragon';
@@ -79,9 +79,6 @@ export interface LocateEvent {
79
79
  }
80
80
  export declare const isLocationData: (obj: any) => obj is LocationData;
81
81
  export declare const isLocationChildrenDetail: (obj: any) => obj is LocationChildrenDetail;
82
- export declare const isText: (elem: any) => elem is Text;
83
- export declare const isElement: (node: any) => node is Element;
84
- export declare const isDocumentElem: (elem: any) => elem is Document;
85
82
  export declare const getWindow: (elem: Element | Document) => Window;
86
83
  export declare class DropLocation {
87
84
  readonly target: INode;
@@ -0,0 +1,34 @@
1
+ export interface Scrollable {
2
+ scrollTarget?: ScrollTarget | Element;
3
+ bounds?: DOMRect | null;
4
+ scale?: number;
5
+ }
6
+ export declare class ScrollTarget {
7
+ private target;
8
+ get left(): number;
9
+ get top(): number;
10
+ private doc?;
11
+ constructor(target: Window | Element);
12
+ scrollTo(options: {
13
+ left?: number;
14
+ top?: number;
15
+ }): void;
16
+ scrollToXY(x: number, y: number): void;
17
+ get scrollHeight(): number;
18
+ get scrollWidth(): number;
19
+ }
20
+ export declare class Scroller {
21
+ private pid;
22
+ scrollable: Scrollable;
23
+ constructor(scrollable: Scrollable);
24
+ get scrollTarget(): ScrollTarget | null;
25
+ scrollTo(options: {
26
+ left?: number;
27
+ top?: number;
28
+ }): void;
29
+ scrolling(point: {
30
+ globalX: number;
31
+ globalY: number;
32
+ }): void;
33
+ cancel(): void;
34
+ }
@@ -1,4 +1,4 @@
1
- import type { Node } from '../document';
1
+ import { type Node } from '../document';
2
2
  import type { Designer } from './designer';
3
3
  export declare enum SELECTION_EVENT {
4
4
  CHANGE = "selection:change"
@@ -1,5 +1,5 @@
1
1
  import type { Node } from '../document';
2
- import type { ComponentInstance } from './component-meta';
2
+ import type { ComponentInstance } from '../types';
3
3
  import type { NodeInstance } from './dragon';
4
4
  import type { DropLocation, LocateEvent } from './location';
5
5
  export interface Sensor<T = Node> {
@@ -1,4 +1,4 @@
1
- import type { Editor, Node, SetterManager } from '../..';
1
+ import type { Editor, Node, Setters } from '../..';
2
2
  import type { Designer } from '../designer';
3
3
  import type { SettingField } from './setting-field';
4
4
  export interface SettingEntry {
@@ -20,7 +20,7 @@ export interface SettingEntry {
20
20
  * 编辑器引用
21
21
  */
22
22
  readonly editor: Editor;
23
- readonly setters: SetterManager;
23
+ readonly setters: Setters;
24
24
  /**
25
25
  * 取得子项
26
26
  */
@@ -1,6 +1,6 @@
1
- import type { DynamicSetter, FieldConfig, FieldExtraProps, SetterType } from '../component-meta';
2
- import type { SettingTopEntry } from './setting-top-entry';
1
+ import type { DynamicSetter, FieldConfig, FieldExtraProps, SetterType } from '../../types';
3
2
  import { SettingPropEntry } from './setting-prop-entry';
3
+ import type { SettingTopEntry } from './setting-top-entry';
4
4
  export interface SetValueOptions {
5
5
  disableMutator?: boolean;
6
6
  type?: PropValueChangedType;
@@ -1,11 +1,11 @@
1
- import type { SettingTopEntry } from './setting-top-entry';
2
1
  import { type Editor } from '../..';
2
+ import type { SettingTopEntry } from './setting-top-entry';
3
3
  export declare class SettingsManager {
4
4
  readonly editor: Editor;
5
5
  private _sessionId;
6
6
  private accessor _settings;
7
7
  get length(): number | undefined;
8
- get componentMeta(): import("..").ComponentMeta | null | undefined;
8
+ get componentMeta(): import("../..").ComponentMeta | null | undefined;
9
9
  get settings(): SettingTopEntry | undefined;
10
10
  private disposeListener;
11
11
  private designer?;
@@ -1,6 +1,6 @@
1
- import type { ComponentMeta, Designer, FieldExtraProps, Node, PropKey } from '../..';
2
- import type { Editor } from '../../editor';
3
- import type { SetterManager } from '../../setter-manager';
1
+ import { type ComponentMeta, type Designer, type FieldExtraProps, type Node, type PropKey } from '../..';
2
+ import type { Setters } from '../../setters';
3
+ import type { Editor } from '../../types';
4
4
  import type { SettingEntry } from './setting-entry';
5
5
  import type { SetValueOptions, SettingField } from './setting-field';
6
6
  import type { SettingTopEntry } from './setting-top-entry';
@@ -10,7 +10,7 @@ export declare class SettingPropEntry implements SettingEntry {
10
10
  readonly isSameComponent: boolean;
11
11
  readonly isMultiple: boolean;
12
12
  readonly isSingle: boolean;
13
- readonly setters: SetterManager;
13
+ readonly setters: Setters;
14
14
  readonly nodes: Node[];
15
15
  readonly componentMeta: ComponentMeta | null;
16
16
  readonly designer: Designer | undefined;
@@ -1,4 +1,4 @@
1
- import type { ComponentMeta, Designer, Editor, Node, PropKey, SetterManager } from '../..';
1
+ import { type ComponentMeta, type Designer, type Editor, type Node, type PropKey, type Setters } from '../..';
2
2
  import type { SettingEntry } from './setting-entry';
3
3
  import { SettingField } from './setting-field';
4
4
  export declare const generateSessionId: (nodes: Node[]) => string;
@@ -31,7 +31,7 @@ export declare class SettingTopEntry implements SettingEntry {
31
31
  readonly id: string;
32
32
  readonly first: Node;
33
33
  readonly designer: Designer | undefined;
34
- readonly setters: SetterManager;
34
+ readonly setters: Setters;
35
35
  disposeFunctions: any[];
36
36
  constructor(editor: Editor, nodes: Node[]);
37
37
  private setupComponentMeta;
@@ -1,8 +1,7 @@
1
- import type { ComponentsMap, Designer, DropLocation } from '../designer';
1
+ import { type Designer, type DropLocation } from '../designer';
2
2
  import type { Project } from '../project';
3
3
  import type { Simulator } from '../simulator';
4
- import type { NodeSchema, RootSchema } from '../types';
5
- import { TRANSFORM_STAGE } from '../types';
4
+ import { type ComponentsMap, type NodeSchema, type RootSchema, TRANSFORM_STAGE } from '../types';
6
5
  import { History } from './history';
7
6
  import { Node } from './node/node';
8
7
  export declare enum DOCUMENT_EVENT {
@@ -87,7 +86,6 @@ export declare class Document {
87
86
  * @param extraComps - extra components that will be added to the components map, use for custom components
88
87
  */
89
88
  getComponentsMap(extraComps?: string[]): ComponentsMap;
90
- getComponent(componentName: string): any;
91
89
  getComponentMeta(componentName: string): import("..").ComponentMeta;
92
90
  toData(extraComps?: string[]): {
93
91
  componentsMap: ComponentsMap;
@@ -1,6 +1,5 @@
1
- import type { NodeSchema } from '../../types';
2
- import type { Node } from './node';
3
- import { TRANSFORM_STAGE } from '../../types';
1
+ import { type NodeSchema, TRANSFORM_STAGE } from '../../types';
2
+ import { type Node } from './node';
4
3
  export declare enum NODE_CHILDREN_EVENT {
5
4
  CHANGE = "nodeChildren:change",
6
5
  INSERT = "nodeChildren:insert"
@@ -1,8 +1,7 @@
1
- import type { NodeSchema } from '../../types';
1
+ import { type SettingTopEntry } from '../..';
2
+ import { type NodeSchema, TRANSFORM_STAGE } from '../../types';
2
3
  import type { Document } from '../document';
3
4
  import type { PropValue, PropsMap } from '../prop/prop';
4
- import { type SettingTopEntry } from '../..';
5
- import { TRANSFORM_STAGE } from '../../types';
6
5
  import { Props } from '../prop/props';
7
6
  import { NodeChildren } from './node-children';
8
7
  export declare enum NODE_EVENT {
@@ -1,7 +1,6 @@
1
- import type { NodeSchema } from '../../types';
1
+ import { type NodeSchema, TRANSFORM_STAGE } from '../../types';
2
2
  import type { Node } from '../node/node';
3
- import type { Props } from './props';
4
- import { TRANSFORM_STAGE } from '../../types';
3
+ import { type Props } from './props';
5
4
  export declare const UNSET: unique symbol;
6
5
  export type UNSET = typeof UNSET;
7
6
  export type ValueTypes = 'unset' | 'literal' | 'list' | 'map' | 'expression';
@@ -1,7 +1,6 @@
1
- import type { Node } from '../node/node';
2
- import type { PropKey, PropValue, PropsMap } from './prop';
3
1
  import { TRANSFORM_STAGE } from '../../types';
4
- import { Prop, UNSET } from './prop';
2
+ import type { Node } from '../node/node';
3
+ import { Prop, type PropKey, type PropValue, type PropsMap, UNSET } from './prop';
5
4
  /**
6
5
  * prop key convert to extra key
7
6
  */
@@ -0,0 +1,45 @@
1
+ import EventEmitter from 'events';
2
+ import { type EditorConfig, type EditorGetResult, type EditorValueKey, EventBus, type HookConfig, type Editor as IEditor, type Plugins } from '..';
3
+ export declare class Editor extends EventEmitter implements IEditor {
4
+ private accessor context;
5
+ config?: EditorConfig;
6
+ eventBus: EventBus;
7
+ components?: IEditor['components'];
8
+ private hooks;
9
+ private waits;
10
+ constructor(config?: EditorConfig);
11
+ get<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType): EditorGetResult<T, KeyOrType> | undefined;
12
+ has(keyOrType: EditorValueKey): boolean;
13
+ set(key: EditorValueKey, data: any): void | Promise<void>;
14
+ /**
15
+ * get value until value is set
16
+ */
17
+ onceGot<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType): Promise<EditorGetResult<T, KeyOrType>>;
18
+ /**
19
+ * listen value when value is set
20
+ */
21
+ onGot<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType, fn: (data: EditorGetResult<T, KeyOrType>) => void): () => void;
22
+ /**
23
+ * listen value when value is changed
24
+ */
25
+ onChange<T = undefined, KeyOrType extends EditorValueKey = any>(keyOrType: KeyOrType, fn: (data: EditorGetResult<T, KeyOrType>) => void): () => void;
26
+ register(data: any, key?: EditorValueKey): void;
27
+ init(config?: EditorConfig, components?: Editor['components']): Promise<any>;
28
+ destroy(): void;
29
+ extend(pluginManager: Plugins): Promise<void>;
30
+ initHooks: (hooks: HookConfig[]) => HookConfig[];
31
+ registerHooks: (hooks: HookConfig[]) => void;
32
+ unregisterHooks: () => void;
33
+ /**
34
+ * notify all listeners when value is got
35
+ */
36
+ private notifyGot;
37
+ private setWait;
38
+ private delWait;
39
+ onBeforeInit(listener: (editor: Editor) => void): () => void;
40
+ onAfterInit(listener: (editor: Editor) => void): () => void;
41
+ onDestroy(listener: (editor: Editor) => void): () => void;
42
+ onBeforeExtend(listener: (editor: Editor) => void): () => void;
43
+ onAfterExtend(listener: (editor: Editor) => void): () => void;
44
+ }
45
+ export declare const createEasyEditor: (config?: EditorConfig) => Editor;
@@ -0,0 +1,11 @@
1
+ import { type ConfigOptions, Event, Hotkey, Materials, Plugins, Setters } from '..';
2
+ declare const project: import("..").Project;
3
+ declare const hotkey: Hotkey;
4
+ declare const setters: Setters;
5
+ declare const materials: Materials;
6
+ declare const event: Event;
7
+ declare const logger: import("..").Logger;
8
+ declare let plugins: Plugins;
9
+ export declare const init: (options?: ConfigOptions) => Promise<void>;
10
+ export declare const destroy: () => Promise<void>;
11
+ export { event, hotkey, logger, materials, plugins, project, setters };
@@ -0,0 +1,5 @@
1
+ /**
2
+ * TODO: 从 core 中抽离出来
3
+ */
4
+ export * from './engine';
5
+ export declare const version = "_EASY_EDITOR_VERSION_";