lithent 1.25.3 → 1.25.4

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.
Files changed (42) hide show
  1. package/devHelper/package.json +2 -2
  2. package/dist/lithent-agent-addon.md +1 -1
  3. package/dist/lithent.cjs +1 -1
  4. package/dist/lithent.cjs.map +1 -1
  5. package/dist/lithent.mjs +12 -9
  6. package/dist/lithent.mjs.map +1 -1
  7. package/dist/lithent.umd.js +1 -1
  8. package/dist/lithent.umd.js.map +1 -1
  9. package/dist/skills/lithent/SKILL.md +1 -1
  10. package/dist/skills/lithent/constraints/mistakes.md +1 -1
  11. package/dist/skills/lithent/constraints/rules.md +1 -1
  12. package/dist/skills/lithent/constraints/troubleshooting.md +1 -1
  13. package/dist/skills/lithent/examples/quick-examples.md +1 -1
  14. package/dist/skills/lithent/reference/children-type.md +1 -1
  15. package/dist/skills/lithent/reference/concurrent.md +1 -1
  16. package/dist/skills/lithent/reference/element.md +1 -1
  17. package/dist/skills/lithent/reference/lstore-inference.md +1 -1
  18. package/dist/skills/lithent/reference/props-types.md +1 -1
  19. package/dist/utils/event.d.cts +12 -0
  20. package/dist/utils/event.d.ts +12 -0
  21. package/element/package.json +2 -2
  22. package/examples/dist/assets/index-BXMpKnXD.js +2 -0
  23. package/examples/dist/assets/index-BXMpKnXD.js.map +1 -0
  24. package/examples/dist/assets/index-C4K2fQqQ.js +2 -0
  25. package/examples/dist/assets/index-C4K2fQqQ.js.map +1 -0
  26. package/examples/dist/assets/index-CDu5iCaJ.js +2 -0
  27. package/examples/dist/assets/index-CDu5iCaJ.js.map +1 -0
  28. package/examples/dist/assets/index-Ch4u_8Bx.js +2 -0
  29. package/examples/dist/assets/index-Ch4u_8Bx.js.map +1 -0
  30. package/examples/dist/index.html +1 -1
  31. package/examples/package.json +2 -2
  32. package/ftags/package.json +2 -2
  33. package/helper/package.json +2 -2
  34. package/jsx-runtime/package.json +2 -2
  35. package/package.json +2 -3
  36. package/src/render.ts +16 -25
  37. package/src/tests/core-bulkRemoval.test.tsx +253 -0
  38. package/src/tests/core-keyedFastPath.test.tsx +226 -0
  39. package/ssr/package.json +2 -2
  40. package/tag/package.json +2 -2
  41. package/examples/dist/assets/index-C-5HazZ7.js +0 -2
  42. package/examples/dist/assets/index-C-5HazZ7.js.map +0 -1
@@ -4,7 +4,7 @@
4
4
  "version": "0.21.1",
5
5
  "description": "Lithent development helper utilities",
6
6
  "private": true,
7
- "packageManager": "pnpm@7.6.0",
7
+ "packageManager": "pnpm@12.15.0",
8
8
  "main": "./dist/lithentDevHelper.cjs",
9
9
  "module": "./dist/lithentDevHelper.mjs",
10
10
  "types": "./dist/index.d.ts",
@@ -32,6 +32,6 @@
32
32
  "lithent": "workspace:*"
33
33
  },
34
34
  "volta": {
35
- "node": "20.3.0"
35
+ "node": "24.22.1"
36
36
  }
37
37
  }
@@ -1,6 +1,6 @@
1
1
  # Lithent Agent Addon
2
2
 
3
- > Version: 1.25.3
3
+ > Version: 1.25.4
4
4
 
5
5
  You are a coding agent with Lithent virtual DOM guidance enabled.
6
6
 
