lithent 1.25.1 → 1.25.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/lithent-agent-addon.md +1 -1
- package/dist/lithent.cjs +1 -1
- package/dist/lithent.cjs.map +1 -1
- package/dist/lithent.mjs +429 -426
- package/dist/lithent.mjs.map +1 -1
- package/dist/lithent.umd.js +1 -1
- package/dist/lithent.umd.js.map +1 -1
- package/dist/render.d.cts +4 -2
- package/dist/render.d.ts +4 -2
- package/dist/skills/lithent/SKILL.md +2 -2
- package/dist/skills/lithent/constraints/mistakes.md +1 -1
- package/dist/skills/lithent/constraints/rules.md +1 -1
- package/dist/skills/lithent/constraints/troubleshooting.md +1 -1
- package/dist/skills/lithent/examples/quick-examples.md +1 -1
- package/dist/skills/lithent/reference/children-type.md +1 -1
- package/dist/skills/lithent/reference/concurrent.md +1 -1
- package/dist/skills/lithent/reference/element.md +1 -1
- package/dist/skills/lithent/reference/lstore-inference.md +1 -1
- package/dist/skills/lithent/reference/props-types.md +1 -1
- package/dist/types/index.d.cts +3 -1
- package/dist/types/index.d.ts +3 -1
- package/dist/utils/predicator.d.cts +8 -6
- package/dist/utils/predicator.d.ts +8 -6
- package/dist/utils/universalRef.d.cts +2 -0
- package/dist/utils/universalRef.d.ts +2 -0
- package/dist/wDom.d.cts +15 -1
- package/dist/wDom.d.ts +15 -1
- package/examples/dist/assets/index-B52a09eX.js +2 -0
- package/examples/dist/assets/index-B52a09eX.js.map +1 -0
- package/examples/dist/index.html +1 -1
- package/package.json +1 -1
- package/src/diff.ts +68 -57
- package/src/hook/internal/unmount.ts +5 -7
- package/src/hook/internal/useUpdate.ts +8 -14
- package/src/hook/mountCallback.ts +17 -28
- package/src/hook/mountReadyCallback.ts +4 -7
- package/src/hook/updateCallback.ts +3 -9
- package/src/render.ts +193 -191
- package/src/tests/core-edgeRegressions.test.tsx +597 -0
- package/src/tests/core-redrawRecovery.test.tsx +106 -0
- package/src/tests/core-renderFuzz.test.ts +304 -88
- package/src/tests/core-renderMatrix.test.ts +1 -0
- package/src/tests/helpers/renderSpec.ts +191 -75
- package/src/types/index.ts +3 -1
- package/src/utils/predicator.ts +41 -73
- package/src/utils/redraw.ts +13 -6
- package/src/utils/universalRef.ts +4 -0
- package/src/wDom.ts +81 -58
- package/examples/dist/assets/index-BLJryCr0.js +0 -2
- package/examples/dist/assets/index-BLJryCr0.js.map +0 -1
package/dist/lithent.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const k=Symbol.for("lithentWDomSymbol"),S={value:""},h={value:null},R={value:!1},f=new WeakMap,q=new WeakSet;let re=!1;const Te=(e,t)=>{f.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},v=()=>h.value,xe=(e,t)=>{const n=f.get(e);return n?n[t]:null},Ee=e=>{h.value=e},Ne=(e,t)=>{h.value=e,Te(e,t)},Fe=e=>{re=e},Le=()=>re,le=e=>{const t=f.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},Ue=e=>{le(e),f.delete(e)},C=e=>e.getParent&&e.getParent(),J=e=>()=>e,D=Object.keys,ue=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),ie=(e,t)=>{if(ue(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&ie(n,t)},P=e=>typeof e=="object"&&e!==null,Ae=e=>P(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(k),M=e=>P(e)&&!("resolve"in e),E=(e,t)=>M(e)&&e.type===t,Oe=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),Be=(e,t)=>!!(M(e)&&t&&t.type==="f"&&!t.ctor&&t.children&&t.children.length===(e.children&&e.children.length)),Ke=(e,t)=>!!(M(e)&&t&&t.type==="e"&&t.tag===e.tag&&t.children&&t.children.length===(e.children&&e.children.length)),ee=(e,t)=>!!(M(e)&&t&&t.type===e.type),Qe=(e,t)=>!!(M(e)&&t&&t.type===e.type&&(N((e.children||[])[0])&&N((t.children||[])[0])||t.children&&e.children&&t.children.length===e.children.length)),I=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),g=e=>e==="f"||e==="l",L=e=>typeof e=="function"&&!ae(e)||P(e)&&"resolve"in e,ae=e=>typeof e=="function"&&e===B,Ie=e=>M(e)&&!e.type,N=e=>fe(I(e)),fe=e=>e!=null,te=(e,t)=>e==="style"&&P(t),je=(e,t)=>e==="ref"&&P(t),ne=new WeakMap,ce=(e,t)=>{const n=e.constructor.prototype;let c=ne.get(n);c||ne.set(n,c=new Map);let s=c.get(t);if(s===void 0){const o=Object.getOwnPropertyDescriptor(n,t);s=!!(o&&o.get&&o.set),c.set(t,s)}return s},se=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Ve=e=>L(e)?"c":E(e,"f")?"f":E(e,"e")?"e":E(e,"l")?"l":E(e,"t")?"t":"et",_e={c:Oe,l:Qe,t:ee,e:Ke,f:Be,et:ee},pe=e=>{const t=v();if(t){const n=f.get(t);n&&n.umts.push(e)}},U=e=>{const{compKey:t}=e;t&&(e.il=!0,He(t)),de(e)},de=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)t[0]==="o"&&t[1]==="n"&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?U(t):de(t)})},He=e=>{le(e),Le()||f.delete(e)};let j=[];const ze=e=>{e.compKey&&j.push(e)},b=()=>{j.forEach(e=>qe(e)),j=[]},Ge=e=>{const t=v();if(t){const n=f.get(t);n&&n.mts.push(e)}},qe=e=>{const{compKey:t}=e;if(t){const n=f.get(t);if(!n)return;const{mts:c,upS:s}=n;h.value=t,s&&(s.value=0),c&&(n.mts=[],c.forEach(o=>{const r=o();r&&pe(r)}))}},Je=e=>{const t=v();if(t){const n=f.get(t);n&&n.wdCB.push(e)}},Xe=e=>{const{compKey:t}=e;if(t){const n=f.get(t),c=n&&n.wdCB;h.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(s=>{const o=s();o&&typeof o=="function"&&pe(o)}))}},oe=(e,t=()=>[])=>{const n=v();if(!n)return;const c=f.get(n);if(!c)return;const{upD:s,upS:o}=c,r=s[o.value],l=t();if(r&&Ze(r,l)){const u=e();u&&c.upCB.push(u)}s[o.value]=l,o.value+=1},Ye=e=>{const{compKey:t}=e;if(t){const n=f.get(t);if(!n)return;const{upCB:c,upS:s}=n;h.value=t,s&&(s.value=0),e.ctor&&c&&(n.upCB=[],c.forEach(o=>o()))}},Ze=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,V=()=>new DocumentFragment,$e=e=>document.createElement(e),me=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const s=T(e,c);return n?(e.ae=n,t.insertBefore(s,n)):c||(t.tagName==="HTML"?t.replaceWith(s):t.appendChild(s)),b(),()=>{const o=f.get(e.compProps||{}),r=o&&o.vd.value||e;U(r),we(r)}},we=e=>he(e,e.we),A=e=>{const t=C(e),n=e.isRoot?e.we:t?x(t):void 0;n&&he(e,n)},he=(e,t)=>{if(t&&e.el){const n=e.el.nodeType;n===11||(e==null?void 0:e.tag)==="portal"?ye(e,t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},ye=(e,t)=>{const n=e&&e.oc||e&&e.children||[];if(n.length>1&&n.every(c=>{const s=c.el&&c.el.nodeType;return(s===1||s===3)&&c.el.tagName!=="HTML"&&c.tag!=="portal"})){let c=0;for(let s=t.firstChild;s&&c<=n.length;s=s.nextSibling)c++;if(c===n.length){t.textContent="",n.forEach(s=>s.el=void 0);return}}n.forEach(c=>{const s=c.el&&c.el.nodeType;if(s)if(s===1||s===3){const o=c.el;o.tagName==="HTML"?o.innerHTML="":o.remove()}else s===11&&ye(c,t)})},We=e=>{e.forEach(t=>{U(t),A(t)})},_=e=>{A(e),X(e)},De=e=>{$(e),(C(e)||e.isRoot)&&X(e,Y(e))},X=(e,t)=>{t||(t=T(e));const n=C(e);if(!n||!n.type){e.isRoot&&e.we&&t&&e.tag!=="portal"&&(e.ae?e.we.insertBefore(t,e.ae):e.we.tagName==="HTML"?e.we.replaceWith(t):e.we.appendChild(t),b());return}const c=x(n),s=Z(e,n);t&&c&&(e.tag!=="portal"&&c.insertBefore(t,s||null),b())},Y=e=>g(e.type)?(e&&e.children||[]).reduce((t,n)=>{const c=Y(n);return c&&t.appendChild(c),t},V()):e.el,Z=(e,t)=>{const n=t.children||[],s=n.indexOf(e)+1,o=n.slice(s),r=F(o),l=t.type||"";if(r)return r;if(!t.isRoot&&g(l))return Z(t,C(t));if(t.isRoot&&g(l)&&t.ae)return t.ae},F=e=>e.reduce((t,n)=>{if(t)return t;const{type:c,el:s}=n;if(c&&g(c)){const o=F(n.children||[]);if(o)return o}return s&&s.nodeType!==11?s:t},void 0),et=e=>{const t=C(e),n=e.el;if(e.isRoot&&!t&&n){_(e);return}if(t&&t.type&&n)if(n.nodeType===11)_(e);else{const c=x(t),s=T(e);c&&e.tag!=="portal"&&c.replaceChild(s,n),b()}},$=e=>{if(e.type==="t"){st(e);return}if(e.el){const{op:t,props:n}=e;Ce(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}tt(e),Ye(e)},tt=e=>{const t=e.children||[];let n=!1;if(e.type==="l"){for(const i of t)if("ATS".includes(i.nr)||i.oi!==void 0){n=!0;break}}if(!n){t.forEach(i=>H(i));return}const c=[],s=[],o=[];let r=0;t.forEach((i,p)=>{const y=i.nr;y==="A"||y==="S"?(y==="S"&&A(i),c[p]=T(i),r++):y==="T"?$(i):H(i),i.oi!==void 0&&c[p]===void 0&&(s.push(p),o.push(i.oi))});const l=new Set(nt(o).map(i=>s[i])),u=x(e),a=e.isRoot?e.ae:Z(e,C(e));let d=t.length;for(;d>0&&c[d-1]!==void 0;)d--;for(let i=d;i<t.length;i++){const p=c[i];p&&u&&t[i].tag!=="portal"&&u.insertBefore(p,a||null)}if(l.size!==s.length||r>t.length-d){let i=F(t.slice(d))||a;for(let p=d-1;p>=0;p--){const y=t[p],K=c[p]!==void 0,be=y.oi!==void 0&&!K&&!l.has(p);if((K||be)&&u&&y.tag!=="portal"){const W=K?c[p]:Y(y);W&&u.insertBefore(W,i||null)}const w=F([y]);w&&(i=w)}}t.forEach(ve),b()},ve=e=>{e.oi=e.nr=e.oc=e.op=void 0},nt=e=>{const t=[];if(!e.length)return t;const n=new Array(e.length);t.push(0);for(let o=1;o<e.length;o++){const r=e[o];if(e[t[t.length-1]]<r){n[o]=t[t.length-1],t.push(o);continue}let l=0,u=t.length-1;for(;l<u;){const a=l+u>>1;e[t[a]]<r?l=a+1:u=a}r<e[t[l]]&&(l>0&&(n[o]=t[l-1]),t[l]=o)}let c=t.length,s=t[c-1];for(;c-- >0;)t[c]=s,s=n[s];return t},H=e=>{const{nr:t}=e;t!==void 0&&t!=="N"&&(ct[t](e),ve(e))},ct={A:X,D:A,R:et,U:$,S:_,T:De},st=e=>{e.el&&(e.el.nodeValue=String(e.text))},Ce=(e,t,n,c)=>{const s=n||{};for(const o in e){const r=e[o];if(r===s[o])continue;const l=o[0]==="o"&&o[1]==="n";c&&l?Q(t,o,r,s[o]):o==="key"||o==="portal"&&P(r)||(o==="innerHTML"&&typeof r=="string"?t.innerHTML=r:te(o,r)?lt(r,te(o,s.style)?s.style:{},t):je(o,r)?r.value=t:l?Q(t,o,r,s[o]):o&&(o!=="type"&&ce(t,o)?t[o]=r:(ot(o==="className"?"class":o,t,r),se(t)&&!(o in HTMLElement.prototype)&&(t[o]=r))))}for(const o in s)if(!(e&&ie(e,o))){if(o[0]==="o"&&o[1]==="n"){Q(t,o,void 0,s[o]);continue}t.removeAttribute(o),se(t)?delete t[o]:t.localName.includes("-")&&ce(t,o)&&(t[o]=void 0)}},ot=(e,t,n)=>S.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),T=(e,t)=>{let n;const{type:c,tag:s,text:o,props:r,children:l=[]}=e,u=g(c);if(Xe(e),s==="svg"&&(S.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c)n=V();else if(u)n=V();else if(c==="e"&&s)s==="portal"&&r&&r.portal?n=r.portal:n=S.value?document.createElementNS(S.value,s):$e(s);else if(c==="t"&&fe(o))n=document.createTextNode(String(o));else throw Error("Invalid wDom");e.el=n}return rt(l,n,t),Ce(r,n,null,t),ze(e),s==="svg"&&(S.value=""),n},rt=(e,t,n)=>{e.forEach(c=>{if(c.type){const s=T(c,n);c.tag!=="portal"&&!n&&t&&t.appendChild(s)}})},Q=(e,t,n,c)=>{const s=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(s,c),n&&e.addEventListener(s,n))},lt=(e,t,n)=>{const c={...t},s=n instanceof HTMLElement?n:null,o=s==null?void 0:s.style;if(!o)return;const r=o;for(const l in e)r[l]=e[l],delete c[l];for(const l in c)r[l]=""},x=e=>{const t=g(e.type);return e.isRoot&&t?e.we:t?x(C(e)):e.el},O=(e,t)=>ut(e,!!t&&_e[Ve(e)](e,t),t),ut=(e,t,n)=>{const c=ht(e,t,n),s=at(c,t,n),o=s==="N";return o||(c.children=yt(c,t,n)),c.nr=s,it(c,n,s),!o&&n&&(n.il=!0,n.children=void 0),(n==null?void 0:n.tag)==="portal"&&(c.tag="portal"),c},it=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&U(t),e.oc=t&&t.children),e.op=t&&t.props},at=(e,t,n)=>{if(Ie(e))return"D";if(e.type==="t"&&t&&e.text===(n&&n.text)||e===n)return"N";if(!(n&&n.type))return"A";const o=C(n),r=!e.isRoot&&o&&o.type==="l"&&N(e);return t?r?"T":"U":r?"S":"R"},ft=(e,t)=>{e&&t!==e&&(t=t||{},D(e).forEach(n=>ue(t,n)||delete e[n]),D(t).forEach(n=>e[n]=t[n]))},pt=(e,t)=>{e&&(e.splice(0,e.length),t&&t.forEach(n=>e.push(n)))},dt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:s,children:o}=t;return n&&ft(n,s),c&&o&&c!==o&&pt(c,o),e.reRender&&e.reRender()},ht=(e,t,n)=>L(e)?t&&n?dt(n,e):e.resolve():e,yt=(e,t,n)=>t&&n?Ct(e,n):vt(e),vt=e=>{const t=J(e);return(e.children||[]).map(n=>{const c=O(n);return c.getParent=t,c})},Ct=(e,t)=>{if(e.type==="l"&&N((e.children||[])[0]))return kt(e,t);const n=t.children||[],c=J(e);return(e.children||[]).map((s,o)=>{const r=O(s,n[o]);return r.getParent=c,r})},kt=(e,t)=>{const[n,c]=Rt(e,t);return We(c),n},Rt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,u)=>{const a=I(l);c.has(a)||c.set(a,u)});const s=[],o=J(e);return[(e.children||[]).map(l=>{const u=I(l),a=c.get(u),d=a!==void 0;d&&(c.delete(u),s[a]=!0);const i=O(l,d?n[a]:void 0);return d&&(i.oi=a),i.getParent=o,i}),n.filter((l,u)=>!s[u])]},z=new Map;let G=!1;const gt=(e,t)=>{z.set(e,t),G||(G=!0,queueMicrotask(Mt))},Pt=(e,t)=>{const n=f.get(e);n&&(n.up=()=>{const c=n.vd.value;gt(e,()=>t(c))})},m=e=>()=>{const t=f.get(e),n=t&&t.up;return n?(n(),!0):!1},Mt=()=>{z.forEach(e=>{e()}),z.clear(),G=!1},St=(e,t=()=>[])=>{const n=v();if(!n)return;const c=f.get(n);c&&(c.upR.push(()=>oe(e,t)),oe(e,t))},bt=()=>{const e=v();if(!e)return;const t=f.get(e),n=t&&t.upR;n&&n.length&&n.forEach(c=>c())},B=(e,...t)=>({type:"f",[k]:!0,children:t}),ke=(e,t,...n)=>{const c={value:void 0},s=ge(c,n),o=Ft(e,t||{},s);return L(o)||(c.value=o),o},Tt=(e,t)=>ke("portal",{portal:t},e),xt=e=>(t,n)=>e,Et=e=>(t,n)=>(q.add(e),e),Nt=(e,t,n)=>{const c=(s,o)=>{if(!(!s||o.has(s))){if(o.add(s),s.compChild){const r=s.compChild.indexOf(t);r!==-1&&s.compChild.splice(r,1,n)}c(s.getParent?s.getParent():void 0,o)}};c(e,new Set)},Re=(e,t,n,c)=>{if(c.il)return;R.value=!0;let s;try{const o=Me(e,t,n);s=O(o,c);const{isRoot:r,getParent:l,we:u,ae:a}=c;if(s.getParent=l,!r&&l){const d=l(),i=d&&d.children||[],p=i.indexOf(c);p!==-1&&i.splice(p,1,s),Nt(d,c,s)}else s.isRoot=!0,s.we=u,s.ae=a}finally{R.value=!1}H(s)},Ft=(e,t,n)=>{if(ae(e))return B(t,...n);if(L(e)){const c=Me(e,t,n);return R.value?c:c.resolve()}return{type:"e",[k]:!0,tag:e,props:t,children:n}},ge=(e,t)=>{const n=()=>e.value;return t.map(c=>{const s=Pe(c);return s.getParent=n,s})},Pe=e=>{if(e==null||e===!1)return{type:null,[k]:!0};if(Array.isArray(e)){const t={value:void 0},n=ge(t,e),c={type:"l",[k]:!0,children:n};return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return{type:"t",[k]:!0,text:e};return e},Lt=(e,t,n)=>(c=t)=>{const s=R.value,o=h.value;R.value=!1;try{Ne(c,e);const r=e(t,n);let l;if(typeof r=="function"){const u=r;l=q.has(u)?u(t,n):u(m(c),t,n)}else{let u=!0;l=a=>u?(u=!1,r):e(a,n)}return Ut(l,c,e,t,n)}finally{h.value=o,R.value=s}},Me=(e,t,n)=>{const c=e,s=n,o=Lt(e,t,s);return{ctor:c,props:t,children:s,resolve:o}},Ut=(e,t,n,c,s)=>{const o=a=>Pe(e(a)),{wrappedComponentMaker:r,customNode:l}=Bt(o,c),u=At(r,t,n,c,s);return Se(l,t,n,c,s,u),Pt(t,a=>Re(n,a.compProps||c,a.compChild||s,a)),l},At=(e,t,n,c,s)=>{const o=()=>Ot(e,t,n,c,s,o);return o},Ot=(e,t,n,c,s,o)=>{const r=h.value;try{Ee(t),bt();const l=e(c);return Se(l,t,n,c,s,o),l}finally{h.value=r}},Bt=(e,t)=>{const n=s=>{const o=e(s),r=B({},o);return o.getParent=()=>r,r},c=n(t);return{wrappedComponentMaker:n,customNode:c}},Se=(e,t,n,c,s,o)=>{e.compProps=c,e.compChild=s,e.ctor=n,e.compKey=t,e.reRender=o;const r=f.get(t);r&&(r.vd.value=e)},Kt=e=>({value:e}),Qt=()=>Promise.resolve(),It=()=>{const e=v();return e?m(e):()=>!1};exports.Fragment=B;exports.componentMap=f;exports.componentUpdate=m;exports.disposeComponentEntry=Ue;exports.getComponentKey=v;exports.getComponentSubInfo=xe;exports.h=ke;exports.isPropType=Ae;exports.lmount=Et;exports.lmountComponentSet=q;exports.mount=xt;exports.mountCallback=Ge;exports.mountReadyCallback=Je;exports.nextTick=Qt;exports.portal=Tt;exports.ref=Kt;exports.render=me;exports.replaceWDom=Re;exports.setComponentMapManualMode=Fe;exports.updateCallback=St;exports.useRenew=It;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const C=Symbol.for("lithentWDomSymbol"),M={value:""},v={value:null},g={value:!1},d=new WeakMap,I=new WeakSet;let ue=!1;const Oe=(e,t)=>{d.set(e,{ctor:t,vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[],wdCB:[]})},ae=()=>v.value,P=()=>d.get(v.value),Ue=(e,t)=>{const n=d.get(e);return n?n[t]:null},Be=e=>{v.value=e},Qe=(e,t)=>{v.value=e,Oe(e,t)},Ke=e=>{ue=e},je=()=>ue,ie=e=>{const t=d.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[])},_e=e=>{ie(e),d.delete(e)},k=e=>e.getParent&&e.getParent(),U=e=>()=>e,D=Object.keys,pe=(e,t)=>Object.prototype.propertyIsEnumerable.call(e,t),fe=(e,t)=>{if(pe(e,t))return!0;const n=Object.getPrototypeOf(e);return!Object.prototype.hasOwnProperty.call(e,t)&&!!n&&fe(n,t)},S=e=>typeof e=="object"&&e!==null,He=e=>S(e)&&!Array.isArray(e)&&!Object.getOwnPropertySymbols(e).includes(C),Ve=(e,t)=>"ctor"in e?e.ctor===(t&&t.ctor):e===(t&&t.ctor),qe=(e,t)=>t.type==="f"&&!t.ctor&&!e.ctor&&!!t.children&&t.children.length===(e.children&&e.children.length),ze=(e,t)=>t.type==="e"&&t.tag===e.tag&&!!t.children&&t.children.length===(e.children&&e.children.length),ee=(e,t)=>t.type===e.type,Ie=(e,t)=>t.type===e.type&&(V(e)&&V(t)||!!t.children&&t.children.length===(e.children&&e.children.length)),_=e=>(e&&e.compProps&&e.compProps.key)??(e&&e.props&&e.props.key),x=e=>e==="f"||e==="l",B=e=>typeof e=="function"&&!de(e)||S(e)&&"resolve"in e,de=e=>e===j,Ge=e=>!e.type,H=e=>e[0]==="o"&&e[1]==="n",G=e=>F(_(e)),V=e=>!!e&&!!e.children&&e.children.some(G),F=e=>e!=null,te=(e,t)=>e==="style"&&S(t),Je=(e,t)=>e==="ref"&&S(t),ne=new WeakMap,ce=(e,t)=>{const n=e.constructor.prototype;let c=ne.get(n);c||ne.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},oe=e=>e.localName.includes("-")&&e.constructor===HTMLElement,Xe=e=>B(e)?"c":e.type||"et",Ye={c:Ve,l:Ie,t:ee,e:ze,f:qe,et:ee},he=e=>{const t=P();t&&t.umts.push(e)},Q=e=>{const{compKey:t}=e;t&&(e.il=!0,Ze(t)),ye(e)},ye=e=>{if(e.tag==="portal"&&e.el)for(const t in e.props)H(t)&&e.el.removeEventListener(t.slice(2).toLowerCase(),e.props[t]);(e.children||[]).forEach(t=>{t.compKey?Q(t):ye(t)})},Ze=e=>{ie(e),je()||d.delete(e)};let q=[];const $e=e=>{e.compKey&&q.push(e)},b=()=>{q.forEach(we),q=[]},me=e=>{const t=P();t&&t.mts.push(e)},we=e=>{const{compKey:t}=e,n=t&&d.get(t);if(n){const c=n.mts;v.value=t,n.upS.value=0,n.mts=[],c.forEach(o=>{const s=o();s&&he(s)})}},We=e=>{const t=P();t&&t.wdCB.push(e)},De=e=>{const{compKey:t}=e;if(t){const n=d.get(t),c=n&&n.wdCB;v.value=t,c&&c.length>0&&(n.wdCB=[],c.forEach(o=>{const s=o();typeof s=="function"&&he(s)}))}},se=(e,t=()=>[])=>{const n=P();if(!n)return;const{upD:c,upS:o}=n,s=c[o.value],r=t();if(s&&tt(s,r)){const l=e();l&&n.upCB.push(l)}c[o.value]=r,o.value+=1},et=e=>{const{compKey:t}=e,n=t&&d.get(t);if(n){const c=n.upCB;v.value=t,n.upS.value=0,e.ctor&&(n.upCB=[],c.forEach(o=>o()))}},tt=(e,t)=>e.length?e.some((n,c)=>n!==t[c]):!0,ve=()=>new DocumentFragment,Ce=(e,t,n)=>n?e.insertBefore(t,n):e.tagName==="HTML"?e.replaceWith(t):e.appendChild(t),nt=e=>document.createElement(e),ct=(e,t,n,c)=>{e.isRoot=!0,t=t||document.body,e.we=t;const o=T(e,c);return e.ae=n,(n||!c)&&Ce(t,o,n),b(),()=>{const s=d.get(e.compProps),r=s&&s.vd.value||e;Q(r),ot(r)}},ot=e=>X(e,e.we),J=e=>{const t=k(e);X(e,e.isRoot?e.we:t&&R(t))},X=(e,t)=>{if(t&&e.el){const n=e.el.nodeType;n===11||e.tag==="portal"?ke(e,t):(n===1||n===3)&&t.removeChild(e.el),e.el=void 0}},ke=(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"&&c.tag!=="portal"})){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(o)if(o===1||o===3){const s=c.el;s.tagName==="HTML"?s.innerHTML="":s.remove()}else o===11&&ke(c,t)})},st=(e,t)=>{const n=R(t);e.forEach(c=>{Q(c),X(c,n)})},ge=e=>{J(e),Pe(e)},Pe=(e,t)=>{t=t||T(e);const n=k(e);if(!n||!n.type){e.isRoot&&e.we&&e.tag!=="portal"&&(Ce(e.we,t,e.ae),b());return}const c=R(n),o=Y(e,n);c&&(e.tag!=="portal"&&c.insertBefore(t,o||null),b())},Re=e=>x(e.type)?(e.children||[]).reduce((t,n)=>{const c=Re(n);return c&&t.appendChild(c),t},ve()):e.el,Y=(e,t)=>{const n=t.children||[];return L(n.slice(n.indexOf(e)+1))||(x(t.type)?t.isRoot?t.ae:Y(t,k(t)):void 0)},A=new Set,L=e=>e.reduce((t,n)=>{if(t||A.size&&A.has(n))return t;const{type:c,el:o}=n;if(c&&x(c)){const s=L(n.children||[]);if(s)return s}return o&&o.nodeType!==11?o:t},void 0),rt=e=>{const t=k(e),n=e.el;if(n&&(t?t.type:e.isRoot))if(!t||n.nodeType===11)ge(e);else{const c=R(t),o=T(e);c&&e.tag!=="portal"&&c.replaceChild(o,n),b()}},re=e=>{if(e.type==="t"){it(e);return}if(e.el){const{op:t,props:n}=e;Me(n,e.el,t),e.tag==="input"&&(e.el.value=String(n&&n.value||""))}lt(e),et(e)},lt=e=>{const t=e.children||[];if(e.type!=="l"||!t.some(u=>"ATS".includes(u.nr)||u.oi!==void 0)){t.forEach(z);return}const n=[],c=[],o=[];let s=!0;t.forEach((u,p)=>{const y=u.oi,E=u.nr;E==="S"?o.push(u):E!=="A"&&y!==void 0&&(y<c[c.length-1]&&(s=!1),n.push(p),c.push(y))});let r;if(!s){const u=r=[];ut(c).forEach(p=>u[n[p]]=!0),n.forEach(p=>u[p]||(u[p]=!1,o.push(t[p])))}const l=[];let a=0;o.forEach(u=>A.add(u));try{t.forEach((u,p)=>{const y=u.nr;y==="A"||y==="S"?(y==="S"&&J(u),l[p]=T(u),a++):z(u)})}finally{o.forEach(u=>A.delete(u))}const i=R(e),h=e.isRoot?e.ae:Y(e,k(e));let f=t.length;for(;f>0&&l[f-1]!==void 0;)f--;for(let u=f;u<t.length;u++){const p=l[u];p&&i&&t[u].tag!=="portal"&&i.insertBefore(p,h||null)}if(r||a>t.length-f){let u=L(t.slice(f))||h;for(let p=f-1;p>=0;p--){const y=t[p],E=l[p]!==void 0,Le=!!r&&r[p]===!1;if((E||Le)&&i&&y.tag!=="portal"){const W=E?l[p]:Re(y);W&&i.insertBefore(W,u||null)}const w=L([y]);w&&(u=w)}}t.forEach(Ee),b()},Ee=e=>{e.oi=e.oc=e.op=void 0,e.nr="N"},ut=e=>{const t=[],n=[];e.forEach((s,r)=>{let l=0,a=t.length;if(a&&e[t[a-1]]<s)l=a;else for(;l<a;){const i=l+a>>1;e[t[i]]<s?l=i+1:a=i}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},z=e=>{const{nr:t}=e;t&&t!=="N"&&(at[t](e),Ee(e))},at={A:Pe,D:J,R:rt,U:re,S:ge,T:re},it=e=>{e.el&&(e.el.nodeValue=String(e.text))},Me=(e,t,n)=>{const c=n||{};for(const o in e){const s=e[o];s!==c[o]&&(H(o)?le(t,o,s,c[o]):o==="key"||o==="portal"&&S(s)||(o==="innerHTML"&&typeof s=="string"?t.innerHTML=s:te(o,s)?dt(s,te(o,c.style)?c.style:{},t):Je(o,s)?s.value=t:o&&(o!=="type"&&ce(t,o)?t[o]=s:(pt(o==="className"?"class":o,t,s),oe(t)&&!(o in HTMLElement.prototype)&&(t[o]=s)))))}for(const o in c)if(!(e&&fe(e,o))){if(H(o)){le(t,o,void 0,c[o]);continue}t.removeAttribute(o),oe(t)?delete t[o]:t.localName.includes("-")&&ce(t,o)&&(t[o]=void 0)}},pt=(e,t,n)=>M.value&&e!=="xmlns"?t.setAttributeNS(null,e,n):t.setAttribute(e,n),T=(e,t)=>{let n;const{type:c,tag:o,text:s,props:r,children:l=[]}=e,a=x(c);if(De(e),o==="svg"&&(M.value=String(r&&r.xmlns)),t)n=e.el;else{if(!c||a)n=ve();else if(c==="e"&&o)o==="portal"&&r&&r.portal?n=r.portal:n=M.value?document.createElementNS(M.value,o):nt(o);else if(c==="t"&&F(s))n=document.createTextNode(String(s));else throw Error("Invalid wDom");e.el=n}return ft(e,l,n,t),Me(r,n,null),$e(e),o==="svg"&&(M.value=""),n},ft=(e,t,n,c)=>{const o=U(e);t.forEach((s,r)=>{if(s.nr==="N"&&!c){const l=Fe(s);s=t[r]="resolve"in l?l.resolve():l}if(s.getParent=o,s.nr="N",s.type){const l=T(s,c);s.tag!=="portal"&&!c&&n&&n.appendChild(l)}})},le=(e,t,n,c)=>{const o=t.slice(2).toLowerCase();c!==n&&(c&&e.removeEventListener(o,c),n&&e.addEventListener(o,n))},dt=(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]=""},R=e=>x(e.type)?e.isRoot?e.we:R(k(e)):e.el,K=(e,t)=>(e!==t&&e.nr&&(e=Fe(e)),ht(e,!!t&&Ye[Xe(e)](e,t),t)),ht=(e,t,n)=>{const c=gt(e,t,n),o=vt(c,t,n),s=o==="N";return s||(c.children=Pt(c,t,n)),c.nr=o,yt(c,n,o),!s&&n&&(n.il=!0,n.ctor&&(n.children=void 0)),n&&n.tag==="portal"&&(c.tag="portal"),c},yt=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),(n==="D"||n==="R"||n==="S")&&(t&&Q(t),e.oc=t&&t.children),e.op=t&&t.props},vt=(e,t,n)=>{if(Ge(e))return"D";if(e===n||t&&e.type==="t"&&e.text===n.text)return"N";if(!(n&&n.type))return"A";const c=k(n),o=!e.isRoot&&c&&c.type==="l"&&G(e);return t?o?"T":"U":o?"S":"R"},Ct=(e,t)=>{e&&t!==e&&(t=t||{},D(e).forEach(n=>pe(t,n)||delete e[n]),D(t).forEach(n=>e[n]=t[n]))},kt=(e,t)=>{const{compProps:n,compChild:c}=e,{props:o,children:s}=t;return n&&Ct(n,o),c&&s&&c!==s&&c.splice(0,c.length,...s),e.reRender&&e.reRender()},gt=(e,t,n)=>B(e)?t&&n?kt(n,e):(e.rd?$(e):(e.rd=!0,e)).resolve():e,Pt=(e,t,n)=>t&&n?Et(e,n):Rt(e),Rt=e=>{const t=U(e);return(e.children||[]).map(n=>{const c=K(n);return c.getParent=t,c})},Et=(e,t)=>{if(e.type==="l"&&V(e))return Mt(e,t);const n=t.children||[],c=U(e);return(e.children||[]).map((o,s)=>{const r=K(o,n[s]);return r.getParent=c,r})},Mt=(e,t)=>{const n=t.children||[],c=new Map;n.forEach((l,a)=>{const i=_(l);F(i)&&!c.has(i)&&c.set(i,a)});const o=[],s=U(e),r=(e.children||[]).map((l,a)=>{const i=_(l),h=F(i)?c.get(i):a<n.length&&!G(n[a])?a:void 0;let f;h!==void 0&&(c.delete(i),o[h]=!0,f=n[h]);const u=K(l,f);return f&&(u.oi=h),u.getParent=s,u});return st(n.filter((l,a)=>!o[a]),t),r},N=new Map;let O=!1;const bt=(e,t)=>{N.set(e,t),O||(O=!0,queueMicrotask(be))},St=(e,t)=>{const n=d.get(e);n&&(n.up=()=>{const c=n.vd.value;bt(e,()=>t(c))})},Z=e=>()=>{const t=d.get(e),n=t&&t.up;return n?(n(),!0):!1},be=()=>{try{N.forEach((e,t)=>{N.delete(t),e()})}finally{O=!!N.size,O&&queueMicrotask(be)}},xt=(e,t=()=>[])=>{const n=P();n&&(n.upR.push(()=>se(e,t)),se(e,t))},Tt=()=>{const e=P(),t=e&&e.upR;t&&t.length&&t.forEach(n=>n())},j=(e,...t)=>({type:"f",nr:void 0,[C]:!0,children:t}),Se=(e,t,...n)=>{const c={value:void 0},o=Te(c,n),s=Ot(e,t||{},o);return B(s)||(c.value=s),s},Nt=(e,t)=>Se("portal",{portal:t},e),Ft=e=>(t,n)=>e,At=e=>(t,n)=>(I.add(e),e),Lt=(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)},xe=(e,t,n,c)=>{if(c.il)return;g.value=!0;let o;try{const s=m(e,t,n);o=K(s,c);const{isRoot:r,getParent:l,we:a,ae:i}=c;if(o.getParent=l,!r&&l){const h=l(),f=h&&h.children||[],u=f.indexOf(c);u!==-1&&f.splice(u,1,o),Lt(h,c,o)}else o.isRoot=!0,o.we=a,o.ae=i}finally{g.value=!1}z(o)},Ot=(e,t,n)=>{if(de(e))return j(t,...n);if(B(e)){const c=m(e,t,n);if(g.value)return c;const o=$(c).resolve();return o.rs=c,o}return{type:"e",nr:void 0,[C]:!0,tag:e,props:t,children:n}},Te=(e,t)=>{const n=()=>e.value;return t.map(c=>{const o=Ne(c);return o.getParent=n,o})},Ne=e=>{if(e==null||typeof e=="boolean")return{type:null,nr:void 0,[C]:!0};if(Array.isArray(e)){const t={value:void 0},n=Te(t,e),c={type:"l",nr:void 0,[C]:!0,children:n};return t.value=c,c}else if(typeof e=="string"||typeof e=="number")return{type:"t",nr:void 0,[C]:!0,text:e};return e},Ut=(e,t,n)=>(c=t)=>{const o=g.value,s=v.value;g.value=!1;try{Qe(c,e);const r=e(t,n);let l;if(typeof r=="function"){const a=r;l=I.has(a)?a(t,n):a(Z(c),t,n)}else{let a=!0;l=i=>a?(a=!1,r):e(i,n)}return Bt(l,c,e,t,n)}finally{v.value=s,g.value=o}},Fe=e=>e.ctor?$(e.rs||{ctor:e.ctor,props:e.compProps,children:e.compChild}):{type:e.type,tag:e.tag,props:e.props,text:e.text,children:e.children&&[...e.children],getParent:e.getParent,[C]:!0},$=({ctor:e,props:t,children:n})=>m(e,{...t},[...n||[]]),m=(e,t,n)=>({ctor:e,props:t,children:n,resolve:Ut(e,t,n)}),Bt=(e,t,n,c,o)=>{const s=Kt(e),r=s(c),l=Qt(s,t,n,c,o);return Ae(r,t,n,c,o,l),St(t,a=>xe(n,a.compProps||c,a.compChild||o,a)),r},Qt=(e,t,n,c,o)=>{const s=()=>{const r=v.value;try{Be(t),Tt();const l=e(c);return Ae(l,t,n,c,o,s),l}finally{v.value=r}};return s},Kt=e=>t=>{const n=Ne(e(t)),c=j({},n);return n.getParent=()=>c,c},Ae=(e,t,n,c,o,s)=>{e.compProps=c,e.compChild=o,e.ctor=n,e.compKey=t,e.reRender=s;const r=d.get(t);r&&(r.vd.value=e)},jt=e=>({value:e}),_t=()=>Promise.resolve(),Ht=()=>{const e=ae();return e?Z(e):()=>!1};exports.Fragment=j;exports.componentMap=d;exports.componentUpdate=Z;exports.disposeComponentEntry=_e;exports.getComponentKey=ae;exports.getComponentSubInfo=Ue;exports.h=Se;exports.isPropType=He;exports.lmount=At;exports.lmountComponentSet=I;exports.mount=Ft;exports.mountCallback=me;exports.mountReadyCallback=We;exports.nextTick=_t;exports.portal=Nt;exports.ref=jt;exports.render=ct;exports.replaceWDom=xe;exports.setComponentMapManualMode=Ke;exports.updateCallback=xt;exports.useRenew=Ht;
|
|
2
2
|
//# sourceMappingURL=lithent.cjs.map
|
package/dist/lithent.cjs.map
CHANGED
|
@@ -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/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\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 checkPlainWDomType = (wDom: WDomParam): wDom is WDom =>\n isObject(wDom) && !('resolve' in wDom);\n\nconst checkPlainType = (wDom: WDomParam, typeName: string) =>\n checkPlainWDomType(wDom) && wDom.type === typeName;\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\nconst checkSameFragment = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\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.\n !originalWDom.ctor &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkSameTagElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === 'e' &&\n originalWDom.tag === newWDom.tag &&\n originalWDom.children &&\n originalWDom.children.length ===\n (newWDom.children && newWDom.children.length)\n );\n\nconst checkNormalTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type\n );\n\nconst checkLoopTypeElement = (\n newWDom: WDom | TagFunction | TagFunctionResolver,\n originalWDom?: WDom\n): boolean =>\n !!(\n checkPlainWDomType(newWDom) &&\n originalWDom &&\n originalWDom.type === newWDom.type &&\n ((checkExistyKey((newWDom.children || [])[0]) &&\n checkExistyKey((originalWDom.children || [])[0])) ||\n (originalWDom.children &&\n newWDom.children &&\n originalWDom.children.length === newWDom.children.length))\n );\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 =>\n typeof target === 'function' && target === Fragment;\n\nexport const checkEmptyElement = (wDom: WDomParam) =>\n checkPlainWDomType(wDom) && !wDom.type;\n\nexport const checkExistyKey = (target: WDom) => checkExisty(getKey(target));\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 : checkPlainType(wDom, 'f')\n ? 'f'\n : checkPlainType(wDom, 'e')\n ? 'e'\n : checkPlainType(wDom, 'l')\n ? 'l'\n : checkPlainType(wDom, 't')\n ? 't'\n : '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 {\n componentMap,\n getComponentKey,\n isComponentMapManualMode,\n runUnmountEffects,\n} from '@/utils/universalRef';\n\nexport const unmount = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.umts.push(effectAction);\n }\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 (key[0] === 'o' && key[1] === 'n') {\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 getComponentKey,\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(item => runMountedQueueFromWDom(item));\n mountedQueue = [];\n};\n\n/**\n * mountCallback 등록\n */\nexport const mountCallback = (effectAction: () => void) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n if (comp) {\n comp.mts.push(effectAction);\n }\n }\n};\n\n/**\n * mountCallback만 실행\n */\nconst runMountedQueueFromWDom = (newWDom: WDom) => {\n const { compKey } = newWDom;\n\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { mts: mountQueue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (mountQueue) {\n component.mts = [];\n\n mountQueue.forEach((effect: Function) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\nimport { unmount } from '@/hook/internal/unmount';\n\n/**\n * WDom이 생성된 직후(DOM 마운트 전)에 실행될 콜백 등록\n */\nexport const mountReadyCallback = (effectAction: () => void | (() => void)) => {\n const compKey = getComponentKey();\n if (compKey) {\n const comp = componentMap.get(compKey);\n comp && comp.wdCB.push(effectAction);\n }\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 (cleanup && typeof cleanup === 'function') {\n unmount(cleanup);\n }\n });\n }\n }\n};\n","import { WDom } from '@/types';\nimport {\n compKeyRef,\n componentMap,\n getComponentKey,\n} from '@/utils/universalRef';\n\ntype DependencyFactory = () => unknown[];\n\nexport const useUpdated = (\n effectAction: () => (() => void) | void,\n dependencies: DependencyFactory = () => []\n) => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\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\n if (compKey) {\n const component = componentMap.get(compKey);\n if (!component) return;\n const { upCB: queue, upS: sequence } = component;\n\n compKeyRef.value = compKey;\n\n if (sequence) {\n sequence.value = 0;\n }\n\n if (newWDom.ctor && queue) {\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} 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 { getParent, isObject, hasEnumerableProp } from '@/utils';\n\nconst DF = () => new DocumentFragment();\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 if (afterElement) {\n wDom.ae = afterElement;\n wrapElement.insertBefore(Dom, afterElement);\n } else if (!isHydration) {\n if (wrapElement.tagName === 'HTML') {\n wrapElement.replaceWith(Dom);\n } else {\n wrapElement.appendChild(Dom);\n }\n }\n\n execMountedQueue();\n\n return () => {\n const compData = componentMap.get(wDom.compProps || {});\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 const parentElement = newWDom.isRoot\n ? newWDom.we\n : parentWDom\n ? findRealParentElement(parentWDom)\n : undefined;\n\n if (parentElement) {\n deleteRealDom(newWDom, parentElement as HTMLElement);\n }\n};\n\nconst deleteRealDom = (newWDom: WDom, parent: HTMLElement) => {\n if (parent && newWDom.el) {\n const nt = newWDom.el.nodeType;\n if (nt === 11 || newWDom?.tag === 'portal') {\n findChildWithRemoveElement(newWDom, parent);\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 && newWDom.oc) || (newWDom && 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 item.tag !== 'portal'\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 (nt) {\n 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/**\n * Unmount and remove unused keyed children. Listeners are left on the\n * discarded DOM and go away with it.\n */\nexport const typeDeleteUnused = (items: WDom[]) => {\n items.forEach(item => {\n runUnmountQueueFromWDom(item);\n typeDelete(item);\n });\n};\n\nconst typeSortedReplace = (newWDom: WDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\n\nconst typeSortedUpdate = (newWDom: WDom) => {\n typeUpdate(newWDom);\n\n if (getParent(newWDom) || newWDom.isRoot) {\n typeAdd(newWDom, getElementFromFragment(newWDom));\n }\n};\n\nconst typeAdd = (\n newWDom: WDom,\n newElement?: HTMLElement | DocumentFragment | Text\n) => {\n if (!newElement) {\n newElement = wDomToDom(newWDom) as HTMLElement;\n }\n\n const parentWDom = getParent(newWDom);\n if (!parentWDom || !parentWDom.type) {\n if (\n newWDom.isRoot &&\n newWDom.we &&\n newElement &&\n newWDom.tag !== 'portal'\n ) {\n if (newWDom.ae) {\n newWDom.we.insertBefore(newElement, newWDom.ae);\n } else if (newWDom.we.tagName === 'HTML') {\n newWDom.we.replaceWith(newElement);\n } else {\n newWDom.we.appendChild(newElement);\n }\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 (newElement && 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 && newWDom.children) || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n\n if (element) {\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 const index = brothers.indexOf(wDom);\n const nextIndex = index + 1;\n const candidiateBrothers = brothers.slice(nextIndex);\n\n const finedNextEl = findChildFragmentNextElement(candidiateBrothers);\n const parentType = parentWDom.type || '';\n\n if (finedNextEl) {\n return finedNextEl;\n }\n\n if (!parentWDom.isRoot && checkVirtualType(parentType)) {\n return startFindNextBrotherElement(parentWDom, getParent(parentWDom));\n } else if (\n parentWDom.isRoot &&\n checkVirtualType(parentType) &&\n parentWDom.ae\n ) {\n return parentWDom.ae;\n }\n\n return undefined;\n};\n\nconst findChildFragmentNextElement = (\n candidiateBrothers: WDom[]\n): HTMLElement | DocumentFragment | Text | undefined =>\n candidiateBrothers.reduce<HTMLElement | DocumentFragment | Text | undefined>(\n (targetEl, bItem) => {\n if (targetEl) 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 (newWDom.isRoot && !parentWDom && orignalElement) {\n typeSortedReplace(newWDom);\n return;\n }\n\n if (parentWDom && parentWDom.type && orignalElement) {\n if (orignalElement.nodeType === 11) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement && newWDom.tag !== 'portal') {\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 let needPlace = false;\n\n if (newWDom.type === 'l') {\n for (const item of children) {\n if ('ATS'.includes(item.nr as string) || item.oi !== undefined) {\n needPlace = true;\n break;\n }\n }\n }\n\n if (!needPlace) {\n children.forEach(childItem => wDomUpdate(childItem));\n return;\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 const matchedIndexes: number[] = [];\n const oiSeq: number[] = [];\n let createdCount = 0;\n\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 if (nr === 'T') {\n typeUpdate(item);\n } else {\n wDomUpdate(item);\n }\n\n if (item.oi !== undefined && created[index] === undefined) {\n matchedIndexes.push(index);\n oiSeq.push(item.oi);\n }\n });\n\n const stay = new Set(getLisPositions(oiSeq).map(pos => matchedIndexes[pos]));\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 (\n stay.size !== matchedIndexes.length ||\n createdCount > children.length - tail\n ) {\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 = item.oi !== undefined && !isNew && !stay.has(i);\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.\nconst clearDiffMeta = (item: WDom) => {\n item.oi = item.nr = item.oc = item.op = undefined;\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 const result: number[] = [];\n\n if (!seq.length) {\n return result;\n }\n\n const prev = new Array(seq.length);\n result.push(0);\n\n for (let i = 1; i < seq.length; i++) {\n const value = seq[i];\n\n if (seq[result[result.length - 1]] < value) {\n prev[i] = result[result.length - 1];\n result.push(i);\n continue;\n }\n\n let lo = 0;\n let hi = result.length - 1;\n while (lo < hi) {\n const mid = (lo + hi) >> 1;\n if (seq[result[mid]] < value) {\n lo = mid + 1;\n } else {\n hi = mid;\n }\n }\n\n if (value < seq[result[lo]]) {\n if (lo > 0) {\n prev[i] = result[lo - 1];\n }\n result[lo] = i;\n }\n }\n\n let i = result.length;\n let last = result[i - 1];\n while (i-- > 0) {\n result[i] = last;\n last = prev[last];\n }\n\n return result;\n};\n\nexport const wDomUpdate = (newWDomTree: WDom) => {\n const { nr: needRerender } = newWDomTree;\n\n if (needRerender !== undefined && 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 T: typeSortedUpdate,\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 isHydration?: boolean\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 const isEvent = dataKey[0] === 'o' && dataKey[1] === 'n';\n\n if (isHydration && isEvent) {\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 (isEvent) {\n updateEvent(\n element as HTMLElement,\n dataKey,\n dataValue as (e: Event) => void,\n originalProps[dataKey] as (e: Event) => void\n );\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 (dataKey[0] === 'o' && dataKey[1] === 'n') {\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) {\n element = DF();\n } else if (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(children, element, isHydration);\n\n updateProps(props, element, null, isHydration);\n\n addMountedQueue(wDom);\n\n if (tag === 'svg') {\n xmlnsRef.value = '';\n }\n\n return element as HTMLElement;\n};\n\nconst wDomChildrenToDom = (\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 children.forEach((childItem: WDom) => {\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 const htmlElement = element instanceof HTMLElement ? element : null;\n const cssStyle = htmlElement?.style;\n\n if (!cssStyle) return;\n\n const styleProxy = cssStyle 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 const isVirtualType = checkVirtualType(vDom.type);\n if (vDom.isRoot && isVirtualType) {\n return vDom.we;\n }\n\n if (!isVirtualType) {\n return vDom.el as HTMLElement;\n }\n\n return findRealParentElement(getParent(vDom));\n};\n","import { WDom, TagFunctionResolver, RenderType, Props } from '@/types';\nimport { checkCustemComponentFunction, getKey } from '@/utils/predicator';\nimport { getParent, makeParentGetter } from '@/utils';\nimport { typeDeleteUnused } from '@/render';\nimport {\n checkEmptyElement,\n checkSameWDomWithOriginal,\n getWDomType,\n checkExistyKey,\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 remakeNewWDom(\n newWDom,\n !!originalWDom &&\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\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 if (!isNoting && originalWDom) {\n originalWDom.il = true;\n originalWDom.children = undefined;\n }\n if (originalWDom?.tag === 'portal') {\n remakeWDom.tag = 'portal';\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 const isSameText =\n newWDom.type === 't' &&\n isSameType &&\n newWDom.text === (originalWDom && originalWDom.text);\n if (isSameText || newWDom === originalWDom) return 'N';\n\n const existOriginalWDom = originalWDom && originalWDom.type;\n if (!existOriginalWDom) 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\nconst syncResolverChildren = (children: WDom[], infoChidren: WDom[]) => {\n if (children) {\n children.splice(0, children.length);\n\n if (infoChidren) {\n infoChidren.forEach(childrenItem => children.push(childrenItem));\n }\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 syncResolverChildren(children, infoChidren);\n }\n\n const newVDom = vDom.reRender && vDom.reRender();\n\n return newVDom 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 : newWDom.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.\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' && checkExistyKey((newWDom.children || [])[0])) {\n return remakeChildrenForLoopUpdate(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 * Handling virtual DOM of loop-type elements.\n */\nconst remakeChildrenForLoopUpdate = (newWDom: WDom, originalWDom: WDom) => {\n const [remakedChildren, unUsedChildren] = diffLoopChildren(\n newWDom,\n originalWDom\n );\n\n typeDeleteUnused(unUsedChildren);\n\n return remakedChildren;\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.\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 (!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 => {\n const key = getKey(item);\n const origIndex = keyMap.get(key);\n const matched = origIndex !== undefined;\n\n if (matched) {\n keyMap.delete(key);\n used[origIndex] = true;\n }\n\n const child = makeNewWDomTree(\n item,\n matched ? origChildren[origIndex] : undefined\n );\n if (matched) {\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 return [remaked, origChildren.filter((_item, index) => !used[index])];\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\nconst execRedrawQueue = () => {\n redrawQueue.forEach((item: () => void) => {\n item();\n });\n\n redrawQueue.clear();\n redrawQueueTimeout = false;\n};\n","import { componentMap, getComponentKey } 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 compKey = getComponentKey();\n if (!compKey) return;\n\n const component = componentMap.get(compKey);\n if (!component) return;\n\n component.upR.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\n\nexport const runUpdateCallback = () => {\n const compKey = getComponentKey();\n if (!compKey) return;\n\n const comp = componentMap.get(compKey);\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 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 wdomSymbol,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { bindRedraw, componentUpdate } from '@/utils/redraw';\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 ({\n type: 'f', // fragment\n [wdomSymbol]: true,\n children,\n }) as WDom;\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 return needDiffRef.value\n ? componetMakeResolver\n : componetMakeResolver.resolve();\n }\n\n return {\n type: 'e', // element\n [wdomSymbol]: true,\n tag,\n props,\n children,\n } as WDom;\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 || item === false) {\n return { type: null, [wdomSymbol]: true } as WDom;\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = {\n type: 'l', // loop (array mapping)\n [wdomSymbol]: true,\n children,\n } as WDom;\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return { type: 't', [wdomSymbol]: true, text: item } as WDom; // text node\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 * Create an intermediate step for diffing between the existing virtual DOM and the new one during re-rendering\n */\nconst makeWDomResolver = (tag: TagFunction, props: Props, children: WDom[]) => {\n const ctor = tag;\n\n const wrappedChildren = children;\n\n const resolve = createComponentResolver(tag, props, wrappedChildren);\n\n return { ctor, props, children: wrappedChildren, resolve };\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 normalizedComponentMaker = (nextProps: Props): WDom =>\n makeChildrenItem(componentMaker(nextProps));\n const { wrappedComponentMaker, customNode } = wrapComponentMakerIfNeeded(\n normalizedComponentMaker,\n props\n );\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 = () =>\n wDomMaker(componentMaker, compKey, tag, props, children, reRender);\n return reRender;\n};\n\n/**\n * The starting point for redrawing from the re-render method\n */\nconst wDomMaker = (\n componentMaker: (props: Props) => WDom,\n compKey: Props,\n tag: TagFunction,\n props: Props,\n children: WDom[],\n reRender: () => WDom\n) => {\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\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 wrapComponentMakerIfNeeded = (\n componentMaker: (props: Props) => WDom,\n props: Props\n): { wrappedComponentMaker: (props: Props) => WDom; customNode: WDom } => {\n const wrappedComponentMaker = (newProps: Props): WDom => {\n const next = componentMaker(newProps);\n const wrapper = Fragment({}, next);\n next.getParent = () => wrapper;\n return wrapper;\n };\n\n const customNode = wrappedComponentMaker(props);\n\n return { wrappedComponentMaker, customNode };\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","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","checkPlainWDomType","wDom","checkPlainType","typeName","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","checkSameTagElement","checkNormalTypeElement","checkLoopTypeElement","checkExistyKey","getKey","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","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","sequence","callback","mountReadyCallback","runWDomCallbacksFromWDom","wdCBQueue","cleanup","useUpdated","dependencies","upD","upS","def","nextDependencies","checkNeedPushQueue","runUpdatedQueueFromWDom","queue","originalDefs","newDefs","index","DF","CE","t","render","wrapElement","afterElement","isHydration","Dom","wDomToDom","compData","rootDelete","deleteRealDom","typeDelete","parentWDom","parentElement","findRealParentElement","nt","findChildWithRemoveElement","items","count","node","el","typeDeleteUnused","typeSortedReplace","typeAdd","typeSortedUpdate","typeUpdate","getElementFromFragment","newElement","parentEl","nextEl","startFindNextBrotherElement","acc","element","brothers","nextIndex","candidiateBrothers","finedNextEl","findChildFragmentNextElement","parentType","targetEl","bItem","found","typeReplace","orignalElement","updateText","oldProps","updateProps","updateChildren","children","needPlace","childItem","wDomUpdate","created","matchedIndexes","oiSeq","createdCount","nr","stay","getLisPositions","pos","baseAnchor","tail","anchor","i","isNew","needMove","first","clearDiffMeta","seq","prev","lo","hi","mid","last","newWDomTree","needRerender","renderHandlers","originalProps","isEvent","updateEvent","updateStyle","setAttr","k","v","tag","text","isVirtualType","wDomChildrenToDom","childElement","eventKey","newEventHandler","oldEventHandler","eventName","style","oldStyle","orig","htmlElement","cssStyle","styleProxy","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","addReRenderTypeProperty","isNoting","remakeChildrenForDiff","inheritPropForRender","isKeyChecked","syncResolverProps","infoProps","syncResolverChildren","infoChidren","childrenItem","runUpdate","infoVdom","remakeChildrenForUpdate","remakeChildrenForAdd","child","remakeChildrenForLoopUpdate","origChildren","remakedChildren","unUsedChildren","diffLoopChildren","keyMap","used","origIndex","matched","_item","redrawQueue","redrawQueueTimeout","schedule","exec","execRedrawQueue","bindRedraw","componentUpdate","up","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","resolve","normalizedComponentMaker","wrappedComponentMaker","customNode","wrapComponentMakerIfNeeded","reRender","makeReRender","addComponentProps","wDomMaker","newProps","next","wrapper","ref","initValue","nextTick","useRenew"],"mappings":"gFAQa,MAAAA,EAAa,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,EAAkB,IAAsBR,EAAW,MAEnDS,GAAsB,CACjCH,EACAI,IAC4B,CACtB,MAAAC,EAAYT,EAAa,IAAII,CAAO,EAC1C,OAAIK,EACKA,EAAUD,CAAM,EAElB,IACT,EAEaE,GAAuBN,GAA2B,CAC7DN,EAAW,MAAQM,CACrB,EAEaO,GAAqB,CAChCP,EACAC,IACS,CACTP,EAAW,MAAQM,EACnBD,GAAeC,EAASC,CAAI,CAC9B,EAEaO,GAA6BC,GAA2B,CAC1CX,GAAAW,CAC3B,EAEaC,GAA2B,IAAeZ,GAE1Ca,GAAqBX,GAA2B,CACrD,MAAAY,EAAUhB,EAAa,IAAII,CAAO,EACpCY,IACFA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Ac3Q,EAAW,MAC3B,GAAA,CACFY,GAAoBN,CAAO,EACTyO,KAEZ,MAAAqC,EAAaP,EAAelP,CAAK,EACvC,OAAA6P,GAAkBJ,EAAY9Q,EAASmL,EAAK9J,EAAO0H,EAAUiI,CAAQ,EAE9DF,CAAA,QACP,CACApR,EAAW,MAAQ2Q,CACrB,CACF,EAWMU,GAA6B,CACjCR,EACAlP,IACwE,CAClE,MAAAwP,EAAyBO,GAA0B,CACjD,MAAAC,EAAOd,EAAea,CAAQ,EAC9BE,EAAUxO,EAAS,CAAC,EAAGuO,CAAI,EACjC,OAAAA,EAAK,UAAY,IAAMC,EAChBA,CAAA,EAGHR,EAAaD,EAAsBxP,CAAK,EAEvC,MAAA,CAAE,sBAAAwP,EAAuB,WAAAC,EAClC,EAKMI,GAAoB,CACxBpP,EACA9B,EACAmL,EACA9J,EACA0H,EACAiI,IACG,CAGHlP,EAAK,UAAYT,EACjBS,EAAK,UAAYiH,EACjBjH,EAAK,KAAOqJ,EACZrJ,EAAK,QAAU9B,EACf8B,EAAK,SAAWkP,EAEV,MAAA/M,EAAOrE,EAAa,IAAII,CAAO,EACjCiE,IACFA,EAAK,GAAG,MAAQnC,EAEpB,EC/bayP,GAAUC,IAAkB,CAAE,MAAOA,CAAU,GAC/CC,GAAW,IAAM,QAAQ,QAAQ,ECOjCC,GAAW,IAAa,CACnC,MAAM1R,EAAUE,IAEhB,OAAKF,EAIEsO,EAAgBtO,CAAO,EAHrB,IAAM,EAIjB"}
|
|
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/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\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} 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 if (nt === 11 || newWDom.tag === 'portal') {\n findChildWithRemoveElement(newWDom, parent);\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 item.tag !== 'portal'\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 (nt) {\n 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/**\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 if (element) {\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 if (targetEl || (moving.size && moving.has(bItem))) 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 if (!parentWDom || orignalElement.nodeType === 11) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n\n if (parentElement && newWDom.tag !== 'portal') {\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 if (originalWDom && originalWDom.tag === 'portal') {\n remakeWDom.tag = 'portal';\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 { 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 wdomSymbol,\n lmountComponentSet,\n} from '@/utils/universalRef';\nimport { bindRedraw, componentUpdate } from '@/utils/redraw';\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 ({\n type: 'f', // fragment\n nr: undefined,\n [wdomSymbol]: true,\n children,\n }) as WDom;\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 {\n type: 'e', // element\n // Declared on every new node: a diff sets it, and a drawn node keeps it\n // ('N'), so the node keeps its shape and reading it is a plain lookup.\n nr: undefined,\n [wdomSymbol]: true,\n tag,\n props,\n children,\n } as WDom;\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 { type: null, nr: undefined, [wdomSymbol]: true } as WDom;\n } else if (Array.isArray(item)) {\n const nodeParentPointer: NodePointer = { value: undefined };\n const children = remakeChildren(nodeParentPointer, item);\n const node = {\n type: 'l', // loop (array mapping)\n nr: undefined,\n [wdomSymbol]: true,\n children,\n } as WDom;\n nodeParentPointer.value = node;\n\n return node;\n } else if (typeof item === 'string' || typeof item === 'number') {\n return { type: 't', nr: undefined, [wdomSymbol]: true, text: item } as WDom; // text node\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 : ({\n type: wDom.type,\n tag: wDom.tag,\n props: wDom.props,\n text: wDom.text,\n children: wDom.children && [...wDom.children],\n getParent: wDom.getParent,\n [wdomSymbol]: true,\n } as WDom);\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","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","findChildWithRemoveElement","items","count","node","el","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","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":"gFAQa,MAAAA,EAAa,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,MA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