@manohub/kit 1.1.3 → 1.1.4

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/CONTRACT.md CHANGED
@@ -66,13 +66,30 @@
66
66
 
67
67
  ```bash
68
68
  pnpm add @manohub/kit @manohub/ui @manohub/theme @manohub/icon
69
- pnpm add vue vue-router pinia vue-i18n @tanstack/vue-query # peer,由应用提供
69
+ pnpm add vue vue-router pinia vue-i18n # peer,由应用提供
70
70
  ```
71
71
 
72
72
  四个包**并列安装**,模块级互不依赖:kit 提供入口编排与本文,ui 提供组件与命令式服务,
73
73
  theme 提供令牌(值),icon 提供图形。**本包只出一条样式出口**(`./index.css`,四节库级基座;见 §1.2),
74
74
  所以 `kit` 的 `peerDependencies` 里没有另外三个。
75
75
 
76
+ **请求层不归本包**(2026-10-17 起):`@tanstack/vue-query` 不在 peer 里,`createSubApp` 也不再装配它 ——
77
+ **谁用谁自己装、自己 `app.use`**,经 `extraPlugins` 传进工厂(顺序上它在 router 之前):
78
+
79
+ ```ts
80
+ import { VueQueryPlugin, QueryClient } from '@tanstack/vue-query'
81
+
82
+ const queryClient = new QueryClient({
83
+ defaultOptions: { queries: { staleTime: 30_000, refetchOnWindowFocus: false } },
84
+ })
85
+ const installQuery = (app) => app.use(VueQueryPlugin, { queryClient })
86
+
87
+ export const { mount, unmount } = createSubApp({ rootComponent, routes, extraPlugins: [installQuery] })
88
+ ```
89
+
90
+ 不用 query 的应用**完全不需要**这个依赖(旧版是「装了 kit 就必须提供」,等于每个子应用都背一份
91
+ query-core 进产物)。
92
+
76
93
  四者之间**唯一的跨包约定**是容器上的属性锚 `data-manohub-ui`(见 §1.3)。
77
94
 
78
95
  ### 1.2 样式链:三行 + 应用自己一行(顺序即契约)
@@ -141,10 +158,12 @@ export const { mount, unmount } = createSubApp({
141
158
  })
142
159
  ```
143
160
 
144
- 工厂替你做完:`div.app-container` 包裹 + `data-manohub-ui` / `data-theme` 属性、pinia / vue-router /
145
- vue-query 装配、宿主挂载协议、宿主语言同步、首帧路由重置。**不要自己手写 main.ts 样板**——
161
+ 工厂替你做完:`div.app-container` 包裹 + `data-manohub-ui` / `data-theme` 属性、pinia / vue-router 装配、
162
+ 宿主挂载协议、宿主语言同步、首帧路由重置。**不要自己手写 main.ts 样板**——
146
163
  漏掉 `exposeToHost` 会让宿主无法重挂子应用。
147
164
 
165
+ 请求层(`@tanstack/vue-query` 等)由应用自己装进 `extraPlugins`,工厂不替你装(见 §1.1)。
166
+
148
167
  容器上的名字分四类,**只有前两个是跨包约定**(改名会断掉对方):
149
168
 
150
169
  | 名字 | 谁写 | 用途 | 跨包契约? |
package/README.md CHANGED
@@ -28,9 +28,12 @@ pnpm add @manohub/kit @manohub/ui @manohub/theme
28
28
  peer(由应用提供,缺一个都装不上):
29
29
 
30
30
  ```bash
31
- pnpm add vue vue-router pinia vue-i18n @tanstack/vue-query
31
+ pnpm add vue vue-router pinia vue-i18n
32
32
  ```
33
33
 
34
+ **请求层不在 peer 里**:`@tanstack/vue-query` 由需要的应用自己装、自己 `app.use(VueQueryPlugin)`,
35
+ 经 `createSubApp` 的 `extraPlugins` 传入;不用 query 的应用不必装(见 `CONTRACT.md` §1.1)。
36
+
34
37
  `@manohub/ui` 自带图标包依赖(`@manohub/icon`),不必单独声明。
35
38
 
36
39
  ### 2. 样式:三行 + 应用自己一行(顺序即契约)
@@ -84,7 +87,7 @@ export const { mount, unmount } = createSubApp({
84
87
  })
85
88
  ```