package/dist/lithent.cjs CHANGED
@@ -1,2 +1,2 @@
1
- "use strict";const ae=Symbol.for("lithentWDomSymbol"),S={value:""},v={value:null},k={value:!1},p=new WeakMap,J=new WeakSet;let fe=!1;const Be=(e,t)=>{p.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},de=()=>v.value,E=()=>p.get(v.value),Qe=(e,t)=>{const n=p.get(e);return n?n[t]:null},Ke=e=>{v.value=e},je=(e,t)=>{v.value=e,Be(e,t)},_e=e=>{fe=e},He=()=>fe,pe=e=>{const t=p.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ve=e=>{pe(e),p.delete(e)},C=e=>e.getParent&&e.getParent(),B=e=>()=>e,te=Object.keys,he=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),ye=(e,t)=>{if(he(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&ye(n,t)},T=e=>typeof e=="object"&&e!==null,qe=e=>T(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(ae),ze=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Ge=(e,t)=>t.type==="f"&&!t.ctor&&!e.ctor&&!!t.children&&t.children.length===(e.children&&e.children.length),Ie=(e,t)=>t.type==="e"&&t.tag===e.tag&&!!t.children&&t.children.length===(e.children&&e.children.length),ne=(e,t)=>t.type===e.type,Je=(e,t)=>t.type===e.type&&(q(e)&&q(t)||!!t.children&&t.children.length===(e.children&&e.children.length)),H=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),x=e=>e==="f"||e==="l",Q=e=>typeof e=="function"&&!ve(e)||T(e)&&"resolve"in e,ve=e=>e===_,Xe=e=>!e.type,R=({el:e,op:t,props:n})=>!!e&&(e===(t&&t.portal)||e===(n&&n.portal)),V=e=>e[0]==="o"&&e[1]==="n",X=e=>A(H(e)),q=e=>!!e&&!!e.children&&e.children.some(X),A=e=>e!=null,ce=(e,t)=>e==="style"&&T(t),Ye=(e,t)=>e==="ref"&&T(t),oe=new WeakMap,se=(e,t)=>{const n=e.constructor.prototype;let c=oe.get(n);c||oe.set(n,c=new Map);let o=c.get(t);if(o===void 0){const s=Object.getOwnPropertyDescriptor(n,t);o=!!(s&&s.get&&s.set),c.set(t,o)}return o},re=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Ze=e=>Q(e)?"c":e.type||"et",$e={c:ze,l:Je,t:ne,e:Ie,f:Ge,et:ne},Ce=e=>{const t=E();t&&t.umts.push(e)},K=e=>{const{compKey:t}=e;t&&(e.il=!0,me(t)),ke(e)},ke=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)V(t)&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?K(t):ke(t)})},me=e=>{pe(e),He()||p.delete(e)};let z=[];const we=e=>{e.compKey&&z.push(e)},b=()=>{z.forEach(De),z=[]},We=e=>{const t=E();t&&t.mts.push(e)},De=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.mts;v.value=t,n.upS.value=0,n.mts=[],c.forEach(o=>{const s=o();s&&Ce(s)})}},et=e=>{const t=E();t&&t.wdCB.push(e)},tt=e=>{const{compKey:t}=e;if(t){const n=p.get(t),c=n&&n.wdCB;v.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(o=>{const s=o();typeof s=="function"&&Ce(s)}))}},le=(e,t=()=>[])=>{const n=E();if(!n)return;const{upD:c,upS:o}=n,s=c[o.value],r=t();if(s&&ct(s,r)){const l=e();l&&n.upCB.push(l)}c[o.value]=r,o.value+=1},nt=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.upCB;v.value=t,n.upS.value=0,e.ctor&&(n.upCB=[],c.forEach(o=>o()))}},ct=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,Pe=()=>new DocumentFragment,Re=(e,t,n)=>n?e.insertBefore(t,n):e.tagName==="HTML"?e.replaceWith(t):e.appendChild(t),ot=e=>document.createElement(e),st=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const o=N(e,c);return e.ae=n,(n||!c)&&Re(t,o,n),b(),()=>{const s=p.get(e.compProps),r=s&&s.vd.value||e;K(r),rt(r)}},rt=e=>Z(e,e.we),Y=e=>{const t=C(e);Z(e,e.isRoot?e.we:t&&g(t))},Z=(e,t)=>{if(t&&e.el){const n=e.el.nodeType,c=R(e);n===11||c?G(e,c?e.el:t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},G=(e,t)=>{const n=e.oc||e.children||[];if(n.length>1&&n.every(c=>{const o=c.el&&c.el.nodeType;return(o===1||o===3)&&c.el.tagName!=="HTML"&&!R(c)})){let c=0;for(let o=t.firstChild;o&&c<=n.length;o=o.nextSibling)c++;if(c===n.length){t.textContent="",n.forEach(o=>o.el=void 0);return}}n.forEach(c=>{const o=c.el&&c.el.nodeType;if(R(c))G(c,c.el);else if(o===1||o===3){const s=c.el;s.tagName==="HTML"?s.innerHTML="":s.remove()}else o===11&&G(c,t)})},lt=(e,t)=>{const n=g(t);e.forEach(c=>{K(c),Z(c,n)})},Ee=e=>{Y(e),ge(e)},ge=(e,t)=>{t=t||N(e);const n=C(e);if(!n||!n.type){e.isRoot&&e.we&&e.tag!=="portal"&&(Re(e.we,t,e.ae),b());return}const c=g(n),o=$(e,n);c&&(e.tag!=="portal"&&c.insertBefore(t,o||null),b())},Me=e=>x(e.type)?(e.children||[]).reduce((t,n)=>{const c=Me(n);return c&&!R(n)&&t.appendChild(c),t},Pe()):e.el,$=(e,t)=>{const n=t.children||[];return U(n.slice(n.indexOf(e)+1))||(x(t.type)?t.isRoot?t.ae:$(t,C(t)):void 0)},L=new Set,U=e=>e.reduce((t,n)=>{if(t||R(n)||L.size&&L.has(n))return t;const{type:c,el:o}=n;if(c&&x(c)){const s=U(n.children||[]);if(s)return s}return o&&o.nodeType!==11?o:t},void 0),ut=e=>{const t=C(e),n=e.el;if(n&&(t?t.type:e.isRoot))if(!t||n.nodeType===11||R(e)||e.tag==="portal")Ee(e);else{const c=g(t),o=N(e);c&&c.replaceChild(o,n),b()}},ue=e=>{if(e.type==="t"){dt(e);return}if(e.el){const{op:t,props:n}=e;be(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}it(e),nt(e)},it=e=>{const t=e.children||[];if(e.type!=="l"||!t.some(u=>"ATS".includes(u.nr)||u.oi!==void 0)){t.forEach(I);return}const n=[],c=[],o=[];let s=!0;t.forEach((u,f)=>{const y=u.oi,M=u.nr;M==="S"?o.push(u):M!=="A"&&y!==void 0&&(y<c[c.length-1]&&(s=!1),n.push(f),c.push(y))});let r;if(!s){const u=r=[];at(c).forEach(f=>u[n[f]]=!0),n.forEach(f=>u[f]||(u[f]=!1,o.push(t[f])))}const l=[];let i=0;o.forEach(u=>L.add(u));try{t.forEach((u,f)=>{const y=u.nr;y==="A"||y==="S"?(y==="S"&&Y(u),l[f]=N(u),i++):I(u)})}finally{o.forEach(u=>L.delete(u))}const a=g(e),h=e.isRoot?e.ae:$(e,C(e));let d=t.length;for(;d>0&&l[d-1]!==void 0;)d--;for(let u=d;u<t.length;u++){const f=l[u];f&&a&&t[u].tag!=="portal"&&a.insertBefore(f,h||null)}if(r||i>t.length-d){let u=U(t.slice(d))||h;for(let f=d-1;f>=0;f--){const y=t[f],M=l[f]!==void 0,Oe=!!r&&r[f]===!1;if((M||Oe)&&a&&y.tag!=="portal"){const ee=M?l[f]:Me(y);ee&&a.insertBefore(ee,u||null)}const D=U([y]);D&&(u=D)}}t.forEach(Se),b()},Se=e=>{e.oi=e.oc=e.op=void 0,e.nr="N"},at=e=>{const t=[],n=[];e.forEach((s,r)=>{let l=0,i=t.length;if(i&&e[t[i-1]]<s)l=i;else for(;l<i;){const a=l+i>>1;e[t[a]]<s?l=a+1:i=a}n[r]=l?t[l-1]:-1,t[l]=r});let c=t.length,o=t[c-1];for(;c-- >0;)t[c]=o,o=n[o];return t},I=e=>{const{nr:t}=e;t&&t!=="N"&&(ft[t](e),Se(e))},ft={A:ge,D:Y,R:ut,U:ue,S:Ee,T:ue},dt=e=>{e.el&&(e.el.nodeValue=String(e.text))},be=(e,t,n)=>{const c=n||{};for(const o in e){const s=e[o];s!==c[o]&&(V(o)?ie(t,o,s,c[o]):o==="key"||o==="portal"&&T(s)||(o==="innerHTML"&&typeof s=="string"?t.innerHTML=s:ce(o,s)?yt(s,ce(o,c.style)?c.style:{},t):Ye(o,s)?s.value=t:o&&(o!=="type"&&se(t,o)?t[o]=s:(pt(o==="className"?"class":o,t,s),re(t)&&!(o in HTMLElement.prototype)&&(t[o]=s)))))}for(const o in c)if(!(e&&ye(e,o))){if(V(o)){ie(t,o,void 0,c[o]);continue}t.removeAttribute(o),re(t)?delete t[o]:t.localName.includes("-")&&se(t,o)&&(t[o]=void 0)}},pt=(e,t,n)=>S.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),N=(e,t)=>{let n;const{type:c,tag:o,text:s,props:r,children:l=[]}=e,i=x(c);if(tt(e),o==="svg"&&(S.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c||i)n=Pe();else if(c==="e"&&o)o==="portal"&&r&&r.portal?n=r.portal:n=S.value?document.createElementNS(S.value,o):ot(o);else if(c==="t"&&A(s))n=document.createTextNode(String(s));else throw Error("Invalid wDom");e.el=n}return ht(e,l,n,t),be(r,n,null),we(e),o==="svg"&&(S.value=""),n},ht=(e,t,n,c)=>{const o=B(e);t.forEach((s,r)=>{if(s.nr==="N"&&!c){const l=Le(s);s=t[r]="resolve"in l?l.resolve():l}if(s.getParent=o,s.nr="N",s.type){const l=N(s,c);s.tag!=="portal"&&!c&&n&&n.appendChild(l)}})},ie=(e,t,n,c)=>{const o=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(o,c),n&&e.addEventListener(o,n))},yt=(e,t,n)=>{const c={...t};if(!(n instanceof HTMLElement))return;const o=n.style;for(const s in e)o[s]=e[s],delete c[s];for(const s in c)o[s]=""},g=e=>x(e.type)?e.isRoot?e.we:g(C(e)):e.el,j=(e,t)=>(e!==t&&e.nr&&(e=Le(e)),vt(e,!!t&&$e[Ze(e)](e,t),t)),vt=(e,t,n)=>{const c=Et(e,t,n),o=kt(c,t,n),s=o==="N";return s||(c.children=gt(c,t,n)),c.nr=o,Ct(c,n,o),!s&&n&&(n.il=!0,n.ctor&&(n.children=void 0)),c},Ct=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&K(t),e.oc=t&&t.children),e.op=t&&t.props},kt=(e,t,n)=>{if(Xe(e))return"D";if(e===n||t&&e.type==="t"&&e.text===n.text)return"N";if(!(n&&n.type))return"A";const c=C(n),o=!e.isRoot&&c&&c.type==="l"&&X(e);return t?o?"T":"U":o?"S":"R"},Pt=(e,t)=>{e&&t!==e&&(t=t||{},te(e).forEach(n=>he(t,n)||delete e[n]),te(t).forEach(n=>e[n]=t[n]))},Rt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:o,children:s}=t;return n&&Pt(n,o),c&&s&&c!==s&&c.splice(0,c.length,...s),e.reRender&&e.reRender()},Et=(e,t,n)=>Q(e)?t&&n?Rt(n,e):(e.rd?w(e):(e.rd=!0,e)).resolve():e,gt=(e,t,n)=>t&&n?St(e,n):Mt(e),Mt=e=>{const t=B(e);return(e.children||[]).map(n=>{const c=j(n);return c.getParent=t,c})},St=(e,t)=>{if(e.type==="l"&&q(e))return bt(e,t);const n=t.children||[],c=B(e);return(e.children||[]).map((o,s)=>{const r=j(o,n[s]);return r.getParent=c,r})},bt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,i)=>{const a=H(l);A(a)&&!c.has(a)&&c.set(a,i)});const o=[],s=B(e),r=(e.children||[]).map((l,i)=>{const a=H(l),h=A(a)?c.get(a):i<n.length&&!X(n[i])?i:void 0;let d;h!==void 0&&(c.delete(a),o[h]=!0,d=n[h]);const u=j(l,d);return d&&(u.oi=h),u.getParent=s,u});return lt(n.filter((l,i)=>!o[i]),t),r},F=new Map;let O=!1;const Tt=(e,t)=>{F.set(e,t),O||(O=!0,queueMicrotask(Te))},xt=(e,t)=>{const n=p.get(e);n&&(n.up=()=>{const c=n.vd.value;Tt(e,()=>t(c))})},m=e=>()=>{const t=p.get(e),n=t&&t.up;return n?(n(),!0):!1},Te=()=>{try{F.forEach((e,t)=>{F.delete(t),e()})}finally{O=!!F.size,O&&queueMicrotask(Te)}},P=(e,t,n,c,o,s)=>({type:e,nr:void 0,tag:t,props:n,text:c,children:o,getParent:s,el:void 0,oi:void 0,oc:void 0,op:void 0,il:void 0,[ae]:!0}),Nt=(e,t=()=>[])=>{const n=E();n&&(n.upR.push(()=>le(e,t)),le(e,t))},Ft=()=>{const e=E(),t=e&&e.upR;t&&t.length&&t.forEach(n=>n())},_=(e,...t)=>P("f",void 0,void 0,void 0,t),xe=(e,t,...n)=>{const c={value:void 0},o=Fe(c,n),s=Bt(e,t||{},o);return Q(s)||(c.value=s),s},At=(e,t)=>xe("portal",{portal:t},e),Lt=e=>(t,n)=>e,Ut=e=>(t,n)=>(J.add(e),e),Ot=(e,t,n)=>{const c=(o,s)=>{if(!(!o||s.has(o))){if(s.add(o),o.compChild){const r=o.compChild.indexOf(t);r!==-1&&o.compChild.splice(r,1,n)}c(o.getParent?o.getParent():void 0,s)}};c(e,new Set)},Ne=(e,t,n,c)=>{if(c.il)return;k.value=!0;let o;try{const s=W(e,t,n);o=j(s,c);const{isRoot:r,getParent:l,we:i,ae:a}=c;if(o.getParent=l,!r&&l){const h=l(),d=h&&h.children||[],u=d.indexOf(c);u!==-1&&d.splice(u,1,o),Ot(h,c,o)}else o.isRoot=!0,o.we=i,o.ae=a}finally{k.value=!1}I(o)},Bt=(e,t,n)=>{if(ve(e))return _(t,...n);if(Q(e)){const c=W(e,t,n);if(k.value)return c;const o=w(c).resolve();return o.rs=c,o}return P("e",e,t,void 0,n)},Fe=(e,t)=>{const n=()=>e.value;return t.map(c=>{const o=Ae(c);return o.getParent=n,o})},Ae=e=>{if(e==null||typeof e=="boolean")return P(null);if(Array.isArray(e)){const t={value:void 0},n=Fe(t,e),c=P("l",void 0,void 0,void 0,n);return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return P("t",void 0,void 0,e);return e},Qt=(e,t,n)=>(c=t)=>{const o=k.value,s=v.value;k.value=!1;try{je(c,e);const r=e(t,n);let l;if(typeof r=="function"){const i=r;l=J.has(i)?i(t,n):i(m(c),t,n)}else{let i=!0;l=a=>i?(i=!1,r):e(a,n)}return Kt(l,c,e,t,n)}finally{v.value=s,k.value=o}},Le=e=>e.ctor?w(e.rs||{ctor:e.ctor,props:e.compProps,children:e.compChild}):P(e.type,e.tag,e.props,e.text,e.children&&[...e.children],e.getParent),w=({ctor:e,props:t,children:n})=>W(e,{...t},[...n||[]]),W=(e,t,n)=>({ctor:e,props:t,children:n,resolve:Qt(e,t,n)}),Kt=(e,t,n,c,o)=>{const s=_t(e),r=s(c),l=jt(s,t,n,c,o);return Ue(r,t,n,c,o,l),xt(t,i=>Ne(n,i.compProps||c,i.compChild||o,i)),r},jt=(e,t,n,c,o)=>{const s=()=>{const r=v.value;try{Ke(t),Ft();const l=e(c);return Ue(l,t,n,c,o,s),l}finally{v.value=r}};return s},_t=e=>t=>{const n=Ae(e(t)),c=_({},n);return n.getParent=()=>c,c},Ue=(e,t,n,c,o,s)=>{e.compProps=c,e.compChild=o,e.ctor=n,e.compKey=t,e.reRender=s;const r=p.get(t);r&&(r.vd.value=e)},Ht=e=>({value:e}),Vt=()=>Promise.resolve(),qt=()=>{const e=de();return e?m(e):()=>!1};exports.Fragment=_;exports.componentMap=p;exports.componentUpdate=m;exports.disposeComponentEntry=Ve;exports.getComponentKey=de;exports.getComponentSubInfo=Qe;exports.h=xe;exports.isPropType=qe;exports.lmount=Ut;exports.lmountComponentSet=J;exports.mount=Lt;exports.mountCallback=We;exports.mountReadyCallback=et;exports.nextTick=Vt;exports.portal=At;exports.ref=Ht;exports.render=st;exports.replaceWDom=Ne;exports.setComponentMapManualMode=_e;exports.updateCallback=Nt;exports.useRenew=qt;
1
+ "use strict";const ae=Symbol.for("lithentWDomSymbol"),S={value:""},v={value:null},k={value:!1},p=new WeakMap,J=new WeakSet;let fe=!1;const Be=(e,t)=>{p.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},de=()=>v.value,E=()=>p.get(v.value),Qe=(e,t)=>{const n=p.get(e);return n?n[t]:null},Ke=e=>{v.value=e},je=(e,t)=>{v.value=e,Be(e,t)},_e=e=>{fe=e},He=()=>fe,pe=e=>{const t=p.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ve=e=>{pe(e),p.delete(e)},C=e=>e.getParent&&e.getParent(),B=e=>()=>e,te=Object.keys,he=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),ye=(e,t)=>{if(he(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&ye(n,t)},x=e=>typeof e=="object"&&e!==null,qe=e=>x(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(ae),ze=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Ge=(e,t)=>t.type==="f"&&!t.ctor&&!e.ctor&&!!t.children&&t.children.length===(e.children&&e.children.length),Ie=(e,t)=>t.type==="e"&&t.tag===e.tag&&!!t.children&&t.children.length===(e.children&&e.children.length),ne=(e,t)=>t.type===e.type,Je=(e,t)=>t.type===e.type&&(q(e)&&q(t)||!!t.children&&t.children.length===(e.children&&e.children.length)),H=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),T=e=>e==="f"||e==="l",Q=e=>typeof e=="function"&&!ve(e)||x(e)&&"resolve"in e,ve=e=>e===_,Xe=e=>!e.type,R=({el:e,op:t,props:n})=>!!e&&(e===(t&&t.portal)||e===(n&&n.portal)),V=e=>e[0]==="o"&&e[1]==="n",X=e=>A(H(e)),q=e=>!!e&&!!e.children&&e.children.some(X),A=e=>e!=null,ce=(e,t)=>e==="style"&&x(t),Ye=(e,t)=>e==="ref"&&x(t),oe=new WeakMap,se=(e,t)=>{const n=e.constructor.prototype;let c=oe.get(n);c||oe.set(n,c=new Map);let o=c.get(t);if(o===void 0){const s=Object.getOwnPropertyDescriptor(n,t);o=!!(s&&s.get&&s.set),c.set(t,o)}return o},re=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Ze=e=>Q(e)?"c":e.type||"et",$e={c:ze,l:Je,t:ne,e:Ie,f:Ge,et:ne},Ce=e=>{const t=E();t&&t.umts.push(e)},K=e=>{const{compKey:t}=e;t&&(e.il=!0,me(t)),ke(e)},ke=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)V(t)&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?K(t):ke(t)})},me=e=>{pe(e),He()||p.delete(e)};let z=[];const we=e=>{e.compKey&&z.push(e)},b=()=>{z.forEach(De),z=[]},We=e=>{const t=E();t&&t.mts.push(e)},De=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.mts;v.value=t,n.upS.value=0,n.mts=[],c.forEach(o=>{const s=o();s&&Ce(s)})}},et=e=>{const t=E();t&&t.wdCB.push(e)},tt=e=>{const{compKey:t}=e;if(t){const n=p.get(t),c=n&&n.wdCB;v.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(o=>{const s=o();typeof s=="function"&&Ce(s)}))}},le=(e,t=()=>[])=>{const n=E();if(!n)return;const{upD:c,upS:o}=n,s=c[o.value],r=t();if(s&&ct(s,r)){const l=e();l&&n.upCB.push(l)}c[o.value]=r,o.value+=1},nt=e=>{const{compKey:t}=e,n=t&&p.get(t);if(n){const c=n.upCB;v.value=t,n.upS.value=0,e.ctor&&(n.upCB=[],c.forEach(o=>o()))}},ct=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,Pe=()=>new DocumentFragment,Re=(e,t,n)=>n?e.insertBefore(t,n):e.tagName==="HTML"?e.replaceWith(t):e.appendChild(t),ot=e=>document.createElement(e),st=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const o=N(e,c);return e.ae=n,(n||!c)&&Re(t,o,n),b(),()=>{const s=p.get(e.compProps),r=s&&s.vd.value||e;K(r),rt(r)}},rt=e=>Z(e,e.we),Y=e=>{const t=C(e);Z(e,e.isRoot?e.we:t&&g(t))},Z=(e,t)=>{if(t&&e.el){const n=e.el.nodeType,c=R(e);n===11||c?G(e,c?e.el:t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},G=(e,t)=>{const n=e.oc||e.children||[];if(n.length>1){let c=t.firstChild;const o=s=>{const r=s.el;if(!r||R(s))return!r;if(r.nodeType===11)return(s.oc||s.children||[]).every(o);const l=r===c&&r.tagName!=="HTML";return c=r.nextSibling,l};if(n.every(o)&&!c){t.textContent="",n.forEach(s=>s.el=void 0);return}}n.forEach(c=>{const o=c.el&&c.el.nodeType;if(R(c))G(c,c.el);else if(o===1||o===3){const s=c.el;s.tagName==="HTML"?s.innerHTML="":s.remove()}else o===11&&G(c,t)})},lt=(e,t)=>{const n=g(t);e.forEach(c=>{K(c),Z(c,n)})},Ee=e=>{Y(e),ge(e)},ge=(e,t)=>{t=t||N(e);const n=C(e);if(!n||!n.type){e.isRoot&&e.we&&e.tag!=="portal"&&(Re(e.we,t,e.ae),b());return}const c=g(n),o=$(e,n);c&&(e.tag!=="portal"&&c.insertBefore(t,o||null),b())},Me=e=>T(e.type)?(e.children||[]).reduce((t,n)=>{const c=Me(n);return c&&!R(n)&&t.appendChild(c),t},Pe()):e.el,$=(e,t)=>{const n=t.children||[];return U(n.slice(n.indexOf(e)+1))||(T(t.type)?t.isRoot?t.ae:$(t,C(t)):void 0)},L=new Set,U=e=>e.reduce((t,n)=>{if(t||R(n)||L.size&&L.has(n))return t;const{type:c,el:o}=n;if(c&&T(c)){const s=U(n.children||[]);if(s)return s}return o&&o.nodeType!==11?o:t},void 0),ut=e=>{const t=C(e),n=e.el;if(n&&(t?t.type:e.isRoot))if(!t||n.nodeType===11||R(e)||e.tag==="portal")Ee(e);else{const c=g(t),o=N(e);c&&c.replaceChild(o,n),b()}},ue=e=>{if(e.type==="t"){dt(e);return}if(e.el){const{op:t,props:n}=e;be(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}it(e),nt(e)},it=e=>{const t=e.children||[];if(e.type!=="l"||!t.some(u=>"ATS".includes(u.nr)||u.oi!==void 0)){t.forEach(I);return}const n=[],c=[],o=[];let s=!0;t.forEach((u,f)=>{const y=u.oi,M=u.nr;M==="S"?o.push(u):M!=="A"&&y!==void 0&&(y<c[c.length-1]&&(s=!1),n.push(f),c.push(y))});let r;if(!s){const u=r=[];at(c).forEach(f=>u[n[f]]=!0),n.forEach(f=>u[f]||(u[f]=!1,o.push(t[f])))}const l=[];let i=0;o.forEach(u=>L.add(u));try{t.forEach((u,f)=>{const y=u.nr;y==="A"||y==="S"?(y==="S"&&Y(u),l[f]=N(u),i++):I(u)})}finally{o.forEach(u=>L.delete(u))}const a=g(e),h=e.isRoot?e.ae:$(e,C(e));let d=t.length;for(;d>0&&l[d-1]!==void 0;)d--;for(let u=d;u<t.length;u++){const f=l[u];f&&a&&t[u].tag!=="portal"&&a.insertBefore(f,h||null)}if(r||i>t.length-d){let u=U(t.slice(d))||h;for(let f=d-1;f>=0;f--){const y=t[f],M=l[f]!==void 0,Oe=!!r&&r[f]===!1;if((M||Oe)&&a&&y.tag!=="portal"){const ee=M?l[f]:Me(y);ee&&a.insertBefore(ee,u||null)}const D=U([y]);D&&(u=D)}}t.forEach(Se),b()},Se=e=>{e.oi=e.oc=e.op=void 0,e.nr="N"},at=e=>{const t=[],n=[];e.forEach((s,r)=>{let l=0,i=t.length;if(i&&e[t[i-1]]<s)l=i;else for(;l<i;){const a=l+i>>1;e[t[a]]<s?l=a+1:i=a}n[r]=l?t[l-1]:-1,t[l]=r});let c=t.length,o=t[c-1];for(;c-- >0;)t[c]=o,o=n[o];return t},I=e=>{const{nr:t}=e;t&&t!=="N"&&(ft[t](e),Se(e))},ft={A:ge,D:Y,R:ut,U:ue,S:Ee,T:ue},dt=e=>{e.el&&(e.el.nodeValue=String(e.text))},be=(e,t,n)=>{const c=n||{};for(const o in e){const s=e[o];s!==c[o]&&(V(o)?ie(t,o,s,c[o]):o==="key"||o==="portal"&&x(s)||(o==="innerHTML"&&typeof s=="string"?t.innerHTML=s:ce(o,s)?yt(s,ce(o,c.style)?c.style:{},t):Ye(o,s)?s.value=t:o&&(o!=="type"&&se(t,o)?t[o]=s:(pt(o==="className"?"class":o,t,s),re(t)&&!(o in HTMLElement.prototype)&&(t[o]=s)))))}for(const o in c)if(!(e&&ye(e,o))){if(V(o)){ie(t,o,void 0,c[o]);continue}t.removeAttribute(o),re(t)?delete t[o]:t.localName.includes("-")&&se(t,o)&&(t[o]=void 0)}},pt=(e,t,n)=>S.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),N=(e,t)=>{let n;const{type:c,tag:o,text:s,props:r,children:l=[]}=e,i=T(c);if(tt(e),o==="svg"&&(S.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c||i)n=Pe();else if(c==="e"&&o)o==="portal"&&r&&r.portal?n=r.portal:n=S.value?document.createElementNS(S.value,o):ot(o);else if(c==="t"&&A(s))n=document.createTextNode(String(s));else throw Error("Invalid wDom");e.el=n}return ht(e,l,n,t),be(r,n,null),we(e),o==="svg"&&(S.value=""),n},ht=(e,t,n,c)=>{const o=B(e);t.forEach((s,r)=>{if(s.nr==="N"&&!c){const l=Le(s);s=t[r]="resolve"in l?l.resolve():l}if(s.getParent=o,s.nr="N",s.type){const l=N(s,c);s.tag!=="portal"&&!c&&n&&n.appendChild(l)}})},ie=(e,t,n,c)=>{const o=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(o,c),n&&e.addEventListener(o,n))},yt=(e,t,n)=>{const c={...t};if(!(n instanceof HTMLElement))return;const o=n.style;for(const s in e)o[s]=e[s],delete c[s];for(const s in c)o[s]=""},g=e=>T(e.type)?e.isRoot?e.we:g(C(e)):e.el,j=(e,t)=>(e!==t&&e.nr&&(e=Le(e)),vt(e,!!t&&$e[Ze(e)](e,t),t)),vt=(e,t,n)=>{const c=Et(e,t,n),o=kt(c,t,n),s=o==="N";return s||(c.children=gt(c,t,n)),c.nr=o,Ct(c,n,o),!s&&n&&(n.il=!0,n.ctor&&(n.children=void 0)),c},Ct=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&K(t),e.oc=t&&t.children),e.op=t&&t.props},kt=(e,t,n)=>{if(Xe(e))return"D";if(e===n||t&&e.type==="t"&&e.text===n.text)return"N";if(!(n&&n.type))return"A";const c=C(n),o=!e.isRoot&&c&&c.type==="l"&&X(e);return t?o?"T":"U":o?"S":"R"},Pt=(e,t)=>{e&&t!==e&&(t=t||{},te(e).forEach(n=>he(t,n)||delete e[n]),te(t).forEach(n=>e[n]=t[n]))},Rt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:o,children:s}=t;return n&&Pt(n,o),c&&s&&c!==s&&c.splice(0,c.length,...s),e.reRender&&e.reRender()},Et=(e,t,n)=>Q(e)?t&&n?Rt(n,e):(e.rd?w(e):(e.rd=!0,e)).resolve():e,gt=(e,t,n)=>t&&n?St(e,n):Mt(e),Mt=e=>{const t=B(e);return(e.children||[]).map(n=>{const c=j(n);return c.getParent=t,c})},St=(e,t)=>{if(e.type==="l"&&q(e))return bt(e,t);const n=t.children||[],c=B(e);return(e.children||[]).map((o,s)=>{const r=j(o,n[s]);return r.getParent=c,r})},bt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,i)=>{const a=H(l);A(a)&&!c.has(a)&&c.set(a,i)});const o=[],s=B(e),r=(e.children||[]).map((l,i)=>{const a=H(l),h=A(a)?c.get(a):i<n.length&&!X(n[i])?i:void 0;let d;h!==void 0&&(c.delete(a),o[h]=!0,d=n[h]);const u=j(l,d);return d&&(u.oi=h),u.getParent=s,u});return lt(n.filter((l,i)=>!o[i]),t),r},F=new Map;let O=!1;const xt=(e,t)=>{F.set(e,t),O||(O=!0,queueMicrotask(xe))},Tt=(e,t)=>{const n=p.get(e);n&&(n.up=()=>{const c=n.vd.value;xt(e,()=>t(c))})},m=e=>()=>{const t=p.get(e),n=t&&t.up;return n?(n(),!0):!1},xe=()=>{try{F.forEach((e,t)=>{F.delete(t),e()})}finally{O=!!F.size,O&&queueMicrotask(xe)}},P=(e,t,n,c,o,s)=>({type:e,nr:void 0,tag:t,props:n,text:c,children:o,getParent:s,el:void 0,oi:void 0,oc:void 0,op:void 0,il:void 0,[ae]:!0}),Nt=(e,t=()=>[])=>{const n=E();n&&(n.upR.push(()=>le(e,t)),le(e,t))},Ft=()=>{const e=E(),t=e&&e.upR;t&&t.length&&t.forEach(n=>n())},_=(e,...t)=>P("f",void 0,void 0,void 0,t),Te=(e,t,...n)=>{const c={value:void 0},o=Fe(c,n),s=Bt(e,t||{},o);return Q(s)||(c.value=s),s},At=(e,t)=>Te("portal",{portal:t},e),Lt=e=>(t,n)=>e,Ut=e=>(t,n)=>(J.add(e),e),Ot=(e,t,n)=>{const c=(o,s)=>{if(!(!o||s.has(o))){if(s.add(o),o.compChild){const r=o.compChild.indexOf(t);r!==-1&&o.compChild.splice(r,1,n)}c(o.getParent?o.getParent():void 0,s)}};c(e,new Set)},Ne=(e,t,n,c)=>{if(c.il)return;k.value=!0;let o;try{const s=W(e,t,n);o=j(s,c);const{isRoot:r,getParent:l,we:i,ae:a}=c;if(o.getParent=l,!r&&l){const h=l(),d=h&&h.children||[],u=d.indexOf(c);u!==-1&&d.splice(u,1,o),Ot(h,c,o)}else o.isRoot=!0,o.we=i,o.ae=a}finally{k.value=!1}I(o)},Bt=(e,t,n)=>{if(ve(e))return _(t,...n);if(Q(e)){const c=W(e,t,n);if(k.value)return c;const o=w(c).resolve();return o.rs=c,o}return P("e",e,t,void 0,n)},Fe=(e,t)=>{const n=()=>e.value;return t.map(c=>{const o=Ae(c);return o.getParent=n,o})},Ae=e=>{if(e==null||typeof e=="boolean")return P(null);if(Array.isArray(e)){const t={value:void 0},n=Fe(t,e),c=P("l",void 0,void 0,void 0,n);return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return P("t",void 0,void 0,e);return e},Qt=(e,t,n)=>(c=t)=>{const o=k.value,s=v.value;k.value=!1;try{je(c,e);const r=e(t,n);let l;if(typeof r=="function"){const i=r;l=J.has(i)?i(t,n):i(m(c),t,n)}else{let i=!0;l=a=>i?(i=!1,r):e(a,n)}return Kt(l,c,e,t,n)}finally{v.value=s,k.value=o}},Le=e=>e.ctor?w(e.rs||{ctor:e.ctor,props:e.compProps,children:e.compChild}):P(e.type,e.tag,e.props,e.text,e.children&&[...e.children],e.getParent),w=({ctor:e,props:t,children:n})=>W(e,{...t},[...n||[]]),W=(e,t,n)=>({ctor:e,props:t,children:n,resolve:Qt(e,t,n)}),Kt=(e,t,n,c,o)=>{const s=_t(e),r=s(c),l=jt(s,t,n,c,o);return Ue(r,t,n,c,o,l),Tt(t,i=>Ne(n,i.compProps||c,i.compChild||o,i)),r},jt=(e,t,n,c,o)=>{const s=()=>{const r=v.value;try{Ke(t),Ft();const l=e(c);return Ue(l,t,n,c,o,s),l}finally{v.value=r}};return s},_t=e=>t=>{const n=Ae(e(t)),c=_({},n);return n.getParent=()=>c,c},Ue=(e,t,n,c,o,s)=>{e.compProps=c,e.compChild=o,e.ctor=n,e.compKey=t,e.reRender=s;const r=p.get(t);r&&(r.vd.value=e)},Ht=e=>({value:e}),Vt=()=>Promise.resolve(),qt=()=>{const e=de();return e?m(e):()=>!1};exports.Fragment=_;exports.componentMap=p;exports.componentUpdate=m;exports.disposeComponentEntry=Ve;exports.getComponentKey=de;exports.getComponentSubInfo=Qe;exports.h=Te;exports.isPropType=qe;exports.lmount=Ut;exports.lmountComponentSet=J;exports.mount=Lt;exports.mountCallback=We;exports.mountReadyCallback=et;exports.nextTick=Vt;exports.portal=At;exports.ref=Ht;exports.render=st;exports.replaceWDom=Ne;exports.setComponentMapManualMode=_e;exports.updateCallback=Nt;exports.useRenew=qt;
2
2
  //# sourceMappingURL=lithent.cjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lithent.cjs","sources":["../src/utils/universalRef.ts","../src/utils/index.ts","../src/utils/predicator.ts","../src/hook/internal/unmount.ts","../src/hook/mountCallback.ts","../src/hook/mountReadyCallback.ts","../src/hook/internal/useUpdate.ts","../src/render.ts","../src/diff.ts","../src/utils/redraw.ts","../src/utils/createWDom.ts","../src/hook/updateCallback.ts","../src/wDom.ts","../src/hook/ref.ts","../src/hook/useRenew.ts"],"sourcesContent":["import {\n ComponentMap,\n ComponentSubKey,\n CompKey,\n ComponentInfo,\n TagFunction,\n} from '@/types';\n\nexport const wdomSymbol = Symbol.for('lithentWDomSymbol');\nexport const xmlnsRef: { value: string } = { value: '' };\nexport const compKeyRef: { value: CompKey | null } = { value: null };\nexport const needDiffRef: { value: boolean } = { value: false };\nexport const componentMap: ComponentMap = new WeakMap();\nexport const lmountComponentSet: WeakSet<Function> = new WeakSet();\nlet componentMapManualMode = false;\n\nconst setComponetRef = (compKey: CompKey, ctor?: TagFunction): void => {\n componentMap.set(compKey, {\n ctor,\n vd: { value: null },\n up: () => {},\n upR: [],\n upS: { value: 0 },\n upD: [],\n upCB: [],\n mts: [],\n umts: [],\n wdCB: [], // WDom creation callback queue\n });\n};\n\nexport const getComponentKey = (): CompKey | null => compKeyRef.value;\n\n/** The component whose setup or render is running (a WeakMap misses null). */\nexport const getCurrentComponent = () =>\n componentMap.get(compKeyRef.value as CompKey);\n\nexport const getComponentSubInfo = <K extends ComponentSubKey>(\n compKey: CompKey,\n subKey: K\n): ComponentInfo[K] | null => {\n const component = componentMap.get(compKey);\n if (component) {\n return component[subKey];\n }\n return null;\n};\n\nexport const initUpdateHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n};\n\nexport const initMountHookState = (\n compKey: CompKey,\n ctor?: TagFunction\n): void => {\n compKeyRef.value = compKey;\n setComponetRef(compKey, ctor);\n};\n\nexport const setComponentMapManualMode = (enabled: boolean): void => {\n componentMapManualMode = enabled;\n};\n\nexport const isComponentMapManualMode = (): boolean => componentMapManualMode;\n\nexport const runUnmountEffects = (compKey: CompKey): void => {\n const subInfo = componentMap.get(compKey);\n if (subInfo) {\n subInfo.umts.forEach(effect => effect());\n subInfo.umts = [];\n }\n};\n\nexport const disposeComponentEntry = (compKey: CompKey): void => {\n runUnmountEffects(compKey);\n componentMap.delete(compKey);\n};\n","import { WDom, Props } from '@/types';\n\nimport { wdomSymbol } from '@/utils/universalRef';\n\nexport const getParent = (vDom: WDom) =>\n (vDom.getParent && vDom.getParent()) as WDom;\n\n// A separate scope keeps parent links from retaining a diff's old children.\nexport const makeParentGetter = (parent: WDom) => () => parent;\n\nexport const entries = Object.entries;\nexport const keys = Object.keys;\n\nexport const isEnumerableProp = (props: Props, key: string) =>\n Object.prototype.propertyIsEnumerable.call(props, key);\n\n// DOM props use for...in, including inherited enumerable keys. A hidden own\n// key shadows the same name on the prototype and must not keep an old prop.\nexport const hasEnumerableProp = (props: Props, key: string): boolean => {\n if (isEnumerableProp(props, key)) return true;\n const prototype = Object.getPrototypeOf(props);\n return (\n !Object.prototype.hasOwnProperty.call(props, key) &&\n !!prototype &&\n hasEnumerableProp(prototype, key)\n );\n};\n\nexport const isObject = (target: unknown): target is Record<string, unknown> =>\n typeof target === 'object' && target !== null;\n\nexport const assign = Object.assign;\nexport const isPropType = (obj: unknown): obj is Props => {\n return (\n isObject(obj) &&\n !Array.isArray(obj) &&\n !Object.getOwnPropertySymbols(obj).includes(wdomSymbol)\n );\n};\n","import { Fragment } from '@/wDom';\nimport {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n WDomType,\n} from '@/types';\nimport { isObject } from '@/utils';\n\ntype WDomParam =\n | string\n | WDom\n | TagFunction\n | TagFunctionResolver\n | FragmentFunction;\n\n/**\n * Predicator\n */\n\nconst checkSameCustomComponent = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n 'ctor' in newWDom\n ? newWDom.ctor === (originalWDom && originalWDom.ctor)\n : newWDom === (originalWDom && originalWDom.ctor);\n\n// The checks below are reached through checkSameWDomWithOriginal only: with\n// a plain node of that type (getWDomType) and an original.\nconst checkSameFragment = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === 'f' &&\n // A component's node is a one-child fragment too: never update it in\n // place as a plain fragment, or the component is never unmounted, nor\n // update a plain fragment with one (a hoisted <Comp /> first drawn by a\n // redraw), or it is never mounted.\n !originalWDom.ctor &&\n !newWDom.ctor &&\n !!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length);\n\nconst checkSameTagElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === 'e' &&\n originalWDom.tag === newWDom.tag &&\n !!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length);\n\nconst checkNormalTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === newWDom.type;\n\nconst checkLoopTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === newWDom.type &&\n ((checkKeyedChildren(newWDom) && checkKeyedChildren(originalWDom)) ||\n (!!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)));\n\nexport const getKey = (target: WDom) =>\n (target && target.compProps && target.compProps.key) ??\n (target && target.props && target.props.key);\n\n/**\n * Check if the type is virtual (fragment or loop)\n * Virtual types don't create real DOM elements themselves\n */\nexport const checkVirtualType = (\n type?: string | null // 'f': fragment, 'l': loop\n) => type === 'f' || type === 'l';\n\nexport const checkCustemComponentFunction = (\n target: WDomParam\n): target is TagFunction | TagFunctionResolver =>\n (typeof target === 'function' && !checkFragmentFunction(target)) ||\n (isObject(target) && 'resolve' in target);\n\nexport const checkFragmentFunction = (\n target: unknown\n): target is FragmentFunction => target === Fragment;\n\n// A diffed node (resolved already): empty when it has no type.\nexport const checkEmptyElement = (wDom: WDom) => !wDom.type;\n\n// Whether the node's element is a portal target, which lies outside the\n// parent the portal sits in: a portal's own element, or the one a node\n// replacing or deleting a portal still holds, with that portal's props (op),\n// until it is drawn.\nexport const checkPortalElement = ({ el, op, props }: WDom) =>\n !!el && (el === (op && op.portal) || el === (props && props.portal));\n\nexport const checkEventKey = (key: string) => key[0] === 'o' && key[1] === 'n';\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\n\n// A list is keyed when any child has a key: a leading null or false (a hidden\n// row) must not turn key matching off for the rest.\nexport const checkKeyedChildren = (target?: WDom) =>\n !!target && !!target.children && target.children.some(checkExistyKey);\n\nexport const checkExisty = (value: unknown) =>\n value !== null && value !== undefined;\n\nexport const checkStyleData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is Record<string, string> =>\n dataKey === 'style' && isObject(dataValue);\n\nexport const checkRefData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is {\n value: HTMLElement | Element | DocumentFragment | Text | undefined;\n} => dataKey === 'ref' && isObject(dataValue);\n\n// Descriptor lookups are cached per prototype+key. Keying by prototype\n// rather than nodeName matters for custom elements: one rendered before its\n// definition is upgraded later and gets a new prototype, which must be looked\n// up again instead of reusing the \"no accessor\" answer for its tag name.\nconst accessorCache = new WeakMap<object, Map<string, boolean>>();\n\nexport const hasAccessorMethods = (target: unknown, dataKey: string) => {\n const proto = target!.constructor.prototype;\n let byKey = accessorCache.get(proto);\n if (!byKey) accessorCache.set(proto, (byKey = new Map()));\n let result = byKey.get(dataKey);\n\n if (result === undefined) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, dataKey);\n result = !!(descriptor && descriptor.get && descriptor.set);\n byKey.set(dataKey, result);\n }\n\n return result;\n};\n\n// A custom element tag whose definition has not arrived, or whose instance\n// has not been upgraded yet: still a plain HTMLElement, with no accessors.\nexport const isPendingCustomElement = (target: unknown) =>\n (target as Element).localName.includes('-') &&\n (target as Element).constructor === HTMLElement;\n\n/**\n * Get WDom type as a single character code\n * 'c': component, 'f': fragment, 'e': element, 'l': loop, 't': text, 'et': empty/null\n */\nexport const getWDomType = (\n wDom: WDom | TagFunction | TagFunctionResolver\n): WDomType =>\n checkCustemComponentFunction(wDom)\n ? 'c'\n : ((wDom as WDom).type as WDomType) || 'et';\n\nexport const checkSameWDomWithOriginal = {\n c: checkSameCustomComponent,\n l: checkLoopTypeElement,\n t: checkNormalTypeElement,\n e: checkSameTagElement,\n f: checkSameFragment,\n et: checkNormalTypeElement,\n};\n","import { WDom, CompKey } from '@/types';\nimport { checkEventKey } from '@/utils/predicator';\nimport {\n componentMap,\n getCurrentComponent,\n isComponentMapManualMode,\n runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n const comp = getCurrentComponent();\n comp && comp.umts.push(effectAction);\n};\n\nexport const runUnmountQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n // A redraw queued before this removal still holds the node. Marking it\n // retired makes that stale redraw a no-op instead of drawing it back in.\n newWDom.il = true;\n removeItem(compKey);\n }\n recursiveRunUnmount(newWDom);\n};\n\nconst recursiveRunUnmount = (wDom: WDom) => {\n // A portal host belongs to the caller and survives removal. Release its\n // handlers while leaving listeners on discarded ordinary DOM untouched.\n if (wDom.tag === 'portal' && wDom.el) {\n for (const key in wDom.props) {\n if (checkEventKey(key)) {\n wDom.el.removeEventListener(\n key.slice(2).toLowerCase(),\n wDom.props[key] as EventListener\n );\n }\n }\n }\n (wDom.children || []).forEach(item => {\n const childComKey = item.compKey;\n if (childComKey) {\n runUnmountQueueFromWDom(item);\n } else {\n recursiveRunUnmount(item);\n }\n });\n};\n\nconst removeItem = (compKey: CompKey) => {\n runUnmountEffects(compKey);\n\n if (!isComponentMapManualMode()) {\n componentMap.delete(compKey);\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\nlet mountedQueue: WDom[] = [];\n\n/**\n * WDom을 mountedQueue에 추가\n */\nexport const addMountedQueue = (wDom: WDom) => {\n if (wDom.compKey) {\n mountedQueue.push(wDom);\n }\n};\n\n/**\n * DOM 렌더링 후 mountCallback 실행\n */\nexport const execMountedQueue = () => {\n mountedQueue.forEach(runMountedQueueFromWDom);\n mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n const comp = getCurrentComponent();\n comp && comp.mts.push(effectAction);\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n // Every entry has all its queues (setComponetRef).\n const component = compKey && componentMap.get(compKey);\n\n if (component) {\n const mountQueue = component.mts;\n\n compKeyRef.value = compKey;\n component.upS.value = 0;\n component.mts = [];\n\n mountQueue.forEach((effect: Function) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n const comp = getCurrentComponent();\n comp && comp.wdCB.push(effectAction);\n};\n\n/**\n * 특정 WDom의 wdomCallback 즉시 실행\n * wDomToDom() 내부에서 각 WDom 생성 시점에 호출됨\n */\nexport const runWDomCallbacksFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n const wdCBQueue = component && component.wdCB;\n\n compKeyRef.value = compKey;\n\n if (wdCBQueue && wdCBQueue.length > 0) {\n component.wdCB = [];\n\n wdCBQueue.forEach((effect: Function) => {\n const cleanup = effect();\n if (typeof cleanup === 'function') {\n unmount(cleanup);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const component = getCurrentComponent();\n if (!component) return;\n\n const { upD, upS } = component;\n const def = upD[upS.value];\n\n const nextDependencies = dependencies();\n\n if (def && checkNeedPushQueue(def, nextDependencies)) {\n const callback = effectAction();\n if (callback) {\n component.upCB.push(callback);\n }\n }\n\n upD[upS.value] = nextDependencies;\n upS.value += 1;\n};\n\nexport const runUpdatedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n // Every entry has all its queues (setComponetRef).\n const component = compKey && componentMap.get(compKey);\n\n if (component) {\n const queue = component.upCB;\n\n compKeyRef.value = compKey;\n component.upS.value = 0;\n\n if (newWDom.ctor) {\n component.upCB = [];\n queue.forEach((effect: Function) => effect());\n }\n }\n};\n\nconst checkNeedPushQueue = (originalDefs: unknown[], newDefs: unknown[]) =>\n !originalDefs.length\n ? true\n : originalDefs.some((def, index) => def !== newDefs[index]);\n","import { WDom, Props } from '@/types';\nimport {\n checkStyleData,\n checkRefData,\n checkExisty,\n checkVirtualType,\n hasAccessorMethods,\n isPendingCustomElement,\n checkEventKey,\n checkPortalElement,\n} from '@/utils/predicator';\n\nimport { componentMap, xmlnsRef } from '@/utils/universalRef';\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { execMountedQueue, addMountedQueue } from '@/hook/mountCallback';\nimport { runWDomCallbacksFromWDom } from '@/hook/mountReadyCallback';\nimport { runUpdatedQueueFromWDom } from '@/hook/internal/useUpdate';\nimport {\n getParent,\n isObject,\n hasEnumerableProp,\n makeParentGetter,\n} from '@/utils';\nimport { cloneWDom } from '@/wDom';\n\nconst DF = () => new DocumentFragment();\n\n// Into the root's wrapper: before its after element, in place of <html>, or\n// at the end.\nconst insertRoot = (\n wrapElement: HTMLElement,\n element: Node,\n afterElement?: HTMLElement | null\n) =>\n afterElement\n ? wrapElement.insertBefore(element, afterElement)\n : wrapElement.tagName === 'HTML'\n ? wrapElement.replaceWith(element)\n : wrapElement.appendChild(element);\nconst CE = (t: string) => document.createElement(t);\n\nexport const render = (\n wDom: WDom,\n wrapElement: HTMLElement | null,\n afterElement?: HTMLElement | null,\n isHydration?: boolean\n) => {\n wDom.isRoot = true;\n wrapElement = wrapElement || document.body;\n wDom.we = wrapElement;\n\n const Dom = wDomToDom(wDom, isHydration);\n\n wDom.ae = afterElement as HTMLElement;\n if (afterElement || !isHydration) {\n insertRoot(wrapElement, Dom, afterElement);\n }\n\n execMountedQueue();\n\n return () => {\n const compData = componentMap.get(wDom.compProps as Props);\n const comp = (compData && compData.vd.value) || wDom;\n runUnmountQueueFromWDom(comp);\n rootDelete(comp);\n };\n};\n\nconst rootDelete = (newWDom: WDom) =>\n deleteRealDom(newWDom, newWDom.we as HTMLElement);\n\nexport const typeDelete = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n deleteRealDom(\n newWDom,\n (newWDom.isRoot\n ? newWDom.we\n : parentWDom && findRealParentElement(parentWDom)) as HTMLElement\n );\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n if (parent && newWDom.el) {\n const nt = newWDom.el.nodeType;\n // A portal's children are in its target, which itself stays.\n const isPortal = checkPortalElement(newWDom);\n if (nt === 11 || isPortal) {\n findChildWithRemoveElement(\n newWDom,\n isPortal ? (newWDom.el as HTMLElement) : parent\n );\n } else if (nt === 1 || nt === 3) {\n parent.removeChild(newWDom.el);\n }\n\n newWDom.el = undefined;\n }\n};\n\nconst findChildWithRemoveElement = (newWDom: WDom, parent: HTMLElement) => {\n const items = newWDom.oc || newWDom.children || [];\n\n // Bulk fast path: the parent element contains exactly these children,\n // so they can all be dropped in a single operation.\n if (\n items.length > 1 &&\n items.every(item => {\n const nt = item.el && item.el.nodeType;\n return (\n (nt === 1 || nt === 3) &&\n (item.el as HTMLElement).tagName !== 'HTML' &&\n !checkPortalElement(item)\n );\n })\n ) {\n // Stop one past the candidates: a component in a long list calls this\n // once per component, so counting every sibling there is quadratic.\n // (counted via sibling pointers -- childNodes would materialize a live list)\n let count = 0;\n for (\n let node = parent.firstChild;\n node && count <= items.length;\n node = node.nextSibling\n ) {\n count++;\n }\n\n if (count === items.length) {\n parent.textContent = '';\n items.forEach(item => (item.el = undefined));\n return;\n }\n }\n\n items.forEach(item => {\n const nt = item.el && item.el.nodeType;\n if (checkPortalElement(item)) {\n findChildWithRemoveElement(item, item.el as HTMLElement);\n } else if (nt === 1 || nt === 3) {\n const el = item.el as HTMLElement;\n el.tagName === 'HTML' ? (el.innerHTML = '') : el.remove();\n } else if (nt === 11) {\n findChildWithRemoveElement(item, parent);\n }\n });\n};\n\n/**\n * Unmount and remove unused keyed children. Listeners are left on the\n * discarded DOM and go away with it. The parent element is found from the\n * list they were in: a child's own parent link may have been moved on by\n * the same node being drawn in another place since.\n */\nexport const typeDeleteUnused = (items: WDom[], list: WDom) => {\n const parentElement = findRealParentElement(list) as HTMLElement;\n items.forEach(item => {\n runUnmountQueueFromWDom(item);\n deleteRealDom(item, parentElement);\n });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\n\nconst typeAdd = (\n newWDom: WDom,\n newElement?: HTMLElement | DocumentFragment | Text\n) => {\n newElement = newElement || wDomToDom(newWDom);\n\n const parentWDom = getParent(newWDom);\n if (!parentWDom || !parentWDom.type) {\n if (newWDom.isRoot && newWDom.we && newWDom.tag !== 'portal') {\n insertRoot(newWDom.we, newElement, newWDom.ae);\n execMountedQueue();\n }\n return;\n }\n\n const parentEl = findRealParentElement(parentWDom);\n // Children added or moved inside a loop are placed by updateChildren, so\n // anything that reaches here (e.g. a replaced fragment or component in an\n // unkeyed loop) goes right before its own next sibling.\n const nextEl = startFindNextBrotherElement(newWDom, parentWDom);\n\n if (parentEl) {\n if (newWDom.tag !== 'portal') {\n parentEl.insertBefore(newElement, nextEl || null);\n }\n execMountedQueue();\n }\n};\n\nconst getElementFromFragment = (newWDom: WDom) => {\n if (checkVirtualType(newWDom.type)) {\n return (newWDom.children || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n\n // A portal's target does not move with its siblings.\n if (element && !checkPortalElement(item)) {\n acc.appendChild(element);\n }\n return acc;\n }, DF());\n }\n\n return newWDom.el;\n};\n\nconst startFindNextBrotherElement = (\n wDom: WDom,\n parentWDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const brothers = parentWDom.children || [];\n\n // After the brothers, a fragment or loop parent goes on with its own next\n // brother, up to the root's after element.\n return (\n findChildFragmentNextElement(brothers.slice(brothers.indexOf(wDom) + 1)) ||\n (checkVirtualType(parentWDom.type)\n ? parentWDom.isRoot\n ? parentWDom.ae\n : startFindNextBrotherElement(parentWDom, getParent(parentWDom))\n : undefined)\n );\n};\n\n// Children of a list being updated that move or are added: until its\n// placement pass they are not where they will be, so they are no anchor for\n// content inserted meanwhile. Kept here rather than as a flag on the node,\n// which would give the nodes that get it another shape.\nconst moving = new Set<WDom>();\n\nconst findChildFragmentNextElement = (\n candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n (targetEl, bItem) => {\n // A portal's target is not in the parent: no anchor there.\n if (\n targetEl ||\n checkPortalElement(bItem) ||\n (moving.size && moving.has(bItem))\n )\n return targetEl;\n const { type, el } = bItem;\n if (type && checkVirtualType(type)) {\n const found = findChildFragmentNextElement(bItem.children || []);\n if (found) return found;\n }\n if (el && el.nodeType !== 11) return el;\n return targetEl;\n },\n undefined\n );\n\nconst typeReplace = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n const orignalElement = newWDom.el;\n\n if (orignalElement && (parentWDom ? parentWDom.type : newWDom.isRoot)) {\n // A portal being replaced, or replacing: one side is drawn in the\n // portal's target, not in the parent, so delete and add instead.\n if (\n !parentWDom ||\n orignalElement.nodeType === 11 ||\n checkPortalElement(newWDom) ||\n newWDom.tag === 'portal'\n ) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement) {\n parentElement.replaceChild(newElement, orignalElement);\n }\n execMountedQueue();\n }\n }\n};\n\nconst typeUpdate = (newWDom: WDom) => {\n if (newWDom.type === 't') {\n updateText(newWDom);\n return;\n }\n\n if (newWDom.el) {\n const { op: oldProps, props } = newWDom;\n updateProps(props, newWDom.el, oldProps);\n\n if (newWDom.tag === 'input') {\n (newWDom.el as HTMLInputElement).value = String(\n (props && props.value) || ''\n );\n }\n }\n\n updateChildren(newWDom);\n runUpdatedQueueFromWDom(newWDom);\n};\n\n/**\n * Process child updates. Loop parents with added/moved children are handled\n * in O(n): a left-to-right content pass (keeps lifecycle order), an LIS over\n * the matched original indices (oi, recorded by the diff phase) to pick the\n * children that can stay in place, and a right-to-left placement pass that\n * inserts only added children and non-LIS moves before a running anchor.\n */\nconst updateChildren = (newWDom: WDom) => {\n const children = newWDom.children || [];\n\n if (\n newWDom.type !== 'l' ||\n !children.some(\n item => 'ATS'.includes(item.nr as string) || item.oi !== undefined\n )\n ) {\n children.forEach(wDomUpdate);\n return;\n }\n\n // The matched children that keep their place: an LIS over their original\n // indexes (oi). Worked out before the content pass, because until the\n // placement pass a child that moves is still where it was, and so is the\n // old element of one replaced (S): neither may be the anchor for content\n // inserted meanwhile (moving), such as a kept row whose fragment changed.\n // An added child needs no such care: it has no element before the content\n // pass reaches it, and anchors are looked for after the child at hand.\n // Read up front: wDomUpdate clears oi on an unkeyed child matched by\n // position.\n const matchedIndexes: number[] = [];\n const oiSeq: number[] = [];\n\n // Replaced children, then the matched ones that move.\n const movers: WDom[] = [];\n let ordered = true;\n\n children.forEach((item, index) => {\n const oi = item.oi;\n const nr = item.nr;\n if (nr === 'S') {\n movers.push(item);\n } else if (nr !== 'A' && oi !== undefined) {\n if (oi < oiSeq[oiSeq.length - 1]) {\n ordered = false;\n }\n matchedIndexes.push(index);\n oiSeq.push(oi);\n }\n });\n\n // keep[i]: whether matched child i stays (unset when not matched).\n // Matched children still in their original order all stay, as in a redraw\n // that moves nothing: no LIS then. Only the children that move or are\n // added are flagged, so a long list's children are usually untouched.\n let keep: boolean[] | undefined;\n if (!ordered) {\n const lis: boolean[] = (keep = []);\n getLisPositions(oiSeq).forEach(pos => (lis[matchedIndexes[pos]] = true));\n matchedIndexes.forEach(\n i => lis[i] || ((lis[i] = false), movers.push(children[i]))\n );\n }\n\n // Content pass (left-to-right, keeps lifecycle order).\n // Added children are created here but inserted in the placement pass.\n const created: (HTMLElement | DocumentFragment | Text | undefined)[] = [];\n let createdCount = 0;\n\n movers.forEach(item => moving.add(item));\n try {\n children.forEach((item, index) => {\n const nr = item.nr;\n\n if (nr === 'A' || nr === 'S') {\n if (nr === 'S') {\n typeDelete(item);\n }\n created[index] = wDomToDom(item);\n createdCount++;\n } else {\n wDomUpdate(item);\n }\n });\n } finally {\n movers.forEach(item => moving.delete(item));\n }\n\n const parentEl = findRealParentElement(newWDom);\n const baseAnchor = newWDom.isRoot\n ? newWDom.ae\n : startFindNextBrotherElement(newWDom, getParent(newWDom));\n\n // Fast-append the trailing run of added children in order\n // (a null anchor makes insertBefore behave as appendChild).\n let tail = children.length;\n while (tail > 0 && created[tail - 1] !== undefined) {\n tail--;\n }\n\n for (let i = tail; i < children.length; i++) {\n const el = created[i];\n\n if (el && parentEl && children[i].tag !== 'portal') {\n parentEl.insertBefore(el, baseAnchor || null);\n }\n }\n\n if (keep || createdCount > children.length - tail) {\n // Placement pass (right-to-left): insert added children and non-LIS\n // moves before a running anchor.\n let anchor =\n findChildFragmentNextElement(children.slice(tail)) || baseAnchor;\n\n for (let i = tail - 1; i >= 0; i--) {\n const item = children[i];\n const isNew = created[i] !== undefined;\n const needMove = !!keep && keep[i] === false;\n\n if ((isNew || needMove) && parentEl && item.tag !== 'portal') {\n const el = isNew ? created[i] : getElementFromFragment(item);\n\n if (el) {\n parentEl.insertBefore(el, anchor || null);\n }\n }\n\n const first = findChildFragmentNextElement([item]);\n if (first) {\n anchor = first;\n }\n }\n }\n\n children.forEach(clearDiffMeta);\n execMountedQueue();\n};\n\n// Assigned, not deleted: `delete` changes the object's shape, which makes\n// every later access to the node slower. nr goes back to 'N' (nothing to\n// do), not undefined: a node that has it is drawn (see makeNewWDomTree).\nconst clearDiffMeta = (item: WDom) => {\n item.oi = item.oc = item.op = undefined;\n item.nr = 'N';\n};\n\n/**\n * Longest increasing subsequence positions (binary search, O(n log n)).\n * Returns the positions in seq that form the LIS.\n */\nconst getLisPositions = (seq: number[]) => {\n // tails[k]: the position ending the smallest-tailed increasing run of\n // length k + 1. A value larger than the last tail just extends it.\n const tails: number[] = [];\n const prev: number[] = [];\n\n seq.forEach((value, i) => {\n let lo = 0;\n let hi = tails.length;\n\n if (hi && seq[tails[hi - 1]] < value) {\n lo = hi;\n } else {\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (seq[tails[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n }\n\n prev[i] = lo ? tails[lo - 1] : -1;\n tails[lo] = i;\n });\n\n let i = tails.length;\n let last = tails[i - 1];\n while (i-- > 0) {\n tails[i] = last;\n last = prev[last];\n }\n\n return tails;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n const { nr: needRerender } = newWDomTree;\n\n if (needRerender && needRerender !== 'N') {\n renderHandlers[needRerender](newWDomTree);\n clearDiffMeta(newWDomTree);\n }\n};\n\nconst renderHandlers = {\n A: typeAdd,\n D: typeDelete,\n R: typeReplace,\n U: typeUpdate,\n S: typeSortedReplace,\n // A keyed item reaches here only as a component redrawing itself: it has\n // not moved, so it is updated in place. Re-inserting its nodes would blur a\n // focused input inside it or reload an iframe. Moves within a list are\n // placed by updateChildren.\n T: typeUpdate,\n} as const;\n\nconst updateText = (newWDom: WDom) => {\n if (newWDom.el) {\n newWDom.el.nodeValue = String(newWDom.text);\n }\n};\n\nconst updateProps = (\n props?: Props,\n element?: HTMLElement | Element | DocumentFragment | Text,\n oldProps?: Props | null\n) => {\n const originalProps = oldProps || {};\n\n for (const dataKey in props) {\n const dataValue: unknown = props[dataKey];\n\n if (dataValue === originalProps[dataKey]) {\n continue;\n }\n\n // An event key starts with \"on\", so it is none of the keys below.\n if (checkEventKey(dataKey)) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else {\n if (dataKey === 'key') {\n // Do nothing\n } else if (dataKey === 'portal' && isObject(dataValue)) {\n // Do nothing\n } else if (dataKey === 'innerHTML' && typeof dataValue === 'string') {\n (element as HTMLElement).innerHTML = dataValue;\n } else if (checkStyleData(dataKey, dataValue)) {\n updateStyle(\n dataValue,\n checkStyleData(dataKey, originalProps.style)\n ? originalProps.style\n : {},\n element\n );\n } else if (checkRefData(dataKey, dataValue)) {\n dataValue.value = element;\n } else if (dataKey) {\n if (dataKey !== 'type' && hasAccessorMethods(element, dataKey)) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n } else {\n setAttr(\n dataKey === 'className' ? 'class' : dataKey,\n element as HTMLElement,\n dataValue as string\n );\n // Keep the real value too: once defined, the element absorbs own\n // properties through its accessors, so an object or `false` is not\n // left as the attribute string (B-3).\n // Only keys HTMLElement lacks: `textContent` or `offsetWidth` would\n // run a DOM setter or throw.\n if (\n isPendingCustomElement(element) &&\n !(dataKey in HTMLElement.prototype)\n ) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n }\n }\n }\n }\n }\n\n // Props that are gone. The previous props object is left as it was: it may\n // be the caller's own object.\n for (const dataKey in originalProps) {\n if (props && hasEnumerableProp(props, dataKey)) {\n continue;\n }\n\n if (checkEventKey(dataKey)) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n undefined,\n originalProps[dataKey] as (e: Event) => void\n );\n continue;\n }\n\n (element as HTMLElement).removeAttribute(dataKey);\n // A prop that went in as a custom element property is unset there too\n // (B-4). Not upgraded yet: drop the value kept for it (B-3); `delete`\n // never touches an inherited DOM property such as `title`. Upgraded:\n // only through the element's own accessors, never built-in ones such as\n // input.value, where `undefined` would read as \"undefined\".\n if (isPendingCustomElement(element)) {\n delete (element as HTMLElement & Record<string, unknown>)[dataKey];\n } else if (\n (element as Element).localName.includes('-') &&\n hasAccessorMethods(element, dataKey)\n ) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] = undefined;\n }\n }\n};\n\nconst setAttr = (k: string, el: HTMLElement, v: string) =>\n xmlnsRef.value && k !== 'xmlns'\n ? el.setAttributeNS(null, k, v)\n : el.setAttribute(k, v);\n\nconst wDomToDom = (wDom: WDom, isHydration?: boolean): HTMLElement => {\n let element;\n const { type, tag, text, props, children = [] } = wDom;\n const isVirtualType = checkVirtualType(type);\n\n runWDomCallbacksFromWDom(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = String(props && props.xmlns);\n }\n\n if (!isHydration) {\n if (!type || isVirtualType) {\n element = DF();\n } else if (type === 'e' && tag) {\n // element\n if (tag === 'portal' && props && props.portal) {\n element = props.portal as HTMLElement;\n } else {\n element = xmlnsRef.value\n ? document.createElementNS(xmlnsRef.value, tag)\n : CE(tag);\n }\n } else if (type === 't' && checkExisty(text)) {\n // text node\n element = document.createTextNode(String(text));\n } else {\n throw Error('Invalid wDom');\n }\n\n wDom.el = element as HTMLElement;\n } else {\n element = wDom.el;\n }\n\n wDomChildrenToDom(wDom, children, element, isHydration);\n\n updateProps(props, element, null);\n\n addMountedQueue(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = '';\n }\n\n return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\n wDom: WDom,\n children: WDom[],\n parentElement?: HTMLElement | Element | DocumentFragment | Text,\n isHydration?: boolean\n) => {\n // The parent is not attached to the document yet, so children can be\n // appended directly (no intermediate fragment allocation).\n const getParent = makeParentGetter(wDom);\n children.forEach((childItem: WDom, index: number) => {\n // A child already drawn elsewhere (nr 'N': the same node twice, a\n // hoisted constant in several components) is drawn here as its own copy.\n // The children of an added subtree come from a diff, which copied those\n // already (nr 'A'). Drawn, the child gets nr 'N' (see makeNewWDomTree).\n if (childItem.nr === 'N' && !isHydration) {\n const copy = cloneWDom(childItem);\n childItem = children[index] = 'resolve' in copy ? copy.resolve() : copy;\n }\n // h() may have assigned a shared node to a later parent already. The\n // first occurrence needs its actual owner too, not only the copies.\n childItem.getParent = getParent;\n childItem.nr = 'N';\n if (childItem.type) {\n const childElement = wDomToDom(childItem, isHydration);\n if (childItem.tag !== 'portal' && !isHydration && parentElement) {\n parentElement.appendChild(childElement);\n }\n }\n });\n};\n\nconst updateEvent = (\n element: HTMLElement,\n eventKey: string,\n newEventHandler: ((e: Event) => void) | undefined,\n oldEventHandler: (e: Event) => void\n) => {\n const eventName = eventKey.slice(2).toLowerCase();\n\n if (oldEventHandler !== newEventHandler) {\n if (oldEventHandler) {\n element.removeEventListener(eventName, oldEventHandler);\n }\n\n if (newEventHandler) {\n element.addEventListener(eventName, newEventHandler);\n }\n }\n};\n\nconst updateStyle = (\n style: Record<string, string>,\n oldStyle: Record<string, string>,\n element?: HTMLElement | Element | DocumentFragment | Text\n) => {\n const orig = { ...oldStyle };\n if (!(element instanceof HTMLElement)) return;\n\n const styleProxy = element.style as unknown as Record<string, string>;\n\n for (const k in style) {\n styleProxy[k] = style[k];\n delete orig[k];\n }\n\n for (const k in orig) {\n styleProxy[k] = '';\n }\n};\n\nconst findRealParentElement = (\n vDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined =>\n checkVirtualType(vDom.type)\n ? vDom.isRoot\n ? vDom.we\n : findRealParentElement(getParent(vDom) as WDom)\n : (vDom.el as HTMLElement);\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent, makeParentGetter } from '@/utils';\nimport { typeDeleteUnused } from '@/render';\nimport { cloneWDom, copyResolver } from '@/wDom';\nimport {\n checkEmptyElement,\n checkSameWDomWithOriginal,\n getWDomType,\n checkExistyKey,\n checkExisty,\n checkKeyedChildren,\n} from '@/utils/predicator';\n\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { keys, isEnumerableProp } from '@/utils';\n\n/**\n * The starting point of the diffing process between the original virtual DOM and the new virtual DOM for re-rendering.\n */\nexport const makeNewWDomTree = (\n newWDom: WDom | TagFunctionResolver,\n originalWDom?: WDom\n) => {\n // Already drawn or taken by a diff (it has nr, 'N' once drawn): the node\n // belongs to another place, so this place draws a copy. The same node in the same place is still left\n // alone as unchanged. A component made without a diff and not drawn yet\n // (in a new component's output, or a hoisted <Comp />) is drawn as it is:\n // a copy would be a second instance, leaving the one already set up behind.\n if (newWDom !== originalWDom && (newWDom as WDom).nr) {\n newWDom = cloneWDom(newWDom as WDom);\n }\n\n return remakeNewWDom(\n newWDom,\n !!originalWDom &&\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\n );\n};\n\n/**\n * Create a new virtual DOM after comparing with the previous virtual DOM\n */\nconst remakeNewWDom = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n) => {\n const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n const needRerender = addReRenderTypeProperty(\n remakeWDom,\n isSameType,\n originalWDom\n );\n const isNoting = needRerender === 'N';\n\n if (!isNoting) {\n remakeWDom.children = remakeChildrenForDiff(\n remakeWDom,\n isSameType,\n originalWDom\n );\n }\n\n // NOTE: short-key metadata (nr = needRerender) keeps bundle size down\n remakeWDom.nr = needRerender;\n inheritPropForRender(remakeWDom, originalWDom, needRerender);\n\n // A retired node keeps its children: it may be a hoisted constant the\n // caller draws again later, which is then copied from them. A component's\n // node is copied from its description instead (cloneWDom), so it lets go\n // of its previous output: otherwise every row a list redraws keeps its old\n // subtree reachable, for the GC to copy, until the whole redraw is done.\n if (!isNoting && originalWDom) {\n originalWDom.il = true;\n if (originalWDom.ctor) {\n originalWDom.children = undefined;\n }\n }\n return remakeWDom;\n};\n\n/**\n * Handle what the new virtual DOM should inherit or reconcile from the original virtual DOM.\n */\nconst inheritPropForRender = (\n remakeWDom: WDom,\n originalWDom?: WDom,\n needRerender?: RenderType\n) => {\n if (needRerender !== 'A' && originalWDom) {\n remakeWDom.el = originalWDom.el;\n }\n\n if (needRerender === 'D' || needRerender === 'R' || needRerender === 'S') {\n if (originalWDom) {\n runUnmountQueueFromWDom(originalWDom);\n }\n remakeWDom.oc = originalWDom && originalWDom.children;\n }\n\n remakeWDom.op = originalWDom && originalWDom.props;\n};\n\n/**\n * Determine the render operation type (Add/Delete/Replace/Update/etc)\n * based on comparison between new and original WDom\n */\nconst addReRenderTypeProperty = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n): RenderType | undefined => {\n if (checkEmptyElement(newWDom)) return 'D';\n\n if (\n newWDom === originalWDom ||\n (isSameType &&\n newWDom.type === 't' &&\n newWDom.text === (originalWDom as WDom).text)\n ) {\n return 'N';\n }\n if (!(originalWDom && originalWDom.type)) return 'A';\n\n const parent = getParent(originalWDom);\n const isKeyChecked =\n !newWDom.isRoot && parent && parent.type === 'l' && checkExistyKey(newWDom);\n\n return isSameType ? (isKeyChecked ? 'T' : 'U') : isKeyChecked ? 'S' : 'R';\n};\n\n/**\n * Handling virtual DOM attribute updates.\n */\nconst syncResolverProps = (props: Props, infoProps: Props) => {\n if (props && infoProps !== props) {\n // Only the keys that are gone: deleting and re-adding every key on every\n // render changes the object's shape each time.\n infoProps = infoProps || {};\n keys(props).forEach(\n key => isEnumerableProp(infoProps, key) || delete props[key]\n );\n keys(infoProps).forEach(key => (props[key] = infoProps[key]));\n }\n};\n\n/**\n * Keep the existing component node while injecting the props/children from the freshly computed TagFunctionResolver.\n * originalWDom is the fully evaluated node from the previous render, whereas infoVdom is the intermediate resolver,\n * so updating compProps/compChild in place lets reRender() evaluate with the latest slots and props.\n * It is crucial that props and children references remain stable as nodes update—many ancestors/closures share these arrays,\n * so mutate the existing arrays instead of replacing their references.\n */\nconst runUpdate = (vDom: WDom, infoVdom: TagFunctionResolver) => {\n const { compProps: props, compChild: children } = vDom;\n const { props: infoProps, children: infoChidren } = infoVdom;\n\n if (props) {\n syncResolverProps(props, infoProps);\n }\n\n /**\n * In runUpdate, the original DOM (vDom) is already fully evaluated and completed, whereas infoVdom represents an intermediate state. Therefore, vdom.compChild and infoVdom.children are indeed the correct counterparts to compare.\n\n * Keep shared child array references intact (<= same slot array instance)\n * When the reference changes, sync the stored compChild contents so reRender sees fresh nodes\n * Only update children if they're different references\n * If it's the same Fragment reference, the diff process will handle updating its children\n */\n if (children && infoChidren && children !== infoChidren) {\n children.splice(0, children.length, ...infoChidren);\n }\n\n return (vDom.reRender && vDom.reRender()) as WDom;\n};\n\n/**\n * Replace the compared virtual DOM with the new virtual DOM or simply update it.\n */\nconst generalize = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n): WDom => {\n return checkCustemComponentFunction(newWDom)\n ? isSameType && originalWDom\n ? runUpdate(originalWDom, newWDom)\n : // Resolved before (children a component draws again somewhere else):\n // the first instance owns its props, which are also its key, so the\n // new instance is made from a copy.\n (newWDom.rd\n ? copyResolver(newWDom)\n : ((newWDom.rd = true), newWDom)\n ).resolve()\n : newWDom;\n};\n\n/**\n * 자식 가상돔들도 전부 재귀처리하며 똑같은 처리를 해준다.\n */\nconst remakeChildrenForDiff = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n) =>\n isSameType && originalWDom\n ? remakeChildrenForUpdate(newWDom, originalWDom)\n : remakeChildrenForAdd(newWDom);\n\n/**\n * Recursive handling for the creation of a new virtual DOM. Kept apart from\n * the update below: one function for both made creating 1,000 rows 6% slower.\n */\nconst remakeChildrenForAdd = (newWDom: WDom) => {\n const getParent = makeParentGetter(newWDom);\n\n return (newWDom.children || []).map((item: WDom) => {\n const child = makeNewWDomTree(item);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling for updates, not additions.\n * Uses key-based diffing for loops, index-based for others\n */\nconst remakeChildrenForUpdate = (newWDom: WDom, originalWDom: WDom) => {\n if (newWDom.type === 'l' && checkKeyedChildren(newWDom)) {\n return diffLoopChildren(newWDom, originalWDom);\n }\n\n const origChildren = originalWDom.children || [];\n const getParent = makeParentGetter(newWDom);\n\n return (newWDom.children || []).map((item: WDom, index: number) => {\n const child = makeNewWDomTree(item, origChildren[index]);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling of loop-type virtual DOM elements.\n * Matches children against the originals by key via a Map in O(n) and\n * records each match's original index (oi) for the render phase to\n * minimize moves via LIS. The originals left unmatched are deleted.\n */\nconst diffLoopChildren = (newWDom: WDom, originalWDom: WDom) => {\n const origChildren = originalWDom.children || [];\n const keyMap = new Map<unknown, number>();\n origChildren.forEach((item, index) => {\n const key = getKey(item);\n if (checkExisty(key) && !keyMap.has(key)) {\n keyMap.set(key, index);\n }\n });\n\n const used: boolean[] = [];\n const getParent = makeParentGetter(newWDom);\n const remaked = (newWDom.children || []).map((item, index) => {\n const key = getKey(item);\n // Unkeyed items among keyed ones (a hidden row's null, a nested array)\n // pair with the unkeyed original at the same index, as in React.\n const origIndex = checkExisty(key)\n ? keyMap.get(key)\n : index < origChildren.length && !checkExistyKey(origChildren[index])\n ? index\n : undefined;\n let original: WDom | undefined;\n\n if (origIndex !== undefined) {\n keyMap.delete(key);\n used[origIndex] = true;\n original = origChildren[origIndex];\n }\n\n const child = makeNewWDomTree(item, original);\n if (original) {\n child.oi = origIndex;\n }\n child.getParent = getParent;\n\n return child;\n });\n\n // Originals left unmatched, including ones whose key was already taken\n // (no key, or a duplicate) and so never made it into keyMap.\n typeDeleteUnused(\n origChildren.filter((_item, index) => !used[index]),\n originalWDom\n );\n\n return remaked;\n};\n","import { Props, WDom } from '@/types';\nimport { componentMap } from '@/utils/universalRef';\n\nconst redrawQueue = new Map<Props, () => void>();\nlet redrawQueueTimeout: boolean = false;\n\nconst schedule = (compKey: Props, exec: () => void) => {\n redrawQueue.set(compKey, exec);\n\n if (!redrawQueueTimeout) {\n redrawQueueTimeout = true;\n queueMicrotask(execRedrawQueue);\n }\n};\n\nexport const setRedrawAction = (compKey: Props, exec: () => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => schedule(compKey, exec);\n }\n};\n\n/**\n * Like setRedrawAction, but bound once per component instead of on every\n * render: the node to redraw is the component's current one when renew() is\n * called.\n */\nexport const bindRedraw = (compKey: Props, exec: (wDom: WDom) => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => {\n const wDom = comp.vd.value as WDom;\n schedule(compKey, () => exec(wDom));\n };\n }\n};\n\nexport const componentUpdate = (compKey: Props) => () => {\n const comp = componentMap.get(compKey);\n const up = comp && comp.up;\n if (up) {\n up();\n return true;\n }\n return false;\n};\n\n// Each entry is taken out before it runs, so a renew raised during the flush\n// (a new child's mountCallback renewing its parent) queues it again and this\n// same pass runs it. If a render throws, another microtask drains the rest\n// without requiring a new renew; the original error still propagates.\nconst execRedrawQueue = () => {\n try {\n redrawQueue.forEach((item: () => void, compKey: Props) => {\n redrawQueue.delete(compKey);\n item();\n });\n } finally {\n redrawQueueTimeout = !!redrawQueue.size;\n if (redrawQueueTimeout) queueMicrotask(execRedrawQueue);\n }\n};\n","import type { WDom } from '@/types';\nimport { wdomSymbol } from '@/utils/universalRef';\n\n// Common hot fields share one layout; root/component metadata stays sparse.\nexport const createWDom = (\n type: WDom['type'],\n tag?: WDom['tag'],\n props?: WDom['props'],\n text?: WDom['text'],\n children?: WDom['children'],\n getParent?: WDom['getParent']\n): WDom => ({\n type,\n nr: undefined,\n tag,\n props,\n text,\n children,\n getParent,\n el: undefined,\n oi: undefined,\n oc: undefined,\n op: undefined,\n il: undefined,\n [wdomSymbol]: true,\n});\n","import { getCurrentComponent } from '@/utils/universalRef';\n\nimport { useUpdated } from '@/hook/internal/useUpdate';\n\ntype DependencyFactory = () => unknown[];\n\nexport const updateCallback = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const component = getCurrentComponent();\n if (!component) return;\n\n component.upR.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n const comp = getCurrentComponent();\n const updateReqs = comp && comp.upR;\n\n if (updateReqs && updateReqs.length) {\n updateReqs.forEach(callback => callback());\n }\n};\n","import {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n Props,\n MiddleStateWDomChildren,\n MiddleStateWDom,\n NodePointer,\n Component,\n LComponent,\n} from '@/types';\n\nimport { makeNewWDomTree } from '@/diff';\nimport { wDomUpdate } from '@/render';\nimport {\n initUpdateHookState,\n compKeyRef,\n initMountHookState,\n needDiffRef,\n componentMap,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { bindRedraw, componentUpdate } from '@/utils/redraw';\nimport { createWDom } from '@/utils/createWDom';\nimport { runUpdateCallback } from '@/hook/updateCallback';\nimport {\n checkFragmentFunction,\n checkCustemComponentFunction,\n} from '@/utils/predicator';\n\n// ============================================================================\n// Public API - Highest Level (User-facing API)\n// ============================================================================\n\n/**\n * It allows grouping multiple elements together.\n */\nexport const Fragment = (_props: Props, ...children: WDom[]) =>\n createWDom('f', undefined, undefined, undefined, children);\n\n/**\n * Element creation\n */\nexport const h = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n ...children: MiddleStateWDomChildren\n) => {\n const nodeParentPointer: NodePointer = { value: undefined };\n const newChildren = remakeChildren(nodeParentPointer, children);\n const node = makeNode(tag, props || {}, newChildren);\n\n if (!checkCustemComponentFunction(node)) {\n nodeParentPointer.value = node;\n }\n\n return node;\n};\n\n/**\n * Enables portals\n */\nexport const portal = (wDom: WDom, portal: HTMLElement) =>\n h('portal', { portal }, wDom);\n\n/**\n * It helps with component creation.\n */\nexport const mount =\n <T>(component: Component<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) =>\n component;\n\n/**\n * It helps with component creation without renew parameter.\n * Use useRenew() hook to get renew function if needed.\n */\nexport const lmount =\n <T>(component: LComponent<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) => {\n lmountComponentSet.add(component);\n return component;\n };\n\n/**\n * Maintain compChild references for upward updates (render props, slots, etc.).\n * JSX always returns a fresh children array, so when a subtree re-renders\n * bottom-up we must manually swap the old child instance out of each ancestor's\n * compChild.\n *\n * Fragment-wrapping solved this by keeping a stable wrapper node,\n * but that hides the actual child tree. We prefer this explicit sync for DX.\n *\n * In practice slot consumers rarely thread children more than a layer or two—\n * usually shallow composed pieces like dropdowns or drag-and-drop shells—so the\n * directed walk keeps DX high without introducing observable overhead.\n */\nconst syncAncestorComponentChildren = (\n parent: WDom | undefined,\n prevChild: WDom,\n nextChild: WDom\n) => {\n const walk = (node: WDom | undefined, visited: Set<WDom>): void => {\n if (!node || visited.has(node)) {\n return;\n }\n\n visited.add(node);\n\n if (node.compChild) {\n const childIndex = node.compChild.indexOf(prevChild);\n\n if (childIndex !== -1) {\n node.compChild.splice(childIndex, 1, nextChild);\n }\n }\n\n walk(node.getParent ? node.getParent() : undefined, visited);\n };\n\n walk(parent, new Set<WDom>());\n};\n\n/**\n * It re-renders starting from a specific component.\n */\nexport const replaceWDom = (\n tag: TagFunction,\n props: Props,\n children: WDom[],\n originalWDom: WDom\n) => {\n if (originalWDom.il) {\n return;\n }\n needDiffRef.value = true;\n\n let newWDomTree: WDom;\n try {\n const newWDom = makeWDomResolver(tag, props, children);\n newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n // NOTE: we/ae are short for wrapElement/afterElement\n const { isRoot, getParent, we, ae } = originalWDom;\n\n newWDomTree.getParent = getParent;\n\n if (!isRoot && getParent) {\n const parent = getParent();\n const brothers = (parent && parent.children) || [];\n const index = brothers.indexOf(originalWDom);\n\n if (index !== -1) {\n brothers.splice(index, 1, newWDomTree);\n }\n\n syncAncestorComponentChildren(parent, originalWDom, newWDomTree);\n } else {\n newWDomTree.isRoot = true;\n newWDomTree.we = we;\n newWDomTree.ae = ae;\n }\n } finally {\n needDiffRef.value = false;\n }\n\n wDomUpdate(newWDomTree);\n};\n\n// ============================================================================\n// Mid-Level - Virtual DOM Node Creation (Intermediate abstraction level)\n// ============================================================================\n\n/**\n * The starting point where the virtual DOM is created from the h function.\n */\nconst makeNode = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n children: WDom[]\n) => {\n if (checkFragmentFunction(tag)) {\n return Fragment(props, ...children);\n } else if (checkCustemComponentFunction(tag)) {\n const componetMakeResolver = makeWDomResolver(tag, props, children);\n\n if (needDiffRef.value) {\n return componetMakeResolver;\n }\n\n // Drawn right away, without a diff. Later updates sync the instance's\n // props and children in place, so it gets copies; the node keeps the\n // untouched description to be drawn again elsewhere (cloneWDom).\n const node = copyResolver(componetMakeResolver).resolve();\n node.rs = componetMakeResolver;\n return node;\n }\n\n return createWDom('e', tag, props, undefined, children);\n};\n\n/**\n * The starting point for recursively processing the child virtual DOM elements.\n */\nconst remakeChildren = (\n nodeParentPointer: NodePointer,\n children: MiddleStateWDomChildren\n): WDom[] => {\n // Siblings share a single getParent closure (one allocation per parent)\n const getParent = () => nodeParentPointer.value;\n\n return children.map((item: MiddleStateWDom) => {\n const childItem = makeChildrenItem(item);\n childItem.getParent = getParent;\n return childItem;\n });\n};\n\n/**\n * Recursively process the child virtual DOM elements.\n */\nconst makeChildrenItem = (item: MiddleStateWDom): WDom => {\n if (item === null || item === undefined || typeof item === 'boolean') {\n return createWDom(null);\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = createWDom('l', undefined, undefined, undefined, children);\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return createWDom('t', undefined, undefined, item);\n }\n\n return item;\n};\n\n// ============================================================================\n// Component Lifecycle - Component Creation & Re-rendering\n// ============================================================================\n\n/**\n * Create component resolver function\n */\nconst createComponentResolver = (\n tag: TagFunction,\n props: Props,\n wrappedChildren: WDom[]\n) => {\n return (compKey = props) => {\n // Diff mode sets needDiffRef to true so h()/makeNode return a resolver\n // placeholder. During actual resolution we must force a real WDom tree,\n // otherwise nested components leave only resolvers (no getParent/children)\n // and CSR renders a blank area. Temporarily drop needDiffRef, then restore.\n // Regression tests: src/tests/core-composedRenew.test.tsx,\n // src/tests/core-component-remount.test.tsx\n const prevNeedDiff = needDiffRef.value;\n const previousKey = compKeyRef.value;\n needDiffRef.value = false;\n try {\n initMountHookState(compKey, tag);\n\n const initialComponent = tag(props, wrappedChildren);\n\n let componentMaker: (nextProps: Props) => MiddleStateWDom;\n\n if (typeof initialComponent === 'function') {\n const component = initialComponent;\n // Check if component is created with lmount (no renew parameter)\n // TypeScript cannot infer that component is LComponent when has() returns true,\n // because WeakSet.has() is a runtime check that doesn't narrow types.\n // We use 'as any' since the runtime check guarantees type safety.\n componentMaker = lmountComponentSet.has(component)\n ? (component as any)(props, wrappedChildren)\n : component(componentUpdate(compKey), props, wrappedChildren);\n } else {\n // For components that directly return a VDom, recreate it each render.\n // The first call already rendered this stateless component. Repeating it\n // creates orphan child instances and can register hooks under a child's key.\n let firstRender = true;\n componentMaker = (nextProps: Props) => {\n if (firstRender) {\n firstRender = false;\n return initialComponent as MiddleStateWDom;\n }\n return tag(nextProps, wrappedChildren) as MiddleStateWDom;\n };\n }\n\n return makeCustomNode(\n componentMaker,\n compKey,\n tag,\n props,\n wrappedChildren\n );\n } finally {\n compKeyRef.value = previousKey;\n needDiffRef.value = prevNeedDiff;\n }\n };\n};\n\n/**\n * A fresh copy of a node that is already drawn somewhere: a hoisted constant,\n * children a component renders again in another place, the same node twice.\n * A node holds the state of the place it is drawn in (el, children, parent,\n * component instance), so a second place gets its own copy. A component\n * becomes a resolver for a new instance with its own props and children.\n */\nexport const cloneWDom = (wDom: WDom): WDom | TagFunctionResolver =>\n wDom.ctor\n ? copyResolver(\n wDom.rs || {\n ctor: wDom.ctor,\n props: wDom.compProps as Props,\n children: wDom.compChild as WDom[],\n }\n )\n : createWDom(\n wDom.type,\n wDom.tag,\n wDom.props,\n wDom.text,\n wDom.children && [...wDom.children],\n wDom.getParent\n );\n\nexport const copyResolver = ({\n ctor,\n props,\n children,\n}: Omit<TagFunctionResolver, 'resolve'>) =>\n makeWDomResolver(ctor as TagFunction, { ...props }, [...(children || [])]);\n\n/**\n * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => ({\n ctor: tag,\n props,\n children,\n resolve: createComponentResolver(tag, props, children),\n});\n\n/**\n * Create the actual virtual DOM node from the component.\n */\nconst makeCustomNode = (\n componentMaker: (props: Props) => MiddleStateWDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const wrappedComponentMaker = wrapComponentMaker(componentMaker);\n const customNode = wrappedComponentMaker(props);\n const reRender = makeReRender(\n wrappedComponentMaker,\n compKey,\n tag,\n props,\n children\n );\n\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n bindRedraw(compKey, wDom =>\n replaceWDom(\n tag,\n (wDom.compProps as Props) || props,\n (wDom.compChild as WDom[]) || children,\n wDom\n )\n );\n return customNode;\n};\n\n/**\n * When the virtual DOM is actually created from the component, generate a re-render method for future redraws.\n */\nconst makeReRender = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const reRender = (): WDom => {\n const previousKey = compKeyRef.value;\n try {\n initUpdateHookState(compKey);\n runUpdateCallback();\n\n const customNode = componentMaker(props);\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n\n return customNode;\n } finally {\n compKeyRef.value = previousKey;\n }\n };\n return reRender;\n};\n\n// ============================================================================\n// Low-Level Utilities - Component Node Manipulation\n// ============================================================================\n\n/**\n * Wrap component output in a stable Fragment so component metadata lives on a\n * dedicated node. This prevents parent/child sharing when a component returns\n * another component and keeps updates stable even when output becomes empty.\n */\nconst wrapComponentMaker =\n (componentMaker: (props: Props) => MiddleStateWDom) =>\n (newProps: Props): WDom => {\n const next = makeChildrenItem(componentMaker(newProps));\n const wrapper = Fragment({}, next);\n next.getParent = () => wrapper;\n return wrapper;\n };\n\n/**\n * When creating a custom component node, attach additional information attributes to the virtual DOM object.\n */\nconst addComponentProps = (\n wDom: WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n // Runs on every render of every component: plain assignments, and the\n // redraw action is bound once in makeCustomNode.\n wDom.compProps = props;\n wDom.compChild = children;\n wDom.ctor = tag;\n wDom.compKey = compKey;\n wDom.reRender = reRender;\n\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.vd.value = wDom;\n }\n};\n","export const ref = <T>(initValue: T) => ({ value: initValue });\nexport const nextTick = () => Promise.resolve();\n","import { Renew } from '@/types';\nimport { getComponentKey } from '@/utils/universalRef';\nimport { componentUpdate } from '@/utils/redraw';\n\n/**\n * Hook to get the renew (component update) function.\n * Useful for lmount components that need to trigger updates.\n */\nexport const useRenew = (): Renew => {\n const compKey = getComponentKey();\n\n if (!compKey) {\n return () => false;\n }\n\n return componentUpdate(compKey);\n};\n"],"names":["wdomSymbol","xmlnsRef","compKeyRef","needDiffRef","componentMap","lmountComponentSet","componentMapManualMode","setComponetRef","compKey","ctor","getComponentKey","getCurrentComponent","getComponentSubInfo","subKey","component","initUpdateHookState","initMountHookState","setComponentMapManualMode","enabled","isComponentMapManualMode","runUnmountEffects","subInfo","effect","disposeComponentEntry","getParent","vDom","makeParentGetter","parent","keys","isEnumerableProp","props","key","hasEnumerableProp","prototype","isObject","target","isPropType","obj","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkKeyedChildren","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","wDom","checkPortalElement","el","op","checkEventKey","checkExistyKey","checkExisty","value","checkStyleData","dataKey","dataValue","checkRefData","accessorCache","hasAccessorMethods","proto","byKey","result","descriptor","isPendingCustomElement","getWDomType","checkSameWDomWithOriginal","unmount","effectAction","comp","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","mountedQueue","addMountedQueue","execMountedQueue","runMountedQueueFromWDom","mountCallback","mountQueue","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","insertRoot","wrapElement","element","afterElement","CE","t","render","isHydration","Dom","wDomToDom","compData","rootDelete","deleteRealDom","typeDelete","parentWDom","findRealParentElement","nt","isPortal","findChildWithRemoveElement","items","count","node","typeDeleteUnused","list","parentElement","typeSortedReplace","typeAdd","newElement","parentEl","nextEl","startFindNextBrotherElement","getElementFromFragment","acc","brothers","findChildFragmentNextElement","moving","candidiateBrothers","targetEl","bItem","found","typeReplace","orignalElement","typeUpdate","updateText","oldProps","updateProps","updateChildren","children","wDomUpdate","matchedIndexes","oiSeq","movers","ordered","oi","nr","keep","lis","getLisPositions","pos","i","created","createdCount","baseAnchor","tail","anchor","isNew","needMove","first","clearDiffMeta","seq","tails","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childItem","copy","cloneWDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","runUpdate","infoVdom","infoChidren","copyResolver","remakeChildrenForUpdate","remakeChildrenForAdd","child","diffLoopChildren","origChildren","keyMap","used","remaked","origIndex","original","_item","redrawQueue","redrawQueueTimeout","schedule","exec","execRedrawQueue","bindRedraw","componentUpdate","up","createWDom","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newChildren","remakeChildren","makeNode","portal","mount","_children","lmount","syncAncestorComponentChildren","prevChild","nextChild","walk","visited","childIndex","replaceWDom","makeWDomResolver","isRoot","we","ae","componetMakeResolver","makeChildrenItem","createComponentResolver","wrappedChildren","prevNeedDiff","previousKey","initialComponent","componentMaker","firstRender","nextProps","makeCustomNode","wrappedComponentMaker","wrapComponentMaker","customNode","reRender","makeReRender","addComponentProps","newProps","next","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"aAQa,MAAAA,GAAa,OAAO,IAAI,mBAAmB,EAC3CC,EAA8B,CAAE,MAAO,IACvCC,EAAwC,CAAE,MAAO,MACjDC,EAAkC,CAA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Ref.ts","../src/utils/index.ts","../src/utils/predicator.ts","../src/hook/internal/unmount.ts","../src/hook/mountCallback.ts","../src/hook/mountReadyCallback.ts","../src/hook/internal/useUpdate.ts","../src/render.ts","../src/diff.ts","../src/utils/redraw.ts","../src/utils/createWDom.ts","../src/hook/updateCallback.ts","../src/wDom.ts","../src/hook/ref.ts","../src/hook/useRenew.ts"],"sourcesContent":["import {\n ComponentMap,\n ComponentSubKey,\n CompKey,\n ComponentInfo,\n TagFunction,\n} from '@/types';\n\nexport const wdomSymbol = Symbol.for('lithentWDomSymbol');\nexport const xmlnsRef: { value: string } = { value: '' };\nexport const compKeyRef: { value: CompKey | null } = { value: null };\nexport const needDiffRef: { value: boolean } = { value: false };\nexport const componentMap: ComponentMap = new WeakMap();\nexport const lmountComponentSet: WeakSet<Function> = new WeakSet();\nlet componentMapManualMode = false;\n\nconst setComponetRef = (compKey: CompKey, ctor?: TagFunction): void => {\n componentMap.set(compKey, {\n ctor,\n vd: { value: null },\n up: () => {},\n upR: [],\n upS: { value: 0 },\n upD: [],\n upCB: [],\n mts: [],\n umts: [],\n wdCB: [], // WDom creation callback queue\n });\n};\n\nexport const getComponentKey = (): CompKey | null => compKeyRef.value;\n\n/** The component whose setup or render is running (a WeakMap misses null). */\nexport const getCurrentComponent = () =>\n componentMap.get(compKeyRef.value as CompKey);\n\nexport const getComponentSubInfo = <K extends ComponentSubKey>(\n compKey: CompKey,\n subKey: K\n): ComponentInfo[K] | null => {\n const component = componentMap.get(compKey);\n if (component) {\n return component[subKey];\n }\n return null;\n};\n\nexport const initUpdateHookState = (compKey: CompKey): void => {\n compKeyRef.value = compKey;\n};\n\nexport const initMountHookState = (\n compKey: CompKey,\n ctor?: TagFunction\n): void => {\n compKeyRef.value = compKey;\n setComponetRef(compKey, ctor);\n};\n\nexport const setComponentMapManualMode = (enabled: boolean): void => {\n componentMapManualMode = enabled;\n};\n\nexport const isComponentMapManualMode = (): boolean => componentMapManualMode;\n\nexport const runUnmountEffects = (compKey: CompKey): void => {\n const subInfo = componentMap.get(compKey);\n if (subInfo) {\n subInfo.umts.forEach(effect => effect());\n subInfo.umts = [];\n }\n};\n\nexport const disposeComponentEntry = (compKey: CompKey): void => {\n runUnmountEffects(compKey);\n componentMap.delete(compKey);\n};\n","import { WDom, Props } from '@/types';\n\nimport { wdomSymbol } from '@/utils/universalRef';\n\nexport const getParent = (vDom: WDom) =>\n (vDom.getParent && vDom.getParent()) as WDom;\n\n// A separate scope keeps parent links from retaining a diff's old children.\nexport const makeParentGetter = (parent: WDom) => () => parent;\n\nexport const entries = Object.entries;\nexport const keys = Object.keys;\n\nexport const isEnumerableProp = (props: Props, key: string) =>\n Object.prototype.propertyIsEnumerable.call(props, key);\n\n// DOM props use for...in, including inherited enumerable keys. A hidden own\n// key shadows the same name on the prototype and must not keep an old prop.\nexport const hasEnumerableProp = (props: Props, key: string): boolean => {\n if (isEnumerableProp(props, key)) return true;\n const prototype = Object.getPrototypeOf(props);\n return (\n !Object.prototype.hasOwnProperty.call(props, key) &&\n !!prototype &&\n hasEnumerableProp(prototype, key)\n );\n};\n\nexport const isObject = (target: unknown): target is Record<string, unknown> =>\n typeof target === 'object' && target !== null;\n\nexport const assign = Object.assign;\nexport const isPropType = (obj: unknown): obj is Props => {\n return (\n isObject(obj) &&\n !Array.isArray(obj) &&\n !Object.getOwnPropertySymbols(obj).includes(wdomSymbol)\n );\n};\n","import { Fragment } from '@/wDom';\nimport {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n WDomType,\n} from '@/types';\nimport { isObject } from '@/utils';\n\ntype WDomParam =\n | string\n | WDom\n | TagFunction\n | TagFunctionResolver\n | FragmentFunction;\n\n/**\n * Predicator\n */\n\nconst checkSameCustomComponent = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n 'ctor' in newWDom\n ? newWDom.ctor === (originalWDom && originalWDom.ctor)\n : newWDom === (originalWDom && originalWDom.ctor);\n\n// The checks below are reached through checkSameWDomWithOriginal only: with\n// a plain node of that type (getWDomType) and an original.\nconst checkSameFragment = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === 'f' &&\n // A component's node is a one-child fragment too: never update it in\n // place as a plain fragment, or the component is never unmounted, nor\n // update a plain fragment with one (a hoisted <Comp /> first drawn by a\n // redraw), or it is never mounted.\n !originalWDom.ctor &&\n !newWDom.ctor &&\n !!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length);\n\nconst checkSameTagElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === 'e' &&\n originalWDom.tag === newWDom.tag &&\n !!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length);\n\nconst checkNormalTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === newWDom.type;\n\nconst checkLoopTypeElement = (newWDom: WDom, originalWDom: WDom): boolean =>\n originalWDom.type === newWDom.type &&\n ((checkKeyedChildren(newWDom) && checkKeyedChildren(originalWDom)) ||\n (!!originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)));\n\nexport const getKey = (target: WDom) =>\n (target && target.compProps && target.compProps.key) ??\n (target && target.props && target.props.key);\n\n/**\n * Check if the type is virtual (fragment or loop)\n * Virtual types don't create real DOM elements themselves\n */\nexport const checkVirtualType = (\n type?: string | null // 'f': fragment, 'l': loop\n) => type === 'f' || type === 'l';\n\nexport const checkCustemComponentFunction = (\n target: WDomParam\n): target is TagFunction | TagFunctionResolver =>\n (typeof target === 'function' && !checkFragmentFunction(target)) ||\n (isObject(target) && 'resolve' in target);\n\nexport const checkFragmentFunction = (\n target: unknown\n): target is FragmentFunction => target === Fragment;\n\n// A diffed node (resolved already): empty when it has no type.\nexport const checkEmptyElement = (wDom: WDom) => !wDom.type;\n\n// Whether the node's element is a portal target, which lies outside the\n// parent the portal sits in: a portal's own element, or the one a node\n// replacing or deleting a portal still holds, with that portal's props (op),\n// until it is drawn.\nexport const checkPortalElement = ({ el, op, props }: WDom) =>\n !!el && (el === (op && op.portal) || el === (props && props.portal));\n\nexport const checkEventKey = (key: string) => key[0] === 'o' && key[1] === 'n';\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\n\n// A list is keyed when any child has a key: a leading null or false (a hidden\n// row) must not turn key matching off for the rest.\nexport const checkKeyedChildren = (target?: WDom) =>\n !!target && !!target.children && target.children.some(checkExistyKey);\n\nexport const checkExisty = (value: unknown) =>\n value !== null && value !== undefined;\n\nexport const checkStyleData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is Record<string, string> =>\n dataKey === 'style' && isObject(dataValue);\n\nexport const checkRefData = (\n dataKey: string,\n dataValue: unknown\n): dataValue is {\n value: HTMLElement | Element | DocumentFragment | Text | undefined;\n} => dataKey === 'ref' && isObject(dataValue);\n\n// Descriptor lookups are cached per prototype+key. Keying by prototype\n// rather than nodeName matters for custom elements: one rendered before its\n// definition is upgraded later and gets a new prototype, which must be looked\n// up again instead of reusing the \"no accessor\" answer for its tag name.\nconst accessorCache = new WeakMap<object, Map<string, boolean>>();\n\nexport const hasAccessorMethods = (target: unknown, dataKey: string) => {\n const proto = target!.constructor.prototype;\n let byKey = accessorCache.get(proto);\n if (!byKey) accessorCache.set(proto, (byKey = new Map()));\n let result = byKey.get(dataKey);\n\n if (result === undefined) {\n const descriptor = Object.getOwnPropertyDescriptor(proto, dataKey);\n result = !!(descriptor && descriptor.get && descriptor.set);\n byKey.set(dataKey, result);\n }\n\n return result;\n};\n\n// A custom element tag whose definition has not arrived, or whose instance\n// has not been upgraded yet: still a plain HTMLElement, with no accessors.\nexport const isPendingCustomElement = (target: unknown) =>\n (target as Element).localName.includes('-') &&\n (target as Element).constructor === HTMLElement;\n\n/**\n * Get WDom type as a single character code\n * 'c': component, 'f': fragment, 'e': element, 'l': loop, 't': text, 'et': empty/null\n */\nexport const getWDomType = (\n wDom: WDom | TagFunction | TagFunctionResolver\n): WDomType =>\n checkCustemComponentFunction(wDom)\n ? 'c'\n : ((wDom as WDom).type as WDomType) || 'et';\n\nexport const checkSameWDomWithOriginal = {\n c: checkSameCustomComponent,\n l: checkLoopTypeElement,\n t: checkNormalTypeElement,\n e: checkSameTagElement,\n f: checkSameFragment,\n et: checkNormalTypeElement,\n};\n","import { WDom, CompKey } from '@/types';\nimport { checkEventKey } from '@/utils/predicator';\nimport {\n componentMap,\n getCurrentComponent,\n isComponentMapManualMode,\n runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n const comp = getCurrentComponent();\n comp && comp.umts.push(effectAction);\n};\n\nexport const runUnmountQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n // A redraw queued before this removal still holds the node. Marking it\n // retired makes that stale redraw a no-op instead of drawing it back in.\n newWDom.il = true;\n removeItem(compKey);\n }\n recursiveRunUnmount(newWDom);\n};\n\nconst recursiveRunUnmount = (wDom: WDom) => {\n // A portal host belongs to the caller and survives removal. Release its\n // handlers while leaving listeners on discarded ordinary DOM untouched.\n if (wDom.tag === 'portal' && wDom.el) {\n for (const key in wDom.props) {\n if (checkEventKey(key)) {\n wDom.el.removeEventListener(\n key.slice(2).toLowerCase(),\n wDom.props[key] as EventListener\n );\n }\n }\n }\n (wDom.children || []).forEach(item => {\n const childComKey = item.compKey;\n if (childComKey) {\n runUnmountQueueFromWDom(item);\n } else {\n recursiveRunUnmount(item);\n }\n });\n};\n\nconst removeItem = (compKey: CompKey) => {\n runUnmountEffects(compKey);\n\n if (!isComponentMapManualMode()) {\n componentMap.delete(compKey);\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\nlet mountedQueue: WDom[] = [];\n\n/**\n * WDom을 mountedQueue에 추가\n */\nexport const addMountedQueue = (wDom: WDom) => {\n if (wDom.compKey) {\n mountedQueue.push(wDom);\n }\n};\n\n/**\n * DOM 렌더링 후 mountCallback 실행\n */\nexport const execMountedQueue = () => {\n mountedQueue.forEach(runMountedQueueFromWDom);\n mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n const comp = getCurrentComponent();\n comp && comp.mts.push(effectAction);\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n // Every entry has all its queues (setComponetRef).\n const component = compKey && componentMap.get(compKey);\n\n if (component) {\n const mountQueue = component.mts;\n\n compKeyRef.value = compKey;\n component.upS.value = 0;\n component.mts = [];\n\n mountQueue.forEach((effect: Function) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n const comp = getCurrentComponent();\n comp && comp.wdCB.push(effectAction);\n};\n\n/**\n * 특정 WDom의 wdomCallback 즉시 실행\n * wDomToDom() 내부에서 각 WDom 생성 시점에 호출됨\n */\nexport const runWDomCallbacksFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n const wdCBQueue = component && component.wdCB;\n\n compKeyRef.value = compKey;\n\n if (wdCBQueue && wdCBQueue.length > 0) {\n component.wdCB = [];\n\n wdCBQueue.forEach((effect: Function) => {\n const cleanup = effect();\n if (typeof cleanup === 'function') {\n unmount(cleanup);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getCurrentComponent,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const component = getCurrentComponent();\n if (!component) return;\n\n const { upD, upS } = component;\n const def = upD[upS.value];\n\n const nextDependencies = dependencies();\n\n if (def && checkNeedPushQueue(def, nextDependencies)) {\n const callback = effectAction();\n if (callback) {\n component.upCB.push(callback);\n }\n }\n\n upD[upS.value] = nextDependencies;\n upS.value += 1;\n};\n\nexport const runUpdatedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n // Every entry has all its queues (setComponetRef).\n const component = compKey && componentMap.get(compKey);\n\n if (component) {\n const queue = component.upCB;\n\n compKeyRef.value = compKey;\n component.upS.value = 0;\n\n if (newWDom.ctor) {\n component.upCB = [];\n queue.forEach((effect: Function) => effect());\n }\n }\n};\n\nconst checkNeedPushQueue = (originalDefs: unknown[], newDefs: unknown[]) =>\n !originalDefs.length\n ? true\n : originalDefs.some((def, index) => def !== newDefs[index]);\n","import { WDom, Props } from '@/types';\nimport {\n checkStyleData,\n checkRefData,\n checkExisty,\n checkVirtualType,\n hasAccessorMethods,\n isPendingCustomElement,\n checkEventKey,\n checkPortalElement,\n} from '@/utils/predicator';\n\nimport { componentMap, xmlnsRef } from '@/utils/universalRef';\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { execMountedQueue, addMountedQueue } from '@/hook/mountCallback';\nimport { runWDomCallbacksFromWDom } from '@/hook/mountReadyCallback';\nimport { runUpdatedQueueFromWDom } from '@/hook/internal/useUpdate';\nimport {\n getParent,\n isObject,\n hasEnumerableProp,\n makeParentGetter,\n} from '@/utils';\nimport { cloneWDom } from '@/wDom';\n\nconst DF = () => new DocumentFragment();\n\n// Into the root's wrapper: before its after element, in place of <html>, or\n// at the end.\nconst insertRoot = (\n wrapElement: HTMLElement,\n element: Node,\n afterElement?: HTMLElement | null\n) =>\n afterElement\n ? wrapElement.insertBefore(element, afterElement)\n : wrapElement.tagName === 'HTML'\n ? wrapElement.replaceWith(element)\n : wrapElement.appendChild(element);\nconst CE = (t: string) => document.createElement(t);\n\nexport const render = (\n wDom: WDom,\n wrapElement: HTMLElement | null,\n afterElement?: HTMLElement | null,\n isHydration?: boolean\n) => {\n wDom.isRoot = true;\n wrapElement = wrapElement || document.body;\n wDom.we = wrapElement;\n\n const Dom = wDomToDom(wDom, isHydration);\n\n wDom.ae = afterElement as HTMLElement;\n if (afterElement || !isHydration) {\n insertRoot(wrapElement, Dom, afterElement);\n }\n\n execMountedQueue();\n\n return () => {\n const compData = componentMap.get(wDom.compProps as Props);\n const comp = (compData && compData.vd.value) || wDom;\n runUnmountQueueFromWDom(comp);\n rootDelete(comp);\n };\n};\n\nconst rootDelete = (newWDom: WDom) =>\n deleteRealDom(newWDom, newWDom.we as HTMLElement);\n\nexport const typeDelete = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n deleteRealDom(\n newWDom,\n (newWDom.isRoot\n ? newWDom.we\n : parentWDom && findRealParentElement(parentWDom)) as HTMLElement\n );\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n if (parent && newWDom.el) {\n const nt = newWDom.el.nodeType;\n // A portal's children are in its target, which itself stays.\n const isPortal = checkPortalElement(newWDom);\n if (nt === 11 || isPortal) {\n findChildWithRemoveElement(\n newWDom,\n isPortal ? (newWDom.el as HTMLElement) : parent\n );\n } else if (nt === 1 || nt === 3) {\n parent.removeChild(newWDom.el);\n }\n\n newWDom.el = undefined;\n }\n};\n\nconst findChildWithRemoveElement = (newWDom: WDom, parent: HTMLElement) => {\n const items = newWDom.oc || newWDom.children || [];\n\n // Clear only when these roots, through any Fragment/component wrappers,\n // are exactly the parent's children. Stop at the first mismatch so removing\n // one part of a larger list never walks its remaining siblings.\n if (items.length > 1) {\n let next = parent.firstChild;\n const matches = (item: WDom): boolean => {\n const el = item.el;\n if (!el || checkPortalElement(item)) return !el;\n if (el.nodeType === 11) {\n return (item.oc || item.children || []).every(matches);\n }\n const same = el === next && (el as HTMLElement).tagName !== 'HTML';\n next = el.nextSibling;\n return same;\n };\n\n if (items.every(matches) && !next) {\n parent.textContent = '';\n items.forEach(item => (item.el = undefined));\n return;\n }\n }\n\n items.forEach(item => {\n const nt = item.el && item.el.nodeType;\n if (checkPortalElement(item)) {\n findChildWithRemoveElement(item, item.el as HTMLElement);\n } else if (nt === 1 || nt === 3) {\n const el = item.el as HTMLElement;\n el.tagName === 'HTML' ? (el.innerHTML = '') : el.remove();\n } else if (nt === 11) {\n findChildWithRemoveElement(item, parent);\n }\n });\n};\n\n/**\n * Unmount and remove unused keyed children. Listeners are left on the\n * discarded DOM and go away with it. The parent element is found from the\n * list they were in: a child's own parent link may have been moved on by\n * the same node being drawn in another place since.\n */\nexport const typeDeleteUnused = (items: WDom[], list: WDom) => {\n const parentElement = findRealParentElement(list) as HTMLElement;\n items.forEach(item => {\n runUnmountQueueFromWDom(item);\n deleteRealDom(item, parentElement);\n });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\n\nconst typeAdd = (\n newWDom: WDom,\n newElement?: HTMLElement | DocumentFragment | Text\n) => {\n newElement = newElement || wDomToDom(newWDom);\n\n const parentWDom = getParent(newWDom);\n if (!parentWDom || !parentWDom.type) {\n if (newWDom.isRoot && newWDom.we && newWDom.tag !== 'portal') {\n insertRoot(newWDom.we, newElement, newWDom.ae);\n execMountedQueue();\n }\n return;\n }\n\n const parentEl = findRealParentElement(parentWDom);\n // Children added or moved inside a loop are placed by updateChildren, so\n // anything that reaches here (e.g. a replaced fragment or component in an\n // unkeyed loop) goes right before its own next sibling.\n const nextEl = startFindNextBrotherElement(newWDom, parentWDom);\n\n if (parentEl) {\n if (newWDom.tag !== 'portal') {\n parentEl.insertBefore(newElement, nextEl || null);\n }\n execMountedQueue();\n }\n};\n\nconst getElementFromFragment = (newWDom: WDom) => {\n if (checkVirtualType(newWDom.type)) {\n return (newWDom.children || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n\n // A portal's target does not move with its siblings.\n if (element && !checkPortalElement(item)) {\n acc.appendChild(element);\n }\n return acc;\n }, DF());\n }\n\n return newWDom.el;\n};\n\nconst startFindNextBrotherElement = (\n wDom: WDom,\n parentWDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined => {\n const brothers = parentWDom.children || [];\n\n // After the brothers, a fragment or loop parent goes on with its own next\n // brother, up to the root's after element.\n return (\n findChildFragmentNextElement(brothers.slice(brothers.indexOf(wDom) + 1)) ||\n (checkVirtualType(parentWDom.type)\n ? parentWDom.isRoot\n ? parentWDom.ae\n : startFindNextBrotherElement(parentWDom, getParent(parentWDom))\n : undefined)\n );\n};\n\n// Children of a list being updated that move or are added: until its\n// placement pass they are not where they will be, so they are no anchor for\n// content inserted meanwhile. Kept here rather than as a flag on the node,\n// which would give the nodes that get it another shape.\nconst moving = new Set<WDom>();\n\nconst findChildFragmentNextElement = (\n candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n (targetEl, bItem) => {\n // A portal's target is not in the parent: no anchor there.\n if (\n targetEl ||\n checkPortalElement(bItem) ||\n (moving.size && moving.has(bItem))\n )\n return targetEl;\n const { type, el } = bItem;\n if (type && checkVirtualType(type)) {\n const found = findChildFragmentNextElement(bItem.children || []);\n if (found) return found;\n }\n if (el && el.nodeType !== 11) return el;\n return targetEl;\n },\n undefined\n );\n\nconst typeReplace = (newWDom: WDom) => {\n const parentWDom = getParent(newWDom);\n const orignalElement = newWDom.el;\n\n if (orignalElement && (parentWDom ? parentWDom.type : newWDom.isRoot)) {\n // A portal being replaced, or replacing: one side is drawn in the\n // portal's target, not in the parent, so delete and add instead.\n if (\n !parentWDom ||\n orignalElement.nodeType === 11 ||\n checkPortalElement(newWDom) ||\n newWDom.tag === 'portal'\n ) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement) {\n parentElement.replaceChild(newElement, orignalElement);\n }\n execMountedQueue();\n }\n }\n};\n\nconst typeUpdate = (newWDom: WDom) => {\n if (newWDom.type === 't') {\n updateText(newWDom);\n return;\n }\n\n if (newWDom.el) {\n const { op: oldProps, props } = newWDom;\n updateProps(props, newWDom.el, oldProps);\n\n if (newWDom.tag === 'input') {\n (newWDom.el as HTMLInputElement).value = String(\n (props && props.value) || ''\n );\n }\n }\n\n updateChildren(newWDom);\n runUpdatedQueueFromWDom(newWDom);\n};\n\n/**\n * Process child updates. Loop parents with added/moved children are handled\n * in O(n): a left-to-right content pass (keeps lifecycle order), an LIS over\n * the matched original indices (oi, recorded by the diff phase) to pick the\n * children that can stay in place, and a right-to-left placement pass that\n * inserts only added children and non-LIS moves before a running anchor.\n */\nconst updateChildren = (newWDom: WDom) => {\n const children = newWDom.children || [];\n\n if (\n newWDom.type !== 'l' ||\n !children.some(\n item => 'ATS'.includes(item.nr as string) || item.oi !== undefined\n )\n ) {\n children.forEach(wDomUpdate);\n return;\n }\n\n // The matched children that keep their place: an LIS over their original\n // indexes (oi). Worked out before the content pass, because until the\n // placement pass a child that moves is still where it was, and so is the\n // old element of one replaced (S): neither may be the anchor for content\n // inserted meanwhile (moving), such as a kept row whose fragment changed.\n // An added child needs no such care: it has no element before the content\n // pass reaches it, and anchors are looked for after the child at hand.\n // Read up front: wDomUpdate clears oi on an unkeyed child matched by\n // position.\n const matchedIndexes: number[] = [];\n const oiSeq: number[] = [];\n\n // Replaced children, then the matched ones that move.\n const movers: WDom[] = [];\n let ordered = true;\n\n children.forEach((item, index) => {\n const oi = item.oi;\n const nr = item.nr;\n if (nr === 'S') {\n movers.push(item);\n } else if (nr !== 'A' && oi !== undefined) {\n if (oi < oiSeq[oiSeq.length - 1]) {\n ordered = false;\n }\n matchedIndexes.push(index);\n oiSeq.push(oi);\n }\n });\n\n // keep[i]: whether matched child i stays (unset when not matched).\n // Matched children still in their original order all stay, as in a redraw\n // that moves nothing: no LIS then. Only the children that move or are\n // added are flagged, so a long list's children are usually untouched.\n let keep: boolean[] | undefined;\n if (!ordered) {\n const lis: boolean[] = (keep = []);\n getLisPositions(oiSeq).forEach(pos => (lis[matchedIndexes[pos]] = true));\n matchedIndexes.forEach(\n i => lis[i] || ((lis[i] = false), movers.push(children[i]))\n );\n }\n\n // Content pass (left-to-right, keeps lifecycle order).\n // Added children are created here but inserted in the placement pass.\n const created: (HTMLElement | DocumentFragment | Text | undefined)[] = [];\n let createdCount = 0;\n\n movers.forEach(item => moving.add(item));\n try {\n children.forEach((item, index) => {\n const nr = item.nr;\n\n if (nr === 'A' || nr === 'S') {\n if (nr === 'S') {\n typeDelete(item);\n }\n created[index] = wDomToDom(item);\n createdCount++;\n } else {\n wDomUpdate(item);\n }\n });\n } finally {\n movers.forEach(item => moving.delete(item));\n }\n\n const parentEl = findRealParentElement(newWDom);\n const baseAnchor = newWDom.isRoot\n ? newWDom.ae\n : startFindNextBrotherElement(newWDom, getParent(newWDom));\n\n // Fast-append the trailing run of added children in order\n // (a null anchor makes insertBefore behave as appendChild).\n let tail = children.length;\n while (tail > 0 && created[tail - 1] !== undefined) {\n tail--;\n }\n\n for (let i = tail; i < children.length; i++) {\n const el = created[i];\n\n if (el && parentEl && children[i].tag !== 'portal') {\n parentEl.insertBefore(el, baseAnchor || null);\n }\n }\n\n if (keep || createdCount > children.length - tail) {\n // Placement pass (right-to-left): insert added children and non-LIS\n // moves before a running anchor.\n let anchor =\n findChildFragmentNextElement(children.slice(tail)) || baseAnchor;\n\n for (let i = tail - 1; i >= 0; i--) {\n const item = children[i];\n const isNew = created[i] !== undefined;\n const needMove = !!keep && keep[i] === false;\n\n if ((isNew || needMove) && parentEl && item.tag !== 'portal') {\n const el = isNew ? created[i] : getElementFromFragment(item);\n\n if (el) {\n parentEl.insertBefore(el, anchor || null);\n }\n }\n\n const first = findChildFragmentNextElement([item]);\n if (first) {\n anchor = first;\n }\n }\n }\n\n children.forEach(clearDiffMeta);\n execMountedQueue();\n};\n\n// Assigned, not deleted: `delete` changes the object's shape, which makes\n// every later access to the node slower. nr goes back to 'N' (nothing to\n// do), not undefined: a node that has it is drawn (see makeNewWDomTree).\nconst clearDiffMeta = (item: WDom) => {\n item.oi = item.oc = item.op = undefined;\n item.nr = 'N';\n};\n\n/**\n * Longest increasing subsequence positions (binary search, O(n log n)).\n * Returns the positions in seq that form the LIS.\n */\nconst getLisPositions = (seq: number[]) => {\n // tails[k]: the position ending the smallest-tailed increasing run of\n // length k + 1. A value larger than the last tail just extends it.\n const tails: number[] = [];\n const prev: number[] = [];\n\n seq.forEach((value, i) => {\n let lo = 0;\n let hi = tails.length;\n\n if (hi && seq[tails[hi - 1]] < value) {\n lo = hi;\n } else {\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (seq[tails[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n }\n\n prev[i] = lo ? tails[lo - 1] : -1;\n tails[lo] = i;\n });\n\n let i = tails.length;\n let last = tails[i - 1];\n while (i-- > 0) {\n tails[i] = last;\n last = prev[last];\n }\n\n return tails;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n const { nr: needRerender } = newWDomTree;\n\n if (needRerender && needRerender !== 'N') {\n renderHandlers[needRerender](newWDomTree);\n clearDiffMeta(newWDomTree);\n }\n};\n\nconst renderHandlers = {\n A: typeAdd,\n D: typeDelete,\n R: typeReplace,\n U: typeUpdate,\n S: typeSortedReplace,\n // A keyed item reaches here only as a component redrawing itself: it has\n // not moved, so it is updated in place. Re-inserting its nodes would blur a\n // focused input inside it or reload an iframe. Moves within a list are\n // placed by updateChildren.\n T: typeUpdate,\n} as const;\n\nconst updateText = (newWDom: WDom) => {\n if (newWDom.el) {\n newWDom.el.nodeValue = String(newWDom.text);\n }\n};\n\nconst updateProps = (\n props?: Props,\n element?: HTMLElement | Element | DocumentFragment | Text,\n oldProps?: Props | null\n) => {\n const originalProps = oldProps || {};\n\n for (const dataKey in props) {\n const dataValue: unknown = props[dataKey];\n\n if (dataValue === originalProps[dataKey]) {\n continue;\n }\n\n // An event key starts with \"on\", so it is none of the keys below.\n if (checkEventKey(dataKey)) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\n } else {\n if (dataKey === 'key') {\n // Do nothing\n } else if (dataKey === 'portal' && isObject(dataValue)) {\n // Do nothing\n } else if (dataKey === 'innerHTML' && typeof dataValue === 'string') {\n (element as HTMLElement).innerHTML = dataValue;\n } else if (checkStyleData(dataKey, dataValue)) {\n updateStyle(\n dataValue,\n checkStyleData(dataKey, originalProps.style)\n ? originalProps.style\n : {},\n element\n );\n } else if (checkRefData(dataKey, dataValue)) {\n dataValue.value = element;\n } else if (dataKey) {\n if (dataKey !== 'type' && hasAccessorMethods(element, dataKey)) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n } else {\n setAttr(\n dataKey === 'className' ? 'class' : dataKey,\n element as HTMLElement,\n dataValue as string\n );\n // Keep the real value too: once defined, the element absorbs own\n // properties through its accessors, so an object or `false` is not\n // left as the attribute string (B-3).\n // Only keys HTMLElement lacks: `textContent` or `offsetWidth` would\n // run a DOM setter or throw.\n if (\n isPendingCustomElement(element) &&\n !(dataKey in HTMLElement.prototype)\n ) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] =\n dataValue;\n }\n }\n }\n }\n }\n\n // Props that are gone. The previous props object is left as it was: it may\n // be the caller's own object.\n for (const dataKey in originalProps) {\n if (props && hasEnumerableProp(props, dataKey)) {\n continue;\n }\n\n if (checkEventKey(dataKey)) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n undefined,\n originalProps[dataKey] as (e: Event) => void\n );\n continue;\n }\n\n (element as HTMLElement).removeAttribute(dataKey);\n // A prop that went in as a custom element property is unset there too\n // (B-4). Not upgraded yet: drop the value kept for it (B-3); `delete`\n // never touches an inherited DOM property such as `title`. Upgraded:\n // only through the element's own accessors, never built-in ones such as\n // input.value, where `undefined` would read as \"undefined\".\n if (isPendingCustomElement(element)) {\n delete (element as HTMLElement & Record<string, unknown>)[dataKey];\n } else if (\n (element as Element).localName.includes('-') &&\n hasAccessorMethods(element, dataKey)\n ) {\n (element as HTMLElement & Record<string, unknown>)[dataKey] = undefined;\n }\n }\n};\n\nconst setAttr = (k: string, el: HTMLElement, v: string) =>\n xmlnsRef.value && k !== 'xmlns'\n ? el.setAttributeNS(null, k, v)\n : el.setAttribute(k, v);\n\nconst wDomToDom = (wDom: WDom, isHydration?: boolean): HTMLElement => {\n let element;\n const { type, tag, text, props, children = [] } = wDom;\n const isVirtualType = checkVirtualType(type);\n\n runWDomCallbacksFromWDom(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = String(props && props.xmlns);\n }\n\n if (!isHydration) {\n if (!type || isVirtualType) {\n element = DF();\n } else if (type === 'e' && tag) {\n // element\n if (tag === 'portal' && props && props.portal) {\n element = props.portal as HTMLElement;\n } else {\n element = xmlnsRef.value\n ? document.createElementNS(xmlnsRef.value, tag)\n : CE(tag);\n }\n } else if (type === 't' && checkExisty(text)) {\n // text node\n element = document.createTextNode(String(text));\n } else {\n throw Error('Invalid wDom');\n }\n\n wDom.el = element as HTMLElement;\n } else {\n element = wDom.el;\n }\n\n wDomChildrenToDom(wDom, children, element, isHydration);\n\n updateProps(props, element, null);\n\n addMountedQueue(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = '';\n }\n\n return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\n wDom: WDom,\n children: WDom[],\n parentElement?: HTMLElement | Element | DocumentFragment | Text,\n isHydration?: boolean\n) => {\n // The parent is not attached to the document yet, so children can be\n // appended directly (no intermediate fragment allocation).\n const getParent = makeParentGetter(wDom);\n children.forEach((childItem: WDom, index: number) => {\n // A child already drawn elsewhere (nr 'N': the same node twice, a\n // hoisted constant in several components) is drawn here as its own copy.\n // The children of an added subtree come from a diff, which copied those\n // already (nr 'A'). Drawn, the child gets nr 'N' (see makeNewWDomTree).\n if (childItem.nr === 'N' && !isHydration) {\n const copy = cloneWDom(childItem);\n childItem = children[index] = 'resolve' in copy ? copy.resolve() : copy;\n }\n // h() may have assigned a shared node to a later parent already. The\n // first occurrence needs its actual owner too, not only the copies.\n childItem.getParent = getParent;\n childItem.nr = 'N';\n if (childItem.type) {\n const childElement = wDomToDom(childItem, isHydration);\n if (childItem.tag !== 'portal' && !isHydration && parentElement) {\n parentElement.appendChild(childElement);\n }\n }\n });\n};\n\nconst updateEvent = (\n element: HTMLElement,\n eventKey: string,\n newEventHandler: ((e: Event) => void) | undefined,\n oldEventHandler: (e: Event) => void\n) => {\n const eventName = eventKey.slice(2).toLowerCase();\n\n if (oldEventHandler !== newEventHandler) {\n if (oldEventHandler) {\n element.removeEventListener(eventName, oldEventHandler);\n }\n\n if (newEventHandler) {\n element.addEventListener(eventName, newEventHandler);\n }\n }\n};\n\nconst updateStyle = (\n style: Record<string, string>,\n oldStyle: Record<string, string>,\n element?: HTMLElement | Element | DocumentFragment | Text\n) => {\n const orig = { ...oldStyle };\n if (!(element instanceof HTMLElement)) return;\n\n const styleProxy = element.style as unknown as Record<string, string>;\n\n for (const k in style) {\n styleProxy[k] = style[k];\n delete orig[k];\n }\n\n for (const k in orig) {\n styleProxy[k] = '';\n }\n};\n\nconst findRealParentElement = (\n vDom: WDom\n): HTMLElement | DocumentFragment | Text | undefined =>\n checkVirtualType(vDom.type)\n ? vDom.isRoot\n ? vDom.we\n : findRealParentElement(getParent(vDom) as WDom)\n : (vDom.el as HTMLElement);\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent, makeParentGetter } from '@/utils';\nimport { typeDeleteUnused } from '@/render';\nimport { cloneWDom, copyResolver } from '@/wDom';\nimport {\n checkEmptyElement,\n checkSameWDomWithOriginal,\n getWDomType,\n checkExistyKey,\n checkExisty,\n checkKeyedChildren,\n} from '@/utils/predicator';\n\nimport { runUnmountQueueFromWDom } from '@/hook/internal/unmount';\nimport { keys, isEnumerableProp } from '@/utils';\n\n/**\n * The starting point of the diffing process between the original virtual DOM and the new virtual DOM for re-rendering.\n */\nexport const makeNewWDomTree = (\n newWDom: WDom | TagFunctionResolver,\n originalWDom?: WDom\n) => {\n // Already drawn or taken by a diff (it has nr, 'N' once drawn): the node\n // belongs to another place, so this place draws a copy. The same node in the same place is still left\n // alone as unchanged. A component made without a diff and not drawn yet\n // (in a new component's output, or a hoisted <Comp />) is drawn as it is:\n // a copy would be a second instance, leaving the one already set up behind.\n if (newWDom !== originalWDom && (newWDom as WDom).nr) {\n newWDom = cloneWDom(newWDom as WDom);\n }\n\n return remakeNewWDom(\n newWDom,\n !!originalWDom &&\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\n );\n};\n\n/**\n * Create a new virtual DOM after comparing with the previous virtual DOM\n */\nconst remakeNewWDom = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n) => {\n const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n const needRerender = addReRenderTypeProperty(\n remakeWDom,\n isSameType,\n originalWDom\n );\n const isNoting = needRerender === 'N';\n\n if (!isNoting) {\n remakeWDom.children = remakeChildrenForDiff(\n remakeWDom,\n isSameType,\n originalWDom\n );\n }\n\n // NOTE: short-key metadata (nr = needRerender) keeps bundle size down\n remakeWDom.nr = needRerender;\n inheritPropForRender(remakeWDom, originalWDom, needRerender);\n\n // A retired node keeps its children: it may be a hoisted constant the\n // caller draws again later, which is then copied from them. A component's\n // node is copied from its description instead (cloneWDom), so it lets go\n // of its previous output: otherwise every row a list redraws keeps its old\n // subtree reachable, for the GC to copy, until the whole redraw is done.\n if (!isNoting && originalWDom) {\n originalWDom.il = true;\n if (originalWDom.ctor) {\n originalWDom.children = undefined;\n }\n }\n return remakeWDom;\n};\n\n/**\n * Handle what the new virtual DOM should inherit or reconcile from the original virtual DOM.\n */\nconst inheritPropForRender = (\n remakeWDom: WDom,\n originalWDom?: WDom,\n needRerender?: RenderType\n) => {\n if (needRerender !== 'A' && originalWDom) {\n remakeWDom.el = originalWDom.el;\n }\n\n if (needRerender === 'D' || needRerender === 'R' || needRerender === 'S') {\n if (originalWDom) {\n runUnmountQueueFromWDom(originalWDom);\n }\n remakeWDom.oc = originalWDom && originalWDom.children;\n }\n\n remakeWDom.op = originalWDom && originalWDom.props;\n};\n\n/**\n * Determine the render operation type (Add/Delete/Replace/Update/etc)\n * based on comparison between new and original WDom\n */\nconst addReRenderTypeProperty = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n): RenderType | undefined => {\n if (checkEmptyElement(newWDom)) return 'D';\n\n if (\n newWDom === originalWDom ||\n (isSameType &&\n newWDom.type === 't' &&\n newWDom.text === (originalWDom as WDom).text)\n ) {\n return 'N';\n }\n if (!(originalWDom && originalWDom.type)) return 'A';\n\n const parent = getParent(originalWDom);\n const isKeyChecked =\n !newWDom.isRoot && parent && parent.type === 'l' && checkExistyKey(newWDom);\n\n return isSameType ? (isKeyChecked ? 'T' : 'U') : isKeyChecked ? 'S' : 'R';\n};\n\n/**\n * Handling virtual DOM attribute updates.\n */\nconst syncResolverProps = (props: Props, infoProps: Props) => {\n if (props && infoProps !== props) {\n // Only the keys that are gone: deleting and re-adding every key on every\n // render changes the object's shape each time.\n infoProps = infoProps || {};\n keys(props).forEach(\n key => isEnumerableProp(infoProps, key) || delete props[key]\n );\n keys(infoProps).forEach(key => (props[key] = infoProps[key]));\n }\n};\n\n/**\n * Keep the existing component node while injecting the props/children from the freshly computed TagFunctionResolver.\n * originalWDom is the fully evaluated node from the previous render, whereas infoVdom is the intermediate resolver,\n * so updating compProps/compChild in place lets reRender() evaluate with the latest slots and props.\n * It is crucial that props and children references remain stable as nodes update—many ancestors/closures share these arrays,\n * so mutate the existing arrays instead of replacing their references.\n */\nconst runUpdate = (vDom: WDom, infoVdom: TagFunctionResolver) => {\n const { compProps: props, compChild: children } = vDom;\n const { props: infoProps, children: infoChidren } = infoVdom;\n\n if (props) {\n syncResolverProps(props, infoProps);\n }\n\n /**\n * In runUpdate, the original DOM (vDom) is already fully evaluated and completed, whereas infoVdom represents an intermediate state. Therefore, vdom.compChild and infoVdom.children are indeed the correct counterparts to compare.\n\n * Keep shared child array references intact (<= same slot array instance)\n * When the reference changes, sync the stored compChild contents so reRender sees fresh nodes\n * Only update children if they're different references\n * If it's the same Fragment reference, the diff process will handle updating its children\n */\n if (children && infoChidren && children !== infoChidren) {\n children.splice(0, children.length, ...infoChidren);\n }\n\n return (vDom.reRender && vDom.reRender()) as WDom;\n};\n\n/**\n * Replace the compared virtual DOM with the new virtual DOM or simply update it.\n */\nconst generalize = (\n newWDom: WDom | TagFunctionResolver,\n isSameType: boolean,\n originalWDom?: WDom\n): WDom => {\n return checkCustemComponentFunction(newWDom)\n ? isSameType && originalWDom\n ? runUpdate(originalWDom, newWDom)\n : // Resolved before (children a component draws again somewhere else):\n // the first instance owns its props, which are also its key, so the\n // new instance is made from a copy.\n (newWDom.rd\n ? copyResolver(newWDom)\n : ((newWDom.rd = true), newWDom)\n ).resolve()\n : newWDom;\n};\n\n/**\n * 자식 가상돔들도 전부 재귀처리하며 똑같은 처리를 해준다.\n */\nconst remakeChildrenForDiff = (\n newWDom: WDom,\n isSameType: boolean,\n originalWDom?: WDom\n) =>\n isSameType && originalWDom\n ? remakeChildrenForUpdate(newWDom, originalWDom)\n : remakeChildrenForAdd(newWDom);\n\n/**\n * Recursive handling for the creation of a new virtual DOM. Kept apart from\n * the update below: one function for both made creating 1,000 rows 6% slower.\n */\nconst remakeChildrenForAdd = (newWDom: WDom) => {\n const getParent = makeParentGetter(newWDom);\n\n return (newWDom.children || []).map((item: WDom) => {\n const child = makeNewWDomTree(item);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling for updates, not additions.\n * Uses key-based diffing for loops, index-based for others\n */\nconst remakeChildrenForUpdate = (newWDom: WDom, originalWDom: WDom) => {\n if (newWDom.type === 'l' && checkKeyedChildren(newWDom)) {\n return diffLoopChildren(newWDom, originalWDom);\n }\n\n const origChildren = originalWDom.children || [];\n const getParent = makeParentGetter(newWDom);\n\n return (newWDom.children || []).map((item: WDom, index: number) => {\n const child = makeNewWDomTree(item, origChildren[index]);\n child.getParent = getParent;\n return child;\n });\n};\n\n/**\n * Recursive handling of loop-type virtual DOM elements.\n * Matches children against the originals by key via a Map in O(n) and\n * records each match's original index (oi) for the render phase to\n * minimize moves via LIS. The originals left unmatched are deleted.\n */\nconst diffLoopChildren = (newWDom: WDom, originalWDom: WDom) => {\n const origChildren = originalWDom.children || [];\n const keyMap = new Map<unknown, number>();\n origChildren.forEach((item, index) => {\n const key = getKey(item);\n if (checkExisty(key) && !keyMap.has(key)) {\n keyMap.set(key, index);\n }\n });\n\n const used: boolean[] = [];\n const getParent = makeParentGetter(newWDom);\n const remaked = (newWDom.children || []).map((item, index) => {\n const key = getKey(item);\n // Unkeyed items among keyed ones (a hidden row's null, a nested array)\n // pair with the unkeyed original at the same index, as in React.\n const origIndex = checkExisty(key)\n ? keyMap.get(key)\n : index < origChildren.length && !checkExistyKey(origChildren[index])\n ? index\n : undefined;\n let original: WDom | undefined;\n\n if (origIndex !== undefined) {\n keyMap.delete(key);\n used[origIndex] = true;\n original = origChildren[origIndex];\n }\n\n const child = makeNewWDomTree(item, original);\n if (original) {\n child.oi = origIndex;\n }\n child.getParent = getParent;\n\n return child;\n });\n\n // Originals left unmatched, including ones whose key was already taken\n // (no key, or a duplicate) and so never made it into keyMap.\n typeDeleteUnused(\n origChildren.filter((_item, index) => !used[index]),\n originalWDom\n );\n\n return remaked;\n};\n","import { Props, WDom } from '@/types';\nimport { componentMap } from '@/utils/universalRef';\n\nconst redrawQueue = new Map<Props, () => void>();\nlet redrawQueueTimeout: boolean = false;\n\nconst schedule = (compKey: Props, exec: () => void) => {\n redrawQueue.set(compKey, exec);\n\n if (!redrawQueueTimeout) {\n redrawQueueTimeout = true;\n queueMicrotask(execRedrawQueue);\n }\n};\n\nexport const setRedrawAction = (compKey: Props, exec: () => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => schedule(compKey, exec);\n }\n};\n\n/**\n * Like setRedrawAction, but bound once per component instead of on every\n * render: the node to redraw is the component's current one when renew() is\n * called.\n */\nexport const bindRedraw = (compKey: Props, exec: (wDom: WDom) => void) => {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.up = () => {\n const wDom = comp.vd.value as WDom;\n schedule(compKey, () => exec(wDom));\n };\n }\n};\n\nexport const componentUpdate = (compKey: Props) => () => {\n const comp = componentMap.get(compKey);\n const up = comp && comp.up;\n if (up) {\n up();\n return true;\n }\n return false;\n};\n\n// Each entry is taken out before it runs, so a renew raised during the flush\n// (a new child's mountCallback renewing its parent) queues it again and this\n// same pass runs it. If a render throws, another microtask drains the rest\n// without requiring a new renew; the original error still propagates.\nconst execRedrawQueue = () => {\n try {\n redrawQueue.forEach((item: () => void, compKey: Props) => {\n redrawQueue.delete(compKey);\n item();\n });\n } finally {\n redrawQueueTimeout = !!redrawQueue.size;\n if (redrawQueueTimeout) queueMicrotask(execRedrawQueue);\n }\n};\n","import type { WDom } from '@/types';\nimport { wdomSymbol } from '@/utils/universalRef';\n\n// Common hot fields share one layout; root/component metadata stays sparse.\nexport const createWDom = (\n type: WDom['type'],\n tag?: WDom['tag'],\n props?: WDom['props'],\n text?: WDom['text'],\n children?: WDom['children'],\n getParent?: WDom['getParent']\n): WDom => ({\n type,\n nr: undefined,\n tag,\n props,\n text,\n children,\n getParent,\n el: undefined,\n oi: undefined,\n oc: undefined,\n op: undefined,\n il: undefined,\n [wdomSymbol]: true,\n});\n","import { getCurrentComponent } from '@/utils/universalRef';\n\nimport { useUpdated } from '@/hook/internal/useUpdate';\n\ntype DependencyFactory = () => unknown[];\n\nexport const updateCallback = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const component = getCurrentComponent();\n if (!component) return;\n\n component.upR.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n const comp = getCurrentComponent();\n const updateReqs = comp && comp.upR;\n\n if (updateReqs && updateReqs.length) {\n updateReqs.forEach(callback => callback());\n }\n};\n","import {\n WDom,\n TagFunction,\n TagFunctionResolver,\n FragmentFunction,\n Props,\n MiddleStateWDomChildren,\n MiddleStateWDom,\n NodePointer,\n Component,\n LComponent,\n} from '@/types';\n\nimport { makeNewWDomTree } from '@/diff';\nimport { wDomUpdate } from '@/render';\nimport {\n initUpdateHookState,\n compKeyRef,\n initMountHookState,\n needDiffRef,\n componentMap,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { bindRedraw, componentUpdate } from '@/utils/redraw';\nimport { createWDom } from '@/utils/createWDom';\nimport { runUpdateCallback } from '@/hook/updateCallback';\nimport {\n checkFragmentFunction,\n checkCustemComponentFunction,\n} from '@/utils/predicator';\n\n// ============================================================================\n// Public API - Highest Level (User-facing API)\n// ============================================================================\n\n/**\n * It allows grouping multiple elements together.\n */\nexport const Fragment = (_props: Props, ...children: WDom[]) =>\n createWDom('f', undefined, undefined, undefined, children);\n\n/**\n * Element creation\n */\nexport const h = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n ...children: MiddleStateWDomChildren\n) => {\n const nodeParentPointer: NodePointer = { value: undefined };\n const newChildren = remakeChildren(nodeParentPointer, children);\n const node = makeNode(tag, props || {}, newChildren);\n\n if (!checkCustemComponentFunction(node)) {\n nodeParentPointer.value = node;\n }\n\n return node;\n};\n\n/**\n * Enables portals\n */\nexport const portal = (wDom: WDom, portal: HTMLElement) =>\n h('portal', { portal }, wDom);\n\n/**\n * It helps with component creation.\n */\nexport const mount =\n <T>(component: Component<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) =>\n component;\n\n/**\n * It helps with component creation without renew parameter.\n * Use useRenew() hook to get renew function if needed.\n */\nexport const lmount =\n <T>(component: LComponent<T>) =>\n (_props: T, _children?: MiddleStateWDomChildren) => {\n lmountComponentSet.add(component);\n return component;\n };\n\n/**\n * Maintain compChild references for upward updates (render props, slots, etc.).\n * JSX always returns a fresh children array, so when a subtree re-renders\n * bottom-up we must manually swap the old child instance out of each ancestor's\n * compChild.\n *\n * Fragment-wrapping solved this by keeping a stable wrapper node,\n * but that hides the actual child tree. We prefer this explicit sync for DX.\n *\n * In practice slot consumers rarely thread children more than a layer or two—\n * usually shallow composed pieces like dropdowns or drag-and-drop shells—so the\n * directed walk keeps DX high without introducing observable overhead.\n */\nconst syncAncestorComponentChildren = (\n parent: WDom | undefined,\n prevChild: WDom,\n nextChild: WDom\n) => {\n const walk = (node: WDom | undefined, visited: Set<WDom>): void => {\n if (!node || visited.has(node)) {\n return;\n }\n\n visited.add(node);\n\n if (node.compChild) {\n const childIndex = node.compChild.indexOf(prevChild);\n\n if (childIndex !== -1) {\n node.compChild.splice(childIndex, 1, nextChild);\n }\n }\n\n walk(node.getParent ? node.getParent() : undefined, visited);\n };\n\n walk(parent, new Set<WDom>());\n};\n\n/**\n * It re-renders starting from a specific component.\n */\nexport const replaceWDom = (\n tag: TagFunction,\n props: Props,\n children: WDom[],\n originalWDom: WDom\n) => {\n if (originalWDom.il) {\n return;\n }\n needDiffRef.value = true;\n\n let newWDomTree: WDom;\n try {\n const newWDom = makeWDomResolver(tag, props, children);\n newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n // NOTE: we/ae are short for wrapElement/afterElement\n const { isRoot, getParent, we, ae } = originalWDom;\n\n newWDomTree.getParent = getParent;\n\n if (!isRoot && getParent) {\n const parent = getParent();\n const brothers = (parent && parent.children) || [];\n const index = brothers.indexOf(originalWDom);\n\n if (index !== -1) {\n brothers.splice(index, 1, newWDomTree);\n }\n\n syncAncestorComponentChildren(parent, originalWDom, newWDomTree);\n } else {\n newWDomTree.isRoot = true;\n newWDomTree.we = we;\n newWDomTree.ae = ae;\n }\n } finally {\n needDiffRef.value = false;\n }\n\n wDomUpdate(newWDomTree);\n};\n\n// ============================================================================\n// Mid-Level - Virtual DOM Node Creation (Intermediate abstraction level)\n// ============================================================================\n\n/**\n * The starting point where the virtual DOM is created from the h function.\n */\nconst makeNode = (\n tag: TagFunction | FragmentFunction | string,\n props: Props,\n children: WDom[]\n) => {\n if (checkFragmentFunction(tag)) {\n return Fragment(props, ...children);\n } else if (checkCustemComponentFunction(tag)) {\n const componetMakeResolver = makeWDomResolver(tag, props, children);\n\n if (needDiffRef.value) {\n return componetMakeResolver;\n }\n\n // Drawn right away, without a diff. Later updates sync the instance's\n // props and children in place, so it gets copies; the node keeps the\n // untouched description to be drawn again elsewhere (cloneWDom).\n const node = copyResolver(componetMakeResolver).resolve();\n node.rs = componetMakeResolver;\n return node;\n }\n\n return createWDom('e', tag, props, undefined, children);\n};\n\n/**\n * The starting point for recursively processing the child virtual DOM elements.\n */\nconst remakeChildren = (\n nodeParentPointer: NodePointer,\n children: MiddleStateWDomChildren\n): WDom[] => {\n // Siblings share a single getParent closure (one allocation per parent)\n const getParent = () => nodeParentPointer.value;\n\n return children.map((item: MiddleStateWDom) => {\n const childItem = makeChildrenItem(item);\n childItem.getParent = getParent;\n return childItem;\n });\n};\n\n/**\n * Recursively process the child virtual DOM elements.\n */\nconst makeChildrenItem = (item: MiddleStateWDom): WDom => {\n if (item === null || item === undefined || typeof item === 'boolean') {\n return createWDom(null);\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = createWDom('l', undefined, undefined, undefined, children);\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return createWDom('t', undefined, undefined, item);\n }\n\n return item;\n};\n\n// ============================================================================\n// Component Lifecycle - Component Creation & Re-rendering\n// ============================================================================\n\n/**\n * Create component resolver function\n */\nconst createComponentResolver = (\n tag: TagFunction,\n props: Props,\n wrappedChildren: WDom[]\n) => {\n return (compKey = props) => {\n // Diff mode sets needDiffRef to true so h()/makeNode return a resolver\n // placeholder. During actual resolution we must force a real WDom tree,\n // otherwise nested components leave only resolvers (no getParent/children)\n // and CSR renders a blank area. Temporarily drop needDiffRef, then restore.\n // Regression tests: src/tests/core-composedRenew.test.tsx,\n // src/tests/core-component-remount.test.tsx\n const prevNeedDiff = needDiffRef.value;\n const previousKey = compKeyRef.value;\n needDiffRef.value = false;\n try {\n initMountHookState(compKey, tag);\n\n const initialComponent = tag(props, wrappedChildren);\n\n let componentMaker: (nextProps: Props) => MiddleStateWDom;\n\n if (typeof initialComponent === 'function') {\n const component = initialComponent;\n // Check if component is created with lmount (no renew parameter)\n // TypeScript cannot infer that component is LComponent when has() returns true,\n // because WeakSet.has() is a runtime check that doesn't narrow types.\n // We use 'as any' since the runtime check guarantees type safety.\n componentMaker = lmountComponentSet.has(component)\n ? (component as any)(props, wrappedChildren)\n : component(componentUpdate(compKey), props, wrappedChildren);\n } else {\n // For components that directly return a VDom, recreate it each render.\n // The first call already rendered this stateless component. Repeating it\n // creates orphan child instances and can register hooks under a child's key.\n let firstRender = true;\n componentMaker = (nextProps: Props) => {\n if (firstRender) {\n firstRender = false;\n return initialComponent as MiddleStateWDom;\n }\n return tag(nextProps, wrappedChildren) as MiddleStateWDom;\n };\n }\n\n return makeCustomNode(\n componentMaker,\n compKey,\n tag,\n props,\n wrappedChildren\n );\n } finally {\n compKeyRef.value = previousKey;\n needDiffRef.value = prevNeedDiff;\n }\n };\n};\n\n/**\n * A fresh copy of a node that is already drawn somewhere: a hoisted constant,\n * children a component renders again in another place, the same node twice.\n * A node holds the state of the place it is drawn in (el, children, parent,\n * component instance), so a second place gets its own copy. A component\n * becomes a resolver for a new instance with its own props and children.\n */\nexport const cloneWDom = (wDom: WDom): WDom | TagFunctionResolver =>\n wDom.ctor\n ? copyResolver(\n wDom.rs || {\n ctor: wDom.ctor,\n props: wDom.compProps as Props,\n children: wDom.compChild as WDom[],\n }\n )\n : createWDom(\n wDom.type,\n wDom.tag,\n wDom.props,\n wDom.text,\n wDom.children && [...wDom.children],\n wDom.getParent\n );\n\nexport const copyResolver = ({\n ctor,\n props,\n children,\n}: Omit<TagFunctionResolver, 'resolve'>) =>\n makeWDomResolver(ctor as TagFunction, { ...props }, [...(children || [])]);\n\n/**\n * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => ({\n ctor: tag,\n props,\n children,\n resolve: createComponentResolver(tag, props, children),\n});\n\n/**\n * Create the actual virtual DOM node from the component.\n */\nconst makeCustomNode = (\n componentMaker: (props: Props) => MiddleStateWDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const wrappedComponentMaker = wrapComponentMaker(componentMaker);\n const customNode = wrappedComponentMaker(props);\n const reRender = makeReRender(\n wrappedComponentMaker,\n compKey,\n tag,\n props,\n children\n );\n\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n bindRedraw(compKey, wDom =>\n replaceWDom(\n tag,\n (wDom.compProps as Props) || props,\n (wDom.compChild as WDom[]) || children,\n wDom\n )\n );\n return customNode;\n};\n\n/**\n * When the virtual DOM is actually created from the component, generate a re-render method for future redraws.\n */\nconst makeReRender = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[]\n) => {\n const reRender = (): WDom => {\n const previousKey = compKeyRef.value;\n try {\n initUpdateHookState(compKey);\n runUpdateCallback();\n\n const customNode = componentMaker(props);\n addComponentProps(customNode, compKey, tag, props, children, reRender);\n\n return customNode;\n } finally {\n compKeyRef.value = previousKey;\n }\n };\n return reRender;\n};\n\n// ============================================================================\n// Low-Level Utilities - Component Node Manipulation\n// ============================================================================\n\n/**\n * Wrap component output in a stable Fragment so component metadata lives on a\n * dedicated node. This prevents parent/child sharing when a component returns\n * another component and keeps updates stable even when output becomes empty.\n */\nconst wrapComponentMaker =\n (componentMaker: (props: Props) => MiddleStateWDom) =>\n (newProps: Props): WDom => {\n const next = makeChildrenItem(componentMaker(newProps));\n const wrapper = Fragment({}, next);\n next.getParent = () => wrapper;\n return wrapper;\n };\n\n/**\n * When creating a custom component node, attach additional information attributes to the virtual DOM object.\n */\nconst addComponentProps = (\n wDom: WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\n // Runs on every render of every component: plain assignments, and the\n // redraw action is bound once in makeCustomNode.\n wDom.compProps = props;\n wDom.compChild = children;\n wDom.ctor = tag;\n wDom.compKey = compKey;\n wDom.reRender = reRender;\n\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.vd.value = wDom;\n }\n};\n","export const ref = <T>(initValue: T) => ({ value: initValue });\nexport const nextTick = () => Promise.resolve();\n","import { Renew } from '@/types';\nimport { getComponentKey } from '@/utils/universalRef';\nimport { componentUpdate } from '@/utils/redraw';\n\n/**\n * Hook to get the renew (component update) function.\n * Useful for lmount components that need to trigger updates.\n */\nexport const useRenew = (): Renew => {\n const compKey = getComponentKey();\n\n if (!compKey) {\n return () => false;\n }\n\n return componentUpdate(compKey);\n};\n"],"names":["wdomSymbol","xmlnsRef","compKeyRef","needDiffRef","componentMap","lmountComponentSet","componentMapManualMode","setComponetRef","compKey","ctor","getComponentKey","getCurrentComponent","getComponentSubInfo","subKey","component","initUpdateHookState","initMountHookState","setComponentMapManualMode","enabled","isComponentMapManualMode","runUnmountEffects","subInfo","effect","disposeComponentEntry","getParent","vDom","makeParentGetter","parent","keys","isEnumerableProp","props","key","hasEnumerableProp","prototype","isObject","target","isPropType","obj","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkKeyedChildren","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","wDom","checkPortalElement","el","op","checkEventKey","checkExistyKey","checkExisty","value","checkStyleData","dataKey","dataValue","checkRefData","accessorCache","hasAccessorMethods","proto","byKey","result","descriptor","isPendingCustomElement","getWDomType","checkSameWDomWithOriginal","unmount","effectAction","comp","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","mountedQueue","addMountedQueue","execMountedQueue","runMountedQueueFromWDom","mountCallback","mountQueue","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","insertRoot","wrapElement","element","afterElement","CE","t","render","isHydration","Dom","wDomToDom","compData","rootDelete","deleteRealDom","typeDelete","parentWDom","findRealParentElement","nt","isPortal","findChildWithRemoveElement","items","next","matches","same","typeDeleteUnused","list","parentElement","typeSortedReplace","typeAdd","newElement","parentEl","nextEl","startFindNextBrotherElement","getElementFromFragment","acc","brothers","findChildFragmentNextElement","moving","candidiateBrothers","targetEl","bItem","found","typeReplace","orignalElement","typeUpdate","updateText","oldProps","updateProps","updateChildren","children","wDomUpdate","matchedIndexes","oiSeq","movers","ordered","oi","nr","keep","lis","getLisPositions","pos","i","created","createdCount","baseAnchor","tail","anchor","isNew","needMove","first","clearDiffMeta","seq","tails","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childItem","copy","cloneWDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","runUpdate","infoVdom","infoChidren","copyResolver","remakeChildrenForUpdate","remakeChildrenForAdd","child","diffLoopChildren","origChildren","keyMap","used","remaked","origIndex","original","_item","redrawQueue","redrawQueueTimeout","schedule","exec","execRedrawQueue","bindRedraw","componentUpdate","up","createWDom","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newChildren","remakeChildren","node","makeNode","portal","mount","_children","lmount","syncAncestorComponentChildren","prevChild","nextChild","walk","visited","childIndex","replaceWDom","makeWDomResolver","isRoot","we","ae","componetMakeResolver","makeChildrenItem","createComponentResolver","wrappedChildren","prevNeedDiff","previousKey","initialComponent","componentMaker","firstRender","nextProps","makeCustomNode","wrappedComponentMaker","wrapComponentMaker","customNode","reRender","makeReRender","addComponentProps","newProps","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"aAQa,MAAAA,GAAa,OAAO,IAAI,mBAAmB,EAC3CC,EAA8B,CAAE,MAAO,IACvCC,EAAwC,CAAE,MAAO,MACjDC,EAAkC,CAAE,MAAO,IAC3CC,MAAiC,QACjCC,MAA4C,QACzD,IAAIC,GAAyB,GAE7B,MAAMC,GAAiB,CAACC,EAAkBC,IAA6B,CACrEL,EAAa,IAAII,EAAS,CACxB,KAAAC,EACA,GAAI,CAAE,MAAO,IAAK,EAClB,GAAI,IAAM,CAAC,EACX,IAAK,CAAC,EACN,IAAK,CAAE,MAAO,CAAE,EAChB,IAAK,CAAC,EACN,KAAM,CAAC,EACP,IAAK,CAAC,EACN,KAAM,CAAC,EACP,KAAM,CAAC,CAAA,CACR,CACH,EAEaC,GAAkB,IAAsBR,EAAW,MAGnDS,EAAsB,IACjCP,EAAa,IAAIF,EAAW,KAAgB,EAEjCU,GAAsB,CACjCJ,EACAK,IAC4B,CACtB,MAAAC,EAAYV,EAAa,IAAII,CAAO,EAC1C,OAAIM,EACKA,EAAUD,CAAM,EAElB,IACT,EAEaE,GAAuBP,GAA2B,CAC7DN,EAAW,MAAQM,CACrB,EAEaQ,GAAqB,CAChCR,EACAC,IACS,CACTP,EAAW,MAAQM,EACnBD,GAAeC,EAASC,CAAI,CAC9B,EAEaQ,GAA6BC,GAA2B,CAC1CZ,GAAAY,CAC3B,EAEaC,GAA2B,IAAeb,GAE1Cc,GAAqBZ,GAA2B,CACrD,MAAAa,EAAUjB,EAAa,IAAII,CAAO,EACpCa,IACFA,EAAQ,KAAK,QAAkBC,GAAAA,EAAQ,CAAA,EACvCD,EAAQ,KAAO,GAEnB,EAEaE,GAAyBf,GAA2B,CAC/DY,GAAkBZ,CAAO,EACzBJ,EAAa,OAAOI,CAAO,CAC7B,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