@learnpack/learnpack 5.0.265 → 5.0.267
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/publish.js +1 -1
- package/lib/commands/serve.js +55 -25
- package/lib/creatorDist/assets/{index-6e9E-1qG.js → index-BXp9oelr.js} +2681 -2672
- package/lib/creatorDist/index.html +1 -1
- package/package.json +1 -1
- package/src/commands/publish.ts +3 -1
- package/src/commands/serve.ts +54 -26
- 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/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/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
|
+
}
|