@unsetsoft/ryunixjs 1.1.5-nightly.13 → 1.1.5-nightly.14
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 o={containerRoot:void 0,nextUnitOfWork:void 0,currentRoot:void 0,wipRoot:void 0,deletions:void 0,wipFiber:void 0,hookIndex:void 0,pendingUpdates:void 0},t=/[A-Z]/g,n=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")}),r=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(),UPDATE:Symbol(),DELETION:Symbol()}),a=e=>e.map((e=>JSON.stringify(e))).join("-"),l=e=>e.children,c=(e,o)=>(o=o||[],null==e||typeof e==r.boolean||(Array.isArray(e)?e.some((e=>{c(e,o)})):o.push(e)),o),p=(e,o,...t)=>{t=c(t,[]);const i=o&&o.key?o.key:`${n.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...o,key:i,children:t.map((e=>typeof e===r.object?e:u(e)))}}},u=e=>({type:n.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,t)=>{o.wipRoot={dom:o.containerRoot||t,props:{children:[e]},alternate:o.currentRoot},o.deletions=[],o.nextUnitOfWork=o.wipRoot},f=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={state:t?t.state:e,queue:t?[...t.queue]:[]};n.queue.forEach((e=>{n.state=typeof e===r.function?e(n.state):e})),n.queue=[]
|
|
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 o={containerRoot:void 0,nextUnitOfWork:void 0,currentRoot:void 0,wipRoot:void 0,deletions:void 0,wipFiber:void 0,hookIndex:void 0,pendingUpdates:void 0},t=/[A-Z]/g,n=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")}),r=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(),UPDATE:Symbol(),DELETION:Symbol()}),a=e=>e.map((e=>JSON.stringify(e))).join("-"),l=e=>e.children,c=(e,o)=>(o=o||[],null==e||typeof e==r.boolean||(Array.isArray(e)?e.some((e=>{c(e,o)})):o.push(e)),o),p=(e,o,...t)=>{t=c(t,[]);const i=o&&o.key?o.key:`${n.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...o,key:i,children:t.map((e=>typeof e===r.object?e:u(e)))}}},u=e=>({type:n.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,t)=>{o.wipRoot={dom:o.containerRoot||t,props:{children:[e]},alternate:o.currentRoot},o.deletions=[],o.nextUnitOfWork=o.wipRoot},f=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],n={state:t?t.state:e,queue:t?[...t.queue]:[]};n.queue.forEach((e=>{n.state=typeof e===r.function?e(n.state):e})),n.queue=[];return o.wipFiber&&o.wipFiber.hooks&&(o.wipFiber.hooks.push(n),o.hookIndex++),[n.state,e=>{n.queue.push(e),o.wipRoot={dom:o.currentRoot.dom,props:o.currentRoot.props,alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[]}]},h=(e,t)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:n.RYUNIX_EFFECT,deps:t,hash:a(t),cleanup:i?i.cleanup:void 0};if(!i||i.hash!==s.hash){s.cleanup&&s.cleanup();const o=e();typeof o===r.function&&(s.cleanup=o)}o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.hookIndex++)},m=(e,t)=>{const r=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],i={type:n.RYUNIX_MEMO,value:null,deps:t,hash:a(t)};return r&&r.hash===i.hash?i.value=r.value:i.value=e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(i),o.hookIndex++),i.value},y=()=>{const e=new URLSearchParams(window.location.search),o={};for(let[t,n]of e.entries())o[t]=n;return o},b=e=>e.startsWith("on"),E=e=>e!==r.children&&!b(e),w=(e,o)=>t=>e[t]!==o[t],k=e=>o=>!(o in e),R=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},F=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},v=e=>{const o=e.type==n.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return x(o,{},e.props),o},x=(e,o,t)=>{Object.keys(o).filter(b).filter((e=>k(t)(e)||w(o,t)(e))).forEach((t=>{const n=t.toLowerCase().substring(2);e.removeEventListener(n,o[t])})),Object.keys(o).filter(E).filter(k(t)).forEach((o=>{e[o]=""})),Object.keys(t).filter(E).filter(w(o,t)).forEach((n=>{if(n===r.style)N(e,t["ryunix-style"]);else if(n===i.style)N(e,t.style);else if(n===r.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===i.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(b).filter(w(o,t)).forEach((o=>{const n=o.toLowerCase().substring(2);e.addEventListener(n,t[o])}))},N=(e,o)=>{e.style=Object.keys(o).reduce(((e,n)=>e+=`${n.replace(t,(function(e){return"-"+e.toLowerCase()}))}: ${o[n]};`),"")};var _=Object.freeze({__proto__:null,DomStyle:N,createDom:v,updateDom:x});const g=()=>{o.deletions.forEach(T),o.wipRoot&&o.wipRoot.child&&(T(o.wipRoot.child),o.currentRoot=o.wipRoot),o.wipRoot=void 0},T=e=>{if(!e)return;let o=e.parent;for(;!o.dom;)o=o.parent;const t=o.dom;if(e.effectTag===s.PLACEMENT&&(null!=e.dom&&t.appendChild(e.dom),F(e)),e.effectTag===s.UPDATE&&(R(e),null!=e.dom&&x(e.dom,e.alternate.props,e.props),F(e)),e.effectTag===s.DELETION)return O(e,t),void R(e);T(e.child),T(e.sibling)},O=(e,o)=>{e.dom?o.removeChild(e.dom):O(e.child,o)};var I=Object.freeze({__proto__:null,commitDeletion:O,commitRoot:g,commitWork:T});const L=(e,t)=>{let n=0,r=e.alternate&&e.alternate.child,i=null;const a=new Map;for(;r;){const e=r.props.key||r.type;a.set(e,r),r=r.sibling}for(;n<t.length;){const r=t[n],l=r.props.key||r.type,c=a.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:s.UPDATE},a.delete(l)):r&&(p={type:r.type,props:r.props,dom:void 0,parent:e,alternate:void 0,effectTag:s.PLACEMENT}),a.forEach((e=>{e.effectTag=s.DELETION,o.deletions.push(e)})),0===n?e.child=p:i&&(i.sibling=p),i=p,n++}};var U=Object.freeze({__proto__:null,reconcileChildren:L});const C=e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);let n=[];n=Array.isArray(t)?[...t]:[t],L(e,n)},j=e=>{e.dom||(e.dom=v(e)),L(e,e.props.children)};var M=Object.freeze({__proto__:null,updateFunctionComponent:C,updateHostComponent:j});const S=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=D(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&g(),requestIdleCallback(S)};requestIdleCallback(S);const D=e=>{if(e.type instanceof Function?C(e):j(e),e.child)return e.child;let o=e;for(;o;){if(o.sibling)return o.sibling;o=o.parent}};var X={createElement:p,render:d,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t),d(e,o.containerRoot)},Fragment:l,Dom:_,Workers:Object.freeze({__proto__:null,performUnitOfWork:D,workLoop:S}),Reconciler:U,Components:M,Commits:I};window.Ryunix=X,e.Fragment=l,e.default=X,e.useCallback=(e,o)=>m((()=>e),o),e.useEffect=h,e.useMemo=m,e.useQuery=y,e.useRef=e=>{const t=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],r={type:n.RYUNIX_REF,value:t?t.value:{current:e}};return o.wipFiber.hooks&&(o.wipFiber.hooks.push(r),o.hookIndex++),r.value},e.useRouter=e=>{const[o,t]=f(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},i=(e,o)=>{e.forEach((e=>{e.path!==o&&((async e=>{e&&typeof e.preload===r.function&&await e.preload()})(e.component),e.subRoutes&&i(e.subRoutes,o))}))},s=e=>{window.history.pushState({},"",e),a(e)},a=e=>{const o=e.split("?")[0];t(o)};h((()=>{const t=()=>a(window.location.pathname);return window.addEventListener("popstate",t),i(e,o),()=>window.removeEventListener("popstate",t)}),[o,e]);const l=n(e,o)||{};return{Children:()=>{const e=y(),{route:o}=l;return o&&o.component&&typeof o.component===r.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})=>p("a",{href:e,onClick:o=>{o.preventDefault(),s(e)},...o},o.children),navigate:s}},e.useStore=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|