@tinkoff/router 0.1.67 → 0.1.68
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/lib/index.browser.js +3 -4
- package/lib/index.es.js +11 -9
- package/lib/index.js +11 -9
- package/lib/router/abstract.d.ts +1 -1
- package/lib/router/server.d.ts +1 -0
- package/package.json +1 -1
package/lib/index.browser.js
CHANGED
|
@@ -220,17 +220,16 @@ class AbstractRouter {
|
|
|
220
220
|
await this.runHooks('afterUpdateCurrent', navigation);
|
|
221
221
|
}
|
|
222
222
|
async navigate(navigateOptions) {
|
|
223
|
-
return this.internalNavigate(navigateOptions, {});
|
|
223
|
+
return this.internalNavigate(typeof navigateOptions === 'string' ? { url: navigateOptions } : navigateOptions, {});
|
|
224
224
|
}
|
|
225
225
|
async internalNavigate(navigateOptions, { history }) {
|
|
226
226
|
var _a;
|
|
227
|
-
const
|
|
228
|
-
const { url, replace, params, navigateState, code } = options;
|
|
227
|
+
const { url, replace, params, navigateState, code } = navigateOptions;
|
|
229
228
|
const prevNavigation = (_a = this.currentNavigation) !== null && _a !== void 0 ? _a : this.lastNavigation;
|
|
230
229
|
if (!url && !prevNavigation) {
|
|
231
230
|
throw new Error('Navigate url should be specified and cannot be omitted for first navigation');
|
|
232
231
|
}
|
|
233
|
-
const resolvedUrl = this.resolveUrl(
|
|
232
|
+
const resolvedUrl = this.resolveUrl(navigateOptions);
|
|
234
233
|
const { to: from, url: fromUrl } = prevNavigation !== null && prevNavigation !== void 0 ? prevNavigation : {};
|
|
235
234
|
let navigation = {
|
|
236
235
|
type: 'navigate',
|
package/lib/index.es.js
CHANGED
|
@@ -220,17 +220,16 @@ class AbstractRouter {
|
|
|
220
220
|
await this.runHooks('afterUpdateCurrent', navigation);
|
|
221
221
|
}
|
|
222
222
|
async navigate(navigateOptions) {
|
|
223
|
-
return this.internalNavigate(navigateOptions, {});
|
|
223
|
+
return this.internalNavigate(typeof navigateOptions === 'string' ? { url: navigateOptions } : navigateOptions, {});
|
|
224
224
|
}
|
|
225
225
|
async internalNavigate(navigateOptions, { history }) {
|
|
226
226
|
var _a;
|
|
227
|
-
const
|
|
228
|
-
const { url, replace, params, navigateState, code } = options;
|
|
227
|
+
const { url, replace, params, navigateState, code } = navigateOptions;
|
|
229
228
|
const prevNavigation = (_a = this.currentNavigation) !== null && _a !== void 0 ? _a : this.lastNavigation;
|
|
230
229
|
if (!url && !prevNavigation) {
|
|
231
230
|
throw new Error('Navigate url should be specified and cannot be omitted for first navigation');
|
|
232
231
|
}
|
|
233
|
-
const resolvedUrl = this.resolveUrl(
|
|
232
|
+
const resolvedUrl = this.resolveUrl(navigateOptions);
|
|
234
233
|
const { to: from, url: fromUrl } = prevNavigation !== null && prevNavigation !== void 0 ? prevNavigation : {};
|
|
235
234
|
let navigation = {
|
|
236
235
|
type: 'navigate',
|
|
@@ -682,13 +681,16 @@ class Router extends AbstractRouter {
|
|
|
682
681
|
});
|
|
683
682
|
return this.lastNavigation;
|
|
684
683
|
}
|
|
685
|
-
async
|
|
686
|
-
if (this.redirectCode) {
|
|
687
|
-
return this.redirect(navigation, { url: navigation.url.path, code: this.redirectCode });
|
|
688
|
-
}
|
|
684
|
+
async internalNavigate(navigateOptions, internalOptions) {
|
|
689
685
|
// any navigation after initial should be considered as redirects
|
|
690
686
|
if (this.getCurrentRoute()) {
|
|
691
|
-
return this.redirect(
|
|
687
|
+
return this.redirect(this.lastNavigation, navigateOptions);
|
|
688
|
+
}
|
|
689
|
+
return super.internalNavigate(navigateOptions, internalOptions);
|
|
690
|
+
}
|
|
691
|
+
async run(navigation) {
|
|
692
|
+
if (this.redirectCode) {
|
|
693
|
+
return this.redirect(navigation, { url: navigation.url.href, code: this.redirectCode });
|
|
692
694
|
}
|
|
693
695
|
await super.run(navigation);
|
|
694
696
|
}
|
package/lib/index.js
CHANGED
|
@@ -236,17 +236,16 @@ class AbstractRouter {
|
|
|
236
236
|
await this.runHooks('afterUpdateCurrent', navigation);
|
|
237
237
|
}
|
|
238
238
|
async navigate(navigateOptions) {
|
|
239
|
-
return this.internalNavigate(navigateOptions, {});
|
|
239
|
+
return this.internalNavigate(typeof navigateOptions === 'string' ? { url: navigateOptions } : navigateOptions, {});
|
|
240
240
|
}
|
|
241
241
|
async internalNavigate(navigateOptions, { history }) {
|
|
242
242
|
var _a;
|
|
243
|
-
const
|
|
244
|
-
const { url, replace, params, navigateState, code } = options;
|
|
243
|
+
const { url, replace, params, navigateState, code } = navigateOptions;
|
|
245
244
|
const prevNavigation = (_a = this.currentNavigation) !== null && _a !== void 0 ? _a : this.lastNavigation;
|
|
246
245
|
if (!url && !prevNavigation) {
|
|
247
246
|
throw new Error('Navigate url should be specified and cannot be omitted for first navigation');
|
|
248
247
|
}
|
|
249
|
-
const resolvedUrl = this.resolveUrl(
|
|
248
|
+
const resolvedUrl = this.resolveUrl(navigateOptions);
|
|
250
249
|
const { to: from, url: fromUrl } = prevNavigation !== null && prevNavigation !== void 0 ? prevNavigation : {};
|
|
251
250
|
let navigation = {
|
|
252
251
|
type: 'navigate',
|
|
@@ -698,13 +697,16 @@ class Router extends AbstractRouter {
|
|
|
698
697
|
});
|
|
699
698
|
return this.lastNavigation;
|
|
700
699
|
}
|
|
701
|
-
async
|
|
702
|
-
if (this.redirectCode) {
|
|
703
|
-
return this.redirect(navigation, { url: navigation.url.path, code: this.redirectCode });
|
|
704
|
-
}
|
|
700
|
+
async internalNavigate(navigateOptions, internalOptions) {
|
|
705
701
|
// any navigation after initial should be considered as redirects
|
|
706
702
|
if (this.getCurrentRoute()) {
|
|
707
|
-
return this.redirect(
|
|
703
|
+
return this.redirect(this.lastNavigation, navigateOptions);
|
|
704
|
+
}
|
|
705
|
+
return super.internalNavigate(navigateOptions, internalOptions);
|
|
706
|
+
}
|
|
707
|
+
async run(navigation) {
|
|
708
|
+
if (this.redirectCode) {
|
|
709
|
+
return this.redirect(navigation, { url: navigation.url.href, code: this.redirectCode });
|
|
708
710
|
}
|
|
709
711
|
await super.run(navigation);
|
|
710
712
|
}
|
package/lib/router/abstract.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ export declare abstract class AbstractRouter {
|
|
|
45
45
|
protected internalUpdateCurrentRoute(updateRouteOptions: UpdateCurrentRouteOptions, { history }: InternalOptions): Promise<void>;
|
|
46
46
|
protected runUpdateCurrentRoute(navigation: Navigation): Promise<void>;
|
|
47
47
|
navigate(navigateOptions: NavigateOptions | string): Promise<void>;
|
|
48
|
-
protected internalNavigate(navigateOptions: NavigateOptions
|
|
48
|
+
protected internalNavigate(navigateOptions: NavigateOptions, { history }: InternalOptions): Promise<void>;
|
|
49
49
|
protected runNavigate(navigation: Navigation): Promise<void>;
|
|
50
50
|
protected run(navigation: Navigation): Promise<void>;
|
|
51
51
|
resolve(resolveOptions: NavigateOptions | string, options?: Parameters<AbstractRouter['resolveRoute']>[1]): import("../types").NavigationRoute;
|
package/lib/router/server.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export declare class Router extends AbstractRouter {
|
|
|
8
8
|
constructor(options: Options);
|
|
9
9
|
protected onRedirect: (navigation: Navigation) => Promise<void>;
|
|
10
10
|
dehydrate(): Promise<Navigation>;
|
|
11
|
+
protected internalNavigate(navigateOptions: NavigateOptions, internalOptions: any): Promise<void>;
|
|
11
12
|
protected run(navigation: Navigation): Promise<void>;
|
|
12
13
|
protected redirect(navigation: Navigation, target: NavigateOptions): Promise<void>;
|
|
13
14
|
protected notfound(navigation: Navigation): Promise<void>;
|