mobx-route 1.2.3 → 1.3.1

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.js CHANGED
@@ -1,744 +1,16 @@
1
- import { isObservableHistory, createBrowserHistory, createQueryParams, buildSearchString } from "mobx-location-history";
2
1
  export * from "mobx-location-history";
3
- import { createGlobalDynamicConfig } from "yummies/complex";
4
- import { computed, observable, reaction, runInAction, action } from "mobx";
5
- import { match, compile, parse } from "path-to-regexp";
6
- import { applyObservable } from "yummies/mobx";
7
- import { callFunction } from "yummies/common";
8
- const routeConfig = createGlobalDynamicConfig(
9
- (update, current) => {
10
- let history;
11
- let queryParams;
12
- if (update?.history) {
13
- history = update.history;
14
- queryParams = update.queryParams;
15
- if (current?.history && isObservableHistory(current.history)) {
16
- current.history.destroy();
17
- }
18
- } else if (current?.history) {
19
- history = current.history;
20
- queryParams = update?.queryParams ?? current.queryParams;
21
- } else {
22
- history = createBrowserHistory();
23
- }
24
- queryParams ??= createQueryParams({ history });
25
- return {
26
- ...update,
27
- history,
28
- queryParams
29
- };
30
- },
31
- /* @__PURE__ */ Symbol.for("MOBX_ROUTE_CONFIG")
32
- );
33
- const annotations$3 = [
34
- [
35
- computed,
36
- "isPathMatched",
37
- "isOpened",
38
- "isOpening",
39
- "path",
40
- "absolutePath",
41
- "hasOpenedChildren",
42
- "isAbleToMergeQuery",
43
- "baseUrl"
44
- ],
45
- [computed.struct, "parsedPathData", "params"],
46
- [observable, "children"],
47
- [observable.ref, "parent", "status"]
48
- ];
49
- class Route {
50
- constructor(pathDeclaration, config = {}) {
51
- this.config = config;
52
- this.history = config.history ?? routeConfig.get().history;
53
- this.query = config.queryParams ?? routeConfig.get().queryParams;
54
- this.pathDeclaration = pathDeclaration;
55
- this.isIndex = !!this.config.index;
56
- this.isHash = !!this.config.hash;
57
- this.meta = this.config.meta;
58
- this.status = "unknown";
59
- this.parent = config.parent ?? null;
60
- applyObservable(this, annotations$3);
61
- if (this.config.abortSignal?.aborted) {
62
- this.isDestroyed = true;
63
- } else {
64
- this.disposer = reaction(() => this.isPathMatched, this.checkPathMatch, {
65
- fireImmediately: true
66
- });
67
- this.config.abortSignal?.addEventListener("abort", () => this.destroy(), {
68
- once: true
69
- });
70
- }
71
- }
72
- config;
73
- isDestroyed;
74
- disposer;
75
- history;
76
- /**
77
- * Parent route.
78
- *
79
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#parent)
80
- */
81
- parent;
82
- query;
83
- _tokenData;
84
- _matcher;
85
- _compiler;
86
- ignoreOpenByPathMatch = false;
87
- status;
88
- meta;
89
- /**
90
- * Route path pattern declaration.
91
- *
92
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#pathdeclaration)
93
- */
94
- pathDeclaration;
95
- /**
96
- * Indicates if this route is an index route. Index routes activate when parent route path matches exactly.
97
- *
98
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isindex)
99
- */
100
- isIndex;
101
- /**
102
- * Indicates if this route is an hash route.
103
- *
104
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#ishash)
105
- */
106
- isHash;
107
- /**
108
- * Array of child routes.
109
- *
110
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#children)
111
- */
112
- children = [];
113
- get baseUrl() {
114
- const baseUrl = this.config.baseUrl ?? routeConfig.get().baseUrl;
115
- return baseUrl?.endsWith("/") ? baseUrl.slice(0, -1) : baseUrl;
116
- }
117
- /**
118
- * Checks whether current route matches provided path.
119
- *
120
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#matchpath)
121
- */
122
- matchPath(path) {
123
- let pathnameToCheck;
124
- if (path != null) {
125
- pathnameToCheck = path;
126
- } else if (this.isHash) {
127
- pathnameToCheck = this.history.location.hash.slice(1);
128
- } else {
129
- pathnameToCheck = this.history.location.pathname;
130
- }
131
- if (this.baseUrl) {
132
- if (!pathnameToCheck.startsWith(this.baseUrl)) {
133
- return null;
134
- }
135
- pathnameToCheck = pathnameToCheck.replace(this.baseUrl, "");
136
- }
137
- if ((this.pathDeclaration === "" || this.pathDeclaration === "/") && (pathnameToCheck === "/" || pathnameToCheck === "")) {
138
- return { params: {}, path: pathnameToCheck };
139
- }
140
- this._matcher ??= match(this.tokenData, {
141
- end: this.config.exact ?? false,
142
- ...this.config.matchOptions
143
- });
144
- const parsed = this._matcher(pathnameToCheck);
145
- if (parsed === false) {
146
- return null;
147
- }
148
- return parsed;
149
- }
150
- get parsedPathData() {
151
- return this.matchPath();
152
- }
153
- /**
154
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopening)
155
- *
156
- * Also true in the short gap after history already matches this route but
157
- * `confirmOpening` has not started yet (e.g. browser Back) — otherwise every
158
- * route looks closed for one tick and RouteViewGroup unmounts the page.
159
- */
160
- get isOpening() {
161
- if (this.status === "opening") {
162
- return true;
163
- }
164
- if (this.isDestroyed || !this.isPathMatched || this.params === null || this.status === "open-confirmed" || this.status === "open-rejected") {
165
- return false;
166
- }
167
- return this.status === "closed" || this.status === "unknown";
168
- }
169
- /**
170
- * Matched path segment for current URL.
171
- *
172
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#path)
173
- */
174
- get path() {
175
- return this.parsedPathData?.path ?? null;
176
- }
177
- /**
178
- * Matched path segment for current URL with base URL.
179
- *
180
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#absolutepath)
181
- */
182
- get absolutePath() {
183
- const path = this.path;
184
- if (path === null) {
185
- return null;
186
- }
187
- return `${this.baseUrl || ""}${path}`;
188
- }
189
- /**
190
- * Current parsed path parameters.
191
- *
192
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#params)
193
- */
194
- get params() {
195
- if (!this.parsedPathData?.params) {
196
- return null;
197
- }
198
- let params = this.parsedPathData?.params ?? null;
199
- if (this.config.params) {
200
- const result = this.config.params(
201
- this.parsedPathData.params,
202
- this.config.meta
203
- );
204
- if (result) {
205
- params = result;
206
- } else {
207
- return null;
208
- }
209
- }
210
- return params;
211
- }
212
- get isPathMatched() {
213
- return this.parsedPathData !== null;
214
- }
215
- /**
216
- * Defines the "open" state for this route.
217
- *
218
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#isopened)
219
- */
220
- get isOpened() {
221
- if (this.isDestroyed || !this.isPathMatched || this.params === null || this.status !== "open-confirmed") {
222
- return false;
223
- }
224
- return (
225
- // this.parsedPathData is defined because this.params !== null
226
- !this.config.checkOpened || this.config.checkOpened(this.parsedPathData)
227
- );
228
- }
229
- /**
230
- * Allows to create child route based on this route with merging this route path and extending path.
231
- *
232
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#extend)
233
- */
234
- extend(pathDeclaration, config) {
235
- const { index, params, exact, ...configFromCurrentRoute } = this.config;
236
- const extendedChild = new Route(`${this.pathDeclaration}${pathDeclaration}`, {
237
- ...configFromCurrentRoute,
238
- ...config,
239
- parent: this
240
- });
241
- this.addChildren(extendedChild);
242
- return extendedChild;
243
- }
244
- /**
245
- * Manually add child routes.
246
- *
247
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#addchildren)
248
- */
249
- addChildren(...routes) {
250
- this.children.push(...routes);
251
- }
252
- /**
253
- * Remove specified routes from children.
254
- *
255
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#removechildren)
256
- */
257
- removeChildren(...routes) {
258
- this.children = this.children.filter((child) => !routes.includes(child));
259
- }
260
- /**
261
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#hasopenedchildren)
262
- */
263
- get hasOpenedChildren() {
264
- return this.children.some(
265
- (child) => child.isOpened || child.hasOpenedChildren
266
- );
267
- }
268
- processParams(params) {
269
- if (params == null) return void 0;
270
- return Object.entries(params).reduce((acc, [key, value]) => {
271
- if (value != null) {
272
- acc[key] = Array.isArray(value) ? value.map(String) : String(value);
273
- }
274
- return acc;
275
- }, {});
276
- }
277
- /**
278
- * Generates full route URL.
279
- *
280
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#createurl)
281
- */
282
- createUrl(...args) {
283
- const params = args[0];
284
- const rawQuery = args[1];
285
- const mergeQueryOrOutputParams = args[2] ?? this.isAbleToMergeQuery;
286
- const outputParams = typeof mergeQueryOrOutputParams === "boolean" ? { mergeQuery: mergeQueryOrOutputParams } : mergeQueryOrOutputParams;
287
- const query = outputParams?.mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery ?? {};
288
- this._compiler ??= compile(this.tokenData);
289
- const defaultUrlCreateParams = {
290
- baseUrl: this.baseUrl,
291
- params,
292
- query
293
- };
294
- const urlCreateParams = this.config.createUrl?.(defaultUrlCreateParams, this.query.data) ?? routeConfig.get().createUrl?.(defaultUrlCreateParams, this.query.data) ?? defaultUrlCreateParams;
295
- let path;
296
- try {
297
- path = this._compiler(this.processParams(urlCreateParams.params));
298
- } catch (e) {
299
- if (process.env.NODE_ENV !== "production") {
300
- console.error(
301
- 'Error #1: Route path compilation failed\nThe path pattern could not be built into a URL (often missing or invalid params for a `:param` segment). Using fallbackPath or "/".\nSee docs: https://js2me.github.io/mobx-route/errors/1',
302
- e
303
- );
304
- } else {
305
- console.error("minified error #1;see mobx-route docs", e);
306
- }
307
- path = this.config.fallbackPath ?? routeConfig.get().fallbackPath ?? "/";
308
- }
309
- const url = `${urlCreateParams.baseUrl || ""}${this.isHash ? "#" : ""}${path}`;
310
- if (outputParams?.omitQuery) {
311
- return url;
312
- }
313
- return `${url}${buildSearchString(urlCreateParams.query)}`;
314
- }
315
- /**
316
- * Navigates to this route.
317
- *
318
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#open)
319
- */
320
- async open(...args) {
321
- const {
322
- replace,
323
- state: rawState,
324
- query: rawQuery,
325
- mergeQuery: rawMergeQuery
326
- } = typeof args[1] === "boolean" || args.length > 2 ? { replace: args[1], query: args[2] } : args[1] ?? {};
327
- let url;
328
- let params;
329
- const mergeQuery = rawMergeQuery ?? this.isAbleToMergeQuery;
330
- const query = mergeQuery ? { ...this.query.data, ...rawQuery } : rawQuery;
331
- if (typeof args[0] === "string") {
332
- url = args[0];
333
- } else {
334
- params = args[0];
335
- url = this.createUrl(args[0], query);
336
- }
337
- const state = rawState ?? null;
338
- const trx = {
339
- url,
340
- params,
341
- replace,
342
- state,
343
- query
344
- };
345
- this.ignoreOpenByPathMatch = true;
346
- const isConfirmed = await this.confirmOpening(trx);
347
- if (isConfirmed !== true) {
348
- this.ignoreOpenByPathMatch = false;
349
- }
350
- }
351
- get tokenData() {
352
- if (!this._tokenData) {
353
- this._tokenData = parse(this.pathDeclaration, this.config.parseOptions);
354
- }
355
- return this._tokenData;
356
- }
357
- async confirmOpening(trx) {
358
- runInAction(() => {
359
- this.status = "opening";
360
- });
361
- let skipHistoryUpdate = !!trx.preferSkipHistoryUpdate;
362
- if (skipHistoryUpdate) {
363
- this.ignoreOpenByPathMatch = false;
364
- }
365
- if (this.config.beforeOpen) {
366
- const feedback = await this.config.beforeOpen(trx);
367
- if (feedback === false) {
368
- runInAction(() => {
369
- this.status = "open-rejected";
370
- });
371
- return;
372
- }
373
- if (typeof feedback === "object") {
374
- skipHistoryUpdate = false;
375
- Object.assign(trx, feedback);
376
- }
377
- }
378
- if (this.isDestroyed) {
379
- return;
380
- }
381
- if (!skipHistoryUpdate) {
382
- if (trx.replace) {
383
- this.history.replace(trx.url, trx.state);
384
- } else {
385
- this.history.push(trx.url, trx.state);
386
- }
387
- }
388
- if (this.isPathMatched) {
389
- runInAction(() => {
390
- this.status = "open-confirmed";
391
- });
392
- this.config.afterOpen?.(this.parsedPathData, this);
393
- }
394
- return true;
395
- }
396
- confirmClosing() {
397
- runInAction(() => {
398
- this.status = "closed";
399
- });
400
- return true;
401
- }
402
- firstPathMatchingRun = true;
403
- checkPathMatch = async (isPathMathched) => {
404
- if (this.firstPathMatchingRun) {
405
- this.firstPathMatchingRun = false;
406
- if (!isPathMathched) {
407
- return;
408
- }
409
- }
410
- if (isPathMathched) {
411
- if (this.ignoreOpenByPathMatch) {
412
- this.ignoreOpenByPathMatch = false;
413
- if (this.status === "opening" && this.parsedPathData) {
414
- runInAction(() => {
415
- this.status = "open-confirmed";
416
- });
417
- this.config.afterOpen?.(this.parsedPathData, this);
418
- }
419
- return;
420
- }
421
- if (this.status !== "opening" && this.status !== "open-confirmed") {
422
- runInAction(() => {
423
- this.status = "opening";
424
- });
425
- }
426
- const trx = {
427
- url: this.parsedPathData.path,
428
- params: this.parsedPathData.params,
429
- state: this.history.location.state,
430
- query: this.query.data,
431
- preferSkipHistoryUpdate: true
432
- };
433
- await this.confirmOpening(trx);
434
- } else {
435
- this.ignoreOpenByPathMatch = false;
436
- const isConfirmed = this.confirmClosing();
437
- if (isConfirmed) {
438
- this.config.afterClose?.();
439
- }
440
- }
441
- };
442
- get isAbleToMergeQuery() {
443
- return this.config.mergeQuery ?? routeConfig.get().mergeQuery;
444
- }
445
- /**
446
- * Destroys route subscriptions and reactions.
447
- *
448
- * [**Documentation**](https://js2me.github.io/mobx-route/core/Route.html#destroy)
449
- */
450
- destroy() {
451
- this.isDestroyed = true;
452
- this.disposer?.();
453
- this.disposer = void 0;
454
- }
455
- }
456
- const createRoute = (path, config) => new Route(path, config);
457
- const annotations$2 = [
458
- [computed, "isOpened", "indexRoute", "canNavigate"],
459
- [observable.shallow, "routes"]
460
- ];
461
- class RouteGroup {
462
- constructor(routes, _indexRoute) {
463
- this._indexRoute = _indexRoute;
464
- this.routes = routes;
465
- applyObservable(this, annotations$2);
466
- }
467
- _indexRoute;
468
- routes;
469
- /**
470
- * Returns true if at least one route in the group is open.
471
- *
472
- * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#isopened)
473
- */
474
- get isOpened() {
475
- const routes = Object.values(this.routes);
476
- return routes.some(
477
- (route) => route.isOpened || "hasOpenedChildren" in route && route.hasOpenedChildren
478
- );
479
- }
480
- /**
481
- * First found index route.
482
- *
483
- * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#indexroute)
484
- */
485
- get indexRoute() {
486
- return this._indexRoute ?? Object.values(this.routes).find(
487
- (route) => "isIndex" in route && route.isIndex
488
- );
489
- }
490
- /**
491
- * `true` if `open()` has a target to navigate to —
492
- * either an own index route or a nested `RouteGroup` that itself can navigate.
493
- *
494
- * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#cannavigate)
495
- */
496
- get canNavigate() {
497
- if (this.indexRoute) return true;
498
- for (const routeName in this.routes) {
499
- const route = this.routes[routeName];
500
- if (route instanceof RouteGroup && route.canNavigate) {
501
- return true;
502
- }
503
- }
504
- return false;
505
- }
506
- /**
507
- * Main navigation method for the group.
508
- *
509
- * [**Documentation**](https://js2me.github.io/mobx-route/core/groupRoutes.html#open)
510
- */
511
- open(...args) {
512
- if (this.indexRoute && "open" in this.indexRoute) {
513
- this.indexRoute.open(...args);
514
- return;
515
- }
516
- for (const routeName in this.routes) {
517
- const route = this.routes[routeName];
518
- if (route instanceof RouteGroup && route.canNavigate) {
519
- route.open(...args);
520
- return;
521
- }
522
- }
523
- if (process.env.NODE_ENV !== "production") {
524
- console.warn(
525
- "Warning #1: RouteGroup.open() cannot navigate\nThis group has no index route (`index: true` or `groupRoutes(routes, indexRoute)`) and no navigable nested RouteGroup, so open() does nothing.\nSee docs: https://js2me.github.io/mobx-route/warnings/1"
526
- );
527
- } else {
528
- console.warn("minified warning #1;see mobx-route docs");
529
- }
530
- }
531
- }
532
- const groupRoutes = (routes, indexRoute) => new RouteGroup(routes, indexRoute);
533
- const annotations$1 = [
534
- [computed.struct, "location"]
535
- ];
536
- class Router {
537
- routes;
538
- history;
539
- query;
540
- constructor(config) {
541
- this.routes = config.routes;
542
- this.history = config.history ?? routeConfig.get().history;
543
- this.query = config.queryParams ?? routeConfig.get().queryParams;
544
- applyObservable(this, annotations$1);
545
- }
546
- get location() {
547
- return this.history.location;
548
- }
549
- navigate(url, options) {
550
- const query = options?.mergeQuery ?? routeConfig.get().mergeQuery ? { ...this.query.data, ...options?.query } : { ...options?.query };
551
- const searchString = buildSearchString(query);
552
- const navigationUrl = `${url}${searchString}`;
553
- if (options?.replace) {
554
- this.history.replace(navigationUrl, options?.state);
555
- } else {
556
- this.history.push(navigationUrl, options?.state);
557
- }
558
- }
559
- }
560
- const createRouter = (config) => new Router(config);
2
+ import { R, a, b, V, c, d, e, g, r } from "./virtual-route-fZzKp_7K.js";
561
3
  const isRouteEntity = (route) => route && "isOpened" in route;
