weifuwu 0.78.0 → 0.80.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 +12 -11
- package/dist/ai/client.d.ts +1 -1
- package/dist/ai/sse.d.ts +1 -1
- package/dist/ai/types.d.ts +2 -2
- package/dist/components/AlertGroup/AlertGroup.d.ts +1 -1
- package/dist/components/Anchor/Anchor.d.ts +1 -1
- package/dist/components/AuthPage/AuthPage.d.ts +36 -0
- package/dist/components/AutoComplete/AutoComplete.d.ts +3 -1
- package/dist/components/AvatarGroup/AvatarGroup.d.ts +1 -1
- package/dist/components/Calendar/Calendar.d.ts +1 -1
- package/dist/components/Carousel/Carousel.d.ts +1 -1
- package/dist/components/Cascader/Cascader.d.ts +1 -1
- package/dist/components/ChatInput/ChatInput.d.ts +61 -0
- package/dist/components/ColorPicker/ColorPicker.d.ts +1 -1
- package/dist/components/DatePicker/DatePicker.d.ts +2 -0
- package/dist/components/FloatButton/FloatButton.d.ts +1 -1
- package/dist/components/Grid/Grid.d.ts +1 -1
- package/dist/components/Input/Input.d.ts +2 -0
- package/dist/components/InputNumber/InputNumber.d.ts +1 -1
- package/dist/components/JSONViewer/JSONViewer.d.ts +1 -1
- package/dist/components/Link/Link.d.ts +1 -1
- package/dist/components/LogViewer/LogViewer.d.ts +1 -1
- package/dist/components/Markdown/parser.d.ts +1 -1
- package/dist/components/Mentions/Mentions.d.ts +1 -1
- package/dist/components/Menu/Menu.d.ts +1 -1
- package/dist/components/Menubar/Menubar.d.ts +1 -1
- package/dist/components/MessageBubble/MessageBubble.d.ts +1 -1
- package/dist/components/NavMenu/NavMenu.d.ts +1 -1
- package/dist/components/Popconfirm/Popconfirm.d.ts +1 -1
- package/dist/components/Result/Result.d.ts +1 -1
- package/dist/components/Scrollbar/Scrollbar.d.ts +1 -1
- package/dist/components/SearchInput/SearchInput.d.ts +1 -0
- package/dist/components/Slider/Slider.d.ts +1 -0
- package/dist/components/TagsInput/TagsInput.d.ts +1 -1
- package/dist/components/Timeline/Timeline.d.ts +1 -1
- package/dist/components/Transfer/Transfer.d.ts +1 -1
- package/dist/components/TreeSelect/TreeSelect.d.ts +2 -0
- package/dist/components/VirtualList/VirtualList.d.ts +3 -1
- package/dist/components/VirtualTable/VirtualTable.d.ts +1 -1
- package/dist/components/Watermark/Watermark.d.ts +1 -1
- package/dist/components/index.d.ts +4 -0
- package/dist/components/index.js +12 -12
- package/dist/components/style.css +77 -23
- package/dist/index.js +166 -149
- package/dist/ui-dom/ai.d.ts +1 -1
- package/dist/ui-dom/context.d.ts +32 -0
- package/dist/ui-dom/index.d.ts +9 -9
- package/dist/ui-dom/index.js +11 -11
- package/dist/ui-dom/jsx-runtime.js +1 -1
- package/dist/ui-dom/{vdom → middleware}/serve.d.ts +5 -8
- package/dist/ui-dom/testing.js +1 -1
- package/dist/ui-dom/use-chat.d.ts +1 -1
- package/dist/ui-dom/{vdom → vdom2}/audit.d.ts +5 -5
- package/dist/ui-dom/{vdom → vdom2}/build.d.ts +5 -5
- package/dist/ui-dom/vdom2/ctx.d.ts +32 -0
- package/dist/ui-dom/vdom2/hydrate.d.ts +13 -0
- package/dist/ui-dom/vdom2/index.d.ts +13 -0
- package/dist/ui-dom/vdom2/kind.d.ts +35 -0
- package/dist/ui-dom/vdom2/mount.d.ts +63 -0
- package/dist/ui-dom/vdom2/patch.d.ts +47 -0
- package/dist/ui-dom/vdom2/render.d.ts +19 -0
- package/dist/ui-dom/vdom2/ssr.d.ts +32 -0
- package/dist/ui-dom/vdom2/trace.d.ts +52 -0
- package/dist/ui-dom/{vdom → vdom2}/transform.d.ts +22 -1
- package/dist/ui-dom/vdom2/transitions.d.ts +23 -0
- package/dist/ui-dom/vdom2/x2html.d.ts +23 -0
- package/dist/ui-dom/vnode.d.ts +64 -67
- package/docs/ai-contract.md +418 -0
- package/docs/components-map.md +7 -5
- package/docs/components.md +6 -3
- package/docs/frontend-ui-dom.md +2 -2
- package/docs/frontend.md +2 -2
- package/docs/layout.md +1 -1
- package/docs/mobile.md +1 -1
- package/docs/saas.md +2 -2
- package/docs/style-guide.md +182 -0
- package/package.json +1 -1
- package/dist/ui-dom/vdom/diff.d.ts +0 -33
- package/dist/ui-dom/vdom/hydration.d.ts +0 -17
- package/dist/ui-dom/vdom/index.d.ts +0 -23
- package/dist/ui-dom/vdom/mount.d.ts +0 -58
- package/dist/ui-dom/vdom/render.d.ts +0 -17
- package/dist/ui-dom/vdom/ssr.d.ts +0 -44
- /package/dist/ui-dom/{vdom → vdom2}/registry.d.ts +0 -0
package/dist/ui-dom/testing.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var R=Symbol("Fragment"),j=Symbol("Portal");function W(e){if(e==null||typeof e=="boolean")return[];if(Array.isArray(e)){let n=!1;for(let o=0;o<e.length;o++)if(Array.isArray(e[o])){n=!0;break}if(!n)return e;let t=[],r=[...e].reverse();for(;r.length>0;){let o=r.pop();if(Array.isArray(o))for(let i=o.length-1;i>=0;i--)r.push(o[i]);else t.push(o)}return t}return[e]}function ne(e,n){if(e===n)return!0;let t=Object.keys(e),r=Object.keys(n);if(t.length!==r.length)return!1;for(let o of t)if(e[o]!==n[o])return!1;return!0}async function te(e,n,t,r){e._id||(r?.reuse?._id?e._id=r.reuse._id:e._id=t.nextId(),t.idRegistry.set(e._id,e)),r?.reuse&&(r.reuse._parentNode&&(e._parentNode=r.reuse._parentNode),r.reuse._refNode&&(e._refNode=r.reuse._refNode),r.reuse._ctxVersion!=null&&(e._ctxVersion=r.reuse._ctxVersion));let o=Object.create(n);o.ui=Object.create(n.ui);let i=o.ui;if(i._selfId=e._id,i._selfVNode=e,i.render=function(d){return d==null&&e._id?n.ui.render([e._id]):n.ui.render(d)},typeof e._render!="function"&&typeof r?.reuse?._render=="function"&&(e._render=r.reuse._render),typeof e._render!="function"){n.ui?.setMounting?.(!0);let d;try{d=await e.type(e.props??{},o)}finally{n.ui?.endMounting?.()}if(typeof d!="function")throw new Error(`Component ${e.type.name||"anonymous"} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);e._render=d}return{renderFn:e._render,childCtx:o}}function J(e){return!!e&&typeof e.then=="function"}function P(e,n,t,r,o){if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;if(Array.isArray(e)){let m=Array.isArray(t)?t:[];for(let l=0;l<e.length;l++){let h=e[l];if(h!=null&&typeof h=="object"&&!Array.isArray(h)){let b=h;b.key===void 0?b.key=String(l):b.key=String(b.key)}}let f=e.map((l,h)=>P(l,n,m[h],r,o)),s=!1;for(let l=0;l<f.length;l++)if(J(f[l])){s=!0;break}return s?Promise.all(f).then(()=>e):e}let i=e,d=r??n.__registry,u=t!=null&&typeof t=="object"&&!Array.isArray(t)&&t.type===i.type?t:null;if(typeof i.type=="function"){i._id||(i._id=u?._id??d.nextId(),d.idRegistry.set(i._id,i)),u&&(u._parentNode&&(i._parentNode=u._parentNode),u._refNode&&(i._refNode=u._refNode),u._ctxVersion!=null&&(i._ctxVersion=u._ctxVersion),typeof u._render=="function"&&(i._render=u._render));let m=ne(u?.props??{},i.props??{}),f=n?.ui?._ctxVersion??0,s=(u?._ctxVersion??-1)===f;return!o?.force&&m&&s&&u?._child!=null?(i._child=u._child,i._ctxVersion=u._ctxVersion,i):(async()=>{let{childCtx:l}=await te(i,n,d,{reuse:u??void 0}),h=await P(await i._render(i.props),l,u?._child,d);return i._child=h??null,i._ctxVersion=f,i})()}if(i.type===R){let m=P(i.props?.children??null,n,u?._child??u?.props?.children,d);return J(m)?m.then(f=>(i._child=f??null,i)):(i._child=m??null,i)}if(typeof i.type=="string"||typeof i.type=="symbol"){let m=P(i.props?.children??null,n,u?.props?.children,d);return J(m)?m.then(f=>(i._child=f??null,i)):(i._child=m??null,i)}return i}function U(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}var D=/^on[A-Z]/,re=/^on[A-Z].*Capture$/;function B(e){let n=re.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var X=new Set(["draggable","contenteditable","spellcheck","translate"]),I=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);var oe=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function q(e,n,t){if(t==null)return;let r=e.ownerDocument?.defaultView;if(X.has(n)){e.setAttribute(n,t?"true":"false");return}if(t!==!1){if(n==="class"||n==="className"){if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t));return}if(n==="style"){if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,d]of Object.entries(t))d==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(d)):typeof d=="number"&&!I.has(i)?o[i]=`${d}px`:o[i]=String(d)}return}if(n==="ref"){if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}return}if(D.test(n)){let{type:o,capture:i}=B(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(o,t,i?{capture:!0}:void 0);return}if(n==="value"){e.value=t;return}if(n==="indeterminate"){e.indeterminate=!!t;return}if(n==="innerHTML"){e.innerHTML=String(t??"");return}if(n.startsWith("aria-")&&typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}function H(e,n){return e.createComment(`wf-hole: ${U(n)}`)}function T(e,n,t){let r=n?.browser??t;if(!r)throw new Error("[vdom] renderValue requires browser env (ctx.browser)");if(e==null||typeof e=="boolean")return null;if(typeof e=="string"||typeof e=="number")return r.createTextNode(String(e));if(Array.isArray(e)){let f=r.createDocumentFragment();if(!f)return null;for(let s of e){let l=s==null||typeof s=="boolean"?H(r,s):T(s,n,r);l!=null&&f.appendChild(l)}return f}let o=e,i=o.type;if(typeof i!="string"&&typeof i!="function"&&i!==R&&i!==j)return console.warn(`[weifuwu] children \u9879\u975E\u6CD5\uFF1Atype=${String(i)}\uFF08${typeof i}\uFF09\uFF0C\u503C=${U(e)}\u2014\u2014\u5DF2\u5360\u4F4D\uFF08wf-hole\uFF09\uFF0C\u68C0\u67E5\u4F20\u5165\u7684 children`),H(r,e);if(o.type===j){let f=r.bodyElement();if(!f)return null;let s=f.querySelector("#__wf_portal");s||(s=r.createElement("div"),s&&(s.id="__wf_portal",f.appendChild(s)));let l=r.createElement("div");if(l){l.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let h=T(o.props?.children??null,n,r);h!=null&&l.appendChild(h),s&&s.appendChild(l),o._remoteEl=l}return null}if(o.type===R){let f=r.createDocumentFragment();if(!f)return null;for(let s of W(o.props?.children)){let l=s==null||typeof s=="boolean"?H(r,s):T(s,n,r);l!=null&&f.appendChild(l)}return o._childNodes=Array.from(f.childNodes),f}if(typeof o.type=="function"){if(typeof o._render!="function")throw new Error(`[vdom] component ${o.type.name||"anonymous"} not built (missing _render) \u2014 buildVNode must run before renderValue`);if(o._child===void 0)throw new Error(`[vdom] component ${o.type.name||"anonymous"} not built (missing _child) \u2014 buildVNode must run before renderValue`);let f=o._child;if(f==null)return o._child=null,null;let s=(Array.isArray(f)||typeof f=="object"&&typeof f.type=="function",f);o._child=s,typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o);let l=T(s,n,r);if(l){if(o._refNode=l,o._id)if(l.nodeType===11)for(let h of Array.from(l.childNodes))h.nodeType===1&&h.setAttribute("data-wf-id",o._id);else l.nodeType===1&&l.setAttribute("data-wf-id",o._id);if(o.key!=null)if(l.nodeType===11)for(let h of Array.from(l.childNodes))h.nodeType===1&&h.setAttribute("data-wf-key",o.key);else l.nodeType===1&&l.setAttribute("data-wf-key",o.key)}return l}let d=o.type,u=oe.has(d)?r.createElementNS("http://www.w3.org/2000/svg",d):r.createElement(d);if(!u)return null;o.el=u,o.key!=null&&u.setAttribute("data-wf-key",o.key);let m;for(let[f,s]of Object.entries(o.props??{}))if(!(f==="children"||f==="key")){if(f==="value"&&u instanceof HTMLSelectElement){m=s;continue}q(u,f,s)}if(!("innerHTML"in(o.props??{}))){let f=[];for(let s of W(o.props?.children)){let l=s==null||typeof s=="boolean"?H(r,s):T(s,n,r);if(l==null){f.push(null);continue}if(u.appendChild(l),f.push(l.nodeType===11?l.firstChild:l),s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"){let h=s;h._parentNode||(h._parentNode=u,h._refNode=l)}}o._childAnchors=f}return m!==void 0&&(u.value=String(m)),u}function k(){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,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,r=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[r](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},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 r=document.execCommand("copy");return document.body.removeChild(t),r}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,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,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{}}}}var ie=0;function K(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${ie++}`}}function Y(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function se(e,n,t,r){try{e(n)}catch(o){console.error(`[weifuwu] ref ${t} error in <${r??"anonymous"}>`,o)}}function E(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let r=[...n.unmountHooks];for(let o of r)o(t._id);if(t._customId)for(let o of r)o(t._customId)}t._id=void 0,t._customId=void 0,t._render=void 0,t._parentNode=void 0,t._refNode=void 0}if(t._child!=null){if(Array.isArray(t._child))for(let r of t._child)r&&typeof r=="object"&&E(r,n);else E(t._child,n);t._child=void 0}if(t.props?.children&&typeof t.type=="string"){let r=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let o of r)o&&typeof o=="object"&&E(o,n)}if(typeof t.props?.ref=="function"&&se(t.props.ref,null,"cleanup"),t._remoteEl){let r=t._child;if(r!=null)if(Array.isArray(r))for(let o of r)o&&typeof o=="object"&&E(o,n);else typeof r=="object"&&E(r,n);t._remoteEl.remove(),t._remoteEl=void 0}}function O(e,n){if(n&&typeof e.type=="function"&&e._id){try{E(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Y(n,e._id)}}function F(e){if(e==null||typeof e!="object"||Array.isArray(e))return;let n=e;return n._placement==="remote"?n.props?.portalKey:n.key}function Z(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)&&e.type===R){let t=e._childNodes;if(t&&t.length)return t}return[n]}function $(e,n,t,r,o){if(typeof r=="string"||typeof r=="number"){if(typeof t=="string"||typeof t=="number"){if(String(t)!==String(r)){if(n&&n.nodeType===3)return n.nodeValue=String(r),n;let l=e.ownerDocument.createTextNode(String(r));return n?.parentNode?n.parentNode.replaceChild(l,n):e.appendChild(l),l}return n}let s=e.ownerDocument.createTextNode(String(r));return n?.parentNode?n.parentNode.replaceChild(s,n):e.appendChild(s),s}if(r==null||typeof r=="boolean"){if(t&&typeof t=="object"&&!Array.isArray(t)&&t.type===j){let s=t._remoteEl;try{E(t.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return s?.parentNode?.removeChild(s),null}if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")O(t,o.registry);else try{E(t,o.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}return n?.parentNode&&n.parentNode.removeChild(n),null}if(Array.isArray(r)){if(t===r&&n?.parentNode)return n;let s=e.ownerDocument.createDocumentFragment(),l=z(e,t,r,o,n?[n]:void 0);for(let h of l)h&&s.appendChild(h);return n?.parentNode?s.contains(n)?e.appendChild(s):n.parentNode.replaceChild(s,n):e.appendChild(s),s}let i=r;if(i.type===j){let s=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(s?.type===j){let l=s._remoteEl;if(l){let h=s.props?.children??null,b=i.props?.children??null;z(l,h,b,o)}return i._remoteEl=s._remoteEl,null}return T(i,o,o.browser??k()),null}if(i.type===R){let s=t&&typeof t=="object"&&!Array.isArray(t)?t:null,l=s?._childNodes,h=z(e,s?.props?.children??t,i.props?.children??null,o,l);return i._childNodes=h.filter(Boolean),n?.parentNode&&n.nodeType===8&&n.parentNode.removeChild(n),n&&n.nodeType===1?n:h[0]??null}if(typeof i.type=="function"){if(typeof i._render!="function")throw new Error(`[vdom] component ${i.type.name||"anonymous"} not built in diff \u2014 buildVNode must run before patchValue`);let s=t&&typeof t=="object"&&!Array.isArray(t)?t:null,l=s?.type===i.type;if(!o.force&&s&&l&&s._child!==void 0&&i._child===s._child)return n;s?.type===i.type&&s._id&&(i._id=s._id,o.registry.idRegistry.set(i._id,i)),i._parentNode=e,n&&(i._refNode=n);let h;if(i._child===void 0)throw new Error(`[vdom] component ${i.type.name||"anonymous"} not built (missing _child) \u2014 buildVNode must run before patchValue`);h=i._child;let b=$(e,n,s?._child,h,o);return b&&(i._refNode=b),b}let d=t&&typeof t=="object"&&!Array.isArray(t)?t:null,u=d?.type??null,m=i.type;if(n&&n.nodeType===1&&u===m){let s=n;if(i.el=s,le(s,d?.props??{},i.props??{}),!("innerHTML"in(i.props??{}))){let l=[];z(s,d?.props?.children??null,i.props?.children??null,o,void 0,d?._childAnchors,l),i._childAnchors=l}return s}let f=T(i,o,o.browser??k());if(f==null)return null;if(n?.parentNode)if(t!=null&&typeof t!="boolean"){if(typeof t=="object"&&!Array.isArray(t))try{E(t,o.registry)}catch(s){console.error("[weifuwu] ref cleanup error",s)}n.parentNode.replaceChild(f,n)}else n.parentNode.insertBefore(f,n);else e.appendChild(f);return f}function le(e,n,t){let r=Object.keys(n),o=Object.keys(t);if(r.length===o.length){let d=!0;for(let u=0;u<r.length;u++)if(r[u]!==o[u]||n[r[u]]!==t[r[u]]){d=!1;break}if(d)return}let i=new Set([...r,...o]);for(let d of i){if(d==="children"||d==="key")continue;let u=n[d],m=t[d];if(u!==m){if(D.test(d)){let{type:f,capture:s}=B(d);typeof u=="function"&&e.removeEventListener(f,u,s?{capture:!0}:void 0),m!=null&&m!==!1&&(typeof m!="function"?console.warn(`[weifuwu] event prop ${d} expects a function, got ${typeof m} \u2014 ignored`):e.addEventListener(f,m,s?{capture:!0}:void 0));continue}if(d==="class"||d==="className"){m==null||m===!1?e.removeAttribute("class"):(e.className="",q(e,d,m));continue}if(m==null||m===!1){if(d==="class"||d==="className")e.removeAttribute("class");else if(D.test(d))e.removeEventListener(d.slice(2).toLowerCase(),u);else if(d==="ref"){if(typeof u=="function")try{u(null)}catch(f){console.error("[weifuwu] ref cleanup error",f)}}else if(d==="value")e.value="";else if(d==="indeterminate")e.indeterminate=!1;else{e.removeAttribute(d);try{delete e[d]}catch{}}continue}q(e,d,m)}}}function z(e,n,t,r,o,i,d){let u=W(n),m=W(t),f=i??o??Array.from(e.childNodes);if(m.some(a=>{if(a==null||typeof a!="object"||Array.isArray(a))return!1;let c=a;return c._placement!=="remote"&&c.key!==void 0})){for(let a=0;a<m.length;a++){let c=m[a];c&&typeof c=="object"&&!Array.isArray(c)&&F(c)===void 0&&(c.key=`pos:${a}`)}for(let a=0;a<u.length;a++){let c=u[a];c&&typeof c=="object"&&!Array.isArray(c)&&F(c)===void 0&&(c.key=`pos:${a}`)}}let l=i?i.map((a,c)=>a??(c<u.length?u[c]?._refNode??null:null)):u.map((a,c)=>{if(a==null||typeof a!="object"||Array.isArray(a))return f[c]??null;let N=a;return N._placement==="remote"?N._remoteEl??null:N.type===R?N._childNodes?.[0]??null:N._refNode??N.el??null});if(!m.some(a=>{if(a==null||typeof a!="object"||Array.isArray(a))return!1;let c=a;return c._placement!=="remote"&&c.key!==void 0})){let a=Math.max(u.length,m.length),c=[],N=V=>{d&&d.push(V)};for(let V=0;V<a;V++){let p=V<u.length?u[V]:null,y=V<m.length?m[V]:null;if(y==null||typeof y=="boolean"){let w=l[V],M=r.browser??k(),_=H(M,y);if(p==null||typeof p=="boolean"){w?.nodeType===8?(_&&w.nodeValue!==_.nodeValue&&(w.nodeValue=_.nodeValue),c.push(w),N(w)):(_&&w?.parentNode?w.parentNode.replaceChild(_,w):_&&e.appendChild(_),c.push(_),N(_));continue}if(p&&typeof p=="object"&&!Array.isArray(p))if(typeof p.type=="function")O(p,r.registry);else try{E(p,r.registry)}catch(v){console.error("[weifuwu] ref cleanup error",v)}_&&w?.parentNode?w.parentNode.replaceChild(_,w):_&&e.appendChild(_),c.push(_),N(_);continue}if(p!=null&&typeof p=="object"&&!Array.isArray(p)&&y!=null&&typeof y=="object"&&!Array.isArray(y)&&y===p){c.push(l[V]),N(l[V]);continue}if(p==null||typeof p=="boolean"){let w=T(y,r,r.browser??k());if(w==null){c.push(null),N(null);continue}let M=l[V];if(M&&M.nodeType===8&&M.nodeValue?.startsWith("wf-hole:")){M.parentNode?.replaceChild(w,M),c.push(w),N(w);continue}let _=null;for(let v=V+1;v<l.length;v++){let x=l[v];if(x&&x.parentNode===e){_=x;break}}if(!_){let v=null;for(let x=c.length-1;x>=0;x--)if(c[x]){v=c[x];break}if(v&&v.parentNode===e&&(_=v.nextSibling),!_){let x=l[l.length-1];x&&x.parentNode===e&&(_=x.nextSibling)}}_&&_.parentNode===e?e.insertBefore(w,_):e.appendChild(w),c.push(w),N(w);continue}let g=$(e,l[V],p,y,r),C=Z(y,g);c.push(...C),N(C[0]??g??null)}return c}let b=new Map;u.forEach((a,c)=>{let N=F(a);N!==void 0&&a&&typeof a=="object"&&!Array.isArray(a)&&b.set(N,{vnode:a,nodes:[l[c]??null].filter(Boolean),index:c})});let S=[],Q=new Set,L=a=>{d&&d.push(a)},A=null;return m.forEach((a,c)=>{let N=F(a),V=a;if(N!==void 0&&b.has(N)){let p=b.get(N),y=p.nodes[0]??null;Q.add(N);let g=$(e,y,p.vnode,V,r),C=Z(V,g),w=C[C.length-1]??g;w&&w.parentNode===e&&A&&w.previousSibling!==A&&e.insertBefore(w,A.nextSibling),S.push(...C),L(C[0]??g??null),w&&(A=w)}else{if(a==null||typeof a=="boolean"){let p=u[c]??null,y=l[c]??null,g=H(r.browser??k(),a);if(p==null||typeof p=="boolean")y?.nodeType===8?(g&&y.nodeValue!==g.nodeValue&&(y.nodeValue=g.nodeValue),S.push(y),L(y),y&&(A=y)):(g&&y?.parentNode?y.parentNode.replaceChild(g,y):g&&e.appendChild(g),S.push(g),L(g),g&&(A=g));else{if(typeof p=="object"&&!Array.isArray(p))if(typeof p.type=="function")O(p,r.registry);else try{E(p,r.registry)}catch(C){console.error("[weifuwu] ref cleanup error",C)}g&&y?.parentNode?y.parentNode.replaceChild(g,y):g&&e.appendChild(g),S.push(g),L(g),g&&(A=g)}return}if(V?._placement==="remote"){let p=u[c]??null,y=$(e,l[c]??null,p,V,r),g=Z(V,y);S.push(...g),L(g[0]??y??null);let C=g[g.length-1]??y;C&&(A=C)}else{let p=T(V,r,r.browser??k());if(S.push(p),L(p??null),p!=null){let y=l[c];y&&y.nodeType===8&&y.nodeValue?.startsWith("wf-hole:")?(y.parentNode?.replaceChild(p,y),A=p):(A?e.insertBefore(p,A.nextSibling):e.insertBefore(p,e.firstChild),A=p)}}}}),u.forEach((a,c)=>{let N=F(a),V=a&&typeof a=="object"&&!Array.isArray(a)&&typeof a.type=="function";if(N!==void 0&&!Q.has(N)){if(a&&typeof a=="object"&&!Array.isArray(a))if(V)O(a,r.registry);else try{E(a,r.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}let p=l[c];p?.parentNode&&p.parentNode.removeChild(p)}else if(N===void 0){let p=c<m.length?m[c]:null,y=l[c];if(!(y?.nodeType===8&&y.nodeValue?.startsWith("wf-hole:"))||p==null){if(a&&typeof a=="object"&&!Array.isArray(a))if(V)O(a,r.registry);else try{E(a,r.registry)}catch(C){console.error("[weifuwu] ref cleanup error",C)}y?.parentNode&&y.parentNode.removeChild(y)}}}),S}function de(e){return e.__registry??(e.__registry=K())}function ee(e,n,t,r){let o=de(t),i=t.browser??k();return Promise.resolve(P(n,t,void 0,o)).then(()=>{let d=T(n,t,i);if(d!=null&&e.appendChild(d),n._id&&o){let u=o.idRegistry.get(n._id);u&&(u._parentNode=e)}r?.onMounted?.()}).catch(d=>console.error("[weifuwu] command mount error",d)),{id:n._id??""}}function Le(e,n,t){return new Promise(r=>{ee(e,n,t,{onMounted:r})})}async function We(e,n,t,r,o){return await P(r,o,t,o.__registry),$(e,n,t,r,{browser:o.browser??o.__browser,registry:o.__registry})}function De(e,n){let t=n.__registry??(n.__registry=K());return Promise.resolve(P(e,n,void 0,t))}async function $e(e,n,t){let r=await e(n,t);return typeof r=="function"?r(n):r}async function Be(e,n,t){let r=await e(n,t);return()=>typeof r=="function"?r(n):r}function G(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let r of e)G(r,n);return}n(e);let t=e?.props?.children;t!=null&&G(t,n)}function Fe(e,n){let t;return G(e,r=>{!t&&n(r)&&(t=r)}),t}function Oe(e,n){let t=[];return G(e,r=>{typeof r?.props?.class=="string"&&r.props.class.split(" ").includes(n)&&t.push(r)}),t}function Ue(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function qe(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,r)=>e()?t:null,wrapProps:{}}}export{De as buildToDom,qe as createPopupMock,Ue as createTestCtx,Oe as findByClass,Fe as findVNode,Be as mountComponent,Le as mountToDom,We as patchToDom,$e as renderVNode,G as walkVNode};
|
|
1
|
+
var O=Symbol("Fragment"),ge=Symbol("Portal");function ve(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function B(e){return e!=null&&typeof e=="object"&&e.type===O}function D(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function H(e){return e!=null&&typeof e=="object"&&e.type===ge}function M(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var je=0;function te(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${je++}`}}function Ae(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function He(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function R(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let o=[...n.unmountHooks];for(let i of o)i(t._id);if(t._customId)for(let i of o)i(t._customId)}t._id=null,t._customId=null,D(t)&&(t._render=null),t._parentNode=null,t._refNode=null}if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&R(o,n);else R(t._child,n);t._child=null}if(t.props?.children&&typeof t.type=="string"){let o=Array.isArray(t.props.children)?t.props.children:[t.props.children];for(let i of o)i&&typeof i=="object"&&R(i,n)}if(typeof t.props?.ref=="function"&&He(t.props.ref,null,"cleanup"),H(t)){let o=t._remoteEl;if(o){let i=t._child;if(i!=null)if(Array.isArray(i))for(let r of i)r&&typeof r=="object"&&R(r,n);else typeof i=="object"&&R(i,n);o.remove(),t._remoteEl=null}}}function oe(e){return typeof e=="function"&&e.name||"anonymous"}function Ee(e){return e.ui?._ctxVersion??0}function he(e,n){e.ui?.setMounting?.(n)}var Ne={error:0,warn:1,info:2,debug:3,trace:4},ke=["mount","build","render","diff","audit"],K={enabled:!1,stages:new Set,level:"info",filter:null},Ve=!1;function Me(e){return e&&e in Ne?e:"info"}function Se(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];ke.includes(o)&&n.add(o)}return n}function Be(){if(Ve)return K;Ve=!0;try{let e=globalThis,n=new URLSearchParams(typeof e.location?.search=="string"?e.location.search:""),t=n.get("vdom_trace"),o=n.get("vdom_debug"),i=e.__vdom_trace__,r=typeof e.localStorage?.getItem=="function"?e.localStorage.getItem("vdom_trace"):null;if(o==="1"||e?.localStorage?.getItem?.("__WF_VDOM_DEBUG")==="1")K={enabled:!0,stages:new Set(ke),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Se(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let a of d)l.add(a)}if(r)for(let d of Se(r))l.add(d);K={enabled:!0,stages:l,level:t?.includes(":")?Me(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return K}function v(e,n="info"){return!K.enabled&&(Ve||Be(),!K.enabled)||K.stages.size&&!K.stages.has(e)?!1:Ne[n]<=Ne[K.level]}function A(e,n,t,...o){if(!v(e,n))return;let i=K.filter;i&&!t.includes(i)||console.log(`[vdom:${e}] ${t}`,...o)}function I(e,n=12){if(!e)return"\u2205";if(typeof e=="string"||typeof e=="number")return`"${e}"`;if(!Array.isArray(e))return z(e);let t=e.slice(0,n).map(z);return e.length>n&&t.push(`\u2026+${e.length-n}`),`[${t.join(" | ")}]`}function z(e){if(e==null||typeof e=="boolean")return String(e);if(typeof e=="string")return`"${e.slice(0,16)}"`;if(typeof e=="number")return String(e);if(Array.isArray(e))return`ARR(${e.length})`;let n=e,t=n.type,o;typeof t=="function"?o=t.name||"Comp":t===O?o="Frag":typeof t=="string"?o=t:o=String(t);let i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function W(e){if(!e)return"null";if(e.nodeType===1){let n=e;return`${n.tagName}${n.id?`#${n.id}`:""}${n.getAttribute?.("data-wf-key")?`@${n.getAttribute("data-wf-key")}`:""}`}return e.nodeType===3?`"${(e.textContent??"").slice(0,12)}"`:e.nodeType===8?`<!--${(e.nodeValue??"").slice(0,40)}-->`:`#${e.nodeType}`}function G(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(W);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}function Fe(e,n){if(e===n)return!0;let t=Object.keys(e),o=Object.keys(n);if(t.length!==o.length)return!1;for(let i of t)if(e[i]!==n[i])return!1;return!0}async function Ie(e,n,t,o){let i=e;i._id||(o?.reuse?._id?i._id=o.reuse._id:i._id=t.nextId(),t.idRegistry.set(i._id,i)),o?.reuse&&(o.reuse._parentNode&&(i._parentNode=o.reuse._parentNode),o.reuse._refNode&&(i._refNode=o.reuse._refNode),o.reuse._ctxVersion!=null&&(i._ctxVersion=o.reuse._ctxVersion));let r=Object.create(n);r.ui=Object.create(n.ui);let l=r.ui;if(l._selfId=i._id??null,l._selfVNode=i,l.render=function(d){let a=n.ui;return d==null&&i._id?a.render([i._id]):a.render(d)},typeof i._render!="function"&&D(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){he(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{he(n,!1)}if(typeof d!="function")throw new Error(`Component ${oe(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function we(e){return!!e&&typeof e.then=="function"}function J(e,n,t,o,i){if(e==null||typeof e=="boolean"||typeof e=="string"||typeof e=="number")return e;if(Array.isArray(e)){v("build")&&A("build","debug","",`array in kids=${I(e)}`);for(let _=0;_<e.length;_++){let m=e[_];if(m!=null&&typeof m=="object"&&!Array.isArray(m)){let $=m;$.key===null?$.key=String(_):$.key=String($.key)}}let a=Array.isArray(t)?t:[],C=e.map((_,m)=>J(_,n,a[m],o,i));v("build")&&A("build","debug","",`array out kids=${I(e)}`);let x=!1;for(let _=0;_<C.length;_++)if(we(C[_])){x=!0;break}return x?Promise.all(C).then(()=>e):e}let r=e,l=o??n.__registry??te(),d=t!=null&&typeof t=="object"&&!Array.isArray(t)&&t.type===r.type?t:null;if(typeof r.type=="function"){r._id||(r._id=d?._id??l.nextId(),l.idRegistry.set(r._id,r)),d&&(d._parentNode&&(r._parentNode=d._parentNode),d._refNode&&(r._refNode=d._refNode),d._ctxVersion!=null&&(r._ctxVersion=d._ctxVersion),D(r)&&D(d)&&typeof d._render=="function"&&(r._render=d._render));let a=Fe(d?.props??{},r.props??{}),C=Ee(n),x=(d?._ctxVersion??-1)===C;return!i?.force&&a&&x&&d?._child!=null?(r._child=d._child,r._ctxVersion=d._ctxVersion,v("build")&&A("build","debug","",`prune comp=${z(r)} propsSame=${a} verSame=${x}`),r):(v("build")&&A("build","debug","",`mount comp=${z(r)} propsSame=${a} verSame=${x} force=${!!i?.force}`),(async()=>{let{childCtx:_}=await Ie(r,n,l,{reuse:d??null}),m=await J(await r._render(r.props),_,d?._child,l,i);return r._child=m??null,r._ctxVersion=C,r})())}if(r.type===O){v("build")&&A("build","debug","",`fragment kids=${I(M(r.props?.children))}`);let a=J(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return we(a)?a.then(C=>(r._child=C??null,r)):(r._child=a??null,r)}if(typeof r.type=="string"||typeof r.type=="symbol"){v("build")&&A("build","trace","",`native <${String(r.type)}> kids=${I(M(r.props?.children))}`);let a=J(r.props?.children??null,n,d?.props?.children,l,i);return we(a)?a.then(C=>(r._child=C??null,r)):(r._child=a??null,r)}return r}function S(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||B(e)){let o=n;if(o&&o.nodeType===8&&o.nodeValue?.includes("type=fragment-start")){let i=[o],r=/fid=([^\s"]+)/.exec(o.nodeValue)?.[1]??"",l=o.nextSibling;for(;l&&(i.push(l),!(l.nodeType===8&&l.nodeValue?.includes("type=fragment-end")&&(/fid=([^\s"]+)/.exec(l.nodeValue)?.[1]??r)===r));)l=l.nextSibling;return i}return null}let t=e;return D(t)?S(t._outputChild??t._child,n):null}function se(e){if(e==null||typeof e=="boolean")return"hole";if(typeof e=="string"||typeof e=="number")return"text";if(Array.isArray(e))return"arr";let n=e;return B(n)?"frag":H(n)?"portal":D(n)?"comp":"native"}function F(){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,queryAll:e=>typeof document<"u"?document.querySelectorAll(e):null,createElement:e=>typeof document<"u"?document.createElement(e):null,createElementNS:(e,n)=>typeof document<"u"?document.createElementNS(e,n):null,createDocumentFragment:()=>typeof document<"u"?document.createDocumentFragment():null,createComment:e=>typeof document<"u"?document.createComment(e):null,createTextNode:e=>typeof document<"u"?document.createTextNode(e):null,addEventListener:(e,n,t)=>{typeof window<"u"&&window.addEventListener(e,n,t)},removeEventListener:(e,n,t)=>{typeof window<"u"&&window.removeEventListener(e,n,t)},scrollTo:e=>{typeof window<"u"&&window.scrollTo(0,e)},matchMedia:e=>typeof window<"u"&&typeof window.matchMedia=="function"?window.matchMedia(e):null,visualViewport:()=>(typeof window<"u"?window:null)?.visualViewport??null,scrollingElement:()=>typeof document<"u"?document.scrollingElement:null,bodyElement:()=>typeof document<"u"?document.body:null,bodyAppend:e=>{typeof document<"u"&&document.body.appendChild(e)},bodyRemove:e=>{typeof document<"u"&&e.parentNode&&document.body.removeChild(e)},clearBody:()=>{typeof document<"u"&&(document.body.innerHTML="")},event:(e,n)=>{let t=typeof window<"u"?window:null,o=n&&(n.key||n.code)?"KeyboardEvent":n&&(n.clientX!==void 0||n.clientY!==void 0||n.pointerId!==void 0)?"PointerEvent":"Event";try{return new t[o](e,n)}catch{return new t.Event(e,n)}},dispatchEvent:(e,n)=>typeof e<"u"?e.dispatchEvent(n):!1,navigate:e=>{typeof window>"u"||(window.history.pushState(null,"",e),window.dispatchEvent(new PopStateEvent("popstate",{state:null})))},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,viewportWidth:()=>typeof window<"u"?window.innerWidth:0,pathname:()=>typeof window<"u"?window.location.pathname:"",createTreeWalker:(e,n)=>typeof document<"u"?document.createTreeWalker(e,n??NodeFilter.SHOW_ALL):null,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 Le(e){if(e===!1)return"false";if(e===null)return"null";if(e===void 0)return"undefined";if(e===!0)return"true";if(typeof e=="object")try{let n=JSON.stringify(e);return`object ${n!=null&&n.length>80?n.slice(0,80)+"\u2026":n??""}`}catch{return`object ${Object.prototype.toString.call(e)}`}return`bad-vnode type=${typeof e}`}function pe(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function re(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${pe(Le(e.value))}`),e.key!=null&&n.push(`key=${pe(e.key)}`),e.id!=null&&n.push(`id=${pe(e.id)}`),e.fid!=null&&n.push(`fid=${pe(e.fid)}`),`wf-hole: ${n.join(" ")}`}var ye=/^on[A-Z]/,Oe=/^on[A-Z].*Capture$/;function be(e){let n=Oe.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var De=new Set(["draggable","contenteditable","spellcheck","translate"]),qe=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function de(e,n,t){if(t==null)return;let o=e.ownerDocument?.defaultView;if(De.has(n)){e.setAttribute(n,t?"true":"false");return}if(t!==!1){if(n==="class"||n==="className"){if(typeof t=="object")for(let[i,r]of Object.entries(t))r&&e.classList.add(i);else e.setAttribute("class",String(t));return}if(n==="style"){if(typeof t=="string")e.setAttribute("style",t);else{let i=e.style;for(let[r,l]of Object.entries(t))l==null?i[r]="":r.startsWith("--")?i.setProperty(r,String(l)):typeof l=="number"&&!qe.has(r)?i[r]=`${l}px`:i[r]=String(l)}return}if(n==="ref"){if(typeof t=="function")try{t(e)}catch(i){console.error("[weifuwu] ref error",i)}return}if(ye.test(n)){let{type:i,capture:r}=be(n);if(typeof t!="function"){console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof t} \u2014 ignored`);return}e.addEventListener(i,t,r?{capture:!0}:{});return}if(n==="value"){e.value=t;return}if(n==="indeterminate"){e.indeterminate=!!t;return}if(n==="innerHTML"){e.innerHTML=String(t??"");return}if(n.startsWith("aria-")&&typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}if(t===!0){e.setAttribute(n,"");return}try{e[n]=t,e.getAttribute(n)!==String(t)&&e.setAttribute(n,String(t))}catch{e.setAttribute(n,String(t))}}}function ue(e,n){return e.createComment(re({type:"hole",value:n,key:null,id:null,fid:null}))}var Ke=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function ae(e,n){return ue(e,n)}function P(e,n,t,o=null,i=null,r=null){let l=n?.browser??t;if(!l)throw new Error("[vdom2] renderValue requires browser env (ctx.browser)");return Ze[se(e)](e,n,l,o,i,r)}function We(e,n,t){return null}function Ue(e,n,t){return t.createTextNode(String(e))}function ze(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;v("render")&&A("render","debug","",`array kids=${I(l)} fid=${r??"-"} key=${o??"-"}`);let a=t.createComment(re({type:"fragment-start",key:o,id:i,fid:r})),C=t.createComment(re({type:"fragment-end",key:o,id:i,fid:r}));a&&d.appendChild(a);for(let x=0;x<l.length;x++){let _=l[x],m=r!=null?`${r}-${x}`:String(x),$=_==null||typeof _=="boolean"?ae(t,_):P(_,n,t,String(x),null,m);$!=null&&d.appendChild($)}return C&&d.appendChild(C),d}function Ge(e,n,t){let o=e,i=o,r=t.bodyElement();if(!r)return null;let l=r.querySelector("#__wf_portal");l||(l=t.createElement("div"),l&&(l.id="__wf_portal",r.appendChild(l)));let d=t.createElement("div");if(d){d.setAttribute("data-portal",String(o.props?.portalKey??"wf"));let a=P(o.props?.children??null,n,t);a!=null&&d.appendChild(a),l&&l.appendChild(d),i._remoteEl=d}return null}function Je(e,n,t,o=null,i=null,r=null){let l=e,d=l,a=t.createDocumentFragment();if(!a)return null;let C=M(l.props?.children);v("render")&&A("render","debug","",`fragment kids=${I(C)} fid=${r??"-"}`);let x=t.createComment(re({type:"fragment-start",key:o,id:i,fid:r})),_=t.createComment(re({type:"fragment-end",key:o,id:i,fid:r}));x&&a.appendChild(x),d._refNode=x;for(let m=0;m<C.length;m++){let $=C[m],X=r!=null?`${r}-${m}`:String(m),k=$==null||typeof $=="boolean"?ae(t,$):P($,n,t,String(m),null,X);k!=null&&a.appendChild(k)}return _&&a.appendChild(_),a}function Xe(e,n,t){let o=e,i=o;if(typeof i._render!="function")throw new Error(`[vdom2] component ${oe(o.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`);let r=i._child;if(r==null)return i._child=null,null;i._child=r,i._outputChild=r,typeof r=="object"&&!Array.isArray(r)&&(r._parentVNode=o);let l=P(r,n,t);if(l){if(i._refNode=l.nodeType===11?l.firstChild:l,i._id)if(l.nodeType===11)for(let d of Array.from(l.childNodes))d.nodeType===1&&d.setAttribute("data-wf-id",i._id);else l.nodeType===1&&l.setAttribute("data-wf-id",i._id);if(i.key!=null)if(l.nodeType===11)for(let d of Array.from(l.childNodes))d.nodeType===1&&d.setAttribute("data-wf-key",i.key);else l.nodeType===1&&l.setAttribute("data-wf-key",i.key)}return l}function Ye(e,n,t,o,i){let r=e,l=r,d=r.type,a=Ke.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!a)return null;l.el=a,l._refNode=a,v("render")&&A("render","trace","",`native <${d}> key=${r.key??"-"} kids=${I(M(r.props?.children))}`),r.key!=null&&a.setAttribute("data-wf-key",r.key);let C=null;for(let[x,_]of Object.entries(r.props??{}))if(!(x==="children"||x==="key")){if(x==="value"&&a instanceof HTMLSelectElement){C=_;continue}de(a,x,_)}if(!("innerHTML"in(r.props??{}))){let x=M(r.props?.children);for(let _=0;_<x.length;_++){let m=x[_],$=i!=null?`${i}-${_}`:String(_),X=m==null||typeof m=="boolean"?ae(t,m):P(m,n,t,String(_),null,$);if(X!=null&&(a.appendChild(X),m&&typeof m=="object"&&!Array.isArray(m)&&typeof m.type=="function")){let k=m;k._parentNode||(k._parentNode=a)}}v("render")&&A("render","trace","",`native <${d}> out=${G(a)}`)}return C!==null&&(a.value=String(C)),a}var Ze={hole:We,text:Ue,arr:ze,portal:Ge,frag:Je,comp:Xe,native:Ye};function Z(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=P(e.newInput,i,i.browser??F());if(r==null)return null;if(t?.parentNode){let l=ne(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function Qe(e){return ne(e.oldInput,e.oldNode,e.parent,e.ctx),null}function en(e){let n=e.oldNode;if(n?.nodeType===8){let t=ae(e.ctx.browser??F(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ie(e){let{parent:n,oldNode:t,ctx:o}=e,i=P(e.newInput,o,o.browser??F());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function nn(e){let{parent:n,oldNode:t,oldInput:o}=e,i=String(e.newInput);if(String(o)!==i){if(t&&t.nodeType===3)return t.nodeValue=i,t;let r=n.ownerDocument.createTextNode(i);return t?.parentNode?t.parentNode.replaceChild(r,t):n.appendChild(r),r}return t}function tn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=r.type;if(t&&t.nodeType===1&&(l?.type??null)===d&&ve(r)){let a=t;return r.el=a,r._refNode=a,$e(a,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||fe(a,l?.props?.children??null,r.props?.children??null,i),a}return Z(e)}function on(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput,l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=B(l)?S(l,t):null,a=Ce(n,l??o,r,i,d);return t?.parentNode?t:a[0]??null}function rn(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!D(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${oe(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null,d=l?.type===r.type;if(!i.force&&l&&d&&l._child!==null&&r._child===l._child)return t;l?.type===r.type&&l._id&&(r._id=l._id,i.registry.idRegistry.set(r._id,r)),r._parentNode=n,t&&(r._refNode=t);let a=r._child;if(a===null)return r._outputChild=null,Q(n,t,l?._child,null,i);r._outputChild=a;let C=Q(n,t,l?._child,a,i);return C&&(r._refNode=C),C}function ln(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e;if(o===e.newInput&&t?.parentNode)return t;let r=n.ownerDocument.createDocumentFragment(),l=fe(n,o,e.newInput,i,t?[t]:null);for(let d of l)d&&r.appendChild(d);return t?.parentNode?r.contains(t)?n.appendChild(r):t.parentNode.replaceChild(r,t):n.appendChild(r),r}function sn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(H(i)&&H(o)){let r=i._remoteEl;if(r){let l=i.props?.children??null,d=o.props?.children??null;fe(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return Z(e)}function ee(e){return{text:Z,native:Z,frag:Z,comp:Z,arr:Z,hole:Qe,portal:Z,...e}}var dn={text:ee({text:nn}),hole:ee({text:ie,native:ie,frag:ie,comp:ie,arr:ie,portal:ie,hole:en}),native:ee({native:tn}),frag:ee({frag:on}),comp:ee({comp:rn}),arr:ee({arr:ln}),portal:ee({portal:sn})};function Te(e){let n=se(e.oldInput),t=se(e.newInput);return dn[n][t](e)}function L(e,n){if(n&&typeof e.type=="function"&&e._id){try{R(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Ae(n,e._id)}}function ce(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return H(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function _e(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=S(e,n);if(t&&t.length>1)return t}return[n]}function Re(e,n){let t=M(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;typeof i.type=="function"?L(i,n):(i.type===O||typeof i.type=="string"||typeof i.type=="symbol")&&Re(i,n)}}function ne(e,n,t,o){let i=null;if(Array.isArray(e)){let r=S(e,n);if(r&&r.length){i=(r[r.length-1]??n)?.nextSibling??null;for(let l of r)l.parentNode&&l.parentNode.removeChild(l);return i&&i.parentNode===t?i:null}return n?.parentNode&&n.parentNode.removeChild(n),n?.nextSibling??null}if(e&&typeof e=="object"&&!Array.isArray(e)){let r=e;if(B(r)){let d=S(r,n)??[];i=(d[d.length-1]??n)?.nextSibling??null;for(let a of d)a.parentNode&&a.parentNode.removeChild(a);return Re(r,o.registry),i&&i.parentNode===t?i:null}if(H(r)){let l=r._remoteEl;try{R(r.props?.children,o.registry)}catch(d){console.error("[weifuwu] portal ref cleanup error",d)}return l?.parentNode?.removeChild(l),null}if(typeof r.type=="function"){let l=S(r,n);if(L(r,o.registry),l&&l.length>1){i=(l[l.length-1]??n)?.nextSibling??null;for(let d of l)d.parentNode&&d.parentNode.removeChild(d);return i&&i.parentNode===t?i:null}}else try{R(r,o.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}}return i=n?.nextSibling??null,n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function Q(e,n,t,o,i){return Te({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}function $e(e,n,t){let o=Object.keys(n),i=Object.keys(t);if(o.length===i.length){let l=!0;for(let d=0;d<o.length;d++)if(o[d]!==i[d]||n[o[d]]!==t[o[d]]){l=!1;break}if(l)return}let r=new Set([...o,...i]);for(let l of r){if(l==="children"||l==="key")continue;let d=n[l],a=t[l];if(d!==a){if(ye.test(l)){let{type:C,capture:x}=be(l);typeof d=="function"&&e.removeEventListener(C,d,x?{capture:!0}:{}),a!=null&&a!==!1&&(typeof a!="function"?console.warn(`[weifuwu] event prop ${l} expects a function, got ${typeof a} \u2014 ignored`):e.addEventListener(C,a,x?{capture:!0}:{}));continue}if(l==="class"||l==="className"){a==null||a===!1?e.removeAttribute("class"):(e.className="",de(e,l,a));continue}if(a==null||a===!1){if(l==="class"||l==="className")e.removeAttribute("class");else if(ye.test(l))e.removeEventListener(l.slice(2).toLowerCase(),d);else if(l==="ref"){if(typeof d=="function")try{d(null)}catch(C){console.error("[weifuwu] ref cleanup error",C)}}else if(l==="value")e.value="";else if(l==="indeterminate")e.indeterminate=!1;else{e.removeAttribute(l);try{delete e[l]}catch{}}continue}de(e,l,a)}}}function Ce(e,n,t,o,i){let r=Array.isArray(n)?n:n?.props?.children??null,l=Array.isArray(t)?t:t?.props?.children??null;return fe(e,r,l,o,i)}function fe(e,n,t,o,i,r){let l=M(n),d=M(t),a=i??Array.from(e.childNodes);v("diff")&&A("diff","debug","",`patchChildren parent=${W(e)} old=${I(l)} new=${I(d)} dom=${G(e)}`);let C=d.some(u=>{if(u==null||typeof u!="object"||Array.isArray(u))return!1;let c=u;return!H(c)&&c.key!==null}),x=d.some(u=>Array.isArray(u))||l.some(u=>Array.isArray(u));v("diff")&&A("diff","debug","",`mode=${C&&!x?"keyed":"unkeyed"} hasUserKey=${C} hasArrayItem=${x}`);let _=i&&i.length?i[i.length-1]:null;if(C){for(let u=0;u<d.length;u++){let c=d[u];c&&typeof c=="object"&&!Array.isArray(c)&&ce(c)===null&&(c.key=`pos:${u}`)}for(let u=0;u<l.length;u++){let c=l[u];c&&typeof c=="object"&&!Array.isArray(c)&&ce(c)===null&&(c.key=`pos:${u}`)}}let m=(()=>{let u=a;u.length>=2&&u[0]?.nodeType===8&&u[0].nodeValue?.includes("fragment-start")&&u[u.length-1]?.nodeType===8&&u[u.length-1].nodeValue?.includes("fragment-end")&&(u=u.slice(1,-1));let c=[],w=0;for(let h=0;h<l.length;h++){let s=l[h];if(Array.isArray(s)){let f=u[w]??null;c.push(f);let b=S(s,f);w+=b?.length??1;continue}if(s==null||typeof s=="boolean"||typeof s=="string"||typeof s=="number"){c.push(u[w]??null),w++;continue}let y=s;if(H(y)){c.push(y._remoteEl??null);continue}if(c.push(y._refNode??u[w]??null),typeof y.type=="function"||B(y)){let f=S(y,y._refNode??u[w]??null);w+=f?.length??1}else w++}return c})();if(x||!d.some(u=>{if(u==null||typeof u!="object"||Array.isArray(u))return!1;let c=u;return!H(c)&&c.key!==null})){let u=Math.max(l.length,d.length),c=[],w=h=>{r&&r.push(h)};for(let h=0;h<u;h++){let s=h<l.length?l[h]:null,y=h<d.length?d[h]:null;if(v("diff")&&A("diff","trace","",`pos ${h} old=${z(s)} new=${z(y)} oldNode=${W(m[h])}`),y==null||typeof y=="boolean"){let N=m[h],j=o.browser??F();if(h>=d.length){if(Array.isArray(s)){v("diff")&&A("diff","trace","",`remove-arr-item i=${h} range=[${(S(s,m[h])??[]).map(W).join(" | ")}] before=${G(e)}`);let V=S(s,m[h]);for(let g of V??[])g.parentNode?.removeChild(g);v("diff")&&A("diff","trace","",`remove-arr-item after=${G(e)}`);for(let g of s)g!=null&&typeof g=="object"&&!Array.isArray(g)&&typeof g.type=="function"&&L(g,o.registry)}else if(s&&typeof s=="object"&&!Array.isArray(s)){if(typeof s.type=="function")L(s,o.registry);else try{R(s,o.registry)}catch(V){console.error("[weifuwu] ref cleanup error",V)}N?.parentNode&&N.parentNode.removeChild(N)}else N?.parentNode&&N.parentNode.removeChild(N);c.push(null),w(null);continue}let p=ue(j,y);if(s==null||typeof s=="boolean"){if(N?.nodeType===8)p&&N.nodeValue!==p.nodeValue&&(N.nodeValue=p.nodeValue),c.push(N),w(N);else if(p&&N?.parentNode)N.parentNode.replaceChild(p,N);else if(p){let V=null;for(let g=h+1;g<m.length;g++){let E=m[g];if(E&&E.parentNode===e){V=E;break}}if(!V){let g=null;for(let E=c.length-1;E>=0;E--)if(c[E]){g=c[E];break}g&&g.parentNode===e&&(V=g.nextSibling)}V&&V.parentNode===e?e.insertBefore(p,V):e.appendChild(p),c.push(p),w(p)}else c.push(p),w(p);continue}if(Array.isArray(s)||s!=null&&typeof s=="object"&&B(s)){let V=S(s,m[h]),g=((V??[])[V?.length?V.length-1:0]??N)?.nextSibling??null;for(let E of V??[])E.parentNode?.removeChild(E);for(let E of M(s?.props?.children))E!=null&&typeof E=="object"&&!Array.isArray(E)&&typeof E.type=="function"&&L(E,o.registry);p&&g&&g.parentNode===e?e.insertBefore(p,g):p&&e.appendChild(p),c.push(p),w(p);continue}if(s&&typeof s=="object"&&!Array.isArray(s)&&s.type===O){let V=ne(s,N,e,o);p&&V?e.insertBefore(p,V):p&&e.appendChild(p),c.push(p),w(p);continue}if(s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"){let V=ne(s,N,e,o);p&&V?e.insertBefore(p,V):p&&e.appendChild(p),c.push(p),w(p);continue}if(s&&typeof s=="object"&&!Array.isArray(s))if(typeof s.type=="function")L(s,o.registry);else try{R(s,o.registry)}catch(V){console.error("[weifuwu] ref cleanup error",V)}p&&N?.parentNode?N.parentNode.replaceChild(p,N):p&&e.appendChild(p),c.push(p),w(p);continue}if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&y!=null&&typeof y=="object"&&!Array.isArray(y)&&y===s){c.push(m[h]),w(m[h]);continue}if(s==null||typeof s=="boolean"){if(y==null||typeof y=="boolean"){let V=m[h]??null;c.push(V),w(V);continue}let N=P(y,o,o.browser??F(),String(h));if(N==null){c.push(null),w(null);continue}let j=m[h];if(j&&j.nodeType===8&&j.nodeValue?.includes("type=hole")){j.parentNode?.replaceChild(N,j),c.push(N),w(N);continue}let p=null;for(let V=h+1;V<m.length;V++){let g=m[V];if(g&&g.parentNode===e){p=g;break}}if(!p){let V=null;for(let g=c.length-1;g>=0;g--)if(c[g]){V=c[g];break}if(V&&V.parentNode===e&&(p=V.nextSibling),!p){let g=m[m.length-1];g&&g.parentNode===e&&(p=g.nextSibling)}}p&&p.parentNode===e?e.insertBefore(N,p):e.appendChild(N),c.push(N),w(N);continue}if(Array.isArray(y)||y!=null&&typeof y=="object"&&B(y)){let N=o.browser??F();if(Array.isArray(s)||s!=null&&typeof s=="object"&&B(s)){let le=S(s,m[h]),Y=Ce(e,s,y,o,le);c.push(...Y),w(m[h]??Y[0]??null);continue}let p=P(y,o,N,String(h));if(p==null){c.push(null),w(null);continue}let V=m[h],g=s&&typeof s=="object"?S(s,V):null;if(g&&g.length>1){let le=(g[g.length-1]??V)?.nextSibling??null;for(let Y of g)Y.parentNode&&Y.parentNode.removeChild(Y);if(s&&typeof s=="object"&&!Array.isArray(s))if(typeof s.type=="function")L(s,o.registry);else try{R(s,o.registry)}catch(Y){console.error("[weifuwu] ref cleanup error",Y)}le&&le.parentNode===e?e.insertBefore(p,le):e.appendChild(p)}else V?.parentNode?V.parentNode.replaceChild(p,V):e.appendChild(p);let E=p.nodeType===11?Array.from(p.childNodes):[p];c.push(...E),w(E[0]??p);continue}if(Array.isArray(s)||s!=null&&typeof s=="object"&&B(s)){let N=o.browser??F(),j=S(s,m[h]);v("diff")&&A("diff","debug","",`multi-remove i=${h} range=${j?j.map(W).join(" | "):"null"}`);for(let g of j??[])g.parentNode?.removeChild(g);for(let g of M(s?.props?.children))g!=null&&typeof g=="object"&&!Array.isArray(g)&&typeof g.type=="function"&&L(g,o.registry);let p=P(y,o,N,String(h));if(p==null){c.push(null),w(null);continue}let V=m[h+1]??null;V?.parentNode?V.parentNode.insertBefore(p,V):e.appendChild(p),c.push(p),w(p);continue}let b=Q(e,m[h],s,y,o);v("diff")&&A("diff","trace","",`after-patch i=${h} new=${z(y)} node=${W(b)} dom=${G(e)}`);let q=_e(y,b);c.push(...q),w(q[0]??b??null)}return c}let X=new Map;l.forEach((u,c)=>{let w=ce(u);w!==null&&u&&typeof u=="object"&&!Array.isArray(u)&&X.set(w,{vnode:u,nodes:[m[c]??null].filter(Boolean),index:c})});let k=[],xe=new Set,U=u=>{r&&r.push(u)},T=null;return d.forEach((u,c)=>{let w=ce(u),h=u;if(w!==null&&X.has(w)){let s=X.get(w),y=s.nodes[0]??null;xe.add(w);let f=Q(e,y,s.vnode,h,o),b=_e(h,f),q=b[0]??f,N=b[b.length-1]??f;if(q&&q.parentNode===e&&T&&q.previousSibling!==T){v("diff")&&A("diff","debug","",`keyed-correct i=${c} k=${w} move=[${b.map(W).join(" | ")}] after=${W(T)} before=${G(e)}`);let j=T.nextSibling;for(let p of b)p&&p.parentNode===e&&e.insertBefore(p,j);v("diff")&&A("diff","debug","",`keyed-correct after=${G(e)}`)}k.push(...b),U(b[0]??f??null),N&&(T=N)}else{if(u==null||typeof u=="boolean"){let s=l[c]??null,y=m[c]??null,f=ue(o.browser??F(),u);if(s==null||typeof s=="boolean")y?.nodeType===8?(f&&y.nodeValue!==f.nodeValue&&(y.nodeValue=f.nodeValue),k.push(y),U(y),y&&(T=y)):(f&&y?.parentNode?y.parentNode.replaceChild(f,y):f&&e.appendChild(f),k.push(f),U(f),f&&(T=f));else{if(Array.isArray(s)||s!=null&&typeof s=="object"&&B(s)){let b=S(s,m[c]),q=((b??[])[b?.length?b.length-1:0]??y)?.nextSibling??null;for(let N of b??[])N.parentNode?.removeChild(N);for(let N of M(s?.props?.children))N!=null&&typeof N=="object"&&!Array.isArray(N)&&typeof N.type=="function"&&L(N,o.registry);f&&q&&q.parentNode===e?e.insertBefore(f,q):f&&e.appendChild(f),k.push(f),U(f),f&&(T=f);return}if(typeof s=="object"&&!Array.isArray(s)&&s.type===O){let b=ne(s,y,e,o);f&&b?e.insertBefore(f,b):f&&e.appendChild(f),k.push(f),U(f),f&&(T=f);return}if(typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"){let b=ne(s,y,e,o);f&&b?e.insertBefore(f,b):f&&e.appendChild(f),k.push(f),U(f),f&&(T=f);return}if(typeof s=="object"&&!Array.isArray(s))if(typeof s.type=="function")L(s,o.registry);else try{R(s,o.registry)}catch(b){console.error("[weifuwu] ref cleanup error",b)}f&&y?.parentNode?y.parentNode.replaceChild(f,y):f&&e.appendChild(f),k.push(f),U(f),f&&(T=f)}return}if(H(h)){let s=l[c]??null,y=Q(e,m[c]??null,s,h,o),f=_e(h,y);k.push(...f),U(f[0]??y??null);let b=f[f.length-1]??y;b&&(T=b)}else{let s=P(h,o,o.browser??F());if(k.push(s),U(s??null),s!=null){let y=m[c];y&&y.nodeType===8&&y.nodeValue?.includes("type=hole")?(y.parentNode?.replaceChild(s,y),T=s):(T?e.insertBefore(s,T.nextSibling):_&&_.parentNode===e?e.insertBefore(s,_):e.insertBefore(s,e.firstChild),T=s)}}}}),l.forEach((u,c)=>{let w=ce(u),h=u&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function";if(w!==null&&!xe.has(w)){let s=u&&typeof u=="object"&&!Array.isArray(u)?S(u,m[c]):null;if(v("diff")&&A("diff","trace","",`keyed-delete i=${c} k=${w} range=${s?.length??0} oldNode=${W(m[c])}`),u&&typeof u=="object"&&!Array.isArray(u))if(h)L(u,o.registry);else try{R(u,o.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let y=m[c];if(s&&s.length>1)for(let f of s)f.parentNode&&f.parentNode.removeChild(f);else y?.parentNode&&y.parentNode.removeChild(y)}else if(w===null){let s=m[c];if(!(s?.nodeType===8&&s.nodeValue?.includes("type=hole"))||c>=d.length){if(u&&typeof u=="object"&&!Array.isArray(u))if(h)L(u,o.registry);else try{R(u,o.registry)}catch(b){console.error("[weifuwu] ref cleanup error",b)}let f=u&&typeof u=="object"&&!Array.isArray(u)?S(u,s):null;if(f&&f.length>1)for(let b of f)b.parentNode&&b.parentNode.removeChild(b);else s?.parentNode&&s.parentNode.removeChild(s)}}}),k}function Pe(e,n,t,o){let i=t,r=i.__registry??te(),l=i.browser??F();return Promise.resolve(J(n,i,null,r)).then(()=>{let d=P(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let a=r.idRegistry.get(n._id);a&&(a._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function yt(e,n,t){return new Promise(o=>{Pe(e,n,t,{onMounted:o})})}async function mt(e,n,t,o,i){return await J(o,i,t,i.__registry),Q(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function gt(e,n){let t=n.__registry??(n.__registry=te());return Promise.resolve(J(e,n,void 0,t))}async function ht(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function Nt(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function me(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)me(o,n);return}n(e);let t=e?.props?.children;t!=null&&me(t,n)}function Vt(e,n){let t;return me(e,o=>{!t&&n(o)&&(t=o)}),t}function wt(e,n){let t=[];return me(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function bt(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function Ct(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{gt as buildToDom,Ct as createPopupMock,bt as createTestCtx,wt as findByClass,Vt as findVNode,Nt as mountComponent,yt as mountToDom,mt as patchToDom,ht as renderVNode,me as walkVNode};
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* 在 aiStream(传输解码)之上加一层「一段对话」的语义:
|
|
5
5
|
* 消息累积、工具调用内嵌、HITL 审批、错误恢复、stop/retry/clear。
|
|
6
6
|
*
|
|
7
|
-
* - 协议透明:消费 wf: 事件(
|
|
7
|
+
* - 协议透明:消费 wf: 事件(docs/ai-contract.md),页面不需要知道事件名
|
|
8
8
|
* - 状态即共享 store(render-only 方案——design/render-only-plan.md):
|
|
9
9
|
* state 是**普通对象**(非 Proxy),变化 → notify() → 订阅者(useExternal)重渲染;
|
|
10
10
|
* handle 带 subscribe——可被 useExternal 订阅(AiChat 等共享会话的子组件)
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* vdom2/audit — 结构一致性运行时校验(design/vdom-consistency-plan.md 阶段 C)
|
|
3
3
|
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
4
|
+
* 把「用户的想法 = vnode = DOM」变成每次 patch 的断言——错位即报错(dev),
|
|
5
|
+
* 不静默传播(提交按钮消失事故的根治)。vdom2 版:vnode2 强类型 + 类型守卫。
|
|
6
6
|
*
|
|
7
7
|
* 开关:`__WF_VDOM_AUDIT`(dev/测试全开,生产默认关——O(n) 递归零生产开销)。
|
|
8
8
|
* 校验项:
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
import type { VNodeChild } from '../vnode.ts';
|
|
15
15
|
/** audit 开关(dev/测试注入;生产默认关) */
|
|
16
16
|
export declare function auditEnabled(): boolean;
|
|
17
|
-
/** 数组级校验:childNodes 与 children 数组对齐(A1/A2
|
|
18
|
-
export declare function auditChildren(parent: Node, children: VNodeChild[] | null
|
|
17
|
+
/** 数组级校验:childNodes 与 children 数组对齐(A1/A2——占位错位/数量错位) */
|
|
18
|
+
export declare function auditChildren(parent: Node, children: VNodeChild[] | null, report: (msg: string) => void): void;
|
|
19
19
|
/** 树级校验:vnode 树 ↔ DOM 树递归对照(A3/A4)——入口调用一次 */
|
|
20
20
|
export declare function auditTree(parent: Node, child: VNodeChild, report: (msg: string) => void): void;
|
|
@@ -14,16 +14,16 @@
|
|
|
14
14
|
* 已构建 native)同步返回——零微任务。调用方统一 await 吸收(同步值 await 仅 1 微任务)。
|
|
15
15
|
*/
|
|
16
16
|
import type { VNode, VNodeChild } from '../vnode.ts';
|
|
17
|
-
import type
|
|
17
|
+
import { type VdomCtx } from './ctx.ts';
|
|
18
18
|
import { type Registry } from './registry.ts';
|
|
19
19
|
/** 组件 props 浅比较(三态 skip 判定) */
|
|
20
20
|
export declare function componentPropsEqual(a: Record<string, any>, b: Record<string, any>): boolean;
|
|
21
21
|
/** 挂载 async 组件:await 工厂(两阶段:外层 mount 一次)→ 设 _render + 分配 id + childCtx */
|
|
22
|
-
export declare function mountAsyncComponent(vnode: VNode, ctx:
|
|
23
|
-
reuse?: VNode;
|
|
22
|
+
export declare function mountAsyncComponent(vnode: VNode, ctx: VdomCtx, reg: Registry, opts?: {
|
|
23
|
+
reuse?: VNode | null;
|
|
24
24
|
}): Promise<{
|
|
25
25
|
renderFn: (props: VNode['props']) => Promise<VNode | null>;
|
|
26
|
-
childCtx:
|
|
26
|
+
childCtx: VdomCtx;
|
|
27
27
|
}>;
|
|
28
28
|
/**
|
|
29
29
|
* 递归展开组件树:await 工厂 → renderFn → 递归子树。**零 DOM**。
|
|
@@ -36,6 +36,6 @@ export declare function mountAsyncComponent(vnode: VNode, ctx: WfuiContext, reg:
|
|
|
36
36
|
* - V3-2:非 async——剪枝/文本/null/已构建 native 同步返回(零微任务);
|
|
37
37
|
* 组件路径(工厂 + renderFn await)返回 Promise(异步契约不变)
|
|
38
38
|
*/
|
|
39
|
-
export declare function buildVNode(input: VNodeChild, ctx:
|
|
39
|
+
export declare function buildVNode(input: VNodeChild, ctx: VdomCtx, oldInput?: VNodeChild, reg?: Registry, opts?: {
|
|
40
40
|
force?: boolean;
|
|
41
41
|
}): VNodeChild | Promise<VNodeChild>;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2 ctx — 类型化渲染上下文(强类型——替代散落的 `ctx as any`/WfuiContext 宽松类型)
|
|
3
|
+
*
|
|
4
|
+
* ctx 是开放扩展(中间件/组件注入任意字段如 data/route)——本接口定义 vdom 引擎
|
|
5
|
+
* 依赖的已知字段;扩展字段由注入方 cast 到具体接口。
|
|
6
|
+
*/
|
|
7
|
+
import type { BrowserEnv } from '../types.ts';
|
|
8
|
+
import type { Registry } from './registry.ts';
|
|
9
|
+
/** ctx.ui(组装层 ui-dom/context.ts 提供完整能力——引擎只依赖以下字段) */
|
|
10
|
+
export interface VdomUi {
|
|
11
|
+
_ctxVersion?: number;
|
|
12
|
+
_mounting?: boolean;
|
|
13
|
+
_rootVNodeId: string | null;
|
|
14
|
+
setMounting?(v: boolean): void;
|
|
15
|
+
endMounting?(): void;
|
|
16
|
+
render(ids?: string[]): Promise<void>;
|
|
17
|
+
}
|
|
18
|
+
/** vdom2 渲染上下文(build/render/patch/mount 依赖的已知字段)——ui 必填(由组装层 ui-dom/context.ts 创建) */
|
|
19
|
+
export interface VdomCtx {
|
|
20
|
+
browser: BrowserEnv;
|
|
21
|
+
__registry: Registry;
|
|
22
|
+
ui: VdomUi;
|
|
23
|
+
[key: string]: unknown;
|
|
24
|
+
}
|
|
25
|
+
/** 组件名提取(强类型——替代 `(type as any).name`) */
|
|
26
|
+
export declare function componentName(type: unknown): string;
|
|
27
|
+
/** ctx.ui 版本号(三态 skip 基准) */
|
|
28
|
+
export declare function ctxVersion(ctx: VdomCtx): number;
|
|
29
|
+
/** ctx.ui.render(组件内部 render 转发——闭包绑定 id 由组装层 childCtx 处理) */
|
|
30
|
+
export declare function ctxRender(ctx: VdomCtx, ids?: string[]): Promise<void>;
|
|
31
|
+
/** 挂载保护期开关(工厂执行期间跳过渲染请求) */
|
|
32
|
+
export declare function setMounting(ctx: VdomCtx, v: boolean): void;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2/hydrate — 游标收养(SSR HTML → 客户端,不重建 DOM)
|
|
3
|
+
*
|
|
4
|
+
* 流程:buildVNode 预构建(await 工厂——组件已 resolve、_child 已展开)→ 游标收养
|
|
5
|
+
* (只接线属性/事件/ref——不重跑 renderFn)。vdom2 版:vnode2 强类型 + 类型守卫。
|
|
6
|
+
*
|
|
7
|
+
* 游标不变量:元素/文本 VNode 恰好消耗一个游标节点;组件/Fragment/数组透明;
|
|
8
|
+
* null 消耗零;创建时 insertBefore(游标) 且游标不动;收养/替换时游标前进。
|
|
9
|
+
*/
|
|
10
|
+
import type { VNode } from '../vnode.ts';
|
|
11
|
+
import { type VdomCtx } from './ctx.ts';
|
|
12
|
+
/** Hydration 入口:buildVNode 预构建(await 工厂)→ 游标收养 */
|
|
13
|
+
export declare function hydrateVNode(container: Element, vnode: VNode, ctx: VdomCtx): Promise<void>;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2 引擎入口(TDD 实施中——测试见 src/test/vdom2-matrix.test.ts)
|
|
3
|
+
*/
|
|
4
|
+
export { mountRoot, createRenderer, type MountHandle, type Renderer } from './mount.ts';
|
|
5
|
+
export { buildVNode } from './build.ts';
|
|
6
|
+
export { renderValue } from './render.ts';
|
|
7
|
+
export { patchValue } from './patch.ts';
|
|
8
|
+
export { x2y, TRANSITIONS } from './transitions.ts';
|
|
9
|
+
export { x2html } from './x2html.ts';
|
|
10
|
+
export { auditEnabled, auditTree, auditChildren } from './audit.ts';
|
|
11
|
+
export { hydrateVNode } from './hydrate.ts';
|
|
12
|
+
export { classifyKind, getOutputRange } from './kind.ts';
|
|
13
|
+
export { h, jsx, jsxs, createPortal, Fragment, Portal, isNative, isFrag, isComp, isPortal } from '../vnode.ts';
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom 类型分类与输出范围(vdom-matrix 方案 2026-12)
|
|
3
|
+
*
|
|
4
|
+
* - classifyKind:children 值类型分类(单一判定源——替代散落的 typeof/Array.isArray/type=== 判断)
|
|
5
|
+
* - getOutputRange:输出 DOM 范围统一获取(多节点完整边界;单节点 null)——
|
|
6
|
+
* 范围定位用节点引用(Fragment._childNodes / 组件 _outputChild 递归 / 数组 fragment-start..end 标记),
|
|
7
|
+
* 不依赖外部下标。x2y 转换(transitions.ts)/ removeOldOutput 统一用它。
|
|
8
|
+
*
|
|
9
|
+
* 类型分类与 VNode 类层次见 vnode.ts(NativeVNode/FragVNode/CompVNode/PortalVNode 继承 VNode 基类);
|
|
10
|
+
* 文本/数组/占位是 JSX 原生值(string/Array/boolean/null)——classifyKind 分类后走同一转换表。
|
|
11
|
+
*/
|
|
12
|
+
import type { VNodeChild } from '../vnode.ts';
|
|
13
|
+
import { Fragment, Portal } from '../vnode.ts';
|
|
14
|
+
/** children 值类型分类(vdom 状态机状态) */
|
|
15
|
+
export type VKind = 'text' | 'native' | 'frag' | 'comp' | 'arr' | 'hole' | 'portal';
|
|
16
|
+
/** patchValue 分派上下文 */
|
|
17
|
+
export interface PatchState {
|
|
18
|
+
parent: Node;
|
|
19
|
+
oldNode: Node | null;
|
|
20
|
+
oldInput: VNodeChild;
|
|
21
|
+
newInput: VNodeChild;
|
|
22
|
+
ctx: {
|
|
23
|
+
browser: any;
|
|
24
|
+
registry: import('./registry.ts').Registry;
|
|
25
|
+
ctxVersion?: number;
|
|
26
|
+
force?: boolean;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
/** 输出范围统一获取(多节点输出完整边界;单节点/未知 → null)——类型守卫收窄,无散落 cast
|
|
30
|
+
* 统一协议(2026-12):Fragment 与数组项同构——多节点输出 = fragment-start/end 标记包裹,
|
|
31
|
+
* 范围由标记推导(anchor = start 标记,DOM 持久化——随移动/移除天然同步);组件经 _outputChild 递归 */
|
|
32
|
+
export declare function getOutputRange(input: VNodeChild, anchor: Node | null): Node[] | null;
|
|
33
|
+
/** 值分类(单一判定源——替代散落的 typeof/Array.isArray/type=== 判断) */
|
|
34
|
+
export declare function classifyKind(v: VNodeChild): VKind;
|
|
35
|
+
export { Fragment, Portal };
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2 mount — 纯引擎挂载核心(无 ctx 组装、无 hooks——那些在 ui-dom/context.ts 组装层)
|
|
3
|
+
*
|
|
4
|
+
* 分层(vdom2 方案):
|
|
5
|
+
* - vdom2/ = 纯渲染引擎(vnode/kind/render/patch/build/mount 核心——改 vdom 不影响其他)
|
|
6
|
+
* - ui-dom/context.ts = 组装层(createVdomContext:ctx.ui 完整能力 + hooks 转发 + popup tracker)
|
|
7
|
+
* - ui-dom/middleware/ = 中间件(uiServe 等——后续迁移)
|
|
8
|
+
*
|
|
9
|
+
* 渲染管线:buildVNode(async 预构建——await 全部工厂)→ renderValue(同步落地)
|
|
10
|
+
* ctx.ui.render:render-only(design/render-only-plan.md)——唯一渲染触发。
|
|
11
|
+
*/
|
|
12
|
+
import type { VNode, VNodeChild } from '../vnode.ts';
|
|
13
|
+
import { createRegistry, type Registry } from './registry.ts';
|
|
14
|
+
import { type VdomCtx } from './ctx.ts';
|
|
15
|
+
import type { BrowserEnv } from '../types.ts';
|
|
16
|
+
export interface MountOptions {
|
|
17
|
+
browser: BrowserEnv;
|
|
18
|
+
root: HTMLElement;
|
|
19
|
+
/** 完整 ctx(ui-dom/context.ts createVdomContext 组装——ui 必填) */
|
|
20
|
+
ctx: VdomCtx;
|
|
21
|
+
registry?: Registry;
|
|
22
|
+
renderer?: Renderer;
|
|
23
|
+
onError?: (e: unknown) => void;
|
|
24
|
+
}
|
|
25
|
+
export interface MountHandle {
|
|
26
|
+
ctx: any;
|
|
27
|
+
registry: Registry;
|
|
28
|
+
renderer: Renderer;
|
|
29
|
+
mount(comp: VNodeChild): Promise<void>;
|
|
30
|
+
rerender(): Promise<void>;
|
|
31
|
+
unmount(): void;
|
|
32
|
+
close?(): void;
|
|
33
|
+
}
|
|
34
|
+
export interface Renderer {
|
|
35
|
+
render(ids?: string[]): Promise<void>;
|
|
36
|
+
}
|
|
37
|
+
export interface VdomContext {
|
|
38
|
+
ctx: any;
|
|
39
|
+
registry: Registry;
|
|
40
|
+
renderer: Renderer;
|
|
41
|
+
rootUi: any;
|
|
42
|
+
}
|
|
43
|
+
/** 渲染执行器(render-only 唯一渲染入口——无调度队列,直接执行) */
|
|
44
|
+
export declare function createRenderer(opts: {
|
|
45
|
+
registry: Registry;
|
|
46
|
+
ctx: any;
|
|
47
|
+
rootEl?: HTMLElement | null;
|
|
48
|
+
onError?: (e: unknown) => void;
|
|
49
|
+
}): Renderer;
|
|
50
|
+
/** 纯引擎挂载(接受已组装 ctx——ui-dom/context.ts 提供便捷入口) */
|
|
51
|
+
export declare function mountRoot(opts: MountOptions): MountHandle;
|
|
52
|
+
export { createRegistry };
|
|
53
|
+
export type { Registry };
|
|
54
|
+
/** vdom2 命令式挂载(toast/notification 等——buildVNode await 工厂 → renderValue → append) */
|
|
55
|
+
export declare function mountCommand(container: HTMLElement, vnode: VNode, ctx: VdomCtx | import('../types.ts').WfuiContext, opts?: {
|
|
56
|
+
onMounted?: () => void;
|
|
57
|
+
}): {
|
|
58
|
+
id: string;
|
|
59
|
+
};
|
|
60
|
+
/** vdom2 命令式卸载:ref 清理 + 卸载钩子 + 容器移除 */
|
|
61
|
+
export declare function unmountCommand(container: HTMLElement, vnode: VNode | null, ctx: VdomCtx | import('../types.ts').WfuiContext): void;
|
|
62
|
+
/** 命令式挂载容器(toast 等——body 下) */
|
|
63
|
+
export declare function createCommandContainer(): HTMLDivElement | null;
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom/diff — 同步 patch(阶段 2)
|
|
3
|
+
*
|
|
4
|
+
* **不变量:diff 只处理已构建树**——组件 vnode 必已 `_render`/`_child`(buildVNode 预构建)。
|
|
5
|
+
* 遇未构建组件 → throw(开发期暴露;生产路径 renderByIds/导航都先 buildVNode await)。
|
|
6
|
+
* 这是第 1 代死循环的根治:diff 永不调用组件工厂、无 resolve 回调、无补全循环。
|
|
7
|
+
*
|
|
8
|
+
* 三态 skip:props 同 + 无 dirty + ctx 版本同 → 复用旧 _child(renderFn 不重跑)。
|
|
9
|
+
*/
|
|
10
|
+
import type { VNode, VNodeChild } from '../vnode.ts';
|
|
11
|
+
import { arrayChildren } from '../vnode.ts';
|
|
12
|
+
export { arrayChildren };
|
|
13
|
+
import { type Registry } from './registry.ts';
|
|
14
|
+
/** 组件 vnode 从树中移除:ref(null) 递归 + 卸载钩子(cleanupComponent) */
|
|
15
|
+
export declare function disposeComponent(vnode: VNode, registry?: Registry): void;
|
|
16
|
+
/**
|
|
17
|
+
* 移除旧输出的全部 DOM(Fragment 展开多节点 + Portal 容器)并做组件/ref 清理。
|
|
18
|
+
* @returns 移除后应插入新节点的位置(范围后兄弟;null = append 末尾)
|
|
19
|
+
* 真实 bug:Frag→div 类型切换只 replaceChild 锚点 → Fragment 其余节点(holes/标记/数组项)残留
|
|
20
|
+
* (frag-native-switch trace 定位 2026-12;同逻辑覆盖 Frag→null/Portal→null)
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeOldOutput(oldInput: VNodeChild, oldNode: Node | null, parent: Node, ctx: PatchCtx): Node | null;
|
|
23
|
+
export interface PatchCtx {
|
|
24
|
+
browser: any;
|
|
25
|
+
registry: import('./registry.ts').Registry;
|
|
26
|
+
/** 当前 ctx 版本号(三态 skip 版本比较:组件 _ctxVersion !== 当前版本 → 不 skip,
|
|
27
|
+
* 强制重渲染——bumpCtxVersion 递增后所有组件重跑 renderFn,如 i18n 切换语言) */
|
|
28
|
+
ctxVersion?: number;
|
|
29
|
+
/** force:跳过三态 skip(mountRoot.rerender 全量重跑用) */
|
|
30
|
+
force?: boolean;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* patchValue — 同步 diff 单一节点。
|
|
34
|
+
* @returns newInput 的实际 DOM(null = 无 DOM)
|
|
35
|
+
*/
|
|
36
|
+
export declare function patchValue(parent: Node, oldNode: Node | null, oldInput: VNodeChild, newInput: VNodeChild, ctx: PatchCtx): Node | null;
|
|
37
|
+
export declare function patchProps(el: Element, oldProps: Record<string, any>, newProps: Record<string, any>): void;
|
|
38
|
+
/**
|
|
39
|
+
* patchChildren — 数组 diff。
|
|
40
|
+
* @returns 每个新子项的 DOM 范围(Fragment 展开对齐)
|
|
41
|
+
*/
|
|
42
|
+
/** 多节点配对 diff(Fragment/数组项统一——2026-12 array2array):
|
|
43
|
+
* 展开 children(Fragment 项取 props.children;数组项传自身)→ patchChildren 递归。
|
|
44
|
+
* 位置循环多节点分支与 fragToFrag(keyed/顶层入口)共用——多节点 diff 实现单点。
|
|
45
|
+
* oldRange = 标记范围(getOutputRange——start/end + fid 配对) */
|
|
46
|
+
export declare function arrayToArray(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange: Node[] | null): (Node | null)[];
|
|
47
|
+
export declare function patchChildren(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange?: Node[] | null, anchorOut?: (Node | null)[]): (Node | null)[];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2 render — vnode → DOM(客户端渲染)
|
|
3
|
+
*
|
|
4
|
+
* 与 vdom1 同构的渲染语义,但组织方式为**类型分派表**(vdom2 方案):
|
|
5
|
+
* RENDERERS[classifyKind(v)] 查表调用——每类一个渲染函数,无 if-else 类型链。
|
|
6
|
+
* 渲染是「创建目标」——按目标类型分派(与 patch 的「源类型驱动 x2y」互补)。
|
|
7
|
+
*
|
|
8
|
+
* 输出范围协议(与 kind.ts getOutputRange 一致):
|
|
9
|
+
* - Fragment:_childNodes(输出节点数组)
|
|
10
|
+
* - 组件:_refNode = 输出范围首节点(非 DocumentFragment——展开后失效)
|
|
11
|
+
* - 数组项:fragment-start/end 标记(DOM 持久化)
|
|
12
|
+
*/
|
|
13
|
+
import type { VNodeChild } from '../vnode.ts';
|
|
14
|
+
import type { BrowserEnv } from '../types.ts';
|
|
15
|
+
/** 创建占位节点(数组上下文的无渲染值 → 注释节点,childNodes 与数组同构——规则表 §1) */
|
|
16
|
+
export declare function createHole(browser: BrowserEnv, v: unknown): Node | null;
|
|
17
|
+
/** 递归渲染(同步——组件必须已构建;首帧/新增路径) */
|
|
18
|
+
export declare function renderValue(v: VNodeChild, ctx: any, browser?: BrowserEnv, key?: string | null, id?: string | null, fid?: string | null): Node | null;
|
|
19
|
+
export declare function renderTree(v: VNodeChild, ctx: any, browser?: BrowserEnv): Node | null;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2/ssr — 服务端渲染(基于 x2html——与客户端 renderValue 同一类型遍历)
|
|
3
|
+
*
|
|
4
|
+
* ssrToString:组件 → HTML 片段(工厂 + renderFn 现场执行——SSR 无预构建)
|
|
5
|
+
* serializeData:__DATA__ 种子(hydration 同步命中)
|
|
6
|
+
* ssrPage:完整页面(路由 + 数据 + HTML + 种子)
|
|
7
|
+
*/
|
|
8
|
+
import type { Component } from '../vnode.ts';
|
|
9
|
+
import { type VdomCtx } from './ctx.ts';
|
|
10
|
+
/** __DATA__ 序列化(hydration 种子——< 转义防注入) */
|
|
11
|
+
export declare function serializeData(data: Map<string, unknown>): string;
|
|
12
|
+
/** SSR ctx:ui shim(hooks no-op)+ ctx.data(预取写入 dataStore) */
|
|
13
|
+
export declare function createSsrContext(serverCtx: Record<string, unknown>, dataStore: Map<string, unknown>): VdomCtx;
|
|
14
|
+
/** SSR 渲染组件 → HTML 片段(组件现场执行工厂 + renderFn) */
|
|
15
|
+
export declare function ssrToString(Comp: Component, props: Record<string, any>, serverCtx: any, opts?: {
|
|
16
|
+
data?: Map<string, unknown>;
|
|
17
|
+
}): Promise<string>;
|
|
18
|
+
export interface SsrPageResult {
|
|
19
|
+
html: string;
|
|
20
|
+
/** __DATA__ 脚本(hydration 种子) */
|
|
21
|
+
dataScript: string;
|
|
22
|
+
/** 完整 HTML 页面 */
|
|
23
|
+
page: string;
|
|
24
|
+
}
|
|
25
|
+
/** SSR 完整页面(路由 + 数据 + HTML + 种子) */
|
|
26
|
+
export declare function ssrPage(router: any, opts: {
|
|
27
|
+
url: string;
|
|
28
|
+
title?: string;
|
|
29
|
+
lang?: string;
|
|
30
|
+
rootId?: string;
|
|
31
|
+
styles?: string[];
|
|
32
|
+
}): Promise<SsrPageResult>;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom/trace — 结构化调试 trace(阶段级开关 + 渲染会话 traceId)
|
|
3
|
+
*
|
|
4
|
+
* 目的(design/vdom-trace-plan.md):
|
|
5
|
+
* - 一次建立全面 vdom 调试能力:build/render/diff/mount/audit 各阶段独立开关
|
|
6
|
+
* - traceId 关联同一渲染会话(renderByIds/首帧/导航)的全部日志——事故可回放
|
|
7
|
+
* - children 顺序可视化(kidsSeq)——快速定位顺序错乱类 bug(Fragment/数组项)
|
|
8
|
+
*
|
|
9
|
+
* 开启方式(三路,幂等解析):
|
|
10
|
+
* 1. URL query:?vdom_trace=build,render,diff(阶段子集);?vdom_trace=render:trace(阶段+级别);
|
|
11
|
+
* ?vdom_debug=1(兼容旧开关——全开 debug + audit)
|
|
12
|
+
* 2. 全局变量(页面加载前注入):window.__vdom_trace__ = { stages, level }
|
|
13
|
+
* 3. localStorage:localStorage.vdom_trace = 'render:debug'(运行时设置 + reload)
|
|
14
|
+
*
|
|
15
|
+
* 性能:关闭时零开销——trace() 首行 flag 检查;插桩点用 traceEnabled() 前置检查
|
|
16
|
+
* (关闭时连参数求值都跳过)。开启时高频路径(diff 逐位置)默认 trace 级(低于默认 debug)。
|
|
17
|
+
*
|
|
18
|
+
* 与 ../debug.ts(uiLog——递归深度/死循环定位)互补:trace 是阶段结构化日志,
|
|
19
|
+
* uiLog 是深度跟踪——两者独立开关、不冲突。
|
|
20
|
+
*/
|
|
21
|
+
import type { VNodeChild } from '../vnode.ts';
|
|
22
|
+
export type VdomStage = 'mount' | 'build' | 'render' | 'diff' | 'audit';
|
|
23
|
+
export type VdomLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
|
|
24
|
+
export interface VdomTraceConfig {
|
|
25
|
+
enabled: boolean;
|
|
26
|
+
/** 空 Set = 全阶段开启 */
|
|
27
|
+
stages: Set<VdomStage>;
|
|
28
|
+
/** 最低级别(info 起;debug/trace 明细) */
|
|
29
|
+
level: VdomLevel;
|
|
30
|
+
/** 组件名过滤(只输出含该名称的组件相关日志;null = 不过滤) */
|
|
31
|
+
filter: string | null;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* 解析开启配置(幂等——首次调用后缓存)。
|
|
35
|
+
* uiServe 在首帧渲染前调用一次;测试/Node 环境也可手动调用。
|
|
36
|
+
*/
|
|
37
|
+
export declare function initVdomTrace(): VdomTraceConfig;
|
|
38
|
+
/** 插桩点前置检查:阶段开启 + 级别满足(关闭时连参数求值都跳过) */
|
|
39
|
+
export declare function traceEnabled(stage: VdomStage, level?: VdomLevel): boolean;
|
|
40
|
+
/** 输出 trace 日志([vdom:{stage}] {traceId} {msg}) */
|
|
41
|
+
export declare function trace(stage: VdomStage, level: VdomLevel, msg: string, ...args: unknown[]): void;
|
|
42
|
+
/** 手动配置(测试/调试用——不受 init 时序/缓存影响) */
|
|
43
|
+
export declare function configureVdomTrace(c: Partial<Omit<VdomTraceConfig, 'enabled'>>): void;
|
|
44
|
+
export declare function nextTraceId(tag?: string): string;
|
|
45
|
+
/** children 顺序摘要:["div#list-simple | false | ARR(2) | str"] */
|
|
46
|
+
export declare function kidsSeq(kids: VNodeChild[] | null, max?: number): string;
|
|
47
|
+
/** 单值摘要(children 项) */
|
|
48
|
+
export declare function vnDesc(v: VNodeChild): string;
|
|
49
|
+
/** DOM 节点摘要 */
|
|
50
|
+
export declare function nodeDesc(n: Node | null): string;
|
|
51
|
+
/** DOM 子节点序列摘要(childNodes 顺序——与 kidsSeq 对照验证顺序一致性) */
|
|
52
|
+
export declare function childNodesSeq(parent: Node | null, max?: number): string;
|
|
@@ -6,8 +6,24 @@
|
|
|
6
6
|
* hydrateVNode 全部调用,禁止各路径各自实现形态判定(同一语义多套实现 = 漂移 = 转化分叉)。
|
|
7
7
|
*/
|
|
8
8
|
import type { VNodeChild } from '../vnode.ts';
|
|
9
|
-
|
|
9
|
+
import type { BrowserEnv } from '../types.ts';
|
|
10
|
+
/** wf-hole 值摘要(占位内容可见可审计:false/null/undefined/true/对象摘要/bad-vnode) */
|
|
10
11
|
export declare function holeDetail(v: unknown): string;
|
|
12
|
+
/** 统一 wf-hole 标记(规则表 §1——全部 wf-hole 同一格式,用户直接读 DOM 注释可懂):
|
|
13
|
+
* - 占位 `wf-hole: type=hole value=false key=0 id=_wf_5`
|
|
14
|
+
* - 边界 `wf-hole: type=fragment-start key="0" id="_wf_5"` / `wf-hole: type=fragment-end key="0"`
|
|
15
|
+
* - 诊断 `wf-hole: type=hole value="object {...}"`(value 承载内容)
|
|
16
|
+
* 字段:type 必写(hole/fragment-start/fragment-end);value/key/id 有则写。
|
|
17
|
+
* 前缀恒为 `wf-hole:`——diff/audit/hydrate 的占位判断(startsWith)不随格式演进变化 */
|
|
18
|
+
export declare function holeMarkup(opts: {
|
|
19
|
+
type: string;
|
|
20
|
+
value?: unknown;
|
|
21
|
+
key: string | null;
|
|
22
|
+
id: string | null;
|
|
23
|
+
fid: string | null;
|
|
24
|
+
}): string;
|
|
25
|
+
/** 解析 wf-hole 注释字段(type/key/depth/id/value——统一格式,单一解析点) */
|
|
26
|
+
export declare function parseHoleMarkup(nodeValue: string): Record<string, string>;
|
|
11
27
|
/** children 项分类(规则表 §1)——唯一判定,消费方只调函数不写判定 */
|
|
12
28
|
export type ChildKind = 'text' | 'hole' | 'native' | 'component' | 'fragment' | 'portal' | 'array' | 'invalid';
|
|
13
29
|
export declare function classifyChild(c: VNodeChild): ChildKind;
|
|
@@ -30,3 +46,8 @@ export declare function eventTarget(key: string): {
|
|
|
30
46
|
export declare const ENUMERATED_VALUE_BASED: Set<string>;
|
|
31
47
|
/** CSS 无单位属性(数字不加 px)——其余数字样式属性必须加 px(规则表 §2 UNITLESS 白名单) */
|
|
32
48
|
export declare const UNITLESS_PROPS: Set<string>;
|
|
49
|
+
export declare function setProp(el: Element, key: string, value: any): void;
|
|
50
|
+
/** 占位内容(规则表 §1——wf-hole 内容可见可审计:false/null/undefined/true/对象摘要/bad-vnode) */
|
|
51
|
+
/** 创建占位节点(数组上下文的无渲染值 → 注释节点,childNodes 与数组同构——规则表 §1) */
|
|
52
|
+
export declare function createHole(browser: BrowserEnv, v: unknown): Node | null;
|
|
53
|
+
/** 递归渲染(同步——组件必须已构建) */
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* vdom2 x2y 转换状态机——**源类型驱动**:每个 (源, 目标) 组合一个转换函数,
|
|
3
|
+
* TRANSITIONS[oldKind][newKind] 查表分派(patchValue 用)。
|
|
4
|
+
*
|
|
5
|
+
* 转换动作由**源类型**决定(源最清楚自己的 DOM 形态如何移除/递归/复用):
|
|
6
|
+
* - 同类型:递归 patch(frag→frag children diff / comp→comp 输出递归 / native→native
|
|
7
|
+
* 同 tag in-place / arr→arr 数组递归 / text→text nodeValue 直改 / hole→hole 占位保持 /
|
|
8
|
+
* portal→portal 远程 patch)
|
|
9
|
+
* - 异类型:toOther 通用——renderValue 渲染目标 + removeOldOutput 移除旧输出
|
|
10
|
+
* (removeOldOutput 内部 getOutputRange 多态——每类输出范围:Fragment._childNodes /
|
|
11
|
+
* 组件 _outputChild 递归 / 数组 fragment-start..end 标记)
|
|
12
|
+
*
|
|
13
|
+
* 全量组合表显式列出——vdom2-matrix.test.ts 9×9 矩阵验证无遗漏。
|
|
14
|
+
*/
|
|
15
|
+
import { Fragment, Portal } from '../vnode.ts';
|
|
16
|
+
import { type PatchState, type VKind } from './kind.ts';
|
|
17
|
+
import { type PatchCtx } from './patch.ts';
|
|
18
|
+
type TransitionFn = (s: PatchState) => Node | null;
|
|
19
|
+
export declare const TRANSITIONS: Record<VKind, Record<VKind, TransitionFn>>;
|
|
20
|
+
/** x2y 状态机分派:由源类型(oldInput)与目标类型(newInput)查表调用转换函数 */
|
|
21
|
+
export declare function x2y(s: PatchState): Node | null;
|
|
22
|
+
export type { PatchCtx };
|
|
23
|
+
export { Fragment, Portal };
|