weifuwu 0.66.0 → 0.67.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/README.md +11 -11
- package/dist/client/index.js +4 -4
- package/dist/client/types.d.ts +8 -0
- package/dist/components/DiffView/DiffView.d.ts +24 -0
- package/dist/components/DiffView/diff-utils.d.ts +19 -0
- package/dist/components/Editor/tools/format.d.ts +1 -1
- package/dist/components/Kanban/Kanban.d.ts +28 -0
- package/dist/components/Pipeline/Pipeline.d.ts +27 -0
- package/dist/components/Pipeline/dag-utils.d.ts +36 -0
- package/dist/components/Sparkline/Sparkline.d.ts +21 -0
- package/dist/components/Sparkline/sparkline-utils.d.ts +16 -0
- package/dist/components/Tour/Tour.d.ts +34 -0
- package/dist/components/Tree/Tree.d.ts +2 -0
- package/dist/components/TreeSelect/TreeSelect.d.ts +24 -0
- package/dist/components/index.d.ts +8 -0
- package/dist/components/index.js +15 -13
- package/dist/components/style.css +427 -0
- package/dist/index.js +15 -2
- package/dist/layout/weifuwu-layout.css +7 -0
- package/docs/components-map.md +17 -0
- package/docs/custom-components.md +3 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# weifuwu
|
|
2
2
|
|
|
3
|
-
**自托管全栈框架** — 一个 npm 包 = 后端 HTTP + 前端 VDOM +
|
|
3
|
+
**自托管全栈框架** — 一个 npm 包 = 后端 HTTP + 前端 VDOM + 102 组件 + CSS 设计系统 + SaaS 地基(认证 / 消息 / 队列 / AI)。全自研、零构建、消灭样板。
|
|
4
4
|
|
|
5
5
|
```bash
|
|
6
6
|
npm install weifuwu # 一个依赖,完整应用栈
|
|
@@ -24,7 +24,7 @@ npm install weifuwu # 一个依赖,完整应用栈
|
|
|
24
24
|
|----|------|------|
|
|
25
25
|
| 后端 | `weifuwu` | Trie 路由 / 中间件链 / serve / 自研 PG+Redis / SSR / GraphQL / WebSocket |
|
|
26
26
|
| 前端 | `weifuwu/client` | 两阶段组件 / Proxy 渲染 / 数据管道 / 路由 / api·auth·ws·i18n / 移动端原语 / **ctx.browser 环境抽象**(组件零 window/document) |
|
|
27
|
-
| 组件 | `weifuwu/components` |
|
|
27
|
+
| 组件 | `weifuwu/components` | 102 个 HTML 原语组件(表单/表格/弹层/AiChat…),引用 `--wf-*` 主题变量 |
|
|
28
28
|
| 样式 | `weifuwu/layout` | 70 布局原语 + 141 主题 Token,零自定义 CSS 文件 |
|
|
29
29
|
| SaaS 地基 | 随包内置 | rateLimit / email / userSystem / messager / queue / ai → `ctx.*` 一行接入 |
|
|
30
30
|
|
|
@@ -109,7 +109,7 @@ npm install weifuwu # 一个依赖,完整应用栈
|
|
|
109
109
|
|
|
110
110
|
**自研数据层** — `ctx.sql`(PG v3 协议)与 `ctx.redis`(RESP2 协议)为**自研客户端**:确定性输出、行为可预测、统一错误模型。jsonb 自动解码、TTL 安全 API、schema 写前校验——高频痛点(双重编码/parseRow 样板/`'EX'` 参数顺序)从根上消除。
|
|
111
111
|
|
|
112
|
-
> **实践验证**:多租户 AI 平台(`apps/agent-platform`——14 页 + 部门聊天 + 知识库 + HITL 审批)已完全运行在框架上:auth(userSystem)/ AI 引擎(ai)/ 实时消息(messager)/ UI(
|
|
112
|
+
> **实践验证**:多租户 AI 平台(`apps/agent-platform`——14 页 + 部门聊天 + 知识库 + HITL 审批)已完全运行在框架上:auth(userSystem)/ AI 引擎(ai)/ 实时消息(messager)/ UI(102 组件)/ 数据管道(ctx.api)零自研替代。框架哲学(中间件注入、诚实裁剪、机制与策略分离)经受住了真实复杂应用的检验——这也是我们确定「哪些进框架、哪些留应用层」的依据。
|
|
113
113
|
|
|
114
114
|
---
|
|
115
115
|
|
|
@@ -218,7 +218,7 @@ createApp().use(router({ routes })).mount('#root', RouteView, { hydrate: true })
|
|
|
218
218
|
### 30 秒体验(跑现有 demo)
|
|
219
219
|
|
|
220
220
|
```bash
|
|
221
|
-
# ① 组件 cheatsheet——
|
|
221
|
+
# ① 组件 cheatsheet——102 组件全部可交互预览(零依赖,5 秒起)
|
|
222
222
|
cd apps/components-demo && node server.ts
|
|
223
223
|
# 打开 http://localhost:3000
|
|
224
224
|
|
|
@@ -304,8 +304,8 @@ cd apps/agent-platform && npm run seed && npm run dev
|
|
|
304
304
|
| 资源 | CDN 地址 | 说明 |
|
|
305
305
|
|------|---------|------|
|
|
306
306
|
| `weifuwu/client` | `https://unpkg.com/weifuwu@latest/dist/client/index.js` | 客户端核心(createApp, h, 路由, 状态管理等) |
|
|
307
|
-
| `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/index.js` |
|
|
308
|
-
| `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/style.css` | 组件 CSS +
|
|
307
|
+
| `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/index.js` | 102 个 UI 组件(Button, Card, Table, Modal, Icon 等) |
|
|
308
|
+
| `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/style.css` | 组件 CSS + 150 个主题 Token + 70 个布局原语 |
|
|
309
309
|
| 独立布局系统 | `https://unpkg.com/weifuwu@latest/dist/layout/weifuwu-layout.css` | 仅 CSS 布局,不依赖 JS |
|
|
310
310
|
|
|
311
311
|
|
|
@@ -346,8 +346,8 @@ cd apps/agent-platform && npm run seed && npm run dev
|
|
|
346
346
|
| `weifuwu/client` | **lockScroll/trapFocus** | 滚动锁定 / 焦点陷阱工具 | — |
|
|
347
347
|
| `weifuwu/client` | **popup** | 弹层 fixed 定位工具(`computeFixedPos` / `computeFixedPosRect` / `clampToViewport`) | — |
|
|
348
348
|
| `weifuwu/client` | **事件原语** | `usePopup` / `useDialog` / `usePresence` / `useInView` / `useScrollPosition` / `useGlobalKey` / `useDrag` / `useDragDrop` / `useAnimationEnd` / `useTween` / `useReducedMotion`(浏览器事件/动画统一入口,见 [docs/mobile.md](docs/mobile.md)) | — |
|
|
349
|
-
| `weifuwu/components` | **
|
|
350
|
-
| `weifuwu/layout` | **CSS 布局** | 70 个布局原语 +
|
|
349
|
+
| `weifuwu/components` | **102 个组件** | Button/Table/Modal/Confirm/Toast/... + `confirm()` / `toast()` 命令式中间件 | weifuwu/client |
|
|
350
|
+
| `weifuwu/layout` | **CSS 布局** | 70 个布局原语 + 150 个主题 Token(也支持 `weifuwu/layout/style.css`) | — |
|
|
351
351
|
|
|
352
352
|
---
|
|
353
353
|
|
|
@@ -368,7 +368,7 @@ cd apps/agent-platform && npm run seed && npm run dev
|
|
|
368
368
|
| 后台任务/定时 | `queue()` → `ctx.queue` · `scheduler()` → `ctx.schedule/cron` | [docs/saas.md](docs/saas.md) |
|
|
369
369
|
| AI 对话 / Agent / HITL 审批 | `ai()` → `ctx.ai` + `ctx.ui.useChat()` + `AiChat` | [docs/saas.md](docs/saas.md) |
|
|
370
370
|
| GraphQL / WebSocket | `app.graphql(handler)` · `app.ws(path, handler)` | [docs/realtime.md](docs/realtime.md) |
|
|
371
|
-
| 前端 UI 组件 | `weifuwu/components`(
|
|
371
|
+
| 前端 UI 组件 | `weifuwu/components`(102 个:Button/Table/Modal/AiChat/...) | [docs/components.md](docs/components.md) |
|
|
372
372
|
| 布局/主题/暗色 | `weifuwu/layout`(70 原语 + 141 Token) | [docs/layout.md](docs/layout.md) |
|
|
373
373
|
| 样式定制(零自定义 CSS) | `--wf-*` 变量覆盖 + 组件定制钩子 | [docs/styling.md](docs/styling.md) |
|
|
374
374
|
| 移动端适配(tap/长按/键盘/弹层) | `usePopup` / `useHoverCapable` / `useLongPress` / `useVisualViewport` | [docs/mobile.md](docs/mobile.md) |
|
|
@@ -490,8 +490,8 @@ README 只保留入门内容(设计理念 / 快速开始 / 核心概念 / 模
|
|
|
490
490
|
|------|------|
|
|
491
491
|
| [docs/frontend.md](docs/frontend.md) | 前端核心:createApp / 组件模型 / 状态管理 / 条件与列表 / ref / 类型 |
|
|
492
492
|
| [docs/frontend-middleware.md](docs/frontend-middleware.md) | 前端中间件:router / api / auth / ws / i18n / ErrorBoundary / confirm / toast / ScrollLock / extendCtx |
|
|
493
|
-
| [docs/components.md](docs/components.md) | 组件库(
|
|
494
|
-
| [docs/layout.md](docs/layout.md) | 布局系统:70 个布局原语 +
|
|
493
|
+
| [docs/components.md](docs/components.md) | 组件库(102 个组件 + 使用示例 + 组件列表) |
|
|
494
|
+
| [docs/layout.md](docs/layout.md) | 布局系统:70 个布局原语 + 150 个主题 Token |
|
|
495
495
|
| [docs/styling.md](docs/styling.md) | 样式定制指南:零自定义 CSS 模式 / 暗色 / 组件级覆盖 / 作用域主题 |
|
|
496
496
|
|
|
497
497
|
### 通用
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Ie="__wfAsyncComponent";function mn(e){let n=e;return n[Ie]=!0,n}function X(e){return typeof e=="function"&&e?.[Ie]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function we(e,n,t){return{type:e,props:Ue(n),key:t??void 0}}var yn=we;function gn(e,n,t){return we(e,n,t)}function hn(e,n,...t){let o=Ue(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function Ue(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function be(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var vn=0,W=new Map,ie=[];function K(e){ie.push(e)}var se=new WeakMap;function J(){se=new WeakMap}function Ce(e,n){let t=se.get(e);if(t)return t;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(n)).then(i=>{if(typeof i!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=i,i}),se.set(e,o),o}async function De(e,n){return Ce(e,n).promise}function je(e){return se.get(e)?.resolved}function wn(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&O(t);else typeof n=="object"&&O(n)}function O(e){if(e==null||typeof e!="object")return;let n=e;if(n._id){if(n._customId&&W.delete(n._customId),W.delete(n._id),ie.length>0){for(let t of ie)t(n._id);if(n._customId)for(let t of ie)t(n._customId)}n._id=void 0,n._customId=void 0,n._render=void 0,n._parentNode=void 0,n._refNode=void 0}if(n._child!=null){if(Array.isArray(n._child))for(let t of n._child)t&&typeof t=="object"&&O(t);else O(n._child);n._child=void 0}if(n.props?.children&&typeof n.type=="string"){let t=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let o of t)o&&typeof o=="object"&&O(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(wn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${vn++}`}var qe=new WeakMap;function bn(e){let n=qe.get(e)??{count:0,warned:!1};n.count++,n.count>=3&&!n.warned&&(n.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),qe.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let c=U(o,i);return c==null?null:(n&&n.parentNode?n.parentNode.insertBefore(c,n):e.appendChild(c),c)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=Be(t),a=Be(o);if(s!==a){O(t);let c=U(o,i);return c==null?null:(n?.parentNode&&n.parentNode.replaceChild(c,n),c)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let u=o,l=t;if(typeof u.type=="function"){let c=u.type;l._render&&(u._render=l._render,u._id=l._id,u._id&&W.set(u._id,u)),u._parentNode=e,u._refNode=n;let p=Object.create(i);if(p.ui=Object.create(i.ui),p.ui._selfId=u._id,p.ui._selfVNode=u,u._ctxVersion=l._ctxVersion??p.ui._ctxVersion??0,l._render&&Tn(l.props,u.props)&&!p.ui._dirtySet?.has(l._id)&&u._ctxVersion===p.ui._ctxVersion)return u._child=l._child,n;p.ui._dirtySet?.delete(l._id);let g;try{typeof u._render=="function"?g=u._render(u.props):g=Ee(c,u.props,u,p)}catch(y){let v=i.ui?._errorHandler;v?(v(y),g=null):(console.error(`[weifuwu] Component render error in <${c?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,y),g=null)}let P=l._child;u._child=g;let C=z(e,n,P,g,p);return C||(u._refNode=null),C}if(u.type===B){let c=l._childNodes,p=$e(e,l,u,i,c);return u._childNodes=p,n}if(typeof u.type=="string"){if(n&&n.nodeType===1){let c=l.props?.ref,p=u.props?.ref;c!==p&&(typeof p=="function"&&p(n),typeof c=="function"&&typeof p=="function"&&bn(n)),Te(n,l.props,u.props),$e(n,l,u,i)}else if(n){O(t);let c=U(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(u.type===q)return ne(l,u,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];ae(c,o);let p=Array.from(e.childNodes),g=n?p.indexOf(n):-1,P=g>=0?Z(p.slice(g),c):Z(p,c);return le(e,c,o,i,P,n),n}return n}var Fe=new Map;function Cn(e){let n=Fe.get(e);return n||(n=`fn:${e.name||"anon"}`,Fe.set(e,n)),n}function Be(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let n=e;return typeof n.type=="function"?Cn(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function Te(e,n,t){let o=n?Object.keys(n).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],i=t?Object.keys(t).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],s=new Set(i);for(let a of o)if(!s.has(a)){if(a==="ref")continue;a.startsWith("on")&&typeof n[a]=="function"?e.removeEventListener(a.slice(2).toLowerCase(),n[a]):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a==="className"?"class":a)}for(let a of i){if(a==="ref")continue;let u=n?.[a],l=t?.[a];if(a==="innerHTML")l!==u&&(e.innerHTML=String(l??""));else if(l!==u)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Ke(l)):e.className=Ke(l);else if(a==="style"&&typeof l=="object"){let c=e.style;for(let p of Object.keys(l)){let g=l[p];g!=null&&(c[p]=typeof g=="number"?g+"px":String(g))}}else if(a.startsWith("on")&&typeof l=="function"){let c=a.slice(2).toLowerCase();typeof u=="function"&&e.removeEventListener(c,u),e.addEventListener(c,l)}else a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(l??""):l===!0?e.setAttribute(a,""):l!=null&&l!==!1?e.setAttribute(a,String(l)):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a)}}function Ke(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function xe(e){if(!(e==null||typeof e!="object"))return e.key}function ae(e,n){if(!n.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<n.length;o++){let i=n[o];i&&typeof i=="object"&&(i.key=o)}for(let o=0;o<e.length;o++){let i=e[o];i&&typeof i=="object"&&(i.key=o)}}}function Z(e,n){let t=[],o=0;for(let i of n){if(i==null||typeof i=="boolean"){t.push(null);continue}let s=i;if(s.type===q){t.push(null);continue}if(s.type===B){let a=s._childNodes;Array.isArray(a)&&a.length>0?(t.push(a.slice()),o+=a.length):(t.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),t.push(e[o]?[e[o]]:null),o+=1}return t}function $e(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);ae(s,a);let u=i??Array.from(e.childNodes),l=Z(u,s),c=le(e,s,a,o,l,i?.[0]??null),p=[];for(let g of c)g&&g.length>0&&p.push(...g);return p}function ee(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function ze(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function le(e,n,t,o,i=[],s=null){if(!t.some(y=>y&&typeof y=="object"&&y.key!==void 0)){let y=Math.max(n.length,t.length);for(let v=0;v<y;v++){let r=v<n.length?n[v]:null,f=v<t.length?t[v]:null;if(f==null){if(r!=null){O(r);for(let d of i[v]??[])d.remove()}}else if(r==null){let d=U(f,o);d!=null&&e.appendChild(d)}else{let d=i[v]?.[0]??null;z(e,d,r,f,o)}}return[]}for(let y=0;y<n.length;y++){let v=n[y];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[y]??[])r.remove()}let u=new Map,l=0;for(let y=0;y<n.length;y++){let v=xe(n[y]);v!==void 0&&u.set(v,{vnode:n[y],nodes:i[y]??[],index:l++})}let c=t.map(y=>xe(y)),p=new Set(c);for(let y of[...u.keys()])if(!p.has(y)){let v=u.get(y);O(v.vnode);for(let r of v.nodes)r?.remove();u.delete(y)}let g=new Array(t.length).fill(null),P=-1,C=s&&s.parentNode===e?s:e.firstChild;for(let y=0;y<t.length;y++){let v=c[y],r=t[y],f=v!==void 0?u.get(v):void 0,d=r&&typeof r=="object"&&r._placement==="remote";if(f)if(f.nodes.length>0){if(f.index<P)for(let h of f.nodes)e.insertBefore(h,C);P=Math.max(P,f.index),z(e,f.nodes[0],f.vnode,r,o),g[y]=r._childNodes??f.nodes.filter(h=>h.parentNode===e),C=g[y][g[y].length-1]?.nextSibling??null}else if(d)ne(f.vnode,r,o),g[y]=[];else{let m=z(e,null,f.vnode,r,o);g[y]=ze(m);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}else if(d)G(r,o),g[y]=[];else{let m=U(r,o);g[y]=ze(m);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}}return g}function xn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return e===n}function Tn(e,n){if(e===n)return!0;if(!e||!n)return!1;let t=new Set([...Object.keys(e),...Object.keys(n)]);for(let o of t)if(o!=="key"){if(o==="children"){if(!xn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Pe="http://www.w3.org/2000/svg",_e=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Ge(e,n){return U(e,n)}function U(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return _n(e,n);let t=e;if(t.type===q)return G(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),u=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of u){let c=U(l,n);c!=null&&a.appendChild(c)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Pn(t.type,t.props,t,n);let o=t.type,i=_e.has(o)?document.createElementNS(Pe,o):document.createElement(o);t.el=i;let s;for(let[a,u]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ye(i,a,u);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ye(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Ae(t.props?.children);for(let u of a){let l=U(u,n);if(l!=null&&(i.appendChild(l),u&&typeof u=="object"&&typeof u.type=="function")){let c=u;c._parentNode||(c._parentNode=i,c._refNode=l)}}}return s!==void 0&&(i.value=String(s)),typeof t.props?.ref=="function"&&t.props.ref(i),i}function En(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ee(e,n,t,o){let i;if(X(e)){if(i=je(e),!i)return Ce(e,o).promise.then(()=>En(o),()=>{}),null}else i=e;o.ui?.setMounting?.(!0);let s;try{s=i(n,o)}finally{o.ui?.endMounting?.()}if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return t._render=s,s(n)}function Pn(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Q(),W.set(t._id,t));let i=Object.create(o);i.ui=Object.create(o.ui),i.ui._selfId=t._id,i.ui._selfVNode=t,t._ctxVersion=i.ui._ctxVersion??0;let s;try{s=Ee(e,n,t,i)}catch(u){let l=o.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,u),s=null)}if(s==null)return t._child=null,null;t._child=s;let a=U(s,i);return t._refNode||(t._refNode=a),a}function _n(e,n){let t=document.createDocumentFragment();for(let o of e){let i=U(o,n);i!=null&&t.appendChild(i)}return t}function An(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function G(e,n){let t=An(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=U(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){G(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,ae(s,i);let a=Z(Array.from(o.childNodes),s);le(o,s,i,t,a,a[0]?.[0]??null)}function Ae(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function Ye(e,n,t){if(n==="class"||n==="className")e instanceof SVGElement?e.setAttribute("class",String(t??"")):e.className=String(t??"");else if(n==="style"&&typeof t=="object"&&t!==null){let o=e.style;for(let i of Object.keys(t)){let s=t[i];s!=null&&(o[i]=typeof s=="number"?s+"px":String(s))}}else n.startsWith("on")&&typeof t=="function"?e.addEventListener(n.slice(2).toLowerCase(),t):n==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(t??""):t===!0?e.setAttribute(n,""):t!=null&&t!==!1&&e.setAttribute(n,String(t))}function Sn(e,n,t){e.innerHTML="";let o=U(n,t);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(i=>e.appendChild(i))}function Se(e){e.node=e.node?e.node.nextSibling:null}function Rn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function kn(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Se(e)):e.parent.appendChild(n)}async function te(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let u=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==u&&(t.node.textContent=u),Se(t),t.node;let l=document.createTextNode(u);return Rn(t,l),l}if(Array.isArray(e)){let u=null;for(let l of e){let c=await te(l,n,t);c!=null&&!u&&(u=c)}return u}let o=e;if(o.type===q||o.type===B){let u=o.props?.children,l=u==null?[]:Array.isArray(u)?u:[u],c=null;for(let p of l){let g=await te(p,n,t);g!=null&&!c&&(c=g)}return c}if(typeof o.type=="function")return Nn(o,n,t);let i=o.type,s=o.props??{},a;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(a=t.node,Se(t)):(a=_e.has(i)?document.createElementNS(Pe,i):document.createElement(i),kn(t,a)),o.el=a,Te(a,null,s),!("innerHTML"in s)){let u={parent:a,node:a.firstChild},l=Ae(s.children);for(let c of l){let p=await te(c,n,u);if(p!=null&&p.parentNode!==a&&a.appendChild(p),c&&typeof c=="object"&&typeof c.type=="function"){let g=c;g._parentNode||(g._parentNode=a,g._refNode=p)}}for(;u.node;){let c=u.node;u.node=c.nextSibling,c.parentNode?.removeChild(c)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Nn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Q(),W.set(e._id,e));let o=Object.create(n);o.ui=Object.create(n.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let i=e.type,s;try{let u;X(i)?u=await De(i,o):u=i;let l=u(e.props??{},o);if(typeof l!="function")throw new Error(`Component ${i.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=l,s=l(e.props??{})}catch(u){let l=n.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,u),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await te(s,o,t);return e._refNode||(e._refNode=a),a}async function Re(e,n,t){let o={parent:e,node:e.firstChild};for(await te(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ue=0,Xe="",Je="",Qe="",Ze="",ce=0;function en(){return typeof window<"u"&&typeof document<"u"}function ke(){if(ue++,ue>1||!en())return;ce=window.scrollY;let e=document.body;Xe=e.style.overflow,Je=e.style.position,Qe=e.style.top,Ze=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${ce}px`,e.style.width="100%")}function Ne(){if(ue--,ue>0||!en())return;let e=document.body;e.style.overflow=Xe,e.style.position=Je,e.style.top=Qe,e.style.width=Ze,ce>0&&window.scrollTo(0,ce)}var Mn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function de(e){let n=e.querySelectorAll(Mn);if(n.length===0)return()=>{};let t=n[0],o=n[n.length-1],i=a=>{a.key==="Tab"&&(a.shiftKey&&document.activeElement===t?(a.preventDefault(),o.focus()):!a.shiftKey&&document.activeElement===o&&(a.preventDefault(),t.focus()))},s=document.activeElement;return queueMicrotask(()=>{t.focus()}),e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i),s?.focus()}}function fe(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(u,l,c){if(Reflect.get(u,l)===c)return!0;Reflect.set(u,l,c),e();for(let g of t)g();return!0},get(u,l){let c=Reflect.get(u,l);return typeof c=="object"&&c!==null?o(c):c},deleteProperty(u,l){if(Reflect.has(u,l)){Reflect.deleteProperty(u,l),e();for(let c of t)c()}return!0}});return n.set(s,a),a},i=o({});return Object.defineProperty(i,"__watch",{value:s=>(t.add(s),()=>{t.delete(s)}),writable:!1,enumerable:!1}),i}function Me(e,n,t){let o=new AbortController,i=t?.signal;i&&(i.aborted?o.abort():i.addEventListener("abort",()=>o.abort(),{once:!0}));let s=t?.traceId??Hn(),a=t?.record!==!1,u=[],l=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(p){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:p instanceof Error?p.message:String(p)});return}if(!c.ok){t?.onError?.({code:Vn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:p,data:g}of On(c.body)){if(o.signal.aborted)return;Wn(u,{name:p,data:g},a),Ln(p,g,t??{})}}catch(p){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:p instanceof Error?p.message:String(p)})}})();return{abort:()=>o.abort(),done:l,traceId:s,events:u}}function Ln(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*On(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:i,value:s}=await n.read();if(i)break;o+=t.decode(s,{stream:!0});let a=o.split(`
|
|
1
|
+
var Ie="__wfAsyncComponent";function mn(e){let n=e;return n[Ie]=!0,n}function X(e){return typeof e=="function"&&e?.[Ie]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function we(e,n,t){return{type:e,props:De(n),key:t??void 0}}var yn=we;function gn(e,n,t){return we(e,n,t)}function hn(e,n,...t){let o=De(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function De(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function be(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var vn=0,V=new Map,ie=[];function K(e){ie.push(e)}var se=new WeakMap;function J(){se=new WeakMap}function Ce(e,n){let t=se.get(e);if(t)return t;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(n)).then(i=>{if(typeof i!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=i,i}),se.set(e,o),o}async function Ue(e,n){return Ce(e,n).promise}function je(e){return se.get(e)?.resolved}function wn(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&O(t);else typeof n=="object"&&O(n)}function O(e){if(e==null||typeof e!="object")return;let n=e;if(n._id){if(n._customId&&V.delete(n._customId),V.delete(n._id),ie.length>0){for(let t of ie)t(n._id);if(n._customId)for(let t of ie)t(n._customId)}n._id=void 0,n._customId=void 0,n._render=void 0,n._parentNode=void 0,n._refNode=void 0}if(n._child!=null){if(Array.isArray(n._child))for(let t of n._child)t&&typeof t=="object"&&O(t);else O(n._child);n._child=void 0}if(n.props?.children&&typeof n.type=="string"){let t=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let o of t)o&&typeof o=="object"&&O(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(wn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${vn++}`}var qe=new WeakMap;function bn(e){let n=qe.get(e)??{count:0,warned:!1};n.count++,n.count>=3&&!n.warned&&(n.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),qe.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let c=D(o,i);return c==null?null:(n&&n.parentNode?n.parentNode.insertBefore(c,n):e.appendChild(c),c)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=Be(t),a=Be(o);if(s!==a){O(t);let c=D(o,i);return c==null?null:(n?.parentNode&&n.parentNode.replaceChild(c,n),c)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let u=o,l=t;if(typeof u.type=="function"){let c=u.type;l._render&&(u._render=l._render,u._id=l._id,u._id&&V.set(u._id,u)),u._parentNode=e,u._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=u._id,m.ui._selfVNode=u,u._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Tn(l.props,u.props)&&!m.ui._dirtySet?.has(l._id)&&u._ctxVersion===m.ui._ctxVersion)return u._child=l._child,n;m.ui._dirtySet?.delete(l._id);let g;try{typeof u._render=="function"?g=u._render(u.props):g=Ee(c,u.props,u,m)}catch(y){let v=i.ui?._errorHandler;v?(v(y),g=null):(console.error(`[weifuwu] Component render error in <${c?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,y),g=null)}let P=l._child;u._child=g;let C=z(e,n,P,g,m);return C||(u._refNode=null),C}if(u.type===B){let c=l._childNodes,m=$e(e,l,u,i,c);return u._childNodes=m,n}if(typeof u.type=="string"){if(n&&n.nodeType===1){let c=l.props?.ref,m=u.props?.ref;c!==m&&(typeof m=="function"&&m(n),typeof c=="function"&&typeof m=="function"&&bn(n)),Te(n,l.props,u.props),$e(n,l,u,i)}else if(n){O(t);let c=D(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(u.type===q)return ne(l,u,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];ae(c,o);let m=Array.from(e.childNodes),g=n?m.indexOf(n):-1,P=g>=0?Z(m.slice(g),c):Z(m,c);return le(e,c,o,i,P,n),n}return n}var Fe=new Map;function Cn(e){let n=Fe.get(e);return n||(n=`fn:${e.name||"anon"}`,Fe.set(e,n)),n}function Be(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let n=e;return typeof n.type=="function"?Cn(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function Te(e,n,t){let o=n?Object.keys(n).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],i=t?Object.keys(t).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],s=new Set(i);for(let a of o)if(!s.has(a)){if(a==="ref")continue;a.startsWith("on")&&typeof n[a]=="function"?e.removeEventListener(a.slice(2).toLowerCase(),n[a]):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a==="className"?"class":a)}for(let a of i){if(a==="ref")continue;let u=n?.[a],l=t?.[a];if(a==="innerHTML")l!==u&&(e.innerHTML=String(l??""));else if(l!==u)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Ke(l)):e.className=Ke(l);else if(a==="style"&&typeof l=="object"){let c=e.style;for(let m of Object.keys(l)){let g=l[m];g!=null&&(c[m]=typeof g=="number"?g+"px":String(g))}}else if(a.startsWith("on")&&typeof l=="function"){let c=a.slice(2).toLowerCase();typeof u=="function"&&e.removeEventListener(c,u),e.addEventListener(c,l)}else a==="draggable"?e.setAttribute("draggable",l?"true":"false"):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(l??""):l===!0?e.setAttribute(a,""):l!=null&&l!==!1?e.setAttribute(a,String(l)):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a)}}function Ke(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function xe(e){if(!(e==null||typeof e!="object"))return e.key}function ae(e,n){if(!n.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<n.length;o++){let i=n[o];i&&typeof i=="object"&&(i.key=o)}for(let o=0;o<e.length;o++){let i=e[o];i&&typeof i=="object"&&(i.key=o)}}}function Z(e,n){let t=[],o=0;for(let i of n){if(i==null||typeof i=="boolean"){t.push(null);continue}let s=i;if(s.type===q){t.push(null);continue}if(s.type===B){let a=s._childNodes;Array.isArray(a)&&a.length>0?(t.push(a.slice()),o+=a.length):(t.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),t.push(e[o]?[e[o]]:null),o+=1}return t}function $e(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);ae(s,a);let u=i??Array.from(e.childNodes),l=Z(u,s),c=le(e,s,a,o,l,i?.[0]??null),m=[];for(let g of c)g&&g.length>0&&m.push(...g);return m}function ee(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function ze(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function le(e,n,t,o,i=[],s=null){if(!t.some(y=>y&&typeof y=="object"&&y.key!==void 0)){let y=Math.max(n.length,t.length);for(let v=0;v<y;v++){let r=v<n.length?n[v]:null,d=v<t.length?t[v]:null;if(d==null){if(r!=null){O(r);for(let f of i[v]??[])f.remove()}}else if(r==null){let f=D(d,o);f!=null&&e.appendChild(f)}else{let f=i[v]?.[0]??null;z(e,f,r,d,o)}}return[]}for(let y=0;y<n.length;y++){let v=n[y];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[y]??[])r.remove()}let u=new Map,l=0;for(let y=0;y<n.length;y++){let v=xe(n[y]);v!==void 0&&u.set(v,{vnode:n[y],nodes:i[y]??[],index:l++})}let c=t.map(y=>xe(y)),m=new Set(c);for(let y of[...u.keys()])if(!m.has(y)){let v=u.get(y);O(v.vnode);for(let r of v.nodes)r?.remove();u.delete(y)}let g=new Array(t.length).fill(null),P=-1,C=s&&s.parentNode===e?s:e.firstChild;for(let y=0;y<t.length;y++){let v=c[y],r=t[y],d=v!==void 0?u.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(d)if(d.nodes.length>0){if(d.index<P)for(let h of d.nodes)e.insertBefore(h,C);P=Math.max(P,d.index),z(e,d.nodes[0],d.vnode,r,o),g[y]=r._childNodes??d.nodes.filter(h=>h.parentNode===e),C=g[y][g[y].length-1]?.nextSibling??null}else if(f)ne(d.vnode,r,o),g[y]=[];else{let p=z(e,null,d.vnode,r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}else if(f)G(r,o),g[y]=[];else{let p=D(r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}}return g}function xn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return e===n}function Tn(e,n){if(e===n)return!0;if(!e||!n)return!1;let t=new Set([...Object.keys(e),...Object.keys(n)]);for(let o of t)if(o!=="key"){if(o==="children"){if(!xn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Pe="http://www.w3.org/2000/svg",_e=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Ge(e,n){return D(e,n)}function D(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return _n(e,n);let t=e;if(t.type===q)return G(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),u=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of u){let c=D(l,n);c!=null&&a.appendChild(c)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Pn(t.type,t.props,t,n);let o=t.type,i=_e.has(o)?document.createElementNS(Pe,o):document.createElement(o);t.el=i;let s;for(let[a,u]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ye(i,a,u);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ye(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Ae(t.props?.children);for(let u of a){let l=D(u,n);if(l!=null&&(i.appendChild(l),u&&typeof u=="object"&&typeof u.type=="function")){let c=u;c._parentNode||(c._parentNode=i,c._refNode=l)}}}return s!==void 0&&(i.value=String(s)),typeof t.props?.ref=="function"&&t.props.ref(i),i}function En(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ee(e,n,t,o){let i;if(X(e)){if(i=je(e),!i)return Ce(e,o).promise.then(()=>En(o),()=>{}),null}else i=e;o.ui?.setMounting?.(!0);let s;try{s=i(n,o)}finally{o.ui?.endMounting?.()}if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return t._render=s,s(n)}function Pn(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Q(),V.set(t._id,t));let i=Object.create(o);i.ui=Object.create(o.ui),i.ui._selfId=t._id,i.ui._selfVNode=t,t._ctxVersion=i.ui._ctxVersion??0;let s;try{s=Ee(e,n,t,i)}catch(u){let l=o.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,u),s=null)}if(s==null)return t._child=null,null;t._child=s;let a=D(s,i);return t._refNode||(t._refNode=a),a}function _n(e,n){let t=document.createDocumentFragment();for(let o of e){let i=D(o,n);i!=null&&t.appendChild(i)}return t}function An(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function G(e,n){let t=An(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=D(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){G(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,ae(s,i);let a=Z(Array.from(o.childNodes),s);le(o,s,i,t,a,a[0]?.[0]??null)}function Ae(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function Ye(e,n,t){if(n==="class"||n==="className")e instanceof SVGElement?e.setAttribute("class",String(t??"")):e.className=String(t??"");else if(n==="style"&&typeof t=="object"&&t!==null){let o=e.style;for(let i of Object.keys(t)){let s=t[i];s!=null&&(o[i]=typeof s=="number"?s+"px":String(s))}}else n.startsWith("on")&&typeof t=="function"?e.addEventListener(n.slice(2).toLowerCase(),t):n==="draggable"?e.setAttribute("draggable",t?"true":"false"):n==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(t??""):t===!0?e.setAttribute(n,""):t!=null&&t!==!1&&e.setAttribute(n,String(t))}function Sn(e,n,t){e.innerHTML="";let o=D(n,t);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(i=>e.appendChild(i))}function Se(e){e.node=e.node?e.node.nextSibling:null}function Rn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function kn(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Se(e)):e.parent.appendChild(n)}async function te(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let u=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==u&&(t.node.textContent=u),Se(t),t.node;let l=document.createTextNode(u);return Rn(t,l),l}if(Array.isArray(e)){let u=null;for(let l of e){let c=await te(l,n,t);c!=null&&!u&&(u=c)}return u}let o=e;if(o.type===q||o.type===B){let u=o.props?.children,l=u==null?[]:Array.isArray(u)?u:[u],c=null;for(let m of l){let g=await te(m,n,t);g!=null&&!c&&(c=g)}return c}if(typeof o.type=="function")return Nn(o,n,t);let i=o.type,s=o.props??{},a;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(a=t.node,Se(t)):(a=_e.has(i)?document.createElementNS(Pe,i):document.createElement(i),kn(t,a)),o.el=a,Te(a,null,s),!("innerHTML"in s)){let u={parent:a,node:a.firstChild},l=Ae(s.children);for(let c of l){let m=await te(c,n,u);if(m!=null&&m.parentNode!==a&&a.appendChild(m),c&&typeof c=="object"&&typeof c.type=="function"){let g=c;g._parentNode||(g._parentNode=a,g._refNode=m)}}for(;u.node;){let c=u.node;u.node=c.nextSibling,c.parentNode?.removeChild(c)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Nn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Q(),V.set(e._id,e));let o=Object.create(n);o.ui=Object.create(n.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let i=e.type,s;try{let u;X(i)?u=await Ue(i,o):u=i;let l=u(e.props??{},o);if(typeof l!="function")throw new Error(`Component ${i.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=l,s=l(e.props??{})}catch(u){let l=n.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,u),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await te(s,o,t);return e._refNode||(e._refNode=a),a}async function Re(e,n,t){let o={parent:e,node:e.firstChild};for(await te(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ue=0,Xe="",Je="",Qe="",Ze="",ce=0;function en(){return typeof window<"u"&&typeof document<"u"}function ke(){if(ue++,ue>1||!en())return;ce=window.scrollY;let e=document.body;Xe=e.style.overflow,Je=e.style.position,Qe=e.style.top,Ze=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${ce}px`,e.style.width="100%")}function Ne(){if(ue--,ue>0||!en())return;let e=document.body;e.style.overflow=Xe,e.style.position=Je,e.style.top=Qe,e.style.width=Ze,ce>0&&window.scrollTo(0,ce)}var Mn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function de(e){let n=e.querySelectorAll(Mn);if(n.length===0)return()=>{};let t=n[0],o=n[n.length-1],i=a=>{a.key==="Tab"&&(a.shiftKey&&document.activeElement===t?(a.preventDefault(),o.focus()):!a.shiftKey&&document.activeElement===o&&(a.preventDefault(),t.focus()))},s=document.activeElement;return queueMicrotask(()=>{t.focus()}),e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i),s?.focus()}}function fe(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(u,l,c){if(Reflect.get(u,l)===c)return!0;Reflect.set(u,l,c),e();for(let g of t)g();return!0},get(u,l){let c=Reflect.get(u,l);return typeof c=="object"&&c!==null?o(c):c},deleteProperty(u,l){if(Reflect.has(u,l)){Reflect.deleteProperty(u,l),e();for(let c of t)c()}return!0}});return n.set(s,a),a},i=o({});return Object.defineProperty(i,"__watch",{value:s=>(t.add(s),()=>{t.delete(s)}),writable:!1,enumerable:!1}),i}function Me(e,n,t){let o=new AbortController,i=t?.signal;i&&(i.aborted?o.abort():i.addEventListener("abort",()=>o.abort(),{once:!0}));let s=t?.traceId??Hn(),a=t?.record!==!1,u=[],l=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)});return}if(!c.ok){t?.onError?.({code:Wn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:m,data:g}of On(c.body)){if(o.signal.aborted)return;Vn(u,{name:m,data:g},a),Ln(m,g,t??{})}}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)})}})();return{abort:()=>o.abort(),done:l,traceId:s,events:u}}function Ln(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*On(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:i,value:s}=await n.read();if(i)break;o+=t.decode(s,{stream:!0});let a=o.split(`
|
|
2
2
|
|
|
3
|
-
`);o=a.pop()??"";for(let u of a){let l="message",c="";for(let
|
|
4
|
-
`))p.startsWith("event: ")?l=p.slice(7):p.startsWith("data: ")&&(c+=p.slice(6));if(c)try{yield{name:l,data:JSON.parse(c)}}catch{}}}}finally{n.releaseLock()}}function Wn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Vn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Hn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e){return e.map(n=>({role:n.role,content:n.content}))}function Le(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tn(e,n,t){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function i(){if(!e.streaming)return;let C=e.messages[e.messages.length-1];return C&&C.role==="assistant"&&C.status==="streaming"?C:void 0}function s(C,y,v){let r=i();switch(C){case"wf:token":r&&(r.content+=y.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:y,status:"running"}));break}case"wf:tool_progress":{let f=y,d=r?.toolCalls?.find(m=>m.call.id===f.toolCallId);d&&(d.progress=f);break}case"wf:tool_result":{let f=y,d=r?.toolCalls?.find(m=>m.call.id===f.id);d&&(d.result=f,d.status=f.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=y);break;case"wf:usage":r&&(r.usage=y);break;case"wf:step":e.step=y;break;case"wf:done":r&&(r.status="done",r.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":r&&(r.status="error",r.error=y,r.approval=void 0),e.error=y,e.streaming=!1,e.step=null;break;default:v?.(C,y);break}}function a(){let C=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,C,{onToken:v=>s("wf:token",{text:v}),onToolCall:v=>s("wf:tool_call",v),onToolProgress:v=>s("wf:tool_progress",v),onToolResult:v=>s("wf:tool_result",v),onApproval:v=>s("wf:approval_request",v),onUsage:v=>s("wf:usage",v),onStep:v=>s("wf:step",v),onDone:v=>s("wf:done",v),onError:v=>s("wf:error",v),onEvent:(v,r)=>s(v,r,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let y=i();y&&o?.traceId&&(y.id=o.traceId)}function u(){if(e.streaming)return;let C=String(e.input??"").trim();C&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:C,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let C=e.messages[e.messages.length-1];C&&C.role==="assistant"&&C.status==="streaming"&&(!C.content&&(!C.toolCalls||C.toolCalls.length===0)?e.messages.pop():C.status="done")}function c(){if(e.streaming)return;let C=-1;for(let y=e.messages.length-1;y>=0;y--)if(e.messages[y].role==="user"){C=y;break}C!==-1&&(e.messages.splice(C+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function p(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function g(C,y){let v=e.messages[e.messages.length-1],r=v?.role==="assistant"?v.approval:void 0;if(r&&(v.approval=void 0,!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify({id:r.id,decision:C,note:y}),signal:t.signal})}catch(f){if(t.signal?.aborted)return;e.error={code:"provider_error",message:f instanceof Error?f.message:String(f)}}}function P(){o?.abort(),o=null}return{send:u,stop:l,retry:c,clear:p,approve:g,dispose:P}}function pe(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function In(e,n="bottom",t=6,o=!0){return pe(e.getBoundingClientRect(),n,t,o)}function me(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let i=Number.parseFloat(n.style.top)||o.top,s=Number.parseFloat(n.style.left)||o.left,a=e.top-i,u=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+u,right:o.right+u},c=window.innerWidth,p=window.innerHeight,g=e.top,P=e.left;return l.bottom>p-t&&(g=Math.max(t,g-(l.bottom-(p-t)))),l.top<t&&(g=Math.max(t,g+(t-l.top))),l.right>c-t&&(P=Math.max(t,P-(l.right-(c-t)))),l.left<t&&(P=Math.max(t,P+(t-l.left))),{top:g,left:P,width:e.width}}var on=new Set,oe=new Map;function rn(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:u,scrollTrackers:l,schedulePopupRecompute:c,ensurePopupListeners:p,isRendering:g,isMounting:P,setMounting:C,endMounting:y}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:C,endMounting:y,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(g()){if(P())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let f=o(this);if(f)r=[f];else return}t(r)},dirty:function(r){if(!P()){if(g()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let f=o(this);if(f)r=[f];else return}for(let f of r)f&&(i.add(f),s.add(f));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let f=[...i];i.clear(),f.length>0&&t(f)}))}},$:function(){let r=this;return r._$cache||(r._$cache=fe(()=>{let f=r._selfVNode?._id??o(r);f&&n.ui.dirty([f])})),r._$cache},useChat:function(r){let f=this.$(),d=tn(f,Me,r);return Object.assign(f,{send:d.send,stop:d.stop,retry:d.retry,clear:d.clear,approve:d.approve,dispose:d.dispose}),f},useMedia:function(r,f){let m=`media:${o(this)}:${r}`;if(!a.has(m)){let h=window.matchMedia(r);f(h.matches);let b=E=>f(E.matches);h.addEventListener("change",b),a.set(m,{mql:h,handler:b})}},useBreakpoint:function(r,f){let d=typeof r=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:r,m=typeof r=="function"?r:f,b=`bp:${o(this)}`;function E(){for(let[x,k]of Object.entries(d))if(window.matchMedia(k).matches)return x;return Object.keys(d)[0]??""}if(!a.has(b)){m(E());let x=[];for(let k of Object.values(d)){let T=window.matchMedia(k),_=()=>m(E());T.addEventListener("change",_),x.push({mql:T,handler:_})}a.set(b,{mqls:x})}},usePopupPosition:function(r){let f=o(this),d={top:0,left:0,refresh:()=>{}};if(!f)return d;let m={pos:d,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return u.set(f,m),p(),d.refresh=()=>{let h=m.getEl();if(!h)return;let b=m.compute(h.getBoundingClientRect());Object.assign(d,me(b,m.panel?.(),m.margin))},d},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,f){return m=>{m?r(m):f?.()}},useVisualViewport:function(){let r=o(this),f={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},d=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},m=()=>{let b=window.visualViewport;f.height=b?.height??window.innerHeight,f.offsetTop=b?.offsetTop??0,f.keyboardOpen=f.height<window.innerHeight*.9,d()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",m),h.addEventListener("scroll",m)):window.addEventListener("resize",m),r&&K(b=>{b===r&&(h?.removeEventListener?(h.removeEventListener("resize",m),h.removeEventListener("scroll",m)):window.removeEventListener("resize",m))}),f},usePopup:function(r){let f=o(this),d=this.useHoverCapable(),m=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,b=()=>!!r.disabled?.(),E=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{b()||(h?r.onOpenChange?.(A):r.setOpen(A))},k=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},T=null,_=!1,w=n.ui.usePopupPosition({el:r.el,isOpen:()=>E(),compute:A=>{if(r.position){let V=r.position();return{top:V.y,left:V.x}}return pe(A,k(),r.gap??6,r.center!==!1)},panel:()=>T,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!E())return;let V=A.target;if(!(V instanceof Node))return;let $=r.el();$&&$.contains(V)||T&&T.contains(V)||x(!1)},M=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!E()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",M),f&&K(A=>{A===f&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",M))});let S={},j=A=>typeof A=="function"?A():A??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,I,re=()=>{clearTimeout(L),clearTimeout(I),L=void 0,I=void 0};if(m()==="hover")d?(S.onMouseEnter=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!E()),S.onFocus=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(m()==="click")S.onClick=()=>x(!E());else if(m()==="longpress"){let A,V=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=D=>{b()||(V=D.clientX??0,$=D.clientY??0,F(),A=setTimeout(()=>{A=void 0,r.onTrigger?.({clientX:V,clientY:$}),x(!0)},r.longPressDuration??500))},S.onPointerUp=F,S.onPointerLeave=F,S.onPointerMove=D=>{let he=Math.abs((D.clientX??0)-V),ve=Math.abs((D.clientY??0)-$);(he>10||ve>10)&&F()},S.onContextMenu=D=>{D.preventDefault(),r.onTrigger?.({clientX:D.clientX??0,clientY:D.clientY??0}),x(!0)}}S.onKeyDown=A=>{A.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},f&&K(A=>{A===f&&re()});let dn=A=>{if(A){T=A;let V=()=>w.refresh();A.addEventListener("animationend",V,{once:!0})}else T=null},fn=(A,V="popover")=>{if(b())return null;if(!E())return _=!1,null;_||(w.refresh(),_=!0);let F=A.props??{},D=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},pn={...A,props:{...F,class:he,style:ve,ref:He=>{dn(He),D&&D(He)}}};return be(pn,V)};return{open:E(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>w.refresh()}},useLongPress:function(r){let{onLongPress:f,duration:d=500}=r,m,h=0,b=0,E=null,x=()=>{clearTimeout(m),m=void 0};return{onPointerDown:k=>{h=k.clientX??0,b=k.clientY??0,E=k,x(),m=setTimeout(()=>{m=void 0,f(E)},d)},onPointerUp:x,onPointerLeave:x,onPointerMove:k=>{let T=Math.abs((k.clientX??0)-h),_=Math.abs((k.clientY??0)-b);(T>10||_>10)&&x()},onContextMenu:k=>{k.preventDefault(),f(k)}}},useInView:function(r){let f=o(this),d={isIn:!1,ready:!1,observe:x,refresh:k,disconnect:T},m=null,h=null,b=()=>{n.ui&&n.ui.dirty(f?[f]:void 0)};function E(){if(h?.disconnect(),h=null,!m)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,w=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let M=R[R.length-1];if(!M)return;let S=M.isIntersecting,j=S!==d.isIn,N=!d.ready;d.isIn=S,d.ready=!0,r.onChange?.(M,S),(j||N)&&b()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:w??0}),h.observe(m)}function x(_){m=_,_?E():(h?.disconnect(),h=null,d.isIn=!1)}function k(){E()}function T(){h?.disconnect(),h=null}return d},useScrollPosition:function(r){let f=o(this),d={y:0,refresh(){let h=m.getScroller();d.y=h instanceof Window?document.scrollingElement?.scrollTop??h.scrollY??0:h.scrollTop??0}},m={handle:d,getScroller:r.getScroller??(()=>window)};return f?(l.set(f,m),p(),d.refresh(),d):(d.refresh(),d)},useAsync:function(r){let f=o(this),d=fe(()=>{n.ui&&n.ui.dirty(f?[f]:void 0)});d.loading=!0;let m=0,h=()=>{let b=++m;d.loading=!0,d.error=null,Promise.resolve().then(()=>r()).then(E=>{m===b&&(d.data=E,d.loading=!1)}).catch(E=>{m===b&&(d.error=E,d.loading=!1)})};return h(),d.reload=h,d},useControlled:function(r){let f=o(this),d=r.value!==void 0;d&&!r.onChange&&r.name&&(on.has(r.name)||(on.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!d&&f&&!oe.has(f)&&(oe.set(f,r.value),K(h=>{oe.delete(h)}));let m=h=>{if(d){r.onChange?.(h);return}f&&oe.set(f,h),n.ui&&(f?n.ui.dirty([f]):n.ui.render())};return{value:d?r.value:f?oe.get(f):r.value,setValue:m,controlled:d}},usePresence:function(r){let f=o(this),d="closed",m,h=()=>{d="closed",n.ui&&(f?n.ui.dirty([f]):n.ui.render())};return{get phase(){return d},ref:E=>{E?m||(m=()=>{d==="exit"&&h()},E.addEventListener("animationend",m)):(E?.removeEventListener("animationend",m),m=void 0)},sync:E=>(E?d="open":d==="open"&&(d="exit"),d)}},useDialog:function(r){let f=o(this),d,m=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(ke(),m&&(d=de(m)),h.ref(x)):(Ne(),d?.(),h.ref(null))},panelRef:x=>{m=x,x&&!d&&(d=de(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let f=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),f&&K(d=>{d===f&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let f=0,d=0,m=!1,h=x=>{m&&r.onMove(x,{x:x.clientX-f,y:x.clientY-d})},b=x=>{m&&(m=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",b),r.onEnd?.(x))};return{onPointerDown:x=>{m||(x.preventDefault(),m=!0,f=x.clientX,d=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",b),r.onStart?.(x))}}},useDragDrop:function(r){let f={};return r.onDrop&&(f.onDrop=d=>{d.preventDefault(),r.onDrop(d)}),r.onDragOver&&(f.onDragOver=d=>{d.preventDefault(),r.onDragOver(d)}),r.onDragLeave&&(f.onDragLeave=d=>r.onDragLeave(d)),{dropProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,f){let d=null,m=()=>{r(),f?.once&&d&&d.removeEventListener("animationend",m)};return b=>{b?(d=b,b.addEventListener("animationend",m)):d&&(d.removeEventListener("animationend",m),d=null)}},useTween:function(r,f){let d=o(this),m=this.useReducedMotion(),h=f?.duration??400,b=f?.ease==="linear"?w=>w:w=>1-Math.pow(1-w,3),E,x=r,k={value:m?r:0,reset:()=>{}},T=()=>{n.ui&&(d?n.ui.dirty([d]):n.ui.render())},_=w=>{if(x=w,m){k.value=w,T();return}if(w===k.value)return;E&&cancelAnimationFrame(E);let R=k.value,M=performance.now(),S=j=>{let N=Math.min(1,(j-M)/h);k.value=Math.round(R+(w-R)*b(N)),N<1?(E=requestAnimationFrame(S),T()):(E=void 0,T())};E=requestAnimationFrame(S)};return k.reset=w=>{w===x&&E||_(w)},queueMicrotask(()=>_(r)),k},selfId:function(r){if(typeof r!="string"||!r)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof r}`);if(W.has(r))throw new Error(`[weifuwu] Duplicate component ID: "${r}". Each component must have a unique custom ID.`);let f=this._selfVNode;f&&(f._customId=r,W.set(r,f))}}}function sn(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Un(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,u=[];function l(T){u.push(a),a=T}function c(){a=u.pop()??!1}let p=new Set,g=!1,P=new Map;function C(T){let _=P.get(T);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:w,handler:R})=>w.removeEventListener("change",R)),P.delete(T))}let y=new Map,v=!1,r=0;function f(){v||(v=!0,window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h))}function d(){v&&(window.removeEventListener("scroll",h,{capture:!0}),window.removeEventListener("resize",h),v=!1)}let m=new Map;function h(){r||(r=requestAnimationFrame(()=>{r=0;let T=[];for(let[_,w]of y){if(!w.isOpen())continue;let R=w.getEl();if(!R)continue;let M=w.compute(R.getBoundingClientRect());Object.assign(w.pos,me(M,w.panel?.(),w.margin)),T.push(_)}for(let[_,w]of m){let R=w.getScroller(),M=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;M!==w.handle.y&&(w.handle.y=M,T.push(_))}T.length>0&&n.ui.render(T)}))}function b(T){if(!s){s=!0;for(let _ of T){let w=W.get(_);if(!w||!w._render)continue;n.ui._dirtySet?.delete(_);let R=w._child,M=w._render(w.props);if(w._child=M,R&&R._placement==="remote"||M&&M._placement==="remote"){R&&M?ne(R,M,n):M?G(M,n):R&&O(R);continue}if(!w._parentNode&&w._refNode&&(w._parentNode=w._refNode.parentNode),w._parentNode){let S=z(w._parentNode,w._refNode??null,R,M,n);S&&S!==w._refNode?w._refNode=S:S||(w._refNode=null)}}s=!1,E()}}function E(){let T=n.ui;p.size>0&&!T._dirtyScheduled&&(T._dirtyScheduled=!0,queueMicrotask(()=>{T._dirtyScheduled=!1;let _=[...p];p.clear(),_.length>0&&b(_)}))}function x(T){return T?._selfId??n.ui?._selfId}let k={get ctx(){return n},use(T){return e.push(T),k},async mount(T,_,w){o=_;for(let N of e)n=await N(n);let R=typeof T=="string"?document.querySelector(T):T;if(!R)throw new Error(`mount target not found: ${T}`);t=R;let M=!!w?.hydrate;M||(t.innerHTML="");let S=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))S.set(N,{value:H});if(n.data={async get(N,H){let L=S.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let I=Promise.resolve().then(()=>H()).then(re=>(S.set(N,{value:re}),re));return S.set(N,{promise:I}),I},set(N,H){S.set(N,{value:H})},has(N){return S.has(N)}},K(N=>{for(let H of[...P.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&C(H);y.delete(N),m.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:b,getSelfId:x,dirtyBatch:p,dirtySet:new Set,mediaRegistry:P,popupTrackers:y,scrollTrackers:m,schedulePopupRecompute:h,ensurePopupListeners:f,destroyPopupListeners:d,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Dn(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=M?t.firstChild:null,W.set("_wf_root",i),M)await Re(t,i,n);else{let N=Ge(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,E()},destroy(){d(),y.clear(),m.clear();for(let T of[...P.keys()])C(T);W.clear(),t&&(t.innerHTML=""),t=null,n={}}};return k}function Dn(e,n){return{type:e,props:{},key:void 0}}function jn(e,n){if(!n||n==="/")return e||"/";let t=e.endsWith("/")?e.slice(0,-1):e,o=n.startsWith("/")?n:"/"+n;return t+o}function qn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Oe(e,n="",t=[]){let o=[];for(let i of e){let s=jn(n,i.path),{re:a,keys:u}=qn(s),l=[...t,i];o.push({re:a,keys:u,def:i,chain:l}),i.children&&o.push(...Oe(i.children,s,l))}return o}function an(e,n){let t=null;for(let o of n)e.match(o.re)&&(!t||o.chain.length>t.chain.length)&&(t=o);return t}function ln(e,n){let t={},o=e.match(n.re);if(o)for(let i=0;i<n.keys.length;i++)t[n.keys[i]]=decodeURIComponent(o[i+1]);return t}function Fn(e){let n=Oe(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=an(s,n);if(a){let u=a.chain[a.chain.length-1];return{path:a.def.path,params:ln(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:u?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let a=i(o());s.route=a,a.title&&(document.title=a.title),s.app||(s.app={}),s.app.navigate=l=>{if(J(),t==="hash"){window.location.hash="#"+l;let c=i(l);s.route=c}else{window.history.pushState({},"",l);let c=i(l);s.route=c}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let u=()=>{J();let l=i(o());s.route=l,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",u),t==="hash"&&window.addEventListener("hashchange",u),s}}function Bn(e,n){let t=n.route?._rvDepth??0;return()=>{let o=n.route;if(!o?.chain?.length||t>=o.chain.length)return null;let i=o.chain[t],s=i.layout??i.component;return s?(i.layout&&(o._rvDepth=t+1),{type:s,props:{},key:void 0}):null}}function Y(e,n){return Object.assign(Object.create(e),n)}function Kn(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,i=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let u=new Set,l=null,c=0,p=null,g=null,P=null,C=!1,y={isConnected:!1,onMessage:m=>(u.add(m),()=>{u.delete(m)}),send:m=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(m))},_connect:v,close:()=>{C=!0,d(),l?.close(),l=null,y.isConnected=!1}};async function v(){if(!C)try{l=new WebSocket(n),l.onopen=()=>{y.isConnected=!0,c=0,r()},l.onmessage=m=>{try{let h=JSON.parse(m.data);for(let b of u)b(h)}catch{}f()},l.onclose=()=>{y.isConnected=!1,d(),!C&&c<o&&(c++,p=setTimeout(v,t*Math.min(c,5)))},l.onerror=()=>{l?.close()}}catch{C||(p=setTimeout(v,t))}}function r(){i<=0||(g=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),P=setTimeout(()=>{l?.close()},s)},i))}function f(){clearTimeout(P)}function d(){clearInterval(g),clearTimeout(P),clearTimeout(p)}return v(),Y(a,{ws:y})}}function $n(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,i=e?.timeout??0;async function s(a,u,l,c){let p=n.baseURL+u,g={method:a,headers:{...n.headers,...c?.headers}},P=e?.token?.();P&&!g.headers.Authorization&&(g.headers.Authorization=`Bearer ${P}`);let C=i>0,y=!!c?.signal,v=null,r=null;(C||y)&&(v=new AbortController,g.signal=v.signal,C&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),y&&c.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(g.body=JSON.stringify(l));let f={url:p,init:g};t&&(f=t(f));try{let d=await fetch(f.url,f.init);if(o)return o(d);if(!d.ok){let b=await d.text().catch(()=>"");throw new ye(d.status,b||d.statusText)}let m=d.headers.get("content-length");if(d.status===204||m==="0")return;let h=(d.headers.get("content-type")||"").toLowerCase();return h.includes("application/json")||h.includes("json")?d.json():d.text()}finally{r&&clearTimeout(r)}}return a=>Y(a,{api:{get:(l,c)=>s("GET",l,void 0,c),post:(l,c,p)=>s("POST",l,c,p),put:(l,c,p)=>s("PUT",l,c,p),patch:(l,c,p)=>s("PATCH",l,c,p),delete:(l,c)=>s("DELETE",l,void 0,c)}})}var ye=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function zn(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Yn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Gn(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",i=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let u=n.getItem(t),l=n.getItem(o),c={token:u,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(p,g,P){c.token=p,c.user=g,n.setItem(t,p),n.setItem(o,JSON.stringify(g)),P&&n.setItem(i,P)},logout(){c.token=null,c.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(p){c.user=p,n.setItem(o,JSON.stringify(p))},async refresh(){let p=n.getItem(i);if(!p)return!1;try{let g=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:p})});if(!g.ok)return c.logout(),!1;let P=await g.json();return c.token=P.token,n.setItem(t,P.token),P.refreshToken&&n.setItem(i,P.refreshToken),!0}catch{return!1}}};return u&&Yn(u)&&c.refresh().catch(()=>{}),Y(a,{auth:c})}}function Xn(e,n){let t=null;return o=>{if(t){let s=o.fallback;return typeof s=="function"?s({error:t}):s??null}n.ui._errorHandler=s=>{t=s,n.ui.render()};let i=o.children;try{return i??null}catch(s){t=s;let a=o.fallback;return typeof a=="function"?a({error:s}):a??null}}}var We={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var Ve={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var ge={"zh-CN":We,"en-US":Ve};function un(e){if(ge[e])return e;let n=e.split("-")[0];return Object.keys(ge).find(o=>o.startsWith(n))??"zh-CN"}function Jn(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=un(n),s=ge[i],a=cn(s,t,o),u={locale:i,t:(l,c)=>a.messages?.[l]??c??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=u,u.setLocale=c=>{let p=un(c),g=ge[p];g&&(a=cn(g,t,o),u.locale=p,u.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function cn(e,n,t){return{messages:{...e?.messages,...n},components:Qn(e?.components??{},t)}}function Qn(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}function Zn(e,n,t=400){let o=!1,i=()=>{o||(o=!0,e.removeEventListener("animationend",i),clearTimeout(s),n())};e.addEventListener("animationend",i);let s=setTimeout(i,t)}export{ye as ApiError,Xn as ErrorBoundary,B as Fragment,q as Portal,Bn as RouteView,Me as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Gn as auth,O as callRefCleanup,J as clearAsyncComponentCache,In as computeFixedPos,pe as computeFixedPosRect,Un as createApp,be as createPortal,fe as createReactiveState,Ve as enUS,Y as extendCtx,hn as h,Re as hydrateVNode,Jn as i18n,X as isAsyncComponent,we as jsx,gn as jsxDEV,yn as jsxs,ke as lockScroll,Sn as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Ne as unlockScroll,Kn as ws,We as zhCN};
|
|
3
|
+
`);o=a.pop()??"";for(let u of a){let l="message",c="";for(let m of u.split(`
|
|
4
|
+
`))m.startsWith("event: ")?l=m.slice(7):m.startsWith("data: ")&&(c+=m.slice(6));if(c)try{yield{name:l,data:JSON.parse(c)}}catch{}}}}finally{n.releaseLock()}}function Vn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Wn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Hn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e){return e.map(n=>({role:n.role,content:n.content}))}function Le(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tn(e,n,t){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function i(){if(!e.streaming)return;let C=e.messages[e.messages.length-1];return C&&C.role==="assistant"&&C.status==="streaming"?C:void 0}function s(C,y,v){let r=i();switch(C){case"wf:token":r&&(r.content+=y.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:y,status:"running"}));break}case"wf:tool_progress":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.toolCallId);f&&(f.progress=d);break}case"wf:tool_result":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.id);f&&(f.result=d,f.status=d.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=y);break;case"wf:usage":r&&(r.usage=y);break;case"wf:step":e.step=y;break;case"wf:done":r&&(r.status="done",r.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":r&&(r.status="error",r.error=y,r.approval=void 0),e.error=y,e.streaming=!1,e.step=null;break;default:v?.(C,y);break}}function a(){let C=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,C,{onToken:v=>s("wf:token",{text:v}),onToolCall:v=>s("wf:tool_call",v),onToolProgress:v=>s("wf:tool_progress",v),onToolResult:v=>s("wf:tool_result",v),onApproval:v=>s("wf:approval_request",v),onUsage:v=>s("wf:usage",v),onStep:v=>s("wf:step",v),onDone:v=>s("wf:done",v),onError:v=>s("wf:error",v),onEvent:(v,r)=>s(v,r,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let y=i();y&&o?.traceId&&(y.id=o.traceId)}function u(){if(e.streaming)return;let C=String(e.input??"").trim();C&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:C,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let C=e.messages[e.messages.length-1];C&&C.role==="assistant"&&C.status==="streaming"&&(!C.content&&(!C.toolCalls||C.toolCalls.length===0)?e.messages.pop():C.status="done")}function c(){if(e.streaming)return;let C=-1;for(let y=e.messages.length-1;y>=0;y--)if(e.messages[y].role==="user"){C=y;break}C!==-1&&(e.messages.splice(C+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function m(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function g(C,y){let v=e.messages[e.messages.length-1],r=v?.role==="assistant"?v.approval:void 0;if(r&&(v.approval=void 0,!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify({id:r.id,decision:C,note:y}),signal:t.signal})}catch(d){if(t.signal?.aborted)return;e.error={code:"provider_error",message:d instanceof Error?d.message:String(d)}}}function P(){o?.abort(),o=null}return{send:u,stop:l,retry:c,clear:m,approve:g,dispose:P}}function pe(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function In(e,n="bottom",t=6,o=!0){return pe(e.getBoundingClientRect(),n,t,o)}function me(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let i=Number.parseFloat(n.style.top)||o.top,s=Number.parseFloat(n.style.left)||o.left,a=e.top-i,u=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+u,right:o.right+u},c=window.innerWidth,m=window.innerHeight,g=e.top,P=e.left;return l.bottom>m-t&&(g=Math.max(t,g-(l.bottom-(m-t)))),l.top<t&&(g=Math.max(t,g+(t-l.top))),l.right>c-t&&(P=Math.max(t,P-(l.right-(c-t)))),l.left<t&&(P=Math.max(t,P+(t-l.left))),{top:g,left:P,width:e.width}}var on=new Set,oe=new Map;function rn(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:u,scrollTrackers:l,schedulePopupRecompute:c,ensurePopupListeners:m,isRendering:g,isMounting:P,setMounting:C,endMounting:y}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:C,endMounting:y,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(g()){if(P())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}t(r)},dirty:function(r){if(!P()){if(g()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}for(let d of r)d&&(i.add(d),s.add(d));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let d=[...i];i.clear(),d.length>0&&t(d)}))}},$:function(){let r=this;return r._$cache||(r._$cache=fe(()=>{let d=r._selfVNode?._id??o(r);d&&n.ui.dirty([d])})),r._$cache},useChat:function(r){let d=this.$(),f=tn(d,Me,r);return Object.assign(d,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),d},useMedia:function(r,d){let p=`media:${o(this)}:${r}`;if(!a.has(p)){let h=window.matchMedia(r);d(h.matches);let b=E=>d(E.matches);h.addEventListener("change",b),a.set(p,{mql:h,handler:b})}},useBreakpoint:function(r,d){let f=typeof r=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:r,p=typeof r=="function"?r:d,b=`bp:${o(this)}`;function E(){for(let[x,k]of Object.entries(f))if(window.matchMedia(k).matches)return x;return Object.keys(f)[0]??""}if(!a.has(b)){p(E());let x=[];for(let k of Object.values(f)){let T=window.matchMedia(k),_=()=>p(E());T.addEventListener("change",_),x.push({mql:T,handler:_})}a.set(b,{mqls:x})}},usePopupPosition:function(r){let d=o(this),f={top:0,left:0,refresh:()=>{}};if(!d)return f;let p={pos:f,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return u.set(d,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let b=p.compute(h.getBoundingClientRect());Object.assign(f,me(b,p.panel?.(),p.margin))},f},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,d){return p=>{p?r(p):d?.()}},useVisualViewport:function(){let r=o(this),d={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},f=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},p=()=>{let b=window.visualViewport;d.height=b?.height??window.innerHeight,d.offsetTop=b?.offsetTop??0,d.keyboardOpen=d.height<window.innerHeight*.9,f()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",p),h.addEventListener("scroll",p)):window.addEventListener("resize",p),r&&K(b=>{b===r&&(h?.removeEventListener?(h.removeEventListener("resize",p),h.removeEventListener("scroll",p)):window.removeEventListener("resize",p))}),d},usePopup:function(r){let d=o(this),f=this.useHoverCapable(),p=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,b=()=>!!r.disabled?.(),E=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{b()||(h?r.onOpenChange?.(A):r.setOpen(A))},k=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},T=null,_=!1,w=n.ui.usePopupPosition({el:r.el,isOpen:()=>E(),compute:A=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return pe(A,k(),r.gap??6,r.center!==!1)},panel:()=>T,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!E())return;let W=A.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||T&&T.contains(W)||x(!1)},M=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!E()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",M),d&&K(A=>{A===d&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",M))});let S={},j=A=>typeof A=="function"?A():A??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,I,re=()=>{clearTimeout(L),clearTimeout(I),L=void 0,I=void 0};if(p()==="hover")f?(S.onMouseEnter=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!E()),S.onFocus=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(p()==="click")S.onClick=()=>x(!E());else if(p()==="longpress"){let A,W=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=U=>{b()||(W=U.clientX??0,$=U.clientY??0,F(),A=setTimeout(()=>{A=void 0,r.onTrigger?.({clientX:W,clientY:$}),x(!0)},r.longPressDuration??500))},S.onPointerUp=F,S.onPointerLeave=F,S.onPointerMove=U=>{let he=Math.abs((U.clientX??0)-W),ve=Math.abs((U.clientY??0)-$);(he>10||ve>10)&&F()},S.onContextMenu=U=>{U.preventDefault(),r.onTrigger?.({clientX:U.clientX??0,clientY:U.clientY??0}),x(!0)}}S.onKeyDown=A=>{A.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},d&&K(A=>{A===d&&re()});let dn=A=>{if(A){T=A;let W=()=>w.refresh();A.addEventListener("animationend",W,{once:!0})}else T=null},fn=(A,W="popover")=>{if(b())return null;if(!E())return _=!1,null;_||(w.refresh(),_=!0);let F=A.props??{},U=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},pn={...A,props:{...F,class:he,style:ve,ref:He=>{dn(He),U&&U(He)}}};return be(pn,W)};return{open:E(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>w.refresh()}},useLongPress:function(r){let{onLongPress:d,duration:f=500}=r,p,h=0,b=0,E=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:k=>{h=k.clientX??0,b=k.clientY??0,E=k,x(),p=setTimeout(()=>{p=void 0,d(E)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:k=>{let T=Math.abs((k.clientX??0)-h),_=Math.abs((k.clientY??0)-b);(T>10||_>10)&&x()},onContextMenu:k=>{k.preventDefault(),d(k)}}},useInView:function(r){let d=o(this),f={isIn:!1,ready:!1,observe:x,refresh:k,disconnect:T},p=null,h=null,b=()=>{n.ui&&n.ui.dirty(d?[d]:void 0)};function E(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,w=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let M=R[R.length-1];if(!M)return;let S=M.isIntersecting,j=S!==f.isIn,N=!f.ready;f.isIn=S,f.ready=!0,r.onChange?.(M,S),(j||N)&&b()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:w??0}),h.observe(p)}function x(_){p=_,_?E():(h?.disconnect(),h=null,f.isIn=!1)}function k(){E()}function T(){h?.disconnect(),h=null}return f},useScrollPosition:function(r){let d=o(this),f={y:0,refresh(){let h=p.getScroller();f.y=h instanceof Window?document.scrollingElement?.scrollTop??h.scrollY??0:h.scrollTop??0}},p={handle:f,getScroller:r.getScroller??(()=>window)};return d?(l.set(d,p),m(),f.refresh(),f):(f.refresh(),f)},useAsync:function(r){let d=o(this),f=fe(()=>{n.ui&&n.ui.dirty(d?[d]:void 0)});f.loading=!0;let p=0,h=()=>{let b=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(E=>{p===b&&(f.data=E,f.loading=!1)}).catch(E=>{p===b&&(f.error=E,f.loading=!1)})};return h(),f.reload=h,f},useControlled:function(r){let d=o(this),f=r.value!==void 0;f&&!r.onChange&&r.name&&(on.has(r.name)||(on.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!f&&d&&!oe.has(d)&&(oe.set(d,r.value),K(h=>{oe.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}d&&oe.set(d,h),n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{value:f?r.value:d?oe.get(d):r.value,setValue:p,controlled:f}},usePresence:function(r){let d=o(this),f="closed",p,h=()=>{f="closed",n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{get phase(){return f},ref:E=>{E?p||(p=()=>{f==="exit"&&h()},E.addEventListener("animationend",p)):(E?.removeEventListener("animationend",p),p=void 0)},sync:E=>(E?f="open":f==="open"&&(f="exit"),f)}},useDialog:function(r){let d=o(this),f,p=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(ke(),p&&(f=de(p)),h.ref(x)):(Ne(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=de(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let d=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),d&&K(f=>{f===d&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let d=0,f=0,p=!1,h=x=>{p&&r.onMove(x,{x:x.clientX-d,y:x.clientY-f})},b=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",b),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,d=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",b),r.onStart?.(x))}}},useDragDrop:function(r){let d={};r.onDrop&&(d.onDrop=p=>{p.preventDefault(),r.onDrop(p)}),r.onDragOver&&(d.onDragOver=p=>{p.preventDefault(),r.onDragOver(p)}),r.onDragLeave&&(d.onDragLeave=p=>r.onDragLeave(p));let f={draggable:!0};return r.onDragStart&&(f.onDragStart=p=>r.onDragStart(p)),r.onDragEnd&&(f.onDragEnd=p=>r.onDragEnd(p)),{dropProps:d,dragProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,d){let f=null,p=()=>{r(),d?.once&&f&&f.removeEventListener("animationend",p)};return b=>{b?(f=b,b.addEventListener("animationend",p)):f&&(f.removeEventListener("animationend",p),f=null)}},useTween:function(r,d){let f=o(this),p=this.useReducedMotion(),h=d?.duration??400,b=d?.ease==="linear"?w=>w:w=>1-Math.pow(1-w,3),E,x=r,k={value:p?r:0,reset:()=>{}},T=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=w=>{if(x=w,p){k.value=w,T();return}if(w===k.value)return;E&&cancelAnimationFrame(E);let R=k.value,M=performance.now(),S=j=>{let N=Math.min(1,(j-M)/h);k.value=Math.round(R+(w-R)*b(N)),N<1?(E=requestAnimationFrame(S),T()):(E=void 0,T())};E=requestAnimationFrame(S)};return k.reset=w=>{w===x&&E||_(w)},queueMicrotask(()=>_(r)),k},selfId:function(r){if(typeof r!="string"||!r)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof r}`);if(V.has(r))throw new Error(`[weifuwu] Duplicate component ID: "${r}". Each component must have a unique custom ID.`);let d=this._selfVNode;d&&(d._customId=r,V.set(r,d))}}}function sn(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Dn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,u=[];function l(T){u.push(a),a=T}function c(){a=u.pop()??!1}let m=new Set,g=!1,P=new Map;function C(T){let _=P.get(T);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:w,handler:R})=>w.removeEventListener("change",R)),P.delete(T))}let y=new Map,v=!1,r=0;function d(){v||(v=!0,window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h))}function f(){v&&(window.removeEventListener("scroll",h,{capture:!0}),window.removeEventListener("resize",h),v=!1)}let p=new Map;function h(){r||(r=requestAnimationFrame(()=>{r=0;let T=[];for(let[_,w]of y){if(!w.isOpen())continue;let R=w.getEl();if(!R)continue;let M=w.compute(R.getBoundingClientRect());Object.assign(w.pos,me(M,w.panel?.(),w.margin)),T.push(_)}for(let[_,w]of p){let R=w.getScroller(),M=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;M!==w.handle.y&&(w.handle.y=M,T.push(_))}T.length>0&&n.ui.render(T)}))}function b(T){if(!s){s=!0;for(let _ of T){let w=V.get(_);if(!w||!w._render)continue;n.ui._dirtySet?.delete(_);let R=w._child,M=w._render(w.props);if(w._child=M,R&&R._placement==="remote"||M&&M._placement==="remote"){R&&M?ne(R,M,n):M?G(M,n):R&&O(R);continue}if(!w._parentNode&&w._refNode&&(w._parentNode=w._refNode.parentNode),w._parentNode){let S=z(w._parentNode,w._refNode??null,R,M,n);S&&S!==w._refNode?w._refNode=S:S||(w._refNode=null)}}s=!1,E()}}function E(){let T=n.ui;m.size>0&&!T._dirtyScheduled&&(T._dirtyScheduled=!0,queueMicrotask(()=>{T._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&b(_)}))}function x(T){return T?._selfId??n.ui?._selfId}let k={get ctx(){return n},use(T){return e.push(T),k},async mount(T,_,w){o=_;for(let N of e)n=await N(n);let R=typeof T=="string"?document.querySelector(T):T;if(!R)throw new Error(`mount target not found: ${T}`);t=R;let M=!!w?.hydrate;M||(t.innerHTML="");let S=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))S.set(N,{value:H});if(n.data={async get(N,H){let L=S.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let I=Promise.resolve().then(()=>H()).then(re=>(S.set(N,{value:re}),re));return S.set(N,{promise:I}),I},set(N,H){S.set(N,{value:H})},has(N){return S.has(N)}},K(N=>{for(let H of[...P.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&C(H);y.delete(N),p.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:b,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:P,popupTrackers:y,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:d,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Un(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=M?t.firstChild:null,V.set("_wf_root",i),M)await Re(t,i,n);else{let N=Ge(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,E()},destroy(){f(),y.clear(),p.clear();for(let T of[...P.keys()])C(T);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return k}function Un(e,n){return{type:e,props:{},key:void 0}}function jn(e,n){if(!n||n==="/")return e||"/";let t=e.endsWith("/")?e.slice(0,-1):e,o=n.startsWith("/")?n:"/"+n;return t+o}function qn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Oe(e,n="",t=[]){let o=[];for(let i of e){let s=jn(n,i.path),{re:a,keys:u}=qn(s),l=[...t,i];o.push({re:a,keys:u,def:i,chain:l}),i.children&&o.push(...Oe(i.children,s,l))}return o}function an(e,n){let t=null;for(let o of n)e.match(o.re)&&(!t||o.chain.length>t.chain.length)&&(t=o);return t}function ln(e,n){let t={},o=e.match(n.re);if(o)for(let i=0;i<n.keys.length;i++)t[n.keys[i]]=decodeURIComponent(o[i+1]);return t}function Fn(e){let n=Oe(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=an(s,n);if(a){let u=a.chain[a.chain.length-1];return{path:a.def.path,params:ln(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:u?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let a=i(o());s.route=a,a.title&&(document.title=a.title),s.app||(s.app={}),s.app.navigate=l=>{if(J(),t==="hash"){window.location.hash="#"+l;let c=i(l);s.route=c}else{window.history.pushState({},"",l);let c=i(l);s.route=c}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let u=()=>{J();let l=i(o());s.route=l,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",u),t==="hash"&&window.addEventListener("hashchange",u),s}}function Bn(e,n){let t=n.route?._rvDepth??0;return()=>{let o=n.route;if(!o?.chain?.length||t>=o.chain.length)return null;let i=o.chain[t],s=i.layout??i.component;return s?(i.layout&&(o._rvDepth=t+1),{type:s,props:{},key:void 0}):null}}function Y(e,n){return Object.assign(Object.create(e),n)}function Kn(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,i=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let u=new Set,l=null,c=0,m=null,g=null,P=null,C=!1,y={isConnected:!1,onMessage:p=>(u.add(p),()=>{u.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{C=!0,f(),l?.close(),l=null,y.isConnected=!1}};async function v(){if(!C)try{l=new WebSocket(n),l.onopen=()=>{y.isConnected=!0,c=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let b of u)b(h)}catch{}d()},l.onclose=()=>{y.isConnected=!1,f(),!C&&c<o&&(c++,m=setTimeout(v,t*Math.min(c,5)))},l.onerror=()=>{l?.close()}}catch{C||(m=setTimeout(v,t))}}function r(){i<=0||(g=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),P=setTimeout(()=>{l?.close()},s)},i))}function d(){clearTimeout(P)}function f(){clearInterval(g),clearTimeout(P),clearTimeout(m)}return v(),Y(a,{ws:y})}}function $n(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,i=e?.timeout??0;async function s(a,u,l,c){let m=n.baseURL+u,g={method:a,headers:{...n.headers,...c?.headers}},P=e?.token?.();P&&!g.headers.Authorization&&(g.headers.Authorization=`Bearer ${P}`);let C=i>0,y=!!c?.signal,v=null,r=null;(C||y)&&(v=new AbortController,g.signal=v.signal,C&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),y&&c.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(g.body=JSON.stringify(l));let d={url:m,init:g};t&&(d=t(d));try{let f=await fetch(d.url,d.init);if(o)return o(f);if(!f.ok){let b=await f.text().catch(()=>"");throw new ye(f.status,b||f.statusText)}let p=f.headers.get("content-length");if(f.status===204||p==="0")return;let h=(f.headers.get("content-type")||"").toLowerCase();return h.includes("application/json")||h.includes("json")?f.json():f.text()}finally{r&&clearTimeout(r)}}return a=>Y(a,{api:{get:(l,c)=>s("GET",l,void 0,c),post:(l,c,m)=>s("POST",l,c,m),put:(l,c,m)=>s("PUT",l,c,m),patch:(l,c,m)=>s("PATCH",l,c,m),delete:(l,c)=>s("DELETE",l,void 0,c)}})}var ye=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function zn(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Yn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Gn(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",i=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let u=n.getItem(t),l=n.getItem(o),c={token:u,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,g,P){c.token=m,c.user=g,n.setItem(t,m),n.setItem(o,JSON.stringify(g)),P&&n.setItem(i,P)},logout(){c.token=null,c.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(m){c.user=m,n.setItem(o,JSON.stringify(m))},async refresh(){let m=n.getItem(i);if(!m)return!1;try{let g=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!g.ok)return c.logout(),!1;let P=await g.json();return c.token=P.token,n.setItem(t,P.token),P.refreshToken&&n.setItem(i,P.refreshToken),!0}catch{return!1}}};return u&&Yn(u)&&c.refresh().catch(()=>{}),Y(a,{auth:c})}}function Xn(e,n){let t=null;return o=>{if(t){let s=o.fallback;return typeof s=="function"?s({error:t}):s??null}n.ui._errorHandler=s=>{t=s,n.ui.render()};let i=o.children;try{return i??null}catch(s){t=s;let a=o.fallback;return typeof a=="function"?a({error:s}):a??null}}}var Ve={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var We={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var ge={"zh-CN":Ve,"en-US":We};function un(e){if(ge[e])return e;let n=e.split("-")[0];return Object.keys(ge).find(o=>o.startsWith(n))??"zh-CN"}function Jn(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=un(n),s=ge[i],a=cn(s,t,o),u={locale:i,t:(l,c)=>a.messages?.[l]??c??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=u,u.setLocale=c=>{let m=un(c),g=ge[m];g&&(a=cn(g,t,o),u.locale=m,u.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function cn(e,n,t){return{messages:{...e?.messages,...n},components:Qn(e?.components??{},t)}}function Qn(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}function Zn(e,n,t=400){let o=!1,i=()=>{o||(o=!0,e.removeEventListener("animationend",i),clearTimeout(s),n())};e.addEventListener("animationend",i);let s=setTimeout(i,t)}export{ye as ApiError,Xn as ErrorBoundary,B as Fragment,q as Portal,Bn as RouteView,Me as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Gn as auth,O as callRefCleanup,J as clearAsyncComponentCache,In as computeFixedPos,pe as computeFixedPosRect,Dn as createApp,be as createPortal,fe as createReactiveState,We as enUS,Y as extendCtx,hn as h,Re as hydrateVNode,Jn as i18n,X as isAsyncComponent,we as jsx,gn as jsxDEV,yn as jsxs,ke as lockScroll,Sn as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Ne as unlockScroll,Kn as ws,Ve as zhCN};
|
package/dist/client/types.d.ts
CHANGED
|
@@ -190,6 +190,10 @@ export interface BrowserEnv {
|
|
|
190
190
|
selectionText(): string | null;
|
|
191
191
|
/** 编辑器选区对象(完整 Selection——Editor 需要 range 操作) */
|
|
192
192
|
getSelection(): Selection | null;
|
|
193
|
+
/** 编辑器格式状态查询(document.queryCommandState) */
|
|
194
|
+
queryCommandState(cmd: string): boolean;
|
|
195
|
+
/** 编辑器格式值查询(document.queryCommandValue) */
|
|
196
|
+
queryCommandValue(cmd: string): string;
|
|
193
197
|
/** 视口高度 */
|
|
194
198
|
viewportHeight(): number;
|
|
195
199
|
/** 滚动量(scrollingElement 优先) */
|
|
@@ -309,8 +313,12 @@ export interface WfuiContext {
|
|
|
309
313
|
onDrop?: (e: DragEvent) => void;
|
|
310
314
|
onDragOver?: (e: DragEvent) => void;
|
|
311
315
|
onDragLeave?: (e: DragEvent) => void;
|
|
316
|
+
/** 拖拽源侧:draggable + onDragStart/onDragEnd(返回 dragProps spread 到拖拽源) */
|
|
317
|
+
onDragStart?: (e: DragEvent) => void;
|
|
318
|
+
onDragEnd?: (e: DragEvent) => void;
|
|
312
319
|
}) => {
|
|
313
320
|
dropProps: Record<string, any>;
|
|
321
|
+
dragProps: Record<string, any>;
|
|
314
322
|
};
|
|
315
323
|
/**
|
|
316
324
|
* 可视视口跟踪(visualViewport):键盘弹起/缩放时自动更新 + dirty。
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { Component } from '../../client/vnode.ts';
|
|
2
|
+
export interface DiffViewProps {
|
|
3
|
+
/** 旧代码 */
|
|
4
|
+
oldCode: string;
|
|
5
|
+
/** 新代码 */
|
|
6
|
+
newCode: string;
|
|
7
|
+
/** 旧标题 */
|
|
8
|
+
oldTitle?: string;
|
|
9
|
+
/** 新标题 */
|
|
10
|
+
newTitle?: string;
|
|
11
|
+
/** 连续未变行超过该值折叠为「↕ N 行」(默认 5;0 = 不折叠) */
|
|
12
|
+
foldThreshold?: number;
|
|
13
|
+
/** 最大渲染行数(超出的变化行显示省略提示——防超大 diff 卡顿) */
|
|
14
|
+
maxLines?: number;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* DiffView — AI 代码生成/审查的 diff 展示。
|
|
19
|
+
* 行级 LCS diff(自研纯函数):same/add/remove 三态 + 未变块折叠。
|
|
20
|
+
*
|
|
21
|
+
* 展开状态用闭包 let + render()(手动模式):`$` 深度 Proxy 包装的
|
|
22
|
+
* Set 会破坏 Set.prototype.has 的 this 绑定(内置类型不可 Proxy 方法调用)。
|
|
23
|
+
*/
|
|
24
|
+
export declare const DiffView: Component<DiffViewProps>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type DiffLineType = 'add' | 'remove' | 'same';
|
|
2
|
+
export interface DiffLine {
|
|
3
|
+
type: DiffLineType;
|
|
4
|
+
line: string;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* LCS(最长公共子序列)行级 diff——O(n·m) 动态规划。
|
|
8
|
+
* 返回按原顺序排列的行序列:same(公共行)/ remove(仅旧)/ add(仅新)。
|
|
9
|
+
*
|
|
10
|
+
* 实现:DP 表回溯——公共行保留原顺序,删除行在前、新增行在后(相邻配对,
|
|
11
|
+
* 符合 diff 展示惯例:修改 = 删旧 + 增新)。
|
|
12
|
+
*/
|
|
13
|
+
export declare function diffLines(oldCode: string, newCode: string): DiffLine[];
|
|
14
|
+
/** 将 diff 行分组为渲染块:连续 same 合并为 same 块(组件按 sameCount 决定是否折叠),add/remove 独立成块 */
|
|
15
|
+
export declare function groupDiffLines(lines: DiffLine[]): {
|
|
16
|
+
kind: 'same' | 'change';
|
|
17
|
+
sameCount?: number;
|
|
18
|
+
lines: DiffLine[];
|
|
19
|
+
}[];
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
import type { FormatState, ToolbarItem } from './types.ts';
|
|
5
5
|
/** 查询当前选区格式状态 */
|
|
6
6
|
export declare function queryFormats(): FormatState;
|
|
7
|
-
/** 执行
|
|
7
|
+
/** 执行 execCommand(经 browser 环境抽象) */
|
|
8
8
|
export declare function exec(cmd: string, value?: string): void;
|
|
9
9
|
/** 根据工具项执行格式化 */
|
|
10
10
|
export declare function execFormat(item: ToolbarItem): void;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Component } from '../../client/vnode.ts';
|
|
2
|
+
export interface KanbanItem {
|
|
3
|
+
id: string;
|
|
4
|
+
title: string;
|
|
5
|
+
/** 可选标签色 */
|
|
6
|
+
tag?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface KanbanColumn {
|
|
9
|
+
key: string;
|
|
10
|
+
title: string;
|
|
11
|
+
items: KanbanItem[];
|
|
12
|
+
}
|
|
13
|
+
export interface KanbanMove {
|
|
14
|
+
columnKey: string;
|
|
15
|
+
index: number;
|
|
16
|
+
}
|
|
17
|
+
export interface KanbanProps {
|
|
18
|
+
columns: KanbanColumn[];
|
|
19
|
+
/** 受控:移动回调(from → to)。缺回调交互静默失效——受控纪律 warn */
|
|
20
|
+
onMove?: (from: KanbanMove, to: KanbanMove) => void;
|
|
21
|
+
className?: string;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Kanban — 看板(原生 HTML5 DnD,零依赖)。
|
|
25
|
+
* 卡片拖拽:dragstart 记录源 → 卡片/列 drop 触发 onMove(跨列 + 同列重排)。
|
|
26
|
+
* 受控纪律:columns 受控 prop——无 onMove 时 warn(交互静默失效防护)。
|
|
27
|
+
*/
|
|
28
|
+
export declare const Kanban: Component<KanbanProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { Component } from '../../client/vnode.ts';
|
|
2
|
+
export type NodeStatus = 'default' | 'success' | 'running' | 'error' | 'pending';
|
|
3
|
+
export interface PipelineNode {
|
|
4
|
+
id: string;
|
|
5
|
+
label: string;
|
|
6
|
+
/** 状态着色(默认 default) */
|
|
7
|
+
status?: NodeStatus;
|
|
8
|
+
}
|
|
9
|
+
export interface PipelineEdge {
|
|
10
|
+
from: string;
|
|
11
|
+
to: string;
|
|
12
|
+
}
|
|
13
|
+
export interface PipelineProps {
|
|
14
|
+
nodes: PipelineNode[];
|
|
15
|
+
edges: PipelineEdge[];
|
|
16
|
+
/** 布局方向(默认 vertical:输入在左→输出在右) */
|
|
17
|
+
orientation?: 'vertical' | 'horizontal';
|
|
18
|
+
width?: number;
|
|
19
|
+
height?: number;
|
|
20
|
+
className?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Pipeline/DAG — Agent 多步工作流可视化。
|
|
24
|
+
* 分层布局(Kahn 拓扑最长路径)+ SVG 贝塞尔连线 + 状态语义色。
|
|
25
|
+
* 纯函数布局(dag-utils)可 SSR/单测;环检测 → 渲染警告不崩溃。
|
|
26
|
+
*/
|
|
27
|
+
export declare const Pipeline: Component<PipelineProps>;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export interface DagNodeInput {
|
|
2
|
+
id: string;
|
|
3
|
+
}
|
|
4
|
+
export interface DagEdgeInput {
|
|
5
|
+
from: string;
|
|
6
|
+
to: string;
|
|
7
|
+
}
|
|
8
|
+
export interface LayoutNode {
|
|
9
|
+
id: string;
|
|
10
|
+
x: number;
|
|
11
|
+
y: number;
|
|
12
|
+
}
|
|
13
|
+
export interface LayoutEdge {
|
|
14
|
+
from: string;
|
|
15
|
+
to: string;
|
|
16
|
+
d: string;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* 分层:每个节点层 = 最长入链深度(BFS/DP)。
|
|
20
|
+
* 无入边节点 → 0;菱形依赖取最长路径。
|
|
21
|
+
*/
|
|
22
|
+
export declare function computeLayers(nodes: DagNodeInput[], edges: DagEdgeInput[]): Map<string, number>;
|
|
23
|
+
/** 环检测:Kahn 拓扑——有环时访问节点数 < 总节点数 */
|
|
24
|
+
export declare function detectCycle(nodes: DagNodeInput[], edges: DagEdgeInput[]): boolean;
|
|
25
|
+
export interface GraphLayoutOptions {
|
|
26
|
+
orientation: 'vertical' | 'horizontal';
|
|
27
|
+
width: number;
|
|
28
|
+
height: number;
|
|
29
|
+
nodeW?: number;
|
|
30
|
+
nodeH?: number;
|
|
31
|
+
}
|
|
32
|
+
/** 布局:分层 → 层列分布 + 层内均匀;边 = 贝塞尔 path */
|
|
33
|
+
export declare function layoutGraph(nodes: DagNodeInput[], edges: DagEdgeInput[], opts: GraphLayoutOptions): {
|
|
34
|
+
nodes: LayoutNode[];
|
|
35
|
+
edges: LayoutEdge[];
|
|
36
|
+
};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Component } from '../../client/vnode.ts';
|
|
2
|
+
export interface SparklineProps {
|
|
3
|
+
/** 数据序列 */
|
|
4
|
+
data: number[];
|
|
5
|
+
/** SVG 宽(默认 120) */
|
|
6
|
+
width?: number;
|
|
7
|
+
/** SVG 高(默认 32) */
|
|
8
|
+
height?: number;
|
|
9
|
+
/** 描边色(默认语义 primary,随 currentColor 可继承) */
|
|
10
|
+
stroke?: string;
|
|
11
|
+
/** 面积填充(默认关) */
|
|
12
|
+
fill?: boolean;
|
|
13
|
+
/** 平滑曲线(Catmull-Rom)——默认折线 */
|
|
14
|
+
smooth?: boolean;
|
|
15
|
+
className?: string;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Sparkline — 迷你趋势线(SVG 自绘,零依赖)。
|
|
19
|
+
* 归一化到 viewBox,等值/单点/空数据安全。
|
|
20
|
+
*/
|
|
21
|
+
export declare const Sparkline: Component<SparklineProps>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export interface SparklinePoint {
|
|
2
|
+
x: number;
|
|
3
|
+
y: number;
|
|
4
|
+
}
|
|
5
|
+
/**
|
|
6
|
+
* 将数据点归一化到 [padding, width-padding] × [padding, height-padding]。
|
|
7
|
+
* - min → 底部(y=height-padding),max → 顶部(y=padding)
|
|
8
|
+
* - 单点:居中(x 中点,y 垂直居中)
|
|
9
|
+
* - 等值:全部垂直居中(除零防护)
|
|
10
|
+
* - 空:空数组
|
|
11
|
+
*/
|
|
12
|
+
export declare function computeSparklinePoints(data: number[], width: number, height: number, padding?: number): SparklinePoint[];
|
|
13
|
+
/** 折线 points 字符串 */
|
|
14
|
+
export declare function polylinePoints(pts: SparklinePoint[]): string;
|
|
15
|
+
/** 平滑 path(Catmull-Rom → cubic Bézier)——描边 + 可选面积 */
|
|
16
|
+
export declare function smoothPath(pts: SparklinePoint[]): string;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import type { Component } from '../../client/vnode.ts';
|
|
2
|
+
export type TourPlacement = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
+
export interface TourStep {
|
|
4
|
+
/** 目标元素选择器(ctx.browser.query) */
|
|
5
|
+
target: string;
|
|
6
|
+
title: string;
|
|
7
|
+
content: string;
|
|
8
|
+
/** 气泡相对目标的位置(默认 bottom) */
|
|
9
|
+
placement?: TourPlacement;
|
|
10
|
+
}
|
|
11
|
+
export interface TourProps {
|
|
12
|
+
steps: TourStep[];
|
|
13
|
+
/** 受控:是否打开 */
|
|
14
|
+
open?: boolean;
|
|
15
|
+
/** 受控回调(关闭时 onChange(false)) */
|
|
16
|
+
onChange?: (open: boolean) => void;
|
|
17
|
+
/** 受控:当前步骤索引 */
|
|
18
|
+
current?: number;
|
|
19
|
+
/** 步骤变化回调 */
|
|
20
|
+
onStepChange?: (step: number) => void;
|
|
21
|
+
/** 完成/跳过回调 */
|
|
22
|
+
onFinish?: () => void;
|
|
23
|
+
/** 遮罩(默认 true) */
|
|
24
|
+
mask?: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Tour — 新手引导(步骤式)。
|
|
28
|
+
* 目标 rect 定位(usePopupPosition 跟随 scroll/resize)+ Portal 遮罩 + 步骤气泡。
|
|
29
|
+
*
|
|
30
|
+
* 状态纪律:
|
|
31
|
+
* - 步骤索引闭包 let + render()(手动模式——避免 $ 内置类型问题)
|
|
32
|
+
* - open 受控(props.open + onChange)
|
|
33
|
+
*/
|
|
34
|
+
export declare const Tour: Component<TourProps>;
|
|
@@ -16,6 +16,8 @@ export interface TreeProps {
|
|
|
16
16
|
onExpand?: (keys: string[]) => void;
|
|
17
17
|
/** 勾选模式(父子联动,antd 非 strict 语义) */
|
|
18
18
|
checkable?: boolean;
|
|
19
|
+
/** 点击有子节点的行 = 展开/折叠(不触发选中)——TreeSelect 场景(点行展开比点箭头直观) */
|
|
20
|
+
expandOnClick?: boolean;
|
|
19
21
|
checkedKeys?: string[];
|
|
20
22
|
onCheck?: (keys: string[]) => void;
|
|
21
23
|
className?: string;
|