@vkontakte/videoplayer-interactive 1.0.21 → 1.0.22-dev.71ddf25e.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.
@@ -1,54 +1,18 @@
1
- export const defaultArgs: Readonly<{
2
- shouldOpenNow: true;
3
- isDetachContainer: true;
4
- }>;
5
- export function extendArgs(action: any, rewrite?: boolean): any;
6
- export function SelectBranches({ globalEventEmitter, player, interactiveEvents, removeControllers }: {
7
- globalEventEmitter: any;
8
- player: any;
9
- interactiveEvents: any;
10
- removeControllers: any;
11
- }): {
12
- onControlEvent: ({ action, controlType, controlId, containerId, branches, onEvent, isEOV, isDisabled, }: {
13
- action: any;
14
- controlType: any;
15
- controlId: any;
16
- containerId: any;
17
- branches?: any[] | undefined;
18
- onEvent: any;
19
- isEOV?: (() => boolean) | undefined;
20
- isDisabled?: (() => boolean) | undefined;
21
- }) => void;
22
- onContainerEvent: ({ action, container: { id: containerId, endTime }, branches, isEOV, autoSelected, }: {
23
- action: any;
24
- container: {
25
- id: any;
26
- endTime: any;
27
- };
28
- branches?: any[] | undefined;
29
- isEOV?: boolean | undefined;
30
- autoSelected?: boolean | undefined;
31
- }) => void;
32
- onChapterEvent: ({ chapterId, action, branches }: {
33
- chapterId: any;
34
- action: any;
35
- branches?: any[] | undefined;
36
- }) => (() => void) | undefined;
37
- onExpectEvent: ({ subjectId, subjectName, action }: {
38
- subjectId: any;
39
- subjectName: any;
40
- action: any;
41
- }) => void;
42
- expectEventHandler: ({ subjectId, subjectName }: {
43
- subjectId: any;
44
- subjectName: any;
45
- }) => void;
46
- setManifestChapterEvents: (chapter: any) => void;
47
- setManifestContainerEvents: ({ container, branches, isEOV }: {
48
- container: any;
49
- branches: any;
50
- isEOV?: boolean | undefined;
51
- }) => void;
1
+ import type { LatestChapter } from '../../../movika.core/manifest';
2
+ import type { SelectBranchesArg, OnControlEventArg, ContinuePlaybackArg, ExpectEventHandlerArg, OnChapterEventArg, OnContainerEventArg, OnExpectEventArg, SetManifestContainerEventsArg, ActionMap, AnyAction } from './SelectBranches.types';
3
+ export declare const defaultArgs: {
4
+ readonly shouldOpenNow: true;
5
+ readonly isDetachContainer: true;
6
+ };
7
+ export declare const extendArgs: <T extends AnyAction>(action: T, rewrite?: boolean) => T;
8
+ export declare const SelectBranches: ({ globalEventEmitter, player, interactiveEvents, removeControllers, }: SelectBranchesArg) => {
9
+ onControlEvent: ({ action, controlType, controlId, containerId, branches, onEvent, isEOV, isDisabled, }: OnControlEventArg) => void;
10
+ onContainerEvent: ({ action, container: { id: containerId, endTime }, branches, isEOV, autoSelected, }: OnContainerEventArg) => void;
11
+ onChapterEvent: ({ chapterId, action, branches }: OnChapterEventArg) => (() => ContinuePlaybackArg<"chapter">) | undefined;
12
+ onExpectEvent: <T extends keyof ActionMap>({ subjectId, subjectName }: OnExpectEventArg<T>) => void;
13
+ expectEventHandler: <T extends keyof ActionMap>({ subjectId, subjectName }: ExpectEventHandlerArg<T>) => void;
14
+ setManifestChapterEvents: (chapter: LatestChapter) => void;
15
+ setManifestContainerEvents: ({ container, branches, isEOV }: SetManifestContainerEventsArg) => void;
52
16
  stopExpect: () => void;
53
17
  state: {
54
18
  isExpect: boolean;
@@ -0,0 +1,73 @@
1
+ import type { LatestContainer, ControlEvent, LatestControl, LatestChapterBranch, ContainerEvent, ChapterEvent } from '../../../movika.core/manifest';
2
+ import type { EventEmitter } from '../../../utils/EventEmitter';
3
+ import type { IPlayer } from '@vkontakte/videoplayer-core';
4
+ import type { InteractiveEventsType } from './InteractiveEvents';
5
+ export type SubjectName = 'chapter' | 'container' | 'control';
6
+ export type SelectBranchesArg = {
7
+ globalEventEmitter: EventEmitter;
8
+ player: IPlayer;
9
+ interactiveEvents: InteractiveEventsType;
10
+ removeControllers?: AnyFn;
11
+ };
12
+ export type OnControlEventArg = {
13
+ action: ControlEvent['action'];
14
+ controlType: LatestControl['type'];
15
+ controlId: LatestControl['id'];
16
+ containerId: LatestContainer['id'];
17
+ onEvent: AnyFn;
18
+ branches?: LatestChapterBranch[];
19
+ isEOV?: () => boolean;
20
+ isDisabled?: () => boolean;
21
+ };
22
+ export type OnContainerEventArg = {
23
+ action: ContainerEvent['action'];
24
+ container: LatestContainer;
25
+ autoSelected?: boolean;
26
+ branches?: LatestChapterBranch[];
27
+ isEOV?: boolean;
28
+ };
29
+ export type OnChapterEventArg = {
30
+ action: ChapterEvent['action'];
31
+ chapterId: string;
32
+ branches?: LatestChapterBranch[];
33
+ };
34
+ export type SetManifestContainerEventsArg = {
35
+ container: LatestContainer;
36
+ branches: LatestChapterBranch[];
37
+ isEOV?: boolean;
38
+ };
39
+ export type AnyAction = ControlEvent['action'] | ContainerEvent['action'] | ChapterEvent['action'];
40
+ export type ActionMap = {
41
+ control: ControlEvent['action'];
42
+ container: ContainerEvent['action'];
43
+ chapter: ChapterEvent['action'];
44
+ };
45
+ export type SubjectType<T extends keyof ActionMap> = T extends 'control' ? LatestControl['type'] : undefined;
46
+ export type EventActionCommon<T extends keyof ActionMap> = {
47
+ subjectId: string;
48
+ subjectName: T;
49
+ subjectType?: SubjectType<T>;
50
+ };
51
+ export type EventActionCommonWithAction<T extends keyof ActionMap> = EventActionCommon<T> & {
52
+ action: ActionMap[T];
53
+ };
54
+ export type OpenURIArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
55
+ payload: {
56
+ URI?: string;
57
+ };
58
+ };
59
+ export type ChangeManifestArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
60
+ payload: {
61
+ behaviour?: string;
62
+ };
63
+ };
64
+ export type ChangeChapterArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
65
+ payload: {
66
+ chapterId: string;
67
+ autoSelect: boolean;
68
+ behaviour?: string;
69
+ };
70
+ };
71
+ export type ContinuePlaybackArg<T extends keyof ActionMap> = EventActionCommonWithAction<T>;
72
+ export type OnExpectEventArg<T extends keyof ActionMap> = EventActionCommon<T>;
73
+ export type ExpectEventHandlerArg<T extends keyof ActionMap> = EventActionCommon<T>;
@@ -5,6 +5,9 @@ export declare const EVENT_NAMES: {
5
5
  */
6
6
  readonly graph: "graph";
7
7
  readonly interactives: "interactives";
8
+ /**
9
+ * @deprecated Используйте interactivesInstance.events.chapterChanged$
10
+ */
8
11
  readonly chapterChanged: "chapter-changed";
9
12
  readonly playerChanged: "player-changed";
10
13
  readonly manifestChanged: "manifest-changed";
@@ -1,6 +1,23 @@
1
- export function getRandomNumber(limit: number): number;
2
- export function minFallbackStrategy(branches: any[]): string;
3
- export function maxFallbackStrategy(branches: any): string;
4
- export function defaultFallbackStrategy(branches: any[]): string;
5
- export function weightlessRandomFallbackStrategy(branches: any[]): string;
6
- export function weightyRandomFallbackStrategy(branches: any): any;
1
+ import { type LatestChapterBranch } from '../../../movika.core/manifest';
2
+ /**
3
+ * Returns a random number in the range [0, limit) or [limit, 0) if the 'limit'
4
+ * value is negative
5
+ */
6
+ export declare const getRandomNumber: (limit: number) => number;
7
+ /**
8
+ * Finds the value with minimal weight number
9
+ */
10
+ export declare const minFallbackStrategy: (branches: LatestChapterBranch[]) => Nullable<import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterBranch>;
11
+ /**
12
+ * Finds the value with maximal weight number
13
+ */
14
+ export declare const maxFallbackStrategy: (branches: LatestChapterBranch[]) => Nullable<import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterBranch>;
15
+ /**
16
+ * Finds first branch with `isDefault === true` value
17
+ */
18
+ export declare const defaultFallbackStrategy: (branches: LatestChapterBranch[]) => import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterBranch | undefined;
19
+ /**
20
+ * Returns the random branch
21
+ */
22
+ export declare const weightlessRandomFallbackStrategy: (branches: LatestChapterBranch[]) => import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterBranch;
23
+ export declare const weightyRandomFallbackStrategy: (branches: LatestChapterBranch[]) => import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterBranch;
@@ -1,26 +1,28 @@
1
- export function excludeTextControl(containers?: any[]): any[];
2
- export const gameStates: Readonly<{
3
- nothing: 0;
4
- beforeInteractive: 1;
5
- interactive: 2;
6
- afterInteractive: 3;
7
- end: 4;
8
- removed: 5;
9
- destroyed: 6;
10
- }>;
11
- export function isControlsExist(controls: any): boolean;
12
- export function isLastChapter(chapter: any): boolean;
13
- export function hasEndTemplate(chapter: any): boolean;
14
- export function isBeforeStartTime(currentTime: any, container: any): boolean;
15
- export function isInteractiveTime(currentTime: any, container: any): boolean;
16
- export function isAfterInteractiveTime(currentTime: any, container: any): boolean;
17
- export function isExpectEvent(events: any): any;
18
- export function getExpectEvent(events: any): any;
19
- export function isOneCtrlOneContainer(controls: any): boolean;
20
- export function isOneTextCtrlContainer(controls: any): boolean;
21
- export function isEOVEndTime(target: any, endTime: any): boolean;
22
- export function partial({ fn, type }: {
23
- fn: any;
24
- type?: number | undefined;
25
- }, ...presetArgs: any[]): (...laterArgs: any[]) => any;
26
- export function shouldIgnoreContainerEvent(container: any, gameControllers: any): any;
1
+ import { type LatestControl, type LatestChapter, type LatestContainer } from '../../../movika.core/manifest';
2
+ import type { GameController } from './GameController';
3
+ export declare enum GameStates {
4
+ nothing = 0,
5
+ beforeInteractive = 1,
6
+ interactive = 2,
7
+ afterInteractive = 3,
8
+ end = 4,
9
+ removed = 5,
10
+ destroyed = 6
11
+ }
12
+ export declare const isControlsExist: (controls: LatestControl[]) => boolean;
13
+ export declare const isLastChapter: (chapter: LatestChapter) => boolean;
14
+ export declare const hasEndTemplate: (chapter: LatestChapter) => boolean;
15
+ export declare const isBeforeStartTime: (currentTime: number, container: LatestContainer) => boolean;
16
+ export declare const isInteractiveTime: (currentTime: number, container: LatestContainer) => boolean;
17
+ export declare const isAfterInteractiveTime: (currentTime: number, container: LatestContainer) => boolean;
18
+ type AnyEvent = LatestContainer['events'] | LatestChapter['events'] | LatestControl['events'];
19
+ export declare const isExpectEvent: (events?: AnyEvent) => boolean;
20
+ export declare const getExpectEvent: (events?: AnyEvent) => import("../../../movika.core/manifest").ControlEvent | import("../../../movika.core/manifest").ChapterEvent | import("../../../movika.core/manifest").ContainerEvent | undefined;
21
+ export declare const isOneCtrlOneContainer: (controls: LatestControl[]) => boolean;
22
+ export declare const isOneTextCtrlContainer: (controls: LatestControl[]) => boolean;
23
+ export declare function excludeTextControl(containers?: LatestContainer[]): import("../../../movika.core/manifest/manifest_3_3/chapter").ChapterContainer[];
24
+ export declare const isEOVEndTime: (target: HTMLVideoElement, endTime: LatestContainer["endTime"]) => boolean;
25
+ export declare function partial<T extends unknown[], U extends unknown[], R>(fn: (...args: [...T, ...U]) => R, ...presetArgs: T): (...laterArgs: U) => R;
26
+ export declare function partial<T extends Record<string, unknown>, P extends Partial<T>>(fn: (args: T) => unknown, presetArgs: P): (laterArgs: Omit<T, keyof P>) => ReturnType<typeof fn>;
27
+ export declare const shouldIgnoreContainerEvent: (container: LatestContainer, gameControllers: GameController[]) => boolean;
28
+ export {};
@@ -1,62 +1,67 @@
1
- export const classnamesPrefix: "interactive";
2
- export const rootElClassName: "interactive-controls-container";
3
- export function getRootEl(): Element | null;
4
- export const DISABLE_OPACITY: 0.4;
5
- export namespace controlStylesFallbacks {
6
- let textColor: string;
7
- let textSize: number;
8
- let textContent: string;
9
- let roundCorners: number;
10
- let borderWidth: number;
11
- let borderColor: string;
12
- let borderAlpha: number;
13
- let backgroundColor: string;
14
- let backgroundAlpha: number;
15
- let innerSizesDependOn: string;
16
- let angle: number;
1
+ import { type LatestControl } from '../../../movika.core/manifest';
2
+ import { type Dimensions } from '../../../modules/Interactives/controls';
3
+ export declare const classnamesPrefix = "interactive";
4
+ export declare const rootElClassName = "interactive-controls-container";
5
+ export declare const getRootEl: () => Element | null;
6
+ export declare const DISABLE_OPACITY = 0.4;
7
+ export declare const controlStylesFallbacks: {
8
+ textColor: string;
9
+ textSize: number;
10
+ textContent: string;
11
+ roundCorners: number;
12
+ borderWidth: number;
13
+ borderColor: string;
14
+ borderAlpha: number;
15
+ backgroundColor: string;
16
+ backgroundAlpha: number;
17
+ innerSizesDependOn: string;
18
+ angle: number;
19
+ };
20
+ type ControlStylesFallbacks = typeof controlStylesFallbacks;
21
+ export declare enum ALIGN_ITEMS {
22
+ top = "flex-start",
23
+ bottom = "flex-end",
24
+ center = "center"
17
25
  }
18
- export namespace ALIGN_ITEMS {
19
- let top: string;
20
- let bottom: string;
21
- let center: string;
26
+ export declare enum JUSTIFY_CONTENT {
27
+ start = "flex-start",
28
+ end = "flex-end",
29
+ center = "center"
22
30
  }
23
- export namespace JUSTIFY_CONTENT {
24
- export let start: string;
25
- export let end: string;
26
- let center_1: string;
27
- export { center_1 as center };
31
+ export declare enum TEXT_ALIGN {
32
+ start = "left",
33
+ end = "right",
34
+ center = "center"
28
35
  }
29
- export namespace TEXT_ALIGN {
30
- let start_1: string;
31
- export { start_1 as start };
32
- let end_1: string;
33
- export { end_1 as end };
34
- let center_2: string;
35
- export { center_2 as center };
36
- }
37
- export function setTextPositionStyles({ target, props }: {
38
- target: any;
39
- props: any;
40
- }): void;
41
- export function setTextStyles({ target, props, fallback, dependsOn }: {
42
- target: any;
43
- props: any;
44
- fallback: any;
45
- dependsOn: any;
46
- }): void;
47
- export function setBackgroundStyles({ target, props, fallback }: {
48
- target: any;
49
- props: any;
50
- fallback: any;
51
- }): void;
52
- export function setBorderStyles({ target, props, fallback, dependsOn }: {
53
- target: any;
54
- props: any;
55
- fallback: any;
56
- dependsOn: any;
57
- }): void;
58
- export function setAngle({ target, layoutParams, fallback }: {
59
- target: any;
60
- layoutParams: any;
61
- fallback: any;
62
- }): void;
36
+ type SetTextPositionStylesProps = {
37
+ target: HTMLElement;
38
+ props: LatestControl['props'];
39
+ };
40
+ export declare const setTextPositionStyles: ({ target, props }: SetTextPositionStylesProps) => void;
41
+ type SetTextStylesProps = {
42
+ target: HTMLElement;
43
+ props: LatestControl['props'];
44
+ fallback: ControlStylesFallbacks;
45
+ dependsOn: Dimensions;
46
+ };
47
+ export declare const setTextStyles: ({ target, props, fallback, dependsOn }: SetTextStylesProps) => void;
48
+ type SetBackgroundStylesProps = {
49
+ target: HTMLElement;
50
+ props: LatestControl['props'];
51
+ fallback: ControlStylesFallbacks;
52
+ };
53
+ export declare const setBackgroundStyles: ({ target, props, fallback }: SetBackgroundStylesProps) => void;
54
+ type SetBorderStylesProps = {
55
+ target: HTMLElement;
56
+ props: LatestControl['props'];
57
+ fallback: ControlStylesFallbacks;
58
+ dependsOn: Dimensions;
59
+ };
60
+ export declare const setBorderStyles: ({ target, props, fallback, dependsOn }: SetBorderStylesProps) => void;
61
+ type SetAngleProps = {
62
+ target: HTMLElement;
63
+ fallback: ControlStylesFallbacks;
64
+ layoutParams: LatestControl['layoutParams'];
65
+ };
66
+ export declare const setAngle: ({ target, layoutParams, fallback }: SetAngleProps) => void;
67
+ export {};
@@ -1,7 +1,7 @@
1
1
  import type { IConfig, PlaybackRate, VideoQuality } from '@vkontakte/videoplayer-core';
2
2
  import { ValueSubject } from '@vkontakte/videoplayer-shared';
3
3
  import type { ManifestVideo, Extensions } from '../../movika.core/manifest';
4
- import { type Interactives } from '../../modules/Interactives';
4
+ import type { Interactives } from '../../modules/Interactives';
5
5
  import type { Instance } from './InstanceManager';
6
6
  interface CreatePlayerParams extends Omit<IConfig, 'sources' | 'container'> {
7
7
  media: ManifestVideo;
@@ -19,6 +19,10 @@ export type LatestManifest = Manifest_3_3;
19
19
  export type LatestContainer = ChapterContainer_3_3;
20
20
  export type LatestControl = Control;
21
21
  export type LatestControlLayoutParams = ControlLayoutParams;
22
+ export type LatestChapterBranch = ChapterBranch_3_3;
23
+ export type { ControlEvent } from './manifest_3_3/control';
24
+ export type { ContainerEvent } from './manifest_3_3/chapter';
25
+ export type { ChapterEvent } from './manifest_3_3/chapter';
22
26
  export * from './migrations';
23
27
  export * from './types';
24
28
  export * from './utils';
@@ -19,6 +19,7 @@ export interface ChapterBranch {
19
19
  chapterId: string;
20
20
  weight?: number;
21
21
  manifestUrl?: string;
22
+ isDefault?: boolean;
22
23
  }
23
24
  export interface ContainerEvent {
24
25
  type: ContainerEventType;
@@ -2,7 +2,7 @@ import type { Control } from './control';
2
2
  export type ChapterEventType = 'onSuspense';
3
3
  export type ContainerEventType = 'onSuspense';
4
4
  export type ChapterSuspenseActionType = 'setNextBranch' | 'setWeightlessRandomBranch' | 'setRandomBranch' | 'setMaxWeightBranch' | 'setMinWeightBranch' | 'setDefaultBranch' | 'continuePlayback' | 'openURI' | 'expect';
5
- export type ContainerSuspenseActionType = 'setNextBranch' | 'continuePlayback' | 'expect';
5
+ export type ContainerSuspenseActionType = 'setNextBranch' | 'continuePlayback' | 'expect' | 'openURI';
6
6
  export interface ChapterEvent {
7
7
  type: ChapterEventType;
8
8
  action: {
@@ -20,6 +20,7 @@ export interface ChapterBranch {
20
20
  chapterId: string;
21
21
  weight?: number;
22
22
  manifestUrl?: string;
23
+ isDefault?: boolean;
23
24
  }
24
25
  export interface ContainerEvent {
25
26
  type: ContainerEventType;
@@ -29,6 +30,7 @@ export interface ContainerEvent {
29
30
  branchId?: string;
30
31
  shouldOpenNow: boolean;
31
32
  isDetachContainer?: boolean;
33
+ uri?: string;
32
34
  };
33
35
  };
34
36
  }
@@ -1,29 +1,30 @@
1
- export type { Control } from './manifest_3_3/control';
2
1
  import type { Chapter } from './manifest_3_3/chapter';
3
- export declare const containerTypes: Readonly<{
4
- Choice: "Choice";
5
- TextInput: "TextInput";
6
- }>;
7
- export declare const controlTypes: Readonly<{
8
- Button: "Button";
9
- Area: "Area";
10
- Text: "Text";
11
- }>;
12
- export declare const eventTypes: Readonly<{
13
- onClick: "onClick";
14
- onSuspense: "onSuspense";
15
- }>;
16
- export declare const eventActionTypes: Readonly<{
17
- openURI: "openURI";
18
- setNextBranch: "setNextBranch";
19
- setWeightlessRandomBranch: "setWeightlessRandomBranch";
20
- setRandomBranch: "setRandomBranch";
21
- setMaxWeightBranch: "setMaxWeightBranch";
22
- setMinWeightBranch: "setMinWeightBranch";
23
- setDefaultBranch: "setDefaultBranch";
24
- continuePlayback: "continuePlayback";
25
- expect: "expect";
26
- }>;
2
+ export type { Control } from './manifest_3_3/control';
3
+ export declare const containerTypes: {
4
+ readonly Choice: "Choice";
5
+ readonly TextInput: "TextInput";
6
+ };
7
+ export declare const controlTypes: {
8
+ readonly Button: "Button";
9
+ readonly Area: "Area";
10
+ readonly Text: "Text";
11
+ };
12
+ export declare const eventTypes: {
13
+ readonly onClick: "onClick";
14
+ readonly onSuspense: "onSuspense";
15
+ };
16
+ export declare const eventActionTypes: {
17
+ readonly openURI: "openURI";
18
+ readonly setNextBranch: "setNextBranch";
19
+ readonly setWeightlessRandomBranch: "setWeightlessRandomBranch";
20
+ readonly setRandomBranch: "setRandomBranch";
21
+ readonly setMaxWeightBranch: "setMaxWeightBranch";
22
+ readonly setMinWeightBranch: "setMinWeightBranch";
23
+ readonly setDefaultBranch: "setDefaultBranch";
24
+ readonly continuePlayback: "continuePlayback";
25
+ readonly expect: "expect";
26
+ };
27
+ export type EventActionTypes = typeof eventActionTypes[keyof typeof eventActionTypes];
27
28
  export type VideoId = number | string;
28
29
  export type ChapterContainers = Chapter['containers'];
29
30
  export type { Chapter } from './manifest_3_3/chapter';