@vkontakte/videoplayer-interactive 1.0.63-dev.fcdd1bac.0 → 1.0.63

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 (154) hide show
  1. package/es2015.cjs +286 -0
  2. package/es2015.esm.js +286 -0
  3. package/es2018.cjs +286 -0
  4. package/es2018.esm.js +286 -0
  5. package/es2024.cjs +286 -0
  6. package/es2024.esm.js +286 -0
  7. package/esnext.cjs +286 -0
  8. package/esnext.esm.js +286 -0
  9. package/evergreen.esm.js +286 -0
  10. package/package.json +32 -9
  11. package/types/index.d.ts +11 -2
  12. package/{manifest → types/manifest}/index.d.ts +3 -3
  13. package/types/manifest/utils.d.ts +48 -0
  14. package/types/modules/Graph/Graph.d.ts +54 -0
  15. package/types/modules/Graph/index.d.ts +1 -0
  16. package/types/modules/Interactives/Interactives.d.ts +143 -0
  17. package/types/modules/Interactives/Layout.d.ts +16 -0
  18. package/types/modules/Interactives/containers/ChoiceContainer.d.ts +34 -0
  19. package/types/modules/Interactives/containers/Container.d.ts +21 -0
  20. package/types/modules/Interactives/containers/index.d.ts +4 -0
  21. package/types/modules/Interactives/containers/types.d.ts +11 -0
  22. package/{modules → types/modules}/Interactives/containers/utils.d.ts +3 -3
  23. package/types/modules/Interactives/controls/AreaControl.d.ts +21 -0
  24. package/types/modules/Interactives/controls/ButtonControl.d.ts +25 -0
  25. package/types/modules/Interactives/controls/Control.d.ts +48 -0
  26. package/types/modules/Interactives/controls/TextControl.d.ts +18 -0
  27. package/types/modules/Interactives/controls/index.d.ts +6 -0
  28. package/types/modules/Interactives/controls/types.d.ts +38 -0
  29. package/types/modules/Interactives/controls/utils.d.ts +14 -0
  30. package/types/modules/Interactives/index.d.ts +16 -0
  31. package/types/modules/Interactives/styles/index.d.ts +1 -0
  32. package/types/modules/Interactives/types.d.ts +79 -0
  33. package/types/modules/Interactives/utils/BlinkAnimationRef.d.ts +15 -0
  34. package/types/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +34 -0
  35. package/types/modules/Interactives/utils/ControlFillAnimation/index.d.ts +1 -0
  36. package/types/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +12 -0
  37. package/types/modules/Interactives/utils/ControlTap/ControlTap.d.ts +17 -0
  38. package/types/modules/Interactives/utils/ControlTap/index.d.ts +1 -0
  39. package/{modules → types/modules}/Interactives/utils/ControlTap/utils.d.ts +3 -3
  40. package/types/modules/Interactives/utils/GameController.d.ts +71 -0
  41. package/types/modules/Interactives/utils/GroupsStack.d.ts +30 -0
  42. package/types/modules/Interactives/utils/HistoryController.d.ts +51 -0
  43. package/types/modules/Interactives/utils/InteractiveEvents.d.ts +32 -0
  44. package/types/modules/Interactives/utils/ResizeManager.d.ts +15 -0
  45. package/types/modules/Interactives/utils/SelectBranches.d.ts +23 -0
  46. package/types/modules/Interactives/utils/SelectBranches.types.d.ts +78 -0
  47. package/{modules → types/modules}/Interactives/utils/angleUtils.d.ts +12 -12
  48. package/types/modules/Interactives/utils/createControlText.d.ts +4 -0
  49. package/types/modules/Interactives/utils/emitOnError.d.ts +13 -0
  50. package/types/modules/Interactives/utils/events.d.ts +79 -0
  51. package/types/modules/Interactives/utils/events.types.d.ts +55 -0
  52. package/{modules → types/modules}/Interactives/utils/fallbackStrategies.d.ts +13 -13
  53. package/types/modules/Interactives/utils/functionUtils.d.ts +12 -0
  54. package/{modules → types/modules}/Interactives/utils/gameUtils.d.ts +20 -20
  55. package/{modules → types/modules}/Interactives/utils/getInteractiveRanges.d.ts +5 -5
  56. package/types/modules/Interactives/utils/renderingUtils.d.ts +75 -0
  57. package/types/modules/Loaders/index.d.ts +1 -0
  58. package/types/modules/Loaders/movikaProjectIdLoader/index.d.ts +1 -0
  59. package/types/modules/Loaders/vkVideoLoader/CustomVkVideoLoader.d.ts +10 -0
  60. package/types/modules/Loaders/vkVideoLoader/index.d.ts +1 -0
  61. package/types/modules/Loaders/vkVideoLoader/types.d.ts +257 -0
  62. package/{modules → types/modules}/Loaders/vkVideoLoader/utils.d.ts +1 -1
  63. package/{modules → types/modules}/ManifestController/Loadable.d.ts +5 -5
  64. package/types/modules/ManifestController/ManifestController.d.ts +34 -0
  65. package/types/modules/ManifestController/index.d.ts +1 -0
  66. package/{modules → types/modules}/ManifestController/utils.d.ts +5 -5
  67. package/types/modules/SeamlessController/InstanceManager.d.ts +15 -0
  68. package/types/modules/SeamlessController/SeamlessController.d.ts +33 -0
  69. package/types/modules/SeamlessController/utils.d.ts +9 -0
  70. package/types/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +10 -0
  71. package/types/modules/SeekToInteractiveController/index.d.ts +1 -0
  72. package/types/types/CustomError.d.ts +13 -0
  73. package/types/types/index.d.ts +2 -0
  74. package/types/utils/CssVarsManager.d.ts +23 -0
  75. package/types/utils/Error.d.ts +8 -0
  76. package/types/utils/EventEmitter.d.ts +12 -0
  77. package/types/utils/LastFrame.d.ts +35 -0
  78. package/types/utils/LastFrameCanvasAPI.d.ts +19 -0
  79. package/types/utils/MultiMap.d.ts +10 -0
  80. package/types/utils/Raf.d.ts +13 -0
  81. package/{utils → types/utils}/chapterHelpers.d.ts +1 -1
  82. package/types/utils/compareVersions.d.ts +14 -0
  83. package/{utils → types/utils}/extractVkMovieId.d.ts +1 -1
  84. package/types/utils/getVideoContentSize.d.ts +5 -0
  85. package/{utils → types/utils}/hexToRgb.d.ts +2 -2
  86. package/{utils → types/utils}/typeCheck.d.ts +6 -6
  87. package/index.d.ts +0 -11
  88. package/manifest/utils.d.ts +0 -48
  89. package/modules/Graph/Graph.d.ts +0 -54
  90. package/modules/Graph/index.d.ts +0 -1
  91. package/modules/Interactives/Interactives.d.ts +0 -143
  92. package/modules/Interactives/Layout.d.ts +0 -16
  93. package/modules/Interactives/containers/ChoiceContainer.d.ts +0 -34
  94. package/modules/Interactives/containers/Container.d.ts +0 -21
  95. package/modules/Interactives/containers/index.d.ts +0 -4
  96. package/modules/Interactives/containers/types.d.ts +0 -11
  97. package/modules/Interactives/controls/AreaControl.d.ts +0 -21
  98. package/modules/Interactives/controls/ButtonControl.d.ts +0 -25
  99. package/modules/Interactives/controls/Control.d.ts +0 -48
  100. package/modules/Interactives/controls/TextControl.d.ts +0 -18
  101. package/modules/Interactives/controls/index.d.ts +0 -6
  102. package/modules/Interactives/controls/types.d.ts +0 -35
  103. package/modules/Interactives/controls/utils.d.ts +0 -14
  104. package/modules/Interactives/index.d.ts +0 -16
  105. package/modules/Interactives/styles/index.d.ts +0 -1
  106. package/modules/Interactives/types.d.ts +0 -79
  107. package/modules/Interactives/utils/BlinkAnimationRef.d.ts +0 -15
  108. package/modules/Interactives/utils/ControlFillAnimation/ControlFillAnimation.d.ts +0 -34
  109. package/modules/Interactives/utils/ControlFillAnimation/index.d.ts +0 -1
  110. package/modules/Interactives/utils/ControlFillAnimation/utils.d.ts +0 -12
  111. package/modules/Interactives/utils/ControlTap/ControlTap.d.ts +0 -17
  112. package/modules/Interactives/utils/ControlTap/index.d.ts +0 -1
  113. package/modules/Interactives/utils/GameController.d.ts +0 -71
  114. package/modules/Interactives/utils/GroupsStack.d.ts +0 -32
  115. package/modules/Interactives/utils/HistoryController.d.ts +0 -52
  116. package/modules/Interactives/utils/InteractiveEvents.d.ts +0 -32
  117. package/modules/Interactives/utils/ResizeManager.d.ts +0 -15
  118. package/modules/Interactives/utils/SelectBranches.d.ts +0 -23
  119. package/modules/Interactives/utils/SelectBranches.types.d.ts +0 -78
  120. package/modules/Interactives/utils/createControlText.d.ts +0 -4
  121. package/modules/Interactives/utils/emitOnError.d.ts +0 -13
  122. package/modules/Interactives/utils/events.d.ts +0 -79
  123. package/modules/Interactives/utils/events.types.d.ts +0 -52
  124. package/modules/Interactives/utils/functionUtils.d.ts +0 -5
  125. package/modules/Interactives/utils/renderingUtils.d.ts +0 -75
  126. package/modules/Loaders/index.d.ts +0 -1
  127. package/modules/Loaders/movikaProjectIdLoader/index.d.ts +0 -1
  128. package/modules/Loaders/vkVideoLoader/CustomVkVideoLoader.d.ts +0 -10
  129. package/modules/Loaders/vkVideoLoader/index.d.ts +0 -1
  130. package/modules/Loaders/vkVideoLoader/types.d.ts +0 -257
  131. package/modules/ManifestController/ManifestController.d.ts +0 -34
  132. package/modules/ManifestController/index.d.ts +0 -1
  133. package/modules/SeamlessController/InstanceManager.d.ts +0 -15
  134. package/modules/SeamlessController/SeamlessController.d.ts +0 -34
  135. package/modules/SeamlessController/utils.d.ts +0 -9
  136. package/modules/SeekToInteractiveController/SeekToInteractiveController.d.ts +0 -10
  137. package/modules/SeekToInteractiveController/index.d.ts +0 -1
  138. package/types/CustomError.d.ts +0 -13
  139. package/utils/CssVarsManager.d.ts +0 -23
  140. package/utils/Error.d.ts +0 -8
  141. package/utils/EventEmitter.d.ts +0 -12
  142. package/utils/LastFrame.d.ts +0 -35
  143. package/utils/LastFrameCanvasAPI.d.ts +0 -19
  144. package/utils/MultiMap.d.ts +0 -10
  145. package/utils/Raf.d.ts +0 -13
  146. package/utils/compareVersions.d.ts +0 -14
  147. package/utils/getVideoContentSize.d.ts +0 -5
  148. /package/{constants.d.ts → types/constants.d.ts} +0 -0
  149. /package/{env.d.ts → types/env.d.ts} +0 -0
  150. /package/{modules → types/modules}/Interactives/styles/utils.d.ts +0 -0
  151. /package/{modules → types/modules}/Loaders/movikaProjectIdLoader/movikaProjectIdLoader.d.ts +0 -0
  152. /package/types/{dom.d.ts → types/dom.d.ts} +0 -0
  153. /package/{utils → types/utils}/debounce.d.ts +0 -0
  154. /package/{utils → types/utils}/throttle.d.ts +0 -0
