@lessonkit/react 1.4.0 → 1.5.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,11 +1,11 @@
1
1
  import React__default from 'react';
2
2
  import * as _lessonkit_core from '@lessonkit/core';
3
- import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LmsBridgeMode, LessonkitPlugin, ProgressState, StoragePort, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, McqAssessmentProps, BlockId, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
3
+ import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LmsBridgeMode, LessonkitPlugin, StoragePort, ProgressState, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, McqAssessmentProps, BlockId, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
4
4
  export { AssessmentAnsweredData, AssessmentBaseProps, AssessmentBehaviour, AssessmentCompletedData, AssessmentHandle, AssessmentInteractionType, AssessmentScoreInput, AssessmentScoreResult, AssessmentXAPIData, CompoundBaseProps, CompoundHandle, CompoundResumeState, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, LmsBridgeMode, McqAssessmentProps, PluginHost, PluginRegistry, TelemetryPipelineSink, buildTelemetryEvent, createLessonkitRuntime, createPluginRegistry, createTelemetryPipeline, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin } from '@lessonkit/core';
5
5
  import * as _lessonkit_xapi from '@lessonkit/xapi';
6
6
  import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
7
- export { Accordion, AccordionProps, AccordionSection, ArithmeticProblem, ArithmeticQuiz, ArithmeticQuizProps, AssessmentSequence, AssessmentSequenceProps, DialogCard, DialogCards, DialogCardsProps, DragAndDrop, DragAndDropProps, DragItem, DragTheWords, DragTheWordsProps, DropTarget, Essay, EssayProps, FillInBlankSpec, FillInTheBlanks, FillInTheBlanksProps, FindHotspot, FindHotspotProps, FindMultipleHotspots, FindMultipleHotspotsProps, Flashcard, Flashcards, FlashcardsProps, Heading, HeadingProps, HotspotSpec, HotspotTarget, Image, ImageHotspots, ImageHotspotsProps, ImagePair, ImagePairing, ImagePairingProps, ImageProps, ImageSequencing, ImageSequencingProps, ImageSlide, ImageSlider, ImageSliderProps, InformationPanel, InformationWall, InformationWallProps, InteractiveBook, InteractiveBookProps, InteractiveVideo, InteractiveVideoProps, MarkTheWords, MarkTheWordsProps, MemoryGame, MemoryGameProps, MemoryPair, Page, PageProps, ParallaxSlide, ParallaxSlideshow, ParallaxSlideshowProps, Questionnaire, QuestionnaireField, QuestionnaireProps, SequencingImage, Slide, SlideDeck, SlideDeckProps, SlideProps, Summary, SummaryProps, Text, TextProps, TimedCue, TimedCueProps, TrueFalse, TrueFalseProps, Video, VideoProps } from './blocks-entry.cjs';
8
- export { K as KnowledgeCheck, Q as Quiz, a as QuizProps, r as resetAssessmentWarningsForTests, b as resetQuizWarningsForTests } from './AssessmentLessonGuard-D2Plzybb.cjs';
7
+ export { Accordion, AccordionProps, AccordionSection, ArithmeticProblem, ArithmeticQuiz, ArithmeticQuizProps, AssessmentSequence, AssessmentSequenceProps, BranchChoice, BranchChoiceProps, BranchNode, BranchNodeProps, BranchingScenario, BranchingScenarioProps, Chart, ChartDatum, ChartProps, DialogCard, DialogCards, DialogCardsProps, DragAndDrop, DragAndDropProps, DragItem, DragTheWords, DragTheWordsProps, DropTarget, Embed, EmbedProps, Essay, EssayProps, FillInBlankSpec, FillInTheBlanks, FillInTheBlanksProps, FindHotspot, FindHotspotProps, FindMultipleHotspots, FindMultipleHotspotsProps, Flashcard, Flashcards, FlashcardsProps, Heading, HeadingProps, HotspotSpec, HotspotTarget, Image, ImageHotspots, ImageHotspotsProps, ImagePair, ImagePairing, ImagePairingProps, ImageProps, ImageSequencing, ImageSequencingProps, ImageSlide, ImageSlider, ImageSliderProps, InformationPanel, InformationWall, InformationWallProps, InteractiveBook, InteractiveBookProps, InteractiveVideo, InteractiveVideoProps, MarkTheWords, MarkTheWordsProps, MemoryGame, MemoryGameProps, MemoryPair, Page, PageProps, ParallaxSlide, ParallaxSlideshow, ParallaxSlideshowProps, Questionnaire, QuestionnaireField, QuestionnaireProps, SequencingImage, Slide, SlideDeck, SlideDeckProps, SlideProps, Summary, SummaryProps, Text, TextProps, TimedCue, TimedCueProps, TrueFalse, TrueFalseProps, Video, VideoProps } from './blocks-entry.cjs';
8
+ export { K as KnowledgeCheck, Q as Quiz, b as QuizProps, r as resetAssessmentWarningsForTests, a as resetQuizWarningsForTests } from './AssessmentLessonGuard-BzNPbjaV.cjs';
9
9
  import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
