@alfalab/bridge-to-native 0.0.10 → 0.0.11-beta-11f7c07

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.
Files changed (2) hide show
  1. package/native-fallbacks.js +11 -11
  2. package/package.json +1 -1
@@ -41,14 +41,13 @@ class NativeFallbacks {
41
41
  */
42
42
  getExternalLinkProps(link, options = {}) {
43
43
  const { onClick, forceOpenInWebview } = options;
44
- const { iosAppId, environment, appVersion, checkAndroidAllowOpenInNewWebview } = this.b2n;
45
44
  const url = (0, utils_1.getUrlInstance)(link);
46
- const appId = (0, utils_1.getAppId)(environment, iosAppId);
45
+ const appId = (0, utils_1.getAppId)(this.b2n.environment, this.b2n.iosAppId);
47
46
  if (!forceOpenInWebview && this.b2n.canUseNativeFeature('linksInBrowser')) {
48
47
  url.searchParams.append('openInBrowser', 'true');
49
48
  return { href: url.href, onClick };
50
49
  }
51
- if (iosAppId || checkAndroidAllowOpenInNewWebview()) {
50
+ if (this.b2n.iosAppId || this.b2n.checkAndroidAllowOpenInNewWebview()) {
52
51
  return {
53
52
  href: `${appId}://webFeature?type=recommendation&url=${encodeURIComponent(url.href)}`,
54
53
  onClick: options === null || options === void 0 ? void 0 : options.onClick,
@@ -82,17 +81,19 @@ class NativeFallbacks {
82
81
  }
83
82
  let replaceUrl = url;
84
83
  const paramsStr = params.toString();
85
- const { environment, iosAppId } = this.b2n;
86
- if (environment === 'ios') {
87
- replaceUrl = `${iosAppId}:///dashboard/pdf_viewer?${paramsStr}`;
84
+ if (this.b2n.environment === 'ios') {
85
+ replaceUrl = `${this.b2n.iosAppId}:///dashboard/pdf_viewer?${paramsStr}`;
88
86
  }
89
87
  // У андройда через диплинк открывается, но предыдущий экран затирается.
90
88
  // Поэтому мы открываем base64 через конвертирование в бинарный pdf (через ручки сервиса)
91
89
  // Это позволяет перейти назад к вебвью
92
- if (environment === 'android' && type === 'base64') {
90
+ if (this.b2n.environment === 'android' && type === 'base64') {
93
91
  replaceUrl = `/services/base64-to-pdf?${paramsStr}`;
94
92
  }
95
- window.open(replaceUrl);
93
+ const windowObjectReference = window.open(replaceUrl);
94
+ if (windowObjectReference === null) {
95
+ window.location.replace(replaceUrl);
96
+ }
96
97
  }
97
98
  /**
98
99
  * Метод, для перехода на ВНЕШНИЙ ресурс.
@@ -105,14 +106,13 @@ class NativeFallbacks {
105
106
  */
106
107
  visitExternalResource(link, forceOpenInWebview = false) {
107
108
  var _a;
108
- const { iosAppId, appVersion, environment, checkAndroidAllowOpenInNewWebview } = this.b2n;
109
109
  const url = (0, utils_1.getUrlInstance)(link);
110
- const appId = (0, utils_1.getAppId)(environment, iosAppId);
110
+ const appId = (0, utils_1.getAppId)(this.b2n.environment, this.b2n.iosAppId);
111
111
  if (!forceOpenInWebview && this.b2n.canUseNativeFeature('linksInBrowser')) {
112
112
  url.searchParams.append('openInBrowser', 'true');
113
113
  window.location.replace(url.href);
114
114
  }
115
- else if (iosAppId || checkAndroidAllowOpenInNewWebview()) {
115
+ else if (this.b2n.iosAppId || this.b2n.checkAndroidAllowOpenInNewWebview()) {
116
116
  window.location.replace(`${appId}://webFeature?type=recommendation&url=${encodeURIComponent(url.href)}`);
117
117
  }
118
118
  else {
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.10",
4
+ "version": "0.0.11-beta-11f7c07",
5
5
  "repository": {
6
6
  "type": "git",
7
7
  "url": "git+https://github.com/core-ds/bridge-to-native.git"