@vkontakte/videoplayer 1.1.95 → 1.1.96-beta.1

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.
Files changed (44) hide show
  1. package/es2015.cjs +10 -10
  2. package/es2015.esm.js +11 -11
  3. package/esnext.cjs +10 -10
  4. package/esnext.esm.js +11 -11
  5. package/evergreen.esm.js +11 -11
  6. package/package.json +5 -5
  7. package/types/VKVideoPlayer/index.svelte.d.ts +8 -1
  8. package/types/components/Ads/admanWrapper.d.ts +2 -1
  9. package/types/components/Ads/types.d.ts +1 -1
  10. package/types/components/Menus/subMenuTabs/types.d.ts +7 -0
  11. package/types/components/Menus/utils/getSubMenusStack.svelte.d.ts +1 -0
  12. package/types/config.d.ts +14 -3
  13. package/types/index.d.ts +3 -3
  14. package/types/store/composition.d.ts +10 -1
  15. package/types/store/connectors/statisticsConnector.d.ts +15 -0
  16. package/types/store/index.d.ts +1 -1
  17. package/types/store/modules/highlightedMenuItemsStore/highlightedMenuItems.module.d.ts +3 -0
  18. package/types/store/modules/highlightedMenuItemsStore/highlightedMenuItems.store.d.ts +21 -0
  19. package/types/store/modules/highlightedMenuItemsStore/highlightedMenuItems.token.d.ts +5 -0
  20. package/types/store/modules/highlightedMenuItemsStore/index.d.ts +3 -0
  21. package/types/store/modules/index.d.ts +10 -1
  22. package/types/store/modules/infrastructure/index.d.ts +1 -1
  23. package/types/store/modules/infrastructure/infrastructure.module.d.ts +6 -1
  24. package/types/store/modules/infrastructure/infrastructure.token.d.ts +5 -1
  25. package/types/store/modules/languageStore/index.d.ts +9 -0
  26. package/types/store/modules/languageStore/languageStore.module.d.ts +3 -0
  27. package/types/store/modules/languageStore/languageStore.store.d.ts +51 -0
  28. package/types/store/modules/languageStore/languageStore.token.d.ts +6 -0
  29. package/types/store/modules/playbackRateStore/index.d.ts +6 -0
  30. package/types/store/modules/playbackRateStore/playbackRateStore.module.d.ts +8 -0
  31. package/types/store/modules/playbackRateStore/playbackRateStore.store.d.ts +61 -0
  32. package/types/store/modules/playbackRateStore/playbackRateStore.token.d.ts +6 -0
  33. package/types/store/modules/qualityStore/index.d.ts +6 -0
  34. package/types/store/modules/qualityStore/qualityStore.module.d.ts +8 -0
  35. package/types/store/modules/qualityStore/qualityStore.store.d.ts +37 -0
  36. package/types/store/modules/qualityStore/qualityStore.token.d.ts +6 -0
  37. package/types/store/modules/subtitlesStore/index.d.ts +9 -0
  38. package/types/store/modules/subtitlesStore/subtitlesStore.module.d.ts +8 -0
  39. package/types/store/modules/subtitlesStore/subtitlesStore.store.d.ts +130 -0
  40. package/types/store/modules/subtitlesStore/subtitlesStore.token.d.ts +6 -0
  41. package/types/store/types.d.ts +15 -9
  42. package/types/translation/types.d.ts +1 -0
  43. package/types/types/index.d.ts +1 -4
  44. package/types/utils/sanitizeSvg.d.ts +5 -0
