Skip to content

Commit 78417cf

Browse files
committed
Updated Dist
1 parent 4e39cc3 commit 78417cf

8 files changed

+513
-9
lines changed

out/index.cjs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
"use strict";var w=Object.defineProperty;var O=Object.getOwnPropertyDescriptor;var L=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var U=(t,e)=>{for(var n in e)w(t,n,{get:e[n],enumerable:!0})},H=(t,e,n,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of L(e))!P.call(t,r)&&r!==n&&w(t,r,{get:()=>e[r],enumerable:!(i=O(e,r))||i.enumerable});return t};var $=t=>H(w({},"__esModule",{value:!0}),t);var X={};U(X,{app:()=>A,component:()=>G,computed:()=>W,hasWindow:()=>Q,mapper:()=>j,ref:()=>J,render:()=>_,state:()=>B,store:()=>z,valueOf:()=>K});module.exports=$(X);var T=()=>{let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",n=t.length;for(let i=0;i<10;i++)e+=t.charAt(Math.floor(Math.random()*n));return e},F=T(),v=t=>{F=t};var k=t=>t.map(e=>JSON.stringify(Object.hasOwn(e,"get")&&e.get())).join("");var g=t=>{let e="",n=!1,i={},r=o=>{},d=()=>{let o=document.querySelector(`[data-nice-id="${e}"]`);!o||n||(n=!0,setTimeout(()=>{let a=r(e);a&&o.replaceWith(a.children[0]),n=!1},0))};return o=>(e=T(),v(e),i=o??{},r=t(i),{id:e,type:"component",properties:o,render:r,markDirty:d})};var A=(t,e)=>{let n=g(t)();if(e&&typeof window<"u"){let i=e?document.querySelector(e):void 0;if(!i)throw new Error(`Failed to attach - Element "${e}" not found in the DOM.`);n.markDirty=()=>{let r=n.render(T());if(r){for(;i.firstChild;)i.removeChild(i.firstChild);window?Array.from(r.hydrate().children).forEach(d=>{i.appendChild(d)}):i.innerHTML=r.html}},n.markDirty()}else return{html:n.render("nice-app-root").html,id:"nice-app-root",hydrate:i=>{let r=document.querySelector(`#${i}`);if(!r)throw new Error(`Failed to attach - Element "${e}" not found in the DOM.`);n.markDirty=()=>{let d=n.render(T());if(d){for(;r.firstChild;)r.removeChild(r.firstChild);window?Array.from(d.hydrate().children).forEach(c=>{r.appendChild(c)}):r.innerHTML=d.html}},n.markDirty()}}};var R=(t,...e)=>r=>{let d=`<!-- ${r} BEGIN -->`,c=`<!-- ${r} END -->`,o="",a={},l={};return t.forEach((p,m)=>{let s=e[m];if(o+=p,s===void 0)return;let f=Math.random().toString(36).substring(7);if(typeof s!="object"){o+=s;return}switch(s.type){case"component":o+=f,a[f]=s.render(s.id);break;case"state":o+=f,l[f]=s;break}}),Object.keys(a).forEach(p=>{o=o.replace(p,a[p].html.replace(/(<.+)( )/,`$1 data-reattach-child="${p}" `))}),Object.keys(l).forEach(p=>{let m=o.split(p)[0],s=q(m),f=l[p].get(),h=f;if(f)if(typeof f=="object"&&f.type==="component"){let y=f;h=y.render(y.id).html}else Array.isArray(f)&&(h=f.map(y=>{if(typeof y=="object"&&y.type==="component"){let u=y;return u.render(u.id).html}else return y}).join(""));let b=s?`state-${p}`:`<!-- @ --><span data-reattach-state="${p}" data-reattach-extras="${!!f}"></span>${h}<!-- # -->`;o=o.replace(p,b)}),{html:o,hydrate:()=>{let p=V(o);return p.children[0].setAttribute("data-nice-id",r),Object.keys(l).forEach(m=>{p.querySelectorAll(`[data-reattach-state="${m}"]`).forEach(s=>{s.getAttribute("data-reattach-extras")==="true"&&s.nextSibling?.remove();let h=l[m].get();l[m].markers.push([s.previousSibling,s.nextSibling]),E(h,s.previousSibling,s.nextSibling)})}),Object.keys(a).forEach(m=>{p.querySelectorAll(`[data-reattach-child="${m}"]`).forEach(s=>{s.replaceWith(a[m].hydrate().children[0])})}),p.querySelectorAll("*").forEach(m=>{Array.from(m.attributes).forEach(s=>{let f=s.name.startsWith("on-"),h=s.name.startsWith("set-"),b=s.name==="ref",y=s.value.match(/state-(.+)/);if(y){let u=l[y[1]];if(!u)return;u.attributes[s.name]||(u.attributes[s.name]=[]),f?(m.removeAttribute(s.name),m.addEventListener(s.name.slice(3),C=>u.set(C))):h?(m.removeAttribute(s.name),u.listen(C=>{m[s.name.slice(4)]=C}),m[s.name.slice(4)]=u.get()):b?(m.removeAttribute(s.name),u.set(m)):(u.attributes[s.name].push(m),m.setAttribute(s.name,u.get()??""))}})}),p}}},E=(t,e,n)=>{let i=[],r=e.nextSibling;for(;r!==n;)i.push(r),r=r?.nextSibling;if(t&&typeof t=="object"&&t.type==="component"){let d=t,c=d.render(d.id);i.forEach(o=>o.remove()),c&&Array.from(c.hydrate().children).reverse().forEach(o=>e.after(o))}else{let c=(Array.isArray(t)?t:[t]).map(o=>{if(typeof o=="object"&&o.type==="component"){let a=o;return a.render(a.id).hydrate()}else return o});i.forEach(o=>o.remove()),c.reverse().forEach(o=>{if(o instanceof HTMLElement)Array.from(o.children).reverse().forEach(a=>e.after(a));else{let a=document.createTextNode(o);e.after(a)}})}},V=t=>{let e=document.createElement("div");return e.innerHTML=t,e},q=t=>{let e=/.+\b(.+)="?$/gm,n,i=[];for(;(n=e.exec(t))!==null;)n.index===e.lastIndex&&e.lastIndex++,n.forEach(r=>{i.push(r)});if(i.length===2)return i[1]};var N=t=>{let e=t,n=T(),i=[],r=[],d=[],c={};return{id:n,type:"state",get:()=>e,set:o=>{let a=e;typeof t=="function"?a=o(e):a=o,a!==e&&(e=a,i.forEach(l=>l(a)),Object.entries(c).forEach(([l,x])=>{x.forEach(p=>{p.setAttribute(l,a??"")})}),d.forEach(([l,x])=>{E(e,l,x)}))},listen:o=>i.push(o),textNodes:r,markers:d,attributes:c}},S=(t,e)=>{let n=N(void 0),i=void 0,r=(e??[]).map(c=>c&&typeof c=="object"&&Object.hasOwn(c,"listen")?c:!1).filter(Boolean),d=c=>{let o=!!c&&!e,a=t(c),l=k(r);a!==n.get()&&l!==i&&!o&&n.set(a)};return e?(r.forEach(c=>c.listen(d)),d()):n.listen(d),n},I=t=>S(t||(()=>{}));var D=t=>{let e=Object.entries(t).reduce((n,[i,r])=>(n[i]=N(r),n),{});return[n=>e[n]]};var j=(t,e)=>{let n=[];return typeof t=="number"?n=Array.from({length:t},(i,r)=>r+1):typeof t=="object"?n=Array.from(Object.entries(t)):Array.isArray(t)&&(n=t),n.map((i,r)=>e(i,r))},M=t=>typeof t=="object"&&Object.hasOwn(t,"get")?t.get():t;var B=N,W=S,_=R,G=g,J=I,z=D,K=M,Q=typeof window<"u";
1+
"use strict";var w=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var V=Object.prototype.hasOwnProperty;var q=(t,e)=>{for(var r in e)w(t,r,{get:e[r],enumerable:!0})},B=(t,e,r,i)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of F(e))!V.call(t,o)&&o!==r&&w(t,o,{get:()=>e[o],enumerable:!(i=P(e,o))||i.enumerable});return t};var W=t=>B(w({},"__esModule",{value:!0}),t);var te={};q(te,{app:()=>M,component:()=>Z,computed:()=>G,hasWindow:()=>ee,mapper:()=>O,ref:()=>Q,render:()=>J,state:()=>z,store:()=>X,styler:()=>U,valueOf:()=>Y});module.exports=W(te);var N=()=>{let t="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789",e="",r=t.length;for(let i=0;i<10;i++)e+=t.charAt(Math.floor(Math.random()*r));return e},K=N(),v=t=>{K=t};var R=t=>t.map(e=>JSON.stringify(Object.hasOwn(e,"get")&&e.get())).join(""),I=t=>t.replace(/([a-z])([A-Z])/g,"$1-$2").toLowerCase();var E=t=>{let e="",r=!1,i={},o=s=>{},f=()=>{let s=document.querySelector(`[data-nice-id="${e}"]`);!s||r||(r=!0,setTimeout(()=>{let n=o(e);n&&s.replaceWith(n.children[0]),r=!1},0))};return(s,n)=>(e=N(),v(e),i=s??{},o=t(i,n),{id:e,type:"component",properties:s,render:o,markDirty:f,key:n??e})};var M=(t,e)=>{let r=E(t)();if(e&&typeof window<"u"){let i=e?document.querySelector(e):void 0;if(!i)throw new Error(`Failed to attach - Element "${e}" not found in the DOM.`);r.markDirty=()=>{let o=r.render(N());if(o){for(;i.firstChild;)i.removeChild(i.firstChild);window?Array.from(o.hydrate().children).forEach(f=>{i.appendChild(f)}):i.innerHTML=o.html}},r.markDirty()}else return{html:r.render("nice-app-root").html,id:"nice-app-root",hydrate:i=>{let o=document.querySelector(`#${i}`);if(!o)throw new Error(`Failed to attach - Element "${e}" not found in the DOM.`);r.markDirty=()=>{let f=r.render(N());if(f){for(;o.firstChild;)o.removeChild(o.firstChild);window?Array.from(f.hydrate().children).forEach(m=>{o.appendChild(m)}):o.innerHTML=f.html}},r.markDirty()}}};var L=(t,...e)=>o=>{let f=`<!-- ${o} BEGIN -->`,m=`<!-- ${o} END -->`,s="",n={},a={};t.forEach((p,l)=>{let d=e[l];if(s+=p,d===void 0)return;let u=j(p),c=Math.random().toString(36).substring(7);if(typeof d!="object"){u&&!p.endsWith('"')?s+=`"${d}"`:s+=d;return}switch(d.type){case"component":s+=c,n[c]=d.render(d.id);break;case"state":s+=c,a[c]=d;break}}),Object.keys(n).forEach(p=>{s=s.replace(p,n[p].html.replace(/(<.+)( )/,`$1 data-reattach-child="${p}" `))}),Object.keys(a).forEach(p=>{let l=s.split(p)[0],d=j(l),u=a[p].get(),c=u,g=1;if(u)if(typeof u=="object"&&u.type==="component"){let T=u;c=T.render(T.id).html}else Array.isArray(u)&&(g=u.length,c=u.map(T=>{if(typeof T=="object"&&T.type==="component"){let b=T;return b.render(b.id).html}else return T}).join(""));let k=d?`"${c||""}" data-bind-${d}="${p}"`:`<!-- @ --><span data-reattach-state="${p}" data-reattach-extras="${!!c&&g}"></span>${c}<!-- # -->`;s=s.replace(p,k)});let y=()=>{let p=_(s);return p.children[0].setAttribute("data-nice-id",o),Object.keys(a).forEach(l=>{p.querySelectorAll(`[data-reattach-state="${l}"]`).forEach(d=>{let u=d.getAttribute("data-reattach-extras");if(u&&u!=="false")for(let g=0;g<parseInt(u);g++)d.nextSibling?.remove();let c=a[l].get();a[l].markers.push([d.previousSibling,d.nextSibling]),S(c,d.previousSibling,d.nextSibling)})}),Object.keys(n).forEach(l=>{p.querySelectorAll(`[data-reattach-child="${l}"]`).forEach(d=>{d.replaceWith(n[l].hydrate().children[0])})}),p.querySelectorAll("*").forEach(l=>{Array.from(l.attributes).forEach(d=>{let u=d.name.match(/data-bind-(.+)$/);if(u){let c=u[1].trim(),g=d.value,k=c.startsWith("on-"),T=c.startsWith("set-"),b=c==="ref",h=a[g];if(!h)return;h.attributes[c]||(h.attributes[c]=[]),k?(l.removeAttribute(c),l.addEventListener(c.slice(3),C=>h.set(C))):T?(l.removeAttribute(c),h.listen(C=>{l[c.slice(4)]=C}),l[c.slice(4)]=h.get()):b?(l.removeAttribute(c),h.set(l)):(h.attributes[c].push(l),l.setAttribute(c,h.get()??"")),l.removeAttribute(d.name)}})}),p};return{html:s.trim(),hydrate:y}},S=(t,e,r)=>{let i=[],o=e.nextSibling;for(;o!==r;)i.push(o),o=o?.nextSibling;if(t&&typeof t=="object"&&t.type==="component"){let f=t,m=f.render(f.id);i.forEach(s=>s.remove()),m&&Array.from(m.hydrate().children).reverse().forEach(s=>e.after(s))}else{let f=Array.isArray(t)?t:[t],m=f.map(n=>{if(typeof n=="object"&&n.type==="component"){let a=n;return a.key??a.id}else return}).filter(n=>n!==void 0),s=f.map(n=>{if(typeof n=="object"&&n.type==="component"){console.log("RendernChild",n,n.properties);let a=n,y=a.render(a.id).hydrate();return y.children[0]&&n.key&&y.children[0].setAttribute("data-nice-key",n.key),console.log(y.children[0]),y}else return n});m.length?(i.forEach(n=>{m.includes(n.getAttribute("data-nice-key"))||n.remove()}),s.reverse().forEach(n=>{if(n instanceof HTMLElement){let a=null;Array.from(n.children).reverse().forEach(y=>{e.parentElement?.querySelector(`[data-nice-key="${y.getAttribute("data-nice-key")}"]`)||(a??r).before(y),a=y})}else{let a=document.createTextNode(n);e.after(a)}})):(i.forEach(n=>n.remove()),s.reverse().forEach(n=>{if(n instanceof HTMLElement)Array.from(n.children).reverse().forEach(a=>e.after(a));else{let a=document.createTextNode(n);e.after(a)}}))}},_=t=>{let e=document.createElement("div");return e.innerHTML=t,e},j=t=>{let e=/.+ (.+)="?$/gm,r,i=[];for(;(r=e.exec(t))!==null;)r.index===e.lastIndex&&e.lastIndex++,r.forEach(o=>{i.push(o)});if(i.length===2)return i[1]};var x=t=>{let e=t,r=N(),i=[],o=[],f=[],m={};return{id:r,type:"state",get:()=>e,set:s=>{let n=e;typeof t=="function"?n=s(e):n=s,n!==e&&(e=n,i.forEach(a=>a(n)),Object.entries(m).forEach(([a,y])=>{y.forEach(p=>{p.setAttribute(a,n??"")})}),f.forEach(([a,y])=>{S(e,a,y)}))},listen:s=>i.push(s),textNodes:o,markers:f,attributes:m}},A=(t,e)=>{let r=x(void 0),i=void 0,o=(e??[]).map(m=>m&&typeof m=="object"&&Object.hasOwn(m,"listen")?m:!1).filter(Boolean),f=m=>{let s=!!m&&!e,n=t(m),a=R(o);n!==r.get()&&a!==i&&!s&&r.set(n)};return e?(o.forEach(m=>m.listen(f)),f()):r.listen(f),r},$=t=>A(t||(()=>{}));var D=t=>{let e=Object.entries(t).reduce((r,[i,o])=>(r[i]=x(o),r),{});return r=>e[r]};var O=(t,e)=>{let r=[];return typeof t=="number"?r=Array.from({length:t},(i,o)=>o+1):typeof t=="object"?r=Array.from(Object.entries(t)):Array.isArray(t)&&(r=t),r.map((i,o)=>e(i,o))},H=t=>typeof t=="object"&&Object.hasOwn(t,"get")?t.get():t,U=t=>Object.entries(t).reduce((e,[r,i])=>`${e}${I(r)}: ${i};`,"");var z=x,G=A,J=L,Z=E,Q=$,X=D,Y=H,ee=typeof window<"u";

0 commit comments

Comments
 (0)