weifuwu 0.65.0 → 0.66.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.
@@ -141,13 +141,17 @@
141
141
  <Badge variant="secondary">x</Badge> // → <Tag variant="secondary">x</Tag>
142
142
  ```
143
143
 
144
- ## weifuwu 尚未实现(三库有)→ 待补清单
144
+ ## weifuwu 已补齐(第六批,2026-08)→ 待补清单清零 ✅
145
145
 
146
- 仅 4 项:
146
+ 第六批 6 组件全部落地(TDD 红→绿 + style-audit + demo + agent-browser 实测):
147
147
 
148
- - **Anchor**(锚点导航,三库均有)
149
- - **Menu 子菜单/折叠**(分组 group 已支持,子级/折叠待补)
150
- - **FileUpload 增强**(拖拽已支持;文件列表/预览/进度待补)
151
- - **VirtualTable**(VirtualList 已有,表格虚拟化待补)
148
+ | 组件 | 类型 | 要点 |
149
+ |------|------|------|
150
+ | **Menu 子菜单/折叠** | 增强 | `children` 子菜单 + `collapsible` 折叠侧栏 + 多级键盘流 |
151
+ | **FileUpload 增强** | 增强 | 图片缩略图(objectURL revoke)+ 进度条 + 受控纪律 |
152
+ | **VirtualTable** | 新增 | 固定表头 + 虚拟滚动(10k 行 ~17 DOM)+ 排序 |
153
+ | **Anchor** | 新增 | 滚动高亮跟随 + 点击平滑滚动 + useHash |
154
+ | **LogViewer** | 新增 | ANSI 着色 + 虚拟滚动 + follow 自动跟随 + maxLines |
155
+ | **JSONViewer** | 新增 | 递归折叠 + 类型色 + 路径复制 + 懒展开(ToolCallCard 已接入) |
152
156
 
153
- > 难度阶梯(L1-L6)与验证的 client 能力点:见 `design/components-cdd.md`;三库 → weifuwu 覆盖矩阵:见 `design/components-migration.md`。
157
+ > 三库共识覆盖度 ~100%(剩余均为已声明裁剪项,见 `design/components-roadmap.md` 第六批裁剪清单)。
@@ -207,6 +207,32 @@ const CollapseItem: Component<{ active?: boolean; onChange?: (v: boolean) => voi
207
207
 
208
208
  **纪律**:组件内动画事件监听**唯一入口是 `useAnimationEnd`**——禁直接 `addEventListener('animationend')`(DatePicker 已收敛);退场优先 `usePresence`(声明式状态机)或 `animateOut`(命令式)。
209
209
 
210
+ ## 8.6 浏览器环境纪律(ctx.browser)
211
+
212
+ > **自定义组件禁止直接引用 window/document**——统一经 `ctx.browser`:
213
+ > SSR 安全(shim 安全默认)+ 测试 mock 单点 + 环境差异隔离。
214
+
215
+ ```tsx
216
+ const MyComp: Component = (_init, ctx) => {
217
+ // mount 层取 browser(ctx.browser 优先,测试/无注入环境 fallback jsdom)
218
+ const browser = ctx.browser ?? createClientBrowser()
219
+ return (props) =>
220
+ h('button', {
221
+ onClick: () => {
222
+ // 复制/查询/存储/滚动——全部经 browser
223
+ void browser.copyText('hello')
224
+ const el = browser.byId('target')
225
+ }
226
+ })
227
+ }
228
+ ```
229
+
230
+ **规则**:
231
+ - 复制统一 `browser.copyText`(clipboard + 降级——勿自建 textarea+execCommand)
232
+ - 键盘导航用 `browser.activeElement()`(勿 document.activeElement)
233
+ - 存储用 `browser.storageGet/Set`(勿 localStorage 裸调)
234
+ - SSR 场景(render/mount 期)绝对不碰环境 API(shim 返回 null——需防御)
235
+
210
236
  ## 9. 样式纪律(style-audit 强制)
211
237
 
212
238
  - 动效用 Token:`--wf-dur-*` / `--wf-ease-*` / `--wf-motion-*`(禁硬编码)
package/docs/frontend.md CHANGED
@@ -143,6 +143,34 @@ ctx.ui.render(['name'])
143
143
 
144
144
  ---
145
145
 
146
+ ## 浏览器环境抽象(ctx.browser)
147
+
148
+ > 组件**不直接引用 window/document**——统一经 `ctx.browser`(环境 API):
149
+ > SSR 安全(shim 返回安全默认)+ 测试可 mock + 环境差异单点隔离。
150
+
151
+ | 方法 | 说明 |
152
+ |------|------|
153
+ | `activeElement()` | 当前焦点元素(键盘导航) |
154
+ | `byId(id)` / `query(sel)` | 元素查询(getElementById / querySelector) |
155
+ | `createElement(tag)` / `bodyAppend(el)` / `bodyRemove(el)` | 动态创建/挂载容器 |
156
+ | `copyText(text)` | **复制统一入口**(clipboard API + execCommand 降级) |
157
+ | `execCommand(cmd, value?)` | 富文本编辑器命令 |
158
+ | `selectionText()` / `getSelection()` | 编辑器选区(文本 / 完整 Selection 对象) |
159
+ | `viewportHeight()` / `scrollTop()` | 视口高度 / 滚动量(scrollingElement 优先) |
160
+ | `hash()` / `setHash(h)` | 锚点 hash |
161
+ | `timeout(fn, ms)` | 定时器(SSR no-op) |
162
+ | `rootElement()` | document.documentElement(主题应用) |
163
+ | `storageGet(key)` / `storageSet(key, val)` | localStorage(SSR/隐私模式安全) |
164
+
165
+ **三态实现**:客户端 `createClientBrowser`(惰性 typeof 防御)· SSR shim(null/0/no-op)· 测试 mock 或 jsdom fallback。
166
+
167
+ ```tsx
168
+ // 组件内(mount 层)
169
+ const browser = ctx.browser ?? createClientBrowser()
170
+ // 事件回调
171
+ await browser.copyText(text)
172
+ ```
173
+
146
174
  ## 状态管理
147
175
 
148
176
  ### ctx.ui 方法速查
package/docs/layout.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  > 本页为 weifuwu 官方文档拆分页 · [返回 README](../README.md)
4
4
 
5
- 纯 CSS 布局原语 + 工具类 + 141 个主题 Token。不绑定任何 JS 框架。
5
+ 纯 CSS 布局原语 + 工具类 + 143 个主题 Token。不绑定任何 JS 框架。
6
6
 
7
7
  > **学习路径与命名规范**:见 [`design/style-guide.md`](../design/style-guide.md)——统一语法 `wf-<域>-<名>`、三档学习(组件 → 10 核心原语 → 完整速查)、场景速查、变量定制。
8
8
 
@@ -101,7 +101,7 @@ app.get('/layout.css', (req, ctx) => ctx.ui.css('weifuwu/layout'))
101
101
  | `wf-truncate` | 单行省略(ellipsis) |
102
102
  | `wf-line-clamp-2/3` | 多行截断 |
103
103
 
104
- ## 141 个主题 Token
104
+ ## 143 个主题 Token
105
105
 
106
106
  **双层结构**:原始层(Primitive,色值只定义一次,品牌/暗色调校改这里)+ 语义层(Semantic,组件消费)。
107
107
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "weifuwu",
3
3
  "type": "module",
4
- "version": "0.65.0",
4
+ "version": "0.66.0",
5
5
  "description": "AI SaaS framework — (req, ctx) => Response",
6
6
  "exports": {
7
7
  ".": {