@easy-editor/react-renderer 0.0.17 → 0.0.18
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.
- package/dist/cjs/index.development.js +1377 -98
- package/dist/cjs/index.development.js.map +1 -1
- package/dist/cjs/index.js +1377 -98
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/index.production.js +1377 -98
- package/dist/cjs/index.production.js.map +1 -1
- package/dist/esm/index.development.js +1378 -100
- package/dist/esm/index.development.js.map +1 -1
- package/dist/esm/index.js +1378 -100
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/index.production.js +1378 -100
- package/dist/esm/index.production.js.map +1 -1
- package/dist/index.js +1378 -100
- package/dist/renderer-core/types.d.ts +35 -20
- package/dist/renderer-core/utils/common.d.ts +6 -0
- package/dist/renderer-core/utils/data-helper.d.ts +83 -0
- package/dist/renderer-core/utils/request.d.ts +43 -0
- package/package.json +6 -6
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { DesignMode,
|
|
1
|
+
import type { DesignMode, Node, NodeSchema, RootSchema, Simulator, SimulatorRenderer } from '@easy-editor/core';
|
|
2
2
|
import type { Component } from 'react';
|
|
3
3
|
import type { FaultComponentProps } from './components/FaultComponent';
|
|
4
4
|
import type { NotFoundComponentProps } from './components/NotFoundComponent';
|
|
@@ -86,11 +86,44 @@ export interface RendererComponentInstance extends Component<RendererProps, Rend
|
|
|
86
86
|
getNotFoundComponent(): any;
|
|
87
87
|
getFaultComponent(): any;
|
|
88
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
|
+
}
|
|
89
118
|
export interface RendererAppHelper {
|
|
90
119
|
/** 全局公共函数 */
|
|
91
120
|
utils?: Record<string, any>;
|
|
92
121
|
/** 全局常量 */
|
|
93
122
|
constants?: Record<string, any>;
|
|
123
|
+
/** react-router 的 location 实例 */
|
|
124
|
+
location?: ILocationLike;
|
|
125
|
+
/** react-router 的 history 实例 */
|
|
126
|
+
history?: IHistoryLike;
|
|
94
127
|
/** @experimental 内部使用 */
|
|
95
128
|
requestHandlersMap?: Record<string, any>;
|
|
96
129
|
}
|
|
@@ -104,25 +137,6 @@ export interface JSExpression {
|
|
|
104
137
|
type: string;
|
|
105
138
|
value: string;
|
|
106
139
|
}
|
|
107
|
-
export interface DataSourceItem {
|
|
108
|
-
id: string;
|
|
109
|
-
isInit?: boolean | JSExpression;
|
|
110
|
-
type?: string;
|
|
111
|
-
options?: {
|
|
112
|
-
uri: string | JSExpression;
|
|
113
|
-
params?: JSONObject | JSExpression;
|
|
114
|
-
method?: string | JSExpression;
|
|
115
|
-
shouldFetch?: string;
|
|
116
|
-
willFetch?: string;
|
|
117
|
-
fit?: string;
|
|
118
|
-
didFetch?: string;
|
|
119
|
-
};
|
|
120
|
-
dataHandler?: JSExpression;
|
|
121
|
-
}
|
|
122
|
-
export interface DataSource {
|
|
123
|
-
list?: DataSourceItem[];
|
|
124
|
-
dataHandler?: JSExpression;
|
|
125
|
-
}
|
|
126
140
|
export interface BaseRendererProps extends RendererProps {
|
|
127
141
|
__appHelper?: RendererAppHelper;
|
|
128
142
|
__components: Record<string, React.ComponentType>;
|
|
@@ -185,3 +199,4 @@ export type BaseRendererInstance = Component<BaseRendererProps, Record<string, a
|
|
|
185
199
|
export interface BaseRenderComponent {
|
|
186
200
|
new (props: BaseRendererProps): BaseRendererInstance;
|
|
187
201
|
}
|
|
202
|
+
export {};
|
|
@@ -51,3 +51,9 @@ export declare function isString(str: any): boolean;
|
|
|
51
51
|
export declare function capitalizeFirstLetter(word: string): string;
|
|
52
52
|
export declare const isReactClass: (obj: any) => obj is ComponentClass<any>;
|
|
53
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;
|
|
@@ -0,0 +1,83 @@
|
|
|
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 {};
|
|
@@ -0,0 +1,43 @@
|
|
|
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>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@easy-editor/react-renderer",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.18",
|
|
4
4
|
"description": "React Renderer package for EasyEditor.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -40,23 +40,23 @@
|
|
|
40
40
|
"url": "https://github.com/Easy-Editor/EasyEditor/issues"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@easy-editor/core": "^0.0.15",
|
|
44
43
|
"mobx-react": "^9.2.0",
|
|
45
44
|
"react": "^18 || ^19",
|
|
46
45
|
"react-dom": "^18 || ^19",
|
|
47
46
|
"@types/react": "^18 || ^19",
|
|
48
|
-
"@types/react-dom": "^18 || ^19"
|
|
47
|
+
"@types/react-dom": "^18 || ^19",
|
|
48
|
+
"@easy-editor/core": "^0.0.16"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
51
|
"lodash-es": "^4.17.21",
|
|
52
52
|
"prop-types": "^15.8.1",
|
|
53
|
-
"react-is": "^18.3.1"
|
|
53
|
+
"react-is": "^18.3.1",
|
|
54
|
+
"@easy-editor/datasource-engine": "^0.0.1"
|
|
54
55
|
},
|
|
55
56
|
"devDependencies": {
|
|
56
57
|
"@types/lodash-es": "^4.17.12",
|
|
57
58
|
"@types/prop-types": "^15.7.14",
|
|
58
|
-
"@types/react-is": "^18.3.0"
|
|
59
|
-
"@easy-editor/core": "0.0.15"
|
|
59
|
+
"@types/react-is": "^18.3.0"
|
|
60
60
|
},
|
|
61
61
|
"scripts": {
|
|
62
62
|
"dev": "deno run --watch ./src/index.ts",
|