@@ -0,0 +1,130 @@
1
+ /**
2
+ * Subtitles Store Module
3
+ *
4
+ * Управляет состоянием субтитров: выбор, отображение, скачивание и парсинг.
5
+ */
6
+ import type { Readable, Writable } from "svelte/store";
7
+ import type { IPlayer, ITextTrack } from "@vkontakte/videoplayer-core";
8
+ import type { ISubscription, ITracer } from "@vkontakte/videoplayer-shared";
9
+ import type { AppTracer } from "@vkontakte/videoplayer-shared";
10
+ import { Subject } from "@vkontakte/videoplayer-shared";
11
+ import type { VideoSubtitle, VideoSubtitleParsed, AvailableVideoSubtitle } from "../../../types";
12
+ import type { IUIConfig } from "../../../config";
13
+ import type { TSignature } from "../../../translation/types";
14
+ /**
15
+ * Зависимости модуля subtitles
16
+ */
17
+ export interface Deps {
18
+ /** Плеер */
19
+ player: IPlayer;
20
+ /** UI конфиг */
21
+ uiConfig: IUIConfig;
22
+ /** Подписки */
23
+ subscription: ISubscription;
24
+ /** Функция перевода */
25
+ t: TSignature;
26
+ /** Стор языка интерфейса */
27
+ interfaceLanguage$: Readable<string>;
28
+ /** Стор точной позиции */
29
+ positionExact$: Readable<number>;
30
+ /** Стор скорости воспроизведения */
31
+ currentPlaybackRate$: Readable<number>;
32
+ /** Стор playing состояния */
33
+ isPlaying$: Readable<boolean>;
34
+ /** Стор minimal view */
35
+ isMinimalView$: Readable<boolean>;
36
+ /** Стор video id */
37
+ videoId$: Writable<number | undefined>;
38
+ /** Видео элемент */
39
+ getVideoElement: () => HTMLVideoElement | null;
40
+ /** Колбэки */
41
+ callbacks: {
42
+ onSubtitleOn?: (lang: string, id: string) => void;
43
+ onSubtitleOff?: () => void;
44
+ onAvailableSubtitlesChanged?: (subtitles: AvailableVideoSubtitle[]) => void;
45
+ };
46
+ /** Функция для получения сервиса статистики */
47
+ getStatisticsService?: () => {
48
+ oneStat?: {
49
+ logError: (params: {
50
+ errorType: string;
51
+ fatal: boolean;
52
+ }) => void;
53
+ };
54
+ } | undefined;
55
+ /** Функция для получения AppTracer для error reporting */
56
+ getAppTracer?: () => AppTracer | undefined;
57
+ /** Tracer для логирования */
58
+ tracer: ITracer;
59
+ }
60
+ /**
61
+ * Состояние модуля subtitles
62
+ */
63
+ export interface SubtitlesStoreState {
64
+ /** Текущие выбранные субтитры */
65
+ currentSubtitle$: Readable<Omit<VideoSubtitle, "selected">>;
66
+ /** Доступные текстовые треки */
67
+ availableTextTracks$: Readable<ITextTrack[]>;
68
+ /** Список доступных субтитров для UI */
69
+ availableSubtitlesList$: Readable<VideoSubtitle[]>;
70
+ /** Текущие субтитры для отображения */
71
+ currentSubtitleCaptions$: Readable<VideoSubtitleParsed["texts"]>;
72
+ /** Видимость авто-субтитров */
73
+ isAutoSubtitleCaptionVisible$: Writable<boolean>;
74
+ }
75
+ /**
76
+ * Экшены модуля subtitles для внутреннего использования
77
+ */
78
+ export interface SubtitlesStoreInternalActions {
79
+ /** Установить субтитры */
80
+ setSubtitle: (subtitle: VideoSubtitle | undefined, external: boolean) => void;
81
+ /** Переключить субтитры */
82
+ toggleSubtitle: (external: boolean) => void;
83
+ /** Включить субтитры */
84
+ subtitleOn: (external: boolean, id?: string) => void;
85
+ /** Выключить субтитры */
86
+ subtitleOff: (external: boolean) => void;
87
+ /** Установить форсированный язык субтитров */
88
+ setForcedSubtitlesLanguage: (language: string) => void;
89
+ /** Обновить доступные субтитры */
90
+ updateAvailableSubtitles: () => void;
91
+ }
92
+ /**
93
+ * Экшены модуля subtitles для внешнего использования
94
+ */
95
+ export interface SubtitlesStoreExternalActions {
96
+ /** Установить субтитры */
97
+ setSubtitle: (subtitle: VideoSubtitle | undefined) => void;
98
+ /** Переключить субтитры */
99
+ toggleSubtitle: () => void;
100
+ /**
101
+ * Изменить субтитры
102
+ */
103
+ changeSubtitle: (enabled: boolean, id?: string) => void;
104
+ }
105
+ /**
106
+ * Результат создания subtitles store
107
+ */
108
+ export interface SubtitlesStore {
109
+ /** Состояние */
110
+ state: SubtitlesStoreState;
111
+ /** Экшены для внутреннего использования */
112
+ actions: SubtitlesStoreInternalActions;
113
+ /** Экшены для внешнего использования */
114
+ externalActions: SubtitlesStoreExternalActions;
115
+ /** События для статистики */
116
+ events: {
117
+ actionSetSubtitle$: Subject<string>;
118
+ actionSubtitlesSwitched$: Subject<{
119
+ enabled: boolean;
120
+ lang: string;
121
+ auto: boolean;
122
+ }>;
123
+ };
124
+ /** Очистка ресурсов */
125
+ destroy(): void;
126
+ }
127
+ /**
128
+ * Создаёт subtitles store
129
+ */
130
+ export declare const createSubtitlesStore: (deps: Deps) => SubtitlesStore;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Subtitles Store Token
3
+ */
4
+ import { InjectionToken } from "@vkontakte/videoplayer-shared";
5
+ import type { SubtitlesStore } from "./subtitlesStore.store";
6
+ export declare const SUBTITLES_STORE_TOKEN: InjectionToken<SubtitlesStore>;
@@ -1,11 +1,11 @@
1
1
  import type { ChromecastState, IAudioStream, IConfig as ICoreInitVideoConfig, IExternalTextTrack, IOptionalTuningConfig, IPlayer, ISources, ITextTrack, IVideoStream, PlaybackRate, PlaybackState, VideoFormat } from "@vkontakte/videoplayer-core";
