atomic-router
Advanced tools
Comparing version 0.6.3 to 0.7.0
@@ -1,2 +0,2 @@ | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,a)}return t}function r(r){for(var t=1;t<arguments.length;t++){var a=null!=arguments[t]?arguments[t]:{};t%2?e(Object(a),!0).forEach((e=>{o(r,e,a[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(a)):e(Object(a)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(a,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,t,o){var i=Object.create((r&&r.prototype instanceof n?r:n).prototype),c=new p(o||[]);return i._invoke=((e,r,t)=>{var n="suspendedStart";return(o,i)=>{if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw i;return{value:void 0,done:!0}}for(t.method=o,t.arg=i;;){var c=t.delegate;if(c){var s=u(c,t);if(s){if(s===k)continue;return s}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===n)throw n="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);n="executing";var d=a(e,r,t);if("normal"===d.type){if(n=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(n="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function a(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function n(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function t(n,o,i,c){var s=a(e[n],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>t("throw",e,i,c)))}c(s.arg)}var n;this._invoke=(e,a)=>{function o(){return new r(((r,n)=>{t(e,a,r,n)}))}return n=n?n.then(o,o):o()}}function u(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var n=a(t,e.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,k;var o=n.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function l(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function p(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,a=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return a.next=a}}return{next:f}}function f(){return{value:void 0,done:!0}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",w=g.asyncIterator||"@@asyncIterator",O=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var E=i.prototype=n.prototype=Object.create(x);return o.prototype=i,e(E,"constructor",i),e(i,"constructor",o),o.displayName=e(i,O,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,O,"GeneratorFunction")),r.prototype=Object.create(E),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,w,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,a,n,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,a,n),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(E),e(E,O,"Generator"),e(E,b,(function(){return this})),e(E,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var a=r.pop();if(a in e)return t.value=a,t.done=!1,t}return t.done=!0,t}},m.values=h,p.prototype={constructor:p,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,a){return o.type="throw",o.arg=e,t.next=r,a&&(t.method="next",t.arg=void 0),!!a}if(this.done)throw e;for(var t=this,a=this.tryEntries.length-1;a>=0;--a){var n=this.tryEntries[a],o=n.completion;if("root"===n.tryLoc)return r("end");if(n.tryLoc<=this.prev){var i=v.call(n,"catchLoc"),c=v.call(n,"finallyLoc");if(i&&c){if(this.prev<n.catchLoc)return r(n.catchLoc,!0);if(this.prev<n.finallyLoc)return r(n.finallyLoc)}else if(i){if(this.prev<n.catchLoc)return r(n.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<n.finallyLoc)return r(n.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var a=this.tryEntries[t];if(a.tryLoc<=this.prev&&v.call(a,"finallyLoc")&&this.prev<a.finallyLoc){var n=a;break}}n&&("break"===e||"continue"===e)&&n.tryLoc<=r&&r<=n.finallyLoc&&(n=null);var o=n?n.completion:{};return o.type=e,o.arg=r,n?(this.method="next",this.next=n.finallyLoc,k):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),l(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var a=t.completion;if("throw"===a.type){var n=a.arg;l(t)}return n}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function a(e,r,t,a,n,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(a,n)}function n(e){return function(){var r=this,t=arguments;return new Promise(((n,o)=>{function i(e){a(s,n,o,i,c,"next",e)}function c(e){a(s,n,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function o(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}function c(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 i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}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 s(e){var r=e.params,t=e.query;return d.compile(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function u(e){var r=e.actualPath,t=d.match(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:!0,params:t.params}:{matches:!1}}Object.defineProperty(exports,'__esModule',{value:!0});var effector=require('effector'),d=require('path-to-regexp'),l={ROUTE:Symbol()},p=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=n(t().mark((function e(r){var a;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{},replace:null!=(a=r.replace)&&a});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"52jcg"}),a=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{},replace:!1})},or:{name:"openFx",sid:"ds1pqb"}}),o=effector.createStore(!1,{name:"$isOpened",sid:"-iv1wgo"}),i=effector.createStore({},{name:"$params",sid:"-p7a5rj"}),c=effector.createStore({},{name:"$query",sid:"-ft242y"}),s=effector.createEvent({name:"opened",sid:"tqi26x"}),u=effector.createEvent({name:"updated",sid:"2k5mw9"}),d=effector.createEvent({name:"left",sid:"8wd07q"}),p=effector.createEvent({name:"closed",sid:"gobyzc"});return o.on(s,(()=>!0)).on(d,(()=>!1)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:o.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vo1lhl"}}),effector.sample({and:[{clock:p,target:d}],or:{sid:"-v7jror"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"k6fanh"}}),match:e=>e?'true':'false',cases:{true:s,false:p}}],or:{sid:"-us5j0x"}}),{$isOpened:o,$params:i,$query:c,opened:s,updated:u,closed:p,left:d,navigate:r,open:a,kind:l.ROUTE,settings:{derived:Boolean(e.filter)}}},h=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},f=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===l.ROUTE,m=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),y=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});exports.Kind=l,exports.buildPath=s,exports.chainRoute=e=>{var t=(e=>{if(f(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>p(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(effector.is.unit(t.beforeOpen)||(t.beforeOpen=effector.attach({and:t.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>p(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var a=e;return{route:a.route,chainedRoute:a.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>p(),name:"chainedRoute",method:"createRoute"}),beforeOpen:a.beforeOpen,openOn:effector.sample({and:[{clock:a.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:a.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),a=t.route,n=t.chainedRoute,o=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[a.$params,a.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),l=effector.sample({and:[{clock:[a.opened,a.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:l,target:o}],or:{sid:"ggm0br"}}),s.on(l,((e,r)=>r.params)),u.on(l,((e,r)=>r.query));var h=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:h,target:n.navigate}],or:{sid:"gyr7wo"}});var m=effector.merge([a.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(m),u.reset(m),effector.sample({and:[{clock:m,target:n.closed}],or:{sid:"hf91pi"}}),n},exports.createHistoryRouter=function(e){var a=((e,t)=>{void 0===t&&(t='');for(var a,n=[],o=()=>{var e,t=a.value;Array.isArray(t.route)?(e=n).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):n.push(t)},i=c(e);!(a=i()).done;)o();n=n.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var s,u=[],d=[],l=c(n);!(s=l()).done;){var p=s.value;p.route.settings.derived?u.push(p):d.push(p)}if(u.length)for(var h,f=c(u);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),o=effector.createEvent({name:"setHistory",sid:"-6zj1hl"}),i=effector.createEvent({name:"routeNotFound",sid:"-ykbdqf"}),d=effector.createStore({},{name:"$query",sid:"-5882ld"}),l=effector.createStore('',{name:"$path",sid:"-n8xqik"}),p=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"xi9y0h"}),y=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"-lmw2f4"}),v=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"projjg"});v.on(o,((e,r)=>r));var g=effector.attach({and:{source:{history:v},effect:m,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8ywb72"}}),b=effector.createEffect((e=>{var r=e.params,t=e.query,a=e.replace;return{path:s({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:a?'replace':'push'}}),{name:"openedFx",sid:"qllh6g"}),w=effector.createEffect((e=>{for(var r,t=e.path,n=e.query,o=e.hash,i=[],s=[],d=c(a);!(r=d()).done;){var l=r.value,p=l.path.includes('#')?""+t+o:""+t,h=u({pathCreator:""+l.path,actualPath:p});(h.matches?i:s).push({route:l,params:h.params,query:n})}var f=e=>{var r=e;i.some((e=>e.route.route===s[r].route.route))&&(s[r]=null)};for(var m in s)f(m);return s=s.filter(Boolean),{opened:i,closed:s}}),{name:"recalculateFx",sid:"pmoect"});l.on(w.done,((e,r)=>r.params.path)),d.on(w.done,((e,r)=>r.params.query)),p.on(w.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:b.doneData,target:g}],or:{sid:"-4vu5fj"}}),effector.guard({and:[{clock:w.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4e8qfz"}});for(var O,k=w.doneData.map((e=>e.opened)),x=w.doneData.map((e=>e.closed)),j=()=>{var e=O.value,r=effector.createStore(!1,{name:"$isOpenedManually",sid:"ccm8mt"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.params.replace,a=r.result;return{route:e,params:a.params,query:a.query,replace:null!=t&&t}},target:b}],or:{sid:"-3ug519"}});var a=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},n={opened:effector.guard({and:[{clock:k.filterMap(a),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"gsr47l"}}),updated:effector.guard({and:[{clock:k.filterMap(a),filter:e.route.$isOpened}],or:{name:"updated",sid:"-h7mvpe"}}),closed:effector.guard({and:[{clock:x.filterMap(a),filter:e.route.$isOpened}],or:{name:"closed",sid:"jb4u8c"}})};r.on(t,(()=>!0));var o=effector.guard({and:[{clock:n.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-n23a7"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"g3r8w1"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!h(e[0],r.params)||!h(t,r.query)}}],or:{name:"clock",sid:"ual9o4"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1ibm90"}}),effector.guard({and:[{clock:n.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"9c2b1e"}}),effector.sample({and:[{clock:n.closed,target:e.route.closed}],or:{sid:"9fwv6x"}}),r.reset(effector.sample({and:[{clock:k}],or:{sid:"ld2dek"}}))},q=c(a);!(O=q()).done;)j();if(f(e.notFoundRoute)){var E=effector.sample({and:[{clock:p,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"47ytg9"}});effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"adgbdy"}}),effector.sample({and:[{clock:E,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"aty56s"}}),effector.sample({and:[{clock:E,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"bafyzm"}})}var R,L=effector.attach({and:{source:{history:v},effect:(R=n(t().mark((function e(r){var a,n;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return n=[(a=r.history).location.pathname,Object.fromEntries(new URLSearchParams(a.location.search)),a.location.hash],e.abrupt("return",{path:n[0],query:n[1],hash:n[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return R.apply(this,arguments)})},or:{name:"recheckFx",sid:"-om9382"}});effector.sample({and:[{source:L.doneData,target:w}],or:{sid:"cpku4h"}});var S,P=effector.attach({and:{source:{history:v},effect:(S=n(t().mark((function e(r){var a,n;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:a=r.history,n=L;try{n=effector.scopeBind(L)}catch(e){}return a.listen((()=>{n()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)}))),function(e){return S.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-gu1w73"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:L}],or:{sid:"o0gl9f"}}),effector.sample({and:[{clock:v,target:P}],or:{sid:"o3rcrv"}}),y.on(w.doneData,(()=>!0)).reset(v);var $=effector.sample({and:[{clock:effector.guard({and:[{clock:y,filter:Boolean}],or:{name:"clock",sid:"-f9ze7m"}}),source:{activeRoutes:p,path:l,query:d}}],or:{name:"initialized",sid:"-khsq3"}});return{$path:l,$query:d,$activeRoutes:p,$history:v,setHistory:o,push:g,routes:a,initialized:$,routeNotFound:i}},exports.createRoute=p,exports.isRoute=f,exports.matchPath=u,exports.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=y(e.params||{}),a=y(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:a},fn:(e,r)=>{var t=e.params,a=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof a?a(r):a}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r}; | ||
function e(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:"bloywh"}),a=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"a4yhwl"}}),t=effector.createStore(!1,{name:"$isOpened",sid:"-9b3vrp"}),o=effector.createStore({},{name:"$params",sid:"-a8p0s"}),n=effector.createStore({},{name:"$query",sid:"thjwzy"}),s=effector.createEvent({name:"opened",sid:"ete45t"}),i=effector.createEvent({name:"updated",sid:"5pu5nl"}),c=effector.createEvent({name:"closed",sid:"-wsro1a"});return t.on(s,(()=>!0)).on(c,(()=>!1)),o.on(s,((e,r)=>r.params)).on(i,((e,r)=>r.params)),n.on(s,((e,r)=>r.query)).on(i,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:t.map((e=>e?'updated':'opened')),cases:{opened:s,updated:i}}],or:{sid:"3ildw2"}}),{$isOpened:t,$params:o,$query:n,opened:s,updated:i,closed:c,navigate:r,open:a,kind:m.ROUTE,settings:{derived:Boolean(e.filter)}}}function r(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 a(e){for(var a=1;a<arguments.length;a++){var o=null!=arguments[a]?arguments[a]:{};a%2?r(Object(o),!0).forEach((r=>{t(e,r,o[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(o)):r(Object(o)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(o,r))}))}return e}function t(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 n(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 s(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 i(e){var r,a=e.params,t=e.query,o=e.serialize,n=p.compile(e.pathCreator)(a),s=null!==(r=null==o?void 0:o.write(t))&&void 0!==r?r:new URLSearchParams(t);return n+(Object.keys(t).length?"?"+s:'')}function c(e){var r=e.actualPath,a=p.match(e.pathCreator.replace('://','\\://'))((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 d(e){if(!e)throw new Error('[Routing] No history provided')}function l(e){return e.map((e=>!e))}function u(e){return effector.is.store(e,{sid:"ayqde0"})?e:effector.createStore(e,{sid:"-f8uw25"})}Object.defineProperty(exports,'__esModule',{value:!0});var effector=require('effector'),p=require('path-to-regexp'),m={ROUTE:Symbol()},h=()=>({$query:effector.createStore({},{and:{updateFilter:(e,r)=>!s(r,e)},name:"$query",sid:"z22f3o"}),back:effector.createEvent({name:"back",sid:"lqciue"}),forward:effector.createEvent({name:"forward",sid:"-5dfdts"})}),f=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===m.ROUTE,y=effector.createEffect((e=>(d(e.history),e.history[e.method](e.path,{}),e)),{name:"historyPushFx",sid:"-w0no5y"}),v=effector.createEffect((e=>(d(e),e.back(),e)),{name:"historyBackFx",sid:"-ny8vwp"}),g=effector.createEffect((e=>(d(e),e.forward(),e)),{name:"historyForwardFx",sid:"88oqi4"}),b=e=>r=>{var a=r.find((r=>r.routeObj.route===e.route));if(a)return{params:a.params,query:a.query}};exports.Kind=m,exports.buildPath=i,exports.chainRoute=r=>{var a=(r=>{var a={};if(effector.withFactory({sid:"-vuorye",fn:()=>f(r),name:"none",method:"isRoute"}))return Object.assign(a,{route:r,chainedRoute:effector.withFactory({sid:"-x3jlk0",fn:()=>e(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"2i9mdy"}),openOn:effector.merge([r.opened,r.closed],{name:"openOn",sid:"-n9uh0c"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"r6ceph"})],{name:"cancelOn",sid:"r6ce1d"})}),a;var t=r;if(Object.assign(a,{route:t.route,chainedRoute:t.chainedRoute||effector.withFactory({sid:"-if59ok",fn:()=>e(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.is.unit(t.beforeOpen)?t.beforeOpen:effector.attach({and:t.beforeOpen,or:{name:"beforeOpen",sid:"-xdumjk"}})}),effector.is.effect(a.beforeOpen,{sid:"-qylloz"}))return Object.assign(a,{openOn:t.openOn||a.beforeOpen.doneData,cancelOn:t.cancelOn||a.beforeOpen.failData}),a;var o=r;return Object.assign(a,{openOn:effector.sample({and:[{clock:o.openOn}],or:{name:"openOn",sid:"-92mmrn"}}),cancelOn:effector.sample({and:[{clock:o.cancelOn||effector.createEvent({name:"clock",sid:"-53qs2n"})}],or:{name:"cancelOn",sid:"-m0jt12"}})}),a})(r),t=a.route,o=a.chainedRoute,n=a.beforeOpen,s=a.openOn,i=a.cancelOn,c=effector.createStore({},{name:"$params",sid:"ahwukb"}),d=effector.createStore({},{name:"$query",sid:"-urele3"}),l=effector.combine({and:[effector.combine({and:[[t.$params,t.$query]],or:{name:"and",sid:"3v6jcf"}}),effector.combine({and:[[c,d]],or:{name:"and",sid:"3vqbxs"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"-xzy23v"}}),u=effector.sample({and:[{clock:[t.opened,t.updated]}],or:{name:"routeOpened",sid:"-gtwxmc"}});effector.sample({and:[{clock:u,target:n}],or:{sid:"-noxmt5"}}),c.on(u,((e,r)=>r.params)),d.on(u,((e,r)=>r.query));var p=effector.guard({and:[{clock:s,source:{params:c,query:d},filter:l}],or:{name:"chainedRouteResolved",sid:"-mwemeb"}});effector.sample({and:[{clock:p,target:o.navigate}],or:{sid:"-n6sf88"}});var m=effector.merge([t.closed,i],{name:"aborted",sid:"utn0jm"});return c.reset(m),d.reset(m),effector.sample({and:[{clock:m,target:o.closed}],or:{sid:"-mqalfe"}}),o},exports.createHistoryRouter=e=>{var r=e.base,t=e.routes,o=e.notFoundRoute,d=e.hydrate,u=e.serialize,p=e.controls,m=void 0===p?effector.withFactory({sid:"d2qzob",fn:()=>h(),name:"controls",method:"createRouterControls"}):p,O=((e,r)=>{void 0===r&&(r='');for(var t,o=[],s=()=>{var e,r=t.value;Array.isArray(r.route)?(e=o).push.apply(e,r.route.map((e=>a(a({},r),{},{route:e})))):o.push(r)},i=n(e);!(t=i()).done;)s();o=o.map((e=>a(a({},e),{},{path:""+r+e.path})));for(var c,d=[],l=[],u=n(o);!(c=u()).done;){var p=c.value;p.route.settings.derived?d.push(p):l.push(p)}if(d.length)for(var m,h=n(d);!(m=h()).done;)console.error("createHistoryRouter: "+m.value.path+" uses derived route. This won't work");return l})(t,r),q=effector.createEvent({name:"setHistory",sid:"9zwyxu"}),k=effector.createEvent({name:"navigateFromRouteTriggered",sid:"soge6d"}),w=effector.createEvent({name:"historyUpdated",sid:"-x4474u"}),j=effector.createEvent({name:"recalculateTriggered",sid:"-ykrhlj"}),R=effector.createEvent({name:"recalculated",sid:"aeh4sf"}),$=effector.createEvent({name:"routesMatched",sid:"2rfqt6"}),x=effector.createEvent({name:"routesMismatched",sid:"71hypl"}),E=effector.createEvent({name:"routeNotFound",sid:"avqxzu"}),P=effector.createEvent({name:"initialized",sid:"du6f0f"}),S=effector.createStore('',{name:"$path",sid:"wz8cwv"}),F=effector.createStore({},{and:{name:'historyRouter.$query',updateFilter:(e,r)=>!s(e,r)},name:"$query",sid:"tkdilp"}),z=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"9ljm7u"}),U=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"g4i7nj"}),A=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"9r108x"}),C=effector.createStore(!1,{name:"$isRouteNavigateInProgress",sid:"a1vtrl"}),D=effector.attach({and:{source:U,effect:(e,r)=>y(a({history:e},r))},or:{name:"pushFx",sid:"qm76ov"}}),T=effector.attach({and:{source:U,effect:e=>{var r=w;try{r=effector.scopeBind(w)}catch(e){console.log(e)}return e.listen((()=>{r()})),!0}},or:{name:"subscribeHistoryFx",sid:"-b12mlt"}}),H=effector.sample({and:[{clock:d?[w]:[w,T.done],source:U,filter:Boolean,fn:e=>{var r;return{path:e.location.pathname,query:null!==(r=null==u?void 0:u.read(e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(e.location.search))}}}],or:{name:"historyUpdatedParsed",sid:"-qjh22g"}}),Q=effector.sample({and:[{clock:H,source:{path:S,query:F},filter:(e,r)=>r.path!==e.path||!s(r.query,e.query),fn:(e,r)=>r}],or:{name:"historyUpdateTriggered",sid:"-efx502"}});U.on(q,((e,r)=>r)),effector.sample({and:[{clock:U,target:T}],or:{sid:"-pvhmnd"}}),effector.sample({and:[{clock:Q,source:U,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==u?void 0:u.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:j}],or:{sid:"-psqnok"}});for(var B,I=n(O);!(B=I()).done;){var L=B.value,M=$.filterMap(b(L)),N=x.filterMap(b(L)),_={opened:effector.sample({and:[{clock:M,filter:l(L.route.$isOpened)}],or:{name:"opened",sid:"-uhj4hx"}}),updated:effector.sample({and:[{clock:M,filter:L.route.$isOpened}],or:{name:"updated",sid:"-1wen4o"}}),closed:effector.sample({and:[{clock:N,filter:L.route.$isOpened}],or:{name:"closed",sid:"u8agap"}})};effector.sample({and:[{clock:_.updated,source:[L.route.$params,L.route.$query],filter:(e,r)=>{var a=e[1];return!s(e[0],r.params)||!s(a,r.query)},fn:(e,r)=>r,target:L.route.updated}],or:{sid:"-nx3ynf"}}),effector.sample({and:[{clock:_.opened,filter:l(C),target:L.route.opened}],or:{sid:"-nfijnv"}}),effector.sample({and:[{clock:_.closed,target:L.route.closed}],or:{sid:"-d1mg6b"}})}for(var K,G=()=>{var e=K.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:k}],or:{sid:"-cl4mdh"}})},J=n(O);!(K=J()).done;)G();C.on(k,(()=>!0)),effector.sample({and:[{clock:k,fn:e=>{var r=e.params,a=e.query,t=e.replace;return{path:i({pathCreator:e.route.path,params:r,query:a,serialize:u}),params:r,query:a,method:t?'replace':'push'}},target:D}],or:{sid:"-bqc56z"}}),C.reset([$,x]),effector.sample({and:[{clock:j,fn:e=>{for(var r,a=e.path,t=e.query,o=e.hash,s=[],i=[],d=n(O);!(r=d()).done;){var l=r.value,u=l.path.includes('#')?""+a+o:""+a,p=c({pathCreator:l.path,actualPath:u});(p.matches?s:i).push({routeObj:l,params:p.params,query:t})}return i.forEach(((e,r)=>{s.some((r=>r.routeObj.route===e.routeObj.route))&&i.splice(r,1)})),{matching:s,mismatching:i.filter(Boolean),path:a,query:t}},target:R}],or:{sid:"-aq1q15"}}),S.on(Q,((e,r)=>r.path)),F.on(Q,((e,r)=>r.query));var V=R.map((e=>e.matching));return effector.sample({and:[{clock:V,filter:e=>e.length>0,target:$}],or:{sid:"1m81en"}}),effector.sample({and:[{clock:R.map((e=>e.mismatching)),filter:e=>e.length>0,target:x}],or:{sid:"212hfe"}}),z.on(R,((e,r)=>r.matching.map((e=>e.routeObj.route)))),effector.sample({and:[{clock:V,filter:e=>0===e.length,target:E}],or:{sid:"2inwey"}}),effector.withFactory({sid:"2lyo2k",fn:()=>f(o),name:"none",method:"isRoute"})&&(effector.sample({and:[{clock:E,source:F,filter:o.$isOpened,fn:e=>({query:e,params:{}}),target:o.updated}],or:{sid:"2y252s"}}),effector.sample({and:[{clock:E,source:{query:F,isOpened:o.$isOpened},filter:e=>!e.isOpened,fn:e=>({query:e.query,params:{}}),target:o.opened}],or:{sid:"32ghto"}}),effector.sample({and:[{clock:V,source:o.$isOpened,filter:(e,r)=>e&&r.length>0,target:o.closed}],or:{sid:"3iej15"}})),effector.sample({and:[{clock:m.back,source:U,target:v}],or:{sid:"3ywcs9"}}),effector.sample({and:[{clock:m.forward,source:U,target:g}],or:{sid:"4dqst0"}}),effector.sample({and:[{clock:F,source:{controlsQuery:m.$query,localQuery:F},filter:e=>!s(e.controlsQuery,e.localQuery),fn:e=>e.localQuery,target:m.$query}],or:{sid:"4hlcyj"}}),effector.sample({and:[{clock:m.$query,source:{path:S,localQuery:F,isNavigateInProgress:C,realHistory:U},filter:(e,r)=>{var a,t,o,n=e.localQuery,i=e.isNavigateInProgress,c=e.realHistory,d=null!==(a=null==u?void 0:u.read(null!==(t=null==c?void 0:c.location.search)&&void 0!==t?t:''))&&void 0!==a?a:Object.fromEntries(new URLSearchParams(null!==(o=null==c?void 0:c.location.search)&&void 0!==o?o:''));return i||!s(r,d)||!s(n,r)},fn:(e,r)=>{var a,t=e.path,o=null!==(a=null==u?void 0:u.write(r))&&void 0!==a?a:new URLSearchParams(r);return{path:t+(o?"?"+o:''),params:{},query:r,method:'push'}},target:D}],or:{sid:"4y36rd"}}),effector.sample({and:[{clock:R,source:{activeRoutes:z,path:S,query:F},filter:A.map((e=>!e)),target:P}],or:{sid:"god6gp"}}),A.on(P,(()=>!0)).reset(U),{$path:S,$activeRoutes:z,$history:U,setHistory:q,$query:F,back:m.back,forward:m.forward,push:D,routes:O,initialized:P,routeNotFound:E}},exports.createRoute=e,exports.createRouterControls=h,exports.isRoute=f,exports.matchPath=c,exports.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-el7py8"}}):effector.createEvent({name:"clock",sid:"-eknxcv"}),a=u(e.params||{}),t=u(e.query||{});return effector.sample({and:[{clock:r,source:{params:a,query:t},fn:(e,r)=>{var a=e.params,t=e.query;return{params:'function'==typeof a?a(r):a,query:'function'==typeof t?t(r):t}},target:e.route.navigate}],or:{sid:"a4hol4"}}),r}; | ||
//# sourceMappingURL=atomic-router.cjs.js.map |
@@ -11,2 +11,5 @@ import * as effector from 'effector'; | ||
}; | ||
interface NavigateParams<Params extends RouteParams> extends RouteParamsAndQuery<Params> { | ||
replace?: boolean; | ||
} | ||
declare type RouteInstance<Params extends RouteParams> = { | ||
@@ -19,20 +22,6 @@ $isOpened: Store<boolean>; | ||
closed: Event<void>; | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
left: Event<void>; | ||
navigate: Effect<RouteParamsAndQuery<Params> & { | ||
replace?: boolean; | ||
}, RouteParamsAndQuery<Params>>; | ||
navigate: Effect<NavigateParams<Params>, NavigateParams<Params>>; | ||
open: Effect<Params, RouteParamsAndQuery<Params>>; | ||
kind: typeof Kind.ROUTE; | ||
}; | ||
declare type PathCreator<Params extends RouteParams> = string; | ||
declare const Kind: { | ||
ROUTE: symbol; | ||
}; | ||
declare type createRouteParams = { | ||
filter?: Store<boolean>; | ||
}; | ||
declare const createRoute: <Params extends RouteParams = {}>(params?: createRouteParams) => RouteInstance<Params>; | ||
declare type RouteObject<Params extends RouteParams> = { | ||
@@ -53,13 +42,38 @@ route: RouteInstance<Params>; | ||
}; | ||
declare const createHistoryRouter: (params: { | ||
declare type HistoryBackForwardParams = History; | ||
declare type ParamsSerializer = { | ||
write: (params: RouteParams) => string; | ||
read: (query: string) => RouteParams; | ||
}; | ||
declare type PathCreator<Params extends RouteParams> = string; | ||
declare const Kind: { | ||
ROUTE: symbol; | ||
}; | ||
declare type CreateRouteParams = { | ||
filter?: Store<boolean>; | ||
}; | ||
declare function createRoute<Params extends RouteParams = {}>(params?: CreateRouteParams): RouteInstance<Params>; | ||
declare const createRouterControls: () => { | ||
$query: effector.Store<RouteQuery>; | ||
back: effector.Event<void>; | ||
forward: effector.Event<void>; | ||
}; | ||
declare function createHistoryRouter({ base, routes, notFoundRoute, hydrate, serialize, controls, }: { | ||
base?: string; | ||
routes: UnmappedRouteObject<any>[]; | ||
notFoundRoute?: RouteInstance<any>; | ||
serialize?: ParamsSerializer; | ||
hydrate?: boolean; | ||
}) => { | ||
controls?: ReturnType<typeof createRouterControls>; | ||
}): { | ||
$path: effector.Store<string>; | ||
$query: effector.Store<{}>; | ||
$activeRoutes: effector.Store<RouteInstance<any>[]>; | ||
$history: effector.Store<History>; | ||
setHistory: effector.Event<History>; | ||
$query: effector.Store<RouteQuery>; | ||
back: effector.Event<void>; | ||
forward: effector.Event<void>; | ||
push: effector.Effect<Omit<HistoryPushParams, "history">, HistoryPushParams, Error>; | ||
@@ -70,3 +84,3 @@ routes: RouteObject<any>[]; | ||
path: string; | ||
query: {}; | ||
query: RouteQuery; | ||
}>; | ||
@@ -80,4 +94,5 @@ routeNotFound: effector.Event<void>; | ||
query: RouteQuery; | ||
serialize?: ParamsSerializer; | ||
}; | ||
declare function buildPath<Params extends RouteParams>({ pathCreator, params, query, }: BuildPathParams<Params>): string; | ||
declare function buildPath<Params extends RouteParams>({ pathCreator, params, query, serialize, }: BuildPathParams<Params>): string; | ||
declare type MatchPathParams<Params extends RouteParams> = { | ||
@@ -98,3 +113,3 @@ pathCreator: PathCreator<Params>; | ||
declare type RedirectParams<T, Params> = Params extends { | ||
declare type RedirectParams<T, Params extends RouteParams> = Params extends { | ||
[key in string]: never; | ||
@@ -120,5 +135,5 @@ } ? { | ||
/** Opens passed `route` upon `clock` trigger */ | ||
declare const redirect: <T, Params>(options: RedirectParams<T, Params>) => Event<T>; | ||
declare function redirect<T, Params extends RouteParams>(options: RedirectParams<T, Params>): Event<T>; | ||
declare type ChainRouteParamsInternalAttach<Params, FX extends Effect<any, any, any>> = { | ||
declare type ChainRouteParamsInternalAttach<Params extends RouteParams, FX extends Effect<any, any, any>> = { | ||
route: RouteInstance<Params>; | ||
@@ -136,3 +151,3 @@ chainedRoute?: RouteInstance<Params>; | ||
}; | ||
declare type ChainRouteParamsWithEffect<Params> = { | ||
declare type ChainRouteParamsWithEffect<Params extends RouteParams> = { | ||
route: RouteInstance<Params>; | ||
@@ -142,3 +157,3 @@ chainedRoute?: RouteInstance<Params>; | ||
}; | ||
declare type ChainRouteParamsAdvanced<Params> = { | ||
declare type ChainRouteParamsAdvanced<Params extends RouteParams> = { | ||
route: RouteInstance<Params>; | ||
@@ -150,7 +165,7 @@ chainedRoute?: RouteInstance<Params>; | ||
}; | ||
declare function chainRoute<Params>(instance: RouteInstance<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params>(config: ChainRouteParamsWithEffect<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params>(config: ChainRouteParamsAdvanced<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params, FX extends Effect<any, any, any>>(config: ChainRouteParamsInternalAttach<Params, FX>): RouteInstance<Params>; | ||
declare function chainRoute<Params extends RouteParams>(instance: RouteInstance<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params extends RouteParams>(config: ChainRouteParamsWithEffect<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params extends RouteParams>(config: ChainRouteParamsAdvanced<Params>): RouteInstance<Params>; | ||
declare function chainRoute<Params extends RouteParams, FX extends Effect<any, any, any>>(config: ChainRouteParamsInternalAttach<Params, FX>): RouteInstance<Params>; | ||
export { Kind, PathCreator, RouteInstance, RouteParams, RouteParamsAndQuery, RouteQuery, buildPath, chainRoute, createHistoryRouter, createRoute, isRoute, matchPath, redirect }; | ||
export { HistoryBackForwardParams, HistoryPushParams, Kind, NavigateParams, ParamsSerializer, PathCreator, RouteInstance, RouteObject, RouteParams, RouteParamsAndQuery, RouteQuery, UnmappedRouteObject, buildPath, chainRoute, createHistoryRouter, createRoute, createRouterControls, isRoute, matchPath, redirect }; |
@@ -1,2 +0,2 @@ | ||
function e(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function r(r){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?e(Object(n),!0).forEach((e=>{a(r,e,n[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(n)):e(Object(n)).forEach((e=>{Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(n,e))}))}return r}function t(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,t,a){var i=Object.create((r&&r.prototype instanceof o?r:o).prototype),c=new p(a||[]);return i._invoke=((e,r,t)=>{var o="suspendedStart";return(a,i)=>{if("executing"===o)throw new Error("Generator is already running");if("completed"===o){if("throw"===a)throw i;return{value:void 0,done:!0}}for(t.method=a,t.arg=i;;){var c=t.delegate;if(c){var u=s(c,t);if(u){if(u===k)continue;return u}}if("next"===t.method)t.sent=t._sent=t.arg;else if("throw"===t.method){if("suspendedStart"===o)throw o="completed",t.arg;t.dispatchException(t.arg)}else"return"===t.method&&t.abrupt("return",t.arg);o="executing";var d=n(e,r,t);if("normal"===d.type){if(o=t.done?"completed":"suspendedYield",d.arg===k)continue;return{value:d.arg,done:t.done}}"throw"===d.type&&(o="completed",t.method="throw",t.arg=d.arg)}}})(e,t,c),i}function n(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function o(){}function a(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function u(e,r){function t(o,a,i,c){var u=n(e[o],e,a);if("throw"!==u.type){var s=u.arg,d=s.value;return d&&"object"==typeof d&&v.call(d,"__await")?r.resolve(d.__await).then((e=>{t("next",e,i,c)}),(e=>{t("throw",e,i,c)})):r.resolve(d).then((e=>{s.value=e,i(s)}),(e=>t("throw",e,i,c)))}c(u.arg)}var o;this._invoke=(e,n)=>{function a(){return new r(((r,o)=>{t(e,n,r,o)}))}return o=o?o.then(a,a):a()}}function s(e,r){var t=e.iterator[r.method];if(void 0===t){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,s(e,r),"throw"===r.method))return k;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return k}var o=n(t,e.iterator,r.arg);if("throw"===o.type)return r.method="throw",r.arg=o.arg,r.delegate=null,k;var a=o.arg;return a?a.done?(r[e.resultName]=a.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,k):a:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,k)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function l(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function p(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function h(e){if(e){var r=e[b];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(v.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:f}}function f(){return{value:void 0,done:!0}}t=()=>m;var m={},y=Object.prototype,v=y.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},b=g.iterator||"@@iterator",w=g.asyncIterator||"@@asyncIterator",O=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var k={},x={};e(x,b,(function(){return this}));var j=Object.getPrototypeOf,q=j&&j(j(h([])));q&&q!==y&&v.call(q,b)&&(x=q);var R=i.prototype=o.prototype=Object.create(x);return a.prototype=i,e(R,"constructor",i),e(i,"constructor",a),a.displayName=e(i,O,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===a||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,O,"GeneratorFunction")),r.prototype=Object.create(R),r),m.awrap=e=>({__await:e}),c(u.prototype),e(u.prototype,w,(function(){return this})),m.AsyncIterator=u,m.async=(e,t,n,o,a)=>{void 0===a&&(a=Promise);var i=new u(r(e,t,n,o),a);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(R),e(R,O,"Generator"),e(R,b,(function(){return this})),e(R,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},m.values=h,p.prototype={constructor:p,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(l),!e)for(var r in this)"t"===r.charAt(0)&&v.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return a.type="throw",a.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n],a=o.completion;if("root"===o.tryLoc)return r("end");if(o.tryLoc<=this.prev){var i=v.call(o,"catchLoc"),c=v.call(o,"finallyLoc");if(i&&c){if(this.prev<o.catchLoc)return r(o.catchLoc,!0);if(this.prev<o.finallyLoc)return r(o.finallyLoc)}else if(i){if(this.prev<o.catchLoc)return r(o.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<o.finallyLoc)return r(o.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&v.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var o=n;break}}o&&("break"===e||"continue"===e)&&o.tryLoc<=r&&r<=o.finallyLoc&&(o=null);var a=o?o.completion:{};return a.type=e,a.arg=r,o?(this.method="next",this.next=o.finallyLoc,k):this.complete(a)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),k},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),l(t),k}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var o=n.arg;l(t)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:h(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),k}},m}function n(e,r,t,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void t(e)}c.done?r(u):Promise.resolve(u).then(n,o)}function o(e){return function(){var r=this,t=arguments;return new Promise(((o,a)=>{function i(e){n(u,o,a,i,c,"next",e)}function c(e){n(u,o,a,i,c,"throw",e)}var u=e.apply(r,t);i(void 0)}))}}function a(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function i(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function c(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 i(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?i(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}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 u(e){var r=e.params,t=e.query;return j(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function s(e){var r=e.actualPath,t=q(e.pathCreator.replace('://','\\://'))((e=>{if(e.match(/^[a-z0-9]+\:\/\//i))return e;var r=new URL("http://_"+e);return[r.pathname,r.hash].join('')})(r));return t?{matches:!0,params:t.params}:{matches:!1}}function d(e){var t=(e=>{if($(e))return{route:e,chainedRoute:x({sid:"wj2jy7",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:f({name:"beforeOpen",sid:"uyxd6d"}),openOn:k([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:k([f({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var t=r({},e);if(w.unit(t.beforeOpen)||(t.beforeOpen=p({and:t.beforeOpen,or:{sid:"-gadjdw"}})),w.effect(t.beforeOpen,{sid:"ohaial"}))return{route:t.route,chainedRoute:t.chainedRoute||x({sid:"-cgk8n3",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:t.beforeOpen,openOn:'openOn'in t?t.openOn:t.beforeOpen.doneData,cancelOn:'cancelOn'in t?t.cancelOn:t.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||x({sid:"rtbqmw",fn:()=>L(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:y({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:y({and:[{clock:n.cancelOn||f({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=t.route,o=t.chainedRoute,a=t.beforeOpen,i=t.openOn,c=t.cancelOn,u=h({},{name:"$params",sid:"-e7xr51"}),s=h({},{name:"$query",sid:"-mfs2i3"}),d=O({and:[O({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),O({and:[[u,s]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),l=y({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});y({and:[{clock:l,target:a}],or:{sid:"ggm0br"}}),u.on(l,((e,r)=>r.params)),s.on(l,((e,r)=>r.query));var m=v({and:[{clock:i,source:{params:u,query:s},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});y({and:[{clock:m,target:o.navigate}],or:{sid:"gyr7wo"}});var g=k([n.closed,c],{name:"aborted",sid:"4m2b1e"});return u.reset(g),s.reset(g),y({and:[{clock:g,target:o.closed}],or:{sid:"hf91pi"}}),o}import{createEffect as l,attach as p,createStore as h,createEvent as f,split as m,sample as y,guard as v,restore as g,scopeBind as b,is as w,combine as O,merge as k,withFactory as x}from'effector';import{compile as j,match as q}from'path-to-regexp';var R={ROUTE:Symbol()},L=function(e){void 0===e&&(e={});var r=l(function(){var e=o(t().mark((function e(r){var n;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{},replace:null!=(n=r.replace)&&n});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"52jcg"}),n=p({and:{effect:r,mapParams:e=>({params:e||{},query:{},replace:!1})},or:{name:"openFx",sid:"ds1pqb"}}),a=h(!1,{name:"$isOpened",sid:"-iv1wgo"}),i=h({},{name:"$params",sid:"-p7a5rj"}),c=h({},{name:"$query",sid:"-ft242y"}),u=f({name:"opened",sid:"tqi26x"}),s=f({name:"updated",sid:"2k5mw9"}),d=f({name:"left",sid:"8wd07q"}),v=f({name:"closed",sid:"gobyzc"});return a.on(u,(()=>!0)).on(d,(()=>!1)),i.on(u,((e,r)=>r.params)).on(s,((e,r)=>r.params)),c.on(u,((e,r)=>r.query)).on(s,((e,r)=>r.query)),m({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:u,updated:s}}],or:{sid:"-vo1lhl"}}),y({and:[{clock:v,target:d}],or:{sid:"-v7jror"}}),e.filter&&m({and:[{source:y({and:[{clock:e.filter}],or:{name:"source",sid:"k6fanh"}}),match:e=>e?'true':'false',cases:{true:u,false:v}}],or:{sid:"-us5j0x"}}),{$isOpened:a,$params:i,$query:c,opened:u,updated:s,closed:v,left:d,navigate:r,open:n,kind:R.ROUTE,settings:{derived:Boolean(e.filter)}}},E=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},$=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===R.ROUTE,P=l((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),F=function(e){var n=((e,t)=>{void 0===t&&(t='');for(var n,o=[],a=()=>{var e,t=n.value;Array.isArray(t.route)?(e=o).push.apply(e,t.route.map((e=>r(r({},t),{},{route:e})))):o.push(t)},i=c(e);!(n=i()).done;)a();o=o.map((e=>r(r({},e),{},{path:""+t+e.path})));for(var u,s=[],d=[],l=c(o);!(u=l()).done;){var p=u.value;p.route.settings.derived?s.push(p):d.push(p)}if(s.length)for(var h,f=c(s);!(h=f()).done;)console.error("createHistoryRouter: "+h.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=f({name:"setHistory",sid:"-6zj1hl"}),i=f({name:"routeNotFound",sid:"-ykbdqf"}),d=h({},{name:"$query",sid:"-5882ld"}),m=h('',{name:"$path",sid:"-n8xqik"}),w=h([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"xi9y0h"}),O=h(!1,{name:"$isFirstCheckPassed",sid:"-lmw2f4"}),k=h(null,{and:{serialize:'ignore'},name:"$history",sid:"projjg"});k.on(a,((e,r)=>r));var x=p({and:{source:{history:k},effect:P,mapParams:(e,t)=>r({history:t.history},e)},or:{name:"pushFx",sid:"8ywb72"}}),j=l((e=>{var r=e.params,t=e.query,n=e.replace;return{path:u({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:n?'replace':'push'}}),{name:"openedFx",sid:"qllh6g"}),q=l((e=>{for(var r,t=e.path,o=e.query,a=e.hash,i=[],u=[],d=c(n);!(r=d()).done;){var l=r.value,p=l.path.includes('#')?""+t+a:""+t,h=s({pathCreator:""+l.path,actualPath:p});(h.matches?i:u).push({route:l,params:h.params,query:o})}var f=e=>{var r=e;i.some((e=>e.route.route===u[r].route.route))&&(u[r]=null)};for(var m in u)f(m);return u=u.filter(Boolean),{opened:i,closed:u}}),{name:"recalculateFx",sid:"pmoect"});m.on(q.done,((e,r)=>r.params.path)),d.on(q.done,((e,r)=>r.params.query)),w.on(q.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),y({and:[{clock:j.doneData,target:x}],or:{sid:"-4vu5fj"}}),v({and:[{clock:q.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4e8qfz"}});for(var R,L=q.doneData.map((e=>e.opened)),F=q.doneData.map((e=>e.closed)),S=()=>{var e=R.value,r=h(!1,{name:"$isOpenedManually",sid:"ccm8mt"}),t=e.route.navigate.done;y({and:[{clock:t,fn:r=>{var t=r.params.replace,n=r.result;return{route:e,params:n.params,query:n.query,replace:null!=t&&t}},target:j}],or:{sid:"-3ug519"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},o={opened:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"gsr47l"}}),updated:v({and:[{clock:L.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-h7mvpe"}}),closed:v({and:[{clock:F.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"jb4u8c"}})};r.on(t,(()=>!0));var a=v({and:[{clock:o.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-n23a7"}});y({and:[{source:g(a,null,{name:"source",sid:"g3r8w1"}),clock:v({and:[{clock:a,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!E(e[0],r.params)||!E(t,r.query)}}],or:{name:"clock",sid:"ual9o4"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1ibm90"}}),v({and:[{clock:o.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"9c2b1e"}}),y({and:[{clock:o.closed,target:e.route.closed}],or:{sid:"9fwv6x"}}),r.reset(y({and:[{clock:L}],or:{sid:"ld2dek"}}))},_=c(n);!(R=_()).done;)S();if($(e.notFoundRoute)){var D=y({and:[{clock:w,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"47ytg9"}});y({and:[{clock:D,source:{query:d},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"adgbdy"}}),y({and:[{clock:D,source:{query:d},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"aty56s"}}),y({and:[{clock:D,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"bafyzm"}})}var z,N=p({and:{source:{history:k},effect:(z=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return o=[(n=r.history).location.pathname,Object.fromEntries(new URLSearchParams(n.location.search)),n.location.hash],e.abrupt("return",{path:o[0],query:o[1],hash:o[2]});case 3:case"end":return e.stop()}}),e)}))),function(e){return z.apply(this,arguments)})},or:{name:"recheckFx",sid:"-om9382"}});y({and:[{source:N.doneData,target:q}],or:{sid:"cpku4h"}});var T,A=p({and:{source:{history:k},effect:(T=o(t().mark((function e(r){var n,o;return t().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:n=r.history,o=N;try{o=b(N)}catch(e){}return n.listen((()=>{o()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)}))),function(e){return T.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-gu1w73"}});e.hydrate||y({and:[{clock:A.doneData,target:N}],or:{sid:"o0gl9f"}}),y({and:[{clock:k,target:A}],or:{sid:"o3rcrv"}}),O.on(q.doneData,(()=>!0)).reset(k);var C=y({and:[{clock:v({and:[{clock:O,filter:Boolean}],or:{name:"clock",sid:"-f9ze7m"}}),source:{activeRoutes:w,path:m,query:d}}],or:{name:"initialized",sid:"-khsq3"}});return{$path:m,$query:d,$activeRoutes:w,$history:k,setHistory:a,push:x,routes:n,initialized:C,routeNotFound:i}},S=e=>{var r=e.clock?y({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):f({name:"clock",sid:"-oj7ut5"}),t=_(e.params||{}),n=_(e.query||{});return y({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),r},_=e=>w.store(e,{sid:"gjk14e"})?e:h(e,{sid:"fmgfpp"});export{R as Kind,u as buildPath,d as chainRoute,F as createHistoryRouter,L as createRoute,$ as isRoute,s as matchPath,S as redirect}; | ||
function e(e){void 0===e&&(e={});var r=f((e=>{var r=e.replace;return{params:e.params||{},query:e.query||{},replace:void 0!==r&&r}}),{name:"navigateFx",sid:"bloywh"}),a=y({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"a4yhwl"}}),n=v(!1,{name:"$isOpened",sid:"-9b3vrp"}),t=v({},{name:"$params",sid:"-a8p0s"}),o=v({},{name:"$query",sid:"thjwzy"}),i=g({name:"opened",sid:"ete45t"}),s=g({name:"updated",sid:"5pu5nl"}),d=g({name:"closed",sid:"-wsro1a"});return n.on(i,(()=>!0)).on(d,(()=>!1)),t.on(i,((e,r)=>r.params)).on(s,((e,r)=>r.params)),o.on(i,((e,r)=>r.query)).on(s,((e,r)=>r.query)),O({and:[{source:r.doneData,match:n.map((e=>e?'updated':'opened')),cases:{opened:i,updated:s}}],or:{sid:"3ildw2"}}),{$isOpened:n,$params:t,$query:o,opened:i,updated:s,closed:d,navigate:r,open:a,kind:z.ROUTE,settings:{derived:Boolean(e.filter)}}}function r(e,r){var a=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),a.push.apply(a,n)}return a}function a(e){for(var a=1;a<arguments.length;a++){var t=null!=arguments[a]?arguments[a]:{};a%2?r(Object(t),!0).forEach((r=>{n(e,r,t[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(t)):r(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 t(e,r){(null==r||r>e.length)&&(r=e.length);for(var a=0,n=new Array(r);a<r;a++)n[a]=e[a];return n}function o(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 t(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)?t(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 i(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){var r,a=e.params,n=e.query,t=e.serialize,o=x(e.pathCreator)(a),i=null!==(r=null==t?void 0:t.write(n))&&void 0!==r?r:new URLSearchParams(n);return o+(Object.keys(n).length?"?"+i:'')}function d(e){var r=e.actualPath,a=P(e.pathCreator.replace('://','\\://'))((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 c(e){if(!e)throw new Error('[Routing] No history provided')}function u(e){return e.map((e=>!e))}function l(e){var r=e.base,n=e.routes,t=e.notFoundRoute,c=e.hydrate,l=e.serialize,p=e.controls,m=void 0===p?b({sid:"d2qzob",fn:()=>F(),name:"controls",method:"createRouterControls"}):p,h=((e,r)=>{void 0===r&&(r='');for(var n,t=[],i=()=>{var e,r=n.value;Array.isArray(r.route)?(e=t).push.apply(e,r.route.map((e=>a(a({},r),{},{route:e})))):t.push(r)},s=o(e);!(n=s()).done;)i();t=t.map((e=>a(a({},e),{},{path:""+r+e.path})));for(var d,c=[],u=[],l=o(t);!(d=l()).done;){var p=d.value;p.route.settings.derived?c.push(p):u.push(p)}if(c.length)for(var m,h=o(c);!(m=h()).done;)console.error("createHistoryRouter: "+m.value.path+" uses derived route. This won't work");return u})(n,r),f=g({name:"setHistory",sid:"9zwyxu"}),O=g({name:"navigateFromRouteTriggered",sid:"soge6d"}),w=g({name:"historyUpdated",sid:"-x4474u"}),j=g({name:"recalculateTriggered",sid:"-ykrhlj"}),$=g({name:"recalculated",sid:"aeh4sf"}),R=g({name:"routesMatched",sid:"2rfqt6"}),x=g({name:"routesMismatched",sid:"71hypl"}),P=g({name:"routeNotFound",sid:"avqxzu"}),z=g({name:"initialized",sid:"du6f0f"}),T=v('',{name:"$path",sid:"wz8cwv"}),C=v({},{and:{name:'historyRouter.$query',updateFilter:(e,r)=>!i(e,r)},name:"$query",sid:"tkdilp"}),Q=v([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"9ljm7u"}),H=v(null,{and:{serialize:'ignore'},name:"$history",sid:"g4i7nj"}),I=v(!1,{name:"$isFirstCheckPassed",sid:"9r108x"}),L=v(!1,{name:"$isRouteNavigateInProgress",sid:"a1vtrl"}),N=y({and:{source:H,effect:(e,r)=>U(a({history:e},r))},or:{name:"pushFx",sid:"qm76ov"}}),B=y({and:{source:H,effect:e=>{var r=w;try{r=q(w)}catch(e){console.log(e)}return e.listen((()=>{r()})),!0}},or:{name:"subscribeHistoryFx",sid:"-b12mlt"}}),M=k({and:[{clock:c?[w]:[w,B.done],source:H,filter:Boolean,fn:e=>{var r;return{path:e.location.pathname,query:null!==(r=null==l?void 0:l.read(e.location.search))&&void 0!==r?r:Object.fromEntries(new URLSearchParams(e.location.search))}}}],or:{name:"historyUpdatedParsed",sid:"-qjh22g"}}),_=k({and:[{clock:M,source:{path:T,query:C},filter:(e,r)=>r.path!==e.path||!i(r.query,e.query),fn:(e,r)=>r}],or:{name:"historyUpdateTriggered",sid:"-efx502"}});H.on(f,((e,r)=>r)),k({and:[{clock:H,target:B}],or:{sid:"-pvhmnd"}}),k({and:[{clock:_,source:H,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==l?void 0:l.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:j}],or:{sid:"-psqnok"}});for(var G,J=o(h);!(G=J()).done;){var K=G.value,V=R.filterMap(D(K)),W=x.filterMap(D(K)),X={opened:k({and:[{clock:V,filter:u(K.route.$isOpened)}],or:{name:"opened",sid:"-uhj4hx"}}),updated:k({and:[{clock:V,filter:K.route.$isOpened}],or:{name:"updated",sid:"-1wen4o"}}),closed:k({and:[{clock:W,filter:K.route.$isOpened}],or:{name:"closed",sid:"u8agap"}})};k({and:[{clock:X.updated,source:[K.route.$params,K.route.$query],filter:(e,r)=>{var a=e[1];return!i(e[0],r.params)||!i(a,r.query)},fn:(e,r)=>r,target:K.route.updated}],or:{sid:"-nx3ynf"}}),k({and:[{clock:X.opened,filter:u(L),target:K.route.opened}],or:{sid:"-nfijnv"}}),k({and:[{clock:X.closed,target:K.route.closed}],or:{sid:"-d1mg6b"}})}for(var Y,Z=()=>{var e=Y.value;k({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:O}],or:{sid:"-cl4mdh"}})},ee=o(h);!(Y=ee()).done;)Z();L.on(O,(()=>!0)),k({and:[{clock:O,fn:e=>{var r=e.params,a=e.query,n=e.replace;return{path:s({pathCreator:e.route.path,params:r,query:a,serialize:l}),params:r,query:a,method:n?'replace':'push'}},target:N}],or:{sid:"-bqc56z"}}),L.reset([R,x]),k({and:[{clock:j,fn:e=>{for(var r,a=e.path,n=e.query,t=e.hash,i=[],s=[],c=o(h);!(r=c()).done;){var u=r.value,l=u.path.includes('#')?""+a+t:""+a,p=d({pathCreator:u.path,actualPath:l});(p.matches?i:s).push({routeObj:u,params:p.params,query:n})}return s.forEach(((e,r)=>{i.some((r=>r.routeObj.route===e.routeObj.route))&&s.splice(r,1)})),{matching:i,mismatching:s.filter(Boolean),path:a,query:n}},target:$}],or:{sid:"-aq1q15"}}),T.on(_,((e,r)=>r.path)),C.on(_,((e,r)=>r.query));var re=$.map((e=>e.matching));return k({and:[{clock:re,filter:e=>e.length>0,target:R}],or:{sid:"1m81en"}}),k({and:[{clock:$.map((e=>e.mismatching)),filter:e=>e.length>0,target:x}],or:{sid:"212hfe"}}),Q.on($,((e,r)=>r.matching.map((e=>e.routeObj.route)))),k({and:[{clock:re,filter:e=>0===e.length,target:P}],or:{sid:"2inwey"}}),b({sid:"2lyo2k",fn:()=>S(t),name:"none",method:"isRoute"})&&(k({and:[{clock:P,source:C,filter:t.$isOpened,fn:e=>({query:e,params:{}}),target:t.updated}],or:{sid:"2y252s"}}),k({and:[{clock:P,source:{query:C,isOpened:t.$isOpened},filter:e=>!e.isOpened,fn:e=>({query:e.query,params:{}}),target:t.opened}],or:{sid:"32ghto"}}),k({and:[{clock:re,source:t.$isOpened,filter:(e,r)=>e&&r.length>0,target:t.closed}],or:{sid:"3iej15"}})),k({and:[{clock:m.back,source:H,target:E}],or:{sid:"3ywcs9"}}),k({and:[{clock:m.forward,source:H,target:A}],or:{sid:"4dqst0"}}),k({and:[{clock:C,source:{controlsQuery:m.$query,localQuery:C},filter:e=>!i(e.controlsQuery,e.localQuery),fn:e=>e.localQuery,target:m.$query}],or:{sid:"4hlcyj"}}),k({and:[{clock:m.$query,source:{path:T,localQuery:C,isNavigateInProgress:L,realHistory:H},filter:(e,r)=>{var a,n,t,o=e.localQuery,s=e.isNavigateInProgress,d=e.realHistory,c=null!==(a=null==l?void 0:l.read(null!==(n=null==d?void 0:d.location.search)&&void 0!==n?n:''))&&void 0!==a?a:Object.fromEntries(new URLSearchParams(null!==(t=null==d?void 0:d.location.search)&&void 0!==t?t:''));return s||!i(r,c)||!i(o,r)},fn:(e,r)=>{var a,n=e.path,t=null!==(a=null==l?void 0:l.write(r))&&void 0!==a?a:new URLSearchParams(r);return{path:n+(t?"?"+t:''),params:{},query:r,method:'push'}},target:N}],or:{sid:"4y36rd"}}),k({and:[{clock:$,source:{activeRoutes:Q,path:T,query:C},filter:I.map((e=>!e)),target:z}],or:{sid:"god6gp"}}),I.on(z,(()=>!0)).reset(H),{$path:T,$activeRoutes:Q,$history:H,setHistory:f,$query:C,back:m.back,forward:m.forward,push:N,routes:h,initialized:z,routeNotFound:P}}function p(e){var r=e.clock?k({and:[{clock:e.clock}],or:{name:"clock",sid:"-el7py8"}}):g({name:"clock",sid:"-eknxcv"}),a=m(e.params||{}),n=m(e.query||{});return k({and:[{clock:r,source:{params:a,query:n},fn:(e,r)=>{var a=e.params,n=e.query;return{params:'function'==typeof a?a(r):a,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"a4hol4"}}),r}function m(e){return w.store(e,{sid:"ayqde0"})?e:v(e,{sid:"-f8uw25"})}function h(r){var a=(r=>{var a={};if(b({sid:"-vuorye",fn:()=>S(r),name:"none",method:"isRoute"}))return Object.assign(a,{route:r,chainedRoute:b({sid:"-x3jlk0",fn:()=>e(),name:"chainedRoute",method:"createRoute"}),beforeOpen:g({name:"beforeOpen",sid:"2i9mdy"}),openOn:R([r.opened,r.closed],{name:"openOn",sid:"-n9uh0c"}),cancelOn:R([g({name:"cancelOn",sid:"r6ceph"})],{name:"cancelOn",sid:"r6ce1d"})}),a;var n=r;if(Object.assign(a,{route:n.route,chainedRoute:n.chainedRoute||b({sid:"-if59ok",fn:()=>e(),name:"chainedRoute",method:"createRoute"}),beforeOpen:w.unit(n.beforeOpen)?n.beforeOpen:y({and:n.beforeOpen,or:{name:"beforeOpen",sid:"-xdumjk"}})}),w.effect(a.beforeOpen,{sid:"-qylloz"}))return Object.assign(a,{openOn:n.openOn||a.beforeOpen.doneData,cancelOn:n.cancelOn||a.beforeOpen.failData}),a;var t=r;return Object.assign(a,{openOn:k({and:[{clock:t.openOn}],or:{name:"openOn",sid:"-92mmrn"}}),cancelOn:k({and:[{clock:t.cancelOn||g({name:"clock",sid:"-53qs2n"})}],or:{name:"cancelOn",sid:"-m0jt12"}})}),a})(r),n=a.route,t=a.chainedRoute,o=a.beforeOpen,i=a.openOn,s=a.cancelOn,d=v({},{name:"$params",sid:"ahwukb"}),c=v({},{name:"$query",sid:"-urele3"}),u=j({and:[j({and:[[n.$params,n.$query]],or:{name:"and",sid:"3v6jcf"}}),j({and:[[d,c]],or:{name:"and",sid:"3vqbxs"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"-xzy23v"}}),l=k({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-gtwxmc"}});k({and:[{clock:l,target:o}],or:{sid:"-noxmt5"}}),d.on(l,((e,r)=>r.params)),c.on(l,((e,r)=>r.query));var p=$({and:[{clock:i,source:{params:d,query:c},filter:u}],or:{name:"chainedRouteResolved",sid:"-mwemeb"}});k({and:[{clock:p,target:t.navigate}],or:{sid:"-n6sf88"}});var m=R([n.closed,s],{name:"aborted",sid:"utn0jm"});return d.reset(m),c.reset(m),k({and:[{clock:m,target:t.closed}],or:{sid:"-mqalfe"}}),t}import{createEffect as f,attach as y,createStore as v,createEvent as g,split as O,withFactory as b,scopeBind as q,sample as k,is as w,combine as j,guard as $,merge as R}from'effector';import{compile as x,match as P}from'path-to-regexp';var z={ROUTE:Symbol()},F=()=>({$query:v({},{and:{updateFilter:(e,r)=>!i(r,e)},name:"$query",sid:"z22f3o"}),back:g({name:"back",sid:"lqciue"}),forward:g({name:"forward",sid:"-5dfdts"})}),S=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===z.ROUTE,U=f((e=>(c(e.history),e.history[e.method](e.path,{}),e)),{name:"historyPushFx",sid:"-w0no5y"}),E=f((e=>(c(e),e.back(),e)),{name:"historyBackFx",sid:"-ny8vwp"}),A=f((e=>(c(e),e.forward(),e)),{name:"historyForwardFx",sid:"88oqi4"}),D=e=>r=>{var a=r.find((r=>r.routeObj.route===e.route));if(a)return{params:a.params,query:a.query}};export{z as Kind,s as buildPath,h as chainRoute,l as createHistoryRouter,e as createRoute,F as createRouterControls,S as isRoute,d as matchPath,p as redirect}; | ||
//# sourceMappingURL=atomic-router.esm.js.map |
@@ -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,(function(e,effector){function r(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);r&&(n=n.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,n)}return t}function t(e){for(var t=1;t<arguments.length;t++){var n=null!=arguments[t]?arguments[t]:{};t%2?r(Object(n),!0).forEach((r=>{i(e,r,n[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(n)):r(Object(n)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(n,r))}))}return e}function n(){function e(e,r,t){return Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}),e[r]}function r(e,r,n,o){var i=Object.create((r&&r.prototype instanceof a?r:a).prototype),c=new l(o||[]);return i._invoke=((e,r,n)=>{var a="suspendedStart";return(o,i)=>{if("executing"===a)throw new Error("Generator is already running");if("completed"===a){if("throw"===o)throw i;return h()}for(n.method=o,n.arg=i;;){var c=n.delegate;if(c){var s=u(c,n);if(s){if(s===O)continue;return s}}if("next"===n.method)n.sent=n._sent=n.arg;else if("throw"===n.method){if("suspendedStart"===a)throw a="completed",n.arg;n.dispatchException(n.arg)}else"return"===n.method&&n.abrupt("return",n.arg);a="executing";var d=t(e,r,n);if("normal"===d.type){if(a=n.done?"completed":"suspendedYield",d.arg===O)continue;return{value:d.arg,done:n.done}}"throw"===d.type&&(a="completed",n.method="throw",n.arg=d.arg)}}})(e,n,c),i}function t(e,r,t){try{return{type:"normal",arg:e.call(r,t)}}catch(e){return{type:"throw",arg:e}}}function a(){}function o(){}function i(){}function c(r){["next","throw","return"].forEach((function(t){e(r,t,(function(e){return this._invoke(t,e)}))}))}function s(e,r){function n(a,o,i,c){var s=t(e[a],e,o);if("throw"!==s.type){var u=s.arg,d=u.value;return d&&"object"==typeof d&&y.call(d,"__await")?r.resolve(d.__await).then((e=>{n("next",e,i,c)}),(e=>{n("throw",e,i,c)})):r.resolve(d).then((e=>{u.value=e,i(u)}),(e=>n("throw",e,i,c)))}c(s.arg)}var a;this._invoke=(e,t)=>{function o(){return new r(((r,a)=>{n(e,t,r,a)}))}return a=a?a.then(o,o):o()}}function u(e,r){var n=e.iterator[r.method];if(void 0===n){if(r.delegate=null,"throw"===r.method){if(e.iterator.return&&(r.method="return",r.arg=void 0,u(e,r),"throw"===r.method))return O;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return O}var a=t(n,e.iterator,r.arg);if("throw"===a.type)return r.method="throw",r.arg=a.arg,r.delegate=null,O;var o=a.arg;return o?o.done?(r[e.resultName]=o.value,r.next=e.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,O):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,O)}function d(e){var r={tryLoc:e[0]};1 in e&&(r.catchLoc=e[1]),2 in e&&(r.finallyLoc=e[2],r.afterLoc=e[3]),this.tryEntries.push(r)}function p(e){var r=e.completion||{};r.type="normal",delete r.arg,e.completion=r}function l(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(d,this),this.reset(!0)}function f(e){if(e){var r=e[w];if(r)return r.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var t=-1,n=function r(){for(;++t<e.length;)if(y.call(e,t))return r.value=e[t],r.done=!1,r;return r.value=void 0,r.done=!0,r};return n.next=n}}return{next:h}}function h(){return{value:void 0,done:!0}}n=()=>m;var m={},v=Object.prototype,y=v.hasOwnProperty,g="function"==typeof Symbol?Symbol:{},w=g.iterator||"@@iterator",b=g.asyncIterator||"@@asyncIterator",x=g.toStringTag||"@@toStringTag";try{e({},"")}catch(r){e=(e,r,t)=>e[r]=t}m.wrap=r;var O={},E={};e(E,w,(function(){return this}));var k=Object.getPrototypeOf,R=k&&k(k(f([])));R&&R!==v&&y.call(R,w)&&(E=R);var j=i.prototype=a.prototype=Object.create(E);return o.prototype=i,e(j,"constructor",i),e(i,"constructor",o),o.displayName=e(i,x,"GeneratorFunction"),m.isGeneratorFunction=e=>{var r="function"==typeof e&&e.constructor;return!!r&&(r===o||"GeneratorFunction"===(r.displayName||r.name))},m.mark=r=>(Object.setPrototypeOf?Object.setPrototypeOf(r,i):(r.__proto__=i,e(r,x,"GeneratorFunction")),r.prototype=Object.create(j),r),m.awrap=e=>({__await:e}),c(s.prototype),e(s.prototype,b,(function(){return this})),m.AsyncIterator=s,m.async=(e,t,n,a,o)=>{void 0===o&&(o=Promise);var i=new s(r(e,t,n,a),o);return m.isGeneratorFunction(t)?i:i.next().then((e=>e.done?e.value:i.next()))},c(j),e(j,x,"Generator"),e(j,w,(function(){return this})),e(j,"toString",(()=>"[object Generator]")),m.keys=e=>{var r=[];for(var t in e)r.push(t);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},m.values=f,l.prototype={constructor:l,reset:function(e){if(this.prev=0,this.next=0,this.sent=this._sent=void 0,this.done=!1,this.delegate=null,this.method="next",this.arg=void 0,this.tryEntries.forEach(p),!e)for(var r in this)"t"===r.charAt(0)&&y.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var e=this.tryEntries[0].completion;if("throw"===e.type)throw e.arg;return this.rval},dispatchException:function(e){function r(r,n){return o.type="throw",o.arg=e,t.next=r,n&&(t.method="next",t.arg=void 0),!!n}if(this.done)throw e;for(var t=this,n=this.tryEntries.length-1;n>=0;--n){var a=this.tryEntries[n],o=a.completion;if("root"===a.tryLoc)return r("end");if(a.tryLoc<=this.prev){var i=y.call(a,"catchLoc"),c=y.call(a,"finallyLoc");if(i&&c){if(this.prev<a.catchLoc)return r(a.catchLoc,!0);if(this.prev<a.finallyLoc)return r(a.finallyLoc)}else if(i){if(this.prev<a.catchLoc)return r(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return r(a.finallyLoc)}}}},abrupt:function(e,r){for(var t=this.tryEntries.length-1;t>=0;--t){var n=this.tryEntries[t];if(n.tryLoc<=this.prev&&y.call(n,"finallyLoc")&&this.prev<n.finallyLoc){var a=n;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var o=a?a.completion:{};return o.type=e,o.arg=r,a?(this.method="next",this.next=a.finallyLoc,O):this.complete(o)},complete:function(e,r){if("throw"===e.type)throw e.arg;return"break"===e.type||"continue"===e.type?this.next=e.arg:"return"===e.type?(this.rval=this.arg=e.arg,this.method="return",this.next="end"):"normal"===e.type&&r&&(this.next=r),O},finish:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.finallyLoc===e)return this.complete(t.completion,t.afterLoc),p(t),O}},catch:function(e){for(var r=this.tryEntries.length-1;r>=0;--r){var t=this.tryEntries[r];if(t.tryLoc===e){var n=t.completion;if("throw"===n.type){var a=n.arg;p(t)}return a}}throw new Error("illegal catch attempt")},delegateYield:function(e,r,t){return this.delegate={iterator:f(e),resultName:r,nextLoc:t},"next"===this.method&&(this.arg=void 0),O}},m}function a(e,r,t,n,a,o,i){try{var c=e[o](i),s=c.value}catch(e){return void t(e)}c.done?r(s):Promise.resolve(s).then(n,a)}function o(e){return function(){var r=this,t=arguments;return new Promise(((n,o)=>{function i(e){a(s,n,o,i,c,"next",e)}function c(e){a(s,n,o,i,c,"throw",e)}var s=e.apply(r,t);i(void 0)}))}}function i(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function c(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=new Array(r);t<r;t++)n[t]=e[t];return n}function s(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 c(e,r);var t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?c(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}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 u(e,r){void 0===r&&(r={});for(var t=(e=>{for(var r=[],t=0;t<e.length;){var n=e[t];if("*"!==n&&"+"!==n&&"?"!==n)if("\\"!==n)if("{"!==n)if("}"!==n)if(":"!==n)if("("!==n)r.push({type:"CHAR",index:t,value:e[t++]});else{var a=1,o="";if("?"===e[c=t+1])throw new TypeError("Pattern cannot start with \"?\" at ".concat(c));for(;c<e.length;)if("\\"!==e[c]){if(")"===e[c]){if(0==--a){c++;break}}else if("("===e[c]&&(a++,"?"!==e[c+1]))throw new TypeError("Capturing groups are not allowed at ".concat(c));o+=e[c++]}else o+=e[c++]+e[c++];if(a)throw new TypeError("Unbalanced pattern at ".concat(t));if(!o)throw new TypeError("Missing pattern at ".concat(t));r.push({type:"PATTERN",index:t,value:o}),t=c}else{for(var i="",c=t+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(t));r.push({type:"NAME",index:t,value:i}),t=c}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r})(e),n=r.prefixes,a=void 0===n?"./":n,o="[^".concat(p(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,u="",d=e=>{if(s<t.length&&t[s].type===e)return t[s++].value},l=e=>{var r=d(e);if(void 0!==r)return r;var n=t[s],a=n.index;throw new TypeError("Unexpected ".concat(n.type," at ").concat(a,", expected ").concat(e))},f=()=>{for(var e,r="";e=d("CHAR")||d("ESCAPED_CHAR");)r+=e;return r};s<t.length;){var h=d("CHAR"),m=d("NAME"),v=d("PATTERN");if(m||v)-1===a.indexOf(g=h||"")&&(u+=g,g=""),u&&(i.push(u),u=""),i.push({name:m||c++,prefix:g,suffix:"",pattern:v||o,modifier:d("MODIFIER")||""});else{var y=h||d("ESCAPED_CHAR");if(y)u+=y;else if(u&&(i.push(u),u=""),d("OPEN")){var g=f(),w=d("NAME")||"",b=d("PATTERN")||"",x=f();l("CLOSE"),i.push({name:w||(b?c++:""),pattern:w&&!b?o:b,prefix:g,suffix:x,modifier:d("MODIFIER")||""})}else l("END")}}return i}function d(e,r){var t=[];return((e,r,t)=>{void 0===t&&(t={});var n=t.decode,a=void 0===n?e=>e:n;return t=>{var n=e.exec(t);if(!n)return!1;for(var o=n[0],i=n.index,c=Object.create(null),s=e=>{if(void 0===n[e])return"continue";var t=r[e-1];c[t.name]="*"===t.modifier||"+"===t.modifier?n[e].split(t.prefix+t.suffix).map((e=>a(e,t))):a(n[e],t)},u=1;u<n.length;u++)s(u);return{path:o,index:i,params:c}}})(f(e,t,r),t,r)}function p(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function f(e,r,t){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,n=0,a=t.exec(e.source);a;)r.push({name:a[1]||n++,prefix:"",suffix:"",modifier:"",pattern:""}),a=t.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,t)=>{var n=e.map((e=>f(e,r,t).source));return new RegExp("(?:".concat(n.join("|"),")"),l(t))})(e,r,t):((e,r,t)=>((e,r,t)=>{void 0===t&&(t={});for(var n=t.strict,a=void 0!==n&&n,o=t.start,i=void 0===o||o,c=t.end,s=void 0===c||c,u=t.encode,d=void 0===u?e=>e:u,f=t.delimiter,h=void 0===f?"/#?":f,m=t.endsWith,v="[".concat(p(void 0===m?"":m),"]|$"),y="[".concat(p(h),"]"),g=i?"^":"",w=0,b=e;w<b.length;w++){var x=b[w];if("string"==typeof x)g+=p(d(x));else{var O=p(d(x.prefix)),E=p(d(x.suffix));if(x.pattern)if(r&&r.push(x),O||E)if("+"===x.modifier||"*"===x.modifier){var k="*"===x.modifier?"?":"";g+="(?:".concat(O,"((?:").concat(x.pattern,")(?:").concat(E).concat(O,"(?:").concat(x.pattern,"))*)").concat(E,")").concat(k)}else g+="(?:".concat(O,"(").concat(x.pattern,")").concat(E,")").concat(x.modifier);else g+="+"===x.modifier||"*"===x.modifier?"((?:".concat(x.pattern,")").concat(x.modifier,")"):"(".concat(x.pattern,")").concat(x.modifier);else g+="(?:".concat(O).concat(E,")").concat(x.modifier)}}if(s)a||(g+="".concat(y,"?")),g+=t.endsWith?"(?=".concat(v,")"):"$";else{var R=e[e.length-1],j="string"==typeof R?y.indexOf(R[R.length-1])>-1:void 0===R;a||(g+="(?:".concat(y,"(?=").concat(v,"))?")),j||(g+="(?=".concat(y,"|").concat(v,")"))}return new RegExp(g,l(t))})(u(e,t),r,t))(e,r,t)}function h(e){var r=e.params,t=e.query;return((e,r)=>((e,r)=>{void 0===r&&(r={});var t=l(r),n=r.encode,a=void 0===n?e=>e:n,o=r.validate,i=void 0===o||o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),t)}));return r=>{for(var t="",n=0;n<e.length;n++){var o=e[n];if("string"!=typeof o){var s=r?r[o.name]:void 0,u="?"===o.modifier||"*"===o.modifier,d="*"===o.modifier||"+"===o.modifier;if(Array.isArray(s)){if(!d)throw new TypeError("Expected \"".concat(o.name,"\" to not repeat, but got an array"));if(0===s.length){if(u)continue;throw new TypeError("Expected \"".concat(o.name,"\" to not be empty"))}for(var p=0;p<s.length;p++){var l=a(s[p],o);if(i&&!c[n].test(l))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else if("string"!=typeof s&&"number"!=typeof s){if(!u){var f=d?"an array":"a string";throw new TypeError("Expected \"".concat(o.name,"\" to be ").concat(f))}}else{if(l=a(String(s),o),i&&!c[n].test(l))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(l,"\""));t+=o.prefix+l+o.suffix}}else t+=o}return t}})(u(e,r),r))(e.pathCreator)(r)+(Object.keys(t).length?"?"+new URLSearchParams(t):'')}function m(e){var r=e.actualPath,t=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 t?{matches:!0,params:t.params}:{matches:!1}}var v={ROUTE:Symbol()},y=function(e){void 0===e&&(e={});var r=effector.createEffect(function(){var e=o(n().mark((function e(r){var t;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:r.params||{},query:r.query||{},replace:null!=(t=r.replace)&&t});case 2:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"52jcg"}),t=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{},replace:!1})},or:{name:"openFx",sid:"ds1pqb"}}),a=effector.createStore(!1,{name:"$isOpened",sid:"-iv1wgo"}),i=effector.createStore({},{name:"$params",sid:"-p7a5rj"}),c=effector.createStore({},{name:"$query",sid:"-ft242y"}),s=effector.createEvent({name:"opened",sid:"tqi26x"}),u=effector.createEvent({name:"updated",sid:"2k5mw9"}),d=effector.createEvent({name:"left",sid:"8wd07q"}),p=effector.createEvent({name:"closed",sid:"gobyzc"});return a.on(s,(()=>!0)).on(d,(()=>!1)),i.on(s,((e,r)=>r.params)).on(u,((e,r)=>r.params)),c.on(s,((e,r)=>r.query)).on(u,((e,r)=>r.query)),effector.split({and:[{source:r.doneData,match:a.map((e=>e?'updated':'opened')),cases:{opened:s,updated:u}}],or:{sid:"-vo1lhl"}}),effector.sample({and:[{clock:p,target:d}],or:{sid:"-v7jror"}}),e.filter&&effector.split({and:[{source:effector.sample({and:[{clock:e.filter}],or:{name:"source",sid:"k6fanh"}}),match:e=>e?'true':'false',cases:{true:s,false:p}}],or:{sid:"-us5j0x"}}),{$isOpened:a,$params:i,$query:c,opened:s,updated:u,closed:p,left:d,navigate:r,open:t,kind:v.ROUTE,settings:{derived:Boolean(e.filter)}}},g=(e,r)=>{if(Object.keys(e).length!==Object.keys(r).length)return!1;for(var t in e)if(""+e[t]!=""+r[t])return!1;return!0},w=e=>'object'==typeof e&&null!==e&&'kind'in e&&e.kind===v.ROUTE,b=effector.createEffect((e=>{if(!e.history)throw new Error('[Routing] No history provided');return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"-v3wpyg"}),x=e=>effector.is.store(e,{sid:"gjk14e"})?e:effector.createStore(e,{sid:"fmgfpp"});e.Kind=v,e.buildPath=h,e.chainRoute=e=>{var r=(e=>{if(w(e))return{route:e,chainedRoute:effector.withFactory({sid:"wj2jy7",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"uyxd6d"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-k9cea0"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"-tayd64"})],{name:"cancelOn",sid:"-taydu8"})};var r=t({},e);if(effector.is.unit(r.beforeOpen)||(r.beforeOpen=effector.attach({and:r.beforeOpen,or:{sid:"-gadjdw"}})),effector.is.effect(r.beforeOpen,{sid:"ohaial"}))return{route:r.route,chainedRoute:r.chainedRoute||effector.withFactory({sid:"-cgk8n3",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:r.beforeOpen,openOn:'openOn'in r?r.openOn:r.beforeOpen.doneData,cancelOn:'cancelOn'in r?r.cancelOn:r.beforeOpen.failData};var n=e;return{route:n.route,chainedRoute:n.chainedRoute||effector.withFactory({sid:"rtbqmw",fn:()=>y(),name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-3cnb0m"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"l7ro4p"})}],or:{name:"cancelOn",sid:"-rzf3am"}})}})(e),n=r.route,a=r.chainedRoute,o=r.beforeOpen,i=r.openOn,c=r.cancelOn,s=effector.createStore({},{name:"$params",sid:"-e7xr51"}),u=effector.createStore({},{name:"$query",sid:"-mfs2i3"}),d=effector.combine({and:[effector.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-34jx4h"}}),effector.combine({and:[[s,u]],or:{name:"and",sid:"-3404j4"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"jxulit"}}),p=effector.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"-dd3mvo"}});effector.sample({and:[{clock:p,target:o}],or:{sid:"ggm0br"}}),s.on(p,((e,r)=>r.params)),u.on(p,((e,r)=>r.query));var l=effector.guard({and:[{clock:i,source:{params:s,query:u},filter:d}],or:{name:"chainedRouteResolved",sid:"pkcoe5"}});effector.sample({and:[{clock:l,target:a.navigate}],or:{sid:"gyr7wo"}});var f=effector.merge([n.closed,c],{name:"aborted",sid:"4m2b1e"});return s.reset(f),u.reset(f),effector.sample({and:[{clock:f,target:a.closed}],or:{sid:"hf91pi"}}),a},e.createHistoryRouter=function(e){var r=((e,r)=>{void 0===r&&(r='');for(var n,a=[],o=()=>{var e,r=n.value;Array.isArray(r.route)?(e=a).push.apply(e,r.route.map((e=>t(t({},r),{},{route:e})))):a.push(r)},i=s(e);!(n=i()).done;)o();a=a.map((e=>t(t({},e),{},{path:""+r+e.path})));for(var c,u=[],d=[],p=s(a);!(c=p()).done;){var l=c.value;l.route.settings.derived?u.push(l):d.push(l)}if(u.length)for(var f,h=s(u);!(f=h()).done;)console.error("createHistoryRouter: "+f.value.path+" uses derived route. This won't work");return d})(e.routes,e.base),a=effector.createEvent({name:"setHistory",sid:"-6zj1hl"}),i=effector.createEvent({name:"routeNotFound",sid:"-ykbdqf"}),c=effector.createStore({},{name:"$query",sid:"-5882ld"}),u=effector.createStore('',{name:"$path",sid:"-n8xqik"}),d=effector.createStore([],{and:{serialize:'ignore'},name:"$activeRoutes",sid:"xi9y0h"}),p=effector.createStore(!1,{name:"$isFirstCheckPassed",sid:"-lmw2f4"}),l=effector.createStore(null,{and:{serialize:'ignore'},name:"$history",sid:"projjg"});l.on(a,((e,r)=>r));var f=effector.attach({and:{source:{history:l},effect:b,mapParams:(e,r)=>t({history:r.history},e)},or:{name:"pushFx",sid:"8ywb72"}}),v=effector.createEffect((e=>{var r=e.params,t=e.query,n=e.replace;return{path:h({pathCreator:e.route.path,params:r,query:t}),params:r,query:t,method:n?'replace':'push'}}),{name:"openedFx",sid:"qllh6g"}),y=effector.createEffect((e=>{for(var t,n=e.path,a=e.query,o=e.hash,i=[],c=[],u=s(r);!(t=u()).done;){var d=t.value,p=d.path.includes('#')?""+n+o:""+n,l=m({pathCreator:""+d.path,actualPath:p});(l.matches?i:c).push({route:d,params:l.params,query:a})}var f=e=>{var r=e;i.some((e=>e.route.route===c[r].route.route))&&(c[r]=null)};for(var h in c)f(h);return c=c.filter(Boolean),{opened:i,closed:c}}),{name:"recalculateFx",sid:"pmoect"});u.on(y.done,((e,r)=>r.params.path)),c.on(y.done,((e,r)=>r.params.query)),d.on(y.doneData,((e,r)=>r.opened.map((e=>e.route.route)))),effector.sample({and:[{clock:v.doneData,target:f}],or:{sid:"-4vu5fj"}}),effector.guard({and:[{clock:y.doneData,filter:e=>0===e.opened.length,target:i}],or:{sid:"-4e8qfz"}});for(var x,O=y.doneData.map((e=>e.opened)),E=y.doneData.map((e=>e.closed)),k=()=>{var e=x.value,r=effector.createStore(!1,{name:"$isOpenedManually",sid:"ccm8mt"}),t=e.route.navigate.done;effector.sample({and:[{clock:t,fn:r=>{var t=r.params.replace,n=r.result;return{route:e,params:n.params,query:n.query,replace:null!=t&&t}},target:v}],or:{sid:"-3ug519"}});var n=r=>{var t=r.find((r=>r.route.route===e.route));if(t)return{params:t.params,query:t.query}},a={opened:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened.map((e=>!e))}],or:{name:"opened",sid:"gsr47l"}}),updated:effector.guard({and:[{clock:O.filterMap(n),filter:e.route.$isOpened}],or:{name:"updated",sid:"-h7mvpe"}}),closed:effector.guard({and:[{clock:E.filterMap(n),filter:e.route.$isOpened}],or:{name:"closed",sid:"jb4u8c"}})};r.on(t,(()=>!0));var o=effector.guard({and:[{clock:a.updated,filter:r.map((e=>!e))}],or:{name:"updated",sid:"-n23a7"}});effector.sample({and:[{source:effector.restore(o,null,{name:"source",sid:"g3r8w1"}),clock:effector.guard({and:[{clock:o,source:[e.route.$params,e.route.$query],filter:(e,r)=>{var t=e[1];return!g(e[0],r.params)||!g(t,r.query)}}],or:{name:"clock",sid:"ual9o4"}}),fn:e=>e,target:e.route.updated}],or:{sid:"-1ibm90"}}),effector.guard({and:[{clock:a.opened,filter:r.map((e=>!e)),target:e.route.opened}],or:{sid:"9c2b1e"}}),effector.sample({and:[{clock:a.closed,target:e.route.closed}],or:{sid:"9fwv6x"}}),r.reset(effector.sample({and:[{clock:O}],or:{sid:"ld2dek"}}))},R=s(r);!(x=R()).done;)k();if(w(e.notFoundRoute)){var j=effector.sample({and:[{clock:d,source:e.notFoundRoute.$isOpened,fn:(e,r)=>({isOpened:e,activeRoutesCount:r.length})}],or:{name:"notFoundRouteTriggered",sid:"47ytg9"}});effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>!r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.opened}],or:{sid:"adgbdy"}}),effector.sample({and:[{clock:j,source:{query:c},filter:(e,r)=>r.isOpened&&0===r.activeRoutesCount,fn:e=>({query:e.query,params:{}}),target:e.notFoundRoute.updated}],or:{sid:"aty56s"}}),effector.sample({and:[{clock:j,filter:e=>e.isOpened&&0!==e.activeRoutesCount,target:e.notFoundRoute.closed}],or:{sid:"bafyzm"}})}var q=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:return a=[(t=r.history).location.pathname,Object.fromEntries(new URLSearchParams(t.location.search)),t.location.hash],e.abrupt("return",{path:a[0],query:a[1],hash:a[2]});case 3:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"recheckFx",sid:"-om9382"}});effector.sample({and:[{source:q.doneData,target:y}],or:{sid:"cpku4h"}});var P=effector.attach({and:{source:{history:l},effect:function(){var e=o(n().mark((function e(r){var t,a;return n().wrap((e=>{for(;;)switch(e.prev=e.next){case 0:t=r.history,a=q;try{a=effector.scopeBind(q)}catch(e){}return t.listen((()=>{a()})),e.abrupt("return",!0);case 5:case"end":return e.stop()}}),e)})));return function(r){return e.apply(this,arguments)}}()},or:{name:"subscribeHistoryFx",sid:"-gu1w73"}});e.hydrate||effector.sample({and:[{clock:P.doneData,target:q}],or:{sid:"o0gl9f"}}),effector.sample({and:[{clock:l,target:P}],or:{sid:"o3rcrv"}}),p.on(y.doneData,(()=>!0)).reset(l);var S=effector.sample({and:[{clock:effector.guard({and:[{clock:p,filter:Boolean}],or:{name:"clock",sid:"-f9ze7m"}}),source:{activeRoutes:d,path:u,query:c}}],or:{name:"initialized",sid:"-khsq3"}});return{$path:u,$query:c,$activeRoutes:d,$history:l,setHistory:a,push:f,routes:r,initialized:S,routeNotFound:i}},e.createRoute=y,e.isRoute=w,e.matchPath=m,e.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-ojrnei"}}):effector.createEvent({name:"clock",sid:"-oj7ut5"}),t=x(e.params||{}),n=x(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:n},fn:(e,r)=>{var t=e.params,n=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof n?n(r):n}},target:e.route.navigate}],or:{sid:"g0v0s3"}}),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:"bloywh"}),t=effector.attach({and:{effect:r,mapParams:e=>({params:e||{},query:{}})},or:{name:"openFx",sid:"a4yhwl"}}),a=effector.createStore(!1,{name:"$isOpened",sid:"-9b3vrp"}),n=effector.createStore({},{name:"$params",sid:"-a8p0s"}),o=effector.createStore({},{name:"$query",sid:"thjwzy"}),i=effector.createEvent({name:"opened",sid:"ete45t"}),c=effector.createEvent({name:"updated",sid:"5pu5nl"}),s=effector.createEvent({name:"closed",sid:"-wsro1a"});return a.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:a.map((e=>e?'updated':'opened')),cases:{opened:i,updated:c}}],or:{sid:"3ildw2"}}),{$isOpened:a,$params:n,$query:o,opened:i,updated:c,closed:s,navigate:r,open:t,kind:g.ROUTE,settings:{derived:Boolean(e.filter)}}}function t(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var a=Object.getOwnPropertySymbols(e);r&&(a=a.filter((r=>Object.getOwnPropertyDescriptor(e,r).enumerable))),t.push.apply(t,a)}return t}function a(e){for(var r=1;r<arguments.length;r++){var a=null!=arguments[r]?arguments[r]:{};r%2?t(Object(a),!0).forEach((r=>{n(e,r,a[r])})):Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(a)):t(Object(a)).forEach((r=>{Object.defineProperty(e,r,Object.getOwnPropertyDescriptor(a,r))}))}return e}function n(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function o(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,a=new Array(r);t<r;t++)a[t]=e[t];return a}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 t={}.toString.call(e).slice(8,-1);return"Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t?Array.from(e):"Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t)?o(e,r):void 0}})(e))||r&&e&&"number"==typeof e.length){it&&(e=it);var t=0;return()=>t>=e.length?{done:!0}:{done:!1,value:e[t++]}}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 t in e)if(""+e[t]!=""+r[t])return!1;return!0}function s(e,r){void 0===r&&(r={});for(var t=(e=>{for(var r=[],t=0;t<e.length;){var a=e[t];if("*"!==a&&"+"!==a&&"?"!==a)if("\\"!==a)if("{"!==a)if("}"!==a)if(":"!==a)if("("!==a)r.push({type:"CHAR",index:t,value:e[t++]});else{var n=1,o="";if("?"===e[c=t+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(t));if(!o)throw new TypeError("Missing pattern at ".concat(t));r.push({type:"PATTERN",index:t,value:o}),t=c}else{for(var i="",c=t+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(t));r.push({type:"NAME",index:t,value:i}),t=c}else r.push({type:"CLOSE",index:t,value:e[t++]});else r.push({type:"OPEN",index:t,value:e[t++]});else r.push({type:"ESCAPED_CHAR",index:t++,value:e[t++]});else r.push({type:"MODIFIER",index:t,value:e[t++]})}return r.push({type:"END",index:t,value:""}),r})(e),a=r.prefixes,n=void 0===a?"./":a,o="[^".concat(u(r.delimiter||"/#?"),"]+?"),i=[],c=0,s=0,d="",l=e=>{if(s<t.length&&t[s].type===e)return t[s++].value},p=e=>{var r=l(e);if(void 0!==r)return r;var a=t[s],n=a.index;throw new TypeError("Unexpected ".concat(a.type," at ").concat(n,", expected ").concat(e))},f=()=>{for(var e,r="";e=l("CHAR")||l("ESCAPED_CHAR");)r+=e;return r};s<t.length;){var m=l("CHAR"),h=l("NAME"),v=l("PATTERN");if(h||v)-1===n.indexOf(g=m||"")&&(d+=g,g=""),d&&(i.push(d),d=""),i.push({name:h||c++,prefix:g,suffix:"",pattern:v||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 t=[];return((e,r,t)=>{void 0===t&&(t={});var a=t.decode,n=void 0===a?e=>e:a;return t=>{var a=e.exec(t);if(!a)return!1;for(var o=a[0],i=a.index,c=Object.create(null),s=e=>{if(void 0===a[e])return"continue";var t=r[e-1];c[t.name]="*"===t.modifier||"+"===t.modifier?a[e].split(t.prefix+t.suffix).map((e=>n(e,t))):n(a[e],t)},d=1;d<a.length;d++)s(d);return{path:o,index:i,params:c}}})(p(e,t,r),t,r)}function u(e){return e.replace(/([.+*?=^!:${}()[\]|/\\])/g,"\\$1")}function l(e){return e&&e.sensitive?"":"i"}function p(e,r,t){return e instanceof RegExp?((e,r)=>{if(!r)return e;for(var t=/\((?:\?<(.*?)>)?(?!\?)/g,a=0,n=t.exec(e.source);n;)r.push({name:n[1]||a++,prefix:"",suffix:"",modifier:"",pattern:""}),n=t.exec(e.source);return e})(e,r):Array.isArray(e)?((e,r,t)=>{var a=e.map((e=>p(e,r,t).source));return new RegExp("(?:".concat(a.join("|"),")"),l(t))})(e,r,t):((e,r,t)=>((e,r,t)=>{void 0===t&&(t={});for(var a=t.strict,n=void 0!==a&&a,o=t.start,i=void 0===o||o,c=t.end,s=void 0===c||c,d=t.encode,p=void 0===d?e=>e:d,f=t.delimiter,m=void 0===f?"/#?":f,h=t.endsWith,v="[".concat(u(void 0===h?"":h),"]|$"),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)),x=u(p(w.suffix));if(w.pattern)if(r&&r.push(w),E||x)if("+"===w.modifier||"*"===w.modifier){var q="*"===w.modifier?"?":"";g+="(?:".concat(E,"((?:").concat(w.pattern,")(?:").concat(x).concat(E,"(?:").concat(w.pattern,"))*)").concat(x,")").concat(q)}else g+="(?:".concat(E,"(").concat(w.pattern,")").concat(x,")").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(x,")").concat(w.modifier)}}if(s)n||(g+="".concat(y,"?")),g+=t.endsWith?"(?=".concat(v,")"):"$";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(v,"))?")),R||(g+="(?=".concat(y,"|").concat(v,")"))}return new RegExp(g,l(t))})(s(e,t),r,t))(e,r,t)}function f(e){var r,t=e.params,a=e.query,n=e.serialize,o=((e,r)=>((e,r)=>{void 0===r&&(r={});var t=l(r),a=r.encode,n=void 0===a?e=>e:a,o=r.validate,i=void 0===o||o,c=e.map((e=>{if("object"==typeof e)return new RegExp("^(?:".concat(e.pattern,")$"),t)}));return r=>{for(var t="",a=0;a<e.length;a++){var o=e[a];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[a].test(p))throw new TypeError("Expected all \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));t+=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[a].test(p))throw new TypeError("Expected \"".concat(o.name,"\" to match \"").concat(o.pattern,"\", but got \"").concat(p,"\""));t+=o.prefix+p+o.suffix}}else t+=o}return t}})(s(e,r),r))(e.pathCreator)(t),i=null!==(r=null==n?void 0:n.write(a))&&void 0!==r?r:new URLSearchParams(a);return o+(Object.keys(a).length?"?"+i:'')}function m(e){var r=e.actualPath,t=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 t?{matches:!0,params:t.params}:{matches:!1}}function h(e){if(!e)throw new Error('[Routing] No history provided')}function v(e){return e.map((e=>!e))}function y(e){return effector.is.store(e,{sid:"ayqde0"})?e:effector.createStore(e,{sid:"-f8uw25"})}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=>(h(e.history),e.history[e.method](e.path,{}),e)),{name:"historyPushFx",sid:"-w0no5y"}),E=effector.createEffect((e=>(h(e),e.back(),e)),{name:"historyBackFx",sid:"-ny8vwp"}),x=effector.createEffect((e=>(h(e),e.forward(),e)),{name:"historyForwardFx",sid:"88oqi4"}),q=e=>r=>{var t=r.find((r=>r.routeObj.route===e.route));if(t)return{params:t.params,query:t.query}};e.Kind=g,e.buildPath=f,e.chainRoute=e=>{var t=(e=>{var t={};if(effector.withFactory({sid:"-vuorye",fn:()=>O(e),name:"none",method:"isRoute"}))return Object.assign(t,{route:e,chainedRoute:effector.withFactory({sid:"-x3jlk0",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.createEvent({name:"beforeOpen",sid:"2i9mdy"}),openOn:effector.merge([e.opened,e.closed],{name:"openOn",sid:"-n9uh0c"}),cancelOn:effector.merge([effector.createEvent({name:"cancelOn",sid:"r6ceph"})],{name:"cancelOn",sid:"r6ce1d"})}),t;var a=e;if(Object.assign(t,{route:a.route,chainedRoute:a.chainedRoute||effector.withFactory({sid:"-if59ok",fn:()=>r(),name:"chainedRoute",method:"createRoute"}),beforeOpen:effector.is.unit(a.beforeOpen)?a.beforeOpen:effector.attach({and:a.beforeOpen,or:{name:"beforeOpen",sid:"-xdumjk"}})}),effector.is.effect(t.beforeOpen,{sid:"-qylloz"}))return Object.assign(t,{openOn:a.openOn||t.beforeOpen.doneData,cancelOn:a.cancelOn||t.beforeOpen.failData}),t;var n=e;return Object.assign(t,{openOn:effector.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-92mmrn"}}),cancelOn:effector.sample({and:[{clock:n.cancelOn||effector.createEvent({name:"clock",sid:"-53qs2n"})}],or:{name:"cancelOn",sid:"-m0jt12"}})}),t})(e),a=t.route,n=t.chainedRoute,o=t.beforeOpen,i=t.openOn,c=t.cancelOn,s=effector.createStore({},{name:"$params",sid:"ahwukb"}),d=effector.createStore({},{name:"$query",sid:"-urele3"}),u=effector.combine({and:[effector.combine({and:[[a.$params,a.$query]],or:{name:"and",sid:"3v6jcf"}}),effector.combine({and:[[s,d]],or:{name:"and",sid:"3vqbxs"}}),(e,r)=>e[0]===r[0]&&e[1]===r[1]],or:{name:"$hasSameParams",sid:"-xzy23v"}}),l=effector.sample({and:[{clock:[a.opened,a.updated]}],or:{name:"routeOpened",sid:"-gtwxmc"}});effector.sample({and:[{clock:l,target:o}],or:{sid:"-noxmt5"}}),s.on(l,((e,r)=>r.params)),d.on(l,((e,r)=>r.query));var p=effector.guard({and:[{clock:i,source:{params:s,query:d},filter:u}],or:{name:"chainedRouteResolved",sid:"-mwemeb"}});effector.sample({and:[{clock:p,target:n.navigate}],or:{sid:"-n6sf88"}});var f=effector.merge([a.closed,c],{name:"aborted",sid:"utn0jm"});return s.reset(f),d.reset(f),effector.sample({and:[{clock:f,target:n.closed}],or:{sid:"-mqalfe"}}),n},e.createHistoryRouter=e=>{var r=e.base,t=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 t,n=[],o=()=>{var e,r=t.value;Array.isArray(r.route)?(e=n).push.apply(e,r.route.map((e=>a(a({},r),{},{route:e})))):n.push(r)},c=i(e);!(t=c()).done;)o();n=n.map((e=>a(a({},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})(t,r),p=effector.createEvent({name:"setHistory",sid:"9zwyxu"}),h=effector.createEvent({name:"navigateFromRouteTriggered",sid:"soge6d"}),y=effector.createEvent({name:"historyUpdated",sid:"-x4474u"}),g=effector.createEvent({name:"recalculateTriggered",sid:"-ykrhlj"}),k=effector.createEvent({name:"recalculated",sid:"aeh4sf"}),R=effector.createEvent({name:"routesMatched",sid:"2rfqt6"}),j=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(a({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){console.log(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:"-qjh22g"}}),M=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:"-efx502"}});F.on(p,((e,r)=>r)),effector.sample({and:[{clock:F,target:N}],or:{sid:"-pvhmnd"}}),effector.sample({and:[{clock:M,source:F,filter:Boolean,fn:e=>{var r,t=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:t}},target:g}],or:{sid:"-psqnok"}});for(var H,I=i(l);!(H=I()).done;){var L=H.value,Q=R.filterMap(q(L)),B=j.filterMap(q(L)),_={opened:effector.sample({and:[{clock:Q,filter:v(L.route.$isOpened)}],or:{name:"opened",sid:"-uhj4hx"}}),updated:effector.sample({and:[{clock:Q,filter:L.route.$isOpened}],or:{name:"updated",sid:"-1wen4o"}}),closed:effector.sample({and:[{clock:B,filter:L.route.$isOpened}],or:{name:"closed",sid:"u8agap"}})};effector.sample({and:[{clock:_.updated,source:[L.route.$params,L.route.$query],filter:(e,r)=>{var t=e[1];return!c(e[0],r.params)||!c(t,r.query)},fn:(e,r)=>r,target:L.route.updated}],or:{sid:"-nx3ynf"}}),effector.sample({and:[{clock:_.opened,filter:v(z),target:L.route.opened}],or:{sid:"-nfijnv"}}),effector.sample({and:[{clock:_.closed,target:L.route.closed}],or:{sid:"-d1mg6b"}})}for(var W,K=()=>{var e=W.value;effector.sample({and:[{clock:e.route.navigate.doneData,fn:r=>{var t=r.replace;return{route:e,params:r.params,query:r.query,replace:null!=t&&t}},target:h}],or:{sid:"-cl4mdh"}})},G=i(l);!(W=G()).done;)K();z.on(h,(()=>!0)),effector.sample({and:[{clock:h,fn:e=>{var r=e.params,t=e.query,a=e.replace;return{path:f({pathCreator:e.route.path,params:r,query:t,serialize:s}),params:r,query:t,method:a?'replace':'push'}},target:D}],or:{sid:"-bqc56z"}}),z.reset([R,j]),effector.sample({and:[{clock:g,fn:e=>{for(var r,t=e.path,a=e.query,n=e.hash,o=[],c=[],s=i(l);!(r=s()).done;){var d=r.value,u=d.path.includes('#')?""+t+n:""+t,p=m({pathCreator:d.path,actualPath:u});(p.matches?o:c).push({routeObj:d,params:p.params,query:a})}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:t,query:a}},target:k}],or:{sid:"-aq1q15"}}),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:"1m81en"}}),effector.sample({and:[{clock:k.map((e=>e.mismatching)),filter:e=>e.length>0,target:j}],or:{sid:"212hfe"}}),T.on(k,((e,r)=>r.matching.map((e=>e.routeObj.route)))),effector.sample({and:[{clock:J,filter:e=>0===e.length,target:$}],or:{sid:"2inwey"}}),effector.withFactory({sid:"2lyo2k",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:"2y252s"}}),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:"32ghto"}}),effector.sample({and:[{clock:J,source:n.$isOpened,filter:(e,r)=>e&&r.length>0,target:n.closed}],or:{sid:"3iej15"}})),effector.sample({and:[{clock:u.back,source:F,target:E}],or:{sid:"3ywcs9"}}),effector.sample({and:[{clock:u.forward,source:F,target:x}],or:{sid:"4dqst0"}}),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:"4hlcyj"}}),effector.sample({and:[{clock:u.$query,source:{path:S,localQuery:A,isNavigateInProgress:z,realHistory:F},filter:(e,r)=>{var t,a,n,o=e.localQuery,i=e.isNavigateInProgress,d=e.realHistory,u=null!==(t=null==s?void 0:s.read(null!==(a=null==d?void 0:d.location.search)&&void 0!==a?a:''))&&void 0!==t?t: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 t,a=e.path,n=null!==(t=null==s?void 0:s.write(r))&&void 0!==t?t:new URLSearchParams(r);return{path:a+(n?"?"+n:''),params:{},query:r,method:'push'}},target:D}],or:{sid:"4y36rd"}}),effector.sample({and:[{clock:k,source:{activeRoutes:T,path:S,query:A},filter:C.map((e=>!e)),target:P}],or:{sid:"god6gp"}}),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.redirect=e=>{var r=e.clock?effector.sample({and:[{clock:e.clock}],or:{name:"clock",sid:"-el7py8"}}):effector.createEvent({name:"clock",sid:"-eknxcv"}),t=y(e.params||{}),a=y(e.query||{});return effector.sample({and:[{clock:r,source:{params:t,query:a},fn:(e,r)=>{var t=e.params,a=e.query;return{params:'function'==typeof t?t(r):t,query:'function'==typeof a?a(r):a}},target:e.route.navigate}],or:{sid:"a4hol4"}}),r},Object.defineProperty(e,'__esModule',{value:!0})})); | ||
//# sourceMappingURL=atomic-router.umd.js.map |
{ | ||
"version": "0.6.3", | ||
"version": "0.7.0", | ||
"license": "MIT", | ||
@@ -16,8 +16,9 @@ "main": "dist/atomic-router.cjs.js", | ||
"scripts": { | ||
"test": "jest -i", | ||
"test:watch": "jest --watch -i", | ||
"test": "vitest run", | ||
"test:ui": "vitest --ui", | ||
"test:watch": "vitest --watch", | ||
"build": "rollup -c", | ||
"prepare": "yarn build", | ||
"lint": "yarn prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,md}\"", | ||
"format": "yarn prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,md}\"" | ||
"prepare": "pnpm build", | ||
"lint": "prettier --check \"{src,test}/**/*.{ts,tsx,js,jsx,md}\"", | ||
"format": "prettier --write \"{src,test}/**/*.{ts,tsx,js,jsx,md}\"" | ||
}, | ||
@@ -42,8 +43,11 @@ "peerDependencies": { | ||
"@types/history": "^4.7.11", | ||
"@types/jest": "^27.5.0", | ||
"@vitest/coverage-c8": "^0.23.2", | ||
"@vitest/ui": "^0.23.2", | ||
"c8": "^7.12.0", | ||
"effector": "^22", | ||
"history": "^5.3.0", | ||
"jest": "^28.1.0", | ||
"jest-environment-jsdom": "^28.1.0", | ||
"jsdom": "^20.0.0", | ||
"patronum": "^1.12.2", | ||
"prettier": "^2.7.1", | ||
"query-string": "^7.1.1", | ||
"rollup": "^2.77.2", | ||
@@ -53,5 +57,5 @@ "rollup-plugin-dts": "^4.2.2", | ||
"size-limit": "^8.0.0", | ||
"ts-jest": "^28.0.1", | ||
"tslib": "^2.4.0", | ||
"typescript": "^4.6.3" | ||
"typescript": "^4.6.3", | ||
"vitest": "^0.23.2" | ||
}, | ||
@@ -82,3 +86,4 @@ "dependencies": { | ||
} | ||
] | ||
], | ||
"packageManager": "pnpm@7.9.3" | ||
} |
@@ -15,2 +15,3 @@ # Atomic Router | ||
### Get view-library bindings | ||
- ⚛️ [**React**](https://github.com/atomic-router/react) | ||
@@ -165,3 +166,3 @@ - 🍃 [**Forest**](https://github.com/atomic-router/forest) | ||
route.updated; // Event<{ params: RouteParams, query: RouteQuery }> | ||
route.left; // Event<{ params: RouteParams, query: RouteQuery }> | ||
route.closed; // Event<{ params: RouteParams, query: RouteQuery }> | ||
@@ -168,0 +169,0 @@ // Effects |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
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
224466
173
29
345