@anov/cic-standard-sdk 0.0.21 → 0.0.23

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.
@@ -2,7 +2,7 @@ import type { CICConfig, ComponentInstance } from '../types';
2
2
  import { CICInstance } from './CICInstance';
3
3
  import { createBareLoader, createDependencyLoader, getDependencyLoaderSingleton } from './depsLoader';
4
4
  import { Render } from './render';
5
- import { createManifestLoader, resolveManifest } from './manifestLoader';
5
+ import { createManifestLoader, resolveManifest } from '../types/manifest/loader';
6
6
  export * from '../types';
7
7
  export type { Result as GeneratorResult } from './core';
8
8
  /**
@@ -22,7 +22,7 @@ export interface IConverse {
22
22
  /** 转换代码 */
23
23
  code: string;
24
24
  /** 依赖变量列表(用于响应式重执行) */
25
- depeedVars?: Array<string>;
25
+ dependVars?: Array<string>;
26
26
  }>;
27
27
  }
28
28
  /** 数据配置 */
@@ -402,7 +402,7 @@ export interface CICManifest {
402
402
  * local —— 局部注册,仅在声明页面可用(适合业务组件)
403
403
  * lazy —— 懒加载注册,首次使用时才加载(适合大型可选组件)
404
404
  */
405
- strategy?: 'global' | 'local' | 'lazy';
405
+ strategy: 'global' | 'local' | 'lazy';
406
406
  /**
407
407
  * 按 match 精确覆盖注册方式,优先级高于 strategy。
408
408
  * 注册执行顺序:按 dependencies 拓扑排序后顺序执行。
@@ -1,5 +1,5 @@
1
1
  /**
2
- * @file sdk/manifestLoader/index.ts
2
+ * @file types/manifest/loader.ts
3
3
  * @description Manifest 供需匹配核心实现
4
4
  *
5
5
  * ┌─────────────────────────────────────────────────────────────────────┐
@@ -23,8 +23,8 @@
23
23
  * window.__ENV__
24
24
  * window.__manifestReady
25
25
  */
26
- import type { CICManifest } from '../../types/manifest/cic.manifest';
27
- import type { LoaderOptions, ResolvedManifest, RuntimeManifest } from '../../types/manifest/runtime.manifest';
26
+ import type { CICManifest } from './cic.manifest';
27
+ import type { LoaderOptions, ResolvedManifest, RuntimeManifest } from './runtime.manifest';
28
28
  /**
29
29
  * 供需匹配核心函数:将 RuntimeManifest(供给)与 CICManifest(需求)合并
30
30
  *
@@ -48,40 +48,32 @@ import type { LoaderOptions, ResolvedManifest, RuntimeManifest } from '../../typ
48
48
  */
49
49
  export declare function resolveManifest(runtime: RuntimeManifest, cic: CICManifest): ResolvedManifest;
50
50
  /**
51
- * 创建 manifest loader 实例(面向浏览器环境)
52
51
  *
53
- * 职责:
54
- * 1. 并行 fetch runtime.manifest.json 和 cic.manifest.json
55
- * 2. 调用 resolveManifest 完成供需匹配
56
- * 3. 将结果写入 globalThis 的三个全局变量
52
+ * 生成 manifest-loader.js 浏览器脚本的源码字符串。
53
+ * 在构建工具(Vite 插件 / Node.js 脚本)中调用,
54
+ * 将返回值写入 public/manifest-loader.js。
57
55
  *
58
- * 与 manifest-loader.js(浏览器脚本)的分工:
59
- * manifest-loader.js —— 负责 importMap DOM 注入、modulepreload 插入、
60
- * script 加载(shimB/globalTask)、import(entry)
61
- * createManifestLoader —— 负责 JSON 加载和供需逻辑,不操作 DOM
56
+ * 生成的脚本职责:
57
+ * 1. fetch runtime + cic manifest(并行)
58
+ * 2. 供需绑定匹配(resolveBindings)
59
+ * 3. 执行 shimB 任务(必须在 importMap 注入前完成)
60
+ * 4. 合并并注入 importMap(唯一一次,不可重复)
61
+ * 5. 注入 modulepreload(importMap 注入后)
62
+ * 6. 执行 globalTasks(含 shimA)
63
+ * 7. 写入 window.__MANIFEST__ / window.__ENV__(对齐 ResolvedManifest 结构)
64
+ * 8. resolve window.__manifestReady
65
+ * 9. import(entry) 拉起应用
62
66
  *
63
- * 使用示例:
64
- * const loader = createManifestLoader({ runtimeUrl: '/runtime.manifest.json' })
65
- * const resolved = await loader.load()
66
- * console.log(resolved.report.entries)
67
+ * 使用方式:
68
+ * import { CICSDK } from '@anov/cic-standard-sdk'
67
69
  *
68
- * @param options LoaderOptions(所有字段可选,提供合理默认值)
70
+ * // 写文件
71
+ * fs.writeFileSync('public/manifest-loader.js', CICSDK.createManifestLoaderCode())
72
+ *
73
+ * // 或通过 Vite transformIndexHtml 内联(减少一次网络请求)
74
+ * transformIndexHtml(html) {
75
+ * return [{ tag: 'script', children: CICSDK.createManifestLoaderCode(), injectTo: 'head-prepend' }]
76
+ * }
77
+
69
78
  */
70
- export declare function createManifestLoader(options?: LoaderOptions): {
71
- /**
72
- * 加载并解析 manifest,写入全局状态
73
- *
74
- * 写入的全局变量:
75
- * globalThis.__MANIFEST__ ResolvedManifest 完整结果
76
- * globalThis.__ENV__ 合并后的环境变量(快捷访问)
77
- * globalThis.__manifestReady 已 resolve 的 Promise(兼容 await 语法)
78
- *
79
- * 注意:此方法写入的 __manifestReady 是 Promise.resolve(resolved),
80
- * 已经 resolve,不是 manifest-loader.js 中的 pending Promise。
81
- * 两者在不同使用场景下使用,不要混淆。
82
- *
83
- * @throws 网络请求失败(HTTP 非 2xx)
84
- * @throws resolveManifest 内部的版本/依赖校验错误
85
- */
86
- load(): Promise<ResolvedManifest>;
87
- };
79
+ export declare function createManifestLoader(options?: LoaderOptions): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@anov/cic-standard-sdk",
3
- "version": "0.0.21",
3
+ "version": "0.0.23",
4
4
  "description": "CIC Standard SDK with TypeScript support",
5
5
  "main": "dist/cic-sdk.cjs.js",
6
6
  "module": "dist/cic-sdk.es.js",