@vkontakte/videoplayer-interactive 1.0.29-dev.e881d3ff.0 → 1.0.30-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.
- package/es2015.cjs.js +7 -7
- package/es2015.esm.js +7 -7
- package/es2018.cjs.js +7 -7
- package/es2018.esm.js +7 -7
- package/esnext.cjs.js +7 -7
- package/esnext.esm.js +7 -7
- package/evergreen.esm.js +7 -7
- package/package.json +4 -4
- package/types/modules/Interactives/Interactives.d.ts +8 -5
- package/types/modules/Interactives/containers/ChoiceContainer.d.ts +2 -1
- package/types/modules/Interactives/types.d.ts +8 -0
- package/types/modules/Interactives/utils/GameController.d.ts +22 -15
- package/types/modules/Interactives/utils/InteractiveEvents.d.ts +1 -1
- package/types/modules/Interactives/utils/SelectBranches.d.ts +4 -2
- package/types/modules/Interactives/utils/SelectBranches.types.d.ts +6 -2
- package/types/modules/Interactives/utils/events.d.ts +30 -6
- package/types/modules/Interactives/utils/events.types.d.ts +47 -0
- package/types/modules/Interactives/utils/gameUtils.d.ts +2 -1
- package/types/modules/Interactives/utils/getInteractiveRanges.d.ts +5 -1
|
@@ -2,6 +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
6
|
export interface GlobalEvents {
|
|
6
7
|
noInteraction$: Subject<void>;
|
|
7
8
|
graphVisibilityChanged$: Subject<boolean>;
|
|
@@ -11,13 +12,21 @@ export interface GlobalEvents {
|
|
|
11
12
|
error$: Subject<CustomError>;
|
|
12
13
|
eachTick$: Subject<EachTickData>;
|
|
13
14
|
manifestChanged$: Subject<Manifest>;
|
|
15
|
+
interactiveRangeEnded$: Subject<TInteractiveRangeEndedEvent>;
|
|
16
|
+
interactiveContainerRemoved$: Subject<TInteractivesContainerRemoved>;
|
|
17
|
+
interactiveActionExecution$: Subject<TInteractivesActionExecutionEvent<SubjectName>>;
|
|
18
|
+
interactiveActionChoice$: Subject<TInteractivesActionChoiceEvent<SubjectName>>;
|
|
19
|
+
interactiveVisibilityChanged$: Subject<TInteractivesVisibility<'container'>>;
|
|
14
20
|
}
|
|
15
21
|
export declare const EVENT_NAMES: {
|
|
16
22
|
/**
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
23
|
+
* @deprecated Используйте interactivesInstance.events.graphVisibilityChanged$
|
|
24
|
+
* & interactivesInstance.events.watchAgainIsClicked$
|
|
25
|
+
*/
|
|
20
26
|
readonly graph: "graph";
|
|
27
|
+
/**
|
|
28
|
+
* @deprecated Используйте interactivesInstance.events
|
|
29
|
+
*/
|
|
21
30
|
readonly interactives: "interactives";
|
|
22
31
|
/**
|
|
23
32
|
* @deprecated Используйте interactivesInstance.events.chapterChanged$
|
|
@@ -31,24 +40,39 @@ export declare const EVENT_NAMES: {
|
|
|
31
40
|
* @deprecated Используйте interactivesInstance.events.manifestChanged$
|
|
32
41
|
*/
|
|
33
42
|
readonly manifestChanged: "manifest-changed";
|
|
43
|
+
/**
|
|
44
|
+
* @deprecated Используйте interactivesInstance.events.error$
|
|
45
|
+
*/
|
|
34
46
|
readonly errors: "errors";
|
|
35
47
|
readonly eachTick: "eachTick";
|
|
36
48
|
readonly historyInited: "history-inited";
|
|
37
49
|
readonly historyDestroyed: "history-destroyed";
|
|
38
50
|
};
|
|
39
51
|
/**
|
|
40
|
-
* @deprecated Используйте interactivesInstance.events.graphVisibilityChanged$ &
|
|
41
|
-
* interactivesInstance.events.watchAgainIsClicked$
|
|
42
|
-
*/
|
|
52
|
+
* @deprecated Используйте interactivesInstance.events.graphVisibilityChanged$ &
|
|
53
|
+
* interactivesInstance.events.watchAgainIsClicked$
|
|
54
|
+
*/
|
|
43
55
|
export declare const graphEventTypes: {
|
|
44
56
|
readonly visibility: "visibility";
|
|
45
57
|
readonly watchAgainClicked: "watchAgainClicked";
|
|
46
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* @deprecated use InteractivesEventTypes enum instead
|
|
61
|
+
*/
|
|
47
62
|
export declare const interactivesEventTypes: {
|
|
48
63
|
readonly actionChoiceCanceled: "action-choice-canceled";
|
|
49
64
|
readonly actionChoice: "action-choice";
|
|
50
65
|
readonly actionExecution: "action-execution";
|
|
51
66
|
readonly visibility: "visibility";
|
|
52
67
|
readonly containerRemoved: "container-removed";
|
|
68
|
+
readonly containerFakeRemoved: "container-fake-removed";
|
|
53
69
|
readonly rangeEnded: "range-ended";
|
|
54
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
|
+
RANGE_ENDED = "range-ended"
|
|
78
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type { SubjectName, ActionMap, SubjectType, AfterExpectActionType, Behaviour } from './SelectBranches.types';
|
|
2
|
+
import { InteractivesEventTypes } from './events';
|
|
3
|
+
import { 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<T extends SubjectName, U extends InteractiveEventType<T>> = {
|
|
13
|
+
subjectId: string;
|
|
14
|
+
subjectName: T;
|
|
15
|
+
type: U;
|
|
16
|
+
};
|
|
17
|
+
export type TInteractivesVisibility<T extends Exclude<SubjectName, 'chapter'>> = TInteractiveCommon<T, InteractivesEventTypes.VISIBILITY> & {
|
|
18
|
+
visibility: boolean;
|
|
19
|
+
isFirst?: boolean;
|
|
20
|
+
};
|
|
21
|
+
type EventActionTypesValues = `${EventActionTypes}`;
|
|
22
|
+
export type TInteractiveRangeEndedEvent = {
|
|
23
|
+
type: InteractivesEventTypes.RANGE_ENDED;
|
|
24
|
+
payload: InteractiveRange;
|
|
25
|
+
};
|
|
26
|
+
type NonChapterChangeEvents = EventActionTypes.openURI | EventActionTypes.continuePlayback | EventActionTypes.expect;
|
|
27
|
+
type TInteractivesActionExecEventPayload<T extends EventActionTypesValues> = T extends Exclude<EventActionTypesValues, NonChapterChangeEvents> ? Partial<{
|
|
28
|
+
chapterId: string;
|
|
29
|
+
autoSelect: boolean;
|
|
30
|
+
behaviour: Behaviour;
|
|
31
|
+
manifestURL: string;
|
|
32
|
+
}> : undefined;
|
|
33
|
+
export type TInteractivesActionExecutionEvent<T extends SubjectName> = TInteractiveCommon<T, InteractivesEventTypes.ACTION_EXECUTION> & {
|
|
34
|
+
actionType: ActionMap[T]['type'] | AfterExpectActionType;
|
|
35
|
+
subjectType?: SubjectType<T>;
|
|
36
|
+
payload?: TInteractivesActionExecEventPayload<ActionMap[T]['type']>;
|
|
37
|
+
};
|
|
38
|
+
type TInteractivesActionChoiceEventPayload<T extends SubjectName> = T extends 'chapter' ? ChapterEvent['action']['args'] : T extends 'container' ? ContainerEvent['action']['args'] : ControlEvent['action']['args'] & {
|
|
39
|
+
containerId: string;
|
|
40
|
+
};
|
|
41
|
+
type TSubjectTypeValues<T extends SubjectName> = T extends 'chapter' ? undefined : T extends 'container' ? ChapterContainer['type'] : Control['type'];
|
|
42
|
+
export type TInteractivesActionChoiceEvent<T extends SubjectName> = TInteractiveCommon<T, InteractivesEventTypes.ACTION_CHOICE | InteractivesEventTypes.ACTION_CHOICE_CANCELED> & {
|
|
43
|
+
subjectType?: TSubjectTypeValues<T>;
|
|
44
|
+
actionType: EventActionTypesValues;
|
|
45
|
+
payload: TInteractivesActionChoiceEventPayload<T>;
|
|
46
|
+
};
|
|
47
|
+
export type TInteractivesContainerRemoved = TInteractiveCommon<'container', InteractivesEventTypes.CONTAINER_REMOVED>;
|
|
@@ -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
|
|
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:
|
|
7
|
+
subjects: Subject[];
|
|
4
8
|
range: [number, number];
|
|
5
9
|
};
|
|
6
10
|
export type InteractiveRanges = Array<InteractiveRange>;
|