@lessonkit/core 1.3.1 → 1.4.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.cts CHANGED
@@ -1,24 +1,5 @@
1
- type CourseId = string;
2
- type LessonId = string;
3
- type CheckId = string;
4
- type BlockId = string;
5
- /** Stable URN string returned by {@link buildLessonkitUrn}. */
6
- type LessonkitUrn = string;
7
- type IdentityValidationIssue = {
8
- path: string;
9
- message: string;
10
- };
11
- type IdentityValidationResult = {
12
- ok: true;
13
- id: string;
14
- } | {
15
- ok: false;
16
- issues: IdentityValidationIssue[];
17
- };
18
- type IdentityIdPath = "courseId" | "lessonId" | "checkId" | "blockId" | "id";
19
- /** LessonKit id format: letter first, then alphanumeric, `_`, `-`; length 1–64. */
20
- declare const ID_PATTERN: RegExp;
21
- declare const ID_MAX_LENGTH = 64;
1
+ import { p as CourseId, E as LessonId, C as CheckId, B as BlockId, t as IdentityIdPath, v as IdentityValidationResult, N as LessonkitUrn, h as AssessmentResumeState, a0 as StoragePort, a5 as TelemetryEventName, a7 as TelemetrySink, a1 as TelemetryBatchSink, aa as TrackingClient, a3 as TelemetryEvent, a8 as TelemetryUser, J as LessonkitPlugin, U as PluginRegistry, V as ProgressController, S as PluginHost, W as ProgressState, a2 as TelemetryDataFor, i as AssessmentScoreInput, j as AssessmentScoreResult, n as ClockPort, g as AssessmentPlugin, O as LifecyclePlugin, a6 as TelemetryPlugin, K as LessonkitPluginContext } from './testing-BhVGckZ5.cjs';
2
+ export { A as AccordionSectionToggledData, a as AssessmentAnsweredData, b as AssessmentBaseProps, c as AssessmentBehaviour, d as AssessmentCompletedData, e as AssessmentHandle, f as AssessmentInteractionType, k as AssessmentXAPIData, l as BookPageViewedData, m as BuildTelemetryEventInput, o as CompoundPageViewedData, q as CourseLifecycleContext, r as CourseLifecycleDeps, F as FlashcardFlippedData, H as HotspotOpenedData, I as ID_MAX_LENGTH, s as ID_PATTERN, u as IdentityValidationIssue, w as ImageSliderChangedData, x as InformationWallSearchData, y as InteractionBlockRegistration, z as InteractionData, D as InteractionPlugin, L as LessonCompletionEmitter, G as LessonLifecycleData, M as LessonkitPluginKind, P as McqAssessmentProps, Q as MemoryCardFlippedData, R as ParallaxSlideViewedData, T as PluginIdentity, X as QuestionnaireSubmittedData, Y as QuizAnsweredData, Z as QuizCompletedData, _ as SESSION_STORAGE_KEY, $ as SlideViewedData, a4 as TelemetryEventBase, a9 as TimerPort, ab as VideoCueReachedData, ac as VideoSegmentCompletedData, ad as buildCourseStartedTelemetryEvent, ae as buildTelemetryEvent, af as completeCourseWithTelemetry, ag as completeLessonWithTelemetry, ah as createDefaultClock, ai as createGlobalTimer, aj as createNoopStorage, ak as createProgressController, al as createSessionStoragePort, am as getTabSessionId, an as hasCourseStarted, ao as hasCourseStartedEmittedToTracking, ap as hasCourseStartedPipelineDelivered, aq as markCourseStarted, ar as markCourseStartedEmittedToTracking, as as markCourseStartedPipelineDelivered, at as migrateCourseStartedMark, av as resetSharedVolatileSessionIdForTests, aw as resetStoragePortForTests, ax as resetTelemetryBuilderWarningsForTests, ay as resolveSessionId, az as tryBuildTelemetryEvent, aA as tryEmitCourseStarted } from './testing-BhVGckZ5.cjs';
22
3
 
23
4
  /**
24
5
  * Exhaustiveness helper for switch/default branches.
@@ -54,215 +35,8 @@ type LessonkitUrnParts = {
54
35
  */
55
36
  declare function buildLessonkitUrn(parts: LessonkitUrnParts): LessonkitUrn;
56
37
 
