@jgengine/shell 0.9.0 → 0.10.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 (49) hide show
  1. package/CHANGELOG.md +21 -1
  2. package/dist/GamePlayerShell.d.ts +6 -21
  3. package/dist/GamePlayerShell.js +419 -234
  4. package/dist/audio/audioEngine.d.ts +8 -0
  5. package/dist/audio/audioEngine.js +33 -0
  6. package/dist/audio/musicDirector.d.ts +31 -0
  7. package/dist/audio/musicDirector.js +125 -0
  8. package/dist/audio/musicVoices.d.ts +10 -0
  9. package/dist/audio/musicVoices.js +338 -0
  10. package/dist/audio/synthEngine.d.ts +9 -0
  11. package/dist/audio/synthEngine.js +57 -0
  12. package/dist/camera/GameFirstPersonCamera.d.ts +3 -0
  13. package/dist/camera/GameFirstPersonCamera.js +21 -4
  14. package/dist/camera/GameInspectionCamera.js +12 -1
  15. package/dist/camera/GameOrbitCamera.js +35 -1
  16. package/dist/camera/orbitCameraMath.d.ts +18 -0
  17. package/dist/camera/orbitCameraMath.js +6 -1
  18. package/dist/cartridge.js +1 -0
  19. package/dist/commandSink.d.ts +20 -0
  20. package/dist/commandSink.js +27 -0
  21. package/dist/defineGame.js +3 -1
  22. package/dist/devtools/CollisionDebugWorld.js +1 -0
  23. package/dist/devtools/collisionDebugMath.d.ts +1 -0
  24. package/dist/devtools/collisionDebugMath.js +2 -1
  25. package/dist/environment/Daylight.d.ts +7 -1
  26. package/dist/environment/Daylight.js +52 -5
  27. package/dist/environment/EnvironmentScene.js +14 -5
  28. package/dist/environment/RoadRibbons.d.ts +7 -0
  29. package/dist/environment/RoadRibbons.js +57 -0
  30. package/dist/inputSink.d.ts +18 -0
  31. package/dist/inputSink.js +35 -0
  32. package/dist/multiplayer.js +7 -3
  33. package/dist/postfx/PostProcessing.d.ts +10 -0
  34. package/dist/postfx/PostProcessing.js +82 -0
  35. package/dist/postfx/gradeShader.d.ts +4 -0
  36. package/dist/postfx/gradeShader.js +64 -0
  37. package/dist/terrain/CarvedTerrain.d.ts +4 -1
  38. package/dist/terrain/CarvedTerrain.js +4 -3
  39. package/dist/terrain/terrainDetailMaterial.d.ts +14 -0
  40. package/dist/terrain/terrainDetailMaterial.js +90 -0
  41. package/dist/touch/TouchControlsOverlay.js +11 -1
  42. package/dist/world/WorldHud.d.ts +3 -1
  43. package/dist/world/WorldHud.js +7 -7
  44. package/dist/world/worldBarSamples.d.ts +1 -1
  45. package/dist/world/worldBarSamples.js +7 -1
  46. package/dist/worldSync.d.ts +10 -0
  47. package/dist/worldSync.js +19 -0
  48. package/llms.txt +140 -22
  49. package/package.json +4 -4
package/CHANGELOG.md CHANGED
@@ -11,7 +11,27 @@ Agents building on the published SDK can also read this programmatically:
11
11
  same data as typed values, so an updater can diff its installed version against
12
12
  the latest and surface the migration steps.
13
13
 
