weifuwu 0.67.3 → 0.69.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +6 -6
- package/dist/client/index.js +5 -4
- package/dist/client/types.d.ts +28 -0
- package/dist/components/AlertGroup/AlertGroup.d.ts +23 -0
- package/dist/components/AutoComplete/AutoComplete.d.ts +37 -0
- package/dist/components/FloatButton/FloatButton.d.ts +34 -0
- package/dist/components/Grid/Grid.d.ts +34 -0
- package/dist/components/Layout/Layout.d.ts +58 -0
- package/dist/components/Link/Link.d.ts +22 -0
- package/dist/components/NavMenu/NavMenu.d.ts +27 -0
- package/dist/components/Popconfirm/Popconfirm.d.ts +34 -0
- package/dist/components/Scrollbar/Scrollbar.d.ts +21 -0
- package/dist/components/Space/Space.d.ts +16 -0
- package/dist/components/StatCard/StatCard.d.ts +4 -0
- package/dist/components/index.d.ts +20 -0
- package/dist/components/index.js +14 -16
- package/dist/components/style.css +709 -92
- package/dist/index.js +22 -0
- package/dist/layout/weifuwu-layout.css +27 -2
- package/docs/compat-three-library.md +290 -0
- package/docs/components-map.md +22 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -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` | 113 个 HTML 原语组件(表单/表格/弹层/AiChat…),引用 `--wf-*` 主题变量 |
|
|
28
28
|
| 样式 | `weifuwu/layout` | 70 布局原语 + 141 主题 Token,零自定义 CSS 文件 |
|
|
29
29
|
| SaaS 地基 | 随包内置 | rateLimit / email / userSystem / messager / queue / ai → `ctx.*` 一行接入 |
|
|
30
30
|
|
|
@@ -305,7 +305,7 @@ cd apps/agent-platform && npm run seed && npm run dev
|
|
|
305
305
|
|------|---------|------|
|
|
306
306
|
| `weifuwu/client` | `https://unpkg.com/weifuwu@latest/dist/client/index.js` | 客户端核心(createApp, h, 路由, 状态管理等) |
|
|
307
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 +
|
|
308
|
+
| `weifuwu/components` | `https://unpkg.com/weifuwu@latest/dist/components/style.css` | 组件 CSS + 164 个主题 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` | **113 个组件** | Button/Table/Modal/Confirm/Toast/... + `confirm()` / `toast()` 命令式中间件 | weifuwu/client |
|
|
350
|
+
| `weifuwu/layout` | **CSS 布局** | 70 个布局原语 + 164 个主题 Token(也支持 `weifuwu/layout/style.css`) | — |
|
|
351
351
|
|
|
352
352
|
---
|
|
353
353
|
|
|
@@ -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) | 组件库(113 个组件 + 使用示例 + 组件列表) |
|
|
494
|
+
| [docs/layout.md](docs/layout.md) | 布局系统:70 个布局原语 + 164 个主题 Token |
|
|
495
495
|
| [docs/styling.md](docs/styling.md) | 样式定制指南:零自定义 CSS 模式 / 暗色 / 组件级覆盖 / 作用域主题 |
|
|
496
496
|
|
|
497
497
|
### 通用
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
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 u=D(o,i);return u==null?null:(n&&n.parentNode?n.parentNode.insertBefore(u,n):e.appendChild(u),u)}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 u=D(o,i);return u==null?null:(n?.parentNode&&n.parentNode.replaceChild(u,n),u)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let c=o,l=t;if(typeof c.type=="function"){let u=c.type;l._render&&(c._render=l._render,c._id=l._id,c._id&&V.set(c._id,c)),c._parentNode=e,c._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=c._id,m.ui._selfVNode=c,c._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Tn(l.props,c.props)&&!m.ui._dirtySet?.has(l._id)&&c._ctxVersion===m.ui._ctxVersion)return c._child=l._child,n;m.ui._dirtySet?.delete(l._id);let y;try{typeof c._render=="function"?y=c._render(c.props):y=Ee(u,c.props,c,m)}catch(g){let v=i.ui?._errorHandler;v?(v(g),y=null):(console.error(`[weifuwu] Component render error in <${u?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,g),y=null)}let T=l._child;c._child=y;let b=z(e,n,T,y,m);return b||(c._refNode=null),b}if(c.type===B){let u=l._childNodes,m=$e(e,l,c,i,u);return c._childNodes=m,n}if(typeof c.type=="string"){if(n&&n.nodeType===1){let u=l.props?.ref,m=c.props?.ref;u!==m&&(typeof m=="function"&&m(n),typeof u=="function"&&typeof m=="function"&&bn(n)),Te(n,l.props,c.props),$e(n,l,c,i)}else if(n){O(t);let u=D(o,i);return u==null?null:(n.parentNode?.replaceChild(u,n),u)}return n}if(c.type===q)return ne(l,c,i),null;if(Array.isArray(o)){let u=Array.isArray(t)?t:[];ae(u,o);let m=Array.from(e.childNodes),y=n?m.indexOf(n):-1,T=y>=0?Z(m.slice(y),u):Z(m,u);return le(e,u,o,i,T,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 c=n?.[a],l=t?.[a];if(a==="innerHTML")l!==c&&(e.innerHTML=String(l??""));else if(l!==c)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 u=e.style;for(let m of Object.keys(l)){let y=l[m];y!=null&&(u[m]=typeof y=="number"?y+"px":String(y))}}else if(a.startsWith("on")&&typeof l=="function"){let u=a.slice(2).toLowerCase();typeof c=="function"&&e.removeEventListener(u,c),e.addEventListener(u,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 c=i??Array.from(e.childNodes),l=Z(c,s),u=le(e,s,a,o,l,i?.[0]??null),m=[];for(let y of u)y&&y.length>0&&m.push(...y);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(g=>g&&typeof g=="object"&&g.key!==void 0)){let g=Math.max(n.length,t.length);for(let v=0;v<g;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 g=0;g<n.length;g++){let v=n[g];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[g]??[])r.remove()}let c=new Map,l=0;for(let g=0;g<n.length;g++){let v=xe(n[g]);v!==void 0&&c.set(v,{vnode:n[g],nodes:i[g]??[],index:l++})}let u=t.map(g=>xe(g)),m=new Set(u);for(let g of[...c.keys()])if(!m.has(g)){let v=c.get(g);O(v.vnode);for(let r of v.nodes)r?.remove();c.delete(g)}let y=new Array(t.length).fill(null),T=-1,b=s&&s.parentNode===e?s:e.firstChild;for(let g=0;g<t.length;g++){let v=u[g],r=t[g],d=v!==void 0?c.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(d)if(d.nodes.length>0){if(d.index<T)for(let h of d.nodes)e.insertBefore(h,b);T=Math.max(T,d.index),z(e,d.nodes[0],d.vnode,r,o),y[g]=r._childNodes??d.nodes.filter(h=>h.parentNode===e),b=y[g][y[g].length-1]?.nextSibling??null}else if(f)ne(d.vnode,r,o),y[g]=[];else{let p=z(e,null,d.vnode,r,o);y[g]=ze(p);for(let w of y[g])e.insertBefore(w,b);b=y[g][y[g].length-1]?.nextSibling??null}else if(f)Y(r,o),y[g]=[];else{let p=D(r,o);y[g]=ze(p);for(let w of y[g])e.insertBefore(w,b);b=y[g][y[g].length-1]?.nextSibling??null}}return y}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 Ye(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 Y(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),c=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of c){let u=D(l,n);u!=null&&a.appendChild(u)}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,c]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ge(i,a,c);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ge(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Se(t.props?.children);for(let c of a){let l=D(c,n);if(l!=null&&(i.appendChild(l),c&&typeof c=="object"&&typeof c.type=="function")){let u=c;u._parentNode||(u._parentNode=i,u._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(c){let l=o.ui?._errorHandler;l?(l(c),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,c),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 Sn(){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 Y(e,n){let t=Sn(),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){Y(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 Se(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 Ge(e,n,t){if(n!=="ref")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 An(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 Ae(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),Ae(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 c=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==c&&(t.node.textContent=c),Ae(t),t.node;let l=document.createTextNode(c);return Rn(t,l),l}if(Array.isArray(e)){let c=null;for(let l of e){let u=await te(l,n,t);u!=null&&!c&&(c=u)}return c}let o=e;if(o.type===q||o.type===B){let c=o.props?.children,l=c==null?[]:Array.isArray(c)?c:[c],u=null;for(let m of l){let y=await te(m,n,t);y!=null&&!u&&(u=y)}return u}if(typeof o.type=="function")return Mn(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,Ae(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 c={parent:a,node:a.firstChild},l=Se(s.children);for(let u of l){let m=await te(u,n,c);if(m!=null&&m.parentNode!==a&&a.appendChild(m),u&&typeof u=="object"&&typeof u.type=="function"){let y=u;y._parentNode||(y._parentNode=a,y._refNode=m)}}for(;c.node;){let u=c.node;c.node=u.nextSibling,u.parentNode?.removeChild(u)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Mn(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 c;X(i)?c=await Ue(i,o):c=i;let l=c(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(c){let l=n.ui?._errorHandler;l?(l(c),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,c),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 Me(){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 Nn='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(Nn);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(s instanceof Set||s instanceof Map){if(n.has(s))return n.get(s);let c=s instanceof Set?new Set(["add","delete","clear"]):new Set(["set","delete","clear"]),l=new Proxy(s,{get(u,m){let y=Reflect.get(u,m);return typeof y=="function"?c.has(String(m))?(...T)=>{let b=y.apply(u,T);e();for(let g of t)g();return b}:y.bind(u):y},set(u,m,y){Reflect.set(u,m,y),e();for(let T of t)T();return!0}});return n.set(s,l),l}if(s instanceof Date||s instanceof RegExp)return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(c,l,u){if(Reflect.get(c,l)===u)return!0;Reflect.set(c,l,u),e();for(let y of t)y();return!0},get(c,l){let u=Reflect.get(c,l);return typeof u=="object"&&u!==null?o(u):u},deleteProperty(c,l){if(Reflect.has(c,l)){Reflect.deleteProperty(c,l),e();for(let u of t)u()}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 Ne(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,c=[],l=(async()=>{let u;try{u=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(!u.ok){t?.onError?.({code:Wn(u.status),message:`HTTP ${u.status} ${u.statusText}`});return}try{for await(let{name:m,data:y}of On(u.body)){if(o.signal.aborted)return;Vn(c,{name:m,data:y},a),Ln(m,y,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:c}}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 Fe="__wfAsyncComponent";function xn(e){let n=e;return n[Fe]=!0,n}function J(e){return typeof e=="function"&&e?.[Fe]===!0}var K=Symbol("Fragment"),F=Symbol("Portal");function Pe(e,n,t){return{type:e,props:Be(n),key:t??void 0}}var Tn=Pe;function En(e,n,t){return Pe(e,n,t)}function Pn(e,n,...t){let o=Be(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function Be(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function Se(e,n){return{type:F,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var Sn=0,W=new Map,ae=[];function B(e){ae.push(e)}var le=new WeakMap;function Q(){le=new WeakMap}function _e(e,n){let t=le.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}),le.set(e,o),o}async function Ke(e,n){return _e(e,n).promise}function $e(e){return le.get(e)?.resolved}function _n(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&V(t);else typeof n=="object"&&V(n)}function V(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),ae.length>0){for(let t of ae)t(n._id);if(n._customId)for(let t of ae)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"&&V(t);else V(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"&&V(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(_n(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Z(){return`_wf_${Sn++}`}var ze=new WeakMap;function An(e){let n=ze.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 })")),ze.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?(V(t),n.remove()):V(t),null;let s=Ye(t),a=Ye(o);if(s!==a){V(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 d=o,l=t;if(typeof d.type=="function"){let c=d.type;l._render&&(d._render=l._render,d._id=l._id,d._id&&W.set(d._id,d)),d._parentNode=e,d._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=d._id,m.ui._selfVNode=d,d._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Mn(l.props,d.props)&&!m.ui._dirtySet?.has(l._id)&&d._ctxVersion===m.ui._ctxVersion)return d._child=l._child,n;m.ui._dirtySet?.delete(l._id);let y;try{typeof d._render=="function"?y=d._render(d.props):y=Re(c,d.props,d,m)}catch(g){let v=i.ui?._errorHandler;v?(v(g),y=null):(console.error(`[weifuwu] Component render error in <${c?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,g),y=null)}let P=l._child;d._child=y;let C=z(e,n,P,y,m);return C||(d._refNode=null),C}if(d.type===K){let c=l._childNodes,m=Je(e,l,d,i,c);return d._childNodes=m,n}if(typeof d.type=="string"){if(n&&n.nodeType===1){let c=l.props?.ref,m=d.props?.ref;c!==m&&(typeof m=="function"&&m(n),typeof c=="function"&&typeof m=="function"&&An(n)),ke(n,l.props,d.props),Je(n,l,d,i)}else if(n){V(t);let c=U(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(d.type===F)return te(l,d,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];ue(c,o);let m=Array.from(e.childNodes),y=n?m.indexOf(n):-1,P=y>=0?ee(m.slice(y),c):ee(m,c);return ce(e,c,o,i,P,n),n}return n}var Ge=new Map;function kn(e){let n=Ge.get(e);return n||(n=`fn:${e.name||"anon"}`,Ge.set(e,n)),n}function Ye(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"?kn(n.type):n.type===K?"fragment":n.type===F?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function ke(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 d=n?.[a],l=t?.[a];if(a==="innerHTML")l!==d&&(e.innerHTML=String(l??""));else if(l!==d)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Xe(l)):e.className=Xe(l);else if(a==="style"&&typeof l=="object"){let c=e.style;for(let m of Object.keys(l)){let y=l[m];y==null?c[m]="":c[m]=typeof y=="number"?y+"px":String(y)}}else if(a.startsWith("on")&&typeof l=="function"){let c=a.slice(2).toLowerCase();typeof d=="function"&&e.removeEventListener(c,d),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 Xe(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 Ae(e){if(!(e==null||typeof e!="object"))return e.key}function ue(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 ee(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===F){t.push(null);continue}if(s.type===K){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 Je(e,n,t,o,i){let s=ne(n.props?.children),a=ne(t.props?.children);ue(s,a);let d=i??Array.from(e.childNodes),l=ee(d,s),c=ce(e,s,a,o,l,i?.[0]??null),m=[];for(let y of c)y&&y.length>0&&m.push(...y);return m}function ne(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 Qe(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function ce(e,n,t,o,i=[],s=null){if(!t.some(g=>g&&typeof g=="object"&&g.key!==void 0&&g._placement!=="remote")){let g=Math.max(n.length,t.length);for(let v=0;v<g;v++){let r=v<n.length?n[v]:null,u=v<t.length?t[v]:null;if(u==null){if(r!=null){V(r);for(let f of i[v]??[])f.remove()}}else if(r==null){let f=U(u,o);f!=null&&e.appendChild(f)}else{let f=i[v]?.[0]??null;z(e,f,r,u,o)}}return[]}for(let g=0;g<n.length;g++){let v=n[g];if(!(v==null||typeof v=="boolean")&&Ae(v)===void 0)for(let r of i[g]??[])r.remove()}let d=new Map,l=0;for(let g=0;g<n.length;g++){let v=Ae(n[g]);v!==void 0&&d.set(v,{vnode:n[g],nodes:i[g]??[],index:l++})}let c=t.map(g=>Ae(g)),m=new Set(c);for(let g of[...d.keys()])if(!m.has(g)){let v=d.get(g);V(v.vnode);for(let r of v.nodes)r?.remove();d.delete(g)}let y=new Array(t.length).fill(null),P=-1,C=s&&s.parentNode===e?s:e.firstChild;for(let g=0;g<t.length;g++){let v=c[g],r=t[g],u=v!==void 0?d.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(u)if(u.nodes.length>0){if(u.index<P)for(let h of u.nodes)e.insertBefore(h,C);P=Math.max(P,u.index),z(e,u.nodes[0],u.vnode,r,o),y[g]=r._childNodes??u.nodes.filter(h=>h.parentNode===e),C=y[g][y[g].length-1]?.nextSibling??null}else if(f)te(u.vnode,r,o),y[g]=[];else{let p=z(e,null,u.vnode,r,o);y[g]=Qe(p);for(let w of y[g])e.insertBefore(w,C);C=y[g][y[g].length-1]?.nextSibling??null}else if(f)Y(r,o),y[g]=[];else{let p=U(r,o);y[g]=Qe(p);for(let w of y[g])e.insertBefore(w,C);C=y[g][y[g].length-1]?.nextSibling??null}}return y}function Rn(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 Mn(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(!Rn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Me="http://www.w3.org/2000/svg",Ne=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function en(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 On(e,n);let t=e;if(t.type===F)return Y(t,n),null;if(t.type===K){let a=document.createDocumentFragment(),d=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of d){let c=U(l,n);c!=null&&a.appendChild(c)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Ln(t.type,t.props,t,n);let o=t.type,i=Ne.has(o)?document.createElementNS(Me,o):document.createElement(o);t.el=i;let s;for(let[a,d]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ze(i,a,d);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ze(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Le(t.props?.children);for(let d of a){let l=U(d,n);if(l!=null&&(i.appendChild(l),d&&typeof d=="object"&&typeof d.type=="function")){let c=d;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 Nn(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Re(e,n,t,o){let i;if(J(e)){if(i=$e(e),!i)return _e(e,o).promise.then(()=>Nn(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 Ln(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Z(),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=Re(e,n,t,i)}catch(d){let l=o.ui?._errorHandler;l?(l(d),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,d),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 On(e,n){let t=document.createDocumentFragment();for(let o of e){let i=U(o,n);i!=null&&t.appendChild(i)}return t}function Vn(){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 Y(e,n){let t=Vn(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ne(e.props?.children);e._child=i;for(let s of i){let a=U(s,n);a!=null&&o.appendChild(a)}}function te(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){Y(n,t);return}let i=ne(n.props?.children),s=e._child||[];n._child=i,ue(s,i);let a=ee(Array.from(o.childNodes),s);ce(o,s,i,t,a,a[0]?.[0]??null)}function Le(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,n,t){if(n!=="ref")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 Wn(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 Oe(e){e.node=e.node?e.node.nextSibling:null}function Hn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function In(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Oe(e)):e.parent.appendChild(n)}async function oe(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let d=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==d&&(t.node.textContent=d),Oe(t),t.node;let l=document.createTextNode(d);return Hn(t,l),l}if(Array.isArray(e)){let d=null;for(let l of e){let c=await oe(l,n,t);c!=null&&!d&&(d=c)}return d}let o=e;if(o.type===F||o.type===K){let d=o.props?.children,l=d==null?[]:Array.isArray(d)?d:[d],c=null;for(let m of l){let y=await oe(m,n,t);y!=null&&!c&&(c=y)}return c}if(typeof o.type=="function")return Dn(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,Oe(t)):(a=Ne.has(i)?document.createElementNS(Me,i):document.createElement(i),In(t,a)),o.el=a,ke(a,null,s),!("innerHTML"in s)){let d={parent:a,node:a.firstChild},l=Le(s.children);for(let c of l){let m=await oe(c,n,d);if(m!=null&&m.parentNode!==a&&a.appendChild(m),c&&typeof c=="object"&&typeof c.type=="function"){let y=c;y._parentNode||(y._parentNode=a,y._refNode=m)}}for(;d.node;){let c=d.node;d.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 Dn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Z(),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 d;J(i)?d=await Ke(i,o):d=i;let l=d(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(d){let l=n.ui?._errorHandler;l?(l(d),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,d),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await oe(s,o,t);return e._refNode||(e._refNode=a),a}async function Ve(e,n,t){let o={parent:e,node:e.firstChild};for(await oe(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var de=0,nn="",tn="",on="",rn="",fe=0;function sn(){return typeof window<"u"&&typeof document<"u"}function We(){if(de++,de>1||!sn())return;fe=window.scrollY;let e=document.body;nn=e.style.overflow,tn=e.style.position,on=e.style.top,rn=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=`-${fe}px`,e.style.width="100%")}function He(){if(de--,de>0||!sn())return;let e=document.body;e.style.overflow=nn,e.style.position=tn,e.style.top=on,e.style.width=rn,fe>0&&window.scrollTo(0,fe)}var Un='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function pe(e){let n=e.querySelectorAll(Un);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 me(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(s instanceof Set||s instanceof Map){if(n.has(s))return n.get(s);let d=s instanceof Set?new Set(["add","delete","clear"]):new Set(["set","delete","clear"]),l=new Proxy(s,{get(c,m){let y=Reflect.get(c,m);return typeof y=="function"?d.has(String(m))?(...P)=>{let C=y.apply(c,P);e();for(let g of t)g();return C}:y.bind(c):y},set(c,m,y){Reflect.set(c,m,y),e();for(let P of t)P();return!0}});return n.set(s,l),l}if(s instanceof Date||s instanceof RegExp)return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(d,l,c){if(Reflect.get(d,l)===c)return!0;Reflect.set(d,l,c),e();for(let y of t)y();return!0},get(d,l){let c=Reflect.get(d,l);return typeof c=="object"&&c!==null?o(c):c},deleteProperty(d,l){if(Reflect.has(d,l)){Reflect.deleteProperty(d,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 Ie(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??Kn(),a=t?.record!==!1,d=[],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:Bn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:m,data:y}of qn(c.body)){if(o.signal.aborted)return;Fn(d,{name:m,data:y},a),jn(m,y,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:d}}function jn(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*qn(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
|
|
4
|
-
`))m.startsWith("event: ")?l=m.slice(7):m.startsWith("data: ")&&(u+=m.slice(6));if(u)try{yield{name:l,data:JSON.parse(u)}}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 b=e.messages[e.messages.length-1];return b&&b.role==="assistant"&&b.status==="streaming"?b:void 0}function s(b,g,v){let r=i();switch(b){case"wf:token":r&&(r.content+=g.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let d=g,f=r?.toolCalls?.find(p=>p.call.id===d.toolCallId);f&&(f.progress=d);break}case"wf:tool_result":{let d=g,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=g);break;case"wf:usage":r&&(r.usage=g);break;case"wf:step":e.step=g;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=g,r.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:v?.(b,g);break}}function a(){let b=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,b,{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 g=i();g&&o?.traceId&&(g.id=o.traceId)}function c(){if(e.streaming)return;let b=String(e.input??"").trim();b&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:b,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let b=e.messages[e.messages.length-1];b&&b.role==="assistant"&&b.status==="streaming"&&(!b.content&&(!b.toolCalls||b.toolCalls.length===0)?e.messages.pop():b.status="done")}function u(){if(e.streaming)return;let b=-1;for(let g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){b=g;break}b!==-1&&(e.messages.splice(b+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 y(b,g){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:b,note:g}),signal:t.signal})}catch(d){if(t.signal?.aborted)return;e.error={code:"provider_error",message:d instanceof Error?d.message:String(d)}}}function T(){o?.abort(),o=null}return{send:c,stop:l,retry:u,clear:m,approve:y,dispose:T}}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,c=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+c,right:o.right+c},u=window.innerWidth,m=window.innerHeight,y=e.top,T=e.left;return l.bottom>m-t&&(y=Math.max(t,y-(l.bottom-(m-t)))),l.top<t&&(y=Math.max(t,y+(t-l.top))),l.right>u-t&&(T=Math.max(t,T-(l.right-(u-t)))),l.left<t&&(T=Math.max(t,T+(t-l.left))),{top:y,left:T,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:c,scrollTrackers:l,schedulePopupRecompute:u,ensurePopupListeners:m,isRendering:y,isMounting:T,setMounting:b,endMounting:g}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:b,endMounting:g,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(y()){if(T())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(!T()){if(y()){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,Ne,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 w=P=>d(P.matches);h.addEventListener("change",w),a.set(p,{mql:h,handler:w})}},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,w=`bp:${o(this)}`;function P(){for(let[x,M]of Object.entries(f))if(window.matchMedia(M).matches)return x;return Object.keys(f)[0]??""}if(!a.has(w)){p(P());let x=[];for(let M of Object.values(f)){let E=window.matchMedia(M),_=()=>p(P());E.addEventListener("change",_),x.push({mql:E,handler:_})}a.set(w,{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 c.set(d,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let w=h.getBoundingClientRect();if(w.width===0&&w.height===0)return;let P=p.compute(w);Object.assign(f,me(P,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 w=window.visualViewport;d.height=w?.height??window.innerHeight,d.offsetTop=w?.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(w=>{w===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,w=()=>!!r.disabled?.(),P=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{w()||(h?r.onOpenChange?.(A):r.setOpen(A))},M=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},E=null,_=!1,C=n.ui.usePopupPosition({el:r.el,isOpen:()=>P(),compute:A=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return pe(A,M(),r.gap??6,r.center!==!1)},panel:()=>E,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!P())return;let W=A.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||E&&E.contains(W)||x(!1)},k=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!P()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",k),d&&K(A=>{A===d&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",k))});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=()=>{w()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{w()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!P()),S.onFocus=()=>{w()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{w()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(p()==="click")S.onClick=()=>x(!P());else if(p()==="longpress"){let A,W=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=U=>{w()||(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){E=A;let W=()=>C.refresh();A.addEventListener("animationend",W,{once:!0})}else E=null},fn=(A,W="popover")=>{if(w())return null;if(!P())return _=!1,null;_||(C.refresh(),_=!0);let F=A.props??{},U=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${C.top}px`,left:`${C.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:P(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>C.refresh()}},useLongPress:function(r){let{onLongPress:d,duration:f=500}=r,p,h=0,w=0,P=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:M=>{h=M.clientX??0,w=M.clientY??0,P=M,x(),p=setTimeout(()=>{p=void 0,d(P)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:M=>{let E=Math.abs((M.clientX??0)-h),_=Math.abs((M.clientY??0)-w);(E>10||_>10)&&x()},onContextMenu:M=>{M.preventDefault(),d(M)}}},useInView:function(r){let d=o(this),f={isIn:!1,ready:!1,observe:x,refresh:M,disconnect:E},p=null,h=null,w=()=>{n.ui&&n.ui.dirty(d?[d]:void 0)};function P(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,C=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let k=R[R.length-1];if(!k)return;let S=k.isIntersecting,j=S!==f.isIn,N=!f.ready;f.isIn=S,f.ready=!0,r.onChange?.(k,S),(j||N)&&w()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:C??0}),h.observe(p)}function x(_){p=_,_?P():(h?.disconnect(),h=null,f.isIn=!1)}function M(){P()}function E(){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 w=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(P=>{p===w&&(f.data=P,f.loading=!1)}).catch(P=>{p===w&&(f.error=P,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:P=>{P?p||(p=()=>{f==="exit"&&h()},P.addEventListener("animationend",p)):(P?.removeEventListener("animationend",p),p=void 0)},sync:P=>(P?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)):(Me(),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})},w=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",w),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,d=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",w),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};if(r.onDragStart){let p=r.onDragStart;f.onDragStart=h=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),p(h)}}if(r.onDragEnd){let p=r.onDragEnd;f.onDragEnd=h=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),p(h)}}return{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 w=>{w?(f=w,w.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,w=d?.ease==="linear"?C=>C:C=>1-Math.pow(1-C,3),P,x=r,M={value:p?r:0,reset:()=>{}},E=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=C=>{if(x=C,p){M.value=C,E();return}if(C===M.value)return;P&&cancelAnimationFrame(P);let R=M.value,k=performance.now(),S=j=>{let N=Math.min(1,(j-k)/h);M.value=Math.round(R+(C-R)*w(N)),N<1?(P=requestAnimationFrame(S),E()):(P=void 0,E())};P=requestAnimationFrame(S)};return M.reset=C=>{C===x&&P||_(C)},queueMicrotask(()=>_(r)),M},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,c=[];function l(E){c.push(a),a=E}function u(){a=c.pop()??!1}let m=new Set,y=!1,T=new Map;function b(E){let _=T.get(E);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:C,handler:R})=>C.removeEventListener("change",R)),T.delete(E))}let g=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 E=[];for(let[_,C]of g){if(!C.isOpen())continue;let R=C.getEl();if(!R)continue;let k=R.getBoundingClientRect();if(k.width===0&&k.height===0)continue;let S=C.compute(k);Object.assign(C.pos,me(S,C.panel?.(),C.margin)),E.push(_)}for(let[_,C]of p){let R=C.getScroller(),k=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;k!==C.handle.y&&(C.handle.y=k,E.push(_))}E.length>0&&n.ui.render(E)}))}function w(E){if(!s){s=!0;for(let _ of E){let C=V.get(_);if(!C||!C._render)continue;n.ui._dirtySet?.delete(_);let R=C._child,k=C._render(C.props);if(C._child=k,R&&R._placement==="remote"||k&&k._placement==="remote"){R&&k?ne(R,k,n):k?Y(k,n):R&&O(R);continue}if(!C._parentNode&&C._refNode&&(C._parentNode=C._refNode.parentNode),C._parentNode){let S=z(C._parentNode,C._refNode??null,R,k,n);S&&S!==C._refNode?C._refNode=S:S||(C._refNode=null)}}s=!1,P()}}function P(){let E=n.ui;m.size>0&&!E._dirtyScheduled&&(E._dirtyScheduled=!0,queueMicrotask(()=>{E._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&w(_)}))}function x(E){return E?._selfId??n.ui?._selfId}let M={get ctx(){return n},use(E){return e.push(E),M},async mount(E,_,C){o=_;for(let N of e)n=await N(n);let R=typeof E=="string"?document.querySelector(E):E;if(!R)throw new Error(`mount target not found: ${E}`);t=R;let k=!!C?.hydrate;k||(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[...T.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&b(H);g.delete(N),p.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:w,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:T,popupTrackers:g,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:d,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:u}),s=!0,i=Un(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=k?t.firstChild:null,V.set("_wf_root",i),k)await Re(t,i,n);else{let N=Ye(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,P()},destroy(){f(),g.clear(),p.clear();for(let E of[...T.keys()])b(E);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return M}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:c}=qn(s),l=[...t,i];o.push({re:a,keys:c,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 c=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:c?.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 u=i(l);s.route=u}else{window.history.pushState({},"",l);let u=i(l);s.route=u}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let c=()=>{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",c),t==="hash"&&window.addEventListener("hashchange",c),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 G(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 c=new Set,l=null,u=0,m=null,y=null,T=null,b=!1,g={isConnected:!1,onMessage:p=>(c.add(p),()=>{c.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{b=!0,f(),l?.close(),l=null,g.isConnected=!1}};async function v(){if(!b)try{l=new WebSocket(n),l.onopen=()=>{g.isConnected=!0,u=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let w of c)w(h)}catch{}d()},l.onclose=()=>{g.isConnected=!1,f(),!b&&u<o&&(u++,m=setTimeout(v,t*Math.min(u,5)))},l.onerror=()=>{l?.close()}}catch{b||(m=setTimeout(v,t))}}function r(){i<=0||(y=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),T=setTimeout(()=>{l?.close()},s)},i))}function d(){clearTimeout(T)}function f(){clearInterval(y),clearTimeout(T),clearTimeout(m)}return v(),G(a,{ws:g})}}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,c,l,u){let m=n.baseURL+c,y={method:a,headers:{...n.headers,...u?.headers}},T=e?.token?.();T&&!y.headers.Authorization&&(y.headers.Authorization=`Bearer ${T}`);let b=i>0,g=!!u?.signal,v=null,r=null;(b||g)&&(v=new AbortController,y.signal=v.signal,b&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),g&&u.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(y.body=JSON.stringify(l));let d={url:m,init:y};t&&(d=t(d));try{let f=await fetch(d.url,d.init);if(o)return o(f);if(!f.ok){let w=await f.text().catch(()=>"");throw new ye(f.status,w||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=>G(a,{api:{get:(l,u)=>s("GET",l,void 0,u),post:(l,u,m)=>s("POST",l,u,m),put:(l,u,m)=>s("PUT",l,u,m),patch:(l,u,m)=>s("PATCH",l,u,m),delete:(l,u)=>s("DELETE",l,void 0,u)}})}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 Gn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Yn(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 c=n.getItem(t),l=n.getItem(o),u={token:c,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,y,T){u.token=m,u.user=y,n.setItem(t,m),n.setItem(o,JSON.stringify(y)),T&&n.setItem(i,T)},logout(){u.token=null,u.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(m){u.user=m,n.setItem(o,JSON.stringify(m))},async refresh(){let m=n.getItem(i);if(!m)return!1;try{let y=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!y.ok)return u.logout(),!1;let T=await y.json();return u.token=T.token,n.setItem(t,T.token),T.refreshToken&&n.setItem(i,T.refreshToken),!0}catch{return!1}}};return c&&Gn(c)&&u.refresh().catch(()=>{}),G(a,{auth:u})}}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),c={locale:i,t:(l,u)=>a.messages?.[l]??u??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=c,c.setLocale=u=>{let m=un(u),y=ge[m];y&&(a=cn(y,t,o),c.locale=m,c.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,Ne as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Yn 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,G 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,An as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Me as unlockScroll,Kn as ws,Ve as zhCN};
|
|
3
|
+
`);o=a.pop()??"";for(let d of a){let l="message",c="";for(let m of d.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 Fn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Bn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Kn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function an(e){return e.map(n=>({role:n.role,content:n.content}))}function De(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function ln(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,g,v){let r=i();switch(C){case"wf:token":r&&(r.content+=g.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:g,status:"running"}));break}case"wf:tool_progress":{let u=g,f=r?.toolCalls?.find(p=>p.call.id===u.toolCallId);f&&(f.progress=u);break}case"wf:tool_result":{let u=g,f=r?.toolCalls?.find(p=>p.call.id===u.id);f&&(f.result=u,f.status=u.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=g);break;case"wf:usage":r&&(r.usage=g);break;case"wf:step":e.step=g;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=g,r.approval=void 0),e.error=g,e.streaming=!1,e.step=null;break;default:v?.(C,g);break}}function a(){let C=t.body?t.body(e.messages):{messages:an(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 g=i();g&&o?.traceId&&(g.id=o.traceId)}function d(){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:De(),role:"user",content:C,status:"done"},{id:De(),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 g=e.messages.length-1;g>=0;g--)if(e.messages[g].role==="user"){C=g;break}C!==-1&&(e.messages.splice(C+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:De(),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 y(C,g){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:g}),signal:t.signal})}catch(u){if(t.signal?.aborted)return;e.error={code:"provider_error",message:u instanceof Error?u.message:String(u)}}}function P(){o?.abort(),o=null}return{send:d,stop:l,retry:c,clear:m,approve:y,dispose:P}}function ye(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 $n(e,n="bottom",t=6,o=!0){return ye(e.getBoundingClientRect(),n,t,o)}function ge(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,d=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+d,right:o.right+d},c=window.innerWidth,m=window.innerHeight,y=e.top,P=e.left;return l.bottom>m-t&&(y=Math.max(t,y-(l.bottom-(m-t)))),l.top<t&&(y=Math.max(t,y+(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:y,left:P,width:e.width}}var he=new Set,re=new Map,ve=new Map,ie=new Map;function un(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:d,scrollTrackers:l,schedulePopupRecompute:c,ensurePopupListeners:m,isRendering:y,isMounting:P,setMounting:C,endMounting:g}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:C,endMounting:g,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(y()){if(P())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let u=o(this);if(u)r=[u];else return}t(r)},dirty:function(r){if(!P()){if(y()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let u=o(this);if(u)r=[u];else return}for(let u of r)u&&(i.add(u),s.add(u));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let u=[...i];i.clear(),u.length>0&&t(u)}))}},$:function(){let r=this;return r._$cache||(r._$cache=me(()=>{let u=r._selfVNode?._id??o(r);u&&n.ui.dirty([u])})),r._$cache},useChat:function(r){let u=this.$(),f=ln(u,Ie,r);return Object.assign(u,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),u},useMedia:function(r,u){let p=`media:${o(this)}:${r}`;if(!a.has(p)){let h=window.matchMedia(r);u(h.matches);let w=T=>u(T.matches);h.addEventListener("change",w),a.set(p,{mql:h,handler:w})}},useBreakpoint:function(r,u){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:u,w=`bp:${o(this)}`;function T(){for(let[x,M]of Object.entries(f))if(window.matchMedia(M).matches)return x;return Object.keys(f)[0]??""}if(!a.has(w)){p(T());let x=[];for(let M of Object.values(f)){let S=window.matchMedia(M),_=()=>p(T());S.addEventListener("change",_),x.push({mql:S,handler:_})}a.set(w,{mqls:x})}},usePopupPosition:function(r){let u=o(this),f={top:0,left:0,refresh:()=>{}};if(!u)return f;let p={pos:f,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return d.set(u,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let w=h.getBoundingClientRect();if(w.width===0&&w.height===0)return;let T=p.compute(w);Object.assign(f,ge(T,p.panel?.(),p.margin))},f},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,u){return p=>{p?r(p):u?.()}},useVisualViewport:function(){let r=o(this),u={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},f=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},p=()=>{let w=window.visualViewport;u.height=w?.height??window.innerHeight,u.offsetTop=w?.offsetTop??0,u.keyboardOpen=u.height<window.innerHeight*.9,f()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",p),h.addEventListener("scroll",p)):window.addEventListener("resize",p),r&&B(w=>{w===r&&(h?.removeEventListener?(h.removeEventListener("resize",p),h.removeEventListener("scroll",p)):window.removeEventListener("resize",p))}),u},usePopup:function(r){let u=o(this),f=this.useHoverCapable(),p=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,w=()=>!!r.disabled?.(),T=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=E=>{w()||(h?r.onOpenChange?.(E):r.setOpen(E))},M=()=>{let E=r.placement;return typeof E=="function"?E():E??"bottom"},S=null,_=!1,b=n.ui.usePopupPosition({el:r.el,isOpen:()=>T(),compute:E=>{if(r.position){let L=r.position();return{top:L.y,left:L.x}}return ye(E,M(),r.gap??6,r.center!==!1)},panel:()=>S,margin:r.margin??8}),k=E=>{if(r.closeOnOutside===!1||!T())return;let L=E.target;if(!(L instanceof Node))return;let j=r.el();j&&j.contains(L)||S&&S.contains(L)||x(!1)},R=E=>{r.closeOnEscape!==!1&&(E.key!=="Escape"||!T()||x(!1))};document.addEventListener("mousedown",k),document.addEventListener("keydown",R),u&&B(E=>{E===u&&(document.removeEventListener("mousedown",k),document.removeEventListener("keydown",R))});let A={},q=E=>typeof E=="function"?E():E??0,N=()=>q(r.openDelay),I=()=>q(r.closeDelay),O,D,se=()=>{clearTimeout(O),clearTimeout(D),O=void 0,D=void 0},yn=E=>{if(w())return;let L=E.currentTarget,j=E.relatedTarget;L.contains(j)||(clearTimeout(D),D=void 0,O=setTimeout(()=>{O=void 0,x(!0)},N()))},gn=E=>{if(w())return;let L=E.currentTarget,j=E.relatedTarget;L.contains(j)||(clearTimeout(O),O=void 0,D=setTimeout(()=>{D=void 0,x(!1)},I()))},hn=()=>{w()||(clearTimeout(D),D=void 0,O=setTimeout(()=>{O=void 0,x(!0)},N()))},vn=()=>{w()||(clearTimeout(O),O=void 0,D=setTimeout(()=>{D=void 0,x(!1)},I()))},X=()=>p()==="hover";if(A.onMouseOver=E=>{X()&&yn(E)},A.onMouseOut=E=>{X()&&gn(E)},A.onClick=()=>{X()?f||x(!T()):p()==="click"&&x(!0)},A.onFocus=()=>{X()&&hn()},A.onBlur=()=>{X()&&vn()},p()==="longpress"){let E,L=0,j=0,$=()=>{clearTimeout(E),E=void 0};A.onPointerDown=H=>{w()||(L=H.clientX??0,j=H.clientY??0,$(),E=setTimeout(()=>{E=void 0,r.onTrigger?.({clientX:L,clientY:j}),x(!0)},r.longPressDuration??500))},A.onPointerUp=$,A.onPointerLeave=$,A.onPointerMove=H=>{let Te=Math.abs((H.clientX??0)-L),Ee=Math.abs((H.clientY??0)-j);(Te>10||Ee>10)&&$()},A.onContextMenu=H=>{H.preventDefault(),r.onTrigger?.({clientX:H.clientX??0,clientY:H.clientY??0}),x(!0)}}A.onKeyDown=E=>{E.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},u&&B(E=>{E===u&&se()});let wn=E=>{if(E){S=E;let L=()=>b.refresh();E.addEventListener("animationend",L,{once:!0})}else S=null},Ce=null,xe=null,bn=E=>{wn(E),xe&&xe(E)};return{get open(){return T()},setOpen:x,wrapProps:A,portal:(E,L="popover")=>{if(w())return null;if(!T())return _=!1,Ce=null,null;let $=r.el();(!_||$!==Ce)&&($?b.refresh():queueMicrotask(()=>{T()&&b.refresh()}),_=!0,Ce=$);let H=E.props??{};xe=H.ref??null;let Te=["wf-popup",H.class].filter(Boolean).join(" "),Ee={...H.style??{},position:"fixed",top:`${b.top}px`,left:`${b.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},Cn={...E,props:{...H,class:Te,style:Ee,ref:bn}};return Se(Cn,L)},refresh:()=>b.refresh()}},useLongPress:function(r){let{onLongPress:u,duration:f=500}=r,p,h=0,w=0,T=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:M=>{h=M.clientX??0,w=M.clientY??0,T=M,x(),p=setTimeout(()=>{p=void 0,u(T)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:M=>{let S=Math.abs((M.clientX??0)-h),_=Math.abs((M.clientY??0)-w);(S>10||_>10)&&x()},onContextMenu:M=>{M.preventDefault(),u(M)}}},useInView:function(r){let u=o(this),f={isIn:!1,ready:!1,observe:x,refresh:M,disconnect:S},p=null,h=null,w=()=>{n.ui&&n.ui.dirty(u?[u]:void 0)};function T(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,b=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(k=>{let R=k[k.length-1];if(!R)return;let A=R.isIntersecting,q=A!==f.isIn,N=!f.ready;f.isIn=A,f.ready=!0,r.onChange?.(R,A),(q||N)&&w()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:b??0}),h.observe(p)}function x(_){p=_,_?T():(h?.disconnect(),h=null,f.isIn=!1)}function M(){T()}function S(){h?.disconnect(),h=null}return f},useScrollPosition:function(r){let u=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 u?(l.set(u,p),m(),f.refresh(),f):(f.refresh(),f)},useAsync:function(r){let u=o(this),f=me(()=>{n.ui&&n.ui.dirty(u?[u]:void 0)});f.loading=!0;let p=0,h=()=>{let w=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(T=>{p===w&&(f.data=T,f.loading=!1)}).catch(T=>{p===w&&(f.error=T,f.loading=!1)})};return h(),f.reload=h,f},useControlled:function(r){let u=o(this),f=r.value!==void 0;f&&!r.onChange&&r.name&&(he.has(r.name)||(he.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&&u&&!re.has(u)&&(re.set(u,r.value),B(h=>{re.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}u&&re.set(u,h),n.ui&&(u?n.ui.dirty([u]):n.ui.render())};return{value:f?r.value:u?re.get(u):r.value,setValue:p,controlled:f}},useControlledInput:function(r){let u=o(this),f=this.useControlled({value:r.value,onChange:r.onChange,name:r.name});u&&!ve.has(u)&&(ve.set(u,{keyword:"",selectedLabel:""}),B(w=>{ve.delete(w)}));let p=u?ve.get(u):{keyword:"",selectedLabel:""},h=()=>{u?n.ui?.dirty([u]):n.ui?.render()};return{...f,get keyword(){return p.keyword},setKeyword(w){p.keyword=w,h()},get selectedLabel(){return p.selectedLabel},setSelectedLabel(w){p.selectedLabel=w,h()}}},useOpen:function(r){let u=o(this);u&&!ie.has(u)&&(ie.set(u,!1),B(T=>{ie.delete(T)}));let f=r.open!==void 0;f&&!r.onOpenChange&&r.name&&!he.has(r.name)&&(he.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08open \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onOpenChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
6
|
+
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 open\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onOpenChange={(o) => setOpen(o)}`));let p=()=>f?!!r.open:u?ie.get(u)??!1:!1,h=()=>{u?n.ui?.dirty([u]):n.ui?.render()},w=T=>{if(f){r.onOpenChange?.(T);return}u&&ie.set(u,T),h()};return{get open(){return p()},setOpen:w,triggerProps:{onClick:()=>w(!0),onFocus:()=>{r.openOnFocus&&w(!0)}}}},usePresence:function(r){let u=o(this),f="closed",p,h=()=>{f="closed",n.ui&&(u?n.ui.dirty([u]):n.ui.render())};return{get phase(){return f},ref:T=>{T?p||(p=()=>{f==="exit"&&h()},T.addEventListener("animationend",p)):(T?.removeEventListener("animationend",p),p=void 0)},sync:T=>(T?f="open":f==="open"&&(f="exit"),f)}},useDialog:function(r){let u=o(this),f,p=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(We(),p&&(f=pe(p)),h.ref(x)):(He(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=pe(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let u=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),u&&B(f=>{f===u&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let u=0,f=0,p=!1,h=x=>{p&&r.onMove(x,{x:x.clientX-u,y:x.clientY-f})},w=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",w),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,u=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",w),r.onStart?.(x))}}},useDragDrop:function(r){let u={};r.onDrop&&(u.onDrop=p=>{p.preventDefault(),r.onDrop(p)}),r.onDragOver&&(u.onDragOver=p=>{p.preventDefault(),r.onDragOver(p)}),r.onDragLeave&&(u.onDragLeave=p=>r.onDragLeave(p));let f={draggable:!0};if(r.onDragStart){let p=r.onDragStart;f.onDragStart=h=>{typeof document<"u"&&document.body.classList.add("wf-dragging"),p(h)}}if(r.onDragEnd){let p=r.onDragEnd;f.onDragEnd=h=>{typeof document<"u"&&document.body.classList.remove("wf-dragging"),p(h)}}return{dropProps:u,dragProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,u){let f=null,p=()=>{r(),u?.once&&f&&f.removeEventListener("animationend",p)};return w=>{w?(f=w,w.addEventListener("animationend",p)):f&&(f.removeEventListener("animationend",p),f=null)}},useTween:function(r,u){let f=o(this),p=this.useReducedMotion(),h=u?.duration??400,w=u?.ease==="linear"?b=>b:b=>1-Math.pow(1-b,3),T,x=r,M={value:p?r:0,reset:()=>{}},S=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=b=>{if(x=b,p){M.value=b,S();return}if(b===M.value)return;T&&cancelAnimationFrame(T);let k=M.value,R=performance.now(),A=q=>{let N=Math.min(1,(q-R)/h);M.value=Math.round(k+(b-k)*w(N)),N<1?(T=requestAnimationFrame(A),S()):(T=void 0,S())};T=requestAnimationFrame(A)};return M.reset=b=>{b===x&&T||_(b)},queueMicrotask(()=>_(r)),M},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 u=this._selfVNode;u&&(u._customId=r,W.set(r,u))}}}function cn(){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 zn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,d=[];function l(S){d.push(a),a=S}function c(){a=d.pop()??!1}let m=new Set,y=!1,P=new Map;function C(S){let _=P.get(S);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:b,handler:k})=>b.removeEventListener("change",k)),P.delete(S))}let g=new Map,v=!1,r=0;function u(){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 S=[];for(let[_,b]of g){if(!b.isOpen())continue;let k=b.getEl();if(!k)continue;let R=k.getBoundingClientRect();if(R.width===0&&R.height===0)continue;let A=b.compute(R);Object.assign(b.pos,ge(A,b.panel?.(),b.margin)),S.push(_)}for(let[_,b]of p){let k=b.getScroller(),R=k instanceof Window?document.scrollingElement?.scrollTop??k.scrollY??0:k.scrollTop??0;R!==b.handle.y&&(b.handle.y=R,S.push(_))}S.length>0&&n.ui.render(S)}))}function w(S){if(!s){s=!0;for(let _ of S){let b=W.get(_);if(!b||!b._render)continue;n.ui._dirtySet?.delete(_);let k=b._child,R=b._render(b.props);if(b._child=R,k&&k._placement==="remote"||R&&R._placement==="remote"){k&&R?te(k,R,n):R?Y(R,n):k&&V(k);continue}if(!b._parentNode&&b._refNode&&(b._parentNode=b._refNode.parentNode),b._parentNode){let A=z(b._parentNode,b._refNode??null,k,R,n);A&&A!==b._refNode?b._refNode=A:A||(b._refNode=null)}}s=!1,T()}}function T(){let S=n.ui;m.size>0&&!S._dirtyScheduled&&(S._dirtyScheduled=!0,queueMicrotask(()=>{S._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&w(_)}))}function x(S){return S?._selfId??n.ui?._selfId}let M={get ctx(){return n},use(S){return e.push(S),M},async mount(S,_,b){o=_;for(let N of e)n=await N(n);let k=typeof S=="string"?document.querySelector(S):S;if(!k)throw new Error(`mount target not found: ${S}`);t=k;let R=!!b?.hydrate;R||(t.innerHTML="");let A=new Map,q=globalThis.__DATA__;if(q&&typeof q=="object")for(let[N,I]of Object.entries(q))A.set(N,{value:I});if(n.data={async get(N,I){let O=A.get(N);if(O&&"value"in O)return O.value;if(O?.promise)return O.promise;if(!I)return;let D=Promise.resolve().then(()=>I()).then(se=>(A.set(N,{value:se}),se));return A.set(N,{promise:D}),D},set(N,I){A.set(N,{value:I})},has(N){return A.has(N)}},B(N=>{for(let I of[...P.keys()])(I.startsWith(`media:${N}:`)||I===`bp:${N}`)&&C(I);g.delete(N),p.delete(N)}),n.browser=cn(),n.ui=un({ctx:n,renderByIds:w,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:P,popupTrackers:g,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:u,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Gn(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=R?t.firstChild:null,W.set("_wf_root",i),R)await Ve(t,i,n);else{let N=en(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,T()},destroy(){f(),g.clear(),p.clear();for(let S of[...P.keys()])C(S);W.clear(),t&&(t.innerHTML=""),t=null,n={}}};return M}function Gn(e,n){return{type:e,props:{},key:void 0}}function Yn(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 Xn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Ue(e,n="",t=[]){let o=[];for(let i of e){let s=Yn(n,i.path),{re:a,keys:d}=Xn(s),l=[...t,i];o.push({re:a,keys:d,def:i,chain:l}),i.children&&o.push(...Ue(i.children,s,l))}return o}function dn(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 fn(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 Jn(e){let n=Ue(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=dn(s,n);if(a){let d=a.chain[a.chain.length-1];return{path:a.def.path,params:fn(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:d?.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(Q(),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 d=()=>{Q();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",d),t==="hash"&&window.addEventListener("hashchange",d),s}}function Qn(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 G(e,n){return Object.assign(Object.create(e),n)}function Zn(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 d=new Set,l=null,c=0,m=null,y=null,P=null,C=!1,g={isConnected:!1,onMessage:p=>(d.add(p),()=>{d.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{C=!0,f(),l?.close(),l=null,g.isConnected=!1}};async function v(){if(!C)try{l=new WebSocket(n),l.onopen=()=>{g.isConnected=!0,c=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let w of d)w(h)}catch{}u()},l.onclose=()=>{g.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||(y=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),P=setTimeout(()=>{l?.close()},s)},i))}function u(){clearTimeout(P)}function f(){clearInterval(y),clearTimeout(P),clearTimeout(m)}return v(),G(a,{ws:g})}}function et(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,d,l,c){let m=n.baseURL+d,y={method:a,headers:{...n.headers,...c?.headers}},P=e?.token?.();P&&!y.headers.Authorization&&(y.headers.Authorization=`Bearer ${P}`);let C=i>0,g=!!c?.signal,v=null,r=null;(C||g)&&(v=new AbortController,y.signal=v.signal,C&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),g&&c.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(y.body=JSON.stringify(l));let u={url:m,init:y};t&&(u=t(u));try{let f=await fetch(u.url,u.init);if(o)return o(f);if(!f.ok){let w=await f.text().catch(()=>"");throw new we(f.status,w||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=>G(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 we=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function nt(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 tt(e){let n=nt(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function ot(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 d=n.getItem(t),l=n.getItem(o),c={token:d,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,y,P){c.token=m,c.user=y,n.setItem(t,m),n.setItem(o,JSON.stringify(y)),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 y=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!y.ok)return c.logout(),!1;let P=await y.json();return c.token=P.token,n.setItem(t,P.token),P.refreshToken&&n.setItem(i,P.refreshToken),!0}catch{return!1}}};return d&&tt(d)&&c.refresh().catch(()=>{}),G(a,{auth:c})}}function rt(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 je={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 qe={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 be={"zh-CN":je,"en-US":qe};function pn(e){if(be[e])return e;let n=e.split("-")[0];return Object.keys(be).find(o=>o.startsWith(n))??"zh-CN"}function it(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=pn(n),s=be[i],a=mn(s,t,o),d={locale:i,t:(l,c)=>a.messages?.[l]??c??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=d,d.setLocale=c=>{let m=pn(c),y=be[m];y&&(a=mn(y,t,o),d.locale=m,d.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function mn(e,n,t){return{messages:{...e?.messages,...n},components:st(e?.components??{},t)}}function st(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 at(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{we as ApiError,rt as ErrorBoundary,K as Fragment,F as Portal,Qn as RouteView,Ie as aiStream,at as animateOut,et as api,xn as asyncComponent,ot as auth,V as callRefCleanup,Q as clearAsyncComponentCache,$n as computeFixedPos,ye as computeFixedPosRect,zn as createApp,Se as createPortal,me as createReactiveState,qe as enUS,G as extendCtx,Pn as h,Ve as hydrateVNode,it as i18n,J as isAsyncComponent,Pe as jsx,En as jsxDEV,Tn as jsxs,We as lockScroll,Wn as mountVNode,z as patchValue,Jn as router,an as toChatMessages,pe as trapFocus,He as unlockScroll,Zn as ws,je as zhCN};
|
package/dist/client/types.d.ts
CHANGED
|
@@ -383,6 +383,34 @@ export interface WfuiContext {
|
|
|
383
383
|
setValue: (v: T) => void;
|
|
384
384
|
controlled: boolean;
|
|
385
385
|
};
|
|
386
|
+
/** 受控输入原语(C3):useControlled + 内部输入态/选中态(keyword/selectedLabel) */
|
|
387
|
+
useControlledInput: (options: {
|
|
388
|
+
value?: string;
|
|
389
|
+
onChange?: (v: string) => void;
|
|
390
|
+
name?: string;
|
|
391
|
+
}) => {
|
|
392
|
+
value: string | undefined;
|
|
393
|
+
setValue: (v: string) => void;
|
|
394
|
+
controlled: boolean;
|
|
395
|
+
keyword: string;
|
|
396
|
+
setKeyword: (v: string) => void;
|
|
397
|
+
selectedLabel: string;
|
|
398
|
+
setSelectedLabel: (v: string) => void;
|
|
399
|
+
};
|
|
400
|
+
/** 显隐打开状态机(C4):trigger/focus 协调(onClick 只开——防 focus 开+click 关冲突);弹层双向场景用 open/setOpen(受控走 onOpenChange + 缺回调 warn) */
|
|
401
|
+
useOpen: (options: {
|
|
402
|
+
open?: boolean;
|
|
403
|
+
onOpenChange?: (open: boolean) => void;
|
|
404
|
+
openOnFocus?: boolean;
|
|
405
|
+
name?: string;
|
|
406
|
+
}) => {
|
|
407
|
+
open: boolean;
|
|
408
|
+
setOpen: (open: boolean) => void;
|
|
409
|
+
triggerProps: {
|
|
410
|
+
onClick: () => void;
|
|
411
|
+
onFocus: () => void;
|
|
412
|
+
};
|
|
413
|
+
};
|
|
386
414
|
/**
|
|
387
415
|
* 全屏对话框组合器(收敛 Modal/Drawer 的退场状态机 + 滚动锁 + 焦点 trap):
|
|
388
416
|
* mount 创建,render 阶段 sync(open) 驱动状态机;组件只管布局。
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — AlertGroup 通知合并组
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:EP AlertGroup(2.8 新增)。
|
|
5
|
+
* 同类通知合并折叠:≥3 条折叠为摘要 +N,点击展开:
|
|
6
|
+
*
|
|
7
|
+
* <AlertGroup items={[{ id, message, time }]} onClose={...} />
|
|
8
|
+
*
|
|
9
|
+
* 裁剪(CS-05):合并阈值固定 3 条起(少于此退化为平铺);
|
|
10
|
+
* 不做时间线分组/虚拟化。
|
|
11
|
+
*/
|
|
12
|
+
import type { Component } from '../../client/vnode.ts';
|
|
13
|
+
export interface AlertGroupItem {
|
|
14
|
+
id: string;
|
|
15
|
+
message: any;
|
|
16
|
+
time?: string;
|
|
17
|
+
variant?: 'info' | 'success' | 'warning' | 'error';
|
|
18
|
+
}
|
|
19
|
+
export interface AlertGroupProps {
|
|
20
|
+
items: AlertGroupItem[];
|
|
21
|
+
onClose?: (id: string) => void;
|
|
22
|
+
}
|
|
23
|
+
export declare const AlertGroup: Component<AlertGroupProps>;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — AutoComplete 输入联想
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:antd AutoComplete / EP Autocomplete / shadcn Combobox(输入侧)。
|
|
5
|
+
* 自由输入 + 实时联想下拉:包含匹配(不区分大小写)、键盘 ↓↑/Enter/Escape、
|
|
6
|
+
* 选中回填。与 Select 区别:Select 选固定选项,AutoComplete 输入是自由值。
|
|
7
|
+
*
|
|
8
|
+
* <AutoComplete
|
|
9
|
+
* options={[{ value: 'pay', label: '支付平台' }]}
|
|
10
|
+
* value={query} onChange={setQuery}
|
|
11
|
+
* />
|
|
12
|
+
*
|
|
13
|
+
* 裁剪(CS-05):不做分组/虚拟化候选(Select searchable 覆盖分组场景);
|
|
14
|
+
* 自定义渲染用 `renderOption` 透传。
|
|
15
|
+
*/
|
|
16
|
+
import type { Component } from '../../client/vnode.ts';
|
|
17
|
+
export interface AutoCompleteOption {
|
|
18
|
+
value: string;
|
|
19
|
+
label?: any;
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface AutoCompleteProps {
|
|
23
|
+
options: AutoCompleteOption[];
|
|
24
|
+
value?: string;
|
|
25
|
+
onChange?: (value: string) => void;
|
|
26
|
+
placeholder?: string;
|
|
27
|
+
open?: boolean;
|
|
28
|
+
onOpenChange?: (open: boolean) => void;
|
|
29
|
+
disabled?: boolean;
|
|
30
|
+
/** 过滤函数(默认包含匹配) */
|
|
31
|
+
filter?: (options: AutoCompleteOption[], query: string) => AutoCompleteOption[];
|
|
32
|
+
renderOption?: (option: AutoCompleteOption) => any;
|
|
33
|
+
onSelect?: (value: string, option: AutoCompleteOption) => void;
|
|
34
|
+
}
|
|
35
|
+
/** 默认过滤:label/value 包含匹配,不区分大小写(纯函数——可单测/SSR) */
|
|
36
|
+
export declare function filterOptions(options: AutoCompleteOption[], query: string): AutoCompleteOption[];
|
|
37
|
+
export declare const AutoComplete: Component<AutoCompleteProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — FloatButton 悬浮操作按钮
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:antd FloatButton(特有——EP/shadcn 无独立等价)。
|
|
5
|
+
* 固定视口定位 + badge + 组展开状态机:
|
|
6
|
+
*
|
|
7
|
+
* <FloatButton icon={...} position="bottom-right" badge={5} onClick={...} />
|
|
8
|
+
* <FloatButtonGroup>
|
|
9
|
+
* <FloatButton icon={...} onClick={...} />
|
|
10
|
+
* </FloatButtonGroup>
|
|
11
|
+
*
|
|
12
|
+
* 裁剪(CS-05):不做拖拽悬浮(Resizable 可组合);回顶用 BackTop 语义更清晰。
|
|
13
|
+
*/
|
|
14
|
+
import type { Component } from '../../client/vnode.ts';
|
|
15
|
+
export type FloatButtonPosition = 'top-left' | 'top-right' | 'bottom-left' | 'bottom-right';
|
|
16
|
+
export interface FloatButtonProps {
|
|
17
|
+
icon?: any;
|
|
18
|
+
badge?: number | string;
|
|
19
|
+
position?: FloatButtonPosition;
|
|
20
|
+
/** 'static':组内子项(不 fixed——独立 fixed 会与主按钮重叠) */
|
|
21
|
+
static?: boolean;
|
|
22
|
+
disabled?: boolean;
|
|
23
|
+
onClick?: () => void;
|
|
24
|
+
'aria-label'?: string;
|
|
25
|
+
children?: any;
|
|
26
|
+
}
|
|
27
|
+
/** 单个悬浮按钮 */
|
|
28
|
+
export declare const FloatButton: Component<FloatButtonProps>;
|
|
29
|
+
export interface FloatButtonGroupProps {
|
|
30
|
+
position?: FloatButtonPosition;
|
|
31
|
+
children?: any;
|
|
32
|
+
}
|
|
33
|
+
/** 悬浮按钮组:主按钮展开/收起子按钮 */
|
|
34
|
+
export declare const FloatButtonGroup: Component<FloatButtonGroupProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — Grid 栅格 + Flex 容器
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:antd Row/Col/Flex、EP Row/Col。
|
|
5
|
+
* 24 栅格 + gutter + flex 容器模式(单行弹性布局 = antd Flex 场景):
|
|
6
|
+
*
|
|
7
|
+
* <Grid gutter={16}>
|
|
8
|
+
* <Col span={8}>A</Col>
|
|
9
|
+
* <Col span={8}>B</Col>
|
|
10
|
+
* </Grid>
|
|
11
|
+
* <Grid flex gap={8} direction="row">...</Grid>
|
|
12
|
+
*
|
|
13
|
+
* 裁剪(CS-05):不做响应式断点 props(useBreakpoint 由用户驱动);
|
|
14
|
+
* gutter 仅水平(垂直 gutter 低频)。
|
|
15
|
+
*/
|
|
16
|
+
import type { Component } from '../../client/vnode.ts';
|
|
17
|
+
export interface GridProps {
|
|
18
|
+
gutter?: number;
|
|
19
|
+
flex?: boolean;
|
|
20
|
+
gap?: number;
|
|
21
|
+
direction?: 'row' | 'column';
|
|
22
|
+
align?: 'start' | 'center' | 'end' | 'stretch';
|
|
23
|
+
children?: any;
|
|
24
|
+
}
|
|
25
|
+
export interface ColProps {
|
|
26
|
+
/** 0-24 栅格跨度;0 = flex:1 占剩余 */
|
|
27
|
+
span?: number;
|
|
28
|
+
gutter?: number;
|
|
29
|
+
children?: any;
|
|
30
|
+
}
|
|
31
|
+
/** 栅格跨度 → 宽度(纯函数——可单测/SSR) */
|
|
32
|
+
export declare function gridColumns(span: number): string;
|
|
33
|
+
export declare const Grid: Component<GridProps>;
|
|
34
|
+
export declare const Col: Component<ColProps>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — Layout 布局外壳
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:antd Layout / Element Plus Container / shadcn Sidebar。
|
|
5
|
+
* 复合子组件模式(无命名空间——独立导出):
|
|
6
|
+
*
|
|
7
|
+
* <Layout>
|
|
8
|
+
* <LayoutSider collapsible collapsed onCollapse>导航</LayoutSider>
|
|
9
|
+
* <Layout>
|
|
10
|
+
* <LayoutHeader>顶部</LayoutHeader>
|
|
11
|
+
* <LayoutContent>主区</LayoutContent>
|
|
12
|
+
* <LayoutFooter>底部</LayoutFooter>
|
|
13
|
+
* </Layout>
|
|
14
|
+
* </Layout>
|
|
15
|
+
*
|
|
16
|
+
* - 含 LayoutSider → row(横向:侧栏 + 主区);否则 column(纵向)
|
|
17
|
+
* - Sider 折叠:collapsible + 受控 collapsed/onCollapse(非受控点击触发器内部切换)
|
|
18
|
+
* - 响应式折叠交还用户:useBreakpoint 驱动 collapsed(裁剪:不自动抽屉化)
|
|
19
|
+
* - 静态外壳见 layout `_app-shell.css`(wf-app-shell/wf-sidebar/wf-main)
|
|
20
|
+
*/
|
|
21
|
+
import type { Component } from '../../client/vnode.ts';
|
|
22
|
+
export interface LayoutProps {
|
|
23
|
+
children?: any;
|
|
24
|
+
}
|
|
25
|
+
export interface LayoutSiderProps {
|
|
26
|
+
width?: number | string;
|
|
27
|
+
/** 折叠宽度(默认 64px——图标栏) */
|
|
28
|
+
collapsedWidth?: number | string;
|
|
29
|
+
collapsed?: boolean;
|
|
30
|
+
/** 显示折叠触发器(底部条) */
|
|
31
|
+
collapsible?: boolean;
|
|
32
|
+
onCollapse?: (collapsed: boolean) => void;
|
|
33
|
+
/** 触发器内容(默认 chevron Icon) */
|
|
34
|
+
trigger?: any;
|
|
35
|
+
children?: any;
|
|
36
|
+
}
|
|
37
|
+
export interface LayoutHeaderProps {
|
|
38
|
+
children?: any;
|
|
39
|
+
style?: any;
|
|
40
|
+
}
|
|
41
|
+
export interface LayoutContentProps {
|
|
42
|
+
children?: any;
|
|
43
|
+
style?: any;
|
|
44
|
+
}
|
|
45
|
+
export interface LayoutFooterProps {
|
|
46
|
+
children?: any;
|
|
47
|
+
style?: any;
|
|
48
|
+
}
|
|
49
|
+
/** 布局容器:含 Sider → row(横向),否则 column(纵向) */
|
|
50
|
+
export declare const Layout: Component<LayoutProps>;
|
|
51
|
+
/** 侧边栏(唯一可折叠部件) */
|
|
52
|
+
export declare const LayoutSider: Component<LayoutSiderProps>;
|
|
53
|
+
/** 顶部栏 */
|
|
54
|
+
export declare const LayoutHeader: Component<LayoutHeaderProps>;
|
|
55
|
+
/** 主内容区(撑满剩余空间 + 可滚动) */
|
|
56
|
+
export declare const LayoutContent: Component<LayoutContentProps>;
|
|
57
|
+
/** 底部栏 */
|
|
58
|
+
export declare const LayoutFooter: Component<LayoutFooterProps>;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — Link 文字链接
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:EP Link / antd Typography.Link(内嵌)。
|
|
5
|
+
* 语义色/下划线/disabled/新窗口/图标——原语 a 的组件化。
|
|
6
|
+
*
|
|
7
|
+
* <Link href="/docs" variant="primary" icon="→">文档</Link>
|
|
8
|
+
*
|
|
9
|
+
* 裁剪(CS-05):不做 hover 弹层预览/图标内置枚举(icon 任意 VNode)。
|
|
10
|
+
*/
|
|
11
|
+
import type { Component } from '../../client/vnode.ts';
|
|
12
|
+
export interface LinkProps {
|
|
13
|
+
href?: string;
|
|
14
|
+
variant?: 'default' | 'primary' | 'danger' | 'muted';
|
|
15
|
+
underline?: boolean;
|
|
16
|
+
disabled?: boolean;
|
|
17
|
+
target?: string;
|
|
18
|
+
icon?: any;
|
|
19
|
+
onClick?: (e: any) => void;
|
|
20
|
+
children?: any;
|
|
21
|
+
}
|
|
22
|
+
export declare const Link: Component<LinkProps>;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — NavMenu 顶部导航
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:shadcn NavigationMenu(特有——antd/EP 用 Menu 横向模式)。
|
|
5
|
+
* 顶部水平导航 + 多级 hover 弹出 + 键盘(→ 进入子菜单 / ← 返回 / Escape 关闭):
|
|
6
|
+
*
|
|
7
|
+
* <NavMenu items={[{ key, label, children: [...] }]} activeKey onSelect />
|
|
8
|
+
*
|
|
9
|
+
* 弹层纪律(AGENTS.md):子菜单/嵌套子菜单全部经 usePopup 组合器
|
|
10
|
+
* (createPortal + fixed + 视口夹紧 + Escape + 外部点击)——不 absolute 定位。
|
|
11
|
+
*
|
|
12
|
+
* 裁剪(CS-05):不做 hover 延迟微调/子菜单动画曲线定制;
|
|
13
|
+
* 折叠态交还 useBreakpoint 由用户驱动。
|
|
14
|
+
*/
|
|
15
|
+
import type { Component } from '../../client/vnode.ts';
|
|
16
|
+
export interface NavMenuItem {
|
|
17
|
+
key: string;
|
|
18
|
+
label?: any;
|
|
19
|
+
children?: NavMenuItem[];
|
|
20
|
+
disabled?: boolean;
|
|
21
|
+
}
|
|
22
|
+
export interface NavMenuProps {
|
|
23
|
+
items: NavMenuItem[];
|
|
24
|
+
activeKey?: string;
|
|
25
|
+
onSelect?: (key: string) => void;
|
|
26
|
+
}
|
|
27
|
+
export declare const NavMenu: Component<NavMenuProps>;
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* weifuwu/components — Popconfirm 气泡确认
|
|
3
|
+
*
|
|
4
|
+
* 三库等价:antd Popconfirm / Element Plus Popconfirm。
|
|
5
|
+
* 复用 usePopup 组合器(Popover 同级基座)——验证弹层体系可组合性:
|
|
6
|
+
* 定位/portal/外部点击/Escape/视口夹紧全部继承,组件只写确认语义。
|
|
7
|
+
*
|
|
8
|
+
* <Popconfirm title="确定删除?" danger onConfirm={...}>
|
|
9
|
+
* <button>删除</button>
|
|
10
|
+
* </Popconfirm>
|
|
11
|
+
*
|
|
12
|
+
* - 受控 open/onOpenChange;非受控点击触发
|
|
13
|
+
* - 确认后自动关闭(onConfirm 后 setOpen(false))
|
|
14
|
+
* - 裁剪(CS-05):不做气泡内表单/自定义箭头
|
|
15
|
+
*/
|
|
16
|
+
import type { Component } from '../../client/vnode.ts';
|
|
17
|
+
import type { Placement } from '../../client/popup.ts';
|
|
18
|
+
export interface PopconfirmProps {
|
|
19
|
+
title?: any;
|
|
20
|
+
okText?: string;
|
|
21
|
+
cancelText?: string;
|
|
22
|
+
okType?: 'primary' | 'danger';
|
|
23
|
+
/** 危险确认(默认图标换 warning 色 + 确认按钮 danger) */
|
|
24
|
+
danger?: boolean;
|
|
25
|
+
onConfirm?: () => void;
|
|
26
|
+
onCancel?: () => void;
|
|
27
|
+
position?: Placement;
|
|
28
|
+
open?: boolean;
|
|
29
|
+
onOpenChange?: (open: boolean) => void;
|
|
30
|
+
disabled?: boolean;
|
|
31
|
+
icon?: any;
|
|
32
|
+
children?: any;
|
|
33
|
+
}
|
|
34
|
+
export declare const Popconfirm: Component<PopconfirmProps>;
|