57
- /** H5P-aligned interaction kinds for assessment telemetry and xAPI. */
58
- type AssessmentInteractionType = "mcq" | "trueFalse" | "fillInBlanks" | "markTheWords" | "dragTheWords" | "dragAndDrop" | "assessmentSequence" | "findHotspot" | "findMultipleHotspots";
59
- /** Serializable resume blob for a single assessment block. */
60
- type AssessmentResumeState = Record<string, unknown>;
61
- /** Behaviour flags aligned with H5P question types. */
62
- type AssessmentBehaviour = {
63
- enableRetry?: boolean;
64
- enableSolutionsButton?: boolean;
65
- autoCheck?: boolean;
66
- };
67
- /** Payload for xAPI mapping from assessment components. */
68
- type AssessmentXAPIData = {
69
- checkId: CheckId;
70
- interactionType: AssessmentInteractionType;
71
- response?: string | string[] | boolean | Record<string, unknown>;
72
- correct?: boolean;
73
- score?: number;
74
- maxScore?: number;
75
- };
76
- /**
77
- * Imperative handle for scored blocks (H5P question-type contract analogue).
78
- * Parent containers (`AssessmentSequence`, future compounds) may call these methods.
79
- */
80
- type AssessmentHandle = {
81
- getScore: () => number;
82
- getMaxScore: () => number;
83
- getAnswerGiven: () => boolean;
84
- resetTask: () => void;
85
- showSolutions: () => void;
86
- getXAPIData: () => AssessmentXAPIData;
87
- getCurrentState?: () => AssessmentResumeState;
88
- resume?: (state: AssessmentResumeState) => void;
89
- };
90
- type AssessmentBaseProps = AssessmentBehaviour & {
91
- checkId: CheckId;
92
- passingScore?: number;
93
- };
94
-
95
- type TelemetryEventName = "course_started" | "course_completed" | "lesson_started" | "lesson_completed" | "lesson_time_on_task" | "quiz_answered" | "quiz_completed" | "assessment_answered" | "assessment_completed" | "interaction" | "book_page_viewed" | "slide_viewed" | "compound_page_viewed" | "hotspot_opened" | "accordion_section_toggled" | "flashcard_flipped" | "image_slider_changed";
96
- type TelemetryUser = {
97
- id?: string;
98
- email?: string;
99
- name?: string;
100
- [key: string]: unknown;
101
- };
102
- type TelemetryEventBase = {
103
- timestamp: string;
104
- courseId: CourseId;
105
- sessionId?: string;
106
- attemptId?: string;
107
- user?: TelemetryUser;
108
- };
109
- type LessonLifecycleData = {
110
- lessonId: LessonId;
111
- durationMs?: number;
112
- success?: boolean;
113
- score?: number;
114
- maxScore?: number;
115
- };
116
- type QuizAnsweredData = {
117
- checkId: CheckId;
118
- question: string;
119
- choice: string;
120
- correct: boolean;
121
- };
122
- type QuizCompletedData = {
123
- checkId: CheckId;
124
- score?: number;
125
- maxScore?: number;
126
- passingScore?: number;
127
- };
128
- type AssessmentAnsweredData = {
129
- checkId: CheckId;
130
- interactionType: AssessmentInteractionType;
131
- question?: string;
132
- response?: string | string[] | boolean | Record<string, unknown>;
133
- correct?: boolean;
134
- };
135
- type AssessmentCompletedData = {
136
- checkId: CheckId;
137
- interactionType: AssessmentInteractionType;
138
- score?: number;
139
- maxScore?: number;
140
- passingScore?: number;
141
- };
142
- type InteractionData = {
143
- kind?: string;
144
- blockId?: BlockId;
145
- payload?: Record<string, unknown>;
146
- [key: string]: unknown;
147
- };
148
- type BookPageViewedData = {
149
- blockId: BlockId;
150
- pageIndex: number;
151
- pageTitle?: string;
152
- };
153
- type SlideViewedData = {
154
- blockId: BlockId;
155
- slideIndex: number;
156
- slideTitle?: string;
157
- };
158
- type CompoundPageViewedData = {
159
- blockId: BlockId;
160
- pageIndex: number;
161
- parentType?: string;
162
- };
163
- type HotspotOpenedData = {
164
- blockId: BlockId;
165
- hotspotId: string;
166
- };
167
- type AccordionSectionToggledData = {
168
- blockId: BlockId;
169
- sectionId: string;
170
- expanded: boolean;
171
- };
172
- type FlashcardFlippedData = {
173
- blockId: BlockId;
174
- cardIndex: number;
175
- face: "front" | "back";
176
- };
177
- type ImageSliderChangedData = {
178
- blockId: BlockId;
179
- slideIndex: number;
180
- };
181
- type TelemetryEvent = (TelemetryEventBase & {
182
- name: "course_started";
183
- lessonId?: LessonId;
184
- data?: undefined;
185
- }) | (TelemetryEventBase & {
186
- name: "course_completed";
187
- lessonId?: LessonId;
188
- data?: undefined;
189
- }) | (TelemetryEventBase & {
190
- name: "lesson_started";
191
- lessonId: LessonId;
192
- data: LessonLifecycleData;
193
- }) | (TelemetryEventBase & {
194
- name: "lesson_completed";
195
- lessonId: LessonId;
196
- data: LessonLifecycleData;
197
- }) | (TelemetryEventBase & {
198
- name: "lesson_time_on_task";
199
- lessonId: LessonId;
200
- data: LessonLifecycleData;
201
- }) | (TelemetryEventBase & {
202
- name: "quiz_answered";
203
- lessonId: LessonId;
204
- data: QuizAnsweredData;
205
- }) | (TelemetryEventBase & {
206
- name: "quiz_completed";
207
- lessonId: LessonId;
208
- data: QuizCompletedData;
209
- }) | (TelemetryEventBase & {
210
- name: "assessment_answered";
211
- lessonId: LessonId;
212
- data: AssessmentAnsweredData;
213
- }) | (TelemetryEventBase & {
214
- name: "assessment_completed";
215
- lessonId: LessonId;
216
- data: AssessmentCompletedData;
217
- }) | (TelemetryEventBase & {
218
- name: "interaction";
219
- lessonId?: LessonId;
220
- data?: InteractionData;
221
- }) | (TelemetryEventBase & {
222
- name: "book_page_viewed";
223
- lessonId: LessonId;
224
- data: BookPageViewedData;
225
- }) | (TelemetryEventBase & {
226
- name: "slide_viewed";
227
- lessonId: LessonId;
228
- data: SlideViewedData;
229
- }) | (TelemetryEventBase & {
230
- name: "compound_page_viewed";
231
- lessonId: LessonId;
232
- data: CompoundPageViewedData;
233
- }) | (TelemetryEventBase & {
234
- name: "hotspot_opened";
235
- lessonId?: LessonId;
236
- data: HotspotOpenedData;
237
- }) | (TelemetryEventBase & {
238
- name: "accordion_section_toggled";
239
- lessonId?: LessonId;
240
- data: AccordionSectionToggledData;
241
- }) | (TelemetryEventBase & {
242
- name: "flashcard_flipped";
243
- lessonId?: LessonId;
244
- data: FlashcardFlippedData;
245
- }) | (TelemetryEventBase & {
246
- name: "image_slider_changed";
247
- lessonId?: LessonId;
248
- data: ImageSliderChangedData;
249
- });
250
- /** Payload shape for a telemetry event name. */
251
- type TelemetryDataFor<N extends TelemetryEventName> = Extract<TelemetryEvent, {
252
- name: N;
253
- }> extends {
254
- data?: infer D;
255
- } ? D : never;
256
- type TelemetrySink = (event: TelemetryEvent) => void | Promise<void>;
257
- type TelemetryBatchSink = (events: TelemetryEvent[]) => void | Promise<void>;
258
- type TrackingClient = {
259
- track: (event: TelemetryEvent) => void;
260
- /** Resolves to true when all buffered events were delivered; false when a sink failure re-queued events. */
261
- flush?: () => void | Promise<boolean>;
262
- /** Best-effort synchronous flush for pagehide (keepalive batch sink when configured). */
263
- flushOnExit?: () => void;
264
- dispose?: () => void | Promise<void>;
265
- };
38
+ /** LMS parent-bridge forwarding mode for packaged course runtimes. */
39
+ type LmsBridgeMode = "auto" | "off";
266
40
 