14
- ## Unreleased
14
+ ## 0.10.0
15
+
16
+ ### Migrate
17
+
18
+ - **Nothing to change for existing games** — the shared mobile-composition system (viewport allocation, region collision, `--jg-*` viewport vars) is wired automatically by the shell for every game; `HudPanel`s inside a `HudCanvas` register themselves. Legacy `orientation: "landscape" | "portrait"` keeps its advisory dismissible-hint behavior unchanged.
19
+ - **Opt a driving/landscape game into the strict gate**: replace the advisory `orientation` with the contract form — `orientation: { mobile: "landscape-required" }` (rules: `any` · `portrait`/`landscape` advisory · `portrait-required`/`landscape-required` · `unsupported`). In portrait the engine now shows a polished `RotateDeviceScreen`, suppresses input, freezes the sim, and unmounts the HUD/controls until the device is landscape.
20
+ - **Declare HUD intent** where useful: `HudPanel` gains `priority` (`critical`/`secondary`/`tertiary`), `mobileBehavior` (`hidden` unmounts on phones, `transient` softens collision, …), `allowOverlapWith`, and `collisionGroup`. Optional — omitting them keeps prior behavior.
21
+ - **Mobile validation now also fails on overlap**: `bun run shoot <game> --device mobile|mobile-landscape|both` exits non-zero on forbidden inter-element collisions (not just viewport overflow), naming both regions.
22
+
23
+ ### Added
24
+
25
+ - Shared mobile layout composition — `@jgengine/core/ui/gameLayout` (pure geometry: `resolveLayoutMode`, `intersects`, `overlapArea`, `detectLayoutCollisions`, `computeGameplayRect`, `LayoutRegion`, `GameViewportLayout`) and `@jgengine/core/ui/orientation` (`resolveOrientationRequirement`, `orientationGateActive`, `MobileOrientationRule`). `@jgengine/react` adds `GameViewportProvider` (mounted by the shell), hooks (`useGameViewportLayout`, `useGameLayoutMode`, `useGameOrientation`, `useReservedControlZones`, `useLayoutCollisions`, `useRegisterLayoutRegion`), and a headless `RotateDeviceScreen`. The provider tracks `window.visualViewport`, publishes `--jg-viewport-*` / `--jg-visual-viewport-*` / `--jg-safe-*` CSS vars, resolves the explicit layout mode, and detects forbidden region overlaps (dev `data-jg-layout-collision` + console diagnostic).
26
+ - Mandatory orientation contract — `PlayableGame.orientation` accepts `{ mobile: <rule> }`; `landscape-required`/`portrait-required` render an engine-owned rotate gate that blocks gameplay (input suppressed, simulation frozen, HUD/controls unmounted), self-correcting when the device is turned. Reduced-motion and safe-area respected; `visualViewport`-sized for mobile Safari/PWA.
27
+ - Reserved touch-control zones — the touch dock registers its joystick / action-cluster / utility rectangles (runtime-measured) as `control` regions, so HUD placement and collision validation know exactly where controls sit.
28
+ - HUD placement metadata — `HudPanel` gains `priority`, `mobileBehavior`, `allowOverlapWith`, `collisionGroup`, and registers as a collision-tracked layout region.
29
+ - Mobile-landscape shoot device — `bun run shoot --device mobile-landscape` (844×390) plus collision-gate reads that fail mobile validation on forbidden overlaps.
30
+ - Canyon Chase migrated as the reference landscape-required game — declares `orientation: { mobile: "landscape-required" }`, composes its HUD through coordinated `HudPanel` regions (pursuit distance critical, border secondary, survey map hidden on mobile, radio transient) instead of independent fixed corners.
31
+
32
+ ### Changed
33
+
34
+ - First-person projectile tracers now originate from the weapon muzzle instead of the camera/eye centerline. Hit detection is unchanged (still crosshair-accurate) — only the drawn tracer's start point moved to the viewmodel muzzle, which tracks full aim yaw and pitch. Non-viewmodel games and enemy tracers are unaffected.
15
35
 
16
36
  ## 0.9.0
17
37
 
@@ -1,11 +1,8 @@
1
1
  import { type ActionStateTracker } from "@jgengine/core/input/actionBindings";
2
2
  import type { Aim } from "@jgengine/core/scene/spatial";
3
- import { type CollisionObstacle, type MovementTuningOverrides } from "@jgengine/core/movement/movementModel";
4
- import type { PhysicsConfig } from "@jgengine/core/game/defineGame";
5
3
  import { type GameContext } from "@jgengine/core/runtime/gameContext";
