@jgengine/shell 0.19.0 → 0.21.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 (203) hide show
  1. package/CHANGELOG.md +346 -0
  2. package/dist/GameHost.d.ts +12 -1
  3. package/dist/GameHost.js +14 -1
  4. package/dist/GamePlayerShell.js +113 -15
  5. package/dist/Shell3dPresentation.d.ts +2 -2
  6. package/dist/Shell3dPresentation.js +49 -7
  7. package/dist/ShellChrome.d.ts +2 -1
  8. package/dist/ShellChrome.js +22 -6
  9. package/dist/ShellHudPresentation.d.ts +11 -1
  10. package/dist/ShellHudPresentation.js +20 -6
  11. package/dist/audio/audioEngine.d.ts +16 -0
  12. package/dist/audio/audioEngine.js +178 -89
  13. package/dist/audio/audioWire.js +2 -2
  14. package/dist/audio/synthEngine.d.ts +7 -1
  15. package/dist/audio/synthEngine.js +103 -38
  16. package/dist/camera/GameCameraRig.js +2 -1
  17. package/dist/camera/GameFirstPersonCamera.d.ts +2 -2
  18. package/dist/camera/GameFirstPersonCamera.js +17 -13
  19. package/dist/camera/cameraRigs.js +8 -2
  20. package/dist/camera/chaseHeading.d.ts +9 -0
  21. package/dist/camera/chaseHeading.js +10 -0
  22. package/dist/camera/customMuzzle.d.ts +14 -0
  23. package/dist/camera/customMuzzle.js +68 -0
  24. package/dist/camera/index.d.ts +1 -0
  25. package/dist/camera/index.js +1 -0
  26. package/dist/camera/rigResolve.d.ts +3 -0
  27. package/dist/camera/rigResolve.js +11 -0
  28. package/dist/combat/ProjectileModels.d.ts +31 -0
  29. package/dist/combat/ProjectileModels.js +70 -0
  30. package/dist/commandSink.d.ts +1 -2
  31. package/dist/commandSink.js +3 -2
  32. package/dist/defineGame.d.ts +12 -5
  33. package/dist/defineGame.js +24 -9
  34. package/dist/devtools/DevtoolsOverlay.d.ts +2 -69
  35. package/dist/devtools/DevtoolsOverlay.js +14 -168
  36. package/dist/devtools/DevtoolsRuntime.d.ts +7 -0
  37. package/dist/devtools/DevtoolsRuntime.js +61 -0
  38. package/dist/devtools/agentBridge.js +1 -1
  39. package/dist/devtools/devtoolsReports.d.ts +68 -0
  40. package/dist/devtools/devtoolsReports.js +100 -0
  41. package/dist/devtools/latencyInstrumentation.d.ts +3 -0
  42. package/dist/devtools/latencyInstrumentation.js +11 -0
  43. package/dist/devtools/playtestProbe.d.ts +4 -0
  44. package/dist/devtools/playtestProbe.js +22 -0
  45. package/dist/drivers/FrameDriver.js +25 -21
  46. package/dist/drivers/HudOnlyDriver.d.ts +6 -1
  47. package/dist/drivers/HudOnlyDriver.js +32 -14
  48. package/dist/environment/EnvironmentScene.js +11 -10
  49. package/dist/inputSink.d.ts +6 -6
  50. package/dist/inputSink.js +60 -21
  51. package/dist/lazyShell3dPresentation.d.ts +9 -0
  52. package/dist/lazyShell3dPresentation.js +24 -0
  53. package/dist/materialOverride.d.ts +42 -0
  54. package/dist/materialOverride.js +95 -36
  55. package/dist/multiplayer.d.ts +33 -3
  56. package/dist/multiplayer.js +105 -22
  57. package/dist/pointer/pointerService.d.ts +2 -0
  58. package/dist/pointer/pointerService.js +12 -2
  59. package/dist/postfx/PostProcessing.d.ts +10 -0
  60. package/dist/postfx/PostProcessing.js +9 -41
  61. package/dist/postfx/gradeShader.d.ts +1 -1
  62. package/dist/postfx/gradeShader.js +30 -2
  63. package/dist/postfx/shadowPrepass.d.ts +3 -0
  64. package/dist/postfx/shadowPrepass.js +18 -0
  65. package/dist/presentationRecovery.d.ts +75 -0
  66. package/dist/presentationRecovery.js +204 -0
  67. package/dist/presentationRecovery3d.d.ts +4 -0
  68. package/dist/presentationRecovery3d.js +32 -0
  69. package/dist/presentationResolve.d.ts +8 -1
  70. package/dist/presentationResolve.js +5 -2
  71. package/dist/render/CascadedShadows.d.ts +7 -2
  72. package/dist/render/CascadedShadows.js +98 -20
  73. package/dist/render/EnvironmentLighting.js +74 -35
  74. package/dist/render/HairCards.d.ts +7 -0
  75. package/dist/render/HairCards.js +23 -0
  76. package/dist/render/SceneModels.js +51 -77
  77. package/dist/render/authoredSurfaceMaterial.d.ts +43 -0
  78. package/dist/render/authoredSurfaceMaterial.js +108 -0
  79. package/dist/render/materialAppearanceSignals.d.ts +23 -0
  80. package/dist/render/materialAppearanceSignals.js +58 -0
  81. package/dist/render/materialAsset.d.ts +98 -0
  82. package/dist/render/materialAsset.js +454 -0
  83. package/dist/render/measureBounds.js +16 -3
  84. package/dist/render/measureCollisionMesh.js +8 -1
  85. package/dist/render/modelAssets.d.ts +8 -0
  86. package/dist/render/modelAssets.js +43 -0
  87. package/dist/render/modelBindPose.d.ts +5 -0
  88. package/dist/render/modelBindPose.js +35 -0
  89. package/dist/render/modelLoad.d.ts +3 -0
  90. package/dist/render/modelLoad.js +9 -0
  91. package/dist/render/modelNodeVisibility.d.ts +6 -0
  92. package/dist/render/modelNodeVisibility.js +18 -0
  93. package/dist/render/modelRender.d.ts +18 -1
  94. package/dist/render/modelRender.js +81 -3
  95. package/dist/render/projectedOverdraw.d.ts +35 -0
  96. package/dist/render/projectedOverdraw.js +204 -0
  97. package/dist/render/resolveModel.d.ts +12 -2
  98. package/dist/render/resolveModel.js +21 -4
  99. package/dist/render/rigNode.d.ts +26 -0
  100. package/dist/render/rigNode.js +32 -0
  101. package/dist/render/spriteRender.d.ts +4 -0
  102. package/dist/render/spriteRender.js +5 -0
  103. package/dist/render/staticShapeInstances.d.ts +34 -0
  104. package/dist/render/staticShapeInstances.js +78 -0
  105. package/dist/render/useFootIk.js +76 -11
  106. package/dist/render/useModelAnimation.d.ts +28 -2
  107. package/dist/render/useModelAnimation.js +194 -69
  108. package/dist/render/useModelInstance.d.ts +25 -0
  109. package/dist/render/useModelInstance.js +43 -0
  110. package/dist/scatter/scatterModels.d.ts +3 -2
  111. package/dist/scatter/scatterModels.js +15 -7
  112. package/dist/scene/AuthoredScene.d.ts +14 -6
  113. package/dist/scene/AuthoredScene.js +30 -9
  114. package/dist/scene/GeneratedAssetRenderer.js +11 -42
  115. package/dist/settings/SettingsMenu.js +11 -18
  116. package/dist/settings/SettingsRuntime.d.ts +5 -0
  117. package/dist/settings/SettingsRuntime.js +29 -2
  118. package/dist/shellControlSuspension.d.ts +18 -0
  119. package/dist/shellControlSuspension.js +28 -0
  120. package/dist/shellInputPublication.d.ts +28 -0
  121. package/dist/shellInputPublication.js +49 -0
  122. package/dist/shellPointerInput.d.ts +18 -0
  123. package/dist/shellPointerInput.js +49 -0
  124. package/dist/structures/BuildingKitBatch.d.ts +3 -1
  125. package/dist/structures/BuildingKitBatch.js +34 -59
  126. package/dist/structures/BuildingRenderBudget.d.ts +23 -0
  127. package/dist/structures/BuildingRenderBudget.js +54 -0
  128. package/dist/structures/GeneratedBuilding.js +13 -8
  129. package/dist/structures/buildingKitMaterials.d.ts +20 -0
  130. package/dist/structures/buildingKitMaterials.js +70 -0
  131. package/dist/structures/buildingSpatialBatch.d.ts +11 -0
  132. package/dist/structures/buildingSpatialBatch.js +45 -0
  133. package/dist/terrain/GrassField.d.ts +2 -1
  134. package/dist/terrain/GrassField.js +59 -5
  135. package/dist/terrain/grassGeometry.d.ts +10 -0
  136. package/dist/terrain/grassGeometry.js +55 -0
  137. package/dist/terrain/grassMaterial.js +2 -2
  138. package/dist/terrain/terrainDetailMaterial.d.ts +3 -3
  139. package/dist/terrain/terrainDetailMaterial.js +7 -7
  140. package/dist/touch/TouchControlsOverlay.js +4 -4
  141. package/dist/useShellMultiplayerSync.js +4 -0
  142. package/dist/vfx/ParticleField.d.ts +23 -20
  143. package/dist/vfx/ParticleField.js +168 -50
  144. package/dist/visibility/CullingProvider.js +2 -62
  145. package/dist/visibility/cullingDriver.d.ts +9 -0
  146. package/dist/visibility/cullingDriver.js +68 -0
  147. package/dist/weather/AuthoredWeatherLayer.d.ts +16 -0
  148. package/dist/weather/AuthoredWeatherLayer.js +31 -0
  149. package/dist/weather/DustField.d.ts +2 -1
  150. package/dist/weather/DustField.js +17 -3
  151. package/dist/weather/FireSpreadLayer.d.ts +4 -2
  152. package/dist/weather/FireSpreadLayer.js +5 -11
  153. package/dist/weather/LightningStrike.d.ts +4 -1
  154. package/dist/weather/LightningStrike.js +13 -17
  155. package/dist/weather/RainField.d.ts +2 -1
  156. package/dist/weather/RainField.js +17 -3
  157. package/dist/weather/RainImpactField.d.ts +16 -0
  158. package/dist/weather/RainImpactField.js +89 -0
  159. package/dist/weather/SnowField.d.ts +2 -1
  160. package/dist/weather/SnowField.js +17 -3
  161. package/dist/weather/WeatherLayer.d.ts +11 -2
  162. package/dist/weather/WeatherLayer.js +30 -6
  163. package/dist/weather/index.d.ts +2 -0
  164. package/dist/weather/index.js +2 -0
  165. package/dist/weather/weatherMath.d.ts +2 -0
  166. package/dist/weather/weatherMath.js +8 -0
  167. package/dist/weather/weatherShelter.d.ts +18 -0
  168. package/dist/weather/weatherShelter.js +75 -0
  169. package/dist/weather/weatherUniforms.d.ts +40 -1
  170. package/dist/weather/weatherUniforms.js +29 -9
  171. package/dist/world/AuthoredFlocks.d.ts +22 -0
  172. package/dist/world/AuthoredFlocks.js +87 -0
  173. package/dist/world/StaticObjectModels.d.ts +8 -0
  174. package/dist/world/StaticObjectModels.js +75 -0
  175. package/dist/world/WorldHud.d.ts +14 -6
  176. package/dist/world/WorldHud.js +25 -12
  177. package/dist/world/WorldParticles.d.ts +10 -23
  178. package/dist/world/WorldParticles.js +209 -61
  179. package/dist/world/WorldScene.d.ts +3 -1
  180. package/dist/world/WorldScene.js +41 -26
  181. package/dist/world/staticObjectBatches.d.ts +35 -0
  182. package/dist/world/staticObjectBatches.js +163 -0
  183. package/dist/world/worldBarSamples.d.ts +37 -33
  184. package/dist/world/worldBarSamples.js +117 -75
  185. package/package.json +4 -4
  186. package/skills/ce-handoff/SKILL.md +1 -1
  187. package/skills/jgengine/SKILL.md +22 -2
  188. package/skills/jgengine/api.md +28 -17
  189. package/skills/jgengine/recipes/minimal-game.md +7 -2
  190. package/skills/jgengine-ui/SKILL.md +3 -1
  191. package/skills/jgengine-ui/api.md +204 -67
  192. package/skills/jgengine-ui/capabilities.md +115 -1
  193. package/skills/jgengine-ui/reference-primitives.md +93 -3
  194. package/skills/jgengine-ui/reference.md +2 -0
  195. package/skills/jgengine-world/SKILL.md +12 -3
  196. package/skills/jgengine-world/api.md +200 -57
  197. package/skills/jgengine-world/capabilities.md +116 -3
  198. package/skills/jgengine-world/recipes/character-animation.md +31 -8
  199. package/skills/jgengine-world/recipes/controls.md +4 -0
  200. package/skills/jgengine-world/recipes/npc-senses.md +12 -0
  201. package/skills/jgengine-world/recipes/vehicle-feel.md +3 -1
  202. package/skills/jgengine-world/reference.md +152 -5
  203. package/skills/jgengine-world/visibility.md +28 -1
