Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

atomic-router

Package Overview
Dependencies
Maintainers
1
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

atomic-router - npm Package Compare versions

Comparing version 0.5.0-dev.1 to 0.5.0-dev.2

180

dist/atomic-router.cjs.development.js

@@ -901,3 +901,3 @@ 'use strict';

name: "openFx",
sid: "68re1x"
sid: "7nw98i"
}

@@ -907,23 +907,23 @@ });

name: "$isOpened",
sid: "5rn6x4"
sid: "76s23p"
});
var $params = effector.createStore({}, {
name: "$params",
sid: "-kl1vo"
sid: "ujtax"
});
var $query = effector.createStore({}, {
name: "$query",
sid: "-14b2z9"
sid: "ats7c"
});
var opened = effector.createEvent({
name: "opened",
sid: "-r2wl2p"
sid: "-pnrpw4"
});
var updated = effector.createEvent({
name: "updated",
sid: "grv23u"
sid: "s4xzki"
});
var left = effector.createEvent({
name: "left",
sid: "mn0sj1"
sid: "y03pzp"
});

@@ -949,9 +949,15 @@ $isOpened.on(opened, function () {

});
effector.sample({
effector.split({
and: [{
clock: navigateFx.doneData,
target: opened
source: navigateFx.doneData,
match: $isOpened.map(function (isOpened) {
return isOpened ? 'updated' : 'opened';
}),
cases: {
opened: opened,
updated: updated
}
}],
or: {
sid: "-xlbo7d"
sid: "-xjoafa"
}

@@ -1057,2 +1063,5 @@ });

var $activeRoutes = effector.createStore([], {
and: {
serialize: 'ignore'
},
name: "$activeRoutes",

@@ -1067,4 +1076,5 @@ sid: "62zlkr"

name: "$history",
sid: "-8w64dv"
}).on(setHistory, function (_, nextHistory) {
sid: "-7y2vlh"
});
$history.on(setHistory, function (_, nextHistory) {
return nextHistory;

@@ -1088,3 +1098,3 @@ }); // historyPushFx for the current history

name: "pushFx",
sid: "cnhqec"
sid: "e2mlkx"
}

@@ -1110,3 +1120,3 @@ }); // Triggered whenever some route.open.doneData is triggered

name: "enteredFx",
sid: "a3ftbh"
sid: "lgiqs5"
}); // Recalculate entered/left routes

@@ -1143,3 +1153,3 @@

name: "recalculateFx",
sid: "-9sft4b"
sid: "-8daxxq"
});

@@ -1166,14 +1176,9 @@ $path.on(recalculateFx.done, function (_prev, _ref4) {

or: {
sid: "7b58a0"
sid: "7csm23"
}
});
effector.sample({
and: [{
clock: pushFx.doneData,
target: recalculateFx
}],
or: {
sid: "7dceng"
}
}); // Trigger 404 if no routes were entered
}); // sample({
// clock: pushFx.doneData,
// target: recalculateFx,
// });
// Trigger 404 if no routes were entered

@@ -1190,3 +1195,3 @@ effector.guard({

or: {
sid: "7rn22u"
sid: "7tafux"
}

@@ -1205,9 +1210,15 @@ });

