@lemon-fe/vite-plugin-micro-frontend 1.0.7 → 1.0.9
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/index.d.ts +4 -18
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/dist/runtime.d.ts +15 -42
- package/dist/runtime.js +27853 -254
- package/dist/runtime.js.map +1 -1
- package/package.json +3 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,70 +1,43 @@
|
|
|
1
1
|
import { ComponentType } from 'react';
|
|
2
2
|
|
|
3
|
-
/**
|
|
4
|
-
* qiankun 运行时导出(浏览器端使用)
|
|
5
|
-
* 这个文件不应该包含任何 Node.js 模块
|
|
6
|
-
*/
|
|
7
3
|
interface QiankunProps {
|
|
8
4
|
container?: HTMLElement;
|
|
9
5
|
[x: string]: any;
|
|
10
6
|
}
|
|
11
7
|
type QiankunLifeCycle = {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
8
|
+
renderContainer: (props: QiankunProps) => Promise<void>;
|
|
9
|
+
bootstrap?: () => void | Promise<void>;
|
|
10
|
+
mount?: (props: QiankunProps) => void | Promise<void>;
|
|
11
|
+
unmount?: (props: QiankunProps) => void | Promise<void>;
|
|
12
|
+
update?: (props: QiankunProps) => void | Promise<void>;
|
|
16
13
|
};
|
|
17
14
|
interface QiankunWindow {
|
|
18
15
|
__POWERED_BY_QIANKUN__?: boolean;
|
|
19
16
|
[x: string]: any;
|
|
20
17
|
}
|
|
21
18
|
declare const qiankunWindow: QiankunWindow;
|
|
22
|
-
|
|
19
|
+
/**
|
|
20
|
+
* 渲染乾坤微应用
|
|
21
|
+
* 自动从 index.html 中查找第一个带 id 的 div 作为挂载容器
|
|
22
|
+
* @param qiankunLifeCycle 生命周期钩子
|
|
23
|
+
*/
|
|
24
|
+
declare const renderWithQiankun: (
|
|
25
|
+
/** 生命周期钩子 */
|
|
26
|
+
qiankunLifeCycle: QiankunLifeCycle) => void;
|
|
23
27
|
|
|
24
28
|
interface DynamicOptions<P = Record<string, unknown>> {
|
|
25
29
|
/** 动态加载函数,返回一个包含 default 导出的 Promise */
|
|
26
30
|
loader: () => Promise<{
|
|
27
31
|
default: ComponentType<P>;
|
|
28
32
|
}>;
|
|
29
|
-
/**
|
|
33
|
+
/** 加载中/加载失败时显示的组件 */
|
|
30
34
|
loading?: ComponentType<any>;
|
|
31
35
|
}
|
|
32
36
|
/**
|
|
33
37
|
* 封装动态导入函数,兼容 Umi 的 dynamic
|
|
34
38
|
*
|
|
35
|
-
* 特性:
|
|
36
|
-
* - 当 chunk 加载失败时(如部署后旧文件不存在),会通过 manifest.json 映射加载最新 chunk
|
|
37
|
-
* - 无需刷新整个页面,适合微前端场景
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* ```tsx
|
|
41
|
-
* import { dynamic } from '@lemon-fe/vite-plugin-micro-frontend/runtime';
|
|
42
|
-
*
|
|
43
|
-
* // 使用 dynamic
|
|
44
|
-
* const MyComponent = dynamic({
|
|
45
|
-
* loader: () => import('./MyComponent'),
|
|
46
|
-
* loading: LoadingComponent,
|
|
47
|
-
* });
|
|
48
|
-
* ```
|
|
49
39
|
*/
|
|
50
40
|
declare function dynamic<P = Record<string, unknown>>(options: DynamicOptions<P>): ComponentType<P>;
|
|
51
|
-
/**
|
|
52
|
-
* 预加载并缓存 manifest.json
|
|
53
|
-
* 建议在应用启动时调用,这样当 chunk 加载失败时可以通过缓存的旧 manifest 找到源文件路径
|
|
54
|
-
*
|
|
55
|
-
* @param baseUrl 应用的 base URL,如 'https://dev.lemengcloud.com/app-wms' 或 '/app-wms'
|
|
56
|
-
*
|
|
57
|
-
* @example
|
|
58
|
-
* ```tsx
|
|
59
|
-
* import { preloadManifest } from '@lemon-fe/vite-plugin-micro-frontend/dynamic';
|
|
60
|
-
*
|
|
61
|
-
* // 在应用入口处调用
|
|
62
|
-
* preloadManifest('/app-wms');
|
|
63
|
-
* // 或者使用完整 URL
|
|
64
|
-
* preloadManifest('https://dev.lemengcloud.com/app-wms');
|
|
65
|
-
* ```
|
|
66
|
-
*/
|
|
67
|
-
declare function preloadManifest(baseUrl: string): Promise<void>;
|
|
68
41
|
|
|
69
|
-
export { dynamic,
|
|
42
|
+
export { dynamic, qiankunWindow, renderWithQiankun };
|
|
70
43
|
export type { DynamicOptions, QiankunLifeCycle, QiankunProps, QiankunWindow };
|