@alfalab/bridge-to-native 1.5.2-beta.feed590 → 1.6.0

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 GeoConfiguration, type HapticsOptions, type HistoryPushStateParams, type HistoryReplaceStateParams, type LocationAssignParam, type LogError, type NativeFeatureKey, type PdfType, type SheetDragArea } from './types';
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';
3
3
  /**
4
4
  * Сервис, предоставляет методы для WA, работающего внутри NA.
5
5
  */
@@ -13,13 +13,13 @@ export declare class BridgeToNative {
13
13
  * будут использованы стандартные `History: pushState()` и `History: go()`.
14
14
  * @param options.logError Функция с помощью которой B2N может залогировать ошибку,
15
15
  * если не передать, B2N не будет логировать ошибки.
16
- * @param options.isSheetWebview Признак открытия WV в шторе. Отвечает за доступность
17
- * новых методов взаимодействия с нативом. По умолчанию true.
16
+ * @param options.featureToggles Список включённых фича-тоглов, передаваемый WA.
17
+ * Без списка или без mainSuperAppIOS часть команд недоступна.
18
18
  */
19
19
  constructor(options?: {
20
20
  browserHistoryApiWrappers?: BrowserHistoryApiWrappers;
21
21
  logError?: LogError;
22
- isSheetWebview?: boolean;
22
+ featureToggles?: FSs[];
23
23
  } | undefined);
24
24
  private nativeParamsService;
25
25
  private externalLinksService;
@@ -261,13 +261,12 @@ export declare class BridgeToNative {
261
261
  * Воспроизводит тактильный отклик.
262
262
  * Работает только на iOS в версиях `17.0.0` и выше.
263
263
  *
264
- * @param isFTEnabled Значение фича-тогла webViewHapticsIOS;
265
- * при false команда не отправляется.
264
+ * Требует mainSuperAppIOS и webViewHapticsIOS в списке featureToggles.
266
265
  * @param options.type Тип тактильного отклика.
267
266
  * @param options.intensity Интенсивность от 0 до 1, применяется только
268
267
  * к impact-типам. Если не передана, NA использует значение по умолчанию.
269
268
  */
270
- vibrate(options: HapticsOptions, isFTEnabled: boolean): void;
269
+ vibrate(options: HapticsOptions): void;
271
270
  /**
272
271
  * Задаёт область нативной шторы, за которую можно её перетаскивать.
273
272
  * Работает только на iOS в версиях `17.0.0` и выше.
@@ -18,16 +18,16 @@ class BridgeToNative {
18
18
  * будут использованы стандартные `History: pushState()` и `History: go()`.
19
19
  * @param options.logError Функция с помощью которой B2N может залогировать ошибку,
20
20
  * если не передать, B2N не будет логировать ошибки.
21
- * @param options.isSheetWebview Признак открытия WV в шторе. Отвечает за доступность
22
- * новых методов взаимодействия с нативом. По умолчанию true.
21
+ * @param options.featureToggles Список включённых фича-тоглов, передаваемый WA.
22
+ * Без списка или без mainSuperAppIOS часть команд недоступна.
23
23
  */
24
24
  constructor(options) {
25
- var _a, _b, _c, _d, _e, _f, _g;
25
+ var _a, _b, _c, _d, _e, _f;
26
26
  this.options = options;
27
27
  this.nativeParamsService = new native_params_service_1.NativeParamsService((_a = this.options) === null || _a === void 0 ? void 0 : _a.logError);
28
28
  this.externalLinksService = new external_links_service_1.ExternalLinksService(this.nativeParamsService, (_b = this.options) === null || _b === void 0 ? void 0 : _b.logError);
29
29
  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, (_g = (_f = this.options) === null || _f === void 0 ? void 0 : _f.isSheetWebview) !== null && _g !== void 0 ? _g : true);
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);
31
31
  }
32
32
  /**
33
33
  * Схема NA.
@@ -318,14 +318,13 @@ class BridgeToNative {
318
318
  * Воспроизводит тактильный отклик.
319
319
  * Работает только на iOS в версиях `17.0.0` и выше.
320
320
  *
321
- * @param isFTEnabled Значение фича-тогла webViewHapticsIOS;
322
- * при false команда не отправляется.
321
+ * Требует mainSuperAppIOS и webViewHapticsIOS в списке featureToggles.
323
322
  * @param options.type Тип тактильного отклика.
324
323
  * @param options.intensity Интенсивность от 0 до 1, применяется только
325
324
  * к impact-типам. Если не передана, NA использует значение по умолчанию.
326
325
  */
