@lessonkit/react 1.1.0 → 1.2.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.ts CHANGED
@@ -1,20 +1,35 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React from 'react';
2
+ import React$1 from 'react';
3
3
  import * as _lessonkit_core from '@lessonkit/core';
4
- import { CourseId, TelemetryUser, TrackingClient, LessonkitPlugin, ProgressState, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, BlockId, AssessmentHandle, AssessmentBaseProps, AssessmentBehaviour, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
5
- export { AssessmentAnsweredData, AssessmentBaseProps, AssessmentBehaviour, AssessmentCompletedData, AssessmentHandle, AssessmentInteractionType, AssessmentScoreInput, AssessmentScoreResult, AssessmentXAPIData, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, PluginHost, PluginRegistry, TelemetryPipelineSink, buildTelemetryEvent, createLessonkitRuntime, createPluginRegistry, createTelemetryPipeline, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin } from '@lessonkit/core';
4
+ import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LessonkitPlugin, ProgressState, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, AssessmentHandle, BlockId, AssessmentBaseProps, AssessmentBehaviour, CompoundHandle, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
5
+ export { AssessmentAnsweredData, AssessmentBaseProps, AssessmentBehaviour, AssessmentCompletedData, AssessmentHandle, AssessmentInteractionType, AssessmentScoreInput, AssessmentScoreResult, AssessmentXAPIData, CompoundBaseProps, CompoundHandle, CompoundResumeState, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, PluginHost, PluginRegistry, TelemetryPipelineSink, buildTelemetryEvent, createLessonkitRuntime, createPluginRegistry, createTelemetryPipeline, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin } from '@lessonkit/core';
6
6
  import { McqAssessmentDescriptor } from '@lessonkit/lxpack';
7
7
  import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
8
8
  import { LxpackBridgeMode } from '@lessonkit/lxpack/bridge';
9
9
  import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
10
10
  export { ThemePresetName } from '@lessonkit/themes';
11
11
 
12
+ type LessonkitObservabilityConfig = {
13
+ /** Tracking or pipeline sink failure (sync or async). */
14
+ onTelemetrySinkError?: (err: unknown, ctx: {
15
+ sinkId?: string;
16
+ }) => void;
17
+ /** Current xAPI queue depth after enqueue or flush. */
18
+ onXapiQueueDepth?: (depth: number) => void;
19
+ /** Oldest xAPI statement dropped because the queue reached max size. */
20
+ onXapiQueueCap?: () => void;
21
+ /** LMS bridge missing for a completion-related telemetry event (`bridge: auto`). */
22
+ onLxpackBridgeMiss?: (event: TelemetryEvent) => void;
23
+ };
24
+
12
25
  type LessonkitConfig = {
13
26
  courseId: CourseId;
14
27
  session?: {
15
28
  sessionId?: string;
16
29
  attemptId?: string;
17
30
  user?: TelemetryUser;
31
+ /** Persist compound navigation and child state in session storage (default true). */
32
+ persistCompoundState?: boolean;
18
33
  };
19
34
  tracking?: {
20
35
  enabled?: boolean;
@@ -41,11 +56,13 @@ type LessonkitConfig = {
41
56
  runtimeVersion?: "v1" | "v2";
42
57
  /** Optional custom telemetry pipeline sinks (used alongside tracking/xapi). */
43
58
  sinks?: _lessonkit_core.TelemetryPipelineSink[];
59
+ /** Production hooks for sink failures, xAPI queue depth, and LMS bridge misses. */
60
+ observability?: LessonkitObservabilityConfig;
44
61
  };
45
62
 
46
63
  type LessonkitProviderProps = {
47
64
  config: LessonkitConfig;
48
- children: React.ReactNode;
65
+ children: React$1.ReactNode;
49
66
  };
50
67
  type LessonkitRuntime = {
51
68
  config: LessonkitConfig;
@@ -69,24 +86,28 @@ type LessonkitRuntime = {
69
86
  };
70
87
  declare function LessonkitProvider(props: LessonkitProviderProps): react_jsx_runtime.JSX.Element;
71
88
 
89
+ type QuizProps = McqAssessmentDescriptor;
90
+ declare const Quiz: React$1.ForwardRefExoticComponent<McqAssessmentDescriptor & React$1.RefAttributes<AssessmentHandle>>;
91
+ declare function KnowledgeCheck(props: QuizProps): react_jsx_runtime.JSX.Element;
72
92
  /** @internal Reset module warnings between tests. */
73
93
  declare function resetQuizWarningsForTests(): void;
94
+
74
95
  type CourseProps = {
75
96
  title: string;
76
97
  courseId: CourseId;
77
98
  config?: Omit<LessonkitConfig, "courseId">;
78
- children: React.ReactNode;
99
+ children: React$1.ReactNode;
79
100
  };
80
101
  type LessonProps = {
81
102
  title: string;
82
103
  lessonId: LessonId;
83
104
  /** When false, unmount does not emit lesson_completed (for routed multi-pane layouts). Default true. */
84
105
  autoCompleteOnUnmount?: boolean;
85
- children: React.ReactNode;
106
+ children: React$1.ReactNode;
86
107
  };
87
108
  type ScenarioProps = {
88
109
  blockId?: BlockId;
89
- children: React.ReactNode;
110
+ children: React$1.ReactNode;
90
111
  };
91
112
  type ReflectionProps = {
92
113
  blockId?: BlockId;
@@ -94,9 +115,8 @@ type ReflectionProps = {
94
115
  hint?: string;
95
116
  value?: string;
96
117
  onChange?: (value: string) => void;
97
- children?: React.ReactNode;
118
+ children?: React$1.ReactNode;
98
119
  };
99
- type QuizProps = McqAssessmentDescriptor;
100
120
  type KnowledgeCheckProps = McqAssessmentDescriptor;
101
121
  type ProgressTrackerProps = {
102
122
  totalLessons?: number;
@@ -105,35 +125,33 @@ declare function Course(props: CourseProps): react_jsx_runtime.JSX.Element;
105
125
  declare function Lesson(props: LessonProps): react_jsx_runtime.JSX.Element;
106
126
  declare function Scenario(props: ScenarioProps): react_jsx_runtime.JSX.Element;
107
127
  declare function Reflection(props: ReflectionProps): react_jsx_runtime.JSX.Element;
108
- declare function KnowledgeCheck(props: KnowledgeCheckProps): react_jsx_runtime.JSX.Element;
109
- declare function Quiz(props: QuizProps): react_jsx_runtime.JSX.Element;
110
128
  declare function ProgressTracker(props: ProgressTrackerProps): react_jsx_runtime.JSX.Element;
111
129
 
112
130
  type TrueFalseProps = AssessmentBaseProps & {
113
131
  question: string;
114
132
  answer: boolean;
115
133
  };
116
- declare const TrueFalse: React.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
134
+ declare const TrueFalse: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
117
135
  checkId: _lessonkit_core.CheckId;
118
136
  passingScore?: number;
119
137
  } & {
120
138
  question: string;
121
139
  answer: boolean;
122
- } & React.RefAttributes<AssessmentHandle>>;
140
+ } & React$1.RefAttributes<AssessmentHandle>>;
123
141
 
124
142
  type MarkTheWordsProps = AssessmentBaseProps & {
125
143
  /** Plain text; words listed in `correctWords` are selectable targets. */
126
144
  text: string;
127
145
  correctWords: string[];
128
146
  };
129
- declare const MarkTheWords: React.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
147
+ declare const MarkTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
130
148
  checkId: _lessonkit_core.CheckId;
131
149
  passingScore?: number;
132
150
  } & {
133
151
  /** Plain text; words listed in `correctWords` are selectable targets. */
134
152
  text: string;
135
153
  correctWords: string[];
136
- } & React.RefAttributes<AssessmentHandle>>;
154
+ } & React$1.RefAttributes<AssessmentHandle>>;
137
155
 
138
156
  type FillInBlankSpec = {
139
157
  id: string;
@@ -145,7 +163,7 @@ type FillInTheBlanksProps = AssessmentBaseProps & {
145
163
  /** Optional explicit blanks (overrides parsing from template). */
146
164
  blanks?: FillInBlankSpec[];
147
165
  };
148
- declare const FillInTheBlanks: React.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
166
+ declare const FillInTheBlanks: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
149
167
  checkId: _lessonkit_core.CheckId;
150
168
  passingScore?: number;
151
169
  } & {
@@ -153,21 +171,21 @@ declare const FillInTheBlanks: React.ForwardRefExoticComponent<_lessonkit_core.A
153
171
  template: string;
154
172
  /** Optional explicit blanks (overrides parsing from template). */
155
173
  blanks?: FillInBlankSpec[];
156
- } & React.RefAttributes<AssessmentHandle>>;
174
+ } & React$1.RefAttributes<AssessmentHandle>>;
157
175
 
158
176
  type DragTheWordsProps = AssessmentBaseProps & {
159
177
  /** Sentence with `*` around drop zones; `words` are draggable options. */
160
178
  template: string;
161
179
  words: string[];
162
180
  };
163
- declare const DragTheWords: React.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
181
+ declare const DragTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
164
182
  checkId: _lessonkit_core.CheckId;
165
183
  passingScore?: number;
166
184
  } & {
167
185
  /** Sentence with `*` around drop zones; `words` are draggable options. */
168
186
  template: string;
169
187
  words: string[];
170
- } & React.RefAttributes<AssessmentHandle>>;
188
+ } & React$1.RefAttributes<AssessmentHandle>>;
171
189
 
