Socket
Socket
Sign inDemoInstall

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.8 to 0.5.0-dev.9

18

dist/atomic-router.cjs.development.js

@@ -1486,5 +1486,13 @@ 'use strict';

var redirect = function redirect(options) {
var clock = options.clock || effector.createEvent({
var clock = options.clock ? effector.sample({
and: [{
clock: options.clock
}],
or: {
name: "clock",
sid: "-nsh945"
}
}) : effector.createEvent({
name: "clock",
sid: "-o9itwn"
sid: "-nbfmpy"
});

@@ -1511,3 +1519,3 @@ var params = toStore(options.params || {});

or: {
sid: "-8lu96o"
sid: "-8kqnzy"
}

@@ -1520,5 +1528,5 @@ });

return effector.is.store(payload, {
sid: "sw2jwt"
sid: "-v906zu"
}) ? payload : effector.createStore(payload, {
sid: "sw2m4w"
sid: "-v904rr"
});

@@ -1525,0 +1533,0 @@ };

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("effector"),t=require("path-to-regexp");function r(e,t,r,n,o,a,i){try{var u=e[a](i),c=u.value}catch(e){return void r(e)}u.done?t(c):Promise.resolve(c).then(n,o)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var i=e.apply(t,n);function u(e){r(i,o,a,u,c,"next",e)}function c(e){r(i,o,a,u,c,"throw",e)}u(void 0)}))}}function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function u(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{u({},"")}catch(e){u=function(e,t,r){return e[t]=r}}function c(e,t,r,n){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),a=new k(n||[]);return o._invoke=function(e,t,r){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(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var u=b(i,r);if(u){if(u===d)continue;return u}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var c=s(e,t,r);if("normal"===c.type){if(n=r.done?"completed":"suspendedYield",c.arg===d)continue;return{value:c.arg,done:r.done}}"throw"===c.type&&(n="completed",r.method="throw",r.arg=c.arg)}}}(e,r,a),o}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=c;var d={};function f(){}function p(){}function l(){}var h={};u(h,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(E([])));y&&y!==t&&r.call(y,o)&&(h=y);var v=l.prototype=f.prototype=Object.create(h);function g(e){["next","throw","return"].forEach((function(t){u(e,t,(function(e){return this._invoke(t,e)}))}))}function w(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,u){var c=s(e[o],e,a);if("throw"!==c.type){var d=c.arg,f=d.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,i,u)}),(function(e){n("throw",e,i,u)})):t.resolve(f).then((function(e){d.value=e,i(d)}),(function(e){return n("throw",e,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,b(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:q}}function q(){return{value:void 0,done:!0}}return p.prototype=l,u(v,"constructor",l),u(l,"constructor",p),p.displayName=u(l,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,u(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},g(w.prototype),u(w.prototype,a,(function(){return this})),e.AsyncIterator=w,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new w(c(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},g(v),u(v,i,"Generator"),u(v,o,(function(){return this})),u(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=E,k.prototype={constructor:k,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(O),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=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){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.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=r.call(a,"catchLoc"),c=r.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(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,t){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&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(u={exports:{}}),u.exports),s={ROUTE:Symbol()},d=function(){var t=e.createEffect(function(){var e=n(c.mark((function e(t){return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:t.params||{},query:t.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-apj8ex"}),r=e.attach({and:{effect:t,mapParams:function(e){return{params:e||{},query:{}}}},or:{name:"openFx",sid:"-ju5g7s"}}),o=e.createStore(!1,{name:"$isOpened",sid:"7ntohw"}),a=e.createStore({},{name:"$params",sid:"1blfp4"}),i=e.createStore({},{name:"$query",sid:"rvelj"}),u=e.createEvent({name:"opened",sid:"-f8s17u"}),d=e.createEvent({name:"updated",sid:"slzlyp"}),f=e.createEvent({name:"left",sid:"yy6ys3"}),p=e.createEvent({name:"closed",sid:"-say4ff"});return o.on(u,(function(){return!0})).on(f,(function(){return!1})),a.on(u,(function(e,t){return t.params})).on(d,(function(e,t){return t.params})),i.on(u,(function(e,t){return t.query})).on(d,(function(e,t){return t.query})),e.split({and:[{source:t.doneData,match:o.map((function(e){return e?"updated":"opened"})),cases:{opened:u,updated:d}}],or:{sid:"-x6h86m"}}),e.sample({and:[{clock:p,target:f}],or:{sid:"-wqj6z5"}}),{$isOpened:o,$params:a,$query:i,opened:u,updated:d,closed:p,left:f,navigate:t,open:r,kind:s.ROUTE}};function f(e){var r=e.params,n=e.query;return t.compile(e.pathCreator)(r)+(Object.keys(n).length?"?"+new URLSearchParams(n):"")}function p(e){var r=e.actualPath,n=t.match(e.pathCreator)(new URL("http://_"+r).pathname);return n?{matches:!0,params:n.params}:{matches:!1}}var l=e.createEffect((function(e){if(!e.history)throw new Error("[Routing] No history provided");return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"sn2691"}),h=function(e){return"object"==typeof e&&null!==e&&"kind"in e&&e.kind===s.ROUTE},m=function(t){return e.is.store(t,{sid:"sw2jwt"})?t:e.createStore(t,{sid:"sw2m4w"})};exports.Kind=s,exports.buildPath=f,exports.chainRoute=function(t){var r=function(t){if(h(t))return{route:t,chainedRoute:e.withFactory({sid:"jogy9l",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:e.createEvent({name:"beforeOpen",sid:"8mpttm"}),openOn:[t.opened,t.closed],cancelOn:[e.createEvent({name:"cancelOn",sid:"ahjdm4"})]};var r=t;if(!("enterOn"in r)&&e.is.effect(r.beforeOpen,{sid:"fx5yhy"}))return{route:r.route,chainedRoute:r.chainedRoute||e.withFactory({sid:"fyulbq",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:r.beforeOpen,openOn:r.beforeOpen.doneData,cancelOn:r.beforeOpen.failData};var n=t;return{route:n.route,chainedRoute:n.chainedRoute||e.withFactory({sid:"u6793u",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:e.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-mm7rdb"}}),cancelOn:e.sample({and:[{clock:n.cancelOn||e.createEvent({name:"clock",sid:"y2etk0"})}],or:{name:"cancelOn",sid:"-vntqxj"}})}}(t),n=r.route,o=r.chainedRoute,a=r.beforeOpen,i=r.openOn,u=r.cancelOn,c=e.createStore({},{name:"$params",sid:"ru233x"}),s=e.createStore({},{name:"$query",sid:"2tnaew"}),f=e.combine({and:[e.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-t8sbqu"}}),e.combine({and:[[c,s]],or:{name:"and",sid:"-t8s8s2"}}),function(e,t){return e[0]===t[0]&&e[1]===t[1]}],or:{name:"$hasSameParams",sid:"-w0fyuc"}}),p=e.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"nobe5z"}});e.sample({and:[{clock:p,target:a}],or:{sid:"n0i9a7"}}),c.on(p,(function(e,t){return t.params})),s.on(p,(function(e,t){return t.query}));var l=e.guard({and:[{clock:i,source:{params:c,query:s},filter:f}],or:{name:"chainedRouteResolved",sid:"-qurk3a"}});e.sample({and:[{clock:l,target:o.navigate}],or:{sid:"ningv4"}});var m=e.merge([n.closed,u],{name:"aborted",sid:"-qm6c6a"});return c.reset(m),s.reset(m),e.sample({and:[{clock:m,target:o.closed}],or:{sid:"nz5any"}}),o},exports.createHistoryRouter=function(t){var r=function(e){for(var t,r=[],n=function(){var e=t.value;Array.isArray(e.route)?r.push.apply(r,e.route.map((function(t){return o({},e,{route:t})}))):r.push(e)},a=i(e);!(t=a()).done;)n();return r}(t.routes),a=e.createEvent({name:"setHistory",sid:"-d2vpek"}),u=e.createEvent({name:"routeNotFound",sid:"-y4sqp2"}),s=e.createStore({},{name:"$query",sid:"hnxt1l"}),d=e.createStore("",{name:"$path",sid:"-sa8poc"}),h=e.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"62zlkr"}),m=e.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"-7y2vlh"});m.on(a,(function(e,t){return t}));var y=e.attach({and:{source:{history:m},effect:l,mapParams:function(e,t){return o({history:t.history},e)}},or:{name:"pushFx",sid:"e2mlkx"}}),v=e.createEffect((function(e){var t=e.params,r=e.query;return{path:f({pathCreator:e.route.path,params:t,query:r}),params:t,query:r,method:"push"}}),{name:"openedFx",sid:"171qv8"}),g=e.createEffect((function(e){for(var t,n=e.path,o=e.query,a=[],u=[],c=i(r);!(t=c()).done;){var s=t.value,d=p({pathCreator:s.path,actualPath:n});(d.matches?a:u).push({route:s,params:d.params,query:o})}return{opened:a,closed:u}}),{name:"recalculateFx",sid:"-8daxxq"});d.on(g.done,(function(e,t){return t.params.path})),s.on(g.done,(function(e,t){return t.params.query})),h.on(g.doneData,(function(e,t){return t.opened.map((function(e){return e.route.route}))})),e.sample({and:[{clock:v.doneData,target:y}],or:{sid:"7csm23"}}),e.guard({and:[{clock:g.doneData,filter:function(e){return 0===e.opened.length},target:u}],or:{sid:"7tafux"}});for(var w,b=g.doneData.map((function(e){return e.opened})),x=g.doneData.map((function(e){return e.closed})),O=function(){var t=w.value,r=e.createStore(!1,{name:"$isOpenedManually",sid:"by1u5o"}),n=t.route.navigate.done;e.sample({and:[{clock:n,fn:function(e){var r=e.result;return{route:t,params:r.params,query:r.query}},target:v}],or:{sid:"-jxfhr2"}});var o=function(e){return e.find((function(e){return e.route===t}))},a={opened:e.guard({and:[{clock:b.filterMap(o),filter:t.route.$isOpened.map((function(e){return!e}))}],or:{name:"opened",sid:"-6e1ik"}}),updated:e.guard({and:[{clock:b.filterMap(o),filter:t.route.$isOpened}],or:{name:"updated",sid:"-y6s1fj"}}),closed:e.guard({and:[{clock:x.filterMap(o),filter:t.route.$isOpened}],or:{name:"closed",sid:"2bzoi7"}})};r.on(n,(function(){return!0})),e.guard({and:[{clock:a.updated,filter:r.map((function(e){return!e})),target:t.route.updated}],or:{sid:"-iiuf5u"}}),e.guard({and:[{clock:a.opened,filter:r.map((function(e){return!e})),target:t.route.opened}],or:{sid:"-i3zz53"}}),e.sample({and:[{clock:a.closed,target:t.route.closed}],or:{sid:"-i0p7kx"}}),r.reset(e.sample({and:[{clock:b}],or:{sid:"lycydm"}}))},k=i(r);!(w=k()).done;)O();var E,q=e.attach({and:{source:{history:m},effect:(E=n(c.mark((function e(t){var r,n;return c.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[(r=t.history).location.pathname,Object.fromEntries(new URLSearchParams(r.location.search))],e.abrupt("return",{path:n[0],query:n[1]});case 3:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)})},or:{name:"recheckFx",sid:"-aaaqj8"}});e.sample({and:[{source:q.doneData,target:g}],or:{sid:"-gnriv8"}});var j,L=e.attach({and:{source:{history:m},effect:(j=n(c.mark((function t(r){var n,o;return c.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=r.history,o=q;try{o=e.scopeBind(q)}catch(e){}return n.listen((function(){o()})),t.abrupt("return",!0);case 5:case"end":return t.stop()}}),t)}))),function(e){return j.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-ec82v1"}});return t.hydrate||e.sample({and:[{clock:L.doneData,target:q}],or:{sid:"-fmxb0l"}}),e.sample({and:[{clock:m,target:L}],or:{sid:"-5aolek"}}),{$path:d,$query:s,$activeRoutes:h,$history:m,setHistory:a,push:y,routes:r,routeNotFound:u}},exports.createRoute=d,exports.isRoute=h,exports.matchPath=p,exports.redirect=function(t){var r=t.clock||e.createEvent({name:"clock",sid:"-o9itwn"}),n=m(t.params||{}),o=m(t.query||{});return e.sample({and:[{clock:r,source:{params:n,query:o},fn:function(e,t){var r=e.params,n=e.query;return{params:"function"==typeof r?r(t):r,query:"function"==typeof n?n(t):n}},target:t.route.navigate}],or:{sid:"-8lu96o"}}),r};
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("effector"),t=require("path-to-regexp");function r(e,t,r,n,o,a,i){try{var c=e[a](i),u=c.value}catch(e){return void r(e)}c.done?t(u):Promise.resolve(u).then(n,o)}function n(e){return function(){var t=this,n=arguments;return new Promise((function(o,a){var i=e.apply(t,n);function c(e){r(i,o,a,c,u,"next",e)}function u(e){r(i,o,a,c,u,"throw",e)}c(void 0)}))}}function o(){return(o=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function a(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=new Array(t);r<t;r++)n[r]=e[r];return n}function i(e,t){var r="undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(r)return(r=r.call(e)).next.bind(r);if(Array.isArray(e)||(r=function(e,t){if(e){if("string"==typeof e)return a(e,void 0);var r=Object.prototype.toString.call(e).slice(8,-1);return"Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r?Array.from(e):"Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?a(e,void 0):void 0}}(e))||t&&e&&"number"==typeof e.length){r&&(e=r);var n=0;return function(){return n>=e.length?{done:!0}:{done:!1,value:e[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 c,u=(function(e){var t=function(e){var t=Object.prototype,r=t.hasOwnProperty,n="function"==typeof Symbol?Symbol:{},o=n.iterator||"@@iterator",a=n.asyncIterator||"@@asyncIterator",i=n.toStringTag||"@@toStringTag";function c(e,t,r){return Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}),e[t]}try{c({},"")}catch(e){c=function(e,t,r){return e[t]=r}}function u(e,t,r,n){var o=Object.create((t&&t.prototype instanceof f?t:f).prototype),a=new k(n||[]);return o._invoke=function(e,t,r){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(r.method=o,r.arg=a;;){var i=r.delegate;if(i){var c=w(i,r);if(c){if(c===d)continue;return c}}if("next"===r.method)r.sent=r._sent=r.arg;else if("throw"===r.method){if("suspendedStart"===n)throw n="completed",r.arg;r.dispatchException(r.arg)}else"return"===r.method&&r.abrupt("return",r.arg);n="executing";var u=s(e,t,r);if("normal"===u.type){if(n=r.done?"completed":"suspendedYield",u.arg===d)continue;return{value:u.arg,done:r.done}}"throw"===u.type&&(n="completed",r.method="throw",r.arg=u.arg)}}}(e,r,a),o}function s(e,t,r){try{return{type:"normal",arg:e.call(t,r)}}catch(e){return{type:"throw",arg:e}}}e.wrap=u;var d={};function f(){}function p(){}function l(){}var h={};c(h,o,(function(){return this}));var m=Object.getPrototypeOf,y=m&&m(m(E([])));y&&y!==t&&r.call(y,o)&&(h=y);var v=l.prototype=f.prototype=Object.create(h);function g(e){["next","throw","return"].forEach((function(t){c(e,t,(function(e){return this._invoke(t,e)}))}))}function b(e,t){var n;this._invoke=function(o,a){function i(){return new t((function(n,i){!function n(o,a,i,c){var u=s(e[o],e,a);if("throw"!==u.type){var d=u.arg,f=d.value;return f&&"object"==typeof f&&r.call(f,"__await")?t.resolve(f.__await).then((function(e){n("next",e,i,c)}),(function(e){n("throw",e,i,c)})):t.resolve(f).then((function(e){d.value=e,i(d)}),(function(e){return n("throw",e,i,c)}))}c(u.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function w(e,t){var r=e.iterator[t.method];if(void 0===r){if(t.delegate=null,"throw"===t.method){if(e.iterator.return&&(t.method="return",t.arg=void 0,w(e,t),"throw"===t.method))return d;t.method="throw",t.arg=new TypeError("The iterator does not provide a 'throw' method")}return d}var n=s(r,e.iterator,t.arg);if("throw"===n.type)return t.method="throw",t.arg=n.arg,t.delegate=null,d;var o=n.arg;return o?o.done?(t[e.resultName]=o.value,t.next=e.nextLoc,"return"!==t.method&&(t.method="next",t.arg=void 0),t.delegate=null,d):o:(t.method="throw",t.arg=new TypeError("iterator result is not an object"),t.delegate=null,d)}function x(e){var t={tryLoc:e[0]};1 in e&&(t.catchLoc=e[1]),2 in e&&(t.finallyLoc=e[2],t.afterLoc=e[3]),this.tryEntries.push(t)}function O(e){var t=e.completion||{};t.type="normal",delete t.arg,e.completion=t}function k(e){this.tryEntries=[{tryLoc:"root"}],e.forEach(x,this),this.reset(!0)}function E(e){if(e){var t=e[o];if(t)return t.call(e);if("function"==typeof e.next)return e;if(!isNaN(e.length)){var n=-1,a=function t(){for(;++n<e.length;)if(r.call(e,n))return t.value=e[n],t.done=!1,t;return t.value=void 0,t.done=!0,t};return a.next=a}}return{next:q}}function q(){return{value:void 0,done:!0}}return p.prototype=l,c(v,"constructor",l),c(l,"constructor",p),p.displayName=c(l,i,"GeneratorFunction"),e.isGeneratorFunction=function(e){var t="function"==typeof e&&e.constructor;return!!t&&(t===p||"GeneratorFunction"===(t.displayName||t.name))},e.mark=function(e){return Object.setPrototypeOf?Object.setPrototypeOf(e,l):(e.__proto__=l,c(e,i,"GeneratorFunction")),e.prototype=Object.create(v),e},e.awrap=function(e){return{__await:e}},g(b.prototype),c(b.prototype,a,(function(){return this})),e.AsyncIterator=b,e.async=function(t,r,n,o,a){void 0===a&&(a=Promise);var i=new b(u(t,r,n,o),a);return e.isGeneratorFunction(r)?i:i.next().then((function(e){return e.done?e.value:i.next()}))},g(v),c(v,i,"Generator"),c(v,o,(function(){return this})),c(v,"toString",(function(){return"[object Generator]"})),e.keys=function(e){var t=[];for(var r in e)t.push(r);return t.reverse(),function r(){for(;t.length;){var n=t.pop();if(n in e)return r.value=n,r.done=!1,r}return r.done=!0,r}},e.values=E,k.prototype={constructor:k,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(O),!e)for(var t in this)"t"===t.charAt(0)&&r.call(this,t)&&!isNaN(+t.slice(1))&&(this[t]=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){if(this.done)throw e;var t=this;function n(r,n){return i.type="throw",i.arg=e,t.next=r,n&&(t.method="next",t.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 c=r.call(a,"catchLoc"),u=r.call(a,"finallyLoc");if(c&&u){if(this.prev<a.catchLoc)return n(a.catchLoc,!0);if(this.prev<a.finallyLoc)return n(a.finallyLoc)}else if(c){if(this.prev<a.catchLoc)return n(a.catchLoc,!0)}else{if(!u)throw new Error("try statement without catch or finally");if(this.prev<a.finallyLoc)return n(a.finallyLoc)}}}},abrupt:function(e,t){for(var n=this.tryEntries.length-1;n>=0;--n){var o=this.tryEntries[n];if(o.tryLoc<=this.prev&&r.call(o,"finallyLoc")&&this.prev<o.finallyLoc){var a=o;break}}a&&("break"===e||"continue"===e)&&a.tryLoc<=t&&t<=a.finallyLoc&&(a=null);var i=a?a.completion:{};return i.type=e,i.arg=t,a?(this.method="next",this.next=a.finallyLoc,d):this.complete(i)},complete:function(e,t){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&&t&&(this.next=t),d},finish:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.finallyLoc===e)return this.complete(r.completion,r.afterLoc),O(r),d}},catch:function(e){for(var t=this.tryEntries.length-1;t>=0;--t){var r=this.tryEntries[t];if(r.tryLoc===e){var n=r.completion;if("throw"===n.type){var o=n.arg;O(r)}return o}}throw new Error("illegal catch attempt")},delegateYield:function(e,t,r){return this.delegate={iterator:E(e),resultName:t,nextLoc:r},"next"===this.method&&(this.arg=void 0),d}},e}(e.exports);try{regeneratorRuntime=t}catch(e){"object"==typeof globalThis?globalThis.regeneratorRuntime=t:Function("r","regeneratorRuntime = r")(t)}}(c={exports:{}}),c.exports),s={ROUTE:Symbol()},d=function(){var t=e.createEffect(function(){var e=n(u.mark((function e(t){return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return e.abrupt("return",{params:t.params||{},query:t.query||{}});case 2:case"end":return e.stop()}}),e)})));return function(t){return e.apply(this,arguments)}}(),{name:"navigateFx",sid:"-apj8ex"}),r=e.attach({and:{effect:t,mapParams:function(e){return{params:e||{},query:{}}}},or:{name:"openFx",sid:"-ju5g7s"}}),o=e.createStore(!1,{name:"$isOpened",sid:"7ntohw"}),a=e.createStore({},{name:"$params",sid:"1blfp4"}),i=e.createStore({},{name:"$query",sid:"rvelj"}),c=e.createEvent({name:"opened",sid:"-f8s17u"}),d=e.createEvent({name:"updated",sid:"slzlyp"}),f=e.createEvent({name:"left",sid:"yy6ys3"}),p=e.createEvent({name:"closed",sid:"-say4ff"});return o.on(c,(function(){return!0})).on(f,(function(){return!1})),a.on(c,(function(e,t){return t.params})).on(d,(function(e,t){return t.params})),i.on(c,(function(e,t){return t.query})).on(d,(function(e,t){return t.query})),e.split({and:[{source:t.doneData,match:o.map((function(e){return e?"updated":"opened"})),cases:{opened:c,updated:d}}],or:{sid:"-x6h86m"}}),e.sample({and:[{clock:p,target:f}],or:{sid:"-wqj6z5"}}),{$isOpened:o,$params:a,$query:i,opened:c,updated:d,closed:p,left:f,navigate:t,open:r,kind:s.ROUTE}};function f(e){var r=e.params,n=e.query;return t.compile(e.pathCreator)(r)+(Object.keys(n).length?"?"+new URLSearchParams(n):"")}function p(e){var r=e.actualPath,n=t.match(e.pathCreator)(new URL("http://_"+r).pathname);return n?{matches:!0,params:n.params}:{matches:!1}}var l=e.createEffect((function(e){if(!e.history)throw new Error("[Routing] No history provided");return e.history[e.method](e.path,{}),e}),{name:"historyPushFx",sid:"sn2691"}),h=function(e){return"object"==typeof e&&null!==e&&"kind"in e&&e.kind===s.ROUTE},m=function(t){return e.is.store(t,{sid:"-v906zu"})?t:e.createStore(t,{sid:"-v904rr"})};exports.Kind=s,exports.buildPath=f,exports.chainRoute=function(t){var r=function(t){if(h(t))return{route:t,chainedRoute:e.withFactory({sid:"jogy9l",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:e.createEvent({name:"beforeOpen",sid:"8mpttm"}),openOn:[t.opened,t.closed],cancelOn:[e.createEvent({name:"cancelOn",sid:"ahjdm4"})]};var r=t;if(!("enterOn"in r)&&e.is.effect(r.beforeOpen,{sid:"fx5yhy"}))return{route:r.route,chainedRoute:r.chainedRoute||e.withFactory({sid:"fyulbq",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:r.beforeOpen,openOn:r.beforeOpen.doneData,cancelOn:r.beforeOpen.failData};var n=t;return{route:n.route,chainedRoute:n.chainedRoute||e.withFactory({sid:"u6793u",fn:function(){return d()},name:"chainedRoute",method:"createRoute"}),beforeOpen:n.beforeOpen,openOn:e.sample({and:[{clock:n.openOn}],or:{name:"openOn",sid:"-mm7rdb"}}),cancelOn:e.sample({and:[{clock:n.cancelOn||e.createEvent({name:"clock",sid:"y2etk0"})}],or:{name:"cancelOn",sid:"-vntqxj"}})}}(t),n=r.route,o=r.chainedRoute,a=r.beforeOpen,i=r.openOn,c=r.cancelOn,u=e.createStore({},{name:"$params",sid:"ru233x"}),s=e.createStore({},{name:"$query",sid:"2tnaew"}),f=e.combine({and:[e.combine({and:[[n.$params,n.$query]],or:{name:"and",sid:"-t8sbqu"}}),e.combine({and:[[u,s]],or:{name:"and",sid:"-t8s8s2"}}),function(e,t){return e[0]===t[0]&&e[1]===t[1]}],or:{name:"$hasSameParams",sid:"-w0fyuc"}}),p=e.sample({and:[{clock:[n.opened,n.updated]}],or:{name:"routeOpened",sid:"nobe5z"}});e.sample({and:[{clock:p,target:a}],or:{sid:"n0i9a7"}}),u.on(p,(function(e,t){return t.params})),s.on(p,(function(e,t){return t.query}));var l=e.guard({and:[{clock:i,source:{params:u,query:s},filter:f}],or:{name:"chainedRouteResolved",sid:"-qurk3a"}});e.sample({and:[{clock:l,target:o.navigate}],or:{sid:"ningv4"}});var m=e.merge([n.closed,c],{name:"aborted",sid:"-qm6c6a"});return u.reset(m),s.reset(m),e.sample({and:[{clock:m,target:o.closed}],or:{sid:"nz5any"}}),o},exports.createHistoryRouter=function(t){var r=function(e){for(var t,r=[],n=function(){var e=t.value;Array.isArray(e.route)?r.push.apply(r,e.route.map((function(t){return o({},e,{route:t})}))):r.push(e)},a=i(e);!(t=a()).done;)n();return r}(t.routes),a=e.createEvent({name:"setHistory",sid:"-d2vpek"}),c=e.createEvent({name:"routeNotFound",sid:"-y4sqp2"}),s=e.createStore({},{name:"$query",sid:"hnxt1l"}),d=e.createStore("",{name:"$path",sid:"-sa8poc"}),h=e.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"62zlkr"}),m=e.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"-7y2vlh"});m.on(a,(function(e,t){return t}));var y=e.attach({and:{source:{history:m},effect:l,mapParams:function(e,t){return o({history:t.history},e)}},or:{name:"pushFx",sid:"e2mlkx"}}),v=e.createEffect((function(e){var t=e.params,r=e.query;return{path:f({pathCreator:e.route.path,params:t,query:r}),params:t,query:r,method:"push"}}),{name:"openedFx",sid:"171qv8"}),g=e.createEffect((function(e){for(var t,n=e.path,o=e.query,a=[],c=[],u=i(r);!(t=u()).done;){var s=t.value,d=p({pathCreator:s.path,actualPath:n});(d.matches?a:c).push({route:s,params:d.params,query:o})}return{opened:a,closed:c}}),{name:"recalculateFx",sid:"-8daxxq"});d.on(g.done,(function(e,t){return t.params.path})),s.on(g.done,(function(e,t){return t.params.query})),h.on(g.doneData,(function(e,t){return t.opened.map((function(e){return e.route.route}))})),e.sample({and:[{clock:v.doneData,target:y}],or:{sid:"7csm23"}}),e.guard({and:[{clock:g.doneData,filter:function(e){return 0===e.opened.length},target:c}],or:{sid:"7tafux"}});for(var b,w=g.doneData.map((function(e){return e.opened})),x=g.doneData.map((function(e){return e.closed})),O=function(){var t=b.value,r=e.createStore(!1,{name:"$isOpenedManually",sid:"by1u5o"}),n=t.route.navigate.done;e.sample({and:[{clock:n,fn:function(e){var r=e.result;return{route:t,params:r.params,query:r.query}},target:v}],or:{sid:"-jxfhr2"}});var o=function(e){return e.find((function(e){return e.route===t}))},a={opened:e.guard({and:[{clock:w.filterMap(o),filter:t.route.$isOpened.map((function(e){return!e}))}],or:{name:"opened",sid:"-6e1ik"}}),updated:e.guard({and:[{clock:w.filterMap(o),filter:t.route.$isOpened}],or:{name:"updated",sid:"-y6s1fj"}}),closed:e.guard({and:[{clock:x.filterMap(o),filter:t.route.$isOpened}],or:{name:"closed",sid:"2bzoi7"}})};r.on(n,(function(){return!0})),e.guard({and:[{clock:a.updated,filter:r.map((function(e){return!e})),target:t.route.updated}],or:{sid:"-iiuf5u"}}),e.guard({and:[{clock:a.opened,filter:r.map((function(e){return!e})),target:t.route.opened}],or:{sid:"-i3zz53"}}),e.sample({and:[{clock:a.closed,target:t.route.closed}],or:{sid:"-i0p7kx"}}),r.reset(e.sample({and:[{clock:w}],or:{sid:"lycydm"}}))},k=i(r);!(b=k()).done;)O();var E,q=e.attach({and:{source:{history:m},effect:(E=n(u.mark((function e(t){var r,n;return u.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:return n=[(r=t.history).location.pathname,Object.fromEntries(new URLSearchParams(r.location.search))],e.abrupt("return",{path:n[0],query:n[1]});case 3:case"end":return e.stop()}}),e)}))),function(e){return E.apply(this,arguments)})},or:{name:"recheckFx",sid:"-aaaqj8"}});e.sample({and:[{source:q.doneData,target:g}],or:{sid:"-gnriv8"}});var j,L=e.attach({and:{source:{history:m},effect:(j=n(u.mark((function t(r){var n,o;return u.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:n=r.history,o=q;try{o=e.scopeBind(q)}catch(e){}return n.listen((function(){o()})),t.abrupt("return",!0);case 5:case"end":return t.stop()}}),t)}))),function(e){return j.apply(this,arguments)})},or:{name:"subscribeHistoryFx",sid:"-ec82v1"}});return t.hydrate||e.sample({and:[{clock:L.doneData,target:q}],or:{sid:"-fmxb0l"}}),e.sample({and:[{clock:m,target:L}],or:{sid:"-5aolek"}}),{$path:d,$query:s,$activeRoutes:h,$history:m,setHistory:a,push:y,routes:r,routeNotFound:c}},exports.createRoute=d,exports.isRoute=h,exports.matchPath=p,exports.redirect=function(t){var r=t.clock?e.sample({and:[{clock:t.clock}],or:{name:"clock",sid:"-nsh945"}}):e.createEvent({name:"clock",sid:"-nbfmpy"}),n=m(t.params||{}),o=m(t.query||{});return e.sample({and:[{clock:r,source:{params:n,query:o},fn:function(e,t){var r=e.params,n=e.query;return{params:"function"==typeof r?r(t):r,query:"function"==typeof n?n(t):n}},target:t.route.navigate}],or:{sid:"-8kqnzy"}}),r};
//# sourceMappingURL=atomic-router.cjs.production.min.js.map

@@ -1482,5 +1482,13 @@ import { createEffect, attach, createStore, createEvent, split, sample, guard, scopeBind, is, combine, merge, withFactory } from 'effector';

var redirect = function redirect(options) {
var clock = options.clock || createEvent({
var clock = options.clock ? sample({
and: [{
clock: options.clock
}],
or: {
name: "clock",
sid: "-nsh945"
}
}) : createEvent({
name: "clock",
sid: "-o9itwn"
sid: "-nbfmpy"
});

@@ -1507,3 +1515,3 @@ var params = toStore(options.params || {});

or: {
sid: "-8lu96o"
sid: "-8kqnzy"
}

@@ -1516,5 +1524,5 @@ });

return is.store(payload, {
sid: "sw2jwt"
sid: "-v906zu"
}) ? payload : createStore(payload, {
sid: "sw2m4w"
sid: "-v904rr"
});

@@ -1521,0 +1529,0 @@ };

@@ -10,3 +10,3 @@ import { Clock, Store } from 'effector';

/** Opens passed `route` upon `clock` trigger */
export declare const redirect: <T, Params>(options: RedirectParams<T, Params>) => [import("effector").Unit<any>, ...import("effector").Unit<any>[]] | import("effector").Unit<T>;
export declare const redirect: <T, Params>(options: RedirectParams<T, Params>) => import("effector").Event<any> | import("effector").Event<T>;
export {};
{
"version": "0.5.0-dev.8",
"version": "0.5.0-dev.9",
"license": "MIT",

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

@@ -13,3 +13,5 @@ import { Clock, createEvent, createStore, is, sample, Store } from 'effector';

export const redirect = <T, Params>(options: RedirectParams<T, Params>) => {
const clock = options.clock || createEvent<T>();
const clock = options.clock
? sample({ clock: options.clock })
: createEvent<T>();
let params = toStore(options.params || {});

@@ -16,0 +18,0 @@ let query = toStore(options.query || {});

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