@unsetsoft/ryunixjs 1.1.6-canary.13 → 1.1.6-canary.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 +5 -3
- package/dist/Ryunix.min.js +1 -1
- package/package.json +1 -1
package/dist/Ryunix.js
CHANGED
|
@@ -185,12 +185,14 @@
|
|
|
185
185
|
|
|
186
186
|
hook.queue = [];
|
|
187
187
|
|
|
188
|
-
vars.
|
|
188
|
+
vars.wipRoot = {
|
|
189
189
|
dom: vars.wipFiber.dom,
|
|
190
|
-
props:
|
|
190
|
+
props: {
|
|
191
|
+
...vars.wipFiber.props,
|
|
192
|
+
},
|
|
191
193
|
alternate: vars.wipFiber,
|
|
192
194
|
};
|
|
193
|
-
vars.nextUnitOfWork = vars.
|
|
195
|
+
vars.nextUnitOfWork = vars.wipRoot;
|
|
194
196
|
vars.deletions = [];
|
|
195
197
|
};
|
|
196
198
|
|
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:{},nextUnitOfWork:{},currentRoot:{},wipRoot:{},deletions:[],wipFiber:{},hookIndex:0};const r=/[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"),RYUNIX_STORE:Symbol("ryunix.store"),RYUNIX_REDUCE:Symbol("ryunix.reduce")}),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("ryunix.reconciler.status.placement").toString(),UPDATE:Symbol("ryunix.reconciler.status.update").toString(),DELETION:Symbol("ryunix.reconciler.status.deletion").toString()}),l=e=>`${e}-${Math.random().toString(36).substring(2,9)}`,p=(e,t)=>(t=t||[],null==e||typeof e==i.boolean||(Array.isArray(e)?e.some((e=>{p(e,t)})):t.push(e)),t),c=(e,t,...o)=>{o=p(o,[]);const r=t&&t.key?l(t.key):l(n.Ryunix_ELEMENT.toString());return{type:e,props:{...t,key:r,children:o.map((e=>typeof e===i.object?e:u(e)))}}},u=e=>({type:n.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,t)=>{o.wipRoot={dom: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.wipFiber.hookIndex],r={state:t?t.state:e,queue:t?[...t.queue]:[]};return o.wipFiber&&o.wipFiber.hooks&&(o.wipFiber.hooks.push(r),o.wipFiber.hookIndex++),[r.state,e=>{r.queue.push(e),r.queue.forEach((e=>{r.state=typeof e===i.function?e(r.state):e})),r.queue=[],o.
|
|
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:{},nextUnitOfWork:{},currentRoot:{},wipRoot:{},deletions:[],wipFiber:{},hookIndex:0};const r=/[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"),RYUNIX_STORE:Symbol("ryunix.store"),RYUNIX_REDUCE:Symbol("ryunix.reduce")}),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("ryunix.reconciler.status.placement").toString(),UPDATE:Symbol("ryunix.reconciler.status.update").toString(),DELETION:Symbol("ryunix.reconciler.status.deletion").toString()}),l=e=>`${e}-${Math.random().toString(36).substring(2,9)}`,p=(e,t)=>(t=t||[],null==e||typeof e==i.boolean||(Array.isArray(e)?e.some((e=>{p(e,t)})):t.push(e)),t),c=(e,t,...o)=>{o=p(o,[]);const r=t&&t.key?l(t.key):l(n.Ryunix_ELEMENT.toString());return{type:e,props:{...t,key:r,children:o.map((e=>typeof e===i.object?e:u(e)))}}},u=e=>({type:n.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,t)=>{o.wipRoot={dom: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.wipFiber.hookIndex],r={state:t?t.state:e,queue:t?[...t.queue]:[]};return o.wipFiber&&o.wipFiber.hooks&&(o.wipFiber.hooks.push(r),o.wipFiber.hookIndex++),[r.state,e=>{r.queue.push(e),r.queue.forEach((e=>{r.state=typeof e===i.function?e(r.state):e})),r.queue=[],o.wipRoot={dom:o.wipFiber.dom,props:{...o.wipFiber.props},alternate:o.wipFiber},o.nextUnitOfWork=o.wipRoot,o.deletions=[]}]},h=(e,r)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.wipFiber.hookIndex],s={type:n.RYUNIX_EFFECT,deps:r};i&&t.isEqual(i.deps,s.deps)||e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.wipFiber.hookIndex++)},m=(e,r)=>{const i=o.wipFiber.alternate&&o.wipFiber.alternate.hooks&&o.wipFiber.alternate.hooks[o.wipFiber.hookIndex],s={type:n.RYUNIX_MEMO,value:null,deps:r};return i&&t.isEqual(i.deps,s.deps)?s.value=i.value:s.value=e(),o.wipFiber.hooks&&(o.wipFiber.hooks.push(s),o.wipFiber.hookIndex++),s.value},y=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,r]of e.entries())t[o]=r;return t},b=e=>e.startsWith("on"),w=e=>e!==i.children&&!b(e),E=(e,t)=>o=>e[o]!==t[o],k=e=>t=>!(t in e),F=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},x=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},R=e=>{const t=e.type==n.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return _(t,{},e.props),t},_=(e,t,o)=>{Object.keys(t).filter(b).filter((e=>k(o)(e)||E(t,o)(e))).forEach((o=>{const r=o.toLowerCase().substring(2);e.removeEventListener(r,t[o])})),Object.keys(t).filter(w).filter(k(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(w).filter(E(t,o)).forEach((r=>{if(r===i.style)N(e,o["ryunix-style"]);else if(r===s.style)N(e,o.style);else if(r===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(r===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[r]=o[r]})),Object.keys(o).filter(b).filter(E(t,o)).forEach((t=>{const r=t.toLowerCase().substring(2);e.addEventListener(r,o[t])}))},N=(e,t)=>{e.style=Object.keys(t).reduce(((e,o)=>e+=`${o.replace(r,(function(e){return"-"+e.toLowerCase()}))}: ${t[o]};`),"")};var g=Object.freeze({__proto__:null,DomStyle:N,createDom:R,updateDom:_});const T=()=>{o.deletions.forEach(v),o.wipRoot&&o.wipRoot.child&&(v(o.wipRoot.child),o.currentRoot=o.wipRoot),o.wipRoot=void 0},v=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.effectTag===a.PLACEMENT&&null!=e.dom)o.appendChild(e.dom),x(e);else if(e.effectTag===a.UPDATE&&null!=e.dom)F(e),_(e.dom,e.alternate.props,e.props),x(e);else if(e.effectTag===a.DELETION)return I(e,o),void F(e);v(e.child),v(e.sibling)},I=(e,t)=>{e.dom?t.removeChild(e.dom):I(e.child,t)};var O=Object.freeze({__proto__:null,commitDeletion:I,commitRoot:T,commitWork:v});const L=(e,t)=>{let r=0,n=e.alternate&&e.alternate.child,i=null;const s=new Map;for(;n;){const e=n.props.key||n.type;s.set(e,n),n=n.sibling}for(;r<t.length;){const o=t[r],n=o.props.key||o.type,l=s.get(n);let p;l&&o&&o.type===l.type?(p={type:l.type,props:o.props,dom:l.dom,parent:e,alternate:l,effectTag:a.UPDATE},s.delete(n)):o&&(p={type:o.type,props:o.props,dom:void 0,parent:e,alternate:void 0,effectTag:a.PLACEMENT}),0===r?e.child=p:i&&(i.sibling=p),i=p,r++}s.forEach((e=>{e.effectTag=a.DELETION,o.deletions.push(e)}))};var U=Object.freeze({__proto__:null,reconcileChildren:L});const C=e=>{o.wipFiber=e,o.hookIndex=0,o.wipFiber.hookIndex=0,o.wipFiber.hooks=[];const t=e.type(e.props);let r=Array.isArray(t)?t:[t];L(e,r)},S=e=>{e.dom||(e.dom=R(e)),L(e,e.props.children)};var j=Object.freeze({__proto__:null,updateFunctionComponent:C,updateHostComponent:S});const M=e=>{let t=!1;for(;o.nextUnitOfWork&&!t;)o.nextUnitOfWork=X(o.nextUnitOfWork),t=e.timeRemaining()<1;!o.nextUnitOfWork&&o.wipRoot&&T(),requestIdleCallback(M)};requestIdleCallback(M);const X=e=>{if(e.type instanceof Function?C(e):S(e),o.wipFiber.hookIndex=0,e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}};var D={createElement:c,render:d,init:(e,t="__ryunix")=>{o.containerRoot=document.getElementById(t),d(e,o.containerRoot)},Fragment:e=>e.children,Dom:g,Workers:Object.freeze({__proto__:null,performUnitOfWork:X,workLoop:M}),Reconciler:U,Components:j,Commits:O};window.Ryunix=D,e.default=D,e.useCallback=(e,t)=>m((()=>e),t),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.wipFiber.hookIndex],r={type:n.RYUNIX_REF,value:t?t.value:{current:e}};return o.wipFiber.hooks&&(o.wipFiber.hooks.push(r),o.wipFiber.hookIndex++),r.value},e.useRouter=e=>{const[t,o]=f(window.location.pathname),r=(e,t)=>{const o=t.split("?")[0],n=e.find((e=>e.NotFound)),i=n?{route:{component:n.NotFound},params:{}}:{route:{component:null},params:{}};for(const n of e){if(n.subRoutes){const e=r(n.subRoutes,t);if(e)return e}if("*"===n.path)return i;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=[],s=new RegExp(`^${n.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),a=o.match(s);if(a){return{route:n,params:e.reduce(((e,t,o)=>(e[t]=a[o+1],e)),{})}}}return i},n=e=>{window.history.pushState({},"",e),s(e)},s=e=>{const t=e.split("?")[0];o(t)};h((()=>{const e=()=>s(window.location.pathname);return window.addEventListener("popstate",e),()=>window.removeEventListener("popstate",e)}),[]);const a=r(e,t)||{};return{Children:()=>{const e=y(),{route:t}=a;return t&&t.component&&typeof t.component===i.function?t.component({params:a.params||{},query:e}):(console.error("Component not found for current path or the component is not a valid function:",a),null)},NavLink:({to:e,...t})=>c("a",{href:e,onClick:t=>{t.preventDefault(),n(e)},...t},t.children),navigate:n}},e.useStore=f,Object.defineProperty(e,"__esModule",{value:!0})}));
|