@fulgurjs/federation 6.8.7 → 6.9.1
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 +14 -0
- package/README.en.md +3 -0
- package/README.md +3 -0
- package/dist/application-core-BuhXQmLF.d.cts +16 -0
- package/dist/application-core-DWI3eKme.d.ts +16 -0
- package/dist/bridge-app-react.cjs +177 -9
- package/dist/bridge-app-react.d.cts +15 -3
- package/dist/bridge-app-react.d.ts +15 -3
- package/dist/bridge-app-react.js +101 -9
- package/dist/bridge-app-vue.cjs +138 -12
- package/dist/bridge-app-vue.d.cts +20 -5
- package/dist/bridge-app-vue.d.ts +20 -5
- package/dist/bridge-app-vue.js +62 -12
- package/dist/bridge-host-react.d.cts +1 -1
- package/dist/bridge-host-react.d.ts +1 -1
- package/dist/bridge-host-vue.d.cts +1 -1
- package/dist/bridge-host-vue.d.ts +1 -1
- package/dist/chunk-6OB47FSR.js +81 -0
- package/dist/cli.js +349 -23
- package/dist/index.cjs +7 -6
- package/dist/index.js +7 -6
- package/dist/react-adapter.d.cts +1 -1
- package/dist/react-adapter.d.ts +1 -1
- package/dist/react.d.ts +29 -4
- package/dist/react.js +1 -0
- package/dist/{remote-types-xf1B6_pK.d.ts → remote-types-COmBhjRc.d.ts} +1 -1
- package/dist/{remote-types-58hdbx6x.d.cts → remote-types-CStGOJwu.d.cts} +1 -1
- package/dist/runtime.js +1 -1
- package/dist/vue-adapter.d.cts +1 -1
- package/dist/vue-adapter.d.ts +1 -1
- package/dist/vue-store.cjs +40 -0
- package/dist/vue-store.d.cts +4 -0
- package/dist/vue-store.d.ts +4 -0
- package/dist/vue-store.js +15 -0
- package/dist/vue.d.ts +37 -6
- package/dist/vue.js +2 -0
- package/docs/en/reference/api.md +38 -2
- package/docs/en/reference/types.md +27 -0
- package/docs/zh/reference/api.md +46 -2
- package/docs/zh/reference/types.md +27 -0
- package/examples/templates/README.md +3 -0
- package/examples/templates/react-host-vue-remote/README.md +24 -0
- package/examples/templates/react-host-vue-remote/package.json +2 -1
- package/examples/templates/react-host-vue-remote/pnpm-lock.yaml +189 -189
- package/examples/templates/react-host-vue-remote/pnpm-workspace.yaml +1 -1
- package/examples/templates/react-host-vue-remote/react-host/package.json +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/application.tsx +62 -0
- package/examples/templates/react-host-vue-remote/react-host/src/main.tsx +2 -62
- package/examples/templates/react-host-vue-remote/scripts/prod.mjs +101 -0
- package/examples/templates/react-host-vue-remote/vue-remote/README.md +17 -16
- package/examples/templates/react-host-vue-remote/vue-remote/fulgurjs.config.ts +2 -2
- package/examples/templates/react-host-vue-remote/vue-remote/package.json +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/AboutPage.vue +1 -0
- package/examples/templates/react-host-vue-remote/vue-remote/src/App.vue +15 -5
- package/examples/templates/react-host-vue-remote/vue-remote/src/HomePage.vue +1 -0
- package/examples/templates/react-host-vue-remote/vue-remote/src/application.ts +19 -0
- package/examples/templates/react-host-vue-remote/vue-remote/src/main.ts +2 -15
- package/examples/templates/react-react/README.md +25 -1
- package/examples/templates/react-react/host/package.json +1 -1
- package/examples/templates/react-react/host/src/application.tsx +33 -0
- package/examples/templates/react-react/host/src/main.tsx +3 -32
- package/examples/templates/react-react/package.json +2 -1
- package/examples/templates/react-react/pnpm-lock.yaml +123 -123
- 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/remote/src/application.tsx +11 -0
- package/examples/templates/react-react/remote/src/main.tsx +3 -10
- package/examples/templates/react-react/scripts/prod.mjs +101 -0
- package/examples/templates/showcase/README.md +35 -7
- package/examples/templates/showcase/package.json +2 -1
- package/examples/templates/showcase/pnpm-lock.yaml +196 -196
- 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/application.tsx +28 -0
- package/examples/templates/showcase/react-host/src/demo-log.ts +5 -8
- package/examples/templates/showcase/react-host/src/main.tsx +2 -33
- package/examples/templates/showcase/react-host/src/routing.ts +2 -2
- package/examples/templates/showcase/react-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/react-remote/package.json +1 -1
- package/examples/templates/showcase/react-remote/src/ChildLayout.tsx +3 -2
- package/examples/templates/showcase/react-remote/src/{bridge.tsx → application.tsx} +21 -21
- package/examples/templates/showcase/react-remote/src/child-bus.ts +23 -23
- package/examples/templates/showcase/react-remote/src/main.tsx +2 -18
- package/examples/templates/showcase/react-remote/src/pages/Locked.tsx +2 -1
- package/examples/templates/showcase/react-remote/src/pages/OrderDetail.tsx +2 -1
- package/examples/templates/showcase/react-remote/src/pages/OrderList.tsx +2 -1
- package/examples/templates/showcase/scripts/prod.mjs +101 -0
- package/examples/templates/showcase/vue-host/package.json +1 -1
- package/examples/templates/showcase/vue-host/src/application.ts +28 -0
- package/examples/templates/showcase/vue-host/src/demo-log.ts +4 -7
- package/examples/templates/showcase/vue-host/src/main.ts +2 -30
- package/examples/templates/showcase/vue-host/src/routing.ts +2 -2
- package/examples/templates/showcase/vue-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/vue-remote/package.json +1 -1
- package/examples/templates/showcase/vue-remote/src/ChildLayout.vue +3 -2
- package/examples/templates/showcase/vue-remote/src/{bridge.ts → application.ts} +10 -13
- package/examples/templates/showcase/vue-remote/src/child-bus.ts +23 -23
- package/examples/templates/showcase/vue-remote/src/main.ts +2 -16
- package/examples/templates/showcase/vue-remote/src/pages/Locked.vue +2 -1
- package/examples/templates/showcase/vue-remote/src/pages/OrderDetail.vue +2 -1
- package/examples/templates/showcase/vue-remote/src/pages/OrderList.vue +2 -1
- package/examples/templates/vue-host-react-remote/README.md +24 -0
- package/examples/templates/vue-host-react-remote/package.json +2 -1
- package/examples/templates/vue-host-react-remote/pnpm-lock.yaml +184 -184
- package/examples/templates/vue-host-react-remote/pnpm-workspace.yaml +1 -1
- package/examples/templates/vue-host-react-remote/react-remote/README.md +17 -17
- package/examples/templates/vue-host-react-remote/react-remote/fulgurjs.config.ts +2 -2
- package/examples/templates/vue-host-react-remote/react-remote/package.json +1 -1
- package/examples/templates/vue-host-react-remote/react-remote/src/{bridge.tsx → application.tsx} +13 -24
- package/examples/templates/vue-host-react-remote/react-remote/src/main.tsx +2 -7
- package/examples/templates/vue-host-react-remote/scripts/prod.mjs +101 -0
- package/examples/templates/vue-host-react-remote/vue-host/package.json +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/application.ts +5 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/main.ts +2 -4
- package/examples/templates/vue-vue/README.md +25 -1
- package/examples/templates/vue-vue/host/package.json +1 -1
- package/examples/templates/vue-vue/host/src/application.ts +54 -0
- package/examples/templates/vue-vue/host/src/main.ts +3 -50
- package/examples/templates/vue-vue/package.json +2 -1
- package/examples/templates/vue-vue/pnpm-lock.yaml +182 -182
- 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/remote/src/application.ts +6 -0
- package/examples/templates/vue-vue/remote/src/main.ts +3 -5
- package/examples/templates/vue-vue/scripts/prod.mjs +101 -0
- package/package.json +14 -9
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote/metadata.json +0 -15
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote/modules.d.ts +0 -14
- package/examples/templates/react-host-vue-remote/react-host/src/fulgurjs/types/bridge-vue-remote/registry.d.ts +0 -10
- package/examples/templates/react-host-vue-remote/vue-remote/src/bridge.ts +0 -57
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote/metadata.json +0 -16
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote/modules.d.ts +0 -71
- package/examples/templates/showcase/react-host/src/fulgurjs/types/vue-remote/registry.d.ts +0 -10
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote/metadata.json +0 -16
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote/modules.d.ts +0 -79
- package/examples/templates/showcase/vue-host/src/fulgurjs/types/react-remote/registry.d.ts +0 -10
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote/metadata.json +0 -16
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote/modules.d.ts +0 -10
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/types/bridge-react-remote/registry.d.ts +0 -10
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
# 双向桥接 URL 同步(examples/templates/showcase)
|
|
2
2
|
|
|
3
|
+
> 本目录是 6.9.0 源码候选:已改用 defineApplication,尚未测试和发布。源码依赖已锁定 6.9.0;正式发布前不要拿旧 registry 包运行这份代码。验收先使用本次候选 tarball,发布后再按下列冻结安装命令验证正式包。
|
|
4
|
+
|
|
5
|
+
|
|
3
6
|
`@fulgurjs/federation` 桥接 URL 同步的双向旗舰演示(API 见[文档中心](https://github.com/chenmingye/fulgurjs-federation/blob/master/docs/README.md)):
|
|
4
7
|
两个方向的宿主 × 子应用各一套——
|
|
5
8
|
|
|
@@ -82,12 +85,12 @@ curl --noproxy '*' -s -o /dev/null -w '%{http_code}\n' http://localhost:5335/@fu
|
|
|
82
85
|
| 插件公开 API | 入口 | 本演示接线位置 |
|
|
83
86
|
|---|---|---|
|
|
84
87
|
| `createVueBridgeApp(spec, options)` | `@fulgurjs/federation/vue` | `vue-host/src/pages/BridgeReactPage.vue`(`<RemoteReactBridge :routing="routing" :app-props="appProps" />`) |
|
|
85
|
-
| `createVueBridgeNavigation(router)` | `@fulgurjs/federation/vue` | `vue-host/src/routing.ts
|
|
86
|
-
| `
|
|
88
|
+
| `createVueBridgeNavigation(router)` | `@fulgurjs/federation/vue` | `vue-host/src/routing.ts`(宿主导航端口,application.ts 组装后 `initBridgeRouting(router)`) |
|
|
89
|
+
| `defineApplication(factory, { routing: true })` → 返回 `{ app, router }` | `@fulgurjs/federation/vue` | `vue-remote/src/application.ts`(根据 mode 选择 web/memory history;插件等待初始路由并安装) |
|
|
87
90
|
| `createReactBridgeApp(spec, options)` | `@fulgurjs/federation/react` | `react-host/src/pages/BridgeVuePage.tsx`(`<RemoteVueBridge routing={routing} appProps={appProps} />`) |
|
|
88
91
|
| `createReactBridgeNavigation(router, { canNavigate?, basename? })`(仅 data router) | `@fulgurjs/federation/react` | `react-host/src/routing.ts`(`createBrowserRouter` 实例组装后初始化) |
|
|
89
|
-
| `createReactBridgeRouter(routing, routes, { signal })` → `{ element }`
|
|
90
|
-
| `
|
|
92
|
+
| `createReactBridgeRouter(routing, routes, { signal })` → `{ element, dispose }` 作为工厂返回值 | `@fulgurjs/federation/react` | `react-remote/src/application.tsx`(`/` 经 loader `redirect('/orders')` 以 replace 规范化) |
|
|
93
|
+
| `defineApplication(factory, { routing: true })`(协议声明,缺失即 MFU-031) | `@fulgurjs/federation/vue`(Vue)/ `@fulgurjs/federation/react`(React) | `vue-remote/src/application.ts`、`react-remote/src/application.tsx`(实例 mode/signal;独立与桥接复用同一套路由) |
|
|
91
94
|
| `BridgeHostRouting`(`{ basePath, navigation }` 组件 prop,独立控制通道不进 appProps) | 类型面见 [API 参考](https://github.com/chenmingye/fulgurjs-federation/blob/master/docs/zh/reference/api.md) | `vue-host/src/routing.ts`、`react-host/src/routing.ts`(basePath 常量 `BRIDGE_BASE_PATH`) |
|
|
92
95
|
| `BridgeChildRoute` / `BridgeLocation`(通道与位置契约) | `@fulgurjs/federation/vue`、`@fulgurjs/federation/react` | 由插件随 mount 第三参数注入子应用;两端仓库源码 `packages/plugin/src/bridge-router-core.ts` |
|
|
93
96
|
|
|
@@ -103,7 +106,7 @@ curl --noproxy '*' -s -o /dev/null -w '%{http_code}\n' http://localhost:5335/@fu
|
|
|
103
106
|
## 构建 / 类型检查
|
|
104
107
|
|
|
105
108
|
```bash
|
|
106
|
-
#
|
|
109
|
+
# 在各应用目录执行;这是验收命令,不代表本轮已经通过
|
|
107
110
|
pnpm run types # 远程类型同步/验证(宿主同步远程声明;提供方验证生成)
|
|
108
111
|
pnpm run typecheck # React 工程 tsc --noEmit;Vue 工程 vue-tsc --noEmit
|
|
109
112
|
pnpm run build
|
|
@@ -117,7 +120,7 @@ pnpm run build
|
|
|
117
120
|
2. 宿主 `fulgurjs.config.ts` 里 `remotes` 的 dev 地址(`vue-host` 指向 react-remote 的 5333;`react-host` 指向 vue-remote 的 5335);
|
|
118
121
|
3. 根 `scripts/dev.config.json` 里该应用的 `port`(**必改**:启动器预检/探活都读它)。
|
|
119
122
|
|
|
120
|
-
|
|
123
|
+
生产部署形态(重要):两个宿主的默认构建 base 都是根,**不能部署到同一站点的根**(两份 `index.html` 会互相覆盖)。按两个站点部署——
|
|
121
124
|
|
|
122
125
|
- 站点 A:`vue-host/dist` 部署在根,`react-remote/dist` 部署在同站 `/react-remote/` 子路径(vue-host 的 prod 地址);
|
|
123
126
|
- 站点 B:`react-host/dist` 部署在另一个站点的根,`vue-remote/dist` 部署在该站 `/vue-remote/` 子路径(react-host 的 prod 地址);
|
|
@@ -127,4 +130,29 @@ pnpm run build
|
|
|
127
130
|
|
|
128
131
|
## 查看应用运行模式
|
|
129
132
|
|
|
130
|
-
子应用显示“当前应用被桥接:true”;Vue 宿主观测台显示“当前宿主被桥接:false”。两者同页并存也不会串模式。Vue 在组件 setup 中调用 `hasBridgeMount(getCurrentInstance()?.appContext.app)`;React 在桥接工厂中查询 `hasBridgeMount(ctx)`,通过 props
|
|
133
|
+
子应用显示“当前应用被桥接:true”;Vue 宿主观测台显示“当前宿主被桥接:false”。两者同页并存也不会串模式。Vue 在组件 setup 中调用 `hasBridgeMount(getCurrentInstance()?.appContext.app)`;React 在桥接工厂中查询 `hasBridgeMount(ctx)`,通过 props 传给布局。独立启动的查询结果为 false;独立子应用也显示同一套工单列表、详情、设置和导航,不使用健康检查壳。该值描述实例的运行方式,不是当前挂载数量。
|
|
134
|
+
|
|
135
|
+
## 一键运行生产产物
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
pnpm build
|
|
139
|
+
pnpm prod
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
`prod` 只服务本次 dist,不启动远程开发服务器。它复用 scripts/dev.config.json 的宿主端口,从实际构建入口推导 base,并把远程静态产物挂在同源子路径。无需为本地复现手写 Nginx;部署真实服务器时仍按部署指南配置。多宿主模板分别启动各宿主地址,不把两个宿主的根资源混在一起。先停止 dev,端口占用会失败并停止本次已起服务;不会关闭已有占用进程。Ctrl+C 关闭本次生产服务。
|
|
143
|
+
|
|
144
|
+
## 插件代码阅读地图
|
|
145
|
+
|
|
146
|
+
| 文件 | 职责 |
|
|
147
|
+
|---|---|
|
|
148
|
+
| `react-host/src/application.tsx` | 本应用唯一装配;main 只负责调用 start |
|
|
149
|
+
| `react-remote/src/application.tsx` | 本应用唯一装配;main 只负责调用 start |
|
|
150
|
+
| `vue-host/src/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
151
|
+
| `vue-remote/src/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
152
|
+
| `react-host/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
153
|
+
| `react-remote/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
154
|
+
| `vue-host/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
155
|
+
| `vue-remote/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
156
|
+
| `scripts/dev.mjs` / `scripts/prod.mjs` | 统一开发/生产启动器;业务接入不复制它们到应用源码 |
|
|
157
|
+
|
|
158
|
+
`application` 是新增的插件装配文件,`main` 是已有入口接线;页面组件、业务路由、权限和数据不是每个项目都必写的联邦配置。跨框架基础组合不逐页登记子应用菜单;逐页远程页面模板的页面表仅服务它所展示的逐页场景。`src/fulgurjs/types/` 是插件生成目录,按远程实际版本同步,不维护人工伪造的声明或旧缓存。
|