From a8ab79d0f1db932a81382622da071952bd3afefa Mon Sep 17 00:00:00 2001 From: Evgen Shmat Date: Mon, 19 Feb 2024 10:30:19 +0300 Subject: [PATCH] refactor(*): fix prettier local setup --- src/constants.ts | 1 + src/index.ts | 47 ++++++++++++++++++++--------------------- src/native-fallbacks.ts | 6 +++--- src/utils.ts | 4 ++-- test/index.test.ts | 7 +++--- 5 files changed, 33 insertions(+), 32 deletions(-) diff --git a/src/constants.ts b/src/constants.ts index 3af58c1..ca2773b 100644 --- a/src/constants.ts +++ b/src/constants.ts @@ -1,6 +1,7 @@ import { NativeFeaturesFromVersion } from './types'; export const START_VERSION_ANDROID_AM_ALLOW_OPEN_NEW_WEBVIEW = '10.35.0'; + export const ANDROID_APP_ID = 'YWxmYWJhbms='; export const CLOSE_WEBVIEW_SEARCH_KEY = 'closeWebView'; export const CLOSE_WEBVIEW_SEARCH_VALUE = 'true'; diff --git a/src/index.ts b/src/index.ts index d5127e9..eee80e1 100644 --- a/src/index.ts +++ b/src/index.ts @@ -8,8 +8,8 @@ import { START_VERSION_ANDROID_AM_ALLOW_OPEN_NEW_WEBVIEW, versionToIosAppId, } from './constants'; -import {NativeFallbacks} from './native-fallbacks'; -import {HandleRedirect, NativeNavigationAndTitle} from './native-navigation-and-title'; +import { NativeFallbacks } from './native-fallbacks'; +import { HandleRedirect, NativeNavigationAndTitle } from './native-navigation-and-title'; import type { Environment, NativeFeatureKey, @@ -17,8 +17,8 @@ import type { NativeParams, WebViewWindow, } from './types'; -import {PreviousBridgeToNativeState} from './types'; -import {isValidVersionFormat} from './utils'; +import { PreviousBridgeToNativeState } from './types'; +import { isValidVersionFormat } from './utils'; type Theme = 'light' | 'dark'; @@ -35,19 +35,6 @@ export class BridgeToNative { public readonly nativeFallbacks: NativeFallbacks; private nextPageId: number | null; - - private _nativeNavigationAndTitle: NativeNavigationAndTitle; - - private _originalWebviewParams: string; - - // В формате `x.x.x`. - private _appVersion: string; - - // Необходимо для формирования диплинка. - private _iosAppId?: string; - - private _theme: Theme; - private _handleRedirect: HandleRedirect; constructor( @@ -86,24 +73,36 @@ export class BridgeToNative { this.nativeFallbacks = new NativeFallbacks(this); } - get theme() { - return this._theme; + private _nativeNavigationAndTitle: NativeNavigationAndTitle; + + get nativeNavigationAndTitle() { + return this._nativeNavigationAndTitle; } + private _originalWebviewParams: string; + + get originalWebviewParams() { + return this._originalWebviewParams; + } + + // В формате `x.x.x`. + private _appVersion: string; + get appVersion() { return this._appVersion; } + // Необходимо для формирования диплинка. + private _iosAppId?: string; + get iosAppId() { return this._iosAppId; } - get nativeNavigationAndTitle() { - return this._nativeNavigationAndTitle; - } + private _theme: Theme; - get originalWebviewParams() { - return this._originalWebviewParams; + get theme() { + return this._theme; } /** diff --git a/src/native-fallbacks.ts b/src/native-fallbacks.ts index 9ec2d1d..dfb7900 100644 --- a/src/native-fallbacks.ts +++ b/src/native-fallbacks.ts @@ -1,7 +1,7 @@ -import type {BridgeToNative} from '.'; -import {ExternalNavigationOptions, PdfType} from './types'; +import type { BridgeToNative } from '.'; +import { ExternalNavigationOptions, PdfType } from './types'; -import {getAppId, getUrlInstance} from './utils'; +import { getAppId, getUrlInstance } from './utils'; /** * Класс содержит реализацию обходных путей для веб-фич, которые не работают в нативном-вебвью. diff --git a/src/utils.ts b/src/utils.ts index 963f559..6da2c19 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,5 +1,5 @@ -import {Environment} from './types'; -import {ANDROID_APP_ID} from './constants'; +import { Environment } from './types'; +import { ANDROID_APP_ID } from './constants'; /** * Разделяет веб ссылку на компоненты diff --git a/test/index.test.ts b/test/index.test.ts index 25263df..f685525 100644 --- a/test/index.test.ts +++ b/test/index.test.ts @@ -1,18 +1,19 @@ /* eslint-disable @typescript-eslint/dot-notation -- отключено, чтобы можно было обращаться к приватным полям для их тестирования */ -import {BridgeToNative} from '../src'; +import { BridgeToNative } from '../src'; import { PREVIOUS_B2N_STATE_STORAGE_KEY, START_VERSION_ANDROID_AM_ALLOW_OPEN_NEW_WEBVIEW, } from '../src/constants'; -import {mockSessionStorage} from '../src/mock/mock-session-storage'; +import { mockSessionStorage } from '../src/mock/mock-session-storage'; -import {WebViewWindow} from '../src/types'; +import { WebViewWindow } from '../src/types'; const mockedNativeFallbacksInstance = {}; const mockedNativeNavigationAndTitleInstance = { saveCurrentState: jest.fn(), }; + const MockedNativeNavigationAndTitleConstructor = jest.fn( () => mockedNativeNavigationAndTitleInstance, );