@air-jam/cli 0.9.3 → 1.0.0-beta.10
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 +128 -0
- package/dist/auth-profile.d.ts +5 -0
- package/dist/auth-profile.js +7 -0
- package/dist/auth-profile.js.map +1 -0
- package/dist/auth-sessions.d.ts +5 -0
- package/dist/auth-sessions.js +7 -0
- package/dist/auth-sessions.js.map +1 -0
- package/dist/chunk-7D4AYBAV.js +64 -0
- package/dist/chunk-7D4AYBAV.js.map +1 -0
- package/dist/chunk-LH7UO57C.js +23 -0
- package/dist/chunk-LH7UO57C.js.map +1 -0
- package/dist/chunk-PKTLVQXZ.js +82 -0
- package/dist/chunk-PKTLVQXZ.js.map +1 -0
- package/dist/chunk-SQE4NPZP.js +31 -0
- package/dist/chunk-SQE4NPZP.js.map +1 -0
- package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
- package/dist/chunk-U6V3HEBB.js.map +1 -0
- package/dist/chunk-VEHNFPEO.js +224 -0
- package/dist/chunk-VEHNFPEO.js.map +1 -0
- package/dist/development.d.ts +4 -0
- package/dist/development.js +1 -1
- package/dist/game-analytics.d.ts +5 -0
- package/dist/game-analytics.js +7 -0
- package/dist/game-analytics.js.map +1 -0
- package/dist/game-app-id.d.ts +5 -0
- package/dist/game-app-id.js +7 -0
- package/dist/game-app-id.js.map +1 -0
- package/dist/game-media.d.ts +5 -0
- package/dist/game-media.js +7 -0
- package/dist/game-media.js.map +1 -0
- package/dist/index.js +688 -404
- package/dist/index.js.map +1 -1
- package/dist/scaffold.d.ts +8 -1
- package/dist/scaffold.js +6 -1
- package/dist/scaffold.js.map +1 -1
- package/package.json +8 -4
- package/runtime/local-network.d.mts +4 -6
- package/runtime/public-assets.mjs +62 -0
- package/runtime/source-fence.mjs +182 -0
- package/runtime/vite-config.d.mts +2 -1
- package/runtime/vite-config.mjs +6 -2
- package/runtime/vite-dev.mjs +18 -0
- package/runtime/vite-https.mjs +2 -3
- package/template-assets/bootstrap/AGENTS.md +56 -14
- package/template-assets/bootstrap/CLAUDE.md +0 -8
- package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
- package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
- package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
- package/template-assets/bootstrap/skills/index.md +1 -1
- package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
- package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
- package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
- package/template-assets/documentation/for-agents/page.mdx +24 -2
- package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
- package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +19 -2
- package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
- package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
- package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
- package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
- package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
- package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
- package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
- package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
- package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
- package/template-assets/documentation/manifest.json +112 -42
- package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
- package/template-assets/documentation/sdk/hooks/page.mdx +108 -172
- package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
- package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
- package/template-assets/documentation/sdk/settings/page.mdx +166 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +38 -27
- package/template-assets/managed/.airjam/ai-pack.json +65 -47
- package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
- package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
- package/template-assets/managed/docs/airjam/composition-shell-contract.md +4 -0
- package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
- package/template-assets/managed/docs/airjam/docs-index.md +18 -12
- package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
- package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
- package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
- package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
- package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
- package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
- package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
- package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
- package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
- package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
- package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
- package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
- package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +108 -167
- package/template-assets/managed/docs/airjam/generated/settings.md +169 -0
- package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +19 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +38 -25
- package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +5 -2
- package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
- package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
- package/dist/chunk-A4V2N4LX.js.map +0 -1
|
@@ -11,9 +11,13 @@ The simplest mode—your game connects directly to the Air Jam server.
|
|
|
11
11
|
|
|
12
12
|
**Usage:**
|
|
13
13
|
|
|
14
|
-
```tsx filename="src/
|
|
15
|
-
import {
|
|
16
|
-
import { airjam } from "
|
|
14
|
+
```tsx filename="src/app.tsx"
|
|
15
|
+
import { createAirJamApp, env } from "@air-jam/sdk";
|
|
16
|
+
import { airjam as game } from "./airjam.config";
|
|
17
|
+
|
|
18
|
+
export const airjam = createAirJamApp(game, {
|
|
19
|
+
runtime: env.vite(import.meta.env),
|
|
20
|
+
});
|
|
17
21
|
|
|
18
22
|
const HostShell = () => (
|
|
19
23
|
<airjam.Host
|
|
@@ -24,21 +28,14 @@ const HostShell = () => (
|
|
|
24
28
|
</airjam.Host>
|
|
25
29
|
);
|
|
26
30
|
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
// Host receives all input directly
|
|
31
|
-
useFrame(() => {
|
|
32
|
-
host.players.forEach((p) => {
|
|
33
|
-
const input = host.getInput(p.id);
|
|
34
|
-
processInput(p.id, input);
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
|
|
38
|
-
return <GameCanvas />;
|
|
39
|
-
};
|
|
31
|
+
// Players' controls reach the game in its simulation steps:
|
|
32
|
+
// step: (sim, { input, players }) => players.forEach((p) => process(sim, input(p.id)))
|
|
33
|
+
const HostView = () => <GameCanvas />;
|
|
40
34
|
```
|
|
41
35
|
|
|
36
|
+
`createAirJamApp` binds the game declaration from `src/airjam.config.ts` to the
|
|
37
|
+
browser and returns `Host`, `Controller` and `paths`.
|
|
38
|
+
|
|
42
39
|
### Arcade Mode (Outer App + Embedded Game)
|
|
43
40
|
|
|
44
41
|
In arcade mode, the platform runs the outer Arcade app and your game runs as an embedded Air Jam host inside an iframe.
|
|
@@ -47,100 +44,108 @@ The important rule is:
|
|
|
47
44
|
|
|
48
45
|
1. Arcade owns platform surface state
|
|
49
46
|
2. your game owns gameplay state
|
|
50
|
-
3. the
|
|
47
|
+
3. the room owns membership, seats and the latest copy of every channel
|
|
51
48
|
|
|
52
|
-
##
|
|
49
|
+
## One Room, Served to Each Frame
|
|
53
50
|
|
|
54
|
-
The
|
|
51
|
+
The Arcade's shell is the room's only host. It never hands its connection to a
|
|
52
|
+
game: when it shows a game, it serves that game's frame a view of its room over
|
|
53
|
+
a `MessagePort`, and each game's controller page gets the same kind of view of
|
|
54
|
+
its phone's seat.
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
- A frame sees and publishes only its own channels: everything outside the
|
|
57
|
+
Arcade's own `arcade.*` channels, such as `airjam.room` and its stores
|
|
58
|
+
- A frame that reaches outside its scope is closed `unauthorised`; the room and
|
|
59
|
+
the shell carry on
|
|
60
|
+
- A new frame for the same surface replaces the old one, which closes as
|
|
61
|
+
`replaced`
|
|
62
|
+
- Which game is showing lives in the shell's `arcade.surface` channel; its
|
|
63
|
+
`epoch` identifies one showing of one game
|
|
57
64
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
3. **Consistency** - All controllers route to same host
|
|
61
|
-
|
|
62
|
-
This focus system does not replace the normal Air Jam model. It only decides which host currently receives controller input. Your game still uses the normal input lane, replicated state lane, and signal lane.
|
|
65
|
+
Your game uses the normal input lane, replicated state lane and signal lane, as
|
|
66
|
+
it would standalone.
|
|
63
67
|
|
|
64
68
|
### 1. Arcade Launch
|
|
65
69
|
|
|
66
70
|
```
|
|
67
|
-
[
|
|
71
|
+
[Arcade shell] [Room] [Phone]
|
|
68
72
|
│ │ │
|
|
69
|
-
│ host
|
|
70
|
-
│ { maxPlayers: 8 } │ │
|
|
73
|
+
│ hello (host key, seats) │ │
|
|
71
74
|
│ ───────────────────────────▶│ │
|
|
72
75
|
│ │ │
|
|
73
|
-
│
|
|
76
|
+
│ welcome { code: "ABCD" } │ │
|
|
74
77
|
│ ◀───────────────────────────│ │
|
|
75
78
|
│ │ │
|
|
76
79
|
│ Display QR Code │ │
|
|
77
80
|
│ with room code │ Scan QR Code │
|
|
78
81
|
│ │ ◀──────────────────────────│
|
|
79
82
|
│ │ │
|
|
80
|
-
│ │
|
|
83
|
+
│ │ hello (phone key) │
|
|
81
84
|
│ │ ◀──────────────────────────│
|
|
82
85
|
│ │ │
|
|
83
|
-
│
|
|
86
|
+
│ seats [p1] │ welcome { seat: p1 } │
|
|
84
87
|
│ ◀───────────────────────────│ ──────────────────────────▶│
|
|
85
88
|
```
|
|
86
89
|
|
|
87
90
|
### 2. Game Launch
|
|
88
91
|
|
|
89
92
|
```
|
|
90
|
-
[Arcade]
|
|
91
|
-
│
|
|
92
|
-
│
|
|
93
|
-
│
|
|
94
|
-
│
|
|
95
|
-
│
|
|
96
|
-
│
|
|
97
|
-
│
|
|
98
|
-
│
|
|
99
|
-
│
|
|
100
|
-
│
|
|
101
|
-
│
|
|
102
|
-
│
|
|
103
|
-
│ │ Focus → GAME │ │
|
|
104
|
-
│ │ │ │
|
|
105
|
-
│ │ Redirect controller │ │
|
|
106
|
-
│ │ ─────────────────────────────────────────▶│
|
|
107
|
-
│ │ │ │
|
|
108
|
-
│ │ │ Load game UI │
|
|
93
|
+
[Arcade shell] [Your Game] [Phone]
|
|
94
|
+
│ │ │
|
|
95
|
+
│ arcade.surface → { kind: "game" } │ │
|
|
96
|
+
│ ─────────────────────────────────────────────────────────▶│
|
|
97
|
+
│ │ │
|
|
98
|
+
│ Load iframe ─────────────────────────▶│ │
|
|
99
|
+
│ │ │
|
|
100
|
+
│ room bridge request (MessagePort) │ │
|
|
101
|
+
│ ◀─────────────────────────────────────│ │
|
|
102
|
+
│ │ │
|
|
103
|
+
│ serve a scoped view of the room ───▶│ │
|
|
104
|
+
│ │ │
|
|
105
|
+
│ │ Load game UI │
|
|
109
106
|
```
|
|
110
107
|
|
|
111
108
|
### 3. Active Gameplay
|
|
112
109
|
|
|
113
|
-
|
|
110
|
+
While the game shows, every seat's input reaches your game:
|
|
114
111
|
|
|
115
|
-
```
|
|
116
|
-
// Your game
|
|
117
|
-
|
|
112
|
+
```ts
|
|
113
|
+
// Your game's simulation reads controls as usual inside the mounted host runtime.
|
|
114
|
+
step: (sim, { input, players }) => {
|
|
115
|
+
for (const player of players) play(sim, player.id, input(player.id));
|
|
116
|
+
},
|
|
117
|
+
```
|
|
118
118
|
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
119
|
+
#### When a phone drops
|
|
120
|
+
|
|
121
|
+
A phone that loses its connection keeps its seat while the room waits for it
|
|
122
|
+
to come back (two minutes by default). The game hears at once: the player stays
|
|
123
|
+
in `players` with `connected: false`, and becomes connected again when the
|
|
124
|
+
phone is back. The simulation step also gets `reconnectingPlayerIds`, so each
|
|
125
|
+
game decides whether to wait, let a bot cover or carry on:
|
|
126
|
+
|
|
127
|
+
```ts
|
|
128
|
+
step: (sim, { players, reconnectingPlayerIds }) => {
|
|
129
|
+
if (reconnectingPlayerIds.length > 0) return; // hold until everyone is back
|
|
130
|
+
// ...
|
|
131
|
+
},
|
|
125
132
|
```
|
|
126
133
|
|
|
134
|
+
Outside the simulation, `getReconnectingPlayerIds(players)` from
|
|
135
|
+
`@air-jam/sdk/core` gives the same list from `useAirJamHost()` state.
|
|
136
|
+
|
|
127
137
|
### 4. Game Exit
|
|
128
138
|
|
|
129
139
|
```
|
|
130
|
-
[
|
|
131
|
-
│ │
|
|
132
|
-
│
|
|
133
|
-
│ ───────────────────▶│
|
|
134
|
-
│ │
|
|
135
|
-
│ │
|
|
136
|
-
│ │
|
|
137
|
-
│ │
|
|
138
|
-
│
|
|
139
|
-
│ │ │ │
|
|
140
|
-
│ Destroy iframe ◀────────────── │ │
|
|
141
|
-
│ │ │ │
|
|
142
|
-
│ │ Restore arcade UI │ │
|
|
143
|
-
│ │ ─────────────────────────────────────────▶│
|
|
140
|
+
[Phone] [Arcade shell] [Your Game]
|
|
141
|
+
│ │ │
|
|
142
|
+
│ exit (arcade.surface request) │
|
|
143
|
+
│ ───────────────────▶│ │
|
|
144
|
+
│ │ arcade.surface → { kind: "browser" }│
|
|
145
|
+
│ │ Close the game's view ─────────────▶│
|
|
146
|
+
│ │ Drop the game's channels │
|
|
147
|
+
│ │ Destroy iframe ────────────────────▶│
|
|
148
|
+
│ ◀── Show Arcade controller │
|
|
144
149
|
```
|
|
145
150
|
|
|
146
151
|
### Standalone Mode
|
|
@@ -156,23 +161,26 @@ const host = useAirJamHost();
|
|
|
156
161
|
// host.joinUrl contains full URL for QR code
|
|
157
162
|
```
|
|
158
163
|
|
|
159
|
-
|
|
164
|
+
Opening the room stays automatic:
|
|
160
165
|
|
|
161
|
-
1. local dev: no
|
|
162
|
-
2.
|
|
163
|
-
|
|
166
|
+
1. local dev: no credential
|
|
167
|
+
2. hosted rooms: the SDK fetches a short-lived grant from `hostGrantEndpoint`
|
|
168
|
+
for each room it opens, and sends render-crash reports to the platform
|
|
169
|
+
unless the app passes its own `reportError`
|
|
170
|
+
3. after a reload, the host returns to its room with its key and keeps its
|
|
171
|
+
players
|
|
164
172
|
|
|
165
173
|
Game code does not change between those modes.
|
|
166
174
|
|
|
167
175
|
### Embedded Game Mode (Arcade)
|
|
168
176
|
|
|
169
177
|
```tsx
|
|
170
|
-
// SDK
|
|
171
|
-
// Game code should not parse
|
|
178
|
+
// The SDK detects that it is embedded and asks the page around it for the room.
|
|
179
|
+
// Game code should not parse the embedding params directly.
|
|
172
180
|
const host = useAirJamHost();
|
|
173
181
|
|
|
174
|
-
//
|
|
175
|
-
// Game hosts
|
|
182
|
+
// Closing and switching games belong to the Arcade.
|
|
183
|
+
// Game hosts keep gameplay logic in host callbacks and simulation steps.
|
|
176
184
|
```
|
|
177
185
|
|
|
178
186
|
### Player Lifecycle
|
|
@@ -181,10 +189,12 @@ const host = useAirJamHost();
|
|
|
181
189
|
const HostShell = () => (
|
|
182
190
|
<airjam.Host
|
|
183
191
|
onPlayerJoin={(player) => {
|
|
184
|
-
// player.id -
|
|
185
|
-
// player.label - Display name ("Player 1",
|
|
192
|
+
// player.id - The seat the room gave ("p1", "p2", …)
|
|
193
|
+
// player.label - Display name ("Player 1", or the name they chose)
|
|
186
194
|
// player.color - Assigned color ("#FF5733")
|
|
187
|
-
// player.
|
|
195
|
+
// player.kind - "phone", "preview" or "agent"
|
|
196
|
+
// player.connected - false while the phone is away
|
|
197
|
+
// player.avatarId - Optional chosen avatar
|
|
188
198
|
spawnPlayerEntity(player);
|
|
189
199
|
announceJoin(player.label);
|
|
190
200
|
}}
|
|
@@ -214,21 +224,19 @@ const player = host.players.find((p) => p.id === targetId);
|
|
|
214
224
|
|
|
215
225
|
## Controller Presentation State
|
|
216
226
|
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
state;
|
|
220
|
-
|
|
227
|
+
The host publishes a small presentation for the phones: whether the game is
|
|
228
|
+
playing or paused, and how to hold the phone. Networked stores own the real
|
|
229
|
+
multiplayer state; a short message for the players is a toast signal or a
|
|
230
|
+
store field.
|
|
231
|
+
|
|
232
|
+
A game whose `inputModalities` include `'joystick'` always gets a landscape controller; the SDK applies it, so do not set orientation; lay it out with `GamepadLayout` from `@air-jam/sdk/ui`: the stick under the left thumb, the actions under the right in a square the same size, and only short status between them.
|
|
221
233
|
|
|
222
234
|
```tsx
|
|
223
|
-
|
|
224
|
-
host.
|
|
225
|
-
|
|
226
|
-
orientation: "landscape", // "portrait" | "landscape"
|
|
227
|
-
message: "Round 3 - Fight!",
|
|
228
|
-
});
|
|
235
|
+
const host = useAirJamHost();
|
|
236
|
+
host.pauseRuntime();
|
|
237
|
+
host.resumeRuntime();
|
|
229
238
|
|
|
230
|
-
// Controllers
|
|
231
|
-
// or controller.runtimeState / controller.controllerOrientation / controller.stateMessage
|
|
239
|
+
// Controllers read controller.runtimeState and controller.controllerOrientation
|
|
232
240
|
```
|
|
233
241
|
|
|
234
242
|
## Error Handling
|
|
@@ -236,16 +244,18 @@ host.sendState({
|
|
|
236
244
|
```tsx
|
|
237
245
|
const host = useAirJamHost();
|
|
238
246
|
|
|
239
|
-
//
|
|
240
|
-
if (host.connectionStatus === "
|
|
247
|
+
// Reconnecting is automatic; show it while it happens
|
|
248
|
+
if (host.connectionStatus === "reconnecting") {
|
|
241
249
|
showReconnectUI();
|
|
242
250
|
}
|
|
243
251
|
|
|
252
|
+
// A busy hosted service queues new rooms
|
|
253
|
+
if (host.queuePosition !== null) {
|
|
254
|
+
showQueue(host.queuePosition);
|
|
255
|
+
}
|
|
256
|
+
|
|
244
257
|
// Check for errors
|
|
245
258
|
if (host.lastError) {
|
|
246
259
|
showError(host.lastError);
|
|
247
260
|
}
|
|
248
|
-
|
|
249
|
-
// Force reconnection
|
|
250
|
-
host.reconnect();
|
|
251
261
|
```
|