@argon-router/core 0.1.0 → 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 +1 -1
- package/dist/index.d.ts +1 -3
- package/dist/index.js +442 -356
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const c=require("effector"),H=require("patronum");function L(t){let n;const e=c.createEffect(()=>n==null?void 0:n(),{name:"waitForAsyncBundleFx",sid:"sy4dxt"}),r=c.createEffect(async v=>(await e(),t.parent&&await t.parent.internal.openFx(v),v),{name:"openFx",sid:"-vpkil5"}),s=c.createStore({},{name:"$params",sid:"c7nw5"}),a=c.createStore(!1,{name:"$isOpened",sid:"83ksdl"}),o=r.pending,i=c.createEvent({name:"open",sid:"v8jsib"}),l=c.createEvent({name:"close",sid:"-9nrj06"}),u=c.createEvent({name:"opened",sid:"-ddw25k"}),f=c.createEvent({name:"openedOnServer",sid:"rqvufw"}),d=c.createEvent({name:"openedOnClient",sid:"rofchv"}),h=c.createEvent({name:"closed",sid:"-qg25d5"});return c.sample({and:[{clock:i,target:r}],or:{sid:"sbzuux"}}),c.split({and:[{source:r.doneData,match:()=>typeof window>"u"?"server":"client",cases:{server:f,client:d}}],or:{sid:"sqaiab"}}),c.sample({and:[{clock:[d,f],target:u}],or:{sid:"t6sc35"}}),c.sample({and:[{clock:u,fn:()=>!0,target:a}],or:{sid:"t9jb1y"}}),c.sample({and:[{clock:h,fn:()=>!1,target:a}],or:{sid:"todr2p"}}),{$params:s,$isOpened:a,$isPending:o,open:i,closed:h,opened:u,openedOnClient:d,openedOnServer:f,internal:{index:!1,close:l,openFx:r,setAsyncImport:v=>n=v,...t},"@@unitShape":()=>({params:s,isPending:o,isOpened:a,onOpen:i})}}var E={};Object.defineProperty(E,"__esModule",{value:!0});E.TokenData=void 0;E.parse=O;var M=E.compile=W,B=E.match=G;E.pathToRegexp=U;E.stringify=Y;const F="/",N=t=>t,I=/^[$_\p{ID_Start}]$/u,P=/^[$\u200c\u200d\p{ID_Continue}]$/u,R="https://git.new/pathToRegexpError",q={"{":"{","}":"}","(":"(",")":")","[":"[","]":"]","+":"+","?":"?","!":"!"};function J(t){return t.replace(/[{}()\[\]+?!:*]/g,"\\$&")}function b(t){return t.replace(/[.+*?^${}()[\]|/\\]/g,"\\$&")}function*V(t){const n=[...t];let e=0;function r(){let s="";if(I.test(n[++e]))for(s+=n[e];P.test(n[++e]);)s+=n[e];else if(n[e]==='"'){let a=e;for(;e<n.length;){if(n[++e]==='"'){e++,a=0;break}n[e]==="\\"?s+=n[++e]:s+=n[e]}if(a)throw new TypeError(`Unterminated quote at ${a}: ${R}`)}if(!s)throw new TypeError(`Missing parameter name at ${e}: ${R}`);return s}for(;e<n.length;){const s=n[e],a=q[s];if(a)yield{type:a,index:e++,value:s};else if(s==="\\")yield{type:"ESCAPED",index:e++,value:n[e++]};else if(s===":"){const o=r();yield{type:"PARAM",index:e,value:o}}else if(s==="*"){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 Q{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:s}=this.peek();throw new TypeError(`Unexpected ${r} at ${s}, expected ${n}: ${R}`)}text(){let n="",e;for(;e=this.tryConsume("CHAR")||this.tryConsume("ESCAPED");)n+=e;return n}}class A{constructor(n){this.tokens=n}}E.TokenData=A;function O(t,n={}){const{encodePath:e=N}=n,r=new Q(V(t));function s(o){const i=[];for(;;){const l=r.text();l&&i.push({type:"text",value:e(l)});const u=r.tryConsume("PARAM");if(u){i.push({type:"param",name:u});continue}const f=r.tryConsume("WILDCARD");if(f){i.push({type:"wildcard",name:f});continue}if(r.tryConsume("{")){i.push({type:"group",tokens:s("}")});continue}return r.consume(o),i}}const a=s("END");return new A(a)}function W(t,n={}){const{encode:e=encodeURIComponent,delimiter:r=F}=n,s=t instanceof A?t:O(t,n),a=_(s.tokens,r,e);return function(i={}){const[l,...u]=a(i);if(u.length)throw new TypeError(`Missing parameters: ${u.join(", ")}`);return l}}function _(t,n,e){const r=t.map(s=>z(s,n,e));return s=>{const a=[""];for(const o of r){const[i,...l]=o(s);a[0]+=i,a.push(...l)}return a}}function z(t,n,e){if(t.type==="text")return()=>[t.value];if(t.type==="group"){const s=_(t.tokens,n,e);return a=>{const[o,...i]=s(a);return i.length?[""]:[o]}}const r=e||N;return t.type==="wildcard"&&e!==!1?s=>{const a=s[t.name];if(a==null)return["",t.name];if(!Array.isArray(a)||a.length===0)throw new TypeError(`Expected "${t.name}" to be a non-empty array`);return[a.map((o,i)=>{if(typeof o!="string")throw new TypeError(`Expected "${t.name}/${i}" to be a string`);return r(o)}).join(n)]}:s=>{const a=s[t.name];if(a==null)return["",t.name];if(typeof a!="string")throw new TypeError(`Expected "${t.name}" to be a string`);return[r(a)]}}function G(t,n={}){const{decode:e=decodeURIComponent,delimiter:r=F}=n,{regexp:s,keys:a}=U(t,n),o=a.map(i=>e===!1?N:i.type==="param"?e:l=>l.split(r).map(e));return function(l){const u=s.exec(l);if(!u)return!1;const f=u[0],d=Object.create(null);for(let h=1;h<u.length;h++){if(u[h]===void 0)continue;const v=a[h-1],k=o[h-1];d[v.name]=k(u[h])}return{path:f,params:d}}}function U(t,n={}){const{delimiter:e=F,end:r=!0,sensitive:s=!1,trailing:a=!0}=n,o=[],i=[],l=s?"":"i",f=(Array.isArray(t)?t:[t]).map(v=>v instanceof A?v:O(v,n));for(const{tokens:v}of f)for(const k of S(v,0,[])){const T=K(k,e,o);i.push(T)}let d=`^(?:${i.join("|")})`;return a&&(d+=`(?:${b(e)}$)?`),d+=r?"$":`(?=${b(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 s=e.slice();for(const a of S(r.tokens,0,s))yield*S(t,n+1,a)}else e.push(r);yield*S(t,n+1,e)}function K(t,n,e){let r="",s="",a=!0;for(let o=0;o<t.length;o++){const i=t[o];if(i.type==="text"){r+=b(i.value),s+=i.value,a||(a=i.value.includes(n));continue}if(i.type==="param"||i.type==="wildcard"){if(!a&&!s)throw new TypeError(`Missing text after "${i.name}": ${R}`);i.type==="param"?r+=`(${X(n,a?"":s)}+)`:r+="([\\s\\S]+)",e.push(i),s="",a=!1;continue}}return r}function X(t,n){return n.length<2?t.length<2?`[^${b(t+n)}]`:`(?:(?!${b(t)})[^${b(n)}])`:t.length<2?`(?:(?!${b(n)})[^${b(t)}])`:`(?:(?!${b(n)}|${b(t)})[\\s\\S])`}function Y(t){return t.tokens.map(function n(e,r,s){if(e.type==="text")return J(e.value);if(e.type==="group")return`{${e.tokens.map(n).join("")}}`;const o=Z(e.name)&&ee(s[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 Z(t){const[n,...e]=t;return I.test(n)?e.every(r=>P.test(r)):!1}function ee(t){return(t==null?void 0:t.type)!=="text"?!0:!P.test(t.value[0])}const te=Symbol("any"),ne=Symbol("number"),re=Symbol("string"),se=Symbol("array"),$={any:te,number:ne,string:re,array:se};function C(t,n){for(const e of t)if(!n.includes(e))return!1;return!0}function D(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 $.any:{if(!t[e])return!1;break}case $.string:{if(!t[e]||Array.isArray(t[e]))return!1;break}case $.array:{if(!t[e]||!Array.isArray(t[e]))return!1;break}case $.number:{if(!t[e]||Array.isArray(t[e])||isNaN(parseInt(t[e]))&&isNaN(parseFloat(t[e])))return!1;break}}}return!0}function ae(t,n){const e={};for(const r in n){const s=n[r],a=t[r];if(Array.isArray(s)){e[r]=a==="1"||a==="true";continue}switch(typeof s){case"number":{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}case"object":{e[r]=JSON.parse(a);break}case"string":e[r]=t[r];case"boolean":{const o=t[r];e[r]=o==="0"?parseFloat(o):parseInt(o);break}}switch(s){case $.any:case $.string:case $.array:{e[r]=t[r];break}case $.number:{const o=t[r];e[r]=isNaN(parseInt(o))?parseFloat(o):parseInt(o);break}}}return e}function oe(t,n){return e=>{const{parameters:r,forRoutes:s}=e,a=c.createEvent({name:"entered",sid:"-d3obu6"}),o=c.createEvent({name:"exited",sid:"-xofyk3"}),i=c.createEvent({name:"exit",sid:"-673d76"});return c.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:f}=l;return(!s||C(s,u))&&D(f,r)},fn:l=>{let{query:u}=l;return ae(u,r)}}],or:{sid:"-so0f9q"}}),c.sample({and:[{source:{activeRoutes:t,query:n},filter:l=>{let{activeRoutes:u,query:f}=l;return!((!s||C(s,u))&&D(f,r))},target:o}],or:{sid:"-s82e29"}}),{entered:a,exited:o,exit:i,getPayload:l=>Object.entries(l).reduce((u,f)=>{let[d,h]=f;return typeof r[d]=="symbol"?u[d]=h:u[d]=r[d],u},{})}}}function ie(t){const{base:n="/",history:e,routes:r}=t,s=c.createStore({},{name:"$query",sid:"2wd7x1"}),a=c.createStore(e??null,{name:"$history",sid:"31majq"}),o=c.createStore("/",{name:"$path",sid:"ld3nhr"}),i=c.createStore([],{name:"$activeRoutes",sid:"mrug12"}),l=c.createEvent({name:"setHistory",sid:"sekwlw"}),u=c.createEvent({name:"back",sid:"-icnnoo"}),f=c.createEvent({name:"forward",sid:"-72o1my"}),d=c.createEvent({name:"locationUpdated",sid:"d8lu52"}),h=r.map(m=>{let g=m;const p=[];for(p.unshift(g.internal.path);g.internal.parent;)g=g.internal.parent,p.unshift(g.internal.path);const y=(n==="/"?p:[n,...p]).join("");return{route:m,path:y,toPath:M(y),fromPath:B(y)}}),v=c.attach({and:{source:{history:a},effect:async(m,g)=>{let{history:p}=m,{path:y,query:x,replace:w}=g;if(!p)throw new Error("history not found");const j={pathname:y,query:x};w?p.replace(j):p.push(j)}},or:{name:"updateHistoryFx",sid:"h74tsu"}});for(const{route:m,toPath:g}of h)c.sample({and:[{clock:m.opened,source:i,fn:p=>[...p,m],target:i}],or:{sid:"-px1r6l"}}),c.sample({and:[{clock:m.opened,fn:p=>{let{params:y,query:x,replace:w}=p;return{path:g(y),query:x??{},replace:w}},target:v}],or:{sid:"-phnikh"}}),c.sample({and:[{clock:m.closed,source:i,fn:p=>p.filter(y=>y!==m),target:i}],or:{sid:"e0gjjf"}});c.sample({and:[{clock:l,target:a}],or:{sid:"egekp6"}});const k=c.createEffect(m=>{const g=c.scopeBind(d);if(!m)throw new Error;m.listen(p=>{let{location:y}=p;g(y)})},{name:"subscribeHistoryFx",sid:"5cocq6"}),T=c.attach({and:{source:{query:s,path:o},effect:async m=>{let{query:g,path:p}=m;for(const{route:y,fromPath:x}of h){const w=x(p);if(w)await y.internal.openFx({query:g,params:w.params});else continue}}},or:{name:"openRoutesByPathFx",sid:"tmly43"}});return c.sample({and:[{clock:a,filter:Boolean,target:k}],or:{sid:"fwn12h"}}),c.sample({and:[{clock:d,fn:m=>{let{pathname:g,search:p}=m;const y=new URLSearchParams(p);return{path:g,query:[...y.keys()].reduce((x,w)=>(x[w]?x[w]=y.getAll(w):x[w]=y.get(w),x),{})}},target:c.withFactory({sid:"f47wtp",fn:()=>H.spread({targets:{path:o,query:s}}),name:"target",method:"spread"})}],or:{sid:"gbhh38"}}),c.sample({and:[{clock:o,target:T}],or:{sid:"hcvhfs"}}),{$query:s,$path:o,$activeRoutes:i,back:u,forward:f,routes:r,setHistory:l,mappedRoutes:h,trackQuery:oe(i,s),"@@unitShape":()=>({query:s,path:o,activeRoutes:i,onBack:u,onForward:f})}}exports.createRoute=L;exports.createRouter=ie;exports.parameters=$;
|
|
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.d.ts
CHANGED
|
@@ -17,8 +17,7 @@ declare const arraySymbol: unique symbol;
|
|
|
17
17
|
declare interface Config<T> {
|
|
18
18
|
path: T;
|
|
19
19
|
parent?: Route<any>;
|
|
20
|
-
|
|
21
|
-
beforeOpen?: Effect<any, any, any>[];
|
|
20
|
+
beforeOpen?: Effect<void, any, any>[];
|
|
22
21
|
}
|
|
23
22
|
|
|
24
23
|
export declare function createRoute<T extends string, Params = ParseUrlParams<T>>(config: Config<T>): Route<Params>;
|
|
@@ -109,7 +108,6 @@ export declare interface Router {
|
|
|
109
108
|
|
|
110
109
|
declare interface RouterConfig {
|
|
111
110
|
base?: string;
|
|
112
|
-
history?: History_2;
|
|
113
111
|
routes: Route<any>[];
|
|
114
112
|
}
|
|
115
113
|
|
package/dist/index.js
CHANGED
|
@@ -1,118 +1,176 @@
|
|
|
1
|
-
import { createEffect as
|
|
2
|
-
import { spread as
|
|
3
|
-
function
|
|
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
|
+
import { spread as L } from "patronum";
|
|
3
|
+
function B(t, n) {
|
|
4
|
+
var e = Object.keys(t);
|
|
5
|
+
if (Object.getOwnPropertySymbols) {
|
|
6
|
+
var r = Object.getOwnPropertySymbols(t);
|
|
7
|
+
n && (r = r.filter(function(s) {
|
|
8
|
+
return Object.getOwnPropertyDescriptor(t, s).enumerable;
|
|
9
|
+
})), e.push.apply(e, r);
|
|
10
|
+
}
|
|
11
|
+
return e;
|
|
12
|
+
}
|
|
13
|
+
function T(t) {
|
|
14
|
+
for (var n = 1; n < arguments.length; n++) {
|
|
15
|
+
var e = arguments[n] != null ? arguments[n] : {};
|
|
16
|
+
n % 2 ? B(Object(e), !0).forEach(function(r) {
|
|
17
|
+
W(t, r, e[r]);
|
|
18
|
+
}) : Object.getOwnPropertyDescriptors ? Object.defineProperties(t, Object.getOwnPropertyDescriptors(e)) : B(Object(e)).forEach(function(r) {
|
|
19
|
+
Object.defineProperty(t, r, Object.getOwnPropertyDescriptor(e, r));
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return t;
|
|
23
|
+
}
|
|
24
|
+
function W(t, n, e) {
|
|
25
|
+
return (n = G(n)) in t ? Object.defineProperty(t, n, { value: e, enumerable: !0, configurable: !0, writable: !0 }) : t[n] = e, t;
|
|
26
|
+
}
|
|
27
|
+
function G(t) {
|
|
28
|
+
var n = X(t, "string");
|
|
29
|
+
return typeof n == "symbol" ? n : n + "";
|
|
30
|
+
}
|
|
31
|
+
function X(t, n) {
|
|
32
|
+
if (typeof t != "object" || !t) return t;
|
|
33
|
+
var e = t[Symbol.toPrimitive];
|
|
34
|
+
if (e !== void 0) {
|
|
35
|
+
var r = e.call(t, n || "default");
|
|
36
|
+
if (typeof r != "object") return r;
|
|
37
|
+
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
38
|
+
}
|
|
39
|
+
return (n === "string" ? String : Number)(t);
|
|
40
|
+
}
|
|
41
|
+
function ve(t) {
|
|
4
42
|
let n;
|
|
5
|
-
const e =
|
|
43
|
+
const e = j(() => {
|
|
44
|
+
var y;
|
|
45
|
+
return (y = n) === null || y === void 0 ? void 0 : y();
|
|
46
|
+
}, {
|
|
6
47
|
name: "waitForAsyncBundleFx",
|
|
7
|
-
sid: "
|
|
8
|
-
}), r =
|
|
48
|
+
sid: "hl1gh5"
|
|
49
|
+
}), r = j(async () => {
|
|
50
|
+
for (const l of (y = t.beforeOpen) !== null && y !== void 0 ? y : []) {
|
|
51
|
+
var y;
|
|
52
|
+
await l();
|
|
53
|
+
}
|
|
54
|
+
}, {
|
|
55
|
+
name: "beforeOpenFx",
|
|
56
|
+
sid: "jez0xa"
|
|
57
|
+
}), s = j(async (y) => (await e(), await r(), t.parent && await t.parent.internal.openFx(T(T({}, y), {}, {
|
|
58
|
+
historyIgnore: !0
|
|
59
|
+
})), y), {
|
|
9
60
|
name: "openFx",
|
|
10
|
-
sid: "-
|
|
11
|
-
}),
|
|
61
|
+
sid: "-uafnek"
|
|
62
|
+
}), o = O({}, {
|
|
12
63
|
name: "$params",
|
|
13
|
-
sid: "
|
|
14
|
-
}), a =
|
|
64
|
+
sid: "dlh2xl"
|
|
65
|
+
}), a = O(!1, {
|
|
15
66
|
name: "$isOpened",
|
|
16
|
-
sid: "
|
|
17
|
-
}),
|
|
67
|
+
sid: "lcu7f1"
|
|
68
|
+
}), i = s.pending, u = v({
|
|
18
69
|
name: "open",
|
|
19
|
-
sid: "
|
|
20
|
-
}),
|
|
70
|
+
sid: "-qjaufd"
|
|
71
|
+
}), c = v({
|
|
21
72
|
name: "close",
|
|
22
|
-
sid: "-
|
|
23
|
-
}),
|
|
73
|
+
sid: "-6cg68t"
|
|
74
|
+
}), d = v({
|
|
24
75
|
name: "opened",
|
|
25
|
-
sid: "-
|
|
26
|
-
}),
|
|
76
|
+
sid: "-a2kpe7"
|
|
77
|
+
}), f = v({
|
|
27
78
|
name: "openedOnServer",
|
|
28
|
-
sid: "
|
|
29
|
-
}),
|
|
79
|
+
sid: "-u0yshs"
|
|
80
|
+
}), h = v({
|
|
30
81
|
name: "openedOnClient",
|
|
31
|
-
sid: "
|
|
32
|
-
}),
|
|
82
|
+
sid: "-u3faft"
|
|
83
|
+
}), w = v({
|
|
33
84
|
name: "closed",
|
|
34
|
-
sid: "-
|
|
85
|
+
sid: "-d6sqbp"
|
|
35
86
|
});
|
|
36
|
-
return
|
|
87
|
+
return g({
|
|
37
88
|
and: [{
|
|
38
|
-
clock:
|
|
39
|
-
target:
|
|
89
|
+
clock: u,
|
|
90
|
+
target: s
|
|
40
91
|
}],
|
|
41
92
|
or: {
|
|
42
|
-
sid: "
|
|
93
|
+
sid: "sre3h1"
|
|
43
94
|
}
|
|
44
|
-
}),
|
|
95
|
+
}), V({
|
|
45
96
|
and: [{
|
|
46
|
-
source:
|
|
97
|
+
source: s.doneData,
|
|
47
98
|
match: () => typeof window > "u" ? "server" : "client",
|
|
48
99
|
cases: {
|
|
49
|
-
server:
|
|
50
|
-
client:
|
|
100
|
+
server: f,
|
|
101
|
+
client: h
|
|
51
102
|
}
|
|
52
103
|
}],
|
|
53
104
|
or: {
|
|
54
|
-
sid: "
|
|
105
|
+
sid: "t5oqwf"
|
|
55
106
|
}
|
|
56
|
-
}),
|
|
107
|
+
}), g({
|
|
57
108
|
and: [{
|
|
58
|
-
clock: [
|
|
59
|
-
target:
|
|
109
|
+
clock: [h, f],
|
|
110
|
+
target: d
|
|
60
111
|
}],
|
|
61
112
|
or: {
|
|
62
|
-
sid: "
|
|
113
|
+
sid: "tamw8o"
|
|
63
114
|
}
|
|
64
|
-
}),
|
|
115
|
+
}), g({
|
|
65
116
|
and: [{
|
|
66
|
-
clock:
|
|
117
|
+
clock: d,
|
|
67
118
|
fn: () => !0,
|
|
68
119
|
target: a
|
|
69
120
|
}],
|
|
70
121
|
or: {
|
|
71
|
-
sid: "
|
|
122
|
+
sid: "toxjo2"
|
|
123
|
+
}
|
|
124
|
+
}), g({
|
|
125
|
+
and: [{
|
|
126
|
+
clock: c,
|
|
127
|
+
target: w
|
|
128
|
+
}],
|
|
129
|
+
or: {
|
|
130
|
+
sid: "u3rzot"
|
|
72
131
|
}
|
|
73
|
-
}),
|
|
132
|
+
}), g({
|
|
74
133
|
and: [{
|
|
75
|
-
clock:
|
|
134
|
+
clock: w,
|
|
76
135
|
fn: () => !1,
|
|
77
136
|
target: a
|
|
78
137
|
}],
|
|
79
138
|
or: {
|
|
80
|
-
sid: "
|
|
139
|
+
sid: "u6iynm"
|
|
81
140
|
}
|
|
82
141
|
}), {
|
|
83
|
-
$params:
|
|
142
|
+
$params: o,
|
|
84
143
|
$isOpened: a,
|
|
85
|
-
$isPending:
|
|
86
|
-
open:
|
|
87
|
-
closed:
|
|
88
|
-
opened:
|
|
89
|
-
openedOnClient:
|
|
90
|
-
openedOnServer:
|
|
91
|
-
internal: {
|
|
144
|
+
$isPending: i,
|
|
145
|
+
open: u,
|
|
146
|
+
closed: w,
|
|
147
|
+
opened: d,
|
|
148
|
+
openedOnClient: h,
|
|
149
|
+
openedOnServer: f,
|
|
150
|
+
internal: T({
|
|
92
151
|
index: !1,
|
|
93
|
-
close:
|
|
94
|
-
openFx:
|
|
95
|
-
setAsyncImport: (
|
|
96
|
-
|
|
97
|
-
},
|
|
152
|
+
close: c,
|
|
153
|
+
openFx: s,
|
|
154
|
+
setAsyncImport: (y) => n = y
|
|
155
|
+
}, t),
|
|
98
156
|
"@@unitShape": () => ({
|
|
99
|
-
params:
|
|
100
|
-
isPending:
|
|
157
|
+
params: o,
|
|
158
|
+
isPending: i,
|
|
101
159
|
isOpened: a,
|
|
102
|
-
onOpen:
|
|
160
|
+
onOpen: u
|
|
103
161
|
})
|
|
104
162
|
};
|
|
105
163
|
}
|
|
106
|
-
var
|
|
107
|
-
Object.defineProperty(
|
|
164
|
+
var k = {};
|
|
165
|
+
Object.defineProperty(k, "__esModule", {
|
|
108
166
|
value: !0
|
|
109
167
|
});
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
var
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
const
|
|
168
|
+
k.TokenData = void 0;
|
|
169
|
+
k.parse = N;
|
|
170
|
+
var Y = k.compile = se, Z = k.match = ae;
|
|
171
|
+
k.pathToRegexp = K;
|
|
172
|
+
k.stringify = ue;
|
|
173
|
+
const F = "/", I = (t) => t, q = /^[$_\p{ID_Start}]$/u, D = /^[$\u200c\u200d\p{ID_Continue}]$/u, A = "https://git.new/pathToRegexpError", ee = {
|
|
116
174
|
// Groups.
|
|
117
175
|
"{": "{",
|
|
118
176
|
"}": "}",
|
|
@@ -125,41 +183,41 @@ const C = "/", D = (t) => t, L = /^[$_\p{ID_Start}]$/u, I = /^[$\u200c\u200d\p{I
|
|
|
125
183
|
"?": "?",
|
|
126
184
|
"!": "!"
|
|
127
185
|
};
|
|
128
|
-
function
|
|
186
|
+
function te(t) {
|
|
129
187
|
return t.replace(/[{}()\[\]+?!:*]/g, "\\$&");
|
|
130
188
|
}
|
|
131
|
-
function
|
|
189
|
+
function x(t) {
|
|
132
190
|
return t.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
133
191
|
}
|
|
134
|
-
function*
|
|
192
|
+
function* ne(t) {
|
|
135
193
|
const n = [...t];
|
|
136
194
|
let e = 0;
|
|
137
195
|
function r() {
|
|
138
196
|
let s = "";
|
|
139
|
-
if (
|
|
140
|
-
for (s += n[e];
|
|
197
|
+
if (q.test(n[++e]))
|
|
198
|
+
for (s += n[e]; D.test(n[++e]); )
|
|
141
199
|
s += n[e];
|
|
142
200
|
else if (n[e] === '"') {
|
|
143
|
-
let
|
|
201
|
+
let o = e;
|
|
144
202
|
for (; e < n.length; ) {
|
|
145
203
|
if (n[++e] === '"') {
|
|
146
|
-
e++,
|
|
204
|
+
e++, o = 0;
|
|
147
205
|
break;
|
|
148
206
|
}
|
|
149
207
|
n[e] === "\\" ? s += n[++e] : s += n[e];
|
|
150
208
|
}
|
|
151
|
-
if (
|
|
152
|
-
throw new TypeError(`Unterminated quote at ${
|
|
209
|
+
if (o)
|
|
210
|
+
throw new TypeError(`Unterminated quote at ${o}: ${A}`);
|
|
153
211
|
}
|
|
154
212
|
if (!s)
|
|
155
|
-
throw new TypeError(`Missing parameter name at ${e}: ${
|
|
213
|
+
throw new TypeError(`Missing parameter name at ${e}: ${A}`);
|
|
156
214
|
return s;
|
|
157
215
|
}
|
|
158
216
|
for (; e < n.length; ) {
|
|
159
|
-
const s = n[e],
|
|
160
|
-
if (
|
|
217
|
+
const s = n[e], o = ee[s];
|
|
218
|
+
if (o)
|
|
161
219
|
yield {
|
|
162
|
-
type:
|
|
220
|
+
type: o,
|
|
163
221
|
index: e++,
|
|
164
222
|
value: s
|
|
165
223
|
};
|
|
@@ -170,18 +228,18 @@ function* X(t) {
|
|
|
170
228
|
value: n[e++]
|
|
171
229
|
};
|
|
172
230
|
else if (s === ":") {
|
|
173
|
-
const
|
|
231
|
+
const a = r();
|
|
174
232
|
yield {
|
|
175
233
|
type: "PARAM",
|
|
176
234
|
index: e,
|
|
177
|
-
value:
|
|
235
|
+
value: a
|
|
178
236
|
};
|
|
179
237
|
} else if (s === "*") {
|
|
180
|
-
const
|
|
238
|
+
const a = r();
|
|
181
239
|
yield {
|
|
182
240
|
type: "WILDCARD",
|
|
183
241
|
index: e,
|
|
184
|
-
value:
|
|
242
|
+
value: a
|
|
185
243
|
};
|
|
186
244
|
} else
|
|
187
245
|
yield {
|
|
@@ -196,7 +254,7 @@ function* X(t) {
|
|
|
196
254
|
value: ""
|
|
197
255
|
};
|
|
198
256
|
}
|
|
199
|
-
class
|
|
257
|
+
class re {
|
|
200
258
|
constructor(n) {
|
|
201
259
|
this.tokens = n;
|
|
202
260
|
}
|
|
@@ -219,7 +277,7 @@ class Y {
|
|
|
219
277
|
type: r,
|
|
220
278
|
index: s
|
|
221
279
|
} = this.peek();
|
|
222
|
-
throw new TypeError(`Unexpected ${r} at ${s}, expected ${n}: ${
|
|
280
|
+
throw new TypeError(`Unexpected ${r} at ${s}, expected ${n}: ${A}`);
|
|
223
281
|
}
|
|
224
282
|
text() {
|
|
225
283
|
let n = "", e;
|
|
@@ -228,17 +286,17 @@ class Y {
|
|
|
228
286
|
return n;
|
|
229
287
|
}
|
|
230
288
|
}
|
|
231
|
-
class
|
|
289
|
+
class R {
|
|
232
290
|
constructor(n) {
|
|
233
291
|
this.tokens = n;
|
|
234
292
|
}
|
|
235
293
|
}
|
|
236
|
-
|
|
237
|
-
function
|
|
294
|
+
k.TokenData = R;
|
|
295
|
+
function N(t, n = {}) {
|
|
238
296
|
const {
|
|
239
|
-
encodePath: e =
|
|
240
|
-
} = n, r = new
|
|
241
|
-
function s(
|
|
297
|
+
encodePath: e = I
|
|
298
|
+
} = n, r = new re(ne(t));
|
|
299
|
+
function s(a) {
|
|
242
300
|
const i = [];
|
|
243
301
|
for (; ; ) {
|
|
244
302
|
const u = r.text();
|
|
@@ -254,11 +312,11 @@ function O(t, n = {}) {
|
|
|
254
312
|
});
|
|
255
313
|
continue;
|
|
256
314
|
}
|
|
257
|
-
const
|
|
258
|
-
if (
|
|
315
|
+
const d = r.tryConsume("WILDCARD");
|
|
316
|
+
if (d) {
|
|
259
317
|
i.push({
|
|
260
318
|
type: "wildcard",
|
|
261
|
-
name:
|
|
319
|
+
name: d
|
|
262
320
|
});
|
|
263
321
|
continue;
|
|
264
322
|
}
|
|
@@ -269,169 +327,169 @@ function O(t, n = {}) {
|
|
|
269
327
|
});
|
|
270
328
|
continue;
|
|
271
329
|
}
|
|
272
|
-
return r.consume(
|
|
330
|
+
return r.consume(a), i;
|
|
273
331
|
}
|
|
274
332
|
}
|
|
275
|
-
const
|
|
276
|
-
return new
|
|
333
|
+
const o = s("END");
|
|
334
|
+
return new R(o);
|
|
277
335
|
}
|
|
278
|
-
function
|
|
336
|
+
function se(t, n = {}) {
|
|
279
337
|
const {
|
|
280
338
|
encode: e = encodeURIComponent,
|
|
281
|
-
delimiter: r =
|
|
282
|
-
} = n, s = t instanceof
|
|
339
|
+
delimiter: r = F
|
|
340
|
+
} = n, s = t instanceof R ? t : N(t, n), o = J(s.tokens, r, e);
|
|
283
341
|
return function(i = {}) {
|
|
284
|
-
const [u, ...c] =
|
|
342
|
+
const [u, ...c] = o(i);
|
|
285
343
|
if (c.length)
|
|
286
344
|
throw new TypeError(`Missing parameters: ${c.join(", ")}`);
|
|
287
345
|
return u;
|
|
288
346
|
};
|
|
289
347
|
}
|
|
290
|
-
function
|
|
291
|
-
const r = t.map((s) =>
|
|
348
|
+
function J(t, n, e) {
|
|
349
|
+
const r = t.map((s) => oe(s, n, e));
|
|
292
350
|
return (s) => {
|
|
293
|
-
const
|
|
294
|
-
for (const
|
|
295
|
-
const [i, ...u] =
|
|
296
|
-
|
|
351
|
+
const o = [""];
|
|
352
|
+
for (const a of r) {
|
|
353
|
+
const [i, ...u] = a(s);
|
|
354
|
+
o[0] += i, o.push(...u);
|
|
297
355
|
}
|
|
298
|
-
return
|
|
356
|
+
return o;
|
|
299
357
|
};
|
|
300
358
|
}
|
|
301
|
-
function
|
|
359
|
+
function oe(t, n, e) {
|
|
302
360
|
if (t.type === "text") return () => [t.value];
|
|
303
361
|
if (t.type === "group") {
|
|
304
|
-
const s =
|
|
305
|
-
return (
|
|
306
|
-
const [
|
|
307
|
-
return i.length ? [""] : [
|
|
362
|
+
const s = J(t.tokens, n, e);
|
|
363
|
+
return (o) => {
|
|
364
|
+
const [a, ...i] = s(o);
|
|
365
|
+
return i.length ? [""] : [a];
|
|
308
366
|
};
|
|
309
367
|
}
|
|
310
|
-
const r = e ||
|
|
368
|
+
const r = e || I;
|
|
311
369
|
return t.type === "wildcard" && e !== !1 ? (s) => {
|
|
312
|
-
const
|
|
313
|
-
if (
|
|
314
|
-
if (!Array.isArray(
|
|
370
|
+
const o = s[t.name];
|
|
371
|
+
if (o == null) return ["", t.name];
|
|
372
|
+
if (!Array.isArray(o) || o.length === 0)
|
|
315
373
|
throw new TypeError(`Expected "${t.name}" to be a non-empty array`);
|
|
316
|
-
return [
|
|
317
|
-
if (typeof
|
|
374
|
+
return [o.map((a, i) => {
|
|
375
|
+
if (typeof a != "string")
|
|
318
376
|
throw new TypeError(`Expected "${t.name}/${i}" to be a string`);
|
|
319
|
-
return r(
|
|
377
|
+
return r(a);
|
|
320
378
|
}).join(n)];
|
|
321
379
|
} : (s) => {
|
|
322
|
-
const
|
|
323
|
-
if (
|
|
324
|
-
if (typeof
|
|
380
|
+
const o = s[t.name];
|
|
381
|
+
if (o == null) return ["", t.name];
|
|
382
|
+
if (typeof o != "string")
|
|
325
383
|
throw new TypeError(`Expected "${t.name}" to be a string`);
|
|
326
|
-
return [r(
|
|
384
|
+
return [r(o)];
|
|
327
385
|
};
|
|
328
386
|
}
|
|
329
|
-
function
|
|
387
|
+
function ae(t, n = {}) {
|
|
330
388
|
const {
|
|
331
389
|
decode: e = decodeURIComponent,
|
|
332
|
-
delimiter: r =
|
|
390
|
+
delimiter: r = F
|
|
333
391
|
} = n, {
|
|
334
392
|
regexp: s,
|
|
335
|
-
keys:
|
|
336
|
-
} =
|
|
393
|
+
keys: o
|
|
394
|
+
} = K(t, n), a = o.map((i) => e === !1 ? I : i.type === "param" ? e : (u) => u.split(r).map(e));
|
|
337
395
|
return function(u) {
|
|
338
396
|
const c = s.exec(u);
|
|
339
397
|
if (!c) return !1;
|
|
340
|
-
const
|
|
341
|
-
for (let
|
|
342
|
-
if (c[
|
|
343
|
-
const
|
|
344
|
-
f[
|
|
398
|
+
const d = c[0], f = /* @__PURE__ */ Object.create(null);
|
|
399
|
+
for (let h = 1; h < c.length; h++) {
|
|
400
|
+
if (c[h] === void 0) continue;
|
|
401
|
+
const w = o[h - 1], y = a[h - 1];
|
|
402
|
+
f[w.name] = y(c[h]);
|
|
345
403
|
}
|
|
346
404
|
return {
|
|
347
|
-
path:
|
|
405
|
+
path: d,
|
|
348
406
|
params: f
|
|
349
407
|
};
|
|
350
408
|
};
|
|
351
409
|
}
|
|
352
|
-
function
|
|
410
|
+
function K(t, n = {}) {
|
|
353
411
|
const {
|
|
354
|
-
delimiter: e =
|
|
412
|
+
delimiter: e = F,
|
|
355
413
|
end: r = !0,
|
|
356
414
|
sensitive: s = !1,
|
|
357
|
-
trailing:
|
|
358
|
-
} = n,
|
|
415
|
+
trailing: o = !0
|
|
416
|
+
} = n, a = [], i = [], u = s ? "" : "i", d = (Array.isArray(t) ? t : [t]).map((w) => w instanceof R ? w : N(w, n));
|
|
359
417
|
for (const {
|
|
360
|
-
tokens:
|
|
361
|
-
} of
|
|
362
|
-
for (const
|
|
363
|
-
const
|
|
364
|
-
i.push(
|
|
418
|
+
tokens: w
|
|
419
|
+
} of d)
|
|
420
|
+
for (const y of P(w, 0, [])) {
|
|
421
|
+
const l = ie(y, e, a);
|
|
422
|
+
i.push(l);
|
|
365
423
|
}
|
|
366
424
|
let f = `^(?:${i.join("|")})`;
|
|
367
|
-
return
|
|
425
|
+
return o && (f += `(?:${x(e)}$)?`), f += r ? "$" : `(?=${x(e)}|$)`, {
|
|
368
426
|
regexp: new RegExp(f, u),
|
|
369
|
-
keys:
|
|
427
|
+
keys: a
|
|
370
428
|
};
|
|
371
429
|
}
|
|
372
|
-
function*
|
|
430
|
+
function* P(t, n, e) {
|
|
373
431
|
if (n === t.length)
|
|
374
432
|
return yield e;
|
|
375
433
|
const r = t[n];
|
|
376
434
|
if (r.type === "group") {
|
|
377
435
|
const s = e.slice();
|
|
378
|
-
for (const
|
|
379
|
-
yield*
|
|
436
|
+
for (const o of P(r.tokens, 0, s))
|
|
437
|
+
yield* P(t, n + 1, o);
|
|
380
438
|
} else
|
|
381
439
|
e.push(r);
|
|
382
|
-
yield*
|
|
440
|
+
yield* P(t, n + 1, e);
|
|
383
441
|
}
|
|
384
|
-
function
|
|
385
|
-
let r = "", s = "",
|
|
386
|
-
for (let
|
|
387
|
-
const i = t[
|
|
442
|
+
function ie(t, n, e) {
|
|
443
|
+
let r = "", s = "", o = !0;
|
|
444
|
+
for (let a = 0; a < t.length; a++) {
|
|
445
|
+
const i = t[a];
|
|
388
446
|
if (i.type === "text") {
|
|
389
|
-
r +=
|
|
447
|
+
r += x(i.value), s += i.value, o || (o = i.value.includes(n));
|
|
390
448
|
continue;
|
|
391
449
|
}
|
|
392
450
|
if (i.type === "param" || i.type === "wildcard") {
|
|
393
|
-
if (!
|
|
394
|
-
throw new TypeError(`Missing text after "${i.name}": ${
|
|
395
|
-
i.type === "param" ? r += `(${
|
|
451
|
+
if (!o && !s)
|
|
452
|
+
throw new TypeError(`Missing text after "${i.name}": ${A}`);
|
|
453
|
+
i.type === "param" ? r += `(${ce(n, o ? "" : s)}+)` : r += "([\\s\\S]+)", e.push(i), s = "", o = !1;
|
|
396
454
|
continue;
|
|
397
455
|
}
|
|
398
456
|
}
|
|
399
457
|
return r;
|
|
400
458
|
}
|
|
401
|
-
function
|
|
402
|
-
return n.length < 2 ? t.length < 2 ? `[^${
|
|
459
|
+
function ce(t, n) {
|
|
460
|
+
return n.length < 2 ? t.length < 2 ? `[^${x(t + n)}]` : `(?:(?!${x(t)})[^${x(n)}])` : t.length < 2 ? `(?:(?!${x(n)})[^${x(t)}])` : `(?:(?!${x(n)}|${x(t)})[\\s\\S])`;
|
|
403
461
|
}
|
|
404
|
-
function
|
|
462
|
+
function ue(t) {
|
|
405
463
|
return t.tokens.map(function n(e, r, s) {
|
|
406
|
-
if (e.type === "text") return
|
|
464
|
+
if (e.type === "text") return te(e.value);
|
|
407
465
|
if (e.type === "group")
|
|
408
466
|
return `{${e.tokens.map(n).join("")}}`;
|
|
409
|
-
const
|
|
410
|
-
if (e.type === "param") return `:${
|
|
411
|
-
if (e.type === "wildcard") return `*${
|
|
467
|
+
const a = le(e.name) && pe(s[r + 1]) ? e.name : JSON.stringify(e.name);
|
|
468
|
+
if (e.type === "param") return `:${a}`;
|
|
469
|
+
if (e.type === "wildcard") return `*${a}`;
|
|
412
470
|
throw new TypeError(`Unexpected token: ${e}`);
|
|
413
471
|
}).join("");
|
|
414
472
|
}
|
|
415
|
-
function
|
|
473
|
+
function le(t) {
|
|
416
474
|
const [n, ...e] = t;
|
|
417
|
-
return
|
|
475
|
+
return q.test(n) ? e.every((r) => D.test(r)) : !1;
|
|
418
476
|
}
|
|
419
|
-
function
|
|
420
|
-
return (t == null ? void 0 : t.type) !== "text" ? !0 : !
|
|
477
|
+
function pe(t) {
|
|
478
|
+
return (t == null ? void 0 : t.type) !== "text" ? !0 : !D.test(t.value[0]);
|
|
421
479
|
}
|
|
422
|
-
const
|
|
423
|
-
any:
|
|
424
|
-
number:
|
|
425
|
-
string:
|
|
426
|
-
array:
|
|
480
|
+
const fe = Symbol("any"), de = Symbol("number"), ye = Symbol("string"), me = Symbol("array"), $ = {
|
|
481
|
+
any: fe,
|
|
482
|
+
number: de,
|
|
483
|
+
string: ye,
|
|
484
|
+
array: me
|
|
427
485
|
};
|
|
428
|
-
function
|
|
486
|
+
function H(t, n) {
|
|
429
487
|
for (const e of t)
|
|
430
488
|
if (!n.includes(e))
|
|
431
489
|
return !1;
|
|
432
490
|
return !0;
|
|
433
491
|
}
|
|
434
|
-
function
|
|
492
|
+
function z(t, n) {
|
|
435
493
|
for (const e in n) {
|
|
436
494
|
const r = n[e];
|
|
437
495
|
if (Array.isArray(r) && (!t[e] || JSON.stringify(r) !== t[e]))
|
|
@@ -459,22 +517,22 @@ function H(t, n) {
|
|
|
459
517
|
}
|
|
460
518
|
}
|
|
461
519
|
switch (r) {
|
|
462
|
-
case
|
|
520
|
+
case $.any: {
|
|
463
521
|
if (!t[e])
|
|
464
522
|
return !1;
|
|
465
523
|
break;
|
|
466
524
|
}
|
|
467
|
-
case
|
|
525
|
+
case $.string: {
|
|
468
526
|
if (!t[e] || Array.isArray(t[e]))
|
|
469
527
|
return !1;
|
|
470
528
|
break;
|
|
471
529
|
}
|
|
472
|
-
case
|
|
530
|
+
case $.array: {
|
|
473
531
|
if (!t[e] || !Array.isArray(t[e]))
|
|
474
532
|
return !1;
|
|
475
533
|
break;
|
|
476
534
|
}
|
|
477
|
-
case
|
|
535
|
+
case $.number: {
|
|
478
536
|
if (!t[e] || Array.isArray(t[e]) || isNaN(parseInt(t[e])) && isNaN(parseFloat(t[e])))
|
|
479
537
|
return !1;
|
|
480
538
|
break;
|
|
@@ -483,64 +541,64 @@ function H(t, n) {
|
|
|
483
541
|
}
|
|
484
542
|
return !0;
|
|
485
543
|
}
|
|
486
|
-
function
|
|
544
|
+
function he(t, n) {
|
|
487
545
|
const e = {};
|
|
488
546
|
for (const r in n) {
|
|
489
|
-
const s = n[r],
|
|
547
|
+
const s = n[r], o = t[r];
|
|
490
548
|
if (Array.isArray(s)) {
|
|
491
|
-
e[r] =
|
|
549
|
+
e[r] = o === "1" || o === "true";
|
|
492
550
|
continue;
|
|
493
551
|
}
|
|
494
552
|
switch (typeof s) {
|
|
495
553
|
case "number": {
|
|
496
|
-
const
|
|
497
|
-
e[r] = isNaN(parseInt(
|
|
554
|
+
const a = t[r];
|
|
555
|
+
e[r] = isNaN(parseInt(a)) ? parseFloat(a) : parseInt(a);
|
|
498
556
|
break;
|
|
499
557
|
}
|
|
500
558
|
case "object": {
|
|
501
|
-
e[r] = JSON.parse(
|
|
559
|
+
e[r] = JSON.parse(o);
|
|
502
560
|
break;
|
|
503
561
|
}
|
|
504
562
|
case "string":
|
|
505
563
|
e[r] = t[r];
|
|
506
564
|
case "boolean": {
|
|
507
|
-
const
|
|
508
|
-
e[r] =
|
|
565
|
+
const a = t[r];
|
|
566
|
+
e[r] = a === "0" ? parseFloat(a) : parseInt(a);
|
|
509
567
|
break;
|
|
510
568
|
}
|
|
511
569
|
}
|
|
512
570
|
switch (s) {
|
|
513
|
-
case
|
|
514
|
-
case
|
|
515
|
-
case
|
|
571
|
+
case $.any:
|
|
572
|
+
case $.string:
|
|
573
|
+
case $.array: {
|
|
516
574
|
e[r] = t[r];
|
|
517
575
|
break;
|
|
518
576
|
}
|
|
519
|
-
case
|
|
520
|
-
const
|
|
521
|
-
e[r] = isNaN(parseInt(
|
|
577
|
+
case $.number: {
|
|
578
|
+
const a = t[r];
|
|
579
|
+
e[r] = isNaN(parseInt(a)) ? parseFloat(a) : parseInt(a);
|
|
522
580
|
break;
|
|
523
581
|
}
|
|
524
582
|
}
|
|
525
583
|
}
|
|
526
584
|
return e;
|
|
527
585
|
}
|
|
528
|
-
function
|
|
586
|
+
function ge(t, n) {
|
|
529
587
|
return (e) => {
|
|
530
588
|
const {
|
|
531
589
|
parameters: r,
|
|
532
590
|
forRoutes: s
|
|
533
|
-
} = e,
|
|
591
|
+
} = e, o = v({
|
|
534
592
|
name: "entered",
|
|
535
593
|
sid: "-d3obu6"
|
|
536
|
-
}),
|
|
594
|
+
}), a = v({
|
|
537
595
|
name: "exited",
|
|
538
596
|
sid: "-xofyk3"
|
|
539
|
-
}), i =
|
|
597
|
+
}), i = v({
|
|
540
598
|
name: "exit",
|
|
541
599
|
sid: "-673d76"
|
|
542
600
|
});
|
|
543
|
-
return
|
|
601
|
+
return g({
|
|
544
602
|
and: [{
|
|
545
603
|
source: {
|
|
546
604
|
activeRoutes: t,
|
|
@@ -549,21 +607,21 @@ function fe(t, n) {
|
|
|
549
607
|
filter: (u) => {
|
|
550
608
|
let {
|
|
551
609
|
activeRoutes: c,
|
|
552
|
-
query:
|
|
610
|
+
query: d
|
|
553
611
|
} = u;
|
|
554
|
-
return (!s ||
|
|
612
|
+
return (!s || H(s, c)) && z(d, r);
|
|
555
613
|
},
|
|
556
614
|
fn: (u) => {
|
|
557
615
|
let {
|
|
558
616
|
query: c
|
|
559
617
|
} = u;
|
|
560
|
-
return
|
|
618
|
+
return he(c, r);
|
|
561
619
|
}
|
|
562
620
|
}],
|
|
563
621
|
or: {
|
|
564
622
|
sid: "-so0f9q"
|
|
565
623
|
}
|
|
566
|
-
}),
|
|
624
|
+
}), g({
|
|
567
625
|
and: [{
|
|
568
626
|
source: {
|
|
569
627
|
activeRoutes: t,
|
|
@@ -572,221 +630,249 @@ function fe(t, n) {
|
|
|
572
630
|
filter: (u) => {
|
|
573
631
|
let {
|
|
574
632
|
activeRoutes: c,
|
|
575
|
-
query:
|
|
633
|
+
query: d
|
|
576
634
|
} = u;
|
|
577
|
-
return !((!s ||
|
|
635
|
+
return !((!s || H(s, c)) && z(d, r));
|
|
578
636
|
},
|
|
579
|
-
target:
|
|
637
|
+
target: a
|
|
580
638
|
}],
|
|
581
639
|
or: {
|
|
582
640
|
sid: "-s82e29"
|
|
583
641
|
}
|
|
584
642
|
}), {
|
|
585
|
-
entered:
|
|
586
|
-
exited:
|
|
643
|
+
entered: o,
|
|
644
|
+
exited: a,
|
|
587
645
|
exit: i,
|
|
588
|
-
getPayload: (u) => Object.entries(u).reduce((c,
|
|
589
|
-
let [f,
|
|
590
|
-
return typeof r[f] == "symbol" ? c[f] =
|
|
646
|
+
getPayload: (u) => Object.entries(u).reduce((c, d) => {
|
|
647
|
+
let [f, h] = d;
|
|
648
|
+
return typeof r[f] == "symbol" ? c[f] = h : c[f] = r[f], c;
|
|
591
649
|
}, {})
|
|
592
650
|
};
|
|
593
651
|
};
|
|
594
652
|
}
|
|
595
|
-
function
|
|
653
|
+
function M(t) {
|
|
654
|
+
const n = new URLSearchParams(t.search);
|
|
655
|
+
return {
|
|
656
|
+
path: t.pathname,
|
|
657
|
+
query: [...n.keys()].reduce((e, r) => (e[r] ? e[r] = n.getAll(r) : e[r] = n.get(r), e), {})
|
|
658
|
+
};
|
|
659
|
+
}
|
|
660
|
+
function xe(t) {
|
|
596
661
|
const {
|
|
597
662
|
base: n = "/",
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
}), a = S(e ?? null, {
|
|
663
|
+
routes: e
|
|
664
|
+
} = t, r = O(null, {
|
|
665
|
+
and: {
|
|
666
|
+
serialize: "ignore"
|
|
667
|
+
},
|
|
604
668
|
name: "$history",
|
|
605
|
-
sid: "
|
|
606
|
-
}),
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
669
|
+
sid: "u16r0t"
|
|
670
|
+
}), s = O([], {
|
|
671
|
+
and: {
|
|
672
|
+
serialize: "ignore"
|
|
673
|
+
},
|
|
610
674
|
name: "$activeRoutes",
|
|
611
|
-
sid: "
|
|
612
|
-
}),
|
|
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({
|
|
613
683
|
name: "setHistory",
|
|
614
|
-
sid: "
|
|
615
|
-
}),
|
|
684
|
+
sid: "-omtidu"
|
|
685
|
+
}), u = v({
|
|
616
686
|
name: "back",
|
|
617
|
-
sid: "-
|
|
618
|
-
}),
|
|
687
|
+
sid: "-cy0pa"
|
|
688
|
+
}), c = v({
|
|
619
689
|
name: "forward",
|
|
620
|
-
sid: "
|
|
621
|
-
}),
|
|
690
|
+
sid: "kuznmj"
|
|
691
|
+
}), d = v({
|
|
622
692
|
name: "locationUpdated",
|
|
623
|
-
sid: "
|
|
624
|
-
}),
|
|
625
|
-
let
|
|
626
|
-
const
|
|
627
|
-
for (
|
|
628
|
-
|
|
629
|
-
const
|
|
693
|
+
sid: "-tuuikl"
|
|
694
|
+
}), f = e.map((l) => {
|
|
695
|
+
let b = l;
|
|
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("");
|
|
630
700
|
return {
|
|
631
|
-
route:
|
|
632
|
-
path:
|
|
633
|
-
toPath:
|
|
634
|
-
fromPath:
|
|
701
|
+
route: l,
|
|
702
|
+
path: m,
|
|
703
|
+
toPath: Y(m),
|
|
704
|
+
fromPath: Z(m)
|
|
635
705
|
};
|
|
636
|
-
}),
|
|
706
|
+
}), h = C({
|
|
637
707
|
and: {
|
|
638
708
|
source: {
|
|
639
|
-
history:
|
|
709
|
+
history: r
|
|
640
710
|
},
|
|
641
|
-
effect: async (
|
|
711
|
+
effect: async (l, b) => {
|
|
642
712
|
let {
|
|
643
|
-
history:
|
|
644
|
-
} =
|
|
645
|
-
path:
|
|
646
|
-
query:
|
|
647
|
-
replace:
|
|
648
|
-
} =
|
|
649
|
-
if (!
|
|
713
|
+
history: p
|
|
714
|
+
} = l, {
|
|
715
|
+
path: m,
|
|
716
|
+
query: S,
|
|
717
|
+
replace: E
|
|
718
|
+
} = b;
|
|
719
|
+
if (!p)
|
|
650
720
|
throw new Error("history not found");
|
|
651
|
-
const
|
|
652
|
-
pathname:
|
|
653
|
-
query:
|
|
721
|
+
const _ = {
|
|
722
|
+
pathname: m,
|
|
723
|
+
query: S
|
|
654
724
|
};
|
|
655
|
-
|
|
725
|
+
E ? p.replace(_) : p.push(_.pathname);
|
|
656
726
|
}
|
|
657
727
|
},
|
|
658
728
|
or: {
|
|
659
729
|
name: "updateHistoryFx",
|
|
660
|
-
sid: "
|
|
730
|
+
sid: "-oh6nq8"
|
|
661
731
|
}
|
|
662
732
|
});
|
|
663
733
|
for (const {
|
|
664
|
-
route:
|
|
665
|
-
toPath:
|
|
666
|
-
} of
|
|
667
|
-
|
|
734
|
+
route: l,
|
|
735
|
+
toPath: b
|
|
736
|
+
} of f)
|
|
737
|
+
g({
|
|
668
738
|
and: [{
|
|
669
|
-
clock:
|
|
670
|
-
source:
|
|
671
|
-
|
|
672
|
-
|
|
739
|
+
clock: l.opened,
|
|
740
|
+
source: s,
|
|
741
|
+
filter: (p) => !p.includes(l),
|
|
742
|
+
fn: (p) => [...p, l],
|
|
743
|
+
target: s
|
|
673
744
|
}],
|
|
674
745
|
or: {
|
|
675
|
-
sid: "
|
|
746
|
+
sid: "e23xbi"
|
|
676
747
|
}
|
|
677
|
-
}),
|
|
748
|
+
}), g({
|
|
678
749
|
and: [{
|
|
679
|
-
clock:
|
|
680
|
-
|
|
750
|
+
clock: l.opened,
|
|
751
|
+
filter: (p) => !p.historyIgnore,
|
|
752
|
+
fn: function() {
|
|
681
753
|
let {
|
|
682
|
-
params:
|
|
683
|
-
query:
|
|
684
|
-
replace:
|
|
685
|
-
} =
|
|
754
|
+
params: p,
|
|
755
|
+
query: m,
|
|
756
|
+
replace: S
|
|
757
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
758
|
+
params: {}
|
|
759
|
+
};
|
|
686
760
|
return {
|
|
687
|
-
path:
|
|
688
|
-
query:
|
|
689
|
-
replace:
|
|
761
|
+
path: b(p),
|
|
762
|
+
query: m ?? {},
|
|
763
|
+
replace: S
|
|
690
764
|
};
|
|
691
765
|
},
|
|
692
|
-
target:
|
|
766
|
+
target: h
|
|
693
767
|
}],
|
|
694
768
|
or: {
|
|
695
|
-
sid: "
|
|
769
|
+
sid: "ei1yiz"
|
|
696
770
|
}
|
|
697
|
-
}),
|
|
771
|
+
}), g({
|
|
698
772
|
and: [{
|
|
699
|
-
clock:
|
|
700
|
-
source:
|
|
701
|
-
fn: (
|
|
702
|
-
target:
|
|
773
|
+
clock: l.closed,
|
|
774
|
+
source: s,
|
|
775
|
+
fn: (p) => p.filter((m) => m !== l),
|
|
776
|
+
target: s
|
|
703
777
|
}],
|
|
704
778
|
or: {
|
|
705
|
-
sid: "
|
|
779
|
+
sid: "ezndij"
|
|
706
780
|
}
|
|
707
781
|
});
|
|
708
|
-
|
|
782
|
+
g({
|
|
709
783
|
and: [{
|
|
710
|
-
clock:
|
|
711
|
-
target:
|
|
784
|
+
clock: i,
|
|
785
|
+
target: r
|
|
712
786
|
}],
|
|
713
787
|
or: {
|
|
714
|
-
sid: "
|
|
788
|
+
sid: "ffleoa"
|
|
715
789
|
}
|
|
716
790
|
});
|
|
717
|
-
const
|
|
718
|
-
const
|
|
719
|
-
if (!
|
|
791
|
+
const w = j((l) => {
|
|
792
|
+
const b = Q(d);
|
|
793
|
+
if (!l)
|
|
720
794
|
throw new Error();
|
|
721
|
-
|
|
795
|
+
l.listen((p) => {
|
|
722
796
|
let {
|
|
723
|
-
location:
|
|
724
|
-
} =
|
|
725
|
-
|
|
797
|
+
location: m
|
|
798
|
+
} = p;
|
|
799
|
+
b(m);
|
|
726
800
|
});
|
|
727
801
|
}, {
|
|
728
802
|
name: "subscribeHistoryFx",
|
|
729
|
-
sid: "
|
|
730
|
-
}),
|
|
803
|
+
sid: "-zdjw0i"
|
|
804
|
+
}), y = C({
|
|
731
805
|
and: {
|
|
732
806
|
source: {
|
|
733
|
-
query:
|
|
734
|
-
path:
|
|
807
|
+
query: o,
|
|
808
|
+
path: a
|
|
735
809
|
},
|
|
736
|
-
effect: async (
|
|
810
|
+
effect: async (l) => {
|
|
737
811
|
let {
|
|
738
|
-
query:
|
|
739
|
-
path:
|
|
740
|
-
} =
|
|
812
|
+
query: b,
|
|
813
|
+
path: p
|
|
814
|
+
} = l;
|
|
741
815
|
for (const {
|
|
742
|
-
route:
|
|
743
|
-
fromPath:
|
|
744
|
-
} of
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
await
|
|
748
|
-
query:
|
|
749
|
-
params:
|
|
816
|
+
route: m,
|
|
817
|
+
fromPath: S
|
|
818
|
+
} of f) {
|
|
819
|
+
const E = S(p);
|
|
820
|
+
if (E)
|
|
821
|
+
await m.internal.openFx({
|
|
822
|
+
query: b,
|
|
823
|
+
params: E.params
|
|
750
824
|
});
|
|
751
|
-
else
|
|
825
|
+
else {
|
|
826
|
+
m.internal.close();
|
|
752
827
|
continue;
|
|
828
|
+
}
|
|
753
829
|
}
|
|
754
830
|
}
|
|
755
831
|
},
|
|
756
832
|
or: {
|
|
757
833
|
name: "openRoutesByPathFx",
|
|
758
|
-
sid: "
|
|
834
|
+
sid: "-15o8ci"
|
|
759
835
|
}
|
|
760
836
|
});
|
|
761
|
-
return
|
|
837
|
+
return g({
|
|
762
838
|
and: [{
|
|
763
|
-
clock:
|
|
839
|
+
clock: r,
|
|
764
840
|
filter: Boolean,
|
|
765
|
-
target:
|
|
841
|
+
target: w
|
|
766
842
|
}],
|
|
767
843
|
or: {
|
|
768
|
-
sid: "
|
|
844
|
+
sid: "gwdnmy"
|
|
769
845
|
}
|
|
770
|
-
}),
|
|
846
|
+
}), g({
|
|
771
847
|
and: [{
|
|
772
|
-
clock:
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
848
|
+
clock: r,
|
|
849
|
+
filter: Boolean,
|
|
850
|
+
fn: (l) => M(l.location),
|
|
851
|
+
target: U({
|
|
852
|
+
sid: "tbkknj",
|
|
853
|
+
fn: () => L({
|
|
854
|
+
targets: {
|
|
855
|
+
path: a,
|
|
856
|
+
query: o
|
|
857
|
+
}
|
|
858
|
+
}),
|
|
859
|
+
name: "target",
|
|
860
|
+
method: "spread"
|
|
861
|
+
})
|
|
862
|
+
}],
|
|
863
|
+
or: {
|
|
864
|
+
sid: "hb83np"
|
|
865
|
+
}
|
|
866
|
+
}), g({
|
|
867
|
+
and: [{
|
|
868
|
+
clock: [d],
|
|
869
|
+
fn: (l) => M(l),
|
|
870
|
+
target: U({
|
|
871
|
+
sid: "-qk3kpd",
|
|
872
|
+
fn: () => L({
|
|
787
873
|
targets: {
|
|
788
|
-
path:
|
|
789
|
-
query:
|
|
874
|
+
path: a,
|
|
875
|
+
query: o
|
|
790
876
|
}
|
|
791
877
|
}),
|
|
792
878
|
name: "target",
|
|
@@ -794,37 +880,37 @@ function he(t) {
|
|
|
794
880
|
})
|
|
795
881
|
}],
|
|
796
882
|
or: {
|
|
797
|
-
sid: "
|
|
883
|
+
sid: "htdb8m"
|
|
798
884
|
}
|
|
799
|
-
}),
|
|
885
|
+
}), g({
|
|
800
886
|
and: [{
|
|
801
|
-
clock:
|
|
802
|
-
target:
|
|
887
|
+
clock: a,
|
|
888
|
+
target: y
|
|
803
889
|
}],
|
|
804
890
|
or: {
|
|
805
|
-
sid: "
|
|
891
|
+
sid: "iayq86"
|
|
806
892
|
}
|
|
807
893
|
}), {
|
|
808
|
-
$query:
|
|
809
|
-
$path:
|
|
810
|
-
$activeRoutes:
|
|
811
|
-
back:
|
|
812
|
-
forward:
|
|
813
|
-
routes:
|
|
814
|
-
setHistory:
|
|
815
|
-
mappedRoutes:
|
|
816
|
-
trackQuery:
|
|
894
|
+
$query: o,
|
|
895
|
+
$path: a,
|
|
896
|
+
$activeRoutes: s,
|
|
897
|
+
back: u,
|
|
898
|
+
forward: c,
|
|
899
|
+
routes: e,
|
|
900
|
+
setHistory: i,
|
|
901
|
+
mappedRoutes: f,
|
|
902
|
+
trackQuery: ge(s, o),
|
|
817
903
|
"@@unitShape": () => ({
|
|
818
|
-
query:
|
|
819
|
-
path:
|
|
820
|
-
activeRoutes:
|
|
821
|
-
onBack:
|
|
822
|
-
onForward:
|
|
904
|
+
query: o,
|
|
905
|
+
path: a,
|
|
906
|
+
activeRoutes: s,
|
|
907
|
+
onBack: u,
|
|
908
|
+
onForward: c
|
|
823
909
|
})
|
|
824
910
|
};
|
|
825
911
|
}
|
|
826
912
|
export {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
913
|
+
ve as createRoute,
|
|
914
|
+
xe as createRouter,
|
|
915
|
+
$ as parameters
|
|
830
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.
|
|
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": "
|
|
58
|
+
"gitHead": "1b46e0c9601dbefe0ba9c29b062237403e5502c3"
|
|
59
59
|
}
|