327
- vibrate(options, isFTEnabled) {
328
- this.nativeCommandsService.vibrate(options, isFTEnabled);
326
+ vibrate(options) {
327
+ this.nativeCommandsService.vibrate(options);
329
328
  }
330
329
  /**
331
330
  * Задаёт область нативной шторы, за которую можно её перетаскивать.
@@ -1,4 +1,4 @@
1
- import { type GeoConfiguration, type HapticsOptions, type LogError, type SheetDragArea } from '../types';
1
+ import { type FSs, 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,11 +9,11 @@ import { type NativeParamsService } from './native-params-service';
9
9
  */
10
10
  export declare class NativeCommandsService {
11
11
  private nativeParamsService;
12
- private isSheetWebview;
13
- constructor(nativeParamsService: NativeParamsService, logError?: LogError, isSheetWebview?: boolean);
12
+ private featureToggles?;
13
+ constructor(nativeParamsService: NativeParamsService, logError?: LogError, featureToggles?: FSs[] | undefined);
14
14
  private modernBridgeService;
15
15
  getGeoConfiguration(): Promise<GeoConfiguration>;
16
- vibrate({ type, intensity }: HapticsOptions, isFTEnabled: boolean): void;
16
+ vibrate({ type, intensity }: HapticsOptions): void;
17
17
  setSheetDragArea(area: SheetDragArea): void;
18
18
  hideTabbar(): void;
19
19
  showTabbar(): void;
@@ -11,9 +11,9 @@ const native_features_1 = require("./native-features");
11
11
  * данные для вызовов через {@link ModernBridgeService}.
12
12
  */
13
13
  class NativeCommandsService {
14
- constructor(nativeParamsService, logError, isSheetWebview = true) {
14
+ constructor(nativeParamsService, logError, featureToggles) {
15
15
  this.nativeParamsService = nativeParamsService;
16
- this.isSheetWebview = isSheetWebview;
16
+ this.featureToggles = featureToggles;
17
17
  this.modernBridgeService = new modern_bridge_service_1.ModernBridgeService(logError);
18
18
  }
19
19
  getGeoConfiguration() {
@@ -22,8 +22,10 @@ class NativeCommandsService {
22
22
  }
23
23
  return this.modernBridgeService.call('geo.configuration', {});
24
24
  }
25
- vibrate({ type, intensity }, isFTEnabled) {
26
- if (!isFTEnabled || !this.isAvailable('haptics.vibrate')) {
25
+ vibrate({ type, intensity }) {
26
+ var _a;
27
+ if (((_a = this.featureToggles) !== null && _a !== void 0 ? _a : []).indexOf('webViewHapticsIOS') === -1 ||
28
+ !this.isAvailable('haptics.vibrate')) {
27
29
  return;
28
30
  }
29
31
  this.modernBridgeService.send('haptics.vibrate', Object.assign({ type }, (intensity === undefined ? {} : { intensity })));
@@ -47,7 +49,8 @@ class NativeCommandsService {
47
49
  this.modernBridgeService.send('tabbar.show', {});
48
50
  }
49
51
  isAvailable(action) {
50
- return (this.isSheetWebview &&
52
+ var _a;
53
+ return (((_a = this.featureToggles) !== null && _a !== void 0 ? _a : []).indexOf('mainSuperAppIOS') !== -1 &&
51
54
  (0, native_features_1.canUseNativeCommand)(this.nativeParamsService.environment, this.nativeParamsService.appVersion, action));
52
55
  }
53
56
  }
package/client/types.d.ts CHANGED
@@ -45,4 +45,5 @@ export type CallbackPayload = {
45
45
  message: string;
46
46
  } | null;
47
47
  };
48
+ export type FSs = 'mainSuperAppIOS' | 'webViewHapticsIOS';
48
49
  export {};
package/package.json CHANGED
@@ -1,132 +1,132 @@
1
1
  {
2
- "name": "@alfalab/bridge-to-native",
3
- "version": "1.5.2-beta.feed590",
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"
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"
19
9
  },
20
- "./client/primitives": {
21
- "import": "./client/primitives.js",
22
- "require": "./client/primitives.js",
23
- "types": "./client/primitives.d.ts"
10
+ "repository": {
11
+ "type": "git",
12
+ "url": "git+https://github.com/core-ds/bridge-to-native.git"
24
13
  },
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
- }
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"
71
48
  },
72
- "parserOptions": {
73
- "project": [
74
- "./__tests__/tsconfig.json",
75
- "./src/client/tsconfig.json",
76
- "./src/server/tsconfig.json"
77
- ]
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
+ ]
78
89
  },
79
- "overrides": [
80
- {
81
- "files": [
82
- "__tests__/**/*"
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
+ }
83
106
  ],
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/"
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"
97
118
  ]
98
- },
99
- {
100
- "displayName": "server-tests",
101
- "testEnvironment": "node",
102
- "testPathIgnorePatterns": [
103
- "/__tests__/client/"
119
+ },
120
+ "prettier": "arui-presets-lint/prettier",
121
+ "stylelint": {
122
+ "extends": "arui-presets-lint/stylelint",
123
+ "ignoreFiles": [
124
+ "coverage/**/*.js",
125
+ ".yarn/releases/*"
104
126
  ]
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"
127
+ },
128
+ "publishConfig": {
129
+ "registry": "https://registry.npmjs.org"
130
+ },
131
+ "packageManager": "yarn@4.12.0"
132
132
  }