Skip to content

Commit 68c85cf

Browse files
committed
chore!: Export yandexProtobuf was devided into 2 abstract classes
1 parent 5c423fa commit 68c85cf

File tree

2 files changed

+42
-27
lines changed

2 files changed

+42
-27
lines changed

packages/core/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
export { yandexProtobuf } from "./protobuf";
1+
export { YandexVOTProtobuf, YandexSessionProtobuf } from "./protobuf";
22

3-
export { default, VOTWorkerClient } from "./client";
3+
export { default, VOTWorkerClient, VOTJSError, MinimalClient } from "./client";
44
export * as videoData from "./utils/videoData";
55
export * as votUtils from "./utils/vot";
66

packages/core/src/protobuf.ts

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ import type {
2020
TranslationHelp,
2121
} from "./types/yandex";
2222

23-
// Export the encoding and decoding functions
24-
export const yandexProtobuf = {
25-
encodeTranslationRequest(
23+
export abstract class YandexVOTProtobuf {
24+
static encodeTranslationRequest(
2625
url: string,
2726
duration: number,
2827
requestLang: string,
@@ -53,11 +52,13 @@ export const yandexProtobuf = {
5352
useNewModel,
5453
videoTitle,
5554
}).finish();
56-
},
57-
decodeTranslationResponse(response: ArrayBuffer) {
55+
}
56+
57+
static decodeTranslationResponse(response: ArrayBuffer) {
5858
return VideoTranslationResponse.decode(new Uint8Array(response));
59-
},
60-
encodeTranslationAudioRequest(
59+
}
60+
61+
static encodeTranslationAudioRequest(
6162
url: string,
6263
translationId: string,
6364
audioBuffer: AudioBufferObject,
@@ -77,41 +78,55 @@ export const yandexProtobuf = {
7778
audioInfo: audioBuffer,
7879
}),
7980
}).finish();
80-
},
81-
decodeTranslationAudioResponse(response: ArrayBuffer) {
81+
}
82+
83+
static decodeTranslationAudioResponse(response: ArrayBuffer) {
8284
return VideoTranslationAudioResponse.decode(new Uint8Array(response));
83-
},
84-
encodeSubtitlesRequest(url: string, requestLang: string) {
85+
}
86+
87+
static encodeSubtitlesRequest(url: string, requestLang: string) {
8588
return SubtitlesRequest.encode({
8689
url,
8790
language: requestLang,
8891
}).finish();
89-
},
90-
decodeSubtitlesResponse(response: ArrayBuffer) {
92+
}
93+
94+
static decodeSubtitlesResponse(response: ArrayBuffer) {
9195
return SubtitlesResponse.decode(new Uint8Array(response));
92-
},
93-
encodeStreamPingRequest(pingId: number) {
96+
}
97+
98+
static encodeStreamPingRequest(pingId: number) {
9499
return StreamPingRequest.encode({
95100
pingId,
96101
}).finish();
97-
},
98-
encodeStreamRequest(url: string, requestLang: string, responseLang: string) {
102+
}
103+
104+
static encodeStreamRequest(
105+
url: string,
106+
requestLang: string,
107+
responseLang: string,
108+
) {
99109
return StreamTranslationRequest.encode({
100110
url,
101111
language: requestLang,
102112
responseLanguage: responseLang,
103113
}).finish();
104-
},
105-
decodeStreamResponse(response: ArrayBuffer) {
114+
}
115+
116+
static decodeStreamResponse(response: ArrayBuffer) {
106117
return StreamTranslationResponse.decode(new Uint8Array(response));
107-
},
108-
encodeYandexSessionRequest(uuid: string, module: SessionModule) {
118+
}
119+
}
120+
121+
export abstract class YandexSessionProtobuf {
122+
static encodeSessionRequest(uuid: string, module: SessionModule) {
109123
return YandexSessionRequest.encode({
110124
uuid,
111125
module,
112126
}).finish();
113-
},
114-
decodeYandexSessionResponse(response: ArrayBuffer) {
127+
}
128+
129+
static decodeSessionResponse(response: ArrayBuffer) {
115130
return YandexSessionResponse.decode(new Uint8Array(response));
116-
},
117-
};
131+
}
132+
}

0 commit comments

Comments
 (0)