172
190
  type DragItem = {
173
191
  id: string;
@@ -182,20 +200,164 @@ type DragAndDropProps = AssessmentBaseProps & {
182
200
  items: DragItem[];
183
201
  targets: DropTarget[];
184
202
  };
185
- declare const DragAndDrop: React.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
203
+ declare const DragAndDrop: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
186
204
  checkId: _lessonkit_core.CheckId;
187
205
  passingScore?: number;
188
206
  } & {
189
207
  items: DragItem[];
190
208
  targets: DropTarget[];
191
- } & React.RefAttributes<AssessmentHandle>>;
209
+ } & React$1.RefAttributes<AssessmentHandle>>;
192
210
 
193
211
  type AssessmentSequenceProps = AssessmentBehaviour & {
194
- children: React.ReactNode;
212
+ children: React$1.ReactNode;
213
+ /** Show one child assessment at a time (Question Set). */
214
+ sequential?: boolean;
215
+ blockId?: BlockId;
216
+ };
217
+ declare const AssessmentSequence: React$1.ForwardRefExoticComponent<AssessmentBehaviour & {
218
+ children: React$1.ReactNode;
195
219
  /** Show one child assessment at a time (Question Set). */
196
220
  sequential?: boolean;
221
+ blockId?: BlockId;
222
+ } & React$1.RefAttributes<CompoundHandle>>;
223
+
224
+ type TextProps = {
225
+ blockId?: BlockId;
226
+ children: React$1.ReactNode;
227
+ };
228
+ declare function Text(props: TextProps): react_jsx_runtime.JSX.Element;
229
+
230
+ type HeadingProps = {
231
+ blockId?: BlockId;
232
+ level: 1 | 2 | 3;
233
+ children: React.ReactNode;
234
+ };
235
+ declare function Heading(props: HeadingProps): react_jsx_runtime.JSX.Element;
236
+
237
+ type ImageProps = {
238
+ blockId?: BlockId;
239
+ src: string;
240
+ alt: string;
241
+ };
242
+ declare function Image(props: ImageProps): react_jsx_runtime.JSX.Element;
243
+
244
+ type PageProps = {
245
+ blockId: BlockId;
246
+ title?: string;
247
+ /** When true, page is used as a book chapter but hidden until navigated (InteractiveBook). */
248
+ hidden?: boolean;
249
+ /** Index within a compound parent (set by InteractiveBook). */
250
+ pageIndex?: number;
251
+ /** Compound parent type for telemetry (e.g. InteractiveBook). */
252
+ parentType?: string;
253
+ children: React$1.ReactNode;
254
+ };
255
+ declare function Page(props: PageProps): react_jsx_runtime.JSX.Element;
256
+
257
+ type InteractiveBookProps = {
258
+ blockId: BlockId;
259
+ title: string;
260
+ showBookScore?: boolean;
261
+ children: React$1.ReactElement<PageProps> | React$1.ReactElement<PageProps>[];
197
262
  };
