@air-jam/cli 0.9.3 → 1.0.0-beta.1
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/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 +0 -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 +106 -171
- 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 +155 -0
- package/template-assets/documentation/sdk/ui-components/page.mdx +45 -4
- package/template-assets/managed/.airjam/ai-pack.json +61 -43
- 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/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 +106 -166
- package/template-assets/managed/docs/airjam/generated/settings.md +158 -0
- package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
- package/template-assets/managed/docs/airjam/generated/ui-components.md +45 -2
- package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
- package/template-assets/managed/docs/airjam/preview-controllers.md +4 -1
- 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
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Controller UI
|
|
4
2
|
|
|
5
3
|
Controller UI should feel like a game controller first and a webpage second.
|
|
@@ -8,6 +6,8 @@ The main failure mode is borrowing desktop web-app patterns for active gameplay
|
|
|
8
6
|
|
|
9
7
|
## Gameplay Controller Rules
|
|
10
8
|
|
|
9
|
+
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.
|
|
10
|
+
|
|
11
11
|
For active gameplay:
|
|
12
12
|
|
|
13
13
|
1. use an absolute `inset-0` root
|
|
@@ -17,6 +17,35 @@ For active gameplay:
|
|
|
17
17
|
5. keep controls visually obvious and single-purpose
|
|
18
18
|
6. minimize text and dense hierarchy
|
|
19
19
|
|
|
20
|
+
## Sideways Controllers
|
|
21
|
+
|
|
22
|
+
A sideways phone is held like a gamepad, so its controls use the screen like one. Compose them in `GamepadLayout`:
|
|
23
|
+
|
|
24
|
+
1. the stick goes in `left` and the actions in `right`; both get the same square, so they carry the same weight and mirror each other about the centre, each centred in its thumb zone on one line
|
|
25
|
+
2. a single action fills its square; several actions share it as one cluster, as phone action games do, rather than starting a third column: the main action sits at the square's centre under the resting thumb at about half the square's width, each other action is about two thirds of the main one's size on a tight arc around its inner side (below, toward the centre, above) with the most used nearest, a rarely used utility goes smaller on the outer side, and every button stays inside the thumb zone
|
|
26
|
+
3. a button with a cooldown shows it on itself: a dark sweep over the icon that shrinks as it recovers, the seconds left when the wait is over a second, and full colour once it is ready again
|
|
27
|
+
4. buttons show icons, not words, drawn as one family: the same grid, the same stroke width with round caps and joins (or all filled), the same optical size of about half the button, one simple silhouette each and no detail finer than the stroke; judge them at real size on a phone
|
|
28
|
+
5. `center` holds only what a player reads at a glance: a round, a number, a word, a few icons; it never wraps into squeezed lines
|
|
29
|
+
6. a longer message goes in the header bar above the layout, or stays on the TV
|
|
30
|
+
|
|
31
|
+
```tsx
|
|
32
|
+
import { ControlButton, GamepadLayout, Stick } from "@air-jam/sdk/ui";
|
|
33
|
+
|
|
34
|
+
// Before: a big stick, a small button pushed to the edge, a sentence wrapping between them.
|
|
35
|
+
<div className="flex h-full items-center justify-between px-6">
|
|
36
|
+
<Stick control={gameInput.move} className="size-56" />
|
|
37
|
+
<p className="max-w-48 text-2xl">Splash! Back next round</p>
|
|
38
|
+
<ControlButton control={gameInput.dash} className="size-28">Dash</ControlButton>
|
|
39
|
+
</div>
|
|
40
|
+
|
|
41
|
+
// After: equal mirrored thumbs, a glanceable centre, the sentence in the header.
|
|
42
|
+
<GamepadLayout
|
|
43
|
+
left={<Stick control={gameInput.move} className="rounded-full bg-white/10" />}
|
|
44
|
+
center={<span className="text-xs uppercase">Round 1</span>}
|
|
45
|
+
right={<ControlButton control={gameInput.dash} className="rounded-full bg-sky-400">Dash</ControlButton>}
|
|
46
|
+
/>
|
|
47
|
+
```
|
|
48
|
+
|
|
20
49
|
## Lobby Rules
|
|
21
50
|
|
|
22
51
|
Lobby screens can be slightly more flexible, but should still prefer:
|
|
@@ -58,3 +87,13 @@ For template and starter work, a practical split is:
|
|
|
58
87
|
2. a gameplay-oriented icon set for abilities, pickups, and status effects
|
|
59
88
|
|
|
60
89
|
Keep icon usage behind local wrappers where practical so the project can curate or replace icons later.
|
|
90
|
+
|
|
91
|
+
## Private player screens and word games
|
|
92
|
+
|
|
93
|
+
Keep secret words or cards in a per-controller map declared with
|
|
94
|
+
`createAirJamStore`'s `privateField`; read that phone's entry with
|
|
95
|
+
`useAirJamPrivateState`. The public store excludes this field and each phone
|
|
96
|
+
receives only its own entry. Test a reveal with `studio_press_phone`'s hold action.
|
|
97
|
+
|
|
98
|
+
A decision-model seat (Jev) answers choice questions only. Give model seats authored
|
|
99
|
+
candidate clues or answers as options; people can type freely into phone fields.
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# For Agents
|
|
4
2
|
|
|
5
3
|
This page is the fastest entrypoint for LLM agents and automation tools.
|
|
@@ -43,6 +41,8 @@ the server. `mcp doctor` distinguishes project declarations from detected client
|
|
|
43
41
|
registrations. Confirm that the connected client discovers Air Jam's tools before
|
|
44
42
|
treating the connection as working.
|
|
45
43
|
|
|
44
|
+
[Supported Agents](/docs/for-agents/supported-agents) lists the clients tested end to end.
|
|
45
|
+
|
|
46
46
|
## Operate and Evaluate
|
|
47
47
|
|
|
48
48
|
For gameplay assertions, use `airjam.open_game_session`,
|
|
@@ -51,6 +51,12 @@ For gameplay assertions, use `airjam.open_game_session`,
|
|
|
51
51
|
do not guess game-specific action IDs. `airjam.capture_game_session_visuals`
|
|
52
52
|
adds host and phone-controller screenshots to the same session.
|
|
53
53
|
|
|
54
|
+
In Studio, `studio_press_phone` taps, holds or types on one named mounted Studio phone
|
|
55
|
+
and returns its private screen in the same call. Coordinates are fractions 0..1 of
|
|
56
|
+
`studio_observe_current_game`'s `surface=phone` image. Tap a field before typing;
|
|
57
|
+
a hold captures while pressed, then releases. Reuse the requestId UUID for retries.
|
|
58
|
+
Guest/real phones and older runtimes return an explicit unavailable reason.
|
|
59
|
+
|
|
54
60
|
MCP is optional. A terminal agent can use the same services:
|
|
55
61
|
|
|
56
62
|
```bash
|
|
@@ -72,6 +78,22 @@ The [Quick Start publishing guide](/docs/getting-started/quick-start#terminal-or
|
|
|
72
78
|
covers CLI authentication, hosted release submission, inspection, and explicit
|
|
73
79
|
publication. Local development and evaluation do not require hosted publishing.
|
|
74
80
|
|
|
81
|
+
## Decision-model Players
|
|
82
|
+
|
|
83
|
+
An `AirJamPlayerContract` from `@air-jam/devtools/testing` describes play with
|
|
84
|
+
`brief` and `turn`. A turn returns `{ state, question, options }` or `null` when
|
|
85
|
+
the seat has nothing to do. Offer 1 to 16 named options, each with a plain-language
|
|
86
|
+
`when` and its `control`. Zero options is invalid; use `null` to wait.
|
|
87
|
+
|
|
88
|
+
A single sensible move is allowed: for example, a lobby turn can offer only
|
|
89
|
+
`join` with `control: { kind: "action", actionId: "join_match" }`. The run owner
|
|
90
|
+
takes that control directly without calling a decision model or incurring model
|
|
91
|
+
cost. Do not invent a second option to satisfy validation. Multiple options ask
|
|
92
|
+
the run's model to choose. Automatic answers retain the choice and control in the
|
|
93
|
+
trace, marked `Only option; no model asked.`, and count toward the seat's optional
|
|
94
|
+
`answers.automatic` summary. The policy receives the choice just like a model
|
|
95
|
+
answer on its next step.
|
|
96
|
+
|
|
75
97
|
## Read These First
|
|
76
98
|
|
|
77
99
|
1. [Introduction](/docs/getting-started/introduction)
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
# Supported Agents
|
|
2
|
+
|
|
3
|
+
Any coding agent that can run terminal commands or start a local stdio MCP
|
|
4
|
+
server can build with Air Jam. Tested means the agent made a game through Air
|
|
5
|
+
Jam's CLI and MCP, played it with two phones and released it.
|
|
6
|
+
|
|
7
|
+
| Agent | Status | Notes |
|
|
8
|
+
| ---------------------------------- | ---------------------- | --------------------------------------- |
|
|
9
|
+
| Codex CLI | Tested | |
|
|
10
|
+
| Claude Code | Tested | |
|
|
11
|
+
| T3 Code | Tested | |
|
|
12
|
+
| Codex app, over SSH | Covered by Codex CLI | Runs the same `codex` program |
|
|
13
|
+
| Claude Desktop Code tab, over SSH | Covered by Claude Code | Runs the same `claude` program |
|
|
14
|
+
| Claude Desktop chat | Not for building | Cannot edit project files |
|
|
15
|
+
| Other terminal or stdio MCP agents | Not tested | Expected to work through the CLI or MCP |
|
|
16
|
+
|
|
17
|
+
Air Jam supports its own CLI and MCP, not the agent's interface. To connect an
|
|
18
|
+
agent, see [For Agents](/docs/for-agents).
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Debugging and Logs
|
|
4
2
|
|
|
5
3
|
When local Air Jam development breaks, the fastest fix is usually knowing which surface is failing:
|
|
@@ -62,7 +60,7 @@ Use the right browser console for the right problem:
|
|
|
62
60
|
|
|
63
61
|
1. **Host tab** for room creation, host bootstrap, input consumption, and gameplay errors
|
|
64
62
|
2. **Controller tab/phone remote inspector** for join failures, input publishing, haptics, and controller UI state
|
|
65
|
-
3. **Server terminal** for room lifecycle,
|
|
63
|
+
3. **Server terminal** for room lifecycle, dropped connections, refused hosts and phones
|
|
66
64
|
|
|
67
65
|
Do not debug everything from only one surface.
|
|
68
66
|
|
|
@@ -96,16 +94,17 @@ pnpm run dev -- --secure
|
|
|
96
94
|
|
|
97
95
|
Check:
|
|
98
96
|
|
|
99
|
-
1.
|
|
100
|
-
2.
|
|
101
|
-
3.
|
|
102
|
-
4.
|
|
97
|
+
1. the game declares its controls with `defineAirJamGame({ input })`
|
|
98
|
+
2. the controller renders the SDK's phone controls bound to those controls
|
|
99
|
+
3. the simulation reads them in its step with `input(playerId)`
|
|
100
|
+
4. you are not trying to send per-frame input through store actions
|
|
101
|
+
5. the dev log shows no `AJ_INPUT_INVALID` diagnostic
|
|
103
102
|
|
|
104
103
|
### Store actions do nothing
|
|
105
104
|
|
|
106
105
|
Check:
|
|
107
106
|
|
|
108
|
-
1. actions are dispatched via `
|
|
107
|
+
1. actions are dispatched via `gameStore.actions` and the store is declared in `defineAirJamGame({ stores })`
|
|
109
108
|
2. payloads are plain serializable objects
|
|
110
109
|
3. your controller is connected before dispatching
|
|
111
110
|
4. identity-dependent actions use `ctx.actorId` on the host side
|
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Game Ideas for Air Jam
|
|
4
2
|
|
|
5
|
-
A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (
|
|
3
|
+
A collection of game concepts that leverage Air Jam's unique architecture: **High-Frequency Input Streams** (declared controls) + **Reliable Shared State** (AirJam Store).
|
|
6
4
|
|
|
7
5
|
---
|
|
8
6
|
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
1
|
# Introduction
|
|
4
2
|
|
|
5
3
|
Air Jam is an open **AI-native framework for multiplayer games controlled by
|
|
@@ -10,7 +8,7 @@ input, state, and release model.
|
|
|
10
8
|
## Key Features
|
|
11
9
|
|
|
12
10
|
- **Zero App Download**: Players join by scanning a QR code—no app store required
|
|
13
|
-
- **Instant Multiplayer**:
|
|
11
|
+
- **Instant Multiplayer**: Connect smartphones up to the game’s declared player capacity
|
|
14
12
|
- **Developer Friendly**: Built with modern web technologies (React, TypeScript)
|
|
15
13
|
- **AI-Native By Design**: Humans and agents share explicit contracts for runtime, input, logs, and release workflows
|
|
16
14
|
- **Type Safe**: End-to-end type safety with Zod schema validation
|
|
@@ -19,7 +17,6 @@ input, state, and release model.
|
|
|
19
17
|
|
|
20
18
|
## How It Works
|
|
21
19
|
|
|
22
|
-
|
|
23
20
|
<HowItWorksDiagram />
|
|
24
21
|
|
|
25
22
|
## Quick Start
|
|
@@ -33,7 +30,10 @@ pnpm add @air-jam/sdk
|
|
|
33
30
|
### 2. Wrap Your App
|
|
34
31
|
|
|
35
32
|
```tsx filename="src/app.tsx"
|
|
36
|
-
import {
|
|
33
|
+
import { createAirJamApp, env } from "@air-jam/sdk";
|
|
34
|
+
import { airjam as game } from "./airjam.config";
|
|
35
|
+
|
|
36
|
+
const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
|
|
37
37
|
|
|
38
38
|
export const App = () => (
|
|
39
39
|
<Routes>
|
|
@@ -64,19 +64,52 @@ export const App = () => (
|
|
|
64
64
|
);
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
```
|
|
68
|
-
import {
|
|
69
|
-
import {
|
|
67
|
+
```ts filename="src/airjam.config.ts"
|
|
68
|
+
import { defineAirJamGame } from "@air-jam/sdk/core";
|
|
69
|
+
import {
|
|
70
|
+
axis,
|
|
71
|
+
button,
|
|
72
|
+
defineAirJamInput,
|
|
73
|
+
defineAirJamSimulation,
|
|
74
|
+
type AirJamInputValues,
|
|
75
|
+
} from "@air-jam/sdk/core";
|
|
76
|
+
|
|
77
|
+
export const gameInput = defineAirJamInput({
|
|
78
|
+
direction: axis(),
|
|
79
|
+
fire: button("pressed"),
|
|
80
|
+
});
|
|
70
81
|
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
82
|
+
const simulation = defineAirJamSimulation<
|
|
83
|
+
World,
|
|
84
|
+
AirJamInputValues<typeof gameInput>
|
|
85
|
+
>({
|
|
86
|
+
stepMs: 1000 / 60,
|
|
87
|
+
create: () => createWorld(),
|
|
88
|
+
step: (world, { input, players, dtSeconds }) => {
|
|
89
|
+
for (const player of players) {
|
|
90
|
+
const { direction, fire } = input(player.id);
|
|
91
|
+
movePaddle(world, player.id, direction * SPEED * dtSeconds);
|
|
92
|
+
if (fire) fireLaser(world, player.id);
|
|
93
|
+
}
|
|
94
|
+
},
|
|
74
95
|
});
|
|
75
96
|
|
|
76
|
-
export const airjam =
|
|
77
|
-
|
|
97
|
+
export const airjam = defineAirJamGame({
|
|
98
|
+
metadata: {
|
|
99
|
+
slug: "space-game",
|
|
100
|
+
name: "Space Game",
|
|
101
|
+
tagline: "Fly together and defend the fleet.",
|
|
102
|
+
category: "arcade",
|
|
103
|
+
minPlayers: 1,
|
|
104
|
+
maxPlayers: 4,
|
|
105
|
+
inputModalities: ["buttons", "touch"],
|
|
106
|
+
supportedSdkRange: "^1.0.0",
|
|
107
|
+
maintainer: { name: "Air Jam" },
|
|
108
|
+
version: 1,
|
|
109
|
+
},
|
|
78
110
|
controllerPath: "/controller",
|
|
79
|
-
|
|
111
|
+
simulation,
|
|
112
|
+
input: gameInput,
|
|
80
113
|
});
|
|
81
114
|
```
|
|
82
115
|
|
|
@@ -90,15 +123,7 @@ import { useAirJamHost } from "@air-jam/sdk";
|
|
|
90
123
|
|
|
91
124
|
const HostView = () => {
|
|
92
125
|
const host = useAirJamHost();
|
|
93
|
-
|
|
94
|
-
// In your game loop (e.g., useFrame or requestAnimationFrame):
|
|
95
|
-
// host.players.forEach(p => {
|
|
96
|
-
// const input = host.getInput(p.id);
|
|
97
|
-
// if (input) {
|
|
98
|
-
// player.y += input.direction * SPEED;
|
|
99
|
-
// if (input.action) fireLaser(p.id);
|
|
100
|
-
// }
|
|
101
|
-
// });
|
|
126
|
+
// The simulation moves the game; this view draws it with useSimulationFrame.
|
|
102
127
|
|
|
103
128
|
return (
|
|
104
129
|
<div className="relative min-h-screen bg-black text-white">
|
|
@@ -128,41 +153,33 @@ The path below also matches the current starter template layout.
|
|
|
128
153
|
If your project uses a different file shape, keep the same ownership boundary even if the filename changes.
|
|
129
154
|
|
|
130
155
|
```tsx filename="src/controller/index.tsx"
|
|
131
|
-
import {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
action: false,
|
|
148
|
-
});
|
|
149
|
-
},
|
|
150
|
-
{
|
|
151
|
-
enabled:
|
|
152
|
-
controller.connectionStatus === "connected" &&
|
|
153
|
-
controller.runtimeState === "playing",
|
|
154
|
-
intervalMs: 16,
|
|
155
|
-
},
|
|
156
|
-
);
|
|
157
|
-
};
|
|
156
|
+
import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
|
|
157
|
+
import { gameInput } from "../airjam.config";
|
|
158
|
+
|
|
159
|
+
const ControllerView = () => (
|
|
160
|
+
<div className="grid h-full grid-cols-2 gap-3 p-3">
|
|
161
|
+
<AxisButton control={gameInput.direction} value={-1}>
|
|
162
|
+
Up
|
|
163
|
+
</AxisButton>
|
|
164
|
+
<AxisButton control={gameInput.direction} value={1}>
|
|
165
|
+
Down
|
|
166
|
+
</AxisButton>
|
|
167
|
+
<ControlButton control={gameInput.fire} className="col-span-2">
|
|
168
|
+
Fire
|
|
169
|
+
</ControlButton>
|
|
170
|
+
</div>
|
|
171
|
+
);
|
|
158
172
|
```
|
|
159
173
|
|
|
174
|
+
The SDK's phone controls fill the declared controls and send them; the
|
|
175
|
+
controller runs no send loop.
|
|
176
|
+
|
|
160
177
|
## Canonical Architecture: Three Lanes
|
|
161
178
|
|
|
162
179
|
Use one lane per concern:
|
|
163
180
|
|
|
164
|
-
1. **Input lane**:
|
|
165
|
-
2. **State lane**: `createAirJamStore` with host-owned actions
|
|
181
|
+
1. **Input lane**: controls declared with `defineAirJamInput`, filled by the SDK's phone controls, read in simulation steps with `input(playerId)`.
|
|
182
|
+
2. **State lane**: `createAirJamStore` with host-owned actions, dispatched through `store.actions`.
|
|
166
183
|
3. **Signal lane**: `sendSignal` / system commands for out-of-band UX and runtime commands.
|
|
167
184
|
|
|
168
185
|
<Callout variant="info" title="Tip">
|
|
@@ -174,10 +191,10 @@ Avoid cross-lane misuse:
|
|
|
174
191
|
|
|
175
192
|
1. Don’t stream per-frame movement through store actions.
|
|
176
193
|
2. Don’t encode authoritative gameplay state in signals.
|
|
177
|
-
3. Don’t call `state.actions.*`;
|
|
194
|
+
3. Don’t call `state.actions.*`; dispatch through `gameStore.actions`.
|
|
178
195
|
|
|
179
196
|
## Next Steps
|
|
180
197
|
|
|
181
198
|
- [Architecture](/docs/how-it-works/architecture) - Understand the system design
|
|
182
199
|
- [Hooks Reference](/docs/sdk/hooks) - Complete API documentation
|
|
183
|
-
- [Input System](/docs/sdk/input-system) -
|
|
200
|
+
- [Input System](/docs/sdk/input-system) - Declare controls and read them each step
|