@easy-editor/renderer-core 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.
package/LICENSE ADDED
@@ -0,0 +1,9 @@
1
+ MIT License
2
+
3
+ Copyright © 2024-PRESENT JinSo <https://github.com/JinSooo>
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,121 @@
1
+ # @easy-editor/renderer-core
2
+
3
+ Renderer Core package for EasyEditor. This package provides the foundation for implementing framework-specific renderers (like React, Vue, etc.) in EasyEditor.
4
+
5
+ ## Package Structure
6
+
7
+ The renderer-core provides:
8
+ - Type definitions for renderer implementations
9
+ - Utility functions for schema processing
10
+ - Core interfaces for component rendering
11
+ - Data handling and transformation helpers
12
+
13
+ ## Features
14
+
15
+ - **Framework Agnostic**: Core renderer interfaces that can be implemented for any UI framework
16
+ - **Schema Processing**: Utilities for processing low-code schema structures
17
+ - **Component Model**: Type definitions for component rendering and lifecycle management
18
+ - **Data Binding**: Support for data expressions and bindings within schemas
19
+ - **DataSource Integration**: Types for handling data sources in rendered components
20
+ - **Error Handling**: Standardized error boundaries and component fallbacks
21
+
22
+ ## Core Interfaces
23
+
24
+ ### Renderer
25
+
26
+ The renderer is responsible for converting schema to component instances:
27
+
28
+ ```typescript
29
+ export interface RendererProps {
30
+ // The schema representing the component tree
31
+ schema: RootSchema | NodeSchema;
32
+
33
+ // Component implementations mapped by name
34
+ components: Record<string, ComponentType<any>>;
35
+
36
+ // Rendering mode (design or live)
37
+ designMode?: DesignMode;
38
+
39
+ // Device information for responsive rendering
40
+ device?: 'default' | 'pc' | 'mobile' | string;
41
+
42
+ // Reference to the Simulator host
43
+ __host?: Simulator;
44
+
45
+ // ... additional properties
46
+ }
47
+ ```
48
+
49
+ ### Component Types
50
+
51
+ The renderer-core defines several component types to handle different rendering scenarios:
52
+
53
+ ```typescript
54
+ // Regular component used in rendering
55
+ export interface GeneralComponent<P = any, S = any, SS = any> {
56
+ // Component lifecycle methods
57
+ componentDidMount?(): void;
58
+ componentDidUpdate?(): void;
59
+ componentWillUnmount?(): void;
60
+
61
+ // Rendering method
62
+ render(): any;
63
+
64
+ // Component state and props
65
+ props: P;
66
+ state: S;
67
+ // ... additional properties
68
+ }
69
+
70
+ // Component shown when a component is not found
71
+ export interface NotFoundComponentProps {
72
+ componentName?: string;
73
+ // ... additional properties
74
+ }
75
+
76
+ // Component shown when rendering fails
77
+ export interface FaultComponentProps {
78
+ componentName?: string;
79
+ error?: Error;
80
+ // ... additional properties
81
+ }
82
+ ```
83
+
84
+ ## Data Handling
85
+
86
+ The renderer-core provides utilities for handling data and expressions:
87
+
88
+ ### Expression Parsing
89
+
90
+ ```typescript
91
+ import { parseExpression } from '@easy-editor/renderer-core';
92
+
93
+ // Convert JSExpression objects into actual values
94
+ const result = parseExpression({
95
+ type: 'JSExpression',
96
+ value: '(function(){ return this.state.count + 1; })'
97
+ }, context);
98
+ ```
99
+
100
+ ### Data Source Types
101
+
102
+ ```typescript
103
+ export interface DataSourceItem {
104
+ id: string;
105
+ isInit?: boolean | JSExpression;
106
+ type?: string;
107
+ options?: {
108
+ uri: string | JSExpression;
109
+ params?: JSONObject | JSExpression;
110
+ method?: string | JSExpression;
111
+ // ... additional options
112
+ };
113
+ dataHandler?: JSExpression;
114
+ }
115
+
116
+ export interface DataSource {
117
+ list?: DataSourceItem[];
118
+ dataHandler?: JSExpression;
119
+ }
120
+ ```
121
+