198
- declare function AssessmentSequence(props: AssessmentSequenceProps): react_jsx_runtime.JSX.Element;
263
+ declare const InteractiveBook: React$1.ForwardRefExoticComponent<InteractiveBookProps & React$1.RefAttributes<CompoundHandle>>;
264
+
265
+ type AccordionSection = {
266
+ id: string;
267
+ title: string;
268
+ content: React$1.ReactNode;
269
+ };
270
+ type AccordionProps = {
271
+ blockId: BlockId;
272
+ sections: AccordionSection[];
273
+ };
274
+ declare function Accordion(props: AccordionProps): react_jsx_runtime.JSX.Element;
275
+
276
+ type DialogCard = {
277
+ front: string;
278
+ back: string;
279
+ };
280
+ type DialogCardsProps = {
281
+ blockId: BlockId;
282
+ cards: DialogCard[];
283
+ };
284
+ declare function DialogCards(props: DialogCardsProps): react_jsx_runtime.JSX.Element | null;
285
+
286
+ type Flashcard = {
287
+ front: string;
288
+ back: string;
289
+ };
290
+ type FlashcardsProps = {
291
+ blockId: BlockId;
292
+ cards: Flashcard[];
293
+ /** Optional self-score mode (not LMS-scored). */
294
+ selfScore?: boolean;
295
+ };
296
+ declare function Flashcards(props: FlashcardsProps): react_jsx_runtime.JSX.Element | null;
297
+
298
+ type HotspotSpec = {
299
+ id: string;
300
+ label: string;
301
+ x: number;
302
+ y: number;
303
+ content: React$1.ReactNode;
304
+ };
305
+ type ImageHotspotsProps = {
306
+ blockId: BlockId;
307
+ src: string;
308
+ alt: string;
309
+ hotspots: HotspotSpec[];
310
+ };
311
+ declare function ImageHotspots(props: ImageHotspotsProps): react_jsx_runtime.JSX.Element;
312
+
313
+ type ImageSlide = {
314
+ src: string;
315
+ alt: string;
316
+ caption?: string;
317
+ };
318
+ type ImageSliderProps = {
319
+ blockId: BlockId;
320
+ slides: ImageSlide[];
321
+ };
322
+ declare function ImageSlider(props: ImageSliderProps): react_jsx_runtime.JSX.Element | null;
323
+
324
+ type HotspotTarget = {
325
+ id: string;
326
+ label: string;
327
+ x: number;
328
+ y: number;
329
+ };
330
+ type FindHotspotProps = AssessmentBaseProps & {
331
+ src: string;
332
+ alt: string;
333
+ targets: HotspotTarget[];
334
+ correctTargetId: string;
335
+ };
336
+ declare const FindHotspot: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
337
+ checkId: _lessonkit_core.CheckId;
338
+ passingScore?: number;
339
+ } & {
340
+ src: string;
341
+ alt: string;
342
+ targets: HotspotTarget[];
343
+ correctTargetId: string;
344
+ } & React$1.RefAttributes<AssessmentHandle>>;
345
+
346
+ type FindMultipleHotspotsProps = AssessmentBaseProps & {
347
+ src: string;
348
+ alt: string;
349
+ targets: HotspotTarget[];
350
+ correctTargetIds: string[];
351
+ };
352
+ declare const FindMultipleHotspots: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
353
+ checkId: _lessonkit_core.CheckId;
354
+ passingScore?: number;
355
+ } & {
356
+ src: string;
357
+ alt: string;
358
+ targets: HotspotTarget[];
359
+ correctTargetIds: string[];
360
+ } & React$1.RefAttributes<AssessmentHandle>>;
199
361
 
