@fulgurjs/federation 5.9.3 → 6.0.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.
- package/CHANGELOG.md +51 -0
- package/README.en.md +57 -416
- package/README.md +56 -446
- package/dist/bridge-app-vue.d.cts +1 -1
- package/dist/bridge-app-vue.d.ts +1 -1
- package/dist/bridge-core.cjs +1 -1
- package/dist/bridge-core.js +2 -2
- package/dist/bridge-errors.cjs +1 -1
- package/dist/bridge-errors.js +1 -1
- package/dist/bridge-host-react.cjs +1 -1
- package/dist/bridge-host-react.js +3 -3
- package/dist/bridge-host-vue.cjs +1 -1
- package/dist/bridge-host-vue.js +3 -3
- package/dist/bridge-router-react.d.ts +4 -2
- package/dist/bridge-router-react.js +95 -9
- package/dist/bridge-router-vue.d.ts +24 -5
- package/dist/bridge-router-vue.js +4 -5
- package/dist/{chunk-YKIFZIBH.js → chunk-77JZ6U6V.js} +1 -1
- package/dist/{chunk-Q6V5O5Y6.js → chunk-ENT3BOTX.js} +1 -1
- package/dist/{chunk-WRJG2YG6.js → chunk-ZAYNS7YQ.js} +1 -1
- package/dist/cli.js +460 -109
- package/dist/index.cjs +25 -38
- package/dist/index.js +25 -38
- package/dist/react.d.ts +194 -101
- package/dist/react.js +4 -0
- package/dist/runtime-entry.d.ts +9 -174
- package/dist/runtime-entry.js +0 -1
- package/dist/runtime.js +1 -1
- package/dist/vue.d.ts +576 -0
- package/dist/vue.js +8 -0
- package/docs/en/migration.md +210 -0
- package/docs/en/reference/api.md +534 -0
- package/docs/en/reference/errors.md +86 -0
- package/docs/{P5-vite7-8 → maintainers/P5-vite7-8}/345/205/274/345/256/271/347/237/251/351/230/265.md +7 -9
- package/docs/{webpack-mf- → maintainers/webpack-mf-}/345/257/271/347/205/247/344/270/216/347/274/272/345/217/243.md +10 -10
- package/docs/maintainers//346/262/231/347/256/261/350/276/271/347/225/214/345/256/241/350/256/241.md +43 -0
- package/docs/zh/migration.md +210 -0
- package/docs/zh/reference/api.md +533 -0
- package/docs/zh/reference/errors.md +86 -0
- package/examples/templates/README.md +1 -1
- package/examples/templates/react-host-vue-remote/pnpm-workspace.yaml +1 -1
- package/examples/templates/react-host-vue-remote/react-host/README.md +2 -2
- package/examples/templates/react-host-vue-remote/react-host/package.json +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/main.tsx +2 -2
- package/examples/templates/react-host-vue-remote/scripts/dev.config.json +11 -2
- package/examples/templates/react-host-vue-remote/vue-remote/package.json +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/bridge.ts +1 -1
- package/examples/templates/react-react/host/package.json +1 -1
- package/examples/templates/react-react/pnpm-workspace.yaml +1 -1
- package/examples/templates/react-react/remote/package.json +1 -1
- package/examples/templates/react-react/scripts/dev.config.json +11 -2
- package/examples/templates/showcase/README.md +6 -6
- package/examples/templates/showcase/pnpm-workspace.yaml +1 -1
- package/examples/templates/showcase/react-host/package.json +1 -1
- package/examples/templates/showcase/react-host/src/pages/BridgeVuePage.tsx +1 -1
- package/examples/templates/showcase/react-host/src/routing.ts +1 -1
- package/examples/templates/showcase/react-remote/package.json +1 -1
- package/examples/templates/showcase/react-remote/src/bridge.tsx +1 -1
- package/examples/templates/showcase/scripts/dev.config.json +22 -4
- package/examples/templates/showcase/vue-host/package.json +1 -1
- package/examples/templates/showcase/vue-host/src/pages/BridgeReactPage.vue +1 -1
- package/examples/templates/showcase/vue-host/src/routing.ts +3 -13
- package/examples/templates/showcase/vue-remote/package.json +1 -1
- package/examples/templates/showcase/vue-remote/src/bridge.ts +2 -2
- package/examples/templates/vue-host-react-remote/pnpm-workspace.yaml +1 -1
- package/examples/templates/vue-host-react-remote/react-remote/package.json +1 -1
- package/examples/templates/vue-host-react-remote/scripts/dev.config.json +11 -2
- package/examples/templates/vue-host-react-remote/vue-host/README.md +2 -2
- package/examples/templates/vue-host-react-remote/vue-host/package.json +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/App.vue +2 -2
- package/examples/templates/vue-vue/host/package.json +1 -1
- package/examples/templates/vue-vue/host/src/main.ts +28 -21
- package/examples/templates/vue-vue/host/src/pages/HomePage.vue +1 -1
- package/examples/templates/vue-vue/pnpm-workspace.yaml +1 -1
- package/examples/templates/vue-vue/remote/package.json +1 -1
- package/examples/templates/vue-vue/scripts/dev.config.json +11 -2
- package/package.json +24 -37
- package/dist/bridge-core-D37VanBl.d.ts +0 -99
- package/dist/bridge-host-react-CGymCzD2.d.ts +0 -35
- package/dist/bridge-host-vue-B3GHaQAC.d.ts +0 -32
- package/dist/bridge-react.d.ts +0 -14
- package/dist/bridge-react.js +0 -3
- package/dist/bridge-vue.d.ts +0 -8
- package/dist/bridge-vue.js +0 -3
- package/dist/bridge.d.ts +0 -18
- package/dist/bridge.js +0 -5
- package/dist/chunk-GLASM5EX.js +0 -1730
- package/dist/chunk-V6EASSCR.js +0 -249
- package/dist/chunk-X34EJB4H.js +0 -207
- package/docs/API.en.md +0 -339
- package/docs/API.md +0 -914
- package/docs//346/262/231/347/256/261/350/276/271/347/225/214/345/256/241/350/256/241.md +0 -45
- package/docs//350/277/201/347/247/273/346/214/207/345/215/227.md +0 -179
package/dist/bridge-host-vue.cjs
CHANGED
|
@@ -97,7 +97,7 @@ function invalidBridgeContractError(spec, mod) {
|
|
|
97
97
|
`\u73B0\u8C61\uFF1A\u8FDC\u7A0B\u6A21\u5757 "${spec}" \u7684\u9ED8\u8BA4\u5BFC\u51FA\u4E0D\u662F\u5408\u6CD5\u7684\u6865\u63A5\u5951\u7EA6\uFF08BridgeApp\uFF09\u3002
|
|
98
98
|
\u6839\u56E0: \u5BFC\u51FA\u503C\u4E3A ${actual}` + (missing.length ? `\uFF0C\u7F3A\u5C11\u51FD\u6570\u7C7B\u578B\u7684 ${missing.map((m) => `"${m}"`).join(" / ")} \u5BFC\u51FA\u3002` : "\u3002") + `
|
|
99
99
|
\u4FEE\u6CD5: \u8FDC\u7A0B\u4FA7\u7528 defineBridgeApp(...) \u521B\u5EFA\u5951\u7EA6\u5E76\u4F5C\u4E3A\u6A21\u5757\u9ED8\u8BA4\u5BFC\u51FA\u2014\u2014
|
|
100
|
-
Vue \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/
|
|
100
|
+
Vue \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/vue'\uFF1B
|
|
101
101
|
React \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/react'\u3002
|
|
102
102
|
\u5951\u7EA6\u5FC5\u987B\u5305\u542B mount(el, props?) \u4E0E unmount(el) \u4E24\u4E2A\u51FD\u6570\u3002`,
|
|
103
103
|
{ spec, missing, actual }
|
package/dist/bridge-host-vue.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
RoutingChannel,
|
|
3
3
|
assertBridgeRoutingProtocol
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-77JZ6U6V.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-
|
|
13
|
+
} from "./chunk-ENT3BOTX.js";
|
|
14
14
|
import {
|
|
15
15
|
bridgeHostError
|
|
16
|
-
} from "./chunk-
|
|
16
|
+
} from "./chunk-ZAYNS7YQ.js";
|
|
17
17
|
import {
|
|
18
18
|
provideAppContext
|
|
19
19
|
} from "./chunk-TSYLDY6H.js";
|
|
@@ -43,7 +43,7 @@ interface BridgeHostRouting {
|
|
|
43
43
|
navigation: BridgeHostNavigation;
|
|
44
44
|
}
|
|
45
45
|
|
|
46
|
-
/** React Router data router
|
|
46
|
+
/** React Router data router 的宿主导航端口与子应用 memory router 接线(统一入口 /react 提供)。 */
|
|
47
47
|
|
|
48
48
|
type ReactBridgeCancelPolicy = (next: BridgeLocation) => boolean;
|
|
49
49
|
interface ReactDataRouterLike {
|
|
@@ -68,6 +68,8 @@ interface ReactDataRouterLike {
|
|
|
68
68
|
replace?: boolean;
|
|
69
69
|
}): void | Promise<void>;
|
|
70
70
|
}
|
|
71
|
+
/** 内部时序缝隙:等待模块级预热落定(仅测试使用;生产代码不需要等待——未就绪时走惰性宿主) */
|
|
72
|
+
declare const __reactRouterDomReady: Promise<void>;
|
|
71
73
|
/** canNavigate 是可选预判;最终结果同时核对真实 blocker 与已提交位置。 */
|
|
72
74
|
declare function createReactBridgeNavigation(router: ReactDataRouterLike, options?: {
|
|
73
75
|
canNavigate?: ReactBridgeCancelPolicy;
|
|
@@ -82,4 +84,4 @@ declare function createReactBridgeRouter(routing: BridgeChildRoute, routes: Rout
|
|
|
82
84
|
signal?: AbortSignal;
|
|
83
85
|
}): ReactBridgeRouterConnection;
|
|
84
86
|
|
|
85
|
-
export { type BridgeHostRouting, type ReactBridgeCancelPolicy, type ReactBridgeRouterConnection, type ReactDataRouterLike, createReactBridgeNavigation, createReactBridgeRouter };
|
|
87
|
+
export { type BridgeHostRouting, type ReactBridgeCancelPolicy, type ReactBridgeRouterConnection, type ReactDataRouterLike, __reactRouterDomReady, createReactBridgeNavigation, createReactBridgeRouter };
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
// src/bridge-router-react.tsx
|
|
2
|
-
import { createElement } from "react";
|
|
3
|
-
import { RouterProvider, createMemoryRouter } from "react-router-dom";
|
|
2
|
+
import { createElement, useEffect, useState } from "react";
|
|
4
3
|
|
|
5
4
|
// src/runtime/errors.ts
|
|
6
5
|
var FgError = class extends Error {
|
|
@@ -118,6 +117,24 @@ function connectChildNavigation(routing, apply, onError) {
|
|
|
118
117
|
}
|
|
119
118
|
|
|
120
119
|
// src/bridge-router-react.tsx
|
|
120
|
+
var routerDomModule = null;
|
|
121
|
+
var routerDomFailure = null;
|
|
122
|
+
var routerDomReady = import("react-router-dom").then(
|
|
123
|
+
(m) => {
|
|
124
|
+
const candidate = m;
|
|
125
|
+
if (candidate && typeof candidate.createMemoryRouter === "function" && typeof candidate.RouterProvider === "function") {
|
|
126
|
+
routerDomModule = candidate;
|
|
127
|
+
} else {
|
|
128
|
+
routerDomFailure = new Error(
|
|
129
|
+
"[fulgurjs] react-router-dom \u672A\u5B89\u88C5\u6216\u4E0D\u53EF\u7528\uFF08createMemoryRouter/RouterProvider \u7F3A\u5931\uFF09\u3002createReactBridgeRouter\uFF08URL \u540C\u6B65\u53D7\u63A7\u8DEF\u7531\uFF09\u9700\u8981 react-router-dom \u22656.11\uFF1B\u4E0D\u4F7F\u7528\u8DEF\u7531\u540C\u6B65\u7684\u7EAF React \u7EC4\u4EF6\u5DE5\u7A0B\u65E0\u9700\u5B89\u88C5\u3002"
|
|
130
|
+
);
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
(e) => {
|
|
134
|
+
routerDomFailure = e;
|
|
135
|
+
}
|
|
136
|
+
);
|
|
137
|
+
var __reactRouterDomReady = routerDomReady;
|
|
121
138
|
function createReactBridgeNavigation(router, options = {}) {
|
|
122
139
|
const base = options.basename && options.basename !== "/" ? options.basename.replace(/\/$/, "") : "";
|
|
123
140
|
const toLogic = () => {
|
|
@@ -205,15 +222,16 @@ function createReactBridgeNavigation(router, options = {}) {
|
|
|
205
222
|
}
|
|
206
223
|
};
|
|
207
224
|
}
|
|
208
|
-
function
|
|
225
|
+
function wireReactBridgeRouter(m, routing, routes, options) {
|
|
209
226
|
const init = routing.getLocation();
|
|
210
|
-
const router = createMemoryRouter(routes, { initialEntries: [init.pathname + init.search + init.hash] });
|
|
227
|
+
const router = m.createMemoryRouter(routes, { initialEntries: [init.pathname + init.search + init.hash] });
|
|
211
228
|
const navigate = router.navigate.bind(router);
|
|
212
229
|
let disposed = false;
|
|
230
|
+
const report = collapseConsecutiveReports((error) => console.error("[fulgurjs] \u5B50\u5E94\u7528 React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error));
|
|
213
231
|
const sync = connectChildNavigation(routing, async (loc) => {
|
|
214
232
|
const cur = router.state.location;
|
|
215
233
|
if (!sameLocation(cur, loc)) await navigate(loc.pathname + loc.search + loc.hash, { replace: true });
|
|
216
|
-
},
|
|
234
|
+
}, report);
|
|
217
235
|
router.navigate = ((to, options2) => {
|
|
218
236
|
if (typeof to === "number") {
|
|
219
237
|
if (!disposed) routing.go(to);
|
|
@@ -225,7 +243,7 @@ function createReactBridgeRouter(routing, routes, options = {}) {
|
|
|
225
243
|
return { pathname: l.pathname, search: l.search, hash: l.hash };
|
|
226
244
|
}, options2?.replace ? "replace" : "push").then(() => {
|
|
227
245
|
});
|
|
228
|
-
void task.catch(
|
|
246
|
+
void task.catch(report);
|
|
229
247
|
return task;
|
|
230
248
|
});
|
|
231
249
|
let unwatch = () => {
|
|
@@ -236,22 +254,90 @@ function createReactBridgeRouter(routing, routes, options = {}) {
|
|
|
236
254
|
const actual = router.state.location;
|
|
237
255
|
if (!sameLocation(actual, init)) void sync.enqueue(async () => actual, "replace").catch((error) => console.error("[fulgurjs] \u521D\u59CB React \u8DEF\u7531\u540C\u6B65\u5931\u8D25\uFF1A", error));
|
|
238
256
|
});
|
|
239
|
-
const
|
|
240
|
-
|
|
257
|
+
const wired = {
|
|
258
|
+
router,
|
|
259
|
+
RouterProvider: m.RouterProvider,
|
|
241
260
|
dispose() {
|
|
242
261
|
if (disposed) return;
|
|
243
|
-
options.signal?.removeEventListener("abort", connection.dispose);
|
|
244
262
|
disposed = true;
|
|
263
|
+
options.signal?.removeEventListener("abort", disposeWired);
|
|
245
264
|
unwatch();
|
|
246
265
|
sync.dispose();
|
|
247
266
|
router.dispose();
|
|
248
267
|
}
|
|
249
268
|
};
|
|
269
|
+
const disposeWired = () => wired.dispose();
|
|
270
|
+
options.signal?.addEventListener("abort", disposeWired, { once: true });
|
|
271
|
+
if (options.signal?.aborted) wired.dispose();
|
|
272
|
+
return wired;
|
|
273
|
+
}
|
|
274
|
+
function LazyRouterProviderHost(props) {
|
|
275
|
+
const [wired, setWired] = useState(null);
|
|
276
|
+
const [failure, setFailure] = useState(routerDomFailure);
|
|
277
|
+
useEffect(() => {
|
|
278
|
+
if (wired || failure !== null) return;
|
|
279
|
+
let alive = true;
|
|
280
|
+
void routerDomReady.then(
|
|
281
|
+
() => {
|
|
282
|
+
if (!alive) return;
|
|
283
|
+
if (routerDomFailure) {
|
|
284
|
+
setFailure(routerDomFailure);
|
|
285
|
+
return;
|
|
286
|
+
}
|
|
287
|
+
if (!routerDomModule || props.isDisposed()) return;
|
|
288
|
+
const w = wireReactBridgeRouter(routerDomModule, props.routing, props.routes, { signal: props.signal });
|
|
289
|
+
props.onWired(w);
|
|
290
|
+
setWired(w);
|
|
291
|
+
},
|
|
292
|
+
(e) => {
|
|
293
|
+
if (alive) setFailure(e);
|
|
294
|
+
}
|
|
295
|
+
);
|
|
296
|
+
return () => {
|
|
297
|
+
alive = false;
|
|
298
|
+
};
|
|
299
|
+
}, [wired, failure, props]);
|
|
300
|
+
if (failure !== null) {
|
|
301
|
+
throw failure instanceof Error ? failure : new Error(String(failure));
|
|
302
|
+
}
|
|
303
|
+
return wired ? createElement(wired.RouterProvider, { router: wired.router }) : null;
|
|
304
|
+
}
|
|
305
|
+
function createReactBridgeRouter(routing, routes, options = {}) {
|
|
306
|
+
let disposed = false;
|
|
307
|
+
let wired = null;
|
|
308
|
+
const dispose = () => {
|
|
309
|
+
if (disposed) return;
|
|
310
|
+
disposed = true;
|
|
311
|
+
wired?.dispose();
|
|
312
|
+
};
|
|
313
|
+
if (routerDomModule) {
|
|
314
|
+
wired = wireReactBridgeRouter(routerDomModule, routing, routes, options);
|
|
315
|
+
const connection2 = {
|
|
316
|
+
element: createElement(wired.RouterProvider, { router: wired.router }),
|
|
317
|
+
dispose
|
|
318
|
+
};
|
|
319
|
+
options.signal?.addEventListener("abort", connection2.dispose, { once: true });
|
|
320
|
+
if (options.signal?.aborted) connection2.dispose();
|
|
321
|
+
return connection2;
|
|
322
|
+
}
|
|
323
|
+
const connection = {
|
|
324
|
+
element: createElement(LazyRouterProviderHost, {
|
|
325
|
+
routing,
|
|
326
|
+
routes,
|
|
327
|
+
signal: options.signal,
|
|
328
|
+
isDisposed: () => disposed,
|
|
329
|
+
onWired: (w) => {
|
|
330
|
+
wired = w;
|
|
331
|
+
}
|
|
332
|
+
}),
|
|
333
|
+
dispose
|
|
334
|
+
};
|
|
250
335
|
options.signal?.addEventListener("abort", connection.dispose, { once: true });
|
|
251
336
|
if (options.signal?.aborted) connection.dispose();
|
|
252
337
|
return connection;
|
|
253
338
|
}
|
|
254
339
|
export {
|
|
340
|
+
__reactRouterDomReady,
|
|
255
341
|
createReactBridgeNavigation,
|
|
256
342
|
createReactBridgeRouter
|
|
257
343
|
};
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Router } from 'vue-router';
|
|
2
|
-
|
|
3
1
|
/** 统一逻辑位置:pathname 以 / 开头;search 空串或 ? 开头;hash 空串或 # 开头 */
|
|
4
2
|
interface BridgeLocation {
|
|
5
3
|
pathname: string;
|
|
@@ -41,21 +39,42 @@ interface BridgeHostRouting {
|
|
|
41
39
|
basePath: string;
|
|
42
40
|
navigation: BridgeHostNavigation;
|
|
43
41
|
}
|
|
42
|
+
/**
|
|
43
|
+
* vue-router 实例的最小结构面(/vue 路由同步端口参数;真实 vue-router Router 结构兼容可赋值)。
|
|
44
|
+
* 6.0.0 可选依赖边界:/vue 的 d.ts 不得 import vue-router 类型——未安装 vue-router 的
|
|
45
|
+
* 纯组件工程在 skipLibCheck:false 下也必须能通过类型检查;结构类型的宽化只影响
|
|
46
|
+
* 路由同步端口处的精确提示,业务代码自己的 Router 类型不受影响。
|
|
47
|
+
*/
|
|
48
|
+
interface VueRouterLike {
|
|
49
|
+
currentRoute: {
|
|
50
|
+
value: {
|
|
51
|
+
fullPath: string;
|
|
52
|
+
};
|
|
53
|
+
};
|
|
54
|
+
push(to: string): Promise<unknown>;
|
|
55
|
+
replace(to: string): Promise<unknown>;
|
|
56
|
+
go(delta: number): void;
|
|
57
|
+
back(): void;
|
|
58
|
+
forward(): void;
|
|
59
|
+
afterEach(handler: (to: unknown, from: unknown, failure?: unknown) => void): () => void;
|
|
60
|
+
beforeResolve(handler: () => unknown): () => void;
|
|
61
|
+
beforeEach(handler: () => unknown): () => void;
|
|
62
|
+
}
|
|
44
63
|
|
|
45
|
-
/** Vue Router 4/5 的宿主导航端口与子应用 memory router
|
|
64
|
+
/** Vue Router 4/5 的宿主导航端口与子应用 memory router 接线(统一入口 /vue 提供)。 */
|
|
46
65
|
|
|
47
66
|
interface VueBridgeNavigationOptions {
|
|
48
67
|
/** 保留配置兼容;Vue Router fullPath 已剥离 history base,不再二次剥离。 */
|
|
49
68
|
routerBase?: string;
|
|
50
69
|
}
|
|
51
|
-
declare function createVueBridgeNavigation(router:
|
|
70
|
+
declare function createVueBridgeNavigation(router: VueRouterLike, _options?: VueBridgeNavigationOptions): BridgeHostNavigation;
|
|
52
71
|
interface VueBridgeRouterConnection {
|
|
53
72
|
/** 必须 await ready 后再 app.use(router),初始错误会拒绝此 Promise。 */
|
|
54
73
|
ready: Promise<void>;
|
|
55
74
|
dispose(): void;
|
|
56
75
|
}
|
|
57
76
|
/** 接线限子应用自己的 memory router;dispose 恢复原始导航方法。 */
|
|
58
|
-
declare function connectVueBridgeRouter(routing: BridgeChildRoute, router:
|
|
77
|
+
declare function connectVueBridgeRouter(routing: BridgeChildRoute, router: VueRouterLike, options?: {
|
|
59
78
|
signal?: AbortSignal;
|
|
60
79
|
}): VueBridgeRouterConnection;
|
|
61
80
|
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
// src/bridge-router-vue.ts
|
|
2
|
-
import { isNavigationFailure, NavigationFailureType } from "vue-router";
|
|
3
|
-
|
|
4
1
|
// src/runtime/errors.ts
|
|
5
2
|
var FgError = class extends Error {
|
|
6
3
|
code;
|
|
@@ -117,6 +114,8 @@ function connectChildNavigation(routing, apply, onError) {
|
|
|
117
114
|
}
|
|
118
115
|
|
|
119
116
|
// src/bridge-router-vue.ts
|
|
117
|
+
var NAVIGATION_FAILURE_CANCELLED = 8;
|
|
118
|
+
var isCancelledNavigationFailure = (failure) => !!failure && typeof failure === "object" && failure.type === NAVIGATION_FAILURE_CANCELLED;
|
|
120
119
|
var locationFromPath = (path) => {
|
|
121
120
|
const raw = new URL(path || "/", "http://f.invalid");
|
|
122
121
|
return { pathname: raw.pathname, search: raw.search, hash: raw.hash };
|
|
@@ -160,7 +159,7 @@ function connectVueBridgeRouter(routing, router, options = {}) {
|
|
|
160
159
|
if (router.currentRoute.value.fullPath !== path) {
|
|
161
160
|
const failure = await replace.call(router, path);
|
|
162
161
|
if (failure && router.currentRoute.value.fullPath !== path) {
|
|
163
|
-
if (
|
|
162
|
+
if (isCancelledNavigationFailure(failure)) return;
|
|
164
163
|
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
164
|
}
|
|
166
165
|
}
|
|
@@ -189,7 +188,7 @@ function connectVueBridgeRouter(routing, router, options = {}) {
|
|
|
189
188
|
await ready;
|
|
190
189
|
failure = await native.call(router, to);
|
|
191
190
|
return failure ? void 0 : locationFromPath(router.currentRoute.value.fullPath);
|
|
192
|
-
}, typeof to === "object" && to
|
|
191
|
+
}, typeof to === "object" && to?.replace ? "replace" : action);
|
|
193
192
|
if (failure) return failure;
|
|
194
193
|
if (result.status === "cancelled") {
|
|
195
194
|
const remove = router.beforeEach(() => false);
|
|
@@ -29,7 +29,7 @@ function invalidBridgeContractError(spec, mod) {
|
|
|
29
29
|
`\u73B0\u8C61\uFF1A\u8FDC\u7A0B\u6A21\u5757 "${spec}" \u7684\u9ED8\u8BA4\u5BFC\u51FA\u4E0D\u662F\u5408\u6CD5\u7684\u6865\u63A5\u5951\u7EA6\uFF08BridgeApp\uFF09\u3002
|
|
30
30
|
\u6839\u56E0: \u5BFC\u51FA\u503C\u4E3A ${actual}` + (missing.length ? `\uFF0C\u7F3A\u5C11\u51FD\u6570\u7C7B\u578B\u7684 ${missing.map((m) => `"${m}"`).join(" / ")} \u5BFC\u51FA\u3002` : "\u3002") + `
|
|
31
31
|
\u4FEE\u6CD5: \u8FDC\u7A0B\u4FA7\u7528 defineBridgeApp(...) \u521B\u5EFA\u5951\u7EA6\u5E76\u4F5C\u4E3A\u6A21\u5757\u9ED8\u8BA4\u5BFC\u51FA\u2014\u2014
|
|
32
|
-
Vue \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/
|
|
32
|
+
Vue \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/vue'\uFF1B
|
|
33
33
|
React \u5B50\u5E94\u7528: import { defineBridgeApp } from '@fulgurjs/federation/react'\u3002
|
|
34
34
|
\u5951\u7EA6\u5FC5\u987B\u5305\u542B mount(el, props?) \u4E0E unmount(el) \u4E24\u4E2A\u51FD\u6570\u3002`,
|
|
35
35
|
{ spec, missing, actual }
|