Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "Translate" method typings #409

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions packages/core/src/bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export const DESKTOP_METHODS = [
'VKWebAppScrollTopStart',
'VKWebAppScrollTopStop',
'VKWebAppShowSlidesSheet',
'VKWebAppTranslate',

// Desktop web specific events
...(IS_DESKTOP_VK
Expand Down
19 changes: 18 additions & 1 deletion packages/core/src/types/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,20 @@ export type ShowSlidesSheetRequest = {
slides: ActionSheetSlide[];
};

type TranslationLanguage = 'ru' | 'en' | 'es' | 'pt' | string;

export type TranslateResponse = {
result: {
texts: string[];
source_lang: TranslationLanguage;
};
};

export type TranslateRequest = {
texts: string[];
translation_language: TranslationLanguage;
};

export enum EGrantedPermission {
CAMERA = 'camera',
LOCATION = 'location',
Expand Down Expand Up @@ -1132,6 +1146,7 @@ export type RequestPropsMap = {
VKWebAppScrollTopStart: {};
VKWebAppScrollTopStop: {};
VKWebAppShowSlidesSheet: ShowSlidesSheetRequest;
VKWebAppTranslate: TranslateRequest;
};

/**
Expand Down Expand Up @@ -1245,6 +1260,7 @@ export type ReceiveDataMap = {
VKWebAppScrollTopStart: { result: true };
VKWebAppScrollTopStop: { result: true };
VKWebAppShowSlidesSheet: ShowSlidesSheetResponse;
VKWebAppTranslate: TranslateResponse;
};
/* eslint-enable @typescript-eslint/ban-types */

Expand Down Expand Up @@ -1607,4 +1623,5 @@ export type ReceiveEventMap = EventReceiveNames<
'VKWebAppShowSlidesSheet',
'VKWebAppShowSlidesSheetResult',
'VKWebAppShowSlidesSheetFailed'
>;
> &
EventReceiveNames<'VKWebAppTranslate', 'VKWebAppTranslateResult', 'VKWebAppTranslateFailed'>;