@fulgurjs/federation 5.4.3 → 5.5.0

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.
Files changed (62) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/bridge-app-react.cjs +6 -58
  3. package/dist/bridge-app-react.d.cts +1 -1
  4. package/dist/bridge-app-react.d.ts +1 -1
  5. package/dist/bridge-app-react.js +6 -15
  6. package/dist/bridge-app-vue.cjs +5 -55
  7. package/dist/bridge-app-vue.d.cts +4 -3
  8. package/dist/bridge-app-vue.d.ts +4 -3
  9. package/dist/bridge-app-vue.js +5 -12
  10. package/dist/{bridge-core-ejlY9ddN.d.ts → bridge-core-D37VanBl.d.ts} +6 -0
  11. package/dist/bridge-core.d.cts +1 -1
  12. package/dist/bridge-core.d.ts +1 -1
  13. package/dist/bridge-core.js +2 -2
  14. package/dist/bridge-errors.cjs +6 -0
  15. package/dist/bridge-errors.d.cts +9 -1
  16. package/dist/bridge-errors.d.ts +9 -1
  17. package/dist/bridge-errors.js +3 -1
  18. package/dist/{bridge-host-react-Bua1TCVh.d.ts → bridge-host-react-CGymCzD2.d.ts} +1 -1
  19. package/dist/bridge-host-react.cjs +11 -2
  20. package/dist/bridge-host-react.d.cts +1 -1
  21. package/dist/bridge-host-react.d.ts +1 -1
  22. package/dist/bridge-host-react.js +10 -6
  23. package/dist/{bridge-host-vue-Dd1kkwDb.d.ts → bridge-host-vue-B3GHaQAC.d.ts} +1 -1
  24. package/dist/bridge-host-vue.cjs +11 -2
  25. package/dist/bridge-host-vue.js +10 -6
  26. package/dist/bridge-react.d.ts +4 -4
  27. package/dist/{bridge-router-core-BRZQYDPm.d.ts → bridge-router-core-DWFCVg9B.d.cts} +6 -0
  28. package/dist/{bridge-router-core-BRZQYDPm.d.cts → bridge-router-core-DWFCVg9B.d.ts} +6 -0
  29. package/dist/bridge-router-react.d.ts +6 -0
  30. package/dist/bridge-router-react.js +13 -3
  31. package/dist/bridge-router-vue.d.ts +7 -1
  32. package/dist/bridge-router-vue.js +22 -5
  33. package/dist/bridge-vue.d.ts +2 -2
  34. package/dist/bridge.d.ts +5 -5
  35. package/dist/{chunk-UFWZPE36.js → chunk-CI54BRPO.js} +12 -2
  36. package/dist/{chunk-43UX3UZE.js → chunk-E3VEP6LN.js} +8 -4
  37. package/dist/{chunk-RXXBTPAY.js → chunk-Q6V5O5Y6.js} +1 -1
  38. package/dist/{chunk-KT3YARK5.js → chunk-TU6DMGDA.js} +8 -4
  39. package/dist/{chunk-HZGQOW35.js → chunk-WRJG2YG6.js} +5 -0
  40. package/dist/{chunk-7CQOVLSI.js → chunk-YKIFZIBH.js} +2 -1
  41. package/dist/index.cjs +125 -2
  42. package/dist/index.js +125 -2
  43. package/dist/react.d.ts +6 -0
  44. package/dist/runtime-entry.d.ts +9 -2
  45. package/dist/runtime.js +8 -8
  46. package/examples/bridge/react-host/package-lock.json +4 -4
  47. package/examples/bridge/react-host/package.json +1 -1
  48. package/examples/bridge/react-remote/package-lock.json +4 -4
  49. package/examples/bridge/react-remote/package.json +1 -1
  50. package/examples/bridge/vue-host/package-lock.json +4 -4
  51. package/examples/bridge/vue-host/package.json +1 -1
  52. package/examples/bridge/vue-remote/package-lock.json +4 -4
  53. package/examples/bridge/vue-remote/package.json +1 -1
  54. package/examples/react/host/package-lock.json +4 -4
  55. package/examples/react/host/package.json +1 -1
  56. package/examples/react/remote/package-lock.json +4 -4
  57. package/examples/react/remote/package.json +1 -1
  58. package/examples/vue/host/package-lock.json +4 -4
  59. package/examples/vue/host/package.json +1 -1
  60. package/examples/vue/remote/package-lock.json +4 -4
  61. package/examples/vue/remote/package.json +1 -1
  62. package/package.json +2 -2
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RoutingChannel,
3
3
  assertBridgeRoutingProtocol
