@easy-editor/react-renderer 0.0.18 → 1.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 (50) hide show
  1. package/README.md +12 -1
  2. package/dist/adapter/index.d.ts +17 -0
  3. package/dist/{renderer-core/base.d.ts → base.d.ts} +2 -2
  4. package/dist/component.d.ts +2 -0
  5. package/dist/components/FaultComponent.d.ts +4 -0
  6. package/dist/components/NotFoundComponent.d.ts +4 -0
  7. package/dist/{renderer-core/hoc → hoc}/leaf.d.ts +2 -1
  8. package/dist/{cjs/index.js → index.cjs} +406 -1894
  9. package/dist/index.d.ts +10 -3
  10. package/dist/index.js +353 -1823
  11. package/dist/page.d.ts +2 -0
  12. package/dist/renderer.d.ts +2 -0
  13. package/dist/setting-renderer/context.d.ts +8 -0
  14. package/dist/setting-renderer/index.d.ts +8 -0
  15. package/dist/types.d.ts +7 -0
  16. package/dist/utils/index.d.ts +2 -0
  17. package/dist/utils/is.d.ts +3 -0
  18. package/package.json +15 -20
  19. package/dist/cjs/index.development.js +0 -4013
  20. package/dist/cjs/index.development.js.map +0 -1
  21. package/dist/cjs/index.js.map +0 -1
  22. package/dist/cjs/index.production.js +0 -4013
  23. package/dist/cjs/index.production.js.map +0 -1
  24. package/dist/configure-renderer/context.d.ts +0 -13
  25. package/dist/configure-renderer/index.d.ts +0 -10
  26. package/dist/esm/index.development.js +0 -3977
  27. package/dist/esm/index.development.js.map +0 -1
  28. package/dist/esm/index.js +0 -3977
  29. package/dist/esm/index.js.map +0 -1
  30. package/dist/esm/index.production.js +0 -3977
  31. package/dist/esm/index.production.js.map +0 -1
  32. package/dist/renderer-core/adapter/index.d.ts +0 -17
  33. package/dist/renderer-core/component.d.ts +0 -2
  34. package/dist/renderer-core/components/FaultComponent.d.ts +0 -7
  35. package/dist/renderer-core/components/NotFoundComponent.d.ts +0 -7
  36. package/dist/renderer-core/index.d.ts +0 -9
  37. package/dist/renderer-core/page.d.ts +0 -2
  38. package/dist/renderer-core/renderer.d.ts +0 -2
  39. package/dist/renderer-core/types.d.ts +0 -202
  40. package/dist/renderer-core/utils/classnames.d.ts +0 -1
  41. package/dist/renderer-core/utils/common.d.ts +0 -59
  42. package/dist/renderer-core/utils/data-helper.d.ts +0 -83
  43. package/dist/renderer-core/utils/index.d.ts +0 -4
  44. package/dist/renderer-core/utils/logger.d.ts +0 -5
  45. package/dist/renderer-core/utils/request.d.ts +0 -43
  46. /package/dist/{renderer-core/context.d.ts → context.d.ts} +0 -0
  47. /package/dist/{renderer-core/hoc → hoc}/comp.d.ts +0 -0
  48. /package/dist/{renderer-core/hoc → hoc}/index.d.ts +0 -0
  49. /package/dist/{configure-renderer → setting-renderer}/SettingSetter.d.ts +0 -0
  50. /package/dist/{renderer-core/utils → utils}/hoc.d.ts +0 -0
