@tinkoff/router 0.7.128 → 0.7.131

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.
@@ -100,10 +100,14 @@ class AbstractRouter {
100
100
  await this.onBlock?.(navigation);
101
101
  });
102
102
  this.internalHooks = {
103
+ 'router:add-route': this.hooksFactory.createSync('router:add-route'),
103
104
  'router:resolve-route': this.hooksFactory.createSync('router:resolve-route'),
104
105
  'router:resolve-url': this.hooksFactory.createSync('router:resolve-url'),
105
106
  'router:resolve-view-transition': this.hooksFactory.createSync('router:resolve-view-transition'),
106
107
  };
108
+ this.internalHooks['router:add-route'].tap('router', (_, route) => {
109
+ this._addRoute(route);
110
+ });
107
111
  this.internalHooks['router:resolve-route'].tap('router', (_, args) => {
108
112
  return this._resolveRoute(...args);
109
113
  });
@@ -295,7 +299,7 @@ class AbstractRouter {
295
299
  }
296
300
  unsubscribe() { }
297
301
  addRoute(route) {
298
- this.tree?.addRoute(route);
302
+ this.internalHooks['router:add-route'].call(route);
299
303
  }
300
304
  async redirect(navigation, target) {
301
305
  logger.debug({
@@ -481,6 +485,9 @@ class AbstractRouter {
481
485
  hash: hash ?? resultUrl.hash,
482
486
  }));
483
487
  }
488
+ _addRoute(route) {
489
+ this.tree?.addRoute(route);
490
+ }
484
491
  _resolveRoute({ url, params, navigateState }, { wildcard } = {}) {
485
492
  let route = url ? this.tree?.getRoute(url.pathname) : this.getCurrentRoute();
486
493
  if (wildcard && !route && url) {
@@ -49,6 +49,7 @@ export declare abstract class AbstractRouter {
49
49
  navigation: Navigation;
50
50
  }>>;
51
51
  readonly internalHooks: {
52
+ 'router:add-route': SyncTapableHookInstance<Route, void>;
52
53
  'router:resolve-route': SyncTapableHookInstance<Parameters<AbstractRouter['_resolveRoute']>, NavigationRoute | undefined>;
53
54
  'router:resolve-url': SyncTapableHookInstance<NavigateOptions, Url>;
54
55
  'router:resolve-view-transition': SyncTapableHookInstance<{
@@ -138,6 +139,7 @@ export declare abstract class AbstractRouter {
138
139
  registerHook(hookName: HookName, hook: NavigationHook): import("@tinkoff/hook-runner/lib/types").UntapCallback;
139
140
  private uuid;
140
141
  protected _resolveUrl({ url, query, params, preserveQuery, hash }: NavigateOptions): Url;
142
+ protected _addRoute(route: Route): void;
141
143
  protected _resolveRoute({ url, params, navigateState }: {
142
144
  url?: Url;
143
145
  params?: Params;
@@ -100,10 +100,14 @@ class AbstractRouter {
100
100
  await this.onBlock?.(navigation);
101
101
  });
102
102
  this.internalHooks = {
103
+ 'router:add-route': this.hooksFactory.createSync('router:add-route'),
103
104
  'router:resolve-route': this.hooksFactory.createSync('router:resolve-route'),
104
105
  'router:resolve-url': this.hooksFactory.createSync('router:resolve-url'),
105
106
  'router:resolve-view-transition': this.hooksFactory.createSync('router:resolve-view-transition'),
106
107
  };
108
+ this.internalHooks['router:add-route'].tap('router', (_, route) => {
109
+ this._addRoute(route);
110
+ });
107
111
  this.internalHooks['router:resolve-route'].tap('router', (_, args) => {
108
112
  return this._resolveRoute(...args);
109
113
  });
@@ -295,7 +299,7 @@ class AbstractRouter {
295
299
  }
296
300
  unsubscribe() { }
297
301
  addRoute(route) {
298
- this.tree?.addRoute(route);
302
+ this.internalHooks['router:add-route'].call(route);
299
303
  }
300
304
  async redirect(navigation, target) {
301
305
  logger.debug({
@@ -481,6 +485,9 @@ class AbstractRouter {
481
485
  hash: hash ?? resultUrl.hash,
482
486
  }));
483
487
  }
488
+ _addRoute(route) {
489
+ this.tree?.addRoute(route);
490
+ }
484
491
  _resolveRoute({ url, params, navigateState }, { wildcard } = {}) {
485
492
  let route = url ? this.tree?.getRoute(url.pathname) : this.getCurrentRoute();
486
493
  if (wildcard && !route && url) {
@@ -109,10 +109,14 @@ class AbstractRouter {
109
109
  await this.onBlock?.(navigation);
110
110
  });
111
111
  this.internalHooks = {
112
+ 'router:add-route': this.hooksFactory.createSync('router:add-route'),
112
113
  'router:resolve-route': this.hooksFactory.createSync('router:resolve-route'),
113
114
  'router:resolve-url': this.hooksFactory.createSync('router:resolve-url'),
114
115
  'router:resolve-view-transition': this.hooksFactory.createSync('router:resolve-view-transition'),
115
116
  };
117
+ this.internalHooks['router:add-route'].tap('router', (_, route) => {
118
+ this._addRoute(route);
119
+ });
116
120
  this.internalHooks['router:resolve-route'].tap('router', (_, args) => {
117
121
  return this._resolveRoute(...args);
118
122
  });
@@ -304,7 +308,7 @@ class AbstractRouter {
304
308
  }
305
309
  unsubscribe() { }
306
310
  addRoute(route) {
307
- this.tree?.addRoute(route);
311
+ this.internalHooks['router:add-route'].call(route);
308
312
  }
309
313
  async redirect(navigation, target) {
310
314
  logger.logger.debug({
@@ -490,6 +494,9 @@ class AbstractRouter {
490
494
  hash: hash ?? resultUrl.hash,
491
495
  }));
492
496
  }
497
+ _addRoute(route) {
498
+ this.tree?.addRoute(route);
499
+ }
493
500
  _resolveRoute({ url, params, navigateState }, { wildcard } = {}) {
494
501
  let route = url ? this.tree?.getRoute(url.pathname) : this.getCurrentRoute();
495
502
  if (wildcard && !route && url) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkoff/router",
3
- "version": "0.7.128",
3
+ "version": "0.7.131",
4
4
  "description": "router",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "use-sync-external-store": "^1.4.0"
29
29
  },
30
30
  "peerDependencies": {
31
- "@tramvai/core": "7.31.1",
31
+ "@tramvai/core": "7.33.1",
32
32
  "react": ">=16.14.0",
33
33
  "tslib": "^2.4.0"
34
34
  },