@argon-router/core 0.1.0
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/LICENSE.MD +21 -0
- package/README.md +0 -0
- package/dist/index.cjs +1 -0
- package/dist/index.d.ts +122 -0
- package/dist/index.js +830 -0
- package/package.json +59 -0
package/LICENSE.MD
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Edward Gigolaev
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
File without changes
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +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=$;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { Effect } from 'effector';
|
|
2
|
+
import { Event as Event_2 } from 'effector';
|
|
3
|
+
import { EventCallable } from 'effector';
|
|
4
|
+
import { History as History_2 } from 'history';
|
|
5
|
+
import { MatchFunction } from 'path-to-regexp';
|
|
6
|
+
import { ParseUrlParams } from 'typed-url-params';
|
|
7
|
+
import { Store } from 'effector';
|
|
8
|
+
|
|
9
|
+
declare type AnyParameter = typeof anySymbol;
|
|
10
|
+
|
|
11
|
+
declare const anySymbol: unique symbol;
|
|
12
|
+
|
|
13
|
+
declare type ArrayParameter = typeof arraySymbol;
|
|
14
|
+
|
|
15
|
+
declare const arraySymbol: unique symbol;
|
|
16
|
+
|
|
17
|
+
declare interface Config<T> {
|
|
18
|
+
path: T;
|
|
19
|
+
parent?: Route<any>;
|
|
20
|
+
index?: boolean;
|
|
21
|
+
beforeOpen?: Effect<any, any, any>[];
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export declare function createRoute<T extends string, Params = ParseUrlParams<T>>(config: Config<T>): Route<Params>;
|
|
25
|
+
|
|
26
|
+
export declare function createRouter(config: RouterConfig): Router;
|
|
27
|
+
|
|
28
|
+
declare type NumberParameter = typeof numberSymbol;
|
|
29
|
+
|
|
30
|
+
declare const numberSymbol: unique symbol;
|
|
31
|
+
|
|
32
|
+
export declare const parameters: Parameters_2;
|
|
33
|
+
|
|
34
|
+
declare type Parameters_2 = {
|
|
35
|
+
any: AnyParameter;
|
|
36
|
+
number: NumberParameter;
|
|
37
|
+
string: StringParameter;
|
|
38
|
+
array: ArrayParameter;
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export declare type Query = Record<string, string | string[]>;
|
|
42
|
+
|
|
43
|
+
declare interface QueryTracker<ParametersConfig extends RawConfig> {
|
|
44
|
+
entered: Event_2<ReadyConfig<ParametersConfig>>;
|
|
45
|
+
exited: Event_2<void>;
|
|
46
|
+
exit: EventCallable<{
|
|
47
|
+
ignoreParams: string[];
|
|
48
|
+
} | void>;
|
|
49
|
+
getPayload: (config: ReadyConfig<ParametersConfig>) => Record<string, any>;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
declare type QueryTrackerConfig<ParametersConfig extends RawConfig> = {
|
|
53
|
+
forRoutes?: Route<any>[];
|
|
54
|
+
parameters: ParametersConfig;
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
declare type RawConfig = Record<string, AnyParameter | ArrayParameter | NumberParameter | StringParameter | SupportedPrimitive | SupportedPrimitive[]>;
|
|
58
|
+
|
|
59
|
+
declare type ReadyConfig<T extends RawConfig> = {
|
|
60
|
+
[K in keyof T]: T[K] extends StringParameter ? string : T[K] extends NumberParameter ? number : T[K] extends ArrayParameter ? string[] : T[K] extends AnyParameter ? string | string[] : never;
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
export declare interface Route<T> {
|
|
64
|
+
$params: Store<T>;
|
|
65
|
+
$isOpened: Store<boolean>;
|
|
66
|
+
$isPending: Store<boolean>;
|
|
67
|
+
open: EventCallable<RouteOpenedPayload<T>>;
|
|
68
|
+
opened: Event_2<RouteOpenedPayload<T>>;
|
|
69
|
+
openedOnServer: Event_2<RouteOpenedPayload<T>>;
|
|
70
|
+
openedOnClient: Event_2<RouteOpenedPayload<T>>;
|
|
71
|
+
closed: Event_2<void>;
|
|
72
|
+
'@@unitShape': () => {
|
|
73
|
+
params: Store<T>;
|
|
74
|
+
isOpened: Store<boolean>;
|
|
75
|
+
isPending: Store<boolean>;
|
|
76
|
+
onOpen: EventCallable<RouteOpenedPayload<T>>;
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
declare type RouteOpenedPayload<T> = {
|
|
81
|
+
params: T;
|
|
82
|
+
query?: Record<string, any>;
|
|
83
|
+
replace?: boolean;
|
|
84
|
+
};
|
|
85
|
+
|
|
86
|
+
export declare interface Router {
|
|
87
|
+
$query: Store<Query>;
|
|
88
|
+
$path: Store<string>;
|
|
89
|
+
$activeRoutes: Store<Route<any>[]>;
|
|
90
|
+
back: EventCallable<void>;
|
|
91
|
+
forward: EventCallable<void>;
|
|
92
|
+
setHistory: EventCallable<History_2>;
|
|
93
|
+
routes: Route<any>[];
|
|
94
|
+
trackQuery: <ParametersConfig extends RawConfig>(config: QueryTrackerConfig<ParametersConfig>) => QueryTracker<ParametersConfig>;
|
|
95
|
+
mappedRoutes: {
|
|
96
|
+
route: Route<any>;
|
|
97
|
+
path: string;
|
|
98
|
+
toPath: (data?: Partial<Record<string, string | string[]>> | undefined) => string;
|
|
99
|
+
fromPath: MatchFunction<Partial<Record<string, string | string[]>>>;
|
|
100
|
+
}[];
|
|
101
|
+
'@@unitShape': () => {
|
|
102
|
+
query: Store<Query>;
|
|
103
|
+
path: Store<string>;
|
|
104
|
+
activeRoutes: Store<Route<any>[]>;
|
|
105
|
+
onBack: EventCallable<void>;
|
|
106
|
+
onForward: EventCallable<void>;
|
|
107
|
+
};
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
declare interface RouterConfig {
|
|
111
|
+
base?: string;
|
|
112
|
+
history?: History_2;
|
|
113
|
+
routes: Route<any>[];
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
declare type StringParameter = typeof stringSymbol;
|
|
117
|
+
|
|
118
|
+
declare const stringSymbol: unique symbol;
|
|
119
|
+
|
|
120
|
+
declare type SupportedPrimitive = string | number | Date | boolean;
|
|
121
|
+
|
|
122
|
+
export { }
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,830 @@
|
|
|
1
|
+
import { createEffect as P, createStore as S, createEvent as x, sample as w, split as J, attach as _, scopeBind as V, withFactory as q } from "effector";
|
|
2
|
+
import { spread as Q } from "patronum";
|
|
3
|
+
function me(t) {
|
|
4
|
+
let n;
|
|
5
|
+
const e = P(() => n == null ? void 0 : n(), {
|
|
6
|
+
name: "waitForAsyncBundleFx",
|
|
7
|
+
sid: "sy4dxt"
|
|
8
|
+
}), r = P(async (g) => (await e(), t.parent && await t.parent.internal.openFx(g), g), {
|
|
9
|
+
name: "openFx",
|
|
10
|
+
sid: "-vpkil5"
|
|
11
|
+
}), s = S({}, {
|
|
12
|
+
name: "$params",
|
|
13
|
+
sid: "c7nw5"
|
|
14
|
+
}), a = S(!1, {
|
|
15
|
+
name: "$isOpened",
|
|
16
|
+
sid: "83ksdl"
|
|
17
|
+
}), o = r.pending, i = x({
|
|
18
|
+
name: "open",
|
|
19
|
+
sid: "v8jsib"
|
|
20
|
+
}), u = x({
|
|
21
|
+
name: "close",
|
|
22
|
+
sid: "-9nrj06"
|
|
23
|
+
}), c = x({
|
|
24
|
+
name: "opened",
|
|
25
|
+
sid: "-ddw25k"
|
|
26
|
+
}), p = x({
|
|
27
|
+
name: "openedOnServer",
|
|
28
|
+
sid: "rqvufw"
|
|
29
|
+
}), f = x({
|
|
30
|
+
name: "openedOnClient",
|
|
31
|
+
sid: "rofchv"
|
|
32
|
+
}), m = x({
|
|
33
|
+
name: "closed",
|
|
34
|
+
sid: "-qg25d5"
|
|
35
|
+
});
|
|
36
|
+
return w({
|
|
37
|
+
and: [{
|
|
38
|
+
clock: i,
|
|
39
|
+
target: r
|
|
40
|
+
}],
|
|
41
|
+
or: {
|
|
42
|
+
sid: "sbzuux"
|
|
43
|
+
}
|
|
44
|
+
}), J({
|
|
45
|
+
and: [{
|
|
46
|
+
source: r.doneData,
|
|
47
|
+
match: () => typeof window > "u" ? "server" : "client",
|
|
48
|
+
cases: {
|
|
49
|
+
server: p,
|
|
50
|
+
client: f
|
|
51
|
+
}
|
|
52
|
+
}],
|
|
53
|
+
or: {
|
|
54
|
+
sid: "sqaiab"
|
|
55
|
+
}
|
|
56
|
+
}), w({
|
|
57
|
+
and: [{
|
|
58
|
+
clock: [f, p],
|
|
59
|
+
target: c
|
|
60
|
+
}],
|
|
61
|
+
or: {
|
|
62
|
+
sid: "t6sc35"
|
|
63
|
+
}
|
|
64
|
+
}), w({
|
|
65
|
+
and: [{
|
|
66
|
+
clock: c,
|
|
67
|
+
fn: () => !0,
|
|
68
|
+
target: a
|
|
69
|
+
}],
|
|
70
|
+
or: {
|
|
71
|
+
sid: "t9jb1y"
|
|
72
|
+
}
|
|
73
|
+
}), w({
|
|
74
|
+
and: [{
|
|
75
|
+
clock: m,
|
|
76
|
+
fn: () => !1,
|
|
77
|
+
target: a
|
|
78
|
+
}],
|
|
79
|
+
or: {
|
|
80
|
+
sid: "todr2p"
|
|
81
|
+
}
|
|
82
|
+
}), {
|
|
83
|
+
$params: s,
|
|
84
|
+
$isOpened: a,
|
|
85
|
+
$isPending: o,
|
|
86
|
+
open: i,
|
|
87
|
+
closed: m,
|
|
88
|
+
opened: c,
|
|
89
|
+
openedOnClient: f,
|
|
90
|
+
openedOnServer: p,
|
|
91
|
+
internal: {
|
|
92
|
+
index: !1,
|
|
93
|
+
close: u,
|
|
94
|
+
openFx: r,
|
|
95
|
+
setAsyncImport: (g) => n = g,
|
|
96
|
+
...t
|
|
97
|
+
},
|
|
98
|
+
"@@unitShape": () => ({
|
|
99
|
+
params: s,
|
|
100
|
+
isPending: o,
|
|
101
|
+
isOpened: a,
|
|
102
|
+
onOpen: i
|
|
103
|
+
})
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
var E = {};
|
|
107
|
+
Object.defineProperty(E, "__esModule", {
|
|
108
|
+
value: !0
|
|
109
|
+
});
|
|
110
|
+
E.TokenData = void 0;
|
|
111
|
+
E.parse = O;
|
|
112
|
+
var W = E.compile = Z, z = E.match = te;
|
|
113
|
+
E.pathToRegexp = M;
|
|
114
|
+
E.stringify = se;
|
|
115
|
+
const C = "/", D = (t) => t, L = /^[$_\p{ID_Start}]$/u, I = /^[$\u200c\u200d\p{ID_Continue}]$/u, T = "https://git.new/pathToRegexpError", G = {
|
|
116
|
+
// Groups.
|
|
117
|
+
"{": "{",
|
|
118
|
+
"}": "}",
|
|
119
|
+
// Reserved.
|
|
120
|
+
"(": "(",
|
|
121
|
+
")": ")",
|
|
122
|
+
"[": "[",
|
|
123
|
+
"]": "]",
|
|
124
|
+
"+": "+",
|
|
125
|
+
"?": "?",
|
|
126
|
+
"!": "!"
|
|
127
|
+
};
|
|
128
|
+
function K(t) {
|
|
129
|
+
return t.replace(/[{}()\[\]+?!:*]/g, "\\$&");
|
|
130
|
+
}
|
|
131
|
+
function v(t) {
|
|
132
|
+
return t.replace(/[.+*?^${}()[\]|/\\]/g, "\\$&");
|
|
133
|
+
}
|
|
134
|
+
function* X(t) {
|
|
135
|
+
const n = [...t];
|
|
136
|
+
let e = 0;
|
|
137
|
+
function r() {
|
|
138
|
+
let s = "";
|
|
139
|
+
if (L.test(n[++e]))
|
|
140
|
+
for (s += n[e]; I.test(n[++e]); )
|
|
141
|
+
s += n[e];
|
|
142
|
+
else if (n[e] === '"') {
|
|
143
|
+
let a = e;
|
|
144
|
+
for (; e < n.length; ) {
|
|
145
|
+
if (n[++e] === '"') {
|
|
146
|
+
e++, a = 0;
|
|
147
|
+
break;
|
|
148
|
+
}
|
|
149
|
+
n[e] === "\\" ? s += n[++e] : s += n[e];
|
|
150
|
+
}
|
|
151
|
+
if (a)
|
|
152
|
+
throw new TypeError(`Unterminated quote at ${a}: ${T}`);
|
|
153
|
+
}
|
|
154
|
+
if (!s)
|
|
155
|
+
throw new TypeError(`Missing parameter name at ${e}: ${T}`);
|
|
156
|
+
return s;
|
|
157
|
+
}
|
|
158
|
+
for (; e < n.length; ) {
|
|
159
|
+
const s = n[e], a = G[s];
|
|
160
|
+
if (a)
|
|
161
|
+
yield {
|
|
162
|
+
type: a,
|
|
163
|
+
index: e++,
|
|
164
|
+
value: s
|
|
165
|
+
};
|
|
166
|
+
else if (s === "\\")
|
|
167
|
+
yield {
|
|
168
|
+
type: "ESCAPED",
|
|
169
|
+
index: e++,
|
|
170
|
+
value: n[e++]
|
|
171
|
+
};
|
|
172
|
+
else if (s === ":") {
|
|
173
|
+
const o = r();
|
|
174
|
+
yield {
|
|
175
|
+
type: "PARAM",
|
|
176
|
+
index: e,
|
|
177
|
+
value: o
|
|
178
|
+
};
|
|
179
|
+
} else if (s === "*") {
|
|
180
|
+
const o = r();
|
|
181
|
+
yield {
|
|
182
|
+
type: "WILDCARD",
|
|
183
|
+
index: e,
|
|
184
|
+
value: o
|
|
185
|
+
};
|
|
186
|
+
} else
|
|
187
|
+
yield {
|
|
188
|
+
type: "CHAR",
|
|
189
|
+
index: e,
|
|
190
|
+
value: n[e++]
|
|
191
|
+
};
|
|
192
|
+
}
|
|
193
|
+
return {
|
|
194
|
+
type: "END",
|
|
195
|
+
index: e,
|
|
196
|
+
value: ""
|
|
197
|
+
};
|
|
198
|
+
}
|
|
199
|
+
class Y {
|
|
200
|
+
constructor(n) {
|
|
201
|
+
this.tokens = n;
|
|
202
|
+
}
|
|
203
|
+
peek() {
|
|
204
|
+
if (!this._peek) {
|
|
205
|
+
const n = this.tokens.next();
|
|
206
|
+
this._peek = n.value;
|
|
207
|
+
}
|
|
208
|
+
return this._peek;
|
|
209
|
+
}
|
|
210
|
+
tryConsume(n) {
|
|
211
|
+
const e = this.peek();
|
|
212
|
+
if (e.type === n)
|
|
213
|
+
return this._peek = void 0, e.value;
|
|
214
|
+
}
|
|
215
|
+
consume(n) {
|
|
216
|
+
const e = this.tryConsume(n);
|
|
217
|
+
if (e !== void 0) return e;
|
|
218
|
+
const {
|
|
219
|
+
type: r,
|
|
220
|
+
index: s
|
|
221
|
+
} = this.peek();
|
|
222
|
+
throw new TypeError(`Unexpected ${r} at ${s}, expected ${n}: ${T}`);
|
|
223
|
+
}
|
|
224
|
+
text() {
|
|
225
|
+
let n = "", e;
|
|
226
|
+
for (; e = this.tryConsume("CHAR") || this.tryConsume("ESCAPED"); )
|
|
227
|
+
n += e;
|
|
228
|
+
return n;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
class F {
|
|
232
|
+
constructor(n) {
|
|
233
|
+
this.tokens = n;
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
E.TokenData = F;
|
|
237
|
+
function O(t, n = {}) {
|
|
238
|
+
const {
|
|
239
|
+
encodePath: e = D
|
|
240
|
+
} = n, r = new Y(X(t));
|
|
241
|
+
function s(o) {
|
|
242
|
+
const i = [];
|
|
243
|
+
for (; ; ) {
|
|
244
|
+
const u = r.text();
|
|
245
|
+
u && i.push({
|
|
246
|
+
type: "text",
|
|
247
|
+
value: e(u)
|
|
248
|
+
});
|
|
249
|
+
const c = r.tryConsume("PARAM");
|
|
250
|
+
if (c) {
|
|
251
|
+
i.push({
|
|
252
|
+
type: "param",
|
|
253
|
+
name: c
|
|
254
|
+
});
|
|
255
|
+
continue;
|
|
256
|
+
}
|
|
257
|
+
const p = r.tryConsume("WILDCARD");
|
|
258
|
+
if (p) {
|
|
259
|
+
i.push({
|
|
260
|
+
type: "wildcard",
|
|
261
|
+
name: p
|
|
262
|
+
});
|
|
263
|
+
continue;
|
|
264
|
+
}
|
|
265
|
+
if (r.tryConsume("{")) {
|
|
266
|
+
i.push({
|
|
267
|
+
type: "group",
|
|
268
|
+
tokens: s("}")
|
|
269
|
+
});
|
|
270
|
+
continue;
|
|
271
|
+
}
|
|
272
|
+
return r.consume(o), i;
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
const a = s("END");
|
|
276
|
+
return new F(a);
|
|
277
|
+
}
|
|
278
|
+
function Z(t, n = {}) {
|
|
279
|
+
const {
|
|
280
|
+
encode: e = encodeURIComponent,
|
|
281
|
+
delimiter: r = C
|
|
282
|
+
} = n, s = t instanceof F ? t : O(t, n), a = B(s.tokens, r, e);
|
|
283
|
+
return function(i = {}) {
|
|
284
|
+
const [u, ...c] = a(i);
|
|
285
|
+
if (c.length)
|
|
286
|
+
throw new TypeError(`Missing parameters: ${c.join(", ")}`);
|
|
287
|
+
return u;
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
function B(t, n, e) {
|
|
291
|
+
const r = t.map((s) => ee(s, n, e));
|
|
292
|
+
return (s) => {
|
|
293
|
+
const a = [""];
|
|
294
|
+
for (const o of r) {
|
|
295
|
+
const [i, ...u] = o(s);
|
|
296
|
+
a[0] += i, a.push(...u);
|
|
297
|
+
}
|
|
298
|
+
return a;
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
function ee(t, n, e) {
|
|
302
|
+
if (t.type === "text") return () => [t.value];
|
|
303
|
+
if (t.type === "group") {
|
|
304
|
+
const s = B(t.tokens, n, e);
|
|
305
|
+
return (a) => {
|
|
306
|
+
const [o, ...i] = s(a);
|
|
307
|
+
return i.length ? [""] : [o];
|
|
308
|
+
};
|
|
309
|
+
}
|
|
310
|
+
const r = e || D;
|
|
311
|
+
return t.type === "wildcard" && e !== !1 ? (s) => {
|
|
312
|
+
const a = s[t.name];
|
|
313
|
+
if (a == null) return ["", t.name];
|
|
314
|
+
if (!Array.isArray(a) || a.length === 0)
|
|
315
|
+
throw new TypeError(`Expected "${t.name}" to be a non-empty array`);
|
|
316
|
+
return [a.map((o, i) => {
|
|
317
|
+
if (typeof o != "string")
|
|
318
|
+
throw new TypeError(`Expected "${t.name}/${i}" to be a string`);
|
|
319
|
+
return r(o);
|
|
320
|
+
}).join(n)];
|
|
321
|
+
} : (s) => {
|
|
322
|
+
const a = s[t.name];
|
|
323
|
+
if (a == null) return ["", t.name];
|
|
324
|
+
if (typeof a != "string")
|
|
325
|
+
throw new TypeError(`Expected "${t.name}" to be a string`);
|
|
326
|
+
return [r(a)];
|
|
327
|
+
};
|
|
328
|
+
}
|
|
329
|
+
function te(t, n = {}) {
|
|
330
|
+
const {
|
|
331
|
+
decode: e = decodeURIComponent,
|
|
332
|
+
delimiter: r = C
|
|
333
|
+
} = n, {
|
|
334
|
+
regexp: s,
|
|
335
|
+
keys: a
|
|
336
|
+
} = M(t, n), o = a.map((i) => e === !1 ? D : i.type === "param" ? e : (u) => u.split(r).map(e));
|
|
337
|
+
return function(u) {
|
|
338
|
+
const c = s.exec(u);
|
|
339
|
+
if (!c) return !1;
|
|
340
|
+
const p = c[0], f = /* @__PURE__ */ Object.create(null);
|
|
341
|
+
for (let m = 1; m < c.length; m++) {
|
|
342
|
+
if (c[m] === void 0) continue;
|
|
343
|
+
const g = a[m - 1], A = o[m - 1];
|
|
344
|
+
f[g.name] = A(c[m]);
|
|
345
|
+
}
|
|
346
|
+
return {
|
|
347
|
+
path: p,
|
|
348
|
+
params: f
|
|
349
|
+
};
|
|
350
|
+
};
|
|
351
|
+
}
|
|
352
|
+
function M(t, n = {}) {
|
|
353
|
+
const {
|
|
354
|
+
delimiter: e = C,
|
|
355
|
+
end: r = !0,
|
|
356
|
+
sensitive: s = !1,
|
|
357
|
+
trailing: a = !0
|
|
358
|
+
} = n, o = [], i = [], u = s ? "" : "i", p = (Array.isArray(t) ? t : [t]).map((g) => g instanceof F ? g : O(g, n));
|
|
359
|
+
for (const {
|
|
360
|
+
tokens: g
|
|
361
|
+
} of p)
|
|
362
|
+
for (const A of R(g, 0, [])) {
|
|
363
|
+
const N = ne(A, e, o);
|
|
364
|
+
i.push(N);
|
|
365
|
+
}
|
|
366
|
+
let f = `^(?:${i.join("|")})`;
|
|
367
|
+
return a && (f += `(?:${v(e)}$)?`), f += r ? "$" : `(?=${v(e)}|$)`, {
|
|
368
|
+
regexp: new RegExp(f, u),
|
|
369
|
+
keys: o
|
|
370
|
+
};
|
|
371
|
+
}
|
|
372
|
+
function* R(t, n, e) {
|
|
373
|
+
if (n === t.length)
|
|
374
|
+
return yield e;
|
|
375
|
+
const r = t[n];
|
|
376
|
+
if (r.type === "group") {
|
|
377
|
+
const s = e.slice();
|
|
378
|
+
for (const a of R(r.tokens, 0, s))
|
|
379
|
+
yield* R(t, n + 1, a);
|
|
380
|
+
} else
|
|
381
|
+
e.push(r);
|
|
382
|
+
yield* R(t, n + 1, e);
|
|
383
|
+
}
|
|
384
|
+
function ne(t, n, e) {
|
|
385
|
+
let r = "", s = "", a = !0;
|
|
386
|
+
for (let o = 0; o < t.length; o++) {
|
|
387
|
+
const i = t[o];
|
|
388
|
+
if (i.type === "text") {
|
|
389
|
+
r += v(i.value), s += i.value, a || (a = i.value.includes(n));
|
|
390
|
+
continue;
|
|
391
|
+
}
|
|
392
|
+
if (i.type === "param" || i.type === "wildcard") {
|
|
393
|
+
if (!a && !s)
|
|
394
|
+
throw new TypeError(`Missing text after "${i.name}": ${T}`);
|
|
395
|
+
i.type === "param" ? r += `(${re(n, a ? "" : s)}+)` : r += "([\\s\\S]+)", e.push(i), s = "", a = !1;
|
|
396
|
+
continue;
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
return r;
|
|
400
|
+
}
|
|
401
|
+
function re(t, n) {
|
|
402
|
+
return n.length < 2 ? t.length < 2 ? `[^${v(t + n)}]` : `(?:(?!${v(t)})[^${v(n)}])` : t.length < 2 ? `(?:(?!${v(n)})[^${v(t)}])` : `(?:(?!${v(n)}|${v(t)})[\\s\\S])`;
|
|
403
|
+
}
|
|
404
|
+
function se(t) {
|
|
405
|
+
return t.tokens.map(function n(e, r, s) {
|
|
406
|
+
if (e.type === "text") return K(e.value);
|
|
407
|
+
if (e.type === "group")
|
|
408
|
+
return `{${e.tokens.map(n).join("")}}`;
|
|
409
|
+
const o = ae(e.name) && oe(s[r + 1]) ? e.name : JSON.stringify(e.name);
|
|
410
|
+
if (e.type === "param") return `:${o}`;
|
|
411
|
+
if (e.type === "wildcard") return `*${o}`;
|
|
412
|
+
throw new TypeError(`Unexpected token: ${e}`);
|
|
413
|
+
}).join("");
|
|
414
|
+
}
|
|
415
|
+
function ae(t) {
|
|
416
|
+
const [n, ...e] = t;
|
|
417
|
+
return L.test(n) ? e.every((r) => I.test(r)) : !1;
|
|
418
|
+
}
|
|
419
|
+
function oe(t) {
|
|
420
|
+
return (t == null ? void 0 : t.type) !== "text" ? !0 : !I.test(t.value[0]);
|
|
421
|
+
}
|
|
422
|
+
const ie = Symbol("any"), ce = Symbol("number"), ue = Symbol("string"), le = Symbol("array"), k = {
|
|
423
|
+
any: ie,
|
|
424
|
+
number: ce,
|
|
425
|
+
string: ue,
|
|
426
|
+
array: le
|
|
427
|
+
};
|
|
428
|
+
function U(t, n) {
|
|
429
|
+
for (const e of t)
|
|
430
|
+
if (!n.includes(e))
|
|
431
|
+
return !1;
|
|
432
|
+
return !0;
|
|
433
|
+
}
|
|
434
|
+
function H(t, n) {
|
|
435
|
+
for (const e in n) {
|
|
436
|
+
const r = n[e];
|
|
437
|
+
if (Array.isArray(r) && (!t[e] || JSON.stringify(r) !== t[e]))
|
|
438
|
+
return !1;
|
|
439
|
+
switch (typeof r) {
|
|
440
|
+
case "number": {
|
|
441
|
+
if (!t[e] || r.toString() !== t[e])
|
|
442
|
+
return !1;
|
|
443
|
+
break;
|
|
444
|
+
}
|
|
445
|
+
case "object": {
|
|
446
|
+
if (!t[e] || JSON.stringify(r) !== t[e])
|
|
447
|
+
return !1;
|
|
448
|
+
break;
|
|
449
|
+
}
|
|
450
|
+
case "string": {
|
|
451
|
+
if (!t[e] || r !== t[e])
|
|
452
|
+
return !1;
|
|
453
|
+
break;
|
|
454
|
+
}
|
|
455
|
+
case "boolean": {
|
|
456
|
+
if (!t[e] || !["0", "1", "false", "true"].includes(t[e]))
|
|
457
|
+
return !1;
|
|
458
|
+
break;
|
|
459
|
+
}
|
|
460
|
+
}
|
|
461
|
+
switch (r) {
|
|
462
|
+
case k.any: {
|
|
463
|
+
if (!t[e])
|
|
464
|
+
return !1;
|
|
465
|
+
break;
|
|
466
|
+
}
|
|
467
|
+
case k.string: {
|
|
468
|
+
if (!t[e] || Array.isArray(t[e]))
|
|
469
|
+
return !1;
|
|
470
|
+
break;
|
|
471
|
+
}
|
|
472
|
+
case k.array: {
|
|
473
|
+
if (!t[e] || !Array.isArray(t[e]))
|
|
474
|
+
return !1;
|
|
475
|
+
break;
|
|
476
|
+
}
|
|
477
|
+
case k.number: {
|
|
478
|
+
if (!t[e] || Array.isArray(t[e]) || isNaN(parseInt(t[e])) && isNaN(parseFloat(t[e])))
|
|
479
|
+
return !1;
|
|
480
|
+
break;
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
return !0;
|
|
485
|
+
}
|
|
486
|
+
function pe(t, n) {
|
|
487
|
+
const e = {};
|
|
488
|
+
for (const r in n) {
|
|
489
|
+
const s = n[r], a = t[r];
|
|
490
|
+
if (Array.isArray(s)) {
|
|
491
|
+
e[r] = a === "1" || a === "true";
|
|
492
|
+
continue;
|
|
493
|
+
}
|
|
494
|
+
switch (typeof s) {
|
|
495
|
+
case "number": {
|
|
496
|
+
const o = t[r];
|
|
497
|
+
e[r] = isNaN(parseInt(o)) ? parseFloat(o) : parseInt(o);
|
|
498
|
+
break;
|
|
499
|
+
}
|
|
500
|
+
case "object": {
|
|
501
|
+
e[r] = JSON.parse(a);
|
|
502
|
+
break;
|
|
503
|
+
}
|
|
504
|
+
case "string":
|
|
505
|
+
e[r] = t[r];
|
|
506
|
+
case "boolean": {
|
|
507
|
+
const o = t[r];
|
|
508
|
+
e[r] = o === "0" ? parseFloat(o) : parseInt(o);
|
|
509
|
+
break;
|
|
510
|
+
}
|
|
511
|
+
}
|
|
512
|
+
switch (s) {
|
|
513
|
+
case k.any:
|
|
514
|
+
case k.string:
|
|
515
|
+
case k.array: {
|
|
516
|
+
e[r] = t[r];
|
|
517
|
+
break;
|
|
518
|
+
}
|
|
519
|
+
case k.number: {
|
|
520
|
+
const o = t[r];
|
|
521
|
+
e[r] = isNaN(parseInt(o)) ? parseFloat(o) : parseInt(o);
|
|
522
|
+
break;
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
return e;
|
|
527
|
+
}
|
|
528
|
+
function fe(t, n) {
|
|
529
|
+
return (e) => {
|
|
530
|
+
const {
|
|
531
|
+
parameters: r,
|
|
532
|
+
forRoutes: s
|
|
533
|
+
} = e, a = x({
|
|
534
|
+
name: "entered",
|
|
535
|
+
sid: "-d3obu6"
|
|
536
|
+
}), o = x({
|
|
537
|
+
name: "exited",
|
|
538
|
+
sid: "-xofyk3"
|
|
539
|
+
}), i = x({
|
|
540
|
+
name: "exit",
|
|
541
|
+
sid: "-673d76"
|
|
542
|
+
});
|
|
543
|
+
return w({
|
|
544
|
+
and: [{
|
|
545
|
+
source: {
|
|
546
|
+
activeRoutes: t,
|
|
547
|
+
query: n
|
|
548
|
+
},
|
|
549
|
+
filter: (u) => {
|
|
550
|
+
let {
|
|
551
|
+
activeRoutes: c,
|
|
552
|
+
query: p
|
|
553
|
+
} = u;
|
|
554
|
+
return (!s || U(s, c)) && H(p, r);
|
|
555
|
+
},
|
|
556
|
+
fn: (u) => {
|
|
557
|
+
let {
|
|
558
|
+
query: c
|
|
559
|
+
} = u;
|
|
560
|
+
return pe(c, r);
|
|
561
|
+
}
|
|
562
|
+
}],
|
|
563
|
+
or: {
|
|
564
|
+
sid: "-so0f9q"
|
|
565
|
+
}
|
|
566
|
+
}), w({
|
|
567
|
+
and: [{
|
|
568
|
+
source: {
|
|
569
|
+
activeRoutes: t,
|
|
570
|
+
query: n
|
|
571
|
+
},
|
|
572
|
+
filter: (u) => {
|
|
573
|
+
let {
|
|
574
|
+
activeRoutes: c,
|
|
575
|
+
query: p
|
|
576
|
+
} = u;
|
|
577
|
+
return !((!s || U(s, c)) && H(p, r));
|
|
578
|
+
},
|
|
579
|
+
target: o
|
|
580
|
+
}],
|
|
581
|
+
or: {
|
|
582
|
+
sid: "-s82e29"
|
|
583
|
+
}
|
|
584
|
+
}), {
|
|
585
|
+
entered: a,
|
|
586
|
+
exited: o,
|
|
587
|
+
exit: i,
|
|
588
|
+
getPayload: (u) => Object.entries(u).reduce((c, p) => {
|
|
589
|
+
let [f, m] = p;
|
|
590
|
+
return typeof r[f] == "symbol" ? c[f] = m : c[f] = r[f], c;
|
|
591
|
+
}, {})
|
|
592
|
+
};
|
|
593
|
+
};
|
|
594
|
+
}
|
|
595
|
+
function he(t) {
|
|
596
|
+
const {
|
|
597
|
+
base: n = "/",
|
|
598
|
+
history: e,
|
|
599
|
+
routes: r
|
|
600
|
+
} = t, s = S({}, {
|
|
601
|
+
name: "$query",
|
|
602
|
+
sid: "2wd7x1"
|
|
603
|
+
}), a = S(e ?? null, {
|
|
604
|
+
name: "$history",
|
|
605
|
+
sid: "31majq"
|
|
606
|
+
}), o = S("/", {
|
|
607
|
+
name: "$path",
|
|
608
|
+
sid: "ld3nhr"
|
|
609
|
+
}), i = S([], {
|
|
610
|
+
name: "$activeRoutes",
|
|
611
|
+
sid: "mrug12"
|
|
612
|
+
}), u = x({
|
|
613
|
+
name: "setHistory",
|
|
614
|
+
sid: "sekwlw"
|
|
615
|
+
}), c = x({
|
|
616
|
+
name: "back",
|
|
617
|
+
sid: "-icnnoo"
|
|
618
|
+
}), p = x({
|
|
619
|
+
name: "forward",
|
|
620
|
+
sid: "-72o1my"
|
|
621
|
+
}), f = x({
|
|
622
|
+
name: "locationUpdated",
|
|
623
|
+
sid: "d8lu52"
|
|
624
|
+
}), m = r.map((d) => {
|
|
625
|
+
let h = d;
|
|
626
|
+
const l = [];
|
|
627
|
+
for (l.unshift(h.internal.path); h.internal.parent; )
|
|
628
|
+
h = h.internal.parent, l.unshift(h.internal.path);
|
|
629
|
+
const y = (n === "/" ? l : [n, ...l]).join("");
|
|
630
|
+
return {
|
|
631
|
+
route: d,
|
|
632
|
+
path: y,
|
|
633
|
+
toPath: W(y),
|
|
634
|
+
fromPath: z(y)
|
|
635
|
+
};
|
|
636
|
+
}), g = _({
|
|
637
|
+
and: {
|
|
638
|
+
source: {
|
|
639
|
+
history: a
|
|
640
|
+
},
|
|
641
|
+
effect: async (d, h) => {
|
|
642
|
+
let {
|
|
643
|
+
history: l
|
|
644
|
+
} = d, {
|
|
645
|
+
path: y,
|
|
646
|
+
query: b,
|
|
647
|
+
replace: $
|
|
648
|
+
} = h;
|
|
649
|
+
if (!l)
|
|
650
|
+
throw new Error("history not found");
|
|
651
|
+
const j = {
|
|
652
|
+
pathname: y,
|
|
653
|
+
query: b
|
|
654
|
+
};
|
|
655
|
+
$ ? l.replace(j) : l.push(j);
|
|
656
|
+
}
|
|
657
|
+
},
|
|
658
|
+
or: {
|
|
659
|
+
name: "updateHistoryFx",
|
|
660
|
+
sid: "h74tsu"
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
for (const {
|
|
664
|
+
route: d,
|
|
665
|
+
toPath: h
|
|
666
|
+
} of m)
|
|
667
|
+
w({
|
|
668
|
+
and: [{
|
|
669
|
+
clock: d.opened,
|
|
670
|
+
source: i,
|
|
671
|
+
fn: (l) => [...l, d],
|
|
672
|
+
target: i
|
|
673
|
+
}],
|
|
674
|
+
or: {
|
|
675
|
+
sid: "-px1r6l"
|
|
676
|
+
}
|
|
677
|
+
}), w({
|
|
678
|
+
and: [{
|
|
679
|
+
clock: d.opened,
|
|
680
|
+
fn: (l) => {
|
|
681
|
+
let {
|
|
682
|
+
params: y,
|
|
683
|
+
query: b,
|
|
684
|
+
replace: $
|
|
685
|
+
} = l;
|
|
686
|
+
return {
|
|
687
|
+
path: h(y),
|
|
688
|
+
query: b ?? {},
|
|
689
|
+
replace: $
|
|
690
|
+
};
|
|
691
|
+
},
|
|
692
|
+
target: g
|
|
693
|
+
}],
|
|
694
|
+
or: {
|
|
695
|
+
sid: "-phnikh"
|
|
696
|
+
}
|
|
697
|
+
}), w({
|
|
698
|
+
and: [{
|
|
699
|
+
clock: d.closed,
|
|
700
|
+
source: i,
|
|
701
|
+
fn: (l) => l.filter((y) => y !== d),
|
|
702
|
+
target: i
|
|
703
|
+
}],
|
|
704
|
+
or: {
|
|
705
|
+
sid: "e0gjjf"
|
|
706
|
+
}
|
|
707
|
+
});
|
|
708
|
+
w({
|
|
709
|
+
and: [{
|
|
710
|
+
clock: u,
|
|
711
|
+
target: a
|
|
712
|
+
}],
|
|
713
|
+
or: {
|
|
714
|
+
sid: "egekp6"
|
|
715
|
+
}
|
|
716
|
+
});
|
|
717
|
+
const A = P((d) => {
|
|
718
|
+
const h = V(f);
|
|
719
|
+
if (!d)
|
|
720
|
+
throw new Error();
|
|
721
|
+
d.listen((l) => {
|
|
722
|
+
let {
|
|
723
|
+
location: y
|
|
724
|
+
} = l;
|
|
725
|
+
h(y);
|
|
726
|
+
});
|
|
727
|
+
}, {
|
|
728
|
+
name: "subscribeHistoryFx",
|
|
729
|
+
sid: "5cocq6"
|
|
730
|
+
}), N = _({
|
|
731
|
+
and: {
|
|
732
|
+
source: {
|
|
733
|
+
query: s,
|
|
734
|
+
path: o
|
|
735
|
+
},
|
|
736
|
+
effect: async (d) => {
|
|
737
|
+
let {
|
|
738
|
+
query: h,
|
|
739
|
+
path: l
|
|
740
|
+
} = d;
|
|
741
|
+
for (const {
|
|
742
|
+
route: y,
|
|
743
|
+
fromPath: b
|
|
744
|
+
} of m) {
|
|
745
|
+
const $ = b(l);
|
|
746
|
+
if ($)
|
|
747
|
+
await y.internal.openFx({
|
|
748
|
+
query: h,
|
|
749
|
+
params: $.params
|
|
750
|
+
});
|
|
751
|
+
else
|
|
752
|
+
continue;
|
|
753
|
+
}
|
|
754
|
+
}
|
|
755
|
+
},
|
|
756
|
+
or: {
|
|
757
|
+
name: "openRoutesByPathFx",
|
|
758
|
+
sid: "tmly43"
|
|
759
|
+
}
|
|
760
|
+
});
|
|
761
|
+
return w({
|
|
762
|
+
and: [{
|
|
763
|
+
clock: a,
|
|
764
|
+
filter: Boolean,
|
|
765
|
+
target: A
|
|
766
|
+
}],
|
|
767
|
+
or: {
|
|
768
|
+
sid: "fwn12h"
|
|
769
|
+
}
|
|
770
|
+
}), w({
|
|
771
|
+
and: [{
|
|
772
|
+
clock: f,
|
|
773
|
+
fn: (d) => {
|
|
774
|
+
let {
|
|
775
|
+
pathname: h,
|
|
776
|
+
search: l
|
|
777
|
+
} = d;
|
|
778
|
+
const y = new URLSearchParams(l);
|
|
779
|
+
return {
|
|
780
|
+
path: h,
|
|
781
|
+
query: [...y.keys()].reduce((b, $) => (b[$] ? b[$] = y.getAll($) : b[$] = y.get($), b), {})
|
|
782
|
+
};
|
|
783
|
+
},
|
|
784
|
+
target: q({
|
|
785
|
+
sid: "f47wtp",
|
|
786
|
+
fn: () => Q({
|
|
787
|
+
targets: {
|
|
788
|
+
path: o,
|
|
789
|
+
query: s
|
|
790
|
+
}
|
|
791
|
+
}),
|
|
792
|
+
name: "target",
|
|
793
|
+
method: "spread"
|
|
794
|
+
})
|
|
795
|
+
}],
|
|
796
|
+
or: {
|
|
797
|
+
sid: "gbhh38"
|
|
798
|
+
}
|
|
799
|
+
}), w({
|
|
800
|
+
and: [{
|
|
801
|
+
clock: o,
|
|
802
|
+
target: N
|
|
803
|
+
}],
|
|
804
|
+
or: {
|
|
805
|
+
sid: "hcvhfs"
|
|
806
|
+
}
|
|
807
|
+
}), {
|
|
808
|
+
$query: s,
|
|
809
|
+
$path: o,
|
|
810
|
+
$activeRoutes: i,
|
|
811
|
+
back: c,
|
|
812
|
+
forward: p,
|
|
813
|
+
routes: r,
|
|
814
|
+
setHistory: u,
|
|
815
|
+
mappedRoutes: m,
|
|
816
|
+
trackQuery: fe(i, s),
|
|
817
|
+
"@@unitShape": () => ({
|
|
818
|
+
query: s,
|
|
819
|
+
path: o,
|
|
820
|
+
activeRoutes: i,
|
|
821
|
+
onBack: c,
|
|
822
|
+
onForward: p
|
|
823
|
+
})
|
|
824
|
+
};
|
|
825
|
+
}
|
|
826
|
+
export {
|
|
827
|
+
me as createRoute,
|
|
828
|
+
he as createRouter,
|
|
829
|
+
k as parameters
|
|
830
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@argon-router/core",
|
|
3
|
+
"publishConfig": {
|
|
4
|
+
"access": "public",
|
|
5
|
+
"registry": "https://registry.npmjs.org/"
|
|
6
|
+
},
|
|
7
|
+
"private": false,
|
|
8
|
+
"version": "0.1.0",
|
|
9
|
+
"description": "Router with power of effector",
|
|
10
|
+
"keywords": [
|
|
11
|
+
"effector",
|
|
12
|
+
"router",
|
|
13
|
+
"argon",
|
|
14
|
+
"argon-router"
|
|
15
|
+
],
|
|
16
|
+
"author": "movpushmov",
|
|
17
|
+
"homepage": "https://github.com/movpushmov/argon-router#readme",
|
|
18
|
+
"license": "MIT",
|
|
19
|
+
"directories": {
|
|
20
|
+
"lib": "lib"
|
|
21
|
+
},
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
24
|
+
],
|
|
25
|
+
"type": "module",
|
|
26
|
+
"module": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.cjs"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
34
|
+
"repository": {
|
|
35
|
+
"type": "git",
|
|
36
|
+
"url": "git+https://github.com/movpushmov/argon-router.git"
|
|
37
|
+
},
|
|
38
|
+
"scripts": {
|
|
39
|
+
"build": "vite build",
|
|
40
|
+
"test": "vitest run"
|
|
41
|
+
},
|
|
42
|
+
"bugs": {
|
|
43
|
+
"url": "https://github.com/movpushmov/argon-router/issues"
|
|
44
|
+
},
|
|
45
|
+
"peerDependencies": {
|
|
46
|
+
"effector": "^23.2.2",
|
|
47
|
+
"patronum": "^2.2.0"
|
|
48
|
+
},
|
|
49
|
+
"devDependencies": {
|
|
50
|
+
"@babel/plugin-transform-export-namespace-from": "^7.24.7",
|
|
51
|
+
"@types/history": "^4.7.11"
|
|
52
|
+
},
|
|
53
|
+
"dependencies": {
|
|
54
|
+
"fast-deep-equal": "^3.1.3",
|
|
55
|
+
"path-to-regexp": "^8.2.0",
|
|
56
|
+
"typed-url-params": "^1.0.1"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "59ab2eda9dffd095ffe5c4625b6a40cd71487410"
|
|
59
|
+
}
|