@lessonkit/react 0.9.3 → 1.0.1

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,18 +1,14 @@
1
1
  import * as react_jsx_runtime from 'react/jsx-runtime';
2
2
  import React from 'react';
3
3
  import * as _lessonkit_core from '@lessonkit/core';
4
- import { LessonId, CourseId, TelemetryUser, TrackingClient, LessonkitPlugin, TelemetryEventName, PluginHost, CheckId, BlockId } from '@lessonkit/core';
5
- export { AssessmentScoreInput, AssessmentScoreResult, InteractionBlockRegistration, LessonkitPlugin, LessonkitPluginContext, LessonkitPluginKind, PluginHost, createPluginHost, defineLessonkitPlugin } 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';
6
7
  import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
8
+ import { LxpackBridgeMode } from '@lessonkit/lxpack/bridge';
7
9
  import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
8
10
  export { ThemePresetName } from '@lessonkit/themes';
9
11
 
10
- type ProgressState = {
11
- activeLessonId?: LessonId;
12
- completedLessonIds: ReadonlySet<LessonId>;
13
- courseCompleted: boolean;
14
- };
15
-
16
12
  type LessonkitConfig = {
17
13
  courseId: CourseId;
18
14
  session?: {
@@ -37,12 +33,20 @@ type LessonkitConfig = {
37
33
  };
38
34
  lxpack?: {
39
35
  /** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
40
- bridge?: "auto" | "off";
36
+ bridge?: LxpackBridgeMode;
41
37
  };
42
38
  /** Framework plugins (analytics, LMS, assessment, interaction, AI). */
43
39
  plugins?: LessonkitPlugin[];
40
+ /** Runtime implementation (`v2` headless runtime is default; set `"v1"` to opt out). */
41
+ runtimeVersion?: "v1" | "v2";
42
+ /** Optional custom telemetry pipeline sinks (used alongside tracking/xapi). */
43
+ sinks?: _lessonkit_core.TelemetryPipelineSink[];
44
44
  };
45
45
 
46
+ type LessonkitProviderProps = {
47
+ config: LessonkitConfig;
48
+ children: React.ReactNode;
49
+ };
46
50
  type LessonkitRuntime = {
47
51
  config: LessonkitConfig;
48
52
  tracking: TrackingClient;
@@ -56,64 +60,65 @@ type LessonkitRuntime = {
56
60
  setActiveLesson: (lessonId: LessonId) => void;
57
61
  completeLesson: (lessonId: LessonId) => void;
58
62
  completeCourse: () => void;
59
- track: (name: TelemetryEventName, data?: unknown, opts?: {
63
+ track: <N extends TelemetryEventName>(name: N, data?: TelemetryDataFor<N>, opts?: {
60
64
  lessonId?: LessonId;
61
65
  }) => void;
62
66
  plugins: PluginHost | null;
63
67
  };
64
- declare function LessonkitProvider(props: {
65
- config: LessonkitConfig;
66
- children: React.ReactNode;
67
- }): react_jsx_runtime.JSX.Element;
68
+ declare function LessonkitProvider(props: LessonkitProviderProps): react_jsx_runtime.JSX.Element;
68
69
 
69
- declare function Course(props: {
70
+ /** @internal Reset module warnings between tests. */
71
+ declare function resetQuizWarningsForTests(): void;
72
+ type CourseProps = {
70
73
  title: string;
71
74
  courseId: CourseId;
72
- config?: Omit<React.ComponentProps<typeof LessonkitProvider>["config"], "courseId">;
75
+ config?: Omit<LessonkitConfig, "courseId">;
73
76
  children: React.ReactNode;
74
- }): react_jsx_runtime.JSX.Element;
75
- declare function Lesson(props: {
77
+ };
78
+ type LessonProps = {
76
79
  title: string;
77
80
  lessonId: LessonId;
81
+ /** When false, unmount does not emit lesson_completed (for routed multi-pane layouts). Default true. */
82
+ autoCompleteOnUnmount?: boolean;
78
83
  children: React.ReactNode;
79
- }): react_jsx_runtime.JSX.Element;
80
- declare function Scenario(props: {
84
+ };
85
+ type ScenarioProps = {
81
86
  blockId?: BlockId;
82
87
  children: React.ReactNode;
83
- }): react_jsx_runtime.JSX.Element;
84
- declare function Reflection(props: {
88
+ };
89
+ type ReflectionProps = {
85
90
  blockId?: BlockId;
86
91
  prompt?: string;
92
+ hint?: string;
93
+ value?: string;
94
+ onChange?: (value: string) => void;
87
95
  children?: React.ReactNode;
88
- }): react_jsx_runtime.JSX.Element;
89
- declare function KnowledgeCheck(props: {
90
- checkId: CheckId;
91
- question: string;
92
- choices: string[];
93
- answer: string;
94
- passingScore?: number;
95
- }): react_jsx_runtime.JSX.Element;
96
- declare function Quiz(props: {
97
- checkId: CheckId;
98
- question: string;
99
- choices: string[];
100
- answer: string;
101
- passingScore?: number;
102
- }): react_jsx_runtime.JSX.Element;
103
- declare function ProgressTracker(): react_jsx_runtime.JSX.Element;
96
+ };
97
+ type QuizProps = AssessmentDescriptor;
98
+ type KnowledgeCheckProps = AssessmentDescriptor;
99
+ type ProgressTrackerProps = {
100
+ totalLessons?: number;
101
+ };
102
+ declare function Course(props: CourseProps): react_jsx_runtime.JSX.Element;
103
+ declare function Lesson(props: LessonProps): react_jsx_runtime.JSX.Element;
104
+ declare function Scenario(props: ScenarioProps): react_jsx_runtime.JSX.Element;
105
+ declare function Reflection(props: ReflectionProps): react_jsx_runtime.JSX.Element;
106
+ declare function KnowledgeCheck(props: KnowledgeCheckProps): react_jsx_runtime.JSX.Element;
107
+ declare function Quiz(props: QuizProps): react_jsx_runtime.JSX.Element;
108
+ declare function ProgressTracker(props: ProgressTrackerProps): react_jsx_runtime.JSX.Element;
104
109
 
105
110
  declare function useLessonkit(): LessonkitRuntime;
106
- declare function useProgress(): ProgressState;
111
+ declare function useProgress(): _lessonkit_core.ProgressState;
107
112
  declare function useTracking(): {
108
- track: (name: _lessonkit_core.TelemetryEventName, data?: unknown, opts?: {
109
- lessonId?: _lessonkit_core.LessonId;
113
+ track: <N extends _lessonkit_core.TelemetryEventName>(name: N, data?: _lessonkit_core.TelemetryDataFor<N>, opts?: {
114
+ lessonId?: LessonId;
110
115
  }) => void;
111
116
  };
112
117
  declare function useCompletion(): {
113
- completeLesson: (lessonId: _lessonkit_core.LessonId) => void;
118
+ completeLesson: (lessonId: LessonId) => void;
114
119
  completeCourse: () => void;
115
120
  };
116
- declare function useQuizState(): {
121
+ declare function useQuizState(enclosingLessonId?: LessonId): {
117
122
  answer: (opts: {
118
123
  checkId: CheckId;
119
124
  question: string;
@@ -182,8 +187,214 @@ type BlockCatalogEntry = {
182
187
  manualTracking?: string;
183
188
  };
184
189
  };
185
- declare const BLOCK_CATALOG: BlockCatalogEntry[];
190
+ declare const BLOCK_CATALOG: ({
191
+ type: string;
192
+ category: "container";
193
+ description: string;
194
+ props: ({
195
+ name: string;
196
+ type: string;
197
+ required: true;
198
+ description: string;
199
+ } | {
200
+ name: string;
201
+ type: string;
202
+ required: false;
203
+ description: string;
204
+ })[];
205
+ requiredIds: string[];
206
+ a11y: {
207
+ element: string;
208
+ ariaLabel: string;
209
+ keyboard: string;
210
+ notes: string;
211
+ liveRegions?: undefined;
212
+ };
213
+ theming: {
214
+ surface: "global-inherit";
215
+ stylingNotes: string;
216
+ dataAttributes?: undefined;
217
+ };
218
+ telemetry: {
219
+ emits: string[];
220
+ manualTracking?: undefined;
221
+ requiresActiveLesson?: undefined;
222
+ };
223
+ parentConstraints?: undefined;
224
+ optionalIds?: undefined;
225
+ aliases?: undefined;
226
+ } | {
227
+ type: string;
228
+ category: "container";
229
+ description: string;
230
+ props: ({
231
+ name: string;
232
+ type: string;
233
+ required: true;
234
+ description: string;
235
+ } | {
236
+ name: string;
237
+ type: string;
238
+ required: false;
239
+ description: string;
240
+ })[];
241
+ requiredIds: string[];
242
+ parentConstraints: string[];
243
+ a11y: {
244
+ element: string;
245
+ ariaLabel: string;
246
+ keyboard: string;
247
+ notes: string;
248
+ liveRegions?: undefined;
249
+ };
250
+ theming: {
251
+ surface: "global-inherit";
252
+ stylingNotes: string;
253
+ dataAttributes?: undefined;
254
+ };
255
+ telemetry: {
256
+ emits: string[];
257
+ manualTracking?: undefined;
258
+ requiresActiveLesson?: undefined;
259
+ };
260
+ optionalIds?: undefined;
261
+ aliases?: undefined;
262
+ } | {
263
+ type: string;
264
+ category: "content";
265
+ description: string;
266
+ props: ({
267
+ name: string;
268
+ type: string;
269
+ required: false;
270
+ description: string;
271
+ } | {
272
+ name: string;
273
+ type: string;
274
+ required: true;
275
+ description: string;
276
+ })[];
277
+ requiredIds: never[];
278
+ optionalIds: string[];
279
+ parentConstraints: string[];
280
+ a11y: {
281
+ element: string;
282
+ ariaLabel: string;
283
+ keyboard: string;
284
+ notes: string;
285
+ liveRegions?: undefined;
286
+ };
287
+ theming: {
288
+ surface: "global-inherit";
289
+ dataAttributes: string[];
290
+ stylingNotes: string;
291
+ };
292
+ telemetry: {
293
+ emits: never[];
294
+ manualTracking: string;
295
+ requiresActiveLesson?: undefined;
296
+ };
297
+ aliases?: undefined;
298
+ } | {
299
+ type: string;
300
+ category: "content";
301
+ description: string;
302
+ props: {
303
+ name: string;
304
+ type: string;
305
+ required: false;
306
+ description: string;
307
+ }[];
308
+ requiredIds: never[];
309
+ optionalIds: string[];
310
+ parentConstraints: string[];
311
+ a11y: {
312
+ element: string;
313
+ ariaLabel: string;
314
+ keyboard: string;
315
+ notes: string;
316
+ liveRegions?: undefined;
317
+ };
318
+ theming: {
319
+ surface: "global-inherit";
320
+ dataAttributes: string[];
321
+ stylingNotes: string;
322
+ };
323
+ telemetry: {
324
+ emits: never[];
325
+ requiresActiveLesson: true;
326
+ manualTracking: string;
327
+ };
328
+ aliases?: undefined;
329
+ } | {
330
+ type: string;
331
+ aliases: string[];
332
+ category: "assessment";
333
+ description: string;
334
+ props: ({
335
+ name: string;
336
+ type: string;
337
+ required: true;
338
+ description: string;
339
+ } | {
340
+ name: string;
341
+ type: string;
342
+ required: false;
343
+ description: string;
344
+ })[];
345
+ requiredIds: string[];
346
+ parentConstraints: string[];
347
+ a11y: {
348
+ element: string;
349
+ ariaLabel: string;
350
+ keyboard: string;
351
+ liveRegions: string;
352
+ notes: string;
353
+ };
354
+ theming: {
355
+ surface: "global-inherit";
356
+ dataAttributes: string[];
357
+ stylingNotes: string;
358
+ };
359
+ telemetry: {
360
+ emits: string[];
361
+ requiresActiveLesson: true;
362
+ manualTracking?: undefined;
363
+ };
364
+ optionalIds?: undefined;
365
+ } | {
366
+ type: string;
367
+ category: "chrome";
368
+ description: string;
369
+ props: {
370
+ name: string;
371
+ type: string;
372
+ required: false;
373
+ description: string;
374
+ }[];
375
+ requiredIds: never[];
376
+ parentConstraints: string[];
377
+ a11y: {
378
+ element: string;
379
+ ariaLabel: string;
380
+ keyboard: string;
381
+ notes: string;
382
+ liveRegions?: undefined;
383
+ };
384
+ theming: {
385
+ surface: "global-inherit";
386
+ stylingNotes: string;
387
+ dataAttributes?: undefined;
388
+ };
389
+ telemetry: {
390
+ emits: never[];
391
+ manualTracking?: undefined;
392
+ requiresActiveLesson?: undefined;
393
+ };
394
+ optionalIds?: undefined;
395
+ aliases?: undefined;
396
+ })[];
186
397
  declare function buildBlockCatalog(): BlockCatalogEntry[];
187
398
  declare function getBlockCatalogEntry(type: string): BlockCatalogEntry | undefined;
188
399
 
189
- export { BLOCK_CATALOG, type BlockCatalogEntry, type BlockPropSpec, Course, KnowledgeCheck, Lesson, type LessonkitConfig, LessonkitProvider, type LessonkitRuntime, ProgressTracker, Quiz, Reflection, Scenario, type ThemeContextValue, type ThemeMode, ThemeProvider, type ThemeProviderProps, type ThemeResolvedMode, blockCatalogVersion, buildBlockCatalog, getBlockCatalogEntry, useCompletion, useLessonkit, useProgress, useQuizState, useTheme, useTracking };
400
+ 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 };