@lemon-fe/vite-plugin-micro-frontend 1.0.7 → 1.0.8
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 +7 -41
- package/dist/runtime.js +27837 -260
- package/dist/runtime.js.map +1 -1
- package/package.json +3 -1
package/dist/runtime.d.ts
CHANGED
|
@@ -1,18 +1,15 @@
|
|
|
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;
|
|
@@ -26,45 +23,14 @@ interface DynamicOptions<P = Record<string, unknown>> {
|
|
|
26
23
|
loader: () => Promise<{
|
|
27
24
|
default: ComponentType<P>;
|
|
28
25
|
}>;
|
|
29
|
-
/**
|
|
26
|
+
/** 加载中/加载失败时显示的组件 */
|
|
30
27
|
loading?: ComponentType<any>;
|
|
31
28
|
}
|
|
32
29
|
/**
|
|
33
30
|
* 封装动态导入函数,兼容 Umi 的 dynamic
|
|
34
31
|
*
|
|
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
32
|
*/
|
|
50
33
|
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
34
|
|
|
69
|
-
export { dynamic,
|
|
35
|
+
export { dynamic, qiankunWindow, renderWithQiankun };
|
|
70
36
|
export type { DynamicOptions, QiankunLifeCycle, QiankunProps, QiankunWindow };
|