var routeObj = _step3.value;
// Watch for route.open.doneData to build new path and push
var $isOpenedManually = effector.createStore(false, {
name: "$isOpenedManually",
sid: "by1u5o"
}); // Watch for route.navigate.doneData to build new path and push
var navigatedManually = routeObj.route.navigate.done;
effector.sample({
and: [{
clock: routeObj.route.navigate.doneData,
clock: navigatedManually,
fn: function fn(_ref13) {
var params = _ref13.params,
query = _ref13.query;
var _ref13$result = _ref13.result,
params = _ref13$result.params,
query = _ref13$result.query;
return {

@@ -1222,4 +1233,49 @@ route: routeObj,

or: {
sid: "-k06gpv"
sid: "-jxfhr2"
}
});
var containsCurrentRoute = function containsCurrentRoute(recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
};
var recheckLifecycle = {
opened: effector.guard({
and: [{
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return !isOpened;
})
}],
or: {
name: "opened",
sid: "-6e1ik"
}
}),
updated: effector.guard({
and: [{
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened
}],
or: {
name: "updated",
sid: "-y6s1fj"
}
}),
left: effector.guard({
and: [{
clock: routesLeft.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened
}],
or: {
name: "left",
sid: "53wp7l"
}
})
}; // This is needed to skip extra opened/udpated calls from the route itself
$isOpenedManually.on(navigatedManually, function () {
return true;
}); // Trigger .updated() for already opened routes marked as "opened"

@@ -1229,14 +1285,10 @@

and: [{
clock: routesEntered.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
clock: recheckLifecycle.updated,
filter: $isOpenedManually.map(function (isOpenedManually) {
return !isOpenedManually;
}),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return isOpened;
}),
target: routeObj.route.updated
}],
or: {
sid: "-jj4ubo"
sid: "-iiuf5u"
}

@@ -1247,30 +1299,34 @@ }); // Trigger .opened() for the routes marked as "opened"

and: [{
clock: routesEntered.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
clock: recheckLifecycle.opened,
filter: $isOpenedManually.map(function (isOpenedManually) {
return !isOpenedManually;
}),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return !isOpened;
}),
target: routeObj.route.opened
}],
or: {
sid: "-j36t47"
sid: "-i3zz53"
}
}); // Trigger .left() for the routes marked as "left"
effector.guard({
effector.sample({
and: [{
clock: routesLeft.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
}),
filter: routeObj.route.$isOpened,
clock: recheckLifecycle.left,
target: routeObj.route.left
}],
or: {
sid: "-iysgdb"
sid: "-i0p7kx"
}
}); // Reset $isOpenedManually
effector.sample({
and: [{
clock: routesEntered,
fn: function fn() {
return false;
},
target: $isOpenedManually
}],
or: {
sid: "-hmek5j"
}
});

@@ -1323,3 +1379,3 @@ };

name: "recheckFx",
sid: "vv2de1"
sid: "1jttbn"
}

@@ -1333,3 +1389,3 @@ });

or: {
sid: "-hlaz29"
sid: "-glkchs"
}

@@ -1380,3 +1436,3 @@ }); // Triggered whenever history instance is set

name: "subscribeHistoryFx",
sid: "-xa0ymt"
sid: "-2i3j06"
}

@@ -1393,3 +1449,3 @@ }); // If `hydrate` flag is set,

or: {
sid: "-g8x2r1"
sid: "-5b8dwh"
}

@@ -1405,3 +1461,3 @@ });

or: {
sid: "-g663vo"
sid: "-58hf14"
}

@@ -1408,0 +1464,0 @@ });

