atomic-router
Advanced tools
Comparing version 0.9.2 to 0.9.3-rc.0
@@ -38,3 +38,3 @@ import * as effector from 'effector'; | ||
query: RouteQuery; | ||
method: 'replace' | 'push'; | ||
method: "replace" | "push"; | ||
}; | ||
@@ -41,0 +41,0 @@ declare type HistoryBackForwardParams = History; |
@@ -1,2 +0,2 @@ | ||
((e,r)=>{'object'==typeof exports&&'undefined'!=typeof module?r(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],r):r((e='undefined'!=typeof globalThis?globalThis:e||self).atomicRouter={},e.effector)})(this,((e,effector)=>{function r(e){void 0===e&&(e={});var r=effector.createEffect((e=>{var r=e.replace;return{params:e.params||{},query:e.query||{},replace:void 0!==r&&r}}),{name:"navigateFx",sid:"c2qlao"}),a=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"am04as"}}),t=effector.createStore(!1,{name:"$isOpened",sid:"-8u29di"}),n=effector.createStore({},{name:"$params",sid:"6sxdf"}),o=effector.createStore({},{name:"$query",sid:"tylje5"}),i=effector.createEvent({name:"opened",sid:"fafqk0"}),c=effector.createEvent({name:"updated",sid:"66vs1s"}),s=effector.createEvent({name:"closed",sid:"-wbq1n3"});return t.on(i,(()=>!0)).on(s,(()=>!1)),n.on(i,((e,r)=>r.params)).on(c,((e,r)=>r.params)),o.on(i,((e,r)=>r.query)).on(c,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:t.map((e=>e?'updated':'opened')),cases:{opened:i,updated:c}}],or:{sid:"3j56hf"}}),{$isOpened:t,$params:n,$query:o,opened:i,updated:c,closed:s,navigate:r,open:a,kind:g.ROUTE,settings:{derived:Boolean(e.filter)}}}function a(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),a.push.apply(a,t)}return a}function t(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((r=>{n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function n(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,t=new Array(r);a<r;a++)t[a]=e[a];return t}function i(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return o(e,r);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var a=0;return()=>a>=e.length?{done:!0}:{done:!1,value:e[a++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var a in e)if(""+e[a]!=""+r[a])return!1;return!0}function s(e,r){void 0===r&&(r={});for(var a=(e=>{for(var r=[],a=0;a<e.length;){var t=e[a];if("*"!==t&&"+"!==t&&"?"!==t)if("\\"!==t)if("{"!==t)if("}"!==t)if(":"!==t)if("("!==t)r.push({type:"CHAR",index:a,value:e[a++]});else{var n=1,o="";if("?"===e[c=a+1])throw new TypeError("Pattern cannot start with \"?\" at ".concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--n){c++;break}}else if("("===e[c]&&(n++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(n)throw new TypeError("Unbalanced pattern at ".concat(a));if(!o)throw new TypeError("Missing pattern at ".concat(a));r.push({type:"PATTERN",index:a,value:o}),a=c}else{for(var i="",c=a+1;c<e.length;){var s=e.charCodeAt(c);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;i+=e[c++]}if(!i)throw new TypeError("Missing parameter name at ".concat(a));r.push({type:"NAME",index:a,value:i}),a=c}else r.push({type:"CLOSE",index:a,value:e[a++]});else r.push({type:"OPEN",index:a,value:e[a++]});else r.push({type:"ESCAPED_CHAR",index:a++,value:e[a++]});else r.push({type:"MODIFIER",index:a,value:e[a++]})}return r.push({type:"END",index:a,value:""}),r})(e),t=r.prefixes,n=void 0===t?"./":t,o="[^".concat(u(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,d="",l=e=>{if(s<a.length&&a[s].type===e)return a[s++].value},p=e=>{var r=l(e);if(void 0!==r)return r;var t=a[s],n=t.index;throw new TypeError("Unexpected ".concat(t.type," at ").concat(n,", expected ").concat(e))},f=()=>{for(var e,r="";e=l("CHAR")||l("ESCAPED_CHAR");)r+=e;return r};s<a.length;){var m=l("CHAR"),v=l("NAME"),h=l("PATTERN");if(v||h)-1===n.indexOf(g=m||"")&&(d+=g,g=""),d&&(i.push(d),d=""),i.push({name:v||c++,prefix:g,suffix:"",pattern:h||o,modifier:l("MODIFIER")||""});else{var y=m||l("ESCAPED_CHAR");if(y)d+=y;else if(d&&(i.push(d),d=""),l("OPEN")){var g=f(),b=l("NAME")||"",O=l("PATTERN")||"",w=f();p("CLOSE"),i.push({name:b||(O?c++:""),pattern:b&&!O?o:O,prefix:g,suffix:w,modifier:l("MODIFIER")||""})}else p("END")}}return i}function d(e,r){var a=[];return((e,r,a)=>{void 0===a&&(a={});var t=a.decode,n=void 0===t?e=>e:t;return a=>{var t=e.exec(a);if(!t)return!1;for(var o=t[0],i=t.index,c=Object.create(null),s=e=>{if(void 0===t[e])return"continue";var a=r[e-1];c[a.name]="*"===a.modifier||"+"===a.modifier?t[e].split(a.prefix+a.suffix).map((e=>n(e,a))):n(t[e],a)},d=1;d<t.length;d++)s(d);return{path:o,index:i,params:c}}})(p(e,a,r),a,r)}function u(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function p(e,r,a){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var a=/\((?:\?<(.*?)>)?(?!\?)/g,t=0,n=a.exec(e.source);n;)r.push({name:n[1]||t++,prefix:"",suffix:"",modifier:"",pattern:""}),n=a.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,a)=>{var t=e.map((e=>p(e,r,a).source));return new RegExp("(?:".concat(t.join("|"),")"),l(a))})(e,r,a):((e,r,a)=>((e,r,a)=>{void 0===a&&(a={});for(var t=a.strict,n=void 0!==t&&t,o=a.start,i=void 0===o||o,c=a.end,s=void 0===c||c,d=a.encode,p=void 0===d?e=>e:d,f=a.delimiter,m=void 0===f?"/#?":f,v=a.endsWith,h="[".concat(u(void 0===v?"":v),"]|$"),y="[".concat(u(m),"]"),g=i?"^":"",b=0,O=e;b<O.length;b++){var w=O[b];if("string"==typeof w)g+=u(p(w));else{var E=u(p(w.prefix)),k=u(p(w.suffix));if(w.pattern)if(r&&r.push(w),E||k)if("+"===w.modifier||"*"===w.modifier){var q="*"===w.modifier?"?":"";g+="(?:".concat(E,"((?:").concat(w.pattern,")(?:").concat(k).concat(E,"(?:").concat(w.pattern,"))*)").concat(k,")").concat(q)}else g+="(?:".concat(E,"(").concat(w.pattern,")").concat(k,")").concat(w.modifier);else g+="+"===w.modifier||"*"===w.modifier?"((?:".concat(w.pattern,")").concat(w.modifier,")"):"(".concat(w.pattern,")").concat(w.modifier);else g+="(?:".concat(E).concat(k,")").concat(w.modifier)}}if(s)n||(g+="".concat(y,"?")),g+=a.endsWith?"(?=".concat(h,")"):"$";else{var x=e[e.length-1],j="string"==typeof x?y.indexOf(x[x.length-1])>-1:void 0===x;n||(g+="(?:".concat(y,"(?=").concat(h,"))?")),j||(g+="(?=".concat(y,"|").concat(h,")"))}return new RegExp(g,l(a))})(s(e,a),r,a))(e,r,a)}function f(e){var r,a=e.params,t=e.query,n=e.serialize,o=((e,r)=>((e,r)=>{void 0===r&&(r={});var a=l(r),t=r.encode,n=void 0===t?e=>e:t,o=r.validate,i=void 0===o||o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),a)}));return r=>{for(var a="",t=0;t<e.length;t++){var o=e[t];if("string"!=typeof o){var s=r?r[o.name]:void 0,d="?"===o.modifier||"*"===o.modifier,u="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!u)throw new TypeError("Expected \"".concat(o.name,"\" to not repeat, but got an array"));if(0===s.length){if(d)continue;throw new TypeError("Expected \"".concat(o.name,"\" to not be empty"))}for(var l=0;l<s.length;l++){var p=n(s[l],o);if(i&&!c[t].test(p))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));a+=o.prefix+p+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!d){var f=u?"an array":"a string";throw new TypeError("Expected \"".concat(o.name,"\" to be ").concat(f))}}else{if(p=n(String(s),o),i&&!c[t].test(p))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));a+=o.prefix+p+o.suffix}}else a+=o}return a}})(s(e,r),r))(e.pathCreator)(a),i=null!==(r=null==n?void 0:n.write(t))&&void 0!==r?r:new URLSearchParams(t);return o+(Object.keys(t).length?"?"+i:'')}function m(e){var r=e.actualPath,a=d((e=>e.replace('://','\\://'))(e.pathCreator))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return a?{matches:!0,params:a.params}:{matches:!1}}function v(e){if(!e)throw new Error('[Routing] No history provided')}function h(e){return e.map((e=>!e))}function y(e){return effector.is.store(e,{sid:"b0xjrg"})?e:effector.createStore(e,{sid:"-dcoehd"})}var g={ROUTE:Symbol()},b=()=>({$query:effector.createStore({},{and:{updateFilter:(e,r)=>!c(r,e)},name:"$query",sid:"z22f3o"}),back:effector.createEvent({name:"back",sid:"lqciue"}),forward:effector.createEvent({name:"forward",sid:"-5dfdts"})}),O=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===g.ROUTE,w=effector.createEffect((e=>(v(e.history),e.history[e.method](e.path,{}),e)),{name:"historyPushFx",sid:"-w0no5y"}),E=effector.createEffect((e=>(v(e),e.back(),e)),{name:"historyBackFx",sid:"-ny8vwp"}),k=effector.createEffect((e=>(v(e),e.forward(),e)),{name:"historyForwardFx",sid:"88oqi4"}),q=e=>r=>{var a=r.find((r=>r.routeObj.route===e.route));if(a)return{params:a.params,query:a.query}},x={all:{irrelevant:!0,empty:!0,preserve:[]},default:{irrelevant:!1,empty:!0,preserve:[]},none:{irrelevant:!1,empty:!1,preserve:[]}};e.Kind=g,e.buildPath=f,e.chainRoute=e=>{var a=(e=>{var a={};if(effector.withFactory({sid:"-wbqecl",fn:()=>O(e),name:"none",method:"isRoute"}))return Object.assign(a,{route:e,chainedRoute:effector.withFactory({sid:"n96673",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"-c64nu3"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"x2vaqr"}),cancelOn:effector.merge([],{name:"cancelOn",sid:"chy3tc"})}),a;var t=e;if(Object.assign(a,{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-x3jjwl",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.is.unit(t.beforeOpen)?t.beforeOpen:effector.attach({and:t.beforeOpen,or:{name:"beforeOpen",sid:"50j77g"}})}),effector.is.effect(a.beforeOpen,{sid:"-veqqqx"}))return Object.assign(a,{openOn:t.openOn||a.beforeOpen.doneData,cancelOn:t.cancelOn||a.beforeOpen.failData}),a;var n=e;return Object.assign(a,{openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-nr0wzo"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"-js52ao"})}],or:{name:"cancelOn",sid:"yc5yq1"}})}),a})(e),t=a.route,n=a.chainedRoute,o=a.beforeOpen,i=a.openOn,c=a.cancelOn,s=effector.createStore({},{name:"$params",sid:"-5lmaub"}),d=effector.createStore({},{name:"$query",sid:"o66b6f"}),u=effector.combine({and:[effector.combine({and:[[t.$params,t.$query]],or:{name:"and",sid:"30xupk"}}),effector.combine({and:[[s,d]],or:{name:"and",sid:"31hnax"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"kxmugn"}}),l=effector.sample({and:[{clock:[t.opened,t.updated]}],or:{name:"routeOpened",sid:"-wxg30y"}});effector.sample({and:[{clock:l,target:o}],or:{sid:"-oj6bg0"}}),s.on(l,((e,r)=>r.params)),d.on(l,((e,r)=>r.query));var p=effector.sample({and:[{clock:i,source:{params:s,query:d},filter:u}],or:{name:"chainedRouteResolved",sid:"w16a67"}});effector.sample({and:[{clock:p,target:n.navigate}],or:{sid:"-o113v3"}});var f=effector.merge([t.closed,c],{name:"aborted",sid:"eq3v50"});return s.reset(f),d.reset(f),effector.sample({and:[{clock:f,target:n.closed}],or:{sid:"-nkja29"}}),n},e.createHistoryRouter=e=>{var r=e.base,a=e.routes,n=e.notFoundRoute,o=e.hydrate,s=e.serialize,d=e.controls,u=void 0===d?effector.withFactory({sid:"d2qzob",fn:()=>b(),name:"controls",method:"createRouterControls"}):d,l=((e,r)=>{void 0===r&&(r='');for(var a,n=[],o=()=>{var e,r=a.value;Array.isArray(r.route)?(e=n).push.apply(e,r.route.map((e=>t(t({},r),{},{route:e})))):n.push(r)},c=i(e);!(a=c()).done;)o();n=n.map((e=>t(t({},e),{},{path:""+r+e.path})));for(var s,d=[],u=[],l=i(n);!(s=l()).done;){var p=s.value;p.route.settings.derived?d.push(p):u.push(p)}if(d.length)for(var f,m=i(d);!(f=m()).done;)console.error("createHistoryRouter: "+f.value.path+" uses derived route. This won't work");return u})(a,r),p=effector.createEvent({name:"setHistory",sid:"9zwyxu"}),v=effector.createEvent({name:"navigateFromRouteTriggered",sid:"soge6d"}),y=effector.createEvent({name:"historyUpdated",sid:"-x4474u"}),g=effector.createEvent({name:"recalculateTriggered",sid:"-ykrhlj"}),x=effector.createEvent({name:"recalculated",sid:"aeh4sf"}),j=effector.createEvent({name:"routesMatched",sid:"2rfqt6"}),R=effector.createEvent({name:"routesMismatched",sid:"71hypl"}),$=effector.createEvent({name:"routeNotFound",sid:"avqxzu"}),P=effector.createEvent({name:"initialized",sid:"du6f0f"}),S=effector.createStore('',{name:"$path",sid:"wz8cwv"}),A=effector.createStore({},{and:{name:'historyRouter.$query',updateFilter:(e,r)=>!c(e,r)},name:"$query",sid:"tkdilp"}),T=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"9ljm7u"}),F=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"g4i7nj"}),C=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"9r108x"}),z=effector.createStore(!1,{name:"$isRouteNavigateInProgress",sid:"a1vtrl"}),D=effector.attach({and:{source:F,effect:(e,r)=>w(t({history:e},r))},or:{name:"pushFx",sid:"qm76ov"}}),N=effector.attach({and:{source:F,effect:e=>{var r=y;try{r=effector.scopeBind(y)}catch(e){}return e.listen((()=>{r()})),!0}},or:{name:"subscribeHistoryFx",sid:"-b12mlt"}}),U=effector.sample({and:[{clock:o?[y]:[y,N.done],source:F,filter:Boolean,fn:e=>{var r;return{path:e.location.pathname,query:null!==(r=null==s?void 0:s.read(e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(e.location.search))}}}],or:{name:"historyUpdatedParsed",sid:"-rhkauu"}}),H=effector.sample({and:[{clock:U,source:{path:S,query:A},filter:(e,r)=>r.path!==e.path||!c(r.query,e.query),fn:(e,r)=>r}],or:{name:"historyUpdateTriggered",sid:"-pbyg2j"}});F.on(p,((e,r)=>r)),effector.sample({and:[{clock:F,target:N}],or:{sid:"-pwl7u3"}}),effector.sample({and:[{clock:H,source:F,filter:Boolean,fn:e=>{var r,a=null==e?void 0:e.location.hash;return{path:null==e?void 0:e.location.pathname,query:null!==(r=null==s?void 0:s.read(null==e?void 0:e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(null==e?void 0:e.location.search)),hash:a}},target:g}],or:{sid:"-ptu8va"}});for(var M,I=i(l);!(M=I()).done;){var L=M.value,Q=j.filterMap(q(L)),B=R.filterMap(q(L)),_={opened:effector.sample({and:[{clock:Q,filter:h(L.route.$isOpened)}],or:{name:"opened",sid:"-vfmdab"}}),updated:effector.sample({and:[{clock:Q,filter:L.route.$isOpened}],or:{name:"updated",sid:"-2uhvx2"}}),closed:effector.sample({and:[{clock:B,filter:L.route.$isOpened}],or:{name:"closed",sid:"jc9588"}})};effector.sample({and:[{clock:_.updated,source:[L.route.$params,L.route.$query],filter:(e,r)=>{var a=e[1];return!c(e[0],r.params)||!c(a,r.query)},fn:(e,r)=>r,target:L.route.updated}],or:{sid:"-ny7ju5"}}),effector.sample({and:[{clock:_.opened,filter:h(z),target:L.route.opened}],or:{sid:"-ngm4ul"}}),effector.sample({and:[{clock:_.closed,target:L.route.closed}],or:{sid:"-d2q1d1"}})}for(var W,K=()=>{var e=W.value;effector.sample({and:[{clock:e.route.navigate.doneData,fn:r=>{var a=r.replace;return{route:e,params:r.params,query:r.query,replace:null!=a&&a}},target:v}],or:{sid:"-cm87k7"}})},G=i(l);!(W=G()).done;)K();z.on(v,(()=>!0)),effector.sample({and:[{clock:v,fn:e=>{var r=e.params,a=e.query,t=e.replace;return{path:f({pathCreator:e.route.path,params:r,query:a,serialize:s}),params:r,query:a,method:t?'replace':'push'}},target:D}],or:{sid:"-c2zeua"}}),z.reset([j,R]),effector.sample({and:[{clock:g,fn:e=>{for(var r,a=e.path,t=e.query,n=e.hash,o=[],c=[],s=i(l);!(r=s()).done;){var d=r.value,u=d.path.includes('#')?""+a+n:""+a,p=m({pathCreator:d.path,actualPath:u});(p.matches?o:c).push({routeObj:d,params:p.params,query:t})}return c.forEach(((e,r)=>{o.some((r=>r.routeObj.route===e.routeObj.route))&&c.splice(r,1)})),{matching:o,mismatching:c.filter(Boolean),path:a,query:t}},target:x}],or:{sid:"-ar5b7v"}}),S.on(H,((e,r)=>r.path)),A.on(H,((e,r)=>r.query));var J=x.map((e=>e.matching));return effector.sample({and:[{clock:J,filter:e=>e.length>0,target:j}],or:{sid:"1l4g7x"}}),effector.sample({and:[{clock:x.map((e=>e.mismatching)),filter:e=>e.length>0,target:R}],or:{sid:"1zyw8o"}}),T.on(x,((e,r)=>r.matching.map((e=>e.routeObj.route)))),effector.sample({and:[{clock:J,filter:e=>0===e.length,target:$}],or:{sid:"2hkb88"}}),effector.withFactory({sid:"2kv2vu",fn:()=>O(n),name:"none",method:"isRoute"})&&(effector.sample({and:[{clock:$,source:A,filter:n.$isOpened,fn:e=>({query:e,params:{}}),target:n.updated}],or:{sid:"2levfh"}}),effector.sample({and:[{clock:$,source:{query:A,isOpened:n.$isOpened},filter:e=>!e.isOpened,fn:e=>({query:e.query,params:{}}),target:n.opened}],or:{sid:"31cwmy"}}),effector.sample({and:[{clock:J,source:n.$isOpened,filter:(e,r)=>e&&r.length>0,target:n.closed}],or:{sid:"3haxuf"}})),effector.sample({and:[{clock:u.back,source:F,target:E}],or:{sid:"3xsrlj"}}),effector.sample({and:[{clock:u.forward,source:F,target:k}],or:{sid:"413j5p"}}),effector.sample({and:[{clock:A,source:{controlsQuery:u.$query,localQuery:A},filter:e=>!c(e.controlsQuery,e.localQuery),fn:e=>e.localQuery,target:u.$query}],or:{sid:"4ghrrt"}}),effector.sample({and:[{clock:u.$query,source:{path:S,localQuery:A,isNavigateInProgress:z,realHistory:F},filter:(e,r)=>{var a,t,n,o=e.localQuery,i=e.isNavigateInProgress,d=e.realHistory,u=null!==(a=null==s?void 0:s.read(null!==(t=null==d?void 0:d.location.search)&&void 0!==t?t:''))&&void 0!==a?a:Object.fromEntries(new URLSearchParams(null!==(n=null==d?void 0:d.location.search)&&void 0!==n?n:''));return i||!c(r,u)||!c(o,r)},fn:(e,r)=>{var a,t=e.path,n=null!==(a=null==s?void 0:s.write(r))&&void 0!==a?a:new URLSearchParams(r);return{path:t+(n?"?"+n:''),params:{},query:r,method:'push'}},target:D}],or:{sid:"4wzlkn"}}),effector.sample({and:[{clock:x,source:{activeRoutes:T,path:S,query:A},filter:C.map((e=>!e)),target:P}],or:{sid:"gbpwte"}}),C.on(P,(()=>!0)).reset(F),{$path:S,$activeRoutes:T,$history:F,setHistory:p,$query:A,back:u.back,forward:u.forward,push:D,routes:l,initialized:P,routeNotFound:$}},e.createRoute=r,e.createRouterControls=b,e.isRoute=O,e.matchPath=m,e.querySync=e=>{var r,a,n,o=null!==(r=null===(a=e.route)||void 0===a?void 0:a.$isOpened)&&void 0!==r?r:effector.createStore(!0,{name:"$isOpened",sid:"-ubx3p"}),c=effector.combine({and:[e.source],or:{name:"$source",sid:"-3rrhte"}}),s=null!==(n=e.clock)&&void 0!==n?n:c,d='cleanup'in e?'boolean'==typeof e.cleanup?x[e.cleanup?'all':'none']:t(t({},x.default),e.cleanup):x.default,u=effector.sample({and:[{clock:e.controls.$query,filter:o}],or:{name:"queryUpdatedFromHistory",sid:"8lf3wv"}});effector.sample({and:[{clock:s,source:effector.combine({and:[[c,e.controls.$query]],or:{name:"source",sid:"-3pgs50"}}),filter:o,fn:e=>{var r=e[0],a=e[1],n={};if(d.irrelevant)for(var o,c=i(d.preserve);!(o=c()).done;){var s=o.value;s in a&&(n[s]=a[s])}else n=t({},a);for(var u in r)n[u]=r[u];if(d.empty)for(var l in r)d.preserve.includes(l)||n[l]||delete n[l];return n},target:e.controls.$query}],or:{sid:"fuzb5g"}});var l=r=>{var a=e.source[r];a.on(u,((e,t)=>{var n;return null!==(n=t[r])&&void 0!==n?n:a.defaultState}))};for(var p in e.source)l(p)},e.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ek44ri"}}):effector.createEvent({name:"clock",sid:"-ejkc65"}),a=y(e.params||{}),t=y(e.query||{}),n=y(e.replace||!1);return effector.sample({and:[{clock:r,source:{params:a,query:t,replace:n},fn:(e,r)=>{var a=e.params,t=e.query,n=e.replace;return{params:'function'==typeof a?a(r):a,query:'function'==typeof t?t(r):t,replace:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"ahoqts"}}),r},Object.defineProperty(e,'__esModule',{value:!0})})); | ||
((e,r)=>{'object'==typeof exports&&'undefined'!=typeof module?r(exports,require('effector')):'function'==typeof define&&define.amd?define(['exports','effector'],r):r((e='undefined'!=typeof globalThis?globalThis:e||self).atomicRouter={},e.effector)})(this,((e,effector)=>{function r(e){void 0===e&&(e={});var r=effector.createEffect((e=>{var r=e.replace;return{params:e.params||{},query:e.query||{},replace:void 0!==r&&r}}),{name:"navigateFx",sid:"-16itqs"}),a=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"-34ax4v"}}),t=effector.createStore(!1,{name:"$isOpened",sid:"-mkdat5"}),n=effector.createStore({},{name:"$params",sid:"-dji428"}),o=effector.createStore({},{name:"$query",sid:"g8ahyi"}),i=effector.createEvent({name:"opened",sid:"1k4p4d"}),c=effector.createEvent({name:"updated",sid:"2eisw8"}),s=effector.createEvent({name:"closed",sid:"yx116h"});return t.on(i,(()=>!0)).on(s,(()=>!1)),n.on(i,((e,r)=>r.params)).on(c,((e,r)=>r.params)),o.on(i,((e,r)=>r.query)).on(c,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:t.map((e=>e?"updated":"opened")),cases:{opened:i,updated:c}}],or:{sid:"2pgafx"}}),{$isOpened:t,$params:n,$query:o,opened:i,updated:c,closed:s,navigate:r,open:a,kind:g.ROUTE,settings:{derived:Boolean(e.filter)}}}function a(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var t=Object.getOwnPropertySymbols(e);r&&(t=t.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),a.push.apply(a,t)}return a}function t(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{};r%2?a(Object(t),!0).forEach((r=>{n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):a(Object(t)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(t,r))}))}return e}function n(e,r,a){return r in e?Object.defineProperty(e,r,{value:a,enumerable:!0,configurable:!0,writable:!0}):e[r]=a,e}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,t=new Array(r);a<r;a++)t[a]=e[a];return t}function i(e,r){var it="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(it)return(it=it.call(e)).next.bind(it);if(Array.isArray(e)||(it=((e,r)=>{if(e){if("string"==typeof e)return o(e,r);var a={}.toString.call(e).slice(8,-1);return"Object"===a&&e.constructor&&(a=e.constructor.name),"Map"===a||"Set"===a?Array.from(e):"Arguments"===a||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(a)?o(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var a=0;return()=>a>=e.length?{done:!0}:{done:!1,value:e[a++]}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function c(e,r){if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var a in e)if(""+e[a]!=""+r[a])return!1;return!0}function s(e,r){void 0===r&&(r={});for(var a=(e=>{for(var r=[],a=0;a<e.length;){var t=e[a];if("*"!==t&&"+"!==t&&"?"!==t)if("\\"!==t)if("{"!==t)if("}"!==t)if(":"!==t)if("("!==t)r.push({type:"CHAR",index:a,value:e[a++]});else{var n=1,o="";if("?"===e[c=a+1])throw new TypeError("Pattern cannot start with \"?\" at ".concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--n){c++;break}}else if("("===e[c]&&(n++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(n)throw new TypeError("Unbalanced pattern at ".concat(a));if(!o)throw new TypeError("Missing pattern at ".concat(a));r.push({type:"PATTERN",index:a,value:o}),a=c}else{for(var i="",c=a+1;c<e.length;){var s=e.charCodeAt(c);if(!(s>=48&&s<=57||s>=65&&s<=90||s>=97&&s<=122||95===s))break;i+=e[c++]}if(!i)throw new TypeError("Missing parameter name at ".concat(a));r.push({type:"NAME",index:a,value:i}),a=c}else r.push({type:"CLOSE",index:a,value:e[a++]});else r.push({type:"OPEN",index:a,value:e[a++]});else r.push({type:"ESCAPED_CHAR",index:a++,value:e[a++]});else r.push({type:"MODIFIER",index:a,value:e[a++]})}return r.push({type:"END",index:a,value:""}),r})(e),t=r.prefixes,n=void 0===t?"./":t,o="[^".concat(u(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,d="",l=e=>{if(s<a.length&&a[s].type===e)return a[s++].value},p=e=>{var r=l(e);if(void 0!==r)return r;var t=a[s],n=t.index;throw new TypeError("Unexpected ".concat(t.type," at ").concat(n,", expected ").concat(e))},f=()=>{for(var e,r="";e=l("CHAR")||l("ESCAPED_CHAR");)r+=e;return r};s<a.length;){var m=l("CHAR"),v=l("NAME"),h=l("PATTERN");if(v||h)-1===n.indexOf(g=m||"")&&(d+=g,g=""),d&&(i.push(d),d=""),i.push({name:v||c++,prefix:g,suffix:"",pattern:h||o,modifier:l("MODIFIER")||""});else{var y=m||l("ESCAPED_CHAR");if(y)d+=y;else if(d&&(i.push(d),d=""),l("OPEN")){var g=f(),b=l("NAME")||"",O=l("PATTERN")||"",x=f();p("CLOSE"),i.push({name:b||(O?c++:""),pattern:b&&!O?o:O,prefix:g,suffix:x,modifier:l("MODIFIER")||""})}else p("END")}}return i}function d(e,r){var a=[];return((e,r,a)=>{void 0===a&&(a={});var t=a.decode,n=void 0===t?e=>e:t;return a=>{var t=e.exec(a);if(!t)return!1;for(var o=t[0],i=t.index,c=Object.create(null),s=e=>{if(void 0===t[e])return"continue";var a=r[e-1];c[a.name]="*"===a.modifier||"+"===a.modifier?t[e].split(a.prefix+a.suffix).map((e=>n(e,a))):n(t[e],a)},d=1;d<t.length;d++)s(d);return{path:o,index:i,params:c}}})(p(e,a,r),a,r)}function u(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function p(e,r,a){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var a=/\((?:\?<(.*?)>)?(?!\?)/g,t=0,n=a.exec(e.source);n;)r.push({name:n[1]||t++,prefix:"",suffix:"",modifier:"",pattern:""}),n=a.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,a)=>{var t=e.map((e=>p(e,r,a).source));return new RegExp("(?:".concat(t.join("|"),")"),l(a))})(e,r,a):((e,r,a)=>((e,r,a)=>{void 0===a&&(a={});for(var t=a.strict,n=void 0!==t&&t,o=a.start,i=void 0===o||o,c=a.end,s=void 0===c||c,d=a.encode,p=void 0===d?e=>e:d,f=a.delimiter,m=void 0===f?"/#?":f,v=a.endsWith,h="[".concat(u(void 0===v?"":v),"]|$"),y="[".concat(u(m),"]"),g=i?"^":"",b=0,O=e;b<O.length;b++){var x=O[b];if("string"==typeof x)g+=u(p(x));else{var E=u(p(x.prefix)),q=u(p(x.suffix));if(x.pattern)if(r&&r.push(x),E||q)if("+"===x.modifier||"*"===x.modifier){var w="*"===x.modifier?"?":"";g+="(?:".concat(E,"((?:").concat(x.pattern,")(?:").concat(q).concat(E,"(?:").concat(x.pattern,"))*)").concat(q,")").concat(w)}else g+="(?:".concat(E,"(").concat(x.pattern,")").concat(q,")").concat(x.modifier);else g+="+"===x.modifier||"*"===x.modifier?"((?:".concat(x.pattern,")").concat(x.modifier,")"):"(".concat(x.pattern,")").concat(x.modifier);else g+="(?:".concat(E).concat(q,")").concat(x.modifier)}}if(s)n||(g+="".concat(y,"?")),g+=a.endsWith?"(?=".concat(h,")"):"$";else{var k=e[e.length-1],R="string"==typeof k?y.indexOf(k[k.length-1])>-1:void 0===k;n||(g+="(?:".concat(y,"(?=").concat(h,"))?")),R||(g+="(?=".concat(y,"|").concat(h,")"))}return new RegExp(g,l(a))})(s(e,a),r,a))(e,r,a)}function f(e){var r,a=e.params,t=e.query,n=e.serialize,o=((e,r)=>((e,r)=>{void 0===r&&(r={});var a=l(r),t=r.encode,n=void 0===t?e=>e:t,o=r.validate,i=void 0===o||o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),a)}));return r=>{for(var a="",t=0;t<e.length;t++){var o=e[t];if("string"!=typeof o){var s=r?r[o.name]:void 0,d="?"===o.modifier||"*"===o.modifier,u="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!u)throw new TypeError("Expected \"".concat(o.name,"\" to not repeat, but got an array"));if(0===s.length){if(d)continue;throw new TypeError("Expected \"".concat(o.name,"\" to not be empty"))}for(var l=0;l<s.length;l++){var p=n(s[l],o);if(i&&!c[t].test(p))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));a+=o.prefix+p+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!d){var f=u?"an array":"a string";throw new TypeError("Expected \"".concat(o.name,"\" to be ").concat(f))}}else{if(p=n(String(s),o),i&&!c[t].test(p))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));a+=o.prefix+p+o.suffix}}else a+=o}return a}})(s(e,r),r))(e.pathCreator)(a),i=null!==(r=null==n?void 0:n.write(t))&&void 0!==r?r:new URLSearchParams(t);return o+(Object.keys(t).length?"?"+i:"")}function m(e){var r=e.actualPath,a=d((e=>e.replace("://","\\://"))(e.pathCreator))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join("")})(r));return a?{matches:!0,params:a.params}:{matches:!1}}function v(e){if(!e)throw new Error("[Routing] No history provided")}function h(e){return e.map((e=>!e))}function y(e){return effector.is.store(e,{sid:"ajvxd9"})?e:effector.createStore(e,{sid:"-s12ope"})}var g={ROUTE:Symbol()},b=()=>({$query:effector.createStore({},{and:{updateFilter:(e,r)=>!c(r,e)},name:"$query",sid:"z22f3o"}),back:effector.createEvent({name:"back",sid:"lqciue"}),forward:effector.createEvent({name:"forward",sid:"-5dfdts"})}),O=e=>"object"==typeof e&&null!==e&&"kind"in e&&e.kind===g.ROUTE,x=effector.createEffect((e=>(v(e.history),e.history[e.method](e.path,{}),e)),{name:"historyPushFx",sid:"-w0no5y"}),E=effector.createEffect((e=>(v(e),e.back(),e)),{name:"historyBackFx",sid:"-ny8vwp"}),q=effector.createEffect((e=>(v(e),e.forward(),e)),{name:"historyForwardFx",sid:"7alhpq"}),w=e=>r=>{var a=r.find((r=>r.routeObj.route===e.route));if(a)return{params:a.params,query:a.query}},k={all:{irrelevant:!0,empty:!0,preserve:[]},default:{irrelevant:!1,empty:!0,preserve:[]},none:{irrelevant:!1,empty:!1,preserve:[]}};e.Kind=g,e.buildPath=f,e.chainRoute=e=>{var a=(e=>{var a={};if(effector.withFactory({sid:"-wbqecl",fn:()=>O(e),name:"none",method:"isRoute"}))return Object.assign(a,{route:e,chainedRoute:effector.withFactory({sid:"n96673",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"-c64nu3"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"x2vaqr"}),cancelOn:effector.merge([],{name:"cancelOn",sid:"chy3tc"})}),a;var t=e;if(Object.assign(a,{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-x3jjwl",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.is.unit(t.beforeOpen)?t.beforeOpen:effector.attach({and:t.beforeOpen,or:{name:"beforeOpen",sid:"50j77g"}})}),effector.is.effect(a.beforeOpen,{sid:"-veqqqx"}))return Object.assign(a,{openOn:t.openOn||a.beforeOpen.doneData,cancelOn:t.cancelOn||a.beforeOpen.failData}),a;var n=e;return Object.assign(a,{openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-nr0wzo"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"-js52ao"})}],or:{name:"cancelOn",sid:"yc5yq1"}})}),a})(e),t=a.route,n=a.chainedRoute,o=a.beforeOpen,i=a.openOn,c=a.cancelOn,s=effector.createStore({},{name:"$params",sid:"-5lmaub"}),d=effector.createStore({},{name:"$query",sid:"o66b6f"}),u=effector.combine({and:[effector.combine({and:[[t.$params,t.$query]],or:{name:"and",sid:"30xupk"}}),effector.combine({and:[[s,d]],or:{name:"and",sid:"31hnax"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"kxmugn"}}),l=effector.sample({and:[{clock:[t.opened,t.updated]}],or:{name:"routeOpened",sid:"-wxg30y"}});effector.sample({and:[{clock:l,target:o}],or:{sid:"-oj6bg0"}}),s.on(l,((e,r)=>r.params)),d.on(l,((e,r)=>r.query));var p=effector.sample({and:[{clock:i,source:{params:s,query:d},filter:u}],or:{name:"chainedRouteResolved",sid:"w16a67"}});effector.sample({and:[{clock:p,target:n.navigate}],or:{sid:"-o113v3"}});var f=effector.merge([t.closed,c],{name:"aborted",sid:"eq3v50"});return s.reset(f),d.reset(f),effector.sample({and:[{clock:f,target:n.closed}],or:{sid:"-nkja29"}}),n},e.createHistoryRouter=e=>{var r=e.base,a=e.routes,n=e.notFoundRoute,o=e.hydrate,s=e.serialize,d=e.controls,u=void 0===d?effector.withFactory({sid:"18mftg",fn:()=>b(),name:"controls",method:"createRouterControls"}):d,l=((e,r)=>{void 0===r&&(r="");for(var a,n=[],o=()=>{var e,r=a.value;Array.isArray(r.route)?(e=n).push.apply(e,r.route.map((e=>t(t({},r),{},{route:e})))):n.push(r)},c=i(e);!(a=c()).done;)o();n=n.map((e=>t(t({},e),{},{path:""+r+e.path})));for(var s,d=[],u=[],l=i(n);!(s=l()).done;){var p=s.value;p.route.settings.derived?d.push(p):u.push(p)}if(d.length)for(var f,m=i(d);!(f=m()).done;)console.error("createHistoryRouter: "+f.value.path+" uses derived route. This won't work");return u})(a,r),p=effector.createEvent({name:"setHistory",sid:"-1u7kx1"}),v=effector.createEvent({name:"navigateFromRouteTriggered",sid:"gububi"}),y=effector.createEvent({name:"historyUpdated",sid:"-z0aopm"}),g=effector.createEvent({name:"recalculateTriggered",sid:"yk62st"}),k=effector.createEvent({name:"recalculated",sid:"8ian7n"}),R=effector.createEvent({name:"routesMatched",sid:"-92ot1p"}),$=effector.createEvent({name:"routesMismatched",sid:"-4sml5a"}),j=effector.createEvent({name:"routeNotFound",sid:"-ydlv1"}),P=effector.createEvent({name:"initialized",sid:"201v5k"}),S=effector.createStore("",{name:"$path",sid:"v31vc3"}),A=effector.createStore({},{and:{name:"historyRouter.$query",updateFilter:(e,r)=>!c(e,r)},name:"$query",sid:"hq8yqu"}),T=effector.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"7pd4n2"}),F=effector.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"4adnso"}),C=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"7uuio5"}),D=effector.createStore(!1,{name:"$isRouteNavigateInProgress",sid:"85pc6t"}),N=effector.attach({and:{source:F,effect:(e,r)=>x(t({history:e},r))},or:{name:"pushFx",sid:"oq0p43"}}),U=effector.attach({and:{source:F,effect:e=>{var r=y;try{r=effector.scopeBind(y)}catch(e){}return e.listen((()=>{r()})),!0}},or:{name:"subscribeHistoryFx",sid:"-cx946l"}}),H=effector.sample({and:[{clock:o?[y]:[y,U.done],source:F,filter:Boolean,fn:e=>{var r;return{path:e.location.pathname,query:null!==(r=null==s?void 0:s.read(e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(e.location.search))}}}],or:{name:"historyUpdatedParsed",sid:"vpf79f"}}),M=effector.sample({and:[{clock:H,source:{path:S,query:A},filter:(e,r)=>r.path!==e.path||!c(r.query,e.query),fn:(e,r)=>r}],or:{name:"historyUpdateTriggered",sid:"-s686fp"}});F.on(p,((e,r)=>r)),effector.sample({and:[{clock:F,target:U}],or:{sid:"-qbfnuu"}}),effector.sample({and:[{clock:M,source:F,filter:Boolean,fn:e=>{var r,a=null==e?void 0:e.location.hash;return{path:null==e?void 0:e.location.pathname,query:null!==(r=null==s?void 0:s.read(null==e?void 0:e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(null==e?void 0:e.location.search)),hash:a}},target:g}],or:{sid:"-px50fg"}});for(var z,I=i(l);!(z=I()).done;){var L=z.value,Q=R.filterMap(w(L)),B=$.filterMap(w(L)),_={opened:effector.sample({and:[{clock:Q,filter:h(L.route.$isOpened)}],or:{name:"opened",sid:"ox3egs"}}),updated:effector.sample({and:[{clock:Q,filter:L.route.$isOpened}],or:{name:"updated",sid:"-hiw653"}}),closed:effector.sample({and:[{clock:B,filter:L.route.$isOpened}],or:{name:"closed",sid:"4nuv07"}})};effector.sample({and:[{clock:_.updated,source:[L.route.$params,L.route.$query],filter:(e,r)=>{var a=e[1];return!c(e[0],r.params)||!c(a,r.query)},fn:(e,r)=>r,target:L.route.updated}],or:{sid:"-of968c"}}),effector.sample({and:[{clock:_.opened,filter:h(D),target:L.route.opened}],or:{sid:"-nxnr8s"}}),effector.sample({and:[{clock:_.closed,target:L.route.closed}],or:{sid:"-nhpq1b"}})}for(var W,K=()=>{var e=W.value;effector.sample({and:[{clock:e.route.navigate.doneData,fn:r=>{var a=r.replace;return{route:e,params:r.params,query:r.query,replace:null!=a&&a}},target:v}],or:{sid:"-d39tye"}})},G=i(l);!(W=G()).done;)K();D.on(v,(()=>!0)),effector.sample({and:[{clock:v,fn:e=>{var r=e.params,a=e.query,t=e.replace;return{path:f({pathCreator:e.route.path,params:r,query:a,serialize:s}),params:r,query:a,method:t?"replace":"push"}},target:N}],or:{sid:"-ck118h"}}),D.reset([R,$]),effector.sample({and:[{clock:g,fn:e=>{for(var r,a=e.path,t=e.query,n=e.hash,o=[],c=[],s=i(l);!(r=s()).done;){var d=r.value,u=d.path.includes("#")?""+a+n:""+a,p=m({pathCreator:d.path,actualPath:u});(p.matches?o:c).push({routeObj:d,params:p.params,query:t})}return c.forEach(((e,r)=>{o.some((r=>r.routeObj.route===e.routeObj.route))&&c.splice(r,1)})),{matching:o,mismatching:c.filter(Boolean),path:a,query:t}},target:k}],or:{sid:"-b86xm2"}}),S.on(M,((e,r)=>r.path)),A.on(M,((e,r)=>r.query));var J=k.map((e=>e.matching));return effector.sample({and:[{clock:J,filter:e=>e.length>0,target:R}],or:{sid:"-8vim8g"}}),effector.sample({and:[{clock:k.map((e=>e.mismatching)),filter:e=>e.length>0,target:$}],or:{sid:"-8s7uoa"}}),T.on(k,((e,r)=>r.matching.map((e=>e.routeObj.route)))),effector.sample({and:[{clock:J,filter:e=>0===e.length,target:j}],or:{sid:"1nbmld"}}),effector.withFactory({sid:"2262pk",fn:()=>O(n),name:"none",method:"isRoute"})&&(effector.sample({and:[{clock:j,source:A,filter:n.$isOpened,fn:e=>({query:e,params:{}}),target:n.updated}],or:{sid:"22pv97"}}),effector.sample({and:[{clock:j,source:{query:A,isOpened:n.$isOpened},filter:e=>!e.isOpened,fn:e=>({query:e.query,params:{}}),target:n.opened}],or:{sid:"2inwgo"}}),effector.sample({and:[{clock:J,source:n.$isOpened,filter:(e,r)=>e&&r.length>0,target:n.closed}],or:{sid:"2ylxo5"}})),effector.sample({and:[{clock:u.back,source:F,target:E}],or:{sid:"3f3rf9"}}),effector.sample({and:[{clock:u.forward,source:F,target:q}],or:{sid:"3ieizf"}}),effector.sample({and:[{clock:A,source:{controlsQuery:u.$query,localQuery:A},filter:e=>!c(e.controlsQuery,e.localQuery),fn:e=>e.localQuery,target:u.$query}],or:{sid:"3xsrlj"}}),effector.sample({and:[{clock:u.$query,source:{path:S,localQuery:A,isNavigateInProgress:D,realHistory:F},filter:(e,r)=>{var a,t,n,o=e.localQuery,i=e.isNavigateInProgress,d=e.realHistory,u=null!==(a=null==s?void 0:s.read(null!==(t=null==d?void 0:d.location.search)&&void 0!==t?t:""))&&void 0!==a?a:Object.fromEntries(new URLSearchParams(null!==(n=null==d?void 0:d.location.search)&&void 0!==n?n:""));return i||!c(r,u)||!c(o,r)},fn:(e,r)=>{var a,t=e.path,n=null!==(a=null==s?void 0:s.write(r))&&void 0!==a?a:new URLSearchParams(r);return{path:t+(n?"?"+n:""),params:{},query:r,method:"push"}},target:N}],or:{sid:"4dqst0"}}),effector.sample({and:[{clock:k,source:{activeRoutes:T,path:S,query:A},filter:C.map((e=>!e)),target:P}],or:{sid:"5sbve8"}}),C.on(P,(()=>!0)).reset(F),{$path:S,$activeRoutes:T,$history:F,setHistory:p,$query:A,back:u.back,forward:u.forward,push:N,routes:l,initialized:P,routeNotFound:j}},e.createRoute=r,e.createRouterControls=b,e.isRoute=O,e.matchPath=m,e.querySync=e=>{var r,a,n,o=null!==(r=null===(a=e.route)||void 0===a?void 0:a.$isOpened)&&void 0!==r?r:effector.createStore(!0,{name:"$isOpened",sid:"-1sf5w3"}),c=effector.combine({and:[e.source],or:{name:"$source",sid:"-4puqls"}}),s=null!==(n=e.clock)&&void 0!==n?n:c,d="cleanup"in e?"boolean"==typeof e.cleanup?k[e.cleanup?"all":"none"]:t(t({},k.default),e.cleanup):k.default,u=effector.sample({and:[{clock:e.controls.$query,filter:o}],or:{name:"queryUpdatedFromHistory",sid:"7nbv4h"}});effector.sample({and:[{clock:s,source:effector.combine({and:[[c,e.controls.$query]],or:{name:"source",sid:"-4nk0xe"}}),filter:o,fn:e=>{var r=e[0],a=e[1],n={};if(d.irrelevant)for(var o,c=i(d.preserve);!(o=c()).done;){var s=o.value;s in a&&(n[s]=a[s])}else n=t({},a);for(var u in r)n[u]=r[u];if(d.empty)for(var l in r)d.preserve.includes(l)||n[l]||delete n[l];return n},target:e.controls.$query}],or:{sid:"ftvpyq"}});var l=r=>{var a=e.source[r];a.on(u,((e,t)=>{var n;return null!==(n=t[r])&&void 0!==n?n:a.defaultState}))};for(var p in e.source)l(p)},e.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-f15r5p"}}):effector.createEvent({name:"clock",sid:"-f0lykc"}),a=y(e.params||{}),t=y(e.query||{}),n=y(e.replace||!1);return effector.sample({and:[{clock:r,source:{params:a,query:t,replace:n},fn:(e,r)=>{var a=e.params,t=e.query,n=e.replace;return{params:"function"==typeof a?a(r):a,query:"function"==typeof t?t(r):t,replace:"function"==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"a0n4fl"}}),r},Object.defineProperty(e,'__esModule',{value:!0})})); | ||
//# sourceMappingURL=atomic-router.umd.js.map |
{ | ||
"name": "atomic-router", | ||
"author": "Anton Kosykh", | ||
"version": "0.9.2", | ||
"version": "0.9.3-rc.0", | ||
"license": "MIT", | ||
"main": "dist/atomic-router.cjs.js", | ||
"module": "dist/atomic-router.esm.js", | ||
"main": "dist/atomic-router.js", | ||
"module": "dist/atomic-router.mjs", | ||
"unpkg": "dist/atomic-router.umd.js", | ||
@@ -12,7 +12,7 @@ "types": "dist/atomic-router.d.ts", | ||
".": { | ||
"types": "./dist/atomic-router.d.ts", | ||
"import": "./dist/atomic-router.esm.js", | ||
"types": "./dist/atomic-router.d.mts", | ||
"import": "./dist/atomic-router.mjs", | ||
"require": "./dist/atomic-router.cjs.js", | ||
"node": "./dist/atomic-router.cjs.js", | ||
"default": "./dist/atomic-router.esm.js" | ||
"default": "./dist/atomic-router.mjs" | ||
}, | ||
@@ -85,7 +85,7 @@ "./package.json": "./package.json" | ||
{ | ||
"path": "dist/atomic-router.esm.js", | ||
"path": "dist/atomic-router.mjs", | ||
"limit": "10 kB" | ||
}, | ||
{ | ||
"path": "dist/atomic-router.cjs.js", | ||
"path": "dist/atomic-router.js", | ||
"limit": "10 kB" | ||
@@ -92,0 +92,0 @@ } |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
251292
12