@@ -0,0 +1,17 @@
1
+ type Options = {
2
+ controlRotateAngleRad: number;
3
+ circleDiameterPx?: number;
4
+ useDimensionsBasedSize?: boolean;
5
+ clickCancelCondition: () => boolean;
6
+ };
7
+ export declare class ControlTap {
8
+ element: HTMLDivElement;
9
+ controlRotateAngleRad: number;
10
+ clickCancelCondition: () => boolean;
11
+ circleDiameterPx: number;
12
+ useDimensionsBasedSize: boolean;
13
+ constructor({ controlRotateAngleRad, clickCancelCondition, circleDiameterPx, useDimensionsBasedSize }: Options);
14
+ onElementClick: (e: MouseEvent) => void;
15
+ onAnimationEnd: (e: TransitionEvent) => void;
16
+ }
17
+ export {};
@@ -0,0 +1 @@
1
+ export * from "./ControlTap";
@@ -1,6 +1,6 @@
1
1
  export declare const CONTROL_TAP_CLASSNAME_PREFIX = "interactive-control-tap";
2
2
  export declare const controlTapClassNames: {
3
- common: string;
4
- animation: string;
5
- visible: string;
3
+ common: string;
4
+ animation: string;
5
+ visible: string;
6
6
  };
@@ -0,0 +1,71 @@
1
+ import { type ISubscription, type IValueSubject } from "@vkontakte/videoplayer-shared";
2
+ import { type IPlayer } from "@vkontakte/videoplayer-core";
3
+ import type { InteractiveEventsType } from "./InteractiveEvents";
4
+ import type { ChapterBranch } from "../../../manifest";
5
+ import type { EventEmitter } from "../../../utils/EventEmitter";
6
+ import type { CustomError } from "../../../utils/Error";
7
+ import type { SelectBranchesType } from "./SelectBranches";
8
+ import type { IgnoreExpectState, AnimationsFeatureToggles, IInteractiveOptions } from "../types";
9
+ import type { ChoiceContainer } from "../containers";
10
+ import { type GlobalEvents } from "./events";
11
+ import { GameStates } from "./gameUtils";
12
+ type Features = Pick<AnimationsFeatureToggles, "controlsHideAnimation"> & Pick<IInteractiveOptions, "enableAvPlayerSupport">;
13
+ type ConstructorArg = {
14
+ player: IPlayer;
15
+ container: ChoiceContainer;
16
+ branches: ChapterBranch[];
17
+ selectBranches: ReturnType<SelectBranchesType>;
18
+ interactiveEvents: InteractiveEventsType;
19
+ globalEventEmitter: EventEmitter;
20
+ globalEvents: GlobalEvents;
21
+ getContainerEventState: () => IgnoreExpectState;
22
+ permanentTextControls: boolean;
23
+ interactiveTimeOpenUri: boolean;
24
+ disabledControls$: IValueSubject<boolean>;
25
+ onRemove: () => void;
26
+ onError: (error: CustomError) => void;
27
+ disableTextControlContainerVisibilityEvents?: boolean;
28
+ features: Features;
29
+ };
30
+ export declare class GameController {
31
+ container: ChoiceContainer;
32
+ branches: ChapterBranch[];
33
+ selectBranches: ReturnType<SelectBranchesType>;
34
+ subscription: ISubscription;
35
+ player: IPlayer;
36
+ interactiveEvents: InteractiveEventsType;
37
+ getContainerEventState: () => IgnoreExpectState;
38
+ isPermanentText: boolean;
39
+ interactiveTimeOpenUri: boolean;
40
+ disabledControls$: IValueSubject<boolean>;
41
+ onRemove: () => void;
42
+ globalEventEmitter: EventEmitter;
43
+ gameState: GameStates;
44
+ isSelectedControlEvent: boolean;
45
+ isSelectedContainerEvent: boolean;
46
+ globalEvents: GlobalEvents;
47
+ onError: ConstructorArg["onError"];
48
+ disableTextControlContainerVisibilityEvents: boolean;
49
+ features: Features;
50
+ constructor({ player, container, branches, selectBranches, interactiveEvents, globalEvents, globalEventEmitter, getContainerEventState, permanentTextControls, interactiveTimeOpenUri, disabledControls$, onRemove, onError, disableTextControlContainerVisibilityEvents, features }: ConstructorArg);
51
+ private emitContainerVisibilityEvent;
52
+ registerEvents(): void;
53
+ hide: () => void;
54
+ show: () => void;
55
+ selectContainerEvent(isEOV?: boolean): void;
56
+ onStartTime(): void;
57
+ onEndTime(): void;
58
+ onBeforeStartTime(): void;
59
+ onEndOfVideo: () => void;
60
+ whilePlaying: () => void;
61
+ onResize(isInteractiveTime: boolean): void;
62
+ reset(): void;
63
+ removeView(withTransition?: boolean | undefined): void;
64
+ fakeRemoveView(remove?: boolean): void;
65
+ updateControlsShadowStyles(isDark?: boolean): void;
66
+ toggleBlinkAnimation(value: boolean): void;
67
+ isInteracted(): boolean;
68
+ isRemovedOrDestroyed(includeWillRemovedState?: boolean): boolean;
69
+ destroy(withTransition?: boolean): void;
70
+ }
71
+ export {};
@@ -0,0 +1,30 @@
1
+ import type { EventActionKeys } from "../../../manifest";
2
+ export type TPriority = "chapter" | "container" | "control";
3
+ export type TPayload = {
4
+ actionType: EventActionKeys;
5
+ action: AnyFn;
6
+ };
7
+ export type TMapInitiator = {
8
+ [initiator: string]: TPayload[];
9
+ };
10
+ type TMapPriority = { [priority in TPriority]? : TMapInitiator };
11
+ type TMap = {
12
+ [timestamp: number]: TMapPriority;
13
+ };
14
+ export type TMapFlattened = {
15
+ timestamp: number;
16
+ priority: TPriority;
17
+ initiator: string;
18
+ } & TPayload;
19
+ type GetAndRemoveArgType = Partial<Omit<TMapFlattened, keyof TPayload>> & Pick<TMapFlattened, "timestamp">;
20
+ export type TGroupsStack = ReturnType<typeof GroupsStack>;
21
+ export declare function GroupsStack(): {
22
+ map: TMap;
23
+ remove: (args: GetAndRemoveArgType) => boolean;
24
+ add: (args: TMapFlattened) => void;
25
+ removeAll: () => void;
26
+ get: (args: GetAndRemoveArgType) => TMapPriority | TMapInitiator | TPayload[] | null;
27
+ getLte: (timestamp: number) => TMap;
28
+ getGte: (timestamp: number) => TMap;
29
+ };
30
+ export {};
@@ -0,0 +1,51 @@
1
+ import { Subject } from "@vkontakte/videoplayer-shared";
2
+ import type { IValueSubject, Nullable } from "@vkontakte/videoplayer-shared";
3
+ import type { EventEmitter } from "../../../utils/EventEmitter";
4
+ import type { Manifest, VideoId } from "../../../manifest";
5
+ import type { VideoInfo } from "..";
6
+ import type { Interactives } from "..";
7
+ import { CustomError } from "../../../utils/Error";
8
+ export interface HistoryApi {
9
+ get: (rawId: string) => Promise<number[]>;
10
+ save: (rawId: string, videoIds: number[]) => Promise<void>;
11
+ }
12
+ export interface HistorySettings {
13
+ maxLength: number;
14
+ initChapterId?: string;
15
+ }
16
+ interface HistoryControllerParams {
17
+ globalEventEmitter: EventEmitter;
18
+ interactiveController: Interactives;
19
+ settings: HistorySettings;
20
+ videoId?: string;
21
+ historyApi?: Nullable<HistoryApi>;
22
+ }
23
+ export interface HistoryControllerState {
24
+ history$: IValueSubject<string[]>;
25
+ hasPrevChapter$: IValueSubject<boolean>;
26
+ prevChapter$: IValueSubject<Nullable<string>>;
27
+ isInitialChapter$: IValueSubject<boolean>;
28
+ isGoBackLimited$: IValueSubject<boolean>;
29
+ }
30
+ interface HistoryInitedEventData {
31
+ initChapterId: string;
32
+ videosInfo?: VideoInfo[];
33
+ }
34
+ export default class HistoryController {
35
+ #private;
36
+ state: HistoryControllerState;
37
+ events: {
38
+ inited$: Subject<HistoryInitedEventData>;
39
+ destroyed$: Subject<void>;
40
+ error$: Subject<CustomError>;
41
+ };
42
+ constructor({ globalEventEmitter, videoId, interactiveController, historyApi, settings }: HistoryControllerParams);
43
+ setManifest(manifest: Manifest): Promise<void>;
44
+ get inited(): boolean;
45
+ updateHistory(chapterIds: string[], shouldSave?: boolean): Promise<void>;
46
+ goBack(): Promise<void>;
47
+ getProjectHistory(): Promise<void>;
48
+ getInitialChapterId(): string;
49
+ getInitialVideoId(): VideoId | null;
50
+ destroy(): void;
51
+ }
@@ -0,0 +1,32 @@
1
+ import { type Container } from "../../../manifest";
2
+ import { type TPayload, type TGroupsStack } from "./GroupsStack";
3
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
4
+ type AddMethodParamType = Parameters<TGroupsStack["add"]>[0];
5
+ type RemoveMethodParamType = Parameters<TGroupsStack["remove"]>[0];
6
+ export interface ContainersEventsCallStateType {
7
+ setCalled: (args: {
8
+ timestamp: number;
9
+ id: string;
10
+ }) => void;
11
+ setData: (containers?: Container[]) => void;
12
+ resetCalled: (timestamp: number) => void;
13
+ isReady: (timestamp: number) => boolean;
14
+ release: () => void;
15
+ }
16
+ export interface InteractiveEventsType {
17
+ setPlayer: (player: IPlayer) => void;
18
+ add: (args: AddMethodParamType) => void;
19
+ remove: (args: RemoveMethodParamType) => void;
20
+ exec: (timestamp: number) => void;
21
+ execEndOfVideo: () => void;
22
+ listen: () => void;
23
+ unlisten: () => void;
24
+ release: () => void;
25
+ containersEventsCallState: ContainersEventsCallStateType;
26
+ getPreparedToExecActions: (timestamp?: number) => TPayload[];
27
+ }
28
+ /**
29
+ * Executes an events at different times of the current chapter
30
+ */
31
+ export declare function InteractiveEvents(player: IPlayer, interactiveTimeOpenUri: boolean): InteractiveEventsType;
32
+ export {};
@@ -0,0 +1,15 @@
1
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
2
+ import type { Nullable } from "@vkontakte/videoplayer-shared";
3
+ import type { CssVarsManager } from "../../../utils/CssVarsManager";
4
+ type ResizeManagerArg = () => {
5
+ parentElement: HTMLElement;
6
+ cssVarsManager: CssVarsManager;
7
+ player?: Nullable<IPlayer>;
8
+ fns?: AnyFn[];
9
+ };
10
+ export declare function ResizeManager(getOptions: ResizeManagerArg): {
11
+ resizeObserver: ResizeObserver;
12
+ calc: () => void;
13
+ release: () => void;
14
+ };
15
+ export {};
@@ -0,0 +1,23 @@
1
+ import type { Chapter } from "../../../manifest";
2
+ import type { SelectBranchesArg, OnControlEventArg, ChangeChapterArg, ContinuePlaybackArg, ExpectEventHandlerArg, OnChapterEventArg, OnContainerEventArg, OnExpectEventArg, SetManifestContainerEventsArg, OpenURIArg, ActionMap, AnyAction, AfterExpectActionType } from "./SelectBranches.types";
3
+ export declare const defaultArgs: {
4
+ readonly shouldOpenNow: true;
5
+ readonly isDetachContainer: true;
6
+ };
7
+ export declare const AFTER_EXPECT_ACTION: AfterExpectActionType;
8
+ export declare const extendArgs: <T extends AnyAction>(action: T, rewrite?: boolean) => T;
9
+ export type ExtendArgsReturnType = ReturnType<typeof extendArgs>;
10
+ export declare const SelectBranches: ({ globalEventEmitter, globalEvents, player, interactiveEvents }: SelectBranchesArg) => {
11
+ onControlEvent: (arg: OnControlEventArg) => void;
12
+ onContainerEvent: (arg: OnContainerEventArg) => void;
13
+ onChapterEvent: (arg: OnChapterEventArg) => (() => ChangeChapterArg<"chapter">) | (() => ContinuePlaybackArg<"chapter">) | (() => OpenURIArg<"chapter">) | undefined;
14
+ onExpectEvent: <T extends keyof ActionMap>(arg: OnExpectEventArg<T>) => void;
15
+ expectEventHandler: <T extends keyof ActionMap>(arg: ExpectEventHandlerArg<T>) => void;
16
+ setManifestChapterEvents: (chapter: Chapter) => void;
17
+ setManifestContainerEvents: (arg: SetManifestContainerEventsArg) => void;
18
+ stopExpect: () => void;
19
+ state: {
20
+ isExpect: boolean;
21
+ };
22
+ };
23
+ export type SelectBranchesType = typeof SelectBranches;
@@ -0,0 +1,78 @@
1
+ import type { ChapterContainer, Control, ChapterBranch, ControlEvent, ContainerEvent, ChapterEvent } from "../../../manifest";
2
+ import type { EventEmitter } from "../../../utils/EventEmitter";
3
+ import type { IPlayer } from "@vkontakte/videoplayer-core";
4
+ import type { InteractiveEventsType } from "./InteractiveEvents";
5
+ import type { GlobalEvents } from "./events";
6
+ import type { Nullable } from "@vkontakte/videoplayer-shared";
7
+ export type SubjectName = "chapter" | "container" | "control";
8
+ export type AfterExpectActionType = "after-expect";
9
+ export type Behaviour = "change-chapter" | "change-manifest";
10
+ export type ControlAfterExpectCallbackType = () => ExpectEventHandlerArg<"control">;
11
+ export type SelectBranchesArg = {
12
+ globalEventEmitter: EventEmitter;
13
+ globalEvents: GlobalEvents;
14
+ player: IPlayer;
15
+ interactiveEvents: InteractiveEventsType;
16
+ };
17
+ export type OnControlEventArg = {
18
+ action: ControlEvent["action"];
19
+ controlType: Control["type"];
20
+ controlId: Control["id"];
21
+ containerId: ChapterContainer["id"];
22
+ onEvent: AnyFn;
23
+ branches?: ChapterBranch[];
24
+ isEOV?: () => boolean;
25
+ isDisabled?: () => boolean;
26
+ };
27
+ export type OnContainerEventArg = {
28
+ action: ContainerEvent["action"];
29
+ container: ChapterContainer;
30
+ autoSelected?: boolean;
31
+ branches?: ChapterBranch[];
32
+ isEOV?: boolean;
33
+ };
34
+ export type OnChapterEventArg = {
35
+ action: ChapterEvent["action"];
36
+ chapterId: string;
37
+ branches?: ChapterBranch[];
38
+ };
39
+ export type SetManifestContainerEventsArg = {
40
+ container: ChapterContainer;
41
+ branches: ChapterBranch[];
42
+ isEOV?: boolean;
43
+ };
44
+ export type AnyAction = ControlEvent["action"] | ContainerEvent["action"] | ChapterEvent["action"];
45
+ export type ActionMap = {
46
+ control: ControlEvent["action"];
47
+ container: ContainerEvent["action"];
48
+ chapter: ChapterEvent["action"];
49
+ };
50
+ export type SubjectType<T extends keyof ActionMap> = T extends "control" ? Control["type"] : undefined;
51
+ export type EventActionCommon<T extends keyof ActionMap> = {
52
+ subjectId: string;
53
+ subjectName: T;
54
+ subjectType?: SubjectType<T>;
55
+ };
56
+ export type EventActionCommonWithAction<T extends keyof ActionMap> = EventActionCommon<T> & {
57
+ action: ActionMap[T];
58
+ };
59
+ export type OpenURIArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
60
+ payload: {
61
+ URI?: Nullable<string>;
62
+ };
63
+ };
64
+ export type ChangeManifestArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
65
+ payload: {
66
+ behaviour?: Behaviour;
67
+ };
68
+ };
69
+ export type ChangeChapterArg<T extends keyof ActionMap> = EventActionCommonWithAction<T> & {
70
+ payload: {
71
+ chapterId: string;
72
+ autoSelect: boolean;
73
+ behaviour?: Behaviour;
74
+ };
75
+ };
76
+ export type ContinuePlaybackArg<T extends keyof ActionMap> = EventActionCommonWithAction<T>;
77
+ export type OnExpectEventArg<T extends keyof ActionMap> = EventActionCommon<T>;
78
+ export type ExpectEventHandlerArg<T extends keyof ActionMap> = EventActionCommon<T>;
@@ -1,25 +1,25 @@
1
1
  /**
2
- * use normalizeRadians before use
3
- */
2
+ * use normalizeRadians before use
3
+ */
4
4
  export declare function isPositiveXAxis(angle: number): boolean;
