chuvsu-js 5.4.0 → 5.5.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.
Files changed (76) hide show
  1. package/README.md +32 -3
  2. package/dist/common/http.d.ts +3 -1
  3. package/dist/common/http.js +9 -2
  4. package/dist/{tt/utils → common}/lesson-type.d.ts +4 -2
  5. package/dist/{tt/utils → common}/lesson-type.js +17 -2
  6. package/dist/core.d.ts +13 -5
  7. package/dist/core.js +7 -2
  8. package/dist/index.d.ts +1 -0
  9. package/dist/index.js +1 -0
  10. package/dist/lk/client.d.ts +23 -1
  11. package/dist/lk/client.js +95 -0
  12. package/dist/lk/parse/grade-value.d.ts +4 -0
  13. package/dist/lk/parse/grade-value.js +16 -0
  14. package/dist/lk/parse/portfolio-content.d.ts +10 -0
  15. package/dist/lk/parse/portfolio-content.js +116 -0
  16. package/dist/lk/parse/portfolio-grades.d.ts +8 -0
  17. package/dist/lk/parse/portfolio-grades.js +41 -0
  18. package/dist/lk/parse/portfolio-performance.d.ts +2 -0
  19. package/dist/lk/parse/portfolio-performance.js +44 -0
  20. package/dist/lk/parse/portfolio.d.ts +6 -0
  21. package/dist/lk/parse/portfolio.js +64 -0
  22. package/dist/lk/parse/webinar-lesson.d.ts +7 -0
  23. package/dist/lk/parse/webinar-lesson.js +28 -0
  24. package/dist/lk/parse/webinars.d.ts +3 -0
  25. package/dist/lk/parse/webinars.js +67 -0
  26. package/dist/lk/portfolio-types.d.ts +113 -0
  27. package/dist/lk/portfolio-types.js +1 -0
  28. package/dist/lk/types.d.ts +29 -0
  29. package/dist/{tt → lk}/webinars.d.ts +3 -1
  30. package/dist/lk/webinars.js +52 -0
  31. package/dist/parsers.d.ts +3 -1
  32. package/dist/parsers.js +3 -1
  33. package/dist/tt/client.d.ts +1 -11
  34. package/dist/tt/client.js +1 -45
  35. package/dist/tt/domain/schedule.js +5 -1
  36. package/dist/tt/domain/substitution-occurrences.d.ts +3 -0
  37. package/dist/tt/domain/substitution-occurrences.js +75 -0
  38. package/dist/tt/domain/types.d.ts +1 -1
  39. package/dist/tt/observations.js +2 -1
  40. package/dist/tt/parse/index.d.ts +0 -1
  41. package/dist/tt/parse/index.js +0 -1
  42. package/dist/tt/types.d.ts +0 -21
  43. package/dist/tt/utils/index.d.ts +0 -1
  44. package/dist/tt/utils/index.js +0 -1
  45. package/dist/webinar/client.d.ts +52 -0
  46. package/dist/webinar/client.js +184 -0
  47. package/dist/webinar/ddp.d.ts +31 -0
  48. package/dist/webinar/ddp.js +208 -0
  49. package/dist/webinar/events.d.ts +6 -0
  50. package/dist/webinar/events.js +38 -0
  51. package/dist/webinar/gateway.d.ts +30 -0
  52. package/dist/webinar/gateway.js +114 -0
  53. package/dist/webinar/media-protocol.d.ts +9 -0
  54. package/dist/webinar/media-protocol.js +24 -0
  55. package/dist/webinar/media-types.d.ts +10 -0
  56. package/dist/webinar/media-types.js +1 -0
  57. package/dist/webinar/media.d.ts +21 -0
  58. package/dist/webinar/media.js +76 -0
  59. package/dist/webinar/parse.d.ts +14 -0
  60. package/dist/webinar/parse.js +113 -0
  61. package/dist/webinar/playback.d.ts +32 -0
  62. package/dist/webinar/playback.js +188 -0
  63. package/dist/webinar/socket.d.ts +3 -0
  64. package/dist/webinar/socket.js +18 -0
  65. package/dist/webinar/state.d.ts +4 -0
  66. package/dist/webinar/state.js +98 -0
  67. package/dist/webinar/types.d.ts +148 -0
  68. package/dist/webinar/types.js +12 -0
  69. package/docs/student-portal.md +151 -0
  70. package/docs/testing.md +13 -0
  71. package/docs/v5-migration.md +25 -2
  72. package/docs/webinar.md +145 -0
  73. package/package.json +2 -2
  74. package/dist/tt/parse/webinars.d.ts +0 -2
  75. package/dist/tt/parse/webinars.js +0 -97
  76. package/dist/tt/webinars.js +0 -39
