@fulgurjs/federation 6.11.5 → 6.11.7
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 +11 -0
- package/dist/cli.js +49 -8
- package/dist/index.cjs +2 -2
- package/dist/index.js +2 -2
- package/dist/runtime.js +1 -1
- package/docs/en/reference/errors.md +1 -1
- package/docs/zh/reference/errors.md +1 -1
- package/examples/templates/README.md +5 -1
- package/examples/templates/react-host-vue-remote/README.md +2 -2
- package/examples/templates/react-host-vue-remote/react-host/src/{application.tsx → fulgurjs/host/application.tsx} +2 -1
- package/examples/templates/react-host-vue-remote/react-host/src/{host-session.ts → fulgurjs/host/session.ts} +1 -1
- package/examples/templates/react-host-vue-remote/react-host/src/main.tsx +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/README.md +2 -2
- package/examples/templates/react-host-vue-remote/vue-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/App.vue +1 -1
- package/examples/templates/react-host-vue-remote/vue-remote/src/{application.ts → fulgurjs/exposes/application.ts} +4 -3
- package/examples/templates/react-host-vue-remote/vue-remote/src/main.ts +1 -1
- package/examples/templates/react-react/README.md +5 -5
- package/examples/templates/react-react/host/README.md +1 -1
- package/examples/templates/react-react/host/src/{application.tsx → fulgurjs/host/application.tsx} +3 -2
- package/examples/templates/react-react/host/src/{remotePages.tsx → fulgurjs/host/remotePages.tsx} +1 -1
- package/examples/templates/react-react/host/src/main.tsx +1 -1
- package/examples/templates/react-react/remote/README.md +4 -4
- package/examples/templates/react-react/remote/fulgurjs.config.ts +4 -4
- package/examples/templates/react-react/remote/src/App.tsx +1 -1
- package/examples/templates/react-react/remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +2 -1
- package/examples/templates/react-react/remote/src/main.tsx +1 -1
- package/examples/templates/showcase/README.md +13 -13
- package/examples/templates/showcase/react-host/src/GuardBanner.tsx +2 -2
- package/examples/templates/showcase/react-host/src/Layout.tsx +1 -1
- package/examples/templates/showcase/react-host/src/ObsPanel.tsx +2 -2
- package/examples/templates/showcase/react-host/src/{pages → fulgurjs/host}/BridgeVuePage.tsx +4 -4
- package/examples/templates/showcase/react-host/src/{application.tsx → fulgurjs/host/application.tsx} +5 -4
- package/examples/templates/showcase/react-host/src/{demo-log.ts → fulgurjs/host/demo-log.ts} +1 -1
- package/examples/templates/showcase/react-host/src/{routing.ts → fulgurjs/host/routing.ts} +1 -1
- package/examples/templates/showcase/react-host/src/main.tsx +1 -1
- package/examples/templates/showcase/react-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/react-remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +7 -6
- package/examples/templates/showcase/react-remote/src/main.tsx +1 -1
- package/examples/templates/showcase/vue-host/src/App.vue +1 -1
- package/examples/templates/showcase/vue-host/src/GuardBanner.vue +1 -1
- package/examples/templates/showcase/vue-host/src/ObsPanel.vue +2 -2
- package/examples/templates/showcase/vue-host/src/{pages → fulgurjs/host}/BridgeReactPage.vue +4 -4
- package/examples/templates/showcase/vue-host/src/{application.ts → fulgurjs/host/application.ts} +5 -4
- package/examples/templates/showcase/vue-host/src/{demo-log.ts → fulgurjs/host/demo-log.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/{guard.ts → fulgurjs/host/guard.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/{routing.ts → fulgurjs/host/routing.ts} +1 -1
- package/examples/templates/showcase/vue-host/src/main.ts +1 -1
- package/examples/templates/showcase/vue-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/showcase/vue-remote/src/{application.ts → fulgurjs/exposes/application.ts} +7 -6
- package/examples/templates/showcase/vue-remote/src/main.ts +1 -1
- package/examples/templates/vue-host-react-remote/README.md +2 -2
- package/examples/templates/vue-host-react-remote/react-remote/README.md +2 -2
- package/examples/templates/vue-host-react-remote/react-remote/fulgurjs.config.ts +1 -1
- package/examples/templates/vue-host-react-remote/react-remote/src/{application.tsx → fulgurjs/exposes/application.tsx} +1 -0
- package/examples/templates/vue-host-react-remote/react-remote/src/main.tsx +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/README.md +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/App.vue +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/fulgurjs/host/application.ts +6 -0
- package/examples/templates/vue-host-react-remote/vue-host/src/main.ts +1 -1
- package/examples/templates/vue-vue/README.md +6 -6
- package/examples/templates/vue-vue/host/src/{application.ts → fulgurjs/host/application.ts} +5 -4
- package/examples/templates/vue-vue/host/src/main.ts +1 -1
- package/examples/templates/vue-vue/host/src/pages/UtilsDemo.vue +1 -1
- package/examples/templates/vue-vue/remote/README.md +4 -4
- package/examples/templates/vue-vue/remote/fulgurjs.config.ts +4 -4
- package/examples/templates/vue-vue/remote/src/App.vue +1 -1
- package/examples/templates/vue-vue/remote/src/{application.ts → fulgurjs/exposes/application.ts} +2 -1
- package/examples/templates/vue-vue/remote/src/main.ts +1 -1
- package/package.json +1 -1
- package/examples/templates/vue-host-react-remote/vue-host/src/application.ts +0 -5
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/ClickButton.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.tsx +0 -0
- /package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/utils.ts +0 -0
- /package/examples/templates/vue-host-react-remote/vue-host/src/{host-session.ts → fulgurjs/host/session.ts} +0 -0
- /package/examples/templates/vue-vue/host/src/{type-demo.ts → fulgurjs/host/type-demo.ts} +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/ClickButton.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.vue +0 -0
- /package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/utils.ts +0 -0
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import application from './application'
|
|
1
|
+
import application from './fulgurjs/exposes/application'
|
|
2
2
|
void application.start('#root', { label: '独立 React 子应用' }).catch(console.error)
|
|
@@ -20,6 +20,6 @@ pnpm build # 构建完整组合
|
|
|
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
|
-
- **`getContext`**:同步纯 getter(`src/host
|
|
23
|
+
- **`getContext`**:同步纯 getter(`src/fulgurjs/host/session.ts`),桥接层校验其快照的 `sessionKey` 后才代写 AppContext。
|
|
24
24
|
- **`appProps`**:挂载时浅拷贝快照;函数引用(`onReady`)保留原引用;换顶层引用不重挂,需要重置时用 `:key`。
|
|
25
25
|
- 错误占位默认内置中文诊断 +「重试加载 / 刷新页面重试」;可用 `errorComponent` 完全接管。
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
import { ref } from 'vue'
|
|
7
7
|
import { clearAppContext } from '@fulgurjs/federation/runtime'
|
|
8
8
|
import { createVueBridgeApp } from '@fulgurjs/federation/vue'
|
|
9
|
-
import { getLatestHostContext, login, logout } from './host
|
|
9
|
+
import { getLatestHostContext, login, logout } from './fulgurjs/host/session'
|
|
10
10
|
|
|
11
11
|
// 工厂选项:retries 透传 loadRemote;getContext 在每次实际加载前同步取最新快照
|
|
12
12
|
const RemoteReactApp = createVueBridgeApp('bridge-react-remote/bridge', {
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import application from './application'
|
|
1
|
+
import application from './fulgurjs/host/application'
|
|
2
2
|
void application.start('#app').catch(console.error)
|
|
@@ -34,9 +34,9 @@ pnpm dev # 同时启动远程和宿主
|
|
|
34
34
|
|
|
35
35
|
| 功能 | 位置 |
|
|
36
36
|
| --- | --- |
|
|
37
|
-
| 远程可点击组件(计数、本地状态在远程组件内) | `remote/src/exposes/ClickButton.vue`,宿主首页消费 |
|
|
38
|
-
| 普通 TS 模块调用 | `remote/src/exposes/utils.ts`,`host/src/pages/UtilsDemo.vue` |
|
|
39
|
-
| 联邦页面(远程首页 / 带参数详情页) | `remote/src/exposes/pages/`,页面表见 `host/fulgurjs.config.ts` |
|
|
37
|
+
| 远程可点击组件(计数、本地状态在远程组件内) | `remote/src/fulgurjs/exposes/ClickButton.vue`,宿主首页消费 |
|
|
38
|
+
| 普通 TS 模块调用 | `remote/src/fulgurjs/exposes/utils.ts`,`host/src/pages/UtilsDemo.vue` |
|
|
39
|
+
| 联邦页面(远程首页 / 带参数详情页) | `remote/src/fulgurjs/exposes/pages/`,页面表见 `host/fulgurjs.config.ts` |
|
|
40
40
|
| 宿主导航 + 懒加载(不批量预取) | `host/src/App.vue` + `host/src/main.ts`(路由级按需加载) |
|
|
41
41
|
| 默认加载/错误/恢复占位 | 插件内置(`remoteComponent` / `createHostPages`),示例不自建错误组件 |
|
|
42
42
|
|
|
@@ -45,7 +45,7 @@ pnpm dev # 同时启动远程和宿主
|
|
|
45
45
|
启动后打开 <http://localhost:5214/utils-demo>(菜单「TS 模块调用」)。页面会显示真实计算结果:`sumNumbers(2, 3, 7) = 12`、`DEMO_ANSWER = 42`、`formatPrice(12.5)`,以及远程详情组件的 `id=7`、`tab=type-demo`。
|
|
46
46
|
|
|
47
47
|
1. 用编辑器打开整个模板目录,启用 Vue 官方扩展 **Vue - Official**。
|
|
48
|
-
2. 打开 [`host/src/type-demo.ts`](host/src/type-demo.ts),在 `utils.` 后触发补全,或悬停 `sumNumbers`:应显示数字参数和数字返回值。类型直接来自远程,没有手写接口或显式泛型。
|
|
48
|
+
2. 打开 [`host/src/fulgurjs/host/type-demo.ts`](host/src/fulgurjs/host/type-demo.ts),在 `utils.` 后触发补全,或悬停 `sumNumbers`:应显示数字参数和数字返回值。类型直接来自远程,没有手写接口或显式泛型。
|
|
49
49
|
3. 打开 [`host/src/pages/UtilsDemo.vue`](host/src/pages/UtilsDemo.vue),在 `<RemoteDetail>` 上查看属性提示。把 `id="7"` 临时改成 `:id="7"`,应提示数字不能赋给字符串;检查后还原。
|
|
50
50
|
4. 在模板根执行:
|
|
51
51
|
|
|
@@ -122,8 +122,8 @@ pnpm prod
|
|
|
122
122
|
|
|
123
123
|
| 文件 | 职责 |
|
|
124
124
|
|---|---|
|
|
125
|
-
| `host/src/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
126
|
-
| `remote/src/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
125
|
+
| `host/src/fulgurjs/host/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
126
|
+
| `remote/src/fulgurjs/exposes/application.ts` | 本应用唯一装配;main 只负责调用 start |
|
|
127
127
|
| `host/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
128
128
|
| `remote/fulgurjs.config.ts` | 本应用的远程地址、exposes、实际共享依赖 |
|
|
129
129
|
| `scripts/dev.mjs` / `scripts/prod.mjs` | 统一开发/生产启动器;业务接入不复制它们到应用源码 |
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
+
/** 宿主装配入口:main 只调用 start;在这里连接本工程的路由与远程挂载,原业务页面仍在 pages/。 */
|
|
1
2
|
import { createApp, h } from 'vue'
|
|
2
3
|
import { createRouter, createWebHistory, useRoute } from 'vue-router'
|
|
3
4
|
import { defineApplication, createHostPages } from '@fulgurjs/federation/vue'
|
|
4
|
-
import App from '
|
|
5
|
-
import HomePage from '
|
|
6
|
-
import UtilsDemo from '
|
|
7
|
-
import { pages, remotePrefixes } from '
|
|
5
|
+
import App from '../../App.vue'
|
|
6
|
+
import HomePage from '../../pages/HomePage.vue'
|
|
7
|
+
import UtilsDemo from '../../pages/UtilsDemo.vue'
|
|
8
|
+
import { pages, remotePrefixes } from '../../../fulgurjs.config.ts'
|
|
8
9
|
|
|
9
10
|
// 页面适配器:URL 解析、最长前缀远程归属、异步组件缓存、
|
|
10
11
|
// 加载/错误占位(含「重试加载 / 刷新页面重试」)全部由插件完成。
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
<button data-testid="demo-utils-reload" @click="load">重新调用</button>
|
|
13
13
|
<section data-testid="demo-types-guide">
|
|
14
14
|
<h3>远程类型提示:像使用本地代码一样</h3>
|
|
15
|
-
<p>打开 <code>host/src/type-demo.ts</code>,在 <code>utils.</code> 后触发补全,或悬停查看函数参数和返回值。</p>
|
|
15
|
+
<p>打开 <code>host/src/fulgurjs/host/type-demo.ts</code>,在 <code>utils.</code> 后触发补全,或悬停查看函数参数和返回值。</p>
|
|
16
16
|
<p>下面的详情组件来自远程,<code>id</code> 和 <code>tab</code> 都是字符串。把本文件中的 <code>id="7"</code> 改成 <code>:id="7"</code>,编辑器和类型检查会提示错误;体验后请还原。</p>
|
|
17
17
|
<RemoteDetail id="7" tab="type-demo" />
|
|
18
18
|
<p>执行 <code>pnpm --dir host typecheck</code> 可检查正确调用和五条错误示例。错误示例不在浏览器中执行;移除其中一行的 <code>@ts-expect-error</code> 后再检查,就能看到具体诊断。</p>
|
|
@@ -17,10 +17,10 @@ pnpm --dir remote dev
|
|
|
17
17
|
|
|
18
18
|
| expose 键 | 源文件 | 说明 |
|
|
19
19
|
| --- | --- | --- |
|
|
20
|
-
| `./ClickButton` | `src/exposes/ClickButton.vue` | 可点击计数按钮(本地状态在组件内) |
|
|
21
|
-
| `./utils` | `src/exposes/utils.ts` | 普通 TS 模块:`sumNumbers` / `DEMO_ANSWER` / `formatPrice` |
|
|
22
|
-
| `./pages/HomePage` | `src/exposes/pages/HomePage.vue` | 联邦页面:远程首页 |
|
|
23
|
-
| `./pages/DetailPage` | `src/exposes/pages/DetailPage.vue` | 联邦页面:详情页(接收宿主路由的 `id` / `tab` props) |
|
|
20
|
+
| `./ClickButton` | `src/fulgurjs/exposes/ClickButton.vue` | 可点击计数按钮(本地状态在组件内) |
|
|
21
|
+
| `./utils` | `src/fulgurjs/exposes/utils.ts` | 普通 TS 模块:`sumNumbers` / `DEMO_ANSWER` / `formatPrice` |
|
|
22
|
+
| `./pages/HomePage` | `src/fulgurjs/exposes/pages/HomePage.vue` | 联邦页面:远程首页 |
|
|
23
|
+
| `./pages/DetailPage` | `src/fulgurjs/exposes/pages/DetailPage.vue` | 联邦页面:详情页(接收宿主路由的 `id` / `tab` props) |
|
|
24
24
|
|
|
25
25
|
宿主如何调用 `./utils`(宿主侧代码):
|
|
26
26
|
|
|
@@ -9,10 +9,10 @@ export default {
|
|
|
9
9
|
// 生产构建的容器入口文件名(部署后宿主 prod 地址指向它所在目录)
|
|
10
10
|
filename: 'fulgurjs-remoteEntry.js',
|
|
11
11
|
exposes: {
|
|
12
|
-
'./ClickButton': './src/exposes/ClickButton.vue',
|
|
13
|
-
'./utils': './src/exposes/utils.ts',
|
|
14
|
-
'./pages/HomePage': './src/exposes/pages/HomePage.vue',
|
|
15
|
-
'./pages/DetailPage': './src/exposes/pages/DetailPage.vue',
|
|
12
|
+
'./ClickButton': './src/fulgurjs/exposes/ClickButton.vue',
|
|
13
|
+
'./utils': './src/fulgurjs/exposes/utils.ts',
|
|
14
|
+
'./pages/HomePage': './src/fulgurjs/exposes/pages/HomePage.vue',
|
|
15
|
+
'./pages/DetailPage': './src/fulgurjs/exposes/pages/DetailPage.vue',
|
|
16
16
|
},
|
|
17
17
|
shared: {
|
|
18
18
|
vue: { singleton: true, requiredVersion: '^3.4.0' },
|
package/examples/templates/vue-vue/remote/src/{application.ts → fulgurjs/exposes/application.ts}
RENAMED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
/** 应用装配入口:main 只调用 start;独立与嵌入复用本工厂,每次挂载的实例和清理由插件管理。 */
|
|
1
2
|
import { createApp } from 'vue'
|
|
2
3
|
import { defineApplication } from '@fulgurjs/federation/vue'
|
|
3
|
-
import App from '
|
|
4
|
+
import App from '../../App.vue'
|
|
4
5
|
|
|
5
6
|
// 普通组件远程不需要额外桥接/路由;独立调试仍由同一应用入口启动。
|
|
6
7
|
export default defineApplication(() => createApp(App))
|
package/package.json
CHANGED
/package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/ClickButton.tsx
RENAMED
|
File without changes
|
/package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.tsx
RENAMED
|
File without changes
|
/package/examples/templates/react-react/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.tsx
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/DetailPage.vue
RENAMED
|
File without changes
|
/package/examples/templates/vue-vue/remote/src/{exposes → fulgurjs/exposes}/pages/HomePage.vue
RENAMED
|
File without changes
|
|
File without changes
|