5
5
  /**
6
- * use normalizeRadians before use
7
- */
6
+ * use normalizeRadians before use
7
+ */
8
8
  export declare function isPositiveYAxis(angle: number): boolean;
9
9
  /**
10
- * use normalizeRadians before use
11
- */
10
+ * use normalizeRadians before use
11
+ */
12
12
  export declare function isNegativeXAxis(angle: number): boolean;
13
13
  /**
14
- * use normalizeRadians before use
15
- */
14
+ * use normalizeRadians before use
15
+ */
16
16
  export declare function isNegativeYAxis(angle: number): boolean;
17
17
  /**
18
- * normalizes to [0, 2π)
19
- */
18
+ * normalizes to [0, 2π)
19
+ */
20
20
  export declare function normalizeRadians(rad: number): number;
21
21
  /**
22
- * use normalizeRadians before use
23
- */
22
+ * use normalizeRadians before use
23
+ */
24
24
  export declare function getQuadrant(rad: number): number | null;
25
25
  export declare function radiansToDegrees(rad: number): number;
@@ -0,0 +1,4 @@
1
+ import type { AnyControl } from "../../../manifest";
2
+ type Type = Lowercase<AnyControl["type"]> | AnyControl["type"];
3
+ export declare const createControlText: (type: Type) => HTMLElement;
4
+ export {};
@@ -0,0 +1,13 @@
1
+ import { ErrorCategoryEnum, ErrorSeverityEnum } from "../../../types";
2
+ import { CustomError } from "../../../utils/Error";
3
+ import type { Subject } from "@vkontakte/videoplayer-shared";
4
+ type EmitOnErrorArg = {
5
+ emitter$: Subject<CustomError>;
6
+ error?: unknown;
7
+ subjectId?: string;
8
+ message?: string;
9
+ severity?: ErrorSeverityEnum;
10
+ category?: ErrorCategoryEnum;
11
+ };
12
+ export declare function emitOnError({ emitter$, error, subjectId, message, severity, category }: EmitOnErrorArg): void;
13
+ export {};
@@ -0,0 +1,79 @@
1
+ import type { Subject } from "@vkontakte/videoplayer-shared";
2
+ import type { ChapterChangedData, EachTickData, PlayerChangedData } from "../types";
3
+ import type { CustomError } from "../../../utils/Error";
4
+ import type { Manifest } from "../../../manifest";
5
+ import type { TInteractiveRangeEndedEvent, TInteractivesActionChoiceEvent, TInteractivesActionExecutionEvent, TInteractivesContainerRemoved, TInteractivesContainerFakeRemoved, SubjectName, TInteractivesVisibility } from "./events.types";
6
+ export interface GlobalEvents {
7
+ noInteraction$: Subject<void>;
8
+ graphVisibilityChanged$: Subject<boolean>;
9
+ watchAgainIsClicked$: Subject<string>;
10
+ chapterChanged$: Subject<ChapterChangedData>;
11
+ playerChanged$: Subject<PlayerChangedData>;
12
+ error$: Subject<CustomError>;
13
+ eachTick$: Subject<EachTickData>;
14
+ manifestChanged$: Subject<Manifest>;
15
+ interactiveRangeEnded$: Subject<TInteractiveRangeEndedEvent>;
16
+ interactiveContainerRemoved$: Subject<TInteractivesContainerRemoved>;
17
+ interactiveContainerFakeRemoved$: Subject<TInteractivesContainerFakeRemoved>;
18
+ interactiveActionExecution$: Subject<TInteractivesActionExecutionEvent<SubjectName>>;
19
+ interactiveActionChoice$: Subject<TInteractivesActionChoiceEvent<SubjectName>>;
20
+ interactiveVisibilityChanged$: Subject<TInteractivesVisibility<"container">>;
21
+ }
22
+ export declare const EVENT_NAMES: {
23
+ /**
24
+ * @deprecated Используйте interactivesInstance.events.graphVisibilityChanged$
25
+ * & interactivesInstance.events.watchAgainIsClicked$
26
+ */
27
+ readonly graph: "graph";
28
+ /**
29
+ * @deprecated Используйте interactivesInstance.events
30
+ */
31
+ readonly interactives: "interactives";
32
+ /**
33
+ * @deprecated Используйте interactivesInstance.events.chapterChanged$
34
+ */
35
+ readonly chapterChanged: "chapter-changed";
36
+ /**
37
+ * @deprecated Используйте interactivesInstance.events.playerChanged$
38
+ */
39
+ readonly playerChanged: "player-changed";
40
+ /**
41
+ * @deprecated Используйте interactivesInstance.events.manifestChanged$
42
+ */
43
+ readonly manifestChanged: "manifest-changed";
44
+ /**
45
+ * @deprecated Используйте interactivesInstance.events.error$
46
+ */
47
+ readonly errors: "errors";
48
+ readonly eachTick: "eachTick";
49
+ readonly historyInited: "history-inited";
50
+ readonly historyDestroyed: "history-destroyed";
51
+ };
52
+ /**
53
+ * @deprecated Используйте interactivesInstance.events.graphVisibilityChanged$ &
54
+ * interactivesInstance.events.watchAgainIsClicked$
55
+ */
56
+ export declare const graphEventTypes: {
57
+ readonly visibility: "visibility";
58
+ readonly watchAgainClicked: "watchAgainClicked";
59
+ };
60
+ /**
61
+ * @deprecated use InteractivesEventTypes enum instead
62
+ */
63
+ export declare const interactivesEventTypes: {
64
+ readonly actionChoiceCanceled: "action-choice-canceled";
65
+ readonly actionChoice: "action-choice";
66
+ readonly actionExecution: "action-execution";
67
+ readonly visibility: "visibility";
68
+ readonly containerRemoved: "container-removed";
69
+ readonly rangeEnded: "range-ended";
70
+ };
71
+ export declare enum InteractivesEventTypes {
72
+ ACTION_CHOICE_CANCELED = "action-choice-canceled",
73
+ ACTION_CHOICE = "action-choice",
74
+ ACTION_EXECUTION = "action-execution",
75
+ VISIBILITY = "visibility",
76
+ CONTAINER_REMOVED = "container-removed",
77
+ CONTAINER_FAKE_REMOVED = "container-fake-removed",
78
+ RANGE_ENDED = "range-ended"
79
+ }
@@ -0,0 +1,55 @@
1
+ import type { SubjectName, ActionMap, SubjectType, AfterExpectActionType, Behaviour } from "./SelectBranches.types";
2
+ import type { InteractivesEventTypes } from "./events";
3
+ import type { EventActionTypes } from "../../../manifest";
4
+ import type { ControlEvent, ContainerEvent, ChapterEvent, ChapterContainer, Control } from "../../../manifest";
5
+ import type { InteractiveRange } from "./getInteractiveRanges";
6
+ export type { SubjectName };
7
+ type InteractivesEventTypesValues = `${InteractivesEventTypes}`;
8
+ type InteractivesEventTypesValuesChapter = InteractivesEventTypes.ACTION_CHOICE | InteractivesEventTypes.ACTION_CHOICE_CANCELED | InteractivesEventTypes.ACTION_EXECUTION;
9
+ type InteractivesEventTypesValuesContainer = InteractivesEventTypesValues;
10
+ type InteractivesEventTypesValuesControl = InteractivesEventTypesValuesChapter | InteractivesEventTypes.VISIBILITY;
11
+ type InteractiveEventType<T extends SubjectName> = T extends "container" ? InteractivesEventTypesValuesContainer : InteractivesEventTypesValuesControl;
12
+ type TInteractiveCommon<
13
+ T extends SubjectName,
14
+ U extends InteractiveEventType<T>
15
+ > = {
16
+ subjectId: string;
17
+ subjectName: T;
18
+ type: U;
19
+ };
20
+ export type TInteractivesVisibility<T extends Exclude<SubjectName, "chapter">> = TInteractiveCommon<T, InteractivesEventTypes.VISIBILITY> & {
21
+ visibility: boolean;
22
+ isFirst?: boolean;
23
+ };
24
+ type EventActionTypesValues = `${EventActionTypes}`;
25
+ export type TInteractiveRangeEndedEvent = {
26
+ type: InteractivesEventTypes.RANGE_ENDED;
27
+ payload: InteractiveRange;
28
+ };
29
+ type NonChapterChangeEvents = EventActionTypes.openURI | EventActionTypes.continuePlayback | EventActionTypes.expect;
30
+ type TInteractivesActionExecEventPayload<T extends EventActionTypesValues> = T extends Exclude<EventActionTypesValues, NonChapterChangeEvents> ? Partial<{
31
+ chapterId: string;
32
+ autoSelect: boolean;
33
+ behaviour: Behaviour;
34
+ manifestURL: string;
35
+ }> : undefined;
36
+ export type TInteractivesActionExecutionEvent<T extends SubjectName> = TInteractiveCommon<T, InteractivesEventTypes.ACTION_EXECUTION> & {
37
+ actionType: ActionMap[T]["type"] | AfterExpectActionType;
38
+ subjectType?: SubjectType<T>;
39
+ payload?: TInteractivesActionExecEventPayload<ActionMap[T]["type"]>;
40
+ };
41
+ type TControlPayloadExtra = {
42
+ containerId: string;
43
+ invokeImmediately: boolean;
44
+ };
45
+ type TInteractivesActionChoiceEventPayload<T extends SubjectName> = T extends "chapter" ? ChapterEvent["action"]["args"] : T extends "container" ? ContainerEvent["action"]["args"] & Pick<TControlPayloadExtra, "invokeImmediately"> : ControlEvent["action"]["args"] & TControlPayloadExtra;
46
+ type TSubjectTypeValues<T extends SubjectName> = T extends "chapter" ? undefined : T extends "container" ? ChapterContainer["type"] : Control["type"];
47
+ export type TInteractivesActionChoiceEvent<T extends SubjectName> = TInteractiveCommon<T, InteractivesEventTypes.ACTION_CHOICE | InteractivesEventTypes.ACTION_CHOICE_CANCELED> & {
48
+ subjectType?: TSubjectTypeValues<T>;
49
+ actionType: EventActionTypesValues;
50
+ payload: TInteractivesActionChoiceEventPayload<T>;
51
+ };
52
+ export type TInteractivesContainerRemoved = TInteractiveCommon<"container", InteractivesEventTypes.CONTAINER_REMOVED>;
53
+ export type TInteractivesContainerFakeRemoved = TInteractiveCommon<"container", InteractivesEventTypes.CONTAINER_FAKE_REMOVED> & {
54
+ removeAllOpenURI: boolean;
55
+ };
@@ -1,24 +1,24 @@
1
- import { type ChapterBranch } from '#/manifest';
2
- import type { Nullable } from '@vkontakte/videoplayer-shared';
1
+ import { type ChapterBranch } from "../../../manifest";
2
+ import type { Nullable } from "@vkontakte/videoplayer-shared";
3
3
  /**
4
- * Returns a random number in the range [0, limit) or [limit, 0) if the 'limit'
5
- * value is negative
6
- */
4
+ * Returns a random number in the range [0, limit) or [limit, 0) if the 'limit'
5
+ * value is negative
6
+ */
7
7
  export declare const getRandomNumber: (limit: number) => number;