10
10
  export { ThemePresetName } from '@lessonkit/themes';
11
11
 
@@ -22,10 +22,29 @@ type LessonkitObservabilityConfig = {
22
22
  onTelemetryBufferDrop?: () => void;
23
23
  /** LMS bridge missing for a completion-related telemetry event (`bridge: auto`). */
24
24
  onLxpackBridgeMiss?: (event: TelemetryEvent) => void;
25
+ /** LMS bridge host threw while forwarding telemetry (`bridge: auto`). */
26
+ onLxpackBridgeError?: (err: unknown) => void;
25
27
  /** xAPI transport failure after retries (statement re-queued). */
26
28
  onXapiTransportError?: (err: unknown) => void;
29
+ /** Telemetry → xAPI mapping failure (statement skipped). */
30
+ onXapiMappingError?: (err: unknown) => void;
31
+ /** Compound child resume incomplete after hydration retries. */
32
+ onCompoundHydrationPartial?: (ctx: {
33
+ compoundId: string;
34
+ missingCheckIds: string[];
35
+ }) => void;
36
+ /** Corrupt compound resume blob or invalid child states stripped on load. */
37
+ onCompoundResumeCorrupt?: (ctx: {
38
+ compoundId: string;
39
+ droppedChildKeys?: string[];
40
+ corrupt?: boolean;
41
+ }) => void;
27
42
  };
28
43
 
