@argon-router/core 0.1.0 → 0.1.2
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 +430 -350
- 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 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;
|
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 P, createStore as
|
|
2
|
-
import { spread as
|
|
3
|
-
function
|
|
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";
|
|
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 we(t) {
|
|
4
42
|
let n;
|
|
5
|
-
const e = P(() =>
|
|
43
|
+
const e = P(() => {
|
|
44
|
+
var y;
|
|
45
|
+
return (y = n) === null || y === void 0 ? void 0 : y();
|
|
46
|
+
}, {
|
|
6
47
|
name: "waitForAsyncBundleFx",
|
|
7
|
-
sid: "
|
|
8
|
-
}), r = P(async (
|
|
48
|
+
sid: "hl1gh5"
|
|
49
|
+
}), r = P(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 = P(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 = w({
|
|
18
69
|
name: "open",
|
|
19
|
-
sid: "
|
|
20
|
-
}),
|
|
70
|
+
sid: "-qjaufd"
|
|
71
|
+
}), c = w({
|
|
21
72
|
name: "close",
|
|
22
|
-
sid: "-
|
|
23
|
-
}),
|
|
73
|
+
sid: "-6cg68t"
|
|
74
|
+
}), d = w({
|
|
24
75
|
name: "opened",
|
|
25
|
-
sid: "-
|
|
26
|
-
}), p =
|
|
76
|
+
sid: "-a2kpe7"
|
|
77
|
+
}), p = w({
|
|
27
78
|
name: "openedOnServer",
|
|
28
|
-
sid: "
|
|
29
|
-
}),
|
|
79
|
+
sid: "-u0yshs"
|
|
80
|
+
}), h = w({
|
|
30
81
|
name: "openedOnClient",
|
|
31
|
-
sid: "
|
|
32
|
-
}),
|
|
82
|
+
sid: "-u3faft"
|
|
83
|
+
}), v = w({
|
|
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
100
|
server: p,
|
|
50
|
-
client:
|
|
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, p],
|
|
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: v
|
|
128
|
+
}],
|
|
129
|
+
or: {
|
|
130
|
+
sid: "u3rzot"
|
|
72
131
|
}
|
|
73
|
-
}),
|
|
132
|
+
}), g({
|
|
74
133
|
and: [{
|
|
75
|
-
clock:
|
|
134
|
+
clock: v,
|
|
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:
|
|
144
|
+
$isPending: i,
|
|
145
|
+
open: u,
|
|
146
|
+
closed: v,
|
|
147
|
+
opened: d,
|
|
148
|
+
openedOnClient: h,
|
|
90
149
|
openedOnServer: p,
|
|
91
|
-
internal: {
|
|
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, J = /^[$_\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 (J.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 = q(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 q(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 = q(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
|
-
|
|
398
|
+
const d = c[0], p = /* @__PURE__ */ Object.create(null);
|
|
399
|
+
for (let h = 1; h < c.length; h++) {
|
|
400
|
+
if (c[h] === void 0) continue;
|
|
401
|
+
const v = o[h - 1], y = a[h - 1];
|
|
402
|
+
p[v.name] = y(c[h]);
|
|
345
403
|
}
|
|
346
404
|
return {
|
|
347
|
-
path:
|
|
348
|
-
params:
|
|
405
|
+
path: d,
|
|
406
|
+
params: p
|
|
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((v) => v instanceof R ? v : N(v, n));
|
|
359
417
|
for (const {
|
|
360
|
-
tokens:
|
|
361
|
-
} of
|
|
362
|
-
for (const
|
|
363
|
-
const
|
|
364
|
-
i.push(
|
|
418
|
+
tokens: v
|
|
419
|
+
} of d)
|
|
420
|
+
for (const y of j(v, 0, [])) {
|
|
421
|
+
const l = ie(y, e, a);
|
|
422
|
+
i.push(l);
|
|
365
423
|
}
|
|
366
|
-
let
|
|
367
|
-
return
|
|
368
|
-
regexp: new RegExp(
|
|
369
|
-
keys:
|
|
424
|
+
let p = `^(?:${i.join("|")})`;
|
|
425
|
+
return o && (p += `(?:${x(e)}$)?`), p += r ? "$" : `(?=${x(e)}|$)`, {
|
|
426
|
+
regexp: new RegExp(p, u),
|
|
427
|
+
keys: a
|
|
370
428
|
};
|
|
371
429
|
}
|
|
372
|
-
function*
|
|
430
|
+
function* j(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 j(r.tokens, 0, s))
|
|
437
|
+
yield* j(t, n + 1, o);
|
|
380
438
|
} else
|
|
381
439
|
e.push(r);
|
|
382
|
-
yield*
|
|
440
|
+
yield* j(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) && fe(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 J.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 fe(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 pe = Symbol("any"), de = Symbol("number"), ye = Symbol("string"), me = Symbol("array"), $ = {
|
|
481
|
+
any: pe,
|
|
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 M(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 = w({
|
|
534
592
|
name: "entered",
|
|
535
593
|
sid: "-d3obu6"
|
|
536
|
-
}),
|
|
594
|
+
}), a = w({
|
|
537
595
|
name: "exited",
|
|
538
596
|
sid: "-xofyk3"
|
|
539
|
-
}), i =
|
|
597
|
+
}), i = w({
|
|
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)) && M(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,243 @@ 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)) && M(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 [
|
|
590
|
-
return typeof r[
|
|
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;
|
|
591
649
|
}, {})
|
|
592
650
|
};
|
|
593
651
|
};
|
|
594
652
|
}
|
|
595
|
-
function
|
|
653
|
+
function z(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
|
-
} = t, s = S({}, {
|
|
663
|
+
routes: e
|
|
664
|
+
} = t, r = O({}, {
|
|
601
665
|
name: "$query",
|
|
602
|
-
sid: "
|
|
603
|
-
}),
|
|
666
|
+
sid: "uczasb"
|
|
667
|
+
}), s = O(null, {
|
|
604
668
|
name: "$history",
|
|
605
|
-
sid: "
|
|
606
|
-
}), o =
|
|
669
|
+
sid: "ui8df0"
|
|
670
|
+
}), o = O(null, {
|
|
607
671
|
name: "$path",
|
|
608
|
-
sid: "
|
|
609
|
-
}),
|
|
672
|
+
sid: "-m7ebm3"
|
|
673
|
+
}), a = O([], {
|
|
610
674
|
name: "$activeRoutes",
|
|
611
|
-
sid: "
|
|
612
|
-
}),
|
|
675
|
+
sid: "-ksnj2s"
|
|
676
|
+
}), i = w({
|
|
613
677
|
name: "setHistory",
|
|
614
|
-
sid: "
|
|
615
|
-
}),
|
|
678
|
+
sid: "-p3v4s1"
|
|
679
|
+
}), u = w({
|
|
616
680
|
name: "back",
|
|
617
|
-
sid: "-
|
|
618
|
-
}),
|
|
681
|
+
sid: "-tzn3h"
|
|
682
|
+
}), c = w({
|
|
619
683
|
name: "forward",
|
|
620
|
-
sid: "
|
|
621
|
-
}),
|
|
684
|
+
sid: "afzyy9"
|
|
685
|
+
}), d = w({
|
|
622
686
|
name: "locationUpdated",
|
|
623
|
-
sid: "
|
|
624
|
-
}),
|
|
625
|
-
let
|
|
626
|
-
const
|
|
627
|
-
for (
|
|
628
|
-
|
|
629
|
-
const
|
|
687
|
+
sid: "-ubw4ys"
|
|
688
|
+
}), p = e.map((l) => {
|
|
689
|
+
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("");
|
|
630
694
|
return {
|
|
631
|
-
route:
|
|
632
|
-
path:
|
|
633
|
-
toPath:
|
|
634
|
-
fromPath:
|
|
695
|
+
route: l,
|
|
696
|
+
path: m,
|
|
697
|
+
toPath: Y(m),
|
|
698
|
+
fromPath: Z(m)
|
|
635
699
|
};
|
|
636
|
-
}),
|
|
700
|
+
}), h = C({
|
|
637
701
|
and: {
|
|
638
702
|
source: {
|
|
639
|
-
history:
|
|
703
|
+
history: s
|
|
640
704
|
},
|
|
641
|
-
effect: async (
|
|
705
|
+
effect: async (l, b) => {
|
|
642
706
|
let {
|
|
643
|
-
history:
|
|
644
|
-
} =
|
|
645
|
-
path:
|
|
646
|
-
query:
|
|
647
|
-
replace:
|
|
648
|
-
} =
|
|
649
|
-
if (!
|
|
707
|
+
history: f
|
|
708
|
+
} = l, {
|
|
709
|
+
path: m,
|
|
710
|
+
query: S,
|
|
711
|
+
replace: E
|
|
712
|
+
} = b;
|
|
713
|
+
if (!f)
|
|
650
714
|
throw new Error("history not found");
|
|
651
|
-
const
|
|
652
|
-
pathname:
|
|
653
|
-
query:
|
|
715
|
+
const _ = {
|
|
716
|
+
pathname: m,
|
|
717
|
+
query: S
|
|
654
718
|
};
|
|
655
|
-
|
|
719
|
+
E ? f.replace(_) : f.push(_.pathname);
|
|
656
720
|
}
|
|
657
721
|
},
|
|
658
722
|
or: {
|
|
659
723
|
name: "updateHistoryFx",
|
|
660
|
-
sid: "
|
|
724
|
+
sid: "-oy8a4f"
|
|
661
725
|
}
|
|
662
726
|
});
|
|
663
727
|
for (const {
|
|
664
|
-
route:
|
|
665
|
-
toPath:
|
|
666
|
-
} of
|
|
667
|
-
|
|
728
|
+
route: l,
|
|
729
|
+
toPath: b
|
|
730
|
+
} of p)
|
|
731
|
+
g({
|
|
668
732
|
and: [{
|
|
669
|
-
clock:
|
|
670
|
-
source:
|
|
671
|
-
|
|
672
|
-
|
|
733
|
+
clock: l.opened,
|
|
734
|
+
source: a,
|
|
735
|
+
filter: (f) => !f.includes(l),
|
|
736
|
+
fn: (f) => [...f, l],
|
|
737
|
+
target: a
|
|
673
738
|
}],
|
|
674
739
|
or: {
|
|
675
|
-
sid: "
|
|
740
|
+
sid: "e1k4q5"
|
|
676
741
|
}
|
|
677
|
-
}),
|
|
742
|
+
}), g({
|
|
678
743
|
and: [{
|
|
679
|
-
clock:
|
|
680
|
-
|
|
744
|
+
clock: l.opened,
|
|
745
|
+
filter: (f) => !f.historyIgnore,
|
|
746
|
+
fn: function() {
|
|
681
747
|
let {
|
|
682
|
-
params:
|
|
683
|
-
query:
|
|
684
|
-
replace:
|
|
685
|
-
} =
|
|
748
|
+
params: f,
|
|
749
|
+
query: m,
|
|
750
|
+
replace: S
|
|
751
|
+
} = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {
|
|
752
|
+
params: {}
|
|
753
|
+
};
|
|
686
754
|
return {
|
|
687
|
-
path:
|
|
688
|
-
query:
|
|
689
|
-
replace:
|
|
755
|
+
path: b(f),
|
|
756
|
+
query: m ?? {},
|
|
757
|
+
replace: S
|
|
690
758
|
};
|
|
691
759
|
},
|
|
692
|
-
target:
|
|
760
|
+
target: h
|
|
693
761
|
}],
|
|
694
762
|
or: {
|
|
695
|
-
sid: "
|
|
763
|
+
sid: "ehi5xm"
|
|
696
764
|
}
|
|
697
|
-
}),
|
|
765
|
+
}), g({
|
|
698
766
|
and: [{
|
|
699
|
-
clock:
|
|
700
|
-
source:
|
|
701
|
-
fn: (
|
|
702
|
-
target:
|
|
767
|
+
clock: l.closed,
|
|
768
|
+
source: a,
|
|
769
|
+
fn: (f) => f.filter((m) => m !== l),
|
|
770
|
+
target: a
|
|
703
771
|
}],
|
|
704
772
|
or: {
|
|
705
|
-
sid: "
|
|
773
|
+
sid: "ez3kx6"
|
|
706
774
|
}
|
|
707
775
|
});
|
|
708
|
-
|
|
776
|
+
g({
|
|
709
777
|
and: [{
|
|
710
|
-
clock:
|
|
711
|
-
target:
|
|
778
|
+
clock: i,
|
|
779
|
+
target: s
|
|
712
780
|
}],
|
|
713
781
|
or: {
|
|
714
|
-
sid: "
|
|
782
|
+
sid: "ff1m2x"
|
|
715
783
|
}
|
|
716
784
|
});
|
|
717
|
-
const
|
|
718
|
-
const
|
|
719
|
-
if (!
|
|
785
|
+
const v = P((l) => {
|
|
786
|
+
const b = Q(d);
|
|
787
|
+
if (!l)
|
|
720
788
|
throw new Error();
|
|
721
|
-
|
|
789
|
+
l.listen((f) => {
|
|
722
790
|
let {
|
|
723
|
-
location:
|
|
724
|
-
} =
|
|
725
|
-
|
|
791
|
+
location: m
|
|
792
|
+
} = f;
|
|
793
|
+
b(m);
|
|
726
794
|
});
|
|
727
795
|
}, {
|
|
728
796
|
name: "subscribeHistoryFx",
|
|
729
|
-
sid: "
|
|
730
|
-
}),
|
|
797
|
+
sid: "z6ijkf"
|
|
798
|
+
}), y = C({
|
|
731
799
|
and: {
|
|
732
800
|
source: {
|
|
733
|
-
query:
|
|
801
|
+
query: r,
|
|
734
802
|
path: o
|
|
735
803
|
},
|
|
736
|
-
effect: async (
|
|
804
|
+
effect: async (l) => {
|
|
737
805
|
let {
|
|
738
|
-
query:
|
|
739
|
-
path:
|
|
740
|
-
} =
|
|
806
|
+
query: b,
|
|
807
|
+
path: f
|
|
808
|
+
} = l;
|
|
741
809
|
for (const {
|
|
742
|
-
route:
|
|
743
|
-
fromPath:
|
|
744
|
-
} of
|
|
745
|
-
const
|
|
746
|
-
if (
|
|
747
|
-
await
|
|
748
|
-
query:
|
|
749
|
-
params:
|
|
810
|
+
route: m,
|
|
811
|
+
fromPath: S
|
|
812
|
+
} of p) {
|
|
813
|
+
const E = S(f);
|
|
814
|
+
if (E)
|
|
815
|
+
await m.internal.openFx({
|
|
816
|
+
query: b,
|
|
817
|
+
params: E.params
|
|
750
818
|
});
|
|
751
|
-
else
|
|
819
|
+
else {
|
|
820
|
+
m.internal.close();
|
|
752
821
|
continue;
|
|
822
|
+
}
|
|
753
823
|
}
|
|
754
824
|
}
|
|
755
825
|
},
|
|
756
826
|
or: {
|
|
757
827
|
name: "openRoutesByPathFx",
|
|
758
|
-
sid: "
|
|
828
|
+
sid: "-1mpuqp"
|
|
759
829
|
}
|
|
760
830
|
});
|
|
761
|
-
return
|
|
831
|
+
return g({
|
|
762
832
|
and: [{
|
|
763
|
-
clock:
|
|
833
|
+
clock: s,
|
|
764
834
|
filter: Boolean,
|
|
765
|
-
target:
|
|
835
|
+
target: v
|
|
766
836
|
}],
|
|
767
837
|
or: {
|
|
768
|
-
sid: "
|
|
838
|
+
sid: "gvtv1l"
|
|
769
839
|
}
|
|
770
|
-
}),
|
|
840
|
+
}), g({
|
|
771
841
|
and: [{
|
|
772
|
-
clock:
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
}
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
842
|
+
clock: s,
|
|
843
|
+
filter: Boolean,
|
|
844
|
+
fn: (l) => z(l.location),
|
|
845
|
+
target: U({
|
|
846
|
+
sid: "suiy9c",
|
|
847
|
+
fn: () => L({
|
|
848
|
+
targets: {
|
|
849
|
+
path: o,
|
|
850
|
+
query: r
|
|
851
|
+
}
|
|
852
|
+
}),
|
|
853
|
+
name: "target",
|
|
854
|
+
method: "spread"
|
|
855
|
+
})
|
|
856
|
+
}],
|
|
857
|
+
or: {
|
|
858
|
+
sid: "haob2c"
|
|
859
|
+
}
|
|
860
|
+
}), g({
|
|
861
|
+
and: [{
|
|
862
|
+
clock: [d],
|
|
863
|
+
fn: (l) => z(l),
|
|
864
|
+
target: U({
|
|
865
|
+
sid: "-r1573k",
|
|
866
|
+
fn: () => L({
|
|
787
867
|
targets: {
|
|
788
868
|
path: o,
|
|
789
|
-
query:
|
|
869
|
+
query: r
|
|
790
870
|
}
|
|
791
871
|
}),
|
|
792
872
|
name: "target",
|
|
@@ -794,37 +874,37 @@ function he(t) {
|
|
|
794
874
|
})
|
|
795
875
|
}],
|
|
796
876
|
or: {
|
|
797
|
-
sid: "
|
|
877
|
+
sid: "hstin9"
|
|
798
878
|
}
|
|
799
|
-
}),
|
|
879
|
+
}), g({
|
|
800
880
|
and: [{
|
|
801
881
|
clock: o,
|
|
802
|
-
target:
|
|
882
|
+
target: y
|
|
803
883
|
}],
|
|
804
884
|
or: {
|
|
805
|
-
sid: "
|
|
885
|
+
sid: "iaexmt"
|
|
806
886
|
}
|
|
807
887
|
}), {
|
|
808
|
-
$query:
|
|
888
|
+
$query: r,
|
|
809
889
|
$path: o,
|
|
810
|
-
$activeRoutes:
|
|
811
|
-
back:
|
|
812
|
-
forward:
|
|
813
|
-
routes:
|
|
814
|
-
setHistory:
|
|
815
|
-
mappedRoutes:
|
|
816
|
-
trackQuery:
|
|
890
|
+
$activeRoutes: a,
|
|
891
|
+
back: u,
|
|
892
|
+
forward: c,
|
|
893
|
+
routes: e,
|
|
894
|
+
setHistory: i,
|
|
895
|
+
mappedRoutes: p,
|
|
896
|
+
trackQuery: ge(a, r),
|
|
817
897
|
"@@unitShape": () => ({
|
|
818
|
-
query:
|
|
898
|
+
query: r,
|
|
819
899
|
path: o,
|
|
820
|
-
activeRoutes:
|
|
821
|
-
onBack:
|
|
822
|
-
onForward:
|
|
900
|
+
activeRoutes: a,
|
|
901
|
+
onBack: u,
|
|
902
|
+
onForward: c
|
|
823
903
|
})
|
|
824
904
|
};
|
|
825
905
|
}
|
|
826
906
|
export {
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
907
|
+
we as createRoute,
|
|
908
|
+
xe as createRouter,
|
|
909
|
+
$ as parameters
|
|
830
910
|
};
|
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.2",
|
|
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": "c5ab346d7c4ed17a58dba0e133895193c93f76d5"
|
|
59
59
|
}
|