@argon-router/core 0.1.2 → 0.1.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.cjs CHANGED
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("effector"),D=require("patronum");function N(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),e.push.apply(e,r)}return e}function j(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?N(Object(e),!0).forEach(function(r){M(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):N(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function M(t,n,e){return(n=z(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function z(t){var n=q(t,"string");return typeof n=="symbol"?n:n+""}function q(t,n){if(typeof t!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function J(t){let n;const e=i.createEffect(()=>{var y;return(y=n)===null||y===void 0?void 0:y()},{name:"waitForAsyncBundleFx",sid:"hl1gh5"}),r=i.createEffect(async()=>{for(const p of(y=t.beforeOpen)!==null&&y!==void 0?y:[]){var y;await p()}},{name:"beforeOpenFx",sid:"jez0xa"}),a=i.createEffect(async y=>(await e(),await r(),t.parent&&await t.parent.internal.openFx(j(j({},y),{},{historyIgnore:!0})),y),{name:"openFx",sid:"-uafnek"}),s=i.createStore({},{name:"$params",sid:"dlh2xl"}),o=i.createStore(!1,{name:"$isOpened",sid:"lcu7f1"}),c=a.pending,l=i.createEvent({name:"open",sid:"-qjaufd"}),u=i.createEvent({name:"close",sid:"-6cg68t"}),m=i.createEvent({name:"opened",sid:"-a2kpe7"}),d=i.createEvent({name:"openedOnServer",sid:"-u0yshs"}),g=i.createEvent({name:"openedOnClient",sid:"-u3faft"}),b=i.createEvent({name:"closed",sid:"-d6sqbp"});return i.sample({and:[{clock:l,target:a}],or:{sid:"sre3h1"}}),i.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:d,client:g}}],or:{sid:"t5oqwf"}}),i.sample({and:[{clock:[g,d],target:m}],or:{sid:"tamw8o"}}),i.sample({and:[{clock:m,fn:()=>!0,target:o}],or:{sid:"toxjo2"}}),i.sample({and:[{clock:u,target:b}],or:{sid:"u3rzot"}}),i.sample({and:[{clock:b,fn:()=>!1,target:o}],or:{sid:"u6iynm"}}),{$params:s,$isOpened:o,$isPending:c,open:l,closed:b,opened:m,openedOnClient:g,openedOnServer:d,internal:j({index:!1,close:u,openFx:a,setAsyncImport:y=>n=y},t),"@@unitShape":()=>({params:s,isPending:c,isOpened:o,onOpen:l})}}var E={};Object.defineProperty(E,"__esModule",{value:!0});E.TokenData=void 0;E.parse=F;var K=E.compile=Y,V=E.match=ee;E.pathToRegexp=H;E.stringify=re;const R="/",A=t=>t,L=/^[$_\p{ID_Start}]$/u,T=/^[$\u200c\u200d\p{ID_Continue}]$/u,O="https://git.new/pathToRegexpError",Q={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function W(t){return t.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function w(t){return t.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*G(t){const n=[...t];let e=0;function r(){let a="";if(L.test(n[++e]))for(a+=n[e];T.test(n[++e]);)a+=n[e];else if(n[e]==='"'){let s=e;for(;e<n.length;){if(n[++e]==='"'){e++,s=0;break}n[e]==="\\"?a+=n[++e]:a+=n[e]}if(s)throw new TypeError(`Unterminated quote at ${s}: ${O}`)}if(!a)throw new TypeError(`Missing parameter name at ${e}: ${O}`);return a}for(;e<n.length;){const a=n[e],s=Q[a];if(s)yield{type:s,index:e++,value:a};else if(a==="\\")yield{type:"ESCAPED",index:e++,value:n[e++]};else if(a===":"){const o=r();yield{type:"PARAM",index:e,value:o}}else if(a==="*"){const o=r();yield{type:"WILDCARD",index:e,value:o}}else yield{type:"CHAR",index:e,value:n[e++]}}return{type:"END",index:e,value:""}}class X{constructor(n){this.tokens=n}peek(){if(!this._peek){const n=this.tokens.next();this._peek=n.value}return this._peek}tryConsume(n){const e=this.peek();if(e.type===n)return this._peek=void 0,e.value}consume(n){const e=this.tryConsume(n);if(e!==void 0)return e;const{type:r,index:a}=this.peek();throw new TypeError(`Unexpected ${r} at ${a}, expected ${n}: ${O}`)}text(){let n="",e;for(;e=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)n+=e;return n}}class P{constructor(n){this.tokens=n}}E.TokenData=P;function F(t,n={}){const{encodePath:e=A}=n,r=new X(G(t));function a(o){const c=[];for(;;){const l=r.text();l&&c.push({type:"text",value:e(l)});const u=r.tryConsume("PARAM");if(u){c.push({type:"param",name:u});continue}const m=r.tryConsume("WILDCARD");if(m){c.push({type:"wildcard",name:m});continue}if(r.tryConsume("{")){c.push({type:"group",tokens:a("}")});continue}return r.consume(o),c}}const s=a("END");return new P(s)}function Y(t,n={}){const{encode:e=encodeURIComponent,delimiter:r=R}=n,a=t instanceof P?t:F(t,n),s=B(a.tokens,r,e);return function(c={}){const[l,...u]=s(c);if(u.length)throw new TypeError(`Missing parameters: ${u.join(", ")}`);return l}}function B(t,n,e){const r=t.map(a=>Z(a,n,e));return a=>{const s=[""];for(const o of r){const[c,...l]=o(a);s[0]+=c,s.push(...l)}return s}}function Z(t,n,e){if(t.type==="text")return()=>[t.value];if(t.type==="group"){const a=B(t.tokens,n,e);return s=>{const[o,...c]=a(s);return c.length?[""]:[o]}}const r=e||A;return t.type==="wildcard"&&e!==!1?a=>{const s=a[t.name];if(s==null)return["",t.name];if(!Array.isArray(s)||s.length===0)throw new TypeError(`Expected "${t.name}" to be a non-empty array`);return[s.map((o,c)=>{if(typeof o!="string")throw new TypeError(`Expected "${t.name}/${c}" to be a string`);return r(o)}).join(n)]}:a=>{const s=a[t.name];if(s==null)return["",t.name];if(typeof s!="string")throw new TypeError(`Expected "${t.name}" to be a string`);return[r(s)]}}function ee(t,n={}){const{decode:e=decodeURIComponent,delimiter:r=R}=n,{regexp:a,keys:s}=H(t,n),o=s.map(c=>e===!1?A:c.type==="param"?e:l=>l.split(r).map(e));return function(l){const u=a.exec(l);if(!u)return!1;const m=u[0],d=Object.create(null);for(let g=1;g<u.length;g++){if(u[g]===void 0)continue;const b=s[g-1],y=o[g-1];d[b.name]=y(u[g])}return{path:m,params:d}}}function H(t,n={}){const{delimiter:e=R,end:r=!0,sensitive:a=!1,trailing:s=!0}=n,o=[],c=[],l=a?"":"i",m=(Array.isArray(t)?t:[t]).map(b=>b instanceof P?b:F(b,n));for(const{tokens:b}of m)for(const y of S(b,0,[])){const p=te(y,e,o);c.push(p)}let d=`^(?:${c.join("|")})`;return s&&(d+=`(?:${w(e)}$)?`),d+=r?"$":`(?=${w(e)}|$)`,{regexp:new RegExp(d,l),keys:o}}function*S(t,n,e){if(n===t.length)return yield e;const r=t[n];if(r.type==="group"){const a=e.slice();for(const s of S(r.tokens,0,a))yield*S(t,n+1,s)}else e.push(r);yield*S(t,n+1,e)}function te(t,n,e){let r="",a="",s=!0;for(let o=0;o<t.length;o++){const c=t[o];if(c.type==="text"){r+=w(c.value),a+=c.value,s||(s=c.value.includes(n));continue}if(c.type==="param"||c.type==="wildcard"){if(!s&&!a)throw new TypeError(`Missing text after "${c.name}": ${O}`);c.type==="param"?r+=`(${ne(n,s?"":a)}+)`:r+="([\\s\\S]+)",e.push(c),a="",s=!1;continue}}return r}function ne(t,n){return n.length<2?t.length<2?`[^${w(t+n)}]`:`(?:(?!${w(t)})[^${w(n)}])`:t.length<2?`(?:(?!${w(n)})[^${w(t)}])`:`(?:(?!${w(n)}|${w(t)})[\\s\\S])`}function re(t){return t.tokens.map(function n(e,r,a){if(e.type==="text")return W(e.value);if(e.type==="group")return`{${e.tokens.map(n).join("")}}`;const o=ae(e.name)&&se(a[r+1])?e.name:JSON.stringify(e.name);if(e.type==="param")return`:${o}`;if(e.type==="wildcard")return`*${o}`;throw new TypeError(`Unexpected token: ${e}`)}).join("")}function ae(t){const[n,...e]=t;return L.test(n)?e.every(r=>T.test(r)):!1}function se(t){return(t==null?void 0:t.type)!=="text"?!0:!T.test(t.value[0])}const oe=Symbol("any"),ie=Symbol("number"),ce=Symbol("string"),ue=Symbol("array"),x={any:oe,number:ie,string:ce,array:ue};function _(t,n){for(const e of t)if(!n.includes(e))return!1;return!0}function C(t,n){for(const e in n){const r=n[e];if(Array.isArray(r)&&(!t[e]||JSON.stringify(r)!==t[e]))return!1;switch(typeof r){case"number":{if(!t[e]||r.toString()!==t[e])return!1;break}case"object":{if(!t[e]||JSON.stringify(r)!==t[e])return!1;break}case"string":{if(!t[e]||r!==t[e])return!1;break}case"boolean":{if(!t[e]||!["0","1","false","true"].includes(t[e]))return!1;break}}switch(r){case x.any:{if(!t[e])return!1;break}case x.string:{if(!t[e]||Array.isArray(t[e]))return!1;break}case x.array:{if(!t[e]||!Array.isArray(t[e]))return!1;break}case x.number:{if(!t[e]||Array.isArray(t[e])||isNaN(parseInt(t[e]))&&isNaN(parseFloat(t[e])))return!1;break}}}return!0}function le(t,n){const e={};for(const r in n){const a=n[r],s=t[r];if(Array.isArray(a)){e[r]=s==="1"||s==="true";continue}switch(typeof a){case"number":{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}case"object":{e[r]=JSON.parse(s);break}case"string":e[r]=t[r];case"boolean":{const o=t[r];e[r]=o==="0"?parseFloat(o):parseInt(o);break}}switch(a){case x.any:case x.string:case x.array:{e[r]=t[r];break}case x.number:{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}}}return e}function pe(t,n){return e=>{const{parameters:r,forRoutes:a}=e,s=i.createEvent({name:"entered",sid:"-d3obu6"}),o=i.createEvent({name:"exited",sid:"-xofyk3"}),c=i.createEvent({name:"exit",sid:"-673d76"});return i.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:m}=l;return(!a||_(a,u))&&C(m,r)},fn:l=>{let{query:u}=l;return le(u,r)}}],or:{sid:"-so0f9q"}}),i.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:m}=l;return!((!a||_(a,u))&&C(m,r))},target:o}],or:{sid:"-s82e29"}}),{entered:s,exited:o,exit:c,getPayload:l=>Object.entries(l).reduce((u,m)=>{let[d,g]=m;return typeof r[d]=="symbol"?u[d]=g:u[d]=r[d],u},{})}}}function U(t){const n=new URLSearchParams(t.search);return{path:t.pathname,query:[...n.keys()].reduce((e,r)=>(e[r]?e[r]=n.getAll(r):e[r]=n.get(r),e),{})}}function fe(t){const{base:n="/",routes:e}=t,r=i.createStore({},{name:"$query",sid:"uczasb"}),a=i.createStore(null,{name:"$history",sid:"ui8df0"}),s=i.createStore(null,{name:"$path",sid:"-m7ebm3"}),o=i.createStore([],{name:"$activeRoutes",sid:"-ksnj2s"}),c=i.createEvent({name:"setHistory",sid:"-p3v4s1"}),l=i.createEvent({name:"back",sid:"-tzn3h"}),u=i.createEvent({name:"forward",sid:"afzyy9"}),m=i.createEvent({name:"locationUpdated",sid:"-ubw4ys"}),d=e.map(p=>{let v=p;const f=[];for(f.unshift(v.internal.path);v.internal.parent;)v=v.internal.parent,v.internal.path!=="/"&&f.unshift(v.internal.path);const h=n==="/"?f.join(""):[n,...f].join("");return{route:p,path:h,toPath:K(h),fromPath:V(h)}}),g=i.attach({and:{source:{history:a},effect:async(p,v)=>{let{history:f}=p,{path:h,query:$,replace:k}=v;if(!f)throw new Error("history not found");const I={pathname:h,query:$};k?f.replace(I):f.push(I.pathname)}},or:{name:"updateHistoryFx",sid:"-oy8a4f"}});for(const{route:p,toPath:v}of d)i.sample({and:[{clock:p.opened,source:o,filter:f=>!f.includes(p),fn:f=>[...f,p],target:o}],or:{sid:"e1k4q5"}}),i.sample({and:[{clock:p.opened,filter:f=>!f.historyIgnore,fn:function(){let{params:f,query:h,replace:$}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{params:{}};return{path:v(f),query:h??{},replace:$}},target:g}],or:{sid:"ehi5xm"}}),i.sample({and:[{clock:p.closed,source:o,fn:f=>f.filter(h=>h!==p),target:o}],or:{sid:"ez3kx6"}});i.sample({and:[{clock:c,target:a}],or:{sid:"ff1m2x"}});const b=i.createEffect(p=>{const v=i.scopeBind(m);if(!p)throw new Error;p.listen(f=>{let{location:h}=f;v(h)})},{name:"subscribeHistoryFx",sid:"z6ijkf"}),y=i.attach({and:{source:{query:r,path:s},effect:async p=>{let{query:v,path:f}=p;for(const{route:h,fromPath:$}of d){const k=$(f);if(k)await h.internal.openFx({query:v,params:k.params});else{h.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"-1mpuqp"}});return i.sample({and:[{clock:a,filter:Boolean,target:b}],or:{sid:"gvtv1l"}}),i.sample({and:[{clock:a,filter:Boolean,fn:p=>U(p.location),target:i.withFactory({sid:"suiy9c",fn:()=>D.spread({targets:{path:s,query:r}}),name:"target",method:"spread"})}],or:{sid:"haob2c"}}),i.sample({and:[{clock:[m],fn:p=>U(p),target:i.withFactory({sid:"-r1573k",fn:()=>D.spread({targets:{path:s,query:r}}),name:"target",method:"spread"})}],or:{sid:"hstin9"}}),i.sample({and:[{clock:s,target:y}],or:{sid:"iaexmt"}}),{$query:r,$path:s,$activeRoutes:o,back:l,forward:u,routes:e,setHistory:c,mappedRoutes:d,trackQuery:pe(o,r),"@@unitShape":()=>({query:r,path:s,activeRoutes:o,onBack:l,onForward:u})}}exports.createRoute=J;exports.createRouter=fe;exports.parameters=x;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const i=require("effector"),D=require("patronum");function N(t,n){var e=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);n&&(r=r.filter(function(a){return Object.getOwnPropertyDescriptor(t,a).enumerable})),e.push.apply(e,r)}return e}function P(t){for(var n=1;n<arguments.length;n++){var e=arguments[n]!=null?arguments[n]:{};n%2?N(Object(e),!0).forEach(function(r){M(t,r,e[r])}):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(e)):N(Object(e)).forEach(function(r){Object.defineProperty(t,r,Object.getOwnPropertyDescriptor(e,r))})}return t}function M(t,n,e){return(n=q(n))in t?Object.defineProperty(t,n,{value:e,enumerable:!0,configurable:!0,writable:!0}):t[n]=e,t}function q(t){var n=z(t,"string");return typeof n=="symbol"?n:n+""}function z(t,n){if(typeof t!="object"||!t)return t;var e=t[Symbol.toPrimitive];if(e!==void 0){var r=e.call(t,n||"default");if(typeof r!="object")return r;throw new TypeError("@@toPrimitive must return a primitive value.")}return(n==="string"?String:Number)(t)}function J(t){let n;const e=i.createEffect(()=>{var y;return(y=n)===null||y===void 0?void 0:y()},{name:"waitForAsyncBundleFx",sid:"hl1gh5"}),r=i.createEffect(async()=>{for(const p of(y=t.beforeOpen)!==null&&y!==void 0?y:[]){var y;await p()}},{name:"beforeOpenFx",sid:"jez0xa"}),a=i.createEffect(async y=>(await e(),await r(),t.parent&&await t.parent.internal.openFx(P(P({},y),{},{historyIgnore:!0})),y),{name:"openFx",sid:"-uafnek"}),s=i.createStore({},{name:"$params",sid:"dlh2xl"}),o=i.createStore(!1,{name:"$isOpened",sid:"lcu7f1"}),c=a.pending,l=i.createEvent({name:"open",sid:"-qjaufd"}),u=i.createEvent({name:"close",sid:"-6cg68t"}),m=i.createEvent({name:"opened",sid:"-a2kpe7"}),d=i.createEvent({name:"openedOnServer",sid:"-u0yshs"}),g=i.createEvent({name:"openedOnClient",sid:"-u3faft"}),b=i.createEvent({name:"closed",sid:"-d6sqbp"});return i.sample({and:[{clock:l,target:a}],or:{sid:"sre3h1"}}),i.split({and:[{source:a.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:d,client:g}}],or:{sid:"t5oqwf"}}),i.sample({and:[{clock:[g,d],target:m}],or:{sid:"tamw8o"}}),i.sample({and:[{clock:m,fn:()=>!0,target:o}],or:{sid:"toxjo2"}}),i.sample({and:[{clock:u,target:b}],or:{sid:"u3rzot"}}),i.sample({and:[{clock:b,fn:()=>!1,target:o}],or:{sid:"u6iynm"}}),{$params:s,$isOpened:o,$isPending:c,open:l,closed:b,opened:m,openedOnClient:g,openedOnServer:d,internal:P({index:!1,close:u,openFx:a,setAsyncImport:y=>n=y},t),"@@unitShape":()=>({params:s,isPending:c,isOpened:o,onOpen:l})}}var E={};Object.defineProperty(E,"__esModule",{value:!0});E.TokenData=void 0;E.parse=F;var K=E.compile=Y,V=E.match=ee;E.pathToRegexp=H;E.stringify=re;const R="/",A=t=>t,L=/^[$_\p{ID_Start}]$/u,T=/^[$\u200c\u200d\p{ID_Continue}]$/u,O="https://git.new/pathToRegexpError",Q={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function W(t){return t.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function w(t){return t.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*G(t){const n=[...t];let e=0;function r(){let a="";if(L.test(n[++e]))for(a+=n[e];T.test(n[++e]);)a+=n[e];else if(n[e]==='"'){let s=e;for(;e<n.length;){if(n[++e]==='"'){e++,s=0;break}n[e]==="\\"?a+=n[++e]:a+=n[e]}if(s)throw new TypeError(`Unterminated quote at ${s}: ${O}`)}if(!a)throw new TypeError(`Missing parameter name at ${e}: ${O}`);return a}for(;e<n.length;){const a=n[e],s=Q[a];if(s)yield{type:s,index:e++,value:a};else if(a==="\\")yield{type:"ESCAPED",index:e++,value:n[e++]};else if(a===":"){const o=r();yield{type:"PARAM",index:e,value:o}}else if(a==="*"){const o=r();yield{type:"WILDCARD",index:e,value:o}}else yield{type:"CHAR",index:e,value:n[e++]}}return{type:"END",index:e,value:""}}class X{constructor(n){this.tokens=n}peek(){if(!this._peek){const n=this.tokens.next();this._peek=n.value}return this._peek}tryConsume(n){const e=this.peek();if(e.type===n)return this._peek=void 0,e.value}consume(n){const e=this.tryConsume(n);if(e!==void 0)return e;const{type:r,index:a}=this.peek();throw new TypeError(`Unexpected ${r} at ${a}, expected ${n}: ${O}`)}text(){let n="",e;for(;e=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)n+=e;return n}}class j{constructor(n){this.tokens=n}}E.TokenData=j;function F(t,n={}){const{encodePath:e=A}=n,r=new X(G(t));function a(o){const c=[];for(;;){const l=r.text();l&&c.push({type:"text",value:e(l)});const u=r.tryConsume("PARAM");if(u){c.push({type:"param",name:u});continue}const m=r.tryConsume("WILDCARD");if(m){c.push({type:"wildcard",name:m});continue}if(r.tryConsume("{")){c.push({type:"group",tokens:a("}")});continue}return r.consume(o),c}}const s=a("END");return new j(s)}function Y(t,n={}){const{encode:e=encodeURIComponent,delimiter:r=R}=n,a=t instanceof j?t:F(t,n),s=B(a.tokens,r,e);return function(c={}){const[l,...u]=s(c);if(u.length)throw new TypeError(`Missing parameters: ${u.join(", ")}`);return l}}function B(t,n,e){const r=t.map(a=>Z(a,n,e));return a=>{const s=[""];for(const o of r){const[c,...l]=o(a);s[0]+=c,s.push(...l)}return s}}function Z(t,n,e){if(t.type==="text")return()=>[t.value];if(t.type==="group"){const a=B(t.tokens,n,e);return s=>{const[o,...c]=a(s);return c.length?[""]:[o]}}const r=e||A;return t.type==="wildcard"&&e!==!1?a=>{const s=a[t.name];if(s==null)return["",t.name];if(!Array.isArray(s)||s.length===0)throw new TypeError(`Expected "${t.name}" to be a non-empty array`);return[s.map((o,c)=>{if(typeof o!="string")throw new TypeError(`Expected "${t.name}/${c}" to be a string`);return r(o)}).join(n)]}:a=>{const s=a[t.name];if(s==null)return["",t.name];if(typeof s!="string")throw new TypeError(`Expected "${t.name}" to be a string`);return[r(s)]}}function ee(t,n={}){const{decode:e=decodeURIComponent,delimiter:r=R}=n,{regexp:a,keys:s}=H(t,n),o=s.map(c=>e===!1?A:c.type==="param"?e:l=>l.split(r).map(e));return function(l){const u=a.exec(l);if(!u)return!1;const m=u[0],d=Object.create(null);for(let g=1;g<u.length;g++){if(u[g]===void 0)continue;const b=s[g-1],y=o[g-1];d[b.name]=y(u[g])}return{path:m,params:d}}}function H(t,n={}){const{delimiter:e=R,end:r=!0,sensitive:a=!1,trailing:s=!0}=n,o=[],c=[],l=a?"":"i",m=(Array.isArray(t)?t:[t]).map(b=>b instanceof j?b:F(b,n));for(const{tokens:b}of m)for(const y of S(b,0,[])){const p=te(y,e,o);c.push(p)}let d=`^(?:${c.join("|")})`;return s&&(d+=`(?:${w(e)}$)?`),d+=r?"$":`(?=${w(e)}|$)`,{regexp:new RegExp(d,l),keys:o}}function*S(t,n,e){if(n===t.length)return yield e;const r=t[n];if(r.type==="group"){const a=e.slice();for(const s of S(r.tokens,0,a))yield*S(t,n+1,s)}else e.push(r);yield*S(t,n+1,e)}function te(t,n,e){let r="",a="",s=!0;for(let o=0;o<t.length;o++){const c=t[o];if(c.type==="text"){r+=w(c.value),a+=c.value,s||(s=c.value.includes(n));continue}if(c.type==="param"||c.type==="wildcard"){if(!s&&!a)throw new TypeError(`Missing text after "${c.name}": ${O}`);c.type==="param"?r+=`(${ne(n,s?"":a)}+)`:r+="([\\s\\S]+)",e.push(c),a="",s=!1;continue}}return r}function ne(t,n){return n.length<2?t.length<2?`[^${w(t+n)}]`:`(?:(?!${w(t)})[^${w(n)}])`:t.length<2?`(?:(?!${w(n)})[^${w(t)}])`:`(?:(?!${w(n)}|${w(t)})[\\s\\S])`}function re(t){return t.tokens.map(function n(e,r,a){if(e.type==="text")return W(e.value);if(e.type==="group")return`{${e.tokens.map(n).join("")}}`;const o=ae(e.name)&&se(a[r+1])?e.name:JSON.stringify(e.name);if(e.type==="param")return`:${o}`;if(e.type==="wildcard")return`*${o}`;throw new TypeError(`Unexpected token: ${e}`)}).join("")}function ae(t){const[n,...e]=t;return L.test(n)?e.every(r=>T.test(r)):!1}function se(t){return(t==null?void 0:t.type)!=="text"?!0:!T.test(t.value[0])}const oe=Symbol("any"),ie=Symbol("number"),ce=Symbol("string"),ue=Symbol("array"),x={any:oe,number:ie,string:ce,array:ue};function _(t,n){for(const e of t)if(!n.includes(e))return!1;return!0}function C(t,n){for(const e in n){const r=n[e];if(Array.isArray(r)&&(!t[e]||JSON.stringify(r)!==t[e]))return!1;switch(typeof r){case"number":{if(!t[e]||r.toString()!==t[e])return!1;break}case"object":{if(!t[e]||JSON.stringify(r)!==t[e])return!1;break}case"string":{if(!t[e]||r!==t[e])return!1;break}case"boolean":{if(!t[e]||!["0","1","false","true"].includes(t[e]))return!1;break}}switch(r){case x.any:{if(!t[e])return!1;break}case x.string:{if(!t[e]||Array.isArray(t[e]))return!1;break}case x.array:{if(!t[e]||!Array.isArray(t[e]))return!1;break}case x.number:{if(!t[e]||Array.isArray(t[e])||isNaN(parseInt(t[e]))&&isNaN(parseFloat(t[e])))return!1;break}}}return!0}function le(t,n){const e={};for(const r in n){const a=n[r],s=t[r];if(Array.isArray(a)){e[r]=s==="1"||s==="true";continue}switch(typeof a){case"number":{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}case"object":{e[r]=JSON.parse(s);break}case"string":e[r]=t[r];case"boolean":{const o=t[r];e[r]=o==="0"?parseFloat(o):parseInt(o);break}}switch(a){case x.any:case x.string:case x.array:{e[r]=t[r];break}case x.number:{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}}}return e}function pe(t,n){return e=>{const{parameters:r,forRoutes:a}=e,s=i.createEvent({name:"entered",sid:"-d3obu6"}),o=i.createEvent({name:"exited",sid:"-xofyk3"}),c=i.createEvent({name:"exit",sid:"-673d76"});return i.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:m}=l;return(!a||_(a,u))&&C(m,r)},fn:l=>{let{query:u}=l;return le(u,r)}}],or:{sid:"-so0f9q"}}),i.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:m}=l;return!((!a||_(a,u))&&C(m,r))},target:o}],or:{sid:"-s82e29"}}),{entered:s,exited:o,exit:c,getPayload:l=>Object.entries(l).reduce((u,m)=>{let[d,g]=m;return typeof r[d]=="symbol"?u[d]=g:u[d]=r[d],u},{})}}}function U(t){const n=new URLSearchParams(t.search);return{path:t.pathname,query:[...n.keys()].reduce((e,r)=>(e[r]?e[r]=n.getAll(r):e[r]=n.get(r),e),{})}}function fe(t){const{base:n="/",routes:e}=t,r=i.createStore(null,{and:{serialize:"ignore"},name:"$history",sid:"u16r0t"}),a=i.createStore([],{and:{serialize:"ignore"},name:"$activeRoutes",sid:"-lqqrv6"}),s=i.createStore({},{name:"$query",sid:"vs45yw"}),o=i.createStore(null,{name:"$path",sid:"-l9b2tp"}),c=i.createEvent({name:"setHistory",sid:"-omtidu"}),l=i.createEvent({name:"back",sid:"-cy0pa"}),u=i.createEvent({name:"forward",sid:"kuznmj"}),m=i.createEvent({name:"locationUpdated",sid:"-tuuikl"}),d=e.map(p=>{let v=p;const f=[];for(f.unshift(v.internal.path);v.internal.parent;)v=v.internal.parent,v.internal.path!=="/"&&f.unshift(v.internal.path);const h=n==="/"?f.join(""):[n,...f].join("");return{route:p,path:h,toPath:K(h),fromPath:V(h)}}),g=i.attach({and:{source:{history:r},effect:async(p,v)=>{let{history:f}=p,{path:h,query:$,replace:k}=v;if(!f)throw new Error("history not found");const I={pathname:h,query:$};k?f.replace(I):f.push(I.pathname)}},or:{name:"updateHistoryFx",sid:"-oh6nq8"}});for(const{route:p,toPath:v}of d)i.sample({and:[{clock:p.opened,source:a,filter:f=>!f.includes(p),fn:f=>[...f,p],target:a}],or:{sid:"e23xbi"}}),i.sample({and:[{clock:p.opened,filter:f=>!f.historyIgnore,fn:function(){let{params:f,query:h,replace:$}=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{params:{}};return{path:v(f),query:h??{},replace:$}},target:g}],or:{sid:"ei1yiz"}}),i.sample({and:[{clock:p.closed,source:a,fn:f=>f.filter(h=>h!==p),target:a}],or:{sid:"ezndij"}});i.sample({and:[{clock:c,target:r}],or:{sid:"ffleoa"}});const b=i.createEffect(p=>{const v=i.scopeBind(m);if(!p)throw new Error;p.listen(f=>{let{location:h}=f;v(h)})},{name:"subscribeHistoryFx",sid:"-zdjw0i"}),y=i.attach({and:{source:{query:s,path:o},effect:async p=>{let{query:v,path:f}=p;for(const{route:h,fromPath:$}of d){const k=$(f);if(k)await h.internal.openFx({query:v,params:k.params});else{h.internal.close();continue}}}},or:{name:"openRoutesByPathFx",sid:"-15o8ci"}});return i.sample({and:[{clock:r,filter:Boolean,target:b}],or:{sid:"gwdnmy"}}),i.sample({and:[{clock:r,filter:Boolean,fn:p=>U(p.location),target:i.withFactory({sid:"tbkknj",fn:()=>D.spread({targets:{path:o,query:s}}),name:"target",method:"spread"})}],or:{sid:"hb83np"}}),i.sample({and:[{clock:[m],fn:p=>U(p),target:i.withFactory({sid:"-qk3kpd",fn:()=>D.spread({targets:{path:o,query:s}}),name:"target",method:"spread"})}],or:{sid:"htdb8m"}}),i.sample({and:[{clock:o,target:y}],or:{sid:"iayq86"}}),{$query:s,$path:o,$activeRoutes:a,back:l,forward:u,routes:e,setHistory:c,mappedRoutes:d,trackQuery:pe(a,s),"@@unitShape":()=>({query:s,path:o,activeRoutes:a,onBack:l,onForward:u})}}exports.createRoute=J;exports.createRouter=fe;exports.parameters=x;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { createEffect as P, createStore as O, createEvent as w, sample as g, split as V, attach as C, scopeBind as Q, withFactory as U } from "effector";
1
+ import { createEffect as j, createStore as O, createEvent as v, sample as g, split as V, attach as C, scopeBind as Q, withFactory as U } from "effector";
2
2
  import { spread as L } from "patronum";