@@ -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 L(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 h(){}function l(){}var d={};u(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(k([])));v&&v!==r&&e.call(v,o)&&(d=v);var m=l.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 E(t){var r=t.completion||{};r.type="normal",delete r.arg,t.completion=r}function L(t){this.tryEntries=[{tryLoc:"root"}],t.forEach(b,this),this.reset(!0)}function k(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 h.prototype=l,u(m,"constructor",l),u(l,"constructor",h),h.displayName=u(l,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===h||"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(m),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(m),u(m,i,"Generator"),u(m,o,(function(){return this})),u(m,"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=k,L.prototype={constructor:L,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(E),!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),E(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;E(e)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(t,r,e){return this.delegate={iterator:k(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"}),h=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"}),h=t.createStore({},{name:"$query",sid:"hnxt1l"}),l=t.createStore("",{name:"$path",sid:"-sa8poc"}),d=t.createStore([],{name:"$activeRoutes",sid:"62zlkr"}),y=t.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"-8w64dv"}).on(a,(function(t,r){return r})),v=t.attach({and:{source:{history:y},effect:p,mapParams:function(t,r){return o({history:r.history},t)}},or:{name:"pushFx",sid:"cnhqec"}}),m=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:"a3ftbh"}),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:"-9sft4b"});l.on(g.done,(function(t,r){return r.params.path})),h.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:m.doneData,target:v}],or:{sid:"7b58a0"}}),t.sample({and:[{clock:v.doneData,target:g}],or:{sid:"7dceng"}}),t.guard({and:[{clock:g.doneData,filter:function(t){return 0===t.entered.length},target:u}],or:{sid:"7rn22u"}});for(var w,x=g.doneData.map((function(t){return t.entered})),b=g.doneData.map((function(t){return t.left})),E=function(){var r=w.value;t.sample({and:[{clock:r.route.navigate.doneData,fn:function(t){return{route:r,params:t.params,query:t.query}},target:m}],or:{sid:"-k06gpv"}}),t.guard({and:[{clock:x.filterMap((function(t){return t.find((function(t){return t.route===r}))})),filter:r.route.$isOpened.map((function(t){return t})),target:r.route.updated}],or:{sid:"-jj4ubo"}}),t.guard({and:[{clock:x.filterMap((function(t){return t.find((function(t){return t.route===r}))})),filter:r.route.$isOpened.map((function(t){return!t})),target:r.route.opened}],or:{sid:"-j36t47"}}),t.guard({and:[{clock:b.filterMap((function(t){return t.find((function(t){return t.route===r}))})),filter:r.route.$isOpened,target:r.route.left}],or:{sid:"-iysgdb"}})},L=i(e);!(w=L()).done;)E();var k,q=t.attach({and:{source:{history:y},effect:(k=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 k.apply(this,arguments)})},or:{name:"recheckFx",sid:"vv2de1"}});t.sample({and:[{source:q.doneData,target:g}],or:{sid:"-hlaz29"}});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:"-xa0ymt"}});return r.hydrate||t.sample({and:[{clock:O.doneData,target:q}],or:{sid:"-g8x2r1"}}),t.sample({and:[{clock:y,target:O}],or:{sid:"-g663vo"}}),{$path:l,$query:h,$activeRoutes:d,$history:y,setHistory:a,push:v,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:"68re1x"}}),o=t.createStore(!1,{name:"$isOpened",sid:"5rn6x4"}),a=t.createStore({},{name:"$params",sid:"-kl1vo"}),i=t.createStore({},{name:"$query",sid:"-14b2z9"}),u=t.createEvent({name:"opened",sid:"-r2wl2p"}),s=t.createEvent({name:"updated",sid:"grv23u"}),f=t.createEvent({name:"left",sid:"mn0sj1"});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.sample({and:[{clock:r.doneData,target:u}],or:{sid:"-xlbo7d"}}),{$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=h(r.params||{}),n=h(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 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"}})};
//# sourceMappingURL=atomic-router.cjs.production.min.js.map

@@ -1,2 +0,2 @@

import { createEffect, attach, createStore, createEvent, sample, guard, scopeBind, is } from 'effector';
import { createEffect, attach, createStore, createEvent, split, sample, guard, scopeBind, is } from 'effector';
import { compile, match } from 'path-to-regexp';

@@ -897,3 +897,3 @@

name: "openFx",
sid: "68re1x"
sid: "7nw98i"
}

@@ -903,23 +903,23 @@ });

name: "$isOpened",
sid: "5rn6x4"
sid: "76s23p"
});
var $params = createStore({}, {
name: "$params",
sid: "-kl1vo"
sid: "ujtax"
});
var $query = createStore({}, {
name: "$query",
sid: "-14b2z9"
sid: "ats7c"
});
var opened = createEvent({
name: "opened",
sid: "-r2wl2p"
sid: "-pnrpw4"
});
var updated = createEvent({
name: "updated",
sid: "grv23u"
sid: "s4xzki"
});
var left = createEvent({
name: "left",
sid: "mn0sj1"
sid: "y03pzp"
});

