@4399ywkf/core 5.1.4 → 5.1.6
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/cli/index.js +27 -11
- package/dist/cli/index.js.map +1 -1
- package/dist/config/index.d.ts +3 -3
- package/dist/config/index.js +1 -0
- package/dist/config/index.js.map +1 -1
- package/dist/index.d.ts +4 -4
- package/dist/index.js +586 -28
- package/dist/index.js.map +1 -1
- package/dist/plugin/index.d.ts +3 -3
- package/dist/router/index.js +12 -9
- package/dist/router/index.js.map +1 -1
- package/dist/rspack/index.d.ts +2 -2
- package/dist/rspack/index.js +26 -11
- package/dist/rspack/index.js.map +1 -1
- package/dist/runtime/index.d.ts +86 -4
- package/dist/runtime/index.js +578 -19
- package/dist/runtime/index.js.map +1 -1
- package/dist/{schema-C91lhskq.d.ts → schema-Ba1qfYz_.d.ts} +6 -1
- package/dist/{types-BYqzyGAY.d.ts → types-ZJhd87ue.d.ts} +51 -1
- package/package.json +8 -6
package/dist/runtime/index.d.ts
CHANGED
|
@@ -1,10 +1,75 @@
|
|
|
1
|
-
import { a as AppConfig, M as MicroAppConfig, b as AppContextValue, P as ProviderConfig } from '../types-
|
|
2
|
-
export { A as AntdConfig, L as LifecycleHooks, R as RequestConfig,
|
|
1
|
+
import { C as ChunkRecoveryConfig, c as ChunkRecoveryEvent, e as ChunkRecoverySource, a as AppConfig, M as MicroAppConfig, b as AppContextValue, P as ProviderConfig } from '../types-ZJhd87ue.js';
|
|
2
|
+
export { A as AntdConfig, d as ChunkRecoveryOutcome, L as LifecycleHooks, R as RequestConfig, f as Result } from '../types-ZJhd87ue.js';
|
|
3
3
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
4
4
|
import * as react from 'react';
|
|
5
5
|
import { ReactNode, Component, ErrorInfo, ComponentType } from 'react';
|
|
6
6
|
import 'react-router';
|
|
7
7
|
|
|
8
|
+
declare const DEFAULT_CHUNK_RECOVERY_COOLDOWN_MS = 30000;
|
|
9
|
+
declare const CHUNK_RECOVERY_STORAGE_KEY = "@4399ywkf/core:chunk-recovery-attempt";
|
|
10
|
+
declare const CHUNK_RECOVERY_CACHE_BUST_PARAM = "__ywkf_chunk_retry";
|
|
11
|
+
declare const CHUNK_RECOVERY_ACTIVE_SYMBOL: unique symbol;
|
|
12
|
+
interface ChunkRecoveryStorage {
|
|
13
|
+
getItem(key: string): string | null;
|
|
14
|
+
setItem(key: string, value: string): void;
|
|
15
|
+
}
|
|
16
|
+
type ChunkRecoveryClaim = {
|
|
17
|
+
claimed: true;
|
|
18
|
+
attemptedAt: number;
|
|
19
|
+
} | {
|
|
20
|
+
claimed: false;
|
|
21
|
+
reason: "already-attempted" | "cooldown" | "storage-unavailable";
|
|
22
|
+
attemptedAt?: number;
|
|
23
|
+
};
|
|
24
|
+
interface ClaimChunkRecoveryAttemptOptions {
|
|
25
|
+
cooldownMs?: number;
|
|
26
|
+
now: number;
|
|
27
|
+
recoveryId: string;
|
|
28
|
+
storageKey?: string;
|
|
29
|
+
}
|
|
30
|
+
interface ChunkRecoveryPolicyContext {
|
|
31
|
+
isProduction: boolean;
|
|
32
|
+
isMicroApp: boolean;
|
|
33
|
+
}
|
|
34
|
+
interface ChunkRecoveryPolicy {
|
|
35
|
+
enabled: boolean;
|
|
36
|
+
disabledReason?: "configuration" | "environment" | "micro-app";
|
|
37
|
+
cooldownMs: number;
|
|
38
|
+
globalHandlers: boolean;
|
|
39
|
+
}
|
|
40
|
+
interface HandleChunkRecoveryOptions {
|
|
41
|
+
source: ChunkRecoverySource;
|
|
42
|
+
config?: boolean | ChunkRecoveryConfig;
|
|
43
|
+
isMicroApp?: boolean;
|
|
44
|
+
onError?: (error: Error) => void;
|
|
45
|
+
onRecoveryEvent?: (event: ChunkRecoveryEvent) => void;
|
|
46
|
+
}
|
|
47
|
+
interface GlobalChunkRecoveryHandlersOptions {
|
|
48
|
+
config?: boolean | ChunkRecoveryConfig;
|
|
49
|
+
isMicroApp?: boolean;
|
|
50
|
+
onError?: (error: Error) => void;
|
|
51
|
+
onRecoveryEvent?: (event: ChunkRecoveryEvent) => void;
|
|
52
|
+
}
|
|
53
|
+
/** 仅匹配 Rspack/Webpack/Vite 的高置信度异步 chunk 加载错误。 */
|
|
54
|
+
declare function isChunkLoadError(error: unknown): boolean;
|
|
55
|
+
/** 将配置解析成与运行环境无关、可测试的恢复策略。 */
|
|
56
|
+
declare function resolveChunkRecoveryPolicy(config: boolean | ChunkRecoveryConfig | undefined, context: ChunkRecoveryPolicyContext): ChunkRecoveryPolicy;
|
|
57
|
+
/**
|
|
58
|
+
* 同步检查并预占本次刷新额度。
|
|
59
|
+
* 一次 setItem 同时提交 build 尝试集合与全局冷却时间;读写或数据校验失败时 fail closed。
|
|
60
|
+
*/
|
|
61
|
+
declare function claimChunkRecoveryAttempt(storage: ChunkRecoveryStorage, options: ClaimChunkRecoveryAttemptOptions): ChunkRecoveryClaim;
|
|
62
|
+
/** 判断当前页面是否运行在已知微前端容器中。 */
|
|
63
|
+
declare function isMicroAppRuntime(): boolean;
|
|
64
|
+
/** 在新文档启动后移除内部 cache-bust 参数,不污染业务分享 URL。 */
|
|
65
|
+
declare function clearChunkRecoveryCacheBustParam(): void;
|
|
66
|
+
declare function handleChunkLoadError(reason: unknown, options: HandleChunkRecoveryOptions): ChunkRecoveryEvent | null;
|
|
67
|
+
/**
|
|
68
|
+
* 可选的全局 chunk 错误监听。仅当 globalHandlers: true 且恢复策略启用时安装。
|
|
69
|
+
* 多个 core 实例共享一组 DOM listener;后注册的实例优先,卸载后自动回退到前一个实例。
|
|
70
|
+
*/
|
|
71
|
+
declare function installGlobalChunkRecoveryHandlers(options: GlobalChunkRecoveryHandlersOptions): () => void;
|
|
72
|
+
|
|
8
73
|
/**
|
|
9
74
|
* 启动应用
|
|
10
75
|
*/
|
|
@@ -99,6 +164,12 @@ interface ErrorBoundaryProps {
|
|
|
99
164
|
fallback?: ReactNode | ((error: Error, reset: () => void) => ReactNode);
|
|
100
165
|
/** 错误回调 */
|
|
101
166
|
onError?: (error: Error, errorInfo: ErrorInfo) => void;
|
|
167
|
+
/** 异步 chunk 加载失败恢复配置;公开组件默认不启用,由 RootProvider 显式传入 */
|
|
168
|
+
chunkRecovery?: boolean | ChunkRecoveryConfig;
|
|
169
|
+
/** chunk 加载恢复事件 */
|
|
170
|
+
onRecoveryEvent?: (event: ChunkRecoveryEvent) => void;
|
|
171
|
+
/** 是否运行在微前端子应用中 */
|
|
172
|
+
isMicroApp?: boolean;
|
|
102
173
|
}
|
|
103
174
|
interface ErrorBoundaryState {
|
|
104
175
|
hasError: boolean;
|
|
@@ -114,16 +185,27 @@ declare class ErrorBoundary extends Component<ErrorBoundaryProps, ErrorBoundaryS
|
|
|
114
185
|
reset: () => void;
|
|
115
186
|
render(): ReactNode;
|
|
116
187
|
}
|
|
188
|
+
interface RouteErrorBoundaryProps {
|
|
189
|
+
/** 业务自定义的同步错误 UI;函数形式可接收标准化后的错误 */
|
|
190
|
+
fallback?: ReactNode | ((error: Error) => ReactNode);
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* React Router 专用的同步错误元素。
|
|
194
|
+
* Router 会在内部吞掉 lazy route 异常,因此约定式路由必须用该组件把 chunk 错误交回恢复器。
|
|
195
|
+
*/
|
|
196
|
+
declare function RouteErrorBoundary({ fallback }: RouteErrorBoundaryProps): string | number | bigint | boolean | Iterable<ReactNode> | Promise<string | number | bigint | boolean | react.ReactPortal | react.ReactElement<unknown, string | react.JSXElementConstructor<any>> | Iterable<ReactNode> | null | undefined> | react_jsx_runtime.JSX.Element | null | undefined;
|
|
117
197
|
|
|
118
198
|
interface RootProviderProps {
|
|
119
199
|
config: AppConfig;
|
|
120
200
|
children?: ReactNode;
|
|
201
|
+
/** 是否运行在微前端子应用中;未传时由运行环境自动判断 */
|
|
202
|
+
isMicroApp?: boolean;
|
|
121
203
|
}
|
|
122
204
|
/**
|
|
123
205
|
* 根 Provider 组件
|
|
124
206
|
* 自动组合所有必要的 Provider
|
|
125
207
|
*/
|
|
126
|
-
declare function RootProvider({ config, children }: RootProviderProps): react_jsx_runtime.JSX.Element;
|
|
208
|
+
declare function RootProvider({ config, children, isMicroApp }: RootProviderProps): react_jsx_runtime.JSX.Element;
|
|
127
209
|
/**
|
|
128
210
|
* 创建自定义 Provider 配置的辅助函数
|
|
129
211
|
*/
|
|
@@ -131,4 +213,4 @@ declare function createProvider<P extends Record<string, unknown>>(component: Co
|
|
|
131
213
|
children: ReactNode;
|
|
132
214
|
}>, props?: Omit<P, "children">, order?: number): ProviderConfig;
|
|
133
215
|
|
|
134
|
-
export { AppConfig, AppContext, AppContextProvider, AppContextValue, ErrorBoundary, type ErrorBoundaryProps, MicroAppConfig, ProviderConfig, RootProvider, type RootProviderProps, bootstrap, createGarfishProvider, createMicroApp, createProvider, getMicroAppPublicPath, isMicroAppEnv, unmount, useApp, useAppName, useBasename, useEnv, useIsDev };
|
|
216
|
+
export { AppConfig, AppContext, AppContextProvider, AppContextValue, CHUNK_RECOVERY_ACTIVE_SYMBOL, CHUNK_RECOVERY_CACHE_BUST_PARAM, CHUNK_RECOVERY_STORAGE_KEY, type ChunkRecoveryClaim, ChunkRecoveryConfig, ChunkRecoveryEvent, type ChunkRecoveryPolicy, type ChunkRecoveryPolicyContext, ChunkRecoverySource, type ChunkRecoveryStorage, type ClaimChunkRecoveryAttemptOptions, DEFAULT_CHUNK_RECOVERY_COOLDOWN_MS, ErrorBoundary, type ErrorBoundaryProps, type GlobalChunkRecoveryHandlersOptions, type HandleChunkRecoveryOptions, MicroAppConfig, ProviderConfig, RootProvider, type RootProviderProps, RouteErrorBoundary, type RouteErrorBoundaryProps, bootstrap, claimChunkRecoveryAttempt, clearChunkRecoveryCacheBustParam, createGarfishProvider, createMicroApp, createProvider, getMicroAppPublicPath, handleChunkLoadError, installGlobalChunkRecoveryHandlers, isChunkLoadError, isMicroAppEnv, isMicroAppRuntime, resolveChunkRecoveryPolicy, unmount, useApp, useAppName, useBasename, useEnv, useIsDev };
|