8
8
  /**
9
- * Finds the value with minimal weight number
10
- */
9
+ * Finds the value with minimal weight number
10
+ */
11
11
  export declare const minFallbackStrategy: (branches: ChapterBranch[]) => Nullable<ChapterBranch>;
12
12
  /**
13
- * Finds the value with maximal weight number
14
- */
13
+ * Finds the value with maximal weight number
14
+ */
15
15
  export declare const maxFallbackStrategy: (branches: ChapterBranch[]) => Nullable<ChapterBranch>;
16
16
  /**
17
- * Finds first branch with `isDefault === true` value
18
- */
17
+ * Finds first branch with `isDefault === true` value
18
+ */
19
19
  export declare const defaultFallbackStrategy: (branches: ChapterBranch[]) => ChapterBranch | undefined;
20
20
  /**
21
- * Returns the random branch
22
- */
21
+ * Returns the random branch
22
+ */
23
23
  export declare const weightlessRandomFallbackStrategy: (branches: ChapterBranch[]) => ChapterBranch;
24
24
  export declare const weightyRandomFallbackStrategy: (branches: ChapterBranch[]) => ChapterBranch;
@@ -0,0 +1,12 @@
1
+ type Reverse<T extends unknown[]> = T extends [infer First, ...infer Rest] ? [...Reverse<Rest>, First] : T;
2
+ export declare function reverseArgs<Fn extends AnyFn>(fn: Fn): (...args: Reverse<Parameters<Fn>>) => ReturnType<Fn>;
3
+ export declare function partial<
4
+ T extends unknown[],
5
+ U extends unknown[],
6
+ R
7
+ >(fn: (...args: [...T, ...U]) => R, ...presetArgs: T): (...laterArgs: U) => R;
8
+ export declare function partial<
9
+ T extends Record<string, unknown>,
10
+ P extends Partial<T>
11
+ >(fn: (args: T) => unknown, presetArgs: P): (laterArgs: Omit<T, keyof P>) => ReturnType<typeof fn>;
12
+ export {};
@@ -1,14 +1,14 @@
1
- import { type Control, type Chapter, type ChapterContainer } from '#/manifest';
2
- import type { GameController } from './GameController';
3
- import type { IgnoreExpectState } from '#/modules/Interactives/types';
1
+ import { type Control, type Chapter, type ChapterContainer } from "../../../manifest";
2
+ import type { GameController } from "./GameController";
3
+ import type { IgnoreExpectState } from "../types";
4
4
  export declare enum GameStates {
5
- nothing = 0,
6
- beforeInteractive = 1,
7
- interactive = 2,
8
- afterInteractive = 3,
9
- end = 4,
10
- removed = 5,
11
- destroyed = 6
5
+ nothing = 0,
6
+ beforeInteractive = 1,
7
+ interactive = 2,
8
+ afterInteractive = 3,
9
+ end = 4,
10
+ removed = 5,
11
+ destroyed = 6
12
12
  }
