@alfalab/bridge-to-native 0.0.9 → 0.0.10

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.
@@ -28,8 +28,9 @@ export declare class NativeNavigationAndTitle {
28
28
  goBackAFewSteps(stepsNumber: number, autoCloseWebview?: boolean): void;
29
29
  /**
30
30
  * @param path Путь для перехода на функциональность внутри приложения.
31
+ * @param historyState (https://developer.mozilla.org/en-US/docs/Web/API/History/state) для новой записи в истории.
31
32
  */
32
- handleRedirect(path: string): void;
33
+ handleRedirect(path: string, historyState?: Record<string, unknown>): void;
33
34
  /**
34
35
  * В этом варианте аргументы 2,3,4 соответствуют аргументам 1,2,3 метода `src/shared/utils/handle-redirect`.
35
36
  *
@@ -37,8 +38,9 @@ export declare class NativeNavigationAndTitle {
37
38
  * @param appName См. первый параметр `src/handle-redirect.ts`.
38
39
  * @param path См. второй параметр `src/handle-redirect.ts`.
39
40
  * @param params См. третий параметр `src/handle-redirect.ts`.
41
+ * @param historyState (https://developer.mozilla.org/en-US/docs/Web/API/History/state) для новой записи в истории.
40
42
  */
41
- handleRedirect(pageTitle: string, appName: string, path?: string, params?: Record<string, string>): void;
43
+ handleRedirect(pageTitle: string, appName: string, path?: string, params?: Record<string, string>, historyState?: Record<string, unknown>): void;
42
44
  /**
43
45
  * Информирует натив, что веб находится на первом экране (сбрасывает историю переходов, не влияя на браузерную
44
46
  * историю), а значит следующее нажатие на кнопку "Назад" в нативе закроет вебвью.
@@ -67,15 +67,17 @@ class NativeNavigationAndTitle {
67
67
  * и регистрирует этот переход в приложении, чтобы кнопка «Назад» в Нативе вызывала
68
68
  * переход назад в вебе.
69
69
  */
70
- handleRedirect(pageTitleOrPath, appName, path, params) {
71
- if (appName) {
72
- this._handleWindowRedirect(appName, path, params);
70
+ handleRedirect(pageTitleOrPath, appNameOrHistoryState, path, params, historyState) {
71
+ const checkAppNameArgument = (argument) => Boolean(appNameOrHistoryState && typeof appNameOrHistoryState === 'string');
72
+ const isAppNameArgument = checkAppNameArgument(appNameOrHistoryState);
73
+ if (isAppNameArgument) {
74
+ this._handleWindowRedirect(appNameOrHistoryState, path, params, historyState);
73
75
  }
74
76
  else {
75
77
  const { appName: extractedAppName, path: extractedPath, query: extractedQuery, } = (0, utils_1.extractAppNameRouteAndQuery)(pageTitleOrPath);
76
- this._handleWindowRedirect(extractedAppName, extractedPath, extractedQuery);
78
+ this._handleWindowRedirect(extractedAppName, extractedPath, extractedQuery, appNameOrHistoryState);
77
79
  }
78
- const title = appName ? pageTitleOrPath : '';
80
+ const title = isAppNameArgument ? pageTitleOrPath : '';
79
81
  this.nativeHistoryStack.push(title);
80
82
  this.syncHistoryWithNative(title, 'navigation');
81
83
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "license": "UNLICENSED",
3
3
  "name": "@alfalab/bridge-to-native",
4
- "version": "0.0.9",
4
+ "version": "0.0.10",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/core-ds/bridge-to-native.git"
package/types.d.ts CHANGED
@@ -30,7 +30,7 @@ export declare type PreviousNativeNavigationAndTitleState = {
30
30
  title: string;
31
31
  };
32
32
  export declare type SyncPurpose = 'initialization' | 'navigation' | 'title-replacing';
33
- export declare type HandleRedirect = (appName: string, path?: string, params?: Record<string, string>) => void;
33
+ export declare type HandleRedirect = (appName: string, path?: string, params?: Record<string, string>, historyState?: Record<string, unknown>) => void;
34
34
  export declare type Theme = 'light' | 'dark';
35
35
  export declare type ExternalNavigationOptions = {
36
36
  onClick?: () => void;