562
- const annotations = [
563
- [observable, "params"],
564
- [observable.ref, "status", "trx", "openChecker", "isOuterOpened"],
565
- [computed, "isOpened", "isOpening", "isClosing"],
566
- [action, "setOpenChecker", "open", "close", "destroy"]
567
- ];
568
- class VirtualRoute {
569
- constructor(config = {}) {
570
- this.config = config;
571
- this.query = config.queryParams ?? routeConfig.get().queryParams;
572
- this.params = callFunction(config.initialParams, this) ?? null;
573
- this.openChecker = config.checkOpened;
574
- this.skipAutoOpenClose = false;
575
- this.isOuterOpened = this.openChecker?.(this);
576
- this.status = this.isOuterOpened ? "opened" : "unknown";
577
- applyObservable(this, annotations);
578
- if (this.config.abortSignal?.aborted) {
579
- this.isDestroyed = true;
580
- } else {
581
- this.disposer = reaction(
582
- () => this.openChecker?.(this),
583
- action((isOuterOpened) => {
584
- this.isOuterOpened = isOuterOpened;
585
- if (this.skipAutoOpenClose || this.status === "closing" || this.status === "opening") {
586
- return;
587
- }
588
- if (this.isOuterOpened) {
589
- if (this.status === "opened") {
590
- return;
591
- }
592
- void this.confirmOpening({
593
- params: this.params ?? null,
594
- ...this.config.getAutoOpenParams?.(this)
595
- });
596
- } else {
597
- if (this.status === "closed" || this.status === "unknown") {
598
- return;
599
- }
600
- void this.confirmClosing();
601
- }
602
- }),
603
- { signal: this.config.abortSignal, fireImmediately: true }
604
- );
605
- }
606
- if (this.status === "opened") {
607
- this.config.afterOpen?.(this.params, this);
608
- }
609
- }
610
- config;
611
- isDestroyed;
612
- disposer;
613
- query;
614
- params;
615
- status;
616
- openChecker;
617
- trx;
618
- skipAutoOpenClose;
619
- /**
620
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isouteropened)
621
- */
622
- isOuterOpened;
623
- /**
624
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopened)
625
- */
626
- get isOpened() {
627
- return !this.isDestroyed && this.status === "opened" && this.isOuterOpened !== false;
628
- }
629
- /**
630
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isopening)
631
- */
632
- get isOpening() {
633
- return this.status === "opening";
634
- }
635
- /**
636
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#isclosing)
637
- */
638
- get isClosing() {
639
- return this.status === "closing";
640
- }
641
- /**
642
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#setopenchecker)
643
- */
644
- setOpenChecker(openChecker) {
645
- this.openChecker = openChecker;
646
- }
647
- async open(...args) {
648
- const params = args[0] ?? null;
649
- const extra = args[1];
650
- this.skipAutoOpenClose = true;
651
- this.trx = {
652
- params,
653
- extra,
654
- manual: true
655
- };
656
- await this.confirmOpening(this.trx);
657
- this.skipAutoOpenClose = false;
658
- }
659
- /**
660
- * [**Documentation**](https://js2me.github.io/mobx-route/core/VirtualRoute.html#close)
661
- */
662
- async close() {
663
- this.skipAutoOpenClose = true;
664
- const result = await this.confirmClosing();
665
- this.skipAutoOpenClose = false;
666
- return result;
667
- }
668
- async confirmOpening(trx) {
669
- runInAction(() => {
670
- this.trx = void 0;
671
- this.status = "opening";
672
- });
673
- if (await this.config.beforeOpen?.(trx.params, this) === false) {
674
- runInAction(() => {
675
- this.status = "open-rejected";
676
- this.trx = void 0;
677
- });
678
- return;
679
- }
680
- if (await this.config.open?.(trx.params, this) === false) {
681
- runInAction(() => {
682
- this.status = "open-rejected";
683
- this.trx = void 0;
684
- });
685
- return;
686
- }
687
- runInAction(() => {
688
- if (trx.extra?.query) {
689
- this.query.update(trx.extra.query, trx.extra.replace);
690
- }
691
- this.trx = void 0;
692
- this.params = trx.params;
693
- this.status = "opened";
694
- this.config.afterOpen?.(this.params, this);
695
- });
696
- return true;
697
- }
698
- async confirmClosing() {
699
- if (this.status === "closed") {
700
- return true;
701
- }
702
- const lastStatus = this.status;
703
- runInAction(() => {
704
- this.status = "closing";
705
- });
706
- if (await this.config.beforeClose?.() === false) {
707
- runInAction(() => {
708
- this.status = lastStatus;
709
- });
710
- return;
711
- }
712
- if (this.config.close?.(this) === false) {
713
- runInAction(() => {
714
- this.status = lastStatus;
715
- });
716
- return;
717
- }
718
- runInAction(() => {
719
- this.status = "closed";
720
- this.params = null;
721
- });
722
- this.config.afterClose?.();
723
- return true;
724
- }
725
- destroy() {
726
- this.isDestroyed = true;
727
- this.status = "unknown";
728
- this.disposer?.();
729
- }
730
- }
731
- const createVirtualRoute = (config) => new VirtualRoute(config);
732
4
  export {
733
- Route,
734
- RouteGroup,
735
- Router,
736
- VirtualRoute,
737
- createRoute,
738
- createRouter,
739
- createVirtualRoute,
740
- groupRoutes,
5
+ R as Route,
6
+ a as RouteGroup,
7
+ b as Router,
8
+ V as VirtualRoute,
9
+ c as createRoute,
10
+ d as createRouter,
11
+ e as createVirtualRoute,
12
+ g as groupRoutes,
741
13
  isRouteEntity,
742
- routeConfig
14
+ r as routeConfig
743
15
  };
744
16
  //# sourceMappingURL=index.js.map