@unsetsoft/ryunixjs 1.1.35 → 1.1.37-canary.1
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/Ryunix.js +134 -0
- package/dist/Ryunix.min.js +1 -1
- package/package.json +1 -1
package/dist/Ryunix.js
CHANGED
|
@@ -600,6 +600,136 @@
|
|
|
600
600
|
requestIdleCallback(workLoop);
|
|
601
601
|
};
|
|
602
602
|
|
|
603
|
+
function getTagKey(tag) {
|
|
604
|
+
if (tag.tag === 'title') return 'title'
|
|
605
|
+
if (tag.tag === 'meta') {
|
|
606
|
+
if (tag.attrs.name) return `meta[name="${tag.attrs.name}"]`
|
|
607
|
+
if (tag.attrs.property) return `meta[property="${tag.attrs.property}"]`
|
|
608
|
+
if (tag.attrs['http-equiv'])
|
|
609
|
+
return `meta[http-equiv="${tag.attrs['http-equiv']}"]`
|
|
610
|
+
if (tag.attrs.itemprop) return `meta[itemprop="${tag.attrs.itemprop}"]`
|
|
611
|
+
return `meta[${Object.entries(tag.attrs)
|
|
612
|
+
.map(([k, v]) => `${k}="${v}"`)
|
|
613
|
+
.join(' ')}]`
|
|
614
|
+
}
|
|
615
|
+
if (tag.tag === 'link') {
|
|
616
|
+
let key = `link[rel="${tag.attrs.rel || ''}"]`;
|
|
617
|
+
if (tag.attrs.hreflang) key += `[hreflang="${tag.attrs.hreflang}"]`;
|
|
618
|
+
if (tag.attrs.href) key += `[href="${tag.attrs.href}"]`;
|
|
619
|
+
return key
|
|
620
|
+
}
|
|
621
|
+
return `${tag.tag}:${JSON.stringify(tag.attrs)}`
|
|
622
|
+
}
|
|
623
|
+
|
|
624
|
+
function setHead(tags = []) {
|
|
625
|
+
document
|
|
626
|
+
.querySelectorAll('[data-ryunix-head]')
|
|
627
|
+
.forEach((el) => el.parentNode.removeChild(el));
|
|
628
|
+
|
|
629
|
+
const seen = new Set();
|
|
630
|
+
tags.forEach((tag) => {
|
|
631
|
+
const key = getTagKey(tag);
|
|
632
|
+
if (seen.has(key)) return
|
|
633
|
+
seen.add(key);
|
|
634
|
+
|
|
635
|
+
const el = document.createElement(tag.tag);
|
|
636
|
+
Object.entries(tag.attrs || {}).forEach(([k, v]) => {
|
|
637
|
+
if (k === 'children') {
|
|
638
|
+
el.textContent = v;
|
|
639
|
+
} else {
|
|
640
|
+
el.setAttribute(k, v);
|
|
641
|
+
}
|
|
642
|
+
});
|
|
643
|
+
if (tag.content) el.textContent = tag.content;
|
|
644
|
+
el.setAttribute('data-ryunix-head', 'true');
|
|
645
|
+
document.head.appendChild(el);
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function Metadata(metadata = {}) {
|
|
650
|
+
const tags = [];
|
|
651
|
+
|
|
652
|
+
if (metadata.title) {
|
|
653
|
+
tags.push({ tag: 'title', attrs: {}, content: metadata.title });
|
|
654
|
+
}
|
|
655
|
+
if (metadata.canonical) {
|
|
656
|
+
tags.push({
|
|
657
|
+
tag: 'link',
|
|
658
|
+
attrs: { rel: 'canonical', href: metadata.canonical },
|
|
659
|
+
});
|
|
660
|
+
}
|
|
661
|
+
if (Array.isArray(metadata.alternate)) {
|
|
662
|
+
metadata.alternate.forEach((alt) => {
|
|
663
|
+
tags.push({
|
|
664
|
+
tag: 'link',
|
|
665
|
+
attrs: { rel: 'alternate', hreflang: alt.hreflang, href: alt.href },
|
|
666
|
+
});
|
|
667
|
+
});
|
|
668
|
+
}
|
|
669
|
+
Object.entries(metadata).forEach(([key, value]) => {
|
|
670
|
+
if (key === 'title' || key === 'canonical' || key === 'alternate') return
|
|
671
|
+
if (key === 'content-language') {
|
|
672
|
+
tags.push({
|
|
673
|
+
tag: 'meta',
|
|
674
|
+
attrs: { 'http-equiv': 'content-language', content: value },
|
|
675
|
+
});
|
|
676
|
+
} else if (
|
|
677
|
+
key.startsWith('og:') ||
|
|
678
|
+
key.startsWith('twitter:') ||
|
|
679
|
+
key.startsWith('fb:') ||
|
|
680
|
+
key.startsWith('article:') ||
|
|
681
|
+
key.startsWith('profile:') ||
|
|
682
|
+
key.startsWith('book:') ||
|
|
683
|
+
key.startsWith('music:') ||
|
|
684
|
+
key.startsWith('video:')
|
|
685
|
+
) {
|
|
686
|
+
tags.push({ tag: 'meta', attrs: { property: key, content: value } });
|
|
687
|
+
} else if (key === 'itemprop') {
|
|
688
|
+
tags.push({ tag: 'meta', attrs: { itemprop: key, content: value } });
|
|
689
|
+
} else {
|
|
690
|
+
tags.push({ tag: 'meta', attrs: { name: key, content: value } });
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
694
|
+
setHead(tags);
|
|
695
|
+
|
|
696
|
+
// just for test
|
|
697
|
+
return tags
|
|
698
|
+
}
|
|
699
|
+
|
|
700
|
+
const headElements = [];
|
|
701
|
+
|
|
702
|
+
function Head(props) {
|
|
703
|
+
headElements.push(props.children);
|
|
704
|
+
return null
|
|
705
|
+
}
|
|
706
|
+
|
|
707
|
+
function renderHead() {
|
|
708
|
+
document
|
|
709
|
+
.querySelectorAll('[data-ryunix-head]')
|
|
710
|
+
.forEach((el) => el.parentNode.removeChild(el));
|
|
711
|
+
|
|
712
|
+
const seen = new Set();
|
|
713
|
+
headElements.flat().forEach((node) => {
|
|
714
|
+
if (!node || typeof node.type !== 'string') return
|
|
715
|
+
const key = getTagKey(node);
|
|
716
|
+
if (seen.has(key)) return
|
|
717
|
+
seen.add(key);
|
|
718
|
+
|
|
719
|
+
const el = document.createElement(node.type);
|
|
720
|
+
Object.entries(node.props || {}).forEach(([k, v]) => {
|
|
721
|
+
if (k === 'children') {
|
|
722
|
+
el.textContent = v;
|
|
723
|
+
} else {
|
|
724
|
+
el.setAttribute(k, v);
|
|
725
|
+
}
|
|
726
|
+
});
|
|
727
|
+
el.setAttribute('data-ryunix-head', 'true');
|
|
728
|
+
document.head.appendChild(el);
|
|
729
|
+
});
|
|
730
|
+
headElements = [];
|
|
731
|
+
}
|
|
732
|
+
|
|
603
733
|
/**
|
|
604
734
|
* Renders an element into a container using a work-in-progress (WIP) root.
|
|
605
735
|
* @function render
|
|
@@ -620,6 +750,8 @@
|
|
|
620
750
|
vars.nextUnitOfWork = vars.wipRoot;
|
|
621
751
|
vars.deletions = [];
|
|
622
752
|
scheduleWork(vars.wipRoot);
|
|
753
|
+
// TODO: Test Seo
|
|
754
|
+
renderHead();
|
|
623
755
|
return vars.wipRoot
|
|
624
756
|
};
|
|
625
757
|
|
|
@@ -1062,7 +1194,9 @@
|
|
|
1062
1194
|
window.Ryunix = Ryunix;
|
|
1063
1195
|
|
|
1064
1196
|
exports.Children = Children;
|
|
1197
|
+
exports.Head = Head;
|
|
1065
1198
|
exports.Image = Image;
|
|
1199
|
+
exports.Metadata = Metadata;
|
|
1066
1200
|
exports.NavLink = NavLink;
|
|
1067
1201
|
exports.RouterProvider = RouterProvider;
|
|
1068
1202
|
exports.createContext = createContext;
|
package/dist/Ryunix.min.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={},e.lodash)}(this,(function(e,t){"use strict";let o={containerRoot:null,nextUnitOfWork:null,currentRoot:null,wipRoot:null,deletions:null,wipFiber:null,hookIndex:null,effects:null};const n=/[A-Z]/g,r=Object.freeze({TEXT_ELEMENT:Symbol("text.element").toString(),Ryunix_ELEMENT:Symbol("ryunix.element").toString(),RYUNIX_EFFECT:Symbol("ryunix.effect").toString(),RYUNIX_MEMO:Symbol("ryunix.memo").toString(),RYUNIX_URL_QUERY:Symbol("ryunix.urlQuery").toString(),RYUNIX_REF:Symbol("ryunix.ref").toString(),RYUNIX_STORE:Symbol("ryunix.store").toString(),RYUNIX_REDUCE:Symbol("ryunix.reduce").toString(),RYUNIX_FRAGMENT:Symbol("ryunix.fragment").toString(),RYUNIX_CONTEXT:Symbol("ryunix.context").toString()}),i=Object.freeze({object:"object",function:"function",style:"ryunix-style",className:"ryunix-class",children:"children",boolean:"boolean",string:"string"}),s=Object.freeze({style:"style",className:"className"}),l=Object.freeze({PLACEMENT:Symbol("ryunix.reconciler.status.placement").toString(),UPDATE:Symbol("ryunix.reconciler.status.update").toString(),DELETION:Symbol("ryunix.reconciler.status.deletion").toString(),NO_EFFECT:Symbol("ryunix.reconciler.status.no_efect").toString()}),a=(e,t,...o)=>({type:e,props:{...t,children:o.flat().map((e=>typeof e===i.object?e:c(e)))}}),c=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),u=e=>{const t=Array.isArray(e.children)?e.children:[e.children];return a(r.RYUNIX_FRAGMENT,{},...t)},p=e=>e.startsWith("on"),d=e=>e!==i.children&&!p(e),h=(e,t)=>o=>e[o]!==t[o],f=e=>t=>!(t in e),y=e=>{e&&(e.hooks&&e.hooks.length>0&&e.hooks.filter((e=>e.type===r.RYUNIX_EFFECT&&typeof e.cancel===i.function)).forEach((e=>{e.cancel()})),e.child&&y(e.child),e.sibling&&y(e.sibling))},m=e=>{if(e.hooks&&0!==e.hooks.length)for(let t=0;t<e.hooks.length;t++){const o=e.hooks[t];if(o.type===r.RYUNIX_EFFECT&&typeof o.effect===i.function&&null!==o.effect){typeof o.cancel===i.function&&o.cancel();const e=o.effect();o.cancel="function"==typeof e?e:void 0}}},E=(e,t,o)=>{Object.keys(t).filter(p).filter((e=>f(o)(e)||h(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(d).filter(f(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(d).filter(h(t,o)).forEach((n=>{if(n===i.style)w(e,o["ryunix-style"]);else if(n===s.style)w(e,o.style);else if(n===i.className){if(""===o["ryunix-class"])throw new Error("data-class cannot be empty.");t["ryunix-class"]&&e.classList.remove(...t["ryunix-class"].split(/\s+/).filter(Boolean)||[]),e.classList.add(...o["ryunix-class"].split(/\s+/).filter(Boolean))}else if(n===s.className){if(""===o.className)throw new Error("className cannot be empty.");t.className&&e.classList.remove(...t.className.split(/\s+/).filter(Boolean)||[]),e.classList.add(...o.className.split(/\s+/).filter(Boolean))}else e[n]=o[n]})),Object.keys(o).filter(p).filter(h(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},w=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")},b=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.effectTag===l.PLACEMENT)null!=e.dom&&o.appendChild(e.dom),m(e);else if(e.effectTag===l.UPDATE)(e=>{e.hooks&&e.hooks.length>0&&e.hooks.filter((e=>e.type===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))})(e),null!=e.dom&&E(e.dom,e.alternate.props,e.props),m(e);else if(e.effectTag===l.DELETION)return y(e),void x(e,o);b(e.child),b(e.sibling)},x=(e,t)=>{if(e.dom)t.removeChild(e.dom);else{let o=e.child;for(;o;)x(o,t),o=o.sibling}},g=(e,t)=>{let n,r=0,i=e.alternate&&e.alternate.child;for(;r<t.length||null!=i;){const s=t[r];let a;const c=i&&s&&s.type==i.type;c&&(a={type:i.type,props:s.props,dom:i.dom,parent:e,alternate:i,effectTag:l.UPDATE,hooks:i.hooks}),s&&!c&&(a={type:s.type,props:s.props,dom:null,parent:e,alternate:null,effectTag:l.PLACEMENT}),i&&!c&&(i.effectTag=l.DELETION,o.deletions.push(i)),i&&(i=i.sibling),0===r?e.child=a:s&&(n.sibling=a),n=a,r++}},k=e=>{const t=Array.isArray(e.props.children)?e.props.children.flat():[e.props.children];e.type===r.RYUNIX_FRAGMENT||e.dom||(e.dom=(e=>{if(e.type===r.RYUNIX_FRAGMENT)return null;const t=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return E(t,{},e.props),t})(e)),g(e,t)},R=({src:e,props:t})=>{const o=new URLSearchParams,n=!e.startsWith("http")||!e.startsWith("https");t.width&&o.set("width",t.width),t.height&&o.set("height",t.height),t.quality&&o.set("quality",t.quality);const r=t.extension?`@${t.extension}`:"";return n?(()=>{const{hostname:e}=window.location;return"localhost"===e||"127.0.0.1"===e})()?(console.warn("Image optimizations only work with full links and must not contain localhost."),e):`${window.location.origin}/${e}`:`https://image.unsetsoft.com/image/${e}${r}?${o.toString()}`},N=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=I(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&(o.deletions.forEach(b),b(o.wipRoot.child),o.currentRoot=o.wipRoot,o.wipRoot=null),requestIdleCallback(N)};requestIdleCallback(N);const I=e=>{if(e.type instanceof Function?(e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=[e.type(e.props)];e.type._contextId&&void 0!==e.props.value&&(e._contextId=e.type._contextId,e._contextValue=e.props.value),g(e,t)})(e):k(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}},v=e=>{o.nextUnitOfWork=e,o.wipRoot=e,o.deletions=[],o.hookIndex=0,o.effects=[],requestIdleCallback(N)},F=(e,t)=>(o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[],v(o.wipRoot),o.wipRoot),T=(e,t)=>_(((e,t)=>"function"==typeof t?t(e):t),e,t),_=(e,t,n)=>{const s=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],l={hookID:o.hookIndex,type:r.RYUNIX_STORE,state:s?s.state:n?n(t):t,queue:s&&Array.isArray(s.queue)?s.queue.slice():[]};s&&Array.isArray(s.queue)&&s.queue.forEach((t=>{l.state=e(l.state,t)}));return l.queue.forEach((t=>{l.state=e(l.state,t)})),o.wipFiber.hooks[o.hookIndex]=l,o.hookIndex++,[l.state,e=>{l.queue.push(typeof e===i.function?e:t=>e),o.wipRoot={dom:o.currentRoot.dom,props:o.currentRoot.props,alternate:o.currentRoot},o.deletions=[],o.hookIndex=0,v(o.wipRoot)}]},S=(e,t)=>{const n=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],i=(s=n?.deps,l=t,!s||!l||s.length!==l.length||s.some(((e,t)=>e!==l[t])));var s,l;const a={hookID:o.hookIndex,type:r.RYUNIX_EFFECT,deps:t,effect:i?e:null,cancel:n?.cancel};o.wipFiber.hooks[o.hookIndex]=a,o.hookIndex++},U=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={type:r.RYUNIX_REF,value:t?t.value:{current:e}};return o.wipFiber.hooks[o.hookIndex]=n,o.hookIndex++,n.value},C=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_MEMO,value:null,deps:n};return i&&t.isEqual(i.deps,s.deps)?s.value=i.value:s.value=e(),o.wipFiber.hooks[o.hookIndex]=s,o.hookIndex++,s.value},L=(e,t)=>C((()=>e),t),O=(e=r.RYUNIX_CONTEXT,t={})=>{const n=({children:e})=>u({children:e});n._contextId=e;return{Provider:n,useContext:(e=r.RYUNIX_CONTEXT)=>{let n=o.wipFiber;for(;n;){if(n.type&&n.type._contextId===e)return n.props&&"value"in n.props?n.props.value:void 0;n=n.parent}return t}}},X=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},Y=()=>{const[e,t]=T(window.location.hash);return S((()=>{const e=()=>{t(window.location.hash)};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),[]),e},A=O("ryunix.navigation",{location:"/",params:{},query:{},navigate:e=>{},route:null}),q=(e,t)=>{const o=t.split("?")[0].split("#")[0],n=e.find((e=>e.NotFound)),r=n?{route:{component:n.NotFound},params:{}}:{route:{component:null},params:{}};for(const n of e){if(n.subRoutes){const e=q(n.subRoutes,t);if(e)return e}if("*"===n.path)return r;if(!n.path||"string"!=typeof n.path){console.warn("Invalid route detected:",n),console.info("if you are using { NotFound: NotFound } please add { path: '*', NotFound: NotFound }");continue}const e=[],i=new RegExp(`^${n.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),s=o.match(i);if(s){return{route:n,params:e.reduce(((e,t,o)=>(e[t]=s[o+1],e)),{})}}}return r},M=({routes:e,children:t})=>{const[o,n]=T(window.location.pathname);S((()=>{const e=()=>n(window.location.pathname);return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),()=>{window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}}),[o]);const r=q(e,o)||{},i=X(),s={location:o,params:r.params||{},query:i,navigate:e=>{window.history.pushState({},"",e),n(e)},route:r.route};return a(A.Provider,{value:s},u({children:t}))},j=()=>A.useContext("ryunix.navigation"),P=()=>{const{route:e,params:t,query:o,location:n}=j();if(!e||!e.component)return null;const r=Y();return S((()=>{if(r){const e=r.slice(1),t=document.getElementById(e);t&&t.scrollIntoView({block:"start",behavior:"smooth"})}}),[r]),a(e.component,{key:n,params:t,query:o,hash:r})},W=({to:e,exact:t=!1,...o})=>{const{location:n,navigate:r}=j(),i=t?n===e:n.startsWith(e),s=o["ryunix-class"]?"ryunix-class":"className",l="function"==typeof(c=o["ryunix-class"]||o.className)?c({isActive:i}):c||"";var c;const{"ryunix-class":u,className:p,...d}=o;return a("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},[s]:l,...d},o.children)};var D={createElement:a,render:F,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t);return F(e,o.containerRoot)},Fragment:u,Hooks:Object.freeze({__proto__:null,Children:P,NavLink:W,RouterProvider:M,createContext:O,useCallback:L,useEffect:S,useHash:Y,useMemo:C,useQuery:X,useRef:U,useRouter:j,useStore:T})};window.Ryunix=D,e.Children=P,e.Image=({src:e,...t})=>{const o={src:"true"===t.optimization?R({src:e,props:t}):e,...t};return a("img",o,null)},e.NavLink=W,e.RouterProvider=M,e.createContext=O,e.default=D,e.useCallback=L,e.useEffect=S,e.useHash=Y,e.useMemo=C,e.useQuery=X,e.useRef=U,e.useRouter=j,e.useStore=T,Object.defineProperty(e,"__esModule",{value:!0})}));
|
|
1
|
+
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={},e.lodash)}(this,(function(e,t){"use strict";let o={containerRoot:null,nextUnitOfWork:null,currentRoot:null,wipRoot:null,deletions:null,wipFiber:null,hookIndex:null,effects:null};const n=/[A-Z]/g,r=Object.freeze({TEXT_ELEMENT:Symbol("text.element").toString(),Ryunix_ELEMENT:Symbol("ryunix.element").toString(),RYUNIX_EFFECT:Symbol("ryunix.effect").toString(),RYUNIX_MEMO:Symbol("ryunix.memo").toString(),RYUNIX_URL_QUERY:Symbol("ryunix.urlQuery").toString(),RYUNIX_REF:Symbol("ryunix.ref").toString(),RYUNIX_STORE:Symbol("ryunix.store").toString(),RYUNIX_REDUCE:Symbol("ryunix.reduce").toString(),RYUNIX_FRAGMENT:Symbol("ryunix.fragment").toString(),RYUNIX_CONTEXT:Symbol("ryunix.context").toString()}),a=Object.freeze({object:"object",function:"function",style:"ryunix-style",className:"ryunix-class",children:"children",boolean:"boolean",string:"string"}),i=Object.freeze({style:"style",className:"className"}),s=Object.freeze({PLACEMENT:Symbol("ryunix.reconciler.status.placement").toString(),UPDATE:Symbol("ryunix.reconciler.status.update").toString(),DELETION:Symbol("ryunix.reconciler.status.deletion").toString(),NO_EFFECT:Symbol("ryunix.reconciler.status.no_efect").toString()}),l=(e,t,...o)=>({type:e,props:{...t,children:o.flat().map((e=>typeof e===a.object?e:c(e)))}}),c=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),u=e=>{const t=Array.isArray(e.children)?e.children:[e.children];return l(r.RYUNIX_FRAGMENT,{},...t)},p=e=>e.startsWith("on"),h=e=>e!==a.children&&!p(e),d=(e,t)=>o=>e[o]!==t[o],f=e=>t=>!(t in e),y=e=>{e&&(e.hooks&&e.hooks.length>0&&e.hooks.filter((e=>e.type===r.RYUNIX_EFFECT&&typeof e.cancel===a.function)).forEach((e=>{e.cancel()})),e.child&&y(e.child),e.sibling&&y(e.sibling))},m=e=>{if(e.hooks&&0!==e.hooks.length)for(let t=0;t<e.hooks.length;t++){const o=e.hooks[t];if(o.type===r.RYUNIX_EFFECT&&typeof o.effect===a.function&&null!==o.effect){typeof o.cancel===a.function&&o.cancel();const e=o.effect();o.cancel="function"==typeof e?e:void 0}}},g=(e,t,o)=>{Object.keys(t).filter(p).filter((e=>f(o)(e)||d(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(h).filter(f(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(h).filter(d(t,o)).forEach((n=>{if(n===a.style)E(e,o["ryunix-style"]);else if(n===i.style)E(e,o.style);else if(n===a.className){if(""===o["ryunix-class"])throw new Error("data-class cannot be empty.");t["ryunix-class"]&&e.classList.remove(...t["ryunix-class"].split(/\s+/).filter(Boolean)||[]),e.classList.add(...o["ryunix-class"].split(/\s+/).filter(Boolean))}else if(n===i.className){if(""===o.className)throw new Error("className cannot be empty.");t.className&&e.classList.remove(...t.className.split(/\s+/).filter(Boolean)||[]),e.classList.add(...o.className.split(/\s+/).filter(Boolean))}else e[n]=o[n]})),Object.keys(o).filter(p).filter(d(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},E=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")},b=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.effectTag===s.PLACEMENT)null!=e.dom&&o.appendChild(e.dom),m(e);else if(e.effectTag===s.UPDATE)(e=>{e.hooks&&e.hooks.length>0&&e.hooks.filter((e=>e.type===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))})(e),null!=e.dom&&g(e.dom,e.alternate.props,e.props),m(e);else if(e.effectTag===s.DELETION)return y(e),void w(e,o);b(e.child),b(e.sibling)},w=(e,t)=>{if(e.dom)t.removeChild(e.dom);else{let o=e.child;for(;o;)w(o,t),o=o.sibling}},x=(e,t)=>{let n,r=0,a=e.alternate&&e.alternate.child;for(;r<t.length||null!=a;){const i=t[r];let l;const c=a&&i&&i.type==a.type;c&&(l={type:a.type,props:i.props,dom:a.dom,parent:e,alternate:a,effectTag:s.UPDATE,hooks:a.hooks}),i&&!c&&(l={type:i.type,props:i.props,dom:null,parent:e,alternate:null,effectTag:s.PLACEMENT}),a&&!c&&(a.effectTag=s.DELETION,o.deletions.push(a)),a&&(a=a.sibling),0===r?e.child=l:i&&(n.sibling=l),n=l,r++}},k=e=>{const t=Array.isArray(e.props.children)?e.props.children.flat():[e.props.children];e.type===r.RYUNIX_FRAGMENT||e.dom||(e.dom=(e=>{if(e.type===r.RYUNIX_FRAGMENT)return null;const t=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return g(t,{},e.props),t})(e)),x(e,t)},R=({src:e,props:t})=>{const o=new URLSearchParams,n=!e.startsWith("http")||!e.startsWith("https");t.width&&o.set("width",t.width),t.height&&o.set("height",t.height),t.quality&&o.set("quality",t.quality);const r=t.extension?`@${t.extension}`:"";return n?(()=>{const{hostname:e}=window.location;return"localhost"===e||"127.0.0.1"===e})()?(console.warn("Image optimizations only work with full links and must not contain localhost."),e):`${window.location.origin}/${e}`:`https://image.unsetsoft.com/image/${e}${r}?${o.toString()}`},N=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=v(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&(o.deletions.forEach(b),b(o.wipRoot.child),o.currentRoot=o.wipRoot,o.wipRoot=null),requestIdleCallback(N)};requestIdleCallback(N);const v=e=>{if(e.type instanceof Function?(e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=[e.type(e.props)];e.type._contextId&&void 0!==e.props.value&&(e._contextId=e.type._contextId,e._contextValue=e.props.value),x(e,t)})(e):k(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}},I=e=>{o.nextUnitOfWork=e,o.wipRoot=e,o.deletions=[],o.hookIndex=0,o.effects=[],requestIdleCallback(N)};function F(e){if("title"===e.tag)return"title";if("meta"===e.tag)return e.attrs.name?`meta[name="${e.attrs.name}"]`:e.attrs.property?`meta[property="${e.attrs.property}"]`:e.attrs["http-equiv"]?`meta[http-equiv="${e.attrs["http-equiv"]}"]`:e.attrs.itemprop?`meta[itemprop="${e.attrs.itemprop}"]`:`meta[${Object.entries(e.attrs).map((([e,t])=>`${e}="${t}"`)).join(" ")}]`;if("link"===e.tag){let t=`link[rel="${e.attrs.rel||""}"]`;return e.attrs.hreflang&&(t+=`[hreflang="${e.attrs.hreflang}"]`),e.attrs.href&&(t+=`[href="${e.attrs.href}"]`),t}return`${e.tag}:${JSON.stringify(e.attrs)}`}const T=[];const S=(e,t)=>(o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[],I(o.wipRoot),function(){document.querySelectorAll("[data-ryunix-head]").forEach((e=>e.parentNode.removeChild(e)));const e=new Set;T.flat().forEach((t=>{if(!t||"string"!=typeof t.type)return;const o=F(t);if(e.has(o))return;e.add(o);const n=document.createElement(t.type);Object.entries(t.props||{}).forEach((([e,t])=>{"children"===e?n.textContent=t:n.setAttribute(e,t)})),n.setAttribute("data-ryunix-head","true"),document.head.appendChild(n)})),T=[]}(),o.wipRoot),_=(e,t)=>C(((e,t)=>"function"==typeof t?t(e):t),e,t),C=(e,t,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={hookID:o.hookIndex,type:r.RYUNIX_STORE,state:i?i.state:n?n(t):t,queue:i&&Array.isArray(i.queue)?i.queue.slice():[]};i&&Array.isArray(i.queue)&&i.queue.forEach((t=>{s.state=e(s.state,t)}));return s.queue.forEach((t=>{s.state=e(s.state,t)})),o.wipFiber.hooks[o.hookIndex]=s,o.hookIndex++,[s.state,e=>{s.queue.push(typeof e===a.function?e:t=>e),o.wipRoot={dom:o.currentRoot.dom,props:o.currentRoot.props,alternate:o.currentRoot},o.deletions=[],o.hookIndex=0,I(o.wipRoot)}]},U=(e,t)=>{const n=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],a=(i=n?.deps,s=t,!i||!s||i.length!==s.length||i.some(((e,t)=>e!==s[t])));var i,s;const l={hookID:o.hookIndex,type:r.RYUNIX_EFFECT,deps:t,effect:a?e:null,cancel:n?.cancel};o.wipFiber.hooks[o.hookIndex]=l,o.hookIndex++},O=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={type:r.RYUNIX_REF,value:t?t.value:{current:e}};return o.wipFiber.hooks[o.hookIndex]=n,o.hookIndex++,n.value},L=(e,n)=>{const a=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],i={type:r.RYUNIX_MEMO,value:null,deps:n};return a&&t.isEqual(a.deps,i.deps)?i.value=a.value:i.value=e(),o.wipFiber.hooks[o.hookIndex]=i,o.hookIndex++,i.value},A=(e,t)=>L((()=>e),t),X=(e=r.RYUNIX_CONTEXT,t={})=>{const n=({children:e})=>u({children:e});n._contextId=e;return{Provider:n,useContext:(e=r.RYUNIX_CONTEXT)=>{let n=o.wipFiber;for(;n;){if(n.type&&n.type._contextId===e)return n.props&&"value"in n.props?n.props.value:void 0;n=n.parent}return t}}},q=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},$=()=>{const[e,t]=_(window.location.hash);return U((()=>{const e=()=>{t(window.location.hash)};return window.addEventListener("hashchange",e),()=>window.removeEventListener("hashchange",e)}),[]),e},Y=X("ryunix.navigation",{location:"/",params:{},query:{},navigate:e=>{},route:null}),j=(e,t)=>{const o=t.split("?")[0].split("#")[0],n=e.find((e=>e.NotFound)),r=n?{route:{component:n.NotFound},params:{}}:{route:{component:null},params:{}};for(const n of e){if(n.subRoutes){const e=j(n.subRoutes,t);if(e)return e}if("*"===n.path)return r;if(!n.path||"string"!=typeof n.path){console.warn("Invalid route detected:",n),console.info("if you are using { NotFound: NotFound } please add { path: '*', NotFound: NotFound }");continue}const e=[],a=new RegExp(`^${n.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),i=o.match(a);if(i){return{route:n,params:e.reduce(((e,t,o)=>(e[t]=i[o+1],e)),{})}}}return r},M=({routes:e,children:t})=>{const[o,n]=_(window.location.pathname);U((()=>{const e=()=>n(window.location.pathname);return window.addEventListener("popstate",e),window.addEventListener("hashchange",e),()=>{window.removeEventListener("popstate",e),window.removeEventListener("hashchange",e)}}),[o]);const r=j(e,o)||{},a=q(),i={location:o,params:r.params||{},query:a,navigate:e=>{window.history.pushState({},"",e),n(e)},route:r.route};return l(Y.Provider,{value:i},u({children:t}))},W=()=>Y.useContext("ryunix.navigation"),P=()=>{const{route:e,params:t,query:o,location:n}=W();if(!e||!e.component)return null;const r=$();return U((()=>{if(r){const e=r.slice(1),t=document.getElementById(e);t&&t.scrollIntoView({block:"start",behavior:"smooth"})}}),[r]),l(e.component,{key:n,params:t,query:o,hash:r})},D=({to:e,exact:t=!1,...o})=>{const{location:n,navigate:r}=W(),a=t?n===e:n.startsWith(e),i=o["ryunix-class"]?"ryunix-class":"className",s="function"==typeof(c=o["ryunix-class"]||o.className)?c({isActive:a}):c||"";var c;const{"ryunix-class":u,className:p,...h}=o;return l("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},[i]:s,...h},o.children)};var z={createElement:l,render:S,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t);return S(e,o.containerRoot)},Fragment:u,Hooks:Object.freeze({__proto__:null,Children:P,NavLink:D,RouterProvider:M,createContext:X,useCallback:A,useEffect:U,useHash:$,useMemo:L,useQuery:q,useRef:O,useRouter:W,useStore:_})};window.Ryunix=z,e.Children=P,e.Head=function(e){return T.push(e.children),null},e.Image=({src:e,...t})=>{const o={src:"true"===t.optimization?R({src:e,props:t}):e,...t};return l("img",o,null)},e.Metadata=function(e={}){const t=[];return e.title&&t.push({tag:"title",attrs:{},content:e.title}),e.canonical&&t.push({tag:"link",attrs:{rel:"canonical",href:e.canonical}}),Array.isArray(e.alternate)&&e.alternate.forEach((e=>{t.push({tag:"link",attrs:{rel:"alternate",hreflang:e.hreflang,href:e.href}})})),Object.entries(e).forEach((([e,o])=>{"title"!==e&&"canonical"!==e&&"alternate"!==e&&("content-language"===e?t.push({tag:"meta",attrs:{"http-equiv":"content-language",content:o}}):e.startsWith("og:")||e.startsWith("twitter:")||e.startsWith("fb:")||e.startsWith("article:")||e.startsWith("profile:")||e.startsWith("book:")||e.startsWith("music:")||e.startsWith("video:")?t.push({tag:"meta",attrs:{property:e,content:o}}):"itemprop"===e?t.push({tag:"meta",attrs:{itemprop:e,content:o}}):t.push({tag:"meta",attrs:{name:e,content:o}}))})),function(e=[]){document.querySelectorAll("[data-ryunix-head]").forEach((e=>e.parentNode.removeChild(e)));const t=new Set;e.forEach((e=>{const o=F(e);if(t.has(o))return;t.add(o);const n=document.createElement(e.tag);Object.entries(e.attrs||{}).forEach((([e,t])=>{"children"===e?n.textContent=t:n.setAttribute(e,t)})),e.content&&(n.textContent=e.content),n.setAttribute("data-ryunix-head","true"),document.head.appendChild(n)}))}(t),t},e.NavLink=D,e.RouterProvider=M,e.createContext=X,e.default=z,e.useCallback=A,e.useEffect=U,e.useHash=$,e.useMemo=L,e.useQuery=q,e.useRef=O,e.useRouter=W,e.useStore=_,Object.defineProperty(e,"__esModule",{value:!0})}));
|