@anov/cic-standard-sdk 0.0.20 → 0.0.21
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 +8 -7
- package/dist/cic-sdk.es.js +2731 -2461
- package/dist/cic-sdk.umd.js +8 -7
- package/dist/sdk/CICSDK.d.ts +5 -0
- package/dist/sdk/manifestLoader/index.d.ts +87 -0
- package/dist/sdk/render/index.d.ts +68 -6
- package/dist/types/components.d.ts +2 -4
- package/dist/types/index.d.ts +3 -3
- package/dist/types/manifest/adapter.d.ts +235 -0
- package/dist/types/manifest/cic.manifest.d.ts +476 -0
- package/dist/types/manifest/runtime.manifest.d.ts +549 -0
- package/package.json +1 -1
- package/dist/types/adapter.d.ts +0 -385
- package/dist/types/cic.manifest.d.ts +0 -367
- package/dist/types/runtime.manifest.d.ts +0 -265
|
@@ -1,367 +0,0 @@
|
|
|
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,265 +0,0 @@
|
|
|
1
|
-
import type { CICManifest } from './cic.manifest';
|
|
2
|
-
/**
|
|
3
|
-
* runtime.manifest.d.ts
|
|
4
|
-
*
|
|
5
|
-
* runtime.manifest.json 的完整 TypeScript 类型定义。
|
|
6
|
-
*
|
|
7
|
-
* 对应概念:
|
|
8
|
-
* RuntimeManifest —— 顶层结构(供给表)
|
|
9
|
-
* CICManifest —— cic.manifest.json 的类型(需求表)
|
|
10
|
-
* ResolvedManifest —— loader 完成匹配后写入 window.__MANIFEST__ 的结构
|
|
11
|
-
*/
|
|
12
|
-
/** semver 版本字符串,如 "3.4.21" */
|
|
13
|
-
type SemverString = string;
|
|
14
|
-
/** semver 版本范围,如 "^3.0.0" "~1.2.0" "4.x" */
|
|
15
|
-
type SemverRange = string;
|
|
16
|
-
/** 相对或绝对 URL 路径 */
|
|
17
|
-
type UrlPath = string;
|
|
18
|
-
/** ES 模块 import specifier,如 "vue" "@anov/core" "cdn/button" */
|
|
19
|
-
type ModuleSpecifier = string;
|
|
20
|
-
/** window 上的属性路径,如 "Vue" "echarts" "MyLib.Core" */
|
|
21
|
-
type WindowPath = string;
|
|
22
|
-
/**
|
|
23
|
-
* 脚本文件格式。
|
|
24
|
-
* 决定 manifest-loader 用何种方式加载该文件:
|
|
25
|
-
* umd → <script src> 执行后将自身挂到 window
|
|
26
|
-
* esm → fetch + blob URL 或 importMap 直接映射
|
|
27
|
-
*/
|
|
28
|
-
type BindingFormat = 'umd' | 'esm';
|
|
29
|
-
/**
|
|
30
|
-
* Global binding:将依赖以 UMD/IIFE 形式挂载到 window 上。
|
|
31
|
-
*
|
|
32
|
-
* 使用场景:
|
|
33
|
-
* - 应用代码通过 window.Vue / window.echarts 访问
|
|
34
|
-
* - 需要 shimB(global → esm)时作为 UMD 源
|
|
35
|
-
*/
|
|
36
|
-
interface GlobalBinding {
|
|
37
|
-
/**
|
|
38
|
-
* 挂载到 window 上的属性路径。
|
|
39
|
-
* 支持链式路径,如 "MyLib.Core"(对应 window.MyLib.Core)。
|
|
40
|
-
*/
|
|
41
|
-
window: WindowPath;
|
|
42
|
-
/**
|
|
43
|
-
* 开发模式下的脚本路径(本地文件系统或 devServer 路径)。
|
|
44
|
-
* runtime.engine.mode === 'development' 时使用。
|
|
45
|
-
*/
|
|
46
|
-
src: UrlPath;
|
|
47
|
-
/**
|
|
48
|
-
* 生产模式下的脚本路径。
|
|
49
|
-
* runtime.engine.mode !== 'development' 时使用。
|
|
50
|
-
* null 表示生产模式由宿主环境注入,loader 不负责加载。
|
|
51
|
-
*/
|
|
52
|
-
prodSrc?: UrlPath | null;
|
|
53
|
-
/**
|
|
54
|
-
* 文件格式。
|
|
55
|
-
* 未填时 loader 尝试从文件名猜测(.mjs/.esm → esm,其余 → umd)。
|
|
56
|
-
* 强烈建议显式声明,避免猜测错误。
|
|
57
|
-
*/
|
|
58
|
-
format?: BindingFormat;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* ESM binding:将依赖注册到 importMap,供 import specifier 使用。
|
|
62
|
-
*
|
|
63
|
-
* 使用场景:
|
|
64
|
-
* - 应用代码通过 import { ref } from 'vue' 访问
|
|
65
|
-
* - importMap 直接映射 specifier → 物理文件路径
|
|
66
|
-
*/
|
|
67
|
-
interface EsmBinding {
|
|
68
|
-
/**
|
|
69
|
-
* 注册到 importMap 的键名(import specifier)。
|
|
70
|
-
* 如 "vue"、"@anov/core"、"cdn/button"。
|
|
71
|
-
*/
|
|
72
|
-
specifier: ModuleSpecifier;
|
|
73
|
-
/**
|
|
74
|
-
* 开发模式下的 ESM 文件路径。
|
|
75
|
-
*/
|
|
76
|
-
src: UrlPath;
|
|
77
|
-
/**
|
|
78
|
-
* 生产模式下的 ESM 文件路径。
|
|
79
|
-
* null 表示生产模式由宿主的 importMap 提供,loader 不注册。
|
|
80
|
-
*/
|
|
81
|
-
prodSrc?: UrlPath | null;
|
|
82
|
-
/**
|
|
83
|
-
* 文件格式,ESM binding 固定为 'esm'。
|
|
84
|
-
* 显式声明可避免 loader 误判。
|
|
85
|
-
*/
|
|
86
|
-
format?: 'esm';
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* 一个依赖可以同时提供 global 和 esm 两种 binding,
|
|
90
|
-
* 也可以只提供其中一种。
|
|
91
|
-
*
|
|
92
|
-
* loader 会根据需求方(cic.external)声明的 consume 类型,
|
|
93
|
-
* 选择合适的 binding,必要时自动插入 shim:
|
|
94
|
-
*
|
|
95
|
-
* 供给 global + 需求 esm → shimB(global → esm data: URL)
|
|
96
|
-
* 供给 esm + 需求 global → shimA(import() 后挂到 window)
|
|
97
|
-
*/
|
|
98
|
-
interface ProvideBindings {
|
|
99
|
-
global?: GlobalBinding;
|
|
100
|
-
esm?: EsmBinding;
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* 依赖的导出接口声明。
|
|
104
|
-
*
|
|
105
|
-
* 主要用于 shimB 场景:当 global binding 需要被转换为 ESM 时,
|
|
106
|
-
* loader 需要知道该库导出了哪些具名符号,才能生成完整的 shim 模块:
|
|
107
|
-
*
|
|
108
|
-
* const __m = window['Vue']
|
|
109
|
-
* export default __m
|
|
110
|
-
* export const { ref, reactive, computed, ... } = __m ← 来自 named
|
|
111
|
-
*
|
|
112
|
-
* 若 named 为空,shim 只有 default export,
|
|
113
|
-
* import { ref } from 'vue' 将返回 undefined。
|
|
114
|
-
*/
|
|
115
|
-
interface ExportsDeclaration {
|
|
116
|
-
/**
|
|
117
|
-
* 具名导出列表。
|
|
118
|
-
* shimB 场景下用于生成 export const { ... } = __m 语句。
|
|
119
|
-
*/
|
|
120
|
-
named: string[];
|
|
121
|
-
/**
|
|
122
|
-
* 是否有 default export。
|
|
123
|
-
* true → export default __m
|
|
124
|
-
* false → 无 default(如 pinia,只有具名导出)
|
|
125
|
-
*/
|
|
126
|
-
default: boolean;
|
|
127
|
-
}
|
|
128
|
-
/**
|
|
129
|
-
* runtime 能提供的一个依赖的完整描述。
|
|
130
|
-
* provides 字典的值类型。
|
|
131
|
-
*/
|
|
132
|
-
interface ProvideEntry {
|
|
133
|
-
/** 该依赖的实际版本号(具体版本,如 "3.4.21")。用于与需求方的版本范围做校验。 */
|
|
134
|
-
version: SemverString;
|
|
135
|
-
/**
|
|
136
|
-
* 导出接口声明。
|
|
137
|
-
* shimB 场景必填,否则生成的 shim 模块缺少具名导出。
|
|
138
|
-
*/
|
|
139
|
-
exports?: ExportsDeclaration;
|
|
140
|
-
/**
|
|
141
|
-
* 供给形态。至少声明一种:
|
|
142
|
-
* 只有 global → 只能满足 consume: 'global',consume: 'esm' 需走 shimB
|
|
143
|
-
* 只有 esm → 只能满足 consume: 'esm', consume: 'global' 需走 shimA
|
|
144
|
-
* 两种都有 → 直连满足所有需求,无需 shim(性能最优)
|
|
145
|
-
*/
|
|
146
|
-
bindings: ProvideBindings;
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* 标准 importMap 结构(W3C 规范子集)。
|
|
150
|
-
* 目前只使用 imports,暂不支持 scopes。
|
|
151
|
-
*/
|
|
152
|
-
interface ImportMap {
|
|
153
|
-
/**
|
|
154
|
-
* specifier → URL 的映射表。
|
|
155
|
-
* 支持路径前缀映射(键以 "/" 结尾),如 "cdn/" → "./anov-prod/mgt/ui/"。
|
|
156
|
-
*/
|
|
157
|
-
imports: Record<ModuleSpecifier, UrlPath>;
|
|
158
|
-
}
|
|
159
|
-
type EnginePlatform = 'web' | 'electron' | 'miniapp';
|
|
160
|
-
type EngineRuntime = 'vue3' | 'vue2' | 'react' | 'svelte';
|
|
161
|
-
type EngineMode = 'development' | 'production' | 'staging';
|
|
162
|
-
interface EngineDescriptor {
|
|
163
|
-
/** 运行平台 */
|
|
164
|
-
platform: EnginePlatform;
|
|
165
|
-
/** JS 框架运行时 */
|
|
166
|
-
runtime: EngineRuntime;
|
|
167
|
-
/** 框架版本范围(semver range) */
|
|
168
|
-
version: SemverRange;
|
|
169
|
-
/**
|
|
170
|
-
* 运行模式。
|
|
171
|
-
* loader 根据此字段决定使用 binding.src 还是 binding.prodSrc。
|
|
172
|
-
*/
|
|
173
|
-
mode: EngineMode;
|
|
174
|
-
/**
|
|
175
|
-
* 开发服务器基础 URL。
|
|
176
|
-
* mode === 'development' 时有效,用于拼接相对路径的绝对地址。
|
|
177
|
-
*/
|
|
178
|
-
baseURL?: string;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
|
-
* 运行时环境变量表。
|
|
182
|
-
* loader 将其展开到 window.__ENV__。
|
|
183
|
-
* cic.manifest 中的同名字段会覆盖 runtime 的默认值。
|
|
184
|
-
*/
|
|
185
|
-
type EnvRecord = Record<string, string | number | boolean>;
|
|
186
|
-
/**
|
|
187
|
-
* runtime.manifest.json 的完整结构。
|
|
188
|
-
*
|
|
189
|
-
* 定位:平台/运行时的"供给表",描述运行环境能提供什么。
|
|
190
|
-
* 与 cic.manifest.json(应用"需求表")相对,由 manifest-loader 完成匹配。
|
|
191
|
-
*/
|
|
192
|
-
export interface RuntimeManifest {
|
|
193
|
-
/**
|
|
194
|
-
* manifest 文件自身的版本号。
|
|
195
|
-
* 用于 loader 做格式兼容判断,遵循 semver。
|
|
196
|
-
*/
|
|
197
|
-
version: SemverString;
|
|
198
|
-
/** 运行时引擎描述 */
|
|
199
|
-
engine: EngineDescriptor;
|
|
200
|
-
/**
|
|
201
|
-
* 依赖供给表。
|
|
202
|
-
* key 为依赖 id(通常与 npm 包名一致),value 为供给描述。
|
|
203
|
-
*
|
|
204
|
-
* @example
|
|
205
|
-
* {
|
|
206
|
-
* "vue": { version: "3.4.21", bindings: { esm: { specifier: "vue", src: "..." } } },
|
|
207
|
-
* "@anov/core": { ... }
|
|
208
|
-
* }
|
|
209
|
-
*/
|
|
210
|
-
provides: Record<string, ProvideEntry>;
|
|
211
|
-
/**
|
|
212
|
-
* 基础 importMap。
|
|
213
|
-
* 通常用于声明路径前缀映射(如 "cdn/" → 本地路径),
|
|
214
|
-
* 不包含具体依赖的 specifier 映射(由 provides 动态生成)。
|
|
215
|
-
*
|
|
216
|
-
* 合并优先级(低 → 高):
|
|
217
|
-
* runtime.importMap < 供需匹配生成 < cic.modules.importMap
|
|
218
|
-
*/
|
|
219
|
-
importMap?: ImportMap;
|
|
220
|
-
/**
|
|
221
|
-
* 运行时默认环境变量。
|
|
222
|
-
* cic.env 中的同名字段会覆盖此处的值。
|
|
223
|
-
*/
|
|
224
|
-
env?: EnvRecord;
|
|
225
|
-
/**
|
|
226
|
-
* importMap 注入后需要预加载的模块路径列表。
|
|
227
|
-
*
|
|
228
|
-
* ⚠️ 不能写在 HTML 的 <link rel="modulepreload"> 里,原因:
|
|
229
|
-
* HTML 解析阶段触发 modulepreload 时 importMap 尚未存在,
|
|
230
|
-
* 模块图中的 specifier 无法映射,导致解析失败。
|
|
231
|
-
* 由 loader 在 importMap 注入后动态插入,才能保证正确解析。
|
|
232
|
-
*
|
|
233
|
-
* 通常包含运行时核心的 vendor chunk、libs chunk 和入口 chunk。
|
|
234
|
-
*/
|
|
235
|
-
preload?: UrlPath[];
|
|
236
|
-
/**
|
|
237
|
-
* 默认应用入口模块路径。
|
|
238
|
-
* 若 cic.entry 未声明,loader 使用此值作为 import() 的目标。
|
|
239
|
-
*/
|
|
240
|
-
entry?: UrlPath;
|
|
241
|
-
/** 预留扩展字段,loader 不处理,原样透传到 window.__MANIFEST__.runtime */
|
|
242
|
-
extensions?: Record<string, unknown>;
|
|
243
|
-
}
|
|
244
|
-
/** manifest-loader 完成后写入 window.__MANIFEST__ 的结构 */
|
|
245
|
-
export interface ResolvedManifest {
|
|
246
|
-
/** 原始 runtime.manifest 内容 */
|
|
247
|
-
runtime: RuntimeManifest;
|
|
248
|
-
/** 原始 cic.manifest 内容 */
|
|
249
|
-
cic: CICManifest;
|
|
250
|
-
/** 最终注入到页面的完整 importMap(三方合并结果) */
|
|
251
|
-
importMap: Record<ModuleSpecifier, UrlPath>;
|
|
252
|
-
/** 合并后的环境变量(runtime.env 被 cic.env 覆盖) */
|
|
253
|
-
env: EnvRecord;
|
|
254
|
-
}
|
|
255
|
-
declare global {
|
|
256
|
-
interface Window {
|
|
257
|
-
/** loader 完成后可 await 的 Promise,resolve 值为 ResolvedManifest */
|
|
258
|
-
__manifestReady: Promise<ResolvedManifest>;
|
|
259
|
-
/** loader 完成后写入的完整解析结果 */
|
|
260
|
-
__MANIFEST__: ResolvedManifest;
|
|
261
|
-
/** 合并后的环境变量,等同于 __MANIFEST__.env */
|
|
262
|
-
__ENV__: EnvRecord;
|
|
263
|
-
}
|
|
264
|
-
}
|
|
265
|
-
export {};
|