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

2

dist/atomic-router.cjs.development.js

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

var aborted = merge([route.closed, cancelOn], {
var aborted = effector.merge([route.closed, cancelOn], {
name: "aborted",

@@ -1704,0 +1704,0 @@ sid: "-qm6c6a"

@@ -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=w(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 b(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 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,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(b.prototype),u(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(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:"rxzb4f"})?t:e.createStore(t,{sid:"rxzdci"})};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=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 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(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=m(t.params||{}),n=m(t.query||{});e.sample({and:[{clock:t.clock,source:{params:r,query:n},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:"-8me1s1"}})};
"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=w(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 b(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 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,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(b.prototype),u(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(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:"rxzb4f"})?t:e.createStore(t,{sid:"rxzdci"})};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 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(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=m(t.params||{}),n=m(t.query||{});e.sample({and:[{clock:t.clock,source:{params:r,query:n},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:"-8me1s1"}})};
//# sourceMappingURL=atomic-router.cjs.production.min.js.map

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

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

@@ -3,0 +3,0 @@

{
"version": "0.5.0-dev.6",
"version": "0.5.0-dev.7",
"license": "MIT",

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

import {
is,
guard,
merge,
sample,

@@ -5,0 +6,0 @@ combine,

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