@vkontakte/videoplayer-core 2.0.175 → 2.0.176-dev.b09e84095.0

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vkontakte/videoplayer-core",
3
- "version": "2.0.175",
3
+ "version": "2.0.176-dev.b09e84095.0",
4
4
  "author": "vk.ru",
5
5
  "description": "Videoplayer core library based on the vk.ru platform",
6
6
  "homepage": "https://vk.ru",
@@ -42,6 +42,6 @@
42
42
  "**/*.d.ts"
43
43
  ],
44
44
  "dependencies": {
45
- "@vkontakte/videoplayer-shared": "1.0.104"
45
+ "@vkontakte/videoplayer-shared": "1.0.105-dev.b09e84095.0"
46
46
  }
47
47
  }
package/types/index.d.ts CHANGED
@@ -3,7 +3,9 @@ import type { IMpegSource, IDashSource, IHLSSource, IDashURLSource, IHLSLiveSour
3
3
  import type { VideoCodec } from "./player/types";
4
4
  import { VideoFormat, Surface, PredefinedQualityLimits, VideoCodecName } from "./player/types";
5
5
  import Player from "./player/Player";
6
- import type { IPlayer, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, IExternalTextTrack, ITextTrack, PlaybackRate, IVideoStream, IAudioStream } from "./player/types";
6
+ import warmUpSources from "./utils/warmUpSources";
7
+ import type { IWarmUp } from "./utils/warmUpSources";
8
+ import type { IPlayer, IPlayerInfo, IPlayerEvents, IConfig, ISources, ICueSettings, IExternalTextTrack, ITextTrack, PlaybackRate, IVideoStream, IAudioStream, StartEnd, HttpConnectionMetrics, HttpDownloadMetrics } from "./player/types";
7
9
  import { PlaybackState, ChromecastState, HttpConnectionType } from "./player/types";
8
10
  import type { IOptionalTuningConfig } from "./utils/tuningConfig";
9
11
  export { clientChecker, isMobile } from "./utils/ClientChecker";
@@ -15,5 +17,6 @@ import { Subscription, Observable, Subject, ValueSubject, VideoQuality } from "@
15
17
  * @deprecated
16
18
  */
17
19
  declare const SDK_VERSION: string;
18
- export type { IPlayer, IPlayerInfo, IPlayerEvents, IConfig, IOptionalTuningConfig, ILogEntry, ISources, IExternalTextTrack, ITextTrack, ISubscription, IUnsubscriber, IObservable, IEmitter, IValueObservable, IValue, IOperator, IListener, IMpegSource, IDashSource, IDashURLSource, IHLSSource, IHLSLiveSource, URLSource, RawSource, URLSourceWithSeek, ExactVideoQuality, IRange, ISeekRequest, ICueSettings, PlaybackRate, IVideoStream, IAudioStream };
19
- export { Player, PlaybackState, ChromecastState, HttpConnectionType, Surface, Subscription, VideoFormat, VideoQuality, Observable, Subject, ValueSubject, VERSION, SDK_VERSION, PredefinedQualityLimits, VideoCodec, VideoCodecName };
20
+ export type { IPlayer, IPlayerInfo, IPlayerEvents, IConfig, IOptionalTuningConfig, ILogEntry, ISources, IExternalTextTrack, ITextTrack, ISubscription, IUnsubscriber, IObservable, IEmitter, IValueObservable, IValue, IOperator, IListener, IMpegSource, IDashSource, IDashURLSource, IHLSSource, IHLSLiveSource, URLSource, RawSource, URLSourceWithSeek, ExactVideoQuality, IRange, ISeekRequest, ICueSettings, PlaybackRate, IVideoStream, IAudioStream, StartEnd, HttpConnectionMetrics, HttpDownloadMetrics };
21
+ export type { IWarmUp };
22
+ export { Player, warmUpSources, PlaybackState, ChromecastState, HttpConnectionType, Surface, Subscription, VideoFormat, VideoQuality, Observable, Subject, ValueSubject, VERSION, SDK_VERSION, PredefinedQualityLimits, VideoCodec, VideoCodecName };
@@ -0,0 +1,21 @@
1
+ export interface IWarmUpTargets {
2
+ preconnect: string[];
3
+ dnsPrefetch: string[];
4
+ }
5
+ /**
6
+ * Прогрев соединения к хостам раздачи. Первый запрос плеера иначе оплачивает полный
7
+ * холодный путь DNS → TCP → TLS, и только после него едут байты.
8
+ *
9
+ * `crossOrigin` на preconnect обязателен: медиазапросы уходят с CORS, а прогретое без него
10
+ * соединение лежит в другом пуле браузера — то есть впустую. Для dns-prefetch он не нужен:
11
+ * резолв имени от пула соединений не зависит.
12
+ *
13
+ * Линки снимаются при `destroy`: плеер переинициализируют, и без уборки `<head>` копил бы
14
+ * их до перезагрузки страницы.
15
+ */
16
+ export declare class ConnectionWarmUp {
17
+ private links;
18
+ warmUp(targets: IWarmUpTargets): IWarmUpTargets;
19
+ destroy(): void;
20
+ private appendLinks;
21
+ }
@@ -475,6 +475,13 @@ export type ITuningConfig = {
475
475
  */
476
476
  useUrlCacheMechanism?: boolean;
477
477
  /**
478
+ * Прогревать ли соединение к хостам раздачи. **Сам SDK этот флаг не читает** — прогрев живёт
479
+ * в `warmUpSources`, а зовёт её потребитель: внутри SDK запаса времени до первого запроса нет.
480
+ * Флаг лежит здесь, чтобы раскаткой управлял тот же ключ конфига плеера, что и остальными
481
+ * экспериментами, а не отдельная ручка на каждом потребителе.
482
+ */
483
+ usePreconnectSources?: boolean;
484
+ /**
478
485
  * Очищаем кэш урлов при падение провайдера.
479
486
  */
480
487
  dropUrlCacheWhenProviderCrashed?: boolean;
@@ -0,0 +1,19 @@
1
+ import type { ISources } from "../player/types";
2
+ import type { IWarmUpTargets } from "./ConnectionWarmUp";
3
+ export interface IWarmUp {
4
+ applied: IWarmUpTargets;
5
+ destroy: () => void;
6
+ }
7
+ interface IOptions {
8
+ failoverHosts?: string[];
9
+ limit?: number;
10
+ }
11
+ /**
12
+ * Прогрев соединения к хостам раздачи по готовым `sources` — до того, как создан плеер.
13
+ *
14
+ * Экономия равна запасу времени до первого запроса: плеер успевает пройти путь от `initVideo`
15
+ * до манифеста за считанные миллисекунды, поэтому звать эту функцию имеет смысл там, где
16
+ * `sources` появились сильно раньше плеера, — сразу после ответа API у потребителя.
17
+ */
18
+ declare const _default: (sources: ISources, { failoverHosts, limit }?: IOptions) => IWarmUp;
19
+ export default _default;
@@ -0,0 +1,18 @@
1
+ import type { ISources } from "../player/types";
2
+ /**
3
+ * Хосты, к которым плеер пойдёт за данными. Считаются до того, как выбран формат:
4
+ * прогрев соединения имеет смысл ровно пока выбор ещё не сделан.
5
+ *
6
+ * Лимит намеренно жёсткий. Каждое лишнее соединение — это DNS, TCP и TLS, потраченные
7
+ * на хост, к которому в этой сессии, скорее всего, не пойдут.
8
+ */
9
+ export declare const collectSourceOrigins: (sources: ISources, limit?: number) => string[];
10
+ /**
11
+ * Запасные хосты, которым достаточно резолва имени. Соединение к ним в большинстве сессий
12
+ * не понадобится — failover это аварийный путь, — но DNS стоит дешевле соединения,
13
+ * поэтому лимит прогрева на них не распространяется.
14
+ *
15
+ * `failoverHosts` — голые хосты: `ProviderContainer.applyFailoverHost` подставляет их
16
+ * в существующий URL, сохраняя протокол. Протокол здесь берётся у прогретого источника.
17
+ */
18
+ export declare const collectDnsPrefetchHosts: (failoverHosts: string[], preconnectOrigins: string[]) => string[];