@@ -1,97 +0,0 @@
1
- import { parseHtml, parseTeacher, parseTime, text, } from "../../common/parse.js";
2
- import { parseGroupsString } from "./groups.js";
3
- import { FLEXIBLE_LESSON_TYPE_RE_I, SUBGROUP_RE } from "./patterns.js";
4
- const GROUP_CODE_RE = /[A-ZА-ЯЁ]{1,}(?:-[A-ZА-ЯЁa-zа-яё0-9]+)+(?:\s*ин)?/u;
5
- function parseDateValue(value) {
6
- const match = value?.match(/^(\d{4})-(\d{2})-(\d{2})$/);
7
- if (!match)
8
- return undefined;
9
- return `${match[1]}-${match[2]}-${match[3]}`;
10
- }
11
- function parseTimeRange(raw) {
12
- const match = raw.match(/(\d{2}:\d{2})\s*-\s*(\d{2}:\d{2})/);
13
- if (!match)
14
- return null;
15
- return { start: parseTime(match[1]), end: parseTime(match[2]) };
16
- }
17
- function splitLesson(raw) {
18
- const typeMatches = [...raw.matchAll(new RegExp(FLEXIBLE_LESSON_TYPE_RE_I, "gi"))];
19
- const typeMatch = typeMatches.at(-1);
20
- if (!typeMatch || typeMatch.index == null) {
21
- return {
22
- subject: raw,
23
- type: "",
24
- teacherRaw: "",
25
- groupsRaw: "",
26
- };
27
- }
28
- const subject = raw.slice(0, typeMatch.index).trim();
29
- const type = typeMatch[1].replace(/\.$/, "").toLowerCase();
30
- const rest = raw.slice(typeMatch.index + typeMatch[0].length).trim();
31
- const groupMatch = rest.match(GROUP_CODE_RE);
32
- const teacherRaw = groupMatch?.index == null ? rest : rest.slice(0, groupMatch.index).trim();
33
- const groupsRaw = groupMatch?.index == null ? "" : rest.slice(groupMatch.index).trim();
34
- const subgroupMatch = raw.match(SUBGROUP_RE);
35
- return {
36
- subject,
37
- type,
38
- teacherRaw,
39
- groupsRaw,
40
- subgroup: subgroupMatch ? parseInt(subgroupMatch[1]) : undefined,
41
- };
42
- }
43
- function parseWebinarRows(doc, tableSelector, scheduled, fallbackDate) {
44
- const webinars = [];
45
- for (const slotRow of doc.querySelectorAll(`${tableSelector} > tbody > tr`)) {
46
- const slotCells = [...slotRow.children].filter((child) => child.tagName.toLowerCase() === "td");
47
- const timeCell = slotCells[0];
48
- const dataCell = slotCells[1];
49
- if (!timeCell || !dataCell)
50
- continue;
51
- const timeText = text(timeCell);
52
- const timeRange = parseTimeRange(timeText);
53
- if (!timeRange)
54
- continue;
55
- const id = timeCell.querySelector("div")?.getAttribute("id") ?? "";
56
- const idMatch = id.match(/trd(\d{4}-\d{2}-\d{2})t(\d+)/);
57
- const date = parseDateValue(idMatch?.[1]) ?? fallbackDate;
58
- const slotNumber = idMatch ? parseInt(idMatch[2]) : undefined;
59
- for (const row of dataCell.querySelectorAll("table tr")) {
60
- const cells = [...row.children].filter((child) => child.tagName.toLowerCase() === "td");
61
- const lessonCell = cells[0];
62
- const titleCell = cells[1];
63
- if (!lessonCell || !titleCell)
64
- continue;
65
- const button = row.querySelector("button[onclick*=\"jointo\"]");
66
- const onclick = button?.getAttribute("onclick") ?? "";
67
- const joinMatch = onclick.match(/jointo(?:sub)?\('([^']+)',\s*(\d+)\)/);
68
- const raw = text(lessonCell);
69
- const parsed = splitLesson(raw);
70
- webinars.push({
71
- id: joinMatch?.[1] ?? "",
72
- idType: joinMatch ? parseInt(joinMatch[2]) : 1,
73
- scheduled,
74
- scheduledDate: date,
75
- slotNumber,
76
- time: timeRange,
77
- subject: parsed.subject,
78
- type: parsed.type,
79
- teacher: parseTeacher(parsed.teacherRaw),
80
- groups: parseGroupsString(parsed.groupsRaw),
81
- subgroup: parsed.subgroup,
82
- title: text(titleCell),
83
- raw,
84
- });
85
- }
86
- }
87
- return webinars;
88
- }
89
- export function parseWebinars(html) {
90
- const doc = parseHtml(html);
91
- const selectedDate = doc.querySelector('select[name="seldate"] option[selected]')?.getAttribute("value");
92
- const fallbackDate = parseDateValue(selectedDate);
93
- return [
94
- ...parseWebinarRows(doc, "#webstt", true, fallbackDate),
95
- ...parseWebinarRows(doc, "#websttext", false, fallbackDate),
96
- ];
97
- }
@@ -1,39 +0,0 @@
1
- import { LessonType, parseLessonType } from "./utils/lesson-type.js";
2
- function normalize(value) {
3
- return value
4
- .toLocaleLowerCase("ru-RU")
5
- .replace(/ё/gu, "е")
6
- .replace(/\s+/gu, " ")
7
- .trim();
8
- }
9
- export function findWebinar(lesson, webinars) {
10
- return webinars.find((webinar) => {
11
- if (!webinar.scheduled)
12
- return false;
13
- if (webinar.scheduledDate &&
14
- webinar.scheduledDate !== lesson.scheduledDate)
15
- return false;
16
- if (webinar.slotNumber != null &&
17
- webinar.slotNumber !== lesson.slotNumber) {
18
- return false;
19
- }
20
- if (!lesson.time ||
21
- webinar.time.start.hours !== lesson.time.start.hours ||
22
- webinar.time.start.minutes !== lesson.time.start.minutes ||
23
- webinar.time.end.hours !== lesson.time.end.hours ||
24
- webinar.time.end.minutes !== lesson.time.end.minutes) {
25
- return false;
26
- }
27
- if (normalize(webinar.subject) !== normalize(lesson.subject))
28
- return false;
29
- if (webinar.type && lesson.type !== LessonType.Unknown && parseLessonType(webinar.type) !== lesson.type)
30
- return false;
31
- return true;
32
- });
33
- }
34
- export function attachWebinars(lessons, webinars) {
35
- return lessons.map((lesson) => {
36
- const webinar = findWebinar(lesson, webinars);
37
- return webinar ? { ...lesson, webinar } : lesson;
38
- });
39
- }