@four-leaf-studios/rl-overlay 1.0.5 → 1.1.1
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/.github/copilot-instructions.md +70 -0
- package/dist/index.cjs.js +298 -10599
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.esm.js +328 -10612
- package/dist/index.esm.js.map +1 -1
- package/dist/types/Overlay.d.ts +5 -6
- package/dist/types/OverlaySlot.d.ts +9 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/registry.d.ts +2 -0
- package/package.json +12 -5
- package/src/Overlay.tsx +47 -41
- package/src/OverlaySlot.tsx +35 -0
- package/src/Player.tsx +1 -0
- package/src/PlayerBoost.tsx +4 -1
- package/src/Scoreboard.tsx +1 -0
- package/src/ScoreboardGameBox.tsx +2 -4
- package/src/ScoreboardSeriesBox.tsx +2 -3
- package/src/ScoreboardTeam.tsx +1 -0
- package/src/StatItem.tsx +4 -1
- package/src/TargetBoost.tsx +1 -0
- package/src/TargetPlayer.tsx +1 -0
- package/src/TargetPlayerLocation.tsx +1 -0
- package/src/TargetPlayerStats.tsx +1 -1
- package/src/Team.tsx +1 -0
- package/src/Timer.tsx +7 -4
- package/src/css/Florida_Tech.css +696 -0
- package/src/css/Horizon_Hues.css +618 -0
- package/src/css/Neo_Glass.css +674 -0
- package/src/css/Obsidian_Glide.css +646 -0
- package/src/css/RLCS_2024.css +566 -0
- package/src/css/RLCS_2025.css +524 -0
- package/src/css/Shaded_blocks.css +594 -0
- package/src/index.ts +2 -0
- package/src/registry.ts +19 -0
- package/src/types.d.ts +20 -0
- package/test-overlay/package-lock.json +2697 -0
- package/test-overlay/package.json +3 -0
- package/test-overlay/public/mock-css.css +259 -386
- package/test-overlay/src/App.jsx +78 -28
- package/tests/BroadcastContext.test.tsx +41 -0
- package/tests/Overlay.test.tsx +106 -0
- package/tests/OverlaySlot.test.tsx +79 -0
- package/tests/PlayerBoost.test.tsx +47 -0
- package/tests/Replay.test.tsx +29 -0
- package/tests/ScoreboardGameBox.test.tsx +35 -0
- package/tests/ScoreboardSeriesBox.test.tsx +48 -0
- package/tests/StatItem.test.tsx +33 -0
- package/tests/__mocks__/@four-leaf-studios/rl-socket-hook.ts +10 -0
- package/tests/fixtures.ts +96 -0
- package/tests/registry.test.ts +27 -0
- package/tests/setup.ts +1 -0
- package/tsconfig.json +16 -20
- package/vitest.config.ts +9 -0
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# RL Overlay – Copilot Instructions
|
|
2
|
+
|
|
3
|
+
This is a React component library for Rocket League broadcast overlays, published as `@four-leaf-studios/rl-overlay`.
|
|
4
|
+
|
|
5
|
+
## Architecture
|
|
6
|
+
|
|
7
|
+
- **Library entry:** `src/index.ts` re-exports all public components, hooks, types, and the registry.
|
|
8
|
+
- **Component registry:** `src/registry.ts` maps `code_id` strings to React components. The `Overlay` component resolves components from this registry at runtime.
|
|
9
|
+
- **Context:** `BroadcastContext` provides broadcast data (teams, scores, series info) to all child components.
|
|
10
|
+
- **Hooks:** Custom hooks in `src/hooks/` consume the `@four-leaf-studios/rl-socket-hook` package for live game state.
|
|
11
|
+
- **Styling:** CSS files in `src/css/` are theme presets. Components use className-based styling with left/right team modifiers.
|
|
12
|
+
|
|
13
|
+
## Conventions
|
|
14
|
+
|
|
15
|
+
### Adding a New Component
|
|
16
|
+
|
|
17
|
+
1. Create `src/MyComponent.tsx` with a named export and a default export.
|
|
18
|
+
2. Use the pattern: `export const MyComponent = ...` + `export default MyComponent;` (or `memo(MyComponent)`).
|
|
19
|
+
3. Add the component to `src/registry.ts` if it should be renderable via overlay configuration.
|
|
20
|
+
4. Re-export from `src/index.ts`.
|
|
21
|
+
5. Add a test in `tests/MyComponent.test.tsx`.
|
|
22
|
+
|
|
23
|
+
### Component Patterns
|
|
24
|
+
|
|
25
|
+
- Props types are defined inline in the component file (not in `types.d.ts` unless shared).
|
|
26
|
+
- Use `data-component-id="ComponentName"` on the root element for debugging/targeting.
|
|
27
|
+
- Team-specific styling uses a `modifier` variable: `const modifier = team === 0 ? "left" : "right";`
|
|
28
|
+
- Animations use `framer-motion` with `AnimatePresence` for enter/exit transitions.
|
|
29
|
+
- Components that depend on game state should return `null` when data is unavailable.
|
|
30
|
+
- Use `memo()` for components that receive primitive props or are rendered in lists.
|
|
31
|
+
|
|
32
|
+
### Hooks
|
|
33
|
+
|
|
34
|
+
- Hooks consume `useEventSelector` or `useEvent` from `@four-leaf-studios/rl-socket-hook`.
|
|
35
|
+
- Always handle the case where state is `null`/`undefined` (game not yet initialized).
|
|
36
|
+
- Export hooks as default exports; re-export from `src/hooks/index.ts`.
|
|
37
|
+
|
|
38
|
+
### Types
|
|
39
|
+
|
|
40
|
+
- Shared domain types (`Broadcast`, `Team`, `Player`, `OverlayObject`, etc.) live in `src/types.d.ts`.
|
|
41
|
+
- Component-specific prop types stay in their component file.
|
|
42
|
+
|
|
43
|
+
### Testing
|
|
44
|
+
|
|
45
|
+
- Tests live in `tests/` using Vitest + React Testing Library.
|
|
46
|
+
- Mock `@four-leaf-studios/rl-socket-hook` via `vi.mock()` in tests that render components using game state hooks.
|
|
47
|
+
- Mock `framer-motion` when testing structure/content (not animation behavior).
|
|
48
|
+
- Use `tests/fixtures.ts` for shared mock data (`mockBroadcast`, `mockOverlay`, `mockPlayerState`).
|
|
49
|
+
- Run tests: `npm test` (single run) or `npm run test:watch` (watch mode).
|
|
50
|
+
|
|
51
|
+
### CSS / Theming
|
|
52
|
+
|
|
53
|
+
- Each CSS theme file in `src/css/` is self-contained.
|
|
54
|
+
- Class names follow the pattern: `{element}_{descriptor}` with optional `{side}_{element}_{descriptor}` for team-specific styles.
|
|
55
|
+
- Team color CSS variables are injected by `useOverlayStyles` hook: `--team-left-primary`, `--team-right-primary`, etc.
|
|
56
|
+
- Components can use `--team-color` as an inline CSS variable for per-component team coloring.
|
|
57
|
+
|
|
58
|
+
### Build
|
|
59
|
+
|
|
60
|
+
- Rollup bundles to CJS + ESM in `dist/`.
|
|
61
|
+
- CSS is inlined (not extracted) — each component's CSS is injected via `<style>` tags at runtime.
|
|
62
|
+
- React and React DOM are peer dependencies (not bundled).
|
|
63
|
+
|
|
64
|
+
## Do NOT
|
|
65
|
+
|
|
66
|
+
- Add runtime dependencies without discussion — this is a lightweight overlay library.
|
|
67
|
+
- Put component-specific types in `types.d.ts` — only shared domain types belong there.
|
|
68
|
+
- Skip null checks on game state — the websocket data arrives asynchronously.
|
|
69
|
+
- Use inline styles for theming — use CSS classes and CSS variables instead.
|
|
70
|
+
- Forget to register new overlay components in `src/registry.ts`.
|