1
- var O = ( e ) => {
2
- throw TypeError ( e ) ;
1
+ var C = ( t ) => {
2
+ throw TypeError ( t ) ;
3
3
} ;
4
- var C = ( e , t , s ) => t . has ( e ) || O ( "Cannot " + s ) ;
5
- var o = ( e , t , s ) => ( C ( e , t , "read from private field" ) , s ? s . call ( e ) : t . get ( e ) ) , y = ( e , t , s ) => t . has ( e ) ? O ( "Cannot add the same private member more than once" ) : t instanceof WeakSet ? t . add ( e ) : t . set ( e , s ) , $ = ( e , t , s , n ) => ( C ( e , t , "write to private field" ) , n ? n . call ( e , s ) : t . set ( e , s ) , s ) ;
4
+ var j = ( t , e , s ) => e . has ( t ) || C ( "Cannot " + s ) ;
5
+ var o = ( t , e , s ) => ( j ( t , e , "read from private field" ) , s ? s . call ( t ) : e . get ( t ) ) , y = ( t , e , s ) => e . has ( t ) ? C ( "Cannot add the same private member more than once" ) : e instanceof WeakSet ? e . add ( t ) : e . set ( t , s ) , $ = ( t , e , s , n ) => ( j ( t , e , "write to private field" ) , n ? n . call ( t , s ) : e . set ( t , s ) , s ) ;
6
6
import { z as r } from "zod" ;
7
- import { parse as P , stringify as D } from "qs" ;
7
+ import { parse as D , stringify as N } from "qs" ;
8
8
r . record ( r . string ( ) , r . boolean ( ) ) ;
9
- const j = r . union ( [ r . string ( ) , r . number ( ) , r . boolean ( ) ] ) , x = r . record (
9
+ const _ = r . union ( [ r . string ( ) , r . number ( ) , r . boolean ( ) ] ) , x = r . record (
10
10
r . unknown ( ) ,
11
- j
12
- ) , N = r . object ( {
11
+ _
12
+ ) , Q = r . object ( {
13
13
_query : r . record (
14
14
x . keySchema ,
15
- x . valueSchema . or ( r . array ( j ) )
15
+ x . valueSchema . or ( r . array ( _ ) )
16
16
) . optional ( )
17
17
} ) ;
18
18
r . intersection (
19
19
x ,
20
- N
20
+ Q
21
21
) ;
22
- const Q = r . object ( {
22
+ const V = r . object ( {
23
23
uri : r . string ( ) ,
24
24
domain : r . string ( ) . nullable ( ) ,
25
25
wheres : x
@@ -28,24 +28,24 @@ r.object({
28
28
substituted : r . array ( r . string ( ) ) ,
29
29
url : r . string ( )
30
30
} ) ;
31
- const V = r . record ( r . string ( ) , Q ) , A = r . object ( {
31
+ const A = r . record ( r . string ( ) , V ) , F = r . object ( {
32
32
base : r . string ( ) ,
33
33
defaults : x ,
34
- routes : V
35
- } ) , _ = ( e ) => typeof e == "string" || e instanceof String , k = ( e ) => e == null ? ! 0 : ( _ ( e ) || ( e = String ( e ) ) , e . trim ( ) . length === 0 ) , R = ( e ) => e . replace ( / \/ + $ / , "" ) , F = ( e ) => {
36
- const t = e . indexOf ( "?" ) , s = t > - 1 ;
34
+ routes : A
35
+ } ) , E = ( t ) => typeof t == "string" || t instanceof String , k = ( t ) => t == null ? ! 0 : ( E ( t ) || ( t = String ( t ) ) , t . trim ( ) . length === 0 ) , R = ( t ) => t . replace ( / \/ + $ / , "" ) , I = ( t ) => {
36
+ const e = t . indexOf ( "?" ) , s = e > - 1 ;
37
37
return {
38
- location : e . substring ( 0 , s ? t : e . length ) ,
39
- query : e . substring ( s ? t + 1 : e . length )
38
+ location : t . substring ( 0 , s ? e : t . length ) ,
39
+ query : t . substring ( s ? e + 1 : t . length )
40
40
} ;
41
41
} ;
42
42
var d , a , g ;
43
- class I {
44
- constructor ( t , s , n ) {
43
+ class W {
44
+ constructor ( e , s , n ) {
45
45
y ( this , d ) ;
46
46
y ( this , a ) ;
47
47
y ( this , g ) ;
48
- $ ( this , d , t ) , $ ( this , a , s ) , $ ( this , g , n ) ;
48
+ $ ( this , d , e ) , $ ( this , a , s ) , $ ( this , g , n ) ;
49
49
}
50
50
/**
51
51
* Retruns the route's origin
@@ -61,32 +61,32 @@ class I {
61
61
* Retruns the route's template
62
62
*/
63
63
get template ( ) {
64
- const t = R ( `${ this . origin } /${ o ( this , a ) . uri } ` ) ;
65
- return k ( t ) ? "/" : t ;
64
+ const e = R ( `${ this . origin } /${ o ( this , a ) . uri } ` ) ;
65
+ return k ( e ) ? "/" : e ;
66
66
}
67
67
/**
68
68
* Retruns the route's template expected parameters
69
69
*/
70
70
get expects ( ) {
71
- const t = { } , s = this . template . match ( / { \w + \? ? } / g) ?? [ ] ;
71
+ const e = { } , s = this . template . match ( / { \w + \? ? } / g) ?? [ ] ;
72
72
for ( const n of s ) {
73
73
const h = n . replace ( / \W / g, "" ) ;
74
- t [ h ] = n . includes ( "?" ) || ( t [ h ] ?? ! 1 ) ;
74
+ e [ h ] = n . includes ( "?" ) || ( e [ h ] ?? ! 1 ) ;
75
75
}
76
- return t ;
76
+ return e ;
77
77
}
78
78
/**
79
79
* Return the compiled URI for this route, along with an array of substituted tokens.
80
80
*/
81
- compile ( t ) {
81
+ compile ( e ) {
82
82
var l ;
83
83
const s = new Array ( ) , n = this . expects , h = Object . keys ( n ) ;
84
84
if ( h . length < 1 )
85
85
return { substituted : s , url : this . template } ;
86
86
let f = this . template ;
87
87
for ( const i of h ) {
88
88
const S = n [ i ] ;
89
- let c = ( t == null ? void 0 : t [ i ] ) ?? ( ( l = o ( this , g ) . config . defaults ) == null ? void 0 : l [ i ] ) ?? "" ;
89
+ let c = ( e == null ? void 0 : e [ i ] ) ?? ( ( l = o ( this , g ) . config . defaults ) == null ? void 0 : l [ i ] ) ?? "" ;
90
90
typeof c == "boolean" && ( c = c ? 1 : 0 ) ;
91
91
const b = String ( c ) ;
92
92
if ( ! S ) {
@@ -122,12 +122,12 @@ class I {
122
122
/**
123
123
* Determine if the current route template matches the given URL.
124
124
*/
125
- matches ( t ) {
125
+ matches ( e ) {
126
126
var b ;
127
127
const s = / ^ [ a - z ] * : \/ \/ / i;
128
128
let n = this . template ;
129
- ( b = o ( this , a ) . domain ) != null && b . includes ( "{" ) ? t = t . replace ( s , "" ) : ( t = t . replace ( / ^ [ a - z ] * : \/ \/ ( [ a - z ] * \. ? ) * / i, "" ) , t += t . startsWith ( "/" ) ? "" : "/" , n = n . replace ( / ^ [ a - z ] * : \/ \/ ( [ a - z ] * \. ? ) * / i, "" ) , n += n . startsWith ( "/" ) ? "" : "/" ) ;
130
- const { location : h , query : f } = F ( t ) , l = / [ / \\ ^ $ . | ? * + ( ) [ \] { } ] / g, i = / \\ { ( \w + ) ( \\ \? ) ? \\ } / g, S = n . replace ( s , "" ) . replace ( l , "\\$&" ) . replace ( i , ( m , p , w ) => {
129
+ ( b = o ( this , a ) . domain ) != null && b . includes ( "{" ) ? e = e . replace ( s , "" ) : ( e = e . replace ( / ^ [ a - z ] * : \/ \/ ( [ a - z ] * \. ? ) * / i, "" ) , e += e . startsWith ( "/" ) ? "" : "/" , n = n . replace ( / ^ [ a - z ] * : \/ \/ ( [ a - z ] * \. ? ) * / i, "" ) , n += n . startsWith ( "/" ) ? "" : "/" ) ;
130
+ const { location : h , query : f } = I ( e ) , l = / [ / \\ ^ $ . | ? * + ( ) [ \] { } ] / g, i = / \\ { ( \w + ) ( \\ \? ) ? \\ } / g, S = n . replace ( s , "" ) . replace ( l , "\\$&" ) . replace ( i , ( m , p , w ) => {
131
131
const z = o ( this , a ) . wheres [ p ] ?? "[^/]+" ;
132
132
return `${ w ? "?" : "" } (?<${ p } >${ z } )${ w ? "?" : "" } ` ;
133
133
} ) , c = new RegExp ( `^${ S } /?$` ) . exec ( h ) ;
@@ -141,40 +141,40 @@ class I {
141
141
}
142
142
return {
143
143
...c . groups ,
144
- _query : P ( f )
144
+ _query : D ( f )
145
145
} ;
146
146
}
147
147
}
148
148
d = new WeakMap ( ) , a = new WeakMap ( ) , g = new WeakMap ( ) ;
149
- const E = ( ) => ( {
149
+ const P = ( ) => ( {
150
150
addQueryPrefix : ! 0 ,
151
- encoder : ( e , t , s , n ) => n === "value" && typeof e == "boolean" ? e ? 1 : 0 : t ( e ) ,
151
+ encoder : ( t , e , s , n ) => n === "value" && typeof t == "boolean" ? t ? 1 : 0 : e ( t ) ,
152
152
encodeValuesOnly : ! 0 ,
153
153
skipNulls : ! 0
154
- } ) , W = ( ) => ( {
154
+ } ) , J = ( ) => ( {
155
155
absolute : ! 1 ,
156
156
strict : ! 1 ,
157
- qsConfig : E ( ) ,
157
+ qsConfig : P ( ) ,
158
158
base : "/" ,
159
159
defaults : { } ,
160
160
routes : { }
161
- } ) , J = ( e ) => A . parse ( JSON . parse ( e ) ) ;
161
+ } ) , L = ( t ) => F . parse ( JSON . parse ( t ) ) ;
162
162
var u ;
163
- class L {
164
- constructor ( t ) {
165
- y ( this , u , W ( ) ) ;
166
- this . config = t ?? { } ;
163
+ class M {
164
+ constructor ( e ) {
165
+ y ( this , u , J ( ) ) ;
166
+ this . config = e ?? { } ;
167
167
}
168
168
get config ( ) {
169
169
return o ( this , u ) ;
170
170
}
171
- set config ( t ) {
172
- t = _ ( t ) ? J ( t ) : t , $ ( this , u , {
171
+ set config ( e ) {
172
+ e = E ( e ) ? L ( e ) : e , $ ( this , u , {
173
173
...o ( this , u ) ,
174
- ...t ,
174
+ ...e ,
175
175
qsConfig : {
176
- ...E ( ) ,
177
- ...( t == null ? void 0 : t . qsConfig ) ?? { }
176
+ ...P ( ) ,
177
+ ...( e == null ? void 0 : e . qsConfig ) ?? { }
178
178
}
179
179
} ) ;
180
180
}
@@ -184,34 +184,34 @@ class L {
184
184
get origin ( ) {
185
185
return o ( this , u ) . absolute ? this . base : "" ;
186
186
}
187
- has ( t ) {
188
- return Object . hasOwn ( o ( this , u ) . routes , t ) ;
187
+ has ( e ) {
188
+ return Object . hasOwn ( o ( this , u ) . routes , e ) ;
189
189
}
190
- compile ( t , s ) {
191
- const n = this . getRoute ( t ) , { substituted : h , url : f } = n . compile ( s ) , l = s . _query ?? { } ;
190
+ compile ( e , s ) {
191
+ const n = this . getRoute ( e ) , { substituted : h , url : f } = n . compile ( s ) , l = s . _query ?? { } ;
192
192
delete s . _query ;
193
193
for ( const i of Object . keys ( s ) )
194
194
h . includes ( i ) || ( Object . hasOwn ( l , i ) && console . warn ( `Duplicate "${ i } " in params and params.query may cause issues` ) , l [ i ] = s [ i ] ) ;
195
- return f + D ( l , o ( this , u ) . qsConfig ) ;
195
+ return f + N ( l , o ( this , u ) . qsConfig ) ;
196
196
}
197
- getRoute ( t ) {
198
- if ( ! this . has ( t ) )
199
- throw new Error ( `No such route "${ t } " in the route list` ) ;
200
- return new I ( t , o ( this , u ) . routes [ t ] , this ) ;
197
+ getRoute ( e ) {
198
+ if ( ! this . has ( e ) )
199
+ throw new Error ( `No such route "${ e } " in the route list` ) ;
200
+ return new W ( e , o ( this , u ) . routes [ e ] , this ) ;
201
201
}
202
202
}
203
203
u = new WeakMap ( ) ;
204
- const q = new L ( ) , T = ( e ) => ( q . config = e ?? { } , q . config ) , M = ( e , t ) => q . compile ( e , t ?? { } ) , Z = ( e ) => q . has ( e ) , G = {
205
- install ( e ) {
206
- e . mixin ( {
207
- methods : { route : M }
208
- } ) ;
204
+ const q = new M ( ) , T = ( t ) => ( q . config = t ?? { } , q . config ) , O = ( t , e ) => q . compile ( t , e ?? { } ) , Z = ( t ) => q . has ( t ) , G = {
205
+ install ( t ) {
206
+ Number ( t . version . split ( "." ) [ 0 ] ) < 3 ? t . mixin ( {
207
+ methods : { route : O }
208
+ } ) : ( t . config . globalProperties . route = O , t . provide ( "route" , O ) ) ;
209
209
}
210
210
} ;
211
211
export {
212
- L as Router ,
212
+ M as Router ,
213
213
G as ZigliteVuePlugin ,
214
214
T as configureRouter ,
215
215
Z as hasRoute ,
216
- M as route
216
+ O as route
217
217
} ;
0 commit comments