@unsetsoft/ryunixjs 1.1.5-nightly.2 → 1.1.5-nightly.4
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 +3 -3
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={}
|
|
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={})}(this,(function(e){"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},o=/[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"}),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,p=(e,t)=>(t=t||[],null==e||typeof e==r.boolean||(Array.isArray(e)?e.some((e=>{p(e,t)})):t.push(e)),t),c=(e,t,...o)=>{o=p(o,[]);const i=t&&t.key?t.key:`${n.Ryunix_ELEMENT.toString()}-${Math.random().toString(36).substring(2,9)}`;return{type:e,props:{...t,key:i,children:o.map((e=>typeof e===r.object?e:u(e)))}}},u=e=>({type:n.TEXT_ELEMENT,props:{nodeValue:e,children:[]}}),d=(e,o)=>{t.wipRoot={dom:t.containerRoot||o,props:{children:[e]},alternate:t.currentRoot},t.deletions=[],t.nextUnitOfWork=t.wipRoot},f=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===r.function?e(n.state):e})),n.queue=[],t.pendingUpdates=[];return t.wipFiber&&t.wipFiber.hooks&&(t.wipFiber.hooks.push(n),t.hookIndex++),[n.state,e=>{n.queue.push(e),t.pendingUpdates.push((()=>{t.wipRoot={dom:t.currentRoot.dom,props:t.currentRoot.props,alternate:t.currentRoot},t.nextUnitOfWork=t.wipRoot,t.deletions=[]})),1===t.pendingUpdates.length&&requestIdleCallback((()=>{t.pendingUpdates.forEach((e=>e())),t.pendingUpdates.length=0}))}]},h=(e,o)=>{const i=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],s={type:n.RYUNIX_EFFECT,deps:o,hash:a(o),cleanup:i?i.cleanup:void 0};if(!i||i.hash!==s.hash){s.cleanup&&s.cleanup();const t=e();typeof t===r.function&&(s.cleanup=t)}t.wipFiber.hooks&&(t.wipFiber.hooks.push(s),t.hookIndex++)},m=(e,o)=>{const r=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],i={type:n.RYUNIX_MEMO,value:null,deps:o,hash:a(o)};return r&&r.hash===i.hash?i.value=r.value:i.value=e(),t.wipFiber.hooks&&(t.wipFiber.hooks.push(i),t.hookIndex++),i.value},y=()=>{const e=new URLSearchParams(window.location.search),t={};for(let[o,n]of e.entries())t[o]=n;return t},b=e=>e.startsWith("on"),E=e=>e!==r.children&&!b(e),w=(e,t)=>o=>e[o]!==t[o],k=e=>t=>!(t in e),R=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.cancel)).forEach((e=>{e.cancel()}))},g=e=>{e.hooks&&e.hooks.filter((e=>e.tag===n.RYUNIX_EFFECT&&e.effect)).forEach((e=>{e.cancel=e.effect()}))},x=e=>{const t=e.type==n.TEXT_ELEMENT?document.createTextNode(""):document.createElement(e.type);return v(t,{},e.props),t},v=(e,t,o)=>{Object.keys(t).filter(b).filter((e=>k(o)(e)||w(t,o)(e))).forEach((o=>{const n=o.toLowerCase().substring(2);e.removeEventListener(n,t[o])})),Object.keys(t).filter(E).filter(k(o)).forEach((t=>{e[t]=""})),Object.keys(o).filter(E).filter(w(t,o)).forEach((n=>{if(n===r.style)_(e,o["ryunix-style"]);else if(n===i.style)_(e,o.style);else if(n===r.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(b).filter(w(t,o)).forEach((t=>{const n=t.toLowerCase().substring(2);e.addEventListener(n,o[t])}))},_=(e,t)=>{e.style=Object.keys(t).reduce(((e,n)=>e+=`${n.replace(o,(function(e){return"-"+e.toLowerCase()}))}: ${t[n]};`),"")};var F=Object.freeze({__proto__:null,DomStyle:_,createDom:x,updateDom:v});const N=()=>{t.deletions.forEach(T),t.wipRoot&&t.wipRoot.child&&(T(t.wipRoot.child),t.currentRoot=t.wipRoot),t.wipRoot=void 0},T=e=>{if(!e)return;let t=e.parent;for(;!t.dom;)t=t.parent;const o=t.dom;if(e.effectTag===s.PLACEMENT&&(null!=e.dom&&o.appendChild(e.dom),g(e)),e.effectTag===s.UPDATE&&(R(e),null!=e.dom&&v(e.dom,e.alternate.props,e.props),g(e)),e.effectTag===s.DELETION)return O(e,o),void R(e);T(e.child),T(e.sibling)},O=(e,t)=>{e.dom?t.removeChild(e.dom):O(e.child,t)};var U=Object.freeze({__proto__:null,commitDeletion:O,commitRoot:N,commitWork:T});const I=(e,o)=>{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<o.length;){const r=o[n],l=r.props.key||r.type,p=a.get(l);let c;p&&r&&r.type===p.type?(c={type:p.type,props:r.props,dom:p.dom,parent:e,alternate:p,effectTag:s.UPDATE},a.delete(l)):r&&(c={type:r.type,props:r.props,dom:void 0,parent:e,alternate:void 0,effectTag:s.PLACEMENT}),a.forEach((e=>{e.effectTag=s.DELETION,t.deletions.push(e)})),0===n?e.child=c:i&&(i.sibling=c),i=c,n++}};var L=Object.freeze({__proto__:null,reconcileChildren:I});const C=e=>{t.wipFiber=e,t.hookIndex=0,t.wipFiber.hooks=[];const o=e.type(e.props);let n=[];n=Array.isArray(o)?[...o]:[o],I(e,n)},j=e=>{e.dom||(e.dom=x(e)),I(e,e.props.children)};var M=Object.freeze({__proto__:null,updateFunctionComponent:C,updateHostComponent:j});const S=e=>{let o=!1;for(;t.nextUnitOfWork&&!o;)t.nextUnitOfWork=D(t.nextUnitOfWork),o=e.timeRemaining()<1;!t.nextUnitOfWork&&t.wipRoot&&N(),requestIdleCallback(S)};requestIdleCallback(S);const D=e=>{if(e.type instanceof Function?C(e):j(e),e.child)return e.child;let t=e;for(;t;){if(t.sibling)return t.sibling;t=t.parent}};var X={createElement:c,render:d,init:(e,o="__ryunix")=>{t.containerRoot=document.getElementById(o),d(e,t.containerRoot)},Fragment:l,Dom:F,Workers:Object.freeze({__proto__:null,performUnitOfWork:D,workLoop:S}),Reconciler:L,Components:M,Commits:U};window.Ryunix=X,e.Fragment=l,e.default=X,e.useCallback=(e,t)=>m((()=>e),t),e.useEffect=h,e.useMemo=m,e.useQuery=y,e.useRef=e=>{const o=t.wipFiber.alternate&&t.wipFiber.alternate.hooks&&t.wipFiber.alternate.hooks[t.hookIndex],r={type:n.RYUNIX_REF,value:o?o.value:{current:e}};return t.wipFiber.hooks&&(t.wipFiber.hooks.push(r),t.hookIndex++),r.value},e.useRouter=e=>{const[t,o]=f(window.location.pathname),n=(e,t)=>{for(const o of e){if(o.subRoutes){const e=n(o.subRoutes,t);if(e)return e}const e=[],r=new RegExp(`^${o.path.replace(/:\w+/g,(t=>(e.push(t.substring(1)),"([^/]+)")))}$`),i=t.match(r);if(i){return{route:o,params:e.reduce(((e,t,o)=>(e[t]=i[o+1],e)),{})}}}return null},i=(e,t)=>{e.forEach((e=>{e.path!==t&&((async e=>{e&&typeof e.preload===r.function&&await e.preload()})(e.component),e.subRoutes&&i(e.subRoutes,t))}))},s=e=>{window.history.pushState({},"",e),a(e)},a=e=>{o(e.split("?")[0])};h((()=>{const o=()=>a(window.location.pathname);return window.addEventListener("popstate",o),i(e,t),()=>window.removeEventListener("popstate",o)}),[t]);const l=n(e,t);return{Children:()=>{const e=y();return l?.route?.component?l.route.component({params:l.params,query:e}):null},NavLink:({to:e,...t})=>c("a",{href:e,onClick:t=>{t.preventDefault(),s(e)},...t},t.children),navigate:s}},e.useStore=f,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.
|
|
3
|
+
"version": "1.1.5-nightly.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"main": "./dist/Ryunix.js",
|
|
6
6
|
"types": "./dist/Ryunix.d.ts",
|
|
@@ -17,9 +17,9 @@
|
|
|
17
17
|
"lint": "eslint . --ext .ts --fix --max-warnings=0 --config .eslintrc.js --no-eslintrc"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@rollup/plugin-terser": "
|
|
20
|
+
"@rollup/plugin-terser": "0.4.4",
|
|
21
21
|
"eslint": "8.56.0",
|
|
22
|
-
"lodash": "
|
|
22
|
+
"lodash": "4.17.20",
|
|
23
23
|
"rollup": "4.9.2"
|
|
24
24
|
},
|
|
25
25
|
"engines": {
|