@@ -945,9 +945,15 @@ $isOpened.on(opened, function () {

});
sample({
split({
and: [{
clock: navigateFx.doneData,
target: opened
source: navigateFx.doneData,
match: $isOpened.map(function (isOpened) {
return isOpened ? 'updated' : 'opened';
}),
cases: {
opened: opened,
updated: updated
}
}],
or: {
sid: "-xlbo7d"
sid: "-xjoafa"
}

@@ -1053,2 +1059,5 @@ });

var $activeRoutes = createStore([], {
and: {
serialize: 'ignore'
},
name: "$activeRoutes",

@@ -1063,4 +1072,5 @@ sid: "62zlkr"

name: "$history",
sid: "-8w64dv"
}).on(setHistory, function (_, nextHistory) {
sid: "-7y2vlh"
});
$history.on(setHistory, function (_, nextHistory) {
return nextHistory;

@@ -1084,3 +1094,3 @@ }); // historyPushFx for the current history

name: "pushFx",
sid: "cnhqec"
sid: "e2mlkx"
}

@@ -1106,3 +1116,3 @@ }); // Triggered whenever some route.open.doneData is triggered

name: "enteredFx",
sid: "a3ftbh"
sid: "lgiqs5"
}); // Recalculate entered/left routes

@@ -1139,3 +1149,3 @@

name: "recalculateFx",
sid: "-9sft4b"
sid: "-8daxxq"
});

@@ -1162,14 +1172,9 @@ $path.on(recalculateFx.done, function (_prev, _ref4) {

or: {
sid: "7b58a0"
sid: "7csm23"
}
});
sample({
and: [{
clock: pushFx.doneData,
target: recalculateFx
}],
or: {
sid: "7dceng"
}
}); // Trigger 404 if no routes were entered
}); // sample({
// clock: pushFx.doneData,
// target: recalculateFx,
// });
// Trigger 404 if no routes were entered

@@ -1186,3 +1191,3 @@ guard({

or: {
sid: "7rn22u"
sid: "7tafux"
}

@@ -1201,9 +1206,15 @@ });

var routeObj = _step3.value;
// Watch for route.open.doneData to build new path and push
var $isOpenedManually = createStore(false, {
name: "$isOpenedManually",
sid: "by1u5o"
}); // Watch for route.navigate.doneData to build new path and push
var navigatedManually = routeObj.route.navigate.done;
sample({
and: [{
clock: routeObj.route.navigate.doneData,
clock: navigatedManually,
fn: function fn(_ref13) {
var params = _ref13.params,
query = _ref13.query;
var _ref13$result = _ref13.result,
params = _ref13$result.params,
query = _ref13$result.query;
return {

@@ -1218,4 +1229,49 @@ route: routeObj,

or: {
sid: "-k06gpv"
sid: "-jxfhr2"
}
});
var containsCurrentRoute = function containsCurrentRoute(recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
};
var recheckLifecycle = {
opened: guard({
and: [{
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return !isOpened;
})
}],
or: {
name: "opened",
sid: "-6e1ik"
}
}),
updated: guard({
and: [{
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened
}],
or: {
name: "updated",
sid: "-y6s1fj"
}
}),
left: guard({
and: [{
clock: routesLeft.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened
}],
or: {
name: "left",
sid: "53wp7l"
}
})
}; // This is needed to skip extra opened/udpated calls from the route itself
$isOpenedManually.on(navigatedManually, function () {
return true;
}); // Trigger .updated() for already opened routes marked as "opened"

@@ -1225,14 +1281,10 @@

and: [{
clock: routesEntered.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
clock: recheckLifecycle.updated,
filter: $isOpenedManually.map(function (isOpenedManually) {
return !isOpenedManually;
}),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return isOpened;
}),
target: routeObj.route.updated
}],
or: {
sid: "-jj4ubo"
sid: "-iiuf5u"
}

