@learnpack/learnpack 5.0.262 → 5.0.266
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/lib/commands/serve.js +137 -75
- package/lib/commands/translate.js +1 -2
- package/lib/creatorDist/assets/{index-6e9E-1qG.js → index-BXp9oelr.js} +2681 -2672
- package/lib/creatorDist/index.html +1 -1
- package/lib/managers/server/routes.js +1 -2
- package/lib/utils/rigoActions.d.ts +6 -3
- package/lib/utils/rigoActions.js +15 -4
- package/package.json +1 -1
- package/src/commands/serve.ts +174 -95
- package/src/commands/translate.ts +8 -5
- package/src/creator/src/components/Message.tsx +6 -1
- package/src/creator/src/components/syllabus/ContentIndex.tsx +1 -1
- package/src/creator/src/components/syllabus/Sidebar.tsx +1 -1
- package/src/creator/src/locales/en.json +4 -2
- package/src/creator/src/locales/es.json +4 -2
- package/src/creator/src/utils/rigo.ts +2 -0
- package/src/creatorDist/assets/{index-6e9E-1qG.js → index-BXp9oelr.js} +2681 -2672
- package/src/creatorDist/index.html +1 -1
- package/src/managers/server/routes.ts +9 -7
- package/src/ui/_app/app.css +1 -1
- package/src/ui/_app/app.js +398 -384
- package/src/ui/_app/sw.js +9 -4
- package/src/ui/app.tar.gz +0 -0
- package/src/utils/creatorSocket.ts +99 -99
- package/src/utils/rigoActions.ts +27 -5
package/src/ui/_app/sw.js
CHANGED
@@ -20,11 +20,16 @@ self.addEventListener('install', (event) => {
|
|
20
20
|
);
|
21
21
|
});
|
22
22
|
|
23
|
-
|
24
23
|
self.addEventListener('fetch', (event) => {
|
24
|
+
// Excluir solicitudes a /socket.io/
|
25
|
+
if (event.request.url.includes('/socket.io/')) {
|
26
|
+
// No interceptar, que siga el flujo normal
|
27
|
+
return;
|
28
|
+
}
|
29
|
+
|
25
30
|
event.respondWith(
|
26
31
|
caches.match(event.request).then((response) => {
|
27
|
-
return response || fetch(event.request)
|
32
|
+
return response || fetch(event.request);
|
28
33
|
})
|
29
|
-
)
|
30
|
-
})
|
34
|
+
);
|
35
|
+
});
|
package/src/ui/app.tar.gz
CHANGED
Binary file
|
@@ -1,99 +1,99 @@
|
|
1
|
-
import { Server as SocketIOServer, Socket } from "socket.io"
|
2
|
-
|
3
|
-
const courseSocketMap = new Map<string, Set<string>>() // slug -> Set<socket.id>
|
4
|
-
|
5
|
-
const notificationSocketMap = new Map<string, Set<string>>() // notificationId -> Set<socket.id>
|
6
|
-
const socketStore = new Map<string, Socket>() // socket.id -> socket
|
7
|
-
|
8
|
-
let io: SocketIOServer | null = null
|
9
|
-
|
10
|
-
export function initSocketIO(server: any) {
|
11
|
-
io = new SocketIOServer(server, {
|
12
|
-
cors: {
|
13
|
-
origin: "*",
|
14
|
-
methods: ["GET", "POST"],
|
15
|
-
},
|
16
|
-
path: "/sockete",
|
17
|
-
})
|
18
|
-
|
19
|
-
io.on("connection", socket => {
|
20
|
-
console.log("🧠 Socket connected:", socket.id)
|
21
|
-
socketStore.set(socket.id, socket)
|
22
|
-
|
23
|
-
socket.on("register", (data: { courseSlug: string }) => {
|
24
|
-
const { courseSlug } = data
|
25
|
-
if (!courseSlug) return
|
26
|
-
|
27
|
-
if (!courseSocketMap.has(courseSlug)) {
|
28
|
-
courseSocketMap.set(courseSlug, new Set())
|
29
|
-
}
|
30
|
-
|
31
|
-
courseSocketMap.get(courseSlug)?.add(socket.id)
|
32
|
-
console.log(`📦 Socket ${socket.id} registered to course: ${courseSlug}`)
|
33
|
-
})
|
34
|
-
|
35
|
-
socket.on("registerNotification", (data: { notificationId: string }) => {
|
36
|
-
const { notificationId } = data
|
37
|
-
if (!notificationId) return
|
38
|
-
|
39
|
-
if (!notificationSocketMap.has(notificationId)) {
|
40
|
-
notificationSocketMap.set(notificationId, new Set())
|
41
|
-
}
|
42
|
-
|
43
|
-
notificationSocketMap.get(notificationId)?.add(socket.id)
|
44
|
-
console.log(
|
45
|
-
`📧 Socket ${socket.id} registered to notification: ${notificationId}`
|
46
|
-
)
|
47
|
-
})
|
48
|
-
|
49
|
-
socket.on("disconnect", () => {
|
50
|
-
console.log("🔥 Socket disconnected:", socket.id)
|
51
|
-
socketStore.delete(socket.id)
|
52
|
-
|
53
|
-
for (const set of courseSocketMap.values()) {
|
54
|
-
set.delete(socket.id)
|
55
|
-
}
|
56
|
-
})
|
57
|
-
})
|
58
|
-
|
59
|
-
return io
|
60
|
-
}
|
61
|
-
|
62
|
-
export function emitToCourse(courseSlug: string, event: string, payload: any) {
|
63
|
-
const socketIds = courseSocketMap.get(courseSlug)
|
64
|
-
if (!socketIds || socketIds.size === 0) return
|
65
|
-
|
66
|
-
for (const id of socketIds) {
|
67
|
-
const socket = socketStore.get(id)
|
68
|
-
if (socket) socket.emit(event, payload)
|
69
|
-
}
|
70
|
-
}
|
71
|
-
|
72
|
-
export function emitToNotification(
|
73
|
-
notificationId: string,
|
74
|
-
payload: any,
|
75
|
-
retry = 0
|
76
|
-
) {
|
77
|
-
const socketIds = notificationSocketMap.get(notificationId)
|
78
|
-
if (!socketIds || socketIds.size === 0) {
|
79
|
-
if (retry > 3) {
|
80
|
-
console.log("❌ Notification", notificationId, "not found")
|
81
|
-
return
|
82
|
-
}
|
83
|
-
|
84
|
-
setTimeout(() => {
|
85
|
-
emitToNotification(notificationId, payload, retry + 1)
|
86
|
-
}, 3000)
|
87
|
-
return
|
88
|
-
}
|
89
|
-
|
90
|
-
for (const id of socketIds) {
|
91
|
-
const socket = socketStore.get(id)
|
92
|
-
if (socket) socket.emit(notificationId, payload)
|
93
|
-
}
|
94
|
-
}
|
95
|
-
|
96
|
-
export function getSocketIO() {
|
97
|
-
if (!io) throw new Error("Socket.IO not initialized")
|
98
|
-
return io
|
99
|
-
}
|
1
|
+
import { Server as SocketIOServer, Socket } from "socket.io"
|
2
|
+
|
3
|
+
const courseSocketMap = new Map<string, Set<string>>() // slug -> Set<socket.id>
|
4
|
+
|
5
|
+
const notificationSocketMap = new Map<string, Set<string>>() // notificationId -> Set<socket.id>
|
6
|
+
const socketStore = new Map<string, Socket>() // socket.id -> socket
|
7
|
+
|
8
|
+
let io: SocketIOServer | null = null
|
9
|
+
|
10
|
+
export function initSocketIO(server: any) {
|
11
|
+
io = new SocketIOServer(server, {
|
12
|
+
cors: {
|
13
|
+
origin: "*",
|
14
|
+
methods: ["GET", "POST"],
|
15
|
+
},
|
16
|
+
path: "/sockete",
|
17
|
+
})
|
18
|
+
|
19
|
+
io.on("connection", socket => {
|
20
|
+
console.log("🧠 Socket connected:", socket.id)
|
21
|
+
socketStore.set(socket.id, socket)
|
22
|
+
|
23
|
+
socket.on("register", (data: { courseSlug: string }) => {
|
24
|
+
const { courseSlug } = data
|
25
|
+
if (!courseSlug) return
|
26
|
+
|
27
|
+
if (!courseSocketMap.has(courseSlug)) {
|
28
|
+
courseSocketMap.set(courseSlug, new Set())
|
29
|
+
}
|
30
|
+
|
31
|
+
courseSocketMap.get(courseSlug)?.add(socket.id)
|
32
|
+
console.log(`📦 Socket ${socket.id} registered to course: ${courseSlug}`)
|
33
|
+
})
|
34
|
+
|
35
|
+
socket.on("registerNotification", (data: { notificationId: string }) => {
|
36
|
+
const { notificationId } = data
|
37
|
+
if (!notificationId) return
|
38
|
+
|
39
|
+
if (!notificationSocketMap.has(notificationId)) {
|
40
|
+
notificationSocketMap.set(notificationId, new Set())
|
41
|
+
}
|
42
|
+
|
43
|
+
notificationSocketMap.get(notificationId)?.add(socket.id)
|
44
|
+
console.log(
|
45
|
+
`📧 Socket ${socket.id} registered to notification: ${notificationId}`
|
46
|
+
)
|
47
|
+
})
|
48
|
+
|
49
|
+
socket.on("disconnect", () => {
|
50
|
+
console.log("🔥 Socket disconnected:", socket.id)
|
51
|
+
socketStore.delete(socket.id)
|
52
|
+
|
53
|
+
for (const set of courseSocketMap.values()) {
|
54
|
+
set.delete(socket.id)
|
55
|
+
}
|
56
|
+
})
|
57
|
+
})
|
58
|
+
|
59
|
+
return io
|
60
|
+
}
|
61
|
+
|
62
|
+
export function emitToCourse(courseSlug: string, event: string, payload: any) {
|
63
|
+
const socketIds = courseSocketMap.get(courseSlug)
|
64
|
+
if (!socketIds || socketIds.size === 0) return
|
65
|
+
|
66
|
+
for (const id of socketIds) {
|
67
|
+
const socket = socketStore.get(id)
|
68
|
+
if (socket) socket.emit(event, payload)
|
69
|
+
}
|
70
|
+
}
|
71
|
+
|
72
|
+
export function emitToNotification(
|
73
|
+
notificationId: string,
|
74
|
+
payload: any,
|
75
|
+
retry = 0
|
76
|
+
) {
|
77
|
+
const socketIds = notificationSocketMap.get(notificationId)
|
78
|
+
if (!socketIds || socketIds.size === 0) {
|
79
|
+
if (retry > 3) {
|
80
|
+
console.log("❌ Notification", notificationId, "not found")
|
81
|
+
return
|
82
|
+
}
|
83
|
+
|
84
|
+
setTimeout(() => {
|
85
|
+
emitToNotification(notificationId, payload, retry + 1)
|
86
|
+
}, 3000)
|
87
|
+
return
|
88
|
+
}
|
89
|
+
|
90
|
+
for (const id of socketIds) {
|
91
|
+
const socket = socketStore.get(id)
|
92
|
+
if (socket) socket.emit(notificationId, payload)
|
93
|
+
}
|
94
|
+
}
|
95
|
+
|
96
|
+
export function getSocketIO() {
|
97
|
+
if (!io) throw new Error("Socket.IO not initialized")
|
98
|
+
return io
|
99
|
+
}
|
package/src/utils/rigoActions.ts
CHANGED
@@ -117,18 +117,19 @@ export async function downloadImage(
|
|
117
117
|
type TTranslateInputs = {
|
118
118
|
text_to_translate: string
|
119
119
|
output_language: string
|
120
|
-
exercise_slug: string
|
121
120
|
}
|
122
121
|
export const translateExercise = async (
|
123
122
|
token: string,
|
124
|
-
inputs: TTranslateInputs
|
123
|
+
inputs: TTranslateInputs,
|
124
|
+
webhookUrl: string
|
125
125
|
) => {
|
126
126
|
const response = await axios.post(
|
127
|
-
`${RIGOBOT_HOST}/v1/prompting/completion/
|
127
|
+
`${RIGOBOT_HOST}/v1/prompting/completion/translate-asset-markdown/`,
|
128
128
|
{
|
129
129
|
inputs: inputs,
|
130
130
|
include_purpose_objective: false,
|
131
|
-
execute_async:
|
131
|
+
execute_async: true,
|
132
|
+
webhook_url: webhookUrl,
|
132
133
|
},
|
133
134
|
{
|
134
135
|
headers: {
|
@@ -335,7 +336,7 @@ export const translateCourseMetadata = async (
|
|
335
336
|
inputs: {
|
336
337
|
title: string
|
337
338
|
description: string
|
338
|
-
|
339
|
+
new_languages: string
|
339
340
|
}
|
340
341
|
) => {
|
341
342
|
const response = await axios.post(
|
@@ -476,3 +477,24 @@ export const isPackageAuthor = async (
|
|
476
477
|
return { isAuthor: false, status }
|
477
478
|
}
|
478
479
|
}
|
480
|
+
|
481
|
+
type TGetLanguageCodesInputs = {
|
482
|
+
raw_languages: string
|
483
|
+
}
|
484
|
+
export const getLanguageCodes = async (
|
485
|
+
token: string,
|
486
|
+
inputs: TGetLanguageCodesInputs
|
487
|
+
) => {
|
488
|
+
const response = await axios.post(
|
489
|
+
`${RIGOBOT_HOST}/v1/prompting/completion/get-language-codes/`,
|
490
|
+
{ inputs, include_purpose_objective: false, execute_async: false },
|
491
|
+
{
|
492
|
+
headers: {
|
493
|
+
"Content-Type": "application/json",
|
494
|
+
Authorization: "Token " + token,
|
495
|
+
},
|
496
|
+
}
|
497
|
+
)
|
498
|
+
|
499
|
+
return response.data
|
500
|
+
}
|