@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.
Files changed (99) hide show
  1. package/README.md +128 -0
  2. package/dist/auth-profile.d.ts +5 -0
  3. package/dist/auth-profile.js +7 -0
  4. package/dist/auth-profile.js.map +1 -0
  5. package/dist/auth-sessions.d.ts +5 -0
  6. package/dist/auth-sessions.js +7 -0
  7. package/dist/auth-sessions.js.map +1 -0
  8. package/dist/chunk-7D4AYBAV.js +64 -0
  9. package/dist/chunk-7D4AYBAV.js.map +1 -0
  10. package/dist/chunk-LH7UO57C.js +23 -0
  11. package/dist/chunk-LH7UO57C.js.map +1 -0
  12. package/dist/chunk-PKTLVQXZ.js +82 -0
  13. package/dist/chunk-PKTLVQXZ.js.map +1 -0
  14. package/dist/chunk-SQE4NPZP.js +31 -0
  15. package/dist/chunk-SQE4NPZP.js.map +1 -0
  16. package/dist/{chunk-A4V2N4LX.js → chunk-U6V3HEBB.js} +6 -5
  17. package/dist/chunk-U6V3HEBB.js.map +1 -0
  18. package/dist/chunk-VEHNFPEO.js +224 -0
  19. package/dist/chunk-VEHNFPEO.js.map +1 -0
  20. package/dist/development.d.ts +4 -0
  21. package/dist/development.js +1 -1
  22. package/dist/game-analytics.d.ts +5 -0
  23. package/dist/game-analytics.js +7 -0
  24. package/dist/game-analytics.js.map +1 -0
  25. package/dist/game-app-id.d.ts +5 -0
  26. package/dist/game-app-id.js +7 -0
  27. package/dist/game-app-id.js.map +1 -0
  28. package/dist/game-media.d.ts +5 -0
  29. package/dist/game-media.js +7 -0
  30. package/dist/game-media.js.map +1 -0
  31. package/dist/index.js +688 -404
  32. package/dist/index.js.map +1 -1
  33. package/dist/scaffold.d.ts +8 -1
  34. package/dist/scaffold.js +6 -1
  35. package/dist/scaffold.js.map +1 -1
  36. package/package.json +8 -4
  37. package/runtime/local-network.d.mts +4 -6
  38. package/runtime/public-assets.mjs +62 -0
  39. package/runtime/source-fence.mjs +182 -0
  40. package/runtime/vite-config.d.mts +2 -1
  41. package/runtime/vite-config.mjs +6 -2
  42. package/runtime/vite-dev.mjs +18 -0
  43. package/runtime/vite-https.mjs +2 -3
  44. package/template-assets/bootstrap/AGENTS.md +56 -14
  45. package/template-assets/bootstrap/CLAUDE.md +0 -8
  46. package/template-assets/bootstrap/skills/airjam-mcp/SKILL.md +44 -0
  47. package/template-assets/bootstrap/skills/controller-ui/SKILL.md +2 -0
  48. package/template-assets/bootstrap/skills/game-architecture/SKILL.md +47 -3
  49. package/template-assets/bootstrap/skills/index.md +1 -1
  50. package/template-assets/bootstrap/skills/prefab-authoring/SKILL.md +10 -0
  51. package/template-assets/bootstrap/skills/r3f-3d-scene/SKILL.md +10 -0
  52. package/template-assets/documentation/for-agents/controller-ui/page.mdx +41 -2
  53. package/template-assets/documentation/for-agents/page.mdx +24 -2
  54. package/template-assets/documentation/for-agents/project-structure/page.mdx +0 -2
  55. package/template-assets/documentation/for-agents/state-and-rendering/page.mdx +19 -2
  56. package/template-assets/documentation/for-agents/supported-agents/page.mdx +18 -0
  57. package/template-assets/documentation/getting-started/debugging/page.mdx +7 -8
  58. package/template-assets/documentation/getting-started/dev-logs/page.mdx +0 -2
  59. package/template-assets/documentation/getting-started/game-ideas/page.mdx +1 -3
  60. package/template-assets/documentation/getting-started/introduction/page.mdx +71 -54
  61. package/template-assets/documentation/getting-started/migrating-legacy-games/page.mdx +308 -62
  62. package/template-assets/documentation/getting-started/quick-start/page.mdx +56 -79
  63. package/template-assets/documentation/how-it-works/architecture/page.mdx +91 -50
  64. package/template-assets/documentation/how-it-works/host-system/page.mdx +112 -109
  65. package/template-assets/documentation/manifest.json +112 -42
  66. package/template-assets/documentation/sdk/assets-and-theme/page.mdx +185 -0
  67. package/template-assets/documentation/sdk/hooks/page.mdx +108 -172
  68. package/template-assets/documentation/sdk/input-system/page.mdx +201 -231
  69. package/template-assets/documentation/sdk/networked-state/page.mdx +134 -52
  70. package/template-assets/documentation/sdk/settings/page.mdx +166 -0
  71. package/template-assets/documentation/sdk/ui-components/page.mdx +38 -27
  72. package/template-assets/managed/.airjam/ai-pack.json +65 -47
  73. package/template-assets/managed/docs/airjam/agent-gold-path.md +55 -7
  74. package/template-assets/managed/docs/airjam/agent-mcp.md +44 -0
  75. package/template-assets/managed/docs/airjam/composition-shell-contract.md +4 -0
  76. package/template-assets/managed/docs/airjam/debug-and-testing.md +18 -0
  77. package/template-assets/managed/docs/airjam/docs-index.md +18 -12
  78. package/template-assets/managed/docs/airjam/generated/architecture.md +91 -46
  79. package/template-assets/managed/docs/airjam/generated/assets-and-theme.md +188 -0
  80. package/template-assets/managed/docs/airjam/generated/controller-ui.md +41 -0
  81. package/template-assets/managed/docs/airjam/generated/debugging-and-logs.md +7 -6
  82. package/template-assets/managed/docs/airjam/generated/for-agents.md +24 -0
  83. package/template-assets/managed/docs/airjam/generated/game-ideas.md +1 -1
  84. package/template-assets/managed/docs/airjam/generated/host-system.md +112 -102
  85. package/template-assets/managed/docs/airjam/generated/input-system.md +199 -218
  86. package/template-assets/managed/docs/airjam/generated/introduction.md +71 -51
  87. package/template-assets/managed/docs/airjam/generated/migrating-legacy-games.md +308 -60
  88. package/template-assets/managed/docs/airjam/generated/networked-state.md +134 -50
  89. package/template-assets/managed/docs/airjam/generated/quick-start.md +56 -79
  90. package/template-assets/managed/docs/airjam/generated/sdk-hooks.md +108 -167
  91. package/template-assets/managed/docs/airjam/generated/settings.md +169 -0
  92. package/template-assets/managed/docs/airjam/generated/state-and-rendering.md +19 -0
  93. package/template-assets/managed/docs/airjam/generated/supported-agents.md +21 -0
  94. package/template-assets/managed/docs/airjam/generated/ui-components.md +38 -25
  95. package/template-assets/managed/docs/airjam/prefab-authoring.md +100 -0
  96. package/template-assets/managed/docs/airjam/preview-controllers.md +5 -2
  97. package/template-assets/managed/docs/airjam/r3f-3d-scene.md +66 -0
  98. package/template-assets/managed/docs/airjam/state-lanes-cookbook.md +15 -20
  99. package/dist/chunk-A4V2N4LX.js.map +0 -1
