@vkontakte/videoplayer-interactive 1.0.31 → 1.0.32-beta.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.
Files changed (32) hide show
  1. package/es2015.cjs.js +44 -7
  2. package/es2015.esm.js +44 -7
  3. package/es2018.cjs.js +44 -7
  4. package/es2018.esm.js +44 -7
  5. package/esnext.cjs.js +44 -7
  6. package/esnext.esm.js +44 -7
  7. package/evergreen.esm.js +43 -6
  8. package/package.json +4 -4
  9. package/types/modules/Interactives/Interactives.d.ts +12 -1
  10. package/types/modules/Interactives/containers/ChoiceContainer.d.ts +8 -6
  11. package/types/modules/Interactives/containers/Container.d.ts +7 -5
  12. package/types/modules/Interactives/containers/index.d.ts +2 -0
  13. package/types/modules/Interactives/containers/types.d.ts +9 -0
  14. package/types/modules/Interactives/containers/utils.d.ts +6 -0
  15. package/types/modules/Interactives/controls/AreaControl.d.ts +11 -2
  16. package/types/modules/Interactives/controls/ButtonControl.d.ts +11 -2
  17. package/types/modules/Interactives/controls/Control.d.ts +12 -9
  18. package/types/modules/Interactives/controls/TextControl.d.ts +11 -2
  19. package/types/modules/Interactives/controls/index.d.ts +4 -2
  20. package/types/modules/Interactives/controls/types.d.ts +17 -8
  21. package/types/modules/Interactives/controls/utils.d.ts +9 -0
  22. package/types/modules/Interactives/index.d.ts +39 -4
  23. package/types/modules/Interactives/styles.d.ts +1 -0
  24. package/types/modules/Interactives/types.d.ts +14 -2
  25. package/types/modules/Interactives/utils/GameController.d.ts +8 -4
  26. package/types/modules/Interactives/utils/HistoryController.d.ts +1 -1
  27. package/types/modules/Interactives/utils/InteractiveEvents.d.ts +1 -1
  28. package/types/modules/Interactives/utils/events.d.ts +3 -1
  29. package/types/modules/Interactives/utils/events.types.d.ts +3 -0
  30. package/types/modules/Interactives/utils/gameUtils.d.ts +2 -1
  31. package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +5 -1
  32. package/types/modules/Interactives/utils/renderingUtils.d.ts +0 -3
@@ -1,4 +1,6 @@
1
- export * from './AreaControl.js';
2
- export * from './ButtonControl.js';
1
+ export * from './AreaControl';
2
+ export * from './ButtonControl';
3
+ export * from './TextControl';
3
4
  export * from './Control';
4
5
  export * from './types';
6
+ export * from './utils';
@@ -1,24 +1,33 @@
1
1
  import type { Control as TControl, ControlEvent, ControlLayoutParams } from '../../../manifest';
2
- import Control from '../../../modules/Interactives/controls/Control';
2
+ import type { Control } from '../../../modules/Interactives/controls/Control';
3
+ import { AnimationsFeatureToggles } from '../../../modules/Interactives/types';
3
4
  export { TControl };
5
+ export declare const CONTROLLER_PREFIX = "int";
4
6
  export declare enum CONTROLLER_IDS {
5
7
  AREA = "int_area",
6
8
  TEXT = "int_text",
7
9
  BUTTON = "int_bttn"
8
10
  }
