@learnpack/learnpack 5.0.178 → 5.0.180

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 (32) hide show
  1. package/README.md +13 -13
  2. package/lib/commands/serve.js +32 -18
  3. package/lib/creatorDist/assets/{index-CrWESWmj.css → index-Bnq3eZ3T.css} +13 -3
  4. package/lib/creatorDist/assets/index-hhajeHFt.js +35366 -0
  5. package/lib/creatorDist/index.html +2 -2
  6. package/lib/utils/creatorSocket.d.ts +1 -0
  7. package/lib/utils/creatorSocket.js +24 -0
  8. package/oclif.manifest.json +1 -1
  9. package/package.json +1 -1
  10. package/src/commands/serve.ts +48 -26
  11. package/src/creator/package-lock.json +137 -0
  12. package/src/creator/package.json +1 -0
  13. package/src/creator/src/App.tsx +77 -50
  14. package/src/creator/src/components/ConsumablesManager.tsx +1 -3
  15. package/src/creator/src/components/FileUploader.tsx +136 -44
  16. package/src/creator/src/components/PurposeSelector.tsx +70 -0
  17. package/src/creator/src/components/SelectableCard.tsx +5 -3
  18. package/src/creator/src/components/Uploader.tsx +12 -1
  19. package/src/creator/src/components/syllabus/SyllabusEditor.tsx +6 -12
  20. package/src/creator/src/utils/constants.ts +10 -4
  21. package/src/creator/src/utils/lib.ts +0 -2
  22. package/src/creator/src/utils/rigo.ts +9 -5
  23. package/src/creator/src/utils/socket.ts +61 -0
  24. package/src/creator/src/utils/store.ts +7 -1
  25. package/src/creatorDist/assets/{index-CrWESWmj.css → index-Bnq3eZ3T.css} +13 -3
  26. package/src/creatorDist/assets/index-hhajeHFt.js +35366 -0
  27. package/src/creatorDist/index.html +2 -2
  28. package/src/ui/_app/app.js +19 -8
  29. package/src/ui/app.tar.gz +0 -0
  30. package/src/utils/creatorSocket.ts +30 -0
  31. package/lib/creatorDist/assets/index-BvrB0WCf.js +0 -32991
  32. package/src/creatorDist/assets/index-BvrB0WCf.js +0 -32991
package/src/ui/app.tar.gz CHANGED
Binary file
@@ -1,6 +1,8 @@
1
1
  import { Server as SocketIOServer, Socket } from "socket.io"
2
2
 
3
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>
4
6
  const socketStore = new Map<string, Socket>() // socket.id -> socket
5
7
 
6
8
  let io: SocketIOServer | null = null
@@ -31,6 +33,21 @@ return
31
33
  console.log(`📦 Socket ${socket.id} registered to course: ${courseSlug}`)
32
34
  })
33
35
 
36
+ socket.on("registerNotification", (data: { notificationId: string }) => {
37
+ const { notificationId } = data
38
+ if (!notificationId)
39
+ return
40
+
41
+ if (!notificationSocketMap.has(notificationId)) {
42
+ notificationSocketMap.set(notificationId, new Set())
43
+ }
44
+
45
+ notificationSocketMap.get(notificationId)?.add(socket.id)
46
+ console.log(
47
+ `📧 Socket ${socket.id} registered to notification: ${notificationId}`
48
+ )
49
+ })
50
+
34
51
  socket.on("disconnect", () => {
35
52
  console.log("🔥 Socket disconnected:", socket.id)
36
53
  socketStore.delete(socket.id)
@@ -56,6 +73,19 @@ socket.emit(event, payload)
56
73
  }
57
74
  }
58
75
 
76
+ export function emitToNotification(notificationId: string, payload: any) {
77
+ console.log("Emitting to notification", notificationId, payload)
78
+ const socketIds = notificationSocketMap.get(notificationId)
79
+ if (!socketIds || socketIds.size === 0)
80
+ return
81
+
82
+ for (const id of socketIds) {
83
+ const socket = socketStore.get(id)
84
+ if (socket)
85
+ socket.emit(notificationId, payload)
86
+ }
87
+ }
88
+
59
89
  export function getSocketIO() {
60
90
  if (!io)
61
91
  throw new Error("Socket.IO not initialized")