3
3
  function B(t, n) {
4
4
  var e = Object.keys(t);
@@ -38,15 +38,15 @@ function X(t, n) {
38
38
  }
39
39
  return (n === "string" ? String : Number)(t);
40
40
  }
41
- function we(t) {
41
+ function ve(t) {
42
42
  let n;
43
- const e = P(() => {
43
+ const e = j(() => {
44
44
  var y;
45
45
  return (y = n) === null || y === void 0 ? void 0 : y();
46
46
  }, {
47
47
  name: "waitForAsyncBundleFx",
48
48
  sid: "hl1gh5"
49
- }), r = P(async () => {
49
+ }), r = j(async () => {
50
50
  for (const l of (y = t.beforeOpen) !== null && y !== void 0 ? y : []) {
51
51
  var y;
52
52
  await l();
@@ -54,7 +54,7 @@ function we(t) {
54
54
  }, {
55
55
  name: "beforeOpenFx",
56
56
  sid: "jez0xa"
57
- }), s = P(async (y) => (await e(), await r(), t.parent && await t.parent.internal.openFx(T(T({}, y), {}, {
57
+ }), s = j(async (y) => (await e(), await r(), t.parent && await t.parent.internal.openFx(T(T({}, y), {}, {
58
58
  historyIgnore: !0
59
59
  })), y), {
60
60
  name: "openFx",
@@ -65,22 +65,22 @@ function we(t) {
65
65
  }), a = O(!1, {
66
66
  name: "$isOpened",
67
67
  sid: "lcu7f1"
68
- }), i = s.pending, u = w({
68
+ }), i = s.pending, u = v({
69
69
  name: "open",
70
70
  sid: "-qjaufd"
71
- }), c = w({
71
+ }), c = v({
72
72
  name: "close",
73
73
  sid: "-6cg68t"
74
- }), d = w({
74
+ }), d = v({
75
75
  name: "opened",
76
76
  sid: "-a2kpe7"
77
- }), p = w({
77
+ }), f = v({
78
78
  name: "openedOnServer",
79
79
  sid: "-u0yshs"
80
- }), h = w({
80
+ }), h = v({
81
81
  name: "openedOnClient",
82
82
  sid: "-u3faft"
83
- }), v = w({
83
+ }), w = v({
84
84
  name: "closed",
85
85
  sid: "-d6sqbp"
86
86
  });
@@ -97,7 +97,7 @@ function we(t) {
97
97
  source: s.doneData,
98
98
  match: () => typeof window > "u" ? "server" : "client",
99
99
  cases: {
100
- server: p,
100
+ server: f,
101
101
  client: h
102
102
  }
103
103
  }],
@@ -106,7 +106,7 @@ function we(t) {
106
106
  }
107
107
  }), g({
108
108
  and: [{
109
- clock: [h, p],
109
+ clock: [h, f],
110
110
  target: d
111
111
  }],
112
112
  or: {
@@ -124,14 +124,14 @@ function we(t) {
124
124
  }), g({
125
125
  and: [{
126
126
  clock: c,
127
- target: v
127
+ target: w
128
128
  }],
129
129
  or: {
130
130
  sid: "u3rzot"
131
131
  }
132
132
  }), g({
133
133
  and: [{
134
- clock: v,
134
+ clock: w,
135
135
  fn: () => !1,
136
136
  target: a
137
137
  }],
@@ -143,10 +143,10 @@ function we(t) {
143
143
  $isOpened: a,
144
144
  $isPending: i,
145
145
  open: u,
146
- closed: v,
146
+ closed: w,
147
147
  opened: d,
148
148
  openedOnClient: h,
149
- openedOnServer: p,
149
+ openedOnServer: f,
150
150
  internal: T({
151
151
  index: !1,
152
152
  close: c,
@@ -170,7 +170,7 @@ k.parse = N;
170
170
  var Y = k.compile = se, Z = k.match = ae;
171
171
  k.pathToRegexp = K;
172
172
  k.stringify = ue;
173
- const F = "/", I = (t) => t, J = /^[$_\p{ID_Start}]$/u, D = /^[$\u200c\u200d\p{ID_Continue}]$/u, A = "https://git.new/pathToRegexpError", ee = {
173
+ const F = "/", I = (t) => t, q = /^[$_\p{ID_Start}]$/u, D = /^[$\u200c\u200d\p{ID_Continue}]$/u, A = "https://git.new/pathToRegexpError", ee = {
174
174
  // Groups.
175
175
  "{": "{",
176
176
  "}": "}",
@@ -194,7 +194,7 @@ function* ne(t) {
194
194
  let e = 0;
195
195
  function r() {
196
196
  let s = "";
197
- if (J.test(n[++e]))
197
+ if (q.test(n[++e]))
198
198
  for (s += n[e]; D.test(n[++e]); )
199
199
  s += n[e];
200
200
  else if (n[e] === '"') {
@@ -337,7 +337,7 @@ function se(t, n = {}) {
337
337
  const {
338
338
  encode: e = encodeURIComponent,
339
339
  delimiter: r = F
340
- } = n, s = t instanceof R ? t : N(t, n), o = q(s.tokens, r, e);
340
+ } = n, s = t instanceof R ? t : N(t, n), o = J(s.tokens, r, e);
341
341
  return function(i = {}) {
342
342
  const [u, ...c] = o(i);
343
343
  if (c.length)
@@ -345,7 +345,7 @@ function se(t, n = {}) {
345
345
  return u;
346
346
  };
347
347
  }
348
- function q(t, n, e) {
348
+ function J(t, n, e) {
349
349
  const r = t.map((s) => oe(s, n, e));
350
350
  return (s) => {
351
351
  const o = [""];
@@ -359,7 +359,7 @@ function q(t, n, e) {
359
359
  function oe(t, n, e) {
360
360
  if (t.type === "text") return () => [t.value];
361
361
  if (t.type === "group") {
362
- const s = q(t.tokens, n, e);
362
+ const s = J(t.tokens, n, e);
363
363
  return (o) => {
364
364
  const [a, ...i] = s(o);
365
365
  return i.length ? [""] : [a];
@@ -395,15 +395,15 @@ function ae(t, n = {}) {
395
395
  return function(u) {
396
396
  const c = s.exec(u);
397
397
  if (!c) return !1;
398
- const d = c[0], p = /* @__PURE__ */ Object.create(null);
398
+ const d = c[0], f = /* @__PURE__ */ Object.create(null);
399
399
  for (let h = 1; h < c.length; h++) {
400
400
  if (c[h] === void 0) continue;
401
- const v = o[h - 1], y = a[h - 1];
402
- p[v.name] = y(c[h]);
401
+ const w = o[h - 1], y = a[h - 1];
402
+ f[w.name] = y(c[h]);
403
403
  }
404
404
  return {
405
405
  path: d,
406
- params: p
406
+ params: f
407
407
  };
408
408
  };
409
409
  }
@@ -413,31 +413,31 @@ function K(t, n = {}) {
413
413
  end: r = !0,
414
414
  sensitive: s = !1,
415
415
  trailing: o = !0
416
- } = n, a = [], i = [], u = s ? "" : "i", d = (Array.isArray(t) ? t : [t]).map((v) => v instanceof R ? v : N(v, n));
416
+ } = n, a = [], i = [], u = s ? "" : "i", d = (Array.isArray(t) ? t : [t]).map((w) => w instanceof R ? w : N(w, n));
417
417
  for (const {
418
- tokens: v
418
+ tokens: w
419
419
  } of d)
420
- for (const y of j(v, 0, [])) {
420
+ for (const y of P(w, 0, [])) {
421
421
  const l = ie(y, e, a);
422
422
  i.push(l);
423
423
  }
424
- let p = `^(?:${i.join("|")})`;
425
- return o && (p += `(?:${x(e)}$)?`), p += r ? "$" : `(?=${x(e)}|$)`, {
426
- regexp: new RegExp(p, u),
424
+ let f = `^(?:${i.join("|")})`;
425
+ return o && (f += `(?:${x(e)}$)?`), f += r ? "$" : `(?=${x(e)}|$)`, {
426
+ regexp: new RegExp(f, u),
427
427
  keys: a
428
428
  };
429
429
  }
430
- function* j(t, n, e) {
430
+ function* P(t, n, e) {
431
431
  if (n === t.length)
432
432
  return yield e;
433
433
  const r = t[n];
434
434
  if (r.type === "group") {
435
435
  const s = e.slice();
436
- for (const o of j(r.tokens, 0, s))
437
- yield* j(t, n + 1, o);
436
+ for (const o of P(r.tokens, 0, s))
437
+ yield* P(t, n + 1, o);
438
438
  } else
439
439
  e.push(r);
440
- yield* j(t, n + 1, e);
440
+ yield* P(t, n + 1, e);
441
441
  }
442
442
  function ie(t, n, e) {
443
443
  let r = "", s = "", o = !0;
@@ -464,7 +464,7 @@ function ue(t) {
464
464
  if (e.type === "text") return te(e.value);
465
465
  if (e.type === "group")
466
466
  return `{${e.tokens.map(n).join("")}}`;
467
- const a = le(e.name) && fe(s[r + 1]) ? e.name : JSON.stringify(e.name);
467
+ const a = le(e.name) && pe(s[r + 1]) ? e.name : JSON.stringify(e.name);
468
468
  if (e.type === "param") return `:${a}`;
469
469
  if (e.type === "wildcard") return `*${a}`;
470
470
  throw new TypeError(`Unexpected token: ${e}`);
@@ -472,13 +472,13 @@ function ue(t) {
472
472
  }
473
473
  function le(t) {
474
474
  const [n, ...e] = t;
475
- return J.test(n) ? e.every((r) => D.test(r)) : !1;
475
+ return q.test(n) ? e.every((r) => D.test(r)) : !1;
476
476
  }
477
- function fe(t) {
477
+ function pe(t) {
478
478
  return (t == null ? void 0 : t.type) !== "text" ? !0 : !D.test(t.value[0]);
479
479
  }
480
- const pe = Symbol("any"), de = Symbol("number"), ye = Symbol("string"), me = Symbol("array"), $ = {
481
- any: pe,
480
+ const fe = Symbol("any"), de = Symbol("number"), ye = Symbol("string"), me = Symbol("array"), $ = {
481
+ any: fe,
482
482
  number: de,
483
483
  string: ye,
484
484
  array: me
@@ -489,7 +489,7 @@ function H(t, n) {
489
489
  return !1;
490
490
  return !0;
491
491
  }
492
- function M(t, n) {
492
+ function z(t, n) {
493
493
  for (const e in n) {
494
494
  const r = n[e];
495
495
  if (Array.isArray(r) && (!t[e] || JSON.stringify(r) !== t[e]))
@@ -588,13 +588,13 @@ function ge(t, n) {
588
588
  const {
589
589
  parameters: r,
590
590
  forRoutes: s
591
- } = e, o = w({
591
+ } = e, o = v({
592
592
  name: "entered",
593
593
  sid: "-d3obu6"
594
- }), a = w({
594
+ }), a = v({
595
595
  name: "exited",
596
596
  sid: "-xofyk3"
597
- }), i = w({
597
+ }), i = v({
598
598
  name: "exit",
599
599
  sid: "-673d76"
600
600
  });
@@ -609,7 +609,7 @@ function ge(t, n) {
609
609
  activeRoutes: c,
610
610
  query: d
611
611
  } = u;
612
- return (!s || H(s, c)) && M(d, r);
612
+ return (!s || H(s, c)) && z(d, r);
613
613
  },
614
614
  fn: (u) => {
615
615
  let {
@@ -632,7 +632,7 @@ function ge(t, n) {
632
632
  activeRoutes: c,
633
633
  query: d
634
634
  } = u;
635
- return !((!s || H(s, c)) && M(d, r));
635
+ return !((!s || H(s, c)) && z(d, r));
636
636
  },
637
637
  target: a
638
638
  }],
@@ -644,13 +644,13 @@ function ge(t, n) {
644
644
  exited: a,
645
645
  exit: i,
646
646
  getPayload: (u) => Object.entries(u).reduce((c, d) => {
647
- let [p, h] = d;
648
- return typeof r[p] == "symbol" ? c[p] = h : c[p] = r[p], c;
647
+ let [f, h] = d;
648
+ return typeof r[f] == "symbol" ? c[f] = h : c[f] = r[f], c;
649
649
  }, {})
650
650
  };
651
651
  };
652
652
  }
653
- function z(t) {
653
+ function M(t) {
654
654
  const n = new URLSearchParams(t.search);
655
655
  return {
656
656
  path: t.pathname,
@@ -661,36 +661,42 @@ function xe(t) {
661
661
  const {
662
662
  base: n = "/",
663
663
  routes: e
664
- } = t, r = O({}, {
665
- name: "$query",
666
- sid: "uczasb"
667
- }), s = O(null, {
664
+ } = t, r = O(null, {
665
+ and: {
666
+ serialize: "ignore"
667
+ },
668
668
  name: "$history",
669
- sid: "ui8df0"
670
- }), o = O(null, {
671
- name: "$path",
672
- sid: "-m7ebm3"
673
- }), a = O([], {
669
+ sid: "u16r0t"
670
+ }), s = O([], {
671
+ and: {
672
+ serialize: "ignore"
673
+ },
674
674
  name: "$activeRoutes",
675
- sid: "-ksnj2s"
676
- }), i = w({
675
+ sid: "-lqqrv6"
676
+ }), o = O({}, {
677
+ name: "$query",
678
+ sid: "vs45yw"
679
+ }), a = O(null, {
680
+ name: "$path",
681
+ sid: "-l9b2tp"
682
+ }), i = v({
677
683
  name: "setHistory",
678
- sid: "-p3v4s1"
679
- }), u = w({
684
+ sid: "-omtidu"
685
+ }), u = v({
680
686
  name: "back",
681
- sid: "-tzn3h"
682
- }), c = w({
687
+ sid: "-cy0pa"
688
+ }), c = v({
683
689
  name: "forward",
684
- sid: "afzyy9"
685
- }), d = w({
690
+ sid: "kuznmj"
691
+ }), d = v({
686
692
  name: "locationUpdated",
687
- sid: "-ubw4ys"
688
- }), p = e.map((l) => {
693
+ sid: "-tuuikl"
694
+ }), f = e.map((l) => {
689
695
  let b = l;
690
- const f = [];
691
- for (f.unshift(b.internal.path); b.internal.parent; )
692
- b = b.internal.parent, b.internal.path !== "/" && f.unshift(b.internal.path);
693
- const m = n === "/" ? f.join("") : [n, ...f].join("");
696
+ const p = [];
697
+ for (p.unshift(b.internal.path); b.internal.parent; )
698
+ b = b.internal.parent, b.internal.path !== "/" && p.unshift(b.internal.path);
699
+ const m = n === "/" ? p.join("") : [n, ...p].join("");
694
700
  return {
695
701
  route: l,
696
702
  path: m,
@@ -700,59 +706,59 @@ function xe(t) {
700
706
  }), h = C({
701
707
  and: {
702
708
  source: {
703
- history: s
709
+ history: r
704
710
  },
705
711
  effect: async (l, b) => {
706
712
  let {
707
- history: f
713
+ history: p
708
714
  } = l, {
709
715
  path: m,
710
716
  query: S,
711
717
  replace: E
712
718
  } = b;
713
- if (!f)
719
+ if (!p)
714
720
  throw new Error("history not found");
715
721
  const _ = {
716
722
  pathname: m,
717
723
  query: S
718
724
  };
719
- E ? f.replace(_) : f.push(_.pathname);
725
+ E ? p.replace(_) : p.push(_.pathname);
720
726
  }
721
727
  },
722
728
  or: {
723
729
  name: "updateHistoryFx",
724
- sid: "-oy8a4f"
730
+ sid: "-oh6nq8"
725
731
  }
726
732
  });
727
733
  for (const {
728
734
  route: l,
729
735
  toPath: b
730
- } of p)
736
+ } of f)
731
737
  g({
732
738
  and: [{
733
739
  clock: l.opened,
734
- source: a,
735
- filter: (f) => !f.includes(l),
736
- fn: (f) => [...f, l],
737
- target: a
740
+ source: s,
741
+ filter: (p) => !p.includes(l),
742
+ fn: (p) => [...p, l],
743
+ target: s
738
744
  }],
739
745
  or: {
740
- sid: "e1k4q5"
746
+ sid: "e23xbi"
741
747
  }
742
748
  }), g({
743
749
  and: [{
744
750
  clock: l.opened,
745
- filter: (f) => !f.historyIgnore,
751
+ filter: (p) => !p.historyIgnore,
746
752
  fn: function() {
747
753
  let {
748
- params: f,
754
+ params: p,
749
755
  query: m,
750
756
  replace: S
751
757
  } = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
752
758
  params: {}
753
759
  };
754
760
  return {
755
- path: b(f),
761
+ path: b(p),
756
762
  query: m ?? {},
757
763
  replace: S
758
764
  };
@@ -760,57 +766,57 @@ function xe(t) {
760
766
  target: h
761
767
  }],
762
768
  or: {
763
- sid: "ehi5xm"
769
+ sid: "ei1yiz"
764
770
  }
765
771
  }), g({
766
772
  and: [{
767
773
  clock: l.closed,
768
- source: a,
769
- fn: (f) => f.filter((m) => m !== l),
770
- target: a
774
+ source: s,
775
+ fn: (p) => p.filter((m) => m !== l),
776
+ target: s
771
777
  }],
772
778
  or: {
773
- sid: "ez3kx6"
779
+ sid: "ezndij"
774
780
  }
775
781
  });
776
782
  g({
777
783
  and: [{
778
784
  clock: i,
779
- target: s
785
+ target: r
780
786
  }],
781
787
  or: {
782
- sid: "ff1m2x"
788
+ sid: "ffleoa"
783
789
  }
784
790
  });
785
- const v = P((l) => {
791
+ const w = j((l) => {
786
792
  const b = Q(d);
787
793
  if (!l)
788
794
  throw new Error();
789
- l.listen((f) => {
795
+ l.listen((p) => {
790
796
  let {
791
797
  location: m
792
- } = f;
798
+ } = p;
793
799
  b(m);
794
800
  });
795
801
  }, {
796
802
  name: "subscribeHistoryFx",
797
- sid: "z6ijkf"
803
+ sid: "-zdjw0i"
798
804
  }), y = C({
799
805
  and: {
800
806
  source: {
801
- query: r,
802
- path: o
807
+ query: o,
808
+ path: a
803
809
  },
804
810
  effect: async (l) => {
805
811
  let {
806
812
  query: b,
807
- path: f
813
+ path: p
808
814
  } = l;
809
815
  for (const {
810
816
  route: m,
811
817
  fromPath: S
812
- } of p) {
813
- const E = S(f);
818
+ } of f) {
819
+ const E = S(p);
814
820
  if (E)
815
821
  await m.internal.openFx({
816
822
  query: b,
@@ -825,29 +831,29 @@ function xe(t) {
825
831
  },
826
832
  or: {
827
833
  name: "openRoutesByPathFx",
828
- sid: "-1mpuqp"
834
+ sid: "-15o8ci"
829
835
  }
830
836
  });
831
837
  return g({
832
838
  and: [{
833
- clock: s,
839
+ clock: r,
834
840
  filter: Boolean,
835
- target: v
841
+ target: w
836
842
  }],
837
843
  or: {
838
- sid: "gvtv1l"
844
+ sid: "gwdnmy"
839
845
  }
840
846
  }), g({
841
847
  and: [{
842
- clock: s,
848
+ clock: r,
843
849
  filter: Boolean,
844
- fn: (l) => z(l.location),
850
+ fn: (l) => M(l.location),
845
851
  target: U({
846
- sid: "suiy9c",
852
+ sid: "tbkknj",
847
853
  fn: () => L({
848
854
  targets: {
849
- path: o,
850
- query: r
855
+ path: a,
856
+ query: o
851
857
  }
852
858
  }),
853
859
  name: "target",
@@ -855,18 +861,18 @@ function xe(t) {
855
861
  })
856
862
  }],
857
863
  or: {
858
- sid: "haob2c"
864
+ sid: "hb83np"
859
865
  }
860
866
  }), g({
861
867
  and: [{
862
868
  clock: [d],
863
- fn: (l) => z(l),
869
+ fn: (l) => M(l),
864
870
  target: U({
865
- sid: "-r1573k",
871
+ sid: "-qk3kpd",
866
872
  fn: () => L({
867
873
  targets: {
868
- path: o,
869
- query: r
874
+ path: a,
875
+ query: o
870
876
  }
871
877
  }),
872
878
  name: "target",
@@ -874,37 +880,37 @@ function xe(t) {
874
880
  })
875
881
  }],
876
882
  or: {
877
- sid: "hstin9"
883
+ sid: "htdb8m"
878
884
  }
879
885
  }), g({
880
886
  and: [{
881
- clock: o,
887
+ clock: a,
882
888
  target: y
883
889
  }],
884
890
  or: {
885
- sid: "iaexmt"
891
+ sid: "iayq86"
886
892
  }
887
893
  }), {
888
- $query: r,
889
- $path: o,
890
- $activeRoutes: a,
894
+ $query: o,
895
+ $path: a,
896
+ $activeRoutes: s,
891
897
  back: u,
892
898
  forward: c,
893
899
  routes: e,
894
900
  setHistory: i,
895
- mappedRoutes: p,
896
- trackQuery: ge(a, r),
901
+ mappedRoutes: f,
902
+ trackQuery: ge(s, o),
897
903
  "@@unitShape": () => ({
898
- query: r,
899
- path: o,
900
- activeRoutes: a,
904
+ query: o,
905
+ path: a,
906
+ activeRoutes: s,
901
907
  onBack: u,
902
908
  onForward: c
903
909
  })
904
910
  };
905
911
  }
906
912
  export {
907
- we as createRoute,
913
+ ve as createRoute,
908
914
  xe as createRouter,
909
915
  $ as parameters
910
916
  };
package/package.json CHANGED
@@ -5,7 +5,7 @@
5
5
  "registry": "https://registry.npmjs.org/"
6
6
  },
7
7
  "private": false,
8
- "version": "0.1.2",
8
+ "version": "0.1.3",
9
9
  "description": "Router with power of effector",
10
10
  "keywords": [
11
11
  "effector",
@@ -55,5 +55,5 @@
55
55
  "path-to-regexp": "^8.2.0",
56
56
  "typed-url-params": "^1.0.1"
57
57
  },
58
- "gitHead": "c5ab346d7c4ed17a58dba0e133895193c93f76d5"
58
+ "gitHead": "1b46e0c9601dbefe0ba9c29b062237403e5502c3"
59
59
  }