atomic-router
Advanced tools
Comparing version 0.4.0 to 0.4.1
@@ -885,18 +885,45 @@ 'use strict'; | ||
}; | ||
}()); | ||
}(), { | ||
name: "navigateFx", | ||
sid: "-b6kut4" | ||
}); | ||
var openFx = effector.attach({ | ||
effect: navigateFx, | ||
mapParams: function mapParams(params) { | ||
return { | ||
params: params || {}, | ||
query: {} | ||
}; | ||
and: { | ||
effect: navigateFx, | ||
mapParams: function mapParams(params) { | ||
return { | ||
params: params || {}, | ||
query: {} | ||
}; | ||
} | ||
}, | ||
or: { | ||
name: "openFx", | ||
sid: "68re1x" | ||
} | ||
}); | ||
var $isOpened = effector.createStore(false); | ||
var $params = effector.createStore({}); | ||
var $query = effector.createStore({}); | ||
var opened = effector.createEvent(); | ||
var updated = effector.createEvent(); | ||
var left = effector.createEvent(); | ||
var $isOpened = effector.createStore(false, { | ||
name: "$isOpened", | ||
sid: "5rn6x4" | ||
}); | ||
var $params = effector.createStore({}, { | ||
name: "$params", | ||
sid: "-kl1vo" | ||
}); | ||
var $query = effector.createStore({}, { | ||
name: "$query", | ||
sid: "-14b2z9" | ||
}); | ||
var opened = effector.createEvent({ | ||
name: "opened", | ||
sid: "-r2wl2p" | ||
}); | ||
var updated = effector.createEvent({ | ||
name: "updated", | ||
sid: "grv23u" | ||
}); | ||
var left = effector.createEvent({ | ||
name: "left", | ||
sid: "mn0sj1" | ||
}); | ||
$isOpened.on(opened, function () { | ||
@@ -922,4 +949,9 @@ return true; | ||
effector.sample({ | ||
clock: navigateFx.doneData, | ||
target: opened | ||
and: [{ | ||
clock: navigateFx.doneData, | ||
target: opened | ||
}], | ||
or: { | ||
sid: "-xlbo7d" | ||
} | ||
}); | ||
@@ -971,2 +1003,5 @@ return { | ||
return pushParams; | ||
}, { | ||
name: "historyPushFx", | ||
sid: "sn2691" | ||
}); | ||
@@ -1001,9 +1036,27 @@ | ||
var remappedRoutes = remapRouteObjects(params.routes); | ||
var setHistory = effector.createEvent(); | ||
var routeNotFound = effector.createEvent(); | ||
var $query = effector.createStore({}); | ||
var $path = effector.createStore(''); | ||
var $activeRoutes = effector.createStore([]); // @ts-expect-error | ||
var setHistory = effector.createEvent({ | ||
name: "setHistory", | ||
sid: "-d2vpek" | ||
}); | ||
var routeNotFound = effector.createEvent({ | ||
name: "routeNotFound", | ||
sid: "-y4sqp2" | ||
}); | ||
var $query = effector.createStore({}, { | ||
name: "$query", | ||
sid: "hnxt1l" | ||
}); | ||
var $path = effector.createStore('', { | ||
name: "$path", | ||
sid: "-sa8poc" | ||
}); | ||
var $activeRoutes = effector.createStore([], { | ||
name: "$activeRoutes", | ||
sid: "62zlkr" | ||
}); // @ts-expect-error | ||
var $history = effector.createStore(null).on(setHistory, function (_, nextHistory) { | ||
var $history = effector.createStore(null, { | ||
name: "$history", | ||
sid: "-8w64dv" | ||
}).on(setHistory, function (_, nextHistory) { | ||
return nextHistory; | ||
@@ -1013,11 +1066,17 @@ }); // historyPushFx for the current history | ||
var pushFx = effector.attach({ | ||
source: { | ||
history: $history | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: historyPushFx, | ||
mapParams: function mapParams(params, _ref) { | ||
var history = _ref.history; | ||
return _extends({ | ||
history: history | ||
}, params); | ||
} | ||
}, | ||
effect: historyPushFx, | ||
mapParams: function mapParams(params, _ref) { | ||
var history = _ref.history; | ||
return _extends({ | ||
history: history | ||
}, params); | ||
or: { | ||
name: "pushFx", | ||
sid: "bpehly" | ||
} | ||
@@ -1041,2 +1100,5 @@ }); // Triggered whenever some route.open.doneData is triggered | ||
}; | ||
}, { | ||
name: "enteredFx", | ||
sid: "95ckj3" | ||
}); // Recalculate entered/left routes | ||
@@ -1071,2 +1133,5 @@ | ||
}; | ||
}, { | ||
name: "recalculateFx", | ||
sid: "-aqj1wp" | ||
}); | ||
@@ -1088,17 +1153,32 @@ $path.on(recalculateFx.done, function (_prev, _ref4) { | ||
effector.sample({ | ||
clock: enteredFx.doneData, | ||
target: pushFx | ||
and: [{ | ||
clock: enteredFx.doneData, | ||
target: pushFx | ||
}], | ||
or: { | ||
sid: "7a1n3a" | ||
} | ||
}); | ||
effector.sample({ | ||
clock: pushFx.doneData, | ||
target: recalculateFx | ||
and: [{ | ||
clock: pushFx.doneData, | ||
target: recalculateFx | ||
}], | ||
or: { | ||
sid: "7c8tgq" | ||
} | ||
}); // Trigger 404 if no routes were entered | ||
effector.guard({ | ||
clock: recalculateFx.doneData, | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
}, | ||
target: routeNotFound | ||
and: [{ | ||
clock: recalculateFx.doneData, | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
}, | ||
target: routeNotFound | ||
}], | ||
or: { | ||
sid: "7qjgw4" | ||
} | ||
}); | ||
@@ -1118,47 +1198,67 @@ var routesEntered = recalculateFx.doneData.map(function (_ref8) { | ||
effector.sample({ | ||
clock: routeObj.route.navigate.doneData, | ||
fn: function fn(_ref13) { | ||
var params = _ref13.params, | ||
query = _ref13.query; | ||
return { | ||
route: routeObj, | ||
params: params, | ||
query: query | ||
}; | ||
}, | ||
target: enteredFx | ||
and: [{ | ||
clock: routeObj.route.navigate.doneData, | ||
fn: function fn(_ref13) { | ||
var params = _ref13.params, | ||
query = _ref13.query; | ||
return { | ||
route: routeObj, | ||
params: params, | ||
query: query | ||
}; | ||
}, | ||
target: enteredFx | ||
}], | ||
or: { | ||
sid: "-k1a1wl" | ||
} | ||
}); // Trigger .updated() for already opened routes marked as "opened" | ||
effector.guard({ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return isOpened; | ||
}), | ||
target: routeObj.route.updated | ||
and: [{ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return isOpened; | ||
}), | ||
target: routeObj.route.updated | ||
}], | ||
or: { | ||
sid: "-jk8fie" | ||
} | ||
}); // Trigger .opened() for the routes marked as "opened" | ||
effector.guard({ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return !isOpened; | ||
}), | ||
target: routeObj.route.opened | ||
and: [{ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return !isOpened; | ||
}), | ||
target: routeObj.route.opened | ||
}], | ||
or: { | ||
sid: "-jfu2ri" | ||
} | ||
}); // Trigger .left() for the routes marked as "left" | ||
effector.guard({ | ||
clock: routesLeft.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened, | ||
target: routeObj.route.left | ||
and: [{ | ||
clock: routesLeft.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened, | ||
target: routeObj.route.left | ||
}], | ||
or: { | ||
sid: "-izw1k1" | ||
} | ||
}); | ||
@@ -1174,79 +1274,96 @@ }; | ||
var recheckFx = effector.attach({ | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref10) { | ||
var history, _ref11, path, query; | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref10) { | ||
var history, _ref11, path, query; | ||
return runtime_1.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
history = _ref10.history; | ||
_ref11 = [history.location.pathname, Object.fromEntries( // @ts-expect-error | ||
new URLSearchParams(history.location.search))], path = _ref11[0], query = _ref11[1]; | ||
return _context.abrupt("return", { | ||
path: path, | ||
query: query | ||
}); | ||
return runtime_1.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
history = _ref10.history; | ||
_ref11 = [history.location.pathname, Object.fromEntries( // @ts-expect-error | ||
new URLSearchParams(history.location.search))], path = _ref11[0], query = _ref11[1]; | ||
return _context.abrupt("return", { | ||
path: path, | ||
query: query | ||
}); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
}, _callee); | ||
})); | ||
function effect(_x) { | ||
return _effect.apply(this, arguments); | ||
} | ||
function effect(_x) { | ||
return _effect.apply(this, arguments); | ||
} | ||
return effect; | ||
}() | ||
return effect; | ||
}() | ||
}, | ||
or: { | ||
name: "recheckFx", | ||
sid: "uwz4ln" | ||
} | ||
}); | ||
effector.sample({ | ||
source: recheckFx.doneData, | ||
target: recalculateFx | ||
and: [{ | ||
source: recheckFx.doneData, | ||
target: recalculateFx | ||
}], | ||
or: { | ||
sid: "-hmek8z" | ||
} | ||
}); // Triggered whenever history instance is set | ||
var subscribeHistoryFx = effector.attach({ | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) { | ||
var history, scopedRecheck; | ||
return runtime_1.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
history = _ref12.history; | ||
scopedRecheck = recheckFx; | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) { | ||
var history, scopedRecheck; | ||
return runtime_1.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
history = _ref12.history; | ||
scopedRecheck = recheckFx; | ||
try { | ||
// @ts-expect-error | ||
scopedRecheck = effector.scopeBind(recheckFx); | ||
} catch (err) {} | ||
try { | ||
// @ts-expect-error | ||
scopedRecheck = effector.scopeBind(recheckFx); | ||
} catch (err) {} | ||
history.listen(function () { | ||
scopedRecheck(); | ||
}); | ||
return _context2.abrupt("return", true); | ||
history.listen(function () { | ||
scopedRecheck(); | ||
}); | ||
return _context2.abrupt("return", true); | ||
case 5: | ||
case "end": | ||
return _context2.stop(); | ||
case 5: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
})); | ||
function effect(_x2) { | ||
return _effect2.apply(this, arguments); | ||
} | ||
function effect(_x2) { | ||
return _effect2.apply(this, arguments); | ||
} | ||
return effect; | ||
}() | ||
return effect; | ||
}() | ||
}, | ||
or: { | ||
name: "subscribeHistoryFx", | ||
sid: "qv1s9u" | ||
} | ||
}); // If `hydrate` flag is set, | ||
@@ -1257,4 +1374,9 @@ // don't trigger recheck on history init | ||
effector.sample({ | ||
clock: subscribeHistoryFx.doneData, | ||
target: recheckFx | ||
and: [{ | ||
clock: subscribeHistoryFx.doneData, | ||
target: recheckFx | ||
}], | ||
or: { | ||
sid: "-glkcec" | ||
} | ||
}); | ||
@@ -1264,4 +1386,9 @@ } | ||
effector.sample({ | ||
clock: $history, | ||
target: subscribeHistoryFx | ||
and: [{ | ||
clock: $history, | ||
target: subscribeHistoryFx | ||
}], | ||
or: { | ||
sid: "-g79p2e" | ||
} | ||
}); | ||
@@ -1268,0 +1395,0 @@ return { |
@@ -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 h?r:h).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=b(i,e);if(u){if(u===s)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=f(t,r,e);if("normal"===c.type){if(n=e.done?"completed":"suspendedYield",c.arg===s)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 f(t,r,e){try{return{type:"normal",arg:t.call(r,e)}}catch(t){return{type:"throw",arg:t}}}t.wrap=c;var s={};function h(){}function p(){}function l(){}var y={};u(y,o,(function(){return this}));var d=Object.getPrototypeOf,v=d&&d(d(O([])));v&&v!==r&&e.call(v,o)&&(y=v);var m=l.prototype=h.prototype=Object.create(y);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=f(t[o],t,a);if("throw"!==c.type){var s=c.arg,h=s.value;return h&&"object"==typeof h&&e.call(h,"__await")?r.resolve(h.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):r.resolve(h).then((function(t){s.value=t,i(s)}),(function(t){return n("throw",t,i,u)}))}u(c.arg)}(o,a,n,i)}))}return n=n?n.then(i,i):i()}}function b(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,b(t,r),"throw"===r.method))return s;r.method="throw",r.arg=new TypeError("The iterator does not provide a 'throw' method")}return s}var n=f(e,t.iterator,r.arg);if("throw"===n.type)return r.method="throw",r.arg=n.arg,r.delegate=null,s;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,s):o:(r.method="throw",r.arg=new TypeError("iterator result is not an object"),r.delegate=null,s)}function x(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(x,this),this.reset(!0)}function O(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:k}}function k(){return{value:void 0,done:!0}}return p.prototype=l,u(m,"constructor",l),u(l,"constructor",p),p.displayName=u(l,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"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=O,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,s):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),s},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),s}},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:O(t),resultName:r,nextLoc:e},"next"===this.method&&(this.arg=void 0),s}},t}(t.exports);try{regeneratorRuntime=r}catch(t){"object"==typeof globalThis?globalThis.regeneratorRuntime=r:Function("r","regeneratorRuntime = r")(r)}}(u={exports:{}}),u.exports);function f(t){var e=t.params,n=t.query;return r.compile(t.pathCreator)(e)+(Object.keys(n).length?"?"+new URLSearchParams(n):"")}function s(t){var e=t.actualPath,n=r.match(t.pathCreator)(e);return n?{matches:!0,params:n.params}:{matches:!1}}var h=t.createEffect((function(t){if(!t.history)throw new Error("[Routing] No history provided");return t.history[t.method](t.path,{}),t}));exports.buildPath=f,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(),u=t.createEvent(),p=t.createStore({}),l=t.createStore(""),y=t.createStore([]),d=t.createStore(null).on(a,(function(t,r){return r})),v=t.attach({source:{history:d},effect:h,mapParams:function(t,r){return o({history:r.history},t)}}),m=t.createEffect((function(t){var r=t.params,e=t.query;return{path:f({pathCreator:t.route.path,params:r,query:e}),params:r,query:e,method:"push"}})),g=t.createEffect((function(t){for(var r,n=t.path,o=t.query,a=[],u=[],c=i(e);!(r=c()).done;){var f=r.value,h=s({pathCreator:f.path,actualPath:n});(h.matches?a:u).push({route:f,params:h.params,query:o})}return{entered:a,left:u}}));l.on(g.done,(function(t,r){return r.params.path})),p.on(g.done,(function(t,r){return r.params.query})),y.on(g.doneData,(function(t,r){return r.entered.map((function(t){return t.route.route}))})),t.sample({clock:m.doneData,target:v}),t.sample({clock:v.doneData,target:g}),t.guard({clock:g.doneData,filter:function(t){return 0===t.entered.length},target:u});for(var w,b=g.doneData.map((function(t){return t.entered})),x=g.doneData.map((function(t){return t.left})),E=function(){var r=w.value;t.sample({clock:r.route.navigate.doneData,fn:function(t){return{route:r,params:t.params,query:t.query}},target:m}),t.guard({clock:b.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}),t.guard({clock:b.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}),t.guard({clock:x.filterMap((function(t){return t.find((function(t){return t.route===r}))})),filter:r.route.$isOpened,target:r.route.left})},L=i(e);!(w=L()).done;)E();var O,k=t.attach({source:{history:d},effect:(O=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 O.apply(this,arguments)})});t.sample({source:k.doneData,target:g});var S,j=t.attach({source:{history:d},effect:(S=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=k;try{o=t.scopeBind(k)}catch(t){}return n.listen((function(){o()})),r.abrupt("return",!0);case 5:case"end":return r.stop()}}),r)}))),function(t){return S.apply(this,arguments)})});return r.hydrate||t.sample({clock:j.doneData,target:k}),t.sample({clock:d,target:j}),{$path:l,$query:p,$activeRoutes:y,$history:d,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)}}()),e=t.attach({effect:r,mapParams:function(t){return{params:t||{},query:{}}}}),o=t.createStore(!1),a=t.createStore({}),i=t.createStore({}),u=t.createEvent(),f=t.createEvent(),s=t.createEvent();return o.on(u,(function(){return!0})).on(s,(function(){return!1})),a.on(u,(function(t,r){return r.params})).on(f,(function(t,r){return r.params})),i.on(u,(function(t,r){return r.query})).on(f,(function(t,r){return r.query})),t.sample({clock:r.doneData,target:u}),{$isOpened:o,$params:a,$query:i,opened:u,updated:f,left:s,navigate:r,open:e}},exports.matchPath=s; | ||
"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 h?r:h).prototype),a=new k(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 h(){}function p(){}function l(){}var d={};u(d,o,(function(){return this}));var y=Object.getPrototypeOf,v=y&&y(y(L([])));v&&v!==r&&e.call(v,o)&&(d=v);var m=l.prototype=h.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,h=f.value;return h&&"object"==typeof h&&e.call(h,"__await")?r.resolve(h.__await).then((function(t){n("next",t,i,u)}),(function(t){n("throw",t,i,u)})):r.resolve(h).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 k(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 p.prototype=l,u(m,"constructor",l),u(l,"constructor",p),p.displayName=u(l,i,"GeneratorFunction"),t.isGeneratorFunction=function(t){var r="function"==typeof t&&t.constructor;return!!r&&(r===p||"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=L,k.prototype={constructor:k,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: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)(e);return n?{matches:!0,params:n.params}:{matches:!1}}var h=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"});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"}),p=t.createStore({},{name:"$query",sid:"hnxt1l"}),l=t.createStore("",{name:"$path",sid:"-sa8poc"}),d=t.createStore([],{name:"$activeRoutes",sid:"62zlkr"}),y=t.createStore(null,{name:"$history",sid:"-8w64dv"}).on(a,(function(t,r){return r})),v=t.attach({and:{source:{history:y},effect:h,mapParams:function(t,r){return o({history:r.history},t)}},or:{name:"pushFx",sid:"bpehly"}}),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:"95ckj3"}),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,h=f({pathCreator:s.path,actualPath:n});(h.matches?a:u).push({route:s,params:h.params,query:o})}return{entered:a,left:u}}),{name:"recalculateFx",sid:"-aqj1wp"});l.on(g.done,(function(t,r){return r.params.path})),p.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:"7a1n3a"}}),t.sample({and:[{clock:v.doneData,target:g}],or:{sid:"7c8tgq"}}),t.guard({and:[{clock:g.doneData,filter:function(t){return 0===t.entered.length},target:u}],or:{sid:"7qjgw4"}});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:"-k1a1wl"}}),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:"-jk8fie"}}),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:"-jfu2ri"}}),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:"-izw1k1"}})},k=i(e);!(w=k()).done;)E();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:"uwz4ln"}});t.sample({and:[{source:j.doneData,target:g}],or:{sid:"-hmek8z"}});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:"qv1s9u"}});return r.hydrate||t.sample({and:[{clock:O.doneData,target:j}],or:{sid:"-glkcec"}}),t.sample({and:[{clock:y,target:O}],or:{sid:"-g79p2e"}}),{$path:l,$query:p,$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; | ||
//# sourceMappingURL=atomic-router.cjs.production.min.js.map |
@@ -881,18 +881,45 @@ import { createEffect, attach, createStore, createEvent, sample, guard, scopeBind } from 'effector'; | ||
}; | ||
}()); | ||
}(), { | ||
name: "navigateFx", | ||
sid: "-b6kut4" | ||
}); | ||
var openFx = attach({ | ||
effect: navigateFx, | ||
mapParams: function mapParams(params) { | ||
return { | ||
params: params || {}, | ||
query: {} | ||
}; | ||
and: { | ||
effect: navigateFx, | ||
mapParams: function mapParams(params) { | ||
return { | ||
params: params || {}, | ||
query: {} | ||
}; | ||
} | ||
}, | ||
or: { | ||
name: "openFx", | ||
sid: "68re1x" | ||
} | ||
}); | ||
var $isOpened = createStore(false); | ||
var $params = createStore({}); | ||
var $query = createStore({}); | ||
var opened = createEvent(); | ||
var updated = createEvent(); | ||
var left = createEvent(); | ||
var $isOpened = createStore(false, { | ||
name: "$isOpened", | ||
sid: "5rn6x4" | ||
}); | ||
var $params = createStore({}, { | ||
name: "$params", | ||
sid: "-kl1vo" | ||
}); | ||
var $query = createStore({}, { | ||
name: "$query", | ||
sid: "-14b2z9" | ||
}); | ||
var opened = createEvent({ | ||
name: "opened", | ||
sid: "-r2wl2p" | ||
}); | ||
var updated = createEvent({ | ||
name: "updated", | ||
sid: "grv23u" | ||
}); | ||
var left = createEvent({ | ||
name: "left", | ||
sid: "mn0sj1" | ||
}); | ||
$isOpened.on(opened, function () { | ||
@@ -918,4 +945,9 @@ return true; | ||
sample({ | ||
clock: navigateFx.doneData, | ||
target: opened | ||
and: [{ | ||
clock: navigateFx.doneData, | ||
target: opened | ||
}], | ||
or: { | ||
sid: "-xlbo7d" | ||
} | ||
}); | ||
@@ -967,2 +999,5 @@ return { | ||
return pushParams; | ||
}, { | ||
name: "historyPushFx", | ||
sid: "sn2691" | ||
}); | ||
@@ -997,9 +1032,27 @@ | ||
var remappedRoutes = remapRouteObjects(params.routes); | ||
var setHistory = createEvent(); | ||
var routeNotFound = createEvent(); | ||
var $query = createStore({}); | ||
var $path = createStore(''); | ||
var $activeRoutes = createStore([]); // @ts-expect-error | ||
var setHistory = createEvent({ | ||
name: "setHistory", | ||
sid: "-d2vpek" | ||
}); | ||
var routeNotFound = createEvent({ | ||
name: "routeNotFound", | ||
sid: "-y4sqp2" | ||
}); | ||
var $query = createStore({}, { | ||
name: "$query", | ||
sid: "hnxt1l" | ||
}); | ||
var $path = createStore('', { | ||
name: "$path", | ||
sid: "-sa8poc" | ||
}); | ||
var $activeRoutes = createStore([], { | ||
name: "$activeRoutes", | ||
sid: "62zlkr" | ||
}); // @ts-expect-error | ||
var $history = createStore(null).on(setHistory, function (_, nextHistory) { | ||
var $history = createStore(null, { | ||
name: "$history", | ||
sid: "-8w64dv" | ||
}).on(setHistory, function (_, nextHistory) { | ||
return nextHistory; | ||
@@ -1009,11 +1062,17 @@ }); // historyPushFx for the current history | ||
var pushFx = attach({ | ||
source: { | ||
history: $history | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: historyPushFx, | ||
mapParams: function mapParams(params, _ref) { | ||
var history = _ref.history; | ||
return _extends({ | ||
history: history | ||
}, params); | ||
} | ||
}, | ||
effect: historyPushFx, | ||
mapParams: function mapParams(params, _ref) { | ||
var history = _ref.history; | ||
return _extends({ | ||
history: history | ||
}, params); | ||
or: { | ||
name: "pushFx", | ||
sid: "bpehly" | ||
} | ||
@@ -1037,2 +1096,5 @@ }); // Triggered whenever some route.open.doneData is triggered | ||
}; | ||
}, { | ||
name: "enteredFx", | ||
sid: "95ckj3" | ||
}); // Recalculate entered/left routes | ||
@@ -1067,2 +1129,5 @@ | ||
}; | ||
}, { | ||
name: "recalculateFx", | ||
sid: "-aqj1wp" | ||
}); | ||
@@ -1084,17 +1149,32 @@ $path.on(recalculateFx.done, function (_prev, _ref4) { | ||
sample({ | ||
clock: enteredFx.doneData, | ||
target: pushFx | ||
and: [{ | ||
clock: enteredFx.doneData, | ||
target: pushFx | ||
}], | ||
or: { | ||
sid: "7a1n3a" | ||
} | ||
}); | ||
sample({ | ||
clock: pushFx.doneData, | ||
target: recalculateFx | ||
and: [{ | ||
clock: pushFx.doneData, | ||
target: recalculateFx | ||
}], | ||
or: { | ||
sid: "7c8tgq" | ||
} | ||
}); // Trigger 404 if no routes were entered | ||
guard({ | ||
clock: recalculateFx.doneData, | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
}, | ||
target: routeNotFound | ||
and: [{ | ||
clock: recalculateFx.doneData, | ||
filter: function filter(_ref7) { | ||
var entered = _ref7.entered; | ||
return entered.length === 0; | ||
}, | ||
target: routeNotFound | ||
}], | ||
or: { | ||
sid: "7qjgw4" | ||
} | ||
}); | ||
@@ -1114,47 +1194,67 @@ var routesEntered = recalculateFx.doneData.map(function (_ref8) { | ||
sample({ | ||
clock: routeObj.route.navigate.doneData, | ||
fn: function fn(_ref13) { | ||
var params = _ref13.params, | ||
query = _ref13.query; | ||
return { | ||
route: routeObj, | ||
params: params, | ||
query: query | ||
}; | ||
}, | ||
target: enteredFx | ||
and: [{ | ||
clock: routeObj.route.navigate.doneData, | ||
fn: function fn(_ref13) { | ||
var params = _ref13.params, | ||
query = _ref13.query; | ||
return { | ||
route: routeObj, | ||
params: params, | ||
query: query | ||
}; | ||
}, | ||
target: enteredFx | ||
}], | ||
or: { | ||
sid: "-k1a1wl" | ||
} | ||
}); // Trigger .updated() for already opened routes marked as "opened" | ||
guard({ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return isOpened; | ||
}), | ||
target: routeObj.route.updated | ||
and: [{ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return isOpened; | ||
}), | ||
target: routeObj.route.updated | ||
}], | ||
or: { | ||
sid: "-jk8fie" | ||
} | ||
}); // Trigger .opened() for the routes marked as "opened" | ||
guard({ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return !isOpened; | ||
}), | ||
target: routeObj.route.opened | ||
and: [{ | ||
clock: routesEntered.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened.map(function (isOpened) { | ||
return !isOpened; | ||
}), | ||
target: routeObj.route.opened | ||
}], | ||
or: { | ||
sid: "-jfu2ri" | ||
} | ||
}); // Trigger .left() for the routes marked as "left" | ||
guard({ | ||
clock: routesLeft.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened, | ||
target: routeObj.route.left | ||
and: [{ | ||
clock: routesLeft.filterMap(function (recheckResults) { | ||
return recheckResults.find(function (recheckResult) { | ||
return recheckResult.route === routeObj; | ||
}); | ||
}), | ||
filter: routeObj.route.$isOpened, | ||
target: routeObj.route.left | ||
}], | ||
or: { | ||
sid: "-izw1k1" | ||
} | ||
}); | ||
@@ -1170,79 +1270,96 @@ }; | ||
var recheckFx = attach({ | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref10) { | ||
var history, _ref11, path, query; | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee(_ref10) { | ||
var history, _ref11, path, query; | ||
return runtime_1.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
history = _ref10.history; | ||
_ref11 = [history.location.pathname, Object.fromEntries( // @ts-expect-error | ||
new URLSearchParams(history.location.search))], path = _ref11[0], query = _ref11[1]; | ||
return _context.abrupt("return", { | ||
path: path, | ||
query: query | ||
}); | ||
return runtime_1.wrap(function _callee$(_context) { | ||
while (1) { | ||
switch (_context.prev = _context.next) { | ||
case 0: | ||
history = _ref10.history; | ||
_ref11 = [history.location.pathname, Object.fromEntries( // @ts-expect-error | ||
new URLSearchParams(history.location.search))], path = _ref11[0], query = _ref11[1]; | ||
return _context.abrupt("return", { | ||
path: path, | ||
query: query | ||
}); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
case 3: | ||
case "end": | ||
return _context.stop(); | ||
} | ||
} | ||
} | ||
}, _callee); | ||
})); | ||
}, _callee); | ||
})); | ||
function effect(_x) { | ||
return _effect.apply(this, arguments); | ||
} | ||
function effect(_x) { | ||
return _effect.apply(this, arguments); | ||
} | ||
return effect; | ||
}() | ||
return effect; | ||
}() | ||
}, | ||
or: { | ||
name: "recheckFx", | ||
sid: "uwz4ln" | ||
} | ||
}); | ||
sample({ | ||
source: recheckFx.doneData, | ||
target: recalculateFx | ||
and: [{ | ||
source: recheckFx.doneData, | ||
target: recalculateFx | ||
}], | ||
or: { | ||
sid: "-hmek8z" | ||
} | ||
}); // Triggered whenever history instance is set | ||
var subscribeHistoryFx = attach({ | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) { | ||
var history, scopedRecheck; | ||
return runtime_1.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
history = _ref12.history; | ||
scopedRecheck = recheckFx; | ||
and: { | ||
source: { | ||
history: $history | ||
}, | ||
effect: function () { | ||
var _effect2 = _asyncToGenerator( /*#__PURE__*/runtime_1.mark(function _callee2(_ref12) { | ||
var history, scopedRecheck; | ||
return runtime_1.wrap(function _callee2$(_context2) { | ||
while (1) { | ||
switch (_context2.prev = _context2.next) { | ||
case 0: | ||
history = _ref12.history; | ||
scopedRecheck = recheckFx; | ||
try { | ||
// @ts-expect-error | ||
scopedRecheck = scopeBind(recheckFx); | ||
} catch (err) {} | ||
try { | ||
// @ts-expect-error | ||
scopedRecheck = scopeBind(recheckFx); | ||
} catch (err) {} | ||
history.listen(function () { | ||
scopedRecheck(); | ||
}); | ||
return _context2.abrupt("return", true); | ||
history.listen(function () { | ||
scopedRecheck(); | ||
}); | ||
return _context2.abrupt("return", true); | ||
case 5: | ||
case "end": | ||
return _context2.stop(); | ||
case 5: | ||
case "end": | ||
return _context2.stop(); | ||
} | ||
} | ||
} | ||
}, _callee2); | ||
})); | ||
}, _callee2); | ||
})); | ||
function effect(_x2) { | ||
return _effect2.apply(this, arguments); | ||
} | ||
function effect(_x2) { | ||
return _effect2.apply(this, arguments); | ||
} | ||
return effect; | ||
}() | ||
return effect; | ||
}() | ||
}, | ||
or: { | ||
name: "subscribeHistoryFx", | ||
sid: "qv1s9u" | ||
} | ||
}); // If `hydrate` flag is set, | ||
@@ -1253,4 +1370,9 @@ // don't trigger recheck on history init | ||
sample({ | ||
clock: subscribeHistoryFx.doneData, | ||
target: recheckFx | ||
and: [{ | ||
clock: subscribeHistoryFx.doneData, | ||
target: recheckFx | ||
}], | ||
or: { | ||
sid: "-glkcec" | ||
} | ||
}); | ||
@@ -1260,4 +1382,9 @@ } | ||
sample({ | ||
clock: $history, | ||
target: subscribeHistoryFx | ||
and: [{ | ||
clock: $history, | ||
target: subscribeHistoryFx | ||
}], | ||
or: { | ||
sid: "-g79p2e" | ||
} | ||
}); | ||
@@ -1264,0 +1391,0 @@ return { |
{ | ||
"version": "0.4.0", | ||
"version": "0.4.1", | ||
"license": "MIT", | ||
@@ -4,0 +4,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
295615
2941