lithent 1.2.6 → 1.2.8

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/src/render.ts CHANGED
@@ -63,6 +63,7 @@ export const wDomUpdate = (newWDomTree: WDom) => {
63
63
  D: typeDelete,
64
64
  R: typeReplace,
65
65
  U: typeUpdate,
66
+ CNSU: typeUpdate,
66
67
  SR: typeSortedReplace,
67
68
  SU: typeSortedUpdate,
68
69
  })[needRerender](newWDomTree);
@@ -124,19 +125,21 @@ const typeSortedReplace = (newWDom: WDom) => {
124
125
  const typeSortedUpdate = (newWDom: WDom) => {
125
126
  typeUpdate(newWDom);
126
127
 
127
- const newElement = getElementFromFragment(newWDom);
128
128
  const parentWDom = getParent(newWDom);
129
- if (parentWDom.type) {
130
- const parentEl = findRealParentElement(parentWDom);
131
- const nextEl = parentWDom.needRerender
132
- ? startFindNextBrotherElement(parentWDom, getParent(parentWDom))
133
- : startFindNextBrotherElement(newWDom, parentWDom);
134
-
135
- if (newElement && parentEl) {
136
- if (nextEl) {
137
- parentEl.insertBefore(newElement, nextEl);
138
- } else {
139
- parentEl.appendChild(newElement);
129
+ if (parentWDom.needRerender !== 'CNSU') {
130
+ const newElement = getElementFromFragment(newWDom);
131
+ if (parentWDom.type) {
132
+ const parentEl = findRealParentElement(parentWDom);
133
+ const nextEl = parentWDom.needRerender
134
+ ? startFindNextBrotherElement(parentWDom, getParent(parentWDom))
135
+ : startFindNextBrotherElement(newWDom, parentWDom);
136
+
137
+ if (newElement && parentEl) {
138
+ if (nextEl) {
139
+ parentEl.insertBefore(newElement, nextEl);
140
+ } else {
141
+ parentEl.appendChild(newElement);
142
+ }
140
143
  }
141
144
  }
142
145
  }
@@ -336,18 +339,11 @@ const updateProps = (
336
339
  [chkRemoveProp, dataValue] = makeAttrDataValue(dataValue);
337
340
 
338
341
  if (chkRemoveProp) {
339
- if (xmlnsRef.value && dataKey !== 'xmlns') {
340
- (element as HTMLElement).setAttributeNS(
341
- null,
342
- getAttrKey(dataKey),
343
- <string>dataValue
344
- );
345
- } else {
346
- (element as HTMLElement).setAttribute(
347
- getAttrKey(dataKey),
348
- <string>dataValue
349
- );
350
- }
342
+ setAttr(
343
+ getAttrKey(dataKey),
344
+ element as HTMLElement,
345
+ dataValue as string
346
+ );
351
347
  }
352
348
  }
353
349
 
@@ -361,6 +357,14 @@ const updateProps = (
361
357
  );
362
358
  };
363
359
 
360
+ const setAttr = (dataKey: string, element: HTMLElement, dataValue: string) => {
361
+ if (xmlnsRef.value && dataKey !== 'xmlns') {
362
+ element.setAttributeNS(null, dataKey, dataValue);
363
+ } else {
364
+ element.setAttribute(dataKey, dataValue);
365
+ }
366
+ };
367
+
364
368
  const makeAttrDataValue = (dataValue: unknown): [boolean, string] => {
365
369
  let allowSetAttr = true;
366
370
  if (typeof dataValue === 'boolean') {
@@ -453,21 +457,19 @@ const updateStyle = (
453
457
  oldStyle: Record<string, string>,
454
458
  element?: HTMLElement | Element | DocumentFragment | Text
455
459
  ) => {
456
- requestAnimationFrame(() => {
457
- const originalStyle = { ...oldStyle };
458
- const elementStyle = (element as HTMLElement)?.style;
459
-
460
- if (elementStyle) {
461
- entries(style).forEach(([styleKey, dataValue]) => {
462
- (elementStyle as any)[styleKey] = dataValue;
463
- delete originalStyle[styleKey];
464
- });
465
-
466
- entries(originalStyle).forEach(
467
- ([styleKey]) => ((elementStyle as any)[styleKey] = '')
468
- );
469
- }
470
- });
460
+ const originalStyle = { ...oldStyle };
461
+ const elementStyle = (element as HTMLElement)?.style;
462
+
463
+ if (elementStyle) {
464
+ entries(style).forEach(([styleKey, dataValue]) => {
465
+ (elementStyle as any)[styleKey] = dataValue;
466
+ delete originalStyle[styleKey];
467
+ });
468
+
469
+ entries(originalStyle).forEach(
470
+ ([styleKey]) => ((elementStyle as any)[styleKey] = '')
471
+ );
472
+ }
471
473
  };
472
474
 
473
475
  const findRealParentElement = (
@@ -29,17 +29,19 @@ const destroy = render(<Loop />, testWrap, document.getElementById('next'));
29
29
  if (import.meta.vitest) {
30
30
  const { it, expect } = import.meta.vitest;
31
31
  it("The 'destroy function' also works well when the loop type is stuck in the middle of the actual DOM.", () => {
32
- expect(testWrap.outerHTML).toBe(
33
- '<ul id="root"> <li>1</li> <li>2</li> <li>3</li> <div class="text-orange-300">4</div><div class="text-orange-300">5</div><div class="text-orange-300">6</div><div class="text-orange-300">7</div><li id="next"> 8 </li> <li>9</li> </ul>'
34
- );
35
- });
36
-
37
- it('The destroy function should work fine.', () => {
38
- destroy();
39
- nextTick().then(() => {
32
+ setTimeout(() => {
40
33
  expect(testWrap.outerHTML).toBe(
41
- '<ul id="root"> <li>1</li> <li>2</li> <li>3</li> <li id="next"> 8 </li> <li>9</li> </ul>'
34
+ '<ul id="root"> <li>1</li> <li>2</li> <li>3</li> <div class="text-orange-300">4</div><div class="text-orange-300">5</div><div class="text-orange-300">6</div><div class="text-orange-300">7</div><li id="next"> 8 </li> <li>9</li> </ul>'
42
35
  );
43
- });
36
+
37
+ nextTick().then(() => {
38
+ it('The destroy function should work fine.', () => {
39
+ destroy();
40
+ expect(testWrap.outerHTML).toBe(
41
+ '<ul id="root"> <li>1</li> <li>2</li> <li>3</li> <li id="next"> 8 </li> <li>9</li> </ul>'
42
+ );
43
+ });
44
+ });
45
+ }, 100);
44
46
  });
45
47
  }
@@ -43,8 +43,10 @@ render(<Root />, testWrap);
43
43
  if (import.meta.vitest) {
44
44
  const { it, expect } = import.meta.vitest;
45
45
  it('Lithent draws the svg correctly.', () => {
46
- expect(testWrap.outerHTML).toBe(
47
- '<div><svg id="toggleSidebarMobileClose" class="w-6 h-6 " fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg><svg class="w-6 h-6" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h6a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h6a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg></div>'
48
- );
46
+ setTimeout(() => {
47
+ expect(testWrap.outerHTML).toBe(
48
+ '<div><svg id="toggleSidebarMobileClose" fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" class="w-6 h-6 "><path fill-rule="evenodd" d="M4.293 4.293a1 1 0 011.414 0L10 8.586l4.293-4.293a1 1 0 111.414 1.414L11.414 10l4.293 4.293a1 1 0 01-1.414 1.414L10 11.414l-4.293 4.293a1 1 0 01-1.414-1.414L8.586 10 4.293 5.707a1 1 0 010-1.414z" clip-rule="evenodd"></path></svg><svg fill="currentColor" viewBox="0 0 20 20" xmlns="http://www.w3.org/2000/svg" class="w-6 h-6"><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h6a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path><path fill-rule="evenodd" d="M3 5a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1zM3 10a1 1 0 011-1h6a1 1 0 110 2H4a1 1 0 01-1-1zM3 15a1 1 0 011-1h12a1 1 0 110 2H4a1 1 0 01-1-1z" clip-rule="evenodd"></path></svg></div>'
49
+ );
50
+ }, 100);
49
51
  });
50
52
  }
@@ -68,6 +68,7 @@ export type RenderType =
68
68
  | 'U' // UPDATE
69
69
  | 'SR' // S_REPLACE
70
70
  | 'SU' // S_UPDATE
71
+ | 'CNSU' // CHILD NOT SORTED AT LOOP
71
72
  | 'N'; // NONE
72
73
 
73
74
  export type ComponentSubKey =
@@ -1,2 +0,0 @@
1
- (function(){const t=document.createElement("link").relList;if(t&&t.supports&&t.supports("modulepreload"))return;for(const c of document.querySelectorAll('link[rel="modulepreload"]'))o(c);new MutationObserver(c=>{for(const r of c)if(r.type==="childList")for(const s of r.addedNodes)s.tagName==="LINK"&&s.rel==="modulepreload"&&o(s)}).observe(document,{childList:!0,subtree:!0});function n(c){const r={};return c.integrity&&(r.integrity=c.integrity),c.referrerPolicy&&(r.referrerPolicy=c.referrerPolicy),c.crossOrigin==="use-credentials"?r.credentials="include":c.crossOrigin==="anonymous"?r.credentials="omit":r.credentials="same-origin",r}function o(c){if(c.ep)return;c.ep=!0;const r=n(c);fetch(c.href,r)}})();const k=e=>typeof e=="object"&&!("resolve"in e),x=(e,t)=>k(e)&&e.type===t,xe=(e,t)=>"ctor"in e?e.ctor===(t==null?void 0:t.ctor):e===(t==null?void 0:t.ctor),be=(e,t)=>{var n,o;return k(e)&&(t==null?void 0:t.type)==="fragment"&&((n=t==null?void 0:t.children)==null?void 0:n.length)===((o=e==null?void 0:e.children)==null?void 0:o.length)},Se=(e,t)=>{var n,o;return k(e)&&(t==null?void 0:t.type)==="element"&&(t==null?void 0:t.tag)===e.tag&&((n=t==null?void 0:t.children)==null?void 0:n.length)===((o=e==null?void 0:e.children)==null?void 0:o.length)},q=(e,t)=>k(e)&&(t==null?void 0:t.type)===e.type&&(e.type!=="loop"||e.type==="loop"&&E(h((e.children||[])[0]))&&E(h((t.children||[])[0]))),h=e=>{var t,n;return((t=e==null?void 0:e.compProps)==null?void 0:t.key)??((n=e==null?void 0:e.props)==null?void 0:n.key)},y=e=>e&&["fragment","loop"].includes(e),N=e=>typeof e=="function"&&!Z(e)||typeof e=="object"&&"resolve"in e,Z=e=>typeof e=="function"&&e===M,K=e=>k(e)&&!e.type,E=e=>e!=null,J=(e,t)=>e==="style"&&typeof t=="object",Te=(e,t)=>e==="ref"&&typeof t=="object",Ne=e=>e.nodeType===1&&e.tagName==="OPTION",Fe=e=>e.nodeType===1&&e.tagName==="TEXTAREA",Ue=e=>e.nodeType===1&&["radio","checkbox"].includes(e.type),_e=e=>{let t="et";return N(e)?t="c":x(e,"fragment")?t="f":x(e,"element")?t="e":x(e,"loop")?t="l":x(e,"text")?t="t":K(e)&&(t="et"),t},Ae={c:xe,l:q,t:q,e:Se,f:be,et:q},v=e=>e.getParent&&e.getParent(),g=Object.entries,w=Object.keys,F=Object.assign,C={value:""},R={value:{}},B={value:!1},u=new WeakMap,Oe=e=>{u.set(e,{vd:{value:null},up:()=>{},upR:[],upS:{value:0},upD:[],upCB:[],mts:[],umts:[]})},m=()=>R.value,D=(e,t)=>u.get(e)[t],Me=e=>R.value=e,Le=e=>{R.value=e,Oe(e)},Ie=e=>{u.get(m()).umts.push(e)},U=e=>{const{compKey:t}=e;t&&qe(t),W(e)},W=e=>{(e.children||[]).forEach(t=>{t.compKey?U(t):W(t)})},qe=e=>{const t=u.get(e);t&&(t.umts.forEach(n=>n()),t.umts=[],u.delete(e))};let Q=[];const Y=()=>{Q.forEach(e=>Qe(e)),Q=[]},Be=e=>{e.compKey&&Q.push(e)},ee=e=>u.get(m()).mts.push(e),Qe=e=>{const{compKey:t}=e;if(t){const n=u.get(t),o=n==null?void 0:n.mts,c=n==null?void 0:n.upS;R.value=t,c&&(c.value=0),o&&(n.mts=[],o.forEach(r=>{const s=r();s&&Ie(s)}))}},X=(e,t=()=>[])=>{const n=u.get(m()),{upD:o,upS:c}=n,r=o[c.value];if(r&&je(r,t())){const s=e();s&&n.upCB.push(s)}o[c.value]=t(),c.value+=1},Ve=e=>{const{compKey:t}=e;if(t){const n=u.get(t),o=n==null?void 0:n.upCB,c=n==null?void 0:n.upS;R.value=t,c&&(c.value=0),e.ctor&&o&&(n.upCB=[],o.forEach(r=>r()))}},je=(e,t)=>e.length?e.some((n,o)=>n!==t[o]):!0,$=e=>e==="className"?"class":e,te=e=>e.replace(/^on(.*)/,(t,n)=>n.toLowerCase()),z=()=>new DocumentFragment,H=e=>document.createElement(e),Ye=(e,t,n)=>{t??(t=document.body),e.isRoot=!0,e.wrapElement=t;const o=A(e);return n?(e.afterElement=n,t.insertBefore(o,n)):t.appendChild(o),Y(),()=>{var c;const r=(c=u.get(e.compProps||{}))==null?void 0:c.vd.value;r&&(U(r),_(r),ze(r))}},ne=e=>{const{needRerender:t}=e;t&&t!=="N"&&({A:le,D:G,R:Je,U:de,SR:re,SU:Ge}[t](e),delete e.needRerender)},_=e=>{e.props&&e.el&&ie(e.props,e.el),(e.children||[]).forEach(t=>{_(t)})},ze=e=>{oe(e,e.wrapElement)},G=e=>{e.oldProps&&e.el&&ie(e.oldProps,e.el),oe(e,P(v(e)))},oe=(e,t)=>{var n,o;t&&e.el&&(((n=e.el)==null?void 0:n.nodeType)===1?t.removeChild(e.el):((o=e.el)==null?void 0:o.nodeType)===11&&ce(e,t),delete e.el)},ce=(e,t)=>{((e==null?void 0:e.oldChildren)||(e==null?void 0:e.children)||[]).forEach(n=>{var o,c;((o=n.el)==null?void 0:o.nodeType)===1?t.removeChild(n==null?void 0:n.el):((c=n.el)==null?void 0:c.nodeType)===11&&ce(n,t)})},re=e=>{G(e),le(e)},Ge=e=>{de(e);const t=se(e),n=v(e);if(n.type){const o=P(n),c=n.needRerender?T(n,v(n)):T(e,n);t&&o&&(c?o.insertBefore(t,c):o.appendChild(t))}},se=e=>y(e.type)?((e==null?void 0:e.children)||[]).reduce((t,n)=>{const o=se(n);return o&&t.appendChild(o),t},z()):e.el,le=e=>{const t=A(e),n=v(e);if(n.type){const o=P(n),c=T(e,n);o&&(c?o.insertBefore(t,c):o.appendChild(t),Y())}},T=(e,t)=>{const n=t.children||[],c=n.indexOf(e)+1,r=n.slice(c),s=ue(r),i=t.type||"";if(s)return s;if(!t.isRoot&&y(i))return T(t,v(t));if(t.isRoot&&y(i)&&t.afterElement)return t.afterElement},ue=e=>e.reduce((t,n)=>{const o=n.type,c=n.el,r=o&&y(o);return t||(r?ue(n.children||[]):c&&c.nodeType!==11?c:t)},void 0),Je=e=>{const t=v(e),n=e.el;if(t.type&&n)if(n.nodeType===11)re(e);else{const o=P(t),c=A(e);o&&o.replaceChild(c,n),Y()}},ie=(e,t)=>{g(e||{}).forEach(([n,o])=>{n.match(/^on/)&&t.removeEventListener(te(n),o)})},de=e=>{var t;const n=e.el;if(e.type==="text"){Xe(e);return}if(n){const{oldProps:o,props:c}=e;fe(c,n,o),delete e.oldProps,e.tag==="input"&&(n.value=String(((t=e==null?void 0:e.props)==null?void 0:t.value)||""))}(e.children||[]).forEach(o=>ne(o)),Ve(e)},Xe=e=>{const t=e.el;t&&(t.nodeValue=String(e.text))},fe=(e,t,n)=>{const o={...n};g(e||{}).forEach(([c,r])=>{let s=!0;c==="key"||(c==="innerHTML"&&typeof r=="string"?t.innerHTML=r:J(c,r)?Ke(r,J(c,o.style)?o.style:{},t):Te(c,r)?r.value=t:c.match(/^on/)?Ze(t,c,r,o[c]):Ue(t)&&c==="checked"?t.checked=!!r:Fe(t)&&c==="value"?t.value=r:Ne(t)&&c==="selected"?t.selected=!!r:c&&([s,r]=$e(r),s&&(C.value&&c!=="xmlns"?t.setAttributeNS(null,$(c),r):t.setAttribute($(c),r)))),s&&delete o[c]}),w(o).forEach(c=>t.removeAttribute(c))},$e=e=>{let t=!0;return typeof e=="boolean"&&(e||(t=!1),e=""),[t,String(e)]},A=e=>{let t;const{type:n,tag:o,text:c,props:r,children:s=[]}=e,i=y(n);return o==="svg"&&(C.value=String(r==null?void 0:r.xmlns)),i?t=z():n==="element"&&o?t=C.value?document.createElementNS(C.value,o):H(o):n==="text"&&E(c)?t=document.createTextNode(String(c)):t=H("e"),He(s,t),fe(r,t),e.el=t,Be(e),o==="svg"&&(C.value=""),t},He=(e,t)=>{const n=e.reduce((o,c)=>(c.type&&o.appendChild(A(c)),o),z());t&&n.hasChildNodes()&&t.appendChild(n)},Ze=(e,t,n,o)=>{const c=te(t);o!==n&&(o&&e.removeEventListener(c,o),n&&e.addEventListener(c,n))},Ke=(e,t,n)=>{requestAnimationFrame(()=>{const o={...t},c=n==null?void 0:n.style;c&&(g(e).forEach(([r,s])=>{c[r]=s,delete o[r]}),g(o).forEach(([r])=>c[r]=""))})},P=e=>{const t=y(e.type);return e.isRoot&&t?e.wrapElement:t?P(v(e)):e.el},O=(e,t)=>we(e,Ae[_e(e)](e,t),t),we=(e,t,n)=>{const o=ot(e,t,n),c=[o,t,n],r=We(...c);return o.children=ct(...c),o.needRerender=r,De(o,n,r),o},De=(e,t,n)=>{n!=="A"&&t&&(e.el=t.el),n&&["D","R","SR"].includes(n)&&(t!=null&&t.compKey&&(U(t),_(t)),e.oldChildren=t==null?void 0:t.children),e.oldProps=t==null?void 0:t.props},We=(e,t,n)=>{var o;const c=n&&n.type,r=K(e),i=!e.isRoot&&n&&((o=v(n))==null?void 0:o.type),f=h(e),d=i==="loop"&&E(f),p=e.type==="text"&&t&&e.text===(n==null?void 0:n.text);let a;return r?a="D":p?a="N":c?t?a=d?"SU":"U":a=d?"SR":"R":a="A",a},et=(e,t)=>{e&&t!==e&&(w(e).forEach(n=>delete e[n]),g(t||{}).forEach(([n,o])=>e[n]=o))},tt=(e,t)=>{e&&t!==e&&(e.splice(0,e.length),t&&t.forEach(n=>e.push(n)))},nt=(e,t)=>{const{compProps:n,compChild:o}=e,{props:c,children:r}=t;return n&&et(n,c),o&&tt(o,r),e.reRender&&e.reRender()},ot=(e,t,n)=>N(e)?t&&n?nt(n,e):e.resolve():e,ct=(e,t,n)=>t&&n?st(e,n):rt(e),rt=e=>(e.children||[]).map(t=>F(O(t),{getParent:()=>e})),st=(e,t)=>e.type==="loop"&&E(h((e.children||[])[0]))?lt(e,t):(e.children||[]).map((n,o)=>F(O(n,(t.children||[])[o]),{getParent:()=>e})),lt=(e,t)=>{const[n,o]=ut(e,t);return o.map(c=>{U(c),_(c),G(c)}),n},ut=(e,t)=>{const n=[...e.children||[]],o=[...t.children||[]];return[n.map(r=>{const s=it(r,o),i=O(r,s);return s&&o.splice(o.indexOf(s),1),i.getParent=()=>e,i}),o]},it=(e,t)=>t.find(n=>h(n)===h(e));let b=[],V=!1;const ae=(e,t)=>{u.get(e).up=()=>{b.push({compKey:e,exec:t}),V||(V=!0,queueMicrotask(ft))}},dt=e=>()=>{var t;const n=(t=u.get(e))==null?void 0:t.up;let o=!1;return n&&(n(),o=!0),o},pe=(e,t)=>{(e.children||[]).forEach(n=>{const o=n.compKey;o&&t.push(o),pe(n,t)})},ft=()=>{let e=[];b.forEach(o=>{var c,r;const s=(r=(c=u.get(o.compKey))==null?void 0:c.vd)==null?void 0:r.value;s&&pe(s,e)});const t=[],n=b.reduce((o,c)=>{const{compKey:r}=c;return e.includes(r)||t.includes(r)||(t.push(r),o.push(c)),o},[]);for(;n.length;){const o=n.shift();o&&o.exec()}b=[],V=!1},ve=(e,t=()=>[])=>{u.get(m()).upR.push(()=>X(e,t)),X(e,t)},at=()=>{var e;const t=(e=u.get(m()))==null?void 0:e.upR;t!=null&&t.length&&t.forEach(n=>n())},M=(e,...t)=>({type:"fragment",children:t}),l=(e,t,...n)=>{const o={value:void 0},c=t||{},r=ge(o,n),s=yt(e,c,r);return N(s)||(o.value=s),s},he=e=>(t,n)=>e,ye=(e,t,n,o)=>{var c;B.value=!0;const r=Ce(e,t,n),s=O(r,o),{isRoot:i,getParent:f,wrapElement:d,afterElement:p}=o;if(s.getParent=f,!i&&f){const a=((c=f())==null?void 0:c.children)||[],L=a.indexOf(o);a.splice(L,1,s)}else s.isRoot=!0,s.wrapElement=d,s.afterElement=p;B.value=!1,ne(s)},Ce=(e,t,n)=>({tagName:e.name,ctor:e,props:t,children:n,resolve:(s=t)=>{Le(s);const f=e(t,n)(dt(s),t,n),d=pt(f,s,e,t,n),p=d;return ae(s,()=>ye(e,t,n,p)),D(s,"vd").value=d,d}}),pt=(e,t,n,o,c)=>{const r=e(o);if(r.reRender)throw new Error('Avoid the case where the first element of a component is a component. Instead of "mount(()=>()=><Component />)" replace it with something like "mount(()=>()=><Fragment><Component /></Fragment>)".');return Ee(r,t,n,o,c,vt(e,t,n,o,c)),r},vt=(e,t,n,o,c)=>{const r=()=>ht(e,t,n,o,c,r);return r},ht=(e,t,n,o,c,r)=>{Me(t),at();const s=e(o);return ae(t,()=>ye(n,o,c,s)),Ee(s,t,n,o,c,r),D(t,"vd").value=s,s},Ee=(e,t,n,o,c,r)=>{F(e,{compProps:o,compChild:c,ctor:n,tagName:n.name,compKey:t,reRender:r})},yt=(e,t,n)=>{if(Z(e))return M(t,...n);if(N(e)){const o=Ce(e,t,n);return B.value?o:o.resolve()}return{type:"element",tag:e,props:t,children:n}},ge=(e,t)=>t.map(n=>F(Ct(n),{getParent:()=>e.value})),Ct=e=>{if(e==null||e===!1)return{type:null};if(Array.isArray(e)){const t={value:void 0},o={type:"loop",children:ge(t,e)};return t.value=o,o}else if(typeof e=="string"||typeof e=="number")return{type:"text",text:e};return e},Et=e=>({value:e}),j=(e,t)=>{let n=e;return{get value(){return n},get v(){return n},set value(o){n=o,t()},set v(o){n=o,t()}}},gt=e=>{let t=e;return{get value(){return t()},get v(){return t()},set value(n){throw new Error("You can't change 'computed'")},set v(n){throw new Error("You can't change 'computed'")}}},kt=(e,t=()=>{},n=()=>[])=>{ee(()=>(e(),t)),ve(()=>(t&&t(),e),n)},ke=new Map,S={},Rt=e=>{const t=Symbol();return ke.set(t,e),n=>(S[t]??(S[t]=[]),S[t].push(n),mt(t))},mt=e=>new Proxy(ke.get(e),{get(t,n){return t[n]},set(t,n,o){t[n]=o;const c=S[e],r=[];return c.forEach(s=>{s()||r.push(s)}),r.forEach(s=>c.splice(c.indexOf(s),1)),!0}}),Pt=he((e,t,n)=>{const o=j(1,e),c=j('"destructuring" the "props" value directly from the mount function will cause referencing issues, so if you want to use it, you need to "destructuring" it from the internal function (updater).',e),r=()=>t.parentValue,s=t.parentValue,i=gt(()=>o.v+d+t.parentValue),f=Rt({text:"s",count:0})(e);let d=t.parentValue;const p=Et(null),a=()=>{o.v=o.v+1,d+=1},L=I=>{c.v=I.target.value},Re=()=>{f.count+=1,f.text+="1"},me=()=>(console.log("MOUNTED",p),()=>console.log("UNMOUNT")),Pe=()=>(console.log("UPDATE - parentValue"),()=>console.log("UPDATED"));return ee(me),ve(Pe,()=>[t.parentValue]),kt(()=>console.log("INJECT"),()=>console.log("CLEAN_UP"),()=>[o.v]),({parentValue:I})=>l(M,null,l("div",null,l("textarea",{value:c.v,onInput:L,style:{width:"300px",height:"100px"}})),l("div",null,c.v),l("div",null,l("div",{style:{color:"blue"}},"parentValueFromRef: ",t.parentValue," (working)"),l("div",{style:{color:"blue"}},"parentValueFromFunction: ",r()," (working)"),l("div",{style:{color:"blue"}},"parentValueFromUpdaterDestructuring: ",I," (working)"),l("div",{style:{color:"red"}},"parentValueFromMounterDestructuring: ",s," (not working)")),l("div",null,l("div",{ref:p},"count: ",o.v),l("div",null,"sum: ",o.v+d+t.parentValue),l("div",null,"sum(computed): ",i.v),l("div",null,"notRefValue: ",d),l("div",null,"localStore(text): ",f.text),l("div",null,"localStore(count): ",f.count)),l("button",{onClick:a},"Increase"),l("button",{onClick:Re},"localStoreUpdate"),n)}),xt=he(e=>{const t=j(7,e),n=()=>{t.v=t.v+1},o=()=>{t.v=t.v-1};return()=>l(M,null,l(Pt,{parentValue:t.v},l("button",{onClick:n},"Increase - Parent")),l("button",{onClick:o},"Decrease - Parent"))}),bt=l(xt,null);Ye(bt,document.getElementById("root"));
2
- //# sourceMappingURL=index-834a5800.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index-834a5800.js","sources":["../../../dist/lithent.mjs","../../../helper/dist/lithentHelper.mjs","../../src/index.tsx"],"sourcesContent":["const checkPlainWDomType = (wDom) => typeof wDom === \"object\" && !(\"resolve\" in wDom);\nconst checkPlainType = (wDom, typeName) => checkPlainWDomType(wDom) && wDom.type === typeName;\nconst checkSameCustomComponent = (newWDom, originalWDom) => \"ctor\" in newWDom ? newWDom.ctor === (originalWDom == null ? void 0 : originalWDom.ctor) : newWDom === (originalWDom == null ? void 0 : originalWDom.ctor);\nconst checkSameFragment = (newWDom, originalWDom) => {\n var _a, _b;\n return checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === \"fragment\" && ((_a = originalWDom == null ? void 0 : originalWDom.children) == null ? void 0 : _a.length) === ((_b = newWDom == null ? void 0 : newWDom.children) == null ? void 0 : _b.length);\n};\nconst checkSameTagElement = (newWDom, originalWDom) => {\n var _a, _b;\n return checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === \"element\" && (originalWDom == null ? void 0 : originalWDom.tag) === newWDom.tag && ((_a = originalWDom == null ? void 0 : originalWDom.children) == null ? void 0 : _a.length) === ((_b = newWDom == null ? void 0 : newWDom.children) == null ? void 0 : _b.length);\n};\nconst checkNormalTypeElement = (newWDom, originalWDom) => checkPlainWDomType(newWDom) && (originalWDom == null ? void 0 : originalWDom.type) === newWDom.type && (newWDom.type !== \"loop\" || newWDom.type === \"loop\" && checkExisty(getKey((newWDom.children || [])[0])) && checkExisty(getKey((originalWDom.children || [])[0])));\nconst getKey = (target) => {\n var _a, _b;\n return ((_a = target == null ? void 0 : target.compProps) == null ? void 0 : _a.key) ?? ((_b = target == null ? void 0 : target.props) == null ? void 0 : _b.key);\n};\nconst checkVirtualType = (type) => type && [\"fragment\", \"loop\"].includes(type);\nconst checkCustemComponentFunction = (target) => typeof target === \"function\" && !checkFragmentFunction(target) || typeof target === \"object\" && \"resolve\" in target;\nconst checkFragmentFunction = (target) => typeof target === \"function\" && target === Fragment;\nconst checkEmptyElement = (wDom) => checkPlainWDomType(wDom) && !wDom.type;\nconst checkExisty = (value) => value !== null && value !== void 0;\nconst checkStyleData = (dataKey, dataValue) => dataKey === \"style\" && typeof dataValue === \"object\";\nconst checkRefData = (dataKey, dataValue) => dataKey === \"ref\" && typeof dataValue === \"object\";\nconst checkOptionElement = (element) => element.nodeType === 1 && element.tagName === \"OPTION\";\nconst checkTextareaElement = (element) => element.nodeType === 1 && element.tagName === \"TEXTAREA\";\nconst checkCheckableElement = (element) => element.nodeType === 1 && [\"radio\", \"checkbox\"].includes(element.type);\nconst getWDomType = (wDom) => {\n let result = \"et\";\n if (checkCustemComponentFunction(wDom)) {\n result = \"c\";\n } else if (checkPlainType(wDom, \"fragment\")) {\n result = \"f\";\n } else if (checkPlainType(wDom, \"element\")) {\n result = \"e\";\n } else if (checkPlainType(wDom, \"loop\")) {\n result = \"l\";\n } else if (checkPlainType(wDom, \"text\")) {\n result = \"t\";\n } else if (checkEmptyElement(wDom)) {\n result = \"et\";\n }\n return result;\n};\nconst checkSameWDomWithOriginal = {\n c: checkSameCustomComponent,\n l: checkNormalTypeElement,\n t: checkNormalTypeElement,\n e: checkSameTagElement,\n f: checkSameFragment,\n et: checkNormalTypeElement\n};\nconst getParent = (vDom) => vDom.getParent && vDom.getParent();\nconst entries = Object.entries;\nconst keys = Object.keys;\nconst assign = Object.assign;\nconst xmlnsRef = { value: \"\" };\nconst compKeyRef = { value: {} };\nconst needDiffRef = { value: false };\nconst componentRef = /* @__PURE__ */ new WeakMap();\nconst setComponetRef = (compKey) => {\n componentRef.set(compKey, {\n vd: { value: null },\n up: () => {\n },\n upR: [],\n upS: { value: 0 },\n upD: [],\n upCB: [],\n mts: [],\n umts: []\n });\n};\nconst getComponentKey = () => compKeyRef.value;\nconst getComponentSubInfo = (compKey, subKey) => componentRef.get(compKey)[subKey];\nconst initUpdateHookState = (compKey) => compKeyRef.value = compKey;\nconst initMountHookState = (compKey) => {\n compKeyRef.value = compKey;\n setComponetRef(compKey);\n};\nconst unmount = (effectAction) => {\n componentRef.get(getComponentKey()).umts.push(effectAction);\n};\nconst runUnmountQueueFromWDom = (newWDom) => {\n const { compKey } = newWDom;\n if (compKey) {\n removeItem(compKey);\n }\n recursiveRunUnmount(newWDom);\n};\nconst recursiveRunUnmount = (wDom) => {\n (wDom.children || []).forEach((item) => {\n const childComKey = item.compKey;\n if (childComKey) {\n runUnmountQueueFromWDom(item);\n } else {\n recursiveRunUnmount(item);\n }\n });\n};\nconst removeItem = (compKey) => {\n const subInfo = componentRef.get(compKey);\n if (subInfo) {\n subInfo.umts.forEach((effect) => effect());\n subInfo.umts = [];\n componentRef.delete(compKey);\n }\n};\nlet mountedQueue = [];\nconst execMountedQueue = () => {\n mountedQueue.forEach((item) => runMountedQueueFromWDom(item));\n mountedQueue = [];\n};\nconst addMountedQueue = (wDom) => {\n if (wDom.compKey) {\n mountedQueue.push(wDom);\n }\n};\nconst mountCallback = (effectAction) => componentRef.get(getComponentKey()).mts.push(effectAction);\nconst runMountedQueueFromWDom = (newWDom) => {\n const { compKey } = newWDom;\n if (compKey) {\n const component = componentRef.get(compKey);\n const queue = component == null ? void 0 : component.mts;\n const sequence = component == null ? void 0 : component.upS;\n compKeyRef.value = compKey;\n if (sequence) {\n sequence.value = 0;\n }\n if (queue) {\n component.mts = [];\n queue.forEach((effect) => {\n const callback = effect();\n if (callback) {\n unmount(callback);\n }\n });\n }\n }\n};\nconst useUpdated = (effectAction, dependencies = () => []) => {\n const component = componentRef.get(getComponentKey());\n const { upD, upS } = component;\n const def = upD[upS.value];\n if (def && checkNeedPushQueue(def, dependencies())) {\n const callback = effectAction();\n if (callback) {\n component.upCB.push(callback);\n }\n }\n upD[upS.value] = dependencies();\n upS.value += 1;\n};\nconst runUpdatedQueueFromWDom = (newWDom) => {\n const { compKey } = newWDom;\n if (compKey) {\n const component = componentRef.get(compKey);\n const queue = component == null ? void 0 : component.upCB;\n const sequence = component == null ? void 0 : component.upS;\n compKeyRef.value = compKey;\n if (sequence) {\n sequence.value = 0;\n }\n if (newWDom.ctor && queue) {\n component.upCB = [];\n queue.forEach((effect) => effect());\n }\n }\n};\nconst checkNeedPushQueue = (originalDefs, newDefs) => !originalDefs.length ? true : originalDefs.some((def, index) => def !== newDefs[index]);\nconst getAttrKey = (keyName) => keyName === \"className\" ? \"class\" : keyName;\nconst getEventName = (eventKey) => eventKey.replace(/^on(.*)/, (_match, p1) => p1.toLowerCase());\nconst DF = () => new DocumentFragment();\nconst CE = (t) => document.createElement(t);\nconst render = (wDom, wrapElement, afterElement) => {\n wrapElement ?? (wrapElement = document.body);\n wDom.isRoot = true;\n wDom.wrapElement = wrapElement;\n const Dom = wDomToDom(wDom);\n if (afterElement) {\n wDom.afterElement = afterElement;\n wrapElement.insertBefore(Dom, afterElement);\n } else {\n wrapElement.appendChild(Dom);\n }\n execMountedQueue();\n return () => {\n var _a;\n const component = (_a = componentRef.get(wDom.compProps || {})) == null ? void 0 : _a.vd.value;\n if (component) {\n runUnmountQueueFromWDom(component);\n recursiveRemoveEvent(component);\n rootDelete(component);\n }\n };\n};\nconst wDomUpdate = (newWDomTree) => {\n const { needRerender } = newWDomTree;\n if (needRerender && needRerender !== \"N\") {\n ({\n A: typeAdd,\n D: typeDelete,\n R: typeReplace,\n U: typeUpdate,\n SR: typeSortedReplace,\n SU: typeSortedUpdate\n })[needRerender](newWDomTree);\n delete newWDomTree.needRerender;\n }\n};\nconst recursiveRemoveEvent = (originalWDom) => {\n if (originalWDom.props && originalWDom.el) {\n removeEvent(originalWDom.props, originalWDom.el);\n }\n (originalWDom.children || []).forEach((childItem) => {\n recursiveRemoveEvent(childItem);\n });\n};\nconst rootDelete = (newWDom) => {\n deleteRealDom(newWDom, newWDom.wrapElement);\n};\nconst typeDelete = (newWDom) => {\n if (newWDom.oldProps && newWDom.el) {\n removeEvent(newWDom.oldProps, newWDom.el);\n }\n deleteRealDom(\n newWDom,\n findRealParentElement(getParent(newWDom))\n );\n};\nconst deleteRealDom = (newWDom, parent) => {\n var _a, _b;\n if (parent && newWDom.el) {\n if (((_a = newWDom.el) == null ? void 0 : _a.nodeType) === 1) {\n parent.removeChild(newWDom.el);\n } else if (((_b = newWDom.el) == null ? void 0 : _b.nodeType) === 11) {\n findChildWithRemoveElement(newWDom, parent);\n }\n delete newWDom.el;\n }\n};\nconst findChildWithRemoveElement = (newWDom, parent) => {\n ((newWDom == null ? void 0 : newWDom.oldChildren) || (newWDom == null ? void 0 : newWDom.children) || []).forEach((item) => {\n var _a, _b;\n if (((_a = item.el) == null ? void 0 : _a.nodeType) === 1) {\n parent.removeChild(item == null ? void 0 : item.el);\n } else if (((_b = item.el) == null ? void 0 : _b.nodeType) === 11) {\n findChildWithRemoveElement(item, parent);\n }\n });\n};\nconst typeSortedReplace = (newWDom) => {\n typeDelete(newWDom);\n typeAdd(newWDom);\n};\nconst typeSortedUpdate = (newWDom) => {\n typeUpdate(newWDom);\n const newElement = getElementFromFragment(newWDom);\n const parentWDom = getParent(newWDom);\n if (parentWDom.type) {\n const parentEl = findRealParentElement(parentWDom);\n const nextEl = parentWDom.needRerender ? startFindNextBrotherElement(parentWDom, getParent(parentWDom)) : startFindNextBrotherElement(newWDom, parentWDom);\n if (newElement && parentEl) {\n if (nextEl) {\n parentEl.insertBefore(newElement, nextEl);\n } else {\n parentEl.appendChild(newElement);\n }\n }\n }\n};\nconst getElementFromFragment = (newWDom) => {\n if (checkVirtualType(newWDom.type)) {\n return ((newWDom == null ? void 0 : newWDom.children) || []).reduce((acc, item) => {\n const element = getElementFromFragment(item);\n if (element) {\n acc.appendChild(element);\n }\n return acc;\n }, DF());\n }\n return newWDom.el;\n};\nconst typeAdd = (newWDom) => {\n const newElement = wDomToDom(newWDom);\n const parentWDom = getParent(newWDom);\n if (parentWDom.type) {\n const parentEl = findRealParentElement(parentWDom);\n const nextEl = startFindNextBrotherElement(newWDom, parentWDom);\n if (parentEl) {\n if (nextEl) {\n parentEl.insertBefore(newElement, nextEl);\n } else {\n parentEl.appendChild(newElement);\n }\n execMountedQueue();\n }\n }\n};\nconst startFindNextBrotherElement = (wDom, parentWDom) => {\n const brothers = parentWDom.children || [];\n const index = brothers.indexOf(wDom);\n const nextIndex = index + 1;\n const candidiateBrothers = brothers.slice(nextIndex);\n const finedNextEl = findChildFragmentNextElement(candidiateBrothers);\n const parentType = parentWDom.type || \"\";\n if (finedNextEl) {\n return finedNextEl;\n }\n if (!parentWDom.isRoot && checkVirtualType(parentType)) {\n return startFindNextBrotherElement(parentWDom, getParent(parentWDom));\n } else if (parentWDom.isRoot && checkVirtualType(parentType) && parentWDom.afterElement) {\n return parentWDom.afterElement;\n }\n return void 0;\n};\nconst findChildFragmentNextElement = (candidiateBrothers) => candidiateBrothers.reduce(\n (targetEl, bItem) => {\n const type = bItem.type;\n const el = bItem.el;\n const isFragment = type && checkVirtualType(type);\n if (targetEl) {\n return targetEl;\n } else if (isFragment) {\n return findChildFragmentNextElement(bItem.children || []);\n } else if (el && el.nodeType !== 11) {\n return el;\n }\n return targetEl;\n },\n void 0\n);\nconst typeReplace = (newWDom) => {\n const parentWDom = getParent(newWDom);\n const orignalElement = newWDom.el;\n if (parentWDom.type && orignalElement) {\n if (orignalElement.nodeType === 11) {\n typeSortedReplace(newWDom);\n } else {\n const parentElement = findRealParentElement(parentWDom);\n const newElement = wDomToDom(newWDom);\n if (parentElement) {\n parentElement.replaceChild(newElement, orignalElement);\n }\n execMountedQueue();\n }\n }\n};\nconst removeEvent = (oldProps, element) => {\n entries(oldProps || {}).forEach(([dataKey, dataValue]) => {\n if (dataKey.match(/^on/)) {\n element.removeEventListener(\n getEventName(dataKey),\n dataValue\n );\n }\n });\n};\nconst typeUpdate = (newWDom) => {\n var _a;\n const element = newWDom.el;\n if (newWDom.type === \"text\") {\n updateText(newWDom);\n return;\n }\n if (element) {\n const { oldProps, props } = newWDom;\n updateProps$1(props, element, oldProps);\n delete newWDom.oldProps;\n if (newWDom.tag === \"input\") {\n element.value = String(((_a = newWDom == null ? void 0 : newWDom.props) == null ? void 0 : _a.value) || \"\");\n }\n }\n (newWDom.children || []).forEach((childItem) => wDomUpdate(childItem));\n runUpdatedQueueFromWDom(newWDom);\n};\nconst updateText = (newWDom) => {\n const element = newWDom.el;\n if (element) {\n element.nodeValue = String(newWDom.text);\n }\n};\nconst updateProps$1 = (props, element, oldProps) => {\n const originalProps = { ...oldProps };\n entries(props || {}).forEach(([dataKey, dataValue]) => {\n let chkRemoveProp = true;\n if (dataKey === \"key\")\n ;\n else if (dataKey === \"innerHTML\" && typeof dataValue === \"string\") {\n element.innerHTML = dataValue;\n } else if (checkStyleData(dataKey, dataValue)) {\n updateStyle(\n dataValue,\n checkStyleData(dataKey, originalProps.style) ? originalProps.style : {},\n element\n );\n } else if (checkRefData(dataKey, dataValue)) {\n dataValue.value = element;\n } else if (dataKey.match(/^on/)) {\n updateEvent(\n element,\n dataKey,\n dataValue,\n originalProps[dataKey]\n );\n } else if (checkCheckableElement(element) && dataKey === \"checked\") {\n element.checked = !!dataValue;\n } else if (checkTextareaElement(element) && dataKey === \"value\") {\n element.value = dataValue;\n } else if (checkOptionElement(element) && dataKey === \"selected\") {\n element.selected = !!dataValue;\n } else if (dataKey) {\n [chkRemoveProp, dataValue] = makeAttrDataValue(dataValue);\n if (chkRemoveProp) {\n if (xmlnsRef.value && dataKey !== \"xmlns\") {\n element.setAttributeNS(\n null,\n getAttrKey(dataKey),\n dataValue\n );\n } else {\n element.setAttribute(\n getAttrKey(dataKey),\n dataValue\n );\n }\n }\n }\n if (chkRemoveProp) {\n delete originalProps[dataKey];\n }\n });\n keys(originalProps).forEach(\n (dataKey) => element.removeAttribute(dataKey)\n );\n};\nconst makeAttrDataValue = (dataValue) => {\n let allowSetAttr = true;\n if (typeof dataValue === \"boolean\") {\n if (!dataValue) {\n allowSetAttr = false;\n }\n dataValue = \"\";\n }\n return [allowSetAttr, String(dataValue)];\n};\nconst wDomToDom = (wDom) => {\n let element;\n const { type, tag, text, props, children = [] } = wDom;\n const isVirtualType = checkVirtualType(type);\n if (tag === \"svg\") {\n xmlnsRef.value = String(props == null ? void 0 : props.xmlns);\n }\n if (isVirtualType) {\n element = DF();\n } else if (type === \"element\" && tag) {\n element = xmlnsRef.value ? document.createElementNS(xmlnsRef.value, tag) : CE(tag);\n } else if (type === \"text\" && checkExisty(text)) {\n element = document.createTextNode(String(text));\n } else {\n element = CE(\"e\");\n }\n wDomChildrenToDom(children, element);\n updateProps$1(props, element);\n wDom.el = element;\n addMountedQueue(wDom);\n if (tag === \"svg\") {\n xmlnsRef.value = \"\";\n }\n return element;\n};\nconst wDomChildrenToDom = (children, parentElement) => {\n const elementChildren = children.reduce(\n (acc, childItem) => {\n if (childItem.type) {\n acc.appendChild(wDomToDom(childItem));\n }\n return acc;\n },\n DF()\n );\n if (parentElement && elementChildren.hasChildNodes()) {\n parentElement.appendChild(elementChildren);\n }\n};\nconst updateEvent = (element, eventKey, newEventHandler, oldEventHandler) => {\n const eventName = getEventName(eventKey);\n if (oldEventHandler !== newEventHandler) {\n if (oldEventHandler) {\n element.removeEventListener(eventName, oldEventHandler);\n }\n if (newEventHandler) {\n element.addEventListener(eventName, newEventHandler);\n }\n }\n};\nconst updateStyle = (style, oldStyle, element) => {\n requestAnimationFrame(() => {\n const originalStyle = { ...oldStyle };\n const elementStyle = element == null ? void 0 : element.style;\n if (elementStyle) {\n entries(style).forEach(([styleKey, dataValue]) => {\n elementStyle[styleKey] = dataValue;\n delete originalStyle[styleKey];\n });\n entries(originalStyle).forEach(\n ([styleKey]) => elementStyle[styleKey] = \"\"\n );\n }\n });\n};\nconst findRealParentElement = (vDom) => {\n const isVirtualType = checkVirtualType(vDom.type);\n if (vDom.isRoot && isVirtualType) {\n return vDom.wrapElement;\n }\n if (!isVirtualType) {\n return vDom.el;\n }\n return findRealParentElement(getParent(vDom));\n};\nconst makeNewWDomTree = (newWDom, originalWDom) => remakeNewWDom(\n newWDom,\n checkSameWDomWithOriginal[getWDomType(newWDom)](newWDom, originalWDom),\n originalWDom\n);\nconst remakeNewWDom = (newWDom, isSameType, originalWDom) => {\n const remakeWDom = generalize(newWDom, isSameType, originalWDom);\n const param = [\n remakeWDom,\n isSameType,\n originalWDom\n ];\n const needRerender = addReRenderTypeProperty(...param);\n remakeWDom.children = remakeChildrenForDiff(...param);\n remakeWDom.needRerender = needRerender;\n inheritPropForRender(remakeWDom, originalWDom, needRerender);\n return remakeWDom;\n};\nconst inheritPropForRender = (remakeWDom, originalWDom, needRerender) => {\n if (needRerender !== \"A\" && originalWDom) {\n remakeWDom.el = originalWDom.el;\n }\n if (needRerender && [\"D\", \"R\", \"SR\"].includes(needRerender)) {\n if (originalWDom == null ? void 0 : originalWDom.compKey) {\n runUnmountQueueFromWDom(originalWDom);\n recursiveRemoveEvent(originalWDom);\n }\n remakeWDom.oldChildren = originalWDom == null ? void 0 : originalWDom.children;\n }\n remakeWDom.oldProps = originalWDom == null ? void 0 : originalWDom.props;\n};\nconst addReRenderTypeProperty = (newWDom, isSameType, originalWDom) => {\n var _a;\n const existOriginalWDom = originalWDom && originalWDom.type;\n const isEmptyElement = checkEmptyElement(newWDom);\n const isRoot = newWDom.isRoot;\n const origParentType = !isRoot && originalWDom && ((_a = getParent(originalWDom)) == null ? void 0 : _a.type);\n const key = getKey(newWDom);\n const isKeyCheckedWDom = origParentType === \"loop\" && checkExisty(key);\n const isSameText = newWDom.type === \"text\" && isSameType && newWDom.text === (originalWDom == null ? void 0 : originalWDom.text);\n let result;\n if (isEmptyElement) {\n result = \"D\";\n } else if (isSameText) {\n result = \"N\";\n } else if (!existOriginalWDom) {\n result = \"A\";\n } else if (isSameType) {\n result = isKeyCheckedWDom ? \"SU\" : \"U\";\n } else {\n result = isKeyCheckedWDom ? \"SR\" : \"R\";\n }\n return result;\n};\nconst updateProps = (props, infoProps) => {\n if (props && infoProps !== props) {\n keys(props).forEach((key) => delete props[key]);\n entries(infoProps || {}).forEach(([key, value]) => props[key] = value);\n }\n};\nconst updateChildren = (children, infoChidren) => {\n if (children && infoChidren !== children) {\n children.splice(0, children.length);\n if (infoChidren) {\n infoChidren.forEach((childrenItem) => children.push(childrenItem));\n }\n }\n};\nconst runUpdate = (vDom, infoVdom) => {\n const { compProps: props, compChild: children } = vDom;\n const { props: infoProps, children: infoChidren } = infoVdom;\n if (props) {\n updateProps(props, infoProps);\n }\n if (children) {\n updateChildren(children, infoChidren);\n }\n const newVDom = vDom.reRender && vDom.reRender();\n return newVDom;\n};\nconst generalize = (newWDom, isSameType, originalWDom) => {\n if (checkCustemComponentFunction(newWDom)) {\n return isSameType && originalWDom ? runUpdate(originalWDom, newWDom) : newWDom.resolve();\n }\n return newWDom;\n};\nconst remakeChildrenForDiff = (newWDom, isSameType, originalWDom) => isSameType && originalWDom ? remakeChildrenForUpdate(newWDom, originalWDom) : remakeChildrenForAdd(newWDom);\nconst remakeChildrenForAdd = (newWDom) => (newWDom.children || []).map(\n (item) => assign(makeNewWDomTree(item), { getParent: () => newWDom })\n);\nconst remakeChildrenForUpdate = (newWDom, originalWDom) => newWDom.type === \"loop\" && checkExisty(getKey((newWDom.children || [])[0])) ? remakeChildrenForLoopUpdate(newWDom, originalWDom) : (newWDom.children || []).map(\n (item, index) => assign(makeNewWDomTree(item, (originalWDom.children || [])[index]), {\n getParent: () => newWDom\n })\n);\nconst remakeChildrenForLoopUpdate = (newWDom, originalWDom) => {\n const [remakedChildren, unUsedChildren] = diffLoopChildren(\n newWDom,\n originalWDom\n );\n unUsedChildren.map((unusedItem) => {\n runUnmountQueueFromWDom(unusedItem);\n recursiveRemoveEvent(unusedItem);\n typeDelete(unusedItem);\n });\n return remakedChildren;\n};\nconst diffLoopChildren = (newWDom, originalWDom) => {\n const newChildren = [...newWDom.children || []];\n const originalChildren = [...originalWDom.children || []];\n const remakedChildren = newChildren.map((item) => {\n const originalItem = findSameKeyOriginalItem(item, originalChildren);\n const childItem = makeNewWDomTree(item, originalItem);\n if (originalItem) {\n originalChildren.splice(originalChildren.indexOf(originalItem), 1);\n }\n childItem.getParent = () => newWDom;\n return childItem;\n });\n return [remakedChildren, originalChildren];\n};\nconst findSameKeyOriginalItem = (item, originalChildren) => originalChildren.find(\n (orignalChildItem) => getKey(orignalChildItem) === getKey(item)\n);\nlet redrawQueue = [];\nlet redrawQueueTimeout = false;\nconst setRedrawAction = (compKey, exec) => {\n componentRef.get(compKey).up = () => {\n redrawQueue.push({\n compKey,\n exec\n });\n if (!redrawQueueTimeout) {\n redrawQueueTimeout = true;\n queueMicrotask(execRedrawQueue);\n }\n };\n};\nconst componentUpdate = (compKey) => () => {\n var _a;\n const up = (_a = componentRef.get(compKey)) == null ? void 0 : _a.up;\n let result = false;\n if (up) {\n up();\n result = true;\n }\n return result;\n};\nconst recursiveGetChildKeys = (wDom, result) => {\n (wDom.children || []).forEach((item) => {\n const childComKey = item.compKey;\n if (childComKey) {\n result.push(childComKey);\n }\n recursiveGetChildKeys(item, result);\n });\n};\nconst execRedrawQueue = () => {\n let childItemList = [];\n redrawQueue.forEach((item) => {\n var _a, _b;\n const childVd = (_b = (_a = componentRef.get(item.compKey)) == null ? void 0 : _a.vd) == null ? void 0 : _b.value;\n if (childVd) {\n recursiveGetChildKeys(childVd, childItemList);\n }\n });\n const addedKey = [];\n const result = redrawQueue.reduce((acc, item) => {\n const { compKey } = item;\n if (childItemList.includes(compKey) || addedKey.includes(compKey)) {\n return acc;\n }\n addedKey.push(compKey);\n acc.push(item);\n return acc;\n }, []);\n while (result.length) {\n const action = result.shift();\n if (action) {\n action.exec();\n }\n }\n redrawQueue = [];\n redrawQueueTimeout = false;\n};\nconst updateCallback = (effectAction, dependencies = () => []) => {\n const updateReqs = componentRef.get(getComponentKey()).upR;\n updateReqs.push(() => useUpdated(effectAction, dependencies));\n useUpdated(effectAction, dependencies);\n};\nconst runUpdateCallback = () => {\n var _a;\n const updateReqs = (_a = componentRef.get(getComponentKey())) == null ? void 0 : _a.upR;\n if (updateReqs == null ? void 0 : updateReqs.length) {\n updateReqs.forEach((callback) => callback());\n }\n};\nconst Fragment = (_props, ...children) => ({\n type: \"fragment\",\n children\n});\nconst h = (tag, props, ...children) => {\n const nodeParentPointer = { value: void 0 };\n const newProps = props || {};\n const newChildren = remakeChildren(nodeParentPointer, children);\n const node = makeNode(tag, newProps, newChildren);\n if (!checkCustemComponentFunction(node)) {\n nodeParentPointer.value = node;\n }\n return node;\n};\nconst mount = (component) => (_props, _children) => component;\nconst reRenderCustomComponent = (tag, props, children, originalWDom) => {\n var _a;\n needDiffRef.value = true;\n const newWDom = makeWDomResolver(tag, props, children);\n const newWDomTree = makeNewWDomTree(newWDom, originalWDom);\n const { isRoot, getParent: getParent2, wrapElement, afterElement } = originalWDom;\n newWDomTree.getParent = getParent2;\n if (!isRoot && getParent2) {\n const brothers = ((_a = getParent2()) == null ? void 0 : _a.children) || [];\n const index = brothers.indexOf(originalWDom);\n brothers.splice(index, 1, newWDomTree);\n } else {\n newWDomTree.isRoot = true;\n newWDomTree.wrapElement = wrapElement;\n newWDomTree.afterElement = afterElement;\n }\n needDiffRef.value = false;\n wDomUpdate(newWDomTree);\n};\nconst makeWDomResolver = (tag, props, children) => {\n const tagName = tag.name;\n const ctor = tag;\n const resolve = (compKey = props) => {\n initMountHookState(compKey);\n const component = tag(props, children);\n const componentMaker = component(componentUpdate(compKey), props, children);\n const customNode = makeCustomNode(\n componentMaker,\n compKey,\n tag,\n props,\n children\n );\n const originalWDom = customNode;\n setRedrawAction(\n compKey,\n () => reRenderCustomComponent(tag, props, children, originalWDom)\n );\n getComponentSubInfo(compKey, \"vd\").value = customNode;\n return customNode;\n };\n return { tagName, ctor, props, children, resolve };\n};\nconst makeCustomNode = (componentMaker, compKey, tag, props, children) => {\n const customNode = componentMaker(props);\n if (customNode.reRender) {\n throw new Error(\n 'Avoid the case where the first element of a component is a component. Instead of \"mount(()=>()=><Component />)\" replace it with something like \"mount(()=>()=><Fragment><Component /></Fragment>)\".'\n );\n }\n addComponentProps(\n customNode,\n compKey,\n tag,\n props,\n children,\n makeReRender(componentMaker, compKey, tag, props, children)\n );\n return customNode;\n};\nconst makeReRender = (componentMaker, compKey, tag, props, children) => {\n const reRender = () => wDomMaker(componentMaker, compKey, tag, props, children, reRender);\n return reRender;\n};\nconst wDomMaker = (componentMaker, compKey, tag, props, children, reRender) => {\n initUpdateHookState(compKey);\n runUpdateCallback();\n const originalWDom = componentMaker(props);\n setRedrawAction(\n compKey,\n () => reRenderCustomComponent(tag, props, children, originalWDom)\n );\n addComponentProps(originalWDom, compKey, tag, props, children, reRender);\n getComponentSubInfo(compKey, \"vd\").value = originalWDom;\n return originalWDom;\n};\nconst addComponentProps = (wDom, compKey, tag, props, children, reRender) => {\n assign(wDom, {\n compProps: props,\n compChild: children,\n ctor: tag,\n tagName: tag.name,\n compKey,\n reRender\n });\n};\nconst makeNode = (tag, props, children) => {\n if (checkFragmentFunction(tag)) {\n return Fragment(props, ...children);\n } else if (checkCustemComponentFunction(tag)) {\n const componetMakeResolver = makeWDomResolver(tag, props, children);\n return needDiffRef.value ? componetMakeResolver : componetMakeResolver.resolve();\n }\n return {\n type: \"element\",\n tag,\n props,\n children\n };\n};\nconst remakeChildren = (nodeParentPointer, children) => children.map(\n (item) => assign(makeChildrenItem(item), { getParent: () => nodeParentPointer.value })\n);\nconst makeChildrenItem = (item) => {\n if (item === null || item === void 0 || item === false) {\n return { type: null };\n } else if (Array.isArray(item)) {\n const nodeParentPointer = { value: void 0 };\n const children = remakeChildren(nodeParentPointer, item);\n const node = {\n type: \"loop\",\n children\n };\n nodeParentPointer.value = node;\n return node;\n } else if (typeof item === \"string\" || typeof item === \"number\") {\n return { type: \"text\", text: item };\n }\n return item;\n};\nconst ref = (initValue) => ({ value: initValue });\nconst nextTick = () => Promise.resolve();\nexport {\n Fragment,\n h,\n mount,\n mountCallback,\n nextTick,\n ref,\n render,\n updateCallback\n};\n//# sourceMappingURL=lithent.mjs.map\n","import { mountCallback as a, updateCallback as p, nextTick as h, render as g } from \"lithent\";\nconst f = (r, t) => {\n let e = r;\n return {\n get value() {\n return e;\n },\n get v() {\n return e;\n },\n set value(n) {\n e = n, t();\n },\n set v(n) {\n e = n, t();\n }\n };\n}, m = (r) => {\n let t = r;\n return {\n get value() {\n return t();\n },\n get v() {\n return t();\n },\n set value(e) {\n throw new Error(\"You can't change 'computed'\");\n },\n set v(e) {\n throw new Error(\"You can't change 'computed'\");\n }\n };\n}, d = (r, t = () => {\n}, e = () => []) => {\n a(() => (r(), t)), p(() => (t && t(), r), e);\n}, l = /* @__PURE__ */ new Map(), u = {}, x = (r) => {\n const t = Symbol();\n return l.set(t, r), (e) => (u[t] ?? (u[t] = []), u[t].push(e), i(t));\n}, i = (r) => new Proxy(l.get(r), {\n get(t, e) {\n return t[e];\n },\n set(t, e, n) {\n t[e] = n;\n const c = u[r], s = [];\n return c.forEach((o) => {\n o() || s.push(o);\n }), s.forEach(\n (o) => c.splice(c.indexOf(o), 1)\n ), !0;\n }\n}), E = (r, t, e) => {\n let n = () => {\n };\n return h().then(() => {\n n = g(r(), t, e);\n }), () => n();\n};\nexport {\n m as computed,\n d as effect,\n E as nextTickRender,\n f as state,\n x as store\n};\n//# sourceMappingURL=lithentHelper.mjs.map\n","// example.jsx\nimport {\n h,\n Fragment,\n render,\n ref,\n mountCallback,\n updateCallback,\n mount,\n} from 'lithent';\nimport { state, computed, effect, store } from 'lithent/helper';\n\n// This is the \"mount\" function.\n// This function is only executed on mount, and on update, only updates `props` and then executes the internal return function.\n// childen is passed as the second argument.\nconst ChildComponent = mount<{ parentValue: number }>(\n (renew, props, children) => {\n // The value is used as a \"getter\" to make it easy to get and write to in the higher-order functions it returns\n const count = state<number>(1, renew);\n const text = state<string>(\n '\"destructuring\" the \"props\" value directly from the mount function will cause referencing issues, so if you want to use it, you need to \"destructuring\" it from the internal function (updater).',\n renew\n );\n const getParentValue = () => props.parentValue;\n const parentValueFromMount = props.parentValue;\n const summ = computed<number>(\n () => count.v + notRefValue + props.parentValue\n );\n\n const localStore = store<{ text: string; count: number }>({\n text: 's',\n count: 0,\n })(renew);\n /*\n // To share a store, make it externally and use `asign`.\n const asignStore = store<{ text: string; count: number }>({ text: 's', count: 0 });\n\n const sharedStore = asignStore(nenew);\n */\n\n // Even if you don't use a ref, the private value is always maintained as a regular variable.\n let notRefValue = props.parentValue;\n\n // Ref is only used to reference the DOM.\n const domRef = ref(null);\n\n const increase = () => {\n count.v = count.v + 1;\n notRefValue += 1;\n };\n\n const handleInputChane = (event: InputEvent) => {\n text.v = (event.target as HTMLInputElement).value;\n };\n\n const localStoreUpdate = () => {\n localStore.count += 1;\n localStore.text += '1';\n };\n\n const handleMounted = () => {\n console.log('MOUNTED', domRef);\n\n return () => console.log('UNMOUNT');\n };\n const handleUpdated = () => {\n console.log('UPDATE - parentValue');\n\n return () => console.log('UPDATED');\n };\n\n mountCallback(handleMounted);\n updateCallback(handleUpdated, () => [props.parentValue]); // Only Defs Updated (using a closure to update a value)\n\n // Behaves like `react`'s `useEffect`\n effect(\n () => console.log('INJECT'),\n () => console.log('CLEAN_UP'),\n () => [count.v]\n );\n\n // Wrap in a function and return (using a closure to hold the value)\n // This is the \"update\" function.\n return ({ parentValue }) => (\n <Fragment>\n {/* Note that the event is onInput (we use the native event name to avoid confusion). */}\n <div>\n <textarea\n value={text.v}\n onInput={handleInputChane}\n style={{ width: '300px', height: '100px' }}\n />\n </div>\n <div>{text.v}</div>\n <div>\n <div style={{ color: 'blue' }}>\n parentValueFromRef: {props.parentValue} (working)\n </div>\n <div style={{ color: 'blue' }}>\n parentValueFromFunction: {getParentValue()} (working)\n </div>\n <div style={{ color: 'blue' }}>\n parentValueFromUpdaterDestructuring: {parentValue} (working)\n </div>\n <div style={{ color: 'red' }}>\n parentValueFromMounterDestructuring: {parentValueFromMount} (not\n working)\n </div>\n </div>\n <div>\n <div ref={domRef}>count: {count.v}</div>\n <div>sum: {count.v + notRefValue + props.parentValue}</div>\n <div>sum(computed): {summ.v}</div>\n {/* It doesn't pull it out from under the reference, it uses the value directly, so you can just use it. */}\n <div>notRefValue: {notRefValue}</div>\n <div>localStore(text): {localStore.text}</div>\n <div>localStore(count): {localStore.count}</div>\n </div>\n <button onClick={increase}>Increase</button>\n <button onClick={localStoreUpdate}>localStoreUpdate</button>\n {children}\n </Fragment>\n );\n }\n);\n\nconst Root = mount(renew => {\n const parentNumber = state<number>(7, renew);\n\n const increaseParent = () => {\n parentNumber.v = parentNumber.v + 1;\n };\n\n const decreaseParent = () => {\n parentNumber.v = parentNumber.v - 1;\n };\n\n return () => (\n <Fragment>\n <ChildComponent parentValue={parentNumber.v}>\n <button onClick={increaseParent}>Increase - Parent</button>\n </ChildComponent>\n <button onClick={decreaseParent}>Decrease - Parent</button>\n </Fragment>\n );\n});\nconst root = <Root />;\n\nrender(root, document.getElementById('root'));\n"],"names":["checkPlainWDomType","wDom","checkPlainType","typeName","checkSameCustomComponent","newWDom","originalWDom","checkSameFragment","_a","_b","checkSameTagElement","checkNormalTypeElement","checkExisty","getKey","target","checkVirtualType","type","checkCustemComponentFunction","checkFragmentFunction","Fragment","checkEmptyElement","value","checkStyleData","dataKey","dataValue","checkRefData","checkOptionElement","element","checkTextareaElement","checkCheckableElement","getWDomType","result","checkSameWDomWithOriginal","getParent","vDom","entries","keys","assign","xmlnsRef","compKeyRef","needDiffRef","componentRef","setComponetRef","compKey","getComponentKey","getComponentSubInfo","subKey","initUpdateHookState","initMountHookState","unmount","effectAction","runUnmountQueueFromWDom","removeItem","recursiveRunUnmount","item","subInfo","effect","mountedQueue","execMountedQueue","runMountedQueueFromWDom","addMountedQueue","mountCallback","component","queue","sequence","callback","useUpdated","dependencies","upD","upS","def","checkNeedPushQueue","runUpdatedQueueFromWDom","originalDefs","newDefs","index","getAttrKey","keyName","getEventName","eventKey","_match","p1","DF","CE","t","render","wrapElement","afterElement","Dom","wDomToDom","recursiveRemoveEvent","rootDelete","wDomUpdate","newWDomTree","needRerender","typeAdd","typeDelete","typeReplace","typeUpdate","typeSortedReplace","typeSortedUpdate","removeEvent","childItem","deleteRealDom","findRealParentElement","parent","findChildWithRemoveElement","newElement","getElementFromFragment","parentWDom","parentEl","nextEl","startFindNextBrotherElement","acc","brothers","nextIndex","candidiateBrothers","finedNextEl","findChildFragmentNextElement","parentType","targetEl","bItem","el","isFragment","orignalElement","parentElement","oldProps","updateText","props","updateProps$1","originalProps","chkRemoveProp","updateStyle","updateEvent","makeAttrDataValue","allowSetAttr","tag","text","children","isVirtualType","wDomChildrenToDom","elementChildren","newEventHandler","oldEventHandler","eventName","style","oldStyle","originalStyle","elementStyle","styleKey","makeNewWDomTree","remakeNewWDom","isSameType","remakeWDom","generalize","param","addReRenderTypeProperty","remakeChildrenForDiff","inheritPropForRender","existOriginalWDom","isEmptyElement","origParentType","key","isKeyCheckedWDom","isSameText","updateProps","infoProps","updateChildren","infoChidren","childrenItem","runUpdate","infoVdom","remakeChildrenForUpdate","remakeChildrenForAdd","remakeChildrenForLoopUpdate","remakedChildren","unUsedChildren","diffLoopChildren","unusedItem","newChildren","originalChildren","originalItem","findSameKeyOriginalItem","orignalChildItem","redrawQueue","redrawQueueTimeout","setRedrawAction","exec","execRedrawQueue","componentUpdate","up","recursiveGetChildKeys","childComKey","childItemList","childVd","addedKey","action","updateCallback","runUpdateCallback","updateReqs","_props","h","nodeParentPointer","newProps","remakeChildren","node","makeNode","mount","_children","reRenderCustomComponent","makeWDomResolver","isRoot","getParent2","componentMaker","customNode","makeCustomNode","addComponentProps","makeReRender","reRender","wDomMaker","componetMakeResolver","makeChildrenItem","ref","initValue","f","r","e","n","m","d","a","p","l","u","x","i","s","o","ChildComponent","renew","count","state","getParentValue","parentValueFromMount","summ","computed","notRefValue","localStore","store","domRef","increase","handleInputChane","event","localStoreUpdate","handleMounted","handleUpdated","parentValue","Root","parentNumber","increaseParent","decreaseParent","root"],"mappings":"ssBAAA,MAAMA,EAAsBC,GAAS,OAAOA,GAAS,UAAY,EAAE,YAAaA,GAC1EC,EAAiB,CAACD,EAAME,IAAaH,EAAmBC,CAAI,GAAKA,EAAK,OAASE,EAC/EC,GAA2B,CAACC,EAASC,IAAiB,SAAUD,EAAUA,EAAQ,QAAUC,GAAgB,KAAO,OAASA,EAAa,MAAQD,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