weifuwu 0.81.0 → 0.81.2

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.
@@ -1 +1 @@
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};
1
+ var ne=Symbol("Fragment"),ue=Symbol("Portal");function ke(e){return e!=null&&typeof e=="object"&&typeof e.type=="string"}function K(e){return e!=null&&typeof e=="object"&&e.type===ne}function C(e){return e!=null&&typeof e=="object"&&typeof e.type=="function"}function S(e){return e!=null&&typeof e=="object"&&e.type===ue}function _(e){return e==null||typeof e=="boolean"?[]:Array.isArray(e)?e:[e]}var Ne={error:0,warn:1,info:2,debug:3,trace:4},Re=["mount","build","render","diff","lifecycle","route","audit"],I={enabled:!1,stages:new Set,level:"info",filter:null},he=!1;function Je(e){return e&&e in Ne?e:"info"}function Te(e){let n=new Set;if(!e)return n;for(let t of e.split(",")){let o=t.trim().split(":")[0];Re.includes(o)&&n.add(o)}return n}function Ze(){if(he)return I;he=!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")I={enabled:!0,stages:new Set(Re),level:"debug",filter:null};else if(t||i||r){let l=new Set;if(t)for(let d of Te(t))l.add(d);if(i?.stages){let d=Array.isArray(i.stages)?i.stages:[...i.stages];for(let u of d)l.add(u)}if(r)for(let d of Te(r))l.add(d);I={enabled:!0,stages:l,level:t?.includes(":")?Je(t.split(":")[1]):i?.level??"debug",filter:typeof i?.filter=="string"?i.filter:null}}}catch{}return I}function m(e,n="info"){return!I.enabled&&(he||Ze(),!I.enabled)||I.stages.size&&!I.stages.has(e)?!1:Ne[n]<=Ne[I.level]}function h(e,n,t,...o){if(!m(e,n)&&!Pe())return;let i=I.filter;i&&!t.includes(i)||w({session:"",machine:e,nodeId:null,component:null,from:"",event:"TRACE",to:"",payload:()=>o.length?`${t} ${o.join(" ")}`:t,level:n,ts:Date.now()})}function A(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 Qe(e){return typeof e=="function"?"function":e===ne?"fragment":typeof e=="string"?"string":"other"}var en={function:e=>e.name||"Comp",fragment:()=>"Frag",string:e=>String(e),other:e=>String(e)};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=en[Qe(t)](t),i=n.props?.id?`#${n.props.id}`:n.key!=null?`@${n.key}`:"";return o+i}function k(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 O(e,n=12){if(!e)return"null";let o=Array.from(e.childNodes).slice(0,n).map(k);return e.childNodes.length>n&&o.push(`\u2026+${e.childNodes.length-n}`),`[${o.join(" | ")}]`}var nn={route:"route",lifecycle:"lifecycle",x2y:"diff",keys:"diff",pos:"diff",render:"render",audit:"audit",build:"build",mount:"mount",diff:"diff"};function Ie(e){return nn[e]}var Y=new Set;function tn(e){return Y.add(e),()=>{Y.delete(e)}}var $e=[];function on(){return $e[$e.length-1]??""}function w(e){if(Y.size!==0){e.session||(e.session=on()),typeof e.payload=="function"&&(Y.size>1||m(Ie(e.machine),e.level??"debug"))&&(e.payload=e.payload());for(let n of Y)try{n(e)}catch{}}}function Pe(){return Y.size>1}function rn(e){if(e==null)return"";if(typeof e=="string")return` ${e}`;if(typeof e=="object"){let n=e,t=[];for(let o of["path","i","key","mode","kind","insertedBefore","after","depth"])if(n[o]!==void 0){let i=n[o];t.push(`${o}=${typeof i=="object"?JSON.stringify(i):String(i)}`)}return t.length?" "+t.join(" "):""}return` ${String(e)}`}function ln(e){let n=Ie(e.machine);if(!m(n,e.level??"debug"))return;if(e.event==="TRACE"){console.log(`[vdom:${e.machine}] ${e.payload}`);return}let t=e.component?`${e.component}${e.nodeId?`(${e.nodeId})`:""}`:e.nodeId?`(${e.nodeId})`:"";console.log(`[vdom:${e.machine}] ${t?t+" ":""}${e.from} --${e.event}--> ${e.to}${rn(e.payload)}`)}tn(ln);var dn={fresh:{BUILD_START:"building",BUILD_DONE:"built",PRUNE:"pruned",DISPOSE:"disposed"},building:{BUILD_DONE:"built",DISPOSE:"disposed"},built:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},pruned:{BUILD_START:"building",PRUNE:"pruned",DISPOSE:"disposed"},disposed:{BUILD_START:"building"}};function R(e){let n=0,t=e._parentVNode??null;for(let o=0;o<10&&t;o++)n++,t=t._parentVNode??null;return{name:typeof e.type=="function"?e.type.name||"anonymous":String(e.type),id:e._id??null,depth:n}}var Le=new Map,sn=50;function un(e,n,t,o){if(!e?.id)return;let i=Le.get(e.id);i||(i={name:e.name??"?",events:[]},Le.set(e.id,i)),i.events.push(`${n}--${t}-->${o}`),i.events.length>sn&&i.events.shift()}function P(e,n,t){let o=dn[e]?.[n]??null;return o==null?(w({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:"?",level:"warn",ts:Date.now()}),e):(un(t,e,n,o),w({session:"",machine:"lifecycle",nodeId:t?.id??null,component:t?.name??null,from:e,event:n,to:o,payload:()=>({depth:t?.depth??0}),level:"debug",ts:Date.now()}),o)}function J(e){return!e||e._lifecycle==="disposed"||e._child==null?!1:!ge(e._child)}function ge(e){if(e==null||typeof e!="object")return!1;if(Array.isArray(e)){for(let t of e)if(ge(t))return!0;return!1}let n=e;return!!(n._lifecycle==="disposed"||n._child!=null&&ge(n._child))}var an=0;function U(){return{idRegistry:new Map,unmountHooks:[],nextId:()=>`_wf_${an++}`}}function Me(e,n){for(let t of[...e.unmountHooks])t(n);e.idRegistry.delete(n),e.idRegistry.delete(`custom:${n}`)}function cn(e,n,t,o){try{e(n)}catch(i){console.error(`[weifuwu] ref ${t} error in <${o??"anonymous"}>`,i)}}function b(e,n){if(e==null||typeof e!="object")return;let t=e;if(t._id){let o=R(t);if(t._customId&&n.idRegistry.delete(t._customId),n.idRegistry.delete(t._id),n.unmountHooks.length>0){let i=[...n.unmountHooks];for(let r of i)r(t._id);if(t._customId)for(let r of i)r(t._customId)}t._id=null,t._customId=null,C(t)&&(t._render=null),t._parentNode=null,t._refNode=null,t._lifecycle=P(t._lifecycle,"DISPOSE",o)}else(C(t)||t._child!=null)&&(t._lifecycle=P(t._lifecycle,"DISPOSE",R(t)));if(t._child!=null){if(Array.isArray(t._child))for(let o of t._child)o&&typeof o=="object"&&b(o,n);else b(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"&&b(i,n)}if(typeof t.props?.ref=="function"&&cn(t.props.ref,null,"cleanup"),S(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"&&b(r,n);else typeof i=="object"&&b(i,n);o.remove(),t._remoteEl=null}}}function v(e){return typeof e=="function"&&e.name||"anonymous"}function je(e){return e.ui?._ctxVersion??0}function Ve(e,n){e.ui?.setMounting?.(n)}function g(e,n){if(e==null||typeof e!="object")return null;if(Array.isArray(e)||K(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 C(t)?g(t._outputChild??t._child,n):null}function L(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 K(n)?"frag":S(n)?"portal":C(n)?"comp":"native"}function Ce(e){let n=!1,t=!1;for(let o of e){if(o==null||typeof o=="boolean"||typeof o=="string"||typeof o=="number")continue;if(Array.isArray(o)){t=!0;continue}let i=o;S(i)||(i.key!=null?n=!0:t=!0)}return n&&t?"mixed":n?"keyed":"unkeyed"}function fn(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 ae(e){return/[\s"=]/.test(e)?`"${e.replace(/"/g,"'")}"`:e}function Z(e){let n=[`type=${e.type}`];return e.value!==void 0&&n.push(`value=${ae(fn(e.value))}`),e.key!=null&&n.push(`key=${ae(e.key)}`),e.id!=null&&n.push(`id=${ae(e.id)}`),e.fid!=null&&n.push(`fid=${ae(e.fid)}`),`wf-hole: ${n.join(" ")}`}var pn=/^on[A-Z]/,yn=/^on[A-Z].*Capture$/;function _e(e){let n=yn.test(e);return{type:(n?e.slice(2,-7):e.slice(2)).toLowerCase(),capture:n}}var mn=new Set(["draggable","contenteditable","spellcheck","translate"]),Nn=new Set(["zIndex","opacity","lineHeight","fontWeight","fontSizeAdjust","flex","flexGrow","flexShrink","order","zoom","aspectRatio","gridRow","gridColumn","scale","rotate","animationIterationCount","columnCount","fillOpacity","strokeOpacity","stopOpacity","floodOpacity"]);function we(e){return mn.has(e)?"enumerated":e==="class"||e==="className"?"class":e==="style"?"style":e==="ref"?"ref":pn.test(e)?"event":e==="value"?"value":e==="indeterminate"?"indeterminate":e==="innerHTML"?"innerHTML":e.startsWith("aria-")?"aria":"default"}function De(e,n,t){if(t!==!1){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))}}}var hn={enumerated:(e,n,t)=>{e.setAttribute(n,t?"true":"false")},class:(e,n,t)=>{if(t!==!1)if(typeof t=="object")for(let[o,i]of Object.entries(t))i&&e.classList.add(o);else e.setAttribute("class",String(t))},style:(e,n,t)=>{if(t!==!1)if(typeof t=="string")e.setAttribute("style",t);else{let o=e.style;for(let[i,r]of Object.entries(t))r==null?o[i]="":i.startsWith("--")?o.setProperty(i,String(r)):typeof r=="number"&&!Nn.has(i)?o[i]=`${r}px`:o[i]=String(r)}},ref:(e,n,t)=>{if(typeof t=="function")try{t(e)}catch(o){console.error("[weifuwu] ref error",o)}},event:(e,n,t)=>{if(t===!1)return;let{type:o,capture:i}=_e(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}:{})},value:(e,n,t)=>{t!==!1&&(e.value=t)},indeterminate:(e,n,t)=>{t!==!1&&(e.indeterminate=!!t)},innerHTML:(e,n,t)=>{t!==!1&&(e.innerHTML=String(t??""))},aria:(e,n,t)=>{if(t!==!1){if(typeof t=="boolean"){e.setAttribute(n,t?"true":"false");return}De(e,n,t)}},default:De};function q(e,n,t){t!=null&&hn[we(n)](e,n,t)}function H(e,n){return e.createComment(Z({type:"hole",value:n,key:null,id:null,fid:null}))}function te(){return!!globalThis?.__WF_VDOM_AUDIT}function gn(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 Vn(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 u=n.ui;return d==null&&i._id?u.render([i._id]):u.render(d)},typeof i._render!="function"&&C(o?.reuse)&&typeof o.reuse._render=="function"&&(i._render=o.reuse._render),typeof i._render!="function"){Ve(n,!0);let d;try{d=await i.type(i.props??{},r)}finally{Ve(n,!1)}if(typeof d!="function")throw new Error(`Component ${v(e.type)} must return a render function. Use (init_props, ctx) => (props) => VNode pattern.`);i._render=d}return{renderFn:i._render,childCtx:r}}function be(e){return!!e&&typeof e.then=="function"}function B(e,n,t,o,i){return Cn[L(e)](e,n,t,o,i)}function xe(e,n){return e!=null&&typeof e=="object"&&!Array.isArray(e)&&e.type===n.type?e:null}var Cn={hole:e=>e,text:e=>e,arr:_n,comp:wn,frag:bn,native:Oe,portal:Oe};function _n(e,n,t,o,i){let r=e;m("build")&&h("build","debug","",`array in kids=${A(r)}`);for(let s of r)if(s!=null&&typeof s=="object"&&!Array.isArray(s)&&s._lifecycle==="disposed"){let a=s;w({session:"",machine:"audit",nodeId:a._id??null,component:v(a.type),from:"disposed",event:"CONTRACT_VIOLATION",to:"new-tree",level:"error",ts:Date.now()}),te()&&console.error(`[vdom2/audit] \u4E24\u9636\u6BB5\u5951\u7EA6\u8FDD\u53CD\uFF1A\u7EC4\u4EF6 ${v(a.type)} \u7684 renderFn \u8FD4\u56DE\u4E86 disposed \u65E7 vnode${a._id?`(${a._id})`:""}\u2014\u2014\u590D\u7528\u65E7\u6811\u5BF9\u8C61\uFF08\u5E94\u4E3A\u6BCF\u6B21\u6E32\u67D3\u751F\u6210\u65B0 vnode\uFF09\u3002\u540C\u4E00\u5BF9\u8C61\u65E2\u662F\u65E7\u6811\u53C8\u88AB dispose \u2192 diff \u81EA dispose \u2192 \u5361\u7247\u9519\u4F4D/\u6D88\u5931\uFF08demo \u641C\u7D22\u6062\u590D\u4E8B\u6545\uFF09`);break}for(let s=0;s<r.length;s++){let a=r[s];if(a!=null&&typeof a=="object"&&!Array.isArray(a)){let c=a;c.key!==null&&(c.key=String(c.key))}}let l=Array.isArray(t)?t:[],d=new Map;for(let s of l)s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&d.set(s.key,s);let u=r.map((s,a)=>{let c=null;return s!=null&&typeof s=="object"&&!Array.isArray(s)&&s.key!=null&&(c=d.get(s.key)??null),c==null&&(c=l[a]??null),B(s,n,c,o,i)});m("build")&&h("build","debug","",`array out kids=${A(r)}`);let f=!1;for(let s=0;s<u.length;s++)if(be(u[s])){f=!0;break}return f?Promise.all(u).then(()=>r):r}function wn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);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),C(r)&&C(d)&&typeof d._render=="function"&&(r._render=d._render));let u=gn(d?.props??{},r.props??{}),f=je(n),s=(d?._ctxVersion??-1)===f;if(!i?.force&&u&&s&&J(d)&&typeof r._render=="function"){let a=d;return r._lifecycle=P(r._lifecycle,"PRUNE",R(r)),r._child=a._child,r._ctxVersion=a._ctxVersion,m("build")&&h("build","debug","",`prune comp=${z(r)} propsSame=${u} verSame=${s}`),r}return r._lifecycle=P(r._lifecycle,"BUILD_START",R(r)),m("build")&&h("build","debug","",`mount comp=${z(r)} propsSame=${u} verSame=${s} force=${!!i?.force}`),(async()=>{let{childCtx:a}=await Vn(r,n,l,{reuse:d??null}),c=await B(await r._render(r.props),a,d?._child,l,i);return r._child=c??null,r._ctxVersion=f,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r})()}function bn(e,n,t,o,i){let r=e,l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","debug","",`fragment kids=${A(_(r.props?.children))}`);let u=B(r.props?.children??null,n,d?._child??d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function Oe(e,n,t,o,i){let r=e;if(typeof r.type!="string"&&typeof r.type!="symbol")return r;let l=o??n.__registry??U(),d=xe(t,r);m("build")&&h("build","trace","",`native <${String(r.type)}> kids=${A(_(r.props?.children))}`);let u=B(r.props?.children??null,n,d?.props?.children,l,i);return be(u)?u.then(f=>(r._child=f??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)):(r._child=u??null,r._lifecycle=P(r._lifecycle,"BUILD_DONE",R(r)),r)}function V(){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{}}}}var xn=new Set(["svg","path","circle","rect","line","polyline","polygon","g","text","defs","use","clipPath"]);function Q(e,n){return H(e,n)}function E(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 $n[L(e)](e,n,l,o,i,r)}function vn(e,n,t){return null}function En(e,n,t){return t.createTextNode(String(e))}function ve(e,n,t,o,i){if(e==null||typeof e=="boolean")return Q(t,e);let r=E(e,n,t,String(o),null,i);return r??Q(t,null)}function Sn(e,n,t,o=null,i=null,r=null){let l=e,d=t.createDocumentFragment();if(!d)return null;m("render")&&h("render","debug","",`array kids=${A(l)} fid=${r??"-"} key=${o??"-"}`);let u=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),f=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));u&&d.appendChild(u);for(let s=0;s<l.length;s++){let a=l[s],c=r!=null?`${r}-${s}`:String(s),p=ve(a,n,t,s,c);p!=null&&d.appendChild(p)}return f&&d.appendChild(f),d}function An(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 u=E(o.props?.children??null,n,t);u!=null&&d.appendChild(u),l&&l.appendChild(d),i._remoteEl=d;let f=_(o.props?.children);for(let s of f)s!=null&&typeof s=="object"&&!Array.isArray(s)&&(s._parentVNode=o)}return null}function kn(e,n,t,o=null,i=null,r=null){let l=e,d=l,u=t.createDocumentFragment();if(!u)return null;let f=_(l.props?.children);m("render")&&h("render","debug","",`fragment kids=${A(f)} fid=${r??"-"}`);let s=t.createComment(Z({type:"fragment-start",key:o,id:i,fid:r})),a=t.createComment(Z({type:"fragment-end",key:o,id:i,fid:r}));s&&u.appendChild(s),d._refNode=s;for(let c=0;c<f.length;c++){let p=f[c],y=r!=null?`${r}-${c}`:String(c),N=ve(p,n,t,c,y);N!=null&&u.appendChild(N)}return a&&u.appendChild(a),u}function Tn(e,n,t){let o=e,i=o._lifecycle??(typeof o._render=="function"?"built":"fresh");return Rn[i](o,n,t)}var Rn={fresh:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} not built (missing _render) \u2014 buildVNode must run before renderValue`)},building:(e,n,t)=>{throw new Error(`[vdom2] component ${v(e.type)} building in render \u2014 buildVNode must await before renderValue`)},disposed:(e,n,t)=>(console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${v(e.type)} \u5728\u6E32\u67D3\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`),Q(t,null)),built:He,pruned:He};function He(e,n,t){let o=e._child;if(o==null)return e._child=null,null;e._child=o,e._outputChild=o,typeof o=="object"&&!Array.isArray(o)&&(o._parentVNode=e);let i=E(o,n,t);if(i){if(e._refNode=i.nodeType===11?i.firstChild:i,e._id)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-id",e._id);else i.nodeType===1&&i.setAttribute("data-wf-id",e._id);if(e.key!=null)if(i.nodeType===11)for(let r of Array.from(i.childNodes))r.nodeType===1&&r.setAttribute("data-wf-key",e.key);else i.nodeType===1&&i.setAttribute("data-wf-key",e.key)}return i}function Pn(e,n,t,o,i){let r=e,l=r,d=r.type,u=xn.has(d)?t.createElementNS("http://www.w3.org/2000/svg",d):t.createElement(d);if(!u)return null;l.el=u,l._refNode=u,m("render")&&h("render","trace","",`native <${d}> key=${r.key??"-"} kids=${A(_(r.props?.children))}`),r.key!=null&&u.setAttribute("data-wf-key",r.key);let f=null;for(let[s,a]of Object.entries(r.props??{}))if(!(s==="children"||s==="key")){if(s==="value"&&u instanceof HTMLSelectElement){f=a;continue}q(u,s,a)}if(!("innerHTML"in(r.props??{}))){let s=_(r.props?.children);for(let a=0;a<s.length;a++){let c=s[a],p=i!=null?`${i}-${a}`:String(a),y=ve(c,n,t,a,p);if(y!=null&&(u.appendChild(y),c&&typeof c=="object"&&!Array.isArray(c)&&typeof c.type=="function")){let N=c;N._parentNode||(N._parentNode=u)}}m("render")&&h("render","trace","",`native <${d}> out=${O(u)}`)}return f!==null&&(u.value=String(f)),u}var $n={hole:vn,text:En,arr:Sn,portal:An,frag:kn,comp:Tn,native:Pn};function F(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=E(e.newInput,i,i.browser??V());if(r==null)return null;if(t?.parentNode){let l=oe(o,t,n,i);return l&&l.parentNode===n?n.insertBefore(r,l):n.appendChild(r),r}return n.appendChild(r),r}function In(e){return oe(e.oldInput,e.oldNode,e.parent,e.ctx),null}function Ln(e){let n=e.oldNode;if(n?.nodeType===8){let t=Q(e.ctx.browser??V(),e.newInput);return t&&n.nodeValue!==t.nodeValue&&(n.nodeValue=t.nodeValue),n}return null}function ee(e){let{parent:n,oldNode:t,ctx:o}=e,i=E(e.newInput,o,o.browser??V());return i==null?null:(t?.parentNode?t.parentNode.replaceChild(i,t):t?n.insertBefore(i,t):n.appendChild(i),i)}function Mn(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 jn(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&&ke(r)){let u=t;return r.el=u,r._refNode=u,Fe(u,l?.props??{},r.props??{}),"innerHTML"in(r.props??{})||re(u,l?._child??l?.props?.children??null,r._child??r.props?.children??null,i),u}return F(e)}function Dn(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=K(l)?g(l,t):null,u=Ee(n,l??o,r,i,d);return t?.parentNode?t:u[0]??null}function On(e){let{parent:n,oldNode:t,oldInput:o,ctx:i}=e,r=e.newInput;if(!C(r)||typeof r._render!="function")throw new Error(`[vdom2] component ${v(r.type)} not built in diff \u2014 buildVNode must run before patchValue`);let l=o&&typeof o=="object"&&!Array.isArray(o)?o:null;if(l?.type!=null&&l.type!==r.type)return F(e);let d=l?.type===r.type;if(!i.force&&l&&d&&J(l)&&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 u=r._child;if(u===null){r._outputChild=null,r._refNode=null;let s=t?.parentNode!=null,a=oe(l?._child??null,t,n,i);l&&(l._child=null);let c=Q(i.browser??V(),null);return s&&c?(a&&a.parentNode===n?n.insertBefore(c,a):n.appendChild(c),c):W(n,t,l?._child,null,i)}r._outputChild=u;let f=W(n,t,l?._child,u,i);return f&&(r._refNode=f),f}function Hn(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=re(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 Bn(e){let{ctx:n,oldInput:t}=e,o=e.newInput,i=t&&typeof t=="object"&&!Array.isArray(t)?t:null;if(S(i)&&S(o)){let r=i._remoteEl;if(r){let l=i._child??i.props?.children??null,d=o._child??o.props?.children??null;re(r,l,d,n)}return o._remoteEl=i._remoteEl,null}return F(e)}function G(e){return{text:F,native:F,frag:F,comp:F,arr:F,hole:In,portal:F,...e}}var Fn={text:G({text:Mn}),hole:G({text:ee,native:ee,frag:ee,comp:ee,arr:ee,portal:ee,hole:Ln}),native:G({native:jn}),frag:G({frag:Dn}),comp:G({comp:On}),arr:G({arr:Hn}),portal:G({portal:Bn})};function Be(e){let n=L(e.oldInput),t=L(e.newInput);return w({session:"",machine:"x2y",nodeId:null,component:null,from:n,event:"X2Y",to:t,level:"trace",ts:Date.now()}),Fn[n][t](e)}function M(e,n){if(n&&typeof e.type=="function"&&e._id){try{b(e,n)}catch(t){console.error("[weifuwu] ref cleanup error",t)}Me(n,e._id)}}function se(e){if(e==null||typeof e!="object"||Array.isArray(e))return null;let n=e;return S(n)?typeof n.props?.portalKey=="string"?n.props.portalKey:null:n.key}function Se(e,n){if(n&&e&&typeof e=="object"&&!Array.isArray(e)){let t=g(e,n);if(t&&t.length>1)return t}return[n]}function ce(e,n){let t=_(e.props?.children);for(let o of t){if(o==null||typeof o!="object"||Array.isArray(o))continue;let i=o;Kn[L(i)](i,n)}}var Kn={comp:(e,n)=>{M(e,n)},frag:(e,n)=>{ce(e,n)},native:(e,n)=>{ce(e,n)},portal:(e,n)=>{ce(e,n)},arr:()=>{},text:()=>{},hole:()=>{}};function oe(e,n,t,o){return Un[L(e)](e,n,t,o)}var Un={arr:(e,n,t,o)=>{let i=g(e,n);if(i&&i.length){let r=(i[i.length-1]??n)?.nextSibling??null;for(let l of i)l.parentNode&&l.parentNode.removeChild(l);return r&&r.parentNode===t?r:null}return ie(e,n,t,o)},frag:(e,n,t,o)=>{let i=e,l=g(i,n)??[],d=(l[l.length-1]??n)?.nextSibling??null;for(let u of l)u.parentNode&&u.parentNode.removeChild(u);return ce(i,o.registry),d&&d.parentNode===t?d:null},portal:(e,n,t,o)=>{let i=e,r=i._remoteEl;try{b(i.props?.children,o.registry)}catch(l){console.error("[weifuwu] portal ref cleanup error",l)}return r?.parentNode?.removeChild(r),null},comp:(e,n,t,o)=>{let i=e,r=g(i,n);if(M(i,o.registry),r&&r.length>1){let l=(r[r.length-1]??n)?.nextSibling??null;for(let d of r)d.parentNode&&d.parentNode.removeChild(d);return l&&l.parentNode===t?l:null}return ie(e,n,t,o)},native:(e,n,t,o)=>{try{b(e,o.registry)}catch(i){console.error("[weifuwu] ref cleanup error",i)}return ie(e,n,t,o)},text:(e,n,t,o)=>ie(e,n,t,o),hole:(e,n,t,o)=>ie(e,n,t,o)};function ie(e,n,t,o){let i=n?.nextSibling??null;return n?.parentNode&&n.parentNode.removeChild(n),i&&i.parentNode===t?i:null}function W(e,n,t,o,i){return Be({parent:e,oldNode:n,oldInput:t,newInput:o,ctx:i})}var qn={event:(e,n,t,o)=>{let{type:i,capture:r}=_e(n);typeof t=="function"&&e.removeEventListener(i,t,r?{capture:!0}:{}),o!=null&&o!==!1&&(typeof o!="function"?console.warn(`[weifuwu] event prop ${n} expects a function, got ${typeof o} \u2014 ignored`):e.addEventListener(i,o,r?{capture:!0}:{}))},class:(e,n,t,o)=>{o==null||o===!1?e.removeAttribute("class"):(e.className="",q(e,n,o))},ref:(e,n,t,o)=>{if(o==null||o===!1){if(typeof t=="function")try{t(null)}catch(i){console.error("[weifuwu] ref cleanup error",i)}}else q(e,n,o)},value:(e,n,t,o)=>{o==null||o===!1?e.value="":q(e,n,o)},indeterminate:(e,n,t,o)=>{o==null||o===!1?e.indeterminate=!1:q(e,n,o)},enumerated:le,style:le,innerHTML:le,aria:le,default:le};function le(e,n,t,o){if(o==null||o===!1){e.removeAttribute(n);try{delete e[n]}catch{}}else q(e,n,o)}function Fe(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],u=t[l];d!==u&&qn[we(l)](e,l,d,u)}}function Ee(e,n,t,o,i){let r=Array.isArray(n)?n:n?._child??n?.props?.children??null,l=Array.isArray(t)?t:t?._child??t?.props?.children??null;return re(e,r,l,o,i)}function re(e,n,t,o,i,r){let l=_(n),d=_(t),u=i??Array.from(e.childNodes);m("diff")&&h("diff","debug","",`patchChildren parent=${k(e)} old=${A(l)} new=${A(d)} dom=${O(e)}`);let f=d.some(p=>Array.isArray(p))||l.some(p=>Array.isArray(p)),s=f?"unkeyed":Ce(d);if(w({session:"",machine:"keys",nodeId:null,component:null,from:f?"unkeyed":Ce(d),event:"SELECT",to:s,payload:()=>({len:d.length}),level:"trace",ts:Date.now()}),te()&&l.length!==d.length)for(let p=0;p<d.length;p++){let y=d[p];y!=null&&typeof y=="object"&&!Array.isArray(y)&&C(y)&&y.key==null&&console.error(`[vdom2/audit] \u52A8\u6001\u6570\u7EC4\u4F4D\u7F6E ${p} \u7684\u7EC4\u4EF6\u7F3A\u5C11 key\u2014\u2014\u5217\u8868\u589E\u5220/\u91CD\u6392\u4F1A\u9519\u4F4D\u7EC4\u4EF6\u5B9E\u4F8B\u72B6\u6001\u3002\u8BF7\u63D0\u4F9B\u4E1A\u52A1\u8EAB\u4EFD key\uFF08\u5982 key={item.id}\uFF09\uFF1B\u65E0\u72B6\u6001 native \u9879\u8C41\u514D\u3002`)}let a=i&&i.length?i[i.length-1]:null;s==="mixed"&&(fe(d),fe(l));let c=(()=>{let p=u;p.length>=2&&p[0]?.nodeType===8&&p[0].nodeValue?.includes("fragment-start")&&p[p.length-1]?.nodeType===8&&p[p.length-1].nodeValue?.includes("fragment-end")&&(p=p.slice(1,-1));let y=[],N=0;for(let T=0;T<l.length;T++){let x=l[T];if(Array.isArray(x)){let j=p[N]??null;y.push(j);let D=g(x,j);N+=D?.length??1;continue}if(x==null||typeof x=="boolean"||typeof x=="string"||typeof x=="number"){y.push(p[N]??null),N++;continue}let $=x;if(S($)){y.push($._remoteEl??null);continue}if(y.push($._refNode??p[N]??null),typeof $.type=="function"||K($)){let j=g($,$._refNode??p[N]??null);N+=j?.length??1}else N++}return y})();return ct[s]({parent:e,oldChildren:l,newChildren:d,oldNodes:c,ctx:o,arrEnd:a,anchorOut:r})}function de(e){return e==null||typeof e=="boolean"?"hole":Array.isArray(e)||e&&typeof e=="object"&&K(e)?"multi":"real"}function Wn(e){let{parent:n,oldC:t,oldNode:o,oldNodes:i,i:r,ctx:l,out:d,pushA:u}=e;if(Array.isArray(t)){m("diff")&&h("diff","trace","",`remove-arr-item i=${r} range=[${(g(t,i[r])??[]).map(k).join(" | ")}] before=${O(n)}`);let f=g(t,o);for(let s of f??[])s.parentNode?.removeChild(s);m("diff")&&h("diff","trace","",`remove-arr-item after=${O(n)}`);for(let s of t)s!=null&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"&&M(s,l.registry)}else if(t&&typeof t=="object"&&!Array.isArray(t)){if(typeof t.type=="function")M(t,l.registry);else try{b(t,l.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}o?.parentNode&&o.parentNode.removeChild(o)}else o?.parentNode&&o.parentNode.removeChild(o);d.push(null),u(null)}function zn(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=H(u.browser??V(),t);if(o?.nodeType===8){f&&o.nodeValue!==f.nodeValue&&(o.nodeValue=f.nodeValue),l.push(o),d(o);return}if(f&&o?.parentNode)o.parentNode.replaceChild(f,o);else if(f){let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(!s){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}a&&a.parentNode===n&&(s=a.nextSibling)}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),l.push(f),d(f)}else l.push(f),d(f)}function Ke(e){let{parent:n,newC:t,oldNode:o,i,oldNodes:r,out:l,pushA:d,ctx:u}=e,f=E(t,u,u.browser??V(),String(i));if(f==null){l.push(null),d(null);return}if(o&&o.nodeType===8&&o.nodeValue?.includes("type=hole")){w({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"HOLE_FILL",to:"real",payload:()=>({i,replaced:k(o)}),level:"trace",ts:Date.now()}),o.parentNode?.replaceChild(f,o),l.push(f),d(f);return}let s=null;for(let a=i+1;a<r.length;a++){let c=r[a];if(c&&c.parentNode===n){s=c;break}}if(s==null){let a=null;for(let c=l.length-1;c>=0;c--)if(l[c]){a=l[c];break}if(a&&a.parentNode===n)s=a.nextSibling;else{let c=r[r.length-1];c&&c.parentNode===n&&(s=c.nextSibling)}}s&&s.parentNode===n?n.insertBefore(f,s):n.appendChild(f),w({session:"",machine:"pos",nodeId:null,component:null,from:"hole",event:"INSERT",to:"real",payload:()=>({i,insertedBefore:s?k(s):"END",node:k(f)}),level:"trace",ts:Date.now()}),l.push(f),d(f)}function Gn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e;if(t&&typeof t=="object"&&!Array.isArray(t)&&typeof t.type=="function"){let f=We(n,t,i,o,d);r.push(f),l(f);return}let u=ze(n,t,i,o,d);r.push(u),l(u)}function Xn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e,f=u.browser??V(),s=E(o,u,f,String(r));if(s==null){l.push(null),d(null);return}let a=t&&typeof t=="object"?g(t,i):null;if(a&&a.length>1){let p=(a[a.length-1]??i)?.nextSibling??null;for(let y of a)y.parentNode&&y.parentNode.removeChild(y);if(t&&typeof t=="object"&&!Array.isArray(t))if(typeof t.type=="function")M(t,u.registry);else try{b(t,u.registry)}catch(y){console.error("[weifuwu] ref cleanup error",y)}p&&p.parentNode===n?n.insertBefore(s,p):n.appendChild(s)}else i?.parentNode?i.parentNode.replaceChild(s,i):n.appendChild(s);let c=s.nodeType===11?Array.from(s.childNodes):[s];l.push(...c),d(c[0]??s)}function Yn(e){let{parent:n,oldC:t,newC:o,oldNode:i,out:r,pushA:l,ctx:d}=e,u=qe(n,t,i,o,d);r.push(u),l(u)}function Jn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,oldNodes:l,out:d,pushA:u,ctx:f}=e,s=f.browser??V(),a=g(t,i);m("diff")&&h("diff","debug","",`multi-remove i=${r} range=${a?a.map(k).join(" | "):"null"}`);for(let y of a??[])y.parentNode?.removeChild(y);for(let y of _(t?.props?.children))y!=null&&typeof y=="object"&&!Array.isArray(y)&&typeof y.type=="function"&&M(y,f.registry);let c=E(o,f,s,String(r));if(c==null){d.push(null),u(null);return}let p=l[r+1]??null;p?.parentNode?p.parentNode.insertBefore(c,p):n.appendChild(c),d.push(c),u(c)}function Zn(e){let{parent:n,oldC:t,newC:o,oldNode:i,oldNodes:r,i:l,out:d,pushA:u,ctx:f}=e,s=g(t,i),a=Ee(n,t,o,f,s);d.push(...a),u(r[l]??a[0]??null)}function Qn(e){let{parent:n,oldC:t,newC:o,oldNode:i,i:r,out:l,pushA:d,ctx:u}=e;if(o&&typeof o=="object"&&!Array.isArray(o)&&typeof o.type=="function"&&o._lifecycle==="disposed"){let a=Xe(n,i,u,v(o.type));l.push(a),d(a);return}let f=W(n,i,t,o,u);m("diff")&&h("diff","trace","",`after-patch i=${r} new=${z(o)} node=${k(f)} dom=${O(n)}`);let s=Se(o,f);l.push(...s),d(s[0]??f??null)}function qe(e,n,t,o,i){let r=H(i.browser??V(),o),l=g(n,t),d=((l??[])[l?.length?l.length-1:0]??t)?.nextSibling??null;for(let u of l??[])u.parentNode?.removeChild(u);for(let u of _(n?.props?.children))u!=null&&typeof u=="object"&&!Array.isArray(u)&&typeof u.type=="function"&&M(u,i.registry);return r&&d&&d.parentNode===e?e.insertBefore(r,d):r&&e.appendChild(r),r}function We(e,n,t,o,i){let r=H(i.browser??V(),o),l=oe(n,t,e,i);return r&&l?e.insertBefore(r,l):r&&e.appendChild(r),r}function ze(e,n,t,o,i){let r=H(i.browser??V(),o);if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}return r&&t?.parentNode?t.parentNode.replaceChild(r,t):r&&e.appendChild(r),r}var et={hole:{hole:zn,real:Ke,multi:Ke},real:{hole:Gn,real:Qn,multi:Xn},multi:{hole:Yn,real:Jn,multi:Zn}};function nt(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l}=e,d=Math.max(t.length,o.length),u=[],f=s=>{l&&l.push(s)};for(let s=0;s<d;s++){let a=s<t.length?t[s]:null,c=s<o.length?o[s]:null;if(s>=o.length){Wn({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r});continue}if(a!=null&&typeof a=="object"&&!Array.isArray(a)&&c!=null&&typeof c=="object"&&!Array.isArray(c)&&c===a&&J(a)){u.push(i[s]),f(i[s]);continue}let p=et[de(a)][de(c)];w({session:"",machine:"pos",nodeId:null,component:null,from:de(a),event:p.name,to:de(c),payload:()=>({i:s}),level:"trace",ts:Date.now()}),p({parent:n,oldC:a,newC:c,oldNode:i[s],i:s,oldNodes:i,newChildren:o,out:u,pushA:f,ctx:r})}return u}function Ue(e){let{parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,anchorOut:l,arrEnd:d}=e,u=new Map;t.forEach((p,y)=>{let N=se(p);N!==null&&p&&typeof p=="object"&&!Array.isArray(p)&&u.set(N,{vnode:p,nodes:[i[y]??null].filter(Boolean),index:y})});let f=[],s=new Set,a=p=>{l&&l.push(p)},c=null;return o.forEach((p,y)=>{let N=se(p),T=p;if(N!==null&&u.has(N)){let x=u.get(N),$=x.nodes[0]??null;if(s.add(N),T&&typeof T=="object"&&typeof T.type=="function"&&T._lifecycle==="disposed"){let X=Xe(n,$,r,v(T.type));f.push(X),a(X),X&&(c=X);return}let j=W(n,$,x.vnode,T,r),D=Se(T,j),ye=D[0]??j,Ae=D[D.length-1]??j;if(ye&&ye.parentNode===n&&c&&ye.previousSibling!==c){m("diff")&&h("diff","debug","",`keyed-correct i=${y} k=${N} move=[${D.map(k).join(" | ")}] after=${k(c)} before=${O(n)}`);let X=c.nextSibling;for(let me of D)me&&me.parentNode===n&&n.insertBefore(me,X);m("diff")&&h("diff","debug","",`keyed-correct after=${O(n)}`)}f.push(...D),a(D[0]??j??null),Ae&&(c=Ae)}else{let x={current:c};dt[lt(p)]({parent:n,oldChildren:t,newChildren:o,oldNodes:i,ctx:r,out:f,pushA:a,arrEnd:d,c:p,i:y},x),c=x.current}}),t.forEach((p,y)=>{ot[tt(se(p),s)](n,p,y,i,r,o.length)}),f}function tt(e,n){return e===null?"unkeyed":n.has(e)?"moved":"stale-keyed"}var ot={moved:()=>{},"stale-keyed":rt,unkeyed:it};function rt(e,n,t,o,i){let r=n&&typeof n=="object"&&!Array.isArray(n)?g(n,o[t]):null;if(m("diff")&&h("diff","trace","",`keyed-delete i=${t} k=${se(n)} range=${r?.length??0} oldNode=${k(o[t])}`),n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(l){console.error("[weifuwu] ref cleanup error",l)}Ge(r,o[t])}function it(e,n,t,o,i,r){let l=o[t];if(l?.nodeType===8&&l.nodeValue?.includes("type=hole")&&t<r)return;if(n&&typeof n=="object"&&!Array.isArray(n))if(typeof n.type=="function")M(n,i.registry);else try{b(n,i.registry)}catch(f){console.error("[weifuwu] ref cleanup error",f)}let u=n&&typeof n=="object"&&!Array.isArray(n)?g(n,l):null;Ge(u,l)}function Ge(e,n){if(e&&e.length>1)for(let t of e)t.parentNode&&t.parentNode.removeChild(t);else n?.parentNode&&n.parentNode.removeChild(n)}function lt(e){return e==null||typeof e=="boolean"?"hole":e&&typeof e=="object"&&!Array.isArray(e)&&S(e)?"portal":"real"}var dt={hole:st,portal:ut,real:at};function st(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=o[f]??null,a=i[f]??null,c=de(s);if(c==="hole"){let y=H(r.browser??V(),u);a?.nodeType===8?(y&&a.nodeValue!==y.nodeValue&&(a.nodeValue=y.nodeValue),l.push(a),d(a),a&&(n.current=a)):(y&&a?.parentNode?a.parentNode.replaceChild(y,a):y&&t.appendChild(y),l.push(y),d(y),y&&(n.current=y));return}let p=c==="multi"?qe(t,s,a,u,r):s&&typeof s=="object"&&!Array.isArray(s)&&typeof s.type=="function"?We(t,s,a,u,r):ze(t,s,a,u,r);l.push(p),d(p),p&&(n.current=p)}function ut(e,n){let{parent:t,oldChildren:o,oldNodes:i,ctx:r,out:l,pushA:d,c:u,i:f}=e,s=u,a=o[f]??null,c=W(t,i[f]??null,a,s,r),p=Se(s,c);l.push(...p),d(p[0]??c??null);let y=p[p.length-1]??c;y&&(n.current=y)}function at(e,n){let{parent:t,oldNodes:o,ctx:i,out:r,pushA:l,arrEnd:d,c:u,i:f}=e,a=E(u,i,i.browser??V());if(r.push(a),l(a??null),a!=null){let c=o[f];c&&c.nodeType===8&&c.nodeValue?.includes("type=hole")?(c.parentNode?.replaceChild(a,c),n.current=a):(n.current?t.insertBefore(a,n.current.nextSibling):d&&d.parentNode===t?t.insertBefore(a,d):t.insertBefore(a,t.firstChild),n.current=a)}}function fe(e){for(let n=0;n<e.length;n++){let t=e[n];t&&typeof t=="object"&&!Array.isArray(t)&&se(t)===null&&(t.key=`pos:${n}`)}}function Xe(e,n,t,o){te()?console.error(`[vdom2/audit] I1 \u8FDD\u53CD\uFF1Adiff \u6536\u5230 disposed \u7EC4\u4EF6 ${o}\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\uFF08portal \u5185\u5BB9\u72EC\u7ACB dispose\uFF09\u2014\u2014\u7236\u6811\u5C06\u91CD\u5EFA`):console.warn(`[vdom2] disposed \u7EC4\u4EF6 ${o} \u5728 diff\u2014\u2014\u526A\u679D\u7F13\u5B58\u5931\u6548\u2014\u2014\u7236\u6811\u91CD\u5EFA\u4E2D\uFF08\u5360\u4F4D\u515C\u5E95\uFF09`);let i=H(t.browser??V(),null);if(i==null)return null;let r=n;if(r){let l=r.parentNode;l?l.replaceChild(i,r):e.appendChild(i)}else e.appendChild(i);return i}var ct={unkeyed:nt,keyed:Ue,mixed:e=>(fe(e.newChildren),fe(e.oldChildren),Ue(e))};function Ye(e,n,t,o){let i=t,r=i.__registry??U(),l=i.browser??V();return Promise.resolve(B(n,i,null,r)).then(()=>{let d=E(n,i,l);if(d!=null&&e.appendChild(d),n._id&&r){let u=r.idRegistry.get(n._id);u&&(u._parentNode=e)}o?.onMounted?.()}).catch(d=>console.error("[vdom2] command mount error",d)),{id:n._id??""}}function jo(e,n,t){return new Promise(o=>{Ye(e,n,t,{onMounted:o})})}async function Do(e,n,t,o,i){return await B(o,i,t,i.__registry),W(e,n,t,o,{browser:i.browser??i.__browser,registry:i.__registry})}function Oo(e,n){let t=n.__registry??(n.__registry=U());return Promise.resolve(B(e,n,void 0,t))}async function Ho(e,n,t){let o=await e(n,t);return typeof o=="function"?o(n):o}async function Bo(e,n,t){let o=await e(n,t);return()=>typeof o=="function"?o(n):o}function pe(e,n){if(e==null||typeof e!="object")return;if(Array.isArray(e)){for(let o of e)pe(o,n);return}n(e);let t=e?.props?.children;t!=null&&pe(t,n)}function Fo(e,n){let t;return pe(e,o=>{!t&&n(o)&&(t=o)}),t}function Ko(e,n){let t=[];return pe(e,o=>{typeof o?.props?.class=="string"&&o.props.class.split(" ").includes(n)&&t.push(o)}),t}function Uo(e){let n={ui:{render:()=>{},ready:!0,useExternal:()=>{}}};return e?{ui:{...n.ui,...e.ui??{}},...e.browser?{browser:e.browser}:{}}:n}function qo(e=()=>!1,n){return{get open(){return e()},setOpen:n??(t=>{}),refresh:()=>{},portal:(t,o)=>e()?t:null,wrapProps:{}}}export{Oo as buildToDom,qo as createPopupMock,Uo as createTestCtx,Ko as findByClass,Fo as findVNode,Bo as mountComponent,jo as mountToDom,Do as patchToDom,Ho as renderVNode,pe as walkVNode};
@@ -12,9 +12,14 @@
12
12
  * A4 锚点:组件 _refNode 指向的节点仍在父 DOM 中
13
13
  */
14
14
  import type { VNodeChild } from '../vnode.ts';
15
+ import { type VKind } from './kind.ts';
15
16
  /** audit 开关(dev/测试注入;生产默认关) */
16
17
  export declare function auditEnabled(): boolean;
18
+ /** 安装挂载不变量 audit(uiServe 初始化时调用一次——订阅事件流而非遍历 DOM) */
19
+ export declare function installMountInvariantAudit(): void;
17
20
  /** 数组级校验:childNodes 与 children 数组对齐(A1/A2——占位错位/数量错位) */
18
21
  export declare function auditChildren(parent: Node, children: VNodeChild[] | null, report: (msg: string) => void): void;
19
- /** 树级校验:vnode 树 ↔ DOM 树递归对照(A3/A4)——入口调用一次 */
22
+ /** 树级校验:vnode 树 ↔ DOM 树递归对照(A3/A4)——入口分派 AUDITERS[classifyKind(child)] 查表 */
20
23
  export declare function auditTree(parent: Node, child: VNodeChild, report: (msg: string) => void): void;
24
+ /** 审计状态机表(kind → 校验行为——portal 远程单独容器跳过;native 含非法 type 诊断跳过) */
25
+ export declare const AUDITERS: Record<VKind, (parent: Node, child: VNodeChild, report: (msg: string) => void) => void>;
@@ -16,6 +16,7 @@
16
16
  import type { VNode, VNodeChild } from '../vnode.ts';
17
17
  import { type VdomCtx } from './ctx.ts';
18
18
  import { type Registry } from './registry.ts';
19
+ import { type VKind } from './kind.ts';
19
20
  /** 组件 props 浅比较(三态 skip 判定) */
20
21
  export declare function componentPropsEqual(a: Record<string, any>, b: Record<string, any>): boolean;
21
22
  /** 挂载 async 组件:await 工厂(两阶段:外层 mount 一次)→ 设 _render + 分配 id + childCtx */
@@ -36,6 +37,17 @@ export declare function mountAsyncComponent(vnode: VNode, ctx: VdomCtx, reg: Reg
36
37
  * - V3-2:非 async——剪枝/文本/null/已构建 native 同步返回(零微任务);
37
38
  * 组件路径(工厂 + renderFn await)返回 Promise(异步契约不变)
38
39
  */
40
+ /** 构建器签名(BUILDERS[kind]——kind 分派查表,无 if/else 类型链) */
41
+ type BuildFn = (input: VNodeChild, ctx: VdomCtx, oldInput: VNodeChild | undefined, reg: Registry | undefined, opts: {
42
+ force?: boolean;
43
+ } | undefined) => VNodeChild | Promise<VNodeChild>;
44
+ /**
45
+ * buildVNode — 构建分派入口(状态机查表:BUILDERS[classifyKind(input)])。
46
+ * hole/text 同步原样;arr 逐项递归;comp 异步工厂;frag/native/portal 同步递归 children。
47
+ */
39
48
  export declare function buildVNode(input: VNodeChild, ctx: VdomCtx, oldInput?: VNodeChild, reg?: Registry, opts?: {
40
49
  force?: boolean;
41
50
  }): VNodeChild | Promise<VNodeChild>;
51
+ /** 构建状态机表(kind → 构建行为——与 render RENDERERS / ssr TO_HTML / hydrate HYDRATERS 同构) */
52
+ export declare const BUILDERS: Record<VKind, BuildFn>;
53
+ export {};
@@ -0,0 +1,61 @@
1
+ /**
2
+ * vdom/events — 统一状态机事件总线
3
+ *
4
+ * 状态机管"转换"(route/lifecycle/x2y/keys/pos),事件总线管"观测":
5
+ * 所有状态转换统一发射结构化 VdomEvent,多路 sink 消费——
6
+ * - console sink:人类可读(复用 trace 阶段开关,格式兼容旧 trace 输出)
7
+ * - ring buffer sink:内存最近 N 条(__vdom_events(n) 查询——事故现场可追溯)
8
+ * - collect sink:测试断言(makeEventCollector——事件序列断言,过程级而非结果级)
9
+ * - audit sink:不变量校验器(订阅事件流而非事后遍历 DOM——阶段 2)
10
+ *
11
+ * 事件 = "决策记录"(同步、纯,不执行 DOM);执行层(appendChild/坐标计算)不进事件流。
12
+ * 性能:emit 首行检查——无观测者或 trace 关闭时仅一次布尔比较;payload 支持惰性函数
13
+ * (高频 diff 事件只在有消费者需要时才求值,避免 vnDesc/nodeDesc 的字符串成本)。
14
+ */
15
+ import { type VdomLevel, type VdomStage } from './trace.ts';
16
+ /** 状态机名(事件来源)——含执行细节摘要通道(build/render/diff/mount——trace 包装) */
17
+ export type VdomMachine = 'route' | 'lifecycle' | 'x2y' | 'keys' | 'pos' | 'render' | 'audit' | 'build' | 'mount' | 'diff';
18
+ export declare function machineToStage(m: VdomMachine): VdomStage;
19
+ /** 统一状态机事件(一次渲染会话的全部转换通过 session 关联) */
20
+ export interface VdomEvent {
21
+ /** 渲染会话 id(R{n}——同一渲染的 build/render/diff 事件共享;阶段 2 接入贯穿) */
22
+ session: string;
23
+ machine: VdomMachine;
24
+ /** 关联 vnode id(_id——按实例过滤/追溯) */
25
+ nodeId: string | null;
26
+ /** 组件名/类型名(尽力) */
27
+ component: string | null;
28
+ from: string;
29
+ event: string;
30
+ to: string;
31
+ /** 附加数据(key/i/path 等)——可传函数惰性求值(高频路径零字符串成本) */
32
+ payload?: unknown;
33
+ /** 输出级别(console sink 门控;默认 debug) */
34
+ level?: VdomLevel;
35
+ ts: number;
36
+ }
37
+ export type EventSink = (ev: VdomEvent) => void;
38
+ /** 注册事件 sink(返回退订函数) */
39
+ export declare function onVdomEvent(sink: EventSink): () => void;
40
+ /** 开始渲染会话(renderOne/renderPath 入口调用)——期间所有 emit 共享 session */
41
+ export declare function beginSession(tag?: string): string;
42
+ /** 结束渲染会话(renderOne/renderPath 出口调用) */
43
+ export declare function endSession(): void;
44
+ /** 当前会话 id(空 = 无会话——事件流外直接 emit) */
45
+ export declare function currentSession(): string;
46
+ /** payload 惰性求值 + 分发(sink 错误隔离——不中断渲染管线)
47
+ * session:事件显式传入优先,否则继承当前渲染会话(一次渲染 = 一棵事件树) */
48
+ export declare function emit(ev: VdomEvent): void;
49
+ /** 是否存在「console 之外」的观测 sink(ring/collect)——trace() 包装的 emit 门槛:
50
+ * trace 关闭但测试收集/调试 ring 存在时,执行细节事件仍要发射(供断言/追溯) */
51
+ export declare function hasObservingSinks(): boolean;
52
+ /** 注册 ring buffer sink(uiServe 初始化时调用——页面生命周期内事件全程可追溯) */
53
+ export declare function installEventRing(): void;
54
+ /** 调试 API:查询最近事件(可按 machine/nodeId/event 过滤)——__vdom_events(50, { machine: 'lifecycle' }) */
55
+ export declare function __vdom_events(n?: number, filter?: Partial<VdomEvent>): VdomEvent[];
56
+ /** 重置 ring buffer(测试隔离用) */
57
+ export declare function __resetVdomEvents(): void;
58
+ export declare function makeEventCollector(): {
59
+ events: VdomEvent[];
60
+ unsubscribe: () => void;
61
+ };
@@ -7,7 +7,15 @@
7
7
  * 游标不变量:元素/文本 VNode 恰好消耗一个游标节点;组件/Fragment/数组透明;
8
8
  * null 消耗零;创建时 insertBefore(游标) 且游标不动;收养/替换时游标前进。
9
9
  */
10
- import type { VNode } from '../vnode.ts';
10
+ import type { VNode, VNodeChild } from '../vnode.ts';
11
+ import { type VKind } from './kind.ts';
11
12
  import { type VdomCtx } from './ctx.ts';
13
+ interface HydrationCursor {
14
+ parent: Node;
15
+ node: Node | null;
16
+ }
17
+ /** 水合状态机表(kind → 收养行为——与 render RENDERERS / ssr TO_HTML 同构) */
18
+ export declare const HYDRATERS: Record<VKind, (v: VNodeChild, ctx: VdomCtx, c: HydrationCursor) => Node | null>;
12
19
  /** Hydration 入口:buildVNode 预构建(await 工厂)→ 游标收养 */
13
20
  export declare function hydrateVNode(container: Element, vnode: VNode, ctx: VdomCtx): Promise<void>;
21
+ export {};
@@ -32,4 +32,13 @@ export interface PatchState {
32
32
  export declare function getOutputRange(input: VNodeChild, anchor: Node | null): Node[] | null;
33
33
  /** 值分类(单一判定源——替代散落的 typeof/Array.isArray/type=== 判断) */
34
34
  export declare function classifyKind(v: VNodeChild): VKind;
35
+ /** 数组 key 模式:diff 策略状态机的状态 */
36
+ export type KeyMode = 'unkeyed' | 'keyed' | 'mixed';
37
+ /** 数组 key 模式判定(单一判定源——替代 patch 散落的 hasUserKey/allUnkeyed 计算):
38
+ * - unkeyed:无用户 key(位置身份——按位置 patch)
39
+ * - keyed :全部用户 key(内容身份——按 key 匹配)
40
+ * - mixed :部分 key(无 key 项由 prepPos 分配 pos:{i} 后降级 keyed)
41
+ * 豁免:占位/文本(无 key 协议豁免);数组项(隐式 Fragment,位置语义);
42
+ * portal(portalKey 不算用户 keyed——C1:[input(无key), portal] 按位置复用) */
43
+ export declare function keyModeOf(children: VNodeChild[]): KeyMode;
35
44
  export { Fragment, Portal };
@@ -0,0 +1,50 @@
1
+ /**
2
+ * vdom2 lifecycle — 节点生命周期状态机(2026-12)
3
+ *
4
+ * 与 x2y(diff 转换状态机)/ KEY_DIFFERS(key 模式状态机)同构的第三个状态机:
5
+ * 节点的构建/清理由**显式状态**管理——根治「dispose 掏空旧树但 build 剪枝按引用误判可用」
6
+ * 的不一致(demo 搜索序列:Section null→恢复后剪枝复用半残旧树 → diff 遇未构建组件 →
7
+ * renderComp 抛「not built」)。
8
+ *
9
+ * 状态:
10
+ * fresh —— JSX 刚创建(未构建:无 _id/_render/_child)
11
+ * building —— buildVNode 处理中(异步工厂 await 中)
12
+ * built —— 已构建(_render/_child 已设——diff 可渲染)
13
+ * pruned —— 剪枝复用(_child 复用旧树——状态保持)
14
+ * disposed —— 已清理(diff 移除 → 掏空 _render/_child)
15
+ *
16
+ * 关键不变量(由 dispose 整树递归保证):组件非 disposed ⟹ 子树全部非 disposed——
17
+ * 剪枝只检查自身生命周期即可,无需深度验证 _child 内部(O(n) 太贵)。
18
+ */
19
+ /** 节点生命周期状态 */
20
+ export type Lifecycle = 'fresh' | 'building' | 'built' | 'pruned' | 'disposed';
21
+ /** 生命周期事件(状态转换触发点) */
22
+ export type LifecycleEvent = 'BUILD_START' | 'BUILD_DONE' | 'PRUNE' | 'DISPOSE';
23
+ /** 生命周期 trace 上下文(组件视角可观测——组件名 + 实例 id + 深度) */
24
+ export interface LifecycleTraceCtx {
25
+ name?: string;
26
+ id?: string | null;
27
+ depth?: number;
28
+ }
29
+ /** 从 vnode 提取 trace 上下文(组件名 + 实例 id + _parentVNode 链深度——尽力,链可能不完整) */
30
+ export declare function vnodeTraceCtx(vnode: {
31
+ type: unknown;
32
+ _id?: string | null;
33
+ _parentVNode?: unknown;
34
+ }): LifecycleTraceCtx;
35
+ /** 查询生命周期时间线(全组件或单组件)——__vdom_lc(id?) */
36
+ export declare function dumpTimeline(id?: string): string;
37
+ /** 状态转换执行(非法转换 → 保留原状态 + 事件/trace warn——不静默吞掉)
38
+ * tctx:trace 上下文(组件名/id/深度——事件携带结构化字段,trace 输出 `Name(id)[d0] from --event--> to`)
39
+ * 事件流:所有转换统一 emit(machine=lifecycle)——过程级可观测/可断言 */
40
+ export declare function transition(from: Lifecycle, event: LifecycleEvent, tctx?: LifecycleTraceCtx): Lifecycle;
41
+ /** 旧树复用有效性(I3——所有复用路径统一检查):
42
+ * - 生命周期非 disposed(dispose 显式标记——根治「引用还在但内容被掏空」的误判)
43
+ * - 旧 _child 非 null(有可复用输出)
44
+ * - _child 树无 disposed(深检查——portal 内容独立 dispose(remoteEl 移除)会打破
45
+ * 「父非 disposed ⟹ 子树全非 disposed」:DemoDrawer 剪枝复用含 disposed Button/Drawer
46
+ * 的输出——demo 搜索序列实测;正确性优先,性能后续用 dirty 标记优化) */
47
+ export declare function canReuse(oldV: {
48
+ _lifecycle?: Lifecycle;
49
+ _child?: unknown;
50
+ } | null | undefined): boolean;
@@ -40,7 +40,8 @@ export interface VdomContext {
40
40
  renderer: Renderer;
41
41
  rootUi: any;
42
42
  }
43
- /** 渲染执行器(render-only 唯一渲染入口——无调度队列,直接执行) */
43
+ /** 渲染执行器(render-only 唯一渲染入口——per-id 串行链:并发触发排队补跑,
44
+ * 同一组件渲染中再次触发 → 排队等前一个完成后补跑最新状态(合并语义)) */
44
45
  export declare function createRenderer(opts: {
45
46
  registry: Registry;
46
47
  ctx: any;
@@ -13,13 +13,19 @@ export { arrayChildren };
13
13
  import { type Registry } from './registry.ts';
14
14
  /** 组件 vnode 从树中移除:ref(null) 递归 + 卸载钩子(cleanupComponent) */
15
15
  export declare function disposeComponent(vnode: VNode, registry?: Registry): void;
16
+ import { type PropChannel } from './transform.ts';
17
+ import { type KeyMode, type VKind } from './kind.ts';
16
18
  /**
17
19
  * 移除旧输出的全部 DOM(Fragment 展开多节点 + Portal 容器)并做组件/ref 清理。
18
20
  * @returns 移除后应插入新节点的位置(范围后兄弟;null = append 末尾)
19
21
  * 真实 bug:Frag→div 类型切换只 replaceChild 锚点 → Fragment 其余节点(holes/标记/数组项)残留
20
22
  * (frag-native-switch trace 定位 2026-12;同逻辑覆盖 Frag→null/Portal→null)
23
+ *
24
+ * 分派:REMOVERS[classifyKind(oldInput)] 查表(kind → 移除行为——无 if/else 类型链)
21
25
  */
22
26
  export declare function removeOldOutput(oldInput: VNodeChild, oldNode: Node | null, parent: Node, ctx: PatchCtx): Node | null;
27
+ /** 移除状态机表(kind → 移除行为——单节点/范围/远程容器三类输出范围) */
28
+ export declare const REMOVERS: Record<VKind, (oldInput: VNodeChild, oldNode: Node | null, parent: Node, ctx: PatchCtx) => Node | null>;
23
29
  export interface PatchCtx {
24
30
  browser: any;
25
31
  registry: import('./registry.ts').Registry;
@@ -34,6 +40,10 @@ export interface PatchCtx {
34
40
  * @returns newInput 的实际 DOM(null = 无 DOM)
35
41
  */
36
42
  export declare function patchValue(parent: Node, oldNode: Node | null, oldInput: VNodeChild, newInput: VNodeChild, ctx: PatchCtx): Node | null;
43
+ /** 属性 diff 状态机表(通道 → 更新/移除行为——patchProps 查表分派):
44
+ * 每个处理器自含「移除」(nv==null/false)与「更新」两态——值判断保留在处理器内。
45
+ * 通道分类单一源 = propChannelOf(transform.ts——与 setProp 共用,禁止各路径各自判定) */
46
+ export declare const PROP_PATCHERS: Record<PropChannel, (el: Element, key: string, ov: any, nv: any) => void>;
37
47
  export declare function patchProps(el: Element, oldProps: Record<string, any>, newProps: Record<string, any>): void;
38
48
  /**
39
49
  * patchChildren — 数组 diff。
@@ -45,3 +55,60 @@ export declare function patchProps(el: Element, oldProps: Record<string, any>, n
45
55
  * oldRange = 标记范围(getOutputRange——start/end + fid 配对) */
46
56
  export declare function arrayToArray(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange: Node[] | null): (Node | null)[];
47
57
  export declare function patchChildren(parent: Node, oldInput: VNodeChild | null, newInput: VNodeChild | null, ctx: PatchCtx, oldRange?: Node[] | null, anchorOut?: (Node | null)[]): (Node | null)[];
58
+ /** 位置级 kind 分类(数组上下文——POS 位置转换表分派用):
59
+ * - hole :无渲染值(null/false/undefined/true——占位)
60
+ * - real :单节点值(text/native/comp/portal)
61
+ * - multi:多节点输出(数组项 = 隐式 Fragment / 显式 Fragment) */
62
+ type PosKind = 'hole' | 'real' | 'multi';
63
+ /** 位置转换上下文(数组 diff 每位置——POS 表分派参数) */
64
+ interface PosState {
65
+ parent: Node;
66
+ oldC: VNodeChild | null;
67
+ newC: VNodeChild;
68
+ oldNode: Node | null;
69
+ i: number;
70
+ oldNodes: (Node | null)[];
71
+ newChildren: VNodeChild[];
72
+ out: (Node | null)[];
73
+ pushA: (n: Node | null) => void;
74
+ ctx: PatchCtx;
75
+ }
76
+ /** 位置级 (oldKind, newKind) 转换状态机表(数组上下文——与 x2y 同构的矩阵分派) */
77
+ export declare const POS: Record<PosKind, Record<PosKind, (s: PosState) => void>>;
78
+ /** keyed 新增项 kind 分类(无 key 匹配的占位/portal/普通项——KEYED_NEW 分派用) */
79
+ type KeyedNewKind = 'hole' | 'portal' | 'real';
80
+ /** keyed 新增上下文(KEYED_NEW 分派参数) */
81
+ interface KeyedNewState {
82
+ parent: Node;
83
+ oldChildren: VNodeChild[];
84
+ newChildren: VNodeChild[];
85
+ oldNodes: (Node | null)[];
86
+ ctx: PatchCtx;
87
+ out: (Node | null)[];
88
+ pushA: (n: Node | null) => void;
89
+ arrEnd: Node | null;
90
+ c: VNodeChild;
91
+ i: number;
92
+ }
93
+ /** keyed 新增分派状态机表(kind → 处理——无 if/else 类型链) */
94
+ export declare const KEYED_NEW: Record<KeyedNewKind, (s: KeyedNewState, lastRef: {
95
+ current: Node | null;
96
+ }) => void>;
97
+ /** 数组 diff 上下文(unkeyed/keyed 共享——状态机分派参数) */
98
+ export interface KeyDiffState {
99
+ parent: Node;
100
+ oldChildren: VNodeChild[];
101
+ newChildren: VNodeChild[];
102
+ oldNodes: (Node | null)[];
103
+ ctx: PatchCtx;
104
+ arrEnd: Node | null;
105
+ anchorOut?: (Node | null)[];
106
+ }
107
+ /** mixed → keyed 状态转换:无 key 项分配 pos:{i}(位置身份显式化——防 keyed 分支
108
+ * 「移除旧+新建」重建固定结构;portal 的 portalKey 不算用户 keyed(C1)——不分配) */
109
+ export declare function prepPos(children: VNodeChild[]): void;
110
+ /** key diff 策略状态机:KeyMode → 实现(查表分派——与 x2y 转换状态机同构)
111
+ * - unkeyed:位置身份——按位置 patch(不移动 DOM)
112
+ * - keyed :内容身份——按 key 匹配(keyMap + 位置校正)
113
+ * - mixed :状态转换 prepPos(无 key 项 → pos:{i})→ 降级 keyed */
114
+ export declare const KEY_DIFFERS: Record<KeyMode, (s: KeyDiffState) => (Node | null)[]>;
@@ -16,4 +16,6 @@ import type { BrowserEnv } from '../types.ts';
16
16
  export declare function createHole(browser: BrowserEnv, v: unknown): Node | null;
17
17
  /** 递归渲染(同步——组件必须已构建;首帧/新增路径) */
18
18
  export declare function renderValue(v: VNodeChild, ctx: any, browser?: BrowserEnv, key?: string | null, id?: string | null, fid?: string | null): Node | null;
19
+ /** 渲染函数表(按 classifyKind 分派——每类一个实现,无 if-else 类型链) */
20
+ export declare const RENDERERS: Record<string, (v: VNodeChild, ctx: any, b: BrowserEnv, key?: string | null, id?: string | null, fid?: string | null) => Node | null>;
19
21
  export declare function renderTree(v: VNodeChild, ctx: any, browser?: BrowserEnv): Node | null;
@@ -0,0 +1,29 @@
1
+ /**
2
+ * vdom2 route — 路由生命周期状态机(2026-12,design/vdom-lifecycle-state-machines.md Phase 1)
3
+ *
4
+ * 四状态机架构的第一层(页面级·宏观):导航状态统一管理——
5
+ * idle → navigating(旧树卸载/新树构建中)→ settled(新树就绪)。
6
+ *
7
+ * 与节点状态机(lifecycle.ts)的协同:NAVIGATE_START 触发旧树 DISPOSE + 新树 BUILD;
8
+ * NAVIGATE_DONE 表示整条链路(build → diff → render)完成。
9
+ *
10
+ * 统一架构模式:状态 + 事件 + 转换表 + 查表分派(无 if/else 分派链)。
11
+ */
12
+ /** 路由生命周期状态 */
13
+ export type RouteLifecycle = 'idle' | 'navigating' | 'settled';
14
+ /** 路由事件(导航触发点) */
15
+ export type RouteEvent = 'NAVIGATE_START' | 'NAVIGATE_DONE' | 'NAVIGATE_ERROR';
16
+ /** 路由生命周期协调器(每 app 实例一个——serve.ts 接入) */
17
+ export interface RouteController {
18
+ state: RouteLifecycle;
19
+ /** 导航开始(renderPath 入口):旧树卸载 + 新树构建起点 */
20
+ navigateStart(path: string): void;
21
+ /** 导航完成(build + diff + render 全部落地) */
22
+ navigateDone(path: string): void;
23
+ /** 导航失败(router.execute 抛错——回退 idle) */
24
+ navigateError(path: string, err: unknown): void;
25
+ }
26
+ /** 创建路由生命周期协调器(查表分派——非法转换 emit/trace warn 不静默) */
27
+ export declare function createRouteController(): RouteController;
28
+ /** 重置(测试/清理用) */
29
+ export declare function __resetRouteState(): void;
@@ -19,7 +19,7 @@
19
19
  * uiLog 是深度跟踪——两者独立开关、不冲突。
20
20
  */
21
21
  import type { VNodeChild } from '../vnode.ts';
22
- export type VdomStage = 'mount' | 'build' | 'render' | 'diff' | 'audit';
22
+ export type VdomStage = 'mount' | 'build' | 'render' | 'diff' | 'lifecycle' | 'route' | 'audit';
23
23
  export type VdomLevel = 'error' | 'warn' | 'info' | 'debug' | 'trace';
24
24
  export interface VdomTraceConfig {
25
25
  enabled: boolean;
@@ -37,7 +37,10 @@ export interface VdomTraceConfig {
37
37
  export declare function initVdomTrace(): VdomTraceConfig;
38
38
  /** 插桩点前置检查:阶段开启 + 级别满足(关闭时连参数求值都跳过) */
39
39
  export declare function traceEnabled(stage: VdomStage, level?: VdomLevel): boolean;
40
- /** 输出 trace 日志([vdom:{stage}] {traceId} {msg}) */
40
+ /** 输出 trace 日志([vdom:{stage}] {traceId} {msg})
41
+ * 统一事件流:trace = 执行细节摘要通道——内部发射 TRACE 事件(console sink 输出原格式;
42
+ * ring/collect sink 记录——执行细节可追溯/可断言)。
43
+ * gate:trace 开启 或 存在观测 sink(collect/ring)——否则零成本(调用点已有 traceEnabled 前置守卫保证 msg 惰性) */
41
44
  export declare function trace(stage: VdomStage, level: VdomLevel, msg: string, ...args: unknown[]): void;
42
45
  /** 手动配置(测试/调试用——不受 init 时序/缓存影响) */
43
46
  export declare function configureVdomTrace(c: Partial<Omit<VdomTraceConfig, 'enabled'>>): void;
@@ -50,3 +53,10 @@ export declare function vnDesc(v: VNodeChild): string;
50
53
  export declare function nodeDesc(n: Node | null): string;
51
54
  /** DOM 子节点序列摘要(childNodes 顺序——与 kidsSeq 对照验证顺序一致性) */
52
55
  export declare function childNodesSeq(parent: Node | null, max?: number): string;
56
+ /** 递归打印 vnode 树快照:type + id + lifecycle + 深度缩进(组件视角——整页可观测) */
57
+ export declare function dumpTree(vnode: VNodeChild, depth?: number): string[];
58
+ /** 安装全局调试 API(dev/调试——页面加载后可用):
59
+ * __vdom_dump() 全树生命周期快照(root 由调用方注入)
60
+ * __vdom_lc(id?) 生命周期时间线(全组件或单组件)
61
+ * __vdom_events(n?) 统一状态机事件流(最近 N 条——跨状态机关联/追溯) */
62
+ export declare function installVdomInspect(rootGetter: () => VNodeChild | null | undefined): void;