13
13
  export declare const isControlsExist: (controls: Control[]) => boolean;
14
14
  export declare const isLastChapter: (chapter: Chapter) => boolean;
@@ -16,7 +16,7 @@ export declare const hasEndTemplate: (chapter: Chapter) => boolean;
16
16
  export declare const isBeforeStartTime: (currentTime: number, container: ChapterContainer) => boolean;
17
17
  export declare const isInteractiveTime: (currentTime: number, container: ChapterContainer) => boolean;
18
18
  export declare const isAfterInteractiveTime: (currentTime: number, container: ChapterContainer) => boolean;
19
- type AnyEvent = (ChapterContainer | Chapter | Control)['events'];
19
+ type AnyEvent = (ChapterContainer | Chapter | Control)["events"];
20
20
  type ExtractItemFromArray<T> = T extends (infer U)[] ? U : never;
21
21
  export declare const isExpectEvent: (events?: AnyEvent) => boolean;
22
22
  export declare const getExpectEvent: (events?: AnyEvent) => ExtractItemFromArray<AnyEvent> | undefined;
@@ -25,18 +25,18 @@ export declare const isOneTextCtrlContainer: (controls: Control[]) => boolean;
25
25
  export declare function excludeTextControl(containers?: ChapterContainer[]): ChapterContainer[];
