remote-reload-utils 0.0.8 → 0.0.11

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/CHANGELOG.md ADDED
@@ -0,0 +1,154 @@
1
+ # Changelog
2
+
3
+ 所有重要的项目变更都将记录在此文件中。
4
+
5
+ 格式基于 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.0.0/),
6
+ 项目遵循 [语义化版本](https://semver.org/lang/zh-CN/)。
7
+
8
+ ## [未发布]
9
+
10
+ ## [0.0.11] - 2026-03-16
11
+
12
+ ### Release
13
+
14
+ - Published version 0.0.11 with patch bump
15
+
16
+
17
+ ## [0.0.10] - 2026-03-15
18
+
19
+ ### Release
20
+
21
+ - Published version 0.0.10 with patch bump
22
+
23
+
24
+ ## [0.0.9] - 2026-03-15
25
+
26
+ ### Release
27
+
28
+ - Published version 0.0.9 with patch bump
29
+
30
+
31
+ ### Refactor
32
+ - 重构项目为模块化目录结构
33
+ - `src/loader/` - 核心加载模块
34
+ - `src/version/` - 版本管理模块
35
+ - `src/preload/` - 预加载模块
36
+ - `src/unload/` - 卸载管理模块
37
+ - `src/health/` - 健康检查模块
38
+ - `src/event-bus/` - 事件总线模块
39
+ - `src/plugins/` - 插件模块
40
+ - `src/types/` - 类型定义
41
+ - 更新 rslib.config.ts entry 为 `./src/index.ts`
42
+ - 更新 package.json types 路径为 `./dist/index.d.ts`
43
+
44
+ ### Changed
45
+ - 修复 preloadRemote 引用从 loadRemote2 改为 loadRemote
46
+ - 移除 App.tsx 中未使用的 React 导入
47
+ - 添加 release 脚本到 package.json
48
+
49
+ ## [0.0.8] - 2026-03-15
50
+
51
+ ### Refactor
52
+ - 抽离公共工具函数到 `loadRemoteUtils.ts`
53
+ - 新增 `fetchLatestVersion()` - 从 npm registry 获取最新版本
54
+ - 新增 `getVersionCache()` / `setVersionCache()` - 缓存管理
55
+ - 新增 `buildCdnUrls()` - 构建 CDN 地址列表
56
+ - 新增 `tryLoadRemote()` - 单个 URL 的加载重试逻辑
57
+ - 新增 `getFinalSharedConfig()` - 合并共享配置
58
+ - 新增 `resolveFinalVersion()` - 解析最终版本号
59
+ - 新增 `buildFinalUrls()` - 构建最终 URL 列表
60
+ - 删除冗余文件 `loadRemote2.ts`
61
+ - 简化 `loadRemote.ts`,使用公共工具函数
62
+
63
+ ### Changed
64
+ - 更新 `index.ts` 导出,新增工具函数导出
65
+
66
+ ### Docs
67
+ - 更新 `loadRemote.md`,添加工具函数 API 文档
68
+
69
+ ## [0.0.7] - 2026-03-15
70
+
71
+ ### Features
72
+ - 新增微前端工具函数集
73
+ - 远程模块加载
74
+ - React 多版本支持
75
+ - 预加载功能
76
+ - 健康检查
77
+ - 事件总线
78
+
79
+ ## [0.0.6] - 2026-03-14
80
+
81
+ ### Docs
82
+ - 更新 README 和 loadRemote.md 文档
83
+ - 添加使用指南和 API 参考
84
+
85
+ ### Chore
86
+ - 更新 remote-reload-utils 版本至 0.0.8
87
+
88
+ ## [0.0.5] - 2026-03-14
89
+
90
+ ### Features
91
+ - 添加多版本远程加载功能
92
+ - 支持自定义 shared 配置
93
+ - 改进错误处理机制
94
+
95
+ ## [0.0.4] - 2026-03-14
96
+
97
+ ### Chore
98
+ - 更新错误处理逻辑
99
+ - 优化加载流程
100
+
101
+ ## [0.0.3] - 2026-03-14
102
+
103
+ ### Docs
104
+ - 添加项目描述和 git 仓库信息
105
+ - 更新 README 中的示例代码
106
+ - 将 loadRemote.md 从 src 移动到根目录
107
+
108
+ ### Chore
109
+ - 更新 remote-reload-utils 的版本号至 0.0.3
110
+
111
+ ## [0.0.2] - 2026-03-14
112
+
113
+ ### Features
114
+ - 添加 React 多版本加载功能(v17/v18/v19)
115
+ - 添加共享配置支持
116
+ - 默认共享 react 和 react-dom
117
+ - 支持自定义共享模块
118
+
119
+ ### Docs
120
+ - 更新示例代码展示如何使用 loadRemoteMultiVersion
121
+
122
+ ## [0.0.1] - 2026-03-14
123
+
124
+ ### Features
125
+ - 实现多版本远程模块加载功能
126
+ - 支持 CDN 故障转移(jsdelivr、unpkg)
127
+ - 支持本地 fallback 兜底
128
+ - 支持重试机制
129
+ - 支持版本缓存
130
+ - 基础工具函数
131
+ - `loadRemoteMultiVersion()` - 加载远程模块
132
+ - `loadReactVersion()` - 加载特定版本 React
133
+
134
+ ---
135
+
136
+ ## 版本说明
137
+
138
+ | 版本 | 日期 | 主要变更 |
139
+ |------|------|----------|
140
+ | 0.0.11 | 2026-03-16 | patch 版本发布 |
141
+ |------|------|----------|
142
+ | 0.0.10 | 2026-03-15 | patch 版本发布 |
143
+ |------|------|----------|
144
+ | 0.0.9 | 2026-03-15 | patch 版本发布 |
145
+ |------|------|----------|
146
+ | 0.0.9 | 2026-03-15 | 重构为模块化目录结构 |
147
+ | 0.0.8 | 2026-03-15 | 重构代码结构,抽离公共工具函数 |
148
+ | 0.0.7 | 2026-03-15 | 新增微前端工具函数集 |
149
+ | 0.0.6 | 2026-03-14 | 文档更新 |
150
+ | 0.0.5 | 2026-03-14 | 多版本远程加载 |
151
+ | 0.0.4 | 2026-03-14 | 错误处理优化 |
152
+ | 0.0.3 | 2026-03-14 | 文档和配置更新 |
153
+ | 0.0.2 | 2026-03-14 | React 多版本支持 |
154
+ | 0.0.1 | 2026-03-14 | 初始版本 |
package/README.md CHANGED
@@ -24,6 +24,8 @@ pnpm dev
24
24
 
25
25
  ### 使用方式
26
26
 
27
+ #### 1. 基础加载远程模块
28
+
27
29
  ```ts
28
30
  import { loadRemoteMultiVersion } from 'remote-reload-utils';
29
31
  const [comp, setComp] = useState(null);
@@ -52,3 +54,63 @@ useEffect(() => {
52
54
  init();
53
55
  }, []);
54
56
  ```
57
+
58
+ #### 2. 使用 React 组件加载远程模块
59
+
60
+ ```tsx
61
+ import { RemoteModuleCard, ErrorBoundary, lazyRemote } from 'remote-reload-utils';
62
+ import React, { Suspense } from 'react';
63
+
64
+ // 方式一:使用 RemoteModuleCard 组件(推荐)
65
+ function App() {
66
+ return (
67
+ <RemoteModuleCard
68
+ pkg="@myorg/remote-app"
69
+ version="^1.0.0"
70
+ moduleName="Dashboard"
71
+ scopeName="myorg"
72
+ loadingFallback={<Spinner />}
73
+ errorFallback={(error, reset) => (
74
+ <div>
75
+ <p>加载失败:{error.message}</p>
76
+ <button onClick={reset}>重试</button>
77
+ </div>
78
+ )}
79
+ componentProps={{ userId: 123 }}
80
+ />
81
+ );
82
+ }
83
+
84
+ // 方式二:使用 lazy + Suspense
85
+ const LazyDashboard = lazyRemote({
86
+ pkg: "@myorg/remote-app",
87
+ version: "^1.0.0",
88
+ moduleName: "Dashboard",
89
+ scopeName: "myorg"
90
+ });
91
+
92
+ function App() {
93
+ return (
94
+ <ErrorBoundary fallback={(error) => <div>错误:{error.message}</div>}>
95
+ <Suspense fallback={<Spinner />}>
96
+ <LazyDashboard userId={123} />
97
+ </Suspense>
98
+ </ErrorBoundary>
99
+ );
100
+ }
101
+
102
+ // 方式三:使用 SuspenseRemoteLoader(一体化方案)
103
+ function App() {
104
+ return (
105
+ <SuspenseRemoteLoader
106
+ pkg="@myorg/remote-app"
107
+ version="^1.0.0"
108
+ moduleName="Dashboard"
109
+ scopeName="myorg"
110
+ fallback={<Spinner />}
111
+ errorFallback={(error) => <div>错误:{error.message}</div>}
112
+ componentProps={{ userId: 123 }}
113
+ />
114
+ );
115
+ }
116
+ ```
@@ -0,0 +1,34 @@
1
+ import React from 'react';
2
+ export interface ErrorBoundaryProps {
3
+ children: React.ReactNode;
4
+ fallback?: React.ReactNode | ((error: Error, resetError: () => void) => React.ReactNode);
5
+ onError?: (error: Error, errorInfo: React.ErrorInfo) => void;
6
+ onReset?: () => void;
7
+ }
8
+ interface ErrorBoundaryState {
9
+ hasError: boolean;
10
+ error: Error | null;
11
+ errorInfo?: React.ErrorInfo | null;
12
+ }
13
+ /**
14
+ * 错误边界组件
15
+ * 用于捕获子组件树中的错误,并显示降级 UI
16
+ *
17
+ * @example
18
+ * ```tsx
19
+ * <ErrorBoundary
20
+ * fallback={(error, reset) => <div onClick={reset}>Error: {error.message}</div>}
21
+ * onError={(error, info) => console.error(error, info)}
22
+ * >
23
+ * <MyComponent />
24
+ * </ErrorBoundary>
25
+ * ```
26
+ */
27
+ export declare class ErrorBoundary extends React.Component<ErrorBoundaryProps, ErrorBoundaryState> {
28
+ constructor(props: ErrorBoundaryProps);
29
+ static getDerivedStateFromError(error: Error): ErrorBoundaryState;
30
+ componentDidCatch(error: Error, errorInfo: React.ErrorInfo): void;
31
+ handleReset: () => void;
32
+ render(): string | number | boolean | Iterable<React.ReactNode> | import("react/jsx-runtime").JSX.Element | null | undefined;
33
+ }
34
+ export {};
@@ -0,0 +1,84 @@
1
+ import React from 'react';
2
+ import type { ErrorBoundaryProps } from './ErrorBoundary';
3
+ export interface RemoteModuleCardProps {
4
+ /** 包名称 */
5
+ pkg: string;
6
+ /** 版本号,支持 semver 范围 */
7
+ version: string;
8
+ /** 远程模块名称(导出名) */
9
+ moduleName: string;
10
+ /** 作用域名称 */
11
+ scopeName: string;
12
+ /** 加载中的占位内容 */
13
+ loadingFallback?: React.ReactNode;
14
+ /** 错误状态的占位内容 */
15
+ errorFallback?: React.ReactNode | ((error: Error, resetError: () => void) => React.ReactNode);
16
+ /** 传递给远程组件的 props */
17
+ componentProps?: Record<string, any>;
18
+ /** 容器类名 */
19
+ className?: string;
20
+ /** 容器样式 */
21
+ style?: React.CSSProperties;
22
+ /** 加载成功回调 */
23
+ onLoad?: (component: React.ComponentType<any>) => void;
24
+ /** 加载失败回调 */
25
+ onError?: (error: Error) => void;
26
+ /** 是否禁用错误边界 */
27
+ disableErrorBoundary?: boolean;
28
+ /** 错误边界配置 */
29
+ errorBoundaryOptions?: Omit<ErrorBoundaryProps, 'children' | 'fallback'>;
30
+ }
31
+ interface ModuleState {
32
+ loading: boolean;
33
+ error: Error | null;
34
+ component: React.ComponentType<any> | null;
35
+ }
36
+ /**
37
+ * 内部 Hook:加载远程模块
38
+ */
39
+ export declare function useRemoteModule({ pkg, version, moduleName, scopeName, onError, onLoad, }: RemoteModuleCardProps): ModuleState;
40
+ /**
41
+ * 内部组件:纯内容渲染(不含 Suspense/ErrorBoundary)
42
+ */
43
+ export declare function RemoteModuleCardContent({ pkg, version, moduleName, scopeName, loadingFallback, errorFallback, componentProps, className, style, onError, onLoad, }: RemoteModuleCardProps): import("react/jsx-runtime").JSX.Element | null;
44
+ /**
45
+ * 远程模块卡片组件
46
+ * 负责加载和渲染远程模块,内置 Suspense 和 ErrorBoundary 支持
47
+ *
48
+ * @features
49
+ * - 自动加载远程模块
50
+ * - 内置加载状态和错误处理
51
+ * - 支持 Suspense 惰性加载
52
+ * - 可配置的错误边界
53
+ * - 支持重试机制
54
+ *
55
+ * @example
56
+ * ```tsx
57
+ * <RemoteModuleCard
58
+ * pkg="@myorg/remote-app"
59
+ * version="^1.0.0"
60
+ * moduleName="Dashboard"
61
+ * scopeName="myorg"
62
+ * loadingFallback={<Spinner />}
63
+ * errorFallback={(error, reset) => <Button onClick={reset}>Retry</Button>}
64
+ * componentProps={{ userId: 123 }}
65
+ * />
66
+ * ```
67
+ *
68
+ * @example
69
+ * ```tsx
70
+ * // 使用 lazy + Suspense 模式
71
+ * const LazyRemote = lazyRemote({
72
+ * pkg: "@myorg/remote-app",
73
+ * version: "^1.0.0",
74
+ * moduleName: "Dashboard",
75
+ * scopeName: "myorg"
76
+ * });
77
+ *
78
+ * <Suspense fallback={<Spinner />}>
79
+ * <LazyRemote userId={123} />
80
+ * </Suspense>
81
+ * ```
82
+ */
83
+ export declare function RemoteModuleCard(props: RemoteModuleCardProps): import("react/jsx-runtime").JSX.Element;
84
+ export {};
@@ -0,0 +1,131 @@
1
+ import React, { type ComponentType, type ReactNode } from 'react';
2
+ export interface LazyRemoteOptions {
3
+ /** 包名称 */
4
+ pkg: string;
5
+ /** 版本号 */
6
+ version?: string;
7
+ /** 模块名称 */
8
+ moduleName: string;
9
+ /** 作用域名称 */
10
+ scopeName: string;
11
+ /** 加载失败时的最大重试次数 */
12
+ maxRetries?: number;
13
+ /** 重试延迟(毫秒) */
14
+ retryDelay?: number;
15
+ }
16
+ export interface SuspenseRemoteProps {
17
+ /** 加载中的占位内容 */
18
+ fallback?: ReactNode;
19
+ children: ReactNode;
20
+ }
21
+ export interface SuspenseRemoteWithPropsProps extends LazyRemoteOptions {
22
+ /** 加载中的占位内容 */
23
+ fallback?: ReactNode;
24
+ /** 错误状态的占位内容 */
25
+ errorFallback?: ReactNode | ((error: Error) => ReactNode);
26
+ /** 传递给远程组件的 props */
27
+ componentProps?: Record<string, any>;
28
+ }
29
+ /**
30
+ * 创建一个惰性加载的远程组件
31
+ * 返回一个可用于 React.lazy() 的 Promise
32
+ *
33
+ * @example
34
+ * ```tsx
35
+ * const LazyDashboard = lazyRemote({
36
+ * pkg: "@myorg/remote-app",
37
+ * version: "^1.0.0",
38
+ * moduleName: "Dashboard",
39
+ * scopeName: "myorg"
40
+ * });
41
+ *
42
+ * function App() {
43
+ * return (
44
+ * <Suspense fallback={<Spinner />}>
45
+ * <LazyDashboard userId={123} />
46
+ * </Suspense>
47
+ * );
48
+ * }
49
+ * ```
50
+ */
51
+ export declare function lazyRemote(options: LazyRemoteOptions): React.LazyExoticComponent<React.ComponentType<any>>;
52
+ /**
53
+ * 带 Suspense 和错误处理的远程组件包装器
54
+ * 注意:错误处理需要与 ErrorBoundary 配合使用
55
+ *
56
+ * @example
57
+ * ```tsx
58
+ * // 与 ErrorBoundary 配合使用
59
+ * <ErrorBoundary fallback={(error) => <div>Error: {error.message}</div>}>
60
+ * <SuspenseRemote fallback={<Spinner />}>
61
+ * <RemoteModuleCard pkg="@myorg/remote-app" version="^1.0.0" moduleName="Dashboard" scopeName="myorg" />
62
+ * </SuspenseRemote>
63
+ * </ErrorBoundary>
64
+ * ```
65
+ */
66
+ export declare function SuspenseRemote({ fallback, children, }: {
67
+ fallback?: ReactNode;
68
+ children: ReactNode;
69
+ }): import("react/jsx-runtime").JSX.Element;
70
+ /**
71
+ * 一体化的远程组件加载器(包含 Suspense 和 ErrorBoundary)
72
+ *
73
+ * @example
74
+ * ```tsx
75
+ * <SuspenseRemoteLoader
76
+ * pkg="@myorg/remote-app"
77
+ * version="^1.0.0"
78
+ * moduleName="Dashboard"
79
+ * scopeName="myorg"
80
+ * fallback={<Spinner />}
81
+ * errorFallback={(error) => <div>Error: {error.message}</div>}
82
+ * componentProps={{ userId: 123 }}
83
+ * />
84
+ * ```
85
+ */
86
+ export declare function SuspenseRemoteLoader({ pkg, version, moduleName, scopeName, fallback, errorFallback, componentProps, }: SuspenseRemoteWithPropsProps): import("react/jsx-runtime").JSX.Element;
87
+ /**
88
+ * HOC:为组件添加远程加载能力
89
+ *
90
+ * @example
91
+ * ```tsx
92
+ * const EnhancedComponent = withRemote(
93
+ * (props) => <div>{props.message}</div>,
94
+ * {
95
+ * pkg: "@myorg/remote-app",
96
+ * version: "^1.0.0",
97
+ * moduleName: "RemoteComponent",
98
+ * scopeName: "myorg"
99
+ * }
100
+ * );
101
+ *
102
+ * <EnhancedComponent message="Hello" />
103
+ * ```
104
+ */
105
+ export declare function withRemote<P extends object>(WrappedComponent: ComponentType<P>, options: LazyRemoteOptions): (props: P) => import("react/jsx-runtime").JSX.Element;
106
+ /**
107
+ * Hook:在函数组件中加载远程模块
108
+ *
109
+ * @example
110
+ * ```tsx
111
+ * function MyComponent() {
112
+ * const { component: RemoteComp, loading, error } = useRemoteModule({
113
+ * pkg: "@myorg/remote-app",
114
+ * version: "^1.0.0",
115
+ * moduleName: "Dashboard",
116
+ * scopeName: "myorg"
117
+ * });
118
+ *
119
+ * if (loading) return <Spinner />;
120
+ * if (error) return <div>Error: {error.message}</div>;
121
+ * if (!RemoteComp) return null;
122
+ *
123
+ * return <RemoteComp userId={123} />;
124
+ * }
125
+ * ```
126
+ */
127
+ export declare function useRemoteModuleHook(options: LazyRemoteOptions): {
128
+ component: ComponentType<any> | null;
129
+ loading: boolean;
130
+ error: Error | null;
131
+ };
@@ -0,0 +1,6 @@
1
+ export { ErrorBoundary } from './ErrorBoundary';
2
+ export type { ErrorBoundaryProps } from './ErrorBoundary';
3
+ export { RemoteModuleCard } from './RemoteModuleCard';
4
+ export type { RemoteModuleCardProps } from './RemoteModuleCard';
5
+ export { lazyRemote, SuspenseRemote, SuspenseRemoteLoader, withRemote, useRemoteModuleHook, } from './SuspenseLoader';
6
+ export type { LazyRemoteOptions, SuspenseRemoteProps, SuspenseRemoteWithPropsProps } from './SuspenseLoader';
@@ -0,0 +1,40 @@
1
+ type EventCallback<T = any> = (data: T, meta?: EventMeta) => void;
2
+ interface EventMeta {
3
+ timestamp: number;
4
+ source?: string;
5
+ id?: string;
6
+ }
7
+ interface EventSubscription<T = any> {
8
+ callback: EventCallback<T>;
9
+ once: boolean;
10
+ filter?: (data: T, meta: EventMeta) => boolean;
11
+ }
12
+ interface EventEmitterOptions {
13
+ once?: boolean;
14
+ filter?: (data: any, meta: EventMeta) => boolean;
15
+ }
16
+ declare class EventBusClass {
17
+ private listeners;
18
+ private eventHistory;
19
+ private maxHistorySize;
20
+ private generateId;
21
+ on<T = any>(event: string, callback: EventCallback<T>, options?: EventEmitterOptions): () => void;
22
+ once<T = any>(event: string, callback: EventCallback<T>): () => void;
23
+ off<T = any>(event: string, callback?: EventCallback<T>): void;
24
+ emit<T = any>(event: string, data?: T, meta?: Partial<EventMeta>): void;
25
+ private addToHistory;
26
+ getHistory<T = any>(event: string): Array<{
27
+ data: T;
28
+ meta: EventMeta;
29
+ }>;
30
+ getEvents(): string[];
31
+ getListenerCount(event: string): number;
32
+ hasListeners(event: string): boolean;
33
+ clear(event?: string): void;
34
+ listenerExists(event: string, callback: EventCallback): boolean;
35
+ emitAsync<T = any>(event: string, data?: T, meta?: Partial<EventMeta>): Promise<void>;
36
+ static create(): EventBusClass;
37
+ }
38
+ export declare const eventBus: EventBusClass;
39
+ export declare function createEventBus(): EventBusClass;
40
+ export type { EventCallback, EventMeta, EventEmitterOptions, EventSubscription };
@@ -0,0 +1,23 @@
1
+ import type { LoadRemoteOptions } from '../types';
2
+ export interface HealthCheckResult {
3
+ pkg: string;
4
+ version: string;
5
+ status: 'healthy' | 'degraded' | 'unhealthy';
6
+ latency: number;
7
+ cdn: string;
8
+ details: {
9
+ cdnReachable: boolean;
10
+ remoteEntryValid: boolean;
11
+ modulesLoadable: boolean;
12
+ error?: string;
13
+ };
14
+ }
15
+ export interface RemoteHealthReport {
16
+ timestamp: number;
17
+ overall: 'healthy' | 'degraded' | 'unhealthy';
18
+ remotes: HealthCheckResult[];
19
+ }
20
+ export declare function checkRemoteHealth(options: LoadRemoteOptions): Promise<HealthCheckResult>;
21
+ export declare function checkModuleLoadable(scopeName: string, modulePath: string, mf: any): Promise<boolean>;
22
+ export declare function getRemoteHealthReport(remotes: LoadRemoteOptions[]): Promise<RemoteHealthReport>;
23
+ export declare function formatHealthStatus(status: 'healthy' | 'degraded' | 'unhealthy'): string;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,12 @@
1
- export { loadReactVersion } from './loadReactVersion';
2
- export { loadRemoteMultiVersion } from './loadRemote';
1
+ export { loadReactVersion } from './version/react';
2
+ export { checkVersionCompatibility, satisfiesVersion, findCompatibleVersion, getCompatibleReactVersions, fetchAvailableVersions, sortVersions, getLatestVersion, getStableVersions, extractMajorVersion, isPrerelease, compareVersions, parseVersion, } from './version';
3
+ export { loadRemoteMultiVersion } from './loader';
4
+ export { fetchLatestVersion, getVersionCache, setVersionCache, buildCdnUrls, tryLoadRemote, getFinalSharedConfig, resolveFinalVersion, buildFinalUrls, type LoadResult, } from './loader/utils';
5
+ export { preloadRemote, preloadRemoteList, cancelPreload, clearPreloadCache, getPreloadStatus, } from './preload';
6
+ export { unloadRemote, unloadAll, registerRemoteInstance, registerLoadedModule, getLoadedRemotes, isRemoteLoaded, } from './unload';
7
+ export { checkRemoteHealth, checkModuleLoadable, getRemoteHealthReport, formatHealthStatus, } from './health';
8
+ export { eventBus, createEventBus, } from './event-bus';
9
+ export type { LoadRemoteOptions, VersionCache, PreloadOptions, PreloadCacheItem, PreloadStatus, } from './types';
10
+ export { fallbackPlugin } from './plugins/fallback';
11
+ export { ErrorBoundary, RemoteModuleCard, lazyRemote, SuspenseRemote, SuspenseRemoteLoader, withRemote, useRemoteModuleHook, } from './components';
12
+ export type { ErrorBoundaryProps, RemoteModuleCardProps, LazyRemoteOptions, SuspenseRemoteProps, SuspenseRemoteWithPropsProps, } from './components';
@@ -0,0 +1,6 @@
1
+ import { ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ import type { LoadRemoteOptions } from '../types';
3
+ /**
4
+ * 多版本共存的 loadRemote
5
+ */
6
+ export declare function loadRemoteMultiVersion(options: LoadRemoteOptions, plugins: ModuleFederationRuntimePlugin[]): Promise<import("./utils").LoadResult>;
@@ -0,0 +1,38 @@
1
+ import { createInstance, ModuleFederationRuntimePlugin } from '@module-federation/enhanced/runtime';
2
+ import type { VersionCache } from '../types';
3
+ /**
4
+ * 从 npm registry 获取最新版本,并增加类型安全性
5
+ */
6
+ export declare function fetchLatestVersion(pkg: string): Promise<string>;
7
+ /**
8
+ * 读取多版本缓存,增强健壮性
9
+ */
10
+ export declare function getVersionCache(): VersionCache;
11
+ /**
12
+ * 写入多版本缓存,增强健壮性
13
+ */
14
+ export declare function setVersionCache(pkg: string, version: string): void;
15
+ /**
16
+ * 拼接 CDN 地址 (统一使用抽象的模板)
17
+ */
18
+ export declare function buildCdnUrls(pkg: string, version: string): string[];
19
+ export interface LoadResult {
20
+ scopeName: string;
21
+ mf: ReturnType<typeof createInstance>;
22
+ }
23
+ /**
24
+ * 尝试加载单个远程模块 URL,包含重试逻辑
25
+ */
26
+ export declare function tryLoadRemote(scopeName: string, url: string, retries: number, delay: number, sharedConfig: Record<string, any>, plugins: ModuleFederationRuntimePlugin[]): Promise<LoadResult>;
27
+ /**
28
+ * 获取最终的共享配置
29
+ */
30
+ export declare function getFinalSharedConfig(customShared?: Record<string, any>): Record<string, any>;
31
+ /**
32
+ * 解析最终版本号(处理 latest 情况)
33
+ */
34
+ export declare function resolveFinalVersion(pkg: string, version: string, cacheTTL: number, revalidate: boolean): Promise<string>;
35
+ /**
36
+ * 构建最终的 URL 列表(包含本地 fallback)
37
+ */
38
+ export declare function buildFinalUrls(pkg: string, version: string, localFallback?: string): string[];