ev-interactivity-core 0.1.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/dist/index.d.mts +158 -0
- package/dist/index.mjs +4459 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +32 -0
package/dist/index.d.mts
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
//#region src/types.d.ts
|
|
2
|
+
type SceneId = string;
|
|
3
|
+
/** Geometry in percent of the player viewport, top-left anchored. All values 0–100. */
|
|
4
|
+
interface Position {
|
|
5
|
+
x: number;
|
|
6
|
+
y: number;
|
|
7
|
+
w: number;
|
|
8
|
+
h: number;
|
|
9
|
+
}
|
|
10
|
+
interface ButtonStyle {
|
|
11
|
+
btnBg: string;
|
|
12
|
+
/** Text colour. Name kept for backward-compat with persisted interactions. */
|
|
13
|
+
textBg: string;
|
|
14
|
+
}
|
|
15
|
+
type Action = {
|
|
16
|
+
type: "next_scene";
|
|
17
|
+
} | {
|
|
18
|
+
type: "go_to_scene";
|
|
19
|
+
targetSceneId: SceneId;
|
|
20
|
+
} | {
|
|
21
|
+
type: "open_url";
|
|
22
|
+
url: string;
|
|
23
|
+
target: "_blank" | "_self";
|
|
24
|
+
} | {
|
|
25
|
+
type: "end_video";
|
|
26
|
+
};
|
|
27
|
+
interface QuizOption {
|
|
28
|
+
id: string;
|
|
29
|
+
label: string;
|
|
30
|
+
correct: boolean;
|
|
31
|
+
}
|
|
32
|
+
interface InteractionBase {
|
|
33
|
+
id: string;
|
|
34
|
+
timeStart: number;
|
|
35
|
+
timeEnd: number;
|
|
36
|
+
position: Position;
|
|
37
|
+
waitForClick: boolean;
|
|
38
|
+
/** Gate: the learner cannot skip past or resume until this is satisfied. */
|
|
39
|
+
required?: boolean;
|
|
40
|
+
}
|
|
41
|
+
interface ButtonInteraction extends InteractionBase {
|
|
42
|
+
type: "button";
|
|
43
|
+
label: string;
|
|
44
|
+
style: ButtonStyle;
|
|
45
|
+
action: Action;
|
|
46
|
+
}
|
|
47
|
+
interface SingleChoiceInteraction extends InteractionBase {
|
|
48
|
+
type: "single_choice";
|
|
49
|
+
question: string;
|
|
50
|
+
options: QuizOption[];
|
|
51
|
+
action: Action;
|
|
52
|
+
}
|
|
53
|
+
interface MultiChoiceInteraction extends InteractionBase {
|
|
54
|
+
type: "multi_choice";
|
|
55
|
+
question: string;
|
|
56
|
+
options: QuizOption[];
|
|
57
|
+
action: Action;
|
|
58
|
+
}
|
|
59
|
+
type Interaction = ButtonInteraction | SingleChoiceInteraction | MultiChoiceInteraction;
|
|
60
|
+
interface ScenesShape {
|
|
61
|
+
id: SceneId;
|
|
62
|
+
order: number;
|
|
63
|
+
interactions?: Interaction[];
|
|
64
|
+
terminal?: boolean;
|
|
65
|
+
}
|
|
66
|
+
type NavigateIntent = {
|
|
67
|
+
type: "navigate";
|
|
68
|
+
sceneId: SceneId | null;
|
|
69
|
+
};
|
|
70
|
+
type PauseIntent = {
|
|
71
|
+
type: "pause";
|
|
72
|
+
};
|
|
73
|
+
type SeekIntent = {
|
|
74
|
+
type: "seek";
|
|
75
|
+
time: number;
|
|
76
|
+
};
|
|
77
|
+
type OpenUrlIntent = {
|
|
78
|
+
type: "open_url";
|
|
79
|
+
url: string;
|
|
80
|
+
target: "_blank" | "_self";
|
|
81
|
+
};
|
|
82
|
+
type Intent = NavigateIntent | PauseIntent | SeekIntent | OpenUrlIntent;
|
|
83
|
+
//#endregion
|
|
84
|
+
//#region src/schema.d.ts
|
|
85
|
+
declare function parseInteractionsSafe(raw: unknown): Interaction[];
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/resolver.d.ts
|
|
88
|
+
declare function resolveAction(scenes: ScenesShape[], currentId: SceneId, action: Action): NavigateIntent | OpenUrlIntent;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/navigation.d.ts
|
|
91
|
+
/** The next scene in display order after `currentId`, or null if it is last/unknown. */
|
|
92
|
+
declare function nextSceneByOrder(scenes: ScenesShape[], currentId: SceneId): SceneId | null;
|
|
93
|
+
//#endregion
|
|
94
|
+
//#region src/visibility.d.ts
|
|
95
|
+
/** Visible while the playhead is in [timeStart, timeEnd). A waitForClick interaction
|
|
96
|
+
* gates playback and stays visible from timeStart regardless of timeEnd (its window
|
|
97
|
+
* is the pause, not a fixed duration). */
|
|
98
|
+
declare function getVisibleInteractions(scene: ScenesShape | undefined, currentTime: number): Interaction[];
|
|
99
|
+
//#endregion
|
|
100
|
+
//#region src/schedule.d.ts
|
|
101
|
+
/** A scene's playback length, supplied by the host (e.g. from the rendered composition). */
|
|
102
|
+
interface SceneTiming {
|
|
103
|
+
id: SceneId;
|
|
104
|
+
duration: number;
|
|
105
|
+
}
|
|
106
|
+
interface SceneLocation {
|
|
107
|
+
sceneId: SceneId;
|
|
108
|
+
localTime: number;
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Maps between a merged/global timeline (scenes played back-to-back) and
|
|
112
|
+
* per-scene local time. Pure: the host owns the clock and scene durations,
|
|
113
|
+
* core owns the arithmetic so every player agrees on it.
|
|
114
|
+
*/
|
|
115
|
+
interface Schedule {
|
|
116
|
+
/** Total duration of all scenes. */
|
|
117
|
+
readonly total: number;
|
|
118
|
+
/** Global start offset of a scene, or null if the scene is unknown. */
|
|
119
|
+
startOf(sceneId: SceneId): number | null;
|
|
120
|
+
/** Scene playing at a given global time (clamps to the last scene past the end). */
|
|
121
|
+
locate(globalTime: number): SceneLocation | null;
|
|
122
|
+
}
|
|
123
|
+
declare function createSchedule(timings: SceneTiming[]): Schedule;
|
|
124
|
+
/**
|
|
125
|
+
* A concrete instruction for a player host to execute. Decouples the intent
|
|
126
|
+
* (what the interaction means) from the engine (how the host plays it), so the
|
|
127
|
+
* in-app preview and the learner-facing player share identical navigation logic.
|
|
128
|
+
*/
|
|
129
|
+
type PlayerCommand = {
|
|
130
|
+
type: "seek";
|
|
131
|
+
time: number;
|
|
132
|
+
} | {
|
|
133
|
+
type: "open_url";
|
|
134
|
+
url: string;
|
|
135
|
+
target: "_blank" | "_self";
|
|
136
|
+
} | {
|
|
137
|
+
type: "pause";
|
|
138
|
+
} | {
|
|
139
|
+
type: "end";
|
|
140
|
+
};
|
|
141
|
+
/** Resolve a player Intent into a host-agnostic command, using the schedule for navigation. */
|
|
142
|
+
declare function resolveIntentCommand(intent: Intent, schedule: Schedule): PlayerCommand;
|
|
143
|
+
//#endregion
|
|
144
|
+
//#region src/graph.d.ts
|
|
145
|
+
interface BrokenLink {
|
|
146
|
+
sceneId: SceneId;
|
|
147
|
+
interactionId: string;
|
|
148
|
+
targetSceneId: SceneId;
|
|
149
|
+
}
|
|
150
|
+
interface GraphValidationResult {
|
|
151
|
+
orphans: SceneId[];
|
|
152
|
+
deadEnds: SceneId[];
|
|
153
|
+
brokenLinks: BrokenLink[];
|
|
154
|
+
}
|
|
155
|
+
declare function validateGraph(scenes: ScenesShape[]): GraphValidationResult;
|
|
156
|
+
//#endregion
|
|
157
|
+
export { type Action, type BrokenLink, type ButtonInteraction, type ButtonStyle, type GraphValidationResult, type Intent, type Interaction, type MultiChoiceInteraction, type NavigateIntent, type OpenUrlIntent, type PauseIntent, type PlayerCommand, type Position, type QuizOption, type SceneId, type SceneLocation, type SceneTiming, type ScenesShape, type Schedule, type SeekIntent, type SingleChoiceInteraction, createSchedule, getVisibleInteractions, nextSceneByOrder, parseInteractionsSafe, resolveAction, resolveIntentCommand, validateGraph };
|
|
158
|
+
//# sourceMappingURL=index.d.mts.map
|