@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.
- package/README.md +87 -0
- package/dist/.tsbuildinfo +1 -0
- package/dist/chunk-XSXI3RIS.js +72 -0
- package/dist/chunk-XSXI3RIS.js.map +1 -0
- package/dist/index.cjs +3514 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1529 -0
- package/dist/index.d.ts +1529 -0
- package/dist/index.js +3366 -0
- package/dist/index.js.map +1 -0
- package/dist/protocol.cjs +85 -0
- package/dist/protocol.cjs.map +1 -0
- package/dist/protocol.d.cts +242 -0
- package/dist/protocol.d.ts +242 -0
- package/dist/protocol.js +3 -0
- package/dist/protocol.js.map +1 -0
- package/package.json +81 -0
- package/src/AirJamClient.ts +775 -0
- package/src/audio/audio-manager.ts +395 -0
- package/src/audio/hooks.tsx +140 -0
- package/src/audio/index.ts +3 -0
- package/src/audio/volume-store.ts +77 -0
- package/src/components/air-jam-overlay.tsx +456 -0
- package/src/components/controller-shell.tsx +329 -0
- package/src/components/qr-scanner-dialog.tsx +373 -0
- package/src/components/ui/alert.tsx +66 -0
- package/src/components/ui/avatar.tsx +46 -0
- package/src/components/ui/badge.tsx +47 -0
- package/src/components/ui/button.tsx +61 -0
- package/src/components/ui/card.tsx +92 -0
- package/src/components/ui/slider.tsx +61 -0
- package/src/components/ui/tabs.tsx +64 -0
- package/src/components/volume-controls.tsx +93 -0
- package/src/constants.ts +45 -0
- package/src/context/air-jam-context.tsx +478 -0
- package/src/context/index.ts +2 -0
- package/src/context/socket-manager.ts +98 -0
- package/src/events.ts +151 -0
- package/src/hooks/use-air-jam-controller.ts +608 -0
- package/src/hooks/use-air-jam-host.ts +624 -0
- package/src/hooks/use-air-jam-shell.ts +343 -0
- package/src/hooks/use-fullscreen.ts +108 -0
- package/src/hooks/use-get-input.ts +97 -0
- package/src/hooks/use-send-signal.ts +164 -0
- package/src/index.ts +33 -0
- package/src/internal/input-manager.ts +362 -0
- package/src/protocol.ts +331 -0
- package/src/state/connection-store.ts +84 -0
- package/src/styles.css +128 -0
- package/src/types/browser.ts +42 -0
- package/src/utils/cn.ts +4 -0
- package/src/utils/ids.ts +31 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/mode.ts +13 -0
- package/src/utils/network-ip.ts +145 -0
- 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;
|