@jgengine/shell 0.11.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.
Files changed (130) hide show
  1. package/CHANGELOG.md +26 -0
  2. package/dist/CombatPresentation.d.ts +5 -0
  3. package/dist/CombatPresentation.js +8 -0
  4. package/dist/GameHost.d.ts +25 -1
  5. package/dist/GameHost.js +60 -4
  6. package/dist/GamePlayer.d.ts +5 -0
  7. package/dist/GamePlayer.js +5 -0
  8. package/dist/GamePlayerShell.d.ts +5 -0
  9. package/dist/GamePlayerShell.js +48 -358
  10. package/dist/GameUiPreview.js +3 -0
  11. package/dist/Shell3dPresentation.d.ts +63 -0
  12. package/dist/Shell3dPresentation.js +302 -0
  13. package/dist/ShellChrome.d.ts +51 -0
  14. package/dist/ShellChrome.js +51 -0
  15. package/dist/ShellHudPresentation.d.ts +41 -0
  16. package/dist/ShellHudPresentation.js +22 -0
  17. package/dist/audio/audioEngine.d.ts +4 -0
  18. package/dist/audio/audioEngine.js +111 -26
  19. package/dist/audio/audioWire.d.ts +22 -4
  20. package/dist/audio/audioWire.js +46 -3
  21. package/dist/audio/loopParams.d.ts +20 -0
  22. package/dist/audio/loopParams.js +28 -0
  23. package/dist/camera/GameCameraRig.js +6 -1
  24. package/dist/camera/cameraRigs.d.ts +3 -1
  25. package/dist/camera/cameraRigs.js +21 -3
  26. package/dist/camera/rigMath.d.ts +20 -0
  27. package/dist/camera/rigMath.js +29 -0
  28. package/dist/defineGame.d.ts +15 -1
  29. package/dist/defineGame.js +26 -4
  30. package/dist/devtools/DevtoolsOverlay.d.ts +4 -4
  31. package/dist/devtools/DevtoolsOverlay.js +28 -12
  32. package/dist/devtools/agentBridge.js +4 -0
  33. package/dist/devtools/perfDiagnose.js +1 -1
  34. package/dist/diagnostics/RuntimeDiagnostics.d.ts +7 -0
  35. package/dist/diagnostics/RuntimeDiagnostics.js +23 -12
  36. package/dist/environment/EnvironmentScene.js +12 -3
  37. package/dist/environment/terrainGroundColor.d.ts +9 -0
  38. package/dist/environment/terrainGroundColor.js +22 -0
  39. package/dist/gameKit.d.ts +27 -0
  40. package/dist/gameKit.js +29 -0
  41. package/dist/map/MapMarkerBeacons.d.ts +3 -2
  42. package/dist/postfx/PostProcessing.d.ts +9 -1
  43. package/dist/postfx/PostProcessing.js +11 -4
  44. package/dist/presentationResolve.d.ts +35 -0
  45. package/dist/presentationResolve.js +51 -0
  46. package/dist/registry.d.ts +1 -0
  47. package/dist/render/assetBase.d.ts +17 -0
  48. package/dist/render/assetBase.js +35 -0
  49. package/dist/render/modelLoad.js +4 -1
  50. package/dist/render/resolveModel.d.ts +15 -0
  51. package/dist/render/resolveModel.js +37 -2
  52. package/dist/scatter/InstancedScatter.js +5 -0
  53. package/dist/scatter/scatterProxies.js +24 -0
  54. package/dist/scene/AuthoredScene.d.ts +3 -1
  55. package/dist/scene/AuthoredScene.js +7 -2
  56. package/dist/scene/CityRenderer.d.ts +2 -0
  57. package/dist/scene/CityRenderer.js +1031 -0
  58. package/dist/scene/GrassFieldRenderer.js +53 -5
  59. package/dist/scene/PoleLineRenderer.d.ts +2 -0
  60. package/dist/scene/PoleLineRenderer.js +287 -0
  61. package/dist/scene/SoilPatchRenderer.js +70 -7
  62. package/dist/scene/WaterRenderer.js +34 -10
  63. package/dist/scene/builtinSceneKindRenderers.js +4 -0
  64. package/dist/scene/cityWindowMaterial.d.ts +16 -0
  65. package/dist/scene/cityWindowMaterial.js +81 -0
  66. package/dist/scene/sceneKindRenderers.d.ts +2 -0
  67. package/dist/settings/appliedSettings.d.ts +2 -1
  68. package/dist/settings/appliedSettings.js +4 -2
  69. package/dist/structures/TransformGizmo.d.ts +11 -1
  70. package/dist/structures/TransformGizmo.js +9 -5
  71. package/dist/terrain/GrassField.d.ts +11 -3
  72. package/dist/terrain/GrassField.js +16 -6
  73. package/dist/terrain/grassGeometry.d.ts +33 -1
  74. package/dist/terrain/grassGeometry.js +83 -21
  75. package/dist/terrain/grassMaterial.d.ts +18 -0
  76. package/dist/terrain/grassMaterial.js +66 -13
  77. package/dist/terrain/heightfieldGeometry.d.ts +34 -0
  78. package/dist/terrain/heightfieldGeometry.js +109 -0
  79. package/dist/terrain/index.d.ts +1 -0
  80. package/dist/terrain/index.js +1 -0
  81. package/dist/terrain/soilPatchMaterial.d.ts +15 -2
  82. package/dist/terrain/soilPatchMaterial.js +46 -8
  83. package/dist/terrain/terrainDetailMaterial.js +15 -2
  84. package/dist/water/Ocean.d.ts +7 -1
  85. package/dist/water/Ocean.js +16 -3
  86. package/dist/water/OceanConfig.d.ts +9 -0
  87. package/dist/water/OceanConfig.js +6 -0
  88. package/dist/water/OceanMaterial.d.ts +12 -0
  89. package/dist/water/OceanMaterial.js +9 -0
  90. package/dist/water/OceanShader.d.ts +2 -2
  91. package/dist/water/OceanShader.js +78 -10
  92. package/dist/world/PlaceScene.d.ts +11 -0
  93. package/dist/world/PlaceScene.js +27 -0
  94. package/dist/world/WorldScene.js +29 -2
  95. package/dist/worldSky.d.ts +7 -1
  96. package/dist/worldSky.js +11 -1
  97. package/package.json +4 -4
  98. package/skills/game-design/SKILL.md +28 -0
  99. package/skills/game-design/agents/openai.yaml +4 -0
  100. package/skills/game-design/references/application-playbook.md +170 -0
  101. package/skills/game-design/references/field-guide.md +288 -0
  102. package/skills/jgengine/SKILL.md +7 -4
  103. package/skills/jgengine/api.md +172 -79
  104. package/skills/jgengine/capabilities.md +104 -2
  105. package/skills/jgengine/recipes/minimal-game.md +88 -0
  106. package/skills/jgengine-ui/SKILL.md +15 -10
  107. package/skills/jgengine-ui/api.md +202 -47
  108. package/skills/jgengine-ui/capabilities.md +71 -2
  109. package/skills/jgengine-ui/recipes/portable-minimap.md +150 -0
  110. package/skills/jgengine-ui/reference.md +20 -7
  111. package/skills/jgengine-ui/references/visual-scorecard.md +1 -1
  112. package/skills/jgengine-world/SKILL.md +13 -0
  113. package/skills/jgengine-world/api.md +419 -15
  114. package/skills/jgengine-world/capabilities.md +108 -2
  115. package/skills/jgengine-world/recipes/commanding-entities.md +128 -0
  116. package/skills/jgengine-world/reference.md +43 -4
  117. package/skills/level-design/SKILL.md +54 -0
  118. package/skills/level-design/agents/openai.yaml +4 -0
  119. package/skills/level-design/references/application-playbook.md +192 -0
  120. package/skills/level-design/references/field-guide.md +337 -0
  121. package/skills/level-design/references/live-editor-loop.md +179 -0
  122. package/dist/cartridge/runtime.d.ts +0 -15
  123. package/dist/cartridge/runtime.js +0 -556
  124. package/dist/cartridge/spec.d.ts +0 -188
  125. package/dist/cartridge/spec.js +0 -19
  126. package/dist/cartridge/validate.d.ts +0 -2
  127. package/dist/cartridge/validate.js +0 -78
  128. package/dist/cartridge.d.ts +0 -145
  129. package/dist/cartridge.js +0 -246
  130. package/skills/jgengine/reference-cartridge.md +0 -72
