@lessonkit/react 0.4.0 → 0.6.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/README.md +17 -10
- package/dist/index.cjs +400 -112
- package/dist/index.d.cts +28 -15
- package/dist/index.d.ts +28 -15
- package/dist/index.js +396 -105
- package/package.json +8 -7
package/dist/index.d.cts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
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 { CourseId, TelemetryUser,
|
|
4
|
+
import { LessonId, CourseId, TelemetryUser, TrackingClient, TelemetryEventName, CheckId, BlockId } from '@lessonkit/core';
|
|
5
5
|
import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
|
|
6
6
|
import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
|
|
7
7
|
export { ThemePresetName } from '@lessonkit/themes';
|
|
8
8
|
|
|
9
|
+
type ProgressState = {
|
|
10
|
+
activeLessonId?: LessonId;
|
|
11
|
+
completedLessonIds: ReadonlySet<LessonId>;
|
|
12
|
+
courseCompleted: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
9
15
|
type LessonkitConfig = {
|
|
10
|
-
courseId
|
|
16
|
+
courseId: CourseId;
|
|
11
17
|
session?: {
|
|
12
18
|
sessionId?: string;
|
|
13
19
|
attemptId?: string;
|
|
@@ -15,8 +21,8 @@ type LessonkitConfig = {
|
|
|
15
21
|
};
|
|
16
22
|
tracking?: {
|
|
17
23
|
enabled?: boolean;
|
|
18
|
-
sink?: (event:
|
|
19
|
-
batchSink?: (events:
|
|
24
|
+
sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
|
|
25
|
+
batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
|
|
20
26
|
batch?: {
|
|
21
27
|
enabled?: boolean;
|
|
22
28
|
flushIntervalMs?: number;
|
|
@@ -28,12 +34,12 @@ type LessonkitConfig = {
|
|
|
28
34
|
transport?: XAPITransport;
|
|
29
35
|
client?: XAPIClient;
|
|
30
36
|
};
|
|
37
|
+
lxpack?: {
|
|
38
|
+
/** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
|
|
39
|
+
bridge?: "auto" | "off";
|
|
40
|
+
};
|
|
31
41
|
};
|
|
32
|
-
|
|
33
|
-
activeLessonId?: LessonId;
|
|
34
|
-
completedLessonIds: ReadonlySet<LessonId>;
|
|
35
|
-
courseCompleted: boolean;
|
|
36
|
-
};
|
|
42
|
+
|
|
37
43
|
type LessonkitRuntime = {
|
|
38
44
|
config: LessonkitConfig;
|
|
39
45
|
tracking: TrackingClient;
|
|
@@ -47,39 +53,43 @@ type LessonkitRuntime = {
|
|
|
47
53
|
setActiveLesson: (lessonId: LessonId) => void;
|
|
48
54
|
completeLesson: (lessonId: LessonId) => void;
|
|
49
55
|
completeCourse: () => void;
|
|
50
|
-
track: (name:
|
|
56
|
+
track: (name: TelemetryEventName, data?: unknown, opts?: {
|
|
51
57
|
lessonId?: LessonId;
|
|
52
58
|
}) => void;
|
|
53
59
|
};
|
|
54
60
|
declare function LessonkitProvider(props: {
|
|
55
|
-
config
|
|
61
|
+
config: LessonkitConfig;
|
|
56
62
|
children: React.ReactNode;
|
|
57
63
|
}): react_jsx_runtime.JSX.Element;
|
|
58
64
|
|
|
59
65
|
declare function Course(props: {
|
|
60
66
|
title: string;
|
|
61
|
-
courseId
|
|
67
|
+
courseId: CourseId;
|
|
62
68
|
config?: Omit<React.ComponentProps<typeof LessonkitProvider>["config"], "courseId">;
|
|
63
69
|
children: React.ReactNode;
|
|
64
70
|
}): react_jsx_runtime.JSX.Element;
|
|
65
71
|
declare function Lesson(props: {
|
|
66
72
|
title: string;
|
|
67
|
-
lessonId
|
|
73
|
+
lessonId: LessonId;
|
|
68
74
|
children: React.ReactNode;
|
|
69
75
|
}): react_jsx_runtime.JSX.Element;
|
|
70
76
|
declare function Scenario(props: {
|
|
77
|
+
blockId?: BlockId;
|
|
71
78
|
children: React.ReactNode;
|
|
72
79
|
}): react_jsx_runtime.JSX.Element;
|
|
73
80
|
declare function Reflection(props: {
|
|
81
|
+
blockId?: BlockId;
|
|
74
82
|
prompt?: string;
|
|
75
83
|
children?: React.ReactNode;
|
|
76
84
|
}): react_jsx_runtime.JSX.Element;
|
|
77
85
|
declare function KnowledgeCheck(props: {
|
|
86
|
+
checkId: CheckId;
|
|
78
87
|
question: string;
|
|
79
88
|
choices: string[];
|
|
80
89
|
answer: string;
|
|
81
90
|
}): react_jsx_runtime.JSX.Element;
|
|
82
91
|
declare function Quiz(props: {
|
|
92
|
+
checkId: CheckId;
|
|
83
93
|
question: string;
|
|
84
94
|
choices: string[];
|
|
85
95
|
answer: string;
|
|
@@ -89,7 +99,7 @@ declare function ProgressTracker(): react_jsx_runtime.JSX.Element;
|
|
|
89
99
|
declare function useLessonkit(): LessonkitRuntime;
|
|
90
100
|
declare function useProgress(): ProgressState;
|
|
91
101
|
declare function useTracking(): {
|
|
92
|
-
track: (name: _lessonkit_core.
|
|
102
|
+
track: (name: _lessonkit_core.TelemetryEventName, data?: unknown, opts?: {
|
|
93
103
|
lessonId?: _lessonkit_core.LessonId;
|
|
94
104
|
}) => void;
|
|
95
105
|
};
|
|
@@ -99,13 +109,16 @@ declare function useCompletion(): {
|
|
|
99
109
|
};
|
|
100
110
|
declare function useQuizState(): {
|
|
101
111
|
answer: (opts: {
|
|
112
|
+
checkId: CheckId;
|
|
102
113
|
question: string;
|
|
103
114
|
choice: string;
|
|
104
115
|
correct: boolean;
|
|
105
116
|
}) => void;
|
|
106
|
-
complete: (opts
|
|
117
|
+
complete: (opts: {
|
|
118
|
+
checkId: CheckId;
|
|
107
119
|
score?: number;
|
|
108
120
|
maxScore?: number;
|
|
121
|
+
passingScore?: number;
|
|
109
122
|
}) => void;
|
|
110
123
|
};
|
|
111
124
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,19 @@
|
|
|
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 { CourseId, TelemetryUser,
|
|
4
|
+
import { LessonId, CourseId, TelemetryUser, TrackingClient, TelemetryEventName, CheckId, BlockId } from '@lessonkit/core';
|
|
5
5
|
import { XAPITransport, XAPIClient } from '@lessonkit/xapi';
|
|
6
6
|
import { LessonkitThemeV1, ThemePresetName, PartialLessonkitThemeV1 } from '@lessonkit/themes';
|
|
7
7
|
export { ThemePresetName } from '@lessonkit/themes';
|
|
8
8
|
|
|
9
|
+
type ProgressState = {
|
|
10
|
+
activeLessonId?: LessonId;
|
|
11
|
+
completedLessonIds: ReadonlySet<LessonId>;
|
|
12
|
+
courseCompleted: boolean;
|
|
13
|
+
};
|
|
14
|
+
|
|
9
15
|
type LessonkitConfig = {
|
|
10
|
-
courseId
|
|
16
|
+
courseId: CourseId;
|
|
11
17
|
session?: {
|
|
12
18
|
sessionId?: string;
|
|
13
19
|
attemptId?: string;
|
|
@@ -15,8 +21,8 @@ type LessonkitConfig = {
|
|
|
15
21
|
};
|
|
16
22
|
tracking?: {
|
|
17
23
|
enabled?: boolean;
|
|
18
|
-
sink?: (event:
|
|
19
|
-
batchSink?: (events:
|
|
24
|
+
sink?: (event: Parameters<TrackingClient["track"]>[0]) => void | Promise<void>;
|
|
25
|
+
batchSink?: (events: Parameters<TrackingClient["track"]>[0][]) => void | Promise<void>;
|
|
20
26
|
batch?: {
|
|
21
27
|
enabled?: boolean;
|
|
22
28
|
flushIntervalMs?: number;
|
|
@@ -28,12 +34,12 @@ type LessonkitConfig = {
|
|
|
28
34
|
transport?: XAPITransport;
|
|
29
35
|
client?: XAPIClient;
|
|
30
36
|
};
|
|
37
|
+
lxpack?: {
|
|
38
|
+
/** Forward completion events to `window.parent.lxpackBridge.v1` when embedded (default `auto`). */
|
|
39
|
+
bridge?: "auto" | "off";
|
|
40
|
+
};
|
|
31
41
|
};
|
|
32
|
-
|
|
33
|
-
activeLessonId?: LessonId;
|
|
34
|
-
completedLessonIds: ReadonlySet<LessonId>;
|
|
35
|
-
courseCompleted: boolean;
|
|
36
|
-
};
|
|
42
|
+
|
|
37
43
|
type LessonkitRuntime = {
|
|
38
44
|
config: LessonkitConfig;
|
|
39
45
|
tracking: TrackingClient;
|
|
@@ -47,39 +53,43 @@ type LessonkitRuntime = {
|
|
|
47
53
|
setActiveLesson: (lessonId: LessonId) => void;
|
|
48
54
|
completeLesson: (lessonId: LessonId) => void;
|
|
49
55
|
completeCourse: () => void;
|
|
50
|
-
track: (name:
|
|
56
|
+
track: (name: TelemetryEventName, data?: unknown, opts?: {
|
|
51
57
|
lessonId?: LessonId;
|
|
52
58
|
}) => void;
|
|
53
59
|
};
|
|
54
60
|
declare function LessonkitProvider(props: {
|
|
55
|
-
config
|
|
61
|
+
config: LessonkitConfig;
|
|
56
62
|
children: React.ReactNode;
|
|
57
63
|
}): react_jsx_runtime.JSX.Element;
|
|
58
64
|
|
|
59
65
|
declare function Course(props: {
|
|
60
66
|
title: string;
|
|
61
|
-
courseId
|
|
67
|
+
courseId: CourseId;
|
|
62
68
|
config?: Omit<React.ComponentProps<typeof LessonkitProvider>["config"], "courseId">;
|
|
63
69
|
children: React.ReactNode;
|
|
64
70
|
}): react_jsx_runtime.JSX.Element;
|
|
65
71
|
declare function Lesson(props: {
|
|
66
72
|
title: string;
|
|
67
|
-
lessonId
|
|
73
|
+
lessonId: LessonId;
|
|
68
74
|
children: React.ReactNode;
|
|
69
75
|
}): react_jsx_runtime.JSX.Element;
|
|
70
76
|
declare function Scenario(props: {
|
|
77
|
+
blockId?: BlockId;
|
|
71
78
|
children: React.ReactNode;
|
|
72
79
|
}): react_jsx_runtime.JSX.Element;
|
|
73
80
|
declare function Reflection(props: {
|
|
81
|
+
blockId?: BlockId;
|
|
74
82
|
prompt?: string;
|
|
75
83
|
children?: React.ReactNode;
|
|
76
84
|
}): react_jsx_runtime.JSX.Element;
|
|
77
85
|
declare function KnowledgeCheck(props: {
|
|
86
|
+
checkId: CheckId;
|
|
78
87
|
question: string;
|
|
79
88
|
choices: string[];
|
|
80
89
|
answer: string;
|
|
81
90
|
}): react_jsx_runtime.JSX.Element;
|
|
82
91
|
declare function Quiz(props: {
|
|
92
|
+
checkId: CheckId;
|
|
83
93
|
question: string;
|
|
84
94
|
choices: string[];
|
|
85
95
|
answer: string;
|
|
@@ -89,7 +99,7 @@ declare function ProgressTracker(): react_jsx_runtime.JSX.Element;
|
|
|
89
99
|
declare function useLessonkit(): LessonkitRuntime;
|
|
90
100
|
declare function useProgress(): ProgressState;
|
|
91
101
|
declare function useTracking(): {
|
|
92
|
-
track: (name: _lessonkit_core.
|
|
102
|
+
track: (name: _lessonkit_core.TelemetryEventName, data?: unknown, opts?: {
|
|
93
103
|
lessonId?: _lessonkit_core.LessonId;
|
|
94
104
|
}) => void;
|
|
95
105
|
};
|
|
@@ -99,13 +109,16 @@ declare function useCompletion(): {
|
|
|
99
109
|
};
|
|
100
110
|
declare function useQuizState(): {
|
|
101
111
|
answer: (opts: {
|
|
112
|
+
checkId: CheckId;
|
|
102
113
|
question: string;
|
|
103
114
|
choice: string;
|
|
104
115
|
correct: boolean;
|
|
105
116
|
}) => void;
|
|
106
|
-
complete: (opts
|
|
117
|
+
complete: (opts: {
|
|
118
|
+
checkId: CheckId;
|
|
107
119
|
score?: number;
|
|
108
120
|
maxScore?: number;
|
|
121
|
+
passingScore?: number;
|
|
109
122
|
}) => void;
|
|
110
123
|
};
|
|
111
124
|
|