@lessonkit/react 1.0.2 → 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, CheckId } from '@lessonkit/core';
5
- export { AssessmentScoreInput, AssessmentScoreResult, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, PluginHost, PluginRegistry, TelemetryPipelineSink, buildTelemetryEvent, createLessonkitRuntime, createPluginRegistry, createTelemetryPipeline, defineAssessmentPlugin, defineLifecyclePlugin, defineTelemetryPlugin } from '@lessonkit/core';
6
- import { AssessmentDescriptor } from '@lessonkit/lxpack';
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
+ 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,10 +115,9 @@ 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 = AssessmentDescriptor;
100
- type KnowledgeCheckProps = AssessmentDescriptor;
120
+ type KnowledgeCheckProps = McqAssessmentDescriptor;
101
121
  type ProgressTrackerProps = {
102
122
  totalLessons?: number;
103
123
  };
@@ -105,10 +125,245 @@ 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
 
130
+ type TrueFalseProps = AssessmentBaseProps & {
131
+ question: string;
132
+ answer: boolean;
133
+ };
134
+ declare const TrueFalse: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
135
+ checkId: _lessonkit_core.CheckId;
136
+ passingScore?: number;
137
+ } & {
138
+ question: string;
139
+ answer: boolean;
140
+ } & React$1.RefAttributes<AssessmentHandle>>;
141
+
142
+ type MarkTheWordsProps = AssessmentBaseProps & {
143
+ /** Plain text; words listed in `correctWords` are selectable targets. */
144
+ text: string;
145
+ correctWords: string[];
146
+ };
147
+ declare const MarkTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
148
+ checkId: _lessonkit_core.CheckId;
149
+ passingScore?: number;
150
+ } & {
151
+ /** Plain text; words listed in `correctWords` are selectable targets. */
152
+ text: string;
153
+ correctWords: string[];
154
+ } & React$1.RefAttributes<AssessmentHandle>>;
155
+
156
+ type FillInBlankSpec = {
157
+ id: string;
158
+ answer: string;
159
+ };
160
+ type FillInTheBlanksProps = AssessmentBaseProps & {
161
+ /** Text with `*` wrapping each blank answer, e.g. "The *capital* of France is *Paris*." */
162
+ template: string;
163
+ /** Optional explicit blanks (overrides parsing from template). */
164
+ blanks?: FillInBlankSpec[];
165
+ };
166
+ declare const FillInTheBlanks: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
167
+ checkId: _lessonkit_core.CheckId;
168
+ passingScore?: number;
169
+ } & {
170
+ /** Text with `*` wrapping each blank answer, e.g. "The *capital* of France is *Paris*." */
171
+ template: string;
172
+ /** Optional explicit blanks (overrides parsing from template). */
173
+ blanks?: FillInBlankSpec[];
174
+ } & React$1.RefAttributes<AssessmentHandle>>;
175
+
176
+ type DragTheWordsProps = AssessmentBaseProps & {
177
+ /** Sentence with `*` around drop zones; `words` are draggable options. */
178
+ template: string;
179
+ words: string[];
180
+ };
181
+ declare const DragTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
182
+ checkId: _lessonkit_core.CheckId;
183
+ passingScore?: number;
184
+ } & {
185
+ /** Sentence with `*` around drop zones; `words` are draggable options. */
186
+ template: string;
187
+ words: string[];
188
+ } & React$1.RefAttributes<AssessmentHandle>>;
189
+
190
+ type DragItem = {
191
+ id: string;
192
+ label: string;
193
+ };
194
+ type DropTarget = {
195
+ id: string;
196
+ label: string;
197
+ accepts: string;
198
+ };
199
+ type DragAndDropProps = AssessmentBaseProps & {
200
+ items: DragItem[];
201
+ targets: DropTarget[];
202
+ };
203
+ declare const DragAndDrop: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
204
+ checkId: _lessonkit_core.CheckId;
205
+ passingScore?: number;
206
+ } & {
207
+ items: DragItem[];
208
+ targets: DropTarget[];
209
+ } & React$1.RefAttributes<AssessmentHandle>>;
210
+
211
+ type AssessmentSequenceProps = AssessmentBehaviour & {
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;
219
+ /** Show one child assessment at a time (Question Set). */
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>[];
262
+ };
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>>;
361
+
362
+ declare function useAssessmentState(enclosingLessonId?: LessonId): {
363
+ answer: (data: AssessmentAnsweredData) => void;
364
+ complete: (data: AssessmentCompletedData) => void;
365
+ };
366
+
112
367
  declare function useLessonkit(): LessonkitRuntime;
