@fulgurjs/federation 5.9.3 → 6.1.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 +66 -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 +22 -3
- package/dist/bridge-router-react.js +107 -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-adapter.d.cts +7 -0
- package/dist/react-adapter.d.ts +7 -0
- package/dist/react.d.ts +229 -101
- package/dist/react.js +4 -0
- package/dist/runtime-entry.d.ts +27 -174
- package/dist/runtime-entry.js +0 -1
- package/dist/runtime.js +19 -17
- package/dist/vue-adapter.cjs +13 -1
- package/dist/vue-adapter.d.cts +1 -0
- package/dist/vue-adapter.d.ts +1 -0
- package/dist/vue-adapter.js +14 -2
- package/dist/vue.d.ts +594 -0
- package/dist/vue.js +8 -0
- package/docs/en/migration.md +210 -0
- package/docs/en/reference/api.md +555 -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 +551 -0
- package/docs/zh/reference/errors.md +86 -0
- package/examples/templates/README.md +1 -1
- package/examples/templates/react-host-vue-remote/pnpm-lock.yaml +7 -7
- 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-lock.yaml +7 -7
- 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-lock.yaml +11 -11
- 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-lock.yaml +7 -7
- 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-lock.yaml +7 -7
- 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
|
@@ -11,8 +11,8 @@ importers:
|
|
|
11
11
|
react-remote:
|
|
12
12
|
dependencies:
|
|
13
13
|
'@fulgurjs/federation':
|
|
14
|
-
specifier:
|
|
15
|
-
version:
|
|
14
|
+
specifier: 6.0.0
|
|
15
|
+
version: 6.0.0(react-dom@19.3.0(react@19.3.0))(react-router-dom@7.18.4(react-dom@19.3.0(react@19.3.0))(react@19.3.0))(react@19.3.0)(vite@6.4.3)(vue@3.5.43(typescript@5.9.3))
|
|
16
16
|
react:
|
|
17
17
|
specifier: ^19.1.0
|
|
18
18
|
version: 19.3.0
|
|
@@ -42,8 +42,8 @@ importers:
|
|
|
42
42
|
vue-host:
|
|
43
43
|
dependencies:
|
|
44
44
|
'@fulgurjs/federation':
|
|
45
|
-
specifier:
|
|
46
|
-
version:
|
|
45
|
+
specifier: 6.0.0
|
|
46
|
+
version: 6.0.0(react-dom@19.3.0(react@19.3.0))(react-router-dom@7.18.4(react-dom@19.3.0(react@19.3.0))(react@19.3.0))(react@19.3.0)(vite@6.4.3)(vue@3.5.43(typescript@5.9.3))
|
|
47
47
|
react:
|
|
48
48
|
specifier: ^19.1.0
|
|
49
49
|
version: 19.3.0
|
|
@@ -467,8 +467,8 @@ packages:
|
|
|
467
467
|
cpu: [x64]
|
|
468
468
|
os: [win32]
|
|
469
469
|
|
|
470
|
-
'@fulgurjs/federation@
|
|
471
|
-
resolution: {integrity: sha512-
|
|
470
|
+
'@fulgurjs/federation@6.0.0':
|
|
471
|
+
resolution: {integrity: sha512-h3/ZvxdJZVtbvQcQ/OycsTQq7J9LYTfDjpjtoLli0eMk1gOjr2xdvtYaKw57Rt+ccGyfJgYPCsF2U48vVkRFpg==}
|
|
472
472
|
engines: {node: '>=18'}
|
|
473
473
|
hasBin: true
|
|
474
474
|
peerDependencies:
|
|
@@ -1221,7 +1221,7 @@ snapshots:
|
|
|
1221
1221
|
'@esbuild/win32-x64@0.27.7':
|
|
1222
1222
|
optional: true
|
|
1223
1223
|
|
|
1224
|
-
'@fulgurjs/federation@
|
|
1224
|
+
'@fulgurjs/federation@6.0.0(react-dom@19.3.0(react@19.3.0))(react-router-dom@7.18.4(react-dom@19.3.0(react@19.3.0))(react@19.3.0))(react@19.3.0)(vite@6.4.3)(vue@3.5.43(typescript@5.9.3))':
|
|
1225
1225
|
dependencies:
|
|
1226
1226
|
es-module-lexer: 1.7.0
|
|
1227
1227
|
esbuild: 0.27.7
|
|
@@ -2,7 +2,7 @@ packages:
|
|
|
2
2
|
- vue-host
|
|
3
3
|
- react-remote
|
|
4
4
|
minimumReleaseAgeExclude:
|
|
5
|
-
- '@fulgurjs/federation@
|
|
5
|
+
- '@fulgurjs/federation@6.0.0'
|
|
6
6
|
# pnpm >=12 构建脚本批准(12 起弃用 onlyBuiltDependencies;pnpm 9-11 忽略本键:
|
|
7
7
|
# esbuild >=0.16 二进制经 optionalDependencies 平台包分发,postinstall 仅校验,不阻塞安装)
|
|
8
8
|
allowBuilds:
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apps": [
|
|
3
|
-
{
|
|
4
|
-
|
|
3
|
+
{
|
|
4
|
+
"name": "react-remote",
|
|
5
|
+
"dir": "react-remote",
|
|
6
|
+
"port": 5303
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "vue-host",
|
|
10
|
+
"dir": "vue-host",
|
|
11
|
+
"port": 5314,
|
|
12
|
+
"host": true
|
|
13
|
+
}
|
|
5
14
|
]
|
|
6
15
|
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# bridge-vue-host — Vue 宿主 × React 桥接子应用示例
|
|
2
2
|
|
|
3
|
-
`@fulgurjs/federation` 跨框架桥接的 **Vue 3 宿主**侧示例:用 `createVueBridgeApp
|
|
3
|
+
`@fulgurjs/federation` 跨框架桥接的 **Vue 3 宿主**侧示例:用 `createVueBridgeApp`(统一入口 `@fulgurjs/federation/vue`)把 `bridge-react-remote/bridge` 作为受控组件挂载。
|
|
4
4
|
|
|
5
5
|
## 运行
|
|
6
6
|
|
|
@@ -18,7 +18,7 @@ pnpm build # 构建完整组合
|
|
|
18
18
|
## 关键点(对应 README §8.2)
|
|
19
19
|
|
|
20
20
|
- **双框架安装合同**:本宿主同时安装 `vue` + `react` + `react-dom`,shared 三键全部 `singleton: true`。
|
|
21
|
-
-
|
|
21
|
+
- **入口选择**:统一入口 `@fulgurjs/federation/vue`——宿主代码全部来自 /vue,不会加载 React 适配代码(6.0.0 起 /bridge、/bridge/* 深层入口已移除)。
|
|
22
22
|
- **`sessionKey`**:受控登录代次(非业务 props)。置 `null` = 登出态(立即卸载、不再请求);换账号走「null → `clearAppContext()` → 新代次」顺序,保证 A 的 context 字段零残留。
|
|
23
23
|
- **`getContext`**:同步纯 getter(`src/host-session.ts`),桥接层校验其快照的 `sessionKey` 后才代写 AppContext。
|
|
24
24
|
- **`appProps`**:挂载时浅拷贝快照;函数引用(`onReady`)保留原引用;换顶层引用不重挂,需要重置时用 `:key`。
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { ref } from 'vue'
|
|
7
7
|
import { clearAppContext } from '@fulgurjs/federation/runtime'
|
|
8
|
-
import { createVueBridgeApp } from '@fulgurjs/federation/
|
|
8
|
+
import { createVueBridgeApp } from '@fulgurjs/federation/vue'
|
|
9
9
|
import { getLatestHostContext, login, logout } from './host-session'
|
|
10
10
|
|
|
11
11
|
// 工厂选项:retries 透传 loadRemote;getContext 在每次实际加载前同步取最新快照
|
|
@@ -51,7 +51,7 @@ async function doLogout(): Promise<void> {
|
|
|
51
51
|
|
|
52
52
|
<template>
|
|
53
53
|
<div style="font-family: sans-serif; padding: 16px; max-width: 720px">
|
|
54
|
-
<h1>Vue 宿主 × React 子应用(@fulgurjs/federation/
|
|
54
|
+
<h1>Vue 宿主 × React 子应用(@fulgurjs/federation/vue)</h1>
|
|
55
55
|
<p data-testid="demo-session">会话:{{ sessionKey ?? '未登录' }}({{ userName || '—' }})· onReady 次数:{{ readyCount }}</p>
|
|
56
56
|
|
|
57
57
|
<p>
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createApp, h } from 'vue'
|
|
2
2
|
import { createRouter, createWebHistory, useRoute } from 'vue-router'
|
|
3
|
-
import { createHostPages } from '@fulgurjs/federation/
|
|
3
|
+
import { createHostPages } from '@fulgurjs/federation/vue'
|
|
4
4
|
import App from './App.vue'
|
|
5
5
|
import HomePage from './pages/HomePage.vue'
|
|
6
6
|
import UtilsDemo from './pages/UtilsDemo.vue'
|
|
@@ -13,31 +13,38 @@ const hostPages = createHostPages({
|
|
|
13
13
|
remotePrefixes,
|
|
14
14
|
})
|
|
15
15
|
|
|
16
|
+
// 远程页面 Router 记录从页面表派生(route + spec 唯一来源 = fulgurjs.config.ts 的 pages;
|
|
17
|
+
// 业务自有路由仍归本 Router 管理——业务 Router 与联邦页面映射是两类事实)。
|
|
18
|
+
// 远程名按最长前缀从 remotePrefixes 解析(与运行时归属一致);params + query 全量透传给
|
|
19
|
+
// 远程页面组件(响应式:路由变化即重渲染)。
|
|
20
|
+
const remoteNameOf = (route: string): string => {
|
|
21
|
+
const prefix = Object.keys(remotePrefixes)
|
|
22
|
+
.filter((p) => route === p || route.startsWith(p + '/') || route.startsWith(p))
|
|
23
|
+
.sort((a, b) => b.length - a.length)[0]
|
|
24
|
+
const name = prefix ? remotePrefixes[prefix] : undefined
|
|
25
|
+
if (!name) throw new Error(`页面 ${route} 不匹配任何 remotePrefixes 前缀——请核对 fulgurjs.config.ts`)
|
|
26
|
+
return name
|
|
27
|
+
}
|
|
28
|
+
const remoteRoutes = pages.map((page) => ({
|
|
29
|
+
path: page.route,
|
|
30
|
+
component: {
|
|
31
|
+
setup() {
|
|
32
|
+
const route = useRoute()
|
|
33
|
+
return () =>
|
|
34
|
+
h(hostPages.component(`${remoteNameOf(page.route)}/${page.spec}`), {
|
|
35
|
+
...route.params,
|
|
36
|
+
...route.query,
|
|
37
|
+
})
|
|
38
|
+
},
|
|
39
|
+
},
|
|
40
|
+
}))
|
|
41
|
+
|
|
16
42
|
const router = createRouter({
|
|
17
43
|
history: createWebHistory(),
|
|
18
44
|
routes: [
|
|
19
45
|
{ path: '/', component: HomePage },
|
|
20
46
|
{ path: '/utils-demo', component: UtilsDemo },
|
|
21
|
-
|
|
22
|
-
// 远程页面:spec 经 hostPages.component(spec) 取异步组件(spec = 远程名 + exposes 键);
|
|
23
|
-
// route.params + route.query 作为 props 透传给远程页面组件
|
|
24
|
-
path: '/remote/home',
|
|
25
|
-
component: { render: () => h(hostPages.component('vue-remote/pages/HomePage')) },
|
|
26
|
-
},
|
|
27
|
-
{
|
|
28
|
-
path: '/remote/detail/:id',
|
|
29
|
-
// params + query 全量透传给远程页面组件(响应式:路由变化即重渲染)
|
|
30
|
-
component: {
|
|
31
|
-
setup() {
|
|
32
|
-
const route = useRoute()
|
|
33
|
-
return () =>
|
|
34
|
-
h(hostPages.component('vue-remote/pages/DetailPage'), {
|
|
35
|
-
id: route.params.id as string,
|
|
36
|
-
tab: (route.query.tab as string | undefined) ?? undefined,
|
|
37
|
-
})
|
|
38
|
-
},
|
|
39
|
-
},
|
|
40
|
-
},
|
|
47
|
+
...remoteRoutes,
|
|
41
48
|
],
|
|
42
49
|
})
|
|
43
50
|
|
|
@@ -11,8 +11,8 @@ importers:
|
|
|
11
11
|
host:
|
|
12
12
|
dependencies:
|
|
13
13
|
'@fulgurjs/federation':
|
|
14
|
-
specifier:
|
|
15
|
-
version:
|
|
14
|
+
specifier: 6.0.0
|
|
15
|
+
version: 6.0.0(vite@6.4.3)(vue-router@4.6.4(vue@3.5.43(typescript@5.9.3)))(vue@3.5.43(typescript@5.9.3))
|
|
16
16
|
vue:
|
|
17
17
|
specifier: ^3.5.13
|
|
18
18
|
version: 3.5.43(typescript@5.9.3)
|
|
@@ -33,8 +33,8 @@ importers:
|
|
|
33
33
|
remote:
|
|
34
34
|
dependencies:
|
|
35
35
|
'@fulgurjs/federation':
|
|
36
|
-
specifier:
|
|
37
|
-
version:
|
|
36
|
+
specifier: 6.0.0
|
|
37
|
+
version: 6.0.0(vite@6.4.3)(vue-router@4.6.4(vue@3.5.43(typescript@5.9.3)))(vue@3.5.43(typescript@5.9.3))
|
|
38
38
|
vue:
|
|
39
39
|
specifier: ^3.5.13
|
|
40
40
|
version: 3.5.43(typescript@5.9.3)
|
|
@@ -380,8 +380,8 @@ packages:
|
|
|
380
380
|
cpu: [x64]
|
|
381
381
|
os: [win32]
|
|
382
382
|
|
|
383
|
-
'@fulgurjs/federation@
|
|
384
|
-
resolution: {integrity: sha512-
|
|
383
|
+
'@fulgurjs/federation@6.0.0':
|
|
384
|
+
resolution: {integrity: sha512-h3/ZvxdJZVtbvQcQ/OycsTQq7J9LYTfDjpjtoLli0eMk1gOjr2xdvtYaKw57Rt+ccGyfJgYPCsF2U48vVkRFpg==}
|
|
385
385
|
engines: {node: '>=18'}
|
|
386
386
|
hasBin: true
|
|
387
387
|
peerDependencies:
|
|
@@ -889,7 +889,7 @@ snapshots:
|
|
|
889
889
|
'@esbuild/win32-x64@0.27.7':
|
|
890
890
|
optional: true
|
|
891
891
|
|
|
892
|
-
'@fulgurjs/federation@
|
|
892
|
+
'@fulgurjs/federation@6.0.0(vite@6.4.3)(vue-router@4.6.4(vue@3.5.43(typescript@5.9.3)))(vue@3.5.43(typescript@5.9.3))':
|
|
893
893
|
dependencies:
|
|
894
894
|
es-module-lexer: 1.7.0
|
|
895
895
|
esbuild: 0.27.7
|
|
@@ -2,7 +2,7 @@ packages:
|
|
|
2
2
|
- host
|
|
3
3
|
- remote
|
|
4
4
|
minimumReleaseAgeExclude:
|
|
5
|
-
- '@fulgurjs/federation@
|
|
5
|
+
- '@fulgurjs/federation@6.0.0'
|
|
6
6
|
# pnpm >=12 构建脚本批准(12 起弃用 onlyBuiltDependencies;pnpm 9-11 忽略本键:
|
|
7
7
|
# esbuild >=0.16 二进制经 optionalDependencies 平台包分发,postinstall 仅校验,不阻塞安装)
|
|
8
8
|
allowBuilds:
|
|
@@ -1,6 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"apps": [
|
|
3
|
-
{
|
|
4
|
-
|
|
3
|
+
{
|
|
4
|
+
"name": "remote",
|
|
5
|
+
"dir": "remote",
|
|
6
|
+
"port": 5213
|
|
7
|
+
},
|
|
8
|
+
{
|
|
9
|
+
"name": "host",
|
|
10
|
+
"dir": "host",
|
|
11
|
+
"port": 5214,
|
|
12
|
+
"host": true
|
|
13
|
+
}
|
|
5
14
|
]
|
|
6
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fulgurjs/federation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "6.1.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vite Module Federation for Vue and React: remote modules, shared dependencies and app bridges.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -13,6 +13,10 @@
|
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"require": "./dist/index.cjs"
|
|
15
15
|
},
|
|
16
|
+
"./vue": {
|
|
17
|
+
"types": "./dist/vue.d.ts",
|
|
18
|
+
"import": "./dist/vue.js"
|
|
19
|
+
},
|
|
16
20
|
"./runtime": {
|
|
17
21
|
"types": "./dist/runtime-entry.d.ts",
|
|
18
22
|
"import": "./dist/runtime-entry.js"
|
|
@@ -21,18 +25,6 @@
|
|
|
21
25
|
"types": "./dist/react.d.ts",
|
|
22
26
|
"import": "./dist/react.js"
|
|
23
27
|
},
|
|
24
|
-
"./bridge": {
|
|
25
|
-
"types": "./dist/bridge.d.ts",
|
|
26
|
-
"import": "./dist/bridge.js"
|
|
27
|
-
},
|
|
28
|
-
"./bridge/vue": {
|
|
29
|
-
"types": "./dist/bridge-vue.d.ts",
|
|
30
|
-
"import": "./dist/bridge-vue.js"
|
|
31
|
-
},
|
|
32
|
-
"./bridge/react": {
|
|
33
|
-
"types": "./dist/bridge-react.d.ts",
|
|
34
|
-
"import": "./dist/bridge-react.js"
|
|
35
|
-
},
|
|
36
28
|
"./package.json": "./package.json",
|
|
37
29
|
"./internal/context.js": {
|
|
38
30
|
"types": "./dist/context.d.ts",
|
|
@@ -74,37 +66,29 @@
|
|
|
74
66
|
"types": "./dist/bridge-host-react.d.ts",
|
|
75
67
|
"import": "./dist/bridge-host-react.js"
|
|
76
68
|
},
|
|
77
|
-
"./bridge
|
|
69
|
+
"./internal/bridge-router-core.js": {
|
|
70
|
+
"types": "./dist/bridge-router-core.d.ts",
|
|
71
|
+
"import": "./dist/bridge-router-core.js"
|
|
72
|
+
},
|
|
73
|
+
"./internal/bridge-router-vue.js": {
|
|
78
74
|
"types": "./dist/bridge-router-vue.d.ts",
|
|
79
75
|
"import": "./dist/bridge-router-vue.js"
|
|
80
76
|
},
|
|
81
|
-
"./bridge
|
|
77
|
+
"./internal/bridge-router-react.js": {
|
|
82
78
|
"types": "./dist/bridge-router-react.d.ts",
|
|
83
79
|
"import": "./dist/bridge-router-react.js"
|
|
84
80
|
}
|
|
85
81
|
},
|
|
86
82
|
"typesVersions": {
|
|
87
83
|
"*": {
|
|
84
|
+
"vue": [
|
|
85
|
+
"dist/vue.d.ts"
|
|
86
|
+
],
|
|
88
87
|
"runtime": [
|
|
89
88
|
"dist/runtime-entry.d.ts"
|
|
90
89
|
],
|
|
91
90
|
"react": [
|
|
92
91
|
"dist/react.d.ts"
|
|
93
|
-
],
|
|
94
|
-
"bridge/vue": [
|
|
95
|
-
"dist/bridge-vue.d.ts"
|
|
96
|
-
],
|
|
97
|
-
"bridge/react": [
|
|
98
|
-
"dist/bridge-react.d.ts"
|
|
99
|
-
],
|
|
100
|
-
"bridge": [
|
|
101
|
-
"dist/bridge.d.ts"
|
|
102
|
-
],
|
|
103
|
-
"bridge/router/vue": [
|
|
104
|
-
"dist/bridge-router-vue.d.ts"
|
|
105
|
-
],
|
|
106
|
-
"bridge/router/react": [
|
|
107
|
-
"dist/bridge-router-react.d.ts"
|
|
108
92
|
]
|
|
109
93
|
}
|
|
110
94
|
},
|
|
@@ -116,15 +100,18 @@
|
|
|
116
100
|
"CHANGELOG.md",
|
|
117
101
|
"DESIGN.md",
|
|
118
102
|
"examples",
|
|
119
|
-
"docs
|
|
120
|
-
"docs/
|
|
121
|
-
"docs
|
|
122
|
-
"docs/
|
|
123
|
-
"docs/
|
|
124
|
-
"docs/
|
|
103
|
+
"docs/zh/reference/api.md",
|
|
104
|
+
"docs/zh/reference/errors.md",
|
|
105
|
+
"docs/zh/migration.md",
|
|
106
|
+
"docs/en/reference/api.md",
|
|
107
|
+
"docs/en/reference/errors.md",
|
|
108
|
+
"docs/en/migration.md",
|
|
109
|
+
"docs/maintainers/webpack-mf-对照与缺口.md",
|
|
110
|
+
"docs/maintainers/沙箱边界审计.md",
|
|
111
|
+
"docs/maintainers/P5-vite7-8兼容矩阵.md"
|
|
125
112
|
],
|
|
126
113
|
"scripts": {
|
|
127
|
-
"build": "cp ../../README.md README.md && cp ../../README.en.md README.en.md && mkdir -p docs && cp ../../docs/
|
|
114
|
+
"build": "cp ../../README.md README.md && cp ../../README.en.md README.en.md && mkdir -p docs && mkdir -p docs/zh/reference docs/en/reference docs/maintainers && cp ../../docs/zh/reference/api.md ../../docs/zh/reference/errors.md docs/zh/reference/ && cp ../../docs/zh/migration.md docs/zh/ && cp ../../docs/en/reference/api.md ../../docs/en/reference/errors.md docs/en/reference/ && cp ../../docs/en/migration.md docs/en/ && cp ../../docs/maintainers/webpack-mf-对照与缺口.md ../../docs/maintainers/沙箱边界审计.md ../../docs/maintainers/P5-vite7-8兼容矩阵.md docs/maintainers/ && cp ../../CHANGELOG.md CHANGELOG.md && cp ../../DESIGN.md DESIGN.md && node scripts/sync-package-examples.mjs && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime.mjs && tsup src/index.ts src/pages.ts src/vue-adapter.ts src/react-adapter.ts src/context.ts src/bridge-core.ts src/bridge-errors.ts src/bridge-app-vue.ts src/bridge-app-react.ts src/bridge-host-vue.ts src/bridge-host-react.ts --format esm,cjs --dts --external vite --target node18 --clean && tsup src/runtime-entry.ts --format esm --dts --external vite --target node18 && tsup src/vue.ts --format esm --dts --external vite,vue,vue-router --target node18 && tsup src/react.ts --format esm --dts --external vite,react,react-dom,react-router-dom --target node18 && tsup src/bridge-router-vue.ts --format esm --dts --external vite,vue,vue-router --target node18 && tsup src/bridge-router-react.tsx --format esm --dts --external vite,react,react-dom,react-router-dom --target node18 && esbuild src/cli.ts --bundle --format=esm --target=node18 --platform=node --outfile=dist/cli.js && esbuild src/runtime/index.ts --bundle --format=esm --target=es2022 --minify --outfile=dist/runtime.js && node scripts/gen-runtime-entry.mjs && node scripts/check-gzip.mjs && node scripts/check-manual-codes.mjs",
|
|
128
115
|
"dev": "tsup --watch",
|
|
129
116
|
"test": "vitest run --dir tests",
|
|
130
117
|
"typecheck": "tsc --noEmit",
|
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
/** 统一逻辑位置:pathname 以 / 开头;search 空串或 ? 开头;hash 空串或 # 开头 */
|
|
2
|
-
interface BridgeLocation {
|
|
3
|
-
pathname: string;
|
|
4
|
-
search: string;
|
|
5
|
-
hash: string;
|
|
6
|
-
}
|
|
7
|
-
type BridgeNavigationResult = {
|
|
8
|
-
status: 'committed';
|
|
9
|
-
location: BridgeLocation;
|
|
10
|
-
} | {
|
|
11
|
-
status: 'cancelled';
|
|
12
|
-
location: BridgeLocation;
|
|
13
|
-
};
|
|
14
|
-
/** 宿主导航端口(宿主适配器把 Router 包装成本接口;逻辑路径不含部署 base) */
|
|
15
|
-
interface BridgeHostNavigation {
|
|
16
|
-
getLocation(): BridgeLocation;
|
|
17
|
-
subscribe(listener: (location: BridgeLocation) => void): () => void;
|
|
18
|
-
navigate(target: BridgeLocation, action: 'push' | 'replace', options?: {
|
|
19
|
-
signal?: AbortSignal;
|
|
20
|
-
}): Promise<BridgeNavigationResult>;
|
|
21
|
-
go(delta: number): void;
|
|
22
|
-
}
|
|
23
|
-
/** 子应用路由通道(桥接宿主按挂载代次创建,随 mount 第三参数交给子应用) */
|
|
24
|
-
interface BridgeChildRoute {
|
|
25
|
-
/**
|
|
26
|
-
* 远程 spec(宿主创建通道时标注,如 "remote-b/bridge");子应用路由接线
|
|
27
|
-
* (connectVueBridgeRouter/createReactBridgeRouter)的诊断错误用它定位真实远程,
|
|
28
|
-
* 缺省(纯 memory 小部件自建通道)回退 'child-router'。
|
|
29
|
-
*/
|
|
30
|
-
readonly spec?: string;
|
|
31
|
-
getLocation(): BridgeLocation;
|
|
32
|
-
subscribe(listener: (location: BridgeLocation) => void): () => void;
|
|
33
|
-
navigate(target: BridgeLocation, action: 'push' | 'replace'): Promise<BridgeNavigationResult>;
|
|
34
|
-
go(delta: number): void;
|
|
35
|
-
}
|
|
36
|
-
/** 挂载控制参数(mount 第三参数;不混入业务 props) */
|
|
37
|
-
interface BridgeMountOptions {
|
|
38
|
-
signal?: AbortSignal;
|
|
39
|
-
routing?: BridgeChildRoute;
|
|
40
|
-
}
|
|
41
|
-
/** 子应用路由协议声明(defineBridgeApp(工厂, { routing: true }) 时写入) */
|
|
42
|
-
interface BridgeRoutingProtocol {
|
|
43
|
-
protocol: 1;
|
|
44
|
-
}
|
|
45
|
-
/** 宿主组件 routing prop(独立控制通道,不进 appProps/Context) */
|
|
46
|
-
interface BridgeHostRouting {
|
|
47
|
-
/** 宿主路由视角的静态绝对路径,如 "/approval";同页各同步实例不得相同或重叠 */
|
|
48
|
-
basePath: string;
|
|
49
|
-
navigation: BridgeHostNavigation;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* 跨应用上下文标准字段表(§4.3,0.8.2 精简后)。
|
|
54
|
-
*
|
|
55
|
-
* 读写约定:宿主桥先写标准字段;远程 boot 只增不改宿主键;
|
|
56
|
-
* 嵌套对象(如 events)是引用共享,子应用挂属性即时可见(同 realm 直引用)。
|
|
57
|
-
*
|
|
58
|
-
* 精简记录(0.8.2):`token` 快照与 `formUrl`/`baseUrl` 从默认 provide 集合移除——
|
|
59
|
-
* token 快照与 getToken 函数引用重复(快照会过期),formUrl/baseUrl 自 0.7.0
|
|
60
|
-
* remoteComponent 直渲染后无消费点;项目如需可经扩展位自行提供。
|
|
61
|
-
*/
|
|
62
|
-
interface AppContext {
|
|
63
|
-
/** 宿主登录用户原始形态(只读约定) */
|
|
64
|
-
user: Record<string, any>;
|
|
65
|
-
/** 取最新 token(拉取式防过期;0.8.2 起 bridge 不再传一次性 token 快照,用本函数取值) */
|
|
66
|
-
getToken?: () => string | undefined;
|
|
67
|
-
/** 宿主 pinia 实例:子应用 useUserStore(ctx.store) 拿共享响应式状态 */
|
|
68
|
-
store?: unknown;
|
|
69
|
-
/** 宿主 Vue App 实例(同 realm 直引用):全局组件/指令注册目标 */
|
|
70
|
-
hostApp?: unknown;
|
|
71
|
-
/** EP locale 等 UI 配置(原 W4 字段) */
|
|
72
|
-
locale?: unknown;
|
|
73
|
-
/** 事件/方法池:events.main.* 宿主提供、events.bpm.* / events.lowcode.* 子应用反向注册 */
|
|
74
|
-
events?: Record<string, any>;
|
|
75
|
-
/**
|
|
76
|
-
* 非敏感登录代次 ID:宿主每次成功登录/重新登录生成新值,token 刷新但会话未变时沿用。
|
|
77
|
-
* 远程 onSession 按它去重(同一代次只执行一次)。不是用户 ID、不是 token、不作为授权凭证。
|
|
78
|
-
* 远程声明了 onSession 时必填(缺省即 MFU-013)。
|
|
79
|
-
*/
|
|
80
|
-
sessionKey?: string;
|
|
81
|
-
/** 项目扩展位(formUrl/baseUrl 等自定义键,按需自行提供) */
|
|
82
|
-
[key: string]: unknown;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/** 子应用桥接契约(远程 ./bridge 模块的默认导出;任务书 §3.2) */
|
|
86
|
-
interface BridgeApp {
|
|
87
|
-
/** 首次根提交完成时才算挂载成功;同一容器未卸载前重复 mount 是契约违例 */
|
|
88
|
-
mount(el: HTMLElement, props?: Record<string, unknown>, options?: BridgeMountOptions): void | Promise<void>;
|
|
89
|
-
/** 同步使当前挂载代次失效并清理已创建的 root;未知容器为 no-op */
|
|
90
|
-
unmount(el: HTMLElement): void;
|
|
91
|
-
/**
|
|
92
|
-
* 路由协议声明(URL 同步):defineBridgeApp(工厂, { routing: true }) 时写入
|
|
93
|
-
* { protocol: 1 }。宿主启用 routing 时必须存在且 protocol === 1(MFU-031),
|
|
94
|
-
* 不允许静默退回 memory 假装深链成功。
|
|
95
|
-
*/
|
|
96
|
-
routing?: BridgeRoutingProtocol;
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
export type { AppContext as A, BridgeHostRouting as B, BridgeApp as a };
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
import { A as AppContext } from './bridge-core-D37VanBl.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* React 宿主桥接工厂(/bridge、/bridge/react 导出 createReactBridgeApp;任务书 §3.4)。
|
|
6
|
-
*
|
|
7
|
-
* 定位:接收注入的 loadRemote(不静态引用运行时内核,dist 壳绑定),返回
|
|
8
|
-
* `ComponentType<{ appProps: P; sessionKey?: string | null }>`,负责:
|
|
9
|
-
* - DOM 所有权(§4.5):只创建并保持稳定的空挂载 el(fragment 的固定子节点);
|
|
10
|
-
* pending/error 占位是它的兄弟节点,宿主重渲染不 patch 子应用 root 内部;
|
|
11
|
-
* - 会话代次(§4.3):受控 sessionKey 驱动 挂载/换会话/登出;同会话重渲染不重挂;
|
|
12
|
-
* - StrictMode 安全(§4.5):双 effect 走 cleanup(作废+卸载)→setup(新代次) 顺序,
|
|
13
|
-
* 顺序 unmount/mount 不产生双实例或残留;
|
|
14
|
-
* - unmount 抛错(BN09):报告 MFU-016(phase: unmount)并封锁该容器的新挂载。
|
|
15
|
-
*
|
|
16
|
-
* appProps 是挂载时浅拷贝快照(顶层替换不追踪,重挂由 key 重建);sessionKey
|
|
17
|
-
* 是桥接控制参数,不混入业务 props。
|
|
18
|
-
*/
|
|
19
|
-
|
|
20
|
-
/** 渲染函数形态的错误占位:(error, retry) => ReactNode */
|
|
21
|
-
type BridgeErrorFallback = (error: unknown, retry: () => void) => ReactNode;
|
|
22
|
-
interface ReactBridgeAppOptions {
|
|
23
|
-
/** 加载 pending 占位(默认 null) */
|
|
24
|
-
fallback?: ReactNode;
|
|
25
|
-
/** 加载/挂载失败占位;默认内置中文诊断 + 「重试加载 / 刷新页面重试」 */
|
|
26
|
-
error?: ReactNode | BridgeErrorFallback;
|
|
27
|
-
/** 透传现行 loadRemote 的重试选项(0-10 整数),不另叠自动重试 */
|
|
28
|
-
retries?: number;
|
|
29
|
-
/** 本次桥接加载等待上限 ms;不取消已发出的共享请求,迟到结果一律丢弃 */
|
|
30
|
-
timeout?: number;
|
|
31
|
-
/** 无副作用的同步 getter:首次、重试及换会话的实际加载前返回本次所需上下文快照 */
|
|
32
|
-
getContext?: () => Partial<AppContext> & Record<string, unknown>;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export type { BridgeErrorFallback as B, ReactBridgeAppOptions as R };
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { Component } from 'vue';
|
|
2
|
-
import { A as AppContext } from './bridge-core-D37VanBl.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Vue 宿主桥接工厂(/bridge、/bridge/vue 导出 createVueBridgeApp;任务书 §3.4)。
|
|
6
|
-
*
|
|
7
|
-
* 定位:接收注入的 loadRemote(不静态引用运行时内核,dist 壳绑定),返回一个
|
|
8
|
-
* 包装组件 `{ appProps: P; sessionKey?: string | null }`,负责:
|
|
9
|
-
* - DOM 所有权(§4.5):只创建并保持稳定的空挂载 el(多根 fragment 的固定子节点);
|
|
10
|
-
* pending/error 占位是它的兄弟节点,宿主重渲染不 patch 子应用 root 内部;
|
|
11
|
-
* - 会话代次(§4.3):受控 sessionKey 驱动 挂载/换会话/登出;同会话重渲染不重挂;
|
|
12
|
-
* - 错误诊断:契约非法 MFU-015、生命周期失败 MFU-016(phase 区分)、会话矛盾 MFU-017;
|
|
13
|
-
* 默认占位含「重试加载 / 刷新页面重试」两条恢复操作(§4.4)。
|
|
14
|
-
*
|
|
15
|
-
* appProps 是挂载时浅拷贝快照(顶层替换不追踪、不重渲染子应用,重挂由 :key 重建);
|
|
16
|
-
* sessionKey 是桥接控制参数,不混入业务 props。
|
|
17
|
-
*/
|
|
18
|
-
|
|
19
|
-
interface VueBridgeAppOptions {
|
|
20
|
-
/** 加载 pending 占位组件(默认无占位节点) */
|
|
21
|
-
loadingComponent?: Component;
|
|
22
|
-
/** 加载/挂载失败占位(完全接管,契约不变:只接收 error prop;默认内置中文诊断 + 两条恢复操作) */
|
|
23
|
-
errorComponent?: Component;
|
|
24
|
-
/** 透传现行 loadRemote 的重试选项(0-10 整数),不另叠自动重试 */
|
|
25
|
-
retries?: number;
|
|
26
|
-
/** 本次桥接加载等待上限 ms;不取消已发出的共享请求,迟到结果一律丢弃 */
|
|
27
|
-
timeout?: number;
|
|
28
|
-
/** 无副作用的同步 getter:首次、重试及换会话的实际加载前返回本次所需上下文快照 */
|
|
29
|
-
getContext?: () => Partial<AppContext> & Record<string, unknown>;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
export type { VueBridgeAppOptions as V };
|
package/dist/bridge-react.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
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
|
-
|
|
7
|
-
/** React 宿主桥接工厂:返回 `ComponentType<{ appProps: P; sessionKey?: string | null }>` */
|
|
8
|
-
declare const createReactBridgeApp: <P = Record<string, unknown>>(spec: string, options?: ReactBridgeAppOptions) => react.ComponentType<{
|
|
9
|
-
appProps?: P;
|
|
10
|
-
sessionKey?: string | null;
|
|
11
|
-
routing?: BridgeHostRouting;
|
|
12
|
-
}>;
|
|
13
|
-
|
|
14
|
-
export { ReactBridgeAppOptions, createReactBridgeApp };
|
package/dist/bridge-react.js
DELETED
package/dist/bridge-vue.d.ts
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import * as vue from 'vue';
|
|
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
|
-
|
|
5
|
-
/** Vue 宿主桥接工厂:返回 `{ appProps: P; sessionKey?: string | null }` 形态的包装组件 */
|
|
6
|
-
declare const createVueBridgeApp: <P = Record<string, unknown>>(spec: string, options?: VueBridgeAppOptions) => vue.Component;
|
|
7
|
-
|
|
8
|
-
export { VueBridgeAppOptions, createVueBridgeApp };
|
package/dist/bridge-vue.js
DELETED
package/dist/bridge.d.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import * as react from 'react';
|
|
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
|
-
import * as vue from 'vue';
|
|
7
|
-
import { V as VueBridgeAppOptions } from './bridge-host-vue-B3GHaQAC.js';
|
|
8
|
-
|
|
9
|
-
/** Vue 宿主桥接工厂:返回 `{ appProps: P; sessionKey?: string | null }` 形态的包装组件 */
|
|
10
|
-
declare const createVueBridgeApp: <P = Record<string, unknown>>(spec: string, options?: VueBridgeAppOptions) => vue.Component;
|
|
11
|
-
/** React 宿主桥接工厂:返回 `ComponentType<{ appProps: P; sessionKey?: string | null }>` */
|
|
12
|
-
declare const createReactBridgeApp: <P = Record<string, unknown>>(spec: string, options?: ReactBridgeAppOptions) => react.ComponentType<{
|
|
13
|
-
appProps?: P;
|
|
14
|
-
sessionKey?: string | null;
|
|
15
|
-
routing?: BridgeHostRouting;
|
|
16
|
-
}>;
|
|
17
|
-
|
|
18
|
-
export { ReactBridgeAppOptions, VueBridgeAppOptions, createReactBridgeApp, createVueBridgeApp };
|
package/dist/bridge.js
DELETED
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { loadRemote } from "./runtime.js";
|
|
2
|
-
import { createVueBridgeAppWithLoader } from "./bridge-host-vue.js";
|
|
3
|
-
import { createReactBridgeAppWithLoader } from "./bridge-host-react.js";
|
|
4
|
-
export const createVueBridgeApp = createVueBridgeAppWithLoader(loadRemote);
|
|
5
|
-
export const createReactBridgeApp = createReactBridgeAppWithLoader(loadRemote);
|