@anov/cic-standard-sdk 0.0.18 → 0.0.20
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/cic-sdk.cjs.js +7 -7
- package/dist/cic-sdk.es.js +2205 -1931
- package/dist/cic-sdk.umd.js +7 -7
- package/dist/sdk/CICInstance.d.ts +48 -0
- package/dist/sdk/CICSDK.d.ts +7 -14
- package/dist/sdk/depsLoader/core/types.d.ts +29 -0
- package/dist/sdk/depsLoader/loaders/jsLoader.d.ts +3 -2
- package/dist/sdk/render/index.d.ts +11 -0
- package/dist/types/adapter.d.ts +385 -0
- package/dist/types/cic.manifest.d.ts +367 -0
- package/dist/types/components.d.ts +4 -2
- package/dist/types/data.d.ts +1 -0
- package/dist/types/dataSources.d.ts +6 -5
- package/dist/types/deps.d.ts +2 -1
- package/dist/types/index.d.ts +3 -0
- package/dist/types/runtime.manifest.d.ts +265 -0
- package/package.json +1 -1
|
@@ -0,0 +1,367 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* =========================================================
|
|
3
|
+
* CIC Manifest 是 CIC 内容包的"运行时装配说明书"
|
|
4
|
+
*
|
|
5
|
+
*
|
|
6
|
+
* 与 CIC Config 的区别:
|
|
7
|
+
* ┌─────────────────┬──────────────────┐
|
|
8
|
+
* │ CIC Config │ CIC Manifest │
|
|
9
|
+
* ├─────────────────┼──────────────────┤
|
|
10
|
+
* │ 描述"是什么" │ 描述"怎么运行" │
|
|
11
|
+
* │ 组件、数据、结构│ 加载、解析、执行 │
|
|
12
|
+
* │ 平台无关 │ 平台相关 │
|
|
13
|
+
* │ 可序列化数据 │ 运行时配置 │
|
|
14
|
+
* └─────────────────┴──────────────────┘
|
|
15
|
+
*
|
|
16
|
+
*
|
|
17
|
+
* 核心职责:
|
|
18
|
+
* - 声明运行时环境要求
|
|
19
|
+
* - 定义模块解析规则(公共依赖:importmap / global / cdn)
|
|
20
|
+
* - 配置组件加载与注册策略(install / init / 自定义调用)
|
|
21
|
+
* - 声明导出策略(公共依赖排除列表)、平台能力要求
|
|
22
|
+
* =========================================================
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* CIC Manifest 主接口
|
|
26
|
+
*/
|
|
27
|
+
export interface CICManifest {
|
|
28
|
+
/**
|
|
29
|
+
* Manifest 版本
|
|
30
|
+
* @example "1.0.0"
|
|
31
|
+
*/
|
|
32
|
+
version: string;
|
|
33
|
+
/**
|
|
34
|
+
* 运行时引擎
|
|
35
|
+
* 声明此 CIC 需要的运行环境
|
|
36
|
+
*/
|
|
37
|
+
engine: RuntimeEngine;
|
|
38
|
+
/**
|
|
39
|
+
* 模块解析
|
|
40
|
+
* 定义如何解析和加载模块(公共依赖)
|
|
41
|
+
*/
|
|
42
|
+
modules: ModuleResolution;
|
|
43
|
+
/**
|
|
44
|
+
* 组件配置(可选)
|
|
45
|
+
* 定义组件加载和注册规则
|
|
46
|
+
*/
|
|
47
|
+
components?: ComponentConfig;
|
|
48
|
+
/**
|
|
49
|
+
* 导出策略(可选)
|
|
50
|
+
*
|
|
51
|
+
* 场景:不同平台导出 CIC Config 时,需要排除公共依赖(宿主统一注入)。
|
|
52
|
+
*/
|
|
53
|
+
export?: ManifestExportConfig;
|
|
54
|
+
/**
|
|
55
|
+
* 扩展配置(可选)
|
|
56
|
+
* 平台特定或自定义配置
|
|
57
|
+
*/
|
|
58
|
+
extensions?: Record<string, any>;
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* 运行时引擎
|
|
62
|
+
*/
|
|
63
|
+
export interface RuntimeEngine {
|
|
64
|
+
/**
|
|
65
|
+
* 平台类型
|
|
66
|
+
* @example "web" | "node" | "mini-program" | "desktop"
|
|
67
|
+
*/
|
|
68
|
+
platform: string;
|
|
69
|
+
/**
|
|
70
|
+
* 运行时类型
|
|
71
|
+
* @example "vue3" | "vue2" | "react" | "angular" | "vanilla"
|
|
72
|
+
*/
|
|
73
|
+
runtime: string;
|
|
74
|
+
/**
|
|
75
|
+
* 运行时版本约束(可选)
|
|
76
|
+
* @example "^3.0.0"
|
|
77
|
+
*/
|
|
78
|
+
version?: string;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* 模块解析配置
|
|
82
|
+
*/
|
|
83
|
+
export interface ModuleResolution {
|
|
84
|
+
/**
|
|
85
|
+
* 解析策略
|
|
86
|
+
* - importmap: 使用 Import Maps(推荐)
|
|
87
|
+
* - global: 使用全局变量
|
|
88
|
+
* - hybrid: 混合模式(优先 importmap,失败降级 global/cdn)
|
|
89
|
+
*/
|
|
90
|
+
strategy: 'importmap' | 'global' | 'hybrid';
|
|
91
|
+
/**
|
|
92
|
+
* Import Map(strategy 为 importmap 或 hybrid 时可用)
|
|
93
|
+
*
|
|
94
|
+
* importMap 与 importMapFile 二选一即可。
|
|
95
|
+
*/
|
|
96
|
+
importMap?: ImportMap;
|
|
97
|
+
/**
|
|
98
|
+
* Import Map 文件路径(可选)
|
|
99
|
+
* 如果提供此字段,运行时将尝试从指定路径加载 Import Map 配置
|
|
100
|
+
* @example "./importmap.json"
|
|
101
|
+
*/
|
|
102
|
+
importMapFile?: string;
|
|
103
|
+
/**
|
|
104
|
+
* 外部依赖(可选)
|
|
105
|
+
* 声明由宿主环境提供的依赖
|
|
106
|
+
*
|
|
107
|
+
* 约束建议:
|
|
108
|
+
* - 同一个 id 不要写两条 externals(避免歧义)
|
|
109
|
+
* - 需要“importmap + global”时,用 strategy=hybrid + fallback 表达“主 + 兜底”
|
|
110
|
+
*/
|
|
111
|
+
externals?: ExternalDep[];
|
|
112
|
+
/**
|
|
113
|
+
* 基础路径(可选)
|
|
114
|
+
* 影响 importMapFile、相对 URL 等解析
|
|
115
|
+
* @example "./" | "/static/cic/" | "https://cdn.example.com/cic/"
|
|
116
|
+
*/
|
|
117
|
+
baseURL?: string;
|
|
118
|
+
/**
|
|
119
|
+
* 预加载模块(可选)
|
|
120
|
+
* @example ["vue","vue-router"]
|
|
121
|
+
*/
|
|
122
|
+
preload?: string[];
|
|
123
|
+
/**
|
|
124
|
+
* 模块别名(可选)
|
|
125
|
+
* @example { "@/": "./src/", "@components/": "./src/components/" }
|
|
126
|
+
*/
|
|
127
|
+
alias?: Record<string, string>;
|
|
128
|
+
/**
|
|
129
|
+
* 降级策略(可选)
|
|
130
|
+
*
|
|
131
|
+
* 当 strategy=hybrid 且 importmap 解析/加载失败时的兜底方案。
|
|
132
|
+
* @example { "strategy": "global", "mapping": { "vue": "window.Vue" } }
|
|
133
|
+
*/
|
|
134
|
+
fallback?: ModuleFallback;
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Import Map 配置
|
|
138
|
+
*/
|
|
139
|
+
export interface ImportMap {
|
|
140
|
+
/**
|
|
141
|
+
* 模块映射
|
|
142
|
+
*/
|
|
143
|
+
imports: Record<string, string>;
|
|
144
|
+
/**
|
|
145
|
+
* 作用域映射(可选)
|
|
146
|
+
*/
|
|
147
|
+
scopes?: Record<string, Record<string, string>>;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* 外部依赖声明
|
|
151
|
+
*/
|
|
152
|
+
export interface ExternalDep {
|
|
153
|
+
/**
|
|
154
|
+
* 模块 ID
|
|
155
|
+
* @example "vue" | "@arco-design/web-vue"
|
|
156
|
+
*/
|
|
157
|
+
id: string;
|
|
158
|
+
/**
|
|
159
|
+
* 提供方式
|
|
160
|
+
* - global: 全局变量
|
|
161
|
+
* - import: 通过 importmap
|
|
162
|
+
* - cdn: CDN 加载
|
|
163
|
+
*/
|
|
164
|
+
provide: 'global' | 'import' | 'cdn';
|
|
165
|
+
/**
|
|
166
|
+
* 全局变量路径(provide 为 global 时)
|
|
167
|
+
* @example "window.Vue" | "wx" | "globalThis.echarts"
|
|
168
|
+
*/
|
|
169
|
+
global?: string;
|
|
170
|
+
/**
|
|
171
|
+
* CDN URL(provide 为 cdn 时)
|
|
172
|
+
* @example "https://cdn.jsdelivr.net/npm/echarts@5/dist/echarts.min.js"
|
|
173
|
+
*/
|
|
174
|
+
url?: string;
|
|
175
|
+
/**
|
|
176
|
+
* 版本约束(可选)
|
|
177
|
+
* @example "^3.0.0"
|
|
178
|
+
*/
|
|
179
|
+
version?: string;
|
|
180
|
+
/**
|
|
181
|
+
* 是否必需(可选)
|
|
182
|
+
* @default true
|
|
183
|
+
*/
|
|
184
|
+
required?: boolean;
|
|
185
|
+
/**
|
|
186
|
+
* 可用性校验(可选)
|
|
187
|
+
* 用于判断 global/cdn 是否已就绪
|
|
188
|
+
* @example "typeof window.Vue !== 'undefined'"
|
|
189
|
+
*/
|
|
190
|
+
checkScript?: string;
|
|
191
|
+
/**
|
|
192
|
+
* 依赖项(可选)
|
|
193
|
+
*
|
|
194
|
+
* 说明:这里用于表达“加载顺序/前置条件”,不是 CICConfig.deps 的替代品。
|
|
195
|
+
* @example ["vue"]
|
|
196
|
+
*/
|
|
197
|
+
dependencies?: string[];
|
|
198
|
+
}
|
|
199
|
+
/**
|
|
200
|
+
* 模块降级配置
|
|
201
|
+
*/
|
|
202
|
+
export interface ModuleFallback {
|
|
203
|
+
/**
|
|
204
|
+
* 兜底策略
|
|
205
|
+
* - global: 从全局变量读取
|
|
206
|
+
* - cdn: 走备用 CDN
|
|
207
|
+
*/
|
|
208
|
+
strategy: 'global' | 'cdn';
|
|
209
|
+
/**
|
|
210
|
+
* 映射:模块 id -> 全局路径或 CDN 相对路径
|
|
211
|
+
* @example { "vue": "window.Vue" }
|
|
212
|
+
*/
|
|
213
|
+
mapping?: Record<string, string>;
|
|
214
|
+
/**
|
|
215
|
+
* CDN 基础路径(strategy=cdn 时可用)
|
|
216
|
+
* @example "https://backup-cdn.example.com/libs/"
|
|
217
|
+
*/
|
|
218
|
+
cdnBase?: string;
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* 组件配置
|
|
222
|
+
*/
|
|
223
|
+
export interface ComponentConfig {
|
|
224
|
+
/**
|
|
225
|
+
* 默认策略(可选)
|
|
226
|
+
* - global: 全局注册
|
|
227
|
+
* - local: 局部注册
|
|
228
|
+
* - lazy: 懒加载
|
|
229
|
+
* @default "global"
|
|
230
|
+
*/
|
|
231
|
+
strategy?: 'global' | 'local' | 'lazy';
|
|
232
|
+
/**
|
|
233
|
+
* 组件适配器
|
|
234
|
+
* 为特定组件定义加载规则
|
|
235
|
+
*/
|
|
236
|
+
adapters?: ComponentAdapter[];
|
|
237
|
+
/**
|
|
238
|
+
* 全局注册前缀(可选)
|
|
239
|
+
* @example "Cic"
|
|
240
|
+
*/
|
|
241
|
+
prefix?: string;
|
|
242
|
+
/**
|
|
243
|
+
* 命名规则(可选)
|
|
244
|
+
* @example "kebab-case" | "PascalCase" | "camelCase"
|
|
245
|
+
*/
|
|
246
|
+
naming?: 'kebab-case' | 'PascalCase' | 'camelCase' | string;
|
|
247
|
+
/**
|
|
248
|
+
* 简易注册表(可选)
|
|
249
|
+
*
|
|
250
|
+
* 组件名 -> 模块 id/路径
|
|
251
|
+
* @example { "ECharts": "@anov/charts", "DataTable": "@anov/components" }
|
|
252
|
+
*/
|
|
253
|
+
registry?: Record<string, string>;
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* 组件适配器
|
|
257
|
+
*/
|
|
258
|
+
export interface ComponentAdapter {
|
|
259
|
+
/**
|
|
260
|
+
* 匹配模式
|
|
261
|
+
* 支持通配符
|
|
262
|
+
* @example "echarts" | "@arco-design/*" | "*"
|
|
263
|
+
*/
|
|
264
|
+
match: string;
|
|
265
|
+
/**
|
|
266
|
+
* 适配器类型
|
|
267
|
+
* - plugin: Vue/React 插件(install/use)
|
|
268
|
+
* - component: 单个组件
|
|
269
|
+
* - module: 需要初始化的模块(init 等)
|
|
270
|
+
* - global: 全局对象(window.echarts 等)
|
|
271
|
+
*/
|
|
272
|
+
kind: 'plugin' | 'component' | 'module' | 'global';
|
|
273
|
+
/**
|
|
274
|
+
* 注册配置(可选)
|
|
275
|
+
*
|
|
276
|
+
* 用于解决不同组件库/组件需要不同调用方式的问题:
|
|
277
|
+
* - install/use:插件注册
|
|
278
|
+
* - init:模块初始化
|
|
279
|
+
* - register:自定义注册
|
|
280
|
+
*/
|
|
281
|
+
register?: {
|
|
282
|
+
/**
|
|
283
|
+
* 注册方法
|
|
284
|
+
* @example "install" | "use" | "init" | "register"
|
|
285
|
+
*/
|
|
286
|
+
method?: string;
|
|
287
|
+
/**
|
|
288
|
+
* 注册目标
|
|
289
|
+
* @example "app" | "Vue" | "window"
|
|
290
|
+
*/
|
|
291
|
+
target?: string;
|
|
292
|
+
/**
|
|
293
|
+
* 初始化参数
|
|
294
|
+
*/
|
|
295
|
+
options?: Record<string, any>;
|
|
296
|
+
};
|
|
297
|
+
/**
|
|
298
|
+
* 是否必需(可选)
|
|
299
|
+
* @default true
|
|
300
|
+
*/
|
|
301
|
+
required?: boolean;
|
|
302
|
+
/**
|
|
303
|
+
* 依赖项(可选)
|
|
304
|
+
*
|
|
305
|
+
* 说明:这里的 dependencies 仅用于表达“组件注册/初始化”的前置依赖(顺序/就绪条件),
|
|
306
|
+
* 不是 CICConfig.deps 的替代品。
|
|
307
|
+
* @example ["vue"]
|
|
308
|
+
*/
|
|
309
|
+
dependencies?: string[];
|
|
310
|
+
/**
|
|
311
|
+
* 是否异步(可选)
|
|
312
|
+
* @default false
|
|
313
|
+
*/
|
|
314
|
+
async?: boolean;
|
|
315
|
+
/**
|
|
316
|
+
* 组件实例初始化(可选)
|
|
317
|
+
*
|
|
318
|
+
* 场景:某些组件在渲染后默认隐藏,需要对组件“实例”主动调用 init 才会显示/运行。
|
|
319
|
+
*
|
|
320
|
+
* 前提(以 Vue3 为例):组件需要通过 expose 暴露出 init 方法,运行时装配器通过 ref/proxy
|
|
321
|
+
* 拿到实例后执行调用。
|
|
322
|
+
*/
|
|
323
|
+
instanceInit?: {
|
|
324
|
+
/**
|
|
325
|
+
* 触发时机
|
|
326
|
+
* - mounted: 组件挂载完成后
|
|
327
|
+
* - ready: 运行时认为实例可用时(框架自定义时机)
|
|
328
|
+
* @default "mounted"
|
|
329
|
+
*/
|
|
330
|
+
when?: 'mounted' | 'ready';
|
|
331
|
+
/**
|
|
332
|
+
* 要调用的实例方法名
|
|
333
|
+
* @example "init"
|
|
334
|
+
*/
|
|
335
|
+
method: string;
|
|
336
|
+
/**
|
|
337
|
+
* 初始化参数(可选)
|
|
338
|
+
*/
|
|
339
|
+
options?: Record<string, any>;
|
|
340
|
+
/**
|
|
341
|
+
* 调用前的就绪判断(可选)
|
|
342
|
+
* @example "typeof instance.init === 'function'"
|
|
343
|
+
*/
|
|
344
|
+
guard?: string;
|
|
345
|
+
};
|
|
346
|
+
/**
|
|
347
|
+
* 全局对象名称(kind=global 时可用)
|
|
348
|
+
* @example "echarts"
|
|
349
|
+
*/
|
|
350
|
+
globalName?: string;
|
|
351
|
+
}
|
|
352
|
+
export interface ManifestExportConfig {
|
|
353
|
+
/**
|
|
354
|
+
* 导出 CIC Config 时,从 config.deps 中排除这些依赖 id
|
|
355
|
+
* @example ["vue","vue-router","pinia"]
|
|
356
|
+
*/
|
|
357
|
+
excludeDeps?: string[];
|
|
358
|
+
/**
|
|
359
|
+
* 说明原因(可选)
|
|
360
|
+
* @example "由宿主统一注入"
|
|
361
|
+
*/
|
|
362
|
+
reason?: string;
|
|
363
|
+
}
|
|
364
|
+
export declare const CICManifestExample: CICManifest;
|
|
365
|
+
export declare const CICManifestMinimal: CICManifest;
|
|
366
|
+
export declare const CICManifestReact: CICManifest;
|
|
367
|
+
export declare const CICManifestMiniProgram: CICManifest;
|
|
@@ -1,17 +1,19 @@
|
|
|
1
1
|
import { CICEventMap } from './events';
|
|
2
2
|
import { Data } from './data';
|
|
3
|
+
import { JSFormat } from './deps';
|
|
3
4
|
/** 通用表达式(用于条件、模板等) */
|
|
4
5
|
export type Expr = string;
|
|
5
6
|
/** 样式值可以是静态或表达式 */
|
|
6
7
|
export type StyleValue = string | number | Expr;
|
|
7
8
|
/** component 引用:字符串或 object 描述 */
|
|
8
9
|
export type ComponentRef = string | {
|
|
9
|
-
type:
|
|
10
|
+
type: 'id';
|
|
10
11
|
value: string;
|
|
11
12
|
};
|
|
12
13
|
export type LogicRef = string | {
|
|
13
|
-
type:
|
|
14
|
+
type: 'url' | 'code';
|
|
14
15
|
value: string;
|
|
16
|
+
format?: JSFormat;
|
|
15
17
|
};
|
|
16
18
|
/**
|
|
17
19
|
* 组件的语义分类(view/container/logic)
|
package/dist/types/data.d.ts
CHANGED
|
@@ -5,18 +5,19 @@ export interface DataSourceBase {
|
|
|
5
5
|
order?: number;
|
|
6
6
|
pollInterval?: Milliseconds;
|
|
7
7
|
transform?: string | ((res: any) => any);
|
|
8
|
+
extensions?: Record<string, any>;
|
|
8
9
|
}
|
|
9
10
|
export interface DataSourceRest extends DataSourceBase {
|
|
10
|
-
type:
|
|
11
|
+
type: 'rest';
|
|
11
12
|
url: string;
|
|
12
|
-
method:
|
|
13
|
+
method: 'GET' | 'POST' | 'PUT' | 'DELETE';
|
|
13
14
|
headers?: Record<string, string>;
|
|
14
15
|
params?: Record<string, any>;
|
|
15
16
|
body?: any;
|
|
16
17
|
timeout?: Milliseconds;
|
|
17
18
|
}
|
|
18
19
|
export interface DataSourceWebSocket extends DataSourceBase {
|
|
19
|
-
type:
|
|
20
|
+
type: 'websocket';
|
|
20
21
|
url: string;
|
|
21
22
|
protocols?: string | string[];
|
|
22
23
|
subscribeMessage?: any;
|
|
@@ -26,11 +27,11 @@ export interface DataSourceWebSocket extends DataSourceBase {
|
|
|
26
27
|
};
|
|
27
28
|
}
|
|
28
29
|
export interface DataSourceStatic extends DataSourceBase {
|
|
29
|
-
type:
|
|
30
|
+
type: 'static';
|
|
30
31
|
value: any;
|
|
31
32
|
}
|
|
32
33
|
export interface DataSourceFunction extends DataSourceBase {
|
|
33
|
-
type:
|
|
34
|
+
type: 'function';
|
|
34
35
|
code: string;
|
|
35
36
|
timeout?: Milliseconds;
|
|
36
37
|
}
|
package/dist/types/deps.d.ts
CHANGED
|
@@ -12,7 +12,7 @@ export interface BaseDependency {
|
|
|
12
12
|
name?: string;
|
|
13
13
|
/** 版本号(语义化版本 / 字体权重皆可) */
|
|
14
14
|
version?: string;
|
|
15
|
-
/** 资源 URL
|
|
15
|
+
/** 资源 URL,服务器或CDN地址 */
|
|
16
16
|
url?: string;
|
|
17
17
|
/** 本地路径(构建后使用) */
|
|
18
18
|
localPath?: string;
|
|
@@ -28,6 +28,7 @@ export interface BaseDependency {
|
|
|
28
28
|
/** 仅在某些条件下加载(如主题) */
|
|
29
29
|
when?: string;
|
|
30
30
|
};
|
|
31
|
+
extensions?: Record<string, any>;
|
|
31
32
|
}
|
|
32
33
|
/** JS 资源 */
|
|
33
34
|
export interface JSDependency extends BaseDependency {
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
/** AUTO-GENERATED BY generate-types.ts — DO NOT EDIT MANUALLY */
|
|
2
|
+
export * from './adapter';
|
|
3
|
+
export * from './cic.manifest';
|
|
2
4
|
export * from './cic';
|
|
3
5
|
export * from './components';
|
|
4
6
|
export * from './data';
|
|
@@ -8,4 +10,5 @@ export * from './events';
|
|
|
8
10
|
export * from './meta';
|
|
9
11
|
export * from './page';
|
|
10
12
|
export * from './registry';
|
|
13
|
+
export * from './runtime.manifest';
|
|
11
14
|
export * from './variables';
|