9
- export type Dimensions = {
10
- width: string;
11
- height: string;
11
+ export type Dimensions<T = string> = {
12
+ width: T;
13
+ height: T;
12
14
  };
13
- export type LayoutCallback = (element: HTMLElement, controlLayoutParams: ControlLayoutParams) => void;
14
- export type CreateViewParams = {
15
+ export type Callbacks = {
16
+ setControlLayout: (element: HTMLElement, controlLayoutParams: ControlLayoutParams) => void;
17
+ };
18
+ export type ControlCreateViewParams = {
15
19
  parentElement: HTMLElement;
16
- layoutCallback: LayoutCallback;
20
+ callbacks: Callbacks;
21
+ };
22
+ export type Options = Record<string, unknown>;
23
+ export type ControlOptions = {
24
+ features: Pick<AnimationsFeatureToggles, never>;
17
25
  };
26
+ export declare function isControlOptions(options: Options): options is ControlOptions;
18
27
  type ControlEventCallbackParams = {
19
28
  action: ControlEvent['action'];
20
29
  controlId: string;
21
30
  controlType: TControl['type'];
22
31
  };
23
32
  export type ControlEventCallback = (params: ControlEventCallbackParams) => void;
24
- export type ControlCreator = (control: TControl) => Control | undefined;
33
+ export type ControlCreator<O extends Options = Options, C extends Control = Control> = (control: TControl, options?: O) => C | undefined;
@@ -0,0 +1,9 @@
1
+ export declare const CONTROLS_CLASSNAME_PREFIX = "interactive-control";
2
+ export declare const controlsClassNames: {
3
+ common: string;
4
+ wrapper: string;
5
+ disabled: string;
6
+ button: string;
7
+ area: string;
8
+ text: string;
9
+ };
@@ -6,9 +6,44 @@ export { isLastChapter, hasEndTemplate, isOneTextCtrlContainer } from './utils/g
6
6
  export type { InteractiveRange } from './utils/getInteractiveRanges';
7
7
  export declare const utils: {
8
8
  Container: typeof Container;
9
- createChoiceContainer: (container: import("@interactiveplatform/movika-manifest").ChapterContainer, rootElement: HTMLElement) => import("./containers/ChoiceContainer").ChoiceContainer | undefined;
10
- createAreaControl: import("./controls").ControlCreator;
11
- createButtonControl: import("./controls").ControlCreator;
12
- getRootEl: () => Element | null;
9
+ createChoiceContainer: (container: import("@interactiveplatform/movika-manifest").ChapterContainer, rootElement: HTMLElement, options?: import("./containers/types").ChoiceContainerOptions) => import("./containers/ChoiceContainer").ChoiceContainer | undefined;
10
+ createAreaControl: import("./controls").ControlCreator<import("./controls").ControlOptions, {
11
+ createView({ parentElement, callbacks }: import("./controls").ControlCreateViewParams): void;
12
+ disable(): void;
13
+ enable(): void;
14
+ getElement(): Nullable<HTMLElement>;
15
+ container: Nullable<{
16
+ element: HTMLElement;
17
+ dimensions: import("./controls").Dimensions;
18
+ }>;
19
+ controlElement: Nullable<HTMLElement>;
20
+ clickListener: Nullable<(event: MouseEvent) => void>;
21
+ control: import("@interactiveplatform/movika-manifest/dist/chapter-COPBtRYg").e;
22
+ options?: import("./controls").Options;
23
+ createContainerElement(callbacks: import("./controls").Callbacks): void;
24
+ createClickListener(callback: AnyFn): (event: MouseEvent) => void;
25
+ featureIsEnabled(name: keyof import("./controls").ControlOptions["features"]): false | undefined;
26
+ setEvents(callback: import("./controls").ControlEventCallback): void;
27
+ removeListeners(): void;
28
+ }>;
29
+ createButtonControl: import("./controls").ControlCreator<import("./controls").ControlOptions, {
30
+ createView({ parentElement, callbacks }: import("./controls").ControlCreateViewParams): void;
31
+ disable(): void;
32
+ enable(): void;
33
+ getElement(): Nullable<HTMLElement>;
34
+ container: Nullable<{
35
+ element: HTMLElement;
36
+ dimensions: import("./controls").Dimensions;
37
+ }>;
38
+ controlElement: Nullable<HTMLElement>;
39
+ clickListener: Nullable<(event: MouseEvent) => void>;
40
+ control: import("@interactiveplatform/movika-manifest/dist/chapter-COPBtRYg").e;
41
+ options?: import("./controls").Options;
42
+ createContainerElement(callbacks: import("./controls").Callbacks): void;
43
+ createClickListener(callback: AnyFn): (event: MouseEvent) => void;
44
+ featureIsEnabled(name: keyof import("./controls").ControlOptions["features"]): false | undefined;
45
+ setEvents(callback: import("./controls").ControlEventCallback): void;
46
+ removeListeners(): void;
47
+ }>;
13
48
  classnamesPrefix: string;
14
49
  };
@@ -0,0 +1 @@
1
+ export declare const applyStyles: (attachToElement: HTMLElement) => void;
@@ -19,6 +19,7 @@ export type RequiredOptions = 'parentElement' | 'fullscreenTargetElement';
19
19
  export type IOptionalInteractiveOptions = Partial<Omit<IInteractiveOptions, RequiredOptions | 'config'>> & Required<Pick<IInteractiveOptions, RequiredOptions>> & {
20
20
  config?: Partial<IInteractiveOptions['config']>;
21
21
  };
22
+ export type AnimationsFeatureToggles = {};
22
23
  export interface IInteractiveOptions {
23
24
  parentElement: HTMLElement;
24
25
  fullscreenTargetElement: HTMLElement;
@@ -31,6 +32,7 @@ export interface IInteractiveOptions {
31
32
  lastFrame: boolean;
32
33
  initSeamless: boolean;
33
34
  permanentTextControls: boolean;
35
+ interactiveTimeOpenUri: boolean;
34
36
  loaders: Partial<Loaders>;
35
37
  initChapterId?: string;
36
38
  projectInfo?: InteractiveProjectInfo;
@@ -40,9 +42,10 @@ export interface IInteractiveOptions {
40
42
  vkVideoLoader?: (owner_id: string, video_id: string) => unknown;
41
43
  createOneStat?: (video: any, configOverwrite?: any) => IOneStat | undefined;
42
44
  /**
43
- * @deprecated
44
- * */
45
+ * @deprecated
46
+ * */
45
47
  disableControlsOnPause?: boolean;
48
+ animationFeatureToggles?: AnimationsFeatureToggles;
46
49
  }
47
50
  export type ChapterChangedData = {
48
51
  chapter: Chapter;
@@ -59,3 +62,12 @@ export interface EachTickData {
59
62
  currentTime: number;
60
63
  isInteractiveTime: boolean;
61
64
  }
65
+ export type IgnoreExpectState = {
66
+ isExpectTime: boolean;
67
+ hasOtherExpect: boolean;
68
+ hasOpenURIEvent: boolean;
69
+ hasOpenURIEventInCurrentContainer: boolean;
70
+ isAllOpenURIEventsValid: boolean;
71
+ isExpectEventForCurrentContainer: boolean;
72
+ hasShouldOpenNowEvent: boolean;
73
+ };
@@ -3,8 +3,9 @@ import { type IPlayer } from '@vkontakte/videoplayer-core';
3
3
  import type { InteractiveEventsType } from './InteractiveEvents';
4
4
  import type { ChapterBranch } from '../../../manifest';
5
5
  import type { EventEmitter } from '../../../utils/EventEmitter';
6
- import type { ChoiceContainer } from '../../../modules/Interactives/containers';
7
6
  import type { SelectBranchesType } from './SelectBranches';
7
+ import type { IgnoreExpectState } from '../../../modules/Interactives/types';
8
+ import type { ChoiceContainer } from '../../../modules/Interactives/containers';
8
9
  import { type GlobalEvents } from './events';
9
10
  import { GameStates } from './gameUtils';
10
11
  type ConstructorArg = {
@@ -15,8 +16,9 @@ type ConstructorArg = {
15
16
  interactiveEvents: InteractiveEventsType;
16
17
  globalEventEmitter: EventEmitter;
17
18
  globalEvents: GlobalEvents;
18
- ignoreContainerEvent: () => boolean;
19
+ getContainerEventState: () => IgnoreExpectState;
19
20
  permanentTextControls: boolean;
21
+ interactiveTimeOpenUri: boolean;
20
22
  disabledControls$: IValueSubject<boolean>;
21
23
  onRemove: () => void;
22
24
  };
@@ -27,8 +29,9 @@ export declare class GameController {
27
29
  subscription: ISubscription;
28
30
  player: IPlayer;
29
31
  interactiveEvents: InteractiveEventsType;
30
- ignoreContainerEvent: () => boolean;
32
+ getContainerEventState: () => IgnoreExpectState;
31
33
  isPermanentText: boolean;
34
+ interactiveTimeOpenUri: boolean;
32
35
  disabledControls$: IValueSubject<boolean>;
33
36
  onRemove: () => void;
34
37
  globalEventEmitter: EventEmitter;
@@ -36,7 +39,7 @@ export declare class GameController {
36
39
  isSelectedControlEvent: boolean;
37
40
  isSelectedContainerEvent: boolean;
38
41
  globalEvents: GlobalEvents;
39
- constructor({ player, container, branches, selectBranches, interactiveEvents, globalEvents, globalEventEmitter, ignoreContainerEvent, permanentTextControls, disabledControls$, onRemove, }: ConstructorArg);
42
+ constructor({ player, container, branches, selectBranches, interactiveEvents, globalEvents, globalEventEmitter, getContainerEventState, permanentTextControls, interactiveTimeOpenUri, disabledControls$, onRemove, }: ConstructorArg);
40
43
  private emitContainerVisibilityEvent;
41
44
  registerEvents(): void;
42
45
  hide: () => void;
@@ -49,6 +52,7 @@ export declare class GameController {
49
52
  whilePlaying: () => void;
50
53
  reset(): void;
51
54
  removeView(): void;
55
+ fakeRemoveView(remove?: boolean): void;
52
56
  destroy(): void;
53
57
  }
54
58
  export {};
@@ -2,7 +2,7 @@ import { Nullable, Subject } from '@vkontakte/videoplayer-shared';
2
2
  import type { IValueSubject } from '@vkontakte/videoplayer-shared';
3
3
  import { EventEmitter } from '../../../utils/EventEmitter';
4
4
  import type { VideoId } from '../../../manifest';
5
- import type { VideoInfo } from "../../../modules/Interactives";
5
+ import type { VideoInfo } from '../../../modules/Interactives';
6
6
  import type { Interactives } from '../../../modules/Interactives';
7
7
  import { CustomError } from '../../../utils/Error';
8
8
  export interface HistoryApi {
@@ -7,7 +7,7 @@ type RemoveMethodParamType = Parameters<TGroupsStack['remove']>[0];
7
7
  /**
8
8
  * Executes an events at different times of the current chapter
9
9
  */
10
- export declare function InteractiveEvents(player: IPlayer): {
10
+ export declare function InteractiveEvents(player: IPlayer, interactiveTimeOpenUri: boolean): {
11
11
  setPlayer: (player: IPlayer) => void;
12
12
  add: (args: AddMethodParamType) => void;
13
13
  remove: (args: RemoveMethodParamType) => void;
@@ -2,7 +2,7 @@ import type { Subject } from '@vkontakte/videoplayer-shared';
2
2
  import type { ChapterChangedData, EachTickData, PlayerChangedData } from '../../../modules/Interactives/types';
3
3
  import type { CustomError } from '../../../utils/Error';
4
4
  import type { Manifest } from '../../../manifest';
5
- import { TInteractiveRangeEndedEvent, TInteractivesActionChoiceEvent, TInteractivesActionExecutionEvent, TInteractivesContainerRemoved, SubjectName, TInteractivesVisibility } from './events.types';
5
+ import { TInteractiveRangeEndedEvent, TInteractivesActionChoiceEvent, TInteractivesActionExecutionEvent, TInteractivesContainerRemoved, TInteractivesContainerFakeRemoved, SubjectName, TInteractivesVisibility } from './events.types';
6
6
  export interface GlobalEvents {
7
7
  noInteraction$: Subject<void>;
8
8
  graphVisibilityChanged$: Subject<boolean>;
@@ -14,6 +14,7 @@ export interface GlobalEvents {
14
14
  manifestChanged$: Subject<Manifest>;
15
15
  interactiveRangeEnded$: Subject<TInteractiveRangeEndedEvent>;
16
16
  interactiveContainerRemoved$: Subject<TInteractivesContainerRemoved>;
17
+ interactiveContainerFakeRemoved$: Subject<TInteractivesContainerFakeRemoved>;
17
18
  interactiveActionExecution$: Subject<TInteractivesActionExecutionEvent<SubjectName>>;
18
19
  interactiveActionChoice$: Subject<TInteractivesActionChoiceEvent<SubjectName>>;
19
20
  interactiveVisibilityChanged$: Subject<TInteractivesVisibility<'container'>>;
@@ -73,5 +74,6 @@ export declare enum InteractivesEventTypes {
73
74
  ACTION_EXECUTION = "action-execution",
74
75
  VISIBILITY = "visibility",
75
76
  CONTAINER_REMOVED = "container-removed",
77
+ CONTAINER_FAKE_REMOVED = "container-fake-removed",
76
78
  RANGE_ENDED = "range-ended"
77
79
  }
@@ -47,3 +47,6 @@ export type TInteractivesActionChoiceEvent<T extends SubjectName> = TInteractive
47
47
  payload: TInteractivesActionChoiceEventPayload<T>;
48
48
  };
49
49
  export type TInteractivesContainerRemoved = TInteractiveCommon<'container', InteractivesEventTypes.CONTAINER_REMOVED>;
50
+ export type TInteractivesContainerFakeRemoved = TInteractiveCommon<'container', InteractivesEventTypes.CONTAINER_FAKE_REMOVED> & {
51
+ removeAllOpenURI: boolean;
52
+ };
@@ -1,5 +1,6 @@
1
1
  import { type Control, type Chapter, type ChapterContainer } from '../../../manifest';
2
2
  import type { GameController } from './GameController';
3
+ import type { IgnoreExpectState } from '../../../modules/Interactives/types';
3
4
  export declare enum GameStates {
4
5
  nothing = 0,
5
6
  beforeInteractive = 1,
@@ -24,5 +25,5 @@ export declare function excludeTextControl(containers?: ChapterContainer[]): Cha
24
25
  export declare const isEOVEndTime: (target: HTMLVideoElement, endTime: ChapterContainer["endTime"]) => boolean;
25
26
  export declare function partial<T extends unknown[], U extends unknown[], R>(fn: (...args: [...T, ...U]) => R, ...presetArgs: T): (...laterArgs: U) => R;
26
27
  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: ChapterContainer, gameControllers: GameController[]) => boolean;
28
+ export declare const evaluateContainerEventStatus: (container: ChapterContainer, gameControllers: GameController[]) => IgnoreExpectState;
28
29
  export {};
@@ -1,6 +1,10 @@
1
1
  import { type Container } from '../../../manifest';
2
+ export type Subject = {
3
+ id: string;
4
+ isRemoved: boolean;
5
+ };
2
6
  export type InteractiveRange = {
3
- subjects: string[];
7
+ subjects: Subject[];
4
8
  range: [number, number];
5
9
  };
6
10
  export type InteractiveRanges = Array<InteractiveRange>;
@@ -1,9 +1,6 @@
1
1
  import { type Control } from '../../../manifest';
2
2
  import { type Dimensions } from '../../../modules/Interactives/controls';
3
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
4
  export declare const controlStylesFallbacks: {
8
5
  textColor: string;
9
6
  textSize: number;