package/CHANGELOG.md CHANGED
@@ -12,6 +12,32 @@ Agents building on the published SDK can also read this programmatically:
12
12
  same data as typed values, so an updater can diff its installed version against
13
13
  the latest and surface the migration steps.
14
14
 
15
+ ## 0.12.0
16
+
17
+ ### Migrate
18
+
19
+ - **Author games through `defineGame` from `@jgengine/shell`** — it is the single public authoring entry (and carries the define-game capability tag). Core's constructor was renamed `defineGame` → `defineGameDefinition` (`@jgengine/core/game/defineGame`); only hosts and tooling call it. If you imported `defineGame` from core, switch the import to `@jgengine/shell`. `GamePlayer`/`GamePlayerShell` are `@internal` now — `GameHost` is the documented mount, and it owns the editor summon (`?mode=editor`, F2+E, dev save endpoint), so delete any per-game editor bootstrap.
20
+ - **Declare your world with `world()`** (`@jgengine/core/world/place`): `world({ id, ground: { mode, size, surface? }, physics? })` with `flat` / `round` / `voxel` / `board` ground. New scaffolds emit a thin infinite flat place instead of the old 96 m meadow. `environment()` still works but is demoted to the legacy consumption path for editor-written scene data — **nothing required** for existing games; new worlds should use `world()` and author all dressing in the editor.
21
+ - Everything else is additive — stat pools, minimap marker sources, auction house, city/path generation, editor workspaces require no changes to existing games.
22
+
23
+ ### Added
24
+
25
+ - **World = place: `world()` API** (#1178) — a world is substrate + laws, not a coded diorama. `@jgengine/core/world/place` ships `world({ id, ground: { mode, size, surface?, generator? }, physics? })`; size is discriminated by mode (flat `{x,z}` with `Infinity` axes, round `{radius}`, voxel generator domain, board `{x,y}` cells — TS and runtime both reject mismatches). `ground.surface` carries matter/feel laws (metal vs slime vs felt) read by the same rule systems; per-place `physics` resolves over the game default; multiple worlds per game are first-class. The shell renders place substrates (`PlaceScene`) under the engine default sky; seeds derive from world id + save via `seedForPlace`.
26
+ - **`@jgengine/shell/gameKit`** — happy-path authoring surface: authoring, mount, stores, systems, authored-scene helpers, HUD primitives, seeded rng in one import.
27
+ - **Portable generic stat pools** — `@jgengine/core/stats/statPool`: bounded named pools (health, energy, heat, ammo…) with the entity-stats integration rebuilt on them; recipe in skill `jgengine-combat`.
28
+ - **Auction-house economy primitives** (#1086) — `@jgengine/core/economy/auctionBook` (timed bid auctions, escrowed bids, outbid refunds, optional buyout, anti-snipe close extension, seller settlement minus house cut) plus market price history.
29
+ - **Portable minimap marker sources** — core world seam feeding game minimaps; recipe in skill `jgengine-ui`.
30
+ - **Unified seed-driven path network + city generation v2** (#1103, #1106) — streets/blocks/buildings with grid-ness, curviness, branching and block-size dials; zone bands, weighted building-class mixes, massing pieces, balance presets, junction-centered clustering, road-derived block polygons and parcels. Shell renders realistic roads: real intersections, curbs, lane lines, tunnels, and roads riding bridge decks.
31
+ - **Physical fidelity** — mesh-accurate hitboxes (shots pass through holes in concave models, #1075), auto-fit entity/object colliders from measured model bounds (#1072), movement obstruction reading fitted boxes + compound-box openings (#1077).
32
+ - **Editor overhaul** (#1110) — materials / lighting / scripting / animation-timeline / multiplayer workspaces, command palette, minimap bake wired end-to-end (#1036), real offscreen GLB thumbnails in the content browser, hierarchy drag-drop + keyboard + context menus + per-object visibility/lock, multi-select inspector, console RPC, asset drag-place, ortho projection, pivot modes, play chrome.
33
+ - **Editor authoring pipeline** — author entity definitions and starter catalogs (#1012), author catalogs/schema fields in the Data tab (#1043), promote an authored scene folder into a runnable game (#1011), authored triggers promoted to a shared primitive with goal/win rules (#1013), asset import rewrites the game's `game/assets.ts` (#1042).
34
+ - **Skills** — research-backed `game-design` and `level-design` skills (#962); every-game-owns-custom-UI invariant codified (#1148).
35
+
36
+ ### Changed
37
+
38
+ - `npx jgengine create` scaffolds a thin infinite flat `world()` place; the editor `blankWorld` no longer pre-bakes seeded grass. Dressing belongs in `editor.scene.json`.
39
+ - Environment studio visual-quality pass — turf tufts, depth-aware water, relief soil, weathered poles; grass fields no longer rebuild geometry per frame (#1090).
40
+
15
41
  ## 0.11.0
16
42
 
17
43
  ### Migrate
@@ -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
+ }
@@ -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
- export declare function GameHost({ playable, gameId, wsUrl, multiplayer, resolveMultiplayer }: GameHostProps): import("react").JSX.Element;
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
- export function GameHost({ playable, gameId, wsUrl, multiplayer, resolveMultiplayer }) {
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: gameId ?? playable.game.name,
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, gameId, wsUrl, multiplayer, resolveMultiplayer]);
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
  }
@@ -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;
@@ -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(() => {
@@ -5,6 +5,11 @@ export { applyMotionImpulses } from "@jgengine/core/runtime/motionIntents";
5
5
  export { nearbyObstacles } from "@jgengine/core/movement/movementModel";
6
6
  export { resolvePhysicsTuning } from "@jgengine/core/movement/playerMovement";
7
7
  export { hasEnvironmentTerrain } from "@jgengine/core/world/terrain";
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
+ */
8
13
  export declare function GamePlayerShell({ playable, multiplayer: rawMultiplayer, poster, onContextReady, }: {
9
14
  playable: PlayableGame;
10
15
  multiplayer?: ShellMultiplayer | null;