@air-jam/sdk 0.1.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 (56) hide show
  1. package/README.md +87 -0
  2. package/dist/.tsbuildinfo +1 -0
  3. package/dist/chunk-XSXI3RIS.js +72 -0
  4. package/dist/chunk-XSXI3RIS.js.map +1 -0
  5. package/dist/index.cjs +3514 -0
  6. package/dist/index.cjs.map +1 -0
  7. package/dist/index.d.cts +1529 -0
  8. package/dist/index.d.ts +1529 -0
  9. package/dist/index.js +3366 -0
  10. package/dist/index.js.map +1 -0
  11. package/dist/protocol.cjs +85 -0
  12. package/dist/protocol.cjs.map +1 -0
  13. package/dist/protocol.d.cts +242 -0
  14. package/dist/protocol.d.ts +242 -0
  15. package/dist/protocol.js +3 -0
  16. package/dist/protocol.js.map +1 -0
  17. package/package.json +81 -0
  18. package/src/AirJamClient.ts +775 -0
  19. package/src/audio/audio-manager.ts +395 -0
  20. package/src/audio/hooks.tsx +140 -0
  21. package/src/audio/index.ts +3 -0
  22. package/src/audio/volume-store.ts +77 -0
  23. package/src/components/air-jam-overlay.tsx +456 -0
  24. package/src/components/controller-shell.tsx +329 -0
  25. package/src/components/qr-scanner-dialog.tsx +373 -0
  26. package/src/components/ui/alert.tsx +66 -0
  27. package/src/components/ui/avatar.tsx +46 -0
  28. package/src/components/ui/badge.tsx +47 -0
  29. package/src/components/ui/button.tsx +61 -0
  30. package/src/components/ui/card.tsx +92 -0
  31. package/src/components/ui/slider.tsx +61 -0
  32. package/src/components/ui/tabs.tsx +64 -0
  33. package/src/components/volume-controls.tsx +93 -0
  34. package/src/constants.ts +45 -0
  35. package/src/context/air-jam-context.tsx +478 -0
  36. package/src/context/index.ts +2 -0
  37. package/src/context/socket-manager.ts +98 -0
  38. package/src/events.ts +151 -0
  39. package/src/hooks/use-air-jam-controller.ts +608 -0
  40. package/src/hooks/use-air-jam-host.ts +624 -0
  41. package/src/hooks/use-air-jam-shell.ts +343 -0
  42. package/src/hooks/use-fullscreen.ts +108 -0
  43. package/src/hooks/use-get-input.ts +97 -0
  44. package/src/hooks/use-send-signal.ts +164 -0
  45. package/src/index.ts +33 -0
  46. package/src/internal/input-manager.ts +362 -0
  47. package/src/protocol.ts +331 -0
  48. package/src/state/connection-store.ts +84 -0
  49. package/src/styles.css +128 -0
  50. package/src/types/browser.ts +42 -0
  51. package/src/utils/cn.ts +4 -0
  52. package/src/utils/ids.ts +31 -0
  53. package/src/utils/index.ts +1 -0
  54. package/src/utils/mode.ts +13 -0
  55. package/src/utils/network-ip.ts +145 -0
  56. package/src/utils/url-builder.ts +170 -0
package/src/events.ts ADDED
@@ -0,0 +1,151 @@
1
+ /**
2
+ * Air Jam Socket.IO event names
3
+ * Centralized to ensure consistency and type safety
4
+ */
5
+
6
+ /**
7
+ * Host events
8
+ */
9
+ export const HostEvents = {
10
+ /**
11
+ * Register as a master host (standalone mode)
12
+ */
13
+ REGISTER: "host:register",
14
+
15
+ /**
16
+ * Register as the system/arcade master host
17
+ */
18
+ REGISTER_SYSTEM: "host:registerSystem",
19
+
20
+ /**
21
+ * Join as a child host (game launched from arcade)
22
+ */
23
+ JOIN_AS_CHILD: "host:joinAsChild",
24
+ } as const;
25
+
26
+ /**
27
+ * Controller events
28
+ */
29
+ export const ControllerEvents = {
30
+ /**
31
+ * Controller joins a room
32
+ */
33
+ JOIN: "controller:join",
34
+
35
+ /**
36
+ * Controller sends input
37
+ */
38
+ INPUT: "controller:input",
39
+
40
+ /**
41
+ * Controller leaves a room
42
+ */
43
+ LEAVE: "controller:leave",
44
+
45
+ /**
46
+ * Controller sends game state update
47
+ */
48
+ STATE: "controller:state",
49
+
50
+ /**
51
+ * Controller sends system command
52
+ */
53
+ SYSTEM: "controller:system",
54
+ } as const;
55
+
56
+ /**
57
+ * System events (Arcade-specific)
58
+ */
59
+ export const SystemEvents = {
60
+ /**
61
+ * Arcade launches a game
62
+ */
63
+ LAUNCH_GAME: "system:launchGame",
64
+
65
+ /**
66
+ * Arcade closes a game
67
+ */
68
+ CLOSE_GAME: "system:closeGame",
69
+ } as const;
70
+
71
+ /**
72
+ * Server events (server -> client)
73
+ */
74
+ export const ServerEvents = {
75
+ /**
76
+ * Welcome message with room/controller info
77
+ */
78
+ WELCOME: "server:welcome",
79
+
80
+ /**
81
+ * Room is ready
82
+ */
83
+ ROOM_READY: "server:roomReady",
84
+
85
+ /**
86
+ * Controller joined notification
87
+ */
88
+ CONTROLLER_JOINED: "server:controllerJoined",
89
+
90
+ /**
91
+ * Controller left notification
92
+ */
93
+ CONTROLLER_LEFT: "server:controllerLeft",
94
+
95
+ /**
96
+ * Host left notification
97
+ */
98
+ HOST_LEFT: "server:hostLeft",
99
+
100
+ /**
101
+ * Server error
102
+ */
103
+ ERROR: "server:error",
104
+
105
+ /**
106
+ * Play sound on client
107
+ */
108
+ PLAY_SOUND: "server:playSound",
109
+ } as const;
110
+
111
+ /**
112
+ * Client events (server -> controller shell)
113
+ */
114
+ export const ClientEvents = {
115
+ /**
116
+ * Load a game UI in the controller iframe
117
+ */
118
+ LOAD_UI: "client:loadUi",
119
+
120
+ /**
121
+ * Unload the game UI from the controller iframe
122
+ */
123
+ UNLOAD_UI: "client:unloadUi",
124
+
125
+ /**
126
+ * Update game state display
127
+ */
128
+ STATE: "client:state",
129
+ } as const;
130
+
131
+ /**
132
+ * Child events (server -> child host)
133
+ */
134
+ export const ChildEvents = {
135
+ /**
136
+ * Server requests child to close
137
+ */
138
+ CLOSE: "child:close",
139
+ } as const;
140
+
141
+ /**
142
+ * All events combined for easy reference
143
+ */
144
+ export const Events = {
145
+ Host: HostEvents,
146
+ Controller: ControllerEvents,
147
+ System: SystemEvents,
148
+ Server: ServerEvents,
149
+ Client: ClientEvents,
150
+ Child: ChildEvents,
151
+ } as const;