86
89
 
87
- 它替你做完:`div.app-container` 包裹与 `data-manohub-ui` 锚点、pinia / vue-router / vue-query 装配、
90
+ 它替你做完:`div.app-container` 包裹与 `data-manohub-ui` 锚点、pinia / vue-router 装配(请求层自装)、
88
91
  宿主挂载协议(`window.mount/unmount` + `microApp.mount/unmount`)、宿主语言同步、首帧路由重置。
89
92
 
90
93
  `data-manohub-ui` 是**跨包唯一的作用域锚点**(主题令牌、组件令牌、微前端 scopecss 都锚在它上面,
@@ -155,7 +158,7 @@ pnpm exec kit install --dry-run # 先看会写什么
155
158
  | 入口 | 内容 |
156
159
  | --- | --- |
157
160
  | `@manohub/kit` | `useClientPagination`、`resolveAppContainer` / `resolveAppContainerSelector` |
158
- | `@manohub/kit/entry` | `createSubApp`、`installInitialGuard`、`createQueryClient`、`applyLocale` / `getLocale` / `i18n` / `setupI18n` |
161
+ | `@manohub/kit/entry` | `createSubApp`、`installInitialGuard`、`applyLocale` / `getLocale` / `i18n` / `setupI18n` |
159
162
  | `@manohub/kit/index.css` | **唯一一条样式出口**:四节库级基座(兜底 / 容器布局 / 滚动条 / 富文本,见 §2 的 ③) |
160
163
  | `@manohub/kit/CONTRACT.md` | 接入契约(权威规范:五层闭集条款 + §7 自检清单) |
161
164
 
@@ -1,4 +1,3 @@
1
- import { QueryClient } from '@tanstack/vue-query';
2
1
  import { type App as VueApp, type Component, type Plugin } from 'vue';
3
2
  import { type RouterHistory, type RouteRecordRaw } from 'vue-router';
4
3
  import { type SetupI18nOptions } from '../providers/setup-i18n';
@@ -22,9 +21,7 @@ export interface CreateSubAppOptions {
22
21
  * 与应用是否传本选项无关,组件树外可照常消费)。
23
22
  */
24
23
  i18n?: SetupI18nOptions;
25
- /** 缺省由 createQueryClient() 提供;带全局错误缓存/自定义 retry 的应用自建后注入 */
26
- queryClient?: QueryClient;
27
- /** 额外插件(如 ContextMenu) */
24
+ /** 额外插件(如 `VueQueryPlugin` / ContextMenu)。**请求层不归本包**:谁用 `@tanstack/vue-query` 谁自己从这里装 */
28
25
  extraPlugins?: Plugin[];
29
26
  /** 额外样式(如 highlight.js 主题),mount 前动态加载 */
30
27
  extraStyles?: () => Promise<unknown>;
@@ -49,10 +46,11 @@ export interface CreateSubAppOptions {
49
46
  * 1. **作用域容器**:外层包 `div.app-container`,无条件写 `data-manohub-ui`(跨包唯一作用域锚:
50
47
  * 主题令牌 / 组件令牌 / reset 作用域 / 组件库服务层宿主解析都认它)与可选的 `data-theme`;
51
48
  * 2. **i18n**:创建全应用唯一的 vue-i18n 实例并注册,由宿主语言下发驱动切换;
52
- * 3. **路由 / 状态 / 请求**:pinia、vue-router、`@tanstack/vue-query` 装配 + 首帧路由重置;
49
+ * 3. **路由 / 状态**:pinia、vue-router 装配 + 首帧路由重置(**请求层不归本包** ——
50
+ * 用 `@tanstack/vue-query` 的应用自己 `app.use(VueQueryPlugin)`,经 `extraPlugins` 传进来);
53
51
  * 4. **宿主挂载协议**:`window.mount/unmount` 与 `window.microApp.mount/unmount` 一并暴露。
54
52
  *
55
- * 流程顺序即契约:createApp → pinia → i18n → vue-query → 额外插件 → router →
53
+ * 流程顺序即契约:createApp → pinia → i18n → 额外插件 → router →
56
54
  * mount(`__MICRO_APP_CONTAINER__` || `#app`) → 初始守卫 → 暴露给宿主。
57
55
  *
58
56
  * @example
@@ -1,9 +1,7 @@
1
- import { VueQueryPlugin } from "@tanstack/vue-query";
2
1
  import { createPinia } from "pinia";
3
2
  import { defineComponent, ref, provide, h, createApp } from "vue";
4
3
  import { createRouter, createWebHistory, createWebHashHistory } from "vue-router";
5
4
  import { installInitialGuard } from "./initial-guard.js";
6
- import { createQueryClient } from "./create-query-client.js";
7
5
  import { setupI18n, applyLocale } from "../providers/setup-i18n.js";
8
6
  import { setCurrentApp } from "../services/app-context.js";
9
7
  function createSubApp(options) {
@@ -12,7 +10,6 @@ function createSubApp(options) {
12
10
  routes,
13
11
  history: historyMode = "history",
14
12
  i18n,
15
- queryClient,
16
13
  extraPlugins = [],
17
14
  extraStyles,
18
15
  theme,
@@ -41,7 +38,6 @@ function createSubApp(options) {
41
38
  pinia = createPinia();
42
39
  app.use(pinia);
43
40
  if (i18n) setupI18n(app, i18n);
44
- app.use(VueQueryPlugin, { queryClient: queryClient ?? createQueryClient() });
45
41
  for (const plugin of extraPlugins) {
46
42
  app.use(plugin);
47
43
  }
@@ -1,4 +1,3 @@
1
1
  export { createSubApp, type CreateSubAppHistory, type CreateSubAppOptions } from './create-sub-app';
2
2
  export { installInitialGuard } from './initial-guard';
3
- export { createQueryClient } from './create-query-client';
4
3
  export { applyLocale, getLocale, i18n, setupI18n, type AppI18n, type SetupI18nOptions, } from '../providers/setup-i18n';
@@ -1,10 +1,8 @@
1
1
  import { createSubApp } from "./create-sub-app.js";
2
2
  import { installInitialGuard } from "./initial-guard.js";
3
- import { createQueryClient } from "./create-query-client.js";
4
3
  import { applyLocale, getLocale, i18n, setupI18n } from "../providers/setup-i18n.js";
5
4
  export {
6
5
  applyLocale,
7
- createQueryClient,
8
6
  createSubApp,
9
7
  getLocale,
10
8
  i18n,
package/dist/index.d.ts CHANGED
@@ -3,7 +3,9 @@
3
3
  * (组件与类型都不行 —— 组件与命令式服务一律从 `@manohub/ui` 直引)。本包只有三件事:
4
4
  *
5
5
  * 1. **入口编排**(子路径 `/entry`):`div.app-container` 包裹与 `data-manohub-ui` 锚点、
6
- * pinia / vue-query / router 装配、宿主挂载协议、语言探测与切换;
6
+ * pinia / router 装配、宿主挂载协议、语言探测与切换(**请求层不归本包** —— 用
7
+ * `@tanstack/vue-query` 的应用自己 `app.use(VueQueryPlugin)`,经 `createSubApp` 的
8
+ * `extraPlugins` 传入;本包因此不依赖、也不再导出 `createQueryClient`);
7
9
  * 2. **应用容器记账**(下面的 `resolveAppContainer`):回答「本应用自己的容器是哪一个」;
8
10
  * 3. **契约分发**:`CONTRACT.md` 与 `skills/` 技能包。
9
11
  */
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "@manohub/kit",
3
- "version": "1.1.3",
3
+ "version": "1.1.4",
4
4
  "private": false,
5
5
  "type": "module",
6
- "description": "子应用入口编排层:createSubApp(作用域容器与宿主锚点、pinia/路由/vue-query 装配、宿主挂载协议)、i18n 单实例与语言探测,外加随包分发的接入契约(CONTRACT.md,五层闭集条款 + 自检清单)与三个 AI 技能包。样式方面本包只有**一条出口** `./index.css`(四节库级基座:宿主兜底 / `.app-container` 容器布局 / 滚动条 / `.app-markdown` 富文本排版;设计令牌(值)在 @manohub/theme,组件(类与行为)在 @manohub/ui,两者由消费方直接引入)。",
6
+ "description": "子应用入口编排层:createSubApp(作用域容器与宿主锚点、pinia/路由装配、宿主挂载协议)、i18n 单实例与语言探测,外加随包分发的接入契约(CONTRACT.md,五层闭集条款 + 自检清单)与三个 AI 技能包。样式方面本包只有**一条出口** `./index.css`(请求层不归本包,谁用 vue-query 谁自己装;四节库级基座:宿主兜底 / `.app-container` 容器布局 / 滚动条 / `.app-markdown` 富文本排版;设计令牌(值)在 @manohub/theme,组件(类与行为)在 @manohub/ui,两者由消费方直接引入)。",
7
7
  "license": "UNLICENSED",
8
8
  "repository": {
9
9
  "type": "git",
@@ -42,14 +42,12 @@
42
42
  "module": "./dist/index.js",
43
43
  "types": "./dist/index.d.ts",
44
44
  "peerDependencies": {
45
- "@tanstack/vue-query": "^5.0.0",
46
45
  "pinia": "^4.0.0",
47
46
  "vue": "^3.5.0",
48
47
  "vue-i18n": "^11.0.0",
49
48
  "vue-router": "^4.6.0"
50
49
  },
51
50
  "devDependencies": {
52
- "@tanstack/vue-query": "^5.64.0",
53
51
  "@vitejs/plugin-vue-jsx": "^5.1.6",
54
52
  "jsdom": "^25.0.1",
55
53
  "pinia": "^4.0.3",
@@ -18,11 +18,14 @@
18
18
 
19
19
  ```bash
20
20
  pnpm add @manohub/kit @manohub/ui @manohub/theme
21
- pnpm add vue vue-router pinia vue-i18n @tanstack/vue-query # peer,由应用提供
21
+ pnpm add vue vue-router pinia vue-i18n # peer,由应用提供(请求层不在内,见下)
22
22
  ```
23
23
 
24
24
  - 三个包**并列安装**:kit 管入口编排与契约,ui 管组件与服务,theme 管全局令牌(值)。
25
25
  - `@manohub/ui` 自带 `@manohub/icon` 依赖,不必单独声明。
26
+ - **请求层自己装**:用 `@tanstack/vue-query` 的应用自己 `pnpm add @tanstack/vue-query` 并
27
+ `app.use(VueQueryPlugin, { queryClient })`,经 `createSubApp({ extraPlugins: [installQuery] })` 传入;
28
+ 不用 query 的应用**不要装**(kit 已不再装配它,也不再把自己的 query client 借给你)。
26
29
  - **每个引入 kit 的应用都必须声明 `vue-i18n`**,哪怕不传 `i18n` 选项 ——
27
30
  `createSubApp` 所在模块静态引入它,漏装会在构建期报 `Rollup failed to resolve import "vue-i18n"`。
28
31
 
@@ -81,7 +84,7 @@ export const { mount, unmount } = createSubApp({
81
84
  ```
82
85
 
83
86
  工厂带给你的(**不要自己再写**):`div.app-container` 包裹与 `data-manohub-ui` / `data-theme` 属性、
84
- pinia / vue-router / vue-query 装配、宿主挂载协议(`window.mount/unmount` + `microApp.*`)、
87
+ pinia / vue-router 装配、宿主挂载协议(`window.mount/unmount` + `microApp.*`)、
85
88
  宿主语言同步、首帧路由重置。
86
89
 
87
90
  > **自建容器(不走 `createSubApp`)必须自己带 `data-manohub-ui`**:主题令牌、组件令牌、
@@ -1,6 +0,0 @@
1
- import { QueryClient } from '@tanstack/vue-query';
2
- /**
3
- * 缺省 QueryClient(staleTime 30s、不因窗口聚焦重取):`createSubApp` 未显式传入时使用。
4
- * 带全局错误缓存 / 自定义 retry 的应用自建一个后经 `createSubApp` 注入。
5
- */
6
- export declare function createQueryClient(): QueryClient;
@@ -1,14 +0,0 @@
1
- import { QueryClient } from "@tanstack/vue-query";
2
- function createQueryClient() {
3
- return new QueryClient({
4
- defaultOptions: {
5
- queries: {
6
- staleTime: 30 * 1e3,
7
- refetchOnWindowFocus: false
8
- }
9
- }
10
- });
11
- }
12
- export {
13
- createQueryClient
14
- };