weifuwu 0.67.2 → 0.68.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 +4 -4
- package/dist/client/types.d.ts +27 -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 +15 -15
- package/dist/components/style.css +655 -13
- package/dist/index.js +54 -4
- package/dist/layout/weifuwu-layout.css +15 -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 + 155 个主题 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 个布局原语 + 155 个主题 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 个布局原语 + 155 个主题 Token |
|
|
495
495
|
| [docs/styling.md](docs/styling.md) | 样式定制指南:零自定义 CSS 模式 / 暗色 / 组件级覆盖 / 作用域主题 |
|
|
496
496
|
|
|
497
497
|
### 通用
|
package/dist/client/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
var Ie="__wfAsyncComponent";function mn(e){let n=e;return n[Ie]=!0,n}function X(e){return typeof e=="function"&&e?.[Ie]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function we(e,n,t){return{type:e,props:De(n),key:t??void 0}}var yn=we;function gn(e,n,t){return we(e,n,t)}function hn(e,n,...t){let o=De(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function De(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function be(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var vn=0,V=new Map,ie=[];function K(e){ie.push(e)}var se=new WeakMap;function J(){se=new WeakMap}function Ce(e,n){let t=se.get(e);if(t)return t;let o={promise:null};return o.promise=Promise.resolve().then(()=>e(n)).then(i=>{if(typeof i!="function")throw new Error(`asyncComponent factory <${e.name||"anonymous"}> must return a Component (initProps, ctx) => (props) => VNode.`);return o.resolved=i,i}),se.set(e,o),o}async function Ue(e,n){return Ce(e,n).promise}function je(e){return se.get(e)?.resolved}function wn(e){let n=e._child;if(n!=null)if(Array.isArray(n))for(let t of n)t&&typeof t=="object"&&O(t);else typeof n=="object"&&O(n)}function O(e){if(e==null||typeof e!="object")return;let n=e;if(n._id){if(n._customId&&V.delete(n._customId),V.delete(n._id),ie.length>0){for(let t of ie)t(n._id);if(n._customId)for(let t of ie)t(n._customId)}n._id=void 0,n._customId=void 0,n._render=void 0,n._parentNode=void 0,n._refNode=void 0}if(n._child!=null){if(Array.isArray(n._child))for(let t of n._child)t&&typeof t=="object"&&O(t);else O(n._child);n._child=void 0}if(n.props?.children&&typeof n.type=="string"){let t=Array.isArray(n.props.children)?n.props.children:[n.props.children];for(let o of t)o&&typeof o=="object"&&O(o)}typeof n.props?.ref=="function"&&n.props.ref(null),n._remoteEl&&(wn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${vn++}`}var qe=new WeakMap;function bn(e){let n=qe.get(e)??{count:0,warned:!1};n.count++,n.count>=3&&!n.warned&&(n.warned=!0,console.warn("[weifuwu] ref \u51FD\u6570\u6BCF\u6B21\u6E32\u67D3\u90FD\u53D8\u5316\uFF08\u5185\u8054 ref\uFF09\u2014\u2014ref \u56DE\u8C03\u5728\u6BCF\u6B21\u6E32\u67D3\u540E\u91CD\u65B0\u6267\u884C\uFF08\u6027\u80FD\u635F\u8017\uFF09\u3002\u628A ref \u5B9A\u4E49\u5230 mount \u4F5C\u7528\u57DF\uFF08\u7A33\u5B9A\u5F15\u7528\uFF09\uFF1Aconst listRef = (el) => {...}; return h('div', { ref: listRef })")),qe.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let c=D(o,i);return c==null?null:(n&&n.parentNode?n.parentNode.insertBefore(c,n):e.appendChild(c),c)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=Be(t),a=Be(o);if(s!==a){O(t);let c=D(o,i);return c==null?null:(n?.parentNode&&n.parentNode.replaceChild(c,n),c)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let u=o,l=t;if(typeof u.type=="function"){let c=u.type;l._render&&(u._render=l._render,u._id=l._id,u._id&&V.set(u._id,u)),u._parentNode=e,u._refNode=n;let m=Object.create(i);if(m.ui=Object.create(i.ui),m.ui._selfId=u._id,m.ui._selfVNode=u,u._ctxVersion=l._ctxVersion??m.ui._ctxVersion??0,l._render&&Tn(l.props,u.props)&&!m.ui._dirtySet?.has(l._id)&&u._ctxVersion===m.ui._ctxVersion)return u._child=l._child,n;m.ui._dirtySet?.delete(l._id);let g;try{typeof u._render=="function"?g=u._render(u.props):g=Ee(c,u.props,u,m)}catch(y){let v=i.ui?._errorHandler;v?(v(y),g=null):(console.error(`[weifuwu] Component render error in <${c?.name||"anonymous"}> (id: ${l._id??"?"}, phase: update)`,y),g=null)}let P=l._child;u._child=g;let C=z(e,n,P,g,m);return C||(u._refNode=null),C}if(u.type===B){let c=l._childNodes,m=$e(e,l,u,i,c);return u._childNodes=m,n}if(typeof u.type=="string"){if(n&&n.nodeType===1){let c=l.props?.ref,m=u.props?.ref;c!==m&&(typeof m=="function"&&m(n),typeof c=="function"&&typeof m=="function"&&bn(n)),Te(n,l.props,u.props),$e(n,l,u,i)}else if(n){O(t);let c=D(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(u.type===q)return ne(l,u,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];ae(c,o);let m=Array.from(e.childNodes),g=n?m.indexOf(n):-1,P=g>=0?Z(m.slice(g),c):Z(m,c);return le(e,c,o,i,P,n),n}return n}var Fe=new Map;function Cn(e){let n=Fe.get(e);return n||(n=`fn:${e.name||"anon"}`,Fe.set(e,n)),n}function Be(e){if(e==null||typeof e=="boolean")return"null";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"array";let n=e;return typeof n.type=="function"?Cn(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function Te(e,n,t){let o=n?Object.keys(n).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],i=t?Object.keys(t).filter(a=>a!=="children"&&a!=="key"&&a!=="innerHTML"):[],s=new Set(i);for(let a of o)if(!s.has(a)){if(a==="ref")continue;a.startsWith("on")&&typeof n[a]=="function"?e.removeEventListener(a.slice(2).toLowerCase(),n[a]):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a==="className"?"class":a)}for(let a of i){if(a==="ref")continue;let u=n?.[a],l=t?.[a];if(a==="innerHTML")l!==u&&(e.innerHTML=String(l??""));else if(l!==u)if(a==="class"||a==="className")e instanceof SVGElement?e.setAttribute("class",Ke(l)):e.className=Ke(l);else if(a==="style"&&typeof l=="object"){let c=e.style;for(let m of Object.keys(l)){let g=l[m];g!=null&&(c[m]=typeof g=="number"?g+"px":String(g))}}else if(a.startsWith("on")&&typeof l=="function"){let c=a.slice(2).toLowerCase();typeof u=="function"&&e.removeEventListener(c,u),e.addEventListener(c,l)}else a==="draggable"?e.setAttribute("draggable",l?"true":"false"):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value=String(l??""):l===!0?e.setAttribute(a,""):l!=null&&l!==!1?e.setAttribute(a,String(l)):a==="value"&&(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)?e.value="":e.removeAttribute(a)}}function Ke(e){return typeof e=="string"?e:Array.isArray(e)?e.filter(Boolean).join(" "):e&&typeof e=="object"?Object.entries(e).filter(([,n])=>n).map(([n])=>n).join(" "):""}function xe(e){if(!(e==null||typeof e!="object"))return e.key}function ae(e,n){if(!n.some(o=>o&&typeof o=="object"&&o.key!==void 0)){for(let o=0;o<n.length;o++){let i=n[o];i&&typeof i=="object"&&(i.key=o)}for(let o=0;o<e.length;o++){let i=e[o];i&&typeof i=="object"&&(i.key=o)}}}function Z(e,n){let t=[],o=0;for(let i of n){if(i==null||typeof i=="boolean"){t.push(null);continue}let s=i;if(s.type===q){t.push(null);continue}if(s.type===B){let a=s._childNodes;Array.isArray(a)&&a.length>0?(t.push(a.slice()),o+=a.length):(t.push(e[o]?[e[o]]:null),o+=1)}else typeof process<"u"&&process.env.DBG&&console.error("[map] idx=",o,"type=",s.type,"sourceLen=",e.length,"hit=",!!e[o]),t.push(e[o]?[e[o]]:null),o+=1}return t}function $e(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);ae(s,a);let u=i??Array.from(e.childNodes),l=Z(u,s),c=le(e,s,a,o,l,i?.[0]??null),m=[];for(let g of c)g&&g.length>0&&m.push(...g);return m}function ee(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function ze(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function le(e,n,t,o,i=[],s=null){if(!t.some(y=>y&&typeof y=="object"&&y.key!==void 0)){let y=Math.max(n.length,t.length);for(let v=0;v<y;v++){let r=v<n.length?n[v]:null,d=v<t.length?t[v]:null;if(d==null){if(r!=null){O(r);for(let f of i[v]??[])f.remove()}}else if(r==null){let f=D(d,o);f!=null&&e.appendChild(f)}else{let f=i[v]?.[0]??null;z(e,f,r,d,o)}}return[]}for(let y=0;y<n.length;y++){let v=n[y];if(!(v==null||typeof v=="boolean")&&xe(v)===void 0)for(let r of i[y]??[])r.remove()}let u=new Map,l=0;for(let y=0;y<n.length;y++){let v=xe(n[y]);v!==void 0&&u.set(v,{vnode:n[y],nodes:i[y]??[],index:l++})}let c=t.map(y=>xe(y)),m=new Set(c);for(let y of[...u.keys()])if(!m.has(y)){let v=u.get(y);O(v.vnode);for(let r of v.nodes)r?.remove();u.delete(y)}let g=new Array(t.length).fill(null),P=-1,C=s&&s.parentNode===e?s:e.firstChild;for(let y=0;y<t.length;y++){let v=c[y],r=t[y],d=v!==void 0?u.get(v):void 0,f=r&&typeof r=="object"&&r._placement==="remote";if(d)if(d.nodes.length>0){if(d.index<P)for(let h of d.nodes)e.insertBefore(h,C);P=Math.max(P,d.index),z(e,d.nodes[0],d.vnode,r,o),g[y]=r._childNodes??d.nodes.filter(h=>h.parentNode===e),C=g[y][g[y].length-1]?.nextSibling??null}else if(f)ne(d.vnode,r,o),g[y]=[];else{let p=z(e,null,d.vnode,r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}else if(f)G(r,o),g[y]=[];else{let p=D(r,o);g[y]=ze(p);for(let b of g[y])e.insertBefore(b,C);C=g[y][g[y].length-1]?.nextSibling??null}}return g}function xn(e,n){if(e===n)return!0;if(Array.isArray(e)&&Array.isArray(n)){if(e.length!==n.length)return!1;for(let t=0;t<e.length;t++)if(e[t]!==n[t])return!1;return!0}return e===n}function Tn(e,n){if(e===n)return!0;if(!e||!n)return!1;let t=new Set([...Object.keys(e),...Object.keys(n)]);for(let o of t)if(o!=="key"){if(o==="children"){if(!xn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var Pe="http://www.w3.org/2000/svg",_e=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Ge(e,n){return D(e,n)}function D(e,n){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return document.createTextNode(String(e));if(Array.isArray(e))return _n(e,n);let t=e;if(t.type===q)return G(t,n),null;if(t.type===B){let a=document.createDocumentFragment(),u=t.props?.children==null?[]:Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let l of u){let c=D(l,n);c!=null&&a.appendChild(c)}return t._childNodes=Array.from(a.childNodes),a}if(typeof t.type=="function")return Pn(t.type,t.props,t,n);let o=t.type,i=_e.has(o)?document.createElementNS(Pe,o):document.createElement(o);t.el=i;let s;for(let[a,u]of Object.entries(t.props??{}))a==="children"||a==="key"||a==="value"||a==="innerHTML"||Ye(i,a,u);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Ye(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Ae(t.props?.children);for(let u of a){let l=D(u,n);if(l!=null&&(i.appendChild(l),u&&typeof u=="object"&&typeof u.type=="function")){let c=u;c._parentNode||(c._parentNode=i,c._refNode=l)}}}return s!==void 0&&(i.value=String(s)),typeof t.props?.ref=="function"&&t.props.ref(i),i}function En(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ee(e,n,t,o){let i;if(X(e)){if(i=je(e),!i)return Ce(e,o).promise.then(()=>En(o),()=>{}),null}else i=e;o.ui?.setMounting?.(!0);let s;try{s=i(n,o)}finally{o.ui?.endMounting?.()}if(typeof s!="function")throw new Error(`Component ${e.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);return t._render=s,s(n)}function Pn(e,n,t,o){o.ui=o.ui??{},t._id||(t._id=Q(),V.set(t._id,t));let i=Object.create(o);i.ui=Object.create(o.ui),i.ui._selfId=t._id,i.ui._selfVNode=t,t._ctxVersion=i.ui._ctxVersion??0;let s;try{s=Ee(e,n,t,i)}catch(u){let l=o.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component render error in <${e.name||"anonymous"}> (id: ${t._id??"?"}, phase: mount)`,u),s=null)}if(s==null)return t._child=null,null;t._child=s;let a=D(s,i);return t._refNode||(t._refNode=a),a}function _n(e,n){let t=document.createDocumentFragment();for(let o of e){let i=D(o,n);i!=null&&t.appendChild(i)}return t}function An(){let e=document.getElementById("__wf_portal");return e||(e=document.createElement("div"),e.id="__wf_portal",e.style.cssText="position:fixed;inset:0;pointer-events:none;z-index:9999",document.body.appendChild(e)),e}function G(e,n){let t=An(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=D(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){G(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,ae(s,i);let a=Z(Array.from(o.childNodes),s);le(o,s,i,t,a,a[0]?.[0]??null)}function Ae(e){if(e==null)return[];if(!Array.isArray(e))return[e];let n=[];for(let t of e)Array.isArray(t)?n.push(...t):n.push(t);return n}function Ye(e,n,t){if(n!=="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 Sn(e,n,t){e.innerHTML="";let o=D(n,t);o instanceof Node?e.appendChild(o):Array.isArray(o)&&o.forEach(i=>e.appendChild(i))}function Se(e){e.node=e.node?e.node.nextSibling:null}function Rn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function kn(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Se(e)):e.parent.appendChild(n)}async function te(e,n,t){if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number"){let u=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==u&&(t.node.textContent=u),Se(t),t.node;let l=document.createTextNode(u);return Rn(t,l),l}if(Array.isArray(e)){let u=null;for(let l of e){let c=await te(l,n,t);c!=null&&!u&&(u=c)}return u}let o=e;if(o.type===q||o.type===B){let u=o.props?.children,l=u==null?[]:Array.isArray(u)?u:[u],c=null;for(let m of l){let g=await te(m,n,t);g!=null&&!c&&(c=g)}return c}if(typeof o.type=="function")return Nn(o,n,t);let i=o.type,s=o.props??{},a;if(t.node&&t.node.nodeType===1&&t.node.tagName.toLowerCase()===i.toLowerCase()?(a=t.node,Se(t)):(a=_e.has(i)?document.createElementNS(Pe,i):document.createElement(i),kn(t,a)),o.el=a,Te(a,null,s),!("innerHTML"in s)){let u={parent:a,node:a.firstChild},l=Ae(s.children);for(let c of l){let m=await te(c,n,u);if(m!=null&&m.parentNode!==a&&a.appendChild(m),c&&typeof c=="object"&&typeof c.type=="function"){let g=c;g._parentNode||(g._parentNode=a,g._refNode=m)}}for(;u.node;){let c=u.node;u.node=c.nextSibling,c.parentNode?.removeChild(c)}}return"value"in s&&a instanceof HTMLSelectElement&&(a.value=String(s.value??"")),typeof s.ref=="function"&&s.ref(a),a}async function Nn(e,n,t){n.ui=n.ui??{},e._id||(e._id=Q(),V.set(e._id,e));let o=Object.create(n);o.ui=Object.create(n.ui),o.ui._selfId=e._id,o.ui._selfVNode=e,e._ctxVersion=o.ui._ctxVersion??0;let i=e.type,s;try{let u;X(i)?u=await Ue(i,o):u=i;let l=u(e.props??{},o);if(typeof l!="function")throw new Error(`Component ${i.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=l,s=l(e.props??{})}catch(u){let l=n.ui?._errorHandler;l?(l(u),s=null):(console.error(`[weifuwu] Component hydration error in <${i.name||"anonymous"}> (id: ${e._id??"?"})`,u),s=null)}if(s==null)return e._child=null,null;e._child=s;let a=await te(s,o,t);return e._refNode||(e._refNode=a),a}async function Re(e,n,t){let o={parent:e,node:e.firstChild};for(await te(n,t,o);o.node;){let i=o.node;o.node=i.nextSibling,i.parentNode?.removeChild(i)}}var ue=0,Xe="",Je="",Qe="",Ze="",ce=0;function en(){return typeof window<"u"&&typeof document<"u"}function ke(){if(ue++,ue>1||!en())return;ce=window.scrollY;let e=document.body;Xe=e.style.overflow,Je=e.style.position,Qe=e.style.top,Ze=e.style.width,e.style.overflow="hidden",(/iPhone|iPad|iPod/.test(navigator.platform)||/Mac/.test(navigator.platform)&&"ontouchend"in document)&&(e.style.position="fixed",e.style.top=`-${ce}px`,e.style.width="100%")}function Ne(){if(ue--,ue>0||!en())return;let e=document.body;e.style.overflow=Xe,e.style.position=Je,e.style.top=Qe,e.style.width=Ze,ce>0&&window.scrollTo(0,ce)}var Mn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function de(e){let n=e.querySelectorAll(Mn);if(n.length===0)return()=>{};let t=n[0],o=n[n.length-1],i=a=>{a.key==="Tab"&&(a.shiftKey&&document.activeElement===t?(a.preventDefault(),o.focus()):!a.shiftKey&&document.activeElement===o&&(a.preventDefault(),t.focus()))},s=document.activeElement;return queueMicrotask(()=>{t.focus()}),e.addEventListener("keydown",i),()=>{e.removeEventListener("keydown",i),s?.focus()}}function fe(e){let n=new WeakMap,t=new Set,o=s=>{if(s===null||typeof s!="object")return s;if(n.has(s))return n.get(s);let a=new Proxy(s,{set(u,l,c){if(Reflect.get(u,l)===c)return!0;Reflect.set(u,l,c),e();for(let g of t)g();return!0},get(u,l){let c=Reflect.get(u,l);return typeof c=="object"&&c!==null?o(c):c},deleteProperty(u,l){if(Reflect.has(u,l)){Reflect.deleteProperty(u,l),e();for(let c of t)c()}return!0}});return n.set(s,a),a},i=o({});return Object.defineProperty(i,"__watch",{value:s=>(t.add(s),()=>{t.delete(s)}),writable:!1,enumerable:!1}),i}function Me(e,n,t){let o=new AbortController,i=t?.signal;i&&(i.aborted?o.abort():i.addEventListener("abort",()=>o.abort(),{once:!0}));let s=t?.traceId??Hn(),a=t?.record!==!1,u=[],l=(async()=>{let c;try{c=await fetch(e,{method:"POST",headers:{"Content-Type":"application/json","X-Trace-Id":s,Accept:"text/event-stream",...t?.headers},body:JSON.stringify(n),signal:o.signal})}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)});return}if(!c.ok){t?.onError?.({code:Wn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:m,data:g}of On(c.body)){if(o.signal.aborted)return;Vn(u,{name:m,data:g},a),Ln(m,g,t??{})}}catch(m){if(o.signal.aborted)return;t?.onError?.({code:"provider_error",message:m instanceof Error?m.message:String(m)})}})();return{abort:()=>o.abort(),done:l,traceId:s,events:u}}function Ln(e,n,t){switch(e){case"wf:token":return t.onToken?.(n.text);case"wf:tool_call":return t.onToolCall?.(n);case"wf:tool_result":return t.onToolResult?.(n);case"wf:tool_progress":return t.onToolProgress?.(n);case"wf:step":return t.onStep?.(n);case"wf:approval_request":return t.onApproval?.(n);case"wf:usage":return t.onUsage?.(n);case"wf:done":return t.onDone?.(n);case"wf:error":return t.onError?.(n);default:return t.onEvent?.(e,n)}}async function*On(e){let n=e.getReader(),t=new TextDecoder,o="";try{for(;;){let{done:i,value:s}=await n.read();if(i)break;o+=t.decode(s,{stream:!0});let a=o.split(`
|
|
1
|
+
var je="__wfAsyncComponent";function hn(e){let n=e;return n[je]=!0,n}function X(e){return typeof e=="function"&&e?.[je]===!0}var B=Symbol("Fragment"),q=Symbol("Portal");function Te(e,n,t){return{type:e,props:qe(n),key:t??void 0}}var vn=Te;function wn(e,n,t){return Te(e,n,t)}function bn(e,n,...t){let o=qe(n??{});return t.length>0&&(o.children=t.length===1?t[0]:t),{type:e,props:o,key:n?.key??void 0}}function qe(e){if(!e)return{};let n={};for(let t of Object.keys(e))t!=="key"&&(n[t]=e[t]);return n}function Ee(e,n){return{type:q,props:{children:e,portalKey:n},key:n??void 0,_placement:"remote"}}var Cn=0,V=new Map,se=[];function F(e){se.push(e)}var ae=new WeakMap;function J(){ae=new WeakMap}function Pe(e,n){let t=ae.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}),ae.set(e,o),o}async function Fe(e,n){return Pe(e,n).promise}function Be(e){return ae.get(e)?.resolved}function xn(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),se.length>0){for(let t of se)t(n._id);if(n._customId)for(let t of se)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&&(xn(n),n._remoteEl.remove(),n._remoteEl=void 0)}function Q(){return`_wf_${Cn++}`}var Ke=new WeakMap;function Tn(e){let n=Ke.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 })")),Ke.set(e,n)}function z(e,n,t,o,i){if(t==null){if(o==null)return null;let c=U(o,i);return c==null?null:(n&&n.parentNode?n.parentNode.insertBefore(c,n):e.appendChild(c),c)}if(o==null)return n?(O(t),n.remove()):O(t),null;let s=ze(t),a=ze(o);if(s!==a){O(t);let c=U(o,i);return c==null?null:(n?.parentNode&&n.parentNode.replaceChild(c,n),c)}if(a==="text")return n&&n.textContent!==String(o)&&(n.textContent=String(o)),n;let 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&&V.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&&Sn(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=Ae(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 E=l._child;d._child=y;let C=z(e,n,E,y,m);return C||(d._refNode=null),C}if(d.type===B){let c=l._childNodes,m=Ye(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"&&Tn(n)),_e(n,l.props,d.props),Ye(n,l,d,i)}else if(n){O(t);let c=U(o,i);return c==null?null:(n.parentNode?.replaceChild(c,n),c)}return n}if(d.type===q)return ne(l,d,i),null;if(Array.isArray(o)){let c=Array.isArray(t)?t:[];le(c,o);let m=Array.from(e.childNodes),y=n?m.indexOf(n):-1,E=y>=0?Z(m.slice(y),c):Z(m,c);return ue(e,c,o,i,E,n),n}return n}var $e=new Map;function En(e){let n=$e.get(e);return n||(n=`fn:${e.name||"anon"}`,$e.set(e,n)),n}function ze(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"?En(n.type):n.type===B?"fragment":n.type===q?"portal":typeof n.type=="string"?"tag:"+n.type:"unknown"}function _e(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",Ge(l)):e.className=Ge(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 Ge(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 Se(e){if(!(e==null||typeof e!="object"))return e.key}function le(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 Ye(e,n,t,o,i){let s=ee(n.props?.children),a=ee(t.props?.children);le(s,a);let d=i??Array.from(e.childNodes),l=Z(d,s),c=ue(e,s,a,o,l,i?.[0]??null),m=[];for(let y of c)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 Xe(e){return e==null?[]:e instanceof DocumentFragment?Array.from(e.childNodes):[e]}function ue(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){O(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")&&Se(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=Se(n[g]);v!==void 0&&d.set(v,{vnode:n[g],nodes:i[g]??[],index:l++})}let c=t.map(g=>Se(g)),m=new Set(c);for(let g of[...d.keys()])if(!m.has(g)){let v=d.get(g);O(v.vnode);for(let r of v.nodes)r?.remove();d.delete(g)}let y=new Array(t.length).fill(null),E=-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<E)for(let h of u.nodes)e.insertBefore(h,C);E=Math.max(E,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)ne(u.vnode,r,o),y[g]=[];else{let p=z(e,null,u.vnode,r,o);y[g]=Xe(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]=Xe(p);for(let w of y[g])e.insertBefore(w,C);C=y[g][y[g].length-1]?.nextSibling??null}}return y}function Pn(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 Sn(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(!Pn(e[o],n[o]))return!1}else if(e[o]!==n[o])return!1}return!0}var ke="http://www.w3.org/2000/svg",Re=new Set(["svg","path","circle","line","rect","text","g","polyline","polygon","ellipse","defs","use","clipPath","mask","linearGradient","radialGradient","stop","tspan"]);function Qe(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 kn(e,n);let t=e;if(t.type===q)return Y(t,n),null;if(t.type===B){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 An(t.type,t.props,t,n);let o=t.type,i=Re.has(o)?document.createElementNS(ke,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"||Je(i,a,d);if("value"in(t.props??{})&&i instanceof HTMLSelectElement?s=t.props.value:"value"in(t.props??{})&&Je(i,"value",t.props.value),"innerHTML"in(t.props??{}))i.innerHTML=String(t.props.innerHTML??"");else{let a=Me(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 _n(e){let n=e.ui;n&&typeof n.render=="function"&&n.render(["_wf_root"])}function Ae(e,n,t,o){let i;if(X(e)){if(i=Be(e),!i)return Pe(e,o).promise.then(()=>_n(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 An(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=Ae(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 kn(e,n){let t=document.createDocumentFragment();for(let o of e){let i=U(o,n);i!=null&&t.appendChild(i)}return t}function Rn(){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=Rn(),o=document.createElement("div");o.style.pointerEvents="auto",t.appendChild(o),e._remoteEl=o;let i=ee(e.props?.children);e._child=i;for(let s of i){let a=U(s,n);a!=null&&o.appendChild(a)}}function ne(e,n,t){let o=e?._remoteEl;if(n._remoteEl=o,!o){Y(n,t);return}let i=ee(n.props?.children),s=e._child||[];n._child=i,le(s,i);let a=Z(Array.from(o.childNodes),s);ue(o,s,i,t,a,a[0]?.[0]??null)}function Me(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 Je(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 Mn(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 Ne(e){e.node=e.node?e.node.nextSibling:null}function Nn(e,n){e.node&&e.node.parentNode?e.node.parentNode.insertBefore(n,e.node):e.parent.appendChild(n)}function Ln(e,n){e.node&&e.node.parentNode?(e.node.parentNode.replaceChild(n,e.node),Ne(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 d=String(e);if(t.node&&t.node.nodeType===3)return t.node.textContent!==d&&(t.node.textContent=d),Ne(t),t.node;let l=document.createTextNode(d);return Nn(t,l),l}if(Array.isArray(e)){let d=null;for(let l of e){let c=await te(l,n,t);c!=null&&!d&&(d=c)}return d}let o=e;if(o.type===q||o.type===B){let d=o.props?.children,l=d==null?[]:Array.isArray(d)?d:[d],c=null;for(let m of l){let y=await te(m,n,t);y!=null&&!c&&(c=y)}return c}if(typeof o.type=="function")return On(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,Ne(t)):(a=Re.has(i)?document.createElementNS(ke,i):document.createElement(i),Ln(t,a)),o.el=a,_e(a,null,s),!("innerHTML"in s)){let d={parent:a,node:a.firstChild},l=Me(s.children);for(let c of l){let m=await te(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 On(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 d;X(i)?d=await Fe(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 te(s,o,t);return e._refNode||(e._refNode=a),a}async function Le(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 ce=0,Ze="",en="",nn="",tn="",de=0;function on(){return typeof window<"u"&&typeof document<"u"}function Oe(){if(ce++,ce>1||!on())return;de=window.scrollY;let e=document.body;Ze=e.style.overflow,en=e.style.position,nn=e.style.top,tn=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=`-${de}px`,e.style.width="100%")}function Ve(){if(ce--,ce>0||!on())return;let e=document.body;e.style.overflow=Ze,e.style.position=en,e.style.top=nn,e.style.width=tn,de>0&&window.scrollTo(0,de)}var Vn='a[href], button:not([disabled]), input:not([disabled]), textarea:not([disabled]), select:not([disabled]), [tabindex]:not([tabindex="-1"])';function fe(e){let n=e.querySelectorAll(Vn);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 pe(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))?(...E)=>{let C=y.apply(c,E);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 E of t)E();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 We(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??Un(),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:Dn(c.status),message:`HTTP ${c.status} ${c.statusText}`});return}try{for await(let{name:m,data:y}of In(c.body)){if(o.signal.aborted)return;Hn(d,{name:m,data:y},a),Wn(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 Wn(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*In(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: ")&&(c+=m.slice(6));if(c)try{yield{name:l,data:JSON.parse(c)}}catch{}}}}finally{n.releaseLock()}}function Vn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Wn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Hn(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function nn(e){return e.map(n=>({role:n.role,content:n.content}))}function Le(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function tn(e,n,t){t.initialMessages?e.messages=structuredClone(t.initialMessages):e.messages===void 0&&(e.messages=[]),e.input===void 0&&(e.input=""),e.streaming===void 0&&(e.streaming=!1),e.error===void 0&&(e.error=null),e.usage===void 0&&(e.usage=null),e.step===void 0&&(e.step=null);let o=null;function i(){if(!e.streaming)return;let C=e.messages[e.messages.length-1];return C&&C.role==="assistant"&&C.status==="streaming"?C:void 0}function s(C,y,v){let r=i();switch(C){case"wf:token":r&&(r.content+=y.text);break;case"wf:tool_call":{r&&(r.toolCalls||(r.toolCalls=[]),r.toolCalls.push({call:y,status:"running"}));break}case"wf:tool_progress":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.toolCallId);f&&(f.progress=d);break}case"wf:tool_result":{let d=y,f=r?.toolCalls?.find(p=>p.call.id===d.id);f&&(f.result=d,f.status=d.ok?"ok":"error");break}case"wf:approval_request":r&&(r.approval=y);break;case"wf:usage":r&&(r.usage=y);break;case"wf:step":e.step=y;break;case"wf:done":r&&(r.status="done",r.approval=void 0),e.streaming=!1,e.step=null;break;case"wf:error":r&&(r.status="error",r.error=y,r.approval=void 0),e.error=y,e.streaming=!1,e.step=null;break;default:v?.(C,y);break}}function a(){let C=t.body?t.body(e.messages):{messages:nn(e.messages)};o=n(t.url,C,{onToken:v=>s("wf:token",{text:v}),onToolCall:v=>s("wf:tool_call",v),onToolProgress:v=>s("wf:tool_progress",v),onToolResult:v=>s("wf:tool_result",v),onApproval:v=>s("wf:approval_request",v),onUsage:v=>s("wf:usage",v),onStep:v=>s("wf:step",v),onDone:v=>s("wf:done",v),onError:v=>s("wf:error",v),onEvent:(v,r)=>s(v,r,t.onEvent)},{signal:t.signal,headers:t.headers}),e.streaming=!0;let y=i();y&&o?.traceId&&(y.id=o.traceId)}function u(){if(e.streaming)return;let C=String(e.input??"").trim();C&&(e.input="",e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"user",content:C,status:"done"},{id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function l(){o?.abort(),e.streaming=!1,e.step=null;let C=e.messages[e.messages.length-1];C&&C.role==="assistant"&&C.status==="streaming"&&(!C.content&&(!C.toolCalls||C.toolCalls.length===0)?e.messages.pop():C.status="done")}function c(){if(e.streaming)return;let C=-1;for(let y=e.messages.length-1;y>=0;y--)if(e.messages[y].role==="user"){C=y;break}C!==-1&&(e.messages.splice(C+1),e.error=null,e.usage=null,e.step=null,e.messages.push({id:Le(),role:"assistant",content:"",status:"streaming",toolCalls:[]}),a())}function m(){o?.abort(),e.messages=[],e.input="",e.streaming=!1,e.error=null,e.usage=null,e.step=null}async function g(C,y){let v=e.messages[e.messages.length-1],r=v?.role==="assistant"?v.approval:void 0;if(r&&(v.approval=void 0,!!t.approveUrl))try{await fetch(t.approveUrl,{method:"POST",headers:{"Content-Type":"application/json",...t.headers},body:JSON.stringify({id:r.id,decision:C,note:y}),signal:t.signal})}catch(d){if(t.signal?.aborted)return;e.error={code:"provider_error",message:d instanceof Error?d.message:String(d)}}}function P(){o?.abort(),o=null}return{send:u,stop:l,retry:c,clear:m,approve:g,dispose:P}}function pe(e,n="bottom",t=6,o=!0){switch(n){case"bottom":return{top:e.bottom+t,left:o?e.left+e.width/2:e.left};case"top":return{top:e.top-t,left:o?e.left+e.width/2:e.left};case"left":return{top:o?e.top+e.height/2:e.top,left:e.left-t};case"right":return{top:o?e.top+e.height/2:e.top,left:e.right+t}}}function In(e,n="bottom",t=6,o=!0){return pe(e.getBoundingClientRect(),n,t,o)}function me(e,n,t=8){if(!n)return e;let o=n.getBoundingClientRect();if(o.width===0&&o.height===0)return e;let i=Number.parseFloat(n.style.top)||o.top,s=Number.parseFloat(n.style.left)||o.left,a=e.top-i,u=e.left-s,l={top:o.top+a,bottom:o.bottom+a,left:o.left+u,right:o.right+u},c=window.innerWidth,m=window.innerHeight,g=e.top,P=e.left;return l.bottom>m-t&&(g=Math.max(t,g-(l.bottom-(m-t)))),l.top<t&&(g=Math.max(t,g+(t-l.top))),l.right>c-t&&(P=Math.max(t,P-(l.right-(c-t)))),l.left<t&&(P=Math.max(t,P+(t-l.left))),{top:g,left:P,width:e.width}}var on=new Set,oe=new Map;function rn(e){let{ctx:n,renderByIds:t,getSelfId:o,dirtyBatch:i,dirtySet:s,mediaRegistry:a,popupTrackers:u,scrollTrackers:l,schedulePopupRecompute:c,ensurePopupListeners:m,isRendering:g,isMounting:P,setMounting:C,endMounting:y}=e;return{_selfId:"_wf_root",_ctxVersion:0,_dirtySet:s,setMounting:C,endMounting:y,bumpCtxVersion:function(){this._ctxVersion++},render:function(r){if(g()){if(P())return;this._pendingRender||(this._pendingRender=!0,queueMicrotask(()=>{this._pendingRender=!1,this.render(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}t(r)},dirty:function(r){if(!P()){if(g()){this._pendingDirty||(this._pendingDirty=!0,queueMicrotask(()=>{this._pendingDirty=!1,this.dirty(r)}));return}if(!r||r.length===0){let d=o(this);if(d)r=[d];else return}for(let d of r)d&&(i.add(d),s.add(d));this._dirtyScheduled||(this._dirtyScheduled=!0,queueMicrotask(()=>{this._dirtyScheduled=!1;let d=[...i];i.clear(),d.length>0&&t(d)}))}},$:function(){let r=this;return r._$cache||(r._$cache=fe(()=>{let d=r._selfVNode?._id??o(r);d&&n.ui.dirty([d])})),r._$cache},useChat:function(r){let d=this.$(),f=tn(d,Me,r);return Object.assign(d,{send:f.send,stop:f.stop,retry:f.retry,clear:f.clear,approve:f.approve,dispose:f.dispose}),d},useMedia:function(r,d){let p=`media:${o(this)}:${r}`;if(!a.has(p)){let h=window.matchMedia(r);d(h.matches);let b=E=>d(E.matches);h.addEventListener("change",b),a.set(p,{mql:h,handler:b})}},useBreakpoint:function(r,d){let f=typeof r=="function"?{mobile:"(max-width: 639px)",tablet:"(min-width: 640px) and (max-width: 1023px)",desktop:"(min-width: 1024px)"}:r,p=typeof r=="function"?r:d,b=`bp:${o(this)}`;function E(){for(let[x,k]of Object.entries(f))if(window.matchMedia(k).matches)return x;return Object.keys(f)[0]??""}if(!a.has(b)){p(E());let x=[];for(let k of Object.values(f)){let T=window.matchMedia(k),_=()=>p(E());T.addEventListener("change",_),x.push({mql:T,handler:_})}a.set(b,{mqls:x})}},usePopupPosition:function(r){let d=o(this),f={top:0,left:0,refresh:()=>{}};if(!d)return f;let p={pos:f,getEl:r.el,isOpen:r.isOpen,compute:r.compute,panel:r.panel,margin:r.margin??8};return u.set(d,p),m(),f.refresh=()=>{let h=p.getEl();if(!h)return;let b=p.compute(h.getBoundingClientRect());Object.assign(f,me(b,p.panel?.(),p.margin))},f},useHoverCapable:function(){return typeof window<"u"&&!!window.matchMedia?.("(hover: hover)").matches},useStableRef:function(r,d){return p=>{p?r(p):d?.()}},useVisualViewport:function(){let r=o(this),d={height:window.innerHeight,offsetTop:0,keyboardOpen:!1},f=()=>{n.ui&&n.ui.dirty(r?[r]:void 0)},p=()=>{let b=window.visualViewport;d.height=b?.height??window.innerHeight,d.offsetTop=b?.offsetTop??0,d.keyboardOpen=d.height<window.innerHeight*.9,f()},h=window.visualViewport;return h?.addEventListener?(h.addEventListener("resize",p),h.addEventListener("scroll",p)):window.addEventListener("resize",p),r&&K(b=>{b===r&&(h?.removeEventListener?(h.removeEventListener("resize",p),h.removeEventListener("scroll",p)):window.removeEventListener("resize",p))}),d},usePopup:function(r){let d=o(this),f=this.useHoverCapable(),p=()=>typeof r.trigger=="function"?r.trigger():r.trigger,h=r.open!==void 0,b=()=>!!r.disabled?.(),E=()=>h?typeof r.open=="function"?!!r.open():!!r.open:r.isOpen(),x=A=>{b()||(h?r.onOpenChange?.(A):r.setOpen(A))},k=()=>{let A=r.placement;return typeof A=="function"?A():A??"bottom"},T=null,_=!1,w=n.ui.usePopupPosition({el:r.el,isOpen:()=>E(),compute:A=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return pe(A,k(),r.gap??6,r.center!==!1)},panel:()=>T,margin:r.margin??8}),R=A=>{if(r.closeOnOutside===!1||!E())return;let W=A.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||T&&T.contains(W)||x(!1)},M=A=>{r.closeOnEscape!==!1&&(A.key!=="Escape"||!E()||x(!1))};document.addEventListener("mousedown",R),document.addEventListener("keydown",M),d&&K(A=>{A===d&&(document.removeEventListener("mousedown",R),document.removeEventListener("keydown",M))});let S={},j=A=>typeof A=="function"?A():A??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,I,re=()=>{clearTimeout(L),clearTimeout(I),L=void 0,I=void 0};if(p()==="hover")f?(S.onMouseEnter=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onMouseLeave=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))}):S.onClick=()=>x(!E()),S.onFocus=()=>{b()||(clearTimeout(I),I=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},S.onBlur=()=>{b()||(clearTimeout(L),L=void 0,I=setTimeout(()=>{I=void 0,x(!1)},H()))};else if(p()==="click")S.onClick=()=>x(!E());else if(p()==="longpress"){let A,W=0,$=0,F=()=>{clearTimeout(A),A=void 0};S.onPointerDown=U=>{b()||(W=U.clientX??0,$=U.clientY??0,F(),A=setTimeout(()=>{A=void 0,r.onTrigger?.({clientX:W,clientY:$}),x(!0)},r.longPressDuration??500))},S.onPointerUp=F,S.onPointerLeave=F,S.onPointerMove=U=>{let he=Math.abs((U.clientX??0)-W),ve=Math.abs((U.clientY??0)-$);(he>10||ve>10)&&F()},S.onContextMenu=U=>{U.preventDefault(),r.onTrigger?.({clientX:U.clientX??0,clientY:U.clientY??0}),x(!0)}}S.onKeyDown=A=>{A.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},d&&K(A=>{A===d&&re()});let dn=A=>{if(A){T=A;let W=()=>w.refresh();A.addEventListener("animationend",W,{once:!0})}else T=null},fn=(A,W="popover")=>{if(b())return null;if(!E())return _=!1,null;_||(w.refresh(),_=!0);let F=A.props??{},U=F.ref,he=["wf-popup",F.class].filter(Boolean).join(" "),ve={...F.style??{},position:"fixed",top:`${w.top}px`,left:`${w.left}px`,maxWidth:r.width!==void 0?`min(${r.width}px, calc(100vw - 32px))`:"calc(100vw - 32px)"},pn={...A,props:{...F,class:he,style:ve,ref:He=>{dn(He),U&&U(He)}}};return be(pn,W)};return{open:E(),setOpen:x,wrapProps:S,portal:fn,refresh:()=>w.refresh()}},useLongPress:function(r){let{onLongPress:d,duration:f=500}=r,p,h=0,b=0,E=null,x=()=>{clearTimeout(p),p=void 0};return{onPointerDown:k=>{h=k.clientX??0,b=k.clientY??0,E=k,x(),p=setTimeout(()=>{p=void 0,d(E)},f)},onPointerUp:x,onPointerLeave:x,onPointerMove:k=>{let T=Math.abs((k.clientX??0)-h),_=Math.abs((k.clientY??0)-b);(T>10||_>10)&&x()},onContextMenu:k=>{k.preventDefault(),d(k)}}},useInView:function(r){let d=o(this),f={isIn:!1,ready:!1,observe:x,refresh:k,disconnect:T},p=null,h=null,b=()=>{n.ui&&n.ui.dirty(d?[d]:void 0)};function E(){if(h?.disconnect(),h=null,!p)return;let _=typeof r.rootMargin=="function"?r.rootMargin():r.rootMargin,w=typeof r.threshold=="function"?r.threshold():r.threshold;h=new IntersectionObserver(R=>{let M=R[R.length-1];if(!M)return;let S=M.isIntersecting,j=S!==f.isIn,N=!f.ready;f.isIn=S,f.ready=!0,r.onChange?.(M,S),(j||N)&&b()},{root:r.root?r.root():null,rootMargin:_??"0px",threshold:w??0}),h.observe(p)}function x(_){p=_,_?E():(h?.disconnect(),h=null,f.isIn=!1)}function k(){E()}function T(){h?.disconnect(),h=null}return f},useScrollPosition:function(r){let d=o(this),f={y:0,refresh(){let h=p.getScroller();f.y=h instanceof Window?document.scrollingElement?.scrollTop??h.scrollY??0:h.scrollTop??0}},p={handle:f,getScroller:r.getScroller??(()=>window)};return d?(l.set(d,p),m(),f.refresh(),f):(f.refresh(),f)},useAsync:function(r){let d=o(this),f=fe(()=>{n.ui&&n.ui.dirty(d?[d]:void 0)});f.loading=!0;let p=0,h=()=>{let b=++p;f.loading=!0,f.error=null,Promise.resolve().then(()=>r()).then(E=>{p===b&&(f.data=E,f.loading=!1)}).catch(E=>{p===b&&(f.error=E,f.loading=!1)})};return h(),f.reload=h,f},useControlled:function(r){let d=o(this),f=r.value!==void 0;f&&!r.onChange&&r.name&&(on.has(r.name)||(on.add(r.name),console.warn(`[weifuwu/${r.name}] \u53D7\u63A7\u6A21\u5F0F\uFF08value \u5DF2\u4F20\uFF09\u4F46\u672A\u63D0\u4F9B onChange\uFF0C\u4EA4\u4E92\u65E0\u6CD5\u751F\u6548\u3002
|
|
5
|
-
\u975E\u53D7\u63A7\uFF1A\u53BB\u6389 value\uFF1B\u53D7\u63A7\uFF1A\u4F20\u5165 onChange={(v) => setValue(v)}`))),!f&&d&&!oe.has(d)&&(oe.set(d,r.value),K(h=>{oe.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}d&&oe.set(d,h),n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{value:f?r.value:d?oe.get(d):r.value,setValue:p,controlled:f}},usePresence:function(r){let d=o(this),f="closed",p,h=()=>{f="closed",n.ui&&(d?n.ui.dirty([d]):n.ui.render())};return{get phase(){return f},ref:E=>{E?p||(p=()=>{f==="exit"&&h()},E.addEventListener("animationend",p)):(E?.removeEventListener("animationend",p),p=void 0)},sync:E=>(E?f="open":f==="open"&&(f="exit"),f)}},useDialog:function(r){let d=o(this),f,p=null,h=this.usePresence(r);return{get phase(){return h.phase},rootRef:x=>{x?(ke(),p&&(f=de(p)),h.ref(x)):(Ne(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=de(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let d=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),d&&K(f=>{f===d&&window.removeEventListener("keydown",r)}),()=>window.removeEventListener("keydown",r))},useDrag:function(r){let d=0,f=0,p=!1,h=x=>{p&&r.onMove(x,{x:x.clientX-d,y:x.clientY-f})},b=x=>{p&&(p=!1,window.removeEventListener("pointermove",h),window.removeEventListener("pointerup",b),r.onEnd?.(x))};return{onPointerDown:x=>{p||(x.preventDefault(),p=!0,d=x.clientX,f=x.clientY,window.addEventListener("pointermove",h),window.addEventListener("pointerup",b),r.onStart?.(x))}}},useDragDrop:function(r){let d={};r.onDrop&&(d.onDrop=p=>{p.preventDefault(),r.onDrop(p)}),r.onDragOver&&(d.onDragOver=p=>{p.preventDefault(),r.onDragOver(p)}),r.onDragLeave&&(d.onDragLeave=p=>r.onDragLeave(p));let f={draggable:!0};return r.onDragStart&&(f.onDragStart=p=>r.onDragStart(p)),r.onDragEnd&&(f.onDragEnd=p=>r.onDragEnd(p)),{dropProps:d,dragProps:f}},useReducedMotion:function(){return typeof window<"u"&&!!window.matchMedia?.("(prefers-reduced-motion: reduce)").matches},useAnimationEnd:function(r,d){let f=null,p=()=>{r(),d?.once&&f&&f.removeEventListener("animationend",p)};return b=>{b?(f=b,b.addEventListener("animationend",p)):f&&(f.removeEventListener("animationend",p),f=null)}},useTween:function(r,d){let f=o(this),p=this.useReducedMotion(),h=d?.duration??400,b=d?.ease==="linear"?w=>w:w=>1-Math.pow(1-w,3),E,x=r,k={value:p?r:0,reset:()=>{}},T=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=w=>{if(x=w,p){k.value=w,T();return}if(w===k.value)return;E&&cancelAnimationFrame(E);let R=k.value,M=performance.now(),S=j=>{let N=Math.min(1,(j-M)/h);k.value=Math.round(R+(w-R)*b(N)),N<1?(E=requestAnimationFrame(S),T()):(E=void 0,T())};E=requestAnimationFrame(S)};return k.reset=w=>{w===x&&E||_(w)},queueMicrotask(()=>_(r)),k},selfId:function(r){if(typeof r!="string"||!r)throw new Error(`[weifuwu] selfId requires a non-empty string, got ${typeof r}`);if(V.has(r))throw new Error(`[weifuwu] Duplicate component ID: "${r}". Each component must have a unique custom ID.`);let d=this._selfVNode;d&&(d._customId=r,V.set(r,d))}}}function sn(){return{activeElement:()=>typeof document<"u"?document.activeElement:null,byId:e=>typeof document<"u"?document.getElementById(e):null,query:e=>typeof document<"u"?document.querySelector(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},copyText:async e=>{let n=typeof window<"u"?window:null;if(n?.navigator?.clipboard?.writeText)try{return await n.navigator.clipboard.writeText(e),!0}catch{}try{if(typeof document>"u")return!1;let t=document.createElement("textarea");t.value=e,t.style.position="fixed",t.style.opacity="0",document.body.appendChild(t),t.select();let o=document.execCommand("copy");return document.body.removeChild(t),o}catch{return!1}},execCommand:(e,n)=>typeof document<"u"?document.execCommand(e,!1,n):!1,queryCommandState:e=>typeof document<"u"?document.queryCommandState(e):!1,queryCommandValue:e=>typeof document<"u"?document.queryCommandValue(e):"",selectionText:()=>typeof window<"u"?window.getSelection?.()?.toString()??null:null,getSelection:()=>typeof window<"u"?window.getSelection():null,viewportHeight:()=>typeof window<"u"?window.innerHeight:0,scrollTop:()=>{let e=typeof document<"u"?document:null,n=typeof window<"u"?window:null;return e?.scrollingElement?.scrollTop??n?.scrollY??0},hash:()=>typeof window<"u"?window.location?.hash??"":"",setHash:e=>{typeof window<"u"&&(window.location.hash=e)},timeout:(e,n)=>typeof window<"u"?window.setTimeout(e,n):0,rootElement:()=>typeof document<"u"?document.documentElement:null,storageGet:e=>{try{return typeof window<"u"?window.localStorage?.getItem(e)??null:null}catch{return null}},storageSet:(e,n)=>{try{typeof window<"u"&&window.localStorage?.setItem(e,n)}catch{}}}}function Dn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,u=[];function l(T){u.push(a),a=T}function c(){a=u.pop()??!1}let m=new Set,g=!1,P=new Map;function C(T){let _=P.get(T);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:w,handler:R})=>w.removeEventListener("change",R)),P.delete(T))}let y=new Map,v=!1,r=0;function d(){v||(v=!0,window.addEventListener("scroll",h,{capture:!0,passive:!0}),window.addEventListener("resize",h))}function f(){v&&(window.removeEventListener("scroll",h,{capture:!0}),window.removeEventListener("resize",h),v=!1)}let p=new Map;function h(){r||(r=requestAnimationFrame(()=>{r=0;let T=[];for(let[_,w]of y){if(!w.isOpen())continue;let R=w.getEl();if(!R)continue;let M=w.compute(R.getBoundingClientRect());Object.assign(w.pos,me(M,w.panel?.(),w.margin)),T.push(_)}for(let[_,w]of p){let R=w.getScroller(),M=R instanceof Window?document.scrollingElement?.scrollTop??R.scrollY??0:R.scrollTop??0;M!==w.handle.y&&(w.handle.y=M,T.push(_))}T.length>0&&n.ui.render(T)}))}function b(T){if(!s){s=!0;for(let _ of T){let w=V.get(_);if(!w||!w._render)continue;n.ui._dirtySet?.delete(_);let R=w._child,M=w._render(w.props);if(w._child=M,R&&R._placement==="remote"||M&&M._placement==="remote"){R&&M?ne(R,M,n):M?G(M,n):R&&O(R);continue}if(!w._parentNode&&w._refNode&&(w._parentNode=w._refNode.parentNode),w._parentNode){let S=z(w._parentNode,w._refNode??null,R,M,n);S&&S!==w._refNode?w._refNode=S:S||(w._refNode=null)}}s=!1,E()}}function E(){let T=n.ui;m.size>0&&!T._dirtyScheduled&&(T._dirtyScheduled=!0,queueMicrotask(()=>{T._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&b(_)}))}function x(T){return T?._selfId??n.ui?._selfId}let k={get ctx(){return n},use(T){return e.push(T),k},async mount(T,_,w){o=_;for(let N of e)n=await N(n);let R=typeof T=="string"?document.querySelector(T):T;if(!R)throw new Error(`mount target not found: ${T}`);t=R;let M=!!w?.hydrate;M||(t.innerHTML="");let S=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))S.set(N,{value:H});if(n.data={async get(N,H){let L=S.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let I=Promise.resolve().then(()=>H()).then(re=>(S.set(N,{value:re}),re));return S.set(N,{promise:I}),I},set(N,H){S.set(N,{value:H})},has(N){return S.has(N)}},K(N=>{for(let H of[...P.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&C(H);y.delete(N),p.delete(N)}),n.browser=sn(),n.ui=rn({ctx:n,renderByIds:b,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:P,popupTrackers:y,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:d,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Un(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=M?t.firstChild:null,V.set("_wf_root",i),M)await Re(t,i,n);else{let N=Ge(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,E()},destroy(){f(),y.clear(),p.clear();for(let T of[...P.keys()])C(T);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return k}function Un(e,n){return{type:e,props:{},key:void 0}}function jn(e,n){if(!n||n==="/")return e||"/";let t=e.endsWith("/")?e.slice(0,-1):e,o=n.startsWith("/")?n:"/"+n;return t+o}function qn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function Oe(e,n="",t=[]){let o=[];for(let i of e){let s=jn(n,i.path),{re:a,keys:u}=qn(s),l=[...t,i];o.push({re:a,keys:u,def:i,chain:l}),i.children&&o.push(...Oe(i.children,s,l))}return o}function an(e,n){let t=null;for(let o of n)e.match(o.re)&&(!t||o.chain.length>t.chain.length)&&(t=o);return t}function ln(e,n){let t={},o=e.match(n.re);if(o)for(let i=0;i<n.keys.length;i++)t[n.keys[i]]=decodeURIComponent(o[i+1]);return t}function Fn(e){let n=Oe(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=an(s,n);if(a){let u=a.chain[a.chain.length-1];return{path:a.def.path,params:ln(s,a),query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:a.chain,title:u?.title??""}}return{path:s,params:{},query:Object.fromEntries(new URLSearchParams(window.location.search)),chain:e.notFound?[{component:e.notFound,title:"Not Found"}]:[],title:""}}return s=>{let a=i(o());s.route=a,a.title&&(document.title=a.title),s.app||(s.app={}),s.app.navigate=l=>{if(J(),t==="hash"){window.location.hash="#"+l;let c=i(l);s.route=c}else{window.history.pushState({},"",l);let c=i(l);s.route=c}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let u=()=>{J();let l=i(o());s.route=l,s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};return window.addEventListener("popstate",u),t==="hash"&&window.addEventListener("hashchange",u),s}}function Bn(e,n){let t=n.route?._rvDepth??0;return()=>{let o=n.route;if(!o?.chain?.length||t>=o.chain.length)return null;let i=o.chain[t],s=i.layout??i.component;return s?(i.layout&&(o._rvDepth=t+1),{type:s,props:{},key:void 0}):null}}function Y(e,n){return Object.assign(Object.create(e),n)}function Kn(e={}){let n=e.url??"/ws",t=e.reconnectInterval??3e3,o=e.maxReconnect??10,i=e.pingInterval??3e4,s=e.pingTimeout??1e4;return a=>{let u=new Set,l=null,c=0,m=null,g=null,P=null,C=!1,y={isConnected:!1,onMessage:p=>(u.add(p),()=>{u.delete(p)}),send:p=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify(p))},_connect:v,close:()=>{C=!0,f(),l?.close(),l=null,y.isConnected=!1}};async function v(){if(!C)try{l=new WebSocket(n),l.onopen=()=>{y.isConnected=!0,c=0,r()},l.onmessage=p=>{try{let h=JSON.parse(p.data);for(let b of u)b(h)}catch{}d()},l.onclose=()=>{y.isConnected=!1,f(),!C&&c<o&&(c++,m=setTimeout(v,t*Math.min(c,5)))},l.onerror=()=>{l?.close()}}catch{C||(m=setTimeout(v,t))}}function r(){i<=0||(g=setInterval(()=>{l?.readyState===WebSocket.OPEN&&l.send(JSON.stringify({type:"ping"})),P=setTimeout(()=>{l?.close()},s)},i))}function d(){clearTimeout(P)}function f(){clearInterval(g),clearTimeout(P),clearTimeout(m)}return v(),Y(a,{ws:y})}}function $n(e){let n={baseURL:e?.baseURL??"",headers:{"Content-Type":"application/json",...e?.headers}},t=e?.onRequest,o=e?.onResponse,i=e?.timeout??0;async function s(a,u,l,c){let m=n.baseURL+u,g={method:a,headers:{...n.headers,...c?.headers}},P=e?.token?.();P&&!g.headers.Authorization&&(g.headers.Authorization=`Bearer ${P}`);let C=i>0,y=!!c?.signal,v=null,r=null;(C||y)&&(v=new AbortController,g.signal=v.signal,C&&(r=setTimeout(()=>v.abort(new Error("Request timed out")),i)),y&&c.signal.addEventListener("abort",()=>v.abort())),l!==void 0&&a!=="GET"&&a!=="HEAD"&&(g.body=JSON.stringify(l));let d={url:m,init:g};t&&(d=t(d));try{let f=await fetch(d.url,d.init);if(o)return o(f);if(!f.ok){let b=await f.text().catch(()=>"");throw new ye(f.status,b||f.statusText)}let p=f.headers.get("content-length");if(f.status===204||p==="0")return;let h=(f.headers.get("content-type")||"").toLowerCase();return h.includes("application/json")||h.includes("json")?f.json():f.text()}finally{r&&clearTimeout(r)}}return a=>Y(a,{api:{get:(l,c)=>s("GET",l,void 0,c),post:(l,c,m)=>s("POST",l,c,m),put:(l,c,m)=>s("PUT",l,c,m),patch:(l,c,m)=>s("PATCH",l,c,m),delete:(l,c)=>s("DELETE",l,void 0,c)}})}var ye=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function zn(e){try{let n=e.split(".");if(n.length!==3)return null;let t=n[1].replace(/-/g,"+").replace(/_/g,"/");return JSON.parse(atob(t))}catch{return null}}function Yn(e){let n=zn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Gn(e){let n=e?.storage??localStorage,t=e?.tokenKey??"weifuwu_token",o=e?.userKey??"weifuwu_user",i=e?.refreshTokenKey??"weifuwu_refresh",s=e?.refreshEndpoint??"/api/auth/refresh";return a=>{let u=n.getItem(t),l=n.getItem(o),c={token:u,user:l?JSON.parse(l):null,get isLoggedIn(){return this.token!==null},login(m,g,P){c.token=m,c.user=g,n.setItem(t,m),n.setItem(o,JSON.stringify(g)),P&&n.setItem(i,P)},logout(){c.token=null,c.user=null,n.removeItem(t),n.removeItem(o),n.removeItem(i)},setUser(m){c.user=m,n.setItem(o,JSON.stringify(m))},async refresh(){let m=n.getItem(i);if(!m)return!1;try{let g=await fetch(s,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({refreshToken:m})});if(!g.ok)return c.logout(),!1;let P=await g.json();return c.token=P.token,n.setItem(t,P.token),P.refreshToken&&n.setItem(i,P.refreshToken),!0}catch{return!1}}};return u&&Yn(u)&&c.refresh().catch(()=>{}),Y(a,{auth:c})}}function Xn(e,n){let t=null;return o=>{if(t){let s=o.fallback;return typeof s=="function"?s({error:t}):s??null}n.ui._errorHandler=s=>{t=s,n.ui.render()};let i=o.children;try{return i??null}catch(s){t=s;let a=o.fallback;return typeof a=="function"?a({error:s}):a??null}}}var Ve={components:{Button:{loading:"\u52A0\u8F7D\u4E2D..."},FileUpload:{placeholder:"\u70B9\u51FB\u6216\u62D6\u62FD\u4E0A\u4F20\u6587\u4EF6",supportedFormats:"\u652F\u6301\u683C\u5F0F: ",maxSize:"\u6700\u5927 ",remove:"\u5220\u9664"},Pagination:{ariaLabel:"\u5206\u9875"},ProgressBar:{ariaLabel:"\u8FDB\u5EA6"},Switch:{ariaLabel:"\u5207\u6362"},Breadcrumb:{ariaLabel:"\u9762\u5305\u5C51"},Modal:{ariaLabel:"\u5F39\u7A97",closeAria:"\u5173\u95ED"},Confirm:{confirmText:"\u786E\u5B9A",cancelText:"\u53D6\u6D88"},Drawer:{ariaLabel:"\u4FA7\u8FB9\u9762\u677F",closeAria:"\u5173\u95ED"},DatePicker:{w0:"\u65E5",w1:"\u4E00",w2:"\u4E8C",w3:"\u4E09",w4:"\u56DB",w5:"\u4E94",w6:"\u516D",hour:"\u65F6",minute:"\u5206",time:"\u65F6\u95F4",confirm:"\u786E\u5B9A",cancel:"\u53D6\u6D88",placeholder:"\u9009\u62E9\u65E5\u671F"}}};var We={components:{Button:{loading:"Loading..."},FileUpload:{placeholder:"Click or drag to upload",supportedFormats:"Supported formats: ",maxSize:"Max size: ",remove:"Remove"},Pagination:{ariaLabel:"Pagination"},ProgressBar:{ariaLabel:"Progress"},Switch:{ariaLabel:"Toggle"},Breadcrumb:{ariaLabel:"Breadcrumb"},Modal:{ariaLabel:"Dialog",closeAria:"Close"},Confirm:{confirmText:"OK",cancelText:"Cancel"},Drawer:{ariaLabel:"Panel",closeAria:"Close"},DatePicker:{w0:"Su",w1:"Mo",w2:"Tu",w3:"We",w4:"Th",w5:"Fr",w6:"Sa",hour:"Hour",minute:"Min",time:"Time",confirm:"OK",cancel:"Cancel",placeholder:"Pick a date"}}};var ge={"zh-CN":Ve,"en-US":We};function un(e){if(ge[e])return e;let n=e.split("-")[0];return Object.keys(ge).find(o=>o.startsWith(n))??"zh-CN"}function Jn(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=un(n),s=ge[i],a=cn(s,t,o),u={locale:i,t:(l,c)=>a.messages?.[l]??c??l,setLocale:()=>{},components:a.components};return l=>(l.i18n=u,u.setLocale=c=>{let m=un(c),g=ge[m];g&&(a=cn(g,t,o),u.locale=m,u.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function cn(e,n,t){return{messages:{...e?.messages,...n},components:Qn(e?.components??{},t)}}function Qn(e,n){let t={...e};for(let o of Object.keys(n))typeof n[o]=="object"&&n[o]!==null&&typeof t[o]=="object"?t[o]={...t[o],...n[o]}:t[o]=n[o];return t}function Zn(e,n,t=400){let o=!1,i=()=>{o||(o=!0,e.removeEventListener("animationend",i),clearTimeout(s),n())};e.addEventListener("animationend",i);let s=setTimeout(i,t)}export{ye as ApiError,Xn as ErrorBoundary,B as Fragment,q as Portal,Bn as RouteView,Me as aiStream,Zn as animateOut,$n as api,mn as asyncComponent,Gn as auth,O as callRefCleanup,J as clearAsyncComponentCache,In as computeFixedPos,pe as computeFixedPosRect,Dn as createApp,be as createPortal,fe as createReactiveState,We as enUS,Y as extendCtx,hn as h,Re as hydrateVNode,Jn as i18n,X as isAsyncComponent,we as jsx,gn as jsxDEV,yn as jsxs,ke as lockScroll,Sn as mountVNode,z as patchValue,Fn as router,nn as toChatMessages,de as trapFocus,Ne as unlockScroll,Kn as ws,Ve as zhCN};
|
|
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 Hn(e,n,t){t&&(e.length>=1e3&&e.shift(),e.push(n))}function Dn(e){return e===401||e===403?"auth_failed":e===429?"rate_limited":e>=500?"provider_error":"invalid_request"}function Un(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`trace-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function rn(e){return e.map(n=>({role:n.role,content:n.content}))}function Ie(){return typeof crypto<"u"&&typeof crypto.randomUUID=="function"?crypto.randomUUID():`msg-${Date.now()}-${Math.random().toString(36).slice(2,10)}`}function sn(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:rn(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:Ie(),role:"user",content:C,status:"done"},{id:Ie(),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:Ie(),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 E(){o?.abort(),o=null}return{send:d,stop:l,retry:c,clear:m,approve:y,dispose:E}}function me(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 jn(e,n="bottom",t=6,o=!0){return me(e.getBoundingClientRect(),n,t,o)}function ye(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,E=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&&(E=Math.max(t,E-(l.right-(c-t)))),l.left<t&&(E=Math.max(t,E+(t-l.left))),{top:y,left:E,width:e.width}}var an=new Set,oe=new Map,ge=new Map,re=new Map;function ln(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:E,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(E())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(!E()){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=pe(()=>{let u=r._selfVNode?._id??o(r);u&&n.ui.dirty([u])})),r._$cache},useChat:function(r){let u=this.$(),f=sn(u,We,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 P=window.matchMedia(M),_=()=>p(T());P.addEventListener("change",_),x.push({mql:P,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,ye(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&&F(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=S=>{w()||(h?r.onOpenChange?.(S):r.setOpen(S))},M=()=>{let S=r.placement;return typeof S=="function"?S():S??"bottom"},P=null,_=!1,b=n.ui.usePopupPosition({el:r.el,isOpen:()=>T(),compute:S=>{if(r.position){let W=r.position();return{top:W.y,left:W.x}}return me(S,M(),r.gap??6,r.center!==!1)},panel:()=>P,margin:r.margin??8}),k=S=>{if(r.closeOnOutside===!1||!T())return;let W=S.target;if(!(W instanceof Node))return;let $=r.el();$&&$.contains(W)||P&&P.contains(W)||x(!1)},R=S=>{r.closeOnEscape!==!1&&(S.key!=="Escape"||!T()||x(!1))};document.addEventListener("mousedown",k),document.addEventListener("keydown",R),u&&F(S=>{S===u&&(document.removeEventListener("mousedown",k),document.removeEventListener("keydown",R))});let A={},j=S=>typeof S=="function"?S():S??0,N=()=>j(r.openDelay),H=()=>j(r.closeDelay),L,D,ie=()=>{clearTimeout(L),clearTimeout(D),L=void 0,D=void 0};if(p()==="hover")f?(A.onMouseEnter=()=>{w()||(clearTimeout(D),D=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},A.onMouseLeave=()=>{w()||(clearTimeout(L),L=void 0,D=setTimeout(()=>{D=void 0,x(!1)},H()))}):A.onClick=()=>x(!T()),A.onFocus=()=>{w()||(clearTimeout(D),D=void 0,L=setTimeout(()=>{L=void 0,x(!0)},N()))},A.onBlur=()=>{w()||(clearTimeout(L),L=void 0,D=setTimeout(()=>{D=void 0,x(!1)},H()))};else if(p()==="click")A.onClick=()=>x(!T());else if(p()==="longpress"){let S,W=0,$=0,K=()=>{clearTimeout(S),S=void 0};A.onPointerDown=I=>{w()||(W=I.clientX??0,$=I.clientY??0,K(),S=setTimeout(()=>{S=void 0,r.onTrigger?.({clientX:W,clientY:$}),x(!0)},r.longPressDuration??500))},A.onPointerUp=K,A.onPointerLeave=K,A.onPointerMove=I=>{let Ce=Math.abs((I.clientX??0)-W),xe=Math.abs((I.clientY??0)-$);(Ce>10||xe>10)&&K()},A.onContextMenu=I=>{I.preventDefault(),r.onTrigger?.({clientX:I.clientX??0,clientY:I.clientY??0}),x(!0)}}A.onKeyDown=S=>{S.key==="Escape"&&r.closeOnEscape!==!1&&x(!1)},u&&F(S=>{S===u&&ie()});let mn=S=>{if(S){P=S;let W=()=>b.refresh();S.addEventListener("animationend",W,{once:!0})}else P=null},we=null,be=null,yn=S=>{mn(S),be&&be(S)};return{get open(){return T()},setOpen:x,wrapProps:A,portal:(S,W="popover")=>{if(w())return null;if(!T())return _=!1,we=null,null;let K=r.el();(!_||K!==we)&&(K?b.refresh():queueMicrotask(()=>{T()&&b.refresh()}),_=!0,we=K);let I=S.props??{};be=I.ref??null;let Ce=["wf-popup",I.class].filter(Boolean).join(" "),xe={...I.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)"},gn={...S,props:{...I,class:Ce,style:xe,ref:yn}};return Ee(gn,W)},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 P=Math.abs((M.clientX??0)-h),_=Math.abs((M.clientY??0)-w);(P>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:P},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,j=A!==f.isIn,N=!f.ready;f.isIn=A,f.ready=!0,r.onChange?.(R,A),(j||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 P(){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=pe(()=>{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&&(an.has(r.name)||(an.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&&!oe.has(u)&&(oe.set(u,r.value),F(h=>{oe.delete(h)}));let p=h=>{if(f){r.onChange?.(h);return}u&&oe.set(u,h),n.ui&&(u?n.ui.dirty([u]):n.ui.render())};return{value:f?r.value:u?oe.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&&!ge.has(u)&&(ge.set(u,{keyword:"",selectedLabel:""}),F(w=>{ge.delete(w)}));let p=u?ge.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&&!re.has(u)&&(re.set(u,!1),F(T=>{re.delete(T)}));let f=r.open!==void 0,p=()=>f?!!r.open:u?re.get(u)??!1:!1,h=()=>{u?n.ui?.dirty([u]):n.ui?.render()},w=T=>{if(f){r.onOpenChange?.(T);return}u&&re.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?(Oe(),p&&(f=fe(p)),h.ref(x)):(Ve(),f?.(),h.ref(null))},panelRef:x=>{p=x,x&&!f&&(f=fe(x))},sync:x=>h.sync(x)}},useGlobalKey:function(r){let u=o(this);return typeof window>"u"?()=>{}:(window.addEventListener("keydown",r),u&&F(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:()=>{}},P=()=>{n.ui&&(f?n.ui.dirty([f]):n.ui.render())},_=b=>{if(x=b,p){M.value=b,P();return}if(b===M.value)return;T&&cancelAnimationFrame(T);let k=M.value,R=performance.now(),A=j=>{let N=Math.min(1,(j-R)/h);M.value=Math.round(k+(b-k)*w(N)),N<1?(T=requestAnimationFrame(A),P()):(T=void 0,P())};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(V.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,V.set(r,u))}}}function un(){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 qn(){let e=[],n={},t=null,o=null,i=null,s=!1,a=!1,d=[];function l(P){d.push(a),a=P}function c(){a=d.pop()??!1}let m=new Set,y=!1,E=new Map;function C(P){let _=E.get(P);_&&(_.mql&&_.handler&&_.mql.removeEventListener("change",_.handler),_.mqls?.forEach(({mql:b,handler:k})=>b.removeEventListener("change",k)),E.delete(P))}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 P=[];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,ye(A,b.panel?.(),b.margin)),P.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,P.push(_))}P.length>0&&n.ui.render(P)}))}function w(P){if(!s){s=!0;for(let _ of P){let b=V.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?ne(k,R,n):R?Y(R,n):k&&O(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 P=n.ui;m.size>0&&!P._dirtyScheduled&&(P._dirtyScheduled=!0,queueMicrotask(()=>{P._dirtyScheduled=!1;let _=[...m];m.clear(),_.length>0&&w(_)}))}function x(P){return P?._selfId??n.ui?._selfId}let M={get ctx(){return n},use(P){return e.push(P),M},async mount(P,_,b){o=_;for(let N of e)n=await N(n);let k=typeof P=="string"?document.querySelector(P):P;if(!k)throw new Error(`mount target not found: ${P}`);t=k;let R=!!b?.hydrate;R||(t.innerHTML="");let A=new Map,j=globalThis.__DATA__;if(j&&typeof j=="object")for(let[N,H]of Object.entries(j))A.set(N,{value:H});if(n.data={async get(N,H){let L=A.get(N);if(L&&"value"in L)return L.value;if(L?.promise)return L.promise;if(!H)return;let D=Promise.resolve().then(()=>H()).then(ie=>(A.set(N,{value:ie}),ie));return A.set(N,{promise:D}),D},set(N,H){A.set(N,{value:H})},has(N){return A.has(N)}},F(N=>{for(let H of[...E.keys()])(H.startsWith(`media:${N}:`)||H===`bp:${N}`)&&C(H);g.delete(N),p.delete(N)}),n.browser=un(),n.ui=ln({ctx:n,renderByIds:w,getSelfId:x,dirtyBatch:m,dirtySet:new Set,mediaRegistry:E,popupTrackers:g,scrollTrackers:p,schedulePopupRecompute:h,ensurePopupListeners:u,destroyPopupListeners:f,isRendering:()=>s,isMounting:()=>a,setMounting:l,endMounting:c}),s=!0,i=Fn(_,n),i._id="_wf_root",i._parentNode=t,i._refNode=R?t.firstChild:null,V.set("_wf_root",i),R)await Le(t,i,n);else{let N=Qe(i,n);N instanceof Node&&t.appendChild(N)}i._refNode=t.firstChild,s=!1,T()},destroy(){f(),g.clear(),p.clear();for(let P of[...E.keys()])C(P);V.clear(),t&&(t.innerHTML=""),t=null,n={}}};return M}function Fn(e,n){return{type:e,props:{},key:void 0}}function Bn(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 Kn(e){let n=[],t=e.replace(/:(\w+)/g,(o,i)=>(n.push(i),"([^/]+)")).replace(/\*/g,".*");return{re:new RegExp(`^${t}$`),keys:n}}function He(e,n="",t=[]){let o=[];for(let i of e){let s=Bn(n,i.path),{re:a,keys:d}=Kn(s),l=[...t,i];o.push({re:a,keys:d,def:i,chain:l}),i.children&&o.push(...He(i.children,s,l))}return o}function cn(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 dn(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 $n(e){let n=He(e.routes),t=e.mode||"history";function o(){return t==="hash"?window.location.hash.replace(/^#/,"")||"/":window.location.pathname}function i(s){let a=cn(s,n);if(a){let d=a.chain[a.chain.length-1];return{path:a.def.path,params:dn(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(J(),t==="hash"){window.location.hash="#"+l;let c=i(l);s.route=c}else{window.history.pushState({},"",l);let c=i(l);s.route=c}s.route?.title&&(document.title=s.route.title),s.ui?.bumpCtxVersion?.(),s.ui?.render()};let d=()=>{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",d),t==="hash"&&window.addEventListener("hashchange",d),s}}function zn(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 Gn(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,E=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"})),E=setTimeout(()=>{l?.close()},s)},i))}function u(){clearTimeout(E)}function f(){clearInterval(y),clearTimeout(E),clearTimeout(m)}return v(),G(a,{ws:g})}}function Yn(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}},E=e?.token?.();E&&!y.headers.Authorization&&(y.headers.Authorization=`Bearer ${E}`);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 he(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 he=class extends Error{status;body;constructor(n,t){super(`API Error ${n}: ${t}`),this.name="ApiError",this.status=n,this.body=t}};function Xn(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 Jn(e){let n=Xn(e);return n?.exp?n.exp*1e3-3e4<Date.now():!0}function Qn(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,E){c.token=m,c.user=y,n.setItem(t,m),n.setItem(o,JSON.stringify(y)),E&&n.setItem(i,E)},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 E=await y.json();return c.token=E.token,n.setItem(t,E.token),E.refreshToken&&n.setItem(i,E.refreshToken),!0}catch{return!1}}};return d&&Jn(d)&&c.refresh().catch(()=>{}),G(a,{auth:c})}}function Zn(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 De={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 Ue={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 ve={"zh-CN":De,"en-US":Ue};function fn(e){if(ve[e])return e;let n=e.split("-")[0];return Object.keys(ve).find(o=>o.startsWith(n))??"zh-CN"}function et(e={}){let{locale:n="zh-CN",messages:t={},components:o={}}=e,i=fn(n),s=ve[i],a=pn(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=fn(c),y=ve[m];y&&(a=pn(y,t,o),d.locale=m,d.components=a.components,l?.ui?.bumpCtxVersion?.(),l?.ui?.render())},l)}function pn(e,n,t){return{messages:{...e?.messages,...n},components:nt(e?.components??{},t)}}function nt(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 tt(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{he as ApiError,Zn as ErrorBoundary,B as Fragment,q as Portal,zn as RouteView,We as aiStream,tt as animateOut,Yn as api,hn as asyncComponent,Qn as auth,O as callRefCleanup,J as clearAsyncComponentCache,jn as computeFixedPos,me as computeFixedPosRect,qn as createApp,Ee as createPortal,pe as createReactiveState,Ue as enUS,G as extendCtx,bn as h,Le as hydrateVNode,et as i18n,X as isAsyncComponent,Te as jsx,wn as jsxDEV,vn as jsxs,Oe as lockScroll,Mn as mountVNode,z as patchValue,$n as router,rn as toChatMessages,fe as trapFocus,Ve as unlockScroll,Gn as ws,De as zhCN};
|
package/dist/client/types.d.ts
CHANGED
|
@@ -383,6 +383,33 @@ 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 关冲突) */
|
|
401
|
+
useOpen: (options: {
|
|
402
|
+
open?: boolean;
|
|
403
|
+
onOpenChange?: (open: boolean) => void;
|
|
404
|
+
openOnFocus?: boolean;
|
|
405
|
+
}) => {
|
|
406
|
+
open: boolean;
|
|
407
|
+
setOpen: (open: boolean) => void;
|
|
408
|
+
triggerProps: {
|
|
409
|
+
onClick: () => void;
|
|
410
|
+
onFocus: () => void;
|
|
411
|
+
};
|
|
412
|
+
};
|
|
386
413
|
/**
|
|
387
414
|
* 全屏对话框组合器(收敛 Modal/Drawer 的退场状态机 + 滚动锁 + 焦点 trap):
|
|
388
415
|
* 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>;
|