44
+ /**
45
+ * Runtime configuration for {@link LessonkitProvider} and {@link Course}.
46
+ * Pass tracking, xAPI, LMS bridge, observability hooks, and plugins here.
47
+ */
29
48
  type LessonkitConfig = {
30
49
  courseId: CourseId;
31
50
  session?: {
@@ -39,6 +58,12 @@ type LessonkitConfig = {
39
58
  enabled?: boolean;
40
59
  sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
41
60
  batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
61
+ /** Factory for a custom tracking client (alternative to sink/batchSink). */
62
+ createClient?: () => TrackingClient;
63
+ /** Explicit opt-in for console sinks in production builds. */
64
+ consoleSink?: boolean;
65
+ /** Re-emit assessment telemetry when restoring session state (default false). */
66
+ replayResumeEvents?: boolean;
42
67
  /** Keepalive batch delivery for pagehide (e.g. from createFetchBatchSink). */
43
68
  exitBatchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
44
69
  batch?: {
@@ -50,6 +75,8 @@ type LessonkitConfig = {
50
75
  xapi?: {
51
76
  enabled?: boolean;
52
77
  transport?: XAPITransport;
78
+ /** Explicit opt-in for console transport in production builds. */
79
+ consoleTransport?: boolean;
53
80
  /** Keepalive transport for pagehide (e.g. from createFetchTransport). */
54
81
  exitTransport?: _lessonkit_xapi.XAPIExitTransport;
55
82
  /** Abort in-flight transport by statement id (e.g. from createFetchTransport). */
@@ -59,6 +86,8 @@ type LessonkitConfig = {
59
86
  lxpack?: {
60
87
  /** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
61
88
  bridge?: LmsBridgeMode;
89
+ /** Parent-frame origins allowed to receive bridge calls when `bridge` is `auto`. */
90
+ allowedParentOrigins?: string[];
62
91
  };
63
92
  /** Framework plugins (analytics, LMS, assessment, interaction, AI). */
64
93
  plugins?: LessonkitPlugin[];
@@ -68,6 +97,22 @@ type LessonkitConfig = {
68
97
  sinks?: _lessonkit_core.TelemetryPipelineSink[];
69
98
  /** Production hooks for sink failures, xAPI queue depth, and LMS bridge misses. */
70
99
  observability?: LessonkitObservabilityConfig;
100
+ /** Optional storage port override (default: per-provider sessionStorage-backed port). */
101
+ storage?: StoragePort;
102
+ /** Embed block security defaults. */
103
+ embed?: {
104
+ /** Strip `allow-popups` from iframe sandbox in production builds (default true). */
105
+ restrictPopupsInProduction?: boolean;
106
+ /** Hostnames allowed to bypass the production private-network media/embed blocklist. */
107
+ allowedHosts?: string[];
108
+ };
109
+ /**
110
+ * Non-production preview options. `allowConsoleTelemetry` skips production guard
111
+ * checks for console sinks (docs demos only — not for shipped LMS courses).
112
+ */
113
+ preview?: {
114
+ allowConsoleTelemetry?: boolean;
115
+ };
71
116
  };
72
117
 
73
118
  type LessonkitProviderProps = {
@@ -95,6 +140,10 @@ type LessonkitRuntime = {
95
140
  }) => void;
96
141
  plugins: PluginHost | null;
97
142
  };
143
+ /**
144
+ * Root runtime provider for telemetry, xAPI, progress, and LMS bridge forwarding.
145
+ * Prefer wrapping with {@link Course} unless you need a custom layout.
146
+ */
98
147
  declare function LessonkitProvider(props: LessonkitProviderProps): React__default.JSX.Element;
99
148
 
100
149
  type CourseProps = {
@@ -126,7 +175,27 @@ type KnowledgeCheckProps = McqAssessmentProps;
126
175
  type ProgressTrackerProps = {
127
176
  totalLessons?: number;
128
177
  };
178
+ /**
179
+ * Top-level course shell. Wraps {@link LessonkitProvider} and renders a semantic section with title.
180
+ *
181
+ * @example
182
+ * ```tsx
183
+ * <Course title="Security 101" courseId="sec-101" config={courseConfig}>
184
+ * <Lesson title="Phishing" lessonId="phishing-101">…</Lesson>
185
+ * </Course>
186
+ * ```
187
+ */
129
188
  declare function Course(props: CourseProps): React__default.JSX.Element;
189
+ /**
190
+ * Lesson container. Sets the active lesson on mount and emits lesson lifecycle telemetry.
191
+ *
192
+ * @example
193
+ * ```tsx
194
+ * <Lesson title="Phishing" lessonId="phishing-101">
195
+ * <Scenario>…</Scenario>
196
+ * </Lesson>
197
+ * ```
198
+ */
130
199
  declare function Lesson(props: LessonProps): React__default.JSX.Element;
131
200
  declare function Scenario(props: ScenarioProps): React__default.JSX.Element;
132
201
  declare function Reflection(props: ReflectionProps): React__default.JSX.Element;
@@ -138,7 +207,9 @@ declare function useAssessmentState(enclosingLessonId?: LessonId): {
138
207
  };
139
208
 
140
209
  declare function useLessonkit(): LessonkitRuntime;
210
+ /** Read course progress state (completed lessons, active lesson). */
141
211
  declare function useProgress(): _lessonkit_core.ProgressState;
212
+ /** Emit typed telemetry events from custom UI (`track("interaction", …)`). */
142
213
  declare function useTracking(): {
143
214
  track: <N extends _lessonkit_core.TelemetryEventName>(name: N, data?: _lessonkit_core.TelemetryDataFor<N>, opts?: {
144
215
  lessonId?: LessonId;
@@ -171,7 +242,7 @@ declare function shouldEnforceProductionGuard(): boolean;
171
242
  * Throws in production when course config still uses dev-only console sinks or
172
243
  * omits observability hooks while telemetry/xAPI are enabled.
173
244
  */
174
- declare function assertProductionCourseConfig(config: Pick<LessonkitConfig, "tracking" | "xapi" | "observability" | "lxpack">): void;
245
+ declare function assertProductionCourseConfig(config: Pick<LessonkitConfig, "tracking" | "xapi" | "observability" | "lxpack" | "preview">): void;
175
246
 
176
247
  type ThemeMode = "light" | "dark" | "system";
177
248
  type ThemeResolvedMode = "light" | "dark";
@@ -193,6 +264,22 @@ type ThemeContextValue = {
193
264
  declare function ThemeProvider(props: ThemeProviderProps): React__default.JSX.Element;
194
265
  declare function useTheme(): ThemeContextValue;
195
266
 
267
+ type BranchingScenarioContextValue = {
268
+ compoundBlockId: string;
269
+ activeNodeId: string;
270
+ visitedNodeIds: readonly string[];
271
+ visitedLabels: readonly string[];
272
+ navigateToNode: (opts: {
273
+ fromNodeId: string;
274
+ toNodeId: string;
275
+ label: string;
276
+ scoreWeight?: number;
277
+ }) => void;
278
+ isTerminal: boolean;
279
+ choicesLocked: boolean;
280
+ };
281
+ declare function useBranchingScenario(): BranchingScenarioContextValue;
282
+
196
283
  declare const blockCatalogVersion: 1;
197
284
  declare const blockCatalogV2Version: 2;
198
285
  declare const blockCatalogV3Version: 3;
@@ -454,4 +541,4 @@ type BuildBlockCatalogOptions = {
454
541
  declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[] | BlockCatalogEntryV3[];
455
542
  declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | BlockCatalogEntryV3 | undefined;
456
543
 
457
- export { BLOCK_CATALOG, BLOCK_CATALOG_V2, BLOCK_CATALOG_V3, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockCatalogEntryV3, type BlockPropSpec, Course, type CourseProps, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, type LessonkitObservabilityConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, ProgressTracker, type ProgressTrackerProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, assertProductionCourseConfig, blockCatalogV2Version, blockCatalogV3Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, shouldEnforceProductionGuard, useAssessmentState, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
544
+ export { BLOCK_CATALOG, BLOCK_CATALOG_V2, BLOCK_CATALOG_V3, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockCatalogEntryV3, type BlockPropSpec, Course, type CourseProps, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, type LessonkitObservabilityConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, ProgressTracker, type ProgressTrackerProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, assertProductionCourseConfig, blockCatalogV2Version, blockCatalogV3Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, shouldEnforceProductionGuard, useAssessmentState, useBranchingScenario, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  import React__default from 'react';
2
2
  import * as _lessonkit_core from '@lessonkit/core';
3
- import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LmsBridgeMode, LessonkitPlugin, ProgressState, StoragePort, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, McqAssessmentProps, BlockId, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
3
+ import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LmsBridgeMode, LessonkitPlugin, StoragePort, ProgressState, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, McqAssessmentProps, BlockId, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
4
4
  export { AssessmentAnsweredData, AssessmentBaseProps, AssessmentBehaviour, AssessmentCompletedData, AssessmentHandle, AssessmentInteractionType, AssessmentScoreInput, AssessmentScoreResult, AssessmentXAPIData, CompoundBaseProps, CompoundHandle, CompoundResumeState, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, LmsBridgeMode, McqAssessmentProps, PluginHost, PluginRegistry, TelemetryPipelineSink, buildTelemetryEvent, createLessonkitRuntime, createPluginRegistry, createTelemetryPipeline, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin } from '@lessonkit/core';
5
5
  import * as _lessonkit_xapi from '@lessonkit/xapi';
6
6
  import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
7
- export { Accordion, AccordionProps, AccordionSection, ArithmeticProblem, ArithmeticQuiz, ArithmeticQuizProps, AssessmentSequence, AssessmentSequenceProps, DialogCard, DialogCards, DialogCardsProps, DragAndDrop, DragAndDropProps, DragItem, DragTheWords, DragTheWordsProps, DropTarget, Essay, EssayProps, FillInBlankSpec, FillInTheBlanks, FillInTheBlanksProps, FindHotspot, FindHotspotProps, FindMultipleHotspots, FindMultipleHotspotsProps, Flashcard, Flashcards, FlashcardsProps, Heading, HeadingProps, HotspotSpec, HotspotTarget, Image, ImageHotspots, ImageHotspotsProps, ImagePair, ImagePairing, ImagePairingProps, ImageProps, ImageSequencing, ImageSequencingProps, ImageSlide, ImageSlider, ImageSliderProps, InformationPanel, InformationWall, InformationWallProps, InteractiveBook, InteractiveBookProps, InteractiveVideo, InteractiveVideoProps, MarkTheWords, MarkTheWordsProps, MemoryGame, MemoryGameProps, MemoryPair, Page, PageProps, ParallaxSlide, ParallaxSlideshow, ParallaxSlideshowProps, Questionnaire, QuestionnaireField, QuestionnaireProps, SequencingImage, Slide, SlideDeck, SlideDeckProps, SlideProps, Summary, SummaryProps, Text, TextProps, TimedCue, TimedCueProps, TrueFalse, TrueFalseProps, Video, VideoProps } from './blocks-entry.js';
8
- export { K as KnowledgeCheck, Q as Quiz, a as QuizProps, r as resetAssessmentWarningsForTests, b as resetQuizWarningsForTests } from './AssessmentLessonGuard-D2Plzybb.js';
7
+ export { Accordion, AccordionProps, AccordionSection, ArithmeticProblem, ArithmeticQuiz, ArithmeticQuizProps, AssessmentSequence, AssessmentSequenceProps, BranchChoice, BranchChoiceProps, BranchNode, BranchNodeProps, BranchingScenario, BranchingScenarioProps, Chart, ChartDatum, ChartProps, DialogCard, DialogCards, DialogCardsProps, DragAndDrop, DragAndDropProps, DragItem, DragTheWords, DragTheWordsProps, DropTarget, Embed, EmbedProps, Essay, EssayProps, FillInBlankSpec, FillInTheBlanks, FillInTheBlanksProps, FindHotspot, FindHotspotProps, FindMultipleHotspots, FindMultipleHotspotsProps, Flashcard, Flashcards, FlashcardsProps, Heading, HeadingProps, HotspotSpec, HotspotTarget, Image, ImageHotspots, ImageHotspotsProps, ImagePair, ImagePairing, ImagePairingProps, ImageProps, ImageSequencing, ImageSequencingProps, ImageSlide, ImageSlider, ImageSliderProps, InformationPanel, InformationWall, InformationWallProps, InteractiveBook, InteractiveBookProps, InteractiveVideo, InteractiveVideoProps, MarkTheWords, MarkTheWordsProps, MemoryGame, MemoryGameProps, MemoryPair, Page, PageProps, ParallaxSlide, ParallaxSlideshow, ParallaxSlideshowProps, Questionnaire, QuestionnaireField, QuestionnaireProps, SequencingImage, Slide, SlideDeck, SlideDeckProps, SlideProps, Summary, SummaryProps, Text, TextProps, TimedCue, TimedCueProps, TrueFalse, TrueFalseProps, Video, VideoProps } from './blocks-entry.js';
8
+ export { K as KnowledgeCheck, Q as Quiz, b as QuizProps, r as resetAssessmentWarningsForTests, a as resetQuizWarningsForTests } from './AssessmentLessonGuard-BzNPbjaV.js';
9
9
  import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
10
10
  export { ThemePresetName } from '@lessonkit/themes';
11
11
 
@@ -22,10 +22,29 @@ type LessonkitObservabilityConfig = {
22
22
  onTelemetryBufferDrop?: () => void;
23
23
  /** LMS bridge missing for a completion-related telemetry event (`bridge: auto`). */
24
24
  onLxpackBridgeMiss?: (event: TelemetryEvent) => void;
25
+ /** LMS bridge host threw while forwarding telemetry (`bridge: auto`). */
26
+ onLxpackBridgeError?: (err: unknown) => void;
25
27
  /** xAPI transport failure after retries (statement re-queued). */
26
28
  onXapiTransportError?: (err: unknown) => void;
29
+ /** Telemetry → xAPI mapping failure (statement skipped). */
30
+ onXapiMappingError?: (err: unknown) => void;
31
+ /** Compound child resume incomplete after hydration retries. */
32
+ onCompoundHydrationPartial?: (ctx: {
33
+ compoundId: string;
34
+ missingCheckIds: string[];
35
+ }) => void;
36
+ /** Corrupt compound resume blob or invalid child states stripped on load. */
37
+ onCompoundResumeCorrupt?: (ctx: {
38
+ compoundId: string;
39
+ droppedChildKeys?: string[];
40
+ corrupt?: boolean;
41
+ }) => void;
27
42
  };
28
43
 
44
+ /**
45
+ * Runtime configuration for {@link LessonkitProvider} and {@link Course}.
46
+ * Pass tracking, xAPI, LMS bridge, observability hooks, and plugins here.
47
+ */
29
48
  type LessonkitConfig = {
30
49
  courseId: CourseId;
31
50
  session?: {
@@ -39,6 +58,12 @@ type LessonkitConfig = {
39
58
  enabled?: boolean;
40
59
  sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
41
60
  batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
61
+ /** Factory for a custom tracking client (alternative to sink/batchSink). */
62
+ createClient?: () => TrackingClient;
63
+ /** Explicit opt-in for console sinks in production builds. */
64
+ consoleSink?: boolean;
65
+ /** Re-emit assessment telemetry when restoring session state (default false). */
66
+ replayResumeEvents?: boolean;
42
67
  /** Keepalive batch delivery for pagehide (e.g. from createFetchBatchSink). */
43
68
  exitBatchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
44
69
  batch?: {
@@ -50,6 +75,8 @@ type LessonkitConfig = {
50
75
  xapi?: {
51
76
  enabled?: boolean;
52
77
  transport?: XAPITransport;
78
+ /** Explicit opt-in for console transport in production builds. */
79
+ consoleTransport?: boolean;
53
80
  /** Keepalive transport for pagehide (e.g. from createFetchTransport). */
54
81
  exitTransport?: _lessonkit_xapi.XAPIExitTransport;
55
82
  /** Abort in-flight transport by statement id (e.g. from createFetchTransport). */
@@ -59,6 +86,8 @@ type LessonkitConfig = {
59
86
  lxpack?: {
60
87
  /** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
61
88
  bridge?: LmsBridgeMode;
89
+ /** Parent-frame origins allowed to receive bridge calls when `bridge` is `auto`. */
90
+ allowedParentOrigins?: string[];
62
91
  };
63
92
  /** Framework plugins (analytics, LMS, assessment, interaction, AI). */
64
93
  plugins?: LessonkitPlugin[];
@@ -68,6 +97,22 @@ type LessonkitConfig = {
68
97
  sinks?: _lessonkit_core.TelemetryPipelineSink[];
69
98
  /** Production hooks for sink failures, xAPI queue depth, and LMS bridge misses. */
70
99
  observability?: LessonkitObservabilityConfig;
100
+ /** Optional storage port override (default: per-provider sessionStorage-backed port). */
101
+ storage?: StoragePort;
102
+ /** Embed block security defaults. */
103
+ embed?: {
104
+ /** Strip `allow-popups` from iframe sandbox in production builds (default true). */
105
+ restrictPopupsInProduction?: boolean;
106
+ /** Hostnames allowed to bypass the production private-network media/embed blocklist. */
107
+ allowedHosts?: string[];
108
+ };
109
+ /**
110
+ * Non-production preview options. `allowConsoleTelemetry` skips production guard
111
+ * checks for console sinks (docs demos only — not for shipped LMS courses).
112
+ */
113
+ preview?: {
114
+ allowConsoleTelemetry?: boolean;
115
+ };
71
116
  };
72
117
 
73
118
  type LessonkitProviderProps = {
@@ -95,6 +140,10 @@ type LessonkitRuntime = {
95
140
  }) => void;
96
141
  plugins: PluginHost | null;
97
142
  };
143
+ /**
144
+ * Root runtime provider for telemetry, xAPI, progress, and LMS bridge forwarding.
145
+ * Prefer wrapping with {@link Course} unless you need a custom layout.
146
+ */
98
147
  declare function LessonkitProvider(props: LessonkitProviderProps): React__default.JSX.Element;
99
148
 
100
149
  type CourseProps = {
@@ -126,7 +175,27 @@ type KnowledgeCheckProps = McqAssessmentProps;
126
175
  type ProgressTrackerProps = {
127
176
  totalLessons?: number;
128
177
  };
178
+ /**
179
+ * Top-level course shell. Wraps {@link LessonkitProvider} and renders a semantic section with title.
180
+ *
181
+ * @example
182
+ * ```tsx
183
+ * <Course title="Security 101" courseId="sec-101" config={courseConfig}>
184
+ * <Lesson title="Phishing" lessonId="phishing-101">…</Lesson>
185
+ * </Course>
186
+ * ```
187
+ */
129
188
  declare function Course(props: CourseProps): React__default.JSX.Element;
189
+ /**
190
+ * Lesson container. Sets the active lesson on mount and emits lesson lifecycle telemetry.
191
+ *
192
+ * @example
193
+ * ```tsx
194
+ * <Lesson title="Phishing" lessonId="phishing-101">
195
+ * <Scenario>…</Scenario>
196
+ * </Lesson>
197
+ * ```
198
+ */
130
199
  declare function Lesson(props: LessonProps): React__default.JSX.Element;
131
200
  declare function Scenario(props: ScenarioProps): React__default.JSX.Element;
132
201
  declare function Reflection(props: ReflectionProps): React__default.JSX.Element;
@@ -138,7 +207,9 @@ declare function useAssessmentState(enclosingLessonId?: LessonId): {
138
207
  };
139
208
 
140
209
  declare function useLessonkit(): LessonkitRuntime;
210
+ /** Read course progress state (completed lessons, active lesson). */
141
211
  declare function useProgress(): _lessonkit_core.ProgressState;
212
+ /** Emit typed telemetry events from custom UI (`track("interaction", …)`). */
142
213
  declare function useTracking(): {
143
214
  track: <N extends _lessonkit_core.TelemetryEventName>(name: N, data?: _lessonkit_core.TelemetryDataFor<N>, opts?: {
144
215
  lessonId?: LessonId;
@@ -171,7 +242,7 @@ declare function shouldEnforceProductionGuard(): boolean;
171
242
  * Throws in production when course config still uses dev-only console sinks or
172
243
  * omits observability hooks while telemetry/xAPI are enabled.
173
244
  */
174
- declare function assertProductionCourseConfig(config: Pick<LessonkitConfig, "tracking" | "xapi" | "observability" | "lxpack">): void;
245
+ declare function assertProductionCourseConfig(config: Pick<LessonkitConfig, "tracking" | "xapi" | "observability" | "lxpack" | "preview">): void;
175
246
 
176
247
  type ThemeMode = "light" | "dark" | "system";
177
248
  type ThemeResolvedMode = "light" | "dark";
@@ -193,6 +264,22 @@ type ThemeContextValue = {
193
264
  declare function ThemeProvider(props: ThemeProviderProps): React__default.JSX.Element;
194
265
  declare function useTheme(): ThemeContextValue;
195
266
 
267
+ type BranchingScenarioContextValue = {
268
+ compoundBlockId: string;
269
+ activeNodeId: string;
270
+ visitedNodeIds: readonly string[];
271
+ visitedLabels: readonly string[];
272
+ navigateToNode: (opts: {
273
+ fromNodeId: string;
274
+ toNodeId: string;
275
+ label: string;
276
+ scoreWeight?: number;
277
+ }) => void;
278
+ isTerminal: boolean;
279
+ choicesLocked: boolean;
280
+ };
281
+ declare function useBranchingScenario(): BranchingScenarioContextValue;
282
+
196
283
  declare const blockCatalogVersion: 1;
197
284
  declare const blockCatalogV2Version: 2;
198
285
  declare const blockCatalogV3Version: 3;
@@ -454,4 +541,4 @@ type BuildBlockCatalogOptions = {
454
541
  declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[] | BlockCatalogEntryV3[];
455
542
  declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | BlockCatalogEntryV3 | undefined;
456
543
 
457
- export { BLOCK_CATALOG, BLOCK_CATALOG_V2, BLOCK_CATALOG_V3, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockCatalogEntryV3, type BlockPropSpec, Course, type CourseProps, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, type LessonkitObservabilityConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, ProgressTracker, type ProgressTrackerProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, assertProductionCourseConfig, blockCatalogV2Version, blockCatalogV3Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, shouldEnforceProductionGuard, useAssessmentState, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
544
+ export { BLOCK_CATALOG, BLOCK_CATALOG_V2, BLOCK_CATALOG_V3, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockCatalogEntryV3, type BlockPropSpec, Course, type CourseProps, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, type LessonkitObservabilityConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, ProgressTracker, type ProgressTrackerProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, assertProductionCourseConfig, blockCatalogV2Version, blockCatalogV3Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, shouldEnforceProductionGuard, useAssessmentState, useBranchingScenario, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
package/dist/index.js CHANGED
@@ -2,9 +2,14 @@ import {
2
2
  Accordion,
3
3
  ArithmeticQuiz,
4
4
  AssessmentSequence,
5
+ BranchChoice,
6
+ BranchNode,
7
+ BranchingScenario,
8
+ Chart,
5
9
  DialogCards,
6
10
  DragAndDrop,
7
11
  DragTheWords,
12
+ Embed,
8
13
  Essay,
9
14
  FillInTheBlanks,
10
15
  FindHotspot,
@@ -30,15 +35,16 @@ import {
30
35
  Text,
31
36
  TimedCue,
32
37
  TrueFalse,
33
- Video
34
- } from "./chunk-4LQ4TTEE.js";
38
+ Video,
39
+ useBranchingScenario
40
+ } from "./chunk-5P23C2W3.js";
35
41
  import {
36
42
  KnowledgeCheck,
37
43
  Quiz,
38
44
  getLessonMountCount,
39
45
  registerLessonMount,
40
46
  resetQuizWarningsForTests
41
- } from "./chunk-UUTXECVW.js";
47
+ } from "./chunk-ELGQ4XI3.js";
42
48
  import {
43
49
  LessonContext,
44
50
  LessonkitProvider,
@@ -52,7 +58,7 @@ import {
52
58
  useProgress,
53
59
  useQuizState,
54
60
  useTracking
55
- } from "./chunk-TDM3ARE7.js";
61
+ } from "./chunk-7TJQJFYR.js";
56
62
 
57
63
  // src/components.tsx
58
64
  import { useEffect, useId, useMemo, useRef, useState } from "react";
@@ -313,6 +319,8 @@ function useTheme() {
313
319
  // src/catalogV3Entries.ts
314
320
  import {
315
321
  ASSESSMENT_SEQUENCE_ALLOWED_CHILD_TYPES,
322
+ BRANCHING_SCENARIO_ALLOWED_CHILD_TYPES,
323
+ BRANCH_NODE_ALLOWED_CHILD_TYPES,
316
324
  INTERACTIVE_BOOK_ALLOWED_CHILD_TYPES,
317
325
  INTERACTIVE_VIDEO_ALLOWED_CHILD_TYPES,
318
326
  PAGE_ALLOWED_CHILD_TYPES,
@@ -329,7 +337,9 @@ var COMPOUND_PARENTS = [
329
337
  "SlideDeck",
330
338
  "TimedCue",
331
339
  "InteractiveVideo",
332
- "AssessmentSequence"
340
+ "AssessmentSequence",
341
+ "BranchingScenario",
342
+ "BranchNode"
333
343
  ];
334
344
  function extendParents(entry) {
335
345
  if (!entry.parentConstraints?.length) return entry;
@@ -548,6 +558,110 @@ var v3CompoundAndContentEntries = [
548
558
  theming: { surface: "global-inherit", stylingNotes: "Video + overlay." },
549
559
  telemetry: { emits: ["video_cue_reached", "video_segment_completed"], requiresActiveLesson: true }
550
560
  },
561
+ {
562
+ type: "BranchNode",
563
+ category: "container",
564
+ compoundContract: true,
565
+ h5pMachineName: "H5P.BranchingScenario",
566
+ h5pAlias: "Branching Scenario node",
567
+ description: "Graph node in a BranchingScenario with content and choices.",
568
+ allowedChildTypes: [...BRANCH_NODE_ALLOWED_CHILD_TYPES],
569
+ maxNestingDepth: COMPOUND_MAX_NESTING_DEPTH.BranchNode,
570
+ props: [
571
+ { name: "nodeId", type: "string", required: true, description: "Unique node id within the scenario." },
572
+ { name: "title", type: "string", required: false, description: "Node title." },
573
+ { name: "terminal", type: "boolean", required: false, description: "End state node." },
574
+ { name: "children", type: "ReactNode", required: true, description: "Content and BranchChoice controls." }
575
+ ],
576
+ requiredIds: [],
577
+ parentConstraints: ["BranchingScenario"],
578
+ a11y: { element: "section", ariaLabel: "Branch node", keyboard: "Branch choices are buttons.", notes: "H5P Branching Scenario node." },
579
+ theming: { surface: "global-inherit", stylingNotes: "Node panel." },
580
+ telemetry: { emits: ["branch_node_viewed"], requiresActiveLesson: true }
581
+ },
582
+ {
583
+ type: "BranchChoice",
584
+ category: "content",
585
+ h5pMachineName: "H5P.BranchingScenario",
586
+ h5pAlias: "Branching Scenario choice",
587
+ description: "Transition control linking to a target BranchNode.",
588
+ props: [
589
+ { name: "label", type: "string", required: true, description: "Choice label." },
590
+ { name: "targetNodeId", type: "string", required: true, description: "Target node id." },
591
+ { name: "scoreWeight", type: "number", required: false, description: "Optional choice score weight." },
592
+ { name: "disabled", type: "boolean", required: false, description: "Disable choice." }
593
+ ],
594
+ requiredIds: [],
595
+ parentConstraints: ["BranchNode"],
596
+ a11y: { element: "button", ariaLabel: "Branch choice", keyboard: "Activate to follow branch.", notes: "Radio group pattern." },
597
+ theming: { surface: "global-inherit", stylingNotes: "Choice button." },
598
+ telemetry: { emits: ["branch_selected"], requiresActiveLesson: true }
599
+ },
600
+ {
601
+ type: "BranchingScenario",
602
+ category: "container",
603
+ compoundContract: true,
604
+ h5pMachineName: "H5P.BranchingScenario",
605
+ h5pAlias: "Branching Scenario",
606
+ description: "Graph-based branching narrative with scored paths.",
607
+ allowedChildTypes: [...BRANCHING_SCENARIO_ALLOWED_CHILD_TYPES],
608
+ maxNestingDepth: COMPOUND_MAX_NESTING_DEPTH.BranchingScenario,
609
+ props: [
610
+ { name: "blockId", type: "BlockId", required: true, description: "Stable block id." },
611
+ { name: "title", type: "string", required: true, description: "Scenario title." },
612
+ { name: "startNodeId", type: "string", required: true, description: "Entry node id." },
613
+ { name: "showPathScore", type: "boolean", required: false, description: "Show visited-path score." },
614
+ { name: "showPathRecap", type: "boolean", required: false, description: "Show path recap on terminal nodes." },
615
+ { name: "children", type: "BranchNode[]", required: true, description: "Branch nodes." }
616
+ ],
617
+ requiredIds: ["blockId"],
618
+ parentConstraints: ["Lesson"],
619
+ a11y: {
620
+ element: "section",
621
+ ariaLabel: "Branching scenario",
622
+ keyboard: "Branch choices; assessments in nodes.",
623
+ notes: "H5P Branching Scenario equivalent."
624
+ },
625
+ theming: { surface: "global-inherit", stylingNotes: "Scenario chrome." },
626
+ telemetry: { emits: ["branch_node_viewed", "branch_selected"], requiresActiveLesson: true }
627
+ },
628
+ {
629
+ type: "Embed",
630
+ category: "content",
631
+ h5pMachineName: "H5P.IFrameEmbed",
632
+ h5pAlias: "Iframe Embedder",
633
+ description: "Sandboxed iframe embed with restrictive defaults.",
634
+ props: [
635
+ { name: "blockId", type: "BlockId", required: true, description: "Stable block id." },
636
+ { name: "src", type: "string", required: true, description: "Embed URL." },
637
+ { name: "title", type: "string", required: true, description: "Accessible title." },
638
+ { name: "allow", type: "string", required: false, description: "Extra sandbox allow tokens." },
639
+ { name: "aspectRatio", type: "string", required: false, description: "CSS aspect-ratio." }
640
+ ],
641
+ requiredIds: ["blockId"],
642
+ parentConstraints: [...COMPOUND_PARENTS],
643
+ a11y: { element: "iframe", ariaLabel: "Embedded content", keyboard: "Focus enters iframe.", notes: "Sandboxed; opt-in allow list." },
644
+ theming: { surface: "global-inherit", stylingNotes: "Responsive iframe." },
645
+ telemetry: { emits: ["interaction"] }
646
+ },
647
+ {
648
+ type: "Chart",
649
+ category: "content",
650
+ h5pMachineName: "H5P.Chart",
651
+ h5pAlias: "Chart",
652
+ description: "Simple bar or pie chart with accessible data table.",
653
+ props: [
654
+ { name: "blockId", type: "BlockId", required: true, description: "Stable block id." },
655
+ { name: "type", type: "bar | pie", required: true, description: "Chart type." },
656
+ { name: "data", type: "ChartDatum[]", required: true, description: "Chart data." },
657
+ { name: "title", type: "string", required: false, description: "Chart title." }
658
+ ],
659
+ requiredIds: ["blockId"],
660
+ parentConstraints: [...COMPOUND_PARENTS],
661
+ a11y: { element: "figure", ariaLabel: "Chart", keyboard: "Data table fallback.", notes: "Table exposes values to screen readers." },
662
+ theming: { surface: "global-inherit", stylingNotes: "Simple SVG/CSS chart." },
663
+ telemetry: { emits: ["interaction"] }
664
+ },
551
665
  {
552
666
  type: "Questionnaire",
553
667
  category: "content",
@@ -1231,10 +1345,15 @@ export {
1231
1345
  BLOCK_CATALOG,
1232
1346
  BLOCK_CATALOG_V2,
1233
1347
  BLOCK_CATALOG_V3,
1348
+ BranchChoice,
1349
+ BranchNode,
1350
+ BranchingScenario,
1351
+ Chart,
1234
1352
  Course,
1235
1353
  DialogCards,
1236
1354
  DragAndDrop,
1237
1355
  DragTheWords,
1356
+ Embed,
1238
1357
  Essay,
1239
1358
  FillInTheBlanks,
1240
1359
  FindHotspot,
@@ -1286,6 +1405,7 @@ export {
1286
1405
  resetQuizWarningsForTests,
1287
1406
  shouldEnforceProductionGuard,
1288
1407
  useAssessmentState,
1408
+ useBranchingScenario,
1289
1409
  useCompletion,
1290
1410
  useLessonkit,
1291
1411
  useProgress,