@jgengine/react 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.
Files changed (72) hide show
  1. package/CHANGELOG.md +39 -2
  2. package/LICENSE +203 -661
  3. package/README.md +1 -1
  4. package/dist/actionHud.d.ts +174 -0
  5. package/dist/actionHud.js +294 -0
  6. package/dist/bars.d.ts +103 -0
  7. package/dist/bars.js +180 -0
  8. package/dist/barsPreview.d.ts +4 -0
  9. package/dist/barsPreview.js +47 -0
  10. package/dist/cards.d.ts +59 -0
  11. package/dist/cards.js +116 -0
  12. package/dist/chat.d.ts +3 -1
  13. package/dist/chat.js +2 -2
  14. package/dist/components.d.ts +28 -1
  15. package/dist/components.js +36 -1
  16. package/dist/display.d.ts +1 -0
  17. package/dist/display.js +1 -0
  18. package/dist/engineStore.d.ts +3 -0
  19. package/dist/engineStore.js +3 -0
  20. package/dist/fogOverlay.d.ts +3 -0
  21. package/dist/fogOverlay.js +3 -0
  22. package/dist/gameViewport.js +16 -0
  23. package/dist/hooks.d.ts +40 -0
  24. package/dist/hooks.js +69 -1
  25. package/dist/hud.d.ts +104 -0
  26. package/dist/hud.js +155 -0
  27. package/dist/hudFrame.d.ts +47 -0
  28. package/dist/hudFrame.js +80 -0
  29. package/dist/hudLayout.d.ts +31 -2
  30. package/dist/hudLayout.js +127 -10
  31. package/dist/hudLayoutPersist.d.ts +23 -0
  32. package/dist/hudLayoutPersist.js +19 -0
  33. package/dist/hudTheme.d.ts +76 -0
  34. package/dist/hudTheme.js +156 -0
  35. package/dist/hudThemePreview.d.ts +4 -0
  36. package/dist/hudThemePreview.js +37 -0
  37. package/dist/iconTreatment.d.ts +50 -0
  38. package/dist/iconTreatment.js +84 -0
  39. package/dist/iconsPreview.d.ts +4 -0
  40. package/dist/iconsPreview.js +29 -0
  41. package/dist/index.d.ts +17 -0
  42. package/dist/index.js +17 -0
  43. package/dist/keyHint.d.ts +30 -0
  44. package/dist/keyHint.js +31 -0
  45. package/dist/map.d.ts +141 -11
  46. package/dist/map.js +138 -16
  47. package/dist/save.d.ts +25 -0
  48. package/dist/save.js +37 -0
  49. package/dist/selectSnapshot.d.ts +2 -0
  50. package/dist/selectSnapshot.js +2 -0
  51. package/dist/selectionHud.d.ts +139 -0
  52. package/dist/selectionHud.js +188 -0
  53. package/dist/skillCheckPaint.d.ts +2 -0
  54. package/dist/skillCheckPaint.js +2 -0
  55. package/dist/slots.d.ts +44 -0
  56. package/dist/slots.js +37 -0
  57. package/dist/startScreen.d.ts +62 -0
  58. package/dist/startScreen.js +62 -0
  59. package/dist/store.d.ts +24 -0
  60. package/dist/store.js +9 -0
  61. package/package.json +4 -4
  62. package/skills/jgengine/SKILL.md +54 -0
  63. package/skills/jgengine/api.md +527 -0
  64. package/skills/jgengine/capabilities.md +131 -0
  65. package/skills/jgengine/recipes/minimal-game.md +88 -0
  66. package/skills/jgengine-ui/SKILL.md +41 -0
  67. package/skills/jgengine-ui/api.md +2007 -0
  68. package/skills/jgengine-ui/capabilities.md +211 -0
  69. package/skills/jgengine-ui/recipes/portable-minimap.md +150 -0
  70. package/skills/jgengine-ui/reference.md +513 -0
  71. package/skills/jgengine-ui/references/visual-scorecard.md +73 -0
  72. package/llms.txt +0 -1724
@@ -0,0 +1,211 @@
1
+ <!-- GENERATED by scripts/gen-capability-index.ts — do not edit. Regenerate: bun run gen:capabilities -->
2
+
3
+ # jgengine-ui — capability index
4
+
5
+ Reach for these before hand-rolling. Each row is *the thing you need* → *the primitive that already does it*.
6
+
7
+ ## action-bar — optional skinned action-bar composition over the headless model — games own chrome
8
+
9
+ - `ActionBar` (function) · `import { ActionBar } from "@jgengine/react"`
10
+
11
+ ## action-bar-chrome — accessible grid/list toolbar renderer over an action-bar model with swappable item chrome
12
+
13
+ - `ActionBarChrome` (function) · `import { ActionBarChrome } from "@jgengine/react"`
14
+
15
+ ## action-bar-model — headless action-collection model with focus, hover, keyboard, and hotkey routing
16
+
17
+ - `useActionBar` (function) · `import { useActionBar } from "@jgengine/react"`
18
+
19
+ ## action-button — cooldown/cost/hotkey action button with complete interaction states
20
+
21
+ - `ActionButton` (function) · `import { ActionButton } from "@jgengine/react"`
22
+
23
+ ## action-from-ability-slot — adapt a combat ability-kit snapshot into an action-bar action def
24
+
25
+ - `actionFromAbilitySlot` (function) · `import { actionFromAbilitySlot } from "@jgengine/react"`
26
+
27
+ ## action-tooltip — structured action tooltip body (title, cost, cooldown, blocking notes)
28
+
29
+ - `ActionTooltip` (function) · `import { ActionTooltip } from "@jgengine/react"`
30
+
31
+ ## clock-format — format a signed time gap like a race split (+/- m:ss.ff)
32
+
33
+ - `formatDelta` (function) · `import { formatDelta } from "@jgengine/core/ui"`
34
+ - `formatDuration` (function) · `import { formatDuration } from "@jgengine/core/ui"`
35
+
36
+ ## controls-list — keybind-derived control legend that hides on touch
37
+
38
+ - `ControlsList` (function) · `import { ControlsList } from "@jgengine/react"`
39
+
40
+ ## default-look — one field that lights a scene like a shipped game (opt out with "flat")
41
+
42
+ - `LookPreset` (type) · `import { LookPreset } from "@jgengine/core/ui"`
43
+
44
+ ## distance-format — render meters as m or km for HUD stats, telemetry, and range readouts
45
+
46
+ - `formatDistance` (function) · `import { formatDistance } from "@jgengine/core/ui"`
47
+
48
+ ## entity-portrait — selectable entity portrait tile with vitals and selected/focus states
49
+
50
+ - `EntityPortrait` (function) · `import { EntityPortrait } from "@jgengine/react"`
51
+
52
+ ## entity-render-cues — live velocity/bob/fire/reload/hit/death cues for a custom renderEntity or viewmodel component
53
+
54
+ - `useEntityRenderCues` (function) · `import { useEntityRenderCues } from "@jgengine/shell/render/useEntityRenderCues"`
55
+
56
+ ## entity-summary — primary selected-entity detail panel (name, tags, vitals)
57
+
58
+ - `EntitySummary` (function) · `import { EntitySummary } from "@jgengine/react"`
59
+
60
+ ## event-meter-hud — render a core event/heat meter's live value, fraction, tier, and ready state in a HUD gauge
61
+
62
+ - `useEventMeter` (function) · `import { useEventMeter } from "@jgengine/react"`
63
+
64
+ ## heightfield-mesh-update — in-place partial update of a displaced ground plane mesh
65
+
66
+ - `displaceHeightfieldGeometry` (function) · `import { displaceHeightfieldGeometry } from "@jgengine/shell/terrain"`
67
+
68
+ ## hud-canvas — the HUD root surface — design-resolution scaling plus live panel-placement editing (F2+C)
69
+
70
+ - `HudCanvas` (function) · `import { HudCanvas } from "@jgengine/react"`
71
+
72
+ ## hud-clock — in-game time-of-day readout bound to the sim clock
73
+
74
+ - `Clock` (function) · `import { Clock } from "@jgengine/react"`
75
+
76
+ ## hud-coins — currency counter widget bound to a currency id
77
+
78
+ - `Coins` (function) · `import { Coins } from "@jgengine/react"`
79
+
80
+ ## hud-frame — optional framed panel skins (glass/plate/retro/themed) — games own product chrome
81
+
82
+ - `HudFrame` (function) · `import { HudFrame } from "@jgengine/react"`
83
+
84
+ ## hud-hotbar — optional inventory hotbar building block — games own slot chrome
85
+
86
+ - `Hotbar` (function) · `import { Hotbar } from "@jgengine/react"`
87
+
88
+ ## hud-icons — painted-icon treatment for hotbar/action slots — glyph + gradient + count badge
89
+
90
+ - `IconSchool` (type) · `import { IconSchool } from "@jgengine/react"`
91
+
92
+ ## hud-layout — persistent, live-editable HUD panel layout state for `HudCanvas`
93
+
94
+ - `useHudLayout` (function) · `import { useHudLayout } from "@jgengine/react"`
95
+
96
+ ## hud-layout-persist — inject a host callback so canvas HUD edits commit into the scene document
97
+
98
+ - `HudLayoutPersistProvider` (function) · `import { HudLayoutPersistProvider } from "@jgengine/react"`
99
+
100
+ ## hud-layout-persist-hook — read the host panel-commit port from a HUD layout widget
101
+
102
+ - `useHudLayoutPersist` (function) · `import { useHudLayoutPersist } from "@jgengine/react"`
103
+
104
+ ## hud-panel — anchored HUD slot — drop any widget in a named, player-movable panel
105
+
106
+ - `HudPanel` (function) · `import { HudPanel } from "@jgengine/react"`
107
+
108
+ ## hud-slots — atomic themed equipment/weapon/armor/potion slot grids with painted icons
109
+
110
+ - `SlotItem` (interface) · `import { SlotItem } from "@jgengine/react"`
111
+
112
+ ## hud-stat-bar — optional stat-bound bar building block (health, mana, stamina) — prefer game-owned chrome
113
+
114
+ - `StatBar` (function) · `import { StatBar } from "@jgengine/react"`
115
+
116
+ ## hud-theme — game-authored token object for bars, frames, slots, and minimap ring
117
+
118
+ - `HudThemePalette` (interface) · `import { HudThemePalette } from "@jgengine/react"`
119
+
120
+ ## hud-vitals — atomic purpose-named vitals bars (token-themed parts, not a finished HUD)
121
+
122
+ - `BarTokens` (interface) · `import { BarTokens } from "@jgengine/react"`
123
+ - `barTokens` (function) · `import { barTokens } from "@jgengine/react"`
124
+
125
+ ## key-hint — keyboard/mouse control hint that hides itself on touch
126
+
127
+ - `KeyHint` (function) · `import { KeyHint } from "@jgengine/react"`
128
+
129
+ ## keycap — styled keyboard/mouse key cap for control hints
130
+
131
+ - `Keycap` (function) · `import { Keycap } from "@jgengine/react"`
132
+
133
+ ## live-markers — a self-ticking MarkerSet kept in sync from the live scene each HUD tick — pass a rebuild(markers, ctx) that clears+repopulates, no hand-rolled setInterval
134
+
135
+ - `useLiveMarkers` (function) · `import { useLiveMarkers } from "@jgengine/react"`
136
+
137
+ ## minimap — framed circular minimap with terrain bake, fog, markers, and facing arrow
138
+
139
+ - `Minimap` (function) · `import { Minimap } from "@jgengine/react"`
140
+
141
+ ## minimap-chrome — ring frame plus edge-clamped, heading-aware marker dots to nest inside a game's own `<svg>`
142
+
143
+ - `MinimapChrome` (function) · `import { MinimapChrome } from "@jgengine/react"`
144
+
145
+ ## minimap-panel — circular minimap with zone label, clock, and compass composed together
146
+
147
+ - `MinimapPanel` (function) · `import { MinimapPanel } from "@jgengine/react"`
148
+
149
+ ## minimap-track-hud — horizontal linear track minimap (corridor/route progress) — colored zone spans and gate/player pips positioned by 0..1 fraction, sharing chrome with the radial Minimap
150
+
151
+ - `MinimapTrack` (function) · `import { MinimapTrack } from "@jgengine/react"`
152
+
153
+ ## nameplates — billboarded name + HP bar over nearby entities
154
+
155
+ - `WorldNameplates` (function) · `import { WorldNameplates } from "@jgengine/shell/world/WorldHud"`
156
+
157
+ ## ordinal-format — format a placement number as 1st/2nd/3rd for HUD ranks
158
+
159
+ - `formatOrdinal` (function) · `import { formatOrdinal } from "@jgengine/core/ui"`
160
+
161
+ ## placement-ghost — render valid/invalid placement preview mesh
162
+
163
+ - `PlacementGhost` (function) · `import { PlacementGhost } from "@jgengine/shell/structures"`
164
+
165
+ ## popover — viewport-flipping, viewport-clamped anchored popover/tooltip shell
166
+
167
+ - `Popover` (function) · `import { Popover } from "@jgengine/react"`
168
+
169
+ ## resolve-game-look — expand a look preset into concrete lighting/backdrop/post knobs
170
+
171
+ - `resolveGameLook` (function) · `import { resolveGameLook } from "@jgengine/core/ui"`
172
+
173
+ ## selection-collection — accessible portrait-strip / group-chip renderer over a selection model
174
+
175
+ - `SelectionCollectionChrome` (function) · `import { SelectionCollectionChrome } from "@jgengine/react"`
176
+
177
+ ## selection-group-chip — same-kind selection chip (icon + count) for a grouped selection
178
+
179
+ - `SelectionGroupChip` (function) · `import { SelectionGroupChip } from "@jgengine/react"`
180
+
181
+ ## selection-model — headless multi-entity selection model with primary focus, grouping, and virtualization
182
+
183
+ - `useSelectionView` (function) · `import { useSelectionView } from "@jgengine/react"`
184
+
185
+ ## selection-panel — optional selection-panel composition: summary + portrait strip / group chips
186
+
187
+ - `SelectionPanel` (function) · `import { SelectionPanel } from "@jgengine/react"`
188
+
189
+ ## speed-format — render a m/s speed as km/h, mph, knots, or m/s for speedometers and telemetry HUDs
190
+
191
+ - `formatSpeed` (function) · `import { formatSpeed } from "@jgengine/core/ui"`
192
+
193
+ ## start-screen — headless title/attract overlay the game fills and skins
194
+
195
+ - `StartScreen` (function) · `import { StartScreen } from "@jgengine/react"`
196
+
197
+ ## studio-stage — cinematic lighting rig + backdrop + turntable for parametric studios
198
+
199
+ - `StudioStage` (function) · `import { StudioStage } from "@jgengine/shell/scene/StudioStage"`
200
+
201
+ ## transform-gizmo — in-game select/move/rotate/scale gizmo
202
+
203
+ - `TransformGizmo` (const) · `import { TransformGizmo } from "@jgengine/shell/structures"`
204
+
205
+ ## vital-bar — compact current/max vital meter for an entity summary
206
+
207
+ - `VitalBar` (function) · `import { VitalBar } from "@jgengine/react"`
208
+
209
+ ## world-object-highlights — ground-ring highlight over every selected placed object
210
+
211
+ - `WorldObjectHighlights` (function) · `import { WorldObjectHighlights } from "@jgengine/shell/world/WorldHud"`
@@ -0,0 +1,150 @@
1
+ # Add the minimap to an existing React game
2
+
3
+ Use this recipe when a React game already owns its entities in an array, ECS
4
+ query, Zustand/Redux-style store, or another observable collection. JGengine
5
+ only needs a display view of those records; do not copy them into a
6
+ `MarkerSet`.
7
+
8
+ ## Install
9
+
10
+ Keep the React and React DOM versions already used by the project, then add the
11
+ two focused JGengine packages:
12
+
13
+ ```sh
14
+ bun add @jgengine/core @jgengine/react
15
+ ```
16
+
17
+ The minimap imports neither Three.js nor React Three Fiber and does not require
18
+ `GameProvider`.
19
+
20
+ ## Static entity arrays
21
+
22
+ Project an existing array directly. Keep the array stable with the same memo or
23
+ selector the project already uses.
24
+
25
+ ```tsx
26
+ import { useMemo } from "react";
27
+ import { Minimap } from "@jgengine/react/map";
28
+
29
+ interface Unit {
30
+ id: string;
31
+ x: number;
32
+ z: number;
33
+ team: "ally" | "enemy";
34
+ }
35
+
36
+ export function MapHud({
37
+ units,
38
+ cameraTarget,
39
+ }: {
40
+ units: readonly Unit[];
41
+ cameraTarget: { x: number; z: number };
42
+ }) {
43
+ const markers = useMemo(
44
+ () =>
45
+ units.map((unit) => ({
46
+ id: unit.id,
47
+ position: [unit.x, 0, unit.z] as const,
48
+ kind: unit.team,
49
+ })),
50
+ [units],
51
+ );
52
+
53
+ return (
54
+ <Minimap
55
+ markers={markers}
56
+ center={[cameraTarget.x, cameraTarget.z]}
57
+ worldRadius={120}
58
+ className="game-minimap"
59
+ />
60
+ );
61
+ }
62
+ ```
63
+
64
+ Only `id` and `position` are required. `kind`, `label`, `heading`, and `meta`
65
+ are optional display data; lifecycle timestamps are not part of this view.
66
+
67
+ ## Observable external store
68
+
69
+ Create the adapter once per store. The source caches its projected marker array
70
+ until the external store emits, so React snapshot reads do not remap the world
71
+ on every frame.
72
+
73
+ ```tsx
74
+ import { useMemo } from "react";
75
+ import { createMarkerSource } from "@jgengine/core/world/markers";
76
+ import { Minimap } from "@jgengine/react/map";
77
+
78
+ interface Unit {
79
+ id: string;
80
+ x: number;
81
+ z: number;
82
+ team: string;
83
+ name: string;
84
+ }
85
+
86
+ interface ExistingWorldStore {
87
+ subscribe(listener: () => void): () => void;
88
+ getState(): { units: readonly Unit[] };
89
+ }
90
+
91
+ export function ExistingGameMinimap({
92
+ world,
93
+ cameraTarget,
94
+ }: {
95
+ world: ExistingWorldStore;
96
+ cameraTarget: { x: number; z: number };
97
+ }) {
98
+ const markers = useMemo(
99
+ () =>
100
+ createMarkerSource({
101
+ subscribe: (listener) => world.subscribe(listener),
102
+ getSnapshot: () => world.getState().units,
103
+ project: (unit) => ({
104
+ id: unit.id,
105
+ position: [unit.x, 0, unit.z] as const,
106
+ kind: unit.team,
107
+ label: unit.name,
108
+ }),
109
+ }),
110
+ [world],
111
+ );
112
+
113
+ return (
114
+ <Minimap
115
+ markers={markers}
116
+ center={[cameraTarget.x, cameraTarget.z]}
117
+ worldRadius={120}
118
+ />
119
+ );
120
+ }
121
+ ```
122
+
123
+ For SSR, make the store's first client snapshot match the server snapshot. When
124
+ they differ structurally, pass `getServerSnapshot` to `createMarkerSource` and
125
+ read the same serialized initial units used to hydrate the external store.
126
+
127
+ ## Ownership
128
+
129
+ The existing project still owns entities, updates, persistence, simulation,
130
+ camera, renderer, input, scheduling, and the subscription. JGengine owns only
131
+ the cached entity-to-marker projection, core world-to-map projection math, and
132
+ the React SVG presentation. Save and restore the project's unit state as usual;
133
+ markers are derived data and need no parallel save format.
134
+
135
+ Use `kindStyles`, `className`, and `style` to skin the production `Minimap`.
136
+ When the project owns every chrome element, compose `MinimapChrome` inside its
137
+ own SVG instead of adopting the framed default.
138
+
139
+ ## Common traps
140
+
141
+ - Keep `getSnapshot()` array identity stable until `subscribe()` emits. This is
142
+ the React external-store contract.
143
+ - Create `createMarkerSource` outside render or in `useMemo`; recreating it each
144
+ render discards its projection cache.
145
+ - Pass world coordinates, not Three.js screen coordinates. Marker positions are
146
+ `[x, y, z]`; the minimap projects X/Z.
147
+ - Do not poll the source from a render loop. Notify subscribers when the
148
+ caller-owned collection changes.
149
+ - Do not add `createdAt` or `expiresAt` unless the project intentionally adopts
150
+ `MarkerSet` lifecycle behavior.