@@ -3,12 +3,17 @@ import { dispatchBoundAction, heldActionsFor, shouldFireBoundAction } from "../b
3
3
  import { advanceBehaviors } from "@jgengine/core/scene/behaviorRuntime";
4
4
  import { playControlsActive } from "@jgengine/core/game/controlGate";
5
5
  import { devtools } from "@jgengine/core/devtools/devtools";
6
+ import { isServerAuthoritative } from "@jgengine/core/runtime/adapter";
7
+ import { resolveCommandSink } from "../commandSink.js";
8
+ import { inputFramesEqual, resolveInputSink } from "../inputSink.js";
6
9
  import { EMPTY_RESERVED, NO_ACTIONS } from "../shellConstants.js";
7
- export function HudOnlyDriver({ ctx, playable, tracker, pointerAxisRef, gateRef, onRuntimeError, }) {
10
+ export function HudOnlyDriver({ ctx, multiplayer, serverIdRef, playable, tracker, pointerAxisRef, gateRef, onRuntimeError, }) {
8
11
  const hasReportedTickError = useRef(false);
9
12
  const repeatFiredAtRef = useRef(new Map());
10
13
  const lastFrameRef = useRef(null);
11
14
  const inputActions = useMemo(() => Object.keys(playable.game.input ?? {}), [playable]);
15
+ const lastSentInputRef = useRef(null);
16
+ const serverAuthoritative = isServerAuthoritative(playable.game.multiplayer) && multiplayer !== null;
12
17
  useEffect(() => {
13
18
  let frameId;
14
19
  const tick = (now) => {
@@ -17,8 +22,19 @@ export function HudOnlyDriver({ ctx, playable, tracker, pointerAxisRef, gateRef,
17
22
  lastFrameRef.current = now;
18
23
  if (last === null)
19
24
  return;
25
+ const sendInput = () => {
26
+ if (!serverAuthoritative || serverIdRef.current === null)
27
+ return;
28
+ const frame = { held: ctx.input.held(), pointer: ctx.input.pointer(), analog: ctx.input.analog() };
29
+ if (lastSentInputRef.current !== null && inputFramesEqual(lastSentInputRef.current, frame))
30
+ return;
31
+ lastSentInputRef.current = frame;
32
+ resolveInputSink({ serverAuthoritative, backend: multiplayer?.backend ?? null, serverId: serverIdRef.current }).send(frame);
33
+ };
20
34
  if (gateRef.current || !playControlsActive(ctx)) {
21
- ctx.input.publish(heldActionsFor(tracker, NO_ACTIONS));
35
+ ctx.input.publish(heldActionsFor(tracker, NO_ACTIONS), { reset: true });
36
+ ctx.input.publishAnalog(null);
37
+ sendInput();
22
38
  return;
23
39
  }
24
40
  const rawDt = (now - last) / 1000;
@@ -26,26 +42,28 @@ export function HudOnlyDriver({ ctx, playable, tracker, pointerAxisRef, gateRef,
26
42
  try {
27
43
  let endPhase = devtools.profile.begin("time+input");
28
44
  const dt = Math.min(rawDt, 0.05);
29
- ctx.input.publish(heldActionsFor(tracker, tracker.actions()));
45
+ ctx.input.publish(heldActionsFor(tracker, tracker.actions()), {});
30
46
  ctx.input.publishPointer(pointerAxisRef.current);
47
+ sendInput();
31
48
  endPhase();
32
- ctx.sim.advance(dt, (stepDt) => {
33
- const gameDt = ctx.time.advance(stepDt);
34
- ctx.sim.runStages("beforeMovement", stepDt);
35
- ctx.sim.runStages("afterMovement", stepDt);
36
- devtools.profile.measure("onTick", () => {
37
- playable.loop.onTick(ctx, gameDt);
49
+ if (!serverAuthoritative)
50
+ ctx.sim.advance(dt, (stepDt, _tick, gameDt) => {
51
+ ctx.input.beginStep();
52
+ ctx.sim.runStages("beforeMovement", stepDt);
53
+ ctx.sim.runStages("afterMovement", stepDt);
54
+ devtools.profile.measure("onTick", () => {
55
+ playable.loop.onTick(ctx, gameDt);
56
+ });
57
+ advanceBehaviors(ctx, gameDt);
58
+ ctx.sim.runStages("afterTick", stepDt);
38
59
  });
39
- advanceBehaviors(ctx, gameDt);
40
- ctx.sim.runStages("afterTick", stepDt);
41
- });
42
60
  endPhase = devtools.profile.begin("actions");
43
61
  const nowMs = performance.now();
44
62
  for (const action of inputActions) {
45
63
  if (!shouldFireBoundAction(tracker, action, playable.game.input, repeatFiredAtRef.current, nowMs))
46
64
  continue;
47
65
  repeatFiredAtRef.current.set(action, nowMs);
48
- dispatchBoundAction(ctx, action, 0, 0, { yaw: 0, pitch: 0 }, EMPTY_RESERVED);
66
+ dispatchBoundAction(ctx, action, 0, 0, { yaw: 0, pitch: 0 }, EMPTY_RESERVED, resolveCommandSink(ctx, { serverAuthoritative, backend: multiplayer?.backend ?? null, serverId: serverIdRef.current }));
49
67
  }
50
68
  tracker.endFrame();
51
69
  endPhase();
@@ -60,6 +78,6 @@ export function HudOnlyDriver({ ctx, playable, tracker, pointerAxisRef, gateRef,
60
78
  };
61
79
  frameId = requestAnimationFrame(tick);
62
80
  return () => cancelAnimationFrame(frameId);
63
- }, [ctx, playable, tracker, pointerAxisRef, gateRef, onRuntimeError, inputActions]);
81
+ }, [ctx, playable, tracker, pointerAxisRef, gateRef, onRuntimeError, inputActions, multiplayer, serverIdRef, serverAuthoritative]);
64
82
  return null;
65
83
  }
@@ -1,7 +1,8 @@
1
1
  import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { useEffect, useMemo, useRef } from "react";
3
3
  import { useFrame } from "@react-three/fiber";
4
- import { useTexture } from "@react-three/drei";
4
+ import { PresentationAssetBoundary } from "../presentationRecovery.js";
5
+ import { PresentationRecoveredDraw, useRecoverableTexture } from "../presentationRecovery3d.js";
5
6
  import * as THREE from "three";
6
7
  import { useGameContext } from "@jgengine/react/provider";
7
8
  import { resolveBuildingPalette } from "@jgengine/core/world/buildings";
@@ -20,14 +21,13 @@ import { createTerrainDetailMaterial } from "../terrain/terrainDetailMaterial.js
20
21
  import { Ocean } from "../water/Ocean.js";
21
22
  import { RainField } from "../weather/RainField.js";
22
23
  import { SnowField } from "../weather/SnowField.js";
23
- import { WeatherUniformProvider } from "../weather/weatherUniforms.js";
24
24
  function TexturedTerrainGround({ detail, layout, }) {
25
25
  const maps = detail.material.maps;
26
- const textures = useTexture({
26
+ const textures = useRecoverableTexture({
27
27
  color: maps.color,
28
28
  normal: maps.normal,
29
- roughness: maps.roughness,
30
- ao: maps.ao,
29
+ ...(maps.roughness !== undefined ? { roughness: maps.roughness } : {}),
30
+ ...(maps.ao !== undefined ? { ao: maps.ao } : {}),
31
31
  });
32
32
  useEffect(() => {
33
33
  textures.color.colorSpace = THREE.SRGBColorSpace;
@@ -38,7 +38,7 @@ function TexturedTerrainGround({ detail, layout, }) {
38
38
  }
39
39
  }, [textures]);
40
40
  const material = useDisposable(() => createTerrainDetailMaterial(detail, textures).material, [detail, textures]);
41
- return (_jsx(CarvedTerrain, { field: layout.field, size: layout.size, segments: layout.segments, colors: layout.colors, heightRange: layout.heightRange, paletteAt: layout.paletteAt, center: layout.center, roughness: 0.94, surfaceMaterial: material }));
41
+ return (_jsxs(_Fragment, { children: [_jsx(PresentationRecoveredDraw, {}), _jsx(CarvedTerrain, { field: layout.field, size: layout.size, segments: layout.segments, colors: layout.colors, heightRange: layout.heightRange, paletteAt: layout.paletteAt, center: layout.center, roughness: 0.94, surfaceMaterial: material })] }));
42
42
  }
43
43
  function TerrainGround({ terrain, field, center, }) {
44
44
  const palette = useMemo(() => resolveTerrainPalette(terrain), [terrain]);
@@ -69,7 +69,7 @@ function TerrainGround({ terrain, field, center, }) {
69
69
  : createTerrainDetailMaterial(resolvedDetail).material, [resolvedDetail]);
70
70
  useEffect(() => () => proceduralMaterial?.dispose(), [proceduralMaterial]);
71
71
  if (resolvedDetail?.material !== undefined) {
72
- return (_jsx(TexturedTerrainGround, { detail: resolvedDetail, layout: { field, size, segments: terrain.segments, colors, heightRange, paletteAt, center } }));
72
+ return (_jsx(PresentationAssetBoundary, { children: _jsx(TexturedTerrainGround, { detail: resolvedDetail, layout: { field, size, segments: terrain.segments, colors, heightRange, paletteAt, center } }) }));
73
73
  }
74
74
  return (_jsx(CarvedTerrain, { field: field, size: size, segments: terrain.segments, colors: colors, heightRange: heightRange, paletteAt: paletteAt, center: center, roughness: 0.94, surfaceMaterial: proceduralMaterial }));
75
75
  }
@@ -99,14 +99,15 @@ function weatherVolume(area) {
99
99
  return [area.w, area.h ?? 60, area.d];
100
100
  }
101
101
  function Precipitation({ weather }) {
102
+ const ctx = useGameContext();
102
103
  const [cx, cz] = areaCenter(weather.area);
103
104
  if (weather.kind === "rain") {
104
- return (_jsx("group", { position: [cx, 0, cz], children: _jsx(RainField, { density: weather.density, speed: weather.speed, length: weather.dropLength, width: weather.width, opacity: weather.opacity, color: weather.color, wind: [weather.wind[0], 0, weather.wind[1]], volume: weatherVolume(weather.area) }) }));
105
+ return (_jsx("group", { position: [cx, 0, cz], children: _jsx(RainField, { timeSeconds: ctx.time.now, density: weather.density, speed: weather.speed, length: weather.dropLength, width: weather.width, opacity: weather.opacity, color: weather.color, wind: [weather.wind[0], 0, weather.wind[1]], volume: weatherVolume(weather.area) }) }));
105
106
  }
106
- return (_jsx("group", { position: [cx, 0, cz], children: _jsx(SnowField, { density: weather.density, speed: weather.speed, size: weather.flakeSize, sway: weather.drift, opacity: weather.opacity, color: weather.color, wind: [weather.wind[0], 0, weather.wind[1]], volume: weatherVolume(weather.area) }) }));
107
+ return (_jsx("group", { position: [cx, 0, cz], children: _jsx(SnowField, { timeSeconds: ctx.time.now, density: weather.density, speed: weather.speed, size: weather.flakeSize, sway: weather.drift, opacity: weather.opacity, color: weather.color, wind: [weather.wind[0], 0, weather.wind[1]], volume: weatherVolume(weather.area) }) }));
107
108
  }
108
109
  function Weather({ weather }) {
109
- return (_jsx(WeatherUniformProvider, { children: weather.map((entry, index) => (_jsx(Precipitation, { weather: entry, index: index }, `${entry.kind}-${index}`))) }));
110
+ return (_jsx(_Fragment, { children: weather.map((entry, index) => (_jsx(Precipitation, { weather: entry, index: index }, `${entry.kind}-${index}`))) }));
110
111
  }
111
112
  function oceanConfig(ocean) {
112
113
  return {
@@ -2,17 +2,17 @@ import { type InputFrame } from "@jgengine/core/runtime/hostedGameRunner";
2
2
  import type { LiveGameBackend } from "@jgengine/core/runtime/transport";
3
3
  /** Where the local player's per-frame input goes: discarded in single-player, sent to the authoritative host under `authority: "server"`. */
4
4
  export interface InputSink {
5
- send(frame: InputFrame): void;
5
+ send(frame: InputFrame, options?: {
6
+ urgent?: boolean;
7
+ reset?: boolean;
8
+ }): void;
6
9
  }
7
10
  /** Discards input — the single-player / client-authoritative default, where the client integrates movement itself.
8
11
  * @internal
9
12
  */
10
13
  export declare function noopInputSink(): InputSink;
11
- /**
12
- * Sends each frame's input to the authoritative host over the transport, reusing the `runCommand` path via
13
- * {@link INPUT_COMMAND}. Sends are sequenced one-in-flight-at-a-time per `serverId` and stamped with a monotonic
14
- * seq: a frame sent while one is already in flight replaces the pending frame rather than racing it, so the
15
- * latest intent always wins and a stale frame can never resolve after (and overwrite) a newer one.
14
+ /** Coalesces continuous frames. Discrete release/reset intents bypass a pending ACK;
15
+ * the host's monotonic sequence admission rejects any older input arriving afterwards.
16
16
  * @internal
17
17
  */
18
18
  export declare function remoteInputSink(backend: Pick<LiveGameBackend, "transport">, serverId: string): InputSink;
package/dist/inputSink.js CHANGED
@@ -5,56 +5,91 @@ import { INPUT_COMMAND } from "@jgengine/core/runtime/hostedGameRunner";
5
5
  export function noopInputSink() {
6
6
  return { send() { } };
7
7
  }
8
- const remoteInputSources = new Map();
9
- function remoteInputSourceFor(serverId) {
10
- let source = remoteInputSources.get(serverId);
8
+ const remoteInputSources = new WeakMap();
9
+ let lastInputSeq = 0;
10
+ function remoteInputSourceFor(backend, serverId) {
11
+ let sources = remoteInputSources.get(backend.transport);
12
+ if (sources === undefined) {
13
+ sources = new Map();
14
+ remoteInputSources.set(backend.transport, sources);
15
+ }
16
+ let source = sources.get(serverId);
11
17
  if (source === undefined) {
12
- source = { pending: null, inFlight: false };
13
- remoteInputSources.set(serverId, source);
18
+ source = { pending: null, inFlight: null, latest: null, presses: new Map() };
19
+ sources.set(serverId, source);
14
20
  }
15
21
  return source;
16
22
  }
23
+ // Use the browser time origin so a full reload stays ahead of the previous client.
24
+ // The local high-water mark also preserves release ordering if its clock regresses.
17
25
  function monotonicInputSeq() {
18
- return typeof performance !== "undefined" && typeof performance.now === "function" ? performance.now() : Date.now();
26
+ const now = typeof performance !== "undefined" ? performance.timeOrigin + performance.now() : Date.now();
27
+ return lastInputSeq = Math.max(now, lastInputSeq + 0.001);
19
28
  }
20
29
  function pumpRemoteInput(backend, serverId, source) {
21
- if (source.inFlight)
30
+ if (source.inFlight !== null)
22
31
  return;
23
32
  const frame = source.pending;
24
33
  if (frame === null) {
25
- remoteInputSources.delete(serverId);
34
+ if (source.presses.size === 0)
35
+ remoteInputSources.get(backend.transport)?.delete(serverId);
26
36
  return;
27
37
  }
28
38
  source.pending = null;
29
- source.inFlight = true;
39
+ const owner = {};
40
+ source.inFlight = owner;
41
+ const presses = [...source.presses.values()].map(press => ({ ...press }));
30
42
  const seq = monotonicInputSeq();
43
+ // Live clients and the joined host have independent simulation clocks. The host
44
+ // stamps receipt on its next tick; explicit ticks remain supported by replay.
45
+ const { tick: _clientTick, presses: _framePresses, ...intent } = frame;
31
46
  void backend.transport
32
- .runCommand({ serverId, command: INPUT_COMMAND, input: { ...frame, seq } })
47
+ .runCommand({ serverId, command: INPUT_COMMAND, input: { ...intent, ...(presses.length > 0 ? { presses } : {}), seq } })
33
48
  .then((result) => {
34
- if (!result.ok) {
49
+ if (result.ok)
50
+ for (const press of presses)
51
+ source.presses.delete(press.seq);
52
+ if (!result.ok)
35
53
  console.warn(`[jgengine:input] frame seq=${seq} to server "${serverId}" rejected: ${result.reason}`);
36
- }
37
54
  })
38
55
  .catch((error) => {
39
56
  console.warn(`[jgengine:input] frame seq=${seq} to server "${serverId}" failed to send`, error);
40
57
  })
41
58
  .finally(() => {
42
- source.inFlight = false;
59
+ // An urgent discrete intent supersedes this flight. Its old completion must not
60
+ // release the replacement's ACK gate or replay the superseded pending frame.
61
+ if (source.inFlight !== owner)
62
+ return;
63
+ source.inFlight = null;
43
64
  pumpRemoteInput(backend, serverId, source);
44
65
  });
45
66
  }
46
- /**
47
- * Sends each frame's input to the authoritative host over the transport, reusing the `runCommand` path via
48
- * {@link INPUT_COMMAND}. Sends are sequenced one-in-flight-at-a-time per `serverId` and stamped with a monotonic
49
- * seq: a frame sent while one is already in flight replaces the pending frame rather than racing it, so the
50
- * latest intent always wins and a stale frame can never resolve after (and overwrite) a newer one.
67
+ /** Coalesces continuous frames. Discrete release/reset intents bypass a pending ACK;
68
+ * the host's monotonic sequence admission rejects any older input arriving afterwards.
51
69
  * @internal
52
70
  */
53
71
  export function remoteInputSink(backend, serverId) {
54
72
  return {
55
- send(frame) {
56
- const source = remoteInputSourceFor(serverId);
57
- source.pending = frame;
73
+ send(frame, options) {
74
+ const source = remoteInputSourceFor(backend, serverId);
75
+ if (options?.reset)
76
+ source.presses.clear();
77
+ for (const press of frame.presses ?? [])
78
+ source.presses.set(press.seq, { ...press });
79
+ // A reset must overtake an identical neutral release that still carries an
80
+ // unacknowledged press. Intent equality alone does not describe that flight.
81
+ if (!options?.reset && source.latest !== null && inputFramesEqual(source.latest, frame) && source.presses.size === 0)
82
+ return;
83
+ const snapshot = {
84
+ ...frame, held: [...frame.held],
85
+ ...(frame.presses === undefined ? {} : { presses: frame.presses.map(press => ({ ...press })) }),
86
+ pointer: frame.pointer === null ? null : { ...frame.pointer },
87
+ ...(frame.analog === undefined ? {} : { analog: frame.analog === null ? null : { ...frame.analog } }),
88
+ };
89
+ source.latest = snapshot;
90
+ source.pending = snapshot;
91
+ if (options?.urgent)
92
+ source.inFlight = null;
58
93
  pumpRemoteInput(backend, serverId, source);
59
94
  },
60
95
  };
@@ -72,6 +107,10 @@ export function resolveInputSink(opts) {
72
107
  * @internal
73
108
  */
74
109
  export function inputFramesEqual(a, b) {
110
+ const ap = a.presses ?? [];
111
+ const bp = b.presses ?? [];
112
+ if (ap.length !== bp.length || ap.some((press, index) => press.seq !== bp[index].seq || press.action !== bp[index].action))
113
+ return false;
75
114
  if (a.held.length !== b.held.length)
76
115
  return false;
77
116
  for (let i = 0; i < a.held.length; i++)
@@ -0,0 +1,9 @@
1
+ import { type ComponentProps } from "react";
2
+ import type { Shell3dPresentation } from "./Shell3dPresentation.js";
3
+ type Presentation = typeof Shell3dPresentation;
4
+ type Props = ComponentProps<Presentation> & {
5
+ onPresentationReveal?: () => void;
6
+ };
7
+ /** Loads the normal 3D implementation only for a 3D presentation. @internal */
8
+ export declare function LazyShell3dPresentation({ onPresentationReveal, ...props }: Props): import("react").JSX.Element;
9
+ export {};
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import { lazy, Suspense, useLayoutEffect, useState } from "react";
3
+ import { suspendPlayControls } from "@jgengine/core/game/controlGate";
4
+ import { markPresentationCodeLoadFailure } from "./presentationRecovery.js";
5
+ let loadedPresentation;
6
+ function getPresentation() {
7
+ return loadedPresentation ??= lazy(() => import("./Shell3dPresentation.js").then((module) => ({ default: module.Shell3dPresentation }), (error) => {
8
+ throw markPresentationCodeLoadFailure(error);
9
+ }));
10
+ }
11
+ function LoadingPresentation({ ctx }) {
12
+ useLayoutEffect(() => suspendPlayControls(ctx), [ctx]);
13
+ return (_jsx("div", { role: "status", "aria-live": "polite", "data-shell-code-loading": true, style: { display: "grid", placeItems: "center", width: "100%", height: "100%", minHeight: 160, background: "#0f172a", color: "#e2e8f0", fontFamily: "ui-sans-serif, system-ui, sans-serif" }, children: "Loading game view\u2026" }));
14
+ }
15
+ function PresentationReveal({ onReveal }) {
16
+ // React repeats layout effects when a suspended tree becomes visible again.
17
+ useLayoutEffect(() => { onReveal?.(); });
18
+ return null;
19
+ }
20
+ /** Loads the normal 3D implementation only for a 3D presentation. @internal */
21
+ export function LazyShell3dPresentation({ onPresentationReveal, ...props }) {
22
+ const [Presentation] = useState(getPresentation);
23
+ return (_jsxs(Suspense, { fallback: _jsx(LoadingPresentation, { ctx: props.ctx }), children: [_jsx(Presentation, { ...props }), _jsx(PresentationReveal, { onReveal: onPresentationReveal })] }));
24
+ }
@@ -4,6 +4,8 @@ export interface MaterialOverrideOptions {
4
4
  clone?: boolean;
5
5
  /** Loaded PBR textures matching `ModelMaterialOverride.maps`' roles, applied onto each standard or physical material alongside the tint override. The caller (a React component, via `useTexture`) owns loading; this function never fetches a URL. */
6
6
  textures?: MaterialOverrideTextures;
7
+ /** Records material replacements for the caller's resource owner. */
8
+ ownMaterial?: (material: THREE.Material) => void;
7
9
  }
8
10
  /** Loaded PBR textures for `applyMaterialOverride`'s `textures` option — matches `ModelMaterialMaps`' roles. */
9
11
  export interface MaterialOverrideTextures {
@@ -14,6 +16,46 @@ export interface MaterialOverrideTextures {
14
16
  metalness?: THREE.Texture;
15
17
  emissive?: THREE.Texture;
16
18
  height?: THREE.Texture;
19
+ alpha?: THREE.Texture;
20
+ sheenColor?: THREE.Texture;
21
+ sheenRoughness?: THREE.Texture;
22
+ anisotropy?: THREE.Texture;
23
+ clearcoat?: THREE.Texture;
24
+ clearcoatRoughness?: THREE.Texture;
25
+ clearcoatNormal?: THREE.Texture;
26
+ specularIntensity?: THREE.Texture;
27
+ specularColor?: THREE.Texture;
28
+ transmission?: THREE.Texture;
29
+ thickness?: THREE.Texture;
30
+ iridescence?: THREE.Texture;
31
+ iridescenceThickness?: THREE.Texture;
17
32
  }
33
+ /** Physical texture roles mapped to the pinned Three renderer's native properties. @internal */
34
+ export declare const MATERIAL_TEXTURE_PROPERTIES: {
35
+ readonly color: "map";
36
+ readonly normal: "normalMap";
37
+ readonly roughness: "roughnessMap";
38
+ readonly ao: "aoMap";
39
+ readonly metalness: "metalnessMap";
40
+ readonly emissive: "emissiveMap";
41
+ readonly height: "displacementMap";
42
+ readonly alpha: "alphaMap";
43
+ readonly sheenColor: "sheenColorMap";
44
+ readonly sheenRoughness: "sheenRoughnessMap";
45
+ readonly anisotropy: "anisotropyMap";
46
+ readonly clearcoat: "clearcoatMap";
47
+ readonly clearcoatRoughness: "clearcoatRoughnessMap";
48
+ readonly clearcoatNormal: "clearcoatNormalMap";
49
+ readonly specularIntensity: "specularIntensityMap";
50
+ readonly specularColor: "specularColorMap";
51
+ readonly transmission: "transmissionMap";
52
+ readonly thickness: "thicknessMap";
53
+ readonly iridescence: "iridescenceMap";
54
+ readonly iridescenceThickness: "iridescenceThicknessMap";
55
+ };
56
+ /** Whether authored settings require a physical shader; ordinary PBR stays standard. @internal */
57
+ export declare function requiresPhysicalMaterial(override: ModelMaterialOverride, textures?: MaterialOverrideTextures): boolean;
18
58
  /** @internal */
19
59
  export declare function applyMaterialOverride(root: THREE.Object3D, override: ModelMaterialOverride, options?: MaterialOverrideOptions): void;
60
+ /** Apply the shared override contract to one material. @internal */
61
+ export declare function applyMaterialOverrideToMaterial(material: THREE.Material, override: ModelMaterialOverride, clone: boolean, textures: MaterialOverrideTextures | undefined): THREE.Material;
@@ -1,50 +1,106 @@
1
1
  import * as THREE from "three";
2
+ /** Physical texture roles mapped to the pinned Three renderer's native properties. @internal */
3
+ export const MATERIAL_TEXTURE_PROPERTIES = {
4
+ color: "map", normal: "normalMap", roughness: "roughnessMap", ao: "aoMap", metalness: "metalnessMap", emissive: "emissiveMap", height: "displacementMap", alpha: "alphaMap",
5
+ sheenColor: "sheenColorMap", sheenRoughness: "sheenRoughnessMap", anisotropy: "anisotropyMap", clearcoat: "clearcoatMap", clearcoatRoughness: "clearcoatRoughnessMap", clearcoatNormal: "clearcoatNormalMap", specularIntensity: "specularIntensityMap", specularColor: "specularColorMap", transmission: "transmissionMap", thickness: "thicknessMap", iridescence: "iridescenceMap", iridescenceThickness: "iridescenceThicknessMap",
6
+ };
7
+ const physicalNumbers = ["sheen", "sheenRoughness", "anisotropy", "anisotropyRotation", "clearcoat", "clearcoatRoughness", "ior", "specularIntensity", "transmission", "thickness", "attenuationDistance", "iridescence", "iridescenceIOR"];
8
+ const physicalColors = ["sheenColor", "specularColor", "attenuationColor"];
9
+ /** Whether authored settings require a physical shader; ordinary PBR stays standard. @internal */
10
+ export function requiresPhysicalMaterial(override, textures) {
11
+ return [...physicalNumbers, ...physicalColors, "iridescenceThicknessRange"].some(key => override[key] !== undefined) || Object.keys(textures ?? {}).some(key => ["sheenColor", "sheenRoughness", "anisotropy", "clearcoat", "clearcoatRoughness", "clearcoatNormal", "specularIntensity", "specularColor", "transmission", "thickness", "iridescence", "iridescenceThickness"].includes(key));
12
+ }
2
13
  /** @internal */
3
14
  export function applyMaterialOverride(root, override, options) {
4
15
  const clone = options?.clone !== false;
5
16
  const textures = options?.textures;
17
+ const applied = new Map();
18
+ const apply = (material) => {
19
+ const cached = applied.get(material);
20
+ if (cached !== undefined)
21
+ return cached;
22
+ const target = applyMaterialOverrideToMaterial(material, override, clone, textures);
23
+ applied.set(material, target);
24
+ if (target !== material)
25
+ options?.ownMaterial?.(target);
26
+ return target;
27
+ };
6
28
  root.traverse((node) => {
7
29
  const mesh = node;
8
30
  if (!mesh.isMesh)
9
31
  return;
10
- mesh.material = Array.isArray(mesh.material)
11
- ? mesh.material.map((material) => overrideOne(material, override, clone, textures))
12
- : overrideOne(mesh.material, override, clone, textures);
32
+ mesh.material = Array.isArray(mesh.material) ? mesh.material.map(apply) : apply(mesh.material);
13
33
  });
14
34
  }
15
- function overrideOne(material, override, clone, textures) {
35
+ /** Apply the shared override contract to one material. @internal */
36
+ export function applyMaterialOverrideToMaterial(material, override, clone, textures) {
16
37
  if (!isStandardOrPhysicalMaterial(material))
17
38
  return material;
18
- const target = clone ? material.clone() : material;
19
- if (override.color !== undefined)
20
- target.color.set(override.color);
21
- if (override.metalness !== undefined)
22
- target.metalness = override.metalness;
23
- if (override.roughness !== undefined)
24
- target.roughness = override.roughness;
25
- if (override.emissive !== undefined)
26
- target.emissive.set(override.emissive);
27
- if (override.emissiveIntensity !== undefined)
28
- target.emissiveIntensity = override.emissiveIntensity;
29
- if (textures?.color !== undefined)
30
- target.map = textures.color;
31
- if (textures?.normal !== undefined)
32
- target.normalMap = textures.normal;
33
- if (textures?.roughness !== undefined)
34
- target.roughnessMap = textures.roughness;
35
- if (textures?.ao !== undefined)
36
- target.aoMap = textures.ao;
37
- if (textures?.metalness !== undefined)
38
- target.metalnessMap = textures.metalness;
39
- if (textures?.emissive !== undefined)
40
- target.emissiveMap = textures.emissive;
41
- if (textures?.height !== undefined)
42
- target.displacementMap = textures.height;
43
- if (textures !== undefined)
44
- target.needsUpdate = true;
45
- if (override.rim !== undefined)
46
- applyRimLight(target, override.rim);
47
- return target;
39
+ const promote = requiresPhysicalMaterial(override, textures) && !material.isMeshPhysicalMaterial;
40
+ const target = promote ? new THREE.MeshPhysicalMaterial() : clone ? material.clone() : material;
41
+ try {
42
+ if (promote)
43
+ THREE.MeshStandardMaterial.prototype.copy.call(target, material);
44
+ if (clone || promote) {
45
+ target.onBeforeCompile = material.onBeforeCompile;
46
+ target.customProgramCacheKey = material.customProgramCacheKey;
47
+ }
48
+ if (override.color !== undefined)
49
+ target.color.set(override.color);
50
+ if (override.metalness !== undefined)
51
+ target.metalness = override.metalness;
52
+ if (override.roughness !== undefined)
53
+ target.roughness = override.roughness;
54
+ if (override.emissive !== undefined)
55
+ target.emissive.set(override.emissive);
56
+ if (override.emissiveIntensity !== undefined)
57
+ target.emissiveIntensity = override.emissiveIntensity;
58
+ if (override.normalScale !== undefined)
59
+ target.normalScale.set(...override.normalScale);
60
+ const physical = target;
61
+ for (const key of physicalNumbers)
62
+ if (override[key] !== undefined)
63
+ physical[key] = override[key];
64
+ for (const key of physicalColors)
65
+ if (override[key] !== undefined)
66
+ physical[key].set(override[key]);
67
+ if (override.iridescenceThicknessRange !== undefined)
68
+ physical.iridescenceThicknessRange = [...override.iridescenceThicknessRange];
69
+ if (override.alphaMode !== undefined) {
70
+ target.transparent = override.alphaMode === "blend";
71
+ target.alphaTest = override.alphaMode === "mask" ? override.alphaCutoff ?? 0.5 : 0;
72
+ target.depthWrite = override.alphaMode !== "blend";
73
+ }
74
+ else if (override.alphaCutoff !== undefined)
75
+ target.alphaTest = override.alphaCutoff;
76
+ if (override.opacity !== undefined)
77
+ target.opacity = override.opacity;
78
+ if (override.doubleSided !== undefined)
79
+ target.side = override.doubleSided ? THREE.DoubleSide : THREE.FrontSide;
80
+ for (const [role, texture] of Object.entries(textures ?? {})) {
81
+ const property = MATERIAL_TEXTURE_PROPERTIES[role];
82
+ if (property !== undefined)
83
+ target[property] = texture;
84
+ }
85
+ if (textures !== undefined)
86
+ target.needsUpdate = true;
87
+ if (override.rim !== undefined)
88
+ applyRimLight(target, override.rim);
89
+ if (override.alphaMode !== undefined || override.doubleSided !== undefined)
90
+ target.needsUpdate = true;
91
+ return target;
92
+ }
93
+ catch (error) {
94
+ if (target !== material) {
95
+ try {
96
+ target.dispose();
97
+ }
98
+ finally {
99
+ throw error;
100
+ }
101
+ }
102
+ throw error;
103
+ }
48
104
  }
49
105
  function isStandardOrPhysicalMaterial(material) {
50
106
  return material.isMeshStandardMaterial === true;
@@ -60,7 +116,10 @@ function applyRimLight(target, rim) {
60
116
  const power = rim.power ?? 2.5;
61
117
  if (strength <= 0)
62
118
  return;
63
- target.onBeforeCompile = (shader) => {
119
+ const previousCompile = target.onBeforeCompile;
120
+ const previousKey = target.customProgramCacheKey();
121
+ target.onBeforeCompile = (shader, renderer) => {
122
+ previousCompile.call(target, shader, renderer);
64
123
  shader.uniforms.uJgRimColor = { value: color };
65
124
  shader.uniforms.uJgRimStrength = { value: strength };
66
125
  shader.uniforms.uJgRimPower = { value: power };
@@ -74,6 +133,6 @@ outgoingLight += uJgRimColor * jgRim * uJgRimStrength;
74
133
  #include <opaque_fragment>`);
75
134
  };
76
135
  // Two materials differing only in rim tuning must not share a compiled program.
77
- target.customProgramCacheKey = () => `jgengine-rim-${rim.color ?? "#ffffff"}-${strength}-${power}`;
136
+ target.customProgramCacheKey = () => `${previousKey}|jgengine-rim-${rim.color ?? "#ffffff"}-${strength}-${power}`;
78
137
  target.needsUpdate = true;
79
138
  }
@@ -1,5 +1,8 @@
1
1
  import type { GameDefinition } from "@jgengine/core/game/defineGame";
2
2
  import type { MultiplayerSession } from "@jgengine/core/runtime/transport";
3
+ import { type HostedWorldStore } from "@jgengine/core/runtime/hostedWorldSession";
4
+ import type { PlayableGame } from "./registry.js";
5
+ import { type PeerHost, type PeerHostOptions, type PeerGuest, type PeerGuestOptions, type PeerSignaling } from "@jgengine/ws/peer";
3
6
  export type ShellMultiplayer = MultiplayerSession;
4
7
  export declare const DEFAULT_FEED_ACTIONS: string[];
5
8
  export declare function randomPlayerId(): string;
@@ -12,12 +15,39 @@ export type ResolveShellMultiplayerArgs = {
12
15
  feedActions?: string[];
13
16
  };
14
17
  export declare function resolveShellMultiplayer(args: ResolveShellMultiplayerArgs): ShellMultiplayer | null;
15
- export declare function resolvePeerShellMultiplayer(args: {
18
+ /** Alternate peer factories for hosts that provide their own WebRTC implementation or transport pipe. */
19
+ export interface PeerShellFactories {
20
+ host(options: PeerHostOptions): PeerHost;
21
+ guest(options: PeerGuestOptions): PeerGuest;
22
+ }
23
+ /** Peer bootstrap options; passing a playable hosts its authoritative GameContext world. */
24
+ export interface ResolvePeerShellMultiplayerArgs {
16
25
  gameId: string;
17
26
  role: "host" | "join";
18
27
  room?: string;
19
28
  userId?: string;
20
29
  feedActions?: string[];
21
- }): Promise<ShellMultiplayer & {
22
- close: () => void;
30
+ /** Requires an adapter with `authority: "server"`; joiners mount the same playable. */
31
+ playable?: PlayableGame;
32
+ /** Maximum active players in the authoritative world, including the host player. */
33
+ slotsPerServer?: number;
34
+ /** Authoritative tick interval in milliseconds; defaults to 1000 / 30. */
35
+ tickMs?: number;
36
+ /** Minimum automatic save interval; joins, commands and close still save immediately. Defaults to 1000 ms. */
37
+ saveIntervalMs?: number;
38
+ /** Persistence for the authoritative host world; defaults to an in-memory store. */
39
+ store?: HostedWorldStore;
40
+ /** Signaling ownership transfers to the returned session, which closes it on teardown. */
41
+ signaling?: PeerSignaling;
42
+ peers?: PeerShellFactories;
43
+ /** Inject host scheduling; the returned cancellation is called before transport teardown. */
44
+ scheduleTicks?: (tick: () => void, intervalMs: number) => () => void;
45
+ }
46
+ /**
47
+ * Opens a peer session. With `playable`, one host runs the game loop and guests mirror its shared world.
48
+ * Await `close()` to finish authoritative persistence. Same-origin rooms use BroadcastChannel signaling.
49
+ * @capability multiplayer-p2p bootstrap a playable authoritative world for browser peer co-op
50
+ */
51
+ export declare function resolvePeerShellMultiplayer(args: ResolvePeerShellMultiplayerArgs): Promise<ShellMultiplayer & {
52
+ close: () => Promise<void>;
23
53
  }>;