@@ -1243,30 +1295,34 @@ }); // Trigger .opened() for the routes marked as "opened"

and: [{
clock: routesEntered.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
clock: recheckLifecycle.opened,
filter: $isOpenedManually.map(function (isOpenedManually) {
return !isOpenedManually;
}),
filter: routeObj.route.$isOpened.map(function (isOpened) {
return !isOpened;
}),
target: routeObj.route.opened
}],
or: {
sid: "-j36t47"
sid: "-i3zz53"
}
}); // Trigger .left() for the routes marked as "left"
guard({
sample({
and: [{
clock: routesLeft.filterMap(function (recheckResults) {
return recheckResults.find(function (recheckResult) {
return recheckResult.route === routeObj;
});
}),
filter: routeObj.route.$isOpened,
clock: recheckLifecycle.left,
target: routeObj.route.left
}],
or: {
sid: "-iysgdb"
sid: "-i0p7kx"
}
}); // Reset $isOpenedManually
sample({
and: [{
clock: routesEntered,
fn: function fn() {
return false;
},
target: $isOpenedManually
}],
or: {
sid: "-hmek5j"
}
});

@@ -1319,3 +1375,3 @@ };

name: "recheckFx",
sid: "vv2de1"
sid: "1jttbn"
}

@@ -1329,3 +1385,3 @@ });

or: {
sid: "-hlaz29"
sid: "-glkchs"
}

@@ -1376,3 +1432,3 @@ }); // Triggered whenever history instance is set

name: "subscribeHistoryFx",
sid: "-xa0ymt"
sid: "-2i3j06"
}

@@ -1389,3 +1445,3 @@ }); // If `hydrate` flag is set,

or: {
sid: "-g8x2r1"
sid: "-5b8dwh"
}

@@ -1401,3 +1457,3 @@ });

or: {
sid: "-g663vo"
sid: "-58hf14"
}

@@ -1404,0 +1460,0 @@ });

