@unsetsoft/ryunixjs 1.1.5-nightly.13 → 1.1.5-nightly.15
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 +1 -1
- package/package.json +1 -1
package/dist/Ryunix.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={})}(this,(function(e){"use strict";const
|
|
1
|
+
!function(e,o){"object"==typeof exports&&"undefined"!=typeof module?o(exports,require("lodash")):"function"==typeof define&&define.amd?define(["exports","lodash"],o):o((e="undefined"!=typeof globalThis?globalThis:e||self).Ryunix={},e.lodash)}(this,(function(e,o){"use strict";const t={containerRoot:void 0,nextUnitOfWork:void 0,currentRoot:void 0,wipRoot:void 0,deletions:void 0,wipFiber:void 0,hookIndex:void 0,pendingUpdates:void 0},n=/[A-Z]/g,r=Object.freeze({TEXT_ELEMENT:Symbol("text.element"),Ryunix_ELEMENT:Symbol("ryunix.element"),RYUNIX_EFFECT:Symbol("ryunix.effect"),RYUNIX_MEMO:Symbol("ryunix.memo"),RYUNIX_URL_QUERY:Symbol("ryunix.urlQuery"),RYUNIX_REF:Symbol("ryunix.ref")}),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"}),a=Object.freeze({PLACEMENT:Symbol(),UPDATE:Symbol(),DELETION:Symbol()}),l=e=>e.map((e=>JSON.stringify(e))).join("-"),c=e=>e.children,p=(e,o)=>(o=o||[],null==e||typeof e==i.boolean||(Array.isArray(e)?e.some((e=>{p(e,o)})):o.push(e)),o),u=(e,o,...t)=>{t=p(t,[]);const n=o&&o.key?o.key:`${r.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...o,key:n,children:t.map((e=>typeof e===i.object?e:d(e)))}}},d=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),f=(e,o)=>{t.wipRoot={dom:t.containerRoot||o,props:{children:[e]},alternate:t.currentRoot},t.deletions=[],t.nextUnitOfWork=t.wipRoot},h=e=>{const o=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],n={state:o?o.state:e,queue:o?[...o.queue]:[]};n.queue.forEach((e=>{n.state=typeof e===i.function?e(n.state):e})),n.queue=[];return t.wipFiber&&t.wipFiber.hooks&&(t.wipFiber.hooks.push(n),t.hookIndex++),[n.state,e=>{n.queue.push(e),t.wipRoot={dom:t.currentRoot.dom,props:t.currentRoot.props,alternate:t.currentRoot},t.nextUnitOfWork=t.wipRoot,t.deletions=[]}]},m=(e,n)=>{const i=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],s={type:r.RYUNIX_EFFECT,deps:n};i&&o.isEqual(i.deps,s.deps)||e(),t.wipFiber.hooks&&(t.wipFiber.hooks.push(s),t.hookIndex++)},y=(e,o)=>{const n=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],i={type:r.RYUNIX_MEMO,value:null,deps:o,hash:l(o)};return n&&n.hash===i.hash?i.value=n.value:i.value=e(),t.wipFiber.hooks&&(t.wipFiber.hooks.push(i),t.hookIndex++),i.value},b=()=>{const e=new URLSearchParams(window.location.search),o={};for(let[t,n]of e.entries())o[t]=n;return o},E=e=>e.startsWith("on"),w=e=>e!==i.children&&!E(e),k=(e,o)=>t=>e[t]!==o[t],R=e=>o=>!(o in e),F=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},v=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},x=e=>{const o=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return N(o,{},e.props),o},N=(e,o,t)=>{Object.keys(o).filter(E).filter((e=>R(t)(e)||k(o,t)(e))).forEach((t=>{const n=t.toLowerCase().substring(2);e.removeEventListener(n,o[t])})),Object.keys(o).filter(w).filter(R(t)).forEach((o=>{e[o]=""})),Object.keys(t).filter(w).filter(k(o,t)).forEach((n=>{if(n===i.style)_(e,t["ryunix-style"]);else if(n===s.style)_(e,t.style);else if(n===i.className){if(""===t["ryunix-class"])throw new Error("data-class cannot be empty.");o["ryunix-class"]&&e.classList.remove(...o["ryunix-class"].split(/\s+/)),e.classList.add(...t["ryunix-class"].split(/\s+/))}else if(n===s.className){if(""===t.className)throw new Error("className cannot be empty.");o.className&&e.classList.remove(...o.className.split(/\s+/)),e.classList.add(...t.className.split(/\s+/))}else e[n]=t[n]})),Object.keys(t).filter(E).filter(k(o,t)).forEach((o=>{const n=o.toLowerCase().substring(2);e.addEventListener(n,t[o])}))},_=(e,o)=>{e.style=Object.keys(o).reduce(((e,t)=>e+=`${t.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${o[t]};`),"")};var g=Object.freeze({__proto__:null,DomStyle:_,createDom:x,updateDom:N});const T=()=>{t.deletions.forEach(O),t.wipRoot&&t.wipRoot.child&&(O(t.wipRoot.child),t.currentRoot=t.wipRoot),t.wipRoot=void 0},O=e=>{if(!e)return;let o=e.parent;for(;!o.dom;)o=o.parent;const t=o.dom;if(e.effectTag===a.PLACEMENT&&(null!=e.dom&&t.appendChild(e.dom),v(e)),e.effectTag===a.UPDATE&&(F(e),null!=e.dom&&N(e.dom,e.alternate.props,e.props),v(e)),e.effectTag===a.DELETION)return I(e,t),void F(e);O(e.child),O(e.sibling)},I=(e,o)=>{e.dom?o.removeChild(e.dom):I(e.child,o)};var L=Object.freeze({__proto__:null,commitDeletion:I,commitRoot:T,commitWork:O});const U=(e,o)=>{let n=0,r=e.alternate&&e.alternate.child,i=null;const s=new Map;for(;r;){const e=r.props.key||r.type;s.set(e,r),r=r.sibling}for(;n<o.length;){const r=o[n],l=r.props.key||r.type,c=s.get(l);let p;c&&r&&r.type===c.type?(p={type:c.type,props:r.props,dom:c.dom,parent:e,alternate:c,effectTag:a.UPDATE},s.delete(l)):r&&(p={type:r.type,props:r.props,dom:void 0,parent:e,alternate:void 0,effectTag:a.PLACEMENT}),s.forEach((e=>{e.effectTag=a.DELETION,t.deletions.push(e)})),0===n?e.child=p:i&&(i.sibling=p),i=p,n++}};var C=Object.freeze({__proto__:null,reconcileChildren:U});const j=e=>{t.wipFiber=e,t.hookIndex=0,t.wipFiber.hooks=[];const o=e.type(e.props);let n=[];n=Array.isArray(o)?[...o]:[o],U(e,n)},M=e=>{e.dom||(e.dom=x(e)),U(e,e.props.children)};var S=Object.freeze({__proto__:null,updateFunctionComponent:j,updateHostComponent:M});const D=e=>{let o=!1;for(;t.nextUnitOfWork&&!o;)t.nextUnitOfWork=X(t.nextUnitOfWork),o=e.timeRemaining()<1;!t.nextUnitOfWork&&t.wipRoot&&T(),requestIdleCallback(D)};requestIdleCallback(D);const X=e=>{if(e.type instanceof Function?j(e):M(e),e.child)return e.child;let o=e;for(;o;){if(o.sibling)return o.sibling;o=o.parent}};var A={createElement:u,render:f,init:(e,o="__ryunix")=>{t.containerRoot=document.getElementById(o),f(e,t.containerRoot)},Fragment:c,Dom:g,Workers:Object.freeze({__proto__:null,performUnitOfWork:X,workLoop:D}),Reconciler:C,Components:S,Commits:L};window.Ryunix=A,e.Fragment=c,e.default=A,e.useCallback=(e,o)=>y((()=>e),o),e.useEffect=m,e.useMemo=y,e.useQuery=b,e.useRef=e=>{const o=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],n={type:r.RYUNIX_REF,value:o?o.value:{current:e}};return t.wipFiber.hooks&&(t.wipFiber.hooks.push(n),t.hookIndex++),n.value},e.useRouter=e=>{const[o,t]=h(window.location.pathname),n=(e,o)=>{const t=o.split("?")[0],r=e.find((e=>e.NotFound)),i=r?{route:{component:r.NotFound},params:{}}:{route:{component:null},params:{}};for(const r of e){if(r.subRoutes){const e=n(r.subRoutes,o);if(e)return e}if("*"===r.path)return i;if(!r.path||"string"!=typeof r.path){console.warn("Invalid route detected:",r),console.info("if you are using { NotFound: NotFound } please add { path: '*', NotFound: NotFound }");continue}const e=[],s=new RegExp(`^${r.path.replace(/:\w+/g,(o=>(e.push(o.substring(1)),"([^/]+)")))}$`),a=t.match(s);if(a){return{route:r,params:e.reduce(((e,o,t)=>(e[o]=a[t+1],e)),{})}}}return i},r=(e,o)=>{e.forEach((e=>{e.path!==o&&((async e=>{e&&typeof e.preload===i.function&&await e.preload()})(e.component),e.subRoutes&&r(e.subRoutes,o))}))},s=e=>{window.history.pushState({},"",e),a(e)},a=e=>{const o=e.split("?")[0];t(o)};m((()=>{const t=()=>a(window.location.pathname);return window.addEventListener("popstate",t),r(e,o),()=>window.removeEventListener("popstate",t)}),[o,e]);const l=n(e,o)||{};return{Children:()=>{const e=b(),{route:o}=l;return o&&o.component&&typeof o.component===i.function?o.component({params:l.params||{},query:e}):(console.error("Component not found for current path or the component is not a valid function:",l),null)},NavLink:({to:e,...o})=>u("a",{href:e,onClick:o=>{o.preventDefault(),s(e)},...o},o.children),navigate:s}},e.useStore=h,Object.defineProperty(e,"__esModule",{value:!0})}));
|