200
362
  declare function useAssessmentState(enclosingLessonId?: LessonId): {
201
363
  answer: (data: AssessmentAnsweredData) => void;
@@ -236,7 +398,7 @@ declare function resetAssessmentWarningsForTests(): void;
236
398
  type ThemeMode = "light" | "dark" | "system";
237
399
  type ThemeResolvedMode = "light" | "dark";
238
400
  type ThemeProviderProps = {
239
- children: React.ReactNode;
401
+ children: React$1.ReactNode;
240
402
  /** Partial theme merged on top of the resolved preset (last writer wins). */
241
403
  theme?: PartialLessonkitThemeV1;
242
404
  preset?: ThemePresetName;
@@ -255,6 +417,7 @@ declare function useTheme(): ThemeContextValue;
255
417
 
256
418
  declare const blockCatalogVersion: 1;
257
419
  declare const blockCatalogV2Version: 2;
420
+ declare const blockCatalogV3Version: 3;
258
421
  type BlockPropSpec = {
259
422
  name: string;
260
423
  type: string;
@@ -291,9 +454,13 @@ type BlockCatalogEntryBase = {
291
454
  type BlockCatalogEntry = BlockCatalogEntryBase;
292
455
  type BlockCatalogEntryV2 = BlockCatalogEntryBase & {
293
456
  assessmentContract?: true;
457
+ compoundContract?: true;
294
458
  h5pMachineName?: string;
295
459
  h5pAlias?: string;
460
+ allowedChildTypes?: readonly string[];
461
+ maxNestingDepth?: number;
296
462
  };
463
+ type BlockCatalogEntryV3 = BlockCatalogEntryV2;
297
464
  declare const BLOCK_CATALOG: ({
298
465
  type: string;
299
466
  category: "container";
@@ -502,10 +669,11 @@ declare const BLOCK_CATALOG: ({
502
669
  aliases?: undefined;
503
670
  })[];
504
671
  declare const BLOCK_CATALOG_V2: BlockCatalogEntryV2[];
672
+ declare const BLOCK_CATALOG_V3: BlockCatalogEntryV3[];
505
673
  type BuildBlockCatalogOptions = {
506
- version?: 1 | 2;
674
+ version?: 1 | 2 | 3;
507
675
  };
508
- declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[];
509
- declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | undefined;
676
+ declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[] | BlockCatalogEntryV3[];
677
+ declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | BlockCatalogEntryV3 | undefined;
510
678
 
511
- export { AssessmentSequence, type AssessmentSequenceProps, BLOCK_CATALOG, BLOCK_CATALOG_V2, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockPropSpec, Course, type CourseProps, DragAndDrop, type DragAndDropProps, type DragItem, DragTheWords, type DragTheWordsProps, type DropTarget, type FillInBlankSpec, FillInTheBlanks, type FillInTheBlanksProps, KnowledgeCheck, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, MarkTheWords, type MarkTheWordsProps, ProgressTracker, type ProgressTrackerProps, Quiz, type QuizProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, TrueFalse, type TrueFalseProps, blockCatalogV2Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, resetAssessmentWarningsForTests, resetQuizWarningsForTests, useAssessmentState, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
679
+ export { Accordion, type AccordionProps, type AccordionSection, AssessmentSequence, type AssessmentSequenceProps, BLOCK_CATALOG, BLOCK_CATALOG_V2, BLOCK_CATALOG_V3, type BlockCatalogEntry, type BlockCatalogEntryV2, type BlockCatalogEntryV3, type BlockPropSpec, Course, type CourseProps, type DialogCard, DialogCards, type DialogCardsProps, DragAndDrop, type DragAndDropProps, type DragItem, DragTheWords, type DragTheWordsProps, type DropTarget, type FillInBlankSpec, FillInTheBlanks, type FillInTheBlanksProps, FindHotspot, type FindHotspotProps, FindMultipleHotspots, type FindMultipleHotspotsProps, type Flashcard, Flashcards, type FlashcardsProps, Heading, type HeadingProps, type HotspotSpec, type HotspotTarget, Image, ImageHotspots, type ImageHotspotsProps, type ImageProps, type ImageSlide, ImageSlider, type ImageSliderProps, InteractiveBook, type InteractiveBookProps, KnowledgeCheck, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, type LessonkitObservabilityConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, MarkTheWords, type MarkTheWordsProps, Page, type PageProps, ProgressTracker, type ProgressTrackerProps, Quiz, type QuizProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, Text, type TextProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, TrueFalse, type TrueFalseProps, blockCatalogV2Version, blockCatalogV3Version, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, resetAssessmentWarningsForTests, resetQuizWarningsForTests, useAssessmentState, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };