@unsetsoft/ryunixjs 1.1.5-nightly.39 → 1.1.5-nightly.40

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.
Files changed (2) hide show
  1. package/dist/Ryunix.js +1 -1
  2. package/package.json +1 -1
package/dist/Ryunix.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};const 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")}),s=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"}),l=Object.freeze({PLACEMENT:Symbol(),UPDATE:Symbol(),DELETION:Symbol()}),a=e=>e.map((e=>JSON.stringify(e))).join("-"),c=e=>e.children,p=(e,t)=>(t=t||[],null==e||typeof e==s.boolean||(Array.isArray(e)?e.some((e=>{p(e,t)})):t.push(e)),t),u=(e,t,...o)=>{o=p(o,[]);const n=t&&t.key?t.key:`${r.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...t,key:n,children:o.map((e=>typeof e===s.object?e:d(e)))}}},d=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),f=(e,t)=>{o.wipRoot={dom:o.containerRoot||t,props:{children:[e]},alternate:o.currentRoot},o.deletions=[],o.nextUnitOfWork=o.wipRoot},h=e=>e.startsWith("on"),m=e=>e!==s.children&&!h(e),y=(e,t)=>o=>e[o]!==t[o],b=e=>t=>!(t in e),E=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},w=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},k=e=>{const t=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return R(t,{},e.props),t},R=(e,t,o)=>{Object.keys(t).filter(h).filter((e=>b(o)(e)||y(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(m).filter(b(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(m).filter(y(t,o)).forEach((n=>{if(n===s.style)F(e,o["ryunix-style"]);else if(n===i.style)F(e,o.style);else if(n===s.className){if(""===o["ryunix-class"])throw new Error("data-class cannot be empty.");t["ryunix-class"]&&e.classList.remove(...t["ryunix-class"].split(/\s+/)),e.classList.add(...o["ryunix-class"].split(/\s+/))}else if(n===i.className){if(""===o.className)throw new Error("className cannot be empty.");t.className&&e.classList.remove(...t.className.split(/\s+/)),e.classList.add(...o.className.split(/\s+/))}else e[n]=o[n]})),Object.keys(o).filter(h).filter(y(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},F=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")};var g=Object.freeze({__proto__:null,DomStyle:F,createDom:k,updateDom:R});const x=()=>{o.deletions.forEach(N),o.wipRoot&&o.wipRoot.child&&(N(o.wipRoot.child),o.currentRoot=o.wipRoot),o.wipRoot=void 0},N=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),w(e);else if(e.effectTag===l.UPDATE)console.log(`Actualizando DOM para el componente con key: ${e.props.key}`),e.alternate&&e.alternate.props!==e.props&&(E(e),null!=e.dom&&R(e.dom,e.alternate.props,e.props),w(e));else if(e.effectTag===l.DELETION)return _(e,o),void E(e);e.child&&N(e.child),e.sibling&&N(e.sibling)},_=(e,t)=>{e.dom?t.removeChild(e.dom):_(e.child,t)};var v=Object.freeze({__proto__:null,commitDeletion:_,commitRoot:x,commitWork:N});const T=(e,t)=>{let n=0,r=e.alternate&&e.alternate.child,s=null;const i=new Map;for(;r;){const e=r.props.key||r.type;i.set(e,r),r=r.sibling}for(;n<t.length;){const o=t[n],a=o.props.key||o.type;let c;r=i.get(a);r&&o&&o.type===r.type?(c={type:r.type,props:o.props,dom:r.dom,parent:e,alternate:r,effectTag:l.UPDATE},i.delete(a)):o&&(c={type:o.type,props:o.props,dom:void 0,parent:e,alternate:void 0,effectTag:l.PLACEMENT}),0===n?e.child=c:s&&(s.sibling=c),s=c,n++}i.forEach((e=>{e.effectTag=l.DELETION,o.deletions.push(e)}))};var O=Object.freeze({__proto__:null,reconcileChildren:T});const I=e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);T(e,Array.isArray(t)?t:[t])},L=e=>{e.dom||(e.dom=k(e)),T(e,e.props.children)};var C=Object.freeze({__proto__:null,updateFunctionComponent:I,updateHostComponent:L});const U=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=j(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&x(),requestIdleCallback(U)};requestIdleCallback(U);const j=e=>{if(e.type instanceof Function?I(e):L(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}return null};const S=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]:[]};(t?t.queue:[]).forEach((e=>{n.state=typeof e===s.function?e(n.state):e,console.log("Estado después de aplicar acción:",n.state)})),o.wipFiber&&o.wipFiber.hooks&&(console.log("Registrando hook: ",n),o.wipFiber.hooks.push(n),o.hookIndex++);return[n.state,e=>{console.log("setState disparado para el estado: ",e),n.queue.push(e),o.wipRoot={dom:o.currentRoot.dom,props:o.currentRoot.props,alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[],console.log("setState: disparando para el estado en hook:",n.state)}]},M=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],l={type:r.RYUNIX_EFFECT,deps:n,cleanup:null};i&&t.isEqual(i.deps,l.deps)||(typeof i?.cleanup===s.function&&i.cleanup(),l.cleanup=e()),o.wipFiber.hooks&&(o.wipFiber.hooks.push(l),o.hookIndex++)},D=(e,t)=>{const n=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_MEMO,value:null,deps:t,hash:a(t)};return n&&n.hash===s.hash?s.value=n.value:s.value=e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.hookIndex++),s.value},A=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t};var X={createElement:u,render:f,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t),f(e,o.containerRoot)},Fragment:c,Dom:g,Workers:Object.freeze({__proto__:null,performUnitOfWork:j,workLoop:U}),Reconciler:O,Components:C,Commits:v};window.Ryunix=X,e.Fragment=c,e.createContext=e=>{let t={value:e,listeners:new Set};return{Provider:({value:e,children:o})=>(t.value=e,t.listeners.forEach((t=>t(e))),o),useContext:()=>{const[e,o]=S(t.value);return M((()=>{const e=e=>o(e);return t.listeners.add(e),()=>t.listeners.delete(e)}),[]),e}}},e.default=X,e.useCallback=(e,t)=>D((()=>e),t),e.useEffect=M,e.useMemo=D,e.useQuery=A,e.useRef=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.wipFiber.hooks.push(n),o.hookIndex++),n.value},e.useRouter=e=>{const[t,o]=S(window.location.pathname),n=(e,t)=>{const o=t.split("?")[0],r=e.find((e=>e.NotFound)),s=r?{route:{component:r.NotFound},params:{}}:{route:{component:null},params:{}};for(const r of e){if(r.subRoutes){const e=n(r.subRoutes,t);if(e)return e}if("*"===r.path)return s;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=[],i=new RegExp(`^${r.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),l=o.match(i);if(l){return{route:r,params:e.reduce(((e,t,o)=>(e[t]=l[o+1],e)),{})}}}return s},r=e=>{window.history.pushState({},"",e),i(e)},i=e=>{const t=e.split("?")[0];o(t)};M((()=>{const e=()=>i(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const l=n(e,t)||{};return{Children:()=>{const e=A(),{route:t}=l;return t&&t.component&&typeof t.component===s.function?t.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,...t})=>u("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},...t},t.children),navigate:r}},e.useStore=S,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};const 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"),RYUNIX_STORE:Symbol("ryunix.store")}),s=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"}),l=Object.freeze({PLACEMENT:Symbol(),UPDATE:Symbol(),DELETION:Symbol()}),a=e=>e.map((e=>JSON.stringify(e))).join("-"),c=e=>e.children,p=(e,t)=>(t=t||[],null==e||typeof e==s.boolean||(Array.isArray(e)?e.some((e=>{p(e,t)})):t.push(e)),t),u=(e,t,...o)=>{o=p(o,[]);const n=t&&t.key?t.key:`${r.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...t,key:n,children:o.map((e=>typeof e===s.object?e:d(e)))}}},d=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),f=(e,t)=>{o.wipRoot={dom:o.containerRoot||t,props:{children:[e]},alternate:o.currentRoot},o.deletions=[],o.nextUnitOfWork=o.wipRoot},h=e=>{const t=(n=o.wipFiber,i=r.RYUNIX_STORE,`${n.key}-${i}`);var n,i;const l=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[t],a={state:l?l.state:e,queue:l?l.queue:[]};a.queue.forEach((e=>{a.state=typeof e===s.function?e(a.state):e}));return o.wipFiber&&o.wipFiber.hooks&&(o.wipFiber.hooks[t]=a),[a.state,e=>{a.queue.push(e),o.wipRoot={dom:o.currentRoot.dom,props:o.currentRoot.props,alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[]}]},m=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],l={type:r.RYUNIX_EFFECT,deps:n,cleanup:null};i&&t.isEqual(i.deps,l.deps)||(typeof i?.cleanup===s.function&&i.cleanup(),l.cleanup=e()),o.wipFiber.hooks&&(o.wipFiber.hooks.push(l),o.hookIndex++)},y=(e,t)=>{const n=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_MEMO,value:null,deps:t,hash:a(t)};return n&&n.hash===s.hash?s.value=n.value:s.value=e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.hookIndex++),s.value},b=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},E=e=>e.startsWith("on"),w=e=>e!==s.children&&!E(e),k=(e,t)=>o=>e[o]!==t[o],R=e=>t=>!(t in e),F=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},x=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},N=e=>{const t=e.type==r.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return _(t,{},e.props),t},_=(e,t,o)=>{Object.keys(t).filter(E).filter((e=>R(o)(e)||k(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(w).filter(R(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(w).filter(k(t,o)).forEach((n=>{if(n===s.style)g(e,o["ryunix-style"]);else if(n===i.style)g(e,o.style);else if(n===s.className){if(""===o["ryunix-class"])throw new Error("data-class cannot be empty.");t["ryunix-class"]&&e.classList.remove(...t["ryunix-class"].split(/\s+/)),e.classList.add(...o["ryunix-class"].split(/\s+/))}else if(n===i.className){if(""===o.className)throw new Error("className cannot be empty.");t.className&&e.classList.remove(...t.className.split(/\s+/)),e.classList.add(...o.className.split(/\s+/))}else e[n]=o[n]})),Object.keys(o).filter(E).filter(k(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},g=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(n,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")};var v=Object.freeze({__proto__:null,DomStyle:g,createDom:N,updateDom:_});const T=()=>{o.deletions.forEach(O),o.wipRoot&&o.wipRoot.child&&(O(o.wipRoot.child),o.currentRoot=o.wipRoot),o.wipRoot=void 0},O=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),x(e);else if(e.effectTag===l.UPDATE)console.log(`Actualizando DOM para el componente con key: ${e.props.key}`),e.alternate&&e.alternate.props!==e.props&&(F(e),null!=e.dom&&_(e.dom,e.alternate.props,e.props),x(e));else if(e.effectTag===l.DELETION)return I(e,o),void F(e);e.child&&O(e.child),e.sibling&&O(e.sibling)},I=(e,t)=>{e.dom?t.removeChild(e.dom):I(e.child,t)};var L=Object.freeze({__proto__:null,commitDeletion:I,commitRoot:T,commitWork:O});const C=(e,t)=>{let n=0,r=e.alternate&&e.alternate.child,s=null;const i=new Map;for(;r;){const e=r.props.key||r.type;i.set(e,r),r=r.sibling}for(;n<t.length;){const o=t[n],a=o.props.key||o.type;let c;r=i.get(a);r&&o&&o.type===r.type?(c={type:r.type,props:o.props,dom:r.dom,parent:e,alternate:r,effectTag:l.UPDATE},i.delete(a)):o&&(c={type:o.type,props:o.props,dom:void 0,parent:e,alternate:void 0,effectTag:l.PLACEMENT}),0===n?e.child=c:s&&(s.sibling=c),s=c,n++}i.forEach((e=>{e.effectTag=l.DELETION,o.deletions.push(e)}))};var U=Object.freeze({__proto__:null,reconcileChildren:C});const j=e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);C(e,Array.isArray(t)?t:[t])},S=e=>{e.dom||(e.dom=N(e)),C(e,e.props.children)};var M=Object.freeze({__proto__:null,updateFunctionComponent:j,updateHostComponent:S});const X=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=D(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&T(),requestIdleCallback(X)};requestIdleCallback(X);const D=e=>{if(e.type instanceof Function?j(e):S(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}return null};var A={createElement:u,render:f,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t),f(e,o.containerRoot)},Fragment:c,Dom:v,Workers:Object.freeze({__proto__:null,performUnitOfWork:D,workLoop:X}),Reconciler:U,Components:M,Commits:L};window.Ryunix=A,e.Fragment=c,e.createContext=e=>{let t={value:e,listeners:new Set};return{Provider:({value:e,children:o})=>(t.value=e,t.listeners.forEach((t=>t(e))),o),useContext:()=>{const[e,o]=h(t.value);return m((()=>{const e=e=>o(e);return t.listeners.add(e),()=>t.listeners.delete(e)}),[]),e}}},e.default=A,e.useCallback=(e,t)=>y((()=>e),t),e.useEffect=m,e.useMemo=y,e.useQuery=b,e.useRef=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.wipFiber.hooks.push(n),o.hookIndex++),n.value},e.useRouter=e=>{const[t,o]=h(window.location.pathname),n=(e,t)=>{const o=t.split("?")[0],r=e.find((e=>e.NotFound)),s=r?{route:{component:r.NotFound},params:{}}:{route:{component:null},params:{}};for(const r of e){if(r.subRoutes){const e=n(r.subRoutes,t);if(e)return e}if("*"===r.path)return s;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=[],i=new RegExp(`^${r.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),l=o.match(i);if(l){return{route:r,params:e.reduce(((e,t,o)=>(e[t]=l[o+1],e)),{})}}}return s},r=e=>{window.history.pushState({},"",e),i(e)},i=e=>{const t=e.split("?")[0];o(t)};m((()=>{const e=()=>i(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const l=n(e,t)||{};return{Children:()=>{const e=b(),{route:t}=l;return t&&t.component&&typeof t.component===s.function?t.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,...t})=>u("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},...t},t.children),navigate:r}},e.useStore=h,Object.defineProperty(e,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@unsetsoft/ryunixjs",
3
- "version": "1.1.5-nightly.39",
3
+ "version": "1.1.5-nightly.40",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.js",
6
6
  "types": "./dist/Ryunix.d.ts",