atomic-router
Advanced tools
Comparing version 0.5.0-dev.2 to 0.5.0-dev.3
@@ -924,6 +924,12 @@ 'use strict'; | ||
}); | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
var left = effector.createEvent({ | ||
name: "left", | ||
sid: "y03pzp" | ||
sid: "yh5cdw" | ||
}); | ||
var closed = effector.createEvent({ | ||
name: "closed", | ||
sid: "-srzqtm" | ||
}); | ||
$isOpened.on(opened, function () { | ||
@@ -960,5 +966,14 @@ return true; | ||
or: { | ||
sid: "-xjoafa" | ||
sid: "-x710rz" | ||
} | ||
}); | ||
effector.sample({ | ||
and: [{ | ||
clock: closed, | ||
target: left | ||
}], | ||
or: { | ||
sid: "-x2mo13" | ||
} | ||
}); | ||
return { | ||
@@ -1097,5 +1112,5 @@ $isOpened: $isOpened, | ||
} | ||
}); // Triggered whenever some route.open.doneData is triggered | ||
}); // Triggered whenever some route.navigate.doneData is triggered | ||
var enteredFx = effector.createEffect(function (_ref2) { | ||
var openedFx = effector.createEffect(function (_ref2) { | ||
var route = _ref2.route, | ||
@@ -1116,5 +1131,5 @@ params = _ref2.params, | ||
}, { | ||
name: "enteredFx", | ||
sid: "lgiqs5" | ||
}); // Recalculate entered/left routes | ||
name: "openedFx", | ||
sid: "171qv8" | ||
}); // Recalculate opened/closed routes | ||
@@ -1124,4 +1139,4 @@ var recalculateFx = effector.createEffect(function (_ref3) { | ||
query = _ref3.query; | ||
var entered = []; | ||
var left = []; | ||
var opened = []; | ||
var closed = []; | ||
@@ -1138,3 +1153,3 @@ for (var _iterator2 = _createForOfIteratorHelperLoose(remappedRoutes), _step2; !(_step2 = _iterator2()).done;) { | ||
(matches ? entered : left).push({ | ||
(matches ? opened : closed).push({ | ||
route: route, | ||
@@ -1147,4 +1162,4 @@ params: _params, | ||
return { | ||
entered: entered, | ||
left: left | ||
opened: opened, | ||
closed: closed | ||
}; | ||
@@ -1164,4 +1179,4 @@ }, { | ||
$activeRoutes.on(recalculateFx.doneData, function (_prev, _ref6) { | ||
var entered = _ref6.entered; | ||
return entered.map(function (recheckResult) { | ||
var opened = _ref6.opened; | ||
return opened.map(function (recheckResult) { | ||
return recheckResult.route.route; | ||
@@ -1172,3 +1187,3 @@ }); | ||
and: [{ | ||
clock: enteredFx.doneData, | ||
clock: openedFx.doneData, | ||
target: pushFx | ||
@@ -1183,3 +1198,3 @@ }], | ||
// }); | ||
// Trigger 404 if no routes were entered | ||
// Trigger 404 if no routes were opened | ||
@@ -1190,4 +1205,4 @@ effector.guard({ | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
var opened = _ref7.opened; | ||
return opened.length === 0; | ||
}, | ||
@@ -1200,9 +1215,9 @@ target: routeNotFound | ||
}); | ||
var routesEntered = recalculateFx.doneData.map(function (_ref8) { | ||
var entered = _ref8.entered; | ||
return entered; | ||
var routesOpened = recalculateFx.doneData.map(function (_ref8) { | ||
var opened = _ref8.opened; | ||
return opened; | ||
}); | ||
var routesLeft = recalculateFx.doneData.map(function (_ref9) { | ||
var left = _ref9.left; | ||
return left; | ||
var routesClosed = recalculateFx.doneData.map(function (_ref9) { | ||
var closed = _ref9.closed; | ||
return closed; | ||
}); | ||
@@ -1231,3 +1246,3 @@ | ||
}, | ||
target: enteredFx | ||
target: openedFx | ||
}], | ||
@@ -1248,3 +1263,3 @@ or: { | ||
and: [{ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
@@ -1261,3 +1276,3 @@ return !isOpened; | ||
and: [{ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened | ||
@@ -1270,10 +1285,10 @@ }], | ||
}), | ||
left: effector.guard({ | ||
closed: effector.guard({ | ||
and: [{ | ||
clock: routesLeft.filterMap(containsCurrentRoute), | ||
clock: routesClosed.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened | ||
}], | ||
or: { | ||
name: "left", | ||
sid: "53wp7l" | ||
name: "closed", | ||
sid: "2bzoi7" | ||
} | ||
@@ -1311,8 +1326,8 @@ }) | ||
} | ||
}); // Trigger .left() for the routes marked as "left" | ||
}); // Trigger .closed() for the routes marked as "closed" | ||
effector.sample({ | ||
and: [{ | ||
clock: recheckLifecycle.left, | ||
target: routeObj.route.left | ||
clock: recheckLifecycle.closed, | ||
target: routeObj.route.closed | ||
}], | ||
@@ -1326,3 +1341,3 @@ or: { | ||
and: [{ | ||
clock: routesEntered, | ||
clock: routesOpened, | ||
fn: function fn() { | ||
@@ -1329,0 +1344,0 @@ return false; |
@@ -1,2 +0,2 @@ | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("effector"),r=require("path-to-regexp");function e(t,r,e,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function n(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function u(t){e(i,o,a,u,c,"next",t)}function c(t){e(i,o,a,u,c,"throw",t)}u(void 0)}))}}function o(){return(o=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function i(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return a(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,c=(function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new E(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(e.method=o,e.arg=a;;){var i=e.delegate;if(i){var u=x(i,e);if(u){if(u===f)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,a),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function p(){}function l(){}function h(){}var d={};u(d,o,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(L([])));m&&m!==r&&e.call(m,o)&&(d=m);var v=h.prototype=p.prototype=Object.create(d);function g(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function w(t,r){var n;this._invoke=function(o,a){function i(){return new r((function(n,i){!function n(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&e.call(p,"__await")?r.resolve(p.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):r.resolve(p).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function x(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,x(t,r),"throw"===r.method))return f;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return a.next=a}}return{next:j}}function j(){return{value:void 0,done:!0}}return l.prototype=h,u(v,"constructor",h),u(h,"constructor",l),l.displayName=u(h,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===l||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,h):(t.__proto__=h,u(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(r,e,n,o,a){void 0===a&&(a=Promise);var i=new w(c(r,e,n,o),a);return t.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(v),u(v,i,"Generator"),u(v,o,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,E.prototype={constructor:E,reset:function(t){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(k),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return i.type="throw",i.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=e.call(a,"catchLoc"),c=e.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),f}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:L(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(u={exports:{}}),u.exports);function s(t){var e=t.params,n=t.query;return r.compile(t.pathCreator)(e)+(Object.keys(n).length?"?"+new URLSearchParams(n):"")}function f(t){var e=t.actualPath,n=r.match(t.pathCreator)(new URL("http://_"+e).pathname);return n?{matches:!0,params:n.params}:{matches:!1}}var p=t.createEffect((function(t){if(!t.history)throw new Error("[Routing] No history provided");return t.history[t.method](t.path,{}),t}),{name:"historyPushFx",sid:"sn2691"}),l=function(r){return t.is.store(r,{sid:"mg21g2"})?r:t.createStore(r,{sid:"mg23o5"})};exports.buildPath=s,exports.createHistoryRouter=function(r){var e=function(t){for(var r,e=[],n=function(){var t=r.value;Array.isArray(t.route)?e.push.apply(e,t.route.map((function(r){return o({},t,{route:r})}))):e.push(t)},a=i(t);!(r=a()).done;)n();return e}(r.routes),a=t.createEvent({name:"setHistory",sid:"-d2vpek"}),u=t.createEvent({name:"routeNotFound",sid:"-y4sqp2"}),l=t.createStore({},{name:"$query",sid:"hnxt1l"}),h=t.createStore("",{name:"$path",sid:"-sa8poc"}),d=t.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"62zlkr"}),y=t.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"-7y2vlh"});y.on(a,(function(t,r){return r}));var m=t.attach({and:{source:{history:y},effect:p,mapParams:function(t,r){return o({history:r.history},t)}},or:{name:"pushFx",sid:"e2mlkx"}}),v=t.createEffect((function(t){var r=t.params,e=t.query;return{path:s({pathCreator:t.route.path,params:r,query:e}),params:r,query:e,method:"push"}}),{name:"enteredFx",sid:"lgiqs5"}),g=t.createEffect((function(t){for(var r,n=t.path,o=t.query,a=[],u=[],c=i(e);!(r=c()).done;){var s=r.value,p=f({pathCreator:s.path,actualPath:n});(p.matches?a:u).push({route:s,params:p.params,query:o})}return{entered:a,left:u}}),{name:"recalculateFx",sid:"-8daxxq"});h.on(g.done,(function(t,r){return r.params.path})),l.on(g.done,(function(t,r){return r.params.query})),d.on(g.doneData,(function(t,r){return r.entered.map((function(t){return t.route.route}))})),t.sample({and:[{clock:v.doneData,target:m}],or:{sid:"7csm23"}}),t.guard({and:[{clock:g.doneData,filter:function(t){return 0===t.entered.length},target:u}],or:{sid:"7tafux"}});for(var w,x=g.doneData.map((function(t){return t.entered})),b=g.doneData.map((function(t){return t.left})),k=function(){var r=w.value,e=t.createStore(!1,{name:"$isOpenedManually",sid:"by1u5o"}),n=r.route.navigate.done;t.sample({and:[{clock:n,fn:function(t){var e=t.result;return{route:r,params:e.params,query:e.query}},target:v}],or:{sid:"-jxfhr2"}});var o=function(t){return t.find((function(t){return t.route===r}))},a={opened:t.guard({and:[{clock:x.filterMap(o),filter:r.route.$isOpened.map((function(t){return!t}))}],or:{name:"opened",sid:"-6e1ik"}}),updated:t.guard({and:[{clock:x.filterMap(o),filter:r.route.$isOpened}],or:{name:"updated",sid:"-y6s1fj"}}),left:t.guard({and:[{clock:b.filterMap(o),filter:r.route.$isOpened}],or:{name:"left",sid:"53wp7l"}})};e.on(n,(function(){return!0})),t.guard({and:[{clock:a.updated,filter:e.map((function(t){return!t})),target:r.route.updated}],or:{sid:"-iiuf5u"}}),t.guard({and:[{clock:a.opened,filter:e.map((function(t){return!t})),target:r.route.opened}],or:{sid:"-i3zz53"}}),t.sample({and:[{clock:a.left,target:r.route.left}],or:{sid:"-i0p7kx"}}),t.sample({and:[{clock:x,fn:function(){return!1},target:e}],or:{sid:"-hmek5j"}})},E=i(e);!(w=E()).done;)k();var L,j=t.attach({and:{source:{history:y},effect:(L=n(c.mark((function t(r){var e,n;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[(e=r.history).location.pathname,Object.fromEntries(new URLSearchParams(e.location.search))],t.abrupt("return",{path:n[0],query:n[1]});case 3:case"end":return t.stop()}}),t)}))),function(t){return L.apply(this,arguments)})},or:{name:"recheckFx",sid:"1jttbn"}});t.sample({and:[{source:j.doneData,target:g}],or:{sid:"-glkchs"}});var q,O=t.attach({and:{source:{history:y},effect:(q=n(c.mark((function r(e){var n,o;return c.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.history,o=j;try{o=t.scopeBind(j)}catch(t){}return n.listen((function(){o()})),r.abrupt("return",!0);case 5:case"end":return r.stop()}}),r)}))),function(t){return q.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-2i3j06"}});return r.hydrate||t.sample({and:[{clock:O.doneData,target:j}],or:{sid:"-5b8dwh"}}),t.sample({and:[{clock:y,target:O}],or:{sid:"-58hf14"}}),{$path:h,$query:l,$activeRoutes:d,$history:y,setHistory:a,push:m,routes:e,routeNotFound:u}},exports.createRoute=function(){var r=t.createEffect(function(){var t=n(c.mark((function t(r){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),{name:"navigateFx",sid:"-b6kut4"}),e=t.attach({and:{effect:r,mapParams:function(t){return{params:t||{},query:{}}}},or:{name:"openFx",sid:"7nw98i"}}),o=t.createStore(!1,{name:"$isOpened",sid:"76s23p"}),a=t.createStore({},{name:"$params",sid:"ujtax"}),i=t.createStore({},{name:"$query",sid:"ats7c"}),u=t.createEvent({name:"opened",sid:"-pnrpw4"}),s=t.createEvent({name:"updated",sid:"s4xzki"}),f=t.createEvent({name:"left",sid:"y03pzp"});return o.on(u,(function(){return!0})).on(f,(function(){return!1})),a.on(u,(function(t,r){return r.params})).on(s,(function(t,r){return r.params})),i.on(u,(function(t,r){return r.query})).on(s,(function(t,r){return r.query})),t.split({and:[{source:r.doneData,match:o.map((function(t){return t?"updated":"opened"})),cases:{opened:u,updated:s}}],or:{sid:"-xjoafa"}}),{$isOpened:o,$params:a,$query:i,opened:u,updated:s,left:f,navigate:r,open:e}},exports.matchPath=f,exports.redirect=function(r){var e=l(r.params||{}),n=l(r.query||{});t.sample({and:[{clock:r.clock,source:{params:e,query:n},fn:function(t,r){var e=t.params,n=t.query;return{params:"function"==typeof e?e(r):e,query:"function"==typeof n?n(r):n}},target:r.route.navigate}],or:{sid:"-1j5fr2"}})}; | ||
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var t=require("effector"),r=require("path-to-regexp");function e(t,r,e,n,o,a,i){try{var u=t[a](i),c=u.value}catch(t){return void e(t)}u.done?r(c):Promise.resolve(c).then(n,o)}function n(t){return function(){var r=this,n=arguments;return new Promise((function(o,a){var i=t.apply(r,n);function u(t){e(i,o,a,u,c,"next",t)}function c(t){e(i,o,a,u,c,"throw",t)}u(void 0)}))}}function o(){return(o=Object.assign||function(t){for(var r=1;r<arguments.length;r++){var e=arguments[r];for(var n in e)Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n])}return t}).apply(this,arguments)}function a(t,r){(null==r||r>t.length)&&(r=t.length);for(var e=0,n=new Array(r);e<r;e++)n[e]=t[e];return n}function i(t,r){var e="undefined"!=typeof Symbol&&t[Symbol.iterator]||t["@@iterator"];if(e)return(e=e.call(t)).next.bind(e);if(Array.isArray(t)||(e=function(t,r){if(t){if("string"==typeof t)return a(t,void 0);var e=Object.prototype.toString.call(t).slice(8,-1);return"Object"===e&&t.constructor&&(e=t.constructor.name),"Map"===e||"Set"===e?Array.from(t):"Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e)?a(t,void 0):void 0}}(t))||r&&t&&"number"==typeof t.length){e&&(t=e);var n=0;return function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}}}throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}var u,c=(function(t){var r=function(t){var r=Object.prototype,e=r.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(t,r,e){return Object.defineProperty(t,r,{value:e,enumerable:!0,configurable:!0,writable:!0}),t[r]}try{u({},"")}catch(t){u=function(t,r,e){return t[r]=e}}function c(t,r,e,n){var o=Object.create((r&&r.prototype instanceof p?r:p).prototype),a=new E(n||[]);return o._invoke=function(t,r,e){var n="suspendedStart";return function(o,a){if("executing"===n)throw new Error("Generator is already running");if("completed"===n){if("throw"===o)throw a;return{value:void 0,done:!0}}for(e.method=o,e.arg=a;;){var i=e.delegate;if(i){var u=x(i,e);if(u){if(u===f)continue;return u}}if("next"===e.method)e.sent=e._sent=e.arg;else if("throw"===e.method){if("suspendedStart"===n)throw n="completed",e.arg;e.dispatchException(e.arg)}else"return"===e.method&&e.abrupt("return",e.arg);n="executing";var c=s(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===f)continue;return{value:c.arg,done:e.done}}"throw"===c.type&&(n="completed",e.method="throw",e.arg=c.arg)}}}(t,e,a),o}function s(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var f={};function p(){}function d(){}function l(){}var h={};u(h,o,(function(){return this}));var y=Object.getPrototypeOf,m=y&&y(y(L([])));m&&m!==r&&e.call(m,o)&&(h=m);var v=l.prototype=p.prototype=Object.create(h);function g(t){["next","throw","return"].forEach((function(r){u(t,r,(function(t){return this._invoke(r,t)}))}))}function w(t,r){var n;this._invoke=function(o,a){function i(){return new r((function(n,i){!function n(o,a,i,u){var c=s(t[o],t,a);if("throw"!==c.type){var f=c.arg,p=f.value;return p&&"object"==typeof p&&e.call(p,"__await")?r.resolve(p.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):r.resolve(p).then((function(t){f.value=t,i(f)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function x(t,r){var e=t.iterator[r.method];if(void 0===e){if(r.delegate=null,"throw"===r.method){if(t.iterator.return&&(r.method="return",r.arg=void 0,x(t,r),"throw"===r.method))return f;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return f}var n=s(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,f;var o=n.arg;return o?o.done?(r[t.resultName]=o.value,r.next=t.nextLoc,"return"!==r.method&&(r.method="next",r.arg=void 0),r.delegate=null,f):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,f)}function b(t){var r={tryLoc:t[0]};1 in t&&(r.catchLoc=t[1]),2 in t&&(r.finallyLoc=t[2],r.afterLoc=t[3]),this.tryEntries.push(r)}function k(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function E(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function L(t){if(t){var r=t[o];if(r)return r.call(t);if("function"==typeof t.next)return t;if(!isNaN(t.length)){var n=-1,a=function r(){for(;++n<t.length;)if(e.call(t,n))return r.value=t[n],r.done=!1,r;return r.value=void 0,r.done=!0,r};return a.next=a}}return{next:q}}function q(){return{value:void 0,done:!0}}return d.prototype=l,u(v,"constructor",l),u(l,"constructor",d),d.displayName=u(l,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===d||"GeneratorFunction"===(r.displayName||r.name))},t.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,l):(t.__proto__=l,u(t,i,"GeneratorFunction")),t.prototype=Object.create(v),t},t.awrap=function(t){return{__await:t}},g(w.prototype),u(w.prototype,a,(function(){return this})),t.AsyncIterator=w,t.async=function(r,e,n,o,a){void 0===a&&(a=Promise);var i=new w(c(r,e,n,o),a);return t.isGeneratorFunction(e)?i:i.next().then((function(t){return t.done?t.value:i.next()}))},g(v),u(v,i,"Generator"),u(v,o,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),t.keys=function(t){var r=[];for(var e in t)r.push(e);return r.reverse(),function e(){for(;r.length;){var n=r.pop();if(n in t)return e.value=n,e.done=!1,e}return e.done=!0,e}},t.values=L,E.prototype={constructor:E,reset:function(t){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(k),!t)for(var r in this)"t"===r.charAt(0)&&e.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=void 0)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if("throw"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(e,n){return i.type="throw",i.arg=t,r.next=e,n&&(r.method="next",r.arg=void 0),!!n}for(var o=this.tryEntries.length-1;o>=0;--o){var a=this.tryEntries[o],i=a.completion;if("root"===a.tryLoc)return n("end");if(a.tryLoc<=this.prev){var u=e.call(a,"catchLoc"),c=e.call(a,"finallyLoc");if(u&&c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!c)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(t,r){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&e.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===t||"continue"===t)&&a.tryLoc<=r&&r<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=t,i.arg=r,a?(this.method="next",this.next=a.finallyLoc,f):this.complete(i)},complete:function(t,r){if("throw"===t.type)throw t.arg;return"break"===t.type||"continue"===t.type?this.next=t.arg:"return"===t.type?(this.rval=this.arg=t.arg,this.method="return",this.next="end"):"normal"===t.type&&r&&(this.next=r),f},finish:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.finallyLoc===t)return this.complete(e.completion,e.afterLoc),k(e),f}},catch:function(t){for(var r=this.tryEntries.length-1;r>=0;--r){var e=this.tryEntries[r];if(e.tryLoc===t){var n=e.completion;if("throw"===n.type){var o=n.arg;k(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:L(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),f}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(u={exports:{}}),u.exports);function s(t){var e=t.params,n=t.query;return r.compile(t.pathCreator)(e)+(Object.keys(n).length?"?"+new URLSearchParams(n):"")}function f(t){var e=t.actualPath,n=r.match(t.pathCreator)(new URL("http://_"+e).pathname);return n?{matches:!0,params:n.params}:{matches:!1}}var p=t.createEffect((function(t){if(!t.history)throw new Error("[Routing] No history provided");return t.history[t.method](t.path,{}),t}),{name:"historyPushFx",sid:"sn2691"}),d=function(r){return t.is.store(r,{sid:"mg21g2"})?r:t.createStore(r,{sid:"mg23o5"})};exports.buildPath=s,exports.createHistoryRouter=function(r){var e=function(t){for(var r,e=[],n=function(){var t=r.value;Array.isArray(t.route)?e.push.apply(e,t.route.map((function(r){return o({},t,{route:r})}))):e.push(t)},a=i(t);!(r=a()).done;)n();return e}(r.routes),a=t.createEvent({name:"setHistory",sid:"-d2vpek"}),u=t.createEvent({name:"routeNotFound",sid:"-y4sqp2"}),d=t.createStore({},{name:"$query",sid:"hnxt1l"}),l=t.createStore("",{name:"$path",sid:"-sa8poc"}),h=t.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"62zlkr"}),y=t.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"-7y2vlh"});y.on(a,(function(t,r){return r}));var m=t.attach({and:{source:{history:y},effect:p,mapParams:function(t,r){return o({history:r.history},t)}},or:{name:"pushFx",sid:"e2mlkx"}}),v=t.createEffect((function(t){var r=t.params,e=t.query;return{path:s({pathCreator:t.route.path,params:r,query:e}),params:r,query:e,method:"push"}}),{name:"openedFx",sid:"171qv8"}),g=t.createEffect((function(t){for(var r,n=t.path,o=t.query,a=[],u=[],c=i(e);!(r=c()).done;){var s=r.value,p=f({pathCreator:s.path,actualPath:n});(p.matches?a:u).push({route:s,params:p.params,query:o})}return{opened:a,closed:u}}),{name:"recalculateFx",sid:"-8daxxq"});l.on(g.done,(function(t,r){return r.params.path})),d.on(g.done,(function(t,r){return r.params.query})),h.on(g.doneData,(function(t,r){return r.opened.map((function(t){return t.route.route}))})),t.sample({and:[{clock:v.doneData,target:m}],or:{sid:"7csm23"}}),t.guard({and:[{clock:g.doneData,filter:function(t){return 0===t.opened.length},target:u}],or:{sid:"7tafux"}});for(var w,x=g.doneData.map((function(t){return t.opened})),b=g.doneData.map((function(t){return t.closed})),k=function(){var r=w.value,e=t.createStore(!1,{name:"$isOpenedManually",sid:"by1u5o"}),n=r.route.navigate.done;t.sample({and:[{clock:n,fn:function(t){var e=t.result;return{route:r,params:e.params,query:e.query}},target:v}],or:{sid:"-jxfhr2"}});var o=function(t){return t.find((function(t){return t.route===r}))},a={opened:t.guard({and:[{clock:x.filterMap(o),filter:r.route.$isOpened.map((function(t){return!t}))}],or:{name:"opened",sid:"-6e1ik"}}),updated:t.guard({and:[{clock:x.filterMap(o),filter:r.route.$isOpened}],or:{name:"updated",sid:"-y6s1fj"}}),closed:t.guard({and:[{clock:b.filterMap(o),filter:r.route.$isOpened}],or:{name:"closed",sid:"2bzoi7"}})};e.on(n,(function(){return!0})),t.guard({and:[{clock:a.updated,filter:e.map((function(t){return!t})),target:r.route.updated}],or:{sid:"-iiuf5u"}}),t.guard({and:[{clock:a.opened,filter:e.map((function(t){return!t})),target:r.route.opened}],or:{sid:"-i3zz53"}}),t.sample({and:[{clock:a.closed,target:r.route.closed}],or:{sid:"-i0p7kx"}}),t.sample({and:[{clock:x,fn:function(){return!1},target:e}],or:{sid:"-hmek5j"}})},E=i(e);!(w=E()).done;)k();var L,q=t.attach({and:{source:{history:y},effect:(L=n(c.mark((function t(r){var e,n;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return n=[(e=r.history).location.pathname,Object.fromEntries(new URLSearchParams(e.location.search))],t.abrupt("return",{path:n[0],query:n[1]});case 3:case"end":return t.stop()}}),t)}))),function(t){return L.apply(this,arguments)})},or:{name:"recheckFx",sid:"1jttbn"}});t.sample({and:[{source:q.doneData,target:g}],or:{sid:"-glkchs"}});var j,O=t.attach({and:{source:{history:y},effect:(j=n(c.mark((function r(e){var n,o;return c.wrap((function(r){for(;;)switch(r.prev=r.next){case 0:n=e.history,o=q;try{o=t.scopeBind(q)}catch(t){}return n.listen((function(){o()})),r.abrupt("return",!0);case 5:case"end":return r.stop()}}),r)}))),function(t){return j.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-2i3j06"}});return r.hydrate||t.sample({and:[{clock:O.doneData,target:q}],or:{sid:"-5b8dwh"}}),t.sample({and:[{clock:y,target:O}],or:{sid:"-58hf14"}}),{$path:l,$query:d,$activeRoutes:h,$history:y,setHistory:a,push:m,routes:e,routeNotFound:u}},exports.createRoute=function(){var r=t.createEffect(function(){var t=n(c.mark((function t(r){return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.abrupt("return",{params:r.params||{},query:r.query||{}});case 2:case"end":return t.stop()}}),t)})));return function(r){return t.apply(this,arguments)}}(),{name:"navigateFx",sid:"-b6kut4"}),e=t.attach({and:{effect:r,mapParams:function(t){return{params:t||{},query:{}}}},or:{name:"openFx",sid:"7nw98i"}}),o=t.createStore(!1,{name:"$isOpened",sid:"76s23p"}),a=t.createStore({},{name:"$params",sid:"ujtax"}),i=t.createStore({},{name:"$query",sid:"ats7c"}),u=t.createEvent({name:"opened",sid:"-pnrpw4"}),s=t.createEvent({name:"updated",sid:"s4xzki"}),f=t.createEvent({name:"left",sid:"yh5cdw"}),p=t.createEvent({name:"closed",sid:"-srzqtm"});return o.on(u,(function(){return!0})).on(f,(function(){return!1})),a.on(u,(function(t,r){return r.params})).on(s,(function(t,r){return r.params})),i.on(u,(function(t,r){return r.query})).on(s,(function(t,r){return r.query})),t.split({and:[{source:r.doneData,match:o.map((function(t){return t?"updated":"opened"})),cases:{opened:u,updated:s}}],or:{sid:"-x710rz"}}),t.sample({and:[{clock:p,target:f}],or:{sid:"-x2mo13"}}),{$isOpened:o,$params:a,$query:i,opened:u,updated:s,left:f,navigate:r,open:e}},exports.matchPath=f,exports.redirect=function(r){var e=d(r.params||{}),n=d(r.query||{});t.sample({and:[{clock:r.clock,source:{params:e,query:n},fn:function(t,r){var e=t.params,n=t.query;return{params:"function"==typeof e?e(r):e,query:"function"==typeof n?n(r):n}},target:r.route.navigate}],or:{sid:"-1j5fr2"}})}; | ||
//# sourceMappingURL=atomic-router.cjs.production.min.js.map |
@@ -920,6 +920,12 @@ import { createEffect, attach, createStore, createEvent, split, sample, guard, scopeBind, is } from 'effector'; | ||
}); | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
var left = createEvent({ | ||
name: "left", | ||
sid: "y03pzp" | ||
sid: "yh5cdw" | ||
}); | ||
var closed = createEvent({ | ||
name: "closed", | ||
sid: "-srzqtm" | ||
}); | ||
$isOpened.on(opened, function () { | ||
@@ -956,5 +962,14 @@ return true; | ||
or: { | ||
sid: "-xjoafa" | ||
sid: "-x710rz" | ||
} | ||
}); | ||
sample({ | ||
and: [{ | ||
clock: closed, | ||
target: left | ||
}], | ||
or: { | ||
sid: "-x2mo13" | ||
} | ||
}); | ||
return { | ||
@@ -1093,5 +1108,5 @@ $isOpened: $isOpened, | ||
} | ||
}); // Triggered whenever some route.open.doneData is triggered | ||
}); // Triggered whenever some route.navigate.doneData is triggered | ||
var enteredFx = createEffect(function (_ref2) { | ||
var openedFx = createEffect(function (_ref2) { | ||
var route = _ref2.route, | ||
@@ -1112,5 +1127,5 @@ params = _ref2.params, | ||
}, { | ||
name: "enteredFx", | ||
sid: "lgiqs5" | ||
}); // Recalculate entered/left routes | ||
name: "openedFx", | ||
sid: "171qv8" | ||
}); // Recalculate opened/closed routes | ||
@@ -1120,4 +1135,4 @@ var recalculateFx = createEffect(function (_ref3) { | ||
query = _ref3.query; | ||
var entered = []; | ||
var left = []; | ||
var opened = []; | ||
var closed = []; | ||
@@ -1134,3 +1149,3 @@ for (var _iterator2 = _createForOfIteratorHelperLoose(remappedRoutes), _step2; !(_step2 = _iterator2()).done;) { | ||
(matches ? entered : left).push({ | ||
(matches ? opened : closed).push({ | ||
route: route, | ||
@@ -1143,4 +1158,4 @@ params: _params, | ||
return { | ||
entered: entered, | ||
left: left | ||
opened: opened, | ||
closed: closed | ||
}; | ||
@@ -1160,4 +1175,4 @@ }, { | ||
$activeRoutes.on(recalculateFx.doneData, function (_prev, _ref6) { | ||
var entered = _ref6.entered; | ||
return entered.map(function (recheckResult) { | ||
var opened = _ref6.opened; | ||
return opened.map(function (recheckResult) { | ||
return recheckResult.route.route; | ||
@@ -1168,3 +1183,3 @@ }); | ||
and: [{ | ||
clock: enteredFx.doneData, | ||
clock: openedFx.doneData, | ||
target: pushFx | ||
@@ -1179,3 +1194,3 @@ }], | ||
// }); | ||
// Trigger 404 if no routes were entered | ||
// Trigger 404 if no routes were opened | ||
@@ -1186,4 +1201,4 @@ guard({ | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
var opened = _ref7.opened; | ||
return opened.length === 0; | ||
}, | ||
@@ -1196,9 +1211,9 @@ target: routeNotFound | ||
}); | ||
var routesEntered = recalculateFx.doneData.map(function (_ref8) { | ||
var entered = _ref8.entered; | ||
return entered; | ||
var routesOpened = recalculateFx.doneData.map(function (_ref8) { | ||
var opened = _ref8.opened; | ||
return opened; | ||
}); | ||
var routesLeft = recalculateFx.doneData.map(function (_ref9) { | ||
var left = _ref9.left; | ||
return left; | ||
var routesClosed = recalculateFx.doneData.map(function (_ref9) { | ||
var closed = _ref9.closed; | ||
return closed; | ||
}); | ||
@@ -1227,3 +1242,3 @@ | ||
}, | ||
target: enteredFx | ||
target: openedFx | ||
}], | ||
@@ -1244,3 +1259,3 @@ or: { | ||
and: [{ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
@@ -1257,3 +1272,3 @@ return !isOpened; | ||
and: [{ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened | ||
@@ -1266,10 +1281,10 @@ }], | ||
}), | ||
left: guard({ | ||
closed: guard({ | ||
and: [{ | ||
clock: routesLeft.filterMap(containsCurrentRoute), | ||
clock: routesClosed.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened | ||
}], | ||
or: { | ||
name: "left", | ||
sid: "53wp7l" | ||
name: "closed", | ||
sid: "2bzoi7" | ||
} | ||
@@ -1307,8 +1322,8 @@ }) | ||
} | ||
}); // Trigger .left() for the routes marked as "left" | ||
}); // Trigger .closed() for the routes marked as "closed" | ||
sample({ | ||
and: [{ | ||
clock: recheckLifecycle.left, | ||
target: routeObj.route.left | ||
clock: recheckLifecycle.closed, | ||
target: routeObj.route.closed | ||
}], | ||
@@ -1322,3 +1337,3 @@ or: { | ||
and: [{ | ||
clock: routesEntered, | ||
clock: routesOpened, | ||
fn: function fn() { | ||
@@ -1325,0 +1340,0 @@ return false; |
@@ -14,2 +14,4 @@ import { Effect, Event, Store } from 'effector'; | ||
updated: Event<RouteParamsAndQuery<Params>>; | ||
closed: Event<void>; | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
left: Event<void>; | ||
@@ -16,0 +18,0 @@ navigate: Effect<RouteParamsAndQuery<Params>, RouteParamsAndQuery<Params>>; |
{ | ||
"version": "0.5.0-dev.2", | ||
"version": "0.5.0-dev.3", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
@@ -103,4 +103,4 @@ import { buildPath, matchPath } from './build-path'; | ||
// Triggered whenever some route.open.doneData is triggered | ||
const enteredFx = createEffect<EnterParams<any>, PushParams>( | ||
// Triggered whenever some route.navigate.doneData is triggered | ||
const openedFx = createEffect<EnterParams<any>, PushParams>( | ||
({ route, params, query }) => { | ||
@@ -121,3 +121,3 @@ const path = buildPath({ | ||
// Recalculate entered/left routes | ||
// Recalculate opened/closed routes | ||
const recalculateFx = createEffect< | ||
@@ -129,8 +129,8 @@ { | ||
{ | ||
entered: RecheckResult<any>[]; | ||
left: RecheckResult<any>[]; | ||
opened: RecheckResult<any>[]; | ||
closed: RecheckResult<any>[]; | ||
} | ||
>(({ path, query }) => { | ||
const entered = [] as RecheckResult<any>[]; | ||
const left = [] as RecheckResult<any>[]; | ||
const opened = [] as RecheckResult<any>[]; | ||
const closed = [] as RecheckResult<any>[]; | ||
@@ -142,3 +142,3 @@ for (const route of remappedRoutes) { | ||
}); | ||
(matches ? entered : left).push({ | ||
(matches ? opened : closed).push({ | ||
route, | ||
@@ -151,4 +151,4 @@ params, | ||
return { | ||
entered, | ||
left, | ||
opened, | ||
closed, | ||
}; | ||
@@ -161,8 +161,8 @@ }); | ||
$activeRoutes.on(recalculateFx.doneData, (_prev, { entered }) => | ||
entered.map(recheckResult => recheckResult.route.route) | ||
$activeRoutes.on(recalculateFx.doneData, (_prev, { opened }) => | ||
opened.map(recheckResult => recheckResult.route.route) | ||
); | ||
sample({ | ||
clock: enteredFx.doneData, | ||
clock: openedFx.doneData, | ||
target: pushFx, | ||
@@ -176,11 +176,11 @@ }); | ||
// Trigger 404 if no routes were entered | ||
// Trigger 404 if no routes were opened | ||
guard({ | ||
clock: recalculateFx.doneData, | ||
filter: ({ entered }) => entered.length === 0, | ||
filter: ({ opened }) => opened.length === 0, | ||
target: routeNotFound, | ||
}); | ||
const routesEntered = recalculateFx.doneData.map(({ entered }) => entered); | ||
const routesLeft = recalculateFx.doneData.map(({ left }) => left); | ||
const routesOpened = recalculateFx.doneData.map(({ opened }) => opened); | ||
const routesClosed = recalculateFx.doneData.map(({ closed }) => closed); | ||
@@ -200,3 +200,3 @@ for (const routeObj of remappedRoutes) { | ||
}), | ||
target: enteredFx, | ||
target: openedFx, | ||
}); | ||
@@ -212,11 +212,11 @@ | ||
opened: guard({ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened.map(isOpened => !isOpened), | ||
}), | ||
updated: guard({ | ||
clock: routesEntered.filterMap(containsCurrentRoute), | ||
clock: routesOpened.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened, | ||
}), | ||
left: guard({ | ||
clock: routesLeft.filterMap(containsCurrentRoute), | ||
closed: guard({ | ||
clock: routesClosed.filterMap(containsCurrentRoute), | ||
filter: routeObj.route.$isOpened, | ||
@@ -243,6 +243,6 @@ }), | ||
// Trigger .left() for the routes marked as "left" | ||
// Trigger .closed() for the routes marked as "closed" | ||
sample({ | ||
clock: recheckLifecycle.left, | ||
target: routeObj.route.left, | ||
clock: recheckLifecycle.closed, | ||
target: routeObj.route.closed, | ||
}); | ||
@@ -252,3 +252,3 @@ | ||
sample({ | ||
clock: routesEntered, | ||
clock: routesOpened, | ||
fn: () => false, | ||
@@ -255,0 +255,0 @@ target: $isOpenedManually, |
@@ -6,2 +6,3 @@ import { | ||
createStore, | ||
sample, | ||
split, | ||
@@ -40,3 +41,5 @@ } from 'effector'; | ||
const updated = createEvent<RouteParamsAndQuery<Params>>(); | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
const left = createEvent<void>(); | ||
const closed = createEvent<void>(); | ||
@@ -62,2 +65,7 @@ $isOpened.on(opened, () => true).on(left, () => false); | ||
sample({ | ||
clock: closed, | ||
target: left, | ||
}); | ||
return { | ||
@@ -64,0 +72,0 @@ $isOpened, |
@@ -18,2 +18,4 @@ import { Effect, Event, Store } from 'effector'; | ||
updated: Event<RouteParamsAndQuery<Params>>; | ||
closed: Event<void>; | ||
/** @deprecated Will be removed in 0.6.0. Use `route.closed` instead */ | ||
left: Event<void>; | ||
@@ -20,0 +22,0 @@ navigate: Effect<RouteParamsAndQuery<Params>, RouteParamsAndQuery<Params>>; |
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
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
317068
3228