Initial Commit

This commit is contained in:
2026-05-27 23:29:53 +01:00
commit fbc70f96e6
10000 changed files with 1102152 additions and 0 deletions

View File

@@ -0,0 +1,106 @@
# OpenSpec Change: enterprise-gaming-react-game-settings
- **Change ID**: enterprise-gaming-react-game-settings
- **Package**: `@suaveplan/react-game-settings`
- **Category**: gaming/react
- **Target path**: `gaming/react/react-game-settings`
- **Status**: PROPOSED
- **Date**: 2026-04-24
- **Reference spec**: `/mnt/s/web/suaveplan/enterprise/react-game-settings.md`
---
## Summary
Deliver `@suaveplan/react-game-settings` on the genesis branch from scratch at enterprise quality. The package is a headless React layer for player-configurable game settings. A `SettingsManager` holds typed settings categories (graphics, audio, controls, gameplay) with default values, dirty tracking, and localStorage persistence; `useGameSettings()` provides `useSyncExternalStore` access; typed components expose sliders, toggles, dropdowns, and keybind rows. Genesis adds Zod settings schemas, structured errors, and Storybook stories for all components.
---
## Current-state audit (genesis)
Package does not exist on genesis yet — fresh build.
---
## Available workspace deps on genesis
| Package | Role |
|---|---|
| `@suaveplan/error` (`workspace:^`) | `SettingsError` |
| `@suaveplan/controller` (`workspace:^`) | Keybind capture for controls settings |
| `react` (`catalog:react`) | React 18 |
| `zod` (`catalog:forms`) | Settings schema validation |
---
## Public API surface
```ts
interface GameSettings {
graphics: GraphicsSettings
audio: AudioSettings
controls: ControlsSettings
gameplay: GameplaySettings
}
function createSettingsManager(defaults: GameSettings, options?: SettingsManagerOptions): SettingsManager
interface SettingsManager {
getSnapshot(): GameSettings
subscribe(cb: () => void): () => void
update<K extends keyof GameSettings>(category: K, values: Partial<GameSettings[K]>): void
reset(category?: keyof GameSettings): void
save(): void
load(): void
readonly isDirty: boolean
}
function useGameSettings(): GameSettings & { update: SettingsManager['update']; isDirty: boolean }
// Components
function SettingsPanel(props: SettingsPanelProps): JSX.Element
function SettingsSlider(props: SettingsSliderProps): JSX.Element
function SettingsToggle(props: SettingsToggleProps): JSX.Element
function SettingsDropdown(props: SettingsDropdownProps): JSX.Element
function KeybindRow(props: KeybindRowProps): JSX.Element
```
---
## File layout
```text
gaming/react/react-game-settings/
package.json
tsconfig.json
vitest.config.ts
src/
index.ts
types/common.ts
types/common.md
state/
settings-manager.ts
settings-manager.md
settings-manager.test.ts
hooks/
use-game-settings.ts
use-game-settings.md
use-game-settings.test.ts
components/
settings-panel/
settings-panel.tsx + md + test + stories + index
settings-slider/
settings-slider.tsx + md + test + stories + index
settings-toggle/
settings-toggle.tsx + md + test + stories + index
settings-dropdown/
settings-dropdown.tsx + md + test + stories + index
keybind-row/
keybind-row.tsx + md + test + stories + index
```
---
## Impact
**Downstream**: game apps use settings panel in pause menu. Prerequisites: `@suaveplan/error`, `@suaveplan/controller`, react, zod.

View File

@@ -0,0 +1,39 @@
# Tasks: enterprise-gaming-react-game-settings
## 0. Pre-flight (non-negotiable)
- [ ] 0.1 Confirm clean working tree (`git status` reports nothing) and no in-flight worktrees with uncommitted work (`git worktree list` then `git status` in each)
- [ ] 0.2 If any worktrees exist under `.claude/worktrees/`, account for each one: still-active agent, work-pending-merge, or stale-and-prune. Stale worktrees MUST be removed (`git worktree remove`) before opening a new one — code that has been lost twice on main is the failure mode this guards against.
- [ ] 0.3 Confirm the package set in `MANIFEST.md` matches `find packages -maxdepth 3 -name package.json` count. Drift here means a prior change archived without regenerating the manifest.
## Phase 1 — Scaffold
- [ ] Create `gaming/react/react-game-settings/` (`@suaveplan/react-game-settings`, `0.1.0`, `sideEffects: false`)
- [ ] `tsconfig.json`, `vitest.config.ts`
## Phase 2 — Types + schemas
- [ ] `src/types/common.ts` + `common.md` — `GameSettings`, category interfaces, Zod schemas
## Phase 3 — Settings manager
- [ ] `src/state/settings-manager.ts` — update/reset/save/load (localStorage), dirty flag
- [ ] Tests + docs
## Phase 4 — `useGameSettings` hook
- [ ] Tests + docs
## Phase 5 — Components (each: tsx + md + test + stories)
- [ ] `SettingsPanel` — tabbed category container
- [ ] `SettingsSlider` — min/max/step range input
- [ ] `SettingsToggle` — boolean checkbox/switch
- [ ] `SettingsDropdown` — option select
- [ ] `KeybindRow` — capture mode with `@suaveplan/controller` virtual adapter
## Phase 6 — Pre-publish gate
- [ ] `bunx turbo lint typecheck test --filter=@suaveplan/react-game-settings` green
- [ ] 100% coverage
- [ ] Publish: `bun scripts/publish.ts --package @suaveplan/react-game-settings`