4
- } from "./chunk-7CQOVLSI.js";
4
+ } from "./chunk-YKIFZIBH.js";
5
5
  import {
6
6
  acquireBridgeSession,
7
7
  assertBridgeContract,
@@ -10,10 +10,10 @@ import {
10
10
  releaseBridgeSession,
11
11
  resolveBridgeContext,
12
12
  withBridgeTimeout
13
- } from "./chunk-RXXBTPAY.js";
13
+ } from "./chunk-Q6V5O5Y6.js";
14
14
  import {
15
- bridgeLifecycleError
16
- } from "./chunk-HZGQOW35.js";
15
+ bridgeHostError
16
+ } from "./chunk-WRJG2YG6.js";
17
17
  import {
18
18
  provideAppContext
19
19
  } from "./chunk-TSYLDY6H.js";
@@ -154,7 +154,11 @@ function createReactBridgeAppWithLoader(loadRemote) {
154
154
  channelRef.current = new RoutingChannel(`bridge-react:${spec}:${myGen}`, routing.basePath, routing.navigation, spec);
155
155
  mountOptions = { signal: abortRef.current.signal, routing: channelRef.current };
156
156
  }
157
- await contract.mount(el, { ...latest.current.appProps ?? {} }, mountOptions);
157
+ try {
158
+ await contract.mount(el, { ...latest.current.appProps ?? {} }, mountOptions);
159
+ } catch (mountError) {
160
+ throw bridgeHostError("mount", spec, mountError);
161
+ }
158
162
  if (generationRef.current !== myGen) return;
159
163
  setStatus("ready");