26
26
  export declare const isEOVEndTime: (target: HTMLVideoElement, endTime: ChapterContainer["endTime"]) => boolean;
27
27
  /**
28
- * @param {GameController[]} [gameControllers=[]] список контрллеров
29
- * @param {(number | null | undefined)} [expectTime=Infinity] expectTime = endTime - какой expectTime мы ищем
30
- * @param {string[]} [ignoreIds=[]] какие контейнеры игнорировать
31
- */
28
+ * @param {GameController[]} [gameControllers=[]] список контрллеров
29
+ * @param {(number | null | undefined)} [expectTime=Infinity] expectTime = endTime - какой expectTime мы ищем
30
+ * @param {string[]} [ignoreIds=[]] какие контейнеры игнорировать
31
+ */
32
32
  export declare function getGameControllerContainersWithExpect(gameControllers?: GameController[], expectTime?: number | null | undefined, ignoreIds?: string[]): GameController[];
33
33
  type ExecForAllExpectContainersParamsType = {
34
- gameControllers: GameController[];
35
- subjectName: string;
36
- subjectId: string;
37
- execFn: (gameController: GameController) => void;
34
+ gameControllers: GameController[];
35
+ subjectName: string;
36
+ subjectId: string;
37
+ execFn: (gameController: GameController) => void;
38
38
  };
39
- export declare function execForAllExpectContainers({ gameControllers, subjectName, subjectId, execFn, }: ExecForAllExpectContainersParamsType): void;
39
+ export declare function execForAllExpectContainers({ gameControllers, subjectName, subjectId, execFn }: ExecForAllExpectContainersParamsType): void;
40
40
  export declare function isControlHasOpenURIEvent(control: Control): boolean;
41
41
  export declare const evaluateContainerEventStatus: (container: ChapterContainer, gameControllers: GameController[]) => IgnoreExpectState;
42
42
  export {};