@@ -1,17 +0,0 @@
1
- import type { ComponentType } from 'react';
2
- import type { BaseRenderComponent } from '../types';
3
- export interface RendererModules {
4
- BaseRenderer?: BaseRenderComponent;
5
- PageRenderer: BaseRenderComponent;
6
- ComponentRenderer: BaseRenderComponent;
7
- }
8
- declare class Adapter {
9
- renderers: RendererModules;
10
- setRenderers(renderers: RendererModules): void;
11
- setBaseRenderer(BaseRenderer: BaseRenderComponent): void;
12
- setPageRenderer(PageRenderer: BaseRenderComponent): void;
13
- setComponentRenderer(ComponentRenderer: BaseRenderComponent): void;
14
- getRenderers(): Record<string, ComponentType<any>>;
15
- }
16
- export declare const adapter: Adapter;
17
- export {};
@@ -1,2 +0,0 @@
1
- import type { BaseRenderComponent } from './types';
2
- export declare function componentRendererFactory(): BaseRenderComponent;
@@ -1,7 +0,0 @@
1
- import type { NodeSchema } from '@easy-editor/core';
2
- import type { FC } from 'react';
3
- export interface FaultComponentProps extends NodeSchema {
4
- error?: Error | string;
5
- }
6
- declare const FaultComponent: FC<FaultComponentProps>;
7
- export default FaultComponent;
@@ -1,7 +0,0 @@
1
- import type { NodeSchema } from '@easy-editor/core';
2
- import type { FC } from 'react';
3
- export interface NotFoundComponentProps extends NodeSchema {
4
- enableStrictNotFoundMode?: boolean;
5
- }
6
- declare const NotFoundComponent: FC<NotFoundComponentProps>;
7
- export default NotFoundComponent;
@@ -1,9 +0,0 @@
1
- export * from './adapter';
2
- export * from './base';
3
- export * from './component';
4
- export * from './context';
5
- export * from './hoc';
6
- export * from './page';
7
- export * from './renderer';
8
- export * from './types';
9
- export * from './utils';
@@ -1,2 +0,0 @@
1
- import type { BaseRenderComponent } from './types';
2
- export declare function pageRendererFactory(): BaseRenderComponent;
@@ -1,2 +0,0 @@
1
- import type { RenderComponent } from './types';
2
- export declare function rendererFactory(): RenderComponent;
@@ -1,202 +0,0 @@
1
- import type { DesignMode, Node, NodeSchema, RootSchema, Simulator, SimulatorRenderer } from '@easy-editor/core';
2
- import type { Component } from 'react';
3
- import type { FaultComponentProps } from './components/FaultComponent';
4
- import type { NotFoundComponentProps } from './components/NotFoundComponent';
5
- export type Schema = NodeSchema | RootSchema;
6
- export interface RendererState {
7
- engineRenderError?: boolean;
8
- error?: Error;
9
- }
10
- export interface RendererProps {
11
- /** 符合低代码搭建协议的数据 */
12
- schema: RootSchema | NodeSchema;
13
- /** 组件依赖的实例 */
14
- components: Record<string, React.ComponentType<any>>;
15
- /** CSS 类名 */
16
- className?: string;
17
- /** style */
18
- style?: React.CSSProperties;
19
- /** id */
20
- id?: string | number;
21
- /** 当前文档的 id */
22
- documentId?: string;
23
- /** 主要用于设置渲染模块的全局上下文,里面定义的内容可以在低代码中通过 this 来访问,比如 this.utils */
24
- appHelper?: RendererAppHelper;
25
- /**
26
- * 配置规范参见《低代码搭建组件描述协议》https://lowcode-engine.cn/lowcode
27
- * 主要在搭建场景中使用,用于提升用户搭建体验。
28
- *
29
- * > 在生产环境下不需要设置
30
- */
31
- componentsMap?: Record<string, any>;
32
- /** 设计模式,可选值:live、design */
33
- designMode?: DesignMode;
34
- /** 渲染模块是否挂起,当设置为 true 时,渲染模块最外层容器的 shouldComponentUpdate 将始终返回false,在下钻编辑或者多引擎渲染的场景会用到该参数。 */
35
- suspended?: boolean;
36
- /** 组件获取 ref 时触发的钩子 */
37
- onCompGetRef?: (schema: NodeSchema, ref: any) => void;
38
- /** 组件 ctx 更新回调 */
39
- onCompGetCtx?: (schema: NodeSchema, ref: any) => void;
40
- /** 传入的 schema 是否有变更 */
41
- getSchemaChangedSymbol?: () => boolean;
42
- /** 设置 schema 是否有变更 */
43
- setSchemaChangedSymbol?: (symbol: boolean) => void;
44
- /** 自定义创建 element 的钩子 */
45
- customCreateElement?: (Component: any, props: any, children: any) => any;
46
- /** 渲染类型,标识当前模块是以什么类型进行渲染的 */
47
- rendererName?: 'LowCodeRenderer' | 'PageRenderer' | string;
48
- /** 当找不到组件时,显示的组件 */
49
- notFoundComponent?: React.ComponentType<NotFoundComponentProps>;
50
- /** 当组件渲染异常时,显示的组件 */
51
- faultComponent?: React.ComponentType<FaultComponentProps>;
52
- /** 设备信息 */
53
- device?: 'default' | 'pc' | 'mobile' | string;
54
- /**
55
- * 当开启组件未找到严格模式时,渲染模块不会默认给一个容器组件
56
- * @default false
57
- */
58
- enableStrictNotFoundMode?: boolean;
59
- /** 获取节点的方法 */
60
- getNode?: (id: string) => Node;
61
- /** 渲染模块的 host */
62
- __host?: Simulator;
63
- /** 渲染模块的 container */
64
- __container?: SimulatorRenderer;
65
- /**
66
- * 是否在设计模式下执行生命周期方法
67
- * @default false
68
- */
69
- excuteLifeCycleInDesignMode?: boolean;
70
- }
71
- export interface RenderComponent {
72
- displayName: string;
73
- defaultProps: RendererProps;
74
- new (props: RendererProps): RendererComponentInstance;
75
- }
76
- export interface RendererComponentInstance extends Component<RendererProps, RendererState> {
77
- [x: string]: any;
78
- __getRef: (ref: any) => void;
79
- componentDidMount(): Promise<void> | void;
80
- componentDidUpdate(): Promise<void> | void;
81
- componentWillUnmount(): Promise<void> | void;
82
- componentDidCatch(e: any): Promise<void> | void;
83
- shouldComponentUpdate(nextProps: RendererProps): boolean;
84
- isValidComponent(SetComponent: any): any;
85
- createElement(SetComponent: any, props: any, children?: any): any;
86
- getNotFoundComponent(): any;
87
- getFaultComponent(): any;
88
- }
89
- /**
90
- * duck-typed History
91
- *
92
- * @see https://github.com/ReactTraining/history/tree/master/docs/api-reference.md
93
- */
94
- interface IHistoryLike {
95
- readonly action: any;
96
- readonly location: ILocationLike;
97
- createHref: (to: any) => string;
98
- push: (to: any, state?: any) => void;
99
- replace: (to: any, state?: any) => void;
100
- go: (delta: any) => void;
101
- back: () => void;
102
- forward: () => void;
103
- listen: (listener: any) => () => void;
104
- block: (blocker: any) => () => void;
105
- }
106
- /**
107
- * duck-typed History.Location
108
- *
109
- * @see https://github.com/remix-run/history/blob/dev/docs/api-reference.md#location
110
- */
111
- export interface ILocationLike {
112
- pathname: any;
113
- search: any;
114
- state: any;
115
- hash: any;
116
- key?: any;
117
- }
118
- export interface RendererAppHelper {
119
- /** 全局公共函数 */
120
- utils?: Record<string, any>;
121
- /** 全局常量 */
122
- constants?: Record<string, any>;
123
- /** react-router 的 location 实例 */
124
- location?: ILocationLike;
125
- /** react-router 的 history 实例 */
126
- history?: IHistoryLike;
127
- /** @experimental 内部使用 */
128
- requestHandlersMap?: Record<string, any>;
129
- }
130
- export interface NodeInfo {
131
- schema?: NodeSchema;
132
- Comp: any;
133
- componentInfo?: any;
134
- componentChildren?: any;
135
- }
136
- export interface JSExpression {
137
- type: string;
138
- value: string;
139
- }
140
- export interface BaseRendererProps extends RendererProps {
141
- __appHelper?: RendererAppHelper;
142
- __components: Record<string, React.ComponentType>;
143
- __ctx?: Record<string, any>;
144
- __schema: RootSchema;
145
- __designMode?: DesignMode;
146
- __host?: Simulator;
147
- __container?: SimulatorRenderer;
148
- config?: Record<string, any>;
149
- designMode?: DesignMode;
150
- className?: string;
151
- style?: React.CSSProperties;
152
- id?: string | number;
153
- getSchemaChangedSymbol?: () => boolean;
154
- setSchemaChangedSymbol?: (symbol: boolean) => void;
155
- documentId?: string;
156
- getNode?: any;
157
- /**
158
- * 设备类型,默认值:'default'
159
- */
160
- device?: 'default' | 'pc' | 'mobile' | string;
161
- componentName?: string;
162
- }
163
- export interface BaseRendererContext {
164
- appHelper: RendererAppHelper;
165
- components: Record<string, React.ComponentType>;
166
- engine: RendererComponentInstance;
167
- pageContext?: BaseRenderComponent;
168
- compContext?: BaseRenderComponent;
169
- }
170
- export type BaseRendererInstance = Component<BaseRendererProps, Record<string, any>, any> & {
171
- reloadDataSource(): Promise<any>;
172
- __beforeInit(props: BaseRendererProps): void;
173
- __init(props: BaseRendererProps): void;
174
- __afterInit(props: BaseRendererProps): void;
175
- __executeLifeCycleMethod(method: string, args?: any[]): void;
176
- __getComponentView(): React.ComponentType | undefined;
177
- __bindCustomMethods(props: BaseRendererProps): void;
178
- __generateCtx(ctx: Record<string, any>): void;
179
- __parseData(data: any, ctx?: any): any;
180
- __initDataSource(props: BaseRendererProps): void;
181
- __writeCss(props: BaseRendererProps): void;
182
- __render(): void;
183
- __getRef(ref: any): void;
184
- __getSchemaChildrenVirtualDom(schema: NodeSchema | undefined, Comp: any, nodeChildrenMap?: any): any;
185
- __getComponentProps(schema: NodeSchema | undefined, scope: any, Comp: any, componentInfo?: any): any;
186
- __createDom(): any;
187
- __createVirtualDom(schema: any, self: any, parentInfo: NodeInfo, idx: string | number): any;
188
- __createLoopVirtualDom(schema: any, self: any, parentInfo: NodeInfo, idx: number | string): any;
189
- __parseProps(props: any, self: any, path: string, info: NodeInfo): any;
190
- __renderContextProvider(customProps?: object, children?: any): any;
191
- __renderContextConsumer(children: any): any;
192
- __renderContent(children: any): any;
193
- __checkSchema(schema: NodeSchema | undefined, extraComponents?: string | string[]): any;
194
- __renderComp(Comp: any, ctxProps: object): any;
195
- $(id: string, instance?: any): any;
196
- context: BaseRendererContext;
197
- __designModeIsDesign?: boolean;
198
- };
199
- export interface BaseRenderComponent {
200
- new (props: BaseRendererProps): BaseRendererInstance;
201
- }
202
- export {};
@@ -1 +0,0 @@
1
- export declare const classnames: (...args: any[]) => string;
@@ -1,59 +0,0 @@
1
- import { type NodeSchema } from '@easy-editor/core';
2
- import { type ComponentClass, type ComponentType } from 'react';
3
- export declare function inSameDomain(): boolean;
4
- /**
5
- * get css styled name from schema`s fileName
6
- * FileName -> lce-file-name
7
- * @returns string
8
- */
9
- export declare function getFileCssName(fileName: string): string | undefined;
10
- export declare const isSchema: (schema: any) => schema is NodeSchema;
11
- export declare const getValue: (obj: any, path: string, defaultValue?: {}) => any;
12
- export declare function transformArrayToMap(arr: any[], key: string, overwrite?: boolean): any;
13
- interface IParseOptions {
14
- logScope?: string;
15
- }
16
- export declare const parseData: (schema: unknown, self: any, options?: IParseOptions) => any;
17
- export declare const isUseLoop: (loop: null | any[], isDesignMode: boolean) => boolean;
18
- export declare function checkPropTypes(value: any, name: string, rule: any, componentName: string): boolean;
19
- /**
20
- * transform string to a function
21
- * @param str function in string form
22
- * @returns funtion
23
- */
24
- export declare function transformStringToFunction(str: string): any;
25
- /**
26
- * 对象类型JSExpression,支持省略this
27
- * @param str expression in string form
28
- * @param self scope object
29
- * @returns funtion
30
- */
31
- declare function parseExpression(options: {
32
- str: any;
33
- self: any;
34
- thisRequired?: boolean;
35
- logScope?: string;
36
- }): any;
37
- declare function parseExpression(str: any, self: any, thisRequired?: boolean): any;
38
- export { parseExpression };
39
- export declare function parseThisRequiredExpression(str: any, self: any): any;
40
- /**
41
- * check str passed in is a string type of not
42
- * @param str obj to be checked
43
- * @returns boolean
44
- */
45
- export declare function isString(str: any): boolean;
46
- /**
47
- * capitalize first letter
48
- * @param word string to be proccessed
49
- * @returns string capitalized string
50
- */
51
- export declare function capitalizeFirstLetter(word: string): string;
52
- export declare const isReactClass: (obj: any) => obj is ComponentClass<any>;
53
- export declare function isReactComponent(obj: any): obj is ComponentType<any>;
54
- /**
55
- * process params for using in a url query
56
- * @param obj params to be processed
57
- * @returns string
58
- */
59
- export declare function serializeParams(obj: any): any;
@@ -1,83 +0,0 @@
1
- import { type DataSource } from '@easy-editor/core';
2
- import type { RendererAppHelper } from '../types';
3
- type DataSourceType = 'fetch';
4
- /**
5
- * do request for standard DataSourceType
6
- * @param {DataSourceType} type type of DataSourceItem
7
- * @param {any} options
8
- */
9
- export declare function doRequest(type: DataSourceType, options: any): Promise<unknown> | undefined;
10
- export declare class DataHelper {
11
- /**
12
- * host object that will be "this" object when excuting dataHandler
13
- *
14
- * @type {*}
15
- * @memberof DataHelper
16
- */
17
- host: any;
18
- /**
19
- * data source config
20
- *
21
- * @type {DataSource}
22
- * @memberof DataHelper
23
- */
24
- config: DataSource;
25
- /**
26
- * a parser function which will be called to process config data
27
- * which eventually will call common/utils.processData() to process data
28
- * (originalConfig) => parsedConfig
29
- * @type {*}
30
- * @memberof DataHelper
31
- */
32
- parser: any;
33
- /**
34
- * config.list
35
- *
36
- * @type {any[]}
37
- * @memberof DataHelper
38
- */
39
- ajaxList: any[];
40
- /**
41
- * dataHandler
42
- *
43
- * @type {*}
44
- * @memberof DataHelper
45
- */
46
- dataHandler: any;
47
- ajaxMap: any;
48
- dataSourceMap: any;
49
- appHelper: RendererAppHelper;
50
- constructor(comp: any, config: DataSource, appHelper: RendererAppHelper, parser: any);
51
- updateConfig(config?: {}): any;
52
- generateDataSourceMap(): any;
53
- updateDataSourceMap(id: string, data: any, error: any): void;
54
- /**
55
- * get all dataSourceItems which marked as isInit === true
56
- * @private
57
- * @returns
58
- * @memberof DataHelper
59
- */
60
- getInitDataSourseConfigs(): any;
61
- /**
62
- * process all dataSourceItems which marked as isInit === true, and get dataSource request results.
63
- * @public
64
- * @returns
65
- * @memberof DataHelper
66
- */
67
- getInitData(): Promise<any>;
68
- reloadDataSource(): Promise<void>;
69
- getDataSource(id: string, params: any, otherOptions: any, callback: any): Promise<any> | undefined;
70
- asyncDataHandler(asyncDataList: any[]): Promise<unknown>;
71
- /**
72
- * process data using dataHandler
73
- *
74
- * @param {(string | null)} id request id, will be used in error message, can be null
75
- * @param {*} dataHandler
76
- * @param {*} data
77
- * @param {*} error
78
- * @returns
79
- * @memberof DataHelper
80
- */
81
- handleData(id: string | null, dataHandler: any, data: any, error: any): any;
82
- }
83
- export {};
@@ -1,4 +0,0 @@
1
- export * from './classnames';
2
- export * from './common';
3
- export * from './hoc';
4
- export * from './logger';
@@ -1,5 +0,0 @@
1
- export declare const logger: {
2
- log: (message?: any, ...optionalParams: any[]) => void;
3
- error: (message?: any, ...optionalParams: any[]) => void;
4
- warn: (message?: any, ...optionalParams: any[]) => void;
5
- };
@@ -1,43 +0,0 @@
1
- /**
2
- * this is a private method, export for testing purposes only.
3
- *
4
- * @export
5
- * @param {*} dataAPI
6
- * @param {*} params
7
- * @returns
8
- */
9
- export declare function buildUrl(dataAPI: any, params: any): any;
10
- /**
11
- * do Get request
12
- *
13
- * @export
14
- * @param {*} dataAPI
15
- * @param {*} [params={}]
16
- * @param {*} [headers={}]
17
- * @param {*} [otherProps={}]
18
- * @returns
19
- */
20
- export declare function get(dataAPI: any, params?: {}, headers?: {}, otherProps?: {}): Promise<unknown>;
21
- /**
22
- * do Post request
23
- *
24
- * @export
25
- * @param {*} dataAPI
26
- * @param {*} [params={}]
27
- * @param {*} [headers={}]
28
- * @param {*} [otherProps={}]
29
- * @returns
30
- */
31
- export declare function post(dataAPI: any, params?: {}, headers?: any, otherProps?: {}): Promise<unknown>;
32
- /**
33
- * do request
34
- *
35
- * @export
36
- * @param {*} dataAPI
37
- * @param {string} [method='GET']
38
- * @param {*} data
39
- * @param {*} [headers={}]
40
- * @param {*} [otherProps={}]
41
- * @returns
42
- */
43
- export declare function request(dataAPI: any, method: string | undefined, data: any, headers?: {}, otherProps?: any): Promise<unknown>;
File without changes
File without changes
File without changes