mobx-route 1.3.3 → 2.0.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/README.md +174 -8
- package/index.cjs +1 -1
- package/index.d.ts +61 -45
- package/index.js +1 -1
- package/package.json +7 -7
- package/view-model.cjs +1 -1
- package/view-model.d.ts +42 -36
- package/view-model.js +1 -1
- package/{virtual-route-Chv5K9C8.js → virtual-route-C21P-S6I.js} +5 -2
- package/virtual-route-C21P-S6I.js.map +1 -0
- package/{virtual-route-sU8rVTsu.cjs → virtual-route-DCnOqDz5.cjs} +5 -2
- package/virtual-route-DCnOqDz5.cjs.map +1 -0
- package/virtual-route-Chv5K9C8.js.map +0 -1
- package/virtual-route-sU8rVTsu.cjs.map +0 -1
package/view-model.d.ts
CHANGED
|
@@ -5,16 +5,19 @@ import { AnyObject, EmptyObject, IsPartial, Maybe, MaybePromise, Class } from 'y
|
|
|
5
5
|
import { RawQueryParamsData, History, IQueryParams } from 'mobx-location-history';
|
|
6
6
|
import { ParseOptions, MatchOptions, ParamData, TokenData } from 'path-to-regexp';
|
|
7
7
|
|
|
8
|
-
interface VirtualOpenExtraParams extends Omit<RouteNavigateParams
|
|
8
|
+
interface VirtualOpenExtraParams<TQueryParams extends Record<string, any> = AnyObject> extends Omit<RouteNavigateParams<TQueryParams>, 'state' | 'mergeQuery'> {
|
|
9
9
|
}
|
|
10
|
-
interface AbstractVirtualRoute<TParams extends AnyObject | EmptyObject = EmptyObject> {
|
|
10
|
+
interface AbstractVirtualRoute<TParams extends AnyObject | EmptyObject = EmptyObject, TQueryParams extends Record<string, any> = AnyObject> {
|
|
11
11
|
isOpened: boolean;
|
|
12
12
|
isOpening: boolean;
|
|
13
13
|
params: TParams | null;
|
|
14
14
|
/**
|
|
15
15
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#open)
|
|
16
16
|
*/
|
|
17
|
-
open(...args: IsPartial<TParams> extends true ? [
|
|
17
|
+
open(...args: IsPartial<TParams> extends true ? [
|
|
18
|
+
params?: Maybe<TParams>,
|
|
19
|
+
extraParams?: VirtualOpenExtraParams<TQueryParams>
|
|
20
|
+
] : [params: TParams, extraParams?: VirtualOpenExtraParams<TQueryParams>]): Promise<void>;
|
|
18
21
|
}
|
|
19
22
|
|
|
20
23
|
interface AbstractRouteGroup<TRoutesCollection extends RoutesCollection = RoutesCollection> {
|
|
@@ -27,7 +30,7 @@ type RoutesArrayCollection = AnyAbstractRouteEntity[];
|
|
|
27
30
|
type RoutesObjectCollection = Record<string, AnyAbstractRouteEntity>;
|
|
28
31
|
type RoutesCollection = RoutesArrayCollection | RoutesObjectCollection;
|
|
29
32
|
|
|
30
|
-
type NavigationTrx<TParams extends AnyObject = AnyObject> = {
|
|
33
|
+
type NavigationTrx<TParams extends AnyObject = AnyObject, TQueryParams extends Record<string, any> = AnyObject> = {
|
|
31
34
|
state?: any;
|
|
32
35
|
/**
|
|
33
36
|
* path parameters
|
|
@@ -37,19 +40,19 @@ type NavigationTrx<TParams extends AnyObject = AnyObject> = {
|
|
|
37
40
|
params?: TParams;
|
|
38
41
|
url: string;
|
|
39
42
|
replace?: boolean;
|
|
40
|
-
query?:
|
|
43
|
+
query?: Partial<TQueryParams>;
|
|
41
44
|
preferSkipHistoryUpdate?: boolean;
|
|
42
45
|
};
|
|
43
46
|
/**
|
|
44
47
|
* Returning `false` means ignore navigation
|
|
45
48
|
*/
|
|
46
49
|
type BeforeOpenFeedback = void | boolean | Pick<NavigationTrx, 'url' | 'state' | 'replace'>;
|
|
47
|
-
interface UrlCreateParams<TInputParams> {
|
|
50
|
+
interface UrlCreateParams<TInputParams, TQueryParams extends Record<string, any> = AnyObject> {
|
|
48
51
|
baseUrl?: string | undefined;
|
|
49
52
|
params: TInputParams;
|
|
50
|
-
query:
|
|
53
|
+
query: Partial<TQueryParams>;
|
|
51
54
|
}
|
|
52
|
-
type UrlCreateParamsFn<TInputParams = any> = (params: UrlCreateParams<TInputParams>, currentQueryData: RawQueryParamsData) => Maybe<UrlCreateParams<TInputParams>>;
|
|
55
|
+
type UrlCreateParamsFn<TInputParams = any, TQueryParams extends Record<string, any> = AnyObject> = (params: UrlCreateParams<TInputParams, TQueryParams>, currentQueryData: RawQueryParamsData) => Maybe<UrlCreateParams<TInputParams, TQueryParams>>;
|
|
53
56
|
/**
|
|
54
57
|
* Output options for `createUrl()` (third argument).
|
|
55
58
|
* @see [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl)
|
|
@@ -60,7 +63,7 @@ interface CreatedUrlOutputParams {
|
|
|
60
63
|
/** @see [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl) */
|
|
61
64
|
omitQuery?: boolean;
|
|
62
65
|
}
|
|
63
|
-
interface RouteConfiguration<TPath extends string, TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>, TOutputParams extends AnyObject = ParsedPathParams<TPath>,
|
|
66
|
+
interface RouteConfiguration<TPath extends string, TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>, TOutputParams extends AnyObject = ParsedPathParams<TPath>, TQueryParams extends Record<string, any> = AnyObject> extends Omit<Partial<RouteGlobalConfig>, 'createUrl'> {
|
|
64
67
|
/**
|
|
65
68
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#abortsignal)
|
|
66
69
|
*/
|
|
@@ -78,7 +81,7 @@ interface RouteConfiguration<TPath extends string, TInputParams extends InputPat
|
|
|
78
81
|
meta?: AnyObject;
|
|
79
82
|
parseOptions?: ParseOptions;
|
|
80
83
|
matchOptions?: MatchOptions & ParseOptions;
|
|
81
|
-
parent?:
|
|
84
|
+
parent?: AnyRoute | null;
|
|
82
85
|
children?: AnyRoute[];
|
|
83
86
|
/**
|
|
84
87
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)
|
|
@@ -91,7 +94,7 @@ interface RouteConfiguration<TPath extends string, TInputParams extends InputPat
|
|
|
91
94
|
/**
|
|
92
95
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#beforeopen)
|
|
93
96
|
*/
|
|
94
|
-
beforeOpen?: (navigationTransaction: NavigationTrx<NoInfer<TInputParams>>) => MaybePromise<BeforeOpenFeedback>;
|
|
97
|
+
beforeOpen?: (navigationTransaction: NavigationTrx<NoInfer<TInputParams>, NoInfer<TQueryParams>>) => MaybePromise<BeforeOpenFeedback>;
|
|
95
98
|
/**
|
|
96
99
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#afterclose)
|
|
97
100
|
*/
|
|
@@ -99,15 +102,15 @@ interface RouteConfiguration<TPath extends string, TInputParams extends InputPat
|
|
|
99
102
|
/**
|
|
100
103
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#afteropen)
|
|
101
104
|
*/
|
|
102
|
-
afterOpen?: (data: ParsedPathData<NoInfer<TPath>>, route: Route<NoInfer<TPath>, NoInfer<TInputParams>, NoInfer<TOutputParams>, NoInfer<
|
|
105
|
+
afterOpen?: (data: ParsedPathData<NoInfer<TPath>>, route: Route<NoInfer<TPath>, NoInfer<TInputParams>, NoInfer<TOutputParams>, NoInfer<TQueryParams>>) => void;
|
|
103
106
|
/**
|
|
104
107
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#afterupdate)
|
|
105
108
|
*/
|
|
106
|
-
afterUpdate?: (data: ParsedPathData<NoInfer<TPath>>, route: Route<NoInfer<TPath>, NoInfer<TInputParams>, NoInfer<TOutputParams>, NoInfer<
|
|
109
|
+
afterUpdate?: (data: ParsedPathData<NoInfer<TPath>>, route: Route<NoInfer<TPath>, NoInfer<TInputParams>, NoInfer<TOutputParams>, NoInfer<TQueryParams>>) => void;
|
|
107
110
|
/**
|
|
108
111
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl)
|
|
109
112
|
*/
|
|
110
|
-
createUrl?: UrlCreateParamsFn<TInputParams>;
|
|
113
|
+
createUrl?: UrlCreateParamsFn<TInputParams, TQueryParams>;
|
|
111
114
|
}
|
|
112
115
|
type AnyRoute = Route<any, any, any, any>;
|
|
113
116
|
type InputPathParam = string | number | boolean | null;
|
|
@@ -129,10 +132,10 @@ type PathToObject<Path extends string, PropertyValue = string> = Simplify<Path e
|
|
|
129
132
|
} : {}>;
|
|
130
133
|
type ParsedPathParams<Path extends string> = PathToObject<Path, ParsedPathParam>;
|
|
131
134
|
type InputPathParams<Path extends string> = PathToObject<Path, InputPathParam>;
|
|
132
|
-
interface RouteNavigateParams {
|
|
135
|
+
interface RouteNavigateParams<TQueryParams extends Record<string, any> = AnyObject> {
|
|
133
136
|
replace?: boolean;
|
|
134
137
|
state?: any;
|
|
135
|
-
query?:
|
|
138
|
+
query?: Partial<TQueryParams>;
|
|
136
139
|
mergeQuery?: boolean;
|
|
137
140
|
}
|
|
138
141
|
interface ParsedPathData<TPath extends string> {
|
|
@@ -145,8 +148,8 @@ interface ParsedPathData<TPath extends string> {
|
|
|
145
148
|
*
|
|
146
149
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html)
|
|
147
150
|
*/
|
|
148
|
-
declare class Route<TPath extends string, TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>, TOutputParams extends AnyObject = ParsedPathParams<TPath>,
|
|
149
|
-
protected config: RouteConfiguration<TPath, TInputParams, TOutputParams,
|
|
151
|
+
declare class Route<TPath extends string, TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>, TOutputParams extends AnyObject = ParsedPathParams<TPath>, TQueryParams extends Record<string, any> = AnyObject> {
|
|
152
|
+
protected config: RouteConfiguration<TPath, TInputParams, TOutputParams, TQueryParams>;
|
|
150
153
|
private isDestroyed?;
|
|
151
154
|
private disposer?;
|
|
152
155
|
protected history: History;
|
|
@@ -155,7 +158,7 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
155
158
|
*
|
|
156
159
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#parent)
|
|
157
160
|
*/
|
|
158
|
-
parent:
|
|
161
|
+
parent: AnyRoute | null;
|
|
159
162
|
query: IQueryParams;
|
|
160
163
|
private _tokenData;
|
|
161
164
|
private _matcher?;
|
|
@@ -189,7 +192,7 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
189
192
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#children)
|
|
190
193
|
*/
|
|
191
194
|
children: AnyRoute[];
|
|
192
|
-
constructor(pathDeclaration: TPath, config?: RouteConfiguration<TPath, TInputParams, TOutputParams,
|
|
195
|
+
constructor(pathDeclaration: TPath, config?: RouteConfiguration<TPath, TInputParams, TOutputParams, TQueryParams>);
|
|
193
196
|
protected get baseUrl(): string | undefined;
|
|
194
197
|
/**
|
|
195
198
|
* Checks whether current route matches provided path.
|
|
@@ -236,7 +239,7 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
236
239
|
*
|
|
237
240
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend)
|
|
238
241
|
*/
|
|
239
|
-
extend<TExtendedPath extends string, TExtendedInputParams extends InputPathParams<`${TPath}${TExtendedPath}`> = InputPathParams<`${TPath}${TExtendedPath}`>, TExtendedOutputParams extends AnyObject = TInputParams & ParsedPathParams<`${TPath}${TExtendedPath}
|
|
242
|
+
extend<TExtendedPath extends string, TExtendedInputParams extends InputPathParams<`${TPath}${TExtendedPath}`> = InputPathParams<`${TPath}${TExtendedPath}`>, TExtendedOutputParams extends AnyObject = TInputParams & ParsedPathParams<`${TPath}${TExtendedPath}`>, TExtendedQueryParams extends Record<string, any> = TQueryParams>(pathDeclaration: TExtendedPath, config?: Omit<RouteConfiguration<`${TPath}${TExtendedPath}`, TInputParams & TExtendedInputParams, TExtendedOutputParams, TExtendedQueryParams>, 'parent'>): Route<`${TPath}${TExtendedPath}`, TInputParams & TExtendedInputParams, TExtendedOutputParams, TExtendedQueryParams>;
|
|
240
243
|
/**
|
|
241
244
|
* Manually add child routes.
|
|
242
245
|
*
|
|
@@ -261,11 +264,11 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
261
264
|
*/
|
|
262
265
|
createUrl(...args: IsPartial<TInputParams> extends true ? [
|
|
263
266
|
params?: Maybe<TInputParams>,
|
|
264
|
-
query?: Maybe<
|
|
267
|
+
query?: Maybe<Partial<TQueryParams>>,
|
|
265
268
|
mergeQueryOrParams?: boolean | CreatedUrlOutputParams
|
|
266
269
|
] : [
|
|
267
270
|
params: TInputParams,
|
|
268
|
-
query?: Maybe<
|
|
271
|
+
query?: Maybe<Partial<TQueryParams>>,
|
|
269
272
|
mergeQueryOrParams?: boolean | CreatedUrlOutputParams
|
|
270
273
|
]): string;
|
|
271
274
|
/**
|
|
@@ -275,19 +278,22 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
275
278
|
*/
|
|
276
279
|
open(...args: IsPartial<TInputParams> extends true ? [
|
|
277
280
|
params?: TInputParams | null | undefined,
|
|
278
|
-
navigateParams?: RouteNavigateParams
|
|
279
|
-
] : [
|
|
281
|
+
navigateParams?: RouteNavigateParams<TQueryParams>
|
|
282
|
+
] : [
|
|
283
|
+
params: TInputParams,
|
|
284
|
+
navigateParams?: RouteNavigateParams<TQueryParams>
|
|
285
|
+
]): Promise<void>;
|
|
280
286
|
open(...args: IsPartial<TInputParams> extends true ? [
|
|
281
287
|
params?: TInputParams | null | undefined,
|
|
282
|
-
replace?: RouteNavigateParams['replace'],
|
|
283
|
-
query?: RouteNavigateParams['query']
|
|
288
|
+
replace?: RouteNavigateParams<TQueryParams>['replace'],
|
|
289
|
+
query?: RouteNavigateParams<TQueryParams>['query']
|
|
284
290
|
] : [
|
|
285
291
|
params: TInputParams,
|
|
286
|
-
replace?: RouteNavigateParams['replace'],
|
|
287
|
-
query?: RouteNavigateParams['query']
|
|
292
|
+
replace?: RouteNavigateParams<TQueryParams>['replace'],
|
|
293
|
+
query?: RouteNavigateParams<TQueryParams>['query']
|
|
288
294
|
]): Promise<void>;
|
|
289
|
-
open(url: string, navigateParams?: RouteNavigateParams): Promise<void>;
|
|
290
|
-
open(url: string, replace?: RouteNavigateParams['replace'], query?: RouteNavigateParams['query']): Promise<void>;
|
|
295
|
+
open(url: string, navigateParams?: RouteNavigateParams<TQueryParams>): Promise<void>;
|
|
296
|
+
open(url: string, replace?: RouteNavigateParams<TQueryParams>['replace'], query?: RouteNavigateParams<TQueryParams>['query']): Promise<void>;
|
|
291
297
|
/**
|
|
292
298
|
* Updates the current route if it is already open.
|
|
293
299
|
* Unlike `open`, this is a no-op if the route is not open,
|
|
@@ -296,12 +302,12 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
296
302
|
*
|
|
297
303
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#update)
|
|
298
304
|
*/
|
|
299
|
-
update(params?: TInputParams | null | undefined, navigateParams?: RouteNavigateParams): Promise<void>;
|
|
300
|
-
update(params?: TInputParams | null | undefined, replace?: RouteNavigateParams['replace'], query?: RouteNavigateParams['query']): Promise<void>;
|
|
301
|
-
update(url: string, navigateParams?: RouteNavigateParams): Promise<void>;
|
|
302
|
-
update(url: string, replace?: RouteNavigateParams['replace'], query?: RouteNavigateParams['query']): Promise<void>;
|
|
305
|
+
update(params?: TInputParams | null | undefined, navigateParams?: RouteNavigateParams<TQueryParams>): Promise<void>;
|
|
306
|
+
update(params?: TInputParams | null | undefined, replace?: RouteNavigateParams<TQueryParams>['replace'], query?: RouteNavigateParams<TQueryParams>['query']): Promise<void>;
|
|
307
|
+
update(url: string, navigateParams?: RouteNavigateParams<TQueryParams>): Promise<void>;
|
|
308
|
+
update(url: string, replace?: RouteNavigateParams<TQueryParams>['replace'], query?: RouteNavigateParams<TQueryParams>['query']): Promise<void>;
|
|
303
309
|
protected get tokenData(): TokenData;
|
|
304
|
-
protected confirmOpening(trx: NavigationTrx<TInputParams>): Promise<true | undefined>;
|
|
310
|
+
protected confirmOpening(trx: NavigationTrx<TInputParams, TQueryParams>): Promise<true | undefined>;
|
|
305
311
|
protected confirmClosing(): boolean;
|
|
306
312
|
private firstPathMatchingRun;
|
|
307
313
|
private checkPathMatch;
|
package/view-model.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { computed } from "mobx";
|
|
2
2
|
import { ViewModelBase, applyObservable } from "mobx-view-model";
|
|
3
|
-
import { r as routeConfig } from "./virtual-route-
|
|
3
|
+
import { r as routeConfig } from "./virtual-route-C21P-S6I.js";
|
|
4
4
|
const annotations = [
|
|
5
5
|
[computed.struct, "pathParams"],
|
|
6
6
|
[computed, "query"]
|
|
@@ -332,7 +332,10 @@ class Route {
|
|
|
332
332
|
state: rawState,
|
|
333
333
|
query: rawQuery,
|
|
334
334
|
mergeQuery: rawMergeQuery
|
|
335
|
-
} = typeof args[1] === "boolean" || args.length > 2 ? {
|
|
335
|
+
} = typeof args[1] === "boolean" || args.length > 2 ? {
|
|
336
|
+
replace: args[1],
|
|
337
|
+
query: args[2]
|
|
338
|
+
} : args[1] ?? {};
|
|
336
339
|
const mergeQuery = rawMergeQuery ?? this.isAbleToMergeQuery;
|
|
337
340
|
const query = mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery;
|
|
338
341
|
const params = typeof args[0] === "string" ? void 0 : args[0];
|
|
@@ -818,4 +821,4 @@ export {
|
|
|
818
821
|
groupRoutes as g,
|
|
819
822
|
routeConfig as r
|
|
820
823
|
};
|
|
821
|
-
//# sourceMappingURL=virtual-route-
|
|
824
|
+
//# sourceMappingURL=virtual-route-C21P-S6I.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-route-C21P-S6I.js","sources":["../src/core/config/config.ts","../src/core/route/route.ts","../src/core/route-group/route-group.ts","../src/core/router/router.ts","../src/core/virtual-route/virtual-route.ts"],"sourcesContent":["import {\n createBrowserHistory,\n createQueryParams,\n type History,\n type IQueryParams,\n isObservableHistory,\n} from 'mobx-location-history';\nimport { createGlobalDynamicConfig } from 'yummies/complex';\n\nimport type { RouteGlobalConfig } from './config.types.js';\n\nexport const routeConfig = createGlobalDynamicConfig<RouteGlobalConfig>(\n (update, current) => {\n let history: History;\n let queryParams: IQueryParams | undefined;\n\n if (update?.history) {\n history = update.history;\n queryParams = update.queryParams;\n\n if (current?.history && isObservableHistory(current.history)) {\n current.history.destroy();\n }\n } else if (current?.history) {\n history = current.history;\n queryParams = update?.queryParams ?? current.queryParams;\n } else {\n history = createBrowserHistory();\n }\n\n queryParams ??= createQueryParams({ history });\n\n return {\n ...update,\n history,\n queryParams,\n };\n },\n Symbol.for('MOBX_ROUTE_CONFIG'),\n);\n","import { comparer, computed, observable, reaction, runInAction } from 'mobx';\nimport {\n buildSearchString,\n type History,\n type IQueryParams,\n} from 'mobx-location-history';\nimport {\n compile,\n match,\n type ParamData,\n parse,\n type TokenData,\n} from 'path-to-regexp';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { AnyObject, IsPartial, Maybe } from 'yummies/types';\nimport { routeConfig } from '../config/index.js';\nimport type {\n AnyRoute,\n CreatedUrlOutputParams,\n InputPathParams,\n NavigationTrx,\n ParsedPathData,\n ParsedPathParams,\n RouteConfiguration,\n RouteNavigateParams,\n UrlCreateParams,\n} from './route.types.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst annotations: ObservableAnnotationsArray<Route<any, any, any, any>> = [\n [\n computed,\n 'isPathMatched',\n 'isOpened',\n 'isOpening',\n 'path',\n 'absolutePath',\n 'hasOpenedChildren',\n 'isAbleToMergeQuery',\n 'baseUrl',\n ],\n [computed.struct, 'parsedPathData', 'params'],\n [observable, 'children'],\n [observable.ref, 'parent', 'status'],\n];\n\n/**\n * Class for creating path based route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html)\n */\nexport class Route<\n TPath extends string,\n TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>,\n TOutputParams extends AnyObject = ParsedPathParams<TPath>,\n TQueryParams extends Record<string, any> = AnyObject,\n> {\n private isDestroyed?: boolean;\n private disposer?: VoidFunction;\n\n protected history: History;\n\n /**\n * Parent route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#parent)\n */\n parent: AnyRoute | null;\n\n query: IQueryParams;\n\n private _tokenData: TokenData | undefined;\n private _matcher?: ReturnType<typeof match>;\n private _compiler?: ReturnType<typeof compile>;\n private ignoreOpenByPathMatch = false;\n private isUpdate = false;\n private updateDisposer?: VoidFunction;\n\n protected status:\n | 'opening'\n | 'closed'\n | 'open-rejected'\n | 'open-confirmed'\n | 'unknown';\n\n meta?: AnyObject;\n\n /**\n * Route path pattern declaration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#pathdeclaration)\n */\n pathDeclaration: TPath;\n\n /**\n * Indicates if this route is an index route. Index routes activate when parent route path matches exactly.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isindex)\n */\n isIndex: boolean;\n\n /**\n * Indicates if this route is an hash route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ishash)\n */\n isHash: boolean;\n\n /**\n * Array of child routes.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#children)\n */\n children: AnyRoute[] = [];\n\n constructor(\n pathDeclaration: TPath,\n protected config: RouteConfiguration<\n TPath,\n TInputParams,\n TOutputParams,\n TQueryParams\n > = {},\n ) {\n this.history = config.history ?? routeConfig.get().history;\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n this.pathDeclaration = pathDeclaration;\n this.isIndex = !!this.config.index;\n this.isHash = !!this.config.hash;\n this.meta = this.config.meta;\n this.status = 'unknown';\n this.parent = config.parent ?? null;\n\n applyObservable(this, annotations);\n\n if (this.config.abortSignal?.aborted) {\n this.isDestroyed = true;\n } else {\n this.disposer = reaction(() => this.isPathMatched, this.checkPathMatch, {\n fireImmediately: true,\n });\n this.updateDisposer = reaction(\n () => {\n if (this.status !== 'open-confirmed') return undefined;\n return [this.parsedPathData, this.query.data] as const;\n },\n (value, prevValue) => {\n if (prevValue === undefined) return;\n if (value === undefined) return;\n if (!this.parsedPathData) return;\n this.config.afterUpdate?.(this.parsedPathData, this);\n },\n {\n fireImmediately: false,\n signal: this.config.abortSignal,\n equals: comparer.structural,\n },\n );\n this.config.abortSignal?.addEventListener('abort', () => this.destroy(), {\n once: true,\n });\n }\n }\n\n protected get baseUrl() {\n const baseUrl = this.config.baseUrl ?? routeConfig.get().baseUrl;\n return baseUrl?.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;\n }\n\n /**\n * Checks whether current route matches provided path.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#matchpath)\n */\n matchPath(path?: Maybe<string>): ParsedPathData<TPath> | null {\n let pathnameToCheck: string;\n\n if (path != null) {\n pathnameToCheck = path;\n } else if (this.isHash) {\n pathnameToCheck = this.history.location.hash.slice(1);\n } else {\n pathnameToCheck = this.history.location.pathname;\n }\n\n if (this.baseUrl) {\n if (!pathnameToCheck.startsWith(this.baseUrl)) {\n return null;\n }\n\n pathnameToCheck = pathnameToCheck.replace(this.baseUrl, '');\n }\n\n if (\n (this.pathDeclaration === '' || this.pathDeclaration === '/') &&\n (pathnameToCheck === '/' || pathnameToCheck === '')\n ) {\n return { params: {} as any, path: pathnameToCheck };\n }\n\n this._matcher ??= match(this.tokenData, {\n end: this.config.exact ?? false,\n ...this.config.matchOptions,\n });\n const parsed = this._matcher(pathnameToCheck);\n\n if (parsed === false) {\n return null;\n }\n\n return parsed as ParsedPathData<TPath>;\n }\n\n protected get parsedPathData(): ParsedPathData<TPath> | null {\n return this.matchPath();\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopening)\n *\n * Also true in the short gap after history already matches this route but\n * `confirmOpening` has not started yet (e.g. browser Back) — otherwise every\n * route looks closed for one tick and RouteViewGroup unmounts the page.\n */\n get isOpening() {\n if (this.status === 'opening') {\n return true;\n }\n\n if (\n this.isDestroyed ||\n !this.isPathMatched ||\n this.params === null ||\n this.status === 'open-confirmed' ||\n this.status === 'open-rejected'\n ) {\n return false;\n }\n\n return this.status === 'closed' || this.status === 'unknown';\n }\n\n /**\n * Matched path segment for current URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#path)\n */\n get path(): string | null {\n return this.parsedPathData?.path ?? null;\n }\n\n /**\n * Matched path segment for current URL with base URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#absolutepath)\n */\n get absolutePath(): string | null {\n const path = this.path;\n\n if (path === null) {\n return null;\n }\n\n return `${this.baseUrl || ''}${path}`;\n }\n\n /**\n * Current parsed path parameters.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)\n */\n get params(): TOutputParams | null {\n if (!this.parsedPathData?.params) {\n return null;\n }\n\n if (this.config.params) {\n const result = this.config.params(\n this.parsedPathData.params,\n this.config.meta,\n );\n return result || null;\n }\n\n return (\n (this.parsedPathData?.params as unknown as Maybe<TOutputParams>) ?? null\n );\n }\n\n protected get isPathMatched() {\n return this.parsedPathData !== null;\n }\n\n /**\n * Defines the \"open\" state for this route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)\n */\n get isOpened() {\n if (\n this.isDestroyed ||\n !this.isPathMatched ||\n this.params === null ||\n this.status !== 'open-confirmed'\n ) {\n return false;\n }\n\n return (\n // this.parsedPathData is defined because this.params !== null\n !this.config.checkOpened || this.config.checkOpened(this.parsedPathData!)\n );\n }\n\n /**\n * Allows to create child route based on this route with merging this route path and extending path.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend)\n */\n extend<\n TExtendedPath extends string,\n TExtendedInputParams extends\n InputPathParams<`${TPath}${TExtendedPath}`> = InputPathParams<`${TPath}${TExtendedPath}`>,\n TExtendedOutputParams extends AnyObject = TInputParams &\n ParsedPathParams<`${TPath}${TExtendedPath}`>,\n TExtendedQueryParams extends Record<string, any> = TQueryParams,\n >(\n pathDeclaration: TExtendedPath,\n config?: Omit<\n RouteConfiguration<\n `${TPath}${TExtendedPath}`,\n TInputParams & TExtendedInputParams,\n TExtendedOutputParams,\n TExtendedQueryParams\n >,\n 'parent'\n >,\n ) {\n type ExtendedRoutePath = `${TPath}${TExtendedPath}`;\n const { index, params, exact, ...configFromCurrentRoute } = this.config;\n\n const extendedChild = new Route<\n ExtendedRoutePath,\n TInputParams & TExtendedInputParams,\n TExtendedOutputParams,\n TExtendedQueryParams\n >(`${this.pathDeclaration}${pathDeclaration}`, {\n ...configFromCurrentRoute,\n ...config,\n parent: this,\n } as any);\n\n this.addChildren(extendedChild as any);\n\n return extendedChild;\n }\n\n /**\n * Manually add child routes.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#addchildren)\n */\n addChildren(...routes: AnyRoute[]) {\n this.children.push(...routes);\n }\n\n /**\n * Remove specified routes from children.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#removechildren)\n */\n removeChildren(...routes: AnyRoute[]) {\n this.children = this.children.filter((child) => !routes.includes(child));\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#hasopenedchildren)\n */\n get hasOpenedChildren(): boolean {\n return this.children.some(\n (child) => child.isOpened || child.hasOpenedChildren,\n );\n }\n\n protected processParams(\n params?: TInputParams | null | undefined,\n ): ParamData | undefined {\n if (params == null) return undefined;\n\n const result: ParamData = {};\n for (const [key, value] of Object.entries(params)) {\n if (value != null) {\n result[key] = Array.isArray(value) ? value.map(String) : String(value);\n }\n }\n return result;\n }\n\n /**\n * Generates full route URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl)\n */\n createUrl(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: Maybe<TInputParams>,\n query?: Maybe<Partial<TQueryParams>>,\n mergeQueryOrParams?: boolean | CreatedUrlOutputParams,\n ]\n : [\n params: TInputParams,\n query?: Maybe<Partial<TQueryParams>>,\n mergeQueryOrParams?: boolean | CreatedUrlOutputParams,\n ]\n ) {\n const params = args[0];\n const rawQuery = args[1];\n const mergeQueryOrOutputParams = args[2] ?? this.isAbleToMergeQuery;\n const outputParams: Maybe<CreatedUrlOutputParams> =\n typeof mergeQueryOrOutputParams === 'boolean'\n ? { mergeQuery: mergeQueryOrOutputParams }\n : mergeQueryOrOutputParams;\n\n const query = outputParams?.mergeQuery\n ? ({ ...this.query.data, ...rawQuery } as Partial<TQueryParams>)\n : ((rawQuery ?? {}) as Partial<TQueryParams>);\n\n this._compiler ??= compile(this.tokenData);\n\n const defaultUrlCreateParams: UrlCreateParams<TInputParams, TQueryParams> =\n {\n baseUrl: this.baseUrl,\n params: params as TInputParams,\n query,\n };\n const urlCreateParams: UrlCreateParams<TInputParams, TQueryParams> =\n this.config.createUrl?.(defaultUrlCreateParams, this.query.data) ??\n routeConfig.get().createUrl?.(defaultUrlCreateParams, this.query.data) ??\n defaultUrlCreateParams;\n\n let path: string;\n\n try {\n path = this._compiler(this.processParams(urlCreateParams.params));\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'Error #1: Route path compilation failed\\n' +\n 'The path pattern could not be built into a URL (often missing or invalid params for a `:param` segment). Using fallbackPath or \"/\".\\n' +\n 'See docs: https://js2me.github.io/mobx-route/errors/1',\n e,\n );\n } else {\n console.error('minified error #1;see mobx-route docs', e);\n }\n path = this.config.fallbackPath ?? routeConfig.get().fallbackPath ?? '/';\n }\n\n const url = `${urlCreateParams.baseUrl || ''}${this.isHash ? '#' : ''}${path}`;\n\n if (outputParams?.omitQuery) {\n return url;\n }\n\n return `${url}${buildSearchString(urlCreateParams.query)}`;\n }\n\n /**\n * Navigates to this route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open)\n */\n open(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: TInputParams | null | undefined,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ]\n : [\n params: TInputParams,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ]\n ): Promise<void>;\n open(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: TInputParams | null | undefined,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ]\n : [\n params: TInputParams,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ]\n ): Promise<void>;\n open(\n url: string,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n open(\n url: string,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n\n async open(...args: any[]) {\n const {\n replace,\n state: rawState,\n query: rawQuery,\n mergeQuery: rawMergeQuery,\n } = typeof args[1] === 'boolean' || args.length > 2\n ? ({\n replace: args[1],\n query: args[2],\n } as RouteNavigateParams<TQueryParams>)\n : ((args[1] ?? {}) as RouteNavigateParams<TQueryParams>);\n\n const mergeQuery = rawMergeQuery ?? this.isAbleToMergeQuery;\n const query = (\n mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery\n ) as Partial<TQueryParams> | undefined;\n\n const params = typeof args[0] === 'string' ? undefined : args[0];\n const url =\n typeof args[0] === 'string' ? args[0] : this.createUrl(args[0], query);\n\n const trx: NavigationTrx<TInputParams, TQueryParams> = {\n url,\n params: params as TInputParams,\n replace,\n state: rawState ?? null,\n query,\n };\n\n this.isUpdate = this.status === 'open-confirmed';\n this.ignoreOpenByPathMatch = true;\n const isConfirmed = await this.confirmOpening(trx);\n\n if (isConfirmed !== true) {\n this.ignoreOpenByPathMatch = false;\n this.isUpdate = false;\n }\n }\n\n /**\n * Updates the current route if it is already open.\n * Unlike `open`, this is a no-op if the route is not open,\n * defaults to `replace: true` instead of push,\n * and defaults to `mergeQuery: true` when no query params are provided.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#update)\n */\n update(\n params?: TInputParams | null | undefined,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n update(\n params?: TInputParams | null | undefined,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n update(\n url: string,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n update(\n url: string,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n\n async update(...args: any[]) {\n if (this.status !== 'open-confirmed') {\n return;\n }\n\n // Reuse current path params when omitted\n if (args[0] == null) {\n args[0] = this.parsedPathData?.params;\n }\n\n const secondArg = args[1];\n const isObjectParams = typeof secondArg === 'object' && secondArg !== null;\n\n if (isObjectParams) {\n args[1] = {\n replace: true,\n ...('query' in secondArg ? {} : { mergeQuery: true }),\n ...secondArg,\n };\n } else if (typeof secondArg === 'boolean') {\n if (args[2] === undefined) {\n args[1] = { replace: secondArg, mergeQuery: true };\n args.length = 2;\n }\n } else if (args.length === 1) {\n args[1] = { replace: true, mergeQuery: true };\n }\n\n return (this.open as (...args: any[]) => Promise<void>)(...args);\n }\n\n protected get tokenData() {\n if (!this._tokenData) {\n this._tokenData = parse(this.pathDeclaration, this.config.parseOptions);\n }\n return this._tokenData;\n }\n\n protected async confirmOpening(\n trx: NavigationTrx<TInputParams, TQueryParams>,\n ) {\n if (!this.isUpdate) {\n runInAction(() => {\n this.status = 'opening';\n });\n }\n\n let skipHistoryUpdate = !!trx.preferSkipHistoryUpdate;\n\n if (skipHistoryUpdate) {\n this.ignoreOpenByPathMatch = false;\n }\n\n if (this.config.beforeOpen) {\n const feedback = await this.config.beforeOpen(trx);\n\n if (feedback === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n });\n\n return;\n }\n\n // Rebuild URL if beforeOpen mutated trx.params\n const newUrl = this.createUrl(\n trx.params as TInputParams,\n trx.query as AnyObject,\n );\n if (newUrl !== trx.url) {\n trx.url = newUrl;\n skipHistoryUpdate = false;\n }\n\n if (typeof feedback === 'object') {\n skipHistoryUpdate = false;\n Object.assign(trx, feedback);\n }\n }\n\n if (this.isDestroyed) {\n return;\n }\n\n if (!skipHistoryUpdate) {\n if (trx.replace) {\n this.history.replace(trx.url, trx.state);\n } else {\n this.history.push(trx.url, trx.state);\n }\n }\n\n if (this.isPathMatched) {\n const wasAlreadyConfirmed = this.status === 'open-confirmed';\n runInAction(() => {\n this.status = 'open-confirmed';\n });\n\n if (this.isUpdate) {\n this.isUpdate = false;\n // afterUpdate handled by updateDisposer reaction\n } else if (!wasAlreadyConfirmed) {\n this.config.afterOpen?.(this.parsedPathData!, this);\n }\n }\n\n return true;\n }\n\n protected confirmClosing() {\n runInAction(() => {\n this.status = 'closed';\n });\n return true;\n }\n\n private firstPathMatchingRun = true;\n\n private checkPathMatch = async (isPathMathched: boolean) => {\n if (this.firstPathMatchingRun) {\n this.firstPathMatchingRun = false;\n // ignore first 'afterClose' callback call\n if (!isPathMathched) {\n return;\n }\n }\n\n if (isPathMathched) {\n // after manual open call\n if (this.ignoreOpenByPathMatch) {\n this.ignoreOpenByPathMatch = false;\n if (this.status === 'opening' && this.parsedPathData) {\n runInAction(() => {\n this.status = 'open-confirmed';\n });\n if (this.isUpdate) {\n this.isUpdate = false;\n this.config.afterUpdate?.(this.parsedPathData, this);\n } else {\n this.config.afterOpen?.(this.parsedPathData, this);\n }\n }\n // update() delegates to confirmOpening\n return;\n }\n\n // Set opening sync to avoid isOpened/isOpening flicker\n if (this.status !== 'opening' && this.status !== 'open-confirmed') {\n runInAction(() => {\n this.status = 'opening';\n });\n }\n\n // already confirmed\n if (this.status === 'open-confirmed') {\n return;\n }\n\n const trx: NavigationTrx<TInputParams, TQueryParams> = {\n url: `${this.parsedPathData!.path}${buildSearchString(this.query.data)}`,\n params: this.parsedPathData!.params as TInputParams,\n state: this.history.location.state,\n query: this.query.data as Partial<TQueryParams>,\n preferSkipHistoryUpdate: true,\n };\n\n await this.confirmOpening(trx);\n } else {\n this.ignoreOpenByPathMatch = false;\n\n const isConfirmed = this.confirmClosing();\n\n if (isConfirmed) {\n this.config.afterClose?.();\n }\n }\n };\n\n private get isAbleToMergeQuery() {\n return this.config.mergeQuery ?? routeConfig.get().mergeQuery;\n }\n\n /**\n * Destroys route subscriptions and reactions.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#destroy)\n */\n destroy() {\n this.isDestroyed = true;\n this.disposer?.();\n this.disposer = undefined;\n this.updateDisposer?.();\n this.updateDisposer = undefined;\n }\n}\n\nexport const createRoute = <\n TPath extends string,\n TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>,\n TOutputParams extends AnyObject = ParsedPathParams<TPath>,\n TQueryParams extends Record<string, any> = AnyObject,\n>(\n path: TPath,\n config?: RouteConfiguration<TPath, TInputParams, TOutputParams, TQueryParams>,\n) => new Route<TPath, TInputParams, TOutputParams, TQueryParams>(path, config);\n","import { computed, observable } from 'mobx';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type {\n AbstractRouteGroup,\n AnyRouteEntity,\n RoutesCollection,\n} from './route-group.types.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst annotations: ObservableAnnotationsArray<RouteGroup<any>> = [\n [computed, 'isOpened', 'indexRoute', 'canNavigate'],\n [observable.shallow, 'routes'],\n];\n\n/**\n * Class for grouping related routes and managing their state.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html)\n */\nexport class RouteGroup<TRoutesCollection extends RoutesCollection>\n implements AbstractRouteGroup<TRoutesCollection>\n{\n routes: TRoutesCollection;\n\n constructor(\n routes: TRoutesCollection,\n private _indexRoute?: AnyRouteEntity,\n ) {\n this.routes = routes;\n\n applyObservable(this, annotations);\n }\n\n /**\n * Returns true if at least one route in the group is open.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#isopened)\n */\n get isOpened(): boolean {\n const routes = Object.values(this.routes);\n return routes.some(\n (route) =>\n route.isOpened ||\n ('hasOpenedChildren' in route && route.hasOpenedChildren),\n );\n }\n\n /**\n * First found index route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#indexroute)\n */\n get indexRoute(): AnyRouteEntity | undefined {\n return (this._indexRoute ??\n Object.values(this.routes).find(\n (route) => 'isIndex' in route && route.isIndex,\n )) as unknown as AnyRouteEntity;\n }\n\n /**\n * `true` if `open()` has a target to navigate to —\n * either an own index route or a nested `RouteGroup` that itself can navigate.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#cannavigate)\n */\n get canNavigate(): boolean {\n if (this.indexRoute) return true;\n\n for (const routeName in this.routes) {\n const route = this.routes[routeName];\n if (route instanceof RouteGroup && route.canNavigate) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Main navigation method for the group.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#open)\n */\n open(...args: any[]) {\n if (this.indexRoute && 'open' in this.indexRoute) {\n this.indexRoute.open(...args);\n return;\n }\n\n for (const routeName in this.routes) {\n const route = this.routes[routeName];\n if (route instanceof RouteGroup && route.canNavigate) {\n route.open(...args);\n return;\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'Warning #1: RouteGroup.open() cannot navigate\\n' +\n 'This group has no index route (`index: true` or `groupRoutes(routes, indexRoute)`) and no navigable nested RouteGroup, so open() does nothing.\\n' +\n 'See docs: https://js2me.github.io/mobx-route/warnings/1',\n );\n } else {\n console.warn('minified warning #1;see mobx-route docs');\n }\n }\n}\n\n/**\n * Helper for creating route groups.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html)\n */\nexport const groupRoutes = <TRoutesCollection extends RoutesCollection>(\n routes: TRoutesCollection,\n indexRoute?: AnyRouteEntity,\n) => new RouteGroup<TRoutesCollection>(routes, indexRoute);\n","import { computed } from 'mobx';\nimport {\n buildSearchString,\n type History,\n type IQueryParams,\n} from 'mobx-location-history';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport { routeConfig } from '../config/index.js';\nimport type { RoutesCollection } from '../route-group/index.js';\nimport type {\n RouterConfiguration,\n RouterNavigateOptions,\n} from './router.types.js';\n\nconst annotations: ObservableAnnotationsArray<Router<any>> = [\n [computed.struct, 'location'],\n];\n\n/**\n * Class for centralized routing management.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Router.html)\n */\nexport class Router<TRoutesCollection extends RoutesCollection> {\n routes: TRoutesCollection;\n history: History;\n query: IQueryParams;\n\n constructor(config: RouterConfiguration<TRoutesCollection>) {\n this.routes = config.routes;\n this.history = config.history ?? routeConfig.get().history;\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n\n applyObservable(this, annotations);\n }\n\n get location() {\n return this.history.location;\n }\n\n navigate(url: string, options?: RouterNavigateOptions) {\n const query =\n (options?.mergeQuery ?? routeConfig.get().mergeQuery)\n ? { ...this.query.data, ...options?.query }\n : { ...options?.query };\n\n const searchString = buildSearchString(query);\n const navigationUrl = `${url}${searchString}`;\n\n if (options?.replace) {\n this.history.replace(navigationUrl, options?.state);\n } else {\n this.history.push(navigationUrl, options?.state);\n }\n }\n}\n\nexport const createRouter = <TRoutesCollection extends RoutesCollection>(\n config: RouterConfiguration<TRoutesCollection>,\n) => new Router(config);\n","import {\n action,\n comparer,\n computed,\n observable,\n reaction,\n runInAction,\n} from 'mobx';\nimport type { IQueryParams } from 'mobx-location-history';\nimport { callFunction } from 'yummies/common';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { AnyObject, EmptyObject, IsPartial, Maybe } from 'yummies/types';\nimport { routeConfig } from '../config/index.js';\nimport type {\n AbstractVirtualRoute,\n VirtualOpenExtraParams,\n VirtualRouteConfiguration,\n VirtualRouteTrx,\n} from './virtual-route.types.js';\n\nconst annotations: ObservableAnnotationsArray<VirtualRoute<any>> = [\n [observable, 'params'],\n [observable.ref, 'status', 'trx', 'openChecker', 'isOuterOpened'],\n [computed, 'isOpened', 'isOpening', 'isClosing'],\n [action, 'setOpenChecker', 'open', 'close', 'destroy'],\n];\n\n/**\n * Class for creating routes with custom activation logic\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html)\n */\nexport class VirtualRoute<\n TParams extends AnyObject | EmptyObject = EmptyObject,\n TQueryParams extends Record<string, any> = AnyObject,\n> implements AbstractVirtualRoute<TParams, TQueryParams>\n{\n private isDestroyed?: boolean;\n private disposer?: VoidFunction;\n\n query: IQueryParams;\n params: TParams | null;\n\n protected status:\n | 'opening'\n | 'open-rejected'\n | 'opened'\n | 'closing'\n | 'closed'\n | 'unknown';\n\n private openChecker: Maybe<VirtualRouteConfiguration<TParams>['checkOpened']>;\n\n private trx: Maybe<VirtualRouteTrx>;\n\n private skipAutoOpenClose: boolean;\n\n private isUpdate = false;\n\n private updateDisposer?: VoidFunction;\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isouteropened)\n */\n isOuterOpened: boolean | undefined;\n\n constructor(protected config: VirtualRouteConfiguration<TParams> = {}) {\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n this.params = callFunction(config.initialParams, this) ?? null;\n this.openChecker = config.checkOpened;\n this.skipAutoOpenClose = false;\n this.isOuterOpened = this.openChecker?.(this);\n this.status = this.isOuterOpened ? 'opened' : 'unknown';\n\n applyObservable(this, annotations);\n\n if (this.config.abortSignal?.aborted) {\n this.isDestroyed = true;\n } else {\n this.disposer = reaction(\n () => this.openChecker?.(this),\n action((isOuterOpened) => {\n this.isOuterOpened = isOuterOpened;\n\n if (\n this.skipAutoOpenClose ||\n this.status === 'closing' ||\n this.status === 'opening'\n ) {\n return;\n }\n\n if (this.isOuterOpened) {\n if (this.status === 'opened') {\n return;\n }\n void this.confirmOpening({\n params: this.params ?? null,\n ...this.config.getAutoOpenParams?.(this),\n });\n } else {\n if (this.status === 'closed' || this.status === 'unknown') {\n return;\n }\n void this.confirmClosing();\n }\n }),\n { signal: this.config.abortSignal, fireImmediately: true },\n );\n this.updateDisposer = reaction(\n () => {\n if (this.status !== 'opened') return undefined;\n return this.query.data;\n },\n (value, prevValue) => {\n if (prevValue === undefined) return;\n if (value === undefined) return;\n this.config.afterUpdate?.(this.params, this);\n },\n {\n fireImmediately: false,\n signal: this.config.abortSignal,\n equals: comparer.structural,\n },\n );\n }\n\n if (this.status === 'opened') {\n this.config.afterOpen?.(this.params, this);\n }\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened)\n */\n get isOpened() {\n return (\n !this.isDestroyed &&\n this.status === 'opened' &&\n this.isOuterOpened !== false\n );\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopening)\n */\n get isOpening() {\n return this.status === 'opening';\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isclosing)\n */\n get isClosing() {\n return this.status === 'closing';\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker)\n */\n setOpenChecker(\n openChecker: Maybe<VirtualRouteConfiguration<TParams>['checkOpened']>,\n ) {\n this.openChecker = openChecker;\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#open)\n */\n open(\n ...args: IsPartial<TParams> extends true\n ? [\n params?: Maybe<TParams>,\n extraParams?: VirtualOpenExtraParams<TQueryParams>,\n ]\n : [params: TParams, extraParams?: VirtualOpenExtraParams<TQueryParams>]\n ): Promise<void>;\n async open(...args: any[]) {\n const params = (args[0] ?? null) as unknown as TParams;\n const extra: Maybe<VirtualOpenExtraParams> = args[1];\n\n this.isUpdate = this.status === 'opened';\n this.skipAutoOpenClose = true;\n\n this.trx = {\n params,\n extra,\n manual: true,\n };\n\n await this.confirmOpening(this.trx);\n\n this.skipAutoOpenClose = false;\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close)\n */\n async close() {\n this.skipAutoOpenClose = true;\n const result = await this.confirmClosing();\n this.skipAutoOpenClose = false;\n return result;\n }\n\n private async confirmOpening(trx: VirtualRouteTrx) {\n runInAction(() => {\n this.trx = undefined;\n this.status = 'opening';\n });\n\n if ((await this.config.beforeOpen?.(trx.params, this)) === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n this.trx = undefined;\n });\n return;\n }\n\n if ((await this.config.open?.(trx.params, this)) === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n this.trx = undefined;\n });\n return;\n }\n\n runInAction(() => {\n if (trx.extra?.query) {\n this.query.update(trx.extra.query, trx.extra.replace);\n }\n\n this.trx = undefined;\n this.params = trx.params;\n this.status = 'opened';\n\n if (this.isUpdate) {\n this.isUpdate = false;\n this.config.afterUpdate?.(this.params!, this);\n } else {\n this.config.afterOpen?.(this.params!, this);\n }\n });\n\n return true;\n }\n\n private async confirmClosing() {\n if (this.status === 'closed') {\n return true;\n }\n\n const lastStatus = this.status;\n\n runInAction(() => {\n this.status = 'closing';\n });\n\n if ((await this.config.beforeClose?.()) === false) {\n runInAction(() => {\n this.status = lastStatus;\n });\n return;\n }\n\n if (this.config.close?.(this) === false) {\n runInAction(() => {\n this.status = lastStatus;\n });\n return;\n }\n\n runInAction(() => {\n this.status = 'closed';\n this.params = null;\n });\n\n this.config.afterClose?.();\n\n return true;\n }\n\n destroy() {\n this.isDestroyed = true;\n this.status = 'unknown';\n this.disposer?.();\n this.updateDisposer?.();\n }\n}\n\nexport const createVirtualRoute = <\n TParams extends AnyObject | EmptyObject = EmptyObject,\n TQueryParams extends Record<string, any> = AnyObject,\n>(\n config?: VirtualRouteConfiguration<TParams>,\n) => new VirtualRoute<TParams, TQueryParams>(config);\n"],"names":["annotations"],"mappings":";;;;;;AAWO,MAAM,cAAc;AAAA,EACzB,CAAC,QAAQ,YAAY;AACnB,QAAI;AACJ,QAAI;AAEJ,QAAI,QAAQ,SAAS;AACnB,gBAAU,OAAO;AACjB,oBAAc,OAAO;AAErB,UAAI,SAAS,WAAW,oBAAoB,QAAQ,OAAO,GAAG;AAC5D,gBAAQ,QAAQ,QAAA;AAAA,MAClB;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AK,SAAS;AAEd,UAAI,KAAK,UAAU;AACjB,aAAK,WAAW;AAChB,aAAK,OAAO,cAAc,KAAK,QAAS,IAAI;AAAA,MAC9C,OAAO;AACL,aAAK,OAAO,YAAY,KAAK,QAAS,IAAI;AAAA,MAC5C;AAAA,IACF,CAAC;AAED,WAAO;AAAA,EACT;AAAA,EAEA,MAAc,iBAAiB;AAC7B,QAAI,KAAK,WAAW,UAAU;AAC5B,aAAO;AAAA,IACT;AAEA,UAAM,aAAa,KAAK;AAExB,gBAAY,MAAM;AAChB,WAAK,SAAS;AAAA,IAChB,CAAC;AAED,QAAK,MAAM,KAAK,OAAO,cAAA,MAAqB,OAAO;AACjD,kBAAY,MAAM;AAChB,aAAK,SAAS;AAAA,MAChB,CAAC;AACD;AAAA,IACF;AAEA,QAAI,KAAK,OAAO,QAAQ,IAAI,MAAM,OAAO;AACvC,kBAAY,MAAM;AAChB,aAAK,SAAS;AAAA,MAChB,CAAC;AACD;AAAA,IACF;AAEA,gBAAY,MAAM;AAChB,WAAK,SAAS;AACd,WAAK,SAAS;AAAA,IAChB,CAAC;AAED,SAAK,OAAO,aAAA;AAEZ,WAAO;AAAA,EACT;AAAA,EAEA,UAAU;AACR,SAAK,cAAc;AACnB,SAAK,SAAS;AACd,SAAK,WAAA;AACL,SAAK,iBAAA;AAAA,EACP;AACF;AAEO,MAAM,qBAAqB,CAIhC,WACG,IAAI,aAAoC,MAAM;"}
|
|
@@ -333,7 +333,10 @@ class Route {
|
|
|
333
333
|
state: rawState,
|
|
334
334
|
query: rawQuery,
|
|
335
335
|
mergeQuery: rawMergeQuery
|
|
336
|
-
} = typeof args[1] === "boolean" || args.length > 2 ? {
|
|
336
|
+
} = typeof args[1] === "boolean" || args.length > 2 ? {
|
|
337
|
+
replace: args[1],
|
|
338
|
+
query: args[2]
|
|
339
|
+
} : args[1] ?? {};
|
|
337
340
|
const mergeQuery = rawMergeQuery ?? this.isAbleToMergeQuery;
|
|
338
341
|
const query = mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery;
|
|
339
342
|
const params = typeof args[0] === "string" ? void 0 : args[0];
|
|
@@ -817,4 +820,4 @@ exports.createRouter = createRouter;
|
|
|
817
820
|
exports.createVirtualRoute = createVirtualRoute;
|
|
818
821
|
exports.groupRoutes = groupRoutes;
|
|
819
822
|
exports.routeConfig = routeConfig;
|
|
820
|
-
//# sourceMappingURL=virtual-route-
|
|
823
|
+
//# sourceMappingURL=virtual-route-DCnOqDz5.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-route-DCnOqDz5.cjs","sources":["../src/core/config/config.ts","../src/core/route/route.ts","../src/core/route-group/route-group.ts","../src/core/router/router.ts","../src/core/virtual-route/virtual-route.ts"],"sourcesContent":["import {\n createBrowserHistory,\n createQueryParams,\n type History,\n type IQueryParams,\n isObservableHistory,\n} from 'mobx-location-history';\nimport { createGlobalDynamicConfig } from 'yummies/complex';\n\nimport type { RouteGlobalConfig } from './config.types.js';\n\nexport const routeConfig = createGlobalDynamicConfig<RouteGlobalConfig>(\n (update, current) => {\n let history: History;\n let queryParams: IQueryParams | undefined;\n\n if (update?.history) {\n history = update.history;\n queryParams = update.queryParams;\n\n if (current?.history && isObservableHistory(current.history)) {\n current.history.destroy();\n }\n } else if (current?.history) {\n history = current.history;\n queryParams = update?.queryParams ?? current.queryParams;\n } else {\n history = createBrowserHistory();\n }\n\n queryParams ??= createQueryParams({ history });\n\n return {\n ...update,\n history,\n queryParams,\n };\n },\n Symbol.for('MOBX_ROUTE_CONFIG'),\n);\n","import { comparer, computed, observable, reaction, runInAction } from 'mobx';\nimport {\n buildSearchString,\n type History,\n type IQueryParams,\n} from 'mobx-location-history';\nimport {\n compile,\n match,\n type ParamData,\n parse,\n type TokenData,\n} from 'path-to-regexp';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { AnyObject, IsPartial, Maybe } from 'yummies/types';\nimport { routeConfig } from '../config/index.js';\nimport type {\n AnyRoute,\n CreatedUrlOutputParams,\n InputPathParams,\n NavigationTrx,\n ParsedPathData,\n ParsedPathParams,\n RouteConfiguration,\n RouteNavigateParams,\n UrlCreateParams,\n} from './route.types.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst annotations: ObservableAnnotationsArray<Route<any, any, any, any>> = [\n [\n computed,\n 'isPathMatched',\n 'isOpened',\n 'isOpening',\n 'path',\n 'absolutePath',\n 'hasOpenedChildren',\n 'isAbleToMergeQuery',\n 'baseUrl',\n ],\n [computed.struct, 'parsedPathData', 'params'],\n [observable, 'children'],\n [observable.ref, 'parent', 'status'],\n];\n\n/**\n * Class for creating path based route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html)\n */\nexport class Route<\n TPath extends string,\n TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>,\n TOutputParams extends AnyObject = ParsedPathParams<TPath>,\n TQueryParams extends Record<string, any> = AnyObject,\n> {\n private isDestroyed?: boolean;\n private disposer?: VoidFunction;\n\n protected history: History;\n\n /**\n * Parent route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#parent)\n */\n parent: AnyRoute | null;\n\n query: IQueryParams;\n\n private _tokenData: TokenData | undefined;\n private _matcher?: ReturnType<typeof match>;\n private _compiler?: ReturnType<typeof compile>;\n private ignoreOpenByPathMatch = false;\n private isUpdate = false;\n private updateDisposer?: VoidFunction;\n\n protected status:\n | 'opening'\n | 'closed'\n | 'open-rejected'\n | 'open-confirmed'\n | 'unknown';\n\n meta?: AnyObject;\n\n /**\n * Route path pattern declaration.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#pathdeclaration)\n */\n pathDeclaration: TPath;\n\n /**\n * Indicates if this route is an index route. Index routes activate when parent route path matches exactly.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isindex)\n */\n isIndex: boolean;\n\n /**\n * Indicates if this route is an hash route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ishash)\n */\n isHash: boolean;\n\n /**\n * Array of child routes.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#children)\n */\n children: AnyRoute[] = [];\n\n constructor(\n pathDeclaration: TPath,\n protected config: RouteConfiguration<\n TPath,\n TInputParams,\n TOutputParams,\n TQueryParams\n > = {},\n ) {\n this.history = config.history ?? routeConfig.get().history;\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n this.pathDeclaration = pathDeclaration;\n this.isIndex = !!this.config.index;\n this.isHash = !!this.config.hash;\n this.meta = this.config.meta;\n this.status = 'unknown';\n this.parent = config.parent ?? null;\n\n applyObservable(this, annotations);\n\n if (this.config.abortSignal?.aborted) {\n this.isDestroyed = true;\n } else {\n this.disposer = reaction(() => this.isPathMatched, this.checkPathMatch, {\n fireImmediately: true,\n });\n this.updateDisposer = reaction(\n () => {\n if (this.status !== 'open-confirmed') return undefined;\n return [this.parsedPathData, this.query.data] as const;\n },\n (value, prevValue) => {\n if (prevValue === undefined) return;\n if (value === undefined) return;\n if (!this.parsedPathData) return;\n this.config.afterUpdate?.(this.parsedPathData, this);\n },\n {\n fireImmediately: false,\n signal: this.config.abortSignal,\n equals: comparer.structural,\n },\n );\n this.config.abortSignal?.addEventListener('abort', () => this.destroy(), {\n once: true,\n });\n }\n }\n\n protected get baseUrl() {\n const baseUrl = this.config.baseUrl ?? routeConfig.get().baseUrl;\n return baseUrl?.endsWith('/') ? baseUrl.slice(0, -1) : baseUrl;\n }\n\n /**\n * Checks whether current route matches provided path.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#matchpath)\n */\n matchPath(path?: Maybe<string>): ParsedPathData<TPath> | null {\n let pathnameToCheck: string;\n\n if (path != null) {\n pathnameToCheck = path;\n } else if (this.isHash) {\n pathnameToCheck = this.history.location.hash.slice(1);\n } else {\n pathnameToCheck = this.history.location.pathname;\n }\n\n if (this.baseUrl) {\n if (!pathnameToCheck.startsWith(this.baseUrl)) {\n return null;\n }\n\n pathnameToCheck = pathnameToCheck.replace(this.baseUrl, '');\n }\n\n if (\n (this.pathDeclaration === '' || this.pathDeclaration === '/') &&\n (pathnameToCheck === '/' || pathnameToCheck === '')\n ) {\n return { params: {} as any, path: pathnameToCheck };\n }\n\n this._matcher ??= match(this.tokenData, {\n end: this.config.exact ?? false,\n ...this.config.matchOptions,\n });\n const parsed = this._matcher(pathnameToCheck);\n\n if (parsed === false) {\n return null;\n }\n\n return parsed as ParsedPathData<TPath>;\n }\n\n protected get parsedPathData(): ParsedPathData<TPath> | null {\n return this.matchPath();\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopening)\n *\n * Also true in the short gap after history already matches this route but\n * `confirmOpening` has not started yet (e.g. browser Back) — otherwise every\n * route looks closed for one tick and RouteViewGroup unmounts the page.\n */\n get isOpening() {\n if (this.status === 'opening') {\n return true;\n }\n\n if (\n this.isDestroyed ||\n !this.isPathMatched ||\n this.params === null ||\n this.status === 'open-confirmed' ||\n this.status === 'open-rejected'\n ) {\n return false;\n }\n\n return this.status === 'closed' || this.status === 'unknown';\n }\n\n /**\n * Matched path segment for current URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#path)\n */\n get path(): string | null {\n return this.parsedPathData?.path ?? null;\n }\n\n /**\n * Matched path segment for current URL with base URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#absolutepath)\n */\n get absolutePath(): string | null {\n const path = this.path;\n\n if (path === null) {\n return null;\n }\n\n return `${this.baseUrl || ''}${path}`;\n }\n\n /**\n * Current parsed path parameters.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)\n */\n get params(): TOutputParams | null {\n if (!this.parsedPathData?.params) {\n return null;\n }\n\n if (this.config.params) {\n const result = this.config.params(\n this.parsedPathData.params,\n this.config.meta,\n );\n return result || null;\n }\n\n return (\n (this.parsedPathData?.params as unknown as Maybe<TOutputParams>) ?? null\n );\n }\n\n protected get isPathMatched() {\n return this.parsedPathData !== null;\n }\n\n /**\n * Defines the \"open\" state for this route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)\n */\n get isOpened() {\n if (\n this.isDestroyed ||\n !this.isPathMatched ||\n this.params === null ||\n this.status !== 'open-confirmed'\n ) {\n return false;\n }\n\n return (\n // this.parsedPathData is defined because this.params !== null\n !this.config.checkOpened || this.config.checkOpened(this.parsedPathData!)\n );\n }\n\n /**\n * Allows to create child route based on this route with merging this route path and extending path.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend)\n */\n extend<\n TExtendedPath extends string,\n TExtendedInputParams extends\n InputPathParams<`${TPath}${TExtendedPath}`> = InputPathParams<`${TPath}${TExtendedPath}`>,\n TExtendedOutputParams extends AnyObject = TInputParams &\n ParsedPathParams<`${TPath}${TExtendedPath}`>,\n TExtendedQueryParams extends Record<string, any> = TQueryParams,\n >(\n pathDeclaration: TExtendedPath,\n config?: Omit<\n RouteConfiguration<\n `${TPath}${TExtendedPath}`,\n TInputParams & TExtendedInputParams,\n TExtendedOutputParams,\n TExtendedQueryParams\n >,\n 'parent'\n >,\n ) {\n type ExtendedRoutePath = `${TPath}${TExtendedPath}`;\n const { index, params, exact, ...configFromCurrentRoute } = this.config;\n\n const extendedChild = new Route<\n ExtendedRoutePath,\n TInputParams & TExtendedInputParams,\n TExtendedOutputParams,\n TExtendedQueryParams\n >(`${this.pathDeclaration}${pathDeclaration}`, {\n ...configFromCurrentRoute,\n ...config,\n parent: this,\n } as any);\n\n this.addChildren(extendedChild as any);\n\n return extendedChild;\n }\n\n /**\n * Manually add child routes.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#addchildren)\n */\n addChildren(...routes: AnyRoute[]) {\n this.children.push(...routes);\n }\n\n /**\n * Remove specified routes from children.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#removechildren)\n */\n removeChildren(...routes: AnyRoute[]) {\n this.children = this.children.filter((child) => !routes.includes(child));\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#hasopenedchildren)\n */\n get hasOpenedChildren(): boolean {\n return this.children.some(\n (child) => child.isOpened || child.hasOpenedChildren,\n );\n }\n\n protected processParams(\n params?: TInputParams | null | undefined,\n ): ParamData | undefined {\n if (params == null) return undefined;\n\n const result: ParamData = {};\n for (const [key, value] of Object.entries(params)) {\n if (value != null) {\n result[key] = Array.isArray(value) ? value.map(String) : String(value);\n }\n }\n return result;\n }\n\n /**\n * Generates full route URL.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl)\n */\n createUrl(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: Maybe<TInputParams>,\n query?: Maybe<Partial<TQueryParams>>,\n mergeQueryOrParams?: boolean | CreatedUrlOutputParams,\n ]\n : [\n params: TInputParams,\n query?: Maybe<Partial<TQueryParams>>,\n mergeQueryOrParams?: boolean | CreatedUrlOutputParams,\n ]\n ) {\n const params = args[0];\n const rawQuery = args[1];\n const mergeQueryOrOutputParams = args[2] ?? this.isAbleToMergeQuery;\n const outputParams: Maybe<CreatedUrlOutputParams> =\n typeof mergeQueryOrOutputParams === 'boolean'\n ? { mergeQuery: mergeQueryOrOutputParams }\n : mergeQueryOrOutputParams;\n\n const query = outputParams?.mergeQuery\n ? ({ ...this.query.data, ...rawQuery } as Partial<TQueryParams>)\n : ((rawQuery ?? {}) as Partial<TQueryParams>);\n\n this._compiler ??= compile(this.tokenData);\n\n const defaultUrlCreateParams: UrlCreateParams<TInputParams, TQueryParams> =\n {\n baseUrl: this.baseUrl,\n params: params as TInputParams,\n query,\n };\n const urlCreateParams: UrlCreateParams<TInputParams, TQueryParams> =\n this.config.createUrl?.(defaultUrlCreateParams, this.query.data) ??\n routeConfig.get().createUrl?.(defaultUrlCreateParams, this.query.data) ??\n defaultUrlCreateParams;\n\n let path: string;\n\n try {\n path = this._compiler(this.processParams(urlCreateParams.params));\n } catch (e) {\n if (process.env.NODE_ENV !== 'production') {\n console.error(\n 'Error #1: Route path compilation failed\\n' +\n 'The path pattern could not be built into a URL (often missing or invalid params for a `:param` segment). Using fallbackPath or \"/\".\\n' +\n 'See docs: https://js2me.github.io/mobx-route/errors/1',\n e,\n );\n } else {\n console.error('minified error #1;see mobx-route docs', e);\n }\n path = this.config.fallbackPath ?? routeConfig.get().fallbackPath ?? '/';\n }\n\n const url = `${urlCreateParams.baseUrl || ''}${this.isHash ? '#' : ''}${path}`;\n\n if (outputParams?.omitQuery) {\n return url;\n }\n\n return `${url}${buildSearchString(urlCreateParams.query)}`;\n }\n\n /**\n * Navigates to this route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open)\n */\n open(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: TInputParams | null | undefined,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ]\n : [\n params: TInputParams,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ]\n ): Promise<void>;\n open(\n ...args: IsPartial<TInputParams> extends true\n ? [\n params?: TInputParams | null | undefined,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ]\n : [\n params: TInputParams,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ]\n ): Promise<void>;\n open(\n url: string,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n open(\n url: string,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n\n async open(...args: any[]) {\n const {\n replace,\n state: rawState,\n query: rawQuery,\n mergeQuery: rawMergeQuery,\n } = typeof args[1] === 'boolean' || args.length > 2\n ? ({\n replace: args[1],\n query: args[2],\n } as RouteNavigateParams<TQueryParams>)\n : ((args[1] ?? {}) as RouteNavigateParams<TQueryParams>);\n\n const mergeQuery = rawMergeQuery ?? this.isAbleToMergeQuery;\n const query = (\n mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery\n ) as Partial<TQueryParams> | undefined;\n\n const params = typeof args[0] === 'string' ? undefined : args[0];\n const url =\n typeof args[0] === 'string' ? args[0] : this.createUrl(args[0], query);\n\n const trx: NavigationTrx<TInputParams, TQueryParams> = {\n url,\n params: params as TInputParams,\n replace,\n state: rawState ?? null,\n query,\n };\n\n this.isUpdate = this.status === 'open-confirmed';\n this.ignoreOpenByPathMatch = true;\n const isConfirmed = await this.confirmOpening(trx);\n\n if (isConfirmed !== true) {\n this.ignoreOpenByPathMatch = false;\n this.isUpdate = false;\n }\n }\n\n /**\n * Updates the current route if it is already open.\n * Unlike `open`, this is a no-op if the route is not open,\n * defaults to `replace: true` instead of push,\n * and defaults to `mergeQuery: true` when no query params are provided.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#update)\n */\n update(\n params?: TInputParams | null | undefined,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n update(\n params?: TInputParams | null | undefined,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n update(\n url: string,\n navigateParams?: RouteNavigateParams<TQueryParams>,\n ): Promise<void>;\n update(\n url: string,\n replace?: RouteNavigateParams<TQueryParams>['replace'],\n query?: RouteNavigateParams<TQueryParams>['query'],\n ): Promise<void>;\n\n async update(...args: any[]) {\n if (this.status !== 'open-confirmed') {\n return;\n }\n\n // Reuse current path params when omitted\n if (args[0] == null) {\n args[0] = this.parsedPathData?.params;\n }\n\n const secondArg = args[1];\n const isObjectParams = typeof secondArg === 'object' && secondArg !== null;\n\n if (isObjectParams) {\n args[1] = {\n replace: true,\n ...('query' in secondArg ? {} : { mergeQuery: true }),\n ...secondArg,\n };\n } else if (typeof secondArg === 'boolean') {\n if (args[2] === undefined) {\n args[1] = { replace: secondArg, mergeQuery: true };\n args.length = 2;\n }\n } else if (args.length === 1) {\n args[1] = { replace: true, mergeQuery: true };\n }\n\n return (this.open as (...args: any[]) => Promise<void>)(...args);\n }\n\n protected get tokenData() {\n if (!this._tokenData) {\n this._tokenData = parse(this.pathDeclaration, this.config.parseOptions);\n }\n return this._tokenData;\n }\n\n protected async confirmOpening(\n trx: NavigationTrx<TInputParams, TQueryParams>,\n ) {\n if (!this.isUpdate) {\n runInAction(() => {\n this.status = 'opening';\n });\n }\n\n let skipHistoryUpdate = !!trx.preferSkipHistoryUpdate;\n\n if (skipHistoryUpdate) {\n this.ignoreOpenByPathMatch = false;\n }\n\n if (this.config.beforeOpen) {\n const feedback = await this.config.beforeOpen(trx);\n\n if (feedback === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n });\n\n return;\n }\n\n // Rebuild URL if beforeOpen mutated trx.params\n const newUrl = this.createUrl(\n trx.params as TInputParams,\n trx.query as AnyObject,\n );\n if (newUrl !== trx.url) {\n trx.url = newUrl;\n skipHistoryUpdate = false;\n }\n\n if (typeof feedback === 'object') {\n skipHistoryUpdate = false;\n Object.assign(trx, feedback);\n }\n }\n\n if (this.isDestroyed) {\n return;\n }\n\n if (!skipHistoryUpdate) {\n if (trx.replace) {\n this.history.replace(trx.url, trx.state);\n } else {\n this.history.push(trx.url, trx.state);\n }\n }\n\n if (this.isPathMatched) {\n const wasAlreadyConfirmed = this.status === 'open-confirmed';\n runInAction(() => {\n this.status = 'open-confirmed';\n });\n\n if (this.isUpdate) {\n this.isUpdate = false;\n // afterUpdate handled by updateDisposer reaction\n } else if (!wasAlreadyConfirmed) {\n this.config.afterOpen?.(this.parsedPathData!, this);\n }\n }\n\n return true;\n }\n\n protected confirmClosing() {\n runInAction(() => {\n this.status = 'closed';\n });\n return true;\n }\n\n private firstPathMatchingRun = true;\n\n private checkPathMatch = async (isPathMathched: boolean) => {\n if (this.firstPathMatchingRun) {\n this.firstPathMatchingRun = false;\n // ignore first 'afterClose' callback call\n if (!isPathMathched) {\n return;\n }\n }\n\n if (isPathMathched) {\n // after manual open call\n if (this.ignoreOpenByPathMatch) {\n this.ignoreOpenByPathMatch = false;\n if (this.status === 'opening' && this.parsedPathData) {\n runInAction(() => {\n this.status = 'open-confirmed';\n });\n if (this.isUpdate) {\n this.isUpdate = false;\n this.config.afterUpdate?.(this.parsedPathData, this);\n } else {\n this.config.afterOpen?.(this.parsedPathData, this);\n }\n }\n // update() delegates to confirmOpening\n return;\n }\n\n // Set opening sync to avoid isOpened/isOpening flicker\n if (this.status !== 'opening' && this.status !== 'open-confirmed') {\n runInAction(() => {\n this.status = 'opening';\n });\n }\n\n // already confirmed\n if (this.status === 'open-confirmed') {\n return;\n }\n\n const trx: NavigationTrx<TInputParams, TQueryParams> = {\n url: `${this.parsedPathData!.path}${buildSearchString(this.query.data)}`,\n params: this.parsedPathData!.params as TInputParams,\n state: this.history.location.state,\n query: this.query.data as Partial<TQueryParams>,\n preferSkipHistoryUpdate: true,\n };\n\n await this.confirmOpening(trx);\n } else {\n this.ignoreOpenByPathMatch = false;\n\n const isConfirmed = this.confirmClosing();\n\n if (isConfirmed) {\n this.config.afterClose?.();\n }\n }\n };\n\n private get isAbleToMergeQuery() {\n return this.config.mergeQuery ?? routeConfig.get().mergeQuery;\n }\n\n /**\n * Destroys route subscriptions and reactions.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#destroy)\n */\n destroy() {\n this.isDestroyed = true;\n this.disposer?.();\n this.disposer = undefined;\n this.updateDisposer?.();\n this.updateDisposer = undefined;\n }\n}\n\nexport const createRoute = <\n TPath extends string,\n TInputParams extends InputPathParams<TPath> = InputPathParams<TPath>,\n TOutputParams extends AnyObject = ParsedPathParams<TPath>,\n TQueryParams extends Record<string, any> = AnyObject,\n>(\n path: TPath,\n config?: RouteConfiguration<TPath, TInputParams, TOutputParams, TQueryParams>,\n) => new Route<TPath, TInputParams, TOutputParams, TQueryParams>(path, config);\n","import { computed, observable } from 'mobx';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type {\n AbstractRouteGroup,\n AnyRouteEntity,\n RoutesCollection,\n} from './route-group.types.js';\n\ndeclare const process: { env: { NODE_ENV?: string } };\n\nconst annotations: ObservableAnnotationsArray<RouteGroup<any>> = [\n [computed, 'isOpened', 'indexRoute', 'canNavigate'],\n [observable.shallow, 'routes'],\n];\n\n/**\n * Class for grouping related routes and managing their state.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html)\n */\nexport class RouteGroup<TRoutesCollection extends RoutesCollection>\n implements AbstractRouteGroup<TRoutesCollection>\n{\n routes: TRoutesCollection;\n\n constructor(\n routes: TRoutesCollection,\n private _indexRoute?: AnyRouteEntity,\n ) {\n this.routes = routes;\n\n applyObservable(this, annotations);\n }\n\n /**\n * Returns true if at least one route in the group is open.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#isopened)\n */\n get isOpened(): boolean {\n const routes = Object.values(this.routes);\n return routes.some(\n (route) =>\n route.isOpened ||\n ('hasOpenedChildren' in route && route.hasOpenedChildren),\n );\n }\n\n /**\n * First found index route.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#indexroute)\n */\n get indexRoute(): AnyRouteEntity | undefined {\n return (this._indexRoute ??\n Object.values(this.routes).find(\n (route) => 'isIndex' in route && route.isIndex,\n )) as unknown as AnyRouteEntity;\n }\n\n /**\n * `true` if `open()` has a target to navigate to —\n * either an own index route or a nested `RouteGroup` that itself can navigate.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#cannavigate)\n */\n get canNavigate(): boolean {\n if (this.indexRoute) return true;\n\n for (const routeName in this.routes) {\n const route = this.routes[routeName];\n if (route instanceof RouteGroup && route.canNavigate) {\n return true;\n }\n }\n\n return false;\n }\n\n /**\n * Main navigation method for the group.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#open)\n */\n open(...args: any[]) {\n if (this.indexRoute && 'open' in this.indexRoute) {\n this.indexRoute.open(...args);\n return;\n }\n\n for (const routeName in this.routes) {\n const route = this.routes[routeName];\n if (route instanceof RouteGroup && route.canNavigate) {\n route.open(...args);\n return;\n }\n }\n\n if (process.env.NODE_ENV !== 'production') {\n console.warn(\n 'Warning #1: RouteGroup.open() cannot navigate\\n' +\n 'This group has no index route (`index: true` or `groupRoutes(routes, indexRoute)`) and no navigable nested RouteGroup, so open() does nothing.\\n' +\n 'See docs: https://js2me.github.io/mobx-route/warnings/1',\n );\n } else {\n console.warn('minified warning #1;see mobx-route docs');\n }\n }\n}\n\n/**\n * Helper for creating route groups.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html)\n */\nexport const groupRoutes = <TRoutesCollection extends RoutesCollection>(\n routes: TRoutesCollection,\n indexRoute?: AnyRouteEntity,\n) => new RouteGroup<TRoutesCollection>(routes, indexRoute);\n","import { computed } from 'mobx';\nimport {\n buildSearchString,\n type History,\n type IQueryParams,\n} from 'mobx-location-history';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport { routeConfig } from '../config/index.js';\nimport type { RoutesCollection } from '../route-group/index.js';\nimport type {\n RouterConfiguration,\n RouterNavigateOptions,\n} from './router.types.js';\n\nconst annotations: ObservableAnnotationsArray<Router<any>> = [\n [computed.struct, 'location'],\n];\n\n/**\n * Class for centralized routing management.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Router.html)\n */\nexport class Router<TRoutesCollection extends RoutesCollection> {\n routes: TRoutesCollection;\n history: History;\n query: IQueryParams;\n\n constructor(config: RouterConfiguration<TRoutesCollection>) {\n this.routes = config.routes;\n this.history = config.history ?? routeConfig.get().history;\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n\n applyObservable(this, annotations);\n }\n\n get location() {\n return this.history.location;\n }\n\n navigate(url: string, options?: RouterNavigateOptions) {\n const query =\n (options?.mergeQuery ?? routeConfig.get().mergeQuery)\n ? { ...this.query.data, ...options?.query }\n : { ...options?.query };\n\n const searchString = buildSearchString(query);\n const navigationUrl = `${url}${searchString}`;\n\n if (options?.replace) {\n this.history.replace(navigationUrl, options?.state);\n } else {\n this.history.push(navigationUrl, options?.state);\n }\n }\n}\n\nexport const createRouter = <TRoutesCollection extends RoutesCollection>(\n config: RouterConfiguration<TRoutesCollection>,\n) => new Router(config);\n","import {\n action,\n comparer,\n computed,\n observable,\n reaction,\n runInAction,\n} from 'mobx';\nimport type { IQueryParams } from 'mobx-location-history';\nimport { callFunction } from 'yummies/common';\nimport { applyObservable, type ObservableAnnotationsArray } from 'yummies/mobx';\nimport type { AnyObject, EmptyObject, IsPartial, Maybe } from 'yummies/types';\nimport { routeConfig } from '../config/index.js';\nimport type {\n AbstractVirtualRoute,\n VirtualOpenExtraParams,\n VirtualRouteConfiguration,\n VirtualRouteTrx,\n} from './virtual-route.types.js';\n\nconst annotations: ObservableAnnotationsArray<VirtualRoute<any>> = [\n [observable, 'params'],\n [observable.ref, 'status', 'trx', 'openChecker', 'isOuterOpened'],\n [computed, 'isOpened', 'isOpening', 'isClosing'],\n [action, 'setOpenChecker', 'open', 'close', 'destroy'],\n];\n\n/**\n * Class for creating routes with custom activation logic\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html)\n */\nexport class VirtualRoute<\n TParams extends AnyObject | EmptyObject = EmptyObject,\n TQueryParams extends Record<string, any> = AnyObject,\n> implements AbstractVirtualRoute<TParams, TQueryParams>\n{\n private isDestroyed?: boolean;\n private disposer?: VoidFunction;\n\n query: IQueryParams;\n params: TParams | null;\n\n protected status:\n | 'opening'\n | 'open-rejected'\n | 'opened'\n | 'closing'\n | 'closed'\n | 'unknown';\n\n private openChecker: Maybe<VirtualRouteConfiguration<TParams>['checkOpened']>;\n\n private trx: Maybe<VirtualRouteTrx>;\n\n private skipAutoOpenClose: boolean;\n\n private isUpdate = false;\n\n private updateDisposer?: VoidFunction;\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isouteropened)\n */\n isOuterOpened: boolean | undefined;\n\n constructor(protected config: VirtualRouteConfiguration<TParams> = {}) {\n this.query = config.queryParams ?? routeConfig.get().queryParams;\n this.params = callFunction(config.initialParams, this) ?? null;\n this.openChecker = config.checkOpened;\n this.skipAutoOpenClose = false;\n this.isOuterOpened = this.openChecker?.(this);\n this.status = this.isOuterOpened ? 'opened' : 'unknown';\n\n applyObservable(this, annotations);\n\n if (this.config.abortSignal?.aborted) {\n this.isDestroyed = true;\n } else {\n this.disposer = reaction(\n () => this.openChecker?.(this),\n action((isOuterOpened) => {\n this.isOuterOpened = isOuterOpened;\n\n if (\n this.skipAutoOpenClose ||\n this.status === 'closing' ||\n this.status === 'opening'\n ) {\n return;\n }\n\n if (this.isOuterOpened) {\n if (this.status === 'opened') {\n return;\n }\n void this.confirmOpening({\n params: this.params ?? null,\n ...this.config.getAutoOpenParams?.(this),\n });\n } else {\n if (this.status === 'closed' || this.status === 'unknown') {\n return;\n }\n void this.confirmClosing();\n }\n }),\n { signal: this.config.abortSignal, fireImmediately: true },\n );\n this.updateDisposer = reaction(\n () => {\n if (this.status !== 'opened') return undefined;\n return this.query.data;\n },\n (value, prevValue) => {\n if (prevValue === undefined) return;\n if (value === undefined) return;\n this.config.afterUpdate?.(this.params, this);\n },\n {\n fireImmediately: false,\n signal: this.config.abortSignal,\n equals: comparer.structural,\n },\n );\n }\n\n if (this.status === 'opened') {\n this.config.afterOpen?.(this.params, this);\n }\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened)\n */\n get isOpened() {\n return (\n !this.isDestroyed &&\n this.status === 'opened' &&\n this.isOuterOpened !== false\n );\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopening)\n */\n get isOpening() {\n return this.status === 'opening';\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isclosing)\n */\n get isClosing() {\n return this.status === 'closing';\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker)\n */\n setOpenChecker(\n openChecker: Maybe<VirtualRouteConfiguration<TParams>['checkOpened']>,\n ) {\n this.openChecker = openChecker;\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#open)\n */\n open(\n ...args: IsPartial<TParams> extends true\n ? [\n params?: Maybe<TParams>,\n extraParams?: VirtualOpenExtraParams<TQueryParams>,\n ]\n : [params: TParams, extraParams?: VirtualOpenExtraParams<TQueryParams>]\n ): Promise<void>;\n async open(...args: any[]) {\n const params = (args[0] ?? null) as unknown as TParams;\n const extra: Maybe<VirtualOpenExtraParams> = args[1];\n\n this.isUpdate = this.status === 'opened';\n this.skipAutoOpenClose = true;\n\n this.trx = {\n params,\n extra,\n manual: true,\n };\n\n await this.confirmOpening(this.trx);\n\n this.skipAutoOpenClose = false;\n }\n\n /**\n * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close)\n */\n async close() {\n this.skipAutoOpenClose = true;\n const result = await this.confirmClosing();\n this.skipAutoOpenClose = false;\n return result;\n }\n\n private async confirmOpening(trx: VirtualRouteTrx) {\n runInAction(() => {\n this.trx = undefined;\n this.status = 'opening';\n });\n\n if ((await this.config.beforeOpen?.(trx.params, this)) === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n this.trx = undefined;\n });\n return;\n }\n\n if ((await this.config.open?.(trx.params, this)) === false) {\n runInAction(() => {\n this.status = 'open-rejected';\n this.trx = undefined;\n });\n return;\n }\n\n runInAction(() => {\n if (trx.extra?.query) {\n this.query.update(trx.extra.query, trx.extra.replace);\n }\n\n this.trx = undefined;\n this.params = trx.params;\n this.status = 'opened';\n\n if (this.isUpdate) {\n this.isUpdate = false;\n this.config.afterUpdate?.(this.params!, this);\n } else {\n this.config.afterOpen?.(this.params!, this);\n }\n });\n\n return true;\n }\n\n private async confirmClosing() {\n if (this.status === 'closed') {\n return true;\n }\n\n const lastStatus = this.status;\n\n runInAction(() => {\n this.status = 'closing';\n });\n\n if ((await this.config.beforeClose?.()) === false) {\n runInAction(() => {\n this.status = lastStatus;\n });\n return;\n }\n\n if (this.config.close?.(this) === false) {\n runInAction(() => {\n this.status = lastStatus;\n });\n return;\n }\n\n runInAction(() => {\n this.status = 'closed';\n this.params = null;\n });\n\n this.config.afterClose?.();\n\n return true;\n }\n\n destroy() {\n this.isDestroyed = true;\n this.status = 'unknown';\n this.disposer?.();\n this.updateDisposer?.();\n }\n}\n\nexport const createVirtualRoute = <\n TParams extends AnyObject | EmptyObject = EmptyObject,\n TQueryParams extends Record<string, any> = AnyObject,\n>(\n config?: VirtualRouteConfiguration<TParams>,\n) => new VirtualRoute<TParams, TQueryParams>(config);\n"],"names":["createGlobalDynamicConfig","isObservableHistory","createBrowserHistory","createQueryParams","annotations","computed","observable","applyObservable","reaction","comparer","match","compile","buildSearchString","parse","runInAction","action","callFunction"],"mappings":";;;;;;;AAWO,MAAM,cAAcA,QAAAA;AAAAA,EACzB,CAAC,QAAQ,YAAY;AACnB,QAAI;AACJ,QAAI;AAEJ,QAAI,QAAQ,SAAS;AACnB,gBAAU,OAAO;AACjB,oBAAc,OAAO;AAErB,UAAI,SAAS,WAAWC,oBAAAA,oBAAoB,QAAQ,OAAO,GAAG;AAC5D,gBAAQ,QAAQ,QAAA;AAAA,MAClB;AAAA,IACF,WAAW,SAAS,SAAS;AAC3B,gBAAU,QAAQ;AAClB,oBAAc,QAAQ,eAAe,QAAQ;AAAA,IAC/C,OAAO;AACL,gBAAUC,oBAAAA,qBAAA;AAAA,IACZ;AAEA,oBAAgBC,oBAAAA,kBAAkB,EAAE,SAAS;AAE7C,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA,EACA,uBAAO,IAAI,mBAAmB;AAChC;ACTA,MAAMC,gBAAqE;AAAA,EACzE;AAAA,IACEC,KAAAA;AAAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,CAACA,c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