@lessonkit/react 1.3.1 → 1.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.cts CHANGED
@@ -1,12 +1,11 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import React$1 from 'react';
1
+ import React__default from 'react';
3
2
  import * as _lessonkit_core from '@lessonkit/core';
4
- import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LessonkitPlugin, ProgressState, StoragePort, 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';
3
+ import { TelemetryEvent, CourseId, TelemetryUser, TrackingClient, LmsBridgeMode, LessonkitPlugin, ProgressState, StoragePort, LessonId, TelemetryEventName, TelemetryDataFor, PluginHost, McqAssessmentProps, BlockId, AssessmentAnsweredData, AssessmentCompletedData, CheckId } from '@lessonkit/core';
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';
7
5
  import * as _lessonkit_xapi from '@lessonkit/xapi';
8
6
  import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
9
- import { LxpackBridgeMode } from '@lessonkit/lxpack/bridge';
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';
10
9
  import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
11
10
  export { ThemePresetName } from '@lessonkit/themes';
12
11
 
@@ -23,6 +22,8 @@ type LessonkitObservabilityConfig = {
23
22
  onTelemetryBufferDrop?: () => void;
24
23
  /** LMS bridge missing for a completion-related telemetry event (`bridge: auto`). */
25
24
  onLxpackBridgeMiss?: (event: TelemetryEvent) => void;
25
+ /** xAPI transport failure after retries (statement re-queued). */
26
+ onXapiTransportError?: (err: unknown) => void;
26
27
  };
27
28
 
