@jgengine/shell 0.10.0 → 0.12.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.
- package/CHANGELOG.md +39 -2
- package/LICENSE +203 -661
- package/README.md +1 -1
- package/dist/CombatPresentation.d.ts +5 -0
- package/dist/CombatPresentation.js +8 -0
- package/dist/GameHost.d.ts +25 -1
- package/dist/GameHost.js +60 -4
- package/dist/GamePhaseStamp.d.ts +1 -0
- package/dist/GamePhaseStamp.js +9 -0
- package/dist/GamePlayer.d.ts +5 -0
- package/dist/GamePlayer.js +5 -0
- package/dist/GamePlayerShell.d.ts +5 -12
- package/dist/GamePlayerShell.js +67 -1332
- package/dist/GameUiPreview.js +3 -2
- package/dist/Shell3dPresentation.d.ts +63 -0
- package/dist/Shell3dPresentation.js +302 -0
- package/dist/ShellChrome.d.ts +51 -0
- package/dist/ShellChrome.js +51 -0
- package/dist/ShellHudPresentation.d.ts +41 -0
- package/dist/ShellHudPresentation.js +22 -0
- package/dist/audio/audioEngine.d.ts +4 -0
- package/dist/audio/audioEngine.js +128 -21
- package/dist/audio/audioWire.d.ts +40 -0
- package/dist/audio/audioWire.js +62 -0
- package/dist/audio/loopParams.d.ts +20 -0
- package/dist/audio/loopParams.js +28 -0
- package/dist/behaviour.d.ts +2 -1
- package/dist/behaviour.js +2 -1
- package/dist/behaviourAttach.d.ts +1 -0
- package/dist/behaviourAttach.js +1 -0
- package/dist/behaviourDriver.d.ts +1 -0
- package/dist/behaviourDriver.js +1 -0
- package/dist/boundActionDispatch.d.ts +13 -0
- package/dist/boundActionDispatch.js +37 -0
- package/dist/camera/GameCameraRig.d.ts +5 -2
- package/dist/camera/GameCameraRig.js +8 -3
- package/dist/camera/GameFirstPersonCamera.d.ts +9 -2
- package/dist/camera/GameFirstPersonCamera.js +8 -3
- package/dist/camera/GameInspectionCamera.d.ts +1 -1
- package/dist/camera/GameInspectionCamera.js +2 -2
- package/dist/camera/GameOrbitCamera.js +24 -9
- package/dist/camera/cameraBlendMath.d.ts +3 -0
- package/dist/camera/cameraBlendMath.js +3 -0
- package/dist/camera/cameraRigs.d.ts +3 -1
- package/dist/camera/cameraRigs.js +21 -3
- package/dist/camera/fovPreference.d.ts +6 -1
- package/dist/camera/fovPreference.js +6 -1
- package/dist/camera/index.d.ts +4 -7
- package/dist/camera/index.js +4 -7
- package/dist/camera/inspectionCameraMath.d.ts +7 -2
- package/dist/camera/inspectionCameraMath.js +7 -2
- package/dist/camera/orbitCameraMath.d.ts +36 -6
- package/dist/camera/orbitCameraMath.js +56 -6
- package/dist/camera/rigMath.d.ts +114 -24
- package/dist/camera/rigMath.js +129 -24
- package/dist/camera/rigResolve.d.ts +4 -2
- package/dist/camera/rigResolve.js +4 -2
- package/dist/camera/shakeChannel.d.ts +6 -2
- package/dist/camera/shakeChannel.js +6 -2
- package/dist/camera/shakeChannelMath.d.ts +1 -0
- package/dist/camera/shakeChannelMath.js +1 -0
- package/dist/commandSink.d.ts +8 -3
- package/dist/commandSink.js +8 -3
- package/dist/defineGame.d.ts +15 -1
- package/dist/defineGame.js +50 -9
- package/dist/devtools/ColPanel.d.ts +1 -0
- package/dist/devtools/ColPanel.js +14 -0
- package/dist/devtools/DevtoolsOverlay.d.ts +11 -7
- package/dist/devtools/DevtoolsOverlay.js +47 -462
- package/dist/devtools/KeysPanel.d.ts +4 -0
- package/dist/devtools/KeysPanel.js +31 -0
- package/dist/devtools/LogsPanel.d.ts +1 -0
- package/dist/devtools/LogsPanel.js +12 -0
- package/dist/devtools/NetPanel.d.ts +4 -0
- package/dist/devtools/NetPanel.js +10 -0
- package/dist/devtools/PerfPanel.d.ts +4 -0
- package/dist/devtools/PerfPanel.js +53 -0
- package/dist/devtools/TunePanel.d.ts +3 -0
- package/dist/devtools/TunePanel.js +309 -0
- package/dist/devtools/agentBridge.d.ts +41 -0
- package/dist/devtools/agentBridge.js +266 -0
- package/dist/devtools/collisionDebug.d.ts +6 -0
- package/dist/devtools/collisionDebug.js +6 -0
- package/dist/devtools/collisionDebugMath.d.ts +8 -2
- package/dist/devtools/collisionDebugMath.js +24 -5
- package/dist/devtools/devtoolsOverrides.d.ts +6 -0
- package/dist/devtools/devtoolsOverrides.js +48 -0
- package/dist/devtools/panelAtoms.d.ts +9 -0
- package/dist/devtools/panelAtoms.js +10 -0
- package/dist/devtools/perfDiagnose.d.ts +2 -0
- package/dist/devtools/perfDiagnose.js +43 -0
- package/dist/diagnostics/RuntimeDiagnostics.d.ts +36 -0
- package/dist/diagnostics/RuntimeDiagnostics.js +80 -0
- package/dist/drivers/FrameDriver.d.ts +37 -0
- package/dist/drivers/FrameDriver.js +232 -0
- package/dist/drivers/HudOnlyDriver.d.ts +16 -0
- package/dist/drivers/HudOnlyDriver.js +60 -0
- package/dist/environment/Daylight.d.ts +23 -7
- package/dist/environment/Daylight.js +106 -13
- package/dist/environment/EnvironmentScene.js +44 -9
- package/dist/environment/VolumetricClouds.d.ts +17 -0
- package/dist/environment/VolumetricClouds.js +202 -0
- package/dist/environment/daylightCycle.d.ts +3 -1
- package/dist/environment/daylightCycle.js +3 -1
- package/dist/environment/groundPadMath.d.ts +3 -0
- package/dist/environment/groundPadMath.js +3 -0
- package/dist/environment/index.d.ts +1 -0
- package/dist/environment/index.js +1 -0
- package/dist/environment/skyLightingPolicy.d.ts +2 -0
- package/dist/environment/skyLightingPolicy.js +2 -0
- package/dist/environment/terrainGroundColor.d.ts +9 -0
- package/dist/environment/terrainGroundColor.js +22 -0
- package/dist/gameKit.d.ts +27 -0
- package/dist/gameKit.js +29 -0
- package/dist/hotbarActions.d.ts +26 -0
- package/dist/hotbarActions.js +27 -0
- package/dist/inputSink.d.ts +16 -4
- package/dist/inputSink.js +57 -7
- package/dist/map/MapMarkerBeacons.d.ts +3 -2
- package/dist/materialOverride.d.ts +10 -0
- package/dist/materialOverride.js +15 -3
- package/dist/multiplayer.js +8 -2
- package/dist/postfx/PostProcessing.d.ts +9 -1
- package/dist/postfx/PostProcessing.js +56 -11
- package/dist/postfx/gradeShader.js +9 -1
- package/dist/presentationResolve.d.ts +35 -0
- package/dist/presentationResolve.js +51 -0
- package/dist/registry.d.ts +4 -2
- package/dist/render/EnvironmentLighting.d.ts +10 -0
- package/dist/render/EnvironmentLighting.js +34 -0
- package/dist/render/SceneLighting.d.ts +7 -0
- package/dist/render/SceneLighting.js +18 -0
- package/dist/render/SceneModels.d.ts +14 -0
- package/dist/render/SceneModels.js +337 -0
- package/dist/render/assetBase.d.ts +17 -0
- package/dist/render/assetBase.js +35 -0
- package/dist/render/defaultSurface.d.ts +29 -0
- package/dist/render/defaultSurface.js +101 -0
- package/dist/render/modelLoad.d.ts +24 -0
- package/dist/render/modelLoad.js +76 -0
- package/dist/render/modelRender.d.ts +11 -0
- package/dist/render/modelRender.js +15 -0
- package/dist/render/resolveModel.d.ts +54 -3
- package/dist/render/resolveModel.js +116 -4
- package/dist/render/useEntityRenderCues.d.ts +13 -0
- package/dist/render/useEntityRenderCues.js +62 -0
- package/dist/scatter/InstancedScatter.d.ts +24 -0
- package/dist/scatter/InstancedScatter.js +135 -0
- package/dist/scatter/scatterModels.d.ts +25 -0
- package/dist/scatter/scatterModels.js +61 -0
- package/dist/scatter/scatterProxies.d.ts +6 -0
- package/dist/scatter/scatterProxies.js +118 -0
- package/dist/scatter.d.ts +1 -0
- package/dist/scatter.js +1 -0
- package/dist/scene/AuthoredScene.d.ts +84 -0
- package/dist/scene/AuthoredScene.js +178 -0
- package/dist/scene/CityRenderer.d.ts +2 -0
- package/dist/scene/CityRenderer.js +1031 -0
- package/dist/scene/GeneratedAssetRenderer.d.ts +14 -0
- package/dist/scene/GeneratedAssetRenderer.js +59 -0
- package/dist/scene/GrassFieldRenderer.d.ts +2 -0
- package/dist/scene/GrassFieldRenderer.js +73 -0
- package/dist/scene/PoleLineRenderer.d.ts +2 -0
- package/dist/scene/PoleLineRenderer.js +287 -0
- package/dist/scene/SoilPatchRenderer.d.ts +2 -0
- package/dist/scene/SoilPatchRenderer.js +84 -0
- package/dist/scene/StudioStage.d.ts +37 -0
- package/dist/scene/StudioStage.js +42 -0
- package/dist/scene/WaterRenderer.d.ts +2 -0
- package/dist/scene/WaterRenderer.js +61 -0
- package/dist/scene/builtinSceneKindRenderers.d.ts +2 -0
- package/dist/scene/builtinSceneKindRenderers.js +26 -0
- package/dist/scene/cityWindowMaterial.d.ts +16 -0
- package/dist/scene/cityWindowMaterial.js +81 -0
- package/dist/scene/sceneKindRenderers.d.ts +30 -0
- package/dist/scene/sceneKindRenderers.js +17 -0
- package/dist/scene.d.ts +1 -0
- package/dist/scene.js +1 -0
- package/dist/settings/appliedSettings.d.ts +7 -1
- package/dist/settings/appliedSettings.js +13 -2
- package/dist/settings/settingsController.d.ts +2 -0
- package/dist/settings/settingsController.js +22 -1
- package/dist/shellConstants.d.ts +4 -0
- package/dist/shellConstants.js +4 -0
- package/dist/shellMovement.d.ts +8 -0
- package/dist/shellMovement.js +11 -0
- package/dist/shellPointer.d.ts +20 -0
- package/dist/shellPointer.js +28 -0
- package/dist/structures/PlacementGhost.d.ts +4 -0
- package/dist/structures/PlacementGhost.js +4 -0
- package/dist/structures/TransformGizmo.d.ts +53 -0
- package/dist/structures/TransformGizmo.js +59 -0
- package/dist/structures/index.d.ts +1 -0
- package/dist/structures/index.js +1 -0
- package/dist/terrain/GrassField.d.ts +11 -3
- package/dist/terrain/GrassField.js +16 -6
- package/dist/terrain/TerraformBrushCursor.js +3 -0
- package/dist/terrain/grassBudget.d.ts +11 -2
- package/dist/terrain/grassBudget.js +20 -4
- package/dist/terrain/grassGeometry.d.ts +35 -0
- package/dist/terrain/grassGeometry.js +85 -20
- package/dist/terrain/grassMaterial.d.ts +20 -0
- package/dist/terrain/grassMaterial.js +68 -13
- package/dist/terrain/heightfieldGeometry.d.ts +34 -0
- package/dist/terrain/heightfieldGeometry.js +109 -0
- package/dist/terrain/index.d.ts +1 -0
- package/dist/terrain/index.js +1 -0
- package/dist/terrain/random.d.ts +3 -0
- package/dist/terrain/random.js +3 -0
- package/dist/terrain/soilPatchMaterial.d.ts +23 -0
- package/dist/terrain/soilPatchMaterial.js +147 -0
- package/dist/terrain/terrainDetailMaterial.d.ts +19 -2
- package/dist/terrain/terrainDetailMaterial.js +87 -7
- package/dist/terrain/terrainMath.d.ts +8 -1
- package/dist/terrain/terrainMath.js +8 -1
- package/dist/touch/TouchControlsOverlay.d.ts +9 -5
- package/dist/touch/TouchControlsOverlay.js +201 -22
- package/dist/useShellMultiplayerSync.d.ts +9 -0
- package/dist/useShellMultiplayerSync.js +98 -0
- package/dist/visibility/CullingProvider.js +1 -1
- package/dist/water/Ocean.d.ts +7 -1
- package/dist/water/Ocean.js +16 -3
- package/dist/water/OceanConfig.d.ts +11 -0
- package/dist/water/OceanConfig.js +8 -0
- package/dist/water/OceanMaterial.d.ts +12 -0
- package/dist/water/OceanMaterial.js +9 -0
- package/dist/water/OceanShader.d.ts +2 -2
- package/dist/water/OceanShader.js +78 -10
- package/dist/weather/fireSpreadPose.d.ts +1 -0
- package/dist/weather/fireSpreadPose.js +1 -0
- package/dist/weather/weatherGeometry.d.ts +1 -0
- package/dist/weather/weatherGeometry.js +1 -0
- package/dist/weather/weatherMath.d.ts +3 -0
- package/dist/weather/weatherMath.js +3 -0
- package/dist/weather/weatherUniforms.d.ts +3 -0
- package/dist/weather/weatherUniforms.js +3 -0
- package/dist/world/PlaceScene.d.ts +11 -0
- package/dist/world/PlaceScene.js +27 -0
- package/dist/world/RetainedVfx.d.ts +10 -0
- package/dist/world/RetainedVfx.js +136 -0
- package/dist/world/WorldHud.d.ts +49 -2
- package/dist/world/WorldHud.js +87 -2
- package/dist/world/WorldScene.d.ts +21 -0
- package/dist/world/WorldScene.js +186 -0
- package/dist/world/WorldVfx.d.ts +9 -0
- package/dist/world/WorldVfx.js +184 -0
- package/dist/world/entityPose.d.ts +2 -0
- package/dist/world/entityPose.js +2 -0
- package/dist/world/floatTextStyle.d.ts +1 -0
- package/dist/world/floatTextStyle.js +1 -0
- package/dist/world/telegraphPulse.d.ts +1 -0
- package/dist/world/telegraphPulse.js +1 -0
- package/dist/world/worldBarSamples.d.ts +25 -0
- package/dist/world/worldBarSamples.js +38 -0
- package/dist/worldSky.d.ts +11 -0
- package/dist/worldSky.js +21 -0
- package/dist/worldSync.d.ts +2 -1
- package/dist/worldSync.js +2 -1
- package/package.json +6 -6
- package/skills/game-design/SKILL.md +28 -0
- package/skills/game-design/agents/openai.yaml +4 -0
- package/skills/game-design/references/application-playbook.md +170 -0
- package/skills/game-design/references/field-guide.md +288 -0
- package/skills/jgengine/SKILL.md +54 -0
- package/skills/jgengine/api.md +527 -0
- package/skills/jgengine/capabilities.md +131 -0
- package/skills/jgengine/recipes/minimal-game.md +88 -0
- package/skills/jgengine-ui/SKILL.md +41 -0
- package/skills/jgengine-ui/api.md +2007 -0
- package/skills/jgengine-ui/capabilities.md +211 -0
- package/skills/jgengine-ui/recipes/portable-minimap.md +150 -0
- package/skills/jgengine-ui/reference.md +513 -0
- package/skills/jgengine-ui/references/visual-scorecard.md +73 -0
- package/skills/jgengine-world/SKILL.md +51 -0
- package/skills/jgengine-world/api.md +3056 -0
- package/skills/jgengine-world/capabilities.md +476 -0
- package/skills/jgengine-world/recipes/commanding-entities.md +128 -0
- package/skills/jgengine-world/reference.md +261 -0
- package/skills/level-design/SKILL.md +54 -0
- package/skills/level-design/agents/openai.yaml +4 -0
- package/skills/level-design/references/application-playbook.md +192 -0
- package/skills/level-design/references/field-guide.md +337 -0
- package/skills/level-design/references/live-editor-loop.md +179 -0
- package/dist/cartridge.d.ts +0 -145
- package/dist/cartridge.js +0 -246
- package/llms.txt +0 -2761
package/README.md
CHANGED
|
@@ -13,7 +13,7 @@ const games: GameRegistry = {
|
|
|
13
13
|
<GamePlayerShell playable={await games["my-game"]()} />;
|
|
14
14
|
```
|
|
15
15
|
|
|
16
|
-
Peer deps: `react`, `three`, `@react-three/fiber`, `@react-three/drei`, `three-stdlib`. The shell's HUD classes are Tailwind — add an `@source` entry for `node_modules/@jgengine/shell` in your CSS.
|
|
16
|
+
Peer deps: `react`, `three`, `@react-three/fiber`, `@react-three/drei`, `three-stdlib`. The shell's HUD classes are Tailwind — add an `@source` entry for `node_modules/@jgengine/shell` in your CSS. Apache-2.0.
|
|
17
17
|
|
|
18
18
|
Weather primitives are available from `@jgengine/shell/weather` for game scene overlays:
|
|
19
19
|
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { ResolvedPresentationEffects } from "./presentationResolve.js";
|
|
2
|
+
/** Mounts the opt-in combat VFX stack inside the 3D canvas. @internal */
|
|
3
|
+
export declare function CombatPresentation({ effects }: {
|
|
4
|
+
effects: ResolvedPresentationEffects;
|
|
5
|
+
}): import("react").JSX.Element;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { CombatCameraShake, ProjectileTracers, WorldFloatText, WorldTelegraphs, } from "./world/WorldHud.js";
|
|
3
|
+
import { WorldSpellVfx } from "./world/WorldVfx.js";
|
|
4
|
+
import { RetainedVfx } from "./world/RetainedVfx.js";
|
|
5
|
+
/** Mounts the opt-in combat VFX stack inside the 3D canvas. @internal */
|
|
6
|
+
export function CombatPresentation({ effects }) {
|
|
7
|
+
return (_jsxs(_Fragment, { children: [effects.telegraphs ? _jsx(WorldTelegraphs, {}) : null, effects.vfx ? (_jsxs(_Fragment, { children: [_jsx(WorldSpellVfx, {}), _jsx(RetainedVfx, {})] })) : null, effects.floatText ? _jsx(WorldFloatText, {}) : null, effects.tracers ? _jsx(ProjectileTracers, {}) : null, effects.shake ? _jsx(CombatCameraShake, {}) : null] }));
|
|
8
|
+
}
|
package/dist/GameHost.d.ts
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
|
+
import { type ComponentType } from "react";
|
|
2
|
+
import type { EditorCatalogDefinition } from "@jgengine/core/editor/types";
|
|
1
3
|
import { type ResolveShellMultiplayerArgs, type ShellMultiplayer } from "./multiplayer.js";
|
|
2
4
|
import type { PlayableGame } from "./registry.js";
|
|
5
|
+
/** Structural shape of the module `GameHost`'s `editor` loader resolves — `import("@jgengine/editor")` satisfies it. */
|
|
6
|
+
export interface EditorSummonModule {
|
|
7
|
+
EditorApp: ComponentType<{
|
|
8
|
+
gameId: string;
|
|
9
|
+
playable: PlayableGame;
|
|
10
|
+
catalogs?: readonly EditorCatalogDefinition[];
|
|
11
|
+
}>;
|
|
12
|
+
}
|
|
13
|
+
/** Props for {@link GameHost}: the playable, optional multiplayer overrides, and the optional editor loader that enables the engine-owned F2+E summon. */
|
|
3
14
|
export interface GameHostProps {
|
|
4
15
|
playable: PlayableGame;
|
|
5
16
|
gameId?: string;
|
|
@@ -8,5 +19,18 @@ export interface GameHostProps {
|
|
|
8
19
|
multiplayer?: ShellMultiplayer | null;
|
|
9
20
|
/** Tried before the built-in {@link resolveShellMultiplayer}; falls back to it when this returns `null`. */
|
|
10
21
|
resolveMultiplayer?: (args: ResolveShellMultiplayerArgs) => ShellMultiplayer | null;
|
|
22
|
+
/**
|
|
23
|
+
* Editor loader — pass `() => import("@jgengine/editor")` and the host owns the whole summon:
|
|
24
|
+
* `?mode=editor`, the F2+E chord, `window.__jgengineSummonEditor`, the dev save endpoint, and the
|
|
25
|
+
* lazy `EditorApp` mount (with the playable's `editorLayers`/`editorCatalogs`). The editor package
|
|
26
|
+
* stays a lazy chunk the game bundles only when this prop is set.
|
|
27
|
+
*/
|
|
28
|
+
editor?: () => Promise<EditorSummonModule>;
|
|
11
29
|
}
|
|
12
|
-
|
|
30
|
+
/**
|
|
31
|
+
* The one documented mount: resolves multiplayer for the playable and renders the shell. With the
|
|
32
|
+
* `editor` loader prop it also owns the whole editor summon (F2+E, `?mode=editor`, dev save endpoint).
|
|
33
|
+
*
|
|
34
|
+
* @capability mount-game mount a defined game in the browser — `<GameHost playable={game} editor={() => import("@jgengine/editor")} />`
|
|
35
|
+
*/
|
|
36
|
+
export declare function GameHost({ playable, gameId, wsUrl, multiplayer, resolveMultiplayer, editor }: GameHostProps): import("react").JSX.Element;
|
package/dist/GameHost.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { useMemo } from "react";
|
|
2
|
+
import { lazy, Suspense, useEffect, useMemo, useState } from "react";
|
|
3
|
+
import { installSaveEndpoint } from "@jgengine/core/devtools/saveEndpoint";
|
|
3
4
|
import { multiplayerAdapterKind } from "@jgengine/core/runtime/adapter";
|
|
4
5
|
import { GamePlayerShell } from "./GamePlayerShell.js";
|
|
5
6
|
import { resolveShellMultiplayer } from "./multiplayer.js";
|
|
@@ -11,13 +12,65 @@ function warnUndrivenAdapter(kind) {
|
|
|
11
12
|
console.warn(`GameHost: game declares multiplayer adapter "${kind}", which the built-in shell resolver cannot drive. ` +
|
|
12
13
|
"Running offline. Pass a prebuilt session via the multiplayer prop, or a resolveMultiplayer prop, to GameHost.");
|
|
13
14
|
}
|
|
14
|
-
|
|
15
|
+
function initialEditorMode(enabled) {
|
|
16
|
+
if (!enabled || typeof window === "undefined")
|
|
17
|
+
return false;
|
|
18
|
+
return new URLSearchParams(window.location.search).get("mode") === "editor";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* The one documented mount: resolves multiplayer for the playable and renders the shell. With the
|
|
22
|
+
* `editor` loader prop it also owns the whole editor summon (F2+E, `?mode=editor`, dev save endpoint).
|
|
23
|
+
*
|
|
24
|
+
* @capability mount-game mount a defined game in the browser — `<GameHost playable={game} editor={() => import("@jgengine/editor")} />`
|
|
25
|
+
*/
|
|
26
|
+
export function GameHost({ playable, gameId, wsUrl, multiplayer, resolveMultiplayer, editor }) {
|
|
27
|
+
const resolvedGameId = gameId ?? playable.game.name;
|
|
28
|
+
const [editorOpen, setEditorOpen] = useState(() => initialEditorMode(editor !== undefined));
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
if (editor === undefined)
|
|
31
|
+
return;
|
|
32
|
+
// Self-guards against production builds; the endpoint just marks where dev saves land.
|
|
33
|
+
return installSaveEndpoint("/__jgengine/save", resolvedGameId);
|
|
34
|
+
}, [editor, resolvedGameId]);
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
if (editor === undefined || editorOpen)
|
|
37
|
+
return;
|
|
38
|
+
const summon = () => setEditorOpen(true);
|
|
39
|
+
const host = window;
|
|
40
|
+
host.__jgengineSummonEditor = summon;
|
|
41
|
+
let f2Held = false;
|
|
42
|
+
const onKeyDown = (event) => {
|
|
43
|
+
if (event.code === "F2")
|
|
44
|
+
f2Held = true;
|
|
45
|
+
else if (event.code === "KeyE" && f2Held) {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
summon();
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
const onKeyUp = (event) => {
|
|
51
|
+
if (event.code === "F2")
|
|
52
|
+
f2Held = false;
|
|
53
|
+
};
|
|
54
|
+
window.addEventListener("keydown", onKeyDown);
|
|
55
|
+
window.addEventListener("keyup", onKeyUp);
|
|
56
|
+
return () => {
|
|
57
|
+
window.removeEventListener("keydown", onKeyDown);
|
|
58
|
+
window.removeEventListener("keyup", onKeyUp);
|
|
59
|
+
if (host.__jgengineSummonEditor === summon)
|
|
60
|
+
delete host.__jgengineSummonEditor;
|
|
61
|
+
};
|
|
62
|
+
}, [editor, editorOpen]);
|
|
63
|
+
const EditorLazy = useMemo(() => {
|
|
64
|
+
if (editor === undefined)
|
|
65
|
+
return null;
|
|
66
|
+
return lazy(async () => ({ default: (await editor()).EditorApp }));
|
|
67
|
+
}, [editor]);
|
|
15
68
|
const resolved = useMemo(() => {
|
|
16
69
|
if (multiplayer !== undefined)
|
|
17
70
|
return multiplayer;
|
|
18
71
|
const args = {
|
|
19
72
|
game: playable.game,
|
|
20
|
-
gameId:
|
|
73
|
+
gameId: resolvedGameId,
|
|
21
74
|
url: wsUrl,
|
|
22
75
|
force: wsUrl !== undefined,
|
|
23
76
|
};
|
|
@@ -28,6 +81,9 @@ export function GameHost({ playable, gameId, wsUrl, multiplayer, resolveMultipla
|
|
|
28
81
|
warnUndrivenAdapter(kind);
|
|
29
82
|
}
|
|
30
83
|
return session;
|
|
31
|
-
}, [playable,
|
|
84
|
+
}, [playable, resolvedGameId, wsUrl, multiplayer, resolveMultiplayer]);
|
|
85
|
+
if (editorOpen && EditorLazy !== null) {
|
|
86
|
+
return (_jsx(Suspense, { fallback: null, children: _jsx(EditorLazy, { gameId: resolvedGameId, playable: playable, catalogs: playable.editorCatalogs }) }));
|
|
87
|
+
}
|
|
32
88
|
return _jsx(GamePlayerShell, { playable: playable, multiplayer: resolved });
|
|
33
89
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function GamePhaseStamp(): null;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
import { useGamePhase } from "@jgengine/react/hooks";
|
|
3
|
+
export function GamePhaseStamp() {
|
|
4
|
+
const { phase } = useGamePhase();
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
document.documentElement.dataset.jgPhase = phase;
|
|
7
|
+
}, [phase]);
|
|
8
|
+
return null;
|
|
9
|
+
}
|
package/dist/GamePlayer.d.ts
CHANGED
|
@@ -8,4 +8,9 @@ export type GamePlayerProps = {
|
|
|
8
8
|
loading?: ReactNode;
|
|
9
9
|
multiplayer?: ShellMultiplayer | null;
|
|
10
10
|
};
|
|
11
|
+
/**
|
|
12
|
+
* Registry-driven lazy loader over {@link GamePlayerShell} for multi-game hosts.
|
|
13
|
+
* Games mount through `GameHost` — the one documented mount.
|
|
14
|
+
* @internal
|
|
15
|
+
*/
|
|
11
16
|
export declare function GamePlayer({ gameId, registry, fallbackGameId, loading, multiplayer }: GamePlayerProps): import("react").JSX.Element;
|
package/dist/GamePlayer.js
CHANGED
|
@@ -2,6 +2,11 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { GamePlayerShell } from "./GamePlayerShell.js";
|
|
4
4
|
import { resolveGameLoader } from "./registry.js";
|
|
5
|
+
/**
|
|
6
|
+
* Registry-driven lazy loader over {@link GamePlayerShell} for multi-game hosts.
|
|
7
|
+
* Games mount through `GameHost` — the one documented mount.
|
|
8
|
+
* @internal
|
|
9
|
+
*/
|
|
5
10
|
export function GamePlayer({ gameId, registry, fallbackGameId, loading = null, multiplayer = null }) {
|
|
6
11
|
const [playable, setPlayable] = useState(null);
|
|
7
12
|
useEffect(() => {
|
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
import { type ActionStateTracker } from "@jgengine/core/input/actionBindings";
|
|
2
|
-
import type { Aim } from "@jgengine/core/scene/spatial";
|
|
3
1
|
import { type GameContext } from "@jgengine/core/runtime/gameContext";
|
|
4
|
-
import { type CommandSink } from "./commandSink.js";
|
|
5
|
-
import type { SkyEnvironmentDescriptor, WorldFeature } from "@jgengine/core/world/features";
|
|
6
2
|
import type { ShellMultiplayer } from "./multiplayer.js";
|
|
7
3
|
import type { PlayableGame } from "./registry.js";
|
|
8
|
-
/** Actions from `input` currently held down, for `ctx.input.publish` (#164.1); includes reserved movement/jump actions. */
|
|
9
|
-
export declare function heldActionsFor(tracker: Pick<ActionStateTracker<string>, "isDown">, actions: readonly string[]): string[];
|
|
10
|
-
/** Whether a bound action should fire this frame: on press, or on repeat interval while held (shared by `FrameDriver` and `HudOnlyDriver`). */
|
|
11
|
-
export declare function shouldFireBoundAction(tracker: Pick<ActionStateTracker<string>, "isDown" | "wasPressed">, action: string, input: PlayableGame["game"]["input"], repeatFiredAt: ReadonlyMap<string, number>, now: number): boolean;
|
|
12
|
-
/** Resolves and runs the command bound to `action` via the shell's action→command convention (shared by `FrameDriver` and `HudOnlyDriver`). */
|
|
13
|
-
export declare function dispatchBoundAction(ctx: GameContext, action: string, yaw: number, pitch: number, aim: Aim, reserved?: ReadonlySet<string>, sink?: CommandSink): void;
|
|
14
4
|
export { applyMotionImpulses } from "@jgengine/core/runtime/motionIntents";
|
|
15
5
|
export { nearbyObstacles } from "@jgengine/core/movement/movementModel";
|
|
16
6
|
export { resolvePhysicsTuning } from "@jgengine/core/movement/playerMovement";
|
|
17
7
|
export { hasEnvironmentTerrain } from "@jgengine/core/world/terrain";
|
|
18
|
-
/**
|
|
19
|
-
|
|
8
|
+
/**
|
|
9
|
+
* The shell body `GameHost` renders after resolving multiplayer. Hosts that resolve their own
|
|
10
|
+
* sessions (the dev runner) render it directly; games mount through `GameHost`.
|
|
11
|
+
* @internal
|
|
12
|
+
*/
|
|
20
13
|
export declare function GamePlayerShell({ playable, multiplayer: rawMultiplayer, poster, onContextReady, }: {
|
|
21
14
|
playable: PlayableGame;
|
|
22
15
|
multiplayer?: ShellMultiplayer | null;
|