@easy-editor/core 0.0.1

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 (71) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/LICENSE +9 -0
  3. package/README.md +3 -0
  4. package/dist/cjs/index.development.js +11252 -0
  5. package/dist/cjs/index.development.js.map +1 -0
  6. package/dist/cjs/index.js +11252 -0
  7. package/dist/cjs/index.js.map +1 -0
  8. package/dist/cjs/index.production.js +11252 -0
  9. package/dist/cjs/index.production.js.map +1 -0
  10. package/dist/designer/clipboard.d.ts +12 -0
  11. package/dist/designer/component-meta/component-meta-manager.d.ts +21 -0
  12. package/dist/designer/component-meta/component-meta.d.ts +30 -0
  13. package/dist/designer/component-meta/index.d.ts +3 -0
  14. package/dist/designer/component-meta/meta.d.ts +264 -0
  15. package/dist/designer/designer.d.ts +86 -0
  16. package/dist/designer/detecting.d.ts +23 -0
  17. package/dist/designer/dragon.d.ts +103 -0
  18. package/dist/designer/index.d.ts +10 -0
  19. package/dist/designer/location.d.ts +94 -0
  20. package/dist/designer/offset-observer.d.ts +41 -0
  21. package/dist/designer/selection.d.ts +27 -0
  22. package/dist/designer/sensor.d.ts +30 -0
  23. package/dist/designer/setting/index.d.ts +5 -0
  24. package/dist/designer/setting/setting-entry.d.ts +42 -0
  25. package/dist/designer/setting/setting-field.d.ts +49 -0
  26. package/dist/designer/setting/setting-manager.d.ts +16 -0
  27. package/dist/designer/setting/setting-prop-entry.d.ts +89 -0
  28. package/dist/designer/setting/setting-top-entry.d.ts +83 -0
  29. package/dist/document/document.d.ts +89 -0
  30. package/dist/document/history.d.ts +76 -0
  31. package/dist/document/index.d.ts +6 -0
  32. package/dist/document/node/node-children.d.ts +51 -0
  33. package/dist/document/node/node.d.ts +233 -0
  34. package/dist/document/prop/prop.d.ts +185 -0
  35. package/dist/document/prop/props.d.ts +57 -0
  36. package/dist/document/prop/value-to-source.d.ts +8 -0
  37. package/dist/editor.d.ts +94 -0
  38. package/dist/esm/index.development.js +11145 -0
  39. package/dist/esm/index.development.js.map +1 -0
  40. package/dist/esm/index.js +11145 -0
  41. package/dist/esm/index.js.map +1 -0
  42. package/dist/esm/index.production.js +11145 -0
  43. package/dist/esm/index.production.js.map +1 -0
  44. package/dist/index.d.ts +10 -0
  45. package/dist/index.js +11144 -0
  46. package/dist/plugin/index.d.ts +3 -0
  47. package/dist/plugin/plugin-context.d.ts +20 -0
  48. package/dist/plugin/plugin-extend.d.ts +32 -0
  49. package/dist/plugin/plugin-manager.d.ts +78 -0
  50. package/dist/plugin/plugin-runtime.d.ts +28 -0
  51. package/dist/plugin/sequencify.d.ts +19 -0
  52. package/dist/project/index.d.ts +1 -0
  53. package/dist/project/project.d.ts +68 -0
  54. package/dist/setter-manager/index.d.ts +1 -0
  55. package/dist/setter-manager/setter-manager.d.ts +29 -0
  56. package/dist/simulator/index.d.ts +3 -0
  57. package/dist/simulator/simulator-renderer.d.ts +41 -0
  58. package/dist/simulator/simulator.d.ts +106 -0
  59. package/dist/simulator/viewport.d.ts +29 -0
  60. package/dist/types/common.d.ts +11 -0
  61. package/dist/types/event.d.ts +12 -0
  62. package/dist/types/index.d.ts +3 -0
  63. package/dist/types/schema.d.ts +64 -0
  64. package/dist/utils/common.d.ts +1 -0
  65. package/dist/utils/event-bus.d.ts +45 -0
  66. package/dist/utils/hotkey.d.ts +87 -0
  67. package/dist/utils/index.d.ts +6 -0
  68. package/dist/utils/is.d.ts +2 -0
  69. package/dist/utils/logger.d.ts +18 -0
  70. package/dist/utils/unique-id.d.ts +5 -0
  71. package/package.json +67 -0