28
29
  type LessonkitConfig = {
@@ -51,11 +52,13 @@ type LessonkitConfig = {
51
52
  transport?: XAPITransport;
52
53
  /** Keepalive transport for pagehide (e.g. from createFetchTransport). */
53
54
  exitTransport?: _lessonkit_xapi.XAPIExitTransport;
55
+ /** Abort in-flight transport by statement id (e.g. from createFetchTransport). */
56
+ abortInFlight?: (statementId: string) => void;
54
57
  client?: XAPIClient;
55
58
  };
56
59
  lxpack?: {
57
60
  /** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
58
- bridge?: LxpackBridgeMode;
61
+ bridge?: LmsBridgeMode;
59
62
  };
60
63
  /** Framework plugins (analytics, LMS, assessment, interaction, AI). */
61
64
  plugins?: LessonkitPlugin[];
@@ -69,7 +72,7 @@ type LessonkitConfig = {
69
72
 
70
73
  type LessonkitProviderProps = {
71
74
  config: LessonkitConfig;
72
- children: React$1.ReactNode;
75
+ children: React__default.ReactNode;
73
76
  };
74
77
  type LessonkitRuntime = {
75
78
  config: LessonkitConfig;
@@ -92,30 +95,24 @@ type LessonkitRuntime = {
92
95
  }) => void;
93
96
  plugins: PluginHost | null;
94
97
  };
95
- declare function LessonkitProvider(props: LessonkitProviderProps): react_jsx_runtime.JSX.Element;
96
-
97
- type QuizProps = McqAssessmentDescriptor;
98
- declare const Quiz: React$1.ForwardRefExoticComponent<McqAssessmentDescriptor & React$1.RefAttributes<AssessmentHandle>>;
99
- declare function KnowledgeCheck(props: QuizProps): react_jsx_runtime.JSX.Element;
100
- /** @internal Reset module warnings between tests. */
101
- declare function resetQuizWarningsForTests(): void;
98
+ declare function LessonkitProvider(props: LessonkitProviderProps): React__default.JSX.Element;
102
99
 
103
100
  type CourseProps = {
104
101
  title: string;
105
102
  courseId: CourseId;
106
103
  config?: Omit<LessonkitConfig, "courseId">;
107
- children: React$1.ReactNode;
104
+ children: React__default.ReactNode;
108
105
  };
109
106
  type LessonProps = {
110
107
  title: string;
111
108
  lessonId: LessonId;
112
109
  /** When false, unmount does not emit lesson_completed (for routed multi-pane layouts). Default true. */
113
110
  autoCompleteOnUnmount?: boolean;
114
- children: React$1.ReactNode;
111
+ children: React__default.ReactNode;
115
112
  };
116
113
  type ScenarioProps = {
117
114
  blockId?: BlockId;
118
- children: React$1.ReactNode;
115
+ children: React__default.ReactNode;
119
116
  };
120
117
  type ReflectionProps = {
121
118
  blockId?: BlockId;
@@ -123,270 +120,17 @@ type ReflectionProps = {
123
120
  hint?: string;
124
121
  value?: string;
125
122
  onChange?: (value: string) => void;
126
- children?: React$1.ReactNode;
123
+ children?: React__default.ReactNode;
127
124
  };
128
- type KnowledgeCheckProps = McqAssessmentDescriptor;
125
+ type KnowledgeCheckProps = McqAssessmentProps;
129
126
  type ProgressTrackerProps = {
130
127
  totalLessons?: number;
131
128
  };
132
- declare function Course(props: CourseProps): react_jsx_runtime.JSX.Element;
133
- declare function Lesson(props: LessonProps): react_jsx_runtime.JSX.Element;
134
- declare function Scenario(props: ScenarioProps): react_jsx_runtime.JSX.Element;
135
- declare function Reflection(props: ReflectionProps): react_jsx_runtime.JSX.Element;
136
- declare function ProgressTracker(props: ProgressTrackerProps): react_jsx_runtime.JSX.Element;
137
-
138
- type TrueFalseProps = AssessmentBaseProps & {
139
- question: string;
140
- answer: boolean;
141
- };
142
- declare const TrueFalse: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
143
- checkId: _lessonkit_core.CheckId;
144
- passingScore?: number;
145
- } & {
146
- question: string;
147
- answer: boolean;
148
- } & React$1.RefAttributes<AssessmentHandle>>;
149
-
150
- type MarkTheWordsProps = AssessmentBaseProps & {
151
- /** Plain text; words listed in `correctWords` are selectable targets. */
152
- text: string;
153
- correctWords: string[];
154
- };
155
- declare const MarkTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
156
- checkId: _lessonkit_core.CheckId;
157
- passingScore?: number;
158
- } & {
159
- /** Plain text; words listed in `correctWords` are selectable targets. */
160
- text: string;
161
- correctWords: string[];
162
- } & React$1.RefAttributes<AssessmentHandle>>;
163
-
164
- type FillInBlankSpec = {
165
- id: string;
166
- answer: string;
167
- };
168
- type FillInTheBlanksProps = AssessmentBaseProps & {
169
- /** Text with `*` wrapping each blank answer, e.g. "The *capital* of France is *Paris*." */
170
- template: string;
171
- /** Optional explicit blanks (overrides parsing from template). */
172
- blanks?: FillInBlankSpec[];
173
- };
174
- declare const FillInTheBlanks: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
175
- checkId: _lessonkit_core.CheckId;
176
- passingScore?: number;
177
- } & {
178
- /** Text with `*` wrapping each blank answer, e.g. "The *capital* of France is *Paris*." */
179
- template: string;
180
- /** Optional explicit blanks (overrides parsing from template). */
181
- blanks?: FillInBlankSpec[];
182
- } & React$1.RefAttributes<AssessmentHandle>>;
183
-
184
- type DragTheWordsProps = AssessmentBaseProps & {
185
- /** Sentence with `*` around drop zones; `words` are draggable options. */
186
- template: string;
187
- words: string[];
188
- };
189
- declare const DragTheWords: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
190
- checkId: _lessonkit_core.CheckId;
191
- passingScore?: number;
192
- } & {
193
- /** Sentence with `*` around drop zones; `words` are draggable options. */
194
- template: string;
195
- words: string[];
196
- } & React$1.RefAttributes<AssessmentHandle>>;
197
-
198
- type DragItem = {
199
- id: string;
200
- label: string;
201
- };
202
- type DropTarget = {
203
- id: string;
204
- label: string;
205
- accepts: string;
206
- };
207
- type DragAndDropProps = AssessmentBaseProps & {
208
- items: DragItem[];
209
- targets: DropTarget[];
210
- };
211
- declare const DragAndDrop: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
212
- checkId: _lessonkit_core.CheckId;
213
- passingScore?: number;
214
- } & {
215
- items: DragItem[];
216
- targets: DropTarget[];
217
- } & React$1.RefAttributes<AssessmentHandle>>;
218
-
219
- type AssessmentSequenceProps = AssessmentBehaviour & {
220
- children: React$1.ReactNode;
221
- /** Show one child assessment at a time (Question Set). */
222
- sequential?: boolean;
223
- blockId?: BlockId;
224
- };
225
- declare const AssessmentSequence: React$1.ForwardRefExoticComponent<AssessmentBehaviour & {
226
- children: React$1.ReactNode;
227
- /** Show one child assessment at a time (Question Set). */
228
- sequential?: boolean;
229
- blockId?: BlockId;
230
- } & React$1.RefAttributes<CompoundHandle>>;
231
-
232
- type TextProps = {
233
- blockId?: BlockId;
234
- children: React$1.ReactNode;
235
- };
236
- declare function Text(props: TextProps): react_jsx_runtime.JSX.Element;
237
-
238
- type HeadingProps = {
239
- blockId?: BlockId;
240
- level: 1 | 2 | 3;
241
- children: React.ReactNode;
242
- };
243
- declare function Heading(props: HeadingProps): react_jsx_runtime.JSX.Element;
244
-
245
- type ImageProps = {
246
- blockId?: BlockId;
247
- src: string;
248
- alt: string;
249
- };
250
- declare function Image(props: ImageProps): react_jsx_runtime.JSX.Element;
251
-
252
- type PageProps = {
253
- blockId: BlockId;
254
- title?: string;
255
- /** When true, page is used as a book chapter but hidden until navigated (InteractiveBook). */
256
- hidden?: boolean;
257
- /** Index within a compound parent (set by InteractiveBook). */
258
- pageIndex?: number;
259
- /** Compound parent type for telemetry (e.g. InteractiveBook). */
260
- parentType?: string;
261
- children: React$1.ReactNode;
262
- };
263
- declare function Page(props: PageProps): react_jsx_runtime.JSX.Element;
264
-
265
- type InteractiveBookProps = {
266
- blockId: BlockId;
267
- title: string;
268
- showBookScore?: boolean;
269
- children: React$1.ReactElement<PageProps> | React$1.ReactElement<PageProps>[];
270
- };
271
- declare const InteractiveBook: React$1.ForwardRefExoticComponent<InteractiveBookProps & React$1.RefAttributes<CompoundHandle>>;
272
-
273
- type SlideProps = {
274
- blockId: BlockId;
275
- title?: string;
276
- /** When true, slide is used in a deck but hidden until navigated (SlideDeck). */
277
- hidden?: boolean;
278
- /** Index within a compound parent (set by SlideDeck). */
279
- slideIndex?: number;
280
- /** Compound parent type for telemetry (e.g. SlideDeck). */
281
- parentType?: string;
282
- children: React$1.ReactNode;
283
- };
284
- declare function Slide(props: SlideProps): react_jsx_runtime.JSX.Element;
285
-
286
- type SlideDeckProps = {
287
- blockId: BlockId;
288
- title: string;
289
- showDeckScore?: boolean;
290
- children: React$1.ReactElement<SlideProps> | React$1.ReactElement<SlideProps>[];
291
- };
292
- declare const SlideDeck: React$1.ForwardRefExoticComponent<SlideDeckProps & React$1.RefAttributes<CompoundHandle>>;
293
-
294
- type AccordionSection = {
295
- id: string;
296
- title: string;
297
- content: React$1.ReactNode;
298
- };
299
- type AccordionProps = {
300
- blockId: BlockId;
301
- sections: AccordionSection[];
302
- };
303
- declare function Accordion(props: AccordionProps): react_jsx_runtime.JSX.Element;
304
-
305
- type DialogCard = {
306
- front: string;
307
- back: string;
308
- };
309
- type DialogCardsProps = {
310
- blockId: BlockId;
311
- cards: DialogCard[];
312
- };
313
- declare function DialogCards(props: DialogCardsProps): react_jsx_runtime.JSX.Element | null;
314
-
315
- type Flashcard = {
316
- front: string;
317
- back: string;
318
- };
319
- type FlashcardsProps = {
320
- blockId: BlockId;
321
- cards: Flashcard[];
322
- /** Optional self-score mode (not LMS-scored). */
323
- selfScore?: boolean;
324
- };
325
- declare function Flashcards(props: FlashcardsProps): react_jsx_runtime.JSX.Element | null;
326
-
327
- type HotspotSpec = {
328
- id: string;
329
- label: string;
330
- x: number;
331
- y: number;
332
- content: React$1.ReactNode;
333
- };
334
- type ImageHotspotsProps = {
335
- blockId: BlockId;
336
- src: string;
337
- alt: string;
338
- hotspots: HotspotSpec[];
339
- };
340
- declare function ImageHotspots(props: ImageHotspotsProps): react_jsx_runtime.JSX.Element;
341
-
342
- type ImageSlide = {
343
- src: string;
344
- alt: string;
345
- caption?: string;
346
- };
347
- type ImageSliderProps = {
348
- blockId: BlockId;
349
- slides: ImageSlide[];
350
- };
351
- declare function ImageSlider(props: ImageSliderProps): react_jsx_runtime.JSX.Element | null;
352
-
353
- type HotspotTarget = {
354
- id: string;
355
- label: string;
356
- x: number;
357
- y: number;
358
- };
359
- type FindHotspotProps = AssessmentBaseProps & {
360
- src: string;
361
- alt: string;
362
- targets: HotspotTarget[];
363
- correctTargetId: string;
364
- };
365
- declare const FindHotspot: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
366
- checkId: _lessonkit_core.CheckId;
367
- passingScore?: number;
368
- } & {
369
- src: string;
370
- alt: string;
371
- targets: HotspotTarget[];
372
- correctTargetId: string;
373
- } & React$1.RefAttributes<AssessmentHandle>>;
374
-
375
- type FindMultipleHotspotsProps = AssessmentBaseProps & {
376
- src: string;
377
- alt: string;
378
- targets: HotspotTarget[];
379
- correctTargetIds: string[];
380
- };
381
- declare const FindMultipleHotspots: React$1.ForwardRefExoticComponent<_lessonkit_core.AssessmentBehaviour & {
382
- checkId: _lessonkit_core.CheckId;
383
- passingScore?: number;
384
- } & {
385
- src: string;
386
- alt: string;
387
- targets: HotspotTarget[];
388
- correctTargetIds: string[];
389
- } & React$1.RefAttributes<AssessmentHandle>>;
129
+ declare function Course(props: CourseProps): React__default.JSX.Element;
130
+ declare function Lesson(props: LessonProps): React__default.JSX.Element;
131
+ declare function Scenario(props: ScenarioProps): React__default.JSX.Element;
132
+ declare function Reflection(props: ReflectionProps): React__default.JSX.Element;
133
+ declare function ProgressTracker(props: ProgressTrackerProps): React__default.JSX.Element;
390
134
 