267
41
  declare const COMPOUND_RESUME_SCHEMA_VERSION: 1;
268
42
  /** Serializable resume blob for a compound container (InteractiveBook, AssessmentSequence, …). */
@@ -299,46 +73,28 @@ type CompoundBaseProps = {
299
73
  blockId: BlockId;
300
74
  };
301
75
 
302
- type StoragePort = {
303
- getItem: (key: string) => string | null;
304
- /** Returns false when the value could not be durably persisted (e.g. sessionStorage quota). */
305
- setItem: (key: string, value: string) => boolean;
306
- removeItem?: (key: string) => void;
307
- /** @internal Test helper to clear in-memory fallback state. */
308
- resetForTests?: () => void;
309
- };
310
- type ClockPort = {
311
- nowMs: () => number;
312
- nowIso: () => string;
313
- };
314
- type TimerPort = {
315
- setInterval: (fn: () => void, ms: number) => ReturnType<typeof globalThis.setInterval>;
316
- clearInterval: (id: ReturnType<typeof globalThis.setInterval>) => void;
317
- };
318
- declare function createDefaultClock(): ClockPort;
319
- declare function createNoopStorage(): StoragePort;
320
- declare function resetStoragePortForTests(storage: StoragePort): void;
321
- declare function createSessionStoragePort(): StoragePort;
322
- declare function createGlobalTimer(): TimerPort;
323
-
324
76
  declare function compoundStateStorageKey(courseId: CourseId, compoundId: BlockId): string;
325
77
  declare function loadCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId): CompoundResumeState | null;
326
78
  declare function saveCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId, state: CompoundResumeState): boolean;
327
79
  declare function clearCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId): void;
328
80
 
329
81
  /** Canonical compound child allowlists (H5P sub-content curation). */