{
"version": "0.5.0-dev.1",
"version": "0.5.0-dev.2",
"license": "MIT",

@@ -4,0 +4,0 @@ "main": "dist/index.js",

@@ -17,2 +17,5 @@ # Atomic Router

## View-library bindings
- [React](https://github.com/kelin2025/atomic-router-react)
## Initialization

@@ -22,5 +25,7 @@ Create your routes wherever you want:

// pages/home
import { createRoute } from 'atomic-router'
export const homeRoute = createRoute()
// pages/posts
import { createRoute } from 'atomic-router'
export const postsRoute = createRoute<{ postId: string }>()

@@ -31,2 +36,4 @@ ```

// app/routing
import { createHistoryRouter } from 'atomic-router'
import { createBrowserHistory, createMemoryHistory } from 'history'
import { homeRoute } from '@/pages/home'

@@ -71,2 +78,3 @@ import { postsRoute } from '@/pages/home'

//route.ts
import { createRoute } from 'atomic-router'
import { getPostFx } from './model'

@@ -110,3 +118,3 @@

```tsx
const readMoreRoute = createRoute<{{ postId: id }}>()
const readMoreRoute = createRoute<{ postId: id }>()
```

@@ -128,2 +136,5 @@

```tsx
// Params is an object-type describing query params for your route
const route = createRoute<Params>()
// Stores

@@ -142,2 +153,4 @@ route.$isOpened // Store<boolean>

route.navigate // Effect<{ params: RouteParams, query: RouteQuery }>
// Note: Store, Event and Effect is imported from 'effector' package
```

@@ -78,3 +78,5 @@ import { buildPath, matchPath } from './build-path';

const $path = createStore('');
const $activeRoutes = createStore<RouteInstance<any>[]>([]);
const $activeRoutes = createStore<RouteInstance<any>[]>([], {
serialize: 'ignore',
});

@@ -84,4 +86,6 @@ // @ts-expect-error

serialize: 'ignore',
}).on(setHistory, (_, nextHistory) => nextHistory);
});
$history.on(setHistory, (_, nextHistory) => nextHistory);
// historyPushFx for the current history

@@ -163,6 +167,6 @@ const pushFx = attach({

sample({
clock: pushFx.doneData,
target: recalculateFx,
});
// sample({
// clock: pushFx.doneData,
// target: recalculateFx,
// });

@@ -180,6 +184,10 @@ // Trigger 404 if no routes were entered

for (const routeObj of remappedRoutes) {
// Watch for route.open.doneData to build new path and push
const $isOpenedManually = createStore(false);
// Watch for route.navigate.doneData to build new path and push
const navigatedManually = routeObj.route.navigate.done;
sample({
clock: routeObj.route.navigate.doneData,
fn: ({ params, query }) => ({
clock: navigatedManually,
fn: ({ result: { params, query } }) => ({
route: routeObj,

@@ -192,10 +200,30 @@ params,

const containsCurrentRoute = (recheckResults: RecheckResult<any>[]) => {
return recheckResults.find(
recheckResult => recheckResult.route === routeObj
);
};
const recheckLifecycle = {
opened: guard({
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened.map(isOpened => !isOpened),
}),
updated: guard({
clock: routesEntered.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened,
}),
left: guard({
clock: routesLeft.filterMap(containsCurrentRoute),
filter: routeObj.route.$isOpened,
}),
};
// This is needed to skip extra opened/udpated calls from the route itself
$isOpenedManually.on(navigatedManually, () => true);
// Trigger .updated() for already opened routes marked as "opened"
guard({
clock: routesEntered.filterMap(recheckResults => {
return recheckResults.find(
recheckResult => recheckResult.route === routeObj
);
}),
filter: routeObj.route.$isOpened.map(isOpened => isOpened),
clock: recheckLifecycle.updated,
filter: $isOpenedManually.map(isOpenedManually => !isOpenedManually),
target: routeObj.route.updated,

@@ -206,8 +234,4 @@ });

guard({
clock: routesEntered.filterMap(recheckResults => {
return recheckResults.find(
recheckResult => recheckResult.route === routeObj
);
}),
filter: routeObj.route.$isOpened.map(isOpened => !isOpened),
clock: recheckLifecycle.opened,
filter: $isOpenedManually.map(isOpenedManually => !isOpenedManually),
target: routeObj.route.opened,

@@ -217,11 +241,13 @@ });

// Trigger .left() for the routes marked as "left"
guard({
clock: routesLeft.filterMap(recheckResults => {
return recheckResults.find(
recheckResult => recheckResult.route === routeObj
);
}),
filter: routeObj.route.$isOpened,
sample({
clock: recheckLifecycle.left,
target: routeObj.route.left,
});
// Reset $isOpenedManually
sample({
clock: routesEntered,
fn: () => false,
target: $isOpenedManually,
});
}

@@ -228,0 +254,0 @@

@@ -6,3 +6,3 @@ import {

createStore,
sample,
split,
} from 'effector';

@@ -17,8 +17,10 @@ import {

export const createRoute = <Params extends RouteParams>() => {
const navigateFx = createEffect<
RouteParamsAndQuery<Params>,
RouteParamsAndQuery<Params>
>(async ({ params, query }) => {
return { params: params || {}, query: query || {} };
});
const navigateFx = createEffect(
async ({ params, query }: RouteParamsAndQuery<Params>) => {
return {
params: params || {},
query: query || {},
} as RouteParamsAndQuery<Params>;
}
);

@@ -51,5 +53,9 @@ const openFx = attach({

sample({
clock: navigateFx.doneData,
target: opened,
split({
source: navigateFx.doneData,
match: $isOpened.map(isOpened => (isOpened ? 'updated' : 'opened')),
cases: {
opened,
updated,
},
});

@@ -56,0 +62,0 @@

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc