@vkontakte/videoplayer-shared 1.0.86-dev.fcdd1bac.0 → 1.0.86

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 (89) hide show
  1. package/es2015.cjs +7 -0
  2. package/es2015.esm.js +7 -0
  3. package/es2018.cjs +7 -0
  4. package/es2018.esm.js +7 -0
  5. package/es2024.cjs +7 -0
  6. package/es2024.esm.js +7 -0
  7. package/esnext.cjs +7 -0
  8. package/esnext.esm.js +7 -0
  9. package/evergreen.esm.js +7 -0
  10. package/package.json +29 -6
  11. package/types/AppTracer/AppTracer.d.ts +25 -0
  12. package/types/AppTracer/constants.d.ts +1 -0
  13. package/types/AppTracer/index.d.ts +2 -0
  14. package/types/AppTracer/types.d.ts +19 -0
  15. package/types/AppTracer/utils.d.ts +5 -0
  16. package/types/InternalsExposure/index.d.ts +28 -0
  17. package/types/Logger/Logger.d.ts +10 -0
  18. package/types/Logger/index.d.ts +2 -0
  19. package/types/Logger/types.d.ts +29 -0
  20. package/types/Tracer/FakeTracer.d.ts +13 -0
  21. package/types/Tracer/RootTracer.d.ts +10 -0
  22. package/types/Tracer/Tracer.d.ts +25 -0
  23. package/types/Tracer/TracerFactory.d.ts +4 -0
  24. package/types/Tracer/index.d.ts +3 -0
  25. package/types/Tracer/types.d.ts +39 -0
  26. package/types/Tracer/utils.d.ts +3 -0
  27. package/types/devNull.d.ts +14 -0
  28. package/types/env.d.ts +1 -0
  29. package/types/index.d.ts +11 -0
  30. package/types/reactive/Observable.d.ts +14 -0
  31. package/types/reactive/ReplaySubject.d.ts +12 -0
  32. package/types/reactive/Subject.d.ts +10 -0
  33. package/types/reactive/Subscription.d.ts +6 -0
  34. package/types/reactive/SubscriptionRemovable.d.ts +5 -0
  35. package/types/reactive/ValueSubject.d.ts +10 -0
  36. package/types/reactive/combine.d.ts +7 -0
  37. package/types/reactive/fromEvent.d.ts +7 -0
  38. package/types/reactive/index.d.ts +25 -0
  39. package/types/reactive/interval.d.ts +4 -0
  40. package/types/reactive/merge.d.ts +82 -0
  41. package/types/reactive/observableFrom.d.ts +3 -0
  42. package/types/reactive/operators/buffer.d.ts +2 -0
  43. package/types/reactive/operators/debounce.d.ts +7 -0
  44. package/types/reactive/operators/filter.d.ts +6 -0
  45. package/types/reactive/operators/filterChanged.d.ts +5 -0
  46. package/types/reactive/operators/map.d.ts +5 -0
  47. package/types/reactive/operators/mapTo.d.ts +5 -0
  48. package/types/reactive/operators/once.d.ts +5 -0
  49. package/types/reactive/operators/pairwise.d.ts +3 -0
  50. package/types/reactive/operators/shareReplay.d.ts +2 -0
  51. package/types/reactive/operators/skip.d.ts +6 -0
  52. package/types/reactive/operators/tap.d.ts +2 -0
  53. package/types/reactive/operators/throttle.d.ts +6 -0
  54. package/types/reactive/timeout.d.ts +4 -0
  55. package/types/reactive/types.d.ts +47 -0
  56. package/types/translation/index.d.ts +2 -0
  57. package/types/translation/loadVKLangPack.d.ts +16 -0
  58. package/types/translation/types.d.ts +5 -0
  59. package/types/types/index.d.ts +71 -0
  60. package/types/utils/abortable.d.ts +6 -0
  61. package/types/utils/addScript.d.ts +1 -0
  62. package/types/utils/browser.d.ts +2 -0
  63. package/types/utils/clearVideoElement.d.ts +1 -0
  64. package/types/utils/cloneDeep.d.ts +1 -0
  65. package/types/utils/cloneDeepWith.d.ts +3 -0
  66. package/types/utils/config.d.ts +2 -0
  67. package/types/utils/debounceFn.d.ts +13 -0
  68. package/types/utils/detectEmbed.d.ts +8 -0
  69. package/types/utils/empty.d.ts +2 -0
  70. package/types/utils/exponentialBackoff.d.ts +9 -0
  71. package/types/utils/flattenObject.d.ts +9 -0
  72. package/types/utils/getPlayerId.d.ts +1 -0
  73. package/types/utils/getRangeAroundIndex.d.ts +7 -0
  74. package/types/utils/iframeSafeStorage.d.ts +6 -0
  75. package/types/utils/index.d.ts +34 -0
  76. package/types/utils/interpolate.d.ts +12 -0
  77. package/types/utils/isIntersecting.d.ts +6 -0
  78. package/types/utils/isValidURL.d.ts +1 -0
  79. package/types/utils/never.d.ts +2 -0
  80. package/types/utils/noop.d.ts +1 -0
  81. package/types/utils/now.d.ts +4 -0
  82. package/types/utils/nullable.d.ts +8 -0
  83. package/types/utils/observeElementSize.d.ts +4 -0
  84. package/types/utils/quality/index.d.ts +21 -0
  85. package/types/utils/quality/types.d.ts +22 -0
  86. package/types/utils/semanticTypes.d.ts +7 -0
  87. package/types/utils/suppressAbort.d.ts +2 -0
  88. package/types/utils/throttleFn.d.ts +6 -0
  89. package/types/utils/timecode.d.ts +1 -0
@@ -0,0 +1,47 @@
1
+ export type IUnsubscriber = () => void;
2
+ export interface ISubscription {
3
+ unsubscribe: IUnsubscriber;
4
+ add(item: ISubscription | IUnsubscriber): ISubscription;
5
+ }
6
+ export interface IObservable<T> {
7
+ subscribe(listener: IListener<T>, error?: IListener<Error | unknown>): ISubscription;
8
+ pipe<T1>(op1: IOperator<T, T1>): IObservable<T1>;
9
+ pipe<
10
+ T1,
11
+ T2
12
+ >(op1: IOperator<T, T1>, op2: IOperator<T1, T2>): IObservable<T2>;
13
+ pipe<
14
+ T1,
15
+ T2,
16
+ T3
17
+ >(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>): IObservable<T3>;
18
+ pipe<
19
+ T1,
20
+ T2,
21
+ T3,
22
+ T4
23
+ >(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>): IObservable<T4>;
24
+ pipe<
25
+ T1,
26
+ T2,
27
+ T3,
28
+ T4,
29
+ T5
30
+ >(op1: IOperator<T, T1>, op2: IOperator<T1, T2>, op3: IOperator<T2, T3>, op4: IOperator<T3, T4>, op5: IOperator<T4, T5>): IObservable<T5>;
31
+ }
32
+ export interface IValue<T> {
33
+ getValue(): T;
34
+ }
35
+ export interface IEmitter<T> {
36
+ next(value: T): void;
37
+ error?(value: Error | unknown): void;
38
+ }
39
+ export interface IValueObservable<T> extends IObservable<T>, IValue<T> {}
40
+ export interface ISubject<T> extends IEmitter<T>, IObservable<T> {}
41
+ export interface IValueSubject<T> extends IEmitter<T>, IObservable<T>, IValue<T> {}
42
+ export type IListener<T> = IEmitter<T> | ((value: T) => void) | ((value: T) => Promise<void>);
43
+ export type IOperator<
44
+ TInput,
45
+ TOutput = TInput
46
+ > = (input: IObservable<TInput>) => IObservable<TOutput>;
47
+ export type TypeOfObservable<TObservable> = TObservable extends IObservable<infer TType> ? TType : never;
@@ -0,0 +1,2 @@
1
+ export * from "./loadVKLangPack";
2
+ export * from "./types";
@@ -0,0 +1,16 @@
1
+ import type { StringRecord } from "./types";
2
+ export declare enum VKNumericLanguage {
3
+ Armenian = "58",
4
+ Azerbaijani = "57",
5
+ Belarusian = "114",
6
+ English = "3",
7
+ Kazakh = "97",
8
+ Portuguese = "73",
9
+ Russian = "0",
10
+ Spanish = "4",
11
+ Ukrainian = "1",
12
+ Uzbek = "65",
13
+ Vietnamese = "75"
14
+ }
15
+ export type VKLanguage = VKNumericLanguage | string;
16
+ export declare const loadVKLangPack: <T extends StringRecord>(language: VKLanguage, packName: string, packPrefix: string) => Promise<T>;
@@ -0,0 +1,5 @@
1
+ export declare enum InterfaceLanguage {
2
+ RU = "ru",
3
+ EN = "en"
4
+ }
5
+ export type StringRecord = Record<string, string>;
@@ -0,0 +1,71 @@
1
+ export type SafeAny = any;
2
+ export interface IError {
3
+ /**
4
+ * Код или другой идентификатор для статистики
5
+ */
6
+ id: string;
7
+ category: ErrorCategory;
8
+ /**
9
+ * Сообщение по которому можно разобрать что случилось
10
+ */
11
+ message: string;
12
+ /**
13
+ * Данные, полезные для отладки
14
+ */
15
+ data?: any;
16
+ /**
17
+ * Возникшее исключение
18
+ */
19
+ thrown?: Error | unknown;
20
+ /**
21
+ * Отправлять в трейс не как error а как log
22
+ */
23
+ traceAsLog?: boolean;
24
+ /**
25
+ * HTTP-code ошибки
26
+ */
27
+ httpCode?: number;
28
+ /**
29
+ * Код ошибки, который вернул backend Единого Видео
30
+ */
31
+ UVBackendErrorCode?: string;
32
+ }
33
+ export interface IWarning {
34
+ /**
35
+ * Код или другой идентификатор для статистики
36
+ */
37
+ id: string;
38
+ /**
39
+ * Сообщение по которому можно разобрать что случилось
40
+ */
41
+ message: string;
42
+ /**
43
+ * Данные, полезные для отладки
44
+ */
45
+ data?: any;
46
+ }
47
+ export declare enum ErrorCategory {
48
+ NETWORK = "network",
49
+ VIDEO_PIPELINE = "video_pipeline",
50
+ EXTERNAL_API = "external_api",
51
+ PARSER = "parser",
52
+ DOM = "dom",
53
+ WTF = "wtf",
54
+ FATAL = "fatal"
55
+ }
56
+ export interface IRange<Unit extends number = number> {
57
+ from: Unit;
58
+ to: Unit;
59
+ }
60
+ export interface IRectangle<Unit extends number = number> {
61
+ width: Unit;
62
+ height: Unit;
63
+ }
64
+ export type RecursivePartial<T> = { [P in keyof T]? : T[P] extends (infer U)[] ? RecursivePartial<U>[] : T[P] extends object | undefined ? RecursivePartial<T[P]> : T[P] };
65
+ export type WithRequired<
66
+ T,
67
+ K extends keyof T
68
+ > = T & { [P in K]-? : T[P] };
69
+ export type Constructor<T> = new () => T;
70
+ export type AbstractConstructor<T> = abstract new () => T;
71
+ export type AnyConstructor<T> = Constructor<T> | AbstractConstructor<T>;
@@ -0,0 +1,6 @@
1
+ type AbortableDecorator = <
2
+ Params extends unknown[] = void[],
3
+ Return = void
4
+ >(signal: AbortSignal, createGenerator: (...param: Params) => AsyncGenerator<unknown, Return, unknown>) => (...param: Params) => Promise<Return | undefined>;
5
+ export declare const abortable: AbortableDecorator;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const addScript: (scriptSrc: string, abortSignal: AbortSignal, timeout?: number) => Promise<void>;
@@ -0,0 +1,2 @@
1
+ export declare const getWindow: () => Window & typeof globalThis;
2
+ export declare const isBrowserWindow: (root?: any) => root is Window;
@@ -0,0 +1 @@
1
+ export declare const clearVideoElement: (video: HTMLVideoElement, clearVideoElementInnerHTML?: boolean) => void;
@@ -0,0 +1 @@
1
+ export declare const cloneDeep: <T>(obj: T) => T;
@@ -0,0 +1,3 @@
1
+ type CloneDeepWithCustomizer<TObject> = (value: unknown, key: number | string | undefined, object: TObject | undefined, stack: any) => any;
2
+ export declare const cloneDeepWith: <T>(obj: T, customizer?: CloneDeepWithCustomizer<T>) => T;
3
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { RecursivePartial } from "../types";
2
+ export declare const fillWithDefault: <Config extends object>(partial: RecursivePartial<Config>, defaultConfig: Config) => Config;
@@ -0,0 +1,13 @@
1
+ interface DebounceSettings {
2
+ leading?: boolean;
3
+ maxWait?: number;
4
+ trailing?: boolean;
5
+ }
6
+ export interface DebouncedFn<T extends (...args: any[]) => any> {
7
+ (...args: Parameters<T>): ReturnType<T> | undefined;
8
+ cancel(): void;
9
+ flush(): ReturnType<T> | undefined;
10
+ pending(): boolean;
11
+ }
12
+ export declare function debounceFn<T extends (...args: any) => any>(func: T, wait?: number, options?: DebounceSettings): DebouncedFn<T>;
13
+ export {};
@@ -0,0 +1,8 @@
1
+ interface Result {
2
+ isEmbed: boolean;
3
+ origins: string[];
4
+ topOrigin?: string;
5
+ immediateOrigin?: string;
6
+ }
7
+ export declare const detectEmbed: () => Result;
8
+ export {};
@@ -0,0 +1,2 @@
1
+ export declare function assertNotEmptyArray<T extends Array<unknown>>(value: T, failMessage: string): void;
2
+ export declare function assertEmptyArray<T extends Array<unknown>>(value: T, failMessage: string): void;
@@ -0,0 +1,9 @@
1
+ import type { Milliseconds } from "./semanticTypes";
2
+ export type ExponentialBackoffConfig = Partial<{
3
+ start: Milliseconds;
4
+ factor: number;
5
+ min: Milliseconds;
6
+ max: Milliseconds;
7
+ random: number;
8
+ }>;
9
+ export declare const getExponentialDelay: (errorsCount: number, { start, factor, max, min, random }?: ExponentialBackoffConfig) => Milliseconds;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * Функция, которая "сплющивает" вложенный объект. Делает так, чтобы все проперти в объекте были примитивами и
3
+ * не содержали вложенных объектов
4
+ * @param obj - исходный объект
5
+ * @param maxDeep - максимальная глубина рекурсивного обхода
6
+ * @param separator - символ разделитель. По умолчанию точка '.'
7
+ * @return - новый сплющенный объект, который не содержит больше вложенных объектов
8
+ */
9
+ export declare const flattenObject: (obj: Record<string, any> | undefined, maxDeep?: number, separator?: string) => Record<string, any>;
@@ -0,0 +1 @@
1
+ export declare const getPlayerId: (playerId?: string) => string;
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Возвращает диапозон индексов вокруг определнного индекса.
3
+ * @param totalItems Размер массива.
4
+ * @param currentIndex Индекс вокруг которого нужно собрать массив.
5
+ * @param max Максимальный размер индекса.
6
+ */
7
+ export declare function getRangeAroundIndex(totalItems: number, currentIndex: number, max: number): number[];
@@ -0,0 +1,6 @@
1
+ export declare const isPersistent: () => boolean;
2
+ export declare const get: (key: string) => string | undefined;
3
+ export declare const set: (key: string, value: string) => void;
4
+ export declare const has: (key: string) => boolean;
5
+ export declare const remove: (key: string) => void;
6
+ export declare const clear: () => void;
@@ -0,0 +1,34 @@
1
+ export { noop } from "./noop";
2
+ export { assertNever, checkNever } from "./never";
3
+ export { isNonNullable, isNullable, assertNonNullable, assertNullable, withoutNullable } from "./nullable";
4
+ export type { Nullable } from "./nullable";
5
+ export { assertNotEmptyArray, assertEmptyArray } from "./empty";
6
+ export { addScript } from "./addScript";
7
+ export type { Milliseconds, bps, Byte, Seconds, Kbps, Mbps, Percentage } from "./semanticTypes";
8
+ export { now, nowInt } from "./now";
9
+ export { abortable } from "./abortable";
10
+ export { getExponentialDelay } from "./exponentialBackoff";
11
+ export type { ExponentialBackoffConfig } from "./exponentialBackoff";
12
+ export * as safeStorage from "./iframeSafeStorage";
13
+ export { detectEmbed } from "./detectEmbed";
14
+ export { VideoQuality } from "./quality/types";
15
+ export type { ExactVideoQuality, QualityLimits } from "./quality/types";
16
+ export { isHigher, isHigherOrEqual, isLower, isLowerOrEqual, getHighestQuality, videoHeightToQuality, videoSizeToQuality, videoQualityToHeight, isInvariantQuality, areQualitiesExact, assertQualityIsExact, getVideoQualityLabel } from "./quality";
17
+ export * from "./config";
18
+ export * from "./timecode";
19
+ export { debounceFn } from "./debounceFn";
20
+ export type { DebouncedFn } from "./debounceFn";
21
+ export { throttleFn } from "./throttleFn";
22
+ export type { ThrottleOptions } from "./throttleFn";
23
+ export { cloneDeep } from "./cloneDeep";
24
+ export { observeElementSize } from "./observeElementSize";
25
+ export { cloneDeepWith } from "./cloneDeepWith";
26
+ export { flattenObject } from "./flattenObject";
27
+ export { clearVideoElement } from "./clearVideoElement";
28
+ export * from "./isValidURL";
29
+ export { isIntersecting } from "./isIntersecting";
30
+ export { getPlayerId } from "./getPlayerId";
31
+ export { interpolate } from "./interpolate";
32
+ export { getRangeAroundIndex } from "./getRangeAroundIndex";
33
+ export * from "./browser";
34
+ export { suppressAbort, isAbortError } from "./suppressAbort";
@@ -0,0 +1,12 @@
1
+ /**
2
+ * clamp - значение не выходит за outputRange, прибиваем его к краям диапозона.
3
+ */
4
+ export type Extrapolate = "clamp";
5
+ /**
6
+ * Линейно интерполирует значение из inputRange в outputRange.
7
+ * @param value - Входное значение (например, прогресс анимации)
8
+ * @param inputRange - Диапазон входных значений (должен быть отсортирован)
9
+ * @param outputRange - Диапазон выходных значений
10
+ * @returns - Интерполированное значение
11
+ */
12
+ export declare function interpolate(value: number, inputRange: [number, number], outputRange: [number, number]): number;
@@ -0,0 +1,6 @@
1
+ type Rect = Pick<DOMRect, "top" | "bottom" | "left" | "right">;
2
+ /**
3
+ * Проверяет пересекаются ли прямоугольники.
4
+ */
5
+ export declare const isIntersecting: (rect1: Rect, rect2: Rect) => boolean;
6
+ export {};
@@ -0,0 +1 @@
1
+ export declare const isValidURL: (urlParam: unknown) => urlParam is string | URL;
@@ -0,0 +1,2 @@
1
+ export declare const assertNever: (x: never) => never;
2
+ export declare const checkNever: (_x: never) => void;
@@ -0,0 +1 @@
1
+ export declare const noop: () => void;
@@ -0,0 +1,4 @@
1
+ import type { Milliseconds } from "./semanticTypes";
2
+ export declare const now: () => Milliseconds;
3
+ /** возвращает `Int` значение `now` */
4
+ export declare const nowInt: () => Milliseconds;
@@ -0,0 +1,8 @@
1
+ export declare function assertNonNullable<T>(value: T, failMessage?: string): asserts value is NonNullable<T>;
2
+ export declare function assertNullable<T extends INullable = INullable>(value: unknown, failMessage?: string): asserts value is T;
3
+ export declare function isNonNullable<T>(value: T): value is NonNullable<T>;
4
+ export declare function isNullable<T extends INullable = INullable>(value: unknown): value is T;
5
+ type INullable = null | undefined;
6
+ export type Nullable<T> = T | INullable;
7
+ export declare const withoutNullable: <T extends object>(target: T) => Required<T>;
8
+ export {};
@@ -0,0 +1,4 @@
1
+ import type { IObservable } from "../reactive";
2
+ import type { IRectangle } from "../types";
3
+ import type { Milliseconds } from "./semanticTypes";
4
+ export declare const observeElementSize: (element: Element, throttleTime?: Milliseconds) => IObservable<IRectangle>;
@@ -0,0 +1,21 @@
1
+ import type { IRectangle } from "../../types";
2
+ import { type ExactVideoQuality, VideoQuality } from "./types";
3
+ export declare const isHigher: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
4
+ export declare const isHigherOrEqual: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
5
+ export declare const isLower: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
6
+ export declare const isLowerOrEqual: (a: ExactVideoQuality, b: ExactVideoQuality) => boolean;
7
+ export declare const getHighestQuality: (qualities: VideoQuality[]) => VideoQuality | undefined;
8
+ /**
9
+ * Выбирает качество, наиболее близкое к указанной высоте кадра, но не менее её.
10
+ * @param tolerance позволяет выбрать качество менее заданной высоты на величину погрешности (в процентах)
11
+ */
12
+ export declare const videoHeightToQuality: (height: number, tolerance?: number) => ExactVideoQuality | undefined;
13
+ /**
14
+ * Выбирает качество описывающее заданные размеры видео потока, т.е. не меньше его.
15
+ */
16
+ export declare const videoSizeToQuality: ({ width, height }: IRectangle) => ExactVideoQuality | undefined;
17
+ export declare const videoQualityToHeight: (quality: ExactVideoQuality) => number;
18
+ export declare const isInvariantQuality: (quality: VideoQuality) => quality is VideoQuality.INVARIANT;
19
+ export declare const areQualitiesExact: (qualities: VideoQuality[]) => qualities is ExactVideoQuality[];
20
+ export declare function assertQualityIsExact(quality: VideoQuality): asserts quality is ExactVideoQuality;
21
+ export declare const getVideoQualityLabel: (q: VideoQuality) => string;
@@ -0,0 +1,22 @@
1
+ export declare enum VideoQuality {
2
+ INVARIANT = "Invariant quality",
3
+ Q_144P = "144p",
4
+ Q_240P = "240p",
5
+ Q_360P = "360p",
6
+ Q_480P = "480p",
7
+ Q_576P = "576p",
8
+ Q_720P = "720p",
9
+ Q_1080P = "1080p",
10
+ Q_1440P = "1440p",
11
+ Q_2160P = "2160p",
12
+ Q_4320P = "4320p"
13
+ }
14
+ export type ExactVideoQuality = Exclude<VideoQuality, VideoQuality.INVARIANT>;
15
+ /**
16
+ * Лимиты трактуются включительно
17
+ * Значение undefined снимает лимит
18
+ */
19
+ export type QualityLimits = {
20
+ max?: ExactVideoQuality;
21
+ min?: ExactVideoQuality;
22
+ };
@@ -0,0 +1,7 @@
1
+ export type Seconds = number;
2
+ export type Milliseconds = number;
3
+ export type bps = number;
4
+ export type Kbps = number;
5
+ export type Mbps = number;
6
+ export type Byte = number;
7
+ export type Percentage = number;
@@ -0,0 +1,2 @@
1
+ export declare const isAbortError: (e: Error | unknown) => boolean;
2
+ export declare const suppressAbort: (e: Error | unknown) => void | never;
@@ -0,0 +1,6 @@
1
+ import { type DebouncedFn } from "./debounceFn";
2
+ export interface ThrottleOptions {
3
+ leading?: boolean;
4
+ trailing?: boolean;
5
+ }
6
+ export declare const throttleFn: <T extends (...args: any) => any>(func: T, wait?: number, options?: ThrottleOptions) => DebouncedFn<T>;
@@ -0,0 +1 @@
1
+ export declare const timeCodeToString: (t: number) => string;