330
- declare const PAGE_ALLOWED_CHILD_TYPES: readonly ["Text", "Heading", "Image", "Scenario", "Reflection", "Quiz", "KnowledgeCheck", "TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Accordion", "DialogCards", "Flashcards", "ImageHotspots", "FindHotspot", "FindMultipleHotspots", "ImageSlider", "ProgressTracker"];
82
+ declare const PAGE_ALLOWED_CHILD_TYPES: readonly ["Text", "Heading", "Image", "Video", "Scenario", "Reflection", "Quiz", "KnowledgeCheck", "TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Summary", "ImagePairing", "ImageSequencing", "MemoryGame", "InformationWall", "ParallaxSlideshow", "Questionnaire", "Essay", "ArithmeticQuiz", "Accordion", "DialogCards", "Flashcards", "ImageHotspots", "FindHotspot", "FindMultipleHotspots", "ImageSlider", "ProgressTracker"];
331
83
  declare const INTERACTIVE_BOOK_ALLOWED_CHILD_TYPES: readonly ["Page"];
332
84
  /** Per-slide content (H5P Course Presentation slide row). Excludes ProgressTracker. */
333
- declare const SLIDE_ALLOWED_CHILD_TYPES: readonly ["Text", "Heading", "Image", "Scenario", "Reflection", "Quiz", "KnowledgeCheck", "TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Accordion", "DialogCards", "Flashcards", "ImageHotspots", "FindHotspot", "FindMultipleHotspots", "ImageSlider"];
85
+ declare const SLIDE_ALLOWED_CHILD_TYPES: readonly ["Text", "Heading", "Image", "Video", "Scenario", "Reflection", "Quiz", "KnowledgeCheck", "TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Summary", "ImagePairing", "ImageSequencing", "MemoryGame", "InformationWall", "ParallaxSlideshow", "Questionnaire", "Essay", "ArithmeticQuiz", "Accordion", "DialogCards", "Flashcards", "ImageHotspots", "FindHotspot", "FindMultipleHotspots", "ImageSlider"];
334
86
  declare const SLIDE_DECK_ALLOWED_CHILD_TYPES: readonly ["Slide"];
335
- declare const ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES: readonly ["TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Quiz", "KnowledgeCheck", "FindHotspot", "FindMultipleHotspots"];
336
- type CompoundParentType = "Page" | "InteractiveBook" | "Slide" | "SlideDeck" | "AssessmentSequence";
87
+ declare const TIMED_CUE_ALLOWED_CHILD_TYPES: readonly ["Text", "Heading", "Image", "Quiz", "TrueFalse", "FillInTheBlanks", "Summary", "ImagePairing", "ImageSequencing", "MemoryGame", "Questionnaire", "Essay", "ArithmeticQuiz"];
88
+ declare const INTERACTIVE_VIDEO_ALLOWED_CHILD_TYPES: readonly ["TimedCue"];
89
+ declare const ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES: readonly ["TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Quiz", "KnowledgeCheck", "FindHotspot", "FindMultipleHotspots", "Summary", "ImagePairing", "ImageSequencing", "ArithmeticQuiz", "Essay"];
90
+ type CompoundParentType = "Page" | "InteractiveBook" | "Slide" | "SlideDeck" | "TimedCue" | "InteractiveVideo" | "AssessmentSequence";
337
91
  declare const COMPOUND_MAX_NESTING_DEPTH: Record<CompoundParentType, number>;
338
92
  declare function getAllowedChildTypes(parent: CompoundParentType): readonly string[];
339
93
  declare function isChildTypeAllowed(parent: CompoundParentType, childType: string): boolean;
340
94
  /** Blocks that must not nest inside Accordion (policy: no accordion-in-accordion). */
341
95
  declare const ACCORDION_FORBIDDEN_CHILD_TYPES: readonly ["Accordion"];
96
+ /** New 1.4 blocks added to Page and Slide allowlists (for docs/tests). */
97
+ declare const BLOCKS_14_PAGE_SLIDE: readonly ["Video", "Summary", "ImagePairing", "ImageSequencing", "MemoryGame", "InformationWall", "ParallaxSlideshow", "Questionnaire", "Essay", "ArithmeticQuiz"];
342
98
 
343
99
  declare const telemetryCatalogVersion: 1;