113
368
  declare function useProgress(): _lessonkit_core.ProgressState;
114
369
  declare function useTracking(): {
@@ -122,6 +377,7 @@ declare function useCompletion(): {
122
377
  }) => void;
123
378
  completeCourse: () => void;
124
379
  };
380
+
125
381
  declare function useQuizState(enclosingLessonId?: LessonId): {
126
382
  answer: (opts: {
127
383
  checkId: CheckId;
@@ -137,10 +393,12 @@ declare function useQuizState(enclosingLessonId?: LessonId): {
137
393
  }) => void;
138
394
  };
139
395
 
396
+ declare function resetAssessmentWarningsForTests(): void;
397
+
140
398
  type ThemeMode = "light" | "dark" | "system";
141
399
  type ThemeResolvedMode = "light" | "dark";
142
400
  type ThemeProviderProps = {
143
- children: React.ReactNode;
401
+ children: React$1.ReactNode;
144
402
  /** Partial theme merged on top of the resolved preset (last writer wins). */
145
403
  theme?: PartialLessonkitThemeV1;
146
404
  preset?: ThemePresetName;
@@ -158,13 +416,15 @@ declare function ThemeProvider(props: ThemeProviderProps): react_jsx_runtime.JSX
158
416
  declare function useTheme(): ThemeContextValue;
159
417
 
160
418
  declare const blockCatalogVersion: 1;
419
+ declare const blockCatalogV2Version: 2;
420
+ declare const blockCatalogV3Version: 3;
161
421
  type BlockPropSpec = {
162
422
  name: string;
163
423
  type: string;
164
424
  required: boolean;
165
425
  description: string;
166
426
  };
167
- type BlockCatalogEntry = {
427
+ type BlockCatalogEntryBase = {
168
428
  type: string;
169
429
  aliases?: string[];
170
430
  category: "container" | "content" | "assessment" | "chrome";
@@ -191,6 +451,16 @@ type BlockCatalogEntry = {
191
451
  manualTracking?: string;
192
452
  };
193
453
  };
454
+ type BlockCatalogEntry = BlockCatalogEntryBase;
455
+ type BlockCatalogEntryV2 = BlockCatalogEntryBase & {
456
+ assessmentContract?: true;
457
+ compoundContract?: true;
458
+ h5pMachineName?: string;
459
+ h5pAlias?: string;
460
+ allowedChildTypes?: readonly string[];
461
+ maxNestingDepth?: number;
462
+ };
463
+ type BlockCatalogEntryV3 = BlockCatalogEntryV2;
194
464
  declare const BLOCK_CATALOG: ({
195
465
  type: string;
196
466
  category: "container";
@@ -398,7 +668,12 @@ declare const BLOCK_CATALOG: ({
398
668
  optionalIds?: undefined;
399
669
  aliases?: undefined;
400
670
  })[];
401
- declare function buildBlockCatalog(): BlockCatalogEntry[];
402
- declare function getBlockCatalogEntry(type: string): BlockCatalogEntry | undefined;
671
+ declare const BLOCK_CATALOG_V2: BlockCatalogEntryV2[];
672
+ declare const BLOCK_CATALOG_V3: BlockCatalogEntryV3[];
673
+ type BuildBlockCatalogOptions = {
674
+ version?: 1 | 2 | 3;
675
+ };
676
+ declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[] | BlockCatalogEntryV3[];
677
+ declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | BlockCatalogEntryV3 | undefined;
403
678
 
404
- export { BLOCK_CATALOG, type BlockCatalogEntry, type BlockPropSpec, Course, type CourseProps, KnowledgeCheck, type KnowledgeCheckProps, Lesson, type LessonProps, type LessonkitConfig, LessonkitProvider, type LessonkitProviderProps, type LessonkitRuntime, ProgressTracker, type ProgressTrackerProps, Quiz, type QuizProps, Reflection, type ReflectionProps, Scenario, type ScenarioProps, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, resetQuizWarningsForTests, 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 };