Free javascript Hosting


index-afc320dd.js

Uploaded on Jan 06 2022 15:25 by alpha1

const e=()=>(e,t,o,n=[])=>{const r=o?.props??{},s=t.props??{};for(const t in{...r,...s}){const o=r[t],i=s[t];if(o!==i)if(t.startsWith("on")){const r=t.slice(2).toLowerCase();n.push((()=>{o&&e.removeEventListener(r,o),e.addEventListener(r,i)}))}else void 0===e[t]||e instanceof SVGElement?i?n.push((()=>e.setAttribute(t,String(i)))):n.push((()=>e.removeAttribute(t))):i?n.push((()=>e[t]=i)):n.push((()=>{e.removeAttribute(t),delete e[t]}))}return{el:e,newVNode:t,oldVNode:o,workStack:n}};var t,o;(o=t||(t={}))[o.IGNORE_NODE=0]="IGNORE_NODE",o[o.REPLACE_NODE=1]="REPLACE_NODE",o[o.NO_CHILDREN=2]="NO_CHILDREN",o[o.ONLY_TEXT_CHILDREN=3]="ONLY_TEXT_CHILDREN",o[o.ONLY_KEYED_CHILDREN=4]="ONLY_KEYED_CHILDREN",o[o.ANY_CHILDREN=5]="ANY_CHILDREN";const n=(e=[],t=(e=>e()))=>{for(let o=0;o<e.length;++o)t(e[o])},r=(o,s,l,a=[])=>{const c=((e=[])=>(t,o,n,r=[])=>{const s=e=>(r.push((()=>{n||(e.__m_old_vnode=o)})),{el:e,newVNode:o,oldVNode:n,workStack:r});if(!o&&""!==o)return r.push((()=>t.remove())),s(t);{const l=n??t.__m_old_vnode,a="string"==typeof l||"string"==typeof o;if(a&&l!==o){const e=i(o);return r.push((()=>t.replaceWith(e))),s(e)}if(!a){const n=l,a=o;if(void 0===n?.key&&void 0===a?.key||n?.key!==a?.key){if(n?.tag!==a?.tag||t instanceof Text){const e=i(o);return r.push((()=>t.replaceWith(e))),s(e)}for(let o=0;o<e.length;++o)e[o](t,a,n,r)}}}return s(t)})([(e,o,n,s=[])=>{const l={el:e,newVNode:o,oldVNode:n,workStack:s};if(o.flag===t.IGNORE_NODE)return l;if(o.flag===t.REPLACE_NODE)return e.replaceWith(i(o)),l;const a=n?.children??[],c=o.children,d=o.delta;if(d){for(let t=0;t<d.length;++t){const[o,n]=d[t],l=e.childNodes[n];switch(o){case 0:s.push((()=>e.insertBefore(i(c[n]),l)));break;case 1:r(l,c[n],a[n]);break;case 2:s.push((()=>e.removeChild(l)))}}return l}if(!c||o.flag===t.NO_CHILDREN)return a?(s.push((()=>e.textContent="")),l):l;if(void 0===o.flag||o.flag===t.ANY_CHILDREN){if(a)for(let t=a.length-1;t>=0;--t)r(e.childNodes[t],c[t],a[t]);for(let t=a.length??0;t<c.length;++t){const o=i(c[t],!1);s.push((()=>e.appendChild(o)))}return l}if(o.flag===t.ONLY_TEXT_CHILDREN)return s.push((()=>e.textContent=o.children.join(""))),l;if(o.flag===t.ONLY_KEYED_CHILDREN){let t=0,o=0,n=a.length-1,r=c.length-1;for(;t<=n&&o<=r&&a[n].key===c[r].key;)n--,r--;for(;t<=n&&o<=r&&a[t].key===c[o].key;)t++,o++;if(t>n)for(;o<=r;){const t=o++;s.push((()=>e.insertBefore(i(c[t],!1),e.childNodes[t])))}else if(o>r)for(;t<=n;){const o=e.childNodes[t++];s.push((()=>e.removeChild(o)))}else{const l={};for(let e=n;e>=t;--e)l[a[e].key]=e;for(;o<=r;){const t=c[o],n=l[t.key],r=e.childNodes[n],d=o++;void 0!==n&&t.key===a[n].key?(d!==n&&s.push((()=>e.insertBefore(r,e.childNodes[d]))),delete l[t.key]):s.push((()=>e.insertBefore(i(t,!1),e.childNodes[d])))}for(const t of Object.values(l)){const o=e.childNodes[t];s.push((()=>e.removeChild(o)))}}return l}return l},e()]),d=c(o,s,l,a);return n(d.workStack),d.el},s=e(),i=(e,t=!0)=>{if("string"==typeof e)return document.createTextNode(e);const o=e.props?.ns?document.createElementNS(e.props?.ns,e.tag):document.createElement(e.tag);if(n(s(o,e).workStack),e.children)for(let t=0;t<e.children.length;++t)o.appendChild(i(e.children[t]));return t&&(o.__m_old_vnode=e),o},l=e=>{if(e.__m_old_vnode)return e.__m_old_vnode;if(e instanceof Text)return String(e.nodeValue);const t={},o=new Array(e.children.length).fill(0);for(let o=0;o<e.attributes.length;o++)t[e.attributes[o].nodeName]=e.attributes[o].nodeValue;for(let t=0;t<e.childNodes.length;t++)o[t]=l(e.childNodes[t]);const n=((e,t,o,n,r)=>{let s;return t?.key&&(s=t.key,delete t.key),{tag:e,props:t,children:o,key:s,flag:n,delta:r}})(e.tagName,t,o);return e.__m_old_vnode=n,n};Promise.resolve();async function a(e){const t=await async function(e){const t=await fetch(e.split("?")[0].split("#")[0]+"/v_dom.json");if(!t.ok)throw new Error(`Failed to load ${e}. Status: ${t.status} ${t.statusText}`);const o=await t.text();return JSON.parse(o)}(e);for(const e in t){const o=t[e],n=document.getElementById(e);n?r(n,o,l(n)):(document.body.appendChild(i(o)),console.log("Warning: no element with id="+JSON.stringify(e)))}}window.addEventListener("click",(async e=>{window.__lastEvent=e;const t=e.target;if("a"===t.tagName.toLowerCase()&&(console.log("Anchor Event: "+t.href),t.href&&t.href.startsWith(location.origin))){e.preventDefault(),console.log(t.href+" is local link");try{await a(t.href),history.pushState({link:t.href},"",t.href)}catch(e){console.log("Using fallback"),window.location.href=t.href}}})),window.addEventListener("popstate",(async e=>{const t=e.state;console.log("popstate",t),t&&t.link?await a(t.link):await a(window.location.pathname)}));
//# sourceMappingURL=index.afc320dd.js.map

Back to list