@@ -11,6 +11,13 @@ If you are using an LLM to help with the migration, copy this guide into the
11
11
  conversation first. Codex or Claude are the best fit for this kind of
12
12
  repo-wide migration work.
13
13
 
14
+ ## Node.js Minimum
15
+
16
+ Air Jam 1.0 authoring requires Node.js 22.15 or newer for devtools, the CLI and MCP,
17
+ create-airjam and generated projects. The declaration loader uses synchronous
18
+ module hooks to enforce its framework-free boundary through imports, `require`
19
+ and `createRequire`. The SDK and server retain their Node.js 22.0 minimum.
20
+
14
21
  ## When You Need This Guide
15
22
 
16
23
  You are likely on the old shape if your game still has some of these patterns:
@@ -60,7 +67,7 @@ Not every migrated game must match that exact folder tree.
60
67
 
61
68
  What matters is the boundary model:
62
69
 
63
- 1. `createAirJamApp(...)` defines runtime and input config
70
+ 1. `defineAirJamGame(...)` declares the game in core; `createAirJamApp(game, options)` binds its browser runtime
64
71
  2. `app.tsx` owns route-level `<airjam.Host>` and `<airjam.Controller>` wrappers
65
72
  3. host/controller runtime owner hooks mount only in those route entry files
66
73
  4. replicated state uses the current `createAirJamStore` action contract