6
- import { type MotionIntentBatch } from "@jgengine/core/runtime/motionIntents";
4
+ import { type CommandSink } from "./commandSink.js";
7
5
  import type { SkyEnvironmentDescriptor, WorldFeature } from "@jgengine/core/world/features";
8
- import { type SceneObject } from "@jgengine/core/scene/objectStore";
9
6
  import type { ShellMultiplayer } from "./multiplayer.js";
10
7
  import type { PlayableGame } from "./registry.js";
11
8
  /** Actions from `input` currently held down, for `ctx.input.publish` (#164.1); includes reserved movement/jump actions. */
@@ -13,25 +10,13 @@ export declare function heldActionsFor(tracker: Pick<ActionStateTracker<string>,
13
10
  /** Whether a bound action should fire this frame: on press, or on repeat interval while held (shared by `FrameDriver` and `HudOnlyDriver`). */
14
11
  export declare function shouldFireBoundAction(tracker: Pick<ActionStateTracker<string>, "isDown" | "wasPressed">, action: string, input: PlayableGame["game"]["input"], repeatFiredAt: ReadonlyMap<string, number>, now: number): boolean;
15
12
  /** Resolves and runs the command bound to `action` via the shell's action→command convention (shared by `FrameDriver` and `HudOnlyDriver`). */
16
- export declare function dispatchBoundAction(ctx: GameContext, action: string, yaw: number, pitch: number, aim: Aim): void;
17
- /** Placed scene objects within `radius` of `center`, as `CollisionObstacle`s for `resolveObstacleStep` (#162.1). */
18
- export declare function nearbyObstacles(objects: readonly SceneObject[], center: readonly [number, number, number], radius?: number): CollisionObstacle[];
19
- /** Applies a pending `MotionIntentBatch` to a vertical velocity: impulses add, then `verticalVelocity` replaces the result outright (#162.4). */
20
- export declare function applyMotionImpulses(currentVelocity: number, batch: MotionIntentBatch | null): number;
13
+ export declare function dispatchBoundAction(ctx: GameContext, action: string, yaw: number, pitch: number, aim: Aim, reserved?: ReadonlySet<string>, sink?: CommandSink): void;
14
+ export { applyMotionImpulses } from "@jgengine/core/runtime/motionIntents";
15
+ export { nearbyObstacles } from "@jgengine/core/movement/movementModel";
16
+ export { resolvePhysicsTuning } from "@jgengine/core/movement/playerMovement";
17
+ export { hasEnvironmentTerrain } from "@jgengine/core/world/terrain";
21
18
  /** The world's declared sky, when its world feature is an environment with one (#196.1). */
22
19
  export declare function resolveWorldSky(world: WorldFeature | undefined): SkyEnvironmentDescriptor | undefined;
23
- /**
24
- * Maps the game's declared `physics` onto the movement controllers' tuning
25
- * overrides. `PhysicsConfig.gravity` is a signed world acceleration (negative
26
- * points down, matching every game's config and the Y-up convention), but the
27
- * controllers integrate `velocityY -= gravityAcceleration * dt` and so expect a
28
- * positive downward magnitude. Negating here is what keeps a down-pointing
29
- * gravity pulling the player *down*; passing the signed value straight through
30
- * flipped the sign and launched airborne players upward instead.
31
- */
32
- export declare function resolvePhysicsTuning(physics: PhysicsConfig | undefined): MovementTuningOverrides | undefined;
33
- /** True when the world is an environment feature with terrain, so the voxel controller should sample its height. */
34
- export declare function hasEnvironmentTerrain(world: WorldFeature | undefined): boolean;
35
20
  export declare function GamePlayerShell({ playable, multiplayer: rawMultiplayer, poster, onContextReady, }: {
36
21
  playable: PlayableGame;
37
22
  multiplayer?: ShellMultiplayer | null;