@lessonkit/core 1.1.0 → 1.3.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.cjs +786 -221
- package/dist/index.d.cts +215 -28
- package/dist/index.d.ts +215 -28
- package/dist/index.js +764 -221
- package/package.json +6 -2
- package/telemetry-catalog.v2.json +21 -0
- package/telemetry-catalog.v3.json +61 -0
package/dist/index.d.cts
CHANGED
|
@@ -55,7 +55,9 @@ type LessonkitUrnParts = {
|
|
|
55
55
|
declare function buildLessonkitUrn(parts: LessonkitUrnParts): LessonkitUrn;
|
|
56
56
|
|
|
57
57
|
/** H5P-aligned interaction kinds for assessment telemetry and xAPI. */
|
|
58
|
-
type AssessmentInteractionType = "mcq" | "trueFalse" | "fillInBlanks" | "markTheWords" | "dragTheWords" | "dragAndDrop" | "assessmentSequence";
|
|
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>;
|
|
59
61
|
/** Behaviour flags aligned with H5P question types. */
|
|
60
62
|
type AssessmentBehaviour = {
|
|
61
63
|
enableRetry?: boolean;
|
|
@@ -82,13 +84,15 @@ type AssessmentHandle = {
|
|
|
82
84
|
resetTask: () => void;
|
|
83
85
|
showSolutions: () => void;
|
|
84
86
|
getXAPIData: () => AssessmentXAPIData;
|
|
87
|
+
getCurrentState?: () => AssessmentResumeState;
|
|
88
|
+
resume?: (state: AssessmentResumeState) => void;
|
|
85
89
|
};
|
|
86
90
|
type AssessmentBaseProps = AssessmentBehaviour & {
|
|
87
91
|
checkId: CheckId;
|
|
88
92
|
passingScore?: number;
|
|
89
93
|
};
|
|
90
94
|
|
|
91
|
-
type TelemetryEventName = "course_started" | "course_completed" | "lesson_started" | "lesson_completed" | "lesson_time_on_task" | "quiz_answered" | "quiz_completed" | "assessment_answered" | "assessment_completed" | "interaction";
|
|
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";
|
|
92
96
|
type TelemetryUser = {
|
|
93
97
|
id?: string;
|
|
94
98
|
email?: string;
|
|
@@ -141,6 +145,39 @@ type InteractionData = {
|
|
|
141
145
|
payload?: Record<string, unknown>;
|
|
142
146
|
[key: string]: unknown;
|
|
143
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
|
+
};
|
|
144
181
|
type TelemetryEvent = (TelemetryEventBase & {
|
|
145
182
|
name: "course_started";
|
|
146
183
|
lessonId?: LessonId;
|
|
@@ -181,6 +218,34 @@ type TelemetryEvent = (TelemetryEventBase & {
|
|
|
181
218
|
name: "interaction";
|
|
182
219
|
lessonId?: LessonId;
|
|
183
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;
|
|
184
249
|
});
|
|
185
250
|
/** Payload shape for a telemetry event name. */
|
|
186
251
|
type TelemetryDataFor<N extends TelemetryEventName> = Extract<TelemetryEvent, {
|
|
@@ -192,10 +257,87 @@ type TelemetrySink = (event: TelemetryEvent) => void | Promise<void>;
|
|
|
192
257
|
type TelemetryBatchSink = (events: TelemetryEvent[]) => void | Promise<void>;
|
|
193
258
|
type TrackingClient = {
|
|
194
259
|
track: (event: TelemetryEvent) => void;
|
|
195
|
-
|
|
260
|
+
/** Resolves to true when all buffered events were delivered; false when a sink failure re-queued events. */
|
|
261
|
+
flush?: () => void | Promise<boolean>;
|
|
196
262
|
dispose?: () => void | Promise<void>;
|
|
197
263
|
};
|
|
198
264
|
|
|
265
|
+
declare const COMPOUND_RESUME_SCHEMA_VERSION: 1;
|
|
266
|
+
/** Serializable resume blob for a compound container (InteractiveBook, AssessmentSequence, …). */
|
|
267
|
+
type CompoundResumeState = {
|
|
268
|
+
schemaVersion: typeof COMPOUND_RESUME_SCHEMA_VERSION;
|
|
269
|
+
activePageIndex: number;
|
|
270
|
+
/** Optional chapter index when nested inside InteractiveBook. */
|
|
271
|
+
activeChapterIndex?: number;
|
|
272
|
+
childStates: Record<string, AssessmentResumeState>;
|
|
273
|
+
};
|
|
274
|
+
type CompoundResumeInput = {
|
|
275
|
+
activePageIndex?: number;
|
|
276
|
+
activeChapterIndex?: number;
|
|
277
|
+
childStates?: Record<CheckId, AssessmentResumeState>;
|
|
278
|
+
};
|
|
279
|
+
declare function createCompoundResumeState(input?: CompoundResumeInput): CompoundResumeState;
|
|
280
|
+
/** Clamp page index to valid range for a compound with `pageCount` pages. */
|
|
281
|
+
declare function clampCompoundPageIndex(index: number, pageCount: number): number;
|
|
282
|
+
declare function parseCompoundResumeState(raw: unknown): CompoundResumeState | null;
|
|
283
|
+
/**
|
|
284
|
+
* Imperative handle for compound containers (H5P compound analogue).
|
|
285
|
+
* Parents aggregate child AssessmentHandle scores and persist navigation state.
|
|
286
|
+
*/
|
|
287
|
+
type CompoundHandle = {
|
|
288
|
+
getScore: () => number;
|
|
289
|
+
getMaxScore: () => number;
|
|
290
|
+
getAnswerGiven: () => boolean;
|
|
291
|
+
resetTask: () => void;
|
|
292
|
+
showSolutions: () => void;
|
|
293
|
+
getCurrentState: () => CompoundResumeState;
|
|
294
|
+
resume: (state: CompoundResumeState) => void;
|
|
295
|
+
};
|
|
296
|
+
type CompoundBaseProps = {
|
|
297
|
+
blockId: BlockId;
|
|
298
|
+
};
|
|
299
|
+
|
|
300
|
+
type StoragePort = {
|
|
301
|
+
getItem: (key: string) => string | null;
|
|
302
|
+
/** Returns false when the value could not be durably persisted (e.g. sessionStorage quota). */
|
|
303
|
+
setItem: (key: string, value: string) => boolean;
|
|
304
|
+
removeItem?: (key: string) => void;
|
|
305
|
+
/** @internal Test helper to clear in-memory fallback state. */
|
|
306
|
+
resetForTests?: () => void;
|
|
307
|
+
};
|
|
308
|
+
type ClockPort = {
|
|
309
|
+
nowMs: () => number;
|
|
310
|
+
nowIso: () => string;
|
|
311
|
+
};
|
|
312
|
+
type TimerPort = {
|
|
313
|
+
setInterval: (fn: () => void, ms: number) => ReturnType<typeof globalThis.setInterval>;
|
|
314
|
+
clearInterval: (id: ReturnType<typeof globalThis.setInterval>) => void;
|
|
315
|
+
};
|
|
316
|
+
declare function createDefaultClock(): ClockPort;
|
|
317
|
+
declare function createNoopStorage(): StoragePort;
|
|
318
|
+
declare function resetStoragePortForTests(storage: StoragePort): void;
|
|
319
|
+
declare function createSessionStoragePort(): StoragePort;
|
|
320
|
+
declare function createGlobalTimer(): TimerPort;
|
|
321
|
+
|
|
322
|
+
declare function compoundStateStorageKey(courseId: CourseId, compoundId: BlockId): string;
|
|
323
|
+
declare function loadCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId): CompoundResumeState | null;
|
|
324
|
+
declare function saveCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId, state: CompoundResumeState): boolean;
|
|
325
|
+
declare function clearCompoundState(storage: StoragePort, courseId: CourseId, compoundId: BlockId): void;
|
|
326
|
+
|
|
327
|
+
/** Canonical compound child allowlists (H5P sub-content curation). */
|
|
328
|
+
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"];
|
|
329
|
+
declare const INTERACTIVE_BOOK_ALLOWED_CHILD_TYPES: readonly ["Page"];
|
|
330
|
+
/** Per-slide content (H5P Course Presentation slide row). Excludes ProgressTracker. */
|
|
331
|
+
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"];
|
|
332
|
+
declare const SLIDE_DECK_ALLOWED_CHILD_TYPES: readonly ["Slide"];
|
|
333
|
+
declare const ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES: readonly ["TrueFalse", "FillInTheBlanks", "DragAndDrop", "DragTheWords", "MarkTheWords", "Quiz", "KnowledgeCheck", "FindHotspot", "FindMultipleHotspots"];
|
|
334
|
+
type CompoundParentType = "Page" | "InteractiveBook" | "Slide" | "SlideDeck" | "AssessmentSequence";
|
|
335
|
+
declare const COMPOUND_MAX_NESTING_DEPTH: Record<CompoundParentType, number>;
|
|
336
|
+
declare function getAllowedChildTypes(parent: CompoundParentType): readonly string[];
|
|
337
|
+
declare function isChildTypeAllowed(parent: CompoundParentType, childType: string): boolean;
|
|
338
|
+
/** Blocks that must not nest inside Accordion (policy: no accordion-in-accordion). */
|
|
339
|
+
declare const ACCORDION_FORBIDDEN_CHILD_TYPES: readonly ["Accordion"];
|
|
340
|
+
|
|
199
341
|
declare const telemetryCatalogVersion: 1;
|
|
200
342
|
type TelemetryCatalogEntry = {
|
|
201
343
|
name: TelemetryEventName;
|
|
@@ -220,6 +362,19 @@ type TelemetryCatalogV2Entry = {
|
|
|
220
362
|
declare const TELEMETRY_EVENT_CATALOG_V2: TelemetryCatalogV2Entry[];
|
|
221
363
|
declare function buildTelemetryCatalogV2(): TelemetryCatalogV2Entry[];
|
|
222
364
|
|
|
365
|
+
declare const telemetryCatalogV3Version: 3;
|
|
366
|
+
type TelemetryCatalogV3EventName = Extract<TelemetryEventName, "book_page_viewed" | "slide_viewed" | "compound_page_viewed" | "hotspot_opened" | "accordion_section_toggled" | "flashcard_flipped" | "image_slider_changed">;
|
|
367
|
+
type TelemetryCatalogV3Entry = {
|
|
368
|
+
name: TelemetryCatalogV3EventName;
|
|
369
|
+
description: string;
|
|
370
|
+
requiredFields: string[];
|
|
371
|
+
dataFields: string[];
|
|
372
|
+
xapiVerb: string;
|
|
373
|
+
urnPattern: string;
|
|
374
|
+
};
|
|
375
|
+
declare const TELEMETRY_EVENT_CATALOG_V3: TelemetryCatalogV3Entry[];
|
|
376
|
+
declare function buildTelemetryCatalogV3(): TelemetryCatalogV3Entry[];
|
|
377
|
+
|
|
223
378
|
declare function createTrackingClient(opts?: {
|
|
224
379
|
sink?: TelemetrySink;
|
|
225
380
|
batch?: {
|
|
@@ -228,6 +383,8 @@ declare function createTrackingClient(opts?: {
|
|
|
228
383
|
maxBatchSize?: number;
|
|
229
384
|
};
|
|
230
385
|
batchSink?: TelemetryBatchSink;
|
|
386
|
+
/** Called when an event is dropped because the batch buffer is at cap (including in production). */
|
|
387
|
+
onBufferDrop?: () => void;
|
|
231
388
|
}): TrackingClient;
|
|
232
389
|
|
|
233
390
|
declare function createSessionId(): string;
|
|
@@ -281,7 +438,36 @@ type BuildTelemetryEventInput = (BuildTelemetryEventContext & {
|
|
|
281
438
|
name: "interaction";
|
|
282
439
|
lessonId?: LessonId;
|
|
283
440
|
data?: InteractionData;
|
|
441
|
+
}) | (BuildTelemetryEventContext & {
|
|
442
|
+
name: "book_page_viewed";
|
|
443
|
+
lessonId?: LessonId;
|
|
444
|
+
data: BookPageViewedData;
|
|
445
|
+
}) | (BuildTelemetryEventContext & {
|
|
446
|
+
name: "slide_viewed";
|
|
447
|
+
lessonId?: LessonId;
|
|
448
|
+
data: SlideViewedData;
|
|
449
|
+
}) | (BuildTelemetryEventContext & {
|
|
450
|
+
name: "compound_page_viewed";
|
|
451
|
+
lessonId?: LessonId;
|
|
452
|
+
data: CompoundPageViewedData;
|
|
453
|
+
}) | (BuildTelemetryEventContext & {
|
|
454
|
+
name: "hotspot_opened";
|
|
455
|
+
lessonId?: LessonId;
|
|
456
|
+
data: HotspotOpenedData;
|
|
457
|
+
}) | (BuildTelemetryEventContext & {
|
|
458
|
+
name: "accordion_section_toggled";
|
|
459
|
+
lessonId?: LessonId;
|
|
460
|
+
data: AccordionSectionToggledData;
|
|
461
|
+
}) | (BuildTelemetryEventContext & {
|
|
462
|
+
name: "flashcard_flipped";
|
|
463
|
+
lessonId?: LessonId;
|
|
464
|
+
data: FlashcardFlippedData;
|
|
465
|
+
}) | (BuildTelemetryEventContext & {
|
|
466
|
+
name: "image_slider_changed";
|
|
467
|
+
lessonId?: LessonId;
|
|
468
|
+
data: ImageSliderChangedData;
|
|
284
469
|
});
|
|
470
|
+
|
|
285
471
|
/** Reset dev-warning state (tests only). */
|
|
286
472
|
declare function resetTelemetryBuilderWarningsForTests(): void;
|
|
287
473
|
/**
|
|
@@ -311,27 +497,6 @@ type TelemetryPipeline = {
|
|
|
311
497
|
declare function createTelemetryPipeline(sinks: TelemetryPipelineSink[]): TelemetryPipeline;
|
|
312
498
|
declare function createTrackingPipelineSink(id: string, track: (event: TelemetryEvent) => void): TelemetryPipelineSink;
|
|
313
499
|
|
|
314
|
-
type StoragePort = {
|
|
315
|
-
getItem: (key: string) => string | null;
|
|
316
|
-
setItem: (key: string, value: string) => void;
|
|
317
|
-
removeItem?: (key: string) => void;
|
|
318
|
-
/** @internal Test helper to clear in-memory fallback state. */
|
|
319
|
-
resetForTests?: () => void;
|
|
320
|
-
};
|
|
321
|
-
type ClockPort = {
|
|
322
|
-
nowMs: () => number;
|
|
323
|
-
nowIso: () => string;
|
|
324
|
-
};
|
|
325
|
-
type TimerPort = {
|
|
326
|
-
setInterval: (fn: () => void, ms: number) => ReturnType<typeof globalThis.setInterval>;
|
|
327
|
-
clearInterval: (id: ReturnType<typeof globalThis.setInterval>) => void;
|
|
328
|
-
};
|
|
329
|
-
declare function createDefaultClock(): ClockPort;
|
|
330
|
-
declare function createNoopStorage(): StoragePort;
|
|
331
|
-
declare function resetStoragePortForTests(storage: StoragePort): void;
|
|
332
|
-
declare function createSessionStoragePort(): StoragePort;
|
|
333
|
-
declare function createGlobalTimer(): TimerPort;
|
|
334
|
-
|
|
335
500
|
type ProgressState = {
|
|
336
501
|
activeLessonId?: LessonId;
|
|
337
502
|
completedLessonIds: ReadonlySet<LessonId>;
|
|
@@ -356,11 +521,13 @@ declare const SESSION_STORAGE_KEY = "lessonkit:sessionId";
|
|
|
356
521
|
declare function getTabSessionId(storage: StoragePort): string | null;
|
|
357
522
|
declare function resolveSessionId(storage: StoragePort, provided?: string): string;
|
|
358
523
|
declare function hasCourseStarted(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
|
|
359
|
-
declare function markCourseStarted(storage: StoragePort, sessionId: string, courseId?: CourseId):
|
|
524
|
+
declare function markCourseStarted(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
|
|
360
525
|
declare function hasCourseStartedEmittedToTracking(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
|
|
361
526
|
declare function markCourseStartedEmittedToTracking(storage: StoragePort, sessionId: string, courseId?: CourseId): void;
|
|
362
527
|
declare function hasCourseStartedPipelineDelivered(storage: StoragePort, sessionId: string, courseId?: CourseId): boolean;
|
|
363
528
|
declare function markCourseStartedPipelineDelivered(storage: StoragePort, sessionId: string, courseId?: CourseId): void;
|
|
529
|
+
/** @internal Reset shared volatile session id between tests. */
|
|
530
|
+
declare function resetSharedVolatileSessionIdForTests(): void;
|
|
364
531
|
declare function migrateCourseStartedMark(storage: StoragePort, fromSessionId: string, toSessionId: string, courseId?: CourseId): void;
|
|
365
532
|
|
|
366
533
|
/** Plugin category — aligns with roadmap extension areas. */
|
|
@@ -410,7 +577,10 @@ type AssessmentPlugin = PluginIdentity & {
|
|
|
410
577
|
kind: "assessment";
|
|
411
578
|
scoreAssessment?: (input: AssessmentScoreInput, ctx: LessonkitPluginContext) => AssessmentScoreResult | null;
|
|
412
579
|
};
|
|
413
|
-
/**
|
|
580
|
+
/**
|
|
581
|
+
* Narrow interaction metadata plugin (ISP).
|
|
582
|
+
* @experimental Not wired into PluginHost; reserved for a future release.
|
|
583
|
+
*/
|
|
414
584
|
type InteractionPlugin = PluginIdentity & {
|
|
415
585
|
interactionBlocks?: InteractionBlockRegistration[];
|
|
416
586
|
};
|
|
@@ -464,6 +634,7 @@ declare function completeCourseWithTelemetry(opts: {
|
|
|
464
634
|
}): boolean;
|
|
465
635
|
|
|
466
636
|
type LessonkitRuntimeVersion = "v1" | "v2";
|
|
637
|
+
type HeadlessLessonkitPlugins = readonly LessonkitPlugin[] | PluginRegistry | null | undefined;
|
|
467
638
|
type HeadlessLessonkitConfig = {
|
|
468
639
|
courseId: CourseId;
|
|
469
640
|
runtimeVersion?: LessonkitRuntimeVersion;
|
|
@@ -472,7 +643,10 @@ type HeadlessLessonkitConfig = {
|
|
|
472
643
|
attemptId?: string;
|
|
473
644
|
user?: TelemetryUser;
|
|
474
645
|
};
|
|
475
|
-
|
|
646
|
+
/** Plugin list or registry; hooks run on {@link HeadlessLessonkitRuntime.track} and lifecycle emits. */
|
|
647
|
+
plugins?: HeadlessLessonkitPlugins;
|
|
648
|
+
/** When true, skip initial {@link PluginHost.setupAll}; host caller runs setup (React v2 provider). */
|
|
649
|
+
deferPluginSetup?: boolean;
|
|
476
650
|
};
|
|
477
651
|
type HeadlessRuntimePorts = {
|
|
478
652
|
storage?: StoragePort;
|
|
@@ -484,6 +658,7 @@ type TelemetryEmitFn = {
|
|
|
484
658
|
type HeadlessLessonkitRuntime = {
|
|
485
659
|
readonly config: HeadlessLessonkitConfig;
|
|
486
660
|
readonly progress: ProgressController;
|
|
661
|
+
readonly pluginHost: PluginHost | null;
|
|
487
662
|
getProgressState: () => ProgressState;
|
|
488
663
|
getSession: () => {
|
|
489
664
|
sessionId: string;
|
|
@@ -495,14 +670,26 @@ type HeadlessLessonkitRuntime = {
|
|
|
495
670
|
completeLesson: (lessonId: LessonId, emit: TelemetryEmitFn) => void;
|
|
496
671
|
completeCourse: (emit: TelemetryEmitFn) => void;
|
|
497
672
|
track: <N extends TelemetryEventName>(name: N, data: TelemetryDataFor<N> | undefined, emit: (event: TelemetryEvent) => void, lessonId?: LessonId) => void;
|
|
673
|
+
scoreAssessment: (input: AssessmentScoreInput, lessonId?: LessonId) => AssessmentScoreResult | null;
|
|
498
674
|
resetForCourseChange: (courseId: CourseId) => void;
|
|
675
|
+
dispose: () => void;
|
|
499
676
|
};
|
|
500
677
|
declare function createLessonkitRuntime(config: HeadlessLessonkitConfig, ports?: HeadlessRuntimePorts): HeadlessLessonkitRuntime;
|
|
501
678
|
|
|
502
679
|
declare function createPluginRegistry(plugins?: readonly LessonkitPlugin[]): PluginRegistry;
|
|
503
680
|
|
|
681
|
+
/** Identity helper for telemetry plugins; does not validate or register at import time. */
|
|
504
682
|
declare function defineTelemetryPlugin(plugin: TelemetryPlugin): LessonkitPlugin;
|
|
683
|
+
/** Identity helper for assessment plugins; does not validate or register at import time. */
|
|
505
684
|
declare function defineAssessmentPlugin(plugin: AssessmentPlugin): LessonkitPlugin;
|
|
685
|
+
/** Identity helper for lifecycle plugins; does not validate or register at import time. */
|
|
506
686
|
declare function defineLifecyclePlugin(plugin: LifecyclePlugin): LessonkitPlugin;
|
|
507
687
|
|
|
508
|
-
|
|
688
|
+
declare function buildPluginContext(opts: {
|
|
689
|
+
courseId: CourseId;
|
|
690
|
+
sessionId?: string;
|
|
691
|
+
attemptId?: string;
|
|
692
|
+
user?: TelemetryUser;
|
|
693
|
+
}): LessonkitPluginContext;
|
|
694
|
+
|
|
695
|
+
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 };
|