160
164
  } catch (e) {
@@ -174,7 +178,7 @@ function createReactBridgeAppWithLoader(loadRemote) {
174
178
  try {
175
179
  c.unmount(el);
176
180
  } catch (e) {
177
- const err = bridgeLifecycleError("unmount", spec, e instanceof Error ? e : String(e));
181
+ const err = bridgeHostError("unmount", spec, e);
178
182
  console.error("[fulgurjs] \u6865\u63A5\u5E94\u7528\u5378\u8F7D\u5931\u8D25\uFF1A", err);
179
183
  blockedRef.current = true;
180
184
  setError(err);
@@ -1,5 +1,5 @@
1
1
  import { Component } from 'vue';
2
- import { A as AppContext } from './bridge-core-ejlY9ddN.js';
2
+ import { A as AppContext } from './bridge-core-D37VanBl.js';
3
3
 
4
4
  /**
5
5
  * Vue 宿主桥接工厂(/bridge、/bridge/vue 导出 createVueBridgeApp;任务书 §3.4)。
@@ -119,6 +119,10 @@ function bridgeLifecycleError(phase, spec, cause, extra) {
119
119
  { cause }
120
120
  );
121
121
  }
122
+ function bridgeHostError(phase, spec, cause) {
123
+ if (cause instanceof FgError) return cause;
124
+ return bridgeLifecycleError(phase, spec, cause instanceof Error ? cause : String(cause));
125
+ }
122
126
  function bridgeSessionMismatchError(spec, controlled, actual, extra) {
123
127
  const actualText = actual === void 0 ? "undefined\uFF08\u9875\u9762\u5C1A\u65E0 AppContext\uFF09" : typeof actual === "string" ? `"${actual}"` : String(actual);
124
128
  return new FgError(
@@ -353,6 +357,7 @@ function assertBridgeRoutingProtocol(spec, contract) {
353
357
  var RoutingChannel = class {
354
358
  id;
355
359
  basePath;
360
+ /** 远程 spec(诊断错误定位真实远程用;随通道暴露给子应用路由接线) */
356
361
  spec;
357
362
  host;
358
363
  listeners = /* @__PURE__ */ new Set();
@@ -664,7 +669,7 @@ function createVueBridgeAppWithLoader(loadRemote) {
664
669
  try {
665
670
  c.unmount(el);
666
671
  } catch (e) {
667
- const err = bridgeLifecycleError("unmount", spec, e instanceof Error ? e : String(e));
672
+ const err = bridgeHostError("unmount", spec, e);
668
673
  containerBlocked = true;
669
674
  console.error("[fulgurjs] \u6865\u63A5\u5E94\u7528\u5378\u8F7D\u5931\u8D25\uFF0C\u8BE5\u5BB9\u5668\u5DF2\u5C01\u9501\uFF08\u540C\u9875\u53EA\u80FD\u5237\u65B0\u6062\u590D\uFF09\uFF1A", err);
670
675
  error.value = err;
@@ -710,7 +715,11 @@ function createVueBridgeAppWithLoader(loadRemote) {
710
715
  mountOptions = { signal: genAbort.signal, routing: channel };
711
716
  void latestLoc;
712
717
  }
713
- await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
718
+ try {
719
+ await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
720
+ } catch (e) {
721
+ throw bridgeHostError("mount", spec, e);
722
+ }
714
723
  if (myGeneration !== generation) return;
715
724
  status.value = "ready";
716
725
  } catch (e) {
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  RoutingChannel,
3
3
  assertBridgeRoutingProtocol
4
- } from "./chunk-7CQOVLSI.js";
4
+ } from "./chunk-YKIFZIBH.js";
5
5
  import {
6
6
  acquireBridgeSession,
7
7
  assertBridgeContract,
@@ -10,10 +10,10 @@ import {
10
10
  releaseBridgeSession,
11
11
  resolveBridgeContext,
12
12
  withBridgeTimeout
13
- } from "./chunk-RXXBTPAY.js";
13
+ } from "./chunk-Q6V5O5Y6.js";
14
14
  import {
15
- bridgeLifecycleError
16
- } from "./chunk-HZGQOW35.js";
15
+ bridgeHostError
16
+ } from "./chunk-WRJG2YG6.js";
17
17
  import {
18
18
  provideAppContext
19
19
  } from "./chunk-TSYLDY6H.js";
@@ -138,7 +138,7 @@ function createVueBridgeAppWithLoader(loadRemote) {
138
138
  try {
139
139
  c.unmount(el);
140
140
  } catch (e) {
141
- const err = bridgeLifecycleError("unmount", spec, e instanceof Error ? e : String(e));
141
+ const err = bridgeHostError("unmount", spec, e);
142
142
  containerBlocked = true;
143
143
  console.error("[fulgurjs] \u6865\u63A5\u5E94\u7528\u5378\u8F7D\u5931\u8D25\uFF0C\u8BE5\u5BB9\u5668\u5DF2\u5C01\u9501\uFF08\u540C\u9875\u53EA\u80FD\u5237\u65B0\u6062\u590D\uFF09\uFF1A", err);
144
144
  error.value = err;
@@ -184,7 +184,11 @@ function createVueBridgeAppWithLoader(loadRemote) {
184
184
  mountOptions = { signal: genAbort.signal, routing: channel };
185
185
  void latestLoc;
186
186
  }
187
- await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
187
+ try {
188
+ await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
189
+ } catch (e) {
190
+ throw bridgeHostError("mount", spec, e);
191
+ }
188
192
  if (myGeneration !== generation) return;
189
193
  status.value = "ready";
190
194
  } catch (e) {
@@ -1,8 +1,8 @@
1
1
  import * as react from 'react';
2
- import { B as BridgeHostRouting } from './bridge-core-ejlY9ddN.js';
3
- export { A as AppContext, a as BridgeApp } from './bridge-core-ejlY9ddN.js';
4
- import { R as ReactBridgeAppOptions } from './bridge-host-react-Bua1TCVh.js';
5
- export { B as BridgeErrorFallback } from './bridge-host-react-Bua1TCVh.js';
2
+ import { B as BridgeHostRouting } from './bridge-core-D37VanBl.js';
3
+ export { A as AppContext, a as BridgeApp } from './bridge-core-D37VanBl.js';
4
+ import { R as ReactBridgeAppOptions } from './bridge-host-react-CGymCzD2.js';
5
+ export { B as BridgeErrorFallback } from './bridge-host-react-CGymCzD2.js';
6
6
 
7
7
  /** React 宿主桥接工厂:返回 `ComponentType<{ appProps: P; sessionKey?: string | null }>` */
8
8
  declare const createReactBridgeApp: <P = Record<string, unknown>>(spec: string, options?: ReactBridgeAppOptions) => react.ComponentType<{
@@ -22,6 +22,12 @@ interface BridgeHostNavigation {
22
22
  }
23
23
  /** 子应用路由通道(桥接宿主按挂载代次创建,随 mount 第三参数交给子应用) */
24
24
  interface BridgeChildRoute {
25
+ /**
26
+ * 远程 spec(宿主创建通道时标注,如 "remote-b/bridge");子应用路由接线
27
+ * (connectVueBridgeRouter/createReactBridgeRouter)的诊断错误用它定位真实远程,
28
+ * 缺省(纯 memory 小部件自建通道)回退 'child-router'。
29
+ */
30
+ readonly spec?: string;
25
31
  getLocation(): BridgeLocation;
26
32
  subscribe(listener: (location: BridgeLocation) => void): () => void;
27
33
  navigate(target: BridgeLocation, action: 'push' | 'replace'): Promise<BridgeNavigationResult>;
@@ -22,6 +22,12 @@ interface BridgeHostNavigation {
22
22
  }
23
23
  /** 子应用路由通道(桥接宿主按挂载代次创建,随 mount 第三参数交给子应用) */
24
24
  interface BridgeChildRoute {
25
+ /**
26
+ * 远程 spec(宿主创建通道时标注,如 "remote-b/bridge");子应用路由接线
27
+ * (connectVueBridgeRouter/createReactBridgeRouter)的诊断错误用它定位真实远程,
28
+ * 缺省(纯 memory 小部件自建通道)回退 'child-router'。
29
+ */
30
+ readonly spec?: string;
25
31
  getLocation(): BridgeLocation;
26
32
  subscribe(listener: (location: BridgeLocation) => void): () => void;
27
33
  navigate(target: BridgeLocation, action: 'push' | 'replace'): Promise<BridgeNavigationResult>;
@@ -25,6 +25,12 @@ interface BridgeHostNavigation {
25
25
  }
26
26
  /** 子应用路由通道(桥接宿主按挂载代次创建,随 mount 第三参数交给子应用) */
27
27
  interface BridgeChildRoute {
28
+ /**
29
+ * 远程 spec(宿主创建通道时标注,如 "remote-b/bridge");子应用路由接线
30
+ * (connectVueBridgeRouter/createReactBridgeRouter)的诊断错误用它定位真实远程,
31
+ * 缺省(纯 memory 小部件自建通道)回退 'child-router'。
32
+ */
33
+ readonly spec?: string;
28
34
  getLocation(): BridgeLocation;
29
35
  subscribe(listener: (location: BridgeLocation) => void): () => void;
30
36
  navigate(target: BridgeLocation, action: 'push' | 'replace'): Promise<BridgeNavigationResult>;
@@ -48,7 +48,17 @@ function sameLocation(a, b) {
48
48
  }
49
49
 
50
50
  // src/bridge-router-sync.ts
51
+ function collapseConsecutiveReports(report) {
52
+ let last = "";
53
+ return (error) => {
54
+ const key = error instanceof Error ? `${error.name}|${error.message}` : String(error);
55
+ if (key === last) return;
56
+ last = key;
57
+ report(error);
58
+ };
59
+ }
51
60
  function connectChildNavigation(routing, apply, onError) {
61
+ const spec = routing.spec ?? "child-router";
52
62
  let disposed = false;
53
63
  let generation = 0;
54
64
  let tail = Promise.resolve();
@@ -89,7 +99,7 @@ function connectChildNavigation(routing, apply, onError) {
89
99
  onError(restoreError);
90
100
  }
91
101
  }
92
- throw routingSyncError("child-router", `\u5B50\u5E94\u7528\u8DEF\u7531\u51C6\u5907\u6216\u540C\u6B65\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
102
+ throw routingSyncError(spec, `\u5B50\u5E94\u7528\u8DEF\u7531\u51C6\u5907\u6216\u540C\u6B65\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
93
103
  } finally {
94
104
  pending = void 0;
95
105
  }
@@ -203,7 +213,7 @@ function createReactBridgeRouter(routing, routes, options = {}) {
203
213
  const sync = connectChildNavigation(routing, async (loc) => {
204
214
  const cur = router.state.location;
205
215
  if (!sameLocation(cur, loc)) await navigate(loc.pathname + loc.search + loc.hash, { replace: true });
206
- }, (error) => console.error("[fulgurjs] \u5B50\u5E94\u7528 React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error));
216
+ }, collapseConsecutiveReports((error) => console.error("[fulgurjs] \u5B50\u5E94\u7528 React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error)));
207
217
  router.navigate = ((to, options2) => {
208
218
  if (typeof to === "number") {
209
219
  if (!disposed) routing.go(to);
@@ -215,7 +225,7 @@ function createReactBridgeRouter(routing, routes, options = {}) {
215
225
  return { pathname: l.pathname, search: l.search, hash: l.hash };
216
226
  }, options2?.replace ? "replace" : "push").then(() => {
217
227
  });
218
- void task.catch((error) => console.error("[fulgurjs] \u5B50\u5E94\u7528 React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error));
228
+ void task.catch(collapseConsecutiveReports((error) => console.error("[fulgurjs] \u5B50\u5E94\u7528 React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error)));
219
229
  return task;
220
230
  });
221
231
  let unwatch = () => {
@@ -24,6 +24,12 @@ interface BridgeHostNavigation {
24
24
  }
25
25
  /** 子应用路由通道(桥接宿主按挂载代次创建,随 mount 第三参数交给子应用) */
26
26
  interface BridgeChildRoute {
27
+ /**
28
+ * 远程 spec(宿主创建通道时标注,如 "remote-b/bridge");子应用路由接线
29
+ * (connectVueBridgeRouter/createReactBridgeRouter)的诊断错误用它定位真实远程,
30
+ * 缺省(纯 memory 小部件自建通道)回退 'child-router'。
31
+ */
32
+ readonly spec?: string;
27
33
  getLocation(): BridgeLocation;
28
34
  subscribe(listener: (location: BridgeLocation) => void): () => void;
29
35
  navigate(target: BridgeLocation, action: 'push' | 'replace'): Promise<BridgeNavigationResult>;
@@ -36,7 +42,7 @@ interface BridgeHostRouting {
36
42
  navigation: BridgeHostNavigation;
37
43
  }
38
44
 
39
- /** Vue Router 4 的宿主导航端口与子应用 memory router 接线(按需入口)。 */
45
+ /** Vue Router 4/5 的宿主导航端口与子应用 memory router 接线(按需入口)。 */
40
46
 
41
47
  interface VueBridgeNavigationOptions {
42
48
  /** 保留配置兼容;Vue Router fullPath 已剥离 history base,不再二次剥离。 */
@@ -1,3 +1,6 @@
1
+ // src/bridge-router-vue.ts
2
+ import { isNavigationFailure, NavigationFailureType } from "vue-router";
3
+
1
4
  // src/runtime/errors.ts
2
5
  var FgError = class extends Error {
3
6
  code;
@@ -44,7 +47,17 @@ function sameLocation(a, b) {
44
47
  }
45
48
 
46
49
  // src/bridge-router-sync.ts
50
+ function collapseConsecutiveReports(report) {
51
+ let last = "";
52
+ return (error) => {
53
+ const key = error instanceof Error ? `${error.name}|${error.message}` : String(error);
54
+ if (key === last) return;
55
+ last = key;
56
+ report(error);
57
+ };
58
+ }
47
59
  function connectChildNavigation(routing, apply, onError) {
60
+ const spec = routing.spec ?? "child-router";
48
61
  let disposed = false;
49
62
  let generation = 0;
50
63
  let tail = Promise.resolve();
@@ -85,7 +98,7 @@ function connectChildNavigation(routing, apply, onError) {
85
98
  onError(restoreError);
86
99
  }
87
100
  }
88
- throw routingSyncError("child-router", `\u5B50\u5E94\u7528\u8DEF\u7531\u51C6\u5907\u6216\u540C\u6B65\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
101
+ throw routingSyncError(spec, `\u5B50\u5E94\u7528\u8DEF\u7531\u51C6\u5907\u6216\u540C\u6B65\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
89
102
  } finally {
90
103
  pending = void 0;
91
104
  }
@@ -134,6 +147,7 @@ function createVueBridgeNavigation(router, _options = {}) {
134
147
  };
135
148
  }
136
149
  function connectVueBridgeRouter(routing, router, options = {}) {
150
+ const spec = routing.spec ?? "vue-router";
137
151
  const push = router.push;
138
152
  const replace = router.replace;
139
153
  const go = router.go;
@@ -145,10 +159,13 @@ function connectVueBridgeRouter(routing, router, options = {}) {
145
159
  const path = loc.pathname + loc.search + loc.hash;
146
160
  if (router.currentRoute.value.fullPath !== path) {
147
161
  const failure = await replace.call(router, path);
148
- if (failure && router.currentRoute.value.fullPath !== path) throw routingSyncError("vue-router", "\u5B50\u5E94\u7528\u5B88\u536B\u62D2\u7EDD\u5E94\u7528\u5BBF\u4E3B\u786E\u8BA4\u7684\u4F4D\u7F6E\uFF1B\u8BF7\u5728\u5BBF\u4E3B\u4FA7\u8BBE\u7F6E\u53D6\u6D88\u5B88\u536B\u3002", []);
162
+ if (failure && router.currentRoute.value.fullPath !== path) {
163
+ if (isNavigationFailure(failure, NavigationFailureType.cancelled)) return;
164
+ throw routingSyncError(spec, `\u5B50\u5E94\u7528\u5B88\u536B\u62D2\u7EDD\u5E94\u7528\u5BBF\u4E3B\u786E\u8BA4\u7684\u4F4D\u7F6E\uFF08\u76EE\u6807 ${path}\uFF09\uFF1B\u8BF7\u5728\u5BBF\u4E3B\u4FA7\u8BBE\u7F6E\u53D6\u6D88\u5B88\u536B\u3002`, []);
165
+ }
149
166
  }
150
167
  };
151
- const sync = connectChildNavigation(routing, (loc) => ready.then(() => apply(loc)), report);
168
+ const sync = connectChildNavigation(routing, (loc) => ready.then(() => apply(loc)), collapseConsecutiveReports(report));
152
169
  const init = routing.getLocation();
153
170
  const ready = push.call(router, init.pathname + init.search + init.hash).then(async (failure) => {
154
171
  if (disposed) return;
@@ -156,14 +173,14 @@ function connectVueBridgeRouter(routing, router, options = {}) {
156
173
  await apply(routing.getLocation());
157
174
  return;
158
175
  }
159
- if (failure) throw routingSyncError("vue-router", "\u5B50\u5E94\u7528\u521D\u59CB\u8DEF\u7531\u88AB\u5B88\u536B\u53D6\u6D88\u3002", []);
176
+ if (failure) throw routingSyncError(spec, "\u5B50\u5E94\u7528\u521D\u59CB\u8DEF\u7531\u88AB\u5B88\u536B\u53D6\u6D88\u3002", []);
160
177
  const target = locationFromPath(router.currentRoute.value.fullPath);
161
178
  if (router.currentRoute.value.fullPath !== init.pathname + init.search + init.hash) {
162
179
  await routing.navigate(target, "replace");
163
180
  await apply(routing.getLocation());
164
181
  }
165
182
  }).catch((cause) => {
166
- throw routingSyncError("vue-router", `\u521D\u59CB\u8DEF\u7531\u51C6\u5907\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
183
+ throw routingSyncError(spec, `\u521D\u59CB\u8DEF\u7531\u51C6\u5907\u5931\u8D25\uFF1A${cause instanceof Error ? cause.message : String(cause)}`, [], cause);
167
184
  });
168
185
  const intercept = (native, action) => (to) => {
169
186
  const task = (async () => {
@@ -1,6 +1,6 @@
1
1
  import * as vue from 'vue';
2
- import { V as VueBridgeAppOptions } from './bridge-host-vue-Dd1kkwDb.js';
3
- export { A as AppContext, a as BridgeApp } from './bridge-core-ejlY9ddN.js';
2
+ import { V as VueBridgeAppOptions } from './bridge-host-vue-B3GHaQAC.js';
3
+ export { A as AppContext, a as BridgeApp } from './bridge-core-D37VanBl.js';
4
4
 
5
5
  /** Vue 宿主桥接工厂:返回 `{ appProps: P; sessionKey?: string | null }` 形态的包装组件 */
6
6
  declare const createVueBridgeApp: <P = Record<string, unknown>>(spec: string, options?: VueBridgeAppOptions) => vue.Component;
package/dist/bridge.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import * as react from 'react';
2
- import { B as BridgeHostRouting } from './bridge-core-ejlY9ddN.js';
3
- export { A as AppContext, a as BridgeApp } from './bridge-core-ejlY9ddN.js';
4
- import { R as ReactBridgeAppOptions } from './bridge-host-react-Bua1TCVh.js';
5
- export { B as BridgeErrorFallback } from './bridge-host-react-Bua1TCVh.js';
2
+ import { B as BridgeHostRouting } from './bridge-core-D37VanBl.js';
3
+ export { A as AppContext, a as BridgeApp } from './bridge-core-D37VanBl.js';
4
+ import { R as ReactBridgeAppOptions } from './bridge-host-react-CGymCzD2.js';
5
+ export { B as BridgeErrorFallback } from './bridge-host-react-CGymCzD2.js';
6
6
  import * as vue from 'vue';
7
- import { V as VueBridgeAppOptions } from './bridge-host-vue-Dd1kkwDb.js';
7
+ import { V as VueBridgeAppOptions } from './bridge-host-vue-B3GHaQAC.js';
8
8
 
9
9
  /** Vue 宿主桥接工厂:返回 `{ appProps: P; sessionKey?: string | null }` 形态的包装组件 */
10
10
  declare const createVueBridgeApp: <P = Record<string, unknown>>(spec: string, options?: VueBridgeAppOptions) => vue.Component;
@@ -653,6 +653,7 @@ function createRuntime() {
653
653
  });
654
654
  }
655
655
  const sleep = (ms) => new Promise((r) => setTimeout(r, ms));
656
+ const nameMismatchWarned = /* @__PURE__ */ new Set();
656
657
  function validateContainerInterface(container, remote) {
657
658
  if (!container || typeof container.get !== "function") {
658
659
  throw new Error(
@@ -662,7 +663,11 @@ function createRuntime() {
662
663
  if (container.name && remote.name && container.name !== remote.name) {
663
664
  const msg = `\u8FDC\u7A0B\u5165\u53E3\u81EA\u62A5\u540D\u79F0 "${container.name}" \u4E0E\u5BBF\u4E3B\u914D\u7F6E\u540D\u79F0 "${remote.name}" \u4E0D\u4E00\u81F4\u3002\u8BF7\u7EDF\u4E00\u4E24\u4FA7 federation({ name }) \u4E0E remotes \u7684\u540D\u79F0\u3002`;
664
665
  if (remote.promise) {
665
- console.warn(`[fulgurjs] ${msg} \u5F53\u524D\u662F\u52A8\u6001 Promise \u8FDC\u7A0B\uFF0C\u7EE7\u7EED\u52A0\u8F7D\u3002`);
666
+ const key = `${remote.name}\u2194${container.name}`;
667
+ if (!nameMismatchWarned.has(key)) {
668
+ nameMismatchWarned.add(key);
669
+ console.warn(`[fulgurjs] ${msg} \u5F53\u524D\u662F\u52A8\u6001 Promise \u8FDC\u7A0B\uFF0C\u7EE7\u7EED\u52A0\u8F7D\u3002`);
670
+ }
666
671
  } else {
667
672
  throw Object.assign(new Error(msg), { code: ErrorCodes.REMOTE_NAME_MISMATCH });
668
673
  }
@@ -1171,6 +1176,10 @@ function bridgeLifecycleError(phase, spec, cause, extra) {
1171
1176
  { cause }
1172
1177
  );
1173
1178
  }
1179
+ function bridgeHostError(phase, spec, cause) {
1180
+ if (cause instanceof FgError) return cause;
1181
+ return bridgeLifecycleError(phase, spec, cause instanceof Error ? cause : String(cause));
1182
+ }
1174
1183
  function bridgeSessionMismatchError(spec, controlled, actual, extra) {
1175
1184
  const actualText = actual === void 0 ? "undefined\uFF08\u9875\u9762\u5C1A\u65E0 AppContext\uFF09" : typeof actual === "string" ? `"${actual}"` : String(actual);
1176
1185
  return new FgError(
@@ -1405,6 +1414,7 @@ function assertBridgeRoutingProtocol(spec, contract) {
1405
1414
  var RoutingChannel = class {
1406
1415
  id;
1407
1416
  basePath;
1417
+ /** 远程 spec(诊断错误定位真实远程用;随通道暴露给子应用路由接线) */
1408
1418
  spec;
1409
1419
  host;
1410
1420
  listeners = /* @__PURE__ */ new Set();
@@ -1601,7 +1611,7 @@ var RoutingChannel = class {
1601
1611
  export {
1602
1612
  loadRemote,
1603
1613
  provideAppContext,
1604
- bridgeLifecycleError,
1614
+ bridgeHostError,
1605
1615
  assertBridgeContract,
1606
1616
  acquireBridgeSession,
1607
1617
  releaseBridgeSession,
@@ -5,12 +5,12 @@ import {
5
5
  assertBridgeOptions,
6
6
  assertBridgeRoutingProtocol,
7
7
  assertControlledSessionKey,
8
- bridgeLifecycleError,
8
+ bridgeHostError,
9
9
  provideAppContext,
10
10
  releaseBridgeSession,
11
11
  resolveBridgeContext,
12
12
  withBridgeTimeout
13
- } from "./chunk-UFWZPE36.js";
13
+ } from "./chunk-CI54BRPO.js";
14
14
 
15
15
  // src/bridge-host-vue.ts
16
16
  import { defineComponent, h, onActivated, onBeforeUnmount, onDeactivated, onMounted, ref, shallowRef, toRaw, watch } from "vue";
@@ -131,7 +131,7 @@ function createVueBridgeAppWithLoader(loadRemote) {
131
131
  try {
132
132
  c.unmount(el);
133
133
  } catch (e) {
134
- const err = bridgeLifecycleError("unmount", spec, e instanceof Error ? e : String(e));
134
+ const err = bridgeHostError("unmount", spec, e);
135
135
  containerBlocked = true;
136
136
  console.error("[fulgurjs] \u6865\u63A5\u5E94\u7528\u5378\u8F7D\u5931\u8D25\uFF0C\u8BE5\u5BB9\u5668\u5DF2\u5C01\u9501\uFF08\u540C\u9875\u53EA\u80FD\u5237\u65B0\u6062\u590D\uFF09\uFF1A", err);
137
137
  error.value = err;
@@ -177,7 +177,11 @@ function createVueBridgeAppWithLoader(loadRemote) {
177
177
  mountOptions = { signal: genAbort.signal, routing: channel };
178
178
  void latestLoc;
179
179
  }
180
- await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
180
+ try {
181
+ await contract.mount(el, { ...appPropsSource ?? {} }, mountOptions);
182
+ } catch (e) {
183
+ throw bridgeHostError("mount", spec, e);
184
+ }
181
185
  if (myGeneration !== generation) return;
182
186
  status.value = "ready";
183
187
  } catch (e) {
@@ -3,7 +3,7 @@ import {
3
3
  bridgeSessionMismatchError,
4
4
  invalidBridgeContractError,
5
5
  invalidSessionKeyError
6
- } from "./chunk-HZGQOW35.js";
6
+ } from "./chunk-WRJG2YG6.js";
7
7
  import {
8
8
  clearAppContext
9
9
  } from "./chunk-TSYLDY6H.js";
@@ -5,12 +5,12 @@ import {
5
5
  assertBridgeOptions,
6
6
  assertBridgeRoutingProtocol,
7
7
  assertControlledSessionKey,
8
- bridgeLifecycleError,
8
+ bridgeHostError,
9
9
  provideAppContext,
10
10
  releaseBridgeSession,
11
11
  resolveBridgeContext,
12
12
  withBridgeTimeout
13
- } from "./chunk-UFWZPE36.js";
13
+ } from "./chunk-CI54BRPO.js";
14
14
 
15
15
  // src/bridge-host-react.ts
16
16
  import {
@@ -147,7 +147,11 @@ function createReactBridgeAppWithLoader(loadRemote) {
147
147
  channelRef.current = new RoutingChannel(`bridge-react:${spec}:${myGen}`, routing.basePath, routing.navigation, spec);
148
148
  mountOptions = { signal: abortRef.current.signal, routing: channelRef.current };
149
149
  }
150
- await contract.mount(el, { ...latest.current.appProps ?? {} }, mountOptions);
150
+ try {
151
+ await contract.mount(el, { ...latest.current.appProps ?? {} }, mountOptions);
152
+ } catch (mountError) {
153
+ throw bridgeHostError("mount", spec, mountError);
154
+ }
151
155
  if (generationRef.current !== myGen) return;
152
156
  setStatus("ready");
153
157
  } catch (e) {
@@ -167,7 +171,7 @@ function createReactBridgeAppWithLoader(loadRemote) {
167
171
  try {
168
172
  c.unmount(el);
169
173
  } catch (e) {
170
- const err = bridgeLifecycleError("unmount", spec, e instanceof Error ? e : String(e));
174
+ const err = bridgeHostError("unmount", spec, e);
171
175
  console.error("[fulgurjs] \u6865\u63A5\u5E94\u7528\u5378\u8F7D\u5931\u8D25\uFF1A", err);
172
176
  blockedRef.current = true;
173
177
  setError(err);
@@ -51,6 +51,10 @@ function bridgeLifecycleError(phase, spec, cause, extra) {
51
51
  { cause }
52
52
  );
53
53
  }
54
+ function bridgeHostError(phase, spec, cause) {
55
+ if (cause instanceof FgError) return cause;
56
+ return bridgeLifecycleError(phase, spec, cause instanceof Error ? cause : String(cause));
57
+ }
54
58
  function bridgeSessionMismatchError(spec, controlled, actual, extra) {
55
59
  const actualText = actual === void 0 ? "undefined\uFF08\u9875\u9762\u5C1A\u65E0 AppContext\uFF09" : typeof actual === "string" ? `"${actual}"` : String(actual);
56
60
  return new FgError(
@@ -116,6 +120,7 @@ export {
116
120
  BridgeErrorCodes,
117
121
  invalidBridgeContractError,
118
122
  bridgeLifecycleError,
123
+ bridgeHostError,
119
124
  bridgeSessionMismatchError,
120
125
  invalidSessionKeyError,
121
126
  routingConfigError,
@@ -3,7 +3,7 @@ import {
3
3
  routingNavigationError,
4
4
  routingProtocolError,
5
5
  routingSyncError
6
- } from "./chunk-HZGQOW35.js";
6
+ } from "./chunk-WRJG2YG6.js";
7
7
 
8
8
  // src/bridge-router-core.ts
9
9
  var MAX_REDIRECT_PER_REQUEST = 5;
@@ -75,6 +75,7 @@ function assertBridgeRoutingProtocol(spec, contract) {
75
75
  var RoutingChannel = class {
76
76
  id;
77
77
  basePath;
78
+ /** 远程 spec(诊断错误定位真实远程用;随通道暴露给子应用路由接线) */
78
79
  spec;
79
80
  host;
80
81
  listeners = /* @__PURE__ */ new Set();