344
100
  type TelemetryCatalogEntry = {
@@ -365,7 +121,7 @@ declare const TELEMETRY_EVENT_CATALOG_V2: TelemetryCatalogV2Entry[];
365
121
  declare function buildTelemetryCatalogV2(): TelemetryCatalogV2Entry[];
366
122
 
367
123
  declare const telemetryCatalogV3Version: 3;
368
- type TelemetryCatalogV3EventName = Extract<TelemetryEventName, "book_page_viewed" | "slide_viewed" | "compound_page_viewed" | "hotspot_opened" | "accordion_section_toggled" | "flashcard_flipped" | "image_slider_changed">;
124
+ type TelemetryCatalogV3EventName = Extract<TelemetryEventName, "book_page_viewed" | "slide_viewed" | "compound_page_viewed" | "hotspot_opened" | "accordion_section_toggled" | "flashcard_flipped" | "image_slider_changed" | "video_cue_reached" | "video_segment_completed" | "memory_card_flipped" | "information_wall_search" | "parallax_slide_viewed" | "questionnaire_submitted">;
369
125
  type TelemetryCatalogV3Entry = {
370
126
  name: TelemetryCatalogV3EventName;
371
127
  description: string;
@@ -395,95 +151,6 @@ declare function createSessionId(): string;
395
151
 
396
152
  declare function nowIso(): string;
397
153
 
398
- type BuildTelemetryEventContext = {
399
- courseId: CourseId;
400
- sessionId?: string;
401
- attemptId?: string;
402
- user?: TelemetryUser;
403
- timestamp?: string;
404
- };
405
- type BuildTelemetryEventInput = (BuildTelemetryEventContext & {
406
- name: "course_started";
407
- lessonId?: LessonId;
408
- data?: undefined;
409
- }) | (BuildTelemetryEventContext & {
410
- name: "course_completed";
411
- lessonId?: LessonId;
412
- data?: undefined;
413
- }) | (BuildTelemetryEventContext & {
414
- name: "lesson_started";
415
- lessonId?: LessonId;
416
- data?: LessonLifecycleData;
417
- }) | (BuildTelemetryEventContext & {
418
- name: "lesson_completed";
419
- lessonId?: LessonId;
420
- data?: LessonLifecycleData;
421
- }) | (BuildTelemetryEventContext & {
422
- name: "lesson_time_on_task";
423
- lessonId?: LessonId;
424
- data?: LessonLifecycleData;
425
- }) | (BuildTelemetryEventContext & {
426
- name: "quiz_answered";
427
- lessonId?: LessonId;
428
- data: QuizAnsweredData;
429
- }) | (BuildTelemetryEventContext & {
430
- name: "quiz_completed";
431
- lessonId?: LessonId;
432
- data: QuizCompletedData;
433
- }) | (BuildTelemetryEventContext & {
434
- name: "assessment_answered";
435
- lessonId?: LessonId;
436
- data: AssessmentAnsweredData;
437
- }) | (BuildTelemetryEventContext & {
438
- name: "assessment_completed";
439
- lessonId?: LessonId;
440
- data: AssessmentCompletedData;
441
- }) | (BuildTelemetryEventContext & {
442
- name: "interaction";
443
- lessonId?: LessonId;
444
- data?: InteractionData;
445
- }) | (BuildTelemetryEventContext & {
446
- name: "book_page_viewed";
447
- lessonId?: LessonId;
448
- data: BookPageViewedData;
449
- }) | (BuildTelemetryEventContext & {
450
- name: "slide_viewed";
451
- lessonId?: LessonId;
452
- data: SlideViewedData;
453
- }) | (BuildTelemetryEventContext & {
454
- name: "compound_page_viewed";
455
- lessonId?: LessonId;
456
- data: CompoundPageViewedData;
457
- }) | (BuildTelemetryEventContext & {
458
- name: "hotspot_opened";
459
- lessonId?: LessonId;
460
- data: HotspotOpenedData;
461
- }) | (BuildTelemetryEventContext & {
462
- name: "accordion_section_toggled";
463
- lessonId?: LessonId;
464
- data: AccordionSectionToggledData;
465
- }) | (BuildTelemetryEventContext & {
466
- name: "flashcard_flipped";
467
- lessonId?: LessonId;
468
- data: FlashcardFlippedData;
469
- }) | (BuildTelemetryEventContext & {
470
- name: "image_slider_changed";
471
- lessonId?: LessonId;
472
- data: ImageSliderChangedData;
473
- });
474
-
475
- /** Reset dev-warning state (tests only). */
476
- declare function resetTelemetryBuilderWarningsForTests(): void;
477
- /**
478
- * Build a typed telemetry event from a catalog event name and context.
479
- * Validates lesson-scoped events require `lessonId`.
480
- */
481
- declare function buildTelemetryEvent(opts: BuildTelemetryEventInput): TelemetryEvent;
482
- /**
483
- * Like `buildTelemetryEvent`, but returns null (with a dev warning) when quiz events lack an active lesson.
484
- */
485
- declare function tryBuildTelemetryEvent(opts: BuildTelemetryEventInput): TelemetryEvent | null;
486
-
487
154
  type EmitContext = {
488
155
  courseId: CourseId;
489
156
  sessionId?: string;
@@ -501,142 +168,6 @@ type TelemetryPipeline = {
501
168
  declare function createTelemetryPipeline(sinks: TelemetryPipelineSink[]): TelemetryPipeline;
502
169
  declare function createTrackingPipelineSink(id: string, track: (event: TelemetryEvent) => void): TelemetryPipelineSink;
503
170
 
504
- type ProgressState = {
505
- activeLessonId?: LessonId;
506
- completedLessonIds: ReadonlySet<LessonId>;
507
- courseCompleted: boolean;
508
- };
509
- type ProgressController = {
510
- getState: () => ProgressState;
511
- setActiveLesson: (lessonId: LessonId, startedAtMs: number) => {
512
- previousLessonId?: LessonId;
513
- };
514
- completeLesson: (lessonId: LessonId, completedAtMs: number) => {
515
- durationMs?: number;
516
- didComplete: boolean;
517
- };
518
- completeCourse: () => {
519
- didComplete: boolean;
520
- };
521
- };
522
- declare function createProgressController(): ProgressController;
523
-
524
- declare const SESSION_STORAGE_KEY = "lessonkit:sessionId";
525
- declare function getTabSessionId(storage: StoragePort): string | null;
526
- declare function resolveSessionId(storage: StoragePort, provided?: string): string;
527
- declare function hasCourseStarted(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
528
- declare function markCourseStarted(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
529
- declare function hasCourseStartedEmittedToTracking(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
530
- declare function markCourseStartedEmittedToTracking(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
531
- declare function hasCourseStartedPipelineDelivered(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
532
- declare function markCourseStartedPipelineDelivered(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
533
- /** @internal Reset shared volatile session id between tests. */
534
- declare function resetSharedVolatileSessionIdForTests(): void;
535
- declare function migrateCourseStartedMark(storage: StoragePort, fromSessionId: string, toSessionId: string, courseId?: CourseId): void;
536
-
537
- /** Plugin category — aligns with roadmap extension areas. */
538
- type LessonkitPluginKind = "analytics" | "lms" | "assessment" | "interaction" | "ai";
539
- type LessonkitPluginContext = {
540
- courseId: CourseId;
541
- sessionId?: string;
542
- attemptId?: string;
543
- user?: TelemetryUser;
544
- };
545
- type AssessmentScoreInput = {
546
- checkId: CheckId;
547
- lessonId?: LessonId;
548
- response: unknown;
549
- };
550
- type AssessmentScoreResult = {
551
- score: number;
552
- maxScore?: number;
553
- passed?: boolean;
554
- feedback?: string;
555
- };
556
- /** Metadata for custom interaction blocks (renderer wiring stays in app code until 1.0). */
557
- type InteractionBlockRegistration = {
558
- blockType: string;
559
- catalogVersion?: string;
560
- description?: string;
561
- };
562
- type PluginIdentity = {
563
- id: string;
564
- version: string;
565
- kind: LessonkitPluginKind;
566
- name?: string;
567
- };
568
- /** Narrow telemetry plugin contract (ISP). */
569
- type TelemetryPlugin = PluginIdentity & {
570
- onTelemetry?: (event: TelemetryEvent, ctx: LessonkitPluginContext) => TelemetryEvent | null;
571
- onTelemetryBatch?: (events: TelemetryEvent[], ctx: LessonkitPluginContext) => void;
572
- wrapTrackingSink?: (sink: TelemetrySink, ctx: LessonkitPluginContext) => TelemetrySink;
573
- };
574
- /** Narrow lifecycle plugin contract (ISP). */
575
- type LifecyclePlugin = PluginIdentity & {
576
- setup?: (ctx: LessonkitPluginContext) => void;
577
- dispose?: () => void;
578
- };
579
- /** Narrow assessment plugin contract (ISP). */
580
- type AssessmentPlugin = PluginIdentity & {
581
- kind: "assessment";
582
- scoreAssessment?: (input: AssessmentScoreInput, ctx: LessonkitPluginContext) => AssessmentScoreResult | null;
583
- };
584
- /**
585
- * Narrow interaction metadata plugin (ISP).
586
- * @experimental Not wired into PluginHost; reserved for a future release.
587
- */
588
- type InteractionPlugin = PluginIdentity & {
589
- interactionBlocks?: InteractionBlockRegistration[];
590
- };
591
- /**
592
- * Combined plugin contract (v1). Prefer segregated types for new plugins.
593
- * @deprecated Prefer `TelemetryPlugin`, `AssessmentPlugin`, or `LifecyclePlugin` via `define*Plugin`.
594
- */
595
- type LessonkitPlugin = PluginIdentity & Partial<Pick<TelemetryPlugin, "onTelemetry" | "onTelemetryBatch" | "wrapTrackingSink"> & Pick<LifecyclePlugin, "setup" | "dispose"> & Pick<AssessmentPlugin, "scoreAssessment"> & Pick<InteractionPlugin, "interactionBlocks">>;
596
- type PluginHost = {
597
- readonly plugins: readonly LessonkitPlugin[];
598
- setupAll: (ctx: LessonkitPluginContext) => void;
599
- disposeAll: () => void;
600
- runTelemetry: (event: TelemetryEvent, ctx: LessonkitPluginContext) => TelemetryEvent | null;
601
- runTelemetryBatch: (events: TelemetryEvent[], ctx: LessonkitPluginContext) => TelemetryEvent[];
602
- deliverTelemetryBatch: (events: TelemetryEvent[], ctx: LessonkitPluginContext) => TelemetryEvent[];
603
- composeTrackingSink: (sink: TelemetrySink | undefined, ctx: LessonkitPluginContext | (() => LessonkitPluginContext)) => TelemetrySink | undefined;
604
- scoreAssessment: (input: AssessmentScoreInput, ctx: LessonkitPluginContext) => AssessmentScoreResult | null;
605
- };
606
- /** Segregated plugin registry (ISP + SRP). */
607
- type PluginRegistry = PluginHost;
608
-
609
- type CourseLifecycleContext = {
610
- courseId: CourseId;
611
- sessionId: string;
612
- attemptId?: string;
613
- user?: TelemetryUser;
614
- storage: StoragePort;
615
- pluginHost: PluginRegistry | null;
616
- lxpackBridge: "auto" | "off";
617
- };
618
- type CourseLifecycleDeps = {
619
- emitCourseStartedEvent: (ctx: CourseLifecycleContext) => boolean;
620
- };
621
- declare function tryEmitCourseStarted(ctx: CourseLifecycleContext, deps: CourseLifecycleDeps, alreadyEmittedToSink: boolean): {
622
- emitted: boolean;
623
- marked: boolean;
624
- };
625
- declare function buildCourseStartedTelemetryEvent(ctx: CourseLifecycleContext): TelemetryEvent;
626
- type LessonCompletionEmitter = (lessonId: LessonId, durationMs?: number) => void;
627
- declare function completeLessonWithTelemetry(opts: {
628
- progress: ProgressController;
629
- lessonId: LessonId;
630
- nowMs: number;
631
- emitLessonCompleted: LessonCompletionEmitter;
632
- }): boolean;
633
- declare function completeCourseWithTelemetry(opts: {
634
- progress: ProgressController;
635
- nowMs: number;
636
- emitLessonCompleted: LessonCompletionEmitter;
637
- emitCourseCompleted: () => void;
638
- }): boolean;
639
-
640
171
  type LessonkitRuntimeVersion = "v1" | "v2";
641
172
  type HeadlessLessonkitPlugins = readonly LessonkitPlugin[] | PluginRegistry | null | undefined;
642
173
  type HeadlessLessonkitConfig = {
@@ -696,4 +227,4 @@ declare function buildPluginContext(opts: {
696
227
  user?: TelemetryUser;
697
228
  }): LessonkitPluginContext;
698
229
 
699
- export { ACCORDION_FORBIDDEN_CHILD_TYPES, ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES, type AccordionSectionToggledData, type AssessmentAnsweredData, type AssessmentBaseProps, type AssessmentBehaviour, type AssessmentCompletedData, type AssessmentHandle, type AssessmentInteractionType, type AssessmentPlugin, type AssessmentResumeState, type AssessmentScoreInput, type AssessmentScoreResult, type AssessmentXAPIData, type BlockId, type BookPageViewedData, type BuildTelemetryEventInput, COMPOUND_MAX_NESTING_DEPTH, COMPOUND_RESUME_SCHEMA_VERSION, type CheckId, type ClockPort, type CompoundBaseProps, type CompoundHandle, type CompoundPageViewedData, type CompoundParentType, type CompoundResumeInput, type CompoundResumeState, type CourseId, type CourseLifecycleContext, type CourseLifecycleDeps, type EmitContext, type FlashcardFlippedData, type HeadlessLessonkitConfig, type HeadlessLessonkitRuntime, type HeadlessRuntimePorts, type HotspotOpenedData, ID_MAX_LENGTH, ID_PATTERN, INTERACTIVE_BOOK_ALLOWED_CHILD_TYPES, type IdentityIdPath, type IdentityValidationIssue, type IdentityValidationResult, type ImageSliderChangedData, type InteractionBlockRegistration, type InteractionData, type InteractionPlugin, type LessonCompletionEmitter, type LessonId, type LessonLifecycleData, type LessonkitPlugin, type LessonkitPluginContext, type LessonkitPluginKind, type LessonkitRuntimeVersion, type LessonkitUrn, type LessonkitUrnParts, type LifecyclePlugin, PAGE_ALLOWED_CHILD_TYPES, type PluginHost, type PluginIdentity, type PluginRegistry, type ProgressController, type ProgressState, type QuizAnsweredData, type QuizCompletedData, SESSION_STORAGE_KEY, SLIDE_ALLOWED_CHILD_TYPES, SLIDE_DECK_ALLOWED_CHILD_TYPES, type SlideViewedData, type StoragePort, TELEMETRY_EVENT_CATALOG, TELEMETRY_EVENT_CATALOG_V2, TELEMETRY_EVENT_CATALOG_V3, type TelemetryBatchSink, type TelemetryCatalogEntry, type TelemetryCatalogV2Entry, type TelemetryCatalogV3Entry, type TelemetryDataFor, type TelemetryEmitFn, type TelemetryEvent, type TelemetryEventBase, type TelemetryEventName, type TelemetryPipeline, type TelemetryPipelineSink, type TelemetryPlugin, type TelemetrySink, type TelemetryUser, type TimerPort, type TrackingClient, assertNever, assertValidId, buildCourseStartedTelemetryEvent, buildLessonkitUrn, buildPluginContext, buildTelemetryCatalog, buildTelemetryCatalogV2, buildTelemetryCatalogV3, buildTelemetryEvent, clampCompoundPageIndex, clearCompoundState, completeCourseWithTelemetry, completeLessonWithTelemetry, compoundStateStorageKey, createCompoundResumeState, createDefaultClock, createGlobalTimer, createLessonkitRuntime, createNoopStorage, createPluginRegistry, createProgressController, createSessionId, createSessionStoragePort, createTelemetryPipeline, createTrackingClient, createTrackingPipelineSink, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin, deriveId, getAllowedChildTypes, getTabSessionId, hasCourseStarted, hasCourseStartedEmittedToTracking, hasCourseStartedPipelineDelivered, isChildTypeAllowed, loadCompoundState, markCourseStarted, markCourseStartedEmittedToTracking, markCourseStartedPipelineDelivered, migrateCourseStartedMark, nowIso, parseBlockId, parseCheckId, parseCompoundResumeState, parseCourseId, parseLessonId, resetSharedVolatileSessionIdForTests, resetStoragePortForTests, resetTelemetryBuilderWarningsForTests, resolveSessionId, saveCompoundState, slugifyId, telemetryCatalogV2Version, telemetryCatalogV3Version, telemetryCatalogVersion, tryBuildTelemetryEvent, tryEmitCourseStarted, validateId };
230
+ export { ACCORDION_FORBIDDEN_CHILD_TYPES, ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES, AssessmentPlugin, AssessmentResumeState, AssessmentScoreInput, AssessmentScoreResult, BLOCKS_14_PAGE_SLIDE, BlockId, COMPOUND_MAX_NESTING_DEPTH, COMPOUND_RESUME_SCHEMA_VERSION, CheckId, ClockPort, type CompoundBaseProps, type CompoundHandle, type CompoundParentType, type CompoundResumeInput, type CompoundResumeState, CourseId, type EmitContext, type HeadlessLessonkitConfig, type HeadlessLessonkitRuntime, type HeadlessRuntimePorts, INTERACTIVE_BOOK_ALLOWED_CHILD_TYPES, INTERACTIVE_VIDEO_ALLOWED_CHILD_TYPES, IdentityIdPath, IdentityValidationResult, LessonId, LessonkitPlugin, LessonkitPluginContext, type LessonkitRuntimeVersion, LessonkitUrn, type LessonkitUrnParts, LifecyclePlugin, type LmsBridgeMode, PAGE_ALLOWED_CHILD_TYPES, PluginHost, PluginRegistry, ProgressController, ProgressState, SLIDE_ALLOWED_CHILD_TYPES, SLIDE_DECK_ALLOWED_CHILD_TYPES, StoragePort, TELEMETRY_EVENT_CATALOG, TELEMETRY_EVENT_CATALOG_V2, TELEMETRY_EVENT_CATALOG_V3, TIMED_CUE_ALLOWED_CHILD_TYPES, TelemetryBatchSink, type TelemetryCatalogEntry, type TelemetryCatalogV2Entry, type TelemetryCatalogV3Entry, TelemetryDataFor, type TelemetryEmitFn, TelemetryEvent, TelemetryEventName, type TelemetryPipeline, type TelemetryPipelineSink, TelemetryPlugin, TelemetrySink, TelemetryUser, TrackingClient, assertNever, assertValidId, buildLessonkitUrn, buildPluginContext, buildTelemetryCatalog, buildTelemetryCatalogV2, buildTelemetryCatalogV3, clampCompoundPageIndex, clearCompoundState, compoundStateStorageKey, createCompoundResumeState, createLessonkitRuntime, createPluginRegistry, createSessionId, createTelemetryPipeline, createTrackingClient, createTrackingPipelineSink, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin, deriveId, getAllowedChildTypes, isChildTypeAllowed, loadCompoundState, nowIso, parseBlockId, parseCheckId, parseCompoundResumeState, parseCourseId, parseLessonId, saveCompoundState, slugifyId, telemetryCatalogV2Version, telemetryCatalogV3Version, telemetryCatalogVersion, validateId };