391
135
  declare function useAssessmentState(enclosingLessonId?: LessonId): {
392
136
  answer: (data: AssessmentAnsweredData) => void;
@@ -422,12 +166,17 @@ declare function useQuizState(enclosingLessonId?: LessonId): {
422
166
  }) => void;
423
167
  };
424
168
 
425
- declare function resetAssessmentWarningsForTests(): void;
169
+ declare function shouldEnforceProductionGuard(): boolean;
170
+ /**
171
+ * Throws in production when course config still uses dev-only console sinks or
172
+ * omits observability hooks while telemetry/xAPI are enabled.
173
+ */
174
+ declare function assertProductionCourseConfig(config: Pick<LessonkitConfig, "tracking" | "xapi" | "observability" | "lxpack">): void;
426
175
 
427
176
  type ThemeMode = "light" | "dark" | "system";
428
177
  type ThemeResolvedMode = "light" | "dark";
429
178
  type ThemeProviderProps = {
430
- children: React$1.ReactNode;
179
+ children: React__default.ReactNode;
431
180
  /** Partial theme merged on top of the resolved preset (last writer wins). */
432
181
  theme?: PartialLessonkitThemeV1;
433
182
  preset?: ThemePresetName;
@@ -441,7 +190,7 @@ type ThemeContextValue = {
441
190
  mode: ThemeMode;
442
191
  resolvedMode: ThemeResolvedMode;
443
192
  };
444
- declare function ThemeProvider(props: ThemeProviderProps): react_jsx_runtime.JSX.Element;
193
+ declare function ThemeProvider(props: ThemeProviderProps): React__default.JSX.Element;
445
194
  declare function useTheme(): ThemeContextValue;
446
195
 
447
196
  declare const blockCatalogVersion: 1;
@@ -705,4 +454,4 @@ type BuildBlockCatalogOptions = {
705
454
  declare function buildBlockCatalog(opts?: BuildBlockCatalogOptions): BlockCatalogEntry[] | BlockCatalogEntryV2[] | BlockCatalogEntryV3[];
706
455
  declare function getBlockCatalogEntry(type: string, opts?: BuildBlockCatalogOptions): BlockCatalogEntry | BlockCatalogEntryV2 | BlockCatalogEntryV3 | undefined;
707
456
 
708
- 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, Slide, SlideDeck, type SlideDeckProps, type SlideProps, 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 };
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 };