@alfalab/bridge-to-native 1.6.0 → 1.6.1-beta.9c312f5

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.
@@ -1,5 +1,5 @@
1
1
 
2
- import { type BrowserHistoryApiWrappers, type FSs, type GeoConfiguration, type HapticsOptions, type HistoryPushStateParams, type HistoryReplaceStateParams, type LocationAssignParam, type LogError, type NativeFeatureKey, type PdfType, type SheetDragArea } from './types';
2
+ import { type BrowserHistoryApiWrappers, type GeoConfiguration, type HapticsOptions, type HistoryPushStateParams, type HistoryReplaceStateParams, type LocationAssignParam, type LogError, type NativeFeatureKey, type PdfType, type SheetDragArea } from './types';
3
3
  /**
4
4
  * Сервис, предоставляет методы для WA, работающего внутри NA.
5
5
  */
@@ -13,13 +13,10 @@ export declare class BridgeToNative {
13
13
  * будут использованы стандартные `History: pushState()` и `History: go()`.
14
14
  * @param options.logError Функция с помощью которой B2N может залогировать ошибку,
15
15
  * если не передать, B2N не будет логировать ошибки.
16
- * @param options.featureToggles Список включённых фича-тоглов, передаваемый WA.
17
- * Без списка или без mainSuperAppIOS часть команд недоступна.
18
16
  */
19
17
  constructor(options?: {
20
18
  browserHistoryApiWrappers?: BrowserHistoryApiWrappers;
21
19
  logError?: LogError;
22
- featureToggles?: FSs[];
23
20
  } | undefined);
24
21
  private nativeParamsService;
25
22
  private externalLinksService;
@@ -261,7 +258,7 @@ export declare class BridgeToNative {
261
258
  * Воспроизводит тактильный отклик.
262
259
  * Работает только на iOS в версиях `17.0.0` и выше.
263
260
  *
264
- * Требует mainSuperAppIOS и webViewHapticsIOS в списке featureToggles.
261
+ * Требует включённых нативных фича-тоглов mainSuperAppIOS и webViewHapticsIOS.
265
262
  * @param options.type Тип тактильного отклика.
266
263
  * @param options.intensity Интенсивность от 0 до 1, применяется только
267
264
  * к impact-типам. Если не передана, NA использует значение по умолчанию.
@@ -18,16 +18,14 @@ class BridgeToNative {
18
18
  * будут использованы стандартные `History: pushState()` и `History: go()`.
19
19
  * @param options.logError Функция с помощью которой B2N может залогировать ошибку,
20
20
  * если не передать, B2N не будет логировать ошибки.
21
- * @param options.featureToggles Список включённых фича-тоглов, передаваемый WA.
22
- * Без списка или без mainSuperAppIOS часть команд недоступна.
23
21
  */
24
22
  constructor(options) {
25
- var _a, _b, _c, _d, _e, _f;
23
+ var _a, _b, _c, _d, _e;
26
24
  this.options = options;
27
25
  this.nativeParamsService = new native_params_service_1.NativeParamsService((_a = this.options) === null || _a === void 0 ? void 0 : _a.logError);
28
26
  this.externalLinksService = new external_links_service_1.ExternalLinksService(this.nativeParamsService, (_b = this.options) === null || _b === void 0 ? void 0 : _b.logError);
29
27
  this.nativeNavigationAndTitleService = new native_navigation_and_title_service_1.NativeNavigationAndTitleService(this.nativeParamsService, (_c = this.options) === null || _c === void 0 ? void 0 : _c.browserHistoryApiWrappers, (_d = this.options) === null || _d === void 0 ? void 0 : _d.logError);
30
- this.nativeCommandsService = new native_commands_service_1.NativeCommandsService(this.nativeParamsService, (_e = this.options) === null || _e === void 0 ? void 0 : _e.logError, (_f = this.options) === null || _f === void 0 ? void 0 : _f.featureToggles);
28
+ this.nativeCommandsService = new native_commands_service_1.NativeCommandsService(this.nativeParamsService, (_e = this.options) === null || _e === void 0 ? void 0 : _e.logError);
31
29
  }
32
30
  /**
33
31
  * Схема NA.
@@ -318,7 +316,7 @@ class BridgeToNative {
318
316
  * Воспроизводит тактильный отклик.
319
317
  * Работает только на iOS в версиях `17.0.0` и выше.
320
318
  *
321
- * Требует mainSuperAppIOS и webViewHapticsIOS в списке featureToggles.
319
+ * Требует включённых нативных фича-тоглов mainSuperAppIOS и webViewHapticsIOS.
322
320
  * @param options.type Тип тактильного отклика.
323
321
  * @param options.intensity Интенсивность от 0 до 1, применяется только
324
322
  * к impact-типам. Если не передана, NA использует значение по умолчанию.
@@ -1,4 +1,4 @@
1
- import { type FSs, type GeoConfiguration, type HapticsOptions, type LogError, type SheetDragArea } from '../types';
1
+ import { type GeoConfiguration, type HapticsOptions, type LogError, type SheetDragArea } from '../types';
2
2
  import { type NativeParamsService } from './native-params-service';
3
3
  /**
4
4
  * Сервис команд для взаимодействия WA с NA (iOS, NA ≥ 17.0.0):
@@ -9,8 +9,7 @@ import { type NativeParamsService } from './native-params-service';
9
9
  */
10
10
  export declare class NativeCommandsService {
11
11
  private nativeParamsService;
12
- private featureToggles?;
13
- constructor(nativeParamsService: NativeParamsService, logError?: LogError, featureToggles?: FSs[] | undefined);
12
+ constructor(nativeParamsService: NativeParamsService, logError?: LogError);
14
13
  private modernBridgeService;
15
14
  getGeoConfiguration(): Promise<GeoConfiguration>;
16
15
  vibrate({ type, intensity }: HapticsOptions): void;
@@ -11,9 +11,8 @@ const native_features_1 = require("./native-features");
11
11
  * данные для вызовов через {@link ModernBridgeService}.
12
12
  */
13
13
  class NativeCommandsService {
14
- constructor(nativeParamsService, logError, featureToggles) {
14
+ constructor(nativeParamsService, logError) {
15
15
  this.nativeParamsService = nativeParamsService;
16
- this.featureToggles = featureToggles;
17
16
  this.modernBridgeService = new modern_bridge_service_1.ModernBridgeService(logError);
18
17
  }
19
18
  getGeoConfiguration() {
@@ -23,9 +22,7 @@ class NativeCommandsService {
23
22
  return this.modernBridgeService.call('geo.configuration', {});
24
23
  }
25
24
  vibrate({ type, intensity }) {
26
- var _a;
27
- if (((_a = this.featureToggles) !== null && _a !== void 0 ? _a : []).indexOf('webViewHapticsIOS') === -1 ||
28
- !this.isAvailable('haptics.vibrate')) {
25
+ if (!this.isAvailable('haptics.vibrate')) {
29
26
  return;
30
27
  }
31
28
  this.modernBridgeService.send('haptics.vibrate', Object.assign({ type }, (intensity === undefined ? {} : { intensity })));
@@ -49,9 +46,13 @@ class NativeCommandsService {
49
46
  this.modernBridgeService.send('tabbar.show', {});
50
47
  }
51
48
  isAvailable(action) {
52
- var _a;
53
- return (((_a = this.featureToggles) !== null && _a !== void 0 ? _a : []).indexOf('mainSuperAppIOS') !== -1 &&
54
- (0, native_features_1.canUseNativeCommand)(this.nativeParamsService.environment, this.nativeParamsService.appVersion, action));
49
+ const { environment, appVersion } = this.nativeParamsService;
50
+ const available = (0, native_features_1.canUseNativeCommand)(environment, appVersion, action);
51
+ if (!available) {
52
+ // eslint-disable-next-line no-console -- предупреждаем о неподдерживаемом окружении.
53
+ console.warn(`NativeCommandsService: "${action}" requires iOS and NA version 17.0.0 or later; current platform: ${environment}, version: ${appVersion}`);
54
+ }
55
+ return available;
55
56
  }
56
57
  }
57
58
  exports.NativeCommandsService = NativeCommandsService;
@@ -15,7 +15,7 @@ function appendFromCurrentQueryParamForIos(nativeUrl) {
15
15
  const query = nativeUrl.slice(qIndex + 1);
16
16
  const params = new URLSearchParams(query);
17
17
  params.set(QUERY_FROM_CURRENT_KEY, QUERY_FROM_CURRENT_VALUE);
18
- return `${base}?${params.toString()}`;
18
+ return `${base}?${params.toString().replace(/\+/g, '%20')}`;
19
19
  }
20
20
  const closeWebviewUtil = () => {
21
21
  const originalPageUrl = new URL(window.location.href);
package/client/types.d.ts CHANGED
@@ -45,5 +45,4 @@ export type CallbackPayload = {
45
45
  message: string;
46
46
  } | null;
47
47
  };
48
- export type FSs = 'mainSuperAppIOS' | 'webViewHapticsIOS';
49
48
  export {};
package/package.json CHANGED
@@ -1,132 +1,132 @@
1
1
  {
2
- "name": "@alfalab/bridge-to-native",
3
- "version": "1.6.0",
4
- "license": "MIT",
5
- "description": "Утилита для удобной работы веб приложения внутри нативного приложения и коммуникации с ним.",
6
- "engines": {
7
- "node": ">=20.19.2",
8
- "npm": "please-use-yarn"
2
+ "name": "@alfalab/bridge-to-native",
3
+ "version": "1.6.1-beta.9c312f5",
4
+ "license": "MIT",
5
+ "description": "Утилита для удобной работы веб приложения внутри нативного приложения и коммуникации с ним.",
6
+ "engines": {
7
+ "node": ">=20.19.2",
8
+ "npm": "please-use-yarn"
9
+ },
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/core-ds/bridge-to-native.git"
13
+ },
14
+ "exports": {
15
+ "./client": {
16
+ "import": "./client/index.js",
17
+ "require": "./client/index.js",
18
+ "types": "./client/index.d.ts"
9
19
  },
10
- "repository": {
11
- "type": "git",
12
- "url": "git+https://github.com/core-ds/bridge-to-native.git"
20
+ "./client/primitives": {
21
+ "import": "./client/primitives.js",
22
+ "require": "./client/primitives.js",
23
+ "types": "./client/primitives.d.ts"
13
24
  },
14
- "exports": {
15
- "./client": {
16
- "import": "./client/index.js",
17
- "require": "./client/index.js",
18
- "types": "./client/index.d.ts"
19
- },
20
- "./client/primitives": {
21
- "import": "./client/primitives.js",
22
- "require": "./client/primitives.js",
23
- "types": "./client/primitives.d.ts"
24
- },
25
- "./server": {
26
- "import": "./server/index.js",
27
- "require": "./server/index.js",
28
- "types": "./server/index.d.ts"
29
- }
30
- },
31
- "sideEffects": false,
32
- "bugs": {
33
- "url": "https://github.com/core-ds/bridge-to-native/issues"
34
- },
35
- "scripts": {
36
- "build": "yarn build:clean && yarn build:ts",
37
- "build:clean": "shx rm -rf .publish",
38
- "build:copy-package-json": "shx cp package.json .publish/package.json",
39
- "build:ts": "tsc --build",
40
- "format": "arui-presets-lint format",
41
- "format:check": "arui-presets-lint format:check",
42
- "lint": "yarn lint:scripts && yarn format:check",
43
- "lint:fix": "yarn lint:scripts --fix && yarn format",
44
- "lint:scripts": "arui-presets-lint scripts",
45
- "pub": "npm publish .publish --userconfig \"../.npmrc\" --tag \"$TAG\"",
46
- "release": "yarn build && yarn build:copy-package-json && yarn pub",
47
- "test": "arui-scripts test --silent --collect-coverage"
25
+ "./server": {
26
+ "import": "./server/index.js",
27
+ "require": "./server/index.js",
28
+ "types": "./server/index.d.ts"
29
+ }
30
+ },
31
+ "sideEffects": false,
32
+ "bugs": {
33
+ "url": "https://github.com/core-ds/bridge-to-native/issues"
34
+ },
35
+ "scripts": {
36
+ "build": "yarn build:clean && yarn build:ts",
37
+ "build:clean": "shx rm -rf .publish",
38
+ "build:copy-package-json": "shx cp package.json .publish/package.json",
39
+ "build:ts": "tsc --build",
40
+ "format": "arui-presets-lint format",
41
+ "format:check": "arui-presets-lint format:check",
42
+ "lint": "yarn lint:scripts && yarn format:check",
43
+ "lint:fix": "yarn lint:scripts --fix && yarn format",
44
+ "lint:scripts": "arui-presets-lint scripts",
45
+ "pub": "npm publish .publish --userconfig \"../.npmrc\" --tag \"$TAG\"",
46
+ "release": "yarn build && yarn build:copy-package-json && yarn pub",
47
+ "test": "arui-scripts test --silent --collect-coverage"
48
+ },
49
+ "devDependencies": {
50
+ "@happy-dom/jest-environment": "18.0.1",
51
+ "@types/jest": "29.5.14",
52
+ "@types/node": "20.19.1",
53
+ "arui-presets-lint": "8.7.0",
54
+ "arui-scripts": "19.0.7",
55
+ "copyfiles": "2.4.1",
56
+ "jest-junit": "10.0.0",
57
+ "lint-staged": "^12.5.0",
58
+ "promisify-child-process": "4.1.1",
59
+ "shx": "0.3.4",
60
+ "typescript": "5.5.4"
61
+ },
62
+ "commitlint": {
63
+ "extends": "./node_modules/arui-presets-lint/commitlint"
64
+ },
65
+ "eslintConfig": {
66
+ "extends": "./node_modules/arui-presets-lint/eslint",
67
+ "settings": {
68
+ "react": {
69
+ "version": "18.0.0"
70
+ }
48
71
  },
49
- "devDependencies": {
50
- "@happy-dom/jest-environment": "18.0.1",
51
- "@types/jest": "29.5.14",
52
- "@types/node": "20.19.1",
53
- "arui-presets-lint": "8.7.0",
54
- "arui-scripts": "19.0.7",
55
- "copyfiles": "2.4.1",
56
- "jest-junit": "10.0.0",
57
- "lint-staged": "^12.5.0",
58
- "promisify-child-process": "4.1.1",
59
- "shx": "0.3.4",
60
- "typescript": "5.5.4"
61
- },
62
- "commitlint": {
63
- "extends": "./node_modules/arui-presets-lint/commitlint"
64
- },
65
- "eslintConfig": {
66
- "extends": "./node_modules/arui-presets-lint/eslint",
67
- "settings": {
68
- "react": {
69
- "version": "18.0.0"
70
- }
71
- },
72
- "parserOptions": {
73
- "project": [
74
- "./__tests__/tsconfig.json",
75
- "./src/client/tsconfig.json",
76
- "./src/server/tsconfig.json"
77
- ]
78
- },
79
- "overrides": [
80
- {
81
- "files": [
82
- "__tests__/**/*"
83
- ],
84
- "rules": {
85
- "max-lines": "off"
86
- }
87
- }
88
- ]
72
+ "parserOptions": {
73
+ "project": [
74
+ "./__tests__/tsconfig.json",
75
+ "./src/client/tsconfig.json",
76
+ "./src/server/tsconfig.json"
77
+ ]
89
78
  },
90
- "jest": {
91
- "projects": [
92
- {
93
- "displayName": "client-tests",
94
- "testEnvironment": "@happy-dom/jest-environment",
95
- "testPathIgnorePatterns": [
96
- "/__tests__/server/"
97
- ]
98
- },
99
- {
100
- "displayName": "server-tests",
101
- "testEnvironment": "node",
102
- "testPathIgnorePatterns": [
103
- "/__tests__/client/"
104
- ]
105
- }
79
+ "overrides": [
80
+ {
81
+ "files": [
82
+ "__tests__/**/*"
106
83
  ],
107
- "testRegex": [
108
- "__tests__/.*\\.test\\.ts"
109
- ],
110
- "coveragePathIgnorePatterns": [
111
- "/node_modules/",
112
- "/src/(client|server)/index.ts",
113
- "/src/client/primitives.ts"
114
- ],
115
- "reporters": [
116
- "default",
117
- "jest-junit"
84
+ "rules": {
85
+ "max-lines": "off"
86
+ }
87
+ }
88
+ ]
89
+ },
90
+ "jest": {
91
+ "projects": [
92
+ {
93
+ "displayName": "client-tests",
94
+ "testEnvironment": "@happy-dom/jest-environment",
95
+ "testPathIgnorePatterns": [
96
+ "/__tests__/server/"
118
97
  ]
119
- },
120
- "prettier": "arui-presets-lint/prettier",
121
- "stylelint": {
122
- "extends": "arui-presets-lint/stylelint",
123
- "ignoreFiles": [
124
- "coverage/**/*.js",
125
- ".yarn/releases/*"
98
+ },
99
+ {
100
+ "displayName": "server-tests",
101
+ "testEnvironment": "node",
102
+ "testPathIgnorePatterns": [
103
+ "/__tests__/client/"
126
104
  ]
127
- },
128
- "publishConfig": {
129
- "registry": "https://registry.npmjs.org"
130
- },
131
- "packageManager": "yarn@4.12.0"
105
+ }
106
+ ],
107
+ "testRegex": [
108
+ "__tests__/.*\\.test\\.ts"
109
+ ],
110
+ "coveragePathIgnorePatterns": [
111
+ "/node_modules/",
112
+ "/src/(client|server)/index.ts",
113
+ "/src/client/primitives.ts"
114
+ ],
115
+ "reporters": [
116
+ "default",
117
+ "jest-junit"
118
+ ]
119
+ },
120
+ "prettier": "arui-presets-lint/prettier",
121
+ "stylelint": {
122
+ "extends": "arui-presets-lint/stylelint",
123
+ "ignoreFiles": [
124
+ "coverage/**/*.js",
125
+ ".yarn/releases/*"
126
+ ]
127
+ },
128
+ "publishConfig": {
129
+ "registry": "https://registry.npmjs.org"
130
+ },
131
+ "packageManager": "yarn@4.12.0"
132
132
  }