@@ -107,16 +114,27 @@ export function App() {
107
114
 
108
115
  Target shape:
109
116
 
110
- ```tsx filename="src/airjam.config.ts"
111
- import { createAirJamApp, env } from "@air-jam/sdk";
112
- import { gameInputSchema } from "./game/input";
113
-
114
- export const airjam = createAirJamApp({
115
- runtime: env.vite(import.meta.env),
116
- controllerPath: "/controller",
117
- input: {
118
- schema: gameInputSchema,
117
+ ```ts filename="src/airjam.config.ts"
118
+ import { defineAirJamGame } from "@air-jam/sdk/core";
119
+ import { gameInput } from "./game/input";
120
+ import { simulation } from "./game/simulation";
121
+
122
+ export const airjam = defineAirJamGame({
123
+ metadata: {
124
+ slug: "space-game",
125
+ name: "Space Game",
126
+ tagline: "Fly together and defend the fleet.",
127
+ category: "arcade",
128
+ minPlayers: 1,
129
+ maxPlayers: 4,
130
+ inputModalities: ["buttons", "touch"],
131
+ supportedSdkRange: "^1.0.0",
132
+ maintainer: { name: "Air Jam" },
133
+ version: 1,
119
134
  },
135
+ controllerPath: "/controller",
136
+ simulation,
137
+ input: gameInput,
120
138
  });
121
139
  ```
122
140
 
@@ -137,7 +155,10 @@ Target shape:
137
155
 
138
156
  ```tsx filename="src/app.tsx"
139
157
  import { Route, Routes } from "react-router-dom";
140
- import { airjam } from "./airjam.config";
158
+ import { createAirJamApp, env } from "@air-jam/sdk";
159
+ import { airjam as game } from "./airjam.config";
160
+
161
+ const airjam = createAirJamApp(game, { runtime: env.vite(import.meta.env) });
141
162
 
142
163
  export function App() {
143
164
  return (
@@ -208,10 +229,8 @@ actions: {
208
229
  Controller-side dispatch should always look like:
209
230
 
210
231
  ```tsx filename="src/routes/controller-view.tsx"
211
- const actions = useGameStore.useActions();
212
-
213
- actions.joinTeam({ team: "team1" });
214
- actions.setReady({ ready: true });
232
+ gameStore.actions.joinTeam({ team: "team1" });
233
+ gameStore.actions.setReady({ ready: true });
215
234
  ```
216
235
 
217
236
  Do not keep trailing `playerId` arguments around.
@@ -284,13 +303,14 @@ The migration guide is about boundaries, not folder cosplay.
284
303
 
285
304
  ### Branch C: Host-Simulation-Heavy App
286
305
 
287
- If most of the game logic lives in a host-side hook or engine module, keep that boundary explicit:
306
+ If most of the game logic lives in a host-side hook or `useHostTick` loop, move it into a declared simulation (`defineAirJamSimulation`, declared with `defineAirJamGame({ simulation })`). `useHostTick` is removed.
288
307
 
289
308
  1. replicated store state owns shared, synchronized state
290
- 2. host-local hook/engine owns timers, refs, physics, media loading, and simulation details
291
- 3. only the minimum necessary state should cross between them
309
+ 2. the simulation owns timers, positions, physics and outcomes; it reads input from its step context, uses the step's `random` and game time instead of `Math.random()` and `Date.now()`, and dispatches store actions for outcomes such as scores
310
+ 3. the host view draws with `useSimulationFrame`, plays sounds and toasts from `useSimulationEvents`, and keeps media loading and draw caches
311
+ 4. what agents see moves from `useHostAgentObservation` into the simulation's `observe`
292
312
 
293
- This is usually cleaner than trying to stuff the whole game loop into the replicated store.
313
+ This is usually cleaner than trying to stuff the whole game loop into the replicated store, and it lets the game's tests run headless.
294
314
 
295
315
  ## Step 6: Migrate Input Based On Input Type
296
316
 
@@ -298,46 +318,35 @@ Do not overgeneralize input migration.
298
318
 
299
319
  ### Continuous Input Games
300
320
 
301
- If your controller sends directional or analog-style input every frame, prefer:
321
+ If your controller sends directional or analog-style input, declare those
322
+ controls and let the SDK's phone controls send them:
302
323
 
303
- 1. local refs/state
304
- 2. `useInputWriter()`
305
- 3. `useControllerTick(...)`
324
+ ```tsx filename="src/game/input.ts"
325
+ import { button, defineAirJamInput, stick } from "@air-jam/sdk/core";
306
326
 
307
- Example:
327
+ export const gameInput = defineAirJamInput({
328
+ move: stick(),
329
+ action: button("held"),
330
+ });
331
+ ```
308
332
 
309
- ```tsx filename="src/routes/controller-view.tsx"
310
- import {
311
- useAirJamController,
312
- useControllerTick,
313
- useInputWriter,
314
- } from "@air-jam/sdk";
315
- import { useRef } from "react";
333
+ ```tsx filename="src/controller/index.tsx"
334
+ import { ControlButton, Stick } from "@air-jam/sdk/ui";
335
+ import { gameInput } from "../game/input";
316
336
 
317
337
  export function ControllerView() {
318
- const controller = useAirJamController();
319
- const writeInput = useInputWriter();
320
- const movementRef = useRef({ x: 0, y: 0 });
321
- const actionRef = useRef(false);
322
-
323
- useControllerTick(
324
- () => {
325
- writeInput({
326
- movementX: movementRef.current.x,
327
- movementY: movementRef.current.y,
328
- action: actionRef.current,
329
- });
330
- },
331
- {
332
- enabled:
333
- controller.connectionStatus === "connected" &&
334
- controller.runtimeState === "playing",
335
- intervalMs: 16,
336
- },
338
+ return (
339
+ <div className="grid h-full grid-cols-2 gap-3 p-3">
340
+ <Stick control={gameInput.move} />
341
+ <ControlButton control={gameInput.action}>Action</ControlButton>
342
+ </div>
337
343
  );
338
344
  }
339
345
  ```
340
346
 
347
+ The simulation reads them each step with `input(playerId)`. Remove the old
348
+ send loop, input writer and any timestamp field.
349
+
341
350
  ### Action-Only Or Choice-Driven Games
342
351
 
343
352
  If the controller mainly sends taps, choices, or store actions, do not add per-frame input machinery just because another game needed it.
@@ -346,17 +355,13 @@ Use the simpler model that matches your game.
346
355
 
347
356
  For more input details, see [Input System](./input-system.md).
348
357
 
349
- ## Step 7: Clean Up Old `latch` Usage Carefully
350
-
351
- Older games may still configure input through `latch`.
358
+ ## Step 7: Replace `latch` And Input Behavior Lists
352
359
 
353
- For most games, the right migration is smaller than you think:
354
-
355
- - move the schema into `airjam.config.ts`
356
- - remove `latch` entirely
357
- - keep the default input behavior unless you have a real non-default need
358
-
359
- Only add `input.behavior` overrides when the defaults are not enough.
360
+ Older games configure input through `latch` or `input.behavior` lists of
361
+ `pulse`, `hold` and `latest` fields. Both are gone: each control's kind carries
362
+ its meaning. A tap-safe boolean becomes `button("pressed")`, a held boolean
363
+ `button("held")`, a sticky vector `stick({ keepDirection: true })`, and any
364
+ other number an `axis()`.
360
365
 
361
366
  ## Step 8: Remove Legacy Workarounds
362
367
 
@@ -417,6 +422,249 @@ That order usually sharpens the guide fastest:
417
422
  2. second app forces the harder boundary decisions
418
423
  3. third app benefits from the refined guide and should migrate more cleanly
419
424
 
425
+ ## From 0.9 To 1.0
426
+
427
+ Games written against the 0.9 SDK, including agent-made Studio games, move
428
+ mechanically with the mappings below. Each removal fails typecheck, so work
429
+ through the compiler errors with this section open.
430
+
431
+ ### The game is declared in core
432
+
433
+ `src/airjam.config.ts` exports only the named `airjam = defineAirJamGame(...)`
434
+ declaration from `@air-jam/sdk/core`. Move metadata into its `metadata` field;
435
+ remove the separate metadata export. Its entire import graph must stay free of
436
+ React, the SDK root, TSX and CSS. The loader names the importing file with
437
+ `AJ_DECLARATION_NOT_FRAMEWORK_FREE` when that boundary is crossed.
438
+
439
+ Move `createAirJamApp` to `app.tsx` and call
440
+ `createAirJamApp(airjam, { runtime: env.vite(import.meta.env) })`. The binding
441
+ returns `Host`, `Controller`, `paths` and `session`; game data stays on the
442
+ declaration. Passing the former options object as the first argument fails
443
+ with an error naming `defineAirJamGame` as its replacement.
444
+
445
+ Import agent helpers and their types from `@air-jam/sdk/core`. A declared
446
+ `testing` path, relative to the config, names the development module:
447
+
448
+ ```ts
449
+ import { defineAirJamTesting } from "@air-jam/devtools/testing";
450
+ import { gamePlayer } from "./player";
451
+
452
+ export const testing = defineAirJamTesting({
453
+ player: gamePlayer,
454
+ profiles: { scoring, diagnostics },
455
+ // Optional: visual: { scenarios: [...] }, using the game's declared agent.
456
+ });
457
+ ```
458
+
459
+ The declared player is offered as `model` in every profile. Remove each
460
+ profile's manually created model policy; the name is reserved and fails with
461
+ `AJ_TEST_POLICY_RESERVED` when authored. Visual packs no longer declare their
462
+ own agent. Tools read the game through `airjam.inspect_game` and its
463
+ `declaration.agent` field.
464
+
465
+ Remove capacity from runtime options. `metadata.maxPlayers` is the capacity
466
+ for both browser and headless rooms: a four-player game refuses a fifth phone.
467
+ Remove identity fields from `airjam-template.json`; it now holds only scaffold
468
+ and export flags. Regenerate template catalogs after changing declarations.
469
+
470
+ ### Stores Are Plain Objects
471
+
472
+ `createAirJamStore` moved to `@air-jam/sdk/core` and returns a store object,
473
+ not a hook. Declare every store in the app; reading an undeclared store throws
474
+ `AJ_STORE_NOT_DECLARED`.
475
+
476
+ ```ts
477
+ // 0.9
478
+ import { createAirJamStore } from "@air-jam/sdk";
479
+ export const useGameStore = createAirJamStore<GameState>((set) => ({ ... }));
480
+
481
+ // 1.0
482
+ import { createAirJamStore } from "@air-jam/sdk/core";
483
+ export const gameStore = createAirJamStore<GameState>((set) => ({ ... }));
484
+ // airjam.config.ts
485
+ defineAirJamGame({ stores: [gameStore], ... });
486
+ ```
487
+
488
+ | 0.9 | 1.0 |
489
+ | --------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------- |
490
+ | `useGameStore((s) => s.score)` | `useAirJamStore(gameStore, (s) => s.score)` from `@air-jam/sdk` |
491
+ | `useGameStore.useActions().joinTeam(...)` | `gameStore.actions.joinTeam(...)` |
492
+ | `useGameStore.asPlayer(id)` | `gameStore.asPlayer(id)` |
493
+ | `useGameStore.getState()`, `.subscribe` | `gameStore.getState()`, `gameStore.subscribe` |
494
+ | `useGameStore.useHostActionListener(listener)` | `useHostActionListener(gameStore, listener)` from `@air-jam/sdk` |
495
+ | `useGameStore.useLiveStateRef().current` | `gameStore.getState()`, always current |
496
+ | `acceptAirJamAction`, `rejectAirJamAction`, `AirJamActionContext` and the other store types from `@air-jam/sdk` | the same names from `@air-jam/sdk/core` |
497
+ | `createAirJamStore(init, { storeDomain })` | unchanged, from `@air-jam/sdk/core` |
498
+ | `Date.now()` inside an action | `ctx.now`, the game time the action runs at |
499
+
500
+ Shells that compose runtimes themselves, such as the Arcade, pass their
501
+ stores to `AirJamHostRuntime` and `AirJamControllerRuntime` from
502
+ `@air-jam/sdk/arcade/runtime` with the `stores` prop.
503
+
504
+ ### Settings are declared
505
+
506
+ Move tunable speed, force, damage, health, duration and count constants into
507
+ `defineAirJamSettings` from `@air-jam/sdk/core`, and pass the result as the
508
+ `settings` field of `defineAirJamGame`. Keep a leaf settings module and infer
509
+ its values with `AirJamSettingsValues<typeof gameSettings>`. Delete the old
510
+ constants. Lobby choices remain store state.
511
+
512
+ Read `settings` in simulation create, step and observe contexts, and in
513
+ `AirJamActionContext<GameSettings>`. Supply the fourth simulation type parameter
514
+ for typed values. Host drawing uses `useAirJamSettings(gameSettings)`; copy any
515
+ phone display values into the store rather than reading settings on controllers.
516
+
517
+ Only settings declared `live: true` can change during a host's lifetime.
518
+ `airjam.read_game_settings` returns the current values and revision;
519
+ `airjam.update_game_settings` takes an atomic patch and `expectedRevision`.
520
+ Unknown, invalid, stale and non-live updates fail with `AJ_SETTING_UNKNOWN`,
521
+ `AJ_SETTING_INVALID`, `AJ_SETTING_STALE` and `AJ_SETTING_NOT_LIVE` respectively.
522
+ Start a new room through `airjam.start_game_run({ settings: { ... }, ... })`
523
+ for a non-live value. Input logs now require version 2, resolved initial
524
+ settings and the ordered settings events; version 1 logs must be recorded again.
525
+
526
+ See [Game Settings](./settings.md) for declarations, host hooks and CLI
527
+ commands.
528
+
529
+ ### Assets and theme are declared
530
+
531
+ Move sound manifests into `defineAirJamAssets` from `@air-jam/sdk/core` and
532
+ pass the result as `assets` in `defineAirJamGame`. Import `SoundConfig` from
533
+ `@air-jam/sdk/core`. Declare images and other loaded files there too, using
534
+ served paths under `public/`. Read their paths
535
+ from the object and remove old manifests and path imports. Use sound `surface`
536
+ marks for host-only or controller-only audio. Remove game-owned `<AudioRuntime>`
537
+ mounts; the binding supplies it on each surface. Keep playlist and playback
538
+ logic inside that binding.
539
+
540
+ Move colours and font families into `defineAirJamTheme` and pass it as `theme`.
541
+ Map existing Tailwind names to `--airjam-color-*` and `--airjam-font-*` with
542
+ `@theme inline`. Canvas and 3D drawing read the same theme object. Remove
543
+ repeated colour and font literals; shadows and gradients remain CSS.
544
+ Inspection now fails `AJ_ASSET_MISSING` for a declared file that is absent.
545
+
546
+ See [Game Assets and Theme](./assets-and-theme.md) for the complete shapes.
547
+
548
+ ### The SDK Owns The Loop
549
+
550
+ `useHostTick` is removed. Per-step game logic moves into a declared
551
+ simulation; components only draw it.
552
+
553
+ ```tsx
554
+ // 0.9
555
+ useHostTick({
556
+ mode: "fixed",
557
+ intervalMs: 16,
558
+ onTick: ({ deltaSeconds }) => stepGame(world, deltaSeconds),
559
+ });
560
+
561
+ // 1.0: src/game/simulation.ts
562
+ export const simulation = defineAirJamSimulation<World, GameInput, GameEvent>({
563
+ stepMs: 16,
564
+ create: ({ random }) => createWorld(random),
565
+ step: (world, { dtSeconds, input, players, random, emit }) =>
566
+ stepGame(world, dtSeconds),
567
+ observe: (world) => ({ score: world.score }),
568
+ });
569
+ // airjam.config.ts
570
+ defineAirJamGame({ simulation, ... });
571
+ ```
572
+
573
+ | 0.9 | 1.0 |
574
+ | -------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------ |
575
+ | `useHostTick({ onTick })` | the simulation's `step` |
576
+ | `useHostTick({ onFrame })`, `fixedStepAlpha` | `useSimulationFrame(({ sim, alpha }) => draw(sim, alpha))` |
577
+ | `HostTickInfo.deltaSeconds`, `.tick` | the step context's `dtSeconds`, `tick` |
578
+ | `Math.random()` in game logic | the step context's `random` |
579
+ | `useHostAgentObservation({ read, capture })` | `read` becomes the simulation's `observe`; `useHostAgentCapture(draw)` draws into the supplied canvas, and its returned function runs after the game renders |
580
+ | UI state derived from the world | `useSimulationSelector((sim) => value)` |
581
+ | one-off feedback such as sounds | `emit` in `step`, `useSimulationEvents` in a component |
582
+
583
+ ### Input Is Declared
584
+
585
+ The `input: { schema, behavior }` config, controller send loops and the host's
586
+ `getInput` are removed. A game declares its controls, the SDK's phone controls
587
+ send them, and the simulation reads them each step.
588
+
589
+ ```tsx
590
+ // 0.9: src/game/contracts/input.ts
591
+ export const gameInputSchema = z.object({ direction: z.number(), fire: z.boolean() });
592
+ // airjam.config.ts
593
+ createAirJamApp({ input: { schema: gameInputSchema, behavior: { pulse: ["fire"] } }, ... });
594
+ // controller
595
+ const writeInput = useInputWriter();
596
+ useControllerTick(() => writeInput({ direction: directionRef.current, fire: fireRef.current }), {
597
+ intervalMs: 16,
598
+ });
599
+ <button onPointerDown={() => (directionRef.current = -1)} onPointerUp={() => (directionRef.current = 0)}>Up</button>
600
+ // host
601
+ const { direction, fire } = host.getInput(playerId) ?? { direction: 0, fire: false };
602
+
603
+ // 1.0: src/game/contracts/input.ts
604
+ import { axis, button, defineAirJamInput } from "@air-jam/sdk/core";
605
+ export const gameInput = defineAirJamInput({ direction: axis(), fire: button("pressed") });
606
+ // airjam.config.ts
607
+ defineAirJamGame({ input: gameInput, simulation, ... });
608
+ // controller
609
+ import { AxisButton, ControlButton } from "@air-jam/sdk/ui";
610
+ <AxisButton control={gameInput.direction} value={-1}>Up</AxisButton>
611
+ <ControlButton control={gameInput.fire}>Fire</ControlButton>
612
+ // simulation step
613
+ step: (sim, { input, players }) => {
614
+ for (const player of players) {
615
+ const { direction, fire } = input(player.id);
616
+ }
617
+ },
618
+ ```
619
+
620
+ | 0.9 | 1.0 |
621
+ | --------------------------------------------------------- | ------------------------------------------------------------------------------ |
622
+ | a boolean in `behavior.pulse` or `latch` | `button("pressed")`: true for exactly one step per press |
623
+ | any other boolean | `button("held")` |
624
+ | a number from -1 to 1 | `axis()`, sent by `AxisButton` with a `value` |
625
+ | a `{ x, y }` vector | `stick()`, or `stick({ keepDirection: true })` for a vector in `behavior.hold` |
626
+ | a timestamp or sequence field | nothing: the SDK orders input by step |
627
+ | buttons with pointer handlers writing refs | `ControlButton`, `AxisButton` and `Stick`, styled through `data-active` |
628
+ | `useInputWriter` and `useControllerTick` send loops | nothing: the controller runtime sends on change, once per frame |
629
+ | `host.getInput(playerId)` or `useGetInput` in a host tick | `input(playerId)` in the simulation's `step`; it always returns every control |
630
+ | `z.infer<typeof gameInputSchema>` | `AirJamInputValues<typeof gameInput>` from `@air-jam/sdk/core` |
631
+
632
+ Choices, menus and other taps that are not per-step play stay store actions.
633
+
634
+ ### Removed Exports
635
+
636
+ These exports are gone; use the replacement.
637
+
638
+ | Removed | Use instead |
639
+ | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
640
+ | `@air-jam/sdk/arcade`, `@air-jam/sdk/arcade/bridge` | the leaf that owns the concept, such as `@air-jam/sdk/arcade/bridge/host` |
641
+ | `useHostTick`, `HostTickInfo`, `HostTickOptions`, `HostFrameInfo` | a declared simulation, above |
642
+ | `useHostAgentObservation` | the simulation's `observe` and `useHostAgentCapture` |
643
+ | `AirJamSyncedStoreHook` | `AirJamStore` from `@air-jam/sdk/core` |
644
+ | `useConnectionStatus()` | `useAirJamHost((s) => s.connectionStatus)` or `useAirJamController((s) => s.connectionStatus)` |
645
+ | `usePlayers()` | `useAirJamHost((s) => s.players)` |
646
+ | `isActiveMatchPhase`, `isEndedMatchPhase`, `isStandardMatchPhase`, `standardMatchPhases` | compare the phase directly; `toShellMatchPhase` stays |
647
+ | `AirJamErrorBoundary`, `PlatformSettingsBoundary` | nothing: `createAirJamApp` and the session runtimes mount both |
648
+ | `getEffectiveAudioVolume`, `useAudioCategoryVolume`, `mergeRoomPlatformSettingsSnapshot` | `useMusicVolume`, `useAirJamSurfaceSettings` |
649
+ | `parseAirJamGameMetadata` | `airJamGameMetadataSchema.safeParse` |
650
+ | `RoomCode`, `RunMode`, `SignalPayload`, `SignalType`, `ControllerStatePayload`, `ControllerUpdatePlayerProfileAck`, `AirJamActionAccepted`, `AirJamActionRejected` from `@air-jam/sdk` | the same types from `@air-jam/sdk/protocol` |
651
+ | `isInternalActionName`, `resolveControllerJoinSource`, `JoinUrlStatus` from `@air-jam/sdk/core` | internal; `JoinUrlStatus` comes from `@air-jam/sdk` |
652
+ | `buttonVariants`, `getPlayerAvatarImageUrl`, `resolvePlayerAvatarSeed` from `@air-jam/sdk/ui` | `Button`, `PlayerAvatar` |
653
+ | `useInputWriter`, `useControllerTick`, `ControllerTickInfo`, `ControllerTickOptions` | declared controls and the SDK's phone controls, above |
654
+ | `useGetInput`, the host's `getInput` | `input(playerId)` in a simulation step |
655
+
656
+ Tool and platform paths also dropped helpers only the SDK itself used:
657
+ `arcade/bridge/controller` (`AIRJAM_CONTROLLER_BRIDGE_RESPONSE`,
658
+ `AIRJAM_CONTROLLER_PRESENTATION_SYNC`, `createControllerPresentationSyncMessage`,
659
+ `parseControllerBridgeResponseMessage`), `arcade/bridge/host`
660
+ (`AIRJAM_HOST_BRIDGE_RESPONSE`), `arcade/bridge/iframe` (the bridge init and
661
+ settings sync messages), `arcade/surface` (implicit store domain resolution),
662
+ `arcade/url` (`urlBuilder`, `arcadeSurfaceRuntimeUrlParams`, which stays in
663
+ `arcade/surface`), `controller-bridge`, `preview`, `runtime-control`,
664
+ `runtime-inspection`, `agent-tooling` and `metadata`. The
665
+ [architecture guide](./architecture.md) lists what each path
666
+ keeps.
667
+
420
668
  ## Related Docs
421
669
 
422
670
  1. [Quick Start](./quick-start.md)