@lessonkit/lxpack 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.
@@ -0,0 +1,184 @@
1
+ import { CheckId, CourseId, LessonId } from '@lessonkit/core';
2
+ import { ThemePresetName, LessonkitThemeV1 } from '@lessonkit/themes';
3
+ import { ExportTarget, ValidateCourseResult, BuildCourseResult } from '@lxpack/api';
4
+ export { ExportTarget } from '@lxpack/api';
5
+
6
+ type SpaLayout = "single-spa" | "per-lesson-spa";
7
+ type LessonDescriptor = {
8
+ id: LessonId;
9
+ title: string;
10
+ /** Built SPA folder relative to the LXPack project root (`per-lesson-spa` only). */
11
+ spaPath?: string;
12
+ };
13
+ type AssessmentDescriptor = {
14
+ checkId: CheckId;
15
+ question: string;
16
+ choices: string[];
17
+ answer: string;
18
+ passingScore?: number;
19
+ };
20
+ type LessonkitCourseDescriptor = {
21
+ courseId: CourseId;
22
+ title: string;
23
+ version?: string;
24
+ layout: SpaLayout;
25
+ lessons: LessonDescriptor[];
26
+ assessments?: AssessmentDescriptor[];
27
+ theme?: {
28
+ preset?: ThemePresetName;
29
+ theme?: LessonkitThemeV1;
30
+ };
31
+ tracking?: {
32
+ completion?: {
33
+ threshold?: number;
34
+ };
35
+ };
36
+ /** Source Vite `dist` directory for `single-spa` (default: `dist`). */
37
+ spaDistDir?: string;
38
+ /** LXPack SPA lesson id for `single-spa` (default: first lesson id or `main`). */
39
+ spaLessonId?: string;
40
+ };
41
+ type LessonkitInterchangeV1 = {
42
+ format: "lessonkit";
43
+ version: "1";
44
+ course: {
45
+ id: CourseId;
46
+ title: string;
47
+ };
48
+ lessons: Array<{
49
+ id: LessonId;
50
+ title: string;
51
+ type: "spa";
52
+ path: string;
53
+ }>;
54
+ tracking?: {
55
+ completion?: {
56
+ threshold?: number;
57
+ };
58
+ };
59
+ };
60
+ type MappedLessonkitIds = {
61
+ courseId: CourseId;
62
+ lessonIds: LessonId[];
63
+ checkIds: CheckId[];
64
+ };
65
+
66
+ type DescriptorValidationIssue = {
67
+ path: string;
68
+ message: string;
69
+ };
70
+ type DescriptorValidationResult = {
71
+ ok: true;
72
+ descriptor: LessonkitCourseDescriptor;
73
+ } | {
74
+ ok: false;
75
+ issues: DescriptorValidationIssue[];
76
+ };
77
+ declare function validateDescriptor(input: LessonkitCourseDescriptor): DescriptorValidationResult;
78
+
79
+ /**
80
+ * Stable 1:1 mapping from LessonKit ids to LXPack manifest ids.
81
+ * LessonKit slug rules already match LXPack `activityIdSchema` (letter-first, alphanumeric + _ -).
82
+ */
83
+ declare function mapLessonkitIds(descriptor: LessonkitCourseDescriptor): MappedLessonkitIds;
84
+
85
+ type LxpackRuntimeTheme = {
86
+ theme: string;
87
+ cssVariables: Record<string, string>;
88
+ };
89
+ declare function themeToLxpackRuntime(input: {
90
+ preset?: ThemePresetName;
91
+ theme?: LessonkitThemeV1;
92
+ }): LxpackRuntimeTheme;
93
+
94
+ type SpaLessonEntry = {
95
+ id: string;
96
+ title: string;
97
+ path: string;
98
+ };
99
+ declare function resolveSpaLessons(descriptor: LessonkitCourseDescriptor): SpaLessonEntry[];
100
+ declare function descriptorToInterchange(descriptor: LessonkitCourseDescriptor): LessonkitInterchangeV1;
101
+
102
+ type LxpackInjectedAssessment = {
103
+ id: string;
104
+ title?: string;
105
+ passingScore: number;
106
+ questions: Array<{
107
+ id: string;
108
+ prompt: string;
109
+ choices: Array<{
110
+ id: string;
111
+ text: string;
112
+ correct?: boolean;
113
+ }>;
114
+ }>;
115
+ };
116
+ declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment;
117
+ declare function extractAssessments(descriptor: LessonkitCourseDescriptor): LxpackInjectedAssessment[];
118
+
119
+ type WriteLxpackProjectOptions = {
120
+ descriptor: LessonkitCourseDescriptor;
121
+ /** LXPack project output directory (created if missing). */
122
+ outDir: string;
123
+ /**
124
+ * Absolute or cwd-relative path to the built SPA for `single-spa`
125
+ * (defaults to `descriptor.spaDistDir` or `./dist`).
126
+ */
127
+ spaDistDir?: string;
128
+ /**
129
+ * For `per-lesson-spa`: map lesson id → absolute path to that lesson's built SPA folder.
130
+ */
131
+ lessonSpaDirs?: Record<string, string>;
132
+ };
133
+ type WriteLxpackProjectResult = {
134
+ outDir: string;
135
+ courseYamlPath: string;
136
+ lessonkitJsonPath: string;
137
+ };
138
+ declare function writeLxpackProject(options: WriteLxpackProjectOptions): Promise<WriteLxpackProjectResult>;
139
+
140
+ type ValidateLessonkitProjectOptions = {
141
+ courseDir: string;
142
+ target?: ExportTarget;
143
+ };
144
+ type BuildLessonkitProjectOptions = {
145
+ courseDir: string;
146
+ target: ExportTarget;
147
+ output?: string;
148
+ dir?: boolean;
149
+ outputBaseDir?: string;
150
+ assessments?: unknown[];
151
+ };
152
+ type PackageLessonkitCourseOptions = WriteLxpackProjectOptions & {
153
+ target: ExportTarget;
154
+ /** Output zip or directory path (must stay inside `outDir` for LXPack). */
155
+ output?: string;
156
+ dir?: boolean;
157
+ outputBaseDir?: string;
158
+ };
159
+ type PackageLessonkitCourseResult = {
160
+ ok: true;
161
+ courseDir: string;
162
+ target: ExportTarget;
163
+ outputPath?: string;
164
+ outputDir?: string;
165
+ fileCount: number;
166
+ validation: ValidateCourseResult;
167
+ build: BuildCourseResult;
168
+ } | {
169
+ ok: false;
170
+ courseDir: string;
171
+ target: ExportTarget;
172
+ validation?: ValidateCourseResult;
173
+ build?: BuildCourseResult;
174
+ issues: Array<{
175
+ path?: string;
176
+ message: string;
177
+ severity?: string;
178
+ }>;
179
+ };
180
+ declare function validateLessonkitProject(options: ValidateLessonkitProjectOptions): Promise<ValidateCourseResult>;
181
+ declare function buildLessonkitProject(options: BuildLessonkitProjectOptions): Promise<BuildCourseResult>;
182
+ declare function packageLessonkitCourse(options: PackageLessonkitCourseOptions): Promise<PackageLessonkitCourseResult>;
183
+
184
+ export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type DescriptorValidationIssue, type DescriptorValidationResult, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitInterchangeV1, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type MappedLessonkitIds, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type SpaLayout, type SpaLessonEntry, type ValidateLessonkitProjectOptions, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, descriptorToInterchange, extractAssessments, mapLessonkitIds, packageLessonkitCourse, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateLessonkitProject, writeLxpackProject };
@@ -0,0 +1,184 @@
1
+ import { CheckId, CourseId, LessonId } from '@lessonkit/core';
2
+ import { ThemePresetName, LessonkitThemeV1 } from '@lessonkit/themes';
3
+ import { ExportTarget, ValidateCourseResult, BuildCourseResult } from '@lxpack/api';
4
+ export { ExportTarget } from '@lxpack/api';
5
+
6
+ type SpaLayout = "single-spa" | "per-lesson-spa";
7
+ type LessonDescriptor = {
8
+ id: LessonId;
9
+ title: string;
10
+ /** Built SPA folder relative to the LXPack project root (`per-lesson-spa` only). */
11
+ spaPath?: string;
12
+ };
13
+ type AssessmentDescriptor = {
14
+ checkId: CheckId;
15
+ question: string;
16
+ choices: string[];
17
+ answer: string;
18
+ passingScore?: number;
19
+ };
20
+ type LessonkitCourseDescriptor = {
21
+ courseId: CourseId;
22
+ title: string;
23
+ version?: string;
24
+ layout: SpaLayout;
25
+ lessons: LessonDescriptor[];
26
+ assessments?: AssessmentDescriptor[];
27
+ theme?: {
28
+ preset?: ThemePresetName;
29
+ theme?: LessonkitThemeV1;
30
+ };
31
+ tracking?: {
32
+ completion?: {
33
+ threshold?: number;
34
+ };
35
+ };
36
+ /** Source Vite `dist` directory for `single-spa` (default: `dist`). */
37
+ spaDistDir?: string;
38
+ /** LXPack SPA lesson id for `single-spa` (default: first lesson id or `main`). */
39
+ spaLessonId?: string;
40
+ };
41
+ type LessonkitInterchangeV1 = {
42
+ format: "lessonkit";
43
+ version: "1";
44
+ course: {
45
+ id: CourseId;
46
+ title: string;
47
+ };
48
+ lessons: Array<{
49
+ id: LessonId;
50
+ title: string;
51
+ type: "spa";
52
+ path: string;
53
+ }>;
54
+ tracking?: {
55
+ completion?: {
56
+ threshold?: number;
57
+ };
58
+ };
59
+ };
60
+ type MappedLessonkitIds = {
61
+ courseId: CourseId;
62
+ lessonIds: LessonId[];
63
+ checkIds: CheckId[];
64
+ };
65
+
66
+ type DescriptorValidationIssue = {
67
+ path: string;
68
+ message: string;
69
+ };
70
+ type DescriptorValidationResult = {
71
+ ok: true;
72
+ descriptor: LessonkitCourseDescriptor;
73
+ } | {
74
+ ok: false;
75
+ issues: DescriptorValidationIssue[];
76
+ };
77
+ declare function validateDescriptor(input: LessonkitCourseDescriptor): DescriptorValidationResult;
78
+
79
+ /**
80
+ * Stable 1:1 mapping from LessonKit ids to LXPack manifest ids.
81
+ * LessonKit slug rules already match LXPack `activityIdSchema` (letter-first, alphanumeric + _ -).
82
+ */
83
+ declare function mapLessonkitIds(descriptor: LessonkitCourseDescriptor): MappedLessonkitIds;
84
+
85
+ type LxpackRuntimeTheme = {
86
+ theme: string;
87
+ cssVariables: Record<string, string>;
88
+ };
89
+ declare function themeToLxpackRuntime(input: {
90
+ preset?: ThemePresetName;
91
+ theme?: LessonkitThemeV1;
92
+ }): LxpackRuntimeTheme;
93
+
94
+ type SpaLessonEntry = {
95
+ id: string;
96
+ title: string;
97
+ path: string;
98
+ };
99
+ declare function resolveSpaLessons(descriptor: LessonkitCourseDescriptor): SpaLessonEntry[];
100
+ declare function descriptorToInterchange(descriptor: LessonkitCourseDescriptor): LessonkitInterchangeV1;
101
+
102
+ type LxpackInjectedAssessment = {
103
+ id: string;
104
+ title?: string;
105
+ passingScore: number;
106
+ questions: Array<{
107
+ id: string;
108
+ prompt: string;
109
+ choices: Array<{
110
+ id: string;
111
+ text: string;
112
+ correct?: boolean;
113
+ }>;
114
+ }>;
115
+ };
116
+ declare function assessmentDescriptorToLxpack(assessment: AssessmentDescriptor): LxpackInjectedAssessment;
117
+ declare function extractAssessments(descriptor: LessonkitCourseDescriptor): LxpackInjectedAssessment[];
118
+
119
+ type WriteLxpackProjectOptions = {
120
+ descriptor: LessonkitCourseDescriptor;
121
+ /** LXPack project output directory (created if missing). */
122
+ outDir: string;
123
+ /**
124
+ * Absolute or cwd-relative path to the built SPA for `single-spa`
125
+ * (defaults to `descriptor.spaDistDir` or `./dist`).
126
+ */
127
+ spaDistDir?: string;
128
+ /**
129
+ * For `per-lesson-spa`: map lesson id → absolute path to that lesson's built SPA folder.
130
+ */
131
+ lessonSpaDirs?: Record<string, string>;
132
+ };
133
+ type WriteLxpackProjectResult = {
134
+ outDir: string;
135
+ courseYamlPath: string;
136
+ lessonkitJsonPath: string;
137
+ };
138
+ declare function writeLxpackProject(options: WriteLxpackProjectOptions): Promise<WriteLxpackProjectResult>;
139
+
140
+ type ValidateLessonkitProjectOptions = {
141
+ courseDir: string;
142
+ target?: ExportTarget;
143
+ };
144
+ type BuildLessonkitProjectOptions = {
145
+ courseDir: string;
146
+ target: ExportTarget;
147
+ output?: string;
148
+ dir?: boolean;
149
+ outputBaseDir?: string;
150
+ assessments?: unknown[];
151
+ };
152
+ type PackageLessonkitCourseOptions = WriteLxpackProjectOptions & {
153
+ target: ExportTarget;
154
+ /** Output zip or directory path (must stay inside `outDir` for LXPack). */
155
+ output?: string;
156
+ dir?: boolean;
157
+ outputBaseDir?: string;
158
+ };
159
+ type PackageLessonkitCourseResult = {
160
+ ok: true;
161
+ courseDir: string;
162
+ target: ExportTarget;
163
+ outputPath?: string;
164
+ outputDir?: string;
165
+ fileCount: number;
166
+ validation: ValidateCourseResult;
167
+ build: BuildCourseResult;
168
+ } | {
169
+ ok: false;
170
+ courseDir: string;
171
+ target: ExportTarget;
172
+ validation?: ValidateCourseResult;
173
+ build?: BuildCourseResult;
174
+ issues: Array<{
175
+ path?: string;
176
+ message: string;
177
+ severity?: string;
178
+ }>;
179
+ };
180
+ declare function validateLessonkitProject(options: ValidateLessonkitProjectOptions): Promise<ValidateCourseResult>;
181
+ declare function buildLessonkitProject(options: BuildLessonkitProjectOptions): Promise<BuildCourseResult>;
182
+ declare function packageLessonkitCourse(options: PackageLessonkitCourseOptions): Promise<PackageLessonkitCourseResult>;
183
+
184
+ export { type AssessmentDescriptor, type BuildLessonkitProjectOptions, type DescriptorValidationIssue, type DescriptorValidationResult, type LessonDescriptor, type LessonkitCourseDescriptor, type LessonkitInterchangeV1, type LxpackInjectedAssessment, type LxpackRuntimeTheme, type MappedLessonkitIds, type PackageLessonkitCourseOptions, type PackageLessonkitCourseResult, type SpaLayout, type SpaLessonEntry, type ValidateLessonkitProjectOptions, type WriteLxpackProjectOptions, type WriteLxpackProjectResult, assessmentDescriptorToLxpack, buildLessonkitProject, descriptorToInterchange, extractAssessments, mapLessonkitIds, packageLessonkitCourse, resolveSpaLessons, themeToLxpackRuntime, validateDescriptor, validateLessonkitProject, writeLxpackProject };