2
2
  import type { InteractiveRange } from "@vkontakte/videoplayer-interactive";
3
- import type { AppTracer, IError, ILogger, InterfaceLanguage, InternalsExposure, IRectangle, IValueObservable, QualityLimits, VideoQuality } from "@vkontakte/videoplayer-shared";
3
+ import type { AppTracer, IError, ILogger, InterfaceLanguage, InternalsExposure, IRectangle, ISubject, IValueObservable, IValueSubject, QualityLimits, VideoQuality } from "@vkontakte/videoplayer-shared";
4
4
  import type { SeekAction, ThinOneStat } from "@vkontakte/videoplayer-statistics";
5
5
  import type { Readable, Writable } from "svelte/store";
6
- import type { AdditionalButtonDeprecated, AdsPlaybackState, ControlBlocksRefs, ControlsKeys, HotKeyMapData, IAnnotationsApi, IControlInfo, IDisabledControls, IInteractiveData, IPictureInPictureApi, IPlayerControlsRef, IPlayerPhase, ITimelinePreviewThumbsData, IVideoEpisode, IVKVideoPlayerCallbacks, IVKVideoPlayerUICallbacks, PlaybackStateRealistic, Position, Size, VideoPlaybackRate, VideoPlayerView, VideoQualityForRender, VideoQualityUI, VideoSubtitle, VideoSubtitleParsed } from "../types";
6
+ import type { AdditionalButtonDeprecated, AdsPlaybackState, ControlBlocksRefs, ControlsKeys, HotKeyMapData, IAnnotationsApi, IControlInfo, IDisabledControls, IInteractiveData, IPictureInPictureApi, IPlayerControlsRef, IPlayerPhase, ITimelinePreviewThumbsData, IVideoEpisode, IVKVideoPlayerCallbacks, IVKVideoPlayerUICallbacks, Position, Size, VideoPlaybackRate, VideoPlayerView, VideoQualityForRender, VideoQualityUI, VideoSubtitle, VideoSubtitleParsed } from "../types";
7
7
  import type { AdmanWrapper } from "../components/Ads/admanWrapper";
8
- import type { Key, LanguageConfig } from "../translation/types";
8
+ import type { Key } from "../translation/types";
9
9
  import type { QualitySettingsAppliesTo } from "../utils/userSettings";
10
10
  import type { GridTypes, PlayPrevChapterDisabledTooltipKey } from "../constans";
11
11
  import type { AdditionalButton, AdditionalDesktopControlPanelButton } from "../components/Controls/types";
