Skip to content

Commit

Permalink
refactor(*): fix prettier local setup
Browse files Browse the repository at this point in the history
  • Loading branch information
evgen-kent committed Feb 19, 2024
1 parent b6c05eb commit a8ab79d
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 32 deletions.
1 change: 1 addition & 0 deletions src/constants.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down
47 changes: 23 additions & 24 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,17 @@ 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,
NativeFeaturesFts,
NativeParams,
WebViewWindow,
} from './types';
import {PreviousBridgeToNativeState} from './types';
import {isValidVersionFormat} from './utils';
import { PreviousBridgeToNativeState } from './types';
import { isValidVersionFormat } from './utils';

type Theme = 'light' | 'dark';

Expand All @@ -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(
Expand Down Expand Up @@ -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;
}

/**
Expand Down
6 changes: 3 additions & 3 deletions src/native-fallbacks.ts
Original file line number Diff line number Diff line change
@@ -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';

/**
* Класс содержит реализацию обходных путей для веб-фич, которые не работают в нативном-вебвью.
Expand Down
4 changes: 2 additions & 2 deletions src/utils.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {Environment} from './types';
import {ANDROID_APP_ID} from './constants';
import { Environment } from './types';
import { ANDROID_APP_ID } from './constants';

/**
* Разделяет веб ссылку на компоненты
Expand Down
7 changes: 4 additions & 3 deletions test/index.test.ts
Original file line number Diff line number Diff line change
@@ -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,
);
Expand Down

0 comments on commit a8ab79d

Please sign in to comment.