@jgengine/react 0.4.0 → 0.5.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 ADDED
@@ -0,0 +1,42 @@
1
+ # Changelog
2
+
3
+ All eight `@jgengine/*` packages are versioned in lockstep, so this one file
4
+ covers every release. Format follows [Keep a Changelog](https://keepachangelog.com);
5
+ each release **leads with a Migrate block** — the concrete steps to move a game
6
+ from the previous version onto the new APIs — because the point of a bump is to
7
+ let consumers pick up the better stuff, not just to list what moved.
8
+
9
+ Agents building on the published SDK can also read this programmatically:
10
+ `import { VERSION, CHANGELOG } from "@jgengine/core/meta/changelog"` gives the
11
+ same data as typed values, so an updater can diff its installed version against
12
+ the latest and surface the migration steps.
13
+
14
+ ## Unreleased
15
+
16
+ _Nothing yet._
17
+
18
+ ## 0.5.0
19
+
20
+ An additive release: **every 0.4.0 API is unchanged**, so upgrading is only a
21
+ version bump. New pure primitives across progression, inventory slots, world
22
+ geometry, and React store bindings.
23
+
24
+ ### Migrate
25
+
26
+ - Bump every `@jgengine/*` dependency to `^0.5.0` (the eight packages version in lockstep).
27
+ - No code change is required — 0.5.0 adds surface, it doesn't move or remove any.
28
+ - Optional: replace a game's hand-rolled `progression/curves.ts` with the new `leveling(...)` track. `leveling({ xpForLevel: { kind: "power", base, exponent, round: "floor" }, maxLevel })` returns `xpForLevel`, `resolve`, and `grantXp(ctx.scene.entity.stats, userId, amount, onLevelUp?)` — a drop-in for the old `xpRequiredForLevel` / `resolveLevelProgress` / `grantXp` exports. `ctx.scene.entity.stats` satisfies the primitive's `LevelingStatAccess` structurally, so no adapter is needed.
29
+
30
+ ### Added
31
+
32
+ - `@jgengine/core/game/progression` — genre-agnostic progression primitive. `curve(spec)` / `evalCurve(spec, x)` evaluate declarative scalar curves (`const`, `linear`, `power`, `geometric`, `steps`, `piecewise`, each with optional `round`/`min`/`max`) for speed-by-level, difficulty-by-wave, loot drop-rate ramps, and similar scaling. `leveling(config)` builds the stateful XP→level track (threshold accumulation, multi-level grants, cap handling, `stat.levelUp` emit) on top of an `xpForLevel` curve.
33
+ - `@jgengine/core/inventory/slotModel` — pure slot-grid primitives (`createSlots`, `placeAt`, `removeAt`, `moveSlot`).
34
+ - `@jgengine/core/world/geometry`, `/world/interiors`, `/world/placement` — pure world primitives: grid snapping, footprint AABBs and overlap, interior/exterior spaces, and placement validation.
35
+ - `@jgengine/react/engineStore` — raw-store React bindings (`useEngineState`, `useEngineStore`, `useEngineEvent`).
36
+ - Pure/functional tiers for the `trade`, `unlocks`, `quest`, and `feed` verbs in `@jgengine/core/game`.
37
+
38
+ ## 0.4.0
39
+
40
+ Baseline release: the eight `@jgengine/*` packages (core, ws, sql, react,
41
+ convex, node, shell, assets) as the first tracked version. No migration —
42
+ this is the floor changelog entries are measured against.
@@ -0,0 +1,10 @@
1
+ export interface ReadableEngineStore<TState> {
2
+ getState(): TState;
3
+ subscribe(listener: (state: TState) => void): () => void;
4
+ }
5
+ export interface EventfulEngineStore<TEventMap extends object> {
6
+ on<K extends keyof TEventMap>(eventName: K, listener: (payload: TEventMap[K]) => void): () => void;
7
+ }
8
+ export declare function useEngineState<TState>(store: ReadableEngineStore<TState>): TState;
9
+ export declare function useEngineStore<TState, TSelected>(store: ReadableEngineStore<TState>, selector: (state: TState) => TSelected): TSelected;
10
+ export declare function useEngineEvent<TEventMap extends object, K extends keyof TEventMap>(store: EventfulEngineStore<TEventMap>, eventName: K, handler: (payload: TEventMap[K]) => void): void;
@@ -0,0 +1,14 @@
1
+ import { useCallback, useEffect, useRef, useSyncExternalStore } from "react";
2
+ export function useEngineState(store) {
3
+ const subscribe = useCallback((onChange) => store.subscribe(() => onChange()), [store]);
4
+ const getSnapshot = useCallback(() => store.getState(), [store]);
5
+ return useSyncExternalStore(subscribe, getSnapshot, getSnapshot);
6
+ }
7
+ export function useEngineStore(store, selector) {
8
+ return selector(useEngineState(store));
9
+ }
10
+ export function useEngineEvent(store, eventName, handler) {
11
+ const handlerRef = useRef(handler);
12
+ handlerRef.current = handler;
13
+ useEffect(() => store.on(eventName, (payload) => handlerRef.current(payload)), [store, eventName]);
14
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jgengine/react",
3
- "version": "0.4.0",
3
+ "version": "0.5.0",
4
4
  "description": "React UI layer for JGengine: GameProvider, hooks, and headless primitives over @jgengine/core.",
5
5
  "license": "AGPL-3.0-only",
6
6
  "type": "module",
@@ -10,7 +10,10 @@
10
10
  "url": "git+https://github.com/Noisemaker111/jgengine.git",
11
11
  "directory": "packages/react"
12
12
  },
13
- "files": ["dist"],
13
+ "files": [
14
+ "dist",
15
+ "CHANGELOG.md"
16
+ ],
14
17
  "exports": {
15
18
  "./*": {
16
19
  "types": "./dist/*.d.ts",
@@ -22,7 +25,7 @@
22
25
  "check-types": "tsgo --noEmit -p tsconfig.json"
23
26
  },
24
27
  "dependencies": {
25
- "@jgengine/core": "^0.4.0"
28
+ "@jgengine/core": "^0.5.0"
26
29
  },
27
30
  "peerDependencies": {
28
31
  "react": "^19.0.0"