mobx-route 2.0.0 → 2.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.cjs +1 -1
- package/index.d.ts +9 -1
- package/index.js +1 -1
- package/package.json +7 -7
- package/view-model.cjs +1 -1
- package/view-model.d.ts +9 -1
- package/view-model.js +1 -1
- package/{virtual-route-C21P-S6I.js → virtual-route-DgVGEWRJ.js} +35 -8
- package/virtual-route-DgVGEWRJ.js.map +1 -0
- package/{virtual-route-DCnOqDz5.cjs → virtual-route-EXYD3rMt.cjs} +35 -8
- package/virtual-route-EXYD3rMt.cjs.map +1 -0
- package/virtual-route-C21P-S6I.js.map +0 -1
- package/virtual-route-DCnOqDz5.cjs.map +0 -1
package/index.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const mobxLocationHistory = require("mobx-location-history");
|
|
4
|
-
const virtualRoute = require("./virtual-route-
|
|
4
|
+
const virtualRoute = require("./virtual-route-EXYD3rMt.cjs");
|
|
5
5
|
const isRouteEntity = (route) => route && "isOpened" in route;
|
|
6
6
|
exports.Route = virtualRoute.Route;
|
|
7
7
|
exports.RouteGroup = virtualRoute.RouteGroup;
|
package/index.d.ts
CHANGED
|
@@ -398,7 +398,15 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
398
398
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)
|
|
399
399
|
*/
|
|
400
400
|
get params(): TOutputParams | null;
|
|
401
|
-
protected get
|
|
401
|
+
protected get isConfigPathMatched(): boolean;
|
|
402
|
+
/**
|
|
403
|
+
* Whether the current URL path includes this route's path pattern.
|
|
404
|
+
* Uses prefix matching (`end: false`), so `/users` matches `/users/123`.
|
|
405
|
+
* Useful for navigation menu highlighting.
|
|
406
|
+
*
|
|
407
|
+
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)
|
|
408
|
+
*/
|
|
409
|
+
get isPathMatched(): boolean;
|
|
402
410
|
/**
|
|
403
411
|
* Defines the "open" state for this route.
|
|
404
412
|
*
|
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "mobx-location-history";
|
|
2
|
-
import { R, a, b, V, c, d, e, g, r } from "./virtual-route-
|
|
2
|
+
import { R, a, b, V, c, d, e, g, r } from "./virtual-route-DgVGEWRJ.js";
|
|
3
3
|
const isRouteEntity = (route) => route && "isOpened" in route;
|
|
4
4
|
export {
|
|
5
5
|
R as Route,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mobx-route",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.0",
|
|
4
4
|
"keywords": [
|
|
5
5
|
"mobx",
|
|
6
6
|
"react",
|
|
@@ -67,13 +67,13 @@
|
|
|
67
67
|
"require": "./view-model.cjs",
|
|
68
68
|
"default": "./view-model.js"
|
|
69
69
|
},
|
|
70
|
-
"./virtual-route-
|
|
71
|
-
"import": "./virtual-route-
|
|
72
|
-
"default": "./virtual-route-
|
|
70
|
+
"./virtual-route-DgVGEWRJ": {
|
|
71
|
+
"import": "./virtual-route-DgVGEWRJ.js",
|
|
72
|
+
"default": "./virtual-route-DgVGEWRJ.js"
|
|
73
73
|
},
|
|
74
|
-
"./virtual-route-
|
|
75
|
-
"require": "./virtual-route-
|
|
76
|
-
"default": "./virtual-route-
|
|
74
|
+
"./virtual-route-EXYD3rMt": {
|
|
75
|
+
"require": "./virtual-route-EXYD3rMt.cjs",
|
|
76
|
+
"default": "./virtual-route-EXYD3rMt.cjs"
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
79
|
"files": [
|
package/view-model.cjs
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
3
3
|
const mobx = require("mobx");
|
|
4
4
|
const mobxViewModel = require("mobx-view-model");
|
|
5
|
-
const virtualRoute = require("./virtual-route-
|
|
5
|
+
const virtualRoute = require("./virtual-route-EXYD3rMt.cjs");
|
|
6
6
|
const annotations = [
|
|
7
7
|
[mobx.computed.struct, "pathParams"],
|
|
8
8
|
[mobx.computed, "query"]
|
package/view-model.d.ts
CHANGED
|
@@ -227,7 +227,15 @@ declare class Route<TPath extends string, TInputParams extends InputPathParams<T
|
|
|
227
227
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)
|
|
228
228
|
*/
|
|
229
229
|
get params(): TOutputParams | null;
|
|
230
|
-
protected get
|
|
230
|
+
protected get isConfigPathMatched(): boolean;
|
|
231
|
+
/**
|
|
232
|
+
* Whether the current URL path includes this route's path pattern.
|
|
233
|
+
* Uses prefix matching (`end: false`), so `/users` matches `/users/123`.
|
|
234
|
+
* Useful for navigation menu highlighting.
|
|
235
|
+
*
|
|
236
|
+
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)
|
|
237
|
+
*/
|
|
238
|
+
get isPathMatched(): boolean;
|
|
231
239
|
/**
|
|
232
240
|
* Defines the "open" state for this route.
|
|
233
241
|
*
|
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-DgVGEWRJ.js";
|
|
4
4
|
const annotations = [
|
|
5
5
|
[computed.struct, "pathParams"],
|
|
6
6
|
[computed, "query"]
|
|
@@ -32,6 +32,7 @@ const routeConfig = createGlobalDynamicConfig(
|
|
|
32
32
|
const annotations$3 = [
|
|
33
33
|
[
|
|
34
34
|
computed,
|
|
35
|
+
"isConfigPathMatched",
|
|
35
36
|
"isPathMatched",
|
|
36
37
|
"isOpened",
|
|
37
38
|
"isOpening",
|
|
@@ -60,9 +61,13 @@ class Route {
|
|
|
60
61
|
if (this.config.abortSignal?.aborted) {
|
|
61
62
|
this.isDestroyed = true;
|
|
62
63
|
} else {
|
|
63
|
-
this.disposer = reaction(
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
this.disposer = reaction(
|
|
65
|
+
() => this.isConfigPathMatched,
|
|
66
|
+
this.checkPathMatch,
|
|
67
|
+
{
|
|
68
|
+
fireImmediately: true
|
|
69
|
+
}
|
|
70
|
+
);
|
|
66
71
|
this.updateDisposer = reaction(
|
|
67
72
|
() => {
|
|
68
73
|
if (this.status !== "open-confirmed") return void 0;
|
|
@@ -179,7 +184,7 @@ class Route {
|
|
|
179
184
|
if (this.status === "opening") {
|
|
180
185
|
return true;
|
|
181
186
|
}
|
|
182
|
-
if (this.isDestroyed || !this.
|
|
187
|
+
if (this.isDestroyed || !this.isConfigPathMatched || this.params === null || this.status === "open-confirmed" || this.status === "open-rejected") {
|
|
183
188
|
return false;
|
|
184
189
|
}
|
|
185
190
|
return this.status === "closed" || this.status === "unknown";
|
|
@@ -222,16 +227,38 @@ class Route {
|
|
|
222
227
|
}
|
|
223
228
|
return this.parsedPathData?.params ?? null;
|
|
224
229
|
}
|
|
225
|
-
get
|
|
230
|
+
get isConfigPathMatched() {
|
|
226
231
|
return this.parsedPathData !== null;
|
|
227
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* Whether the current URL path includes this route's path pattern.
|
|
235
|
+
* Uses prefix matching (`end: false`), so `/users` matches `/users/123`.
|
|
236
|
+
* Useful for navigation menu highlighting.
|
|
237
|
+
*
|
|
238
|
+
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)
|
|
239
|
+
*/
|
|
240
|
+
get isPathMatched() {
|
|
241
|
+
let pathname = this.isHash ? this.history.location.hash.slice(1) : this.history.location.pathname;
|
|
242
|
+
if (this.baseUrl) {
|
|
243
|
+
if (!pathname.startsWith(this.baseUrl)) return false;
|
|
244
|
+
pathname = pathname.replace(this.baseUrl, "");
|
|
245
|
+
}
|
|
246
|
+
if (this.pathDeclaration === "" || this.pathDeclaration === "/") {
|
|
247
|
+
return pathname === "/" || pathname === "" || pathname.startsWith("/");
|
|
248
|
+
}
|
|
249
|
+
const matcher = match(this.tokenData, {
|
|
250
|
+
end: false,
|
|
251
|
+
...this.config.matchOptions
|
|
252
|
+
});
|
|
253
|
+
return matcher(pathname) !== false;
|
|
254
|
+
}
|
|
228
255
|
/**
|
|
229
256
|
* Defines the "open" state for this route.
|
|
230
257
|
*
|
|
231
258
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)
|
|
232
259
|
*/
|
|
233
260
|
get isOpened() {
|
|
234
|
-
if (this.isDestroyed || !this.
|
|
261
|
+
if (this.isDestroyed || !this.isConfigPathMatched || this.params === null || this.status !== "open-confirmed") {
|
|
235
262
|
return false;
|
|
236
263
|
}
|
|
237
264
|
return (
|
|
@@ -427,7 +454,7 @@ class Route {
|
|
|
427
454
|
this.history.push(trx.url, trx.state);
|
|
428
455
|
}
|
|
429
456
|
}
|
|
430
|
-
if (this.
|
|
457
|
+
if (this.isConfigPathMatched) {
|
|
431
458
|
const wasAlreadyConfirmed = this.status === "open-confirmed";
|
|
432
459
|
runInAction(() => {
|
|
433
460
|
this.status = "open-confirmed";
|
|
@@ -821,4 +848,4 @@ export {
|
|
|
821
848
|
groupRoutes as g,
|
|
822
849
|
routeConfig as r
|
|
823
850
|
};
|
|
824
|
-
//# sourceMappingURL=virtual-route-
|
|
851
|
+
//# sourceMappingURL=virtual-route-DgVGEWRJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-route-DgVGEWRJ.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 'isConfigPathMatched',\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(\n () => this.isConfigPathMatched,\n this.checkPathMatch,\n {\n fireImmediately: true,\n },\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.isConfigPathMatched ||\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 isConfigPathMatched() {\n return this.parsedPathData !== null;\n }\n\n /**\n * Whether the current URL path includes this route's path pattern.\n * Uses prefix matching (`end: false`), so `/users` matches `/users/123`.\n * Useful for navigation menu highlighting.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)\n */\n get isPathMatched(): boolean {\n let pathname = this.isHash\n ? this.history.location.hash.slice(1)\n : this.history.location.pathname;\n\n if (this.baseUrl) {\n if (!pathname.startsWith(this.baseUrl)) return false;\n pathname = pathname.replace(this.baseUrl, '');\n }\n\n // Root route always matches any path (prefix of everything)\n if (this.pathDeclaration === '' || this.pathDeclaration === '/') {\n return pathname === '/' || pathname === '' || pathname.startsWith('/');\n }\n\n const matcher = match(this.tokenData, {\n end: false,\n ...this.config.matchOptions,\n });\n return matcher(pathname) !== false;\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.isConfigPathMatched ||\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.isConfigPathMatched) {\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;AAAA,IACF,WAAW,SAAS,SAAS;AAC3B,gBAAU,QAAQ;AAClB,oBAAc,QAAQ,eAAe,QAAQ;AAAA,IAC/C,OAAO;AACL,gBAAU,qBAAA;AAAA,IACZ;AAEA,oBAAgB,kBAAkB,EAAE,SAAS;AAE7C,WAAO;AAAA,MACL,GAAG;AAAA,MACH;AAAA,MACA;AAAA,IAAA;AAAA,EAEJ;AAAA,EACA,uBAAO,IAAI,mBAAmB;AAChC;ACTA,MAAMA,gBAAqE;AAAA,EACzE;AAAA,IACE;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EAAA;AAAA,EAEF,CAAC,SAAS,QAAQ,kBAAkB,QAAQ;AAAA,EAC5C,CAAC,YAAY,UAAU;AAAA,EACvB,CAAC,WAAW,KAAK,UAAU,QAAQ;AACrC;AAOO,MAAM,MAKX;AAAA,EA2DA,YACE,iBACU,SAKN,IACJ;AANU,SAAA,SAAA;AAOV,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AAW;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;"}
|
|
@@ -33,6 +33,7 @@ const routeConfig = complex.createGlobalDynamicConfig(
|
|
|
33
33
|
const annotations$3 = [
|
|
34
34
|
[
|
|
35
35
|
mobx.computed,
|
|
36
|
+
"isConfigPathMatched",
|
|
36
37
|
"isPathMatched",
|
|
37
38
|
"isOpened",
|
|
38
39
|
"isOpening",
|
|
@@ -61,9 +62,13 @@ class Route {
|
|
|
61
62
|
if (this.config.abortSignal?.aborted) {
|
|
62
63
|
this.isDestroyed = true;
|
|
63
64
|
} else {
|
|
64
|
-
this.disposer = mobx.reaction(
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
this.disposer = mobx.reaction(
|
|
66
|
+
() => this.isConfigPathMatched,
|
|
67
|
+
this.checkPathMatch,
|
|
68
|
+
{
|
|
69
|
+
fireImmediately: true
|
|
70
|
+
}
|
|
71
|
+
);
|
|
67
72
|
this.updateDisposer = mobx.reaction(
|
|
68
73
|
() => {
|
|
69
74
|
if (this.status !== "open-confirmed") return void 0;
|
|
@@ -180,7 +185,7 @@ class Route {
|
|
|
180
185
|
if (this.status === "opening") {
|
|
181
186
|
return true;
|
|
182
187
|
}
|
|
183
|
-
if (this.isDestroyed || !this.
|
|
188
|
+
if (this.isDestroyed || !this.isConfigPathMatched || this.params === null || this.status === "open-confirmed" || this.status === "open-rejected") {
|
|
184
189
|
return false;
|
|
185
190
|
}
|
|
186
191
|
return this.status === "closed" || this.status === "unknown";
|
|
@@ -223,16 +228,38 @@ class Route {
|
|
|
223
228
|
}
|
|
224
229
|
return this.parsedPathData?.params ?? null;
|
|
225
230
|
}
|
|
226
|
-
get
|
|
231
|
+
get isConfigPathMatched() {
|
|
227
232
|
return this.parsedPathData !== null;
|
|
228
233
|
}
|
|
234
|
+
/**
|
|
235
|
+
* Whether the current URL path includes this route's path pattern.
|
|
236
|
+
* Uses prefix matching (`end: false`), so `/users` matches `/users/123`.
|
|
237
|
+
* Useful for navigation menu highlighting.
|
|
238
|
+
*
|
|
239
|
+
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)
|
|
240
|
+
*/
|
|
241
|
+
get isPathMatched() {
|
|
242
|
+
let pathname = this.isHash ? this.history.location.hash.slice(1) : this.history.location.pathname;
|
|
243
|
+
if (this.baseUrl) {
|
|
244
|
+
if (!pathname.startsWith(this.baseUrl)) return false;
|
|
245
|
+
pathname = pathname.replace(this.baseUrl, "");
|
|
246
|
+
}
|
|
247
|
+
if (this.pathDeclaration === "" || this.pathDeclaration === "/") {
|
|
248
|
+
return pathname === "/" || pathname === "" || pathname.startsWith("/");
|
|
249
|
+
}
|
|
250
|
+
const matcher = pathToRegexp.match(this.tokenData, {
|
|
251
|
+
end: false,
|
|
252
|
+
...this.config.matchOptions
|
|
253
|
+
});
|
|
254
|
+
return matcher(pathname) !== false;
|
|
255
|
+
}
|
|
229
256
|
/**
|
|
230
257
|
* Defines the "open" state for this route.
|
|
231
258
|
*
|
|
232
259
|
* [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)
|
|
233
260
|
*/
|
|
234
261
|
get isOpened() {
|
|
235
|
-
if (this.isDestroyed || !this.
|
|
262
|
+
if (this.isDestroyed || !this.isConfigPathMatched || this.params === null || this.status !== "open-confirmed") {
|
|
236
263
|
return false;
|
|
237
264
|
}
|
|
238
265
|
return (
|
|
@@ -428,7 +455,7 @@ class Route {
|
|
|
428
455
|
this.history.push(trx.url, trx.state);
|
|
429
456
|
}
|
|
430
457
|
}
|
|
431
|
-
if (this.
|
|
458
|
+
if (this.isConfigPathMatched) {
|
|
432
459
|
const wasAlreadyConfirmed = this.status === "open-confirmed";
|
|
433
460
|
mobx.runInAction(() => {
|
|
434
461
|
this.status = "open-confirmed";
|
|
@@ -820,4 +847,4 @@ exports.createRouter = createRouter;
|
|
|
820
847
|
exports.createVirtualRoute = createVirtualRoute;
|
|
821
848
|
exports.groupRoutes = groupRoutes;
|
|
822
849
|
exports.routeConfig = routeConfig;
|
|
823
|
-
//# sourceMappingURL=virtual-route-
|
|
850
|
+
//# sourceMappingURL=virtual-route-EXYD3rMt.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"virtual-route-EXYD3rMt.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 'isConfigPathMatched',\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(\n () => this.isConfigPathMatched,\n this.checkPathMatch,\n {\n fireImmediately: true,\n },\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.isConfigPathMatched ||\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 isConfigPathMatched() {\n return this.parsedPathData !== null;\n }\n\n /**\n * Whether the current URL path includes this route's path pattern.\n * Uses prefix matching (`end: false`), so `/users` matches `/users/123`.\n * Useful for navigation menu highlighting.\n *\n * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ispathmatched)\n */\n get isPathMatched(): boolean {\n let pathname = this.isHash\n ? this.history.location.hash.slice(1)\n : this.history.location.pathname;\n\n if (this.baseUrl) {\n if (!pathname.startsWith(this.baseUrl)) return false;\n pathname = pathname.replace(this.baseUrl, '');\n }\n\n // Root route always matches any path (prefix of everything)\n if (this.pathDeclaration === '' || this.pathDeclaration === '/') {\n return pathname === '/' || pathname === '' || pathname.startsWith('/');\n }\n\n const matcher = match(this.tokenData, {\n end: false,\n ...this.config.matchOptions,\n });\n return matcher(pathname) !== false;\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.isConfigPathMatched ||\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.isConfigPathMatched) {\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,IACA;AAAA,EAAA;AAAA,EAEF,CAACA,cAAS,QAAQ,kBAAkB,QAAQ;AAAA,EAC5C,CAACC,KAAAA,YAAY,UAAU;AAAA,EACvB,CAACA,KAAAA,WAAW,KAAK,UAAU,QAAQ;AACrC;AAO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
-
{"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<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tual-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,cAAS,QAAQ,kBAAkB,QAAQ;AAAA,EAC5C,CAACC,KAAAA,YAAY,UAAU;AAAA,EACvB,CAACA,KAAAA,WAAW,KAAK,UAAU,QAAQ;AACrC;AAOO,MAAM,MAKX;AAAA,EA2DA,YACE,iBACU,SAKN,IACJ;AANU,SAAA,SAAA;AAOV,SAAK,UAAU,OAAO,WAAW,YAAY,MAAM;AACnD,SAAK,QAAQ,OAAO,eAAe,YAAY,MAAM;AACrD,SAAK,kBAAkB;AACvB,SAAK,UAAU,CAAC,CAAC,KAAK,OAAO;AAC7B,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