@tinkoff/router 0.3.18 → 0.3.21

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.
@@ -236,6 +236,7 @@ class AbstractRouter {
236
236
  }
237
237
  throw new Error('Navigation blocked');
238
238
  }
239
+ cancel() { }
239
240
  normalizePathname(pathname) {
240
241
  let normalized = pathname;
241
242
  if (this.mergeSlashes) {
@@ -65,6 +65,7 @@ export declare abstract class AbstractRouter {
65
65
  protected redirect(navigation: Navigation, target: NavigateOptions): Promise<void>;
66
66
  protected notfound(navigation: Navigation): Promise<void>;
67
67
  protected block(navigation: Navigation): Promise<void>;
68
+ cancel(): Navigation | void;
68
69
  protected normalizePathname(pathname?: string): string;
69
70
  protected resolveUrl({ url, query, params, preserveQuery, hash }: NavigateOptions): Url;
70
71
  protected resolveRoute({ url, params, navigateState }: {
@@ -236,6 +236,7 @@ class AbstractRouter {
236
236
  }
237
237
  throw new Error('Navigation blocked');
238
238
  }
239
+ cancel() { }
239
240
  normalizePathname(pathname) {
240
241
  let normalized = pathname;
241
242
  if (this.mergeSlashes) {
@@ -245,6 +245,7 @@ class AbstractRouter {
245
245
  }
246
246
  throw new Error('Navigation blocked');
247
247
  }
248
+ cancel() { }
248
249
  normalizePathname(pathname) {
249
250
  let normalized = pathname;
250
251
  if (this.mergeSlashes) {
@@ -70,7 +70,7 @@ class Router extends ClientRouter {
70
70
  }
71
71
  commitNavigation(navigation) {
72
72
  // if we have parallel navigation do not update current url, as it outdated anyway
73
- if (navigation.cancelled) {
73
+ if (navigation.cancelled || navigation.skipped) {
74
74
  logger.debug({
75
75
  event: 'delay-ignore-commit',
76
76
  navigation,
@@ -226,6 +226,18 @@ class Router extends ClientRouter {
226
226
  catch (error) { }
227
227
  }
228
228
  }
229
+ cancel() {
230
+ if (!this.isNavigating())
231
+ return;
232
+ logger.debug({
233
+ event: 'cancelled',
234
+ navigation: this.currentNavigation,
235
+ });
236
+ const cancelled = this.currentNavigation;
237
+ this.currentNavigation.skipped = true;
238
+ this.currentNavigation = null;
239
+ return cancelled;
240
+ }
229
241
  }
230
242
 
231
243
  export { Router };
@@ -20,5 +20,6 @@ export declare class Router extends ClientRouter {
20
20
  private shouldApplyViewTransition;
21
21
  private restoreAppliedViewTransitions;
22
22
  private saveAppliedViewTransitions;
23
+ cancel(): Navigation;
23
24
  }
24
25
  //# sourceMappingURL=browser.d.ts.map
package/lib/types.d.ts CHANGED
@@ -43,6 +43,7 @@ export interface Navigation {
43
43
  navigateState?: any;
44
44
  history?: boolean;
45
45
  cancelled?: boolean;
46
+ skipped?: boolean;
46
47
  code?: number;
47
48
  redirect?: boolean;
48
49
  redirectFrom?: NavigationRoute;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinkoff/router",
3
- "version": "0.3.18",
3
+ "version": "0.3.21",
4
4
  "description": "router",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
@@ -27,7 +27,7 @@
27
27
  "use-sync-external-store": "^1.2.0"
28
28
  },
29
29
  "peerDependencies": {
30
- "@tramvai/core": "3.14.1",
30
+ "@tramvai/core": "3.15.1",
31
31
  "react": ">=16.14.0",
32
32
  "tslib": "^2.4.0"
33
33
  },