@learnmd/core 0.0.1-beta.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/LICENSE +21 -0
- package/README.md +30 -0
- package/dist/components/LearnMDProvider.d.ts +33 -0
- package/dist/components/LearnMDProvider.d.ts.map +1 -0
- package/dist/components/LearnMDProvider.js +16 -0
- package/dist/components/LearnMDProvider.js.map +1 -0
- package/dist/gamification/index.d.ts +77 -0
- package/dist/gamification/index.d.ts.map +1 -0
- package/dist/gamification/index.js +402 -0
- package/dist/gamification/index.js.map +1 -0
- package/dist/i18n/index.d.ts +119 -0
- package/dist/i18n/index.d.ts.map +1 -0
- package/dist/i18n/index.js +261 -0
- package/dist/i18n/index.js.map +1 -0
- package/dist/index.d.ts +81 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +77 -0
- package/dist/index.js.map +1 -0
- package/dist/parser/index.d.ts +57 -0
- package/dist/parser/index.d.ts.map +1 -0
- package/dist/parser/index.js +182 -0
- package/dist/parser/index.js.map +1 -0
- package/dist/plugins/index.d.ts +150 -0
- package/dist/plugins/index.d.ts.map +1 -0
- package/dist/plugins/index.js +291 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/pdf/index.d.ts +8 -0
- package/dist/plugins/pdf/index.d.ts.map +1 -0
- package/dist/plugins/pdf/index.js +53 -0
- package/dist/plugins/pdf/index.js.map +1 -0
- package/dist/router/index.d.ts +111 -0
- package/dist/router/index.d.ts.map +1 -0
- package/dist/router/index.js +268 -0
- package/dist/router/index.js.map +1 -0
- package/dist/storage/index.d.ts +110 -0
- package/dist/storage/index.d.ts.map +1 -0
- package/dist/storage/index.js +390 -0
- package/dist/storage/index.js.map +1 -0
- package/dist/types/index.d.ts +283 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +2 -0
- package/dist/types/index.js.map +1 -0
- package/package.json +73 -0
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { jsPDF } from 'jspdf';
|
|
2
|
+
export async function generateCertificate(profile, options) {
|
|
3
|
+
const doc = new jsPDF({
|
|
4
|
+
orientation: 'landscape',
|
|
5
|
+
unit: 'in',
|
|
6
|
+
format: 'letter'
|
|
7
|
+
});
|
|
8
|
+
const { courseTitle, completionDate = new Date(), signature = 'LearnMD Instructors' } = options;
|
|
9
|
+
// Add border
|
|
10
|
+
doc.setLineWidth(0.1);
|
|
11
|
+
doc.rect(0.5, 0.5, 10, 7.5);
|
|
12
|
+
doc.setLineWidth(0.02);
|
|
13
|
+
doc.rect(0.6, 0.6, 9.8, 7.3);
|
|
14
|
+
// Title
|
|
15
|
+
doc.setFont('helvetica', 'bold');
|
|
16
|
+
doc.setFontSize(40);
|
|
17
|
+
doc.setTextColor(59, 130, 246); // Emerald-ish or Blue
|
|
18
|
+
doc.text('Certificate of Completion', 5.5, 2.5, { align: 'center' });
|
|
19
|
+
// Subtitle
|
|
20
|
+
doc.setFont('helvetica', 'normal');
|
|
21
|
+
doc.setFontSize(20);
|
|
22
|
+
doc.setTextColor(100, 100, 100);
|
|
23
|
+
doc.text('This is to certify that', 5.5, 3.5, { align: 'center' });
|
|
24
|
+
// Student Name
|
|
25
|
+
doc.setFont('helvetica', 'bold');
|
|
26
|
+
doc.setFontSize(30);
|
|
27
|
+
doc.setTextColor(0, 0, 0);
|
|
28
|
+
doc.text(profile.name || 'Student Name', 5.5, 4.5, { align: 'center' });
|
|
29
|
+
// Course Text
|
|
30
|
+
doc.setFont('helvetica', 'normal');
|
|
31
|
+
doc.setFontSize(16);
|
|
32
|
+
doc.setTextColor(100, 100, 100);
|
|
33
|
+
doc.text('has successfully completed the course', 5.5, 5.3, { align: 'center' });
|
|
34
|
+
// Course Title
|
|
35
|
+
doc.setFont('helvetica', 'bold');
|
|
36
|
+
doc.setFontSize(24);
|
|
37
|
+
doc.setTextColor(16, 185, 129); // Emerald
|
|
38
|
+
doc.text(courseTitle, 5.5, 6.0, { align: 'center' });
|
|
39
|
+
// Date and Signature labels
|
|
40
|
+
doc.setFont('helvetica', 'normal');
|
|
41
|
+
doc.setFontSize(14);
|
|
42
|
+
doc.setTextColor(0, 0, 0);
|
|
43
|
+
const dateStr = completionDate.toLocaleDateString();
|
|
44
|
+
doc.text(dateStr, 2.5, 7.2, { align: 'center' });
|
|
45
|
+
doc.text('Date', 2.5, 7.5, { align: 'center' });
|
|
46
|
+
doc.line(1.5, 7.3, 3.5, 7.3);
|
|
47
|
+
doc.text(signature, 8.5, 7.2, { align: 'center' });
|
|
48
|
+
doc.text('Signature', 8.5, 7.5, { align: 'center' });
|
|
49
|
+
doc.line(7.5, 7.3, 9.5, 7.3);
|
|
50
|
+
// Save the PDF
|
|
51
|
+
doc.save(`Certificate-${courseTitle.replace(/\s+/g, '-')}.pdf`);
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/plugins/pdf/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,OAAO,CAAC;AAS9B,MAAM,CAAC,KAAK,UAAU,mBAAmB,CAAC,OAAoB,EAAE,OAA2B;IACzF,MAAM,GAAG,GAAG,IAAI,KAAK,CAAC;QACpB,WAAW,EAAE,WAAW;QACxB,IAAI,EAAE,IAAI;QACV,MAAM,EAAE,QAAQ;KACjB,CAAC,CAAC;IAEH,MAAM,EAAE,WAAW,EAAE,cAAc,GAAG,IAAI,IAAI,EAAE,EAAE,SAAS,GAAG,qBAAqB,EAAE,GAAG,OAAO,CAAC;IAEhG,aAAa;IACb,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IACtB,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,EAAE,EAAE,GAAG,CAAC,CAAC;IAC5B,GAAG,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;IACvB,GAAG,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,EA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AC;IAE7B,eAAe;IACf,GAAG,CAAC,IAAI,CAAC,eAAe,WAAW,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,MAAM,CAAC,CAAC;AAClE,CAAC"}
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { Course, Lesson, CourseModule } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* Router state
|
|
4
|
+
*/
|
|
5
|
+
export interface RouterState {
|
|
6
|
+
currentCourse: string | null;
|
|
7
|
+
currentLesson: string | null;
|
|
8
|
+
currentModule: string | null;
|
|
9
|
+
history: string[];
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Navigation item for sidebar
|
|
13
|
+
*/
|
|
14
|
+
export interface NavigationItem {
|
|
15
|
+
type: 'module' | 'lesson';
|
|
16
|
+
id: string;
|
|
17
|
+
title: string;
|
|
18
|
+
slug?: string;
|
|
19
|
+
moduleId?: string;
|
|
20
|
+
completed?: boolean;
|
|
21
|
+
active?: boolean;
|
|
22
|
+
children?: NavigationItem[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Router manager for course navigation
|
|
26
|
+
*/
|
|
27
|
+
export declare class RouterManager {
|
|
28
|
+
private course;
|
|
29
|
+
private state;
|
|
30
|
+
private listeners;
|
|
31
|
+
/**
|
|
32
|
+
* Set the current course
|
|
33
|
+
*/
|
|
34
|
+
setCourse(course: Course): void;
|
|
35
|
+
/**
|
|
36
|
+
* Navigate to a lesson
|
|
37
|
+
*/
|
|
38
|
+
navigateToLesson(lessonSlug: string, addToHistory?: boolean): boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Navigate to the next lesson
|
|
41
|
+
*/
|
|
42
|
+
nextLesson(): boolean;
|
|
43
|
+
/**
|
|
44
|
+
* Navigate to the previous lesson
|
|
45
|
+
*/
|
|
46
|
+
previousLesson(): boolean;
|
|
47
|
+
/**
|
|
48
|
+
* Go back in history
|
|
49
|
+
*/
|
|
50
|
+
goBack(): boolean;
|
|
51
|
+
/**
|
|
52
|
+
* Get the current lesson
|
|
53
|
+
*/
|
|
54
|
+
getCurrentLesson(): Lesson | null;
|
|
55
|
+
/**
|
|
56
|
+
* Get the current module
|
|
57
|
+
*/
|
|
58
|
+
getCurrentModule(): CourseModule | null;
|
|
59
|
+
/**
|
|
60
|
+
* Get navigation structure for sidebar
|
|
61
|
+
*/
|
|
62
|
+
getNavigation(completedLessons?: string[]): NavigationItem[];
|
|
63
|
+
/**
|
|
64
|
+
* Get lesson progress percentage
|
|
65
|
+
*/
|
|
66
|
+
getProgress(completedLessons: string[]): number;
|
|
67
|
+
/**
|
|
68
|
+
* Check if a lesson is available (prerequisites met)
|
|
69
|
+
*/
|
|
70
|
+
isLessonAvailable(lessonSlug: string, completedLessons: string[]): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Subscribe to router state changes
|
|
73
|
+
*/
|
|
74
|
+
subscribe(listener: (state: RouterState) => void): () => void;
|
|
75
|
+
/**
|
|
76
|
+
* Get current state
|
|
77
|
+
*/
|
|
78
|
+
getState(): RouterState;
|
|
79
|
+
/**
|
|
80
|
+
* Reset router state
|
|
81
|
+
*/
|
|
82
|
+
reset(): void;
|
|
83
|
+
/**
|
|
84
|
+
* Notify all listeners of state change
|
|
85
|
+
*/
|
|
86
|
+
private notifyListeners;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Create router manager instance
|
|
90
|
+
*/
|
|
91
|
+
export declare function createRouterManager(): RouterManager;
|
|
92
|
+
/**
|
|
93
|
+
* Generate URL for a lesson
|
|
94
|
+
*/
|
|
95
|
+
export declare function generateLessonUrl(basePath: string, courseSlug: string, lessonSlug: string): string;
|
|
96
|
+
/**
|
|
97
|
+
* Parse URL to extract course and lesson slugs
|
|
98
|
+
*/
|
|
99
|
+
export declare function parseUrl(path: string): {
|
|
100
|
+
courseSlug?: string;
|
|
101
|
+
lessonSlug?: string;
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* Get lesson order number
|
|
105
|
+
*/
|
|
106
|
+
export declare function getLessonOrder(course: Course, lessonSlug: string): number;
|
|
107
|
+
/**
|
|
108
|
+
* Get total lessons count
|
|
109
|
+
*/
|
|
110
|
+
export declare function getTotalLessons(course: Course): number;
|
|
111
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAE7D;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,QAAQ,GAAG,QAAQ,CAAC;IAC1B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,cAAc,EAAE,CAAC;CAC7B;AAED;;GAEG;AACH,qBAAa,aAAa;IACxB,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,KAAK,CAKX;IACF,OAAO,CAAC,SAAS,CAA2C;IAE5D;;OAEG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAM/B;;OAEG;IACH,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,YAAY,UAAO,GAAG,OAAO;IAiBlE;;OAEG;IACH,UAAU,IAAI,OAAO;IAarB;;OAEG;IACH,cAAc,IA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() {
|
|
6
|
+
Object.defineProperty(this, "course", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
writable: true,
|
|
10
|
+
value: null
|
|
11
|
+
});
|
|
12
|
+
Object.defineProperty(this, "state", {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
configurable: true,
|
|
15
|
+
writable: true,
|
|
16
|
+
value: {
|
|
17
|
+
currentCourse: null,
|
|
18
|
+
currentLesson: null,
|
|
19
|
+
currentModule: null,
|
|
20
|
+
history: [],
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
Object.defineProperty(this, "listeners", {
|
|
24
|
+
enumerable: true,
|
|
25
|
+
configurable: true,
|
|
26
|
+
writable: true,
|
|
27
|
+
value: []
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set the current course
|
|
32
|
+
*/
|
|
33
|
+
setCourse(course) {
|
|
34
|
+
this.course = course;
|
|
35
|
+
this.state.currentCourse = course.id;
|
|
36
|
+
this.notifyListeners();
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Navigate to a lesson
|
|
40
|
+
*/
|
|
41
|
+
navigateToLesson(lessonSlug, addToHistory = true) {
|
|
42
|
+
if (!this.course)
|
|
43
|
+
return false;
|
|
44
|
+
const lesson = this.course.lessons.find((l) => l.slug === lessonSlug);
|
|
45
|
+
if (!lesson)
|
|
46
|
+
return false;
|
|
47
|
+
if (addToHistory && this.state.currentLesson) {
|
|
48
|
+
this.state.history.push(this.state.currentLesson);
|
|
49
|
+
}
|
|
50
|
+
this.state.currentLesson = lessonSlug;
|
|
51
|
+
this.state.currentModule = lesson.moduleId || null;
|
|
52
|
+
this.notifyListeners();
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Navigate to the next lesson
|
|
57
|
+
*/
|
|
58
|
+
nextLesson() {
|
|
59
|
+
if (!this.course || !this.state.currentLesson)
|
|
60
|
+
return false;
|
|
61
|
+
const currentIndex = this.course.lessons.findIndex((l) => l.slug === this.state.currentLesson);
|
|
62
|
+
if (currentIndex === -1 || currentIndex >= this.course.lessons.length - 1) {
|
|
63
|
+
return false;
|
|
64
|
+
}
|
|
65
|
+
const nextLesson = this.course.lessons[currentIndex + 1];
|
|
66
|
+
return this.navigateToLesson(nextLesson.slug);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Navigate to the previous lesson
|
|
70
|
+
*/
|
|
71
|
+
previousLesson() {
|
|
72
|
+
if (!this.course || !this.state.currentLesson)
|
|
73
|
+
return false;
|
|
74
|
+
const currentIndex = this.course.lessons.findIndex((l) => l.slug === this.state.currentLesson);
|
|
75
|
+
if (currentIndex <= 0) {
|
|
76
|
+
return false;
|
|
77
|
+
}
|
|
78
|
+
const prevLesson = this.course.lessons[currentIndex - 1];
|
|
79
|
+
return this.navigateToLesson(prevLesson.slug);
|
|
80
|
+
}
|
|
81
|
+
/**
|
|
82
|
+
* Go back in history
|
|
83
|
+
*/
|
|
84
|
+
goBack() {
|
|
85
|
+
if (this.state.history.length === 0)
|
|
86
|
+
return false;
|
|
87
|
+
const previousLesson = this.state.history.pop();
|
|
88
|
+
if (previousLesson) {
|
|
89
|
+
this.state.currentLesson = previousLesson;
|
|
90
|
+
this.notifyListeners();
|
|
91
|
+
return true;
|
|
92
|
+
}
|
|
93
|
+
return false;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Get the current lesson
|
|
97
|
+
*/
|
|
98
|
+
getCurrentLesson() {
|
|
99
|
+
if (!this.course || !this.state.currentLesson)
|
|
100
|
+
return null;
|
|
101
|
+
return this.course.lessons.find((l) => l.slug === this.state.currentLesson) || null;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Get the current module
|
|
105
|
+
*/
|
|
106
|
+
getCurrentModule() {
|
|
107
|
+
if (!this.course || !this.state.currentModule)
|
|
108
|
+
return null;
|
|
109
|
+
return this.course.modules.find((m) => m.id === this.state.currentModule) || null;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Get navigation structure for sidebar
|
|
113
|
+
*/
|
|
114
|
+
getNavigation(completedLessons = []) {
|
|
115
|
+
if (!this.course)
|
|
116
|
+
return [];
|
|
117
|
+
const items = [];
|
|
118
|
+
for (const module of this.course.modules) {
|
|
119
|
+
const moduleItem = {
|
|
120
|
+
type: 'module',
|
|
121
|
+
id: module.id,
|
|
122
|
+
title: typeof module.title === 'string' ? module.title : Object.values(module.title)[0],
|
|
123
|
+
children: [],
|
|
124
|
+
};
|
|
125
|
+
for (const lessonSlug of module.lessons) {
|
|
126
|
+
const lesson = this.course.lessons.find((l) => l.slug === lessonSlug);
|
|
127
|
+
if (lesson) {
|
|
128
|
+
const title = typeof lesson.frontmatter.title === 'string'
|
|
129
|
+
? lesson.frontmatter.title
|
|
130
|
+
: Object.values(lesson.frontmatter.title)[0];
|
|
131
|
+
moduleItem.children.push({
|
|
132
|
+
type: 'lesson',
|
|
133
|
+
id: lesson.slug,
|
|
134
|
+
title,
|
|
135
|
+
slug: lesson.slug,
|
|
136
|
+
moduleId: module.id,
|
|
137
|
+
completed: completedLessons.includes(lessonSlug),
|
|
138
|
+
active: this.state.currentLesson === lessonSlug,
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
items.push(moduleItem);
|
|
143
|
+
}
|
|
144
|
+
// Add lessons without modules
|
|
145
|
+
const lessonsWithoutModule = this.course.lessons.filter((l) => !l.moduleId || !this.course?.modules.some((m) => m.id === l.moduleId));
|
|
146
|
+
if (lessonsWithoutModule.length > 0) {
|
|
147
|
+
const otherItem = {
|
|
148
|
+
type: 'module',
|
|
149
|
+
id: 'other',
|
|
150
|
+
title: 'Other Lessons',
|
|
151
|
+
children: lessonsWithoutModule.map((lesson) => ({
|
|
152
|
+
type: 'lesson',
|
|
153
|
+
id: lesson.slug,
|
|
154
|
+
title: typeof lesson.frontmatter.title === 'string'
|
|
155
|
+
? lesson.frontmatter.title
|
|
156
|
+
: Object.values(lesson.frontmatter.title)[0],
|
|
157
|
+
slug: lesson.slug,
|
|
158
|
+
completed: completedLessons.includes(lesson.slug),
|
|
159
|
+
active: this.state.currentLesson === lesson.slug,
|
|
160
|
+
})),
|
|
161
|
+
};
|
|
162
|
+
items.push(otherItem);
|
|
163
|
+
}
|
|
164
|
+
return items;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Get lesson progress percentage
|
|
168
|
+
*/
|
|
169
|
+
getProgress(completedLessons) {
|
|
170
|
+
if (!this.course || this.course.lessons.length === 0)
|
|
171
|
+
return 0;
|
|
172
|
+
return (completedLessons.length / this.course.lessons.length) * 100;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Check if a lesson is available (prerequisites met)
|
|
176
|
+
*/
|
|
177
|
+
isLessonAvailable(lessonSlug, completedLessons) {
|
|
178
|
+
if (!this.course)
|
|
179
|
+
return false;
|
|
180
|
+
const lesson = this.course.lessons.find((l) => l.slug === lessonSlug);
|
|
181
|
+
if (!lesson)
|
|
182
|
+
return false;
|
|
183
|
+
// First lesson is always available
|
|
184
|
+
const lessonIndex = this.course.lessons.findIndex((l) => l.slug === lessonSlug);
|
|
185
|
+
if (lessonIndex === 0)
|
|
186
|
+
return true;
|
|
187
|
+
// Check if previous lesson is completed
|
|
188
|
+
const previousLesson = this.course.lessons[lessonIndex - 1];
|
|
189
|
+
if (previousLesson) {
|
|
190
|
+
return completedLessons.includes(previousLesson.slug);
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
/**
|
|
195
|
+
* Subscribe to router state changes
|
|
196
|
+
*/
|
|
197
|
+
subscribe(listener) {
|
|
198
|
+
this.listeners.push(listener);
|
|
199
|
+
return () => {
|
|
200
|
+
this.listeners = this.listeners.filter((l) => l !== listener);
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Get current state
|
|
205
|
+
*/
|
|
206
|
+
getState() {
|
|
207
|
+
return { ...this.state };
|
|
208
|
+
}
|
|
209
|
+
/**
|
|
210
|
+
* Reset router state
|
|
211
|
+
*/
|
|
212
|
+
reset() {
|
|
213
|
+
this.state = {
|
|
214
|
+
currentCourse: null,
|
|
215
|
+
currentLesson: null,
|
|
216
|
+
currentModule: null,
|
|
217
|
+
history: [],
|
|
218
|
+
};
|
|
219
|
+
this.notifyListeners();
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Notify all listeners of state change
|
|
223
|
+
*/
|
|
224
|
+
notifyListeners() {
|
|
225
|
+
for (const listener of this.listeners) {
|
|
226
|
+
listener({ ...this.state });
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Create router manager instance
|
|
232
|
+
*/
|
|
233
|
+
export function createRouterManager() {
|
|
234
|
+
return new RouterManager();
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Generate URL for a lesson
|
|
238
|
+
*/
|
|
239
|
+
export function generateLessonUrl(basePath, courseSlug, lessonSlug) {
|
|
240
|
+
return `${basePath}/courses/${courseSlug}/${lessonSlug}`;
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Parse URL to extract course and lesson slugs
|
|
244
|
+
*/
|
|
245
|
+
export function parseUrl(path) {
|
|
246
|
+
const match = path.match(/\/courses\/([^/]+)\/([^/]+)/);
|
|
247
|
+
if (match) {
|
|
248
|
+
return {
|
|
249
|
+
courseSlug: match[1],
|
|
250
|
+
lessonSlug: match[2],
|
|
251
|
+
};
|
|
252
|
+
}
|
|
253
|
+
return {};
|
|
254
|
+
}
|
|
255
|
+
/**
|
|
256
|
+
* Get lesson order number
|
|
257
|
+
*/
|
|
258
|
+
export function getLessonOrder(course, lessonSlug) {
|
|
259
|
+
const index = course.lessons.findIndex((l) => l.slug === lessonSlug);
|
|
260
|
+
return index + 1;
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* Get total lessons count
|
|
264
|
+
*/
|
|
265
|
+
export function getTotalLessons(course) {
|
|
266
|
+
return course.lessons.length;
|
|
267
|
+
}
|
|
268
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/router/index.ts"],"names":[],"mappings":"AA0BA;;GAEG;AACH,MAAM,OAAO,aAAa;IAA1B;QACU;;;;mBAAwB,IAAI;WAAC;QAC7B;;;;mBAAqB;gBAC3B,aAAa,EAAE,IAAI;gBACnB,aAAa,EAAE,IAAI;gBACnB,aAAa,EAAE,IAAI;gBACnB,OAAO,EAAE,EAAE;aACZ;WAAC;QACM;;;;mBAAiD,EAAE;WAAC;IAsO9D,CAAC;IApOC;;OAEG;IACH,SAAS,CAAC,MAAc;QACtB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,MAAM,CAAC,EAAE,CAAC;QACrC,IAAI,CAAC,eAAe,EAAE,CAAC;IACzB,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,UAAkB,EAAE,YAAY,GAAG,IAAI;QACtD,IAAI,CAAC,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAE/B,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,UAAU,CAAC,CAAC;QACtE,IAAI,CAAC,MAAM;YAAE,OAAO,KAAK,CAAC;QAE1B,IAAI,YAAY,IAAI,IAAI,CAAC,KAAK,CAAC,aAAa,EAAE,CAAC;YAC7C,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC;QACpD,CAAC;QAED,IAAI,CAAC,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;QACtC,IAAI,CAAC,KAAK,CAAC,a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;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,MAAc;IAC5C,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC;AAC/B,CAAC"}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
import type { StorageAdapter, CourseProgress, UserProfile, LessonProgress } from '../types';
|
|
2
|
+
/**
|
|
3
|
+
* LocalStorage adapter for simple key-value storage
|
|
4
|
+
*/
|
|
5
|
+
export declare class LocalStorageAdapter implements StorageAdapter {
|
|
6
|
+
private prefix;
|
|
7
|
+
constructor(prefix?: string);
|
|
8
|
+
private getKey;
|
|
9
|
+
get<T>(key: string): Promise<T | null>;
|
|
10
|
+
set<T>(key: string, value: T): Promise<void>;
|
|
11
|
+
remove(key: string): Promise<void>;
|
|
12
|
+
clear(): Promise<void>;
|
|
13
|
+
keys(): Promise<string[]>;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* IndexedDB adapter for larger data storage (offline content)
|
|
17
|
+
*/
|
|
18
|
+
export declare class IndexedDBAdapter implements StorageAdapter {
|
|
19
|
+
private dbName;
|
|
20
|
+
private dbVersion;
|
|
21
|
+
private db;
|
|
22
|
+
constructor(dbName?: string, dbVersion?: number);
|
|
23
|
+
private getDB;
|
|
24
|
+
get<T>(key: string, storeName?: string): Promise<T | null>;
|
|
25
|
+
set<T>(key: string, value: T, storeName?: string): Promise<void>;
|
|
26
|
+
remove(key: string, storeName?: string): Promise<void>;
|
|
27
|
+
clear(storeName?: string): Promise<void>;
|
|
28
|
+
keys(storeName?: string): Promise<string[]>;
|
|
29
|
+
/**
|
|
30
|
+
* Cache course content for offline use
|
|
31
|
+
*/
|
|
32
|
+
cacheCourse(courseId: string, content: unknown): Promise<void>;
|
|
33
|
+
/**
|
|
34
|
+
* Get cached course content
|
|
35
|
+
*/
|
|
36
|
+
getCachedCourse(courseId: string): Promise<unknown | null>;
|
|
37
|
+
/**
|
|
38
|
+
* Clear cache older than specified milliseconds
|
|
39
|
+
*/
|
|
40
|
+
clearOldCache(maxAge: number): Promise<void>;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Combined storage manager using both LocalStorage and IndexedDB
|
|
44
|
+
*/
|
|
45
|
+
export declare class StorageManager {
|
|
46
|
+
private readonly localStorage;
|
|
47
|
+
private readonly _indexedDB;
|
|
48
|
+
constructor();
|
|
49
|
+
/**
|
|
50
|
+
* Get the IndexedDB adapter for advanced operations
|
|
51
|
+
*/
|
|
52
|
+
get indexedDB(): IndexedDBAdapter;
|
|
53
|
+
/**
|
|
54
|
+
* Get user profile
|
|
55
|
+
*/
|
|
56
|
+
getUserProfile(): Promise<UserProfile | null>;
|
|
57
|
+
/**
|
|
58
|
+
* Save user profile
|
|
59
|
+
*/
|
|
60
|
+
saveUserProfile(profile: UserProfile): Promise<void>;
|
|
61
|
+
/**
|
|
62
|
+
* Get course progress
|
|
63
|
+
*/
|
|
64
|
+
getCourseProgress(courseId: string): Promise<CourseProgress | null>;
|
|
65
|
+
/**
|
|
66
|
+
* Save course progress
|
|
67
|
+
*/
|
|
68
|
+
saveCourseProgress(progress: CourseProgress): Promise<void>;
|
|
69
|
+
/**
|
|
70
|
+
* Get lesson progress
|
|
71
|
+
*/
|
|
72
|
+
getLessonProgress(courseId: string, lessonSlug: string): Promise<LessonProgress | null>;
|
|
73
|
+
/**
|
|
74
|
+
* Update lesson progress
|
|
75
|
+
*/
|
|
76
|
+
updateLessonProgress(courseId: string, lessonSlug: string, progress: Partial<LessonProgress>): Promise<void>;
|
|
77
|
+
/**
|
|
78
|
+
* Mark lesson as completed
|
|
79
|
+
*/
|
|
80
|
+
completeLesson(courseId: string, lessonSlug: string, quizScore?: number, quizPassed?: boolean): Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* Track time spent on lesson
|
|
83
|
+
*/
|
|
84
|
+
trackTimeSpent(courseId: string, lessonSlug: string, seconds: number): Promise<void>;
|
|
85
|
+
/**
|
|
86
|
+
* Get all course progress
|
|
87
|
+
*/
|
|
88
|
+
getAllCourseProgress(): Promise<Record<string, CourseProgress>>;
|
|
89
|
+
/**
|
|
90
|
+
* Reset course progress
|
|
91
|
+
*/
|
|
92
|
+
resetCourseProgress(courseId: string): Promise<void>;
|
|
93
|
+
/**
|
|
94
|
+
* Clear all progress data
|
|
95
|
+
*/
|
|
96
|
+
clearAllProgress(): Promise<void>;
|
|
97
|
+
/**
|
|
98
|
+
* Export all data
|
|
99
|
+
*/
|
|
100
|
+
exportData(): Promise<Record<string, unknown>>;
|
|
101
|
+
/**
|
|
102
|
+
* Import data
|
|
103
|
+
*/
|
|
104
|
+
importData(data: Record<string, unknown>): Promise<void>;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Create storage manager instance
|
|
108
|
+
*/
|
|
109
|
+
export declare function createStorageManager(): StorageManager;
|
|
110
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/storage/index.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAE5F;;GAEG;AACH,qBAAa,mBAAoB,YAAW,cAAc;IACxD,OAAO,CAAC,MAAM,CAAS;gBAEX,MAAM,SAAY;IAI9B,OAAO,CAAC,MAAM;IAIR,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,GAAG,IAAI,CAAC;IAWtC,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;IAS5C,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;IAStB,IAAI,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;CAUhC;AAED;;GAEG;AACH,qBAAa,g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