forked from alibaba/lowcode-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathassets.ts
More file actions
223 lines (206 loc) · 4.3 KB
/
assets.ts
File metadata and controls
223 lines (206 loc) · 4.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
import { Snippet, ComponentMetadata } from './metadata';
import { I18nData } from './i18n';
export interface AssetItem {
type: AssetType;
content?: string | null;
device?: string;
level?: AssetLevel;
id?: string;
}
export enum AssetLevel {
// 环境依赖库 比如 react, react-dom
Environment = 1,
// 基础类库,比如 lodash deep fusion antd
Library = 2,
// 主题
Theme = 3,
// 运行时
Runtime = 4,
// 业务组件
Components = 5,
// 应用 & 页面
App = 6,
}
export const AssetLevels = [
AssetLevel.Environment,
AssetLevel.Library,
AssetLevel.Theme,
AssetLevel.Runtime,
AssetLevel.Components,
AssetLevel.App,
];
export type URL = string;
export enum AssetType {
JSUrl = 'jsUrl',
CSSUrl = 'cssUrl',
CSSText = 'cssText',
JSText = 'jsText',
Bundle = 'bundle',
}
export interface AssetBundle {
type: AssetType.Bundle;
level?: AssetLevel;
assets?: Asset | AssetList | null;
}
export type Asset = AssetList | AssetBundle | AssetItem | URL;
export type AssetList = Array<Asset | undefined | null>;
/**
* 资产包协议
*/
export interface AssetsJson {
/**
* 资产包协议版本号
*/
version: string;
/**
* 大包列表,external与package的概念相似,融合在一起
*/
packages?: Package[];
/**
* 所有组件的描述协议列表所有组件的列表
*/
components: Array<ComponentDescription | RemoteComponentDescription>;
/**
* 组件分类列表,用来描述物料面板
* @deprecated 最新版物料面板已不需要此描述
*/
componentList?: ComponentCategory[];
/**
* 业务组件分类列表,用来描述物料面板
* @deprecated 最新版物料面板已不需要此描述
*/
bizComponentList?: ComponentCategory[];
/**
* 用于描述组件面板中的 tab 和 category
*/
sort?: ComponentSort;
}
/**
* 用于描述组件面板中的 tab 和 category
*/
export interface ComponentSort {
/**
* 用于描述组件面板的 tab 项及其排序,例如:["精选组件", "原子组件"]
*/
groupList?: string[];
/**
* 组件面板中同一个 tab 下的不同区间用 category 区分,category 的排序依照 categoryList 顺序排列;
*/
categoryList?: string[];
}
/**
* 定义组件大包及 external 资源的信息
* 应该被编辑器默认加载
*/
export interface Package {
/**
* 包名
*/
package: string;
/**
* 包版本号
*/
version: string;
/**
* 组件渲染态视图打包后的 CDN url 列表,包含 js 和 css
*/
urls?: string[] | any;
/**
* 组件编辑态视图打包后的 CDN url 列表,包含 js 和 css
*/
editUrls?: string[] | any;
/**
* 作为全局变量引用时的名称,和webpack output.library字段含义一样,用来定义全局变量名
*/
library: string;
/**
* @experimental
*
* @todo 需推进提案 @度城
*/
async?: boolean;
/**
* 组件描述导出名字,可以通过 window[exportName] 获取到组件描述的 Object 内容;
*/
exportName?: string;
}
/**
* 组件分类
* @deprecated 已被 ComponentMetadata 替代
*/
export interface ComponentCategory {
/**
* 组件分类title
*/
title: string;
/**
* 组件分类icon
*/
icon?: string;
/**
* 可能有子分类
*/
children?: ComponentItem[] | ComponentCategory[];
}
/**
* 组件
* @deprecated 已被 ComponentMetadata 替代
*/
export interface ComponentItem {
/**
* 组件title
*/
title: string;
/**
* 组件名
*/
componentName?: string;
/**
* 组件icon
*/
icon?: string;
/**
* 可用片段
*/
snippets?: Snippet[];
/**
* 一级分组
*/
group?: string | I18nData;
/**
* 二级分组
*/
category?: string | I18nData;
/**
* 组件优先级排序
*/
priority?: number;
}
/**
* 本地物料描述
*/
export interface ComponentDescription extends ComponentMetadata {
/**
* @todo 待补充文档 @jinchan
*/
keywords: string[];
}
/**
* 远程物料描述
*/
export interface RemoteComponentDescription {
/**
* 组件描述导出名字,可以通过 window[exportName] 获取到组件描述的 Object 内容;
*/
exportName?: string;
/**
* 组件描述的资源链接;
*/
url?: string;
/**
* 组件(库)的 npm 信息;
*/
package?: {
npm?: string;
};
}