@@ -0,0 +1,3 @@
1
+ export * from './plugin-context';
2
+ export * from './plugin-manager';
3
+ export * from './plugin-runtime';
@@ -0,0 +1,20 @@
1
+ import type { ComponentMetaManager, Designer, Editor, Project, SetterManager, Simulator } from '..';
2
+ import type { EventBus, Hotkey, Logger } from '../utils';
3
+ import type { PluginContextApiAssembler, PluginMeta } from './plugin-manager';
4
+ export interface PluginContextOptions {
5
+ pluginName: string;
6
+ meta?: PluginMeta;
7
+ }
8
+ export declare class PluginContext {
9
+ editor: Editor;
10
+ simulator: Simulator;
11
+ designer: Designer;
12
+ project: Project;
13
+ setterManager: SetterManager;
14
+ componentMetaManager: ComponentMetaManager;
15
+ logger: Logger;
16
+ event: EventBus;
17
+ pluginEvent: EventBus;
18
+ hotkey: Hotkey;
19
+ constructor(options: PluginContextOptions, contextApiAssembler: PluginContextApiAssembler);
20
+ }
@@ -0,0 +1,32 @@
1
+ import type { ComponentMeta, ComponentMetaManager, Designer, Detecting, Document, Dragon, DropLocation, History, Node, NodeChildren, OffsetObserver, Project, Prop, Props, Selection, SetterManager, Simulator, Viewport } from '..';
2
+ export interface PluginExtend {
3
+ extendClass: PluginExtendClass;
4
+ extend: <T extends keyof PluginExtendClass>(extendClass: T, properties: Record<PropertyKey, () => any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>)) => void;
5
+ }
6
+ export interface PluginExtendClass {
7
+ Simulator: typeof Simulator;
8
+ Viewport: typeof Viewport;
9
+ Designer: typeof Designer;
10
+ Dragon: typeof Dragon;
11
+ Detecting: typeof Detecting;
12
+ Selection: typeof Selection;
13
+ DropLocation: typeof DropLocation;
14
+ OffsetObserver: typeof OffsetObserver;
15
+ Project: typeof Project;
16
+ Document: typeof Document;
17
+ History: typeof History;
18
+ Node: typeof Node;
19
+ NodeChildren: typeof NodeChildren;
20
+ Props: typeof Props;
21
+ Prop: typeof Prop;
22
+ ComponentMetaManager: typeof ComponentMetaManager;
23
+ SetterManager: typeof SetterManager;
24
+ ComponentMeta: typeof ComponentMeta;
25
+ }
26
+ /**
27
+ * 扩展类
28
+ * @param extendMap 扩展类映射
29
+ * @param extendClass 扩展类
30
+ * @param properties 扩展属性
31
+ */
32
+ export declare const extend: <T extends keyof PluginExtendClass>(extendMap: Record<T, PluginExtendClass[T]>, extendClass: T, properties: Record<PropertyKey, () => any> | (PropertyDescriptorMap & ThisType<InstanceType<PluginExtendClass[T]>>)) => void;
@@ -0,0 +1,78 @@
1
+ import type { PluginContextOptions } from './plugin-context';
2
+ import { type PluginExtend } from './plugin-extend';
3
+ import { PluginContext } from './plugin-context';
4
+ import { PluginRuntime } from './plugin-runtime';
5
+ export interface Plugin {
6
+ name: string;
7
+ deps?: string[];
8
+ eventPrefix?: string;
9
+ init(ctx: PluginContext): Promise<void> | void;
10
+ destroy?(ctx: PluginContext): Promise<void> | void;
11
+ extend?(ctx: PluginExtend): void;
12
+ }
13
+ export interface PluginMeta {
14
+ /**
15
+ * define dependencies which the plugin depends on
16
+ */
17
+ dependencies?: string[];
18
+ /**
19
+ * use 'common' as event prefix when eventPrefix is not set.
20
+ */
21
+ eventPrefix?: string;
22
+ }
23
+ export type PluginCreator<O = any> = (options?: O) => Plugin;
24
+ export interface PluginRegisterOptions {
25
+ /**
26
+ * Will enable plugin registered with auto-initialization immediately
27
+ * other than plugin-manager init all plugins at certain time.
28
+ * It is helpful when plugin register is later than plugin-manager initialization.
29
+ */
30
+ autoInit?: boolean;
31
+ /**
32
+ * allow overriding existing plugin with same name when override === true
33
+ */
34
+ override?: boolean;
35
+ }
36
+ /**
37
+ * Assemble APIs for plugins to create context
38
+ */
39
+ export interface PluginContextApiAssembler {
40
+ assembleApis(context: PluginContext, pluginName: string, meta: PluginMeta): void;
41
+ }
42
+ export declare class PluginManager {
43
+ private plugins;
44
+ pluginsMap: Map<string, PluginRuntime>;
45
+ pluginContextMap: Map<string, PluginContext>;
46
+ private contextApiAssembler;
47
+ constructor(contextApiAssembler?: PluginContextApiAssembler);
48
+ setContextApiAssembler(contextApiAssembler: PluginContextApiAssembler): void;
49
+ getPluginContext: (options: PluginContextOptions) => PluginContext;
50
+ /**
51
+ * register a plugin
52
+ * @param pluginConfigCreator - a creator function which returns the plugin config
53
+ * @param options - the plugin options
54
+ * @param registerOptions - the plugin register options
55
+ */
56
+ register(pluginModel: Plugin, registerOptions?: PluginRegisterOptions): Promise<void>;
57
+ /**
58
+ * batch register plugins
59
+ */
60
+ registerPlugins(plugins: Plugin[], registerOptions?: PluginRegisterOptions): Promise<void>;
61
+ get(pluginName: string): PluginRuntime | undefined;
62
+ getAll(): PluginRuntime[];
63
+ has(pluginName: string): boolean;
64
+ delete(pluginName: string): Promise<boolean>;
65
+ init(): Promise<void>;
66
+ /**
67
+ * destroy all plugins
68
+ */
69
+ destroy(): Promise<void>;
70
+ extend(): Promise<void>;
71
+ get size(): number;
72
+ setDisabled(pluginName: string, flag?: boolean): void;
73
+ /**
74
+ * reset plugin manager
75
+ */
76
+ dispose(): Promise<void>;
77
+ }
78
+ export declare const isRegisterOptions: (opts: any) => opts is PluginRegisterOptions;
@@ -0,0 +1,28 @@
1
+ import { type Logger } from '../utils';
2
+ import type { PluginExtend } from './plugin-extend';
3
+ import type { Plugin, PluginManager, PluginMeta } from './plugin-manager';
4
+ export declare class PluginRuntime {
5
+ config: Plugin;
6
+ logger: Logger;
7
+ private manager;
8
+ private _inited;
9
+ private _extended;
10
+ private pluginName;
11
+ meta: PluginMeta;
12
+ /**
13
+ * indicates whether the plugin is disabled
14
+ */
15
+ private _disabled;
16
+ get ctx(): import("./plugin-context").PluginContext;
17
+ constructor(pluginName: string, manager: PluginManager, config: Plugin);
18
+ get name(): string;
19
+ get deps(): string[];
20
+ get disabled(): boolean;
21
+ isInited(): boolean;
22
+ isExtended(): boolean;
23
+ init(forceInit?: boolean): Promise<void>;
24
+ destroy(): Promise<void>;
25
+ extend(pluginExtend: PluginExtend): Promise<void>;
26
+ setDisabled(flag?: boolean): void;
27
+ dispose(): Promise<void>;
28
+ }
@@ -0,0 +1,19 @@
1
+ type Tasks = Record<string, {
2
+ name: string;
3
+ deps: string[];
4
+ }>;
5
+ export declare function sequence({ tasks, names, results, missing, recursive, nest, parentName, }: {
6
+ tasks: Tasks;
7
+ names: string[];
8
+ results: string[];
9
+ missing: string[];
10
+ recursive: string[][];
11
+ nest: string[];
12
+ parentName: string;
13
+ }): void;
14
+ export default function (tasks: Tasks, names: string[]): {
15
+ sequence: string[];
16
+ missingTasks: string[];
17
+ recursiveDependencies: string[][];
18
+ };
19
+ export {};
@@ -0,0 +1 @@
1
+ export * from './project';
@@ -0,0 +1,68 @@
1
+ import type { Designer } from '../designer';
2
+ import type { Simulator } from '../simulator';
3
+ import type { ProjectSchema, RootSchema } from '../types';
4
+ import { Document } from '../document';
5
+ import { TRANSFORM_STAGE } from '../types';
6
+ export declare enum PROJECT_EVENT {
7
+ RENDERER_READY = "renderer:ready",
8
+ SIMULATOR_READY = "simulator:ready"
9
+ }
10
+ export declare class Project {
11
+ readonly designer: Designer;
12
+ private emitter;
13
+ private data;
14
+ accessor documents: Document[];
15
+ private documentsMap;
16
+ get currentDocument(): Document | undefined;
17
+ private accessor _config;
18
+ get config(): Record<string, any> | undefined;
19
+ set config(value: Record<string, any>);
20
+ private _simulator?;
21
+ get simulator(): Simulator | null;
22
+ constructor(designer: Designer, schema?: ProjectSchema);
23
+ import(schema: ProjectSchema): void;
24
+ export(stage?: TRANSFORM_STAGE): ProjectSchema;
25
+ private getComponentsMap;
26
+ /**
27
+ * load project schema
28
+ * @param schema project schema
29
+ * @param autoOpen auto open document, if type is string, will open document by id, if type is boolean, will open first document
30
+ */
31
+ load(schema?: ProjectSchema, autoOpen?: boolean | string): void;
32
+ unload(): void;
33
+ createDocument(schema?: RootSchema): Document;
34
+ removeDocument(idOrDoc: string | Document): void;
35
+ getDocument(id: string): Document | undefined;
36
+ /**
37
+ * open or create a document
38
+ */
39
+ open(idOrDoc?: string | Document | RootSchema): Document | null;
40
+ /**
41
+ * suspense other documents
42
+ * @param curDoc current active document
43
+ */
44
+ checkExclusive(curDoc: Document): void;
45
+ closeOthers(opened: Document): void;
46
+ /**
47
+ * set extra data, available for plugins
48
+ */
49
+ set<T extends keyof ProjectSchema>(key: T, value: ProjectSchema[T]): void;
50
+ set(key: string, value: unknown): void;
51
+ /**
52
+ * get extra data, available for plugins
53
+ */
54
+ get<T extends keyof ProjectSchema>(key: T): ProjectSchema[T];
55
+ get<T>(key: string): T;
56
+ get(key: string): unknown;
57
+ private isRendererReady;
58
+ setRendererReady(renderer: any): void;
59
+ mountSimulator(simulator: Simulator): void;
60
+ onSimulatorReady(listener: (simulator: Simulator) => void): () => void;
61
+ /**
62
+ * use to wait for renderer ready and then do initial work
63
+ */
64
+ onRendererReady(listener: () => void): () => void;
65
+ onDocumentAdd(listener: (document: Document) => void): () => void;
66
+ onDocumentRemove(listener: (id: string) => void): () => void;
67
+ onCurrentDocumentChange(listener: (document: Document) => void): () => void;
68
+ }
@@ -0,0 +1 @@
1
+ export * from './setter-manager';
@@ -0,0 +1,29 @@
1
+ import type { Component } from '../designer';
2
+ /**
3
+ * for setter component props
4
+ */
5
+ export interface SetterProps<T = unknown> {
6
+ value: T;
7
+ onChange: (val: T) => void;
8
+ }
9
+ export interface Setter {
10
+ component: Component;
11
+ defaultProps?: object;
12
+ name?: string;
13
+ }
14
+ interface RegisterSetterOption {
15
+ overwrite?: boolean;
16
+ }
17
+ export declare class SetterManager {
18
+ private _settersMap;
19
+ get settersMap(): Map<string, Setter & {
20
+ type: string;
21
+ }>;
22
+ getSetter(type: string): (Setter & {
23
+ type: string;
24
+ }) | undefined;
25
+ buildSettersMap: (setters: Record<string, Setter>) => void;
26
+ registerSetter(type: string, setter: Component | Setter, option?: RegisterSetterOption): void;
27
+ createSetterContent: (setter: any, props: Record<string, any>) => Component;
28
+ }
29
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './simulator';
2
+ export * from './simulator-renderer';
3
+ export * from './viewport';
@@ -0,0 +1,41 @@
1
+ import type { Node } from '..';
2
+ import type { Component, ComponentInstance, NodeInstance } from '../designer';
3
+ export interface SimulatorRenderer {
4
+ readonly isSimulatorRenderer: true;
5
+ /**
6
+ * 是否自动重绘节点
7
+ */
8
+ autoRepaintNode?: boolean;
9
+ /**
10
+ * 组件列表
11
+ */
12
+ components: Record<string, Component>;
13
+ /**
14
+ * 重新渲染
15
+ */
16
+ rerender: () => void;
17
+ /**
18
+ * 获取组件
19
+ */
20
+ getComponent(componentName: string): Component;
21
+ /**
22
+ * 获取最近的节点实例
23
+ */
24
+ getClosestNodeInstance(from: ComponentInstance, nodeId?: string): NodeInstance<ComponentInstance, Node> | null;
25
+ /**
26
+ * 获取元素的 Rect 信息
27
+ */
28
+ getClientRects(element: Element | Text): DOMRect[];
29
+ /**
30
+ * 关闭自动重绘节点
31
+ */
32
+ stopAutoRepaintNode(): void;
33
+ /**
34
+ * 开启自动重绘节点
35
+ */
36
+ enableAutoRepaintNode(): void;
37
+ /**
38
+ * 渲染器启动
39
+ */
40
+ run(): void;
41
+ }
@@ -0,0 +1,106 @@
1
+ import type { IReactionDisposer, IReactionOptions, IReactionPublic } from 'mobx';
2
+ import type { Component, ComponentInstance, Designer, LocateEvent, NodeInstance, Snippet } from '../designer';
3
+ import type { Node } from '../document';
4
+ import type { Project } from '../project';
5
+ import type { SimulatorRenderer } from './simulator-renderer';
6
+ import { Viewport } from './viewport';
7
+ export interface DropContainer {
8
+ container: Node;
9
+ instance: ComponentInstance;
10
+ }
11
+ export type DesignMode = 'design' | 'preview' | 'live';
12
+ export type Device = 'mobile' | 'iphone' | 'pc' | string;
13
+ export interface SimulatorProps {
14
+ designMode?: DesignMode;
15
+ device?: Device;
16
+ deviceClassName?: string;
17
+ requestHandlersMap?: any;
18
+ [key: string]: any;
19
+ }
20
+ export interface DeviceStyleProps {
21
+ canvas?: object;
22
+ viewport?: object;
23
+ content?: object;
24
+ }
25
+ export declare class Simulator {
26
+ readonly emitter: import("..").EventBus;
27
+ isSimulator: boolean;
28
+ readonly project: Project;
29
+ readonly designer: Designer;
30
+ readonly viewport: Viewport;
31
+ iframe?: HTMLElement;
32
+ autoRender: boolean;
33
+ get editor(): import("..").Editor;
34
+ get device(): string;
35
+ get requestHandlersMap(): any;
36
+ get thisRequiredInJSE(): boolean;
37
+ get enableStrictNotFoundMode(): any;
38
+ get notFoundComponent(): any;
39
+ get faultComponent(): any;
40
+ get designMode(): DesignMode;
41
+ get deviceStyle(): DeviceStyleProps | undefined;
42
+ get componentsMap(): {
43
+ [key: string]: any;
44
+ };
45
+ accessor _props: SimulatorProps;
46
+ private accessor _contentWindow;
47
+ get contentWindow(): Window | undefined;
48
+ private accessor _contentDocument;
49
+ get contentDocument(): Document | undefined;
50
+ private accessor _components;
51
+ /**
52
+ * material to component map
53
+ */
54
+ get components(): Record<string, any>;
55
+ private accessor instancesMap;
56
+ private _sensorAvailable;
57
+ get sensorAvailable(): boolean;
58
+ private _renderer?;
59
+ get renderer(): SimulatorRenderer | undefined;
60
+ private sensing;
61
+ get currentDocument(): import("..").Document | undefined;
62
+ constructor(designer: Designer);
63
+ setProps(props: SimulatorProps): void;
64
+ set(key: string, value: any): void;
65
+ get(key: string): any;
66
+ connect(renderer: SimulatorRenderer, effect: (reaction: IReactionPublic) => void, options?: IReactionOptions<unknown, boolean>): IReactionDisposer;
67
+ reaction(expression: (reaction: IReactionPublic) => unknown, effect: (value: unknown, prev: unknown, reaction: IReactionPublic) => void, opts?: IReactionOptions<unknown, boolean>): IReactionDisposer;
68
+ autorun(effect: (reaction: IReactionPublic) => void, options?: IReactionOptions<unknown, boolean>): IReactionDisposer;
69
+ purge(): void;
70
+ /**
71
+ * force to rerender the viewport
72
+ */
73
+ rerender(): void;
74
+ mountContentFrame(iframe: HTMLIFrameElement | HTMLElement | null): void;
75
+ getComponent(componentName: string): any;
76
+ postEvent(eventName: string, ...data: any[]): void;
77
+ linkSnippet(ref: HTMLElement, snippet: Snippet): () => void;
78
+ setupEvents(): void;
79
+ setupDragAndClick(): void;
80
+ setupDetecting(): void;
81
+ buildComponentMap(components: Record<string, Component>): void;
82
+ addComponent(name: string, component: Component, override?: boolean): void;
83
+ setInstance(docId: string, id: string, instances: ComponentInstance[] | null): void;
84
+ getInstance(docId: string, id: string): any;
85
+ getComponentInstances(node: Node, context?: NodeInstance<ComponentInstance, Node>): ComponentInstance | null;
86
+ getClosestNodeInstance(from: ComponentInstance, specId?: string): NodeInstance<ComponentInstance> | null;
87
+ computeRect(node: Node): DOMRect | null | undefined;
88
+ computeComponentInstanceRect(instance: ComponentInstance, selector?: string): DOMRect | undefined;
89
+ getNodeInstanceFromElement(target: Element | null): NodeInstance<ComponentInstance, Node> | null;
90
+ /**
91
+ * fix event's prop, canvasX、canvasY and target
92
+ */
93
+ fixEvent(e: LocateEvent): LocateEvent;
94
+ /**
95
+ * check the rect whether is in the viewport
96
+ */
97
+ isEnter(e: LocateEvent): boolean;
98
+ deactiveSensor(): void;
99
+ locate(e: LocateEvent): any;
100
+ /**
101
+ * find the suitable drop container
102
+ */
103
+ getDropContainer(e: LocateEvent): DropContainer | null;
104
+ handleAccept({ container }: DropContainer, e: LocateEvent): boolean;
105
+ }
106
+ export declare const isSimulator: (obj: any) => obj is Simulator;
@@ -0,0 +1,29 @@
1
+ import { type Designer, type Point } from '../designer';
2
+ export type AutoFit = '100%';
3
+ export declare const AutoFit: AutoFit;
4
+ export declare class Viewport {
5
+ readonly designer: Designer;
6
+ private accessor rect;
7
+ private _bounds?;
8
+ get bounds(): DOMRect;
9
+ get contentBounds(): DOMRect;
10
+ private viewportElement?;
11
+ constructor(designer: Designer);
12
+ mount(viewportElement: HTMLElement | null): void;
13
+ touch(): void;
14
+ get height(): number;
15
+ set height(newHeight: number);
16
+ get width(): number;
17
+ set width(newWidth: number);
18
+ private accessor _scale;
19
+ get scale(): number;
20
+ set scale(newScale: number);
21
+ private accessor _contentWidth;
22
+ private accessor _contentHeight;
23
+ get contentHeight(): number | AutoFit;
24
+ set contentHeight(newContentHeight: number | AutoFit);
25
+ get contentWidth(): number | AutoFit;
26
+ set contentWidth(val: number | AutoFit);
27
+ toGlobalPoint(point: Point): Point;
28
+ toLocalPoint(point: Point): Point;
29
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * transform stage, use for export
3
+ */
4
+ export declare enum TRANSFORM_STAGE {
5
+ RENDER = "render",
6
+ SERIALIZE = "serialize",
7
+ SAVE = "save",
8
+ CLONE = "clone",
9
+ INIT = "init",
10
+ UPGRADE = "upgrade"
11
+ }
@@ -0,0 +1,12 @@
1
+ import { DESIGNER_EVENT, DETECTING_EVENT, DOCUMENT_EVENT, DRAGON_EVENT, EDITOR_EVENT, NODE_CHILDREN_EVENT, NODE_EVENT, PROJECT_EVENT, SELECTION_EVENT } from '..';
2
+ export declare const GLOBAL_EVENT: {
3
+ EDITOR_EVENT: typeof EDITOR_EVENT;
4
+ DESIGNER_EVENT: typeof DESIGNER_EVENT;
5
+ DRAGON_EVENT: typeof DRAGON_EVENT;
6
+ DETECTING_EVENT: typeof DETECTING_EVENT;
7
+ SELECTION_EVENT: typeof SELECTION_EVENT;
8
+ PROJECT_EVENT: typeof PROJECT_EVENT;
9
+ DOCUMENT_EVENT: typeof DOCUMENT_EVENT;
10
+ NODE_EVENT: typeof NODE_EVENT;
11
+ NODE_CHILDREN_EVENT: typeof NODE_CHILDREN_EVENT;
12
+ };
@@ -0,0 +1,3 @@
1
+ export * from './common';
2
+ export * from './event';
3
+ export * from './schema';
@@ -0,0 +1,64 @@
1
+ import type { CompositeValue, JSExpression, JSFunction, JSONObject, PropsMap } from '../document';
2
+ export interface ProjectSchema<T = RootSchema> {
3
+ id?: string;
4
+ version: string;
5
+ componentsMap?: any;
6
+ componentsTree: T[];
7
+ utils?: Record<string, any>;
8
+ constants?: JSONObject;
9
+ css?: string;
10
+ config?: Record<string, any>;
11
+ meta?: Record<string, any>;
12
+ [key: string]: any;
13
+ }
14
+ export interface RootSchema extends NodeSchema {
15
+ docId?: string;
16
+ /**
17
+ * 文件名称
18
+ */
19
+ fileName?: string;
20
+ meta?: Record<string, unknown>;
21
+ /**
22
+ * 容器初始数据
23
+ */
24
+ state?: {
25
+ [key: string]: CompositeValue;
26
+ };
27
+ /**
28
+ * 自定义方法设置
29
+ */
30
+ methods?: {
31
+ [key: string]: JSExpression | JSFunction;
32
+ };
33
+ /**
34
+ * 生命周期对象
35
+ */
36
+ lifeCycles?: {
37
+ [key: string]: JSExpression | JSFunction;
38
+ };
39
+ /**
40
+ * 样式文件
41
+ */
42
+ css?: string;
43
+ }
44
+ export interface NodeSchema {
45
+ id?: string;
46
+ /** title */
47
+ title?: string;
48
+ /** required */
49
+ componentName: string;
50
+ /** props */
51
+ props?: PropsMap;
52
+ /** sub nodes */
53
+ children?: NodeSchema[];
54
+ /** hidden */
55
+ hidden?: boolean;
56
+ /** locked */
57
+ locked?: boolean;
58
+ /** render condition */
59
+ condition?: CompositeValue;
60
+ /** loop data */
61
+ loop?: CompositeValue;
62
+ [key: string]: any;
63
+ }
64
+ export type NodeData = NodeSchema | JSExpression;
@@ -0,0 +1 @@
1
+ export declare const cloneDeep: (src: any) => any;
@@ -0,0 +1,45 @@
1
+ type EventType = string | symbol;
2
+ type Events = Record<EventType, unknown>;
3
+ type Handler = (event: Events[keyof Events]) => void;
4
+ declare class EventEmitter {
5
+ all: Map<EventType, Handler[]>;
6
+ on<Key extends keyof Events>(type: Key, handler: Handler): void;
7
+ off<Key extends keyof Events>(type: Key, handler?: Handler): void;
8
+ emit<Key extends keyof Events>(type: Key, evt?: Events[Key]): void;
9
+ }
10
+ export declare class EventBus {
11
+ private readonly eventEmitter;
12
+ private readonly name?;
13
+ private logger;
14
+ /**
15
+ * 内核触发的事件名
16
+ */
17
+ readonly names: never[];
18
+ constructor(emitter: EventEmitter, name?: string);
19
+ private getMsgPrefix;
20
+ /**
21
+ * 监听事件
22
+ * @param event 事件名称
23
+ * @param listener 事件回调
24
+ */
25
+ on(event: string, listener: (...args: any[]) => void): () => void;
26
+ /**
27
+ * 取消监听事件
28
+ * @param event 事件名称
29
+ * @param listener 事件回调
30
+ */
31
+ off(event: string, listener: (...args: any[]) => void): void;
32
+ /**
33
+ * 触发事件
34
+ * @param event 事件名称
35
+ * @param args 事件参数
36
+ * @returns
37
+ */
38
+ emit(event: string, ...args: any[]): void;
39
+ }
40
+ /**
41
+ * 创建一个独立模块事件总线
42
+ * @param name 模块名称
43
+ */
44
+ export declare const createEventBus: (name: string) => EventBus;
45
+ export {};