weifuwu 0.75.0 → 0.77.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/README.md +48 -53
- package/dist/ai/types.d.ts +2 -0
- package/dist/components/AiChat/AiChat.d.ts +5 -1
- package/dist/components/ApprovalCard/ApprovalCard.d.ts +5 -2
- package/dist/components/CitationCard/CitationCard.d.ts +38 -0
- package/dist/components/Command/Command.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +1 -1
- package/dist/components/JsonSchemaForm/JsonSchemaForm.d.ts +48 -0
- package/dist/components/ReasoningBlock/ReasoningBlock.d.ts +25 -0
- package/dist/components/Select/Select.d.ts +11 -1
- package/dist/components/SessionList/SessionList.d.ts +42 -0
- package/dist/components/Tour/Tour.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.d.ts +3 -2
- package/dist/components/index.d.ts +10 -2
- package/dist/components/index.js +14 -14
- package/dist/components/style.css +625 -20
- package/dist/index.js +1349 -1529
- package/dist/layout/weifuwu-layout.css +9 -0
- package/dist/scheduler/index.d.ts +7 -2
- package/dist/test/client/setup.d.ts +12 -0
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui-dom/Confirm.d.ts +5 -41
- package/dist/ui-dom/Notification.d.ts +8 -70
- package/dist/ui-dom/Toast.d.ts +8 -43
- package/dist/ui-dom/hooks/chat.d.ts +11 -0
- package/dist/ui-dom/hooks/events.d.ts +30 -0
- package/dist/ui-dom/hooks/external.d.ts +20 -0
- package/dist/ui-dom/hooks/index.d.ts +30 -0
- package/dist/ui-dom/hooks/input.d.ts +33 -0
- package/dist/ui-dom/hooks/media.d.ts +17 -0
- package/dist/ui-dom/hooks/popup.d.ts +28 -0
- package/dist/ui-dom/hooks/stable.d.ts +39 -0
- package/dist/ui-dom/hooks/test/hooks.test.d.ts +1 -0
- package/dist/ui-dom/hooks/types.d.ts +77 -0
- package/dist/ui-dom/index.d.ts +19 -17
- package/dist/ui-dom/index.js +11 -11
- package/dist/ui-dom/jsx-runtime.js +1 -1
- package/dist/ui-dom/store.d.ts +24 -0
- package/dist/ui-dom/testing.d.ts +74 -0
- package/dist/ui-dom/testing.js +1 -0
- package/dist/ui-dom/testing.test.d.ts +1 -0
- package/dist/ui-dom/types.d.ts +55 -50
- package/dist/ui-dom/use-chat.d.ts +19 -14
- package/dist/ui-dom/vdom/build.d.ts +41 -0
- package/dist/ui-dom/vdom/diff.d.ts +33 -0
- package/dist/ui-dom/vdom/hydration.d.ts +17 -0
- package/dist/ui-dom/vdom/index.d.ts +23 -0
- package/dist/ui-dom/vdom/mount.d.ts +58 -0
- package/dist/ui-dom/vdom/registry.d.ts +27 -0
- package/dist/ui-dom/vdom/render.d.ts +15 -0
- package/dist/ui-dom/vdom/serve.d.ts +30 -0
- package/dist/ui-dom/vdom/ssr.d.ts +44 -0
- package/dist/ui-dom/vnode.d.ts +19 -31
- package/docs/components-map.md +18 -1
- package/docs/components.md +12 -7
- package/docs/custom-components.md +90 -60
- package/docs/examples.md +35 -41
- package/docs/frontend-middleware.md +3 -4
- package/docs/frontend-ui-dom.md +21 -18
- package/docs/frontend.md +243 -168
- package/docs/layout.md +2 -2
- package/docs/mobile.md +2 -2
- package/docs/realtime.md +8 -3
- package/package.json +5 -1
- package/dist/ui/ssr.d.ts +0 -35
- package/dist/ui-dom/diff.d.ts +0 -28
- package/dist/ui-dom/focus-trap.d.ts +0 -4
- package/dist/ui-dom/hydration.d.ts +0 -13
- package/dist/ui-dom/reactive.d.ts +0 -6
- package/dist/ui-dom/registry.d.ts +0 -27
- package/dist/ui-dom/render.d.ts +0 -46
- package/dist/ui-dom/scroll-lock.d.ts +0 -5
- package/dist/ui-dom/serve.d.ts +0 -28
- package/dist/ui-dom/ssr.d.ts +0 -57
- package/dist/ui-dom/ui.d.ts +0 -78
package/docs/frontend-ui-dom.md
CHANGED
|
@@ -23,16 +23,15 @@
|
|
|
23
23
|
### 两阶段组件模型:从 hooks 心智负担中解脱
|
|
24
24
|
|
|
25
25
|
```tsx
|
|
26
|
-
const Counter = (initProps, ctx) => {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
h('button', { onClick: () => $.count += props.step }, $.count) // render
|
|
26
|
+
const Counter = async (initProps, ctx) => {
|
|
27
|
+
let count = initProps.initial ?? 0 // mount:只执行一次
|
|
28
|
+
return async (props) =>
|
|
29
|
+
h('button', { onClick: () => { count += props.step; ctx.ui.render() } }, count) // render
|
|
31
30
|
}
|
|
32
31
|
```
|
|
33
32
|
|
|
34
|
-
- **没有 hooks 规则、没有依赖数组、没有闭包陷阱**。外层 = 初始化(一次),内层 =
|
|
35
|
-
-
|
|
33
|
+
- **没有 hooks 规则、没有依赖数组、没有闭包陷阱**。外层 = 初始化(一次),内层 = 渲染(每次变化)。
|
|
34
|
+
- **render-only 确定性渲染**(design/render-only-plan.md):渲染只发生在 `ctx.ui.render()` 调用处——改状态后显式 `render()`,行为可静态推导。无 `$` Proxy、无隐式触发;跨组件共享用 `createStore` + `ctx.ui.useExternal()`。
|
|
36
35
|
|
|
37
36
|
### 框架即纪律:浏览器环境抽象把常见坑变成编译期/审计期错误
|
|
38
37
|
|
|
@@ -55,7 +54,7 @@ AGENTS.md 每条纪律对应真实事故(JSONViewer selfId 错位、AutoComple
|
|
|
55
54
|
|
|
56
55
|
| 维度 | 价值 |
|
|
57
56
|
|------|------|
|
|
58
|
-
| **上手** | 两阶段组件 +
|
|
57
|
+
| **上手** | 两阶段组件 + 改状态后 render()——无 hooks/依赖数组心智负担 |
|
|
59
58
|
| **后端互迁** | req/res/中间件契约同构,SSR 透明,一份 router 两端共享 |
|
|
60
59
|
| **可靠性** | 确定性失败、诚实裁剪、环境边界、测试侧同构 |
|
|
61
60
|
| **效率** | 弹层/数据管道/事件原语全覆盖——不重复造轮子 |
|
|
@@ -74,14 +73,13 @@ const app = new UIRouter()
|
|
|
74
73
|
|
|
75
74
|
app.use(toast()) // ctx 注入链(对齐后端 app.use——注入 ctx.toast)
|
|
76
75
|
|
|
77
|
-
// handler = 异步组件:async (location, ctx) => VNode
|
|
76
|
+
// handler = 异步组件:async (location, ctx) => VNode(render-only——改状态后 ctx.ui.render())
|
|
78
77
|
app.get('/', async (location, ctx) => {
|
|
79
78
|
const info = await ctx.data.get('/api/info', async () => ({ title: '首页' }))
|
|
80
|
-
|
|
81
|
-
$.clicks = $.clicks ?? 0
|
|
79
|
+
let clicks = 0
|
|
82
80
|
return h('div', {},
|
|
83
81
|
h('h2', {}, info.title),
|
|
84
|
-
h(Button, { onClick: () =>
|
|
82
|
+
h(Button, { onClick: () => { clicks++; ctx.ui.render() } }, `点击 ${clicks} 次`),
|
|
85
83
|
h(Button, { variant: 'secondary', onClick: () => ctx.toast?.('提示', 'success') }, '弹 toast'),
|
|
86
84
|
)
|
|
87
85
|
})
|
|
@@ -119,17 +117,22 @@ handler 只产 VNode,落地由 serve 决定——SSR 与 SPA 是两种落地
|
|
|
119
117
|
|
|
120
118
|
VNode 契约以 ui-dom 为唯一来源(Fragment/Portal symbol 由 ui-dom 自持)——components 产的 VNode
|
|
121
119
|
直接被 ui-dom 渲染器识别。渲染算法(render/diff/createUi 原语)在 ui-dom 内自主实现,
|
|
122
|
-
**registry/popup-tracker
|
|
120
|
+
**registry/popup-tracker 局部实例**(serve 每实例隔离)。
|
|
123
121
|
|
|
124
122
|
命令式工厂(toast/confirm/notification)位于 ui-dom(`src/ui-dom/Toast.ts` 等):
|
|
125
123
|
components 消费端 import `weifuwu/ui-dom`(构建外部化,共享同一模块实例)。
|
|
126
124
|
|
|
127
|
-
###
|
|
125
|
+
### render-only 渲染(唯一触发:ctx.ui.render())
|
|
128
126
|
|
|
129
|
-
|
|
|
127
|
+
| 原语 | 触发 | 重渲染范围 |
|
|
130
128
|
|------|------|-----------|
|
|
131
|
-
|
|
|
132
|
-
|
|
|
129
|
+
| `ctx.ui.render()`(无参) | 主动调用 | 当前组件(闭包绑定,无 this 陷阱) |
|
|
130
|
+
| `ctx.ui.render(['id'])` | 主动调用 | 指定组件(selfId 注册的语义 ID) |
|
|
131
|
+
| `ctx.ui.useExternal(store)` | store 变更自动 | **仅订阅组件**(unmount 自动退订) |
|
|
132
|
+
|
|
133
|
+
- 状态是普通对象(`let` / `createStore`)——改状态后显式 `render()`,无赋值自动渲染
|
|
134
|
+
- 跨组件共享:`createStore` + `useExternal`(替代已删除的 `$` Proxy / `dirty`)
|
|
135
|
+
- hooks(useMedia/useInView/usePopup 等)事件驱动重渲染——与"赋值自动"本质不同
|
|
133
136
|
|
|
134
137
|
## SSR + hydration(端到端)
|
|
135
138
|
|
|
@@ -154,7 +157,7 @@ uiServe(app, { root: '#root', hydrate: true })
|
|
|
154
157
|
|------|------|
|
|
155
158
|
| `ctx.params` / `ctx.query` | 路由参数 / URL query(顶层,对齐后端) |
|
|
156
159
|
| `ctx.data.get/set/has` | 数据管道(缓存 + in-flight 合并 + `__DATA__` 种子) |
|
|
157
|
-
| `ctx.ui.*` |
|
|
160
|
+
| `ctx.ui.*` | 原语(`render`/`useExternal`/`usePopup`/`useChat`/`useInView`…) |
|
|
158
161
|
| `ctx.browser.*` | 环境抽象(window/document 唯一入口,SSR shim 同构) |
|
|
159
162
|
| `ctx.toast` / `ctx.confirm` / `ctx.notification` | 命令式注入(`app.use(toast())` 等) |
|
|
160
163
|
|