@@ -62,6 +62,7 @@ export interface IUIState {
62
62
  fullscreen: Writable<IControlInfo | undefined>;
63
63
  chromecast: Writable<IControlInfo | undefined>;
64
64
  pip: Writable<IControlInfo | undefined>;
65
+ qoe: Writable<IControlInfo | undefined>;
65
66
  "theater-mode-button": Writable<IControlInfo | undefined>;
66
67
  vkLogo: Writable<IControlInfo | undefined>;
67
68
  interactiveTimeIndicator: Writable<IControlInfo | undefined>;
@@ -153,7 +154,7 @@ export interface IPlayerState {
153
154
  positionWithScrubbing$: Readable<number>;
154
155
  duration$: Readable<number>;
155
156
  playbackState$: Readable<PlaybackState | undefined>;
156
- playbackStateRealistic$: Readable<PlaybackStateRealistic | undefined>;
157
+ isBuffering$: Readable<boolean>;
157
158
  isPlaying$: Readable<boolean>;
158
159
  isLoaderVisible: Readable<boolean>;
159
160
  bufferedProgress$: Readable<number>;
@@ -272,8 +273,7 @@ export interface IStoreInternalActions {
272
273
  holdCamera(): void;
273
274
  releaseCamera(): void;
274
275
  downloadVideo: () => void;
275
- addLanguage: (config: LanguageConfig) => void;
276
- setLanguage: (language: InterfaceLanguage | string) => void;
276
+ setLanguage: (language: InterfaceLanguage | string) => Promise<void>;
277
277
  nextMovie: (movieId: number) => void;
278
278
  correctSeekTimeToInteractive: (time: number) => number;
279
279
  replayInteractive?: () => void;
@@ -334,18 +334,25 @@ export interface IStoreInitVideoConfig extends ICoreInitVideoConfig {
334
334
  canDownload?: boolean;
335
335
  previewThumbsData?: ITimelinePreviewThumbsData;
336
336
  subtitles?: Omit<IExternalTextTrack, "type">[];
337
- subtitlesForcedLanguage?: string;
338
337
  unitedVideoId?: number;
339
338
  videoEpisodes?: IVideoEpisode[];
340
339
  }
340
+ export interface IStoreEvents {
341
+ actionRewind$: ISubject<void>;
342
+ actionSeek$: IValueSubject<SeekAction | ThinOneStat.ActionSeekType>;
343
+ actionQuality$: ISubject<ThinOneStat.ActionQualityType>;
344
+ nextMovie$: ISubject<number>;
345
+ }
341
346
  export interface IStore {
342
347
  initVideo: (config: IStoreInitVideoConfig) => void;
343
348
  videoId$: Writable<number | undefined>;
344
349
  playerPhase: IPlayerPhase;
345
350
  interfaceLanguage$: Readable<InterfaceLanguage | string>;
351
+ interfaceLanguageUpdated$: ISubject<void>;
346
352
  isCyrillicRelatedInterface$: Readable<boolean>;
347
353
  interactiveData?: IInteractiveData;
348
- vsid$: Readable<string | undefined>;
354
+ vsid$: Writable<string | undefined>;
355
+ events: IStoreEvents;
349
356
  state: IPlayerState;
350
357
  ui: IUIState;
351
358
  ads: IAdsState;
@@ -360,7 +367,6 @@ export interface IStore {
360
367
  initOnFinishedCallback: VoidFunction;
361
368
  resetAdsState: VoidFunction;
362
369
  updateAdmanWrapperSubscriptions: VoidFunction;
363
- updateStatisticsSubscriptions: VoidFunction;
364
370
  updateAppTracerSubscriptions: VoidFunction;
365
371
  updateTracerSubscriptions: VoidFunction;
366
372
  getLogger: () => ILogger;
@@ -6,3 +6,4 @@ export type LanguageConfig = {
6
6
  fallback: InterfaceLanguage;
7
7
  pack: LanguagePack;
8
8
  };
9
+ export type TSignature = (key: Key, params?: Record<string, string>) => string;
@@ -381,6 +381,7 @@ export interface IPlayerControlsRef {
381
381
  interactiveTimeIndicator?: HTMLElement;
382
382
  timeline?: HTMLElement;
383
383
  autoplayNextToggle?: HTMLButtonElement;
384
+ qoe?: HTMLElement;
384
385
  }
385
386
  export interface IPlayerDesktopControlsWidth {
386
387
  prevButton: number;
@@ -628,7 +629,3 @@ export interface Caption {
628
629
  value: string;
629
630
  }
630
631
  export type NotificationId = "slow_video";
631
- export declare enum PlaybackStateExtended {
632
- BUFFERING = "buffering"
633
- }
634
- export type PlaybackStateRealistic = PlaybackState | PlaybackStateExtended;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Базовая санитизация SVG для защиты от XSS.
3
+ * Удаляет опасные паттерны: script-теги, event handlers, javascript: URLs.
4
+ */
5
+ export declare function sanitizeSvg(svg: string | undefined): string;