@unsetsoft/ryunixjs 1.1.7-canary.26 → 1.1.7-canary.28

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 CHANGED
@@ -339,58 +339,43 @@
339
339
  )
340
340
  };
341
341
 
342
+ const recycleFiber = (oldFiber, newProps) => {
343
+ return {
344
+ ...oldFiber,
345
+ props: newProps,
346
+ alternate: oldFiber,
347
+ effectTag: EFFECT_TAGS.UPDATE,
348
+ }
349
+ };
350
+
342
351
  const reconcileChildren = (wipFiber, elements) => {
343
352
  let index = 0;
344
353
  let oldFiber = wipFiber.alternate && wipFiber.alternate.child;
345
354
  let prevSibling = null;
346
355
 
347
356
  const oldFibersMap = new Map();
348
- let oldIndex = 0;
349
357
  while (oldFiber) {
350
- const key = oldFiber.props?.key ?? oldFiber.type + '-' + oldIndex;
351
- oldFibersMap.set(key, oldFiber);
358
+ const oldKey = oldFiber.props.key || oldFiber.type;
359
+ oldFibersMap.set(oldKey, oldFiber);
352
360
  oldFiber = oldFiber.sibling;
353
- oldIndex++;
354
361
  }
355
362
 
356
363
  while (index < elements.length) {
357
364
  const element = elements[index];
358
-
359
- if (!element.props?.key && element.type !== RYUNIX_TYPES.RYUNIX_FRAGMENT) {
360
- console.warn(
361
- `Warning: Element of type ${element.type} at index ${index} is missing a key.`,
362
- );
363
- }
364
-
365
- const key =
366
- element.type === RYUNIX_TYPES.RYUNIX_FRAGMENT
367
- ? null
368
- : element.props?.key ?? element.type + '-' + index;
369
-
370
- const matchedOldFiber = key !== null ? oldFibersMap.get(key) : null;
365
+ const key = element.props.key || element.type;
366
+ const oldFiber = oldFibersMap.get(key);
371
367
 
372
368
  let newFiber;
369
+ const sameType = oldFiber && element && element.type === oldFiber.type;
373
370
 
374
- const sameType =
375
- matchedOldFiber && element && element.type === matchedOldFiber.type;
376
-
377
- if (sameType) {
378
- const shouldUpdate = shouldComponentUpdate(
379
- matchedOldFiber.props,
380
- element.props,
381
- );
382
-
383
- newFiber = {
384
- type: matchedOldFiber.type,
385
- props: element.props,
386
- dom: matchedOldFiber.dom,
387
- parent: wipFiber,
388
- alternate: matchedOldFiber,
389
- effectTag: shouldUpdate ? EFFECT_TAGS.UPDATE : EFFECT_TAGS.NO_EFFECT,
390
- };
371
+ if (sameType && !shouldComponentUpdate(oldFiber.props, element.props)) {
372
+ // Reutilizar fibra existente si no hay cambios
373
+ newFiber = recycleFiber(oldFiber, element.props);
374
+ oldFibersMap.delete(key);
375
+ }
391
376
 
392
- if (key !== null) oldFibersMap.delete(key);
393
- } else if (element) {
377
+ if (element && !sameType) {
378
+ // Crear nueva fibra
394
379
  newFiber = {
395
380
  type: element.type,
396
381
  props: element.props,
@@ -399,30 +384,28 @@
399
384
  alternate: null,
400
385
  effectTag: EFFECT_TAGS.PLACEMENT,
401
386
  };
402
-
403
- if (matchedOldFiber) {
404
- matchedOldFiber.effectTag = EFFECT_TAGS.DELETION;
405
- vars.deletions.push(matchedOldFiber);
406
- if (key !== null) oldFibersMap.delete(key);
407
- }
408
387
  }
409
388
 
410
- if (newFiber) {
411
- if (index === 0) {
412
- wipFiber.child = newFiber;
413
- } else if (prevSibling) {
414
- prevSibling.sibling = newFiber;
415
- }
389
+ if (oldFiber && !sameType) {
390
+ oldFiber.effectTag = EFFECT_TAGS.DELETION;
391
+ wipFiber.effects = wipFiber.effects || [];
392
+ wipFiber.effects.push(oldFiber);
393
+ }
416
394
 
417
- prevSibling = newFiber;
395
+ if (index === 0) {
396
+ wipFiber.child = newFiber;
397
+ } else if (prevSibling) {
398
+ prevSibling.sibling = newFiber;
418
399
  }
419
400
 
401
+ prevSibling = newFiber;
402
+
420
403
  index++;
421
404
  }
422
405
 
423
- oldFibersMap.forEach((remainingFiber) => {
424
- remainingFiber.effectTag = EFFECT_TAGS.DELETION;
425
- vars.deletions.push(remainingFiber);
406
+ oldFibersMap.forEach((oldFiber) => {
407
+ oldFiber.effectTag = EFFECT_TAGS.DELETION;
408
+ vars.deletions.push(oldFiber);
426
409
  });
427
410
  };
428
411
 
@@ -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()}),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)=>{const n=t?.key??t?.id??null;return{type:e,props:{...t,key:n,children:o.flat().map((e=>typeof e===i.object?e:c(e)))}}},c=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),u=e=>e.startsWith("on"),p=e=>e!==i.children&&!u(e),f=(e,t)=>o=>e[o]!==t[o],d=e=>t=>!(t in e),h=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},y=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},m=(e,t,o)=>{Object.keys(t).filter(u).filter((e=>d(o)(e)||f(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(p).filter(d(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(p).filter(f(t,o)).forEach((n=>{if(n===i.style)E(e,o["ryunix-style"]);else if(n===s.style)E(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+/)),e.classList.add(...o["ryunix-class"].split(/\s+/))}else if(n===s.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(u).filter(f(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]};`),"")},w=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.type===r.RYUNIX_FRAGMENT)return w(e.child),void w(e.sibling);if(e.effectTag===l.PLACEMENT&&null!=e.dom)o.appendChild(e.dom),y(e);else if(e.effectTag===l.UPDATE&&null!=e.dom)h(e),m(e.dom,e.alternate.props,e.props),y(e);else if(e.effectTag===l.DELETION)return b(e,o),void h(e);w(e.child),w(e.sibling)},b=(e,t)=>{e.dom?t.removeChild(e.dom):b(e.child,t)},R=(e,t)=>!e||!t||Object.keys(e).length!==Object.keys(t).length||Object.keys(t).some((o=>e[o]!==t[o])),g=(e,t)=>{let n=0,i=e.alternate&&e.alternate.child,s=null;const a=new Map;let c=0;for(;i;){const e=i.props?.key??i.type+"-"+c;a.set(e,i),i=i.sibling,c++}for(;n<t.length;){const i=t[n];i.props?.key||i.type===r.RYUNIX_FRAGMENT||console.warn(`Warning: Element of type ${i.type} at index ${n} is missing a key.`);const c=i.type===r.RYUNIX_FRAGMENT?null:i.props?.key??i.type+"-"+n,u=null!==c?a.get(c):null;let p;if(u&&i&&i.type===u.type){const t=R(u.props,i.props);p={type:u.type,props:i.props,dom:u.dom,parent:e,alternate:u,effectTag:t?l.UPDATE:l.NO_EFFECT},null!==c&&a.delete(c)}else i&&(p={type:i.type,props:i.props,dom:(i.type,r.RYUNIX_FRAGMENT,null),parent:e,alternate:null,effectTag:l.PLACEMENT},u&&(u.effectTag=l.DELETION,o.deletions.push(u),null!==c&&a.delete(c)));p&&(0===n?e.child=p:s&&(s.sibling=p),s=p),n++}a.forEach((e=>{e.effectTag=l.DELETION,o.deletions.push(e)}))},k=e=>{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 m(t,{},e.props),t})(e)),g(e,e.props.children)},x=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=N(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&(o.deletions.forEach(w),o.wipRoot&&o.wipRoot.child&&(w(o.wipRoot.child),o.currentRoot=o.wipRoot),o.effects.forEach((e=>{try{e()}catch(e){console.error("Error in effect:",e)}})),o.effects=[],o.wipRoot=null),requestIdleCallback(x)},N=e=>{if(e.type instanceof Function?(e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);let n=Array.isArray(t)?t:[t];g(e,n)})(e):k(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}},F=(e,t)=>{var n;return o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[],n=o.wipRoot,o.nextUnitOfWork=n,o.wipRoot=n,o.deletions=[],o.hookIndex=0,o.effects=[],requestIdleCallback(x),o.wipRoot},T=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:[]).forEach((e=>{n.state=typeof e===i.function?e(n.state):e}));return 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=[]}]},I=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_EFFECT,deps:n,cleanup:i?.cleanup};(!i||!t.isEqual(i.deps,n))&&o.effects.push((()=>{"function"==typeof s.cleanup&&s.cleanup();const t=e();"function"==typeof t&&(s.cleanup=t)})),o.wipFiber.hooks[o.hookIndex]=s,o.hookIndex++},S=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},U=(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},_=(e,t)=>U((()=>e),t),O=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},v=e=>{const[t,o]=T(window.location.pathname),n=(e,t)=>{const o=t.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,t);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,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),l=o.match(s);if(l){return{route:r,params:e.reduce(((e,t,o)=>(e[t]=l[o+1],e)),{})}}}return i},r=e=>{window.history.pushState({},"",e),s(e)},s=e=>{const t=e.split("?")[0];o(t)};I((()=>{const e=()=>s(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const l=n(e,t)||{};return{Children:()=>{const e=O(),{route:t}=l;return t&&t.component&&typeof t.component===i.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})=>a("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},...t},t.children),navigate:r}};var L={createElement:a,render:F,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t);return F(e,o.containerRoot)},Fragment:e=>e.children,Hooks:Object.freeze({__proto__:null,useCallback:_,useEffect:I,useMemo:U,useQuery:O,useRef:S,useRouter:v,useStore:T})};window.Ryunix=L,e.Image=({src:e,...t})=>{const o="true"===t.optimization?(({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("width",t.height),t.quality&&o.set("quality",t.quality);const r=t.extension?`@${t.extension}`:"",i="http://localhost:3000"===window.location.origin||"http://localhost:5173"===window.location.origin||"http://localhost:4173"===window.location.origin;return n?i?(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()}`})({src:e,props:t}):e;return a("img",{src:o,props:t},null)},e.default=L,e.useCallback=_,e.useEffect=I,e.useMemo=U,e.useQuery=O,e.useRef=S,e.useRouter=v,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()}),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)=>{const n=t?.key??t?.id??null;return{type:e,props:{...t,key:n,children:o.flat().map((e=>typeof e===i.object?e:c(e)))}}},c=e=>({type:r.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),u=e=>e.startsWith("on"),p=e=>e!==i.children&&!u(e),f=(e,t)=>o=>e[o]!==t[o],d=e=>t=>!(t in e),h=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},y=e=>{e.hooks&&e.hooks.filter((e=>e.tag===r.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},m=(e,t,o)=>{Object.keys(t).filter(u).filter((e=>d(o)(e)||f(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(p).filter(d(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(p).filter(f(t,o)).forEach((n=>{if(n===i.style)E(e,o["ryunix-style"]);else if(n===s.style)E(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+/)),e.classList.add(...o["ryunix-class"].split(/\s+/))}else if(n===s.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(u).filter(f(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]};`),"")},w=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.type===r.RYUNIX_FRAGMENT)return w(e.child),void w(e.sibling);if(e.effectTag===l.PLACEMENT&&null!=e.dom)o.appendChild(e.dom),y(e);else if(e.effectTag===l.UPDATE&&null!=e.dom)h(e),m(e.dom,e.alternate.props,e.props),y(e);else if(e.effectTag===l.DELETION)return b(e,o),void h(e);w(e.child),w(e.sibling)},b=(e,t)=>{e.dom?t.removeChild(e.dom):b(e.child,t)},g=(e,t)=>!e||!t||Object.keys(e).length!==Object.keys(t).length||Object.keys(t).some((o=>e[o]!==t[o])),R=(e,t)=>({...e,props:t,alternate:e,effectTag:l.UPDATE}),k=(e,t)=>{let n=0,i=e.alternate&&e.alternate.child,s=null;const a=new Map;for(;i;){const e=i.props.key||i.type;a.set(e,i),i=i.sibling}for(;n<t.length;){const o=t[n],i=o.props.key||o.type,c=a.get(i);let u;const p=c&&o&&o.type===c.type;p&&!g(c.props,o.props)&&(u=R(c,o.props),a.delete(i)),o&&!p&&(u={type:o.type,props:o.props,dom:(o.type,r.RYUNIX_FRAGMENT,null),parent:e,alternate:null,effectTag:l.PLACEMENT}),c&&!p&&(c.effectTag=l.DELETION,e.effects=e.effects||[],e.effects.push(c)),0===n?e.child=u:s&&(s.sibling=u),s=u,n++}a.forEach((e=>{e.effectTag=l.DELETION,o.deletions.push(e)}))},x=e=>{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 m(t,{},e.props),t})(e)),k(e,e.props.children)},N=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=F(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&(o.deletions.forEach(w),o.wipRoot&&o.wipRoot.child&&(w(o.wipRoot.child),o.currentRoot=o.wipRoot),o.effects.forEach((e=>{try{e()}catch(e){console.error("Error in effect:",e)}})),o.effects=[],o.wipRoot=null),requestIdleCallback(N)},F=e=>{if(e.type instanceof Function?(e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);let n=Array.isArray(t)?t:[t];k(e,n)})(e):x(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}},T=(e,t)=>{var n;return o.wipRoot={dom:t,props:{children:[e]},alternate:o.currentRoot},o.nextUnitOfWork=o.wipRoot,o.deletions=[],n=o.wipRoot,o.nextUnitOfWork=n,o.wipRoot=n,o.deletions=[],o.hookIndex=0,o.effects=[],requestIdleCallback(N),o.wipRoot},I=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:[]).forEach((e=>{n.state=typeof e===i.function?e(n.state):e}));return 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=[]}]},S=(e,n)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.hookIndex],s={type:r.RYUNIX_EFFECT,deps:n,cleanup:i?.cleanup};(!i||!t.isEqual(i.deps,n))&&o.effects.push((()=>{"function"==typeof s.cleanup&&s.cleanup();const t=e();"function"==typeof t&&(s.cleanup=t)})),o.wipFiber.hooks[o.hookIndex]=s,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},O=(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},_=(e,t)=>O((()=>e),t),v=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},L=e=>{const[t,o]=I(window.location.pathname),n=(e,t)=>{const o=t.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,t);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,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),l=o.match(s);if(l){return{route:r,params:e.reduce(((e,t,o)=>(e[t]=l[o+1],e)),{})}}}return i},r=e=>{window.history.pushState({},"",e),s(e)},s=e=>{const t=e.split("?")[0];o(t)};S((()=>{const e=()=>s(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const l=n(e,t)||{};return{Children:()=>{const e=v(),{route:t}=l;return t&&t.component&&typeof t.component===i.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})=>a("a",{href:e,onClick:t=>{t.preventDefault(),r(e)},...t},t.children),navigate:r}};var C={createElement:a,render:T,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t);return T(e,o.containerRoot)},Fragment:e=>e.children,Hooks:Object.freeze({__proto__:null,useCallback:_,useEffect:S,useMemo:O,useQuery:v,useRef:U,useRouter:L,useStore:I})};window.Ryunix=C,e.Image=({src:e,...t})=>{const o="true"===t.optimization?(({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("width",t.height),t.quality&&o.set("quality",t.quality);const r=t.extension?`@${t.extension}`:"",i="http://localhost:3000"===window.location.origin||"http://localhost:5173"===window.location.origin||"http://localhost:4173"===window.location.origin;return n?i?(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()}`})({src:e,props:t}):e;return a("img",{src:o,props:t},null)},e.default=C,e.useCallback=_,e.useEffect=S,e.useMemo=O,e.useQuery=v,e.useRef=U,e.useRouter=L,e.useStore=I,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.7-canary.26",
3
+ "version": "1.1.7-canary.28",
4
4
  "license": "MIT",
5
5
  "main": "./dist/Ryunix.min.js",
6
6
  "types": "./dist/Ryunix.d.ts",